diff options
-rw-r--r-- | CREDITS | 3 | ||||
-rw-r--r-- | FILES | 3 | ||||
-rw-r--r-- | INSTALL | 3 | ||||
-rw-r--r-- | Makefile.in | 6 | ||||
-rw-r--r-- | acconfig.h | 9 | ||||
-rw-r--r-- | aclocal.m4 | 48 | ||||
-rw-r--r-- | config.h.in | 9 | ||||
-rwxr-xr-x | configure | 262 | ||||
-rw-r--r-- | missing/datalinks.c | 63 | ||||
-rw-r--r-- | missing/dlnames.c | 148 | ||||
-rw-r--r-- | pcap-missing.h | 52 | ||||
-rw-r--r-- | tcpdump.c | 117 |
12 files changed, 614 insertions, 109 deletions
@@ -31,6 +31,7 @@ Additional people who have contributed patches: Crist J. Clark <cjclark@alum.mit.edu> Daniel Hagerty <hag@ai.mit.edu> Darren Reed <darrenr@reed.wattle.id.au> + David Young <dyoung@ojctech.com> Francisco Matias Cuenca-Acuna <mcuenca@george.rutgers.edu> Frank Volf <volf@oasis.IAEhv.nl> Fulvio Risso <risso@polito.it> @@ -43,7 +44,7 @@ Additional people who have contributed patches: Hendrik Scholz <hendrik@scholz.net> Jakob Schlyter <jakob@openbsd.org> Jan Oravec <wsx@wsx6.net> - Jason R. Thorpe <thorpej@zembu.com> + Jason R. Thorpe <thorpej@netbsd.org> Jefferson Ogata <jogata@nodc.noaa.gov> Jeffrey Hutzelman <jhutz@cmu.edu> Jim Hutchins <jim@ca.sandia.gov> @@ -57,6 +57,8 @@ mib.h missing/addrinfo.h missing/addrsize.h missing/bittypes.h +missing/dlnames.c +missing/datalinks.c missing/getaddrinfo.c missing/getnameinfo.c missing/inet_aton.c @@ -80,6 +82,7 @@ ospf.h ospf6.h packetdat.awk parsenfsfh.c +pcap-missing.h ppp.h print-802_11.c print-ah.c @@ -1,4 +1,4 @@ -@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.51 2002-10-03 16:00:33 hannes Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/Attic/INSTALL,v 1.52 2002-12-19 09:27:55 guy Exp $ (LBL) If you have not built libpcap, do so first. See the README file in this directory for the ftp location. @@ -104,6 +104,7 @@ ospf.h - Open Shortest Path First definitions ospf6.h - IPv6 Open Shortest Path First definitions packetdat.awk - TCP chunk summary awk script parsenfsfh.c - Network File System file parser routines +pcap-missing.h - declarations of functions possibly missing from libpcap ppp.h - Point to Point Protocol definitions print-802_11.c - IEEE 802.11 printer routines print-ah.c - IPSEC Authentication Header printer routines diff --git a/Makefile.in b/Makefile.in index 6d08605a..aec803f4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,7 +17,7 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.269 2002-12-13 00:40:34 hannes Exp $ (LBL) +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.270 2002-12-19 09:27:55 guy Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) @@ -123,6 +123,10 @@ $(PROG): $(OBJ) @V_PCAPDEP@ @rm -f $@ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) +datalinks.o: $(srcdir)/missing/datalinks.c + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c +dlnames.o: $(srcdir)/missing/dlnames.c + $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c getnameinfo.o: $(srcdir)/missing/getnameinfo.c $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c getaddrinfo.o: $(srcdir)/missing/getaddrinfo.c @@ -74,6 +74,15 @@ /* define if libpcap has yydebug */ #undef HAVE_YYDEBUG +/* define if libpcap has pcap_list_datalinks() */ +#undef HAVE_PCAP_LIST_DATALINKS + +/* define if libpcap has pcap_set_datalink() */ +#undef HAVE_PCAP_SET_DATALINK + +/* define if libpcap has pcap_datalink_name_to_val() */ +#undef HAVE_PCAP_DATALINK_NAME_TO_VAL + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.90 2002-12-17 09:55:14 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.91 2002-12-19 09:27:56 guy Exp $ (LBL) dnl dnl Copyright (c) 1995, 1996, 1997, 1998 dnl The Regents of the University of California. All rights reserved. @@ -257,21 +257,21 @@ AC_DEFUN(AC_LBL_LIBPCAP, if test $libpcap = FAIL ; then AC_MSG_ERROR(see the INSTALL doc for more info) fi - # - # Good old Red Hat Linux puts "pcap.h" in - # "/usr/include/pcap"; had the LBL folks done so, - # that would have been a good idea, but for - # the Red Hat folks to do so just breaks source - # compatibility with other systems. - # - # We work around this by assuming that, as we didn't - # find a local libpcap, libpcap is in /usr/lib or - # /usr/local/lib and that the corresponding header - # file is under one of those directories; if we don't - # find it in either of those directories, we check to - # see if it's in a "pcap" subdirectory of them and, - # if so, add that subdirectory to the "-I" list. - # + dnl + dnl Good old Red Hat Linux puts "pcap.h" in + dnl "/usr/include/pcap"; had the LBL folks done so, + dnl that would have been a good idea, but for + dnl the Red Hat folks to do so just breaks source + dnl compatibility with other systems. + dnl + dnl We work around this by assuming that, as we didn't + dnl find a local libpcap, libpcap is in /usr/lib or + dnl /usr/local/lib and that the corresponding header + dnl file is under one of those directories; if we don't + dnl find it in either of those directories, we check to + dnl see if it's in a "pcap" subdirectory of them and, + dnl if so, add that subdirectory to the "-I" list. + dnl AC_MSG_CHECKING(for extraneous pcap header directories) if ! test \( -r /usr/local/include/pcap.h -o \ -r /usr/include/pcap.h \); then @@ -311,7 +311,21 @@ AC_DEFUN(AC_LBL_LIBPCAP, LIBS="$LIBS -I:$pseexe" fi ;; - esac]) + esac + + dnl + dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()", + dnl and "pcap_datalink_name_to_val()". + dnl + AC_CHECK_LIB(pcap, pcap_list_datalinks, + AC_DEFINE(HAVE_PCAP_LIST_DATALINKS), + LIBOBJS="$LIBOBJS datalinks.o") + AC_CHECK_LIB(pcap, pcap_set_datalink, + AC_DEFINE(HAVE_PCAP_SET_DATALINK)) + AC_CHECK_LIB(pcap, pcap_datalink_name_to_val, + AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL), + LIBOBJS="$LIBOBJS dlnames.o") +]) dnl dnl Define RETSIGTYPE and RETSIGVAL diff --git a/config.h.in b/config.h.in index 318e6eeb..89af5e84 100644 --- a/config.h.in +++ b/config.h.in @@ -65,6 +65,15 @@ /* define if libpcap has yydebug */ #undef HAVE_YYDEBUG +/* define if libpcap has pcap_list_datalinks() */ +#undef HAVE_PCAP_LIST_DATALINKS + +/* define if libpcap has pcap_set_datalink() */ +#undef HAVE_PCAP_SET_DATALINK + +/* define if libpcap has pcap_datalink_name_to_val() */ +#undef HAVE_PCAP_DATALINK_NAME_TO_VAL + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN @@ -3919,23 +3919,8 @@ fi if test $libpcap = FAIL ; then { echo "configure: error: see the INSTALL doc for more info" 1>&2; exit 1; } fi - # - # Good old Red Hat Linux puts "pcap.h" in - # "/usr/include/pcap"; had the LBL folks done so, - # that would have been a good idea, but for - # the Red Hat folks to do so just breaks source - # compatibility with other systems. - # - # We work around this by assuming that, as we didn't - # find a local libpcap, libpcap is in /usr/lib or - # /usr/local/lib and that the corresponding header - # file is under one of those directories; if we don't - # find it in either of those directories, we check to - # see if it's in a "pcap" subdirectory of them and, - # if so, add that subdirectory to the "-I" list. - # - echo $ac_n "checking for extraneous pcap header directories""... $ac_c" 1>&6 -echo "configure:3939: checking for extraneous pcap header directories" >&5 + echo $ac_n "checking for extraneous pcap header directories""... $ac_c" 1>&6 +echo "configure:3924: checking for extraneous pcap header directories" >&5 if ! test \( -r /usr/local/include/pcap.h -o \ -r /usr/include/pcap.h \); then if test -r /usr/local/include/pcap/pcap.h; then @@ -3969,7 +3954,7 @@ echo "configure:3939: checking for extraneous pcap header directories" >&5 aix*) pseexe="/lib/pse.exp" echo $ac_n "checking for $pseexe""... $ac_c" 1>&6 -echo "configure:3973: checking for $pseexe" >&5 +echo "configure:3958: checking for $pseexe" >&5 if test -f $pseexe ; then echo "$ac_t""yes" 1>&6 LIBS="$LIBS -I:$pseexe" @@ -3977,15 +3962,148 @@ echo "configure:3973: checking for $pseexe" >&5 ;; esac + echo $ac_n "checking for pcap_list_datalinks in -lpcap""... $ac_c" 1>&6 +echo "configure:3967: checking for pcap_list_datalinks in -lpcap" >&5 +ac_lib_var=`echo pcap'_'pcap_list_datalinks | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpcap $LIBS" +cat > conftest.$ac_ext <<EOF +#line 3975 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_list_datalinks(); + +int main() { +pcap_list_datalinks() +; return 0; } +EOF +if { (eval echo configure:3986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_PCAP_LIST_DATALINKS 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LIBOBJS="$LIBOBJS datalinks.o" +fi + + echo $ac_n "checking for pcap_set_datalink in -lpcap""... $ac_c" 1>&6 +echo "configure:4011: checking for pcap_set_datalink in -lpcap" >&5 +ac_lib_var=`echo pcap'_'pcap_set_datalink | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpcap $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4019 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_set_datalink(); + +int main() { +pcap_set_datalink() +; return 0; } +EOF +if { (eval echo configure:4030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_PCAP_SET_DATALINK 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + + echo $ac_n "checking for pcap_datalink_name_to_val in -lpcap""... $ac_c" 1>&6 +echo "configure:4054: checking for pcap_datalink_name_to_val in -lpcap" >&5 +ac_lib_var=`echo pcap'_'pcap_datalink_name_to_val | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lpcap $LIBS" +cat > conftest.$ac_ext <<EOF +#line 4062 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_datalink_name_to_val(); + +int main() { +pcap_datalink_name_to_val() +; return 0; } +EOF +if { (eval echo configure:4073: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LIBOBJS="$LIBOBJS dlnames.o" +fi + + + for ac_func in pcap_findalldevs do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3984: checking for $ac_func" >&5 +echo "configure:4102: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3989 "configure" +#line 4107 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4008,7 +4126,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4033,9 +4151,9 @@ fi done echo $ac_n "checking whether pcap_version is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4037: checking whether pcap_version is defined by libpcap" >&5 +echo "configure:4155: checking whether pcap_version is defined by libpcap" >&5 cat > conftest.$ac_ext <<EOF -#line 4039 "configure" +#line 4157 "configure" #include "confdefs.h" int main() { @@ -4050,7 +4168,7 @@ return_pcap_version(void) ; return 0; } EOF -if { (eval echo configure:4054: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4172: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_lbl_cv_pcap_version_defined=yes else @@ -4070,9 +4188,9 @@ else echo "$ac_t""no" 1>&6 fi echo $ac_n "checking whether pcap_debug is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4074: checking whether pcap_debug is defined by libpcap" >&5 +echo "configure:4192: checking whether pcap_debug is defined by libpcap" >&5 cat > conftest.$ac_ext <<EOF -#line 4076 "configure" +#line 4194 "configure" #include "confdefs.h" int main() { @@ -4087,7 +4205,7 @@ return_pcap_debug(void) ; return 0; } EOF -if { (eval echo configure:4091: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_lbl_cv_pcap_debug_defined=yes else @@ -4109,9 +4227,9 @@ else # OK, what about "yydebug"? # echo $ac_n "checking whether yydebug is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4113: checking whether yydebug is defined by libpcap" >&5 +echo "configure:4231: checking whether yydebug is defined by libpcap" >&5 cat > conftest.$ac_ext <<EOF -#line 4115 "configure" +#line 4233 "configure" #include "confdefs.h" int main() { @@ -4126,7 +4244,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:4130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_lbl_cv_yydebug_defined=yes else @@ -4149,12 +4267,12 @@ fi for ac_func in bpf_dump do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4153: checking for $ac_func" >&5 +echo "configure:4271: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4158 "configure" +#line 4276 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4177,7 +4295,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4181: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4234,12 +4352,12 @@ if test -f /dev/bpf0 ; then fi echo $ac_n "checking for int8_t using $CC""... $ac_c" 1>&6 -echo "configure:4238: checking for int8_t using $CC" >&5 +echo "configure:4356: checking for int8_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_int8_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4243 "configure" +#line 4361 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4252,7 +4370,7 @@ int main() { int8_t i ; return 0; } EOF -if { (eval echo configure:4256: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4374: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int8_t=yes else @@ -4272,12 +4390,12 @@ EOF fi echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6 -echo "configure:4276: checking for u_int8_t using $CC" >&5 +echo "configure:4394: checking for u_int8_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int8_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4281 "configure" +#line 4399 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4290,7 +4408,7 @@ int main() { u_int8_t i ; return 0; } EOF -if { (eval echo configure:4294: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int8_t=yes else @@ -4310,12 +4428,12 @@ EOF fi echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4314: checking for int16_t using $CC" >&5 +echo "configure:4432: checking for int16_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_int16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4319 "configure" +#line 4437 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4328,7 +4446,7 @@ int main() { int16_t i ; return 0; } EOF -if { (eval echo configure:4332: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4450: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int16_t=yes else @@ -4348,12 +4466,12 @@ EOF fi echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4352: checking for u_int16_t using $CC" >&5 +echo "configure:4470: checking for u_int16_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4357 "configure" +#line 4475 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4366,7 +4484,7 @@ int main() { u_int16_t i ; return 0; } EOF -if { (eval echo configure:4370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4488: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int16_t=yes else @@ -4386,12 +4504,12 @@ EOF fi echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4390: checking for int32_t using $CC" >&5 +echo "configure:4508: checking for int32_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_int32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4395 "configure" +#line 4513 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4404,7 +4522,7 @@ int main() { int32_t i ; return 0; } EOF -if { (eval echo configure:4408: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int32_t=yes else @@ -4424,12 +4542,12 @@ EOF fi echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4428: checking for u_int32_t using $CC" >&5 +echo "configure:4546: checking for u_int32_t using $CC" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_have_u_int32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4433 "configure" +#line 4551 "configure" #include "confdefs.h" # include "confdefs.h" @@ -4442,7 +4560,7 @@ int main() { u_int32_t i ; return 0; } EOF -if { (eval echo configure:4446: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4564: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int32_t=yes else @@ -4502,12 +4620,12 @@ EOF fi echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:4506: checking if sockaddr struct has sa_len member" >&5 +echo "configure:4624: checking if sockaddr struct has sa_len member" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_sockaddr_has_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4511 "configure" +#line 4629 "configure" #include "confdefs.h" # include <sys/types.h> @@ -4516,7 +4634,7 @@ int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF -if { (eval echo configure:4520: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4638: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_sockaddr_has_sa_len=yes else @@ -4537,7 +4655,7 @@ EOF fi echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6 -echo "configure:4541: checking if unaligned accesses fail" >&5 +echo "configure:4659: checking if unaligned accesses fail" >&5 if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4602,12 +4720,12 @@ EOF echo $ac_n "checking for h_errno""... $ac_c" 1>&6 -echo "configure:4606: checking for h_errno" >&5 +echo "configure:4724: checking for h_errno" >&5 if eval "test \"`echo '$''{'ac_cv_var_h_errno'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4611 "configure" +#line 4729 "configure" #include "confdefs.h" # include <sys/types.h> @@ -4616,7 +4734,7 @@ int main() { int foo = h_errno; ; return 0; } EOF -if { (eval echo configure:4620: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4738: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_var_h_errno=yes else @@ -4644,7 +4762,7 @@ if test "${with_crypto+set}" = set; then else echo $ac_n "checking for SSLeay""... $ac_c" 1>&6 -echo "configure:4648: checking for SSLeay" >&5 +echo "configure:4766: checking for SSLeay" >&5 ac_cv_ssleay_path=no incdir=no for dir in /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do @@ -4672,7 +4790,7 @@ if test "$ac_cv_ssleay_path" != no; then LIBS="$LIBS -lrsaref" fi echo $ac_n "checking for des_cbc_encrypt in -lcrypto""... $ac_c" 1>&6 -echo "configure:4676: checking for des_cbc_encrypt in -lcrypto" >&5 +echo "configure:4794: checking for des_cbc_encrypt in -lcrypto" >&5 ac_lib_var=`echo crypto'_'des_cbc_encrypt | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4680,7 +4798,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypto $LIBS" cat > conftest.$ac_ext <<EOF -#line 4684 "configure" +#line 4802 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -4691,7 +4809,7 @@ int main() { des_cbc_encrypt() ; return 0; } EOF -if { (eval echo configure:4695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4813: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4725,17 +4843,17 @@ fi do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4729: checking for $ac_hdr" >&5 +echo "configure:4847: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4734 "configure" +#line 4852 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4857: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4764,7 +4882,7 @@ done if test "$ac_cv_header_openssl_cast_h" = "yes"; then echo $ac_n "checking for buggy CAST128""... $ac_c" 1>&6 -echo "configure:4768: checking for buggy CAST128" >&5 +echo "configure:4886: checking for buggy CAST128" >&5 if eval "test \"`echo '$''{'td_cv_buggy_cast128'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4772,7 +4890,7 @@ else td_cv_buggy_cast128="cross-compiling, assume yes" else cat > conftest.$ac_ext <<EOF -#line 4776 "configure" +#line 4894 "configure" #include "confdefs.h" #include <openssl/cast.h> @@ -4791,7 +4909,7 @@ main() return 1; } EOF -if { (eval echo configure:4795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then td_cv_buggy_cast128=yes else @@ -4825,17 +4943,17 @@ for ac_hdr in openssl/rc5.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4829: checking for $ac_hdr" >&5 +echo "configure:4947: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4834 "configure" +#line 4952 "configure" #include "confdefs.h" #include <$ac_hdr> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4839: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4957: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4880,7 +4998,7 @@ done # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:4884: checking for a BSD compatible install" >&5 +echo "configure:5002: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 diff --git a/missing/datalinks.c b/missing/datalinks.c new file mode 100644 index 00000000..64996971 --- /dev/null +++ b/missing/datalinks.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] = + "@(#) $Header: /tcpdump/master/tcpdump/missing/datalinks.c,v 1.1 2002-12-19 09:27:58 guy Exp $ (LBL)"; +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <stdlib.h> +#include <stdio.h> + +#include "pcap-missing.h" + +/* + * Stub versions for platforms that don't support them. + */ +int +pcap_list_datalinks(pcap_t *p, int **dlt_buffer) +{ + /* + * This platform doesn't support changing the DLT for an + * interface. Return a list of DLTs containing only the + * DLT this device supports. + */ + *dlt_buffer = (int*)malloc(sizeof(**dlt_buffer)); + if (*dlt_buffer == NULL) + return (-1); + **dlt_buffer = pcap_datalink(p); + return (1); +} diff --git a/missing/dlnames.c b/missing/dlnames.c new file mode 100644 index 00000000..1dd100a4 --- /dev/null +++ b/missing/dlnames.c @@ -0,0 +1,148 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +static const char rcsid[] = + "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.1 2002-12-19 09:27:58 guy Exp $ (LBL)"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <pcap.h> +#include <string.h> + +#include "pcap-missing.h" + +struct dlt_choice { + const char *name; + int dlt; +}; + +#define DLT_CHOICE(code) { #code, code } +#define DLT_CHOICE_SENTINEL { NULL, 0 } + +static struct dlt_choice dlt_choices[] = { + DLT_CHOICE(DLT_ARCNET), + DLT_CHOICE(DLT_EN10MB), + DLT_CHOICE(DLT_SLIP), + DLT_CHOICE(DLT_SLIP_BSDOS), + DLT_CHOICE(DLT_NULL), +#ifdef DLT_LOOP + DLT_CHOICE(DLT_LOOP), +#endif + DLT_CHOICE(DLT_PPP), +#ifdef DLT_C_HDLC + DLT_CHOICE(DLT_C_HDLC), +#endif +#ifdef DLT_PPP_SERIAL + DLT_CHOICE(DLT_PPP_SERIAL), +#endif +#ifdef DLT_PPP_ETHER + DLT_CHOICE(DLT_PPP_ETHER), +#endif + DLT_CHOICE(DLT_PPP_BSDOS), + DLT_CHOICE(DLT_FDDI), + DLT_CHOICE(DLT_IEEE802), +#ifdef DLT_IEEE802_11 + DLT_CHOICE(DLT_IEEE802_11), +#endif +#ifdef DLT_PRISM_HEADER + DLT_CHOICE(DLT_PRISM_HEADER), +#endif +#ifdef DLT_IEEE802_11_RADIO + DLT_CHOICE(DLT_IEEE802_11_RADIO), +#endif + DLT_CHOICE(DLT_ATM_RFC1483), +#ifdef DLT_ATM_CLIP + DLT_CHOICE(DLT_ATM_CLIP), +#endif +#ifdef DLT_SUNATM + DLT_CHOICE(DLT_SUNATM), +#endif + DLT_CHOICE(DLT_RAW), +#ifdef DLT_LINUX_SLL + DLT_CHOICE(DLT_LINUX_SLL), +#endif +#ifdef DLT_LTALK + DLT_CHOICE(DLT_LTALK), +#endif +#ifdef DLT_IP_OVER_FC + DLT_CHOICE(DLT_IP_OVER_FC), +#endif +#ifdef DLT_FRELAY + DLT_CHOICE(DLT_FRELAY), +#endif + +#ifdef DLT_LANE8023 + DLT_CHOICE(DLT_LANE8023), +#endif +#ifdef DLT_CIP + DLT_CHOICE(DLT_CIP), +#endif +#ifdef DLT_HDLC + DLT_CHOICE(DLT_HDLC), +#endif +#ifdef DLT_PFLOG + DLT_CHOICE(DLT_PFLOG), +#endif + DLT_CHOICE_SENTINEL +}; + +int +pcap_datalink_name_to_val(const char *name) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1, + name) == 0) + return (dlt_choices[i].dlt); + } + return (-1); +} + +const char * +pcap_datalink_val_to_name(int dlt) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (dlt_choices[i].dlt == dlt) + return (dlt_choices[i].name + sizeof("DLT_") - 1); + } + return (NULL); +} diff --git a/pcap-missing.h b/pcap-missing.h new file mode 100644 index 00000000..9a86110c --- /dev/null +++ b/pcap-missing.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 1988-2002 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.1 2002-12-19 09:27:57 guy Exp $ (LBL) + */ + +#ifndef tcpdump_pcap_missing_h +#define tcpdump_pcap_missing_h + +/* + * Declarations of functions that might be missing from libpcap. + */ + +#ifndef HAVE_PCAP_LIST_DATALINKS +extern int pcap_list_datalinks(pcap_t *, int **); +#endif + +#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL +/* + * We assume no platform has one but not the other. + */ +extern int pcap_datalink_name_to_val(const char *); +extern const char *pcap_datalink_val_to_name(int); +#endif + +#endif + + + + + + + + + @@ -30,7 +30,7 @@ static const char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.191 2002-12-19 05:44:47 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.192 2002-12-19 09:27:57 guy Exp $ (LBL)"; #endif /* @@ -62,17 +62,18 @@ extern int SIZE_BUF; #include <stdlib.h> #include <string.h> - #include "interface.h" #include "addrtoname.h" #include "machdep.h" #include "setsignal.h" #include "gmt2local.h" +#include "pcap-missing.h" int aflag; /* translate network and broadcast addresses */ int dflag; /* print filter code */ int eflag; /* print ethernet header */ int fflag; /* don't translate "foreign" IP address */ +int Lflag; /* list available data link types and exit */ int nflag; /* leave addresses as numbers */ int Nflag; /* remove domains from printed host names */ int Oflag = 1; /* run filter code optimizer */ @@ -88,6 +89,9 @@ int xflag; /* print packet in hex */ int Xflag; /* print packet in ascii as well as hex */ off_t Cflag = 0; /* rotate dump files after this many bytes */ int Aflag = 0; /* print packet only in ascii observing LF, CR, TAB, SPACE */ +int dlt = -1; /* if != -1, ask libpcap for the DLT it names */ + +const char *dlt_name = NULL; char *espsecret = NULL; /* ESP secret key */ @@ -103,6 +107,7 @@ int32_t thiszone; /* seconds offset from gmt to local time */ /* Forwards */ static RETSIGTYPE cleanup(int); static void usage(void) __attribute__((noreturn)); +static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn)); static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *); static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *); @@ -197,7 +202,7 @@ lookup_printer(int type) if (type == p->type) return p->f; - error("unknown data link type %d", type); + return NULL; /* NOTREACHED */ } @@ -213,12 +218,48 @@ struct dump_info { pcap_dumper_t *p; }; +static void +show_dlts_and_exit(pcap_t *pd) +{ + int n_dlts; + int *dlts = 0; + const char *dlt_name; + + n_dlts = pcap_list_datalinks(pd, &dlts); + if (n_dlts < 0) + error("%s", pcap_geterr(pd)); + else if (n_dlts == 0 || !dlts) + error("No data link types."); + + (void) fprintf(stderr, "Data link types (use option -y to set):\n"); + + while (--n_dlts >= 0) { + dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]); + if (dlt_name != NULL) { + (void) fprintf(stderr, " %s", dlt_name); + + /* + * OK, does tcpdump handle that type? + */ + if (lookup_printer(dlts[n_dlts]) == NULL) + (void) fprintf(stderr, " (not supported)"); + putchar('\n'); + } else { + (void) fprintf(stderr, " DLT %d (not supported)\n", + dlts[n_dlts]); + } + } + free(dlts); + exit(0); +} + int main(int argc, char **argv) { register int cnt, op, i; bpf_u_int32 localnet, netmask; register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName; + int type; pcap_handler printer; struct bpf_program fcode; #ifndef WIN32 @@ -263,12 +304,12 @@ main(int argc, char **argv) opterr = 0; while ( #ifdef WIN32 - (op = getopt(argc, argv, "aAB:c:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1) + (op = getopt(argc, argv, "aAB:c:C:dDeE:fF:i:lLm:nNOpqr:Rs:StT:uvw:xXy:Y")) != -1) #else /* WIN32 */ #ifdef HAVE_PCAP_FINDALLDEVS - (op = getopt(argc, argv, "aAc:C:dDeE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1) + (op = getopt(argc, argv, "aAc:C:dDeE:fF:i:lLm:nNOpqr:Rs:StT:uvw:xXy:Y")) != -1) #else /* HAVE_PCAP_FINDALLDEVS */ - (op = getopt(argc, argv, "aAc:C:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1) + (op = getopt(argc, argv, "aAc:C:deE:fF:i:lLm:nNOpqr:Rs:StT:uvw:xXy:Y")) != -1) #endif /* HAVE_PCAP_FINDALLDEVS */ #endif /* WIN32 */ switch (op) { @@ -277,11 +318,11 @@ main(int argc, char **argv) ++aflag; break; - case 'A': - ++xflag; - ++Xflag; - ++Aflag; - break; + case 'A': + ++xflag; + ++Xflag; + ++Aflag; + break; #ifdef WIN32 case 'B': @@ -323,6 +364,10 @@ main(int argc, char **argv) return 0; #endif /* HAVE_PCAP_FINDALLDEVS */ + case 'L': + Lflag++; + break; + case 'e': ++eflag; break; @@ -485,6 +530,13 @@ main(int argc, char **argv) ++Xflag; break; + case 'y': + dlt_name = optarg; + dlt = pcap_datalink_name_to_val(dlt_name); + if (dlt < 0) + error("invalid data link type %s", dlt_name); + break; + #if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG) case 'Y': { @@ -548,6 +600,27 @@ main(int argc, char **argv) error("%s", pcap_geterr(pd)); } #endif /* WIN32 */ + if (Lflag) + show_dlts_and_exit(pd); + if (dlt >= 0) { +#ifdef HAVE_PCAP_SET_DATALINK + if (pcap_set_datalink(pd, dlt) < 0) + error("%s", pcap_geterr(pd)); +#else + /* + * We don't actually support changing the + * data link type, so we only let them + * set it to what it already is. + */ + if (dlt != pcap_datalink(pd)) { + error("%s is not one of the DLTs supported by this device\n", + dlt_name); + } +#endif + (void)fprintf(stderr, "%s: data link type %s\n", + program_name, dlt_name); + (void)fflush(stderr); + } i = pcap_snapshot(pd); if (snaplen < i) { warning("snaplen raised from %d to %d", snaplen, i); @@ -604,7 +677,15 @@ main(int argc, char **argv) pcap_userdata = (u_char *)p; } } else { - printer = lookup_printer(pcap_datalink(pd)); + type = pcap_datalink(pd); + printer = lookup_printer(type); + if (printer == NULL) { + dlt_name = pcap_datalink_val_to_name(type); + if (dlt_name != NULL) + error("unsupported data link type %s", dlt_name); + else + error("unsupported data link type %d", type); + } pcap_userdata = 0; } #ifdef SIGINFO @@ -857,17 +938,19 @@ usage(void) #endif /* WIN32 */ (void)fprintf(stderr, #ifdef WIN32 -"Usage: %s [-aAdDeflnNOpqRStuvxX] [-B size] [-c count] [ -C file_size ]\n", program_name); +"Usage: %s [-aAdDeflLnNOpqRStuvxX] [-B size] [-c count] [ -C file_size ]\n", program_name); #else /* WIN32 */ #ifdef HAVE_PCAP_FINDALLDEVS -"Usage: %s [-aAdDeflnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name); +"Usage: %s [-aAdDeflLnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name); #else /* HAVE_PCAP_FINDALLDEVS */ -"Usage: %s [-aAdeflnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name); +"Usage: %s [-aAdeflLnNOpqRStuvxX] [-c count] [ -C file_size ]\n", program_name); #endif /* HAVE_PCAP_FINDALLDEVS */ #endif /* WIN32 */ (void)fprintf(stderr, -"\t\t[ -F file ] [ -i interface ] [ -r file ] [ -s snaplen ]\n"); +"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -r file ]\n"); + (void)fprintf(stderr, +"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -y datalinktype ]\n"); (void)fprintf(stderr, -"\t\t[ -T type ] [ -w file ] [ -E algo:secret ] [ expression ]\n"); +"\t\t[ expression ]\n"); exit(1); } |