diff options
Diffstat (limited to 'contrib/libpcap')
28 files changed, 1239 insertions, 282 deletions
diff --git a/contrib/libpcap/CHANGES b/contrib/libpcap/CHANGES index 015836d..d187a99 100644 --- a/contrib/libpcap/CHANGES +++ b/contrib/libpcap/CHANGES @@ -1,4 +1,17 @@ -@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.59 2004/03/30 14:42:50 mcr Exp $ (LBL) +@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.59.2.1 2005/07/05 21:04:27 mcr Exp $ (LBL) + +Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.x tcpdump + + Fixes for compiling on nearly every platform, + including improved 64bit support + MSDOS Support + Add support for sending packets + OpenBSD pf format support + IrDA capture (Linux only) + +Tue. May 27, 2005. mcr@sandelman.ottawa.on.ca. Summary for 0.9.1 release + + Numerous fixes for Tue. March 30, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.3 release diff --git a/contrib/libpcap/CREDITS b/contrib/libpcap/CREDITS index 870ec50..6b78ed4 100644 --- a/contrib/libpcap/CREDITS +++ b/contrib/libpcap/CREDITS @@ -33,6 +33,7 @@ Additional people who have contributed patches: Erik de Castro Lopo <erik.de.castro.lopo@sensorynetworks.com> Franz Schaefer <schaefer@mond.at> Gianluca Varenni <varenni@netgroup-serv.polito.it> + Gilbert Hoyek <gil_hoyek@hotmail.com> Gisle Vanem <giva@bgnett.no> Graeme Hewson <ghewson@cix.compulink.co.uk> Greg Stark <gsstark@mit.edu> @@ -58,6 +59,7 @@ Additional people who have contributed patches: Love Hörnquist-Åstrand <lha@stacken.kth.se> Maciej W. Rozycki <macro@ds2.pg.gda.pl> Marcus Felipe Pereira <marcus@task.com.br> + Mark C. Brown <mbrown@hp.com> Mark Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net> Martin Husemann <martin@netbsd.org> Matthew Luckie <mjl@luckie.org.nz> @@ -67,8 +69,10 @@ Additional people who have contributed patches: Octavian Cerna <tavy@ylabs.com> Olaf Kirch <okir@caldera.de> Onno van der Linden <onno@simplex.nl> + Patrick Marie <mycroft@virgaria.org> Paul Mundt <lethal@linux-sh.org> Pavel Kankovsky <kan@dcit.cz> + Pawel Pokrywka <publicpp@gmail.com> Peter Fales <peter@fales-lorenz.net> Peter Jeremy <peter.jeremy@alcatel.com.au> Phil Wood <cpw@lanl.gov> @@ -81,6 +85,7 @@ Additional people who have contributed patches: Solomon Peachy <pizza@shaftnet.org> Stefan Hudson <hudson@mbay.net> Takashi Yamamoto <yamt@mwd.biglobe.ne.jp> + Tanaka Shin-ya <zstanaka@archer.livedoor.com> Tony Li <tli@procket.com> Torsten Landschoff <torsten@debian.org> Uns Lider <unslider@miranda.org> diff --git a/contrib/libpcap/FILES b/contrib/libpcap/FILES index 95b75cf..879d74b 100644 --- a/contrib/libpcap/FILES +++ b/contrib/libpcap/FILES @@ -12,6 +12,7 @@ README.dag README.hpux README.linux README.macosx +README.septel README.tru64 README.Win32 SUNOS4/nit_if.o.sparc @@ -87,6 +88,8 @@ pcap-nit.h pcap-null.c pcap-pf.c pcap-pf.h +pcap-septel.c +pcap-septel.h pcap-stdinc.h pcap-snit.c pcap-snoop.c @@ -96,7 +99,6 @@ pcap.c pcap.h pf.h ppp.h -rawss7.h savefile.c scanner.l sll.h diff --git a/contrib/libpcap/INSTALL.txt b/contrib/libpcap/INSTALL.txt index 2f9075d..d2c0180 100644 --- a/contrib/libpcap/INSTALL.txt +++ b/contrib/libpcap/INSTALL.txt @@ -1,4 +1,4 @@ -@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.12 2004/12/18 08:52:08 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.12.2.1 2005/06/20 21:30:14 guy Exp $ (LBL) To build libpcap, run "./configure" (a shell script). The configure script will determine your system attributes and generate an @@ -308,6 +308,7 @@ README.dag - notes on using libpcap to capture on Endace DAG devices README.hpux - notes on using libpcap on HP-UX README.linux - notes on using libpcap on Linux README.macosx - notes on using libpcap on Mac OS X +README.septel - notes on using libpcap to capture on Intel/Septel devices README.tru64 - notes on using libpcap on Digital/Tru64 UNIX README.Win32 - notes on using libpcap on Win32 systems (with WinPcap) SUNOS4 - pre-SunOS 4.1 replacement kernel nit modules @@ -363,6 +364,8 @@ pcap-nit.h - SunOS Network Interface Tap definitions pcap-null.c - dummy monitor support (allows offline use of libpcap) pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions +pcap-septel.c - INTEL/Septel device capture support +pcap-septel.h - INTEL/Septel device capture support pcap-stdinc.h - includes and #defines for compiling on Win32 systems pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support pcap-snoop.c - IRIX Snoop network monitoring support diff --git a/contrib/libpcap/README.septel b/contrib/libpcap/README.septel new file mode 100644 index 0000000..fbc88df --- /dev/null +++ b/contrib/libpcap/README.septel @@ -0,0 +1,50 @@ +The following instructions apply if you have a Linux platform and want +libpcap to support the Septel range of passive network monitoring cards +from Intel (http://www.intel.com) + +1) Install and build the Septel software distribution by following the +instructions supplied with that package. + +2) Configure libcap. To allow the 'configure' script to locate the Septel +software distribution use the '--with-septel' option: + + ./configure --with-septel=DIR + +where DIR is the root of the Septel software distribution, for example +/var/src/septel. + +By default (if you write only ./configure --with-septel) it takes +./../septel as argument for DIR. + +If the Septel software is correctly detected 'configure' will +report: + + checking whether we have Septel API... yes + +If 'configure' reports that there is no Septel API, the directory may have been +incorrectly specified or the Septel software was not built before configuring +libpcap. + +See also the libpcap INSTALL.txt file for further libpcap configuration +options. + +Building libpcap at this stage will include support for both the native +packet capture stream and for capturing from Septel cards. To build +libpcap with only Septel support specify the capture type as 'septel' +when configuring libpcap: + + ./configure --with-septel=DIR --with-pcap=septel + +Applications built with libpcap configured in this way will only detect Septel +cards and will not capture from the native OS packet stream. + +Note: As mentioned in pcap-septel.c we should first edit the system.txt +file to change the user part example (UPE) module id to 0xdd instead of +0x2d for technical reason. So this change in system.txt is crutial and +things will go wrong if it's not done. System.txt along with config.txt +are configuration files that are edited by the user before running the +gctload program that uses these files for initialising modules and +configuring parameters. + +---------------------------------------------------------------------- +for more information please contact me : gil_hoyek@hotmail.com diff --git a/contrib/libpcap/VERSION b/contrib/libpcap/VERSION index e80fc25..f374f66 100644 --- a/contrib/libpcap/VERSION +++ b/contrib/libpcap/VERSION @@ -1 +1 @@ -0.9-PRE-CVS +0.9.1 diff --git a/contrib/libpcap/config.h.in b/contrib/libpcap/config.h.in index 2ecdbc1..43a6b94 100644 --- a/contrib/libpcap/config.h.in +++ b/contrib/libpcap/config.h.in @@ -23,8 +23,8 @@ /* Define to 1 if you have the `ether_hostton' function. */ #undef HAVE_ETHER_HOSTTON -/* on HP-UX 10.20 */ -#undef HAVE_HPUX10_20 +/* on HP-UX 10.20 or later */ +#undef HAVE_HPUX10_20_OR_LATER /* on HP-UX 9.x */ #undef HAVE_HPUX9 @@ -53,6 +53,9 @@ /* define if you have a /proc/net/dev */ #undef HAVE_PROC_NET_DEV +/* define if you have a Septel API */ +#undef HAVE_SEPTEL_API + /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF @@ -83,6 +86,9 @@ /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY +/* Define to 1 if the system has the type `struct ether_addr'. */ +#undef HAVE_STRUCT_ETHER_ADDR + /* Define to 1 if you have the <sys/bufmod.h> header file. */ #undef HAVE_SYS_BUFMOD_H diff --git a/contrib/libpcap/configure b/contrib/libpcap/configure index ba01786..42b8153 100755 --- a/contrib/libpcap/configure +++ b/contrib/libpcap/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.120 . +# From configure.in Revision: 1.120.2.6 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # @@ -855,9 +855,10 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-gcc don't use gcc --with-pcap=TYPE use packet capture TYPE - --with-dag[=DIR] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present) + --with-dag[=DIR] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present) --with-dag-includes=DIR Endace DAG include directory --with-dag-libraries=DIR Endace DAG library directory + --with-septel[=DIR] include Septel support (located in directory DIR, if supplied). default=yes, on Linux, if present --without-flex don't use flex --without-bison don't use bison @@ -2633,10 +2634,6 @@ cat >>conftest.$ac_ext <<_ACEOF #include <stdlib.h> -int -main () -{ - static void foo(void) __attribute__ ((noreturn)); static void @@ -2645,9 +2642,12 @@ foo(void) exit(1); } - ; - return 0; +int +main(int argc, char **argv) +{ + foo(); } + _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 @@ -4416,6 +4416,7 @@ cat >>conftest.$ac_ext <<_ACEOF #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> +#include <arpa/inet.h> struct mbuf; struct rtentry; #include <net/if.h> @@ -4458,26 +4459,14 @@ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_hostton" >&5 echo "${ECHO_T}$ac_cv_have_decl_ether_hostton" >&6 if test $ac_cv_have_decl_ether_hostton = yes; then -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF #define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON _ACEOF -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 0 -_ACEOF - - fi - fi # # Did that succeed? @@ -4688,27 +4677,101 @@ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_hostton" >&5 echo "${ECHO_T}$ac_cv_have_decl_ether_hostton" >&6 if test $ac_cv_have_decl_ether_hostton = yes; then -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 1 + +cat >>confdefs.h <<\_ACEOF +#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON _ACEOF +fi -cat >>confdefs.h <<\_ACEOF -#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON + fi + fi + # + # Is ether_hostton() declared? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, we'll have to declare it ourselves. + # Do we have "struct ether_addr"? + # + echo "$as_me:$LINENO: checking for struct ether_addr" >&5 +echo $ECHO_N "checking for struct ether_addr... $ECHO_C" >&6 +if test "${ac_cv_type_struct_ether_addr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ _ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + +int +main () +{ +if ((struct ether_addr *) 0) + return 0; +if (sizeof (struct ether_addr)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_struct_ether_addr=yes else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_HOSTTON 0 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_struct_ether_addr=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_struct_ether_addr" >&5 +echo "${ECHO_T}$ac_cv_type_struct_ether_addr" >&6 +if test $ac_cv_type_struct_ether_addr = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_ETHER_ADDR 1 _ACEOF fi - fi +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_ETHER_HOSTTON 0 +_ACEOF + + else + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_ETHER_HOSTTON 1 +_ACEOF + fi fi @@ -5433,6 +5496,10 @@ dag) V_DEFS="$V_DEFS -DDAG_ONLY" ;; +septel) + V_DEFS="$V_DEFS -DSEPTEL_ONLY" + ;; + null) { echo "$as_me:$LINENO: WARNING: cannot determine packet capture interface" >&5 echo "$as_me: WARNING: cannot determine packet capture interface" >&2;} @@ -5513,8 +5580,8 @@ fi; case "$V_PCAP" in linux|bpf|dag) # - # We support the DAG API on Linux or BSD, or if we're building a - # DAG-only libpcap. + # We support the DAG API if we're on Linux or BSD, or if we're + # building a DAG-only libpcap. # ;; *) @@ -5540,7 +5607,7 @@ if test "$want_dag" != no; then echo "$as_me:$LINENO: checking whether we have DAG API headers" >&5 echo $ECHO_N "checking whether we have DAG API headers... $ECHO_C" >&6 - # If necessary, set default paths for DAG API headers and libraries. + # If necessary, set default paths for DAG API headers and libraries. if test -z "$dag_root"; then dag_root=/usr/local fi @@ -5560,7 +5627,7 @@ echo $ECHO_N "checking whether we have DAG API headers... $ECHO_C" >&6 if test -r $dag_include_dir/dagapi.h; then ac_cv_lbl_dag_api=yes fi - echo "$as_me:$LINENO: result: $ac_cv_lbl_dag_api ($dag_include_dir)" >&5 + echo "$as_me:$LINENO: result: $ac_cv_lbl_dag_api ($dag_include_dir)" >&5 echo "${ECHO_T}$ac_cv_lbl_dag_api ($dag_include_dir)" >&6 fi @@ -5570,32 +5637,27 @@ if test $ac_cv_lbl_dag_api = yes; then echo $ECHO_N "checking dagapi.o... $ECHO_C" >&6 dagapi_obj=no if test -r $dag_tools_dir/dagapi.o; then - - # 2.4.x. + # 2.4.x. dagapi_obj=$dag_tools_dir/dagapi.o - elif test -r $dag_lib_dir/dagapi.o; then - - # 2.5.x. - dagapi_obj=$dag_lib_dir/dagapi.o - - elif test -r $dag_lib_dir/libdag.a; then - - # 2.5.x. + # 2.5.x. + dagapi_obj=$dag_lib_dir/dagapi.o + elif test -r $dag_lib_dir/libdag.a; then + # 2.5.x. ar x $dag_lib_dir/libdag.a dagapi.o if test -r ./dagapi.o; then dagapi_obj=./dagapi.o fi - fi + fi if test $dagapi_obj = no; then - echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 + echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 echo "${ECHO_T}no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&6 ac_cv_lbl_dag_api=no else echo "$as_me:$LINENO: result: yes ($dagapi_obj)" >&5 echo "${ECHO_T}yes ($dagapi_obj)" >&6 - fi + fi fi if test $ac_cv_lbl_dag_api = yes; then @@ -5604,26 +5666,21 @@ if test $ac_cv_lbl_dag_api = yes; then echo $ECHO_N "checking dagopts.o... $ECHO_C" >&6 dagopts_obj=no if test -r $dag_tools_dir/dagopts.o; then - - # 2.4.x. + # 2.4.x. dagopts_obj=$dag_tools_dir/dagopts.o - elif test -r $dag_lib_dir/dagopts.o; then - - # 2.5.x. - dagopts_obj=$dag_lib_dir/dagopts.o - - elif test -r $dag_lib_dir/libdag.a; then - - # 2.5.x. + # 2.5.x. + dagopts_obj=$dag_lib_dir/dagopts.o + elif test -r $dag_lib_dir/libdag.a; then + # 2.5.x. ar x $dag_lib_dir/libdag.a dagopts.o if test -r ./dagopts.o; then dagopts_obj=./dagopts.o - fi + fi fi if test $dagopts_obj = no; then - echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 + echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&5 echo "${ECHO_T}no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)" >&6 ac_cv_lbl_dag_api=no else @@ -5633,32 +5690,27 @@ echo "${ECHO_T}yes ($dagopts_obj)" >&6 fi if test $ac_cv_lbl_dag_api = yes; then - # Under 2.5.x only we need to add dagreg.o. if test -r $dag_include_dir/dagreg.h; then - - echo "$as_me:$LINENO: checking dagreg.o" >&5 + echo "$as_me:$LINENO: checking dagreg.o" >&5 echo $ECHO_N "checking dagreg.o... $ECHO_C" >&6 - dagreg_obj=no - if test -r $dag_lib_dir/dagreg.o; then - - # Object file is ready and waiting. - dagreg_obj=$dag_lib_dir/dagreg.o - - elif test -r $dag_lib_dir/libdag.a; then - - # Extract from libdag.a. + dagreg_obj=no + if test -r $dag_lib_dir/dagreg.o; then + # Object file is ready and waiting. + dagreg_obj=$dag_lib_dir/dagreg.o + elif test -r $dag_lib_dir/libdag.a; then + # Extract from libdag.a. ar x $dag_lib_dir/libdag.a dagreg.o if test -r ./dagreg.o; then - dagreg_obj=./dagreg.o - fi + dagreg_obj=./dagreg.o + fi fi if test $dagreg_obj = no; then - echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&5 + echo "$as_me:$LINENO: result: no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&5 echo "${ECHO_T}no (checked $dag_lib_dir $dag_lib_dir/libdag.a)" >&6 ac_cv_lbl_dag_api=no - else + else echo "$as_me:$LINENO: result: yes ($dagreg_obj)" >&5 echo "${ECHO_T}yes ($dagreg_obj)" >&6 fi @@ -5666,7 +5718,6 @@ echo "${ECHO_T}yes ($dagreg_obj)" >&6 fi if test $ac_cv_lbl_dag_api = yes; then - V_INCLS="$V_INCLS -I$dag_include_dir" V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj" if test $V_PCAP != dag ; then @@ -5674,7 +5725,8 @@ if test $ac_cv_lbl_dag_api = yes; then fi # See if we can find a general version string. - # Don't need to save and restore LIBS to prevent -ldag being included if there's a found-action (arg 3). + # Don't need to save and restore LIBS to prevent -ldag being + # included if there's a found-action (arg 3). saved_ldflags=$LDFLAGS LDFLAGS="-L$dag_lib_dir" echo "$as_me:$LINENO: checking for dag_attach_stream in -ldag" >&5 @@ -5745,7 +5797,7 @@ echo $ECHO_N "checking the DAG API version... $ECHO_C" >&6 if test -r "$dag_root/VERSION"; then dag_version="`cat $dag_root/VERSION`" fi - echo "$as_me:$LINENO: result: $dag_version" >&5 + echo "$as_me:$LINENO: result: $dag_version" >&5 echo "${ECHO_T}$dag_version" >&6 cat >>confdefs.h <<\_ACEOF @@ -5756,18 +5808,119 @@ fi if test $ac_cv_lbl_dag_api = no; then if test "$want_dag" = yes; then - # User wanted DAG support but we couldn't find it. + # User wanted DAG support but we couldn't find it. { { echo "$as_me:$LINENO: error: DAG API requested, but not found at $dag_root: use --without-dag" >&5 echo "$as_me: error: DAG API requested, but not found at $dag_root: use --without-dag" >&2;} { (exit 1); exit 1; }; } fi - if test "$V_PCAP" = dag; then - # User requested "dag" capture type but the DAG API wasn't found. - { { echo "$as_me:$LINENO: error: Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" >&5 + if test "$V_PCAP" = dag; then + # User requested "dag" capture type but the DAG API wasn't + # found. + { { echo "$as_me:$LINENO: error: Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" >&5 echo "$as_me: error: Specifying the capture type as \"dag\" requires the DAG API to be present; use the --with-dag options to specify the location. (Try \"./configure --help\" for more information.)" >&2;} { (exit 1); exit 1; }; } - fi + fi +fi + + +# Check whether --with-septel or --without-septel was given. +if test "${with_septel+set}" = set; then + withval="$with_septel" + + if test "$withval" = no + then + want_septel=no + elif test "$withval" = yes + then + want_septel=yes + septel_root= + else + want_septel=yes + septel_root=$withval + fi + +else + + # + # Use Septel API if present, otherwise don't + # + want_septel=ifpresent + septel_root=./../septel + +fi; +ac_cv_lbl_septel_api=no +case "$V_PCAP" in +linux|septel) + # + # We support the Septel API if we're on Linux, or if we're building + # a Septel-only libpcap. + # + ;; +*) + # + # If the user explicitly requested Septel, tell them it's not + # supported. + # + # If they expressed no preference, don't include it. + # + if test $want_septel = yes; then + { { echo "$as_me:$LINENO: error: Septel support only available with 'linux' and 'septel' packet capture types" >&5 +echo "$as_me: error: Septel support only available with 'linux' and 'septel' packet capture types" >&2;} + { (exit 1); exit 1; }; } + elif test $want_septel = yes; then + want_septel=no + fi + ;; +esac + +if test "$with_septel" != no; then + echo "$as_me:$LINENO: checking whether we have Septel API" >&5 +echo $ECHO_N "checking whether we have Septel API... $ECHO_C" >&6 + + if test -z "$septel_root"; then + septel_root=$srcdir/../septel + + fi + + septel_tools_dir="$septel_root" + septel_include_dir="$septel_root/INC" + DEF="-DHAVE_SEPTEL_API" + + ac_cv_lbl_septel_api=no + if test -r "$septel_include_dir/msg.h"; then + V_INCLS="$V_INCLS -I$septel_include_dir" + V_DEFS="$V_DEFS $DEF" + V_LIBS="$V_LIBS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o " + + if test "$V_PCAP" != septel ; then + SSRC="pcap-septel.c" + + fi + ac_cv_lbl_septel_api=yes + fi + + echo "$as_me:$LINENO: result: $ac_cv_lbl_septel_api" >&5 +echo "${ECHO_T}$ac_cv_lbl_septel_api" >&6 + if test $ac_cv_lbl_septel_api = no; then + if test "$want_septel" = yes; then + { { echo "$as_me:$LINENO: error: Septel API not found under directory $septel_root; use --without-septel" >&5 +echo "$as_me: error: Septel API not found under directory $septel_root; use --without-septel" >&2;} + { (exit 1); exit 1; }; } + fi + else + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SEPTEL_API 1 +_ACEOF + + fi +fi + +if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then + { { echo "$as_me:$LINENO: error: Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" >&5 +echo "$as_me: error: Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR" >&2;} + { (exit 1); exit 1; }; } fi @@ -5966,7 +6119,7 @@ hpux10.1*) hpux*) cat >>confdefs.h <<\_ACEOF -#define HAVE_HPUX10_20 1 +#define HAVE_HPUX10_20_OR_LATER 1 _ACEOF ;; diff --git a/contrib/libpcap/configure.in b/contrib/libpcap/configure.in index d970fd5..fbc70b8 100755 --- a/contrib/libpcap/configure.in +++ b/contrib/libpcap/configure.in @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.120 2005/03/27 22:26:25 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.120.2.6 2005/06/20 21:37:43 guy Exp $ (LBL) dnl dnl Copyright (c) 1994, 1995, 1996, 1997 dnl The Regents of the University of California. All rights reserved. @@ -6,7 +6,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl -AC_REVISION($Revision: 1.120 $) +AC_REVISION($Revision: 1.120.2.6 $) AC_PREREQ(2.50) AC_INIT(pcap.c) @@ -84,7 +84,7 @@ if test "$ac_cv_func_ether_hostton" = yes; then # # Yes. Does it declare ether_hostton()? # - AC_CHECK_DECLS(ether_hostton, + AC_CHECK_DECL(ether_hostton, [ AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,, [Define to 1 if netinet/if_ether.h declares `ether_hostton']) @@ -93,6 +93,7 @@ if test "$ac_cv_func_ether_hostton" = yes; then #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> +#include <arpa/inet.h> struct mbuf; struct rtentry; #include <net/if.h> @@ -115,7 +116,7 @@ struct rtentry; # suppress the next test. # unset ac_cv_have_decl_ether_hostton - AC_CHECK_DECLS(ether_hostton, + AC_CHECK_DECL(ether_hostton, [ AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,, [Define to 1 if netinet/ether.h declares `ether_hostton']) @@ -125,6 +126,33 @@ struct rtentry; ]) fi fi + # + # Is ether_hostton() declared? + # + if test "$ac_cv_have_decl_ether_hostton" != yes; then + # + # No, we'll have to declare it ourselves. + # Do we have "struct ether_addr"? + # + AC_CHECK_TYPES(struct ether_addr,,, + [ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +struct mbuf; +struct rtentry; +#include <net/if.h> +#include <netinet/if_ether.h> + ]) + AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 0, + [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you +don't.]) + else + AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1, + [Define to 1 if you have the declaration of `ether_hostton', and to 0 if you +don't.]) + fi fi dnl to pacify those who hate protochain insn @@ -338,7 +366,11 @@ linux) dag) V_DEFS="$V_DEFS -DDAG_ONLY" - ;; + ;; + +septel) + V_DEFS="$V_DEFS -DSEPTEL_ONLY" + ;; null) AC_MSG_WARN(cannot determine packet capture interface) @@ -359,7 +391,7 @@ fi AC_MSG_RESULT($ac_cv_lbl_proc_net_dev) # Check for Endace DAG card support. -AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)], +AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)], [ if test "$withval" = no then @@ -398,8 +430,8 @@ AC_ARG_WITH([dag-libraries], [ --with-dag-libraries=DIR Endace DAG library dir case "$V_PCAP" in linux|bpf|dag) # - # We support the DAG API on Linux or BSD, or if we're building a - # DAG-only libpcap. + # We support the DAG API if we're on Linux or BSD, or if we're + # building a DAG-only libpcap. # ;; *) @@ -422,7 +454,7 @@ if test "$want_dag" != no; then AC_MSG_CHECKING([whether we have DAG API headers]) - # If necessary, set default paths for DAG API headers and libraries. + # If necessary, set default paths for DAG API headers and libraries. if test -z "$dag_root"; then dag_root=/usr/local fi @@ -442,7 +474,7 @@ if test "$want_dag" != no; then if test -r $dag_include_dir/dagapi.h; then ac_cv_lbl_dag_api=yes fi - AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)]) + AC_MSG_RESULT([$ac_cv_lbl_dag_api ($dag_include_dir)]) fi if test $ac_cv_lbl_dag_api = yes; then @@ -450,30 +482,25 @@ if test $ac_cv_lbl_dag_api = yes; then AC_MSG_CHECKING([dagapi.o]) dagapi_obj=no if test -r $dag_tools_dir/dagapi.o; then - - # 2.4.x. + # 2.4.x. dagapi_obj=$dag_tools_dir/dagapi.o - elif test -r $dag_lib_dir/dagapi.o; then - - # 2.5.x. - dagapi_obj=$dag_lib_dir/dagapi.o - - elif test -r $dag_lib_dir/libdag.a; then - - # 2.5.x. + # 2.5.x. + dagapi_obj=$dag_lib_dir/dagapi.o + elif test -r $dag_lib_dir/libdag.a; then + # 2.5.x. ar x $dag_lib_dir/libdag.a dagapi.o if test -r ./dagapi.o; then dagapi_obj=./dagapi.o fi - fi + fi if test $dagapi_obj = no; then - AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) ac_cv_lbl_dag_api=no else AC_MSG_RESULT([yes ($dagapi_obj)]) - fi + fi fi if test $ac_cv_lbl_dag_api = yes; then @@ -481,26 +508,21 @@ if test $ac_cv_lbl_dag_api = yes; then AC_MSG_CHECKING([dagopts.o]) dagopts_obj=no if test -r $dag_tools_dir/dagopts.o; then - - # 2.4.x. + # 2.4.x. dagopts_obj=$dag_tools_dir/dagopts.o - elif test -r $dag_lib_dir/dagopts.o; then - - # 2.5.x. - dagopts_obj=$dag_lib_dir/dagopts.o - - elif test -r $dag_lib_dir/libdag.a; then - - # 2.5.x. + # 2.5.x. + dagopts_obj=$dag_lib_dir/dagopts.o + elif test -r $dag_lib_dir/libdag.a; then + # 2.5.x. ar x $dag_lib_dir/libdag.a dagopts.o if test -r ./dagopts.o; then dagopts_obj=./dagopts.o - fi + fi fi if test $dagopts_obj = no; then - AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_tools_dir $dag_lib_dir/libdag.a)]) ac_cv_lbl_dag_api=no else AC_MSG_RESULT([yes ($dagopts_obj)]) @@ -508,37 +530,31 @@ if test $ac_cv_lbl_dag_api = yes; then fi if test $ac_cv_lbl_dag_api = yes; then - # Under 2.5.x only we need to add dagreg.o. if test -r $dag_include_dir/dagreg.h; then - - AC_MSG_CHECKING([dagreg.o]) - dagreg_obj=no - if test -r $dag_lib_dir/dagreg.o; then - - # Object file is ready and waiting. - dagreg_obj=$dag_lib_dir/dagreg.o - - elif test -r $dag_lib_dir/libdag.a; then - - # Extract from libdag.a. + AC_MSG_CHECKING([dagreg.o]) + dagreg_obj=no + if test -r $dag_lib_dir/dagreg.o; then + # Object file is ready and waiting. + dagreg_obj=$dag_lib_dir/dagreg.o + elif test -r $dag_lib_dir/libdag.a; then + # Extract from libdag.a. ar x $dag_lib_dir/libdag.a dagreg.o if test -r ./dagreg.o; then - dagreg_obj=./dagreg.o - fi + dagreg_obj=./dagreg.o + fi fi if test $dagreg_obj = no; then - AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)]) + AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)]) ac_cv_lbl_dag_api=no - else + else AC_MSG_RESULT([yes ($dagreg_obj)]) fi fi fi if test $ac_cv_lbl_dag_api = yes; then - V_INCLS="$V_INCLS -I$dag_include_dir" V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj" if test $V_PCAP != dag ; then @@ -546,7 +562,8 @@ if test $ac_cv_lbl_dag_api = yes; then fi # See if we can find a general version string. - # Don't need to save and restore LIBS to prevent -ldag being included if there's a found-action (arg 3). + # Don't need to save and restore LIBS to prevent -ldag being + # included if there's a found-action (arg 3). saved_ldflags=$LDFLAGS LDFLAGS="-L$dag_lib_dir" AC_CHECK_LIB([dag], [dag_attach_stream], [dag_version="2.5.x"], [dag_version="2.4.x"]) @@ -557,20 +574,103 @@ if test $ac_cv_lbl_dag_api = yes; then if test -r "$dag_root/VERSION"; then dag_version="`cat $dag_root/VERSION`" fi - AC_MSG_RESULT([$dag_version]) + AC_MSG_RESULT([$dag_version]) AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API]) fi if test $ac_cv_lbl_dag_api = no; then if test "$want_dag" = yes; then - # User wanted DAG support but we couldn't find it. + # User wanted DAG support but we couldn't find it. AC_MSG_ERROR([DAG API requested, but not found at $dag_root: use --without-dag]) fi - if test "$V_PCAP" = dag; then - # User requested "dag" capture type but the DAG API wasn't found. - AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)]) - fi + if test "$V_PCAP" = dag; then + # User requested "dag" capture type but the DAG API wasn't + # found. + AC_MSG_ERROR([Specifying the capture type as "dag" requires the DAG API to be present; use the --with-dag options to specify the location. (Try "./configure --help" for more information.)]) + fi +fi + +AC_ARG_WITH(septel, [ --with-septel[[=DIR]] include Septel support (located in directory DIR, if supplied). [default=yes, on Linux, if present]], +[ + if test "$withval" = no + then + want_septel=no + elif test "$withval" = yes + then + want_septel=yes + septel_root= + else + want_septel=yes + septel_root=$withval + fi +],[ + # + # Use Septel API if present, otherwise don't + # + want_septel=ifpresent + septel_root=./../septel +]) +ac_cv_lbl_septel_api=no +case "$V_PCAP" in +linux|septel) + # + # We support the Septel API if we're on Linux, or if we're building + # a Septel-only libpcap. + # + ;; +*) + # + # If the user explicitly requested Septel, tell them it's not + # supported. + # + # If they expressed no preference, don't include it. + # + if test $want_septel = yes; then + AC_MSG_ERROR(Septel support only available with 'linux' and 'septel' packet capture types) + elif test $want_septel = yes; then + want_septel=no + fi + ;; +esac + +if test "$with_septel" != no; then + AC_MSG_CHECKING(whether we have Septel API) + + if test -z "$septel_root"; then + septel_root=$srcdir/../septel + + fi + + septel_tools_dir="$septel_root" + septel_include_dir="$septel_root/INC" + DEF="-DHAVE_SEPTEL_API" + + ac_cv_lbl_septel_api=no + if test -r "$septel_include_dir/msg.h"; then + V_INCLS="$V_INCLS -I$septel_include_dir" + V_DEFS="$V_DEFS $DEF" + V_LIBS="$V_LIBS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o " + + if test "$V_PCAP" != septel ; then + SSRC="pcap-septel.c" + + fi + ac_cv_lbl_septel_api=yes + fi + + AC_MSG_RESULT($ac_cv_lbl_septel_api) + if test $ac_cv_lbl_septel_api = no; then + if test "$want_septel" = yes; then + AC_MSG_ERROR(Septel API not found under directory $septel_root; use --without-septel) + fi + else + AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have a Septel API]) + fi +fi + +if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then + AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR) fi @@ -617,7 +717,7 @@ hpux*) dnl XXX - DYEXT should be set to "sl" if this is building dnl for 32-bit PA-RISC, but should be left as "so" for dnl 64-bit PA-RISC or, I suspect, IA-64. - AC_DEFINE(HAVE_HPUX10_20,1,[on HP-UX 10.20]) + AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later]) ;; sinix*) diff --git a/contrib/libpcap/fad-getad.c b/contrib/libpcap/fad-getad.c index e9ec409..58305d5 100644 --- a/contrib/libpcap/fad-getad.c +++ b/contrib/libpcap/fad-getad.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/fad-getad.c,v 1.10 2004/11/04 07:26:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/fad-getad.c,v 1.10.2.1 2005/04/10 18:04:49 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -47,9 +47,11 @@ static const char rcsid[] _U_ = #include <net/if.h> +#include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <ifaddrs.h> #include "pcap-int.h" @@ -137,6 +139,7 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) struct sockaddr *addr, *netmask, *broadaddr, *dstaddr; size_t addr_size, broadaddr_size, dstaddr_size; int ret = 0; + char *p, *q; /* * Get the list of interface addresses. @@ -215,6 +218,35 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) } /* + * If this entry has a colon followed by a number at + * the end, we assume it's a logical interface. Those + * are just the way you assign multiple IP addresses to + * a real interface on Linux, so an entry for a logical + * interface should be treated like the entry for the + * real interface; we do that by stripping off the ":" + * and the number. + * + * XXX - should we do this only on Linux? + */ + p = strchr(ifa->ifa_name, ':'); + if (p != NULL) { + /* + * We have a ":"; is it followed by a number? + */ + q = p + 1; + while (isdigit((unsigned char)*q)) + q++; + if (*q == '\0') { + /* + * All digits after the ":" until the end. + * Strip off the ":" and everything after + * it. + */ + *p = '\0'; + } + } + + /* * Add information for this address to the list. */ if (add_addr_to_iflist(&devlist, ifa->ifa_name, diff --git a/contrib/libpcap/fad-gifc.c b/contrib/libpcap/fad-gifc.c index 4ed02f9..985d2c0 100644 --- a/contrib/libpcap/fad-gifc.c +++ b/contrib/libpcap/fad-gifc.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/fad-gifc.c,v 1.8 2005/01/29 10:34:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/fad-gifc.c,v 1.8.2.2 2005/06/29 06:43:31 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -102,6 +102,27 @@ struct rtentry; /* declarations in <net/if.h> */ #endif /* HAVE_SOCKADDR_SA_LEN */ #endif /* SA_LEN */ +/* + * This is also fun. + * + * There is no ioctl that returns the amount of space required for all + * the data that SIOCGIFCONF could return, and if a buffer is supplied + * that's not large enough for all the data SIOCGIFCONF could return, + * on at least some platforms it just returns the data that'd fit with + * no indication that there wasn't enough room for all the data, much + * less an indication of how much more room is required. + * + * The only way to ensure that we got all the data is to pass a buffer + * large enough that the amount of space in the buffer *not* filled in + * is greater than the largest possible entry. + * + * We assume that's "sizeof(ifreq.ifr_name)" plus 255, under the assumption + * that no address is more than 255 bytes (on systems where the "sa_len" + * field in a "struct sockaddr" is 1 byte, e.g. newer BSDs, that's the + * case, and addresses are unlikely to be bigger than that in any case). + */ +#define MAX_SA_LEN 255 + #ifdef HAVE_PROC_NET_DEV /* * Get from "/proc/net/dev" all interfaces listed there; if they're @@ -255,7 +276,7 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) struct ifconf ifc; char *buf = NULL; unsigned buf_size; -#ifdef HAVE_SOLARIS +#if defined (HAVE_SOLARIS) || defined (HAVE_HPUX10_20_OR_LATER) char *p, *q; #endif struct ifreq ifrflags, ifrnetmask, ifrbroadaddr, ifrdstaddr; @@ -275,9 +296,10 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) /* * Start with an 8K buffer, and keep growing the buffer until - * we get the entire interface list or fail to get it for some - * reason other than EINVAL (which is presumed here to mean - * "buffer is too small"). + * we have more than "sizeof(ifrp->ifr_name) + MAX_SA_LEN" + * bytes left over in the buffer or we fail to get the + * interface list for some reason other than EINVAL (which is + * presumed here to mean "buffer is too small"). */ buf_size = 8192; for (;;) { @@ -300,7 +322,8 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) free(buf); return (-1); } - if (ifc.ifc_len < buf_size) + if (ifc.ifc_len < buf_size && + (buf_size - ifc.ifc_len) > sizeof(ifrp->ifr_name) + MAX_SA_LEN) break; free(buf); buf_size *= 2; @@ -474,7 +497,7 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) dstaddr_size = 0; } -#ifdef HAVE_SOLARIS +#if defined (HAVE_SOLARIS) || defined (HAVE_HPUX10_20_OR_LATER) /* * If this entry has a colon followed by a number at * the end, it's a logical interface. Those are just diff --git a/contrib/libpcap/fad-glifc.c b/contrib/libpcap/fad-glifc.c index 8ad7a6c..8a86a3d 100644 --- a/contrib/libpcap/fad-glifc.c +++ b/contrib/libpcap/fad-glifc.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/fad-glifc.c,v 1.5 2005/01/29 10:34:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/fad-glifc.c,v 1.5.2.1 2005/04/19 00:54:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -326,7 +326,7 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) * be treated like the entry for the real interface; * we do that by stripping off the ":" and the number. */ - p = strchr(ifrp->ifr_name, ':'); + p = strchr(ifrp->lifr_name, ':'); if (p != NULL) { /* * We have a ":"; is it followed by a number? diff --git a/contrib/libpcap/inet.c b/contrib/libpcap/inet.c index 561781a..fb05b76 100644 --- a/contrib/libpcap/inet.c +++ b/contrib/libpcap/inet.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66 2005/02/10 19:38:06 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.66.2.1 2005/06/20 21:30:17 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -539,6 +539,9 @@ pcap_lookupnet(device, netp, maskp, errbuf) #ifdef HAVE_DAG_API || strstr(device, "dag") != NULL #endif +#ifdef HAVE_SEPTEL_API + || strstr(device, "septel") != NULL +#endif ) { *netp = *maskp = 0; return 0; diff --git a/contrib/libpcap/pcap-bpf.c b/contrib/libpcap/pcap-bpf.c index 085f181..ccf9d73 100644 --- a/contrib/libpcap/pcap-bpf.c +++ b/contrib/libpcap/pcap-bpf.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.86 2005/02/26 21:58:05 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.86.2.4 2005/06/04 02:53:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -59,7 +59,7 @@ static const char rcsid[] _U_ = #include <net/if_types.h> /* for IFT_ values */ #include <sys/sysconfig.h> #include <sys/device.h> -#include <odmi.h> +#include <sys/cfgodm.h> #include <cf.h> #ifdef __64BIT__ @@ -105,6 +105,7 @@ static int odmlockid = 0; #include "gencode.h" /* for "no_optimize" */ static int pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp); +static int pcap_setdirection_bpf(pcap_t *, direction_t); static int pcap_set_datalink_bpf(pcap_t *p, int dlt); static int @@ -729,7 +730,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, #endif #ifdef PCAP_FDDIPAD if (v == DLT_FDDI) - p->fddipad = PCAP_FDDIPAD: + p->fddipad = PCAP_FDDIPAD; else p->fddipad = 0; #endif @@ -996,29 +997,30 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, * there (and in sufficiently recent versions of OpenBSD * "select()" and "poll()" should work correctly). * + * In addition, in Mac OS X 10.4, "select()" and "poll()" don't + * work on *any* character devices, including BPF devices. + * * XXX - what about AIX? */ + p->selectable_fd = p->fd; /* assume select() works until we know otherwise */ if (uname(&osinfo) == 0) { /* * We can check what OS this is. */ - if (strcmp(osinfo.sysname, "FreeBSD") == 0 && - (strncmp(osinfo.release, "4.3-", 4) == 0 || - strncmp(osinfo.release, "4.4-", 4) == 0)) - p->selectable_fd = -1; - else - p->selectable_fd = p->fd; - } else { - /* - * We can't find out what OS this is, so assume we can - * do a "select()" or "poll()". - */ - p->selectable_fd = p->fd; + if (strcmp(osinfo.sysname, "FreeBSD") == 0) { + if (strncmp(osinfo.release, "4.3-", 4) == 0 || + strncmp(osinfo.release, "4.4-", 4) == 0) + p->selectable_fd = -1; + } else if (strcmp(osinfo.sysname, "Darwin") == 0) { + if (strncmp(osinfo.release, "8.", 2) == 0) + p->selectable_fd = -1; + } } p->read_op = pcap_read_bpf; p->inject_op = pcap_inject_bpf; p->setfilter_op = pcap_setfilter_bpf; + p->setdirection_op = pcap_setdirection_bpf; p->set_datalink_op = pcap_set_datalink_bpf; p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; @@ -1088,6 +1090,42 @@ pcap_setfilter_bpf(pcap_t *p, struct bpf_program *fp) return (0); } +/* + * Set direction flag: Which packets do we accept on a forwarding + * single device? IN, OUT or both? + */ +static int +pcap_setdirection_bpf(pcap_t *p, direction_t d) +{ +#ifdef BIOCSSEESENT + u_int seesent; +#endif + + /* + * We don't support D_OUT. + */ + if (d == D_OUT) { + snprintf(p->errbuf, sizeof(p->errbuf), + "Setting direction to D_OUT is not supported on BPF"); + return -1; + } +#ifdef BIOCSSEESENT + seesent = (d == D_INOUT); + if (ioctl(p->fd, BIOCSSEESENT, &seesent) == -1) { + (void) snprintf(p->errbuf, sizeof(p->errbuf), + "Cannot set direction to %s: %s", + (d == D_INOUT) ? "D_INOUT" : "D_IN", + strerror(errno)); + return (-1); + } + return (0); +#else + (void) snprintf(p->errbuf, sizeof(p->errbuf), + "This system doesn't support BIOCSSEESENT, so the direction can't be set"); + return (-1); +#endif +} + static int pcap_set_datalink_bpf(pcap_t *p, int dlt) { diff --git a/contrib/libpcap/pcap-bpf.h b/contrib/libpcap/pcap-bpf.h index deb15ac..9811613 100644 --- a/contrib/libpcap/pcap-bpf.h +++ b/contrib/libpcap/pcap-bpf.h @@ -37,7 +37,7 @@ * * @(#)bpf.h 7.1 (Berkeley) 5/7/91 * - * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34 2005/02/08 20:03:15 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.5 2005/05/27 23:33:00 guy Exp $ (LBL) */ /* @@ -147,7 +147,7 @@ struct bpf_version { * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, * but I don't know what the right #define is for BSD/OS. */ -#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */ +#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */ #ifdef __OpenBSD__ #define DLT_RAW 14 /* raw IP */ @@ -423,8 +423,13 @@ struct bpf_version { #define DLT_APPLE_IP_OVER_IEEE1394 138 /* - * 139 through 142 are reserved for SS7. + * Various SS7 encapsulations, as per a request from Jeff Morriss + * <jeff.morriss[AT]ulticom.com> and subsequent discussions. */ +#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ +#define DLT_MTP2 140 /* MTP2, without pseudo-header */ +#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ +#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ /* * DOCSIS MAC frames. @@ -581,6 +586,14 @@ struct bpf_version { #define DLT_ERF_POS 176 /* Packet-over-SONET */ /* + * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define DLT_LINUX_LAPD 177 + +/* * The instruction encodings. */ /* instruction classes */ diff --git a/contrib/libpcap/pcap-dag.c b/contrib/libpcap/pcap-dag.c index a30f970..0587856 100644 --- a/contrib/libpcap/pcap-dag.c +++ b/contrib/libpcap/pcap-dag.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.21 2005/04/03 23:56:47 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.21.2.1 2005/05/03 18:54:35 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -507,6 +507,7 @@ dag_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebu handle->read_op = dag_read; handle->inject_op = dag_inject; handle->setfilter_op = dag_setfilter; + handle->setdirection_op = NULL; /* Not implemented.*/ handle->set_datalink_op = dag_set_datalink; handle->getnonblock_op = pcap_getnonblock_fd; handle->setnonblock_op = dag_setnonblock; diff --git a/contrib/libpcap/pcap-dlpi.c b/contrib/libpcap/pcap-dlpi.c index c927629..a9a4dc3 100644 --- a/contrib/libpcap/pcap-dlpi.c +++ b/contrib/libpcap/pcap-dlpi.c @@ -20,8 +20,9 @@ * * This code contributed by Atanu Ghosh (atanu@cs.ucl.ac.uk), * University College London, and subsequently modified by - * Guy Harris (guy@alum.mit.edu) and Mark Pizzolato - * <List-tcpdump-workers@subscriptions.pizzolato.net>. + * Guy Harris (guy@alum.mit.edu), Mark Pizzolato + * <List-tcpdump-workers@subscriptions.pizzolato.net>, + * and Mark C. Brown (mbrown@hp.com). */ /* @@ -37,7 +38,8 @@ * - It might be desirable to use pfmod(7) to filter packets in the * kernel when possible. * - * - The HP-UX 10.20 DLPI Programmer's Guide used to be available + * - An older version of the HP-UX DLPI Programmer's Guide, which + * I think was advertised as the 10.20 version, used to be available * at * * http://docs.hp.com/hpux/onlinedocs/B2355-90093/B2355-90093.html @@ -48,21 +50,27 @@ * * in PDF form. * - * - The HP-UX 11.00 DLPI Programmer's Guide is available at + * - The HP-UX 10.x, 11.0, and 11i v1.6 version of the HP-UX DLPI + * Programmer's Guide, which I think was once advertised as the + * 11.00 version is available at * - * http://docs.hp.com/hpux/onlinedocs/B2355-90139/B2355-90139.html + * http://docs.hp.com/en/B2355-90139/index.html * - * and in PDF form at + * - The HP-UX 11i v2 version of the HP-UX DLPI Programmer's Guide + * is available at * - * http://h21007.www2.hp.com/dspp/files/unprotected/Drivers/Docs/Refs/B2355-90139.pdf + * http://docs.hp.com/en/B2355-90871/index.html * - * - Both of the HP documents describe raw-mode services, which are - * what we use if DL_HP_RAWDLS is defined. + * - All of the HP documents describe raw-mode services, which are + * what we use if DL_HP_RAWDLS is defined. XXX - we use __hpux + * in some places to test for HP-UX, but use DL_HP_RAWDLS in + * other places; do we support any versions of HP-UX without + * DL_HP_RAWDLS? */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.108 2004/10/19 07:06:12 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.108.2.5 2005/05/03 18:54:35 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -158,9 +166,12 @@ static const char rcsid[] _U_ = /* Forwards */ static char *split_dname(char *, int *, char *); static int dl_doattach(int, int, char *); +#ifdef DL_HP_RAWDLS +static int dl_dohpuxbind(int, char *); +#endif static int dlattachreq(int, bpf_u_int32, char *); static int dlbindreq(int, bpf_u_int32, char *); -static int dlbindack(int, char *, char *); +static int dlbindack(int, char *, char *, int *); static int dlpromisconreq(int, bpf_u_int32, char *); static int dlokack(int, const char *, char *, char *); static int dlinforeq(int, char *); @@ -168,7 +179,7 @@ static int dlinfoack(int, char *, char *); #ifdef DL_HP_RAWDLS static int dlrawdatareq(int, const u_char *, int); #endif -static int recv_ack(int, int, const char *, char *, char *); +static int recv_ack(int, int, const char *, char *, char *, int *); static char *dlstrerror(bpf_u_int32); static char *dlprim(bpf_u_int32); #if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H) @@ -411,7 +422,7 @@ pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size) ret = -1; #endif /* raw mode */ return (ret); -} +} #ifndef DL_IPATM #define DL_IPATM 0x12 /* ATM Classical IP interface */ @@ -510,9 +521,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, #ifdef DL_HP_RAWDLS /* * XXX - HP-UX 10.20 and 11.xx don't appear to support sending and - * receiving packets on the same descriptor - you have to bind the - * descriptor on which you receive to a SAP of 22 and bind the - * descriptor on which you send to a SAP of 24. + * receiving packets on the same descriptor - you need separate + * descriptors for sending and receiving, bound to different SAPs. * * If the open fails, we just leave -1 in "p->send_fd" and reject * attempts to send packets, just as if, in pcap-bpf.c, we fail @@ -622,12 +632,14 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, } /* - ** Bind (defer if using HP-UX 9 or HP-UX 10.20, totally skip if - ** using SINIX) + ** Bind (defer if using HP-UX 9 or HP-UX 10.20 or later, totally + ** skip if using SINIX) */ -#if !defined(HAVE_HPUX9) && !defined(HAVE_HPUX10_20) && !defined(sinix) +#if !defined(HAVE_HPUX9) && !defined(HAVE_HPUX10_20_OR_LATER) && !defined(sinix) #ifdef _AIX - /* According to IBM's AIX Support Line, the dl_sap value + /* + ** AIX. + ** According to IBM's AIX Support Line, the dl_sap value ** should not be less than 0x600 (1536) for standard Ethernet. ** However, we seem to get DL_BADADDR - "DLSAP addr in improper ** format or invalid" - errors if we use 1537 on the "tr0" @@ -645,34 +657,33 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, */ if ((dlbindreq(p->fd, 1537, ebuf) < 0 && dlbindreq(p->fd, 2, ebuf) < 0) || - dlbindack(p->fd, (char *)buf, ebuf) < 0) + dlbindack(p->fd, (char *)buf, ebuf, NULL) < 0) goto bad; #elif defined(DL_HP_RAWDLS) /* - ** This is the descriptor on which we receive packets; we - ** bind it to 22, as that's INSAP, as per the HP-UX DLPI - ** Programmer's Guide. + ** HP-UX 10.0x and 10.1x. */ - if (dlbindreq(p->fd, 22, ebuf) < 0 || - dlbindack(p->fd, (char *)buf, ebuf) < 0) + if (dl_dohpuxbind(p->fd, ebuf) < 0) goto bad; - if (p->send_fd >= 0) { /* - ** This is the descriptor on which we send packets; we - ** bind it to 24, as that's OUTSAP, as per the HP-UX - ** DLPI Programmer's Guide. + ** XXX - if this fails, just close send_fd and + ** set it to -1, so that you can't send but can + ** still receive? */ - if (dlbindreq(p->send_fd, 24, ebuf) < 0 || - dlbindack(p->send_fd, (char *)buf, ebuf) < 0) + if (dl_dohpuxbind(p->send_fd, ebuf) < 0) goto bad; } #else /* neither AIX nor HP-UX */ + /* + ** Not Sinix, and neither AIX nor HP-UX - Solaris, and any other + ** OS using DLPI. + **/ if (dlbindreq(p->fd, 0, ebuf) < 0 || - dlbindack(p->fd, (char *)buf, ebuf) < 0) + dlbindack(p->fd, (char *)buf, ebuf, NULL) < 0) goto bad; -#endif /* SAP to bind to */ -#endif /* HP-UX 9 or 10.20 or SINIX */ +#endif /* AIX vs. HP-UX vs. other */ +#endif /* !HP-UX 9 and !HP-UX 10.20 or later and !SINIX */ #ifdef HAVE_SOLARIS if (isatm) { @@ -710,8 +721,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, #endif } /* - ** Try to enable sap (when not in promiscuous mode when using - ** using HP-UX, when not doing SunATM on Solaris, and never + ** Try to enable SAP promiscuity (when not in promiscuous mode + ** when using HP-UX, when not doing SunATM on Solaris, and never ** under SINIX) (Not necessary on send FD) */ #ifndef sinix @@ -731,16 +742,29 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, else goto bad; } -#endif +#endif /* sinix */ /* - ** HP-UX 9 and HP-UX 10.20 must bind after setting promiscuous - ** options) + ** HP-UX 9, and HP-UX 10.20 or later, must bind after setting + ** promiscuous options. */ -#if defined(HAVE_HPUX9) || defined(HAVE_HPUX10_20) - if (dlbindreq(p->fd, 0, ebuf) < 0 || - dlbindack(p->fd, (char *)buf, ebuf) < 0) +#if defined(HAVE_HPUX9) || defined(HAVE_HPUX10_20_OR_LATER) + if (dl_dohpuxbind(p->fd, ebuf) < 0) goto bad; + /* + ** We don't set promiscuous mode on the send FD, but we'll defer + ** binding it anyway, just to keep the HP-UX 9/10.20 or later + ** code together. + */ + if (p->send_fd >= 0) { + /* + ** XXX - if this fails, just close send_fd and + ** set it to -1, so that you can't send but can + ** still receive? + */ + if (dl_dohpuxbind(p->send_fd, ebuf) < 0) + goto bad; + } #endif /* @@ -909,6 +933,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, p->read_op = pcap_read_dlpi; p->inject_op = pcap_inject_dlpi; p->setfilter_op = install_bpf_program; /* no kernel filtering */ + p->setdirection_op = NULL; /* Not implemented.*/ p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; @@ -990,6 +1015,47 @@ dl_doattach(int fd, int ppa, char *ebuf) return (0); } +#ifdef DL_HP_RAWDLS +static int +dl_dohpuxbind(int fd, char *ebuf) +{ + int hpsap; + int uerror; + bpf_u_int32 buf[MAXDLBUF]; + + /* + * XXX - we start at 22 because we used to use only 22, but + * that was just because that was the value used in some + * sample code from HP. With what value *should* we start? + * Does it matter, given that we're enabling SAP promiscuity + * on the input FD? + */ + hpsap = 22; + for (;;) { + if (dlbindreq(fd, hpsap, ebuf) < 0) + return (-1); + if (dlbindack(fd, (char *)buf, ebuf, &uerror) >= 0) + break; + /* + * For any error other than a UNIX EBUSY, give up. + */ + if (uerror != EBUSY) + return (-1); + + /* + * For EBUSY, try the next SAP value; that means that + * somebody else is using that SAP. Clear ebuf so + * that application doesn't report the "Device busy" + * error as a warning. + */ + *ebuf = '\0'; + hpsap++; + if (hpsap > 100) + return (-1); + } +} +#endif + int pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) { @@ -1054,7 +1120,7 @@ send_request(int fd, char *ptr, int len, char *what, char *ebuf) } static int -recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf) +recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror) { union DL_primitives *dlp; struct strbuf ctl; @@ -1087,12 +1153,16 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf) switch (dlp->error_ack.dl_errno) { case DL_SYSERR: + if (uerror != NULL) + *uerror = dlp->error_ack.dl_unix_errno; snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: UNIX error - %s", what, pcap_strerror(dlp->error_ack.dl_unix_errno)); break; default: + if (uerror != NULL) + *uerror = 0; snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: %s", what, dlstrerror(dlp->error_ack.dl_errno)); break; @@ -1100,6 +1170,8 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf) return (-1); default: + if (uerror != NULL) + *uerror = 0; snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: Unexpected primitive ack %s", what, dlprim(dlp->dl_primitive)); @@ -1107,6 +1179,8 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf) } if (ctl.len < size) { + if (uerror != NULL) + *uerror = 0; snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s: Ack too small (%d < %d)", what, ctl.len, size); @@ -1338,26 +1412,23 @@ dlbindreq(int fd, bpf_u_int32 sap, char *ebuf) memset((char *)&req, 0, sizeof(req)); req.dl_primitive = DL_BIND_REQ; -#ifdef DL_HP_RAWDLS + /* XXX - what if neither of these are defined? */ +#if defined(DL_HP_RAWDLS) req.dl_max_conind = 1; /* XXX magic number */ - /* 22 is INSAP as per the HP-UX DLPI Programmer's Guide */ - req.dl_sap = 22; req.dl_service_mode = DL_HP_RAWDLS; -#else - req.dl_sap = sap; -#ifdef DL_CLDLS +#elif defined(DL_CLDLS) req.dl_service_mode = DL_CLDLS; #endif -#endif + req.dl_sap = sap; return (send_request(fd, (char *)&req, sizeof(req), "bind", ebuf)); } static int -dlbindack(int fd, char *bufp, char *ebuf) +dlbindack(int fd, char *bufp, char *ebuf, int *uerror) { - return (recv_ack(fd, DL_BIND_ACK_SIZE, "bind", bufp, ebuf)); + return (recv_ack(fd, DL_BIND_ACK_SIZE, "bind", bufp, ebuf, uerror)); } static int @@ -1375,7 +1446,7 @@ static int dlokack(int fd, const char *what, char *bufp, char *ebuf) { - return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf)); + return (recv_ack(fd, DL_OK_ACK_SIZE, what, bufp, ebuf, NULL)); } @@ -1393,7 +1464,7 @@ static int dlinfoack(int fd, char *bufp, char *ebuf) { - return (recv_ack(fd, DL_INFO_ACK_SIZE, "info", bufp, ebuf)); + return (recv_ack(fd, DL_INFO_ACK_SIZE, "info", bufp, ebuf, NULL)); } #ifdef DL_HP_RAWDLS @@ -1674,20 +1745,20 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit, ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset); } } - if (i == ap->dl_count) { - snprintf(ebuf, PCAP_ERRBUF_SIZE, + if (i == ap->dl_count) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, "can't find /dev/dlpi PPA for %s%d", device, unit); return (-1); - } - if (ip->dl_hdw_state == HDW_DEAD) { - snprintf(ebuf, PCAP_ERRBUF_SIZE, + } + if (ip->dl_hdw_state == HDW_DEAD) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s%d: hardware state: DOWN\n", device, unit); free(ppa_data_buf); return (-1); - } - ppa = ip->dl_ppa; - free(ppa_data_buf); - return (ppa); + } + ppa = ip->dl_ppa; + free(ppa_data_buf); + return (ppa); } #endif diff --git a/contrib/libpcap/pcap-dos.c b/contrib/libpcap/pcap-dos.c index 21fd113..0700d6b 100644 --- a/contrib/libpcap/pcap-dos.c +++ b/contrib/libpcap/pcap-dos.c @@ -5,7 +5,7 @@ * pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode * network drivers. * - * @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.1 2004/12/18 08:52:10 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.1.2.1 2005/05/03 18:54:35 guy Exp $ (LBL) */ #include <stdio.h> @@ -172,6 +172,7 @@ pcap_t *pcap_open_live (const char *device_name, int snaplen, int promisc, pcap->stats_op = pcap_stats_dos; pcap->inject_op = pcap_sendpacket_dos; pcap->setfilter_op = pcap_setfilter_dos; + pcap->setdirection_op = NULL; /* Not implemented.*/ pcap->fd = ++ref_count; if (pcap->fd == 1) /* first time we're called */ diff --git a/contrib/libpcap/pcap-linux.c b/contrib/libpcap/pcap-linux.c index 89ad5c4..0cd6ca8 100644 --- a/contrib/libpcap/pcap-linux.c +++ b/contrib/libpcap/pcap-linux.c @@ -27,7 +27,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.110 2004/10/19 07:06:12 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.110.2.2 2005/06/20 21:30:18 guy Exp $ (LBL)"; #endif /* @@ -83,6 +83,10 @@ static const char rcsid[] _U_ = #ifdef HAVE_DAG_API #include "pcap-dag.h" #endif /* HAVE_DAG_API */ + +#ifdef HAVE_SEPTEL_API +#include "pcap-septel.h" +#endif /* HAVE_SEPTEL_API */ #include <errno.h> #include <stdlib.h> @@ -191,6 +195,7 @@ static int pcap_read_packet(pcap_t *, pcap_handler, u_char *); static int pcap_inject_linux(pcap_t *, const void *, size_t); static int pcap_stats_linux(pcap_t *, struct pcap_stat *); static int pcap_setfilter_linux(pcap_t *, struct bpf_program *); +static int pcap_setdirection_linux(pcap_t *, direction_t); static void pcap_close_linux(pcap_t *); /* @@ -244,7 +249,13 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, } #endif /* HAVE_DAG_API */ - /* Allocate a handle for this session. */ +#ifdef HAVE_SEPTEL_API + if (strstr(device, "septel")) { + return septel_open_live(device, snaplen, promisc, to_ms, ebuf); + } +#endif /* HAVE_SEPTEL_API */ + + /* Allocate a handle for this session. */ handle = malloc(sizeof(*handle)); if (handle == NULL) { @@ -407,6 +418,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, handle->read_op = pcap_read_linux; handle->inject_op = pcap_inject_linux; handle->setfilter_op = pcap_setfilter_linux; + handle->setdirection_op = pcap_setdirection_linux; handle->set_datalink_op = NULL; /* can't change data link type */ handle->getnonblock_op = pcap_getnonblock_fd; handle->setnonblock_op = pcap_setnonblock_fd; @@ -504,19 +516,37 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata) } #ifdef HAVE_PF_PACKET_SOCKETS - /* - * If this is from the loopback device, reject outgoing packets; - * we'll see the packet as an incoming packet as well, and - * we don't want to see it twice. - * - * We can only do this if we're using PF_PACKET; the address - * returned for SOCK_PACKET is a "sockaddr_pkt" which lacks - * the relevant packet type information. - */ - if (!handle->md.sock_packet && - from.sll_ifindex == handle->md.lo_ifindex && - from.sll_pkttype == PACKET_OUTGOING) - return 0; + if (!handle->md.sock_packet) { + /* + * Do checks based on packet direction. + * We can only do this if we're using PF_PACKET; the + * address returned for SOCK_PACKET is a "sockaddr_pkt" + * which lacks the relevant packet type information. + */ + if (from.sll_pkttype == PACKET_OUTGOING) { + /* + * Outgoing packet. + * If this is from the loopback device, reject it; + * we'll see the packet as an incoming packet as well, + * and we don't want to see it twice. + */ + if (from.sll_ifindex == handle->md.lo_ifindex) + return 0; + + /* + * If the user only wants incoming packets, reject it. + */ + if (handle->direction == D_IN) + return 0; + } else { + /* + * Incoming packet. + * If the user only wants outgoing packets, reject it. + */ + if (handle->direction == D_OUT) + return 0; + } + } #endif #ifdef HAVE_PF_PACKET_SOCKETS @@ -835,6 +865,11 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) return (-1); #endif /* HAVE_DAG_API */ +#ifdef HAVE_SEPTEL_API + if (septel_platform_finddevs(alldevsp, errbuf) < 0) + return (-1); +#endif /* HAVE_SEPTEL_API */ + return (0); } @@ -975,6 +1010,28 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter) } /* + * Set direction flag: Which packets do we accept on a forwarding + * single device? IN, OUT or both? + */ +static int +pcap_setdirection_linux(pcap_t *handle, direction_t d) +{ +#ifdef HAVE_PF_PACKET_SOCKETS + if (!handle->md.sock_packet) { + handle->direction = d; + return 0; + } +#endif + /* + * We're not using PF_PACKET sockets, so we can't determine + * the direction of the packet. + */ + snprintf(handle->errbuf, sizeof(handle->errbuf), + "Setting direction is not supported on SOCK_PACKET sockets"); + return -1; +} + +/* * Linux uses the ARP hardware type to identify the type of an * interface. pcap uses the DLT_xxx constants for this. This * function takes a pointer to a "pcap_t", and an ARPHRD_xxx diff --git a/contrib/libpcap/pcap-nit.c b/contrib/libpcap/pcap-nit.c index 097c3be..94c4528 100644 --- a/contrib/libpcap/pcap-nit.c +++ b/contrib/libpcap/pcap-nit.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.57 2004/10/19 07:06:13 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.57.2.1 2005/05/03 18:54:37 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -334,6 +334,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, p->read_op = pcap_read_nit; p->inject_op = pcap_inject_nit; p->setfilter_op = install_bpf_program; /* no kernel filtering */ + p->setdirection_op = NULL; /* Not implemented. */ p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; diff --git a/contrib/libpcap/pcap-pf.c b/contrib/libpcap/pcap-pf.c index 1c3158a..e733540 100644 --- a/contrib/libpcap/pcap-pf.c +++ b/contrib/libpcap/pcap-pf.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.91 2005/02/26 21:58:06 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.91.2.2 2005/05/03 18:54:37 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -129,7 +129,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) */ n = 0; #ifdef PCAP_FDDIPAD - pad = p->fddipad; + pad = pc->fddipad; #endif while (cc > 0) { /* @@ -191,7 +191,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) * #ifdef PCAP_FDDIPAD * Note: the filter code was generated assuming - * that p->fddipad was the amount of padding + * that pc->fddipad was the amount of padding * before the header, as that's what's required * in the kernel, so we run the filter before * skipping that padding. @@ -448,7 +448,7 @@ your system may not be properly configured; see the packetfilter(4) man page\n", /* set truncation */ #ifdef PCAP_FDDIPAD if (p->linktype == DLT_FDDI) { - p->fddipad = PCAP_FDDIPAD: + p->fddipad = PCAP_FDDIPAD; /* packetfilter includes the padding in the snapshot */ snaplen += PCAP_FDDIPAD; @@ -497,6 +497,7 @@ your system may not be properly configured; see the packetfilter(4) man page\n", p->read_op = pcap_read_pf; p->inject_op = pcap_inject_pf; p->setfilter_op = pcap_setfilter_pf; + p->setdirection_op = NULL; /* Not implemented. */ p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; diff --git a/contrib/libpcap/pcap-septel.c b/contrib/libpcap/pcap-septel.c new file mode 100644 index 0000000..5169ec0 --- /dev/null +++ b/contrib/libpcap/pcap-septel.c @@ -0,0 +1,307 @@ +/* + * pcap-septel.c: Packet capture interface for Intel/Septel card. + * + * The functionality of this code attempts to mimic that of pcap-linux as much + * as possible. This code is compiled in several different ways depending on + * whether SEPTEL_ONLY and HAVE_SEPTEL_API are defined. If HAVE_SEPTEL_API is + * not defined it should not get compiled in, otherwise if SEPTEL_ONLY is + * defined then the 'septel_' function calls are renamed to 'pcap_' + * equivalents. If SEPTEL_ONLY is not defined then nothing is altered - the + * septel_ functions will be called as required from their + * pcap-linux/equivalents. + * + * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY + * (+961 3 485243) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/libpcap/pcap-septel.c,v 1.1.2.2 2005/06/21 01:03:23 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/param.h> + +#include <stdlib.h> +#include <string.h> +#include <errno.h> + +#include "pcap-int.h" + +#include <ctype.h> +#include <netinet/in.h> +#include <sys/mman.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> + +#ifdef HAVE_SEPTEL_API +#include <msg.h> +#include <ss7_inc.h> +#include <sysgct.h> +#include <pack.h> +#include <system.h> +#endif /* HAVE_SEPTEL_API */ + +#ifdef SEPTEL_ONLY +/* This code is required when compiling for a Septel device only. */ +#include "pcap-septel.h" + +/* Replace dag function names with pcap equivalent. */ +#define septel_open_live pcap_open_live +#define septel_platform_finddevs pcap_platform_finddevs +#endif /* SEPTEL_ONLY */ + +static int septel_setfilter(pcap_t *p, struct bpf_program *fp); +static int septel_stats(pcap_t *p, struct pcap_stat *ps); +static int septel_setnonblock(pcap_t *p, int nonblock, char *errbuf); + +static void septel_platform_close(pcap_t *p) { + +} + + + +/* + * Read at most max_packets from the capture queue and call the callback + * for each of them. Returns the number of packets handled, -1 if an + * error occured, or -2 if we were told to break out of the loop. + */ +static int septel_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) { + + HDR *h; + MSG *m; + int processed = 0 ; + int t = 0 ; + + /* identifier for the message queue of the module(upe) from which we are capturing + * packets.These IDs are defined in system.txt . By default it is set to 0x2d + * so change it to 0xdd for technical reason and therefore the module id for upe becomes: + * LOCAL 0xdd * upe - Example user part task */ + unsigned int id = 0xdd; + + /* process the packets */ + do { + + unsigned short packet_len = 0; + int caplen = 0; + int counter = 0; + struct pcap_pkthdr pcap_header; + u_char *dp ; + + /* + * Has "pcap_breakloop()" been called? + */ +loop: + if (p->break_loop) { + /* + * Yes - clear the flag that indicates that + * it has, and return -2 to indicate that + * we were told to break out of the loop. + */ + p->break_loop = 0; + return -2; + } + + /*repeat until a packet is read + *a NULL message means : + * when no packet is in queue or all packets in queue already read */ + do { + /* receive packet in non-blocking mode + * GCT_grab is defined in the septel library software */ + h = GCT_grab(id); + + m = (MSG*)h; + /* a couter is added here to avoid an infinite loop + * that will cause our capture program GUI to freeze while waiting + * for a packet*/ + counter++ ; + + } + while ((m == NULL)&& (counter< 100)) ; + + if (m != NULL) { + + t = h->type ; + + /* catch only messages with type = 0xcf00 or 0x8f01 corrsponding to ss7 messages*/ + /* XXX = why not use API_MSG_TX_REQ for 0xcf00 and API_MSG_RX_IND + * for 0x8f01? */ + if ((t != 0xcf00) && (t != 0x8f01)) { + relm(h); + goto loop ; + } + + /* XXX - is API_MSG_RX_IND for an MTP2 or MTP3 message? */ + dp = get_param(m);/* get pointer to MSG parameter area (m->param) */ + packet_len = m->len; + caplen = p->snapshot ; + + + if (caplen > packet_len) { + + caplen = packet_len; + } + /* Run the packet filter if there is one. */ + if ((p->fcode.bf_insns == NULL) || bpf_filter(p->fcode.bf_insns, dp, packet_len, caplen)) { + + + /* get a time stamp , consisting of : + * + * pcap_header.ts.tv_sec: + * ---------------------- + * a UNIX format time-in-seconds when he packet was captured, + * i.e. the number of seconds since Epoch time (January 1,1970, 00:00:00 GMT) + * + * pcap_header.ts.tv_usec : + * ------------------------ + * the number of microseconds since that second + * when the packet was captured + */ + + (void)gettimeofday(&pcap_header.ts, NULL); + + /* Fill in our own header data */ + pcap_header.caplen = caplen; + pcap_header.len = packet_len; + + /* Count the packet. */ + p->md.stat.ps_recv++; + + /* Call the user supplied callback function */ + callback(user, &pcap_header, dp); + + processed++ ; + + } + /* after being processed the packet must be + *released in order to receive another one */ + relm(h); + }else + processed++; + + } + while (processed < cnt) ; + + return processed ; +} + + +static int +septel_inject(pcap_t *handle, const void *buf _U_, size_t size _U_) +{ + strlcpy(handle->errbuf, "Sending packets isn't supported on Septel cards", + PCAP_ERRBUF_SIZE); + return (-1); +} + +/* + * Get a handle for a live capture from the given Septel device. Always pass a NULL device + * The promisc flag is ignored because Septel cards have built-in tracing. + * The to_ms parameter is also ignored as it is + * not supported in hardware. + * + * See also pcap(3). + */ +pcap_t *septel_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf) { + pcap_t *handle; + + handle = malloc(sizeof(*handle)); + if (handle == NULL) { + snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc %s: %s", device, pcap_strerror(errno)); + return NULL; + } + + /* Initialize some components of the pcap structure. */ + + memset(handle, 0, sizeof(*handle)); + + handle->snapshot = snaplen; + + handle->linktype = DLT_MTP2; + + handle->bufsize = 0; + + /* + * "select()" and "poll()" don't work on Septel queues + */ + handle->selectable_fd = -1; + + handle->read_op = septel_read; + handle->inject_op = septel_inject; + handle->setfilter_op = septel_setfilter; + handle->set_datalink_op = NULL; /* can't change data link type */ + handle->getnonblock_op = pcap_getnonblock_fd; + handle->setnonblock_op = septel_setnonblock; + handle->stats_op = septel_stats; + handle->close_op = septel_platform_close; + + return handle; + +fail: + if (handle != NULL) { + free(handle); + } + + return NULL; +} + +static int septel_stats(pcap_t *p, struct pcap_stat *ps) { + /*p->md.stat.ps_recv = 0;*/ + /*p->md.stat.ps_drop = 0;*/ + + *ps = p->md.stat; + + return 0; +} + + +int +septel_platform_finddevs(pcap_if_t **devlistp, char *errbuf) +{ +unsigned char *p; + const char description[512]= "Intel/Septel device"; + char name[512]="septel" ; + int ret = 0; + pcap_add_if(devlistp,name,0,description,errbuf); + + return (ret); +} + + +/* + * Installs the given bpf filter program in the given pcap structure. There is + * no attempt to store the filter in kernel memory as that is not supported + * with Septel cards. + */ +static int septel_setfilter(pcap_t *p, struct bpf_program *fp) { + if (!p) + return -1; + if (!fp) { + strncpy(p->errbuf, "setfilter: No filter specified", + sizeof(p->errbuf)); + return -1; + } + + /* Make our private copy of the filter */ + + if (install_bpf_program(p, fp) < 0) { + snprintf(p->errbuf, sizeof(p->errbuf), + "malloc: %s", pcap_strerror(errno)); + return -1; + } + + p->md.use_bpf = 0; + + return (0); +} + + +static int +septel_setnonblock(pcap_t *p, int nonblock, char *errbuf) +{ + return (0); +} diff --git a/contrib/libpcap/pcap-septel.h b/contrib/libpcap/pcap-septel.h new file mode 100644 index 0000000..1de6377 --- /dev/null +++ b/contrib/libpcap/pcap-septel.h @@ -0,0 +1,15 @@ +/* + * pcap-septel.c: Packet capture interface for Intel Septel card + * + * The functionality of this code attempts to mimic that of pcap-linux as much + * as possible. This code is only needed when compiling in the Intel/Septel + * card code at the same time as another type of device. + * + * Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY + * (+961 3 485343); + * + * @(#) $Header: /tcpdump/master/libpcap/pcap-septel.h,v 1.1.2.1 2005/06/20 21:30:19 guy Exp $ + */ + +pcap_t *septel_open_live(const char *device, int snaplen, int promisc, int to_ms, char *ebuf); + diff --git a/contrib/libpcap/pcap-snit.c b/contrib/libpcap/pcap-snit.c index 47bf443..60abe64 100644 --- a/contrib/libpcap/pcap-snit.c +++ b/contrib/libpcap/pcap-snit.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.72 2004/10/19 07:06:13 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.72.2.1 2005/05/03 18:54:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -397,6 +397,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, p->read_op = pcap_read_snit; p->inject_op = pcap_inject_snit; p->setfilter_op = install_bpf_program; /* no kernel filtering */ + p->setdirection_op = NULL; /* Not implemented. */ p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; diff --git a/contrib/libpcap/pcap-snoop.c b/contrib/libpcap/pcap-snoop.c index acbe548..f6425f1 100644 --- a/contrib/libpcap/pcap-snoop.c +++ b/contrib/libpcap/pcap-snoop.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.54 2004/10/19 07:06:14 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.54.2.1 2005/05/03 18:54:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -379,6 +379,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, p->read_op = pcap_read_snoop; p->inject_op = pcap_inject_snoop; p->setfilter_op = install_bpf_program; /* no kernel filtering */ + p->setdirection_op = NULL; /* Not implemented. */ p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_fd; p->setnonblock_op = pcap_setnonblock_fd; diff --git a/contrib/libpcap/pcap-win32.c b/contrib/libpcap/pcap-win32.c index cb6c696..5b814f0 100644 --- a/contrib/libpcap/pcap-win32.c +++ b/contrib/libpcap/pcap-win32.c @@ -32,7 +32,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.25 2005/02/26 21:58:06 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.25.2.2 2005/06/10 03:48:56 risso Exp $ (LBL)"; #endif #include <pcap-int.h> @@ -411,6 +411,7 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, if (p->adapter == NULL) { + free(p); /* Adapter detected but we are not able to open it. Return failure. */ snprintf(ebuf, PCAP_ERRBUF_SIZE, "Error opening adapter: %s", pcap_win32strerror()); return NULL; @@ -602,6 +603,8 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, #ifdef HAVE_DAG_API } #endif /* HAVE_DAG_API */ + p->setdirection_op = NULL; /* Not implemented. */ + /* XXX - can this be implemented on some versions of Windows? */ p->inject_op = pcap_inject_win32; p->set_datalink_op = NULL; /* can't change data link type */ p->getnonblock_op = pcap_getnonblock_win32; diff --git a/contrib/libpcap/pcap.c b/contrib/libpcap/pcap.c index 7cad9ea..e647dc5 100644 --- a/contrib/libpcap/pcap.c +++ b/contrib/libpcap/pcap.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.88 2005/02/08 20:03:15 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.88.2.3 2005/05/27 23:33:00 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -331,7 +331,7 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(DLT_SLIP, "SLIP"), DLT_CHOICE(DLT_PPP, "PPP"), DLT_CHOICE(DLT_FDDI, "FDDI"), - DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 IP-over-ATM"), + DLT_CHOICE(DLT_ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"), DLT_CHOICE(DLT_RAW, "Raw IP"), DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"), DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"), @@ -369,6 +369,10 @@ static struct dlt_choice dlt_choices[] = { DLT_CHOICE(DLT_JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"), DLT_CHOICE(DLT_ERF_ETH, "Ethernet with Endace ERF header"), DLT_CHOICE(DLT_ERF_POS, "Packet-over-SONET with Endace ERF header"), + DLT_CHOICE(DLT_JUNIPER_GGSN, "Juniper GGSN PIC"), + DLT_CHOICE(DLT_JUNIPER_ES, "Juniper Encryption Services PIC"), + DLT_CHOICE(DLT_JUNIPER_MONITOR, "Juniper Passive Monitor PIC"), + DLT_CHOICE(DLT_JUNIPER_SERVICES, "Juniper Advanced Services PIC"), DLT_CHOICE_SENTINEL }; @@ -685,6 +689,23 @@ pcap_setfilter(pcap_t *p, struct bpf_program *fp) return p->setfilter_op(p, fp); } +/* + * Set direction flag, which controls whether we accept only incoming + * packets, only outgoing packets, or both. + * Note that, depending on the platform, some or all direction arguments + * might not be supported. + */ +int +pcap_setdirection(pcap_t *p, direction_t d) +{ + if (p->setdirection_op == NULL) { + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, + "Setting direction is not implemented on this platform"); + return -1; + } else + return p->setdirection_op(p, d); +} + int pcap_stats(pcap_t *p, struct pcap_stat *ps) { diff --git a/contrib/libpcap/savefile.c b/contrib/libpcap/savefile.c index 0a739fa..ec1088d 100644 --- a/contrib/libpcap/savefile.c +++ b/contrib/libpcap/savefile.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.126 2005/02/08 20:03:16 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.126.2.8 2005/06/03 20:36:57 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -98,7 +98,7 @@ static const char rcsid[] _U_ = * Setting O_BINARY on DOS/Windows is a bit tricky */ #if defined(WIN32) - #define SET_BINMODE(f) _setmode(fileno(f), O_BINARY) + #define SET_BINMODE(f) _setmode(_fileno(f), _O_BINARY) #elif defined(MSDOS) #if defined(__HIGHC__) #define SET_BINMODE(f) setmode(f, O_BINARY) @@ -269,10 +269,10 @@ static const char rcsid[] _U_ = #define LINKTYPE_APPLE_IP_OVER_IEEE1394 138 /* Apple IP-over-IEEE 1394 cooked header */ -#define LINKTYPE_RAWSS7 139 /* see rawss7.h for */ -#define LINKTYPE_RAWSS7_MTP2 140 /* information on these */ -#define LINKTYPE_RAWSS7_MTP3 141 /* definitions */ -#define LINKTYPE_RAWSS7_SCCP 142 +#define LINKTYPE_MTP2_WITH_PHDR 139 +#define LINKTYPE_MTP2 140 +#define LINKTYPE_MTP3 141 +#define LINKTYPE_SCCP 142 #define LINKTYPE_DOCSIS 143 /* DOCSIS MAC frames */ @@ -404,6 +404,14 @@ static const char rcsid[] _U_ = #define LINKTYPE_ERF_ETH 175 /* Ethernet */ #define LINKTYPE_ERF_POS 176 /* Packet-over-SONET */ +/* + * Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define LINKTYPE_LINUX_LAPD 177 + static struct linktype_map { int dlt; int linktype; @@ -530,6 +538,12 @@ static struct linktype_map { /* Apple IP-over-IEEE 1394 cooked header */ { DLT_APPLE_IP_OVER_IEEE1394, LINKTYPE_APPLE_IP_OVER_IEEE1394 }, + /* SS7 */ + { DLT_MTP2_WITH_PHDR, LINKTYPE_MTP2_WITH_PHDR }, + { DLT_MTP2, LINKTYPE_MTP2 }, + { DLT_MTP3, LINKTYPE_MTP3 }, + { DLT_SCCP, LINKTYPE_SCCP }, + /* DOCSIS MAC frames */ { DLT_DOCSIS, LINKTYPE_DOCSIS }, @@ -594,6 +608,9 @@ static struct linktype_map { { DLT_ERF_ETH, LINKTYPE_ERF_ETH }, { DLT_ERF_POS, LINKTYPE_ERF_POS }, + /* viSDN LAPD */ + { DLT_LINUX_LAPD, LINKTYPE_LINUX_LAPD }, + { -1, -1 } }; @@ -700,6 +717,18 @@ sf_inject(pcap_t *p, const void *buf _U_, size_t size _U_) return (-1); } +/* + * Set direction flag: Which packets do we accept on a forwarding + * single device? IN, OUT or both? + */ +static int +sf_setdirection(pcap_t *p, direction_t d) +{ + snprintf(p->errbuf, sizeof(p->errbuf), + "Setting direction is not supported on savefiles"); + return (-1); +} + static void sf_close(pcap_t *p) { @@ -716,7 +745,16 @@ pcap_open_offline(const char *fname, char *errbuf) pcap_t *p; if (fname[0] == '-' && fname[1] == '\0') + { fp = stdin; +#if defined(WIN32) || defined(MSDOS) + /* + * We're reading from the standard input, so put it in binary + * mode, as savefiles are binary files. + */ + SET_BINMODE(fp); +#endif + } else { #if !defined(WIN32) && !defined(MSDOS) fp = fopen(fname, "r"); @@ -892,21 +930,13 @@ pcap_fopen_offline(FILE *fp, char *errbuf) p->read_op = pcap_offline_read; p->inject_op = sf_inject; p->setfilter_op = install_bpf_program; + p->setdirection_op = sf_setdirection; p->set_datalink_op = NULL; /* we don't support munging link-layer headers */ p->getnonblock_op = sf_getnonblock; p->setnonblock_op = sf_setnonblock; p->stats_op = sf_stats; p->close_op = sf_close; -#if defined(WIN32) || defined(MSDOS) - /* - * If we're reading from the standard input, put it in binary - * mode, as savefiles are binary files. - */ - if (fp == stdin) - SET_BINMODE(fp); -#endif - return (p); bad: free(p); @@ -1212,6 +1242,12 @@ pcap_dump_file(pcap_dumper_t *p) return ((FILE *)p); } +long +pcap_dump_ftell(pcap_dumper_t *p) +{ + return (ftell((FILE *)p)); +} + int pcap_dump_flush(pcap_dumper_t *p) { |