From: guy Date: Tue, 18 Nov 2003 23:09:42 +0000 (+0000) Subject: Print both the name and the description of a link-layer type (the name X-Git-Tag: tcpdump-3.9.1~562 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/0cf35b497d9abccfd00bc8bf1c669bffe974da17 Print both the name and the description of a link-layer type (the name isn't always very suggestive - for example, somebody might think "EN10MB" is always 10 MB/s, and might not know that "IEEE802" is Token Ring), using "pcap_datalink_val_to_description()". Supply our own "pcap_datalink_val_to_description()" if libpcap doesn't have it (even if it has "pcap_datalink_name_to_val()"). --- diff --git a/acconfig.h b/acconfig.h index d9dcffc1..09e83515 100644 --- a/acconfig.h +++ b/acconfig.h @@ -83,6 +83,9 @@ /* define if libpcap has pcap_datalink_name_to_val() */ #undef HAVE_PCAP_DATALINK_NAME_TO_VAL +/* define if libpcap has pcap_datalink_val_to_description() */ +#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN diff --git a/aclocal.m4 b/aclocal.m4 index ac30b283..0d6c18de 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.100 2003-11-16 09:44:20 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.101 2003-11-18 23:09:42 guy Exp $ (LBL) dnl dnl Copyright (c) 1995, 1996, 1997, 1998 dnl The Regents of the University of California. All rights reserved. @@ -331,7 +331,12 @@ AC_DEFUN(AC_LBL_LIBPCAP, AC_CHECK_FUNC(pcap_set_datalink, AC_DEFINE(HAVE_PCAP_SET_DATALINK)) AC_CHECK_FUNC(pcap_datalink_name_to_val, - AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL), + [ + AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL) + AC_CHECK_FUNC(pcap_datalink_val_to_description, + AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION), + LIBOBJS="$LIBOBJS dlnames.o") + ], LIBOBJS="$LIBOBJS dlnames.o") dnl diff --git a/config.h.in b/config.h.in index bb522b93..2b2ad137 100644 --- a/config.h.in +++ b/config.h.in @@ -71,6 +71,9 @@ /* define if libpcap has pcap_datalink_name_to_val() */ #undef HAVE_PCAP_DATALINK_NAME_TO_VAL +/* define if libpcap has pcap_datalink_val_to_description() */ +#undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION + /* define if unaligned memory accesses fail */ #undef LBL_ALIGN diff --git a/configure b/configure index 62ee290d..255f9b67 100755 --- a/configure +++ b/configure @@ -3891,10 +3891,64 @@ fi if eval "test \"`echo '$ac_cv_func_'pcap_datalink_name_to_val`\" = yes"; then echo "$ac_t""yes" 1>&6 - cat >> confdefs.h <<\EOF + + cat >> confdefs.h <<\EOF #define HAVE_PCAP_DATALINK_NAME_TO_VAL 1 EOF + echo $ac_n "checking for pcap_datalink_val_to_description""... $ac_c" 1>&6 +echo "configure:3901: checking for pcap_datalink_val_to_description" >&5 +if eval "test \"`echo '$''{'ac_cv_func_pcap_datalink_val_to_description'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* 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_val_to_description(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_pcap_datalink_val_to_description) || defined (__stub___pcap_datalink_val_to_description) +choke me +#else +pcap_datalink_val_to_description(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3929: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_pcap_datalink_val_to_description=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_pcap_datalink_val_to_description=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'pcap_datalink_val_to_description`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1 +EOF + +else + echo "$ac_t""no" 1>&6 +LIBOBJS="$LIBOBJS dlnames.o" +fi + + else echo "$ac_t""no" 1>&6 LIBOBJS="$LIBOBJS dlnames.o" @@ -3904,12 +3958,12 @@ fi for ac_func in pcap_breakloop do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3908: checking for $ac_func" >&5 +echo "configure:3962: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3990: \"$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 @@ -3971,9 +4025,9 @@ done # to rename it. # echo $ac_n "checking for inet_ntop""... $ac_c" 1>&6 -echo "configure:3975: checking for inet_ntop" >&5 +echo "configure:4029: checking for inet_ntop" >&5 cat > conftest.$ac_ext < #include @@ -3984,7 +4038,7 @@ char src[4], dst[128]; inet_ntop(AF_INET, src, dst, sizeof(dst)); ; return 0; } EOF -if { (eval echo configure:3988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -3996,9 +4050,9 @@ else fi rm -f conftest* echo $ac_n "checking for inet_pton""... $ac_c" 1>&6 -echo "configure:4000: checking for inet_pton" >&5 +echo "configure:4054: checking for inet_pton" >&5 cat > conftest.$ac_ext < #include @@ -4009,7 +4063,7 @@ char src[128], dst[4]; inet_pton(AF_INET, src, dst); ; return 0; } EOF -if { (eval echo configure:4013: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -4021,9 +4075,9 @@ else fi rm -f conftest* echo $ac_n "checking for inet_aton""... $ac_c" 1>&6 -echo "configure:4025: checking for inet_aton" >&5 +echo "configure:4079: checking for inet_aton" >&5 cat > conftest.$ac_ext < #include @@ -4034,7 +4088,7 @@ struct in_addr dst; inet_aton(src, &dst); ; return 0; } EOF -if { (eval echo configure:4038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4092: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -4048,12 +4102,12 @@ rm -f conftest* echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:4052: checking if sockaddr struct has sa_len member" >&5 +echo "configure:4106: checking if sockaddr struct has sa_len member" >&5 if eval "test \"`echo '$''{'ac_cv_sockaddr_has_sa_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4062,7 +4116,7 @@ int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF -if { (eval echo configure:4066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4120: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sockaddr_has_sa_len=yes else @@ -4089,12 +4143,12 @@ fi for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4093: checking for $ac_func" >&5 +echo "configure:4147: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4175: \"$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 @@ -4143,9 +4197,9 @@ done if test $ac_cv_func_pcap_lib_version = "no" ; then echo $ac_n "checking whether pcap_version is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4147: checking whether pcap_version is defined by libpcap" >&5 +echo "configure:4201: checking whether pcap_version is defined by libpcap" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4218: \"$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 @@ -4181,9 +4235,9 @@ EOF fi fi echo $ac_n "checking whether pcap_debug is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4185: checking whether pcap_debug is defined by libpcap" >&5 +echo "configure:4239: checking whether pcap_debug is defined by libpcap" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4256: \"$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 @@ -4220,9 +4274,9 @@ else # OK, what about "yydebug"? # echo $ac_n "checking whether yydebug is defined by libpcap""... $ac_c" 1>&6 -echo "configure:4224: checking whether yydebug is defined by libpcap" >&5 +echo "configure:4278: checking whether yydebug is defined by libpcap" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4295: \"$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 @@ -4260,12 +4314,12 @@ fi for ac_func in bpf_dump do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4264: checking for $ac_func" >&5 +echo "configure:4318: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4346: \"$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 @@ -4345,12 +4399,12 @@ if test -f /dev/bpf0 ; then fi echo $ac_n "checking for int8_t using $CC""... $ac_c" 1>&6 -echo "configure:4349: checking for int8_t using $CC" >&5 +echo "configure:4403: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4421: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int8_t=yes else @@ -4383,12 +4437,12 @@ EOF fi echo $ac_n "checking for u_int8_t using $CC""... $ac_c" 1>&6 -echo "configure:4387: checking for u_int8_t using $CC" >&5 +echo "configure:4441: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int8_t=yes else @@ -4421,12 +4475,12 @@ EOF fi echo $ac_n "checking for int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4425: checking for int16_t using $CC" >&5 +echo "configure:4479: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4497: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int16_t=yes else @@ -4459,12 +4513,12 @@ EOF fi echo $ac_n "checking for u_int16_t using $CC""... $ac_c" 1>&6 -echo "configure:4463: checking for u_int16_t using $CC" >&5 +echo "configure:4517: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4535: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int16_t=yes else @@ -4497,12 +4551,12 @@ EOF fi echo $ac_n "checking for int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4501: checking for int32_t using $CC" >&5 +echo "configure:4555: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_int32_t=yes else @@ -4535,12 +4589,12 @@ EOF fi echo $ac_n "checking for u_int32_t using $CC""... $ac_c" 1>&6 -echo "configure:4539: checking for u_int32_t using $CC" >&5 +echo "configure:4593: 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 <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4611: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_have_u_int32_t=yes else @@ -4613,12 +4667,12 @@ EOF fi echo $ac_n "checking if sockaddr struct has sa_len member""... $ac_c" 1>&6 -echo "configure:4617: checking if sockaddr struct has sa_len member" >&5 +echo "configure:4671: 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 < @@ -4627,7 +4681,7 @@ int main() { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } EOF -if { (eval echo configure:4631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_lbl_sockaddr_has_sa_len=yes else @@ -4648,7 +4702,7 @@ EOF fi echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6 -echo "configure:4652: checking if unaligned accesses fail" >&5 +echo "configure:4706: 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 @@ -4744,12 +4798,12 @@ EOF echo $ac_n "checking for h_errno""... $ac_c" 1>&6 -echo "configure:4748: checking for h_errno" >&5 +echo "configure:4802: 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 < @@ -4758,7 +4812,7 @@ int main() { int foo = h_errno; ; return 0; } EOF -if { (eval echo configure:4762: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4816: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_var_h_errno=yes else @@ -4786,7 +4840,7 @@ if test "${with_crypto+set}" = set; then else echo $ac_n "checking for SSLeay""... $ac_c" 1>&6 -echo "configure:4790: checking for SSLeay" >&5 +echo "configure:4844: 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 @@ -4827,7 +4881,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:4831: checking for des_cbc_encrypt in -lcrypto" >&5 +echo "configure:4885: 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 @@ -4835,7 +4889,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcrypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4904: \"$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 @@ -4879,17 +4933,17 @@ fi do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:4883: checking for $ac_hdr" >&5 +echo "configure:4937: 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 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4893: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4947: \"$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* @@ -4939,7 +4993,7 @@ fi # 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:4943: checking for a BSD compatible install" >&5 +echo "configure:4997: 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/dlnames.c b/missing/dlnames.c index e2623b04..32072b78 100644 --- a/missing/dlnames.c +++ b/missing/dlnames.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.4 2003-11-16 09:36:47 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/missing/dlnames.c,v 1.5 2003-11-18 23:09:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -49,83 +49,93 @@ static const char rcsid[] _U_ = struct dlt_choice { const char *name; + const char *description; int dlt; }; -#define DLT_CHOICE(code) { #code, code } -#define DLT_CHOICE_SENTINEL { NULL, 0 } +#define DLT_CHOICE(code, description) { #code, description, code } +#define DLT_CHOICE_SENTINEL { NULL, NULL, 0 } static struct dlt_choice dlt_choices[] = { - DLT_CHOICE(DLT_ARCNET), - DLT_CHOICE(DLT_EN10MB), - DLT_CHOICE(DLT_SLIP), + DLT_CHOICE(DLT_NULL, "BSD loopback"), + DLT_CHOICE(DLT_EN10MB, "Ethernet"), + DLT_CHOICE(DLT_IEEE802, "Token ring"), + DLT_CHOICE(DLT_ARCNET, "ARCNET"), + 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_RAW, "Raw IP"), #ifdef DLT_SLIP_BSDOS - DLT_CHOICE(DLT_SLIP_BSDOS), + DLT_CHOICE(DLT_SLIP_BSDOS, "BSD/OS SLIP"), #endif - DLT_CHOICE(DLT_NULL), -#ifdef DLT_LOOP - DLT_CHOICE(DLT_LOOP), +#ifdef DLT_PPP_BSDOS + DLT_CHOICE(DLT_PPP_BSDOS, "BSD/OS PPP"), #endif - DLT_CHOICE(DLT_PPP), -#ifdef DLT_C_HDLC - DLT_CHOICE(DLT_C_HDLC), +#ifdef DLT_ATM_CLIP + DLT_CHOICE(DLT_ATM_CLIP, "Linux Classical IP-over-ATM"), #endif #ifdef DLT_PPP_SERIAL - DLT_CHOICE(DLT_PPP_SERIAL), + DLT_CHOICE(DLT_PPP_SERIAL, "PPP over serial"), #endif #ifdef DLT_PPP_ETHER - DLT_CHOICE(DLT_PPP_ETHER), + DLT_CHOICE(DLT_PPP_ETHER, "PPPoE"), #endif -#ifdef DLT_PPP_BSDOS - DLT_CHOICE(DLT_PPP_BSDOS), +#ifdef DLT_C_HDLC + DLT_CHOICE(DLT_C_HDLC, "Cisco HDLC"), #endif - 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), + DLT_CHOICE(DLT_IEEE802_11, "802.11"), #endif -#ifdef DLT_IEEE802_11_RADIO - DLT_CHOICE(DLT_IEEE802_11_RADIO), +#ifdef DLT_FRELAY + DLT_CHOICE(DLT_FRELAY, "Frame Relay"), #endif - DLT_CHOICE(DLT_ATM_RFC1483), -#ifdef DLT_ATM_CLIP - DLT_CHOICE(DLT_ATM_CLIP), +#ifdef DLT_LOOP + DLT_CHOICE(DLT_LOOP, "OpenBSD loopback"), #endif -#ifdef DLT_SUNATM - DLT_CHOICE(DLT_SUNATM), +#ifdef DLT_ENC + DLT_CHOICE(DLT_ENC, "OpenBSD encapsulated IP"), #endif - DLT_CHOICE(DLT_RAW), #ifdef DLT_LINUX_SLL - DLT_CHOICE(DLT_LINUX_SLL), + DLT_CHOICE(DLT_LINUX_SLL, "Linux cooked"), #endif #ifdef DLT_LTALK - DLT_CHOICE(DLT_LTALK), + DLT_CHOICE(DLT_LTALK, "Localtalk"), +#endif +#ifdef DLT_PFLOG + DLT_CHOICE(DLT_PFLOG, "OpenBSD pflog file"), +#endif +#ifdef DLT_PRISM_HEADER + DLT_CHOICE(DLT_PRISM_HEADER, "802.11 plus Prism header"), #endif #ifdef DLT_IP_OVER_FC - DLT_CHOICE(DLT_IP_OVER_FC), + DLT_CHOICE(DLT_IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"), #endif -#ifdef DLT_FRELAY - DLT_CHOICE(DLT_FRELAY), +#ifdef DLT_SUNATM + DLT_CHOICE(DLT_SUNATM, "Sun raw ATM"), +#endif +#ifdef DLT_IEEE802_11_RADIO + DLT_CHOICE(DLT_IEEE802_11_RADIO, "802.11 plus radio information header"), +#endif +#ifdef DLT_ARCNET_LINUX + DLT_CHOICE(DLT_ARCNET_LINUX, "Linux ARCNET"), +#endif +#ifdef DLT_LINUX_IRDA + DLT_CHOICE(DLT_LINUX_IRDA, "Linux IrDA"), #endif - #ifdef DLT_LANE8023 - DLT_CHOICE(DLT_LANE8023), + DLT_CHOICE(DLT_LANE8023, "Linux 802.3 LANE"), #endif #ifdef DLT_CIP - DLT_CHOICE(DLT_CIP), + DLT_CHOICE(DLT_CIP, "Linux Classical IP-over-ATM"), #endif #ifdef DLT_HDLC - DLT_CHOICE(DLT_HDLC), -#endif -#ifdef DLT_PFLOG - DLT_CHOICE(DLT_PFLOG), + DLT_CHOICE(DLT_HDLC, "Cisco HDLC"), #endif DLT_CHOICE_SENTINEL }; +#ifndef HAVE_PCAP_DATALINK_NAME_TO_VAL int pcap_datalink_name_to_val(const char *name) { @@ -150,3 +160,16 @@ pcap_datalink_val_to_name(int dlt) } return (NULL); } +#endif + +const char * +pcap_datalink_val_to_description(int dlt) +{ + int i; + + for (i = 0; dlt_choices[i].name != NULL; i++) { + if (dlt_choices[i].dlt == dlt) + return (dlt_choices[i].description); + } + return (NULL); +} diff --git a/pcap-missing.h b/pcap-missing.h index 9a86110c..64e5b00b 100644 --- a/pcap-missing.h +++ b/pcap-missing.h @@ -18,7 +18,7 @@ * 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) + * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.2 2003-11-18 23:09:42 guy Exp $ (LBL) */ #ifndef tcpdump_pcap_missing_h @@ -40,6 +40,10 @@ extern int pcap_datalink_name_to_val(const char *); extern const char *pcap_datalink_val_to_name(int); #endif +#ifndef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +extern const char *pcap_datalink_val_to_description(int); +#endif + #endif diff --git a/tcpdump.c b/tcpdump.c index a8b2fcae..b00683a8 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -30,7 +30,7 @@ static const char copyright[] _U_ = "@(#) 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[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.219 2003-11-18 08:53:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.220 2003-11-18 23:09:43 guy Exp $ (LBL)"; #endif /* @@ -256,7 +256,8 @@ show_dlts_and_exit(pcap_t *pd) while (--n_dlts >= 0) { dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]); if (dlt_name != NULL) { - (void) fprintf(stderr, " %s", dlt_name); + (void) fprintf(stderr, " %s (%s)", dlt_name, + pcap_datalink_val_to_description(dlts[n_dlts])); /* * OK, does tcpdump handle that type? @@ -634,10 +635,14 @@ main(int argc, char **argv) error("%s", ebuf); dlt = pcap_datalink(pd); dlt_name = pcap_datalink_val_to_name(dlt); - if (dlt_name == NULL) - dlt_name = "???"; - printf("reading from file %s, link-type %u (%s)\n", - RFileName, dlt, dlt_name); + if (dlt_name == NULL) { + printf("reading from file %s, link-type %u\n", + RFileName, dlt); + } else { + printf("reading from file %s, link-type %s (%s)\n", + RFileName, dlt_name, + pcap_datalink_val_to_description(dlt)); + } localnet = 0; netmask = 0; if (fflag != 0) @@ -783,10 +788,14 @@ main(int argc, char **argv) (void)fprintf(stderr, "%s: ", program_name); dlt = pcap_datalink(pd); dlt_name = pcap_datalink_val_to_name(dlt); - if (dlt_name == NULL) - dlt_name = "???"; - (void)fprintf(stderr, "listening on %s, link-type %u (%s), capture size %u bytes\n", - device, dlt, dlt_name, snaplen); + if (dlt_name == NULL) { + (void)fprintf(stderr, "listening on %s, link-type %u, capture size %u bytes\n", + device, dlt, snaplen); + } else { + (void)fprintf(stderr, "listening on %s, link-type %s (%s), capture size %u bytes\n", + device, dlt_name, + pcap_datalink_val_to_description(dlt), snaplen); + } (void)fflush(stderr); } #endif /* WIN32 */