diff options
author | sam <sam@FreeBSD.org> | 2005-07-11 03:54:22 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2005-07-11 03:54:22 +0000 |
commit | 357fae9fdf73c79a5782f504a8f5a3cac82c0557 (patch) | |
tree | b68926b8180e315dce4092f21e6a7e7e9344b68a /contrib/tcpdump | |
parent | 6c6937427c2191e884402043ff0843960687f7b2 (diff) | |
parent | 1166f90fe87cef69f7923a1b8c386eecdc6cb92b (diff) | |
download | FreeBSD-src-357fae9fdf73c79a5782f504a8f5a3cac82c0557.zip FreeBSD-src-357fae9fdf73c79a5782f504a8f5a3cac82c0557.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r147899,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/tcpdump')
59 files changed, 3330 insertions, 818 deletions
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES index db20780..23e07ef 100644 --- a/contrib/tcpdump/CHANGES +++ b/contrib/tcpdump/CHANGES @@ -1,4 +1,40 @@ -$Header: /tcpdump/master/tcpdump/CHANGES,v 1.87 2004/03/30 14:42:38 mcr Exp $ +$Header: /tcpdump/master/tcpdump/CHANGES,v 1.87.2.1 2005/07/05 21:08:01 mcr Exp $ + +Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.x tcpdump + + Option to chroot() when dropping privs + Fixes for compiling on nearly every platform, + including improved 64bit support + Many new testcases + Support for sending packets + Many compliation fixes on most platforms + Fixes for recent version of GCC to eliminate warnings + Improved Unicode support + + Decoders & DLT Changes, Updates and New: + AES ESP support + Juniper ATM, FRF.15, FRF.16, PPPoE, + ML-FR, ML-PIC, ML-PPP, PL-PPP, LS-PIC + GGSN,ES,MONITOR,SERVICES + L2VPN + Axent Raptor/Symantec Firewall + TCP-MD5 (RFC 2385) + ESP-in-UDP (RFC 3948) + ATM OAM + LMP, LMP Service Discovery + IP over FC + IP over IEEE 1394 + BACnet MS/TP + SS7 + LDP over TCP + PGM (RFC 3208) + LSP-PING + G.7041/Y.1303 Generic Framing Procedure + EIGRP-IP, EIGRP-IPX + ICMP6 + Radio - via radiotap + DHCPv6 + HDLC over PPP Tue. March 30, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.3 release diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS index 0370e07..9332def 100644 --- a/contrib/tcpdump/CREDITS +++ b/contrib/tcpdump/CREDITS @@ -17,6 +17,7 @@ Additional people who have contributed patches: Andrew Church <andrew@users.sourceforge.net> Andrew Hintz <adhintz@users.sourceforge.net> Andrew Tridgell <tridge@linuxcare.com> + Andy Heffernan <ahh@juniper.net> Arkadiusz Miskiewicz <misiek@pld.org.pl> Armando L. Caro Jr. <acaro@mail.eecis.udel.edu> Atsushi Onoe <onoe@netbsd.org> @@ -76,6 +77,7 @@ Additional people who have contributed patches: Loris Degioanni <loris@netgroup-serv.polito.it> Love Hörnquist-Åstrand <lha@stacken.kth.se> Maciej W. Rozycki <macro@ds2.pg.gda.pl> + Manu Pathak <mapathak@cisco.com> Marc A. Lehmann <pcg@goof.com> Mark Ellzey Thomas <mark@ackers.net> Marko Kiiskila <carnil@cs.tut.fi> @@ -93,6 +95,7 @@ Additional people who have contributed patches: Niels Provos <provos@openbsd.org> Nickolai Zeldovich <kolya@MIT.EDU> Nicolas Ferrero <toorop@babylo.net> + Noritoshi Demizu <demizu@users.sourceforge.net> Olaf Kirch <okir@caldera.de> Onno van der Linden <onno@simplex.nl> Pascal Hennequin <pascal.hennequin@int-evry.fr> diff --git a/contrib/tcpdump/FILES b/contrib/tcpdump/FILES index 2479f27..ebd02cb 100644 --- a/contrib/tcpdump/FILES +++ b/contrib/tcpdump/FILES @@ -103,6 +103,7 @@ oui.c oui.h packetdat.awk parsenfsfh.c +pcap_dump_ftell.c pcap-missing.h pf.h pmap_prot.h @@ -171,6 +172,7 @@ print-null.c print-ospf.c print-ospf6.c print-pflog.c +print-pgm.c print-pim.c print-ppp.c print-pppoe.c diff --git a/contrib/tcpdump/INSTALL b/contrib/tcpdump/INSTALL index 8ffb9f8..2aaa18e 100644 --- a/contrib/tcpdump/INSTALL +++ b/contrib/tcpdump/INSTALL @@ -1,4 +1,4 @@ -@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.63 2004/12/27 00:41:29 guy Exp $ (LBL) +@(#) $Header: /tcpdump/master/tcpdump/INSTALL,v 1.63.2.2 2005/06/03 22:10:15 guy Exp $ (LBL) If you have not built libpcap, do so first. See the README file in this directory for the ftp location. @@ -124,6 +124,8 @@ 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_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap + doesn't have it pcap-missing.h - declarations of functions possibly missing from libpcap pf.h - OpenBSD PF definitions pmap_prot.h - definitions for ONC RPC portmapper protocol @@ -186,6 +188,7 @@ print-null.c - BSD loopback device printer routines print-ospf.c - Open Shortest Path First printer routines print-ospf6.c - IPv6 Open Shortest Path First printer routines print-pflog.c - OpenBSD packet filter log file printer routines +print-pgm.c - Pragmatic General Multicast printer routines print-pim.c - Protocol Independent Multicast printer routines print-ppp.c - Point to Point Protocol printer routines print-pppoe.c - PPP-over-Ethernet printer routines diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in index c7ead57..1778f85 100644 --- a/contrib/tcpdump/Makefile.in +++ b/contrib/tcpdump/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.293 2004/10/29 11:42:53 hannes Exp $ (LBL) +# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.293.2.1 2005/05/20 21:15:45 hannes Exp $ (LBL) # # Various configurable paths (remember to edit Makefile.in, not Makefile) @@ -81,7 +81,7 @@ CSRC = addrtoname.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \ print-lmp.c print-lspping.c \ print-lwres.c print-mobile.c print-mpls.c print-msdp.c \ print-nfs.c print-ntp.c print-null.c print-ospf.c \ - print-pflog.c print-pim.c print-ppp.c print-pppoe.c \ + print-pflog.c print-pgm.c print-pim.c print-ppp.c print-pppoe.c \ print-pptp.c print-radius.c print-raw.c print-rip.c \ print-rsvp.c print-rx.c print-sctp.c print-sip.c print-sl.c print-sll.c \ print-snmp.c print-stp.c print-sunatm.c print-sunrpc.c \ diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION index b233a76..6bd1074 100644 --- a/contrib/tcpdump/VERSION +++ b/contrib/tcpdump/VERSION @@ -1 +1 @@ -3.9-PRE-CVS +3.9.1 diff --git a/contrib/tcpdump/acconfig.h b/contrib/tcpdump/acconfig.h index 4a743b8..f28d52c 100644 --- a/contrib/tcpdump/acconfig.h +++ b/contrib/tcpdump/acconfig.h @@ -20,9 +20,6 @@ /* define if your struct __res_state has the nsort member */ #undef HAVE_NEW_RES_STATE -/* define if <inttypes.h> defines PRI[doxu]64 macros */ -#undef INTTYPES_H_DEFINES_FORMATS - /* * define if struct ether_header.ether_dhost is a struct with ether_addr_octet */ @@ -88,6 +85,9 @@ /* define if libpcap has pcap_datalink_val_to_description() */ #undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +/* define if libpcap has pcap_dump_ftell() */ +#undef HAVE_PCAP_DUMP_FTELL + /* define if you have getrpcbynumber() */ #undef HAVE_GETRPCBYNUMBER @@ -106,17 +106,6 @@ /* AIX hack. */ #undef _SUN -/* Workaround for missing sized types */ -/* XXX this should move to the more standard uint*_t */ -#undef int8_t -#undef int16_t -#undef int32_t -#undef int64_t -#undef u_int8_t -#undef u_int16_t -#undef u_int32_t -#undef u_int64_t - /* Workaround for missing 64-bit formats */ #undef PRId64 #undef PRIo64 diff --git a/contrib/tcpdump/atm.h b/contrib/tcpdump/atm.h index 4fe2021..c6ac53e 100644 --- a/contrib/tcpdump/atm.h +++ b/contrib/tcpdump/atm.h @@ -14,7 +14,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.1 2002/07/11 09:17:22 guy Exp $ + * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.1.4.1 2005/06/20 07:45:05 hannes Exp $ */ /* @@ -23,3 +23,10 @@ #define ATM_UNKNOWN 0 /* Unknown */ #define ATM_LANE 1 /* LANE */ #define ATM_LLC 2 /* LLC encapsulation */ + +/* + * some OAM cell captures (most notably Juniper's) + * do not deliver a heading HEC byte + */ +#define ATM_OAM_NOHEC 0 +#define ATM_OAM_HEC 1 diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in index a02d6b7..dbda505 100644 --- a/contrib/tcpdump/config.h.in +++ b/contrib/tcpdump/config.h.in @@ -20,9 +20,6 @@ /* define if your struct __res_state has the nsort member */ #undef HAVE_NEW_RES_STATE -/* define if <inttypes.h> defines PRI[doxu]64 macros */ -#undef INTTYPES_H_DEFINES_FORMATS - /* * define if struct ether_header.ether_dhost is a struct with ether_addr_octet */ @@ -88,6 +85,9 @@ /* define if libpcap has pcap_datalink_val_to_description() */ #undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION +/* define if libpcap has pcap_dump_ftell() */ +#undef HAVE_PCAP_DUMP_FTELL + /* define if you have getrpcbynumber() */ #undef HAVE_GETRPCBYNUMBER @@ -106,17 +106,6 @@ /* AIX hack. */ #undef _SUN -/* Workaround for missing sized types */ -/* XXX this should move to the more standard uint*_t */ -#undef int8_t -#undef int16_t -#undef int32_t -#undef int64_t -#undef u_int8_t -#undef u_int16_t -#undef u_int32_t -#undef u_int64_t - /* Workaround for missing 64-bit formats */ #undef PRId64 #undef PRIo64 @@ -261,6 +250,12 @@ /* Define to 1 if you have the `strsep' function. */ #undef HAVE_STRSEP +/* 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/bitypes.h> header file. */ +#undef HAVE_SYS_BITYPES_H + /* Define to 1 if you have the <sys/stat.h> header file. */ #undef HAVE_SYS_STAT_H @@ -326,3 +321,27 @@ /* Define as token for inline if inlining supported */ #undef inline + +/* Define to `short' if int16_t not defined. */ +#undef int16_t + +/* Define to `int' if int32_t not defined. */ +#undef int32_t + +/* Define to `long long' if int64_t not defined. */ +#undef int64_t + +/* Define to `signed char' if int8_t not defined. */ +#undef int8_t + +/* Define to `unsigned short' if u_int16_t not defined. */ +#undef u_int16_t + +/* Define to `unsigned int' if u_int32_t not defined. */ +#undef u_int32_t + +/* Define to `unsigned long long' if u_int64_t not defined. */ +#undef u_int64_t + +/* Define to `unsigned char' if u_int8_t not defined. */ +#undef u_int8_t diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure index 3af0745..60efb94 100755 --- a/contrib/tcpdump/configure +++ b/contrib/tcpdump/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.188 . +# From configure.in Revision: 1.188.2.6 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # @@ -2503,8 +2503,6 @@ _ACEOF echo "$as_me:$LINENO: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6 - save_CFLAGS="$CFLAGS" - CFLAGS="$V_CCOPT" if test "${ac_cv_lbl_inline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2570,7 +2568,6 @@ rm -f conftest.$ac_objext conftest.$ac_ext fi fi - CFLAGS="$save_CFLAGS" if test ! -z "$ac_cv_lbl_inline" ; then echo "$as_me:$LINENO: result: $ac_cv_lbl_inline" >&5 echo "${ECHO_T}$ac_cv_lbl_inline" >&6 @@ -2600,10 +2597,6 @@ cat >>conftest.$ac_ext <<_ACEOF #include <stdlib.h> -int -main () -{ - static void foo(void) __attribute__ ((noreturn)); static void @@ -2612,9 +2605,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 @@ -8446,7 +8442,9 @@ if test $ac_cv_func_pcap_list_datalinks = yes; then _ACEOF else - LIBOBJS="$LIBOBJS datalinks.$ac_objext" + + LIBOBJS="$LIBOBJS datalinks.$ac_objext" + fi echo "$as_me:$LINENO: checking for pcap_set_datalink" >&5 @@ -8684,12 +8682,16 @@ if test $ac_cv_func_pcap_datalink_val_to_description = yes; then _ACEOF else - LIBOBJS="$LIBOBJS dlnames.$ac_objext" + + LIBOBJS="$LIBOBJS dlnames.$ac_objext" + fi else - LIBOBJS="$LIBOBJS dlnames.$ac_objext" + + LIBOBJS="$LIBOBJS dlnames.$ac_objext" + fi @@ -8778,6 +8780,90 @@ fi done + echo "$as_me:$LINENO: checking for pcap_dump_ftell" >&5 +echo $ECHO_N "checking for pcap_dump_ftell... $ECHO_C" >&6 +if test "${ac_cv_func_pcap_dump_ftell+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. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pcap_dump_ftell (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pcap_dump_ftell (); +/* 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_dump_ftell) || defined (__stub___pcap_dump_ftell) +choke me +#else +char (*f) () = pcap_dump_ftell; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != pcap_dump_ftell; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (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_func_pcap_dump_ftell=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_pcap_dump_ftell=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_pcap_dump_ftell" >&5 +echo "${ECHO_T}$ac_cv_func_pcap_dump_ftell" >&6 +if test $ac_cv_func_pcap_dump_ftell = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_PCAP_DUMP_FTELL 1 +_ACEOF + +else + + LIBOBJS="$LIBOBJS pcap_dump_ftell.$ac_objext" + +fi + + # # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate @@ -9114,6 +9200,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> @@ -9156,26 +9243,14 @@ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5 echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6 if test $ac_cv_have_decl_ether_ntohost = yes; then -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_NTOHOST 1 -_ACEOF - - cat >>confdefs.h <<\_ACEOF #define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST _ACEOF -else - cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_NTOHOST 0 -_ACEOF - - fi - fi # # Did that succeed? @@ -9386,27 +9461,101 @@ echo "$as_me:$LINENO: result: $ac_cv_have_decl_ether_ntohost" >&5 echo "${ECHO_T}$ac_cv_have_decl_ether_ntohost" >&6 if test $ac_cv_have_decl_ether_ntohost = yes; then -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_ETHER_NTOHOST 1 + +cat >>confdefs.h <<\_ACEOF +#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST _ACEOF +fi -cat >>confdefs.h <<\_ACEOF -#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST + fi + fi + # + # Is ether_ntohost() declared? + # + if test "$ac_cv_have_decl_ether_ntohost" != 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_NTOHOST 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_NTOHOST 0 +_ACEOF + + else + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DECL_ETHER_NTOHOST 1 +_ACEOF + fi fi @@ -9899,29 +10048,169 @@ if test -f /dev/bpf0 ; then V_GROUP=bpf fi -echo "$as_me:$LINENO: checking for int8_t using $CC" >&5 -echo $ECHO_N "checking for int8_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_int8_t+set}" = set; then + +for ac_header in sys/bitypes.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else - cat >conftest.$ac_ext <<_ACEOF + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +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. */ +$ac_includes_default +#include <$ac_header> +_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_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +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 <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking for int8_t" >&5 +echo $ECHO_N "checking for int8_t... $ECHO_C" >&6 +if test "${ac_cv_type_int8_t+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. */ +$ac_includes_default int main () { -int8_t i +if ((int8_t *) 0) + return 0; +if (sizeof (int8_t)) + return 0; ; return 0; } @@ -9938,27 +10227,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_int8_t=yes + ac_cv_type_int8_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_int8_t=no +ac_cv_type_int8_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_int8_t" >&5 +echo "${ECHO_T}$ac_cv_type_int8_t" >&6 +if test $ac_cv_type_int8_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int8_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_int8_t" >&6 - if test $ac_cv_lbl_have_int8_t = no ; then - cat >>confdefs.h <<\_ACEOF +cat >>confdefs.h <<\_ACEOF #define int8_t signed char _ACEOF - fi -echo "$as_me:$LINENO: checking for u_int8_t using $CC" >&5 -echo $ECHO_N "checking for u_int8_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_u_int8_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for u_int8_t" >&5 +echo $ECHO_N "checking for u_int8_t... $ECHO_C" >&6 +if test "${ac_cv_type_u_int8_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -9968,17 +10260,18 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif int main () { -u_int8_t i +if ((u_int8_t *) 0) + return 0; +if (sizeof (u_int8_t)) + return 0; ; return 0; } @@ -9995,27 +10288,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_u_int8_t=yes + ac_cv_type_u_int8_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_u_int8_t=no +ac_cv_type_u_int8_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_u_int8_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int8_t" >&6 +if test $ac_cv_type_u_int8_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int8_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_u_int8_t" >&6 - if test $ac_cv_lbl_have_u_int8_t = no ; then - cat >>confdefs.h <<\_ACEOF -#define u_int8_t u_char +cat >>confdefs.h <<\_ACEOF +#define u_int8_t unsigned char _ACEOF - fi -echo "$as_me:$LINENO: checking for int16_t using $CC" >&5 -echo $ECHO_N "checking for int16_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_int16_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for int16_t" >&5 +echo $ECHO_N "checking for int16_t... $ECHO_C" >&6 +if test "${ac_cv_type_int16_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10025,17 +10321,14 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif +$ac_includes_default int main () { -int16_t i +if ((int16_t *) 0) + return 0; +if (sizeof (int16_t)) + return 0; ; return 0; } @@ -10052,27 +10345,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_int16_t=yes + ac_cv_type_int16_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_int16_t=no +ac_cv_type_int16_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_int16_t" >&5 +echo "${ECHO_T}$ac_cv_type_int16_t" >&6 +if test $ac_cv_type_int16_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int16_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_int16_t" >&6 - if test $ac_cv_lbl_have_int16_t = no ; then - cat >>confdefs.h <<\_ACEOF +cat >>confdefs.h <<\_ACEOF #define int16_t short _ACEOF - fi -echo "$as_me:$LINENO: checking for u_int16_t using $CC" >&5 -echo $ECHO_N "checking for u_int16_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_u_int16_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for u_int16_t" >&5 +echo $ECHO_N "checking for u_int16_t... $ECHO_C" >&6 +if test "${ac_cv_type_u_int16_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10082,17 +10378,18 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif int main () { -u_int16_t i +if ((u_int16_t *) 0) + return 0; +if (sizeof (u_int16_t)) + return 0; ; return 0; } @@ -10109,27 +10406,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_u_int16_t=yes + ac_cv_type_u_int16_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_u_int16_t=no +ac_cv_type_u_int16_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_u_int16_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int16_t" >&6 +if test $ac_cv_type_u_int16_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int16_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_u_int16_t" >&6 - if test $ac_cv_lbl_have_u_int16_t = no ; then - cat >>confdefs.h <<\_ACEOF -#define u_int16_t u_short +cat >>confdefs.h <<\_ACEOF +#define u_int16_t unsigned short _ACEOF - fi -echo "$as_me:$LINENO: checking for int32_t using $CC" >&5 -echo $ECHO_N "checking for int32_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_int32_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for int32_t" >&5 +echo $ECHO_N "checking for int32_t... $ECHO_C" >&6 +if test "${ac_cv_type_int32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10139,17 +10439,14 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif +$ac_includes_default int main () { -int32_t i +if ((int32_t *) 0) + return 0; +if (sizeof (int32_t)) + return 0; ; return 0; } @@ -10166,27 +10463,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_int32_t=yes + ac_cv_type_int32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_int32_t=no +ac_cv_type_int32_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_int32_t" >&5 +echo "${ECHO_T}$ac_cv_type_int32_t" >&6 +if test $ac_cv_type_int32_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int32_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_int32_t" >&6 - if test $ac_cv_lbl_have_int32_t = no ; then - cat >>confdefs.h <<\_ACEOF +cat >>confdefs.h <<\_ACEOF #define int32_t int _ACEOF - fi -echo "$as_me:$LINENO: checking for u_int32_t using $CC" >&5 -echo $ECHO_N "checking for u_int32_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_u_int32_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for u_int32_t" >&5 +echo $ECHO_N "checking for u_int32_t... $ECHO_C" >&6 +if test "${ac_cv_type_u_int32_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10196,17 +10496,18 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif int main () { -u_int32_t i +if ((u_int32_t *) 0) + return 0; +if (sizeof (u_int32_t)) + return 0; ; return 0; } @@ -10223,27 +10524,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_u_int32_t=yes + ac_cv_type_u_int32_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_u_int32_t=no +ac_cv_type_u_int32_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_u_int32_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int32_t" >&6 +if test $ac_cv_type_u_int32_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int32_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_u_int32_t" >&6 - if test $ac_cv_lbl_have_u_int32_t = no ; then - cat >>confdefs.h <<\_ACEOF -#define u_int32_t u_int +cat >>confdefs.h <<\_ACEOF +#define u_int32_t unsigned int _ACEOF - fi -echo "$as_me:$LINENO: checking for int64_t using $CC" >&5 -echo $ECHO_N "checking for int64_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_int64_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for int64_t" >&5 +echo $ECHO_N "checking for int64_t... $ECHO_C" >&6 +if test "${ac_cv_type_int64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10253,17 +10557,14 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif +$ac_includes_default int main () { -int64_t i +if ((int64_t *) 0) + return 0; +if (sizeof (int64_t)) + return 0; ; return 0; } @@ -10280,27 +10581,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_int64_t=yes + ac_cv_type_int64_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_int64_t=no +ac_cv_type_int64_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_int64_t" >&5 +echo "${ECHO_T}$ac_cv_type_int64_t" >&6 +if test $ac_cv_type_int64_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_int64_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_int64_t" >&6 - if test $ac_cv_lbl_have_int64_t = no ; then - cat >>confdefs.h <<\_ACEOF +cat >>confdefs.h <<\_ACEOF #define int64_t long long _ACEOF - fi -echo "$as_me:$LINENO: checking for u_int64_t using $CC" >&5 -echo $ECHO_N "checking for u_int64_t using $CC... $ECHO_C" >&6 - if test "${ac_cv_lbl_have_u_int64_t+set}" = set; then +fi + +echo "$as_me:$LINENO: checking for u_int64_t" >&5 +echo $ECHO_N "checking for u_int64_t... $ECHO_C" >&6 +if test "${ac_cv_type_u_int64_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -10310,17 +10614,18 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif -# include "confdefs.h" -# include <sys/types.h> -# if STDC_HEADERS -# include <stdlib.h> -# include <stddef.h> -# endif int main () { -u_int64_t i +if ((u_int64_t *) 0) + return 0; +if (sizeof (u_int64_t)) + return 0; ; return 0; } @@ -10337,24 +10642,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_lbl_have_u_int64_t=yes + ac_cv_type_u_int64_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lbl_have_u_int64_t=no +ac_cv_type_u_int64_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_type_u_int64_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int64_t" >&6 +if test $ac_cv_type_u_int64_t = yes; then + : +else - echo "$as_me:$LINENO: result: $ac_cv_lbl_have_u_int64_t" >&5 -echo "${ECHO_T}$ac_cv_lbl_have_u_int64_t" >&6 - if test $ac_cv_lbl_have_u_int64_t = no ; then - cat >>confdefs.h <<\_ACEOF +cat >>confdefs.h <<\_ACEOF #define u_int64_t unsigned long long _ACEOF - fi +fi + # # We can't just check for <inttypes.h> - some systems have one that @@ -10515,6 +10823,9 @@ cat >>conftest.$ac_ext <<_ACEOF #include <inttypes.h> #include <stdio.h> #include <sys/types.h> + #ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> + #endif main() { @@ -10567,12 +10878,89 @@ fi done -if test "$ac_lbl_inttypes_h_defines_formats" = yes; then - cat >>confdefs.h <<\_ACEOF -#define INTTYPES_H_DEFINES_FORMATS 1 +if test "$ac_lbl_inttypes_h_defines_formats" = no; then + + echo "$as_me:$LINENO: checking whether %lx can be used to format 64-bit integers" >&5 +echo $ECHO_N "checking whether %lx can be used to format 64-bit integers... $ECHO_C" >&6 + if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +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. */ + +# ifdef HAVE_INTTYPES_H + #include <inttypes.h> +# endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif + #include <stdio.h> + #include <sys/types.h> + + main() + { + u_int64_t t = 1; + char strbuf[16+1]; + sprintf(strbuf, "%016lx", t << 32); + if (strcmp(strbuf, "0000000100000000") == 0) + exit(0); + else + exit(1); + } + + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (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 + + cat >>confdefs.h <<\_ACEOF +#define PRId64 "ld" _ACEOF + cat >>confdefs.h <<\_ACEOF +#define PRIo64 "lo" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIx64 "lx" +_ACEOF + + cat >>confdefs.h <<\_ACEOF +#define PRIu64 "lu" +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + echo "$as_me:$LINENO: checking whether %llx can be used to format 64-bit integers" >&5 echo $ECHO_N "checking whether %llx can be used to format 64-bit integers... $ECHO_C" >&6 @@ -10595,6 +10983,9 @@ cat >>conftest.$ac_ext <<_ACEOF # ifdef HAVE_INTTYPES_H #include <inttypes.h> # endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif #include <stdio.h> #include <sys/types.h> @@ -10674,6 +11065,9 @@ cat >>conftest.$ac_ext <<_ACEOF # ifdef HAVE_INTTYPES_H #include <inttypes.h> # endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif #include <stdio.h> #include <sys/types.h> @@ -10753,6 +11147,9 @@ cat >>conftest.$ac_ext <<_ACEOF # ifdef HAVE_INTTYPES_H #include <inttypes.h> # endif +# ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> +# endif #include <stdio.h> #include <sys/types.h> @@ -10810,7 +11207,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 - { { echo "$as_me:$LINENO: error: neither %llx nor %Lx nor %qx worked on a 64-bit integer" >&5 + { { echo "$as_me:$LINENO: error: neither %llx nor %Lx nor %qx worked on a 64-bit integer" >&5 echo "$as_me: error: neither %llx nor %Lx nor %qx worked on a 64-bit integer" >&2;} { (exit 1); exit 1; }; } @@ -10831,6 +11228,12 @@ fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + fi rm -f os-proto.h diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in index 1bb29bb..220289a 100755 --- a/contrib/tcpdump/configure.in +++ b/contrib/tcpdump/configure.in @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.188 2005/03/27 23:16:08 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.188.2.6 2005/04/24 01:36:19 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.188 $) +AC_REVISION($Revision: 1.188.2.6 $) AC_PREREQ(2.50) AC_INIT(tcpdump.c) @@ -619,7 +619,7 @@ if test "$ac_cv_func_ether_ntohost" = yes -a \ # # Yes. Does it declare ether_ntohost()? # - AC_CHECK_DECLS(ether_ntohost, + AC_CHECK_DECL(ether_ntohost, [ AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,, [Define to 1 if netinet/if_ether.h declares `ether_ntohost']) @@ -628,6 +628,7 @@ if test "$ac_cv_func_ether_ntohost" = yes -a \ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> +#include <arpa/inet.h> struct mbuf; struct rtentry; #include <net/if.h> @@ -650,7 +651,7 @@ struct rtentry; # suppress the next test. # unset ac_cv_have_decl_ether_ntohost - AC_CHECK_DECLS(ether_ntohost, + AC_CHECK_DECL(ether_ntohost, [ AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,, [Define to 1 if netinet/ether.h declares `ether_ntohost']) @@ -660,6 +661,33 @@ struct rtentry; ]) fi fi + # + # Is ether_ntohost() declared? + # + if test "$ac_cv_have_decl_ether_ntohost" != 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_NTOHOST, 0, + [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you +don't.]) + else + AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1, + [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you +don't.]) + fi fi dnl portability macros for getaddrinfo/getnameinfo @@ -761,14 +789,48 @@ if test -f /dev/bpf0 ; then V_GROUP=bpf fi -AC_LBL_CHECK_TYPE(int8_t, signed char) -AC_LBL_CHECK_TYPE(u_int8_t, u_char) -AC_LBL_CHECK_TYPE(int16_t, short) -AC_LBL_CHECK_TYPE(u_int16_t, u_short) -AC_LBL_CHECK_TYPE(int32_t, int) -AC_LBL_CHECK_TYPE(u_int32_t, u_int) -AC_LBL_CHECK_TYPE(int64_t, long long) -AC_LBL_CHECK_TYPE(u_int64_t, unsigned long long) +AC_CHECK_HEADERS(sys/bitypes.h) + +AC_CHECK_TYPE([int8_t], , + [AC_DEFINE([int8_t], [signed char], + [Define to `signed char' if int8_t not defined.])]) +AC_CHECK_TYPE([u_int8_t], , + [AC_DEFINE([u_int8_t], [unsigned char], + [Define to `unsigned char' if u_int8_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int16_t], , + [AC_DEFINE([int16_t], [short], + [Define to `short' if int16_t not defined.])]) +AC_CHECK_TYPE([u_int16_t], , + [AC_DEFINE([u_int16_t], [unsigned short], + [Define to `unsigned short' if u_int16_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int32_t], , + [AC_DEFINE([int32_t], [int], + [Define to `int' if int32_t not defined.])]) +AC_CHECK_TYPE([u_int32_t], , + [AC_DEFINE([u_int32_t], [unsigned int], + [Define to `unsigned int' if u_int32_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) +AC_CHECK_TYPE([int64_t], , + [AC_DEFINE([int64_t], [long long], + [Define to `long long' if int64_t not defined.])]) +AC_CHECK_TYPE([u_int64_t], , + [AC_DEFINE([u_int64_t], [unsigned long long], + [Define to `unsigned long long' if u_int64_t not defined.])], + [AC_INCLUDES_DEFAULT +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif]) # # We can't just check for <inttypes.h> - some systems have one that @@ -787,6 +849,9 @@ AC_CHECK_HEADERS(inttypes.h, #include <inttypes.h> #include <stdio.h> #include <sys/types.h> + #ifdef HAVE_SYS_BITYPES_H + #include <sys/bitypes.h> + #endif main() { @@ -813,16 +878,17 @@ AC_CHECK_HEADERS(inttypes.h, # ac_lbl_inttypes_h_defines_formats=no ]) -if test "$ac_lbl_inttypes_h_defines_formats" = yes; then - AC_DEFINE(INTTYPES_H_DEFINES_FORMATS) -else - AC_LBL_CHECK_64BIT_FORMAT(ll, +if test "$ac_lbl_inttypes_h_defines_formats" = no; then + AC_LBL_CHECK_64BIT_FORMAT(l, [ - AC_LBL_CHECK_64BIT_FORMAT(L, - [ - AC_LBL_CHECK_64BIT_FORMAT(q, + AC_LBL_CHECK_64BIT_FORMAT(ll, + [ + AC_LBL_CHECK_64BIT_FORMAT(L, [ - AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) + AC_LBL_CHECK_64BIT_FORMAT(q, + [ + AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) + ]) ]) ]) ]) diff --git a/contrib/tcpdump/gmpls.c b/contrib/tcpdump/gmpls.c index 0716e26..4d4b9ae 100644 --- a/contrib/tcpdump/gmpls.c +++ b/contrib/tcpdump/gmpls.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.5 2004/09/15 17:54:10 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.5.2.1 2005/05/19 06:44:02 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -133,6 +133,50 @@ struct tok gmpls_payload_values[] = { { 0, NULL } }; +/* + * Link Type values used by LMP Service Discovery (specifically, the Client + * Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details. + */ +struct tok lmp_sd_service_config_cpsa_link_type_values[] = { + { 5, "SDH ITU-T G.707"}, + { 6, "SONET ANSI T1.105"}, + { 0, NULL} +}; + +/* + * Signal Type values for SDH links used by LMP Service Discovery (specifically, + * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for + * details. + */ +struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = { + { 5, "VC-3"}, + { 6, "VC-4"}, + { 7, "STM-0"}, + { 8, "STM-1"}, + { 9, "STM-4"}, + { 10, "STM-16"}, + { 11, "STM-64"}, + { 12, "STM-256"}, + { 0, NULL} +}; + +/* + * Signal Type values for SONET links used by LMP Service Discovery (specifically, + * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for + * details. + */ +struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = { + { 5, "STS-1 SPE"}, + { 6, "STS-3c SPE"}, + { 7, "STS-1"}, + { 8, "STM-3"}, + { 9, "STM-12"}, + { 10, "STM-48"}, + { 11, "STM-192"}, + { 12, "STM-768"}, + { 0, NULL} +}; + #define DIFFSERV_BC_MODEL_RDM 0 /* draft-ietf-tewg-diff-te-proto-07 */ #define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */ #define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */ diff --git a/contrib/tcpdump/gmpls.h b/contrib/tcpdump/gmpls.h index 76ddc2f..8c3f051 100644 --- a/contrib/tcpdump/gmpls.h +++ b/contrib/tcpdump/gmpls.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.3 2004/09/15 17:54:11 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.3.2.1 2005/05/19 06:44:03 guy Exp $ (LBL) */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code @@ -19,3 +19,6 @@ extern struct tok gmpls_switch_cap_values[]; extern struct tok gmpls_encoding_values[]; extern struct tok gmpls_payload_values[]; extern struct tok diffserv_te_bc_values[]; +extern struct tok lmp_sd_service_config_cpsa_link_type_values[]; +extern struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[]; +extern struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[]; diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h index c858a48..acf465c 100644 --- a/contrib/tcpdump/ip6.h +++ b/contrib/tcpdump/ip6.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.6 2002/12/11 22:29:21 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.6.4.1 2005/04/20 10:04:37 guy Exp $ (LBL) */ /* $NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp $ */ /* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */ @@ -95,9 +95,6 @@ struct ip6_hdr { #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim -#define IPV6_VERSION 0x60 -#define IPV6_VERSION_MASK 0xf0 - /* in network endian */ #define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */ #define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */ diff --git a/contrib/tcpdump/ipproto.c b/contrib/tcpdump/ipproto.c index f3fe741..f057acf 100755 --- a/contrib/tcpdump/ipproto.c +++ b/contrib/tcpdump/ipproto.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.3 2004/12/15 08:41:26 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.3.2.2 2005/05/20 21:15:45 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -24,8 +24,8 @@ static const char rcsid[] _U_ = #include <tcpdump-stdinc.h> -#include "ipproto.h" #include "interface.h" +#include "ipproto.h" struct tok ipproto_values[] = { { IPPROTO_HOPOPTS, "Options" }, @@ -51,6 +51,7 @@ struct tok ipproto_values[] = { { IPPROTO_PIM, "PIM" }, { IPPROTO_IPCOMP, "Compressed IP" }, { IPPROTO_VRRP, "VRRP" }, + { IPPROTO_PGM, "PGM" }, { IPPROTO_SCTP, "SCTP" }, { IPPROTO_MOBILITY, "Mobility" }, { 0, NULL } diff --git a/contrib/tcpdump/ipproto.h b/contrib/tcpdump/ipproto.h index b2159d6..aa37ef8 100644 --- a/contrib/tcpdump/ipproto.h +++ b/contrib/tcpdump/ipproto.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.4 2004/04/28 22:02:23 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.4.2.1 2005/05/20 21:15:46 hannes Exp $ (LBL) * * From: * @(#)in.h 8.3 (Berkeley) 1/3/94 @@ -130,6 +130,9 @@ extern struct tok ipproto_values[]; #ifndef IPPROTO_VRRP #define IPPROTO_VRRP 112 #endif +#ifndef IPPROTO_PGM +#define IPPROTO_PGM 113 +#endif #ifndef IPPROTO_SCTP #define IPPROTO_SCTP 132 #endif diff --git a/contrib/tcpdump/llc.h b/contrib/tcpdump/llc.h index 9da9a39..112ecbd 100644 --- a/contrib/tcpdump/llc.h +++ b/contrib/tcpdump/llc.h @@ -18,44 +18,13 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.17 2005/04/06 20:09:07 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.17.2.1 2005/04/26 07:27:16 guy Exp $ (LBL) */ /* - * This stuff should come from a system header file, but there's no - * obviously portable way to do that and it's not really going - * to change from system to system. + * Definitions for information in the LLC header. */ -/* - * A somewhat abstracted view of the LLC header - */ - -struct llc { - u_int8_t dsap; - u_int8_t ssap; - union { - u_int8_t u_ctl; - u_int16_t is_ctl; - struct { - u_int8_t snap_ui; - u_int8_t snap_pi[5]; - } snap; - struct { - u_int8_t snap_ui; - u_int8_t snap_orgcode[3]; - u_int8_t snap_ethertype[2]; - } snap_ether; - } ctl; -}; - -#define llcui ctl.snap.snap_ui -#define llcpi ctl.snap.snap_pi -#define llc_orgcode ctl.snap_ether.snap_orgcode -#define llc_ethertype ctl.snap_ether.snap_ethertype -#define llcis ctl.is_ctl -#define llcu ctl.u_ctl - #define LLC_U_FMT 3 #define LLC_GSAP 1 #define LLC_S_FMT 1 @@ -144,4 +113,3 @@ struct llc { #define PID_RFC2684_802_6_FCS 0x0005 /* 802.6, with FCS */ #define PID_RFC2684_802_6_NOFCS 0x000b /* 802.6, without FCS */ #define PID_RFC2684_BPDU 0x000e /* BPDUs */ - diff --git a/contrib/tcpdump/oui.c b/contrib/tcpdump/oui.c index c2bb2be..7cdcd40 100644 --- a/contrib/tcpdump/oui.c +++ b/contrib/tcpdump/oui.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.4 2005/04/06 20:13:13 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.4.2.1 2005/04/17 01:20:56 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -31,20 +31,39 @@ static const char rcsid[] _U_ = struct tok oui_values[] = { { OUI_ENCAP_ETHER, "Ethernet" }, { OUI_CISCO, "Cisco" }, + { OUI_NORTEL, "Nortel Networks SONMP" }, { OUI_CISCO_90, "Cisco bridged" }, { OUI_RFC2684, "Ethernet bridged" }, + { OUI_ATM_FORUM, "ATM Forum" }, + { OUI_CABLE_BPDU, "DOCSIS Spanning Tree" }, { OUI_APPLETALK, "Appletalk" }, - { OUI_JUNIPER, "Juniper"}, + { OUI_JUNIPER, "Juniper" }, + { OUI_HP, "Hewlett-Packard" }, + { 0, NULL } }; -/* list taken from ethereal/packet-radius.c */ - +/* + * SMI Network Management Private Enterprise Codes for organizations. + * + * XXX - these also appear in FreeRadius dictionary files, with items such + * as + * + * VENDOR Cisco 9 + * + * List taken from Ethereal's epan/sminmpec.c. + */ struct tok smi_values[] = { + { SMI_IETF, "IETF (reserved)"}, { SMI_ACC, "ACC"}, { SMI_CISCO, "Cisco"}, + { SMI_HEWLETT_PACKARD, "Hewlett Packard"}, + { SMI_SUN_MICROSYSTEMS, "Sun Microsystems"}, + { SMI_MERIT, "Merit"}, { SMI_SHIVA, "Shiva"}, - { SMI_MICROSOFT, "Microsoft"}, + { SMI_ERICSSON, "Ericsson AB"}, + { SMI_CISCO_VPN5000, "Cisco VPN 5000"}, { SMI_LIVINGSTON, "Livingston"}, + { SMI_MICROSOFT, "Microsoft"}, { SMI_3COM, "3Com"}, { SMI_ASCEND, "Ascend"}, { SMI_BAY, "Bay Networks"}, @@ -53,14 +72,24 @@ struct tok smi_values[] = { { SMI_REDBACK, "Redback"}, { SMI_JUNIPER, "Juniper Networks"}, { SMI_APTIS, "Aptis"}, + { SMI_CISCO_VPN3000, "Cisco VPN 3000"}, { SMI_COSINE, "CoSine Communications"}, + { SMI_NETSCREEN, "Netscreen"}, { SMI_SHASTA, "Shasta"}, { SMI_NOMADIX, "Nomadix"}, + { SMI_SIEMENS, "Siemens"}, + { SMI_CABLELABS, "CableLabs"}, { SMI_UNISPHERE, "Unisphere Networks"}, + { SMI_CISCO_BBSM, "Cisco BBSM"}, + { SMI_THE3GPP2, "3rd Generation Partnership Project 2 (3GPP2)"}, + { SMI_IP_UNPLUGGED, "ipUnplugged"}, { SMI_ISSANNI, "Issanni Communications"}, { SMI_QUINTUM, "Quintum"}, + { SMI_INTERLINK, "Interlink"}, { SMI_COLUBRIS, "Colubris"}, { SMI_COLUMBIA_UNIVERSITY, "Columbia University"}, { SMI_THE3GPP, "3GPP"}, - { 0, NULL } + { SMI_GEMTEK_SYSTEMS, "Gemtek-Systems"}, + { SMI_WIFI_ALLIANCE, "Wi-Fi Alliance"}, + { 0, NULL} }; diff --git a/contrib/tcpdump/oui.h b/contrib/tcpdump/oui.h index 4dcaf3e..4d79e19 100644 --- a/contrib/tcpdump/oui.h +++ b/contrib/tcpdump/oui.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.3 2005/04/06 20:13:13 hannes Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.3.2.1 2005/04/17 01:20:56 guy Exp $ (LBL) */ /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code @@ -19,14 +19,34 @@ extern struct tok smi_values[]; #define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */ #define OUI_CISCO 0x00000c /* Cisco protocols */ +#define OUI_NORTEL 0x000081 /* Nortel SONMP */ #define OUI_CISCO_90 0x0000f8 /* Cisco bridging */ -#define OUI_RFC2684 0x0080c2 /* RFC 2684 bridged Ethernet */ +#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */ +#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */ +#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */ #define OUI_APPLETALK 0x080007 /* Appletalk */ #define OUI_JUNIPER 0x009069 /* Juniper */ +#define OUI_HP 0x080009 /* Hewlett-Packard */ +/* + * These are SMI Network Management Private Enterprise Codes for + * organizations; see + * + * http://www.iana.org/assignments/enterprise-numbers + * + * for a list. + * + * List taken from Ethereal's epan/sminmpec.h. + */ +#define SMI_IETF 0 /* reserved - used by the IETF in L2TP? */ #define SMI_ACC 5 #define SMI_CISCO 9 +#define SMI_HEWLETT_PACKARD 11 +#define SMI_SUN_MICROSYSTEMS 42 +#define SMI_MERIT 61 #define SMI_SHIVA 166 +#define SMI_ERICSSON 193 +#define SMI_CISCO_VPN5000 255 #define SMI_LIVINGSTON 307 #define SMI_MICROSOFT 311 #define SMI_3COM 429 @@ -37,12 +57,22 @@ extern struct tok smi_values[]; #define SMI_REDBACK 2352 #define SMI_JUNIPER 2636 #define SMI_APTIS 2637 +#define SMI_CISCO_VPN3000 3076 #define SMI_COSINE 3085 #define SMI_SHASTA 3199 +#define SMI_NETSCREEN 3224 #define SMI_NOMADIX 3309 +#define SMI_SIEMENS 4329 +#define SMI_CABLELABS 4491 #define SMI_UNISPHERE 4874 +#define SMI_CISCO_BBSM 5263 +#define SMI_THE3GPP2 5535 +#define SMI_IP_UNPLUGGED 5925 #define SMI_ISSANNI 5948 #define SMI_QUINTUM 6618 +#define SMI_INTERLINK 6728 #define SMI_COLUBRIS 8744 #define SMI_COLUMBIA_UNIVERSITY 11862 #define SMI_THE3GPP 10415 +#define SMI_GEMTEK_SYSTEMS 10529 +#define SMI_WIFI_ALLIANCE 14122 diff --git a/contrib/tcpdump/pcap-missing.h b/contrib/tcpdump/pcap-missing.h index 7739c1e..1f2fcb4 100644 --- a/contrib/tcpdump/pcap-missing.h +++ b/contrib/tcpdump/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.2 2003/11/18 23:09:42 guy Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.2.2.1 2005/06/03 22:10:16 guy Exp $ (LBL) */ #ifndef tcpdump_pcap_missing_h @@ -44,6 +44,10 @@ extern const char *pcap_datalink_val_to_name(int); extern const char *pcap_datalink_val_to_description(int); #endif +#ifndef HAVE_PCAP_DUMP_FTELL +extern long pcap_dump_ftell(pcap_dumper_t *); +#endif + #endif diff --git a/contrib/tcpdump/pcap_dump_ftell.c b/contrib/tcpdump/pcap_dump_ftell.c new file mode 100644 index 0000000..438cd29 --- /dev/null +++ b/contrib/tcpdump/pcap_dump_ftell.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * 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. + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/pcap_dump_ftell.c,v 1.1.2.1 2005/06/03 22:10:17 guy Exp $ (LBL)"; +#endif + +#include <stdio.h> +#include <pcap.h> + +#include "pcap-missing.h" + +long +pcap_dump_ftell(pcap_dumper_t *p) +{ + return (ftell((FILE *)p)); +} diff --git a/contrib/tcpdump/pmap_prot.h b/contrib/tcpdump/pmap_prot.h index fdc4831..17cb92f 100644 --- a/contrib/tcpdump/pmap_prot.h +++ b/contrib/tcpdump/pmap_prot.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.1 2004/12/27 00:41:30 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.1.2.2 2005/04/27 21:44:06 guy Exp $ (LBL) */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -69,26 +69,21 @@ * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ -#ifndef _RPC_PMAPPROT_H -#define _RPC_PMAPPROT_H +#define SUNRPC_PMAPPORT ((u_int16_t)111) +#define SUNRPC_PMAPPROG ((u_int32_t)100000) +#define SUNRPC_PMAPVERS ((u_int32_t)2) +#define SUNRPC_PMAPVERS_PROTO ((u_int32_t)2) +#define SUNRPC_PMAPVERS_ORIG ((u_int32_t)1) +#define SUNRPC_PMAPPROC_NULL ((u_int32_t)0) +#define SUNRPC_PMAPPROC_SET ((u_int32_t)1) +#define SUNRPC_PMAPPROC_UNSET ((u_int32_t)2) +#define SUNRPC_PMAPPROC_GETPORT ((u_int32_t)3) +#define SUNRPC_PMAPPROC_DUMP ((u_int32_t)4) +#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5) -#define PMAPPORT ((u_int16_t)111) -#define PMAPPROG ((u_int32_t)100000) -#define PMAPVERS ((u_int32_t)2) -#define PMAPVERS_PROTO ((u_int32_t)2) -#define PMAPVERS_ORIG ((u_int32_t)1) -#define PMAPPROC_NULL ((u_int32_t)0) -#define PMAPPROC_SET ((u_int32_t)1) -#define PMAPPROC_UNSET ((u_int32_t)2) -#define PMAPPROC_GETPORT ((u_int32_t)3) -#define PMAPPROC_DUMP ((u_int32_t)4) -#define PMAPPROC_CALLIT ((u_int32_t)5) - -struct pmap { +struct sunrpc_pmap { u_int32_t pm_prog; u_int32_t pm_vers; u_int32_t pm_prot; u_int32_t pm_port; }; - -#endif /* !_RPC_PMAPPROT_H */ diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c index c4c0ac8..32f85ce 100644 --- a/contrib/tcpdump/print-802_11.c +++ b/contrib/tcpdump/print-802_11.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31 2004/11/04 07:35:53 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.1 2005/04/20 19:32:41 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -1100,7 +1100,8 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) next_present = present & (present - 1); /* extract the least significant bit that is set */ - bit = bit0 + BITNO_32(present ^ next_present); + bit = (enum ieee80211_radiotap_type) + (bit0 + BITNO_32(present ^ next_present)); if (print_radiotap_field(&cpacker, bit) != 0) goto out; diff --git a/contrib/tcpdump/print-bfd.c b/contrib/tcpdump/print-bfd.c index 485dde8..755f728 100644 --- a/contrib/tcpdump/print-bfd.c +++ b/contrib/tcpdump/print-bfd.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.5 2003/11/16 09:36:14 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.5.2.4 2005/04/28 09:28:47 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -34,7 +34,7 @@ static const char rcsid[] _U_ = #include "udp.h" /* - * Control packet, draft-katz-ward-bfd-01.txt + * Control packet, BFDv0, draft-katz-ward-bfd-01.txt * * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 @@ -53,6 +53,26 @@ static const char rcsid[] _U_ = * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ +/* + * Control packet, BFDv1, draft-ietf-bfd-base-02.txt + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | My Discriminator | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Your Discriminator | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Desired Min TX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Required Min RX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Required Min Echo RX Interval | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + struct bfd_header_t { u_int8_t version_diag; u_int8_t flags; @@ -65,6 +85,32 @@ struct bfd_header_t { u_int8_t required_min_echo_interval[4]; }; +/* + * An optional Authentication Header may be present + * + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Auth Type | Auth Len | Authentication Data... | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + +struct bfd_auth_header_t { + u_int8_t auth_type; + u_int8_t auth_len; + u_int8_t auth_data; +}; + +static const struct tok bfd_v1_authentication_values[] = { + { 0, "Reserved" }, + { 1, "Simple Password" }, + { 2, "Keyed MD5" }, + { 3, "Meticulous Keyed MD5" }, + { 4, "Keyed SHA1" }, + { 5, "Meticulous Keyed SHA1" }, + { 0, NULL } +}; + #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5) #define BFD_EXTRACT_DIAG(x) ((x)&0x1f) @@ -84,10 +130,11 @@ static const struct tok bfd_diag_values[] = { { 5, "Path Down" }, { 6, "Concatenated Path Down" }, { 7, "Administratively Down" }, + { 8, "Reverse Concatenated Path Down" }, { 0, NULL } }; -static const struct tok bfd_flag_values[] = { +static const struct tok bfd_v0_flag_values[] = { { 0x80, "I Hear You" }, { 0x40, "Demand" }, { 0x20, "Poll" }, @@ -99,34 +146,58 @@ static const struct tok bfd_flag_values[] = { { 0, NULL } }; +#define BFD_FLAG_AUTH 0x04 + +static const struct tok bfd_v1_flag_values[] = { + { 0x20, "Poll" }, + { 0x10, "Final" }, + { 0x08, "Control Plane Independent" }, + { BFD_FLAG_AUTH, "Authentication Present" }, + { 0x02, "Demand" }, + { 0x01, "Reserved" }, + { 0, NULL } +}; + +static const struct tok bfd_v1_state_values[] = { + { 0, "AdminDown" }, + { 1, "Down" }, + { 2, "Init" }, + { 3, "Up" }, + { 0, NULL } +}; + void bfd_print(register const u_char *pptr, register u_int len, register u_int port) { const struct bfd_header_t *bfd_header; + const struct bfd_auth_header_t *bfd_auth_header; + u_int8_t version; bfd_header = (const struct bfd_header_t *)pptr; TCHECK(*bfd_header); + version = BFD_EXTRACT_VERSION(bfd_header->version_diag); - switch (port) { + switch (port << 8 | version) { - case BFD_CONTROL_PORT: + /* BFDv0 */ + case (BFD_CONTROL_PORT << 8): if (vflag < 1 ) { printf("BFDv%u, %s, Flags: [%s], length: %u", - BFD_EXTRACT_VERSION(bfd_header->version_diag), + version, tok2str(bfd_port_values, "unknown (%u)", port), - bittok2str(bfd_flag_values, "none", bfd_header->flags), + bittok2str(bfd_v0_flag_values, "none", bfd_header->flags), len); return; } printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)", - BFD_EXTRACT_VERSION(bfd_header->version_diag), + version, len, tok2str(bfd_port_values, "unknown (%u)", port), - bittok2str(bfd_flag_values, "none", bfd_header->flags), + bittok2str(bfd_v0_flag_values, "none", bfd_header->flags), tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)), - BFD_EXTRACT_DIAG(bfd_header->version_diag)); + BFD_EXTRACT_DIAG(bfd_header->version_diag)); printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u", bfd_header->detect_time_multiplier, @@ -141,7 +212,55 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port) printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000); break; - case BFD_ECHO_PORT: /* not yet supported - fall through */ + /* BFDv1 */ + case (BFD_CONTROL_PORT << 8 | 1): + if (vflag < 1 ) + { + printf("BFDv%u, %s, State %s, Flags: [%s], length: %u", + version, + tok2str(bfd_port_values, "unknown (%u)", port), + tok2str(bfd_v1_state_values, "unknown (%u)", bfd_header->flags & 0xc0), + bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f), + len); + return; + } + + printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)", + version, + len, + tok2str(bfd_port_values, "unknown (%u)", port), + tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6), + bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f), + tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)), + BFD_EXTRACT_DIAG(bfd_header->version_diag)); + + printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u", + bfd_header->detect_time_multiplier, + bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000, + bfd_header->length); + + + printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)); + printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)); + printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000); + printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000); + printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000); + + if (bfd_header->flags & BFD_FLAG_AUTH) { + pptr += sizeof (const struct bfd_header_t); + bfd_auth_header = (const struct bfd_auth_header_t *)pptr; + TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t)); + printf("\n\t%s (%u) Authentication, length %u present", + tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type), + bfd_auth_header->auth_type, + bfd_auth_header->auth_len); + } + break; + + /* BFDv0 */ + case (BFD_ECHO_PORT << 8): /* not yet supported - fall through */ + /* BFDv1 */ + case (BFD_ECHO_PORT << 8 | 1): default: printf("BFD, %s, length: %u", diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c index d1b0271..d6377fb 100644 --- a/contrib/tcpdump/print-bgp.c +++ b/contrib/tcpdump/print-bgp.c @@ -36,7 +36,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91 2005/03/27 01:31:25 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.6 2005/06/03 07:31:43 hannes Exp $"; #endif #include <tcpdump-stdinc.h> @@ -772,14 +772,13 @@ trunc: #endif static int -decode_labeled_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) +decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) { u_int8_t addr[19]; u_int plen; TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ - plen-=24; /* adjust prefixlen - labellength */ if (152 < plen) return -1; @@ -791,14 +790,11 @@ decode_labeled_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - /* the label may get offsetted by 4 bits so lets shift it right */ - snprintf(buf, buflen, "%s/%d, label:%u %s", - isonsap_string(addr,(plen + 7) / 8 - 1), - plen, - EXTRACT_24BITS(pptr+1)>>4, - ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); + snprintf(buf, buflen, "%s/%d", + isonsap_string(addr,(plen + 7) / 8), + plen); - return 4 + (plen + 7) / 8; + return 1 + (plen + 7) / 8; trunc: return -2; @@ -828,7 +824,7 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen) /* the label may get offsetted by 4 bits so lets shift it right */ snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s", bgp_vpn_rd_print(pptr+4), - isonsap_string(addr,(plen + 7) / 8 - 1), + isonsap_string(addr,(plen + 7) / 8), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); @@ -844,7 +840,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) { int i; u_int16_t af; - u_int8_t safi, snpa; + u_int8_t safi, snpa, nhlen; union { /* copy buffer for bandwidth values */ float f; u_int32_t i; @@ -1024,6 +1020,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): break; default: + TCHECK2(tptr[0], tlen); printf("\n\t no AFI %u / SAFI %u decoder",af,safi); if (vflag <= 1) print_unknown_data(tptr,"\n\t ",tlen); @@ -1034,7 +1031,8 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) tptr +=3; TCHECK(tptr[0]); - tlen = tptr[0]; + nhlen = tptr[0]; + tlen = nhlen; tptr++; if (tlen) { @@ -1160,6 +1158,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) } } } + printf(", nh-length: %u", nhlen); tptr += tlen; TCHECK(tptr[0]); @@ -1275,7 +1274,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): - advance = decode_labeled_clnp_prefix(tptr, buf, sizeof(buf)); + advance = decode_clnp_prefix(tptr, buf, sizeof(buf)); if (advance == -1) printf("\n\t (illegal prefix length)"); else if (advance == -2) @@ -1303,8 +1302,8 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) tptr = pptr + len; break; } - break; - + if (advance < 0) + break; tptr += advance; } done: @@ -1409,7 +1408,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): - advance = decode_labeled_clnp_prefix(tptr, buf, sizeof(buf)); + advance = decode_clnp_prefix(tptr, buf, sizeof(buf)); if (advance == -1) printf("\n\t (illegal prefix length)"); else if (advance == -2) @@ -1437,7 +1436,8 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) tptr = pptr + len; break; } - break; + if (advance < 0) + break; tptr += advance; } break; @@ -1518,6 +1518,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) EXTRACT_16BITS(tptr+4)); break; default: + TCHECK2(*tptr,8); print_unknown_data(tptr,"\n\t ",8); break; } @@ -1575,8 +1576,10 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len) print_unknown_data(pptr,"\n\t ",len); break; } - if (vflag > 1 && len) /* omit zero length attributes*/ + if (vflag > 1 && len) { /* omit zero length attributes*/ + TCHECK2(*pptr,len); print_unknown_data(pptr,"\n\t ",len); + } return 1; trunc: @@ -1588,7 +1591,6 @@ bgp_open_print(const u_char *dat, int length) { struct bgp_open bgpo; struct bgp_opt bgpopt; - int hlen; const u_char *opt; int i,cap_type,cap_len,tcap_len,cap_offset; char tokbuf[TOKBUFSIZE]; @@ -1596,7 +1598,6 @@ bgp_open_print(const u_char *dat, int length) TCHECK2(dat[0], BGP_OPEN_SIZE); memcpy(&bgpo, dat, BGP_OPEN_SIZE); - hlen = ntohs(bgpo.bgpo_len); printf("\n\t Version %d, ", bgpo.bgpo_version); printf("my AS %u, ", ntohs(bgpo.bgpo_myas)); @@ -1676,14 +1677,17 @@ bgp_open_print(const u_char *dat, int length) case BGP_CAPCODE_RR_CISCO: break; default: + TCHECK2(opt[i+BGP_OPT_SIZE+2],cap_len); printf("\n\t\tno decoder for Capability %u", cap_type); if (vflag <= 1) print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len); break; } - if (vflag > 1) + if (vflag > 1) { + TCHECK2(opt[i+BGP_OPT_SIZE+2],cap_len); print_unknown_data(&opt[i+BGP_OPT_SIZE+2],"\n\t\t",cap_len); + } break; case BGP_OPT_AUTH: default: @@ -1704,7 +1708,6 @@ bgp_update_print(const u_char *dat, int length) { struct bgp bgp; struct bgp_attr bgpa; - int hlen; const u_char *p; int len; int i; @@ -1712,7 +1715,6 @@ bgp_update_print(const u_char *dat, int length) TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); - hlen = ntohs(bgp.bgp_len); p = dat + BGP_SIZE; /*XXX*/ /* Unfeasible routes */ @@ -1794,7 +1796,7 @@ bgp_update_print(const u_char *dat, int length) p += 2 + len; if (dat + length > p) { - printf("\n\t Updated routes:"); + printf("\n\t Updated routes:"); while (dat + length > p) { char buf[MAXHOSTNAMELEN + 100]; i = decode_prefix4(p, buf, sizeof(buf)); @@ -1818,14 +1820,12 @@ static void bgp_notification_print(const u_char *dat, int length) { struct bgp_notification bgpn; - int hlen; const u_char *tptr; char tokbuf[TOKBUFSIZE]; char tokbuf2[TOKBUFSIZE]; TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); - hlen = ntohs(bgpn.bgpn_len); /* some little sanity checking */ if (length<BGP_NOTIFICATION_SIZE) @@ -1899,6 +1899,12 @@ bgp_route_refresh_print(const u_char *pptr, int len) { char tokbuf[TOKBUFSIZE]; char tokbuf2[TOKBUFSIZE]; + TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE); + + /* some little sanity checking */ + if (len<BGP_ROUTE_REFRESH_SIZE) + return; + bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr; printf("\n\t AFI %s (%u), SAFI %s (%u)", @@ -1913,10 +1919,14 @@ bgp_route_refresh_print(const u_char *pptr, int len) { tokbuf2, sizeof(tokbuf2)), bgp_route_refresh_header->safi); - if (vflag > 1) + if (vflag > 1) { + TCHECK2(*pptr, len); print_unknown_data(pptr,"\n\t ", len); + } return; +trunc: + printf("[|BGP]"); } static int @@ -1949,9 +1959,10 @@ bgp_header_print(const u_char *dat, int length) bgp_route_refresh_print(dat, length); break; default: - /* we have no decoder for the BGP message */ - printf("\n\t no Message %u decoder",bgp.bgp_type); - print_unknown_data(dat,"\n\t ",length); + /* we have no decoder for the BGP message */ + TCHECK2(*dat, length); + printf("\n\t no Message %u decoder",bgp.bgp_type); + print_unknown_data(dat,"\n\t ",length); break; } return 1; @@ -1985,7 +1996,7 @@ bgp_print(const u_char *dat, int length) p = dat; start = p; - while (p < snapend) { + while (p < ep) { if (!TTEST2(p[0], 1)) break; if (p[0] != 0xff) { diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c index 730d1aa..d2b5611 100644 --- a/contrib/tcpdump/print-chdlc.c +++ b/contrib/tcpdump/print-chdlc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32 2005/04/06 21:32:38 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.7 2005/04/27 14:35:56 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -112,45 +112,54 @@ chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p) return (CHDLC_HDRLEN); } +/* + * The fixed-length portion of a SLARP packet. + */ struct cisco_slarp { - u_int32_t code; + u_int8_t code[4]; #define SLARP_REQUEST 0 #define SLARP_REPLY 1 #define SLARP_KEEPALIVE 2 union { struct { - struct in_addr addr; - struct in_addr mask; - u_int16_t unused[3]; + u_int8_t addr[4]; + u_int8_t mask[4]; } addr; struct { - u_int32_t myseq; - u_int32_t yourseq; - u_int16_t rel; - u_int16_t t1; - u_int16_t t2; + u_int8_t myseq[4]; + u_int8_t yourseq[4]; + u_int8_t rel[2]; } keep; } un; }; -#define SLARP_LEN 18 +#define SLARP_MIN_LEN 14 +#define SLARP_MAX_LEN 18 static void chdlc_slarp_print(const u_char *cp, u_int length) { const struct cisco_slarp *slarp; + u_int sec,min,hrs,days; - if (length < SLARP_LEN) + printf("SLARP (length: %u), ",length); + if (length < SLARP_MIN_LEN) goto trunc; slarp = (const struct cisco_slarp *)cp; - TCHECK(*slarp); - printf("SLARP (length: %u), ",length); + TCHECK2(*slarp, SLARP_MIN_LEN); switch (EXTRACT_32BITS(&slarp->code)) { case SLARP_REQUEST: printf("request"); - /* ok we do not know it - but lets at least dump it */ - print_unknown_data(cp+4,"\n\t",length-4); + /* + * At least according to William "Chops" Westfield's + * message in + * + * http://www.nethelp.no/net/cisco-hdlc.txt + * + * the address and mask aren't used in requests - + * they're just zero. + */ break; case SLARP_REPLY: printf("reply %s/%s", @@ -158,13 +167,21 @@ chdlc_slarp_print(const u_char *cp, u_int length) ipaddr_string(&slarp->un.addr.mask)); break; case SLARP_KEEPALIVE: - printf("keepalive: mineseen=0x%08x, yourseen=0x%08x", - EXTRACT_32BITS(&slarp->un.keep.myseq), - EXTRACT_32BITS(&slarp->un.keep.yourseq)); - printf(", reliability=0x%04x, t1=%d.%d", - EXTRACT_16BITS(&slarp->un.keep.rel), - EXTRACT_16BITS(&slarp->un.keep.t1), - EXTRACT_16BITS(&slarp->un.keep.t2)); + printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x", + EXTRACT_32BITS(&slarp->un.keep.myseq), + EXTRACT_32BITS(&slarp->un.keep.yourseq), + EXTRACT_16BITS(&slarp->un.keep.rel)); + + if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */ + cp += SLARP_MIN_LEN; + if (!TTEST2(*cp, 4)) + goto trunc; + sec = EXTRACT_32BITS(cp) / 1000; + min = sec / 60; sec -= min * 60; + hrs = min / 60; min -= hrs * 60; + days = hrs / 24; hrs -= days * 24; + printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec); + } break; default: printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code)); @@ -173,8 +190,8 @@ chdlc_slarp_print(const u_char *cp, u_int length) break; } - if (SLARP_LEN < length && vflag) - printf(", (trailing junk: %d bytes)", length - SLARP_LEN); + if (SLARP_MAX_LEN < length && vflag) + printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN); if (vflag > 1) print_unknown_data(cp+4,"\n\t",length-4); return; diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c index 2c1043f..9fdfbd4 100644 --- a/contrib/tcpdump/print-cnfp.c +++ b/contrib/tcpdump/print-cnfp.c @@ -34,7 +34,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.16 2003/11/16 09:36:16 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.16.2.1 2005/04/20 20:53:39 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -79,16 +79,16 @@ struct nfrec { }; void -cnfp_print(const u_char *cp, const u_char *bp) +cnfp_print(const u_char *cp, const u_char *bp _U_) { register const struct nfhdr *nh; register const struct nfrec *nr; - register const struct ip *ip; struct protoent *pent; int nrecs, ver; +#if 0 time_t t; +#endif - ip = (const struct ip *)bp; nh = (const struct nfhdr *)cp; if ((const u_char *)(nh + 1) > snapend) @@ -96,8 +96,14 @@ cnfp_print(const u_char *cp, const u_char *bp) nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff; ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16; +#if 0 + /* + * This is seconds since the UN*X epoch, and is followed by + * nanoseconds. XXX - format it, rather than just dumping the + * raw seconds-since-the-Epoch. + */ t = EXTRACT_32BITS(&nh->utc_sec); -/* (p = ctime(&t))[24] = '\0'; */ +#endif printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver, EXTRACT_32BITS(&nh->msys_uptime)/1000, diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c index 43fe71d..ae7ba5c4 100644 --- a/contrib/tcpdump/print-decnet.c +++ b/contrib/tcpdump/print-decnet.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.38 2003/11/16 09:36:17 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.38.2.1 2005/05/06 02:16:53 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -47,13 +47,13 @@ struct rtentry; #include "addrtoname.h" /* Forwards */ -static void print_decnet_ctlmsg(const union routehdr *, u_int); +static int print_decnet_ctlmsg(const union routehdr *, u_int, u_int); static void print_t_info(int); -static void print_l1_routes(const char *, u_int); -static void print_l2_routes(const char *, u_int); +static int print_l1_routes(const char *, u_int); +static int print_l2_routes(const char *, u_int); static void print_i_info(int); -static void print_elist(const char *, u_int); -static void print_nsp(const u_char *, u_int); +static int print_elist(const char *, u_int); +static int print_nsp(const u_char *, u_int); static void print_reason(int); #ifdef PRINT_NSPDATA static void pdata(u_char *, int); @@ -67,11 +67,10 @@ void decnet_print(register const u_char *ap, register u_int length, register u_int caplen) { - static union routehdr rhcopy; - register union routehdr *rhp = &rhcopy; + register const union routehdr *rhp; register int mflags; int dst, src, hops; - u_int rhlen, nsplen, pktlen; + u_int nsplen, pktlen; const u_char *nspp; if (length < sizeof(struct shorthdr)) { @@ -79,12 +78,20 @@ decnet_print(register const u_char *ap, register u_int length, return; } + TCHECK2(*ap, sizeof(short)); pktlen = EXTRACT_LE_16BITS(ap); + if (pktlen < sizeof(struct shorthdr)) { + (void)printf("[|decnet]"); + return; + } + if (pktlen > length) { + (void)printf("[|decnet]"); + return; + } + length = pktlen; - rhlen = min(length, caplen); - rhlen = min(rhlen, sizeof(*rhp)); - memcpy((char *)rhp, (char *)&(ap[sizeof(short)]), rhlen); - + rhp = (const union routehdr *)&(ap[sizeof(short)]); + TCHECK(rhp->rh_short.sh_flags); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); if (mflags & RMF_PAD) { @@ -92,49 +99,57 @@ decnet_print(register const u_char *ap, register u_int length, u_int padlen = mflags & RMF_PADMASK; if (vflag) (void) printf("[pad:%d] ", padlen); + if (length < padlen + 2) { + (void)printf("[|decnet]"); + return; + } + TCHECK2(ap[sizeof(short)], padlen); ap += padlen; length -= padlen; caplen -= padlen; - rhlen = min(length, caplen); - rhlen = min(rhlen, sizeof(*rhp)); - memcpy((char *)rhp, (char *)&(ap[sizeof(short)]), rhlen); + rhp = (const union routehdr *)&(ap[sizeof(short)]); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); } if (mflags & RMF_FVER) { (void) printf("future-version-decnet"); - default_print(ap, length); + default_print(ap, min(length, caplen)); return; } /* is it a control message? */ if (mflags & RMF_CTLMSG) { - print_decnet_ctlmsg(rhp, min(length, caplen)); + if (!print_decnet_ctlmsg(rhp, length, caplen)) + goto trunc; return; } switch (mflags & RMF_MASK) { case RMF_LONG: + if (length < sizeof(struct longhdr)) { + (void)printf("[|decnet]"); + return; + } + TCHECK(rhp->rh_long); dst = EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr); src = EXTRACT_LE_16BITS(rhp->rh_long.lg_src.dne_remote.dne_nodeaddr); hops = EXTRACT_LE_8BITS(rhp->rh_long.lg_visits); nspp = &(ap[sizeof(short) + sizeof(struct longhdr)]); - nsplen = min((length - sizeof(struct longhdr)), - (caplen - sizeof(struct longhdr))); + nsplen = length - sizeof(struct longhdr); break; case RMF_SHORT: + TCHECK(rhp->rh_short); dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst); src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src); hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1; nspp = &(ap[sizeof(short) + sizeof(struct shorthdr)]); - nsplen = min((length - sizeof(struct shorthdr)), - (caplen - sizeof(struct shorthdr))); + nsplen = length - sizeof(struct shorthdr); break; default: (void) printf("unknown message flags under mask"); - default_print((u_char *)ap, length); + default_print((u_char *)ap, min(length, caplen)); return; } @@ -150,11 +165,18 @@ decnet_print(register const u_char *ap, register u_int length, (void)printf("%d hops ", hops); } - print_nsp(nspp, nsplen); + if (!print_nsp(nspp, nsplen)) + goto trunc; + return; + +trunc: + (void)printf("[|decnet]"); + return; } -static void -print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) +static int +print_decnet_ctlmsg(register const union routehdr *rhp, u_int length, + u_int caplen) { int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); register union controlmsg *cmp = (union controlmsg *)rhp; @@ -162,10 +184,14 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) etheraddr srcea, rtea; int priority; char *rhpx = (char *)rhp; + int ret; switch (mflags & RMF_CTLMASK) { case RMF_INIT: (void)printf("init "); + if (length < sizeof(struct initmsg)) + goto trunc; + TCHECK(cmp->cm_init); src = EXTRACT_LE_16BITS(cmp->cm_init.in_src); info = EXTRACT_LE_8BITS(cmp->cm_init.in_info); blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize); @@ -178,35 +204,53 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) "src %sblksize %d vers %d eco %d ueco %d hello %d", dnaddr_string(src), blksize, vers, eco, ueco, hello); + ret = 1; break; case RMF_VER: (void)printf("verification "); + if (length < sizeof(struct verifmsg)) + goto trunc; + TCHECK(cmp->cm_ver); src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src); other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval); (void)printf("src %s fcnval %o", dnaddr_string(src), other); + ret = 1; break; case RMF_TEST: (void)printf("test "); + if (length < sizeof(struct testmsg)) + goto trunc; + TCHECK(cmp->cm_test); src = EXTRACT_LE_16BITS(cmp->cm_test.te_src); other = EXTRACT_LE_8BITS(cmp->cm_test.te_data); (void)printf("src %s data %o", dnaddr_string(src), other); + ret = 1; break; case RMF_L1ROUT: (void)printf("lev-1-routing "); + if (length < sizeof(struct l1rout)) + goto trunc; + TCHECK(cmp->cm_l1rou); src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src); (void)printf("src %s ", dnaddr_string(src)); - print_l1_routes(&(rhpx[sizeof(struct l1rout)]), + ret = print_l1_routes(&(rhpx[sizeof(struct l1rout)]), length - sizeof(struct l1rout)); break; case RMF_L2ROUT: (void)printf("lev-2-routing "); + if (length < sizeof(struct l2rout)) + goto trunc; + TCHECK(cmp->cm_l2rout); src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src); (void)printf("src %s ", dnaddr_string(src)); - print_l2_routes(&(rhpx[sizeof(struct l2rout)]), + ret = print_l2_routes(&(rhpx[sizeof(struct l2rout)]), length - sizeof(struct l2rout)); break; case RMF_RHELLO: (void)printf("router-hello "); + if (length < sizeof(struct rhellomsg)) + goto trunc; + TCHECK(cmp->cm_rhello); vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers); eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco); @@ -222,11 +266,14 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d", vers, eco, ueco, dnaddr_string(src), blksize, priority, hello); - print_elist(&(rhpx[sizeof(struct rhellomsg)]), + ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]), length - sizeof(struct rhellomsg)); break; case RMF_EHELLO: (void)printf("endnode-hello "); + if (length < sizeof(struct ehellomsg)) + goto trunc; + TCHECK(cmp->cm_ehello); vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers); eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco); @@ -246,13 +293,19 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length) "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o", vers, eco, ueco, dnaddr_string(src), blksize, dnaddr_string(dst), hello, other); + ret = 1; break; default: (void)printf("unknown control message"); - default_print((u_char *)rhp, length); + default_print((u_char *)rhp, min(length, caplen)); + ret = 1; break; } + return (ret); + +trunc: + return (0); } static void @@ -271,7 +324,7 @@ print_t_info(int info) (void)printf("blo "); } -static void +static int print_l1_routes(const char *rp, u_int len) { int count; @@ -280,9 +333,10 @@ print_l1_routes(const char *rp, u_int len) /* The last short is a checksum */ while (len > (3 * sizeof(short))) { + TCHECK2(*rp, 3 * sizeof(short)); count = EXTRACT_LE_16BITS(rp); if (count > 1024) - return; /* seems to be bogus from here on */ + return (1); /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); id = EXTRACT_LE_16BITS(rp); @@ -294,9 +348,13 @@ print_l1_routes(const char *rp, u_int len) (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count, RI_COST(info), RI_HOPS(info)); } + return (1); + +trunc: + return (0); } -static void +static int print_l2_routes(const char *rp, u_int len) { int count; @@ -305,9 +363,10 @@ print_l2_routes(const char *rp, u_int len) /* The last short is a checksum */ while (len > (3 * sizeof(short))) { + TCHECK2(*rp, 3 * sizeof(short)); count = EXTRACT_LE_16BITS(rp); if (count > 1024) - return; /* seems to be bogus from here on */ + return (1); /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); area = EXTRACT_LE_16BITS(rp); @@ -319,6 +378,10 @@ print_l2_routes(const char *rp, u_int len) (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count, RI_COST(info), RI_HOPS(info)); } + return (1); + +trunc: + return (0); } static void @@ -339,18 +402,22 @@ print_i_info(int info) (void)printf("blo "); } -static void +static int print_elist(const char *elp _U_, u_int len _U_) { /* Not enough examples available for me to debug this */ + return (1); } -static void -print_nsp(const u_char *nspp, u_int nsplen _U_) +static int +print_nsp(const u_char *nspp, u_int nsplen) { const struct nsphdr *nsphp = (struct nsphdr *)nspp; int dst, src, flags; + if (nsplen < sizeof(struct nsphdr)) + goto trunc; + TCHECK(*nsphp); flags = EXTRACT_LE_8BITS(nsphp->nh_flags); dst = EXTRACT_LE_16BITS(nsphp->nh_dst); src = EXTRACT_LE_16BITS(nsphp->nh_src); @@ -371,27 +438,39 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) #endif u_int data_off = sizeof(struct minseghdr); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[0]); ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); - ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[1]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); if (ack & SGQ_OACK) { /* ackoth field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("onak %d ", ack & SGQ_MASK); else (void)printf("oack %d ", ack & SGQ_MASK); - ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[2]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } (void)printf("seg %d ", ack & SGQ_MASK); #ifdef PRINT_NSPDATA - dp = &(nspp[data_off]); - pdata(dp, 10); + if (nsplen > data_off) { + dp = &(nspp[data_off]); + TCHECK2(*dp, nsplen - data_off); + pdata(dp, nsplen - data_off); + } #endif } break; @@ -405,27 +484,39 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) #endif u_int data_off = sizeof(struct minseghdr); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[0]); ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); - ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[1]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("nakdat %d ", ack & SGQ_MASK); else (void)printf("ackdat %d ", ack & SGQ_MASK); - ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); data_off += sizeof(short); + if (nsplen < data_off) + goto trunc; + TCHECK(shp->sh_seq[2]); + ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } (void)printf("seg %d ", ack & SGQ_MASK); #ifdef PRINT_NSPDATA - dp = &(nspp[data_off]); - pdata(dp, 10); + if (nsplen > data_off) { + dp = &(nspp[data_off]); + TCHECK2(*dp, nsplen - data_off); + pdata(dp, nsplen - data_off); + } #endif } break; @@ -438,22 +529,28 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) int ack; int lsflags, fcval; + if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg)) + goto trunc; + TCHECK(shp->sh_seq[0]); ack = EXTRACT_LE_16BITS(shp->sh_seq[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); + TCHECK(shp->sh_seq[1]); ack = EXTRACT_LE_16BITS(shp->sh_seq[1]); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) (void)printf("nakdat %d ", ack & SGQ_MASK); else (void)printf("ackdat %d ", ack & SGQ_MASK); + TCHECK(shp->sh_seq[2]); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } (void)printf("seg %d ", ack & SGQ_MASK); + TCHECK(*lsmp); lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags); fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval); switch (lsflags & LSI_MASK) { @@ -495,6 +592,9 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) struct ackmsg *amp = (struct ackmsg *)nspp; int ack; + if (nsplen < sizeof(struct ackmsg)) + goto trunc; + TCHECK(*amp); ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) @@ -517,12 +617,16 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) struct ackmsg *amp = (struct ackmsg *)nspp; int ack; + if (nsplen < sizeof(struct ackmsg)) + goto trunc; + TCHECK(*amp); ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) (void)printf("nak %d ", ack & SGQ_MASK); else (void)printf("ack %d ", ack & SGQ_MASK); + TCHECK(amp->ak_acknum[1]); ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); if (ack & SGQ_OACK) { /* ackdat field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) @@ -557,6 +661,9 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) u_char *dp; #endif + if (nsplen < sizeof(struct cimsg)) + goto trunc; + TCHECK(*cimp); services = EXTRACT_LE_8BITS(cimp->ci_services); info = EXTRACT_LE_8BITS(cimp->ci_info); segsize = EXTRACT_LE_16BITS(cimp->ci_segsize); @@ -590,8 +697,11 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) } (void)printf("segsize %d ", segsize); #ifdef PRINT_NSPDATA - dp = &(nspp[sizeof(struct cimsg)]); - pdata(dp, nsplen - sizeof(struct cimsg)); + if (nsplen > sizeof(struct cimsg)) { + dp = &(nspp[sizeof(struct cimsg)]); + TCHECK2(*dp, nsplen - sizeof(struct cimsg)); + pdata(dp, nsplen - sizeof(struct cimsg)); + } #endif } break; @@ -605,6 +715,9 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) u_char *dp; #endif + if (nsplen < sizeof(struct ccmsg)) + goto trunc; + TCHECK(*ccmp); services = EXTRACT_LE_8BITS(ccmp->cc_services); info = EXTRACT_LE_8BITS(ccmp->cc_info); segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize); @@ -641,8 +754,10 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) if (optlen) { (void)printf("optlen %d ", optlen); #ifdef PRINT_NSPDATA - optlen = min(optlen, nsplen - sizeof(struct ccmsg)); + if (optlen > nsplen - sizeof(struct ccmsg)) + goto trunc; dp = &(nspp[sizeof(struct ccmsg)]); + TCHECK2(*dp, optlen); pdata(dp, optlen); #endif } @@ -658,6 +773,9 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) u_char *dp; #endif + if (nsplen < sizeof(struct dimsg)) + goto trunc; + TCHECK(*dimp); reason = EXTRACT_LE_16BITS(dimp->di_reason); optlen = EXTRACT_LE_8BITS(dimp->di_optlen); @@ -665,8 +783,10 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) if (optlen) { (void)printf("optlen %d ", optlen); #ifdef PRINT_NSPDATA - optlen = min(optlen, nsplen - sizeof(struct dimsg)); + if (optlen > nsplen - sizeof(struct dimsg)) + goto trunc; dp = &(nspp[sizeof(struct dimsg)]); + TCHECK2(*dp, optlen); pdata(dp, optlen); #endif } @@ -678,6 +798,7 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) struct dcmsg *dcmp = (struct dcmsg *)nspp; int reason; + TCHECK(*dcmp); reason = EXTRACT_LE_16BITS(dcmp->dc_reason); print_reason(reason); @@ -692,6 +813,10 @@ print_nsp(const u_char *nspp, u_int nsplen _U_) (void)printf("reserved-type? %x %d > %d", flags, src, dst); break; } + return (1); + +trunc: + return (0); } static struct tok reason2str[] = { diff --git a/contrib/tcpdump/print-eigrp.c b/contrib/tcpdump/print-eigrp.c index f4db8ed..3168b3c 100644 --- a/contrib/tcpdump/print-eigrp.c +++ b/contrib/tcpdump/print-eigrp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.5 2004/05/12 22:22:40 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.5.2.2 2005/05/06 02:53:41 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -216,7 +216,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { const struct eigrp_common_header *eigrp_com_header; const struct eigrp_tlv_header *eigrp_tlv_header; const u_char *tptr,*tlv_tptr; - int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen,byte_length, bit_length; + u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length; u_int8_t prefix[4]; union { @@ -271,15 +271,15 @@ eigrp_print(register const u_char *pptr, register u_int len) { while(tlen>0) { /* did we capture enough for fully decoding the object header ? */ - if (!TTEST2(*tptr, sizeof(struct eigrp_tlv_header))) - goto trunc; + TCHECK2(*tptr, sizeof(struct eigrp_tlv_header)); eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr; eigrp_tlv_len=EXTRACT_16BITS(&eigrp_tlv_header->length); eigrp_tlv_type=EXTRACT_16BITS(&eigrp_tlv_header->type); - if (eigrp_tlv_len == 0 || eigrp_tlv_len > tlen) { + if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) || + eigrp_tlv_len > tlen) { print_unknown_data(tptr+sizeof(sizeof(struct eigrp_tlv_header)),"\n\t ",tlen); return; } @@ -295,8 +295,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header); /* did we capture enough for fully decoding the object ? */ - if (!TTEST2(*tptr, eigrp_tlv_len)) - goto trunc; + TCHECK2(*tptr, eigrp_tlv_len); switch(eigrp_tlv_type) { @@ -326,7 +325,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { tlv_ptr.eigrp_tlv_ip_int = (const struct eigrp_tlv_ip_int_t *)tlv_tptr; bit_length = tlv_ptr.eigrp_tlv_ip_int->plen; - if (bit_length < 0 || bit_length > 32) { + if (bit_length > 32) { printf("\n\t illegal prefix length %u",bit_length); break; } @@ -340,7 +339,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0) printf("self"); else - printf("%s",ipaddr_string(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop))); + printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_int->nexthop)); printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->delay)/100), @@ -355,7 +354,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { tlv_ptr.eigrp_tlv_ip_ext = (const struct eigrp_tlv_ip_ext_t *)tlv_tptr; bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen; - if (bit_length < 0 || bit_length > 32) { + if (bit_length > 32) { printf("\n\t illegal prefix length %u",bit_length); break; } @@ -369,7 +368,7 @@ eigrp_print(register const u_char *pptr, register u_int len) { if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0) printf("self"); else - printf("%s",ipaddr_string(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop))); + printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_ext->nexthop)); printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", ipaddr_string(tlv_ptr.eigrp_tlv_ip_ext->origin_router), diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c index bf125eb..3ccc899 100644 --- a/contrib/tcpdump/print-esp.c +++ b/contrib/tcpdump/print-esp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.55 2004/07/21 22:00:11 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.55.2.1 2005/04/21 06:44:57 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -75,7 +75,7 @@ struct sa_list { const EVP_CIPHER *evp; int ivlen; int authlen; - char secret[256]; /* is that big enough for all secrets? */ + u_char secret[256]; /* is that big enough for all secrets? */ int secretlen; }; @@ -100,7 +100,7 @@ static void esp_print_addsa(netdissect_options *ndo, } -static int hexdigit(netdissect_options *ndo, char hex) +static u_int hexdigit(netdissect_options *ndo, char hex) { if (hex >= '0' && hex <= '9') return (hex - '0'); @@ -114,9 +114,9 @@ static int hexdigit(netdissect_options *ndo, char hex) } } -static int hex2byte(netdissect_options *ndo, char *hexstring) +static u_int hex2byte(netdissect_options *ndo, char *hexstring) { - int byte; + u_int byte; byte = (hexdigit(ndo, hexstring[0]) << 4) + hexdigit(ndo, hexstring[1]); return byte; @@ -219,7 +219,7 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line) if (decode) { char *colon, *p; - char espsecret_key[256]; + u_char espsecret_key[256]; int len; size_t i; const EVP_CIPHER *evp; @@ -353,7 +353,7 @@ esp_print(netdissect_options *ndo, #endif int advance; int len; - char *secret; + u_char *secret; int ivlen = 0; u_char *ivoff; u_char *p; diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c index 534c5c1..2c7788b 100644 --- a/contrib/tcpdump/print-frag6.c +++ b/contrib/tcpdump/print-frag6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.19 2003/11/19 00:36:07 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.19.2.1 2005/04/20 22:33:21 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -45,14 +45,10 @@ frag6_print(register const u_char *bp, register const u_char *bp2) { register const struct ip6_frag *dp; register const struct ip6_hdr *ip6; - register const u_char *ep; dp = (const struct ip6_frag *)bp; ip6 = (const struct ip6_hdr *)bp2; - /* 'ep' points to the end of available data. */ - ep = snapend; - TCHECK(dp->ip6f_offlg); if (vflag) { diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c index 03dace7..1d22247 100644 --- a/contrib/tcpdump/print-hsrp.c +++ b/contrib/tcpdump/print-hsrp.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.9 2003/11/16 09:36:22 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.9.2.1 2005/05/06 07:57:17 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -127,7 +127,11 @@ hsrp_print(register const u_int8_t *bp, register u_int len) relts_print(hp->hsrp_holdtime); printf(" priority=%d", hp->hsrp_priority); printf(" auth=\""); - fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL); + if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), + snapend)) { + printf("\""); + goto trunc; + } printf("\""); } return; diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c index 4cf7deb..2d47ea6 100644 --- a/contrib/tcpdump/print-icmp6.c +++ b/contrib/tcpdump/print-icmp6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.79 2005/01/14 10:41:50 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.79.2.4 2005/05/14 00:42:54 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -35,14 +35,14 @@ static const char rcsid[] _U_ = #include <stdio.h> #include <string.h> -#include "ip6.h" -#include "icmp6.h" -#include "ipproto.h" - #include "interface.h" #include "addrtoname.h" #include "extract.h" +#include "ip6.h" +#include "icmp6.h" +#include "ipproto.h" + #include "udp.h" #include "ah.h" @@ -69,10 +69,10 @@ static struct tok icmp6_type_values[] = { { ICMP6_PARAM_PROB, "parameter problem"}, { ICMP6_ECHO_REQUEST, "echo request"}, { ICMP6_ECHO_REPLY, "echo reply"}, - { MLD6_LISTENER_QUERY, "multicast listener query "}, - { MLD6_LISTENER_REPORT, "multicast listener report "}, - { MLD6_LISTENER_DONE, "multicast listener done "}, - { ND_ROUTER_SOLICIT, "router solicitation "}, + { MLD6_LISTENER_QUERY, "multicast listener query"}, + { MLD6_LISTENER_REPORT, "multicast listener report"}, + { MLD6_LISTENER_DONE, "multicast listener done"}, + { ND_ROUTER_SOLICIT, "router solicitation"}, { ND_ROUTER_ADVERT, "router advertisement"}, { ND_NEIGHBOR_SOLICIT, "neighbor solicitation"}, { ND_NEIGHBOR_ADVERT, "neighbor advertisment"}, @@ -80,7 +80,7 @@ static struct tok icmp6_type_values[] = { { ICMP6_ROUTER_RENUMBERING, "router renumbering"}, { IND_SOLICIT, "inverse neighbor solicitation"}, { IND_ADVERT, "inverse neighbor advertisement"}, - { MLDV2_LISTENER_REPORT, "multicast listener report v2 "}, + { MLDV2_LISTENER_REPORT, "multicast listener report v2"}, { ICMP6_HADISCOV_REQUEST, "ha discovery request"}, { ICMP6_HADISCOV_REPLY, "ha discovery reply"}, { ICMP6_MOBILEPREFIX_SOLICIT, "mobile router solicitation"}, @@ -237,18 +237,15 @@ icmp6_print(const u_char *bp, u_int length, const u_char *bp2, int fragmented) { const struct icmp6_hdr *dp; const struct ip6_hdr *ip; - const char *str; const struct ip6_hdr *oip; const struct udphdr *ouh; int dport; const u_char *ep; - char buf[256]; u_int prot; dp = (struct icmp6_hdr *)bp; ip = (struct ip6_hdr *)bp2; oip = (struct ip6_hdr *)(dp + 1); - str = buf; /* 'ep' points to the end of available data. */ ep = snapend; @@ -542,7 +539,7 @@ get_upperlayer(u_char *bp, u_int *prot) nh = ip6->ip6_nxt; hlen = sizeof(struct ip6_hdr); - while (bp < snapend) { + while (bp < ep) { bp += hlen; switch(nh) { @@ -1153,8 +1150,6 @@ static void icmp6_rrenum_print(const u_char *bp, const u_char *ep) { struct icmp6_router_renum *rr6; - struct icmp6_hdr *dp; - size_t siz; const char *cp; struct rr_pco_match *match; struct rr_pco_use *use; @@ -1163,9 +1158,7 @@ icmp6_rrenum_print(const u_char *bp, const u_char *ep) if (ep < bp) return; - dp = (struct icmp6_hdr *)bp; rr6 = (struct icmp6_router_renum *)bp; - siz = ep - bp; cp = (const char *)(rr6 + 1); TCHECK(rr6->rr_reserved); diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c index b166690..898471d 100644 --- a/contrib/tcpdump/print-igrp.c +++ b/contrib/tcpdump/print-igrp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.20 2003/11/16 09:36:23 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.20.2.1 2005/04/20 21:02:15 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -77,15 +77,13 @@ static struct tok op2str[] = { }; void -igrp_print(register const u_char *bp, u_int length, register const u_char *bp2) +igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_) { register struct igrphdr *hdr; - register struct ip *ip; register u_char *cp; u_int nint, nsys, next; hdr = (struct igrphdr *)bp; - ip = (struct ip *)bp2; cp = (u_char *)(hdr + 1); (void)printf("igrp:"); diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c index dc63da8..82163a2 100644 --- a/contrib/tcpdump/print-ip6opts.c +++ b/contrib/tcpdump/print-ip6opts.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.17 2003/11/19 00:36:08 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.17.2.1 2005/04/20 22:19:06 guy Exp $"; #endif #ifdef INET6 @@ -289,11 +289,8 @@ int hbhopt_print(register const u_char *bp) { const struct ip6_hbh *dp = (struct ip6_hbh *)bp; - register const u_char *ep; int hbhlen = 0; - /* 'ep' points to the end of available data. */ - ep = snapend; TCHECK(dp->ip6h_len); hbhlen = (int)((dp->ip6h_len + 1) << 3); TCHECK2(*dp, hbhlen); @@ -312,11 +309,8 @@ int dstopt_print(register const u_char *bp) { const struct ip6_dest *dp = (struct ip6_dest *)bp; - register const u_char *ep; int dstoptlen = 0; - /* 'ep' points to the end of available data. */ - ep = snapend; TCHECK(dp->ip6d_len); dstoptlen = (int)((dp->ip6d_len + 1) << 3); TCHECK2(*dp, dstoptlen); diff --git a/contrib/tcpdump/print-juniper.c b/contrib/tcpdump/print-juniper.c index 5d48bf7..098f017 100644 --- a/contrib/tcpdump/print-juniper.c +++ b/contrib/tcpdump/print-juniper.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8 2005/04/06 21:32:41 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.13 2005/06/20 07:45:05 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -28,131 +28,476 @@ static const char rcsid[] _U_ = #include <stdio.h> #include "interface.h" +#include "addrtoname.h" #include "extract.h" #include "ppp.h" #include "llc.h" #include "nlpid.h" +#include "ethertype.h" +#include "atm.h" #define JUNIPER_BPF_OUT 0 /* Outgoing packet */ #define JUNIPER_BPF_IN 1 /* Incoming packet */ #define JUNIPER_BPF_PKT_IN 0x1 /* Incoming packet */ #define JUNIPER_BPF_NO_L2 0x2 /* L2 header stripped */ +#define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */ + +#define JUNIPER_LSQ_L3_PROTO_SHIFT 4 +#define JUNIPER_LSQ_L3_PROTO_MASK (0x17 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_IPV4 (0 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_IPV6 (1 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_MPLS (2 << JUNIPER_LSQ_L3_PROTO_SHIFT) +#define JUNIPER_LSQ_L3_PROTO_ISO (3 << JUNIPER_LSQ_L3_PROTO_SHIFT) + +#define JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE 1 +#define JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE 2 +#define JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE 3 +#define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4 +#define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5 + +static struct tok juniper_ipsec_type_values[] = { + { JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" }, + { JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" }, + { JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" }, + { JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE, "AH AUTH" }, + { JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE, "ESP ENCR" }, + { 0, NULL} +}; + +static struct tok juniper_direction_values[] = { + { JUNIPER_BPF_IN, "In"}, + { JUNIPER_BPF_OUT, "Out"}, + { 0, NULL} +}; + +struct juniper_cookie_table_t { + u_int32_t pictype; /* pic type */ + u_int8_t cookie_len; /* cookie len */ + const char *s; /* pic name */ +}; + +static struct juniper_cookie_table_t juniper_cookie_table[] = { +#ifdef DLT_JUNIPER_ATM1 + { DLT_JUNIPER_ATM1, 4, "ATM1"}, +#endif +#ifdef DLT_JUNIPER_ATM2 + { DLT_JUNIPER_ATM2, 8, "ATM2"}, +#endif +#ifdef DLT_JUNIPER_MLPPP + { DLT_JUNIPER_MLPPP, 2, "MLPPP"}, +#endif +#ifdef DLT_JUNIPER_MLFR + { DLT_JUNIPER_MLFR, 2, "MLFR"}, +#endif +#ifdef DLT_JUNIPER_MFR + { DLT_JUNIPER_MFR, 4, "MFR"}, +#endif +#ifdef DLT_JUNIPER_PPPOE + { DLT_JUNIPER_PPPOE, 0, "PPPoE"}, +#endif +#ifdef DLT_JUNIPER_PPPOE_ATM + { DLT_JUNIPER_PPPOE_ATM, 0, "PPPoE ATM"}, +#endif +#ifdef DLT_JUNIPER_GGSN + { DLT_JUNIPER_GGSN, 8, "GGSN"}, +#endif +#ifdef DLT_JUNIPER_MONITOR + { DLT_JUNIPER_MONITOR, 8, "MONITOR"}, +#endif +#ifdef DLT_JUNIPER_SERVICES + { DLT_JUNIPER_SERVICES, 8, "AS"}, +#endif +#ifdef DLT_JUNIPER_ES + { DLT_JUNIPER_ES, 0, "ES"}, +#endif + { 0, 0, NULL } +}; + +struct juniper_l2info_t { + u_int32_t length; + u_int32_t caplen; + u_int32_t pictype; + u_int8_t direction; + u_int8_t header_len; + u_int8_t cookie_len; + u_int8_t cookie_type; + u_int8_t cookie[8]; + u_int8_t bundle; + u_int16_t proto; +}; #define LS_COOKIE_ID 0x54 -#define LS_MLFR_LEN 4 -#define ML_MLFR_LEN 2 +#define AS_COOKIE_ID 0x47 +#define LS_MLFR_COOKIE_LEN 4 +#define ML_MLFR_COOKIE_LEN 2 +#define LS_MFR_COOKIE_LEN 6 +#define ATM1_COOKIE_LEN 4 +#define ATM2_COOKIE_LEN 8 #define ATM2_PKT_TYPE_MASK 0x70 #define ATM2_GAP_COUNT_MASK 0x3F +#define JUNIPER_PROTO_NULL 1 +#define JUNIPER_PROTO_IPV4 2 +#define JUNIPER_PROTO_IPV6 6 + +static struct tok juniper_protocol_values[] = { + { JUNIPER_PROTO_NULL, "Null" }, + { JUNIPER_PROTO_IPV4, "IPv4" }, + { JUNIPER_PROTO_IPV6, "IPv6" }, + { 0, NULL} +}; + int ip_heuristic_guess(register const u_char *, u_int); int juniper_ppp_heuristic_guess(register const u_char *, u_int); -static int juniper_parse_header (const u_char *, u_int8_t *, u_int); +static int juniper_parse_header (const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *); +#ifdef DLT_JUNIPER_GGSN u_int -juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p) +juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; - u_int8_t direction,bundle,cookie_len; - u_int32_t cookie,proto; - - if(juniper_parse_header(p, &direction,length) == 0) - return 0; - - p+=4; - length-=4; - caplen-=4; - - if (p[0] == LS_COOKIE_ID) { - cookie=EXTRACT_32BITS(p); - if (eflag) printf("LSPIC-MLPPP cookie 0x%08x, ",cookie); - cookie_len = LS_MLFR_LEN; - bundle = cookie & 0xff; - } else { - cookie=EXTRACT_16BITS(p); - if (eflag) printf("MLPIC-MLPPP cookie 0x%04x, ",cookie); - cookie_len = ML_MLFR_LEN; - bundle = (cookie >> 8) & 0xff; + struct juniper_l2info_t l2info; + struct juniper_ggsn_header { + u_int8_t svc_id; + u_int8_t flags_len; + u_int8_t proto; + u_int8_t flags; + u_int8_t vlan_id[2]; + u_int8_t res[2]; + }; + const struct juniper_ggsn_header *gh; + + l2info.pictype = DLT_JUNIPER_GGSN; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + gh = (struct juniper_ggsn_header *)p; + + if (eflag) + printf("proto %s (%u), vlan %u: ", + tok2str(juniper_protocol_values,"Unknown",gh->proto), + gh->proto, + EXTRACT_16BITS(&gh->vlan_id[0])); + + switch (gh->proto) { + case JUNIPER_PROTO_IPV4: + ip_print(gndo, p, l2info.length); + break; +#ifdef INET6 + case JUNIPER_PROTO_IPV6: + ip6_print(p, l2info.length); + break; +#endif /* INET6 */ + default: + if (!eflag) + printf("unknown GGSN proto (%u)", gh->proto); + } + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_ES +u_int +juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_ipsec_header { + u_int8_t sa_index[2]; + u_int8_t ttl; + u_int8_t type; + u_int8_t spi[4]; + u_int8_t src_ip[4]; + u_int8_t dst_ip[4]; + }; + u_int rewrite_len,es_type_bundle; + const struct juniper_ipsec_header *ih; + + l2info.pictype = DLT_JUNIPER_ES; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + ih = (struct juniper_ipsec_header *)p; + + switch (ih->type) { + case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE: + case JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE: + rewrite_len = 0; + es_type_bundle = 1; + break; + case JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE: + case JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE: + case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE: + rewrite_len = 16; + es_type_bundle = 0; + default: + printf("ES Invalid type %u, length %u", + ih->type, + l2info.length); + return l2info.header_len; } - proto = EXTRACT_16BITS(p+cookie_len); - p += cookie_len; - length-= cookie_len; - caplen-= cookie_len; + l2info.length-=rewrite_len; + p+=rewrite_len; + + if (eflag) { + if (!es_type_bundle) { + printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n", + EXTRACT_16BITS(&ih->sa_index), + ih->ttl, + tok2str(juniper_ipsec_type_values,"Unknown",ih->type), + ih->type, + EXTRACT_32BITS(&ih->spi), + ipaddr_string(EXTRACT_32BITS(&ih->src_ip)), + ipaddr_string(EXTRACT_32BITS(&ih->dst_ip)), + l2info.length); + } else { + printf("ES SA, index %u, ttl %u type %s (%u), length %u\n", + EXTRACT_16BITS(&ih->sa_index), + ih->ttl, + tok2str(juniper_ipsec_type_values,"Unknown",ih->type), + ih->type, + l2info.length); + } + } + + ip_print(gndo, p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MONITOR +u_int +juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_monitor_header { + u_int8_t pkt_type; + u_int8_t padding; + u_int8_t iif[2]; + u_int8_t service_id[4]; + }; + const struct juniper_monitor_header *mh; + + l2info.pictype = DLT_JUNIPER_MONITOR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + mh = (struct juniper_monitor_header *)p; + + if (eflag) + printf("service-id %u, iif %u, pkt-type %u: ", + EXTRACT_32BITS(&mh->service_id), + EXTRACT_16BITS(&mh->iif), + mh->pkt_type); + + /* no proto field - lets guess by first byte of IP header*/ + ip_heuristic_guess(p, l2info.length); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_SERVICES +u_int +juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + struct juniper_services_header { + u_int8_t svc_id; + u_int8_t flags_len; + u_int8_t svc_set_id[2]; + u_int8_t dir_iif[4]; + }; + const struct juniper_services_header *sh; + + l2info.pictype = DLT_JUNIPER_SERVICES; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + sh = (struct juniper_services_header *)p; + + if (eflag) + printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ", + sh->svc_id, + sh->flags_len, + EXTRACT_16BITS(&sh->svc_set_id), + EXTRACT_24BITS(&sh->dir_iif[1])); + + /* no proto field - lets guess by first byte of IP header*/ + ip_heuristic_guess(p, l2info.length); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPPOE +u_int +juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_PPPOE; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw ethernet frames */ + ether_print(p, l2info.length, l2info.caplen); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPPOE_ATM +u_int +juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + u_int16_t extracted_ethertype; + + l2info.pictype = DLT_JUNIPER_PPPOE_ATM; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + + extracted_ethertype = EXTRACT_16BITS(p); + /* this DLT contains nothing but raw PPPoE frames, + * prepended with a type field*/ + if (ether_encap_print(extracted_ethertype, + p+ETHERTYPE_LEN, + l2info.length-ETHERTYPE_LEN, + l2info.caplen-ETHERTYPE_LEN, + &extracted_ethertype) == 0) + /* ether_type not known, probably it wasn't one */ + printf("unknown ethertype 0x%04x", extracted_ethertype); + + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MLPPP +u_int +juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_MLPPP; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; /* suppress Bundle-ID if frame was captured on a child-link - * this may be the case if the cookie looks like a proto */ + * best indicator if the cookie looks like a proto */ if (eflag && - cookie != PPP_OSI && - cookie != (PPP_ADDRESS << 8 | PPP_CONTROL)) - printf("Bundle-ID %u, ",bundle); + EXTRACT_16BITS(&l2info.cookie) != PPP_OSI && + EXTRACT_16BITS(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL)) + printf("Bundle-ID %u: ",l2info.bundle); - switch (cookie) { + p+=l2info.header_len; + + /* first try the LSQ protos */ + switch(l2info.proto) { + case JUNIPER_LSQ_L3_PROTO_IPV4: + ip_print(gndo, p, l2info.length); + return l2info.header_len; +#ifdef INET6 + case JUNIPER_LSQ_L3_PROTO_IPV6: + ip6_print(p,l2info.length); + return l2info.header_len; +#endif + case JUNIPER_LSQ_L3_PROTO_MPLS: + mpls_print(p,l2info.length); + return l2info.header_len; + case JUNIPER_LSQ_L3_PROTO_ISO: + isoclns_print(p,l2info.length,l2info.caplen); + return l2info.header_len; + default: + break; + } + + /* zero length cookie ? */ + switch (EXTRACT_16BITS(&l2info.cookie)) { case PPP_OSI: - ppp_print(p-2,length+2); + ppp_print(p-2,l2info.length+2); break; case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */ default: - ppp_print(p,length); + ppp_print(p,l2info.length); break; } - return cookie_len; + return l2info.header_len; } +#endif +#ifdef DLT_JUNIPER_MFR u_int -juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p) +juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; - u_int8_t direction,bundle,cookie_len; - u_int32_t cookie,proto,frelay_len = 0; + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_MFR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; - if(juniper_parse_header(p, &direction,length) == 0) - return 0; - - p+=4; - length-=4; - caplen-=4; - - if (p[0] == LS_COOKIE_ID) { - cookie=EXTRACT_32BITS(p); - if (eflag) printf("LSPIC-MLFR cookie 0x%08x, ",cookie); - cookie_len = LS_MLFR_LEN; - bundle = cookie & 0xff; - } else { - cookie=EXTRACT_16BITS(p); - if (eflag) printf("MLPIC-MLFR cookie 0x%04x, ",cookie); - cookie_len = ML_MLFR_LEN; - bundle = (cookie >> 8) & 0xff; + p+=l2info.header_len; + /* suppress Bundle-ID if frame was captured on a child-link */ + if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle); + switch (l2info.proto) { + case (LLCSAP_ISONS<<8 | LLCSAP_ISONS): + isoclns_print(p+1, l2info.length-1, l2info.caplen-1); + break; + case (LLC_UI<<8 | NLPID_Q933): + case (LLC_UI<<8 | NLPID_IP): + case (LLC_UI<<8 | NLPID_IP6): + /* pass IP{4,6} to the OSI layer for proper link-layer printing */ + isoclns_print(p-1, l2info.length+1, l2info.caplen+1); + break; + default: + printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length); } - proto = EXTRACT_16BITS(p+cookie_len); - p += cookie_len+2; - length-= cookie_len+2; - caplen-= cookie_len+2; + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_MLFR +u_int +juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; - /* suppress Bundle-ID if frame was captured on a child-link */ - if (eflag && cookie != 1) printf("Bundle-ID %u, ",bundle); + l2info.pictype = DLT_JUNIPER_MLFR; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; - switch (proto) { + /* suppress Bundle-ID if frame was captured on a child-link */ + if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle); + switch (l2info.proto) { case (LLC_UI): case (LLC_UI<<8): - isoclns_print(p, length, caplen); + isoclns_print(p, l2info.length, l2info.caplen); break; case (LLC_UI<<8 | NLPID_Q933): case (LLC_UI<<8 | NLPID_IP): case (LLC_UI<<8 | NLPID_IP6): - isoclns_print(p-1, length+1, caplen+1); /* pass IP{4,6} to the OSI layer for proper link-layer printing */ + /* pass IP{4,6} to the OSI layer for proper link-layer printing */ + isoclns_print(p-1, l2info.length+1, l2info.caplen+1); break; default: - printf("unknown protocol 0x%04x, length %u",proto, length); + printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length); } - return cookie_len + frelay_len; + return l2info.header_len; } +#endif /* * ATM1 PIC cookie format @@ -162,59 +507,45 @@ juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p) * +-----+-------------------------+-------------------------------+ */ +#ifdef DLT_JUNIPER_ATM1 u_int juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; u_int16_t extracted_ethertype; - u_int8_t direction; - u_int32_t cookie1; - if(juniper_parse_header(p, &direction,length) == 0) - return 0; + struct juniper_l2info_t l2info; - p+=4; - length-=4; - caplen-=4; + l2info.pictype = DLT_JUNIPER_ATM1; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; - cookie1=EXTRACT_32BITS(p); + p+=l2info.header_len; - if (eflag) { - /* FIXME decode channel-id, vc-index, fmt-id - for once lets just hexdump the cookie */ - - printf("ATM1 cookie 0x%08x, ", cookie1); - } - - p+=4; - length-=4; - caplen-=4; - - if ((cookie1 >> 24) == 0x80) { /* OAM cell ? */ - oam_print(p,length); - return 0; + if (l2info.cookie[0] == 0x80) { /* OAM cell ? */ + oam_print(p,l2info.length,ATM_OAM_NOHEC); + return l2info.header_len; } if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ - if (llc_print(p, length, caplen, NULL, NULL, + if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL, &extracted_ethertype) != 0) - return 8; + return l2info.header_len; } if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ - isoclns_print(p + 1, length - 1, caplen - 1); + isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1); /* FIXME check if frame was recognized */ - return 8; + return l2info.header_len; } - if(ip_heuristic_guess(p, length) != 0) /* last try - vcmux encaps ? */ - return 0; + if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */ + return l2info.header_len; - return (8); + return l2info.header_len; } +#endif /* * ATM2 PIC cookie format @@ -224,71 +555,61 @@ juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p) * +-------------------------------+---------+---+-----+-----------+ */ +#ifdef DLT_JUNIPER_ATM2 u_int juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; u_int16_t extracted_ethertype; - u_int8_t direction; - u_int32_t cookie1,cookie2; - - if(juniper_parse_header(p, &direction,length) == 0) - return 0; + u_int32_t control_word; - p+=4; - length-=4; - caplen-=4; + struct juniper_l2info_t l2info; - cookie1=EXTRACT_32BITS(p); - cookie2=EXTRACT_32BITS(p+4); + l2info.pictype = DLT_JUNIPER_ATM2; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; - if (eflag) { - /* FIXME decode channel, fmt-id, ccrq, aal, gap cnt - for once lets just hexdump the cookie */ + p+=l2info.header_len; - printf("ATM2 cookie 0x%08x%08x, ", - EXTRACT_32BITS(p), - EXTRACT_32BITS(p+4)); - } - - p+=8; - length-=8; - caplen-=8; - - if (cookie2 & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ - oam_print(p,length); - return 12; + if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ + control_word = EXTRACT_32BITS(p); + if(control_word == 0 || control_word == 0x08000000) { + l2info.header_len += 4; + l2info.length -= 4; + p += 4; + } + oam_print(p,l2info.length,ATM_OAM_NOHEC); + return l2info.header_len; } if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ - if (llc_print(p, length, caplen, NULL, NULL, + if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL, &extracted_ethertype) != 0) - return 12; + return l2info.header_len; } - if (direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */ - (cookie1 & ATM2_GAP_COUNT_MASK)) { - ether_print(p, length, caplen); - return 12; + if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */ + (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) { + ether_print(p, l2info.length, l2info.caplen); + return l2info.header_len; } if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ - isoclns_print(p + 1, length - 1, caplen - 1); + isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1); /* FIXME check if frame was recognized */ - return 12; + return l2info.header_len; } - if(juniper_ppp_heuristic_guess(p, length) != 0) /* PPPoA vcmux encaps ? */ - return 12; + if(juniper_ppp_heuristic_guess(p, l2info.length) != 0) /* PPPoA vcmux encaps ? */ + return l2info.header_len; - if(ip_heuristic_guess(p, length) != 0) /* last try - vcmux encaps ? */ - return 12; + if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */ + return l2info.header_len; - return (12); + return l2info.header_len; } +#endif /* try to guess, based on all PPP protos that are supported in @@ -367,21 +688,28 @@ ip_heuristic_guess(register const u_char *p, u_int length) { } static int -juniper_parse_header (const u_char *p, u_int8_t *direction, u_int length) { +juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) { - *direction = p[3]&JUNIPER_BPF_PKT_IN; - - if (EXTRACT_24BITS(p) != 0x4d4743) /* magic number found ? */ - return -1; + struct juniper_cookie_table_t *lp = juniper_cookie_table; + u_int idx; + + l2info->header_len = 0; + l2info->cookie_len = 0; + l2info->proto = 0; + + + l2info->length = h->len; + l2info->caplen = h->caplen; + l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; - if (*direction == JUNIPER_BPF_PKT_IN) { - if (eflag) - printf("%3s ", "In"); - } - else { - if (eflag) - printf("%3s ", "Out"); - } + TCHECK2(p[0],4); + if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) /* magic number found ? */ + return 0; + else + l2info->header_len = 4; + + if (eflag) /* print direction */ + printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction)); if ((p[3] & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { if (eflag) @@ -391,19 +719,129 @@ juniper_parse_header (const u_char *p, u_int8_t *direction, u_int length) { * perform the v4/v6 heuristics * to figure out what it is */ - if(ip_heuristic_guess(p+8,length-8) == 0) + TCHECK2(p[8],1); + if(ip_heuristic_guess(p+8,l2info->length-8) == 0) printf("no IP-hdr found!"); + l2info->header_len+=4; return 0; /* stop parsing the output further */ } + + p+=l2info->header_len; + l2info->length -= l2info->header_len; + l2info->caplen -= l2info->header_len; + + /* search through the cookie table and copy values matching for our PIC type */ + while (lp->s != NULL) { + if (lp->pictype == l2info->pictype) { + + l2info->cookie_len = lp->cookie_len; + l2info->header_len += lp->cookie_len; + + switch (p[0]) { + case LS_COOKIE_ID: + l2info->cookie_type = LS_COOKIE_ID; + l2info->cookie_len += 2; + l2info->header_len += 2; + break; + case AS_COOKIE_ID: + l2info->cookie_type = AS_COOKIE_ID; + l2info->cookie_len += 6; + l2info->header_len += 6; + break; + + default: + l2info->bundle = l2info->cookie[0]; + break; + } + + if (eflag) + printf("%s-PIC, cookie-len %u", + lp->s, + l2info->cookie_len); + + if (l2info->cookie_len > 0) { + TCHECK2(p[0],l2info->cookie_len); + if (eflag) + printf(", cookie 0x"); + for (idx = 0; idx < l2info->cookie_len; idx++) { + l2info->cookie[idx] = p[idx]; /* copy cookie data */ + if (eflag) printf("%02x",p[idx]); + } + } + + if (eflag) printf(": "); /* print demarc b/w L2/L3*/ + + + l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); + break; + } + ++lp; + } + p+=l2info->cookie_len; + + /* DLT_ specific parsing */ + switch(l2info->pictype) { + case DLT_JUNIPER_MLPPP: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + break; + case DLT_JUNIPER_MLFR: /* fall through */ + case DLT_JUNIPER_MFR: + switch (l2info->cookie_type) { + case LS_COOKIE_ID: + l2info->bundle = l2info->cookie[1]; + break; + case AS_COOKIE_ID: + l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; + break; + default: + l2info->bundle = l2info->cookie[0]; + break; + } + l2info->proto = EXTRACT_16BITS(p); + l2info->header_len += 2; + l2info->length -= 2; + l2info->caplen -= 2; + break; + case DLT_JUNIPER_ATM2: + TCHECK2(p[0],4); + /* ATM cell relay control word present ? */ + if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK && *p & 0x08) { + l2info->header_len += 4; + if (eflag) + printf("control-word 0x%08x ",EXTRACT_32BITS(p)); + } + break; + case DLT_JUNIPER_ATM1: + default: + break; + } + + if (eflag > 1) + printf("hlen %u, proto 0x%04x, ",l2info->header_len,l2info->proto); + return 1; /* everything went ok so far. continue parsing */ + trunc: + printf("[|juniper_hdr], length %u",h->len); + return 0; } /* * Local Variables: * c-style: whitesmith - * c-basic-offset: 8 + * c-basic-offset: 4 * End: */ diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c index a4036d1..52766b5 100644 --- a/contrib/tcpdump/print-l2tp.c +++ b/contrib/tcpdump/print-l2tp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.17 2003/12/26 23:20:58 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.17.2.2 2005/04/20 21:50:16 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -617,10 +617,10 @@ l2tp_print(const u_char *dat, u_int length) const u_int16_t *ptr = (u_int16_t *)dat; u_int cnt = 0; /* total octets consumed */ u_int16_t pad; - int flag_t, flag_l, flag_s, flag_o, flag_p; + int flag_t, flag_l, flag_s, flag_o; u_int16_t l2tp_len; - flag_t = flag_l = flag_s = flag_o = flag_p = FALSE; + flag_t = flag_l = flag_s = flag_o = FALSE; TCHECK(*ptr); /* Flags & Version */ if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { @@ -650,10 +650,8 @@ l2tp_print(const u_char *dat, u_int length) flag_o = TRUE; printf("O"); } - if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) { - flag_p = TRUE; + if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) printf("P"); - } printf("]"); ptr++; @@ -690,7 +688,22 @@ l2tp_print(const u_char *dat, u_int length) cnt += (2 + pad); } + if (flag_l) { + if (length < l2tp_len) { + printf(" Length %u larger than packet", l2tp_len); + return; + } + length = l2tp_len; + } + if (length < cnt) { + printf(" Length %u smaller than header length", length); + return; + } if (flag_t) { + if (!flag_l) { + printf(" No length"); + return; + } if (length - cnt == 0) { printf(" ZLB"); } else { diff --git a/contrib/tcpdump/print-ldp.c b/contrib/tcpdump/print-ldp.c index 61d2a54..e296508 100644 --- a/contrib/tcpdump/print-ldp.c +++ b/contrib/tcpdump/print-ldp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8 2004/06/15 09:42:42 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.5 2005/06/16 01:10:35 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -187,6 +187,33 @@ static const struct tok ldp_fec_values[] = { { 0, NULL} }; +#define LDP_FEC_MARTINI_IFPARM_MTU 0x01 +#define LDP_FEC_MARTINI_IFPARM_DESC 0x03 +#define LDP_FEC_MARTINI_IFPARM_VCCV 0x0c + +static const struct tok ldp_fec_martini_ifparm_values[] = { + { LDP_FEC_MARTINI_IFPARM_MTU, "MTU" }, + { LDP_FEC_MARTINI_IFPARM_DESC, "Description" }, + { LDP_FEC_MARTINI_IFPARM_VCCV, "VCCV" }, + { 0, NULL} +}; + +/* draft-ietf-pwe3-vccv-04.txt */ +static const struct tok ldp_fec_martini_ifparm_vccv_cc_values[] = { + { 0x01, "PWE3 control word" }, + { 0x02, "MPLS Router Alert Label" }, + { 0x04, "MPLS inner label TTL = 1" }, + { 0, NULL} +}; + +/* draft-ietf-pwe3-vccv-04.txt */ +static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = { + { 0x01, "ICMP Ping" }, + { 0x02, "LSP Ping" }, + { 0x04, "BFD" }, + { 0, NULL} +}; + /* RFC1700 address family numbers, same definition in print-bgp.c */ #define AFNUM_INET 1 #define AFNUM_INET6 2 @@ -194,6 +221,7 @@ static const struct tok ldp_fec_values[] = { #define FALSE 0 #define TRUE 1 +int ldp_msg_print(register const u_char *); int ldp_tlv_print(register const u_char *); /* @@ -224,7 +252,7 @@ ldp_tlv_print(register const u_char *tptr) { const struct ldp_tlv_header *ldp_tlv_header; u_short tlv_type,tlv_len,tlv_tlen,af,ft_flags; u_char fec_type; - u_int ui; + u_int ui,vc_info_len, vc_info_tlv_type, vc_info_tlv_len,idx; char buf[100]; int i; @@ -324,10 +352,65 @@ ldp_tlv_print(register const u_char *tptr) { case LDP_FEC_HOSTADDRESS: break; case LDP_FEC_MARTINI_VC: - printf(": %s, %scontrol word, VC %u", + if (!TTEST2(*tptr, 11)) + goto trunc; + vc_info_len = *(tptr+2); + + printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u", tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff), EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ", - EXTRACT_32BITS(tptr+7)); + EXTRACT_32BITS(tptr+3), + EXTRACT_32BITS(tptr+7), + vc_info_len); + + if (vc_info_len == 0) /* infinite loop protection */ + break; + + tptr+=11; + if (!TTEST2(*tptr, vc_info_len)) + goto trunc; + + while (vc_info_len > 2) { + vc_info_tlv_type = *tptr; + vc_info_tlv_len = *(tptr+1); + if (vc_info_tlv_len < 2) + break; + if (vc_info_len < vc_info_tlv_len) + break; + + printf("\n\t\tInterface Parameter: %s (0x%02x), len %u", + tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type), + vc_info_tlv_type, + vc_info_tlv_len); + + switch(vc_info_tlv_type) { + case LDP_FEC_MARTINI_IFPARM_MTU: + printf(": %u",EXTRACT_16BITS(tptr+2)); + break; + + case LDP_FEC_MARTINI_IFPARM_DESC: + printf(": "); + for (idx = 2; idx < vc_info_tlv_len; idx++) + safeputchar(*(tptr+idx)); + break; + + case LDP_FEC_MARTINI_IFPARM_VCCV: + printf("\n\t\t Control Channels (0x%02x) = [%s]", + *(tptr+2), + bittok2str(ldp_fec_martini_ifparm_vccv_cc_values,"none",*(tptr+2))); + printf("\n\t\t CV Types (0x%02x) = [%s]", + *(tptr+3), + bittok2str(ldp_fec_martini_ifparm_vccv_cv_values,"none",*(tptr+3))); + break; + + default: + print_unknown_data(tptr+2,"\n\t\t ",vc_info_tlv_len-2); + break; + } + + vc_info_len -= vc_info_tlv_len; + tptr += vc_info_tlv_len; + } break; } @@ -391,16 +474,34 @@ ldp_tlv_print(register const u_char *tptr) { break; } return(tlv_len+4); /* Type & Length fields not included */ + +trunc: + printf("\n\t\t packet exceeded snapshot"); + return 0; } void ldp_print(register const u_char *pptr, register u_int len) { + int processed; + while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) { + processed = ldp_msg_print(pptr); + if (processed == 0) + return; + len -= processed; + pptr += processed; + } +} + + +int +ldp_msg_print(register const u_char *pptr) { + const struct ldp_common_header *ldp_com_header; const struct ldp_msg_header *ldp_msg_header; const u_char *tptr,*msg_tptr; u_short tlen; - u_short msg_len,msg_type,msg_tlen; + u_short pdu_len,msg_len,msg_type,msg_tlen; int hexdump,processed; tptr=pptr; @@ -411,24 +512,26 @@ ldp_print(register const u_char *pptr, register u_int len) { * Sanity checking of the header. */ if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) { - printf("LDP version %u packet not supported", + printf("%sLDP version %u packet not supported", + (vflag < 1) ? "" : "\n\t", EXTRACT_16BITS(&ldp_com_header->version)); - return; + return 0; } /* print the LSR-ID, label-space & length */ - printf("%sLDP, Label-Space-ID: %s:%u, length: %u", + pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length); + printf("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u", (vflag < 1) ? "" : "\n\t", ipaddr_string(&ldp_com_header->lsr_id), EXTRACT_16BITS(&ldp_com_header->label_space), - len); + pdu_len); /* bail out if non-verbose */ if (vflag < 1) - return; + return 0; /* ok they seem to want to know everything - lets fully decode it */ - tlen=EXTRACT_16BITS(ldp_com_header->pdu_length); + tlen=pdu_len; tptr += sizeof(const struct ldp_common_header); tlen -= sizeof(const struct ldp_common_header)-4; /* Type & Length fields not included */ @@ -452,6 +555,9 @@ ldp_print(register const u_char *pptr, register u_int len) { EXTRACT_32BITS(&ldp_msg_header->id), LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore"); + if (msg_len == 0) /* infinite loop protection */ + return 0; + msg_tptr=tptr+sizeof(struct ldp_msg_header); msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */ @@ -501,8 +607,9 @@ ldp_print(register const u_char *pptr, register u_int len) { tptr += msg_len+4; tlen -= msg_len+4; } - return; + return pdu_len+4; trunc: printf("\n\t\t packet exceeded snapshot"); + return 0; } diff --git a/contrib/tcpdump/print-lmp.c b/contrib/tcpdump/print-lmp.c index d2089fe..14c7cf2 100644 --- a/contrib/tcpdump/print-lmp.c +++ b/contrib/tcpdump/print-lmp.c @@ -11,11 +11,13 @@ * FOR A PARTICULAR PURPOSE. * * Original code by Hannes Gredler (hannes@juniper.net) + * Support for LMP service discovery extensions (defined by UNI 1.0) added + * by Manu Pathak (mapathak@cisco.com), May 2005 */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.5 2004/04/27 14:03:44 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.5.2.1 2005/05/19 06:44:03 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -107,6 +109,48 @@ static const struct tok lmp_obj_link_summary_error_values[] = { { 0, NULL} }; +/* Service Config Supported Protocols Flags */ +static const struct tok lmp_obj_service_config_sp_flag_values[] = { + { 0x01, "RSVP Supported"}, + { 0x02, "LDP Supported"}, + { 0, NULL} +}; + +/* Service Config Client Port Service Attribute Transparency Flags */ +static const struct tok lmp_obj_service_config_cpsa_tp_flag_values[] = { + { 0x01, "Path/VC Overhead Transparency Supported"}, + { 0x02, "Line/MS Overhead Transparency Supported"}, + { 0x04, "Section/RS Overhead Transparency Supported"}, + { 0, NULL} +}; + +/* Service Config Client Port Service Attribute Contiguous Concatenation Types Flags */ +static const struct tok lmp_obj_service_config_cpsa_cct_flag_values[] = { + { 0x01, "Contiguous Concatenation Types Supported"}, + { 0, NULL} +}; + +/* Service Config Network Service Attributes Transparency Flags */ +static const struct tok lmp_obj_service_config_nsa_transparency_flag_values[] = { + { 0x01, "Standard SOH/RSOH Transparency Supported"}, + { 0x02, "Standard LOH/MSOH Transparency Supported"}, + { 0, NULL} +}; + +/* Service Config Network Service Attributes TCM Monitoring Flags */ +static const struct tok lmp_obj_service_config_nsa_tcm_flag_values[] = { + { 0x01, "Transparent Tandem Connection Monitoring Supported"}, + { 0, NULL} +}; + +/* Network Service Attributes Network Diversity Flags */ +static const struct tok lmp_obj_service_config_nsa_network_diversity_flag_values[] = { + { 0x01, "Node Diversity Supported"}, + { 0x02, "Link Diversity Supported"}, + { 0x04, "SRLG Diversity Supported"}, + { 0, NULL} +}; + #define LMP_MSGTYPE_CONFIG 1 #define LMP_MSGTYPE_CONFIG_ACK 2 #define LMP_MSGTYPE_CONFIG_NACK 3 @@ -127,6 +171,10 @@ static const struct tok lmp_obj_link_summary_error_values[] = { #define LMP_MSGTYPE_CHANNEL_STATUS_ACK 18 #define LMP_MSGTYPE_CHANNEL_STATUS_REQ 19 #define LMP_MSGTYPE_CHANNEL_STATUS_RESP 20 +/* LMP Service Discovery message types defined by UNI 1.0 */ +#define LMP_MSGTYPE_SERVICE_CONFIG 50 +#define LMP_MSGTYPE_SERVICE_CONFIG_ACK 51 +#define LMP_MSGTYPE_SERVICE_CONFIG_NACK 52 static const struct tok lmp_msg_type_values[] = { { LMP_MSGTYPE_CONFIG, "Config"}, @@ -149,6 +197,9 @@ static const struct tok lmp_msg_type_values[] = { { LMP_MSGTYPE_CHANNEL_STATUS_ACK, "Channel Status ACK"}, { LMP_MSGTYPE_CHANNEL_STATUS_REQ, "Channel Status Request"}, { LMP_MSGTYPE_CHANNEL_STATUS_RESP, "Channel Status Response"}, + { LMP_MSGTYPE_SERVICE_CONFIG, "Service Config"}, + { LMP_MSGTYPE_SERVICE_CONFIG_ACK, "Service Config ACK"}, + { LMP_MSGTYPE_SERVICE_CONFIG_NACK, "Service Config NACK"}, { 0, NULL} }; @@ -188,6 +239,8 @@ struct lmp_object_header { #define LMP_OBJ_CHANNEL_STATUS_REQ 14 #define LMP_OBJ_ERROR_CODE 20 +#define LMP_OBJ_SERVICE_CONFIG 51 /* defined in UNI 1.0 */ + static const struct tok lmp_obj_values[] = { { LMP_OBJ_CC_ID, "Control Channel ID" }, { LMP_OBJ_NODE_ID, "Node ID" }, @@ -204,6 +257,8 @@ static const struct tok lmp_obj_values[] = { { LMP_OBJ_CHANNEL_STATUS, "Channel Status" }, { LMP_OBJ_CHANNEL_STATUS_REQ, "Channel Status Request" }, { LMP_OBJ_ERROR_CODE, "Error Code" }, + { LMP_OBJ_SERVICE_CONFIG, "Service Config" }, + { 0, NULL} }; @@ -239,6 +294,19 @@ static const struct tok lmp_data_link_subobj[] = { #define LMP_CTYPE_BEGIN_VERIFY_ERROR 1 #define LMP_CTYPE_LINK_SUMMARY_ERROR 2 +/* C-Types for Service Config Object */ +#define LMP_CTYPE_SERVICE_CONFIG_SP 1 +#define LMP_CTYPE_SERVICE_CONFIG_CPSA 2 +#define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM 3 +#define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY 4 + +/* + * Different link types allowed in the Client Port Service Attributes + * subobject defined for LMP Service Discovery in the UNI 1.0 spec + */ +#define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH 5 /* UNI 1.0 Sec 9.4.2 */ +#define LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET 6 /* UNI 1.0 Sec 9.4.2 */ + #define FALSE 0 #define TRUE 1 @@ -286,6 +354,10 @@ static const struct tok lmp_ctype_values[] = { { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_UNMD, "Unnumbered" }, { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_ERROR_CODE+LMP_CTYPE_2, "2" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_SP, "1" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_CPSA, "2" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM, "3" }, + { 256*LMP_OBJ_SERVICE_CONFIG+LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY, "4" }, { 0, NULL} }; @@ -298,6 +370,7 @@ lmp_print(register const u_char *pptr, register u_int len) { int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen; int hexdump; int offset,subobj_type,subobj_len,total_subobj_len; + int link_type; union { /* int to float conversion buffer */ float f; @@ -693,7 +766,105 @@ lmp_print(register const u_char *pptr, register u_int len) { hexdump=TRUE; } break; - + + case LMP_OBJ_SERVICE_CONFIG: + switch (lmp_obj_ctype) { + case LMP_CTYPE_SERVICE_CONFIG_SP: + + printf("\n\t Flags: %s", + bittok2str(lmp_obj_service_config_sp_flag_values, + "none", + EXTRACT_16BITS(obj_tptr)>>8)); + + printf("\n\t UNI Version: %u", + EXTRACT_16BITS(obj_tptr) & 0x00FF); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_CPSA: + + link_type = EXTRACT_16BITS(obj_tptr)>>8; + + printf("\n\t Link Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_link_type_values, + "Unknown", link_type), + link_type); + + if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) { + printf("\n\t Signal Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values, + "Unknown", + EXTRACT_16BITS(obj_tptr) & 0x00FF), + EXTRACT_16BITS(obj_tptr) & 0x00FF); + } + + if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) { + printf("\n\t Signal Type: %s (%u)", + tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values, + "Unknown", + EXTRACT_16BITS(obj_tptr) & 0x00FF), + EXTRACT_16BITS(obj_tptr) & 0x00FF); + } + + printf("\n\t Transparency: %s", + bittok2str(lmp_obj_service_config_cpsa_tp_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2)>>8)); + + printf("\n\t Contiguous Concatenation Types: %s", + bittok2str(lmp_obj_service_config_cpsa_cct_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)); + + printf("\n\t Minimum NCC: %u", + EXTRACT_16BITS(obj_tptr+4)); + + printf("\n\t Maximum NCC: %u", + EXTRACT_16BITS(obj_tptr+6)); + + printf("\n\t Minimum NVC:%u", + EXTRACT_16BITS(obj_tptr+8)); + + printf("\n\t Maximum NVC:%u", + EXTRACT_16BITS(obj_tptr+10)); + + printf("\n\t Local Interface ID: %s (0x%08x)", + ipaddr_string(obj_tptr+12), + EXTRACT_32BITS(obj_tptr+12)); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM: + + printf("\n\t Transparency Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_transparency_flag_values, + "none", + EXTRACT_32BITS(obj_tptr))); + + printf("\n\t TCM Monitoring Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_tcm_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+6) & 0x00FF)); + + break; + + case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY: + + printf("\n\t Diversity: Flags: %s", + bittok2str( + lmp_obj_service_config_nsa_network_diversity_flag_values, + "none", + EXTRACT_16BITS(obj_tptr+2) & 0x00FF)); + break; + + default: + hexdump = TRUE; + }; + + break; + default: if (vflag <= 1) print_unknown_data(obj_tptr,"\n\t ",obj_tlen); diff --git a/contrib/tcpdump/print-lspping.c b/contrib/tcpdump/print-lspping.c index 34e433c..a851fbe 100644 --- a/contrib/tcpdump/print-lspping.c +++ b/contrib/tcpdump/print-lspping.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.12 2004/11/11 12:02:31 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.12.2.3 2005/05/03 08:12:31 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -137,7 +137,7 @@ struct lspping_tlv_header { #define LSPPING_TLV_DOWNSTREAM_MAPPING 2 #define LSPPING_TLV_PAD 3 #define LSPPING_TLV_ERROR_CODE 4 -#define LSPPING_TLV_VENDOR_PRIVATE 5 +#define LSPPING_TLV_VENDOR_PRIVATE 0xfc00 static const struct tok lspping_tlv_values[] = { { LSPPING_TLV_TARGET_FEC_STACK, "Target FEC Stack" }, @@ -515,10 +515,11 @@ lspping_print(register const u_char *pptr, register u_int len) { tlen=len; - printf("\n\tLSP-PINGv%u, msg-type: %s (%u), reply-mode: %s (%u)", + printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)", EXTRACT_16BITS(&lspping_com_header->version[0]), tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type), lspping_com_header->msg_type, + len, tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode), lspping_com_header->reply_mode); @@ -532,13 +533,13 @@ lspping_print(register const u_char *pptr, register u_int len) { lspping_com_header->return_code == 10 || lspping_com_header->return_code == 11 || lspping_com_header->return_code == 12 ) - printf("\n\t Return Code: %s %u (%u), Return Subcode: (%u)", + printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)", tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), lspping_com_header->return_subcode, lspping_com_header->return_code, lspping_com_header->return_subcode); else - printf("\n\t Return Code: %s (%u), Return Subcode: (%u)", + printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)", tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code), lspping_com_header->return_code, lspping_com_header->return_subcode); @@ -850,7 +851,7 @@ lspping_print(register const u_char *pptr, register u_int len) { print_unknown_data(tptr+sizeof(sizeof(struct lspping_tlv_header)),"\n\t ", lspping_tlv_len); - tptr+=lspping_tlv_len; + tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header); tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header); } return; diff --git a/contrib/tcpdump/print-mobility.c b/contrib/tcpdump/print-mobility.c index a1a24a9..8f9cbee 100644 --- a/contrib/tcpdump/print-mobility.c +++ b/contrib/tcpdump/print-mobility.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.11 2003/11/16 09:36:28 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.11.2.1 2005/04/20 22:21:16 guy Exp $"; #endif #ifdef INET6 @@ -168,15 +168,13 @@ trunc: * Mobility Header */ int -mobility_print(const u_char *bp, const u_char *bp2) +mobility_print(const u_char *bp, const u_char *bp2 _U_) { const struct ip6_mobility *mh; - const struct ip6_hdr *ip6; const u_char *ep; int mhlen, hlen, type; mh = (struct ip6_mobility *)bp; - ip6 = (struct ip6_hdr *)bp2; /* 'ep' points to the end of available data. */ ep = snapend; diff --git a/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c index 3cb3504..9d54567 100644 --- a/contrib/tcpdump/print-mpls.c +++ b/contrib/tcpdump/print-mpls.c @@ -28,7 +28,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.13 2005/04/06 21:32:41 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.13.2.1 2005/07/05 09:39:29 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -61,36 +61,45 @@ void mpls_print(const u_char *bp, u_int length) { const u_char *p; - u_int32_t v; + u_int32_t label_entry; + u_int16_t label_stack_depth = 0; p = bp; printf("MPLS"); do { - TCHECK2(*p, sizeof(v)); - v = EXTRACT_32BITS(p); - printf(" ("); /*)*/ - printf("label %u", MPLS_LABEL(v)); + TCHECK2(*p, sizeof(label_entry)); + label_entry = EXTRACT_32BITS(p); + printf("%s(label %u", + label_stack_depth ? "\n\t" : " ", + MPLS_LABEL(label_entry)); + label_stack_depth++; if (vflag && - MPLS_LABEL(v) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0])) - printf(" (%s)", mpls_labelname[MPLS_LABEL(v)]); - printf(", exp %u", MPLS_EXP(v)); - if (MPLS_STACK(v)) + MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0])) + printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]); + printf(", exp %u", MPLS_EXP(label_entry)); + if (MPLS_STACK(label_entry)) printf(", [S]"); - printf(", ttl %u", MPLS_TTL(v)); - /*(*/ - printf(")"); + printf(", ttl %u)", MPLS_TTL(label_entry)); - p += sizeof(v); - } while (!MPLS_STACK(v)); + p += sizeof(label_entry); + } while (!MPLS_STACK(label_entry)); - switch (MPLS_LABEL(v)) { + switch (MPLS_LABEL(label_entry)) { case 0: /* IPv4 explicit NULL label */ case 3: /* IPv4 implicit NULL label */ - ip_print(gndo, p, length - (p - bp)); + if (vflag>0) { + printf("\n\t"); + ip_print(gndo, p, length - (p - bp)); + } + else printf(", IP, length: %u",length); break; #ifdef INET6 case 2: /* IPv6 explicit NULL label */ - ip6_print(p, length - (p - bp)); + if (vflag>0) { + printf("\n\t"); + ip6_print(p, length - (p - bp)); + } + else printf(", IPv6, length: %u",length); break; #endif default: @@ -107,7 +116,7 @@ mpls_print(const u_char *bp, u_int length) * which cisco by default sends MPLS encapsulated */ - if (MPLS_STACK(v)) { /* only do this if the stack bit is set */ + if (MPLS_STACK(label_entry)) { /* only do this if the stack bit is set */ switch(*p) { case 0x45: case 0x46: diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c index 5a217fe..9ac6c61 100644 --- a/contrib/tcpdump/print-ospf.c +++ b/contrib/tcpdump/print-ospf.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.56 2004/09/29 16:49:31 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.56.2.2 2005/05/06 07:57:19 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -873,15 +873,13 @@ trunc: void ospf_print(register const u_char *bp, register u_int length, - register const u_char *bp2) + const u_char *bp2 _U_) { register const struct ospfhdr *op; - register const struct ip *ip; register const u_char *dataend; register const char *cp; op = (struct ospfhdr *)bp; - ip = (struct ip *)bp2; /* XXX Before we do anything else, strip off the MD5 trailer */ TCHECK(op->ospf_authtype); @@ -934,8 +932,11 @@ ospf_print(register const u_char *bp, register u_int length, break; case OSPF_AUTH_SIMPLE: - (void)fn_printn(op->ospf_authdata, - sizeof(op->ospf_authdata), NULL); + if (fn_printn(op->ospf_authdata, + sizeof(op->ospf_authdata), snapend)) { + printf("\""); + goto trunc; + } printf("\""); break; diff --git a/contrib/tcpdump/print-pgm.c b/contrib/tcpdump/print-pgm.c new file mode 100644 index 0000000..edaf933 --- /dev/null +++ b/contrib/tcpdump/print-pgm.c @@ -0,0 +1,759 @@ +/* + * 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, and (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. + * 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. + * + * Original code by Andy Heffernan (ahh@juniper.net) + */ + +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.1.2.5 2005/06/07 22:06:16 guy Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <tcpdump-stdinc.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "interface.h" +#include "extract.h" +#include "addrtoname.h" + +#include "ip.h" +#ifdef INET6 +#include "ip6.h" +#endif +#include "ipproto.h" + +/* + * PGM header (RFC 3208) + */ +struct pgm_header { + u_int16_t pgm_sport; + u_int16_t pgm_dport; + u_int8_t pgm_type; + u_int8_t pgm_options; + u_int16_t pgm_sum; + u_int8_t pgm_gsid[6]; + u_int16_t pgm_length; +}; + +struct pgm_spm { + u_int32_t pgms_seq; + u_int32_t pgms_trailseq; + u_int32_t pgms_leadseq; + u_int16_t pgms_nla_afi; + u_int16_t pgms_reserved; + /* ... u_int8_t pgms_nla[0]; */ + /* ... options */ +}; + +struct pgm_nak { + u_int32_t pgmn_seq; + u_int16_t pgmn_source_afi; + u_int16_t pgmn_reserved; + /* ... u_int8_t pgmn_source[0]; */ + /* ... u_int16_t pgmn_group_afi */ + /* ... u_int16_t pgmn_reserved2; */ + /* ... u_int8_t pgmn_group[0]; */ + /* ... options */ +}; + +struct pgm_poll { + u_int32_t pgmp_seq; + u_int16_t pgmp_round; + u_int16_t pgmp_reserved; + /* ... options */ +}; + +struct pgm_polr { + u_int32_t pgmp_seq; + u_int16_t pgmp_round; + u_int16_t pgmp_subtype; + u_int16_t pgmp_nla_afi; + u_int16_t pgmp_reserved; + /* ... u_int8_t pgmp_nla[0]; */ + /* ... options */ +}; + +struct pgm_data { + u_int32_t pgmd_seq; + u_int32_t pgmd_trailseq; + /* ... options */ +}; + +typedef enum _pgm_type { + PGM_SPM = 0, /* source path message */ + PGM_POLL = 1, /* POLL Request */ + PGM_POLR = 2, /* POLL Response */ + PGM_ODATA = 4, /* original data */ + PGM_RDATA = 5, /* repair data */ + PGM_NAK = 8, /* NAK */ + PGM_NULLNAK = 9, /* Null NAK */ + PGM_NCF = 10, /* NAK Confirmation */ + PGM_ACK = 11, /* ACK for congestion control */ + PGM_SPMR = 12, /* SPM request */ + PGM_MAX = 255 +} pgm_type; + +#define PGM_OPT_BIT_PRESENT 0x01 +#define PGM_OPT_BIT_NETWORK 0x02 +#define PGM_OPT_BIT_VAR_PKTLEN 0x40 +#define PGM_OPT_BIT_PARITY 0x80 + +#define PGM_OPT_LENGTH 0x00 +#define PGM_OPT_FRAGMENT 0x01 +#define PGM_OPT_NAK_LIST 0x02 +#define PGM_OPT_JOIN 0x03 +#define PGM_OPT_NAK_BO_IVL 0x04 +#define PGM_OPT_NAK_BO_RNG 0x05 + +#define PGM_OPT_REDIRECT 0x07 +#define PGM_OPT_PARITY_PRM 0x08 +#define PGM_OPT_PARITY_GRP 0x09 +#define PGM_OPT_CURR_TGSIZE 0x0A +#define PGM_OPT_NBR_UNREACH 0x0B +#define PGM_OPT_PATH_NLA 0x0C + +#define PGM_OPT_SYN 0x0D +#define PGM_OPT_FIN 0x0E +#define PGM_OPT_RST 0x0F +#define PGM_OPT_CR 0x10 +#define PGM_OPT_CRQST 0x11 + +#define PGM_OPT_MASK 0x7f + +#define PGM_OPT_END 0x80 /* end of options marker */ + +#define PGM_MIN_OPT_LEN 4 + +#ifndef AFI_IP +#define AFI_IP 1 +#define AFI_IP6 2 +#endif + +void +pgm_print(register const u_char *bp, register u_int length, + register const u_char *bp2) +{ + register const struct pgm_header *pgm; + register const struct ip *ip; + register char ch; + u_int16_t sport, dport; + int addr_size; + const void *nla; + int nla_af; +#ifdef INET6 + char nla_buf[INET6_ADDRSTRLEN]; + register const struct ip6_hdr *ip6; +#else + char nla_buf[INET_ADDRSTRLEN]; +#endif + u_int8_t opt_type, opt_len, flags1, flags2; + u_int32_t seq, opts_len, len, offset; + + pgm = (struct pgm_header *)bp; + ip = (struct ip *)bp2; +#ifdef INET6 + if (IP_V(ip) == 6) + ip6 = (struct ip6_hdr *)bp2; + else + ip6 = NULL; +#else /* INET6 */ + if (IP_V(ip) == 6) { + (void)printf("Can't handle IPv6"); + return; + } +#endif /* INET6 */ + ch = '\0'; + if (!TTEST(pgm->pgm_dport)) { +#ifdef INET6 + if (ip6) { + (void)printf("%s > %s: [|pgm]", + ip6addr_string(&ip6->ip6_src), + ip6addr_string(&ip6->ip6_dst)); + return; + } else +#endif /* INET6 */ + { + (void)printf("%s > %s: [|pgm]", + ipaddr_string(&ip->ip_src), + ipaddr_string(&ip->ip_dst)); + return; + } + } + + sport = EXTRACT_16BITS(&pgm->pgm_sport); + dport = EXTRACT_16BITS(&pgm->pgm_dport); + +#ifdef INET6 + if (ip6) { + if (ip6->ip6_nxt == IPPROTO_PGM) { + (void)printf("%s.%s > %s.%s: ", + ip6addr_string(&ip6->ip6_src), + tcpport_string(sport), + ip6addr_string(&ip6->ip6_dst), + tcpport_string(dport)); + } else { + (void)printf("%s > %s: ", + tcpport_string(sport), tcpport_string(dport)); + } + } else +#endif /*INET6*/ + { + if (ip->ip_p == IPPROTO_PGM) { + (void)printf("%s.%s > %s.%s: ", + ipaddr_string(&ip->ip_src), + tcpport_string(sport), + ipaddr_string(&ip->ip_dst), + tcpport_string(dport)); + } else { + (void)printf("%s > %s: ", + tcpport_string(sport), tcpport_string(dport)); + } + } + + TCHECK(*pgm); + + (void)printf("PGM, length %u", pgm->pgm_length); + + if (!vflag) + return; + + if (length > pgm->pgm_length) + length = pgm->pgm_length; + + (void)printf(" 0x%02x%02x%02x%02x%02x%02x ", + pgm->pgm_gsid[0], + pgm->pgm_gsid[1], + pgm->pgm_gsid[2], + pgm->pgm_gsid[3], + pgm->pgm_gsid[4], + pgm->pgm_gsid[5]); + switch (pgm->pgm_type) { + case PGM_SPM: { + struct pgm_spm *spm; + + spm = (struct pgm_spm *)(pgm + 1); + TCHECK(*spm); + + switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) { + case AFI_IP: + addr_size = sizeof(struct in_addr); + nla_af = AF_INET; + break; +#ifdef INET6 + case AFI_IP6: + addr_size = sizeof(struct in6_addr); + nla_af = AF_INET6; + break; +#endif + default: + goto trunc; + break; + } + bp = (u_char *) (spm + 1); + TCHECK2(*bp, addr_size); + nla = bp; + bp += addr_size; + + inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf)); + (void)printf("SPM seq %u trail %u lead %u nla %s", + EXTRACT_32BITS(&spm->pgms_seq), + EXTRACT_32BITS(&spm->pgms_trailseq), + EXTRACT_32BITS(&spm->pgms_leadseq), + nla_buf); + break; + } + + case PGM_POLL: { + struct pgm_poll *poll; + + poll = (struct pgm_poll *)(pgm + 1); + TCHECK(*poll); + (void)printf("POLL seq %u round %u", + EXTRACT_32BITS(&poll->pgmp_seq), + EXTRACT_16BITS(&poll->pgmp_round)); + bp = (u_char *) (poll + 1); + break; + } + case PGM_POLR: { + struct pgm_polr *polr; + u_int32_t ivl, rnd, mask; + + polr = (struct pgm_polr *)(pgm + 1); + TCHECK(*polr); + + switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) { + case AFI_IP: + addr_size = sizeof(struct in_addr); + nla_af = AF_INET; + break; +#ifdef INET6 + case AFI_IP6: + addr_size = sizeof(struct in6_addr); + nla_af = AF_INET6; + break; +#endif + default: + goto trunc; + break; + } + bp = (u_char *) (polr + 1); + TCHECK2(*bp, addr_size); + nla = bp; + bp += addr_size; + + inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf)); + + TCHECK2(*bp, sizeof(u_int32_t)); + ivl = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + + TCHECK2(*bp, sizeof(u_int32_t)); + rnd = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + + TCHECK2(*bp, sizeof(u_int32_t)); + mask = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + + (void)printf("POLR seq %u round %u nla %s ivl %u rnd 0x%08x " + "mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq), + EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask); + break; + } + case PGM_ODATA: { + struct pgm_data *odata; + + odata = (struct pgm_data *)(pgm + 1); + TCHECK(*odata); + (void)printf("ODATA trail %u seq %u", + EXTRACT_32BITS(&odata->pgmd_trailseq), + EXTRACT_32BITS(&odata->pgmd_seq)); + bp = (u_char *) (odata + 1); + break; + } + + case PGM_RDATA: { + struct pgm_data *rdata; + + rdata = (struct pgm_data *)(pgm + 1); + TCHECK(*rdata); + (void)printf("RDATA trail %u seq %u", + EXTRACT_32BITS(&rdata->pgmd_trailseq), + EXTRACT_32BITS(&rdata->pgmd_seq)); + bp = (u_char *) (rdata + 1); + break; + } + + case PGM_NAK: + case PGM_NULLNAK: + case PGM_NCF: { + struct pgm_nak *nak; + const void *source, *group; + int source_af, group_af; +#ifdef INET6 + char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN]; +#else + char source_buf[INET_ADDRSTRLEN], group_buf[INET_ADDRSTRLEN]; +#endif + + nak = (struct pgm_nak *)(pgm + 1); + TCHECK(*nak); + + /* + * Skip past the source, saving info along the way + * and stopping if we don't have enough. + */ + switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) { + case AFI_IP: + addr_size = sizeof(struct in_addr); + source_af = AF_INET; + break; +#ifdef INET6 + case AFI_IP6: + addr_size = sizeof(struct in6_addr); + source_af = AF_INET6; + break; +#endif + default: + goto trunc; + break; + } + bp = (u_char *) (nak + 1); + TCHECK2(*bp, addr_size); + source = bp; + bp += addr_size; + + /* + * Skip past the group, saving info along the way + * and stopping if we don't have enough. + */ + switch (EXTRACT_16BITS(bp)) { + case AFI_IP: + addr_size = sizeof(struct in_addr); + group_af = AF_INET; + break; +#ifdef INET6 + case AFI_IP6: + addr_size = sizeof(struct in6_addr); + group_af = AF_INET6; + break; +#endif + default: + goto trunc; + break; + } + bp += (2 * sizeof(u_int16_t)); + TCHECK2(*bp, addr_size); + group = bp; + bp += addr_size; + + /* + * Options decoding can go here. + */ + inet_ntop(source_af, source, source_buf, sizeof(source_buf)); + inet_ntop(group_af, group, group_buf, sizeof(group_buf)); + switch (pgm->pgm_type) { + case PGM_NAK: + (void)printf("NAK "); + break; + case PGM_NULLNAK: + (void)printf("NNAK "); + break; + case PGM_NCF: + (void)printf("NCF "); + break; + default: + break; + } + (void)printf("(%s -> %s), seq %u", + source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq)); + break; + } + + case PGM_SPMR: + (void)printf("SPMR"); + break; + + default: + (void)printf("UNKNOWN type %0x02x", pgm->pgm_type); + break; + + } + if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) { + + /* + * make sure there's enough for the first option header + */ + if (!TTEST2(*bp, PGM_MIN_OPT_LEN)) { + (void)printf("[|OPT]"); + return; + } + + /* + * That option header MUST be an OPT_LENGTH option + * (see the first paragraph of section 9.1 in RFC 3208). + */ + opt_type = *bp++; + if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) { + (void)printf("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK); + return; + } + opt_len = *bp++; + if (opt_len != 4) { + (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len); + return; + } + opts_len = EXTRACT_16BITS(bp); + if (opts_len < 4) { + (void)printf("[Bad total option length %u < 4]", opts_len); + return; + } + bp += sizeof(u_int16_t); + (void)printf(" OPTS LEN %d", opts_len); + opts_len -= 4; + + while (opts_len) { + if (opts_len < PGM_MIN_OPT_LEN) { + (void)printf("[Total option length leaves no room for final option]"); + return; + } + opt_type = *bp++; + opt_len = *bp++; + if (opt_len < PGM_MIN_OPT_LEN) { + (void)printf("[Bad option, length %u < %u]", opt_len, + PGM_MIN_OPT_LEN); + break; + } + if (opts_len < opt_len) { + (void)printf("[Total option length leaves no room for final option]"); + return; + } + if (!TTEST2(*bp, opt_len - 2)) { + (void)printf(" [|OPT]"); + return; + } + + switch (opt_type & PGM_OPT_MASK) { + case PGM_OPT_LENGTH: + if (opt_len != 4) { + (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len); + return; + } + (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)); + bp += sizeof(u_int16_t); + opts_len -= 4; + break; + + case PGM_OPT_FRAGMENT: + if (opt_len != 16) { + (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + seq = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + offset = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + len = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" FRAG seq %u off %u len %u", seq, offset, len); + opts_len -= 16; + break; + + case PGM_OPT_NAK_LIST: + flags1 = *bp++; + flags2 = *bp++; + opt_len -= sizeof(u_int32_t); /* option header */ + (void)printf(" NAK LIST"); + while (opt_len) { + if (opt_len < sizeof(u_int32_t)) { + (void)printf("[Option length not a multiple of 4]"); + return; + } + TCHECK2(*bp, sizeof(u_int32_t)); + (void)printf(" %u", EXTRACT_32BITS(bp)); + bp += sizeof(u_int32_t); + opt_len -= sizeof(u_int32_t); + opts_len -= sizeof(u_int32_t); + } + break; + + case PGM_OPT_JOIN: + if (opt_len != 8) { + (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + seq = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" JOIN %u", seq); + opts_len -= 8; + break; + + case PGM_OPT_NAK_BO_IVL: + if (opt_len != 12) { + (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + offset = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + seq = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq); + opts_len -= 12; + break; + + case PGM_OPT_NAK_BO_RNG: + if (opt_len != 12) { + (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + offset = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + seq = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" BACKOFF max %u min %u", offset, seq); + opts_len -= 12; + break; + + case PGM_OPT_REDIRECT: + flags1 = *bp++; + flags2 = *bp++; + switch (EXTRACT_16BITS(bp)) { + case AFI_IP: + addr_size = sizeof(struct in_addr); + nla_af = AF_INET; + break; +#ifdef INET6 + case AFI_IP6: + addr_size = sizeof(struct in6_addr); + nla_af = AF_INET6; + break; +#endif + default: + goto trunc; + break; + } + bp += (2 * sizeof(u_int16_t)); + if (opt_len != 4 + addr_size) { + (void)printf("[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len); + return; + } + TCHECK2(*bp, addr_size); + nla = bp; + bp += addr_size; + + inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf)); + (void)printf(" REDIRECT %s", (char *)nla); + opts_len -= 4 + addr_size; + break; + + case PGM_OPT_PARITY_PRM: + if (opt_len != 8) { + (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + len = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" PARITY MAXTGS %u", len); + opts_len -= 8; + break; + + case PGM_OPT_PARITY_GRP: + if (opt_len != 8) { + (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + seq = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" PARITY GROUP %u", seq); + opts_len -= 8; + break; + + case PGM_OPT_CURR_TGSIZE: + if (opt_len != 8) { + (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + len = EXTRACT_32BITS(bp); + bp += sizeof(u_int32_t); + (void)printf(" PARITY ATGS %u", len); + opts_len -= 8; + break; + + case PGM_OPT_NBR_UNREACH: + if (opt_len != 4) { + (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + (void)printf(" NBR_UNREACH"); + opts_len -= 4; + break; + + case PGM_OPT_PATH_NLA: + (void)printf(" PATH_NLA [%d]", opt_len); + bp += opt_len; + opts_len -= opt_len; + break; + + case PGM_OPT_SYN: + if (opt_len != 4) { + (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + (void)printf(" SYN"); + opts_len -= 4; + break; + + case PGM_OPT_FIN: + if (opt_len != 4) { + (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + (void)printf(" FIN"); + opts_len -= 4; + break; + + case PGM_OPT_RST: + if (opt_len != 4) { + (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + (void)printf(" RST"); + opts_len -= 4; + break; + + case PGM_OPT_CR: + (void)printf(" CR"); + bp += opt_len; + opts_len -= opt_len; + break; + + case PGM_OPT_CRQST: + if (opt_len != 4) { + (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len); + return; + } + flags1 = *bp++; + flags2 = *bp++; + (void)printf(" CRQST"); + opts_len -= 4; + break; + + default: + (void)printf(" OPT_%02X [%d] ", opt_type, opt_len); + bp += opt_len; + opts_len -= opt_len; + break; + } + + if (opt_type & PGM_OPT_END) + break; + } + } + + (void)printf(" [%u]", EXTRACT_16BITS(&pgm->pgm_length)); + + return; + +trunc: + fputs("[|pgm]", stdout); + if (ch != '\0') + putchar('>'); +} diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c index 8835e1e..229b5ee 100644 --- a/contrib/tcpdump/print-pppoe.c +++ b/contrib/tcpdump/print-pppoe.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = -"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.30 2004/08/27 03:57:41 guy Exp $ (LBL)"; +"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.30.2.1 2005/04/26 19:48:56 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -138,21 +138,6 @@ pppoe_print(register const u_char *bp, u_int length) printf(" [ses 0x%x]", pppoe_sessionid); } - if (pppoe_length < length && length + ETHER_HDRLEN > 60) { - /* (small packets are probably just padded up to the ethernet - minimum of 60 bytes of data + 4 bytes of CRC) */ - printf(" [length %u (%u extra bytes)]", - pppoe_length, length - pppoe_length); -#if RESPECT_PAYLOAD_LENGTH - if (snaplend > pppoe_payload+pppoe_length) - snapend = pppoe_payload+pppoe_length; -#else - /* Actual PPPoE implementations appear to ignore the payload - length and use the full ethernet frame anyways */ - pppoe_length = length; -#endif - } - if (pppoe_code) { /* PPP session packets don't contain tags */ u_short tag_type = 0xffff, tag_len; diff --git a/contrib/tcpdump/print-rsvp.c b/contrib/tcpdump/print-rsvp.c index 58da545..b3324b4 100644 --- a/contrib/tcpdump/print-rsvp.c +++ b/contrib/tcpdump/print-rsvp.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33 2005/01/13 07:08:54 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.33.2.3 2005/06/16 00:50:12 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -548,7 +548,7 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) { } bw; u_int8_t namelen; - while(tlen>0) { + while(tlen>=sizeof(struct rsvp_object_header)) { /* did we capture enough for fully decoding the object header ? */ if (!TTEST2(*tptr, sizeof(struct rsvp_object_header))) goto trunc; @@ -557,7 +557,11 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) { rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); rsvp_obj_ctype=rsvp_obj_header->ctype; - if(rsvp_obj_len % 4 || rsvp_obj_len < sizeof(struct rsvp_object_header)) { + if(rsvp_obj_len % 4) { + printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len); + return -1; + } + if(rsvp_obj_len < sizeof(struct rsvp_object_header)) { printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len, (unsigned long)sizeof(const struct rsvp_object_header)); return -1; @@ -582,6 +586,11 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) { rsvp_obj_ctype, rsvp_obj_len); + if(tlen < rsvp_obj_len) { + printf("%sERROR: object goes past end of objects TLV", ident); + return -1; + } + obj_tptr=tptr+sizeof(struct rsvp_object_header); obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header); @@ -1268,6 +1277,8 @@ rsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) { *(obj_tptr+1)); if (obj_tlen < *(obj_tptr+1)) return-1; + if (*(obj_tptr+1) < 2) + return -1; print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2); obj_tlen-=*(obj_tptr+1); obj_tptr+=*(obj_tptr+1); @@ -1422,6 +1433,12 @@ rsvp_print(register const u_char *pptr, register u_int len) { return; } + if (tlen < subtlen) { + printf("ERROR: common header too large %u > %u", subtlen, + tlen); + return; + } + subtptr+=sizeof(const struct rsvp_common_header); subtlen-=sizeof(const struct rsvp_common_header); diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c index 95de311..39e22ae 100644 --- a/contrib/tcpdump/print-rt6.c +++ b/contrib/tcpdump/print-rt6.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.26 2003/11/19 00:36:08 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.26.2.1 2005/04/20 22:35:11 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -41,17 +41,15 @@ static const char rcsid[] _U_ = #include "extract.h" int -rt6_print(register const u_char *bp, register const u_char *bp2) +rt6_print(register const u_char *bp, const u_char *bp2 _U_) { register const struct ip6_rthdr *dp; register const struct ip6_rthdr0 *dp0; - register const struct ip6_hdr *ip; register const u_char *ep; int i, len; register const struct in6_addr *addr; dp = (struct ip6_rthdr *)bp; - ip = (struct ip6_hdr *)bp2; len = dp->ip6r_len; /* 'ep' points to the end of available data. */ diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c index b0e0036..cd9e8cd 100644 --- a/contrib/tcpdump/print-sctp.c +++ b/contrib/tcpdump/print-sctp.c @@ -35,7 +35,7 @@ #ifndef lint static const char rcsid[] _U_ = -"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.16 2004/12/15 08:43:23 guy Exp $ (NETLAB/PEL)"; +"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.16.2.3 2005/05/06 10:53:20 guy Exp $ (NETLAB/PEL)"; #endif #ifdef HAVE_CONFIG_H @@ -68,7 +68,6 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ #ifdef INET6 const struct ip6_hdr *ip6; #endif - const u_char *cp; const void *endPacketPtr; u_short sourcePort, destPort; int chunkCount; @@ -88,12 +87,7 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ else ip6 = NULL; #endif /*INET6*/ - cp = (const u_char *)(sctpPktHdr + 1); - if (cp > snapend) - { - printf("[|sctp]"); - return; - } + TCHECK(*sctpPktHdr); if (sctpPacketLength < sizeof(struct sctpHeader)) { @@ -141,12 +135,21 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++) { - u_short align; + u_int16_t chunkLength; const u_char *chunkEnd; + u_int16_t align; - chunkEnd = ((const u_char*)chunkDescPtr + EXTRACT_16BITS(&chunkDescPtr->chunkLength)); + TCHECK(*chunkDescPtr); + chunkLength = EXTRACT_16BITS(&chunkDescPtr->chunkLength); + if (chunkLength < sizeof(*chunkDescPtr)) { + printf("%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength); + break; + } - align=EXTRACT_16BITS(&chunkDescPtr->chunkLength) % 4; + TCHECK2(*((u_int8_t *)chunkDescPtr), chunkLength); + chunkEnd = ((const u_char*)chunkDescPtr + chunkLength); + + align=chunkLength % 4; if (align != 0) align = 4 - align; @@ -259,7 +262,7 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ const struct sctpSelectiveAck *sack; const struct sctpSelectiveFrag *frag; int fragNo, tsnNo; - const u_long *dupTSN; + const u_char *dupTSN; printf("[SACK] "); sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1); @@ -282,9 +285,9 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ /* print duplicate TSNs */ - for (dupTSN = (const u_long*)frag, tsnNo=0; + for (dupTSN = (const u_char *)frag, tsnNo=0; (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns); - dupTSN++, tsnNo++) + dupTSN += 4, tsnNo++) printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1, EXTRACT_32BITS(dupTSN)); @@ -347,4 +350,9 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */ if (vflag < 2) sep = ", ("; } + return; + +trunc: + printf("[|sctp]"); + return; } diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c index aeb0610..6ac51e1 100644 --- a/contrib/tcpdump/print-sll.c +++ b/contrib/tcpdump/print-sll.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16 2004/10/28 00:34:29 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16.2.1 2005/04/26 00:16:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -53,6 +53,8 @@ const struct tok sll_pkttype_values[] = { static inline void sll_print(register const struct sll_header *sllp, u_int length) { + u_short ether_type; + printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype))); /* @@ -63,11 +65,44 @@ sll_print(register const struct sll_header *sllp, u_int length) if (EXTRACT_16BITS(&sllp->sll_halen) == 6) (void)printf("%s ", etheraddr_string(sllp->sll_addr)); - if (!qflag) - (void)printf("ethertype %s (0x%04x), length %u: ", - tok2str(ethertype_values,"Unknown", EXTRACT_16BITS(&sllp->sll_protocol)), - EXTRACT_16BITS(&sllp->sll_protocol), - length); + if (!qflag) { + ether_type = EXTRACT_16BITS(&sllp->sll_protocol); + + if (ether_type <= ETHERMTU) { + /* + * Not an Ethernet type; what type is it? + */ + switch (ether_type) { + + case LINUX_SLL_P_802_3: + /* + * Ethernet_802.3 IPX frame. + */ + (void)printf("802.3"); + break; + + case LINUX_SLL_P_802_2: + /* + * 802.2. + */ + (void)printf("802.3"); + break; + + default: + /* + * What is it? + */ + (void)printf("ethertype Unknown (0x%04x)", + ether_type); + break; + } + } else { + (void)printf("ethertype %s (0x%04x)", + tok2str(ethertype_values, "Unknown", ether_type), + ether_type); + } + (void)printf(", length %u: ", length); + } } /* diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c index fe1b439..3c8cfbf 100644 --- a/contrib/tcpdump/print-smb.c +++ b/contrib/tcpdump/print-smb.c @@ -12,7 +12,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41 2004/12/30 03:36:51 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.41.2.2 2005/05/08 20:01:09 guy Exp $"; #endif #include <tcpdump-stdinc.h> @@ -925,17 +925,25 @@ trunc: void nbt_tcp_print(const u_char *data, int length) { - const u_char *maxbuf = data + length; + int caplen; int type; u_int nbt_len; + const u_char *maxbuf; - TCHECK2(data[2], 2); + if (length < 4) + goto trunc; + if (snapend < data) + goto trunc; + caplen = snapend - data; + if (caplen < 4) + goto trunc; + maxbuf = data + caplen; type = data[0]; nbt_len = EXTRACT_16BITS(data + 2); + length -= 4; + caplen -= 4; startbuf = data; - if (maxbuf <= data) - return; if (vflag < 2) { printf(" NBT Session Packet: "); @@ -956,7 +964,12 @@ nbt_tcp_print(const u_char *data, int length) { int ecode; - TCHECK(data[4]); + if (nbt_len < 4) + goto trunc; + if (length < 4) + goto trunc; + if (caplen < 4) + goto trunc; ecode = data[4]; printf("Session Reject, "); @@ -996,13 +1009,17 @@ nbt_tcp_print(const u_char *data, int length) data + 4, 0); if (data == NULL) break; - if (memcmp(data,"\377SMB",4) == 0) { - if (nbt_len > PTR_DIFF(maxbuf, data)) - printf("WARNING: Short packet. Try increasing the snap length (%lu)\n", - (unsigned long)PTR_DIFF(maxbuf, data)); + if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) { + if ((int)nbt_len > caplen) { + if ((int)nbt_len > length) + printf("WARNING: Packet is continued in later TCP segments\n"); + else + printf("WARNING: Short packet. Try increasing the snap length by %d\n", + nbt_len - caplen); + } print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf); } else - printf("Session packet:(raw data?)\n"); + printf("Session packet:(raw data or continuation?)\n"); break; case 0x81: @@ -1017,29 +1034,33 @@ nbt_tcp_print(const u_char *data, int length) case 0x83: { + const u_char *origdata; int ecode; - TCHECK(data[4]); - ecode = data[4]; - + origdata = data; data = smb_fdata(data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n", maxbuf, 0); - switch (ecode) { - case 0x80: - printf("Not listening on called name\n"); - break; - case 0x81: - printf("Not listening for calling name\n"); - break; - case 0x82: - printf("Called name not present\n"); - break; - case 0x83: - printf("Called name present, but insufficient resources\n"); - break; - default: - printf("Unspecified error 0x%X\n", ecode); + if (data == NULL) break; + if (nbt_len >= 1 && caplen >= 1) { + ecode = origdata[4]; + switch (ecode) { + case 0x80: + printf("Not listening on called name\n"); + break; + case 0x81: + printf("Not listening for calling name\n"); + break; + case 0x82: + printf("Called name not present\n"); + break; + case 0x83: + printf("Called name present, but insufficient resources\n"); + break; + default: + printf("Unspecified error 0x%X\n", ecode); + break; + } } } break; @@ -1141,12 +1162,13 @@ nbt_udp137_print(const u_char *data, int length) if (qdcount) { printf("QuestionRecords:\n"); - for (i = 0; i < qdcount; i++) + for (i = 0; i < qdcount; i++) { p = smb_fdata(p, "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#", maxbuf, 0); - if (p == NULL) - goto out; + if (p == NULL) + goto out; + } } if (total) { @@ -1180,6 +1202,8 @@ nbt_udp137_print(const u_char *data, int length) goto out; while (numnames--) { p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0); + if (p == NULL) + goto out; TCHECK(*p); if (p[0] & 0x80) printf("<GROUP> "); diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c index 4758ac2..0686b62 100644 --- a/contrib/tcpdump/print-snmp.c +++ b/contrib/tcpdump/print-snmp.c @@ -58,7 +58,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.62 2005/01/05 04:05:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.62.2.2 2005/05/06 07:57:19 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -786,7 +786,10 @@ asn1_print(struct be *elem) p = elem->data.str; if (printable) { putchar('"'); - (void)fn_print(p, p + asnlen); + if (fn_printn(p, asnlen, snapend)) { + putchar('"'); + goto trunc; + } putchar('"'); } else for (i = asnlen; i-- > 0; p++) { @@ -1320,13 +1323,13 @@ snmppdu_print(u_short pduid, const u_char *np, u_int length) if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ || pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT) && elem.data.integer != 0) { - char errbuf[10]; + char errbuf[20]; printf("[errorStatus(%s)!=0]", DECODE_ErrorStatus(elem.data.integer)); } else if (pduid == GETBULKREQ) { printf(" N=%d", elem.data.integer); } else if (elem.data.integer != 0) { - char errbuf[10]; + char errbuf[20]; printf(" %s", DECODE_ErrorStatus(elem.data.integer)); error = elem.data.integer; } @@ -1415,7 +1418,7 @@ trappdu_print(const u_char *np, u_int length) } generic = elem.data.integer; { - char buf[10]; + char buf[20]; printf(" %s", DECODE_GenericTrap(generic)); } length -= count; diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c index a13f24e..3f631d2 100644 --- a/contrib/tcpdump/print-stp.c +++ b/contrib/tcpdump/print-stp.c @@ -11,7 +11,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13 2003/11/16 09:36:38 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.13.2.1 2005/04/26 07:27:17 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -39,23 +39,23 @@ static void stp_print_config_bpdu(const u_char *p) { printf("config "); - if (p[7] & 1) + if (p[4] & 1) printf("TOP_CHANGE "); - if (p[7] & 0x80) + if (p[4] & 0x80) printf("TOP_CHANGE_ACK "); - stp_print_bridge_id(p+20); - printf(".%.2x%.2x ", p[28], p[29]); + stp_print_bridge_id(p+17); + printf(".%.2x%.2x ", p[25], p[26]); printf("root "); - stp_print_bridge_id(p+8); + stp_print_bridge_id(p+5); - printf(" pathcost %i ", (p[16] << 24) | (p[17] << 16) | (p[18] << 8) | p[19]); + printf(" pathcost %i ", (p[13] << 24) | (p[14] << 16) | (p[15] << 8) | p[16]); - printf("age %i ", p[30]); - printf("max %i ", p[32]); - printf("hello %i ", p[34]); - printf("fdelay %i ", p[36]); + printf("age %i ", p[27]); + printf("max %i ", p[29]); + printf("hello %i ", p[31]); + printf("fdelay %i ", p[33]); } static void @@ -70,16 +70,16 @@ stp_print_tcn_bpdu(void) void stp_print(const u_char *p, u_int length) { - if (length < 7) + if (length < 4) goto trunc; printf("802.1d "); - if (p[2] != 0x03 || p[3] || p[4] || p[5]) { + if (p[0] || p[1] || p[2]) { printf("unknown version"); return; } - switch (p[6]) + switch (p[3]) { case 0x00: if (length < 10) @@ -92,7 +92,7 @@ stp_print(const u_char *p, u_int length) break; default: - printf("unknown type %i", p[6]); + printf("unknown type %i", p[3]); break; } diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c index e51f4e9..ab736a0 100644 --- a/contrib/tcpdump/print-tcp.c +++ b/contrib/tcpdump/print-tcp.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.120 2005/04/06 18:53:56 mcr Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.120.2.2 2005/04/21 06:36:05 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -520,14 +520,13 @@ tcp_print(register const u_char *bp, register u_int length, break; case TCPOPT_SACK: - (void)printf("sack"); datalen = len - 2; if (datalen % 8 != 0) { - (void)printf(" malformed sack "); + (void)printf("malformed sack"); } else { u_int32_t s, e; - (void)printf(" sack %d ", datalen / 8); + (void)printf("sack %d ", datalen / 8); for (i = 0; i < datalen; i += 8) { LENCHECK(i + 4); s = EXTRACT_32BITS(cp + i); @@ -542,7 +541,6 @@ tcp_print(register const u_char *bp, register u_int length, } (void)printf("{%u:%u}", s, e); } - (void)printf(" "); } break; @@ -738,7 +736,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp, const u_char *data, int length, const u_char *rcvsig) { struct tcphdr tp1; - char sig[TCP_SIGLEN]; + u_char sig[TCP_SIGLEN]; char zero_proto = 0; MD5_CTX ctx; u_int16_t savecsum, tlen; diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c index f575e4a..1e87a50 100644 --- a/contrib/tcpdump/print-vrrp.c +++ b/contrib/tcpdump/print-vrrp.c @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.9 2003/11/16 09:36:41 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.9.2.1 2005/05/06 07:57:20 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -128,7 +128,10 @@ vrrp_print(register const u_char *bp, register u_int len, int ttl) if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */ TCHECK(bp[7]); printf(" auth \""); - fn_printn(bp, 8, NULL); + if (fn_printn(bp, 8, snapend)) { + printf("\""); + goto trunc; + } printf("\""); } } diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c index f50e8c9..698faa2 100644 --- a/contrib/tcpdump/print-zephyr.c +++ b/contrib/tcpdump/print-zephyr.c @@ -1,6 +1,8 @@ /* * Decode and print Zephyr packets. * + * http://web.mit.edu/zephyr/doc/protocol + * * Copyright (c) 2001 Nickolai Zeldovich <kolya@MIT.EDU> * All rights reserved. * @@ -20,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.8 2003/11/16 09:36:42 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.8.2.1 2005/04/21 06:51:24 guy Exp $"; #endif #ifdef HAVE_CONFIG_H diff --git a/contrib/tcpdump/rpc_auth.h b/contrib/tcpdump/rpc_auth.h index c72b603..2b8ddc1 100644 --- a/contrib/tcpdump/rpc_auth.h +++ b/contrib/tcpdump/rpc_auth.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.1 2004/12/27 00:41:32 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.1.2.1 2005/04/27 21:44:07 guy Exp $ (LBL) */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -42,9 +42,6 @@ * "sessions". */ -#ifndef __RPC_AUTH_H_ -#define __RPC_AUTH_H_ - /* * Status returned from authentication check */ @@ -80,5 +77,3 @@ struct sunrpc_opaque_auth { #define SUNRPC_AUTH_SYS 1 /* forward compatibility */ #define SUNRPC_AUTH_SHORT 2 /* short hand unix style */ #define SUNRPC_AUTH_DES 3 /* des style (encrypted timestamps) */ - -#endif /* !__RPC_AUTH_H_ */ diff --git a/contrib/tcpdump/rpc_msg.h b/contrib/tcpdump/rpc_msg.h index ed281ce..01185de 100644 --- a/contrib/tcpdump/rpc_msg.h +++ b/contrib/tcpdump/rpc_msg.h @@ -1,4 +1,4 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.1 2004/12/27 00:41:32 guy Exp $ (LBL) */ +/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.1.2.1 2005/04/27 21:44:07 guy Exp $ (LBL) */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -39,9 +39,6 @@ * Copyright (C) 1984, Sun Microsystems, Inc. */ -#ifndef __RPC_MSG_H_ -#define __RPC_MSG_H_ - #define SUNRPC_MSG_VERSION ((u_int32_t) 2) /* @@ -129,5 +126,3 @@ struct sunrpc_msg { }; #define acpted_rply ru.RM_rmb.ru.RP_ar #define rjcted_rply ru.RM_rmb.ru.RP_dr - -#endif /* !__RPC_MSG_H_ */ diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c index b7875f5..b3d4b5f 100644 --- a/contrib/tcpdump/smbutil.c +++ b/contrib/tcpdump/smbutil.c @@ -12,7 +12,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36 2005/01/29 10:37:02 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.36.2.1 2005/04/21 04:09:58 guy Exp $"; #endif #include <tcpdump-stdinc.h> @@ -428,7 +428,6 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf, { int reverse = 0; const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; - int len; while (*fmt && buf<maxbuf) { switch (*fmt) { @@ -608,6 +607,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf, { /*XXX unistr() */ const char *s; + u_int32_t len; + len = 0; s = unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr); if (s == NULL) @@ -621,6 +622,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf, case 'Y': /* like 'Z', but always ASCII */ { const char *s; + u_int32_t len; + TCHECK(*buf); if (*buf != 4 && *buf != 2) { printf("Error! ASCIIZ buffer of type %u", *buf); diff --git a/contrib/tcpdump/util.c b/contrib/tcpdump/util.c index f342506..c078f0b 100644 --- a/contrib/tcpdump/util.c +++ b/contrib/tcpdump/util.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95 2005/03/21 11:35:55 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95.2.5 2005/06/16 01:19:57 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -45,7 +45,7 @@ static const char rcsid[] _U_ = #include "interface.h" /* - * Print out a filename (or other ascii string). + * Print out a null-terminated filename (or other ascii string). * If ep is NULL, assume no truncation check is needed. * Return true if truncated. */ @@ -105,6 +105,40 @@ fn_printn(register const u_char *s, register u_int n, } /* + * Print out a null-padded filename (or other ascii string). + * If ep is NULL, assume no truncation check is needed. + * Return true if truncated. + */ +int +fn_printzp(register const u_char *s, register u_int n, + register const u_char *ep) +{ + register int ret; + register u_char c; + + ret = 1; /* assume truncated */ + while (n > 0 && (ep == NULL || s < ep)) { + n--; + c = *s++; + if (c == '\0') { + ret = 0; + break; + } + if (!isascii(c)) { + c = toascii(c); + putchar('M'); + putchar('-'); + } + if (!isprint(c)) { + c ^= 0x40; /* DEL to ?, others to alpha */ + putchar('^'); + } + putchar(c); + } + return (n == 0) ? 0 : ret; +} + +/* * Print the timestamp */ void @@ -208,6 +242,18 @@ relts_print(int secs) int print_unknown_data(const u_char *cp,const char *ident,int len) { + if (len < 0) { + printf("%sDissector error: print_unknown_data called with negative length", + ident); + return(0); + } + if (snapend - cp < len) + len = snapend - cp; + if (len < 0) { + printf("%sDissector error: print_unknown_data called with pointer past end of packet", + ident); + return(0); + } hex_print(ident,cp,len); return(1); /* everything is ok */ } @@ -219,10 +265,12 @@ const char * tok2strbuf(register const struct tok *lp, register const char *fmt, register int v, char *buf, size_t bufsize) { - while (lp->s != NULL && lp != NULL) { - if (lp->v == v) - return (lp->s); - ++lp; + if (lp != NULL) { + while (lp->s != NULL) { + if (lp->v == v) + return (lp->s); + ++lp; + } } if (fmt == NULL) fmt = "#%d"; |