Index: vendor/tcpdump/dist/configure.in =================================================================== --- vendor/tcpdump/dist/configure.in (revision 353143) +++ vendor/tcpdump/dist/configure.in (nonexistent) @@ -1,1017 +0,0 @@ -dnl Copyright (c) 1994, 1995, 1996, 1997 -dnl The Regents of the University of California. All rights reserved. -dnl -dnl Process this file with autoconf to produce a configure script. -dnl - -# -# See -# -# http://ftp.gnu.org/gnu/config/README -# -# for the URLs to use to fetch new versions of config.guess and -# config.sub. -# - -AC_PREREQ(2.61) -AC_INIT(tcpdump.c) - -AC_CANONICAL_HOST - -AC_LBL_C_INIT_BEFORE_CC(V_INCLS) -AC_PROG_CC -AC_LBL_C_INIT(V_CCOPT, V_INCLS) -AC_LBL_C_INLINE -AC_C___ATTRIBUTE__ -if test "$ac_cv___attribute__" = "yes"; then - AC_C___ATTRIBUTE___UNUSED - AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER - AC_C___ATTRIBUTE___FORMAT - if test "$ac_cv___attribute___format" = "yes"; then - AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER - fi -fi - -AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h) -AC_CHECK_HEADERS(net/pfvar.h, , , [#include -#include -#include ]) -if test "$ac_cv_header_net_pfvar_h" = yes; then - AC_CHECK_HEADERS(net/if_pflog.h, , , [#include - #include - #include - #include ]) - if test "$ac_cv_header_net_if_pflog_h" = yes; then - LOCALSRC="print-pflog.c $LOCALSRC" - fi -fi -AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include -#include ]) -if test "$ac_cv_header_netinet_if_ether_h" != yes; then - # - # The simple test didn't work. - # Do we need to include first? - # Unset ac_cv_header_netinet_if_ether_h so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - AC_MSG_NOTICE([Rechecking with some additional includes]) - unset ac_cv_header_netinet_if_ether_h - AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include -#include -#include -struct mbuf; -struct rtentry; -#include ]) -fi - -AC_HEADER_TIME - -case "$host_os" in - -darwin*) - AC_ARG_ENABLE(universal, - AC_HELP_STRING([--disable-universal],[don't build universal on OS X])) - if test "$enable_universal" != "no"; then - case "$host_os" in - - darwin9.*) - # - # Leopard. Build for x86 and 32-bit PowerPC, with - # x86 first. (That's what Apple does.) - # - V_CCOPT="$V_CCOPT -arch i386 -arch ppc" - LDFLAGS="$LDFLAGS -arch i386 -arch ppc" - ;; - - darwin10.*) - # - # Snow Leopard. Build for x86-64 and x86, with - # x86-64 first. (That's what Apple does.) - # - V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" - LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" - ;; - esac - fi - ;; -esac - - -AC_ARG_WITH(smi, -[ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes] - --without-smi don't link with libsmi],, - with_smi=yes) - -if test "x$with_smi" != "xno" ; then - AC_CHECK_HEADER(smi.h, - [ - # - # OK, we found smi.h. Do we have libsmi with smiInit? - # - AC_CHECK_LIB(smi, smiInit, - [ - # - # OK, we have libsmi with smiInit. Can we use it? - # - AC_MSG_CHECKING([whether to enable libsmi]) - savedlibs="$LIBS" - LIBS="-lsmi $LIBS" - AC_TRY_RUN( - [ -/* libsmi available check */ -#include -main() -{ - int current, revision, age, n; - const int required = 2; - if (smiInit("")) - exit(1); - if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) - exit(2); - n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); - if (n != 3) - exit(3); - if (required < current - age || required > current) - exit(4); - exit(0); -} - ], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(USE_LIBSMI, 1, - [Define if you enable support for libsmi]) - ], - [ - dnl autoconf documentation says that - dnl $? contains the exit value. - dnl reality is that it does not. - dnl We leave this in just in case - dnl autoconf ever comes back to - dnl match the documentation. - case $? in - 1) AC_MSG_RESULT(no - smiInit failed) ;; - 2) AC_MSG_RESULT(no - header/library version mismatch) ;; - 3) AC_MSG_RESULT(no - can't determine library version) ;; - 4) AC_MSG_RESULT(no - too old) ;; - *) AC_MSG_RESULT(no) ;; - esac - LIBS="$savedlibs" - ], - [ - AC_MSG_RESULT(not when cross-compiling) - LIBS="$savedlibs" - ] - ) - ]) - ]) -fi - -AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) -AC_ARG_ENABLE(smb, -[ --enable-smb enable possibly-buggy SMB printer [default=yes] - --disable-smb disable possibly-buggy SMB printer],, - enableval=yes) -case "$enableval" in -yes) AC_MSG_RESULT(yes) - AC_WARN([The SMB printer may have exploitable buffer overflows!!!]) - AC_DEFINE(ENABLE_SMB, 1, - [define if you want to build the possibly-buggy SMB printer]) - LOCALSRC="print-smb.c smbutil.c $LOCALSRC" - ;; -*) AC_MSG_RESULT(no) - ;; -esac - -AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME]) -AC_MSG_CHECKING([whether to drop root privileges by default]) -if test ! -z "$with_user" ; then - AC_DEFINE_UNQUOTED(WITH_USER, "$withval", - [define if should drop privileges by default]) - AC_MSG_RESULT(to \"$withval\") -else - AC_MSG_RESULT(no) -fi - -AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY]) -AC_MSG_CHECKING([whether to chroot]) -if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then - AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval", - [define if should chroot when dropping privileges]) - AC_MSG_RESULT(to \"$withval\") -else - AC_MSG_RESULT(no) -fi - -AC_ARG_WITH(sandbox-capsicum, - AS_HELP_STRING([--with-sandbox-capsicum], - [use Capsicum security functions @<:@default=yes, if available@:>@])) -# -# Check whether various functions are available. If any are, set -# ac_lbl_capsicum_function_seen to yes; if any are not, set -# ac_lbl_capsicum_function_not_seen to yes. -# -# We don't check cap_rights_init(), as it's a macro, wrapping another -# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS() -# doesn't handle that. -# -# All of the ones we check for must be available in order to enable -# capsicum sandboxing. -# -# XXX - do we need to check for all of them, or are there some that, if -# present, imply others are present? -# -if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then - AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat, - ac_lbl_capsicum_function_seen=yes, - ac_lbl_capsicum_function_not_seen=yes) -fi -AC_MSG_CHECKING([whether to sandbox using capsicum]) -if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then - AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi - -# -# We must check this before checking whether to check the OS's IPv6, -# support because, on some platforms (such as SunOS 5.x), the test -# program requires the extra networking libraries. -# -AC_LBL_LIBRARY_NET - -# -# Check whether AF_INET6 and struct in6_addr are defined. -# If they aren't both defined, we don't have sufficient OS -# support for IPv6, so we don't look for IPv6 support libraries, -# and we define AF_INET6 and struct in6_addr ourselves. -# -AC_MSG_CHECKING([whether the operating system supports IPv6]) -AC_COMPILE_IFELSE( - [ - AC_LANG_SOURCE( - [[ -/* AF_INET6 available check */ -#include -#include -#include -#ifdef AF_INET6 -void -foo(struct in6_addr *addr) -{ - memset(addr, 0, sizeof (struct in6_addr)); -} -#else -#error "AF_INET6 not defined" -#endif - ]]) - ], - [ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1, - [define if the OS provides AF_INET6 and struct in6_addr]) - ipv6=yes - ], - [ - AC_MSG_RESULT(no) - ipv6=no - ] -) - -ipv6type=unknown -ipv6lib=none -ipv6trylibc=no - -if test "$ipv6" = "yes"; then - AC_MSG_CHECKING([ipv6 stack type]) - for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do - case $i in - inria) - dnl http://www.kame.net/ - AC_EGREP_CPP(yes, -[#include -#ifdef IPV6_INRIA_VERSION -yes -#endif], - [ipv6type=$i]) - ;; - kame) - dnl http://www.kame.net/ - AC_EGREP_CPP(yes, -[#include -#ifdef __KAME__ -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6; - ipv6libdir=/usr/local/v6/lib; - ipv6trylibc=yes]) - ;; - linux-glibc) - dnl http://www.v6.linux.or.jp/ - AC_EGREP_CPP(yes, -[#include -#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 -yes -#endif], - [ipv6type=$i]) - ;; - linux-libinet6) - dnl http://www.v6.linux.or.jp/ - dnl - dnl This also matches Solaris 8 and Tru64 UNIX 5.1, - dnl and possibly other versions of those OSes - dnl - if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then - ipv6type=$i - ipv6lib=inet6 - ipv6libdir=/usr/inet6/lib - ipv6trylibc=yes; - CFLAGS="-I/usr/inet6/include $CFLAGS" - fi - ;; - toshiba) - AC_EGREP_CPP(yes, -[#include -#ifdef _TOSHIBA_INET6 -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6; - ipv6libdir=/usr/local/v6/lib]) - ;; - v6d) - AC_EGREP_CPP(yes, -[#include -#ifdef __V6D__ -yes -#endif], - [ipv6type=$i; - ipv6lib=v6; - ipv6libdir=/usr/local/v6/lib; - CFLAGS="-I/usr/local/v6/include $CFLAGS"]) - ;; - zeta) - AC_EGREP_CPP(yes, -[#include -#ifdef _ZETA_MINAMI_INET6 -yes -#endif], - [ipv6type=$i; - ipv6lib=inet6; - ipv6libdir=/usr/local/v6/lib]) - ;; - esac - if test "$ipv6type" != "unknown"; then - break - fi - done - AC_MSG_RESULT($ipv6type) -fi - -if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then - if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then - LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" - echo "You have $ipv6lib library, using it" - else - if test "$ipv6trylibc" = "yes"; then - echo "You do not have $ipv6lib library, using libc" - else - echo 'Fatal: no $ipv6lib library found. cannot continue.' - echo "You need to fetch lib$ipv6lib.a from appropriate" - echo 'ipv6 kit and compile beforehand.' - exit 1 - fi - fi -fi - -AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h], -[td_cv_decl_netdnet_dnetdb_h_dnet_htoa], -[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h, - td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes, - td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)]) -if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then - AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1, - [define if you have a dnet_htoa declaration in ]) -fi - -AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long) -AC_CHECK_FUNCS(fork vfork strftime) -AC_CHECK_FUNCS(setlinebuf alarm) - -needsnprintf=no -AC_CHECK_FUNCS(vsnprintf snprintf,, - [needsnprintf=yes]) -if test $needsnprintf = yes; then - AC_LIBOBJ(snprintf) -fi - -AC_LBL_TYPE_SIGNAL - -AC_SEARCH_LIBS(dnet_htoa, dnet, - AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function])) - -AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc - -dnl Some platforms may need -lnsl for getrpcbynumber. -AC_SEARCH_LIBS(getrpcbynumber, nsl, - AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()])) - -AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) - -# -# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate -# libraries (e.g., "-lsocket -lnsl" on Solaris). -# -# You are in a twisty little maze of UN*Xes, all different. -# Some might not have ether_ntohost(). -# Some might have it, but not declare it in any header file. -# Some might have it, but declare it in . -# Some might have it, but declare it in -# (And some might have it but document it as something declared in -# , although appears to work.) -# -# Before you is a C compiler. -# -AC_CHECK_FUNCS(ether_ntohost, [ - AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ - AC_TRY_RUN([ - #include - #include - #include - #include - - int - main(int argc, char **argv) - { - u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; - char name[MAXHOSTNAMELEN]; - - ether_ntohost(name, (struct ether_addr *)ea); - exit(0); - } - ], [ac_cv_buggy_ether_ntohost=no], - [ac_cv_buggy_ether_ntohost=yes], - [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) - if test "$ac_cv_buggy_ether_ntohost" = "no"; then - AC_DEFINE(USE_ETHER_NTOHOST, 1, - [define if you have ether_ntohost() and it works]) - fi -]) -if test "$ac_cv_func_ether_ntohost" = yes -a \ - "$ac_cv_buggy_ether_ntohost" = "no"; then - # - # OK, we have ether_ntohost(). Do we have ? - # - if test "$ac_cv_header_netinet_if_ether_h" = yes; then - # - # Yes. Does it declare 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']) - ],, - [ -#include -#include -#include -#include -struct mbuf; -struct rtentry; -#include -#include - ]) - fi - # - # Did that succeed? - # - if test "$ac_cv_have_decl_ether_ntohost" != yes; then - # - # No, how about , as on Linux? - # - AC_CHECK_HEADERS(netinet/ether.h) - if test "$ac_cv_header_netinet_ether_h" = yes; then - # - # We have it - does it declare ether_ntohost()? - # Unset ac_cv_have_decl_ether_ntohost so we don't - # treat the previous failure as a cached value and - # suppress the next test. - # - unset ac_cv_have_decl_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']) - ],, - [ -#include - ]) - 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 -#include -#include -#include -struct mbuf; -struct rtentry; -#include -#include - ]) - 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 - -# libdlpi is needed for Solaris 11 and later. -AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib) - -dnl -dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()", -dnl and "pcap_datalink_name_to_val()", and use substitute versions -dnl if they're not present. -dnl -AC_CHECK_FUNC(pcap_list_datalinks, - [ - AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1, - [define if libpcap has pcap_list_datalinks()]) - AC_CHECK_FUNCS(pcap_free_datalinks) - ], - [ - AC_LIBOBJ(datalinks) - ]) -AC_CHECK_FUNCS(pcap_set_datalink) -AC_CHECK_FUNC(pcap_datalink_name_to_val, - [ - AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1, - [define if libpcap has pcap_datalink_name_to_val()]) - AC_CHECK_FUNC(pcap_datalink_val_to_description, - AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1, - [define if libpcap has pcap_datalink_val_to_description()]), - [ - AC_LIBOBJ(dlnames) - ]) - ], - [ - AC_LIBOBJ(dlnames) - ]) - -dnl -dnl Check for "pcap_breakloop()"; you can't substitute for it if -dnl it's absent (it has hooks into the live capture routines), -dnl so just define the HAVE_ value if it's there. -dnl -AC_CHECK_FUNCS(pcap_breakloop) - -dnl -dnl Check for "pcap_dump_ftell()" and use a substitute version -dnl if it's not present. -dnl -AC_CHECK_FUNC(pcap_dump_ftell, - AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1, - [define if libpcap has pcap_dump_ftell()]), - [ - AC_LIBOBJ(pcap_dump_ftell) - ]) - -# -# Do we have the new open API? Check for pcap_create, and assume that, -# if we do, we also have pcap_activate() and the other new routines -# introduced in libpcap 1.0.0. -# -AC_CHECK_FUNCS(pcap_create) -if test $ac_cv_func_pcap_create = "yes" ; then - # - # OK, do we have pcap_set_tstamp_type? If so, assume we have - # pcap_list_tstamp_types and pcap_free_tstamp_types as well. - # - AC_CHECK_FUNCS(pcap_set_tstamp_type) - # - # And do we have pcap_set_tstamp_precision? If so, we assume - # we also have pcap_open_offline_with_tstamp_precision. - # - AC_CHECK_FUNCS(pcap_set_tstamp_precision) -fi - -# -# Check for a miscellaneous collection of functions which we use -# if we have them. -# -AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode) -if test $ac_cv_func_pcap_findalldevs = "yes" ; then -dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may -dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't -dnl have pcap_if_t. - savedcppflags="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $V_INCLS" - AC_CHECK_TYPES(pcap_if_t, , , [#include ]) - CPPFLAGS="$savedcppflags" -fi - -if test $ac_cv_func_pcap_lib_version = "no" ; then - AC_MSG_CHECKING(whether pcap_version is defined by libpcap) - AC_TRY_LINK([], - [ - extern char pcap_version[]; - - return (int)pcap_version; - ], - ac_lbl_cv_pcap_version_defined=yes, - ac_lbl_cv_pcap_version_defined=no) - if test "$ac_lbl_cv_pcap_version_defined" = yes ; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version]) - else - AC_MSG_RESULT(no) - fi -fi - -# -# Check for special debugging functions -# -AC_CHECK_FUNCS(pcap_set_parser_debug) -if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then - # - # OK, we don't have pcap_set_parser_debug() to set the libpcap - # filter expression parser debug flag; can we directly set the - # flag? - AC_MSG_CHECKING(whether pcap_debug is defined by libpcap) - AC_TRY_LINK([], - [ - extern int pcap_debug; - - return pcap_debug; - ], - ac_lbl_cv_pcap_debug_defined=yes, - ac_lbl_cv_pcap_debug_defined=no) - if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug]) - else - AC_MSG_RESULT(no) - # - # OK, what about "yydebug"? - # - AC_MSG_CHECKING(whether yydebug is defined by libpcap) - AC_TRY_LINK([], - [ - extern int yydebug; - - return yydebug; - ], - ac_lbl_cv_yydebug_defined=yes, - ac_lbl_cv_yydebug_defined=no) - if test "$ac_lbl_cv_yydebug_defined" = yes ; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug]) - else - AC_MSG_RESULT(no) - fi - fi -fi -AC_CHECK_FUNCS(pcap_set_optimizer_debug) -AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 - -V_GROUP=0 -if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then - V_GROUP=wheel -fi -# -# Assume V7/BSD convention for man pages (file formats in section 5, -# miscellaneous info in section 7). -# -MAN_FILE_FORMATS=5 -MAN_MISC_INFO=7 -case "$host_os" in - -aix*) - dnl Workaround to enable certain features - AC_DEFINE(_SUN,1,[define on AIX to get certain functions]) - ;; - -hpux*) - # - # Use System V conventions for man pages. - # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 - ;; - -irix*) - V_GROUP=sys - - # - # Use System V conventions for man pages. - # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 - ;; - -osf*) - V_GROUP=system - - # - # Use System V conventions for man pages. - # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 - ;; - -solaris*) - V_GROUP=sys - - # - # Use System V conventions for man pages. - # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 - ;; -esac - -if test -f /dev/bpf0 ; then - V_GROUP=bpf -fi - -# -# Make sure we have definitions for all the C99 specified-width types -# (regardless of whether the environment is a C99 environment or not). -# -AC_TYPE_INT8_T -AC_TYPE_INT16_T -AC_TYPE_INT32_T -AC_TYPE_INT64_T -AC_TYPE_UINT8_T -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T - -# -# Make sure we have a definition for C99's uintptr_t (regardless of -# whether the environment is a C99 environment or not). -# -AC_TYPE_UINTPTR_T - -# -# Define the old BSD specified-width types in terms of the C99 types; -# we may need them with libpcap include files. -# -AC_CHECK_TYPE([u_int8_t], , - [AC_DEFINE([u_int8_t], [uint8_t], - [Define to `uint8_t' if u_int8_t not defined.])], - [AC_INCLUDES_DEFAULT -#include -]) -AC_CHECK_TYPE([u_int16_t], , - [AC_DEFINE([u_int16_t], [uint16_t], - [Define to `uint16_t' if u_int16_t not defined.])], - [AC_INCLUDES_DEFAULT -#include -]) -AC_CHECK_TYPE([u_int32_t], , - [AC_DEFINE([u_int32_t], [uint32_t], - [Define to `uint32_t' if u_int32_t not defined.])], - [AC_INCLUDES_DEFAULT -#include -]) -AC_CHECK_TYPE([u_int64_t], , - [AC_DEFINE([u_int64_t], [uint64_t], - [Define to `uint64_t' if u_int64_t not defined.])], - [AC_INCLUDES_DEFAULT -#include -]) - -# -# Check for -# -AC_CHECK_HEADERS(inttypes.h, - [ - # - # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros? - # Some systems have an inttypes.h that doesn't define all of them. - # - AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]]) - AC_COMPILE_IFELSE( - [ - AC_LANG_SOURCE( - [[ - #include - #include - #include - - main() - { - printf("%" PRId64 "\n", (uint64_t)1); - printf("%" PRIo64 "\n", (uint64_t)1); - printf("%" PRIx64 "\n", (uint64_t)1); - printf("%" PRIu64 "\n", (uint64_t)1); - } - ]]) - ], - [ - AC_MSG_RESULT(yes) - ac_lbl_inttypes_h_defines_formats=yes - ], - [ - AC_MSG_RESULT(no) - ac_lbl_inttypes_h_defines_formats=no - ]) - ], - [ - # - # We don't have inttypes.h, so it obviously can't define those - # macros. - # - ac_lbl_inttypes_h_defines_formats=no - ]) -if test "$ac_lbl_inttypes_h_defines_formats" = no; then - AC_LBL_CHECK_64BIT_FORMAT(l, - [ - AC_LBL_CHECK_64BIT_FORMAT(ll, - [ - AC_LBL_CHECK_64BIT_FORMAT(L, - [ - AC_LBL_CHECK_64BIT_FORMAT(q, - [ - AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) - ]) - ]) - ]) - ]) -fi - -# -# Check for some headers introduced in later versions of libpcap -# and used by some printers. -# -# Those headers use the {u_}intN_t types, so we must do this after -# we check for what's needed to get them defined. -# -savedcppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $V_INCLS" -AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"]) -AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"]) -AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"]) -CPPFLAGS="$savedcppflags" - -AC_PROG_RANLIB -AC_CHECK_TOOL([AR], [ar]) - -AC_LBL_DEVEL(V_CCOPT) - -AC_LBL_SOCKADDR_SA_LEN - -AC_LBL_UNALIGNED_ACCESS - -# Check for OpenSSL/libressl libcrypto -AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto) -# Specify location for both includes and libraries. -want_libcrypto=ifavailable -AC_ARG_WITH(crypto, - AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@, - [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]), -[ - if test $withval = no - then - # User doesn't want to link with libcrypto. - want_libcrypto=no - AC_MSG_RESULT(no) - elif test $withval = yes - then - # User wants to link with libcrypto but hasn't specified - # a directory. - want_libcrypto=yes - AC_MSG_RESULT(yes) - else - # User wants to link with libcrypto and has specified - # a directory, so use the provided value. - want_libcrypto=yes - libcrypto_root=$withval - AC_MSG_RESULT([yes, using the version installed in $withval]) - - # - # Put the subdirectories of the libcrypto root directory - # at the front of the header and library search path. - # - CFLAGS="-I$withval/include $CFLAGS" - LIBS="-L$withval/lib $LIBS" - fi -],[ - # - # Use libcrypto if it's present, otherwise don't; no directory - # was specified. - # - want_libcrypto=ifavailable - AC_MSG_RESULT([yes, if available]) -]) -if test "$want_libcrypto" != "no"; then - # - # Don't check for libcrypto unless we have its headers; - # Apple, bless their pointy little heads, apparently ship - # libcrypto as a library, but not the header files, in - # El Capitan, probably because they don't want you writing - # nasty portable code that could run on other UN*Xes, they - # want you writing code that uses their Shiny New Crypto - # Library and that only runs on OS X. - # - AC_CHECK_HEADER(openssl/crypto.h, - [ - AC_CHECK_LIB(crypto, DES_cbc_encrypt) - if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then - AC_CHECK_HEADERS(openssl/evp.h) - # - # OK, then: - # - # 1) do we have EVP_CIPHER_CTX_new? - # If so, we use it to allocate an - # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be - # opaque; otherwise, we allocate it ourselves. - # - # 2) do we have EVP_CipherInit_ex()? - # If so, we use it, because we need to be - # able to make two "initialize the cipher" - # calls, one with the cipher and key, and - # one with the IV, and, as of OpenSSL 1.1, - # You Can't Do That with EVP_CipherInit(), - # because a call to EVP_CipherInit() will - # unconditionally clear the context, and - # if you don't supply a cipher, it'll - # clear the cipher, rendering the context - # unusable and causing a crash. - # - AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_CipherInit_ex) - fi - ]) -fi - -# Check for libcap-ng -AC_MSG_CHECKING(whether to use libcap-ng) -# Specify location for both includes and libraries. -want_libcap_ng=ifavailable -AC_ARG_WITH(cap_ng, - AS_HELP_STRING([--with-cap-ng], - [use libcap-ng @<:@default=yes, if available@:>@]), -[ - if test $withval = no - then - want_libcap_ng=no - AC_MSG_RESULT(no) - elif test $withval = yes - then - want_libcap_ng=yes - AC_MSG_RESULT(yes) - fi -],[ - # - # Use libcap-ng if it's present, otherwise don't. - # - want_libcap_ng=ifavailable - AC_MSG_RESULT([yes, if available]) -]) -if test "$want_libcap_ng" != "no"; then - AC_CHECK_LIB(cap-ng, capng_change_id) - AC_CHECK_HEADERS(cap-ng.h) -fi - -dnl -dnl set additional include path if necessary -if test "$missing_includes" = "yes"; then - CPPFLAGS="$CPPFLAGS -I$srcdir/missing" - V_INCLS="$V_INCLS -I$srcdir/missing" -fi - -AC_SUBST(V_CCOPT) -AC_SUBST(V_DEFS) -AC_SUBST(V_GROUP) -AC_SUBST(V_INCLS) -AC_SUBST(V_PCAPDEP) -AC_SUBST(LOCALSRC) -AC_SUBST(MAN_FILE_FORMATS) -AC_SUBST(MAN_MISC_INFO) - -AC_PROG_INSTALL - -AC_CONFIG_HEADER(config.h) - -AC_OUTPUT_COMMANDS([if test -f .devel; then - echo timestamp > stamp-h - cat Makefile-devel-adds >> Makefile - make depend -fi]) -AC_OUTPUT(Makefile tcpdump.1) -exit 0 Property changes on: vendor/tcpdump/dist/configure.in ___________________________________________________________________ Deleted: svn:executable ## -1 +0,0 ## -* \ No newline at end of property Index: vendor/tcpdump/dist/CHANGES =================================================================== --- vendor/tcpdump/dist/CHANGES (revision 353143) +++ vendor/tcpdump/dist/CHANGES (revision 353144) @@ -1,1446 +1,1479 @@ +Friday, September 20, 2019, by mcr@sandelman.ca + A huge thank you to Denis, Francois-Xavier and Guy who did much of the heavy lifting. + Summary for 4.9.3 tcpdump release + Fix buffer overflow/overread vulnerabilities: + CVE-2017-16808 (AoE) + CVE-2018-14468 (FrameRelay) + CVE-2018-14469 (IKEv1) + CVE-2018-14470 (BABEL) + CVE-2018-14466 (AFS/RX) + CVE-2018-14461 (LDP) + CVE-2018-14462 (ICMP) + CVE-2018-14465 (RSVP) + CVE-2018-14881 (BGP) + CVE-2018-14464 (LMP) + CVE-2018-14463 (VRRP) + CVE-2018-14467 (BGP) + CVE-2018-10103 (SMB - partially fixed, but SMB printing disabled) + CVE-2018-10105 (SMB - too unreliably reproduced, SMB printing disabled) + CVE-2018-14880 (OSPF6) + CVE-2018-16451 (SMB) + CVE-2018-14882 (RPL) + CVE-2018-16227 (802.11) + CVE-2018-16229 (DCCP) + CVE-2018-16301 (was fixed in libpcap) + CVE-2018-16230 (BGP) + CVE-2018-16452 (SMB) + CVE-2018-16300 (BGP) + CVE-2018-16228 (HNCP) + CVE-2019-15166 (LMP) + CVE-2019-15167 (VRRP) + Fix for cmdline argument/local issues: + CVE-2018-14879 (tcpdump -V) + Sunday September 3, 2017 denis@ovsienko.info Summary for 4.9.2 tcpdump release Do not use getprotobynumber() for protocol name resolution. Do not do any protocol name resolution if -n is specified. Improve errors detection in the test scripts. Fix a segfault with OpenSSL 1.1 and improve OpenSSL usage. Clean up IS-IS printing. Fix buffer overflow vulnerabilities: CVE-2017-11543 (SLIP) CVE-2017-13011 (bittok2str_internal) Fix infinite loop vulnerabilities: CVE-2017-12989 (RESP) CVE-2017-12990 (ISAKMP) CVE-2017-12995 (DNS) CVE-2017-12997 (LLDP) Fix buffer over-read vulnerabilities: CVE-2017-11541 (safeputs) CVE-2017-11542 (PIMv1) CVE-2017-12893 (SMB/CIFS) CVE-2017-12894 (lookup_bytestring) CVE-2017-12895 (ICMP) CVE-2017-12896 (ISAKMP) CVE-2017-12897 (ISO CLNS) CVE-2017-12898 (NFS) CVE-2017-12899 (DECnet) CVE-2017-12900 (tok2strbuf) CVE-2017-12901 (EIGRP) CVE-2017-12902 (Zephyr) CVE-2017-12985 (IPv6) CVE-2017-12986 (IPv6 routing headers) CVE-2017-12987 (IEEE 802.11) CVE-2017-12988 (telnet) CVE-2017-12991 (BGP) CVE-2017-12992 (RIPng) CVE-2017-12993 (Juniper) CVE-2017-11542 (PIMv1) CVE-2017-11541 (safeputs) CVE-2017-12994 (BGP) CVE-2017-12996 (PIMv2) CVE-2017-12998 (ISO IS-IS) CVE-2017-12999 (ISO IS-IS) CVE-2017-13000 (IEEE 802.15.4) CVE-2017-13001 (NFS) CVE-2017-13002 (AODV) CVE-2017-13003 (LMP) CVE-2017-13004 (Juniper) CVE-2017-13005 (NFS) CVE-2017-13006 (L2TP) CVE-2017-13007 (Apple PKTAP) CVE-2017-13008 (IEEE 802.11) CVE-2017-13009 (IPv6 mobility) CVE-2017-13010 (BEEP) CVE-2017-13012 (ICMP) CVE-2017-13013 (ARP) CVE-2017-13014 (White Board) CVE-2017-13015 (EAP) CVE-2017-11543 (SLIP) CVE-2017-13016 (ISO ES-IS) CVE-2017-13017 (DHCPv6) CVE-2017-13018 (PGM) CVE-2017-13019 (PGM) CVE-2017-13020 (VTP) CVE-2017-13021 (ICMPv6) CVE-2017-13022 (IP) CVE-2017-13023 (IPv6 mobility) CVE-2017-13024 (IPv6 mobility) CVE-2017-13025 (IPv6 mobility) CVE-2017-13026 (ISO IS-IS) CVE-2017-13027 (LLDP) CVE-2017-13028 (BOOTP) CVE-2017-13029 (PPP) CVE-2017-13030 (PIM) CVE-2017-13031 (IPv6 fragmentation header) CVE-2017-13032 (RADIUS) CVE-2017-13033 (VTP) CVE-2017-13034 (PGM) CVE-2017-13035 (ISO IS-IS) CVE-2017-13036 (OSPFv3) CVE-2017-13037 (IP) CVE-2017-13038 (PPP) CVE-2017-13039 (ISAKMP) CVE-2017-13040 (MPTCP) CVE-2017-13041 (ICMPv6) CVE-2017-13042 (HNCP) CVE-2017-13043 (BGP) CVE-2017-13044 (HNCP) CVE-2017-13045 (VQP) CVE-2017-13046 (BGP) CVE-2017-13047 (ISO ES-IS) CVE-2017-13048 (RSVP) CVE-2017-13049 (Rx) CVE-2017-13050 (RPKI-Router) CVE-2017-13051 (RSVP) CVE-2017-13052 (CFM) CVE-2017-13053 (BGP) CVE-2017-13054 (LLDP) CVE-2017-13055 (ISO IS-IS) CVE-2017-13687 (Cisco HDLC) CVE-2017-13688 (OLSR) CVE-2017-13689 (IKEv1) CVE-2017-13690 (IKEv2) CVE-2017-13725 (IPv6 routing headers) Sunday July 23, 2017 denis@ovsienko.info Summary for 4.9.1 tcpdump release CVE-2017-11108/Fix bounds checking for STP. Make assorted documentation updates and fix a few typos in tcpdump output. Fixup -C for file size >2GB (GH #488). Show AddressSanitizer presence in version output. Fix a bug in test scripts (exposed in GH #613). On FreeBSD adjust Capsicum capabilities for netmap. On Linux fix a use-after-free when the requested interface does not exist. Wednesday January 18, 2017 devel.fx.lebail@orange.fr Summary for 4.9.0 tcpdump release General updates: Fix some heap overflows found with American Fuzzy Lop by Hanno Boeck and others (More information in the log with CVE-2016-* and CVE-2017-*) Change the way protocols print link-layer addresses (Fix heap overflows in CALM-FAST and GeoNetworking printers) Pass correct caplen value to ether_print() and some other functions Fix lookup_nsap() to match what isonsap_string() expects Clean up relative time stamp printing (Fix an array overflow) Fix some alignment issues with GCC on Solaris 10 SPARC Add some ND_TTEST_/ND_TCHECK_ macros to simplify writing bounds checks Add a fn_printztn() which returns the number of bytes processed Add nd_init() and nd_cleanup() functions. Improve libsmi support Add CONTRIBUTING file Add a summary comment in all printers Compile with more warning options in devel mode if supported (-Wcast-qual, ...) Fix some leaks found by Valgrind/Memcheck Fix a bunch of de-constifications Squelch some Coverity warnings and some compiler warnings Update Coverity and Travis-CI setup Update Visual Studio files Frontend: Fix capsicum support to work with zerocopy buffers in bpf Try opening interfaces by name first, then by name-as-index Work around pcap_create() failures fetching time stamp type lists Fix a segmentation fault with 'tcpdump -J' Improve addrtostr6() bounds checking Add exit_tcpdump() function Don't drop CAP_SYS_CHROOT before chrooting Fixes issue where statistics not reported when -G and -W options used Updated printers: 802.11: Beginnings of 11ac radiotap support 802.11: Check the Protected bit for management frames 802.11: Do bounds checking on last_presentp before dereferencing it (Fix a heap overflow) 802.11: Fix the radiotap printer to handle the special bits correctly 802.11: If we have the MCS field, it's 11n 802.11: Only print unknown frame type or subtype messages once 802.11: Radiotap dBm values get printed as dB; Update a test output accordingly 802.11: Source and destination addresses were backwards AH: Add a bounds check AH: Report to our caller that dissection failed if a bounds check fails AP1394: Print src > dst, not dst > src ARP: Don't assume the target hardware address is <= 6 octets long (Fix a heap overflow) ATALK: Add bounds and length checks (Fix heap overflows) ATM: Add some bounds checks (Fix a heap overflow) ATM: Fix an incorrect bounds check BFD: Update specification from draft to RFC 5880 BFD: Update to print optional authentication field BGP: Add support for the AIGP attribute (RFC7311) BGP: Print LARGE_COMMUNITY Path Attribute BGP: Update BGP numbers from IANA; Print minor values for FSM notification BOOTP: Add a bounds check Babel: Add decoder for source-specific extension CDP: Filter out non-printable characters CFM: Fixes to match the IEEE standard, additional bounds and length checks CSLIP: Add more bounds checks (Fix a heap overflow) ClassicalIPoATM: Add a bounds check on LLC+SNAP header (Fix a heap overflow) DHCP: Fix MUDURL and TZ options DHCPv6: Process MUDURL and TZ options DHCPv6: Update Status Codes with RFCs/IANA names DNS: Represent the "DNSSEC OK" bit as "DO" instead of "OK". Add a test case DTP: Improve packet integrity checks EGP: Fix bounds checks ESP: Don't use OpenSSL_add_all_algorithms() in OpenSSL 1.1.0 or later Ethernet: Add some bounds checking before calling isoclns_print (Fix a heap overflow) Ethernet: Print the Length/Type field as length when needed FDDI: Fix -e output for FDDI FR: Add some packet-length checks and improve Q.933 printing (Fix heap overflows) GRE: Add some bounds checks (Fix heap overflows) Geneve: Fix error message with invalid option length; Update list option classes HNCP: Fix incorrect time interval format. Fix handling of IPv4 prefixes ICMP6: Fetch a 32-bit big-endian quantity with EXTRACT_32BITS() IGMP: Add a length check IP: Add a bounds check (Fix a heap overflow) IP: Check before fetching the protocol version (Fix a heap overflow) IP: Don't try to dissect if IP version != 4 (Fix a heap overflow) IP: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP IPComp: Check whether we have the CPI before we fetch it (Fix a heap overflow) IPoFC: Fix -e output (IP-over-Fibre Channel) IPv6: Don't overwrite the destination IPv6 address for routing headers IPv6: Fix header printing IPv6: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP ISAKMP: Clean up parsing of IKEv2 Security Associations ISOCLNS/IS-IS: Add support for Purge Originator Identifier (RFC6232) and test cases ISOCLNS/IS-IS: Don't overwrite packet data when checking the signature ISOCLNS/IS-IS: Filter out non-printable characters ISOCLNS/IS-IS: Fix segmentation faults ISOCLNS/IS-IS: Have signature_verify() do the copying and clearing ISOCLNS: Add some bounds checks Juniper: Make sure a Juniper header TLV isn't bigger than what's left in the packet (Fix a heap overflow) LLC/SNAP: With -e, print the LLC header before the SNAP header; without it, cut the SNAP header LLC: Add a bounds check (Fix a heap overflow) LLC: Clean up printing of LLC packets LLC: Fix the printing of RFC 948-style IP packets LLC: Skip the LLC and SNAP headers with -x for 802.11 and some other protocols LLDP: Implement IANA OUI and LLDP MUD option MPLS LSP ping: Update printing for RFC 4379, bug fixes, more bounds checks MPLS: "length" is now the *remaining* packet length MPLS: Add bounds and length checks (Fix a heap overflow) NFS: Don't assume the ONC RPC header is nicely aligned NFS: Don't overflow the Opaque_Handle buffer (Fix a segmentation fault) NFS: Don't run past the end of an NFSv3 file handle OLSR: Add a test to cover a HNA sgw case OLSR: Fix 'Advertised networks' count OLSR: Fix printing of smart-gateway HNAs in IPv4 OSPF: Add a bounds check for the Hello packet options OSPF: Do more bounds checking OSPF: Fix a segmentation fault OSPF: Fix printing 'ospf_topology_values' default OTV: Add missing bounds checks PGM: Print the formatted IP address, not the raw binary address, as a string PIM: Add some bounds checking (Fix a heap overflow) PIMv2: Fix checksumming of Register messages PPP: Add some bounds checks (Fix a heap overflow) PPP: Report invalid PAP AACK/ANAK packets Q.933: Add a missing bounds check RADIUS: Add Value 13 "VLAN" to Tunnel-Type attribute RADIUS: Filter out non-printable characters RADIUS: Translate UDP/1700 as RADIUS RESP: Do better checking of RESP packets RPKI-RTR: Add a return value check for "fn_printn" call RPKI-RTR: Remove printing when truncated condition already detected RPL: Fix 'Consistency Check' control code RPL: Fix suboption print RSVP: An INTEGRITY object in a submessage covers only the submessage RSVP: Fix an infinite loop; Add bounds and length checks RSVP: Fix some if statements missing brackets RSVP: Have signature_verify() do the copying and clearing RTCP: Add some bounds checks RTP: Add some bounds checks, fix two segmentation faults SCTP: Do more bounds checking SFLOW: Fix bounds checking SLOW: Fix bugs, add checks SMB: Before fetching the flags2 field, make sure we have it SMB: Do bounds checks on NBNS resource types and resource data lengths SNMP: Clean up the "have libsmi but no modules loaded" case SNMP: Clean up the object abbreviation list and fix the code to match them SNMP: Do bounds checks when printing character and octet strings SNMP: Improve ASN.1 bounds checks SNMP: More bounds and length checks STP: Add a bunch of bounds checks, and fix some printing (Fix heap overflows) STP: Filter out non-printable characters TCP: Add bounds and length checks for packets with TCP option 20 TCP: Correct TCP option Kind value for TCP Auth and add SCPS-TP TCP: Fix two bounds checks (Fix heap overflows) TCP: Make sure we have the data offset field before fetching it (Fix a heap overflow) TCP: Put TCP-AO option decoding right TFTP: Don't use strchr() to scan packet data (Fix a heap overflow) Telnet: Add some bounds checks TokenRing: Fix -e output UDLD: Fix an infinite loop UDP: Add a bounds check (Fix a heap overflow) UDP: Check against the packet length first VAT: Add some bounds checks VTP: Add a test on Mgmt Domain Name length VTP: Add bounds checks and filter out non-printable characters VXLAN: Add a bound check and a test case ZeroMQ: Fix an infinite loop Tuesday October 25, 2016 mcr@sandelman.ca Summary for 4.8.1 tcpdump release Fix "-x" for Apple PKTAP and PPI packets Improve separation frontend/backend (tcpdump/libnetdissect) Fix display of timestamps with -tt, -ttt and -ttttt options Add support for the Marvell Extended Distributed Switch Architecture header Use PRIx64 to print a 64-bit number in hex. Printer for HNCP (RFCs 7787 and 7788). dagid is always an IPv6 address, not an opaque 128-bit string, and other fixes to RPL printer. RSVP: Add bounds and length checks OSPF: Do more bounds checking Handle OpenSSL 1.1.x. Initial support for the REdis Serialization Protocol known as RESP. Add printing function for Generic Protocol Extension for VXLAN draft-ietf-nvo3-vxlan-gpe-01 Network Service Header: draft-ietf-sfc-nsh-01 Don't recompile the filter if the new file has the same DLT. Pass an adjusted struct pcap_pkthdr to the sub-printer. Add three test cases for already fixed CVEs CVE-2014-8767: OLSR CVE-2014-8768: Geonet CVE-2014-8769: AODV Don't do the DDP-over-UDP heuristic first: GitHub issue #499. Use the new debugging routines in libpcap. Harmonize TCP source or destination ports tests with UDP ones Introduce data types to use for integral values in packet structures. RSVP: Fix an infinite loop Support of Type 3 and Type 4 LISP packets. Don't require IPv6 library support in order to support IPv6 addresses. Many many changes to support libnetdissect usage. Add a test that makes unaligned accesses: GitHub issue #478. add a DNSSEC test case: GH #445 and GH #467. BGP: add decoding of ADD-PATH capability fixes to LLC header printing, and RFC948-style IP packets Friday April 10, 2015 guy@alum.mit.edu Summary for 4.7.4 tcpdump release RPKI to Router Protocol: Fix Segmentation Faults and other problems RPKI to Router Protocol: print strings with fn_printn() wb: fix some bounds checks Wednesday March 11, 2015 mcr@sandelman.ca Summary for 4.7.3 tcpdump release Capsicum fixes for FreeBSD 10 Tuesday March 10, 2015 mcr@sandelman.ca Summary for 4.7.2 tcpdump release DCCP: update Packet Types with RFC4340/IANA names fixes for CVE-2015-0261: IPv6 mobility header check issue fixes for CVE-2015-2153, 2154, 2155: kday packets Friday Nov. 12, 2014 guy@alum.mit.edu Summary for 4.7.0 tcpdump release changes to hex printing of CDP packets Fix PPI printing Radius: update Packet Type Codes and Attribute Types with RFC/IANA names Add a routine to print "text protocols", and add FTP/HTTP/SMTP/RTSP support. improvements to telnet printer, even if not -v omit length for bcp, print-tcp uses it formatting fixes for a bunch of protocols new bounds checks for a number of protocols split netflow 1,6, and 6 dissector up. added geneve dissector CVE-2014-9140 PPP dissector fixed. Tuesday Sep. 2, 2014 mcr@sandelman.ca Summary for 4.6.2 tcpdump release fix out-of-source-tree builds: find libpcap that is out of source better configure check for libsmi Saturday Jul. 19, 2014 mcr@sandelman.ca Summary for 4.6.1 tcpdump release added FreeBSD capsicum add a short option '#', same as long option '--number' Wednesday Jul. 2, 2014 mcr@sandelman.ca Summary for 4.6.0 tcpdump release all of tcpdump is now using the new "NDO" code base (Thanks Denis!) nflog, mobile, forces, pptp, AODV, AHCP, IPv6, OSPFv4, RPL, DHCPv6 enhancements/fixes M3UA decode added. many new test cases: 82 in 4.5.1 to 133 in 4.6.0 many improvements to travis continuous integration system: OSX, and Coverity options cleaned up some unnecessary header files Added bittok2str(). a number of unaligned access faults fixed -A flag does not consider CR to be printable anymore fx.lebail took over coverity baby sitting default snapshot size increased to 256K for accomodate USB captures WARNING: this release contains a lot of very worthwhile code churn. Wednesday Jan. 15, 2014 guy@alum.mit.edu Summary for 4.5.2 tcpdump release Man page fix Fix crashes on SPARC Monday Nov. 11, 2013 mcr@sandelman.ca Summary for 4.5.1 tcpdump release CREDITS file fixes Thursday Nov. 7, 2013 mcr@sandelman.ca and guy@alum.mit.edu. Summary for 4.5.0 tcpdump release some NFSv4 fixes for printing fix printing of unknown TCP options, and tcp fast-open fixes for syslog parser some gcc-version-specific flag tuning adopt MacOS deprecation workarounds for openssl improvements to babel printing add OpenFlow 1.0 (no SSL) and test cases GeoNet printer. added STBC Rx support improvements to DHCPv6 decoder clarify which autoconf is needed Point users to the the-tcpdump-group repository on GitHub rather than the mcr repository Add MSDP printer. Fixed IPv6 check on Solaris and other OSes requiring extra networking libraries. Add support for VXLAN (draft-mahalingam-dutt-dcops-vxlan-03), and add "vxlan" as an option for -T. Add support for OTV (draft-hasmit-otv-04). fixes for DLT_IEEE802_11_RADIO datalink types added MPTCP decoder Saturday April 6, 2013 guy@alum.mit.edu. Summary for 4.4.0 tcpdump release RPKI-RTR (RFC6810) is now official (TCP Port 323) Fix detection of OpenSSL libcrypto. Add DNSSL (RFC6106) support. Add "radius" as an option for -T. Update Action codes for handle_action function according to 802.11s amendment. Decode DHCPv6 AFTR-Name option (RFC6334). Updates for Babel. Fix printing of infinite lifetime in ICMPv6. Added support for SPB, SPBM Service Identifier, and Unicast Address sub-TLV in ISIS. Decode RIPv2 authentication up to RFC4822. Fix RIP Request/full table decoding issues. On Linux systems with cap-ng.h, drop root privileges using Linux Capabilities. Add support for reading multiple files. Add MS NLB heartbeat printer. Separate multiple nexthops in BGP. Wednesday November 28, 2012 guy@alum.mit.edu. Summary for 4.3.1 tcpdump release Print "LLDP, length N" for LLDP packets even when not in verbose mode, so something is printed even if only the timestamp is present Document "-T carp" Print NTP poll interval correctly (it's an exponent, so print both its raw value and 2^value) Document that "-e" is used to get MAC addresses More clearly document that you need to escape or quote backslashes in filter expressions on the command line Fix some "the the" in the man page Use the right maximum path length Don't treat 192_1_2, when passed to -i, as an interface number Friday April 3, 2012. mcr@sandelman.ca. Summary for 4.3.0 tcpdump release fixes for forces: SPARSE data (per RFC 5810) some more test cases added updates to documentation on -l, -U and -w flags. Fix printing of BGP optional headers. Tried to include DLT_PFSYNC support, failed due to headers required. added TIPC support. Fix LLDP Network Policy bit definitions. fixes for IGMPv3's Max Response Time: it is in units of 0.1 second. SIGUSR1 can be used rather than SIGINFO for stats permit -n flag to affect print-ip for protocol numbers ND_OPT_ADVINTERVAL is in milliseconds, not seconds Teach PPPoE parser about RFC 4638 Friday December 9, 2011. guy@alum.mit.edu. Summary for 4.2.1 tcpdump release Only build the Babel printer if IPv6 is enabled. Support Babel on port 6696 as well as 6697. Include ppi.h in release tarball. Include all the test files in the release tarball, and don't "include" test files that no longer exist. Don't assume we have - check for it. Support "-T carp" as a way of dissecting IP protocol 112 as CARP rather than VRRP. Support Hilscher NetAnalyzer link-layer header format. Constify some pointers and fix compiler warnings. Get rid of never-true test. Fix an unintended fall-through in a case statement in the ARP printer. Fix several cases where sizeof(sizeof(XXX)) was used when just sizeof(XXX) was intended. Make stricter sanity checks in the ES-IS printer. Get rid of some GCCisms that caused builds to fai with compilers that don't support them. Fix typo in man page. Added length checks to Babel printer. Sunday July 24, 2011. mcr@sandelman.ca. Summary for 4.2.+ merged 802.15.4 decoder from Dmitry Eremin-Solenikov updates to forces for new port numbers Use "-H", not "-h", for the 802.11s option. (-h always help) Better ICMPv6 checksum handling. add support for the RPKI/Router Protocol, per -ietf-sidr-rpki-rtr-12 get rid of uuencoded pcap test files, git can do binary. sFlow changes for 64-bit counters. fixes for PPI packet header handling and printing. Add DCB Exchange protocol (DCBX) version 1.01. Babel dissector, from Juliusz Chroboczek and GrĂ©goire Henry. improvements to radiotap for rate values > 127. Many improvements to ForCES decode, including fix SCTP TML port updated RPL type code to RPL-17 draft Improve printout of DHCPv6 options. added support and test case for QinQ (802.1q VLAN) packets Handle DLT_IEEE802_15_4_NOFCS like DLT_IEEE802_15_4. Build fixes for Sparc and other machines with alignment restrictions. Merged changes from Debian package. PGM: Add ACK decoding and add PGMCC DATA and FEEDBACK options. Build fixes for OSX (Snow Leopard and others) Add support for IEEE 802.15.4 packets Tue. July 20, 2010. guy@alum.mit.edu. Summary for 4.1.2 tcpdump release If -U is specified, flush the file after creating it, so it's not zero-length Fix TCP flags output description, and some typoes, in the man page Add a -h flag, and only attempt to recognize 802.11s mesh headers if it's set When printing the link-layer type list, send *all* output to stderr Include the CFLAGS setting when configure was run in the compiler flags Thu. April 1, 2010. guy@alum.mit.edu. Summary for 4.1.1 tcpdump release Fix build on systems with PF, such as FreeBSD and OpenBSD. Don't blow up if a zero-length link-layer address is passed to linkaddr_string(). Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu. Summary for 4.1.0 tcpdump release Fix printing of MAC addresses for VLAN frames with a length field Add some additional bounds checks and use the EXTRACT_ macros more Add a -b flag to print the AS number in BGP packets in ASDOT notation rather than ASPLAIN notation Add ICMPv6 RFC 5006 support Decode the access flags in NFS access requests Handle the new DLT_ for memory-mapped USB captures on Linux Make the default snapshot (-s) the maximum Print name of device (when -L is used) Support for OpenSolaris (and SXCE build 125 and later) Print new TCP flags Add support for RPL DIO Add support for TCP User Timeout (UTO) Add support for non-standard Ethertypes used by 3com PPPoE gear Add support for 802.11n and 802.11s Add support for Transparent Ethernet Bridge ethertype in GRE Add 4 byte AS support for BGP printer Add support for the MDT SAFI 66 BG printer Add basic IPv6 support to print-olsr Add USB printer Add printer for ForCES Handle frames with an FCS Handle 802.11n Control Wrapper, Block Acq Req and Block Ack frames Fix TCP sequence number printing Report 802.2 packets as 802.2 instead of 802.3 Don't include -L/usr/lib in LDFLAGS On x86_64 Linux, look in lib64 directory too Lots of code clean ups Autoconf clean ups Update testcases to make output changes Fix compiling with/out smi (--with{,out}-smi) Fix compiling without IPv6 support (--disable-ipv6) Mon. October 27, 2008. ken@netfunctional.ca. Summary for 4.0.0 tcpdump release Add support for Bluetooth Sniffing Add support for Realtek Remote Control Protocol (openrrcp.org.ru) Add support for 802.11 AVS Add support for SMB over TCP Add support for 4 byte BGP AS printing Add support for compiling on case-insensitive file systems Add support for ikev2 printing Update support for decoding AFS Update DHCPv6 printer Use newer libpcap API's (allows -B option on all platforms) Add -I to turn on monitor mode Bugfixes in lldp, lspping, dccp, ESP, NFS printers Cleanup unused files and various cruft Mon. September 10, 2007. ken@xelerance.com. Summary for 3.9.8 tcpdump release Rework ARP printer Rework OSPFv3 printer Add support for Frame-Relay ARP Decode DHCP Option 121 (RFC 3442 Classless Static Route) Decode DHCP Option 249 (MS Classless Static Route) the same as Option 121 TLV: Add support for Juniper .pcap extensions Print EGP header in new-world-order style Converted print-isakmp.c to NETDISSECT Moved AF specific stuff into af.h Test subsystem now table driven, and saves outputs and diffs to one place Require for pf definitions - allows reading of pflog formatted libpcap files on an OS other than where the file was generated Wed. July 23, 2007. mcr@xelerance.com. Summary for 3.9.7 libpcap release NFS: Print unsigned values as such. RX: parse safely. BGP: fixes for IPv6-less builds. 801.1ag: use standard codepoint. use /dev/bpf on systems with such a device. 802.11: print QoS data, avoid dissect of no-data frame, ignore padding. smb: make sure that we haven't gone past the end of the captured data. smb: squelch an uninitialized complaint from coverity. NFS: from NetBSD; don't interpret the reply as a possible NFS reply if it got MSG_DENIED. BGP: don't print TLV values that didn't fit, from www.digit-labs.org. revised INSTALL.txt about libpcap dependancy. Wed. April 25, 2007. ken@xelerance.com. Summary for 3.9.6 tcpdump release Update man page to reflect changes to libpcap Changes to both TCP and IP Printer Output Fix a potential buffer overflow in the 802.11 printer Print basic info about a few more Cisco LAN protocols. mDNS cleanup ICMP MPLS rework of the extension code bugfix: use the correct codepoint for the OSPF simple text auth token entry, and use safeputs to print the password. Add support in pflog for additional values Add support for OIF RSVP Extensions UNI 1.0 Rev. 2 and additional RSVP objects Add support for the Message-id NACK c-type. Add support for 802.3ah loopback ctrl msg Add support for Multiple-STP as per 802.1s Add support for rapid-SPT as per 802.1w Add support for CFM Link-trace msg, Link-trace-Reply msg, Sender-ID tlv, private tlv, port, interface status Add support for unidirectional link detection as per http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt Add support for the olsr protocol as per RFC 3626 plus the LQ extensions from olsr.org Add support for variable-length checksum in DCCP, as per section 9 of RFC 4340. Add support for per-VLAN spanning tree and per-VLAN rapid spanning tree Add support for Multiple-STP as per 802.1s Add support for the cisco propriatry 'dynamic trunking protocol' Add support for the cisco proprietary VTP protocol Update dhcp6 options table as per IETF standardization activities Tue. September 19, 2006. ken@xelerance.com. Summary for 3.9.5 tcpdump release Fix compiling on AIX (, at end of ENUM) Updated list of DNS RR typecodes Use local Ethernet defs on WIN32 Add support for Frame-Relay ARP Fixes for compiling under MSVC++ Add support for parsing Juniper .pcap files Add support for FRF.16 Multilink Frame-Relay (DLT_MFR) Rework the OSPFv3 printer Fix printing for 4.4BSD/NetBSD NFS Filehandles Add support for Cisco style NLPID encapsulation Add cisco prop. eigrp related, extended communities Add support for BGP signaled VPLS Cleanup the bootp printer Add support for PPP over Frame-Relay Add some bounds checking to the IP options code, and clean up the options output a bit. Add additional modp groups to ISAKMP printer Add support for Address-Withdraw and Label-Withdraw Msgs Add support for the BFD Discriminator TLV Fixes for 64bit compiling Add support for PIMv2 checksum verification Add support for further dissection of the IPCP Compression Option Add support for Cisco's proposed VQP protocol Add basic support for keyed authentication TCP option Lots of minor cosmetic changes to output printers Mon. September 19, 2005. ken@xelerance.com. Summary for 3.9.4 tcpdump release Decoder support for more Juniper link-layer types Fix a potential buffer overflow (although it can't occur in practice). Fix the handling of unknown management frame types in the 802.11 printer. Add FRF.16 support, fix various Frame Relay bugs. Add support for RSVP integrity objects, update fast-reroute object printer to latest spec. Clean up documentation of vlan filter expression, document mpls filter expression. Document new pppoed and pppoes filter expressions. Update diffserver-TE codepoints as per RFC 4124. Spelling fixes in ICMPv6. Don't require any fields other than flags to be present in IS-IS restart signaling TLVs, and only print the system ID in those TLVs as system IDs, not as node IDs. Support for DCCP. Tue. July 5, 2005. ken@xelerance.com. Summary for 3.9.3 tcpdump release 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 LACP, MARKER as per 802.3ad 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 No changes from 3.8.2. Version bumped only to maintain consistency with libpcap 0.8.3. Mon. March 29, 2004. mcr@sandelman.ottawa.on.ca. Summary for 3.8.2 release Fixes for print-isakmp.c CVE: CAN-2004-0183, CAN-2004-0184 http://www.rapid7.com/advisories/R7-0017.html IP-over-IEEE1394 printing. some MINGW32 changes. updates for autoconf 2.5 fixes for print-aodv.c - check for too short packets formatting changes to print-ascii for hex output. check for too short packets: print-bgp.c, print-bootp.c, print-cdp.c, print-chdlc.c, print-domain.c, print-icmp.c, print-icmp6.c, print-ip.c, print-lwres.c, print-ospf.c, print-pim.c, print-ppp.c,print-pppoe.c, print-rsvp.c, print-wb.c print-ether.c - better handling of unknown types. print-isoclns.c - additional decoding of types. print-llc.c - strings for LLC names added. print-pfloc.c - various enhancements print-radius.c - better decoding to strings. Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 3.8 release changed syntax of -E argument so that multiple SAs can be decrypted fixes for Digital Unix headers and Documentation __attribute__ fixes CDP changes from Terry Kennedy . IPv6 mobility updates from Kazushi Sugyo Fixes for ASN.1 decoder for 2.100.3 forms. Added a count of packets received and processed to clarify numbers. Incorporated WinDUMP patches for Win32 builds. PPPoE payload length headers. Fixes for HP C compiler builds. Use new pcap_breakloop() and pcap_findalldevs() if we can. BGP output split into multiple lines. Fixes to 802.11 decoding. Fixes to PIM decoder. SuperH is a CPU that can't handle unaligned access. Many fixes for unaligned access work. Fixes to Frame-Relay decoder for Q.933/922 frames. Clarified when Solaris can do captures as non-root. Added tests/ subdir for examples/regression tests. New -U flag. -flush stdout after every packet New -A flag -print ascii only support for decoding IS-IS inside Cisco HDLC Frames more verbosity for tftp decoder mDNS decoder new BFD decoder cross compilation patches RFC 3561 AODV support. UDP/TCP pseudo-checksum properly for source-route options. sanitized all files to modified BSD license Add support for RFC 2625 IP-over-Fibre Channel. fixes for DECnet support. Support RFC 2684 bridging of Ethernet, 802.5 Token Ring, and FDDI. RFC 2684 encapsulation of BPDUs. Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release Fixed infinite loop when parsing invalid isakmp packets. (reported by iDefense; already fixed in CVS) Fixed infinite loop when parsing invalid BGP packets. Fixed buffer overflow with certain invalid NFS packets. Pretty-print unprintable network names in 802.11 printer. Handle truncated nbp (appletalk) packets. Updated DHCPv6 printer to match draft-ietf-dhc-dhcpv6-22.txt Print IP protocol name even if we don't have a printer for it. Print IP protocol name or number for fragments. Print the whole MPLS label stack, not just the top label. Print request header and file handle for NFS v3 FSINFO and PATHCONF requests. Fix NFS packet truncation checks. Handle "old" DR-Priority and Bidir-Capable PIM HELLO options. Handle unknown RADIUS attributes properly. Fix an ASN.1 parsing error that would cause e.g. the OID 2.100.3 to be misrepresented as 4.20.3 . Monday, January 21, 2002. mcr@sandelman.ottawa.on.ca. Summary for 3.7 release see http://www.tcpdump.org/cvs-log/2002-01-21.10:16:48.html for commit log. keyword "ipx" added. Better OSI/802.2 support on Linux. IEEE 802.11 support, from clenahan@fortresstech.com, achirica@ttd.net. LLC SAP support for FDDI/token ring/RFC-1483 style ATM BXXP protocol was replaced by the BEEP protocol; improvements to SNAP demux. Changes to "any" interface documentation. Documentation on pcap_stats() counters. Fix a memory leak found by Miklos Szeredi - pcap_ether_aton(). Added MPLS encapsulation decoding per RFC3032. DNS dissector handles TKEY, TSIG and IXFR. adaptive SLIP interface patch from Igor Khristophorov SMB printing has much improved bounds checks OUI 0x0000f8 decoded as encapsulated ethernet for Cisco-custom bridging Zephyr support, from Nickolai Zeldovich . Solaris - devices with digits in them. Stefan Hudson IPX socket 0x85be is for Cisco EIGRP over IPX. Improvements to fragmented ESP handling. SCTP support from Armando L. Caro Jr. Linux ARPHDR_ATM support fixed. Added a "netbeui" keyword, which selects NetBEUI packets. IPv6 ND improvements, MobileIP dissector, 2292bis-02 for RA option. Handle ARPHDR_HDLC from Marcus Felipe Pereira . Handle IPX socket 0x553 -> NetBIOS-over-IPX socket, "nwlink-dgm" Better Linux libc5 compat. BIND9 lwres dissector added. MIPS and SPARC get strict alignment macros (affects print-bgp.c) Apple LocalTalk LINKTYPE_ reserved. New time stamp formats documented. DHCP6 updated to draft-22.txt spec. ICMP types/codes now accept symbolic names. Add SIGINFO handler from LBL encrypted CIPE tunnels in IRIX, from Franz Schaefer . now we are -Wstrict-prototype clean. NetBSD DLT_PPP_ETHER; adapted from Martin Husemann . PPPoE dissector cleaned up. Support for LocalTalk hardware, from Uns Lider . In dissector, now the caller prints the IP addresses rather than proto. cjclark@alum.mit.edu: print the IP proto for non-initial fragments. LLC frames with a DSAP and LSAP of 0xe0 are IPX frames. Linux cooked frames with a type value of LINUX_SLL_P_802_3 are IPX. captures on the "any" device won't be done in promiscuous mode Token Ring support on DLPI - Onno van der Linden ARCNet support, from NetBSD. HSRP dissector, from Julian Cowley . Handle (GRE-encapsulated) PPTP added -C option to rotate save file every optarg * 1,000,000 bytes. support for "vrrp" name - NetBSD, by Klaus Klein . PPTP support, from Motonori Shindo . IS-IS over PPP support, from Hannes Gredler . CNFP support for IPv6,format. Harry Raaymakers . ESP printing updated to RFC2406. HP-UX can now handle large number of PPAs. MSDP printer added. L2TP dissector improvements from Motonori Shindo. Tuesday January 9, 2001. mcr@sandelman.ottawa.on.ca. Summary for 3.6 release Cleaned up documentation. Promisc mode fixes for Linux IPsec changes/cleanups. Alignment fixes for picky architectures Removed dependency on native headers for packet dissectors. Removed Linux specific headers that were shipped libpcap changes provide for exchanging capture files between systems. Save files now have well known PACKET_ values instead of depending upon system dependant mappings of DLT_* types. Support for computing/checking IP and UDP/TCP checksums. Updated autoconf stock files. IPv6 improvements: dhcp (draft-15), mobile-ip6, ppp, ospf6, Added dissector support for: ISOCLNS, Token Ring, IGMPv3, bxxp, timed, vrrp, radius, chdlc, cnfp, cdp, IEEE802.1d, raw-AppleTalk Added filtering support for: VLANs, ESIS, ISIS Improvements to: print-telnet, IPTalk, bootp/dhcp, ECN, PPP, L2TP, PPPoE HP-UX 11.0 -- find the right dlpi device. Solaris 8 - IPv6 works Linux - Added support for an "any" device to capture on all interfaces Security fixes: buffer overrun audit done. Strcpy replaced with strlcpy, sprintf replaced with snprintf. Look for lex problems, and warn about them. v3.5 Fri Jan 28 18:00:00 PST 2000 Bill Fenner - switch to config.h for autoconf - unify RCSID strings - Updated PIMv1, PIMv2, DVMRP, IGMP parsers, add Cisco Auto-RP parser - Really fix the RIP printer - Fix MAC address -> name translation. - some -Wall -Wformat fixes - update makemib to parse much of SMIv2 - Print TCP sequence # with -vv even if you normally wouldn't - Print as much of IP/TCP/UDP headers as possible even if truncated. itojun@iijlab.net - -X will make a ascii dump. from netbsd. - telnet command sequence decoder (ff xx xx). from netbsd. - print-bgp.c: improve options printing. ugly code exists for unaligned option parsing (need some fix). - const poisoning in SMB decoder. - -Wall -Werror clean checks. - bring in KAME IPv6/IPsec decoding code. Assar Westerlund - SNMPv2 and SNMPv3 printer - If compiled with libsmi, tcpdump can load MIBs on the fly to decode SNMP packets. - Incorporate NFS parsing code from NetBSD. Adds support for nfsv3. - portability fixes - permit building in different directories. Ken Hornstein - bring in code at /afs/transarc.com/public/afs-contrib/tools/tcpdump for parsing AFS3 packets Andrew Tridgell - SMB printing code Love - print-rx.c: add code for printing MakeDir and StoreStatus. Also change date format to the right one. Michael C. Richardson - Created tcpdump.org repository v3.4 Sat Jul 25 12:40:55 PDT 1998 - Hardwire Linux slip support since it's too hard to detect. - Redo configuration of "network" libraries (-lsocket and -lnsl) to deal with IRIX. Thanks to John Hawkinson (jhawk@mit.edu) - Added -a which tries to translate network and broadcast addresses to names. Suggested by Rob van Nieuwkerk (robn@verdi.et.tudelft.nl) - Added a configure option to disable gcc. - Added a "raw" packet printer. - Not having an interface address is no longer fatal. Requested by John Hawkinson. - Rework signal setup to accommodate Linux. - OSPF truncation check fix. Also display the type of OSPF packets using MD5 authentication. Thanks to Brian Wellington (bwelling@tis.com) - Fix truncation check bugs in the Kerberos printer. Reported by Ezra Peisach (epeisach@mit.edu) - Don't catch SIGHUP when invoked with nohup(1). Thanks to Dave Plonka (plonka@mfa.com) - Specify full install target as a way of detecting if install directory does not exist. Thanks to Dave Plonka. - Bit-swap FDDI addresses for BSD/OS too. Thanks to Paul Vixie (paul@vix.com) - Fix off-by-one bug when testing size of ethernet packets. Thanks to Marty Leisner (leisner@sdsp.mc.xerox.com) - Add a local autoconf macro to check for routines in libraries; the autoconf version is broken (it only puts the library name in the cache variable name). Thanks to John Hawkinson. - Add a local autoconf macro to check for types; the autoconf version is broken (it uses grep instead of actually compiling a code fragment). - Modified to support the new BSD/OS 2.1 PPP and SLIP link layer header formats. - Extend OSF ip header workaround to versions 1 and 2. - Fix some signed problems in the nfs printer. As reported by David Sacerdote (davids@silence.secnet.com) - Detect group wheel and use it as the default since BSD/OS' install can't hack numeric groups. Reported by David Sacerdote. - AIX needs special loader options. Thanks to Jonathan I. Kamens (jik@cam.ov.com) - Fixed the nfs printer to print port numbers in decimal. Thanks to Kent Vander Velden (graphix@iastate.edu) - Find installed libpcap in /usr/local/lib when not using gcc. - Disallow network masks with non-network bits set. - Attempt to detect "egcs" versions of gcc. - Add missing closing double quotes when displaying bootp strings. Reported by Viet-Trung Luu (vluu@picard.math.uwaterloo.ca) v3.3 Sat Nov 30 20:56:27 PST 1996 - Added Linux support. - GRE encapsulated packet printer thanks to John Hawkinson (jhawk@mit.edu) - Rewrite gmt2local() to avoid problematic os dependencies. - Suppress nfs truncation message on errors. - Add missing m4 quoting in AC_LBL_UNALIGNED_ACCESS autoconf macro. Reported by Joachim Ott (ott@ardala.han.de) - Enable "ip_hl vs. ip_vhl" workaround for OSF4 too. - Print arp hardware type in host order. Thanks to Onno van der Linden (onno@simplex.nl) - Avoid solaris compiler warnings. Thanks to Bruce Barnett (barnett@grymoire.crd.ge.com) - Fix rip printer to not print one more route than is actually in the packet. Thanks to Jean-Luc Richier (Jean-Luc.Richier@imag.fr) and Bill Fenner (fenner@parc.xerox.com) - Use autoconf endian detection since BYTE_ORDER isn't defined on all systems. - Fix dvmrp printer truncation checks and add a dvmrp probe printer. Thanks to Danny J. Mitzel (mitzel@ipsilon.com) - Rewrite ospf printer to improve truncation checks. - Don't parse tcp options past the EOL. As noted by David Sacerdote (davids@secnet.com). Also, check tcp options to make sure they ar actually in the tcp header (in addition to the normal truncation checks). Fix the SACK code to print the N blocks (instead of the first block N times). - Don't say really small UDP packets are truncated just because they aren't big enough to be a RPC. As noted by David Sacerdote. v3.2.1 Sun Jul 14 03:02:26 PDT 1996 - Added rfc1716 icmp codes as suggested by Martin Fredriksson (martin@msp.se) - Print mtu for icmp unreach need frag packets. Thanks to John Hawkinson (jhawk@mit.edu) - Decode icmp router discovery messages. Thanks to Jeffrey Honig (jch@bsdi.com) - Added a printer entry for DLT_IEEE802 as suggested by Tak Kushida (kushida@trl.ibm.co.jp) - Check igmp checksum if possible. Thanks to John Hawkinson. - Made changes for SINIX. Thanks to Andrej Borsenkow (borsenkow.msk@sni.de) - Use autoconf's idea of the top level directory in install targets. Thanks to John Hawkinson. - Avoid infinite loop in tcp options printing code. Thanks to Jeffrey Mogul (mogul@pa.dec.com) - Avoid using -lsocket in IRIX 5.2 and earlier since it breaks snoop. Thanks to John Hawkinson. - Added some more packet truncation checks. - On systems that have it, use sigset() instead of signal() since signal() has different semantics on these systems. - Fixed some more alignment problems on the alpha. - Add code to massage unprintable characters in the domain and ipx printers. Thanks to John Hawkinson. - Added explicit netmask support. Thanks to Steve Nuchia (steve@research.oknet.com) - Add "sca" keyword (for DEC cluster services) as suggested by Terry Kennedy (terry@spcvxa.spc.edu) - Add "atalk" keyword as suggested by John Hawkinson. - Added an igrp printer. Thanks to Francis Dupont (francis.dupont@inria.fr) - Print IPX net numbers in hex a la Novell Netware. Thanks to Terry Kennedy (terry@spcvxa.spc.edu) - Fixed snmp extended tag field parsing bug. Thanks to Pascal Hennequin (pascal.hennequin@hugo.int-evry.fr) - Added some ETHERTYPEs missing on some systems. - Added truncated packet macros and various checks. - Fixed endian problems with the DECnet printer. - Use $CC when checking gcc version. Thanks to Carl Lindberg (carl_lindberg@blacksmith.com) - Fixes for AIX (although this system is not yet supported). Thanks to John Hawkinson. - Fix bugs in the autoconf misaligned accesses code fragment. - Include sys/param.h to get BYTE_ORDER in a few places. Thanks to Pavlin Ivanov Radoslavov (pavlin@cs.titech.ac.jp) v3.2 Sun Jun 23 02:28:10 PDT 1996 - Print new icmp unreachable codes as suggested by Martin Fredriksson (martin@msp.se). Also print code value when unknown for icmp redirect and time exceeded. - Fix an alignment endian bug in getname(). Thanks to John Hawkinson. - Define "new" domain record types if not found in arpa/nameserv.h. Resulted from a suggestion from John Hawkinson (jhawk@mit.edu). Also fixed an endian bug when printing mx record and added some new record types. - Added RIP V2 support. Thanks to Jeffrey Honig (jch@bsdi.com) - Added T/TCP options printing. As suggested by Richard Stevens (rstevens@noao.edu) - Use autoconf to detect architectures that can't handle misaligned accesses. v3.1 Thu Jun 13 20:59:32 PDT 1996 - Changed u_int32/int32 to u_int32_t/int32_t to be consistent with bsd and bind (as suggested by Charles Hannum). - Port to GNU autoconf. - Add support for printing DVMRP and PIM traffic thanks to Havard Eidnes (Havard.Eidnes@runit.sintef.no). - Fix AppleTalk, IPX and DECnet byte order problems due to wrong endian define being referenced. Reported by Terry Kennedy. - Minor fixes to the man page thanks to Mark Andrews. - Endian fixes to RTP and vat packet dumpers, thanks to Bruce Mah (bmah@cs.berkeley.edu). - Added support for new dns types, thanks to Rainer Orth. - Fixed tftp_print() to print the block number for ACKs. - Document -dd and -ddd. Resulted from a bug report from Charlie Slater (cslater@imatek.com). - Check return status from malloc/calloc/etc. - Check return status from pcap_loop() so we can print an error and exit with a bad status if there were problems. - Bail if ip option length is <= 0. Resulted from a bug report from Darren Reed (darrenr@vitruvius.arbld.unimelb.edu.au). - Print out a little more information for sun rpc packets. - Add suport for Kerberos 4 thanks to John Hawkinson (jhawk@mit.edu). - Fixed the Fix EXTRACT_SHORT() and EXTRACT_LONG() macros (which were wrong on little endian machines). - Fixed alignment bug in ipx_decode(). Thanks to Matt Crawford (crawdad@fnal.gov). - Fix ntp_print() to not print garbage when the stratum is "unspecified." Thanks to Deus Ex Machina (root@belle.bork.com). - Rewrote tcp options printer code to check for truncation. Added selective acknowledgment case. - Fixed an endian bug in the ospf printer. Thanks to Jeffrey C Honig (jch@bsdi.com) - Fix rip printer to handle 4.4 BSD sockaddr struct which only uses one octet for the sa_family member. Thanks to Yoshitaka Tokugawa (toku@dit.co.jp) - Don't checksum ip header if we don't have all of it. Thanks to John Hawkinson (jhawk@mit.edu). - Print out hostnames if possible in egp printer. Thanks to Jeffrey Honig (jhc@bsdi.com) v3.1a1 Wed May 3 19:21:11 PDT 1995 - Include time.h when SVR4 is defined to avoid problems under Solaris 2.3. - Fix etheraddr_string() in the ETHER_SERVICE to return the saved strings, not the local buffer. Thanks to Stefan Petri (petri@ibr.cs.tu-bs.de). - Detect when pcap raises the snaplen (e.g. with snit). Print a warning that the selected value was not used. Thanks to Pascal Hennequin (Pascal.Hennequin@hugo.int-evry.fr). - Add a truncated packet test to print-nfs.c. Thanks to Pascal Hennequin. - BYTEORDER -> BYTE_ORDER Thanks to Terry Kennedy (terry@spcvxa.spc.edu). v3.0.3 Sun Oct 1 18:35:00 GMT 1995 - Although there never was a 3.0.3 release, the linux boys cleverly "released" one in late 1995. v3.0.2 Thu Apr 20 21:28:16 PDT 1995 - Change configuration to not use gcc v2 flags with gcc v1. - Redo gmt2local() so that it works under BSDI (which seems to return an empty timezone struct from gettimeofday()). Based on report from Terry Kennedy (terry@spcvxa.spc.edu). - Change configure to recognize IP[0-9]* as "mips" SGI hardware. Based on report from Mark Andrews (mandrews@alias.com). - Don't pass cc flags to gcc. Resulted from a bug report from Rainer Orth (ro@techfak.uni-bielefeld.de). - Fixed printout of connection id for uncompressed tcp slip packets. Resulted from a bug report from Richard Stevens (rstevens@noao.edu). - Hack around deficiency in Ultrix's make. - Add ETHERTYPE_TRAIL define which is missing from irix5. v3.0.1 Wed Aug 31 22:42:26 PDT 1994 - Fix problems with gcc2 vs. malloc() and read() prototypes under SunOS 4. v3.0 Mon Jun 20 19:23:27 PDT 1994 - Added support for printing tcp option timestamps thanks to Mark Andrews (mandrews@alias.com). - Reorganize protocol dumpers to take const pointers to packets so they never change the contents (i.e., they used to do endian conversions in place). Previously, whenever more than one pass was taken over the packet, the packet contents would be dumped incorrectly (i.e., the output form -x would be wrong on little endian machines because the protocol dumpers would modify the data). Thanks to Charles Hannum (mycroft@gnu.ai.mit.edu) for reporting this problem. - Added support for decnet protocol dumping thanks to Jeff Mogul (mogul@pa.dec.com). - Fix bug that caused length of packet to be incorrectly printed (off by ether header size) for unknown ethernet types thanks to Greg Miller (gmiller@kayak.mitre.org). - Added support for IPX protocol dumping thanks to Brad Parker (brad@fcr.com). - Added check to verify IP header checksum under -v thanks to Brad Parker (brad@fcr.com). - Move packet capture code to new libpcap library (which is packaged separately). - Prototype everything and assume an ansi compiler. - print-arp.c: Print hardware ethernet addresses if they're not what we expect. - print-bootp.c: Decode the cmu vendor field. Add RFC1497 tags. Many helpful suggestions from Gordon Ross (gwr@jericho.mc.com). - print-fddi.c: Improvements. Thanks to Jeffrey Mogul (mogul@pa.dec.com). - print-icmp.c: Byte swap netmask before printing. Thanks to Richard Stevens (rstevens@noao.edu). Print icmp type when unknown. - print-ip.c: Print the inner ip datagram of ip-in-ip encapsulated packets. By default, only the inner packet is dumped, appended with the token "(encap)". Under -v, both the inner and output packets are dumped (on the same line). Note that the filter applies to the original packet, not the encapsulated packet. So if you run tcpdump on a net with an IP Multicast tunnel, you cannot filter out the datagrams using the conventional syntax. (You can filter away all the ip-in-ip traffic with "not ip proto 4".) - print-nfs.c: Keep pending rpc's in circular table. Add generic nfs header and remove os dependences. Thanks to Jeffrey Mogul. - print-ospf.c: Improvements. Thanks to Jeffrey Mogul. - tcpdump.c: Add -T flag allows interpretation of "vat", "wb", "rpc" (sunrpc) and rtp packets. Added "inbound" and "outbound" keywords Add && and || operators v2.2.1 Tue Jun 6 17:57:22 PDT 1992 - Fix bug with -c flag. v2.2 Fri May 22 17:19:41 PDT 1992 - savefile.c: Remove hack that shouldn't have been exported. Add truncate checks. - Added the 'icmp' keyword. For example, 'icmp[0] != 8 and icmp[0] != 0' matches non-echo/reply ICMP packets. - Many improvements to filter code optimizer. - Added 'multicast' keyword and extended the 'broadcast' keyword can now be so that protocol qualifications are allowed. For example, "ip broadcast" and "ether multicast" are valid filters. - Added support for monitoring the loopback interface (i.e. 'tcpdump -i lo'). Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) contributed the kernel patches to netinet/if_loop.c. - Added support for the Ungermann-Bass Ethernet on IBM/PC-RTs running AOS. Contact Jeffrey Honig (jch@MITCHELL.CIT.CORNELL.EDU) for the diffs. - Added EGP and OSPF printers, thanks to Jeffrey Honig. v2.1 Tue Jan 28 11:00:14 PST 1992 - Internal release (never publically exported). v2.0.1 Sun Jan 26 21:10:10 PDT - Various byte ordering fixes. - Add truncation checks. - inet.c: Support BSD style SIOCGIFCONF. - nametoaddr.c: Handle multi addresses for single host. - optimize.c: Rewritten. - pcap-bpf.c: don't choke when we get ptraced. only set promiscuous for broadcast nets. - print-atal.c: Fix an alignment bug (thanks to stanonik@nprdc.navy.mil) Add missing printf() argument. - print-bootp.c: First attempt at decoding the vendor buffer. - print-domain.c: Fix truncation checks. - print-icmp.c: Calculate length of packets from the ip header. - print-ip.c: Print frag id in decimal (so it's easier to match up with non-frags). Add support for ospf, egp and igmp. - print-nfs.c: Lots of changes. - print-ntp.c: Make some verbose output depend on -v. - print-snmp.c: New version from John LoVerso. - print-tcp.c: Print rfc1072 tcp options. - tcpdump.c: Print "0x" prefix for %x formats. Always print 6 digits (microseconds) worth of precision. Fix uid bugs. - A packet dumper has been added (thanks to Jeff Mogul of DECWRL). With this option, you can create an architecture independent binary trace file in real time, without the overhead of the packet printer. At a later time, the packets can be filtered (again) and printed. - BSD is supported. You must have BPF in your kernel. Since the filtering is now done in the kernel, fewer packets are dropped. In fact, with BPF and the packet dumper option, a measly Sun 3/50 can keep up with a busy network. - Compressed SLIP packets can now be dumped, provided you use our SLIP software and BPF. These packets are dumped as any other IP packet; the compressed headers are dumped with the '-e' option. - Machines with little-endian byte ordering are supported (thanks to Jeff Mogul). - Ultrix 4.0 is supported (also thanks to Jeff Mogul). - IBM RT and Stanford Enetfilter support has been added by Rayan Zachariassen . Tcpdump has been tested under both the vanilla Enetfilter interface, and the extended interface (#ifdef'd by IBMRTPC) present in the MERIT version of the Enetfilter. - TFTP packets are now printed (requests only). - BOOTP packets are now printed. - SNMP packets are now printed. (thanks to John LoVerso of Xylogics). - Sparc architectures, including the Sparcstation-1, are now supported thanks to Steve McCanne and Craig Leres. - SunOS 4 is now supported thanks to Micky Liu of Columbia University (micky@cunixc.cc.columbia.edu). - IP options are now printed. - RIP packets are now printed. - There's a -v flag that prints out more information than the default (e.g., it will enable printing of IP ttl, tos and id) and -q flag that prints out less (e.g., it will disable interpretation of AppleTalk-in-UDP). - The grammar has undergone substantial changes (if you have an earlier version of tcpdump, you should re-read the manual entry). The most useful change is the addition of an expression syntax that lets you filter on arbitrary fields or values in the packet. E.g., "ip[0] > 0x45" would print only packets with IP options, "tcp[13] & 3 != 0" would print only TCP SYN and FIN packets. The most painful change is that concatenation no longer means "and" -- e.g., you have to say "host foo and port bar" instead of "host foo port bar". The up side to this down is that repeated qualifiers can be omitted, making most filter expressions shorter. E.g., you can now say "ip host foo and (bar or baz)" to look at ip traffic between hosts foo and bar or between hosts foo and baz. [The old way of saying this was "ip host foo and (ip host bar or ip host baz)".] v2.0 Sun Jan 13 12:20:40 PST 1991 - Initial public release. Index: vendor/tcpdump/dist/CONTRIBUTING =================================================================== --- vendor/tcpdump/dist/CONTRIBUTING (revision 353143) +++ vendor/tcpdump/dist/CONTRIBUTING (revision 353144) @@ -1,151 +1,151 @@ Some Information for Contributors --------------------------------- You want to contribute to Tcpdump, Thanks! Please, read these lines. How to report bugs and other problems ------------------------------------- To report a security issue (segfault, buffer overflow, infinite loop, arbitrary code execution etc) please send an e-mail to security@tcpdump.org, do not use the bug tracker! To report a non-security problem (failure to compile, incorrect output in the protocol printout, missing support for a particular protocol etc) please check first that it reproduces with the latest stable release of tcpdump and the latest stable release of libpcap. If it does, please check that the problem reproduces with the current git master branch of tcpdump and the current git master branch of libpcap. If it does (and it is not a security-related problem, otherwise see above), please navigate to https://github.com/the-tcpdump-group/tcpdump/issues and check if the problem has already been reported. If it has not, please open a new issue and provide the following details: * tcpdump and libpcap version (tcpdump --version) * operating system name and version and any other details that may be relevant (uname -a, compiler name and version, CPU type etc.) * configure flags if any were used * statement of the problem * steps to reproduce Please note that if you know exactly how to solve the problem and the solution would not be too intrusive, it would be best to contribute some development time and open a pull request instead as discussed below. -Still not sure how to do? Feel free to [subscribe](http://www.tcpdump.org/#mailing-lists) +Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists) to the mailing list tcpdump-workers@lists.tcpdump.org and ask! How to add new code and to update existing code ----------------------------------------------- 0) Check that there isn't a pull request already opened for the changes you intend to make. 1) Fork the Tcpdump repository on GitHub from https://github.com/the-tcpdump-group/tcpdump (See https://help.github.com/articles/fork-a-repo/) 2) Setup an optional Travis-CI build You can setup a travis build for your fork. So, you can test your changes on Linux and OSX before sending pull requests. (See http://docs.travis-ci.com/user/getting-started/) 3) Setup your git working copy git clone https://github.com//tcpdump.git cd tcpdump git remote add upstream https://github.com/the-tcpdump-group/tcpdump git fetch upstream 4) Do a 'touch .devel' in your working directory. Currently, the effect is a) add (via configure, in Makefile) some warnings options ( -Wall -Wmissing-prototypes -Wstrict-prototypes, ...) to the compiler if it supports these options, b) have the Makefile support "make depend" and the configure script run it. 5) Configure and build ./configure && make -s && make check 6) Add/update sample.pcap files We use tests directory to do regression tests on the dissection of captured packets, by running tcpdump against a savefile sample.pcap, created with -w option and comparing the results with a text file sample.out giving the expected results. Any new/updated fields in a dissector must be present in a sample.pcap file and the corresponding output file. Configuration is set in tests/TESTLIST. Each line in this file has the following format: test-name sample.pcap sample.out tcpdump-options the sample.out file can be build by: (cd tests && ../tcpdump -n -r sample.pcap tcpdump-options > sample.out) It is often useful to have test outputs with different verbosity levels (none, -v, -vv, -vvv, etc.) depending on the code. 7) Test with 'make check' Don't send a pull request if 'make check' gives failed tests. 8) Try to rebase your commits to keep the history simple. git rebase upstream/master (If the rebase fails and you cannot resolve, issue "git rebase --abort" and ask for help in the pull request comment.) 9) Once 100% happy, put your work into your forked repository. git push 10) Initiate and send a pull request (See https://help.github.com/articles/using-pull-requests/) Code style and generic remarks ------------------------------ a) A thorough reading of some other printers code is useful. b) Put the normative reference if any as comments (RFC, etc.). c) Put the format of packets/headers/options as comments if there is no published normative reference. d) The printer may receive incomplete packet in the buffer, truncated at any random position, for example by capturing with '-s size' option. Thus use ND_TTEST, ND_TTEST2, ND_TCHECK or ND_TCHECK2 for bound checking. For ND_TCHECK2: Define : static const char tstr[] = " [|protocol]"; Define a label: trunc Print with: ND_PRINT((ndo, "%s", tstr)); You can test the code via: sudo ./tcpdump -s snaplen [-v][v][...] -i lo # in a terminal sudo tcpreplay -i lo sample.pcap # in another terminal You should try several values for snaplen to do various truncation. e) Do invalid packet checks in code: Think that your code can receive in input not only a valid packet but any arbitrary random sequence of octets (packet - built malformed originally by the sender or by a fuzz tester, - became corrupted in transit). Print with: ND_PRINT((ndo, "%s", istr)); /* to print " (invalid)" */ f) Use 'struct tok' for indexed strings and print them with tok2str() or bittok2str() (for flags). g) Avoid empty lines in output of printers. h) A commit message must have: First line: Capitalized short summary in the imperative (70 chars or less) Body: Detailed explanatory text, if necessary. Fold it to approximately 72 characters. There must be an empty line separating the summary from the body. i) Avoid non-ASCII characters in code and commit messages. j) Use the style of the modified sources. k) Don't mix declarations and code l) Don't use // for comments Not all C compilers accept C++/C99 comments by default. m) Avoid trailing tabs/spaces Index: vendor/tcpdump/dist/INSTALL.txt =================================================================== --- vendor/tcpdump/dist/INSTALL.txt (revision 353143) +++ vendor/tcpdump/dist/INSTALL.txt (revision 353144) @@ -1,123 +1,123 @@ If you have not built libpcap, and your system does not have libpcap installed, install libpcap first. Your system might provide a version of libpcap that can be installed; if so, to compile tcpdump you might need to install a "developer" version of libpcap as well as the "run-time" version. You can also install tcpdump.org's version of libpcap; see the README file in this directory for the ftp location. You will need an ANSI C compiler to build tcpdump. The configure script will abort if your compiler is not ANSI compliant. If this happens, use the generally available GNU C compiler (GCC). After libpcap has been built (either install it with "make install" or make sure both the libpcap and tcpdump source trees are in the same directory), run ./configure (a shell script). "configure" will determine your system attributes and generate an appropriate Makefile from Makefile.in. Now build tcpdump by running "make". If everything builds ok, su and type "make install". This will install tcpdump and the manual entry. Any user will be able to use tcpdump to read saved captures. Whether a user will be able to capture traffic depends on the OS and the configuration of the system; see the tcpdump man page for details. DO NOT give untrusted users the ability to capture traffic. If a user can capture traffic, he or she could use utilities such as tcpdump to capture any traffic on your net, including passwords. Note that most systems ship tcpdump, but usually an older version. Remember to remove or rename the installed binary when upgrading. If your system is not one which we have tested tcpdump on, you may have to modify the configure script and Makefile.in. Please send us patches for any modifications you need to make. Please see "PLATFORMS" for notes about tested platforms. FILES ----- CHANGES - description of differences between releases CONTRIBUTING - guidelines for contributing CREDITS - people that have helped tcpdump along INSTALL.txt - this file LICENSE - the license under which tcpdump is distributed Makefile.in - compilation rules (input to the configure script) README - description of distribution Readme.Win32 - notes on building tcpdump on Win32 systems (with WinPcap) VERSION - version of this release aclocal.m4 - autoconf macros addrtoname.c - address to hostname routines addrtoname.h - address to hostname definitions ah.h - IPSEC Authentication Header definitions appletalk.h - AppleTalk definitions ascii_strcasecmp.c - locale-independent case-independent string comparison routines atime.awk - TCP ack awk script atm.h - ATM traffic type definitions bpf_dump.c - BPF program printing routines, in case libpcap doesn't have them chdlc.h - Cisco HDLC definitions cpack.c - functions to extract packed data cpack.h - declarations of functions to extract packed data config.guess - autoconf support config.h.in - autoconf input config.sub - autoconf support configure - configure script (run this first) -configure.in - configure script source +configure.ac - configure script source ether.h - Ethernet definitions ethertype.h - Ethernet type value definitions extract.h - alignment definitions gmpls.c - GMPLS definitions gmpls.h - GMPLS declarations gmt2local.c - time conversion routines gmt2local.h - time conversion prototypes install-sh - BSD style install script interface.h - globals, prototypes and definitions ip.h - IP definitions ip6.h - IPv6 definitions ipproto.c - IP protocol type value-to-name table ipproto.h - IP protocol type value definitions l2vpn.c - L2VPN encapsulation value-to-name table l2vpn.h - L2VPN encapsulation definitions lbl/os-*.h - OS-dependent defines and prototypes llc.h - LLC definitions machdep.c - machine dependent routines machdep.h - machine dependent definitions makemib - mib to header script mib.h - mib definitions missing/* - replacements for missing library functions mkdep - construct Makefile dependency list mpls.h - MPLS definitions nameser.h - DNS definitions netdissect.h - definitions and declarations for tcpdump-as-library (under development) nfs.h - Network File System V2 definitions nfsfh.h - Network File System file handle definitions nlpid.c - OSI NLPID value-to-name table nlpid.h - OSI NLPID definitions ospf.h - 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 ppp.h - Point to Point Protocol definitions print.c - Top-level routines for protocol printing print-*.c - The netdissect printers rpc_auth.h - definitions for ONC RPC authentication rpc_msg.h - definitions for ONC RPC messages send-ack.awk - unidirectional tcp send/ack awk script setsignal.c - OS-independent signal routines setsignal.h - OS-independent signal prototypes slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions smb.h - SMB/CIFS definitions smbutil.c - SMB/CIFS utility routines stime.awk - TCP send awk script tcp.h - TCP definitions tcpdump.1 - manual entry tcpdump.c - main program timeval-operations.h - timeval operations macros udp.h - UDP definitions util-print.c - utility routines for protocol printers vfprintf.c - emulation routine win32 - headers and routines for building on Win32 systems Index: vendor/tcpdump/dist/Makefile-devel-adds =================================================================== --- vendor/tcpdump/dist/Makefile-devel-adds (revision 353143) +++ vendor/tcpdump/dist/Makefile-devel-adds (revision 353144) @@ -1,22 +1,22 @@ # # Auto-regenerate configure script or Makefile when things change. # From autoconf.info . Works best with GNU Make. # -${srcdir}/configure: configure.in aclocal.m4 +${srcdir}/configure: configure.ac aclocal.m4 cd ${srcdir} && autoconf # autoheader might not change config.h.in, so touch a stamp file. ${srcdir}/config.h.in: ${srcdir}/stamp-h.in -${srcdir}/stamp-h.in: configure.in aclocal.m4 +${srcdir}/stamp-h.in: configure.ac aclocal.m4 cd ${srcdir} && autoheader echo timestamp > ${srcdir}/stamp-h.in config.h: stamp-h stamp-h: ${srcdir}/config.h.in config.status ./config.status Makefile: Makefile.in config.status ./config.status config.status: ${srcdir}/configure ./config.status --recheck Index: vendor/tcpdump/dist/Makefile.in =================================================================== --- vendor/tcpdump/dist/Makefile.in (revision 353143) +++ vendor/tcpdump/dist/Makefile.in (revision 353144) @@ -1,463 +1,463 @@ # Copyright (c) 1988, 1989, 1990, 1991, 1992, 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. # # Various configurable paths (remember to edit Makefile.in, not Makefile) # # Top level hierarchy prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ # Pathname of directory to install the binary sbindir = @sbindir@ # Pathname of directory to install the man page mandir = @mandir@ # VPATH srcdir = @srcdir@ VPATH = @srcdir@ # # You shouldn't need to edit anything below here. # CC = @CC@ AR = @AR@ MKDEP = @MKDEP@ PROG = tcpdump CCOPT = @V_CCOPT@ INCLS = -I. @V_INCLS@ DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@ # Standard CFLAGS CFLAGS = @CFLAGS@ FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS) # Standard LDFLAGS LDFLAGS = @LDFLAGS@ # Standard LIBS LIBS = @LIBS@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. # Also, gcc does not remove the .o before forking 'as', which can be a # problem if you don't own the file but can write to the directory. .c.o: @rm -f $@ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c CSRC = setsignal.c tcpdump.c LIBNETDISSECT_SRC=\ addrtoname.c \ addrtostr.c \ af.c \ ascii_strcasecmp.c \ checksum.c \ cpack.c \ gmpls.c \ gmt2local.c \ in_cksum.c \ ipproto.c \ l2vpn.c \ machdep.c \ nlpid.c \ oui.c \ parsenfsfh.c \ print.c \ print-802_11.c \ print-802_15_4.c \ print-ah.c \ print-ahcp.c \ print-aodv.c \ print-aoe.c \ print-ap1394.c \ print-arcnet.c \ print-arp.c \ print-ascii.c \ print-atalk.c \ print-atm.c \ print-babel.c \ print-beep.c \ print-bfd.c \ print-bgp.c \ print-bootp.c \ print-bt.c \ print-calm-fast.c \ print-carp.c \ print-cdp.c \ print-cfm.c \ print-chdlc.c \ print-cip.c \ print-cnfp.c \ print-dccp.c \ print-decnet.c \ print-dhcp6.c \ print-domain.c \ print-dtp.c \ print-dvmrp.c \ print-eap.c \ print-egp.c \ print-eigrp.c \ print-enc.c \ print-esp.c \ print-ether.c \ print-fddi.c \ print-forces.c \ print-fr.c \ print-frag6.c \ print-ftp.c \ print-geneve.c \ print-geonet.c \ print-gre.c \ print-hncp.c \ print-hsrp.c \ print-http.c \ print-icmp.c \ print-icmp6.c \ print-igmp.c \ print-igrp.c \ print-ip.c \ print-ip6.c \ print-ip6opts.c \ print-ipcomp.c \ print-ipfc.c \ print-ipnet.c \ print-ipx.c \ print-isakmp.c \ print-isoclns.c \ print-juniper.c \ print-krb.c \ print-l2tp.c \ print-lane.c \ print-ldp.c \ print-lisp.c \ print-llc.c \ print-lldp.c \ print-lmp.c \ print-loopback.c \ print-lspping.c \ print-lwapp.c \ print-lwres.c \ print-m3ua.c \ print-medsa.c \ print-mobile.c \ print-mobility.c \ print-mpcp.c \ print-mpls.c \ print-mptcp.c \ print-msdp.c \ print-msnlb.c \ print-nflog.c \ print-nfs.c \ print-nsh.c \ print-ntp.c \ print-null.c \ print-olsr.c \ print-openflow-1.0.c \ print-openflow.c \ print-ospf.c \ print-ospf6.c \ print-otv.c \ print-pgm.c \ print-pim.c \ print-pktap.c \ print-ppi.c \ print-ppp.c \ print-pppoe.c \ print-pptp.c \ print-radius.c \ print-raw.c \ print-resp.c \ print-rip.c \ print-ripng.c \ print-rpki-rtr.c \ print-rrcp.c \ print-rsvp.c \ print-rt6.c \ print-rtsp.c \ print-rx.c \ print-sctp.c \ print-sflow.c \ print-sip.c \ print-sl.c \ print-sll.c \ print-slow.c \ print-smtp.c \ print-snmp.c \ print-stp.c \ print-sunatm.c \ print-sunrpc.c \ print-symantec.c \ print-syslog.c \ print-tcp.c \ print-telnet.c \ print-tftp.c \ print-timed.c \ print-tipc.c \ print-token.c \ print-udld.c \ print-udp.c \ print-usb.c \ print-vjc.c \ print-vqp.c \ print-vrrp.c \ print-vtp.c \ print-vxlan.c \ print-vxlan-gpe.c \ print-wb.c \ print-zephyr.c \ print-zeromq.c \ netdissect.c \ signature.c \ strtoaddr.c \ util-print.c LOCALSRC = @LOCALSRC@ GENSRC = version.c LIBOBJS = @LIBOBJS@ LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS} LIBNETDISSECT=libnetdissect.a SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC) # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot # hack the extra indirection OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ) HDR = \ addrtoname.h \ addrtostr.h \ af.h \ ah.h \ appletalk.h \ ascii_strcasecmp.h \ atm.h \ chdlc.h \ cpack.h \ ether.h \ ethertype.h \ extract.h \ funcattrs.h \ getopt_long.h \ gmpls.h \ gmt2local.h \ interface.h \ ip.h \ ip6.h \ ipproto.h \ l2vpn.h \ llc.h \ machdep.h \ mib.h \ mpls.h \ nameser.h \ netdissect.h \ nfs.h \ nfsfh.h \ nlpid.h \ openflow.h \ ospf.h \ oui.h \ pcap-missing.h \ ppp.h \ print.h \ rpc_auth.h \ rpc_msg.h \ rpl.h \ setsignal.h \ signature.h \ slcompress.h \ smb.h \ strtoaddr.h \ tcp.h \ netdissect-stdinc.h \ timeval-operations.h \ udp.h TAGHDR = \ /usr/include/arpa/tftp.h \ /usr/include/net/if_arp.h \ /usr/include/netinet/if_ether.h \ /usr/include/netinet/in.h \ /usr/include/netinet/ip_icmp.h \ /usr/include/netinet/tcp.h \ /usr/include/netinet/udp.h \ /usr/include/protocols/routed.h TAGFILES = $(SRC) $(HDR) $(TAGHDR) CLEANFILES = $(PROG) $(OBJ) $(GENSRC) EXTRA_DIST = \ CHANGES \ CONTRIBUTING \ CREDITS \ INSTALL.txt \ LICENSE \ Makefile.in \ Makefile-devel-adds \ PLATFORMS \ README \ README.md \ Readme.Win32 \ VERSION \ aclocal.m4 \ atime.awk \ bpf_dump.c \ config.guess \ config.h.in \ config.sub \ configure \ - configure.in \ + configure.ac \ install-sh \ lbl/os-osf4.h \ lbl/os-solaris2.h \ lbl/os-sunos4.h \ lbl/os-ultrix4.h \ makemib \ missing/dlnames.c \ missing/datalinks.c \ missing/getopt_long.c \ missing/snprintf.c \ missing/strdup.c \ missing/strlcat.c \ missing/strlcpy.c \ missing/strsep.c \ mkdep \ packetdat.awk \ pcap_dump_ftell.c \ print-pflog.c \ print-smb.c \ send-ack.awk \ smbutil.c \ stime.awk \ tcpdump.1.in \ vfprintf.c \ win32/prj/GNUmakefile \ win32/prj/WinDump.dsp \ win32/prj/WinDump.dsw \ win32/prj/WinDump.sln \ win32/prj/WinDump.vcproj \ win32/src/ether_ntohost.c -TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print` +TEST_DIST= `git ls-files tests | grep -v 'tests/\..*'` all: $(PROG) $(LIBNETDISSECT) $(PROG): $(OBJ) @V_PCAPDEP@ @rm -f $@ $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(LIBNETDISSECT): $(LIBNETDISSECT_OBJ) @rm -f $@ $(AR) cr $@ $(LIBNETDISSECT_OBJ) $(RANLIB) $@ datalinks.o: $(srcdir)/missing/datalinks.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c dlnames.o: $(srcdir)/missing/dlnames.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c getopt_long.o: $(srcdir)/missing/getopt_long.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c snprintf.o: $(srcdir)/missing/snprintf.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c strdup.o: $(srcdir)/missing/strdup.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strdup.c strlcat.o: $(srcdir)/missing/strlcat.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c strlcpy.o: $(srcdir)/missing/strlcpy.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c strsep.o: $(srcdir)/missing/strsep.c $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c version.o: version.c $(CC) $(FULL_CFLAGS) -c version.c version.c: $(srcdir)/VERSION @rm -f $@ if grep GIT ${srcdir}/VERSION >/dev/null; then \ read ver <${srcdir}/VERSION; \ echo $$ver | tr -d '\012'; \ date +_%Y_%m_%d; \ else \ cat ${srcdir}/VERSION; \ fi | sed -e 's/.*/const char version[] = "&";/' > $@ install: all [ -d $(DESTDIR)$(sbindir) ] || \ (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir)) $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG) $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG).`cat ${srcdir}/VERSION` [ -d $(DESTDIR)$(mandir)/man1 ] || \ (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) $(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1 uninstall: rm -f $(DESTDIR)$(sbindir)/$(PROG) rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1 lint: $(GENSRC) lint -hbxn $(SRC) | \ grep -v 'struct/union .* never defined' | \ grep -v 'possible pointer alignment problem' clean: rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz distclean: rm -f $(CLEANFILES) Makefile config.cache config.log config.status \ config.h gnuc.h os-proto.h stamp-h stamp-h.in $(PROG).1 \ libnetdissect.a tests/.failed tests/.passed \ tests/failure-outputs.txt rm -rf autom4te.cache tests/DIFF tests/NEW check: tcpdump - (cd tests && ./TESTrun.sh) + (mkdir -p tests && SRCDIR=`cd ${srcdir}; pwd` && export SRCDIR && $$SRCDIR/tests/TESTrun.sh ) extags: $(TAGFILES) ctags $(TAGFILES) tags: $(TAGFILES) ctags -wtd $(TAGFILES) TAGS: $(TAGFILES) etags $(TAGFILES) releasetar: @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ mkdir $$name; \ tar cf - $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) $(TEST_DIST) | (cd $$name; tar xf -); \ tar -c -z -f $$name.tar.gz $$name; \ rm -rf $$name testlist: echo $(TEST_DIST) depend: $(GENSRC) $(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC) Index: vendor/tcpdump/dist/Readme.Win32 =================================================================== --- vendor/tcpdump/dist/Readme.Win32 (revision 353143) +++ vendor/tcpdump/dist/Readme.Win32 (revision 353144) @@ -1,24 +1,24 @@ To build tcpdump under Windows, you need: - version 6 (or higher) of Microsoft Visual Studio or the Cygnus gnu C compiler. - The November 2001 (or later) edition of Microsoft Platform Software Development Kit (SDK), that contains some necessary includes for IPv6 support. You can download it from http://www.microsoft.com/sdk - the WinPcap source code, that includes libpcap for win32. Download it from http://winpcap.polito.it or download libpcap sources from -http://www.tcpdump.org and follow the instructions in the README.Win32 +https://www.tcpdump.org and follow the instructions in the README.Win32 file. First, extract tcpdump and WinPcap in the same folder, and build WinPcap. The Visual Studio project and the cygwin makefile are in the Win32\prj folder. From Visual Studio, open windump.dsw and build the program. The release version of the WinDump.exe executable file will be created in the windump\win32\prj\release directory . The debug version will be generated in windump\win32\prj\debug. From cygnus, go to windump\win32\prj\ and type "make". WinDump.exe will be created in the same directory. \ No newline at end of file Index: vendor/tcpdump/dist/VERSION =================================================================== --- vendor/tcpdump/dist/VERSION (revision 353143) +++ vendor/tcpdump/dist/VERSION (revision 353144) @@ -1 +1 @@ -4.9.2 +4.9.3 Index: vendor/tcpdump/dist/addrtoname.c =================================================================== --- vendor/tcpdump/dist/addrtoname.c (revision 353143) +++ vendor/tcpdump/dist/addrtoname.c (revision 353144) @@ -1,1285 +1,1282 @@ /* * Copyright (c) 1990, 1991, 1992, 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. * * Internet, ethernet, port, and protocol string to address * and address to string conversion routines */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #ifdef USE_ETHER_NTOHOST #ifdef HAVE_NETINET_IF_ETHER_H struct mbuf; /* Squelch compiler warnings on some platforms for */ struct rtentry; /* declarations in */ #include /* for "struct ifnet" in "struct arpcom" on Solaris */ #include #endif /* HAVE_NETINET_IF_ETHER_H */ #ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST #include #endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */ #if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST #ifndef HAVE_STRUCT_ETHER_ADDR struct ether_addr { unsigned char ether_addr_octet[6]; }; #endif extern int ether_ntohost(char *, const struct ether_addr *); #endif #endif /* USE_ETHER_NTOHOST */ #include #include #include #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "addrtostr.h" #include "ethertype.h" #include "llc.h" #include "setsignal.h" #include "extract.h" #include "oui.h" #ifndef ETHER_ADDR_LEN #define ETHER_ADDR_LEN 6 #endif /* * hash tables for whatever-to-name translations * * ndo_error() called on strdup(3) failure */ #define HASHNAMESIZE 4096 struct hnamemem { uint32_t addr; const char *name; struct hnamemem *nxt; }; static struct hnamemem hnametable[HASHNAMESIZE]; static struct hnamemem tporttable[HASHNAMESIZE]; static struct hnamemem uporttable[HASHNAMESIZE]; static struct hnamemem eprototable[HASHNAMESIZE]; static struct hnamemem dnaddrtable[HASHNAMESIZE]; static struct hnamemem ipxsaptable[HASHNAMESIZE]; #ifdef _WIN32 /* * fake gethostbyaddr for Win2k/XP * gethostbyaddr() returns incorrect value when AF_INET6 is passed * to 3rd argument. * * h_name in struct hostent is only valid. */ static struct hostent * win32_gethostbyaddr(const char *addr, int len, int type) { static struct hostent host; static char hostbuf[NI_MAXHOST]; char hname[NI_MAXHOST]; struct sockaddr_in6 addr6; host.h_name = hostbuf; switch (type) { case AF_INET: return gethostbyaddr(addr, len, type); break; case AF_INET6: memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; memcpy(&addr6.sin6_addr, addr, len); if (getnameinfo((struct sockaddr *)&addr6, sizeof(addr6), hname, sizeof(hname), NULL, 0, 0)) { return NULL; } else { - strcpy(host.h_name, hname); + strlcpy(host.h_name, hname, NI_MAXHOST); return &host; } break; default: return NULL; } } #define gethostbyaddr win32_gethostbyaddr #endif /* _WIN32 */ struct h6namemem { struct in6_addr addr; char *name; struct h6namemem *nxt; }; static struct h6namemem h6nametable[HASHNAMESIZE]; struct enamemem { u_short e_addr0; u_short e_addr1; u_short e_addr2; const char *e_name; u_char *e_nsap; /* used only for nsaptable[] */ struct enamemem *e_nxt; }; static struct enamemem enametable[HASHNAMESIZE]; static struct enamemem nsaptable[HASHNAMESIZE]; struct bsnamemem { u_short bs_addr0; u_short bs_addr1; u_short bs_addr2; const char *bs_name; u_char *bs_bytes; unsigned int bs_nbytes; struct bsnamemem *bs_nxt; }; static struct bsnamemem bytestringtable[HASHNAMESIZE]; struct protoidmem { uint32_t p_oui; u_short p_proto; const char *p_name; struct protoidmem *p_nxt; }; static struct protoidmem protoidtable[HASHNAMESIZE]; /* * A faster replacement for inet_ntoa(). */ const char * intoa(uint32_t addr) { register char *cp; register u_int byte; register int n; static char buf[sizeof(".xxx.xxx.xxx.xxx")]; NTOHL(addr); cp = buf + sizeof(buf); *--cp = '\0'; n = 4; do { byte = addr & 0xff; *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) { *--cp = byte % 10 + '0'; byte /= 10; if (byte > 0) *--cp = byte + '0'; } *--cp = '.'; addr >>= 8; } while (--n > 0); return cp + 1; } static uint32_t f_netmask; static uint32_t f_localnet; /* * Return a name for the IP address pointed to by ap. This address * is assumed to be in network byte order. * * NOTE: ap is *NOT* necessarily part of the packet data (not even if * this is being called with the "ipaddr_string()" macro), so you * *CANNOT* use the ND_TCHECK{2}/ND_TTEST{2} macros on it. Furthermore, * even in cases where it *is* part of the packet data, the caller * would still have to check for a null return value, even if it's * just printing the return value with "%s" - not all versions of * printf print "(null)" with "%s" and a null pointer, some of them * don't check for a null pointer and crash in that case. * * The callers of this routine should, before handing this routine * a pointer to packet data, be sure that the data is present in * the packet buffer. They should probably do those checks anyway, * as other data at that layer might not be IP addresses, and it * also needs to check whether they're present in the packet buffer. */ const char * getname(netdissect_options *ndo, const u_char *ap) { register struct hostent *hp; uint32_t addr; struct hnamemem *p; memcpy(&addr, ap, sizeof(addr)); p = &hnametable[addr & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (p->addr == addr) return (p->name); } p->addr = addr; p->nxt = newhnamemem(ndo); /* * Print names unless: * (1) -n was given. * (2) Address is foreign and -f was given. (If -f was not * given, f_netmask and f_localnet are 0 and the test * evaluates to true) */ if (!ndo->ndo_nflag && (addr & f_netmask) == f_localnet) { hp = gethostbyaddr((char *)&addr, 4, AF_INET); if (hp) { char *dotp; p->name = strdup(hp->h_name); if (p->name == NULL) (*ndo->ndo_error)(ndo, "getname: strdup(hp->h_name)"); if (ndo->ndo_Nflag) { /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = '\0'; } return (p->name); } } p->name = strdup(intoa(addr)); if (p->name == NULL) (*ndo->ndo_error)(ndo, "getname: strdup(intoa(addr))"); return (p->name); } /* * Return a name for the IP6 address pointed to by ap. This address * is assumed to be in network byte order. */ const char * getname6(netdissect_options *ndo, const u_char *ap) { register struct hostent *hp; union { struct in6_addr addr; struct for_hash_addr { char fill[14]; uint16_t d; } addra; } addr; struct h6namemem *p; register const char *cp; char ntop_buf[INET6_ADDRSTRLEN]; memcpy(&addr, ap, sizeof(addr)); p = &h6nametable[addr.addra.d & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (memcmp(&p->addr, &addr, sizeof(addr)) == 0) return (p->name); } p->addr = addr.addr; p->nxt = newh6namemem(ndo); /* * Do not print names if -n was given. */ if (!ndo->ndo_nflag) { hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6); if (hp) { char *dotp; p->name = strdup(hp->h_name); if (p->name == NULL) (*ndo->ndo_error)(ndo, "getname6: strdup(hp->h_name)"); if (ndo->ndo_Nflag) { /* Remove domain qualifications */ dotp = strchr(p->name, '.'); if (dotp) *dotp = '\0'; } return (p->name); } } cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf)); p->name = strdup(cp); if (p->name == NULL) (*ndo->ndo_error)(ndo, "getname6: strdup(cp)"); return (p->name); } static const char hex[16] = "0123456789abcdef"; /* Find the hash node that corresponds the ether address 'ep' */ static inline struct enamemem * lookup_emem(netdissect_options *ndo, const u_char *ep) { register u_int i, j, k; struct enamemem *tp; k = (ep[0] << 8) | ep[1]; j = (ep[2] << 8) | ep[3]; i = (ep[4] << 8) | ep[5]; tp = &enametable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->e_nxt) if (tp->e_addr0 == i && tp->e_addr1 == j && tp->e_addr2 == k) return tp; else tp = tp->e_nxt; tp->e_addr0 = i; tp->e_addr1 = j; tp->e_addr2 = k; tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); if (tp->e_nxt == NULL) (*ndo->ndo_error)(ndo, "lookup_emem: calloc"); return tp; } /* * Find the hash node that corresponds to the bytestring 'bs' * with length 'nlen' */ static inline struct bsnamemem * lookup_bytestring(netdissect_options *ndo, register const u_char *bs, const unsigned int nlen) { struct bsnamemem *tp; register u_int i, j, k; if (nlen >= 6) { k = (bs[0] << 8) | bs[1]; j = (bs[2] << 8) | bs[3]; i = (bs[4] << 8) | bs[5]; } else if (nlen >= 4) { k = (bs[0] << 8) | bs[1]; j = (bs[2] << 8) | bs[3]; i = 0; } else i = j = k = 0; tp = &bytestringtable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->bs_nxt) if (nlen == tp->bs_nbytes && tp->bs_addr0 == i && tp->bs_addr1 == j && tp->bs_addr2 == k && memcmp((const char *)bs, (const char *)(tp->bs_bytes), nlen) == 0) return tp; else tp = tp->bs_nxt; tp->bs_addr0 = i; tp->bs_addr1 = j; tp->bs_addr2 = k; tp->bs_bytes = (u_char *) calloc(1, nlen); if (tp->bs_bytes == NULL) (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc"); memcpy(tp->bs_bytes, bs, nlen); tp->bs_nbytes = nlen; tp->bs_nxt = (struct bsnamemem *)calloc(1, sizeof(*tp)); if (tp->bs_nxt == NULL) (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc"); return tp; } /* Find the hash node that corresponds the NSAP 'nsap' */ static inline struct enamemem * lookup_nsap(netdissect_options *ndo, register const u_char *nsap, register u_int nsap_length) { register u_int i, j, k; struct enamemem *tp; const u_char *ensap; if (nsap_length > 6) { ensap = nsap + nsap_length - 6; k = (ensap[0] << 8) | ensap[1]; j = (ensap[2] << 8) | ensap[3]; i = (ensap[4] << 8) | ensap[5]; } else i = j = k = 0; tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->e_nxt) if (nsap_length == tp->e_nsap[0] && tp->e_addr0 == i && tp->e_addr1 == j && tp->e_addr2 == k && memcmp((const char *)nsap, (char *)&(tp->e_nsap[1]), nsap_length) == 0) return tp; else tp = tp->e_nxt; tp->e_addr0 = i; tp->e_addr1 = j; tp->e_addr2 = k; tp->e_nsap = (u_char *)malloc(nsap_length + 1); if (tp->e_nsap == NULL) (*ndo->ndo_error)(ndo, "lookup_nsap: malloc"); tp->e_nsap[0] = (u_char)nsap_length; /* guaranteed < ISONSAP_MAX_LENGTH */ memcpy((char *)&tp->e_nsap[1], (const char *)nsap, nsap_length); tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp)); if (tp->e_nxt == NULL) (*ndo->ndo_error)(ndo, "lookup_nsap: calloc"); return tp; } /* Find the hash node that corresponds the protoid 'pi'. */ static inline struct protoidmem * lookup_protoid(netdissect_options *ndo, const u_char *pi) { register u_int i, j; struct protoidmem *tp; /* 5 octets won't be aligned */ i = (((pi[0] << 8) + pi[1]) << 8) + pi[2]; j = (pi[3] << 8) + pi[4]; /* XXX should be endian-insensitive, but do big-endian testing XXX */ tp = &protoidtable[(i ^ j) & (HASHNAMESIZE-1)]; while (tp->p_nxt) if (tp->p_oui == i && tp->p_proto == j) return tp; else tp = tp->p_nxt; tp->p_oui = i; tp->p_proto = j; tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp)); if (tp->p_nxt == NULL) (*ndo->ndo_error)(ndo, "lookup_protoid: calloc"); return tp; } const char * etheraddr_string(netdissect_options *ndo, register const u_char *ep) { register int i; register char *cp; register struct enamemem *tp; int oui; char buf[BUFSIZE]; tp = lookup_emem(ndo, ep); if (tp->e_name) return (tp->e_name); #ifdef USE_ETHER_NTOHOST if (!ndo->ndo_nflag) { char buf2[BUFSIZE]; if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) { tp->e_name = strdup(buf2); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf2)"); return (tp->e_name); } } #endif cp = buf; oui = EXTRACT_24BITS(ep); *cp++ = hex[*ep >> 4 ]; *cp++ = hex[*ep++ & 0xf]; for (i = 5; --i >= 0;) { *cp++ = ':'; *cp++ = hex[*ep >> 4 ]; *cp++ = hex[*ep++ & 0xf]; } if (!ndo->ndo_nflag) { snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)", tok2str(oui_values, "Unknown", oui)); } else *cp = '\0'; tp->e_name = strdup(buf); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf)"); return (tp->e_name); } const char * le64addr_string(netdissect_options *ndo, const u_char *ep) { const unsigned int len = 8; register u_int i; register char *cp; register struct bsnamemem *tp; char buf[BUFSIZE]; tp = lookup_bytestring(ndo, ep, len); if (tp->bs_name) return (tp->bs_name); cp = buf; for (i = len; i > 0 ; --i) { *cp++ = hex[*(ep + i - 1) >> 4]; *cp++ = hex[*(ep + i - 1) & 0xf]; *cp++ = ':'; } cp --; *cp = '\0'; tp->bs_name = strdup(buf); if (tp->bs_name == NULL) (*ndo->ndo_error)(ndo, "le64addr_string: strdup(buf)"); return (tp->bs_name); } const char * linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int type, const unsigned int len) { register u_int i; register char *cp; register struct bsnamemem *tp; if (len == 0) return (""); if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) return (etheraddr_string(ndo, ep)); if (type == LINKADDR_FRELAY) return (q922_string(ndo, ep, len)); tp = lookup_bytestring(ndo, ep, len); if (tp->bs_name) return (tp->bs_name); tp->bs_name = cp = (char *)malloc(len*3); if (tp->bs_name == NULL) (*ndo->ndo_error)(ndo, "linkaddr_string: malloc"); *cp++ = hex[*ep >> 4]; *cp++ = hex[*ep++ & 0xf]; for (i = len-1; i > 0 ; --i) { *cp++ = ':'; *cp++ = hex[*ep >> 4]; *cp++ = hex[*ep++ & 0xf]; } *cp = '\0'; return (tp->bs_name); } const char * etherproto_string(netdissect_options *ndo, u_short port) { register char *cp; register struct hnamemem *tp; register uint32_t i = port; char buf[sizeof("0000")]; for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(ndo); cp = buf; NTOHS(port); *cp++ = hex[port >> 12 & 0xf]; *cp++ = hex[port >> 8 & 0xf]; *cp++ = hex[port >> 4 & 0xf]; *cp++ = hex[port & 0xf]; *cp++ = '\0'; tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)"); return (tp->name); } const char * protoid_string(netdissect_options *ndo, register const u_char *pi) { register u_int i, j; register char *cp; register struct protoidmem *tp; char buf[sizeof("00:00:00:00:00")]; tp = lookup_protoid(ndo, pi); if (tp->p_name) return tp->p_name; cp = buf; if ((j = *pi >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*pi++ & 0xf]; for (i = 4; (int)--i >= 0;) { *cp++ = ':'; if ((j = *pi >> 4) != 0) *cp++ = hex[j]; *cp++ = hex[*pi++ & 0xf]; } *cp = '\0'; tp->p_name = strdup(buf); if (tp->p_name == NULL) (*ndo->ndo_error)(ndo, "protoid_string: strdup(buf)"); return (tp->p_name); } #define ISONSAP_MAX_LENGTH 20 const char * isonsap_string(netdissect_options *ndo, const u_char *nsap, register u_int nsap_length) { register u_int nsap_idx; register char *cp; register struct enamemem *tp; if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH) return ("isonsap_string: illegal length"); tp = lookup_nsap(ndo, nsap, nsap_length); if (tp->e_name) return tp->e_name; tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")); if (cp == NULL) (*ndo->ndo_error)(ndo, "isonsap_string: malloc"); for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) { *cp++ = hex[*nsap >> 4]; *cp++ = hex[*nsap++ & 0xf]; if (((nsap_idx & 1) == 0) && (nsap_idx + 1 < nsap_length)) { *cp++ = '.'; } } *cp = '\0'; return (tp->e_name); } const char * tcpport_string(netdissect_options *ndo, u_short port) { register struct hnamemem *tp; register uint32_t i = port; char buf[sizeof("00000")]; for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(ndo); (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)"); return (tp->name); } const char * udpport_string(netdissect_options *ndo, register u_short port) { register struct hnamemem *tp; register uint32_t i = port; char buf[sizeof("00000")]; for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(ndo); (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)"); return (tp->name); } const char * ipxsap_string(netdissect_options *ndo, u_short port) { register char *cp; register struct hnamemem *tp; register uint32_t i = port; char buf[sizeof("0000")]; for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) if (tp->addr == i) return (tp->name); tp->addr = i; tp->nxt = newhnamemem(ndo); cp = buf; NTOHS(port); *cp++ = hex[port >> 12 & 0xf]; *cp++ = hex[port >> 8 & 0xf]; *cp++ = hex[port >> 4 & 0xf]; *cp++ = hex[port & 0xf]; *cp++ = '\0'; tp->name = strdup(buf); if (tp->name == NULL) (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)"); return (tp->name); } static void init_servarray(netdissect_options *ndo) { struct servent *sv; register struct hnamemem *table; register int i; char buf[sizeof("0000000000")]; while ((sv = getservent()) != NULL) { int port = ntohs(sv->s_port); i = port & (HASHNAMESIZE-1); if (strcmp(sv->s_proto, "tcp") == 0) table = &tporttable[i]; else if (strcmp(sv->s_proto, "udp") == 0) table = &uporttable[i]; else continue; while (table->name) table = table->nxt; if (ndo->ndo_nflag) { (void)snprintf(buf, sizeof(buf), "%d", port); table->name = strdup(buf); } else table->name = strdup(sv->s_name); if (table->name == NULL) (*ndo->ndo_error)(ndo, "init_servarray: strdup"); table->addr = port; table->nxt = newhnamemem(ndo); } endservent(); } static const struct eproto { const char *s; u_short p; } eproto_db[] = { { "pup", ETHERTYPE_PUP }, { "xns", ETHERTYPE_NS }, { "ip", ETHERTYPE_IP }, { "ip6", ETHERTYPE_IPV6 }, { "arp", ETHERTYPE_ARP }, { "rarp", ETHERTYPE_REVARP }, { "sprite", ETHERTYPE_SPRITE }, { "mopdl", ETHERTYPE_MOPDL }, { "moprc", ETHERTYPE_MOPRC }, { "decnet", ETHERTYPE_DN }, { "lat", ETHERTYPE_LAT }, { "sca", ETHERTYPE_SCA }, { "lanbridge", ETHERTYPE_LANBRIDGE }, { "vexp", ETHERTYPE_VEXP }, { "vprod", ETHERTYPE_VPROD }, { "atalk", ETHERTYPE_ATALK }, { "atalkarp", ETHERTYPE_AARP }, { "loopback", ETHERTYPE_LOOPBACK }, { "decdts", ETHERTYPE_DECDTS }, { "decdns", ETHERTYPE_DECDNS }, { (char *)0, 0 } }; static void init_eprotoarray(netdissect_options *ndo) { register int i; register struct hnamemem *table; for (i = 0; eproto_db[i].s; i++) { int j = htons(eproto_db[i].p) & (HASHNAMESIZE-1); table = &eprototable[j]; while (table->name) table = table->nxt; table->name = eproto_db[i].s; table->addr = htons(eproto_db[i].p); table->nxt = newhnamemem(ndo); } } static const struct protoidlist { const u_char protoid[5]; const char *name; } protoidlist[] = { {{ 0x00, 0x00, 0x0c, 0x01, 0x07 }, "CiscoMLS" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x00 }, "CiscoCDP" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x01 }, "CiscoCGMP" }, {{ 0x00, 0x00, 0x0c, 0x20, 0x03 }, "CiscoVTP" }, {{ 0x00, 0xe0, 0x2b, 0x00, 0xbb }, "ExtremeEDP" }, {{ 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } }; /* * SNAP proto IDs with org code 0:0:0 are actually encapsulated Ethernet * types. */ static void init_protoidarray(netdissect_options *ndo) { register int i; register struct protoidmem *tp; const struct protoidlist *pl; u_char protoid[5]; protoid[0] = 0; protoid[1] = 0; protoid[2] = 0; for (i = 0; eproto_db[i].s; i++) { u_short etype = htons(eproto_db[i].p); memcpy((char *)&protoid[3], (char *)&etype, 2); tp = lookup_protoid(ndo, protoid); tp->p_name = strdup(eproto_db[i].s); if (tp->p_name == NULL) (*ndo->ndo_error)(ndo, "init_protoidarray: strdup(eproto_db[i].s)"); } /* Hardwire some SNAP proto ID names */ for (pl = protoidlist; pl->name != NULL; ++pl) { tp = lookup_protoid(ndo, pl->protoid); /* Don't override existing name */ if (tp->p_name != NULL) continue; tp->p_name = pl->name; } } static const struct etherlist { const u_char addr[6]; const char *name; } etherlist[] = { {{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, "Broadcast" }, {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, NULL } }; /* * Initialize the ethers hash table. We take two different approaches * depending on whether or not the system provides the ethers name * service. If it does, we just wire in a few names at startup, * and etheraddr_string() fills in the table on demand. If it doesn't, * then we suck in the entire /etc/ethers file at startup. The idea * is that parsing the local file will be fast, but spinning through * all the ethers entries via NIS & next_etherent might be very slow. * * XXX pcap_next_etherent doesn't belong in the pcap interface, but * since the pcap module already does name-to-address translation, * it's already does most of the work for the ethernet address-to-name * translation, so we just pcap_next_etherent as a convenience. */ static void init_etherarray(netdissect_options *ndo) { register const struct etherlist *el; register struct enamemem *tp; #ifdef USE_ETHER_NTOHOST char name[256]; #else register struct pcap_etherent *ep; register FILE *fp; /* Suck in entire ethers file */ fp = fopen(PCAP_ETHERS_FILE, "r"); if (fp != NULL) { while ((ep = pcap_next_etherent(fp)) != NULL) { tp = lookup_emem(ndo, ep->addr); tp->e_name = strdup(ep->name); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "init_etherarray: strdup(ep->addr)"); } (void)fclose(fp); } #endif /* Hardwire some ethernet names */ for (el = etherlist; el->name != NULL; ++el) { tp = lookup_emem(ndo, el->addr); /* Don't override existing name */ if (tp->e_name != NULL) continue; #ifdef USE_ETHER_NTOHOST /* * Use YP/NIS version of name if available. */ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) { tp->e_name = strdup(name); if (tp->e_name == NULL) (*ndo->ndo_error)(ndo, "init_etherarray: strdup(name)"); continue; } #endif tp->e_name = el->name; } } static const struct tok ipxsap_db[] = { { 0x0000, "Unknown" }, { 0x0001, "User" }, { 0x0002, "User Group" }, { 0x0003, "PrintQueue" }, { 0x0004, "FileServer" }, { 0x0005, "JobServer" }, { 0x0006, "Gateway" }, { 0x0007, "PrintServer" }, { 0x0008, "ArchiveQueue" }, { 0x0009, "ArchiveServer" }, { 0x000a, "JobQueue" }, { 0x000b, "Administration" }, { 0x000F, "Novell TI-RPC" }, { 0x0017, "Diagnostics" }, { 0x0020, "NetBIOS" }, { 0x0021, "NAS SNA Gateway" }, { 0x0023, "NACS AsyncGateway" }, { 0x0024, "RemoteBridge/RoutingService" }, { 0x0026, "BridgeServer" }, { 0x0027, "TCP/IP Gateway" }, { 0x0028, "Point-to-point X.25 BridgeServer" }, { 0x0029, "3270 Gateway" }, { 0x002a, "CHI Corp" }, { 0x002c, "PC Chalkboard" }, { 0x002d, "TimeSynchServer" }, { 0x002e, "ARCserve5.0/PalindromeBackup" }, { 0x0045, "DI3270 Gateway" }, { 0x0047, "AdvertisingPrintServer" }, { 0x004a, "NetBlazerModems" }, { 0x004b, "BtrieveVAP" }, { 0x004c, "NetwareSQL" }, { 0x004d, "XtreeNetwork" }, { 0x0050, "BtrieveVAP4.11" }, { 0x0052, "QuickLink" }, { 0x0053, "PrintQueueUser" }, { 0x0058, "Multipoint X.25 Router" }, { 0x0060, "STLB/NLM" }, { 0x0064, "ARCserve" }, { 0x0066, "ARCserve3.0" }, { 0x0072, "WAN CopyUtility" }, { 0x007a, "TES-NetwareVMS" }, { 0x0092, "WATCOM Debugger/EmeraldTapeBackupServer" }, { 0x0095, "DDA OBGYN" }, { 0x0098, "NetwareAccessServer" }, { 0x009a, "Netware for VMS II/NamedPipeServer" }, { 0x009b, "NetwareAccessServer" }, { 0x009e, "PortableNetwareServer/SunLinkNVT" }, { 0x00a1, "PowerchuteAPC UPS" }, { 0x00aa, "LAWserve" }, { 0x00ac, "CompaqIDA StatusMonitor" }, { 0x0100, "PIPE STAIL" }, { 0x0102, "LAN ProtectBindery" }, { 0x0103, "OracleDataBaseServer" }, { 0x0107, "Netware386/RSPX RemoteConsole" }, { 0x010f, "NovellSNA Gateway" }, { 0x0111, "TestServer" }, { 0x0112, "HP PrintServer" }, { 0x0114, "CSA MUX" }, { 0x0115, "CSA LCA" }, { 0x0116, "CSA CM" }, { 0x0117, "CSA SMA" }, { 0x0118, "CSA DBA" }, { 0x0119, "CSA NMA" }, { 0x011a, "CSA SSA" }, { 0x011b, "CSA STATUS" }, { 0x011e, "CSA APPC" }, { 0x0126, "SNA TEST SSA Profile" }, { 0x012a, "CSA TRACE" }, { 0x012b, "NetwareSAA" }, { 0x012e, "IKARUS VirusScan" }, { 0x0130, "CommunicationsExecutive" }, { 0x0133, "NNS DomainServer/NetwareNamingServicesDomain" }, { 0x0135, "NetwareNamingServicesProfile" }, { 0x0137, "Netware386 PrintQueue/NNS PrintQueue" }, { 0x0141, "LAN SpoolServer" }, { 0x0152, "IRMALAN Gateway" }, { 0x0154, "NamedPipeServer" }, { 0x0166, "NetWareManagement" }, { 0x0168, "Intel PICKIT CommServer/Intel CAS TalkServer" }, { 0x0173, "Compaq" }, { 0x0174, "Compaq SNMP Agent" }, { 0x0175, "Compaq" }, { 0x0180, "XTreeServer/XTreeTools" }, { 0x018A, "NASI ServicesBroadcastServer" }, { 0x01b0, "GARP Gateway" }, { 0x01b1, "Binfview" }, { 0x01bf, "IntelLanDeskManager" }, { 0x01ca, "AXTEC" }, { 0x01cb, "ShivaNetModem/E" }, { 0x01cc, "ShivaLanRover/E" }, { 0x01cd, "ShivaLanRover/T" }, { 0x01ce, "ShivaUniversal" }, { 0x01d8, "CastelleFAXPressServer" }, { 0x01da, "CastelleLANPressPrintServer" }, { 0x01dc, "CastelleFAX/Xerox7033 FaxServer/ExcelLanFax" }, { 0x01f0, "LEGATO" }, { 0x01f5, "LEGATO" }, { 0x0233, "NMS Agent/NetwareManagementAgent" }, { 0x0237, "NMS IPX Discovery/LANternReadWriteChannel" }, { 0x0238, "NMS IP Discovery/LANternTrapAlarmChannel" }, { 0x023a, "LANtern" }, { 0x023c, "MAVERICK" }, { 0x023f, "NovellSMDR" }, { 0x024e, "NetwareConnect" }, { 0x024f, "NASI ServerBroadcast Cisco" }, { 0x026a, "NMS ServiceConsole" }, { 0x026b, "TimeSynchronizationServer Netware 4.x" }, { 0x0278, "DirectoryServer Netware 4.x" }, { 0x027b, "NetwareManagementAgent" }, { 0x0280, "Novell File and Printer Sharing Service for PC" }, { 0x0304, "NovellSAA Gateway" }, { 0x0308, "COM/VERMED" }, { 0x030a, "GalacticommWorldgroupServer" }, { 0x030c, "IntelNetport2/HP JetDirect/HP Quicksilver" }, { 0x0320, "AttachmateGateway" }, { 0x0327, "MicrosoftDiagnostiocs" }, { 0x0328, "WATCOM SQL Server" }, { 0x0335, "MultiTechSystems MultisynchCommServer" }, { 0x0343, "Xylogics RemoteAccessServer/LANModem" }, { 0x0355, "ArcadaBackupExec" }, { 0x0358, "MSLCD1" }, { 0x0361, "NETINELO" }, { 0x037e, "Powerchute UPS Monitoring" }, { 0x037f, "ViruSafeNotify" }, { 0x0386, "HP Bridge" }, { 0x0387, "HP Hub" }, { 0x0394, "NetWare SAA Gateway" }, { 0x039b, "LotusNotes" }, { 0x03b7, "CertusAntiVirus" }, { 0x03c4, "ARCserve4.0" }, { 0x03c7, "LANspool3.5" }, { 0x03d7, "LexmarkPrinterServer" }, { 0x03d8, "LexmarkXLE PrinterServer" }, { 0x03dd, "BanyanENS NetwareClient" }, { 0x03de, "GuptaSequelBaseServer/NetWareSQL" }, { 0x03e1, "UnivelUnixware" }, { 0x03e4, "UnivelUnixware" }, { 0x03fc, "IntelNetport" }, { 0x03fd, "PrintServerQueue" }, { 0x040A, "ipnServer" }, { 0x040D, "LVERRMAN" }, { 0x040E, "LVLIC" }, { 0x0414, "NET Silicon (DPI)/Kyocera" }, { 0x0429, "SiteLockVirus" }, { 0x0432, "UFHELPR???" }, { 0x0433, "Synoptics281xAdvancedSNMPAgent" }, { 0x0444, "MicrosoftNT SNA Server" }, { 0x0448, "Oracle" }, { 0x044c, "ARCserve5.01" }, { 0x0457, "CanonGP55" }, { 0x045a, "QMS Printers" }, { 0x045b, "DellSCSI Array" }, { 0x0491, "NetBlazerModems" }, { 0x04ac, "OnTimeScheduler" }, { 0x04b0, "CD-Net" }, { 0x0513, "EmulexNQA" }, { 0x0520, "SiteLockChecks" }, { 0x0529, "SiteLockChecks" }, { 0x052d, "CitrixOS2 AppServer" }, { 0x0535, "Tektronix" }, { 0x0536, "Milan" }, { 0x055d, "Attachmate SNA gateway" }, { 0x056b, "IBM8235 ModemServer" }, { 0x056c, "ShivaLanRover/E PLUS" }, { 0x056d, "ShivaLanRover/T PLUS" }, { 0x0580, "McAfeeNetShield" }, { 0x05B8, "NLM to workstation communication (Revelation Software)" }, { 0x05BA, "CompatibleSystemsRouters" }, { 0x05BE, "CheyenneHierarchicalStorageManager" }, { 0x0606, "JCWatermarkImaging" }, { 0x060c, "AXISNetworkPrinter" }, { 0x0610, "AdaptecSCSIManagement" }, { 0x0621, "IBM AntiVirus" }, { 0x0640, "Windows95 RemoteRegistryService" }, { 0x064e, "MicrosoftIIS" }, { 0x067b, "Microsoft Win95/98 File and Print Sharing for NetWare" }, { 0x067c, "Microsoft Win95/98 File and Print Sharing for NetWare" }, { 0x076C, "Xerox" }, { 0x079b, "ShivaLanRover/E 115" }, { 0x079c, "ShivaLanRover/T 115" }, { 0x07B4, "CubixWorldDesk" }, { 0x07c2, "Quarterdeck IWare Connect V2.x NLM" }, { 0x07c1, "Quarterdeck IWare Connect V3.x NLM" }, { 0x0810, "ELAN License Server Demo" }, { 0x0824, "ShivaLanRoverAccessSwitch/E" }, { 0x086a, "ISSC Collector" }, { 0x087f, "ISSC DAS AgentAIX" }, { 0x0880, "Intel Netport PRO" }, { 0x0881, "Intel Netport PRO" }, { 0x0b29, "SiteLock" }, { 0x0c29, "SiteLockApplications" }, { 0x0c2c, "LicensingServer" }, { 0x2101, "PerformanceTechnologyInstantInternet" }, { 0x2380, "LAI SiteLock" }, { 0x238c, "MeetingMaker" }, { 0x4808, "SiteLockServer/SiteLockMetering" }, { 0x5555, "SiteLockUser" }, { 0x6312, "Tapeware" }, { 0x6f00, "RabbitGateway" }, { 0x7703, "MODEM" }, { 0x8002, "NetPortPrinters" }, { 0x8008, "WordPerfectNetworkVersion" }, { 0x85BE, "Cisco EIGRP" }, { 0x8888, "WordPerfectNetworkVersion/QuickNetworkManagement" }, { 0x9000, "McAfeeNetShield" }, { 0x9604, "CSA-NT_MON" }, { 0xb6a8, "OceanIsleReachoutRemoteControl" }, { 0xf11f, "SiteLockMetering" }, { 0xf1ff, "SiteLock" }, { 0xf503, "Microsoft SQL Server" }, { 0xF905, "IBM TimeAndPlace" }, { 0xfbfb, "TopCallIII FaxServer" }, { 0xffff, "AnyService/Wildcard" }, { 0, (char *)0 } }; static void init_ipxsaparray(netdissect_options *ndo) { register int i; register struct hnamemem *table; for (i = 0; ipxsap_db[i].s != NULL; i++) { int j = htons(ipxsap_db[i].v) & (HASHNAMESIZE-1); table = &ipxsaptable[j]; while (table->name) table = table->nxt; table->name = ipxsap_db[i].s; table->addr = htons(ipxsap_db[i].v); table->nxt = newhnamemem(ndo); } } /* * Initialize the address to name translation machinery. We map all * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true * (i.e., to prevent blocking on the nameserver). localnet is the IP address * of the local network. mask is its subnet mask. */ void init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask) { if (ndo->ndo_fflag) { f_localnet = localnet; f_netmask = mask; } if (ndo->ndo_nflag) /* * Simplest way to suppress names. */ return; init_etherarray(ndo); init_servarray(ndo); init_eprotoarray(ndo); init_protoidarray(ndo); init_ipxsaparray(ndo); } const char * dnaddr_string(netdissect_options *ndo, u_short dnaddr) { register struct hnamemem *tp; for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL; tp = tp->nxt) if (tp->addr == dnaddr) return (tp->name); tp->addr = dnaddr; tp->nxt = newhnamemem(ndo); - if (ndo->ndo_nflag) - tp->name = dnnum_string(ndo, dnaddr); - else - tp->name = dnname_string(ndo, dnaddr); + tp->name = dnnum_string(ndo, dnaddr); return(tp->name); } /* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */ struct hnamemem * newhnamemem(netdissect_options *ndo) { register struct hnamemem *p; static struct hnamemem *ptr = NULL; static u_int num = 0; if (num <= 0) { num = 64; ptr = (struct hnamemem *)calloc(num, sizeof (*ptr)); if (ptr == NULL) (*ndo->ndo_error)(ndo, "newhnamemem: calloc"); } --num; p = ptr++; return (p); } /* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */ struct h6namemem * newh6namemem(netdissect_options *ndo) { register struct h6namemem *p; static struct h6namemem *ptr = NULL; static u_int num = 0; if (num <= 0) { num = 64; ptr = (struct h6namemem *)calloc(num, sizeof (*ptr)); if (ptr == NULL) (*ndo->ndo_error)(ndo, "newh6namemem: calloc"); } --num; p = ptr++; return (p); } /* Represent TCI part of the 802.1Q 4-octet tag as text. */ const char * ieee8021q_tci_string(const uint16_t tci) { static char buf[128]; snprintf(buf, sizeof(buf), "vlan %u, p %u%s", tci & 0xfff, tci >> 13, (tci & 0x1000) ? ", DEI" : ""); return buf; } Index: vendor/tcpdump/dist/config.guess =================================================================== --- vendor/tcpdump/dist/config.guess (revision 353143) +++ vendor/tcpdump/dist/config.guess (revision 353144) @@ -1,1435 +1,1476 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2015-02-23' +timestamp='2018-07-06' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; +case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu - eval $set_cc_for_build - cat <<-EOF > $dummy.c + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" + exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + eval "$set_cc_for_build" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys + echo "$UNAME_MACHINE"-pc-msys exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" + exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build + eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; esac +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: Index: vendor/tcpdump/dist/config.h.in =================================================================== --- vendor/tcpdump/dist/config.h.in (revision 353143) +++ vendor/tcpdump/dist/config.h.in (revision 353144) @@ -1,397 +1,388 @@ -/* config.h.in. Generated from configure.in by autoheader. */ +/* config.h.in. Generated from configure.ac by autoheader. */ /* define if you want to build the possibly-buggy SMB printer */ #undef ENABLE_SMB /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have the `bpf_dump' function. */ #undef HAVE_BPF_DUMP /* capsicum support available */ #undef HAVE_CAPSICUM /* Define to 1 if you have the `cap_enter' function. */ #undef HAVE_CAP_ENTER /* Define to 1 if you have the `cap_ioctls_limit' function. */ #undef HAVE_CAP_IOCTLS_LIMIT /* Define to 1 if you have the header file. */ #undef HAVE_CAP_NG_H /* Define to 1 if you have the `cap_rights_limit' function. */ #undef HAVE_CAP_RIGHTS_LIMIT /* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you don't. */ #undef HAVE_DECL_ETHER_NTOHOST -/* define if you have the dnet_htoa function */ -#undef HAVE_DNET_HTOA - /* Define to 1 if you have the `ether_ntohost' function. */ #undef HAVE_ETHER_NTOHOST /* Define to 1 if you have the `EVP_CipherInit_ex' function. */ #undef HAVE_EVP_CIPHERINIT_EX /* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */ #undef HAVE_EVP_CIPHER_CTX_NEW /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* define if you have getrpcbynumber() */ #undef HAVE_GETRPCBYNUMBER /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `cap-ng' library (-lcap-ng). */ #undef HAVE_LIBCAP_NG /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO /* Define to 1 if you have the `rpc' library (-lrpc). */ #undef HAVE_LIBRPC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETDNET_DNETDB_H - -/* define if you have a dnet_htoa declaration in */ -#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_ETHER_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IF_ETHER_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_IF_PFLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_NET_PFVAR_H /* Define to 1 if you have the `openat' function. */ #undef HAVE_OPENAT /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_EVP_H /* define if the OS provides AF_INET6 and struct in6_addr */ #undef HAVE_OS_IPV6_SUPPORT /* if there's an os_proto.h for this platform, to use additional prototypes */ #undef HAVE_OS_PROTO_H /* Define to 1 if you have the header file. */ #undef HAVE_PCAP_BLUETOOTH_H /* Define to 1 if you have the `pcap_breakloop' function. */ #undef HAVE_PCAP_BREAKLOOP /* Define to 1 if you have the `pcap_create' function. */ #undef HAVE_PCAP_CREATE /* define if libpcap has pcap_datalink_name_to_val() */ #undef HAVE_PCAP_DATALINK_NAME_TO_VAL /* define if libpcap has pcap_datalink_val_to_description() */ #undef HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION /* define if libpcap has pcap_debug */ #undef HAVE_PCAP_DEBUG /* Define to 1 if you have the `pcap_dump_flush' function. */ #undef HAVE_PCAP_DUMP_FLUSH /* define if libpcap has pcap_dump_ftell() */ #undef HAVE_PCAP_DUMP_FTELL /* Define to 1 if you have the `pcap_findalldevs' function. */ #undef HAVE_PCAP_FINDALLDEVS /* Define to 1 if you have the `pcap_free_datalinks' function. */ #undef HAVE_PCAP_FREE_DATALINKS /* Define to 1 if the system has the type `pcap_if_t'. */ #undef HAVE_PCAP_IF_T /* Define to 1 if you have the `pcap_lib_version' function. */ #undef HAVE_PCAP_LIB_VERSION /* define if libpcap has pcap_list_datalinks() */ #undef HAVE_PCAP_LIST_DATALINKS /* Define to 1 if you have the header file. */ #undef HAVE_PCAP_NFLOG_H /* Define to 1 if you have the `pcap_setdirection' function. */ #undef HAVE_PCAP_SETDIRECTION /* Define to 1 if you have the `pcap_set_datalink' function. */ #undef HAVE_PCAP_SET_DATALINK /* Define to 1 if you have the `pcap_set_immediate_mode' function. */ #undef HAVE_PCAP_SET_IMMEDIATE_MODE /* Define to 1 if you have the `pcap_set_optimizer_debug' function. */ #undef HAVE_PCAP_SET_OPTIMIZER_DEBUG /* Define to 1 if you have the `pcap_set_parser_debug' function. */ #undef HAVE_PCAP_SET_PARSER_DEBUG /* Define to 1 if you have the `pcap_set_tstamp_precision' function. */ #undef HAVE_PCAP_SET_TSTAMP_PRECISION /* Define to 1 if you have the `pcap_set_tstamp_type' function. */ #undef HAVE_PCAP_SET_TSTAMP_TYPE /* Define to 1 if you have the header file. */ #undef HAVE_PCAP_USB_H /* define if libpcap has pcap_version */ #undef HAVE_PCAP_VERSION /* Define to 1 if you have the `pfopen' function. */ #undef HAVE_PFOPEN /* Define to 1 if you have the header file. */ #undef HAVE_RPC_RPCENT_H /* Define to 1 if you have the header file. */ #undef HAVE_RPC_RPC_H /* Define to 1 if you have the `setlinebuf' function. */ #undef HAVE_SETLINEBUF /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION /* Define to 1 if you have the `sigset' function. */ #undef HAVE_SIGSET /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* if struct sockaddr has the sa_len member */ #undef HAVE_SOCKADDR_SA_LEN /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strftime' function. */ #undef HAVE_STRFTIME /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strlcat' function. */ #undef HAVE_STRLCAT /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* 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 header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK /* Define to 1 if you have the `vfprintf' function. */ #undef HAVE_VFPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* define if libpcap has yydebug */ #undef HAVE_YYDEBUG /* define if your compiler has __attribute__ */ #undef HAVE___ATTRIBUTE__ /* if unaligned access fails */ #undef LBL_ALIGN /* Define to 1 if netinet/ether.h declares `ether_ntohost' */ #undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /* Define to 1 if netinet/if_ether.h declares `ether_ntohost' */ #undef NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* define if the platform doesn't define PRId64 */ #undef PRId64 /* define if the platform doesn't define PRIo64 */ #undef PRIo64 /* define if the platform doesn't define PRIx64 */ #undef PRIu64 /* define if the platform doesn't define PRIu64 */ #undef PRIx64 /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* return value of signal handlers */ #undef RETSIGVAL /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* define if you have ether_ntohost() and it works */ #undef USE_ETHER_NTOHOST /* Define if you enable support for libsmi */ #undef USE_LIBSMI /* define if should chroot when dropping privileges */ #undef WITH_CHROOT /* define if should drop privileges by default */ #undef WITH_USER /* get BSD semantics on Irix */ #undef _BSD_SIGNALS /* define on AIX to get certain functions */ #undef _SUN /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* Define for Solaris 2.5.1 so the uint8_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT8_T /* define if your compiler allows __attribute__((format)) without a warning */ #undef __ATTRIBUTE___FORMAT_OK /* define if your compiler allows __attribute__((format)) to be applied to function pointers */ #undef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS /* define if your compiler allows __attribute__((noreturn)) to be applied to function pointers */ #undef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS /* to handle Ultrix compilers that don't support const in prototypes */ #undef const /* Define as token for inline if inlining supported */ #undef inline /* Define to the type of a signed integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef int16_t /* Define to the type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef int32_t /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef int64_t /* Define to the type of a signed integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef int8_t /* Define to `uint16_t' if u_int16_t not defined. */ #undef u_int16_t /* Define to `uint32_t' if u_int32_t not defined. */ #undef u_int32_t /* Define to `uint64_t' if u_int64_t not defined. */ #undef u_int64_t /* Define to `uint8_t' if u_int8_t not defined. */ #undef u_int8_t /* Define to the type of an unsigned integer type of width exactly 16 bits if such a type exists and the standard includes do not define it. */ #undef uint16_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t /* Define to the type of an unsigned integer type of width exactly 8 bits if such a type exists and the standard includes do not define it. */ #undef uint8_t /* Define to the type of an unsigned integer type wide enough to hold a pointer, if such a type exists, and if the system does not define it. */ #undef uintptr_t Index: vendor/tcpdump/dist/config.sub =================================================================== --- vendor/tcpdump/dist/config.sub (revision 353143) +++ vendor/tcpdump/dist/config.sub (revision 353144) @@ -1,1807 +1,1808 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2015-02-22' +timestamp='2018-07-03' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +IFS="-" read -r field1 field2 field3 field4 <&2 + exit 1 ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 ;; - -bluegene*) - os=-cnk + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \ + | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \ + | harris | dolphin | highlevel | gould | cbm | ns | masscomp \ + | apple | axis | knuth | cray | microblaze* \ + | sim | cisco | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac ;; - -scout) + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + craynv) + basic_machine=craynv-cray + os=unicosmp + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + vsta) + basic_machine=i386-unknown + os=vsta + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ | avr | avr32 \ + | ba \ | be32 | be64 \ | bfin \ - | c4x | c8051 | clipper \ + | c4x | c8051 | clipper | csky \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ + | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia64 \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ + | nfp \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ + | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ - | riscv32 | riscv64 \ + | riscv | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ - | we32k \ + | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown - os=-none + os=${os:-none} ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; + m9s12z | m68hcs12z | hcs12z | s12z) + basic_machine=s12z-unknown + os=${os:-none} + ;; ms1) basic_machine=mt-unknown ;; - strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown - os=-none + os=${os:-none} ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ + | nfp-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv-* | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; abacus) basic_machine=abacus-unknown ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; amd64) basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; amiga | amiga-*) basic_machine=m68k-unknown ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos + asmjs) + basic_machine=asmjs-unknown ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; bluegene*) basic_machine=powerpc-ibm - os=-cnk + os=cnk ;; c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray - os=-unicos + os=${os:-unicos} ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; convex-c1) basic_machine=c1-convex - os=-bsd + os=bsd ;; convex-c2) basic_machine=c2-convex - os=-bsd + os=bsd ;; convex-c32) basic_machine=c32-convex - os=-bsd + os=bsd ;; convex-c34) basic_machine=c34-convex - os=-bsd + os=bsd ;; convex-c38) basic_machine=c38-convex - os=-bsd + os=bsd ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; cr16 | cr16-*) basic_machine=cr16-unknown - os=-elf + os=${os:-elf} ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown - os=-elf + os=${os:-elf} ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec - os=-tops10 + os=tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec - os=-tops20 + os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; dpx20 | dpx20-*) basic_machine=rs6000-bull - os=-bosx + os=${os:-bosx} ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull - os=-sysv3 + os=sysv3 ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" ;; encore | umax | mmax) basic_machine=ns32k-encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + basic_machine=elxsi-elxsi + os=${os:-bsd} ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 + os=hiuxwe2 ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; hp300-*) basic_machine=m68k-hp ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=solaris2 ;; - i386mach) - basic_machine=i386-mach - os=-mach + j90 | j90-cray) + basic_machine=j90-cray + os=${os:-unicos} ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; iris | iris4d) basic_machine=mips-sgi case $os in - -irix*) + irix*) ;; *) - os=-irix4 + os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; microblaze*) basic_machine=microblaze-xilinx ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) basic_machine=m68000-convergent ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari - os=-mint + os=mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; news-3600 | risc-news) basic_machine=mips-sony - os=-newsos + os=newsos ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in - -nextstep* ) + nextstep* ) ;; - -ns2*) - os=-nextstep2 + ns2*) + os=nextstep2 ;; *) - os=-nextstep3 + os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki - os=-proelf + os=proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; pa-hitachi) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 + os=hiuxwe2 ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde - os=-elf + os=${os:-elf} ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs - os=-vxworks + os=vxworks ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; tile*) basic_machine=$basic_machine-unknown - os=-linux-gnu + os=linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; tower | tower-32) basic_machine=m68k-ncr ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; w65*) basic_machine=w65-wdc - os=-none + os=none ;; w89k-*) basic_machine=hppa1.1-winbond - os=-proelf + os=proelf ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + x64) + basic_machine=x86_64-pc ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; none) basic_machine=none-none - os=-none + os=${os:-none} ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$os != x ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris1 | -solaris1.*) + bluegene*) + os=cnk + ;; + solaris1 | solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; - -solaris) - os=-solaris2 + solaris) + os=solaris2 ;; - -svr4*) - os=-sysv4 + unixware*) + os=sysv4.2uw ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) + gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + ;; + sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + scout) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + psos*) + os=psos + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Each alternative MUST end in a * to match a version number. + # sysv* is not here because it comes later, after sysvr4. + gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | kopensolaris* | plan9* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \ + | knetbsd* | mirbsd* | netbsd* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* \ + | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ + | linux-newlib* | linux-musl* | linux-uclibc* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* \ + | morphos* | superux* | rtmk* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; - -qnx*) + qnx*) case $basic_machine in x86-* | i*86-*) ;; *) - os=-nto$os + os=nto-$os ;; esac ;; - -nto-qnx*) + hiux*) + os=hiuxwe2 ;; - -nto*) + nto-qnx*) + ;; + nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + linux-dietlibc) + os=linux-dietlibc ;; - -linux-dietlibc) - os=-linux-dietlibc - ;; - -linux*) + linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + lynx*178) + os=lynxos178 ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + lynx*5) + os=lynxos5 ;; - -opened*) - os=-openedition + lynx*) + os=lynxos ;; - -os400*) - os=-os400 + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -wince*) - os=-wince + opened*) + os=openedition ;; - -osfrose*) - os=-osfrose + os400*) + os=os400 ;; - -osf*) - os=-osf + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -utek*) - os=-bsd + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -dynix*) - os=-bsd + wince*) + os=wince ;; - -acis*) - os=-aos + utek*) + os=bsd ;; - -atheos*) - os=-atheos + dynix*) + os=bsd ;; - -syllable*) - os=-syllable + acis*) + os=aos ;; - -386bsd) - os=-bsd + atheos*) + os=atheos ;; - -ctix* | -uts*) - os=-sysv + syllable*) + os=syllable ;; - -nova*) - os=-rtmk-nova + 386bsd) + os=bsd ;; - -ns2 ) - os=-nextstep2 + ctix* | uts*) + os=sysv ;; - -nsk*) - os=-nsk + nova*) + os=rtmk-nova ;; + ns2) + os=nextstep2 + ;; + nsk*) + os=nsk + ;; # Preserve the version number of sinix5. - -sinix5.*) + sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; - -sinix*) - os=-sysv4 + sinix*) + os=sysv4 ;; - -tpf*) - os=-tpf + tpf*) + os=tpf ;; - -triton*) - os=-sysv3 + triton*) + os=sysv3 ;; - -oss*) - os=-sysv3 + oss*) + os=sysv3 ;; - -svr4) - os=-sysv4 + svr4*) + os=sysv4 ;; - -svr3) - os=-sysv3 + svr3) + os=sysv3 ;; - -sysvr4) - os=-sysv4 + sysvr4) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + # This must come after sysvr4. + sysv*) ;; - -ose*) - os=-ose + ose*) + os=ose ;; - -es1800*) - os=-ose + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -xenix) - os=-xenix + zvmoe) + os=zvmoe ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + dicos*) + os=dicos ;; - -aros*) - os=-aros + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; - -zvmoe) - os=-zvmoe + nacl*) ;; - -dicos*) - os=-dicos + ios) ;; - -nacl*) + none) ;; - -none) + *-eabi) ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + os=linux ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf ;; + clipper-intergraph) + os=clix + ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; + pru-*) + os=elf + ;; *-be) - os=-beos + os=beos ;; - *-haiku) - os=-haiku - ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs + os=mvs ;; - *-next) - os=-nextstep3 - ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint ;; + *-wrs) + os=vxworks + ;; *) - os=-none + os=none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in - -riscix*) + riscix*) vendor=acorn ;; - -sunos*) + sunos*) vendor=sun ;; - -cnk*|-aix*) + cnk*|-aix*) vendor=ibm ;; - -beos*) + beos*) vendor=be ;; - -hpux*) + hpux*) vendor=hp ;; - -mpeix*) + mpeix*) vendor=hp ;; - -hiux*) + hiux*) vendor=hitachi ;; - -unos*) + unos*) vendor=crds ;; - -dgux*) + dgux*) vendor=dg ;; - -luna*) + luna*) vendor=omron ;; - -genix*) + genix*) vendor=ns ;; - -mvs* | -opened*) + clix*) + vendor=intergraph + ;; + mvs* | opened*) vendor=ibm ;; - -os400*) + os400*) vendor=ibm ;; - -ptx*) + ptx*) vendor=sequent ;; - -tpf*) + tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + vxsim* | vxworks* | windiss*) vendor=wrs ;; - -aux*) + aux*) vendor=apple ;; - -hms*) + hms*) vendor=hitachi ;; - -mpw* | -macos*) + mpw* | macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) vendor=atari ;; - -vos*) + vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine-$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: Index: vendor/tcpdump/dist/configure =================================================================== --- vendor/tcpdump/dist/configure (revision 353143) +++ vendor/tcpdump/dist/configure (revision 353144) @@ -1,9665 +1,9589 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="tcpdump.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM MAN_MISC_INFO MAN_FILE_FORMATS LOCALSRC V_PCAPDEP V_INCLS V_GROUP V_DEFS V_CCOPT MKDEP DEPENDENCY_CFLAG AR RANLIB PCAP_CONFIG LIBOBJS EGREP GREP CPP OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC SHLICC2 host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking with_gcc enable_universal with_smi enable_smb with_user with_chroot with_sandbox_capsicum with_system_libpcap with_crypto with_cap_ng ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-universal don't build universal on OS X - --enable-smb enable possibly-buggy SMB printer default=yes + --enable-smb enable possibly-buggy SMB printer default=no --disable-smb disable possibly-buggy SMB printer Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-gcc don't use gcc --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. default=yes --without-smi don't link with libsmi --with-user=USERNAME drop privileges by default to USERNAME --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY --with-sandbox-capsicum use Capsicum security functions [default=yes, if available] --with-system-libpcap don't use local pcap library --with-crypto[=DIR] use OpenSSL/libressl libcrypto (located in directory DIR, if specified) [default=yes, if available] --with-cap-ng use libcap-ng [default=yes, if available] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* 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_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_intX_t LINENO BITS VAR # ----------------------------------- # Finds a signed integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_intX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 $as_echo_n "checking for int$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in int$2_t 'int' 'long int' \ 'long long int' 'short int' 'signed char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else case $ac_type in #( int$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_intX_t # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Check whether --with-gcc was given. if test "${with_gcc+set}" = set; then : withval=$with_gcc; fi V_INCLS="" if test "${srcdir}" != "." ; then V_INCLS="-I$srcdir" fi if test "${CFLAGS+set}" = set; then LBL_CFLAGS="$CFLAGS" fi if test -z "$CC" ; then case "$host_os" in bsdi*) # Extract the first word of "shlicc2", so it can be a program name with args. set dummy shlicc2; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_SHLICC2+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$SHLICC2"; then ac_cv_prog_SHLICC2="$SHLICC2" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_SHLICC2="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_prog_SHLICC2" && ac_cv_prog_SHLICC2="no" fi fi SHLICC2=$ac_cv_prog_SHLICC2 if test -n "$SHLICC2"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHLICC2" >&5 $as_echo "$SHLICC2" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $SHLICC2 = yes ; then CC=shlicc2 export CC fi ;; esac fi if test -z "$CC" -a "$with_gcc" = no ; then CC=cc export CC fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "$GCC" = yes ; then # # -Werror forces warnings to be errors. # ac_lbl_cc_force_warning_errors=-Werror # # Use -ffloat-store so that, on 32-bit x86, we don't # do 80-bit arithmetic with the FPU; that way we should # get the same results for floating-point calculations # on x86-32 and x86-64. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -ffloat-store option" >&5 $as_echo_n "checking whether the compiler supports the -ffloat-store option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-ffloat-store" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -ffloat-store" elif expr "x-ffloat-store" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -ffloat-store" elif expr "x-ffloat-store" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -ffloat-store" else CFLAGS="$CFLAGS -ffloat-store" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -ffloat-store" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else V_INCLS="$V_INCLS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" case "$host_os" in darwin*) # # This is assumed either to be GCC or clang, both # of which use -Werror to force warnings to be errors. # ac_lbl_cc_force_warning_errors=-Werror ;; hpux*) # # HP C, which is what we presume we're using, doesn't # exit with a non-zero exit status if we hand it an # invalid -W flag, can't be forced to do so even with # +We, and doesn't handle GCC-style -W flags, so we # don't want to try using GCC-style -W flags. # ac_lbl_cc_dont_try_gcc_dashW=yes ;; irix*) # # MIPS C, which is what we presume we're using, doesn't # necessarily exit with a non-zero exit status if we # hand it an invalid -W flag, can't be forced to do # so, and doesn't handle GCC-style -W flags, so we # don't want to try using GCC-style -W flags. # ac_lbl_cc_dont_try_gcc_dashW=yes # # It also, apparently, defaults to "char" being # unsigned, unlike most other C implementations; # I suppose we could say "signed char" whenever # we want to guarantee a signed "char", but let's # just force signed chars. # # -xansi is normally the default, but the # configure script was setting it; perhaps -cckr # was the default in the Old Days. (Then again, # that would probably be for backwards compatibility # in the days when ANSI C was Shiny and New, i.e. # 1989 and the early '90's, so maybe we can just # drop support for those compilers.) # # -g is equivalent to -g2, which turns off # optimization; we choose -g3, which generates # debugging information but doesn't turn off # optimization (even if the optimization would # cause inaccuracies in debugging). # V_CCOPT="$V_CCOPT -xansi -signed -g3" ;; osf*) # # Presumed to be DEC OSF/1, Digital UNIX, or # Tru64 UNIX. # # The DEC C compiler, which is what we presume we're # using, doesn't exit with a non-zero exit status if we # hand it an invalid -W flag, can't be forced to do # so, and doesn't handle GCC-style -W flags, so we # don't want to try using GCC-style -W flags. # ac_lbl_cc_dont_try_gcc_dashW=yes # # -g is equivalent to -g2, which turns off # optimization; we choose -g3, which generates # debugging information but doesn't turn off # optimization (even if the optimization would # cause inaccuracies in debugging). # V_CCOPT="$V_CCOPT -g3" ;; solaris*) # # Assumed to be Sun C, which requires -errwarn to force # warnings to be treated as errors. # ac_lbl_cc_force_warning_errors=-errwarn ;; ultrix*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking that Ultrix $CC hacks const in prototypes" >&5 $as_echo_n "checking that Ultrix $CC hacks const in prototypes... " >&6; } if ${ac_cv_lbl_cc_const_proto+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct a { int b; }; void c(const struct a *) ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_cc_const_proto=yes else ac_cv_lbl_cc_const_proto=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_const_proto" >&5 $as_echo "$ac_cv_lbl_cc_const_proto" >&6; } if test $ac_cv_lbl_cc_const_proto = no ; then $as_echo "#define const /**/" >>confdefs.h fi ;; esac V_CCOPT="$V_CCOPT -O" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } save_CFLAGS="$CFLAGS" CFLAGS="$V_CCOPT" if ${ac_cv_lbl_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_lbl_inline="" ac_lbl_cc_inline=no for ac_lbl_inline in inline __inline__ __inline do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define inline $ac_lbl_inline static inline struct iltest *foo(void); struct iltest { int iltest1; int iltest2; }; static inline struct iltest * foo() { static struct iltest xxx; return &xxx; } int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lbl_cc_inline=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$ac_lbl_cc_inline" = yes ; then break; fi done if test "$ac_lbl_cc_inline" = yes ; then ac_cv_lbl_inline=$ac_lbl_inline fi fi CFLAGS="$save_CFLAGS" if test ! -z "$ac_cv_lbl_inline" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_inline" >&5 $as_echo "$ac_cv_lbl_inline" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi cat >>confdefs.h <<_ACEOF #define inline $ac_cv_lbl_inline _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5 $as_echo_n "checking for __attribute__... " >&6; } if ${ac_cv___attribute__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include static void foo(void) __attribute__ ((noreturn)); static void foo(void) { exit(1); } int main(int argc, char **argv) { foo(); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute__=yes else ac_cv___attribute__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv___attribute__" = "yes"; then $as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h else # # We can't use __attribute__, so we can't use __attribute__((unused)), # so we define _U_ to an empty string. # V_DEFS="$V_DEFS -D_U_=\"\"" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5 $as_echo "$ac_cv___attribute__" >&6; } if test "$ac_cv___attribute__" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((unused)) can be used without warnings" >&5 $as_echo_n "checking whether __attribute__((unused)) can be used without warnings... " >&6; } if ${ac_cv___attribute___unused+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main(int argc __attribute((unused)), char **argv __attribute((unused))) { printf("Hello, world!\n"); return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute___unused=yes else ac_cv___attribute___unused=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test "$ac_cv___attribute___unused" = "yes"; then V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" else V_DEFS="$V_DEFS -D_U_=\"\"" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___unused" >&5 $as_echo "$ac_cv___attribute___unused" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((noreturn)) can be applied to function pointers without warnings" >&5 $as_echo_n "checking whether __attribute__((noreturn)) can be applied to function pointers without warnings... " >&6; } if ${ac_cv___attribute___noreturn_function_pointer+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern int (*foo)(int i) __attribute__ ((noreturn)); int main(int argc, char **argv) { (*foo)(1); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute___noreturn_function_pointer=yes else ac_cv___attribute___noreturn_function_pointer=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test "$ac_cv___attribute___noreturn_function_pointer" = "yes"; then $as_echo "#define __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___noreturn_function_pointer" >&5 $as_echo "$ac_cv___attribute___noreturn_function_pointer" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be used without warnings" >&5 $as_echo_n "checking whether __attribute__((format)) can be used without warnings... " >&6; } if ${ac_cv___attribute___format+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern int foo(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int main(int argc, char **argv) { foo("%s", "test"); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute___format=yes else ac_cv___attribute___format=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$save_CFLAGS" if test "$ac_cv___attribute___format" = "yes"; then $as_echo "#define __ATTRIBUTE___FORMAT_OK 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format" >&5 $as_echo "$ac_cv___attribute___format" >&6; } if test "$ac_cv___attribute___format" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be applied to function pointers" >&5 $as_echo_n "checking whether __attribute__((format)) can be applied to function pointers... " >&6; } if ${ac_cv___attribute___format_function_pointer+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include extern int (*foo)(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int main(int argc, char **argv) { (*foo)("%s", "test"); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv___attribute___format_function_pointer=yes else ac_cv___attribute___format_function_pointer=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv___attribute___format_function_pointer" = "yes"; then $as_echo "#define __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format_function_pointer" >&5 $as_echo "$ac_cv___attribute___format_function_pointer" >&6; } fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done -for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h +for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in net/pfvar.h do : ac_fn_c_check_header_compile "$LINENO" "net/pfvar.h" "ac_cv_header_net_pfvar_h" "#include #include #include " if test "x$ac_cv_header_net_pfvar_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NET_PFVAR_H 1 _ACEOF fi done if test "$ac_cv_header_net_pfvar_h" = yes; then for ac_header in net/if_pflog.h do : ac_fn_c_check_header_compile "$LINENO" "net/if_pflog.h" "ac_cv_header_net_if_pflog_h" "#include #include #include #include " if test "x$ac_cv_header_net_if_pflog_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NET_IF_PFLOG_H 1 _ACEOF fi done if test "$ac_cv_header_net_if_pflog_h" = yes; then LOCALSRC="print-pflog.c $LOCALSRC" fi fi for ac_header in netinet/if_ether.h do : ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include #include " if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_IF_ETHER_H 1 _ACEOF fi done if test "$ac_cv_header_netinet_if_ether_h" != yes; then # # The simple test didn't work. # Do we need to include first? # Unset ac_cv_header_netinet_if_ether_h so we don't # treat the previous failure as a cached value and # suppress the next test. # { $as_echo "$as_me:${as_lineno-$LINENO}: Rechecking with some additional includes" >&5 $as_echo "$as_me: Rechecking with some additional includes" >&6;} unset ac_cv_header_netinet_if_ether_h for ac_header in netinet/if_ether.h do : ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include #include #include struct mbuf; struct rtentry; #include " if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_IF_ETHER_H 1 _ACEOF fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi case "$host_os" in darwin*) # Check whether --enable-universal was given. if test "${enable_universal+set}" = set; then : enableval=$enable_universal; fi if test "$enable_universal" != "no"; then case "$host_os" in darwin9.*) # # Leopard. Build for x86 and 32-bit PowerPC, with # x86 first. (That's what Apple does.) # V_CCOPT="$V_CCOPT -arch i386 -arch ppc" LDFLAGS="$LDFLAGS -arch i386 -arch ppc" ;; darwin10.*) # # Snow Leopard. Build for x86-64 and x86, with # x86-64 first. (That's what Apple does.) # V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" ;; esac fi ;; esac # Check whether --with-smi was given. if test "${with_smi+set}" = set; then : withval=$with_smi; else with_smi=yes fi if test "x$with_smi" != "xno" ; then ac_fn_c_check_header_mongrel "$LINENO" "smi.h" "ac_cv_header_smi_h" "$ac_includes_default" if test "x$ac_cv_header_smi_h" = xyes; then : # # OK, we found smi.h. Do we have libsmi with smiInit? # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for smiInit in -lsmi" >&5 $as_echo_n "checking for smiInit in -lsmi... " >&6; } if ${ac_cv_lib_smi_smiInit+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsmi $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char smiInit (); int main () { return smiInit (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_smi_smiInit=yes else ac_cv_lib_smi_smiInit=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_smi_smiInit" >&5 $as_echo "$ac_cv_lib_smi_smiInit" >&6; } if test "x$ac_cv_lib_smi_smiInit" = xyes; then : # # OK, we have libsmi with smiInit. Can we use it? # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libsmi" >&5 $as_echo_n "checking whether to enable libsmi... " >&6; } savedlibs="$LIBS" LIBS="-lsmi $LIBS" if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not when cross-compiling" >&5 $as_echo "not when cross-compiling" >&6; } LIBS="$savedlibs" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* libsmi available check */ #include main() { int current, revision, age, n; const int required = 2; if (smiInit("")) exit(1); if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) exit(2); n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); if (n != 3) exit(3); if (required < current - age || required > current) exit(4); exit(0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define USE_LIBSMI 1" >>confdefs.h else case $? in 1) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - smiInit failed" >&5 $as_echo "no - smiInit failed" >&6; } ;; 2) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - header/library version mismatch" >&5 $as_echo "no - header/library version mismatch" >&6; } ;; 3) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - can't determine library version" >&5 $as_echo "no - can't determine library version" >&6; } ;; 4) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no - too old" >&5 $as_echo "no - too old" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac LIBS="$savedlibs" fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the possibly-buggy SMB printer" >&5 $as_echo_n "checking whether to enable the possibly-buggy SMB printer... " >&6; } # Check whether --enable-smb was given. if test "${enable_smb+set}" = set; then : enableval=$enable_smb; else - enableval=yes + enableval=no fi case "$enableval" in yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&5 -$as_echo "$as_me: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&2;} $as_echo "#define ENABLE_SMB 1" >>confdefs.h LOCALSRC="print-smb.c smbutil.c $LOCALSRC" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac # Check whether --with-user was given. if test "${with_user+set}" = set; then : withval=$with_user; fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to drop root privileges by default" >&5 $as_echo_n "checking whether to drop root privileges by default... " >&6; } if test ! -z "$with_user" ; then cat >>confdefs.h <<_ACEOF #define WITH_USER "$withval" _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: to \"$withval\"" >&5 $as_echo "to \"$withval\"" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Check whether --with-chroot was given. if test "${with_chroot+set}" = set; then : withval=$with_chroot; fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to chroot" >&5 $as_echo_n "checking whether to chroot... " >&6; } if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then cat >>confdefs.h <<_ACEOF #define WITH_CHROOT "$withval" _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: to \"$withval\"" >&5 $as_echo "to \"$withval\"" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Check whether --with-sandbox-capsicum was given. if test "${with_sandbox_capsicum+set}" = set; then : withval=$with_sandbox_capsicum; fi # # Check whether various functions are available. If any are, set # ac_lbl_capsicum_function_seen to yes; if any are not, set # ac_lbl_capsicum_function_not_seen to yes. # # We don't check cap_rights_init(), as it's a macro, wrapping another # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS() # doesn't handle that. # # All of the ones we check for must be available in order to enable # capsicum sandboxing. # # XXX - do we need to check for all of them, or are there some that, if # present, imply others are present? # if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then for ac_func in cap_enter cap_rights_limit cap_ioctls_limit openat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF ac_lbl_capsicum_function_seen=yes else ac_lbl_capsicum_function_not_seen=yes fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to sandbox using capsicum" >&5 $as_echo_n "checking whether to sandbox using capsicum... " >&6; } if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then $as_echo "#define HAVE_CAPSICUM 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # # We must check this before checking whether to check the OS's IPv6, # support because, on some platforms (such as SunOS 5.x), the test # program requires the extra networking libraries. # # Most operating systems have gethostbyname() in the default searched # libraries (i.e. libc): # Some OSes (eg. Solaris) place it in libnsl # Some strange OSes (SINIX) have it in libsocket: { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' nsl socket resolv; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # Unfortunately libsocket sometimes depends on libnsl and # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this. if test "$ac_cv_search_gethostbyname" = "no" then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5 $as_echo_n "checking for gethostbyname in -lsocket... " >&6; } if ${ac_cv_lib_socket_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_gethostbyname=yes else ac_cv_lib_socket_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5 $as_echo "$ac_cv_lib_socket_gethostbyname" >&6; } if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then : LIBS="-lsocket -lnsl $LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } if ${ac_cv_search_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socket+:} false; then : break fi done if ${ac_cv_search_socket+:} false; then : else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } if ${ac_cv_lib_socket_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket -lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else ac_cv_lib_socket_socket=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } if test "x$ac_cv_lib_socket_socket" = xyes; then : LIBS="-lsocket -lnsl $LIBS" fi fi # DLPI needs putmsg under HPUX so test for -lstr while we're at it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5 $as_echo_n "checking for library containing putmsg... " >&6; } if ${ac_cv_search_putmsg+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char putmsg (); int main () { return putmsg (); ; return 0; } _ACEOF for ac_lib in '' str; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_putmsg=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_putmsg+:} false; then : break fi done if ${ac_cv_search_putmsg+:} false; then : else ac_cv_search_putmsg=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_putmsg" >&5 $as_echo "$ac_cv_search_putmsg" >&6; } ac_res=$ac_cv_search_putmsg if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # # Check whether AF_INET6 and struct in6_addr are defined. # If they aren't both defined, we don't have sufficient OS # support for IPv6, so we don't look for IPv6 support libraries, # and we define AF_INET6 and struct in6_addr ourselves. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the operating system supports IPv6" >&5 $as_echo_n "checking whether the operating system supports IPv6... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* AF_INET6 available check */ #include #include #include #ifdef AF_INET6 void foo(struct in6_addr *addr) { memset(addr, 0, sizeof (struct in6_addr)); } #else #error "AF_INET6 not defined" #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_OS_IPV6_SUPPORT 1" >>confdefs.h ipv6=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ipv6=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ipv6type=unknown ipv6lib=none ipv6trylibc=no if test "$ipv6" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking ipv6 stack type" >&5 $as_echo_n "checking ipv6 stack type... " >&6; } for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do case $i in inria) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef IPV6_INRIA_VERSION yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i fi rm -f conftest* ;; kame) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __KAME__ yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib; ipv6trylibc=yes fi rm -f conftest* ;; linux-glibc) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i fi rm -f conftest* ;; linux-libinet6) if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then ipv6type=$i ipv6lib=inet6 ipv6libdir=/usr/inet6/lib ipv6trylibc=yes; CFLAGS="-I/usr/inet6/include $CFLAGS" fi ;; toshiba) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef _TOSHIBA_INET6 yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi rm -f conftest* ;; v6d) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __V6D__ yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i; ipv6lib=v6; ipv6libdir=/usr/local/v6/lib; CFLAGS="-I/usr/local/v6/include $CFLAGS" fi rm -f conftest* ;; zeta) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef _ZETA_MINAMI_INET6 yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : ipv6type=$i; ipv6lib=inet6; ipv6libdir=/usr/local/v6/lib fi rm -f conftest* ;; esac if test "$ipv6type" != "unknown"; then break fi done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ipv6type" >&5 $as_echo "$ipv6type" >&6; } fi if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" echo "You have $ipv6lib library, using it" else if test "$ipv6trylibc" = "yes"; then echo "You do not have $ipv6lib library, using libc" else echo 'Fatal: no $ipv6lib library found. cannot continue.' echo "You need to fetch lib$ipv6lib.a from appropriate" echo 'ipv6 kit and compile beforehand.' exit 1 fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5 -$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; } -if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "dnet_htoa" >/dev/null 2>&1; then : - td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes -else - td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5 -$as_echo "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6; } -if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then - -$as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h - -fi - ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf" if test "x$ac_cv_func_vfprintf" = xyes; then : $as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h else case " $LIBOBJS " in *" vfprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS vfprintf.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" if test "x$ac_cv_func_strlcat" = xyes; then : $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h else case " $LIBOBJS " in *" strlcat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcat.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes; then : $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h else case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes; then : $as_echo "#define HAVE_STRDUP 1" >>confdefs.h else case " $LIBOBJS " in *" strdup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strdup.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strsep" "ac_cv_func_strsep" if test "x$ac_cv_func_strsep" = xyes; then : $as_echo "#define HAVE_STRSEP 1" >>confdefs.h else case " $LIBOBJS " in *" strsep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strsep.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" if test "x$ac_cv_func_getopt_long" = xyes; then : $as_echo "#define HAVE_GETOPT_LONG 1" >>confdefs.h else case " $LIBOBJS " in *" getopt_long.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt_long.$ac_objext" ;; esac fi for ac_func in fork vfork strftime do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in setlinebuf alarm do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done needsnprintf=no for ac_func in vsnprintf snprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else needsnprintf=yes fi done if test $needsnprintf = yes; then case " $LIBOBJS " in *" snprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF if test "$ac_cv_type_signal" = void ; then $as_echo "#define RETSIGVAL /**/" >>confdefs.h else $as_echo "#define RETSIGVAL (0)" >>confdefs.h fi case "$host_os" in irix*) $as_echo "#define _BSD_SIGNALS 1" >>confdefs.h ;; *) for ac_func in sigaction do : ac_fn_c_check_func "$LINENO" "sigaction" "ac_cv_func_sigaction" if test "x$ac_cv_func_sigaction" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGACTION 1 _ACEOF fi done if test $ac_cv_func_sigaction = no ; then for ac_func in sigset do : ac_fn_c_check_func "$LINENO" "sigset" "ac_cv_func_sigset" if test "x$ac_cv_func_sigset" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGSET 1 _ACEOF fi done fi ;; esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5 -$as_echo_n "checking for library containing dnet_htoa... " >&6; } -if ${ac_cv_search_dnet_htoa+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dnet_htoa (); -int -main () -{ -return dnet_htoa (); - ; - return 0; -} -_ACEOF -for ac_lib in '' dnet; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_dnet_htoa=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_dnet_htoa+:} false; then : - break -fi -done -if ${ac_cv_search_dnet_htoa+:} false; then : - -else - ac_cv_search_dnet_htoa=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5 -$as_echo "$ac_cv_search_dnet_htoa" >&6; } -ac_res=$ac_cv_search_dnet_htoa -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h - -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5 $as_echo_n "checking for main in -lrpc... " >&6; } if ${ac_cv_lib_rpc_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrpc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_rpc_main=yes else ac_cv_lib_rpc_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rpc_main" >&5 $as_echo "$ac_cv_lib_rpc_main" >&6; } if test "x$ac_cv_lib_rpc_main" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBRPC 1 _ACEOF LIBS="-lrpc $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getrpcbynumber" >&5 $as_echo_n "checking for library containing getrpcbynumber... " >&6; } if ${ac_cv_search_getrpcbynumber+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char getrpcbynumber (); int main () { return getrpcbynumber (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_getrpcbynumber=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_getrpcbynumber+:} false; then : break fi done if ${ac_cv_search_getrpcbynumber+:} false; then : else ac_cv_search_getrpcbynumber=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getrpcbynumber" >&5 $as_echo "$ac_cv_search_getrpcbynumber" >&6; } ac_res=$ac_cv_search_getrpcbynumber if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_GETRPCBYNUMBER 1" >>confdefs.h fi LBL_LIBS="$LIBS" pfopen=/usr/examples/packetfilter/pfopen.c if test -f $pfopen ; then for ac_func in pfopen do : ac_fn_c_check_func "$LINENO" "pfopen" "ac_cv_func_pfopen" if test "x$ac_cv_func_pfopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PFOPEN 1 _ACEOF fi done if test $ac_cv_func_pfopen = "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using $pfopen" >&5 $as_echo "Using $pfopen" >&6; } LIBS="$LIBS $pfopen" fi fi libpcap=FAIL { $as_echo "$as_me:${as_lineno-$LINENO}: checking for local pcap library" >&5 $as_echo_n "checking for local pcap library... " >&6; } # Check whether --with-system-libpcap was given. if test "${with_system_libpcap+set}" = set; then : withval=$with_system_libpcap; fi if test "x$with_system_libpcap" != xyes ; then lastdir=FAIL places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'` places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \ egrep '/libpcap-[0-9]+\.[0-9]+(\.[0-9]*)?([ab][0-9]*|-PRE-GIT)?$'` for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do basedir=`echo $dir | sed -e 's/[ab][0-9]*$//' | \ sed -e 's/-PRE-GIT$//' ` if test $lastdir = $basedir ; then continue; fi lastdir=$dir if test -r $dir/libpcap.a ; then libpcap=$dir/libpcap.a d=$dir fi done fi if test $libpcap = FAIL ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } # # Look for pcap-config. # if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pcap-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pcap-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PCAP_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PCAP_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG if test -n "$PCAP_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCAP_CONFIG" >&5 $as_echo "$PCAP_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PCAP_CONFIG"; then ac_pt_PCAP_CONFIG=$PCAP_CONFIG # Extract the first word of "pcap-config", so it can be a program name with args. set dummy pcap-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PCAP_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PCAP_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PCAP_CONFIG="$ac_pt_PCAP_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PCAP_CONFIG=$ac_cv_path_ac_pt_PCAP_CONFIG if test -n "$ac_pt_PCAP_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PCAP_CONFIG" >&5 $as_echo "$ac_pt_PCAP_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PCAP_CONFIG" = x; then PCAP_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PCAP_CONFIG=$ac_pt_PCAP_CONFIG fi else PCAP_CONFIG="$ac_cv_path_PCAP_CONFIG" fi if test -n "$PCAP_CONFIG" ; then # # Found - use it to get the include flags for # libpcap and the flags to link with libpcap. # # Please read section 11.6 "Shell Substitutions" # in the autoconf manual before doing anything # to this that involves quoting. Especially note # the statement "There is just no portable way to use # double-quoted strings inside double-quoted back-quoted # expressions (pfew!)." # cflags=`"$PCAP_CONFIG" --cflags` V_INCLS="$cflags $V_INCLS" libpcap=`"$PCAP_CONFIG" --libs` else # # Not found; look for pcap. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpcap" >&5 $as_echo_n "checking for main in -lpcap... " >&6; } if ${ac_cv_lib_pcap_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_main=yes else ac_cv_lib_pcap_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_main" >&5 $as_echo "$ac_cv_lib_pcap_main" >&6; } if test "x$ac_cv_lib_pcap_main" = xyes; then : libpcap="-lpcap" fi if test $libpcap = FAIL ; then as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extraneous pcap header directories" >&5 $as_echo_n "checking for extraneous pcap header directories... " >&6; } if test \( ! -r /usr/local/include/pcap.h \) -a \ \( ! -r /usr/include/pcap.h \); then if test -r /usr/local/include/pcap/pcap.h; then d="/usr/local/include/pcap" elif test -r /usr/include/pcap/pcap.h; then d="/usr/include/pcap" fi fi if test -z "$d" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } else V_INCLS="-I$d $V_INCLS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: found -- -I$d added" >&5 $as_echo "found -- -I$d added" >&6; } fi fi else V_PCAPDEP=$libpcap places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \ egrep '/libpcap-[0-9]*.[0-9]*(.[0-9]*)?([ab][0-9]*)?$'` pcapH=FAIL if test -r $d/pcap.h; then pcapH=$d else for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do if test -r $dir/pcap.h ; then pcapH=$dir fi done fi if test $pcapH = FAIL ; then as_fn_error $? "cannot find pcap.h: see INSTALL" "$LINENO" 5 fi V_INCLS="-I$pcapH $V_INCLS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libpcap" >&5 $as_echo "$libpcap" >&6; } # Extract the first word of "pcap-config", so it can be a program name with args. set dummy pcap-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PCAP_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PCAP_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PCAP_CONFIG="$PCAP_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $d do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PCAP_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PCAP_CONFIG=$ac_cv_path_PCAP_CONFIG if test -n "$PCAP_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCAP_CONFIG" >&5 $as_echo "$PCAP_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -n "$PCAP_CONFIG"; then # # The libpcap directory has a pcap-config script. # Use it to get any additioal libraries needed # to link with the libpcap archive library in # that directory. # # Please read section 11.6 "Shell Substitutions" # in the autoconf manual before doing anything # to this that involves quoting. Especially note # the statement "There is just no portable way to use # double-quoted strings inside double-quoted back-quoted # expressions (pfew!)." # additional_libs=`"$PCAP_CONFIG" --additional-libs --static` libpcap="$libpcap $additional_libs" fi fi LIBS="$libpcap $LIBS" if ! test -n "$PCAP_CONFIG" ; then # # We don't have pcap-config; find out any additional link flags # we need. (If we have pcap-config, we assume it tells us what # we need.) # case "$host_os" in aix*) # # If libpcap is DLPI-based, we have to use /lib/pse.exp if # present, as we use the STREAMS routines. # # (XXX - true only if we're linking with a static libpcap?) # pseexe="/lib/pse.exp" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $pseexe" >&5 $as_echo_n "checking for $pseexe... " >&6; } if test -f $pseexe ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } LIBS="$LIBS -I:$pseexe" fi # # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as # we use them to load the BPF module. # # (XXX - true only if we're linking with a static libpcap?) # LIBS="$LIBS -lodm -lcfg" ;; esac fi ac_fn_c_check_func "$LINENO" "pcap_loop" "ac_cv_func_pcap_loop" if test "x$ac_cv_func_pcap_loop" = xyes; then : else as_fn_error $? "This is a bug, please follow the guidelines in CONTRIBUTING and include the config.log file in your report. If you have downloaded libpcap from tcpdump.org, and built it yourself, please also include the config.log file from the libpcap source directory, the Makefile from the libpcap source directory, and the output of the make process for libpcap, as this could be a problem with the libpcap that was built, and we will not be able to determine why this is happening, and thus will not be able to fix it, without that information, as we have not been able to reproduce this problem ourselves." "$LINENO" 5 fi # # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate # libraries (e.g., "-lsocket -lnsl" on Solaris). # # You are in a twisty little maze of UN*Xes, all different. # Some might not have ether_ntohost(). # Some might have it, but not declare it in any header file. # Some might have it, but declare it in . # Some might have it, but declare it in # (And some might have it but document it as something declared in # , although appears to work.) # # Before you is a C compiler. # for ac_func in ether_ntohost do : ac_fn_c_check_func "$LINENO" "ether_ntohost" "ac_cv_func_ether_ntohost" if test "x$ac_cv_func_ether_ntohost" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ETHER_NTOHOST 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for buggy ether_ntohost" >&5 $as_echo_n "checking for buggy ether_ntohost... " >&6; } if ${ac_cv_buggy_ether_ntohost+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_buggy_ether_ntohost="not while cross-compiling" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main(int argc, char **argv) { u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; char name[MAXHOSTNAMELEN]; ether_ntohost(name, (struct ether_addr *)ea); exit(0); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_buggy_ether_ntohost=no else ac_cv_buggy_ether_ntohost=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buggy_ether_ntohost" >&5 $as_echo "$ac_cv_buggy_ether_ntohost" >&6; } if test "$ac_cv_buggy_ether_ntohost" = "no"; then $as_echo "#define USE_ETHER_NTOHOST 1" >>confdefs.h fi fi done if test "$ac_cv_func_ether_ntohost" = yes -a \ "$ac_cv_buggy_ether_ntohost" = "no"; then # # OK, we have ether_ntohost(). Do we have ? # if test "$ac_cv_header_netinet_if_ether_h" = yes; then # # Yes. Does it declare ether_ntohost()? # ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" " #include #include #include #include struct mbuf; struct rtentry; #include #include " if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then : $as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h fi fi # # Did that succeed? # if test "$ac_cv_have_decl_ether_ntohost" != yes; then # # No, how about , as on Linux? # for ac_header in netinet/ether.h do : ac_fn_c_check_header_mongrel "$LINENO" "netinet/ether.h" "ac_cv_header_netinet_ether_h" "$ac_includes_default" if test "x$ac_cv_header_netinet_ether_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NETINET_ETHER_H 1 _ACEOF fi done if test "$ac_cv_header_netinet_ether_h" = yes; then # # We have it - does it declare ether_ntohost()? # Unset ac_cv_have_decl_ether_ntohost so we don't # treat the previous failure as a cached value and # suppress the next test. # unset ac_cv_have_decl_ether_ntohost ac_fn_c_check_decl "$LINENO" "ether_ntohost" "ac_cv_have_decl_ether_ntohost" " #include " if test "x$ac_cv_have_decl_ether_ntohost" = xyes; then : $as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_NTOHOST /**/" >>confdefs.h fi 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_fn_c_check_type "$LINENO" "struct ether_addr" "ac_cv_type_struct_ether_addr" " #include #include #include #include struct mbuf; struct rtentry; #include #include " if test "x$ac_cv_type_struct_ether_addr" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_ETHER_ADDR 1 _ACEOF fi $as_echo "#define HAVE_DECL_ETHER_NTOHOST 0" >>confdefs.h else $as_echo "#define HAVE_DECL_ETHER_NTOHOST 1" >>confdefs.h fi fi # libdlpi is needed for Solaris 11 and later. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5 $as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; } if ${ac_cv_lib_dlpi_dlpi_walk+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldlpi -L/lib $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlpi_walk (); int main () { return dlpi_walk (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dlpi_dlpi_walk=yes else ac_cv_lib_dlpi_dlpi_walk=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dlpi_dlpi_walk" >&5 $as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; } if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then : LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS" fi ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks" if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then : $as_echo "#define HAVE_PCAP_LIST_DATALINKS 1" >>confdefs.h for ac_func in pcap_free_datalinks do : ac_fn_c_check_func "$LINENO" "pcap_free_datalinks" "ac_cv_func_pcap_free_datalinks" if test "x$ac_cv_func_pcap_free_datalinks" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_FREE_DATALINKS 1 _ACEOF fi done else case " $LIBOBJS " in *" datalinks.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS datalinks.$ac_objext" ;; esac fi for ac_func in pcap_set_datalink do : ac_fn_c_check_func "$LINENO" "pcap_set_datalink" "ac_cv_func_pcap_set_datalink" if test "x$ac_cv_func_pcap_set_datalink" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_SET_DATALINK 1 _ACEOF fi done ac_fn_c_check_func "$LINENO" "pcap_datalink_name_to_val" "ac_cv_func_pcap_datalink_name_to_val" if test "x$ac_cv_func_pcap_datalink_name_to_val" = xyes; then : $as_echo "#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1" >>confdefs.h ac_fn_c_check_func "$LINENO" "pcap_datalink_val_to_description" "ac_cv_func_pcap_datalink_val_to_description" if test "x$ac_cv_func_pcap_datalink_val_to_description" = xyes; then : $as_echo "#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1" >>confdefs.h else case " $LIBOBJS " in *" dlnames.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dlnames.$ac_objext" ;; esac fi else case " $LIBOBJS " in *" dlnames.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dlnames.$ac_objext" ;; esac fi for ac_func in pcap_breakloop do : ac_fn_c_check_func "$LINENO" "pcap_breakloop" "ac_cv_func_pcap_breakloop" if test "x$ac_cv_func_pcap_breakloop" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_BREAKLOOP 1 _ACEOF fi done ac_fn_c_check_func "$LINENO" "pcap_dump_ftell" "ac_cv_func_pcap_dump_ftell" if test "x$ac_cv_func_pcap_dump_ftell" = xyes; then : $as_echo "#define HAVE_PCAP_DUMP_FTELL 1" >>confdefs.h else case " $LIBOBJS " in *" pcap_dump_ftell.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS pcap_dump_ftell.$ac_objext" ;; esac fi # # Do we have the new open API? Check for pcap_create, and assume that, # if we do, we also have pcap_activate() and the other new routines # introduced in libpcap 1.0.0. # for ac_func in pcap_create do : ac_fn_c_check_func "$LINENO" "pcap_create" "ac_cv_func_pcap_create" if test "x$ac_cv_func_pcap_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_CREATE 1 _ACEOF fi done if test $ac_cv_func_pcap_create = "yes" ; then # # OK, do we have pcap_set_tstamp_type? If so, assume we have # pcap_list_tstamp_types and pcap_free_tstamp_types as well. # for ac_func in pcap_set_tstamp_type do : ac_fn_c_check_func "$LINENO" "pcap_set_tstamp_type" "ac_cv_func_pcap_set_tstamp_type" if test "x$ac_cv_func_pcap_set_tstamp_type" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_SET_TSTAMP_TYPE 1 _ACEOF fi done # # And do we have pcap_set_tstamp_precision? If so, we assume # we also have pcap_open_offline_with_tstamp_precision. # for ac_func in pcap_set_tstamp_precision do : ac_fn_c_check_func "$LINENO" "pcap_set_tstamp_precision" "ac_cv_func_pcap_set_tstamp_precision" if test "x$ac_cv_func_pcap_set_tstamp_precision" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_SET_TSTAMP_PRECISION 1 _ACEOF fi done fi # # Check for a miscellaneous collection of functions which we use # if we have them. # for ac_func in pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test $ac_cv_func_pcap_findalldevs = "yes" ; then savedcppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $V_INCLS" ac_fn_c_check_type "$LINENO" "pcap_if_t" "ac_cv_type_pcap_if_t" "#include " if test "x$ac_cv_type_pcap_if_t" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_IF_T 1 _ACEOF fi CPPFLAGS="$savedcppflags" fi if test $ac_cv_func_pcap_lib_version = "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_version is defined by libpcap" >&5 $as_echo_n "checking whether pcap_version is defined by libpcap... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { extern char pcap_version[]; return (int)pcap_version; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_lbl_cv_pcap_version_defined=yes else ac_lbl_cv_pcap_version_defined=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_lbl_cv_pcap_version_defined" = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # # Check for special debugging functions # for ac_func in pcap_set_parser_debug do : ac_fn_c_check_func "$LINENO" "pcap_set_parser_debug" "ac_cv_func_pcap_set_parser_debug" if test "x$ac_cv_func_pcap_set_parser_debug" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_SET_PARSER_DEBUG 1 _ACEOF fi done if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then # # OK, we don't have pcap_set_parser_debug() to set the libpcap # filter expression parser debug flag; can we directly set the # flag? { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_debug is defined by libpcap" >&5 $as_echo_n "checking whether pcap_debug is defined by libpcap... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { extern int pcap_debug; return pcap_debug; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_lbl_cv_pcap_debug_defined=yes else ac_lbl_cv_pcap_debug_defined=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_PCAP_DEBUG 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # # OK, what about "yydebug"? # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yydebug is defined by libpcap" >&5 $as_echo_n "checking whether yydebug is defined by libpcap... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { extern int yydebug; return yydebug; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_lbl_cv_yydebug_defined=yes else ac_lbl_cv_yydebug_defined=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_lbl_cv_yydebug_defined" = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_YYDEBUG 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi for ac_func in pcap_set_optimizer_debug do : ac_fn_c_check_func "$LINENO" "pcap_set_optimizer_debug" "ac_cv_func_pcap_set_optimizer_debug" if test "x$ac_cv_func_pcap_set_optimizer_debug" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_SET_OPTIMIZER_DEBUG 1 _ACEOF fi done ac_fn_c_check_func "$LINENO" "bpf_dump" "ac_cv_func_bpf_dump" if test "x$ac_cv_func_bpf_dump" = xyes; then : $as_echo "#define HAVE_BPF_DUMP 1" >>confdefs.h else case " $LIBOBJS " in *" bpf_dump.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS bpf_dump.$ac_objext" ;; esac fi V_GROUP=0 if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then V_GROUP=wheel fi # # Assume V7/BSD convention for man pages (file formats in section 5, # miscellaneous info in section 7). # MAN_FILE_FORMATS=5 MAN_MISC_INFO=7 case "$host_os" in aix*) $as_echo "#define _SUN 1" >>confdefs.h ;; hpux*) # # Use System V conventions for man pages. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; irix*) V_GROUP=sys # # Use System V conventions for man pages. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; osf*) V_GROUP=system # # Use System V conventions for man pages. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; solaris*) V_GROUP=sys # # Use System V conventions for man pages. # MAN_FILE_FORMATS=4 MAN_MISC_INFO=5 ;; esac if test -f /dev/bpf0 ; then V_GROUP=bpf fi # # Make sure we have definitions for all the C99 specified-width types # (regardless of whether the environment is a C99 environment or not). # ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" case $ac_cv_c_int8_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int8_t $ac_cv_c_int8_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" case $ac_cv_c_int16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int16_t $ac_cv_c_int16_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" case $ac_cv_c_int32_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int32_t $ac_cv_c_int32_t _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" case $ac_cv_c_int64_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int64_t $ac_cv_c_int64_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) $as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint8_t $ac_cv_c_uint8_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define uint16_t $ac_cv_c_uint16_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( *) $as_echo "#define _UINT64_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint64_t $ac_cv_c_uint64_t _ACEOF ;; esac # # Make sure we have a definition for C99's uintptr_t (regardless of # whether the environment is a C99 environment or not). # ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" if test "x$ac_cv_type_uintptr_t" = xyes; then : $as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h else for ac_type in 'unsigned int' 'unsigned long int' \ 'unsigned long long int'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat >>confdefs.h <<_ACEOF #define uintptr_t $ac_type _ACEOF ac_type= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test -z "$ac_type" && break done fi # # Define the old BSD specified-width types in terms of the C99 types; # we may need them with libpcap include files. # ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default #include " if test "x$ac_cv_type_u_int8_t" = xyes; then : else $as_echo "#define u_int8_t uint8_t" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default #include " if test "x$ac_cv_type_u_int16_t" = xyes; then : else $as_echo "#define u_int16_t uint16_t" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default #include " if test "x$ac_cv_type_u_int32_t" = xyes; then : else $as_echo "#define u_int32_t uint32_t" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default #include " if test "x$ac_cv_type_u_int64_t" = xyes; then : else $as_echo "#define u_int64_t uint64_t" >>confdefs.h fi # # Check for # for ac_header in inttypes.h do : ac_fn_c_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" if test "x$ac_cv_header_inttypes_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_INTTYPES_H 1 _ACEOF # # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros? # Some systems have an inttypes.h that doesn't define all of them. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether inttypes.h defines the PRI[doxu]64 macros" >&5 $as_echo_n "checking whether inttypes.h defines the PRI[doxu]64 macros... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include main() { printf("%" PRId64 "\n", (uint64_t)1); printf("%" PRIo64 "\n", (uint64_t)1); printf("%" PRIx64 "\n", (uint64_t)1); printf("%" PRIu64 "\n", (uint64_t)1); } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ac_lbl_inttypes_h_defines_formats=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_lbl_inttypes_h_defines_formats=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # # We don't have inttypes.h, so it obviously can't define those # macros. # ac_lbl_inttypes_h_defines_formats=no fi done if test "$ac_lbl_inttypes_h_defines_formats" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %lx can be used to format 64-bit integers" >&5 $as_echo_n "checking whether %lx can be used to format 64-bit integers... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef HAVE_INTTYPES_H #include # endif #include #include main() { uint64_t t = 1; char strbuf[16+1]; sprintf(strbuf, "%016lx", t << 32); if (strcmp(strbuf, "0000000100000000") == 0) exit(0); else exit(1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : $as_echo "#define PRId64 \"ld\"" >>confdefs.h $as_echo "#define PRIo64 \"lo\"" >>confdefs.h $as_echo "#define PRIx64 \"lx\"" >>confdefs.h $as_echo "#define PRIu64 \"lu\"" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %llx can be used to format 64-bit integers" >&5 $as_echo_n "checking whether %llx can be used to format 64-bit integers... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef HAVE_INTTYPES_H #include # endif #include #include main() { uint64_t t = 1; char strbuf[16+1]; sprintf(strbuf, "%016llx", t << 32); if (strcmp(strbuf, "0000000100000000") == 0) exit(0); else exit(1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : $as_echo "#define PRId64 \"lld\"" >>confdefs.h $as_echo "#define PRIo64 \"llo\"" >>confdefs.h $as_echo "#define PRIx64 \"llx\"" >>confdefs.h $as_echo "#define PRIu64 \"llu\"" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %Lx can be used to format 64-bit integers" >&5 $as_echo_n "checking whether %Lx can be used to format 64-bit integers... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef HAVE_INTTYPES_H #include # endif #include #include main() { uint64_t t = 1; char strbuf[16+1]; sprintf(strbuf, "%016Lx", t << 32); if (strcmp(strbuf, "0000000100000000") == 0) exit(0); else exit(1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : $as_echo "#define PRId64 \"Ld\"" >>confdefs.h $as_echo "#define PRIo64 \"Lo\"" >>confdefs.h $as_echo "#define PRIx64 \"Lx\"" >>confdefs.h $as_echo "#define PRIu64 \"Lu\"" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether %qx can be used to format 64-bit integers" >&5 $as_echo_n "checking whether %qx can be used to format 64-bit integers... " >&6; } if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # ifdef HAVE_INTTYPES_H #include # endif #include #include main() { uint64_t t = 1; char strbuf[16+1]; sprintf(strbuf, "%016qx", t << 32); if (strcmp(strbuf, "0000000100000000") == 0) exit(0); else exit(1); } _ACEOF if ac_fn_c_try_run "$LINENO"; then : $as_echo "#define PRId64 \"qd\"" >>confdefs.h $as_echo "#define PRIo64 \"qo\"" >>confdefs.h $as_echo "#define PRIx64 \"qx\"" >>confdefs.h $as_echo "#define PRIu64 \"qu\"" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "neither %llx nor %Lx nor %qx worked on a 64-bit integer" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi # # Check for some headers introduced in later versions of libpcap # and used by some printers. # # Those headers use the {u_}intN_t types, so we must do this after # we check for what's needed to get them defined. # savedcppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $V_INCLS" for ac_header in pcap/bluetooth.h do : ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include \"netdissect-stdinc.h\" " if test "x$ac_cv_header_pcap_bluetooth_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_BLUETOOTH_H 1 _ACEOF fi done for ac_header in pcap/nflog.h do : ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"netdissect-stdinc.h\" " if test "x$ac_cv_header_pcap_nflog_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_NFLOG_H 1 _ACEOF fi done for ac_header in pcap/usb.h do : ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include \"netdissect-stdinc.h\" " if test "x$ac_cv_header_pcap_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PCAP_USB_H 1 _ACEOF fi done CPPFLAGS="$savedcppflags" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AR" = x; then AR="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi else AR="$ac_cv_prog_AR" fi rm -f os-proto.h if test "${LBL_CFLAGS+set}" = set; then V_CCOPT="$V_CCOPT ${LBL_CFLAGS}" fi if test -f .devel ; then # # Skip all the warning option stuff on some compilers. # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5 $as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; } save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # # We're assuming this is clang, where # -Werror=unknown-warning-option is the appropriate # option to force the compiler to fail. # ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 $as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wall" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall" elif expr "x-Wall" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wall" elif expr "x-Wall" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wall" else CFLAGS="$CFLAGS -Wall" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wall" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5 $as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes" elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" else CFLAGS="$CFLAGS -Wmissing-prototypes" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wmissing-prototypes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5 $as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes" elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" else CFLAGS="$CFLAGS -Wstrict-prototypes" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wstrict-prototypes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wwrite-strings option" >&5 $as_echo_n "checking whether the compiler supports the -Wwrite-strings option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wwrite-strings" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wwrite-strings" elif expr "x-Wwrite-strings" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wwrite-strings" elif expr "x-Wwrite-strings" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wwrite-strings" else CFLAGS="$CFLAGS -Wwrite-strings" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wwrite-strings" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5 $as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wpointer-arith" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith" elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wpointer-arith" elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wpointer-arith" else CFLAGS="$CFLAGS -Wpointer-arith" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wpointer-arith" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcast-qual option" >&5 $as_echo_n "checking whether the compiler supports the -Wcast-qual option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wcast-qual" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcast-qual" elif expr "x-Wcast-qual" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wcast-qual" elif expr "x-Wcast-qual" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wcast-qual" else CFLAGS="$CFLAGS -Wcast-qual" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wcast-qual" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5 $as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wshadow" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow" elif expr "x-Wshadow" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wshadow" elif expr "x-Wshadow" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wshadow" else CFLAGS="$CFLAGS -Wshadow" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wshadow" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdeclaration-after-statement option" >&5 $as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement" elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement" elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement" else CFLAGS="$CFLAGS -Wdeclaration-after-statement" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wdeclaration-after-statement" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpedantic option" >&5 $as_echo_n "checking whether the compiler supports the -Wpedantic option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wpedantic" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpedantic" elif expr "x-Wpedantic" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wpedantic" elif expr "x-Wpedantic" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wpedantic" else CFLAGS="$CFLAGS -Wpedantic" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wpedantic" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wold-style-definition option" >&5 $as_echo_n "checking whether the compiler supports the -Wold-style-definition option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wold-style-definition" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wold-style-definition" elif expr "x-Wold-style-definition" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wold-style-definition" elif expr "x-Wold-style-definition" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wold-style-definition" else CFLAGS="$CFLAGS -Wold-style-definition" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wold-style-definition" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5 $as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused" elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" else CFLAGS="$CFLAGS -Wused-but-marked-unused" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -Wused-but-marked-unused" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 $as_echo_n "checking whether the compiler supports the -W option... " >&6; } save_CFLAGS="$CFLAGS" if expr "x-W" : "x-W.*" >/dev/null then CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W" elif expr "x-W" : "x-f.*" >/dev/null then CFLAGS="$CFLAGS -Werror -W" elif expr "x-W" : "x-m.*" >/dev/null then CFLAGS="$CFLAGS -Werror -W" else CFLAGS="$CFLAGS -W" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CFLAGS="$save_CFLAGS" V_CCOPT="$V_CCOPT -W" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CFLAGS="$save_CFLAGS" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5 $as_echo_n "checking whether the compiler supports generating dependencies... " >&6; } if test "$GCC" = yes ; then # # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even # though it's not); we assume that, in this case, the flag # would be -M. # ac_lbl_dependency_flag="-M" else # # Not GCC or a compiler deemed to be GCC; what platform is # this? (We're assuming that if the compiler isn't GCC # it's the compiler from the vendor of the OS; that won't # necessarily be true for x86 platforms, where it might be # the Intel C compiler.) # case "$host_os" in irix*|osf*|darwin*) # # MIPS C for IRIX, DEC C, and clang all use -M. # ac_lbl_dependency_flag="-M" ;; solaris*) # # Sun C uses -xM. # ac_lbl_dependency_flag="-xM" ;; hpux*) # # HP's older C compilers don't support this. # HP's newer C compilers support this with # either +M or +Make; the older compilers # interpret +M as something completely # different, so we use +Make so we don't # think it works with the older compilers. # ac_lbl_dependency_flag="+Make" ;; *) # # Not one of the above; assume no support for # generating dependencies. # ac_lbl_dependency_flag="" ;; esac fi # # Is ac_lbl_dependency_flag defined and, if so, does the compiler # complain about it? # # Note: clang doesn't seem to exit with an error status when handed # an unknown non-warning error, even if you pass it # -Werror=unknown-warning-option. However, it always supports # -M, so the fact that this test always succeeds with clang # isn't an issue. # if test ! -z "$ac_lbl_dependency_flag"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main(void) { return 0; } _ACEOF echo "$CC" $ac_lbl_dependency_flag conftest.c >&5 if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, with $ac_lbl_dependency_flag" >&5 $as_echo "yes, with $ac_lbl_dependency_flag" >&6; } DEPENDENCY_CFLAG="$ac_lbl_dependency_flag" MKDEP='${srcdir}/mkdep' else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # # We can't run mkdep, so have "make depend" do # nothing. # MKDEP=: fi rm -rf conftest* else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # # We can't run mkdep, so have "make depend" do # nothing. # MKDEP=: fi # # We used to set -n32 for IRIX 6 when not using GCC (presumed # to mean that we're using MIPS C or MIPSpro C); it specified # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm # not sure why that would be something to do *only* with a # .devel file; why should the ABI for which we produce code # depend on .devel? # os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'` name="lbl/os-$os.h" if test -f $name ; then ln -s $name os-proto.h $as_echo "#define HAVE_OS_PROTO_H 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: can't find $name" >&5 $as_echo "$as_me: WARNING: can't find $name" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has the sa_len member" >&5 $as_echo_n "checking if sockaddr struct has the sa_len member... " >&6; } if ${ac_cv_lbl_sockaddr_has_sa_len+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include # include int main () { u_int i = sizeof(((struct sockaddr *)0)->sa_len) ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_lbl_sockaddr_has_sa_len=yes else ac_cv_lbl_sockaddr_has_sa_len=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_sockaddr_has_sa_len" >&5 $as_echo "$ac_cv_lbl_sockaddr_has_sa_len" >&6; } if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if unaligned accesses fail" >&5 $as_echo_n "checking if unaligned accesses fail... " >&6; } if ${ac_cv_lbl_unaligned_fail+:} false; then : $as_echo_n "(cached) " >&6 else case "$host_cpu" in # # These are CPU types where: # # the CPU faults on an unaligned access, but at least some # OSes that support that CPU catch the fault and simulate # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - # the simulation is slow, so we don't want to use it; # # the CPU, I infer (from the old # # XXX: should also check that they don't do weird things (like on arm) # # comment) doesn't fault on unaligned accesses, but doesn't # do a normal unaligned fetch, either (e.g., presumably, ARM); # # for whatever reason, the test program doesn't work # (this has been claimed to be the case for several of those # CPUs - I don't know what the problem is; the problem # was reported as "the test program dumps core" for SuperH, # but that's what the test program is *supposed* to do - # it dumps core before it writes anything, so the test # for an empty output file should find an empty output # file and conclude that unaligned accesses don't work). # # This run-time test won't work if you're cross-compiling, so # in order to support cross-compiling for a particular CPU, # we have to wire in the list of CPU types anyway, as far as # I know, so perhaps we should just have a set of CPUs on # which we know it doesn't work, a set of CPUs on which we # know it does work, and have the script just fail on other # cpu types and update it when such a failure occurs. # alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) ac_cv_lbl_unaligned_fail=yes ;; *) cat >conftest.c < # include # include unsigned char a[5] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[1]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then ac_cv_lbl_unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then ac_cv_lbl_unaligned_fail=yes else ac_cv_lbl_unaligned_fail=no fi fi rm -f -r conftest* core core.conftest ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_unaligned_fail" >&5 $as_echo "$ac_cv_lbl_unaligned_fail" >&6; } if test $ac_cv_lbl_unaligned_fail = yes ; then $as_echo "#define LBL_ALIGN 1" >>confdefs.h fi # Check for OpenSSL/libressl libcrypto { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL/libressl libcrypto" >&5 $as_echo_n "checking whether to use OpenSSL/libressl libcrypto... " >&6; } # Specify location for both includes and libraries. want_libcrypto=ifavailable # Check whether --with-crypto was given. if test "${with_crypto+set}" = set; then : withval=$with_crypto; if test $withval = no then # User doesn't want to link with libcrypto. want_libcrypto=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } elif test $withval = yes then # User wants to link with libcrypto but hasn't specified # a directory. want_libcrypto=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # User wants to link with libcrypto and has specified # a directory, so use the provided value. want_libcrypto=yes libcrypto_root=$withval { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, using the version installed in $withval" >&5 $as_echo "yes, using the version installed in $withval" >&6; } # # Put the subdirectories of the libcrypto root directory # at the front of the header and library search path. # CFLAGS="-I$withval/include $CFLAGS" LIBS="-L$withval/lib $LIBS" fi else # # Use libcrypto if it's present, otherwise don't; no directory # was specified. # want_libcrypto=ifavailable { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5 $as_echo "yes, if available" >&6; } fi if test "$want_libcrypto" != "no"; then # # Don't check for libcrypto unless we have its headers; # Apple, bless their pointy little heads, apparently ship # libcrypto as a library, but not the header files, in # El Capitan, probably because they don't want you writing # nasty portable code that could run on other UN*Xes, they # want you writing code that uses their Shiny New Crypto # Library and that only runs on OS X. # ac_fn_c_check_header_mongrel "$LINENO" "openssl/crypto.h" "ac_cv_header_openssl_crypto_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_crypto_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DES_cbc_encrypt in -lcrypto" >&5 $as_echo_n "checking for DES_cbc_encrypt in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_DES_cbc_encrypt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char DES_cbc_encrypt (); int main () { return DES_cbc_encrypt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_DES_cbc_encrypt=yes else ac_cv_lib_crypto_DES_cbc_encrypt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_DES_cbc_encrypt" >&5 $as_echo "$ac_cv_lib_crypto_DES_cbc_encrypt" >&6; } if test "x$ac_cv_lib_crypto_DES_cbc_encrypt" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCRYPTO 1 _ACEOF LIBS="-lcrypto $LIBS" fi if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then for ac_header in openssl/evp.h do : ac_fn_c_check_header_mongrel "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default" if test "x$ac_cv_header_openssl_evp_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENSSL_EVP_H 1 _ACEOF fi done # # OK, then: # # 1) do we have EVP_CIPHER_CTX_new? # If so, we use it to allocate an # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be # opaque; otherwise, we allocate it ourselves. # # 2) do we have EVP_CipherInit_ex()? # If so, we use it, because we need to be # able to make two "initialize the cipher" # calls, one with the cipher and key, and # one with the IV, and, as of OpenSSL 1.1, # You Can't Do That with EVP_CipherInit(), # because a call to EVP_CipherInit() will # unconditionally clear the context, and # if you don't supply a cipher, it'll # clear the cipher, rendering the context # unusable and causing a crash. # for ac_func in EVP_CIPHER_CTX_new EVP_CipherInit_ex do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done fi fi fi # Check for libcap-ng { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use libcap-ng" >&5 $as_echo_n "checking whether to use libcap-ng... " >&6; } # Specify location for both includes and libraries. want_libcap_ng=ifavailable # Check whether --with-cap_ng was given. if test "${with_cap_ng+set}" = set; then : withval=$with_cap_ng; if test $withval = no then want_libcap_ng=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } elif test $withval = yes then want_libcap_ng=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi else # # Use libcap-ng if it's present, otherwise don't. # want_libcap_ng=ifavailable { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5 $as_echo "yes, if available" >&6; } fi if test "$want_libcap_ng" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capng_change_id in -lcap-ng" >&5 $as_echo_n "checking for capng_change_id in -lcap-ng... " >&6; } if ${ac_cv_lib_cap_ng_capng_change_id+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcap-ng $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char capng_change_id (); int main () { return capng_change_id (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_cap_ng_capng_change_id=yes else ac_cv_lib_cap_ng_capng_change_id=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cap_ng_capng_change_id" >&5 $as_echo "$ac_cv_lib_cap_ng_capng_change_id" >&6; } if test "x$ac_cv_lib_cap_ng_capng_change_id" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCAP_NG 1 _ACEOF LIBS="-lcap-ng $LIBS" fi for ac_header in cap-ng.h do : ac_fn_c_check_header_mongrel "$LINENO" "cap-ng.h" "ac_cv_header_cap_ng_h" "$ac_includes_default" if test "x$ac_cv_header_cap_ng_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_CAP_NG_H 1 _ACEOF fi done fi if test "$missing_includes" = "yes"; then CPPFLAGS="$CPPFLAGS -I$srcdir/missing" V_INCLS="$V_INCLS -I$srcdir/missing" fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_config_headers="$ac_config_headers config.h" ac_config_commands="$ac_config_commands default-1" ac_config_files="$ac_config_files Makefile tcpdump.1" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "tcpdump.1") CONFIG_FILES="$CONFIG_FILES tcpdump.1" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "default-1":C) if test -f .devel; then echo timestamp > stamp-h cat Makefile-devel-adds >> Makefile make depend fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi exit 0 Index: vendor/tcpdump/dist/configure.ac =================================================================== --- vendor/tcpdump/dist/configure.ac (nonexistent) +++ vendor/tcpdump/dist/configure.ac (revision 353144) @@ -0,0 +1,1003 @@ +dnl Copyright (c) 1994, 1995, 1996, 1997 +dnl The Regents of the University of California. All rights reserved. +dnl +dnl Process this file with autoconf to produce a configure script. +dnl + +# +# See +# +# http://ftp.gnu.org/gnu/config/README +# +# for the URLs to use to fetch new versions of config.guess and +# config.sub. +# + +AC_PREREQ(2.61) +AC_INIT(tcpdump.c) + +AC_CANONICAL_HOST + +AC_LBL_C_INIT_BEFORE_CC(V_INCLS) +AC_PROG_CC +AC_LBL_C_INIT(V_CCOPT, V_INCLS) +AC_LBL_C_INLINE +AC_C___ATTRIBUTE__ +if test "$ac_cv___attribute__" = "yes"; then + AC_C___ATTRIBUTE___UNUSED + AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER + AC_C___ATTRIBUTE___FORMAT + if test "$ac_cv___attribute___format" = "yes"; then + AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER + fi +fi + +AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h) +AC_CHECK_HEADERS(net/pfvar.h, , , [#include +#include +#include ]) +if test "$ac_cv_header_net_pfvar_h" = yes; then + AC_CHECK_HEADERS(net/if_pflog.h, , , [#include + #include + #include + #include ]) + if test "$ac_cv_header_net_if_pflog_h" = yes; then + LOCALSRC="print-pflog.c $LOCALSRC" + fi +fi +AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include +#include ]) +if test "$ac_cv_header_netinet_if_ether_h" != yes; then + # + # The simple test didn't work. + # Do we need to include first? + # Unset ac_cv_header_netinet_if_ether_h so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + AC_MSG_NOTICE([Rechecking with some additional includes]) + unset ac_cv_header_netinet_if_ether_h + AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include +#include +#include +struct mbuf; +struct rtentry; +#include ]) +fi + +AC_HEADER_TIME + +case "$host_os" in + +darwin*) + AC_ARG_ENABLE(universal, + AC_HELP_STRING([--disable-universal],[don't build universal on OS X])) + if test "$enable_universal" != "no"; then + case "$host_os" in + + darwin9.*) + # + # Leopard. Build for x86 and 32-bit PowerPC, with + # x86 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch i386 -arch ppc" + LDFLAGS="$LDFLAGS -arch i386 -arch ppc" + ;; + + darwin10.*) + # + # Snow Leopard. Build for x86-64 and x86, with + # x86-64 first. (That's what Apple does.) + # + V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" + LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" + ;; + esac + fi + ;; +esac + + +AC_ARG_WITH(smi, +[ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes] + --without-smi don't link with libsmi],, + with_smi=yes) + +if test "x$with_smi" != "xno" ; then + AC_CHECK_HEADER(smi.h, + [ + # + # OK, we found smi.h. Do we have libsmi with smiInit? + # + AC_CHECK_LIB(smi, smiInit, + [ + # + # OK, we have libsmi with smiInit. Can we use it? + # + AC_MSG_CHECKING([whether to enable libsmi]) + savedlibs="$LIBS" + LIBS="-lsmi $LIBS" + AC_TRY_RUN( + [ +/* libsmi available check */ +#include +main() +{ + int current, revision, age, n; + const int required = 2; + if (smiInit("")) + exit(1); + if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) + exit(2); + n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); + if (n != 3) + exit(3); + if (required < current - age || required > current) + exit(4); + exit(0); +} + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(USE_LIBSMI, 1, + [Define if you enable support for libsmi]) + ], + [ + dnl autoconf documentation says that + dnl $? contains the exit value. + dnl reality is that it does not. + dnl We leave this in just in case + dnl autoconf ever comes back to + dnl match the documentation. + case $? in + 1) AC_MSG_RESULT(no - smiInit failed) ;; + 2) AC_MSG_RESULT(no - header/library version mismatch) ;; + 3) AC_MSG_RESULT(no - can't determine library version) ;; + 4) AC_MSG_RESULT(no - too old) ;; + *) AC_MSG_RESULT(no) ;; + esac + LIBS="$savedlibs" + ], + [ + AC_MSG_RESULT(not when cross-compiling) + LIBS="$savedlibs" + ] + ) + ]) + ]) +fi + +AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) +AC_ARG_ENABLE(smb, +[ --enable-smb enable possibly-buggy SMB printer [default=no] + --disable-smb disable possibly-buggy SMB printer],, + enableval=no) +case "$enableval" in +yes) AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_SMB, 1, + [define if you want to build the possibly-buggy SMB printer]) + LOCALSRC="print-smb.c smbutil.c $LOCALSRC" + ;; +*) AC_MSG_RESULT(no) + ;; +esac + +AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME]) +AC_MSG_CHECKING([whether to drop root privileges by default]) +if test ! -z "$with_user" ; then + AC_DEFINE_UNQUOTED(WITH_USER, "$withval", + [define if should drop privileges by default]) + AC_MSG_RESULT(to \"$withval\") +else + AC_MSG_RESULT(no) +fi + +AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY]) +AC_MSG_CHECKING([whether to chroot]) +if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then + AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval", + [define if should chroot when dropping privileges]) + AC_MSG_RESULT(to \"$withval\") +else + AC_MSG_RESULT(no) +fi + +AC_ARG_WITH(sandbox-capsicum, + AS_HELP_STRING([--with-sandbox-capsicum], + [use Capsicum security functions @<:@default=yes, if available@:>@])) +# +# Check whether various functions are available. If any are, set +# ac_lbl_capsicum_function_seen to yes; if any are not, set +# ac_lbl_capsicum_function_not_seen to yes. +# +# We don't check cap_rights_init(), as it's a macro, wrapping another +# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS() +# doesn't handle that. +# +# All of the ones we check for must be available in order to enable +# capsicum sandboxing. +# +# XXX - do we need to check for all of them, or are there some that, if +# present, imply others are present? +# +if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then + AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat, + ac_lbl_capsicum_function_seen=yes, + ac_lbl_capsicum_function_not_seen=yes) +fi +AC_MSG_CHECKING([whether to sandbox using capsicum]) +if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then + AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +# +# We must check this before checking whether to check the OS's IPv6, +# support because, on some platforms (such as SunOS 5.x), the test +# program requires the extra networking libraries. +# +AC_LBL_LIBRARY_NET + +# +# Check whether AF_INET6 and struct in6_addr are defined. +# If they aren't both defined, we don't have sufficient OS +# support for IPv6, so we don't look for IPv6 support libraries, +# and we define AF_INET6 and struct in6_addr ourselves. +# +AC_MSG_CHECKING([whether the operating system supports IPv6]) +AC_COMPILE_IFELSE( + [ + AC_LANG_SOURCE( + [[ +/* AF_INET6 available check */ +#include +#include +#include +#ifdef AF_INET6 +void +foo(struct in6_addr *addr) +{ + memset(addr, 0, sizeof (struct in6_addr)); +} +#else +#error "AF_INET6 not defined" +#endif + ]]) + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1, + [define if the OS provides AF_INET6 and struct in6_addr]) + ipv6=yes + ], + [ + AC_MSG_RESULT(no) + ipv6=no + ] +) + +ipv6type=unknown +ipv6lib=none +ipv6trylibc=no + +if test "$ipv6" = "yes"; then + AC_MSG_CHECKING([ipv6 stack type]) + for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do + case $i in + inria) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, +[#include +#ifdef IPV6_INRIA_VERSION +yes +#endif], + [ipv6type=$i]) + ;; + kame) + dnl http://www.kame.net/ + AC_EGREP_CPP(yes, +[#include +#ifdef __KAME__ +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib; + ipv6trylibc=yes]) + ;; + linux-glibc) + dnl http://www.v6.linux.or.jp/ + AC_EGREP_CPP(yes, +[#include +#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 +yes +#endif], + [ipv6type=$i]) + ;; + linux-libinet6) + dnl http://www.v6.linux.or.jp/ + dnl + dnl This also matches Solaris 8 and Tru64 UNIX 5.1, + dnl and possibly other versions of those OSes + dnl + if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then + ipv6type=$i + ipv6lib=inet6 + ipv6libdir=/usr/inet6/lib + ipv6trylibc=yes; + CFLAGS="-I/usr/inet6/include $CFLAGS" + fi + ;; + toshiba) + AC_EGREP_CPP(yes, +[#include +#ifdef _TOSHIBA_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib]) + ;; + v6d) + AC_EGREP_CPP(yes, +[#include +#ifdef __V6D__ +yes +#endif], + [ipv6type=$i; + ipv6lib=v6; + ipv6libdir=/usr/local/v6/lib; + CFLAGS="-I/usr/local/v6/include $CFLAGS"]) + ;; + zeta) + AC_EGREP_CPP(yes, +[#include +#ifdef _ZETA_MINAMI_INET6 +yes +#endif], + [ipv6type=$i; + ipv6lib=inet6; + ipv6libdir=/usr/local/v6/lib]) + ;; + esac + if test "$ipv6type" != "unknown"; then + break + fi + done + AC_MSG_RESULT($ipv6type) +fi + +if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then + if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then + LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" + echo "You have $ipv6lib library, using it" + else + if test "$ipv6trylibc" = "yes"; then + echo "You do not have $ipv6lib library, using libc" + else + echo 'Fatal: no $ipv6lib library found. cannot continue.' + echo "You need to fetch lib$ipv6lib.a from appropriate" + echo 'ipv6 kit and compile beforehand.' + exit 1 + fi + fi +fi + +AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long) +AC_CHECK_FUNCS(fork vfork strftime) +AC_CHECK_FUNCS(setlinebuf alarm) + +needsnprintf=no +AC_CHECK_FUNCS(vsnprintf snprintf,, + [needsnprintf=yes]) +if test $needsnprintf = yes; then + AC_LIBOBJ(snprintf) +fi + +AC_LBL_TYPE_SIGNAL + +AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc + +dnl Some platforms may need -lnsl for getrpcbynumber. +AC_SEARCH_LIBS(getrpcbynumber, nsl, + AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()])) + +AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) + +# +# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate +# libraries (e.g., "-lsocket -lnsl" on Solaris). +# +# You are in a twisty little maze of UN*Xes, all different. +# Some might not have ether_ntohost(). +# Some might have it, but not declare it in any header file. +# Some might have it, but declare it in . +# Some might have it, but declare it in +# (And some might have it but document it as something declared in +# , although appears to work.) +# +# Before you is a C compiler. +# +AC_CHECK_FUNCS(ether_ntohost, [ + AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ + AC_TRY_RUN([ + #include + #include + #include + #include + + int + main(int argc, char **argv) + { + u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; + char name[MAXHOSTNAMELEN]; + + ether_ntohost(name, (struct ether_addr *)ea); + exit(0); + } + ], [ac_cv_buggy_ether_ntohost=no], + [ac_cv_buggy_ether_ntohost=yes], + [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) + if test "$ac_cv_buggy_ether_ntohost" = "no"; then + AC_DEFINE(USE_ETHER_NTOHOST, 1, + [define if you have ether_ntohost() and it works]) + fi +]) +if test "$ac_cv_func_ether_ntohost" = yes -a \ + "$ac_cv_buggy_ether_ntohost" = "no"; then + # + # OK, we have ether_ntohost(). Do we have ? + # + if test "$ac_cv_header_netinet_if_ether_h" = yes; then + # + # Yes. Does it declare 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']) + ],, + [ +#include +#include +#include +#include +struct mbuf; +struct rtentry; +#include +#include + ]) + fi + # + # Did that succeed? + # + if test "$ac_cv_have_decl_ether_ntohost" != yes; then + # + # No, how about , as on Linux? + # + AC_CHECK_HEADERS(netinet/ether.h) + if test "$ac_cv_header_netinet_ether_h" = yes; then + # + # We have it - does it declare ether_ntohost()? + # Unset ac_cv_have_decl_ether_ntohost so we don't + # treat the previous failure as a cached value and + # suppress the next test. + # + unset ac_cv_have_decl_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']) + ],, + [ +#include + ]) + 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 +#include +#include +#include +struct mbuf; +struct rtentry; +#include +#include + ]) + 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 + +# libdlpi is needed for Solaris 11 and later. +AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib) + +dnl +dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()", +dnl and "pcap_datalink_name_to_val()", and use substitute versions +dnl if they're not present. +dnl +AC_CHECK_FUNC(pcap_list_datalinks, + [ + AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1, + [define if libpcap has pcap_list_datalinks()]) + AC_CHECK_FUNCS(pcap_free_datalinks) + ], + [ + AC_LIBOBJ(datalinks) + ]) +AC_CHECK_FUNCS(pcap_set_datalink) +AC_CHECK_FUNC(pcap_datalink_name_to_val, + [ + AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1, + [define if libpcap has pcap_datalink_name_to_val()]) + AC_CHECK_FUNC(pcap_datalink_val_to_description, + AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1, + [define if libpcap has pcap_datalink_val_to_description()]), + [ + AC_LIBOBJ(dlnames) + ]) + ], + [ + AC_LIBOBJ(dlnames) + ]) + +dnl +dnl Check for "pcap_breakloop()"; you can't substitute for it if +dnl it's absent (it has hooks into the live capture routines), +dnl so just define the HAVE_ value if it's there. +dnl +AC_CHECK_FUNCS(pcap_breakloop) + +dnl +dnl Check for "pcap_dump_ftell()" and use a substitute version +dnl if it's not present. +dnl +AC_CHECK_FUNC(pcap_dump_ftell, + AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1, + [define if libpcap has pcap_dump_ftell()]), + [ + AC_LIBOBJ(pcap_dump_ftell) + ]) + +# +# Do we have the new open API? Check for pcap_create, and assume that, +# if we do, we also have pcap_activate() and the other new routines +# introduced in libpcap 1.0.0. +# +AC_CHECK_FUNCS(pcap_create) +if test $ac_cv_func_pcap_create = "yes" ; then + # + # OK, do we have pcap_set_tstamp_type? If so, assume we have + # pcap_list_tstamp_types and pcap_free_tstamp_types as well. + # + AC_CHECK_FUNCS(pcap_set_tstamp_type) + # + # And do we have pcap_set_tstamp_precision? If so, we assume + # we also have pcap_open_offline_with_tstamp_precision. + # + AC_CHECK_FUNCS(pcap_set_tstamp_precision) +fi + +# +# Check for a miscellaneous collection of functions which we use +# if we have them. +# +AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode) +if test $ac_cv_func_pcap_findalldevs = "yes" ; then +dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may +dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't +dnl have pcap_if_t. + savedcppflags="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $V_INCLS" + AC_CHECK_TYPES(pcap_if_t, , , [#include ]) + CPPFLAGS="$savedcppflags" +fi + +if test $ac_cv_func_pcap_lib_version = "no" ; then + AC_MSG_CHECKING(whether pcap_version is defined by libpcap) + AC_TRY_LINK([], + [ + extern char pcap_version[]; + + return (int)pcap_version; + ], + ac_lbl_cv_pcap_version_defined=yes, + ac_lbl_cv_pcap_version_defined=no) + if test "$ac_lbl_cv_pcap_version_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version]) + else + AC_MSG_RESULT(no) + fi +fi + +# +# Check for special debugging functions +# +AC_CHECK_FUNCS(pcap_set_parser_debug) +if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then + # + # OK, we don't have pcap_set_parser_debug() to set the libpcap + # filter expression parser debug flag; can we directly set the + # flag? + AC_MSG_CHECKING(whether pcap_debug is defined by libpcap) + AC_TRY_LINK([], + [ + extern int pcap_debug; + + return pcap_debug; + ], + ac_lbl_cv_pcap_debug_defined=yes, + ac_lbl_cv_pcap_debug_defined=no) + if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug]) + else + AC_MSG_RESULT(no) + # + # OK, what about "yydebug"? + # + AC_MSG_CHECKING(whether yydebug is defined by libpcap) + AC_TRY_LINK([], + [ + extern int yydebug; + + return yydebug; + ], + ac_lbl_cv_yydebug_defined=yes, + ac_lbl_cv_yydebug_defined=no) + if test "$ac_lbl_cv_yydebug_defined" = yes ; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug]) + else + AC_MSG_RESULT(no) + fi + fi +fi +AC_CHECK_FUNCS(pcap_set_optimizer_debug) +AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 + +V_GROUP=0 +if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then + V_GROUP=wheel +fi +# +# Assume V7/BSD convention for man pages (file formats in section 5, +# miscellaneous info in section 7). +# +MAN_FILE_FORMATS=5 +MAN_MISC_INFO=7 +case "$host_os" in + +aix*) + dnl Workaround to enable certain features + AC_DEFINE(_SUN,1,[define on AIX to get certain functions]) + ;; + +hpux*) + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +irix*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +osf*) + V_GROUP=system + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; + +solaris*) + V_GROUP=sys + + # + # Use System V conventions for man pages. + # + MAN_FILE_FORMATS=4 + MAN_MISC_INFO=5 + ;; +esac + +if test -f /dev/bpf0 ; then + V_GROUP=bpf +fi + +# +# Make sure we have definitions for all the C99 specified-width types +# (regardless of whether the environment is a C99 environment or not). +# +AC_TYPE_INT8_T +AC_TYPE_INT16_T +AC_TYPE_INT32_T +AC_TYPE_INT64_T +AC_TYPE_UINT8_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T + +# +# Make sure we have a definition for C99's uintptr_t (regardless of +# whether the environment is a C99 environment or not). +# +AC_TYPE_UINTPTR_T + +# +# Define the old BSD specified-width types in terms of the C99 types; +# we may need them with libpcap include files. +# +AC_CHECK_TYPE([u_int8_t], , + [AC_DEFINE([u_int8_t], [uint8_t], + [Define to `uint8_t' if u_int8_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int16_t], , + [AC_DEFINE([u_int16_t], [uint16_t], + [Define to `uint16_t' if u_int16_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int32_t], , + [AC_DEFINE([u_int32_t], [uint32_t], + [Define to `uint32_t' if u_int32_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) +AC_CHECK_TYPE([u_int64_t], , + [AC_DEFINE([u_int64_t], [uint64_t], + [Define to `uint64_t' if u_int64_t not defined.])], + [AC_INCLUDES_DEFAULT +#include +]) + +# +# Check for +# +AC_CHECK_HEADERS(inttypes.h, + [ + # + # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros? + # Some systems have an inttypes.h that doesn't define all of them. + # + AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]]) + AC_COMPILE_IFELSE( + [ + AC_LANG_SOURCE( + [[ + #include + #include + #include + + main() + { + printf("%" PRId64 "\n", (uint64_t)1); + printf("%" PRIo64 "\n", (uint64_t)1); + printf("%" PRIx64 "\n", (uint64_t)1); + printf("%" PRIu64 "\n", (uint64_t)1); + } + ]]) + ], + [ + AC_MSG_RESULT(yes) + ac_lbl_inttypes_h_defines_formats=yes + ], + [ + AC_MSG_RESULT(no) + ac_lbl_inttypes_h_defines_formats=no + ]) + ], + [ + # + # We don't have inttypes.h, so it obviously can't define those + # macros. + # + ac_lbl_inttypes_h_defines_formats=no + ]) +if test "$ac_lbl_inttypes_h_defines_formats" = no; then + AC_LBL_CHECK_64BIT_FORMAT(l, + [ + AC_LBL_CHECK_64BIT_FORMAT(ll, + [ + AC_LBL_CHECK_64BIT_FORMAT(L, + [ + AC_LBL_CHECK_64BIT_FORMAT(q, + [ + AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) + ]) + ]) + ]) + ]) +fi + +# +# Check for some headers introduced in later versions of libpcap +# and used by some printers. +# +# Those headers use the {u_}intN_t types, so we must do this after +# we check for what's needed to get them defined. +# +savedcppflags="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $V_INCLS" +AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"]) +AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"]) +AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"]) +CPPFLAGS="$savedcppflags" + +AC_PROG_RANLIB +AC_CHECK_TOOL([AR], [ar]) + +AC_LBL_DEVEL(V_CCOPT) + +AC_LBL_SOCKADDR_SA_LEN + +AC_LBL_UNALIGNED_ACCESS + +# Check for OpenSSL/libressl libcrypto +AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto) +# Specify location for both includes and libraries. +want_libcrypto=ifavailable +AC_ARG_WITH(crypto, + AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@, + [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]), +[ + if test $withval = no + then + # User doesn't want to link with libcrypto. + want_libcrypto=no + AC_MSG_RESULT(no) + elif test $withval = yes + then + # User wants to link with libcrypto but hasn't specified + # a directory. + want_libcrypto=yes + AC_MSG_RESULT(yes) + else + # User wants to link with libcrypto and has specified + # a directory, so use the provided value. + want_libcrypto=yes + libcrypto_root=$withval + AC_MSG_RESULT([yes, using the version installed in $withval]) + + # + # Put the subdirectories of the libcrypto root directory + # at the front of the header and library search path. + # + CFLAGS="-I$withval/include $CFLAGS" + LIBS="-L$withval/lib $LIBS" + fi +],[ + # + # Use libcrypto if it's present, otherwise don't; no directory + # was specified. + # + want_libcrypto=ifavailable + AC_MSG_RESULT([yes, if available]) +]) +if test "$want_libcrypto" != "no"; then + # + # Don't check for libcrypto unless we have its headers; + # Apple, bless their pointy little heads, apparently ship + # libcrypto as a library, but not the header files, in + # El Capitan, probably because they don't want you writing + # nasty portable code that could run on other UN*Xes, they + # want you writing code that uses their Shiny New Crypto + # Library and that only runs on OS X. + # + AC_CHECK_HEADER(openssl/crypto.h, + [ + AC_CHECK_LIB(crypto, DES_cbc_encrypt) + if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then + AC_CHECK_HEADERS(openssl/evp.h) + # + # OK, then: + # + # 1) do we have EVP_CIPHER_CTX_new? + # If so, we use it to allocate an + # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be + # opaque; otherwise, we allocate it ourselves. + # + # 2) do we have EVP_CipherInit_ex()? + # If so, we use it, because we need to be + # able to make two "initialize the cipher" + # calls, one with the cipher and key, and + # one with the IV, and, as of OpenSSL 1.1, + # You Can't Do That with EVP_CipherInit(), + # because a call to EVP_CipherInit() will + # unconditionally clear the context, and + # if you don't supply a cipher, it'll + # clear the cipher, rendering the context + # unusable and causing a crash. + # + AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_CipherInit_ex) + fi + ]) +fi + +# Check for libcap-ng +AC_MSG_CHECKING(whether to use libcap-ng) +# Specify location for both includes and libraries. +want_libcap_ng=ifavailable +AC_ARG_WITH(cap_ng, + AS_HELP_STRING([--with-cap-ng], + [use libcap-ng @<:@default=yes, if available@:>@]), +[ + if test $withval = no + then + want_libcap_ng=no + AC_MSG_RESULT(no) + elif test $withval = yes + then + want_libcap_ng=yes + AC_MSG_RESULT(yes) + fi +],[ + # + # Use libcap-ng if it's present, otherwise don't. + # + want_libcap_ng=ifavailable + AC_MSG_RESULT([yes, if available]) +]) +if test "$want_libcap_ng" != "no"; then + AC_CHECK_LIB(cap-ng, capng_change_id) + AC_CHECK_HEADERS(cap-ng.h) +fi + +dnl +dnl set additional include path if necessary +if test "$missing_includes" = "yes"; then + CPPFLAGS="$CPPFLAGS -I$srcdir/missing" + V_INCLS="$V_INCLS -I$srcdir/missing" +fi + +AC_SUBST(V_CCOPT) +AC_SUBST(V_DEFS) +AC_SUBST(V_GROUP) +AC_SUBST(V_INCLS) +AC_SUBST(V_PCAPDEP) +AC_SUBST(LOCALSRC) +AC_SUBST(MAN_FILE_FORMATS) +AC_SUBST(MAN_MISC_INFO) + +AC_PROG_INSTALL + +AC_CONFIG_HEADER(config.h) + +AC_OUTPUT_COMMANDS([if test -f .devel; then + echo timestamp > stamp-h + cat Makefile-devel-adds >> Makefile + make depend +fi]) +AC_OUTPUT(Makefile tcpdump.1) +exit 0 Index: vendor/tcpdump/dist/netdissect.h =================================================================== --- vendor/tcpdump/dist/netdissect.h (revision 353143) +++ vendor/tcpdump/dist/netdissect.h (revision 353144) @@ -1,657 +1,657 @@ /* * Copyright (c) 1988-1997 * The Regents of the University of California. All rights reserved. * * Copyright (c) 1998-2012 Michael Richardson * The TCPDUMP project * * 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 netdissect_h #define netdissect_h #ifdef HAVE_OS_PROTO_H #include "os-proto.h" #endif #include #ifndef HAVE___ATTRIBUTE__ #define __attribute__(x) #endif /* * Data types corresponding to multi-byte integral values within data * structures. These are defined as arrays of octets, so that they're * not aligned on their "natural" boundaries, and so that you *must* * use the EXTRACT_ macros to extract them (which you should be doing * *anyway*, so as not to assume a particular byte order or alignment * in your code). */ typedef unsigned char nd_uint16_t[2]; typedef unsigned char nd_uint24_t[3]; typedef unsigned char nd_uint32_t[4]; typedef unsigned char nd_uint40_t[5]; typedef unsigned char nd_uint48_t[6]; typedef unsigned char nd_uint56_t[7]; typedef unsigned char nd_uint64_t[8]; /* * Use this for IPv4 addresses. It's defined as an array of octets, so * that it's not aligned on its "natural" boundary, and it's defined as * a structure in the hopes that this makes it harder to naively use * EXTRACT_32BITS() to extract the value - in many cases you just want * to use UNALIGNED_MEMCPY() to copy its value, so that it remains in * network byte order. */ typedef struct { unsigned char bytes[4]; } nd_ipv4; /* * Data types corresponding to single-byte integral values, for * completeness. */ typedef unsigned char nd_uint8_t; typedef signed char nd_int8_t; /* snprintf et al */ #include #include #include "ip.h" /* struct ip for nextproto4_cksum() */ #include "ip6.h" /* struct ip6 for nextproto6_cksum() */ extern int32_t thiszone; /* seconds offset from gmt to local time */ /* invalid string to print '(invalid)' for malformed or corrupted packets */ extern const char istr[]; #if !defined(HAVE_SNPRINTF) int snprintf (char *str, size_t sz, FORMAT_STRING(const char *format), ...) PRINTFLIKE(3, 4); #endif /* !defined(HAVE_SNPRINTF) */ #if !defined(HAVE_VSNPRINTF) int vsnprintf (char *str, size_t sz, FORMAT_STRING(const char *format), va_list ap) PRINTFLIKE(3, 0); #endif /* !defined(HAVE_VSNPRINTF) */ #ifndef HAVE_STRLCAT extern size_t strlcat (char *, const char *, size_t); #endif #ifndef HAVE_STRLCPY extern size_t strlcpy (char *, const char *, size_t); #endif #ifndef HAVE_STRDUP extern char *strdup (const char *str); #endif #ifndef HAVE_STRSEP extern char *strsep(char **, const char *); #endif struct tok { u_int v; /* value */ const char *s; /* string */ }; extern const char *tok2strbuf(const struct tok *, const char *, u_int, char *buf, size_t bufsize); /* tok2str is deprecated */ extern const char *tok2str(const struct tok *, const char *, u_int); extern char *bittok2str(const struct tok *, const char *, u_int); extern char *bittok2str_nosep(const struct tok *, const char *, u_int); /* Initialize netdissect. */ extern int nd_init(char *, size_t); /* Clean up netdissect. */ extern void nd_cleanup(void); /* Do we have libsmi support? */ extern int nd_have_smi_support(void); /* Load an SMI module. */ extern int nd_load_smi_module(const char *, char *, size_t); /* Flag indicating whether an SMI module has been loaded. */ extern int nd_smi_module_loaded; /* Version number of the SMI library, or NULL if we don't have libsmi support. */ extern const char *nd_smi_version_string(void); typedef struct netdissect_options netdissect_options; #define IF_PRINTER_ARGS (netdissect_options *, const struct pcap_pkthdr *, const u_char *) typedef u_int (*if_printer) IF_PRINTER_ARGS; struct netdissect_options { int ndo_bflag; /* print 4 byte ASes in ASDOT notation */ int ndo_eflag; /* print ethernet header */ int ndo_fflag; /* don't translate "foreign" IP address */ int ndo_Kflag; /* don't check TCP checksums */ int ndo_nflag; /* leave addresses as numbers */ int ndo_Nflag; /* remove domains from printed host names */ int ndo_qflag; /* quick (shorter) output */ int ndo_Sflag; /* print raw TCP sequence numbers */ int ndo_tflag; /* print packet arrival time */ int ndo_uflag; /* Print undecoded NFS handles */ int ndo_vflag; /* verbosity level */ int ndo_xflag; /* print packet in hex */ int ndo_Xflag; /* print packet in hex/ascii */ int ndo_Aflag; /* print packet only in ascii observing TAB, * LF, CR and SPACE as graphical chars */ int ndo_Hflag; /* dissect 802.11s draft mesh standard */ int ndo_packet_number; /* print a packet number in the beginning of line */ int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */ int ndo_tstamp_precision; /* requested time stamp precision */ const char *program_name; /* Name of the program using the library */ char *ndo_espsecret; struct sa_list *ndo_sa_list_head; /* used by print-esp.c */ struct sa_list *ndo_sa_default; char *ndo_sigsecret; /* Signature verification secret key */ int ndo_packettype; /* as specified by -T */ int ndo_snaplen; /*global pointers to beginning and end of current packet (during printing) */ const u_char *ndo_packetp; const u_char *ndo_snapend; /* pointer to the if_printer function */ if_printer ndo_if_printer; /* pointer to void function to output stuff */ void (*ndo_default_print)(netdissect_options *, register const u_char *bp, register u_int length); /* pointer to function to do regular output */ int (*ndo_printf)(netdissect_options *, const char *fmt, ...) #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS __attribute__ ((format (printf, 2, 3))) #endif ; /* pointer to function to output errors */ void (*ndo_error)(netdissect_options *, const char *fmt, ...) #ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS __attribute__ ((noreturn)) #endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */ #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS __attribute__ ((format (printf, 2, 3))) #endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */ ; /* pointer to function to output warnings */ void (*ndo_warning)(netdissect_options *, const char *fmt, ...) #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS __attribute__ ((format (printf, 2, 3))) #endif ; }; #define PT_VAT 1 /* Visual Audio Tool */ #define PT_WB 2 /* distributed White Board */ #define PT_RPC 3 /* Remote Procedure Call */ #define PT_RTP 4 /* Real-Time Applications protocol */ #define PT_RTCP 5 /* Real-Time Applications control protocol */ #define PT_SNMP 6 /* Simple Network Management Protocol */ #define PT_CNFP 7 /* Cisco NetFlow protocol */ #define PT_TFTP 8 /* trivial file transfer protocol */ #define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */ #define PT_CARP 10 /* Common Address Redundancy Protocol */ #define PT_RADIUS 11 /* RADIUS authentication Protocol */ #define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */ #define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */ #define PT_PGM 14 /* [UDP-encapsulated] Pragmatic General Multicast */ #define PT_PGM_ZMTP1 15 /* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */ #define PT_LMP 16 /* Link Management Protocol */ #define PT_RESP 17 /* RESP */ #ifndef min #define min(a,b) ((a)>(b)?(b):(a)) #endif #ifndef max #define max(a,b) ((b)>(a)?(b):(a)) #endif /* For source or destination ports tests (UDP, TCP, ...) */ #define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p)) /* * Maximum snapshot length. This should be enough to capture the full * packet on most network interfaces. * * * Somewhat arbitrary, but chosen to be: * * 1) big enough for maximum-size Linux loopback packets (65549) * and some USB packets captured with USBPcap: * * http://desowin.org/usbpcap/ * * (> 131072, < 262144) * * and * * 2) small enough not to cause attempts to allocate huge amounts of * memory; some applications might use the snapshot length in a * savefile header to control the size of the buffer they allocate, * so a size of, say, 2^31-1 might not work well. * * XXX - does it need to be bigger still? */ #define MAXIMUM_SNAPLEN 262144 /* * The default snapshot length is the maximum. */ #define DEFAULT_SNAPLEN MAXIMUM_SNAPLEN #define ESRC(ep) ((ep)->ether_shost) #define EDST(ep) ((ep)->ether_dhost) #ifndef NTOHL #define NTOHL(x) (x) = ntohl(x) #define NTOHS(x) (x) = ntohs(x) #define HTONL(x) (x) = htonl(x) #define HTONS(x) (x) = htons(x) #endif /* * True if "l" bytes of "var" were captured. * * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows. * * The check is for <= rather than < because "l" might be 0. * * We cast the pointers to uintptr_t to make sure that the compiler * doesn't optimize away any of these tests (which it is allowed to * do, as adding an integer to, or subtracting an integer from, a * pointer assumes that the pointer is a pointer to an element of an * array and that the result of the addition or subtraction yields a * pointer to another member of the array, so that, for example, if * you subtract a positive integer from a pointer, the result is * guaranteed to be less than the original pointer value). See * * http://www.kb.cert.org/vuls/id/162289 */ /* * Test in two parts to avoid these warnings: * comparison of unsigned expression >= 0 is always true [-Wtype-limits], * comparison is always true due to limited range of data type [-Wtype-limits]. */ #define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0)) #define ND_TTEST2(var, l) \ (IS_NOT_NEGATIVE(l) && \ ((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \ (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l))) /* True if "var" was captured */ #define ND_TTEST(var) ND_TTEST2(var, sizeof(var)) /* Bail if "l" bytes of "var" were not captured */ #define ND_TCHECK2(var, l) if (!ND_TTEST2(var, l)) goto trunc /* Bail if "var" was not captured */ #define ND_TCHECK(var) ND_TCHECK2(var, sizeof(var)) #define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF #define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length) extern void ts_print(netdissect_options *, const struct timeval *); extern void signed_relts_print(netdissect_options *, int32_t); extern void unsigned_relts_print(netdissect_options *, uint32_t); extern void fn_print_char(netdissect_options *, u_char); extern int fn_print(netdissect_options *, const u_char *, const u_char *); extern u_int fn_printztn(netdissect_options *ndo, const u_char *, u_int, const u_char *); extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *); extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *); /* * Flags for txtproto_print(). */ #define RESP_CODE_SECOND_TOKEN 0x00000001 /* response code is second token in response line */ extern void txtproto_print(netdissect_options *, const u_char *, u_int, const char *, const char **, u_int); /* * Locale-independent macros for testing character properties and * stripping the 8th bit from characters. Assumed to be handed * a value between 0 and 255, i.e. don't hand them a char, as * those might be in the range -128 to 127. */ #define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */ #define ND_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E) #define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E) #define ND_TOASCII(c) ((c) & 0x7F) extern void safeputchar(netdissect_options *, const u_char); extern void safeputs(netdissect_options *, const u_char *, const u_int); #ifdef LBL_ALIGN /* * The processor doesn't natively handle unaligned loads, * and the compiler might "helpfully" optimize memcpy() * and memcmp(), when handed pointers that would normally * be properly aligned, into sequences that assume proper * alignment. * * Do copies and compares of possibly-unaligned data by * calling routines that wrap memcpy() and memcmp(), to * prevent that optimization. */ extern void unaligned_memcpy(void *, const void *, size_t); extern int unaligned_memcmp(const void *, const void *, size_t); #define UNALIGNED_MEMCPY(p, q, l) unaligned_memcpy((p), (q), (l)) #define UNALIGNED_MEMCMP(p, q, l) unaligned_memcmp((p), (q), (l)) #else /* * The procesor natively handles unaligned loads, so just use memcpy() * and memcmp(), to enable those optimizations. */ #define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l)) #define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l)) #endif #define PLURAL_SUFFIX(n) \ (((n) != 1) ? "s" : "") extern const char *tok2strary_internal(const char **, int, const char *, int); #define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i) extern if_printer lookup_printer(int); /* The DLT printer routines */ extern u_int ap1394_if_print IF_PRINTER_ARGS; extern u_int arcnet_if_print IF_PRINTER_ARGS; extern u_int arcnet_linux_if_print IF_PRINTER_ARGS; extern u_int atm_if_print IF_PRINTER_ARGS; extern u_int bt_if_print IF_PRINTER_ARGS; extern u_int chdlc_if_print IF_PRINTER_ARGS; extern u_int cip_if_print IF_PRINTER_ARGS; extern u_int enc_if_print IF_PRINTER_ARGS; extern u_int ether_if_print IF_PRINTER_ARGS; extern u_int fddi_if_print IF_PRINTER_ARGS; extern u_int fr_if_print IF_PRINTER_ARGS; extern u_int ieee802_11_if_print IF_PRINTER_ARGS; extern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS; extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS; extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS; extern u_int ipfc_if_print IF_PRINTER_ARGS; extern u_int ipnet_if_print IF_PRINTER_ARGS; extern u_int juniper_atm1_print IF_PRINTER_ARGS; extern u_int juniper_atm2_print IF_PRINTER_ARGS; extern u_int juniper_chdlc_print IF_PRINTER_ARGS; extern u_int juniper_es_print IF_PRINTER_ARGS; extern u_int juniper_ether_print IF_PRINTER_ARGS; extern u_int juniper_frelay_print IF_PRINTER_ARGS; extern u_int juniper_ggsn_print IF_PRINTER_ARGS; extern u_int juniper_mfr_print IF_PRINTER_ARGS; extern u_int juniper_mlfr_print IF_PRINTER_ARGS; extern u_int juniper_mlppp_print IF_PRINTER_ARGS; extern u_int juniper_monitor_print IF_PRINTER_ARGS; extern u_int juniper_ppp_print IF_PRINTER_ARGS; extern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS; extern u_int juniper_pppoe_print IF_PRINTER_ARGS; extern u_int juniper_services_print IF_PRINTER_ARGS; extern u_int lane_if_print IF_PRINTER_ARGS; extern u_int ltalk_if_print IF_PRINTER_ARGS; extern u_int mfr_if_print IF_PRINTER_ARGS; extern u_int netanalyzer_if_print IF_PRINTER_ARGS; extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS; extern u_int nflog_if_print IF_PRINTER_ARGS; extern u_int null_if_print IF_PRINTER_ARGS; extern u_int pflog_if_print IF_PRINTER_ARGS; extern u_int pktap_if_print IF_PRINTER_ARGS; extern u_int ppi_if_print IF_PRINTER_ARGS; extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS; extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS; extern u_int ppp_if_print IF_PRINTER_ARGS; extern u_int pppoe_if_print IF_PRINTER_ARGS; extern u_int prism_if_print IF_PRINTER_ARGS; extern u_int raw_if_print IF_PRINTER_ARGS; extern u_int sl_bsdos_if_print IF_PRINTER_ARGS; extern u_int sl_if_print IF_PRINTER_ARGS; extern u_int sll_if_print IF_PRINTER_ARGS; extern u_int sunatm_if_print IF_PRINTER_ARGS; extern u_int symantec_if_print IF_PRINTER_ARGS; extern u_int token_if_print IF_PRINTER_ARGS; extern u_int usb_linux_48_byte_print IF_PRINTER_ARGS; extern u_int usb_linux_64_byte_print IF_PRINTER_ARGS; /* * Structure passed to some printers to allow them to print * link-layer address information if ndo_eflag isn't set * (because they are for protocols that don't have their * own addresses, so that we'd want to report link-layer * address information). * * This contains a pointer to an address and a pointer to a routine * to which we pass that pointer in order to get a string. */ struct lladdr_info { const char *(*addr_string)(netdissect_options *, const u_char *); const u_char *addr; }; /* The printer routines. */ extern void aarp_print(netdissect_options *, const u_char *, u_int); extern int ah_print(netdissect_options *, register const u_char *); extern void ahcp_print(netdissect_options *, const u_char *, const u_int); extern void aodv_print(netdissect_options *, const u_char *, u_int, int); extern void aoe_print(netdissect_options *, const u_char *, const u_int); extern void arp_print(netdissect_options *, const u_char *, u_int, u_int); extern void ascii_print(netdissect_options *, const u_char *, u_int); extern void atalk_print(netdissect_options *, const u_char *, u_int); extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int); extern void babel_print(netdissect_options *, const u_char *, u_int); extern void beep_print(netdissect_options *, const u_char *, u_int); extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int); extern void bgp_print(netdissect_options *, const u_char *, int); extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *); extern void bootp_print(netdissect_options *, const u_char *, u_int); extern void calm_fast_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *); extern void carp_print(netdissect_options *, const u_char *, u_int, int); extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int); extern void cfm_print(netdissect_options *, const u_char *, u_int); extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int); extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int); extern void cnfp_print(netdissect_options *, const u_char *); extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int); extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int); extern void dhcp6_print(netdissect_options *, const u_char *, u_int); extern int dstopt_print(netdissect_options *, const u_char *); extern void dtp_print(netdissect_options *, const u_char *, u_int); extern void dvmrp_print(netdissect_options *, const u_char *, u_int); extern void eap_print(netdissect_options *, const u_char *, u_int); extern void egp_print(netdissect_options *, const u_char *, u_int); extern void eigrp_print(netdissect_options *, const u_char *, u_int); extern int esp_print(netdissect_options *, const u_char *, const int, const u_char *, int *, int *); extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *); extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *); extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int); extern void forces_print(netdissect_options *, const u_char *, u_int); extern u_int fr_print(netdissect_options *, register const u_char *, u_int); extern int frag6_print(netdissect_options *, const u_char *, const u_char *); extern void ftp_print(netdissect_options *, const u_char *, u_int); extern void geneve_print(netdissect_options *, const u_char *, u_int); extern void geonet_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *); extern void gre_print(netdissect_options *, const u_char *, u_int); extern int hbhopt_print(netdissect_options *, const u_char *); extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int); extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int); extern void hex_print(netdissect_options *, const char *ident, const u_char *cp, u_int); extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp, u_int, u_int); extern void hncp_print(netdissect_options *, const u_char *, u_int); extern void hsrp_print(netdissect_options *, const u_char *, u_int); extern void http_print(netdissect_options *, const u_char *, u_int); extern void icmp6_print(netdissect_options *, const u_char *, u_int, const u_char *, int); extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); +extern u_int ieee802_11_radio_print(netdissect_options *, const u_char *, u_int, u_int); extern void igmp_print(netdissect_options *, const u_char *, u_int); extern void igrp_print(netdissect_options *, const u_char *, u_int); extern void ip6_print(netdissect_options *, const u_char *, u_int); extern void ipN_print(netdissect_options *, const u_char *, u_int); extern void ip_print(netdissect_options *, const u_char *, u_int); extern void ip_print_inner(netdissect_options *, const u_char *, u_int, u_int nh, const u_char *); extern void ipcomp_print(netdissect_options *, register const u_char *); extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int); extern void ipx_print(netdissect_options *, const u_char *, u_int); extern void isakmp_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void isoclns_print(netdissect_options *, const u_char *, u_int); extern void krb_print(netdissect_options *, const u_char *); extern void l2tp_print(netdissect_options *, const u_char *, u_int); extern void lane_print(netdissect_options *, const u_char *, u_int, u_int); extern void ldp_print(netdissect_options *, const u_char *, u_int); extern void lisp_print(netdissect_options *, const u_char *, u_int); extern u_int llap_print(netdissect_options *, const u_char *, u_int); extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *); extern void lldp_print(netdissect_options *, const u_char *, u_int); extern void lmp_print(netdissect_options *, const u_char *, u_int); extern void loopback_print(netdissect_options *, const u_char *, const u_int); extern void lspping_print(netdissect_options *, const u_char *, u_int); extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int); extern void lwapp_data_print(netdissect_options *, const u_char *, u_int); extern void lwres_print(netdissect_options *, const u_char *, u_int); extern void m3ua_print(netdissect_options *, const u_char *, const u_int); extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *); extern u_int mfr_print(netdissect_options *, register const u_char *, u_int); extern void mobile_print(netdissect_options *, const u_char *, u_int); extern int mobility_print(netdissect_options *, const u_char *, const u_char *); extern void mpcp_print(netdissect_options *, const u_char *, u_int); extern void mpls_print(netdissect_options *, const u_char *, u_int); extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char); extern void msdp_print(netdissect_options *, const u_char *, u_int); extern void msnlb_print(netdissect_options *, const u_char *); extern void nbt_tcp_print(netdissect_options *, const u_char *, int); extern void nbt_udp137_print(netdissect_options *, const u_char *, int); extern void nbt_udp138_print(netdissect_options *, const u_char *, int); extern void netbeui_print(netdissect_options *, u_short, const u_char *, int); extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *); extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *); extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *); extern void ns_print(netdissect_options *, const u_char *, u_int, int); extern void nsh_print(netdissect_options *ndo, const u_char *bp, u_int len); extern void ntp_print(netdissect_options *, const u_char *, u_int); extern void oam_print(netdissect_options *, const u_char *, u_int, u_int); extern void olsr_print(netdissect_options *, const u_char *, u_int, int); extern void openflow_print(netdissect_options *, const u_char *, const u_int); extern void ospf6_print(netdissect_options *, const u_char *, u_int); extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *); extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int); extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int); extern void otv_print(netdissect_options *, const u_char *, u_int); extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void pimv1_print(netdissect_options *, const u_char *, u_int); extern u_int ppp_print(netdissect_options *, register const u_char *, u_int); extern u_int pppoe_print(netdissect_options *, const u_char *, u_int); extern void pptp_print(netdissect_options *, const u_char *); extern int print_unknown_data(netdissect_options *, const u_char *, const char *, int); extern char *q922_string(netdissect_options *, const u_char *, u_int); extern void q933_print(netdissect_options *, const u_char *, u_int); extern void radius_print(netdissect_options *, const u_char *, u_int); extern void resp_print(netdissect_options *, const u_char *, u_int); extern void rip_print(netdissect_options *, const u_char *, u_int); extern void ripng_print(netdissect_options *, const u_char *, unsigned int); extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int); extern void rrcp_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *, const struct lladdr_info *); extern void rsvp_print(netdissect_options *, const u_char *, u_int); extern int rt6_print(netdissect_options *, const u_char *, const u_char *); extern void rtsp_print(netdissect_options *, const u_char *, u_int); extern void rx_print(netdissect_options *, register const u_char *, int, int, int, const u_char *); extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int); extern void sflow_print(netdissect_options *, const u_char *, u_int); extern void sip_print(netdissect_options *, const u_char *, u_int); extern void slow_print(netdissect_options *, const u_char *, u_int); extern void smb_print_data(netdissect_options *, const unsigned char *, int); extern void smb_tcp_print(netdissect_options *, const u_char *, int); extern void smtp_print(netdissect_options *, const u_char *, u_int); extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *, u_int); extern void snmp_print(netdissect_options *, const u_char *, u_int); extern void stp_print(netdissect_options *, const u_char *, u_int); extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *); extern void syslog_print(netdissect_options *, const u_char *, u_int); extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); extern void telnet_print(netdissect_options *, const u_char *, u_int); extern void tftp_print(netdissect_options *, const u_char *, u_int); extern void timed_print(netdissect_options *, const u_char *); extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int); extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int); extern void udld_print(netdissect_options *, const u_char *, u_int); extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); extern int vjc_print(netdissect_options *, register const char *, u_short); extern void vqp_print(netdissect_options *, register const u_char *, register u_int); extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int); extern void vtp_print(netdissect_options *, const u_char *, u_int); extern void vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len); extern void vxlan_print(netdissect_options *, const u_char *, u_int); extern void wb_print(netdissect_options *, const void *, u_int); extern void zephyr_print(netdissect_options *, const u_char *, int); extern void zmtp1_print(netdissect_options *, const u_char *, u_int); extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int); /* checksum routines */ extern void init_checksum(void); extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int); extern uint16_t create_osi_cksum(const uint8_t *, int, int); struct cksum_vec { const uint8_t *ptr; int len; }; extern uint16_t in_cksum(const struct cksum_vec *, int); extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t); extern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int); /* in print-ip6.c */ extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int); /* Utilities */ extern int mask2plen(uint32_t); extern int mask62plen(const u_char *); -extern const char *dnname_string(netdissect_options *, u_short); extern const char *dnnum_string(netdissect_options *, u_short); extern char *smb_errstr(int, int); extern const char *nt_errstr(uint32_t); extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, u_int); extern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, u_int); extern void esp_print_decodesecret(netdissect_options *); extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *, int, u_char spii[8], u_char spir[8], const u_char *, const u_char *); #endif /* netdissect_h */ Index: vendor/tcpdump/dist/print-802_11.c =================================================================== --- vendor/tcpdump/dist/print-802_11.c (revision 353143) +++ vendor/tcpdump/dist/print-802_11.c (revision 353144) @@ -1,3365 +1,3378 @@ /* * Copyright (c) 2001 * Fortress Technologies, Inc. All rights reserved. * Charlie Lenahan (clenahan@fortresstech.com) * * 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. */ /* \summary: IEEE 802.11 printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "cpack.h" /* Lengths of 802.11 header components. */ #define IEEE802_11_FC_LEN 2 #define IEEE802_11_DUR_LEN 2 #define IEEE802_11_DA_LEN 6 #define IEEE802_11_SA_LEN 6 #define IEEE802_11_BSSID_LEN 6 #define IEEE802_11_RA_LEN 6 #define IEEE802_11_TA_LEN 6 #define IEEE802_11_ADDR1_LEN 6 #define IEEE802_11_SEQ_LEN 2 #define IEEE802_11_CTL_LEN 2 #define IEEE802_11_CARRIED_FC_LEN 2 #define IEEE802_11_HT_CONTROL_LEN 4 #define IEEE802_11_IV_LEN 3 #define IEEE802_11_KID_LEN 1 /* Frame check sequence length. */ #define IEEE802_11_FCS_LEN 4 /* Lengths of beacon components. */ #define IEEE802_11_TSTAMP_LEN 8 #define IEEE802_11_BCNINT_LEN 2 #define IEEE802_11_CAPINFO_LEN 2 #define IEEE802_11_LISTENINT_LEN 2 #define IEEE802_11_AID_LEN 2 #define IEEE802_11_STATUS_LEN 2 #define IEEE802_11_REASON_LEN 2 /* Length of previous AP in reassocation frame */ #define IEEE802_11_AP_LEN 6 #define T_MGMT 0x0 /* management */ #define T_CTRL 0x1 /* control */ #define T_DATA 0x2 /* data */ #define T_RESV 0x3 /* reserved */ #define ST_ASSOC_REQUEST 0x0 #define ST_ASSOC_RESPONSE 0x1 #define ST_REASSOC_REQUEST 0x2 #define ST_REASSOC_RESPONSE 0x3 #define ST_PROBE_REQUEST 0x4 #define ST_PROBE_RESPONSE 0x5 /* RESERVED 0x6 */ /* RESERVED 0x7 */ #define ST_BEACON 0x8 #define ST_ATIM 0x9 #define ST_DISASSOC 0xA #define ST_AUTH 0xB #define ST_DEAUTH 0xC #define ST_ACTION 0xD /* RESERVED 0xE */ /* RESERVED 0xF */ static const struct tok st_str[] = { { ST_ASSOC_REQUEST, "Assoc Request" }, { ST_ASSOC_RESPONSE, "Assoc Response" }, { ST_REASSOC_REQUEST, "ReAssoc Request" }, { ST_REASSOC_RESPONSE, "ReAssoc Response" }, { ST_PROBE_REQUEST, "Probe Request" }, { ST_PROBE_RESPONSE, "Probe Response" }, { ST_BEACON, "Beacon" }, { ST_ATIM, "ATIM" }, { ST_DISASSOC, "Disassociation" }, { ST_AUTH, "Authentication" }, { ST_DEAUTH, "DeAuthentication" }, { ST_ACTION, "Action" }, { 0, NULL } }; #define CTRL_CONTROL_WRAPPER 0x7 #define CTRL_BAR 0x8 #define CTRL_BA 0x9 #define CTRL_PS_POLL 0xA #define CTRL_RTS 0xB #define CTRL_CTS 0xC #define CTRL_ACK 0xD #define CTRL_CF_END 0xE #define CTRL_END_ACK 0xF static const struct tok ctrl_str[] = { { CTRL_CONTROL_WRAPPER, "Control Wrapper" }, { CTRL_BAR, "BAR" }, { CTRL_BA, "BA" }, { CTRL_PS_POLL, "Power Save-Poll" }, { CTRL_RTS, "Request-To-Send" }, { CTRL_CTS, "Clear-To-Send" }, { CTRL_ACK, "Acknowledgment" }, { CTRL_CF_END, "CF-End" }, { CTRL_END_ACK, "CF-End+CF-Ack" }, { 0, NULL } }; #define DATA_DATA 0x0 #define DATA_DATA_CF_ACK 0x1 #define DATA_DATA_CF_POLL 0x2 #define DATA_DATA_CF_ACK_POLL 0x3 #define DATA_NODATA 0x4 #define DATA_NODATA_CF_ACK 0x5 #define DATA_NODATA_CF_POLL 0x6 #define DATA_NODATA_CF_ACK_POLL 0x7 #define DATA_QOS_DATA 0x8 #define DATA_QOS_DATA_CF_ACK 0x9 #define DATA_QOS_DATA_CF_POLL 0xA #define DATA_QOS_DATA_CF_ACK_POLL 0xB #define DATA_QOS_NODATA 0xC #define DATA_QOS_CF_POLL_NODATA 0xE #define DATA_QOS_CF_ACK_POLL_NODATA 0xF /* * The subtype field of a data frame is, in effect, composed of 4 flag * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have * any data), and QoS. */ #define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01) #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02) #define DATA_FRAME_IS_NULL(x) ((x) & 0x04) #define DATA_FRAME_IS_QOS(x) ((x) & 0x08) /* * Bits in the frame control field. */ #define FC_VERSION(fc) ((fc) & 0x3) #define FC_TYPE(fc) (((fc) >> 2) & 0x3) #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) #define FC_TO_DS(fc) ((fc) & 0x0100) #define FC_FROM_DS(fc) ((fc) & 0x0200) #define FC_MORE_FLAG(fc) ((fc) & 0x0400) #define FC_RETRY(fc) ((fc) & 0x0800) #define FC_POWER_MGMT(fc) ((fc) & 0x1000) #define FC_MORE_DATA(fc) ((fc) & 0x2000) #define FC_PROTECTED(fc) ((fc) & 0x4000) #define FC_ORDER(fc) ((fc) & 0x8000) struct mgmt_header_t { uint16_t fc; uint16_t duration; uint8_t da[IEEE802_11_DA_LEN]; uint8_t sa[IEEE802_11_SA_LEN]; uint8_t bssid[IEEE802_11_BSSID_LEN]; uint16_t seq_ctrl; }; #define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\ IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN) #define CAPABILITY_ESS(cap) ((cap) & 0x0001) #define CAPABILITY_IBSS(cap) ((cap) & 0x0002) #define CAPABILITY_CFP(cap) ((cap) & 0x0004) #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) struct ssid_t { uint8_t element_id; uint8_t length; u_char ssid[33]; /* 32 + 1 for null */ }; struct rates_t { uint8_t element_id; uint8_t length; uint8_t rate[16]; }; struct challenge_t { uint8_t element_id; uint8_t length; uint8_t text[254]; /* 1-253 + 1 for null */ }; struct fh_t { uint8_t element_id; uint8_t length; uint16_t dwell_time; uint8_t hop_set; uint8_t hop_pattern; uint8_t hop_index; }; struct ds_t { uint8_t element_id; uint8_t length; uint8_t channel; }; struct cf_t { uint8_t element_id; uint8_t length; uint8_t count; uint8_t period; uint16_t max_duration; uint16_t dur_remaing; }; struct tim_t { uint8_t element_id; uint8_t length; uint8_t count; uint8_t period; uint8_t bitmap_control; uint8_t bitmap[251]; }; #define E_SSID 0 #define E_RATES 1 #define E_FH 2 #define E_DS 3 #define E_CF 4 #define E_TIM 5 #define E_IBSS 6 /* reserved 7 */ /* reserved 8 */ /* reserved 9 */ /* reserved 10 */ /* reserved 11 */ /* reserved 12 */ /* reserved 13 */ /* reserved 14 */ /* reserved 15 */ /* reserved 16 */ #define E_CHALLENGE 16 /* reserved 17 */ /* reserved 18 */ /* reserved 19 */ /* reserved 16 */ /* reserved 16 */ struct mgmt_body_t { uint8_t timestamp[IEEE802_11_TSTAMP_LEN]; uint16_t beacon_interval; uint16_t listen_interval; uint16_t status_code; uint16_t aid; u_char ap[IEEE802_11_AP_LEN]; uint16_t reason_code; uint16_t auth_alg; uint16_t auth_trans_seq_num; int challenge_present; struct challenge_t challenge; uint16_t capability_info; int ssid_present; struct ssid_t ssid; int rates_present; struct rates_t rates; int ds_present; struct ds_t ds; int cf_present; struct cf_t cf; int fh_present; struct fh_t fh; int tim_present; struct tim_t tim; }; struct ctrl_control_wrapper_hdr_t { uint16_t fc; uint16_t duration; uint8_t addr1[IEEE802_11_ADDR1_LEN]; uint16_t carried_fc[IEEE802_11_CARRIED_FC_LEN]; uint16_t ht_control[IEEE802_11_HT_CONTROL_LEN]; }; #define CTRL_CONTROL_WRAPPER_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_ADDR1_LEN+\ IEEE802_11_CARRIED_FC_LEN+\ IEEE802_11_HT_CONTROL_LEN) struct ctrl_rts_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; uint8_t ta[IEEE802_11_TA_LEN]; }; #define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN) struct ctrl_cts_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; }; #define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) struct ctrl_ack_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; }; #define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) struct ctrl_ps_poll_hdr_t { uint16_t fc; uint16_t aid; uint8_t bssid[IEEE802_11_BSSID_LEN]; uint8_t ta[IEEE802_11_TA_LEN]; }; #define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\ IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN) struct ctrl_end_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; uint8_t bssid[IEEE802_11_BSSID_LEN]; }; #define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) struct ctrl_end_ack_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; uint8_t bssid[IEEE802_11_BSSID_LEN]; }; #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) struct ctrl_ba_hdr_t { uint16_t fc; uint16_t duration; uint8_t ra[IEEE802_11_RA_LEN]; }; #define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN) struct ctrl_bar_hdr_t { uint16_t fc; uint16_t dur; uint8_t ra[IEEE802_11_RA_LEN]; uint8_t ta[IEEE802_11_TA_LEN]; uint16_t ctl; uint16_t seq; }; #define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\ IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN) struct meshcntl_t { uint8_t flags; uint8_t ttl; uint8_t seq[4]; uint8_t addr4[6]; uint8_t addr5[6]; uint8_t addr6[6]; }; #define IV_IV(iv) ((iv) & 0xFFFFFF) #define IV_PAD(iv) (((iv) >> 24) & 0x3F) #define IV_KEYID(iv) (((iv) >> 30) & 0x03) #define PRINT_SSID(p) \ if (p.ssid_present) { \ ND_PRINT((ndo, " (")); \ fn_print(ndo, p.ssid.ssid, NULL); \ ND_PRINT((ndo, ")")); \ } #define PRINT_RATE(_sep, _r, _suf) \ ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)) #define PRINT_RATES(p) \ if (p.rates_present) { \ int z; \ const char *sep = " ["; \ for (z = 0; z < p.rates.length ; z++) { \ PRINT_RATE(sep, p.rates.rate[z], \ (p.rates.rate[z] & 0x80 ? "*" : "")); \ sep = " "; \ } \ if (p.rates.length != 0) \ ND_PRINT((ndo, " Mbit]")); \ } #define PRINT_DS_CHANNEL(p) \ if (p.ds_present) \ ND_PRINT((ndo, " CH: %u", p.ds.channel)); \ ND_PRINT((ndo, "%s", \ CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "")); #define MAX_MCS_INDEX 76 /* * Indices are: * * the MCS index (0-76); * * 0 for 20 MHz, 1 for 40 MHz; * * 0 for a long guard interval, 1 for a short guard interval. */ static const float ieee80211_float_htrates[MAX_MCS_INDEX+1][2][2] = { /* MCS 0 */ { /* 20 Mhz */ { 6.5, /* SGI */ 7.2, }, /* 40 Mhz */ { 13.5, /* SGI */ 15.0, }, }, /* MCS 1 */ { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, }, /* 40 Mhz */ { 27.0, /* SGI */ 30.0, }, }, /* MCS 2 */ { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, }, /* 40 Mhz */ { 40.5, /* SGI */ 45.0, }, }, /* MCS 3 */ { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, }, /* MCS 4 */ { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, }, /* MCS 5 */ { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, }, /* MCS 6 */ { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, }, /* MCS 7 */ { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, }, /* MCS 8 */ { /* 20 Mhz */ { 13.0, /* SGI */ 14.4, }, /* 40 Mhz */ { 27.0, /* SGI */ 30.0, }, }, /* MCS 9 */ { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, }, /* MCS 10 */ { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, }, /* MCS 11 */ { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, }, /* MCS 12 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 13 */ { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, }, /* MCS 14 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 15 */ { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, }, /* MCS 16 */ { /* 20 Mhz */ { 19.5, /* SGI */ 21.7, }, /* 40 Mhz */ { 40.5, /* SGI */ 45.0, }, }, /* MCS 17 */ { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, }, /* MCS 18 */ { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, }, /* MCS 19 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 20 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 21 */ { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, }, /* MCS 22 */ { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, }, /* MCS 23 */ { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, }, /* MCS 24 */ { /* 20 Mhz */ { 26.0, /* SGI */ 28.9, }, /* 40 Mhz */ { 54.0, /* SGI */ 60.0, }, }, /* MCS 25 */ { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, }, /* MCS 26 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 27 */ { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, }, /* MCS 28 */ { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, }, /* MCS 29 */ { /* 20 Mhz */ { 208.0, /* SGI */ 231.1, }, /* 40 Mhz */ { 432.0, /* SGI */ 480.0, }, }, /* MCS 30 */ { /* 20 Mhz */ { 234.0, /* SGI */ 260.0, }, /* 40 Mhz */ { 486.0, /* SGI */ 540.0, }, }, /* MCS 31 */ { /* 20 Mhz */ { 260.0, /* SGI */ 288.9, }, /* 40 Mhz */ { 540.0, /* SGI */ 600.0, }, }, /* MCS 32 */ { /* 20 Mhz */ { 0.0, /* SGI */ 0.0, }, /* not valid */ /* 40 Mhz */ { 6.0, /* SGI */ 6.7, }, }, /* MCS 33 */ { /* 20 Mhz */ { 39.0, /* SGI */ 43.3, }, /* 40 Mhz */ { 81.0, /* SGI */ 90.0, }, }, /* MCS 34 */ { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, }, /* MCS 35 */ { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, }, /* MCS 36 */ { /* 20 Mhz */ { 58.5, /* SGI */ 65.0, }, /* 40 Mhz */ { 121.5, /* SGI */ 135.0, }, }, /* MCS 37 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 38 */ { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, }, /* MCS 39 */ { /* 20 Mhz */ { 52.0, /* SGI */ 57.8, }, /* 40 Mhz */ { 108.0, /* SGI */ 120.0, }, }, /* MCS 40 */ { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, }, /* MCS 41 */ { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, }, /* MCS 42 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 43 */ { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, }, /* MCS 44 */ { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, }, /* MCS 45 */ { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, }, /* MCS 46 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 47 */ { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, }, /* MCS 48 */ { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, }, /* MCS 49 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 50 */ { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, }, /* MCS 51 */ { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, }, /* MCS 52 */ { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, }, /* MCS 53 */ { /* 20 Mhz */ { 65.0, /* SGI */ 72.2, }, /* 40 Mhz */ { 135.0, /* SGI */ 150.0, }, }, /* MCS 54 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 55 */ { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, }, /* MCS 56 */ { /* 20 Mhz */ { 78.0, /* SGI */ 86.7, }, /* 40 Mhz */ { 162.0, /* SGI */ 180.0, }, }, /* MCS 57 */ { /* 20 Mhz */ { 91.0, /* SGI */ 101.1, }, /* 40 Mhz */ { 189.0, /* SGI */ 210.0, }, }, /* MCS 58 */ { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, }, /* MCS 59 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 60 */ { /* 20 Mhz */ { 104.0, /* SGI */ 115.6, }, /* 40 Mhz */ { 216.0, /* SGI */ 240.0, }, }, /* MCS 61 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 62 */ { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, }, /* MCS 63 */ { /* 20 Mhz */ { 130.0, /* SGI */ 144.4, }, /* 40 Mhz */ { 270.0, /* SGI */ 300.0, }, }, /* MCS 64 */ { /* 20 Mhz */ { 143.0, /* SGI */ 158.9, }, /* 40 Mhz */ { 297.0, /* SGI */ 330.0, }, }, /* MCS 65 */ { /* 20 Mhz */ { 97.5, /* SGI */ 108.3, }, /* 40 Mhz */ { 202.5, /* SGI */ 225.0, }, }, /* MCS 66 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 67 */ { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, }, /* MCS 68 */ { /* 20 Mhz */ { 117.0, /* SGI */ 130.0, }, /* 40 Mhz */ { 243.0, /* SGI */ 270.0, }, }, /* MCS 69 */ { /* 20 Mhz */ { 136.5, /* SGI */ 151.7, }, /* 40 Mhz */ { 283.5, /* SGI */ 315.0, }, }, /* MCS 70 */ { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, }, /* MCS 71 */ { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, }, /* MCS 72 */ { /* 20 Mhz */ { 156.0, /* SGI */ 173.3, }, /* 40 Mhz */ { 324.0, /* SGI */ 360.0, }, }, /* MCS 73 */ { /* 20 Mhz */ { 175.5, /* SGI */ 195.0, }, /* 40 Mhz */ { 364.5, /* SGI */ 405.0, }, }, /* MCS 74 */ { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, }, /* MCS 75 */ { /* 20 Mhz */ { 195.0, /* SGI */ 216.7, }, /* 40 Mhz */ { 405.0, /* SGI */ 450.0, }, }, /* MCS 76 */ { /* 20 Mhz */ { 214.5, /* SGI */ 238.3, }, /* 40 Mhz */ { 445.5, /* SGI */ 495.0, }, }, }; static const char *auth_alg_text[]={"Open System","Shared Key","EAP"}; #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0]) static const char *status_text[] = { "Successful", /* 0 */ "Unspecified failure", /* 1 */ "Reserved", /* 2 */ "Reserved", /* 3 */ "Reserved", /* 4 */ "Reserved", /* 5 */ "Reserved", /* 6 */ "Reserved", /* 7 */ "Reserved", /* 8 */ "Reserved", /* 9 */ "Cannot Support all requested capabilities in the Capability " "Information field", /* 10 */ "Reassociation denied due to inability to confirm that association " "exists", /* 11 */ "Association denied due to reason outside the scope of the " "standard", /* 12 */ "Responding station does not support the specified authentication " "algorithm ", /* 13 */ "Received an Authentication frame with authentication transaction " "sequence number out of expected sequence", /* 14 */ "Authentication rejected because of challenge failure", /* 15 */ "Authentication rejected due to timeout waiting for next frame in " "sequence", /* 16 */ "Association denied because AP is unable to handle additional" "associated stations", /* 17 */ "Association denied due to requesting station not supporting all of " "the data rates in BSSBasicRateSet parameter", /* 18 */ "Association denied due to requesting station not supporting " "short preamble operation", /* 19 */ "Association denied due to requesting station not supporting " "PBCC encoding", /* 20 */ "Association denied due to requesting station not supporting " "channel agility", /* 21 */ "Association request rejected because Spectrum Management " "capability is required", /* 22 */ "Association request rejected because the information in the " "Power Capability element is unacceptable", /* 23 */ "Association request rejected because the information in the " "Supported Channels element is unacceptable", /* 24 */ "Association denied due to requesting station not supporting " "short slot operation", /* 25 */ "Association denied due to requesting station not supporting " "DSSS-OFDM operation", /* 26 */ "Association denied because the requested STA does not support HT " "features", /* 27 */ "Reserved", /* 28 */ "Association denied because the requested STA does not support " "the PCO transition time required by the AP", /* 29 */ "Reserved", /* 30 */ "Reserved", /* 31 */ "Unspecified, QoS-related failure", /* 32 */ "Association denied due to QAP having insufficient bandwidth " "to handle another QSTA", /* 33 */ "Association denied due to excessive frame loss rates and/or " "poor conditions on current operating channel", /* 34 */ "Association (with QBSS) denied due to requesting station not " "supporting the QoS facility", /* 35 */ "Association denied due to requesting station not supporting " "Block Ack", /* 36 */ "The request has been declined", /* 37 */ "The request has not been successful as one or more parameters " "have invalid values", /* 38 */ "The TS has not been created because the request cannot be honored. " "Try again with the suggested changes to the TSPEC", /* 39 */ "Invalid Information Element", /* 40 */ "Group Cipher is not valid", /* 41 */ "Pairwise Cipher is not valid", /* 42 */ "AKMP is not valid", /* 43 */ "Unsupported RSN IE version", /* 44 */ "Invalid RSN IE Capabilities", /* 45 */ "Cipher suite is rejected per security policy", /* 46 */ "The TS has not been created. However, the HC may be capable of " "creating a TS, in response to a request, after the time indicated " "in the TS Delay element", /* 47 */ "Direct Link is not allowed in the BSS by policy", /* 48 */ "Destination STA is not present within this QBSS.", /* 49 */ "The Destination STA is not a QSTA.", /* 50 */ }; #define NUM_STATUSES (sizeof status_text / sizeof status_text[0]) static const char *reason_text[] = { "Reserved", /* 0 */ "Unspecified reason", /* 1 */ "Previous authentication no longer valid", /* 2 */ "Deauthenticated because sending station is leaving (or has left) " "IBSS or ESS", /* 3 */ "Disassociated due to inactivity", /* 4 */ "Disassociated because AP is unable to handle all currently " " associated stations", /* 5 */ "Class 2 frame received from nonauthenticated station", /* 6 */ "Class 3 frame received from nonassociated station", /* 7 */ "Disassociated because sending station is leaving " "(or has left) BSS", /* 8 */ "Station requesting (re)association is not authenticated with " "responding station", /* 9 */ "Disassociated because the information in the Power Capability " "element is unacceptable", /* 10 */ "Disassociated because the information in the SupportedChannels " "element is unacceptable", /* 11 */ "Invalid Information Element", /* 12 */ "Reserved", /* 13 */ "Michael MIC failure", /* 14 */ "4-Way Handshake timeout", /* 15 */ "Group key update timeout", /* 16 */ "Information element in 4-Way Handshake different from (Re)Association" "Request/Probe Response/Beacon", /* 17 */ "Group Cipher is not valid", /* 18 */ "AKMP is not valid", /* 20 */ "Unsupported RSN IE version", /* 21 */ "Invalid RSN IE Capabilities", /* 22 */ "IEEE 802.1X Authentication failed", /* 23 */ "Cipher suite is rejected per security policy", /* 24 */ "Reserved", /* 25 */ "Reserved", /* 26 */ "Reserved", /* 27 */ "Reserved", /* 28 */ "Reserved", /* 29 */ "Reserved", /* 30 */ "TS deleted because QoS AP lacks sufficient bandwidth for this " "QoS STA due to a change in BSS service characteristics or " "operational mode (e.g. an HT BSS change from 40 MHz channel " "to 20 MHz channel)", /* 31 */ "Disassociated for unspecified, QoS-related reason", /* 32 */ "Disassociated because QoS AP lacks sufficient bandwidth for this " "QoS STA", /* 33 */ "Disassociated because of excessive number of frames that need to be " "acknowledged, but are not acknowledged for AP transmissions " "and/or poor channel conditions", /* 34 */ "Disassociated because STA is transmitting outside the limits " "of its TXOPs", /* 35 */ "Requested from peer STA as the STA is leaving the BSS " "(or resetting)", /* 36 */ "Requested from peer STA as it does not want to use the " "mechanism", /* 37 */ "Requested from peer STA as the STA received frames using the " "mechanism for which a set up is required", /* 38 */ "Requested from peer STA due to time out", /* 39 */ "Reserved", /* 40 */ "Reserved", /* 41 */ "Reserved", /* 42 */ "Reserved", /* 43 */ "Reserved", /* 44 */ "Peer STA does not support the requested cipher suite", /* 45 */ "Association denied due to requesting STA not supporting HT " "features", /* 46 */ }; #define NUM_REASONS (sizeof reason_text / sizeof reason_text[0]) static int wep_print(netdissect_options *ndo, const u_char *p) { uint32_t iv; if (!ND_TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN)) return 0; iv = EXTRACT_LE_32BITS(p); ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv), IV_KEYID(iv))); return 1; } static int parse_elements(netdissect_options *ndo, struct mgmt_body_t *pbody, const u_char *p, int offset, u_int length) { u_int elementlen; struct ssid_t ssid; struct challenge_t challenge; struct rates_t rates; struct ds_t ds; struct cf_t cf; struct tim_t tim; /* * We haven't seen any elements yet. */ pbody->challenge_present = 0; pbody->ssid_present = 0; pbody->rates_present = 0; pbody->ds_present = 0; pbody->cf_present = 0; pbody->tim_present = 0; while (length != 0) { /* Make sure we at least have the element ID and length. */ if (!ND_TTEST2(*(p + offset), 2)) return 0; if (length < 2) return 0; elementlen = *(p + offset + 1); /* Make sure we have the entire element. */ if (!ND_TTEST2(*(p + offset + 2), elementlen)) return 0; if (length < elementlen + 2) return 0; switch (*(p + offset)) { case E_SSID: memcpy(&ssid, p + offset, 2); offset += 2; length -= 2; if (ssid.length != 0) { if (ssid.length > sizeof(ssid.ssid) - 1) return 0; memcpy(&ssid.ssid, p + offset, ssid.length); offset += ssid.length; length -= ssid.length; } ssid.ssid[ssid.length] = '\0'; /* * Present and not truncated. * * If we haven't already seen an SSID IE, * copy this one, otherwise ignore this one, * so we later report the first one we saw. */ if (!pbody->ssid_present) { pbody->ssid = ssid; pbody->ssid_present = 1; } break; case E_CHALLENGE: memcpy(&challenge, p + offset, 2); offset += 2; length -= 2; if (challenge.length != 0) { if (challenge.length > sizeof(challenge.text) - 1) return 0; memcpy(&challenge.text, p + offset, challenge.length); offset += challenge.length; length -= challenge.length; } challenge.text[challenge.length] = '\0'; /* * Present and not truncated. * * If we haven't already seen a challenge IE, * copy this one, otherwise ignore this one, * so we later report the first one we saw. */ if (!pbody->challenge_present) { pbody->challenge = challenge; pbody->challenge_present = 1; } break; case E_RATES: memcpy(&rates, p + offset, 2); offset += 2; length -= 2; if (rates.length != 0) { if (rates.length > sizeof rates.rate) return 0; memcpy(&rates.rate, p + offset, rates.length); offset += rates.length; length -= rates.length; } /* * Present and not truncated. * * If we haven't already seen a rates IE, * copy this one if it's not zero-length, * otherwise ignore this one, so we later * report the first one we saw. * * We ignore zero-length rates IEs as some * devices seem to put a zero-length rates * IE, followed by an SSID IE, followed by * a non-zero-length rates IE into frames, * even though IEEE Std 802.11-2007 doesn't * seem to indicate that a zero-length rates * IE is valid. */ if (!pbody->rates_present && rates.length != 0) { pbody->rates = rates; pbody->rates_present = 1; } break; case E_DS: memcpy(&ds, p + offset, 2); offset += 2; length -= 2; if (ds.length != 1) { offset += ds.length; length -= ds.length; break; } ds.channel = *(p + offset); offset += 1; length -= 1; /* * Present and not truncated. * * If we haven't already seen a DS IE, * copy this one, otherwise ignore this one, * so we later report the first one we saw. */ if (!pbody->ds_present) { pbody->ds = ds; pbody->ds_present = 1; } break; case E_CF: memcpy(&cf, p + offset, 2); offset += 2; length -= 2; if (cf.length != 6) { offset += cf.length; length -= cf.length; break; } memcpy(&cf.count, p + offset, 6); offset += 6; length -= 6; /* * Present and not truncated. * * If we haven't already seen a CF IE, * copy this one, otherwise ignore this one, * so we later report the first one we saw. */ if (!pbody->cf_present) { pbody->cf = cf; pbody->cf_present = 1; } break; case E_TIM: memcpy(&tim, p + offset, 2); offset += 2; length -= 2; if (tim.length <= 3) { offset += tim.length; length -= tim.length; break; } if (tim.length - 3 > (int)sizeof tim.bitmap) return 0; memcpy(&tim.count, p + offset, 3); offset += 3; length -= 3; memcpy(tim.bitmap, p + offset, tim.length - 3); offset += tim.length - 3; length -= tim.length - 3; /* * Present and not truncated. * * If we haven't already seen a TIM IE, * copy this one, otherwise ignore this one, * so we later report the first one we saw. */ if (!pbody->tim_present) { pbody->tim = tim; pbody->tim_present = 1; } break; default: #if 0 ND_PRINT((ndo, "(1) unhandled element_id (%d) ", *(p + offset))); #endif offset += 2 + elementlen; length -= 2 + elementlen; break; } } /* No problems found. */ return 1; } /********************************************************************************* * Print Handle functions for the management frame types *********************************************************************************/ static int handle_beacon(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN)) return 0; if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN) return 0; memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); offset += IEEE802_11_TSTAMP_LEN; length -= IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_BCNINT_LEN; length -= IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; ret = parse_elements(ndo, &pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); ND_PRINT((ndo, " %s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS")); PRINT_DS_CHANNEL(pbody); return ret; } static int handle_assoc_request(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)) return 0; if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_LISTENINT_LEN; length -= IEEE802_11_LISTENINT_LEN; ret = parse_elements(ndo, &pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); return ret; } static int handle_assoc_response(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN + IEEE802_11_AID_LEN)) return 0; if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN + IEEE802_11_AID_LEN) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; pbody.status_code = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_STATUS_LEN; length -= IEEE802_11_STATUS_LEN; pbody.aid = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_AID_LEN; length -= IEEE802_11_AID_LEN; ret = parse_elements(ndo, &pbody, p, offset, length); ND_PRINT((ndo, " AID(%x) :%s: %s", ((uint16_t)(pbody.aid << 2 )) >> 2 , CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "", (pbody.status_code < NUM_STATUSES ? status_text[pbody.status_code] : "n/a"))); return ret; } static int handle_reassoc_request(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN + IEEE802_11_AP_LEN)) return 0; if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN + IEEE802_11_AP_LEN) return 0; pbody.capability_info = EXTRACT_LE_16BITS(p); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_LISTENINT_LEN; length -= IEEE802_11_LISTENINT_LEN; memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN); offset += IEEE802_11_AP_LEN; length -= IEEE802_11_AP_LEN; ret = parse_elements(ndo, &pbody, p, offset, length); PRINT_SSID(pbody); ND_PRINT((ndo, " AP : %s", etheraddr_string(ndo, pbody.ap ))); return ret; } static int handle_reassoc_response(netdissect_options *ndo, const u_char *p, u_int length) { /* Same as a Association Reponse */ return handle_assoc_response(ndo, p, length); } static int handle_probe_request(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); ret = parse_elements(ndo, &pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); return ret; } static int handle_probe_response(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN)) return 0; if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN) return 0; memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); offset += IEEE802_11_TSTAMP_LEN; length -= IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_BCNINT_LEN; length -= IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; ret = parse_elements(ndo, &pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); PRINT_DS_CHANNEL(pbody); return ret; } static int handle_atim(void) { /* the frame body for ATIM is null. */ return 1; } static int handle_disassoc(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN)) return 0; if (length < IEEE802_11_REASON_LEN) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); ND_PRINT((ndo, ": %s", (pbody.reason_code < NUM_REASONS) ? reason_text[pbody.reason_code] : "Reserved")); return 1; } static int handle_auth(netdissect_options *ndo, const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, 6)) return 0; if (length < 6) return 0; pbody.auth_alg = EXTRACT_LE_16BITS(p); offset += 2; length -= 2; pbody.auth_trans_seq_num = EXTRACT_LE_16BITS(p + offset); offset += 2; length -= 2; pbody.status_code = EXTRACT_LE_16BITS(p + offset); offset += 2; length -= 2; ret = parse_elements(ndo, &pbody, p, offset, length); if ((pbody.auth_alg == 1) && ((pbody.auth_trans_seq_num == 2) || (pbody.auth_trans_seq_num == 3))) { ND_PRINT((ndo, " (%s)-%x [Challenge Text] %s", (pbody.auth_alg < NUM_AUTH_ALGS) ? auth_alg_text[pbody.auth_alg] : "Reserved", pbody.auth_trans_seq_num, ((pbody.auth_trans_seq_num % 2) ? ((pbody.status_code < NUM_STATUSES) ? status_text[pbody.status_code] : "n/a") : ""))); return ret; } ND_PRINT((ndo, " (%s)-%x: %s", (pbody.auth_alg < NUM_AUTH_ALGS) ? auth_alg_text[pbody.auth_alg] : "Reserved", pbody.auth_trans_seq_num, (pbody.auth_trans_seq_num % 2) ? ((pbody.status_code < NUM_STATUSES) ? status_text[pbody.status_code] : "n/a") : "")); return ret; } static int handle_deauth(netdissect_options *ndo, const uint8_t *src, const u_char *p, u_int length) { struct mgmt_body_t pbody; const char *reason = NULL; memset(&pbody, 0, sizeof(pbody)); if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN)) return 0; if (length < IEEE802_11_REASON_LEN) return 0; pbody.reason_code = EXTRACT_LE_16BITS(p); reason = (pbody.reason_code < NUM_REASONS) ? reason_text[pbody.reason_code] : "Reserved"; if (ndo->ndo_eflag) { ND_PRINT((ndo, ": %s", reason)); } else { ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason)); } return 1; } #define PRINT_HT_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \ (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_BA_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \ (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \ (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_MESHLINK_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "Request")) : \ (v) == 1 ? ND_PRINT((ndo, "Report")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_MESHPEERING_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "Open")) : \ (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \ (v) == 2 ? ND_PRINT((ndo, "Close")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_MESHPATH_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "Request")) : \ (v) == 1 ? ND_PRINT((ndo, "Report")) : \ (v) == 2 ? ND_PRINT((ndo, "Error")) : \ (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_MESH_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \ (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \ (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \ (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \ (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \ (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \ (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \ (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \ (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \ (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \ (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_MULTIHOP_ACTION(v) (\ (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \ (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) #define PRINT_SELFPROT_ACTION(v) (\ (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \ (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \ (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \ (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \ (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \ ND_PRINT((ndo, "Act#%d", (v))) \ ) static int handle_action(netdissect_options *ndo, const uint8_t *src, const u_char *p, u_int length) { if (!ND_TTEST2(*p, 2)) return 0; if (length < 2) return 0; if (ndo->ndo_eflag) { ND_PRINT((ndo, ": ")); } else { ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src))); } switch (p[0]) { case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break; case 1: ND_PRINT((ndo, "QoS Act#%d", p[1])); break; case 2: ND_PRINT((ndo, "DLS Act#%d", p[1])); break; case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(p[1]); break; case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(p[1]); break; case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(p[1]); break; case 14: ND_PRINT((ndo, "MultiohopAction ")); PRINT_MULTIHOP_ACTION(p[1]); break; case 15: ND_PRINT((ndo, "SelfprotectAction ")); PRINT_SELFPROT_ACTION(p[1]); break; case 127: ND_PRINT((ndo, "Vendor Act#%d", p[1])); break; default: ND_PRINT((ndo, "Reserved(%d) Act#%d", p[0], p[1])); break; } return 1; } /********************************************************************************* * Print Body funcs *********************************************************************************/ static int mgmt_body_print(netdissect_options *ndo, uint16_t fc, const uint8_t *src, const u_char *p, u_int length) { ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc)))); /* There may be a problem w/ AP not having this bit set */ if (FC_PROTECTED(fc)) return wep_print(ndo, p); switch (FC_SUBTYPE(fc)) { case ST_ASSOC_REQUEST: return handle_assoc_request(ndo, p, length); case ST_ASSOC_RESPONSE: return handle_assoc_response(ndo, p, length); case ST_REASSOC_REQUEST: return handle_reassoc_request(ndo, p, length); case ST_REASSOC_RESPONSE: return handle_reassoc_response(ndo, p, length); case ST_PROBE_REQUEST: return handle_probe_request(ndo, p, length); case ST_PROBE_RESPONSE: return handle_probe_response(ndo, p, length); case ST_BEACON: return handle_beacon(ndo, p, length); case ST_ATIM: return handle_atim(); case ST_DISASSOC: return handle_disassoc(ndo, p, length); case ST_AUTH: return handle_auth(ndo, p, length); case ST_DEAUTH: return handle_deauth(ndo, src, p, length); case ST_ACTION: return handle_action(ndo, src, p, length); default: return 1; } } /********************************************************************************* * Handles printing all the control frame types *********************************************************************************/ static int ctrl_body_print(netdissect_options *ndo, uint16_t fc, const u_char *p) { ND_PRINT((ndo, "%s", tok2str(ctrl_str, "Unknown Ctrl Subtype", FC_SUBTYPE(fc)))); switch (FC_SUBTYPE(fc)) { case CTRL_CONTROL_WRAPPER: /* XXX - requires special handling */ break; case CTRL_BAR: if (!ND_TTEST2(*p, CTRL_BAR_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ", etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra), etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq)))); break; case CTRL_BA: if (!ND_TTEST2(*p, CTRL_BA_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s ", etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra))); break; case CTRL_PS_POLL: if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN)) return 0; ND_PRINT((ndo, " AID(%x)", EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t *)p)->aid)))); break; case CTRL_RTS: if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " TA:%s ", etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta))); break; case CTRL_CTS: if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s ", etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra))); break; case CTRL_ACK: if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s ", etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra))); break; case CTRL_CF_END: if (!ND_TTEST2(*p, CTRL_END_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s ", etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra))); break; case CTRL_END_ACK: if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN)) return 0; if (!ndo->ndo_eflag) ND_PRINT((ndo, " RA:%s ", etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra))); break; } return 1; } /* * Data Frame - Address field contents * * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4 * 0 | 0 | DA | SA | BSSID | n/a * 0 | 1 | DA | BSSID | SA | n/a * 1 | 0 | BSSID | SA | DA | n/a * 1 | 1 | RA | TA | DA | SA */ /* * Function to get source and destination MAC addresses for a data frame. */ static void get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp, const uint8_t **dstp) { #define ADDR1 (p + 4) #define ADDR2 (p + 10) #define ADDR3 (p + 16) #define ADDR4 (p + 24) if (!FC_TO_DS(fc)) { if (!FC_FROM_DS(fc)) { /* not To DS and not From DS */ *srcp = ADDR2; *dstp = ADDR1; } else { /* not To DS and From DS */ *srcp = ADDR3; *dstp = ADDR1; } } else { if (!FC_FROM_DS(fc)) { /* From DS and not To DS */ *srcp = ADDR2; *dstp = ADDR3; } else { /* To DS and From DS */ *srcp = ADDR4; *dstp = ADDR3; } } #undef ADDR1 #undef ADDR2 #undef ADDR3 #undef ADDR4 } static void get_mgmt_src_dst_mac(const u_char *p, const uint8_t **srcp, const uint8_t **dstp) { const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p; if (srcp != NULL) *srcp = hp->sa; if (dstp != NULL) *dstp = hp->da; } /* * Print Header funcs */ static void data_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p) { u_int subtype = FC_SUBTYPE(fc); if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) || DATA_FRAME_IS_QOS(subtype)) { ND_PRINT((ndo, "CF ")); if (DATA_FRAME_IS_CF_ACK(subtype)) { if (DATA_FRAME_IS_CF_POLL(subtype)) ND_PRINT((ndo, "Ack/Poll")); else ND_PRINT((ndo, "Ack")); } else { if (DATA_FRAME_IS_CF_POLL(subtype)) ND_PRINT((ndo, "Poll")); } if (DATA_FRAME_IS_QOS(subtype)) ND_PRINT((ndo, "+QoS")); ND_PRINT((ndo, " ")); } #define ADDR1 (p + 4) #define ADDR2 (p + 10) #define ADDR3 (p + 16) #define ADDR4 (p + 24) if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) { ND_PRINT((ndo, "DA:%s SA:%s BSSID:%s ", etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2), etheraddr_string(ndo, ADDR3))); } else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) { ND_PRINT((ndo, "DA:%s BSSID:%s SA:%s ", etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2), etheraddr_string(ndo, ADDR3))); } else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) { ND_PRINT((ndo, "BSSID:%s SA:%s DA:%s ", etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2), etheraddr_string(ndo, ADDR3))); } else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) { ND_PRINT((ndo, "RA:%s TA:%s DA:%s SA:%s ", etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2), etheraddr_string(ndo, ADDR3), etheraddr_string(ndo, ADDR4))); } #undef ADDR1 #undef ADDR2 #undef ADDR3 #undef ADDR4 } static void mgmt_header_print(netdissect_options *ndo, const u_char *p) { const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p; ND_PRINT((ndo, "BSSID:%s DA:%s SA:%s ", etheraddr_string(ndo, (hp)->bssid), etheraddr_string(ndo, (hp)->da), etheraddr_string(ndo, (hp)->sa))); } static void ctrl_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p) { switch (FC_SUBTYPE(fc)) { case CTRL_BAR: ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ", etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra), etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq)))); break; case CTRL_BA: ND_PRINT((ndo, "RA:%s ", etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra))); break; case CTRL_PS_POLL: ND_PRINT((ndo, "BSSID:%s TA:%s ", etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->bssid), etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->ta))); break; case CTRL_RTS: ND_PRINT((ndo, "RA:%s TA:%s ", etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ra), etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta))); break; case CTRL_CTS: ND_PRINT((ndo, "RA:%s ", etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra))); break; case CTRL_ACK: ND_PRINT((ndo, "RA:%s ", etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra))); break; case CTRL_CF_END: ND_PRINT((ndo, "RA:%s BSSID:%s ", etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra), etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->bssid))); break; case CTRL_END_ACK: ND_PRINT((ndo, "RA:%s BSSID:%s ", etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra), etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->bssid))); break; default: /* We shouldn't get here - we should already have quit */ break; } } static int extract_header_length(netdissect_options *ndo, uint16_t fc) { int len; switch (FC_TYPE(fc)) { case T_MGMT: return MGMT_HDRLEN; case T_CTRL: switch (FC_SUBTYPE(fc)) { case CTRL_CONTROL_WRAPPER: return CTRL_CONTROL_WRAPPER_HDRLEN; case CTRL_BAR: return CTRL_BAR_HDRLEN; case CTRL_BA: return CTRL_BA_HDRLEN; case CTRL_PS_POLL: return CTRL_PS_POLL_HDRLEN; case CTRL_RTS: return CTRL_RTS_HDRLEN; case CTRL_CTS: return CTRL_CTS_HDRLEN; case CTRL_ACK: return CTRL_ACK_HDRLEN; case CTRL_CF_END: return CTRL_END_HDRLEN; case CTRL_END_ACK: return CTRL_END_ACK_HDRLEN; default: ND_PRINT((ndo, "unknown 802.11 ctrl frame subtype (%d)", FC_SUBTYPE(fc))); return 0; } case T_DATA: len = (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24; if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) len += 2; return len; default: ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc))); return 0; } } static int extract_mesh_header_length(const u_char *p) { return (p[0] &~ 3) ? 0 : 6*(1 + (p[0] & 3)); } /* * Print the 802.11 MAC header. */ static void ieee_802_11_hdr_print(netdissect_options *ndo, uint16_t fc, const u_char *p, u_int hdrlen, u_int meshdrlen) { if (ndo->ndo_vflag) { if (FC_MORE_DATA(fc)) ND_PRINT((ndo, "More Data ")); if (FC_MORE_FLAG(fc)) ND_PRINT((ndo, "More Fragments ")); if (FC_POWER_MGMT(fc)) ND_PRINT((ndo, "Pwr Mgmt ")); if (FC_RETRY(fc)) ND_PRINT((ndo, "Retry ")); if (FC_ORDER(fc)) ND_PRINT((ndo, "Strictly Ordered ")); if (FC_PROTECTED(fc)) ND_PRINT((ndo, "Protected ")); if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL) ND_PRINT((ndo, "%dus ", EXTRACT_LE_16BITS( &((const struct mgmt_header_t *)p)->duration))); } if (meshdrlen != 0) { const struct meshcntl_t *mc = (const struct meshcntl_t *)&p[hdrlen - meshdrlen]; int ae = mc->flags & 3; ND_PRINT((ndo, "MeshData (AE %d TTL %u seq %u", ae, mc->ttl, EXTRACT_LE_32BITS(mc->seq))); if (ae > 0) ND_PRINT((ndo, " A4:%s", etheraddr_string(ndo, mc->addr4))); if (ae > 1) ND_PRINT((ndo, " A5:%s", etheraddr_string(ndo, mc->addr5))); if (ae > 2) ND_PRINT((ndo, " A6:%s", etheraddr_string(ndo, mc->addr6))); ND_PRINT((ndo, ") ")); } switch (FC_TYPE(fc)) { case T_MGMT: mgmt_header_print(ndo, p); break; case T_CTRL: ctrl_header_print(ndo, fc, p); break; case T_DATA: data_header_print(ndo, fc, p); break; default: break; } } #ifndef roundup2 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ #endif static const char tstr[] = "[|802.11]"; static u_int ieee802_11_print(netdissect_options *ndo, const u_char *p, u_int length, u_int orig_caplen, int pad, u_int fcslen) { uint16_t fc; u_int caplen, hdrlen, meshdrlen; struct lladdr_info src, dst; int llc_hdrlen; caplen = orig_caplen; /* Remove FCS, if present */ if (length < fcslen) { ND_PRINT((ndo, "%s", tstr)); return caplen; } length -= fcslen; if (caplen > length) { /* Amount of FCS in actual packet data, if any */ fcslen = caplen - length; caplen -= fcslen; ndo->ndo_snapend -= fcslen; } if (caplen < IEEE802_11_FC_LEN) { ND_PRINT((ndo, "%s", tstr)); return orig_caplen; } fc = EXTRACT_LE_16BITS(p); hdrlen = extract_header_length(ndo, fc); if (hdrlen == 0) { /* Unknown frame type or control frame subtype; quit. */ return (0); } if (pad) hdrlen = roundup2(hdrlen, 4); if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA && DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) { + if (caplen < hdrlen + 1) { + ND_PRINT((ndo, "%s", tstr)); + return hdrlen; + } meshdrlen = extract_mesh_header_length(p+hdrlen); hdrlen += meshdrlen; } else meshdrlen = 0; if (caplen < hdrlen) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } if (ndo->ndo_eflag) ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen); /* * Go past the 802.11 header. */ length -= hdrlen; caplen -= hdrlen; p += hdrlen; src.addr_string = etheraddr_string; dst.addr_string = etheraddr_string; switch (FC_TYPE(fc)) { case T_MGMT: get_mgmt_src_dst_mac(p - hdrlen, &src.addr, &dst.addr); if (!mgmt_body_print(ndo, fc, src.addr, p, length)) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } break; case T_CTRL: if (!ctrl_body_print(ndo, fc, p - hdrlen)) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } break; case T_DATA: if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc))) return hdrlen; /* no-data frame */ /* There may be a problem w/ AP not having this bit set */ if (FC_PROTECTED(fc)) { ND_PRINT((ndo, "Data")); if (!wep_print(ndo, p)) { ND_PRINT((ndo, "%s", tstr)); return hdrlen; } } else { get_data_src_dst_mac(fc, p - hdrlen, &src.addr, &dst.addr); llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst); if (llc_hdrlen < 0) { /* * Some kinds of LLC packet we cannot * handle intelligently */ if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); llc_hdrlen = -llc_hdrlen; } hdrlen += llc_hdrlen; } break; default: /* We shouldn't get here - we should already have quit */ break; } return hdrlen; } /* * This is the top level routine of the printer. 'p' points * to the 802.11 header of the packet, 'h->ts' is the timestamp, * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ u_int ieee802_11_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0); } /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */ /* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */ /*- * Copyright (c) 2003, 2004 David Young. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of David Young may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ /* A generic radio capture format is desirable. It must be * rigidly defined (e.g., units for fields should be given), * and easily extensible. * * The following is an extensible radio capture format. It is * based on a bitmap indicating which fields are present. * * I am trying to describe precisely what the application programmer * should expect in the following, and for that reason I tell the * units and origin of each measurement (where it applies), or else I * use sufficiently weaselly language ("is a monotonically nondecreasing * function of...") that I cannot set false expectations for lawyerly * readers. */ /* * The radio capture header precedes the 802.11 header. * * Note well: all radiotap fields are little-endian. */ struct ieee80211_radiotap_header { uint8_t it_version; /* Version 0. Only increases * for drastic changes, * introduction of compatible * new fields does not count. */ uint8_t it_pad; uint16_t it_len; /* length of the whole * header in bytes, including * it_version, it_pad, * it_len, and data fields. */ uint32_t it_present; /* A bitmap telling which * fields are present. Set bit 31 * (0x80000000) to extend the * bitmap by another 32 bits. * Additional extensions are made * by setting bit 31. */ }; /* Name Data type Units * ---- --------- ----- * * IEEE80211_RADIOTAP_TSFT uint64_t microseconds * * Value in microseconds of the MAC's 64-bit 802.11 Time * Synchronization Function timer when the first bit of the * MPDU arrived at the MAC. For received frames, only. * * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap * * Tx/Rx frequency in MHz, followed by flags (see below). * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to * represent an HT channel as there is not enough room in * the flags word. * * IEEE80211_RADIOTAP_FHSS uint16_t see below * * For frequency-hopping radios, the hop set (first byte) * and pattern (second byte). * * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index * * Tx/Rx data rate. If bit 0x80 is set then it represents an * an MCS index and not an IEEE rate. * * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from * one milliwatt (dBm) * * RF signal power at the antenna, decibel difference from * one milliwatt. * * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from * one milliwatt (dBm) * * RF noise power at the antenna, decibel difference from one * milliwatt. * * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) * * RF signal power at the antenna, decibel difference from an * arbitrary, fixed reference. * * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) * * RF noise power at the antenna, decibel difference from an * arbitrary, fixed reference point. * * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless * * Quality of Barker code lock. Unitless. Monotonically * nondecreasing with "better" lock strength. Called "Signal * Quality" in datasheets. (Is there a standard way to measure * this?) * * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless * * Transmit power expressed as unitless distance from max * power set at factory calibration. 0 is max power. * Monotonically nondecreasing with lower power levels. * * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB) * * Transmit power expressed as decibel distance from max power * set at factory calibration. 0 is max power. Monotonically * nondecreasing with lower power levels. * * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from * one milliwatt (dBm) * * Transmit power expressed as dBm (decibels from a 1 milliwatt * reference). This is the absolute power level measured at * the antenna port. * * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap * * Properties of transmitted and received frames. See flags * defined below. * * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index * * Unitless indication of the Rx/Tx antenna for this packet. * The first antenna is antenna 0. * * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap * * Properties of received frames. See flags defined below. * * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap * uint16_t MHz * uint8_t channel number * uint8_t .5 dBm * * Extended channel specification: flags (see below) followed by * frequency in MHz, the corresponding IEEE channel number, and * finally the maximum regulatory transmit power cap in .5 dBm * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL * and only one of the two should be present. * * IEEE80211_RADIOTAP_MCS uint8_t known * uint8_t flags * uint8_t mcs * * Bitset indicating which fields have known values, followed * by bitset of flag values, followed by the MCS rate index as * in IEEE 802.11n. * * * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless * * Contains the AMPDU information for the subframe. * * IEEE80211_RADIOTAP_VHT u16, u8, u8, u8[4], u8, u8, u16 * * Contains VHT information about this frame. * * IEEE80211_RADIOTAP_VENDOR_NAMESPACE * uint8_t OUI[3] * uint8_t subspace * uint16_t length * * The Vendor Namespace Field contains three sub-fields. The first * sub-field is 3 bytes long. It contains the vendor's IEEE 802 * Organizationally Unique Identifier (OUI). The fourth byte is a * vendor-specific "namespace selector." * */ enum ieee80211_radiotap_type { IEEE80211_RADIOTAP_TSFT = 0, IEEE80211_RADIOTAP_FLAGS = 1, IEEE80211_RADIOTAP_RATE = 2, IEEE80211_RADIOTAP_CHANNEL = 3, IEEE80211_RADIOTAP_FHSS = 4, IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, IEEE80211_RADIOTAP_LOCK_QUALITY = 7, IEEE80211_RADIOTAP_TX_ATTENUATION = 8, IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, IEEE80211_RADIOTAP_DBM_TX_POWER = 10, IEEE80211_RADIOTAP_ANTENNA = 11, IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, IEEE80211_RADIOTAP_DB_ANTNOISE = 13, IEEE80211_RADIOTAP_RX_FLAGS = 14, /* NB: gap for netbsd definitions */ IEEE80211_RADIOTAP_XCHANNEL = 18, IEEE80211_RADIOTAP_MCS = 19, IEEE80211_RADIOTAP_AMPDU_STATUS = 20, IEEE80211_RADIOTAP_VHT = 21, IEEE80211_RADIOTAP_NAMESPACE = 29, IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, IEEE80211_RADIOTAP_EXT = 31 }; /* channel attributes */ #define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */ #define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */ #define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */ #define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */ #define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */ #define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */ #define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */ #define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */ #define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */ #define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */ #define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */ #define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */ #define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */ #define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */ #define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */ /* Useful combinations of channel characteristics, borrowed from Ethereal */ #define IEEE80211_CHAN_A \ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) #define IEEE80211_CHAN_B \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) #define IEEE80211_CHAN_G \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) #define IEEE80211_CHAN_TA \ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO) #define IEEE80211_CHAN_TG \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO) /* For IEEE80211_RADIOTAP_FLAGS */ #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received * during CFP */ #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received * with short * preamble */ #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received * with WEP encryption */ #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received * with fragmentation */ #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between * 802.11 header and payload * (to 32-bit boundary) */ #define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */ /* For IEEE80211_RADIOTAP_RX_FLAGS */ #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ #define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */ /* For IEEE80211_RADIOTAP_MCS known */ #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01 #define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */ #define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04 #define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08 #define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10 #define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20 #define IEEE80211_RADIOTAP_MCS_NESS_KNOWN 0x40 #define IEEE80211_RADIOTAP_MCS_NESS_BIT_1 0x80 /* For IEEE80211_RADIOTAP_MCS flags */ #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2 #define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3 #define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */ #define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 #define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60 #define IEEE80211_RADIOTAP_MCS_STBC_1 1 #define IEEE80211_RADIOTAP_MCS_STBC_2 2 #define IEEE80211_RADIOTAP_MCS_STBC_3 3 #define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5 #define IEEE80211_RADIOTAP_MCS_NESS_BIT_0 0x80 /* For IEEE80211_RADIOTAP_AMPDU_STATUS */ #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001 #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002 #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004 #define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008 #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010 #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020 /* For IEEE80211_RADIOTAP_VHT known */ #define IEEE80211_RADIOTAP_VHT_STBC_KNOWN 0x0001 #define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA_KNOWN 0x0002 #define IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN 0x0004 #define IEEE80211_RADIOTAP_VHT_SGI_NSYM_DIS_KNOWN 0x0008 #define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM_KNOWN 0x0010 #define IEEE80211_RADIOTAP_VHT_BEAMFORMED_KNOWN 0x0020 #define IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN 0x0040 #define IEEE80211_RADIOTAP_VHT_GROUP_ID_KNOWN 0x0080 #define IEEE80211_RADIOTAP_VHT_PARTIAL_AID_KNOWN 0x0100 /* For IEEE80211_RADIOTAP_VHT flags */ #define IEEE80211_RADIOTAP_VHT_STBC 0x01 #define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA 0x02 #define IEEE80211_RADIOTAP_VHT_SHORT_GI 0x04 #define IEEE80211_RADIOTAP_VHT_SGI_NSYM_M10_9 0x08 #define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM 0x10 #define IEEE80211_RADIOTAP_VHT_BEAMFORMED 0x20 #define IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK 0x1f #define IEEE80211_RADIOTAP_VHT_NSS_MASK 0x0f #define IEEE80211_RADIOTAP_VHT_MCS_MASK 0xf0 #define IEEE80211_RADIOTAP_VHT_MCS_SHIFT 4 #define IEEE80211_RADIOTAP_CODING_LDPC_USERn 0x01 #define IEEE80211_CHAN_FHSS \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK) #define IEEE80211_CHAN_A \ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM) #define IEEE80211_CHAN_B \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK) #define IEEE80211_CHAN_PUREG \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM) #define IEEE80211_CHAN_G \ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN) #define IS_CHAN_FHSS(flags) \ ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS) #define IS_CHAN_A(flags) \ ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A) #define IS_CHAN_B(flags) \ ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B) #define IS_CHAN_PUREG(flags) \ ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG) #define IS_CHAN_G(flags) \ ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G) #define IS_CHAN_ANYG(flags) \ (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags)) static void print_chaninfo(netdissect_options *ndo, uint16_t freq, int flags, int presentflags) { ND_PRINT((ndo, "%u MHz", freq)); if (presentflags & (1 << IEEE80211_RADIOTAP_MCS)) { /* * We have the MCS field, so this is 11n, regardless * of what the channel flags say. */ ND_PRINT((ndo, " 11n")); } else { if (IS_CHAN_FHSS(flags)) ND_PRINT((ndo, " FHSS")); if (IS_CHAN_A(flags)) { if (flags & IEEE80211_CHAN_HALF) ND_PRINT((ndo, " 11a/10Mhz")); else if (flags & IEEE80211_CHAN_QUARTER) ND_PRINT((ndo, " 11a/5Mhz")); else ND_PRINT((ndo, " 11a")); } if (IS_CHAN_ANYG(flags)) { if (flags & IEEE80211_CHAN_HALF) ND_PRINT((ndo, " 11g/10Mhz")); else if (flags & IEEE80211_CHAN_QUARTER) ND_PRINT((ndo, " 11g/5Mhz")); else ND_PRINT((ndo, " 11g")); } else if (IS_CHAN_B(flags)) ND_PRINT((ndo, " 11b")); if (flags & IEEE80211_CHAN_TURBO) ND_PRINT((ndo, " Turbo")); } /* * These apply to 11n. */ if (flags & IEEE80211_CHAN_HT20) ND_PRINT((ndo, " ht/20")); else if (flags & IEEE80211_CHAN_HT40D) ND_PRINT((ndo, " ht/40-")); else if (flags & IEEE80211_CHAN_HT40U) ND_PRINT((ndo, " ht/40+")); ND_PRINT((ndo, " ")); } static int print_radiotap_field(netdissect_options *ndo, struct cpack_state *s, uint32_t bit, uint8_t *flagsp, uint32_t presentflags) { u_int i; int rc; switch (bit) { case IEEE80211_RADIOTAP_TSFT: { uint64_t tsft; rc = cpack_uint64(s, &tsft); if (rc != 0) goto trunc; ND_PRINT((ndo, "%" PRIu64 "us tsft ", tsft)); break; } case IEEE80211_RADIOTAP_FLAGS: { uint8_t flagsval; rc = cpack_uint8(s, &flagsval); if (rc != 0) goto trunc; *flagsp = flagsval; if (flagsval & IEEE80211_RADIOTAP_F_CFP) ND_PRINT((ndo, "cfp ")); if (flagsval & IEEE80211_RADIOTAP_F_SHORTPRE) ND_PRINT((ndo, "short preamble ")); if (flagsval & IEEE80211_RADIOTAP_F_WEP) ND_PRINT((ndo, "wep ")); if (flagsval & IEEE80211_RADIOTAP_F_FRAG) ND_PRINT((ndo, "fragmented ")); if (flagsval & IEEE80211_RADIOTAP_F_BADFCS) ND_PRINT((ndo, "bad-fcs ")); break; } case IEEE80211_RADIOTAP_RATE: { uint8_t rate; rc = cpack_uint8(s, &rate); if (rc != 0) goto trunc; /* * XXX On FreeBSD rate & 0x80 means we have an MCS. On * Linux and AirPcap it does not. (What about * Mac OS X, NetBSD, OpenBSD, and DragonFly BSD?) * * This is an issue either for proprietary extensions * to 11a or 11g, which do exist, or for 11n * implementations that stuff a rate value into * this field, which also appear to exist. * * We currently handle that by assuming that * if the 0x80 bit is set *and* the remaining * bits have a value between 0 and 15 it's * an MCS value, otherwise it's a rate. If * there are cases where systems that use * "0x80 + MCS index" for MCS indices > 15, * or stuff a rate value here between 64 and * 71.5 Mb/s in here, we'll need a preference * setting. Such rates do exist, e.g. 11n * MCS 7 at 20 MHz with a long guard interval. */ if (rate >= 0x80 && rate <= 0x8f) { /* * XXX - we don't know the channel width * or guard interval length, so we can't * convert this to a data rate. * * If you want us to show a data rate, * use the MCS field, not the Rate field; * the MCS field includes not only the * MCS index, it also includes bandwidth * and guard interval information. * * XXX - can we get the channel width * from XChannel and the guard interval * information from Flags, at least on * FreeBSD? */ ND_PRINT((ndo, "MCS %u ", rate & 0x7f)); } else ND_PRINT((ndo, "%2.1f Mb/s ", .5 * rate)); break; } case IEEE80211_RADIOTAP_CHANNEL: { uint16_t frequency; uint16_t flags; rc = cpack_uint16(s, &frequency); if (rc != 0) goto trunc; rc = cpack_uint16(s, &flags); if (rc != 0) goto trunc; /* * If CHANNEL and XCHANNEL are both present, skip * CHANNEL. */ if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL)) break; print_chaninfo(ndo, frequency, flags, presentflags); break; } case IEEE80211_RADIOTAP_FHSS: { uint8_t hopset; uint8_t hoppat; rc = cpack_uint8(s, &hopset); if (rc != 0) goto trunc; rc = cpack_uint8(s, &hoppat); if (rc != 0) goto trunc; ND_PRINT((ndo, "fhset %d fhpat %d ", hopset, hoppat)); break; } case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: { int8_t dbm_antsignal; rc = cpack_int8(s, &dbm_antsignal); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddBm signal ", dbm_antsignal)); break; } case IEEE80211_RADIOTAP_DBM_ANTNOISE: { int8_t dbm_antnoise; rc = cpack_int8(s, &dbm_antnoise); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddBm noise ", dbm_antnoise)); break; } case IEEE80211_RADIOTAP_LOCK_QUALITY: { uint16_t lock_quality; rc = cpack_uint16(s, &lock_quality); if (rc != 0) goto trunc; ND_PRINT((ndo, "%u sq ", lock_quality)); break; } case IEEE80211_RADIOTAP_TX_ATTENUATION: { uint16_t tx_attenuation; rc = cpack_uint16(s, &tx_attenuation); if (rc != 0) goto trunc; ND_PRINT((ndo, "%d tx power ", -(int)tx_attenuation)); break; } case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: { uint8_t db_tx_attenuation; rc = cpack_uint8(s, &db_tx_attenuation); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddB tx attenuation ", -(int)db_tx_attenuation)); break; } case IEEE80211_RADIOTAP_DBM_TX_POWER: { int8_t dbm_tx_power; rc = cpack_int8(s, &dbm_tx_power); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddBm tx power ", dbm_tx_power)); break; } case IEEE80211_RADIOTAP_ANTENNA: { uint8_t antenna; rc = cpack_uint8(s, &antenna); if (rc != 0) goto trunc; ND_PRINT((ndo, "antenna %u ", antenna)); break; } case IEEE80211_RADIOTAP_DB_ANTSIGNAL: { uint8_t db_antsignal; rc = cpack_uint8(s, &db_antsignal); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddB signal ", db_antsignal)); break; } case IEEE80211_RADIOTAP_DB_ANTNOISE: { uint8_t db_antnoise; rc = cpack_uint8(s, &db_antnoise); if (rc != 0) goto trunc; ND_PRINT((ndo, "%ddB noise ", db_antnoise)); break; } case IEEE80211_RADIOTAP_RX_FLAGS: { uint16_t rx_flags; rc = cpack_uint16(s, &rx_flags); if (rc != 0) goto trunc; /* Do nothing for now */ break; } case IEEE80211_RADIOTAP_XCHANNEL: { uint32_t flags; uint16_t frequency; uint8_t channel; uint8_t maxpower; rc = cpack_uint32(s, &flags); if (rc != 0) goto trunc; rc = cpack_uint16(s, &frequency); if (rc != 0) goto trunc; rc = cpack_uint8(s, &channel); if (rc != 0) goto trunc; rc = cpack_uint8(s, &maxpower); if (rc != 0) goto trunc; print_chaninfo(ndo, frequency, flags, presentflags); break; } case IEEE80211_RADIOTAP_MCS: { uint8_t known; uint8_t flags; uint8_t mcs_index; static const char *ht_bandwidth[4] = { "20 MHz", "40 MHz", "20 MHz (L)", "20 MHz (U)" }; float htrate; rc = cpack_uint8(s, &known); if (rc != 0) goto trunc; rc = cpack_uint8(s, &flags); if (rc != 0) goto trunc; rc = cpack_uint8(s, &mcs_index); if (rc != 0) goto trunc; if (known & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) { /* * We know the MCS index. */ if (mcs_index <= MAX_MCS_INDEX) { /* * And it's in-range. */ if (known & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) { /* * And we know both the bandwidth and * the guard interval, so we can look * up the rate. */ htrate = ieee80211_float_htrates \ [mcs_index] \ [((flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \ [((flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)]; } else { /* * We don't know both the bandwidth * and the guard interval, so we can * only report the MCS index. */ htrate = 0.0; } } else { /* * The MCS value is out of range. */ htrate = 0.0; } if (htrate != 0.0) { /* * We have the rate. * Print it. */ ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, mcs_index)); } else { /* * We at least have the MCS index. * Print it. */ ND_PRINT((ndo, "MCS %u ", mcs_index)); } } if (known & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) { ND_PRINT((ndo, "%s ", ht_bandwidth[flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK])); } if (known & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) { ND_PRINT((ndo, "%s GI ", (flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? "short" : "long")); } if (known & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) { ND_PRINT((ndo, "%s ", (flags & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ? "greenfield" : "mixed")); } if (known & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) { ND_PRINT((ndo, "%s FEC ", (flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ? "LDPC" : "BCC")); } if (known & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) { ND_PRINT((ndo, "RX-STBC%u ", (flags & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT)); } break; } case IEEE80211_RADIOTAP_AMPDU_STATUS: { uint32_t reference_num; uint16_t flags; uint8_t delim_crc; uint8_t reserved; rc = cpack_uint32(s, &reference_num); if (rc != 0) goto trunc; rc = cpack_uint16(s, &flags); if (rc != 0) goto trunc; rc = cpack_uint8(s, &delim_crc); if (rc != 0) goto trunc; rc = cpack_uint8(s, &reserved); if (rc != 0) goto trunc; /* Do nothing for now */ break; } case IEEE80211_RADIOTAP_VHT: { uint16_t known; uint8_t flags; uint8_t bandwidth; uint8_t mcs_nss[4]; uint8_t coding; uint8_t group_id; uint16_t partial_aid; static const char *vht_bandwidth[32] = { "20 MHz", "40 MHz", "20 MHz (L)", "20 MHz (U)", "80 MHz", "80 MHz (L)", "80 MHz (U)", "80 MHz (LL)", "80 MHz (LU)", "80 MHz (UL)", "80 MHz (UU)", "160 MHz", "160 MHz (L)", "160 MHz (U)", "160 MHz (LL)", "160 MHz (LU)", "160 MHz (UL)", "160 MHz (UU)", "160 MHz (LLL)", "160 MHz (LLU)", "160 MHz (LUL)", "160 MHz (UUU)", "160 MHz (ULL)", "160 MHz (ULU)", "160 MHz (UUL)", "160 MHz (UUU)", "unknown (26)", "unknown (27)", "unknown (28)", "unknown (29)", "unknown (30)", "unknown (31)" }; rc = cpack_uint16(s, &known); if (rc != 0) goto trunc; rc = cpack_uint8(s, &flags); if (rc != 0) goto trunc; rc = cpack_uint8(s, &bandwidth); if (rc != 0) goto trunc; for (i = 0; i < 4; i++) { rc = cpack_uint8(s, &mcs_nss[i]); if (rc != 0) goto trunc; } rc = cpack_uint8(s, &coding); if (rc != 0) goto trunc; rc = cpack_uint8(s, &group_id); if (rc != 0) goto trunc; rc = cpack_uint16(s, &partial_aid); if (rc != 0) goto trunc; for (i = 0; i < 4; i++) { u_int nss, mcs; nss = mcs_nss[i] & IEEE80211_RADIOTAP_VHT_NSS_MASK; mcs = (mcs_nss[i] & IEEE80211_RADIOTAP_VHT_MCS_MASK) >> IEEE80211_RADIOTAP_VHT_MCS_SHIFT; if (nss == 0) continue; ND_PRINT((ndo, "User %u MCS %u ", i, mcs)); ND_PRINT((ndo, "%s FEC ", (coding & (IEEE80211_RADIOTAP_CODING_LDPC_USERn << i)) ? "LDPC" : "BCC")); } if (known & IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN) { ND_PRINT((ndo, "%s ", vht_bandwidth[bandwidth & IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK])); } if (known & IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN) { ND_PRINT((ndo, "%s GI ", (flags & IEEE80211_RADIOTAP_VHT_SHORT_GI) ? "short" : "long")); } break; } default: /* this bit indicates a field whose * size we do not know, so we cannot * proceed. Just print the bit number. */ ND_PRINT((ndo, "[bit %u] ", bit)); return -1; } return 0; trunc: ND_PRINT((ndo, "%s", tstr)); return rc; } static int print_in_radiotap_namespace(netdissect_options *ndo, struct cpack_state *s, uint8_t *flags, uint32_t presentflags, int bit0) { #define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x))) #define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x))) #define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x))) #define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x))) #define BITNO_2(x) (((x) & 2) ? 1 : 0) uint32_t present, next_present; int bitno; enum ieee80211_radiotap_type bit; int rc; for (present = presentflags; present; present = next_present) { /* * Clear the least significant bit that is set. */ next_present = present & (present - 1); /* * Get the bit number, within this presence word, * of the remaining least significant bit that * is set. */ bitno = BITNO_32(present ^ next_present); /* * Stop if this is one of the "same meaning * in all presence flags" bits. */ if (bitno >= IEEE80211_RADIOTAP_NAMESPACE) break; /* * Get the radiotap bit number of that bit. */ bit = (enum ieee80211_radiotap_type)(bit0 + bitno); rc = print_radiotap_field(ndo, s, bit, flags, presentflags); if (rc != 0) return rc; } return 0; } -static u_int +u_int ieee802_11_radio_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) { #define BIT(n) (1U << n) #define IS_EXTENDED(__p) \ (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0 struct cpack_state cpacker; const struct ieee80211_radiotap_header *hdr; uint32_t presentflags; const uint32_t *presentp, *last_presentp; int vendor_namespace; uint8_t vendor_oui[3]; uint8_t vendor_subnamespace; uint16_t skip_length; int bit0; u_int len; uint8_t flags; int pad; u_int fcslen; if (caplen < sizeof(*hdr)) { ND_PRINT((ndo, "%s", tstr)); return caplen; } hdr = (const struct ieee80211_radiotap_header *)p; len = EXTRACT_LE_16BITS(&hdr->it_len); + if (len < sizeof(*hdr)) { + /* + * The length is the length of the entire header, so + * it must be as large as the fixed-length part of + * the header. + */ + ND_PRINT((ndo, "%s", tstr)); + return caplen; + } /* * If we don't have the entire radiotap header, just give up. */ if (caplen < len) { ND_PRINT((ndo, "%s", tstr)); return caplen; } cpack_init(&cpacker, (const uint8_t *)hdr, len); /* align against header start */ cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */ for (last_presentp = &hdr->it_present; (const u_char*)(last_presentp + 1) <= p + len && IS_EXTENDED(last_presentp); last_presentp++) cpack_advance(&cpacker, sizeof(hdr->it_present)); /* more bitmaps */ /* are there more bitmap extensions than bytes in header? */ if ((const u_char*)(last_presentp + 1) > p + len) { ND_PRINT((ndo, "%s", tstr)); return caplen; } /* * Start out at the beginning of the default radiotap namespace. */ bit0 = 0; vendor_namespace = 0; memset(vendor_oui, 0, 3); vendor_subnamespace = 0; skip_length = 0; /* Assume no flags */ flags = 0; /* Assume no Atheros padding between 802.11 header and body */ pad = 0; /* Assume no FCS at end of frame */ fcslen = 0; for (presentp = &hdr->it_present; presentp <= last_presentp; presentp++) { presentflags = EXTRACT_LE_32BITS(presentp); /* * If this is a vendor namespace, we don't handle it. */ if (vendor_namespace) { /* * Skip past the stuff we don't understand. * If we add support for any vendor namespaces, * it'd be added here; use vendor_oui and * vendor_subnamespace to interpret the fields. */ if (cpack_advance(&cpacker, skip_length) != 0) { /* * Ran out of space in the packet. */ break; } /* * We've skipped it all; nothing more to * skip. */ skip_length = 0; } else { if (print_in_radiotap_namespace(ndo, &cpacker, &flags, presentflags, bit0) != 0) { /* * Fatal error - can't process anything * more in the radiotap header. */ break; } } /* * Handle the namespace switch bits; we've already handled * the extension bit in all but the last word above. */ switch (presentflags & (BIT(IEEE80211_RADIOTAP_NAMESPACE)|BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE))) { case 0: /* * We're not changing namespaces. * advance to the next 32 bits in the current * namespace. */ bit0 += 32; break; case BIT(IEEE80211_RADIOTAP_NAMESPACE): /* * We're switching to the radiotap namespace. * Reset the presence-bitmap index to 0, and * reset the namespace to the default radiotap * namespace. */ bit0 = 0; vendor_namespace = 0; memset(vendor_oui, 0, 3); vendor_subnamespace = 0; skip_length = 0; break; case BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE): /* * We're switching to a vendor namespace. * Reset the presence-bitmap index to 0, * note that we're in a vendor namespace, * and fetch the fields of the Vendor Namespace * item. */ bit0 = 0; vendor_namespace = 1; if ((cpack_align_and_reserve(&cpacker, 2)) == NULL) { ND_PRINT((ndo, "%s", tstr)); break; } if (cpack_uint8(&cpacker, &vendor_oui[0]) != 0) { ND_PRINT((ndo, "%s", tstr)); break; } if (cpack_uint8(&cpacker, &vendor_oui[1]) != 0) { ND_PRINT((ndo, "%s", tstr)); break; } if (cpack_uint8(&cpacker, &vendor_oui[2]) != 0) { ND_PRINT((ndo, "%s", tstr)); break; } if (cpack_uint8(&cpacker, &vendor_subnamespace) != 0) { ND_PRINT((ndo, "%s", tstr)); break; } if (cpack_uint16(&cpacker, &skip_length) != 0) { ND_PRINT((ndo, "%s", tstr)); break; } break; default: /* * Illegal combination. The behavior in this * case is undefined by the radiotap spec; we * just ignore both bits. */ break; } } if (flags & IEEE80211_RADIOTAP_F_DATAPAD) pad = 1; /* Atheros padding */ if (flags & IEEE80211_RADIOTAP_F_FCS) fcslen = 4; /* FCS at end of packet */ return len + ieee802_11_print(ndo, p + len, length - len, caplen - len, pad, fcslen); #undef BITNO_32 #undef BITNO_16 #undef BITNO_8 #undef BITNO_4 #undef BITNO_2 #undef BIT } static u_int ieee802_11_avs_radio_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) { uint32_t caphdr_len; if (caplen < 8) { ND_PRINT((ndo, "%s", tstr)); return caplen; } caphdr_len = EXTRACT_32BITS(p + 4); if (caphdr_len < 8) { /* * Yow! The capture header length is claimed not * to be large enough to include even the version * cookie or capture header length! */ ND_PRINT((ndo, "%s", tstr)); return caplen; } if (caplen < caphdr_len) { ND_PRINT((ndo, "%s", tstr)); return caplen; } return caphdr_len + ieee802_11_print(ndo, p + caphdr_len, length - caphdr_len, caplen - caphdr_len, 0, 0); } #define PRISM_HDR_LEN 144 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002 /* * For DLT_PRISM_HEADER; like DLT_IEEE802_11, but with an extra header, * containing information such as radio information, which we * currently ignore. * * If, however, the packet begins with WLANCAP_MAGIC_COOKIE_V1 or * WLANCAP_MAGIC_COOKIE_V2, it's really DLT_IEEE802_11_RADIO_AVS * (currently, on Linux, there's no ARPHRD_ type for * DLT_IEEE802_11_RADIO_AVS, as there is a ARPHRD_IEEE80211_PRISM * for DLT_PRISM_HEADER, so ARPHRD_IEEE80211_PRISM is used for * the AVS header, and the first 4 bytes of the header are used to * indicate whether it's a Prism header or an AVS header). */ u_int prism_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; uint32_t msgcode; if (caplen < 4) { ND_PRINT((ndo, "%s", tstr)); return caplen; } msgcode = EXTRACT_32BITS(p); if (msgcode == WLANCAP_MAGIC_COOKIE_V1 || msgcode == WLANCAP_MAGIC_COOKIE_V2) return ieee802_11_avs_radio_print(ndo, p, length, caplen); if (caplen < PRISM_HDR_LEN) { ND_PRINT((ndo, "%s", tstr)); return caplen; } return PRISM_HDR_LEN + ieee802_11_print(ndo, p + PRISM_HDR_LEN, length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0); } /* * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra * header, containing information such as radio information. */ u_int ieee802_11_radio_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_radio_print(ndo, p, h->len, h->caplen); } /* * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an * extra header, containing information such as radio information, * which we currently ignore. */ u_int ieee802_11_radio_avs_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_avs_radio_print(ndo, p, h->len, h->caplen); } Index: vendor/tcpdump/dist/print-aoe.c =================================================================== --- vendor/tcpdump/dist/print-aoe.c (revision 353143) +++ vendor/tcpdump/dist/print-aoe.c (revision 353144) @@ -1,430 +1,432 @@ /* * Copyright (c) 2014 The TCPDUMP project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* \summary: ATA over Ethernet (AoE) protocol printer */ /* specification: http://brantleycoilecompany.com/AoEr11.pdf */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "ether.h" static const char tstr[] = " [|aoe]"; #define AOE_V1 1 #define ATA_SECTOR_SIZE 512 #define AOEV1_CMD_ISSUE_ATA_COMMAND 0 #define AOEV1_CMD_QUERY_CONFIG_INFORMATION 1 #define AOEV1_CMD_MAC_MASK_LIST 2 #define AOEV1_CMD_RESERVE_RELEASE 3 static const struct tok cmdcode_str[] = { { AOEV1_CMD_ISSUE_ATA_COMMAND, "Issue ATA Command" }, { AOEV1_CMD_QUERY_CONFIG_INFORMATION, "Query Config Information" }, { AOEV1_CMD_MAC_MASK_LIST, "MAC Mask List" }, { AOEV1_CMD_RESERVE_RELEASE, "Reserve/Release" }, { 0, NULL } }; #define AOEV1_COMMON_HDR_LEN 10U /* up to but w/o Arg */ #define AOEV1_ISSUE_ARG_LEN 12U /* up to but w/o Data */ #define AOEV1_QUERY_ARG_LEN 8U /* up to but w/o Config String */ #define AOEV1_MAC_ARG_LEN 4U /* up to but w/o Directive 0 */ #define AOEV1_RESERVE_ARG_LEN 2U /* up to but w/o Ethernet address 0 */ #define AOEV1_MAX_CONFSTR_LEN 1024U #define AOEV1_FLAG_R 0x08 #define AOEV1_FLAG_E 0x04 static const struct tok aoev1_flag_str[] = { { AOEV1_FLAG_R, "Response" }, { AOEV1_FLAG_E, "Error" }, { 0x02, "MBZ-0x02" }, { 0x01, "MBZ-0x01" }, { 0, NULL } }; static const struct tok aoev1_errcode_str[] = { { 1, "Unrecognized command code" }, { 2, "Bad argument parameter" }, { 3, "Device unavailable" }, { 4, "Config string present" }, { 5, "Unsupported version" }, { 6, "Target is reserved" }, { 0, NULL } }; #define AOEV1_AFLAG_E 0x40 #define AOEV1_AFLAG_D 0x10 #define AOEV1_AFLAG_A 0x02 #define AOEV1_AFLAG_W 0x01 static const struct tok aoev1_aflag_str[] = { { 0x08, "MBZ-0x08" }, { AOEV1_AFLAG_E, "Ext48" }, { 0x06, "MBZ-0x06" }, { AOEV1_AFLAG_D, "Device" }, { 0x04, "MBZ-0x04" }, { 0x03, "MBZ-0x03" }, { AOEV1_AFLAG_A, "Async" }, { AOEV1_AFLAG_W, "Write" }, { 0, NULL } }; static const struct tok aoev1_ccmd_str[] = { { 0, "read config string" }, { 1, "test config string" }, { 2, "test config string prefix" }, { 3, "set config string" }, { 4, "force set config string" }, { 0, NULL } }; static const struct tok aoev1_mcmd_str[] = { { 0, "Read Mac Mask List" }, { 1, "Edit Mac Mask List" }, { 0, NULL } }; static const struct tok aoev1_merror_str[] = { { 1, "Unspecified Error" }, { 2, "Bad DCmd directive" }, { 3, "Mask list full" }, { 0, NULL } }; static const struct tok aoev1_dcmd_str[] = { { 0, "No Directive" }, { 1, "Add mac address to mask list" }, { 2, "Delete mac address from mask list" }, { 0, NULL } }; static const struct tok aoev1_rcmd_str[] = { { 0, "Read reserve list" }, { 1, "Set reserve list" }, { 2, "Force set reserve list" }, { 0, NULL } }; static void aoev1_issue_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; if (len < AOEV1_ISSUE_ARG_LEN) goto invalid; /* AFlags */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp))); cp += 1; /* Err/Feature */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Err/Feature: %u", *cp)); cp += 1; /* Sector Count (not correlated with the length) */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Sector Count: %u", *cp)); cp += 1; /* Cmd/Status */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Cmd/Status: %u", *cp)); cp += 1; /* lba0 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\tlba0: %u", *cp)); cp += 1; /* lba1 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", lba1: %u", *cp)); cp += 1; /* lba2 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", lba2: %u", *cp)); cp += 1; /* lba3 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", lba3: %u", *cp)); cp += 1; /* lba4 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", lba4: %u", *cp)); cp += 1; /* lba5 */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", lba5: %u", *cp)); cp += 1; /* Reserved */ ND_TCHECK2(*cp, 2); cp += 2; /* Data */ if (len > AOEV1_ISSUE_ARG_LEN) ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN)); return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void aoev1_query_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint16_t cslen; if (len < AOEV1_QUERY_ARG_LEN) goto invalid; /* Buffer Count */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp))); cp += 2; /* Firmware Version */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp))); cp += 2; /* Sector Count */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Sector Count: %u", *cp)); cp += 1; /* AoE/CCmd */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4, tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F))); cp += 1; /* Config String Length */ ND_TCHECK2(*cp, 2); cslen = EXTRACT_16BITS(cp); cp += 2; if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len) goto invalid; /* Config String */ ND_TCHECK2(*cp, cslen); if (cslen) { ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen)); if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend)) goto trunc; } return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void aoev1_mac_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint8_t dircount, i; if (len < AOEV1_MAC_ARG_LEN) goto invalid; /* Reserved */ ND_TCHECK2(*cp, 1); cp += 1; /* MCmd */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp))); cp += 1; /* MError */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp))); cp += 1; /* Dir Count */ ND_TCHECK2(*cp, 1); dircount = *cp; cp += 1; ND_PRINT((ndo, ", Dir Count: %u", dircount)); if (AOEV1_MAC_ARG_LEN + dircount * 8 > len) goto invalid; /* directives */ for (i = 0; i < dircount; i++) { /* Reserved */ ND_TCHECK2(*cp, 1); cp += 1; /* DCmd */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp))); cp += 1; /* Ethernet Address */ ND_TCHECK2(*cp, ETHER_ADDR_LEN); ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp))); cp += ETHER_ADDR_LEN; } return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void aoev1_reserve_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint8_t nmacs, i; if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN) goto invalid; /* RCmd */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp))); cp += 1; /* NMacs (correlated with the length) */ ND_TCHECK2(*cp, 1); nmacs = *cp; cp += 1; ND_PRINT((ndo, ", NMacs: %u", nmacs)); if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len) goto invalid; /* addresses */ for (i = 0; i < nmacs; i++) { + ND_TCHECK2(*cp, ETHER_ADDR_LEN); ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp))); cp += ETHER_ADDR_LEN; } return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* cp points to the Ver/Flags octet */ static void aoev1_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint8_t flags, command; void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int); if (len < AOEV1_COMMON_HDR_LEN) goto invalid; /* Flags */ + ND_TCHECK2(*cp, 1); flags = *cp & 0x0F; ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags))); cp += 1; if (! ndo->ndo_vflag) return; /* Error */ ND_TCHECK2(*cp, 1); if (flags & AOEV1_FLAG_E) ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp))); cp += 1; /* Major */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp))); cp += 2; /* Minor */ ND_TCHECK2(*cp, 1); ND_PRINT((ndo, ", Minor: 0x%02x", *cp)); cp += 1; /* Command */ ND_TCHECK2(*cp, 1); command = *cp; cp += 1; ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command))); /* Tag */ ND_TCHECK2(*cp, 4); ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp))); cp += 4; /* Arg */ cmd_decoder = command == AOEV1_CMD_ISSUE_ATA_COMMAND ? aoev1_issue_print : command == AOEV1_CMD_QUERY_CONFIG_INFORMATION ? aoev1_query_print : command == AOEV1_CMD_MAC_MASK_LIST ? aoev1_mac_print : command == AOEV1_CMD_RESERVE_RELEASE ? aoev1_reserve_print : NULL; if (cmd_decoder != NULL) cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN); return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } void aoe_print(netdissect_options *ndo, const u_char *cp, const u_int len) { const u_char *ep = cp + len; uint8_t ver; ND_PRINT((ndo, "AoE length %u", len)); if (len < 1) goto invalid; /* Ver/Flags */ ND_TCHECK2(*cp, 1); ver = (*cp & 0xF0) >> 4; /* Don't advance cp yet: low order 4 bits are version-specific. */ ND_PRINT((ndo, ", Ver %u", ver)); switch (ver) { case AOE_V1: aoev1_print(ndo, cp, len); break; } return; invalid: ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return; trunc: ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-babel.c =================================================================== --- vendor/tcpdump/dist/print-babel.c (revision 353143) +++ vendor/tcpdump/dist/print-babel.c (revision 353144) @@ -1,717 +1,719 @@ /* * Copyright (c) 2007-2011 GrĂ©goire Henry, Juliusz Chroboczek * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* \summary: Babel Routing Protocol printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" static const char tstr[] = "[|babel]"; static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length); void babel_print(netdissect_options *ndo, const u_char *cp, u_int length) { ND_PRINT((ndo, "babel")); ND_TCHECK2(*cp, 4); if(cp[0] != 42) { ND_PRINT((ndo, " invalid header")); return; } else { ND_PRINT((ndo, " %d", cp[1])); } switch(cp[1]) { case 2: babel_print_v2(ndo, cp, length); break; default: ND_PRINT((ndo, " unknown version")); break; } return; trunc: ND_PRINT((ndo, " %s", tstr)); return; } /* TLVs */ #define MESSAGE_PAD1 0 #define MESSAGE_PADN 1 #define MESSAGE_ACK_REQ 2 #define MESSAGE_ACK 3 #define MESSAGE_HELLO 4 #define MESSAGE_IHU 5 #define MESSAGE_ROUTER_ID 6 #define MESSAGE_NH 7 #define MESSAGE_UPDATE 8 #define MESSAGE_REQUEST 9 #define MESSAGE_MH_REQUEST 10 #define MESSAGE_TSPC 11 #define MESSAGE_HMAC 12 #define MESSAGE_UPDATE_SRC_SPECIFIC 13 #define MESSAGE_REQUEST_SRC_SPECIFIC 14 #define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15 /* sub-TLVs */ #define MESSAGE_SUB_PAD1 0 #define MESSAGE_SUB_PADN 1 #define MESSAGE_SUB_DIVERSITY 2 #define MESSAGE_SUB_TIMESTAMP 3 /* Diversity sub-TLV channel codes */ static const struct tok diversity_str[] = { { 0, "reserved" }, { 255, "all" }, { 0, NULL } }; static const char * format_id(const u_char *id) { static char buf[25]; snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]); buf[24] = '\0'; return buf; } static const unsigned char v4prefix[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; static const char * format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen) { static char buf[50]; if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0) snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96); else snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen); buf[49] = '\0'; return buf; } static const char * format_address(netdissect_options *ndo, const u_char *prefix) { if(memcmp(prefix, v4prefix, 12) == 0) return ipaddr_string(ndo, prefix + 12); else return ip6addr_string(ndo, prefix); } static const char * format_interval(const uint16_t i) { static char buf[sizeof("000.00s")]; if (i == 0) return "0.0s (bogus)"; snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100); return buf; } static const char * format_interval_update(const uint16_t i) { return i == 0xFFFF ? "infinity" : format_interval(i); } static const char * format_timestamp(const uint32_t i) { static char buf[sizeof("0000.000000s")]; snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000); return buf; } /* Return number of octets consumed from the input buffer (not the prefix length * in bytes), or -1 for encoding error. */ static int network_prefix(int ae, int plen, unsigned int omitted, const unsigned char *p, const unsigned char *dp, unsigned int len, unsigned char *p_r) { unsigned pb; unsigned char prefix[16]; int consumed = 0; if(plen >= 0) pb = (plen + 7) / 8; else if(ae == 1) pb = 4; else pb = 16; if(pb > 16) return -1; memset(prefix, 0, 16); switch(ae) { case 0: break; case 1: if(omitted > 4 || pb > 4 || (pb > omitted && len < pb - omitted)) return -1; memcpy(prefix, v4prefix, 12); if(omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, 12 + omitted); } if(pb > omitted) { memcpy(prefix + 12 + omitted, p, pb - omitted); consumed = pb - omitted; } break; case 2: if(omitted > 16 || (pb > omitted && len < pb - omitted)) return -1; if(omitted) { if (dp == NULL) return -1; memcpy(prefix, dp, omitted); } if(pb > omitted) { memcpy(prefix + omitted, p, pb - omitted); consumed = pb - omitted; } break; case 3: if(pb > 8 && len < pb - 8) return -1; prefix[0] = 0xfe; prefix[1] = 0x80; if(pb > 8) { memcpy(prefix + 8, p, pb - 8); consumed = pb - 8; } break; default: return -1; } memcpy(p_r, prefix, 16); return consumed; } static int network_address(int ae, const unsigned char *a, unsigned int len, unsigned char *a_r) { return network_prefix(ae, -1, 0, a, NULL, len, a_r); } /* * Sub-TLVs consume the "extra data" of Babel TLVs (see Section 4.3 of RFC6126), * their encoding is similar to the encoding of TLVs, but the type namespace is * different: * * o Type 0 stands for Pad1 sub-TLV with the same encoding as the Pad1 TLV. * o Type 1 stands for PadN sub-TLV with the same encoding as the PadN TLV. * o Type 2 stands for Diversity sub-TLV, which propagates diversity routing * data. Its body is a variable-length sequence of 8-bit unsigned integers, * each representing per-hop number of interferring radio channel for the * prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel * 255 interferes with any other channel. * o Type 3 stands for Timestamp sub-TLV, used to compute RTT between * neighbours. In the case of a Hello TLV, the body stores a 32-bits * timestamp, while in the case of a IHU TLV, two 32-bits timestamps are * stored. * * Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is * only valid for TLV type 8 (Update). Note that within an Update TLV a missing * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body. * The former would mean a lack of any claims about the interference, and the * latter would state that interference is definitely absent. * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact * semantic of the sub-TLV is different in each case. */ static void subtlvs_print(netdissect_options *ndo, const u_char *cp, const u_char *ep, const uint8_t tlv_type) { uint8_t subtype, sublen; const char *sep; uint32_t t1, t2; while (cp < ep) { subtype = *cp++; if(subtype == MESSAGE_SUB_PAD1) { ND_PRINT((ndo, " sub-pad1")); continue; } if(cp == ep) goto invalid; sublen = *cp++; if(cp + sublen > ep) goto invalid; switch(subtype) { case MESSAGE_SUB_PADN: ND_PRINT((ndo, " sub-padn")); cp += sublen; break; case MESSAGE_SUB_DIVERSITY: ND_PRINT((ndo, " sub-diversity")); if (sublen == 0) { ND_PRINT((ndo, " empty")); break; } sep = " "; while(sublen--) { ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++))); sep = "-"; } if(tlv_type != MESSAGE_UPDATE && tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC) ND_PRINT((ndo, " (bogus)")); break; case MESSAGE_SUB_TIMESTAMP: ND_PRINT((ndo, " sub-timestamp")); if(tlv_type == MESSAGE_HELLO) { if(sublen < 4) goto invalid; t1 = EXTRACT_32BITS(cp); ND_PRINT((ndo, " %s", format_timestamp(t1))); } else if(tlv_type == MESSAGE_IHU) { if(sublen < 8) goto invalid; t1 = EXTRACT_32BITS(cp); ND_PRINT((ndo, " %s", format_timestamp(t1))); t2 = EXTRACT_32BITS(cp + 4); ND_PRINT((ndo, "|%s", format_timestamp(t2))); } else ND_PRINT((ndo, " (bogus)")); cp += sublen; break; default: ND_PRINT((ndo, " sub-unknown-0x%02x", subtype)); cp += sublen; } /* switch */ } /* while */ return; invalid: ND_PRINT((ndo, "%s", istr)); } #define ICHECK(i, l) \ if ((i) + (l) > bodylen || (i) + (l) > length) goto invalid; static void babel_print_v2(netdissect_options *ndo, const u_char *cp, u_int length) { u_int i; u_short bodylen; u_char v4_prefix[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 }; u_char v6_prefix[16] = {0}; ND_TCHECK2(*cp, 4); if (length < 4) goto invalid; bodylen = EXTRACT_16BITS(cp + 2); ND_PRINT((ndo, " (%u)", bodylen)); + if (4U + bodylen > length) + goto invalid; /* Process the TLVs in the body */ i = 0; while(i < bodylen) { const u_char *message; u_int type, len; message = cp + 4 + i; ND_TCHECK2(*message, 1); if((type = message[0]) == MESSAGE_PAD1) { ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1")); i += 1; continue; } ND_TCHECK2(*message, 2); ICHECK(i, 2); len = message[1]; ND_TCHECK2(*message, 2 + len); ICHECK(i, 2 + len); switch(type) { case MESSAGE_PADN: { if (!ndo->ndo_vflag) ND_PRINT((ndo, " padN")); else ND_PRINT((ndo, "\n\tPad %d", len + 2)); } break; case MESSAGE_ACK_REQ: { u_short nonce, interval; if (!ndo->ndo_vflag) ND_PRINT((ndo, " ack-req")); else { ND_PRINT((ndo, "\n\tAcknowledgment Request ")); if(len < 6) goto invalid; nonce = EXTRACT_16BITS(message + 4); interval = EXTRACT_16BITS(message + 6); ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval))); } } break; case MESSAGE_ACK: { u_short nonce; if (!ndo->ndo_vflag) ND_PRINT((ndo, " ack")); else { ND_PRINT((ndo, "\n\tAcknowledgment ")); if(len < 2) goto invalid; nonce = EXTRACT_16BITS(message + 2); ND_PRINT((ndo, "%04x", nonce)); } } break; case MESSAGE_HELLO: { u_short seqno, interval; if (!ndo->ndo_vflag) ND_PRINT((ndo, " hello")); else { ND_PRINT((ndo, "\n\tHello ")); if(len < 6) goto invalid; seqno = EXTRACT_16BITS(message + 4); interval = EXTRACT_16BITS(message + 6); ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval))); /* Extra data. */ if(len > 6) subtlvs_print(ndo, message + 8, message + 2 + len, type); } } break; case MESSAGE_IHU: { unsigned short txcost, interval; if (!ndo->ndo_vflag) ND_PRINT((ndo, " ihu")); else { u_char address[16]; int rc; ND_PRINT((ndo, "\n\tIHU ")); if(len < 6) goto invalid; txcost = EXTRACT_16BITS(message + 4); interval = EXTRACT_16BITS(message + 6); rc = network_address(message[2], message + 8, len - 6, address); if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; } ND_PRINT((ndo, "%s txcost %u interval %s", format_address(ndo, address), txcost, format_interval(interval))); /* Extra data. */ if((u_int)rc < len - 6) subtlvs_print(ndo, message + 8 + rc, message + 2 + len, type); } } break; case MESSAGE_ROUTER_ID: { if (!ndo->ndo_vflag) ND_PRINT((ndo, " router-id")); else { ND_PRINT((ndo, "\n\tRouter Id")); if(len < 10) goto invalid; ND_PRINT((ndo, " %s", format_id(message + 4))); } } break; case MESSAGE_NH: { if (!ndo->ndo_vflag) ND_PRINT((ndo, " nh")); else { int rc; u_char nh[16]; ND_PRINT((ndo, "\n\tNext Hop")); if(len < 2) goto invalid; rc = network_address(message[2], message + 4, len - 2, nh); if(rc < 0) goto invalid; ND_PRINT((ndo, " %s", format_address(ndo, nh))); } } break; case MESSAGE_UPDATE: { if (!ndo->ndo_vflag) { ND_PRINT((ndo, " update")); - if(len < 1) + if(len < 10) ND_PRINT((ndo, "/truncated")); else ND_PRINT((ndo, "%s%s%s", (message[3] & 0x80) ? "/prefix": "", (message[3] & 0x40) ? "/id" : "", (message[3] & 0x3f) ? "/unknown" : "")); } else { u_short interval, seqno, metric; u_char plen; int rc; u_char prefix[16]; ND_PRINT((ndo, "\n\tUpdate")); if(len < 10) goto invalid; plen = message[4] + (message[2] == 1 ? 96 : 0); rc = network_prefix(message[2], message[4], message[5], message + 12, message[2] == 1 ? v4_prefix : v6_prefix, len - 10, prefix); if(rc < 0) goto invalid; interval = EXTRACT_16BITS(message + 6); seqno = EXTRACT_16BITS(message + 8); metric = EXTRACT_16BITS(message + 10); ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s", (message[3] & 0x80) ? "/prefix": "", (message[3] & 0x40) ? "/id" : "", (message[3] & 0x3f) ? "/unknown" : "", format_prefix(ndo, prefix, plen), metric, seqno, format_interval_update(interval))); if(message[3] & 0x80) { if(message[2] == 1) memcpy(v4_prefix, prefix, 16); else memcpy(v6_prefix, prefix, 16); } /* extra data? */ if((u_int)rc < len - 10) subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type); } } break; case MESSAGE_REQUEST: { if (!ndo->ndo_vflag) ND_PRINT((ndo, " request")); else { int rc; u_char prefix[16], plen; ND_PRINT((ndo, "\n\tRequest ")); if(len < 2) goto invalid; plen = message[3] + (message[2] == 1 ? 96 : 0); rc = network_prefix(message[2], message[3], 0, message + 4, NULL, len - 2, prefix); if(rc < 0) goto invalid; ND_PRINT((ndo, "for %s", message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen))); } } break; case MESSAGE_MH_REQUEST : { if (!ndo->ndo_vflag) ND_PRINT((ndo, " mh-request")); else { int rc; u_short seqno; u_char prefix[16], plen; ND_PRINT((ndo, "\n\tMH-Request ")); if(len < 14) goto invalid; seqno = EXTRACT_16BITS(message + 4); rc = network_prefix(message[2], message[3], 0, message + 16, NULL, len - 14, prefix); if(rc < 0) goto invalid; plen = message[3] + (message[2] == 1 ? 96 : 0); ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s", message[6], format_prefix(ndo, prefix, plen), seqno, format_id(message + 8))); } } break; case MESSAGE_TSPC : if (!ndo->ndo_vflag) ND_PRINT((ndo, " tspc")); else { ND_PRINT((ndo, "\n\tTS/PC ")); if(len < 6) goto invalid; ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4), EXTRACT_16BITS(message + 2))); } break; case MESSAGE_HMAC : { if (!ndo->ndo_vflag) ND_PRINT((ndo, " hmac")); else { unsigned j; ND_PRINT((ndo, "\n\tHMAC ")); if(len < 18) goto invalid; ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2)); for (j = 0; j < len - 2; j++) ND_PRINT((ndo, "%02X", message[4 + j])); } } break; case MESSAGE_UPDATE_SRC_SPECIFIC : { if(!ndo->ndo_vflag) { ND_PRINT((ndo, " ss-update")); } else { u_char prefix[16], src_prefix[16]; u_short interval, seqno, metric; u_char ae, plen, src_plen, omitted; int rc; int parsed_len = 10; ND_PRINT((ndo, "\n\tSS-Update")); if(len < 10) goto invalid; ae = message[2]; src_plen = message[3]; plen = message[4]; omitted = message[5]; interval = EXTRACT_16BITS(message + 6); seqno = EXTRACT_16BITS(message + 8); metric = EXTRACT_16BITS(message + 10); rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len, ae == 1 ? v4_prefix : v6_prefix, len - parsed_len, prefix); if(rc < 0) goto invalid; if(ae == 1) plen += 96; parsed_len += rc; rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, src_prefix); if(rc < 0) goto invalid; if(ae == 1) src_plen += 96; parsed_len += rc; ND_PRINT((ndo, " %s from", format_prefix(ndo, prefix, plen))); ND_PRINT((ndo, " %s metric %u seqno %u interval %s", format_prefix(ndo, src_prefix, src_plen), metric, seqno, format_interval_update(interval))); /* extra data? */ if((u_int)parsed_len < len) subtlvs_print(ndo, message + 2 + parsed_len, message + 2 + len, type); } } break; case MESSAGE_REQUEST_SRC_SPECIFIC : { if(!ndo->ndo_vflag) ND_PRINT((ndo, " ss-request")); else { int rc, parsed_len = 3; u_char ae, plen, src_plen, prefix[16], src_prefix[16]; ND_PRINT((ndo, "\n\tSS-Request ")); if(len < 3) goto invalid; ae = message[2]; plen = message[3]; src_plen = message[4]; rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, prefix); if(rc < 0) goto invalid; if(ae == 1) plen += 96; parsed_len += rc; rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, src_prefix); if(rc < 0) goto invalid; if(ae == 1) src_plen += 96; parsed_len += rc; if(ae == 0) { ND_PRINT((ndo, "for any")); } else { ND_PRINT((ndo, "for (%s, ", format_prefix(ndo, prefix, plen))); ND_PRINT((ndo, "%s)", format_prefix(ndo, src_prefix, src_plen))); } } } break; case MESSAGE_MH_REQUEST_SRC_SPECIFIC : { if(!ndo->ndo_vflag) ND_PRINT((ndo, " ss-mh-request")); else { int rc, parsed_len = 14; u_short seqno; u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc; const u_char *router_id = NULL; ND_PRINT((ndo, "\n\tSS-MH-Request ")); if(len < 14) goto invalid; ae = message[2]; plen = message[3]; seqno = EXTRACT_16BITS(message + 4); hopc = message[6]; src_plen = message[7]; router_id = message + 8; rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, prefix); if(rc < 0) goto invalid; if(ae == 1) plen += 96; parsed_len += rc; rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, src_prefix); if(rc < 0) goto invalid; if(ae == 1) src_plen += 96; ND_PRINT((ndo, "(%u hops) for (%s, ", hopc, format_prefix(ndo, prefix, plen))); ND_PRINT((ndo, "%s) seqno %u id %s", format_prefix(ndo, src_prefix, src_plen), seqno, format_id(router_id))); } } break; default: if (!ndo->ndo_vflag) ND_PRINT((ndo, " unknown")); else ND_PRINT((ndo, "\n\tUnknown message type %d", type)); } i += len + 2; } return; trunc: ND_PRINT((ndo, " %s", tstr)); return; invalid: ND_PRINT((ndo, "%s", istr)); return; } Index: vendor/tcpdump/dist/print-bfd.c =================================================================== --- vendor/tcpdump/dist/print-bfd.c (revision 353143) +++ vendor/tcpdump/dist/print-bfd.c (revision 353144) @@ -1,406 +1,421 @@ /* * 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 Hannes Gredler (hannes@gredler.at) */ /* \summary: Bidirectional Forwarding Detection (BFD) printer */ -/* specification: RFC 5880 (for version 1) and RFC 5881 */ +/* + * specification: draft-ietf-bfd-base-01 for version 0, + * RFC 5880 for version 1, and RFC 5881 + */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "udp.h" /* - * Control packet, BFDv0, draft-katz-ward-bfd-01.txt + * Control packet, BFDv0, draft-ietf-bfd-base-01 * * 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 |H|D|P|F| Rsvd | Detect Mult | Length | + * |Vers | Diag |H|D|P|F|C|A|Rsv| Detect Mult | Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | My Discriminator | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Your Discriminator | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Desired Min TX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Required Min RX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Required Min Echo RX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ /* * Control packet, BFDv1, RFC 5880 * * 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|M| Detect Mult | Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | My Discriminator | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Your Discriminator | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Desired Min TX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Required Min RX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Required Min Echo RX Interval | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct bfd_header_t { uint8_t version_diag; uint8_t flags; uint8_t detect_time_multiplier; uint8_t length; uint8_t my_discriminator[4]; uint8_t your_discriminator[4]; uint8_t desired_min_tx_interval[4]; uint8_t required_min_rx_interval[4]; uint8_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 { uint8_t auth_type; uint8_t auth_len; uint8_t auth_data; uint8_t dummy; /* minimun 4 bytes */ }; enum auth_type { AUTH_PASSWORD = 1, AUTH_MD5 = 2, AUTH_MET_MD5 = 3, AUTH_SHA1 = 4, AUTH_MET_SHA1 = 5 }; static const struct tok bfd_v1_authentication_values[] = { { AUTH_PASSWORD, "Simple Password" }, { AUTH_MD5, "Keyed MD5" }, { AUTH_MET_MD5, "Meticulous Keyed MD5" }, { AUTH_SHA1, "Keyed SHA1" }, { AUTH_MET_SHA1, "Meticulous Keyed SHA1" }, { 0, NULL } }; enum auth_length { AUTH_PASSWORD_FIELD_MIN_LEN = 4, /* header + password min: 3 + 1 */ AUTH_PASSWORD_FIELD_MAX_LEN = 19, /* header + password max: 3 + 16 */ AUTH_MD5_FIELD_LEN = 24, AUTH_MD5_HASH_LEN = 16, AUTH_SHA1_FIELD_LEN = 28, AUTH_SHA1_HASH_LEN = 20 }; #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5) #define BFD_EXTRACT_DIAG(x) ((x)&0x1f) -static const struct tok bfd_port_values[] = { - { BFD_CONTROL_PORT, "Control" }, - { BFD_ECHO_PORT, "Echo" }, - { 0, NULL } -}; - static const struct tok bfd_diag_values[] = { { 0, "No Diagnostic" }, { 1, "Control Detection Time Expired" }, { 2, "Echo Function Failed" }, { 3, "Neighbor Signaled Session Down" }, { 4, "Forwarding Plane Reset" }, { 5, "Path Down" }, { 6, "Concatenated Path Down" }, { 7, "Administratively Down" }, { 8, "Reverse Concatenated Path Down" }, { 0, NULL } }; +#define BFD_FLAG_AUTH 0x04 + static const struct tok bfd_v0_flag_values[] = { { 0x80, "I Hear You" }, { 0x40, "Demand" }, { 0x20, "Poll" }, { 0x10, "Final" }, - { 0x08, "Reserved" }, - { 0x04, "Reserved" }, + { 0x08, "Control Plane Independent" }, + { BFD_FLAG_AUTH, "Authentication Present" }, { 0x02, "Reserved" }, { 0x01, "Reserved" }, { 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, "Multipoint" }, { 0, NULL } }; static const struct tok bfd_v1_state_values[] = { { 0, "AdminDown" }, { 1, "Down" }, { 2, "Init" }, { 3, "Up" }, { 0, NULL } }; static int auth_print(netdissect_options *ndo, register const u_char *pptr) { const struct bfd_auth_header_t *bfd_auth_header; int i; pptr += sizeof (const struct bfd_header_t); bfd_auth_header = (const struct bfd_auth_header_t *)pptr; ND_TCHECK(*bfd_auth_header); ND_PRINT((ndo, "\n\tAuthentication: %s (%u), length: %u", tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type), bfd_auth_header->auth_type, bfd_auth_header->auth_len)); pptr += 2; ND_PRINT((ndo, "\n\t Auth Key ID: %d", *pptr)); switch(bfd_auth_header->auth_type) { case AUTH_PASSWORD: /* * Simple Password Authentication Section Format * * 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 | Auth Key ID | Password... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (bfd_auth_header->auth_len < AUTH_PASSWORD_FIELD_MIN_LEN || bfd_auth_header->auth_len > AUTH_PASSWORD_FIELD_MAX_LEN) { ND_PRINT((ndo, "[invalid length %d]", bfd_auth_header->auth_len)); break; } pptr++; ND_PRINT((ndo, ", Password: ")); /* the length is equal to the password length plus three */ if (fn_printn(ndo, pptr, bfd_auth_header->auth_len - 3, ndo->ndo_snapend)) goto trunc; break; case AUTH_MD5: case AUTH_MET_MD5: /* * Keyed MD5 and Meticulous Keyed MD5 Authentication Section Format * * 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 | Auth Key ID | Reserved | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Sequence Number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Auth Key/Digest... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (bfd_auth_header->auth_len != AUTH_MD5_FIELD_LEN) { ND_PRINT((ndo, "[invalid length %d]", bfd_auth_header->auth_len)); break; } pptr += 2; ND_TCHECK2(*pptr, 4); ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr))); pptr += 4; ND_TCHECK2(*pptr, AUTH_MD5_HASH_LEN); ND_PRINT((ndo, "\n\t Digest: ")); for(i = 0; i < AUTH_MD5_HASH_LEN; i++) ND_PRINT((ndo, "%02x", pptr[i])); break; case AUTH_SHA1: case AUTH_MET_SHA1: /* * Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section Format * * 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 | Auth Key ID | Reserved | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Sequence Number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Auth Key/Hash... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ... | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (bfd_auth_header->auth_len != AUTH_SHA1_FIELD_LEN) { ND_PRINT((ndo, "[invalid length %d]", bfd_auth_header->auth_len)); break; } pptr += 2; ND_TCHECK2(*pptr, 4); ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr))); pptr += 4; ND_TCHECK2(*pptr, AUTH_SHA1_HASH_LEN); ND_PRINT((ndo, "\n\t Hash: ")); for(i = 0; i < AUTH_SHA1_HASH_LEN; i++) ND_PRINT((ndo, "%02x", pptr[i])); break; } return 0; trunc: return 1; } void bfd_print(netdissect_options *ndo, register const u_char *pptr, register u_int len, register u_int port) { - const struct bfd_header_t *bfd_header; - uint8_t version = 0; - - bfd_header = (const struct bfd_header_t *)pptr; if (port == BFD_CONTROL_PORT) { + /* + * Control packet. + */ + const struct bfd_header_t *bfd_header; + uint8_t version_diag; + uint8_t version = 0; + uint8_t flags; + + bfd_header = (const struct bfd_header_t *)pptr; ND_TCHECK(*bfd_header); - version = BFD_EXTRACT_VERSION(bfd_header->version_diag); - } else if (port == BFD_ECHO_PORT) { - /* Echo is BFD v1 only */ - version = 1; - } - switch ((port << 8) | version) { + version_diag = bfd_header->version_diag; + version = BFD_EXTRACT_VERSION(version_diag); + flags = bfd_header->flags; - /* BFDv0 */ - case (BFD_CONTROL_PORT << 8): - if (ndo->ndo_vflag < 1) - { - ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u", - version, - tok2str(bfd_port_values, "unknown (%u)", port), - bittok2str(bfd_v0_flag_values, "none", bfd_header->flags), - len)); - return; - } + switch (version) { - ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)", - version, - len, - tok2str(bfd_port_values, "unknown (%u)", port), - 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))); + /* BFDv0 */ + case 0: + if (ndo->ndo_vflag < 1) + { + ND_PRINT((ndo, "BFDv0, Control, Flags: [%s], length: %u", + bittok2str(bfd_v0_flag_values, "none", flags), + len)); + return; + } - ND_PRINT((ndo, "\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)); + ND_PRINT((ndo, "BFDv0, length: %u\n\tControl, Flags: [%s], Diagnostic: %s (0x%02x)", + len, + bittok2str(bfd_v0_flag_values, "none", flags), + tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)), + BFD_EXTRACT_DIAG(version_diag))); + ND_PRINT((ndo, "\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)); - ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator))); - ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator))); - ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000)); - ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000)); - ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000)); - break; - /* BFDv1 */ - case (BFD_CONTROL_PORT << 8 | 1): - if (ndo->ndo_vflag < 1) - { - ND_PRINT((ndo, "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) >> 6), - bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f), - len)); - return; - } + ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator))); + ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator))); + ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000)); + ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000)); + ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000)); - ND_PRINT((ndo, "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))); + if (flags & BFD_FLAG_AUTH) { + if (auth_print(ndo, pptr)) + goto trunc; + } + break; - ND_PRINT((ndo, "\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)); + /* BFDv1 */ + case 1: + if (ndo->ndo_vflag < 1) + { + ND_PRINT((ndo, "BFDv1, Control, State %s, Flags: [%s], length: %u", + tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6), + bittok2str(bfd_v1_flag_values, "none", flags & 0x3f), + len)); + return; + } + ND_PRINT((ndo, "BFDv1, length: %u\n\tControl, State %s, Flags: [%s], Diagnostic: %s (0x%02x)", + len, + tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6), + bittok2str(bfd_v1_flag_values, "none", flags & 0x3f), + tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)), + BFD_EXTRACT_DIAG(version_diag))); - ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator))); - ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator))); - ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000)); - ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000)); - ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000)); + ND_PRINT((ndo, "\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)); - if (bfd_header->flags & BFD_FLAG_AUTH) { - if (auth_print(ndo, pptr)) - goto trunc; - } - break; - /* BFDv0 */ - case (BFD_ECHO_PORT << 8): /* not yet supported - fall through */ - /* BFDv1 */ - case (BFD_ECHO_PORT << 8 | 1): + ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator))); + ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator))); + ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000)); + ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000)); + ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000)); - default: - ND_PRINT((ndo, "BFD, %s, length: %u", - tok2str(bfd_port_values, "unknown (%u)", port), + if (flags & BFD_FLAG_AUTH) { + if (auth_print(ndo, pptr)) + goto trunc; + } + break; + + default: + ND_PRINT((ndo, "BFDv%u, Control, length: %u", + version, + len)); + if (ndo->ndo_vflag >= 1) { + if(!print_unknown_data(ndo, pptr,"\n\t",len)) + return; + } + break; + } + } else if (port == BFD_ECHO_PORT) { + /* + * Echo packet. + */ + ND_PRINT((ndo, "BFD, Echo, length: %u", len)); if (ndo->ndo_vflag >= 1) { + if(!print_unknown_data(ndo, pptr,"\n\t",len)) + return; + } + } else { + /* + * Unknown packet type. + */ + ND_PRINT((ndo, "BFD, unknown (%u), length: %u", + port, + len)); + if (ndo->ndo_vflag >= 1) { if(!print_unknown_data(ndo, pptr,"\n\t",len)) return; } - break; } return; trunc: ND_PRINT((ndo, "[|BFD]")); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-bgp.c =================================================================== --- vendor/tcpdump/dist/print-bgp.c (revision 353143) +++ vendor/tcpdump/dist/print-bgp.c (revision 353144) @@ -1,2861 +1,2878 @@ /* * Copyright (C) 1999 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Extensively modified by Hannes Gredler (hannes@gredler.at) for more * complete BGP support. */ /* \summary: Border Gateway Protocol (BGP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "af.h" #include "l2vpn.h" +static const char tstr[] = "[|BGP]"; + struct bgp { uint8_t bgp_marker[16]; uint16_t bgp_len; uint8_t bgp_type; }; #define BGP_SIZE 19 /* unaligned */ #define BGP_OPEN 1 #define BGP_UPDATE 2 #define BGP_NOTIFICATION 3 #define BGP_KEEPALIVE 4 #define BGP_ROUTE_REFRESH 5 static const struct tok bgp_msg_values[] = { { BGP_OPEN, "Open"}, { BGP_UPDATE, "Update"}, { BGP_NOTIFICATION, "Notification"}, { BGP_KEEPALIVE, "Keepalive"}, { BGP_ROUTE_REFRESH, "Route Refresh"}, { 0, NULL} }; struct bgp_open { uint8_t bgpo_marker[16]; uint16_t bgpo_len; uint8_t bgpo_type; uint8_t bgpo_version; uint16_t bgpo_myas; uint16_t bgpo_holdtime; uint32_t bgpo_id; uint8_t bgpo_optlen; /* options should follow */ }; #define BGP_OPEN_SIZE 29 /* unaligned */ struct bgp_opt { uint8_t bgpopt_type; uint8_t bgpopt_len; /* variable length */ }; #define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */ #define BGP_CAP_HEADER_SIZE 2 /* some compilers may pad to 4 bytes */ struct bgp_notification { uint8_t bgpn_marker[16]; uint16_t bgpn_len; uint8_t bgpn_type; uint8_t bgpn_major; uint8_t bgpn_minor; }; #define BGP_NOTIFICATION_SIZE 21 /* unaligned */ struct bgp_route_refresh { uint8_t bgp_marker[16]; uint16_t len; uint8_t type; uint8_t afi[2]; /* the compiler messes this structure up */ uint8_t res; /* when doing misaligned sequences of int8 and int16 */ uint8_t safi; /* afi should be int16 - so we have to access it using */ }; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */ #define BGP_ROUTE_REFRESH_SIZE 23 #define bgp_attr_lenlen(flags, p) \ (((flags) & 0x10) ? 2 : 1) #define bgp_attr_len(flags, p) \ (((flags) & 0x10) ? EXTRACT_16BITS(p) : *(p)) #define BGPTYPE_ORIGIN 1 #define BGPTYPE_AS_PATH 2 #define BGPTYPE_NEXT_HOP 3 #define BGPTYPE_MULTI_EXIT_DISC 4 #define BGPTYPE_LOCAL_PREF 5 #define BGPTYPE_ATOMIC_AGGREGATE 6 #define BGPTYPE_AGGREGATOR 7 #define BGPTYPE_COMMUNITIES 8 /* RFC1997 */ #define BGPTYPE_ORIGINATOR_ID 9 /* RFC4456 */ #define BGPTYPE_CLUSTER_LIST 10 /* RFC4456 */ #define BGPTYPE_DPA 11 /* deprecated, draft-ietf-idr-bgp-dpa */ #define BGPTYPE_ADVERTISERS 12 /* deprecated RFC1863 */ #define BGPTYPE_RCID_PATH 13 /* deprecated RFC1863 */ #define BGPTYPE_MP_REACH_NLRI 14 /* RFC4760 */ #define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC4760 */ #define BGPTYPE_EXTD_COMMUNITIES 16 /* RFC4360 */ #define BGPTYPE_AS4_PATH 17 /* RFC6793 */ #define BGPTYPE_AGGREGATOR4 18 /* RFC6793 */ #define BGPTYPE_PMSI_TUNNEL 22 /* RFC6514 */ #define BGPTYPE_TUNNEL_ENCAP 23 /* RFC5512 */ #define BGPTYPE_TRAFFIC_ENG 24 /* RFC5543 */ #define BGPTYPE_IPV6_EXTD_COMMUNITIES 25 /* RFC5701 */ #define BGPTYPE_AIGP 26 /* RFC7311 */ #define BGPTYPE_PE_DISTINGUISHER_LABEL 27 /* RFC6514 */ #define BGPTYPE_ENTROPY_LABEL 28 /* RFC6790 */ #define BGPTYPE_LARGE_COMMUNITY 32 /* draft-ietf-idr-large-community-05 */ #define BGPTYPE_ATTR_SET 128 /* RFC6368 */ #define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */ static const struct tok bgp_attr_values[] = { { BGPTYPE_ORIGIN, "Origin"}, { BGPTYPE_AS_PATH, "AS Path"}, { BGPTYPE_AS4_PATH, "AS4 Path"}, { BGPTYPE_NEXT_HOP, "Next Hop"}, { BGPTYPE_MULTI_EXIT_DISC, "Multi Exit Discriminator"}, { BGPTYPE_LOCAL_PREF, "Local Preference"}, { BGPTYPE_ATOMIC_AGGREGATE, "Atomic Aggregate"}, { BGPTYPE_AGGREGATOR, "Aggregator"}, { BGPTYPE_AGGREGATOR4, "Aggregator4"}, { BGPTYPE_COMMUNITIES, "Community"}, { BGPTYPE_ORIGINATOR_ID, "Originator ID"}, { BGPTYPE_CLUSTER_LIST, "Cluster List"}, { BGPTYPE_DPA, "DPA"}, { BGPTYPE_ADVERTISERS, "Advertisers"}, { BGPTYPE_RCID_PATH, "RCID Path / Cluster ID"}, { BGPTYPE_MP_REACH_NLRI, "Multi-Protocol Reach NLRI"}, { BGPTYPE_MP_UNREACH_NLRI, "Multi-Protocol Unreach NLRI"}, { BGPTYPE_EXTD_COMMUNITIES, "Extended Community"}, { BGPTYPE_PMSI_TUNNEL, "PMSI Tunnel"}, { BGPTYPE_TUNNEL_ENCAP, "Tunnel Encapsulation"}, { BGPTYPE_TRAFFIC_ENG, "Traffic Engineering"}, { BGPTYPE_IPV6_EXTD_COMMUNITIES, "IPv6 Extended Community"}, { BGPTYPE_AIGP, "Accumulated IGP Metric"}, { BGPTYPE_PE_DISTINGUISHER_LABEL, "PE Distinguisher Label"}, { BGPTYPE_ENTROPY_LABEL, "Entropy Label"}, { BGPTYPE_LARGE_COMMUNITY, "Large Community"}, { BGPTYPE_ATTR_SET, "Attribute Set"}, { 255, "Reserved for development"}, { 0, NULL} }; #define BGP_AS_SET 1 #define BGP_AS_SEQUENCE 2 #define BGP_CONFED_AS_SEQUENCE 3 /* draft-ietf-idr-rfc3065bis-01 */ #define BGP_CONFED_AS_SET 4 /* draft-ietf-idr-rfc3065bis-01 */ #define BGP_AS_SEG_TYPE_MIN BGP_AS_SET #define BGP_AS_SEG_TYPE_MAX BGP_CONFED_AS_SET static const struct tok bgp_as_path_segment_open_values[] = { { BGP_AS_SEQUENCE, ""}, { BGP_AS_SET, "{ "}, { BGP_CONFED_AS_SEQUENCE, "( "}, { BGP_CONFED_AS_SET, "({ "}, { 0, NULL} }; static const struct tok bgp_as_path_segment_close_values[] = { { BGP_AS_SEQUENCE, ""}, { BGP_AS_SET, "}"}, { BGP_CONFED_AS_SEQUENCE, ")"}, { BGP_CONFED_AS_SET, "})"}, { 0, NULL} }; #define BGP_OPT_AUTH 1 #define BGP_OPT_CAP 2 static const struct tok bgp_opt_values[] = { { BGP_OPT_AUTH, "Authentication Information"}, { BGP_OPT_CAP, "Capabilities Advertisement"}, { 0, NULL} }; #define BGP_CAPCODE_MP 1 /* RFC2858 */ #define BGP_CAPCODE_RR 2 /* RFC2918 */ #define BGP_CAPCODE_ORF 3 /* RFC5291 */ #define BGP_CAPCODE_MR 4 /* RFC3107 */ #define BGP_CAPCODE_EXT_NH 5 /* RFC5549 */ #define BGP_CAPCODE_RESTART 64 /* RFC4724 */ #define BGP_CAPCODE_AS_NEW 65 /* RFC6793 */ #define BGP_CAPCODE_DYN_CAP 67 /* draft-ietf-idr-dynamic-cap */ #define BGP_CAPCODE_MULTISESS 68 /* draft-ietf-idr-bgp-multisession */ #define BGP_CAPCODE_ADD_PATH 69 /* RFC7911 */ #define BGP_CAPCODE_ENH_RR 70 /* draft-keyur-bgp-enhanced-route-refresh */ #define BGP_CAPCODE_RR_CISCO 128 static const struct tok bgp_capcode_values[] = { { BGP_CAPCODE_MP, "Multiprotocol Extensions"}, { BGP_CAPCODE_RR, "Route Refresh"}, { BGP_CAPCODE_ORF, "Cooperative Route Filtering"}, { BGP_CAPCODE_MR, "Multiple Routes to a Destination"}, { BGP_CAPCODE_EXT_NH, "Extended Next Hop Encoding"}, { BGP_CAPCODE_RESTART, "Graceful Restart"}, { BGP_CAPCODE_AS_NEW, "32-Bit AS Number"}, { BGP_CAPCODE_DYN_CAP, "Dynamic Capability"}, { BGP_CAPCODE_MULTISESS, "Multisession BGP"}, { BGP_CAPCODE_ADD_PATH, "Multiple Paths"}, { BGP_CAPCODE_ENH_RR, "Enhanced Route Refresh"}, { BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"}, { 0, NULL} }; #define BGP_NOTIFY_MAJOR_MSG 1 #define BGP_NOTIFY_MAJOR_OPEN 2 #define BGP_NOTIFY_MAJOR_UPDATE 3 #define BGP_NOTIFY_MAJOR_HOLDTIME 4 #define BGP_NOTIFY_MAJOR_FSM 5 #define BGP_NOTIFY_MAJOR_CEASE 6 #define BGP_NOTIFY_MAJOR_CAP 7 static const struct tok bgp_notify_major_values[] = { { BGP_NOTIFY_MAJOR_MSG, "Message Header Error"}, { BGP_NOTIFY_MAJOR_OPEN, "OPEN Message Error"}, { BGP_NOTIFY_MAJOR_UPDATE, "UPDATE Message Error"}, { BGP_NOTIFY_MAJOR_HOLDTIME,"Hold Timer Expired"}, { BGP_NOTIFY_MAJOR_FSM, "Finite State Machine Error"}, { BGP_NOTIFY_MAJOR_CEASE, "Cease"}, { BGP_NOTIFY_MAJOR_CAP, "Capability Message Error"}, { 0, NULL} }; /* draft-ietf-idr-cease-subcode-02 */ #define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1 static const struct tok bgp_notify_minor_cease_values[] = { { BGP_NOTIFY_MINOR_CEASE_MAXPRFX, "Maximum Number of Prefixes Reached"}, { 2, "Administratively Shutdown"}, { 3, "Peer Unconfigured"}, { 4, "Administratively Reset"}, { 5, "Connection Rejected"}, { 6, "Other Configuration Change"}, { 7, "Connection Collision Resolution"}, { 0, NULL} }; static const struct tok bgp_notify_minor_msg_values[] = { { 1, "Connection Not Synchronized"}, { 2, "Bad Message Length"}, { 3, "Bad Message Type"}, { 0, NULL} }; static const struct tok bgp_notify_minor_open_values[] = { { 1, "Unsupported Version Number"}, { 2, "Bad Peer AS"}, { 3, "Bad BGP Identifier"}, { 4, "Unsupported Optional Parameter"}, { 5, "Authentication Failure"}, { 6, "Unacceptable Hold Time"}, { 7, "Capability Message Error"}, { 0, NULL} }; static const struct tok bgp_notify_minor_update_values[] = { { 1, "Malformed Attribute List"}, { 2, "Unrecognized Well-known Attribute"}, { 3, "Missing Well-known Attribute"}, { 4, "Attribute Flags Error"}, { 5, "Attribute Length Error"}, { 6, "Invalid ORIGIN Attribute"}, { 7, "AS Routing Loop"}, { 8, "Invalid NEXT_HOP Attribute"}, { 9, "Optional Attribute Error"}, { 10, "Invalid Network Field"}, { 11, "Malformed AS_PATH"}, { 0, NULL} }; static const struct tok bgp_notify_minor_fsm_values[] = { { 1, "In OpenSent State"}, { 2, "In OpenConfirm State"}, { 3, "In Established State"}, { 0, NULL } }; static const struct tok bgp_notify_minor_cap_values[] = { { 1, "Invalid Action Value" }, { 2, "Invalid Capability Length" }, { 3, "Malformed Capability Value" }, { 4, "Unsupported Capability Code" }, { 0, NULL } }; static const struct tok bgp_origin_values[] = { { 0, "IGP"}, { 1, "EGP"}, { 2, "Incomplete"}, { 0, NULL} }; #define BGP_PMSI_TUNNEL_RSVP_P2MP 1 #define BGP_PMSI_TUNNEL_LDP_P2MP 2 #define BGP_PMSI_TUNNEL_PIM_SSM 3 #define BGP_PMSI_TUNNEL_PIM_SM 4 #define BGP_PMSI_TUNNEL_PIM_BIDIR 5 #define BGP_PMSI_TUNNEL_INGRESS 6 #define BGP_PMSI_TUNNEL_LDP_MP2MP 7 static const struct tok bgp_pmsi_tunnel_values[] = { { BGP_PMSI_TUNNEL_RSVP_P2MP, "RSVP-TE P2MP LSP"}, { BGP_PMSI_TUNNEL_LDP_P2MP, "LDP P2MP LSP"}, { BGP_PMSI_TUNNEL_PIM_SSM, "PIM-SSM Tree"}, { BGP_PMSI_TUNNEL_PIM_SM, "PIM-SM Tree"}, { BGP_PMSI_TUNNEL_PIM_BIDIR, "PIM-Bidir Tree"}, { BGP_PMSI_TUNNEL_INGRESS, "Ingress Replication"}, { BGP_PMSI_TUNNEL_LDP_MP2MP, "LDP MP2MP LSP"}, { 0, NULL} }; static const struct tok bgp_pmsi_flag_values[] = { { 0x01, "Leaf Information required"}, { 0, NULL} }; #define BGP_AIGP_TLV 1 static const struct tok bgp_aigp_values[] = { { BGP_AIGP_TLV, "AIGP"}, { 0, NULL} }; /* Subsequent address family identifier, RFC2283 section 7 */ #define SAFNUM_RES 0 #define SAFNUM_UNICAST 1 #define SAFNUM_MULTICAST 2 #define SAFNUM_UNIMULTICAST 3 /* deprecated now */ /* labeled BGP RFC3107 */ #define SAFNUM_LABUNICAST 4 /* RFC6514 */ #define SAFNUM_MULTICAST_VPN 5 /* draft-nalawade-kapoor-tunnel-safi */ #define SAFNUM_TUNNEL 64 /* RFC4761 */ #define SAFNUM_VPLS 65 /* RFC6037 */ #define SAFNUM_MDT 66 /* RFC4364 */ #define SAFNUM_VPNUNICAST 128 /* RFC6513 */ #define SAFNUM_VPNMULTICAST 129 #define SAFNUM_VPNUNIMULTICAST 130 /* deprecated now */ /* RFC4684 */ #define SAFNUM_RT_ROUTING_INFO 132 #define BGP_VPN_RD_LEN 8 static const struct tok bgp_safi_values[] = { { SAFNUM_RES, "Reserved"}, { SAFNUM_UNICAST, "Unicast"}, { SAFNUM_MULTICAST, "Multicast"}, { SAFNUM_UNIMULTICAST, "Unicast+Multicast"}, { SAFNUM_LABUNICAST, "labeled Unicast"}, { SAFNUM_TUNNEL, "Tunnel"}, { SAFNUM_VPLS, "VPLS"}, { SAFNUM_MDT, "MDT"}, { SAFNUM_VPNUNICAST, "labeled VPN Unicast"}, { SAFNUM_VPNMULTICAST, "labeled VPN Multicast"}, { SAFNUM_VPNUNIMULTICAST, "labeled VPN Unicast+Multicast"}, { SAFNUM_RT_ROUTING_INFO, "Route Target Routing Information"}, { SAFNUM_MULTICAST_VPN, "Multicast VPN"}, { 0, NULL } }; /* well-known community */ #define BGP_COMMUNITY_NO_EXPORT 0xffffff01 #define BGP_COMMUNITY_NO_ADVERT 0xffffff02 #define BGP_COMMUNITY_NO_EXPORT_SUBCONFED 0xffffff03 /* Extended community type - draft-ietf-idr-bgp-ext-communities-05 */ #define BGP_EXT_COM_RT_0 0x0002 /* Route Target,Format AS(2bytes):AN(4bytes) */ #define BGP_EXT_COM_RT_1 0x0102 /* Route Target,Format IP address:AN(2bytes) */ #define BGP_EXT_COM_RT_2 0x0202 /* Route Target,Format AN(4bytes):local(2bytes) */ #define BGP_EXT_COM_RO_0 0x0003 /* Route Origin,Format AS(2bytes):AN(4bytes) */ #define BGP_EXT_COM_RO_1 0x0103 /* Route Origin,Format IP address:AN(2bytes) */ #define BGP_EXT_COM_RO_2 0x0203 /* Route Origin,Format AN(4bytes):local(2bytes) */ #define BGP_EXT_COM_LINKBAND 0x4004 /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */ /* rfc2547 bgp-mpls-vpns */ #define BGP_EXT_COM_VPN_ORIGIN 0x0005 /* OSPF Domain ID / VPN of Origin - draft-rosen-vpns-ospf-bgp-mpls */ #define BGP_EXT_COM_VPN_ORIGIN2 0x0105 /* duplicate - keep for backwards compatability */ #define BGP_EXT_COM_VPN_ORIGIN3 0x0205 /* duplicate - keep for backwards compatability */ #define BGP_EXT_COM_VPN_ORIGIN4 0x8005 /* duplicate - keep for backwards compatability */ #define BGP_EXT_COM_OSPF_RTYPE 0x0306 /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */ #define BGP_EXT_COM_OSPF_RTYPE2 0x8000 /* duplicate - keep for backwards compatability */ #define BGP_EXT_COM_OSPF_RID 0x0107 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */ #define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */ #define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */ #define BGP_EXT_COM_SOURCE_AS 0x0009 /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */ #define BGP_EXT_COM_VRF_RT_IMP 0x010b /* RFC-ietf-l3vpn-2547bis-mcast-bgp-08.txt */ #define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */ #define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */ /* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */ #define BGP_EXT_COM_EIGRP_GEN 0x8800 #define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY 0x8801 #define BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW 0x8802 #define BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU 0x8803 #define BGP_EXT_COM_EIGRP_EXT_REMAS_REMID 0x8804 #define BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC 0x8805 static const struct tok bgp_extd_comm_flag_values[] = { { 0x8000, "vendor-specific"}, { 0x4000, "non-transitive"}, { 0, NULL}, }; static const struct tok bgp_extd_comm_subtype_values[] = { { BGP_EXT_COM_RT_0, "target"}, { BGP_EXT_COM_RT_1, "target"}, { BGP_EXT_COM_RT_2, "target"}, { BGP_EXT_COM_RO_0, "origin"}, { BGP_EXT_COM_RO_1, "origin"}, { BGP_EXT_COM_RO_2, "origin"}, { BGP_EXT_COM_LINKBAND, "link-BW"}, { BGP_EXT_COM_VPN_ORIGIN, "ospf-domain"}, { BGP_EXT_COM_VPN_ORIGIN2, "ospf-domain"}, { BGP_EXT_COM_VPN_ORIGIN3, "ospf-domain"}, { BGP_EXT_COM_VPN_ORIGIN4, "ospf-domain"}, { BGP_EXT_COM_OSPF_RTYPE, "ospf-route-type"}, { BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"}, { BGP_EXT_COM_OSPF_RID, "ospf-router-id"}, { BGP_EXT_COM_OSPF_RID2, "ospf-router-id"}, { BGP_EXT_COM_L2INFO, "layer2-info"}, { BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" }, { BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" }, { BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" }, { BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU , "eigrp-route-metric (load, MTU)" }, { BGP_EXT_COM_EIGRP_EXT_REMAS_REMID , "eigrp-external-route (remote-AS, remote-ID)" }, { BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC , "eigrp-external-route (remote-proto, remote-metric)" }, { BGP_EXT_COM_SOURCE_AS, "source-AS" }, { BGP_EXT_COM_VRF_RT_IMP, "vrf-route-import"}, { BGP_EXT_COM_L2VPN_RT_0, "l2vpn-id"}, { BGP_EXT_COM_L2VPN_RT_1, "l2vpn-id"}, { 0, NULL}, }; /* OSPF codes for BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls */ #define BGP_OSPF_RTYPE_RTR 1 /* OSPF Router LSA */ #define BGP_OSPF_RTYPE_NET 2 /* OSPF Network LSA */ #define BGP_OSPF_RTYPE_SUM 3 /* OSPF Summary LSA */ #define BGP_OSPF_RTYPE_EXT 5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */ #define BGP_OSPF_RTYPE_NSSA 7 /* OSPF NSSA External*/ #define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */ #define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */ static const struct tok bgp_extd_comm_ospf_rtype_values[] = { { BGP_OSPF_RTYPE_RTR, "Router" }, { BGP_OSPF_RTYPE_NET, "Network" }, { BGP_OSPF_RTYPE_SUM, "Summary" }, { BGP_OSPF_RTYPE_EXT, "External" }, { BGP_OSPF_RTYPE_NSSA,"NSSA External" }, { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" }, { 0, NULL }, }; /* ADD-PATH Send/Receive field values */ static const struct tok bgp_add_path_recvsend[] = { { 1, "Receive" }, { 2, "Send" }, { 3, "Both" }, { 0, NULL }, }; static char astostr[20]; /* * as_printf * * Convert an AS number into a string and return string pointer. * * Depending on bflag is set or not, AS number is converted into ASDOT notation * or plain number notation. * */ static char * as_printf(netdissect_options *ndo, char *str, int size, u_int asnum) { if (!ndo->ndo_bflag || asnum <= 0xFFFF) { snprintf(str, size, "%u", asnum); } else { snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF); } return str; } #define ITEMCHECK(minlen) if (itemlen < minlen) goto badtlv; int decode_prefix4(netdissect_options *ndo, const u_char *pptr, u_int itemlen, char *buf, u_int buflen) { struct in_addr addr; u_int plen, plenbytes; ND_TCHECK(pptr[0]); ITEMCHECK(1); plen = pptr[0]; if (32 < plen) return -1; itemlen -= 1; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; ND_TCHECK2(pptr[1], plenbytes); ITEMCHECK(plenbytes); memcpy(&addr, &pptr[1], plenbytes); if (plen % 8) { ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "%s/%d", ipaddr_string(ndo, &addr), plen); return 1 + plenbytes; trunc: return -2; badtlv: return -3; } static int decode_labeled_prefix4(netdissect_options *ndo, const u_char *pptr, u_int itemlen, char *buf, u_int buflen) { struct in_addr addr; u_int plen, plenbytes; /* prefix length and label = 4 bytes */ ND_TCHECK2(pptr[0], 4); ITEMCHECK(4); plen = pptr[0]; /* get prefix length */ /* this is one of the weirdnesses of rfc3107 the label length (actually the label + COS bits) is added to the prefix length; we also do only read out just one label - there is no real application for advertisement of stacked labels in a single BGP message */ if (24 > plen) return -1; plen-=24; /* adjust prefixlen - labellength */ if (32 < plen) return -1; itemlen -= 4; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; ND_TCHECK2(pptr[4], plenbytes); ITEMCHECK(plenbytes); memcpy(&addr, &pptr[4], plenbytes); if (plen % 8) { ((u_char *)&addr)[plenbytes - 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", ipaddr_string(ndo, &addr), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); return 4 + plenbytes; trunc: return -2; badtlv: return -3; } /* * bgp_vpn_ip_print * * print an ipv4 or ipv6 address into a buffer dependend on address length. */ static char * bgp_vpn_ip_print(netdissect_options *ndo, const u_char *pptr, u_int addr_length) { /* worst case string is s fully formatted v6 address */ static char addr[sizeof("1234:5678:89ab:cdef:1234:5678:89ab:cdef")]; char *pos = addr; switch(addr_length) { case (sizeof(struct in_addr) << 3): /* 32 */ ND_TCHECK2(pptr[0], sizeof(struct in_addr)); snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr)); break; case (sizeof(struct in6_addr) << 3): /* 128 */ ND_TCHECK2(pptr[0], sizeof(struct in6_addr)); snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr)); break; default: snprintf(pos, sizeof(addr), "bogus address length %u", addr_length); break; } pos += strlen(pos); trunc: *(pos) = '\0'; return (addr); } /* * bgp_vpn_sg_print * * print an multicast s,g entry into a buffer. * the s,g entry is encoded like this. * * +-----------------------------------+ * | Multicast Source Length (1 octet) | * +-----------------------------------+ * | Multicast Source (Variable) | * +-----------------------------------+ * | Multicast Group Length (1 octet) | * +-----------------------------------+ * | Multicast Group (Variable) | * +-----------------------------------+ * * return the number of bytes read from the wire. */ static int bgp_vpn_sg_print(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { uint8_t addr_length; u_int total_length, offset; total_length = 0; /* Source address length, encoded in bits */ ND_TCHECK2(pptr[0], 1); addr_length = *pptr++; /* Source address */ ND_TCHECK2(pptr[0], (addr_length >> 3)); total_length += (addr_length >> 3) + 1; offset = strlen(buf); if (addr_length) { snprintf(buf + offset, buflen - offset, ", Source %s", bgp_vpn_ip_print(ndo, pptr, addr_length)); pptr += (addr_length >> 3); } /* Group address length, encoded in bits */ ND_TCHECK2(pptr[0], 1); addr_length = *pptr++; /* Group address */ ND_TCHECK2(pptr[0], (addr_length >> 3)); total_length += (addr_length >> 3) + 1; offset = strlen(buf); if (addr_length) { snprintf(buf + offset, buflen - offset, ", Group %s", bgp_vpn_ip_print(ndo, pptr, addr_length)); pptr += (addr_length >> 3); } trunc: return (total_length); } /* RDs and RTs share the same semantics * we use bgp_vpn_rd_print for * printing route targets inside a NLRI */ char * bgp_vpn_rd_print(netdissect_options *ndo, const u_char *pptr) { /* allocate space for the largest possible string */ static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")]; char *pos = rd; /* ok lets load the RD format */ switch (EXTRACT_16BITS(pptr)) { /* 2-byte-AS:number fmt*/ case 0: snprintf(pos, sizeof(rd) - (pos - rd), "%u:%u (= %u.%u.%u.%u)", EXTRACT_16BITS(pptr+2), EXTRACT_32BITS(pptr+4), *(pptr+4), *(pptr+5), *(pptr+6), *(pptr+7)); break; /* IP-address:AS fmt*/ case 1: snprintf(pos, sizeof(rd) - (pos - rd), "%u.%u.%u.%u:%u", *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5), EXTRACT_16BITS(pptr+6)); break; /* 4-byte-AS:number fmt*/ case 2: snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)), EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4), *(pptr+5), EXTRACT_16BITS(pptr+6)); break; default: snprintf(pos, sizeof(rd) - (pos - rd), "unknown RD format"); break; } pos += strlen(pos); *(pos) = '\0'; return (rd); } static int decode_rt_routing_info(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { uint8_t route_target[8]; u_int plen; char asbuf[sizeof(astostr)]; /* bgp_vpn_rd_print() overwrites astostr */ /* NLRI "prefix length" from RFC 2858 Section 4. */ ND_TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ /* NLRI "prefix" (ibid), valid lengths are { 0, 32, 33, ..., 96 } bits. * RFC 4684 Section 4 defines the layout of "origin AS" and "route * target" fields inside the "prefix" depending on its length. */ if (0 == plen) { /* Without "origin AS", without "route target". */ snprintf(buf, buflen, "default route target"); return 1; } if (32 > plen) return -1; /* With at least "origin AS", possibly with "route target". */ ND_TCHECK_32BITS(pptr + 1); as_printf(ndo, asbuf, sizeof(asbuf), EXTRACT_32BITS(pptr + 1)); plen-=32; /* adjust prefix length */ if (64 < plen) return -1; /* From now on (plen + 7) / 8 evaluates to { 0, 1, 2, ..., 8 } * and gives the number of octets in the variable-length "route * target" field inside this NLRI "prefix". Look for it. */ memset(&route_target, 0, sizeof(route_target)); ND_TCHECK2(pptr[5], (plen + 7) / 8); memcpy(&route_target, &pptr[5], (plen + 7) / 8); /* Which specification says to do this? */ if (plen % 8) { ((u_char *)&route_target)[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "origin AS: %s, route target %s", asbuf, bgp_vpn_rd_print(ndo, (u_char *)&route_target)); return 5 + (plen + 7) / 8; trunc: return -2; } static int decode_labeled_vpn_prefix4(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { struct in_addr addr; u_int plen; ND_TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ if ((24+64) > plen) return -1; plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ if (32 < plen) return -1; memset(&addr, 0, sizeof(addr)); ND_TCHECK2(pptr[12], (plen + 7) / 8); memcpy(&addr, &pptr[12], (plen + 7) / 8); if (plen % 8) { ((u_char *)&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, "RD: %s, %s/%d, label:%u %s", bgp_vpn_rd_print(ndo, pptr+4), ipaddr_string(ndo, &addr), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); return 12 + (plen + 7) / 8; trunc: return -2; } /* * +-------------------------------+ * | | * | RD:IPv4-address (12 octets) | * | | * +-------------------------------+ * | MDT Group-address (4 octets) | * +-------------------------------+ */ #define MDT_VPN_NLRI_LEN 16 static int decode_mdt_vpn_nlri(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { const u_char *rd; const u_char *vpn_ip; ND_TCHECK(pptr[0]); /* if the NLRI is not predefined length, quit.*/ if (*pptr != MDT_VPN_NLRI_LEN * 8) return -1; pptr++; /* RD */ ND_TCHECK2(pptr[0], 8); rd = pptr; pptr+=8; /* IPv4 address */ ND_TCHECK2(pptr[0], sizeof(struct in_addr)); vpn_ip = pptr; pptr+=sizeof(struct in_addr); /* MDT Group Address */ ND_TCHECK2(pptr[0], sizeof(struct in_addr)); snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s", bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr)); return MDT_VPN_NLRI_LEN + 1; trunc: return -2; } #define BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI 1 #define BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI 2 #define BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI 3 #define BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF 4 #define BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE 5 #define BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN 6 #define BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN 7 static const struct tok bgp_multicast_vpn_route_type_values[] = { { BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI, "Intra-AS I-PMSI"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI, "Inter-AS I-PMSI"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI, "S-PMSI"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF, "Intra-AS Segment-Leaf"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE, "Source-Active"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN, "Shared Tree Join"}, { BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN, "Source Tree Join"}, { 0, NULL} }; static int decode_multicast_vpn(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { uint8_t route_type, route_length, addr_length, sg_length; u_int offset; ND_TCHECK2(pptr[0], 2); route_type = *pptr++; route_length = *pptr++; snprintf(buf, buflen, "Route-Type: %s (%u), length: %u", tok2str(bgp_multicast_vpn_route_type_values, "Unknown", route_type), route_type, route_length); switch(route_type) { case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI: ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s", bgp_vpn_rd_print(ndo, pptr), bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN, (route_length - BGP_VPN_RD_LEN) << 3)); break; case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI: ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", bgp_vpn_rd_print(ndo, pptr), as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); break; case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI: ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", RD: %s", bgp_vpn_rd_print(ndo, pptr)); pptr += BGP_VPN_RD_LEN; sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen); addr_length = route_length - sg_length; ND_TCHECK2(pptr[0], addr_length); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", Originator %s", bgp_vpn_ip_print(ndo, pptr, addr_length << 3)); break; case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE: ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", RD: %s", bgp_vpn_rd_print(ndo, pptr)); pptr += BGP_VPN_RD_LEN; bgp_vpn_sg_print(ndo, pptr, buf, buflen); break; case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */ case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN: ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4); offset = strlen(buf); snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s", bgp_vpn_rd_print(ndo, pptr), as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN))); pptr += BGP_VPN_RD_LEN + 4; bgp_vpn_sg_print(ndo, pptr, buf, buflen); break; /* * no per route-type printing yet. */ case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_SEG_LEAF: default: break; } return route_length + 2; trunc: return -2; } /* * As I remember, some versions of systems have an snprintf() that * returns -1 if the buffer would have overflowed. If the return * value is negative, set buflen to 0, to indicate that we've filled * the buffer up. * * If the return value is greater than buflen, that means that * the buffer would have overflowed; again, set buflen to 0 in * that case. */ #define UPDATE_BUF_BUFLEN(buf, buflen, stringlen) \ if (stringlen<0) \ - buflen=0; \ + buflen=0; \ else if ((u_int)stringlen>buflen) \ buflen=0; \ else { \ buflen-=stringlen; \ buf+=stringlen; \ } static int decode_labeled_vpn_l2(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len; ND_TCHECK2(pptr[0], 2); plen=EXTRACT_16BITS(pptr); tlen=plen; pptr+=2; /* Old and new L2VPN NLRI share AFI/SAFI * -> Assume a 12 Byte-length NLRI is auto-discovery-only * and > 17 as old format. Complain for the middle case */ if (plen==12) { /* assume AD-only with RD, BGPNH */ ND_TCHECK2(pptr[0],12); buf[0]='\0'; stringlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s", bgp_vpn_rd_print(ndo, pptr), ipaddr_string(ndo, pptr+8) ); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); pptr+=12; tlen-=12; return plen; } else if (plen>17) { /* assume old format */ /* RD, ID, LBLKOFF, LBLBASE */ ND_TCHECK2(pptr[0],15); buf[0]='\0'; stringlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u", bgp_vpn_rd_print(ndo, pptr), EXTRACT_16BITS(pptr+8), EXTRACT_16BITS(pptr+10), EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */ UPDATE_BUF_BUFLEN(buf, buflen, stringlen); pptr+=15; tlen-=15; /* ok now the variable part - lets read out TLVs*/ while (tlen>0) { if (tlen < 3) return -1; ND_TCHECK2(pptr[0], 3); tlv_type=*pptr++; tlv_len=EXTRACT_16BITS(pptr); ttlv_len=tlv_len; pptr+=2; switch(tlv_type) { case 1: if (buflen!=0) { stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x", tlv_type, tlv_len); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */ while (ttlv_len>0) { ND_TCHECK(pptr[0]); if (buflen!=0) { stringlen=snprintf(buf,buflen, "%02x",*pptr++); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } ttlv_len--; } break; default: if (buflen!=0) { stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u", tlv_type, tlv_len); UPDATE_BUF_BUFLEN(buf, buflen, stringlen); } break; } tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */ } return plen+2; } else { /* complain bitterly ? */ /* fall through */ goto trunc; } trunc: return -2; } int decode_prefix6(netdissect_options *ndo, const u_char *pd, u_int itemlen, char *buf, u_int buflen) { struct in6_addr addr; u_int plen, plenbytes; ND_TCHECK(pd[0]); ITEMCHECK(1); plen = pd[0]; if (128 < plen) return -1; itemlen -= 1; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; ND_TCHECK2(pd[1], plenbytes); ITEMCHECK(plenbytes); memcpy(&addr, &pd[1], plenbytes); if (plen % 8) { addr.s6_addr[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen); return 1 + plenbytes; trunc: return -2; badtlv: return -3; } static int decode_labeled_prefix6(netdissect_options *ndo, const u_char *pptr, u_int itemlen, char *buf, u_int buflen) { struct in6_addr addr; u_int plen, plenbytes; /* prefix length and label = 4 bytes */ ND_TCHECK2(pptr[0], 4); ITEMCHECK(4); plen = pptr[0]; /* get prefix length */ if (24 > plen) return -1; plen-=24; /* adjust prefixlen - labellength */ if (128 < plen) return -1; itemlen -= 4; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; ND_TCHECK2(pptr[4], plenbytes); memcpy(&addr, &pptr[4], plenbytes); if (plen % 8) { addr.s6_addr[plenbytes - 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", ip6addr_string(ndo, &addr), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); return 4 + plenbytes; trunc: return -2; badtlv: return -3; } static int decode_labeled_vpn_prefix6(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { struct in6_addr addr; u_int plen; ND_TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ if ((24+64) > plen) return -1; plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ if (128 < plen) return -1; memset(&addr, 0, sizeof(addr)); ND_TCHECK2(pptr[12], (plen + 7) / 8); memcpy(&addr, &pptr[12], (plen + 7) / 8); if (plen % 8) { addr.s6_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, "RD: %s, %s/%d, label:%u %s", bgp_vpn_rd_print(ndo, pptr+4), ip6addr_string(ndo, &addr), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); return 12 + (plen + 7) / 8; trunc: return -2; } static int decode_clnp_prefix(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { uint8_t addr[19]; u_int plen; ND_TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ if (152 < plen) return -1; memset(&addr, 0, sizeof(addr)); ND_TCHECK2(pptr[4], (plen + 7) / 8); memcpy(&addr, &pptr[4], (plen + 7) / 8); if (plen % 8) { addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, buflen, "%s/%d", isonsap_string(ndo, addr,(plen + 7) / 8), plen); return 1 + (plen + 7) / 8; trunc: return -2; } static int decode_labeled_vpn_clnp_prefix(netdissect_options *ndo, const u_char *pptr, char *buf, u_int buflen) { uint8_t addr[19]; u_int plen; ND_TCHECK(pptr[0]); plen = pptr[0]; /* get prefix length */ if ((24+64) > plen) return -1; plen-=(24+64); /* adjust prefixlen - labellength - RD len*/ if (152 < plen) return -1; memset(&addr, 0, sizeof(addr)); ND_TCHECK2(pptr[12], (plen + 7) / 8); memcpy(&addr, &pptr[12], (plen + 7) / 8); if (plen % 8) { 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, "RD: %s, %s/%d, label:%u %s", bgp_vpn_rd_print(ndo, pptr+4), isonsap_string(ndo, addr,(plen + 7) / 8), plen, EXTRACT_24BITS(pptr+1)>>4, ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" ); return 12 + (plen + 7) / 8; trunc: return -2; } /* * bgp_attr_get_as_size * * Try to find the size of the ASs encoded in an as-path. It is not obvious, as * both Old speakers that do not support 4 byte AS, and the new speakers that do * support, exchange AS-Path with the same path-attribute type value 0x02. */ static int bgp_attr_get_as_size(netdissect_options *ndo, uint8_t bgpa_type, const u_char *pptr, int len) { const u_char *tptr = pptr; /* * If the path attribute is the optional AS4 path type, then we already * know, that ASs must be encoded in 4 byte format. */ if (bgpa_type == BGPTYPE_AS4_PATH) { return 4; } /* * Let us assume that ASs are of 2 bytes in size, and check if the AS-Path * TLV is good. If not, ask the caller to try with AS encoded as 4 bytes * each. */ while (tptr < pptr + len) { ND_TCHECK(tptr[0]); /* * If we do not find a valid segment type, our guess might be wrong. */ if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) { goto trunc; } ND_TCHECK(tptr[1]); tptr += 2 + tptr[1] * 2; } /* * If we correctly reached end of the AS path attribute data content, * then most likely ASs were indeed encoded as 2 bytes. */ if (tptr == pptr + len) { return 2; } trunc: /* * We can come here, either we did not have enough data, or if we * try to decode 4 byte ASs in 2 byte format. Either way, return 4, * so that calller can try to decode each AS as of 4 bytes. If indeed * there was not enough data, it will crib and end the parse anyways. */ return 4; } static int bgp_attr_print(netdissect_options *ndo, - u_int atype, const u_char *pptr, u_int len) + u_int atype, const u_char *pptr, u_int len, const unsigned attr_set_level) { int i; uint16_t af; uint8_t safi, snpa, nhlen; union { /* copy buffer for bandwidth values */ float f; uint32_t i; } bw; int advance; u_int tlen; const u_char *tptr; char buf[MAXHOSTNAMELEN + 100]; int as_size; tptr = pptr; tlen=len; switch (atype) { case BGPTYPE_ORIGIN: if (len != 1) ND_PRINT((ndo, "invalid len")); else { ND_TCHECK(*tptr); ND_PRINT((ndo, "%s", tok2str(bgp_origin_values, "Unknown Origin Typecode", tptr[0]))); } break; /* * Process AS4 byte path and AS2 byte path attributes here. */ case BGPTYPE_AS4_PATH: case BGPTYPE_AS_PATH: if (len % 2) { ND_PRINT((ndo, "invalid len")); break; } if (!len) { ND_PRINT((ndo, "empty")); break; } /* * BGP updates exchanged between New speakers that support 4 * byte AS, ASs are always encoded in 4 bytes. There is no * definitive way to find this, just by the packet's * contents. So, check for packet's TLV's sanity assuming * 2 bytes first, and it does not pass, assume that ASs are * encoded in 4 bytes format and move on. */ as_size = bgp_attr_get_as_size(ndo, atype, pptr, len); while (tptr < pptr + len) { ND_TCHECK(tptr[0]); ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_open_values, "?", tptr[0]))); ND_TCHECK(tptr[1]); for (i = 0; i < tptr[1] * as_size; i += as_size) { ND_TCHECK2(tptr[2 + i], as_size); ND_PRINT((ndo, "%s ", as_printf(ndo, astostr, sizeof(astostr), as_size == 2 ? EXTRACT_16BITS(&tptr[2 + i]) : EXTRACT_32BITS(&tptr[2 + i])))); } ND_TCHECK(tptr[0]); ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_close_values, "?", tptr[0]))); ND_TCHECK(tptr[1]); tptr += 2 + tptr[1] * as_size; } break; case BGPTYPE_NEXT_HOP: if (len != 4) ND_PRINT((ndo, "invalid len")); else { ND_TCHECK2(tptr[0], 4); ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr))); } break; case BGPTYPE_MULTI_EXIT_DISC: case BGPTYPE_LOCAL_PREF: if (len != 4) ND_PRINT((ndo, "invalid len")); else { ND_TCHECK2(tptr[0], 4); ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr))); } break; case BGPTYPE_ATOMIC_AGGREGATE: if (len != 0) ND_PRINT((ndo, "invalid len")); break; case BGPTYPE_AGGREGATOR: /* * Depending on the AS encoded is of 2 bytes or of 4 bytes, * the length of this PA can be either 6 bytes or 8 bytes. */ if (len != 6 && len != 8) { ND_PRINT((ndo, "invalid len")); break; } ND_TCHECK2(tptr[0], len); if (len == 6) { ND_PRINT((ndo, " AS #%s, origin %s", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)), ipaddr_string(ndo, tptr + 2))); } else { ND_PRINT((ndo, " AS #%s, origin %s", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); } break; case BGPTYPE_AGGREGATOR4: if (len != 8) { ND_PRINT((ndo, "invalid len")); break; } ND_TCHECK2(tptr[0], 8); ND_PRINT((ndo, " AS #%s, origin %s", - as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), + as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4))); break; case BGPTYPE_COMMUNITIES: if (len % 4) { ND_PRINT((ndo, "invalid len")); break; } while (tlen>0) { uint32_t comm; ND_TCHECK2(tptr[0], 4); comm = EXTRACT_32BITS(tptr); switch (comm) { case BGP_COMMUNITY_NO_EXPORT: ND_PRINT((ndo, " NO_EXPORT")); break; case BGP_COMMUNITY_NO_ADVERT: ND_PRINT((ndo, " NO_ADVERTISE")); break; case BGP_COMMUNITY_NO_EXPORT_SUBCONFED: ND_PRINT((ndo, " NO_EXPORT_SUBCONFED")); break; default: ND_PRINT((ndo, "%u:%u%s", (comm >> 16) & 0xffff, comm & 0xffff, (tlen>4) ? ", " : "")); break; } tlen -=4; tptr +=4; } break; case BGPTYPE_ORIGINATOR_ID: if (len != 4) { ND_PRINT((ndo, "invalid len")); break; } ND_TCHECK2(tptr[0], 4); ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr))); break; case BGPTYPE_CLUSTER_LIST: if (len % 4) { ND_PRINT((ndo, "invalid len")); break; } while (tlen>0) { ND_TCHECK2(tptr[0], 4); ND_PRINT((ndo, "%s%s", ipaddr_string(ndo, tptr), (tlen>4) ? ", " : "")); tlen -=4; tptr +=4; } break; case BGPTYPE_MP_REACH_NLRI: ND_TCHECK2(tptr[0], 3); af = EXTRACT_16BITS(tptr); safi = tptr[2]; ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)", tok2str(af_values, "Unknown AFI", af), af, (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ tok2str(bgp_safi_values, "Unknown SAFI", safi), safi)); switch(af<<8 | safi) { case (AFNUM_INET<<8 | SAFNUM_UNICAST): case (AFNUM_INET<<8 | SAFNUM_MULTICAST): case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): case (AFNUM_INET<<8 | SAFNUM_MDT): case (AFNUM_INET6<<8 | SAFNUM_UNICAST): case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): case (AFNUM_VPLS<<8 | SAFNUM_VPLS): break; default: ND_TCHECK2(tptr[0], tlen); ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", tlen); goto done; break; } tptr +=3; ND_TCHECK(tptr[0]); nhlen = tptr[0]; tlen = nhlen; tptr++; if (tlen) { int nnh = 0; ND_PRINT((ndo, "\n\t nexthop: ")); while (tlen > 0) { if ( nnh++ > 0 ) { ND_PRINT((ndo, ", " )); } switch(af<<8 | safi) { case (AFNUM_INET<<8 | SAFNUM_UNICAST): case (AFNUM_INET<<8 | SAFNUM_MULTICAST): case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): case (AFNUM_INET<<8 | SAFNUM_MDT): if (tlen < (int)sizeof(struct in_addr)) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], sizeof(struct in_addr)); ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr))); tlen -= sizeof(struct in_addr); tptr += sizeof(struct in_addr); } break; case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN); ND_PRINT((ndo, "RD: %s, %s", bgp_vpn_rd_print(ndo, tptr), ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN))); tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN); tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN); } break; case (AFNUM_INET6<<8 | SAFNUM_UNICAST): case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): if (tlen < (int)sizeof(struct in6_addr)) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], sizeof(struct in6_addr)); ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr))); tlen -= sizeof(struct in6_addr); tptr += sizeof(struct in6_addr); } break; case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN); ND_PRINT((ndo, "RD: %s, %s", bgp_vpn_rd_print(ndo, tptr), ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN))); tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN); } break; case (AFNUM_VPLS<<8 | SAFNUM_VPLS): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): if (tlen < (int)sizeof(struct in_addr)) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], sizeof(struct in_addr)); ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr))); tlen -= (sizeof(struct in_addr)); tptr += (sizeof(struct in_addr)); } break; case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): ND_TCHECK2(tptr[0], tlen); ND_PRINT((ndo, "%s", isonsap_string(ndo, tptr, tlen))); tptr += tlen; tlen = 0; break; case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): if (tlen < BGP_VPN_RD_LEN+1) { ND_PRINT((ndo, "invalid len")); tlen = 0; } else { ND_TCHECK2(tptr[0], tlen); ND_PRINT((ndo, "RD: %s, %s", bgp_vpn_rd_print(ndo, tptr), isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN))); /* rfc986 mapped IPv4 address ? */ - if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) + if (tlen == BGP_VPN_RD_LEN + 4 + sizeof(struct in_addr) + && EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601) ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4))); /* rfc1888 mapped IPv6 address ? */ - else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) + else if (tlen == BGP_VPN_RD_LEN + 3 + sizeof(struct in6_addr) + && EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000) ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3))); tptr += tlen; tlen = 0; } break; default: ND_TCHECK2(tptr[0], tlen); ND_PRINT((ndo, "no AFI %u/SAFI %u decoder", af, safi)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", tlen); tptr += tlen; tlen = 0; goto done; break; } } } ND_PRINT((ndo, ", nh-length: %u", nhlen)); tptr += tlen; ND_TCHECK(tptr[0]); snpa = tptr[0]; tptr++; if (snpa) { ND_PRINT((ndo, "\n\t %u SNPA", snpa)); for (/*nothing*/; snpa > 0; snpa--) { ND_TCHECK(tptr[0]); ND_PRINT((ndo, "\n\t %d bytes", tptr[0])); tptr += tptr[0] + 1; } } else { ND_PRINT((ndo, ", no SNPA")); } while (tptr < pptr + len) { switch (af<<8 | safi) { case (AFNUM_INET<<8 | SAFNUM_UNICAST): case (AFNUM_INET<<8 | SAFNUM_MULTICAST): case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO): advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_MDT): advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_UNICAST): case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_VPLS<<8 | SAFNUM_VPLS): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; default: ND_TCHECK2(*tptr,tlen); ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", tlen); advance = 0; tptr = pptr + len; break; } if (advance < 0) break; tptr += advance; } done: break; case BGPTYPE_MP_UNREACH_NLRI: ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); af = EXTRACT_16BITS(tptr); safi = tptr[2]; ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)", tok2str(af_values, "Unknown AFI", af), af, (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */ tok2str(bgp_safi_values, "Unknown SAFI", safi), safi)); if (len == BGP_MP_NLRI_MINSIZE) ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)")); tptr += 3; while (tptr < pptr + len) { switch (af<<8 | safi) { case (AFNUM_INET<<8 | SAFNUM_UNICAST): case (AFNUM_INET<<8 | SAFNUM_MULTICAST): case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST): advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_LABUNICAST): advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_UNICAST): case (AFNUM_INET6<<8 | SAFNUM_MULTICAST): case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST): advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST): advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else if (advance == -3) break; /* bytes left, but not enough */ else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_VPLS<<8 | SAFNUM_VPLS): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_NSAP<<8 | SAFNUM_UNICAST): case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST): advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST): case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST): advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_MDT): advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */ case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN): advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf)); if (advance == -1) ND_PRINT((ndo, "\n\t (illegal prefix length)")); else if (advance == -2) goto trunc; else ND_PRINT((ndo, "\n\t %s", buf)); break; default: ND_TCHECK2(*(tptr-3),tlen); ND_PRINT((ndo, "no AFI %u / SAFI %u decoder", af, safi)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr-3, "\n\t ", tlen); advance = 0; tptr = pptr + len; break; } if (advance < 0) break; tptr += advance; } break; case BGPTYPE_EXTD_COMMUNITIES: if (len % 8) { ND_PRINT((ndo, "invalid len")); break; } while (tlen>0) { uint16_t extd_comm; ND_TCHECK2(tptr[0], 2); extd_comm=EXTRACT_16BITS(tptr); ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]", tok2str(bgp_extd_comm_subtype_values, "unknown extd community typecode", extd_comm), extd_comm, bittok2str(bgp_extd_comm_flag_values, "none", extd_comm))); ND_TCHECK2(*(tptr+2), 6); switch(extd_comm) { case BGP_EXT_COM_RT_0: case BGP_EXT_COM_RO_0: case BGP_EXT_COM_L2VPN_RT_0: ND_PRINT((ndo, ": %u:%u (= %s)", EXTRACT_16BITS(tptr+2), EXTRACT_32BITS(tptr+4), ipaddr_string(ndo, tptr+4))); break; case BGP_EXT_COM_RT_1: case BGP_EXT_COM_RO_1: case BGP_EXT_COM_L2VPN_RT_1: case BGP_EXT_COM_VRF_RT_IMP: ND_PRINT((ndo, ": %s:%u", ipaddr_string(ndo, tptr+2), EXTRACT_16BITS(tptr+6))); break; case BGP_EXT_COM_RT_2: case BGP_EXT_COM_RO_2: ND_PRINT((ndo, ": %s:%u", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6))); break; case BGP_EXT_COM_LINKBAND: bw.i = EXTRACT_32BITS(tptr+2); ND_PRINT((ndo, ": bandwidth: %.3f Mbps", bw.f*8/1000000)); break; case BGP_EXT_COM_VPN_ORIGIN: case BGP_EXT_COM_VPN_ORIGIN2: case BGP_EXT_COM_VPN_ORIGIN3: case BGP_EXT_COM_VPN_ORIGIN4: case BGP_EXT_COM_OSPF_RID: case BGP_EXT_COM_OSPF_RID2: ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr+2))); break; case BGP_EXT_COM_OSPF_RTYPE: case BGP_EXT_COM_OSPF_RTYPE2: ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s", ipaddr_string(ndo, tptr+2), tok2str(bgp_extd_comm_ospf_rtype_values, "unknown (0x%02x)", *(tptr+6)), (*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "", ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "")); break; case BGP_EXT_COM_L2INFO: ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u", tok2str(l2vpn_encaps_values, "unknown encaps", *(tptr+2)), *(tptr+3), EXTRACT_16BITS(tptr+4))); break; case BGP_EXT_COM_SOURCE_AS: ND_PRINT((ndo, ": AS %u", EXTRACT_16BITS(tptr+2))); break; default: ND_TCHECK2(*tptr,8); print_unknown_data(ndo, tptr, "\n\t ", 8); break; } tlen -=8; tptr +=8; } break; case BGPTYPE_PMSI_TUNNEL: { uint8_t tunnel_type, flags; ND_TCHECK2(tptr[0], 5); tunnel_type = *(tptr+1); flags = *tptr; tlen = len; ND_PRINT((ndo, "\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u", tok2str(bgp_pmsi_tunnel_values, "Unknown", tunnel_type), tunnel_type, bittok2str(bgp_pmsi_flag_values, "none", flags), EXTRACT_24BITS(tptr+2)>>4)); tptr +=5; tlen -= 5; switch (tunnel_type) { case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */ case BGP_PMSI_TUNNEL_PIM_BIDIR: ND_TCHECK2(tptr[0], 8); ND_PRINT((ndo, "\n\t Sender %s, P-Group %s", ipaddr_string(ndo, tptr), ipaddr_string(ndo, tptr+4))); break; case BGP_PMSI_TUNNEL_PIM_SSM: ND_TCHECK2(tptr[0], 8); ND_PRINT((ndo, "\n\t Root-Node %s, P-Group %s", ipaddr_string(ndo, tptr), ipaddr_string(ndo, tptr+4))); break; case BGP_PMSI_TUNNEL_INGRESS: ND_TCHECK2(tptr[0], 4); ND_PRINT((ndo, "\n\t Tunnel-Endpoint %s", ipaddr_string(ndo, tptr))); break; case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */ case BGP_PMSI_TUNNEL_LDP_MP2MP: ND_TCHECK2(tptr[0], 8); ND_PRINT((ndo, "\n\t Root-Node %s, LSP-ID 0x%08x", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr+4))); break; case BGP_PMSI_TUNNEL_RSVP_P2MP: ND_TCHECK2(tptr[0], 8); ND_PRINT((ndo, "\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr+4))); break; default: if (ndo->ndo_vflag <= 1) { print_unknown_data(ndo, tptr, "\n\t ", tlen); } } break; } case BGPTYPE_AIGP: { uint8_t type; uint16_t length; tlen = len; while (tlen >= 3) { ND_TCHECK2(tptr[0], 3); type = *tptr; length = EXTRACT_16BITS(tptr+1); tptr += 3; tlen -= 3; ND_PRINT((ndo, "\n\t %s TLV (%u), length %u", tok2str(bgp_aigp_values, "Unknown", type), type, length)); if (length < 3) goto trunc; length -= 3; /* * Check if we can read the TLV data. */ ND_TCHECK2(tptr[3], length); switch (type) { case BGP_AIGP_TLV: if (length < 8) goto trunc; ND_PRINT((ndo, ", metric %" PRIu64, EXTRACT_64BITS(tptr))); break; default: if (ndo->ndo_vflag <= 1) { print_unknown_data(ndo, tptr,"\n\t ", length); } } tptr += length; tlen -= length; } break; } case BGPTYPE_ATTR_SET: ND_TCHECK2(tptr[0], 4); if (len < 4) goto trunc; ND_PRINT((ndo, "\n\t Origin AS: %s", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)))); tptr+=4; len -=4; while (len) { u_int aflags, alenlen, alen; ND_TCHECK2(tptr[0], 2); if (len < 2) goto trunc; aflags = *tptr; atype = *(tptr + 1); tptr += 2; len -= 2; alenlen = bgp_attr_lenlen(aflags, tptr); ND_TCHECK2(tptr[0], alenlen); if (len < alenlen) goto trunc; alen = bgp_attr_len(aflags, tptr); tptr += alenlen; len -= alenlen; ND_PRINT((ndo, "\n\t %s (%u), length: %u", tok2str(bgp_attr_values, "Unknown Attribute", atype), atype, alen)); if (aflags) { ND_PRINT((ndo, ", Flags [%s%s%s%s", aflags & 0x80 ? "O" : "", aflags & 0x40 ? "T" : "", aflags & 0x20 ? "P" : "", aflags & 0x10 ? "E" : "")); if (aflags & 0xf) ND_PRINT((ndo, "+%x", aflags & 0xf)); ND_PRINT((ndo, "]: ")); } - /* FIXME check for recursion */ - if (!bgp_attr_print(ndo, atype, tptr, alen)) + /* The protocol encoding per se allows ATTR_SET to be nested as many times + * as the message can accommodate. This printer used to be able to recurse + * into ATTR_SET contents until the stack exhaustion, but now there is a + * limit on that (if live protocol exchange goes that many levels deep, + * something is probably wrong anyway). Feel free to refine this value if + * you can find the spec with respective normative text. + */ + if (attr_set_level == 10) + ND_PRINT((ndo, "(too many nested levels, not recursing)")); + else if (!bgp_attr_print(ndo, atype, tptr, alen, attr_set_level + 1)) return 0; tptr += alen; len -= alen; } break; case BGPTYPE_LARGE_COMMUNITY: if (len == 0 || len % 12) { ND_PRINT((ndo, "invalid len")); break; } ND_PRINT((ndo, "\n\t ")); while (len > 0) { ND_TCHECK2(*tptr, 12); ND_PRINT((ndo, "%u:%u:%u%s", EXTRACT_32BITS(tptr), EXTRACT_32BITS(tptr + 4), EXTRACT_32BITS(tptr + 8), (len > 12) ? ", " : "")); tptr += 12; len -= 12; } break; default: ND_TCHECK2(*pptr,len); ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */ if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, pptr, "\n\t ", len); break; } if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/ ND_TCHECK2(*pptr,len); print_unknown_data(ndo, pptr, "\n\t ", len); } return 1; trunc: return 0; } static void bgp_capabilities_print(netdissect_options *ndo, const u_char *opt, int caps_len) { int cap_type, cap_len, tcap_len, cap_offset; int i = 0; while (i < caps_len) { ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE); cap_type=opt[i]; cap_len=opt[i+1]; tcap_len=cap_len; ND_PRINT((ndo, "\n\t %s (%u), length: %u", tok2str(bgp_capcode_values, "Unknown", cap_type), cap_type, cap_len)); ND_TCHECK2(opt[i+2], cap_len); switch (cap_type) { case BGP_CAPCODE_MP: + /* AFI (16 bits), Reserved (8 bits), SAFI (8 bits) */ + ND_TCHECK_8BITS(opt + i + 5); ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)", tok2str(af_values, "Unknown", EXTRACT_16BITS(opt+i+2)), EXTRACT_16BITS(opt+i+2), tok2str(bgp_safi_values, "Unknown", opt[i+5]), opt[i+5])); break; case BGP_CAPCODE_RESTART: + /* Restart Flags (4 bits), Restart Time in seconds (12 bits) */ + ND_TCHECK_16BITS(opt + i + 2); ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us", ((opt[i+2])&0x80) ? "R" : "none", EXTRACT_16BITS(opt+i+2)&0xfff)); tcap_len-=2; cap_offset=4; while(tcap_len>=4) { + ND_TCHECK_8BITS(opt + i + cap_offset + 3); ND_PRINT((ndo, "\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s", tok2str(af_values,"Unknown", EXTRACT_16BITS(opt+i+cap_offset)), EXTRACT_16BITS(opt+i+cap_offset), tok2str(bgp_safi_values,"Unknown", opt[i+cap_offset+2]), opt[i+cap_offset+2], ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" )); tcap_len-=4; cap_offset+=4; } break; case BGP_CAPCODE_RR: case BGP_CAPCODE_RR_CISCO: break; case BGP_CAPCODE_AS_NEW: /* * Extract the 4 byte AS number encoded. */ if (cap_len == 4) { ND_PRINT((ndo, "\n\t\t 4 Byte AS %s", as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(opt + i + 2)))); } break; case BGP_CAPCODE_ADD_PATH: cap_offset=2; if (tcap_len == 0) { ND_PRINT((ndo, " (bogus)")); /* length */ break; } while (tcap_len > 0) { if (tcap_len < 4) { ND_PRINT((ndo, "\n\t\t(invalid)")); break; } ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s", tok2str(af_values,"Unknown",EXTRACT_16BITS(opt+i+cap_offset)), EXTRACT_16BITS(opt+i+cap_offset), tok2str(bgp_safi_values,"Unknown",opt[i+cap_offset+2]), opt[i+cap_offset+2], tok2str(bgp_add_path_recvsend,"Bogus (0x%02x)",opt[i+cap_offset+3]) )); tcap_len-=4; cap_offset+=4; } break; default: ND_PRINT((ndo, "\n\t\tno decoder for Capability %u", cap_type)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len); break; } if (ndo->ndo_vflag > 1 && cap_len > 0) { print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len); } i += BGP_CAP_HEADER_SIZE + cap_len; } return; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } static void bgp_open_print(netdissect_options *ndo, const u_char *dat, int length) { struct bgp_open bgpo; struct bgp_opt bgpopt; const u_char *opt; int i; ND_TCHECK2(dat[0], BGP_OPEN_SIZE); memcpy(&bgpo, dat, BGP_OPEN_SIZE); ND_PRINT((ndo, "\n\t Version %d, ", bgpo.bgpo_version)); ND_PRINT((ndo, "my AS %s, ", as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas)))); ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime))); ND_PRINT((ndo, "ID %s", ipaddr_string(ndo, &bgpo.bgpo_id))); ND_PRINT((ndo, "\n\t Optional parameters, length: %u", bgpo.bgpo_optlen)); /* some little sanity checking */ if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE) return; /* ugly! */ opt = &((const struct bgp_open *)dat)->bgpo_optlen; opt++; i = 0; while (i < bgpo.bgpo_optlen) { ND_TCHECK2(opt[i], BGP_OPT_SIZE); memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE); if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) { ND_PRINT((ndo, "\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len)); break; } ND_PRINT((ndo, "\n\t Option %s (%u), length: %u", tok2str(bgp_opt_values,"Unknown", bgpopt.bgpopt_type), bgpopt.bgpopt_type, bgpopt.bgpopt_len)); /* now let's decode the options we know*/ switch(bgpopt.bgpopt_type) { case BGP_OPT_CAP: bgp_capabilities_print(ndo, &opt[i+BGP_OPT_SIZE], bgpopt.bgpopt_len); break; case BGP_OPT_AUTH: default: ND_PRINT((ndo, "\n\t no decoder for option %u", bgpopt.bgpopt_type)); break; } i += BGP_OPT_SIZE + bgpopt.bgpopt_len; } return; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } static void bgp_update_print(netdissect_options *ndo, const u_char *dat, int length) { struct bgp bgp; const u_char *p; int withdrawn_routes_len; int len; int i; ND_TCHECK2(dat[0], BGP_SIZE); if (length < BGP_SIZE) goto trunc; memcpy(&bgp, dat, BGP_SIZE); p = dat + BGP_SIZE; /*XXX*/ length -= BGP_SIZE; /* Unfeasible routes */ ND_TCHECK2(p[0], 2); if (length < 2) goto trunc; withdrawn_routes_len = EXTRACT_16BITS(p); p += 2; length -= 2; if (withdrawn_routes_len) { /* * Without keeping state from the original NLRI message, * it's not possible to tell if this a v4 or v6 route, * so only try to decode it if we're not v6 enabled. */ ND_TCHECK2(p[0], withdrawn_routes_len); if (length < withdrawn_routes_len) goto trunc; ND_PRINT((ndo, "\n\t Withdrawn routes: %d bytes", withdrawn_routes_len)); p += withdrawn_routes_len; length -= withdrawn_routes_len; } ND_TCHECK2(p[0], 2); if (length < 2) goto trunc; len = EXTRACT_16BITS(p); p += 2; length -= 2; if (withdrawn_routes_len == 0 && len == 0 && length == 0) { /* No withdrawn routes, no path attributes, no NLRI */ ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)")); return; } if (len) { /* do something more useful!*/ while (len) { int aflags, atype, alenlen, alen; ND_TCHECK2(p[0], 2); if (len < 2) goto trunc; if (length < 2) goto trunc; aflags = *p; atype = *(p + 1); p += 2; len -= 2; length -= 2; alenlen = bgp_attr_lenlen(aflags, p); ND_TCHECK2(p[0], alenlen); if (len < alenlen) goto trunc; if (length < alenlen) goto trunc; alen = bgp_attr_len(aflags, p); p += alenlen; len -= alenlen; length -= alenlen; ND_PRINT((ndo, "\n\t %s (%u), length: %u", tok2str(bgp_attr_values, "Unknown Attribute", atype), atype, alen)); if (aflags) { ND_PRINT((ndo, ", Flags [%s%s%s%s", aflags & 0x80 ? "O" : "", aflags & 0x40 ? "T" : "", aflags & 0x20 ? "P" : "", aflags & 0x10 ? "E" : "")); if (aflags & 0xf) ND_PRINT((ndo, "+%x", aflags & 0xf)); ND_PRINT((ndo, "]: ")); } if (len < alen) goto trunc; if (length < alen) goto trunc; - if (!bgp_attr_print(ndo, atype, p, alen)) + if (!bgp_attr_print(ndo, atype, p, alen, 0)) goto trunc; p += alen; len -= alen; length -= alen; } } if (length) { /* * XXX - what if they're using the "Advertisement of * Multiple Paths in BGP" feature: * * https://datatracker.ietf.org/doc/draft-ietf-idr-add-paths/ * * http://tools.ietf.org/html/draft-ietf-idr-add-paths-06 */ ND_PRINT((ndo, "\n\t Updated routes:")); while (length) { char buf[MAXHOSTNAMELEN + 100]; i = decode_prefix4(ndo, p, length, buf, sizeof(buf)); if (i == -1) { ND_PRINT((ndo, "\n\t (illegal prefix length)")); break; } else if (i == -2) goto trunc; else if (i == -3) goto trunc; /* bytes left, but not enough */ else { ND_PRINT((ndo, "\n\t %s", buf)); p += i; length -= i; } } } return; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } static void bgp_notification_print(netdissect_options *ndo, const u_char *dat, int length) { struct bgp_notification bgpn; const u_char *tptr; ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE); memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE); /* some little sanity checking */ if (length= BGP_NOTIFICATION_SIZE + 7) { tptr = dat + BGP_NOTIFICATION_SIZE; ND_TCHECK2(*tptr, 7); ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u", tok2str(af_values, "Unknown", EXTRACT_16BITS(tptr)), EXTRACT_16BITS(tptr), tok2str(bgp_safi_values, "Unknown", *(tptr+2)), *(tptr+2), EXTRACT_32BITS(tptr+3))); } break; default: break; } return; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } static void bgp_route_refresh_print(netdissect_options *ndo, const u_char *pptr, int len) { const struct bgp_route_refresh *bgp_route_refresh_header; ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE); /* some little sanity checking */ if (lenafi)), EXTRACT_16BITS(&bgp_route_refresh_header->afi), tok2str(bgp_safi_values,"Unknown", bgp_route_refresh_header->safi), bgp_route_refresh_header->safi)); if (ndo->ndo_vflag > 1) { ND_TCHECK2(*pptr, len); print_unknown_data(ndo, pptr, "\n\t ", len); } return; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } static int bgp_header_print(netdissect_options *ndo, const u_char *dat, int length) { struct bgp bgp; ND_TCHECK2(dat[0], BGP_SIZE); memcpy(&bgp, dat, BGP_SIZE); ND_PRINT((ndo, "\n\t%s Message (%u), length: %u", tok2str(bgp_msg_values, "Unknown", bgp.bgp_type), bgp.bgp_type, length)); switch (bgp.bgp_type) { case BGP_OPEN: bgp_open_print(ndo, dat, length); break; case BGP_UPDATE: bgp_update_print(ndo, dat, length); break; case BGP_NOTIFICATION: bgp_notification_print(ndo, dat, length); break; case BGP_KEEPALIVE: break; case BGP_ROUTE_REFRESH: bgp_route_refresh_print(ndo, dat, length); break; default: /* we have no decoder for the BGP message */ ND_TCHECK2(*dat, length); ND_PRINT((ndo, "\n\t no Message %u decoder", bgp.bgp_type)); print_unknown_data(ndo, dat, "\n\t ", length); break; } return 1; trunc: - ND_PRINT((ndo, "[|BGP]")); + ND_PRINT((ndo, "%s", tstr)); return 0; } void bgp_print(netdissect_options *ndo, const u_char *dat, int length) { const u_char *p; const u_char *ep; const u_char *start; const u_char marker[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; struct bgp bgp; uint16_t hlen; ep = dat + length; if (ndo->ndo_snapend < dat + length) ep = ndo->ndo_snapend; ND_PRINT((ndo, ": BGP")); if (ndo->ndo_vflag < 1) /* lets be less chatty */ return; p = dat; start = p; while (p < ep) { if (!ND_TTEST2(p[0], 1)) break; if (p[0] != 0xff) { p++; continue; } if (!ND_TTEST2(p[0], sizeof(marker))) break; if (memcmp(p, marker, sizeof(marker)) != 0) { p++; continue; } /* found BGP header */ ND_TCHECK2(p[0], BGP_SIZE); /*XXX*/ memcpy(&bgp, p, BGP_SIZE); if (start != p) - ND_PRINT((ndo, " [|BGP]")); + ND_PRINT((ndo, " %s", tstr)); hlen = ntohs(bgp.bgp_len); if (hlen < BGP_SIZE) { ND_PRINT((ndo, "\n[|BGP Bogus header length %u < %u]", hlen, BGP_SIZE)); break; } if (ND_TTEST2(p[0], hlen)) { if (!bgp_header_print(ndo, p, hlen)) return; p += hlen; start = p; } else { ND_PRINT((ndo, "\n[|BGP %s]", tok2str(bgp_msg_values, "Unknown Message Type", bgp.bgp_type))); break; } } return; trunc: - ND_PRINT((ndo, " [|BGP]")); + ND_PRINT((ndo, "%s", tstr)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */ Index: vendor/tcpdump/dist/print-bootp.c =================================================================== --- vendor/tcpdump/dist/print-bootp.c (revision 353143) +++ vendor/tcpdump/dist/print-bootp.c (revision 353144) @@ -1,1094 +1,1095 @@ /* * Copyright (c) 1990, 1991, 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. */ /* \summary: BOOTP and IPv4 DHCP printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" static const char tstr[] = " [|bootp]"; /* * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. * * This file specifies the "implementation-independent" BOOTP protocol * information which is common to both client and server. * * Copyright 1988 by Carnegie Mellon. * * Permission to use, copy, modify, and distribute this program for any * purpose and without fee is hereby granted, provided that this copyright * and permission notice appear on all copies and supporting documentation, * the name of Carnegie Mellon not be used in advertising or publicity * pertaining to distribution of the program without specific prior * permission, and notice be given in supporting documentation that copying * and distribution is by permission of Carnegie Mellon and Stanford * University. Carnegie Mellon makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. */ struct bootp { uint8_t bp_op; /* packet opcode type */ uint8_t bp_htype; /* hardware addr type */ uint8_t bp_hlen; /* hardware addr length */ uint8_t bp_hops; /* gateway hops */ uint32_t bp_xid; /* transaction ID */ uint16_t bp_secs; /* seconds since boot began */ uint16_t bp_flags; /* flags - see bootp_flag_values[] in print-bootp.c */ struct in_addr bp_ciaddr; /* client IP address */ struct in_addr bp_yiaddr; /* 'your' IP address */ struct in_addr bp_siaddr; /* server IP address */ struct in_addr bp_giaddr; /* gateway IP address */ uint8_t bp_chaddr[16]; /* client hardware address */ uint8_t bp_sname[64]; /* server host name */ uint8_t bp_file[128]; /* boot file name */ uint8_t bp_vend[64]; /* vendor-specific area */ } UNALIGNED; #define BOOTPREPLY 2 #define BOOTPREQUEST 1 /* * Vendor magic cookie (v_magic) for CMU */ #define VM_CMU "CMU" /* * Vendor magic cookie (v_magic) for RFC1048 */ #define VM_RFC1048 { 99, 130, 83, 99 } /* * RFC1048 tag values used to specify what information is being supplied in * the vendor field of the packet. */ #define TAG_PAD ((uint8_t) 0) #define TAG_SUBNET_MASK ((uint8_t) 1) #define TAG_TIME_OFFSET ((uint8_t) 2) #define TAG_GATEWAY ((uint8_t) 3) #define TAG_TIME_SERVER ((uint8_t) 4) #define TAG_NAME_SERVER ((uint8_t) 5) #define TAG_DOMAIN_SERVER ((uint8_t) 6) #define TAG_LOG_SERVER ((uint8_t) 7) #define TAG_COOKIE_SERVER ((uint8_t) 8) #define TAG_LPR_SERVER ((uint8_t) 9) #define TAG_IMPRESS_SERVER ((uint8_t) 10) #define TAG_RLP_SERVER ((uint8_t) 11) #define TAG_HOSTNAME ((uint8_t) 12) #define TAG_BOOTSIZE ((uint8_t) 13) #define TAG_END ((uint8_t) 255) /* RFC1497 tags */ #define TAG_DUMPPATH ((uint8_t) 14) #define TAG_DOMAINNAME ((uint8_t) 15) #define TAG_SWAP_SERVER ((uint8_t) 16) #define TAG_ROOTPATH ((uint8_t) 17) #define TAG_EXTPATH ((uint8_t) 18) /* RFC2132 */ #define TAG_IP_FORWARD ((uint8_t) 19) #define TAG_NL_SRCRT ((uint8_t) 20) #define TAG_PFILTERS ((uint8_t) 21) #define TAG_REASS_SIZE ((uint8_t) 22) #define TAG_DEF_TTL ((uint8_t) 23) #define TAG_MTU_TIMEOUT ((uint8_t) 24) #define TAG_MTU_TABLE ((uint8_t) 25) #define TAG_INT_MTU ((uint8_t) 26) #define TAG_LOCAL_SUBNETS ((uint8_t) 27) #define TAG_BROAD_ADDR ((uint8_t) 28) #define TAG_DO_MASK_DISC ((uint8_t) 29) #define TAG_SUPPLY_MASK ((uint8_t) 30) #define TAG_DO_RDISC ((uint8_t) 31) #define TAG_RTR_SOL_ADDR ((uint8_t) 32) #define TAG_STATIC_ROUTE ((uint8_t) 33) #define TAG_USE_TRAILERS ((uint8_t) 34) #define TAG_ARP_TIMEOUT ((uint8_t) 35) #define TAG_ETH_ENCAP ((uint8_t) 36) #define TAG_TCP_TTL ((uint8_t) 37) #define TAG_TCP_KEEPALIVE ((uint8_t) 38) #define TAG_KEEPALIVE_GO ((uint8_t) 39) #define TAG_NIS_DOMAIN ((uint8_t) 40) #define TAG_NIS_SERVERS ((uint8_t) 41) #define TAG_NTP_SERVERS ((uint8_t) 42) #define TAG_VENDOR_OPTS ((uint8_t) 43) #define TAG_NETBIOS_NS ((uint8_t) 44) #define TAG_NETBIOS_DDS ((uint8_t) 45) #define TAG_NETBIOS_NODE ((uint8_t) 46) #define TAG_NETBIOS_SCOPE ((uint8_t) 47) #define TAG_XWIN_FS ((uint8_t) 48) #define TAG_XWIN_DM ((uint8_t) 49) #define TAG_NIS_P_DOMAIN ((uint8_t) 64) #define TAG_NIS_P_SERVERS ((uint8_t) 65) #define TAG_MOBILE_HOME ((uint8_t) 68) #define TAG_SMPT_SERVER ((uint8_t) 69) #define TAG_POP3_SERVER ((uint8_t) 70) #define TAG_NNTP_SERVER ((uint8_t) 71) #define TAG_WWW_SERVER ((uint8_t) 72) #define TAG_FINGER_SERVER ((uint8_t) 73) #define TAG_IRC_SERVER ((uint8_t) 74) #define TAG_STREETTALK_SRVR ((uint8_t) 75) #define TAG_STREETTALK_STDA ((uint8_t) 76) /* DHCP options */ #define TAG_REQUESTED_IP ((uint8_t) 50) #define TAG_IP_LEASE ((uint8_t) 51) #define TAG_OPT_OVERLOAD ((uint8_t) 52) #define TAG_TFTP_SERVER ((uint8_t) 66) #define TAG_BOOTFILENAME ((uint8_t) 67) #define TAG_DHCP_MESSAGE ((uint8_t) 53) #define TAG_SERVER_ID ((uint8_t) 54) #define TAG_PARM_REQUEST ((uint8_t) 55) #define TAG_MESSAGE ((uint8_t) 56) #define TAG_MAX_MSG_SIZE ((uint8_t) 57) #define TAG_RENEWAL_TIME ((uint8_t) 58) #define TAG_REBIND_TIME ((uint8_t) 59) #define TAG_VENDOR_CLASS ((uint8_t) 60) #define TAG_CLIENT_ID ((uint8_t) 61) /* RFC 2241 */ #define TAG_NDS_SERVERS ((uint8_t) 85) #define TAG_NDS_TREE_NAME ((uint8_t) 86) #define TAG_NDS_CONTEXT ((uint8_t) 87) /* RFC 2242 */ #define TAG_NDS_IPDOMAIN ((uint8_t) 62) #define TAG_NDS_IPINFO ((uint8_t) 63) /* RFC 2485 */ #define TAG_OPEN_GROUP_UAP ((uint8_t) 98) /* RFC 2563 */ #define TAG_DISABLE_AUTOCONF ((uint8_t) 116) /* RFC 2610 */ #define TAG_SLP_DA ((uint8_t) 78) #define TAG_SLP_SCOPE ((uint8_t) 79) /* RFC 2937 */ #define TAG_NS_SEARCH ((uint8_t) 117) /* RFC 3004 - The User Class Option for DHCP */ #define TAG_USER_CLASS ((uint8_t) 77) /* RFC 3011 */ #define TAG_IP4_SUBNET_SELECT ((uint8_t) 118) /* RFC 3442 */ #define TAG_CLASSLESS_STATIC_RT ((uint8_t) 121) #define TAG_CLASSLESS_STA_RT_MS ((uint8_t) 249) /* RFC 5859 - TFTP Server Address Option for DHCPv4 */ #define TAG_TFTP_SERVER_ADDRESS ((uint8_t) 150) /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */ #define TAG_SLP_NAMING_AUTH ((uint8_t) 80) #define TAG_CLIENT_FQDN ((uint8_t) 81) #define TAG_AGENT_CIRCUIT ((uint8_t) 82) #define TAG_AGENT_REMOTE ((uint8_t) 83) #define TAG_AGENT_MASK ((uint8_t) 84) #define TAG_TZ_STRING ((uint8_t) 88) #define TAG_FQDN_OPTION ((uint8_t) 89) #define TAG_AUTH ((uint8_t) 90) #define TAG_VINES_SERVERS ((uint8_t) 91) #define TAG_SERVER_RANK ((uint8_t) 92) #define TAG_CLIENT_ARCH ((uint8_t) 93) #define TAG_CLIENT_NDI ((uint8_t) 94) #define TAG_CLIENT_GUID ((uint8_t) 97) #define TAG_LDAP_URL ((uint8_t) 95) #define TAG_6OVER4 ((uint8_t) 96) /* RFC 4833, TZ codes */ #define TAG_TZ_PCODE ((uint8_t) 100) #define TAG_TZ_TCODE ((uint8_t) 101) #define TAG_IPX_COMPAT ((uint8_t) 110) #define TAG_NETINFO_PARENT ((uint8_t) 112) #define TAG_NETINFO_PARENT_TAG ((uint8_t) 113) #define TAG_URL ((uint8_t) 114) #define TAG_FAILOVER ((uint8_t) 115) #define TAG_EXTENDED_REQUEST ((uint8_t) 126) #define TAG_EXTENDED_OPTION ((uint8_t) 127) #define TAG_MUDURL ((uint8_t) 161) /* DHCP Message types (values for TAG_DHCP_MESSAGE option) */ #define DHCPDISCOVER 1 #define DHCPOFFER 2 #define DHCPREQUEST 3 #define DHCPDECLINE 4 #define DHCPACK 5 #define DHCPNAK 6 #define DHCPRELEASE 7 #define DHCPINFORM 8 /* * "vendor" data permitted for CMU bootp clients. */ struct cmu_vend { uint8_t v_magic[4]; /* magic number */ uint32_t v_flags; /* flags/opcodes, etc. */ struct in_addr v_smask; /* Subnet mask */ struct in_addr v_dgate; /* Default gateway */ struct in_addr v_dns1, v_dns2; /* Domain name servers */ struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */ struct in_addr v_ts1, v_ts2; /* Time servers */ uint8_t v_unused[24]; /* currently unused */ } UNALIGNED; /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ /* RFC 4702 DHCP Client FQDN Option */ #define CLIENT_FQDN_FLAGS_S 0x01 #define CLIENT_FQDN_FLAGS_O 0x02 #define CLIENT_FQDN_FLAGS_E 0x04 #define CLIENT_FQDN_FLAGS_N 0x08 /* end of original bootp.h */ static void rfc1048_print(netdissect_options *, const u_char *); static void cmu_print(netdissect_options *, const u_char *); static char *client_fqdn_flags(u_int flags); static const struct tok bootp_flag_values[] = { { 0x8000, "Broadcast" }, { 0, NULL} }; static const struct tok bootp_op_values[] = { { BOOTPREQUEST, "Request" }, { BOOTPREPLY, "Reply" }, { 0, NULL} }; /* * Print bootp requests */ void bootp_print(netdissect_options *ndo, register const u_char *cp, u_int length) { register const struct bootp *bp; static const u_char vm_cmu[4] = VM_CMU; static const u_char vm_rfc1048[4] = VM_RFC1048; bp = (const struct bootp *)cp; ND_TCHECK(bp->bp_op); ND_PRINT((ndo, "BOOTP/DHCP, %s", tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op))); ND_TCHECK(bp->bp_hlen); if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { ND_TCHECK2(bp->bp_chaddr[0], 6); ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr))); } ND_PRINT((ndo, ", length %u", length)); if (!ndo->ndo_vflag) return; ND_TCHECK(bp->bp_secs); /* The usual hardware address type is 1 (10Mb Ethernet) */ if (bp->bp_htype != 1) ND_PRINT((ndo, ", htype %d", bp->bp_htype)); /* The usual length for 10Mb Ethernet address is 6 bytes */ if (bp->bp_htype != 1 || bp->bp_hlen != 6) ND_PRINT((ndo, ", hlen %d", bp->bp_hlen)); /* Only print interesting fields */ if (bp->bp_hops) ND_PRINT((ndo, ", hops %d", bp->bp_hops)); if (EXTRACT_32BITS(&bp->bp_xid)) ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid))); if (EXTRACT_16BITS(&bp->bp_secs)) ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs))); ND_TCHECK(bp->bp_flags); ND_PRINT((ndo, ", Flags [%s]", bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)))); if (ndo->ndo_vflag > 1) ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags))); /* Client's ip address */ ND_TCHECK(bp->bp_ciaddr); if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr)) ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr))); /* 'your' ip address (bootp client) */ ND_TCHECK(bp->bp_yiaddr); if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr)) ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr))); /* Server's ip address */ ND_TCHECK(bp->bp_siaddr); if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr)) ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr))); /* Gateway's ip address */ ND_TCHECK(bp->bp_giaddr); if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr)) ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr))); /* Client's Ethernet address */ if (bp->bp_htype == 1 && bp->bp_hlen == 6) { ND_TCHECK2(bp->bp_chaddr[0], 6); ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr))); } ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */ if (*bp->bp_sname) { ND_PRINT((ndo, "\n\t sname \"")); if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname, - ndo->ndo_snapend)) { + ndo->ndo_snapend) == 0) { ND_PRINT((ndo, "\"")); ND_PRINT((ndo, "%s", tstr + 1)); return; } ND_PRINT((ndo, "\"")); } ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */ if (*bp->bp_file) { ND_PRINT((ndo, "\n\t file \"")); if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file, - ndo->ndo_snapend)) { + ndo->ndo_snapend) == 0) { ND_PRINT((ndo, "\"")); ND_PRINT((ndo, "%s", tstr + 1)); return; } ND_PRINT((ndo, "\"")); } /* Decode the vendor buffer */ - ND_TCHECK(bp->bp_vend[0]); + ND_TCHECK2(bp->bp_vend[0], 4); if (memcmp((const char *)bp->bp_vend, vm_rfc1048, sizeof(uint32_t)) == 0) rfc1048_print(ndo, bp->bp_vend); else if (memcmp((const char *)bp->bp_vend, vm_cmu, sizeof(uint32_t)) == 0) cmu_print(ndo, bp->bp_vend); else { uint32_t ul; + ND_TCHECK_32BITS(&bp->bp_vend); ul = EXTRACT_32BITS(&bp->bp_vend); if (ul != 0) ND_PRINT((ndo, "\n\t Vendor-#0x%x", ul)); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* * The first character specifies the format to print: * i - ip address (32 bits) * p - ip address pairs (32 bits + 32 bits) * l - long (32 bits) * L - unsigned long (32 bits) * s - short (16 bits) * b - period-seperated decimal bytes (variable length) * x - colon-seperated hex bytes (variable length) * a - ascii string (variable length) * B - on/off (8 bits) * $ - special (explicit code to handle) */ static const struct tok tag2str[] = { /* RFC1048 tags */ { TAG_PAD, " PAD" }, { TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */ { TAG_TIME_OFFSET, "LTime-Zone" }, /* seconds from UTC */ { TAG_GATEWAY, "iDefault-Gateway" }, /* default gateway */ { TAG_TIME_SERVER, "iTime-Server" }, /* time servers (RFC868) */ { TAG_NAME_SERVER, "iIEN-Name-Server" }, /* IEN name servers (IEN116) */ { TAG_DOMAIN_SERVER, "iDomain-Name-Server" }, /* domain name (RFC1035) */ { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ { TAG_LPR_SERVER, "iLPR-Server" }, /* lpr server (RFC1179) */ { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ { TAG_HOSTNAME, "aHostname" }, /* ascii hostname */ { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ { TAG_END, " END" }, /* RFC1497 tags */ { TAG_DUMPPATH, "aDP" }, { TAG_DOMAINNAME, "aDomain-Name" }, { TAG_SWAP_SERVER, "iSS" }, { TAG_ROOTPATH, "aRP" }, { TAG_EXTPATH, "aEP" }, /* RFC2132 tags */ { TAG_IP_FORWARD, "BIPF" }, { TAG_NL_SRCRT, "BSRT" }, { TAG_PFILTERS, "pPF" }, { TAG_REASS_SIZE, "sRSZ" }, { TAG_DEF_TTL, "bTTL" }, { TAG_MTU_TIMEOUT, "lMTU-Timeout" }, { TAG_MTU_TABLE, "sMTU-Table" }, { TAG_INT_MTU, "sMTU" }, { TAG_LOCAL_SUBNETS, "BLSN" }, { TAG_BROAD_ADDR, "iBR" }, { TAG_DO_MASK_DISC, "BMD" }, { TAG_SUPPLY_MASK, "BMS" }, { TAG_DO_RDISC, "BRouter-Discovery" }, { TAG_RTR_SOL_ADDR, "iRSA" }, { TAG_STATIC_ROUTE, "pStatic-Route" }, { TAG_USE_TRAILERS, "BUT" }, { TAG_ARP_TIMEOUT, "lAT" }, { TAG_ETH_ENCAP, "BIE" }, { TAG_TCP_TTL, "bTT" }, { TAG_TCP_KEEPALIVE, "lKI" }, { TAG_KEEPALIVE_GO, "BKG" }, { TAG_NIS_DOMAIN, "aYD" }, { TAG_NIS_SERVERS, "iYS" }, { TAG_NTP_SERVERS, "iNTP" }, { TAG_VENDOR_OPTS, "bVendor-Option" }, { TAG_NETBIOS_NS, "iNetbios-Name-Server" }, { TAG_NETBIOS_DDS, "iWDD" }, { TAG_NETBIOS_NODE, "$Netbios-Node" }, { TAG_NETBIOS_SCOPE, "aNetbios-Scope" }, { TAG_XWIN_FS, "iXFS" }, { TAG_XWIN_DM, "iXDM" }, { TAG_NIS_P_DOMAIN, "sN+D" }, { TAG_NIS_P_SERVERS, "iN+S" }, { TAG_MOBILE_HOME, "iMH" }, { TAG_SMPT_SERVER, "iSMTP" }, { TAG_POP3_SERVER, "iPOP3" }, { TAG_NNTP_SERVER, "iNNTP" }, { TAG_WWW_SERVER, "iWWW" }, { TAG_FINGER_SERVER, "iFG" }, { TAG_IRC_SERVER, "iIRC" }, { TAG_STREETTALK_SRVR, "iSTS" }, { TAG_STREETTALK_STDA, "iSTDA" }, { TAG_REQUESTED_IP, "iRequested-IP" }, { TAG_IP_LEASE, "lLease-Time" }, { TAG_OPT_OVERLOAD, "$OO" }, { TAG_TFTP_SERVER, "aTFTP" }, { TAG_BOOTFILENAME, "aBF" }, { TAG_DHCP_MESSAGE, " DHCP-Message" }, { TAG_SERVER_ID, "iServer-ID" }, { TAG_PARM_REQUEST, "bParameter-Request" }, { TAG_MESSAGE, "aMSG" }, { TAG_MAX_MSG_SIZE, "sMSZ" }, { TAG_RENEWAL_TIME, "lRN" }, { TAG_REBIND_TIME, "lRB" }, { TAG_VENDOR_CLASS, "aVendor-Class" }, { TAG_CLIENT_ID, "$Client-ID" }, /* RFC 2485 */ { TAG_OPEN_GROUP_UAP, "aUAP" }, /* RFC 2563 */ { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, /* RFC 2610 */ { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ /* RFC 2937 */ { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ /* RFC 3004 - The User Class Option for DHCP */ { TAG_USER_CLASS, "$User-Class" }, /* RFC 3011 */ { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, /* RFC 3442 */ { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" }, { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" }, /* RFC 5859 - TFTP Server Address Option for DHCPv4 */ { TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" }, /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, { TAG_CLIENT_FQDN, "$FQDN" }, { TAG_AGENT_CIRCUIT, "$Agent-Information" }, { TAG_AGENT_REMOTE, "bARMT" }, { TAG_AGENT_MASK, "bAMSK" }, { TAG_TZ_STRING, "aTZSTR" }, { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ { TAG_VINES_SERVERS, "iVINES" }, { TAG_SERVER_RANK, "sRANK" }, { TAG_CLIENT_ARCH, "sARCH" }, { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */ { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */ { TAG_LDAP_URL, "aLDAP" }, { TAG_6OVER4, "i6o4" }, { TAG_TZ_PCODE, "aPOSIX-TZ" }, { TAG_TZ_TCODE, "aTZ-Name" }, { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */ { TAG_NETINFO_PARENT, "iNI" }, { TAG_NETINFO_PARENT_TAG, "aNITAG" }, { TAG_URL, "aURL" }, { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */ { TAG_MUDURL, "aMUD-URL" }, { 0, NULL } }; /* 2-byte extended tags */ static const struct tok xtag2str[] = { { 0, NULL } }; /* DHCP "options overload" types */ static const struct tok oo2str[] = { { 1, "file" }, { 2, "sname" }, { 3, "file+sname" }, { 0, NULL } }; /* NETBIOS over TCP/IP node type options */ static const struct tok nbo2str[] = { { 0x1, "b-node" }, { 0x2, "p-node" }, { 0x4, "m-node" }, { 0x8, "h-node" }, { 0, NULL } }; /* ARP Hardware types, for Client-ID option */ static const struct tok arp2str[] = { { 0x1, "ether" }, { 0x6, "ieee802" }, { 0x7, "arcnet" }, { 0xf, "frelay" }, { 0x17, "strip" }, { 0x18, "ieee1394" }, { 0, NULL } }; static const struct tok dhcp_msg_values[] = { { DHCPDISCOVER, "Discover" }, { DHCPOFFER, "Offer" }, { DHCPREQUEST, "Request" }, { DHCPDECLINE, "Decline" }, { DHCPACK, "ACK" }, { DHCPNAK, "NACK" }, { DHCPRELEASE, "Release" }, { DHCPINFORM, "Inform" }, { 0, NULL } }; #define AGENT_SUBOPTION_CIRCUIT_ID 1 /* RFC 3046 */ #define AGENT_SUBOPTION_REMOTE_ID 2 /* RFC 3046 */ #define AGENT_SUBOPTION_SUBSCRIBER_ID 6 /* RFC 3993 */ static const struct tok agent_suboption_values[] = { { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" }, { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" }, { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" }, { 0, NULL } }; static void rfc1048_print(netdissect_options *ndo, register const u_char *bp) { register uint16_t tag; register u_int len; register const char *cp; register char c; int first, idx; uint32_t ul; uint16_t us; uint8_t uc, subopt, suboptlen; ND_PRINT((ndo, "\n\t Vendor-rfc1048 Extensions")); /* Step over magic cookie */ ND_PRINT((ndo, "\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp))); bp += sizeof(int32_t); /* Loop while we there is a tag left in the buffer */ while (ND_TTEST2(*bp, 1)) { tag = *bp++; if (tag == TAG_PAD && ndo->ndo_vflag < 3) continue; if (tag == TAG_END && ndo->ndo_vflag < 3) return; if (tag == TAG_EXTENDED_OPTION) { ND_TCHECK2(*(bp + 1), 2); tag = EXTRACT_16BITS(bp + 1); /* XXX we don't know yet if the IANA will * preclude overlap of 1-byte and 2-byte spaces. * If not, we need to offset tag after this step. */ cp = tok2str(xtag2str, "?xT%u", tag); } else cp = tok2str(tag2str, "?T%u", tag); c = *cp++; if (tag == TAG_PAD || tag == TAG_END) len = 0; else { /* Get the length; check for truncation */ ND_TCHECK2(*bp, 1); len = *bp++; } ND_PRINT((ndo, "\n\t %s Option %u, length %u%s", cp, tag, len, len > 0 ? ": " : "")); if (tag == TAG_PAD && ndo->ndo_vflag > 2) { u_int ntag = 1; while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) { bp++; ntag++; } if (ntag > 1) ND_PRINT((ndo, ", occurs %u", ntag)); } if (!ND_TTEST2(*bp, len)) { ND_PRINT((ndo, "[|rfc1048 %u]", len)); return; } if (tag == TAG_DHCP_MESSAGE && len == 1) { uc = *bp++; ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc))); continue; } if (tag == TAG_PARM_REQUEST) { idx = 0; while (len-- > 0) { uc = *bp++; cp = tok2str(tag2str, "?Option %u", uc); if (idx % 4 == 0) ND_PRINT((ndo, "\n\t ")); else ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "%s", cp + 1)); idx++; } continue; } if (tag == TAG_EXTENDED_REQUEST) { first = 1; while (len > 1) { len -= 2; us = EXTRACT_16BITS(bp); bp += 2; cp = tok2str(xtag2str, "?xT%u", us); if (!first) ND_PRINT((ndo, "+")); ND_PRINT((ndo, "%s", cp + 1)); first = 0; } continue; } /* Print data */ if (c == '?') { /* Base default formats for unknown tags on data size */ if (len & 1) c = 'b'; else if (len & 2) c = 's'; else c = 'l'; } first = 1; switch (c) { case 'a': /* ascii strings */ ND_PRINT((ndo, "\"")); if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); bp += len; len = 0; break; case 'i': case 'l': case 'L': /* ip addresses/32-bit words */ while (len >= sizeof(ul)) { if (!first) ND_PRINT((ndo, ",")); ul = EXTRACT_32BITS(bp); if (c == 'i') { ul = htonl(ul); ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul))); } else if (c == 'L') ND_PRINT((ndo, "%d", ul)); else ND_PRINT((ndo, "%u", ul)); bp += sizeof(ul); len -= sizeof(ul); first = 0; } break; case 'p': /* IP address pairs */ while (len >= 2*sizeof(ul)) { if (!first) ND_PRINT((ndo, ",")); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul))); bp += sizeof(ul); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul))); bp += sizeof(ul); len -= 2*sizeof(ul); first = 0; } break; case 's': /* shorts */ while (len >= sizeof(us)) { if (!first) ND_PRINT((ndo, ",")); us = EXTRACT_16BITS(bp); ND_PRINT((ndo, "%u", us)); bp += sizeof(us); len -= sizeof(us); first = 0; } break; case 'B': /* boolean */ while (len > 0) { if (!first) ND_PRINT((ndo, ",")); switch (*bp) { case 0: ND_PRINT((ndo, "N")); break; case 1: ND_PRINT((ndo, "Y")); break; default: ND_PRINT((ndo, "%u?", *bp)); break; } ++bp; --len; first = 0; } break; case 'b': case 'x': default: /* Bytes */ while (len > 0) { if (!first) ND_PRINT((ndo, c == 'x' ? ":" : ".")); if (c == 'x') ND_PRINT((ndo, "%02x", *bp)); else ND_PRINT((ndo, "%u", *bp)); ++bp; --len; first = 0; } break; case '$': /* Guys we can't handle with one of the usual cases */ switch (tag) { case TAG_NETBIOS_NODE: /* this option should be at least 1 byte long */ if (len < 1) { ND_PRINT((ndo, "ERROR: length < 1 bytes")); break; } tag = *bp++; --len; ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag))); break; case TAG_OPT_OVERLOAD: /* this option should be at least 1 byte long */ if (len < 1) { ND_PRINT((ndo, "ERROR: length < 1 bytes")); break; } tag = *bp++; --len; ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag))); break; case TAG_CLIENT_FQDN: /* this option should be at least 3 bytes long */ if (len < 3) { ND_PRINT((ndo, "ERROR: length < 3 bytes")); bp += len; len = 0; break; } if (*bp) ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp))); bp++; if (*bp || *(bp+1)) ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1))); bp += 2; ND_PRINT((ndo, "\"")); if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); bp += len - 3; len = 0; break; case TAG_CLIENT_ID: { int type; /* this option should be at least 1 byte long */ if (len < 1) { ND_PRINT((ndo, "ERROR: length < 1 bytes")); break; } type = *bp++; len--; if (type == 0) { ND_PRINT((ndo, "\"")); if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); bp += len; len = 0; break; } else { ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type))); while (len > 0) { if (!first) ND_PRINT((ndo, ":")); ND_PRINT((ndo, "%02x", *bp)); ++bp; --len; first = 0; } } break; } case TAG_AGENT_CIRCUIT: while (len >= 2) { subopt = *bp++; suboptlen = *bp++; len -= 2; if (suboptlen > len) { ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: length goes past end of option", tok2str(agent_suboption_values, "Unknown", subopt), subopt, suboptlen)); bp += len; len = 0; break; } ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: ", tok2str(agent_suboption_values, "Unknown", subopt), subopt, suboptlen)); switch (subopt) { case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */ case AGENT_SUBOPTION_REMOTE_ID: case AGENT_SUBOPTION_SUBSCRIBER_ID: if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) goto trunc; break; default: print_unknown_data(ndo, bp, "\n\t\t", suboptlen); } len -= suboptlen; bp += suboptlen; } break; case TAG_CLASSLESS_STATIC_RT: case TAG_CLASSLESS_STA_RT_MS: { u_int mask_width, significant_octets, i; /* this option should be at least 5 bytes long */ if (len < 5) { ND_PRINT((ndo, "ERROR: length < 5 bytes")); bp += len; len = 0; break; } while (len > 0) { if (!first) ND_PRINT((ndo, ",")); mask_width = *bp++; len--; /* mask_width <= 32 */ if (mask_width > 32) { ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]", mask_width)); bp += len; len = 0; break; } significant_octets = (mask_width + 7) / 8; /* significant octets + router(4) */ if (len < significant_octets + 4) { ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4)); bp += len; len = 0; break; } ND_PRINT((ndo, "(")); if (mask_width == 0) ND_PRINT((ndo, "default")); else { for (i = 0; i < significant_octets ; i++) { if (i > 0) ND_PRINT((ndo, ".")); ND_PRINT((ndo, "%d", *bp++)); } for (i = significant_octets ; i < 4 ; i++) ND_PRINT((ndo, ".0")); ND_PRINT((ndo, "/%d", mask_width)); } memcpy((char *)&ul, (const char *)bp, sizeof(ul)); ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul))); bp += sizeof(ul); len -= (significant_octets + 4); first = 0; } break; } case TAG_USER_CLASS: { u_int suboptnumber = 1; first = 1; if (len < 2) { ND_PRINT((ndo, "ERROR: length < 2 bytes")); bp += len; len = 0; break; } while (len > 0) { suboptlen = *bp++; len--; ND_PRINT((ndo, "\n\t ")); ND_PRINT((ndo, "instance#%u: ", suboptnumber)); if (suboptlen == 0) { ND_PRINT((ndo, "ERROR: suboption length must be non-zero")); bp += len; len = 0; break; } if (len < suboptlen) { ND_PRINT((ndo, "ERROR: invalid option")); bp += len; len = 0; break; } ND_PRINT((ndo, "\"")); if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); ND_PRINT((ndo, ", length %d", suboptlen)); suboptnumber++; len -= suboptlen; bp += suboptlen; } break; } default: ND_PRINT((ndo, "[unknown special tag %u, size %u]", tag, len)); bp += len; len = 0; break; } break; } /* Data left over? */ if (len) { ND_PRINT((ndo, "\n\t trailing data length %u", len)); bp += len; } } return; trunc: ND_PRINT((ndo, "|[rfc1048]")); } static void cmu_print(netdissect_options *ndo, register const u_char *bp) { register const struct cmu_vend *cmu; #define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \ if (cmu->m.s_addr != 0) \ ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); } ND_PRINT((ndo, " vend-cmu")); cmu = (const struct cmu_vend *)bp; /* Only print if there are unknown bits */ ND_TCHECK(cmu->v_flags); if ((cmu->v_flags & ~(VF_SMASK)) != 0) ND_PRINT((ndo, " F:0x%x", cmu->v_flags)); PRINTCMUADDR(v_dgate, "DG"); PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*"); PRINTCMUADDR(v_dns1, "NS1"); PRINTCMUADDR(v_dns2, "NS2"); PRINTCMUADDR(v_ins1, "IEN1"); PRINTCMUADDR(v_ins2, "IEN2"); PRINTCMUADDR(v_ts1, "TS1"); PRINTCMUADDR(v_ts2, "TS2"); return; trunc: ND_PRINT((ndo, "%s", tstr)); #undef PRINTCMUADDR } static char * client_fqdn_flags(u_int flags) { static char buf[8+1]; int i = 0; if (flags & CLIENT_FQDN_FLAGS_S) buf[i++] = 'S'; if (flags & CLIENT_FQDN_FLAGS_O) buf[i++] = 'O'; if (flags & CLIENT_FQDN_FLAGS_E) buf[i++] = 'E'; if (flags & CLIENT_FQDN_FLAGS_N) buf[i++] = 'N'; buf[i] = '\0'; return buf; } Index: vendor/tcpdump/dist/print-dccp.c =================================================================== --- vendor/tcpdump/dist/print-dccp.c (revision 353143) +++ vendor/tcpdump/dist/print-dccp.c (revision 353144) @@ -1,659 +1,698 @@ /* * Copyright (C) Arnaldo Carvalho de Melo 2004 * Copyright (C) Ian McDonald 2005 * Copyright (C) Yoshifumi Nishida 2005 * * This software may be distributed either under the terms of the * BSD-style license that accompanies tcpdump or the GNU GPL version 2 */ /* \summary: Datagram Congestion Control Protocol (DCCP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "ip.h" #include "ip6.h" #include "ipproto.h" /* RFC4340: Datagram Congestion Control Protocol (DCCP) */ /** * struct dccp_hdr - generic part of DCCP packet header, with a 24-bit * sequence number * * @dccph_sport - Relevant port on the endpoint that sent this packet * @dccph_dport - Relevant port on the other endpoint * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words * @dccph_ccval - Used by the HC-Sender CCID * @dccph_cscov - Parts of the packet that are covered by the Checksum field * @dccph_checksum - Internet checksum, depends on dccph_cscov * @dccph_x - 0 = 24 bit sequence number, 1 = 48 * @dccph_type - packet type, see DCCP_PKT_ prefixed macros * @dccph_seq - 24-bit sequence number */ struct dccp_hdr { uint16_t dccph_sport, dccph_dport; uint8_t dccph_doff; uint8_t dccph_ccval_cscov; uint16_t dccph_checksum; uint8_t dccph_xtr; uint8_t dccph_seq[3]; } UNALIGNED; /** * struct dccp_hdr_ext - generic part of DCCP packet header, with a 48-bit * sequence number * * @dccph_sport - Relevant port on the endpoint that sent this packet * @dccph_dport - Relevant port on the other endpoint * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words * @dccph_ccval - Used by the HC-Sender CCID * @dccph_cscov - Parts of the packet that are covered by the Checksum field * @dccph_checksum - Internet checksum, depends on dccph_cscov * @dccph_x - 0 = 24 bit sequence number, 1 = 48 * @dccph_type - packet type, see DCCP_PKT_ prefixed macros * @dccph_seq - 48-bit sequence number */ struct dccp_hdr_ext { uint16_t dccph_sport, dccph_dport; uint8_t dccph_doff; uint8_t dccph_ccval_cscov; uint16_t dccph_checksum; uint8_t dccph_xtr; uint8_t reserved; uint8_t dccph_seq[6]; } UNALIGNED; #define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov >> 4) & 0xF) #define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov) & 0xF) #define DCCPH_X(dh) ((dh)->dccph_xtr & 1) #define DCCPH_TYPE(dh) (((dh)->dccph_xtr >> 1) & 0xF) /** * struct dccp_hdr_request - Conection initiation request header * * @dccph_req_service - Service to which the client app wants to connect */ struct dccp_hdr_request { uint32_t dccph_req_service; } UNALIGNED; /** * struct dccp_hdr_response - Conection initiation response header * * @dccph_resp_ack - 48 bit ack number, contains GSR * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request */ struct dccp_hdr_response { uint8_t dccph_resp_ack[8]; /* always 8 bytes */ uint32_t dccph_resp_service; } UNALIGNED; /** * struct dccp_hdr_reset - Unconditionally shut down a connection * * @dccph_resp_ack - 48 bit ack number * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request */ struct dccp_hdr_reset { uint8_t dccph_reset_ack[8]; /* always 8 bytes */ uint8_t dccph_reset_code, dccph_reset_data[3]; } UNALIGNED; enum dccp_pkt_type { DCCP_PKT_REQUEST = 0, DCCP_PKT_RESPONSE, DCCP_PKT_DATA, DCCP_PKT_ACK, DCCP_PKT_DATAACK, DCCP_PKT_CLOSEREQ, DCCP_PKT_CLOSE, DCCP_PKT_RESET, DCCP_PKT_SYNC, DCCP_PKT_SYNCACK }; static const struct tok dccp_pkt_type_str[] = { { DCCP_PKT_REQUEST, "DCCP-Request" }, { DCCP_PKT_RESPONSE, "DCCP-Response" }, { DCCP_PKT_DATA, "DCCP-Data" }, { DCCP_PKT_ACK, "DCCP-Ack" }, { DCCP_PKT_DATAACK, "DCCP-DataAck" }, { DCCP_PKT_CLOSEREQ, "DCCP-CloseReq" }, { DCCP_PKT_CLOSE, "DCCP-Close" }, { DCCP_PKT_RESET, "DCCP-Reset" }, { DCCP_PKT_SYNC, "DCCP-Sync" }, { DCCP_PKT_SYNCACK, "DCCP-SyncAck" }, { 0, NULL} }; enum dccp_reset_codes { DCCP_RESET_CODE_UNSPECIFIED = 0, DCCP_RESET_CODE_CLOSED, DCCP_RESET_CODE_ABORTED, DCCP_RESET_CODE_NO_CONNECTION, DCCP_RESET_CODE_PACKET_ERROR, DCCP_RESET_CODE_OPTION_ERROR, DCCP_RESET_CODE_MANDATORY_ERROR, DCCP_RESET_CODE_CONNECTION_REFUSED, DCCP_RESET_CODE_BAD_SERVICE_CODE, DCCP_RESET_CODE_TOO_BUSY, DCCP_RESET_CODE_BAD_INIT_COOKIE, DCCP_RESET_CODE_AGGRESSION_PENALTY, __DCCP_RESET_CODE_LAST }; static const char tstr[] = "[|dccp]"; static const char *dccp_reset_codes[] = { "unspecified", "closed", "aborted", "no_connection", "packet_error", "option_error", "mandatory_error", "connection_refused", "bad_service_code", "too_busy", "bad_init_cookie", "aggression_penalty", }; static const char *dccp_feature_nums[] = { "reserved", "ccid", "allow_short_seqno", "sequence_window", "ecn_incapable", "ack_ratio", "send_ack_vector", "send_ndp_count", "minimum checksum coverage", "check data checksum", }; static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len) { u_int cov; if (DCCPH_CSCOV(dh) == 0) return len; cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t); return (cov > len)? len : cov; } static int dccp_cksum(netdissect_options *ndo, const struct ip *ip, const struct dccp_hdr *dh, u_int len) { return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)dh, len, dccp_csum_coverage(dh, len), IPPROTO_DCCP); } static int dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len) { return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len, dccp_csum_coverage(dh, len), IPPROTO_DCCP); } static const char *dccp_reset_code(uint8_t code) { if (code >= __DCCP_RESET_CODE_LAST) return "invalid"; return dccp_reset_codes[code]; } static uint64_t dccp_seqno(const u_char *bp) { const struct dccp_hdr *dh = (const struct dccp_hdr *)bp; uint64_t seqno; if (DCCPH_X(dh) != 0) { const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp; seqno = EXTRACT_48BITS(dhx->dccph_seq); } else { seqno = EXTRACT_24BITS(dh->dccph_seq); } return seqno; } static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh) { return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr); } static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp) { const struct dccp_hdr *dh = (const struct dccp_hdr *)bp; const u_char *ackp = bp + dccp_basic_hdr_len(dh); uint64_t ackno; if (DCCPH_X(dh) != 0) { ND_TCHECK2(*ackp, 8); ackno = EXTRACT_48BITS(ackp + 2); } else { ND_TCHECK2(*ackp, 4); ackno = EXTRACT_24BITS(ackp + 1); } ND_PRINT((ndo, "(ack=%" PRIu64 ") ", ackno)); trunc: return; } static int dccp_print_option(netdissect_options *, const u_char *, u_int); /** * dccp_print - show dccp packet * @bp - beginning of dccp packet * @data2 - beginning of enclosing * @len - lenght of ip packet */ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2, u_int len) { const struct dccp_hdr *dh; const struct ip *ip; const struct ip6_hdr *ip6; const u_char *cp; u_short sport, dport; u_int hlen; u_int fixed_hdrlen; uint8_t dccph_type; dh = (const struct dccp_hdr *)bp; ip = (const struct ip *)data2; if (IP_V(ip) == 6) ip6 = (const struct ip6_hdr *)data2; else ip6 = NULL; /* make sure we have enough data to look at the X bit */ cp = (const u_char *)(dh + 1); if (cp > ndo->ndo_snapend) { ND_PRINT((ndo, "[Invalid packet|dccp]")); return; } if (len < sizeof(struct dccp_hdr)) { ND_PRINT((ndo, "truncated-dccp - %u bytes missing!", len - (u_int)sizeof(struct dccp_hdr))); return; } /* get the length of the generic header */ fixed_hdrlen = dccp_basic_hdr_len(dh); if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-dccp - %u bytes missing!", len - fixed_hdrlen)); return; } ND_TCHECK2(*dh, fixed_hdrlen); sport = EXTRACT_16BITS(&dh->dccph_sport); dport = EXTRACT_16BITS(&dh->dccph_dport); hlen = dh->dccph_doff * 4; if (ip6) { ND_PRINT((ndo, "%s.%d > %s.%d: ", ip6addr_string(ndo, &ip6->ip6_src), sport, ip6addr_string(ndo, &ip6->ip6_dst), dport)); } else { ND_PRINT((ndo, "%s.%d > %s.%d: ", ipaddr_string(ndo, &ip->ip_src), sport, ipaddr_string(ndo, &ip->ip_dst), dport)); } ND_PRINT((ndo, "DCCP")); if (ndo->ndo_qflag) { ND_PRINT((ndo, " %d", len - hlen)); if (hlen > len) { ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]", hlen, len)); } return; } /* other variables in generic header */ if (ndo->ndo_vflag) { ND_PRINT((ndo, " (CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh))); } /* checksum calculation */ if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) { uint16_t sum = 0, dccp_sum; dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum); ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum)); if (IP_V(ip) == 4) sum = dccp_cksum(ndo, ip, dh, len); else if (IP_V(ip) == 6) sum = dccp6_cksum(ndo, ip6, dh, len); if (sum != 0) ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum))); else ND_PRINT((ndo, "(correct)")); } if (ndo->ndo_vflag) ND_PRINT((ndo, ")")); ND_PRINT((ndo, " ")); dccph_type = DCCPH_TYPE(dh); switch (dccph_type) { case DCCP_PKT_REQUEST: { const struct dccp_hdr_request *dhr = (const struct dccp_hdr_request *)(bp + fixed_hdrlen); fixed_hdrlen += 4; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_TCHECK(*dhr); ND_PRINT((ndo, "%s (service=%d) ", tok2str(dccp_pkt_type_str, "", dccph_type), EXTRACT_32BITS(&dhr->dccph_req_service))); break; } case DCCP_PKT_RESPONSE: { const struct dccp_hdr_response *dhr = (const struct dccp_hdr_response *)(bp + fixed_hdrlen); fixed_hdrlen += 12; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_TCHECK(*dhr); ND_PRINT((ndo, "%s (service=%d) ", tok2str(dccp_pkt_type_str, "", dccph_type), EXTRACT_32BITS(&dhr->dccph_resp_service))); break; } case DCCP_PKT_DATA: ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; case DCCP_PKT_ACK: { fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; } case DCCP_PKT_DATAACK: { fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; } case DCCP_PKT_CLOSEREQ: fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; case DCCP_PKT_CLOSE: fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; case DCCP_PKT_RESET: { const struct dccp_hdr_reset *dhr = (const struct dccp_hdr_reset *)(bp + fixed_hdrlen); fixed_hdrlen += 12; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_TCHECK(*dhr); ND_PRINT((ndo, "%s (code=%s) ", tok2str(dccp_pkt_type_str, "", dccph_type), dccp_reset_code(dhr->dccph_reset_code))); break; } case DCCP_PKT_SYNC: fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; case DCCP_PKT_SYNCACK: fixed_hdrlen += 8; if (len < fixed_hdrlen) { ND_PRINT((ndo, "truncated-%s - %u bytes missing!", tok2str(dccp_pkt_type_str, "", dccph_type), len - fixed_hdrlen)); return; } ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type))); break; default: ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "unknown-type-%u", dccph_type))); break; } if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) && (DCCPH_TYPE(dh) != DCCP_PKT_REQUEST)) dccp_print_ack_no(ndo, bp); if (ndo->ndo_vflag < 2) return; ND_PRINT((ndo, "seq %" PRIu64, dccp_seqno(bp))); /* process options */ if (hlen > fixed_hdrlen){ u_int optlen; cp = bp + fixed_hdrlen; ND_PRINT((ndo, " <")); hlen -= fixed_hdrlen; while(1){ optlen = dccp_print_option(ndo, cp, hlen); if (!optlen) break; if (hlen <= optlen) break; hlen -= optlen; cp += optlen; ND_PRINT((ndo, ", ")); } ND_PRINT((ndo, ">")); } return; trunc: ND_PRINT((ndo, "%s", tstr)); return; } static const struct tok dccp_option_values[] = { { 0, "nop" }, { 1, "mandatory" }, { 2, "slowreceiver" }, { 32, "change_l" }, { 33, "confirm_l" }, { 34, "change_r" }, { 35, "confirm_r" }, { 36, "initcookie" }, { 37, "ndp_count" }, { 38, "ack_vector0" }, { 39, "ack_vector1" }, { 40, "data_dropped" }, { 41, "timestamp" }, { 42, "timestamp_echo" }, { 43, "elapsed_time" }, { 44, "data_checksum" }, { 0, NULL } }; -static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) +static int +dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen) { uint8_t optlen, i; ND_TCHECK(*option); if (*option >= 32) { ND_TCHECK(*(option+1)); optlen = *(option +1); if (optlen < 2) { if (*option >= 128) ND_PRINT((ndo, "CCID option %u optlen too short", *option)); else ND_PRINT((ndo, "%s optlen too short", tok2str(dccp_option_values, "Option %u", *option))); return 0; } } else optlen = 1; if (hlen < optlen) { if (*option >= 128) ND_PRINT((ndo, "CCID option %u optlen goes past header length", *option)); else ND_PRINT((ndo, "%s optlen goes past header length", tok2str(dccp_option_values, "Option %u", *option))); return 0; } ND_TCHECK2(*option, optlen); if (*option >= 128) { ND_PRINT((ndo, "CCID option %d", *option)); switch (optlen) { case 4: ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2))); break; case 6: ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); break; default: break; } } else { ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", *option))); switch (*option) { case 32: case 33: case 34: case 35: if (optlen < 3) { ND_PRINT((ndo, " optlen too short")); return optlen; } if (*(option + 2) < 10){ ND_PRINT((ndo, " %s", dccp_feature_nums[*(option + 2)])); for (i = 0; i < optlen - 3; i++) ND_PRINT((ndo, " %d", *(option + 3 + i))); } break; case 36: if (optlen > 2) { ND_PRINT((ndo, " 0x")); for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, "%02x", *(option + 2 + i))); } break; case 37: for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, " %d", *(option + 2 + i))); break; case 38: if (optlen > 2) { ND_PRINT((ndo, " 0x")); for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, "%02x", *(option + 2 + i))); } break; case 39: if (optlen > 2) { ND_PRINT((ndo, " 0x")); for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, "%02x", *(option + 2 + i))); } break; case 40: if (optlen > 2) { ND_PRINT((ndo, " 0x")); for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, "%02x", *(option + 2 + i))); } break; case 41: - if (optlen == 4) + /* + * 13.1. Timestamp Option + * + * +--------+--------+--------+--------+--------+--------+ + * |00101001|00000110| Timestamp Value | + * +--------+--------+--------+--------+--------+--------+ + * Type=41 Length=6 + */ + if (optlen == 6) ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); else - ND_PRINT((ndo, " optlen != 4")); + ND_PRINT((ndo, " [optlen != 6]")); break; case 42: - if (optlen == 4) + /* + * 13.3. Timestamp Echo Option + * + * +--------+--------+--------+--------+--------+--------+ + * |00101010|00000110| Timestamp Echo | + * +--------+--------+--------+--------+--------+--------+ + * Type=42 Len=6 + * + * +--------+--------+------- ... -------+--------+--------+ + * |00101010|00001000| Timestamp Echo | Elapsed Time | + * +--------+--------+------- ... -------+--------+--------+ + * Type=42 Len=8 (4 bytes) + * + * +--------+--------+------- ... -------+------- ... -------+ + * |00101010|00001010| Timestamp Echo | Elapsed Time | + * +--------+--------+------- ... -------+------- ... -------+ + * Type=42 Len=10 (4 bytes) (4 bytes) + */ + switch (optlen) { + case 6: ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); - else - ND_PRINT((ndo, " optlen != 4")); + break; + case 8: + ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); + ND_PRINT((ndo, " (elapsed time %u)", EXTRACT_16BITS(option + 6))); + break; + case 10: + ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); + ND_PRINT((ndo, " (elapsed time %u)", EXTRACT_32BITS(option + 6))); + break; + default: + ND_PRINT((ndo, " [optlen != 6 or 8 or 10]")); + break; + } break; case 43: if (optlen == 6) ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2))); else if (optlen == 4) ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2))); else - ND_PRINT((ndo, " optlen != 4 or 6")); + ND_PRINT((ndo, " [optlen != 4 or 6]")); break; case 44: if (optlen > 2) { ND_PRINT((ndo, " ")); for (i = 0; i < optlen - 2; i++) ND_PRINT((ndo, "%02x", *(option + 2 + i))); } break; } } return optlen; trunc: ND_PRINT((ndo, "%s", tstr)); return 0; } Index: vendor/tcpdump/dist/print-decnet.c =================================================================== --- vendor/tcpdump/dist/print-decnet.c (revision 353143) +++ vendor/tcpdump/dist/print-decnet.c (revision 353144) @@ -1,1273 +1,1240 @@ /* * Copyright (c) 1992, 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. */ /* \summary: DECnet printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include struct mbuf; struct rtentry; -#ifdef HAVE_NETDNET_DNETDB_H -#include -#endif - #include #include #include #include "extract.h" #include "netdissect.h" #include "addrtoname.h" static const char tstr[] = "[|decnet]"; #ifndef _WIN32 typedef uint8_t byte[1]; /* single byte field */ #else /* * the keyword 'byte' generates conflicts in Windows */ typedef unsigned char Byte[1]; /* single byte field */ #define byte Byte #endif /* _WIN32 */ typedef uint8_t word[2]; /* 2 byte field */ typedef uint8_t longword[4]; /* 4 bytes field */ /* * Definitions for DECNET Phase IV protocol headers */ union etheraddress { uint8_t dne_addr[6]; /* full ethernet address */ struct { uint8_t dne_hiord[4]; /* DECnet HIORD prefix */ uint8_t dne_nodeaddr[2]; /* DECnet node address */ } dne_remote; }; typedef union etheraddress etheraddr; /* Ethernet address */ #define HIORD 0x000400aa /* high 32-bits of address (swapped) */ #define AREAMASK 0176000 /* mask for area field */ #define AREASHIFT 10 /* bit-offset for area field */ #define NODEMASK 01777 /* mask for node address field */ -#define DN_MAXADDL 20 /* max size of DECnet address */ -struct dn_naddr { - uint16_t a_len; /* length of address */ - uint8_t a_addr[DN_MAXADDL]; /* address as bytes */ -}; - /* * Define long and short header formats. */ struct shorthdr { byte sh_flags; /* route flags */ word sh_dst; /* destination node address */ word sh_src; /* source node address */ byte sh_visits; /* visit count */ }; struct longhdr { byte lg_flags; /* route flags */ byte lg_darea; /* destination area (reserved) */ byte lg_dsarea; /* destination subarea (reserved) */ etheraddr lg_dst; /* destination id */ byte lg_sarea; /* source area (reserved) */ byte lg_ssarea; /* source subarea (reserved) */ etheraddr lg_src; /* source id */ byte lg_nextl2; /* next level 2 router (reserved) */ byte lg_visits; /* visit count */ byte lg_service; /* service class (reserved) */ byte lg_pt; /* protocol type (reserved) */ }; union routehdr { struct shorthdr rh_short; /* short route header */ struct longhdr rh_long; /* long route header */ }; /* * Define the values of various fields in the protocol messages. * * 1. Data packet formats. */ #define RMF_MASK 7 /* mask for message type */ #define RMF_SHORT 2 /* short message format */ #define RMF_LONG 6 /* long message format */ #ifndef RMF_RQR #define RMF_RQR 010 /* request return to sender */ #define RMF_RTS 020 /* returning to sender */ #define RMF_IE 040 /* intra-ethernet packet */ #endif /* RMR_RQR */ #define RMF_FVER 0100 /* future version flag */ #define RMF_PAD 0200 /* pad field */ #define RMF_PADMASK 0177 /* pad field mask */ #define VIS_MASK 077 /* visit field mask */ /* * 2. Control packet formats. */ #define RMF_CTLMASK 017 /* mask for message type */ #define RMF_CTLMSG 01 /* control message indicator */ #define RMF_INIT 01 /* initialization message */ #define RMF_VER 03 /* verification message */ #define RMF_TEST 05 /* hello and test message */ #define RMF_L1ROUT 07 /* level 1 routing message */ #define RMF_L2ROUT 011 /* level 2 routing message */ #define RMF_RHELLO 013 /* router hello message */ #define RMF_EHELLO 015 /* endnode hello message */ #define TI_L2ROUT 01 /* level 2 router */ #define TI_L1ROUT 02 /* level 1 router */ #define TI_ENDNODE 03 /* endnode */ #define TI_VERIF 04 /* verification required */ #define TI_BLOCK 010 /* blocking requested */ #define VE_VERS 2 /* version number (2) */ #define VE_ECO 0 /* ECO number */ #define VE_UECO 0 /* user ECO number (0) */ #define P3_VERS 1 /* phase III version number (1) */ #define P3_ECO 3 /* ECO number (3) */ #define P3_UECO 0 /* user ECO number (0) */ #define II_L2ROUT 01 /* level 2 router */ #define II_L1ROUT 02 /* level 1 router */ #define II_ENDNODE 03 /* endnode */ #define II_VERIF 04 /* verification required */ #define II_NOMCAST 040 /* no multicast traffic accepted */ #define II_BLOCK 0100 /* blocking requested */ #define II_TYPEMASK 03 /* mask for node type */ #define TESTDATA 0252 /* test data bytes */ #define TESTLEN 1 /* length of transmitted test data */ /* * Define control message formats. */ struct initmsgIII /* phase III initialization message */ { byte inIII_flags; /* route flags */ word inIII_src; /* source node address */ byte inIII_info; /* routing layer information */ word inIII_blksize; /* maximum data link block size */ byte inIII_vers; /* version number */ byte inIII_eco; /* ECO number */ byte inIII_ueco; /* user ECO number */ byte inIII_rsvd; /* reserved image field */ }; struct initmsg /* initialization message */ { byte in_flags; /* route flags */ word in_src; /* source node address */ byte in_info; /* routing layer information */ word in_blksize; /* maximum data link block size */ byte in_vers; /* version number */ byte in_eco; /* ECO number */ byte in_ueco; /* user ECO number */ word in_hello; /* hello timer */ byte in_rsvd; /* reserved image field */ }; struct verifmsg /* verification message */ { byte ve_flags; /* route flags */ word ve_src; /* source node address */ byte ve_fcnval; /* function value image field */ }; struct testmsg /* hello and test message */ { byte te_flags; /* route flags */ word te_src; /* source node address */ byte te_data; /* test data image field */ }; struct l1rout /* level 1 routing message */ { byte r1_flags; /* route flags */ word r1_src; /* source node address */ byte r1_rsvd; /* reserved field */ }; struct l2rout /* level 2 routing message */ { byte r2_flags; /* route flags */ word r2_src; /* source node address */ byte r2_rsvd; /* reserved field */ }; struct rhellomsg /* router hello message */ { byte rh_flags; /* route flags */ byte rh_vers; /* version number */ byte rh_eco; /* ECO number */ byte rh_ueco; /* user ECO number */ etheraddr rh_src; /* source id */ byte rh_info; /* routing layer information */ word rh_blksize; /* maximum data link block size */ byte rh_priority; /* router's priority */ byte rh_area; /* reserved */ word rh_hello; /* hello timer */ byte rh_mpd; /* reserved */ }; struct ehellomsg /* endnode hello message */ { byte eh_flags; /* route flags */ byte eh_vers; /* version number */ byte eh_eco; /* ECO number */ byte eh_ueco; /* user ECO number */ etheraddr eh_src; /* source id */ byte eh_info; /* routing layer information */ word eh_blksize; /* maximum data link block size */ byte eh_area; /* area (reserved) */ byte eh_seed[8]; /* verification seed */ etheraddr eh_router; /* designated router */ word eh_hello; /* hello timer */ byte eh_mpd; /* (reserved) */ byte eh_data; /* test data image field */ }; union controlmsg { struct initmsg cm_init; /* initialization message */ struct verifmsg cm_ver; /* verification message */ struct testmsg cm_test; /* hello and test message */ struct l1rout cm_l1rou; /* level 1 routing message */ struct l2rout cm_l2rout; /* level 2 routing message */ struct rhellomsg cm_rhello; /* router hello message */ struct ehellomsg cm_ehello; /* endnode hello message */ }; /* Macros for decoding routing-info fields */ #define RI_COST(x) ((x)&0777) #define RI_HOPS(x) (((x)>>10)&037) /* * NSP protocol fields and values. */ #define NSP_TYPEMASK 014 /* mask to isolate type code */ #define NSP_SUBMASK 0160 /* mask to isolate subtype code */ #define NSP_SUBSHFT 4 /* shift to move subtype code */ #define MFT_DATA 0 /* data message */ #define MFT_ACK 04 /* acknowledgement message */ #define MFT_CTL 010 /* control message */ #define MFS_ILS 020 /* data or I/LS indicator */ #define MFS_BOM 040 /* beginning of message (data) */ #define MFS_MOM 0 /* middle of message (data) */ #define MFS_EOM 0100 /* end of message (data) */ #define MFS_INT 040 /* interrupt message */ #define MFS_DACK 0 /* data acknowledgement */ #define MFS_IACK 020 /* I/LS acknowledgement */ #define MFS_CACK 040 /* connect acknowledgement */ #define MFS_NOP 0 /* no operation */ #define MFS_CI 020 /* connect initiate */ #define MFS_CC 040 /* connect confirm */ #define MFS_DI 060 /* disconnect initiate */ #define MFS_DC 0100 /* disconnect confirm */ #define MFS_RCI 0140 /* retransmitted connect initiate */ #define SGQ_ACK 0100000 /* ack */ #define SGQ_NAK 0110000 /* negative ack */ #define SGQ_OACK 0120000 /* other channel ack */ #define SGQ_ONAK 0130000 /* other channel negative ack */ #define SGQ_MASK 07777 /* mask to isolate seq # */ #define SGQ_OTHER 020000 /* other channel qualifier */ #define SGQ_DELAY 010000 /* ack delay flag */ #define SGQ_EOM 0100000 /* pseudo flag for end-of-message */ #define LSM_MASK 03 /* mask for modifier field */ #define LSM_NOCHANGE 0 /* no change */ #define LSM_DONOTSEND 1 /* do not send data */ #define LSM_SEND 2 /* send data */ #define LSI_MASK 014 /* mask for interpretation field */ #define LSI_DATA 0 /* data segment or message count */ #define LSI_INTR 4 /* interrupt request count */ #define LSI_INTM 0377 /* funny marker for int. message */ #define COS_MASK 014 /* mask for flow control field */ #define COS_NONE 0 /* no flow control */ #define COS_SEGMENT 04 /* segment flow control */ #define COS_MESSAGE 010 /* message flow control */ #define COS_DEFAULT 1 /* default value for field */ #define COI_MASK 3 /* mask for version field */ #define COI_32 0 /* version 3.2 */ #define COI_31 1 /* version 3.1 */ #define COI_40 2 /* version 4.0 */ #define COI_41 3 /* version 4.1 */ #define MNU_MASK 140 /* mask for session control version */ #define MNU_10 000 /* session V1.0 */ #define MNU_20 040 /* session V2.0 */ #define MNU_ACCESS 1 /* access control present */ #define MNU_USRDATA 2 /* user data field present */ #define MNU_INVKPROXY 4 /* invoke proxy field present */ #define MNU_UICPROXY 8 /* use uic-based proxy */ #define DC_NORESOURCES 1 /* no resource reason code */ #define DC_NOLINK 41 /* no link terminate reason code */ #define DC_COMPLETE 42 /* disconnect complete reason code */ #define DI_NOERROR 0 /* user disconnect */ #define DI_SHUT 3 /* node is shutting down */ #define DI_NOUSER 4 /* destination end user does not exist */ #define DI_INVDEST 5 /* invalid end user destination */ #define DI_REMRESRC 6 /* insufficient remote resources */ #define DI_TPA 8 /* third party abort */ #define DI_PROTOCOL 7 /* protocol error discovered */ #define DI_ABORT 9 /* user abort */ #define DI_LOCALRESRC 32 /* insufficient local resources */ #define DI_REMUSERRESRC 33 /* insufficient remote user resources */ #define DI_BADACCESS 34 /* bad access control information */ #define DI_BADACCNT 36 /* bad ACCOUNT information */ #define DI_CONNECTABORT 38 /* connect request cancelled */ #define DI_TIMEDOUT 38 /* remote node or user crashed */ #define DI_UNREACHABLE 39 /* local timers expired due to ... */ #define DI_BADIMAGE 43 /* bad image data in connect */ #define DI_SERVMISMATCH 54 /* cryptographic service mismatch */ #define UC_OBJREJECT 0 /* object rejected connect */ #define UC_USERDISCONNECT 0 /* user disconnect */ #define UC_RESOURCES 1 /* insufficient resources (local or remote) */ #define UC_NOSUCHNODE 2 /* unrecognized node name */ #define UC_REMOTESHUT 3 /* remote node shutting down */ #define UC_NOSUCHOBJ 4 /* unrecognized object */ #define UC_INVOBJFORMAT 5 /* invalid object name format */ #define UC_OBJTOOBUSY 6 /* object too busy */ #define UC_NETWORKABORT 8 /* network abort */ #define UC_USERABORT 9 /* user abort */ #define UC_INVNODEFORMAT 10 /* invalid node name format */ #define UC_LOCALSHUT 11 /* local node shutting down */ #define UC_ACCESSREJECT 34 /* invalid access control information */ #define UC_NORESPONSE 38 /* no response from object */ #define UC_UNREACHABLE 39 /* node unreachable */ /* * NSP message formats. */ struct nsphdr /* general nsp header */ { byte nh_flags; /* message flags */ word nh_dst; /* destination link address */ word nh_src; /* source link address */ }; struct seghdr /* data segment header */ { byte sh_flags; /* message flags */ word sh_dst; /* destination link address */ word sh_src; /* source link address */ word sh_seq[3]; /* sequence numbers */ }; struct minseghdr /* minimum data segment header */ { byte ms_flags; /* message flags */ word ms_dst; /* destination link address */ word ms_src; /* source link address */ word ms_seq; /* sequence number */ }; struct lsmsg /* link service message (after hdr) */ { byte ls_lsflags; /* link service flags */ byte ls_fcval; /* flow control value */ }; struct ackmsg /* acknowledgement message */ { byte ak_flags; /* message flags */ word ak_dst; /* destination link address */ word ak_src; /* source link address */ word ak_acknum[2]; /* acknowledgement numbers */ }; struct minackmsg /* minimum acknowledgement message */ { byte mk_flags; /* message flags */ word mk_dst; /* destination link address */ word mk_src; /* source link address */ word mk_acknum; /* acknowledgement number */ }; struct ciackmsg /* connect acknowledgement message */ { byte ck_flags; /* message flags */ word ck_dst; /* destination link address */ }; struct cimsg /* connect initiate message */ { byte ci_flags; /* message flags */ word ci_dst; /* destination link address (0) */ word ci_src; /* source link address */ byte ci_services; /* requested services */ byte ci_info; /* information */ word ci_segsize; /* maximum segment size */ }; struct ccmsg /* connect confirm message */ { byte cc_flags; /* message flags */ word cc_dst; /* destination link address */ word cc_src; /* source link address */ byte cc_services; /* requested services */ byte cc_info; /* information */ word cc_segsize; /* maximum segment size */ byte cc_optlen; /* optional data length */ }; struct cnmsg /* generic connect message */ { byte cn_flags; /* message flags */ word cn_dst; /* destination link address */ word cn_src; /* source link address */ byte cn_services; /* requested services */ byte cn_info; /* information */ word cn_segsize; /* maximum segment size */ }; struct dimsg /* disconnect initiate message */ { byte di_flags; /* message flags */ word di_dst; /* destination link address */ word di_src; /* source link address */ word di_reason; /* reason code */ byte di_optlen; /* optional data length */ }; struct dcmsg /* disconnect confirm message */ { byte dc_flags; /* message flags */ word dc_dst; /* destination link address */ word dc_src; /* source link address */ word dc_reason; /* reason code */ }; /* Forwards */ static int print_decnet_ctlmsg(netdissect_options *, const union routehdr *, u_int, u_int); static void print_t_info(netdissect_options *, int); static int print_l1_routes(netdissect_options *, const char *, u_int); static int print_l2_routes(netdissect_options *, const char *, u_int); static void print_i_info(netdissect_options *, int); static int print_elist(const char *, u_int); static int print_nsp(netdissect_options *, const u_char *, u_int); static void print_reason(netdissect_options *, int); -#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA -extern char *dnet_htoa(struct dn_naddr *); -#endif - void decnet_print(netdissect_options *ndo, register const u_char *ap, register u_int length, register u_int caplen) { register const union routehdr *rhp; register int mflags; int dst, src, hops; u_int nsplen, pktlen; const u_char *nspp; if (length < sizeof(struct shorthdr)) { ND_PRINT((ndo, "%s", tstr)); return; } ND_TCHECK2(*ap, sizeof(short)); pktlen = EXTRACT_LE_16BITS(ap); if (pktlen < sizeof(struct shorthdr)) { ND_PRINT((ndo, "%s", tstr)); return; } if (pktlen > length) { ND_PRINT((ndo, "%s", tstr)); return; } length = pktlen; rhp = (const union routehdr *)&(ap[sizeof(short)]); ND_TCHECK(rhp->rh_short.sh_flags); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); if (mflags & RMF_PAD) { /* pad bytes of some sort in front of message */ u_int padlen = mflags & RMF_PADMASK; if (ndo->ndo_vflag) ND_PRINT((ndo, "[pad:%d] ", padlen)); if (length < padlen + 2) { ND_PRINT((ndo, "%s", tstr)); return; } ND_TCHECK2(ap[sizeof(short)], padlen); ap += padlen; length -= padlen; caplen -= padlen; rhp = (const union routehdr *)&(ap[sizeof(short)]); ND_TCHECK(rhp->rh_short.sh_flags); mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); } if (mflags & RMF_FVER) { ND_PRINT((ndo, "future-version-decnet")); ND_DEFAULTPRINT(ap, min(length, caplen)); return; } /* is it a control message? */ if (mflags & RMF_CTLMSG) { if (!print_decnet_ctlmsg(ndo, rhp, length, caplen)) goto trunc; return; } switch (mflags & RMF_MASK) { case RMF_LONG: if (length < sizeof(struct longhdr)) { ND_PRINT((ndo, "%s", tstr)); return; } ND_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 = length - sizeof(struct longhdr); break; case RMF_SHORT: ND_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 = length - sizeof(struct shorthdr); break; default: ND_PRINT((ndo, "unknown message flags under mask")); ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen)); return; } ND_PRINT((ndo, "%s > %s %d ", dnaddr_string(ndo, src), dnaddr_string(ndo, dst), pktlen)); if (ndo->ndo_vflag) { if (mflags & RMF_RQR) ND_PRINT((ndo, "RQR ")); if (mflags & RMF_RTS) ND_PRINT((ndo, "RTS ")); if (mflags & RMF_IE) ND_PRINT((ndo, "IE ")); ND_PRINT((ndo, "%d hops ", hops)); } if (!print_nsp(ndo, nspp, nsplen)) goto trunc; return; trunc: ND_PRINT((ndo, "%s", tstr)); return; } static int print_decnet_ctlmsg(netdissect_options *ndo, register const union routehdr *rhp, u_int length, u_int caplen) { /* Our caller has already checked for mflags */ int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags); register const union controlmsg *cmp = (const union controlmsg *)rhp; int src, dst, info, blksize, eco, ueco, hello, other, vers; etheraddr srcea, rtea; int priority; const char *rhpx = (const char *)rhp; int ret; switch (mflags & RMF_CTLMASK) { case RMF_INIT: ND_PRINT((ndo, "init ")); if (length < sizeof(struct initmsg)) goto trunc; ND_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); vers = EXTRACT_LE_8BITS(cmp->cm_init.in_vers); eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco); ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco); hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello); print_t_info(ndo, info); ND_PRINT((ndo, "src %sblksize %d vers %d eco %d ueco %d hello %d", dnaddr_string(ndo, src), blksize, vers, eco, ueco, hello)); ret = 1; break; case RMF_VER: ND_PRINT((ndo, "verification ")); if (length < sizeof(struct verifmsg)) goto trunc; ND_TCHECK(cmp->cm_ver); src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src); other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval); ND_PRINT((ndo, "src %s fcnval %o", dnaddr_string(ndo, src), other)); ret = 1; break; case RMF_TEST: ND_PRINT((ndo, "test ")); if (length < sizeof(struct testmsg)) goto trunc; ND_TCHECK(cmp->cm_test); src = EXTRACT_LE_16BITS(cmp->cm_test.te_src); other = EXTRACT_LE_8BITS(cmp->cm_test.te_data); ND_PRINT((ndo, "src %s data %o", dnaddr_string(ndo, src), other)); ret = 1; break; case RMF_L1ROUT: ND_PRINT((ndo, "lev-1-routing ")); if (length < sizeof(struct l1rout)) goto trunc; ND_TCHECK(cmp->cm_l1rou); src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src); ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src))); ret = print_l1_routes(ndo, &(rhpx[sizeof(struct l1rout)]), length - sizeof(struct l1rout)); break; case RMF_L2ROUT: ND_PRINT((ndo, "lev-2-routing ")); if (length < sizeof(struct l2rout)) goto trunc; ND_TCHECK(cmp->cm_l2rout); src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src); ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src))); ret = print_l2_routes(ndo, &(rhpx[sizeof(struct l2rout)]), length - sizeof(struct l2rout)); break; case RMF_RHELLO: ND_PRINT((ndo, "router-hello ")); if (length < sizeof(struct rhellomsg)) goto trunc; ND_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); memcpy((char *)&srcea, (const char *)&(cmp->cm_rhello.rh_src), sizeof(srcea)); src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info); blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize); priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority); hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello); print_i_info(ndo, info); ND_PRINT((ndo, "vers %d eco %d ueco %d src %s blksize %d pri %d hello %d", vers, eco, ueco, dnaddr_string(ndo, src), blksize, priority, hello)); ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]), length - sizeof(struct rhellomsg)); break; case RMF_EHELLO: ND_PRINT((ndo, "endnode-hello ")); if (length < sizeof(struct ehellomsg)) goto trunc; ND_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); memcpy((char *)&srcea, (const char *)&(cmp->cm_ehello.eh_src), sizeof(srcea)); src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr); info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info); blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize); /*seed*/ memcpy((char *)&rtea, (const char *)&(cmp->cm_ehello.eh_router), sizeof(rtea)); dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr); hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello); other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data); print_i_info(ndo, info); ND_PRINT((ndo, "vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o", vers, eco, ueco, dnaddr_string(ndo, src), blksize, dnaddr_string(ndo, dst), hello, other)); ret = 1; break; default: ND_PRINT((ndo, "unknown control message")); ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen)); ret = 1; break; } return (ret); trunc: return (0); } static void print_t_info(netdissect_options *ndo, int info) { int ntype = info & 3; switch (ntype) { case 0: ND_PRINT((ndo, "reserved-ntype? ")); break; case TI_L2ROUT: ND_PRINT((ndo, "l2rout ")); break; case TI_L1ROUT: ND_PRINT((ndo, "l1rout ")); break; case TI_ENDNODE: ND_PRINT((ndo, "endnode ")); break; } if (info & TI_VERIF) ND_PRINT((ndo, "verif ")); if (info & TI_BLOCK) ND_PRINT((ndo, "blo ")); } static int print_l1_routes(netdissect_options *ndo, const char *rp, u_int len) { int count; int id; int info; /* The last short is a checksum */ while (len > (3 * sizeof(short))) { ND_TCHECK2(*rp, 3 * sizeof(short)); count = EXTRACT_LE_16BITS(rp); if (count > 1024) return (1); /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); id = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); info = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); ND_PRINT((ndo, "{ids %d-%d cost %d hops %d} ", id, id + count, RI_COST(info), RI_HOPS(info))); } return (1); trunc: return (0); } static int print_l2_routes(netdissect_options *ndo, const char *rp, u_int len) { int count; int area; int info; /* The last short is a checksum */ while (len > (3 * sizeof(short))) { ND_TCHECK2(*rp, 3 * sizeof(short)); count = EXTRACT_LE_16BITS(rp); if (count > 1024) return (1); /* seems to be bogus from here on */ rp += sizeof(short); len -= sizeof(short); area = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); info = EXTRACT_LE_16BITS(rp); rp += sizeof(short); len -= sizeof(short); ND_PRINT((ndo, "{areas %d-%d cost %d hops %d} ", area, area + count, RI_COST(info), RI_HOPS(info))); } return (1); trunc: return (0); } static void print_i_info(netdissect_options *ndo, int info) { int ntype = info & II_TYPEMASK; switch (ntype) { case 0: ND_PRINT((ndo, "reserved-ntype? ")); break; case II_L2ROUT: ND_PRINT((ndo, "l2rout ")); break; case II_L1ROUT: ND_PRINT((ndo, "l1rout ")); break; case II_ENDNODE: ND_PRINT((ndo, "endnode ")); break; } if (info & II_VERIF) ND_PRINT((ndo, "verif ")); if (info & II_NOMCAST) ND_PRINT((ndo, "nomcast ")); if (info & II_BLOCK) ND_PRINT((ndo, "blo ")); } static int print_elist(const char *elp _U_, u_int len _U_) { /* Not enough examples available for me to debug this */ return (1); } static int print_nsp(netdissect_options *ndo, const u_char *nspp, u_int nsplen) { const struct nsphdr *nsphp = (const struct nsphdr *)nspp; int dst, src, flags; if (nsplen < sizeof(struct nsphdr)) goto trunc; ND_TCHECK(*nsphp); flags = EXTRACT_LE_8BITS(nsphp->nh_flags); dst = EXTRACT_LE_16BITS(nsphp->nh_dst); src = EXTRACT_LE_16BITS(nsphp->nh_src); switch (flags & NSP_TYPEMASK) { case MFT_DATA: switch (flags & NSP_SUBMASK) { case MFS_BOM: case MFS_MOM: case MFS_EOM: case MFS_BOM+MFS_EOM: ND_PRINT((ndo, "data %d>%d ", src, dst)); { const struct seghdr *shp = (const struct seghdr *)nspp; int ack; u_int data_off = sizeof(struct minseghdr); if (nsplen < data_off) goto trunc; ND_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) ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK)); data_off += sizeof(short); if (nsplen < data_off) goto trunc; ND_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) ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK)); data_off += sizeof(short); if (nsplen < data_off) goto trunc; ND_TCHECK(shp->sh_seq[2]); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK)); } break; case MFS_ILS+MFS_INT: ND_PRINT((ndo, "intr ")); { const struct seghdr *shp = (const struct seghdr *)nspp; int ack; u_int data_off = sizeof(struct minseghdr); if (nsplen < data_off) goto trunc; ND_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) ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK)); data_off += sizeof(short); if (nsplen < data_off) goto trunc; ND_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) ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK)); data_off += sizeof(short); if (nsplen < data_off) goto trunc; ND_TCHECK(shp->sh_seq[2]); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK)); } break; case MFS_ILS: ND_PRINT((ndo, "link-service %d>%d ", src, dst)); { const struct seghdr *shp = (const struct seghdr *)nspp; const struct lsmsg *lsmp = (const struct lsmsg *)&(nspp[sizeof(struct seghdr)]); int ack; int lsflags, fcval; if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg)) goto trunc; ND_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) ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK)); ND_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) ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK)); ND_TCHECK(shp->sh_seq[2]); ack = EXTRACT_LE_16BITS(shp->sh_seq[2]); } } ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK)); ND_TCHECK(*lsmp); lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags); fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval); switch (lsflags & LSI_MASK) { case LSI_DATA: ND_PRINT((ndo, "dat seg count %d ", fcval)); switch (lsflags & LSM_MASK) { case LSM_NOCHANGE: break; case LSM_DONOTSEND: ND_PRINT((ndo, "donotsend-data ")); break; case LSM_SEND: ND_PRINT((ndo, "send-data ")); break; default: ND_PRINT((ndo, "reserved-fcmod? %x", lsflags)); break; } break; case LSI_INTR: ND_PRINT((ndo, "intr req count %d ", fcval)); break; default: ND_PRINT((ndo, "reserved-fcval-int? %x", lsflags)); break; } } break; default: ND_PRINT((ndo, "reserved-subtype? %x %d > %d", flags, src, dst)); break; } break; case MFT_ACK: switch (flags & NSP_SUBMASK) { case MFS_DACK: ND_PRINT((ndo, "data-ack %d>%d ", src, dst)); { const struct ackmsg *amp = (const struct ackmsg *)nspp; int ack; if (nsplen < sizeof(struct ackmsg)) goto trunc; ND_TCHECK(*amp); ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK)); ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]); if (ack & SGQ_OACK) { /* ackoth field */ if ((ack & SGQ_ONAK) == SGQ_ONAK) ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK)); } } } break; case MFS_IACK: ND_PRINT((ndo, "ils-ack %d>%d ", src, dst)); { const struct ackmsg *amp = (const struct ackmsg *)nspp; int ack; if (nsplen < sizeof(struct ackmsg)) goto trunc; ND_TCHECK(*amp); ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]); if (ack & SGQ_ACK) { /* acknum field */ if ((ack & SGQ_NAK) == SGQ_NAK) ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK)); ND_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) ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK)); else ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK)); } } } break; case MFS_CACK: ND_PRINT((ndo, "conn-ack %d", dst)); break; default: ND_PRINT((ndo, "reserved-acktype? %x %d > %d", flags, src, dst)); break; } break; case MFT_CTL: switch (flags & NSP_SUBMASK) { case MFS_CI: case MFS_RCI: if ((flags & NSP_SUBMASK) == MFS_CI) ND_PRINT((ndo, "conn-initiate ")); else ND_PRINT((ndo, "retrans-conn-initiate ")); ND_PRINT((ndo, "%d>%d ", src, dst)); { const struct cimsg *cimp = (const struct cimsg *)nspp; int services, info, segsize; if (nsplen < sizeof(struct cimsg)) goto trunc; ND_TCHECK(*cimp); services = EXTRACT_LE_8BITS(cimp->ci_services); info = EXTRACT_LE_8BITS(cimp->ci_info); segsize = EXTRACT_LE_16BITS(cimp->ci_segsize); switch (services & COS_MASK) { case COS_NONE: break; case COS_SEGMENT: ND_PRINT((ndo, "seg ")); break; case COS_MESSAGE: ND_PRINT((ndo, "msg ")); break; } switch (info & COI_MASK) { case COI_32: ND_PRINT((ndo, "ver 3.2 ")); break; case COI_31: ND_PRINT((ndo, "ver 3.1 ")); break; case COI_40: ND_PRINT((ndo, "ver 4.0 ")); break; case COI_41: ND_PRINT((ndo, "ver 4.1 ")); break; } ND_PRINT((ndo, "segsize %d ", segsize)); } break; case MFS_CC: ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst)); { const struct ccmsg *ccmp = (const struct ccmsg *)nspp; int services, info; u_int segsize, optlen; if (nsplen < sizeof(struct ccmsg)) goto trunc; ND_TCHECK(*ccmp); services = EXTRACT_LE_8BITS(ccmp->cc_services); info = EXTRACT_LE_8BITS(ccmp->cc_info); segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize); optlen = EXTRACT_LE_8BITS(ccmp->cc_optlen); switch (services & COS_MASK) { case COS_NONE: break; case COS_SEGMENT: ND_PRINT((ndo, "seg ")); break; case COS_MESSAGE: ND_PRINT((ndo, "msg ")); break; } switch (info & COI_MASK) { case COI_32: ND_PRINT((ndo, "ver 3.2 ")); break; case COI_31: ND_PRINT((ndo, "ver 3.1 ")); break; case COI_40: ND_PRINT((ndo, "ver 4.0 ")); break; case COI_41: ND_PRINT((ndo, "ver 4.1 ")); break; } ND_PRINT((ndo, "segsize %d ", segsize)); if (optlen) { ND_PRINT((ndo, "optlen %d ", optlen)); } } break; case MFS_DI: ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst)); { const struct dimsg *dimp = (const struct dimsg *)nspp; int reason; u_int optlen; if (nsplen < sizeof(struct dimsg)) goto trunc; ND_TCHECK(*dimp); reason = EXTRACT_LE_16BITS(dimp->di_reason); optlen = EXTRACT_LE_8BITS(dimp->di_optlen); print_reason(ndo, reason); if (optlen) { ND_PRINT((ndo, "optlen %d ", optlen)); } } break; case MFS_DC: ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst)); { const struct dcmsg *dcmp = (const struct dcmsg *)nspp; int reason; ND_TCHECK(*dcmp); reason = EXTRACT_LE_16BITS(dcmp->dc_reason); print_reason(ndo, reason); } break; default: ND_PRINT((ndo, "reserved-ctltype? %x %d > %d", flags, src, dst)); break; } break; default: ND_PRINT((ndo, "reserved-type? %x %d > %d", flags, src, dst)); break; } return (1); trunc: return (0); } static const struct tok reason2str[] = { { UC_OBJREJECT, "object rejected connect" }, { UC_RESOURCES, "insufficient resources" }, { UC_NOSUCHNODE, "unrecognized node name" }, { DI_SHUT, "node is shutting down" }, { UC_NOSUCHOBJ, "unrecognized object" }, { UC_INVOBJFORMAT, "invalid object name format" }, { UC_OBJTOOBUSY, "object too busy" }, { DI_PROTOCOL, "protocol error discovered" }, { DI_TPA, "third party abort" }, { UC_USERABORT, "user abort" }, { UC_INVNODEFORMAT, "invalid node name format" }, { UC_LOCALSHUT, "local node shutting down" }, { DI_LOCALRESRC, "insufficient local resources" }, { DI_REMUSERRESRC, "insufficient remote user resources" }, { UC_ACCESSREJECT, "invalid access control information" }, { DI_BADACCNT, "bad ACCOUNT information" }, { UC_NORESPONSE, "no response from object" }, { UC_UNREACHABLE, "node unreachable" }, { DC_NOLINK, "no link terminate" }, { DC_COMPLETE, "disconnect complete" }, { DI_BADIMAGE, "bad image data in connect" }, { DI_SERVMISMATCH, "cryptographic service mismatch" }, { 0, NULL } }; static void print_reason(netdissect_options *ndo, register int reason) { ND_PRINT((ndo, "%s ", tok2str(reason2str, "reason-%d", reason))); } const char * dnnum_string(netdissect_options *ndo, u_short dnaddr) { char *str; size_t siz; int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT; int node = dnaddr & NODEMASK; str = (char *)malloc(siz = sizeof("00.0000")); if (str == NULL) (*ndo->ndo_error)(ndo, "dnnum_string: malloc"); snprintf(str, siz, "%d.%d", area, node); return(str); -} - -const char * -dnname_string(netdissect_options *ndo, u_short dnaddr) -{ -#ifdef HAVE_DNET_HTOA - struct dn_naddr dna; - char *dnname; - - dna.a_len = sizeof(short); - memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short)); - dnname = dnet_htoa(&dna); - if(dnname != NULL) - return (strdup(dnname)); - else - return(dnnum_string(ndo, dnaddr)); -#else - return(dnnum_string(ndo, dnaddr)); /* punt */ -#endif } Index: vendor/tcpdump/dist/print-domain.c =================================================================== --- vendor/tcpdump/dist/print-domain.c (revision 353143) +++ vendor/tcpdump/dist/print-domain.c (revision 353144) @@ -1,749 +1,756 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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. */ /* \summary: Domain Name System (DNS) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "nameser.h" #include #include "netdissect.h" #include "addrtoname.h" #include "addrtostr.h" #include "extract.h" static const char *ns_ops[] = { "", " inv_q", " stat", " op3", " notify", " update", " op6", " op7", " op8", " updateA", " updateD", " updateDA", " updateM", " updateMA", " zoneInit", " zoneRef", }; static const char *ns_resp[] = { "", " FormErr", " ServFail", " NXDomain", " NotImp", " Refused", " YXDomain", " YXRRSet", " NXRRSet", " NotAuth", " NotZone", " Resp11", " Resp12", " Resp13", " Resp14", " NoChange", }; /* skip over a domain name */ static const u_char * ns_nskip(netdissect_options *ndo, register const u_char *cp) { register u_char i; if (!ND_TTEST2(*cp, 1)) return (NULL); i = *cp++; while (i) { if ((i & INDIR_MASK) == INDIR_MASK) return (cp + 1); if ((i & INDIR_MASK) == EDNS0_MASK) { int bitlen, bytelen; if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL) return(NULL); /* unknown ELT */ if (!ND_TTEST2(*cp, 1)) return (NULL); if ((bitlen = *cp++) == 0) bitlen = 256; bytelen = (bitlen + 7) / 8; cp += bytelen; } else cp += i; if (!ND_TTEST2(*cp, 1)) return (NULL); i = *cp++; } return (cp); } /* print a */ static const u_char * blabel_print(netdissect_options *ndo, const u_char *cp) { int bitlen, slen, b; const u_char *bitp, *lim; char tc; if (!ND_TTEST2(*cp, 1)) return(NULL); if ((bitlen = *cp) == 0) bitlen = 256; slen = (bitlen + 3) / 4; lim = cp + 1 + slen; /* print the bit string as a hex string */ ND_PRINT((ndo, "\\[x")); for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) { ND_TCHECK(*bitp); ND_PRINT((ndo, "%02x", *bitp)); } if (b > 4) { ND_TCHECK(*bitp); tc = *bitp++; ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b)))); } else if (b > 0) { ND_TCHECK(*bitp); tc = *bitp++; ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)))); } ND_PRINT((ndo, "/%d]", bitlen)); return lim; trunc: ND_PRINT((ndo, ".../%d]", bitlen)); return NULL; } static int labellen(netdissect_options *ndo, const u_char *cp) { register u_int i; if (!ND_TTEST2(*cp, 1)) return(-1); i = *cp; if ((i & INDIR_MASK) == EDNS0_MASK) { int bitlen, elt; if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) { ND_PRINT((ndo, "", elt)); return(-1); } if (!ND_TTEST2(*(cp + 1), 1)) return(-1); if ((bitlen = *(cp + 1)) == 0) bitlen = 256; return(((bitlen + 7) / 8) + 1); } else return(i); } const u_char * ns_nprint(netdissect_options *ndo, register const u_char *cp, register const u_char *bp) { register u_int i, l; register const u_char *rp = NULL; register int compress = 0; int elt; u_int offset, max_offset; if ((l = labellen(ndo, cp)) == (u_int)-1) return(NULL); if (!ND_TTEST2(*cp, 1)) return(NULL); max_offset = (u_int)(cp - bp); if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) { compress = 0; rp = cp + l; } if (i != 0) while (i && cp < ndo->ndo_snapend) { if ((i & INDIR_MASK) == INDIR_MASK) { if (!compress) { rp = cp + 1; compress = 1; } if (!ND_TTEST2(*cp, 1)) return(NULL); offset = (((i << 8) | *cp) & 0x3fff); /* * This must move backwards in the packet. * No RFC explicitly says that, but BIND's * name decompression code requires it, * as a way of preventing infinite loops * and other bad behavior, and it's probably * what was intended (compress by pointing * to domain name suffixes already seen in * the packet). */ if (offset >= max_offset) { ND_PRINT((ndo, "")); return(NULL); } max_offset = offset; cp = bp + offset; if ((l = labellen(ndo, cp)) == (u_int)-1) return(NULL); if (!ND_TTEST2(*cp, 1)) return(NULL); i = *cp++; continue; } if ((i & INDIR_MASK) == EDNS0_MASK) { elt = (i & ~INDIR_MASK); switch(elt) { case EDNS0_ELT_BITLABEL: if (blabel_print(ndo, cp) == NULL) return (NULL); break; default: /* unknown ELT */ ND_PRINT((ndo, "", elt)); return(NULL); } } else { if (fn_printn(ndo, cp, l, ndo->ndo_snapend)) return(NULL); } cp += l; ND_PRINT((ndo, ".")); if ((l = labellen(ndo, cp)) == (u_int)-1) return(NULL); if (!ND_TTEST2(*cp, 1)) return(NULL); i = *cp++; if (!compress) rp += l + 1; } else ND_PRINT((ndo, ".")); return (rp); } /* print a */ static const u_char * ns_cprint(netdissect_options *ndo, register const u_char *cp) { register u_int i; if (!ND_TTEST2(*cp, 1)) return (NULL); i = *cp++; if (fn_printn(ndo, cp, i, ndo->ndo_snapend)) return (NULL); return (cp + i); } /* http://www.iana.org/assignments/dns-parameters */ const struct tok ns_type2str[] = { { T_A, "A" }, /* RFC 1035 */ { T_NS, "NS" }, /* RFC 1035 */ { T_MD, "MD" }, /* RFC 1035 */ { T_MF, "MF" }, /* RFC 1035 */ { T_CNAME, "CNAME" }, /* RFC 1035 */ { T_SOA, "SOA" }, /* RFC 1035 */ { T_MB, "MB" }, /* RFC 1035 */ { T_MG, "MG" }, /* RFC 1035 */ { T_MR, "MR" }, /* RFC 1035 */ { T_NULL, "NULL" }, /* RFC 1035 */ { T_WKS, "WKS" }, /* RFC 1035 */ { T_PTR, "PTR" }, /* RFC 1035 */ { T_HINFO, "HINFO" }, /* RFC 1035 */ { T_MINFO, "MINFO" }, /* RFC 1035 */ { T_MX, "MX" }, /* RFC 1035 */ { T_TXT, "TXT" }, /* RFC 1035 */ { T_RP, "RP" }, /* RFC 1183 */ { T_AFSDB, "AFSDB" }, /* RFC 1183 */ { T_X25, "X25" }, /* RFC 1183 */ { T_ISDN, "ISDN" }, /* RFC 1183 */ { T_RT, "RT" }, /* RFC 1183 */ { T_NSAP, "NSAP" }, /* RFC 1706 */ { T_NSAP_PTR, "NSAP_PTR" }, { T_SIG, "SIG" }, /* RFC 2535 */ { T_KEY, "KEY" }, /* RFC 2535 */ { T_PX, "PX" }, /* RFC 2163 */ { T_GPOS, "GPOS" }, /* RFC 1712 */ { T_AAAA, "AAAA" }, /* RFC 1886 */ { T_LOC, "LOC" }, /* RFC 1876 */ { T_NXT, "NXT" }, /* RFC 2535 */ { T_EID, "EID" }, /* Nimrod */ { T_NIMLOC, "NIMLOC" }, /* Nimrod */ { T_SRV, "SRV" }, /* RFC 2782 */ { T_ATMA, "ATMA" }, /* ATM Forum */ { T_NAPTR, "NAPTR" }, /* RFC 2168, RFC 2915 */ { T_KX, "KX" }, /* RFC 2230 */ { T_CERT, "CERT" }, /* RFC 2538 */ { T_A6, "A6" }, /* RFC 2874 */ { T_DNAME, "DNAME" }, /* RFC 2672 */ { T_SINK, "SINK" }, { T_OPT, "OPT" }, /* RFC 2671 */ { T_APL, "APL" }, /* RFC 3123 */ { T_DS, "DS" }, /* RFC 4034 */ { T_SSHFP, "SSHFP" }, /* RFC 4255 */ { T_IPSECKEY, "IPSECKEY" }, /* RFC 4025 */ { T_RRSIG, "RRSIG" }, /* RFC 4034 */ { T_NSEC, "NSEC" }, /* RFC 4034 */ { T_DNSKEY, "DNSKEY" }, /* RFC 4034 */ { T_SPF, "SPF" }, /* RFC-schlitt-spf-classic-02.txt */ { T_UINFO, "UINFO" }, { T_UID, "UID" }, { T_GID, "GID" }, { T_UNSPEC, "UNSPEC" }, { T_UNSPECA, "UNSPECA" }, { T_TKEY, "TKEY" }, /* RFC 2930 */ { T_TSIG, "TSIG" }, /* RFC 2845 */ { T_IXFR, "IXFR" }, /* RFC 1995 */ { T_AXFR, "AXFR" }, /* RFC 1035 */ { T_MAILB, "MAILB" }, /* RFC 1035 */ { T_MAILA, "MAILA" }, /* RFC 1035 */ { T_ANY, "ANY" }, { 0, NULL } }; const struct tok ns_class2str[] = { { C_IN, "IN" }, /* Not used */ { C_CHAOS, "CHAOS" }, { C_HS, "HS" }, { C_ANY, "ANY" }, { 0, NULL } }; /* print a query */ static const u_char * ns_qprint(netdissect_options *ndo, register const u_char *cp, register const u_char *bp, int is_mdns) { register const u_char *np = cp; register u_int i, class; cp = ns_nskip(ndo, cp); if (cp == NULL || !ND_TTEST2(*cp, 4)) return(NULL); /* print the qtype */ i = EXTRACT_16BITS(cp); cp += 2; ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", i))); /* print the qclass (if it's not IN) */ i = EXTRACT_16BITS(cp); cp += 2; if (is_mdns) class = (i & ~C_QU); else class = i; if (class != C_IN) ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class))); if (is_mdns) { ND_PRINT((ndo, i & C_QU ? " (QU)" : " (QM)")); } ND_PRINT((ndo, "? ")); cp = ns_nprint(ndo, np, bp); return(cp ? cp + 4 : NULL); } /* print a reply */ static const u_char * ns_rprint(netdissect_options *ndo, register const u_char *cp, register const u_char *bp, int is_mdns) { register u_int i, class, opt_flags = 0; register u_short typ, len; register const u_char *rp; if (ndo->ndo_vflag) { ND_PRINT((ndo, " ")); if ((cp = ns_nprint(ndo, cp, bp)) == NULL) return NULL; } else cp = ns_nskip(ndo, cp); if (cp == NULL || !ND_TTEST2(*cp, 10)) return (ndo->ndo_snapend); /* print the type/qtype */ typ = EXTRACT_16BITS(cp); cp += 2; /* print the class (if it's not IN and the type isn't OPT) */ i = EXTRACT_16BITS(cp); cp += 2; if (is_mdns) class = (i & ~C_CACHE_FLUSH); else class = i; if (class != C_IN && typ != T_OPT) ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class))); if (is_mdns) { if (i & C_CACHE_FLUSH) ND_PRINT((ndo, " (Cache flush)")); } if (typ == T_OPT) { /* get opt flags */ cp += 2; opt_flags = EXTRACT_16BITS(cp); /* ignore rest of ttl field */ cp += 2; } else if (ndo->ndo_vflag > 2) { /* print ttl */ ND_PRINT((ndo, " [")); unsigned_relts_print(ndo, EXTRACT_32BITS(cp)); ND_PRINT((ndo, "]")); cp += 4; } else { /* ignore ttl */ cp += 4; } len = EXTRACT_16BITS(cp); cp += 2; rp = cp + len; ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", typ))); if (rp > ndo->ndo_snapend) return(NULL); switch (typ) { case T_A: if (!ND_TTEST2(*cp, sizeof(struct in_addr))) return(NULL); ND_PRINT((ndo, " %s", intoa(htonl(EXTRACT_32BITS(cp))))); break; case T_NS: case T_CNAME: case T_PTR: #ifdef T_DNAME case T_DNAME: #endif ND_PRINT((ndo, " ")); if (ns_nprint(ndo, cp, bp) == NULL) return(NULL); break; case T_SOA: if (!ndo->ndo_vflag) break; ND_PRINT((ndo, " ")); if ((cp = ns_nprint(ndo, cp, bp)) == NULL) return(NULL); ND_PRINT((ndo, " ")); if ((cp = ns_nprint(ndo, cp, bp)) == NULL) return(NULL); if (!ND_TTEST2(*cp, 5 * 4)) return(NULL); ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); cp += 4; ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); cp += 4; ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); cp += 4; ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); cp += 4; ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); cp += 4; break; case T_MX: ND_PRINT((ndo, " ")); if (!ND_TTEST2(*cp, 2)) return(NULL); if (ns_nprint(ndo, cp + 2, bp) == NULL) return(NULL); ND_PRINT((ndo, " %d", EXTRACT_16BITS(cp))); break; case T_TXT: while (cp < rp) { ND_PRINT((ndo, " \"")); cp = ns_cprint(ndo, cp); if (cp == NULL) return(NULL); ND_PRINT((ndo, "\"")); } break; case T_SRV: ND_PRINT((ndo, " ")); if (!ND_TTEST2(*cp, 6)) return(NULL); if (ns_nprint(ndo, cp + 6, bp) == NULL) return(NULL); ND_PRINT((ndo, ":%d %d %d", EXTRACT_16BITS(cp + 4), EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2))); break; case T_AAAA: { char ntop_buf[INET6_ADDRSTRLEN]; if (!ND_TTEST2(*cp, sizeof(struct in6_addr))) return(NULL); ND_PRINT((ndo, " %s", addrtostr6(cp, ntop_buf, sizeof(ntop_buf)))); break; } case T_A6: { struct in6_addr a; int pbit, pbyte; char ntop_buf[INET6_ADDRSTRLEN]; if (!ND_TTEST2(*cp, 1)) return(NULL); pbit = *cp; pbyte = (pbit & ~7) / 8; if (pbit > 128) { ND_PRINT((ndo, " %u(bad plen)", pbit)); break; } else if (pbit < 128) { if (!ND_TTEST2(*(cp + 1), sizeof(a) - pbyte)) return(NULL); memset(&a, 0, sizeof(a)); memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); ND_PRINT((ndo, " %u %s", pbit, addrtostr6(&a, ntop_buf, sizeof(ntop_buf)))); } if (pbit > 0) { ND_PRINT((ndo, " ")); if (ns_nprint(ndo, cp + 1 + sizeof(a) - pbyte, bp) == NULL) return(NULL); } break; } case T_OPT: ND_PRINT((ndo, " UDPsize=%u", class)); if (opt_flags & 0x8000) ND_PRINT((ndo, " DO")); break; case T_UNSPECA: /* One long string */ if (!ND_TTEST2(*cp, len)) return(NULL); if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) return(NULL); break; case T_TSIG: { if (cp + len > ndo->ndo_snapend) return(NULL); if (!ndo->ndo_vflag) break; ND_PRINT((ndo, " ")); if ((cp = ns_nprint(ndo, cp, bp)) == NULL) return(NULL); cp += 6; if (!ND_TTEST2(*cp, 2)) return(NULL); ND_PRINT((ndo, " fudge=%u", EXTRACT_16BITS(cp))); cp += 2; if (!ND_TTEST2(*cp, 2)) return(NULL); ND_PRINT((ndo, " maclen=%u", EXTRACT_16BITS(cp))); cp += 2 + EXTRACT_16BITS(cp); if (!ND_TTEST2(*cp, 2)) return(NULL); ND_PRINT((ndo, " origid=%u", EXTRACT_16BITS(cp))); cp += 2; if (!ND_TTEST2(*cp, 2)) return(NULL); ND_PRINT((ndo, " error=%u", EXTRACT_16BITS(cp))); cp += 2; if (!ND_TTEST2(*cp, 2)) return(NULL); ND_PRINT((ndo, " otherlen=%u", EXTRACT_16BITS(cp))); cp += 2; } } return (rp); /* XXX This isn't always right */ } void ns_print(netdissect_options *ndo, register const u_char *bp, u_int length, int is_mdns) { register const HEADER *np; register int qdcount, ancount, nscount, arcount; register const u_char *cp; uint16_t b2; + if(length < sizeof(*np)) { + ND_PRINT((ndo, "domain")); + ND_PRINT((ndo, " [length %u < %zu]", length, sizeof(*np))); + ND_PRINT((ndo, " (invalid)")); + return; + } + np = (const HEADER *)bp; ND_TCHECK(*np); /* get the byte-order right */ qdcount = EXTRACT_16BITS(&np->qdcount); ancount = EXTRACT_16BITS(&np->ancount); nscount = EXTRACT_16BITS(&np->nscount); arcount = EXTRACT_16BITS(&np->arcount); if (DNS_QR(np)) { /* this is a response */ ND_PRINT((ndo, "%d%s%s%s%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], ns_resp[DNS_RCODE(np)], DNS_AA(np)? "*" : "", DNS_RA(np)? "" : "-", DNS_TC(np)? "|" : "", DNS_AD(np)? "$" : "")); if (qdcount != 1) ND_PRINT((ndo, " [%dq]", qdcount)); /* Print QUESTION section on -vv */ cp = (const u_char *)(np + 1); while (qdcount--) { if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1) ND_PRINT((ndo, ",")); if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, " q:")); if ((cp = ns_qprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } else { if ((cp = ns_nskip(ndo, cp)) == NULL) goto trunc; cp += 4; /* skip QTYPE and QCLASS */ } } ND_PRINT((ndo, " %d/%d/%d", ancount, nscount, arcount)); if (ancount--) { if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (cp < ndo->ndo_snapend && ancount--) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; /* Print NS and AR sections on -vv */ if (ndo->ndo_vflag > 1) { if (cp < ndo->ndo_snapend && nscount--) { ND_PRINT((ndo, " ns:")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (cp < ndo->ndo_snapend && nscount--) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < ndo->ndo_snapend && arcount--) { ND_PRINT((ndo, " ar:")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (cp < ndo->ndo_snapend && arcount--) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } else { /* this is a request */ ND_PRINT((ndo, "%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], DNS_RD(np) ? "+" : "", DNS_CD(np) ? "%" : "")); /* any weirdness? */ b2 = EXTRACT_16BITS(((const u_short *)np)+1); if (b2 & 0x6cf) ND_PRINT((ndo, " [b2&3=0x%x]", b2)); if (DNS_OPCODE(np) == IQUERY) { if (qdcount) ND_PRINT((ndo, " [%dq]", qdcount)); if (ancount != 1) ND_PRINT((ndo, " [%da]", ancount)); } else { if (ancount) ND_PRINT((ndo, " [%da]", ancount)); if (qdcount != 1) ND_PRINT((ndo, " [%dq]", qdcount)); } if (nscount) ND_PRINT((ndo, " [%dn]", nscount)); if (arcount) ND_PRINT((ndo, " [%dau]", arcount)); cp = (const u_char *)(np + 1); if (qdcount--) { cp = ns_qprint(ndo, cp, (const u_char *)np, is_mdns); if (!cp) goto trunc; while (cp < ndo->ndo_snapend && qdcount--) { cp = ns_qprint(ndo, (const u_char *)cp, (const u_char *)np, is_mdns); if (!cp) goto trunc; } } if (qdcount > 0) goto trunc; /* Print remaining sections on -vv */ if (ndo->ndo_vflag > 1) { if (ancount--) { if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (cp < ndo->ndo_snapend && ancount--) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (ancount > 0) goto trunc; if (cp < ndo->ndo_snapend && nscount--) { ND_PRINT((ndo, " ns:")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (nscount-- && cp < ndo->ndo_snapend) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (nscount > 0) goto trunc; if (cp < ndo->ndo_snapend && arcount--) { ND_PRINT((ndo, " ar:")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; while (cp < ndo->ndo_snapend && arcount--) { ND_PRINT((ndo, ",")); if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL) goto trunc; } } if (arcount > 0) goto trunc; } } ND_PRINT((ndo, " (%d)", length)); return; trunc: ND_PRINT((ndo, "[|domain]")); } Index: vendor/tcpdump/dist/print-dvmrp.c =================================================================== --- vendor/tcpdump/dist/print-dvmrp.c (revision 353143) +++ vendor/tcpdump/dist/print-dvmrp.c (revision 353144) @@ -1,367 +1,367 @@ /* * Copyright (c) 1995, 1996 * 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. */ /* \summary: Distance Vector Multicast Routing Protocol printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" /* + * See: RFC 1075 and draft-ietf-idmr-dvmrp-v3 + * * DVMRP message types and flag values shamelessly stolen from * mrouted/dvmrp.h. */ #define DVMRP_PROBE 1 /* for finding neighbors */ #define DVMRP_REPORT 2 /* for reporting some or all routes */ #define DVMRP_ASK_NEIGHBORS 3 /* sent by mapper, asking for a list */ /* of this router's neighbors */ #define DVMRP_NEIGHBORS 4 /* response to such a request */ #define DVMRP_ASK_NEIGHBORS2 5 /* as above, want new format reply */ #define DVMRP_NEIGHBORS2 6 #define DVMRP_PRUNE 7 /* prune message */ #define DVMRP_GRAFT 8 /* graft message */ #define DVMRP_GRAFT_ACK 9 /* graft acknowledgement */ /* * 'flags' byte values in DVMRP_NEIGHBORS2 reply. */ #define DVMRP_NF_TUNNEL 0x01 /* neighbors reached via tunnel */ #define DVMRP_NF_SRCRT 0x02 /* tunnel uses IP source routing */ #define DVMRP_NF_DOWN 0x10 /* kernel state of interface */ #define DVMRP_NF_DISABLED 0x20 /* administratively disabled */ #define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */ static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int); static int print_report(netdissect_options *, const u_char *, const u_char *, u_int); static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int); -static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int); +static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int, uint8_t, uint8_t); static int print_prune(netdissect_options *, const u_char *); static int print_graft(netdissect_options *, const u_char *); static int print_graft_ack(netdissect_options *, const u_char *); -static uint32_t target_level; - void dvmrp_print(netdissect_options *ndo, register const u_char *bp, register u_int len) { register const u_char *ep; register u_char type; + uint8_t major_version, minor_version; ep = (const u_char *)ndo->ndo_snapend; if (bp >= ep) return; ND_TCHECK(bp[1]); type = bp[1]; /* Skip IGMP header */ bp += 8; len -= 8; switch (type) { case DVMRP_PROBE: ND_PRINT((ndo, " Probe")); if (ndo->ndo_vflag) { if (print_probe(ndo, bp, ep, len) < 0) goto trunc; } break; case DVMRP_REPORT: ND_PRINT((ndo, " Report")); if (ndo->ndo_vflag > 1) { if (print_report(ndo, bp, ep, len) < 0) goto trunc; } break; case DVMRP_ASK_NEIGHBORS: ND_PRINT((ndo, " Ask-neighbors(old)")); break; case DVMRP_NEIGHBORS: ND_PRINT((ndo, " Neighbors(old)")); if (print_neighbors(ndo, bp, ep, len) < 0) goto trunc; break; case DVMRP_ASK_NEIGHBORS2: ND_PRINT((ndo, " Ask-neighbors2")); break; case DVMRP_NEIGHBORS2: ND_PRINT((ndo, " Neighbors2")); /* - * extract version and capabilities from IGMP group - * address field + * extract version from IGMP group address field */ bp -= 4; ND_TCHECK2(bp[0], 4); - target_level = (bp[0] << 24) | (bp[1] << 16) | - (bp[2] << 8) | bp[3]; + major_version = *(bp + 3); + minor_version = *(bp + 2); bp += 4; - if (print_neighbors2(ndo, bp, ep, len) < 0) + if (print_neighbors2(ndo, bp, ep, len, major_version, + minor_version) < 0) goto trunc; break; case DVMRP_PRUNE: ND_PRINT((ndo, " Prune")); if (print_prune(ndo, bp) < 0) goto trunc; break; case DVMRP_GRAFT: ND_PRINT((ndo, " Graft")); if (print_graft(ndo, bp) < 0) goto trunc; break; case DVMRP_GRAFT_ACK: ND_PRINT((ndo, " Graft-ACK")); if (print_graft_ack(ndo, bp) < 0) goto trunc; break; default: ND_PRINT((ndo, " [type %d]", type)); break; } return; trunc: ND_PRINT((ndo, "[|dvmrp]")); return; } static int print_report(netdissect_options *ndo, register const u_char *bp, register const u_char *ep, register u_int len) { register uint32_t mask, origin; register int metric, done; register u_int i, width; while (len > 0) { if (len < 3) { ND_PRINT((ndo, " [|]")); return (0); } ND_TCHECK2(bp[0], 3); mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2]; width = 1; if (bp[0]) width = 2; if (bp[1]) width = 3; if (bp[2]) width = 4; ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask)))); bp += 3; len -= 3; do { if (bp + width + 1 > ep) { ND_PRINT((ndo, " [|]")); return (0); } if (len < width + 1) { ND_PRINT((ndo, "\n\t [Truncated Report]")); return (0); } origin = 0; for (i = 0; i < width; ++i) { ND_TCHECK(*bp); origin = origin << 8 | *bp++; } for ( ; i < 4; ++i) origin <<= 8; ND_TCHECK(*bp); metric = *bp++; done = metric & 0x80; metric &= 0x7f; ND_PRINT((ndo, "\n\t %s metric %d", intoa(htonl(origin)), metric)); len -= width + 1; } while (!done); } return (0); trunc: return (-1); } static int print_probe(netdissect_options *ndo, register const u_char *bp, register const u_char *ep, register u_int len) { register uint32_t genid; ND_TCHECK2(bp[0], 4); if ((len < 4) || ((bp + 4) > ep)) { /* { (ctags) */ ND_PRINT((ndo, " [|}")); return (0); } - genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3]; + genid = EXTRACT_32BITS(bp); bp += 4; len -= 4; ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " ")); ND_PRINT((ndo, "genid %u", genid)); if (ndo->ndo_vflag < 2) return (0); while ((len > 0) && (bp < ep)) { ND_TCHECK2(bp[0], 4); ND_PRINT((ndo, "\n\tneighbor %s", ipaddr_string(ndo, bp))); bp += 4; len -= 4; } return (0); trunc: return (-1); } static int print_neighbors(netdissect_options *ndo, register const u_char *bp, register const u_char *ep, register u_int len) { const u_char *laddr; register u_char metric; register u_char thresh; register int ncount; while (len > 0 && bp < ep) { ND_TCHECK2(bp[0], 7); laddr = bp; bp += 4; metric = *bp++; thresh = *bp++; ncount = *bp++; len -= 7; while (--ncount >= 0) { ND_TCHECK2(bp[0], 4); ND_PRINT((ndo, " [%s ->", ipaddr_string(ndo, laddr))); ND_PRINT((ndo, " %s, (%d/%d)]", ipaddr_string(ndo, bp), metric, thresh)); bp += 4; len -= 4; } } return (0); trunc: return (-1); } static int print_neighbors2(netdissect_options *ndo, register const u_char *bp, register const u_char *ep, - register u_int len) + register u_int len, uint8_t major_version, + uint8_t minor_version) { const u_char *laddr; register u_char metric, thresh, flags; register int ncount; - ND_PRINT((ndo, " (v %d.%d):", - (int)target_level & 0xff, - (int)(target_level >> 8) & 0xff)); + ND_PRINT((ndo, " (v %d.%d):", major_version, minor_version)); while (len > 0 && bp < ep) { ND_TCHECK2(bp[0], 8); laddr = bp; bp += 4; metric = *bp++; thresh = *bp++; flags = *bp++; ncount = *bp++; len -= 8; while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) { ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr))); ND_PRINT((ndo, "%s (%d/%d", ipaddr_string(ndo, bp), metric, thresh)); if (flags & DVMRP_NF_TUNNEL) ND_PRINT((ndo, "/tunnel")); if (flags & DVMRP_NF_SRCRT) ND_PRINT((ndo, "/srcrt")); if (flags & DVMRP_NF_QUERIER) ND_PRINT((ndo, "/querier")); if (flags & DVMRP_NF_DISABLED) ND_PRINT((ndo, "/disabled")); if (flags & DVMRP_NF_DOWN) ND_PRINT((ndo, "/down")); ND_PRINT((ndo, ")]")); bp += 4; len -= 4; } if (ncount != -1) { ND_PRINT((ndo, " [|]")); return (0); } } return (0); trunc: return (-1); } static int print_prune(netdissect_options *ndo, register const u_char *bp) { ND_TCHECK2(bp[0], 12); ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4))); bp += 8; ND_PRINT((ndo, " timer ")); unsigned_relts_print(ndo, EXTRACT_32BITS(bp)); return (0); trunc: return (-1); } static int print_graft(netdissect_options *ndo, register const u_char *bp) { ND_TCHECK2(bp[0], 8); ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4))); return (0); trunc: return (-1); } static int print_graft_ack(netdissect_options *ndo, register const u_char *bp) { ND_TCHECK2(bp[0], 8); ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4))); return (0); trunc: return (-1); } Index: vendor/tcpdump/dist/print-eigrp.c =================================================================== --- vendor/tcpdump/dist/print-eigrp.c (revision 353143) +++ vendor/tcpdump/dist/print-eigrp.c (revision 353144) @@ -1,522 +1,524 @@ /* * Copyright (c) 1998-2004 Hannes Gredler * The TCPDUMP project * * 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. */ /* \summary: Enhanced Interior Gateway Routing Protocol (EIGRP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" /* * packet format documented at * http://www.rhyshaden.com/eigrp.htm * RFC 7868 */ struct eigrp_common_header { uint8_t version; uint8_t opcode; uint8_t checksum[2]; uint8_t flags[4]; uint8_t seq[4]; uint8_t ack[4]; uint8_t asn[4]; }; #define EIGRP_VERSION 2 #define EIGRP_OPCODE_UPDATE 1 #define EIGRP_OPCODE_QUERY 3 #define EIGRP_OPCODE_REPLY 4 #define EIGRP_OPCODE_HELLO 5 #define EIGRP_OPCODE_IPXSAP 6 #define EIGRP_OPCODE_PROBE 7 static const struct tok eigrp_opcode_values[] = { { EIGRP_OPCODE_UPDATE, "Update" }, { EIGRP_OPCODE_QUERY, "Query" }, { EIGRP_OPCODE_REPLY, "Reply" }, { EIGRP_OPCODE_HELLO, "Hello" }, { EIGRP_OPCODE_IPXSAP, "IPX SAP" }, { EIGRP_OPCODE_PROBE, "Probe" }, { 0, NULL} }; static const struct tok eigrp_common_header_flag_values[] = { { 0x01, "Init" }, { 0x02, "Conditionally Received" }, { 0, NULL} }; struct eigrp_tlv_header { uint8_t type[2]; uint8_t length[2]; }; #define EIGRP_TLV_GENERAL_PARM 0x0001 #define EIGRP_TLV_AUTH 0x0002 #define EIGRP_TLV_SEQ 0x0003 #define EIGRP_TLV_SW_VERSION 0x0004 #define EIGRP_TLV_MCAST_SEQ 0x0005 #define EIGRP_TLV_IP_INT 0x0102 #define EIGRP_TLV_IP_EXT 0x0103 #define EIGRP_TLV_AT_INT 0x0202 #define EIGRP_TLV_AT_EXT 0x0203 #define EIGRP_TLV_AT_CABLE_SETUP 0x0204 #define EIGRP_TLV_IPX_INT 0x0302 #define EIGRP_TLV_IPX_EXT 0x0303 static const struct tok eigrp_tlv_values[] = { { EIGRP_TLV_GENERAL_PARM, "General Parameters"}, { EIGRP_TLV_AUTH, "Authentication"}, { EIGRP_TLV_SEQ, "Sequence"}, { EIGRP_TLV_SW_VERSION, "Software Version"}, { EIGRP_TLV_MCAST_SEQ, "Next Multicast Sequence"}, { EIGRP_TLV_IP_INT, "IP Internal routes"}, { EIGRP_TLV_IP_EXT, "IP External routes"}, { EIGRP_TLV_AT_INT, "AppleTalk Internal routes"}, { EIGRP_TLV_AT_EXT, "AppleTalk External routes"}, { EIGRP_TLV_AT_CABLE_SETUP, "AppleTalk Cable setup"}, { EIGRP_TLV_IPX_INT, "IPX Internal routes"}, { EIGRP_TLV_IPX_EXT, "IPX External routes"}, { 0, NULL} }; struct eigrp_tlv_general_parm_t { uint8_t k1; uint8_t k2; uint8_t k3; uint8_t k4; uint8_t k5; uint8_t res; uint8_t holdtime[2]; }; struct eigrp_tlv_sw_version_t { uint8_t ios_major; uint8_t ios_minor; uint8_t eigrp_major; uint8_t eigrp_minor; }; struct eigrp_tlv_ip_int_t { uint8_t nexthop[4]; uint8_t delay[4]; uint8_t bandwidth[4]; uint8_t mtu[3]; uint8_t hopcount; uint8_t reliability; uint8_t load; uint8_t reserved[2]; uint8_t plen; uint8_t destination; /* variable length [1-4] bytes encoding */ }; struct eigrp_tlv_ip_ext_t { uint8_t nexthop[4]; uint8_t origin_router[4]; uint8_t origin_as[4]; uint8_t tag[4]; uint8_t metric[4]; uint8_t reserved[2]; uint8_t proto_id; uint8_t flags; uint8_t delay[4]; uint8_t bandwidth[4]; uint8_t mtu[3]; uint8_t hopcount; uint8_t reliability; uint8_t load; uint8_t reserved2[2]; uint8_t plen; uint8_t destination; /* variable length [1-4] bytes encoding */ }; struct eigrp_tlv_at_cable_setup_t { uint8_t cable_start[2]; uint8_t cable_end[2]; uint8_t router_id[4]; }; struct eigrp_tlv_at_int_t { uint8_t nexthop[4]; uint8_t delay[4]; uint8_t bandwidth[4]; uint8_t mtu[3]; uint8_t hopcount; uint8_t reliability; uint8_t load; uint8_t reserved[2]; uint8_t cable_start[2]; uint8_t cable_end[2]; }; struct eigrp_tlv_at_ext_t { uint8_t nexthop[4]; uint8_t origin_router[4]; uint8_t origin_as[4]; uint8_t tag[4]; uint8_t proto_id; uint8_t flags; uint8_t metric[2]; uint8_t delay[4]; uint8_t bandwidth[4]; uint8_t mtu[3]; uint8_t hopcount; uint8_t reliability; uint8_t load; uint8_t reserved2[2]; uint8_t cable_start[2]; uint8_t cable_end[2]; }; static const struct tok eigrp_ext_proto_id_values[] = { { 0x01, "IGRP" }, { 0x02, "EIGRP" }, { 0x03, "Static" }, { 0x04, "RIP" }, { 0x05, "Hello" }, { 0x06, "OSPF" }, { 0x07, "IS-IS" }, { 0x08, "EGP" }, { 0x09, "BGP" }, { 0x0a, "IDRP" }, { 0x0b, "Connected" }, { 0, NULL} }; void eigrp_print(netdissect_options *ndo, 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; u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length; uint8_t prefix[4]; union { const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm; const struct eigrp_tlv_sw_version_t *eigrp_tlv_sw_version; const struct eigrp_tlv_ip_int_t *eigrp_tlv_ip_int; const struct eigrp_tlv_ip_ext_t *eigrp_tlv_ip_ext; const struct eigrp_tlv_at_cable_setup_t *eigrp_tlv_at_cable_setup; const struct eigrp_tlv_at_int_t *eigrp_tlv_at_int; const struct eigrp_tlv_at_ext_t *eigrp_tlv_at_ext; } tlv_ptr; tptr=pptr; eigrp_com_header = (const struct eigrp_common_header *)pptr; ND_TCHECK(*eigrp_com_header); /* * Sanity checking of the header. */ if (eigrp_com_header->version != EIGRP_VERSION) { ND_PRINT((ndo, "EIGRP version %u packet not supported",eigrp_com_header->version)); return; } /* in non-verbose mode just lets print the basic Message Type*/ if (ndo->ndo_vflag < 1) { ND_PRINT((ndo, "EIGRP %s, length: %u", tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode), len)); return; } /* ok they seem to want to know everything - lets fully decode it */ if (len < sizeof(struct eigrp_common_header)) { ND_PRINT((ndo, "EIGRP %s, length: %u (too short, < %u)", tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode), len, (u_int) sizeof(struct eigrp_common_header))); return; } tlen=len-sizeof(struct eigrp_common_header); /* FIXME print other header info */ ND_PRINT((ndo, "\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u", eigrp_com_header->version, tok2str(eigrp_opcode_values, "unknown, type: %u",eigrp_com_header->opcode), eigrp_com_header->opcode, EXTRACT_16BITS(&eigrp_com_header->checksum), tok2str(eigrp_common_header_flag_values, "none", EXTRACT_32BITS(&eigrp_com_header->flags)), EXTRACT_32BITS(&eigrp_com_header->seq), EXTRACT_32BITS(&eigrp_com_header->ack), EXTRACT_32BITS(&eigrp_com_header->asn), tlen)); tptr+=sizeof(const struct eigrp_common_header); while(tlen>0) { /* did we capture enough for fully decoding the object header ? */ ND_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 < sizeof(struct eigrp_tlv_header) || eigrp_tlv_len > tlen) { print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen); return; } ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u", tok2str(eigrp_tlv_values, "Unknown", eigrp_tlv_type), eigrp_tlv_type, eigrp_tlv_len)); if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) sizeof(struct eigrp_tlv_header))); break; } tlv_tptr=tptr+sizeof(struct eigrp_tlv_header); tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header); /* did we capture enough for fully decoding the object ? */ ND_TCHECK2(*tptr, eigrp_tlv_len); switch(eigrp_tlv_type) { case EIGRP_TLV_GENERAL_PARM: tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_general_parm)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_general_parm)))); break; } ND_PRINT((ndo, "\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u", EXTRACT_16BITS(tlv_ptr.eigrp_tlv_general_parm->holdtime), tlv_ptr.eigrp_tlv_general_parm->k1, tlv_ptr.eigrp_tlv_general_parm->k2, tlv_ptr.eigrp_tlv_general_parm->k3, tlv_ptr.eigrp_tlv_general_parm->k4, tlv_ptr.eigrp_tlv_general_parm->k5)); break; case EIGRP_TLV_SW_VERSION: tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_sw_version)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_sw_version)))); break; } ND_PRINT((ndo, "\n\t IOS version: %u.%u, EIGRP version %u.%u", tlv_ptr.eigrp_tlv_sw_version->ios_major, tlv_ptr.eigrp_tlv_sw_version->ios_minor, tlv_ptr.eigrp_tlv_sw_version->eigrp_major, tlv_ptr.eigrp_tlv_sw_version->eigrp_minor)); break; case EIGRP_TLV_IP_INT: tlv_ptr.eigrp_tlv_ip_int = (const struct eigrp_tlv_ip_int_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_ip_int)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_ip_int)))); break; } bit_length = tlv_ptr.eigrp_tlv_ip_int->plen; if (bit_length > 32) { ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length)); break; } byte_length = (bit_length + 7) / 8; /* variable length encoding */ memset(prefix, 0, 4); + ND_TCHECK2(tlv_ptr.eigrp_tlv_ip_int->destination, byte_length); memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length); ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ", ipaddr_string(ndo, prefix), bit_length)); if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0) ND_PRINT((ndo, "self")); else ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_int->nexthop))); ND_PRINT((ndo, "\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), EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->bandwidth), EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_int->mtu), tlv_ptr.eigrp_tlv_ip_int->hopcount, tlv_ptr.eigrp_tlv_ip_int->reliability, tlv_ptr.eigrp_tlv_ip_int->load)); break; case EIGRP_TLV_IP_EXT: tlv_ptr.eigrp_tlv_ip_ext = (const struct eigrp_tlv_ip_ext_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_ip_ext)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_ip_ext)))); break; } bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen; if (bit_length > 32) { ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length)); break; } byte_length = (bit_length + 7) / 8; /* variable length encoding */ memset(prefix, 0, 4); + ND_TCHECK2(tlv_ptr.eigrp_tlv_ip_ext->destination, byte_length); memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length); ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ", ipaddr_string(ndo, prefix), bit_length)); if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0) ND_PRINT((ndo, "self")); else ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_ext->nexthop))); ND_PRINT((ndo, "\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", ipaddr_string(ndo, tlv_ptr.eigrp_tlv_ip_ext->origin_router), EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->origin_as), tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_ip_ext->proto_id), tlv_ptr.eigrp_tlv_ip_ext->flags, EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->tag), EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric))); ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->delay)/100), EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->bandwidth), EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_ext->mtu), tlv_ptr.eigrp_tlv_ip_ext->hopcount, tlv_ptr.eigrp_tlv_ip_ext->reliability, tlv_ptr.eigrp_tlv_ip_ext->load)); break; case EIGRP_TLV_AT_CABLE_SETUP: tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_cable_setup)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_cable_setup)))); break; } ND_PRINT((ndo, "\n\t Cable-range: %u-%u, Router-ID %u", EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_start), EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_end), EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id))); break; case EIGRP_TLV_AT_INT: tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_int)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_int)))); break; } ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ", EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_start), EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end))); if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop) == 0) ND_PRINT((ndo, "self")); else ND_PRINT((ndo, "%u.%u", EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop), EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2]))); ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->delay)/100), EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->bandwidth), EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_int->mtu), tlv_ptr.eigrp_tlv_at_int->hopcount, tlv_ptr.eigrp_tlv_at_int->reliability, tlv_ptr.eigrp_tlv_at_int->load)); break; case EIGRP_TLV_AT_EXT: tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr; if (tlv_tlen < sizeof(*tlv_ptr.eigrp_tlv_at_ext)) { ND_PRINT((ndo, " (too short, < %u)", (u_int) (sizeof(struct eigrp_tlv_header) + sizeof(*tlv_ptr.eigrp_tlv_at_ext)))); break; } ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ", EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_start), EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end))); if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0) ND_PRINT((ndo, "self")); else ND_PRINT((ndo, "%u.%u", EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop), EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2]))); ND_PRINT((ndo, "\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u", EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_router), EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_as), tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_at_ext->proto_id), tlv_ptr.eigrp_tlv_at_ext->flags, EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->tag), EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric))); ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u", (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->delay)/100), EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->bandwidth), EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_ext->mtu), tlv_ptr.eigrp_tlv_at_ext->hopcount, tlv_ptr.eigrp_tlv_at_ext->reliability, tlv_ptr.eigrp_tlv_at_ext->load)); break; /* * FIXME those are the defined TLVs that lack a decoder * you are welcome to contribute code ;-) */ case EIGRP_TLV_AUTH: case EIGRP_TLV_SEQ: case EIGRP_TLV_MCAST_SEQ: case EIGRP_TLV_IPX_INT: case EIGRP_TLV_IPX_EXT: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo,tlv_tptr,"\n\t ",tlv_tlen); break; } /* do we want to see an additionally hexdump ? */ if (ndo->ndo_vflag > 1) print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ", eigrp_tlv_len-sizeof(struct eigrp_tlv_header)); tptr+=eigrp_tlv_len; tlen-=eigrp_tlv_len; } return; trunc: ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); } Index: vendor/tcpdump/dist/print-esp.c =================================================================== --- vendor/tcpdump/dist/print-esp.c (revision 353143) +++ vendor/tcpdump/dist/print-esp.c (revision 353144) @@ -1,835 +1,878 @@ /* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * 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. */ /* \summary: IPSEC Encapsulating Security Payload (ESP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include /* Any code in this file that depends on HAVE_LIBCRYPTO depends on * HAVE_OPENSSL_EVP_H too. Undefining the former when the latter isn't defined * is the simplest way of handling the dependency. */ #ifdef HAVE_LIBCRYPTO #ifdef HAVE_OPENSSL_EVP_H #include #else #undef HAVE_LIBCRYPTO #endif #endif #include "netdissect.h" #include "strtoaddr.h" #include "extract.h" #include "ascii_strcasecmp.h" #include "ip.h" #include "ip6.h" /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * RFC1827/2406 Encapsulated Security Payload. */ struct newesp { uint32_t esp_spi; /* ESP */ uint32_t esp_seq; /* Sequence number */ /*variable size*/ /* (IV and) Payload data */ /*variable size*/ /* padding */ /*8bit*/ /* pad size */ /*8bit*/ /* next header */ /*8bit*/ /* next header */ /*variable size, 32bit bound*/ /* Authentication data */ }; #ifdef HAVE_LIBCRYPTO union inaddr_u { struct in_addr in4; struct in6_addr in6; }; struct sa_list { struct sa_list *next; u_int daddr_version; union inaddr_u daddr; uint32_t spi; /* if == 0, then IKEv2 */ int initiator; u_char spii[8]; /* for IKEv2 */ u_char spir[8]; const EVP_CIPHER *evp; int ivlen; int authlen; u_char authsecret[256]; int authsecret_len; u_char secret[256]; /* is that big enough for all secrets? */ int secretlen; }; #ifndef HAVE_EVP_CIPHER_CTX_NEW /* * Allocate an EVP_CIPHER_CTX. * Used if we have an older version of OpenSSL that doesn't provide * routines to allocate and free them. */ static EVP_CIPHER_CTX * EVP_CIPHER_CTX_new(void) { EVP_CIPHER_CTX *ctx; ctx = malloc(sizeof(*ctx)); if (ctx == NULL) return (NULL); memset(ctx, 0, sizeof(*ctx)); return (ctx); } static void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) { EVP_CIPHER_CTX_cleanup(ctx); free(ctx); } #endif #ifdef HAVE_EVP_CIPHERINIT_EX /* * Initialize the cipher by calling EVP_CipherInit_ex(), because * calling EVP_CipherInit() will reset the cipher context, clearing * the cipher, so calling it twice, with the second call having a * null cipher, will clear the already-set cipher. EVP_CipherInit_ex(), * however, won't reset the cipher context, so you can use it to specify * the IV oin a second call after a first call to EVP_CipherInit_ex() * to set the cipher and the key. * * XXX - is there some reason why we need to make two calls? */ static int set_cipher_parameters(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv, int enc) { return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc); } #else /* * Initialize the cipher by calling EVP_CipherInit(), because we don't * have EVP_CipherInit_ex(); we rely on it not trashing the context. */ static int set_cipher_parameters(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const unsigned char *key, const unsigned char *iv, int enc) { return EVP_CipherInit(ctx, cipher, key, iv, enc); } #endif /* * this will adjust ndo_packetp and ndo_snapend to new buffer! */ USES_APPLE_DEPRECATED_API int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo, int initiator, u_char spii[8], u_char spir[8], const u_char *buf, const u_char *end) { struct sa_list *sa; const u_char *iv; unsigned int len; EVP_CIPHER_CTX *ctx; - unsigned int block_size, output_buffer_size; - u_char *output_buffer; + unsigned int block_size, buffer_size; + u_char *input_buffer, *output_buffer; /* initiator arg is any non-zero value */ if(initiator) initiator=1; /* see if we can find the SA, and if so, decode it */ for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { if (sa->spi == 0 && initiator == sa->initiator && memcmp(spii, sa->spii, 8) == 0 && memcmp(spir, sa->spir, 8) == 0) break; } if(sa == NULL) return 0; if(sa->evp == NULL) return 0; /* * remove authenticator, and see if we still have something to * work with */ end = end - sa->authlen; iv = buf; buf = buf + sa->ivlen; len = end-buf; if(end <= buf) return 0; ctx = EVP_CIPHER_CTX_new(); if (ctx == NULL) return 0; if (set_cipher_parameters(ctx, sa->evp, sa->secret, NULL, 0) < 0) (*ndo->ndo_warning)(ndo, "espkey init failed"); set_cipher_parameters(ctx, NULL, NULL, iv, 0); /* - * Allocate a buffer for the decrypted data. - * The output buffer must be separate from the input buffer, and - * its size must be a multiple of the cipher block size. + * Allocate buffers for the encrypted and decrypted data. + * Both buffers' sizes must be a multiple of the cipher block + * size, and the output buffer must be separate from the input + * buffer. */ block_size = (unsigned int)EVP_CIPHER_CTX_block_size(ctx); - output_buffer_size = len + (block_size - len % block_size); - output_buffer = (u_char *)malloc(output_buffer_size); + buffer_size = len + (block_size - len % block_size); + + /* + * Attempt to allocate the input buffer. + */ + input_buffer = (u_char *)malloc(buffer_size); + if (input_buffer == NULL) { + EVP_CIPHER_CTX_free(ctx); + (*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer"); + } + /* + * Copy the input data to the encrypted data buffer, and pad it + * with zeroes. + */ + memcpy(input_buffer, buf, len); + memset(input_buffer + len, 0, buffer_size - len); + + /* + * Attempt to allocate the output buffer. + */ + output_buffer = (u_char *)malloc(buffer_size); if (output_buffer == NULL) { - (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer"); + free(input_buffer); EVP_CIPHER_CTX_free(ctx); - return 0; + (*ndo->ndo_error)(ndo, "can't allocate memory for decryption buffer"); } - EVP_Cipher(ctx, output_buffer, buf, len); + EVP_Cipher(ctx, output_buffer, input_buffer, len); EVP_CIPHER_CTX_free(ctx); /* * XXX - of course this is wrong, because buf is a const buffer, * but changing this would require a more complicated fix. */ memcpy(buf, output_buffer, len); + free(input_buffer); free(output_buffer); ndo->ndo_packetp = buf; ndo->ndo_snapend = end; return 1; } USES_APPLE_RST static void esp_print_addsa(netdissect_options *ndo, struct sa_list *sa, int sa_def) { /* copy the "sa" */ struct sa_list *nsa; nsa = (struct sa_list *)malloc(sizeof(struct sa_list)); if (nsa == NULL) (*ndo->ndo_error)(ndo, "ran out of memory to allocate sa structure"); *nsa = *sa; if (sa_def) ndo->ndo_sa_default = nsa; nsa->next = ndo->ndo_sa_list_head; ndo->ndo_sa_list_head = nsa; } static u_int hexdigit(netdissect_options *ndo, char hex) { if (hex >= '0' && hex <= '9') return (hex - '0'); else if (hex >= 'A' && hex <= 'F') return (hex - 'A' + 10); else if (hex >= 'a' && hex <= 'f') return (hex - 'a' + 10); else { (*ndo->ndo_error)(ndo, "invalid hex digit %c in espsecret\n", hex); - return 0; } } static u_int hex2byte(netdissect_options *ndo, char *hexstring) { u_int byte; byte = (hexdigit(ndo, hexstring[0]) << 4) + hexdigit(ndo, hexstring[1]); return byte; } /* * returns size of binary, 0 on failure. */ static int espprint_decode_hex(netdissect_options *ndo, u_char *binbuf, unsigned int binbuf_len, char *hex) { unsigned int len; int i; len = strlen(hex) / 2; if (len > binbuf_len) { (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len); return 0; } i = 0; while (hex[0] != '\0' && hex[1]!='\0') { binbuf[i] = hex2byte(ndo, hex); hex += 2; i++; } return i; } /* * decode the form: SPINUM@IP ALGONAME:0xsecret */ USES_APPLE_DEPRECATED_API static int espprint_decode_encalgo(netdissect_options *ndo, char *decode, struct sa_list *sa) { size_t i; const EVP_CIPHER *evp; int authlen = 0; char *colon, *p; colon = strchr(decode, ':'); if (colon == NULL) { (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode); return 0; } *colon = '\0'; if (strlen(decode) > strlen("-hmac96") && !strcmp(decode + strlen(decode) - strlen("-hmac96"), "-hmac96")) { p = strstr(decode, "-hmac96"); *p = '\0'; authlen = 12; } if (strlen(decode) > strlen("-cbc") && !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) { p = strstr(decode, "-cbc"); *p = '\0'; } evp = EVP_get_cipherbyname(decode); if (!evp) { (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode); sa->evp = NULL; sa->authlen = 0; sa->ivlen = 0; return 0; } sa->evp = evp; sa->authlen = authlen; sa->ivlen = EVP_CIPHER_iv_length(evp); colon++; if (colon[0] == '0' && colon[1] == 'x') { /* decode some hex! */ colon += 2; sa->secretlen = espprint_decode_hex(ndo, sa->secret, sizeof(sa->secret), colon); if(sa->secretlen == 0) return 0; } else { i = strlen(colon); if (i < sizeof(sa->secret)) { memcpy(sa->secret, colon, i); sa->secretlen = i; } else { memcpy(sa->secret, colon, sizeof(sa->secret)); sa->secretlen = sizeof(sa->secret); } } return 1; } USES_APPLE_RST /* - * for the moment, ignore the auth algorith, just hard code the authenticator + * for the moment, ignore the auth algorithm, just hard code the authenticator * length. Need to research how openssl looks up HMAC stuff. */ static int espprint_decode_authalgo(netdissect_options *ndo, char *decode, struct sa_list *sa) { char *colon; colon = strchr(decode, ':'); if (colon == NULL) { (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode); return 0; } *colon = '\0'; if(ascii_strcasecmp(colon,"sha1") == 0 || ascii_strcasecmp(colon,"md5") == 0) { sa->authlen = 12; } return 1; } static void esp_print_decode_ikeline(netdissect_options *ndo, char *line, const char *file, int lineno) { /* it's an IKEv2 secret, store it instead */ struct sa_list sa1; char *init; char *icookie, *rcookie; int ilen, rlen; char *authkey; char *enckey; init = strsep(&line, " \t"); icookie = strsep(&line, " \t"); rcookie = strsep(&line, " \t"); authkey = strsep(&line, " \t"); enckey = strsep(&line, " \t"); /* if any fields are missing */ if(!init || !icookie || !rcookie || !authkey || !enckey) { (*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u", file, lineno); return; } ilen = strlen(icookie); rlen = strlen(rcookie); if((init[0]!='I' && init[0]!='R') || icookie[0]!='0' || icookie[1]!='x' || rcookie[0]!='0' || rcookie[1]!='x' || ilen!=18 || rlen!=18) { (*ndo->ndo_warning)(ndo, "print_esp: line %s:%u improperly formatted.", file, lineno); (*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)", init, icookie, ilen, rcookie, rlen); return; } sa1.spi = 0; sa1.initiator = (init[0] == 'I'); if(espprint_decode_hex(ndo, sa1.spii, sizeof(sa1.spii), icookie+2)!=8) return; if(espprint_decode_hex(ndo, sa1.spir, sizeof(sa1.spir), rcookie+2)!=8) return; if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return; if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return; esp_print_addsa(ndo, &sa1, FALSE); } /* * * special form: file /name * causes us to go read from this file instead. * */ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line, const char *file, int lineno) { struct sa_list sa1; int sa_def; char *spikey; char *decode; spikey = strsep(&line, " \t"); sa_def = 0; memset(&sa1, 0, sizeof(struct sa_list)); /* if there is only one token, then it is an algo:key token */ if (line == NULL) { decode = spikey; spikey = NULL; /* sa1.daddr.version = 0; */ /* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */ /* sa1.spi = 0; */ sa_def = 1; } else decode = line; if (spikey && ascii_strcasecmp(spikey, "file") == 0) { /* open file and read it */ FILE *secretfile; char fileline[1024]; int subfile_lineno=0; char *nl; char *filename = line; secretfile = fopen(filename, FOPEN_READ_TXT); if (secretfile == NULL) { (*ndo->ndo_error)(ndo, "print_esp: can't open %s: %s\n", filename, strerror(errno)); - return; } while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) { subfile_lineno++; /* remove newline from the line */ nl = strchr(fileline, '\n'); if (nl) *nl = '\0'; if (fileline[0] == '#') continue; if (fileline[0] == '\0') continue; esp_print_decode_onesecret(ndo, fileline, filename, subfile_lineno); } fclose(secretfile); return; } if (spikey && ascii_strcasecmp(spikey, "ikev2") == 0) { esp_print_decode_ikeline(ndo, line, file, lineno); return; } if (spikey) { char *spistr, *foo; uint32_t spino; spistr = strsep(&spikey, "@"); + if (spistr == NULL) { + (*ndo->ndo_warning)(ndo, "print_esp: failed to find the @ token"); + return; + } spino = strtoul(spistr, &foo, 0); if (spistr == foo || !spikey) { (*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo); return; } sa1.spi = spino; if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) { sa1.daddr_version = 6; } else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) { sa1.daddr_version = 4; } else { (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey); return; } } if (decode) { /* skip any blank spaces */ while (isspace((unsigned char)*decode)) decode++; if(!espprint_decode_encalgo(ndo, decode, &sa1)) { return; } } esp_print_addsa(ndo, &sa1, sa_def); } USES_APPLE_DEPRECATED_API static void esp_init(netdissect_options *ndo _U_) { /* * 0.9.6 doesn't appear to define OPENSSL_API_COMPAT, so * we check whether it's undefined or it's less than the * value for 1.1.0. */ #if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L OpenSSL_add_all_algorithms(); #endif EVP_add_cipher_alias(SN_des_ede3_cbc, "3des"); } USES_APPLE_RST void esp_print_decodesecret(netdissect_options *ndo) { char *line; char *p; static int initialized = 0; if (!initialized) { esp_init(ndo); initialized = 1; } p = ndo->ndo_espsecret; while (p && p[0] != '\0') { /* pick out the first line or first thing until a comma */ if ((line = strsep(&p, "\n,")) == NULL) { line = p; p = NULL; } esp_print_decode_onesecret(ndo, line, "cmdline", 0); } ndo->ndo_espsecret = NULL; } #endif #ifdef HAVE_LIBCRYPTO USES_APPLE_DEPRECATED_API #endif int esp_print(netdissect_options *ndo, const u_char *bp, const int length, const u_char *bp2 #ifndef HAVE_LIBCRYPTO _U_ #endif , int *nhdr #ifndef HAVE_LIBCRYPTO _U_ #endif , int *padlen #ifndef HAVE_LIBCRYPTO _U_ #endif ) { register const struct newesp *esp; register const u_char *ep; #ifdef HAVE_LIBCRYPTO const struct ip *ip; struct sa_list *sa = NULL; const struct ip6_hdr *ip6 = NULL; int advance; int len; u_char *secret; int ivlen = 0; const u_char *ivoff; const u_char *p; EVP_CIPHER_CTX *ctx; - unsigned int block_size, output_buffer_size; - u_char *output_buffer; + unsigned int block_size, buffer_size; + u_char *input_buffer, *output_buffer; #endif esp = (const struct newesp *)bp; #ifdef HAVE_LIBCRYPTO secret = NULL; advance = 0; #endif #if 0 /* keep secret out of a register */ p = (u_char *)&secret; #endif /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; if ((const u_char *)(esp + 1) >= ep) { ND_PRINT((ndo, "[|ESP]")); goto fail; } ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi))); ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq))); ND_PRINT((ndo, ", length %u", length)); #ifndef HAVE_LIBCRYPTO goto fail; #else /* initiailize SAs */ if (ndo->ndo_sa_list_head == NULL) { if (!ndo->ndo_espsecret) goto fail; esp_print_decodesecret(ndo); } if (ndo->ndo_sa_list_head == NULL) goto fail; ip = (const struct ip *)bp2; switch (IP_V(ip)) { case 6: ip6 = (const struct ip6_hdr *)bp2; /* we do not attempt to decrypt jumbograms */ if (!EXTRACT_16BITS(&ip6->ip6_plen)) goto fail; /* if we can't get nexthdr, we do not need to decrypt it */ len = sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen); /* see if we can find the SA, and if so, decode it */ for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) && sa->daddr_version == 6 && UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr)) == 0) { break; } } break; case 4: /* nexthdr & padding are in the last fragment */ if (EXTRACT_16BITS(&ip->ip_off) & IP_MF) goto fail; len = EXTRACT_16BITS(&ip->ip_len); /* see if we can find the SA, and if so, decode it */ for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) { if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) && sa->daddr_version == 4 && UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst, sizeof(struct in_addr)) == 0) { break; } } break; default: goto fail; } /* if we didn't find the specific one, then look for * an unspecified one. */ if (sa == NULL) sa = ndo->ndo_sa_default; /* if not found fail */ if (sa == NULL) goto fail; /* if we can't get nexthdr, we do not need to decrypt it */ if (ep - bp2 < len) goto fail; if (ep - bp2 > len) { /* FCS included at end of frame (NetBSD 1.6 or later) */ ep = bp2 + len; } /* pointer to the IV, if there is one */ ivoff = (const u_char *)(esp + 1) + 0; /* length of the IV, if there is one; 0, if there isn't */ ivlen = sa->ivlen; secret = sa->secret; ep = ep - sa->authlen; if (sa->evp) { ctx = EVP_CIPHER_CTX_new(); if (ctx != NULL) { if (set_cipher_parameters(ctx, sa->evp, secret, NULL, 0) < 0) (*ndo->ndo_warning)(ndo, "espkey init failed"); p = ivoff; set_cipher_parameters(ctx, NULL, NULL, p, 0); len = ep - (p + ivlen); /* - * Allocate a buffer for the decrypted data. - * The output buffer must be separate from the - * input buffer, and its size must be a multiple - * of the cipher block size. + * Allocate buffers for the encrypted and decrypted + * data. Both buffers' sizes must be a multiple of + * the cipher block size, and the output buffer must + * be separate from the input buffer. */ block_size = (unsigned int)EVP_CIPHER_CTX_block_size(ctx); - output_buffer_size = len + (block_size - len % block_size); - output_buffer = (u_char *)malloc(output_buffer_size); + buffer_size = len + (block_size - len % block_size); + + /* + * Attempt to allocate the input buffer. + */ + input_buffer = (u_char *)malloc(buffer_size); + if (input_buffer == NULL) { + EVP_CIPHER_CTX_free(ctx); + (*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer"); + } + /* + * Copy the input data to the encrypted data buffer, + * and pad it with zeroes. + */ + memcpy(input_buffer, p + ivlen, len); + memset(input_buffer + len, 0, buffer_size - len); + + /* + * Attempt to allocate the output buffer. + */ + output_buffer = (u_char *)malloc(buffer_size); if (output_buffer == NULL) { - (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer"); + free(input_buffer); EVP_CIPHER_CTX_free(ctx); - return -1; + (*ndo->ndo_error)(ndo, "can't allocate memory for decryption buffer"); } - EVP_Cipher(ctx, output_buffer, p + ivlen, len); + EVP_Cipher(ctx, output_buffer, input_buffer, len); + free(input_buffer); EVP_CIPHER_CTX_free(ctx); /* * XXX - of course this is wrong, because buf is a * const buffer, but changing this would require a * more complicated fix. */ memcpy(p + ivlen, output_buffer, len); free(output_buffer); advance = ivoff - (const u_char *)esp + ivlen; } else advance = sizeof(struct newesp); } else advance = sizeof(struct newesp); /* sanity check for pad length */ if (ep - bp < *(ep - 2)) goto fail; if (padlen) *padlen = *(ep - 2) + 2; if (nhdr) *nhdr = *(ep - 1); ND_PRINT((ndo, ": ")); return advance; #endif fail: return -1; } #ifdef HAVE_LIBCRYPTO USES_APPLE_RST #endif /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-fr.c =================================================================== --- vendor/tcpdump/dist/print-fr.c (revision 353143) +++ vendor/tcpdump/dist/print-fr.c (revision 353144) @@ -1,1142 +1,1151 @@ /* * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996 * 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. */ /* \summary: Frame Relay printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "ethertype.h" #include "llc.h" #include "nlpid.h" #include "extract.h" #include "oui.h" static void frf15_print(netdissect_options *ndo, const u_char *, u_int); /* * the frame relay header has a variable length * * the EA bit determines if there is another byte * in the header * * minimum header length is 2 bytes * maximum header length is 4 bytes * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * | DLCI (6 bits) | CR | EA | * +----+----+----+----+----+----+----+----+ * | DLCI (4 bits) |FECN|BECN| DE | EA | * +----+----+----+----+----+----+----+----+ * | DLCI (7 bits) | EA | * +----+----+----+----+----+----+----+----+ * | DLCI (6 bits) |SDLC| EA | * +----+----+----+----+----+----+----+----+ */ #define FR_EA_BIT 0x01 #define FR_CR_BIT 0x02000000 #define FR_DE_BIT 0x00020000 #define FR_BECN_BIT 0x00040000 #define FR_FECN_BIT 0x00080000 #define FR_SDLC_BIT 0x00000002 static const struct tok fr_header_flag_values[] = { { FR_CR_BIT, "C!" }, { FR_DE_BIT, "DE" }, { FR_BECN_BIT, "BECN" }, { FR_FECN_BIT, "FECN" }, { FR_SDLC_BIT, "sdlcore" }, { 0, NULL } }; /* FRF.15 / FRF.16 */ #define MFR_B_BIT 0x80 #define MFR_E_BIT 0x40 #define MFR_C_BIT 0x20 #define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) #define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT) #define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT ) static const struct tok frf_flag_values[] = { { MFR_B_BIT, "Begin" }, { MFR_E_BIT, "End" }, { MFR_C_BIT, "Control" }, { 0, NULL } }; /* Finds out Q.922 address length, DLCI and flags. Returns 1 on success, * 0 on invalid address, -1 on truncated packet * save the flags dep. on address length */ static int parse_q922_addr(netdissect_options *ndo, const u_char *p, u_int *dlci, u_int *addr_len, uint8_t *flags, u_int length) { if (!ND_TTEST(p[0]) || length < 1) return -1; if ((p[0] & FR_EA_BIT)) return 0; if (!ND_TTEST(p[1]) || length < 2) return -1; *addr_len = 2; *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4); flags[0] = p[0] & 0x02; /* populate the first flag fields */ flags[1] = p[1] & 0x0c; flags[2] = 0; /* clear the rest of the flags */ flags[3] = 0; if (p[1] & FR_EA_BIT) return 1; /* 2-byte Q.922 address */ p += 2; length -= 2; if (!ND_TTEST(p[0]) || length < 1) return -1; (*addr_len)++; /* 3- or 4-byte Q.922 address */ if ((p[0] & FR_EA_BIT) == 0) { *dlci = (*dlci << 7) | (p[0] >> 1); (*addr_len)++; /* 4-byte Q.922 address */ p++; length--; } if (!ND_TTEST(p[0]) || length < 1) return -1; if ((p[0] & FR_EA_BIT) == 0) return 0; /* more than 4 bytes of Q.922 address? */ flags[3] = p[0] & 0x02; *dlci = (*dlci << 6) | (p[0] >> 2); return 1; } char * q922_string(netdissect_options *ndo, const u_char *p, u_int length) { static u_int dlci, addr_len; static uint8_t flags[4]; static char buffer[sizeof("DLCI xxxxxxxxxx")]; memset(buffer, 0, sizeof(buffer)); if (parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length) == 1){ snprintf(buffer, sizeof(buffer), "DLCI %u", dlci); } return buffer; } /* Frame Relay packet structure, with flags and CRC removed +---------------------------+ | Q.922 Address* | +-- --+ | | +---------------------------+ | Control (UI = 0x03) | +---------------------------+ | Optional Pad (0x00) | +---------------------------+ | NLPID | +---------------------------+ | . | | . | | . | | Data | | . | | . | +---------------------------+ * Q.922 addresses, as presently defined, are two octets and contain a 10-bit DLCI. In some networks Q.922 addresses may optionally be increased to three or four octets. */ static void fr_hdr_print(netdissect_options *ndo, int length, u_int addr_len, u_int dlci, uint8_t *flags, uint16_t nlpid) { if (ndo->ndo_qflag) { ND_PRINT((ndo, "Q.922, DLCI %u, length %u: ", dlci, length)); } else { if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ", addr_len, dlci, bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)), tok2str(nlpid_values,"unknown", nlpid), nlpid, length)); else /* must be an ethertype */ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ", addr_len, dlci, bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)), tok2str(ethertype_values, "unknown", nlpid), nlpid, length)); } } u_int fr_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; ND_TCHECK2(*p, 4); /* minimum frame header length */ if ((length = fr_print(ndo, p, length)) == 0) return (0); else return length; trunc: ND_PRINT((ndo, "[|fr]")); return caplen; } u_int fr_print(netdissect_options *ndo, register const u_char *p, u_int length) { int ret; uint16_t extracted_ethertype; u_int dlci; u_int addr_len; uint16_t nlpid; u_int hdr_len; uint8_t flags[4]; ret = parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length); if (ret == -1) goto trunc; if (ret == 0) { ND_PRINT((ndo, "Q.922, invalid address")); return 0; } ND_TCHECK(p[addr_len]); if (length < addr_len + 1) goto trunc; if (p[addr_len] != LLC_UI && dlci != 0) { /* * Let's figure out if we have Cisco-style encapsulation, * with an Ethernet type (Cisco HDLC type?) following the * address. */ if (!ND_TTEST2(p[addr_len], 2) || length < addr_len + 2) { /* no Ethertype */ ND_PRINT((ndo, "UI %02x! ", p[addr_len])); } else { extracted_ethertype = EXTRACT_16BITS(p+addr_len); if (ndo->ndo_eflag) fr_hdr_print(ndo, length, addr_len, dlci, flags, extracted_ethertype); if (ethertype_print(ndo, extracted_ethertype, p+addr_len+ETHERTYPE_LEN, length-addr_len-ETHERTYPE_LEN, ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN, NULL, NULL) == 0) /* ether_type not known, probably it wasn't one */ ND_PRINT((ndo, "UI %02x! ", p[addr_len])); else return addr_len + 2; } } ND_TCHECK(p[addr_len+1]); if (length < addr_len + 2) goto trunc; if (p[addr_len + 1] == 0) { /* * Assume a pad byte after the control (UI) byte. * A pad byte should only be used with 3-byte Q.922. */ if (addr_len != 3) ND_PRINT((ndo, "Pad! ")); hdr_len = addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */; } else { /* * Not a pad byte. * A pad byte should be used with 3-byte Q.922. */ if (addr_len == 3) ND_PRINT((ndo, "No pad! ")); hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */; } ND_TCHECK(p[hdr_len - 1]); if (length < hdr_len) goto trunc; nlpid = p[hdr_len - 1]; if (ndo->ndo_eflag) fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid); p += hdr_len; length -= hdr_len; switch (nlpid) { case NLPID_IP: ip_print(ndo, p, length); break; case NLPID_IP6: ip6_print(ndo, p, length); break; case NLPID_CLNP: case NLPID_ESIS: case NLPID_ISIS: isoclns_print(ndo, p - 1, length + 1); /* OSI printers need the NLPID field */ break; case NLPID_SNAP: if (snap_print(ndo, p, length, ndo->ndo_snapend - p, NULL, NULL, 0) == 0) { /* ether_type not known, print raw packet */ if (!ndo->ndo_eflag) fr_hdr_print(ndo, length + hdr_len, hdr_len, dlci, flags, nlpid); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p - hdr_len, length + hdr_len); } break; case NLPID_Q933: q933_print(ndo, p, length); break; case NLPID_MFR: frf15_print(ndo, p, length); break; case NLPID_PPP: ppp_print(ndo, p, length); break; default: if (!ndo->ndo_eflag) fr_hdr_print(ndo, length + hdr_len, addr_len, dlci, flags, nlpid); if (!ndo->ndo_xflag) ND_DEFAULTPRINT(p, length); } return hdr_len; trunc: ND_PRINT((ndo, "[|fr]")); return 0; } u_int mfr_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { register u_int length = h->len; register u_int caplen = h->caplen; ND_TCHECK2(*p, 2); /* minimum frame header length */ if ((length = mfr_print(ndo, p, length)) == 0) return (0); else return length; trunc: ND_PRINT((ndo, "[|mfr]")); return caplen; } #define MFR_CTRL_MSG_ADD_LINK 1 #define MFR_CTRL_MSG_ADD_LINK_ACK 2 #define MFR_CTRL_MSG_ADD_LINK_REJ 3 #define MFR_CTRL_MSG_HELLO 4 #define MFR_CTRL_MSG_HELLO_ACK 5 #define MFR_CTRL_MSG_REMOVE_LINK 6 #define MFR_CTRL_MSG_REMOVE_LINK_ACK 7 static const struct tok mfr_ctrl_msg_values[] = { { MFR_CTRL_MSG_ADD_LINK, "Add Link" }, { MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" }, { MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" }, { MFR_CTRL_MSG_HELLO, "Hello" }, { MFR_CTRL_MSG_HELLO_ACK, "Hello ACK" }, { MFR_CTRL_MSG_REMOVE_LINK, "Remove Link" }, { MFR_CTRL_MSG_REMOVE_LINK_ACK, "Remove Link ACK" }, { 0, NULL } }; #define MFR_CTRL_IE_BUNDLE_ID 1 #define MFR_CTRL_IE_LINK_ID 2 #define MFR_CTRL_IE_MAGIC_NUM 3 #define MFR_CTRL_IE_TIMESTAMP 5 #define MFR_CTRL_IE_VENDOR_EXT 6 #define MFR_CTRL_IE_CAUSE 7 static const struct tok mfr_ctrl_ie_values[] = { { MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"}, { MFR_CTRL_IE_LINK_ID, "Link ID"}, { MFR_CTRL_IE_MAGIC_NUM, "Magic Number"}, { MFR_CTRL_IE_TIMESTAMP, "Timestamp"}, { MFR_CTRL_IE_VENDOR_EXT, "Vendor Extension"}, { MFR_CTRL_IE_CAUSE, "Cause"}, { 0, NULL } }; #define MFR_ID_STRING_MAXLEN 50 struct ie_tlv_header_t { uint8_t ie_type; uint8_t ie_len; }; u_int mfr_print(netdissect_options *ndo, register const u_char *p, u_int length) { u_int tlen,idx,hdr_len = 0; uint16_t sequence_num; uint8_t ie_type,ie_len; const uint8_t *tptr; /* * FRF.16 Link Integrity Control Frame * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * | B | E | C=1| 0 0 0 0 | EA | * +----+----+----+----+----+----+----+----+ * | 0 0 0 0 0 0 0 0 | * +----+----+----+----+----+----+----+----+ * | message type | * +----+----+----+----+----+----+----+----+ */ ND_TCHECK2(*p, 4); /* minimum frame header length */ + if (length < 4) { + ND_PRINT((ndo, "Message too short (%u bytes)", length)); + return length; + } if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) { ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u", bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)), tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]), length)); tptr = p + 3; tlen = length -3; hdr_len = 3; if (!ndo->ndo_vflag) return hdr_len; while (tlen>sizeof(struct ie_tlv_header_t)) { ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t)); ie_type=tptr[0]; ie_len=tptr[1]; ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ", tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), ie_type, ie_len)); /* infinite loop check */ if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t)) return hdr_len; ND_TCHECK2(*tptr, ie_len); tptr+=sizeof(struct ie_tlv_header_t); /* tlv len includes header */ ie_len-=sizeof(struct ie_tlv_header_t); tlen-=sizeof(struct ie_tlv_header_t); switch (ie_type) { case MFR_CTRL_IE_MAGIC_NUM: + /* FRF.16.1 Section 3.4.3 Magic Number Information Element */ + if (ie_len != 4) { + ND_PRINT((ndo, "(invalid length)")); + break; + } ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr))); break; case MFR_CTRL_IE_BUNDLE_ID: /* same message format */ case MFR_CTRL_IE_LINK_ID: for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { if (*(tptr+idx) != 0) /* don't print null termination */ safeputchar(ndo, *(tptr + idx)); else break; } break; case MFR_CTRL_IE_TIMESTAMP: if (ie_len == sizeof(struct timeval)) { ts_print(ndo, (const struct timeval *)tptr); break; } /* fall through and hexdump if no unix timestamp */ /* * FIXME those are the defined IEs that lack a decoder * you are welcome to contribute code ;-) */ case MFR_CTRL_IE_VENDOR_EXT: case MFR_CTRL_IE_CAUSE: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", ie_len); break; } /* do we want to see a hexdump of the IE ? */ if (ndo->ndo_vflag > 1 ) print_unknown_data(ndo, tptr, "\n\t ", ie_len); tlen-=ie_len; tptr+=ie_len; } return hdr_len; } /* * FRF.16 Fragmentation Frame * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * | B | E | C=0|seq. (high 4 bits) | EA | * +----+----+----+----+----+----+----+----+ * | sequence (low 8 bits) | * +----+----+----+----+----+----+----+----+ * | DLCI (6 bits) | CR | EA | * +----+----+----+----+----+----+----+----+ * | DLCI (4 bits) |FECN|BECN| DE | EA | * +----+----+----+----+----+----+----+----+ */ sequence_num = (p[0]&0x1e)<<7 | p[1]; /* whole packet or first fragment ? */ if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME || (p[0] & MFR_BEC_MASK) == MFR_B_BIT) { ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ", sequence_num, bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)))); hdr_len = 2; fr_print(ndo, p+hdr_len,length-hdr_len); return hdr_len; } /* must be a middle or the last fragment */ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]", sequence_num, bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)))); print_unknown_data(ndo, p, "\n\t", length); return hdr_len; trunc: ND_PRINT((ndo, "[|mfr]")); return length; } /* an NLPID of 0xb1 indicates a 2-byte * FRF.15 header * * 7 6 5 4 3 2 1 0 * +----+----+----+----+----+----+----+----+ * ~ Q.922 header ~ * +----+----+----+----+----+----+----+----+ * | NLPID (8 bits) | NLPID=0xb1 * +----+----+----+----+----+----+----+----+ * | B | E | C |seq. (high 4 bits) | R | * +----+----+----+----+----+----+----+----+ * | sequence (low 8 bits) | * +----+----+----+----+----+----+----+----+ */ #define FR_FRF15_FRAGTYPE 0x01 static void frf15_print(netdissect_options *ndo, const u_char *p, u_int length) { uint16_t sequence_num, flags; if (length < 2) goto trunc; ND_TCHECK2(*p, 2); flags = p[0]&MFR_BEC_MASK; sequence_num = (p[0]&0x1e)<<7 | p[1]; ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u", sequence_num, bittok2str(frf_flag_values,"none",flags), p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End", length)); /* TODO: * depending on all permutations of the B, E and C bit * dig as deep as we can - e.g. on the first (B) fragment * there is enough payload to print the IP header * on non (B) fragments it depends if the fragmentation * model is end-to-end or interface based wether we want to print * another Q.922 header */ return; trunc: ND_PRINT((ndo, "[|frf.15]")); } /* * Q.933 decoding portion for framerelay specific. */ /* Q.933 packet format Format of Other Protocols using Q.933 NLPID +-------------------------------+ | Q.922 Address | +---------------+---------------+ |Control 0x03 | NLPID 0x08 | +---------------+---------------+ | L2 Protocol ID | | octet 1 | octet 2 | +-------------------------------+ | L3 Protocol ID | | octet 2 | octet 2 | +-------------------------------+ | Protocol Data | +-------------------------------+ | FCS | +-------------------------------+ */ /* L2 (Octet 1)- Call Reference Usually is 0x0 */ /* * L2 (Octet 2)- Message Types definition 1 byte long. */ /* Call Establish */ #define MSG_TYPE_ESC_TO_NATIONAL 0x00 #define MSG_TYPE_ALERT 0x01 #define MSG_TYPE_CALL_PROCEEDING 0x02 #define MSG_TYPE_CONNECT 0x07 #define MSG_TYPE_CONNECT_ACK 0x0F #define MSG_TYPE_PROGRESS 0x03 #define MSG_TYPE_SETUP 0x05 /* Call Clear */ #define MSG_TYPE_DISCONNECT 0x45 #define MSG_TYPE_RELEASE 0x4D #define MSG_TYPE_RELEASE_COMPLETE 0x5A #define MSG_TYPE_RESTART 0x46 #define MSG_TYPE_RESTART_ACK 0x4E /* Status */ #define MSG_TYPE_STATUS 0x7D #define MSG_TYPE_STATUS_ENQ 0x75 static const struct tok fr_q933_msg_values[] = { { MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" }, { MSG_TYPE_ALERT, "Alert" }, { MSG_TYPE_CALL_PROCEEDING, "Call proceeding" }, { MSG_TYPE_CONNECT, "Connect" }, { MSG_TYPE_CONNECT_ACK, "Connect ACK" }, { MSG_TYPE_PROGRESS, "Progress" }, { MSG_TYPE_SETUP, "Setup" }, { MSG_TYPE_DISCONNECT, "Disconnect" }, { MSG_TYPE_RELEASE, "Release" }, { MSG_TYPE_RELEASE_COMPLETE, "Release Complete" }, { MSG_TYPE_RESTART, "Restart" }, { MSG_TYPE_RESTART_ACK, "Restart ACK" }, { MSG_TYPE_STATUS, "Status Reply" }, { MSG_TYPE_STATUS_ENQ, "Status Enquiry" }, { 0, NULL } }; #define IE_IS_SINGLE_OCTET(iecode) ((iecode) & 0x80) #define IE_IS_SHIFT(iecode) (((iecode) & 0xF0) == 0x90) #define IE_SHIFT_IS_NON_LOCKING(iecode) ((iecode) & 0x08) #define IE_SHIFT_IS_LOCKING(iecode) (!(IE_SHIFT_IS_NON_LOCKING(iecode))) #define IE_SHIFT_CODESET(iecode) ((iecode) & 0x07) #define FR_LMI_ANSI_REPORT_TYPE_IE 0x01 #define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */ #define FR_LMI_ANSI_LINK_VERIFY_IE 0x03 #define FR_LMI_ANSI_PVC_STATUS_IE 0x07 #define FR_LMI_CCITT_REPORT_TYPE_IE 0x51 #define FR_LMI_CCITT_LINK_VERIFY_IE 0x53 #define FR_LMI_CCITT_PVC_STATUS_IE 0x57 static const struct tok fr_q933_ie_values_codeset_0_5[] = { { FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" }, { FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" }, { FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" }, { FR_LMI_ANSI_PVC_STATUS_IE, "ANSI PVC Status" }, { FR_LMI_CCITT_REPORT_TYPE_IE, "CCITT Report Type" }, { FR_LMI_CCITT_LINK_VERIFY_IE, "CCITT Link Verify" }, { FR_LMI_CCITT_PVC_STATUS_IE, "CCITT PVC Status" }, { 0, NULL } }; #define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0 #define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1 #define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2 static const struct tok fr_lmi_report_type_ie_values[] = { { FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" }, { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" }, { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" }, { 0, NULL } }; /* array of 16 codesets - currently we only support codepage 0 and 5 */ static const struct tok *fr_q933_ie_codesets[] = { fr_q933_ie_values_codeset_0_5, NULL, NULL, NULL, NULL, fr_q933_ie_values_codeset_0_5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static int fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, u_int ielength, const u_char *p); typedef int (*codeset_pr_func_t)(netdissect_options *, u_int iecode, u_int ielength, const u_char *p); /* array of 16 codesets - currently we only support codepage 0 and 5 */ static const codeset_pr_func_t fr_q933_print_ie_codeset[] = { fr_q933_print_ie_codeset_0_5, NULL, NULL, NULL, NULL, fr_q933_print_ie_codeset_0_5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* * ITU-T Q.933. * * p points to octet 2, the octet containing the length of the * call reference value, so p[n] is octet n+2 ("octet X" is as * used in Q.931/Q.933). * * XXX - actually used both for Q.931 and Q.933. */ void q933_print(netdissect_options *ndo, const u_char *p, u_int length) { u_int olen; u_int call_ref_length, i; uint8_t call_ref[15]; /* maximum length - length field is 4 bits */ u_int msgtype; u_int iecode; u_int ielength; u_int codeset = 0; u_int is_ansi = 0; u_int ie_is_known; u_int non_locking_shift; u_int unshift_codeset; ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933")); if (length == 0 || !ND_TTEST(*p)) { if (!ndo->ndo_eflag) ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "length %u", length)); goto trunc; } /* * Get the length of the call reference value. */ olen = length; /* preserve the original length for display */ call_ref_length = (*p) & 0x0f; p++; length--; /* * Get the call reference value. */ for (i = 0; i < call_ref_length; i++) { if (length == 0 || !ND_TTEST(*p)) { if (!ndo->ndo_eflag) ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "length %u", olen)); goto trunc; } call_ref[i] = *p; p++; length--; } /* * Get the message type. */ if (length == 0 || !ND_TTEST(*p)) { if (!ndo->ndo_eflag) ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "length %u", olen)); goto trunc; } msgtype = *p; p++; length--; /* * Peek ahead to see if we start with a shift. */ non_locking_shift = 0; unshift_codeset = codeset; if (length != 0) { if (!ND_TTEST(*p)) { if (!ndo->ndo_eflag) ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "length %u", olen)); goto trunc; } iecode = *p; if (IE_IS_SHIFT(iecode)) { /* * It's a shift. Skip over it. */ p++; length--; /* * Get the codeset. */ codeset = IE_SHIFT_CODESET(iecode); /* * If it's a locking shift to codeset 5, * mark this as ANSI. (XXX - 5 is actually * for national variants in general, not * the US variant in particular, but maybe * this is more American exceptionalism. :-)) */ if (IE_SHIFT_IS_LOCKING(iecode)) { /* * It's a locking shift. */ if (codeset == 5) { /* * It's a locking shift to * codeset 5, so this is * T1.617 Annex D. */ is_ansi = 1; } } else { /* * It's a non-locking shift. * Remember the current codeset, so we * can revert to it after the next IE. */ non_locking_shift = 1; unshift_codeset = 0; } } } /* printing out header part */ if (!ndo->ndo_eflag) ND_PRINT((ndo, ", ")); ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset)); if (call_ref_length != 0) { ND_TCHECK(p[0]); if (call_ref_length > 1 || p[0] != 0) { /* * Not a dummy call reference. */ ND_PRINT((ndo, ", Call Ref: 0x")); for (i = 0; i < call_ref_length; i++) ND_PRINT((ndo, "%02x", call_ref[i])); } } if (ndo->ndo_vflag) { ND_PRINT((ndo, ", %s (0x%02x), length %u", tok2str(fr_q933_msg_values, "unknown message", msgtype), msgtype, olen)); } else { ND_PRINT((ndo, ", %s", tok2str(fr_q933_msg_values, "unknown message 0x%02x", msgtype))); } /* Loop through the rest of the IEs */ while (length != 0) { /* * What's the state of any non-locking shifts? */ if (non_locking_shift == 1) { /* * There's a non-locking shift in effect for * this IE. Count it, so we reset the codeset * before the next IE. */ non_locking_shift = 2; } else if (non_locking_shift == 2) { /* * Unshift. */ codeset = unshift_codeset; non_locking_shift = 0; } /* * Get the first octet of the IE. */ if (!ND_TTEST(*p)) { if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", length %u", olen)); } goto trunc; } iecode = *p; p++; length--; /* Single-octet IE? */ if (IE_IS_SINGLE_OCTET(iecode)) { /* * Yes. Is it a shift? */ if (IE_IS_SHIFT(iecode)) { /* * Yes. Is it locking? */ if (IE_SHIFT_IS_LOCKING(iecode)) { /* * Yes. */ non_locking_shift = 0; } else { /* * No. Remember the current * codeset, so we can revert * to it after the next IE. */ non_locking_shift = 1; unshift_codeset = codeset; } /* * Get the codeset. */ codeset = IE_SHIFT_CODESET(iecode); } } else { /* * No. Get the IE length. */ if (length == 0 || !ND_TTEST(*p)) { if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", length %u", olen)); } goto trunc; } ielength = *p; p++; length--; /* lets do the full IE parsing only in verbose mode * however some IEs (DLCI Status, Link Verify) * are also interesting in non-verbose mode */ if (ndo->ndo_vflag) { ND_PRINT((ndo, "\n\t%s IE (0x%02x), length %u: ", tok2str(fr_q933_ie_codesets[codeset], "unknown", iecode), iecode, ielength)); } /* sanity checks */ if (iecode == 0 || ielength == 0) { return; } if (length < ielength || !ND_TTEST2(*p, ielength)) { if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", length %u", olen)); } goto trunc; } ie_is_known = 0; if (fr_q933_print_ie_codeset[codeset] != NULL) { ie_is_known = fr_q933_print_ie_codeset[codeset](ndo, iecode, ielength, p); } if (ie_is_known) { /* * Known IE; do we want to see a hexdump * of it? */ if (ndo->ndo_vflag > 1) { /* Yes. */ print_unknown_data(ndo, p, "\n\t ", ielength); } } else { /* * Unknown IE; if we're printing verbosely, * print its content in hex. */ if (ndo->ndo_vflag >= 1) { print_unknown_data(ndo, p, "\n\t", ielength); } } length -= ielength; p += ielength; } } if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", length %u", olen)); } return; trunc: ND_PRINT((ndo, "[|q.933]")); } static int fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode, u_int ielength, const u_char *p) { u_int dlci; switch (iecode) { case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */ case FR_LMI_CCITT_REPORT_TYPE_IE: if (ielength < 1) { if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", ")); } ND_PRINT((ndo, "Invalid REPORT TYPE IE")); return 1; } if (ndo->ndo_vflag) { ND_PRINT((ndo, "%s (%u)", tok2str(fr_lmi_report_type_ie_values,"unknown",p[0]), p[0])); } return 1; case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */ case FR_LMI_CCITT_LINK_VERIFY_IE: case FR_LMI_ANSI_LINK_VERIFY_IE_91: if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", ")); } if (ielength < 2) { ND_PRINT((ndo, "Invalid LINK VERIFY IE")); return 1; } ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[0], p[1])); return 1; case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */ case FR_LMI_CCITT_PVC_STATUS_IE: if (!ndo->ndo_vflag) { ND_PRINT((ndo, ", ")); } /* now parse the DLCI information element. */ if ((ielength < 3) || (p[0] & 0x80) || ((ielength == 3) && !(p[1] & 0x80)) || ((ielength == 4) && ((p[1] & 0x80) || !(p[2] & 0x80))) || ((ielength == 5) && ((p[1] & 0x80) || (p[2] & 0x80) || !(p[3] & 0x80))) || (ielength > 5) || !(p[ielength - 1] & 0x80)) { ND_PRINT((ndo, "Invalid DLCI in PVC STATUS IE")); return 1; } dlci = ((p[0] & 0x3F) << 4) | ((p[1] & 0x78) >> 3); if (ielength == 4) { dlci = (dlci << 6) | ((p[2] & 0x7E) >> 1); } else if (ielength == 5) { dlci = (dlci << 13) | (p[2] & 0x7F) | ((p[3] & 0x7E) >> 1); } ND_PRINT((ndo, "DLCI %u: status %s%s", dlci, p[ielength - 1] & 0x8 ? "New, " : "", p[ielength - 1] & 0x2 ? "Active" : "Inactive")); return 1; } return 0; } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-hncp.c =================================================================== --- vendor/tcpdump/dist/print-hncp.c (revision 353143) +++ vendor/tcpdump/dist/print-hncp.c (revision 353144) @@ -1,863 +1,865 @@ /* * Copyright (c) 2016 Antonin DĂ©cimo, Jean-RaphaĂ«l Gaglione * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* \summary: Home Networking Control Protocol (HNCP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" static void hncp_print_rec(netdissect_options *ndo, const u_char *cp, u_int length, int indent); void hncp_print(netdissect_options *ndo, const u_char *cp, u_int length) { ND_PRINT((ndo, "hncp (%d)", length)); hncp_print_rec(ndo, cp, length, 1); } /* RFC7787 */ #define DNCP_REQUEST_NETWORK_STATE 1 #define DNCP_REQUEST_NODE_STATE 2 #define DNCP_NODE_ENDPOINT 3 #define DNCP_NETWORK_STATE 4 #define DNCP_NODE_STATE 5 #define DNCP_PEER 8 #define DNCP_KEEP_ALIVE_INTERVAL 9 #define DNCP_TRUST_VERDICT 10 /* RFC7788 */ #define HNCP_HNCP_VERSION 32 #define HNCP_EXTERNAL_CONNECTION 33 #define HNCP_DELEGATED_PREFIX 34 #define HNCP_PREFIX_POLICY 43 -#define HNCP_DHCPV4_DATA 37 -#define HNCP_DHCPV6_DATA 38 +#define HNCP_DHCPV4_DATA 37 /* This is correct, see RFC 7788 Errata ID 5113. */ +#define HNCP_DHCPV6_DATA 38 /* idem */ #define HNCP_ASSIGNED_PREFIX 35 #define HNCP_NODE_ADDRESS 36 #define HNCP_DNS_DELEGATED_ZONE 39 #define HNCP_DOMAIN_NAME 40 #define HNCP_NODE_NAME 41 #define HNCP_MANAGED_PSK 42 /* See type_mask in hncp_print_rec below */ #define RANGE_DNCP_RESERVED 0x10000 #define RANGE_HNCP_UNASSIGNED 0x10001 #define RANGE_DNCP_PRIVATE_USE 0x10002 #define RANGE_DNCP_FUTURE_USE 0x10003 static const struct tok type_values[] = { { DNCP_REQUEST_NETWORK_STATE, "Request network state" }, { DNCP_REQUEST_NODE_STATE, "Request node state" }, { DNCP_NODE_ENDPOINT, "Node endpoint" }, { DNCP_NETWORK_STATE, "Network state" }, { DNCP_NODE_STATE, "Node state" }, { DNCP_PEER, "Peer" }, { DNCP_KEEP_ALIVE_INTERVAL, "Keep-alive interval" }, { DNCP_TRUST_VERDICT, "Trust-Verdict" }, { HNCP_HNCP_VERSION, "HNCP-Version" }, { HNCP_EXTERNAL_CONNECTION, "External-Connection" }, { HNCP_DELEGATED_PREFIX, "Delegated-Prefix" }, { HNCP_PREFIX_POLICY, "Prefix-Policy" }, { HNCP_DHCPV4_DATA, "DHCPv4-Data" }, { HNCP_DHCPV6_DATA, "DHCPv6-Data" }, { HNCP_ASSIGNED_PREFIX, "Assigned-Prefix" }, { HNCP_NODE_ADDRESS, "Node-Address" }, { HNCP_DNS_DELEGATED_ZONE, "DNS-Delegated-Zone" }, { HNCP_DOMAIN_NAME, "Domain-Name" }, { HNCP_NODE_NAME, "Node-Name" }, { HNCP_MANAGED_PSK, "Managed-PSK" }, { RANGE_DNCP_RESERVED, "Reserved" }, { RANGE_HNCP_UNASSIGNED, "Unassigned" }, { RANGE_DNCP_PRIVATE_USE, "Private use" }, { RANGE_DNCP_FUTURE_USE, "Future use" }, { 0, NULL} }; #define DH4OPT_DNS_SERVERS 6 /* RFC2132 */ #define DH4OPT_NTP_SERVERS 42 /* RFC2132 */ #define DH4OPT_DOMAIN_SEARCH 119 /* RFC3397 */ static const struct tok dh4opt_str[] = { { DH4OPT_DNS_SERVERS, "DNS-server" }, { DH4OPT_NTP_SERVERS, "NTP-server"}, { DH4OPT_DOMAIN_SEARCH, "DNS-search" }, { 0, NULL } }; #define DH6OPT_DNS_SERVERS 23 /* RFC3646 */ #define DH6OPT_DOMAIN_LIST 24 /* RFC3646 */ #define DH6OPT_SNTP_SERVERS 31 /* RFC4075 */ static const struct tok dh6opt_str[] = { { DH6OPT_DNS_SERVERS, "DNS-server" }, { DH6OPT_DOMAIN_LIST, "DNS-search-list" }, { DH6OPT_SNTP_SERVERS, "SNTP-servers" }, { 0, NULL } }; /* * For IPv4-mapped IPv6 addresses, length of the prefix that precedes * the 4 bytes of IPv4 address at the end of the IPv6 address. */ #define IPV4_MAPPED_HEADING_LEN 12 /* * Is an IPv6 address an IPv4-mapped address? */ static inline int is_ipv4_mapped_address(const u_char *addr) { /* The value of the prefix */ static const u_char ipv4_mapped_heading[IPV4_MAPPED_HEADING_LEN] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF }; return memcmp(addr, ipv4_mapped_heading, IPV4_MAPPED_HEADING_LEN) == 0; } static const char * format_nid(const u_char *data) { - static char buf[4][11+5]; + static char buf[4][sizeof("01:01:01:01")]; static int i = 0; i = (i + 1) % 4; - snprintf(buf[i], 16, "%02x:%02x:%02x:%02x", + snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x", data[0], data[1], data[2], data[3]); return buf[i]; } static const char * format_256(const u_char *data) { - static char buf[4][64+5]; + static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")]; static int i = 0; i = (i + 1) % 4; - snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, + snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, EXTRACT_64BITS(data), EXTRACT_64BITS(data + 8), EXTRACT_64BITS(data + 16), EXTRACT_64BITS(data + 24) ); return buf[i]; } static const char * format_interval(const uint32_t n) { static char buf[4][sizeof("0000000.000s")]; static int i = 0; i = (i + 1) % 4; snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000); return buf[i]; } static const char * format_ip6addr(netdissect_options *ndo, const u_char *cp) { if (is_ipv4_mapped_address(cp)) return ipaddr_string(ndo, cp + IPV4_MAPPED_HEADING_LEN); else return ip6addr_string(ndo, cp); } static int print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length) { int plenbytes; char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx::/128")]; if (prefix[0] >= 96 && max_length >= IPV4_MAPPED_HEADING_LEN + 1 && is_ipv4_mapped_address(&prefix[1])) { struct in_addr addr; u_int plen; plen = prefix[0]-96; if (32 < plen) return -1; max_length -= 1; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; if (max_length < (u_int)plenbytes + IPV4_MAPPED_HEADING_LEN) return -3; memcpy(&addr, &prefix[1 + IPV4_MAPPED_HEADING_LEN], plenbytes); if (plen % 8) { ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, sizeof(buf), "%s/%d", ipaddr_string(ndo, &addr), plen); plenbytes += 1 + IPV4_MAPPED_HEADING_LEN; } else { plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf)); + if (plenbytes < 0) + return plenbytes; } ND_PRINT((ndo, "%s", buf)); return plenbytes; } static int print_dns_label(netdissect_options *ndo, const u_char *cp, u_int max_length, int print) { u_int length = 0; while (length < max_length) { u_int lab_length = cp[length++]; if (lab_length == 0) return (int)length; if (length > 1 && print) safeputchar(ndo, '.'); if (length+lab_length > max_length) { if (print) safeputs(ndo, cp+length, max_length-length); break; } if (print) safeputs(ndo, cp+length, lab_length); length += lab_length; } if (print) ND_PRINT((ndo, "[|DNS]")); return -1; } static int dhcpv4_print(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { u_int i, t; const u_char *tlv, *value; uint8_t type, optlen; i = 0; while (i < length) { if (i + 2 > length) return -1; tlv = cp + i; type = (uint8_t)tlv[0]; optlen = (uint8_t)tlv[1]; value = tlv + 2; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); ND_PRINT((ndo, "%s", tok2str(dh4opt_str, "Unknown", type))); ND_PRINT((ndo," (%u)", optlen + 2 )); if (i + 2 + optlen > length) return -1; switch (type) { case DH4OPT_DNS_SERVERS: case DH4OPT_NTP_SERVERS: { if (optlen < 4 || optlen % 4 != 0) { return -1; } for (t = 0; t < optlen; t += 4) ND_PRINT((ndo, " %s", ipaddr_string(ndo, value + t))); } break; case DH4OPT_DOMAIN_SEARCH: { const u_char *tp = value; while (tp < value + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL) return -1; } } break; } i += 2 + optlen; } return 0; } static int dhcpv6_print(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { u_int i, t; const u_char *tlv, *value; uint16_t type, optlen; i = 0; while (i < length) { if (i + 4 > length) return -1; tlv = cp + i; type = EXTRACT_16BITS(tlv); optlen = EXTRACT_16BITS(tlv + 2); value = tlv + 4; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); ND_PRINT((ndo, "%s", tok2str(dh6opt_str, "Unknown", type))); ND_PRINT((ndo," (%u)", optlen + 4 )); if (i + 4 + optlen > length) return -1; switch (type) { case DH6OPT_DNS_SERVERS: case DH6OPT_SNTP_SERVERS: { if (optlen % 16 != 0) { ND_PRINT((ndo, " %s", istr)); return -1; } for (t = 0; t < optlen; t += 16) ND_PRINT((ndo, " %s", ip6addr_string(ndo, value + t))); } break; case DH6OPT_DOMAIN_LIST: { const u_char *tp = value; while (tp < value + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL) return -1; } } break; } i += 4 + optlen; } return 0; } /* Determine in-line mode */ static int is_in_line(netdissect_options *ndo, int indent) { return indent - 1 >= ndo->ndo_vflag && ndo->ndo_vflag < 3; } static void print_type_in_line(netdissect_options *ndo, uint32_t type, int count, int indent, int *first_one) { if (count > 0) { if (*first_one) { *first_one = 0; if (indent > 1) { u_int t; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); } else { ND_PRINT((ndo, " ")); } } else { ND_PRINT((ndo, ", ")); } ND_PRINT((ndo, "%s", tok2str(type_values, "Easter Egg", type))); if (count > 1) ND_PRINT((ndo, " (x%d)", count)); } } void hncp_print_rec(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { const int in_line = is_in_line(ndo, indent); int first_one = 1; u_int i, t; uint32_t last_type_mask = 0xffffffffU; int last_type_count = -1; const u_char *tlv, *value; uint16_t type, bodylen; uint32_t type_mask; i = 0; while (i < length) { tlv = cp + i; if (!in_line) { ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); } ND_TCHECK2(*tlv, 4); if (i + 4 > length) goto invalid; type = EXTRACT_16BITS(tlv); bodylen = EXTRACT_16BITS(tlv + 2); value = tlv + 4; ND_TCHECK2(*value, bodylen); if (i + bodylen + 4 > length) goto invalid; type_mask = (type == 0) ? RANGE_DNCP_RESERVED: (44 <= type && type <= 511) ? RANGE_HNCP_UNASSIGNED: (768 <= type && type <= 1023) ? RANGE_DNCP_PRIVATE_USE: RANGE_DNCP_FUTURE_USE; if (type == 6 || type == 7) type_mask = RANGE_DNCP_FUTURE_USE; /* defined types */ { t = 0; while (1) { u_int key = type_values[t++].v; if (key > 0xffff) break; if (key == type) { type_mask = type; break; } } } if (in_line) { if (last_type_mask == type_mask) { last_type_count++; } else { print_type_in_line(ndo, last_type_mask, last_type_count, indent, &first_one); last_type_mask = type_mask; last_type_count = 1; } goto skip_multiline; } ND_PRINT((ndo,"%s", tok2str(type_values, "Easter Egg (42)", type_mask) )); if (type_mask > 0xffff) ND_PRINT((ndo,": type=%u", type )); ND_PRINT((ndo," (%u)", bodylen + 4 )); switch (type_mask) { case DNCP_REQUEST_NETWORK_STATE: { if (bodylen != 0) ND_PRINT((ndo, " %s", istr)); } break; case DNCP_REQUEST_NODE_STATE: { const char *node_identifier; if (bodylen != 4) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); ND_PRINT((ndo, " NID: %s", node_identifier)); } break; case DNCP_NODE_ENDPOINT: { const char *node_identifier; uint32_t endpoint_identifier; if (bodylen != 8) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); endpoint_identifier = EXTRACT_32BITS(value + 4); ND_PRINT((ndo, " NID: %s EPID: %08x", node_identifier, endpoint_identifier )); } break; case DNCP_NETWORK_STATE: { uint64_t hash; if (bodylen != 8) { ND_PRINT((ndo, " %s", istr)); break; } hash = EXTRACT_64BITS(value); ND_PRINT((ndo, " hash: %016" PRIx64, hash)); } break; case DNCP_NODE_STATE: { const char *node_identifier, *interval; uint32_t sequence_number; uint64_t hash; if (bodylen < 20) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); sequence_number = EXTRACT_32BITS(value + 4); interval = format_interval(EXTRACT_32BITS(value + 8)); hash = EXTRACT_64BITS(value + 12); ND_PRINT((ndo, " NID: %s seqno: %u %s hash: %016" PRIx64, node_identifier, sequence_number, interval, hash )); hncp_print_rec(ndo, value+20, bodylen-20, indent+1); } break; case DNCP_PEER: { const char *peer_node_identifier; uint32_t peer_endpoint_identifier, endpoint_identifier; if (bodylen != 12) { ND_PRINT((ndo, " %s", istr)); break; } peer_node_identifier = format_nid(value); peer_endpoint_identifier = EXTRACT_32BITS(value + 4); endpoint_identifier = EXTRACT_32BITS(value + 8); ND_PRINT((ndo, " Peer-NID: %s Peer-EPID: %08x Local-EPID: %08x", peer_node_identifier, peer_endpoint_identifier, endpoint_identifier )); } break; case DNCP_KEEP_ALIVE_INTERVAL: { uint32_t endpoint_identifier; const char *interval; if (bodylen < 8) { ND_PRINT((ndo, " %s", istr)); break; } endpoint_identifier = EXTRACT_32BITS(value); interval = format_interval(EXTRACT_32BITS(value + 4)); ND_PRINT((ndo, " EPID: %08x Interval: %s", endpoint_identifier, interval )); } break; case DNCP_TRUST_VERDICT: { if (bodylen <= 36) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " Verdict: %u Fingerprint: %s Common Name: ", *value, format_256(value + 4))); safeputs(ndo, value + 36, bodylen - 36); } break; case HNCP_HNCP_VERSION: { uint16_t capabilities; uint8_t M, P, H, L; if (bodylen < 5) { ND_PRINT((ndo, " %s", istr)); break; } capabilities = EXTRACT_16BITS(value + 2); M = (uint8_t)((capabilities >> 12) & 0xf); P = (uint8_t)((capabilities >> 8) & 0xf); H = (uint8_t)((capabilities >> 4) & 0xf); L = (uint8_t)(capabilities & 0xf); ND_PRINT((ndo, " M: %u P: %u H: %u L: %u User-agent: ", M, P, H, L )); safeputs(ndo, value + 4, bodylen - 4); } break; case HNCP_EXTERNAL_CONNECTION: { /* Container TLV */ hncp_print_rec(ndo, value, bodylen, indent+1); } break; case HNCP_DELEGATED_PREFIX: { int l; if (bodylen < 9 || bodylen < 9 + (value[8] + 7) / 8) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " VLSO: %s PLSO: %s Prefix: ", format_interval(EXTRACT_32BITS(value)), format_interval(EXTRACT_32BITS(value + 4)) )); l = print_prefix(ndo, value + 8, bodylen - 8); if (l == -1) { ND_PRINT((ndo, "(length is invalid)")); break; } if (l < 0) { /* * We've already checked that we've captured the * entire TLV, based on its length, so this will * either be -1, meaning "the prefix length is * greater than the longest possible address of * that type" (i.e., > 32 for IPv4 or > 128 for * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ ND_PRINT((ndo, " %s", istr)); break; } l += 8 + (-l & 3); if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_PREFIX_POLICY: { uint8_t policy; int l; if (bodylen < 1) { ND_PRINT((ndo, " %s", istr)); break; } policy = value[0]; ND_PRINT((ndo, " type: ")); if (policy == 0) { if (bodylen != 1) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, "Internet connectivity")); } else if (policy >= 1 && policy <= 128) { ND_PRINT((ndo, "Dest-Prefix: ")); l = print_prefix(ndo, value, bodylen); if (l == -1) { ND_PRINT((ndo, "(length is invalid)")); break; } if (l < 0) { /* * We've already checked that we've captured the * entire TLV, based on its length, so this will * either be -1, meaning "the prefix length is * greater than the longest possible address of * that type" (i.e., > 32 for IPv4 or > 128 for * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ ND_PRINT((ndo, " %s", istr)); break; } } else if (policy == 129) { ND_PRINT((ndo, "DNS domain: ")); print_dns_label(ndo, value+1, bodylen-1, 1); } else if (policy == 130) { ND_PRINT((ndo, "Opaque UTF-8: ")); safeputs(ndo, value + 1, bodylen - 1); } else if (policy == 131) { if (bodylen != 1) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, "Restrictive assignment")); } else if (policy >= 132) { ND_PRINT((ndo, "Unknown (%u)", policy)); /* Reserved for future additions */ } } break; case HNCP_DHCPV4_DATA: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } if (dhcpv4_print(ndo, value, bodylen, indent+1) != 0) goto invalid; } break; case HNCP_DHCPV6_DATA: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } if (dhcpv6_print(ndo, value, bodylen, indent+1) != 0) { ND_PRINT((ndo, " %s", istr)); break; } } break; case HNCP_ASSIGNED_PREFIX: { uint8_t prty; int l; if (bodylen < 6 || bodylen < 6 + (value[5] + 7) / 8) { ND_PRINT((ndo, " %s", istr)); break; } prty = (uint8_t)(value[4] & 0xf); ND_PRINT((ndo, " EPID: %08x Prty: %u", EXTRACT_32BITS(value), prty )); ND_PRINT((ndo, " Prefix: ")); if ((l = print_prefix(ndo, value + 5, bodylen - 5)) < 0) { ND_PRINT((ndo, " %s", istr)); break; } l += 5; l += -l & 3; if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_NODE_ADDRESS: { uint32_t endpoint_identifier; const char *ip_address; if (bodylen < 20) { ND_PRINT((ndo, " %s", istr)); break; } endpoint_identifier = EXTRACT_32BITS(value); ip_address = format_ip6addr(ndo, value + 4); ND_PRINT((ndo, " EPID: %08x IP Address: %s", endpoint_identifier, ip_address )); hncp_print_rec(ndo, value + 20, bodylen - 20, indent+1); } break; case HNCP_DNS_DELEGATED_ZONE: { const char *ip_address; int len; if (bodylen < 17) { ND_PRINT((ndo, " %s", istr)); break; } ip_address = format_ip6addr(ndo, value); ND_PRINT((ndo, " IP-Address: %s %c%c%c ", ip_address, (value[16] & 4) ? 'l' : '-', (value[16] & 2) ? 'b' : '-', (value[16] & 1) ? 's' : '-' )); len = print_dns_label(ndo, value+17, bodylen-17, 1); if (len < 0) { ND_PRINT((ndo, " %s", istr)); break; } len += 17; len += -len & 3; if (bodylen >= len) hncp_print_rec(ndo, value+len, bodylen-len, indent+1); } break; case HNCP_DOMAIN_NAME: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " Domain: ")); print_dns_label(ndo, value, bodylen, 1); } break; case HNCP_NODE_NAME: { u_int l; if (bodylen < 17) { ND_PRINT((ndo, " %s", istr)); break; } l = value[16]; if (bodylen < 17 + l) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " IP-Address: %s Name: ", format_ip6addr(ndo, value) )); if (l < 64) { safeputchar(ndo, '"'); safeputs(ndo, value + 17, l); safeputchar(ndo, '"'); } else { ND_PRINT((ndo, "%s", istr)); } l += 17; l += -l & 3; if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_MANAGED_PSK: { if (bodylen < 32) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " PSK: %s", format_256(value))); hncp_print_rec(ndo, value + 32, bodylen - 32, indent+1); } break; case RANGE_DNCP_RESERVED: case RANGE_HNCP_UNASSIGNED: case RANGE_DNCP_PRIVATE_USE: case RANGE_DNCP_FUTURE_USE: break; } skip_multiline: i += 4 + bodylen + (-bodylen & 3); } print_type_in_line(ndo, last_type_mask, last_type_count, indent, &first_one); return; trunc: ND_PRINT((ndo, "%s", "[|hncp]")); return; invalid: ND_PRINT((ndo, "%s", istr)); return; } Index: vendor/tcpdump/dist/print-icmp.c =================================================================== --- vendor/tcpdump/dist/print-icmp.c (revision 353143) +++ vendor/tcpdump/dist/print-icmp.c (revision 353144) @@ -1,702 +1,704 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 * 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. */ /* \summary: Internet Control Message Protocol (ICMP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "ip.h" #include "udp.h" #include "ipproto.h" #include "mpls.h" /* * Interface Control Message Protocol Definitions. * Per RFC 792, September 1981. */ /* * Structure of an icmp header. */ struct icmp { uint8_t icmp_type; /* type of message, see below */ uint8_t icmp_code; /* type sub code */ uint16_t icmp_cksum; /* ones complement cksum of struct */ union { uint8_t ih_pptr; /* ICMP_PARAMPROB */ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ struct ih_idseq { uint16_t icd_id; uint16_t icd_seq; } ih_idseq; uint32_t ih_void; } icmp_hun; #define icmp_pptr icmp_hun.ih_pptr #define icmp_gwaddr icmp_hun.ih_gwaddr #define icmp_id icmp_hun.ih_idseq.icd_id #define icmp_seq icmp_hun.ih_idseq.icd_seq #define icmp_void icmp_hun.ih_void union { struct id_ts { uint32_t its_otime; uint32_t its_rtime; uint32_t its_ttime; } id_ts; struct id_ip { struct ip idi_ip; /* options and then 64 bits of data */ } id_ip; uint32_t id_mask; uint8_t id_data[1]; } icmp_dun; #define icmp_otime icmp_dun.id_ts.its_otime #define icmp_rtime icmp_dun.id_ts.its_rtime #define icmp_ttime icmp_dun.id_ts.its_ttime #define icmp_ip icmp_dun.id_ip.idi_ip #define icmp_mask icmp_dun.id_mask #define icmp_data icmp_dun.id_data }; #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) #define ICMP_MPLS_EXT_VERSION 2 /* * Lower bounds on packet lengths for various types. * For the error advice packets must first insure that the * packet is large enought to contain the returned ip header. * Only then can we do the check to see if 64 bits of packet * data have been returned, since we need to check the returned * ip header length. */ #define ICMP_MINLEN 8 /* abs minimum */ #define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */ #define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */ #define ICMP_MASKLEN 12 /* address mask */ #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ #define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8) /* N.B.: must separately check that ip_hl >= 5 */ /* * Definition of type and code field values. */ #define ICMP_ECHOREPLY 0 /* echo reply */ #define ICMP_UNREACH 3 /* dest unreachable, codes: */ #define ICMP_UNREACH_NET 0 /* bad net */ #define ICMP_UNREACH_HOST 1 /* bad host */ #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ #define ICMP_UNREACH_PORT 3 /* bad port */ #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ #define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */ #define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */ #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ #define ICMP_REDIRECT 5 /* shorter route, codes: */ #define ICMP_REDIRECT_NET 0 /* for network */ #define ICMP_REDIRECT_HOST 1 /* for host */ #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ #define ICMP_ECHO 8 /* echo service */ #define ICMP_ROUTERADVERT 9 /* router advertisement */ #define ICMP_ROUTERSOLICIT 10 /* router solicitation */ #define ICMP_TIMXCEED 11 /* time exceeded, code: */ #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ #define ICMP_PARAMPROB 12 /* ip header bad */ #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ #define ICMP_TSTAMP 13 /* timestamp request */ #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ #define ICMP_IREQ 15 /* information request */ #define ICMP_IREQREPLY 16 /* information reply */ #define ICMP_MASKREQ 17 /* address mask request */ #define ICMP_MASKREPLY 18 /* address mask reply */ #define ICMP_MAXTYPE 18 #define ICMP_ERRTYPE(type) \ ((type) == ICMP_UNREACH || (type) == ICMP_SOURCEQUENCH || \ (type) == ICMP_REDIRECT || (type) == ICMP_TIMXCEED || \ (type) == ICMP_PARAMPROB) #define ICMP_MPLS_EXT_TYPE(type) \ ((type) == ICMP_UNREACH || \ (type) == ICMP_TIMXCEED || \ (type) == ICMP_PARAMPROB) /* rfc1700 */ #ifndef ICMP_UNREACH_NET_UNKNOWN #define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */ #endif #ifndef ICMP_UNREACH_HOST_UNKNOWN #define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */ #endif #ifndef ICMP_UNREACH_ISOLATED #define ICMP_UNREACH_ISOLATED 8 /* source host isolated */ #endif #ifndef ICMP_UNREACH_NET_PROHIB #define ICMP_UNREACH_NET_PROHIB 9 /* admin prohibited net */ #endif #ifndef ICMP_UNREACH_HOST_PROHIB #define ICMP_UNREACH_HOST_PROHIB 10 /* admin prohibited host */ #endif #ifndef ICMP_UNREACH_TOSNET #define ICMP_UNREACH_TOSNET 11 /* tos prohibited net */ #endif #ifndef ICMP_UNREACH_TOSHOST #define ICMP_UNREACH_TOSHOST 12 /* tos prohibited host */ #endif /* rfc1716 */ #ifndef ICMP_UNREACH_FILTER_PROHIB #define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohibited filter */ #endif #ifndef ICMP_UNREACH_HOST_PRECEDENCE #define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */ #endif #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */ #endif /* Most of the icmp types */ static const struct tok icmp2str[] = { { ICMP_ECHOREPLY, "echo reply" }, { ICMP_SOURCEQUENCH, "source quench" }, { ICMP_ECHO, "echo request" }, { ICMP_ROUTERSOLICIT, "router solicitation" }, { ICMP_TSTAMP, "time stamp request" }, { ICMP_TSTAMPREPLY, "time stamp reply" }, { ICMP_IREQ, "information request" }, { ICMP_IREQREPLY, "information reply" }, { ICMP_MASKREQ, "address mask request" }, { 0, NULL } }; /* Formats for most of the ICMP_UNREACH codes */ static const struct tok unreach2str[] = { { ICMP_UNREACH_NET, "net %s unreachable" }, { ICMP_UNREACH_HOST, "host %s unreachable" }, { ICMP_UNREACH_SRCFAIL, "%s unreachable - source route failed" }, { ICMP_UNREACH_NET_UNKNOWN, "net %s unreachable - unknown" }, { ICMP_UNREACH_HOST_UNKNOWN, "host %s unreachable - unknown" }, { ICMP_UNREACH_ISOLATED, "%s unreachable - source host isolated" }, { ICMP_UNREACH_NET_PROHIB, "net %s unreachable - admin prohibited" }, { ICMP_UNREACH_HOST_PROHIB, "host %s unreachable - admin prohibited" }, { ICMP_UNREACH_TOSNET, "net %s unreachable - tos prohibited" }, { ICMP_UNREACH_TOSHOST, "host %s unreachable - tos prohibited" }, { ICMP_UNREACH_FILTER_PROHIB, "host %s unreachable - admin prohibited filter" }, { ICMP_UNREACH_HOST_PRECEDENCE, "host %s unreachable - host precedence violation" }, { ICMP_UNREACH_PRECEDENCE_CUTOFF, "host %s unreachable - precedence cutoff" }, { 0, NULL } }; /* Formats for the ICMP_REDIRECT codes */ static const struct tok type2str[] = { { ICMP_REDIRECT_NET, "redirect %s to net %s" }, { ICMP_REDIRECT_HOST, "redirect %s to host %s" }, { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" }, { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to host %s" }, { 0, NULL } }; /* rfc1191 */ struct mtu_discovery { uint16_t unused; uint16_t nexthopmtu; }; /* rfc1256 */ struct ih_rdiscovery { uint8_t ird_addrnum; uint8_t ird_addrsiz; uint16_t ird_lifetime; }; struct id_rdiscovery { uint32_t ird_addr; uint32_t ird_pref; }; /* * draft-bonica-internet-icmp-08 * * The Destination Unreachable, Time Exceeded * and Parameter Problem messages are slighly changed as per * the above draft. A new Length field gets added to give * the caller an idea about the length of the piggypacked * IP packet before the MPLS extension header starts. * * The Length field represents length of the padded "original datagram" * field measured in 32-bit words. * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Type | Code | Checksum | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | unused | Length | unused | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Internet Header + leading octets of original datagram | * | | * | // | * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct icmp_ext_t { uint8_t icmp_type; uint8_t icmp_code; uint8_t icmp_checksum[2]; uint8_t icmp_reserved; uint8_t icmp_length; uint8_t icmp_reserved2[2]; uint8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */ uint8_t icmp_ext_version_res[2]; uint8_t icmp_ext_checksum[2]; uint8_t icmp_ext_data[1]; }; struct icmp_mpls_ext_object_header_t { uint8_t length[2]; uint8_t class_num; uint8_t ctype; }; static const struct tok icmp_mpls_ext_obj_values[] = { { 1, "MPLS Stack Entry" }, { 2, "Extended Payload" }, { 0, NULL} }; /* prototypes */ const char *icmp_tstamp_print(u_int); /* print the milliseconds since midnight UTC */ const char * icmp_tstamp_print(u_int tstamp) { u_int msec,sec,min,hrs; static char buf[64]; msec = tstamp % 1000; sec = tstamp / 1000; min = sec / 60; sec -= min * 60; hrs = min / 60; min -= hrs * 60; snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec); return buf; } void icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2, int fragmented) { char *cp; const struct icmp *dp; const struct icmp_ext_t *ext_dp; const struct ip *ip; const char *str, *fmt; const struct ip *oip; const struct udphdr *ouh; const uint8_t *obj_tptr; uint32_t raw_label; const u_char *snapend_save; const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header; u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype; char buf[MAXHOSTNAMELEN + 100]; struct cksum_vec vec[1]; dp = (const struct icmp *)bp; ext_dp = (const struct icmp_ext_t *)bp; ip = (const struct ip *)bp2; str = buf; ND_TCHECK(dp->icmp_code); switch (dp->icmp_type) { case ICMP_ECHO: case ICMP_ECHOREPLY: ND_TCHECK(dp->icmp_seq); (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u", dp->icmp_type == ICMP_ECHO ? "request" : "reply", EXTRACT_16BITS(&dp->icmp_id), EXTRACT_16BITS(&dp->icmp_seq)); break; case ICMP_UNREACH: ND_TCHECK(dp->icmp_ip.ip_dst); switch (dp->icmp_code) { case ICMP_UNREACH_PROTOCOL: ND_TCHECK(dp->icmp_ip.ip_p); (void)snprintf(buf, sizeof(buf), "%s protocol %d unreachable", ipaddr_string(ndo, &dp->icmp_ip.ip_dst), dp->icmp_ip.ip_p); break; case ICMP_UNREACH_PORT: ND_TCHECK(dp->icmp_ip.ip_p); oip = &dp->icmp_ip; hlen = IP_HL(oip) * 4; ouh = (const struct udphdr *)(((const u_char *)oip) + hlen); ND_TCHECK(ouh->uh_dport); dport = EXTRACT_16BITS(&ouh->uh_dport); switch (oip->ip_p) { case IPPROTO_TCP: (void)snprintf(buf, sizeof(buf), "%s tcp port %s unreachable", ipaddr_string(ndo, &oip->ip_dst), tcpport_string(ndo, dport)); break; case IPPROTO_UDP: (void)snprintf(buf, sizeof(buf), "%s udp port %s unreachable", ipaddr_string(ndo, &oip->ip_dst), udpport_string(ndo, dport)); break; default: (void)snprintf(buf, sizeof(buf), - "%s protocol %d port %d unreachable", + "%s protocol %u port %u unreachable", ipaddr_string(ndo, &oip->ip_dst), oip->ip_p, dport); break; } break; case ICMP_UNREACH_NEEDFRAG: { register const struct mtu_discovery *mp; mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void; mtu = EXTRACT_16BITS(&mp->nexthopmtu); if (mtu) { (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag (mtu %d)", ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu); } else { (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag", ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); } } break; default: fmt = tok2str(unreach2str, "#%d %%s unreachable", dp->icmp_code); (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(ndo, &dp->icmp_ip.ip_dst)); break; } break; case ICMP_REDIRECT: ND_TCHECK(dp->icmp_ip.ip_dst); fmt = tok2str(type2str, "redirect-#%d %%s to net %%s", dp->icmp_code); (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(ndo, &dp->icmp_ip.ip_dst), ipaddr_string(ndo, &dp->icmp_gwaddr)); break; case ICMP_ROUTERADVERT: { register const struct ih_rdiscovery *ihp; register const struct id_rdiscovery *idp; u_int lifetime, num, size; (void)snprintf(buf, sizeof(buf), "router advertisement"); cp = buf + strlen(buf); ihp = (const struct ih_rdiscovery *)&dp->icmp_void; ND_TCHECK(*ihp); (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf)); cp = buf + strlen(buf); lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); if (lifetime < 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", lifetime); } else if (lifetime < 60 * 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", lifetime / 60, lifetime % 60); } else { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u:%02u", lifetime / 3600, (lifetime % 3600) / 60, lifetime % 60); } cp = buf + strlen(buf); num = ihp->ird_addrnum; (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num); cp = buf + strlen(buf); size = ihp->ird_addrsiz; if (size != 2) { (void)snprintf(cp, sizeof(buf) - (cp - buf), " [size %d]", size); break; } idp = (const struct id_rdiscovery *)&dp->icmp_data; while (num-- > 0) { ND_TCHECK(*idp); (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", ipaddr_string(ndo, &idp->ird_addr), EXTRACT_32BITS(&idp->ird_pref)); cp = buf + strlen(buf); ++idp; } } break; case ICMP_TIMXCEED: ND_TCHECK(dp->icmp_ip.ip_dst); switch (dp->icmp_code) { case ICMP_TIMXCEED_INTRANS: str = "time exceeded in-transit"; break; case ICMP_TIMXCEED_REASS: str = "ip reassembly time exceeded"; break; default: - (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", + (void)snprintf(buf, sizeof(buf), "time exceeded-#%u", dp->icmp_code); break; } break; case ICMP_PARAMPROB: if (dp->icmp_code) (void)snprintf(buf, sizeof(buf), - "parameter problem - code %d", dp->icmp_code); + "parameter problem - code %u", dp->icmp_code); else { ND_TCHECK(dp->icmp_pptr); (void)snprintf(buf, sizeof(buf), - "parameter problem - octet %d", dp->icmp_pptr); + "parameter problem - octet %u", dp->icmp_pptr); } break; case ICMP_MASKREPLY: ND_TCHECK(dp->icmp_mask); (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", EXTRACT_32BITS(&dp->icmp_mask)); break; case ICMP_TSTAMP: ND_TCHECK(dp->icmp_seq); (void)snprintf(buf, sizeof(buf), "time stamp query id %u seq %u", EXTRACT_16BITS(&dp->icmp_id), EXTRACT_16BITS(&dp->icmp_seq)); break; case ICMP_TSTAMPREPLY: ND_TCHECK(dp->icmp_ttime); (void)snprintf(buf, sizeof(buf), "time stamp reply id %u seq %u: org %s", EXTRACT_16BITS(&dp->icmp_id), EXTRACT_16BITS(&dp->icmp_seq), icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_otime))); (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", recv %s", icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_rtime))); (void)snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),", xmit %s", icmp_tstamp_print(EXTRACT_32BITS(&dp->icmp_ttime))); break; default: str = tok2str(icmp2str, "type-#%d", dp->icmp_type); break; } ND_PRINT((ndo, "ICMP %s, length %u", str, plen)); if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */ - uint16_t sum, icmp_sum; - if (ND_TTEST2(*bp, plen)) { + uint16_t sum; + vec[0].ptr = (const uint8_t *)(const void *)dp; vec[0].len = plen; sum = in_cksum(vec, 1); if (sum != 0) { + uint16_t icmp_sum; + ND_TCHECK_16BITS(&dp->icmp_cksum); icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum); ND_PRINT((ndo, " (wrong icmp cksum %x (->%x)!)", icmp_sum, in_cksum_shouldbe(icmp_sum, sum))); } } } /* * print the remnants of the IP packet. * save the snaplength as this may get overidden in the IP printer. */ if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) { bp += 8; ND_PRINT((ndo, "\n\t")); ip = (const struct ip *)bp; ndo->ndo_snaplen = ndo->ndo_snapend - bp; snapend_save = ndo->ndo_snapend; ND_TCHECK_16BITS(&ip->ip_len); ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len)); ndo->ndo_snapend = snapend_save; } /* * Attempt to decode the MPLS extensions only for some ICMP types. */ if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) { ND_TCHECK(*ext_dp); /* * Check first if the mpls extension header shows a non-zero length. * If the length field is not set then silently verify the checksum * to check if an extension header is present. This is expedient, * however not all implementations set the length field proper. */ if (!ext_dp->icmp_length && ND_TTEST2(ext_dp->icmp_ext_version_res, plen - ICMP_EXTD_MINLEN)) { vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; vec[0].len = plen - ICMP_EXTD_MINLEN; if (in_cksum(vec, 1)) { return; } } ND_PRINT((ndo, "\n\tMPLS extension v%u", ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)))); /* * Sanity checking of the header. */ if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) != ICMP_MPLS_EXT_VERSION) { ND_PRINT((ndo, " packet not supported")); return; } hlen = plen - ICMP_EXTD_MINLEN; if (ND_TTEST2(ext_dp->icmp_ext_version_res, hlen)) { vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res; vec[0].len = hlen; ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u", EXTRACT_16BITS(ext_dp->icmp_ext_checksum), in_cksum(vec, 1) ? "in" : "", hlen)); } hlen -= 4; /* subtract common header size */ obj_tptr = (const uint8_t *)ext_dp->icmp_ext_data; while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) { icmp_mpls_ext_object_header = (const struct icmp_mpls_ext_object_header_t *)obj_tptr; ND_TCHECK(*icmp_mpls_ext_object_header); obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length); obj_class_num = icmp_mpls_ext_object_header->class_num; obj_ctype = icmp_mpls_ext_object_header->ctype; obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t); ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %u, length %u", tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num), obj_class_num, obj_ctype, obj_tlen)); hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */ /* infinite loop protection */ if ((obj_class_num == 0) || (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) { return; } obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t); switch (obj_class_num) { case 1: switch(obj_ctype) { case 1: ND_TCHECK2(*obj_tptr, 4); raw_label = EXTRACT_32BITS(obj_tptr); ND_PRINT((ndo, "\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label))); if (MPLS_STACK(raw_label)) ND_PRINT((ndo, ", [S]")); ND_PRINT((ndo, ", ttl %u", MPLS_TTL(raw_label))); break; default: print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen); } break; /* * FIXME those are the defined objects that lack a decoder * you are welcome to contribute code ;-) */ case 2: default: print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen); break; } if (hlen < obj_tlen) break; hlen -= obj_tlen; obj_tptr += obj_tlen; } } return; trunc: ND_PRINT((ndo, "[|icmp]")); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-icmp6.c =================================================================== --- vendor/tcpdump/dist/print-icmp6.c (revision 353143) +++ vendor/tcpdump/dist/print-icmp6.c (revision 353144) @@ -1,1956 +1,1961 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994 * 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. */ /* \summary: IPv6 Internet Control Message Protocol (ICMPv6) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "addrtostr.h" #include "extract.h" #include "ip6.h" #include "ipproto.h" #include "udp.h" #include "ah.h" +static const char icmp6_tstr[] = " [|icmp6]"; +static const char rpl_tstr[] = " [|rpl]"; +static const char mldv2_tstr[] = " [|mldv2]"; + /* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */ /* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ struct icmp6_hdr { uint8_t icmp6_type; /* type field */ uint8_t icmp6_code; /* code field */ uint16_t icmp6_cksum; /* checksum field */ union { uint32_t icmp6_un_data32[1]; /* type-specific field */ uint16_t icmp6_un_data16[2]; /* type-specific field */ uint8_t icmp6_un_data8[4]; /* type-specific field */ } icmp6_dataun; }; #define icmp6_data32 icmp6_dataun.icmp6_un_data32 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 #define icmp6_pptr icmp6_data32[0] /* parameter prob */ #define icmp6_mtu icmp6_data32[0] /* packet too big */ #define icmp6_id icmp6_data16[0] /* echo request/reply */ #define icmp6_seq icmp6_data16[1] /* echo request/reply */ #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ #define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */ #define ICMP6_PACKET_TOO_BIG 2 /* packet too big */ #define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */ #define ICMP6_PARAM_PROB 4 /* ip6 header bad */ #define ICMP6_ECHO_REQUEST 128 /* echo service */ #define ICMP6_ECHO_REPLY 129 /* echo reply */ #define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */ #define MLD6_LISTENER_QUERY 130 /* multicast listener query */ #define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */ #define MLD6_LISTENER_REPORT 131 /* multicast listener report */ #define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */ #define MLD6_LISTENER_DONE 132 /* multicast listener done */ #define ND_ROUTER_SOLICIT 133 /* router solicitation */ #define ND_ROUTER_ADVERT 134 /* router advertisement */ #define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */ #define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */ #define ND_REDIRECT 137 /* redirect */ #define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */ #define ICMP6_WRUREQUEST 139 /* who are you request */ #define ICMP6_WRUREPLY 140 /* who are you reply */ #define ICMP6_FQDN_QUERY 139 /* FQDN query */ #define ICMP6_FQDN_REPLY 140 /* FQDN reply */ #define ICMP6_NI_QUERY 139 /* node information request */ #define ICMP6_NI_REPLY 140 /* node information reply */ #define IND_SOLICIT 141 /* inverse neighbor solicitation */ #define IND_ADVERT 142 /* inverse neighbor advertisement */ #define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */ #define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */ #define ICMP6_HADISCOV_REQUEST 144 #define ICMP6_HADISCOV_REPLY 145 #define ICMP6_MOBILEPREFIX_SOLICIT 146 #define ICMP6_MOBILEPREFIX_ADVERT 147 #define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */ #define MLD6_MTRACE 201 /* mtrace messages */ #define ICMP6_MAXTYPE 201 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ #define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */ #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */ #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ #define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */ #define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */ #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */ #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */ #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */ #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ #define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */ #define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */ #define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */ #define ICMP6_NI_SUCCESS 0 /* node information successful reply */ #define ICMP6_NI_REFUSED 1 /* node information request is refused */ #define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */ #define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */ #define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */ #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */ /* Used in kernel only */ #define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */ #define ND_REDIRECT_ROUTER 1 /* redirect to a better router */ /* * Multicast Listener Discovery */ struct mld6_hdr { struct icmp6_hdr mld6_hdr; struct in6_addr mld6_addr; /* multicast address */ }; #define mld6_type mld6_hdr.icmp6_type #define mld6_code mld6_hdr.icmp6_code #define mld6_cksum mld6_hdr.icmp6_cksum #define mld6_maxdelay mld6_hdr.icmp6_data16[0] #define mld6_reserved mld6_hdr.icmp6_data16[1] #define MLD_MINLEN 24 #define MLDV2_MINLEN 28 /* * Neighbor Discovery */ struct nd_router_solicit { /* router solicitation */ struct icmp6_hdr nd_rs_hdr; /* could be followed by options */ }; #define nd_rs_type nd_rs_hdr.icmp6_type #define nd_rs_code nd_rs_hdr.icmp6_code #define nd_rs_cksum nd_rs_hdr.icmp6_cksum #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] struct nd_router_advert { /* router advertisement */ struct icmp6_hdr nd_ra_hdr; uint32_t nd_ra_reachable; /* reachable time */ uint32_t nd_ra_retransmit; /* retransmit timer */ /* could be followed by options */ }; #define nd_ra_type nd_ra_hdr.icmp6_type #define nd_ra_code nd_ra_hdr.icmp6_code #define nd_ra_cksum nd_ra_hdr.icmp6_cksum #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] #define ND_RA_FLAG_MANAGED 0x80 #define ND_RA_FLAG_OTHER 0x40 #define ND_RA_FLAG_HOME_AGENT 0x20 /* * Router preference values based on draft-draves-ipngwg-router-selection-01. * These are non-standard definitions. */ #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */ #define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */ #define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] struct nd_neighbor_solicit { /* neighbor solicitation */ struct icmp6_hdr nd_ns_hdr; struct in6_addr nd_ns_target; /*target address */ /* could be followed by options */ }; #define nd_ns_type nd_ns_hdr.icmp6_type #define nd_ns_code nd_ns_hdr.icmp6_code #define nd_ns_cksum nd_ns_hdr.icmp6_cksum #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] struct nd_neighbor_advert { /* neighbor advertisement */ struct icmp6_hdr nd_na_hdr; struct in6_addr nd_na_target; /* target address */ /* could be followed by options */ }; #define nd_na_type nd_na_hdr.icmp6_type #define nd_na_code nd_na_hdr.icmp6_code #define nd_na_cksum nd_na_hdr.icmp6_cksum #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] #define ND_NA_FLAG_ROUTER 0x80000000 #define ND_NA_FLAG_SOLICITED 0x40000000 #define ND_NA_FLAG_OVERRIDE 0x20000000 struct nd_redirect { /* redirect */ struct icmp6_hdr nd_rd_hdr; struct in6_addr nd_rd_target; /* target address */ struct in6_addr nd_rd_dst; /* destination address */ /* could be followed by options */ }; #define nd_rd_type nd_rd_hdr.icmp6_type #define nd_rd_code nd_rd_hdr.icmp6_code #define nd_rd_cksum nd_rd_hdr.icmp6_cksum #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] struct nd_opt_hdr { /* Neighbor discovery option header */ uint8_t nd_opt_type; uint8_t nd_opt_len; /* followed by option specific data*/ }; #define ND_OPT_SOURCE_LINKADDR 1 #define ND_OPT_TARGET_LINKADDR 2 #define ND_OPT_PREFIX_INFORMATION 3 #define ND_OPT_REDIRECTED_HEADER 4 #define ND_OPT_MTU 5 #define ND_OPT_ADVINTERVAL 7 #define ND_OPT_HOMEAGENT_INFO 8 #define ND_OPT_ROUTE_INFO 24 /* RFC4191 */ #define ND_OPT_RDNSS 25 #define ND_OPT_DNSSL 31 struct nd_opt_prefix_info { /* prefix information */ nd_uint8_t nd_opt_pi_type; nd_uint8_t nd_opt_pi_len; nd_uint8_t nd_opt_pi_prefix_len; nd_uint8_t nd_opt_pi_flags_reserved; nd_uint32_t nd_opt_pi_valid_time; nd_uint32_t nd_opt_pi_preferred_time; nd_uint32_t nd_opt_pi_reserved2; struct in6_addr nd_opt_pi_prefix; }; #define ND_OPT_PI_FLAG_ONLINK 0x80 #define ND_OPT_PI_FLAG_AUTO 0x40 #define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/ struct nd_opt_rd_hdr { /* redirected header */ uint8_t nd_opt_rh_type; uint8_t nd_opt_rh_len; uint16_t nd_opt_rh_reserved1; uint32_t nd_opt_rh_reserved2; /* followed by IP header and data */ }; struct nd_opt_mtu { /* MTU option */ uint8_t nd_opt_mtu_type; uint8_t nd_opt_mtu_len; uint16_t nd_opt_mtu_reserved; uint32_t nd_opt_mtu_mtu; }; struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */ uint8_t nd_opt_rdnss_type; uint8_t nd_opt_rdnss_len; uint16_t nd_opt_rdnss_reserved; uint32_t nd_opt_rdnss_lifetime; struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */ }; struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */ uint8_t nd_opt_dnssl_type; uint8_t nd_opt_dnssl_len; uint16_t nd_opt_dnssl_reserved; uint32_t nd_opt_dnssl_lifetime; /* followed by list of DNS search domains, variable-length */ }; struct nd_opt_advinterval { /* Advertisement interval option */ uint8_t nd_opt_adv_type; uint8_t nd_opt_adv_len; uint16_t nd_opt_adv_reserved; uint32_t nd_opt_adv_interval; }; struct nd_opt_homeagent_info { /* Home Agent info */ uint8_t nd_opt_hai_type; uint8_t nd_opt_hai_len; uint16_t nd_opt_hai_reserved; int16_t nd_opt_hai_preference; uint16_t nd_opt_hai_lifetime; }; struct nd_opt_route_info { /* route info */ uint8_t nd_opt_rti_type; uint8_t nd_opt_rti_len; uint8_t nd_opt_rti_prefixlen; uint8_t nd_opt_rti_flags; uint32_t nd_opt_rti_lifetime; /* prefix follows */ }; /* * icmp6 namelookup */ struct icmp6_namelookup { struct icmp6_hdr icmp6_nl_hdr; uint8_t icmp6_nl_nonce[8]; int32_t icmp6_nl_ttl; #if 0 uint8_t icmp6_nl_len; uint8_t icmp6_nl_name[3]; #endif /* could be followed by options */ }; /* * icmp6 node information */ struct icmp6_nodeinfo { struct icmp6_hdr icmp6_ni_hdr; uint8_t icmp6_ni_nonce[8]; /* could be followed by reply data */ }; #define ni_type icmp6_ni_hdr.icmp6_type #define ni_code icmp6_ni_hdr.icmp6_code #define ni_cksum icmp6_ni_hdr.icmp6_cksum #define ni_qtype icmp6_ni_hdr.icmp6_data16[0] #define ni_flags icmp6_ni_hdr.icmp6_data16[1] #define NI_QTYPE_NOOP 0 /* NOOP */ #define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */ #define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */ #define NI_QTYPE_DNSNAME 2 /* DNS Name */ #define NI_QTYPE_NODEADDR 3 /* Node Addresses */ #define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */ /* network endian */ #define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1)) #define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1)) /* network endian */ #define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1)) #define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2)) #define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4)) #define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8)) #define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10)) #define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20)) #define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */ struct ni_reply_fqdn { uint32_t ni_fqdn_ttl; /* TTL */ uint8_t ni_fqdn_namelen; /* length in octets of the FQDN */ uint8_t ni_fqdn_name[3]; /* XXX: alignment */ }; /* * Router Renumbering. as router-renum-08.txt */ struct icmp6_router_renum { /* router renumbering header */ struct icmp6_hdr rr_hdr; uint8_t rr_segnum; uint8_t rr_flags; uint16_t rr_maxdelay; uint32_t rr_reserved; }; #define ICMP6_RR_FLAGS_TEST 0x80 #define ICMP6_RR_FLAGS_REQRESULT 0x40 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 #define ICMP6_RR_FLAGS_SPECSITE 0x10 #define ICMP6_RR_FLAGS_PREVDONE 0x08 #define rr_type rr_hdr.icmp6_type #define rr_code rr_hdr.icmp6_code #define rr_cksum rr_hdr.icmp6_cksum #define rr_seqnum rr_hdr.icmp6_data32[0] struct rr_pco_match { /* match prefix part */ uint8_t rpm_code; uint8_t rpm_len; uint8_t rpm_ordinal; uint8_t rpm_matchlen; uint8_t rpm_minlen; uint8_t rpm_maxlen; uint16_t rpm_reserved; struct in6_addr rpm_prefix; }; #define RPM_PCO_ADD 1 #define RPM_PCO_CHANGE 2 #define RPM_PCO_SETGLOBAL 3 #define RPM_PCO_MAX 4 struct rr_pco_use { /* use prefix part */ uint8_t rpu_uselen; uint8_t rpu_keeplen; uint8_t rpu_ramask; uint8_t rpu_raflags; uint32_t rpu_vltime; uint32_t rpu_pltime; uint32_t rpu_flags; struct in6_addr rpu_prefix; }; #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40 /* network endian */ #define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000)) #define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000)) struct rr_result { /* router renumbering result message */ uint16_t rrr_flags; uint8_t rrr_ordinal; uint8_t rrr_matchedlen; uint32_t rrr_ifid; struct in6_addr rrr_prefix; }; /* network endian */ #define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002)) #define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001)) static const char *get_rtpref(u_int); static const char *get_lifetime(uint32_t); static void print_lladdr(netdissect_options *ndo, const u_char *, size_t); static void icmp6_opt_print(netdissect_options *ndo, const u_char *, int); static void mld6_print(netdissect_options *ndo, const u_char *); static void mldv2_report_print(netdissect_options *ndo, const u_char *, u_int); static void mldv2_query_print(netdissect_options *ndo, const u_char *, u_int); static const struct udphdr *get_upperlayer(netdissect_options *ndo, const u_char *, u_int *); static void dnsname_print(netdissect_options *ndo, const u_char *, const u_char *); static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *); static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *); #ifndef abs #define abs(a) ((0 < (a)) ? (a) : -(a)) #endif #include "rpl.h" static const struct tok icmp6_type_values[] = { { ICMP6_DST_UNREACH, "destination unreachable"}, { ICMP6_PACKET_TOO_BIG, "packet too big"}, { ICMP6_TIME_EXCEEDED, "time exceeded in-transit"}, { 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"}, { ND_ROUTER_ADVERT, "router advertisement"}, { ND_NEIGHBOR_SOLICIT, "neighbor solicitation"}, { ND_NEIGHBOR_ADVERT, "neighbor advertisement"}, { ND_REDIRECT, "redirect"}, { ICMP6_ROUTER_RENUMBERING, "router renumbering"}, { IND_SOLICIT, "inverse neighbor solicitation"}, { IND_ADVERT, "inverse neighbor advertisement"}, { 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"}, { ICMP6_MOBILEPREFIX_ADVERT, "mobile router advertisement"}, { ICMP6_WRUREQUEST, "who-are-you request"}, { ICMP6_WRUREPLY, "who-are-you reply"}, { ICMP6_NI_QUERY, "node information query"}, { ICMP6_NI_REPLY, "node information reply"}, { MLD6_MTRACE, "mtrace message"}, { MLD6_MTRACE_RESP, "mtrace response"}, { ND_RPL_MESSAGE, "RPL"}, { 0, NULL } }; static const struct tok icmp6_dst_unreach_code_values[] = { { ICMP6_DST_UNREACH_NOROUTE, "unreachable route" }, { ICMP6_DST_UNREACH_ADMIN, " unreachable prohibited"}, { ICMP6_DST_UNREACH_BEYONDSCOPE, "beyond scope"}, { ICMP6_DST_UNREACH_ADDR, "unreachable address"}, { ICMP6_DST_UNREACH_NOPORT, "unreachable port"}, { 0, NULL } }; static const struct tok icmp6_opt_pi_flag_values[] = { { ND_OPT_PI_FLAG_ONLINK, "onlink" }, { ND_OPT_PI_FLAG_AUTO, "auto" }, { ND_OPT_PI_FLAG_ROUTER, "router" }, { 0, NULL } }; static const struct tok icmp6_opt_ra_flag_values[] = { { ND_RA_FLAG_MANAGED, "managed" }, { ND_RA_FLAG_OTHER, "other stateful"}, { ND_RA_FLAG_HOME_AGENT, "home agent"}, { 0, NULL } }; static const struct tok icmp6_nd_na_flag_values[] = { { ND_NA_FLAG_ROUTER, "router" }, { ND_NA_FLAG_SOLICITED, "solicited" }, { ND_NA_FLAG_OVERRIDE, "override" }, { 0, NULL } }; static const struct tok icmp6_opt_values[] = { { ND_OPT_SOURCE_LINKADDR, "source link-address"}, { ND_OPT_TARGET_LINKADDR, "destination link-address"}, { ND_OPT_PREFIX_INFORMATION, "prefix info"}, { ND_OPT_REDIRECTED_HEADER, "redirected header"}, { ND_OPT_MTU, "mtu"}, { ND_OPT_RDNSS, "rdnss"}, { ND_OPT_DNSSL, "dnssl"}, { ND_OPT_ADVINTERVAL, "advertisement interval"}, { ND_OPT_HOMEAGENT_INFO, "homeagent information"}, { ND_OPT_ROUTE_INFO, "route info"}, { 0, NULL } }; /* mldv2 report types */ static const struct tok mldv2report2str[] = { { 1, "is_in" }, { 2, "is_ex" }, { 3, "to_in" }, { 4, "to_ex" }, { 5, "allow" }, { 6, "block" }, { 0, NULL } }; static const char * get_rtpref(u_int v) { static const char *rtpref_str[] = { "medium", /* 00 */ "high", /* 01 */ "rsv", /* 10 */ "low" /* 11 */ }; return rtpref_str[((v & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff]; } static const char * get_lifetime(uint32_t v) { static char buf[20]; if (v == (uint32_t)~0UL) return "infinity"; else { snprintf(buf, sizeof(buf), "%us", v); return buf; } } static void print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l) { const uint8_t *ep, *q; q = p; ep = p + l; while (l > 0 && q < ep) { if (q > p) ND_PRINT((ndo,":")); ND_PRINT((ndo,"%02x", *q++)); l--; } } static int icmp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6, const struct icmp6_hdr *icp, u_int len) { return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)icp, len, len, IPPROTO_ICMPV6); } static const struct tok rpl_mop_values[] = { { RPL_DIO_NONSTORING, "nonstoring"}, { RPL_DIO_STORING, "storing"}, { RPL_DIO_NONSTORING_MULTICAST, "nonstoring-multicast"}, { RPL_DIO_STORING_MULTICAST, "storing-multicast"}, { 0, NULL}, }; static const struct tok rpl_subopt_values[] = { { RPL_OPT_PAD0, "pad0"}, { RPL_OPT_PADN, "padN"}, { RPL_DIO_METRICS, "metrics"}, { RPL_DIO_ROUTINGINFO, "routinginfo"}, { RPL_DIO_CONFIG, "config"}, { RPL_DAO_RPLTARGET, "rpltarget"}, { RPL_DAO_TRANSITINFO, "transitinfo"}, { RPL_DIO_DESTPREFIX, "destprefix"}, { RPL_DAO_RPLTARGET_DESC, "rpltargetdesc"}, { 0, NULL}, }; static void rpl_dio_printopt(netdissect_options *ndo, const struct rpl_dio_genoption *opt, u_int length) { if(length < RPL_DIO_GENOPTION_LEN) return; length -= RPL_DIO_GENOPTION_LEN; ND_TCHECK(opt->rpl_dio_len); while((opt->rpl_dio_type == RPL_OPT_PAD0 && (const u_char *)opt < ndo->ndo_snapend) || ND_TTEST2(*opt,(opt->rpl_dio_len+2))) { unsigned int optlen = opt->rpl_dio_len+2; if(opt->rpl_dio_type == RPL_OPT_PAD0) { optlen = 1; ND_PRINT((ndo, " opt:pad0")); } else { ND_PRINT((ndo, " opt:%s len:%u ", tok2str(rpl_subopt_values, "subopt:%u", opt->rpl_dio_type), optlen)); if(ndo->ndo_vflag > 2) { unsigned int paylen = opt->rpl_dio_len; if(paylen > length) paylen = length; hex_print(ndo, " ", ((const uint8_t *)opt) + RPL_DIO_GENOPTION_LEN, /* content of DIO option */ paylen); } } opt = (const struct rpl_dio_genoption *)(((const char *)opt) + optlen); length -= optlen; + ND_TCHECK(opt->rpl_dio_len); } return; trunc: - ND_PRINT((ndo," [|truncated]")); + ND_PRINT((ndo, "%s", rpl_tstr)); return; } static void rpl_dio_print(netdissect_options *ndo, const u_char *bp, u_int length) { const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp; const char *dagid_str; ND_TCHECK(*dio); dagid_str = ip6addr_string (ndo, dio->rpl_dagid); ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]", dagid_str, dio->rpl_dtsn, dio->rpl_instanceid, EXTRACT_16BITS(&dio->rpl_dagrank), RPL_DIO_GROUNDED(dio->rpl_mopprf) ? "grounded,":"", tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(dio->rpl_mopprf)), RPL_DIO_PRF(dio->rpl_mopprf))); if(ndo->ndo_vflag > 1) { const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)&dio[1]; rpl_dio_printopt(ndo, opt, length); } return; trunc: - ND_PRINT((ndo," [|truncated]")); + ND_PRINT((ndo, "%s", rpl_tstr)); return; } static void rpl_dao_print(netdissect_options *ndo, const u_char *bp, u_int length) { const struct nd_rpl_dao *dao = (const struct nd_rpl_dao *)bp; const char *dagid_str = ""; ND_TCHECK(*dao); if (length < ND_RPL_DAO_MIN_LEN) goto tooshort; bp += ND_RPL_DAO_MIN_LEN; length -= ND_RPL_DAO_MIN_LEN; if(RPL_DAO_D(dao->rpl_flags)) { ND_TCHECK2(dao->rpl_dagid, DAGID_LEN); if (length < DAGID_LEN) goto tooshort; dagid_str = ip6addr_string (ndo, dao->rpl_dagid); bp += DAGID_LEN; length -= DAGID_LEN; } ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]", dagid_str, dao->rpl_daoseq, dao->rpl_instanceid, RPL_DAO_K(dao->rpl_flags) ? ",acK":"", RPL_DAO_D(dao->rpl_flags) ? ",Dagid":"", dao->rpl_flags)); if(ndo->ndo_vflag > 1) { const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp; rpl_dio_printopt(ndo, opt, length); } return; trunc: - ND_PRINT((ndo," [|truncated]")); + ND_PRINT((ndo, "%s", rpl_tstr)); return; tooshort: ND_PRINT((ndo," [|length too short]")); return; } static void rpl_daoack_print(netdissect_options *ndo, const u_char *bp, u_int length) { const struct nd_rpl_daoack *daoack = (const struct nd_rpl_daoack *)bp; const char *dagid_str = ""; ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN); if (length < ND_RPL_DAOACK_MIN_LEN) goto tooshort; bp += ND_RPL_DAOACK_MIN_LEN; length -= ND_RPL_DAOACK_MIN_LEN; if(RPL_DAOACK_D(daoack->rpl_flags)) { ND_TCHECK2(daoack->rpl_dagid, DAGID_LEN); if (length < DAGID_LEN) goto tooshort; dagid_str = ip6addr_string (ndo, daoack->rpl_dagid); bp += DAGID_LEN; length -= DAGID_LEN; } ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,status:%u]", dagid_str, daoack->rpl_daoseq, daoack->rpl_instanceid, daoack->rpl_status)); /* no officially defined options for DAOACK, but print any we find */ if(ndo->ndo_vflag > 1) { const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp; rpl_dio_printopt(ndo, opt, length); } return; trunc: - ND_PRINT((ndo," [|dao-truncated]")); + ND_PRINT((ndo, "%s", rpl_tstr)); return; tooshort: ND_PRINT((ndo," [|dao-length too short]")); return; } static void rpl_print(netdissect_options *ndo, const struct icmp6_hdr *hdr, const u_char *bp, u_int length) { int secured = hdr->icmp6_code & 0x80; int basecode= hdr->icmp6_code & 0x7f; if(secured) { ND_PRINT((ndo, ", (SEC) [worktodo]")); /* XXX * the next header pointer needs to move forward to * skip the secure part. */ return; } else { ND_PRINT((ndo, ", (CLR)")); } switch(basecode) { case ND_RPL_DAG_IS: ND_PRINT((ndo, "DODAG Information Solicitation")); if(ndo->ndo_vflag) { } break; case ND_RPL_DAG_IO: ND_PRINT((ndo, "DODAG Information Object")); if(ndo->ndo_vflag) { rpl_dio_print(ndo, bp, length); } break; case ND_RPL_DAO: ND_PRINT((ndo, "Destination Advertisement Object")); if(ndo->ndo_vflag) { rpl_dao_print(ndo, bp, length); } break; case ND_RPL_DAO_ACK: ND_PRINT((ndo, "Destination Advertisement Object Ack")); if(ndo->ndo_vflag) { rpl_daoack_print(ndo, bp, length); } break; default: ND_PRINT((ndo, "RPL message, unknown code %u",hdr->icmp6_code)); break; } return; #if 0 trunc: - ND_PRINT((ndo," [|truncated]")); + ND_PRINT((ndo, "%s", rpl_tstr)); return; #endif } void icmp6_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2, int fragmented) { const struct icmp6_hdr *dp; const struct ip6_hdr *ip; const struct ip6_hdr *oip; const struct udphdr *ouh; int dport; const u_char *ep; u_int prot; dp = (const struct icmp6_hdr *)bp; ip = (const struct ip6_hdr *)bp2; oip = (const struct ip6_hdr *)(dp + 1); /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; ND_TCHECK(dp->icmp6_cksum); if (ndo->ndo_vflag && !fragmented) { uint16_t sum, udp_sum; if (ND_TTEST2(bp[0], length)) { udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum); sum = icmp6_cksum(ndo, ip, dp, length); if (sum != 0) ND_PRINT((ndo,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ", udp_sum, in_cksum_shouldbe(udp_sum, sum))); else ND_PRINT((ndo,"[icmp6 sum ok] ")); } } ND_PRINT((ndo,"ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type))); /* display cosmetics: print the packet length for printer that use the vflag now */ if (ndo->ndo_vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT || dp->icmp6_type == ND_ROUTER_ADVERT || dp->icmp6_type == ND_NEIGHBOR_ADVERT || dp->icmp6_type == ND_NEIGHBOR_SOLICIT || dp->icmp6_type == ND_REDIRECT || dp->icmp6_type == ICMP6_HADISCOV_REPLY || dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT )) ND_PRINT((ndo,", length %u", length)); switch (dp->icmp6_type) { case ICMP6_DST_UNREACH: ND_TCHECK(oip->ip6_dst); ND_PRINT((ndo,", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code))); switch (dp->icmp6_code) { case ICMP6_DST_UNREACH_NOROUTE: /* fall through */ case ICMP6_DST_UNREACH_ADMIN: case ICMP6_DST_UNREACH_ADDR: ND_PRINT((ndo," %s",ip6addr_string(ndo, &oip->ip6_dst))); break; case ICMP6_DST_UNREACH_BEYONDSCOPE: ND_PRINT((ndo," %s, source address %s", ip6addr_string(ndo, &oip->ip6_dst), ip6addr_string(ndo, &oip->ip6_src))); break; case ICMP6_DST_UNREACH_NOPORT: if ((ouh = get_upperlayer(ndo, (const u_char *)oip, &prot)) == NULL) goto trunc; dport = EXTRACT_16BITS(&ouh->uh_dport); switch (prot) { case IPPROTO_TCP: ND_PRINT((ndo,", %s tcp port %s", ip6addr_string(ndo, &oip->ip6_dst), tcpport_string(ndo, dport))); break; case IPPROTO_UDP: ND_PRINT((ndo,", %s udp port %s", ip6addr_string(ndo, &oip->ip6_dst), udpport_string(ndo, dport))); break; default: ND_PRINT((ndo,", %s protocol %d port %d unreachable", ip6addr_string(ndo, &oip->ip6_dst), oip->ip6_nxt, dport)); break; } break; default: if (ndo->ndo_vflag <= 1) { print_unknown_data(ndo, bp,"\n\t",length); return; } break; } break; case ICMP6_PACKET_TOO_BIG: ND_TCHECK(dp->icmp6_mtu); ND_PRINT((ndo,", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu))); break; case ICMP6_TIME_EXCEEDED: ND_TCHECK(oip->ip6_dst); switch (dp->icmp6_code) { case ICMP6_TIME_EXCEED_TRANSIT: ND_PRINT((ndo," for %s", ip6addr_string(ndo, &oip->ip6_dst))); break; case ICMP6_TIME_EXCEED_REASSEMBLY: ND_PRINT((ndo," (reassembly)")); break; default: ND_PRINT((ndo,", unknown code (%u)", dp->icmp6_code)); break; } break; case ICMP6_PARAM_PROB: ND_TCHECK(oip->ip6_dst); switch (dp->icmp6_code) { case ICMP6_PARAMPROB_HEADER: ND_PRINT((ndo,", erroneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr))); break; case ICMP6_PARAMPROB_NEXTHEADER: ND_PRINT((ndo,", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr))); break; case ICMP6_PARAMPROB_OPTION: ND_PRINT((ndo,", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr))); break; default: ND_PRINT((ndo,", code-#%d", dp->icmp6_code)); break; } break; case ICMP6_ECHO_REQUEST: case ICMP6_ECHO_REPLY: ND_TCHECK(dp->icmp6_seq); ND_PRINT((ndo,", seq %u", EXTRACT_16BITS(&dp->icmp6_seq))); break; case ICMP6_MEMBERSHIP_QUERY: if (length == MLD_MINLEN) { mld6_print(ndo, (const u_char *)dp); } else if (length >= MLDV2_MINLEN) { ND_PRINT((ndo," v2")); mldv2_query_print(ndo, (const u_char *)dp, length); } else { ND_PRINT((ndo," unknown-version (len %u) ", length)); } break; case ICMP6_MEMBERSHIP_REPORT: mld6_print(ndo, (const u_char *)dp); break; case ICMP6_MEMBERSHIP_REDUCTION: mld6_print(ndo, (const u_char *)dp); break; case ND_ROUTER_SOLICIT: #define RTSOLLEN 8 if (ndo->ndo_vflag) { icmp6_opt_print(ndo, (const u_char *)dp + RTSOLLEN, length - RTSOLLEN); } break; case ND_ROUTER_ADVERT: #define RTADVLEN 16 if (ndo->ndo_vflag) { const struct nd_router_advert *p; p = (const struct nd_router_advert *)dp; ND_TCHECK(p->nd_ra_retransmit); ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \ - ", pref %s, router lifetime %us, reachable time %us, retrans time %us", + ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums", (u_int)p->nd_ra_curhoplimit, bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)), get_rtpref(p->nd_ra_flags_reserved), EXTRACT_16BITS(&p->nd_ra_router_lifetime), EXTRACT_32BITS(&p->nd_ra_reachable), EXTRACT_32BITS(&p->nd_ra_retransmit))); icmp6_opt_print(ndo, (const u_char *)dp + RTADVLEN, length - RTADVLEN); } break; case ND_NEIGHBOR_SOLICIT: { const struct nd_neighbor_solicit *p; p = (const struct nd_neighbor_solicit *)dp; ND_TCHECK(p->nd_ns_target); ND_PRINT((ndo,", who has %s", ip6addr_string(ndo, &p->nd_ns_target))); if (ndo->ndo_vflag) { #define NDSOLLEN 24 icmp6_opt_print(ndo, (const u_char *)dp + NDSOLLEN, length - NDSOLLEN); } } break; case ND_NEIGHBOR_ADVERT: { const struct nd_neighbor_advert *p; p = (const struct nd_neighbor_advert *)dp; ND_TCHECK(p->nd_na_target); ND_PRINT((ndo,", tgt is %s", ip6addr_string(ndo, &p->nd_na_target))); if (ndo->ndo_vflag) { ND_PRINT((ndo,", Flags [%s]", bittok2str(icmp6_nd_na_flag_values, "none", EXTRACT_32BITS(&p->nd_na_flags_reserved)))); #define NDADVLEN 24 icmp6_opt_print(ndo, (const u_char *)dp + NDADVLEN, length - NDADVLEN); #undef NDADVLEN } } break; case ND_REDIRECT: #define RDR(i) ((const struct nd_redirect *)(i)) ND_TCHECK(RDR(dp)->nd_rd_dst); ND_PRINT((ndo,", %s", ip6addr_string(ndo, &RDR(dp)->nd_rd_dst))); ND_TCHECK(RDR(dp)->nd_rd_target); ND_PRINT((ndo," to %s", ip6addr_string(ndo, &RDR(dp)->nd_rd_target))); #define REDIRECTLEN 40 if (ndo->ndo_vflag) { icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN, length - REDIRECTLEN); } break; #undef REDIRECTLEN #undef RDR case ICMP6_ROUTER_RENUMBERING: icmp6_rrenum_print(ndo, bp, ep); break; case ICMP6_NI_QUERY: case ICMP6_NI_REPLY: icmp6_nodeinfo_print(ndo, length, bp, ep); break; case IND_SOLICIT: case IND_ADVERT: break; case ICMP6_V2_MEMBERSHIP_REPORT: mldv2_report_print(ndo, (const u_char *) dp, length); break; case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */ case ICMP6_HADISCOV_REQUEST: ND_TCHECK(dp->icmp6_data16[0]); ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]))); break; case ICMP6_HADISCOV_REPLY: if (ndo->ndo_vflag) { const struct in6_addr *in6; const u_char *cp; ND_TCHECK(dp->icmp6_data16[0]); ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]))); cp = (const u_char *)dp + length; in6 = (const struct in6_addr *)(dp + 1); for (; (const u_char *)in6 < cp; in6++) { ND_TCHECK(*in6); ND_PRINT((ndo,", %s", ip6addr_string(ndo, in6))); } } break; case ICMP6_MOBILEPREFIX_ADVERT: if (ndo->ndo_vflag) { ND_TCHECK(dp->icmp6_data16[0]); ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]))); ND_TCHECK(dp->icmp6_data16[1]); if (dp->icmp6_data16[1] & 0xc0) ND_PRINT((ndo," ")); if (dp->icmp6_data16[1] & 0x80) ND_PRINT((ndo,"M")); if (dp->icmp6_data16[1] & 0x40) ND_PRINT((ndo,"O")); #define MPADVLEN 8 icmp6_opt_print(ndo, (const u_char *)dp + MPADVLEN, length - MPADVLEN); } break; case ND_RPL_MESSAGE: /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */ rpl_print(ndo, dp, &dp->icmp6_data8[0], length-sizeof(struct icmp6_hdr)+4); break; default: ND_PRINT((ndo,", length %u", length)); if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, bp,"\n\t", length); return; } if (!ndo->ndo_vflag) ND_PRINT((ndo,", length %u", length)); return; trunc: - ND_PRINT((ndo, "[|icmp6]")); + ND_PRINT((ndo, "%s", icmp6_tstr)); } static const struct udphdr * get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot) { const u_char *ep; const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp; const struct udphdr *uh; const struct ip6_hbh *hbh; const struct ip6_frag *fragh; const struct ah *ah; u_int nh; int hlen; /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; if (!ND_TTEST(ip6->ip6_nxt)) return NULL; nh = ip6->ip6_nxt; hlen = sizeof(struct ip6_hdr); while (bp < ep) { bp += hlen; switch(nh) { case IPPROTO_UDP: case IPPROTO_TCP: uh = (const struct udphdr *)bp; if (ND_TTEST(uh->uh_dport)) { *prot = nh; return(uh); } else return(NULL); /* NOTREACHED */ case IPPROTO_HOPOPTS: case IPPROTO_DSTOPTS: case IPPROTO_ROUTING: hbh = (const struct ip6_hbh *)bp; if (!ND_TTEST(hbh->ip6h_len)) return(NULL); nh = hbh->ip6h_nxt; hlen = (hbh->ip6h_len + 1) << 3; break; case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */ fragh = (const struct ip6_frag *)bp; if (!ND_TTEST(fragh->ip6f_offlg)) return(NULL); /* fragments with non-zero offset are meaningless */ if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0) return(NULL); nh = fragh->ip6f_nxt; hlen = sizeof(struct ip6_frag); break; case IPPROTO_AH: ah = (const struct ah *)bp; if (!ND_TTEST(ah->ah_len)) return(NULL); nh = ah->ah_nxt; hlen = (ah->ah_len + 2) << 2; break; default: /* unknown or undecodable header */ *prot = nh; /* meaningless, but set here anyway */ return(NULL); } } return(NULL); /* should be notreached, though */ } static void icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid) { const struct nd_opt_hdr *op; const struct nd_opt_prefix_info *opp; const struct nd_opt_mtu *opm; const struct nd_opt_rdnss *oprd; const struct nd_opt_dnssl *opds; const struct nd_opt_advinterval *opa; const struct nd_opt_homeagent_info *oph; const struct nd_opt_route_info *opri; const u_char *cp, *ep, *domp; struct in6_addr in6; const struct in6_addr *in6p; size_t l; u_int i; #define ECHECK(var) if ((const u_char *)&(var) > ep - sizeof(var)) return cp = bp; /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; while (cp < ep) { op = (const struct nd_opt_hdr *)cp; ECHECK(op->nd_opt_len); if (resid <= 0) return; if (op->nd_opt_len == 0) goto trunc; if (cp + (op->nd_opt_len << 3) > ep) goto trunc; ND_PRINT((ndo,"\n\t %s option (%u), length %u (%u): ", tok2str(icmp6_opt_values, "unknown", op->nd_opt_type), op->nd_opt_type, op->nd_opt_len << 3, op->nd_opt_len)); switch (op->nd_opt_type) { case ND_OPT_SOURCE_LINKADDR: l = (op->nd_opt_len << 3) - 2; print_lladdr(ndo, cp + 2, l); break; case ND_OPT_TARGET_LINKADDR: l = (op->nd_opt_len << 3) - 2; print_lladdr(ndo, cp + 2, l); break; case ND_OPT_PREFIX_INFORMATION: opp = (const struct nd_opt_prefix_info *)op; ND_TCHECK(opp->nd_opt_pi_prefix); ND_PRINT((ndo,"%s/%u%s, Flags [%s], valid time %s", ip6addr_string(ndo, &opp->nd_opt_pi_prefix), opp->nd_opt_pi_prefix_len, (op->nd_opt_len != 4) ? "badlen" : "", bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved), get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)))); ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)))); break; case ND_OPT_REDIRECTED_HEADER: print_unknown_data(ndo, bp,"\n\t ",op->nd_opt_len<<3); /* xxx */ break; case ND_OPT_MTU: opm = (const struct nd_opt_mtu *)op; ND_TCHECK(opm->nd_opt_mtu_mtu); ND_PRINT((ndo," %u%s", EXTRACT_32BITS(&opm->nd_opt_mtu_mtu), (op->nd_opt_len != 1) ? "bad option length" : "" )); break; case ND_OPT_RDNSS: oprd = (const struct nd_opt_rdnss *)op; l = (op->nd_opt_len - 1) / 2; ND_PRINT((ndo," lifetime %us,", EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime))); for (i = 0; i < l; i++) { ND_TCHECK(oprd->nd_opt_rdnss_addr[i]); ND_PRINT((ndo," addr: %s", ip6addr_string(ndo, &oprd->nd_opt_rdnss_addr[i]))); } break; case ND_OPT_DNSSL: opds = (const struct nd_opt_dnssl *)op; ND_PRINT((ndo," lifetime %us, domain(s):", EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime))); domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */ while (domp < cp + (op->nd_opt_len << 3) && *domp != '\0') { ND_PRINT((ndo, " ")); if ((domp = ns_nprint (ndo, domp, bp)) == NULL) goto trunc; } break; case ND_OPT_ADVINTERVAL: opa = (const struct nd_opt_advinterval *)op; ND_TCHECK(opa->nd_opt_adv_interval); ND_PRINT((ndo," %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval))); break; case ND_OPT_HOMEAGENT_INFO: oph = (const struct nd_opt_homeagent_info *)op; ND_TCHECK(oph->nd_opt_hai_lifetime); ND_PRINT((ndo," preference %u, lifetime %u", EXTRACT_16BITS(&oph->nd_opt_hai_preference), EXTRACT_16BITS(&oph->nd_opt_hai_lifetime))); break; case ND_OPT_ROUTE_INFO: opri = (const struct nd_opt_route_info *)op; ND_TCHECK(opri->nd_opt_rti_lifetime); memset(&in6, 0, sizeof(in6)); in6p = (const struct in6_addr *)(opri + 1); switch (op->nd_opt_len) { case 1: break; case 2: ND_TCHECK2(*in6p, 8); memcpy(&in6, opri + 1, 8); break; case 3: ND_TCHECK(*in6p); memcpy(&in6, opri + 1, sizeof(in6)); break; default: goto trunc; } ND_PRINT((ndo," %s/%u", ip6addr_string(ndo, &in6), opri->nd_opt_rti_prefixlen)); ND_PRINT((ndo,", pref=%s", get_rtpref(opri->nd_opt_rti_flags))); ND_PRINT((ndo,", lifetime=%s", get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime)))); break; default: if (ndo->ndo_vflag <= 1) { print_unknown_data(ndo,cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */ return; } break; } /* do we want to see an additional hexdump ? */ if (ndo->ndo_vflag> 1) print_unknown_data(ndo, cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */ cp += op->nd_opt_len << 3; resid -= op->nd_opt_len << 3; } return; - trunc: - ND_PRINT((ndo, "[ndp opt]")); +trunc: + ND_PRINT((ndo, "%s", icmp6_tstr)); return; #undef ECHECK } static void mld6_print(netdissect_options *ndo, const u_char *bp) { const struct mld6_hdr *mp = (const struct mld6_hdr *)bp; const u_char *ep; /* 'ep' points to the end of available data. */ ep = ndo->ndo_snapend; if ((const u_char *)mp + sizeof(*mp) > ep) return; ND_PRINT((ndo,"max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay))); ND_PRINT((ndo,"addr: %s", ip6addr_string(ndo, &mp->mld6_addr))); } static void mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len) { const struct icmp6_hdr *icp = (const struct icmp6_hdr *) bp; u_int group, nsrcs, ngroups; u_int i, j; /* Minimum len is 8 */ if (len < 8) { ND_PRINT((ndo," [invalid len %d]", len)); return; } ND_TCHECK(icp->icmp6_data16[1]); ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]); ND_PRINT((ndo,", %d group record(s)", ngroups)); if (ndo->ndo_vflag > 0) { /* Print the group records */ group = 8; for (i = 0; i < ngroups; i++) { /* type(1) + auxlen(1) + numsrc(2) + grp(16) */ if (len < group + 20) { ND_PRINT((ndo," [invalid number of groups]")); return; } ND_TCHECK2(bp[group + 4], sizeof(struct in6_addr)); ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[group + 4]))); ND_PRINT((ndo," %s", tok2str(mldv2report2str, " [v2-report-#%d]", bp[group]))); nsrcs = (bp[group + 2] << 8) + bp[group + 3]; /* Check the number of sources and print them */ if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) { ND_PRINT((ndo," [invalid number of sources %d]", nsrcs)); return; } if (ndo->ndo_vflag == 1) ND_PRINT((ndo,", %d source(s)", nsrcs)); else { /* Print the sources */ ND_PRINT((ndo," {")); for (j = 0; j < nsrcs; j++) { ND_TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)], sizeof(struct in6_addr)); ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[group + 20 + j * sizeof(struct in6_addr)]))); } ND_PRINT((ndo," }")); } /* Next group record */ group += 20 + nsrcs * sizeof(struct in6_addr); ND_PRINT((ndo,"]")); } } return; trunc: - ND_PRINT((ndo,"[|icmp6]")); + ND_PRINT((ndo, "%s", mldv2_tstr)); return; } static void mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len) { const struct icmp6_hdr *icp = (const struct icmp6_hdr *) bp; u_int mrc; int mrt, qqi; u_int nsrcs; register u_int i; /* Minimum len is 28 */ if (len < 28) { ND_PRINT((ndo," [invalid len %d]", len)); return; } ND_TCHECK(icp->icmp6_data16[0]); mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]); if (mrc < 32768) { mrt = mrc; } else { mrt = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3); } if (ndo->ndo_vflag) { ND_PRINT((ndo," [max resp delay=%d]", mrt)); } ND_TCHECK2(bp[8], sizeof(struct in6_addr)); ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[8]))); if (ndo->ndo_vflag) { ND_TCHECK(bp[25]); if (bp[24] & 0x08) { ND_PRINT((ndo," sflag")); } if (bp[24] & 0x07) { ND_PRINT((ndo," robustness=%d", bp[24] & 0x07)); } if (bp[25] < 128) { qqi = bp[25]; } else { qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3); } ND_PRINT((ndo," qqi=%d", qqi)); } ND_TCHECK2(bp[26], 2); nsrcs = EXTRACT_16BITS(&bp[26]); if (nsrcs > 0) { if (len < 28 + nsrcs * sizeof(struct in6_addr)) ND_PRINT((ndo," [invalid number of sources]")); else if (ndo->ndo_vflag > 1) { ND_PRINT((ndo," {")); for (i = 0; i < nsrcs; i++) { ND_TCHECK2(bp[28 + i * sizeof(struct in6_addr)], sizeof(struct in6_addr)); ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[28 + i * sizeof(struct in6_addr)]))); } ND_PRINT((ndo," }")); } else ND_PRINT((ndo,", %d source(s)", nsrcs)); } ND_PRINT((ndo,"]")); return; trunc: - ND_PRINT((ndo,"[|icmp6]")); + ND_PRINT((ndo, "%s", mldv2_tstr)); return; } static void dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) { int i; /* DNS name decoding - no decompression */ ND_PRINT((ndo,", \"")); while (cp < ep) { i = *cp++; if (i) { if (i > ep - cp) { ND_PRINT((ndo,"???")); break; } while (i-- && cp < ep) { safeputchar(ndo, *cp); cp++; } if (cp + 1 < ep && *cp) ND_PRINT((ndo,".")); } else { if (cp == ep) { /* FQDN */ ND_PRINT((ndo,".")); } else if (cp + 1 == ep && *cp == '\0') { /* truncated */ } else { /* invalid */ ND_PRINT((ndo,"???")); } break; } } ND_PRINT((ndo,"\"")); } static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, const u_char *ep) { const struct icmp6_nodeinfo *ni6; const struct icmp6_hdr *dp; const u_char *cp; size_t siz, i; int needcomma; if (ep < bp) return; dp = (const struct icmp6_hdr *)bp; ni6 = (const struct icmp6_nodeinfo *)bp; siz = ep - bp; switch (ni6->ni_type) { case ICMP6_NI_QUERY: if (siz == sizeof(*dp) + 4) { /* KAME who-are-you */ ND_PRINT((ndo," who-are-you request")); break; } ND_PRINT((ndo," node information query")); ND_TCHECK2(*dp, sizeof(*ni6)); ni6 = (const struct icmp6_nodeinfo *)dp; ND_PRINT((ndo," (")); /*)*/ switch (EXTRACT_16BITS(&ni6->ni_qtype)) { case NI_QTYPE_NOOP: ND_PRINT((ndo,"noop")); break; case NI_QTYPE_SUPTYPES: ND_PRINT((ndo,"supported qtypes")); i = EXTRACT_16BITS(&ni6->ni_flags); if (i) ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : "")); break; case NI_QTYPE_FQDN: ND_PRINT((ndo,"DNS name")); break; case NI_QTYPE_NODEADDR: ND_PRINT((ndo,"node addresses")); i = ni6->ni_flags; if (!i) break; /* NI_NODEADDR_FLAG_TRUNCATE undefined for query */ ND_PRINT((ndo," [%s%s%s%s%s%s]", (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", (i & NI_NODEADDR_FLAG_ALL) ? "A" : "")); break; default: ND_PRINT((ndo,"unknown")); break; } if (ni6->ni_qtype == NI_QTYPE_NOOP || ni6->ni_qtype == NI_QTYPE_SUPTYPES) { if (siz != sizeof(*ni6)) if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid len")); /*(*/ ND_PRINT((ndo,")")); break; } /* XXX backward compat, icmp-name-lookup-03 */ if (siz == sizeof(*ni6)) { ND_PRINT((ndo,", 03 draft")); /*(*/ ND_PRINT((ndo,")")); break; } switch (ni6->ni_code) { case ICMP6_NI_SUBJ_IPV6: if (!ND_TTEST2(*dp, sizeof(*ni6) + sizeof(struct in6_addr))) break; if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) { if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid subject len")); break; } ND_PRINT((ndo,", subject=%s", ip6addr_string(ndo, ni6 + 1))); break; case ICMP6_NI_SUBJ_FQDN: ND_PRINT((ndo,", subject=DNS name")); cp = (const u_char *)(ni6 + 1); if (cp[0] == ep - cp - 1) { /* icmp-name-lookup-03, pascal string */ if (ndo->ndo_vflag) ND_PRINT((ndo,", 03 draft")); cp++; ND_PRINT((ndo,", \"")); while (cp < ep) { safeputchar(ndo, *cp); cp++; } ND_PRINT((ndo,"\"")); } else dnsname_print(ndo, cp, ep); break; case ICMP6_NI_SUBJ_IPV4: if (!ND_TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr))) break; if (siz != sizeof(*ni6) + sizeof(struct in_addr)) { if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid subject len")); break; } ND_PRINT((ndo,", subject=%s", ipaddr_string(ndo, ni6 + 1))); break; default: ND_PRINT((ndo,", unknown subject")); break; } /*(*/ ND_PRINT((ndo,")")); break; case ICMP6_NI_REPLY: if (icmp6len > siz) { ND_PRINT((ndo,"[|icmp6: node information reply]")); break; } needcomma = 0; ND_TCHECK2(*dp, sizeof(*ni6)); ni6 = (const struct icmp6_nodeinfo *)dp; ND_PRINT((ndo," node information reply")); ND_PRINT((ndo," (")); /*)*/ switch (ni6->ni_code) { case ICMP6_NI_SUCCESS: if (ndo->ndo_vflag) { ND_PRINT((ndo,"success")); needcomma++; } break; case ICMP6_NI_REFUSED: ND_PRINT((ndo,"refused")); needcomma++; if (siz != sizeof(*ni6)) if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid length")); break; case ICMP6_NI_UNKNOWN: ND_PRINT((ndo,"unknown")); needcomma++; if (siz != sizeof(*ni6)) if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid length")); break; } if (ni6->ni_code != ICMP6_NI_SUCCESS) { /*(*/ ND_PRINT((ndo,")")); break; } switch (EXTRACT_16BITS(&ni6->ni_qtype)) { case NI_QTYPE_NOOP: if (needcomma) ND_PRINT((ndo,", ")); ND_PRINT((ndo,"noop")); if (siz != sizeof(*ni6)) if (ndo->ndo_vflag) ND_PRINT((ndo,", invalid length")); break; case NI_QTYPE_SUPTYPES: if (needcomma) ND_PRINT((ndo,", ")); ND_PRINT((ndo,"supported qtypes")); i = EXTRACT_16BITS(&ni6->ni_flags); if (i) ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : "")); break; case NI_QTYPE_FQDN: if (needcomma) ND_PRINT((ndo,", ")); ND_PRINT((ndo,"DNS name")); cp = (const u_char *)(ni6 + 1) + 4; ND_TCHECK(cp[0]); if (cp[0] == ep - cp - 1) { /* icmp-name-lookup-03, pascal string */ if (ndo->ndo_vflag) ND_PRINT((ndo,", 03 draft")); cp++; ND_PRINT((ndo,", \"")); while (cp < ep) { safeputchar(ndo, *cp); cp++; } ND_PRINT((ndo,"\"")); } else dnsname_print(ndo, cp, ep); if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0) ND_PRINT((ndo," [TTL=%u]", EXTRACT_32BITS(ni6 + 1))); break; case NI_QTYPE_NODEADDR: if (needcomma) ND_PRINT((ndo,", ")); ND_PRINT((ndo,"node addresses")); i = sizeof(*ni6); while (i < siz) { if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz) break; ND_PRINT((ndo," %s", ip6addr_string(ndo, bp + i))); i += sizeof(struct in6_addr); ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i))); i += sizeof(int32_t); } i = ni6->ni_flags; if (!i) break; ND_PRINT((ndo," [%s%s%s%s%s%s%s]", (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "", (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "", (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "", (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "", (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "", (i & NI_NODEADDR_FLAG_ALL) ? "A" : "", (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "")); break; default: if (needcomma) ND_PRINT((ndo,", ")); ND_PRINT((ndo,"unknown")); break; } /*(*/ ND_PRINT((ndo,")")); break; } return; trunc: - ND_PRINT((ndo, "[|icmp6]")); + ND_PRINT((ndo, "%s", icmp6_tstr)); } static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep) { const struct icmp6_router_renum *rr6; const char *cp; const struct rr_pco_match *match; const struct rr_pco_use *use; char hbuf[NI_MAXHOST]; int n; if (ep < bp) return; rr6 = (const struct icmp6_router_renum *)bp; cp = (const char *)(rr6 + 1); ND_TCHECK(rr6->rr_reserved); switch (rr6->rr_code) { case ICMP6_ROUTER_RENUMBERING_COMMAND: ND_PRINT((ndo,"router renum: command")); break; case ICMP6_ROUTER_RENUMBERING_RESULT: ND_PRINT((ndo,"router renum: result")); break; case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET: ND_PRINT((ndo,"router renum: sequence number reset")); break; default: ND_PRINT((ndo,"router renum: code-#%d", rr6->rr_code)); break; } ND_PRINT((ndo,", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum))); if (ndo->ndo_vflag) { #define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "") ND_PRINT((ndo,"[")); /*]*/ if (rr6->rr_flags) { ND_PRINT((ndo,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"), F(ICMP6_RR_FLAGS_REQRESULT, "R"), F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"), F(ICMP6_RR_FLAGS_SPECSITE, "S"), F(ICMP6_RR_FLAGS_PREVDONE, "P"))); } ND_PRINT((ndo,"seg=%u,", rr6->rr_segnum)); ND_PRINT((ndo,"maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay))); if (rr6->rr_reserved) ND_PRINT((ndo,"rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved))); /*[*/ ND_PRINT((ndo,"]")); #undef F } if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) { match = (const struct rr_pco_match *)cp; cp = (const char *)(match + 1); ND_TCHECK(match->rpm_prefix); if (ndo->ndo_vflag > 1) ND_PRINT((ndo,"\n\t")); else ND_PRINT((ndo," ")); ND_PRINT((ndo,"match(")); /*)*/ switch (match->rpm_code) { case RPM_PCO_ADD: ND_PRINT((ndo,"add")); break; case RPM_PCO_CHANGE: ND_PRINT((ndo,"change")); break; case RPM_PCO_SETGLOBAL: ND_PRINT((ndo,"setglobal")); break; default: ND_PRINT((ndo,"#%u", match->rpm_code)); break; } if (ndo->ndo_vflag) { ND_PRINT((ndo,",ord=%u", match->rpm_ordinal)); ND_PRINT((ndo,",min=%u", match->rpm_minlen)); ND_PRINT((ndo,",max=%u", match->rpm_maxlen)); } if (addrtostr6(&match->rpm_prefix, hbuf, sizeof(hbuf))) ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen)); else ND_PRINT((ndo,",?/%u", match->rpm_matchlen)); /*(*/ ND_PRINT((ndo,")")); n = match->rpm_len - 3; if (n % 4) goto trunc; n /= 4; while (n-- > 0) { use = (const struct rr_pco_use *)cp; cp = (const char *)(use + 1); ND_TCHECK(use->rpu_prefix); if (ndo->ndo_vflag > 1) ND_PRINT((ndo,"\n\t")); else ND_PRINT((ndo," ")); ND_PRINT((ndo,"use(")); /*)*/ if (use->rpu_flags) { #define F(x, y) ((use->rpu_flags) & (x) ? (y) : "") ND_PRINT((ndo,"%s%s,", F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"), F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"))); #undef F } if (ndo->ndo_vflag) { ND_PRINT((ndo,"mask=0x%x,", use->rpu_ramask)); ND_PRINT((ndo,"raflags=0x%x,", use->rpu_raflags)); if (~use->rpu_vltime == 0) ND_PRINT((ndo,"vltime=infty,")); else ND_PRINT((ndo,"vltime=%u,", EXTRACT_32BITS(&use->rpu_vltime))); if (~use->rpu_pltime == 0) ND_PRINT((ndo,"pltime=infty,")); else ND_PRINT((ndo,"pltime=%u,", EXTRACT_32BITS(&use->rpu_pltime))); } if (addrtostr6(&use->rpu_prefix, hbuf, sizeof(hbuf))) ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen, use->rpu_keeplen)); else ND_PRINT((ndo,"?/%u/%u", use->rpu_uselen, use->rpu_keeplen)); /*(*/ ND_PRINT((ndo,")")); } } return; trunc: - ND_PRINT((ndo,"[|icmp6]")); + ND_PRINT((ndo, "%s", icmp6_tstr)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-ipnet.c =================================================================== --- vendor/tcpdump/dist/print-ipnet.c (revision 353143) +++ vendor/tcpdump/dist/print-ipnet.c (revision 353144) @@ -1,117 +1,127 @@ /* \summary: Solaris DLT_IPNET printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" +#include "extract.h" +static const char tstr[] = "[|ipnet]"; + typedef struct ipnet_hdr { - uint8_t iph_version; - uint8_t iph_family; - uint16_t iph_htype; - uint32_t iph_pktlen; - uint32_t iph_ifindex; - uint32_t iph_grifindex; - uint32_t iph_zsrc; - uint32_t iph_zdst; + nd_uint8_t iph_version; + nd_uint8_t iph_family; + nd_uint16_t iph_htype; + nd_uint32_t iph_pktlen; + nd_uint32_t iph_ifindex; + nd_uint32_t iph_grifindex; + nd_uint32_t iph_zsrc; + nd_uint32_t iph_zdst; } ipnet_hdr_t; #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ #ifdef DLT_IPNET static const struct tok ipnet_values[] = { { IPH_AF_INET, "IPv4" }, { IPH_AF_INET6, "IPv6" }, { 0, NULL } }; static inline void ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length) { const ipnet_hdr_t *hdr; hdr = (const ipnet_hdr_t *)bp; - ND_PRINT((ndo, "%d > %d", hdr->iph_zsrc, hdr->iph_zdst)); + ND_TCHECK(*hdr); + ND_PRINT((ndo, "%d > %d", EXTRACT_32BITS(hdr->iph_zsrc), + EXTRACT_32BITS(hdr->iph_zdst))); if (!ndo->ndo_qflag) { ND_PRINT((ndo,", family %s (%d)", tok2str(ipnet_values, "Unknown", - hdr->iph_family), - hdr->iph_family)); + EXTRACT_8BITS(&hdr->iph_family)), + EXTRACT_8BITS(&hdr->iph_family))); } else { ND_PRINT((ndo,", %s", tok2str(ipnet_values, "Unknown Ethertype (0x%04x)", - hdr->iph_family))); + EXTRACT_8BITS(&hdr->iph_family)))); } ND_PRINT((ndo, ", length %u: ", length)); + return; +trunc: + ND_PRINT((ndo, " %s", tstr)); } static void ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen) { const ipnet_hdr_t *hdr; - if (caplen < sizeof(ipnet_hdr_t)) { - ND_PRINT((ndo, "[|ipnet]")); - return; - } + if (caplen < sizeof(ipnet_hdr_t)) + goto trunc; if (ndo->ndo_eflag) ipnet_hdr_print(ndo, p, length); length -= sizeof(ipnet_hdr_t); caplen -= sizeof(ipnet_hdr_t); hdr = (const ipnet_hdr_t *)p; p += sizeof(ipnet_hdr_t); - switch (hdr->iph_family) { + ND_TCHECK2(hdr->iph_family, 1); + switch (EXTRACT_8BITS(&hdr->iph_family)) { case IPH_AF_INET: ip_print(ndo, p, length); break; case IPH_AF_INET6: ip6_print(ndo, p, length); break; default: if (!ndo->ndo_eflag) ipnet_hdr_print(ndo, (const u_char *)hdr, length + sizeof(ipnet_hdr_t)); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); break; } + return; +trunc: + ND_PRINT((ndo, " %s", tstr)); } /* * This is the top level routine of the printer. 'p' points * to the ether header of the packet, 'h->ts' is the timestamp, * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ u_int ipnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { ipnet_print(ndo, p, h->len, h->caplen); return (sizeof(ipnet_hdr_t)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ #endif /* DLT_IPNET */ Index: vendor/tcpdump/dist/print-isakmp.c =================================================================== --- vendor/tcpdump/dist/print-isakmp.c (revision 353143) +++ vendor/tcpdump/dist/print-isakmp.c (revision 353144) @@ -1,3145 +1,3146 @@ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project 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 BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ /* \summary: Internet Security Association and Key Management Protocol (ISAKMP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* The functions from print-esp.c used in this file are only defined when both * OpenSSL and evp.h are detected. Employ the same preprocessor device here. */ #ifndef HAVE_OPENSSL_EVP_H #undef HAVE_LIBCRYPTO #endif #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "ip.h" #include "ip6.h" #include "ipproto.h" /* refer to RFC 2408 */ typedef u_char cookie_t[8]; typedef u_char msgid_t[4]; #define PORT_ISAKMP 500 /* 3.1 ISAKMP Header Format (IKEv1 and IKEv2) 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Initiator ! ! Cookie ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Responder ! ! Cookie ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Message ID ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Length ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp { cookie_t i_ck; /* Initiator Cookie */ cookie_t r_ck; /* Responder Cookie */ uint8_t np; /* Next Payload Type */ uint8_t vers; #define ISAKMP_VERS_MAJOR 0xf0 #define ISAKMP_VERS_MAJOR_SHIFT 4 #define ISAKMP_VERS_MINOR 0x0f #define ISAKMP_VERS_MINOR_SHIFT 0 uint8_t etype; /* Exchange Type */ uint8_t flags; /* Flags */ msgid_t msgid; uint32_t len; /* Length */ }; /* Next Payload Type */ #define ISAKMP_NPTYPE_NONE 0 /* NONE*/ #define ISAKMP_NPTYPE_SA 1 /* Security Association */ #define ISAKMP_NPTYPE_P 2 /* Proposal */ #define ISAKMP_NPTYPE_T 3 /* Transform */ #define ISAKMP_NPTYPE_KE 4 /* Key Exchange */ #define ISAKMP_NPTYPE_ID 5 /* Identification */ #define ISAKMP_NPTYPE_CERT 6 /* Certificate */ #define ISAKMP_NPTYPE_CR 7 /* Certificate Request */ #define ISAKMP_NPTYPE_HASH 8 /* Hash */ #define ISAKMP_NPTYPE_SIG 9 /* Signature */ #define ISAKMP_NPTYPE_NONCE 10 /* Nonce */ #define ISAKMP_NPTYPE_N 11 /* Notification */ #define ISAKMP_NPTYPE_D 12 /* Delete */ #define ISAKMP_NPTYPE_VID 13 /* Vendor ID */ #define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */ #define IKEv1_MAJOR_VERSION 1 #define IKEv1_MINOR_VERSION 0 #define IKEv2_MAJOR_VERSION 2 #define IKEv2_MINOR_VERSION 0 /* Flags */ #define ISAKMP_FLAG_E 0x01 /* Encryption Bit */ #define ISAKMP_FLAG_C 0x02 /* Commit Bit */ #define ISAKMP_FLAG_extra 0x04 /* IKEv2 */ #define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */ #define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */ #define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */ /* 3.2 Payload Generic Header 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ! Next Payload ! RESERVED ! Payload Length ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp_gen { uint8_t np; /* Next Payload */ uint8_t critical; /* bit 7 - critical, rest is RESERVED */ uint16_t len; /* Payload Length */ }; /* 3.3 Data Attributes 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ !A! Attribute Type ! AF=0 Attribute Length ! !F! ! AF=1 Attribute Value ! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . AF=0 Attribute Value . . AF=1 Not Transmitted . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct isakmp_data { uint16_t type; /* defined by DOI-spec, and Attribute Format */ uint16_t lorv; /* if f equal 1, Attribute Length */ /* if f equal 0, Attribute Value */ /* if f equal 1, Attribute Value */ }; /* 3.4 Security Association Payload */ /* MAY NOT be used, because of being defined in ipsec-doi. */ /* If the current payload is the last in the message, then the value of the next payload field will be 0. This field MUST NOT contain the values for the Proposal or Transform payloads as they are considered part of the security association negotiation. For example, this field would contain the value "10" (Nonce payload) in the first message of a Base Exchange (see Section 4.4) and the value "0" in the first message of an Identity Protect Exchange (see Section 4.5). */ struct ikev1_pl_sa { struct isakmp_gen h; uint32_t doi; /* Domain of Interpretation */ uint32_t sit; /* Situation */ }; /* 3.5 Proposal Payload */ /* The value of the next payload field MUST only contain the value "2" or "0". If there are additional Proposal payloads in the message, then this field will be 2. If the current Proposal payload is the last within the security association proposal, then this field will be 0. */ struct ikev1_pl_p { struct isakmp_gen h; uint8_t p_no; /* Proposal # */ uint8_t prot_id; /* Protocol */ uint8_t spi_size; /* SPI Size */ uint8_t num_t; /* Number of Transforms */ /* SPI */ }; /* 3.6 Transform Payload */ /* The value of the next payload field MUST only contain the value "3" or "0". If there are additional Transform payloads in the proposal, then this field will be 3. If the current Transform payload is the last within the proposal, then this field will be 0. */ struct ikev1_pl_t { struct isakmp_gen h; uint8_t t_no; /* Transform # */ uint8_t t_id; /* Transform-Id */ uint16_t reserved; /* RESERVED2 */ /* SA Attributes */ }; /* 3.7 Key Exchange Payload */ struct ikev1_pl_ke { struct isakmp_gen h; /* Key Exchange Data */ }; /* 3.8 Identification Payload */ /* MUST NOT to be used, because of being defined in ipsec-doi. */ struct ikev1_pl_id { struct isakmp_gen h; union { uint8_t id_type; /* ID Type */ uint32_t doi_data; /* DOI Specific ID Data */ } d; /* Identification Data */ }; /* 3.9 Certificate Payload */ struct ikev1_pl_cert { struct isakmp_gen h; uint8_t encode; /* Cert Encoding */ char cert; /* Certificate Data */ /* This field indicates the type of certificate or certificate-related information contained in the Certificate Data field. */ }; /* 3.10 Certificate Request Payload */ struct ikev1_pl_cr { struct isakmp_gen h; uint8_t num_cert; /* # Cert. Types */ /* Certificate Types (variable length) -- Contains a list of the types of certificates requested, sorted in order of preference. Each individual certificate type is 1 octet. This field is NOT requiredo */ /* # Certificate Authorities (1 octet) */ /* Certificate Authorities (variable length) */ }; /* 3.11 Hash Payload */ /* may not be used, because of having only data. */ struct ikev1_pl_hash { struct isakmp_gen h; /* Hash Data */ }; /* 3.12 Signature Payload */ /* may not be used, because of having only data. */ struct ikev1_pl_sig { struct isakmp_gen h; /* Signature Data */ }; /* 3.13 Nonce Payload */ /* may not be used, because of having only data. */ struct ikev1_pl_nonce { struct isakmp_gen h; /* Nonce Data */ }; /* 3.14 Notification Payload */ struct ikev1_pl_n { struct isakmp_gen h; uint32_t doi; /* Domain of Interpretation */ uint8_t prot_id; /* Protocol-ID */ uint8_t spi_size; /* SPI Size */ uint16_t type; /* Notify Message Type */ /* SPI */ /* Notification Data */ }; /* 3.14.1 Notify Message Types */ /* NOTIFY MESSAGES - ERROR TYPES */ #define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1 #define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2 #define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3 #define ISAKMP_NTYPE_INVALID_COOKIE 4 #define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5 #define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6 #define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7 #define ISAKMP_NTYPE_INVALID_FLAGS 8 #define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9 #define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10 #define ISAKMP_NTYPE_INVALID_SPI 11 #define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12 #define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13 #define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14 #define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15 #define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16 #define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17 #define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18 #define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19 #define ISAKMP_NTYPE_INVALID_CERTIFICATE 20 #define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21 #define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22 #define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23 #define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24 #define ISAKMP_NTYPE_INVALID_SIGNATURE 25 #define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26 /* 3.15 Delete Payload */ struct ikev1_pl_d { struct isakmp_gen h; uint32_t doi; /* Domain of Interpretation */ uint8_t prot_id; /* Protocol-Id */ uint8_t spi_size; /* SPI Size */ uint16_t num_spi; /* # of SPIs */ /* SPI(es) */ }; struct ikev1_ph1tab { struct ikev1_ph1 *head; struct ikev1_ph1 *tail; int len; }; struct isakmp_ph2tab { struct ikev1_ph2 *head; struct ikev1_ph2 *tail; int len; }; /* IKEv2 (RFC4306) */ /* 3.3 Security Association Payload -- generic header */ /* 3.3.1. Proposal Substructure */ struct ikev2_p { struct isakmp_gen h; uint8_t p_no; /* Proposal # */ uint8_t prot_id; /* Protocol */ uint8_t spi_size; /* SPI Size */ uint8_t num_t; /* Number of Transforms */ }; /* 3.3.2. Transform Substructure */ struct ikev2_t { struct isakmp_gen h; uint8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/ uint8_t res2; /* reserved byte */ uint16_t t_id; /* Transform ID */ }; enum ikev2_t_type { IV2_T_ENCR = 1, IV2_T_PRF = 2, IV2_T_INTEG= 3, IV2_T_DH = 4, IV2_T_ESN = 5 }; /* 3.4. Key Exchange Payload */ struct ikev2_ke { struct isakmp_gen h; uint16_t ke_group; uint16_t ke_res1; /* KE data */ }; /* 3.5. Identification Payloads */ enum ikev2_id_type { ID_IPV4_ADDR=1, ID_FQDN=2, ID_RFC822_ADDR=3, ID_IPV6_ADDR=5, ID_DER_ASN1_DN=9, ID_DER_ASN1_GN=10, ID_KEY_ID=11 }; struct ikev2_id { struct isakmp_gen h; uint8_t type; /* ID type */ uint8_t res1; uint16_t res2; /* SPI */ /* Notification Data */ }; /* 3.10 Notification Payload */ struct ikev2_n { struct isakmp_gen h; uint8_t prot_id; /* Protocol-ID */ uint8_t spi_size; /* SPI Size */ uint16_t type; /* Notify Message Type */ }; enum ikev2_n_type { IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1, IV2_NOTIFY_INVALID_IKE_SPI = 4, IV2_NOTIFY_INVALID_MAJOR_VERSION = 5, IV2_NOTIFY_INVALID_SYNTAX = 7, IV2_NOTIFY_INVALID_MESSAGE_ID = 9, IV2_NOTIFY_INVALID_SPI =11, IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14, IV2_NOTIFY_INVALID_KE_PAYLOAD =17, IV2_NOTIFY_AUTHENTICATION_FAILED =24, IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34, IV2_NOTIFY_NO_ADDITIONAL_SAS =35, IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36, IV2_NOTIFY_FAILED_CP_REQUIRED =37, IV2_NOTIFY_INVALID_SELECTORS =39, IV2_NOTIFY_INITIAL_CONTACT =16384, IV2_NOTIFY_SET_WINDOW_SIZE =16385, IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386, IV2_NOTIFY_IPCOMP_SUPPORTED =16387, IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388, IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389, IV2_NOTIFY_COOKIE =16390, IV2_NOTIFY_USE_TRANSPORT_MODE =16391, IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392, IV2_NOTIFY_REKEY_SA =16393, IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394, IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395 }; struct notify_messages { uint16_t type; char *msg; }; /* 3.8 Authentication Payload */ struct ikev2_auth { struct isakmp_gen h; uint8_t auth_method; /* Protocol-ID */ uint8_t reserved[3]; /* authentication data */ }; enum ikev2_auth_type { IV2_RSA_SIG = 1, IV2_SHARED = 2, IV2_DSS_SIG = 3 }; /* refer to RFC 2409 */ #if 0 /* isakmp sa structure */ struct oakley_sa { uint8_t proto_id; /* OAKLEY */ vchar_t *spi; /* spi */ uint8_t dhgrp; /* DH; group */ uint8_t auth_t; /* method of authentication */ uint8_t prf_t; /* type of prf */ uint8_t hash_t; /* type of hash */ uint8_t enc_t; /* type of cipher */ uint8_t life_t; /* type of duration of lifetime */ uint32_t ldur; /* life duration */ }; #endif /* refer to RFC 2407 */ #define IPSEC_DOI 1 /* 4.2 IPSEC Situation Definition */ #define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001 #define IPSECDOI_SIT_SECRECY 0x00000002 #define IPSECDOI_SIT_INTEGRITY 0x00000004 /* 4.4.1 IPSEC Security Protocol Identifiers */ /* 4.4.2 IPSEC ISAKMP Transform Values */ #define IPSECDOI_PROTO_ISAKMP 1 #define IPSECDOI_KEY_IKE 1 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPSEC_AH 2 /* 4.4.3 IPSEC AH Transform Values */ #define IPSECDOI_AH_MD5 2 #define IPSECDOI_AH_SHA 3 #define IPSECDOI_AH_DES 4 #define IPSECDOI_AH_SHA2_256 5 #define IPSECDOI_AH_SHA2_384 6 #define IPSECDOI_AH_SHA2_512 7 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPSEC_ESP 3 /* 4.4.4 IPSEC ESP Transform Identifiers */ #define IPSECDOI_ESP_DES_IV64 1 #define IPSECDOI_ESP_DES 2 #define IPSECDOI_ESP_3DES 3 #define IPSECDOI_ESP_RC5 4 #define IPSECDOI_ESP_IDEA 5 #define IPSECDOI_ESP_CAST 6 #define IPSECDOI_ESP_BLOWFISH 7 #define IPSECDOI_ESP_3IDEA 8 #define IPSECDOI_ESP_DES_IV32 9 #define IPSECDOI_ESP_RC4 10 #define IPSECDOI_ESP_NULL 11 #define IPSECDOI_ESP_RIJNDAEL 12 #define IPSECDOI_ESP_AES 12 /* 4.4.1 IPSEC Security Protocol Identifiers */ #define IPSECDOI_PROTO_IPCOMP 4 /* 4.4.5 IPSEC IPCOMP Transform Identifiers */ #define IPSECDOI_IPCOMP_OUI 1 #define IPSECDOI_IPCOMP_DEFLATE 2 #define IPSECDOI_IPCOMP_LZS 3 /* 4.5 IPSEC Security Association Attributes */ #define IPSECDOI_ATTR_SA_LTYPE 1 /* B */ #define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1 #define IPSECDOI_ATTR_SA_LTYPE_SEC 1 #define IPSECDOI_ATTR_SA_LTYPE_KB 2 #define IPSECDOI_ATTR_SA_LDUR 2 /* V */ #define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */ #define IPSECDOI_ATTR_GRP_DESC 3 /* B */ #define IPSECDOI_ATTR_ENC_MODE 4 /* B */ /* default value: host dependent */ #define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1 #define IPSECDOI_ATTR_ENC_MODE_TRNS 2 #define IPSECDOI_ATTR_AUTH 5 /* B */ /* 0 means not to use authentication. */ #define IPSECDOI_ATTR_AUTH_HMAC_MD5 1 #define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2 #define IPSECDOI_ATTR_AUTH_DES_MAC 3 #define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/ /* * When negotiating ESP without authentication, the Auth * Algorithm attribute MUST NOT be included in the proposal. * When negotiating ESP without confidentiality, the Auth * Algorithm attribute MUST be included in the proposal and * the ESP transform ID must be ESP_NULL. */ #define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */ #define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */ #define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */ #define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */ /* 4.6.1 Security Association Payload */ struct ipsecdoi_sa { struct isakmp_gen h; uint32_t doi; /* Domain of Interpretation */ uint32_t sit; /* Situation */ }; struct ipsecdoi_secrecy_h { uint16_t len; uint16_t reserved; }; /* 4.6.2.1 Identification Type Values */ struct ipsecdoi_id { struct isakmp_gen h; uint8_t type; /* ID Type */ uint8_t proto_id; /* Protocol ID */ uint16_t port; /* Port */ /* Identification Data */ }; #define IPSECDOI_ID_IPV4_ADDR 1 #define IPSECDOI_ID_FQDN 2 #define IPSECDOI_ID_USER_FQDN 3 #define IPSECDOI_ID_IPV4_ADDR_SUBNET 4 #define IPSECDOI_ID_IPV6_ADDR 5 #define IPSECDOI_ID_IPV6_ADDR_SUBNET 6 #define IPSECDOI_ID_IPV4_ADDR_RANGE 7 #define IPSECDOI_ID_IPV6_ADDR_RANGE 8 #define IPSECDOI_ID_DER_ASN1_DN 9 #define IPSECDOI_ID_DER_ASN1_GN 10 #define IPSECDOI_ID_KEY_ID 11 /* 4.6.3 IPSEC DOI Notify Message Types */ /* Notify Messages - Status Types */ #define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576 #define IPSECDOI_NTYPE_REPLAY_STATUS 24577 #define IPSECDOI_NTYPE_INITIAL_CONTACT 24578 #define DECLARE_PRINTER(func) static const u_char *ike##func##_print( \ netdissect_options *ndo, u_char tpay, \ const struct isakmp_gen *ext, \ u_int item_len, \ const u_char *end_pointer, \ uint32_t phase,\ uint32_t doi0, \ uint32_t proto0, int depth) DECLARE_PRINTER(v1_sa); DECLARE_PRINTER(v1_p); DECLARE_PRINTER(v1_t); DECLARE_PRINTER(v1_ke); DECLARE_PRINTER(v1_id); DECLARE_PRINTER(v1_cert); DECLARE_PRINTER(v1_cr); DECLARE_PRINTER(v1_sig); DECLARE_PRINTER(v1_hash); DECLARE_PRINTER(v1_nonce); DECLARE_PRINTER(v1_n); DECLARE_PRINTER(v1_d); DECLARE_PRINTER(v1_vid); DECLARE_PRINTER(v2_sa); DECLARE_PRINTER(v2_ke); DECLARE_PRINTER(v2_ID); DECLARE_PRINTER(v2_cert); DECLARE_PRINTER(v2_cr); DECLARE_PRINTER(v2_auth); DECLARE_PRINTER(v2_nonce); DECLARE_PRINTER(v2_n); DECLARE_PRINTER(v2_d); DECLARE_PRINTER(v2_vid); DECLARE_PRINTER(v2_TS); DECLARE_PRINTER(v2_cp); DECLARE_PRINTER(v2_eap); static const u_char *ikev2_e_print(netdissect_options *ndo, struct isakmp *base, u_char tpay, const struct isakmp_gen *ext, u_int item_len, const u_char *end_pointer, uint32_t phase, uint32_t doi0, uint32_t proto0, int depth); static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *, const u_char *, uint32_t, uint32_t, uint32_t, int); static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *, const u_char *, uint32_t, uint32_t, uint32_t, int); static const u_char *ikev2_sub_print(netdissect_options *ndo, struct isakmp *base, u_char np, const struct isakmp_gen *ext, const u_char *ep, uint32_t phase, uint32_t doi, uint32_t proto, int depth); static char *numstr(int); static void ikev1_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2, struct isakmp *base); #define MAXINITIATORS 20 static int ninitiator = 0; union inaddr_u { struct in_addr in4; struct in6_addr in6; }; static struct { cookie_t initiator; u_int version; union inaddr_u iaddr; union inaddr_u raddr; } cookiecache[MAXINITIATORS]; /* protocol id */ static const char *protoidstr[] = { NULL, "isakmp", "ipsec-ah", "ipsec-esp", "ipcomp", }; /* isakmp->np */ static const char *npstr[] = { "none", "sa", "p", "t", "ke", "id", "cert", "cr", "hash", /* 0 - 8 */ "sig", "nonce", "n", "d", "vid", /* 9 - 13 */ "pay14", "pay15", "pay16", "pay17", "pay18", /* 14- 18 */ "pay19", "pay20", "pay21", "pay22", "pay23", /* 19- 23 */ "pay24", "pay25", "pay26", "pay27", "pay28", /* 24- 28 */ "pay29", "pay30", "pay31", "pay32", /* 29- 32 */ "v2sa", "v2ke", "v2IDi", "v2IDr", "v2cert",/* 33- 37 */ "v2cr", "v2auth","v2nonce", "v2n", "v2d", /* 38- 42 */ "v2vid", "v2TSi", "v2TSr", "v2e", "v2cp", /* 43- 47 */ "v2eap", /* 48 */ }; /* isakmp->np */ static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len, const u_char *end_pointer, uint32_t phase, uint32_t doi0, uint32_t proto0, int depth) = { NULL, ikev1_sa_print, ikev1_p_print, ikev1_t_print, ikev1_ke_print, ikev1_id_print, ikev1_cert_print, ikev1_cr_print, ikev1_hash_print, ikev1_sig_print, ikev1_nonce_print, ikev1_n_print, ikev1_d_print, ikev1_vid_print, /* 13 */ NULL, NULL, NULL, NULL, NULL, /* 14- 18 */ NULL, NULL, NULL, NULL, NULL, /* 19- 23 */ NULL, NULL, NULL, NULL, NULL, /* 24- 28 */ NULL, NULL, NULL, NULL, /* 29- 32 */ ikev2_sa_print, /* 33 */ ikev2_ke_print, /* 34 */ ikev2_ID_print, /* 35 */ ikev2_ID_print, /* 36 */ ikev2_cert_print, /* 37 */ ikev2_cr_print, /* 38 */ ikev2_auth_print, /* 39 */ ikev2_nonce_print, /* 40 */ ikev2_n_print, /* 41 */ ikev2_d_print, /* 42 */ ikev2_vid_print, /* 43 */ ikev2_TS_print, /* 44 */ ikev2_TS_print, /* 45 */ NULL, /* ikev2_e_print,*/ /* 46 - special */ ikev2_cp_print, /* 47 */ ikev2_eap_print, /* 48 */ }; /* isakmp->etype */ static const char *etypestr[] = { /* IKEv1 exchange types */ "none", "base", "ident", "auth", "agg", "inf", NULL, NULL, /* 0-7 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 8-15 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 16-23 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 24-31 */ "oakley-quick", "oakley-newgroup", /* 32-33 */ /* IKEv2 exchange types */ "ikev2_init", "ikev2_auth", "child_sa", "inf2" /* 34-37 */ }; #define STR_OR_ID(x, tab) \ (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x)) #define PROTOIDSTR(x) STR_OR_ID(x, protoidstr) #define NPSTR(x) STR_OR_ID(x, npstr) #define ETYPESTR(x) STR_OR_ID(x, etypestr) #define CHECKLEN(p, np) \ if (ep < (const u_char *)(p)) { \ ND_PRINT((ndo," [|%s]", NPSTR(np))); \ goto done; \ } #define NPFUNC(x) \ (((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \ ? npfunc[(x)] : NULL) static int iszero(const u_char *p, size_t l) { while (l--) { if (*p++) return 0; } return 1; } /* find cookie from initiator cache */ static int cookie_find(cookie_t *in) { int i; for (i = 0; i < MAXINITIATORS; i++) { if (memcmp(in, &cookiecache[i].initiator, sizeof(*in)) == 0) return i; } return -1; } /* record initiator */ static void cookie_record(cookie_t *in, const u_char *bp2) { int i; const struct ip *ip; const struct ip6_hdr *ip6; i = cookie_find(in); if (0 <= i) { ninitiator = (i + 1) % MAXINITIATORS; return; } ip = (const struct ip *)bp2; switch (IP_V(ip)) { case 4: cookiecache[ninitiator].version = 4; UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr)); UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr)); break; case 6: ip6 = (const struct ip6_hdr *)bp2; cookiecache[ninitiator].version = 6; UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr)); UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr)); break; default: return; } UNALIGNED_MEMCPY(&cookiecache[ninitiator].initiator, in, sizeof(*in)); ninitiator = (ninitiator + 1) % MAXINITIATORS; } #define cookie_isinitiator(x, y) cookie_sidecheck((x), (y), 1) #define cookie_isresponder(x, y) cookie_sidecheck((x), (y), 0) static int cookie_sidecheck(int i, const u_char *bp2, int initiator) { const struct ip *ip; const struct ip6_hdr *ip6; ip = (const struct ip *)bp2; switch (IP_V(ip)) { case 4: if (cookiecache[i].version != 4) return 0; if (initiator) { if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0) return 1; } else { if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0) return 1; } break; case 6: if (cookiecache[i].version != 6) return 0; ip6 = (const struct ip6_hdr *)bp2; if (initiator) { if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0) return 1; } else { if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0) return 1; } break; default: break; } return 0; } static void hexprint(netdissect_options *ndo, const uint8_t *loc, size_t len) { const uint8_t *p; size_t i; p = loc; for (i = 0; i < len; i++) ND_PRINT((ndo,"%02x", p[i] & 0xff)); } static int rawprint(netdissect_options *ndo, const uint8_t *loc, size_t len) { ND_TCHECK2(*loc, len); hexprint(ndo, loc, len); return 1; trunc: return 0; } /* * returns false if we run out of data buffer */ static int ike_show_somedata(netdissect_options *ndo, const u_char *cp, const u_char *ep) { /* there is too much data, just show some of it */ const u_char *end = ep - 20; int elen = 20; int len = ep - cp; if(len > 10) { len = 10; } /* really shouldn't happen because of above */ if(end < cp + len) { end = cp+len; elen = ep - end; } ND_PRINT((ndo," data=(")); if(!rawprint(ndo, (const uint8_t *)(cp), len)) goto trunc; ND_PRINT((ndo, "...")); if(elen) { if(!rawprint(ndo, (const uint8_t *)(end), elen)) goto trunc; } ND_PRINT((ndo,")")); return 1; trunc: return 0; } struct attrmap { const char *type; u_int nvalue; const char *value[30]; /*XXX*/ }; static const u_char * ikev1_attrmap_print(netdissect_options *ndo, const u_char *p, const u_char *ep2, const struct attrmap *map, size_t nmap) { int totlen; uint32_t t, v; ND_TCHECK(p[0]); if (p[0] & 0x80) totlen = 4; else { ND_TCHECK_16BITS(&p[2]); totlen = 4 + EXTRACT_16BITS(&p[2]); } if (ep2 < p + totlen) { ND_PRINT((ndo,"[|attr]")); return ep2 + 1; } ND_TCHECK_16BITS(&p[0]); ND_PRINT((ndo,"(")); t = EXTRACT_16BITS(&p[0]) & 0x7fff; if (map && t < nmap && map[t].type) ND_PRINT((ndo,"type=%s ", map[t].type)); else ND_PRINT((ndo,"type=#%d ", t)); if (p[0] & 0x80) { ND_PRINT((ndo,"value=")); ND_TCHECK_16BITS(&p[2]); v = EXTRACT_16BITS(&p[2]); if (map && t < nmap && v < map[t].nvalue && map[t].value[v]) ND_PRINT((ndo,"%s", map[t].value[v])); else { if (!rawprint(ndo, (const uint8_t *)&p[2], 2)) { ND_PRINT((ndo,")")); goto trunc; } } } else { ND_PRINT((ndo,"len=%d value=", totlen - 4)); if (!rawprint(ndo, (const uint8_t *)&p[4], totlen - 4)) { ND_PRINT((ndo,")")); goto trunc; } } ND_PRINT((ndo,")")); return p + totlen; trunc: return NULL; } static const u_char * ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep2) { int totlen; uint32_t t; ND_TCHECK(p[0]); if (p[0] & 0x80) totlen = 4; else { ND_TCHECK_16BITS(&p[2]); totlen = 4 + EXTRACT_16BITS(&p[2]); } if (ep2 < p + totlen) { ND_PRINT((ndo,"[|attr]")); return ep2 + 1; } ND_TCHECK_16BITS(&p[0]); ND_PRINT((ndo,"(")); t = EXTRACT_16BITS(&p[0]) & 0x7fff; ND_PRINT((ndo,"type=#%d ", t)); if (p[0] & 0x80) { ND_PRINT((ndo,"value=")); t = p[2]; if (!rawprint(ndo, (const uint8_t *)&p[2], 2)) { ND_PRINT((ndo,")")); goto trunc; } } else { ND_PRINT((ndo,"len=%d value=", totlen - 4)); if (!rawprint(ndo, (const uint8_t *)&p[4], totlen - 4)) { ND_PRINT((ndo,")")); goto trunc; } } ND_PRINT((ndo,")")); return p + totlen; trunc: return NULL; } static const u_char * ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep, uint32_t phase, uint32_t doi0 _U_, uint32_t proto0, int depth) { const struct ikev1_pl_sa *p; struct ikev1_pl_sa sa; uint32_t doi, sit, ident; const u_char *cp, *np; int t; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA))); p = (const struct ikev1_pl_sa *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&sa, ext, sizeof(sa)); doi = ntohl(sa.doi); sit = ntohl(sa.sit); if (doi != 1) { ND_PRINT((ndo," doi=%d", doi)); ND_PRINT((ndo," situation=%u", (uint32_t)ntohl(sa.sit))); return (const u_char *)(p + 1); } ND_PRINT((ndo," doi=ipsec")); ND_PRINT((ndo," situation=")); t = 0; if (sit & 0x01) { ND_PRINT((ndo,"identity")); t++; } if (sit & 0x02) { ND_PRINT((ndo,"%ssecrecy", t ? "+" : "")); t++; } if (sit & 0x04) ND_PRINT((ndo,"%sintegrity", t ? "+" : "")); np = (const u_char *)ext + sizeof(sa); if (sit != 0x01) { ND_TCHECK2(*(ext + 1), sizeof(ident)); UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident)); ND_PRINT((ndo," ident=%u", (uint32_t)ntohl(ident))); np += sizeof(ident); } ext = (const struct isakmp_gen *)np; ND_TCHECK(*ext); cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0, depth); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SA))); return NULL; } static const u_char * ikev1_p_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep, uint32_t phase, uint32_t doi0, uint32_t proto0 _U_, int depth) { const struct ikev1_pl_p *p; struct ikev1_pl_p prop; const u_char *cp; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_P))); p = (const struct ikev1_pl_p *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&prop, ext, sizeof(prop)); ND_PRINT((ndo," #%d protoid=%s transform=%d", prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t)); if (prop.spi_size) { ND_PRINT((ndo," spi=")); if (!rawprint(ndo, (const uint8_t *)(p + 1), prop.spi_size)) goto trunc; } ext = (const struct isakmp_gen *)((const u_char *)(p + 1) + prop.spi_size); ND_TCHECK(*ext); cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0, prop.prot_id, depth); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); return NULL; } static const char *ikev1_p_map[] = { NULL, "ike", }; static const char *ikev2_t_type_map[]={ NULL, "encr", "prf", "integ", "dh", "esn" }; static const char *ah_p_map[] = { NULL, "(reserved)", "md5", "sha", "1des", "sha2-256", "sha2-384", "sha2-512", }; static const char *prf_p_map[] = { NULL, "hmac-md5", "hmac-sha", "hmac-tiger", "aes128_xcbc" }; static const char *integ_p_map[] = { NULL, "hmac-md5", "hmac-sha", "dec-mac", "kpdk-md5", "aes-xcbc" }; static const char *esn_p_map[] = { "no-esn", "esn" }; static const char *dh_p_map[] = { NULL, "modp768", "modp1024", /* group 2 */ "EC2N 2^155", /* group 3 */ "EC2N 2^185", /* group 4 */ "modp1536", /* group 5 */ "iana-grp06", "iana-grp07", /* reserved */ "iana-grp08", "iana-grp09", "iana-grp10", "iana-grp11", "iana-grp12", "iana-grp13", "modp2048", /* group 14 */ "modp3072", /* group 15 */ "modp4096", /* group 16 */ "modp6144", /* group 17 */ "modp8192", /* group 18 */ }; static const char *esp_p_map[] = { NULL, "1des-iv64", "1des", "3des", "rc5", "idea", "cast", "blowfish", "3idea", "1des-iv32", "rc4", "null", "aes" }; static const char *ipcomp_p_map[] = { NULL, "oui", "deflate", "lzs", }; static const struct attrmap ipsec_t_map[] = { { NULL, 0, { NULL } }, { "lifetype", 3, { NULL, "sec", "kb", }, }, { "life", 0, { NULL } }, { "group desc", 18, { NULL, "modp768", "modp1024", /* group 2 */ "EC2N 2^155", /* group 3 */ "EC2N 2^185", /* group 4 */ "modp1536", /* group 5 */ "iana-grp06", "iana-grp07", /* reserved */ "iana-grp08", "iana-grp09", "iana-grp10", "iana-grp11", "iana-grp12", "iana-grp13", "modp2048", /* group 14 */ "modp3072", /* group 15 */ "modp4096", /* group 16 */ "modp6144", /* group 17 */ "modp8192", /* group 18 */ }, }, { "enc mode", 3, { NULL, "tunnel", "transport", }, }, { "auth", 5, { NULL, "hmac-md5", "hmac-sha1", "1des-mac", "keyed", }, }, { "keylen", 0, { NULL } }, { "rounds", 0, { NULL } }, { "dictsize", 0, { NULL } }, { "privalg", 0, { NULL } }, }; static const struct attrmap encr_t_map[] = { { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 0, 1 */ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 2, 3 */ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 4, 5 */ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 6, 7 */ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 8, 9 */ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 10,11*/ { NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 12,13*/ { "keylen", 14, { NULL }}, }; static const struct attrmap oakley_t_map[] = { { NULL, 0, { NULL } }, { "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5", "3des", "cast", "aes", }, }, { "hash", 7, { NULL, "md5", "sha1", "tiger", "sha2-256", "sha2-384", "sha2-512", }, }, { "auth", 6, { NULL, "preshared", "dss", "rsa sig", "rsa enc", "rsa enc revised", }, }, { "group desc", 18, { NULL, "modp768", "modp1024", /* group 2 */ "EC2N 2^155", /* group 3 */ "EC2N 2^185", /* group 4 */ "modp1536", /* group 5 */ "iana-grp06", "iana-grp07", /* reserved */ "iana-grp08", "iana-grp09", "iana-grp10", "iana-grp11", "iana-grp12", "iana-grp13", "modp2048", /* group 14 */ "modp3072", /* group 15 */ "modp4096", /* group 16 */ "modp6144", /* group 17 */ "modp8192", /* group 18 */ }, }, { "group type", 4, { NULL, "MODP", "ECP", "EC2N", }, }, { "group prime", 0, { NULL } }, { "group gen1", 0, { NULL } }, { "group gen2", 0, { NULL } }, { "group curve A", 0, { NULL } }, { "group curve B", 0, { NULL } }, { "lifetype", 3, { NULL, "sec", "kb", }, }, { "lifeduration", 0, { NULL } }, { "prf", 0, { NULL } }, { "keylen", 0, { NULL } }, { "field", 0, { NULL } }, { "order", 0, { NULL } }, }; static const u_char * ikev1_t_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto, int depth _U_) { const struct ikev1_pl_t *p; struct ikev1_pl_t t; const u_char *cp; const char *idstr; const struct attrmap *map; size_t nmap; const u_char *ep2; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_T))); p = (const struct ikev1_pl_t *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&t, ext, sizeof(t)); switch (proto) { case 1: idstr = STR_OR_ID(t.t_id, ikev1_p_map); map = oakley_t_map; nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); break; case 2: idstr = STR_OR_ID(t.t_id, ah_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; case 3: idstr = STR_OR_ID(t.t_id, esp_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; case 4: idstr = STR_OR_ID(t.t_id, ipcomp_p_map); map = ipsec_t_map; nmap = sizeof(ipsec_t_map)/sizeof(ipsec_t_map[0]); break; default: idstr = NULL; map = NULL; nmap = 0; break; } if (idstr) ND_PRINT((ndo," #%d id=%s ", t.t_no, idstr)); else ND_PRINT((ndo," #%d id=%d ", t.t_no, t.t_id)); cp = (const u_char *)(p + 1); ep2 = (const u_char *)p + item_len; while (cp < ep && cp < ep2) { if (map && nmap) cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); else cp = ikev1_attr_print(ndo, cp, ep2); if (cp == NULL) goto trunc; } if (ep < ep2) ND_PRINT((ndo,"...")); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T))); return NULL; } static const u_char * ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE))); ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4)); if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_KE))); return NULL; } static const u_char * ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep _U_, uint32_t phase, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { #define USE_IPSECDOI_IN_PHASE1 1 const struct ikev1_pl_id *p; struct ikev1_pl_id id; static const char *idtypestr[] = { "IPv4", "IPv4net", "IPv6", "IPv6net", }; static const char *ipsecidtypestr[] = { NULL, "IPv4", "FQDN", "user FQDN", "IPv4net", "IPv6", "IPv6net", "IPv4range", "IPv6range", "ASN1 DN", "ASN1 GN", "keyid", }; int len; const u_char *data; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_ID))); p = (const struct ikev1_pl_id *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&id, ext, sizeof(id)); if (sizeof(*p) < item_len) { data = (const u_char *)(p + 1); len = item_len - sizeof(*p); } else { data = NULL; len = 0; } #if 0 /*debug*/ ND_PRINT((ndo," [phase=%d doi=%d proto=%d]", phase, doi, proto)); #endif switch (phase) { #ifndef USE_IPSECDOI_IN_PHASE1 case 1: #endif default: ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr))); ND_PRINT((ndo," doi_data=%u", (uint32_t)(ntohl(id.d.doi_data) & 0xffffff))); break; #ifdef USE_IPSECDOI_IN_PHASE1 case 1: #endif case 2: { const struct ipsecdoi_id *doi_p; struct ipsecdoi_id doi_id; const char *p_name; doi_p = (const struct ipsecdoi_id *)ext; ND_TCHECK(*doi_p); UNALIGNED_MEMCPY(&doi_id, ext, sizeof(doi_id)); ND_PRINT((ndo," idtype=%s", STR_OR_ID(doi_id.type, ipsecidtypestr))); /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */ if (!ndo->ndo_nflag && doi_id.proto_id && (p_name = netdb_protoname(doi_id.proto_id)) != NULL) ND_PRINT((ndo," protoid=%s", p_name)); else ND_PRINT((ndo," protoid=%u", doi_id.proto_id)); ND_PRINT((ndo," port=%d", ntohs(doi_id.port))); if (!len) break; if (data == NULL) goto trunc; ND_TCHECK2(*data, len); switch (doi_id.type) { case IPSECDOI_ID_IPV4_ADDR: if (len < 4) ND_PRINT((ndo," len=%d [bad: < 4]", len)); else ND_PRINT((ndo," len=%d %s", len, ipaddr_string(ndo, data))); len = 0; break; case IPSECDOI_ID_FQDN: case IPSECDOI_ID_USER_FQDN: { int i; ND_PRINT((ndo," len=%d ", len)); for (i = 0; i < len; i++) safeputchar(ndo, data[i]); len = 0; break; } case IPSECDOI_ID_IPV4_ADDR_SUBNET: { const u_char *mask; if (len < 8) ND_PRINT((ndo," len=%d [bad: < 8]", len)); else { mask = data + sizeof(struct in_addr); ND_PRINT((ndo," len=%d %s/%u.%u.%u.%u", len, ipaddr_string(ndo, data), mask[0], mask[1], mask[2], mask[3])); } len = 0; break; } case IPSECDOI_ID_IPV6_ADDR: if (len < 16) ND_PRINT((ndo," len=%d [bad: < 16]", len)); else ND_PRINT((ndo," len=%d %s", len, ip6addr_string(ndo, data))); len = 0; break; case IPSECDOI_ID_IPV6_ADDR_SUBNET: { const u_char *mask; if (len < 32) ND_PRINT((ndo," len=%d [bad: < 32]", len)); else { mask = (const u_char *)(data + sizeof(struct in6_addr)); /*XXX*/ ND_PRINT((ndo," len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", len, ip6addr_string(ndo, data), mask[0], mask[1], mask[2], mask[3], mask[4], mask[5], mask[6], mask[7], mask[8], mask[9], mask[10], mask[11], mask[12], mask[13], mask[14], mask[15])); } len = 0; break; } case IPSECDOI_ID_IPV4_ADDR_RANGE: if (len < 8) ND_PRINT((ndo," len=%d [bad: < 8]", len)); else { ND_PRINT((ndo," len=%d %s-%s", len, ipaddr_string(ndo, data), ipaddr_string(ndo, data + sizeof(struct in_addr)))); } len = 0; break; case IPSECDOI_ID_IPV6_ADDR_RANGE: if (len < 32) ND_PRINT((ndo," len=%d [bad: < 32]", len)); else { ND_PRINT((ndo," len=%d %s-%s", len, ip6addr_string(ndo, data), ip6addr_string(ndo, data + sizeof(struct in6_addr)))); } len = 0; break; case IPSECDOI_ID_DER_ASN1_DN: case IPSECDOI_ID_DER_ASN1_GN: case IPSECDOI_ID_KEY_ID: break; } break; } } if (data && len) { ND_PRINT((ndo," len=%d", len)); if (2 < ndo->ndo_vflag) { ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)data, len)) goto trunc; } } return (const u_char *)ext + item_len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_ID))); return NULL; } static const u_char * ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_, uint32_t proto0 _U_, int depth _U_) { const struct ikev1_pl_cert *p; struct ikev1_pl_cert cert; static const char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", }; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT))); p = (const struct ikev1_pl_cert *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&cert, ext, sizeof(cert)); ND_PRINT((ndo," len=%d", item_len - 4)); ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr))); if (2 < ndo->ndo_vflag && 4 < item_len) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), item_len - 4)) goto trunc; } return (const u_char *)ext + item_len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT))); return NULL; } static const u_char * ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_, uint32_t proto0 _U_, int depth _U_) { const struct ikev1_pl_cert *p; struct ikev1_pl_cert cert; static const char *certstr[] = { "none", "pkcs7", "pgp", "dns", "x509sign", "x509ke", "kerberos", "crl", "arl", "spki", "x509attr", }; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CR))); p = (const struct ikev1_pl_cert *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&cert, ext, sizeof(cert)); ND_PRINT((ndo," len=%d", item_len - 4)); ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr))); if (2 < ndo->ndo_vflag && 4 < item_len) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), item_len - 4)) goto trunc; } return (const u_char *)ext + item_len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CR))); return NULL; } static const u_char * ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH))); ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_HASH))); return NULL; } static const u_char * ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG))); ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SIG))); return NULL; } static const u_char * ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE))); ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); /* * Our caller has ensured that the length is >= 4. */ ND_PRINT((ndo," n len=%u", ntohs(e.len) - 4)); if (ntohs(e.len) > 4) { if (ndo->ndo_vflag > 2) { ND_PRINT((ndo, " ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } else if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, " ")); if (!ike_show_somedata(ndo, (const u_char *)(ext + 1), ep)) goto trunc; } } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE))); return NULL; } static const u_char * ikev1_n_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep, uint32_t phase _U_, uint32_t doi0 _U_, uint32_t proto0 _U_, int depth _U_) { const struct ikev1_pl_n *p; struct ikev1_pl_n n; const u_char *cp; const u_char *ep2; uint32_t doi; uint32_t proto; static const char *notify_error_str[] = { NULL, "INVALID-PAYLOAD-TYPE", "DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED", "INVALID-COOKIE", "INVALID-MAJOR-VERSION", "INVALID-MINOR-VERSION", "INVALID-EXCHANGE-TYPE", "INVALID-FLAGS", "INVALID-MESSAGE-ID", "INVALID-PROTOCOL-ID", "INVALID-SPI", "INVALID-TRANSFORM-ID", "ATTRIBUTES-NOT-SUPPORTED", "NO-PROPOSAL-CHOSEN", "BAD-PROPOSAL-SYNTAX", "PAYLOAD-MALFORMED", "INVALID-KEY-INFORMATION", "INVALID-ID-INFORMATION", "INVALID-CERT-ENCODING", "INVALID-CERTIFICATE", "CERT-TYPE-UNSUPPORTED", "INVALID-CERT-AUTHORITY", "INVALID-HASH-INFORMATION", "AUTHENTICATION-FAILED", "INVALID-SIGNATURE", "ADDRESS-NOTIFICATION", "NOTIFY-SA-LIFETIME", "CERTIFICATE-UNAVAILABLE", "UNSUPPORTED-EXCHANGE-TYPE", "UNEQUAL-PAYLOAD-LENGTHS", }; static const char *ipsec_notify_error_str[] = { "RESERVED", }; static const char *notify_status_str[] = { "CONNECTED", }; static const char *ipsec_notify_status_str[] = { "RESPONDER-LIFETIME", "REPLAY-STATUS", "INITIAL-CONTACT", }; /* NOTE: these macro must be called with x in proper range */ /* 0 - 8191 */ #define NOTIFY_ERROR_STR(x) \ STR_OR_ID((x), notify_error_str) /* 8192 - 16383 */ #define IPSEC_NOTIFY_ERROR_STR(x) \ STR_OR_ID((u_int)((x) - 8192), ipsec_notify_error_str) /* 16384 - 24575 */ #define NOTIFY_STATUS_STR(x) \ STR_OR_ID((u_int)((x) - 16384), notify_status_str) /* 24576 - 32767 */ #define IPSEC_NOTIFY_STATUS_STR(x) \ STR_OR_ID((u_int)((x) - 24576), ipsec_notify_status_str) ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N))); p = (const struct ikev1_pl_n *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&n, ext, sizeof(n)); doi = ntohl(n.doi); proto = n.prot_id; if (doi != 1) { ND_PRINT((ndo," doi=%d", doi)); ND_PRINT((ndo," proto=%d", proto)); if (ntohs(n.type) < 8192) ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 16384) ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); else if (ntohs(n.type) < 24576) ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); else ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); if (n.spi_size) { ND_PRINT((ndo," spi=")); if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) goto trunc; } return (const u_char *)(p + 1) + n.spi_size; } ND_PRINT((ndo," doi=ipsec")); ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); if (ntohs(n.type) < 8192) ND_PRINT((ndo," type=%s", NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 16384) ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_ERROR_STR(ntohs(n.type)))); else if (ntohs(n.type) < 24576) ND_PRINT((ndo," type=%s", NOTIFY_STATUS_STR(ntohs(n.type)))); else if (ntohs(n.type) < 32768) ND_PRINT((ndo," type=%s", IPSEC_NOTIFY_STATUS_STR(ntohs(n.type)))); else ND_PRINT((ndo," type=%s", numstr(ntohs(n.type)))); if (n.spi_size) { ND_PRINT((ndo," spi=")); if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) goto trunc; } cp = (const u_char *)(p + 1) + n.spi_size; ep2 = (const u_char *)p + item_len; if (cp < ep) { switch (ntohs(n.type)) { case IPSECDOI_NTYPE_RESPONDER_LIFETIME: { const struct attrmap *map = oakley_t_map; size_t nmap = sizeof(oakley_t_map)/sizeof(oakley_t_map[0]); ND_PRINT((ndo," attrs=(")); while (cp < ep && cp < ep2) { cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); if (cp == NULL) { ND_PRINT((ndo,")")); goto trunc; } } ND_PRINT((ndo,")")); break; } case IPSECDOI_NTYPE_REPLAY_STATUS: ND_PRINT((ndo," status=(")); + ND_TCHECK_32BITS(cp); ND_PRINT((ndo,"replay detection %sabled", EXTRACT_32BITS(cp) ? "en" : "dis")); ND_PRINT((ndo,")")); break; default: /* * XXX - fill in more types here; see, for example, * draft-ietf-ipsec-notifymsg-04. */ if (ndo->ndo_vflag > 3) { ND_PRINT((ndo," data=(")); if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp)) goto trunc; ND_PRINT((ndo,")")); } else { if (!ike_show_somedata(ndo, cp, ep)) goto trunc; } break; } } return (const u_char *)ext + item_len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N))); return NULL; } static const u_char * ikev1_d_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_, uint32_t proto0 _U_, int depth _U_) { const struct ikev1_pl_d *p; struct ikev1_pl_d d; const uint8_t *q; uint32_t doi; uint32_t proto; int i; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D))); p = (const struct ikev1_pl_d *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&d, ext, sizeof(d)); doi = ntohl(d.doi); proto = d.prot_id; if (doi != 1) { ND_PRINT((ndo," doi=%u", doi)); ND_PRINT((ndo," proto=%u", proto)); } else { ND_PRINT((ndo," doi=ipsec")); ND_PRINT((ndo," proto=%s", PROTOIDSTR(proto))); } ND_PRINT((ndo," spilen=%u", d.spi_size)); ND_PRINT((ndo," nspi=%u", ntohs(d.num_spi))); ND_PRINT((ndo," spi=")); q = (const uint8_t *)(p + 1); for (i = 0; i < ntohs(d.num_spi); i++) { if (i != 0) ND_PRINT((ndo,",")); if (!rawprint(ndo, (const uint8_t *)q, d.spi_size)) goto trunc; q += d.spi_size; } return q; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_D))); return NULL; } static const u_char * ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID))); ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_VID))); return NULL; } /************************************************************/ /* */ /* IKE v2 - rfc4306 - dissector */ /* */ /************************************************************/ static void ikev2_pay_print(netdissect_options *ndo, const char *payname, int critical) { ND_PRINT((ndo,"%s%s:", payname, critical&0x80 ? "[C]" : "")); } static const u_char * ikev2_gen_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext) { struct isakmp_gen e; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ikev2_pay_print(ndo, NPSTR(tpay), e.critical); ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_t_print(netdissect_options *ndo, int tcount, const struct isakmp_gen *ext, u_int item_len, const u_char *ep) { const struct ikev2_t *p; struct ikev2_t t; uint16_t t_id; const u_char *cp; const char *idstr; const struct attrmap *map; size_t nmap; const u_char *ep2; p = (const struct ikev2_t *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&t, ext, sizeof(t)); ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical); t_id = ntohs(t.t_id); map = NULL; nmap = 0; switch (t.t_type) { case IV2_T_ENCR: idstr = STR_OR_ID(t_id, esp_p_map); map = encr_t_map; nmap = sizeof(encr_t_map)/sizeof(encr_t_map[0]); break; case IV2_T_PRF: idstr = STR_OR_ID(t_id, prf_p_map); break; case IV2_T_INTEG: idstr = STR_OR_ID(t_id, integ_p_map); break; case IV2_T_DH: idstr = STR_OR_ID(t_id, dh_p_map); break; case IV2_T_ESN: idstr = STR_OR_ID(t_id, esn_p_map); break; default: idstr = NULL; break; } if (idstr) ND_PRINT((ndo," #%u type=%s id=%s ", tcount, STR_OR_ID(t.t_type, ikev2_t_type_map), idstr)); else ND_PRINT((ndo," #%u type=%s id=%u ", tcount, STR_OR_ID(t.t_type, ikev2_t_type_map), t.t_id)); cp = (const u_char *)(p + 1); ep2 = (const u_char *)p + item_len; while (cp < ep && cp < ep2) { if (map && nmap) { cp = ikev1_attrmap_print(ndo, cp, ep2, map, nmap); } else cp = ikev1_attr_print(ndo, cp, ep2); if (cp == NULL) goto trunc; } if (ep < ep2) ND_PRINT((ndo,"...")); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_T))); return NULL; } static const u_char * ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_, const struct isakmp_gen *ext, u_int oprop_length, const u_char *ep, int depth) { const struct ikev2_p *p; struct ikev2_p prop; u_int prop_length; const u_char *cp; int i; int tcount; u_char np; struct isakmp_gen e; u_int item_len; p = (const struct ikev2_p *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&prop, ext, sizeof(prop)); ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical); /* * ikev2_sa_print() guarantees that this is >= 4. */ prop_length = oprop_length - 4; ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u", prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t, oprop_length)); cp = (const u_char *)(p + 1); if (prop.spi_size) { if (prop_length < prop.spi_size) goto toolong; ND_PRINT((ndo," spi=")); if (!rawprint(ndo, (const uint8_t *)cp, prop.spi_size)) goto trunc; cp += prop.spi_size; prop_length -= prop.spi_size; } /* * Print the transforms. */ tcount = 0; for (np = ISAKMP_NPTYPE_T; np != 0; np = e.np) { tcount++; ext = (const struct isakmp_gen *)cp; if (prop_length < sizeof(*ext)) goto toolong; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); /* * Since we can't have a payload length of less than 4 bytes, * we need to bail out here if the generic header is nonsensical * or truncated, otherwise we could loop forever processing * zero-length items or otherwise misdissect the packet. */ item_len = ntohs(e.len); if (item_len <= 4) goto trunc; if (prop_length < item_len) goto toolong; ND_TCHECK2(*cp, item_len); depth++; ND_PRINT((ndo,"\n")); for (i = 0; i < depth; i++) ND_PRINT((ndo," ")); ND_PRINT((ndo,"(")); if (np == ISAKMP_NPTYPE_T) { cp = ikev2_t_print(ndo, tcount, ext, item_len, ep); if (cp == NULL) { /* error, already reported */ return NULL; } } else { ND_PRINT((ndo, "%s", NPSTR(np))); cp += item_len; } ND_PRINT((ndo,")")); depth--; prop_length -= item_len; } return cp; toolong: /* * Skip the rest of the proposal. */ cp += prop_length; ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P))); return NULL; } static const u_char * ikev2_sa_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext1, u_int osa_length, const u_char *ep, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth) { const struct isakmp_gen *ext; struct isakmp_gen e; u_int sa_length; const u_char *cp; int i; int pcount; u_char np; u_int item_len; ND_TCHECK(*ext1); UNALIGNED_MEMCPY(&e, ext1, sizeof(e)); ikev2_pay_print(ndo, "sa", e.critical); /* * ikev2_sub0_print() guarantees that this is >= 4. */ osa_length= ntohs(e.len); sa_length = osa_length - 4; ND_PRINT((ndo," len=%d", sa_length)); /* * Print the payloads. */ cp = (const u_char *)(ext1 + 1); pcount = 0; for (np = ISAKMP_NPTYPE_P; np != 0; np = e.np) { pcount++; ext = (const struct isakmp_gen *)cp; if (sa_length < sizeof(*ext)) goto toolong; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); /* * Since we can't have a payload length of less than 4 bytes, * we need to bail out here if the generic header is nonsensical * or truncated, otherwise we could loop forever processing * zero-length items or otherwise misdissect the packet. */ item_len = ntohs(e.len); if (item_len <= 4) goto trunc; if (sa_length < item_len) goto toolong; ND_TCHECK2(*cp, item_len); depth++; ND_PRINT((ndo,"\n")); for (i = 0; i < depth; i++) ND_PRINT((ndo," ")); ND_PRINT((ndo,"(")); if (np == ISAKMP_NPTYPE_P) { cp = ikev2_p_print(ndo, np, pcount, ext, item_len, ep, depth); if (cp == NULL) { /* error, already reported */ return NULL; } } else { ND_PRINT((ndo, "%s", NPSTR(np))); cp += item_len; } ND_PRINT((ndo,")")); depth--; sa_length -= item_len; } return cp; toolong: /* * Skip the rest of the SA. */ cp += sa_length; ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_ke_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct ikev2_ke ke; const struct ikev2_ke *k; k = (const struct ikev2_ke *)ext; ND_TCHECK(*k); UNALIGNED_MEMCPY(&ke, ext, sizeof(ke)); ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical); ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8, STR_OR_ID(ntohs(ke.ke_group), dh_p_map))); if (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) { ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(k + 1), ntohs(ke.h.len) - 8)) goto trunc; } return (const u_char *)ext + ntohs(ke.h.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_ID_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { const struct ikev2_id *idp; struct ikev2_id id; int id_len, idtype_len, i; unsigned int dumpascii, dumphex; const unsigned char *typedata; idp = (const struct ikev2_id *)ext; ND_TCHECK(*idp); UNALIGNED_MEMCPY(&id, ext, sizeof(id)); ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical); id_len = ntohs(id.h.len); ND_PRINT((ndo," len=%d", id_len - 4)); if (2 < ndo->ndo_vflag && 4 < id_len) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), id_len - 4)) goto trunc; } idtype_len =id_len - sizeof(struct ikev2_id); dumpascii = 0; dumphex = 0; typedata = (const unsigned char *)(ext)+sizeof(struct ikev2_id); switch(id.type) { case ID_IPV4_ADDR: ND_PRINT((ndo, " ipv4:")); dumphex=1; break; case ID_FQDN: ND_PRINT((ndo, " fqdn:")); dumpascii=1; break; case ID_RFC822_ADDR: ND_PRINT((ndo, " rfc822:")); dumpascii=1; break; case ID_IPV6_ADDR: ND_PRINT((ndo, " ipv6:")); dumphex=1; break; case ID_DER_ASN1_DN: ND_PRINT((ndo, " dn:")); dumphex=1; break; case ID_DER_ASN1_GN: ND_PRINT((ndo, " gn:")); dumphex=1; break; case ID_KEY_ID: ND_PRINT((ndo, " keyid:")); dumphex=1; break; } if(dumpascii) { ND_TCHECK2(*typedata, idtype_len); for(i=0; i= 4. */ ND_PRINT((ndo," len=%u method=%s", len-4, STR_OR_ID(a.auth_method, v2_auth))); if (len > 4) { if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, " authdata=(")); if (!rawprint(ndo, (const uint8_t *)authdata, len - sizeof(a))) goto trunc; ND_PRINT((ndo, ") ")); } else if (ndo->ndo_vflag) { if (!ike_show_somedata(ndo, authdata, ep)) goto trunc; } } return (const u_char *)ext + len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_nonce_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ikev2_pay_print(ndo, "nonce", e.critical); ND_PRINT((ndo," len=%d", ntohs(e.len) - 4)); if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) { ND_PRINT((ndo," nonce=(")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; ND_PRINT((ndo,") ")); } else if(ndo->ndo_vflag && 4 < ntohs(e.len)) { if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } /* notify payloads */ static const u_char * ikev2_n_print(netdissect_options *ndo, u_char tpay _U_, const struct isakmp_gen *ext, u_int item_len, const u_char *ep, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { const struct ikev2_n *p; struct ikev2_n n; const u_char *cp; u_char showspi, showsomedata; const char *notify_name; uint32_t type; p = (const struct ikev2_n *)ext; ND_TCHECK(*p); UNALIGNED_MEMCPY(&n, ext, sizeof(n)); ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical); showspi = 1; showsomedata=0; notify_name=NULL; ND_PRINT((ndo," prot_id=%s", PROTOIDSTR(n.prot_id))); type = ntohs(n.type); /* notify space is annoying sparse */ switch(type) { case IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD: notify_name = "unsupported_critical_payload"; showspi = 0; break; case IV2_NOTIFY_INVALID_IKE_SPI: notify_name = "invalid_ike_spi"; showspi = 1; break; case IV2_NOTIFY_INVALID_MAJOR_VERSION: notify_name = "invalid_major_version"; showspi = 0; break; case IV2_NOTIFY_INVALID_SYNTAX: notify_name = "invalid_syntax"; showspi = 1; break; case IV2_NOTIFY_INVALID_MESSAGE_ID: notify_name = "invalid_message_id"; showspi = 1; break; case IV2_NOTIFY_INVALID_SPI: notify_name = "invalid_spi"; showspi = 1; break; case IV2_NOTIFY_NO_PROPOSAL_CHOSEN: notify_name = "no_protocol_chosen"; showspi = 1; break; case IV2_NOTIFY_INVALID_KE_PAYLOAD: notify_name = "invalid_ke_payload"; showspi = 1; break; case IV2_NOTIFY_AUTHENTICATION_FAILED: notify_name = "authentication_failed"; showspi = 1; break; case IV2_NOTIFY_SINGLE_PAIR_REQUIRED: notify_name = "single_pair_required"; showspi = 1; break; case IV2_NOTIFY_NO_ADDITIONAL_SAS: notify_name = "no_additional_sas"; showspi = 0; break; case IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE: notify_name = "internal_address_failure"; showspi = 0; break; case IV2_NOTIFY_FAILED_CP_REQUIRED: notify_name = "failed:cp_required"; showspi = 0; break; case IV2_NOTIFY_INVALID_SELECTORS: notify_name = "invalid_selectors"; showspi = 0; break; case IV2_NOTIFY_INITIAL_CONTACT: notify_name = "initial_contact"; showspi = 0; break; case IV2_NOTIFY_SET_WINDOW_SIZE: notify_name = "set_window_size"; showspi = 0; break; case IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE: notify_name = "additional_ts_possible"; showspi = 0; break; case IV2_NOTIFY_IPCOMP_SUPPORTED: notify_name = "ipcomp_supported"; showspi = 0; break; case IV2_NOTIFY_NAT_DETECTION_SOURCE_IP: notify_name = "nat_detection_source_ip"; showspi = 1; break; case IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP: notify_name = "nat_detection_destination_ip"; showspi = 1; break; case IV2_NOTIFY_COOKIE: notify_name = "cookie"; showspi = 1; showsomedata= 1; break; case IV2_NOTIFY_USE_TRANSPORT_MODE: notify_name = "use_transport_mode"; showspi = 0; break; case IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED: notify_name = "http_cert_lookup_supported"; showspi = 0; break; case IV2_NOTIFY_REKEY_SA: notify_name = "rekey_sa"; showspi = 1; break; case IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED: notify_name = "tfc_padding_not_supported"; showspi = 0; break; case IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO: notify_name = "non_first_fragment_also"; showspi = 0; break; default: if (type < 8192) { notify_name="error"; } else if(type < 16384) { notify_name="private-error"; } else if(type < 40960) { notify_name="status"; } else { notify_name="private-status"; } } if(notify_name) { ND_PRINT((ndo," type=%u(%s)", type, notify_name)); } if (showspi && n.spi_size) { ND_PRINT((ndo," spi=")); if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size)) goto trunc; } cp = (const u_char *)(p + 1) + n.spi_size; if (cp < ep) { if (ndo->ndo_vflag > 3 || (showsomedata && ep-cp < 30)) { ND_PRINT((ndo," data=(")); if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp)) goto trunc; ND_PRINT((ndo,")")); } else if (showsomedata) { if (!ike_show_somedata(ndo, cp, ep)) goto trunc; } } return (const u_char *)ext + item_len; trunc: ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N))); return NULL; } static const u_char * ikev2_d_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { return ikev2_gen_print(ndo, tpay, ext); } static const u_char * ikev2_vid_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { struct isakmp_gen e; const u_char *vid; int i, len; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ikev2_pay_print(ndo, NPSTR(tpay), e.critical); ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4)); vid = (const u_char *)(ext+1); len = ntohs(e.len) - 4; ND_TCHECK2(*vid, len); for(i=0; indo_vflag && 4 < len) { /* Print the entire payload in hex */ ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4)) goto trunc; } return (const u_char *)ext + ntohs(e.len); trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_TS_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { return ikev2_gen_print(ndo, tpay, ext); } static const u_char * ikev2_e_print(netdissect_options *ndo, #ifndef HAVE_LIBCRYPTO _U_ #endif struct isakmp *base, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, #ifndef HAVE_LIBCRYPTO _U_ #endif uint32_t phase, #ifndef HAVE_LIBCRYPTO _U_ #endif uint32_t doi, #ifndef HAVE_LIBCRYPTO _U_ #endif uint32_t proto, #ifndef HAVE_LIBCRYPTO _U_ #endif int depth) { struct isakmp_gen e; const u_char *dat; volatile int dlen; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ikev2_pay_print(ndo, NPSTR(tpay), e.critical); dlen = ntohs(e.len)-4; ND_PRINT((ndo," len=%d", dlen)); if (2 < ndo->ndo_vflag && 4 < dlen) { ND_PRINT((ndo," ")); if (!rawprint(ndo, (const uint8_t *)(ext + 1), dlen)) goto trunc; } dat = (const u_char *)(ext+1); ND_TCHECK2(*dat, dlen); #ifdef HAVE_LIBCRYPTO /* try to decypt it! */ if(esp_print_decrypt_buffer_by_ikev2(ndo, base->flags & ISAKMP_FLAG_I, base->i_ck, base->r_ck, dat, dat+dlen)) { ext = (const struct isakmp_gen *)ndo->ndo_packetp; /* got it decrypted, print stuff inside. */ ikev2_sub_print(ndo, base, e.np, ext, ndo->ndo_snapend, phase, doi, proto, depth+1); } #endif /* always return NULL, because E must be at end, and NP refers * to what was inside. */ return NULL; trunc: ND_PRINT((ndo," [|%s]", NPSTR(tpay))); return NULL; } static const u_char * ikev2_cp_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { return ikev2_gen_print(ndo, tpay, ext); } static const u_char * ikev2_eap_print(netdissect_options *ndo, u_char tpay, const struct isakmp_gen *ext, u_int item_len _U_, const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_, uint32_t proto _U_, int depth _U_) { return ikev2_gen_print(ndo, tpay, ext); } static const u_char * ike_sub0_print(netdissect_options *ndo, u_char np, const struct isakmp_gen *ext, const u_char *ep, uint32_t phase, uint32_t doi, uint32_t proto, int depth) { const u_char *cp; struct isakmp_gen e; u_int item_len; cp = (const u_char *)ext; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); /* * Since we can't have a payload length of less than 4 bytes, * we need to bail out here if the generic header is nonsensical * or truncated, otherwise we could loop forever processing * zero-length items or otherwise misdissect the packet. */ item_len = ntohs(e.len); if (item_len <= 4) return NULL; if (NPFUNC(np)) { /* * XXX - what if item_len is too short, or too long, * for this payload type? */ cp = (*npfunc[np])(ndo, np, ext, item_len, ep, phase, doi, proto, depth); } else { ND_PRINT((ndo,"%s", NPSTR(np))); cp += item_len; } return cp; trunc: ND_PRINT((ndo," [|isakmp]")); return NULL; } static const u_char * ikev1_sub_print(netdissect_options *ndo, u_char np, const struct isakmp_gen *ext, const u_char *ep, uint32_t phase, uint32_t doi, uint32_t proto, int depth) { const u_char *cp; int i; struct isakmp_gen e; cp = (const u_char *)ext; while (np) { ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_TCHECK2(*ext, ntohs(e.len)); depth++; ND_PRINT((ndo,"\n")); for (i = 0; i < depth; i++) ND_PRINT((ndo," ")); ND_PRINT((ndo,"(")); cp = ike_sub0_print(ndo, np, ext, ep, phase, doi, proto, depth); ND_PRINT((ndo,")")); depth--; if (cp == NULL) { /* Zero-length subitem */ return NULL; } np = e.np; ext = (const struct isakmp_gen *)cp; } return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(np))); return NULL; } static char * numstr(int x) { static char buf[20]; snprintf(buf, sizeof(buf), "#%d", x); return buf; } static void ikev1_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2, struct isakmp *base) { const struct isakmp *p; const u_char *ep; u_char np; int i; int phase; p = (const struct isakmp *)bp; ep = ndo->ndo_snapend; phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2; if (phase == 1) ND_PRINT((ndo," phase %d", phase)); else ND_PRINT((ndo," phase %d/others", phase)); i = cookie_find(&base->i_ck); if (i < 0) { if (iszero((const u_char *)&base->r_ck, sizeof(base->r_ck))) { /* the first packet */ ND_PRINT((ndo," I")); if (bp2) cookie_record(&base->i_ck, bp2); } else ND_PRINT((ndo," ?")); } else { if (bp2 && cookie_isinitiator(i, bp2)) ND_PRINT((ndo," I")); else if (bp2 && cookie_isresponder(i, bp2)) ND_PRINT((ndo," R")); else ND_PRINT((ndo," ?")); } ND_PRINT((ndo," %s", ETYPESTR(base->etype))); if (base->flags) { ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "", base->flags & ISAKMP_FLAG_C ? "C" : "")); } if (ndo->ndo_vflag) { const struct isakmp_gen *ext; ND_PRINT((ndo,":")); /* regardless of phase... */ if (base->flags & ISAKMP_FLAG_E) { /* * encrypted, nothing we can do right now. * we hope to decrypt the packet in the future... */ ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np))); goto done; } CHECKLEN(p + 1, base->np); np = base->np; ext = (const struct isakmp_gen *)(p + 1); ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0); } done: if (ndo->ndo_vflag) { if (ntohl(base->len) != length) { ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)", (uint32_t)ntohl(base->len), length)); } } } static const u_char * ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base, u_char np, const struct isakmp_gen *ext, const u_char *ep, uint32_t phase, uint32_t doi, uint32_t proto, int depth) { const u_char *cp; struct isakmp_gen e; u_int item_len; cp = (const u_char *)ext; ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); /* * Since we can't have a payload length of less than 4 bytes, * we need to bail out here if the generic header is nonsensical * or truncated, otherwise we could loop forever processing * zero-length items or otherwise misdissect the packet. */ item_len = ntohs(e.len); if (item_len <= 4) return NULL; if (np == ISAKMP_NPTYPE_v2E) { cp = ikev2_e_print(ndo, base, np, ext, item_len, ep, phase, doi, proto, depth); } else if (NPFUNC(np)) { /* * XXX - what if item_len is too short, or too long, * for this payload type? */ cp = (*npfunc[np])(ndo, np, ext, item_len, ep, phase, doi, proto, depth); } else { ND_PRINT((ndo,"%s", NPSTR(np))); cp += item_len; } return cp; trunc: ND_PRINT((ndo," [|isakmp]")); return NULL; } static const u_char * ikev2_sub_print(netdissect_options *ndo, struct isakmp *base, u_char np, const struct isakmp_gen *ext, const u_char *ep, uint32_t phase, uint32_t doi, uint32_t proto, int depth) { const u_char *cp; int i; struct isakmp_gen e; cp = (const u_char *)ext; while (np) { ND_TCHECK(*ext); UNALIGNED_MEMCPY(&e, ext, sizeof(e)); ND_TCHECK2(*ext, ntohs(e.len)); depth++; ND_PRINT((ndo,"\n")); for (i = 0; i < depth; i++) ND_PRINT((ndo," ")); ND_PRINT((ndo,"(")); cp = ikev2_sub0_print(ndo, base, np, ext, ep, phase, doi, proto, depth); ND_PRINT((ndo,")")); depth--; if (cp == NULL) { /* Zero-length subitem */ return NULL; } np = e.np; ext = (const struct isakmp_gen *)cp; } return cp; trunc: ND_PRINT((ndo," [|%s]", NPSTR(np))); return NULL; } static void ikev2_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2 _U_, struct isakmp *base) { const struct isakmp *p; const u_char *ep; u_char np; int phase; p = (const struct isakmp *)bp; ep = ndo->ndo_snapend; phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2; if (phase == 1) ND_PRINT((ndo, " parent_sa")); else ND_PRINT((ndo, " child_sa ")); ND_PRINT((ndo, " %s", ETYPESTR(base->etype))); if (base->flags) { ND_PRINT((ndo, "[%s%s%s]", base->flags & ISAKMP_FLAG_I ? "I" : "", base->flags & ISAKMP_FLAG_V ? "V" : "", base->flags & ISAKMP_FLAG_R ? "R" : "")); } if (ndo->ndo_vflag) { const struct isakmp_gen *ext; ND_PRINT((ndo, ":")); /* regardless of phase... */ if (base->flags & ISAKMP_FLAG_E) { /* * encrypted, nothing we can do right now. * we hope to decrypt the packet in the future... */ ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np))); goto done; } CHECKLEN(p + 1, base->np) np = base->np; ext = (const struct isakmp_gen *)(p + 1); ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0); } done: if (ndo->ndo_vflag) { if (ntohl(base->len) != length) { ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)", (uint32_t)ntohl(base->len), length)); } } } void isakmp_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2) { const struct isakmp *p; struct isakmp base; const u_char *ep; int major, minor; #ifdef HAVE_LIBCRYPTO /* initialize SAs */ if (ndo->ndo_sa_list_head == NULL) { if (ndo->ndo_espsecret) esp_print_decodesecret(ndo); } #endif p = (const struct isakmp *)bp; ep = ndo->ndo_snapend; if ((const struct isakmp *)ep < p + 1) { ND_PRINT((ndo,"[|isakmp]")); return; } UNALIGNED_MEMCPY(&base, p, sizeof(base)); ND_PRINT((ndo,"isakmp")); major = (base.vers & ISAKMP_VERS_MAJOR) >> ISAKMP_VERS_MAJOR_SHIFT; minor = (base.vers & ISAKMP_VERS_MINOR) >> ISAKMP_VERS_MINOR_SHIFT; if (ndo->ndo_vflag) { ND_PRINT((ndo," %d.%d", major, minor)); } if (ndo->ndo_vflag) { ND_PRINT((ndo," msgid ")); hexprint(ndo, (const uint8_t *)&base.msgid, sizeof(base.msgid)); } if (1 < ndo->ndo_vflag) { ND_PRINT((ndo," cookie ")); hexprint(ndo, (const uint8_t *)&base.i_ck, sizeof(base.i_ck)); ND_PRINT((ndo,"->")); hexprint(ndo, (const uint8_t *)&base.r_ck, sizeof(base.r_ck)); } ND_PRINT((ndo,":")); switch(major) { case IKEv1_MAJOR_VERSION: ikev1_print(ndo, bp, length, bp2, &base); break; case IKEv2_MAJOR_VERSION: ikev2_print(ndo, bp, length, bp2, &base); break; } } void isakmp_rfc3948_print(netdissect_options *ndo, const u_char *bp, u_int length, const u_char *bp2) { ND_TCHECK(bp[0]); if(length == 1 && bp[0]==0xff) { ND_PRINT((ndo, "isakmp-nat-keep-alive")); return; } if(length < 4) { goto trunc; } ND_TCHECK(bp[3]); /* * see if this is an IKE packet */ if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) { ND_PRINT((ndo, "NONESP-encap: ")); isakmp_print(ndo, bp+4, length-4, bp2); return; } /* must be an ESP packet */ { int nh, enh, padlen; int advance; ND_PRINT((ndo, "UDP-encap: ")); advance = esp_print(ndo, bp, length, bp2, &enh, &padlen); if(advance <= 0) return; bp += advance; length -= advance + padlen; nh = enh & 0xff; ip_print_inner(ndo, bp, length, nh, bp2); return; } trunc: ND_PRINT((ndo,"[|isakmp]")); return; } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-juniper.c =================================================================== --- vendor/tcpdump/dist/print-juniper.c (revision 353143) +++ vendor/tcpdump/dist/print-juniper.c (revision 353144) @@ -1,1508 +1,1513 @@ /* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */ /* * 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 Hannes Gredler (hannes@gredler.at) */ /* \summary: DLT_JUNIPER_* printers */ #ifndef lint #else __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp "); #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.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_BPF_IIF 0x4 /* IIF is valid */ #define JUNIPER_BPF_FILTER 0x40 /* BPF filtering is supported */ #define JUNIPER_BPF_EXT 0x80 /* extensions present */ #define JUNIPER_MGC_NUMBER 0x4d4743 /* = "MGC" */ #define JUNIPER_LSQ_COOKIE_RE (1 << 3) #define JUNIPER_LSQ_COOKIE_DIR (1 << 2) #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 AS_PIC_COOKIE_LEN 8 #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 const 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 const struct tok juniper_direction_values[] = { { JUNIPER_BPF_IN, "In"}, { JUNIPER_BPF_OUT, "Out"}, { 0, NULL} }; /* codepoints for encoding extensions to a .pcap file */ enum { JUNIPER_EXT_TLV_IFD_IDX = 1, JUNIPER_EXT_TLV_IFD_NAME = 2, JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3, JUNIPER_EXT_TLV_IFL_IDX = 4, JUNIPER_EXT_TLV_IFL_UNIT = 5, JUNIPER_EXT_TLV_IFL_ENCAPS = 6, JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7, JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8 }; /* 1 byte type and 1-byte length */ #define JUNIPER_EXT_TLV_OVERHEAD 2U static const struct tok jnx_ext_tlv_values[] = { { JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" }, { JUNIPER_EXT_TLV_IFD_NAME,"Device Interface Name" }, { JUNIPER_EXT_TLV_IFD_MEDIATYPE, "Device Media Type" }, { JUNIPER_EXT_TLV_IFL_IDX, "Logical Interface Index" }, { JUNIPER_EXT_TLV_IFL_UNIT,"Logical Unit Number" }, { JUNIPER_EXT_TLV_IFL_ENCAPS, "Logical Interface Encapsulation" }, { JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE, "TTP derived Device Media Type" }, { JUNIPER_EXT_TLV_TTP_IFL_ENCAPS, "TTP derived Logical Interface Encapsulation" }, { 0, NULL } }; static const struct tok jnx_flag_values[] = { { JUNIPER_BPF_EXT, "Ext" }, { JUNIPER_BPF_FILTER, "Filter" }, { JUNIPER_BPF_IIF, "IIF" }, { JUNIPER_BPF_NO_L2, "no-L2" }, { JUNIPER_BPF_PKT_IN, "In" }, { 0, NULL } }; #define JUNIPER_IFML_ETHER 1 #define JUNIPER_IFML_FDDI 2 #define JUNIPER_IFML_TOKENRING 3 #define JUNIPER_IFML_PPP 4 #define JUNIPER_IFML_FRAMERELAY 5 #define JUNIPER_IFML_CISCOHDLC 6 #define JUNIPER_IFML_SMDSDXI 7 #define JUNIPER_IFML_ATMPVC 8 #define JUNIPER_IFML_PPP_CCC 9 #define JUNIPER_IFML_FRAMERELAY_CCC 10 #define JUNIPER_IFML_IPIP 11 #define JUNIPER_IFML_GRE 12 #define JUNIPER_IFML_PIM 13 #define JUNIPER_IFML_PIMD 14 #define JUNIPER_IFML_CISCOHDLC_CCC 15 #define JUNIPER_IFML_VLAN_CCC 16 #define JUNIPER_IFML_MLPPP 17 #define JUNIPER_IFML_MLFR 18 #define JUNIPER_IFML_ML 19 #define JUNIPER_IFML_LSI 20 #define JUNIPER_IFML_DFE 21 #define JUNIPER_IFML_ATM_CELLRELAY_CCC 22 #define JUNIPER_IFML_CRYPTO 23 #define JUNIPER_IFML_GGSN 24 #define JUNIPER_IFML_LSI_PPP 25 #define JUNIPER_IFML_LSI_CISCOHDLC 26 #define JUNIPER_IFML_PPP_TCC 27 #define JUNIPER_IFML_FRAMERELAY_TCC 28 #define JUNIPER_IFML_CISCOHDLC_TCC 29 #define JUNIPER_IFML_ETHERNET_CCC 30 #define JUNIPER_IFML_VT 31 #define JUNIPER_IFML_EXTENDED_VLAN_CCC 32 #define JUNIPER_IFML_ETHER_OVER_ATM 33 #define JUNIPER_IFML_MONITOR 34 #define JUNIPER_IFML_ETHERNET_TCC 35 #define JUNIPER_IFML_VLAN_TCC 36 #define JUNIPER_IFML_EXTENDED_VLAN_TCC 37 #define JUNIPER_IFML_CONTROLLER 38 #define JUNIPER_IFML_MFR 39 #define JUNIPER_IFML_LS 40 #define JUNIPER_IFML_ETHERNET_VPLS 41 #define JUNIPER_IFML_ETHERNET_VLAN_VPLS 42 #define JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS 43 #define JUNIPER_IFML_LT 44 #define JUNIPER_IFML_SERVICES 45 #define JUNIPER_IFML_ETHER_VPLS_OVER_ATM 46 #define JUNIPER_IFML_FR_PORT_CCC 47 #define JUNIPER_IFML_FRAMERELAY_EXT_CCC 48 #define JUNIPER_IFML_FRAMERELAY_EXT_TCC 49 #define JUNIPER_IFML_FRAMERELAY_FLEX 50 #define JUNIPER_IFML_GGSNI 51 #define JUNIPER_IFML_ETHERNET_FLEX 52 #define JUNIPER_IFML_COLLECTOR 53 #define JUNIPER_IFML_AGGREGATOR 54 #define JUNIPER_IFML_LAPD 55 #define JUNIPER_IFML_PPPOE 56 #define JUNIPER_IFML_PPP_SUBORDINATE 57 #define JUNIPER_IFML_CISCOHDLC_SUBORDINATE 58 #define JUNIPER_IFML_DFC 59 #define JUNIPER_IFML_PICPEER 60 static const struct tok juniper_ifmt_values[] = { { JUNIPER_IFML_ETHER, "Ethernet" }, { JUNIPER_IFML_FDDI, "FDDI" }, { JUNIPER_IFML_TOKENRING, "Token-Ring" }, { JUNIPER_IFML_PPP, "PPP" }, { JUNIPER_IFML_PPP_SUBORDINATE, "PPP-Subordinate" }, { JUNIPER_IFML_FRAMERELAY, "Frame-Relay" }, { JUNIPER_IFML_CISCOHDLC, "Cisco-HDLC" }, { JUNIPER_IFML_SMDSDXI, "SMDS-DXI" }, { JUNIPER_IFML_ATMPVC, "ATM-PVC" }, { JUNIPER_IFML_PPP_CCC, "PPP-CCC" }, { JUNIPER_IFML_FRAMERELAY_CCC, "Frame-Relay-CCC" }, { JUNIPER_IFML_FRAMERELAY_EXT_CCC, "Extended FR-CCC" }, { JUNIPER_IFML_IPIP, "IP-over-IP" }, { JUNIPER_IFML_GRE, "GRE" }, { JUNIPER_IFML_PIM, "PIM-Encapsulator" }, { JUNIPER_IFML_PIMD, "PIM-Decapsulator" }, { JUNIPER_IFML_CISCOHDLC_CCC, "Cisco-HDLC-CCC" }, { JUNIPER_IFML_VLAN_CCC, "VLAN-CCC" }, { JUNIPER_IFML_EXTENDED_VLAN_CCC, "Extended-VLAN-CCC" }, { JUNIPER_IFML_MLPPP, "Multilink-PPP" }, { JUNIPER_IFML_MLFR, "Multilink-FR" }, { JUNIPER_IFML_MFR, "Multilink-FR-UNI-NNI" }, { JUNIPER_IFML_ML, "Multilink" }, { JUNIPER_IFML_LS, "LinkService" }, { JUNIPER_IFML_LSI, "LSI" }, { JUNIPER_IFML_ATM_CELLRELAY_CCC, "ATM-CCC-Cell-Relay" }, { JUNIPER_IFML_CRYPTO, "IPSEC-over-IP" }, { JUNIPER_IFML_GGSN, "GGSN" }, { JUNIPER_IFML_PPP_TCC, "PPP-TCC" }, { JUNIPER_IFML_FRAMERELAY_TCC, "Frame-Relay-TCC" }, { JUNIPER_IFML_FRAMERELAY_EXT_TCC, "Extended FR-TCC" }, { JUNIPER_IFML_CISCOHDLC_TCC, "Cisco-HDLC-TCC" }, { JUNIPER_IFML_ETHERNET_CCC, "Ethernet-CCC" }, { JUNIPER_IFML_VT, "VPN-Loopback-tunnel" }, { JUNIPER_IFML_ETHER_OVER_ATM, "Ethernet-over-ATM" }, { JUNIPER_IFML_ETHER_VPLS_OVER_ATM, "Ethernet-VPLS-over-ATM" }, { JUNIPER_IFML_MONITOR, "Monitor" }, { JUNIPER_IFML_ETHERNET_TCC, "Ethernet-TCC" }, { JUNIPER_IFML_VLAN_TCC, "VLAN-TCC" }, { JUNIPER_IFML_EXTENDED_VLAN_TCC, "Extended-VLAN-TCC" }, { JUNIPER_IFML_CONTROLLER, "Controller" }, { JUNIPER_IFML_ETHERNET_VPLS, "VPLS" }, { JUNIPER_IFML_ETHERNET_VLAN_VPLS, "VLAN-VPLS" }, { JUNIPER_IFML_ETHERNET_EXTENDED_VLAN_VPLS, "Extended-VLAN-VPLS" }, { JUNIPER_IFML_LT, "Logical-tunnel" }, { JUNIPER_IFML_SERVICES, "General-Services" }, { JUNIPER_IFML_PPPOE, "PPPoE" }, { JUNIPER_IFML_ETHERNET_FLEX, "Flexible-Ethernet-Services" }, { JUNIPER_IFML_FRAMERELAY_FLEX, "Flexible-FrameRelay" }, { JUNIPER_IFML_COLLECTOR, "Flow-collection" }, { JUNIPER_IFML_PICPEER, "PIC Peer" }, { JUNIPER_IFML_DFC, "Dynamic-Flow-Capture" }, {0, NULL} }; #define JUNIPER_IFLE_ATM_SNAP 2 #define JUNIPER_IFLE_ATM_NLPID 3 #define JUNIPER_IFLE_ATM_VCMUX 4 #define JUNIPER_IFLE_ATM_LLC 5 #define JUNIPER_IFLE_ATM_PPP_VCMUX 6 #define JUNIPER_IFLE_ATM_PPP_LLC 7 #define JUNIPER_IFLE_ATM_PPP_FUNI 8 #define JUNIPER_IFLE_ATM_CCC 9 #define JUNIPER_IFLE_FR_NLPID 10 #define JUNIPER_IFLE_FR_SNAP 11 #define JUNIPER_IFLE_FR_PPP 12 #define JUNIPER_IFLE_FR_CCC 13 #define JUNIPER_IFLE_ENET2 14 #define JUNIPER_IFLE_IEEE8023_SNAP 15 #define JUNIPER_IFLE_IEEE8023_LLC 16 #define JUNIPER_IFLE_PPP 17 #define JUNIPER_IFLE_CISCOHDLC 18 #define JUNIPER_IFLE_PPP_CCC 19 #define JUNIPER_IFLE_IPIP_NULL 20 #define JUNIPER_IFLE_PIM_NULL 21 #define JUNIPER_IFLE_GRE_NULL 22 #define JUNIPER_IFLE_GRE_PPP 23 #define JUNIPER_IFLE_PIMD_DECAPS 24 #define JUNIPER_IFLE_CISCOHDLC_CCC 25 #define JUNIPER_IFLE_ATM_CISCO_NLPID 26 #define JUNIPER_IFLE_VLAN_CCC 27 #define JUNIPER_IFLE_MLPPP 28 #define JUNIPER_IFLE_MLFR 29 #define JUNIPER_IFLE_LSI_NULL 30 #define JUNIPER_IFLE_AGGREGATE_UNUSED 31 #define JUNIPER_IFLE_ATM_CELLRELAY_CCC 32 #define JUNIPER_IFLE_CRYPTO 33 #define JUNIPER_IFLE_GGSN 34 #define JUNIPER_IFLE_ATM_TCC 35 #define JUNIPER_IFLE_FR_TCC 36 #define JUNIPER_IFLE_PPP_TCC 37 #define JUNIPER_IFLE_CISCOHDLC_TCC 38 #define JUNIPER_IFLE_ETHERNET_CCC 39 #define JUNIPER_IFLE_VT 40 #define JUNIPER_IFLE_ATM_EOA_LLC 41 #define JUNIPER_IFLE_EXTENDED_VLAN_CCC 42 #define JUNIPER_IFLE_ATM_SNAP_TCC 43 #define JUNIPER_IFLE_MONITOR 44 #define JUNIPER_IFLE_ETHERNET_TCC 45 #define JUNIPER_IFLE_VLAN_TCC 46 #define JUNIPER_IFLE_EXTENDED_VLAN_TCC 47 #define JUNIPER_IFLE_MFR 48 #define JUNIPER_IFLE_ETHERNET_VPLS 49 #define JUNIPER_IFLE_ETHERNET_VLAN_VPLS 50 #define JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS 51 #define JUNIPER_IFLE_SERVICES 52 #define JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC 53 #define JUNIPER_IFLE_FR_PORT_CCC 54 #define JUNIPER_IFLE_ATM_MLPPP_LLC 55 #define JUNIPER_IFLE_ATM_EOA_CCC 56 #define JUNIPER_IFLE_LT_VLAN 57 #define JUNIPER_IFLE_COLLECTOR 58 #define JUNIPER_IFLE_AGGREGATOR 59 #define JUNIPER_IFLE_LAPD 60 #define JUNIPER_IFLE_ATM_PPPOE_LLC 61 #define JUNIPER_IFLE_ETHERNET_PPPOE 62 #define JUNIPER_IFLE_PPPOE 63 #define JUNIPER_IFLE_PPP_SUBORDINATE 64 #define JUNIPER_IFLE_CISCOHDLC_SUBORDINATE 65 #define JUNIPER_IFLE_DFC 66 #define JUNIPER_IFLE_PICPEER 67 static const struct tok juniper_ifle_values[] = { { JUNIPER_IFLE_AGGREGATOR, "Aggregator" }, { JUNIPER_IFLE_ATM_CCC, "CCC over ATM" }, { JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" }, { JUNIPER_IFLE_ATM_CISCO_NLPID, "CISCO compatible NLPID" }, { JUNIPER_IFLE_ATM_EOA_CCC, "Ethernet over ATM CCC" }, { JUNIPER_IFLE_ATM_EOA_LLC, "Ethernet over ATM LLC" }, { JUNIPER_IFLE_ATM_ETHER_VPLS_ATM_LLC, "Ethernet VPLS over ATM LLC" }, { JUNIPER_IFLE_ATM_LLC, "ATM LLC" }, { JUNIPER_IFLE_ATM_MLPPP_LLC, "MLPPP over ATM LLC" }, { JUNIPER_IFLE_ATM_NLPID, "ATM NLPID" }, { JUNIPER_IFLE_ATM_PPPOE_LLC, "PPPoE over ATM LLC" }, { JUNIPER_IFLE_ATM_PPP_FUNI, "PPP over FUNI" }, { JUNIPER_IFLE_ATM_PPP_LLC, "PPP over ATM LLC" }, { JUNIPER_IFLE_ATM_PPP_VCMUX, "PPP over ATM VCMUX" }, { JUNIPER_IFLE_ATM_SNAP, "ATM SNAP" }, { JUNIPER_IFLE_ATM_SNAP_TCC, "ATM SNAP TCC" }, { JUNIPER_IFLE_ATM_TCC, "ATM VCMUX TCC" }, { JUNIPER_IFLE_ATM_VCMUX, "ATM VCMUX" }, { JUNIPER_IFLE_CISCOHDLC, "C-HDLC" }, { JUNIPER_IFLE_CISCOHDLC_CCC, "C-HDLC CCC" }, { JUNIPER_IFLE_CISCOHDLC_SUBORDINATE, "C-HDLC via dialer" }, { JUNIPER_IFLE_CISCOHDLC_TCC, "C-HDLC TCC" }, { JUNIPER_IFLE_COLLECTOR, "Collector" }, { JUNIPER_IFLE_CRYPTO, "Crypto" }, { JUNIPER_IFLE_ENET2, "Ethernet" }, { JUNIPER_IFLE_ETHERNET_CCC, "Ethernet CCC" }, { JUNIPER_IFLE_ETHERNET_EXTENDED_VLAN_VPLS, "Extended VLAN VPLS" }, { JUNIPER_IFLE_ETHERNET_PPPOE, "PPPoE over Ethernet" }, { JUNIPER_IFLE_ETHERNET_TCC, "Ethernet TCC" }, { JUNIPER_IFLE_ETHERNET_VLAN_VPLS, "VLAN VPLS" }, { JUNIPER_IFLE_ETHERNET_VPLS, "VPLS" }, { JUNIPER_IFLE_EXTENDED_VLAN_CCC, "Extended VLAN CCC" }, { JUNIPER_IFLE_EXTENDED_VLAN_TCC, "Extended VLAN TCC" }, { JUNIPER_IFLE_FR_CCC, "FR CCC" }, { JUNIPER_IFLE_FR_NLPID, "FR NLPID" }, { JUNIPER_IFLE_FR_PORT_CCC, "FR CCC" }, { JUNIPER_IFLE_FR_PPP, "FR PPP" }, { JUNIPER_IFLE_FR_SNAP, "FR SNAP" }, { JUNIPER_IFLE_FR_TCC, "FR TCC" }, { JUNIPER_IFLE_GGSN, "GGSN" }, { JUNIPER_IFLE_GRE_NULL, "GRE NULL" }, { JUNIPER_IFLE_GRE_PPP, "PPP over GRE" }, { JUNIPER_IFLE_IPIP_NULL, "IPIP" }, { JUNIPER_IFLE_LAPD, "LAPD" }, { JUNIPER_IFLE_LSI_NULL, "LSI Null" }, { JUNIPER_IFLE_LT_VLAN, "LT VLAN" }, { JUNIPER_IFLE_MFR, "MFR" }, { JUNIPER_IFLE_MLFR, "MLFR" }, { JUNIPER_IFLE_MLPPP, "MLPPP" }, { JUNIPER_IFLE_MONITOR, "Monitor" }, { JUNIPER_IFLE_PIMD_DECAPS, "PIMd" }, { JUNIPER_IFLE_PIM_NULL, "PIM Null" }, { JUNIPER_IFLE_PPP, "PPP" }, { JUNIPER_IFLE_PPPOE, "PPPoE" }, { JUNIPER_IFLE_PPP_CCC, "PPP CCC" }, { JUNIPER_IFLE_PPP_SUBORDINATE, "" }, { JUNIPER_IFLE_PPP_TCC, "PPP TCC" }, { JUNIPER_IFLE_SERVICES, "General Services" }, { JUNIPER_IFLE_VLAN_CCC, "VLAN CCC" }, { JUNIPER_IFLE_VLAN_TCC, "VLAN TCC" }, { JUNIPER_IFLE_VT, "VT" }, {0, NULL} }; struct juniper_cookie_table_t { uint32_t pictype; /* pic type */ uint8_t cookie_len; /* cookie len */ const char *s; /* pic name */ }; static const 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 { uint32_t length; uint32_t caplen; uint32_t pictype; uint8_t direction; uint8_t header_len; uint8_t cookie_len; uint8_t cookie_type; uint8_t cookie[8]; uint8_t bundle; uint16_t proto; uint8_t flags; }; #define LS_COOKIE_ID 0x54 #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 #define MFR_BE_MASK 0xc0 static const struct tok juniper_protocol_values[] = { { JUNIPER_PROTO_NULL, "Null" }, { JUNIPER_PROTO_IPV4, "IPv4" }, { JUNIPER_PROTO_IPV6, "IPv6" }, { 0, NULL} }; static int ip_heuristic_guess(netdissect_options *, register const u_char *, u_int); static int juniper_ppp_heuristic_guess(netdissect_options *, register const u_char *, u_int); static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *); #ifdef DLT_JUNIPER_GGSN u_int juniper_ggsn_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; struct juniper_ggsn_header { uint8_t svc_id; uint8_t flags_len; uint8_t proto; uint8_t flags; uint8_t vlan_id[2]; uint8_t res[2]; }; const struct juniper_ggsn_header *gh; l2info.pictype = DLT_JUNIPER_GGSN; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; gh = (struct juniper_ggsn_header *)&l2info.cookie; ND_TCHECK(*gh); if (ndo->ndo_eflag) { ND_PRINT((ndo, "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(ndo, p, l2info.length); break; case JUNIPER_PROTO_IPV6: ip6_print(ndo, p, l2info.length); break; default: if (!ndo->ndo_eflag) ND_PRINT((ndo, "unknown GGSN proto (%u)", gh->proto)); } return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_services]")); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_ES u_int juniper_es_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; struct juniper_ipsec_header { uint8_t sa_index[2]; uint8_t ttl; uint8_t type; uint8_t spi[4]; uint8_t src_ip[4]; uint8_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(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; ih = (const struct juniper_ipsec_header *)p; ND_TCHECK(*ih); 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; break; default: ND_PRINT((ndo, "ES Invalid type %u, length %u", ih->type, l2info.length)); return l2info.header_len; } l2info.length-=rewrite_len; p+=rewrite_len; if (ndo->ndo_eflag) { if (!es_type_bundle) { ND_PRINT((ndo, "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(ndo, &ih->src_ip), ipaddr_string(ndo, &ih->dst_ip), l2info.length)); } else { ND_PRINT((ndo, "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(ndo, p, l2info.length); return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_services]")); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_MONITOR u_int juniper_monitor_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; struct juniper_monitor_header { uint8_t pkt_type; uint8_t padding; uint8_t iif[2]; uint8_t service_id[4]; }; const struct juniper_monitor_header *mh; l2info.pictype = DLT_JUNIPER_MONITOR; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; mh = (const struct juniper_monitor_header *)p; ND_TCHECK(*mh); if (ndo->ndo_eflag) ND_PRINT((ndo, "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 (ndo, p, l2info.length); return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_services]")); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_SERVICES u_int juniper_services_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; struct juniper_services_header { uint8_t svc_id; uint8_t flags_len; uint8_t svc_set_id[2]; uint8_t dir_iif[4]; }; const struct juniper_services_header *sh; l2info.pictype = DLT_JUNIPER_SERVICES; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; sh = (const struct juniper_services_header *)p; ND_TCHECK(*sh); if (ndo->ndo_eflag) ND_PRINT((ndo, "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 (ndo, p, l2info.length); return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_services]")); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_PPPOE u_int juniper_pppoe_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_PPPOE; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* this DLT contains nothing but raw ethernet frames */ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_ETHER u_int juniper_ether_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_ETHER; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* this DLT contains nothing but raw Ethernet frames */ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_PPP u_int juniper_ppp_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_PPP; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* this DLT contains nothing but raw ppp frames */ ppp_print(ndo, p, l2info.length); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_FRELAY u_int juniper_frelay_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_FRELAY; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* this DLT contains nothing but raw frame-relay frames */ fr_print(ndo, p, l2info.length); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_CHDLC u_int juniper_chdlc_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_CHDLC; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* this DLT contains nothing but raw c-hdlc frames */ chdlc_print(ndo, p, l2info.length); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_PPPOE_ATM u_int juniper_pppoe_atm_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; uint16_t extracted_ethertype; l2info.pictype = DLT_JUNIPER_PPPOE_ATM; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; ND_TCHECK2(p[0], 2); extracted_ethertype = EXTRACT_16BITS(p); /* this DLT contains nothing but raw PPPoE frames, * prepended with a type field*/ if (ethertype_print(ndo, extracted_ethertype, p+ETHERTYPE_LEN, l2info.length-ETHERTYPE_LEN, l2info.caplen-ETHERTYPE_LEN, NULL, NULL) == 0) /* ether_type not known, probably it wasn't one */ ND_PRINT((ndo, "unknown ethertype 0x%04x", extracted_ethertype)); return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_pppoe_atm]")); return l2info.header_len; } #endif #ifdef DLT_JUNIPER_MLPPP u_int juniper_mlppp_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_MLPPP; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; /* suppress Bundle-ID if frame was captured on a child-link * best indicator if the cookie looks like a proto */ if (ndo->ndo_eflag && EXTRACT_16BITS(&l2info.cookie) != PPP_OSI && EXTRACT_16BITS(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL)) ND_PRINT((ndo, "Bundle-ID %u: ", l2info.bundle)); p+=l2info.header_len; /* first try the LSQ protos */ switch(l2info.proto) { case JUNIPER_LSQ_L3_PROTO_IPV4: /* IP traffic going to the RE would not have a cookie * -> this must be incoming IS-IS over PPP */ if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR)) ppp_print(ndo, p, l2info.length); else ip_print(ndo, p, l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_IPV6: ip6_print(ndo, p,l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_MPLS: mpls_print(ndo, p, l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_ISO: isoclns_print(ndo, p, l2info.length); return l2info.header_len; default: break; } /* zero length cookie ? */ switch (EXTRACT_16BITS(&l2info.cookie)) { case PPP_OSI: ppp_print(ndo, p - 2, l2info.length + 2); break; case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */ default: ppp_print(ndo, p, l2info.length); break; } return l2info.header_len; } #endif #ifdef DLT_JUNIPER_MFR u_int juniper_mfr_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; memset(&l2info, 0, sizeof(l2info)); l2info.pictype = DLT_JUNIPER_MFR; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* child-link ? */ if (l2info.cookie_len == 0) { mfr_print(ndo, p, l2info.length); return l2info.header_len; } /* first try the LSQ protos */ if (l2info.cookie_len == AS_PIC_COOKIE_LEN) { switch(l2info.proto) { case JUNIPER_LSQ_L3_PROTO_IPV4: ip_print(ndo, p, l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_IPV6: ip6_print(ndo, p,l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_MPLS: mpls_print(ndo, p, l2info.length); return l2info.header_len; case JUNIPER_LSQ_L3_PROTO_ISO: isoclns_print(ndo, p, l2info.length); return l2info.header_len; default: break; } return l2info.header_len; } /* suppress Bundle-ID if frame was captured on a child-link */ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1) ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle)); switch (l2info.proto) { case (LLCSAP_ISONS<<8 | LLCSAP_ISONS): isoclns_print(ndo, p + 1, l2info.length - 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(ndo, p - 1, l2info.length + 1); break; default: ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length)); } return l2info.header_len; } #endif #ifdef DLT_JUNIPER_MLFR u_int juniper_mlfr_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_MLFR; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; /* suppress Bundle-ID if frame was captured on a child-link */ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1) ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle)); switch (l2info.proto) { case (LLC_UI): case (LLC_UI<<8): isoclns_print(ndo, p, l2info.length); 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(ndo, p - 1, l2info.length + 1); break; default: ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length)); } return l2info.header_len; } #endif /* * ATM1 PIC cookie format * * +-----+-------------------------+-------------------------------+ * |fmtid| vc index | channel ID | * +-----+-------------------------+-------------------------------+ */ #ifdef DLT_JUNIPER_ATM1 u_int juniper_atm1_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { int llc_hdrlen; struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_ATM1; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; if (l2info.cookie[0] == 0x80) { /* OAM cell ? */ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC); return l2info.header_len; } ND_TCHECK2(p[0], 3); if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); if (llc_hdrlen > 0) return l2info.header_len; } if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ isoclns_print(ndo, p + 1, l2info.length - 1); /* FIXME check if frame was recognized */ return l2info.header_len; } if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */ return l2info.header_len; return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_atm1]")); return l2info.header_len; } #endif /* * ATM2 PIC cookie format * * +-------------------------------+---------+---+-----+-----------+ * | channel ID | reserv |AAL| CCRQ| gap cnt | * +-------------------------------+---------+---+-----+-----------+ */ #ifdef DLT_JUNIPER_ATM2 u_int juniper_atm2_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p) { int llc_hdrlen; struct juniper_l2info_t l2info; l2info.pictype = DLT_JUNIPER_ATM2; if (juniper_parse_header(ndo, p, h, &l2info) == 0) return l2info.header_len; p+=l2info.header_len; if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC); return l2info.header_len; } ND_TCHECK2(p[0], 3); if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */ EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); if (llc_hdrlen > 0) return l2info.header_len; } if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */ (EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) { ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL); return l2info.header_len; } if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */ isoclns_print(ndo, p + 1, l2info.length - 1); /* FIXME check if frame was recognized */ return l2info.header_len; } if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */ return l2info.header_len; if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */ return l2info.header_len; return l2info.header_len; trunc: ND_PRINT((ndo, "[|juniper_atm2]")); return l2info.header_len; } #endif /* try to guess, based on all PPP protos that are supported in * a juniper router if the payload data is encapsulated using PPP */ static int juniper_ppp_heuristic_guess(netdissect_options *ndo, register const u_char *p, u_int length) { switch(EXTRACT_16BITS(p)) { case PPP_IP : case PPP_OSI : case PPP_MPLS_UCAST : case PPP_MPLS_MCAST : case PPP_IPCP : case PPP_OSICP : case PPP_MPLSCP : case PPP_LCP : case PPP_PAP : case PPP_CHAP : case PPP_ML : case PPP_IPV6 : case PPP_IPV6CP : ppp_print(ndo, p, length); break; default: return 0; /* did not find a ppp header */ break; } return 1; /* we printed a ppp packet */ } static int ip_heuristic_guess(netdissect_options *ndo, register const u_char *p, u_int length) { switch(p[0]) { case 0x45: case 0x46: case 0x47: case 0x48: case 0x49: case 0x4a: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x4f: ip_print(ndo, p, length); break; case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: ip6_print(ndo, p, length); break; default: return 0; /* did not find a ip header */ break; } return 1; /* we printed an v4/v6 packet */ } static int juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) { int tlv_value; /* TLVs < 128 are little endian encoded */ if (tlv_type < 128) { switch (tlv_len) { case 1: tlv_value = *p; break; case 2: tlv_value = EXTRACT_LE_16BITS(p); break; case 3: tlv_value = EXTRACT_LE_24BITS(p); break; case 4: tlv_value = EXTRACT_LE_32BITS(p); break; default: tlv_value = -1; break; } } else { /* TLVs >= 128 are big endian encoded */ switch (tlv_len) { case 1: tlv_value = *p; break; case 2: tlv_value = EXTRACT_16BITS(p); break; case 3: tlv_value = EXTRACT_24BITS(p); break; case 4: tlv_value = EXTRACT_32BITS(p); break; default: tlv_value = -1; break; } } return tlv_value; } static int juniper_parse_header(netdissect_options *ndo, const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) { const struct juniper_cookie_table_t *lp = juniper_cookie_table; u_int idx, jnx_ext_len, jnx_header_len = 0; uint8_t tlv_type,tlv_len; uint32_t control_word; int tlv_value; const u_char *tptr; l2info->header_len = 0; l2info->cookie_len = 0; l2info->proto = 0; l2info->length = h->len; l2info->caplen = h->caplen; ND_TCHECK2(p[0], 4); l2info->flags = p[3]; l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ ND_PRINT((ndo, "no magic-number found!")); return 0; } if (ndo->ndo_eflag) /* print direction */ ND_PRINT((ndo, "%3s ", tok2str(juniper_direction_values, "---", l2info->direction))); /* magic number + flags */ jnx_header_len = 4; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\tJuniper PCAP Flags [%s]", bittok2str(jnx_flag_values, "none", l2info->flags))); /* extensions present ? - calculate how much bytes to skip */ if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { tptr = p+jnx_header_len; /* ok to read extension length ? */ ND_TCHECK2(tptr[0], 2); jnx_ext_len = EXTRACT_16BITS(tptr); jnx_header_len += 2; tptr +=2; /* nail up the total length - * just in case something goes wrong * with TLV parsing */ jnx_header_len += jnx_ext_len; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, ", PCAP Extension(s) total length %u", jnx_ext_len)); ND_TCHECK2(tptr[0], jnx_ext_len); while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { tlv_type = *(tptr++); tlv_len = *(tptr++); tlv_value = 0; /* sanity checks */ if (tlv_type == 0 || tlv_len == 0) break; if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len) goto trunc; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\t %s Extension TLV #%u, length %u, value ", tok2str(jnx_ext_tlv_values,"Unknown",tlv_type), tlv_type, tlv_len)); tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len); switch (tlv_type) { case JUNIPER_EXT_TLV_IFD_NAME: /* FIXME */ break; case JUNIPER_EXT_TLV_IFD_MEDIATYPE: case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%s (%u)", tok2str(juniper_ifmt_values, "Unknown", tlv_value), tlv_value)); } break; case JUNIPER_EXT_TLV_IFL_ENCAPS: case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%s (%u)", tok2str(juniper_ifle_values, "Unknown", tlv_value), tlv_value)); } break; case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ case JUNIPER_EXT_TLV_IFL_UNIT: case JUNIPER_EXT_TLV_IFD_IDX: default: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%u", tlv_value)); } break; } tptr+=tlv_len; jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; } if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\t-----original packet-----\n\t")); } if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { if (ndo->ndo_eflag) ND_PRINT((ndo, "no-L2-hdr, ")); /* there is no link-layer present - * perform the v4/v6 heuristics * to figure out what it is */ ND_TCHECK2(p[jnx_header_len + 4], 1); if (ip_heuristic_guess(ndo, p + jnx_header_len + 4, l2info->length - (jnx_header_len + 4)) == 0) ND_PRINT((ndo, "no IP-hdr found!")); l2info->header_len=jnx_header_len+4; return 0; /* stop parsing the output further */ } l2info->header_len = jnx_header_len; 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 */ ND_TCHECK(p[0]); while (lp->s != NULL) { if (lp->pictype == l2info->pictype) { l2info->cookie_len += lp->cookie_len; switch (p[0]) { case LS_COOKIE_ID: l2info->cookie_type = LS_COOKIE_ID; l2info->cookie_len += 2; break; case AS_COOKIE_ID: l2info->cookie_type = AS_COOKIE_ID; l2info->cookie_len = 8; break; default: l2info->bundle = l2info->cookie[0]; break; } #ifdef DLT_JUNIPER_MFR /* MFR child links don't carry cookies */ if (l2info->pictype == DLT_JUNIPER_MFR && (p[0] & MFR_BE_MASK) == MFR_BE_MASK) { l2info->cookie_len = 0; } #endif l2info->header_len += l2info->cookie_len; l2info->length -= l2info->cookie_len; l2info->caplen -= l2info->cookie_len; if (ndo->ndo_eflag) ND_PRINT((ndo, "%s-PIC, cookie-len %u", lp->s, l2info->cookie_len)); + if (l2info->cookie_len > 8) { + ND_PRINT((ndo, " (invalid)")); + return 0; + } + if (l2info->cookie_len > 0) { ND_TCHECK2(p[0], l2info->cookie_len); if (ndo->ndo_eflag) ND_PRINT((ndo, ", cookie 0x")); for (idx = 0; idx < l2info->cookie_len; idx++) { l2info->cookie[idx] = p[idx]; /* copy cookie data */ if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", p[idx])); } } if (ndo->ndo_eflag) ND_PRINT((ndo, ": ")); /* print demarc b/w L2/L3*/ ND_TCHECK_16BITS(p+l2info->cookie_len); l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); break; } ++lp; } p+=l2info->cookie_len; /* DLT_ specific parsing */ switch(l2info->pictype) { #ifdef DLT_JUNIPER_MLPPP 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; #endif #ifdef DLT_JUNIPER_MLFR case DLT_JUNIPER_MLFR: switch (l2info->cookie_type) { case LS_COOKIE_ID: ND_TCHECK2(p[0], 2); l2info->bundle = l2info->cookie[1]; l2info->proto = EXTRACT_16BITS(p); l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; 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]; l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; break; } break; #endif #ifdef DLT_JUNIPER_MFR case DLT_JUNIPER_MFR: switch (l2info->cookie_type) { case LS_COOKIE_ID: ND_TCHECK2(p[0], 2); l2info->bundle = l2info->cookie[1]; l2info->proto = EXTRACT_16BITS(p); l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; 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; #endif #ifdef DLT_JUNIPER_ATM2 case DLT_JUNIPER_ATM2: ND_TCHECK2(p[0], 4); /* ATM cell relay control word present ? */ if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { control_word = EXTRACT_32BITS(p); /* some control word heuristics */ switch(control_word) { case 0: /* zero control word */ case 0x08000000: /* < JUNOS 7.4 control-word */ case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ l2info->header_len += 4; break; default: break; } if (ndo->ndo_eflag) ND_PRINT((ndo, "control-word 0x%08x ", control_word)); } break; #endif #ifdef DLT_JUNIPER_GGSN case DLT_JUNIPER_GGSN: break; #endif #ifdef DLT_JUNIPER_ATM1 case DLT_JUNIPER_ATM1: break; #endif #ifdef DLT_JUNIPER_PPP case DLT_JUNIPER_PPP: break; #endif #ifdef DLT_JUNIPER_CHDLC case DLT_JUNIPER_CHDLC: break; #endif #ifdef DLT_JUNIPER_ETHER case DLT_JUNIPER_ETHER: break; #endif #ifdef DLT_JUNIPER_FRELAY case DLT_JUNIPER_FRELAY: break; #endif default: ND_PRINT((ndo, "Unknown Juniper DLT_ type %u: ", l2info->pictype)); break; } if (ndo->ndo_eflag > 1) ND_PRINT((ndo, "hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto)); return 1; /* everything went ok so far. continue parsing */ trunc: ND_PRINT((ndo, "[|juniper_hdr], length %u", h->len)); return 0; } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */ Index: vendor/tcpdump/dist/print-l2tp.c =================================================================== --- vendor/tcpdump/dist/print-l2tp.c (revision 353143) +++ vendor/tcpdump/dist/print-l2tp.c (revision 353144) @@ -1,880 +1,864 @@ /* * Copyright (c) 1991, 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. * * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) */ /* \summary: Layer Two Tunneling Protocol (L2TP) printer */ +/* specification: RFC 2661 */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */ #define L2TP_FLAG_LENGTH 0x4000 /* Length */ #define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */ #define L2TP_FLAG_OFFSET 0x0200 /* Offset */ #define L2TP_FLAG_PRIORITY 0x0100 /* Priority */ #define L2TP_VERSION_MASK 0x000f /* Version Mask */ #define L2TP_VERSION_L2F 0x0001 /* L2F */ #define L2TP_VERSION_L2TP 0x0002 /* L2TP */ #define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */ #define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */ #define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */ #define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */ #define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */ /* Authen Type */ #define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */ #define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */ #define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */ #define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */ #define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */ #define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */ #define L2TP_PROXY_AUTH_ID_MASK 0x00ff static const char tstr[] = " [|l2tp]"; #define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */ #define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */ #define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */ #define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */ #define L2TP_MSGTYPE_HELLO 6 /* Hello */ #define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */ #define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */ #define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */ #define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */ #define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */ #define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */ #define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */ #define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */ #define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */ static const struct tok l2tp_msgtype2str[] = { { L2TP_MSGTYPE_SCCRQ, "SCCRQ" }, { L2TP_MSGTYPE_SCCRP, "SCCRP" }, { L2TP_MSGTYPE_SCCCN, "SCCCN" }, { L2TP_MSGTYPE_STOPCCN, "StopCCN" }, { L2TP_MSGTYPE_HELLO, "HELLO" }, { L2TP_MSGTYPE_OCRQ, "OCRQ" }, { L2TP_MSGTYPE_OCRP, "OCRP" }, { L2TP_MSGTYPE_OCCN, "OCCN" }, { L2TP_MSGTYPE_ICRQ, "ICRQ" }, { L2TP_MSGTYPE_ICRP, "ICRP" }, { L2TP_MSGTYPE_ICCN, "ICCN" }, { L2TP_MSGTYPE_CDN, "CDN" }, { L2TP_MSGTYPE_WEN, "WEN" }, { L2TP_MSGTYPE_SLI, "SLI" }, { 0, NULL } }; #define L2TP_AVP_MSGTYPE 0 /* Message Type */ #define L2TP_AVP_RESULT_CODE 1 /* Result Code */ #define L2TP_AVP_PROTO_VER 2 /* Protocol Version */ #define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */ #define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */ #define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */ #define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */ #define L2TP_AVP_HOST_NAME 7 /* Host Name */ #define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */ #define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */ #define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */ #define L2TP_AVP_CHALLENGE 11 /* Challenge */ #define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */ #define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */ #define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */ #define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */ #define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */ #define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */ #define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */ #define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */ #define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */ #define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */ #define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */ #define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */ #define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */ #define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */ #define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */ #define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */ #define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */ #define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */ #define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */ #define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */ #define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */ #define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */ #define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */ #define L2TP_AVP_ACCM 35 /* ACCM */ #define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */ #define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */ #define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */ #define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */ -#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */ +#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code - RFC 3145 */ static const struct tok l2tp_avp2str[] = { { L2TP_AVP_MSGTYPE, "MSGTYPE" }, { L2TP_AVP_RESULT_CODE, "RESULT_CODE" }, { L2TP_AVP_PROTO_VER, "PROTO_VER" }, { L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" }, { L2TP_AVP_BEARER_CAP, "BEARER_CAP" }, { L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" }, { L2TP_AVP_FIRM_VER, "FIRM_VER" }, { L2TP_AVP_HOST_NAME, "HOST_NAME" }, { L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" }, { L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" }, { L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" }, { L2TP_AVP_CHALLENGE, "CHALLENGE" }, { L2TP_AVP_Q931_CC, "Q931_CC", }, { L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" }, { L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" }, { L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" }, { L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" }, { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" }, { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" }, { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" }, { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" }, { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" }, { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" }, { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" }, { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" }, { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" }, { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" }, { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" }, { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" }, { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" }, { L2TP_AVP_ACCM, "ACCM" }, { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" }, { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, { 0, NULL } }; static const struct tok l2tp_authentype2str[] = { { L2TP_AUTHEN_TYPE_RESERVED, "Reserved" }, { L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" }, { L2TP_AUTHEN_TYPE_CHAP, "CHAP" }, { L2TP_AUTHEN_TYPE_PAP, "PAP" }, { L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" }, { L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" }, { 0, NULL } }; #define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2 static const struct tok l2tp_cc_direction2str[] = { { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" }, { 0, NULL } }; #if 0 static char *l2tp_result_code_StopCCN[] = { "Reserved", "General request to clear control connection", "General error--Error Code indicates the problem", "Control channel already exists", "Requester is not authorized to establish a control channel", "The protocol version of the requester is not supported", "Requester is being shut down", "Finite State Machine error" #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8 }; #endif #if 0 static char *l2tp_result_code_CDN[] = { "Reserved", "Call disconnected due to loss of carrier", "Call disconnected for the reason indicated in error code", "Call disconnected for administrative reasons", "Call failed due to lack of appropriate facilities being " \ "available (temporary condition)", "Call failed due to lack of appropriate facilities being " \ "available (permanent condition)", "Invalid destination", "Call failed due to no carrier detected", "Call failed due to detection of a busy signal", "Call failed due to lack of a dial tone", "Call was not established within time allotted by LAC", "Call was connected but no appropriate framing was detected" #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12 }; #endif #if 0 static char *l2tp_error_code_general[] = { "No general error", "No control connection exists yet for this LAC-LNS pair", "Length is wrong", "One of the field values was out of range or " \ "reserved field was non-zero" "Insufficient resources to handle this operation now", "The Session ID is invalid in this context", "A generic vendor-specific error occurred in the LAC", "Try another" #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8 }; #endif /******************************/ /* generic print out routines */ /******************************/ static void print_string(netdissect_options *ndo, const u_char *dat, u_int length) { u_int i; for (i=0; i> 8), (EXTRACT_16BITS(dat) & 0xff))); } static void l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint32_t *ptr = (const uint32_t *)dat; - if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_ASYNC_MASK) { ND_PRINT((ndo, "A")); } - if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_SYNC_MASK) { ND_PRINT((ndo, "S")); } } static void l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint32_t *ptr = (const uint32_t *)dat; - if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_ANALOG_MASK) { ND_PRINT((ndo, "A")); } - if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_DIGITAL_MASK) { ND_PRINT((ndo, "D")); } } static void l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 3) { ND_PRINT((ndo, "AVP too short")); return; } - print_16bits_val(ndo, (const uint16_t *)dat); - ND_PRINT((ndo, ", %02x", dat[2])); + print_16bits_val(ndo, dat); + ND_PRINT((ndo, ", %02x", EXTRACT_8BITS(dat + 2))); dat += 3; length -= 3; if (length != 0) { ND_PRINT((ndo, " ")); print_string(ndo, dat, length); } } static void l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint32_t *ptr = (const uint32_t *)dat; - if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_ANALOG_MASK) { ND_PRINT((ndo, "A")); } - if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_DIGITAL_MASK) { ND_PRINT((ndo, "D")); } } static void l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint32_t *ptr = (const uint32_t *)dat; - if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_ASYNC_MASK) { ND_PRINT((ndo, "A")); } - if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) { + if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_SYNC_MASK) { ND_PRINT((ndo, "S")); } } static void l2tp_packet_proc_delay_print(netdissect_options *ndo) { ND_PRINT((ndo, "obsolete")); } static void l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint16_t *ptr = (const uint16_t *)dat; - if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str, - "AuthType-#%u", EXTRACT_16BITS(ptr)))); + "AuthType-#%u", EXTRACT_16BITS(dat)))); } static void l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint16_t *ptr = (const uint16_t *)dat; - if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } - ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK)); + ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat) & L2TP_PROXY_AUTH_ID_MASK)); } static void l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint16_t *ptr = (const uint16_t *)dat; - uint16_t val_h, val_l; + uint32_t val; if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } - ptr++; /* skip "Reserved" */ + dat += 2; /* skip "Reserved" */ length -= 2; if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "CRCErr=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "CRCErr=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "FrameErr=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "FrameErr=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "HardOver=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "HardOver=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "BufOver=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "BufOver=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "Timeout=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "Timeout=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; - val_l = EXTRACT_16BITS(ptr); ptr++; - ND_PRINT((ndo, "AlignErr=%u ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "AlignErr=%u ", val)); } static void l2tp_accm_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint16_t *ptr = (const uint16_t *)dat; - uint16_t val_h, val_l; + uint32_t val; if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } - ptr++; /* skip "Reserved" */ + dat += 2; /* skip "Reserved" */ length -= 2; if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2; - val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2; - ND_PRINT((ndo, "send=%08x ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "send=%08x ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } - val_h = EXTRACT_16BITS(ptr); ptr++; - val_l = EXTRACT_16BITS(ptr); ptr++; - ND_PRINT((ndo, "recv=%08x ", (val_h<<16) + val_l)); + val = EXTRACT_32BITS(dat); dat += 4; length -= 4; + ND_PRINT((ndo, "recv=%08x ", val)); } static void l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length) { - const uint16_t *ptr = (const uint16_t *)dat; - if (length < 5) { ND_PRINT((ndo, "AVP too short")); return; } /* Disconnect Code */ ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Control Protocol Number */ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Direction */ ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str, - "Direction-#%u", EXTRACT_8BITS(ptr)))); - ptr++; + "Direction-#%u", EXTRACT_8BITS(dat)))); + dat++; length--; if (length != 0) { ND_PRINT((ndo, " ")); - print_string(ndo, (const u_char *)ptr, length); + print_string(ndo, (const u_char *)dat, length); } } -static void -l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length) +static u_int +l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length) { u_int len; - const uint16_t *ptr = (const uint16_t *)dat; uint16_t attr_type; int hidden = FALSE; - if (length <= 0) { - return; - } - ND_PRINT((ndo, " ")); - ND_TCHECK(*ptr); /* Flags & Length */ - len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK; + ND_TCHECK_16BITS(dat); /* Flags & Length */ + len = EXTRACT_16BITS(dat) & L2TP_AVP_HDR_LEN_MASK; /* If it is not long enough to contain the header, we'll give up. */ if (len < 6) goto trunc; /* If it goes past the end of the remaining length of the packet, we'll give up. */ if (len > (u_int)length) goto trunc; /* If it goes past the end of the remaining length of the captured data, we'll give up. */ - ND_TCHECK2(*ptr, len); + ND_TCHECK2(*dat, len); /* * After this point, we don't need to check whether we go past * the length of the captured data; however, we *do* need to * check whether we go past the end of the AVP. */ - if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) { + if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_MANDATORY) { ND_PRINT((ndo, "*")); } - if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) { + if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_HIDDEN) { hidden = TRUE; ND_PRINT((ndo, "?")); } - ptr++; + dat += 2; - if (EXTRACT_16BITS(ptr)) { + if (EXTRACT_16BITS(dat)) { /* Vendor Specific Attribute */ - ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++; - ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++; + ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(dat))); dat += 2; + ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(dat))); dat += 2; ND_PRINT((ndo, "(")); - print_octets(ndo, (const u_char *)ptr, len-6); + print_octets(ndo, dat, len-6); ND_PRINT((ndo, ")")); } else { /* IETF-defined Attributes */ - ptr++; - attr_type = EXTRACT_16BITS(ptr); ptr++; + dat += 2; + attr_type = EXTRACT_16BITS(dat); dat += 2; ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type))); ND_PRINT((ndo, "(")); if (hidden) { ND_PRINT((ndo, "???")); } else { switch (attr_type) { case L2TP_AVP_MSGTYPE: - l2tp_msgtype_print(ndo, (const u_char *)ptr, len-6); + l2tp_msgtype_print(ndo, dat, len-6); break; case L2TP_AVP_RESULT_CODE: - l2tp_result_code_print(ndo, (const u_char *)ptr, len-6); + l2tp_result_code_print(ndo, dat, len-6); break; case L2TP_AVP_PROTO_VER: - l2tp_proto_ver_print(ndo, ptr, len-6); + l2tp_proto_ver_print(ndo, dat, len-6); break; case L2TP_AVP_FRAMING_CAP: - l2tp_framing_cap_print(ndo, (const u_char *)ptr, len-6); + l2tp_framing_cap_print(ndo, dat, len-6); break; case L2TP_AVP_BEARER_CAP: - l2tp_bearer_cap_print(ndo, (const u_char *)ptr, len-6); + l2tp_bearer_cap_print(ndo, dat, len-6); break; case L2TP_AVP_TIE_BREAKER: if (len-6 < 8) { ND_PRINT((ndo, "AVP too short")); break; } - print_octets(ndo, (const u_char *)ptr, 8); + print_octets(ndo, dat, 8); break; case L2TP_AVP_FIRM_VER: case L2TP_AVP_ASSND_TUN_ID: case L2TP_AVP_RECV_WIN_SIZE: case L2TP_AVP_ASSND_SESS_ID: if (len-6 < 2) { ND_PRINT((ndo, "AVP too short")); break; } - print_16bits_val(ndo, ptr); + print_16bits_val(ndo, dat); break; case L2TP_AVP_HOST_NAME: case L2TP_AVP_VENDOR_NAME: case L2TP_AVP_CALLING_NUMBER: case L2TP_AVP_CALLED_NUMBER: case L2TP_AVP_SUB_ADDRESS: case L2TP_AVP_PROXY_AUTH_NAME: case L2TP_AVP_PRIVATE_GRP_ID: - print_string(ndo, (const u_char *)ptr, len-6); + print_string(ndo, dat, len-6); break; case L2TP_AVP_CHALLENGE: case L2TP_AVP_INI_RECV_LCP: case L2TP_AVP_LAST_SENT_LCP: case L2TP_AVP_LAST_RECV_LCP: case L2TP_AVP_PROXY_AUTH_CHAL: case L2TP_AVP_PROXY_AUTH_RESP: case L2TP_AVP_RANDOM_VECTOR: - print_octets(ndo, (const u_char *)ptr, len-6); + print_octets(ndo, dat, len-6); break; case L2TP_AVP_Q931_CC: - l2tp_q931_cc_print(ndo, (const u_char *)ptr, len-6); + l2tp_q931_cc_print(ndo, dat, len-6); break; case L2TP_AVP_CHALLENGE_RESP: if (len-6 < 16) { ND_PRINT((ndo, "AVP too short")); break; } - print_octets(ndo, (const u_char *)ptr, 16); + print_octets(ndo, dat, 16); break; case L2TP_AVP_CALL_SER_NUM: case L2TP_AVP_MINIMUM_BPS: case L2TP_AVP_MAXIMUM_BPS: case L2TP_AVP_TX_CONN_SPEED: case L2TP_AVP_PHY_CHANNEL_ID: case L2TP_AVP_RX_CONN_SPEED: if (len-6 < 4) { ND_PRINT((ndo, "AVP too short")); break; } - print_32bits_val(ndo, (const uint32_t *)ptr); + print_32bits_val(ndo, dat); break; case L2TP_AVP_BEARER_TYPE: - l2tp_bearer_type_print(ndo, (const u_char *)ptr, len-6); + l2tp_bearer_type_print(ndo, dat, len-6); break; case L2TP_AVP_FRAMING_TYPE: - l2tp_framing_type_print(ndo, (const u_char *)ptr, len-6); + l2tp_framing_type_print(ndo, dat, len-6); break; case L2TP_AVP_PACKET_PROC_DELAY: l2tp_packet_proc_delay_print(ndo); break; case L2TP_AVP_PROXY_AUTH_TYPE: - l2tp_proxy_auth_type_print(ndo, (const u_char *)ptr, len-6); + l2tp_proxy_auth_type_print(ndo, dat, len-6); break; case L2TP_AVP_PROXY_AUTH_ID: - l2tp_proxy_auth_id_print(ndo, (const u_char *)ptr, len-6); + l2tp_proxy_auth_id_print(ndo, dat, len-6); break; case L2TP_AVP_CALL_ERRORS: - l2tp_call_errors_print(ndo, (const u_char *)ptr, len-6); + l2tp_call_errors_print(ndo, dat, len-6); break; case L2TP_AVP_ACCM: - l2tp_accm_print(ndo, (const u_char *)ptr, len-6); + l2tp_accm_print(ndo, dat, len-6); break; case L2TP_AVP_SEQ_REQUIRED: break; /* No Attribute Value */ case L2TP_AVP_PPP_DISCON_CC: - l2tp_ppp_discon_cc_print(ndo, (const u_char *)ptr, len-6); + l2tp_ppp_discon_cc_print(ndo, dat, len-6); break; default: break; } } ND_PRINT((ndo, ")")); } - l2tp_avp_print(ndo, dat+len, length-len); - return; + return (len); trunc: ND_PRINT((ndo, "|...")); + return (0); } void l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length) { const u_char *ptr = dat; u_int cnt = 0; /* total octets consumed */ uint16_t pad; int flag_t, flag_l, flag_s, flag_o; uint16_t l2tp_len; flag_t = flag_l = flag_s = flag_o = FALSE; ND_TCHECK2(*ptr, 2); /* Flags & Version */ if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { ND_PRINT((ndo, " l2tp:")); } else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) { ND_PRINT((ndo, " l2f:")); return; /* nothing to do */ } else { ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)")); return; /* nothing we can do */ } ND_PRINT((ndo, "[")); if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) { flag_t = TRUE; ND_PRINT((ndo, "T")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) { flag_l = TRUE; ND_PRINT((ndo, "L")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) { flag_s = TRUE; ND_PRINT((ndo, "S")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) { flag_o = TRUE; ND_PRINT((ndo, "O")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) ND_PRINT((ndo, "P")); ND_PRINT((ndo, "]")); ptr += 2; cnt += 2; if (flag_l) { ND_TCHECK2(*ptr, 2); /* Length */ l2tp_len = EXTRACT_16BITS(ptr); ptr += 2; cnt += 2; } else { l2tp_len = 0; } ND_TCHECK2(*ptr, 2); /* Tunnel ID */ ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; ND_TCHECK2(*ptr, 2); /* Session ID */ ND_PRINT((ndo, "%u)", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; if (flag_s) { ND_TCHECK2(*ptr, 2); /* Ns */ ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; ND_TCHECK2(*ptr, 2); /* Nr */ ND_PRINT((ndo, "Nr=%u", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; } if (flag_o) { ND_TCHECK2(*ptr, 2); /* Offset Size */ pad = EXTRACT_16BITS(ptr); ptr += (2 + pad); cnt += (2 + pad); } if (flag_l) { if (length < l2tp_len) { ND_PRINT((ndo, " Length %u larger than packet", l2tp_len)); return; } length = l2tp_len; } if (length < cnt) { ND_PRINT((ndo, " Length %u smaller than header length", length)); return; } if (flag_t) { if (!flag_l) { ND_PRINT((ndo, " No length")); return; } if (length - cnt == 0) { ND_PRINT((ndo, " ZLB")); } else { - l2tp_avp_print(ndo, ptr, length - cnt); + /* + * Print AVPs. + */ + while (length - cnt != 0) { + u_int avp_length; + + avp_length = l2tp_avp_print(ndo, ptr, length - cnt); + if (avp_length == 0) { + /* + * Truncated. + */ + break; + } + cnt += avp_length; + ptr += avp_length; + } } } else { ND_PRINT((ndo, " {")); ppp_print(ndo, ptr, length - cnt); ND_PRINT((ndo, "}")); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-ldp.c =================================================================== --- vendor/tcpdump/dist/print-ldp.c (revision 353143) +++ vendor/tcpdump/dist/print-ldp.c (revision 353144) @@ -1,698 +1,712 @@ /* * 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 Hannes Gredler (hannes@gredler.at) * and Steinar Haug (sthaug@nethelp.no) */ /* \summary: Label Distribution Protocol (LDP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "l2vpn.h" #include "af.h" +static const char tstr[] = " [|LDP]"; + /* * ldp common header * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | PDU Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | LDP Identifier | * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ struct ldp_common_header { uint8_t version[2]; uint8_t pdu_length[2]; uint8_t lsr_id[4]; uint8_t label_space[2]; }; #define LDP_VERSION 1 /* * ldp message header * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |U| Message Type | Message Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Message ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + + * | Mandatory Parameters | * + + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + + * | Optional Parameters | * + + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct ldp_msg_header { uint8_t type[2]; uint8_t length[2]; uint8_t id[4]; }; #define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff) #define LDP_MASK_U_BIT(x) ((x)&0x8000) #define LDP_MSG_NOTIF 0x0001 #define LDP_MSG_HELLO 0x0100 #define LDP_MSG_INIT 0x0200 #define LDP_MSG_KEEPALIVE 0x0201 #define LDP_MSG_ADDRESS 0x0300 #define LDP_MSG_ADDRESS_WITHDRAW 0x0301 #define LDP_MSG_LABEL_MAPPING 0x0400 #define LDP_MSG_LABEL_REQUEST 0x0401 #define LDP_MSG_LABEL_WITHDRAW 0x0402 #define LDP_MSG_LABEL_RELEASE 0x0403 #define LDP_MSG_LABEL_ABORT_REQUEST 0x0404 #define LDP_VENDOR_PRIVATE_MIN 0x3e00 #define LDP_VENDOR_PRIVATE_MAX 0x3eff #define LDP_EXPERIMENTAL_MIN 0x3f00 #define LDP_EXPERIMENTAL_MAX 0x3fff static const struct tok ldp_msg_values[] = { { LDP_MSG_NOTIF, "Notification" }, { LDP_MSG_HELLO, "Hello" }, { LDP_MSG_INIT, "Initialization" }, { LDP_MSG_KEEPALIVE, "Keepalive" }, { LDP_MSG_ADDRESS, "Address" }, { LDP_MSG_ADDRESS_WITHDRAW, "Address Withdraw" }, { LDP_MSG_LABEL_MAPPING, "Label Mapping" }, { LDP_MSG_LABEL_REQUEST, "Label Request" }, { LDP_MSG_LABEL_WITHDRAW, "Label Withdraw" }, { LDP_MSG_LABEL_RELEASE, "Label Release" }, { LDP_MSG_LABEL_ABORT_REQUEST, "Label Abort Request" }, { 0, NULL} }; #define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff) #define LDP_MASK_F_BIT(x) ((x)&0x4000) #define LDP_TLV_FEC 0x0100 #define LDP_TLV_ADDRESS_LIST 0x0101 #define LDP_TLV_ADDRESS_LIST_AFNUM_LEN 2 #define LDP_TLV_HOP_COUNT 0x0103 #define LDP_TLV_PATH_VECTOR 0x0104 #define LDP_TLV_GENERIC_LABEL 0x0200 #define LDP_TLV_ATM_LABEL 0x0201 #define LDP_TLV_FR_LABEL 0x0202 #define LDP_TLV_STATUS 0x0300 #define LDP_TLV_EXTD_STATUS 0x0301 #define LDP_TLV_RETURNED_PDU 0x0302 #define LDP_TLV_RETURNED_MSG 0x0303 #define LDP_TLV_COMMON_HELLO 0x0400 #define LDP_TLV_IPV4_TRANSPORT_ADDR 0x0401 #define LDP_TLV_CONFIG_SEQ_NUMBER 0x0402 #define LDP_TLV_IPV6_TRANSPORT_ADDR 0x0403 #define LDP_TLV_COMMON_SESSION 0x0500 #define LDP_TLV_ATM_SESSION_PARM 0x0501 #define LDP_TLV_FR_SESSION_PARM 0x0502 #define LDP_TLV_FT_SESSION 0x0503 #define LDP_TLV_LABEL_REQUEST_MSG_ID 0x0600 #define LDP_TLV_MTU 0x0601 /* rfc 3988 */ static const struct tok ldp_tlv_values[] = { { LDP_TLV_FEC, "FEC" }, { LDP_TLV_ADDRESS_LIST, "Address List" }, { LDP_TLV_HOP_COUNT, "Hop Count" }, { LDP_TLV_PATH_VECTOR, "Path Vector" }, { LDP_TLV_GENERIC_LABEL, "Generic Label" }, { LDP_TLV_ATM_LABEL, "ATM Label" }, { LDP_TLV_FR_LABEL, "Frame-Relay Label" }, { LDP_TLV_STATUS, "Status" }, { LDP_TLV_EXTD_STATUS, "Extended Status" }, { LDP_TLV_RETURNED_PDU, "Returned PDU" }, { LDP_TLV_RETURNED_MSG, "Returned Message" }, { LDP_TLV_COMMON_HELLO, "Common Hello Parameters" }, { LDP_TLV_IPV4_TRANSPORT_ADDR, "IPv4 Transport Address" }, { LDP_TLV_CONFIG_SEQ_NUMBER, "Configuration Sequence Number" }, { LDP_TLV_IPV6_TRANSPORT_ADDR, "IPv6 Transport Address" }, { LDP_TLV_COMMON_SESSION, "Common Session Parameters" }, { LDP_TLV_ATM_SESSION_PARM, "ATM Session Parameters" }, { LDP_TLV_FR_SESSION_PARM, "Frame-Relay Session Parameters" }, { LDP_TLV_FT_SESSION, "Fault-Tolerant Session Parameters" }, { LDP_TLV_LABEL_REQUEST_MSG_ID, "Label Request Message ID" }, { LDP_TLV_MTU, "MTU" }, { 0, NULL} }; #define LDP_FEC_WILDCARD 0x01 #define LDP_FEC_PREFIX 0x02 #define LDP_FEC_HOSTADDRESS 0x03 /* From RFC 4906; should probably be updated to RFC 4447 (e.g., VC -> PW) */ #define LDP_FEC_MARTINI_VC 0x80 static const struct tok ldp_fec_values[] = { { LDP_FEC_WILDCARD, "Wildcard" }, { LDP_FEC_PREFIX, "Prefix" }, { LDP_FEC_HOSTADDRESS, "Host address" }, { LDP_FEC_MARTINI_VC, "Martini VC" }, { 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} }; -static int ldp_pdu_print(netdissect_options *, register const u_char *); +static u_int ldp_pdu_print(netdissect_options *, register const u_char *); /* * ldp tlv header * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |U|F| Type | Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * | Value | * ~ ~ * | | * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ #define TLV_TCHECK(minlen) \ ND_TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv; static int ldp_tlv_print(netdissect_options *ndo, register const u_char *tptr, u_short msg_tlen) { struct ldp_tlv_header { uint8_t type[2]; uint8_t length[2]; }; 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,vc_info_len, vc_info_tlv_type, vc_info_tlv_len,idx; char buf[100]; int i; ldp_tlv_header = (const struct ldp_tlv_header *)tptr; ND_TCHECK(*ldp_tlv_header); tlv_len=EXTRACT_16BITS(ldp_tlv_header->length); if (tlv_len + 4 > msg_tlen) { ND_PRINT((ndo, "\n\t\t TLV contents go past end of message")); return 0; } tlv_tlen=tlv_len; tlv_type=LDP_MASK_TLV_TYPE(EXTRACT_16BITS(ldp_tlv_header->type)); /* FIXME vendor private / experimental check */ ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]", tok2str(ldp_tlv_values, "Unknown", tlv_type), tlv_type, tlv_len, LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "continue processing" : "ignore", LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't")); tptr+=sizeof(struct ldp_tlv_header); switch(tlv_type) { case LDP_TLV_COMMON_HELLO: TLV_TCHECK(4); ND_PRINT((ndo, "\n\t Hold Time: %us, Flags: [%s Hello%s]", EXTRACT_16BITS(tptr), (EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link", (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : "")); break; case LDP_TLV_IPV4_TRANSPORT_ADDR: TLV_TCHECK(4); ND_PRINT((ndo, "\n\t IPv4 Transport Address: %s", ipaddr_string(ndo, tptr))); break; case LDP_TLV_IPV6_TRANSPORT_ADDR: TLV_TCHECK(16); ND_PRINT((ndo, "\n\t IPv6 Transport Address: %s", ip6addr_string(ndo, tptr))); break; case LDP_TLV_CONFIG_SEQ_NUMBER: TLV_TCHECK(4); ND_PRINT((ndo, "\n\t Sequence Number: %u", EXTRACT_32BITS(tptr))); break; case LDP_TLV_ADDRESS_LIST: TLV_TCHECK(LDP_TLV_ADDRESS_LIST_AFNUM_LEN); af = EXTRACT_16BITS(tptr); tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN; ND_PRINT((ndo, "\n\t Address Family: %s, addresses", tok2str(af_values, "Unknown (%u)", af))); switch (af) { case AFNUM_INET: while(tlv_tlen >= sizeof(struct in_addr)) { ND_TCHECK2(*tptr, sizeof(struct in_addr)); ND_PRINT((ndo, " %s", ipaddr_string(ndo, tptr))); tlv_tlen-=sizeof(struct in_addr); tptr+=sizeof(struct in_addr); } break; case AFNUM_INET6: while(tlv_tlen >= sizeof(struct in6_addr)) { ND_TCHECK2(*tptr, sizeof(struct in6_addr)); ND_PRINT((ndo, " %s", ip6addr_string(ndo, tptr))); tlv_tlen-=sizeof(struct in6_addr); tptr+=sizeof(struct in6_addr); } break; default: /* unknown AF */ break; } break; case LDP_TLV_COMMON_SESSION: TLV_TCHECK(8); ND_PRINT((ndo, "\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]", EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2), (EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited", (EXTRACT_16BITS(tptr+6)&0x4000) ? "Enabled" : "Disabled" )); break; case LDP_TLV_FEC: TLV_TCHECK(1); fec_type = *tptr; ND_PRINT((ndo, "\n\t %s FEC (0x%02x)", tok2str(ldp_fec_values, "Unknown", fec_type), fec_type)); tptr+=1; tlv_tlen-=1; switch(fec_type) { case LDP_FEC_WILDCARD: break; case LDP_FEC_PREFIX: TLV_TCHECK(2); af = EXTRACT_16BITS(tptr); tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN; if (af == AFNUM_INET) { i=decode_prefix4(ndo, tptr, tlv_tlen, buf, sizeof(buf)); if (i == -2) goto trunc; if (i == -3) ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)")); else if (i == -1) ND_PRINT((ndo, ": IPv4 prefix (invalid length)")); else ND_PRINT((ndo, ": IPv4 prefix %s", buf)); } else if (af == AFNUM_INET6) { i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf)); if (i == -2) goto trunc; if (i == -3) ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)")); else if (i == -1) ND_PRINT((ndo, ": IPv6 prefix (invalid length)")); else ND_PRINT((ndo, ": IPv6 prefix %s", buf)); } else ND_PRINT((ndo, ": Address family %u prefix", af)); break; case LDP_FEC_HOSTADDRESS: break; case LDP_FEC_MARTINI_VC: /* * We assume the type was supposed to be one of the MPLS * Pseudowire Types. */ TLV_TCHECK(7); vc_info_len = *(tptr+2); /* * According to RFC 4908, the VC info Length field can be zero, * in which case not only are there no interface parameters, * there's no VC ID. */ if (vc_info_len == 0) { ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-info-length: %u", tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff), EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ", EXTRACT_32BITS(tptr+3), vc_info_len)); break; } /* Make sure we have the VC ID as well */ TLV_TCHECK(11); ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u", tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff), EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ", EXTRACT_32BITS(tptr+3), EXTRACT_32BITS(tptr+7), vc_info_len)); if (vc_info_len < 4) { /* minimum 4, for the VC ID */ ND_PRINT((ndo, " (invalid, < 4")); return(tlv_len+4); /* Type & Length fields not included */ } vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */ /* Skip past the fixed information and the VC ID */ tptr+=11; tlv_tlen-=11; TLV_TCHECK(vc_info_len); 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; ND_PRINT((ndo, "\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: + ND_TCHECK_16BITS(tptr + 2); ND_PRINT((ndo, ": %u", EXTRACT_16BITS(tptr+2))); break; case LDP_FEC_MARTINI_IFPARM_DESC: ND_PRINT((ndo, ": ")); - for (idx = 2; idx < vc_info_tlv_len; idx++) + for (idx = 2; idx < vc_info_tlv_len; idx++) { + ND_TCHECK_8BITS(tptr + idx); safeputchar(ndo, *(tptr + idx)); + } break; case LDP_FEC_MARTINI_IFPARM_VCCV: + ND_TCHECK_8BITS(tptr + 2); ND_PRINT((ndo, "\n\t\t Control Channels (0x%02x) = [%s]", *(tptr+2), bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", *(tptr+2)))); + ND_TCHECK_8BITS(tptr + 3); ND_PRINT((ndo, "\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(ndo, tptr+2, "\n\t\t ", vc_info_tlv_len-2); break; } vc_info_len -= vc_info_tlv_len; tptr += vc_info_tlv_len; } break; } break; case LDP_TLV_GENERIC_LABEL: TLV_TCHECK(4); ND_PRINT((ndo, "\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff)); break; case LDP_TLV_STATUS: TLV_TCHECK(8); ui = EXTRACT_32BITS(tptr); tptr+=4; ND_PRINT((ndo, "\n\t Status: 0x%02x, Flags: [%s and %s forward]", ui&0x3fffffff, ui&0x80000000 ? "Fatal error" : "Advisory Notification", ui&0x40000000 ? "do" : "don't")); ui = EXTRACT_32BITS(tptr); tptr+=4; if (ui) ND_PRINT((ndo, ", causing Message ID: 0x%08x", ui)); break; case LDP_TLV_FT_SESSION: - TLV_TCHECK(8); + TLV_TCHECK(12); ft_flags = EXTRACT_16BITS(tptr); ND_PRINT((ndo, "\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]", ft_flags&0x8000 ? "" : "No ", ft_flags&0x8 ? "" : "Don't ", ft_flags&0x4 ? "" : "No ", ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels", ft_flags&0x1 ? "" : "Don't ")); + /* 16 bits (FT Flags) + 16 bits (Reserved) */ tptr+=4; ui = EXTRACT_32BITS(tptr); if (ui) ND_PRINT((ndo, ", Reconnect Timeout: %ums", ui)); tptr+=4; ui = EXTRACT_32BITS(tptr); if (ui) ND_PRINT((ndo, ", Recovery Time: %ums", ui)); break; case LDP_TLV_MTU: TLV_TCHECK(2); ND_PRINT((ndo, "\n\t MTU: %u", EXTRACT_16BITS(tptr))); break; /* * FIXME those are the defined TLVs that lack a decoder * you are welcome to contribute code ;-) */ case LDP_TLV_HOP_COUNT: case LDP_TLV_PATH_VECTOR: case LDP_TLV_ATM_LABEL: case LDP_TLV_FR_LABEL: case LDP_TLV_EXTD_STATUS: case LDP_TLV_RETURNED_PDU: case LDP_TLV_RETURNED_MSG: case LDP_TLV_ATM_SESSION_PARM: case LDP_TLV_FR_SESSION_PARM: case LDP_TLV_LABEL_REQUEST_MSG_ID: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", tlv_tlen); break; } return(tlv_len+4); /* Type & Length fields not included */ trunc: - ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); + ND_PRINT((ndo, "%s", tstr)); return 0; badtlv: ND_PRINT((ndo, "\n\t\t TLV contents go past end of TLV")); return(tlv_len+4); /* Type & Length fields not included */ } void ldp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len) { - int processed; + u_int processed; while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) { processed = ldp_pdu_print(ndo, pptr); if (processed == 0) return; + if (len < processed) { + ND_PRINT((ndo, " [remaining length %u < %u]", len, processed)); + ND_PRINT((ndo, "%s", istr)); + break; + + } len -= processed; pptr += processed; } } -static int +static u_int ldp_pdu_print(netdissect_options *ndo, 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 pdu_len,msg_len,msg_type,msg_tlen; int hexdump,processed; ldp_com_header = (const struct ldp_common_header *)pptr; ND_TCHECK(*ldp_com_header); /* * Sanity checking of the header. */ if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) { ND_PRINT((ndo, "%sLDP version %u packet not supported", (ndo->ndo_vflag < 1) ? "" : "\n\t", EXTRACT_16BITS(&ldp_com_header->version))); return 0; } pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length); if (pdu_len < sizeof(const struct ldp_common_header)-4) { /* length too short */ ND_PRINT((ndo, "%sLDP, pdu-length: %u (too short, < %u)", (ndo->ndo_vflag < 1) ? "" : "\n\t", pdu_len, (u_int)(sizeof(const struct ldp_common_header)-4))); return 0; } /* print the LSR-ID, label-space & length */ ND_PRINT((ndo, "%sLDP, Label-Space-ID: %s:%u, pdu-length: %u", (ndo->ndo_vflag < 1) ? "" : "\n\t", ipaddr_string(ndo, &ldp_com_header->lsr_id), EXTRACT_16BITS(&ldp_com_header->label_space), pdu_len)); /* bail out if non-verbose */ if (ndo->ndo_vflag < 1) return 0; /* ok they seem to want to know everything - lets fully decode it */ tptr = pptr + sizeof(const struct ldp_common_header); tlen = pdu_len - (sizeof(const struct ldp_common_header)-4); /* Type & Length fields not included */ while(tlen>0) { /* did we capture enough for fully decoding the msg header ? */ ND_TCHECK2(*tptr, sizeof(struct ldp_msg_header)); ldp_msg_header = (const struct ldp_msg_header *)tptr; msg_len=EXTRACT_16BITS(ldp_msg_header->length); msg_type=LDP_MASK_MSG_TYPE(EXTRACT_16BITS(ldp_msg_header->type)); if (msg_len < sizeof(struct ldp_msg_header)-4) { /* length too short */ /* FIXME vendor private / experimental check */ ND_PRINT((ndo, "\n\t %s Message (0x%04x), length: %u (too short, < %u)", tok2str(ldp_msg_values, "Unknown", msg_type), msg_type, msg_len, (u_int)(sizeof(struct ldp_msg_header)-4))); return 0; } /* FIXME vendor private / experimental check */ ND_PRINT((ndo, "\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]", tok2str(ldp_msg_values, "Unknown", msg_type), msg_type, msg_len, EXTRACT_32BITS(&ldp_msg_header->id), LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore")); msg_tptr=tptr+sizeof(struct ldp_msg_header); msg_tlen=msg_len-(sizeof(struct ldp_msg_header)-4); /* Type & Length fields not included */ /* did we capture enough for fully decoding the message ? */ ND_TCHECK2(*tptr, msg_len); hexdump=FALSE; switch(msg_type) { case LDP_MSG_NOTIF: case LDP_MSG_HELLO: case LDP_MSG_INIT: case LDP_MSG_KEEPALIVE: case LDP_MSG_ADDRESS: case LDP_MSG_LABEL_MAPPING: case LDP_MSG_ADDRESS_WITHDRAW: case LDP_MSG_LABEL_WITHDRAW: while(msg_tlen >= 4) { processed = ldp_tlv_print(ndo, msg_tptr, msg_tlen); if (processed == 0) break; msg_tlen-=processed; msg_tptr+=processed; } break; /* * FIXME those are the defined messages that lack a decoder * you are welcome to contribute code ;-) */ case LDP_MSG_LABEL_REQUEST: case LDP_MSG_LABEL_RELEASE: case LDP_MSG_LABEL_ABORT_REQUEST: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, msg_tptr, "\n\t ", msg_tlen); break; } /* do we want to see an additionally hexdump ? */ if (ndo->ndo_vflag > 1 || hexdump==TRUE) print_unknown_data(ndo, tptr+sizeof(struct ldp_msg_header), "\n\t ", msg_len); tptr += msg_len+4; tlen -= msg_len+4; } return pdu_len+4; trunc: - ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); + ND_PRINT((ndo, "%s", tstr)); return 0; } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-lmp.c =================================================================== --- vendor/tcpdump/dist/print-lmp.c (revision 353143) +++ vendor/tcpdump/dist/print-lmp.c (revision 353144) @@ -1,1139 +1,1158 @@ /* * 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 Hannes Gredler (hannes@gredler.at) * Support for LMP service discovery extensions (defined by OIF UNI 1.0) * added by Manu Pathak (mapathak@cisco.com), May 2005 */ /* \summary: Link Management Protocol (LMP) printer */ /* specification: RFC 4204 */ /* OIF UNI 1.0: http://www.oiforum.com/public/documents/OIF-UNI-01.0.pdf */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "gmpls.h" +static const char tstr[] = " [|LMP]"; + /* * LMP common header * * 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 | (Reserved) | Flags | Msg Type | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | LMP Length | (Reserved) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct lmp_common_header { uint8_t version_res[2]; uint8_t flags; uint8_t msg_type; uint8_t length[2]; uint8_t reserved[2]; }; #define LMP_VERSION 1 #define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) static const struct tok lmp_header_flag_values[] = { { 0x01, "Control Channel Down"}, { 0x02, "LMP restart"}, { 0, NULL} }; static const struct tok lmp_obj_te_link_flag_values[] = { { 0x01, "Fault Management Supported"}, { 0x02, "Link Verification Supported"}, { 0, NULL} }; static const struct tok lmp_obj_data_link_flag_values[] = { { 0x01, "Data Link Port"}, { 0x02, "Allocated for user traffic"}, { 0x04, "Failed link"}, { 0, NULL} }; static const struct tok lmp_obj_channel_status_values[] = { { 1, "Signal Okay"}, { 2, "Signal Degraded"}, { 3, "Signal Fail"}, { 0, NULL} }; static const struct tok lmp_obj_begin_verify_flag_values[] = { { 0x0001, "Verify all links"}, { 0x0002, "Data link type"}, { 0, NULL} }; static const struct tok lmp_obj_begin_verify_error_values[] = { { 0x01, "Link Verification Procedure Not supported"}, { 0x02, "Unwilling to verify"}, { 0x04, "Unsupported verification transport mechanism"}, { 0x08, "Link-Id configuration error"}, { 0x10, "Unknown object c-type"}, { 0, NULL} }; static const struct tok lmp_obj_link_summary_error_values[] = { { 0x01, "Unacceptable non-negotiable LINK-SUMMARY parameters"}, { 0x02, "Renegotiate LINK-SUMMARY parameters"}, { 0x04, "Invalid TE-LINK Object"}, { 0x08, "Invalid DATA-LINK Object"}, { 0x10, "Unknown TE-LINK Object c-type"}, { 0x20, "Unknown DATA-LINK Object c-type"}, { 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 #define LMP_MSGTYPE_HELLO 4 #define LMP_MSGTYPE_VERIFY_BEGIN 5 #define LMP_MSGTYPE_VERIFY_BEGIN_ACK 6 #define LMP_MSGTYPE_VERIFY_BEGIN_NACK 7 #define LMP_MSGTYPE_VERIFY_END 8 #define LMP_MSGTYPE_VERIFY_END_ACK 9 #define LMP_MSGTYPE_TEST 10 #define LMP_MSGTYPE_TEST_STATUS_SUCCESS 11 #define LMP_MSGTYPE_TEST_STATUS_FAILURE 12 #define LMP_MSGTYPE_TEST_STATUS_ACK 13 #define LMP_MSGTYPE_LINK_SUMMARY 14 #define LMP_MSGTYPE_LINK_SUMMARY_ACK 15 #define LMP_MSGTYPE_LINK_SUMMARY_NACK 16 #define LMP_MSGTYPE_CHANNEL_STATUS 17 #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"}, { LMP_MSGTYPE_CONFIG_ACK, "Config ACK"}, { LMP_MSGTYPE_CONFIG_NACK, "Config NACK"}, { LMP_MSGTYPE_HELLO, "Hello"}, { LMP_MSGTYPE_VERIFY_BEGIN, "Begin Verify"}, { LMP_MSGTYPE_VERIFY_BEGIN_ACK, "Begin Verify ACK"}, { LMP_MSGTYPE_VERIFY_BEGIN_NACK, "Begin Verify NACK"}, { LMP_MSGTYPE_VERIFY_END, "End Verify"}, { LMP_MSGTYPE_VERIFY_END_ACK, "End Verify ACK"}, { LMP_MSGTYPE_TEST, "Test"}, { LMP_MSGTYPE_TEST_STATUS_SUCCESS, "Test Status Success"}, { LMP_MSGTYPE_TEST_STATUS_FAILURE, "Test Status Failure"}, { LMP_MSGTYPE_TEST_STATUS_ACK, "Test Status ACK"}, { LMP_MSGTYPE_LINK_SUMMARY, "Link Summary"}, { LMP_MSGTYPE_LINK_SUMMARY_ACK, "Link Summary ACK"}, { LMP_MSGTYPE_LINK_SUMMARY_NACK, "Link Summary NACK"}, { LMP_MSGTYPE_CHANNEL_STATUS, "Channel Status"}, { 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} }; /* * LMP object header * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |N| C-Type | Class | Length | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * // (object contents) // * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct lmp_object_header { uint8_t ctype; uint8_t class_num; uint8_t length[2]; }; #define LMP_OBJ_CC_ID 1 #define LMP_OBJ_NODE_ID 2 #define LMP_OBJ_LINK_ID 3 #define LMP_OBJ_INTERFACE_ID 4 #define LMP_OBJ_MESSAGE_ID 5 #define LMP_OBJ_CONFIG 6 #define LMP_OBJ_HELLO 7 #define LMP_OBJ_VERIFY_BEGIN 8 #define LMP_OBJ_VERIFY_BEGIN_ACK 9 #define LMP_OBJ_VERIFY_ID 10 #define LMP_OBJ_TE_LINK 11 #define LMP_OBJ_DATA_LINK 12 #define LMP_OBJ_CHANNEL_STATUS 13 #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" }, { LMP_OBJ_LINK_ID, "Link ID" }, { LMP_OBJ_INTERFACE_ID, "Interface ID" }, { LMP_OBJ_MESSAGE_ID, "Message ID" }, { LMP_OBJ_CONFIG, "Configuration" }, { LMP_OBJ_HELLO, "Hello" }, { LMP_OBJ_VERIFY_BEGIN, "Verify Begin" }, { LMP_OBJ_VERIFY_BEGIN_ACK, "Verify Begin ACK" }, { LMP_OBJ_VERIFY_ID, "Verify ID" }, { LMP_OBJ_TE_LINK, "TE Link" }, { LMP_OBJ_DATA_LINK, "Data Link" }, { 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} }; #define INT_SWITCHING_TYPE_SUBOBJ 1 #define WAVELENGTH_SUBOBJ 2 static const struct tok lmp_data_link_subobj[] = { { INT_SWITCHING_TYPE_SUBOBJ, "Interface Switching Type" }, { WAVELENGTH_SUBOBJ , "Wavelength" }, { 0, NULL} }; #define LMP_CTYPE_IPV4 1 #define LMP_CTYPE_IPV6 2 #define LMP_CTYPE_LOC 1 #define LMP_CTYPE_RMT 2 #define LMP_CTYPE_UNMD 3 #define LMP_CTYPE_IPV4_LOC 1 #define LMP_CTYPE_IPV4_RMT 2 #define LMP_CTYPE_IPV6_LOC 3 #define LMP_CTYPE_IPV6_RMT 4 #define LMP_CTYPE_UNMD_LOC 5 #define LMP_CTYPE_UNMD_RMT 6 #define LMP_CTYPE_1 1 #define LMP_CTYPE_2 2 #define LMP_CTYPE_HELLO_CONFIG 1 #define LMP_CTYPE_HELLO 1 #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 */ /* * the ctypes are not globally unique so for * translating it to strings we build a table based * on objects offsetted by the ctype */ static const struct tok lmp_ctype_values[] = { { 256*LMP_OBJ_CC_ID+LMP_CTYPE_LOC, "Local" }, { 256*LMP_OBJ_CC_ID+LMP_CTYPE_RMT, "Remote" }, { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_LOC, "Local" }, { 256*LMP_OBJ_NODE_ID+LMP_CTYPE_RMT, "Remote" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, { 256*LMP_OBJ_LINK_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_LOC, "IPv4 Local" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV4_RMT, "IPv4 Remote" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_LOC, "IPv6 Local" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_IPV6_RMT, "IPv6 Remote" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_LOC, "Unnumbered Local" }, { 256*LMP_OBJ_INTERFACE_ID+LMP_CTYPE_UNMD_RMT, "Unnumbered Remote" }, { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_MESSAGE_ID+LMP_CTYPE_2, "2" }, { 256*LMP_OBJ_CONFIG+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_HELLO+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_VERIFY_BEGIN+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_VERIFY_BEGIN_ACK+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_VERIFY_ID+LMP_CTYPE_1, "1" }, { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV4, "IPv4" }, { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_IPV6, "IPv6" }, { 256*LMP_OBJ_TE_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV4, "IPv4" }, { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_IPV6, "IPv6" }, { 256*LMP_OBJ_DATA_LINK+LMP_CTYPE_UNMD, "Unnumbered" }, { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV4, "IPv4" }, { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_IPV6, "IPv6" }, { 256*LMP_OBJ_CHANNEL_STATUS+LMP_CTYPE_UNMD, "Unnumbered" }, { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV4, "IPv4" }, { 256*LMP_OBJ_CHANNEL_STATUS_REQ+LMP_CTYPE_IPV6, "IPv6" }, { 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} }; static int lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr, int total_subobj_len, int offset) { int hexdump = FALSE; int subobj_type, subobj_len; union { /* int to float conversion buffer */ float f; uint32_t i; } bw; while (total_subobj_len > 0 && hexdump == FALSE ) { - subobj_type = EXTRACT_8BITS(obj_tptr+offset); - subobj_len = EXTRACT_8BITS(obj_tptr+offset+1); + ND_TCHECK_16BITS(obj_tptr + offset); + subobj_type = EXTRACT_8BITS(obj_tptr + offset); + subobj_len = EXTRACT_8BITS(obj_tptr + offset + 1); ND_PRINT((ndo, "\n\t Subobject, Type: %s (%u), Length: %u", tok2str(lmp_data_link_subobj, "Unknown", subobj_type), subobj_type, subobj_len)); if (subobj_len < 4) { ND_PRINT((ndo, " (too short)")); break; } if ((subobj_len % 4) != 0) { ND_PRINT((ndo, " (not a multiple of 4)")); break; } if (total_subobj_len < subobj_len) { ND_PRINT((ndo, " (goes past the end of the object)")); break; } switch(subobj_type) { case INT_SWITCHING_TYPE_SUBOBJ: + ND_TCHECK_8BITS(obj_tptr + offset + 2); ND_PRINT((ndo, "\n\t Switching Type: %s (%u)", tok2str(gmpls_switch_cap_values, "Unknown", - EXTRACT_8BITS(obj_tptr+offset+2)), - EXTRACT_8BITS(obj_tptr+offset+2))); + EXTRACT_8BITS(obj_tptr + offset + 2)), + EXTRACT_8BITS(obj_tptr + offset + 2))); + ND_TCHECK_8BITS(obj_tptr + offset + 3); ND_PRINT((ndo, "\n\t Encoding Type: %s (%u)", tok2str(gmpls_encoding_values, "Unknown", - EXTRACT_8BITS(obj_tptr+offset+3)), - EXTRACT_8BITS(obj_tptr+offset+3))); + EXTRACT_8BITS(obj_tptr + offset + 3)), + EXTRACT_8BITS(obj_tptr + offset + 3))); + ND_TCHECK_32BITS(obj_tptr + offset + 4); bw.i = EXTRACT_32BITS(obj_tptr+offset+4); ND_PRINT((ndo, "\n\t Min Reservable Bandwidth: %.3f Mbps", bw.f*8/1000000)); + ND_TCHECK_32BITS(obj_tptr + offset + 8); bw.i = EXTRACT_32BITS(obj_tptr+offset+8); ND_PRINT((ndo, "\n\t Max Reservable Bandwidth: %.3f Mbps", bw.f*8/1000000)); break; case WAVELENGTH_SUBOBJ: + ND_TCHECK_32BITS(obj_tptr + offset + 4); ND_PRINT((ndo, "\n\t Wavelength: %u", EXTRACT_32BITS(obj_tptr+offset+4))); break; default: /* Any Unknown Subobject ==> Exit loop */ hexdump=TRUE; break; } total_subobj_len-=subobj_len; offset+=subobj_len; } return (hexdump); +trunc: + return -1; } void lmp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len) { const struct lmp_common_header *lmp_com_header; const struct lmp_object_header *lmp_obj_header; const u_char *tptr,*obj_tptr; u_int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen; - int hexdump; + int hexdump, ret; u_int offset; u_int link_type; union { /* int to float conversion buffer */ float f; uint32_t i; } bw; tptr=pptr; lmp_com_header = (const struct lmp_common_header *)pptr; ND_TCHECK(*lmp_com_header); /* * Sanity checking of the header. */ if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) { ND_PRINT((ndo, "LMP version %u packet not supported", LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]))); return; } /* in non-verbose mode just lets print the basic Message Type*/ if (ndo->ndo_vflag < 1) { ND_PRINT((ndo, "LMPv%u %s Message, length: %u", LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type), len)); return; } /* ok they seem to want to know everything - lets fully decode it */ tlen=EXTRACT_16BITS(lmp_com_header->length); ND_PRINT((ndo, "\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u", LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]), tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type), bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags), tlen)); if (tlen < sizeof(const struct lmp_common_header)) { ND_PRINT((ndo, " (too short)")); return; } if (tlen > len) { ND_PRINT((ndo, " (too long)")); tlen = len; } tptr+=sizeof(const struct lmp_common_header); tlen-=sizeof(const struct lmp_common_header); while(tlen>0) { /* did we capture enough for fully decoding the object header ? */ ND_TCHECK2(*tptr, sizeof(struct lmp_object_header)); lmp_obj_header = (const struct lmp_object_header *)tptr; lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length); lmp_obj_ctype=(lmp_obj_header->ctype)&0x7f; ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u", tok2str(lmp_obj_values, "Unknown", lmp_obj_header->class_num), lmp_obj_header->class_num, tok2str(lmp_ctype_values, "Unknown", ((lmp_obj_header->class_num)<<8)+lmp_obj_ctype), lmp_obj_ctype, (lmp_obj_header->ctype)&0x80 ? "" : "non-", lmp_obj_len)); if (lmp_obj_len < 4) { ND_PRINT((ndo, " (too short)")); return; } if ((lmp_obj_len % 4) != 0) { ND_PRINT((ndo, " (not a multiple of 4)")); return; } obj_tptr=tptr+sizeof(struct lmp_object_header); obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header); /* did we capture enough for fully decoding the object ? */ ND_TCHECK2(*tptr, lmp_obj_len); hexdump=FALSE; switch(lmp_obj_header->class_num) { case LMP_OBJ_CC_ID: switch(lmp_obj_ctype) { case LMP_CTYPE_LOC: case LMP_CTYPE_RMT: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Control Channel ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr))); break; default: hexdump=TRUE; } break; case LMP_OBJ_LINK_ID: case LMP_OBJ_INTERFACE_ID: switch(lmp_obj_ctype) { case LMP_CTYPE_IPV4_LOC: case LMP_CTYPE_IPV4_RMT: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t IPv4 Link ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr))); break; case LMP_CTYPE_IPV6_LOC: case LMP_CTYPE_IPV6_RMT: if (obj_tlen != 16) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t IPv6 Link ID: %s (0x%08x)", ip6addr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr))); break; case LMP_CTYPE_UNMD_LOC: case LMP_CTYPE_UNMD_RMT: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Link ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr))); break; default: hexdump=TRUE; } break; case LMP_OBJ_MESSAGE_ID: switch(lmp_obj_ctype) { case LMP_CTYPE_1: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Message ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr))); break; case LMP_CTYPE_2: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Message ID Ack: %u (0x%08x)", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr))); break; default: hexdump=TRUE; } break; case LMP_OBJ_NODE_ID: switch(lmp_obj_ctype) { case LMP_CTYPE_LOC: case LMP_CTYPE_RMT: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Node ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr))); break; default: hexdump=TRUE; } break; case LMP_OBJ_CONFIG: switch(lmp_obj_ctype) { case LMP_CTYPE_HELLO_CONFIG: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Hello Interval: %u\n\t Hello Dead Interval: %u", EXTRACT_16BITS(obj_tptr), EXTRACT_16BITS(obj_tptr+2))); break; default: hexdump=TRUE; } break; case LMP_OBJ_HELLO: switch(lmp_obj_ctype) { case LMP_CTYPE_HELLO: if (obj_tlen != 8) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Tx Seq: %u, Rx Seq: %u", EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr+4))); break; default: hexdump=TRUE; } break; case LMP_OBJ_TE_LINK: switch(lmp_obj_ctype) { case LMP_CTYPE_IPV4: if (obj_tlen != 12) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_te_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Link-ID: %s (0x%08x)" "\n\t Remote Link-ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), ipaddr_string(ndo, obj_tptr+8), EXTRACT_32BITS(obj_tptr+8))); break; case LMP_CTYPE_IPV6: if (obj_tlen != 36) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_te_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Link-ID: %s (0x%08x)" "\n\t Remote Link-ID: %s (0x%08x)", ip6addr_string(ndo, obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), ip6addr_string(ndo, obj_tptr+20), EXTRACT_32BITS(obj_tptr+20))); break; case LMP_CTYPE_UNMD: if (obj_tlen != 12) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_te_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Link-ID: %u (0x%08x)" "\n\t Remote Link-ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr+8), EXTRACT_32BITS(obj_tptr+8))); break; default: hexdump=TRUE; } break; case LMP_OBJ_DATA_LINK: switch(lmp_obj_ctype) { case LMP_CTYPE_IPV4: if (obj_tlen < 12) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_data_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)" "\n\t Remote Interface ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), ipaddr_string(ndo, obj_tptr+8), EXTRACT_32BITS(obj_tptr+8))); - if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12)) + ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12); + if (ret == -1) + goto trunc; + if (ret == TRUE) hexdump=TRUE; break; case LMP_CTYPE_IPV6: if (obj_tlen < 36) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_data_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)" "\n\t Remote Interface ID: %s (0x%08x)", ip6addr_string(ndo, obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), ip6addr_string(ndo, obj_tptr+20), EXTRACT_32BITS(obj_tptr+20))); - if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36)) + ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36); + if (ret == -1) + goto trunc; + if (ret == TRUE) hexdump=TRUE; break; case LMP_CTYPE_UNMD: if (obj_tlen < 12) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: [%s]", bittok2str(lmp_obj_data_link_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Local Interface ID: %u (0x%08x)" "\n\t Remote Interface ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr+8), EXTRACT_32BITS(obj_tptr+8))); - if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12)) + ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12); + if (ret == -1) + goto trunc; + if (ret == TRUE) hexdump=TRUE; break; default: hexdump=TRUE; } break; case LMP_OBJ_VERIFY_BEGIN: switch(lmp_obj_ctype) { case LMP_CTYPE_1: if (obj_tlen != 20) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: %s", bittok2str(lmp_obj_begin_verify_flag_values, "none", EXTRACT_16BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t Verify Interval: %u", EXTRACT_16BITS(obj_tptr+2))); ND_PRINT((ndo, "\n\t Data links: %u", EXTRACT_32BITS(obj_tptr+4))); ND_PRINT((ndo, "\n\t Encoding type: %s", tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8)))); ND_PRINT((ndo, "\n\t Verify Transport Mechanism: %u (0x%x)%s", EXTRACT_16BITS(obj_tptr+10), EXTRACT_16BITS(obj_tptr+10), EXTRACT_16BITS(obj_tptr+10)&8000 ? " (Payload test messages capable)" : "")); bw.i = EXTRACT_32BITS(obj_tptr+12); ND_PRINT((ndo, "\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000)); ND_PRINT((ndo, "\n\t Wavelength: %u", EXTRACT_32BITS(obj_tptr+16))); break; default: hexdump=TRUE; } break; case LMP_OBJ_VERIFY_BEGIN_ACK: switch(lmp_obj_ctype) { case LMP_CTYPE_1: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Verify Dead Interval: %u" "\n\t Verify Transport Response: %u", EXTRACT_16BITS(obj_tptr), EXTRACT_16BITS(obj_tptr+2))); break; default: hexdump=TRUE; } break; case LMP_OBJ_VERIFY_ID: switch(lmp_obj_ctype) { case LMP_CTYPE_1: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Verify ID: %u", EXTRACT_32BITS(obj_tptr))); break; default: hexdump=TRUE; } break; case LMP_OBJ_CHANNEL_STATUS: switch(lmp_obj_ctype) { case LMP_CTYPE_IPV4: offset = 0; /* Decode pairs: */ while (offset+8 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); ND_PRINT((ndo, "\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ? "Allocated" : "Non-allocated", (EXTRACT_32BITS(obj_tptr+offset+4)>>31))); ND_PRINT((ndo, "\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ? "Transmit" : "Receive", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1)); ND_PRINT((ndo, "\n\t\t Channel Status: %s (%u)", tok2str(lmp_obj_channel_status_values, "Unknown", EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF), EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF)); offset+=8; } break; case LMP_CTYPE_IPV6: offset = 0; /* Decode pairs: */ while (offset+20 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)", ip6addr_string(ndo, obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); ND_PRINT((ndo, "\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+16)>>31) ? "Allocated" : "Non-allocated", (EXTRACT_32BITS(obj_tptr+offset+16)>>31))); ND_PRINT((ndo, "\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+16)>>30)&0x1 ? "Transmit" : "Receive", (EXTRACT_32BITS(obj_tptr+offset+16)>>30)&0x1)); ND_PRINT((ndo, "\n\t\t Channel Status: %s (%u)", tok2str(lmp_obj_channel_status_values, "Unknown", EXTRACT_32BITS(obj_tptr+offset+16)&0x3FFFFFF), EXTRACT_32BITS(obj_tptr+offset+16)&0x3FFFFFF)); offset+=20; } break; case LMP_CTYPE_UNMD: offset = 0; /* Decode pairs: */ while (offset+8 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); ND_PRINT((ndo, "\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ? "Allocated" : "Non-allocated", (EXTRACT_32BITS(obj_tptr+offset+4)>>31))); ND_PRINT((ndo, "\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ? "Transmit" : "Receive", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1)); ND_PRINT((ndo, "\n\t\t Channel Status: %s (%u)", tok2str(lmp_obj_channel_status_values, "Unknown", EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF), EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF)); offset+=8; } break; default: hexdump=TRUE; } break; case LMP_OBJ_CHANNEL_STATUS_REQ: switch(lmp_obj_ctype) { case LMP_CTYPE_IPV4: offset = 0; while (offset+4 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); offset+=4; } break; case LMP_CTYPE_IPV6: offset = 0; while (offset+16 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)", ip6addr_string(ndo, obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); offset+=16; } break; case LMP_CTYPE_UNMD: offset = 0; while (offset+4 <= obj_tlen) { ND_PRINT((ndo, "\n\t Interface ID: %u (0x%08x)", EXTRACT_32BITS(obj_tptr+offset), EXTRACT_32BITS(obj_tptr+offset))); offset+=4; } break; default: hexdump=TRUE; } break; case LMP_OBJ_ERROR_CODE: switch(lmp_obj_ctype) { case LMP_CTYPE_BEGIN_VERIFY_ERROR: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Error Code: %s", bittok2str(lmp_obj_begin_verify_error_values, "none", EXTRACT_32BITS(obj_tptr)))); break; case LMP_CTYPE_LINK_SUMMARY_ERROR: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Error Code: %s", bittok2str(lmp_obj_link_summary_error_values, "none", EXTRACT_32BITS(obj_tptr)))); break; default: hexdump=TRUE; } break; case LMP_OBJ_SERVICE_CONFIG: switch (lmp_obj_ctype) { case LMP_CTYPE_SERVICE_CONFIG_SP: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Flags: %s", bittok2str(lmp_obj_service_config_sp_flag_values, "none", EXTRACT_8BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t UNI Version: %u", - EXTRACT_8BITS(obj_tptr+1))); + EXTRACT_8BITS(obj_tptr + 1))); break; case LMP_CTYPE_SERVICE_CONFIG_CPSA: if (obj_tlen != 16) { ND_PRINT((ndo, " (not correct for object)")); break; } link_type = EXTRACT_8BITS(obj_tptr); ND_PRINT((ndo, "\n\t Link Type: %s (%u)", tok2str(lmp_sd_service_config_cpsa_link_type_values, "Unknown", link_type), link_type)); switch (link_type) { case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH: ND_PRINT((ndo, "\n\t Signal Type: %s (%u)", tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values, "Unknown", - EXTRACT_8BITS(obj_tptr+1)), - EXTRACT_8BITS(obj_tptr+1))); + EXTRACT_8BITS(obj_tptr + 1)), + EXTRACT_8BITS(obj_tptr + 1))); break; case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET: ND_PRINT((ndo, "\n\t Signal Type: %s (%u)", tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values, "Unknown", - EXTRACT_8BITS(obj_tptr+1)), - EXTRACT_8BITS(obj_tptr+1))); + EXTRACT_8BITS(obj_tptr + 1)), + EXTRACT_8BITS(obj_tptr + 1))); break; } ND_PRINT((ndo, "\n\t Transparency: %s", bittok2str(lmp_obj_service_config_cpsa_tp_flag_values, "none", - EXTRACT_8BITS(obj_tptr+2)))); + EXTRACT_8BITS(obj_tptr + 2)))); ND_PRINT((ndo, "\n\t Contiguous Concatenation Types: %s", bittok2str(lmp_obj_service_config_cpsa_cct_flag_values, "none", - EXTRACT_8BITS(obj_tptr+3)))); + EXTRACT_8BITS(obj_tptr + 3)))); ND_PRINT((ndo, "\n\t Minimum NCC: %u", EXTRACT_16BITS(obj_tptr+4))); ND_PRINT((ndo, "\n\t Maximum NCC: %u", EXTRACT_16BITS(obj_tptr+6))); ND_PRINT((ndo, "\n\t Minimum NVC:%u", EXTRACT_16BITS(obj_tptr+8))); ND_PRINT((ndo, "\n\t Maximum NVC:%u", EXTRACT_16BITS(obj_tptr+10))); ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)", ipaddr_string(ndo, obj_tptr+12), EXTRACT_32BITS(obj_tptr+12))); break; case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM: if (obj_tlen != 8) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Transparency Flags: %s", bittok2str( lmp_obj_service_config_nsa_transparency_flag_values, "none", EXTRACT_32BITS(obj_tptr)))); ND_PRINT((ndo, "\n\t TCM Monitoring Flags: %s", bittok2str( lmp_obj_service_config_nsa_tcm_flag_values, "none", - EXTRACT_8BITS(obj_tptr+7)))); + EXTRACT_8BITS(obj_tptr + 7)))); break; case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY: if (obj_tlen != 4) { ND_PRINT((ndo, " (not correct for object)")); break; } ND_PRINT((ndo, "\n\t Diversity: Flags: %s", bittok2str( lmp_obj_service_config_nsa_network_diversity_flag_values, "none", - EXTRACT_8BITS(obj_tptr+3)))); + EXTRACT_8BITS(obj_tptr + 3)))); break; default: hexdump = TRUE; } break; default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo,obj_tptr,"\n\t ",obj_tlen); break; } /* do we want to see an additionally hexdump ? */ if (ndo->ndo_vflag > 1 || hexdump==TRUE) print_unknown_data(ndo,tptr+sizeof(struct lmp_object_header),"\n\t ", lmp_obj_len-sizeof(struct lmp_object_header)); tptr+=lmp_obj_len; tlen-=lmp_obj_len; } return; trunc: - ND_PRINT((ndo, "\n\t\t packet exceeded snapshot")); + ND_PRINT((ndo, "%s", tstr)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-nfs.c =================================================================== --- vendor/tcpdump/dist/print-nfs.c (revision 353143) +++ vendor/tcpdump/dist/print-nfs.c (revision 353144) @@ -1,1715 +1,1715 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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. */ /* \summary: Network File System (NFS) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "nfs.h" #include "nfsfh.h" #include "ip.h" #include "ip6.h" #include "rpc_auth.h" #include "rpc_msg.h" static const char tstr[] = " [|nfs]"; static void nfs_printfh(netdissect_options *, const uint32_t *, const u_int); static int xid_map_enter(netdissect_options *, const struct sunrpc_msg *, const u_char *); static int xid_map_find(const struct sunrpc_msg *, const u_char *, uint32_t *, uint32_t *); static void interp_reply(netdissect_options *, const struct sunrpc_msg *, uint32_t, uint32_t, int); static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *, int); /* * Mapping of old NFS Version 2 RPC numbers to generic numbers. */ static uint32_t nfsv3_procid[NFS_NPROCS] = { NFSPROC_NULL, NFSPROC_GETATTR, NFSPROC_SETATTR, NFSPROC_NOOP, NFSPROC_LOOKUP, NFSPROC_READLINK, NFSPROC_READ, NFSPROC_NOOP, NFSPROC_WRITE, NFSPROC_CREATE, NFSPROC_REMOVE, NFSPROC_RENAME, NFSPROC_LINK, NFSPROC_SYMLINK, NFSPROC_MKDIR, NFSPROC_RMDIR, NFSPROC_READDIR, NFSPROC_FSSTAT, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP, NFSPROC_NOOP }; static const struct tok nfsproc_str[] = { { NFSPROC_NOOP, "nop" }, { NFSPROC_NULL, "null" }, { NFSPROC_GETATTR, "getattr" }, { NFSPROC_SETATTR, "setattr" }, { NFSPROC_LOOKUP, "lookup" }, { NFSPROC_ACCESS, "access" }, { NFSPROC_READLINK, "readlink" }, { NFSPROC_READ, "read" }, { NFSPROC_WRITE, "write" }, { NFSPROC_CREATE, "create" }, { NFSPROC_MKDIR, "mkdir" }, { NFSPROC_SYMLINK, "symlink" }, { NFSPROC_MKNOD, "mknod" }, { NFSPROC_REMOVE, "remove" }, { NFSPROC_RMDIR, "rmdir" }, { NFSPROC_RENAME, "rename" }, { NFSPROC_LINK, "link" }, { NFSPROC_READDIR, "readdir" }, { NFSPROC_READDIRPLUS, "readdirplus" }, { NFSPROC_FSSTAT, "fsstat" }, { NFSPROC_FSINFO, "fsinfo" }, { NFSPROC_PATHCONF, "pathconf" }, { NFSPROC_COMMIT, "commit" }, { 0, NULL } }; /* * NFS V2 and V3 status values. * * Some of these come from the RFCs for NFS V2 and V3, with the message * strings taken from the FreeBSD C library "errlst.c". * * Others are errors that are not in the RFC but that I suspect some * NFS servers could return; the values are FreeBSD errno values, as * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS * was primarily BSD-derived. */ static const struct tok status2str[] = { { 1, "Operation not permitted" }, /* EPERM */ { 2, "No such file or directory" }, /* ENOENT */ { 5, "Input/output error" }, /* EIO */ { 6, "Device not configured" }, /* ENXIO */ { 11, "Resource deadlock avoided" }, /* EDEADLK */ { 12, "Cannot allocate memory" }, /* ENOMEM */ { 13, "Permission denied" }, /* EACCES */ { 17, "File exists" }, /* EEXIST */ { 18, "Cross-device link" }, /* EXDEV */ { 19, "Operation not supported by device" }, /* ENODEV */ { 20, "Not a directory" }, /* ENOTDIR */ { 21, "Is a directory" }, /* EISDIR */ { 22, "Invalid argument" }, /* EINVAL */ { 26, "Text file busy" }, /* ETXTBSY */ { 27, "File too large" }, /* EFBIG */ { 28, "No space left on device" }, /* ENOSPC */ { 30, "Read-only file system" }, /* EROFS */ { 31, "Too many links" }, /* EMLINK */ { 45, "Operation not supported" }, /* EOPNOTSUPP */ { 62, "Too many levels of symbolic links" }, /* ELOOP */ { 63, "File name too long" }, /* ENAMETOOLONG */ { 66, "Directory not empty" }, /* ENOTEMPTY */ { 69, "Disc quota exceeded" }, /* EDQUOT */ { 70, "Stale NFS file handle" }, /* ESTALE */ { 71, "Too many levels of remote in path" }, /* EREMOTE */ { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */ { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */ { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */ { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */ { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */ { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */ { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */ { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */ { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */ { 0, NULL } }; static const struct tok nfsv3_writemodes[] = { { 0, "unstable" }, { 1, "datasync" }, { 2, "filesync" }, { 0, NULL } }; static const struct tok type2str[] = { { NFNON, "NON" }, { NFREG, "REG" }, { NFDIR, "DIR" }, { NFBLK, "BLK" }, { NFCHR, "CHR" }, { NFLNK, "LNK" }, { NFFIFO, "FIFO" }, { 0, NULL } }; static const struct tok sunrpc_auth_str[] = { { SUNRPC_AUTH_OK, "OK" }, { SUNRPC_AUTH_BADCRED, "Bogus Credentials (seal broken)" }, { SUNRPC_AUTH_REJECTEDCRED, "Rejected Credentials (client should begin new session)" }, { SUNRPC_AUTH_BADVERF, "Bogus Verifier (seal broken)" }, { SUNRPC_AUTH_REJECTEDVERF, "Verifier expired or was replayed" }, { SUNRPC_AUTH_TOOWEAK, "Credentials are too weak" }, { SUNRPC_AUTH_INVALIDRESP, "Bogus response verifier" }, { SUNRPC_AUTH_FAILED, "Unknown failure" }, { 0, NULL } }; static const struct tok sunrpc_str[] = { { SUNRPC_PROG_UNAVAIL, "PROG_UNAVAIL" }, { SUNRPC_PROG_MISMATCH, "PROG_MISMATCH" }, { SUNRPC_PROC_UNAVAIL, "PROC_UNAVAIL" }, { SUNRPC_GARBAGE_ARGS, "GARBAGE_ARGS" }, { SUNRPC_SYSTEM_ERR, "SYSTEM_ERR" }, { 0, NULL } }; static void print_nfsaddr(netdissect_options *ndo, const u_char *bp, const char *s, const char *d) { const struct ip *ip; const struct ip6_hdr *ip6; char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN]; srcaddr[0] = dstaddr[0] = '\0'; switch (IP_V((const struct ip *)bp)) { case 4: ip = (const struct ip *)bp; strlcpy(srcaddr, ipaddr_string(ndo, &ip->ip_src), sizeof(srcaddr)); strlcpy(dstaddr, ipaddr_string(ndo, &ip->ip_dst), sizeof(dstaddr)); break; case 6: ip6 = (const struct ip6_hdr *)bp; strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src), sizeof(srcaddr)); strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst), sizeof(dstaddr)); break; default: strlcpy(srcaddr, "?", sizeof(srcaddr)); strlcpy(dstaddr, "?", sizeof(dstaddr)); break; } ND_PRINT((ndo, "%s.%s > %s.%s: ", srcaddr, s, dstaddr, d)); } static const uint32_t * parse_sattr3(netdissect_options *ndo, const uint32_t *dp, struct nfsv3_sattr *sa3) { ND_TCHECK(dp[0]); sa3->sa_modeset = EXTRACT_32BITS(dp); dp++; if (sa3->sa_modeset) { ND_TCHECK(dp[0]); sa3->sa_mode = EXTRACT_32BITS(dp); dp++; } ND_TCHECK(dp[0]); sa3->sa_uidset = EXTRACT_32BITS(dp); dp++; if (sa3->sa_uidset) { ND_TCHECK(dp[0]); sa3->sa_uid = EXTRACT_32BITS(dp); dp++; } ND_TCHECK(dp[0]); sa3->sa_gidset = EXTRACT_32BITS(dp); dp++; if (sa3->sa_gidset) { ND_TCHECK(dp[0]); sa3->sa_gid = EXTRACT_32BITS(dp); dp++; } ND_TCHECK(dp[0]); sa3->sa_sizeset = EXTRACT_32BITS(dp); dp++; if (sa3->sa_sizeset) { ND_TCHECK(dp[0]); sa3->sa_size = EXTRACT_32BITS(dp); dp++; } ND_TCHECK(dp[0]); sa3->sa_atimetype = EXTRACT_32BITS(dp); dp++; if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) { ND_TCHECK(dp[1]); sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp); dp++; sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp); dp++; } ND_TCHECK(dp[0]); sa3->sa_mtimetype = EXTRACT_32BITS(dp); dp++; if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) { ND_TCHECK(dp[1]); sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp); dp++; sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp); dp++; } return dp; trunc: return NULL; } static int nfserr; /* true if we error rather than trunc */ static void print_sattr3(netdissect_options *ndo, const struct nfsv3_sattr *sa3, int verbose) { if (sa3->sa_modeset) ND_PRINT((ndo, " mode %o", sa3->sa_mode)); if (sa3->sa_uidset) ND_PRINT((ndo, " uid %u", sa3->sa_uid)); if (sa3->sa_gidset) ND_PRINT((ndo, " gid %u", sa3->sa_gid)); if (verbose > 1) { if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) ND_PRINT((ndo, " atime %u.%06u", sa3->sa_atime.nfsv3_sec, sa3->sa_atime.nfsv3_nsec)); if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) ND_PRINT((ndo, " mtime %u.%06u", sa3->sa_mtime.nfsv3_sec, sa3->sa_mtime.nfsv3_nsec)); } } void nfsreply_print(netdissect_options *ndo, register const u_char *bp, u_int length, register const u_char *bp2) { register const struct sunrpc_msg *rp; char srcid[20], dstid[20]; /*fits 32bit*/ nfserr = 0; /* assume no error */ rp = (const struct sunrpc_msg *)bp; ND_TCHECK(rp->rm_xid); if (!ndo->ndo_nflag) { strlcpy(srcid, "nfs", sizeof(srcid)); snprintf(dstid, sizeof(dstid), "%u", EXTRACT_32BITS(&rp->rm_xid)); } else { snprintf(srcid, sizeof(srcid), "%u", NFS_PORT); snprintf(dstid, sizeof(dstid), "%u", EXTRACT_32BITS(&rp->rm_xid)); } print_nfsaddr(ndo, bp2, srcid, dstid); nfsreply_print_noaddr(ndo, bp, length, bp2); return; trunc: if (!nfserr) ND_PRINT((ndo, "%s", tstr)); } void nfsreply_print_noaddr(netdissect_options *ndo, register const u_char *bp, u_int length, register const u_char *bp2) { register const struct sunrpc_msg *rp; uint32_t proc, vers, reply_stat; enum sunrpc_reject_stat rstat; uint32_t rlow; uint32_t rhigh; enum sunrpc_auth_stat rwhy; nfserr = 0; /* assume no error */ rp = (const struct sunrpc_msg *)bp; ND_TCHECK(rp->rm_reply.rp_stat); reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat); switch (reply_stat) { case SUNRPC_MSG_ACCEPTED: ND_PRINT((ndo, "reply ok %u", length)); if (xid_map_find(rp, bp2, &proc, &vers) >= 0) interp_reply(ndo, rp, proc, vers, length); break; case SUNRPC_MSG_DENIED: ND_PRINT((ndo, "reply ERR %u: ", length)); ND_TCHECK(rp->rm_reply.rp_reject.rj_stat); rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat); switch (rstat) { case SUNRPC_RPC_MISMATCH: ND_TCHECK(rp->rm_reply.rp_reject.rj_vers.high); rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low); rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high); ND_PRINT((ndo, "RPC Version mismatch (%u-%u)", rlow, rhigh)); break; case SUNRPC_AUTH_ERROR: ND_TCHECK(rp->rm_reply.rp_reject.rj_why); rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why); ND_PRINT((ndo, "Auth %s", tok2str(sunrpc_auth_str, "Invalid failure code %u", rwhy))); break; default: ND_PRINT((ndo, "Unknown reason for rejecting rpc message %u", (unsigned int)rstat)); break; } break; default: ND_PRINT((ndo, "reply Unknown rpc response code=%u %u", reply_stat, length)); break; } return; trunc: if (!nfserr) ND_PRINT((ndo, "%s", tstr)); } /* * Return a pointer to the first file handle in the packet. * If the packet was truncated, return 0. */ static const uint32_t * parsereq(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length) { register const uint32_t *dp; register u_int len; /* * find the start of the req data (if we captured it) */ dp = (const uint32_t *)&rp->rm_call.cb_cred; ND_TCHECK(dp[1]); len = EXTRACT_32BITS(&dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); ND_TCHECK(dp[1]); len = EXTRACT_32BITS(&dp[1]); if (len < length) { dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp); ND_TCHECK2(dp[0], 0); return (dp); } } trunc: return (NULL); } /* * Print out an NFS file handle and return a pointer to following word. * If packet was truncated, return 0. */ static const uint32_t * parsefh(netdissect_options *ndo, register const uint32_t *dp, int v3) { u_int len; if (v3) { ND_TCHECK(dp[0]); len = EXTRACT_32BITS(dp) / 4; dp++; } else len = NFSX_V2FH / 4; if (ND_TTEST2(*dp, len * sizeof(*dp))) { nfs_printfh(ndo, dp, len); return (dp + len); } trunc: return (NULL); } /* * Print out a file name and return pointer to 32-bit word past it. * If packet was truncated, return 0. */ static const uint32_t * parsefn(netdissect_options *ndo, register const uint32_t *dp) { register uint32_t len; register const u_char *cp; /* Bail if we don't have the string length */ ND_TCHECK(*dp); /* Fetch string length; convert to host order */ len = *dp++; NTOHL(len); ND_TCHECK2(*dp, ((len + 3) & ~3)); cp = (const u_char *)dp; /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */ dp += ((len + 3) & ~3) / sizeof(*dp); ND_PRINT((ndo, "\"")); if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); return (dp); trunc: return NULL; } /* * Print out file handle and file name. * Return pointer to 32-bit word past file name. * If packet was truncated (or there was some other error), return 0. */ static const uint32_t * parsefhn(netdissect_options *ndo, register const uint32_t *dp, int v3) { dp = parsefh(ndo, dp, v3); if (dp == NULL) return (NULL); ND_PRINT((ndo, " ")); return (parsefn(ndo, dp)); } void nfsreq_print_noaddr(netdissect_options *ndo, register const u_char *bp, u_int length, register const u_char *bp2) { register const struct sunrpc_msg *rp; register const uint32_t *dp; nfs_type type; int v3; uint32_t proc; uint32_t access_flags; struct nfsv3_sattr sa3; ND_PRINT((ndo, "%d", length)); nfserr = 0; /* assume no error */ rp = (const struct sunrpc_msg *)bp; if (!xid_map_enter(ndo, rp, bp2)) /* record proc number for later on */ goto trunc; v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3); proc = EXTRACT_32BITS(&rp->rm_call.cb_proc); if (!v3 && proc < NFS_NPROCS) proc = nfsv3_procid[proc]; ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc))); switch (proc) { case NFSPROC_GETATTR: case NFSPROC_SETATTR: case NFSPROC_READLINK: case NFSPROC_FSSTAT: case NFSPROC_FSINFO: case NFSPROC_PATHCONF: if ((dp = parsereq(ndo, rp, length)) != NULL && parsefh(ndo, dp, v3) != NULL) return; break; case NFSPROC_LOOKUP: case NFSPROC_CREATE: case NFSPROC_MKDIR: case NFSPROC_REMOVE: case NFSPROC_RMDIR: if ((dp = parsereq(ndo, rp, length)) != NULL && parsefhn(ndo, dp, v3) != NULL) return; break; case NFSPROC_ACCESS: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { ND_TCHECK(dp[0]); access_flags = EXTRACT_32BITS(&dp[0]); if (access_flags & ~NFSV3ACCESS_FULL) { /* NFSV3ACCESS definitions aren't up to date */ ND_PRINT((ndo, " %04x", access_flags)); } else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) { ND_PRINT((ndo, " NFS_ACCESS_FULL")); } else { char separator = ' '; if (access_flags & NFSV3ACCESS_READ) { ND_PRINT((ndo, " NFS_ACCESS_READ")); separator = '|'; } if (access_flags & NFSV3ACCESS_LOOKUP) { ND_PRINT((ndo, "%cNFS_ACCESS_LOOKUP", separator)); separator = '|'; } if (access_flags & NFSV3ACCESS_MODIFY) { ND_PRINT((ndo, "%cNFS_ACCESS_MODIFY", separator)); separator = '|'; } if (access_flags & NFSV3ACCESS_EXTEND) { ND_PRINT((ndo, "%cNFS_ACCESS_EXTEND", separator)); separator = '|'; } if (access_flags & NFSV3ACCESS_DELETE) { ND_PRINT((ndo, "%cNFS_ACCESS_DELETE", separator)); separator = '|'; } if (access_flags & NFSV3ACCESS_EXECUTE) ND_PRINT((ndo, "%cNFS_ACCESS_EXECUTE", separator)); } return; } break; case NFSPROC_READ: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { if (v3) { ND_TCHECK(dp[2]); ND_PRINT((ndo, " %u bytes @ %" PRIu64, EXTRACT_32BITS(&dp[2]), EXTRACT_64BITS(&dp[0]))); } else { ND_TCHECK(dp[1]); ND_PRINT((ndo, " %u bytes @ %u", EXTRACT_32BITS(&dp[1]), EXTRACT_32BITS(&dp[0]))); } return; } break; case NFSPROC_WRITE: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { if (v3) { ND_TCHECK(dp[4]); ND_PRINT((ndo, " %u (%u) bytes @ %" PRIu64, EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[2]), EXTRACT_64BITS(&dp[0]))); if (ndo->ndo_vflag) { ND_PRINT((ndo, " <%s>", tok2str(nfsv3_writemodes, NULL, EXTRACT_32BITS(&dp[3])))); } } else { ND_TCHECK(dp[3]); ND_PRINT((ndo, " %u (%u) bytes @ %u (%u)", EXTRACT_32BITS(&dp[3]), EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[1]), EXTRACT_32BITS(&dp[0]))); } return; } break; case NFSPROC_SYMLINK: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefhn(ndo, dp, v3)) != NULL) { ND_PRINT((ndo, " ->")); if (v3 && (dp = parse_sattr3(ndo, dp, &sa3)) == NULL) break; if (parsefn(ndo, dp) == NULL) break; if (v3 && ndo->ndo_vflag) print_sattr3(ndo, &sa3, ndo->ndo_vflag); return; } break; case NFSPROC_MKNOD: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefhn(ndo, dp, v3)) != NULL) { ND_TCHECK(*dp); type = (nfs_type)EXTRACT_32BITS(dp); dp++; if ((dp = parse_sattr3(ndo, dp, &sa3)) == NULL) break; ND_PRINT((ndo, " %s", tok2str(type2str, "unk-ft %d", type))); if (ndo->ndo_vflag && (type == NFCHR || type == NFBLK)) { ND_TCHECK(dp[1]); ND_PRINT((ndo, " %u/%u", EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]))); dp += 2; } if (ndo->ndo_vflag) print_sattr3(ndo, &sa3, ndo->ndo_vflag); return; } break; case NFSPROC_RENAME: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefhn(ndo, dp, v3)) != NULL) { ND_PRINT((ndo, " ->")); if (parsefhn(ndo, dp, v3) != NULL) return; } break; case NFSPROC_LINK: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { ND_PRINT((ndo, " ->")); if (parsefhn(ndo, dp, v3) != NULL) return; } break; case NFSPROC_READDIR: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { if (v3) { ND_TCHECK(dp[4]); /* * We shouldn't really try to interpret the * offset cookie here. */ ND_PRINT((ndo, " %u bytes @ %" PRId64, EXTRACT_32BITS(&dp[4]), EXTRACT_64BITS(&dp[0]))); if (ndo->ndo_vflag) ND_PRINT((ndo, " verf %08x%08x", dp[2], dp[3])); } else { ND_TCHECK(dp[1]); /* * Print the offset as signed, since -1 is * common, but offsets > 2^31 aren't. */ ND_PRINT((ndo, " %u bytes @ %d", EXTRACT_32BITS(&dp[1]), EXTRACT_32BITS(&dp[0]))); } return; } break; case NFSPROC_READDIRPLUS: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { ND_TCHECK(dp[4]); /* * We don't try to interpret the offset * cookie here. */ ND_PRINT((ndo, " %u bytes @ %" PRId64, EXTRACT_32BITS(&dp[4]), EXTRACT_64BITS(&dp[0]))); if (ndo->ndo_vflag) { ND_TCHECK(dp[5]); ND_PRINT((ndo, " max %u verf %08x%08x", EXTRACT_32BITS(&dp[5]), dp[2], dp[3])); } return; } break; case NFSPROC_COMMIT: if ((dp = parsereq(ndo, rp, length)) != NULL && (dp = parsefh(ndo, dp, v3)) != NULL) { ND_TCHECK(dp[2]); ND_PRINT((ndo, " %u bytes @ %" PRIu64, EXTRACT_32BITS(&dp[2]), EXTRACT_64BITS(&dp[0]))); return; } break; default: return; } trunc: if (!nfserr) ND_PRINT((ndo, "%s", tstr)); } /* * Print out an NFS file handle. * We assume packet was not truncated before the end of the * file handle pointed to by dp. * * Note: new version (using portable file-handle parser) doesn't produce * generation number. It probably could be made to do that, with some * additional hacking on the parser code. */ static void nfs_printfh(netdissect_options *ndo, register const uint32_t *dp, const u_int len) { my_fsid fsid; uint32_t ino; const char *sfsname = NULL; char *spacep; if (ndo->ndo_uflag) { u_int i; char const *sep = ""; ND_PRINT((ndo, " fh[")); for (i=0; i NFSX_V3FHMAX) stringlen = NFSX_V3FHMAX; strncpy(temp, sfsname, stringlen); temp[stringlen] = '\0'; /* Remove trailing spaces */ spacep = strchr(temp, ' '); if (spacep) *spacep = '\0'; ND_PRINT((ndo, " fh %s/", temp)); } else { ND_PRINT((ndo, " fh %d,%d/", fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor)); } if(fsid.Fsid_dev.Minor == 257) /* Print the undecoded handle */ ND_PRINT((ndo, "%s", fsid.Opaque_Handle)); else ND_PRINT((ndo, "%ld", (long) ino)); } /* * Maintain a small cache of recent client.XID.server/proc pairs, to allow * us to match up replies with requests and thus to know how to parse * the reply. */ struct xid_map_entry { uint32_t xid; /* transaction ID (net order) */ int ipver; /* IP version (4 or 6) */ struct in6_addr client; /* client IP address (net order) */ struct in6_addr server; /* server IP address (net order) */ uint32_t proc; /* call proc number (host order) */ uint32_t vers; /* program version (host order) */ }; /* * Map entries are kept in an array that we manage as a ring; * new entries are always added at the tail of the ring. Initially, * all the entries are zero and hence don't match anything. */ #define XIDMAPSIZE 64 static struct xid_map_entry xid_map[XIDMAPSIZE]; static int xid_map_next = 0; static int xid_map_hint = 0; static int xid_map_enter(netdissect_options *ndo, const struct sunrpc_msg *rp, const u_char *bp) { const struct ip *ip = NULL; const struct ip6_hdr *ip6 = NULL; struct xid_map_entry *xmep; if (!ND_TTEST(rp->rm_call.cb_proc)) return (0); switch (IP_V((const struct ip *)bp)) { case 4: ip = (const struct ip *)bp; break; case 6: ip6 = (const struct ip6_hdr *)bp; break; default: return (1); } xmep = &xid_map[xid_map_next]; if (++xid_map_next >= XIDMAPSIZE) xid_map_next = 0; UNALIGNED_MEMCPY(&xmep->xid, &rp->rm_xid, sizeof(xmep->xid)); if (ip) { xmep->ipver = 4; UNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src)); UNALIGNED_MEMCPY(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst)); } else if (ip6) { xmep->ipver = 6; UNALIGNED_MEMCPY(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src)); UNALIGNED_MEMCPY(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst)); } xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc); xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers); return (1); } /* * Returns 0 and puts NFSPROC_xxx in proc return and * version in vers return, or returns -1 on failure */ static int xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc, uint32_t *vers) { int i; struct xid_map_entry *xmep; uint32_t xid; const struct ip *ip = (const struct ip *)bp; const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp; int cmp; UNALIGNED_MEMCPY(&xid, &rp->rm_xid, sizeof(xmep->xid)); /* Start searching from where we last left off */ i = xid_map_hint; do { xmep = &xid_map[i]; cmp = 1; if (xmep->ipver != IP_V(ip) || xmep->xid != xid) goto nextitem; switch (xmep->ipver) { case 4: if (UNALIGNED_MEMCMP(&ip->ip_src, &xmep->server, sizeof(ip->ip_src)) != 0 || UNALIGNED_MEMCMP(&ip->ip_dst, &xmep->client, sizeof(ip->ip_dst)) != 0) { cmp = 0; } break; case 6: if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server, sizeof(ip6->ip6_src)) != 0 || UNALIGNED_MEMCMP(&ip6->ip6_dst, &xmep->client, sizeof(ip6->ip6_dst)) != 0) { cmp = 0; } break; default: cmp = 0; break; } if (cmp) { /* match */ xid_map_hint = i; *proc = xmep->proc; *vers = xmep->vers; return 0; } nextitem: if (++i >= XIDMAPSIZE) i = 0; } while (i != xid_map_hint); /* search failed */ return (-1); } /* * Routines for parsing reply packets */ /* * Return a pointer to the beginning of the actual results. * If the packet was truncated, return 0. */ static const uint32_t * parserep(netdissect_options *ndo, register const struct sunrpc_msg *rp, register u_int length) { register const uint32_t *dp; u_int len; enum sunrpc_accept_stat astat; /* * Portability note: * Here we find the address of the ar_verf credentials. * Originally, this calculation was * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf * On the wire, the rp_acpt field starts immediately after * the (32 bit) rp_stat field. However, rp_acpt (which is a * "struct accepted_reply") contains a "struct opaque_auth", * whose internal representation contains a pointer, so on a * 64-bit machine the compiler inserts 32 bits of padding * before rp->rm_reply.rp_acpt.ar_verf. So, we cannot use * the internal representation to parse the on-the-wire * representation. Instead, we skip past the rp_stat field, * which is an "enum" and so occupies one 32-bit word. */ dp = ((const uint32_t *)&rp->rm_reply) + 1; ND_TCHECK(dp[1]); len = EXTRACT_32BITS(&dp[1]); if (len >= length) return (NULL); /* * skip past the ar_verf credentials. */ dp += (len + (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t); /* * now we can check the ar_stat field */ ND_TCHECK(dp[0]); astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp); if (astat != SUNRPC_SUCCESS) { ND_PRINT((ndo, " %s", tok2str(sunrpc_str, "ar_stat %d", astat))); nfserr = 1; /* suppress trunc string */ return (NULL); } /* successful return */ ND_TCHECK2(*dp, sizeof(astat)); return ((const uint32_t *) (sizeof(astat) + ((const char *)dp))); trunc: return (0); } static const uint32_t * parsestatus(netdissect_options *ndo, const uint32_t *dp, int *er) { int errnum; ND_TCHECK(dp[0]); errnum = EXTRACT_32BITS(&dp[0]); if (er) *er = errnum; if (errnum != 0) { if (!ndo->ndo_qflag) ND_PRINT((ndo, " ERROR: %s", tok2str(status2str, "unk %d", errnum))); nfserr = 1; } return (dp + 1); trunc: return NULL; } static const uint32_t * parsefattr(netdissect_options *ndo, const uint32_t *dp, int verbose, int v3) { const struct nfs_fattr *fap; fap = (const struct nfs_fattr *)dp; ND_TCHECK(fap->fa_gid); if (verbose) { ND_PRINT((ndo, " %s %o ids %d/%d", tok2str(type2str, "unk-ft %d ", EXTRACT_32BITS(&fap->fa_type)), EXTRACT_32BITS(&fap->fa_mode), EXTRACT_32BITS(&fap->fa_uid), EXTRACT_32BITS(&fap->fa_gid))); if (v3) { ND_TCHECK(fap->fa3_size); ND_PRINT((ndo, " sz %" PRIu64, EXTRACT_64BITS((const uint32_t *)&fap->fa3_size))); } else { ND_TCHECK(fap->fa2_size); ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size))); } } /* print lots more stuff */ if (verbose > 1) { if (v3) { ND_TCHECK(fap->fa3_ctime); ND_PRINT((ndo, " nlink %d rdev %d/%d", EXTRACT_32BITS(&fap->fa_nlink), EXTRACT_32BITS(&fap->fa3_rdev.specdata1), EXTRACT_32BITS(&fap->fa3_rdev.specdata2))); ND_PRINT((ndo, " fsid %" PRIx64, EXTRACT_64BITS((const uint32_t *)&fap->fa3_fsid))); ND_PRINT((ndo, " fileid %" PRIx64, EXTRACT_64BITS((const uint32_t *)&fap->fa3_fileid))); ND_PRINT((ndo, " a/m/ctime %u.%06u", EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec), EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec))); ND_PRINT((ndo, " %u.%06u", EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec), EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec))); ND_PRINT((ndo, " %u.%06u", EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec), EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec))); } else { ND_TCHECK(fap->fa2_ctime); ND_PRINT((ndo, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime", EXTRACT_32BITS(&fap->fa_nlink), EXTRACT_32BITS(&fap->fa2_rdev), EXTRACT_32BITS(&fap->fa2_fsid), EXTRACT_32BITS(&fap->fa2_fileid))); ND_PRINT((ndo, " %u.%06u", EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec), EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec))); ND_PRINT((ndo, " %u.%06u", EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec), EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec))); ND_PRINT((ndo, " %u.%06u", EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec), EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec))); } } return ((const uint32_t *)((const unsigned char *)dp + (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); trunc: return (NULL); } static int parseattrstat(netdissect_options *ndo, const uint32_t *dp, int verbose, int v3) { int er; dp = parsestatus(ndo, dp, &er); if (dp == NULL) return (0); if (er) return (1); return (parsefattr(ndo, dp, verbose, v3) != NULL); } static int parsediropres(netdissect_options *ndo, const uint32_t *dp) { int er; if (!(dp = parsestatus(ndo, dp, &er))) return (0); if (er) return (1); dp = parsefh(ndo, dp, 0); if (dp == NULL) return (0); return (parsefattr(ndo, dp, ndo->ndo_vflag, 0) != NULL); } static int parselinkres(netdissect_options *ndo, const uint32_t *dp, int v3) { int er; dp = parsestatus(ndo, dp, &er); if (dp == NULL) return(0); if (er) return(1); if (v3 && !(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) return (0); ND_PRINT((ndo, " ")); return (parsefn(ndo, dp) != NULL); } static int parsestatfs(netdissect_options *ndo, const uint32_t *dp, int v3) { const struct nfs_statfs *sfsp; int er; dp = parsestatus(ndo, dp, &er); if (dp == NULL) return (0); if (!v3 && er) return (1); if (ndo->ndo_qflag) return(1); if (v3) { if (ndo->ndo_vflag) ND_PRINT((ndo, " POST:")); if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) return (0); } ND_TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); sfsp = (const struct nfs_statfs *)dp; if (v3) { ND_PRINT((ndo, " tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64, EXTRACT_64BITS((const uint32_t *)&sfsp->sf_tbytes), EXTRACT_64BITS((const uint32_t *)&sfsp->sf_fbytes), EXTRACT_64BITS((const uint32_t *)&sfsp->sf_abytes))); if (ndo->ndo_vflag) { ND_PRINT((ndo, " tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u", EXTRACT_64BITS((const uint32_t *)&sfsp->sf_tfiles), EXTRACT_64BITS((const uint32_t *)&sfsp->sf_ffiles), EXTRACT_64BITS((const uint32_t *)&sfsp->sf_afiles), EXTRACT_32BITS(&sfsp->sf_invarsec))); } } else { ND_PRINT((ndo, " tsize %d bsize %d blocks %d bfree %d bavail %d", EXTRACT_32BITS(&sfsp->sf_tsize), EXTRACT_32BITS(&sfsp->sf_bsize), EXTRACT_32BITS(&sfsp->sf_blocks), EXTRACT_32BITS(&sfsp->sf_bfree), EXTRACT_32BITS(&sfsp->sf_bavail))); } return (1); trunc: return (0); } static int parserddires(netdissect_options *ndo, const uint32_t *dp) { int er; dp = parsestatus(ndo, dp, &er); if (dp == NULL) return (0); if (er) return (1); if (ndo->ndo_qflag) return (1); ND_TCHECK(dp[2]); ND_PRINT((ndo, " offset 0x%x size %d ", EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]))); if (dp[2] != 0) ND_PRINT((ndo, " eof")); return (1); trunc: return (0); } static const uint32_t * parse_wcc_attr(netdissect_options *ndo, const uint32_t *dp) { /* Our caller has already checked this */ ND_PRINT((ndo, " sz %" PRIu64, EXTRACT_64BITS(&dp[0]))); ND_PRINT((ndo, " mtime %u.%06u ctime %u.%06u", EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]), EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]))); return (dp + 6); } /* * Pre operation attributes. Print only if vflag > 1. */ static const uint32_t * parse_pre_op_attr(netdissect_options *ndo, const uint32_t *dp, int verbose) { ND_TCHECK(dp[0]); if (!EXTRACT_32BITS(&dp[0])) return (dp + 1); dp++; ND_TCHECK2(*dp, 24); if (verbose > 1) { return parse_wcc_attr(ndo, dp); } else { /* If not verbose enough, just skip over wcc_attr */ return (dp + 6); } trunc: return (NULL); } /* * Post operation attributes are printed if vflag >= 1 */ static const uint32_t * parse_post_op_attr(netdissect_options *ndo, const uint32_t *dp, int verbose) { ND_TCHECK(dp[0]); if (!EXTRACT_32BITS(&dp[0])) return (dp + 1); dp++; if (verbose) { return parsefattr(ndo, dp, verbose, 1); } else return (dp + (NFSX_V3FATTR / sizeof (uint32_t))); trunc: return (NULL); } static const uint32_t * parse_wcc_data(netdissect_options *ndo, const uint32_t *dp, int verbose) { if (verbose > 1) ND_PRINT((ndo, " PRE:")); if (!(dp = parse_pre_op_attr(ndo, dp, verbose))) return (0); if (verbose) ND_PRINT((ndo, " POST:")); return parse_post_op_attr(ndo, dp, verbose); } static const uint32_t * parsecreateopres(netdissect_options *ndo, const uint32_t *dp, int verbose) { int er; if (!(dp = parsestatus(ndo, dp, &er))) return (0); if (er) dp = parse_wcc_data(ndo, dp, verbose); else { ND_TCHECK(dp[0]); if (!EXTRACT_32BITS(&dp[0])) return (dp + 1); dp++; if (!(dp = parsefh(ndo, dp, 1))) return (0); if (verbose) { if (!(dp = parse_post_op_attr(ndo, dp, verbose))) return (0); if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, " dir attr:")); dp = parse_wcc_data(ndo, dp, verbose); } } } return (dp); trunc: return (NULL); } static int parsewccres(netdissect_options *ndo, const uint32_t *dp, int verbose) { int er; if (!(dp = parsestatus(ndo, dp, &er))) return (0); return parse_wcc_data(ndo, dp, verbose) != NULL; } static const uint32_t * parsev3rddirres(netdissect_options *ndo, const uint32_t *dp, int verbose) { int er; if (!(dp = parsestatus(ndo, dp, &er))) return (0); if (ndo->ndo_vflag) ND_PRINT((ndo, " POST:")); if (!(dp = parse_post_op_attr(ndo, dp, verbose))) return (0); if (er) return dp; if (ndo->ndo_vflag) { ND_TCHECK(dp[1]); ND_PRINT((ndo, " verf %08x%08x", dp[0], dp[1])); dp += 2; } return dp; trunc: return (NULL); } static int parsefsinfo(netdissect_options *ndo, const uint32_t *dp) { const struct nfsv3_fsinfo *sfp; int er; if (!(dp = parsestatus(ndo, dp, &er))) return (0); if (ndo->ndo_vflag) ND_PRINT((ndo, " POST:")); if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) return (0); if (er) return (1); sfp = (const struct nfsv3_fsinfo *)dp; ND_TCHECK(*sfp); ND_PRINT((ndo, " rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u", EXTRACT_32BITS(&sfp->fs_rtmax), EXTRACT_32BITS(&sfp->fs_rtpref), EXTRACT_32BITS(&sfp->fs_wtmax), EXTRACT_32BITS(&sfp->fs_wtpref), EXTRACT_32BITS(&sfp->fs_dtpref))); if (ndo->ndo_vflag) { ND_PRINT((ndo, " rtmult %u wtmult %u maxfsz %" PRIu64, EXTRACT_32BITS(&sfp->fs_rtmult), EXTRACT_32BITS(&sfp->fs_wtmult), EXTRACT_64BITS((const uint32_t *)&sfp->fs_maxfilesize))); ND_PRINT((ndo, " delta %u.%06u ", EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec), EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec))); } return (1); trunc: return (0); } static int parsepathconf(netdissect_options *ndo, const uint32_t *dp) { int er; const struct nfsv3_pathconf *spp; if (!(dp = parsestatus(ndo, dp, &er))) return (0); if (ndo->ndo_vflag) ND_PRINT((ndo, " POST:")); if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) return (0); if (er) return (1); spp = (const struct nfsv3_pathconf *)dp; ND_TCHECK(*spp); ND_PRINT((ndo, " linkmax %u namemax %u %s %s %s %s", EXTRACT_32BITS(&spp->pc_linkmax), EXTRACT_32BITS(&spp->pc_namemax), EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "", EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "", EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "", EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "")); return (1); trunc: return (0); } static void interp_reply(netdissect_options *ndo, const struct sunrpc_msg *rp, uint32_t proc, uint32_t vers, int length) { register const uint32_t *dp; register int v3; int er; v3 = (vers == NFS_VER3); if (!v3 && proc < NFS_NPROCS) proc = nfsv3_procid[proc]; ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc))); switch (proc) { case NFSPROC_GETATTR: dp = parserep(ndo, rp, length); if (dp != NULL && parseattrstat(ndo, dp, !ndo->ndo_qflag, v3) != 0) return; break; case NFSPROC_SETATTR: if (!(dp = parserep(ndo, rp, length))) return; if (v3) { if (parsewccres(ndo, dp, ndo->ndo_vflag)) return; } else { if (parseattrstat(ndo, dp, !ndo->ndo_qflag, 0) != 0) return; } break; case NFSPROC_LOOKUP: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (!(dp = parsestatus(ndo, dp, &er))) break; if (er) { if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, " post dattr:")); dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag); } } else { if (!(dp = parsefh(ndo, dp, v3))) break; if ((dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)) && ndo->ndo_vflag > 1) { ND_PRINT((ndo, " post dattr:")); dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag); } } if (dp) return; } else { if (parsediropres(ndo, dp) != 0) return; } break; case NFSPROC_ACCESS: if (!(dp = parserep(ndo, rp, length))) break; if (!(dp = parsestatus(ndo, dp, &er))) break; if (ndo->ndo_vflag) ND_PRINT((ndo, " attr:")); if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) break; if (!er) { ND_TCHECK(dp[0]); ND_PRINT((ndo, " c %04x", EXTRACT_32BITS(&dp[0]))); } return; case NFSPROC_READLINK: dp = parserep(ndo, rp, length); if (dp != NULL && parselinkres(ndo, dp, v3) != 0) return; break; case NFSPROC_READ: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (!(dp = parsestatus(ndo, dp, &er))) break; if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) break; if (er) return; if (ndo->ndo_vflag) { ND_TCHECK(dp[1]); ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0]))); if (EXTRACT_32BITS(&dp[1])) ND_PRINT((ndo, " EOF")); } return; } else { if (parseattrstat(ndo, dp, ndo->ndo_vflag, 0) != 0) return; } break; case NFSPROC_WRITE: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (!(dp = parsestatus(ndo, dp, &er))) break; if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag))) break; if (er) return; if (ndo->ndo_vflag) { ND_TCHECK(dp[0]); ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0]))); if (ndo->ndo_vflag > 1) { ND_TCHECK(dp[1]); ND_PRINT((ndo, " <%s>", tok2str(nfsv3_writemodes, NULL, EXTRACT_32BITS(&dp[1])))); } - return; } + return; } else { if (parseattrstat(ndo, dp, ndo->ndo_vflag, v3) != 0) return; } break; case NFSPROC_CREATE: case NFSPROC_MKDIR: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL) return; } else { if (parsediropres(ndo, dp) != 0) return; } break; case NFSPROC_SYMLINK: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL) return; } else { if (parsestatus(ndo, dp, &er) != NULL) return; } break; case NFSPROC_MKNOD: if (!(dp = parserep(ndo, rp, length))) break; if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL) return; break; case NFSPROC_REMOVE: case NFSPROC_RMDIR: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (parsewccres(ndo, dp, ndo->ndo_vflag)) return; } else { if (parsestatus(ndo, dp, &er) != NULL) return; } break; case NFSPROC_RENAME: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (!(dp = parsestatus(ndo, dp, &er))) break; if (ndo->ndo_vflag) { ND_PRINT((ndo, " from:")); if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag))) break; ND_PRINT((ndo, " to:")); if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag))) break; } return; } else { if (parsestatus(ndo, dp, &er) != NULL) return; } break; case NFSPROC_LINK: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (!(dp = parsestatus(ndo, dp, &er))) break; if (ndo->ndo_vflag) { ND_PRINT((ndo, " file POST:")); if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag))) break; ND_PRINT((ndo, " dir:")); if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag))) break; - return; } + return; } else { if (parsestatus(ndo, dp, &er) != NULL) return; } break; case NFSPROC_READDIR: if (!(dp = parserep(ndo, rp, length))) break; if (v3) { if (parsev3rddirres(ndo, dp, ndo->ndo_vflag)) return; } else { if (parserddires(ndo, dp) != 0) return; } break; case NFSPROC_READDIRPLUS: if (!(dp = parserep(ndo, rp, length))) break; if (parsev3rddirres(ndo, dp, ndo->ndo_vflag)) return; break; case NFSPROC_FSSTAT: dp = parserep(ndo, rp, length); if (dp != NULL && parsestatfs(ndo, dp, v3) != 0) return; break; case NFSPROC_FSINFO: dp = parserep(ndo, rp, length); if (dp != NULL && parsefsinfo(ndo, dp) != 0) return; break; case NFSPROC_PATHCONF: dp = parserep(ndo, rp, length); if (dp != NULL && parsepathconf(ndo, dp) != 0) return; break; case NFSPROC_COMMIT: dp = parserep(ndo, rp, length); if (dp != NULL && parsewccres(ndo, dp, ndo->ndo_vflag) != 0) return; break; default: return; } trunc: if (!nfserr) ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-openflow.c =================================================================== --- vendor/tcpdump/dist/print-openflow.c (revision 353143) +++ vendor/tcpdump/dist/print-openflow.c (revision 353144) @@ -1,142 +1,140 @@ /* * This module implements printing of the very basic (version-independent) * OpenFlow header and iteration over OpenFlow messages. It is intended for * dispatching of version-specific OpenFlow message decoding. * * * Copyright (c) 2013 The TCPDUMP project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* \summary: version-independent OpenFlow printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "openflow.h" #include "oui.h" static const char tstr[] = " [|openflow]"; #define OF_VER_1_0 0x01 const struct tok onf_exp_str[] = { { ONF_EXP_ONF, "ONF Extensions" }, { ONF_EXP_BUTE, "Budapest University of Technology and Economics" }, { ONF_EXP_NOVIFLOW, "NoviFlow" }, { ONF_EXP_L3, "L3+ Extensions, Vendor Neutral" }, { ONF_EXP_L4L7, "L4-L7 Extensions" }, { ONF_EXP_WMOB, "Wireless and Mobility Extensions" }, { ONF_EXP_FABS, "Forwarding Abstractions Extensions" }, { ONF_EXP_OTRANS, "Optical Transport Extensions" }, { 0, NULL } }; const char * of_vendor_name(const uint32_t vendor) { const struct tok *table = (vendor & 0xff000000) == 0 ? oui_values : onf_exp_str; return tok2str(table, "unknown", vendor); } static void of_header_print(netdissect_options *ndo, const uint8_t version, const uint8_t type, const uint16_t length, const uint32_t xid) { ND_PRINT((ndo, "\n\tversion unknown (0x%02x), type 0x%02x, length %u, xid 0x%08x", version, type, length, xid)); } /* Print a single OpenFlow message. */ static const u_char * of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) { uint8_t version, type; uint16_t length; uint32_t xid; if (ep < cp + OF_HEADER_LEN) goto invalid; /* version */ ND_TCHECK2(*cp, 1); version = *cp; cp += 1; /* type */ ND_TCHECK2(*cp, 1); type = *cp; cp += 1; /* length */ ND_TCHECK2(*cp, 2); length = EXTRACT_16BITS(cp); cp += 2; /* xid */ ND_TCHECK2(*cp, 4); xid = EXTRACT_32BITS(cp); cp += 4; /* Message length includes the header length and a message always includes * the basic header. A message length underrun fails decoding of the rest of * the current packet. At the same time, try decoding as much of the current * message as possible even when it does not end within the current TCP * segment. */ if (length < OF_HEADER_LEN) { of_header_print(ndo, version, type, length, xid); goto invalid; } /* Decode known protocol versions further without printing the header (the * type decoding is version-specific. */ switch (version) { case OF_VER_1_0: return of10_header_body_print(ndo, cp, ep, type, length, xid); default: of_header_print(ndo, version, type, length, xid); ND_TCHECK2(*cp, length - OF_HEADER_LEN); return cp + length - OF_HEADER_LEN; /* done with current message */ } invalid: /* fail current packet */ ND_PRINT((ndo, "%s", istr)); ND_TCHECK2(*cp, ep - cp); return ep; trunc: ND_PRINT((ndo, "%s", tstr)); return ep; } /* Print a TCP segment worth of OpenFlow messages presuming the segment begins * on a message boundary. */ void -openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len) +openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len _U_) { - const u_char *ep = cp + len; - ND_PRINT((ndo, ": OpenFlow")); - while (cp < ep) - cp = of_header_body_print(ndo, cp, ep); + while (cp < ndo->ndo_snapend) + cp = of_header_body_print(ndo, cp, ndo->ndo_snapend); } Index: vendor/tcpdump/dist/print-ospf.c =================================================================== --- vendor/tcpdump/dist/print-ospf.c (revision 353143) +++ vendor/tcpdump/dist/print-ospf.c (revision 353144) @@ -1,1209 +1,1209 @@ /* * Copyright (c) 1992, 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. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ /* \summary: Open Shortest Path First (OSPF) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "gmpls.h" #include "ospf.h" static const char tstr[] = " [|ospf2]"; static const struct tok ospf_option_values[] = { { OSPF_OPTION_T, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */ { OSPF_OPTION_E, "External" }, { OSPF_OPTION_MC, "Multicast" }, { OSPF_OPTION_NP, "NSSA" }, { OSPF_OPTION_L, "LLS" }, { OSPF_OPTION_DC, "Demand Circuit" }, { OSPF_OPTION_O, "Opaque" }, { OSPF_OPTION_DN, "Up/Down" }, { 0, NULL } }; static const struct tok ospf_authtype_values[] = { { OSPF_AUTH_NONE, "none" }, { OSPF_AUTH_SIMPLE, "simple" }, { OSPF_AUTH_MD5, "MD5" }, { 0, NULL } }; static const struct tok ospf_rla_flag_values[] = { { RLA_FLAG_B, "ABR" }, { RLA_FLAG_E, "ASBR" }, { RLA_FLAG_W1, "Virtual" }, { RLA_FLAG_W2, "W2" }, { 0, NULL } }; static const struct tok type2str[] = { { OSPF_TYPE_UMD, "UMD" }, { OSPF_TYPE_HELLO, "Hello" }, { OSPF_TYPE_DD, "Database Description" }, { OSPF_TYPE_LS_REQ, "LS-Request" }, { OSPF_TYPE_LS_UPDATE, "LS-Update" }, { OSPF_TYPE_LS_ACK, "LS-Ack" }, { 0, NULL } }; static const struct tok lsa_values[] = { { LS_TYPE_ROUTER, "Router" }, { LS_TYPE_NETWORK, "Network" }, { LS_TYPE_SUM_IP, "Summary" }, { LS_TYPE_SUM_ABR, "ASBR Summary" }, { LS_TYPE_ASE, "External" }, { LS_TYPE_GROUP, "Multicast Group" }, { LS_TYPE_NSSA, "NSSA" }, { LS_TYPE_OPAQUE_LL, "Link Local Opaque" }, { LS_TYPE_OPAQUE_AL, "Area Local Opaque" }, { LS_TYPE_OPAQUE_DW, "Domain Wide Opaque" }, { 0, NULL } }; static const struct tok ospf_dd_flag_values[] = { { OSPF_DB_INIT, "Init" }, { OSPF_DB_MORE, "More" }, { OSPF_DB_MASTER, "Master" }, { OSPF_DB_RESYNC, "OOBResync" }, { 0, NULL } }; static const struct tok lsa_opaque_values[] = { { LS_OPAQUE_TYPE_TE, "Traffic Engineering" }, { LS_OPAQUE_TYPE_GRACE, "Graceful restart" }, { LS_OPAQUE_TYPE_RI, "Router Information" }, { 0, NULL } }; static const struct tok lsa_opaque_te_tlv_values[] = { { LS_OPAQUE_TE_TLV_ROUTER, "Router Address" }, { LS_OPAQUE_TE_TLV_LINK, "Link" }, { 0, NULL } }; static const struct tok lsa_opaque_te_link_tlv_subtlv_values[] = { { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE, "Link Type" }, { LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID, "Link ID" }, { LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP, "Local Interface IP address" }, { LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP, "Remote Interface IP address" }, { LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC, "Traffic Engineering Metric" }, { LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW, "Maximum Bandwidth" }, { LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW, "Maximum Reservable Bandwidth" }, { LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW, "Unreserved Bandwidth" }, { LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP, "Administrative Group" }, { LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" }, { LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE, "Link Protection Type" }, { LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR, "Interface Switching Capability" }, { LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP, "Shared Risk Link Group" }, { LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS, "Bandwidth Constraints" }, { 0, NULL } }; static const struct tok lsa_opaque_grace_tlv_values[] = { { LS_OPAQUE_GRACE_TLV_PERIOD, "Grace Period" }, { LS_OPAQUE_GRACE_TLV_REASON, "Graceful restart Reason" }, { LS_OPAQUE_GRACE_TLV_INT_ADDRESS, "IPv4 interface address" }, { 0, NULL } }; static const struct tok lsa_opaque_grace_tlv_reason_values[] = { { LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN, "Unknown" }, { LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART, "Software Restart" }, { LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE, "Software Reload/Upgrade" }, { LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH, "Control Processor Switch" }, { 0, NULL } }; static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = { { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" }, { LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA, "Multi-Access" }, { 0, NULL } }; static const struct tok lsa_opaque_ri_tlv_values[] = { { LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" }, { 0, NULL } }; static const struct tok lsa_opaque_ri_tlv_cap_values[] = { { 1, "Reserved" }, { 2, "Reserved" }, { 4, "Reserved" }, { 8, "Reserved" }, { 16, "graceful restart capable" }, { 32, "graceful restart helper" }, { 64, "Stub router support" }, { 128, "Traffic engineering" }, { 256, "p2p over LAN" }, { 512, "path computation server" }, { 0, NULL } }; static const struct tok ospf_lls_tlv_values[] = { { OSPF_LLS_EO, "Extended Options" }, { OSPF_LLS_MD5, "MD5 Authentication" }, { 0, NULL } }; static const struct tok ospf_lls_eo_options[] = { { OSPF_LLS_EO_LR, "LSDB resync" }, { OSPF_LLS_EO_RS, "Restart" }, { 0, NULL } }; int ospf_print_grace_lsa(netdissect_options *ndo, const uint8_t *tptr, u_int ls_length) { u_int tlv_type, tlv_length; while (ls_length > 0) { ND_TCHECK2(*tptr, 4); if (ls_length < 4) { ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length)); return -1; } tlv_type = EXTRACT_16BITS(tptr); tlv_length = EXTRACT_16BITS(tptr+2); tptr+=4; ls_length-=4; ND_PRINT((ndo, "\n\t %s TLV (%u), length %u, value: ", tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type), tlv_type, tlv_length)); if (tlv_length > ls_length) { ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length, ls_length)); return -1; } /* Infinite loop protection. */ if (tlv_type == 0 || tlv_length ==0) { return -1; } ND_TCHECK2(*tptr, tlv_length); switch(tlv_type) { case LS_OPAQUE_GRACE_TLV_PERIOD: if (tlv_length != 4) { ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length)); return -1; } ND_PRINT((ndo, "%us", EXTRACT_32BITS(tptr))); break; case LS_OPAQUE_GRACE_TLV_REASON: if (tlv_length != 1) { ND_PRINT((ndo, "\n\t Bogus length %u != 1", tlv_length)); return -1; } ND_PRINT((ndo, "%s (%u)", tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr), *tptr)); break; case LS_OPAQUE_GRACE_TLV_INT_ADDRESS: if (tlv_length != 4) { ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length)); return -1; } ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr))); break; default: if (ndo->ndo_vflag <= 1) { if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length)) return -1; } break; } /* in OSPF everything has to be 32-bit aligned, including TLVs */ if (tlv_length%4 != 0) tlv_length+=4-(tlv_length%4); ls_length-=tlv_length; tptr+=tlv_length; } return 0; trunc: return -1; } int ospf_print_te_lsa(netdissect_options *ndo, const uint8_t *tptr, u_int ls_length) { u_int tlv_type, tlv_length, subtlv_type, subtlv_length; u_int priority_level, te_class, count_srlg; union { /* int to float conversion buffer for several subTLVs */ float f; uint32_t i; } bw; while (ls_length != 0) { ND_TCHECK2(*tptr, 4); if (ls_length < 4) { ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length)); return -1; } tlv_type = EXTRACT_16BITS(tptr); tlv_length = EXTRACT_16BITS(tptr+2); tptr+=4; ls_length-=4; ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u", tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type), tlv_type, tlv_length)); if (tlv_length > ls_length) { ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length, ls_length)); return -1; } /* Infinite loop protection. */ if (tlv_type == 0 || tlv_length ==0) { return -1; } switch(tlv_type) { case LS_OPAQUE_TE_TLV_LINK: while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) { if (tlv_length < 4) { ND_PRINT((ndo, "\n\t Remaining TLV length %u < 4", tlv_length)); return -1; } ND_TCHECK2(*tptr, 4); subtlv_type = EXTRACT_16BITS(tptr); subtlv_length = EXTRACT_16BITS(tptr+2); tptr+=4; tlv_length-=4; /* Infinite loop protection */ if (subtlv_type == 0 || subtlv_length == 0) goto invalid; ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u", tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type), subtlv_type, subtlv_length)); ND_TCHECK2(*tptr, subtlv_length); switch(subtlv_type) { case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP: if (subtlv_length != 4) { ND_PRINT((ndo, " != 4")); goto invalid; } ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr))); break; case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID: case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID: if (subtlv_length != 4 && subtlv_length != 8) { ND_PRINT((ndo, " != 4 && != 8")); goto invalid; } ND_PRINT((ndo, ", %s (0x%08x)", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr))); if (subtlv_length == 8) /* rfc4203 */ ND_PRINT((ndo, ", %s (0x%08x)", ipaddr_string(ndo, tptr+4), EXTRACT_32BITS(tptr + 4))); break; case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP: case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP: if (subtlv_length != 4) { ND_PRINT((ndo, " != 4")); goto invalid; } ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr))); break; case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW: case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW: if (subtlv_length != 4) { ND_PRINT((ndo, " != 4")); goto invalid; } bw.i = EXTRACT_32BITS(tptr); ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000)); break; case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW: if (subtlv_length != 32) { ND_PRINT((ndo, " != 32")); goto invalid; } for (te_class = 0; te_class < 8; te_class++) { bw.i = EXTRACT_32BITS(tptr+te_class*4); ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps", te_class, bw.f * 8 / 1000000)); } break; case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS: if (subtlv_length < 4) { ND_PRINT((ndo, " < 4")); goto invalid; } /* BC Model Id (1 octet) + Reserved (3 octets) */ ND_PRINT((ndo, "\n\t\tBandwidth Constraints Model ID: %s (%u)", tok2str(diffserv_te_bc_values, "unknown", *tptr), *tptr)); if (subtlv_length % 4 != 0) { ND_PRINT((ndo, "\n\t\tlength %u != N x 4", subtlv_length)); goto invalid; } if (subtlv_length > 36) { ND_PRINT((ndo, "\n\t\tlength %u > 36", subtlv_length)); goto invalid; } /* decode BCs until the subTLV ends */ for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) { bw.i = EXTRACT_32BITS(tptr+4+te_class*4); ND_PRINT((ndo, "\n\t\t Bandwidth constraint CT%u: %.3f Mbps", te_class, bw.f * 8 / 1000000)); } break; case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC: if (subtlv_length != 4) { ND_PRINT((ndo, " != 4")); goto invalid; } ND_PRINT((ndo, ", Metric %u", EXTRACT_32BITS(tptr))); break; case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE: /* Protection Cap (1 octet) + Reserved ((3 octets) */ if (subtlv_length != 4) { ND_PRINT((ndo, " != 4")); goto invalid; } ND_PRINT((ndo, ", %s", bittok2str(gmpls_link_prot_values, "none", *tptr))); break; case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR: if (subtlv_length < 36) { ND_PRINT((ndo, " < 36")); goto invalid; } /* Switching Cap (1 octet) + Encoding (1) + Reserved (2) */ ND_PRINT((ndo, "\n\t\tInterface Switching Capability: %s", tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)))); ND_PRINT((ndo, "\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:", tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1)))); for (priority_level = 0; priority_level < 8; priority_level++) { bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4)); ND_PRINT((ndo, "\n\t\t priority level %d: %.3f Mbps", priority_level, bw.f * 8 / 1000000)); } break; case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE: if (subtlv_length != 1) { ND_PRINT((ndo, " != 1")); goto invalid; } ND_PRINT((ndo, ", %s (%u)", tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr), *tptr)); break; case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP: if (subtlv_length % 4 != 0) { ND_PRINT((ndo, " != N x 4")); goto invalid; } count_srlg = subtlv_length / 4; if (count_srlg != 0) ND_PRINT((ndo, "\n\t\t Shared risk group: ")); while (count_srlg > 0) { bw.i = EXTRACT_32BITS(tptr); ND_PRINT((ndo, "%d", bw.i)); tptr+=4; count_srlg--; if (count_srlg > 0) ND_PRINT((ndo, ", ")); } break; default: if (ndo->ndo_vflag <= 1) { if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length)) return -1; } break; } /* in OSPF everything has to be 32-bit aligned, including subTLVs */ if (subtlv_length%4 != 0) subtlv_length+=4-(subtlv_length%4); tlv_length-=subtlv_length; tptr+=subtlv_length; } break; case LS_OPAQUE_TE_TLV_ROUTER: if (tlv_length < 4) { ND_PRINT((ndo, "\n\t TLV length %u < 4", tlv_length)); return -1; } ND_TCHECK2(*tptr, 4); ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr))); break; default: if (ndo->ndo_vflag <= 1) { if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length)) return -1; } break; } /* in OSPF everything has to be 32-bit aligned, including TLVs */ if (tlv_length%4 != 0) tlv_length+=4-(tlv_length%4); ls_length-=tlv_length; tptr+=tlv_length; } return 0; trunc: return -1; invalid: ND_PRINT((ndo, "%s", istr)); return -1; } static int ospf_print_lshdr(netdissect_options *ndo, register const struct lsa_hdr *lshp) { u_int ls_length; ND_TCHECK(lshp->ls_length); ls_length = EXTRACT_16BITS(&lshp->ls_length); if (ls_length < sizeof(struct lsa_hdr)) { ND_PRINT((ndo, "\n\t Bogus length %u < header (%lu)", ls_length, (unsigned long)sizeof(struct lsa_hdr))); return(-1); } ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u", ipaddr_string(ndo, &lshp->ls_router), EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age), ls_length - (u_int)sizeof(struct lsa_hdr))); ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */ switch (lshp->ls_type) { /* the LSA header for opaque LSAs was slightly changed */ case LS_TYPE_OPAQUE_LL: case LS_TYPE_OPAQUE_AL: case LS_TYPE_OPAQUE_DW: ND_PRINT((ndo, "\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u", tok2str(lsa_values,"unknown",lshp->ls_type), lshp->ls_type, tok2str(lsa_opaque_values, "unknown", *(&lshp->un_lsa_id.opaque_field.opaque_type)), *(&lshp->un_lsa_id.opaque_field.opaque_type), EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id) )); break; /* all other LSA types use regular style LSA headers */ default: ND_PRINT((ndo, "\n\t %s LSA (%d), LSA-ID: %s", tok2str(lsa_values,"unknown",lshp->ls_type), lshp->ls_type, ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id))); break; } ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */ ND_PRINT((ndo, "\n\t Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options))); return (ls_length); trunc: return (-1); } /* draft-ietf-ospf-mt-09 */ static const struct tok ospf_topology_values[] = { { 0, "default" }, { 1, "multicast" }, { 2, "management" }, { 0, NULL } }; /* * Print all the per-topology metrics. */ static int ospf_print_tos_metrics(netdissect_options *ndo, const union un_tos *tos) { int metric_count; int toscount; toscount = tos->link.link_tos_count+1; metric_count = 0; /* * All but the first metric contain a valid topology id. */ while (toscount > 0) { ND_TCHECK(*tos); ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u", tok2str(ospf_topology_values, "Unknown", metric_count ? tos->metrics.tos_type : 0), metric_count ? tos->metrics.tos_type : 0, EXTRACT_16BITS(&tos->metrics.tos_metric))); metric_count++; tos++; toscount--; } return 0; trunc: return 1; } /* * Print a single link state advertisement. If truncated or if LSA length * field is less than the length of the LSA header, return NULl, else * return pointer to data past end of LSA. */ static const uint8_t * ospf_print_lsa(netdissect_options *ndo, register const struct lsa *lsap) { register const uint8_t *ls_end; register const struct rlalink *rlp; register const struct in_addr *ap; register const struct aslametric *almp; register const struct mcla *mcp; register const uint32_t *lp; register int j, tlv_type, tlv_length, topology; register int ls_length; const uint8_t *tptr; tptr = (const uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */ ls_length = ospf_print_lshdr(ndo, &lsap->ls_hdr); if (ls_length == -1) return(NULL); ls_end = (const uint8_t *)lsap + ls_length; ls_length -= sizeof(struct lsa_hdr); switch (lsap->ls_hdr.ls_type) { case LS_TYPE_ROUTER: ND_TCHECK(lsap->lsa_un.un_rla.rla_flags); ND_PRINT((ndo, "\n\t Router LSA Options: [%s]", bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags))); ND_TCHECK(lsap->lsa_un.un_rla.rla_count); j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count); ND_TCHECK(lsap->lsa_un.un_rla.rla_link); rlp = lsap->lsa_un.un_rla.rla_link; while (j--) { ND_TCHECK(*rlp); switch (rlp->un_tos.link.link_type) { case RLA_TYPE_VIRTUAL: ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s", ipaddr_string(ndo, &rlp->link_id), ipaddr_string(ndo, &rlp->link_data))); break; case RLA_TYPE_ROUTER: ND_PRINT((ndo, "\n\t Neighbor Router-ID: %s, Interface Address: %s", ipaddr_string(ndo, &rlp->link_id), ipaddr_string(ndo, &rlp->link_data))); break; case RLA_TYPE_TRANSIT: ND_PRINT((ndo, "\n\t Neighbor Network-ID: %s, Interface Address: %s", ipaddr_string(ndo, &rlp->link_id), ipaddr_string(ndo, &rlp->link_data))); break; case RLA_TYPE_STUB: ND_PRINT((ndo, "\n\t Stub Network: %s, Mask: %s", ipaddr_string(ndo, &rlp->link_id), ipaddr_string(ndo, &rlp->link_data))); break; default: ND_PRINT((ndo, "\n\t Unknown Router Link Type (%u)", rlp->un_tos.link.link_type)); return (ls_end); } if (ospf_print_tos_metrics(ndo, &rlp->un_tos)) goto trunc; rlp = (const struct rlalink *)((const u_char *)(rlp + 1) + ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos))); } break; case LS_TYPE_NETWORK: ND_TCHECK(lsap->lsa_un.un_nla.nla_mask); ND_PRINT((ndo, "\n\t Mask %s\n\t Connected Routers:", ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask))); ap = lsap->lsa_un.un_nla.nla_router; while ((const u_char *)ap < ls_end) { ND_TCHECK(*ap); ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap))); ++ap; } break; case LS_TYPE_SUM_IP: ND_TCHECK(lsap->lsa_un.un_nla.nla_mask); ND_PRINT((ndo, "\n\t Mask %s", ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask))); ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; while ((const u_char *)lp < ls_end) { register uint32_t ul; - ND_TCHECK(*lp); + ND_TCHECK_32BITS(lp); ul = EXTRACT_32BITS(lp); topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d", tok2str(ospf_topology_values, "Unknown", topology), topology, ul & SLA_MASK_METRIC)); ++lp; } break; case LS_TYPE_SUM_ABR: ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); lp = lsap->lsa_un.un_sla.sla_tosmetric; while ((const u_char *)lp < ls_end) { register uint32_t ul; - ND_TCHECK(*lp); + ND_TCHECK_32BITS(lp); ul = EXTRACT_32BITS(lp); topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d", tok2str(ospf_topology_values, "Unknown", topology), topology, ul & SLA_MASK_METRIC)); ++lp; } break; case LS_TYPE_ASE: case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask); ND_PRINT((ndo, "\n\t Mask %s", ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask))); ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric); almp = lsap->lsa_un.un_asla.asla_metric; while ((const u_char *)almp < ls_end) { register uint32_t ul; ND_TCHECK(almp->asla_tosmetric); ul = EXTRACT_32BITS(&almp->asla_tosmetric); topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS); ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric", tok2str(ospf_topology_values, "Unknown", topology), topology, (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1)); if ((ul & ASLA_MASK_METRIC) == 0xffffff) ND_PRINT((ndo, " infinite")); else ND_PRINT((ndo, " %d", (ul & ASLA_MASK_METRIC))); ND_TCHECK(almp->asla_forward); if (almp->asla_forward.s_addr) { ND_PRINT((ndo, ", forward %s", ipaddr_string(ndo, &almp->asla_forward))); } ND_TCHECK(almp->asla_tag); if (almp->asla_tag.s_addr) { ND_PRINT((ndo, ", tag %s", ipaddr_string(ndo, &almp->asla_tag))); } ++almp; } break; case LS_TYPE_GROUP: /* Multicast extensions as of 23 July 1991 */ mcp = lsap->lsa_un.un_mcla; while ((const u_char *)mcp < ls_end) { ND_TCHECK(mcp->mcla_vid); switch (EXTRACT_32BITS(&mcp->mcla_vtype)) { case MCLA_VERTEX_ROUTER: ND_PRINT((ndo, "\n\t Router Router-ID %s", ipaddr_string(ndo, &mcp->mcla_vid))); break; case MCLA_VERTEX_NETWORK: ND_PRINT((ndo, "\n\t Network Designated Router %s", ipaddr_string(ndo, &mcp->mcla_vid))); break; default: ND_PRINT((ndo, "\n\t unknown VertexType (%u)", EXTRACT_32BITS(&mcp->mcla_vtype))); break; } ++mcp; } break; case LS_TYPE_OPAQUE_LL: /* fall through */ case LS_TYPE_OPAQUE_AL: case LS_TYPE_OPAQUE_DW: switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) { case LS_OPAQUE_TYPE_RI: tptr = (const uint8_t *)(&lsap->lsa_un.un_ri_tlv.type); while (ls_length != 0) { ND_TCHECK2(*tptr, 4); if (ls_length < 4) { ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length)); return(ls_end); } tlv_type = EXTRACT_16BITS(tptr); tlv_length = EXTRACT_16BITS(tptr+2); tptr+=4; ls_length-=4; ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u, value: ", tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type), tlv_type, tlv_length)); if (tlv_length > ls_length) { ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length, ls_length)); return(ls_end); } ND_TCHECK2(*tptr, tlv_length); switch(tlv_type) { case LS_OPAQUE_RI_TLV_CAP: if (tlv_length != 4) { ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length)); return(ls_end); } ND_PRINT((ndo, "Capabilities: %s", bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr)))); break; default: if (ndo->ndo_vflag <= 1) { if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length)) return(ls_end); } break; } tptr+=tlv_length; ls_length-=tlv_length; } break; case LS_OPAQUE_TYPE_GRACE: if (ospf_print_grace_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_grace_tlv.type), ls_length) == -1) { return(ls_end); } break; case LS_OPAQUE_TYPE_TE: if (ospf_print_te_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type), ls_length) == -1) { return(ls_end); } break; default: if (ndo->ndo_vflag <= 1) { if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown, "\n\t ", ls_length)) return(ls_end); } break; } } /* do we want to see an additionally hexdump ? */ if (ndo->ndo_vflag> 1) if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown, "\n\t ", ls_length)) { return(ls_end); } return (ls_end); trunc: return (NULL); } static int ospf_decode_lls(netdissect_options *ndo, register const struct ospfhdr *op, register u_int length) { register const u_char *dptr; register const u_char *dataend; register u_int length2; register uint16_t lls_type, lls_len; register uint32_t lls_flags; switch (op->ospf_type) { case OSPF_TYPE_HELLO: if (!(op->ospf_hello.hello_options & OSPF_OPTION_L)) return (0); break; case OSPF_TYPE_DD: if (!(op->ospf_db.db_options & OSPF_OPTION_L)) return (0); break; default: return (0); } /* dig deeper if LLS data is available; see RFC4813 */ length2 = EXTRACT_16BITS(&op->ospf_len); dptr = (const u_char *)op + length2; dataend = (const u_char *)op + length; if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) { dptr = dptr + op->ospf_authdata[3]; length2 += op->ospf_authdata[3]; } if (length2 >= length) { ND_PRINT((ndo, "\n\t[LLS truncated]")); return (1); } ND_TCHECK2(*dptr, 2); ND_PRINT((ndo, "\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr))); dptr += 2; ND_TCHECK2(*dptr, 2); length2 = EXTRACT_16BITS(dptr); ND_PRINT((ndo, ", length: %u", length2)); dptr += 2; ND_TCHECK(*dptr); while (dptr < dataend) { ND_TCHECK2(*dptr, 2); lls_type = EXTRACT_16BITS(dptr); ND_PRINT((ndo, "\n\t %s (%u)", tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type), lls_type)); dptr += 2; ND_TCHECK2(*dptr, 2); lls_len = EXTRACT_16BITS(dptr); ND_PRINT((ndo, ", length: %u", lls_len)); dptr += 2; switch (lls_type) { case OSPF_LLS_EO: if (lls_len != 4) { ND_PRINT((ndo, " [should be 4]")); lls_len = 4; } ND_TCHECK2(*dptr, 4); lls_flags = EXTRACT_32BITS(dptr); ND_PRINT((ndo, "\n\t Options: 0x%08x [%s]", lls_flags, bittok2str(ospf_lls_eo_options, "?", lls_flags))); break; case OSPF_LLS_MD5: if (lls_len != 20) { ND_PRINT((ndo, " [should be 20]")); lls_len = 20; } ND_TCHECK2(*dptr, 4); ND_PRINT((ndo, "\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr))); break; } dptr += lls_len; } return (0); trunc: return (1); } static int ospf_decode_v2(netdissect_options *ndo, register const struct ospfhdr *op, register const u_char *dataend) { register const struct in_addr *ap; register const struct lsr *lsrp; register const struct lsa_hdr *lshp; register const struct lsa *lsap; register uint32_t lsa_count,lsa_count_max; switch (op->ospf_type) { case OSPF_TYPE_UMD: /* * Rob Coltun's special monitoring packets; * do nothing */ break; case OSPF_TYPE_HELLO: ND_TCHECK(op->ospf_hello.hello_options); ND_PRINT((ndo, "\n\tOptions [%s]", bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options))); ND_TCHECK(op->ospf_hello.hello_deadint); ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u", EXTRACT_16BITS(&op->ospf_hello.hello_helloint), EXTRACT_32BITS(&op->ospf_hello.hello_deadint), ipaddr_string(ndo, &op->ospf_hello.hello_mask), op->ospf_hello.hello_priority)); ND_TCHECK(op->ospf_hello.hello_dr); if (op->ospf_hello.hello_dr.s_addr != 0) ND_PRINT((ndo, "\n\t Designated Router %s", ipaddr_string(ndo, &op->ospf_hello.hello_dr))); ND_TCHECK(op->ospf_hello.hello_bdr); if (op->ospf_hello.hello_bdr.s_addr != 0) ND_PRINT((ndo, ", Backup Designated Router %s", ipaddr_string(ndo, &op->ospf_hello.hello_bdr))); ap = op->ospf_hello.hello_neighbor; if ((const u_char *)ap < dataend) ND_PRINT((ndo, "\n\t Neighbor List:")); while ((const u_char *)ap < dataend) { ND_TCHECK(*ap); ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap))); ++ap; } break; /* HELLO */ case OSPF_TYPE_DD: ND_TCHECK(op->ospf_db.db_options); ND_PRINT((ndo, "\n\tOptions [%s]", bittok2str(ospf_option_values, "none", op->ospf_db.db_options))); ND_TCHECK(op->ospf_db.db_flags); ND_PRINT((ndo, ", DD Flags [%s]", bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags))); ND_TCHECK(op->ospf_db.db_ifmtu); if (op->ospf_db.db_ifmtu) { ND_PRINT((ndo, ", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu))); } ND_TCHECK(op->ospf_db.db_seq); ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq))); /* Print all the LS adv's */ lshp = op->ospf_db.db_lshdr; while (((const u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) { ++lshp; } break; case OSPF_TYPE_LS_REQ: lsrp = op->ospf_lsr; while ((const u_char *)lsrp < dataend) { ND_TCHECK(*lsrp); ND_PRINT((ndo, "\n\t Advertising Router: %s, %s LSA (%u)", ipaddr_string(ndo, &lsrp->ls_router), tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)), EXTRACT_32BITS(&lsrp->ls_type))); switch (EXTRACT_32BITS(lsrp->ls_type)) { /* the LSA header for opaque LSAs was slightly changed */ case LS_TYPE_OPAQUE_LL: case LS_TYPE_OPAQUE_AL: case LS_TYPE_OPAQUE_DW: ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u", tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type), lsrp->un_ls_stateid.opaque_field.opaque_type, EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id))); break; default: ND_PRINT((ndo, ", LSA-ID: %s", ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid))); break; } ++lsrp; } break; case OSPF_TYPE_LS_UPDATE: lsap = op->ospf_lsu.lsu_lsa; ND_TCHECK(op->ospf_lsu.lsu_count); lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count); ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max))); for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) { ND_PRINT((ndo, "\n\t LSA #%u", lsa_count)); lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap); if (lsap == NULL) goto trunc; } break; case OSPF_TYPE_LS_ACK: lshp = op->ospf_lsa.lsa_lshdr; while (ospf_print_lshdr(ndo, lshp) != -1) { ++lshp; } break; default: break; } return (0); trunc: return (1); } void ospf_print(netdissect_options *ndo, register const u_char *bp, register u_int length, const u_char *bp2 _U_) { register const struct ospfhdr *op; register const u_char *dataend; register const char *cp; op = (const struct ospfhdr *)bp; /* XXX Before we do anything else, strip off the MD5 trailer */ ND_TCHECK(op->ospf_authtype); if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) { length -= OSPF_AUTH_MD5_LEN; ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN; } /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ ND_TCHECK(op->ospf_type); cp = tok2str(type2str, "unknown LS-type", op->ospf_type); ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length)); if (*cp == 'u') return; if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */ return; } ND_TCHECK(op->ospf_len); if (length != EXTRACT_16BITS(&op->ospf_len)) { ND_PRINT((ndo, " [len %d]", EXTRACT_16BITS(&op->ospf_len))); } if (length > EXTRACT_16BITS(&op->ospf_len)) { dataend = bp + EXTRACT_16BITS(&op->ospf_len); } else { dataend = bp + length; } ND_TCHECK(op->ospf_routerid); ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid))); ND_TCHECK(op->ospf_areaid); if (op->ospf_areaid.s_addr != 0) ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf_areaid))); else ND_PRINT((ndo, ", Backbone Area")); if (ndo->ndo_vflag) { /* Print authentication data (should we really do this?) */ ND_TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata)); ND_PRINT((ndo, ", Authentication Type: %s (%u)", tok2str(ospf_authtype_values, "unknown", EXTRACT_16BITS(&op->ospf_authtype)), EXTRACT_16BITS(&op->ospf_authtype))); switch (EXTRACT_16BITS(&op->ospf_authtype)) { case OSPF_AUTH_NONE: break; case OSPF_AUTH_SIMPLE: ND_PRINT((ndo, "\n\tSimple text password: ")); safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN); break; case OSPF_AUTH_MD5: ND_PRINT((ndo, "\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x", *((op->ospf_authdata) + 2), *((op->ospf_authdata) + 3), EXTRACT_32BITS((op->ospf_authdata) + 4))); break; default: return; } } /* Do rest according to version. */ switch (op->ospf_version) { case 2: /* ospf version 2 */ if (ospf_decode_v2(ndo, op, dataend)) goto trunc; if (length > EXTRACT_16BITS(&op->ospf_len)) { if (ospf_decode_lls(ndo, op, length)) goto trunc; } break; default: ND_PRINT((ndo, " ospf [version %d]", op->ospf_version)); break; } /* end switch on version */ return; trunc: ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-ospf6.c =================================================================== --- vendor/tcpdump/dist/print-ospf6.c (revision 353143) +++ vendor/tcpdump/dist/print-ospf6.c (revision 353144) @@ -1,1014 +1,1013 @@ /* * Copyright (c) 1992, 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. * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ /* \summary: IPv6 Open Shortest Path First (OSPFv3) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "ospf.h" #define OSPF_TYPE_HELLO 1 /* Hello */ #define OSPF_TYPE_DD 2 /* Database Description */ #define OSPF_TYPE_LS_REQ 3 /* Link State Request */ #define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */ #define OSPF_TYPE_LS_ACK 5 /* Link State Ack */ /* Options *_options */ #define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */ #define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */ #define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */ #define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */ #define OSPF6_OPTION_R 0x10 /* R bit: Router bit */ #define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */ /* The field is actually 24-bit (RFC5340 Section A.2). */ #define OSPF6_OPTION_AF 0x0100 /* AF bit: Multiple address families */ #define OSPF6_OPTION_L 0x0200 /* L bit: Link-local signaling (LLS) */ #define OSPF6_OPTION_AT 0x0400 /* AT bit: Authentication trailer */ /* db_flags */ #define OSPF6_DB_INIT 0x04 /* */ #define OSPF6_DB_MORE 0x02 #define OSPF6_DB_MASTER 0x01 #define OSPF6_DB_M6 0x10 /* IPv6 MTU */ /* ls_type */ #define LS_TYPE_ROUTER 1 /* router link */ #define LS_TYPE_NETWORK 2 /* network link */ #define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */ #define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */ #define LS_TYPE_ASE 5 /* ASE */ #define LS_TYPE_GROUP 6 /* Group membership */ #define LS_TYPE_NSSA 7 /* NSSA */ #define LS_TYPE_LINK 8 /* Link LSA */ #define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */ #define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */ #define LS_TYPE_GRACE 11 /* Grace LSA */ #define LS_TYPE_RI 12 /* Router information */ #define LS_TYPE_INTER_ASTE 13 /* Inter-AS-TE */ #define LS_TYPE_L1VPN 14 /* L1VPN */ #define LS_TYPE_MASK 0x1fff #define LS_SCOPE_LINKLOCAL 0x0000 #define LS_SCOPE_AREA 0x2000 #define LS_SCOPE_AS 0x4000 #define LS_SCOPE_MASK 0x6000 #define LS_SCOPE_U 0x8000 /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ #define RLA_TYPE_TRANSIT 2 /* connection to transit network */ #define RLA_TYPE_VIRTUAL 4 /* virtual link */ /* rla_flags */ #define RLA_FLAG_B 0x01 #define RLA_FLAG_E 0x02 #define RLA_FLAG_V 0x04 #define RLA_FLAG_W 0x08 #define RLA_FLAG_N 0x10 /* lsa_prefix options */ #define LSA_PREFIX_OPT_NU 0x01 #define LSA_PREFIX_OPT_LA 0x02 #define LSA_PREFIX_OPT_MC 0x04 #define LSA_PREFIX_OPT_P 0x08 #define LSA_PREFIX_OPT_DN 0x10 /* sla_tosmetric breakdown */ #define SLA_MASK_TOS 0x7f000000 #define SLA_MASK_METRIC 0x00ffffff #define SLA_SHIFT_TOS 24 /* asla_metric */ #define ASLA_FLAG_FWDADDR 0x02000000 #define ASLA_FLAG_ROUTETAG 0x01000000 #define ASLA_MASK_METRIC 0x00ffffff /* RFC6506 Section 4.1 */ #define OSPF6_AT_HDRLEN 16U #define OSPF6_AUTH_TYPE_HMAC 0x0001 typedef uint32_t rtrid_t; /* link state advertisement header */ struct lsa6_hdr { uint16_t ls_age; uint16_t ls_type; rtrid_t ls_stateid; rtrid_t ls_router; uint32_t ls_seq; uint16_t ls_chksum; uint16_t ls_length; }; /* Length of an IPv6 address, in bytes. */ #define IPV6_ADDR_LEN_BYTES (128/8) struct lsa6_prefix { uint8_t lsa_p_len; uint8_t lsa_p_opt; uint16_t lsa_p_metric; uint8_t lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */ }; /* link state advertisement */ struct lsa6 { struct lsa6_hdr ls_hdr; /* Link state types */ union { /* Router links advertisements */ struct { union { uint8_t flg; uint32_t opt; } rla_flgandopt; #define rla_flags rla_flgandopt.flg #define rla_options rla_flgandopt.opt struct rlalink6 { uint8_t link_type; uint8_t link_zero[1]; uint16_t link_metric; uint32_t link_ifid; uint32_t link_nifid; rtrid_t link_nrtid; } rla_link[1]; /* may repeat */ } un_rla; /* Network links advertisements */ struct { uint32_t nla_options; rtrid_t nla_router[1]; /* may repeat */ } un_nla; /* Inter Area Prefix LSA */ struct { uint32_t inter_ap_metric; struct lsa6_prefix inter_ap_prefix[1]; } un_inter_ap; /* AS external links advertisements */ struct { uint32_t asla_metric; struct lsa6_prefix asla_prefix[1]; /* some optional fields follow */ } un_asla; #if 0 /* Summary links advertisements */ struct { struct in_addr sla_mask; uint32_t sla_tosmetric[1]; /* may repeat */ } un_sla; /* Multicast group membership */ struct mcla { uint32_t mcla_vtype; struct in_addr mcla_vid; } un_mcla[1]; #endif /* Type 7 LSA */ /* Link LSA */ struct llsa { union { uint8_t pri; uint32_t opt; } llsa_priandopt; #define llsa_priority llsa_priandopt.pri #define llsa_options llsa_priandopt.opt struct in6_addr llsa_lladdr; uint32_t llsa_nprefix; struct lsa6_prefix llsa_prefix[1]; } un_llsa; /* Intra-Area-Prefix */ struct { uint16_t intra_ap_nprefix; uint16_t intra_ap_lstype; rtrid_t intra_ap_lsid; rtrid_t intra_ap_rtid; struct lsa6_prefix intra_ap_prefix[1]; } un_intra_ap; } lsa_un; }; /* * the main header */ struct ospf6hdr { uint8_t ospf6_version; uint8_t ospf6_type; uint16_t ospf6_len; rtrid_t ospf6_routerid; rtrid_t ospf6_areaid; uint16_t ospf6_chksum; uint8_t ospf6_instanceid; uint8_t ospf6_rsvd; }; /* * The OSPF6 header length is 16 bytes, regardless of how your compiler * might choose to pad the above structure. */ #define OSPF6HDR_LEN 16 /* Hello packet */ struct hello6 { uint32_t hello_ifid; union { uint8_t pri; uint32_t opt; } hello_priandopt; #define hello_priority hello_priandopt.pri #define hello_options hello_priandopt.opt uint16_t hello_helloint; uint16_t hello_deadint; rtrid_t hello_dr; rtrid_t hello_bdr; rtrid_t hello_neighbor[1]; /* may repeat */ }; /* Database Description packet */ struct dd6 { uint32_t db_options; uint16_t db_mtu; uint8_t db_mbz; uint8_t db_flags; uint32_t db_seq; struct lsa6_hdr db_lshdr[1]; /* may repeat */ }; /* Link State Request */ struct lsr6 { uint16_t ls_mbz; uint16_t ls_type; rtrid_t ls_stateid; rtrid_t ls_router; }; /* Link State Update */ struct lsu6 { uint32_t lsu_count; struct lsa6 lsu_lsa[1]; /* may repeat */ }; static const char tstr[] = " [|ospf3]"; static const struct tok ospf6_option_values[] = { { OSPF6_OPTION_V6, "V6" }, { OSPF6_OPTION_E, "External" }, { OSPF6_OPTION_MC, "Deprecated" }, { OSPF6_OPTION_N, "NSSA" }, { OSPF6_OPTION_R, "Router" }, { OSPF6_OPTION_DC, "Demand Circuit" }, { OSPF6_OPTION_AF, "AFs Support" }, { OSPF6_OPTION_L, "LLS" }, { OSPF6_OPTION_AT, "Authentication Trailer" }, { 0, NULL } }; static const struct tok ospf6_rla_flag_values[] = { { RLA_FLAG_B, "ABR" }, { RLA_FLAG_E, "External" }, { RLA_FLAG_V, "Virtual-Link Endpoint" }, { RLA_FLAG_W, "Wildcard Receiver" }, { RLA_FLAG_N, "NSSA Translator" }, { 0, NULL } }; static const struct tok ospf6_asla_flag_values[] = { { ASLA_FLAG_EXTERNAL, "External Type 2" }, { ASLA_FLAG_FWDADDR, "Forwarding" }, { ASLA_FLAG_ROUTETAG, "Tag" }, { 0, NULL } }; static const struct tok ospf6_type_values[] = { { OSPF_TYPE_HELLO, "Hello" }, { OSPF_TYPE_DD, "Database Description" }, { OSPF_TYPE_LS_REQ, "LS-Request" }, { OSPF_TYPE_LS_UPDATE, "LS-Update" }, { OSPF_TYPE_LS_ACK, "LS-Ack" }, { 0, NULL } }; static const struct tok ospf6_lsa_values[] = { { LS_TYPE_ROUTER, "Router" }, { LS_TYPE_NETWORK, "Network" }, { LS_TYPE_INTER_AP, "Inter-Area Prefix" }, { LS_TYPE_INTER_AR, "Inter-Area Router" }, { LS_TYPE_ASE, "External" }, { LS_TYPE_GROUP, "Deprecated" }, { LS_TYPE_NSSA, "NSSA" }, { LS_TYPE_LINK, "Link" }, { LS_TYPE_INTRA_AP, "Intra-Area Prefix" }, { LS_TYPE_INTRA_ATE, "Intra-Area TE" }, { LS_TYPE_GRACE, "Grace" }, { LS_TYPE_RI, "Router Information" }, { LS_TYPE_INTER_ASTE, "Inter-AS-TE" }, { LS_TYPE_L1VPN, "Layer 1 VPN" }, { 0, NULL } }; static const struct tok ospf6_ls_scope_values[] = { { LS_SCOPE_LINKLOCAL, "Link Local" }, { LS_SCOPE_AREA, "Area Local" }, { LS_SCOPE_AS, "Domain Wide" }, { 0, NULL } }; static const struct tok ospf6_dd_flag_values[] = { { OSPF6_DB_INIT, "Init" }, { OSPF6_DB_MORE, "More" }, { OSPF6_DB_MASTER, "Master" }, { OSPF6_DB_M6, "IPv6 MTU" }, { 0, NULL } }; static const struct tok ospf6_lsa_prefix_option_values[] = { { LSA_PREFIX_OPT_NU, "No Unicast" }, { LSA_PREFIX_OPT_LA, "Local address" }, { LSA_PREFIX_OPT_MC, "Deprecated" }, { LSA_PREFIX_OPT_P, "Propagate" }, { LSA_PREFIX_OPT_DN, "Down" }, { 0, NULL } }; static const struct tok ospf6_auth_type_str[] = { { OSPF6_AUTH_TYPE_HMAC, "HMAC" }, { 0, NULL } }; static void ospf6_print_ls_type(netdissect_options *ndo, register u_int ls_type, register const rtrid_t *ls_stateid) { ND_PRINT((ndo, "\n\t %s LSA (%d), %s Scope%s, LSA-ID %s", tok2str(ospf6_lsa_values, "Unknown", ls_type & LS_TYPE_MASK), ls_type & LS_TYPE_MASK, tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK), ls_type &0x8000 ? ", transitive" : "", /* U-bit */ ipaddr_string(ndo, ls_stateid))); } static int ospf6_print_lshdr(netdissect_options *ndo, register const struct lsa6_hdr *lshp, const u_char *dataend) { if ((const u_char *)(lshp + 1) > dataend) goto trunc; - ND_TCHECK(lshp->ls_type); - ND_TCHECK(lshp->ls_seq); + ND_TCHECK(lshp->ls_length); /* last field of struct lsa6_hdr */ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u", ipaddr_string(ndo, &lshp->ls_router), EXTRACT_32BITS(&lshp->ls_seq), EXTRACT_16BITS(&lshp->ls_age), EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr))); ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid); return (0); trunc: return (1); } static int ospf6_print_lsaprefix(netdissect_options *ndo, const uint8_t *tptr, u_int lsa_length) { const struct lsa6_prefix *lsapp = (const struct lsa6_prefix *)tptr; u_int wordlen; struct in6_addr prefix; if (lsa_length < sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES) goto trunc; lsa_length -= sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES; ND_TCHECK2(*lsapp, sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES); wordlen = (lsapp->lsa_p_len + 31) / 32; if (wordlen * 4 > sizeof(struct in6_addr)) { ND_PRINT((ndo, " bogus prefixlen /%d", lsapp->lsa_p_len)); goto trunc; } if (lsa_length < wordlen * 4) goto trunc; lsa_length -= wordlen * 4; ND_TCHECK2(lsapp->lsa_p_prefix, wordlen * 4); memset(&prefix, 0, sizeof(prefix)); memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4); ND_PRINT((ndo, "\n\t\t%s/%d", ip6addr_string(ndo, &prefix), lsapp->lsa_p_len)); if (lsapp->lsa_p_opt) { ND_PRINT((ndo, ", Options [%s]", bittok2str(ospf6_lsa_prefix_option_values, "none", lsapp->lsa_p_opt))); } ND_PRINT((ndo, ", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric))); return sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES + wordlen * 4; trunc: return -1; } /* * Print a single link state advertisement. If truncated return 1, else 0. */ static int ospf6_print_lsa(netdissect_options *ndo, register const struct lsa6 *lsap, const u_char *dataend) { register const struct rlalink6 *rlp; #if 0 register const struct tos_metric *tosp; #endif register const rtrid_t *ap; #if 0 register const struct aslametric *almp; register const struct mcla *mcp; #endif register const struct llsa *llsap; register const struct lsa6_prefix *lsapp; #if 0 register const uint32_t *lp; #endif register u_int prefixes; register int bytelen; register u_int length, lsa_length; uint32_t flags32; const uint8_t *tptr; if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend)) return (1); ND_TCHECK(lsap->ls_hdr.ls_length); length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length); /* * The LSA length includes the length of the header; * it must have a value that's at least that length. * If it does, find the length of what follows the * header. */ if (length < sizeof(struct lsa6_hdr) || (const u_char *)lsap + length > dataend) return (1); lsa_length = length - sizeof(struct lsa6_hdr); tptr = (const uint8_t *)lsap+sizeof(struct lsa6_hdr); switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) { case LS_TYPE_ROUTER | LS_SCOPE_AREA: if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options); ND_TCHECK(lsap->lsa_un.un_rla.rla_options); ND_PRINT((ndo, "\n\t Options [%s]", bittok2str(ospf6_option_values, "none", EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)))); ND_PRINT((ndo, ", RLA-Flags [%s]", bittok2str(ospf6_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags))); rlp = lsap->lsa_un.un_rla.rla_link; while (lsa_length != 0) { if (lsa_length < sizeof (*rlp)) return (1); lsa_length -= sizeof (*rlp); ND_TCHECK(*rlp); switch (rlp->link_type) { case RLA_TYPE_VIRTUAL: ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID %s" "\n\t Neighbor Interface-ID %s, Interface %s", ipaddr_string(ndo, &rlp->link_nrtid), ipaddr_string(ndo, &rlp->link_nifid), ipaddr_string(ndo, &rlp->link_ifid))); break; case RLA_TYPE_ROUTER: ND_PRINT((ndo, "\n\t Neighbor Router-ID %s" "\n\t Neighbor Interface-ID %s, Interface %s", ipaddr_string(ndo, &rlp->link_nrtid), ipaddr_string(ndo, &rlp->link_nifid), ipaddr_string(ndo, &rlp->link_ifid))); break; case RLA_TYPE_TRANSIT: ND_PRINT((ndo, "\n\t Neighbor Network-ID %s" "\n\t Neighbor Interface-ID %s, Interface %s", ipaddr_string(ndo, &rlp->link_nrtid), ipaddr_string(ndo, &rlp->link_nifid), ipaddr_string(ndo, &rlp->link_ifid))); break; default: ND_PRINT((ndo, "\n\t Unknown Router Links Type 0x%02x", rlp->link_type)); return (0); } ND_PRINT((ndo, ", metric %d", EXTRACT_16BITS(&rlp->link_metric))); rlp++; } break; case LS_TYPE_NETWORK | LS_SCOPE_AREA: if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options); ND_TCHECK(lsap->lsa_un.un_nla.nla_options); ND_PRINT((ndo, "\n\t Options [%s]", bittok2str(ospf6_option_values, "none", EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)))); ND_PRINT((ndo, "\n\t Connected Routers:")); ap = lsap->lsa_un.un_nla.nla_router; while (lsa_length != 0) { if (lsa_length < sizeof (*ap)) return (1); lsa_length -= sizeof (*ap); ND_TCHECK(*ap); ND_PRINT((ndo, "\n\t\t%s", ipaddr_string(ndo, ap))); ++ap; } break; case LS_TYPE_INTER_AP | LS_SCOPE_AREA: if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric); ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric); ND_PRINT((ndo, ", metric %u", EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC)); tptr = (const uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix; while (lsa_length != 0) { bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length); if (bytelen < 0) goto trunc; lsa_length -= bytelen; tptr += bytelen; } break; case LS_TYPE_ASE | LS_SCOPE_AS: if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric); ND_TCHECK(lsap->lsa_un.un_asla.asla_metric); flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric); ND_PRINT((ndo, "\n\t Flags [%s]", bittok2str(ospf6_asla_flag_values, "none", flags32))); ND_PRINT((ndo, " metric %u", EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) & ASLA_MASK_METRIC)); tptr = (const uint8_t *)lsap->lsa_un.un_asla.asla_prefix; lsapp = (const struct lsa6_prefix *)tptr; bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length); if (bytelen < 0) goto trunc; lsa_length -= bytelen; tptr += bytelen; if ((flags32 & ASLA_FLAG_FWDADDR) != 0) { const struct in6_addr *fwdaddr6; fwdaddr6 = (const struct in6_addr *)tptr; if (lsa_length < sizeof (*fwdaddr6)) return (1); lsa_length -= sizeof (*fwdaddr6); ND_TCHECK(*fwdaddr6); ND_PRINT((ndo, " forward %s", ip6addr_string(ndo, fwdaddr6))); tptr += sizeof(*fwdaddr6); } if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) { if (lsa_length < sizeof (uint32_t)) return (1); lsa_length -= sizeof (uint32_t); ND_TCHECK(*(const uint32_t *)tptr); ND_PRINT((ndo, " tag %s", ipaddr_string(ndo, (const uint32_t *)tptr))); tptr += sizeof(uint32_t); } if (lsapp->lsa_p_metric) { if (lsa_length < sizeof (uint32_t)) return (1); lsa_length -= sizeof (uint32_t); ND_TCHECK(*(const uint32_t *)tptr); ND_PRINT((ndo, " RefLSID: %s", ipaddr_string(ndo, (const uint32_t *)tptr))); tptr += sizeof(uint32_t); } break; case LS_TYPE_LINK: /* Link LSA */ llsap = &lsap->lsa_un.un_llsa; if (lsa_length < sizeof (llsap->llsa_priandopt)) return (1); lsa_length -= sizeof (llsap->llsa_priandopt); ND_TCHECK(llsap->llsa_priandopt); ND_PRINT((ndo, "\n\t Options [%s]", bittok2str(ospf6_option_values, "none", EXTRACT_32BITS(&llsap->llsa_options)))); if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix)) return (1); lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix); ND_TCHECK(llsap->llsa_nprefix); prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix); ND_PRINT((ndo, "\n\t Priority %d, Link-local address %s, Prefixes %d:", llsap->llsa_priority, ip6addr_string(ndo, &llsap->llsa_lladdr), prefixes)); tptr = (const uint8_t *)llsap->llsa_prefix; while (prefixes > 0) { bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length); if (bytelen < 0) goto trunc; prefixes--; lsa_length -= bytelen; tptr += bytelen; } break; case LS_TYPE_INTRA_AP | LS_SCOPE_AREA: /* Intra-Area-Prefix LSA */ if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid); ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid); ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype), &lsap->lsa_un.un_intra_ap.intra_ap_lsid); if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix)) return (1); lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix); ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix); prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix); ND_PRINT((ndo, "\n\t Prefixes %d:", prefixes)); tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix; while (prefixes > 0) { bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length); if (bytelen < 0) goto trunc; prefixes--; lsa_length -= bytelen; tptr += bytelen; } break; case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL: if (ospf_print_grace_lsa(ndo, tptr, lsa_length) == -1) { return 1; } break; case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL: if (ospf_print_te_lsa(ndo, tptr, lsa_length) == -1) { return 1; } break; default: if(!print_unknown_data(ndo,tptr, "\n\t ", lsa_length)) { return (1); } break; } return (0); trunc: return (1); } static int ospf6_decode_v3(netdissect_options *ndo, register const struct ospf6hdr *op, register const u_char *dataend) { register const rtrid_t *ap; register const struct lsr6 *lsrp; register const struct lsa6_hdr *lshp; register const struct lsa6 *lsap; register int i; switch (op->ospf6_type) { case OSPF_TYPE_HELLO: { register const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN); ND_TCHECK_32BITS(&hellop->hello_options); ND_PRINT((ndo, "\n\tOptions [%s]", bittok2str(ospf6_option_values, "none", EXTRACT_32BITS(&hellop->hello_options)))); ND_TCHECK(hellop->hello_deadint); ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u", EXTRACT_16BITS(&hellop->hello_helloint), EXTRACT_16BITS(&hellop->hello_deadint), ipaddr_string(ndo, &hellop->hello_ifid), hellop->hello_priority)); ND_TCHECK(hellop->hello_dr); if (EXTRACT_32BITS(&hellop->hello_dr) != 0) ND_PRINT((ndo, "\n\t Designated Router %s", ipaddr_string(ndo, &hellop->hello_dr))); ND_TCHECK(hellop->hello_bdr); if (EXTRACT_32BITS(&hellop->hello_bdr) != 0) ND_PRINT((ndo, ", Backup Designated Router %s", ipaddr_string(ndo, &hellop->hello_bdr))); if (ndo->ndo_vflag > 1) { ND_PRINT((ndo, "\n\t Neighbor List:")); ap = hellop->hello_neighbor; while ((const u_char *)ap < dataend) { ND_TCHECK(*ap); ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap))); ++ap; } } break; /* HELLO */ } case OSPF_TYPE_DD: { register const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN); ND_TCHECK(ddp->db_options); ND_PRINT((ndo, "\n\tOptions [%s]", bittok2str(ospf6_option_values, "none", EXTRACT_32BITS(&ddp->db_options)))); ND_TCHECK(ddp->db_flags); ND_PRINT((ndo, ", DD Flags [%s]", bittok2str(ospf6_dd_flag_values,"none",ddp->db_flags))); ND_TCHECK(ddp->db_seq); ND_PRINT((ndo, ", MTU %u, DD-Sequence 0x%08x", EXTRACT_16BITS(&ddp->db_mtu), EXTRACT_32BITS(&ddp->db_seq))); if (ndo->ndo_vflag > 1) { /* Print all the LS adv's */ lshp = ddp->db_lshdr; while ((const u_char *)lshp < dataend) { if (ospf6_print_lshdr(ndo, lshp++, dataend)) goto trunc; } } break; } case OSPF_TYPE_LS_REQ: if (ndo->ndo_vflag > 1) { lsrp = (const struct lsr6 *)((const uint8_t *)op + OSPF6HDR_LEN); while ((const u_char *)lsrp < dataend) { ND_TCHECK(*lsrp); ND_PRINT((ndo, "\n\t Advertising Router %s", ipaddr_string(ndo, &lsrp->ls_router))); ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lsrp->ls_type), &lsrp->ls_stateid); ++lsrp; } } break; case OSPF_TYPE_LS_UPDATE: if (ndo->ndo_vflag > 1) { register const struct lsu6 *lsup = (const struct lsu6 *)((const uint8_t *)op + OSPF6HDR_LEN); ND_TCHECK(lsup->lsu_count); i = EXTRACT_32BITS(&lsup->lsu_count); lsap = lsup->lsu_lsa; while ((const u_char *)lsap < dataend && i--) { if (ospf6_print_lsa(ndo, lsap, dataend)) goto trunc; lsap = (const struct lsa6 *)((const u_char *)lsap + EXTRACT_16BITS(&lsap->ls_hdr.ls_length)); } } break; case OSPF_TYPE_LS_ACK: if (ndo->ndo_vflag > 1) { lshp = (const struct lsa6_hdr *)((const uint8_t *)op + OSPF6HDR_LEN); while ((const u_char *)lshp < dataend) { if (ospf6_print_lshdr(ndo, lshp++, dataend)) goto trunc; } } break; default: break; } return (0); trunc: return (1); } /* RFC5613 Section 2.2 (w/o the TLVs) */ static int ospf6_print_lls(netdissect_options *ndo, const u_char *cp, const u_int len) { uint16_t llsdatalen; if (len == 0) return 0; if (len < OSPF_LLS_HDRLEN) goto trunc; /* Checksum */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, "\n\tLLS Checksum 0x%04x", EXTRACT_16BITS(cp))); cp += 2; /* LLS Data Length */ ND_TCHECK2(*cp, 2); llsdatalen = EXTRACT_16BITS(cp); ND_PRINT((ndo, ", Data Length %u", llsdatalen)); if (llsdatalen < OSPF_LLS_HDRLEN || llsdatalen > len) goto trunc; cp += 2; /* LLS TLVs */ ND_TCHECK2(*cp, llsdatalen - OSPF_LLS_HDRLEN); /* FIXME: code in print-ospf.c can be reused to decode the TLVs */ return llsdatalen; trunc: return -1; } /* RFC6506 Section 4.1 */ static int ospf6_decode_at(netdissect_options *ndo, const u_char *cp, const u_int len) { uint16_t authdatalen; if (len == 0) return 0; if (len < OSPF6_AT_HDRLEN) goto trunc; /* Authentication Type */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, "\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str, "unknown (0x%04x)", EXTRACT_16BITS(cp)))); cp += 2; /* Auth Data Len */ ND_TCHECK2(*cp, 2); authdatalen = EXTRACT_16BITS(cp); ND_PRINT((ndo, ", Length %u", authdatalen)); if (authdatalen < OSPF6_AT_HDRLEN || authdatalen > len) goto trunc; cp += 2; /* Reserved */ ND_TCHECK2(*cp, 2); cp += 2; /* Security Association ID */ ND_TCHECK2(*cp, 2); ND_PRINT((ndo, ", SAID %u", EXTRACT_16BITS(cp))); cp += 2; /* Cryptographic Sequence Number (High-Order 32 Bits) */ ND_TCHECK2(*cp, 4); ND_PRINT((ndo, ", CSN 0x%08x", EXTRACT_32BITS(cp))); cp += 4; /* Cryptographic Sequence Number (Low-Order 32 Bits) */ ND_TCHECK2(*cp, 4); ND_PRINT((ndo, ":%08x", EXTRACT_32BITS(cp))); cp += 4; /* Authentication Data */ ND_TCHECK2(*cp, authdatalen - OSPF6_AT_HDRLEN); if (ndo->ndo_vflag > 1) print_unknown_data(ndo,cp, "\n\tAuthentication Data ", authdatalen - OSPF6_AT_HDRLEN); return 0; trunc: return 1; } /* The trailing data may include LLS and/or AT data (in this specific order). * LLS data may be present only in Hello and DBDesc packets with the L-bit set. * AT data may be present in Hello and DBDesc packets with the AT-bit set or in * any other packet type, thus decode the AT data regardless of the AT-bit. */ static int ospf6_decode_v3_trailer(netdissect_options *ndo, const struct ospf6hdr *op, const u_char *cp, const unsigned len) { int llslen = 0; int lls_hello = 0; int lls_dd = 0; if (op->ospf6_type == OSPF_TYPE_HELLO) { const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN); ND_TCHECK(hellop->hello_options); if (EXTRACT_32BITS(&hellop->hello_options) & OSPF6_OPTION_L) lls_hello = 1; } else if (op->ospf6_type == OSPF_TYPE_DD) { const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN); ND_TCHECK(ddp->db_options); if (EXTRACT_32BITS(&ddp->db_options) & OSPF6_OPTION_L) lls_dd = 1; } if ((lls_hello || lls_dd) && (llslen = ospf6_print_lls(ndo, cp, len)) < 0) goto trunc; return ospf6_decode_at(ndo, cp + llslen, len - llslen); trunc: return 1; } void ospf6_print(netdissect_options *ndo, register const u_char *bp, register u_int length) { register const struct ospf6hdr *op; register const u_char *dataend; register const char *cp; uint16_t datalen; op = (const struct ospf6hdr *)bp; /* If the type is valid translate it, or just print the type */ /* value. If it's not valid, say so and return */ ND_TCHECK(op->ospf6_type); cp = tok2str(ospf6_type_values, "unknown packet type (%u)", op->ospf6_type); ND_PRINT((ndo, "OSPFv%u, %s, length %d", op->ospf6_version, cp, length)); if (*cp == 'u') { return; } if(!ndo->ndo_vflag) { /* non verbose - so lets bail out here */ return; } /* OSPFv3 data always comes first and optional trailing data may follow. */ ND_TCHECK(op->ospf6_len); datalen = EXTRACT_16BITS(&op->ospf6_len); if (datalen > length) { ND_PRINT((ndo, " [len %d]", datalen)); return; } dataend = bp + datalen; ND_TCHECK(op->ospf6_routerid); ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid))); ND_TCHECK(op->ospf6_areaid); if (EXTRACT_32BITS(&op->ospf6_areaid) != 0) ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf6_areaid))); else ND_PRINT((ndo, ", Backbone Area")); ND_TCHECK(op->ospf6_instanceid); if (op->ospf6_instanceid) ND_PRINT((ndo, ", Instance %u", op->ospf6_instanceid)); /* Do rest according to version. */ switch (op->ospf6_version) { case 3: /* ospf version 3 */ if (ospf6_decode_v3(ndo, op, dataend) || ospf6_decode_v3_trailer(ndo, op, dataend, length - datalen)) goto trunc; break; } /* end switch on version */ return; trunc: ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-ppi.c =================================================================== --- vendor/tcpdump/dist/print-ppi.c (revision 353143) +++ vendor/tcpdump/dist/print-ppi.c (revision 353144) @@ -1,129 +1,133 @@ /* * Oracle */ /* \summary: Oracle DLT_PPI printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" typedef struct ppi_header { uint8_t ppi_ver; uint8_t ppi_flags; uint16_t ppi_len; uint32_t ppi_dlt; } ppi_header_t; #define PPI_HDRLEN 8 #ifdef DLT_PPI static inline void ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length) { const ppi_header_t *hdr; uint16_t len; uint32_t dlt; const char *dltname; hdr = (const ppi_header_t *)bp; len = EXTRACT_LE_16BITS(&hdr->ppi_len); dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); dltname = pcap_datalink_val_to_name(dlt); if (!ndo->ndo_qflag) { ND_PRINT((ndo, "V.%d DLT %s (%d) len %d", hdr->ppi_ver, (dltname != NULL ? dltname : "UNKNOWN"), dlt, len)); } else { ND_PRINT((ndo, "%s", (dltname != NULL ? dltname : "UNKNOWN"))); } ND_PRINT((ndo, ", length %u: ", length)); } static u_int ppi_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { if_printer printer; const ppi_header_t *hdr; u_int caplen = h->caplen; u_int length = h->len; uint16_t len; uint32_t dlt; uint32_t hdrlen; struct pcap_pkthdr nhdr; if (caplen < sizeof(ppi_header_t)) { ND_PRINT((ndo, "[|ppi]")); return (caplen); } hdr = (const ppi_header_t *)p; + ND_TCHECK_16BITS(&hdr->ppi_len); len = EXTRACT_LE_16BITS(&hdr->ppi_len); if (caplen < len) { /* * If we don't have the entire PPI header, don't * bother. */ ND_PRINT((ndo, "[|ppi]")); return (caplen); } if (len < sizeof(ppi_header_t)) { ND_PRINT((ndo, "[|ppi]")); return (len); } + ND_TCHECK_32BITS(&hdr->ppi_dlt); dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt); if (ndo->ndo_eflag) ppi_header_print(ndo, p, length); length -= len; caplen -= len; p += len; if ((printer = lookup_printer(dlt)) != NULL) { nhdr = *h; nhdr.caplen = caplen; nhdr.len = length; hdrlen = printer(ndo, &nhdr, p); } else { if (!ndo->ndo_eflag) ppi_header_print(ndo, (const u_char *)hdr, length + len); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); hdrlen = 0; } return (len + hdrlen); +trunc: + return (caplen); } /* * This is the top level routine of the printer. 'p' points * to the ether header of the packet, 'h->ts' is the timestamp, * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ u_int ppi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { return (ppi_print(ndo, h, p)); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ #endif /* DLT_PPI */ Index: vendor/tcpdump/dist/print-rsvp.c =================================================================== --- vendor/tcpdump/dist/print-rsvp.c (revision 353143) +++ vendor/tcpdump/dist/print-rsvp.c (revision 353144) @@ -1,1990 +1,1992 @@ /* * Copyright (c) 1998-2007 The TCPDUMP project * * 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 Hannes Gredler (hannes@gredler.at) */ /* \summary: Resource ReSerVation Protocol (RSVP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "ethertype.h" #include "gmpls.h" #include "af.h" #include "signature.h" static const char tstr[] = " [|rsvp]"; /* * RFC 2205 common header * * 0 1 2 3 * +-------------+-------------+-------------+-------------+ * | Vers | Flags| Msg Type | RSVP Checksum | * +-------------+-------------+-------------+-------------+ * | Send_TTL | (Reserved) | RSVP Length | * +-------------+-------------+-------------+-------------+ * */ struct rsvp_common_header { uint8_t version_flags; uint8_t msg_type; uint8_t checksum[2]; uint8_t ttl; uint8_t reserved; uint8_t length[2]; }; /* * RFC2205 object header * * * 0 1 2 3 * +-------------+-------------+-------------+-------------+ * | Length (bytes) | Class-Num | C-Type | * +-------------+-------------+-------------+-------------+ * | | * // (Object contents) // * | | * +-------------+-------------+-------------+-------------+ */ struct rsvp_object_header { uint8_t length[2]; uint8_t class_num; uint8_t ctype; }; #define RSVP_VERSION 1 #define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4) #define RSVP_EXTRACT_FLAGS(x) ((x)&0x0f) #define RSVP_MSGTYPE_PATH 1 #define RSVP_MSGTYPE_RESV 2 #define RSVP_MSGTYPE_PATHERR 3 #define RSVP_MSGTYPE_RESVERR 4 #define RSVP_MSGTYPE_PATHTEAR 5 #define RSVP_MSGTYPE_RESVTEAR 6 #define RSVP_MSGTYPE_RESVCONF 7 #define RSVP_MSGTYPE_BUNDLE 12 #define RSVP_MSGTYPE_ACK 13 #define RSVP_MSGTYPE_HELLO_OLD 14 /* ancient Hellos */ #define RSVP_MSGTYPE_SREFRESH 15 #define RSVP_MSGTYPE_HELLO 20 static const struct tok rsvp_msg_type_values[] = { { RSVP_MSGTYPE_PATH, "Path" }, { RSVP_MSGTYPE_RESV, "Resv" }, { RSVP_MSGTYPE_PATHERR, "PathErr" }, { RSVP_MSGTYPE_RESVERR, "ResvErr" }, { RSVP_MSGTYPE_PATHTEAR, "PathTear" }, { RSVP_MSGTYPE_RESVTEAR, "ResvTear" }, { RSVP_MSGTYPE_RESVCONF, "ResvConf" }, { RSVP_MSGTYPE_BUNDLE, "Bundle" }, { RSVP_MSGTYPE_ACK, "Acknowledgement" }, { RSVP_MSGTYPE_HELLO_OLD, "Hello (Old)" }, { RSVP_MSGTYPE_SREFRESH, "Refresh" }, { RSVP_MSGTYPE_HELLO, "Hello" }, { 0, NULL} }; static const struct tok rsvp_header_flag_values[] = { { 0x01, "Refresh reduction capable" }, /* rfc2961 */ { 0, NULL} }; #define RSVP_OBJ_SESSION 1 /* rfc2205 */ #define RSVP_OBJ_RSVP_HOP 3 /* rfc2205, rfc3473 */ #define RSVP_OBJ_INTEGRITY 4 /* rfc2747 */ #define RSVP_OBJ_TIME_VALUES 5 /* rfc2205 */ #define RSVP_OBJ_ERROR_SPEC 6 #define RSVP_OBJ_SCOPE 7 #define RSVP_OBJ_STYLE 8 /* rfc2205 */ #define RSVP_OBJ_FLOWSPEC 9 /* rfc2215 */ #define RSVP_OBJ_FILTERSPEC 10 /* rfc2215 */ #define RSVP_OBJ_SENDER_TEMPLATE 11 #define RSVP_OBJ_SENDER_TSPEC 12 /* rfc2215 */ #define RSVP_OBJ_ADSPEC 13 /* rfc2215 */ #define RSVP_OBJ_POLICY_DATA 14 #define RSVP_OBJ_CONFIRM 15 /* rfc2205 */ #define RSVP_OBJ_LABEL 16 /* rfc3209 */ #define RSVP_OBJ_LABEL_REQ 19 /* rfc3209 */ #define RSVP_OBJ_ERO 20 /* rfc3209 */ #define RSVP_OBJ_RRO 21 /* rfc3209 */ #define RSVP_OBJ_HELLO 22 /* rfc3209 */ #define RSVP_OBJ_MESSAGE_ID 23 /* rfc2961 */ #define RSVP_OBJ_MESSAGE_ID_ACK 24 /* rfc2961 */ #define RSVP_OBJ_MESSAGE_ID_LIST 25 /* rfc2961 */ #define RSVP_OBJ_RECOVERY_LABEL 34 /* rfc3473 */ #define RSVP_OBJ_UPSTREAM_LABEL 35 /* rfc3473 */ #define RSVP_OBJ_LABEL_SET 36 /* rfc3473 */ #define RSVP_OBJ_PROTECTION 37 /* rfc3473 */ #define RSVP_OBJ_S2L 50 /* rfc4875 */ #define RSVP_OBJ_DETOUR 63 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */ #define RSVP_OBJ_CLASSTYPE 66 /* rfc4124 */ #define RSVP_OBJ_CLASSTYPE_OLD 125 /* draft-ietf-tewg-diff-te-proto-07 */ #define RSVP_OBJ_SUGGESTED_LABEL 129 /* rfc3473 */ #define RSVP_OBJ_ACCEPT_LABEL_SET 130 /* rfc3473 */ #define RSVP_OBJ_RESTART_CAPABILITY 131 /* rfc3473 */ #define RSVP_OBJ_NOTIFY_REQ 195 /* rfc3473 */ #define RSVP_OBJ_ADMIN_STATUS 196 /* rfc3473 */ #define RSVP_OBJ_PROPERTIES 204 /* juniper proprietary */ #define RSVP_OBJ_FASTREROUTE 205 /* draft-ietf-mpls-rsvp-lsp-fastreroute-07 */ #define RSVP_OBJ_SESSION_ATTRIBUTE 207 /* rfc3209 */ #define RSVP_OBJ_GENERALIZED_UNI 229 /* OIF RSVP extensions UNI 1.0 Signaling, Rel. 2 */ #define RSVP_OBJ_CALL_ID 230 /* rfc3474 */ #define RSVP_OBJ_CALL_OPS 236 /* rfc3474 */ static const struct tok rsvp_obj_values[] = { { RSVP_OBJ_SESSION, "Session" }, { RSVP_OBJ_RSVP_HOP, "RSVP Hop" }, { RSVP_OBJ_INTEGRITY, "Integrity" }, { RSVP_OBJ_TIME_VALUES, "Time Values" }, { RSVP_OBJ_ERROR_SPEC, "Error Spec" }, { RSVP_OBJ_SCOPE, "Scope" }, { RSVP_OBJ_STYLE, "Style" }, { RSVP_OBJ_FLOWSPEC, "Flowspec" }, { RSVP_OBJ_FILTERSPEC, "FilterSpec" }, { RSVP_OBJ_SENDER_TEMPLATE, "Sender Template" }, { RSVP_OBJ_SENDER_TSPEC, "Sender TSpec" }, { RSVP_OBJ_ADSPEC, "Adspec" }, { RSVP_OBJ_POLICY_DATA, "Policy Data" }, { RSVP_OBJ_CONFIRM, "Confirm" }, { RSVP_OBJ_LABEL, "Label" }, { RSVP_OBJ_LABEL_REQ, "Label Request" }, { RSVP_OBJ_ERO, "ERO" }, { RSVP_OBJ_RRO, "RRO" }, { RSVP_OBJ_HELLO, "Hello" }, { RSVP_OBJ_MESSAGE_ID, "Message ID" }, { RSVP_OBJ_MESSAGE_ID_ACK, "Message ID Ack" }, { RSVP_OBJ_MESSAGE_ID_LIST, "Message ID List" }, { RSVP_OBJ_RECOVERY_LABEL, "Recovery Label" }, { RSVP_OBJ_UPSTREAM_LABEL, "Upstream Label" }, { RSVP_OBJ_LABEL_SET, "Label Set" }, { RSVP_OBJ_ACCEPT_LABEL_SET, "Acceptable Label Set" }, { RSVP_OBJ_DETOUR, "Detour" }, { RSVP_OBJ_CLASSTYPE, "Class Type" }, { RSVP_OBJ_CLASSTYPE_OLD, "Class Type (old)" }, { RSVP_OBJ_SUGGESTED_LABEL, "Suggested Label" }, { RSVP_OBJ_PROPERTIES, "Properties" }, { RSVP_OBJ_FASTREROUTE, "Fast Re-Route" }, { RSVP_OBJ_SESSION_ATTRIBUTE, "Session Attribute" }, { RSVP_OBJ_GENERALIZED_UNI, "Generalized UNI" }, { RSVP_OBJ_CALL_ID, "Call-ID" }, { RSVP_OBJ_CALL_OPS, "Call Capability" }, { RSVP_OBJ_RESTART_CAPABILITY, "Restart Capability" }, { RSVP_OBJ_NOTIFY_REQ, "Notify Request" }, { RSVP_OBJ_PROTECTION, "Protection" }, { RSVP_OBJ_ADMIN_STATUS, "Administrative Status" }, { RSVP_OBJ_S2L, "Sub-LSP to LSP" }, { 0, NULL} }; #define RSVP_CTYPE_IPV4 1 #define RSVP_CTYPE_IPV6 2 #define RSVP_CTYPE_TUNNEL_IPV4 7 #define RSVP_CTYPE_TUNNEL_IPV6 8 #define RSVP_CTYPE_UNI_IPV4 11 /* OIF RSVP extensions UNI 1.0 Signaling Rel. 2 */ #define RSVP_CTYPE_1 1 #define RSVP_CTYPE_2 2 #define RSVP_CTYPE_3 3 #define RSVP_CTYPE_4 4 #define RSVP_CTYPE_12 12 #define RSVP_CTYPE_13 13 #define RSVP_CTYPE_14 14 /* * the ctypes are not globally unique so for * translating it to strings we build a table based * on objects offsetted by the ctype */ static const struct tok rsvp_ctype_values[] = { { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" }, { 256*RSVP_OBJ_RSVP_HOP+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" }, { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_NOTIFY_REQ+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_CONFIRM+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_TIME_VALUES+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_1, "obsolete" }, { 256*RSVP_OBJ_FLOWSPEC+RSVP_CTYPE_2, "IntServ" }, { 256*RSVP_OBJ_SENDER_TSPEC+RSVP_CTYPE_2, "IntServ" }, { 256*RSVP_OBJ_ADSPEC+RSVP_CTYPE_2, "IntServ" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_3, "IPv6 Flow-label" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_12, "IPv4 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_FILTERSPEC+RSVP_CTYPE_13, "IPv6 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_UNI_IPV4, "UNI IPv4" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_13, "IPv4 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_SESSION+RSVP_CTYPE_14, "IPv6 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_12, "IPv4 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_SENDER_TEMPLATE+RSVP_CTYPE_13, "IPv6 P2MP LSP Tunnel" }, { 256*RSVP_OBJ_MESSAGE_ID+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_1, "Message id ack" }, { 256*RSVP_OBJ_MESSAGE_ID_ACK+RSVP_CTYPE_2, "Message id nack" }, { 256*RSVP_OBJ_MESSAGE_ID_LIST+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_STYLE+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_1, "Hello Request" }, { 256*RSVP_OBJ_HELLO+RSVP_CTYPE_2, "Hello Ack" }, { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_1, "without label range" }, { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_2, "with ATM label range" }, { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_3, "with FR label range" }, { 256*RSVP_OBJ_LABEL_REQ+RSVP_CTYPE_4, "Generalized Label" }, { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_1, "Label" }, { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_2, "Generalized Label" }, { 256*RSVP_OBJ_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_1, "Label" }, { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_2, "Generalized Label" }, { 256*RSVP_OBJ_SUGGESTED_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_1, "Label" }, { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_2, "Generalized Label" }, { 256*RSVP_OBJ_UPSTREAM_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_1, "Label" }, { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_2, "Generalized Label" }, { 256*RSVP_OBJ_RECOVERY_LABEL+RSVP_CTYPE_3, "Waveband Switching" }, { 256*RSVP_OBJ_ERO+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_RRO+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV4, "IPv4" }, { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_IPV6, "IPv6" }, { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_3, "IPv4 plus opt. TLVs" }, { 256*RSVP_OBJ_ERROR_SPEC+RSVP_CTYPE_4, "IPv6 plus opt. TLVs" }, { 256*RSVP_OBJ_RESTART_CAPABILITY+RSVP_CTYPE_1, "IPv4" }, { 256*RSVP_OBJ_SESSION_ATTRIBUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, /* old style*/ { 256*RSVP_OBJ_FASTREROUTE+RSVP_CTYPE_1, "1" }, /* new style */ { 256*RSVP_OBJ_DETOUR+RSVP_CTYPE_TUNNEL_IPV4, "Tunnel IPv4" }, { 256*RSVP_OBJ_PROPERTIES+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_ADMIN_STATUS+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_CLASSTYPE+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_CLASSTYPE_OLD+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_LABEL_SET+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_GENERALIZED_UNI+RSVP_CTYPE_1, "1" }, { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV4, "IPv4 sub-LSP" }, { 256*RSVP_OBJ_S2L+RSVP_CTYPE_IPV6, "IPv6 sub-LSP" }, { 0, NULL} }; struct rsvp_obj_integrity_t { uint8_t flags; uint8_t res; uint8_t key_id[6]; uint8_t sequence[8]; uint8_t digest[16]; }; static const struct tok rsvp_obj_integrity_flag_values[] = { { 0x80, "Handshake" }, { 0, NULL} }; struct rsvp_obj_frr_t { uint8_t setup_prio; uint8_t hold_prio; uint8_t hop_limit; uint8_t flags; uint8_t bandwidth[4]; uint8_t include_any[4]; uint8_t exclude_any[4]; uint8_t include_all[4]; }; #define RSVP_OBJ_XRO_MASK_SUBOBJ(x) ((x)&0x7f) #define RSVP_OBJ_XRO_MASK_LOOSE(x) ((x)&0x80) #define RSVP_OBJ_XRO_RES 0 #define RSVP_OBJ_XRO_IPV4 1 #define RSVP_OBJ_XRO_IPV6 2 #define RSVP_OBJ_XRO_LABEL 3 #define RSVP_OBJ_XRO_ASN 32 #define RSVP_OBJ_XRO_MPLS 64 static const struct tok rsvp_obj_xro_values[] = { { RSVP_OBJ_XRO_RES, "Reserved" }, { RSVP_OBJ_XRO_IPV4, "IPv4 prefix" }, { RSVP_OBJ_XRO_IPV6, "IPv6 prefix" }, { RSVP_OBJ_XRO_LABEL, "Label" }, { RSVP_OBJ_XRO_ASN, "Autonomous system number" }, { RSVP_OBJ_XRO_MPLS, "MPLS label switched path termination" }, { 0, NULL} }; /* draft-ietf-mpls-rsvp-lsp-fastreroute-07.txt */ static const struct tok rsvp_obj_rro_flag_values[] = { { 0x01, "Local protection available" }, { 0x02, "Local protection in use" }, { 0x04, "Bandwidth protection" }, { 0x08, "Node protection" }, { 0, NULL} }; /* RFC3209 */ static const struct tok rsvp_obj_rro_label_flag_values[] = { { 0x01, "Global" }, { 0, NULL} }; static const struct tok rsvp_resstyle_values[] = { { 17, "Wildcard Filter" }, { 10, "Fixed Filter" }, { 18, "Shared Explicit" }, { 0, NULL} }; #define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2 #define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5 static const struct tok rsvp_intserv_service_type_values[] = { { 1, "Default/Global Information" }, { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" }, { RSVP_OBJ_INTSERV_CONTROLLED_LOAD, "Controlled Load" }, { 0, NULL} }; static const struct tok rsvp_intserv_parameter_id_values[] = { { 4, "IS hop cnt" }, { 6, "Path b/w estimate" }, { 8, "Minimum path latency" }, { 10, "Composed MTU" }, { 127, "Token Bucket TSpec" }, { 130, "Guaranteed Service RSpec" }, { 133, "End-to-end composed value for C" }, { 134, "End-to-end composed value for D" }, { 135, "Since-last-reshaping point composed C" }, { 136, "Since-last-reshaping point composed D" }, { 0, NULL} }; static const struct tok rsvp_session_attribute_flag_values[] = { { 0x01, "Local Protection" }, { 0x02, "Label Recording" }, { 0x04, "SE Style" }, { 0x08, "Bandwidth protection" }, /* RFC4090 */ { 0x10, "Node protection" }, /* RFC4090 */ { 0, NULL} }; static const struct tok rsvp_obj_prop_tlv_values[] = { { 0x01, "Cos" }, { 0x02, "Metric 1" }, { 0x04, "Metric 2" }, { 0x08, "CCC Status" }, { 0x10, "Path Type" }, { 0, NULL} }; #define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24 #define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY 25 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28 #define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125 static const struct tok rsvp_obj_error_code_values[] = { { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" }, { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY, "Notify Error" }, { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" }, { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD, "Diffserv TE Error (Old)" }, { 0, NULL} }; static const struct tok rsvp_obj_error_code_routing_values[] = { { 1, "Bad EXPLICIT_ROUTE object" }, { 2, "Bad strict node" }, { 3, "Bad loose node" }, { 4, "Bad initial subobject" }, { 5, "No route available toward destination" }, { 6, "Unacceptable label value" }, { 7, "RRO indicated routing loops" }, { 8, "non-RSVP-capable router in the path" }, { 9, "MPLS label allocation failure" }, { 10, "Unsupported L3PID" }, { 0, NULL} }; static const struct tok rsvp_obj_error_code_diffserv_te_values[] = { { 1, "Unexpected CT object" }, { 2, "Unsupported CT" }, { 3, "Invalid CT value" }, { 4, "CT/setup priority do not form a configured TE-Class" }, { 5, "CT/holding priority do not form a configured TE-Class" }, { 6, "CT/setup priority and CT/holding priority do not form a configured TE-Class" }, { 7, "Inconsistency between signaled PSC and signaled CT" }, { 8, "Inconsistency between signaled PHBs and signaled CT" }, { 0, NULL} }; /* rfc3473 / rfc 3471 */ static const struct tok rsvp_obj_admin_status_flag_values[] = { { 0x80000000, "Reflect" }, { 0x00000004, "Testing" }, { 0x00000002, "Admin-down" }, { 0x00000001, "Delete-in-progress" }, { 0, NULL} }; /* label set actions - rfc3471 */ #define LABEL_SET_INCLUSIVE_LIST 0 #define LABEL_SET_EXCLUSIVE_LIST 1 #define LABEL_SET_INCLUSIVE_RANGE 2 #define LABEL_SET_EXCLUSIVE_RANGE 3 static const struct tok rsvp_obj_label_set_action_values[] = { { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" }, { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" }, { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" }, { LABEL_SET_EXCLUSIVE_RANGE, "Exclusive range" }, { 0, NULL} }; /* OIF RSVP extensions UNI 1.0 Signaling, release 2 */ #define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS 1 #define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2 #define RSVP_GEN_UNI_SUBOBJ_DIVERSITY 3 #define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL 4 #define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL 5 static const struct tok rsvp_obj_generalized_uni_values[] = { { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" }, { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" }, { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" }, { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" }, { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" }, { 0, NULL} }; /* * this is a dissector for all the intserv defined * specs as defined per rfc2215 * it is called from various rsvp objects; * returns the amount of bytes being processed */ static int rsvp_intserv_print(netdissect_options *ndo, const u_char *tptr, u_short obj_tlen) { int parameter_id,parameter_length; union { float f; uint32_t i; } bw; if (obj_tlen < 4) return 0; + ND_TCHECK_8BITS(tptr); parameter_id = *(tptr); ND_TCHECK2(*(tptr + 2), 2); parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */ ND_PRINT((ndo, "\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]", tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id), parameter_id, parameter_length, *(tptr + 1))); if (obj_tlen < parameter_length+4) return 0; switch(parameter_id) { /* parameter_id */ case 4: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 4 (e) | (f) | 1 (g) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IS hop cnt (32-bit unsigned integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 4) { ND_TCHECK2(*(tptr + 4), 4); ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr + 4))); } break; case 6: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 6 (h) | (i) | 1 (j) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Path b/w estimate (32-bit IEEE floating point number) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 4) { ND_TCHECK2(*(tptr + 4), 4); bw.i = EXTRACT_32BITS(tptr+4); ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000)); } break; case 8: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 8 (k) | (l) | 1 (m) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Minimum path latency (32-bit integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 4) { ND_TCHECK2(*(tptr + 4), 4); ND_PRINT((ndo, "\n\t\tMinimum path latency: ")); if (EXTRACT_32BITS(tptr+4) == 0xffffffff) ND_PRINT((ndo, "don't care")); else ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr + 4))); } break; case 10: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 10 (n) | (o) | 1 (p) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Composed MTU (32-bit unsigned integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 4) { ND_TCHECK2(*(tptr + 4), 4); ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr + 4))); } break; case 127: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 127 (e) | 0 (f) | 5 (g) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Token Bucket Rate [r] (32-bit IEEE floating point number) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Token Bucket Size [b] (32-bit IEEE floating point number) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Peak Data Rate [p] (32-bit IEEE floating point number) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Minimum Policed Unit [m] (32-bit integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Maximum Packet Size [M] (32-bit integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 20) { ND_TCHECK2(*(tptr + 4), 20); bw.i = EXTRACT_32BITS(tptr+4); ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000)); bw.i = EXTRACT_32BITS(tptr+8); ND_PRINT((ndo, "\n\t\tToken Bucket Size: %.10g bytes", bw.f)); bw.i = EXTRACT_32BITS(tptr+12); ND_PRINT((ndo, "\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000)); ND_PRINT((ndo, "\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr + 16))); ND_PRINT((ndo, "\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr + 20))); } break; case 130: /* * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 130 (h) | 0 (i) | 2 (j) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Rate [R] (32-bit IEEE floating point number) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Slack Term [S] (32-bit integer) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ if (parameter_length == 8) { ND_TCHECK2(*(tptr + 4), 8); bw.i = EXTRACT_32BITS(tptr+4); ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000)); ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8))); } break; case 133: case 134: case 135: case 136: if (parameter_length == 4) { ND_TCHECK2(*(tptr + 4), 4); ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4))); } break; default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length); } return (parameter_length+4); /* header length 4 bytes */ trunc: ND_PRINT((ndo, "%s", tstr)); return 0; } /* * Clear checksum prior to signature verification. */ static void rsvp_clear_checksum(void *header) { struct rsvp_common_header *rsvp_com_header = (struct rsvp_common_header *) header; rsvp_com_header->checksum[0] = 0; rsvp_com_header->checksum[1] = 0; } static int rsvp_obj_print(netdissect_options *ndo, const u_char *pptr, u_int plen, const u_char *tptr, const char *ident, u_int tlen, const struct rsvp_common_header *rsvp_com_header) { const struct rsvp_object_header *rsvp_obj_header; const u_char *obj_tptr; union { const struct rsvp_obj_integrity_t *rsvp_obj_integrity; const struct rsvp_obj_frr_t *rsvp_obj_frr; } obj_ptr; u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen; int hexdump,processed,padbytes,error_code,error_value,i,sigcheck; union { float f; uint32_t i; } bw; uint8_t namelen; u_int action, subchannel; while(tlen>=sizeof(struct rsvp_object_header)) { /* did we capture enough for fully decoding the object header ? */ ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header)); rsvp_obj_header = (const struct rsvp_object_header *)tptr; rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length); rsvp_obj_ctype=rsvp_obj_header->ctype; if(rsvp_obj_len % 4) { ND_PRINT((ndo, "%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)) { ND_PRINT((ndo, "%sERROR: object header too short %u < %lu", ident, rsvp_obj_len, (unsigned long)sizeof(const struct rsvp_object_header))); return -1; } ND_PRINT((ndo, "%s%s Object (%u) Flags: [%s", ident, tok2str(rsvp_obj_values, "Unknown", rsvp_obj_header->class_num), rsvp_obj_header->class_num, ((rsvp_obj_header->class_num) & 0x80) ? "ignore" : "reject")); if (rsvp_obj_header->class_num > 128) ND_PRINT((ndo, " %s", ((rsvp_obj_header->class_num) & 0x40) ? "and forward" : "silently")); ND_PRINT((ndo, " if unknown], Class-Type: %s (%u), length: %u", tok2str(rsvp_ctype_values, "Unknown", ((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype), rsvp_obj_ctype, rsvp_obj_len)); if(tlen < rsvp_obj_len) { ND_PRINT((ndo, "%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); /* did we capture enough for fully decoding the object ? */ if (!ND_TTEST2(*tptr, rsvp_obj_len)) return -1; hexdump=FALSE; switch(rsvp_obj_header->class_num) { case RSVP_OBJ_SESSION: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < 8) return -1; ND_PRINT((ndo, "%s IPv4 DestAddress: %s, Protocol ID: 0x%02x", ident, ipaddr_string(ndo, obj_tptr), *(obj_tptr + sizeof(struct in_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", ident, *(obj_tptr+5), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return -1; ND_PRINT((ndo, "%s IPv6 DestAddress: %s, Protocol ID: 0x%02x", ident, ip6addr_string(ndo, obj_tptr), *(obj_tptr + sizeof(struct in6_addr)))); ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u", ident, *(obj_tptr+sizeof(struct in6_addr)+1), EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2))); obj_tlen-=20; obj_tptr+=20; break; case RSVP_CTYPE_TUNNEL_IPV6: if (obj_tlen < 36) return -1; ND_PRINT((ndo, "%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), ip6addr_string(ndo, obj_tptr + 20))); obj_tlen-=36; obj_tptr+=36; break; case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */ if (obj_tlen < 26) return -1; ND_PRINT((ndo, "%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, EXTRACT_32BITS(obj_tptr), EXTRACT_16BITS(obj_tptr+6), ip6addr_string(ndo, obj_tptr + 8))); obj_tlen-=26; obj_tptr+=26; break; case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */ if (obj_tlen < 12) return -1; ND_PRINT((ndo, "%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ipaddr_string(ndo, obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; case RSVP_CTYPE_TUNNEL_IPV4: case RSVP_CTYPE_UNI_IPV4: if (obj_tlen < 12) return -1; ND_PRINT((ndo, "%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ipaddr_string(ndo, obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; default: hexdump=TRUE; } break; case RSVP_OBJ_CONFIRM: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < sizeof(struct in_addr)) return -1; ND_PRINT((ndo, "%s IPv4 Receiver Address: %s", ident, ipaddr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in_addr); obj_tptr+=sizeof(struct in_addr); break; case RSVP_CTYPE_IPV6: if (obj_tlen < sizeof(struct in6_addr)) return -1; ND_PRINT((ndo, "%s IPv6 Receiver Address: %s", ident, ip6addr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in6_addr); obj_tptr+=sizeof(struct in6_addr); break; default: hexdump=TRUE; } break; case RSVP_OBJ_NOTIFY_REQ: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < sizeof(struct in_addr)) return -1; ND_PRINT((ndo, "%s IPv4 Notify Node Address: %s", ident, ipaddr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in_addr); obj_tptr+=sizeof(struct in_addr); break; case RSVP_CTYPE_IPV6: if (obj_tlen < sizeof(struct in6_addr)) return-1; ND_PRINT((ndo, "%s IPv6 Notify Node Address: %s", ident, ip6addr_string(ndo, obj_tptr))); obj_tlen-=sizeof(struct in6_addr); obj_tptr+=sizeof(struct in6_addr); break; default: hexdump=TRUE; } break; case RSVP_OBJ_SUGGESTED_LABEL: /* fall through */ case RSVP_OBJ_UPSTREAM_LABEL: /* fall through */ case RSVP_OBJ_RECOVERY_LABEL: /* fall through */ case RSVP_OBJ_LABEL: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: while(obj_tlen >= 4 ) { ND_PRINT((ndo, "%s Label: %u", ident, EXTRACT_32BITS(obj_tptr))); obj_tlen-=4; obj_tptr+=4; } break; case RSVP_CTYPE_2: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Generalized Label: %u", ident, EXTRACT_32BITS(obj_tptr))); obj_tlen-=4; obj_tptr+=4; break; case RSVP_CTYPE_3: if (obj_tlen < 12) return-1; ND_PRINT((ndo, "%s Waveband ID: %u%s Start Label: %u, Stop Label: %u", ident, EXTRACT_32BITS(obj_tptr), ident, EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; default: hexdump=TRUE; } break; case RSVP_OBJ_STYLE: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Reservation Style: %s, Flags: [0x%02x]", ident, tok2str(rsvp_resstyle_values, "Unknown", EXTRACT_24BITS(obj_tptr+1)), *(obj_tptr))); obj_tlen-=4; obj_tptr+=4; break; default: hexdump=TRUE; } break; case RSVP_OBJ_SENDER_TEMPLATE: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; break; case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ if (obj_tlen < 40) return-1; ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), ident, ip6addr_string(ndo, obj_tptr+20), EXTRACT_16BITS(obj_tptr + 38))); obj_tlen-=40; obj_tptr+=40; break; case RSVP_CTYPE_TUNNEL_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ if (obj_tlen < 16) return-1; ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ident, ipaddr_string(ndo, obj_tptr+8), EXTRACT_16BITS(obj_tptr + 12))); obj_tlen-=16; obj_tptr+=16; break; default: hexdump=TRUE; } break; case RSVP_OBJ_LABEL_REQ: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: while(obj_tlen >= 4 ) { ND_PRINT((ndo, "%s L3 Protocol ID: %s", ident, tok2str(ethertype_values, "Unknown Protocol (0x%04x)", EXTRACT_16BITS(obj_tptr + 2)))); obj_tlen-=4; obj_tptr+=4; } break; case RSVP_CTYPE_2: if (obj_tlen < 12) return-1; ND_PRINT((ndo, "%s L3 Protocol ID: %s", ident, tok2str(ethertype_values, "Unknown Protocol (0x%04x)", EXTRACT_16BITS(obj_tptr + 2)))); ND_PRINT((ndo, ",%s merge capability",((*(obj_tptr + 4)) & 0x80) ? "no" : "" )); ND_PRINT((ndo, "%s Minimum VPI/VCI: %u/%u", ident, (EXTRACT_16BITS(obj_tptr+4))&0xfff, (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff)); ND_PRINT((ndo, "%s Maximum VPI/VCI: %u/%u", ident, (EXTRACT_16BITS(obj_tptr+8))&0xfff, (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff)); obj_tlen-=12; obj_tptr+=12; break; case RSVP_CTYPE_3: if (obj_tlen < 12) return-1; ND_PRINT((ndo, "%s L3 Protocol ID: %s", ident, tok2str(ethertype_values, "Unknown Protocol (0x%04x)", EXTRACT_16BITS(obj_tptr + 2)))); ND_PRINT((ndo, "%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI", ident, (EXTRACT_32BITS(obj_tptr+4))&0x7fffff, (EXTRACT_32BITS(obj_tptr+8))&0x7fffff, (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "", (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : "")); obj_tlen-=12; obj_tptr+=12; break; case RSVP_CTYPE_4: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s LSP Encoding Type: %s (%u)", ident, tok2str(gmpls_encoding_values, "Unknown", *obj_tptr), *obj_tptr)); ND_PRINT((ndo, "%s Switching Type: %s (%u), Payload ID: %s (0x%04x)", ident, tok2str(gmpls_switch_cap_values, "Unknown", *(obj_tptr+1)), *(obj_tptr+1), tok2str(gmpls_payload_values, "Unknown", EXTRACT_16BITS(obj_tptr+2)), EXTRACT_16BITS(obj_tptr + 2))); obj_tlen-=4; obj_tptr+=4; break; default: hexdump=TRUE; } break; case RSVP_OBJ_RRO: case RSVP_OBJ_ERO: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: while(obj_tlen >= 4 ) { u_char length; ND_TCHECK2(*obj_tptr, 4); length = *(obj_tptr + 1); ND_PRINT((ndo, "%s Subobject Type: %s, length %u", ident, tok2str(rsvp_obj_xro_values, "Unknown %u", RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)), length)); if (length == 0) { /* prevent infinite loops */ ND_PRINT((ndo, "%s ERROR: zero length ERO subtype", ident)); break; } switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) { u_char prefix_length; case RSVP_OBJ_XRO_IPV4: if (length != 8) { ND_PRINT((ndo, " ERROR: length != 8")); goto invalid; } ND_TCHECK2(*obj_tptr, 8); prefix_length = *(obj_tptr+6); if (prefix_length != 32) { ND_PRINT((ndo, " ERROR: Prefix length %u != 32", prefix_length)); goto invalid; } ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]", RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict", ipaddr_string(ndo, obj_tptr+2), *(obj_tptr+6), bittok2str(rsvp_obj_rro_flag_values, "none", *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */ break; case RSVP_OBJ_XRO_LABEL: if (length != 8) { ND_PRINT((ndo, " ERROR: length != 8")); goto invalid; } ND_TCHECK2(*obj_tptr, 8); ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u", bittok2str(rsvp_obj_rro_label_flag_values, "none", *(obj_tptr+2)), *(obj_tptr+2), tok2str(rsvp_ctype_values, "Unknown", *(obj_tptr+3) + 256*RSVP_OBJ_RRO), *(obj_tptr+3), EXTRACT_32BITS(obj_tptr + 4))); } obj_tlen-=*(obj_tptr+1); obj_tptr+=*(obj_tptr+1); } break; default: hexdump=TRUE; } break; case RSVP_OBJ_HELLO: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: case RSVP_CTYPE_2: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Source Instance: 0x%08x, Destination Instance: 0x%08x", ident, EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; break; default: hexdump=TRUE; } break; case RSVP_OBJ_RESTART_CAPABILITY: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Restart Time: %ums, Recovery Time: %ums", ident, EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; break; default: hexdump=TRUE; } break; case RSVP_OBJ_SESSION_ATTRIBUTE: switch(rsvp_obj_ctype) { case RSVP_CTYPE_TUNNEL_IPV4: if (obj_tlen < 4) return-1; namelen = *(obj_tptr+3); if (obj_tlen < 4+namelen) return-1; ND_PRINT((ndo, "%s Session Name: ", ident)); for (i = 0; i < namelen; i++) safeputchar(ndo, *(obj_tptr + 4 + i)); ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)", ident, (int)*obj_tptr, (int)*(obj_tptr+1), bittok2str(rsvp_session_attribute_flag_values, "none", *(obj_tptr+2)), *(obj_tptr + 2))); obj_tlen-=4+*(obj_tptr+3); obj_tptr+=4+*(obj_tptr+3); break; default: hexdump=TRUE; } break; case RSVP_OBJ_GENERALIZED_UNI: switch(rsvp_obj_ctype) { int subobj_type,af,subobj_len,total_subobj_len; case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; /* read variable length subobjects */ total_subobj_len = obj_tlen; while(total_subobj_len > 0) { /* If RFC 3476 Section 3.1 defined that a sub-object of the * GENERALIZED_UNI RSVP object must have the Length field as * a multiple of 4, instead of the check below it would be * better to test total_subobj_len only once before the loop. * So long as it does not define it and this while loop does * not implement such a requirement, let's accept that within * each iteration subobj_len may happen to be a multiple of 1 * and test it and total_subobj_len respectively. */ if (total_subobj_len < 4) goto invalid; subobj_len = EXTRACT_16BITS(obj_tptr); subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8; af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF; ND_PRINT((ndo, "%s Subobject Type: %s (%u), AF: %s (%u), length: %u", ident, tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type), subobj_type, tok2str(af_values, "Unknown", af), af, subobj_len)); /* In addition to what is explained above, the same spec does not * explicitly say that the same Length field includes the 4-octet * sub-object header, but as long as this while loop implements it * as it does include, let's keep the check below consistent with * the rest of the code. */ if(subobj_len < 4 || subobj_len > total_subobj_len) goto invalid; switch(subobj_type) { case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS: case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS: switch(af) { case AFNUM_INET: if (subobj_len < 8) return -1; ND_PRINT((ndo, "%s UNI IPv4 TNA address: %s", ident, ipaddr_string(ndo, obj_tptr + 4))); break; case AFNUM_INET6: if (subobj_len < 20) return -1; ND_PRINT((ndo, "%s UNI IPv6 TNA address: %s", ident, ip6addr_string(ndo, obj_tptr + 4))); break; case AFNUM_NSAP: if (subobj_len) { /* unless we have a TLV parser lets just hexdump */ hexdump=TRUE; } break; } break; case RSVP_GEN_UNI_SUBOBJ_DIVERSITY: if (subobj_len) { /* unless we have a TLV parser lets just hexdump */ hexdump=TRUE; } break; case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL: if (subobj_len < 16) { return -1; } ND_PRINT((ndo, "%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u", ident, ((EXTRACT_32BITS(obj_tptr+4))>>31), ((EXTRACT_32BITS(obj_tptr+4))&0xFF), EXTRACT_32BITS(obj_tptr+8), EXTRACT_32BITS(obj_tptr + 12))); break; case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL: if (subobj_len < 8) { return -1; } ND_PRINT((ndo, "%s Service level: %u", ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24)); break; default: hexdump=TRUE; break; } total_subobj_len-=subobj_len; obj_tptr+=subobj_len; obj_tlen+=subobj_len; } if (total_subobj_len) { /* unless we have a TLV parser lets just hexdump */ hexdump=TRUE; } break; default: hexdump=TRUE; } break; case RSVP_OBJ_RSVP_HOP: switch(rsvp_obj_ctype) { case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; if (obj_tlen) hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ break; case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_32BITS(obj_tptr + 16))); obj_tlen-=20; obj_tptr+=20; hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */ break; default: hexdump=TRUE; } break; case RSVP_OBJ_TIME_VALUES: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Refresh Period: %ums", ident, EXTRACT_32BITS(obj_tptr))); obj_tlen-=4; obj_tptr+=4; break; default: hexdump=TRUE; } break; /* those three objects do share the same semantics */ case RSVP_OBJ_SENDER_TSPEC: case RSVP_OBJ_ADSPEC: case RSVP_OBJ_FLOWSPEC: switch(rsvp_obj_ctype) { case RSVP_CTYPE_2: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Msg-Version: %u, length: %u", ident, (*obj_tptr & 0xf0) >> 4, EXTRACT_16BITS(obj_tptr + 2) << 2)); obj_tptr+=4; /* get to the start of the service header */ obj_tlen-=4; while (obj_tlen >= 4) { intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2; ND_PRINT((ndo, "%s Service Type: %s (%u), break bit %s set, Service length: %u", ident, tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)), *(obj_tptr), (*(obj_tptr+1)&0x80) ? "" : "not", intserv_serv_tlen)); obj_tptr+=4; /* get to the start of the parameter list */ obj_tlen-=4; while (intserv_serv_tlen>=4) { processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen); if (processed == 0) break; obj_tlen-=processed; intserv_serv_tlen-=processed; obj_tptr+=processed; } } break; default: hexdump=TRUE; } break; case RSVP_OBJ_FILTERSPEC: switch(rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; break; case RSVP_CTYPE_3: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, Flow Label: %u", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_24BITS(obj_tptr + 17))); obj_tlen-=20; obj_tptr+=20; break; case RSVP_CTYPE_TUNNEL_IPV6: if (obj_tlen < 20) return-1; ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 18))); obj_tlen-=20; obj_tptr+=20; break; case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */ if (obj_tlen < 40) return-1; ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, ip6addr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+18), ident, ip6addr_string(ndo, obj_tptr+20), EXTRACT_16BITS(obj_tptr + 38))); obj_tlen-=40; obj_tptr+=40; break; case RSVP_CTYPE_TUNNEL_IPV4: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr + 6))); obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */ if (obj_tlen < 16) return-1; ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x" "%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x", ident, ipaddr_string(ndo, obj_tptr), EXTRACT_16BITS(obj_tptr+6), ident, ipaddr_string(ndo, obj_tptr+8), EXTRACT_16BITS(obj_tptr + 12))); obj_tlen-=16; obj_tptr+=16; break; default: hexdump=TRUE; } break; case RSVP_OBJ_FASTREROUTE: /* the differences between c-type 1 and 7 are minor */ obj_ptr.rsvp_obj_frr = (const struct rsvp_obj_frr_t *)obj_tptr; switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: /* new style */ if (obj_tlen < sizeof(struct rsvp_obj_frr_t)) return-1; bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps", ident, (int)obj_ptr.rsvp_obj_frr->setup_prio, (int)obj_ptr.rsvp_obj_frr->hold_prio, (int)obj_ptr.rsvp_obj_frr->hop_limit, bw.f * 8 / 1000000)); ND_PRINT((ndo, "%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x", ident, EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any), EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all))); obj_tlen-=sizeof(struct rsvp_obj_frr_t); obj_tptr+=sizeof(struct rsvp_obj_frr_t); break; case RSVP_CTYPE_TUNNEL_IPV4: /* old style */ if (obj_tlen < 16) return-1; bw.i = EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->bandwidth); ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps", ident, (int)obj_ptr.rsvp_obj_frr->setup_prio, (int)obj_ptr.rsvp_obj_frr->hold_prio, (int)obj_ptr.rsvp_obj_frr->hop_limit, bw.f * 8 / 1000000)); ND_PRINT((ndo, "%s Include Colors: 0x%08x, Exclude Colors: 0x%08x", ident, EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any), EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any))); obj_tlen-=16; obj_tptr+=16; break; default: hexdump=TRUE; } break; case RSVP_OBJ_DETOUR: switch(rsvp_obj_ctype) { case RSVP_CTYPE_TUNNEL_IPV4: while(obj_tlen >= 8) { ND_PRINT((ndo, "%s PLR-ID: %s, Avoid-Node-ID: %s", ident, ipaddr_string(ndo, obj_tptr), ipaddr_string(ndo, obj_tptr + 4))); obj_tlen-=8; obj_tptr+=8; } break; default: hexdump=TRUE; } break; case RSVP_OBJ_CLASSTYPE: case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */ switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: + ND_TCHECK_32BITS(obj_tptr); ND_PRINT((ndo, "%s CT: %u", ident, EXTRACT_32BITS(obj_tptr) & 0x7)); obj_tlen-=4; obj_tptr+=4; break; default: hexdump=TRUE; } break; case RSVP_OBJ_ERROR_SPEC: switch(rsvp_obj_ctype) { case RSVP_CTYPE_3: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV4: if (obj_tlen < 8) return-1; error_code=*(obj_tptr+5); error_value=EXTRACT_16BITS(obj_tptr+6); ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)", ident, ipaddr_string(ndo, obj_tptr), *(obj_tptr+4), ident, tok2str(rsvp_obj_error_code_values,"unknown",error_code), error_code)); switch (error_code) { case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: ND_PRINT((ndo, ", Error Value: %s (%u)", tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value), error_value)); break; case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */ case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD: ND_PRINT((ndo, ", Error Value: %s (%u)", tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value), error_value)); break; default: ND_PRINT((ndo, ", Unknown Error Value (%u)", error_value)); break; } obj_tlen-=8; obj_tptr+=8; break; case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */ case RSVP_CTYPE_IPV6: if (obj_tlen < 20) return-1; error_code=*(obj_tptr+17); error_value=EXTRACT_16BITS(obj_tptr+18); ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)", ident, ip6addr_string(ndo, obj_tptr), *(obj_tptr+16), ident, tok2str(rsvp_obj_error_code_values,"unknown",error_code), error_code)); switch (error_code) { case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING: ND_PRINT((ndo, ", Error Value: %s (%u)", tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value), error_value)); break; default: break; } obj_tlen-=20; obj_tptr+=20; break; default: hexdump=TRUE; } break; case RSVP_OBJ_PROPERTIES: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; padbytes = EXTRACT_16BITS(obj_tptr+2); ND_PRINT((ndo, "%s TLV count: %u, padding bytes: %u", ident, EXTRACT_16BITS(obj_tptr), padbytes)); obj_tlen-=4; obj_tptr+=4; /* loop through as long there is anything longer than the TLV header (2) */ while(obj_tlen >= 2 + padbytes) { ND_PRINT((ndo, "%s %s TLV (0x%02x), length: %u", /* length includes header */ ident, tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr), *obj_tptr, *(obj_tptr + 1))); if (obj_tlen < *(obj_tptr+1)) return-1; if (*(obj_tptr+1) < 2) return -1; print_unknown_data(ndo, obj_tptr + 2, "\n\t\t", *(obj_tptr + 1) - 2); obj_tlen-=*(obj_tptr+1); obj_tptr+=*(obj_tptr+1); } break; default: hexdump=TRUE; } break; case RSVP_OBJ_MESSAGE_ID: /* fall through */ case RSVP_OBJ_MESSAGE_ID_ACK: /* fall through */ case RSVP_OBJ_MESSAGE_ID_LIST: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: case RSVP_CTYPE_2: if (obj_tlen < 8) return-1; ND_PRINT((ndo, "%s Flags [0x%02x], epoch: %u", ident, *obj_tptr, EXTRACT_24BITS(obj_tptr + 1))); obj_tlen-=4; obj_tptr+=4; /* loop through as long there are no messages left */ while(obj_tlen >= 4) { ND_PRINT((ndo, "%s Message-ID 0x%08x (%u)", ident, EXTRACT_32BITS(obj_tptr), EXTRACT_32BITS(obj_tptr))); obj_tlen-=4; obj_tptr+=4; } break; default: hexdump=TRUE; } break; case RSVP_OBJ_INTEGRITY: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < sizeof(struct rsvp_obj_integrity_t)) return-1; obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr; ND_PRINT((ndo, "%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]", ident, EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4), bittok2str(rsvp_obj_integrity_flag_values, "none", obj_ptr.rsvp_obj_integrity->flags))); ND_PRINT((ndo, "%s MD5-sum 0x%08x%08x%08x%08x ", ident, EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8), EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12))); sigcheck = signature_verify(ndo, pptr, plen, obj_ptr.rsvp_obj_integrity->digest, rsvp_clear_checksum, rsvp_com_header); ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck))); obj_tlen+=sizeof(struct rsvp_obj_integrity_t); obj_tptr+=sizeof(struct rsvp_obj_integrity_t); break; default: hexdump=TRUE; } break; case RSVP_OBJ_ADMIN_STATUS: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Flags [%s]", ident, bittok2str(rsvp_obj_admin_status_flag_values, "none", EXTRACT_32BITS(obj_tptr)))); obj_tlen-=4; obj_tptr+=4; break; default: hexdump=TRUE; } break; case RSVP_OBJ_LABEL_SET: switch(rsvp_obj_ctype) { case RSVP_CTYPE_1: if (obj_tlen < 4) return-1; action = (EXTRACT_16BITS(obj_tptr)>>8); ND_PRINT((ndo, "%s Action: %s (%u), Label type: %u", ident, tok2str(rsvp_obj_label_set_action_values, "Unknown", action), action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)))); switch (action) { case LABEL_SET_INCLUSIVE_RANGE: case LABEL_SET_EXCLUSIVE_RANGE: /* fall through */ /* only a couple of subchannels are expected */ if (obj_tlen < 12) return -1; ND_PRINT((ndo, "%s Start range: %u, End range: %u", ident, EXTRACT_32BITS(obj_tptr+4), EXTRACT_32BITS(obj_tptr + 8))); obj_tlen-=12; obj_tptr+=12; break; default: obj_tlen-=4; obj_tptr+=4; subchannel = 1; while(obj_tlen >= 4 ) { ND_PRINT((ndo, "%s Subchannel #%u: %u", ident, subchannel, EXTRACT_32BITS(obj_tptr))); obj_tptr+=4; obj_tlen-=4; subchannel++; } break; } break; default: hexdump=TRUE; } case RSVP_OBJ_S2L: switch (rsvp_obj_ctype) { case RSVP_CTYPE_IPV4: if (obj_tlen < 4) return-1; ND_PRINT((ndo, "%s Sub-LSP destination address: %s", ident, ipaddr_string(ndo, obj_tptr))); obj_tlen-=4; obj_tptr+=4; break; case RSVP_CTYPE_IPV6: if (obj_tlen < 16) return-1; ND_PRINT((ndo, "%s Sub-LSP destination address: %s", ident, ip6addr_string(ndo, obj_tptr))); obj_tlen-=16; obj_tptr+=16; break; default: hexdump=TRUE; } /* * FIXME those are the defined objects that lack a decoder * you are welcome to contribute code ;-) */ case RSVP_OBJ_SCOPE: case RSVP_OBJ_POLICY_DATA: case RSVP_OBJ_ACCEPT_LABEL_SET: case RSVP_OBJ_PROTECTION: default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen); /* FIXME indentation */ break; } /* do we also want to see a hex dump ? */ if (ndo->ndo_vflag > 1 || hexdump == TRUE) print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t ", /* FIXME indentation */ rsvp_obj_len - sizeof(struct rsvp_object_header)); tptr+=rsvp_obj_len; tlen-=rsvp_obj_len; } return 0; invalid: ND_PRINT((ndo, "%s", istr)); return -1; trunc: ND_PRINT((ndo, "\n\t\t")); ND_PRINT((ndo, "%s", tstr)); return -1; } void rsvp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len) { const struct rsvp_common_header *rsvp_com_header; const u_char *tptr; u_short plen, tlen; tptr=pptr; rsvp_com_header = (const struct rsvp_common_header *)pptr; ND_TCHECK(*rsvp_com_header); /* * Sanity checking of the header. */ if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) { ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported", RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags))); return; } /* in non-verbose mode just lets print the basic Message Type*/ if (ndo->ndo_vflag < 1) { ND_PRINT((ndo, "RSVPv%u %s Message, length: %u", RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags), tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type), len)); return; } /* ok they seem to want to know everything - lets fully decode it */ plen = tlen = EXTRACT_16BITS(rsvp_com_header->length); ND_PRINT((ndo, "\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x", RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags), tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type), rsvp_com_header->msg_type, bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)), tlen, rsvp_com_header->ttl, EXTRACT_16BITS(rsvp_com_header->checksum))); if (tlen < sizeof(const struct rsvp_common_header)) { ND_PRINT((ndo, "ERROR: common header too short %u < %lu", tlen, (unsigned long)sizeof(const struct rsvp_common_header))); return; } tptr+=sizeof(const struct rsvp_common_header); tlen-=sizeof(const struct rsvp_common_header); switch(rsvp_com_header->msg_type) { case RSVP_MSGTYPE_BUNDLE: /* * Process each submessage in the bundle message. * Bundle messages may not contain bundle submessages, so we don't * need to handle bundle submessages specially. */ while(tlen > 0) { const u_char *subpptr=tptr, *subtptr; u_short subplen, subtlen; subtptr=subpptr; rsvp_com_header = (const struct rsvp_common_header *)subpptr; ND_TCHECK(*rsvp_com_header); /* * Sanity checking of the header. */ if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) { ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported", RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags))); return; } subplen = subtlen = EXTRACT_16BITS(rsvp_com_header->length); ND_PRINT((ndo, "\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x", RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags), tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type), rsvp_com_header->msg_type, bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)), subtlen, rsvp_com_header->ttl, EXTRACT_16BITS(rsvp_com_header->checksum))); if (subtlen < sizeof(const struct rsvp_common_header)) { ND_PRINT((ndo, "ERROR: common header too short %u < %lu", subtlen, (unsigned long)sizeof(const struct rsvp_common_header))); return; } if (tlen < subtlen) { ND_PRINT((ndo, "ERROR: common header too large %u > %u", subtlen, tlen)); return; } subtptr+=sizeof(const struct rsvp_common_header); subtlen-=sizeof(const struct rsvp_common_header); /* * Print all objects in the submessage. */ if (rsvp_obj_print(ndo, subpptr, subplen, subtptr, "\n\t ", subtlen, rsvp_com_header) == -1) return; tptr+=subtlen+sizeof(const struct rsvp_common_header); tlen-=subtlen+sizeof(const struct rsvp_common_header); } break; case RSVP_MSGTYPE_PATH: case RSVP_MSGTYPE_RESV: case RSVP_MSGTYPE_PATHERR: case RSVP_MSGTYPE_RESVERR: case RSVP_MSGTYPE_PATHTEAR: case RSVP_MSGTYPE_RESVTEAR: case RSVP_MSGTYPE_RESVCONF: case RSVP_MSGTYPE_HELLO_OLD: case RSVP_MSGTYPE_HELLO: case RSVP_MSGTYPE_ACK: case RSVP_MSGTYPE_SREFRESH: /* * Print all objects in the message. */ if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t ", tlen, rsvp_com_header) == -1) return; break; default: print_unknown_data(ndo, tptr, "\n\t ", tlen); break; } return; trunc: ND_PRINT((ndo, "\n\t\t")); ND_PRINT((ndo, "%s", tstr)); } Index: vendor/tcpdump/dist/print-rx.c =================================================================== --- vendor/tcpdump/dist/print-rx.c (revision 353143) +++ vendor/tcpdump/dist/print-rx.c (revision 353144) @@ -1,2893 +1,2897 @@ /* * Copyright: (c) 2000 United States Government as represented by the * Secretary of the Navy. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not 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. */ /* \summary: AFS RX printer */ /* * This code unmangles RX packets. RX is the mutant form of RPC that AFS * uses to communicate between clients and servers. * * In this code, I mainly concern myself with decoding the AFS calls, not * with the guts of RX, per se. * * Bah. If I never look at rx_packet.h again, it will be too soon. * * Ken Hornstein */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "ip.h" #define FS_RX_PORT 7000 #define CB_RX_PORT 7001 #define PROT_RX_PORT 7002 #define VLDB_RX_PORT 7003 #define KAUTH_RX_PORT 7004 #define VOL_RX_PORT 7005 #define ERROR_RX_PORT 7006 /* Doesn't seem to be used */ #define BOS_RX_PORT 7007 #define AFSNAMEMAX 256 #define AFSOPAQUEMAX 1024 #define PRNAMEMAX 64 #define VLNAMEMAX 65 #define KANAMEMAX 64 #define BOSNAMEMAX 256 #define PRSFS_READ 1 /* Read files */ #define PRSFS_WRITE 2 /* Write files */ #define PRSFS_INSERT 4 /* Insert files into a directory */ #define PRSFS_LOOKUP 8 /* Lookup files into a directory */ #define PRSFS_DELETE 16 /* Delete files */ #define PRSFS_LOCK 32 /* Lock files */ #define PRSFS_ADMINISTER 64 /* Change ACL's */ struct rx_header { nd_uint32_t epoch; nd_uint32_t cid; nd_uint32_t callNumber; nd_uint32_t seq; nd_uint32_t serial; nd_uint8_t type; #define RX_PACKET_TYPE_DATA 1 #define RX_PACKET_TYPE_ACK 2 #define RX_PACKET_TYPE_BUSY 3 #define RX_PACKET_TYPE_ABORT 4 #define RX_PACKET_TYPE_ACKALL 5 #define RX_PACKET_TYPE_CHALLENGE 6 #define RX_PACKET_TYPE_RESPONSE 7 #define RX_PACKET_TYPE_DEBUG 8 #define RX_PACKET_TYPE_PARAMS 9 #define RX_PACKET_TYPE_VERSION 13 nd_uint8_t flags; #define RX_CLIENT_INITIATED 1 #define RX_REQUEST_ACK 2 #define RX_LAST_PACKET 4 #define RX_MORE_PACKETS 8 #define RX_FREE_PACKET 16 #define RX_SLOW_START_OK 32 #define RX_JUMBO_PACKET 32 nd_uint8_t userStatus; nd_uint8_t securityIndex; nd_uint16_t spare; /* How clever: even though the AFS */ nd_uint16_t serviceId; /* header files indicate that the */ }; /* serviceId is first, it's really */ /* encoded _after_ the spare field */ /* I wasted a day figuring that out! */ #define NUM_RX_FLAGS 7 #define RX_MAXACKS 255 struct rx_ackPacket { uint16_t bufferSpace; /* Number of packet buffers available */ uint16_t maxSkew; /* Max diff between ack'd packet and */ /* highest packet received */ uint32_t firstPacket; /* The first packet in ack list */ uint32_t previousPacket; /* Previous packet recv'd (obsolete) */ uint32_t serial; /* # of packet that prompted the ack */ uint8_t reason; /* Reason for acknowledgement */ uint8_t nAcks; /* Number of acknowledgements */ uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */ }; /* * Values for the acks array */ #define RX_ACK_TYPE_NACK 0 /* Don't have this packet */ #define RX_ACK_TYPE_ACK 1 /* I have this packet */ static const struct tok rx_types[] = { { RX_PACKET_TYPE_DATA, "data" }, { RX_PACKET_TYPE_ACK, "ack" }, { RX_PACKET_TYPE_BUSY, "busy" }, { RX_PACKET_TYPE_ABORT, "abort" }, { RX_PACKET_TYPE_ACKALL, "ackall" }, { RX_PACKET_TYPE_CHALLENGE, "challenge" }, { RX_PACKET_TYPE_RESPONSE, "response" }, { RX_PACKET_TYPE_DEBUG, "debug" }, { RX_PACKET_TYPE_PARAMS, "params" }, { RX_PACKET_TYPE_VERSION, "version" }, { 0, NULL }, }; static const struct double_tok { int flag; /* Rx flag */ int packetType; /* Packet type */ const char *s; /* Flag string */ } rx_flags[] = { { RX_CLIENT_INITIATED, 0, "client-init" }, { RX_REQUEST_ACK, 0, "req-ack" }, { RX_LAST_PACKET, 0, "last-pckt" }, { RX_MORE_PACKETS, 0, "more-pckts" }, { RX_FREE_PACKET, 0, "free-pckt" }, { RX_SLOW_START_OK, RX_PACKET_TYPE_ACK, "slow-start" }, { RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" } }; static const struct tok fs_req[] = { { 130, "fetch-data" }, { 131, "fetch-acl" }, { 132, "fetch-status" }, { 133, "store-data" }, { 134, "store-acl" }, { 135, "store-status" }, { 136, "remove-file" }, { 137, "create-file" }, { 138, "rename" }, { 139, "symlink" }, { 140, "link" }, { 141, "makedir" }, { 142, "rmdir" }, { 143, "oldsetlock" }, { 144, "oldextlock" }, { 145, "oldrellock" }, { 146, "get-stats" }, { 147, "give-cbs" }, { 148, "get-vlinfo" }, { 149, "get-vlstats" }, { 150, "set-vlstats" }, { 151, "get-rootvl" }, { 152, "check-token" }, { 153, "get-time" }, { 154, "nget-vlinfo" }, { 155, "bulk-stat" }, { 156, "setlock" }, { 157, "extlock" }, { 158, "rellock" }, { 159, "xstat-ver" }, { 160, "get-xstat" }, { 161, "dfs-lookup" }, { 162, "dfs-flushcps" }, { 163, "dfs-symlink" }, { 220, "residency" }, { 65536, "inline-bulk-status" }, { 65537, "fetch-data-64" }, { 65538, "store-data-64" }, { 65539, "give-up-all-cbs" }, { 65540, "get-caps" }, { 65541, "cb-rx-conn-addr" }, { 0, NULL }, }; static const struct tok cb_req[] = { { 204, "callback" }, { 205, "initcb" }, { 206, "probe" }, { 207, "getlock" }, { 208, "getce" }, { 209, "xstatver" }, { 210, "getxstat" }, { 211, "initcb2" }, { 212, "whoareyou" }, { 213, "initcb3" }, { 214, "probeuuid" }, { 215, "getsrvprefs" }, { 216, "getcellservdb" }, { 217, "getlocalcell" }, { 218, "getcacheconf" }, { 65536, "getce64" }, { 65537, "getcellbynum" }, { 65538, "tellmeaboutyourself" }, { 0, NULL }, }; static const struct tok pt_req[] = { { 500, "new-user" }, { 501, "where-is-it" }, { 502, "dump-entry" }, { 503, "add-to-group" }, { 504, "name-to-id" }, { 505, "id-to-name" }, { 506, "delete" }, { 507, "remove-from-group" }, { 508, "get-cps" }, { 509, "new-entry" }, { 510, "list-max" }, { 511, "set-max" }, { 512, "list-entry" }, { 513, "change-entry" }, { 514, "list-elements" }, { 515, "same-mbr-of" }, { 516, "set-fld-sentry" }, { 517, "list-owned" }, { 518, "get-cps2" }, { 519, "get-host-cps" }, { 520, "update-entry" }, { 521, "list-entries" }, { 530, "list-super-groups" }, { 0, NULL }, }; static const struct tok vldb_req[] = { { 501, "create-entry" }, { 502, "delete-entry" }, { 503, "get-entry-by-id" }, { 504, "get-entry-by-name" }, { 505, "get-new-volume-id" }, { 506, "replace-entry" }, { 507, "update-entry" }, { 508, "setlock" }, { 509, "releaselock" }, { 510, "list-entry" }, { 511, "list-attrib" }, { 512, "linked-list" }, { 513, "get-stats" }, { 514, "probe" }, { 515, "get-addrs" }, { 516, "change-addr" }, { 517, "create-entry-n" }, { 518, "get-entry-by-id-n" }, { 519, "get-entry-by-name-n" }, { 520, "replace-entry-n" }, { 521, "list-entry-n" }, { 522, "list-attrib-n" }, { 523, "linked-list-n" }, { 524, "update-entry-by-name" }, { 525, "create-entry-u" }, { 526, "get-entry-by-id-u" }, { 527, "get-entry-by-name-u" }, { 528, "replace-entry-u" }, { 529, "list-entry-u" }, { 530, "list-attrib-u" }, { 531, "linked-list-u" }, { 532, "regaddr" }, { 533, "get-addrs-u" }, { 534, "list-attrib-n2" }, { 0, NULL }, }; static const struct tok kauth_req[] = { { 1, "auth-old" }, { 21, "authenticate" }, { 22, "authenticate-v2" }, { 2, "change-pw" }, { 3, "get-ticket-old" }, { 23, "get-ticket" }, { 4, "set-pw" }, { 5, "set-fields" }, { 6, "create-user" }, { 7, "delete-user" }, { 8, "get-entry" }, { 9, "list-entry" }, { 10, "get-stats" }, { 11, "debug" }, { 12, "get-pw" }, { 13, "get-random-key" }, { 14, "unlock" }, { 15, "lock-status" }, { 0, NULL }, }; static const struct tok vol_req[] = { { 100, "create-volume" }, { 101, "delete-volume" }, { 102, "restore" }, { 103, "forward" }, { 104, "end-trans" }, { 105, "clone" }, { 106, "set-flags" }, { 107, "get-flags" }, { 108, "trans-create" }, { 109, "dump" }, { 110, "get-nth-volume" }, { 111, "set-forwarding" }, { 112, "get-name" }, { 113, "get-status" }, { 114, "sig-restore" }, { 115, "list-partitions" }, { 116, "list-volumes" }, { 117, "set-id-types" }, { 118, "monitor" }, { 119, "partition-info" }, { 120, "reclone" }, { 121, "list-one-volume" }, { 122, "nuke" }, { 123, "set-date" }, { 124, "x-list-volumes" }, { 125, "x-list-one-volume" }, { 126, "set-info" }, { 127, "x-list-partitions" }, { 128, "forward-multiple" }, { 65536, "convert-ro" }, { 65537, "get-size" }, { 65538, "dump-v2" }, { 0, NULL }, }; static const struct tok bos_req[] = { { 80, "create-bnode" }, { 81, "delete-bnode" }, { 82, "set-status" }, { 83, "get-status" }, { 84, "enumerate-instance" }, { 85, "get-instance-info" }, { 86, "get-instance-parm" }, { 87, "add-superuser" }, { 88, "delete-superuser" }, { 89, "list-superusers" }, { 90, "list-keys" }, { 91, "add-key" }, { 92, "delete-key" }, { 93, "set-cell-name" }, { 94, "get-cell-name" }, { 95, "get-cell-host" }, { 96, "add-cell-host" }, { 97, "delete-cell-host" }, { 98, "set-t-status" }, { 99, "shutdown-all" }, { 100, "restart-all" }, { 101, "startup-all" }, { 102, "set-noauth-flag" }, { 103, "re-bozo" }, { 104, "restart" }, { 105, "start-bozo-install" }, { 106, "uninstall" }, { 107, "get-dates" }, { 108, "exec" }, { 109, "prune" }, { 110, "set-restart-time" }, { 111, "get-restart-time" }, { 112, "start-bozo-log" }, { 113, "wait-all" }, { 114, "get-instance-strings" }, { 115, "get-restricted" }, { 116, "set-restricted" }, { 0, NULL }, }; static const struct tok ubik_req[] = { { 10000, "vote-beacon" }, { 10001, "vote-debug-old" }, { 10002, "vote-sdebug-old" }, { 10003, "vote-getsyncsite" }, { 10004, "vote-debug" }, { 10005, "vote-sdebug" }, { 10006, "vote-xdebug" }, { 10007, "vote-xsdebug" }, { 20000, "disk-begin" }, { 20001, "disk-commit" }, { 20002, "disk-lock" }, { 20003, "disk-write" }, { 20004, "disk-getversion" }, { 20005, "disk-getfile" }, { 20006, "disk-sendfile" }, { 20007, "disk-abort" }, { 20008, "disk-releaselocks" }, { 20009, "disk-truncate" }, { 20010, "disk-probe" }, { 20011, "disk-writev" }, { 20012, "disk-interfaceaddr" }, { 20013, "disk-setversion" }, { 0, NULL }, }; #define VOTE_LOW 10000 #define VOTE_HIGH 10007 #define DISK_LOW 20000 #define DISK_HIGH 20013 static const struct tok cb_types[] = { { 1, "exclusive" }, { 2, "shared" }, { 3, "dropped" }, { 0, NULL }, }; static const struct tok ubik_lock_types[] = { { 1, "read" }, { 2, "write" }, { 3, "wait" }, { 0, NULL }, }; static const char *voltype[] = { "read-write", "read-only", "backup" }; static const struct tok afs_fs_errors[] = { { 101, "salvage volume" }, { 102, "no such vnode" }, { 103, "no such volume" }, { 104, "volume exist" }, { 105, "no service" }, { 106, "volume offline" }, { 107, "voline online" }, { 108, "diskfull" }, { 109, "diskquota exceeded" }, { 110, "volume busy" }, { 111, "volume moved" }, { 112, "AFS IO error" }, { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */ { 0, NULL } }; /* * Reasons for acknowledging a packet */ static const struct tok rx_ack_reasons[] = { { 1, "ack requested" }, { 2, "duplicate packet" }, { 3, "out of sequence" }, { 4, "exceeds window" }, { 5, "no buffer space" }, { 6, "ping" }, { 7, "ping response" }, { 8, "delay" }, { 9, "idle" }, { 0, NULL }, }; /* * Cache entries we keep around so we can figure out the RX opcode * numbers for replies. This allows us to make sense of RX reply packets. */ struct rx_cache_entry { uint32_t callnum; /* Call number (net order) */ struct in_addr client; /* client IP address (net order) */ struct in_addr server; /* server IP address (net order) */ int dport; /* server port (host order) */ u_short serviceId; /* Service identifier (net order) */ uint32_t opcode; /* RX opcode (host order) */ }; #define RX_CACHE_SIZE 64 static struct rx_cache_entry rx_cache[RX_CACHE_SIZE]; static int rx_cache_next = 0; static int rx_cache_hint = 0; static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int); static int rx_cache_find(const struct rx_header *, const struct ip *, int, int32_t *); static void fs_print(netdissect_options *, const u_char *, int); static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t); static void acl_print(netdissect_options *, u_char *, int, u_char *); static void cb_print(netdissect_options *, const u_char *, int); static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t); static void prot_print(netdissect_options *, const u_char *, int); static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t); static void vldb_print(netdissect_options *, const u_char *, int); static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t); static void kauth_print(netdissect_options *, const u_char *, int); static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t); static void vol_print(netdissect_options *, const u_char *, int); static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t); static void bos_print(netdissect_options *, const u_char *, int); static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t); static void ubik_print(netdissect_options *, const u_char *); static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t); static void rx_ack_print(netdissect_options *, const u_char *, int); static int is_ubik(uint32_t); /* * Handle the rx-level packet. See if we know what port it's going to so * we can peek at the afs call inside */ void rx_print(netdissect_options *ndo, register const u_char *bp, int length, int sport, int dport, const u_char *bp2) { register const struct rx_header *rxh; int i; int32_t opcode; if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) { ND_PRINT((ndo, " [|rx] (%d)", length)); return; } rxh = (const struct rx_header *) bp; ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type))); if (ndo->ndo_vflag) { int firstflag = 0; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, " cid %08x call# %d", (int) EXTRACT_32BITS(&rxh->cid), (int) EXTRACT_32BITS(&rxh->callNumber))); ND_PRINT((ndo, " seq %d ser %d", (int) EXTRACT_32BITS(&rxh->seq), (int) EXTRACT_32BITS(&rxh->serial))); if (ndo->ndo_vflag > 2) ND_PRINT((ndo, " secindex %d serviceid %hu", (int) rxh->securityIndex, EXTRACT_16BITS(&rxh->serviceId))); if (ndo->ndo_vflag > 1) for (i = 0; i < NUM_RX_FLAGS; i++) { if (rxh->flags & rx_flags[i].flag && (!rx_flags[i].packetType || rxh->type == rx_flags[i].packetType)) { if (!firstflag) { firstflag = 1; ND_PRINT((ndo, " ")); } else { ND_PRINT((ndo, ",")); } ND_PRINT((ndo, "<%s>", rx_flags[i].s)); } } } /* * Try to handle AFS calls that we know about. Check the destination * port and make sure it's a data packet. Also, make sure the * seq number is 1 (because otherwise it's a continuation packet, * and we can't interpret that). Also, seems that reply packets * do not have the client-init flag set, so we check for that * as well. */ if (rxh->type == RX_PACKET_TYPE_DATA && EXTRACT_32BITS(&rxh->seq) == 1 && rxh->flags & RX_CLIENT_INITIATED) { /* * Insert this call into the call cache table, so we * have a chance to print out replies */ rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport); switch (dport) { case FS_RX_PORT: /* AFS file service */ fs_print(ndo, bp, length); break; case CB_RX_PORT: /* AFS callback service */ cb_print(ndo, bp, length); break; case PROT_RX_PORT: /* AFS protection service */ prot_print(ndo, bp, length); break; case VLDB_RX_PORT: /* AFS VLDB service */ vldb_print(ndo, bp, length); break; case KAUTH_RX_PORT: /* AFS Kerberos auth service */ kauth_print(ndo, bp, length); break; case VOL_RX_PORT: /* AFS Volume service */ vol_print(ndo, bp, length); break; case BOS_RX_PORT: /* AFS BOS service */ bos_print(ndo, bp, length); break; default: ; } /* * If it's a reply (client-init is _not_ set, but seq is one) * then look it up in the cache. If we find it, call the reply * printing functions Note that we handle abort packets here, * because printing out the return code can be useful at times. */ } else if (((rxh->type == RX_PACKET_TYPE_DATA && EXTRACT_32BITS(&rxh->seq) == 1) || rxh->type == RX_PACKET_TYPE_ABORT) && (rxh->flags & RX_CLIENT_INITIATED) == 0 && rx_cache_find(rxh, (const struct ip *) bp2, sport, &opcode)) { switch (sport) { case FS_RX_PORT: /* AFS file service */ fs_reply_print(ndo, bp, length, opcode); break; case CB_RX_PORT: /* AFS callback service */ cb_reply_print(ndo, bp, length, opcode); break; case PROT_RX_PORT: /* AFS PT service */ prot_reply_print(ndo, bp, length, opcode); break; case VLDB_RX_PORT: /* AFS VLDB service */ vldb_reply_print(ndo, bp, length, opcode); break; case KAUTH_RX_PORT: /* AFS Kerberos auth service */ kauth_reply_print(ndo, bp, length, opcode); break; case VOL_RX_PORT: /* AFS Volume service */ vol_reply_print(ndo, bp, length, opcode); break; case BOS_RX_PORT: /* AFS BOS service */ bos_reply_print(ndo, bp, length, opcode); break; default: ; } /* * If it's an RX ack packet, then use the appropriate ack decoding * function (there isn't any service-specific information in the * ack packet, so we can use one for all AFS services) */ } else if (rxh->type == RX_PACKET_TYPE_ACK) rx_ack_print(ndo, bp, length); ND_PRINT((ndo, " (%d)", length)); } /* * Insert an entry into the cache. Taken from print-nfs.c */ static void rx_cache_insert(netdissect_options *ndo, const u_char *bp, const struct ip *ip, int dport) { struct rx_cache_entry *rxent; const struct rx_header *rxh = (const struct rx_header *) bp; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) return; rxent = &rx_cache[rx_cache_next]; if (++rx_cache_next >= RX_CACHE_SIZE) rx_cache_next = 0; rxent->callnum = EXTRACT_32BITS(&rxh->callNumber); UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t)); UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t)); rxent->dport = dport; - rxent->serviceId = EXTRACT_32BITS(&rxh->serviceId); + rxent->serviceId = EXTRACT_16BITS(&rxh->serviceId); rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header)); } /* * Lookup an entry in the cache. Also taken from print-nfs.c * * Note that because this is a reply, we're looking at the _source_ * port. */ static int rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport, int32_t *opcode) { int i; struct rx_cache_entry *rxent; uint32_t clip; uint32_t sip; UNALIGNED_MEMCPY(&clip, &ip->ip_dst, sizeof(uint32_t)); UNALIGNED_MEMCPY(&sip, &ip->ip_src, sizeof(uint32_t)); /* Start the search where we last left off */ i = rx_cache_hint; do { rxent = &rx_cache[i]; if (rxent->callnum == EXTRACT_32BITS(&rxh->callNumber) && rxent->client.s_addr == clip && rxent->server.s_addr == sip && - rxent->serviceId == EXTRACT_32BITS(&rxh->serviceId) && + rxent->serviceId == EXTRACT_16BITS(&rxh->serviceId) && rxent->dport == sport) { /* We got a match! */ rx_cache_hint = i; *opcode = rxent->opcode; return(1); } if (++i >= RX_CACHE_SIZE) i = 0; } while (i != rx_cache_hint); /* Our search failed */ return(0); } /* * These extrememly grody macros handle the printing of various AFS stuff. */ #define FIDOUT() { unsigned long n1, n2, n3; \ ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \ n1 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n2 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n3 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \ } #define STROUT(MAX) { unsigned int _i; \ ND_TCHECK2(bp[0], sizeof(int32_t)); \ _i = EXTRACT_32BITS(bp); \ if (_i > (MAX)) \ goto trunc; \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " \"")); \ if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \ goto trunc; \ ND_PRINT((ndo, "\"")); \ bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \ } #define INTOUT() { int _i; \ ND_TCHECK2(bp[0], sizeof(int32_t)); \ _i = (int) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " %d", _i)); \ } #define UINTOUT() { unsigned long _i; \ ND_TCHECK2(bp[0], sizeof(int32_t)); \ _i = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " %lu", _i)); \ } #define UINT64OUT() { uint64_t _i; \ ND_TCHECK2(bp[0], sizeof(uint64_t)); \ _i = EXTRACT_64BITS(bp); \ bp += sizeof(uint64_t); \ ND_PRINT((ndo, " %" PRIu64, _i)); \ } #define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \ ND_TCHECK2(bp[0], sizeof(int32_t)); \ _t = (time_t) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ tm = localtime(&_t); \ strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \ ND_PRINT((ndo, " %s", str)); \ } #define STOREATTROUT() { unsigned long mask, _i; \ ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \ mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask) ND_PRINT((ndo, " StoreStatus")); \ if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \ else bp += sizeof(int32_t); \ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 2) ND_PRINT((ndo, " owner %lu", _i)); \ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 4) ND_PRINT((ndo, " group %lu", _i)); \ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 8) ND_PRINT((ndo, " mode %lo", _i & 07777)); \ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \ if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \ /* undocumented in 3.3 docu */ \ if (mask & 1024) ND_PRINT((ndo, " fsync")); \ } #define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \ ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \ epoch = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ counter = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " %d.%d", epoch, counter)); \ } #define AFSUUIDOUT() {uint32_t temp; int _i; \ ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(uint32_t); \ ND_PRINT((ndo, " %08x", temp)); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(uint32_t); \ ND_PRINT((ndo, "%04x", temp)); \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(uint32_t); \ ND_PRINT((ndo, "%04x", temp)); \ for (_i = 0; _i < 8; _i++) { \ temp = EXTRACT_32BITS(bp); \ bp += sizeof(uint32_t); \ ND_PRINT((ndo, "%02x", (unsigned char) temp)); \ } \ } /* * This is the sickest one of all */ #define VECOUT(MAX) { u_char *sp; \ u_char s[AFSNAMEMAX]; \ int k; \ if ((MAX) + 1 > sizeof(s)) \ goto trunc; \ ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \ sp = s; \ for (k = 0; k < (MAX); k++) { \ *sp++ = (u_char) EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ } \ s[(MAX)] = '\0'; \ ND_PRINT((ndo, " \"")); \ fn_print(ndo, s, NULL); \ ND_PRINT((ndo, "\"")); \ } #define DESTSERVEROUT() { unsigned long n1, n2, n3; \ ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \ n1 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n2 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ n3 = EXTRACT_32BITS(bp); \ bp += sizeof(int32_t); \ ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \ } /* * Handle calls to the AFS file service (fs) */ static void fs_print(netdissect_options *ndo, register const u_char *bp, int length) { int fs_op; unsigned long i; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afsint.xg */ fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op))); /* * Print out arguments to some of the AFS calls. This stuff is * all from afsint.xg */ bp += sizeof(struct rx_header) + 4; /* * Sigh. This is gross. Ritchie forgive me. */ switch (fs_op) { case 130: /* Fetch data */ FIDOUT(); ND_PRINT((ndo, " offset")); UINTOUT(); ND_PRINT((ndo, " length")); UINTOUT(); break; case 131: /* Fetch ACL */ case 132: /* Fetch Status */ case 143: /* Old set lock */ case 144: /* Old extend lock */ case 145: /* Old release lock */ case 156: /* Set lock */ case 157: /* Extend lock */ case 158: /* Release lock */ FIDOUT(); break; case 135: /* Store status */ FIDOUT(); STOREATTROUT(); break; case 133: /* Store data */ FIDOUT(); STOREATTROUT(); ND_PRINT((ndo, " offset")); UINTOUT(); ND_PRINT((ndo, " length")); UINTOUT(); ND_PRINT((ndo, " flen")); UINTOUT(); break; case 134: /* Store ACL */ { char a[AFSOPAQUEMAX+1]; FIDOUT(); ND_TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_TCHECK2(bp[0], i); i = min(AFSOPAQUEMAX, i); strncpy(a, (const char *) bp, i); a[i] = '\0'; acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i); break; } case 137: /* Create file */ case 141: /* MakeDir */ FIDOUT(); STROUT(AFSNAMEMAX); STOREATTROUT(); break; case 136: /* Remove file */ case 142: /* Remove directory */ FIDOUT(); STROUT(AFSNAMEMAX); break; case 138: /* Rename file */ ND_PRINT((ndo, " old")); FIDOUT(); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " new")); FIDOUT(); STROUT(AFSNAMEMAX); break; case 139: /* Symlink */ FIDOUT(); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " link to")); STROUT(AFSNAMEMAX); break; case 140: /* Link */ FIDOUT(); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " link to")); FIDOUT(); break; case 148: /* Get volume info */ STROUT(AFSNAMEMAX); break; case 149: /* Get volume stats */ case 150: /* Set volume stats */ ND_PRINT((ndo, " volid")); UINTOUT(); break; case 154: /* New get volume info */ ND_PRINT((ndo, " volname")); STROUT(AFSNAMEMAX); break; case 155: /* Bulk stat */ case 65536: /* Inline bulk stat */ { unsigned long j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { FIDOUT(); if (i != j - 1) ND_PRINT((ndo, ",")); } if (j == 0) ND_PRINT((ndo, " ")); + break; } case 65537: /* Fetch data 64 */ FIDOUT(); ND_PRINT((ndo, " offset")); UINT64OUT(); ND_PRINT((ndo, " length")); UINT64OUT(); break; case 65538: /* Store data 64 */ FIDOUT(); STOREATTROUT(); ND_PRINT((ndo, " offset")); UINT64OUT(); ND_PRINT((ndo, " length")); UINT64OUT(); ND_PRINT((ndo, " flen")); UINT64OUT(); break; case 65541: /* CallBack rx conn address */ ND_PRINT((ndo, " addr")); UINTOUT(); default: ; } return; trunc: ND_PRINT((ndo, " [|fs]")); } /* * Handle replies to the AFS file service */ static void fs_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { unsigned long i; const struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afsint.xg */ ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) { switch (opcode) { case 131: /* Fetch ACL */ { char a[AFSOPAQUEMAX+1]; ND_TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_TCHECK2(bp[0], i); i = min(AFSOPAQUEMAX, i); strncpy(a, (const char *) bp, i); a[i] = '\0'; acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i); break; } case 137: /* Create file */ case 141: /* MakeDir */ ND_PRINT((ndo, " new")); FIDOUT(); break; case 151: /* Get root volume */ ND_PRINT((ndo, " root volume")); STROUT(AFSNAMEMAX); break; case 153: /* Get time */ DATEOUT(); break; default: ; } } else if (rxh->type == RX_PACKET_TYPE_ABORT) { /* * Otherwise, just print out the return code */ ND_TCHECK2(bp[0], sizeof(int32_t)); i = (int) EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i))); } else { ND_PRINT((ndo, " strange fs reply of type %d", rxh->type)); } return; trunc: ND_PRINT((ndo, " [|fs]")); } /* * Print out an AFS ACL string. An AFS ACL is a string that has the * following format: * * * * .... * * "positive" and "negative" are integers which contain the number of * positive and negative ACL's in the string. The uid/aclbits pair are * ASCII strings containing the UID/PTS record and and a ascii number * representing a logical OR of all the ACL permission bits */ static void acl_print(netdissect_options *ndo, u_char *s, int maxsize, u_char *end) { int pos, neg, acl; int n, i; char *user; char fmt[1024]; if ((user = (char *)malloc(maxsize)) == NULL) return; if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2) goto finish; s += n; if (s > end) goto finish; /* * This wacky order preserves the order used by the "fs" command */ #define ACLOUT(acl) \ ND_PRINT((ndo, "%s%s%s%s%s%s%s", \ acl & PRSFS_READ ? "r" : "", \ acl & PRSFS_LOOKUP ? "l" : "", \ acl & PRSFS_INSERT ? "i" : "", \ acl & PRSFS_DELETE ? "d" : "", \ acl & PRSFS_WRITE ? "w" : "", \ acl & PRSFS_LOCK ? "k" : "", \ acl & PRSFS_ADMINISTER ? "a" : "")); for (i = 0; i < pos; i++) { snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); if (sscanf((char *) s, fmt, user, &acl, &n) != 2) goto finish; s += n; ND_PRINT((ndo, " +{")); fn_print(ndo, (u_char *)user, NULL); ND_PRINT((ndo, " ")); ACLOUT(acl); ND_PRINT((ndo, "}")); if (s > end) goto finish; } for (i = 0; i < neg; i++) { snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1); if (sscanf((char *) s, fmt, user, &acl, &n) != 2) goto finish; s += n; ND_PRINT((ndo, " -{")); fn_print(ndo, (u_char *)user, NULL); ND_PRINT((ndo, " ")); ACLOUT(acl); ND_PRINT((ndo, "}")); if (s > end) goto finish; } finish: free(user); return; } #undef ACLOUT /* * Handle calls to the AFS callback service */ static void cb_print(netdissect_options *ndo, register const u_char *bp, int length) { int cb_op; unsigned long i; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op))); bp += sizeof(struct rx_header) + 4; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ switch (cb_op) { case 204: /* Callback */ { unsigned long j, t; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { FIDOUT(); if (i != j - 1) ND_PRINT((ndo, ",")); } if (j == 0) ND_PRINT((ndo, " ")); ND_TCHECK_32BITS(bp); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (j != 0) ND_PRINT((ndo, ";")); for (i = 0; i < j; i++) { ND_PRINT((ndo, " ver")); INTOUT(); ND_PRINT((ndo, " expires")); DATEOUT(); ND_TCHECK2(bp[0], 4); t = EXTRACT_32BITS(bp); bp += sizeof(int32_t); tok2str(cb_types, "type %d", t); } + break; } case 214: { ND_PRINT((ndo, " afsuuid")); AFSUUIDOUT(); break; } default: ; } return; trunc: ND_PRINT((ndo, " [|cb]")); } /* * Handle replies to the AFS Callback Service */ static void cb_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from fsint/afscbint.xg */ ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 213: /* InitCallBackState3 */ AFSUUIDOUT(); break; default: ; } else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|cb]")); } /* * Handle calls to the AFS protection database server */ static void prot_print(netdissect_options *ndo, register const u_char *bp, int length) { unsigned long i; int pt_op; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from ptserver/ptint.xg */ pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " pt")); if (is_ubik(pt_op)) { ubik_print(ndo, bp); return; } ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op))); /* * Decode some of the arguments to the PT calls */ bp += sizeof(struct rx_header) + 4; switch (pt_op) { case 500: /* I New User */ STROUT(PRNAMEMAX); ND_PRINT((ndo, " id")); INTOUT(); ND_PRINT((ndo, " oldid")); INTOUT(); break; case 501: /* Where is it */ case 506: /* Delete */ case 508: /* Get CPS */ case 512: /* List entry */ case 514: /* List elements */ case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ case 530: /* List super groups */ ND_PRINT((ndo, " id")); INTOUT(); break; case 502: /* Dump entry */ ND_PRINT((ndo, " pos")); INTOUT(); break; case 503: /* Add to group */ case 507: /* Remove from group */ case 515: /* Is a member of? */ ND_PRINT((ndo, " uid")); INTOUT(); ND_PRINT((ndo, " gid")); INTOUT(); break; case 504: /* Name to ID */ { unsigned long j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); /* * Who designed this chicken-shit protocol? * * Each character is stored as a 32-bit * integer! */ for (i = 0; i < j; i++) { VECOUT(PRNAMEMAX); } if (j == 0) ND_PRINT((ndo, " ")); } break; case 505: /* Id to name */ { unsigned long j; ND_PRINT((ndo, " ids:")); ND_TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (j = 0; j < i; j++) INTOUT(); if (j == 0) ND_PRINT((ndo, " ")); } break; case 509: /* New entry */ STROUT(PRNAMEMAX); ND_PRINT((ndo, " flag")); INTOUT(); ND_PRINT((ndo, " oid")); INTOUT(); break; case 511: /* Set max */ ND_PRINT((ndo, " id")); INTOUT(); ND_PRINT((ndo, " gflag")); INTOUT(); break; case 513: /* Change entry */ ND_PRINT((ndo, " id")); INTOUT(); STROUT(PRNAMEMAX); ND_PRINT((ndo, " oldid")); INTOUT(); ND_PRINT((ndo, " newid")); INTOUT(); break; case 520: /* Update entry */ ND_PRINT((ndo, " id")); INTOUT(); STROUT(PRNAMEMAX); break; default: ; } return; trunc: ND_PRINT((ndo, " [|pt]")); } /* * Handle replies to the AFS protection service */ static void prot_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; unsigned long i; if (length < (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from ptserver/ptint.xg. Check to see if it's a * Ubik call, however. */ ND_PRINT((ndo, " pt")); if (is_ubik(opcode)) { ubik_reply_print(ndo, bp, length, opcode); return; } ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 504: /* Name to ID */ { unsigned long j; ND_PRINT((ndo, " ids:")); ND_TCHECK2(bp[0], 4); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (j = 0; j < i; j++) INTOUT(); if (j == 0) ND_PRINT((ndo, " ")); } break; case 505: /* ID to name */ { unsigned long j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); /* * Who designed this chicken-shit protocol? * * Each character is stored as a 32-bit * integer! */ for (i = 0; i < j; i++) { VECOUT(PRNAMEMAX); } if (j == 0) ND_PRINT((ndo, " ")); } break; case 508: /* Get CPS */ case 514: /* List elements */ case 517: /* List owned */ case 518: /* Get CPS2 */ case 519: /* Get host CPS */ { unsigned long j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { INTOUT(); } if (j == 0) ND_PRINT((ndo, " ")); } break; case 510: /* List max */ ND_PRINT((ndo, " maxuid")); INTOUT(); ND_PRINT((ndo, " maxgid")); INTOUT(); break; default: ; } else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|pt]")); } /* * Handle calls to the AFS volume location database service */ static void vldb_print(netdissect_options *ndo, register const u_char *bp, int length) { int vldb_op; unsigned long i; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg */ vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " vldb")); if (is_ubik(vldb_op)) { ubik_print(ndo, bp); return; } ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op))); /* * Decode some of the arguments to the VLDB calls */ bp += sizeof(struct rx_header) + 4; switch (vldb_op) { case 501: /* Create new volume */ case 517: /* Create entry N */ VECOUT(VLNAMEMAX); break; case 502: /* Delete entry */ case 503: /* Get entry by ID */ case 507: /* Update entry */ case 508: /* Set lock */ case 509: /* Release lock */ case 518: /* Get entry by ID N */ ND_PRINT((ndo, " volid")); INTOUT(); ND_TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) ND_PRINT((ndo, " type %s", voltype[i])); break; case 504: /* Get entry by name */ case 519: /* Get entry by name N */ case 524: /* Update entry by name */ case 527: /* Get entry by name U */ STROUT(VLNAMEMAX); break; case 505: /* Get new vol id */ ND_PRINT((ndo, " bump")); INTOUT(); break; case 506: /* Replace entry */ case 520: /* Replace entry N */ ND_PRINT((ndo, " volid")); INTOUT(); ND_TCHECK2(bp[0], sizeof(int32_t)); i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); if (i <= 2) ND_PRINT((ndo, " type %s", voltype[i])); VECOUT(VLNAMEMAX); break; case 510: /* List entry */ case 521: /* List entry N */ ND_PRINT((ndo, " index")); INTOUT(); break; default: ; } return; trunc: ND_PRINT((ndo, " [|vldb]")); } /* * Handle replies to the AFS volume location database service */ static void vldb_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; unsigned long i; if (length < (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from vlserver/vldbint.xg. Check to see if it's a * Ubik call, however. */ ND_PRINT((ndo, " vldb")); if (is_ubik(opcode)) { ubik_reply_print(ndo, bp, length, opcode); return; } ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 510: /* List entry */ ND_PRINT((ndo, " count")); INTOUT(); ND_PRINT((ndo, " nextindex")); INTOUT(); + /*FALLTHROUGH*/ case 503: /* Get entry by id */ case 504: /* Get entry by name */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); ND_TCHECK2(bp[0], sizeof(int32_t)); bp += sizeof(int32_t); ND_PRINT((ndo, " numservers")); ND_TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_PRINT((ndo, " %lu", nservers)); ND_PRINT((ndo, " servers")); for (i = 0; i < 8; i++) { ND_TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) ND_PRINT((ndo, " %s", intoa(((const struct in_addr *) bp)->s_addr))); bp += sizeof(int32_t); } ND_PRINT((ndo, " partitions")); for (i = 0; i < 8; i++) { ND_TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) ND_PRINT((ndo, " %c", 'a' + (int)j)); else if (i < nservers) ND_PRINT((ndo, " %lu", j)); bp += sizeof(int32_t); } ND_TCHECK2(bp[0], 8 * sizeof(int32_t)); bp += 8 * sizeof(int32_t); ND_PRINT((ndo, " rwvol")); UINTOUT(); ND_PRINT((ndo, " rovol")); UINTOUT(); ND_PRINT((ndo, " backup")); UINTOUT(); } break; case 505: /* Get new volume ID */ ND_PRINT((ndo, " newvol")); UINTOUT(); break; case 521: /* List entry */ case 529: /* List entry U */ ND_PRINT((ndo, " count")); INTOUT(); ND_PRINT((ndo, " nextindex")); INTOUT(); + /*FALLTHROUGH*/ case 518: /* Get entry by ID N */ case 519: /* Get entry by name N */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); ND_PRINT((ndo, " numservers")); ND_TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_PRINT((ndo, " %lu", nservers)); ND_PRINT((ndo, " servers")); for (i = 0; i < 13; i++) { ND_TCHECK2(bp[0], sizeof(int32_t)); if (i < nservers) ND_PRINT((ndo, " %s", intoa(((const struct in_addr *) bp)->s_addr))); bp += sizeof(int32_t); } ND_PRINT((ndo, " partitions")); for (i = 0; i < 13; i++) { ND_TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) ND_PRINT((ndo, " %c", 'a' + (int)j)); else if (i < nservers) ND_PRINT((ndo, " %lu", j)); bp += sizeof(int32_t); } ND_TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); ND_PRINT((ndo, " rwvol")); UINTOUT(); ND_PRINT((ndo, " rovol")); UINTOUT(); ND_PRINT((ndo, " backup")); UINTOUT(); } break; case 526: /* Get entry by ID U */ case 527: /* Get entry by name U */ { unsigned long nservers, j; VECOUT(VLNAMEMAX); ND_PRINT((ndo, " numservers")); ND_TCHECK2(bp[0], sizeof(int32_t)); nservers = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_PRINT((ndo, " %lu", nservers)); ND_PRINT((ndo, " servers")); for (i = 0; i < 13; i++) { if (i < nservers) { ND_PRINT((ndo, " afsuuid")); AFSUUIDOUT(); } else { ND_TCHECK2(bp[0], 44); bp += 44; } } ND_TCHECK2(bp[0], 4 * 13); bp += 4 * 13; ND_PRINT((ndo, " partitions")); for (i = 0; i < 13; i++) { ND_TCHECK2(bp[0], sizeof(int32_t)); j = EXTRACT_32BITS(bp); if (i < nservers && j <= 26) ND_PRINT((ndo, " %c", 'a' + (int)j)); else if (i < nservers) ND_PRINT((ndo, " %lu", j)); bp += sizeof(int32_t); } ND_TCHECK2(bp[0], 13 * sizeof(int32_t)); bp += 13 * sizeof(int32_t); ND_PRINT((ndo, " rwvol")); UINTOUT(); ND_PRINT((ndo, " rovol")); UINTOUT(); ND_PRINT((ndo, " backup")); UINTOUT(); } default: ; } else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|vldb]")); } /* * Handle calls to the AFS Kerberos Authentication service */ static void kauth_print(netdissect_options *ndo, register const u_char *bp, int length) { int kauth_op; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " kauth")); if (is_ubik(kauth_op)) { ubik_print(ndo, bp); return; } ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op))); /* * Decode some of the arguments to the KA calls */ bp += sizeof(struct rx_header) + 4; switch (kauth_op) { case 1: /* Authenticate old */ case 21: /* Authenticate */ case 22: /* Authenticate-V2 */ case 2: /* Change PW */ case 5: /* Set fields */ case 6: /* Create user */ case 7: /* Delete user */ case 8: /* Get entry */ case 14: /* Unlock */ case 15: /* Lock status */ ND_PRINT((ndo, " principal")); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; case 3: /* GetTicket-old */ case 23: /* GetTicket */ { int i; ND_PRINT((ndo, " kvno")); INTOUT(); ND_PRINT((ndo, " domain")); STROUT(KANAMEMAX); ND_TCHECK2(bp[0], sizeof(int32_t)); i = (int) EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_TCHECK2(bp[0], i); bp += i; ND_PRINT((ndo, " principal")); STROUT(KANAMEMAX); STROUT(KANAMEMAX); break; } case 4: /* Set Password */ ND_PRINT((ndo, " principal")); STROUT(KANAMEMAX); STROUT(KANAMEMAX); ND_PRINT((ndo, " kvno")); INTOUT(); break; case 12: /* Get password */ ND_PRINT((ndo, " name")); STROUT(KANAMEMAX); break; default: ; } return; trunc: ND_PRINT((ndo, " [|kauth]")); } /* * Handle replies to the AFS Kerberos Authentication Service */ static void kauth_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from kauth/kauth.rg */ ND_PRINT((ndo, " kauth")); if (is_ubik(opcode)) { ubik_reply_print(ndo, bp, length, opcode); return; } ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|kauth]")); } /* * Handle calls to the AFS Volume location service */ static void vol_print(netdissect_options *ndo, register const u_char *bp, int length) { int vol_op; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op))); bp += sizeof(struct rx_header) + 4; switch (vol_op) { case 100: /* Create volume */ ND_PRINT((ndo, " partition")); UINTOUT(); ND_PRINT((ndo, " name")); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " type")); UINTOUT(); ND_PRINT((ndo, " parent")); UINTOUT(); break; case 101: /* Delete volume */ case 107: /* Get flags */ ND_PRINT((ndo, " trans")); UINTOUT(); break; case 102: /* Restore */ ND_PRINT((ndo, " totrans")); UINTOUT(); ND_PRINT((ndo, " flags")); UINTOUT(); break; case 103: /* Forward */ ND_PRINT((ndo, " fromtrans")); UINTOUT(); ND_PRINT((ndo, " fromdate")); DATEOUT(); DESTSERVEROUT(); ND_PRINT((ndo, " desttrans")); INTOUT(); break; case 104: /* End trans */ ND_PRINT((ndo, " trans")); UINTOUT(); break; case 105: /* Clone */ ND_PRINT((ndo, " trans")); UINTOUT(); ND_PRINT((ndo, " purgevol")); UINTOUT(); ND_PRINT((ndo, " newtype")); UINTOUT(); ND_PRINT((ndo, " newname")); STROUT(AFSNAMEMAX); break; case 106: /* Set flags */ ND_PRINT((ndo, " trans")); UINTOUT(); ND_PRINT((ndo, " flags")); UINTOUT(); break; case 108: /* Trans create */ ND_PRINT((ndo, " vol")); UINTOUT(); ND_PRINT((ndo, " partition")); UINTOUT(); ND_PRINT((ndo, " flags")); UINTOUT(); break; case 109: /* Dump */ case 655537: /* Get size */ ND_PRINT((ndo, " fromtrans")); UINTOUT(); ND_PRINT((ndo, " fromdate")); DATEOUT(); break; case 110: /* Get n-th volume */ ND_PRINT((ndo, " index")); UINTOUT(); break; case 111: /* Set forwarding */ ND_PRINT((ndo, " tid")); UINTOUT(); ND_PRINT((ndo, " newsite")); UINTOUT(); break; case 112: /* Get name */ case 113: /* Get status */ ND_PRINT((ndo, " tid")); break; case 114: /* Signal restore */ ND_PRINT((ndo, " name")); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " type")); UINTOUT(); ND_PRINT((ndo, " pid")); UINTOUT(); ND_PRINT((ndo, " cloneid")); UINTOUT(); break; case 116: /* List volumes */ ND_PRINT((ndo, " partition")); UINTOUT(); ND_PRINT((ndo, " flags")); UINTOUT(); break; case 117: /* Set id types */ ND_PRINT((ndo, " tid")); UINTOUT(); ND_PRINT((ndo, " name")); STROUT(AFSNAMEMAX); ND_PRINT((ndo, " type")); UINTOUT(); ND_PRINT((ndo, " pid")); UINTOUT(); ND_PRINT((ndo, " clone")); UINTOUT(); ND_PRINT((ndo, " backup")); UINTOUT(); break; case 119: /* Partition info */ ND_PRINT((ndo, " name")); STROUT(AFSNAMEMAX); break; case 120: /* Reclone */ ND_PRINT((ndo, " tid")); UINTOUT(); break; case 121: /* List one volume */ case 122: /* Nuke volume */ case 124: /* Extended List volumes */ case 125: /* Extended List one volume */ case 65536: /* Convert RO to RW volume */ ND_PRINT((ndo, " partid")); UINTOUT(); ND_PRINT((ndo, " volid")); UINTOUT(); break; case 123: /* Set date */ ND_PRINT((ndo, " tid")); UINTOUT(); ND_PRINT((ndo, " date")); DATEOUT(); break; case 126: /* Set info */ ND_PRINT((ndo, " tid")); UINTOUT(); break; case 128: /* Forward multiple */ ND_PRINT((ndo, " fromtrans")); UINTOUT(); ND_PRINT((ndo, " fromdate")); DATEOUT(); { unsigned long i, j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { DESTSERVEROUT(); if (i != j - 1) ND_PRINT((ndo, ",")); } if (j == 0) ND_PRINT((ndo, " ")); } break; case 65538: /* Dump version 2 */ ND_PRINT((ndo, " fromtrans")); UINTOUT(); ND_PRINT((ndo, " fromdate")); DATEOUT(); ND_PRINT((ndo, " flags")); UINTOUT(); break; default: ; } return; trunc: ND_PRINT((ndo, " [|vol]")); } /* * Handle replies to the AFS Volume Service */ static void vol_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) { switch (opcode) { case 100: /* Create volume */ ND_PRINT((ndo, " volid")); UINTOUT(); ND_PRINT((ndo, " trans")); UINTOUT(); break; case 104: /* End transaction */ UINTOUT(); break; case 105: /* Clone */ ND_PRINT((ndo, " newvol")); UINTOUT(); break; case 107: /* Get flags */ UINTOUT(); break; case 108: /* Transaction create */ ND_PRINT((ndo, " trans")); UINTOUT(); break; case 110: /* Get n-th volume */ ND_PRINT((ndo, " volume")); UINTOUT(); ND_PRINT((ndo, " partition")); UINTOUT(); break; case 112: /* Get name */ STROUT(AFSNAMEMAX); break; case 113: /* Get status */ ND_PRINT((ndo, " volid")); UINTOUT(); ND_PRINT((ndo, " nextuniq")); UINTOUT(); ND_PRINT((ndo, " type")); UINTOUT(); ND_PRINT((ndo, " parentid")); UINTOUT(); ND_PRINT((ndo, " clone")); UINTOUT(); ND_PRINT((ndo, " backup")); UINTOUT(); ND_PRINT((ndo, " restore")); UINTOUT(); ND_PRINT((ndo, " maxquota")); UINTOUT(); ND_PRINT((ndo, " minquota")); UINTOUT(); ND_PRINT((ndo, " owner")); UINTOUT(); ND_PRINT((ndo, " create")); DATEOUT(); ND_PRINT((ndo, " access")); DATEOUT(); ND_PRINT((ndo, " update")); DATEOUT(); ND_PRINT((ndo, " expire")); DATEOUT(); ND_PRINT((ndo, " backup")); DATEOUT(); ND_PRINT((ndo, " copy")); DATEOUT(); break; case 115: /* Old list partitions */ break; case 116: /* List volumes */ case 121: /* List one volume */ { unsigned long i, j; ND_TCHECK2(bp[0], 4); j = EXTRACT_32BITS(bp); bp += sizeof(int32_t); for (i = 0; i < j; i++) { ND_PRINT((ndo, " name")); VECOUT(32); ND_PRINT((ndo, " volid")); UINTOUT(); ND_PRINT((ndo, " type")); bp += sizeof(int32_t) * 21; if (i != j - 1) ND_PRINT((ndo, ",")); } if (j == 0) ND_PRINT((ndo, " ")); } break; default: ; } } else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|vol]")); } /* * Handle calls to the AFS BOS service */ static void bos_print(netdissect_options *ndo, register const u_char *bp, int length) { int bos_op; if (length <= (int)sizeof(struct rx_header)) return; if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) { goto trunc; } /* * Print out the afs call we're invoking. The table used here was * gleaned from bozo/bosint.xg */ bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op))); /* * Decode some of the arguments to the BOS calls */ bp += sizeof(struct rx_header) + 4; switch (bos_op) { case 80: /* Create B node */ ND_PRINT((ndo, " type")); STROUT(BOSNAMEMAX); ND_PRINT((ndo, " instance")); STROUT(BOSNAMEMAX); break; case 81: /* Delete B node */ case 83: /* Get status */ case 85: /* Get instance info */ case 87: /* Add super user */ case 88: /* Delete super user */ case 93: /* Set cell name */ case 96: /* Add cell host */ case 97: /* Delete cell host */ case 104: /* Restart */ case 106: /* Uninstall */ case 108: /* Exec */ case 112: /* Getlog */ case 114: /* Get instance strings */ STROUT(BOSNAMEMAX); break; case 82: /* Set status */ case 98: /* Set T status */ STROUT(BOSNAMEMAX); ND_PRINT((ndo, " status")); INTOUT(); break; case 86: /* Get instance parm */ STROUT(BOSNAMEMAX); ND_PRINT((ndo, " num")); INTOUT(); break; case 84: /* Enumerate instance */ case 89: /* List super users */ case 90: /* List keys */ case 91: /* Add key */ case 92: /* Delete key */ case 95: /* Get cell host */ INTOUT(); break; case 105: /* Install */ STROUT(BOSNAMEMAX); ND_PRINT((ndo, " size")); INTOUT(); ND_PRINT((ndo, " flags")); INTOUT(); ND_PRINT((ndo, " date")); INTOUT(); break; default: ; } return; trunc: ND_PRINT((ndo, " [|bos]")); } /* * Handle replies to the AFS BOS Service */ static void bos_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; if (length <= (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the afs call we're invoking. The table used here was * gleaned from volser/volint.xg */ ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, interpret the response. */ if (rxh->type == RX_PACKET_TYPE_DATA) /* Well, no, not really. Leave this for later */ ; else { /* * Otherwise, just print out the return code */ ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|bos]")); } /* * Check to see if this is a Ubik opcode. */ static int is_ubik(uint32_t opcode) { if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || (opcode >= DISK_LOW && opcode <= DISK_HIGH)) return(1); else return(0); } /* * Handle Ubik opcodes to any one of the replicated database services */ static void ubik_print(netdissect_options *ndo, register const u_char *bp) { int ubik_op; int32_t temp; /* * Print out the afs call we're invoking. The table used here was * gleaned from ubik/ubik_int.xg */ /* Every function that calls this function first makes a bounds check * for (sizeof(rx_header) + 4) bytes, so long as it remains this way * the line below will not over-read. */ ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header)); ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op))); /* * Decode some of the arguments to the Ubik calls */ bp += sizeof(struct rx_header) + 4; switch (ubik_op) { case 10000: /* Beacon */ ND_TCHECK2(bp[0], 4); temp = EXTRACT_32BITS(bp); bp += sizeof(int32_t); ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no")); ND_PRINT((ndo, " votestart")); DATEOUT(); ND_PRINT((ndo, " dbversion")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); break; case 10003: /* Get sync site */ ND_PRINT((ndo, " site")); UINTOUT(); break; case 20000: /* Begin */ case 20001: /* Commit */ case 20007: /* Abort */ case 20008: /* Release locks */ case 20010: /* Writev */ ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); break; case 20002: /* Lock */ ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " file")); INTOUT(); ND_PRINT((ndo, " pos")); INTOUT(); ND_PRINT((ndo, " length")); INTOUT(); ND_TCHECK_32BITS(bp); temp = EXTRACT_32BITS(bp); bp += sizeof(int32_t); tok2str(ubik_lock_types, "type %d", temp); break; case 20003: /* Write */ ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " file")); INTOUT(); ND_PRINT((ndo, " pos")); INTOUT(); break; case 20005: /* Get file */ ND_PRINT((ndo, " file")); INTOUT(); break; case 20006: /* Send file */ ND_PRINT((ndo, " file")); INTOUT(); ND_PRINT((ndo, " length")); INTOUT(); ND_PRINT((ndo, " dbversion")); UBIK_VERSIONOUT(); break; case 20009: /* Truncate */ ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " file")); INTOUT(); ND_PRINT((ndo, " length")); INTOUT(); break; case 20012: /* Set version */ ND_PRINT((ndo, " tid")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " oldversion")); UBIK_VERSIONOUT(); ND_PRINT((ndo, " newversion")); UBIK_VERSIONOUT(); break; default: ; } return; trunc: ND_PRINT((ndo, " [|ubik]")); } /* * Handle Ubik replies to any one of the replicated database services */ static void ubik_reply_print(netdissect_options *ndo, register const u_char *bp, int length, int32_t opcode) { const struct rx_header *rxh; if (length < (int)sizeof(struct rx_header)) return; rxh = (const struct rx_header *) bp; /* * Print out the ubik call we're invoking. This table was gleaned * from ubik/ubik_int.xg */ ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode))); bp += sizeof(struct rx_header); /* * If it was a data packet, print out the arguments to the Ubik calls */ if (rxh->type == RX_PACKET_TYPE_DATA) switch (opcode) { case 10000: /* Beacon */ ND_PRINT((ndo, " vote no")); break; case 20004: /* Get version */ ND_PRINT((ndo, " dbversion")); UBIK_VERSIONOUT(); break; default: ; } /* * Otherwise, print out "yes" it it was a beacon packet (because * that's how yes votes are returned, go figure), otherwise * just print out the error code. */ else switch (opcode) { case 10000: /* Beacon */ ND_PRINT((ndo, " vote yes until")); DATEOUT(); break; default: ND_PRINT((ndo, " errcode")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|ubik]")); } /* * Handle RX ACK packets. */ static void rx_ack_print(netdissect_options *ndo, register const u_char *bp, int length) { const struct rx_ackPacket *rxa; int i, start, last; uint32_t firstPacket; if (length < (int)sizeof(struct rx_header)) return; bp += sizeof(struct rx_header); /* * This may seem a little odd .... the rx_ackPacket structure * contains an array of individual packet acknowledgements * (used for selective ack/nack), but since it's variable in size, * we don't want to truncate based on the size of the whole * rx_ackPacket structure. */ ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS); rxa = (const struct rx_ackPacket *) bp; bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS); /* * Print out a few useful things from the ack packet structure */ if (ndo->ndo_vflag > 2) ND_PRINT((ndo, " bufspace %d maxskew %d", (int) EXTRACT_16BITS(&rxa->bufferSpace), (int) EXTRACT_16BITS(&rxa->maxSkew))); firstPacket = EXTRACT_32BITS(&rxa->firstPacket); ND_PRINT((ndo, " first %d serial %d reason %s", firstPacket, EXTRACT_32BITS(&rxa->serial), tok2str(rx_ack_reasons, "#%d", (int) rxa->reason))); /* * Okay, now we print out the ack array. The way _this_ works * is that we start at "first", and step through the ack array. * If we have a contiguous range of acks/nacks, try to * collapse them into a range. * * If you're really clever, you might have noticed that this * doesn't seem quite correct. Specifically, due to structure * padding, sizeof(struct rx_ackPacket) - RX_MAXACKS won't actually * yield the start of the ack array (because RX_MAXACKS is 255 * and the structure will likely get padded to a 2 or 4 byte * boundary). However, this is the way it's implemented inside * of AFS - the start of the extra fields are at * sizeof(struct rx_ackPacket) - RX_MAXACKS + nAcks, which _isn't_ * the exact start of the ack array. Sigh. That's why we aren't * using bp, but instead use rxa->acks[]. But nAcks gets added * to bp after this, so bp ends up at the right spot. Go figure. */ if (rxa->nAcks != 0) { ND_TCHECK2(bp[0], rxa->nAcks); /* * Sigh, this is gross, but it seems to work to collapse * ranges correctly. */ for (i = 0, start = last = -2; i < rxa->nAcks; i++) if (rxa->acks[i] == RX_ACK_TYPE_ACK) { /* * I figured this deserved _some_ explanation. * First, print "acked" and the packet seq * number if this is the first time we've * seen an acked packet. */ if (last == -2) { ND_PRINT((ndo, " acked %d", firstPacket + i)); start = i; } /* * Otherwise, if there is a skip in * the range (such as an nacked packet in * the middle of some acked packets), * then print the current packet number * seperated from the last number by * a comma. */ else if (last != i - 1) { ND_PRINT((ndo, ",%d", firstPacket + i)); start = i; } /* * We always set last to the value of * the last ack we saw. Conversely, start * is set to the value of the first ack * we saw in a range. */ last = i; /* * Okay, this bit a code gets executed when * we hit a nack ... in _this_ case we * want to print out the range of packets * that were acked, so we need to print * the _previous_ packet number seperated * from the first by a dash (-). Since we * already printed the first packet above, * just print the final packet. Don't * do this if there will be a single-length * range. */ } else if (last == i - 1 && start != last) ND_PRINT((ndo, "-%d", firstPacket + i - 1)); /* * So, what's going on here? We ran off the end of the * ack list, and if we got a range we need to finish it up. * So we need to determine if the last packet in the list * was an ack (if so, then last will be set to it) and * we need to see if the last range didn't start with the * last packet (because if it _did_, then that would mean * that the packet number has already been printed and * we don't need to print it again). */ if (last == i - 1 && start != last) ND_PRINT((ndo, "-%d", firstPacket + i - 1)); /* * Same as above, just without comments */ for (i = 0, start = last = -2; i < rxa->nAcks; i++) if (rxa->acks[i] == RX_ACK_TYPE_NACK) { if (last == -2) { ND_PRINT((ndo, " nacked %d", firstPacket + i)); start = i; } else if (last != i - 1) { ND_PRINT((ndo, ",%d", firstPacket + i)); start = i; } last = i; } else if (last == i - 1 && start != last) ND_PRINT((ndo, "-%d", firstPacket + i - 1)); if (last == i - 1 && start != last) ND_PRINT((ndo, "-%d", firstPacket + i - 1)); bp += rxa->nAcks; } /* * These are optional fields; depending on your version of AFS, * you may or may not see them */ #define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return; if (ndo->ndo_vflag > 1) { TRUNCRET(4); ND_PRINT((ndo, " ifmtu")); INTOUT(); TRUNCRET(4); ND_PRINT((ndo, " maxmtu")); INTOUT(); TRUNCRET(4); ND_PRINT((ndo, " rwind")); INTOUT(); TRUNCRET(4); ND_PRINT((ndo, " maxpackets")); INTOUT(); } return; trunc: ND_PRINT((ndo, " [|ack]")); } #undef TRUNCRET Index: vendor/tcpdump/dist/print-sflow.c =================================================================== --- vendor/tcpdump/dist/print-sflow.c (revision 353143) +++ vendor/tcpdump/dist/print-sflow.c (revision 353144) @@ -1,991 +1,1001 @@ /* * Copyright (c) 1998-2007 The TCPDUMP project * * 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 Carles Kishimoto * * Expansion and refactoring by Rick Jones */ /* \summary: sFlow protocol printer */ /* specification: http://www.sflow.org/developers/specifications.php */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" /* * sFlow datagram * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Sflow version (2,4,5) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP version (1 for IPv4 | 2 for IPv6) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP Address AGENT (4 or 16 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Sub agent ID | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Datagram sequence number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Switch uptime in ms | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | num samples in datagram | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ struct sflow_datagram_t { uint8_t version[4]; uint8_t ip_version[4]; uint8_t agent[4]; uint8_t agent_id[4]; uint8_t seqnum[4]; uint8_t uptime[4]; uint8_t samples[4]; }; struct sflow_sample_header { uint8_t format[4]; uint8_t len[4]; }; #define SFLOW_FLOW_SAMPLE 1 #define SFLOW_COUNTER_SAMPLE 2 #define SFLOW_EXPANDED_FLOW_SAMPLE 3 #define SFLOW_EXPANDED_COUNTER_SAMPLE 4 static const struct tok sflow_format_values[] = { { SFLOW_FLOW_SAMPLE, "flow sample" }, { SFLOW_COUNTER_SAMPLE, "counter sample" }, { SFLOW_EXPANDED_FLOW_SAMPLE, "expanded flow sample" }, { SFLOW_EXPANDED_COUNTER_SAMPLE, "expanded counter sample" }, { 0, NULL} }; struct sflow_flow_sample_t { uint8_t seqnum[4]; uint8_t typesource[4]; uint8_t rate[4]; uint8_t pool[4]; uint8_t drops[4]; uint8_t in_interface[4]; uint8_t out_interface[4]; uint8_t records[4]; }; struct sflow_expanded_flow_sample_t { uint8_t seqnum[4]; uint8_t type[4]; uint8_t index[4]; uint8_t rate[4]; uint8_t pool[4]; uint8_t drops[4]; uint8_t in_interface_format[4]; uint8_t in_interface_value[4]; uint8_t out_interface_format[4]; uint8_t out_interface_value[4]; uint8_t records[4]; }; #define SFLOW_FLOW_RAW_PACKET 1 #define SFLOW_FLOW_ETHERNET_FRAME 2 #define SFLOW_FLOW_IPV4_DATA 3 #define SFLOW_FLOW_IPV6_DATA 4 #define SFLOW_FLOW_EXTENDED_SWITCH_DATA 1001 #define SFLOW_FLOW_EXTENDED_ROUTER_DATA 1002 #define SFLOW_FLOW_EXTENDED_GATEWAY_DATA 1003 #define SFLOW_FLOW_EXTENDED_USER_DATA 1004 #define SFLOW_FLOW_EXTENDED_URL_DATA 1005 #define SFLOW_FLOW_EXTENDED_MPLS_DATA 1006 #define SFLOW_FLOW_EXTENDED_NAT_DATA 1007 #define SFLOW_FLOW_EXTENDED_MPLS_TUNNEL 1008 #define SFLOW_FLOW_EXTENDED_MPLS_VC 1009 #define SFLOW_FLOW_EXTENDED_MPLS_FEC 1010 #define SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC 1011 #define SFLOW_FLOW_EXTENDED_VLAN_TUNNEL 1012 static const struct tok sflow_flow_type_values[] = { { SFLOW_FLOW_RAW_PACKET, "Raw packet"}, { SFLOW_FLOW_ETHERNET_FRAME, "Ethernet frame"}, { SFLOW_FLOW_IPV4_DATA, "IPv4 Data"}, { SFLOW_FLOW_IPV6_DATA, "IPv6 Data"}, { SFLOW_FLOW_EXTENDED_SWITCH_DATA, "Extended Switch data"}, { SFLOW_FLOW_EXTENDED_ROUTER_DATA, "Extended Router data"}, { SFLOW_FLOW_EXTENDED_GATEWAY_DATA, "Extended Gateway data"}, { SFLOW_FLOW_EXTENDED_USER_DATA, "Extended User data"}, { SFLOW_FLOW_EXTENDED_URL_DATA, "Extended URL data"}, { SFLOW_FLOW_EXTENDED_MPLS_DATA, "Extended MPLS data"}, { SFLOW_FLOW_EXTENDED_NAT_DATA, "Extended NAT data"}, { SFLOW_FLOW_EXTENDED_MPLS_TUNNEL, "Extended MPLS tunnel"}, { SFLOW_FLOW_EXTENDED_MPLS_VC, "Extended MPLS VC"}, { SFLOW_FLOW_EXTENDED_MPLS_FEC, "Extended MPLS FEC"}, { SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC, "Extended MPLS LVP FEC"}, { SFLOW_FLOW_EXTENDED_VLAN_TUNNEL, "Extended VLAN Tunnel"}, { 0, NULL} }; #define SFLOW_HEADER_PROTOCOL_ETHERNET 1 #define SFLOW_HEADER_PROTOCOL_IPV4 11 #define SFLOW_HEADER_PROTOCOL_IPV6 12 static const struct tok sflow_flow_raw_protocol_values[] = { { SFLOW_HEADER_PROTOCOL_ETHERNET, "Ethernet"}, { SFLOW_HEADER_PROTOCOL_IPV4, "IPv4"}, { SFLOW_HEADER_PROTOCOL_IPV6, "IPv6"}, { 0, NULL} }; struct sflow_expanded_flow_raw_t { uint8_t protocol[4]; uint8_t length[4]; uint8_t stripped_bytes[4]; uint8_t header_size[4]; }; struct sflow_ethernet_frame_t { uint8_t length[4]; uint8_t src_mac[8]; uint8_t dst_mac[8]; uint8_t type[4]; }; struct sflow_extended_switch_data_t { uint8_t src_vlan[4]; uint8_t src_pri[4]; uint8_t dst_vlan[4]; uint8_t dst_pri[4]; }; struct sflow_counter_record_t { uint8_t format[4]; uint8_t length[4]; }; struct sflow_flow_record_t { uint8_t format[4]; uint8_t length[4]; }; struct sflow_counter_sample_t { uint8_t seqnum[4]; uint8_t typesource[4]; uint8_t records[4]; }; struct sflow_expanded_counter_sample_t { uint8_t seqnum[4]; uint8_t type[4]; uint8_t index[4]; uint8_t records[4]; }; #define SFLOW_COUNTER_GENERIC 1 #define SFLOW_COUNTER_ETHERNET 2 #define SFLOW_COUNTER_TOKEN_RING 3 #define SFLOW_COUNTER_BASEVG 4 #define SFLOW_COUNTER_VLAN 5 #define SFLOW_COUNTER_PROCESSOR 1001 static const struct tok sflow_counter_type_values[] = { { SFLOW_COUNTER_GENERIC, "Generic counter"}, { SFLOW_COUNTER_ETHERNET, "Ethernet counter"}, { SFLOW_COUNTER_TOKEN_RING, "Token ring counter"}, { SFLOW_COUNTER_BASEVG, "100 BaseVG counter"}, { SFLOW_COUNTER_VLAN, "Vlan counter"}, { SFLOW_COUNTER_PROCESSOR, "Processor counter"}, { 0, NULL} }; #define SFLOW_IFACE_DIRECTION_UNKNOWN 0 #define SFLOW_IFACE_DIRECTION_FULLDUPLEX 1 #define SFLOW_IFACE_DIRECTION_HALFDUPLEX 2 #define SFLOW_IFACE_DIRECTION_IN 3 #define SFLOW_IFACE_DIRECTION_OUT 4 static const struct tok sflow_iface_direction_values[] = { { SFLOW_IFACE_DIRECTION_UNKNOWN, "unknown"}, { SFLOW_IFACE_DIRECTION_FULLDUPLEX, "full-duplex"}, { SFLOW_IFACE_DIRECTION_HALFDUPLEX, "half-duplex"}, { SFLOW_IFACE_DIRECTION_IN, "in"}, { SFLOW_IFACE_DIRECTION_OUT, "out"}, { 0, NULL} }; struct sflow_generic_counter_t { uint8_t ifindex[4]; uint8_t iftype[4]; uint8_t ifspeed[8]; uint8_t ifdirection[4]; uint8_t ifstatus[4]; uint8_t ifinoctets[8]; uint8_t ifinunicastpkts[4]; uint8_t ifinmulticastpkts[4]; uint8_t ifinbroadcastpkts[4]; uint8_t ifindiscards[4]; uint8_t ifinerrors[4]; uint8_t ifinunkownprotos[4]; uint8_t ifoutoctets[8]; uint8_t ifoutunicastpkts[4]; uint8_t ifoutmulticastpkts[4]; uint8_t ifoutbroadcastpkts[4]; uint8_t ifoutdiscards[4]; uint8_t ifouterrors[4]; uint8_t ifpromiscmode[4]; }; struct sflow_ethernet_counter_t { uint8_t alignerrors[4]; uint8_t fcserrors[4]; uint8_t single_collision_frames[4]; uint8_t multiple_collision_frames[4]; uint8_t test_errors[4]; uint8_t deferred_transmissions[4]; uint8_t late_collisions[4]; uint8_t excessive_collisions[4]; uint8_t mac_transmit_errors[4]; uint8_t carrier_sense_errors[4]; uint8_t frame_too_longs[4]; uint8_t mac_receive_errors[4]; uint8_t symbol_errors[4]; }; struct sflow_100basevg_counter_t { uint8_t in_highpriority_frames[4]; uint8_t in_highpriority_octets[8]; uint8_t in_normpriority_frames[4]; uint8_t in_normpriority_octets[8]; uint8_t in_ipmerrors[4]; uint8_t in_oversized[4]; uint8_t in_data_errors[4]; uint8_t in_null_addressed_frames[4]; uint8_t out_highpriority_frames[4]; uint8_t out_highpriority_octets[8]; uint8_t transitioninto_frames[4]; uint8_t hc_in_highpriority_octets[8]; uint8_t hc_in_normpriority_octets[8]; uint8_t hc_out_highpriority_octets[8]; }; struct sflow_vlan_counter_t { uint8_t vlan_id[4]; uint8_t octets[8]; uint8_t unicast_pkt[4]; uint8_t multicast_pkt[4]; uint8_t broadcast_pkt[4]; uint8_t discards[4]; }; static int print_sflow_counter_generic(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_generic_counter_t *sflow_gen_counter; if (len < sizeof(struct sflow_generic_counter_t)) return 1; sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer; ND_TCHECK(*sflow_gen_counter); ND_PRINT((ndo, "\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)", EXTRACT_32BITS(sflow_gen_counter->ifindex), EXTRACT_32BITS(sflow_gen_counter->iftype), EXTRACT_64BITS(sflow_gen_counter->ifspeed), EXTRACT_32BITS(sflow_gen_counter->ifdirection), tok2str(sflow_iface_direction_values, "Unknown", EXTRACT_32BITS(sflow_gen_counter->ifdirection)))); ND_PRINT((ndo, "\n\t ifstatus %u, adminstatus: %s, operstatus: %s", EXTRACT_32BITS(sflow_gen_counter->ifstatus), EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down", (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down")); ND_PRINT((ndo, "\n\t In octets %" PRIu64 ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u", EXTRACT_64BITS(sflow_gen_counter->ifinoctets), EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts), EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts), EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts), EXTRACT_32BITS(sflow_gen_counter->ifindiscards))); ND_PRINT((ndo, "\n\t In errors %u, unknown protos %u", EXTRACT_32BITS(sflow_gen_counter->ifinerrors), EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos))); ND_PRINT((ndo, "\n\t Out octets %" PRIu64 ", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u", EXTRACT_64BITS(sflow_gen_counter->ifoutoctets), EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts), EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts), EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts), EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards))); ND_PRINT((ndo, "\n\t Out errors %u, promisc mode %u", EXTRACT_32BITS(sflow_gen_counter->ifouterrors), EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode))); return 0; trunc: return 1; } static int print_sflow_counter_ethernet(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_ethernet_counter_t *sflow_eth_counter; if (len < sizeof(struct sflow_ethernet_counter_t)) return 1; sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer; ND_TCHECK(*sflow_eth_counter); ND_PRINT((ndo, "\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u", EXTRACT_32BITS(sflow_eth_counter->alignerrors), EXTRACT_32BITS(sflow_eth_counter->fcserrors), EXTRACT_32BITS(sflow_eth_counter->single_collision_frames), EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames), EXTRACT_32BITS(sflow_eth_counter->test_errors))); ND_PRINT((ndo, "\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u", EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions), EXTRACT_32BITS(sflow_eth_counter->late_collisions), EXTRACT_32BITS(sflow_eth_counter->excessive_collisions), EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors))); ND_PRINT((ndo, "\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u", EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors), EXTRACT_32BITS(sflow_eth_counter->frame_too_longs), EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors), EXTRACT_32BITS(sflow_eth_counter->symbol_errors))); return 0; trunc: return 1; } static int print_sflow_counter_token_ring(netdissect_options *ndo _U_, const u_char *pointer _U_, u_int len _U_) { return 0; } static int print_sflow_counter_basevg(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_100basevg_counter_t *sflow_100basevg_counter; if (len < sizeof(struct sflow_100basevg_counter_t)) return 1; sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer; ND_TCHECK(*sflow_100basevg_counter); ND_PRINT((ndo, "\n\t in high prio frames %u, in high prio octets %" PRIu64, EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames), EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets))); ND_PRINT((ndo, "\n\t in norm prio frames %u, in norm prio octets %" PRIu64, EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames), EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets))); ND_PRINT((ndo, "\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u", EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors), EXTRACT_32BITS(sflow_100basevg_counter->in_oversized), EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors), EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames))); ND_PRINT((ndo, "\n\t out high prio frames %u, out high prio octets %" PRIu64 ", trans into frames %u", EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames), EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets), EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames))); ND_PRINT((ndo, "\n\t in hc high prio octets %" PRIu64 ", in hc norm prio octets %" PRIu64 ", out hc high prio octets %" PRIu64, EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets), EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets), EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets))); return 0; trunc: return 1; } static int print_sflow_counter_vlan(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_vlan_counter_t *sflow_vlan_counter; if (len < sizeof(struct sflow_vlan_counter_t)) return 1; sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer; ND_TCHECK(*sflow_vlan_counter); ND_PRINT((ndo, "\n\t vlan_id %u, octets %" PRIu64 ", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u", EXTRACT_32BITS(sflow_vlan_counter->vlan_id), EXTRACT_64BITS(sflow_vlan_counter->octets), EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt), EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt), EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt), EXTRACT_32BITS(sflow_vlan_counter->discards))); return 0; trunc: return 1; } struct sflow_processor_counter_t { uint8_t five_sec_util[4]; uint8_t one_min_util[4]; uint8_t five_min_util[4]; uint8_t total_memory[8]; uint8_t free_memory[8]; }; static int print_sflow_counter_processor(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_processor_counter_t *sflow_processor_counter; if (len < sizeof(struct sflow_processor_counter_t)) return 1; sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer; ND_TCHECK(*sflow_processor_counter); ND_PRINT((ndo, "\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64 ", total_mem %" PRIu64, EXTRACT_32BITS(sflow_processor_counter->five_sec_util), EXTRACT_32BITS(sflow_processor_counter->one_min_util), EXTRACT_32BITS(sflow_processor_counter->five_min_util), EXTRACT_64BITS(sflow_processor_counter->total_memory), EXTRACT_64BITS(sflow_processor_counter->free_memory))); return 0; trunc: return 1; } static int sflow_print_counter_records(netdissect_options *ndo, const u_char *pointer, u_int len, u_int records) { u_int nrecords; const u_char *tptr; u_int tlen; u_int counter_type; u_int counter_len; u_int enterprise; const struct sflow_counter_record_t *sflow_counter_record; nrecords = records; tptr = pointer; tlen = len; while (nrecords > 0) { /* do we have the "header?" */ if (tlen < sizeof(struct sflow_counter_record_t)) return 1; sflow_counter_record = (const struct sflow_counter_record_t *)tptr; ND_TCHECK(*sflow_counter_record); enterprise = EXTRACT_32BITS(sflow_counter_record->format); counter_type = enterprise & 0x0FFF; enterprise = enterprise >> 20; counter_len = EXTRACT_32BITS(sflow_counter_record->length); ND_PRINT((ndo, "\n\t enterprise %u, %s (%u) length %u", enterprise, (enterprise == 0) ? tok2str(sflow_counter_type_values,"Unknown",counter_type) : "Unknown", counter_type, counter_len)); tptr += sizeof(struct sflow_counter_record_t); tlen -= sizeof(struct sflow_counter_record_t); if (tlen < counter_len) return 1; if (enterprise == 0) { switch (counter_type) { case SFLOW_COUNTER_GENERIC: if (print_sflow_counter_generic(ndo, tptr, tlen)) return 1; break; case SFLOW_COUNTER_ETHERNET: if (print_sflow_counter_ethernet(ndo, tptr, tlen)) return 1; break; case SFLOW_COUNTER_TOKEN_RING: if (print_sflow_counter_token_ring(ndo, tptr,tlen)) return 1; break; case SFLOW_COUNTER_BASEVG: if (print_sflow_counter_basevg(ndo, tptr, tlen)) return 1; break; case SFLOW_COUNTER_VLAN: if (print_sflow_counter_vlan(ndo, tptr, tlen)) return 1; break; case SFLOW_COUNTER_PROCESSOR: if (print_sflow_counter_processor(ndo, tptr, tlen)) return 1; break; default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t\t", counter_len); break; } } tptr += counter_len; tlen -= counter_len; nrecords--; } return 0; trunc: return 1; } static int sflow_print_counter_sample(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_counter_sample_t *sflow_counter_sample; u_int nrecords; u_int typesource; u_int type; u_int index; if (len < sizeof(struct sflow_counter_sample_t)) return 1; sflow_counter_sample = (const struct sflow_counter_sample_t *)pointer; ND_TCHECK(*sflow_counter_sample); typesource = EXTRACT_32BITS(sflow_counter_sample->typesource); nrecords = EXTRACT_32BITS(sflow_counter_sample->records); type = typesource >> 24; index = typesource & 0x0FFF; ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u", EXTRACT_32BITS(sflow_counter_sample->seqnum), type, index, nrecords)); return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t), len - sizeof(struct sflow_counter_sample_t), nrecords); trunc: return 1; } static int sflow_print_expanded_counter_sample(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample; u_int nrecords; if (len < sizeof(struct sflow_expanded_counter_sample_t)) return 1; sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)pointer; ND_TCHECK(*sflow_expanded_counter_sample); nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records); ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u", EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum), EXTRACT_32BITS(sflow_expanded_counter_sample->type), EXTRACT_32BITS(sflow_expanded_counter_sample->index), nrecords)); return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t), len - sizeof(struct sflow_expanded_counter_sample_t), nrecords); trunc: return 1; } static int print_sflow_raw_packet(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_expanded_flow_raw_t *sflow_flow_raw; if (len < sizeof(struct sflow_expanded_flow_raw_t)) return 1; sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer; ND_TCHECK(*sflow_flow_raw); ND_PRINT((ndo, "\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u", tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)), EXTRACT_32BITS(sflow_flow_raw->protocol), EXTRACT_32BITS(sflow_flow_raw->length), EXTRACT_32BITS(sflow_flow_raw->stripped_bytes), EXTRACT_32BITS(sflow_flow_raw->header_size))); /* QUESTION - should we attempt to print the raw header itself? assuming of course there is wnough data present to do so... */ return 0; trunc: return 1; } static int print_sflow_ethernet_frame(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_ethernet_frame_t *sflow_ethernet_frame; if (len < sizeof(struct sflow_ethernet_frame_t)) return 1; sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer; ND_TCHECK(*sflow_ethernet_frame); ND_PRINT((ndo, "\n\t frame len %u, type %u", EXTRACT_32BITS(sflow_ethernet_frame->length), EXTRACT_32BITS(sflow_ethernet_frame->type))); return 0; trunc: return 1; } static int print_sflow_extended_switch_data(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_extended_switch_data_t *sflow_extended_sw_data; if (len < sizeof(struct sflow_extended_switch_data_t)) return 1; sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer; ND_TCHECK(*sflow_extended_sw_data); ND_PRINT((ndo, "\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u", EXTRACT_32BITS(sflow_extended_sw_data->src_vlan), EXTRACT_32BITS(sflow_extended_sw_data->src_pri), EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan), EXTRACT_32BITS(sflow_extended_sw_data->dst_pri))); return 0; trunc: return 1; } static int sflow_print_flow_records(netdissect_options *ndo, const u_char *pointer, u_int len, u_int records) { u_int nrecords; const u_char *tptr; u_int tlen; u_int flow_type; u_int enterprise; u_int flow_len; const struct sflow_flow_record_t *sflow_flow_record; nrecords = records; tptr = pointer; tlen = len; while (nrecords > 0) { /* do we have the "header?" */ if (tlen < sizeof(struct sflow_flow_record_t)) return 1; sflow_flow_record = (const struct sflow_flow_record_t *)tptr; ND_TCHECK(*sflow_flow_record); /* so, the funky encoding means we cannot blythly mask-off bits, we must also check the enterprise. */ enterprise = EXTRACT_32BITS(sflow_flow_record->format); flow_type = enterprise & 0x0FFF; enterprise = enterprise >> 12; flow_len = EXTRACT_32BITS(sflow_flow_record->length); ND_PRINT((ndo, "\n\t enterprise %u %s (%u) length %u", enterprise, (enterprise == 0) ? tok2str(sflow_flow_type_values,"Unknown",flow_type) : "Unknown", flow_type, flow_len)); tptr += sizeof(struct sflow_flow_record_t); tlen -= sizeof(struct sflow_flow_record_t); if (tlen < flow_len) return 1; if (enterprise == 0) { switch (flow_type) { case SFLOW_FLOW_RAW_PACKET: if (print_sflow_raw_packet(ndo, tptr, tlen)) return 1; break; case SFLOW_FLOW_EXTENDED_SWITCH_DATA: if (print_sflow_extended_switch_data(ndo, tptr, tlen)) return 1; break; case SFLOW_FLOW_ETHERNET_FRAME: if (print_sflow_ethernet_frame(ndo, tptr, tlen)) return 1; break; /* FIXME these need a decoder */ case SFLOW_FLOW_IPV4_DATA: case SFLOW_FLOW_IPV6_DATA: case SFLOW_FLOW_EXTENDED_ROUTER_DATA: case SFLOW_FLOW_EXTENDED_GATEWAY_DATA: case SFLOW_FLOW_EXTENDED_USER_DATA: case SFLOW_FLOW_EXTENDED_URL_DATA: case SFLOW_FLOW_EXTENDED_MPLS_DATA: case SFLOW_FLOW_EXTENDED_NAT_DATA: case SFLOW_FLOW_EXTENDED_MPLS_TUNNEL: case SFLOW_FLOW_EXTENDED_MPLS_VC: case SFLOW_FLOW_EXTENDED_MPLS_FEC: case SFLOW_FLOW_EXTENDED_MPLS_LVP_FEC: case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL: break; default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t\t", flow_len); break; } } tptr += flow_len; tlen -= flow_len; nrecords--; } return 0; trunc: return 1; } static int sflow_print_flow_sample(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_flow_sample_t *sflow_flow_sample; u_int nrecords; u_int typesource; u_int type; u_int index; if (len < sizeof(struct sflow_flow_sample_t)) return 1; sflow_flow_sample = (const struct sflow_flow_sample_t *)pointer; ND_TCHECK(*sflow_flow_sample); typesource = EXTRACT_32BITS(sflow_flow_sample->typesource); nrecords = EXTRACT_32BITS(sflow_flow_sample->records); type = typesource >> 24; index = typesource & 0x0FFF; ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u", EXTRACT_32BITS(sflow_flow_sample->seqnum), type, index, EXTRACT_32BITS(sflow_flow_sample->rate), EXTRACT_32BITS(sflow_flow_sample->pool), EXTRACT_32BITS(sflow_flow_sample->drops), EXTRACT_32BITS(sflow_flow_sample->in_interface), EXTRACT_32BITS(sflow_flow_sample->out_interface), nrecords)); return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t), len - sizeof(struct sflow_flow_sample_t), nrecords); trunc: return 1; } static int sflow_print_expanded_flow_sample(netdissect_options *ndo, const u_char *pointer, u_int len) { const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample; u_int nrecords; if (len < sizeof(struct sflow_expanded_flow_sample_t)) return 1; sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)pointer; ND_TCHECK(*sflow_expanded_flow_sample); nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records); ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u", EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum), EXTRACT_32BITS(sflow_expanded_flow_sample->type), EXTRACT_32BITS(sflow_expanded_flow_sample->index), EXTRACT_32BITS(sflow_expanded_flow_sample->rate), EXTRACT_32BITS(sflow_expanded_flow_sample->pool), EXTRACT_32BITS(sflow_expanded_flow_sample->drops), EXTRACT_32BITS(sflow_expanded_flow_sample->records))); return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t), len - sizeof(struct sflow_expanded_flow_sample_t), nrecords); trunc: return 1; } void sflow_print(netdissect_options *ndo, const u_char *pptr, u_int len) { const struct sflow_datagram_t *sflow_datagram; const struct sflow_sample_header *sflow_sample; const u_char *tptr; u_int tlen; uint32_t sflow_sample_type, sflow_sample_len; uint32_t nsamples; tptr = pptr; tlen = len; sflow_datagram = (const struct sflow_datagram_t *)pptr; + if (len < sizeof(struct sflow_datagram_t)) { + ND_TCHECK(sflow_datagram->version); + ND_PRINT((ndo, "sFlowv%u", EXTRACT_32BITS(sflow_datagram->version))); + ND_PRINT((ndo, " [length %u < %zu]", + len, sizeof(struct sflow_datagram_t))); + ND_PRINT((ndo, " (invalid)")); + return; + } ND_TCHECK(*sflow_datagram); /* * Sanity checking of the header. */ if (EXTRACT_32BITS(sflow_datagram->version) != 5) { ND_PRINT((ndo, "sFlow version %u packet not supported", EXTRACT_32BITS(sflow_datagram->version))); return; } if (ndo->ndo_vflag < 1) { ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, length %u", EXTRACT_32BITS(sflow_datagram->version), EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", ipaddr_string(ndo, sflow_datagram->agent), EXTRACT_32BITS(sflow_datagram->agent_id), len)); return; } /* ok they seem to want to know everything - lets fully decode it */ nsamples=EXTRACT_32BITS(sflow_datagram->samples); ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u", EXTRACT_32BITS(sflow_datagram->version), EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6", ipaddr_string(ndo, sflow_datagram->agent), EXTRACT_32BITS(sflow_datagram->agent_id), EXTRACT_32BITS(sflow_datagram->seqnum), EXTRACT_32BITS(sflow_datagram->uptime), nsamples, len)); /* skip Common header */ tptr += sizeof(const struct sflow_datagram_t); + + if(tlen <= sizeof(const struct sflow_datagram_t)) goto trunc; tlen -= sizeof(const struct sflow_datagram_t); while (nsamples > 0 && tlen > 0) { sflow_sample = (const struct sflow_sample_header *)tptr; ND_TCHECK(*sflow_sample); sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF); sflow_sample_len = EXTRACT_32BITS(sflow_sample->len); if (tlen < sizeof(struct sflow_sample_header)) goto trunc; tptr += sizeof(struct sflow_sample_header); tlen -= sizeof(struct sflow_sample_header); ND_PRINT((ndo, "\n\t%s (%u), length %u,", tok2str(sflow_format_values, "Unknown", sflow_sample_type), sflow_sample_type, sflow_sample_len)); /* basic sanity check */ if (sflow_sample_type == 0 || sflow_sample_len ==0) { return; } if (tlen < sflow_sample_len) goto trunc; /* did we capture enough for fully decoding the sample ? */ ND_TCHECK2(*tptr, sflow_sample_len); switch(sflow_sample_type) { case SFLOW_FLOW_SAMPLE: if (sflow_print_flow_sample(ndo, tptr, tlen)) goto trunc; break; case SFLOW_COUNTER_SAMPLE: if (sflow_print_counter_sample(ndo, tptr,tlen)) goto trunc; break; case SFLOW_EXPANDED_FLOW_SAMPLE: if (sflow_print_expanded_flow_sample(ndo, tptr, tlen)) goto trunc; break; case SFLOW_EXPANDED_COUNTER_SAMPLE: if (sflow_print_expanded_counter_sample(ndo, tptr,tlen)) goto trunc; break; default: if (ndo->ndo_vflag <= 1) print_unknown_data(ndo, tptr, "\n\t ", sflow_sample_len); break; } tptr += sflow_sample_len; tlen -= sflow_sample_len; nsamples--; } return; trunc: ND_PRINT((ndo, "[|SFLOW]")); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */ Index: vendor/tcpdump/dist/print-sl.c =================================================================== --- vendor/tcpdump/dist/print-sl.c (revision 353143) +++ vendor/tcpdump/dist/print-sl.c (revision 353144) @@ -1,276 +1,290 @@ /* * Copyright (c) 1989, 1990, 1991, 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. */ /* \summary: Compressed Serial Line Internet Protocol printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "ip.h" #include "tcp.h" #include "slcompress.h" /* * definitions of the pseudo- link-level header attached to slip * packets grabbed by the packet filter (bpf) traffic monitor. */ #define SLIP_HDRLEN 16 #define SLX_DIR 0 #define SLX_CHDR 1 #define CHDR_LEN 15 #define SLIPDIR_IN 0 #define SLIPDIR_OUT 1 static const char tstr[] = "[|slip]"; static u_int lastlen[2][256]; static u_int lastconn = 255; -static void sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int); -static void compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int); +static int sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int); +static int compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int); u_int sl_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) { ND_PRINT((ndo, "%s", tstr)); return (caplen); } caplen -= SLIP_HDRLEN; length -= SLIP_HDRLEN; ip = (const struct ip *)(p + SLIP_HDRLEN); if (ndo->ndo_eflag) - sliplink_print(ndo, p, ip, length); + if (sliplink_print(ndo, p, ip, length) == -1) { + ND_PRINT((ndo, "%s", tstr)); + return (caplen + SLIP_HDRLEN); + } if (caplen < 1 || length < 1) { ND_PRINT((ndo, "%s", tstr)); return (caplen + SLIP_HDRLEN); } switch (IP_V(ip)) { case 4: ip_print(ndo, (const u_char *)ip, length); break; case 6: ip6_print(ndo, (const u_char *)ip, length); break; default: ND_PRINT((ndo, "ip v%d", IP_V(ip))); } return (SLIP_HDRLEN); } u_int sl_bsdos_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { register u_int caplen = h->caplen; register u_int length = h->len; register const struct ip *ip; if (caplen < SLIP_HDRLEN) { ND_PRINT((ndo, "%s", tstr)); return (caplen); } length -= SLIP_HDRLEN; ip = (const struct ip *)(p + SLIP_HDRLEN); #ifdef notdef if (ndo->ndo_eflag) sliplink_print(ndo, p, ip, length); #endif ip_print(ndo, (const u_char *)ip, length); return (SLIP_HDRLEN); } -static void +static int sliplink_print(netdissect_options *ndo, register const u_char *p, register const struct ip *ip, register u_int length) { int dir; u_int hlen; dir = p[SLX_DIR]; switch (dir) { case SLIPDIR_IN: ND_PRINT((ndo, "I ")); break; case SLIPDIR_OUT: ND_PRINT((ndo, "O ")); break; default: ND_PRINT((ndo, "Invalid direction %d ", dir)); dir = -1; break; } if (ndo->ndo_nflag) { /* XXX just dump the header */ register int i; for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i) ND_PRINT((ndo, "%02x.", p[i])); ND_PRINT((ndo, "%02x: ", p[SLX_CHDR + CHDR_LEN - 1])); - return; + return 0; } switch (p[SLX_CHDR] & 0xf0) { case TYPE_IP: ND_PRINT((ndo, "ip %d: ", length + SLIP_HDRLEN)); break; case TYPE_UNCOMPRESSED_TCP: /* * The connection id is stored in the IP protocol field. * Get it from the link layer since sl_uncompress_tcp() * has restored the IP header copy to IPPROTO_TCP. */ lastconn = ((const struct ip *)&p[SLX_CHDR])->ip_p; ND_PRINT((ndo, "utcp %d: ", lastconn)); if (dir == -1) { /* Direction is bogus, don't use it */ - return; + return 0; } + ND_TCHECK(*ip); hlen = IP_HL(ip); + ND_TCHECK(*((const struct tcphdr *)&((const int *)ip)[hlen])); hlen += TH_OFF((const struct tcphdr *)&((const int *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); break; default: if (dir == -1) { /* Direction is bogus, don't use it */ - return; + return 0; } if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) { - compressed_sl_print(ndo, &p[SLX_CHDR], ip, - length, dir); + if (compressed_sl_print(ndo, &p[SLX_CHDR], ip, + length, dir) == -1) + goto trunc; ND_PRINT((ndo, ": ")); } else ND_PRINT((ndo, "slip-%d!: ", p[SLX_CHDR])); } + return 0; +trunc: + return -1; } static const u_char * print_sl_change(netdissect_options *ndo, const char *str, register const u_char *cp) { register u_int i; if ((i = *cp++) == 0) { i = EXTRACT_16BITS(cp); cp += 2; } ND_PRINT((ndo, " %s%d", str, i)); return (cp); } static const u_char * print_sl_winchange(netdissect_options *ndo, register const u_char *cp) { register short i; if ((i = *cp++) == 0) { i = EXTRACT_16BITS(cp); cp += 2; } if (i >= 0) ND_PRINT((ndo, " W+%d", i)); else ND_PRINT((ndo, " W%d", i)); return (cp); } -static void +static int compressed_sl_print(netdissect_options *ndo, const u_char *chdr, const struct ip *ip, u_int length, int dir) { register const u_char *cp = chdr; register u_int flags, hlen; flags = *cp++; if (flags & NEW_C) { lastconn = *cp++; ND_PRINT((ndo, "ctcp %d", lastconn)); } else ND_PRINT((ndo, "ctcp *")); /* skip tcp checksum */ cp += 2; switch (flags & SPECIALS_MASK) { case SPECIAL_I: ND_PRINT((ndo, " *SA+%d", lastlen[dir][lastconn])); break; case SPECIAL_D: ND_PRINT((ndo, " *S+%d", lastlen[dir][lastconn])); break; default: if (flags & NEW_U) cp = print_sl_change(ndo, "U=", cp); if (flags & NEW_W) cp = print_sl_winchange(ndo, cp); if (flags & NEW_A) cp = print_sl_change(ndo, "A+", cp); if (flags & NEW_S) cp = print_sl_change(ndo, "S+", cp); break; } if (flags & NEW_I) cp = print_sl_change(ndo, "I+", cp); /* * 'hlen' is the length of the uncompressed TCP/IP header (in words). * 'cp - chdr' is the length of the compressed header. * 'length - hlen' is the amount of data in the packet. */ + ND_TCHECK(*ip); hlen = IP_HL(ip); + ND_TCHECK(*((const struct tcphdr *)&((const int32_t *)ip)[hlen])); hlen += TH_OFF((const struct tcphdr *)&((const int32_t *)ip)[hlen]); lastlen[dir][lastconn] = length - (hlen << 2); ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr))); + return 0; +trunc: + return -1; } Index: vendor/tcpdump/dist/print-sll.c =================================================================== --- vendor/tcpdump/dist/print-sll.c (revision 353143) +++ vendor/tcpdump/dist/print-sll.c (revision 353144) @@ -1,310 +1,321 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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. */ /* \summary: Linux cooked sockets capture printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" #include "ether.h" /* * For captures on Linux cooked sockets, we construct a fake header * that includes: * * a 2-byte "packet type" which is one of: * * LINUX_SLL_HOST packet was sent to us * LINUX_SLL_BROADCAST packet was broadcast * LINUX_SLL_MULTICAST packet was multicast * LINUX_SLL_OTHERHOST packet was sent to somebody else * LINUX_SLL_OUTGOING packet was sent *by* us; * * a 2-byte Ethernet protocol field; * * a 2-byte link-layer type; * * a 2-byte link-layer address length; * * an 8-byte source link-layer address, whose actual length is * specified by the previous value. * * All fields except for the link-layer address are in network byte order. * * DO NOT change the layout of this structure, or change any of the * LINUX_SLL_ values below. If you must change the link-layer header * for a "cooked" Linux capture, introduce a new DLT_ type (ask * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it * a value that collides with a value already being used), and use the * new header in captures of that type, so that programs that can * handle DLT_LINUX_SLL captures will continue to handle them correctly * without any change, and so that capture files with different headers * can be told apart and programs that read them can dissect the * packets in them. * * This structure, and the #defines below, must be the same in the * libpcap and tcpdump versions of "sll.h". */ /* * A DLT_LINUX_SLL fake link-layer header. */ #define SLL_HDR_LEN 16 /* total header length */ #define SLL_ADDRLEN 8 /* length of address field */ struct sll_header { uint16_t sll_pkttype; /* packet type */ uint16_t sll_hatype; /* link-layer address type */ uint16_t sll_halen; /* link-layer address length */ uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ uint16_t sll_protocol; /* protocol */ }; /* * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the * PACKET_ values on Linux, but are defined here so that they're * available even on systems other than Linux, and so that they * don't change even if the PACKET_ values change. */ #define LINUX_SLL_HOST 0 #define LINUX_SLL_BROADCAST 1 #define LINUX_SLL_MULTICAST 2 #define LINUX_SLL_OTHERHOST 3 #define LINUX_SLL_OUTGOING 4 /* * The LINUX_SLL_ values for "sll_protocol"; these correspond to the * ETH_P_ values on Linux, but are defined here so that they're * available even on systems other than Linux. We assume, for now, * that the ETH_P_ values won't change in Linux; if they do, then: * * if we don't translate them in "pcap-linux.c", capture files * won't necessarily be readable if captured on a system that * defines ETH_P_ values that don't match these values; * * if we do translate them in "pcap-linux.c", that makes life * unpleasant for the BPF code generator, as the values you test * for in the kernel aren't the values that you test for when * reading a capture file, so the fixup code run on BPF programs * handed to the kernel ends up having to do more work. * * Add other values here as necessary, for handling packet types that * might show up on non-Ethernet, non-802.x networks. (Not all the ones * in the Linux "if_ether.h" will, I suspect, actually show up in * captures.) */ #define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ #define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ static const struct tok sll_pkttype_values[] = { { LINUX_SLL_HOST, "In" }, { LINUX_SLL_BROADCAST, "B" }, { LINUX_SLL_MULTICAST, "M" }, { LINUX_SLL_OTHERHOST, "P" }, { LINUX_SLL_OUTGOING, "Out" }, { 0, NULL} }; static inline void sll_print(netdissect_options *ndo, register const struct sll_header *sllp, u_int length) { u_short ether_type; ND_PRINT((ndo, "%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)))); /* * XXX - check the link-layer address type value? * For now, we just assume 6 means Ethernet. * XXX - print others as strings of hex? */ if (EXTRACT_16BITS(&sllp->sll_halen) == 6) ND_PRINT((ndo, "%s ", etheraddr_string(ndo, sllp->sll_addr))); if (!ndo->ndo_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. */ ND_PRINT((ndo, "802.3")); break; case LINUX_SLL_P_802_2: /* * 802.2. */ ND_PRINT((ndo, "802.2")); break; default: /* * What is it? */ ND_PRINT((ndo, "ethertype Unknown (0x%04x)", ether_type)); break; } } else { ND_PRINT((ndo, "ethertype %s (0x%04x)", tok2str(ethertype_values, "Unknown", ether_type), ether_type)); } ND_PRINT((ndo, ", length %u: ", length)); } } /* * This is the top level routine of the printer. 'p' points to the * Linux "cooked capture" header of the packet, 'h->ts' is the timestamp, * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ u_int sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { u_int caplen = h->caplen; u_int length = h->len; register const struct sll_header *sllp; + u_short hatype; u_short ether_type; int llc_hdrlen; u_int hdrlen; if (caplen < SLL_HDR_LEN) { /* * XXX - this "can't happen" because "pcap-linux.c" always * adds this many bytes of header to every packet in a * cooked socket capture. */ ND_PRINT((ndo, "[|sll]")); return (caplen); } sllp = (const struct sll_header *)p; if (ndo->ndo_eflag) sll_print(ndo, sllp, length); /* * Go past the cooked-mode header. */ length -= SLL_HDR_LEN; caplen -= SLL_HDR_LEN; p += SLL_HDR_LEN; hdrlen = SLL_HDR_LEN; + hatype = EXTRACT_16BITS(&sllp->sll_hatype); + switch (hatype) { + + case 803: + /* + * This is an packet with a radiotap header; + * just dissect the payload as such. + */ + return (SLL_HDR_LEN + ieee802_11_radio_print(ndo, p, length, caplen)); + } ether_type = EXTRACT_16BITS(&sllp->sll_protocol); recurse: /* * Is it (gag) an 802.3 encapsulation, or some non-Ethernet * packet type? */ if (ether_type <= ETHERMTU) { /* * Yes - what type is it? */ switch (ether_type) { case LINUX_SLL_P_802_3: /* * Ethernet_802.3 IPX frame. */ ipx_print(ndo, p, length); break; case LINUX_SLL_P_802_2: /* * 802.2. * Try to print the LLC-layer header & higher layers. */ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL); if (llc_hdrlen < 0) goto unknown; /* unknown LLC type */ hdrlen += llc_hdrlen; break; default: /*FALLTHROUGH*/ unknown: /* packet type not known, print raw packet */ if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); break; } } else if (ether_type == ETHERTYPE_8021Q) { /* * Print VLAN information, and then go back and process * the enclosed type field. */ if (caplen < 4) { ND_PRINT((ndo, "[|vlan]")); return (hdrlen + caplen); } if (length < 4) { ND_PRINT((ndo, "[|vlan]")); return (hdrlen + length); } if (ndo->ndo_eflag) { uint16_t tag = EXTRACT_16BITS(p); ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag))); } ether_type = EXTRACT_16BITS(p + 2); if (ether_type <= ETHERMTU) ether_type = LINUX_SLL_P_802_2; if (!ndo->ndo_qflag) { ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values, "Unknown", ether_type))); } p += 4; length -= 4; caplen -= 4; hdrlen += 4; goto recurse; } else { if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) { /* ether_type not known, print raw packet */ if (!ndo->ndo_eflag) sll_print(ndo, sllp, length + SLL_HDR_LEN); if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); } } return (hdrlen); } Index: vendor/tcpdump/dist/print-smb.c =================================================================== --- vendor/tcpdump/dist/print-smb.c (revision 353143) +++ vendor/tcpdump/dist/print-smb.c (revision 353144) @@ -1,1498 +1,1505 @@ /* * Copyright (C) Andrew Tridgell 1995-1999 * * This software may be distributed either under the terms of the * BSD-style license that accompanies tcpdump or the GNU GPL version 2 * or later */ /* \summary: SMB/CIFS printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "netdissect.h" #include "extract.h" #include "smb.h" static const char tstr[] = "[|SMB]"; static int request = 0; static int unicodestr = 0; const u_char *startbuf = NULL; struct smbdescript { const char *req_f1; const char *req_f2; const char *rep_f1; const char *rep_f2; void (*fn)(netdissect_options *, const u_char *, const u_char *, const u_char *, const u_char *); }; struct smbdescriptint { const char *req_f1; const char *req_f2; const char *rep_f1; const char *rep_f2; void (*fn)(netdissect_options *, const u_char *, const u_char *, int, int); }; struct smbfns { int id; const char *name; int flags; struct smbdescript descript; }; struct smbfnsint { int id; const char *name; int flags; struct smbdescriptint descript; }; #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL } #define FLG_CHAIN (1 << 0) static const struct smbfns * smbfind(int id, const struct smbfns *list) { int sindex; for (sindex = 0; list[sindex].name; sindex++) if (list[sindex].id == id) return(&list[sindex]); return(&list[0]); } static const struct smbfnsint * smbfindint(int id, const struct smbfnsint *list) { int sindex; for (sindex = 0; list[sindex].name; sindex++) if (list[sindex].id == id) return(&list[sindex]); return(&list[0]); } static void trans2_findfirst(netdissect_options *ndo, const u_char *param, const u_char *data, int pcnt, int dcnt) { const char *fmt; if (request) fmt = "Attribute=[A]\nSearchCount=[d]\nFlags=[w]\nLevel=[dP4]\nFile=[S]\n"; else fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n"; smb_fdata(ndo, param, fmt, param + pcnt, unicodestr); if (dcnt) { ND_PRINT((ndo, "data:\n")); smb_print_data(ndo, data, dcnt); } } static void trans2_qfsinfo(netdissect_options *ndo, const u_char *param, const u_char *data, int pcnt, int dcnt) { static int level = 0; const char *fmt=""; if (request) { ND_TCHECK2(*param, 2); level = EXTRACT_LE_16BITS(param); fmt = "InfoLevel=[d]\n"; smb_fdata(ndo, param, fmt, param + pcnt, unicodestr); } else { switch (level) { case 1: fmt = "idFileSystem=[W]\nSectorUnit=[D]\nUnit=[D]\nAvail=[D]\nSectorSize=[d]\n"; break; case 2: fmt = "CreationTime=[T2]VolNameLength=[lb]\nVolumeLabel=[c]\n"; break; case 0x105: fmt = "Capabilities=[W]\nMaxFileLen=[D]\nVolNameLen=[lD]\nVolume=[C]\n"; break; default: fmt = "UnknownLevel\n"; break; } smb_fdata(ndo, data, fmt, data + dcnt, unicodestr); } if (dcnt) { ND_PRINT((ndo, "data:\n")); smb_print_data(ndo, data, dcnt); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static const struct smbfnsint trans2_fns[] = { { 0, "TRANSACT2_OPEN", 0, { "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]", NULL, "Handle=[d]\nAttrib=[A]\nTime=[T2]\nSize=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[d]\n|EALength=[d]\n", NULL, NULL }}, { 1, "TRANSACT2_FINDFIRST", 0, { NULL, NULL, NULL, NULL, trans2_findfirst }}, { 2, "TRANSACT2_FINDNEXT", 0, DEFDESCRIPT }, { 3, "TRANSACT2_QFSINFO", 0, { NULL, NULL, NULL, NULL, trans2_qfsinfo }}, { 4, "TRANSACT2_SETFSINFO", 0, DEFDESCRIPT }, { 5, "TRANSACT2_QPATHINFO", 0, DEFDESCRIPT }, { 6, "TRANSACT2_SETPATHINFO", 0, DEFDESCRIPT }, { 7, "TRANSACT2_QFILEINFO", 0, DEFDESCRIPT }, { 8, "TRANSACT2_SETFILEINFO", 0, DEFDESCRIPT }, { 9, "TRANSACT2_FSCTL", 0, DEFDESCRIPT }, { 10, "TRANSACT2_IOCTL", 0, DEFDESCRIPT }, { 11, "TRANSACT2_FINDNOTIFYFIRST", 0, DEFDESCRIPT }, { 12, "TRANSACT2_FINDNOTIFYNEXT", 0, DEFDESCRIPT }, { 13, "TRANSACT2_MKDIR", 0, DEFDESCRIPT }, { -1, NULL, 0, DEFDESCRIPT } }; static void print_trans2(netdissect_options *ndo, const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf) { u_int bcc; static const struct smbfnsint *fn = &trans2_fns[0]; const u_char *data, *param; const u_char *w = words + 1; const char *f1 = NULL, *f2 = NULL; int pcnt, dcnt; ND_TCHECK(words[0]); if (request) { ND_TCHECK2(w[14 * 2], 2); pcnt = EXTRACT_LE_16BITS(w + 9 * 2); param = buf + EXTRACT_LE_16BITS(w + 10 * 2); dcnt = EXTRACT_LE_16BITS(w + 11 * 2); data = buf + EXTRACT_LE_16BITS(w + 12 * 2); fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns); } else { if (words[0] == 0) { ND_PRINT((ndo, "%s\n", fn->name)); ND_PRINT((ndo, "Trans2Interim\n")); return; } ND_TCHECK2(w[7 * 2], 2); pcnt = EXTRACT_LE_16BITS(w + 3 * 2); param = buf + EXTRACT_LE_16BITS(w + 4 * 2); dcnt = EXTRACT_LE_16BITS(w + 6 * 2); data = buf + EXTRACT_LE_16BITS(w + 7 * 2); } ND_PRINT((ndo, "%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt)); if (request) { if (words[0] == 8) { smb_fdata(ndo, words + 1, "Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n", maxbuf, unicodestr); return; } else { smb_fdata(ndo, words + 1, "TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n", words + 1 + 14 * 2, unicodestr); } f1 = fn->descript.req_f1; f2 = fn->descript.req_f2; } else { smb_fdata(ndo, words + 1, "TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n", words + 1 + 10 * 2, unicodestr); f1 = fn->descript.rep_f1; f2 = fn->descript.rep_f2; } ND_TCHECK2(*dat, 2); bcc = EXTRACT_LE_16BITS(dat); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (fn->descript.fn) (*fn->descript.fn)(ndo, param, data, pcnt, dcnt); else { smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr); smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void print_browse(netdissect_options *ndo, const u_char *param, int paramlen, const u_char *data, int datalen) { const u_char *maxbuf = data + datalen; int command; ND_TCHECK(data[0]); command = data[0]; smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr); switch (command) { case 0xF: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", maxbuf, unicodestr); break; case 0x1: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n", maxbuf, unicodestr); break; case 0x2: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n", maxbuf, unicodestr); break; case 0xc: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n", maxbuf, unicodestr); break; case 0x8: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n", maxbuf, unicodestr); break; case 0xb: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n", maxbuf, unicodestr); break; case 0x9: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n", maxbuf, unicodestr); break; case 0xa: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n", maxbuf, unicodestr); break; case 0xd: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n", maxbuf, unicodestr); break; case 0xe: data = smb_fdata(ndo, data, "BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr); break; default: data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr); break; } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void print_ipc(netdissect_options *ndo, const u_char *param, int paramlen, const u_char *data, int datalen) { if (paramlen) smb_fdata(ndo, param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen, unicodestr); if (datalen) smb_fdata(ndo, data, "IPC ", data + datalen, unicodestr); } static void print_trans(netdissect_options *ndo, const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf) { u_int bcc; const char *f1, *f2, *f3, *f4; const u_char *data, *param; const u_char *w = words + 1; int datalen, paramlen; if (request) { ND_TCHECK2(w[12 * 2], 2); paramlen = EXTRACT_LE_16BITS(w + 9 * 2); param = buf + EXTRACT_LE_16BITS(w + 10 * 2); datalen = EXTRACT_LE_16BITS(w + 11 * 2); data = buf + EXTRACT_LE_16BITS(w + 12 * 2); f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nMaxParmCnt=[d] \nMaxDataCnt=[d]\nMaxSCnt=[d] \nTransFlags=[w] \nRes1=[w] \nRes2=[w] \nRes3=[w]\nParamCnt=[d] \nParamOff=[d] \nDataCnt=[d] \nDataOff=[d] \nSUCnt=[d]\n"; f2 = "|Name=[S]\n"; f3 = "|Param "; f4 = "|Data "; } else { ND_TCHECK2(w[7 * 2], 2); paramlen = EXTRACT_LE_16BITS(w + 3 * 2); param = buf + EXTRACT_LE_16BITS(w + 4 * 2); datalen = EXTRACT_LE_16BITS(w + 6 * 2); data = buf + EXTRACT_LE_16BITS(w + 7 * 2); f1 = "TotParamCnt=[d] \nTotDataCnt=[d] \nRes1=[d]\nParamCnt=[d] \nParamOff=[d] \nRes2=[d] \nDataCnt=[d] \nDataOff=[d] \nRes3=[d]\nLsetup=[d]\n"; f2 = "|Unknown "; f3 = "|Param "; f4 = "|Data "; } smb_fdata(ndo, words + 1, f1, min(words + 1 + 2 * words[0], maxbuf), unicodestr); ND_TCHECK2(*data1, 2); bcc = EXTRACT_LE_16BITS(data1); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (bcc > 0) { smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr); - - if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) { +#define MAILSLOT_BROWSE_STR "\\MAILSLOT\\BROWSE" + ND_TCHECK2(*(data1 + 2), strlen(MAILSLOT_BROWSE_STR) + 1); + if (strcmp((const char *)(data1 + 2), MAILSLOT_BROWSE_STR) == 0) { print_browse(ndo, param, paramlen, data, datalen); return; } +#undef MAILSLOT_BROWSE_STR - if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) { +#define PIPE_LANMAN_STR "\\PIPE\\LANMAN" + ND_TCHECK2(*(data1 + 2), strlen(PIPE_LANMAN_STR) + 1); + if (strcmp((const char *)(data1 + 2), PIPE_LANMAN_STR) == 0) { print_ipc(ndo, param, paramlen, data, datalen); return; } +#undef PIPE_LANMAN_STR if (paramlen) smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr); if (datalen) smb_fdata(ndo, data, f4, min(data + datalen, maxbuf), unicodestr); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void print_negprot(netdissect_options *ndo, const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { u_int wct, bcc; const char *f1 = NULL, *f2 = NULL; ND_TCHECK(words[0]); wct = words[0]; if (request) f2 = "*|Dialect=[Y]\n"; else { if (wct == 1) f1 = "Core Protocol\nDialectIndex=[d]"; else if (wct == 17) f1 = "NT1 Protocol\nDialectIndex=[d]\nSecMode=[B]\nMaxMux=[d]\nNumVcs=[d]\nMaxBuffer=[D]\nRawSize=[D]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[d]\nCryptKey="; else if (wct == 13) f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[d]\nSecMode=[w]\nMaxXMit=[d]\nMaxMux=[d]\nMaxVcs=[d]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[d]\nRes=[W]\nCryptKey="; } if (f1) smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf), unicodestr); else smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1))); ND_TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (bcc > 0) { if (f2) smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data), maxbuf), unicodestr); else smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void print_sesssetup(netdissect_options *ndo, const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { u_int wct, bcc; const char *f1 = NULL, *f2 = NULL; ND_TCHECK(words[0]); wct = words[0]; if (request) { if (wct == 10) f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n"; else f1 = "Com2=[B]\nRes1=[B]\nOff2=[d]\nMaxBuffer=[d]\nMaxMpx=[d]\nVcNumber=[d]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[d]\nCaseSensitivePasswordLength=[d]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n"; } else { if (wct == 3) { f1 = "Com2=[w]\nOff2=[d]\nAction=[w]\n"; } else if (wct == 13) { f1 = "Com2=[B]\nRes=[B]\nOff2=[d]\nAction=[w]\n"; f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n"; } } if (f1) smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf), unicodestr); else smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1))); ND_TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (bcc > 0) { if (f2) smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data), maxbuf), unicodestr); else smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static void print_lockingandx(netdissect_options *ndo, const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf) { u_int wct, bcc; const u_char *maxwords; const char *f1 = NULL, *f2 = NULL; ND_TCHECK(words[0]); wct = words[0]; if (request) { f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n"; ND_TCHECK(words[7]); if (words[7] & 0x10) f2 = "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n"; else f2 = "*Process=[d]\nOffset=[D]\nLength=[D]\n"; } else { f1 = "Com2=[w]\nOff2=[d]\n"; } maxwords = min(words + 1 + wct * 2, maxbuf); if (wct) smb_fdata(ndo, words + 1, f1, maxwords, unicodestr); ND_TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (bcc > 0) { if (f2) smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data), maxbuf), unicodestr); else smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2))); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static const struct smbfns smb_fns[] = { { -1, "SMBunknown", 0, DEFDESCRIPT }, { SMBtcon, "SMBtcon", 0, { NULL, "Path=[Z]\nPassword=[Z]\nDevice=[Z]\n", "MaxXmit=[d]\nTreeId=[d]\n", NULL, NULL } }, { SMBtdis, "SMBtdis", 0, DEFDESCRIPT }, { SMBexit, "SMBexit", 0, DEFDESCRIPT }, { SMBioctl, "SMBioctl", 0, DEFDESCRIPT }, { SMBecho, "SMBecho", 0, { "ReverbCount=[d]\n", NULL, "SequenceNum=[d]\n", NULL, NULL } }, { SMBulogoffX, "SMBulogoffX", FLG_CHAIN, DEFDESCRIPT }, { SMBgetatr, "SMBgetatr", 0, { NULL, "Path=[Z]\n", "Attribute=[A]\nTime=[T2]Size=[D]\nRes=([w,w,w,w,w])\n", NULL, NULL } }, { SMBsetatr, "SMBsetatr", 0, { "Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n", "Path=[Z]\n", NULL, NULL, NULL } }, { SMBchkpth, "SMBchkpth", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBsearch, "SMBsearch", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBopen, "SMBopen", 0, { "Mode=[w]\nAttribute=[A]\n", "Path=[Z]\n", "Handle=[d]\nOAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\n", NULL, NULL } }, { SMBcreate, "SMBcreate", 0, { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBmknew, "SMBmknew", 0, { "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBunlink, "SMBunlink", 0, { "Attrib=[A]\n", "Path=[Z]\n", NULL, NULL, NULL } }, { SMBread, "SMBread", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwrite, "SMBwrite", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBclose, "SMBclose", 0, { "Handle=[d]\nTime=[T2]", NULL, NULL, NULL, NULL } }, { SMBmkdir, "SMBmkdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBrmdir, "SMBrmdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBdskattr, "SMBdskattr", 0, { NULL, NULL, "TotalUnits=[d]\nBlocksPerUnit=[d]\nBlockSize=[d]\nFreeUnits=[d]\nMedia=[w]\n", NULL, NULL } }, { SMBmv, "SMBmv", 0, { "Attrib=[A]\n", "OldPath=[Z]\nNewPath=[Z]\n", NULL, NULL, NULL } }, /* * this is a Pathworks specific call, allowing the * changing of the root path */ { pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } }, { SMBlseek, "SMBlseek", 0, { "Handle=[d]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL, NULL } }, { SMBflush, "SMBflush", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsplopen, "SMBsplopen", 0, { "SetupLen=[d]\nMode=[w]\n", "Ident=[Z]\n", "Handle=[d]\n", NULL, NULL } }, { SMBsplclose, "SMBsplclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsplretq, "SMBsplretq", 0, { "MaxCount=[d]\nStartIndex=[d]\n", NULL, "Count=[d]\nIndex=[d]\n", "*Time=[T2]Status=[B]\nJobID=[d]\nSize=[D]\nRes=[B]Name=[s16]\n", NULL } }, { SMBsplwr, "SMBsplwr", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBlock, "SMBlock", 0, { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } }, { SMBunlock, "SMBunlock", 0, { "Handle=[d]\nCount=[D]\nOffset=[D]\n", NULL, NULL, NULL, NULL } }, /* CORE+ PROTOCOL FOLLOWS */ { SMBreadbraw, "SMBreadbraw", 0, { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[d]\n", NULL, NULL, NULL, NULL } }, { SMBwritebraw, "SMBwritebraw", 0, { "Handle=[d]\nTotalCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[d]\nDataOff=[d]\n", NULL, "WriteRawAck", NULL, NULL } }, { SMBwritec, "SMBwritec", 0, { NULL, NULL, "Count=[d]\n", NULL, NULL } }, { SMBwriteclose, "SMBwriteclose", 0, { "Handle=[d]\nCount=[d]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])", NULL, "Count=[d]\n", NULL, NULL } }, { SMBlockread, "SMBlockread", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwriteunlock, "SMBwriteunlock", 0, { "Handle=[d]\nByteCount=[d]\nOffset=[D]\nCountLeft=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBreadBmpx, "SMBreadBmpx", 0, { "Handle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nRes=[w]\n", NULL, "Offset=[D]\nTotCount=[d]\nRemaining=[d]\nRes=([w,w])\nDataSize=[d]\nDataOff=[d]\n", NULL, NULL } }, { SMBwriteBmpx, "SMBwriteBmpx", 0, { "Handle=[d]\nTotCount=[d]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Remaining=[d]\n", NULL, NULL } }, { SMBwriteBs, "SMBwriteBs", 0, { "Handle=[d]\nTotCount=[d]\nOffset=[D]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Count=[d]\n", NULL, NULL } }, { SMBsetattrE, "SMBsetattrE", 0, { "Handle=[d]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]", NULL, NULL, NULL, NULL } }, { SMBgetattrE, "SMBgetattrE", 0, { "Handle=[d]\n", NULL, "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D]\nAllocSize=[D]\nAttribute=[A]\n", NULL, NULL } }, { SMBtranss, "SMBtranss", 0, DEFDESCRIPT }, { SMBioctls, "SMBioctls", 0, DEFDESCRIPT }, { SMBcopy, "SMBcopy", 0, { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n", "CopyCount=[d]\n", "|ErrStr=[S]\n", NULL } }, { SMBmove, "SMBmove", 0, { "TreeID2=[d]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n", "MoveCount=[d]\n", "|ErrStr=[S]\n", NULL } }, { SMBopenX, "SMBopenX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[D]\nTimeOut=[D]\nRes=[W]\n", "Path=[S]\n", "Com2=[w]\nOff2=[d]\nHandle=[d]\nAttrib=[A]\nTime=[T2]Size=[D]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n", NULL, NULL } }, { SMBreadX, "SMBreadX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nMaxCount=[d]\nMinCount=[d]\nTimeOut=[D]\nCountLeft=[d]\n", NULL, "Com2=[w]\nOff2=[d]\nRemaining=[d]\nRes=[W]\nDataSize=[d]\nDataOff=[d]\nRes=([w,w,w,w])\n", NULL, NULL } }, { SMBwriteX, "SMBwriteX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nHandle=[d]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[d]\nRes=[w]\nDataSize=[d]\nDataOff=[d]\n", NULL, "Com2=[w]\nOff2=[d]\nCount=[d]\nRemaining=[d]\nRes=[W]\n", NULL, NULL } }, { SMBffirst, "SMBffirst", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfunique, "SMBfunique", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfclose, "SMBfclose", 0, { "Count=[d]\nAttrib=[A]\n", "Path=[Z]\nBlkType=[B]\nBlkLen=[d]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\n", "Count=[d]\n", "BlkType=[B]\nBlkLen=[d]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[d]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[D]\nName=[s13]\n", NULL } }, { SMBfindnclose, "SMBfindnclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBfindclose, "SMBfindclose", 0, { "Handle=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsends, "SMBsends", 0, { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } }, { SMBsendstrt, "SMBsendstrt", 0, { NULL, "Source=[Z]\nDest=[Z]\n", "GroupID=[d]\n", NULL, NULL } }, { SMBsendend, "SMBsendend", 0, { "GroupID=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsendtxt, "SMBsendtxt", 0, { "GroupID=[d]\n", NULL, NULL, NULL, NULL } }, { SMBsendb, "SMBsendb", 0, { NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } }, { SMBfwdname, "SMBfwdname", 0, DEFDESCRIPT }, { SMBcancelf, "SMBcancelf", 0, DEFDESCRIPT }, { SMBgetmac, "SMBgetmac", 0, DEFDESCRIPT }, { SMBnegprot, "SMBnegprot", 0, { NULL, NULL, NULL, NULL, print_negprot } }, { SMBsesssetupX, "SMBsesssetupX", FLG_CHAIN, { NULL, NULL, NULL, NULL, print_sesssetup } }, { SMBtconX, "SMBtconX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nFlags=[w]\nPassLen=[d]\nPasswd&Path&Device=\n", NULL, "Com2=[w]\nOff2=[d]\n", "ServiceType=[R]\n", NULL } }, { SMBlockingX, "SMBlockingX", FLG_CHAIN, { NULL, NULL, NULL, NULL, print_lockingandx } }, { SMBtrans2, "SMBtrans2", 0, { NULL, NULL, NULL, NULL, print_trans2 } }, { SMBtranss2, "SMBtranss2", 0, DEFDESCRIPT }, { SMBctemp, "SMBctemp", 0, DEFDESCRIPT }, { SMBreadBs, "SMBreadBs", 0, DEFDESCRIPT }, { SMBtrans, "SMBtrans", 0, { NULL, NULL, NULL, NULL, print_trans } }, { SMBnttrans, "SMBnttrans", 0, DEFDESCRIPT }, { SMBnttranss, "SMBnttranss", 0, DEFDESCRIPT }, { SMBntcreateX, "SMBntcreateX", FLG_CHAIN, { "Com2=[w]\nOff2=[d]\nRes=[b]\nNameLen=[ld]\nFlags=[W]\nRootDirectoryFid=[D]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n", "Path=[C]\n", "Com2=[w]\nOff2=[d]\nOplockLevel=[b]\nFid=[d]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n", NULL, NULL } }, { SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT }, { -1, NULL, 0, DEFDESCRIPT } }; /* * print a SMB message */ static void print_smb(netdissect_options *ndo, const u_char *buf, const u_char *maxbuf) { uint16_t flags2; int nterrcodes; int command; uint32_t nterror; const u_char *words, *maxwords, *data; const struct smbfns *fn; const char *fmt_smbheader = "[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n"; int smboffset; ND_TCHECK(buf[9]); request = (buf[9] & 0x80) ? 0 : 1; startbuf = buf; command = buf[4]; fn = smbfind(command, smb_fns); if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n")); ND_PRINT((ndo, "SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY")); if (ndo->ndo_vflag < 2) return; ND_TCHECK_16BITS(&buf[10]); flags2 = EXTRACT_LE_16BITS(&buf[10]); unicodestr = flags2 & 0x8000; nterrcodes = flags2 & 0x4000; /* print out the header */ smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr); if (nterrcodes) { nterror = EXTRACT_LE_32BITS(&buf[5]); if (nterror) ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror))); } else { if (buf[5]) ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])))); } smboffset = 32; for (;;) { const char *f1, *f2; int wct; u_int bcc; int newsmboffset; words = buf + smboffset; ND_TCHECK(words[0]); wct = words[0]; data = words + 1 + wct * 2; maxwords = min(data, maxbuf); if (request) { f1 = fn->descript.req_f1; f2 = fn->descript.req_f2; } else { f1 = fn->descript.rep_f1; f2 = fn->descript.rep_f2; } if (fn->descript.fn) (*fn->descript.fn)(ndo, words, data, buf, maxbuf); else { if (wct) { if (f1) smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr); else { int i; int v; for (i = 0; &words[1 + 2 * i] < maxwords; i++) { ND_TCHECK2(words[1 + 2 * i], 2); v = EXTRACT_LE_16BITS(words + 1 + 2 * i); ND_PRINT((ndo, "smb_vwv[%d]=%d (0x%X)\n", i, v, v)); } } } ND_TCHECK2(*data, 2); bcc = EXTRACT_LE_16BITS(data); ND_PRINT((ndo, "smb_bcc=%u\n", bcc)); if (f2) { if (bcc > 0) smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr); } else { if (bcc > 0) { ND_PRINT((ndo, "smb_buf[]=\n")); smb_print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2))); } } } if ((fn->flags & FLG_CHAIN) == 0) break; if (wct == 0) break; ND_TCHECK(words[1]); command = words[1]; if (command == 0xFF) break; ND_TCHECK2(words[3], 2); newsmboffset = EXTRACT_LE_16BITS(words + 3); fn = smbfind(command, smb_fns); ND_PRINT((ndo, "\nSMB PACKET: %s (%s) (CHAINED)\n", fn->name, request ? "REQUEST" : "REPLY")); if (newsmboffset <= smboffset) { ND_PRINT((ndo, "Bad andX offset: %u <= %u\n", newsmboffset, smboffset)); break; } smboffset = newsmboffset; } ND_PRINT((ndo, "\n")); return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* * print a NBT packet received across tcp on port 139 */ void nbt_tcp_print(netdissect_options *ndo, const u_char *data, int length) { int caplen; int type; u_int nbt_len; const u_char *maxbuf; if (length < 4) goto trunc; if (ndo->ndo_snapend < data) goto trunc; caplen = ndo->ndo_snapend - data; if (caplen < 4) goto trunc; maxbuf = data + caplen; + ND_TCHECK_8BITS(data); type = data[0]; + ND_TCHECK_16BITS(data + 2); nbt_len = EXTRACT_16BITS(data + 2); length -= 4; caplen -= 4; startbuf = data; if (ndo->ndo_vflag < 2) { ND_PRINT((ndo, " NBT Session Packet: ")); switch (type) { case 0x00: ND_PRINT((ndo, "Session Message")); break; case 0x81: ND_PRINT((ndo, "Session Request")); break; case 0x82: ND_PRINT((ndo, "Session Granted")); break; case 0x83: { int ecode; if (nbt_len < 4) goto trunc; if (length < 4) goto trunc; if (caplen < 4) goto trunc; ecode = data[4]; ND_PRINT((ndo, "Session Reject, ")); switch (ecode) { case 0x80: ND_PRINT((ndo, "Not listening on called name")); break; case 0x81: ND_PRINT((ndo, "Not listening for calling name")); break; case 0x82: ND_PRINT((ndo, "Called name not present")); break; case 0x83: ND_PRINT((ndo, "Called name present, but insufficient resources")); break; default: ND_PRINT((ndo, "Unspecified error 0x%X", ecode)); break; } } break; case 0x85: ND_PRINT((ndo, "Session Keepalive")); break; default: data = smb_fdata(ndo, data, "Unknown packet type [rB]", maxbuf, 0); break; } } else { ND_PRINT((ndo, "\n>>> NBT Session Packet\n")); switch (type) { case 0x00: data = smb_fdata(ndo, data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n", data + 4, 0); if (data == NULL) break; if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) { if ((int)nbt_len > caplen) { if ((int)nbt_len > length) ND_PRINT((ndo, "WARNING: Packet is continued in later TCP segments\n")); else ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length by %d\n", nbt_len - caplen)); } print_smb(ndo, data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf); } else ND_PRINT((ndo, "Session packet:(raw data or continuation?)\n")); break; case 0x81: data = smb_fdata(ndo, data, "[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n", maxbuf, 0); break; case 0x82: data = smb_fdata(ndo, data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0); break; case 0x83: { const u_char *origdata; int ecode; origdata = data; data = smb_fdata(ndo, data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n", maxbuf, 0); if (data == NULL) break; if (nbt_len >= 1 && caplen >= 1) { ecode = origdata[4]; switch (ecode) { case 0x80: ND_PRINT((ndo, "Not listening on called name\n")); break; case 0x81: ND_PRINT((ndo, "Not listening for calling name\n")); break; case 0x82: ND_PRINT((ndo, "Called name not present\n")); break; case 0x83: ND_PRINT((ndo, "Called name present, but insufficient resources\n")); break; default: ND_PRINT((ndo, "Unspecified error 0x%X\n", ecode)); break; } } } break; case 0x85: data = smb_fdata(ndo, data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0); break; default: data = smb_fdata(ndo, data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0); break; } ND_PRINT((ndo, "\n")); } return; trunc: ND_PRINT((ndo, "%s", tstr)); } static const struct tok opcode_str[] = { { 0, "QUERY" }, { 5, "REGISTRATION" }, { 6, "RELEASE" }, { 7, "WACK" }, { 8, "REFRESH(8)" }, { 9, "REFRESH" }, { 15, "MULTIHOMED REGISTRATION" }, { 0, NULL } }; /* * print a NBT packet received across udp on port 137 */ void nbt_udp137_print(netdissect_options *ndo, const u_char *data, int length) { const u_char *maxbuf = data + length; int name_trn_id, response, opcode, nm_flags, rcode; int qdcount, ancount, nscount, arcount; const u_char *p; int total, i; ND_TCHECK2(data[10], 2); name_trn_id = EXTRACT_16BITS(data); response = (data[2] >> 7); opcode = (data[2] >> 3) & 0xF; nm_flags = ((data[2] & 0x7) << 4) + (data[3] >> 4); rcode = data[3] & 0xF; qdcount = EXTRACT_16BITS(data + 4); ancount = EXTRACT_16BITS(data + 6); nscount = EXTRACT_16BITS(data + 8); arcount = EXTRACT_16BITS(data + 10); startbuf = data; if (maxbuf <= data) return; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n>>> ")); ND_PRINT((ndo, "NBT UDP PACKET(137): %s", tok2str(opcode_str, "OPUNKNOWN", opcode))); if (response) { ND_PRINT((ndo, "; %s", rcode ? "NEGATIVE" : "POSITIVE")); } ND_PRINT((ndo, "; %s; %s", response ? "RESPONSE" : "REQUEST", (nm_flags & 1) ? "BROADCAST" : "UNICAST")); if (ndo->ndo_vflag < 2) return; ND_PRINT((ndo, "\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n", name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount, arcount)); p = data + 12; total = ancount + nscount + arcount; if (qdcount > 100 || total > 100) { ND_PRINT((ndo, "Corrupt packet??\n")); return; } if (qdcount) { ND_PRINT((ndo, "QuestionRecords:\n")); for (i = 0; i < qdcount; i++) { p = smb_fdata(ndo, p, "|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#", maxbuf, 0); if (p == NULL) goto out; } } if (total) { ND_PRINT((ndo, "\nResourceRecords:\n")); for (i = 0; i < total; i++) { int rdlen; int restype; p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0); if (p == NULL) goto out; ND_TCHECK_16BITS(p); restype = EXTRACT_16BITS(p); p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0); if (p == NULL) goto out; ND_TCHECK_16BITS(p); rdlen = EXTRACT_16BITS(p); ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen)); p += 2; if (rdlen == 6) { p = smb_fdata(ndo, p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0); if (p == NULL) goto out; } else { if (restype == 0x21) { int numnames; ND_TCHECK(*p); numnames = p[0]; p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0); if (p == NULL) goto out; while (numnames--) { p = smb_fdata(ndo, p, "Name=[n2]\t#", maxbuf, 0); if (p == NULL) goto out; ND_TCHECK(*p); if (p[0] & 0x80) ND_PRINT((ndo, " ")); switch (p[0] & 0x60) { case 0x00: ND_PRINT((ndo, "B ")); break; case 0x20: ND_PRINT((ndo, "P ")); break; case 0x40: ND_PRINT((ndo, "M ")); break; case 0x60: ND_PRINT((ndo, "_ ")); break; } if (p[0] & 0x10) ND_PRINT((ndo, " ")); if (p[0] & 0x08) ND_PRINT((ndo, " ")); if (p[0] & 0x04) ND_PRINT((ndo, " ")); if (p[0] & 0x02) ND_PRINT((ndo, " ")); ND_PRINT((ndo, "\n")); p += 2; } } else { smb_print_data(ndo, p, min(rdlen, length - (p - data))); p += rdlen; } } } } if (p < maxbuf) smb_fdata(ndo, p, "AdditionalData:\n", maxbuf, 0); out: ND_PRINT((ndo, "\n")); return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* * Print an SMB-over-TCP packet received across tcp on port 445 */ void smb_tcp_print(netdissect_options *ndo, const u_char * data, int length) { int caplen; u_int smb_len; const u_char *maxbuf; if (length < 4) goto trunc; if (ndo->ndo_snapend < data) goto trunc; caplen = ndo->ndo_snapend - data; if (caplen < 4) goto trunc; maxbuf = data + caplen; smb_len = EXTRACT_24BITS(data + 1); length -= 4; caplen -= 4; startbuf = data; data += 4; if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) { if ((int)smb_len > caplen) { if ((int)smb_len > length) ND_PRINT((ndo, " WARNING: Packet is continued in later TCP segments\n")); else ND_PRINT((ndo, " WARNING: Short packet. Try increasing the snap length by %d\n", smb_len - caplen)); } else ND_PRINT((ndo, " ")); print_smb(ndo, data, maxbuf > data + smb_len ? data + smb_len : maxbuf); } else ND_PRINT((ndo, " SMB-over-TCP packet:(raw data or continuation?)\n")); return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* * print a NBT packet received across udp on port 138 */ void nbt_udp138_print(netdissect_options *ndo, const u_char *data, int length) { const u_char *maxbuf = data + length; if (maxbuf > ndo->ndo_snapend) maxbuf = ndo->ndo_snapend; if (maxbuf <= data) return; startbuf = data; if (ndo->ndo_vflag < 2) { ND_PRINT((ndo, "NBT UDP PACKET(138)")); return; } data = smb_fdata(ndo, data, "\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#", maxbuf, 0); if (data != NULL) { /* If there isn't enough data for "\377SMB", don't check for it. */ if (&data[3] >= maxbuf) goto out; if (memcmp(data, "\377SMB",4) == 0) print_smb(ndo, data, maxbuf); } out: ND_PRINT((ndo, "\n")); } /* print netbeui frames */ static struct nbf_strings { const char *name; const char *nonverbose; const char *verbose; } nbf_strings[0x20] = { { "Add Group Name Query", ", [P23]Name to add=[n2]#", "[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" }, { "Add Name Query", ", [P23]Name to add=[n2]#", "[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" }, { "Name In Conflict", NULL, NULL }, { "Status Query", NULL, NULL }, { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { "Terminate Trace", NULL, NULL }, { "Datagram", NULL, "[P7]Destination=[n2]\nSource=[n2]\n" }, { "Broadcast Datagram", NULL, "[P7]Destination=[n2]\nSource=[n2]\n" }, { "Name Query", ", [P7]Name=[n2]#", "[P1]SessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nName=[n2]\nName of sender=[n2]\n" }, { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { "Add Name Response", ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#", "AddNameInProcess=[B]\nGroupName=[w]\nTransmitCorrelator=[w][P2]\nDestination=[n2]\nSource=[n2]\n" }, { "Name Recognized", NULL, "[P1]Data2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n" }, { "Status Response", NULL, NULL }, { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { "Terminate Trace", NULL, NULL }, { "Data Ack", NULL, "[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Data First/Middle", NULL, "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Data Only/Last", NULL, "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Session Confirm", NULL, "Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Session End", NULL, "[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Session Initialize", NULL, "Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "No Receive", NULL, "Flags=[{|SEND_NO_ACK}]\nDataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Receive Outstanding", NULL, "[P1]DataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { "Receive Continue", NULL, "[P2]TransmitCorrelator=[w]\n[P2]RemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" }, { NULL, NULL, NULL }, /* not used */ { NULL, NULL, NULL }, /* not used */ { "Session Alive", NULL, NULL } }; void netbeui_print(netdissect_options *ndo, u_short control, const u_char *data, int length) { const u_char *maxbuf = data + length; int len; int command; const u_char *data2; int is_truncated = 0; if (maxbuf > ndo->ndo_snapend) maxbuf = ndo->ndo_snapend; ND_TCHECK(data[4]); len = EXTRACT_LE_16BITS(data); command = data[4]; data2 = data + len; if (data2 >= maxbuf) { data2 = maxbuf; is_truncated = 1; } startbuf = data; if (ndo->ndo_vflag < 2) { ND_PRINT((ndo, "NBF Packet: ")); data = smb_fdata(ndo, data, "[P5]#", maxbuf, 0); } else { ND_PRINT((ndo, "\n>>> NBF Packet\nType=0x%X ", control)); data = smb_fdata(ndo, data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0); } if (data == NULL) goto out; if (command > 0x1f || nbf_strings[command].name == NULL) { if (ndo->ndo_vflag < 2) data = smb_fdata(ndo, data, "Unknown NBF Command#", data2, 0); else data = smb_fdata(ndo, data, "Unknown NBF Command\n", data2, 0); } else { if (ndo->ndo_vflag < 2) { ND_PRINT((ndo, "%s", nbf_strings[command].name)); if (nbf_strings[command].nonverbose != NULL) data = smb_fdata(ndo, data, nbf_strings[command].nonverbose, data2, 0); } else { ND_PRINT((ndo, "%s:\n", nbf_strings[command].name)); if (nbf_strings[command].verbose != NULL) data = smb_fdata(ndo, data, nbf_strings[command].verbose, data2, 0); else ND_PRINT((ndo, "\n")); } } if (ndo->ndo_vflag < 2) return; if (data == NULL) goto out; if (is_truncated) { /* data2 was past the end of the buffer */ goto out; } /* If this isn't a command that would contain an SMB message, quit. */ if (command != 0x08 && command != 0x09 && command != 0x15 && command != 0x16) goto out; /* If there isn't enough data for "\377SMB", don't look for it. */ if (&data2[3] >= maxbuf) goto out; if (memcmp(data2, "\377SMB",4) == 0) print_smb(ndo, data2, maxbuf); else { int i; for (i = 0; i < 128; i++) { if (&data2[i + 3] >= maxbuf) break; if (memcmp(&data2[i], "\377SMB", 4) == 0) { ND_PRINT((ndo, "found SMB packet at %d\n", i)); print_smb(ndo, &data2[i], maxbuf); break; } } } out: ND_PRINT((ndo, "\n")); return; trunc: ND_PRINT((ndo, "%s", tstr)); } /* * print IPX-Netbios frames */ void ipx_netbios_print(netdissect_options *ndo, const u_char *data, u_int length) { /* * this is a hack till I work out how to parse the rest of the * NetBIOS-over-IPX stuff */ int i; const u_char *maxbuf; maxbuf = data + length; /* Don't go past the end of the captured data in the packet. */ if (maxbuf > ndo->ndo_snapend) maxbuf = ndo->ndo_snapend; startbuf = data; for (i = 0; i < 128; i++) { if (&data[i + 4] > maxbuf) break; if (memcmp(&data[i], "\377SMB", 4) == 0) { smb_fdata(ndo, data, "\n>>> IPX transport ", &data[i], 0); print_smb(ndo, &data[i], maxbuf); ND_PRINT((ndo, "\n")); break; } } if (i == 128) smb_fdata(ndo, data, "\n>>> Unknown IPX ", maxbuf, 0); } Index: vendor/tcpdump/dist/print-tcp.c =================================================================== --- vendor/tcpdump/dist/print-tcp.c (revision 353143) +++ vendor/tcpdump/dist/print-tcp.c (revision 353144) @@ -1,920 +1,926 @@ /* $NetBSD: print-tcp.c,v 1.9 2007/07/26 18:15:12 plunky Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Copyright (c) 1999-2004 The tcpdump.org project * * 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. */ /* \summary: TCP printer */ #ifndef lint #else __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $"); #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #include "tcp.h" #include "ip.h" #include "ip6.h" #include "ipproto.h" #include "rpc_auth.h" #include "rpc_msg.h" #ifdef HAVE_LIBCRYPTO #include #include "signature.h" static int tcp_verify_signature(netdissect_options *ndo, const struct ip *ip, const struct tcphdr *tp, const u_char *data, int length, const u_char *rcvsig); #endif static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length); static void print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp, u_int datalen, int exp); #define MAX_RST_DATA_LEN 30 struct tha { struct in_addr src; struct in_addr dst; u_int port; }; struct tcp_seq_hash { struct tcp_seq_hash *nxt; struct tha addr; tcp_seq seq; tcp_seq ack; }; struct tha6 { struct in6_addr src; struct in6_addr dst; u_int port; }; struct tcp_seq_hash6 { struct tcp_seq_hash6 *nxt; struct tha6 addr; tcp_seq seq; tcp_seq ack; }; #define TSEQ_HASHSIZE 919 /* These tcp optinos do not have the size octet */ #define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP) static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE]; static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE]; static const struct tok tcp_flag_values[] = { { TH_FIN, "F" }, { TH_SYN, "S" }, { TH_RST, "R" }, { TH_PUSH, "P" }, { TH_ACK, "." }, { TH_URG, "U" }, { TH_ECNECHO, "E" }, { TH_CWR, "W" }, { 0, NULL } }; static const struct tok tcp_option_values[] = { { TCPOPT_EOL, "eol" }, { TCPOPT_NOP, "nop" }, { TCPOPT_MAXSEG, "mss" }, { TCPOPT_WSCALE, "wscale" }, { TCPOPT_SACKOK, "sackOK" }, { TCPOPT_SACK, "sack" }, { TCPOPT_ECHO, "echo" }, { TCPOPT_ECHOREPLY, "echoreply" }, { TCPOPT_TIMESTAMP, "TS" }, { TCPOPT_CC, "cc" }, { TCPOPT_CCNEW, "ccnew" }, { TCPOPT_CCECHO, "" }, { TCPOPT_SIGNATURE, "md5" }, { TCPOPT_SCPS, "scps" }, { TCPOPT_UTO, "uto" }, { TCPOPT_TCPAO, "tcp-ao" }, { TCPOPT_MPTCP, "mptcp" }, { TCPOPT_FASTOPEN, "tfo" }, { TCPOPT_EXPERIMENT2, "exp" }, { 0, NULL } }; static int tcp_cksum(netdissect_options *ndo, register const struct ip *ip, register const struct tcphdr *tp, register u_int len) { return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len, IPPROTO_TCP); } static int tcp6_cksum(netdissect_options *ndo, register const struct ip6_hdr *ip6, register const struct tcphdr *tp, register u_int len) { return nextproto6_cksum(ndo, ip6, (const uint8_t *)tp, len, len, IPPROTO_TCP); } void tcp_print(netdissect_options *ndo, register const u_char *bp, register u_int length, register const u_char *bp2, int fragmented) { register const struct tcphdr *tp; register const struct ip *ip; register u_char flags; register u_int hlen; register char ch; uint16_t sport, dport, win, urp; uint32_t seq, ack, thseq, thack; u_int utoval; uint16_t magic; register int rev; register const struct ip6_hdr *ip6; tp = (const struct tcphdr *)bp; ip = (const struct ip *)bp2; if (IP_V(ip) == 6) ip6 = (const struct ip6_hdr *)bp2; else ip6 = NULL; ch = '\0'; if (!ND_TTEST(tp->th_dport)) { ND_PRINT((ndo, "%s > %s: [|tcp]", ipaddr_string(ndo, &ip->ip_src), ipaddr_string(ndo, &ip->ip_dst))); return; } sport = EXTRACT_16BITS(&tp->th_sport); dport = EXTRACT_16BITS(&tp->th_dport); if (ip6) { if (ip6->ip6_nxt == IPPROTO_TCP) { ND_PRINT((ndo, "%s.%s > %s.%s: ", ip6addr_string(ndo, &ip6->ip6_src), tcpport_string(ndo, sport), ip6addr_string(ndo, &ip6->ip6_dst), tcpport_string(ndo, dport))); } else { ND_PRINT((ndo, "%s > %s: ", tcpport_string(ndo, sport), tcpport_string(ndo, dport))); } } else { if (ip->ip_p == IPPROTO_TCP) { ND_PRINT((ndo, "%s.%s > %s.%s: ", ipaddr_string(ndo, &ip->ip_src), tcpport_string(ndo, sport), ipaddr_string(ndo, &ip->ip_dst), tcpport_string(ndo, dport))); } else { ND_PRINT((ndo, "%s > %s: ", tcpport_string(ndo, sport), tcpport_string(ndo, dport))); } } ND_TCHECK(*tp); hlen = TH_OFF(tp) * 4; if (hlen < sizeof(*tp)) { ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]", length - hlen, hlen, (unsigned long)sizeof(*tp))); return; } seq = EXTRACT_32BITS(&tp->th_seq); ack = EXTRACT_32BITS(&tp->th_ack); win = EXTRACT_16BITS(&tp->th_win); urp = EXTRACT_16BITS(&tp->th_urp); if (ndo->ndo_qflag) { ND_PRINT((ndo, "tcp %d", length - hlen)); if (hlen > length) { ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]", hlen, length)); } return; } flags = tp->th_flags; ND_PRINT((ndo, "Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags))); if (!ndo->ndo_Sflag && (flags & TH_ACK)) { /* * Find (or record) the initial sequence numbers for * this conversation. (we pick an arbitrary * collating order so there's only one entry for * both directions). */ rev = 0; if (ip6) { register struct tcp_seq_hash6 *th; struct tcp_seq_hash6 *tcp_seq_hash; const struct in6_addr *src, *dst; struct tha6 tha; tcp_seq_hash = tcp_seq_hash6; src = &ip6->ip6_src; dst = &ip6->ip6_dst; if (sport > dport) rev = 1; else if (sport == dport) { if (UNALIGNED_MEMCMP(src, dst, sizeof ip6->ip6_dst) > 0) rev = 1; } if (rev) { UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst); UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip6->ip6_src); - tha.port = dport << 16 | sport; + tha.port = ((u_int)dport) << 16 | sport; } else { UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst); UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src); - tha.port = sport << 16 | dport; + tha.port = ((u_int)sport) << 16 | dport; } for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; th->nxt; th = th->nxt) if (memcmp((char *)&tha, (char *)&th->addr, sizeof(th->addr)) == 0) break; if (!th->nxt || (flags & TH_SYN)) { /* didn't find it or new conversation */ if (th->nxt == NULL) { th->nxt = (struct tcp_seq_hash6 *) calloc(1, sizeof(*th)); if (th->nxt == NULL) (*ndo->ndo_error)(ndo, "tcp_print: calloc"); } th->addr = tha; if (rev) th->ack = seq, th->seq = ack - 1; else th->seq = seq, th->ack = ack - 1; } else { if (rev) seq -= th->ack, ack -= th->seq; else seq -= th->seq, ack -= th->ack; } thseq = th->seq; thack = th->ack; } else { register struct tcp_seq_hash *th; struct tcp_seq_hash *tcp_seq_hash; struct tha tha; tcp_seq_hash = tcp_seq_hash4; if (sport > dport) rev = 1; else if (sport == dport) { if (UNALIGNED_MEMCMP(&ip->ip_src, &ip->ip_dst, sizeof ip->ip_dst) > 0) rev = 1; } if (rev) { UNALIGNED_MEMCPY(&tha.src, &ip->ip_dst, sizeof ip->ip_dst); UNALIGNED_MEMCPY(&tha.dst, &ip->ip_src, sizeof ip->ip_src); - tha.port = dport << 16 | sport; + tha.port = ((u_int)dport) << 16 | sport; } else { UNALIGNED_MEMCPY(&tha.dst, &ip->ip_dst, sizeof ip->ip_dst); UNALIGNED_MEMCPY(&tha.src, &ip->ip_src, sizeof ip->ip_src); - tha.port = sport << 16 | dport; + tha.port = ((u_int)sport) << 16 | dport; } for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE]; th->nxt; th = th->nxt) if (memcmp((char *)&tha, (char *)&th->addr, sizeof(th->addr)) == 0) break; if (!th->nxt || (flags & TH_SYN)) { /* didn't find it or new conversation */ if (th->nxt == NULL) { th->nxt = (struct tcp_seq_hash *) calloc(1, sizeof(*th)); if (th->nxt == NULL) (*ndo->ndo_error)(ndo, "tcp_print: calloc"); } th->addr = tha; if (rev) th->ack = seq, th->seq = ack - 1; else th->seq = seq, th->ack = ack - 1; } else { if (rev) seq -= th->ack, ack -= th->seq; else seq -= th->seq, ack -= th->ack; } thseq = th->seq; thack = th->ack; } } else { /*fool gcc*/ thseq = thack = rev = 0; } if (hlen > length) { ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]", hlen, length)); return; } if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) { /* Check the checksum, if possible. */ uint16_t sum, tcp_sum; if (IP_V(ip) == 4) { if (ND_TTEST2(tp->th_sport, length)) { sum = tcp_cksum(ndo, ip, tp, length); tcp_sum = EXTRACT_16BITS(&tp->th_sum); ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum)); if (sum != 0) ND_PRINT((ndo, " (incorrect -> 0x%04x)", in_cksum_shouldbe(tcp_sum, sum))); else ND_PRINT((ndo, " (correct)")); } } else if (IP_V(ip) == 6 && ip6->ip6_plen) { if (ND_TTEST2(tp->th_sport, length)) { sum = tcp6_cksum(ndo, ip6, tp, length); tcp_sum = EXTRACT_16BITS(&tp->th_sum); ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum)); if (sum != 0) ND_PRINT((ndo, " (incorrect -> 0x%04x)", in_cksum_shouldbe(tcp_sum, sum))); else ND_PRINT((ndo, " (correct)")); } } } length -= hlen; if (ndo->ndo_vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) { ND_PRINT((ndo, ", seq %u", seq)); if (length > 0) { ND_PRINT((ndo, ":%u", seq + length)); } } if (flags & TH_ACK) { ND_PRINT((ndo, ", ack %u", ack)); } ND_PRINT((ndo, ", win %d", win)); if (flags & TH_URG) ND_PRINT((ndo, ", urg %d", urp)); /* * Handle any options. */ if (hlen > sizeof(*tp)) { register const u_char *cp; register u_int i, opt, datalen; register u_int len; hlen -= sizeof(*tp); cp = (const u_char *)tp + sizeof(*tp); ND_PRINT((ndo, ", options [")); while (hlen > 0) { if (ch != '\0') ND_PRINT((ndo, "%c", ch)); ND_TCHECK(*cp); opt = *cp++; if (ZEROLENOPT(opt)) len = 1; else { ND_TCHECK(*cp); len = *cp++; /* total including type, len */ if (len < 2 || len > hlen) goto bad; --hlen; /* account for length byte */ } --hlen; /* account for type byte */ datalen = 0; /* Bail if "l" bytes of data are not left or were not captured */ #define LENCHECK(l) { if ((l) > hlen) goto bad; ND_TCHECK2(*cp, l); } ND_PRINT((ndo, "%s", tok2str(tcp_option_values, "unknown-%u", opt))); switch (opt) { case TCPOPT_MAXSEG: datalen = 2; LENCHECK(datalen); ND_PRINT((ndo, " %u", EXTRACT_16BITS(cp))); break; case TCPOPT_WSCALE: datalen = 1; LENCHECK(datalen); ND_PRINT((ndo, " %u", *cp)); break; case TCPOPT_SACK: datalen = len - 2; if (datalen % 8 != 0) { ND_PRINT((ndo, " invalid sack")); } else { uint32_t s, e; ND_PRINT((ndo, " %d ", datalen / 8)); for (i = 0; i < datalen; i += 8) { LENCHECK(i + 4); s = EXTRACT_32BITS(cp + i); LENCHECK(i + 8); e = EXTRACT_32BITS(cp + i + 4); if (rev) { s -= thseq; e -= thseq; } else { s -= thack; e -= thack; } ND_PRINT((ndo, "{%u:%u}", s, e)); } } break; case TCPOPT_CC: case TCPOPT_CCNEW: case TCPOPT_CCECHO: case TCPOPT_ECHO: case TCPOPT_ECHOREPLY: /* * those options share their semantics. * fall through */ datalen = 4; LENCHECK(datalen); ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp))); break; case TCPOPT_TIMESTAMP: datalen = 8; LENCHECK(datalen); ND_PRINT((ndo, " val %u ecr %u", EXTRACT_32BITS(cp), EXTRACT_32BITS(cp + 4))); break; case TCPOPT_SIGNATURE: datalen = TCP_SIGLEN; LENCHECK(datalen); ND_PRINT((ndo, " ")); #ifdef HAVE_LIBCRYPTO switch (tcp_verify_signature(ndo, ip, tp, bp + TH_OFF(tp) * 4, length, cp)) { case SIGNATURE_VALID: ND_PRINT((ndo, "valid")); break; case SIGNATURE_INVALID: ND_PRINT((ndo, "invalid")); break; case CANT_CHECK_SIGNATURE: ND_PRINT((ndo, "can't check - ")); for (i = 0; i < TCP_SIGLEN; ++i) ND_PRINT((ndo, "%02x", cp[i])); break; } #else for (i = 0; i < TCP_SIGLEN; ++i) ND_PRINT((ndo, "%02x", cp[i])); #endif break; case TCPOPT_SCPS: datalen = 2; LENCHECK(datalen); ND_PRINT((ndo, " cap %02x id %u", cp[0], cp[1])); break; case TCPOPT_TCPAO: datalen = len - 2; /* RFC 5925 Section 2.2: * "The Length value MUST be greater than or equal to 4." * (This includes the Kind and Length fields already processed * at this point.) */ if (datalen < 2) { ND_PRINT((ndo, " invalid")); } else { LENCHECK(1); ND_PRINT((ndo, " keyid %u", cp[0])); LENCHECK(2); ND_PRINT((ndo, " rnextkeyid %u", cp[1])); if (datalen > 2) { ND_PRINT((ndo, " mac 0x")); for (i = 2; i < datalen; i++) { LENCHECK(i + 1); ND_PRINT((ndo, "%02x", cp[i])); } } } break; case TCPOPT_EOL: case TCPOPT_NOP: case TCPOPT_SACKOK: /* * Nothing interesting. * fall through */ break; case TCPOPT_UTO: datalen = 2; LENCHECK(datalen); utoval = EXTRACT_16BITS(cp); ND_PRINT((ndo, " 0x%x", utoval)); if (utoval & 0x0001) utoval = (utoval >> 1) * 60; else utoval >>= 1; ND_PRINT((ndo, " %u", utoval)); break; case TCPOPT_MPTCP: datalen = len - 2; LENCHECK(datalen); if (!mptcp_print(ndo, cp-2, len, flags)) goto bad; break; case TCPOPT_FASTOPEN: datalen = len - 2; LENCHECK(datalen); ND_PRINT((ndo, " ")); print_tcp_fastopen_option(ndo, cp, datalen, FALSE); break; case TCPOPT_EXPERIMENT2: datalen = len - 2; LENCHECK(datalen); if (datalen < 2) goto bad; /* RFC6994 */ magic = EXTRACT_16BITS(cp); ND_PRINT((ndo, "-")); switch(magic) { case 0xf989: /* TCP Fast Open RFC 7413 */ print_tcp_fastopen_option(ndo, cp + 2, datalen - 2, TRUE); break; default: /* Unknown magic number */ ND_PRINT((ndo, "%04x", magic)); break; } break; default: datalen = len - 2; if (datalen) ND_PRINT((ndo, " 0x")); for (i = 0; i < datalen; ++i) { LENCHECK(i + 1); ND_PRINT((ndo, "%02x", cp[i])); } break; } /* Account for data printed */ cp += datalen; hlen -= datalen; /* Check specification against observed length */ ++datalen; /* option octet */ if (!ZEROLENOPT(opt)) ++datalen; /* size octet */ if (datalen != len) ND_PRINT((ndo, "[len %d]", len)); ch = ','; if (opt == TCPOPT_EOL) break; } ND_PRINT((ndo, "]")); } /* * Print length field before crawling down the stack. */ ND_PRINT((ndo, ", length %u", length)); if (length <= 0) return; /* * Decode payload if necessary. */ bp += TH_OFF(tp) * 4; if ((flags & TH_RST) && ndo->ndo_vflag) { print_tcp_rst_data(ndo, bp, length); return; } if (ndo->ndo_packettype) { switch (ndo->ndo_packettype) { case PT_ZMTP1: zmtp1_print(ndo, bp, length); break; case PT_RESP: resp_print(ndo, bp, length); break; } return; } if (IS_SRC_OR_DST_PORT(TELNET_PORT)) { telnet_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(SMTP_PORT)) { ND_PRINT((ndo, ": ")); smtp_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(BGP_PORT)) bgp_print(ndo, bp, length); else if (IS_SRC_OR_DST_PORT(PPTP_PORT)) pptp_print(ndo, bp); else if (IS_SRC_OR_DST_PORT(REDIS_PORT)) resp_print(ndo, bp, length); #ifdef ENABLE_SMB else if (IS_SRC_OR_DST_PORT(NETBIOS_SSN_PORT)) nbt_tcp_print(ndo, bp, length); else if (IS_SRC_OR_DST_PORT(SMB_PORT)) smb_tcp_print(ndo, bp, length); #endif else if (IS_SRC_OR_DST_PORT(BEEP_PORT)) beep_print(ndo, bp, length); else if (IS_SRC_OR_DST_PORT(OPENFLOW_PORT_OLD) || IS_SRC_OR_DST_PORT(OPENFLOW_PORT_IANA)) openflow_print(ndo, bp, length); else if (IS_SRC_OR_DST_PORT(FTP_PORT)) { ND_PRINT((ndo, ": ")); ftp_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(HTTP_PORT) || IS_SRC_OR_DST_PORT(HTTP_PORT_ALT)) { ND_PRINT((ndo, ": ")); http_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(RTSP_PORT) || IS_SRC_OR_DST_PORT(RTSP_PORT_ALT)) { ND_PRINT((ndo, ": ")); rtsp_print(ndo, bp, length); } else if (length > 2 && (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) { + /* domain_print() assumes it does not have to prepend a space before its + * own output to separate it from the output of the calling function. This + * works well with udp_print(), but requires a small prop here. + */ + ND_PRINT((ndo, " ")); + /* * TCP DNS query has 2byte length at the head. * XXX packet could be unaligned, it can go strange */ ns_print(ndo, bp + 2, length - 2, 0); } else if (IS_SRC_OR_DST_PORT(MSDP_PORT)) { msdp_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(RPKI_RTR_PORT)) { rpki_rtr_print(ndo, bp, length); } else if (length > 0 && (IS_SRC_OR_DST_PORT(LDP_PORT))) { ldp_print(ndo, bp, length); } else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) && length >= 4 && ND_TTEST2(*bp, 4)) { /* * If data present, header length valid, and NFS port used, * assume NFS. * Pass offset of data plus 4 bytes for RPC TCP msg length * to NFS print routines. */ uint32_t fraglen; register const struct sunrpc_msg *rp; enum sunrpc_msg_type direction; fraglen = EXTRACT_32BITS(bp) & 0x7FFFFFFF; if (fraglen > (length) - 4) fraglen = (length) - 4; rp = (const struct sunrpc_msg *)(bp + 4); if (ND_TTEST(rp->rm_direction)) { direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction); if (dport == NFS_PORT && direction == SUNRPC_CALL) { ND_PRINT((ndo, ": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid))); nfsreq_print_noaddr(ndo, (const u_char *)rp, fraglen, (const u_char *)ip); return; } if (sport == NFS_PORT && direction == SUNRPC_REPLY) { ND_PRINT((ndo, ": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid))); nfsreply_print_noaddr(ndo, (const u_char *)rp, fraglen, (const u_char *)ip); return; } } } return; bad: ND_PRINT((ndo, "[bad opt]")); if (ch != '\0') ND_PRINT((ndo, ">")); return; trunc: ND_PRINT((ndo, "[|tcp]")); if (ch != '\0') ND_PRINT((ndo, ">")); } /* * RFC1122 says the following on data in RST segments: * * 4.2.2.12 RST Segment: RFC-793 Section 3.4 * * A TCP SHOULD allow a received RST segment to include data. * * DISCUSSION * It has been suggested that a RST segment could contain * ASCII text that encoded and explained the cause of the * RST. No standard has yet been established for such * data. * */ static void print_tcp_rst_data(netdissect_options *ndo, register const u_char *sp, u_int length) { int c; ND_PRINT((ndo, ND_TTEST2(*sp, length) ? " [RST" : " [!RST")); if (length > MAX_RST_DATA_LEN) { length = MAX_RST_DATA_LEN; /* can use -X for longer */ ND_PRINT((ndo, "+")); /* indicate we truncate */ } ND_PRINT((ndo, " ")); while (length-- && sp < ndo->ndo_snapend) { c = *sp++; safeputchar(ndo, c); } ND_PRINT((ndo, "]")); } static void print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp, u_int datalen, int exp) { u_int i; if (exp) ND_PRINT((ndo, "tfo")); if (datalen == 0) { /* Fast Open Cookie Request */ ND_PRINT((ndo, " cookiereq")); } else { /* Fast Open Cookie */ if (datalen % 2 != 0 || datalen < 4 || datalen > 16) { ND_PRINT((ndo, " invalid")); } else { ND_PRINT((ndo, " cookie ")); for (i = 0; i < datalen; ++i) ND_PRINT((ndo, "%02x", cp[i])); } } } #ifdef HAVE_LIBCRYPTO USES_APPLE_DEPRECATED_API static int tcp_verify_signature(netdissect_options *ndo, const struct ip *ip, const struct tcphdr *tp, const u_char *data, int length, const u_char *rcvsig) { struct tcphdr tp1; u_char sig[TCP_SIGLEN]; char zero_proto = 0; MD5_CTX ctx; uint16_t savecsum, tlen; const struct ip6_hdr *ip6; uint32_t len32; uint8_t nxt; if (data + length > ndo->ndo_snapend) { ND_PRINT((ndo, "snaplen too short, ")); return (CANT_CHECK_SIGNATURE); } tp1 = *tp; if (ndo->ndo_sigsecret == NULL) { ND_PRINT((ndo, "shared secret not supplied with -M, ")); return (CANT_CHECK_SIGNATURE); } MD5_Init(&ctx); /* * Step 1: Update MD5 hash with IP pseudo-header. */ if (IP_V(ip) == 4) { MD5_Update(&ctx, (const char *)&ip->ip_src, sizeof(ip->ip_src)); MD5_Update(&ctx, (const char *)&ip->ip_dst, sizeof(ip->ip_dst)); MD5_Update(&ctx, (const char *)&zero_proto, sizeof(zero_proto)); MD5_Update(&ctx, (const char *)&ip->ip_p, sizeof(ip->ip_p)); tlen = EXTRACT_16BITS(&ip->ip_len) - IP_HL(ip) * 4; tlen = htons(tlen); MD5_Update(&ctx, (const char *)&tlen, sizeof(tlen)); } else if (IP_V(ip) == 6) { ip6 = (const struct ip6_hdr *)ip; MD5_Update(&ctx, (const char *)&ip6->ip6_src, sizeof(ip6->ip6_src)); MD5_Update(&ctx, (const char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst)); len32 = htonl(EXTRACT_16BITS(&ip6->ip6_plen)); MD5_Update(&ctx, (const char *)&len32, sizeof(len32)); nxt = 0; MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt)); MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt)); MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt)); nxt = IPPROTO_TCP; MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt)); } else { ND_PRINT((ndo, "IP version not 4 or 6, ")); return (CANT_CHECK_SIGNATURE); } /* * Step 2: Update MD5 hash with TCP header, excluding options. * The TCP checksum must be set to zero. */ savecsum = tp1.th_sum; tp1.th_sum = 0; MD5_Update(&ctx, (const char *)&tp1, sizeof(struct tcphdr)); tp1.th_sum = savecsum; /* * Step 3: Update MD5 hash with TCP segment data, if present. */ if (length > 0) MD5_Update(&ctx, data, length); /* * Step 4: Update MD5 hash with shared secret. */ MD5_Update(&ctx, ndo->ndo_sigsecret, strlen(ndo->ndo_sigsecret)); MD5_Final(sig, &ctx); if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0) return (SIGNATURE_VALID); else return (SIGNATURE_INVALID); } USES_APPLE_RST #endif /* HAVE_LIBCRYPTO */ /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/print-vrrp.c =================================================================== --- vendor/tcpdump/dist/print-vrrp.c (revision 353143) +++ vendor/tcpdump/dist/print-vrrp.c (revision 353144) @@ -1,183 +1,187 @@ /* * Copyright (c) 2000 William C. Fenner. * All rights reserved. * * Kevin Steves July 2000 * Modified to: * - print version, type string and packet length * - print IP address count if > 1 (-v) * - verify checksum (-v) * - print authentication string (-v) * * 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. * The name of William C. Fenner may not 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. */ /* \summary: Virtual Router Redundancy Protocol (VRRP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "extract.h" #include "addrtoname.h" #include "ip.h" #include "ipproto.h" /* * RFC 2338 (VRRP v2): * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |Version| Type | Virtual Rtr ID| Priority | Count IP Addrs| * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Auth Type | Adver Int | Checksum | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP Address (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | . | * | . | * | . | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IP Address (n) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data (1) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Authentication Data (2) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * * * RFC 5798 (VRRP v3): * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | IPv4 Fields or IPv6 Fields | * ... ... * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr| * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |(rsvd) | Max Adver Int | Checksum | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | | * + + * | IPvX Address(es) | * + + * | | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ /* Type */ #define VRRP_TYPE_ADVERTISEMENT 1 static const struct tok type2str[] = { { VRRP_TYPE_ADVERTISEMENT, "Advertisement" }, { 0, NULL } }; /* Auth Type */ #define VRRP_AUTH_NONE 0 #define VRRP_AUTH_SIMPLE 1 #define VRRP_AUTH_AH 2 static const struct tok auth2str[] = { { VRRP_AUTH_NONE, "none" }, { VRRP_AUTH_SIMPLE, "simple" }, { VRRP_AUTH_AH, "ah" }, { 0, NULL } }; void vrrp_print(netdissect_options *ndo, register const u_char *bp, register u_int len, register const u_char *bp2, int ttl) { int version, type, auth_type = VRRP_AUTH_NONE; /* keep compiler happy */ const char *type_s; ND_TCHECK(bp[0]); version = (bp[0] & 0xf0) >> 4; type = bp[0] & 0x0f; type_s = tok2str(type2str, "unknown type (%u)", type); ND_PRINT((ndo, "VRRPv%u, %s", version, type_s)); if (ttl != 255) ND_PRINT((ndo, ", (ttl %u)", ttl)); if (version < 2 || version > 3 || type != VRRP_TYPE_ADVERTISEMENT) return; ND_TCHECK(bp[2]); ND_PRINT((ndo, ", vrid %u, prio %u", bp[1], bp[2])); ND_TCHECK(bp[5]); if (version == 2) { auth_type = bp[4]; ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type))); ND_PRINT((ndo, ", intvl %us, length %u", bp[5], len)); } else { /* version == 3 */ uint16_t intvl = (bp[4] & 0x0f) << 8 | bp[5]; ND_PRINT((ndo, ", intvl %ucs, length %u", intvl, len)); } if (ndo->ndo_vflag) { int naddrs = bp[3]; int i; char c; if (version == 2 && ND_TTEST2(bp[0], len)) { struct cksum_vec vec[1]; vec[0].ptr = bp; vec[0].len = len; - if (in_cksum(vec, 1)) + if (in_cksum(vec, 1)) { + ND_TCHECK_16BITS(&bp[6]); ND_PRINT((ndo, ", (bad vrrp cksum %x)", EXTRACT_16BITS(&bp[6]))); + } } if (version == 3 && ND_TTEST2(bp[0], len)) { uint16_t cksum = nextproto4_cksum(ndo, (const struct ip *)bp2, bp, len, len, IPPROTO_VRRP); - if (cksum) + if (cksum) { + ND_TCHECK_16BITS(&bp[6]); ND_PRINT((ndo, ", (bad vrrp cksum %x)", EXTRACT_16BITS(&bp[6]))); + } } ND_PRINT((ndo, ", addrs")); if (naddrs > 1) ND_PRINT((ndo, "(%d)", naddrs)); ND_PRINT((ndo, ":")); c = ' '; bp += 8; for (i = 0; i < naddrs; i++) { ND_TCHECK(bp[3]); ND_PRINT((ndo, "%c%s", c, ipaddr_string(ndo, bp))); c = ','; bp += 4; } if (version == 2 && auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */ ND_TCHECK(bp[7]); ND_PRINT((ndo, " auth \"")); if (fn_printn(ndo, bp, 8, ndo->ndo_snapend)) { ND_PRINT((ndo, "\"")); goto trunc; } ND_PRINT((ndo, "\"")); } } return; trunc: ND_PRINT((ndo, "[|vrrp]")); } Index: vendor/tcpdump/dist/print-vtp.c =================================================================== --- vendor/tcpdump/dist/print-vtp.c (revision 353143) +++ vendor/tcpdump/dist/print-vtp.c (revision 353144) @@ -1,403 +1,403 @@ /* * Copyright (c) 1998-2007 The TCPDUMP project * * 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. * * Reference documentation: * http://www.cisco.com/c/en/us/support/docs/lan-switching/vtp/10558-21.html * http://docstore.mik.ua/univercd/cc/td/doc/product/lan/trsrb/frames.htm * * Original code ode by Carles Kishimoto */ /* \summary: Cisco VLAN Trunking Protocol (VTP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" #define VTP_HEADER_LEN 36 #define VTP_DOMAIN_NAME_LEN 32 #define VTP_MD5_DIGEST_LEN 16 #define VTP_UPDATE_TIMESTAMP_LEN 12 #define VTP_VLAN_INFO_FIXED_PART_LEN 12 /* length of VLAN info before VLAN name */ #define VTP_SUMMARY_ADV 0x01 #define VTP_SUBSET_ADV 0x02 #define VTP_ADV_REQUEST 0x03 #define VTP_JOIN_MESSAGE 0x04 struct vtp_vlan_ { uint8_t len; uint8_t status; uint8_t type; uint8_t name_len; uint16_t vlanid; uint16_t mtu; uint32_t index; }; static const struct tok vtp_message_type_values[] = { { VTP_SUMMARY_ADV, "Summary advertisement"}, { VTP_SUBSET_ADV, "Subset advertisement"}, { VTP_ADV_REQUEST, "Advertisement request"}, { VTP_JOIN_MESSAGE, "Join message"}, { 0, NULL } }; static const struct tok vtp_header_values[] = { { 0x01, "Followers"}, /* On Summary advertisement, 3rd byte is Followers */ { 0x02, "Seq number"}, /* On Subset advertisement, 3rd byte is Sequence number */ { 0x03, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */ { 0x04, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */ { 0, NULL } }; static const struct tok vtp_vlan_type_values[] = { { 0x01, "Ethernet"}, { 0x02, "FDDI"}, { 0x03, "TrCRF"}, { 0x04, "FDDI-net"}, { 0x05, "TrBRF"}, { 0, NULL } }; static const struct tok vtp_vlan_status[] = { { 0x00, "Operational"}, { 0x01, "Suspended"}, { 0, NULL } }; #define VTP_VLAN_SOURCE_ROUTING_RING_NUMBER 0x01 #define VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER 0x02 #define VTP_VLAN_STP_TYPE 0x03 #define VTP_VLAN_PARENT_VLAN 0x04 #define VTP_VLAN_TRANS_BRIDGED_VLAN 0x05 #define VTP_VLAN_PRUNING 0x06 #define VTP_VLAN_BRIDGE_TYPE 0x07 #define VTP_VLAN_ARP_HOP_COUNT 0x08 #define VTP_VLAN_STE_HOP_COUNT 0x09 #define VTP_VLAN_BACKUP_CRF_MODE 0x0A static const struct tok vtp_vlan_tlv_values[] = { { VTP_VLAN_SOURCE_ROUTING_RING_NUMBER, "Source-Routing Ring Number TLV"}, { VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER, "Source-Routing Bridge Number TLV"}, { VTP_VLAN_STP_TYPE, "STP type TLV"}, { VTP_VLAN_PARENT_VLAN, "Parent VLAN TLV"}, { VTP_VLAN_TRANS_BRIDGED_VLAN, "Translationally bridged VLANs TLV"}, { VTP_VLAN_PRUNING, "Pruning TLV"}, { VTP_VLAN_BRIDGE_TYPE, "Bridge Type TLV"}, { VTP_VLAN_ARP_HOP_COUNT, "Max ARP Hop Count TLV"}, { VTP_VLAN_STE_HOP_COUNT, "Max STE Hop Count TLV"}, { VTP_VLAN_BACKUP_CRF_MODE, "Backup CRF Mode TLV"}, { 0, NULL } }; static const struct tok vtp_stp_type_values[] = { { 1, "SRT"}, { 2, "SRB"}, { 3, "Auto"}, { 0, NULL } }; void vtp_print (netdissect_options *ndo, const u_char *pptr, u_int length) { int type, len, tlv_len, tlv_value, mgmtd_len; const u_char *tptr; const struct vtp_vlan_ *vtp_vlan; if (length < VTP_HEADER_LEN) goto trunc; tptr = pptr; ND_TCHECK2(*tptr, VTP_HEADER_LEN); type = *(tptr+1); ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u", *tptr, tok2str(vtp_message_type_values,"Unknown message type", type), type, length)); /* In non-verbose mode, just print version and message type */ if (ndo->ndo_vflag < 1) { return; } /* verbose mode print all fields */ ND_PRINT((ndo, "\n\tDomain name: ")); mgmtd_len = *(tptr + 3); if (mgmtd_len < 1 || mgmtd_len > 32) { ND_PRINT((ndo, " [invalid MgmtD Len %d]", mgmtd_len)); return; } fn_printzp(ndo, tptr + 4, mgmtd_len, NULL); ND_PRINT((ndo, ", %s: %u", tok2str(vtp_header_values, "Unknown", type), *(tptr+2))); tptr += VTP_HEADER_LEN; switch (type) { case VTP_SUMMARY_ADV: /* * SUMMARY ADVERTISEMENT * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Followers | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Updater Identity IP address | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Update Timestamp (12 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | MD5 digest (16 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK2(*tptr, 8); ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s", EXTRACT_32BITS(tptr), ipaddr_string(ndo, tptr+4))); tptr += 8; ND_TCHECK2(*tptr, VTP_UPDATE_TIMESTAMP_LEN); ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x", EXTRACT_32BITS(tptr), EXTRACT_32BITS(tptr + 4), EXTRACT_32BITS(tptr + 8))); tptr += VTP_UPDATE_TIMESTAMP_LEN; ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN); ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x", EXTRACT_32BITS(tptr), EXTRACT_32BITS(tptr + 4), EXTRACT_32BITS(tptr + 8), EXTRACT_32BITS(tptr + 12))); tptr += VTP_MD5_DIGEST_LEN; break; case VTP_SUBSET_ADV: /* * SUBSET ADVERTISEMENT * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Seq number | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN info field 1 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ................ | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN info field N | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK_32BITS(tptr); ND_PRINT((ndo, ", Config Rev %x", EXTRACT_32BITS(tptr))); /* * VLAN INFORMATION * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | V info len | Status | VLAN type | VLAN name len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | ISL vlan id | MTU size | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | 802.10 index (SAID) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | VLAN name | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ tptr += 4; - while (tptr < (pptr+length)) { + while ((unsigned)(tptr - pptr) < length) { ND_TCHECK_8BITS(tptr); len = *tptr; if (len == 0) break; ND_TCHECK2(*tptr, len); vtp_vlan = (const struct vtp_vlan_*)tptr; if (len < VTP_VLAN_INFO_FIXED_PART_LEN) goto trunc; ND_TCHECK(*vtp_vlan); ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ", tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status), tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type), EXTRACT_16BITS(&vtp_vlan->vlanid), EXTRACT_16BITS(&vtp_vlan->mtu), EXTRACT_32BITS(&vtp_vlan->index))); len -= VTP_VLAN_INFO_FIXED_PART_LEN; tptr += VTP_VLAN_INFO_FIXED_PART_LEN; if (len < 4*((vtp_vlan->name_len + 3)/4)) goto trunc; ND_TCHECK2(*tptr, vtp_vlan->name_len); fn_printzp(ndo, tptr, vtp_vlan->name_len, NULL); /* * Vlan names are aligned to 32-bit boundaries. */ len -= 4*((vtp_vlan->name_len + 3)/4); tptr += 4*((vtp_vlan->name_len + 3)/4); /* TLV information follows */ while (len > 0) { /* * Cisco specs say 2 bytes for type + 2 bytes for length; * see http://docstore.mik.ua/univercd/cc/td/doc/product/lan/trsrb/frames.htm * However, actual packets on the wire appear to use 1 * byte for the type and 1 byte for the length, so that's * what we do. */ if (len < 2) goto trunc; ND_TCHECK2(*tptr, 2); type = *tptr; tlv_len = *(tptr+1); ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV", tok2str(vtp_vlan_tlv_values, "Unknown", type), type)); if (len < tlv_len * 2 + 2) { ND_PRINT((ndo, " (TLV goes past the end of the packet)")); return; } ND_TCHECK2(*tptr, tlv_len * 2 +2); /* * We assume the value is a 2-byte integer; the length is * in units of 16-bit words. */ if (tlv_len != 1) { ND_PRINT((ndo, " (invalid TLV length %u != 1)", tlv_len)); return; } else { tlv_value = EXTRACT_16BITS(tptr+2); switch (type) { case VTP_VLAN_STE_HOP_COUNT: ND_PRINT((ndo, ", %u", tlv_value)); break; case VTP_VLAN_PRUNING: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "Enabled" : "Disabled", tlv_value)); break; case VTP_VLAN_STP_TYPE: ND_PRINT((ndo, ", %s (%u)", tok2str(vtp_stp_type_values, "Unknown", tlv_value), tlv_value)); break; case VTP_VLAN_BRIDGE_TYPE: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "SRB" : "SRT", tlv_value)); break; case VTP_VLAN_BACKUP_CRF_MODE: ND_PRINT((ndo, ", %s (%u)", tlv_value == 1 ? "Backup" : "Not backup", tlv_value)); break; /* * FIXME those are the defined TLVs that lack a decoder * you are welcome to contribute code ;-) */ case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER: case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER: case VTP_VLAN_PARENT_VLAN: case VTP_VLAN_TRANS_BRIDGED_VLAN: case VTP_VLAN_ARP_HOP_COUNT: default: print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2); break; } } len -= 2 + tlv_len*2; tptr += 2 + tlv_len*2; } } break; case VTP_ADV_REQUEST: /* * ADVERTISEMENT REQUEST * * 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 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Reserved | MgmtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Start value | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ ND_TCHECK2(*tptr, 4); ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr))); break; case VTP_JOIN_MESSAGE: /* FIXME - Could not find message format */ break; default: break; } return; trunc: ND_PRINT((ndo, "[|vtp]")); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */ Index: vendor/tcpdump/dist/print-wb.c =================================================================== --- vendor/tcpdump/dist/print-wb.c (revision 353143) +++ vendor/tcpdump/dist/print-wb.c (revision 353144) @@ -1,458 +1,458 @@ /* * Copyright (c) 1993, 1994, 1995, 1996 * 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. */ /* \summary: White Board printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "netdissect.h" #include "addrtoname.h" #include "extract.h" static const char tstr[] = "[|wb]"; /* XXX need to add byte-swapping macros! */ /* XXX - you mean like the ones in "extract.h"? */ /* * Largest packet size. Everything should fit within this space. * For instance, multiline objects are sent piecewise. */ #define MAXFRAMESIZE 1024 /* * Multiple drawing ops can be sent in one packet. Each one starts on a * an even multiple of DOP_ALIGN bytes, which must be a power of two. */ #define DOP_ALIGN 4 #define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1)) #define DOP_NEXT(d)\ ((const struct dophdr *)((const u_char *)(d) + \ DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d))))) /* * Format of the whiteboard packet header. * The transport level header. */ struct pkt_hdr { uint32_t ph_src; /* site id of source */ uint32_t ph_ts; /* time stamp (for skew computation) */ uint16_t ph_version; /* version number */ u_char ph_type; /* message type */ u_char ph_flags; /* message flags */ }; /* Packet types */ #define PT_DRAWOP 0 /* drawing operation */ #define PT_ID 1 /* announcement packet */ #define PT_RREQ 2 /* repair request */ #define PT_RREP 3 /* repair reply */ #define PT_KILL 4 /* terminate participation */ #define PT_PREQ 5 /* page vector request */ #define PT_PREP 7 /* page vector reply */ #ifdef PF_USER #undef PF_USER /* {Digital,Tru64} UNIX define this, alas */ #endif /* flags */ #define PF_USER 0x01 /* hint that packet has interactive data */ #define PF_VIS 0x02 /* only visible ops wanted */ struct PageID { uint32_t p_sid; /* session id of initiator */ uint32_t p_uid; /* page number */ }; struct dophdr { uint32_t dh_ts; /* sender's timestamp */ uint16_t dh_len; /* body length */ u_char dh_flags; u_char dh_type; /* body type */ /* body follows */ }; /* * Drawing op sub-types. */ #define DT_RECT 2 #define DT_LINE 3 #define DT_ML 4 #define DT_DEL 5 #define DT_XFORM 6 #define DT_ELL 7 #define DT_CHAR 8 #define DT_STR 9 #define DT_NOP 10 #define DT_PSCODE 11 #define DT_PSCOMP 12 #define DT_REF 13 #define DT_SKIP 14 #define DT_HOLE 15 #define DT_MAXTYPE 15 /* * A drawing operation. */ struct pkt_dop { struct PageID pd_page; /* page that operations apply to */ uint32_t pd_sseq; /* start sequence number */ uint32_t pd_eseq; /* end sequence number */ /* drawing ops follow */ }; /* * A repair request. */ struct pkt_rreq { uint32_t pr_id; /* source id of drawops to be repaired */ struct PageID pr_page; /* page of drawops */ uint32_t pr_sseq; /* start seqno */ uint32_t pr_eseq; /* end seqno */ }; /* * A repair reply. */ struct pkt_rrep { uint32_t pr_id; /* original site id of ops */ struct pkt_dop pr_dop; /* drawing ops follow */ }; struct id_off { uint32_t id; uint32_t off; }; struct pgstate { uint32_t slot; struct PageID page; uint16_t nid; uint16_t rsvd; /* seqptr's */ }; /* * An announcement packet. */ struct pkt_id { uint32_t pi_mslot; struct PageID pi_mpage; /* current page */ struct pgstate pi_ps; /* seqptr's */ /* null-terminated site name */ }; struct pkt_preq { struct PageID pp_page; uint32_t pp_low; uint32_t pp_high; }; struct pkt_prep { uint32_t pp_n; /* size of pageid array */ /* pgstate's follow */ }; static int wb_id(netdissect_options *ndo, const struct pkt_id *id, u_int len) { int i; const char *cp; const struct id_off *io; char c; int nid; ND_PRINT((ndo, " wb-id:")); if (len < sizeof(*id) || !ND_TTEST(*id)) return (-1); len -= sizeof(*id); ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ", EXTRACT_32BITS(&id->pi_ps.slot), ipaddr_string(ndo, &id->pi_ps.page.p_sid), EXTRACT_32BITS(&id->pi_ps.page.p_uid), EXTRACT_32BITS(&id->pi_mslot), ipaddr_string(ndo, &id->pi_mpage.p_sid), EXTRACT_32BITS(&id->pi_mpage.p_uid))); nid = EXTRACT_16BITS(&id->pi_ps.nid); len -= sizeof(*io) * nid; io = (const struct id_off *)(id + 1); cp = (const char *)(io + nid); - if (ND_TTEST2(cp, len)) { + if (ND_TTEST2(*cp, len)) { ND_PRINT((ndo, "\"")); fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len); ND_PRINT((ndo, "\"")); } c = '<'; for (i = 0; i < nid && ND_TTEST(*io); ++io, ++i) { ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off))); c = ','; } if (i >= nid) { ND_PRINT((ndo, ">")); return (0); } return (-1); } static int wb_rreq(netdissect_options *ndo, const struct pkt_rreq *rreq, u_int len) { ND_PRINT((ndo, " wb-rreq:")); if (len < sizeof(*rreq) || !ND_TTEST(*rreq)) return (-1); ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>", ipaddr_string(ndo, &rreq->pr_id), ipaddr_string(ndo, &rreq->pr_page.p_sid), EXTRACT_32BITS(&rreq->pr_page.p_uid), EXTRACT_32BITS(&rreq->pr_sseq), EXTRACT_32BITS(&rreq->pr_eseq))); return (0); } static int wb_preq(netdissect_options *ndo, const struct pkt_preq *preq, u_int len) { ND_PRINT((ndo, " wb-preq:")); if (len < sizeof(*preq) || !ND_TTEST(*preq)) return (-1); ND_PRINT((ndo, " need %u/%s:%u", EXTRACT_32BITS(&preq->pp_low), ipaddr_string(ndo, &preq->pp_page.p_sid), EXTRACT_32BITS(&preq->pp_page.p_uid))); return (0); } static int wb_prep(netdissect_options *ndo, const struct pkt_prep *prep, u_int len) { int n; const struct pgstate *ps; const u_char *ep = ndo->ndo_snapend; ND_PRINT((ndo, " wb-prep:")); if (len < sizeof(*prep) || !ND_TTEST(*prep)) return (-1); n = EXTRACT_32BITS(&prep->pp_n); ps = (const struct pgstate *)(prep + 1); while (--n >= 0 && ND_TTEST(*ps)) { const struct id_off *io, *ie; char c = '<'; ND_PRINT((ndo, " %u/%s:%u", EXTRACT_32BITS(&ps->slot), ipaddr_string(ndo, &ps->page.p_sid), EXTRACT_32BITS(&ps->page.p_uid))); io = (const struct id_off *)(ps + 1); for (ie = io + ps->nid; io < ie && ND_TTEST(*io); ++io) { ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off))); c = ','; } ND_PRINT((ndo, ">")); ps = (const struct pgstate *)io; } return ((const u_char *)ps <= ep? 0 : -1); } static const char *dopstr[] = { "dop-0!", "dop-1!", "RECT", "LINE", "ML", "DEL", "XFORM", "ELL", "CHAR", "STR", "NOP", "PSCODE", "PSCOMP", "REF", "SKIP", "HOLE", }; static int wb_dops(netdissect_options *ndo, const struct pkt_dop *dop, uint32_t ss, uint32_t es) { const struct dophdr *dh = (const struct dophdr *)((const u_char *)dop + sizeof(*dop)); ND_PRINT((ndo, " <")); for ( ; ss <= es; ++ss) { int t; if (!ND_TTEST(*dh)) { ND_PRINT((ndo, "%s", tstr)); break; } t = dh->dh_type; if (t > DT_MAXTYPE) ND_PRINT((ndo, " dop-%d!", t)); else { ND_PRINT((ndo, " %s", dopstr[t])); if (t == DT_SKIP || t == DT_HOLE) { uint32_t ts = EXTRACT_32BITS(&dh->dh_ts); ND_PRINT((ndo, "%d", ts - ss + 1)); if (ss > ts || ts > es) { ND_PRINT((ndo, "[|]")); if (ts < ss) return (0); } ss = ts; } } dh = DOP_NEXT(dh); } ND_PRINT((ndo, " >")); return (0); } static int wb_rrep(netdissect_options *ndo, const struct pkt_rrep *rrep, u_int len) { const struct pkt_dop *dop = &rrep->pr_dop; ND_PRINT((ndo, " wb-rrep:")); if (len < sizeof(*rrep) || !ND_TTEST(*rrep)) return (-1); len -= sizeof(*rrep); ND_PRINT((ndo, " for %s %s:%u<%u:%u>", ipaddr_string(ndo, &rrep->pr_id), ipaddr_string(ndo, &dop->pd_page.p_sid), EXTRACT_32BITS(&dop->pd_page.p_uid), EXTRACT_32BITS(&dop->pd_sseq), EXTRACT_32BITS(&dop->pd_eseq))); if (ndo->ndo_vflag) return (wb_dops(ndo, dop, EXTRACT_32BITS(&dop->pd_sseq), EXTRACT_32BITS(&dop->pd_eseq))); return (0); } static int wb_drawop(netdissect_options *ndo, const struct pkt_dop *dop, u_int len) { ND_PRINT((ndo, " wb-dop:")); if (len < sizeof(*dop) || !ND_TTEST(*dop)) return (-1); len -= sizeof(*dop); ND_PRINT((ndo, " %s:%u<%u:%u>", ipaddr_string(ndo, &dop->pd_page.p_sid), EXTRACT_32BITS(&dop->pd_page.p_uid), EXTRACT_32BITS(&dop->pd_sseq), EXTRACT_32BITS(&dop->pd_eseq))); if (ndo->ndo_vflag) return (wb_dops(ndo, dop, EXTRACT_32BITS(&dop->pd_sseq), EXTRACT_32BITS(&dop->pd_eseq))); return (0); } /* * Print whiteboard multicast packets. */ void wb_print(netdissect_options *ndo, register const void *hdr, register u_int len) { register const struct pkt_hdr *ph; ph = (const struct pkt_hdr *)hdr; if (len < sizeof(*ph) || !ND_TTEST(*ph)) { ND_PRINT((ndo, "%s", tstr)); return; } len -= sizeof(*ph); if (ph->ph_flags) ND_PRINT((ndo, "*")); switch (ph->ph_type) { case PT_KILL: ND_PRINT((ndo, " wb-kill")); return; case PT_ID: if (wb_id(ndo, (const struct pkt_id *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; case PT_RREQ: if (wb_rreq(ndo, (const struct pkt_rreq *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; case PT_RREP: if (wb_rrep(ndo, (const struct pkt_rrep *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; case PT_DRAWOP: if (wb_drawop(ndo, (const struct pkt_dop *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; case PT_PREQ: if (wb_preq(ndo, (const struct pkt_preq *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; case PT_PREP: if (wb_prep(ndo, (const struct pkt_prep *)(ph + 1), len) >= 0) return; ND_PRINT((ndo, "%s", tstr)); break; default: ND_PRINT((ndo, " wb-%d!", ph->ph_type)); return; } } Index: vendor/tcpdump/dist/signature.c =================================================================== --- vendor/tcpdump/dist/signature.c (revision 353143) +++ vendor/tcpdump/dist/signature.c (revision 353144) @@ -1,214 +1,214 @@ /* * 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. * * Functions for signature and digest verification. * * Original code by Hannes Gredler (hannes@gredler.at) */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "netdissect.h" #include "signature.h" #ifdef HAVE_LIBCRYPTO #include #endif const struct tok signature_check_values[] = { { SIGNATURE_VALID, "valid"}, { SIGNATURE_INVALID, "invalid"}, { CANT_ALLOCATE_COPY, "can't allocate memory"}, { CANT_CHECK_SIGNATURE, "unchecked"}, { 0, NULL } }; #ifdef HAVE_LIBCRYPTO /* * Compute a HMAC MD5 sum. * Taken from rfc2104, Appendix. */ USES_APPLE_DEPRECATED_API static void signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key, unsigned int key_len, uint8_t *digest) { MD5_CTX context; unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */ unsigned char k_opad[65]; /* outer padding - key XORd with opad */ unsigned char tk[16]; int i; /* if key is longer than 64 bytes reset it to key=MD5(key) */ if (key_len > 64) { MD5_CTX tctx; MD5_Init(&tctx); MD5_Update(&tctx, key, key_len); MD5_Final(tk, &tctx); key = tk; key_len = 16; } /* * the HMAC_MD5 transform looks like: * * MD5(K XOR opad, MD5(K XOR ipad, text)) * * where K is an n byte key * ipad is the byte 0x36 repeated 64 times * opad is the byte 0x5c repeated 64 times * and text is the data being protected */ /* start out by storing key in pads */ memset(k_ipad, 0, sizeof k_ipad); memset(k_opad, 0, sizeof k_opad); memcpy(k_ipad, key, key_len); memcpy(k_opad, key, key_len); /* XOR key with ipad and opad values */ for (i=0; i<64; i++) { k_ipad[i] ^= 0x36; k_opad[i] ^= 0x5c; } /* * perform inner MD5 */ MD5_Init(&context); /* init context for 1st pass */ MD5_Update(&context, k_ipad, 64); /* start with inner pad */ MD5_Update(&context, text, text_len); /* then text of datagram */ MD5_Final(digest, &context); /* finish up 1st pass */ /* * perform outer MD5 */ MD5_Init(&context); /* init context for 2nd pass */ MD5_Update(&context, k_opad, 64); /* start with outer pad */ MD5_Update(&context, digest, 16); /* then results of 1st hash */ MD5_Final(digest, &context); /* finish up 2nd pass */ } USES_APPLE_RST /* * Verify a cryptographic signature of the packet. * Currently only MD5 is supported. */ int signature_verify(netdissect_options *ndo, const u_char *pptr, u_int plen, const u_char *sig_ptr, void (*clear_rtn)(void *), const void *clear_arg) { uint8_t *packet_copy, *sig_copy; uint8_t sig[16]; unsigned int i; if (!ndo->ndo_sigsecret) { return (CANT_CHECK_SIGNATURE); } /* * Do we have all the packet data to be checked? */ - if (!ND_TTEST2(pptr, plen)) { + if (!ND_TTEST2(*pptr, plen)) { /* No. */ return (CANT_CHECK_SIGNATURE); } /* * Do we have the entire signature to check? */ - if (!ND_TTEST2(sig_ptr, sizeof(sig))) { + if (!ND_TTEST2(*sig_ptr, sizeof(sig))) { /* No. */ return (CANT_CHECK_SIGNATURE); } if (sig_ptr + sizeof(sig) > pptr + plen) { /* No. */ return (CANT_CHECK_SIGNATURE); } /* * Make a copy of the packet, so we don't overwrite the original. */ packet_copy = malloc(plen); if (packet_copy == NULL) { return (CANT_ALLOCATE_COPY); } memcpy(packet_copy, pptr, plen); /* * Clear the signature in the copy. */ sig_copy = packet_copy + (sig_ptr - pptr); memset(sig_copy, 0, sizeof(sig)); /* * Clear anything else that needs to be cleared in the copy. * Our caller is assumed to have vetted the clear_arg pointer. */ (*clear_rtn)((void *)(packet_copy + ((const uint8_t *)clear_arg - pptr))); /* * Compute the signature. */ signature_compute_hmac_md5(packet_copy, plen, (unsigned char *)ndo->ndo_sigsecret, strlen(ndo->ndo_sigsecret), sig); /* * Free the copy. */ free(packet_copy); /* * Does the computed signature match the signature in the packet? */ if (memcmp(sig_ptr, sig, sizeof(sig)) == 0) { /* Yes. */ return (SIGNATURE_VALID); } else { /* No - print the computed signature. */ for (i = 0; i < sizeof(sig); ++i) { ND_PRINT((ndo, "%02x", sig[i])); } return (SIGNATURE_INVALID); } } #else int signature_verify(netdissect_options *ndo _U_, const u_char *pptr _U_, u_int plen _U_, const u_char *sig_ptr _U_, void (*clear_rtn)(void *) _U_, const void *clear_arg _U_) { return (CANT_CHECK_SIGNATURE); } #endif /* * Local Variables: * c-style: whitesmith * c-basic-offset: 4 * End: */ Index: vendor/tcpdump/dist/smbutil.c =================================================================== --- vendor/tcpdump/dist/smbutil.c (revision 353143) +++ vendor/tcpdump/dist/smbutil.c (revision 353144) @@ -1,1893 +1,1927 @@ /* * Copyright (C) Andrew Tridgell 1995-1999 * * This software may be distributed either under the terms of the * BSD-style license that accompanies tcpdump or the GNU GPL version 2 * or later */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "netdissect.h" #include "extract.h" #include "smb.h" static uint32_t stringlen; extern const u_char *startbuf; /* * interpret a 32 bit dos packed date/time to some parameters */ static void interpret_dos_date(uint32_t date, struct tm *tp) { uint32_t p0, p1, p2, p3; p0 = date & 0xFF; p1 = ((date & 0xFF00) >> 8) & 0xFF; p2 = ((date & 0xFF0000) >> 16) & 0xFF; p3 = ((date & 0xFF000000) >> 24) & 0xFF; tp->tm_sec = 2 * (p0 & 0x1F); tp->tm_min = ((p0 >> 5) & 0xFF) + ((p1 & 0x7) << 3); tp->tm_hour = (p1 >> 3) & 0xFF; tp->tm_mday = (p2 & 0x1F); tp->tm_mon = ((p2 >> 5) & 0xFF) + ((p3 & 0x1) << 3) - 1; tp->tm_year = ((p3 >> 1) & 0xFF) + 80; } /* * common portion: * create a unix date from a dos date */ static time_t int_unix_date(uint32_t dos_date) { struct tm t; if (dos_date == 0) return(0); interpret_dos_date(dos_date, &t); t.tm_wday = 1; t.tm_yday = 1; t.tm_isdst = 0; return (mktime(&t)); } /* * create a unix date from a dos date * in network byte order */ static time_t make_unix_date(const u_char *date_ptr) { uint32_t dos_date = 0; dos_date = EXTRACT_LE_32BITS(date_ptr); return int_unix_date(dos_date); } /* * create a unix date from a dos date * in halfword-swapped network byte order! */ static time_t make_unix_date2(const u_char *date_ptr) { uint32_t x, x2; x = EXTRACT_LE_32BITS(date_ptr); x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16); return int_unix_date(x2); } /* * interpret an 8 byte "filetime" structure to a time_t * It's originally in "100ns units since jan 1st 1601" */ static time_t interpret_long_date(const u_char *p) { double d; time_t ret; /* this gives us seconds since jan 1st 1601 (approx) */ d = (EXTRACT_LE_32BITS(p + 4) * 256.0 + p[3]) * (1.0e-7 * (1 << 24)); /* now adjust by 369 years to make the secs since 1970 */ d -= 369.0 * 365.25 * 24 * 60 * 60; /* and a fudge factor as we got it wrong by a few days */ d += (3 * 24 * 60 * 60 + 6 * 60 * 60 + 2); if (d < 0) return(0); ret = (time_t)d; return(ret); } /* * interpret the weird netbios "name". Return the name type, or -1 if * we run past the end of the buffer */ static int name_interpret(netdissect_options *ndo, const u_char *in, const u_char *maxbuf, char *out) { int ret; int len; if (in >= maxbuf) return(-1); /* name goes past the end of the buffer */ ND_TCHECK2(*in, 1); len = (*in++) / 2; *out=0; if (len > 30 || len < 1) return(0); while (len--) { ND_TCHECK2(*in, 2); if (in + 1 >= maxbuf) return(-1); /* name goes past the end of the buffer */ if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') { *out = 0; return(0); } *out = ((in[0] - 'A') << 4) + (in[1] - 'A'); in += 2; out++; } *out = 0; ret = out[-1]; return(ret); trunc: return(-1); } /* * find a pointer to a netbios name */ static const u_char * name_ptr(netdissect_options *ndo, const u_char *buf, int ofs, const u_char *maxbuf) { const u_char *p; u_char c; p = buf + ofs; if (p >= maxbuf) return(NULL); /* name goes past the end of the buffer */ ND_TCHECK2(*p, 1); c = *p; /* XXX - this should use the same code that the DNS dissector does */ if ((c & 0xC0) == 0xC0) { uint16_t l; ND_TCHECK2(*p, 2); if ((p + 1) >= maxbuf) return(NULL); /* name goes past the end of the buffer */ l = EXTRACT_16BITS(p) & 0x3FFF; if (l == 0) { /* We have a pointer that points to itself. */ return(NULL); } p = buf + l; if (p >= maxbuf) return(NULL); /* name goes past the end of the buffer */ ND_TCHECK2(*p, 1); } return(p); trunc: return(NULL); /* name goes past the end of the buffer */ } /* * extract a netbios name from a buf */ static int name_extract(netdissect_options *ndo, const u_char *buf, int ofs, const u_char *maxbuf, char *name) { const u_char *p = name_ptr(ndo, buf, ofs, maxbuf); if (p == NULL) return(-1); /* error (probably name going past end of buffer) */ name[0] = '\0'; return(name_interpret(ndo, p, maxbuf, name)); } /* * return the total storage length of a mangled name */ static int name_len(netdissect_options *ndo, const unsigned char *s, const unsigned char *maxbuf) { const unsigned char *s0 = s; unsigned char c; if (s >= maxbuf) return(-1); /* name goes past the end of the buffer */ ND_TCHECK2(*s, 1); c = *s; if ((c & 0xC0) == 0xC0) return(2); while (*s) { if (s >= maxbuf) return(-1); /* name goes past the end of the buffer */ ND_TCHECK2(*s, 1); s += (*s) + 1; ND_TCHECK2(*s, 1); } return(PTR_DIFF(s, s0) + 1); trunc: return(-1); /* name goes past the end of the buffer */ } static void print_asc(netdissect_options *ndo, const unsigned char *buf, int len) { int i; for (i = 0; i < len; i++) safeputchar(ndo, buf[i]); } static const char * name_type_str(int name_type) { const char *f = NULL; switch (name_type) { case 0: f = "Workstation"; break; case 0x03: f = "Client?"; break; case 0x20: f = "Server"; break; case 0x1d: f = "Master Browser"; break; case 0x1b: f = "Domain Controller"; break; case 0x1e: f = "Browser Server"; break; default: f = "Unknown"; break; } return(f); } void smb_print_data(netdissect_options *ndo, const unsigned char *buf, int len) { int i = 0; if (len <= 0) return; ND_PRINT((ndo, "[%03X] ", i)); for (i = 0; i < len; /*nothing*/) { ND_TCHECK(buf[i]); ND_PRINT((ndo, "%02X ", buf[i] & 0xff)); i++; if (i%8 == 0) ND_PRINT((ndo, " ")); if (i % 16 == 0) { print_asc(ndo, &buf[i - 16], 8); ND_PRINT((ndo, " ")); print_asc(ndo, &buf[i - 8], 8); ND_PRINT((ndo, "\n")); if (i < len) ND_PRINT((ndo, "[%03X] ", i)); } } if (i % 16) { int n; n = 16 - (i % 16); ND_PRINT((ndo, " ")); if (n>8) ND_PRINT((ndo, " ")); while (n--) ND_PRINT((ndo, " ")); n = min(8, i % 16); print_asc(ndo, &buf[i - (i % 16)], n); ND_PRINT((ndo, " ")); n = (i % 16) - n; if (n > 0) print_asc(ndo, &buf[i - n], n); ND_PRINT((ndo, "\n")); } return; trunc: ND_PRINT((ndo, "\n")); ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n")); } static void write_bits(netdissect_options *ndo, unsigned int val, const char *fmt) { const char *p = fmt; int i = 0; while ((p = strchr(fmt, '|'))) { size_t l = PTR_DIFF(p, fmt); if (l && (val & (1 << i))) ND_PRINT((ndo, "%.*s ", (int)l, fmt)); fmt = p + 1; i++; } } /* convert a UCS-2 string into an ASCII string */ #define MAX_UNISTR_SIZE 1000 static const char * unistr(netdissect_options *ndo, const u_char *s, uint32_t *len, int use_unicode) { static char buf[MAX_UNISTR_SIZE+1]; size_t l = 0; uint32_t strsize; const u_char *sp; if (use_unicode) { /* * Skip padding that puts the string on an even boundary. */ if (((s - startbuf) % 2) != 0) { ND_TCHECK(s[0]); s++; } } if (*len == 0) { /* * Null-terminated string. */ strsize = 0; sp = s; if (!use_unicode) { for (;;) { ND_TCHECK(sp[0]); *len += 1; if (sp[0] == 0) break; sp++; } strsize = *len - 1; } else { for (;;) { ND_TCHECK2(sp[0], 2); *len += 2; if (sp[0] == 0 && sp[1] == 0) break; sp += 2; } strsize = *len - 2; } } else { /* * Counted string. */ strsize = *len; } if (!use_unicode) { while (strsize != 0) { ND_TCHECK(s[0]); if (l >= MAX_UNISTR_SIZE) break; if (ND_ISPRINT(s[0])) buf[l] = s[0]; else { if (s[0] == 0) break; buf[l] = '.'; } l++; s++; strsize--; } } else { while (strsize != 0) { ND_TCHECK2(s[0], 2); if (l >= MAX_UNISTR_SIZE) break; if (s[1] == 0 && ND_ISPRINT(s[0])) { /* It's a printable ASCII character */ buf[l] = s[0]; } else { /* It's a non-ASCII character or a non-printable ASCII character */ if (s[0] == 0 && s[1] == 0) break; buf[l] = '.'; } l++; s += 2; if (strsize == 1) break; strsize -= 2; } } buf[l] = 0; return buf; trunc: return NULL; } static const u_char * smb_fdata1(netdissect_options *ndo, const u_char *buf, const char *fmt, const u_char *maxbuf, int unicodestr) { int reverse = 0; const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|"; while (*fmt && buf sizeof(bitfmt) - 1) l = sizeof(bitfmt)-1; strncpy(bitfmt, fmt, l); bitfmt[l] = '\0'; fmt = p + 1; ND_TCHECK(buf[0]); write_bits(ndo, buf[0], bitfmt); buf++; break; } case 'P': { - int l = atoi(fmt + 1); + int l = atoi(fmt + 1); + if(l <= 0) goto trunc; /* actually error in fmt string */ ND_TCHECK2(buf[0], l); buf += l; fmt++; while (isdigit((unsigned char)*fmt)) - fmt++; + fmt++; break; } case 'r': reverse = !reverse; fmt++; break; case 'b': { unsigned int x; ND_TCHECK(buf[0]); x = buf[0]; ND_PRINT((ndo, "%u (0x%x)", x, x)); buf += 1; fmt++; break; } case 'd': { unsigned int x; ND_TCHECK2(buf[0], 2); x = reverse ? EXTRACT_16BITS(buf) : EXTRACT_LE_16BITS(buf); ND_PRINT((ndo, "%d (0x%x)", x, x)); buf += 2; fmt++; break; } case 'D': { unsigned int x; ND_TCHECK2(buf[0], 4); x = reverse ? EXTRACT_32BITS(buf) : EXTRACT_LE_32BITS(buf); ND_PRINT((ndo, "%d (0x%x)", x, x)); buf += 4; fmt++; break; } case 'L': { uint64_t x; ND_TCHECK2(buf[0], 8); x = reverse ? EXTRACT_64BITS(buf) : EXTRACT_LE_64BITS(buf); ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x)); buf += 8; fmt++; break; } case 'M': { /* Weird mixed-endian length values in 64-bit locks */ uint32_t x1, x2; uint64_t x; ND_TCHECK2(buf[0], 8); x1 = reverse ? EXTRACT_32BITS(buf) : EXTRACT_LE_32BITS(buf); x2 = reverse ? EXTRACT_32BITS(buf + 4) : EXTRACT_LE_32BITS(buf + 4); x = (((uint64_t)x1) << 32) | x2; ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x)); buf += 8; fmt++; break; } case 'B': { unsigned int x; ND_TCHECK(buf[0]); x = buf[0]; ND_PRINT((ndo, "0x%X", x)); buf += 1; fmt++; break; } case 'w': { unsigned int x; ND_TCHECK2(buf[0], 2); x = reverse ? EXTRACT_16BITS(buf) : EXTRACT_LE_16BITS(buf); ND_PRINT((ndo, "0x%X", x)); buf += 2; fmt++; break; } case 'W': { unsigned int x; ND_TCHECK2(buf[0], 4); x = reverse ? EXTRACT_32BITS(buf) : EXTRACT_LE_32BITS(buf); ND_PRINT((ndo, "0x%X", x)); buf += 4; fmt++; break; } case 'l': { fmt++; switch (*fmt) { case 'b': ND_TCHECK(buf[0]); stringlen = buf[0]; ND_PRINT((ndo, "%u", stringlen)); buf += 1; break; case 'd': ND_TCHECK2(buf[0], 2); stringlen = reverse ? EXTRACT_16BITS(buf) : EXTRACT_LE_16BITS(buf); ND_PRINT((ndo, "%u", stringlen)); buf += 2; break; case 'D': ND_TCHECK2(buf[0], 4); stringlen = reverse ? EXTRACT_32BITS(buf) : EXTRACT_LE_32BITS(buf); ND_PRINT((ndo, "%u", stringlen)); buf += 4; break; } fmt++; break; } case 'S': case 'R': /* like 'S', but always ASCII */ { /*XXX unistr() */ const char *s; uint32_t len; len = 0; s = unistr(ndo, buf, &len, (*fmt == 'R') ? 0 : unicodestr); if (s == NULL) goto trunc; ND_PRINT((ndo, "%s", s)); buf += len; fmt++; break; } case 'Z': case 'Y': /* like 'Z', but always ASCII */ { const char *s; uint32_t len; ND_TCHECK(*buf); if (*buf != 4 && *buf != 2) { ND_PRINT((ndo, "Error! ASCIIZ buffer of type %u", *buf)); return maxbuf; /* give up */ } len = 0; s = unistr(ndo, buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr); if (s == NULL) goto trunc; ND_PRINT((ndo, "%s", s)); buf += len + 1; fmt++; break; } case 's': { int l = atoi(fmt + 1); ND_TCHECK2(*buf, l); ND_PRINT((ndo, "%-*.*s", l, l, buf)); buf += l; fmt++; while (isdigit((unsigned char)*fmt)) fmt++; break; } case 'c': { ND_TCHECK2(*buf, stringlen); ND_PRINT((ndo, "%-*.*s", (int)stringlen, (int)stringlen, buf)); buf += stringlen; fmt++; while (isdigit((unsigned char)*fmt)) fmt++; break; } case 'C': { const char *s; s = unistr(ndo, buf, &stringlen, unicodestr); if (s == NULL) goto trunc; ND_PRINT((ndo, "%s", s)); buf += stringlen; fmt++; break; } case 'h': { int l = atoi(fmt + 1); ND_TCHECK2(*buf, l); while (l--) ND_PRINT((ndo, "%02x", *buf++)); fmt++; while (isdigit((unsigned char)*fmt)) fmt++; break; } case 'n': { int t = atoi(fmt+1); char nbuf[255]; int name_type; int len; switch (t) { case 1: name_type = name_extract(ndo, startbuf, PTR_DIFF(buf, startbuf), maxbuf, nbuf); if (name_type < 0) goto trunc; len = name_len(ndo, buf, maxbuf); if (len < 0) goto trunc; buf += len; ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", nbuf, name_type, name_type_str(name_type))); break; case 2: ND_TCHECK(buf[15]); name_type = buf[15]; ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type, name_type_str(name_type))); buf += 16; break; } fmt++; while (isdigit((unsigned char)*fmt)) fmt++; break; } case 'T': { time_t t; struct tm *lt; const char *tstring; uint32_t x; switch (atoi(fmt + 1)) { case 1: ND_TCHECK2(buf[0], 4); x = EXTRACT_LE_32BITS(buf); if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date(buf); buf += 4; break; case 2: ND_TCHECK2(buf[0], 4); x = EXTRACT_LE_32BITS(buf); if (x == 0 || x == 0xFFFFFFFF) t = 0; else t = make_unix_date2(buf); buf += 4; break; case 3: ND_TCHECK2(buf[0], 8); t = interpret_long_date(buf); buf += 8; break; default: t = 0; break; } if (t != 0) { lt = localtime(&t); if (lt != NULL) tstring = asctime(lt); else tstring = "(Can't convert time)\n"; } else tstring = "NULL\n"; ND_PRINT((ndo, "%s", tstring)); fmt++; while (isdigit((unsigned char)*fmt)) fmt++; break; } default: ND_PRINT((ndo, "%c", *fmt)); fmt++; break; } } if (buf >= maxbuf && *fmt) ND_PRINT((ndo, "END OF BUFFER\n")); return(buf); trunc: ND_PRINT((ndo, "\n")); ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n")); return(NULL); } const u_char * smb_fdata(netdissect_options *ndo, const u_char *buf, const char *fmt, const u_char *maxbuf, int unicodestr) { static int depth = 0; + const u_char *buf_start = buf; char s[128]; char *p; while (*fmt) { switch (*fmt) { case '*': + /* + * List of multiple instances of something described by the + * remainder of the string (which may itself include a list + * of multiple instances of something, so we recurse). + */ fmt++; while (buf < maxbuf) { const u_char *buf2; depth++; - buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr); + /* + * In order to avoid stack exhaustion recurse at most 10 + * levels; that "should not happen", as no SMB structure + * should be nested *that* deeply, and we thus shouldn't + * have format strings with that level of nesting. + */ + if (depth == 10) { + ND_PRINT((ndo, "(too many nested levels, not recursing)")); + buf2 = buf; + } else + buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr); depth--; if (buf2 == NULL) return(NULL); if (buf2 == buf) return(buf); buf = buf2; } return(buf); case '|': + /* + * Just do a bounds check. + */ fmt++; if (buf >= maxbuf) return(buf); break; case '%': + /* + * XXX - unused? + */ fmt++; buf = maxbuf; break; case '#': + /* + * Done? + */ fmt++; return(buf); break; case '[': + /* + * Format of an item, enclosed in square brackets; dissect + * the item with smb_fdata1(). + */ fmt++; if (buf >= maxbuf) return(buf); memset(s, 0, sizeof(s)); p = strchr(fmt, ']'); if ((size_t)(p - fmt + 1) > sizeof(s)) { /* overrun */ return(buf); } strncpy(s, fmt, p - fmt); s[p - fmt] = '\0'; fmt = p + 1; buf = smb_fdata1(ndo, buf, s, maxbuf, unicodestr); - if (buf == NULL) + if(buf < buf_start || buf == NULL) { return(NULL); + } break; default: + /* + * Not a formatting character, so just print it. + */ ND_PRINT((ndo, "%c", *fmt)); fmt++; break; } } if (!depth && buf < maxbuf) { size_t len = PTR_DIFF(maxbuf, buf); ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len)); smb_print_data(ndo, buf, len); return(buf + len); } return(buf); } typedef struct { const char *name; int code; const char *message; } err_code_struct; /* DOS Error Messages */ static const err_code_struct dos_msgs[] = { { "ERRbadfunc", 1, "Invalid function." }, { "ERRbadfile", 2, "File not found." }, { "ERRbadpath", 3, "Directory invalid." }, { "ERRnofids", 4, "No file descriptors available" }, { "ERRnoaccess", 5, "Access denied." }, { "ERRbadfid", 6, "Invalid file handle." }, { "ERRbadmcb", 7, "Memory control blocks destroyed." }, { "ERRnomem", 8, "Insufficient server memory to perform the requested function." }, { "ERRbadmem", 9, "Invalid memory block address." }, { "ERRbadenv", 10, "Invalid environment." }, { "ERRbadformat", 11, "Invalid format." }, { "ERRbadaccess", 12, "Invalid open mode." }, { "ERRbaddata", 13, "Invalid data." }, { "ERR", 14, "reserved." }, { "ERRbaddrive", 15, "Invalid drive specified." }, { "ERRremcd", 16, "A Delete Directory request attempted to remove the server's current directory." }, { "ERRdiffdevice", 17, "Not same device." }, { "ERRnofiles", 18, "A File Search command can find no more files matching the specified criteria." }, { "ERRbadshare", 32, "The sharing mode specified for an Open conflicts with existing FIDs on the file." }, { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." }, { "ERRfilexists", 80, "The file named in a Create Directory, Make New File or Link request already exists." }, { "ERRbadpipe", 230, "Pipe invalid." }, { "ERRpipebusy", 231, "All instances of the requested pipe are busy." }, { "ERRpipeclosing", 232, "Pipe close in progress." }, { "ERRnotconnected", 233, "No process on other end of pipe." }, { "ERRmoredata", 234, "There is more data to be returned." }, { NULL, -1, NULL } }; /* Server Error Messages */ static const err_code_struct server_msgs[] = { { "ERRerror", 1, "Non-specific error code." }, { "ERRbadpw", 2, "Bad password - name/password pair in a Tree Connect or Session Setup are invalid." }, { "ERRbadtype", 3, "reserved." }, { "ERRaccess", 4, "The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID." }, { "ERRinvnid", 5, "The tree ID (TID) specified in a command was invalid." }, { "ERRinvnetname", 6, "Invalid network name in tree connect." }, { "ERRinvdevice", 7, "Invalid device - printer request made to non-printer connection or non-printer request made to printer connection." }, { "ERRqfull", 49, "Print queue full (files) -- returned by open print file." }, { "ERRqtoobig", 50, "Print queue full -- no space." }, { "ERRqeof", 51, "EOF on print queue dump." }, { "ERRinvpfid", 52, "Invalid print file FID." }, { "ERRsmbcmd", 64, "The server did not recognize the command received." }, { "ERRsrverror", 65, "The server encountered an internal error, e.g., system file unavailable." }, { "ERRfilespecs", 67, "The file handle (FID) and pathname parameters contained an invalid combination of values." }, { "ERRreserved", 68, "reserved." }, { "ERRbadpermits", 69, "The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute." }, { "ERRreserved", 70, "reserved." }, { "ERRsetattrmode", 71, "The attribute mode in the Set File Attribute request is invalid." }, { "ERRpaused", 81, "Server is paused." }, { "ERRmsgoff", 82, "Not receiving messages." }, { "ERRnoroom", 83, "No room to buffer message." }, { "ERRrmuns", 87, "Too many remote user names." }, { "ERRtimeout", 88, "Operation timed out." }, { "ERRnoresource", 89, "No resources currently available for request." }, { "ERRtoomanyuids", 90, "Too many UIDs active on this session." }, { "ERRbaduid", 91, "The UID is not known as a valid ID on this session." }, { "ERRusempx", 250, "Temp unable to support Raw, use MPX mode." }, { "ERRusestd", 251, "Temp unable to support Raw, use standard read/write." }, { "ERRcontmpx", 252, "Continue in MPX mode." }, { "ERRreserved", 253, "reserved." }, { "ERRreserved", 254, "reserved." }, { "ERRnosupport", 0xFFFF, "Function not supported." }, { NULL, -1, NULL } }; /* Hard Error Messages */ static const err_code_struct hard_msgs[] = { { "ERRnowrite", 19, "Attempt to write on write-protected diskette." }, { "ERRbadunit", 20, "Unknown unit." }, { "ERRnotready", 21, "Drive not ready." }, { "ERRbadcmd", 22, "Unknown command." }, { "ERRdata", 23, "Data error (CRC)." }, { "ERRbadreq", 24, "Bad request structure length." }, { "ERRseek", 25 , "Seek error." }, { "ERRbadmedia", 26, "Unknown media type." }, { "ERRbadsector", 27, "Sector not found." }, { "ERRnopaper", 28, "Printer out of paper." }, { "ERRwrite", 29, "Write fault." }, { "ERRread", 30, "Read fault." }, { "ERRgeneral", 31, "General failure." }, { "ERRbadshare", 32, "A open conflicts with an existing open." }, { "ERRlock", 33, "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process." }, { "ERRwrongdisk", 34, "The wrong disk was found in a drive." }, { "ERRFCBUnavail", 35, "No FCBs are available to process request." }, { "ERRsharebufexc", 36, "A sharing buffer has been exceeded." }, { NULL, -1, NULL } }; static const struct { int code; const char *class; const err_code_struct *err_msgs; } err_classes[] = { { 0, "SUCCESS", NULL }, { 0x01, "ERRDOS", dos_msgs }, { 0x02, "ERRSRV", server_msgs }, { 0x03, "ERRHRD", hard_msgs }, { 0x04, "ERRXOS", NULL }, { 0xE1, "ERRRMX1", NULL }, { 0xE2, "ERRRMX2", NULL }, { 0xE3, "ERRRMX3", NULL }, { 0xFF, "ERRCMD", NULL }, { -1, NULL, NULL } }; /* * return a SMB error string from a SMB buffer */ char * smb_errstr(int class, int num) { static char ret[128]; int i, j; ret[0] = 0; for (i = 0; err_classes[i].class; i++) if (err_classes[i].code == class) { if (err_classes[i].err_msgs) { const err_code_struct *err = err_classes[i].err_msgs; for (j = 0; err[j].name; j++) if (num == err[j].code) { snprintf(ret, sizeof(ret), "%s - %s (%s)", err_classes[i].class, err[j].name, err[j].message); return ret; } } snprintf(ret, sizeof(ret), "%s - %d", err_classes[i].class, num); return ret; } snprintf(ret, sizeof(ret), "ERROR: Unknown error (%d,%d)", class, num); return(ret); } typedef struct { uint32_t code; const char *name; } nt_err_code_struct; /* * NT Error codes */ static const nt_err_code_struct nt_errors[] = { { 0x00000000, "STATUS_SUCCESS" }, { 0x00000000, "STATUS_WAIT_0" }, { 0x00000001, "STATUS_WAIT_1" }, { 0x00000002, "STATUS_WAIT_2" }, { 0x00000003, "STATUS_WAIT_3" }, { 0x0000003F, "STATUS_WAIT_63" }, { 0x00000080, "STATUS_ABANDONED" }, { 0x00000080, "STATUS_ABANDONED_WAIT_0" }, { 0x000000BF, "STATUS_ABANDONED_WAIT_63" }, { 0x000000C0, "STATUS_USER_APC" }, { 0x00000100, "STATUS_KERNEL_APC" }, { 0x00000101, "STATUS_ALERTED" }, { 0x00000102, "STATUS_TIMEOUT" }, { 0x00000103, "STATUS_PENDING" }, { 0x00000104, "STATUS_REPARSE" }, { 0x00000105, "STATUS_MORE_ENTRIES" }, { 0x00000106, "STATUS_NOT_ALL_ASSIGNED" }, { 0x00000107, "STATUS_SOME_NOT_MAPPED" }, { 0x00000108, "STATUS_OPLOCK_BREAK_IN_PROGRESS" }, { 0x00000109, "STATUS_VOLUME_MOUNTED" }, { 0x0000010A, "STATUS_RXACT_COMMITTED" }, { 0x0000010B, "STATUS_NOTIFY_CLEANUP" }, { 0x0000010C, "STATUS_NOTIFY_ENUM_DIR" }, { 0x0000010D, "STATUS_NO_QUOTAS_FOR_ACCOUNT" }, { 0x0000010E, "STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED" }, { 0x00000110, "STATUS_PAGE_FAULT_TRANSITION" }, { 0x00000111, "STATUS_PAGE_FAULT_DEMAND_ZERO" }, { 0x00000112, "STATUS_PAGE_FAULT_COPY_ON_WRITE" }, { 0x00000113, "STATUS_PAGE_FAULT_GUARD_PAGE" }, { 0x00000114, "STATUS_PAGE_FAULT_PAGING_FILE" }, { 0x00000115, "STATUS_CACHE_PAGE_LOCKED" }, { 0x00000116, "STATUS_CRASH_DUMP" }, { 0x00000117, "STATUS_BUFFER_ALL_ZEROS" }, { 0x00000118, "STATUS_REPARSE_OBJECT" }, { 0x0000045C, "STATUS_NO_SHUTDOWN_IN_PROGRESS" }, { 0x40000000, "STATUS_OBJECT_NAME_EXISTS" }, { 0x40000001, "STATUS_THREAD_WAS_SUSPENDED" }, { 0x40000002, "STATUS_WORKING_SET_LIMIT_RANGE" }, { 0x40000003, "STATUS_IMAGE_NOT_AT_BASE" }, { 0x40000004, "STATUS_RXACT_STATE_CREATED" }, { 0x40000005, "STATUS_SEGMENT_NOTIFICATION" }, { 0x40000006, "STATUS_LOCAL_USER_SESSION_KEY" }, { 0x40000007, "STATUS_BAD_CURRENT_DIRECTORY" }, { 0x40000008, "STATUS_SERIAL_MORE_WRITES" }, { 0x40000009, "STATUS_REGISTRY_RECOVERED" }, { 0x4000000A, "STATUS_FT_READ_RECOVERY_FROM_BACKUP" }, { 0x4000000B, "STATUS_FT_WRITE_RECOVERY" }, { 0x4000000C, "STATUS_SERIAL_COUNTER_TIMEOUT" }, { 0x4000000D, "STATUS_NULL_LM_PASSWORD" }, { 0x4000000E, "STATUS_IMAGE_MACHINE_TYPE_MISMATCH" }, { 0x4000000F, "STATUS_RECEIVE_PARTIAL" }, { 0x40000010, "STATUS_RECEIVE_EXPEDITED" }, { 0x40000011, "STATUS_RECEIVE_PARTIAL_EXPEDITED" }, { 0x40000012, "STATUS_EVENT_DONE" }, { 0x40000013, "STATUS_EVENT_PENDING" }, { 0x40000014, "STATUS_CHECKING_FILE_SYSTEM" }, { 0x40000015, "STATUS_FATAL_APP_EXIT" }, { 0x40000016, "STATUS_PREDEFINED_HANDLE" }, { 0x40000017, "STATUS_WAS_UNLOCKED" }, { 0x40000018, "STATUS_SERVICE_NOTIFICATION" }, { 0x40000019, "STATUS_WAS_LOCKED" }, { 0x4000001A, "STATUS_LOG_HARD_ERROR" }, { 0x4000001B, "STATUS_ALREADY_WIN32" }, { 0x4000001C, "STATUS_WX86_UNSIMULATE" }, { 0x4000001D, "STATUS_WX86_CONTINUE" }, { 0x4000001E, "STATUS_WX86_SINGLE_STEP" }, { 0x4000001F, "STATUS_WX86_BREAKPOINT" }, { 0x40000020, "STATUS_WX86_EXCEPTION_CONTINUE" }, { 0x40000021, "STATUS_WX86_EXCEPTION_LASTCHANCE" }, { 0x40000022, "STATUS_WX86_EXCEPTION_CHAIN" }, { 0x40000023, "STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE" }, { 0x40000024, "STATUS_NO_YIELD_PERFORMED" }, { 0x40000025, "STATUS_TIMER_RESUME_IGNORED" }, { 0x80000001, "STATUS_GUARD_PAGE_VIOLATION" }, { 0x80000002, "STATUS_DATATYPE_MISALIGNMENT" }, { 0x80000003, "STATUS_BREAKPOINT" }, { 0x80000004, "STATUS_SINGLE_STEP" }, { 0x80000005, "STATUS_BUFFER_OVERFLOW" }, { 0x80000006, "STATUS_NO_MORE_FILES" }, { 0x80000007, "STATUS_WAKE_SYSTEM_DEBUGGER" }, { 0x8000000A, "STATUS_HANDLES_CLOSED" }, { 0x8000000B, "STATUS_NO_INHERITANCE" }, { 0x8000000C, "STATUS_GUID_SUBSTITUTION_MADE" }, { 0x8000000D, "STATUS_PARTIAL_COPY" }, { 0x8000000E, "STATUS_DEVICE_PAPER_EMPTY" }, { 0x8000000F, "STATUS_DEVICE_POWERED_OFF" }, { 0x80000010, "STATUS_DEVICE_OFF_LINE" }, { 0x80000011, "STATUS_DEVICE_BUSY" }, { 0x80000012, "STATUS_NO_MORE_EAS" }, { 0x80000013, "STATUS_INVALID_EA_NAME" }, { 0x80000014, "STATUS_EA_LIST_INCONSISTENT" }, { 0x80000015, "STATUS_INVALID_EA_FLAG" }, { 0x80000016, "STATUS_VERIFY_REQUIRED" }, { 0x80000017, "STATUS_EXTRANEOUS_INFORMATION" }, { 0x80000018, "STATUS_RXACT_COMMIT_NECESSARY" }, { 0x8000001A, "STATUS_NO_MORE_ENTRIES" }, { 0x8000001B, "STATUS_FILEMARK_DETECTED" }, { 0x8000001C, "STATUS_MEDIA_CHANGED" }, { 0x8000001D, "STATUS_BUS_RESET" }, { 0x8000001E, "STATUS_END_OF_MEDIA" }, { 0x8000001F, "STATUS_BEGINNING_OF_MEDIA" }, { 0x80000020, "STATUS_MEDIA_CHECK" }, { 0x80000021, "STATUS_SETMARK_DETECTED" }, { 0x80000022, "STATUS_NO_DATA_DETECTED" }, { 0x80000023, "STATUS_REDIRECTOR_HAS_OPEN_HANDLES" }, { 0x80000024, "STATUS_SERVER_HAS_OPEN_HANDLES" }, { 0x80000025, "STATUS_ALREADY_DISCONNECTED" }, { 0x80000026, "STATUS_LONGJUMP" }, { 0x80040111, "MAPI_E_LOGON_FAILED" }, { 0x80090300, "SEC_E_INSUFFICIENT_MEMORY" }, { 0x80090301, "SEC_E_INVALID_HANDLE" }, { 0x80090302, "SEC_E_UNSUPPORTED_FUNCTION" }, { 0x8009030B, "SEC_E_NO_IMPERSONATION" }, { 0x8009030D, "SEC_E_UNKNOWN_CREDENTIALS" }, { 0x8009030E, "SEC_E_NO_CREDENTIALS" }, { 0x8009030F, "SEC_E_MESSAGE_ALTERED" }, { 0x80090310, "SEC_E_OUT_OF_SEQUENCE" }, { 0x80090311, "SEC_E_NO_AUTHENTICATING_AUTHORITY" }, { 0xC0000001, "STATUS_UNSUCCESSFUL" }, { 0xC0000002, "STATUS_NOT_IMPLEMENTED" }, { 0xC0000003, "STATUS_INVALID_INFO_CLASS" }, { 0xC0000004, "STATUS_INFO_LENGTH_MISMATCH" }, { 0xC0000005, "STATUS_ACCESS_VIOLATION" }, { 0xC0000006, "STATUS_IN_PAGE_ERROR" }, { 0xC0000007, "STATUS_PAGEFILE_QUOTA" }, { 0xC0000008, "STATUS_INVALID_HANDLE" }, { 0xC0000009, "STATUS_BAD_INITIAL_STACK" }, { 0xC000000A, "STATUS_BAD_INITIAL_PC" }, { 0xC000000B, "STATUS_INVALID_CID" }, { 0xC000000C, "STATUS_TIMER_NOT_CANCELED" }, { 0xC000000D, "STATUS_INVALID_PARAMETER" }, { 0xC000000E, "STATUS_NO_SUCH_DEVICE" }, { 0xC000000F, "STATUS_NO_SUCH_FILE" }, { 0xC0000010, "STATUS_INVALID_DEVICE_REQUEST" }, { 0xC0000011, "STATUS_END_OF_FILE" }, { 0xC0000012, "STATUS_WRONG_VOLUME" }, { 0xC0000013, "STATUS_NO_MEDIA_IN_DEVICE" }, { 0xC0000014, "STATUS_UNRECOGNIZED_MEDIA" }, { 0xC0000015, "STATUS_NONEXISTENT_SECTOR" }, { 0xC0000016, "STATUS_MORE_PROCESSING_REQUIRED" }, { 0xC0000017, "STATUS_NO_MEMORY" }, { 0xC0000018, "STATUS_CONFLICTING_ADDRESSES" }, { 0xC0000019, "STATUS_NOT_MAPPED_VIEW" }, { 0xC000001A, "STATUS_UNABLE_TO_FREE_VM" }, { 0xC000001B, "STATUS_UNABLE_TO_DELETE_SECTION" }, { 0xC000001C, "STATUS_INVALID_SYSTEM_SERVICE" }, { 0xC000001D, "STATUS_ILLEGAL_INSTRUCTION" }, { 0xC000001E, "STATUS_INVALID_LOCK_SEQUENCE" }, { 0xC000001F, "STATUS_INVALID_VIEW_SIZE" }, { 0xC0000020, "STATUS_INVALID_FILE_FOR_SECTION" }, { 0xC0000021, "STATUS_ALREADY_COMMITTED" }, { 0xC0000022, "STATUS_ACCESS_DENIED" }, { 0xC0000023, "STATUS_BUFFER_TOO_SMALL" }, { 0xC0000024, "STATUS_OBJECT_TYPE_MISMATCH" }, { 0xC0000025, "STATUS_NONCONTINUABLE_EXCEPTION" }, { 0xC0000026, "STATUS_INVALID_DISPOSITION" }, { 0xC0000027, "STATUS_UNWIND" }, { 0xC0000028, "STATUS_BAD_STACK" }, { 0xC0000029, "STATUS_INVALID_UNWIND_TARGET" }, { 0xC000002A, "STATUS_NOT_LOCKED" }, { 0xC000002B, "STATUS_PARITY_ERROR" }, { 0xC000002C, "STATUS_UNABLE_TO_DECOMMIT_VM" }, { 0xC000002D, "STATUS_NOT_COMMITTED" }, { 0xC000002E, "STATUS_INVALID_PORT_ATTRIBUTES" }, { 0xC000002F, "STATUS_PORT_MESSAGE_TOO_LONG" }, { 0xC0000030, "STATUS_INVALID_PARAMETER_MIX" }, { 0xC0000031, "STATUS_INVALID_QUOTA_LOWER" }, { 0xC0000032, "STATUS_DISK_CORRUPT_ERROR" }, { 0xC0000033, "STATUS_OBJECT_NAME_INVALID" }, { 0xC0000034, "STATUS_OBJECT_NAME_NOT_FOUND" }, { 0xC0000035, "STATUS_OBJECT_NAME_COLLISION" }, { 0xC0000037, "STATUS_PORT_DISCONNECTED" }, { 0xC0000038, "STATUS_DEVICE_ALREADY_ATTACHED" }, { 0xC0000039, "STATUS_OBJECT_PATH_INVALID" }, { 0xC000003A, "STATUS_OBJECT_PATH_NOT_FOUND" }, { 0xC000003B, "STATUS_OBJECT_PATH_SYNTAX_BAD" }, { 0xC000003C, "STATUS_DATA_OVERRUN" }, { 0xC000003D, "STATUS_DATA_LATE_ERROR" }, { 0xC000003E, "STATUS_DATA_ERROR" }, { 0xC000003F, "STATUS_CRC_ERROR" }, { 0xC0000040, "STATUS_SECTION_TOO_BIG" }, { 0xC0000041, "STATUS_PORT_CONNECTION_REFUSED" }, { 0xC0000042, "STATUS_INVALID_PORT_HANDLE" }, { 0xC0000043, "STATUS_SHARING_VIOLATION" }, { 0xC0000044, "STATUS_QUOTA_EXCEEDED" }, { 0xC0000045, "STATUS_INVALID_PAGE_PROTECTION" }, { 0xC0000046, "STATUS_MUTANT_NOT_OWNED" }, { 0xC0000047, "STATUS_SEMAPHORE_LIMIT_EXCEEDED" }, { 0xC0000048, "STATUS_PORT_ALREADY_SET" }, { 0xC0000049, "STATUS_SECTION_NOT_IMAGE" }, { 0xC000004A, "STATUS_SUSPEND_COUNT_EXCEEDED" }, { 0xC000004B, "STATUS_THREAD_IS_TERMINATING" }, { 0xC000004C, "STATUS_BAD_WORKING_SET_LIMIT" }, { 0xC000004D, "STATUS_INCOMPATIBLE_FILE_MAP" }, { 0xC000004E, "STATUS_SECTION_PROTECTION" }, { 0xC000004F, "STATUS_EAS_NOT_SUPPORTED" }, { 0xC0000050, "STATUS_EA_TOO_LARGE" }, { 0xC0000051, "STATUS_NONEXISTENT_EA_ENTRY" }, { 0xC0000052, "STATUS_NO_EAS_ON_FILE" }, { 0xC0000053, "STATUS_EA_CORRUPT_ERROR" }, { 0xC0000054, "STATUS_FILE_LOCK_CONFLICT" }, { 0xC0000055, "STATUS_LOCK_NOT_GRANTED" }, { 0xC0000056, "STATUS_DELETE_PENDING" }, { 0xC0000057, "STATUS_CTL_FILE_NOT_SUPPORTED" }, { 0xC0000058, "STATUS_UNKNOWN_REVISION" }, { 0xC0000059, "STATUS_REVISION_MISMATCH" }, { 0xC000005A, "STATUS_INVALID_OWNER" }, { 0xC000005B, "STATUS_INVALID_PRIMARY_GROUP" }, { 0xC000005C, "STATUS_NO_IMPERSONATION_TOKEN" }, { 0xC000005D, "STATUS_CANT_DISABLE_MANDATORY" }, { 0xC000005E, "STATUS_NO_LOGON_SERVERS" }, { 0xC000005F, "STATUS_NO_SUCH_LOGON_SESSION" }, { 0xC0000060, "STATUS_NO_SUCH_PRIVILEGE" }, { 0xC0000061, "STATUS_PRIVILEGE_NOT_HELD" }, { 0xC0000062, "STATUS_INVALID_ACCOUNT_NAME" }, { 0xC0000063, "STATUS_USER_EXISTS" }, { 0xC0000064, "STATUS_NO_SUCH_USER" }, { 0xC0000065, "STATUS_GROUP_EXISTS" }, { 0xC0000066, "STATUS_NO_SUCH_GROUP" }, { 0xC0000067, "STATUS_MEMBER_IN_GROUP" }, { 0xC0000068, "STATUS_MEMBER_NOT_IN_GROUP" }, { 0xC0000069, "STATUS_LAST_ADMIN" }, { 0xC000006A, "STATUS_WRONG_PASSWORD" }, { 0xC000006B, "STATUS_ILL_FORMED_PASSWORD" }, { 0xC000006C, "STATUS_PASSWORD_RESTRICTION" }, { 0xC000006D, "STATUS_LOGON_FAILURE" }, { 0xC000006E, "STATUS_ACCOUNT_RESTRICTION" }, { 0xC000006F, "STATUS_INVALID_LOGON_HOURS" }, { 0xC0000070, "STATUS_INVALID_WORKSTATION" }, { 0xC0000071, "STATUS_PASSWORD_EXPIRED" }, { 0xC0000072, "STATUS_ACCOUNT_DISABLED" }, { 0xC0000073, "STATUS_NONE_MAPPED" }, { 0xC0000074, "STATUS_TOO_MANY_LUIDS_REQUESTED" }, { 0xC0000075, "STATUS_LUIDS_EXHAUSTED" }, { 0xC0000076, "STATUS_INVALID_SUB_AUTHORITY" }, { 0xC0000077, "STATUS_INVALID_ACL" }, { 0xC0000078, "STATUS_INVALID_SID" }, { 0xC0000079, "STATUS_INVALID_SECURITY_DESCR" }, { 0xC000007A, "STATUS_PROCEDURE_NOT_FOUND" }, { 0xC000007B, "STATUS_INVALID_IMAGE_FORMAT" }, { 0xC000007C, "STATUS_NO_TOKEN" }, { 0xC000007D, "STATUS_BAD_INHERITANCE_ACL" }, { 0xC000007E, "STATUS_RANGE_NOT_LOCKED" }, { 0xC000007F, "STATUS_DISK_FULL" }, { 0xC0000080, "STATUS_SERVER_DISABLED" }, { 0xC0000081, "STATUS_SERVER_NOT_DISABLED" }, { 0xC0000082, "STATUS_TOO_MANY_GUIDS_REQUESTED" }, { 0xC0000083, "STATUS_GUIDS_EXHAUSTED" }, { 0xC0000084, "STATUS_INVALID_ID_AUTHORITY" }, { 0xC0000085, "STATUS_AGENTS_EXHAUSTED" }, { 0xC0000086, "STATUS_INVALID_VOLUME_LABEL" }, { 0xC0000087, "STATUS_SECTION_NOT_EXTENDED" }, { 0xC0000088, "STATUS_NOT_MAPPED_DATA" }, { 0xC0000089, "STATUS_RESOURCE_DATA_NOT_FOUND" }, { 0xC000008A, "STATUS_RESOURCE_TYPE_NOT_FOUND" }, { 0xC000008B, "STATUS_RESOURCE_NAME_NOT_FOUND" }, { 0xC000008C, "STATUS_ARRAY_BOUNDS_EXCEEDED" }, { 0xC000008D, "STATUS_FLOAT_DENORMAL_OPERAND" }, { 0xC000008E, "STATUS_FLOAT_DIVIDE_BY_ZERO" }, { 0xC000008F, "STATUS_FLOAT_INEXACT_RESULT" }, { 0xC0000090, "STATUS_FLOAT_INVALID_OPERATION" }, { 0xC0000091, "STATUS_FLOAT_OVERFLOW" }, { 0xC0000092, "STATUS_FLOAT_STACK_CHECK" }, { 0xC0000093, "STATUS_FLOAT_UNDERFLOW" }, { 0xC0000094, "STATUS_INTEGER_DIVIDE_BY_ZERO" }, { 0xC0000095, "STATUS_INTEGER_OVERFLOW" }, { 0xC0000096, "STATUS_PRIVILEGED_INSTRUCTION" }, { 0xC0000097, "STATUS_TOO_MANY_PAGING_FILES" }, { 0xC0000098, "STATUS_FILE_INVALID" }, { 0xC0000099, "STATUS_ALLOTTED_SPACE_EXCEEDED" }, { 0xC000009A, "STATUS_INSUFFICIENT_RESOURCES" }, { 0xC000009B, "STATUS_DFS_EXIT_PATH_FOUND" }, { 0xC000009C, "STATUS_DEVICE_DATA_ERROR" }, { 0xC000009D, "STATUS_DEVICE_NOT_CONNECTED" }, { 0xC000009E, "STATUS_DEVICE_POWER_FAILURE" }, { 0xC000009F, "STATUS_FREE_VM_NOT_AT_BASE" }, { 0xC00000A0, "STATUS_MEMORY_NOT_ALLOCATED" }, { 0xC00000A1, "STATUS_WORKING_SET_QUOTA" }, { 0xC00000A2, "STATUS_MEDIA_WRITE_PROTECTED" }, { 0xC00000A3, "STATUS_DEVICE_NOT_READY" }, { 0xC00000A4, "STATUS_INVALID_GROUP_ATTRIBUTES" }, { 0xC00000A5, "STATUS_BAD_IMPERSONATION_LEVEL" }, { 0xC00000A6, "STATUS_CANT_OPEN_ANONYMOUS" }, { 0xC00000A7, "STATUS_BAD_VALIDATION_CLASS" }, { 0xC00000A8, "STATUS_BAD_TOKEN_TYPE" }, { 0xC00000A9, "STATUS_BAD_MASTER_BOOT_RECORD" }, { 0xC00000AA, "STATUS_INSTRUCTION_MISALIGNMENT" }, { 0xC00000AB, "STATUS_INSTANCE_NOT_AVAILABLE" }, { 0xC00000AC, "STATUS_PIPE_NOT_AVAILABLE" }, { 0xC00000AD, "STATUS_INVALID_PIPE_STATE" }, { 0xC00000AE, "STATUS_PIPE_BUSY" }, { 0xC00000AF, "STATUS_ILLEGAL_FUNCTION" }, { 0xC00000B0, "STATUS_PIPE_DISCONNECTED" }, { 0xC00000B1, "STATUS_PIPE_CLOSING" }, { 0xC00000B2, "STATUS_PIPE_CONNECTED" }, { 0xC00000B3, "STATUS_PIPE_LISTENING" }, { 0xC00000B4, "STATUS_INVALID_READ_MODE" }, { 0xC00000B5, "STATUS_IO_TIMEOUT" }, { 0xC00000B6, "STATUS_FILE_FORCED_CLOSED" }, { 0xC00000B7, "STATUS_PROFILING_NOT_STARTED" }, { 0xC00000B8, "STATUS_PROFILING_NOT_STOPPED" }, { 0xC00000B9, "STATUS_COULD_NOT_INTERPRET" }, { 0xC00000BA, "STATUS_FILE_IS_A_DIRECTORY" }, { 0xC00000BB, "STATUS_NOT_SUPPORTED" }, { 0xC00000BC, "STATUS_REMOTE_NOT_LISTENING" }, { 0xC00000BD, "STATUS_DUPLICATE_NAME" }, { 0xC00000BE, "STATUS_BAD_NETWORK_PATH" }, { 0xC00000BF, "STATUS_NETWORK_BUSY" }, { 0xC00000C0, "STATUS_DEVICE_DOES_NOT_EXIST" }, { 0xC00000C1, "STATUS_TOO_MANY_COMMANDS" }, { 0xC00000C2, "STATUS_ADAPTER_HARDWARE_ERROR" }, { 0xC00000C3, "STATUS_INVALID_NETWORK_RESPONSE" }, { 0xC00000C4, "STATUS_UNEXPECTED_NETWORK_ERROR" }, { 0xC00000C5, "STATUS_BAD_REMOTE_ADAPTER" }, { 0xC00000C6, "STATUS_PRINT_QUEUE_FULL" }, { 0xC00000C7, "STATUS_NO_SPOOL_SPACE" }, { 0xC00000C8, "STATUS_PRINT_CANCELLED" }, { 0xC00000C9, "STATUS_NETWORK_NAME_DELETED" }, { 0xC00000CA, "STATUS_NETWORK_ACCESS_DENIED" }, { 0xC00000CB, "STATUS_BAD_DEVICE_TYPE" }, { 0xC00000CC, "STATUS_BAD_NETWORK_NAME" }, { 0xC00000CD, "STATUS_TOO_MANY_NAMES" }, { 0xC00000CE, "STATUS_TOO_MANY_SESSIONS" }, { 0xC00000CF, "STATUS_SHARING_PAUSED" }, { 0xC00000D0, "STATUS_REQUEST_NOT_ACCEPTED" }, { 0xC00000D1, "STATUS_REDIRECTOR_PAUSED" }, { 0xC00000D2, "STATUS_NET_WRITE_FAULT" }, { 0xC00000D3, "STATUS_PROFILING_AT_LIMIT" }, { 0xC00000D4, "STATUS_NOT_SAME_DEVICE" }, { 0xC00000D5, "STATUS_FILE_RENAMED" }, { 0xC00000D6, "STATUS_VIRTUAL_CIRCUIT_CLOSED" }, { 0xC00000D7, "STATUS_NO_SECURITY_ON_OBJECT" }, { 0xC00000D8, "STATUS_CANT_WAIT" }, { 0xC00000D9, "STATUS_PIPE_EMPTY" }, { 0xC00000DA, "STATUS_CANT_ACCESS_DOMAIN_INFO" }, { 0xC00000DB, "STATUS_CANT_TERMINATE_SELF" }, { 0xC00000DC, "STATUS_INVALID_SERVER_STATE" }, { 0xC00000DD, "STATUS_INVALID_DOMAIN_STATE" }, { 0xC00000DE, "STATUS_INVALID_DOMAIN_ROLE" }, { 0xC00000DF, "STATUS_NO_SUCH_DOMAIN" }, { 0xC00000E0, "STATUS_DOMAIN_EXISTS" }, { 0xC00000E1, "STATUS_DOMAIN_LIMIT_EXCEEDED" }, { 0xC00000E2, "STATUS_OPLOCK_NOT_GRANTED" }, { 0xC00000E3, "STATUS_INVALID_OPLOCK_PROTOCOL" }, { 0xC00000E4, "STATUS_INTERNAL_DB_CORRUPTION" }, { 0xC00000E5, "STATUS_INTERNAL_ERROR" }, { 0xC00000E6, "STATUS_GENERIC_NOT_MAPPED" }, { 0xC00000E7, "STATUS_BAD_DESCRIPTOR_FORMAT" }, { 0xC00000E8, "STATUS_INVALID_USER_BUFFER" }, { 0xC00000E9, "STATUS_UNEXPECTED_IO_ERROR" }, { 0xC00000EA, "STATUS_UNEXPECTED_MM_CREATE_ERR" }, { 0xC00000EB, "STATUS_UNEXPECTED_MM_MAP_ERROR" }, { 0xC00000EC, "STATUS_UNEXPECTED_MM_EXTEND_ERR" }, { 0xC00000ED, "STATUS_NOT_LOGON_PROCESS" }, { 0xC00000EE, "STATUS_LOGON_SESSION_EXISTS" }, { 0xC00000EF, "STATUS_INVALID_PARAMETER_1" }, { 0xC00000F0, "STATUS_INVALID_PARAMETER_2" }, { 0xC00000F1, "STATUS_INVALID_PARAMETER_3" }, { 0xC00000F2, "STATUS_INVALID_PARAMETER_4" }, { 0xC00000F3, "STATUS_INVALID_PARAMETER_5" }, { 0xC00000F4, "STATUS_INVALID_PARAMETER_6" }, { 0xC00000F5, "STATUS_INVALID_PARAMETER_7" }, { 0xC00000F6, "STATUS_INVALID_PARAMETER_8" }, { 0xC00000F7, "STATUS_INVALID_PARAMETER_9" }, { 0xC00000F8, "STATUS_INVALID_PARAMETER_10" }, { 0xC00000F9, "STATUS_INVALID_PARAMETER_11" }, { 0xC00000FA, "STATUS_INVALID_PARAMETER_12" }, { 0xC00000FB, "STATUS_REDIRECTOR_NOT_STARTED" }, { 0xC00000FC, "STATUS_REDIRECTOR_STARTED" }, { 0xC00000FD, "STATUS_STACK_OVERFLOW" }, { 0xC00000FE, "STATUS_NO_SUCH_PACKAGE" }, { 0xC00000FF, "STATUS_BAD_FUNCTION_TABLE" }, { 0xC0000100, "STATUS_VARIABLE_NOT_FOUND" }, { 0xC0000101, "STATUS_DIRECTORY_NOT_EMPTY" }, { 0xC0000102, "STATUS_FILE_CORRUPT_ERROR" }, { 0xC0000103, "STATUS_NOT_A_DIRECTORY" }, { 0xC0000104, "STATUS_BAD_LOGON_SESSION_STATE" }, { 0xC0000105, "STATUS_LOGON_SESSION_COLLISION" }, { 0xC0000106, "STATUS_NAME_TOO_LONG" }, { 0xC0000107, "STATUS_FILES_OPEN" }, { 0xC0000108, "STATUS_CONNECTION_IN_USE" }, { 0xC0000109, "STATUS_MESSAGE_NOT_FOUND" }, { 0xC000010A, "STATUS_PROCESS_IS_TERMINATING" }, { 0xC000010B, "STATUS_INVALID_LOGON_TYPE" }, { 0xC000010C, "STATUS_NO_GUID_TRANSLATION" }, { 0xC000010D, "STATUS_CANNOT_IMPERSONATE" }, { 0xC000010E, "STATUS_IMAGE_ALREADY_LOADED" }, { 0xC000010F, "STATUS_ABIOS_NOT_PRESENT" }, { 0xC0000110, "STATUS_ABIOS_LID_NOT_EXIST" }, { 0xC0000111, "STATUS_ABIOS_LID_ALREADY_OWNED" }, { 0xC0000112, "STATUS_ABIOS_NOT_LID_OWNER" }, { 0xC0000113, "STATUS_ABIOS_INVALID_COMMAND" }, { 0xC0000114, "STATUS_ABIOS_INVALID_LID" }, { 0xC0000115, "STATUS_ABIOS_SELECTOR_NOT_AVAILABLE" }, { 0xC0000116, "STATUS_ABIOS_INVALID_SELECTOR" }, { 0xC0000117, "STATUS_NO_LDT" }, { 0xC0000118, "STATUS_INVALID_LDT_SIZE" }, { 0xC0000119, "STATUS_INVALID_LDT_OFFSET" }, { 0xC000011A, "STATUS_INVALID_LDT_DESCRIPTOR" }, { 0xC000011B, "STATUS_INVALID_IMAGE_NE_FORMAT" }, { 0xC000011C, "STATUS_RXACT_INVALID_STATE" }, { 0xC000011D, "STATUS_RXACT_COMMIT_FAILURE" }, { 0xC000011E, "STATUS_MAPPED_FILE_SIZE_ZERO" }, { 0xC000011F, "STATUS_TOO_MANY_OPENED_FILES" }, { 0xC0000120, "STATUS_CANCELLED" }, { 0xC0000121, "STATUS_CANNOT_DELETE" }, { 0xC0000122, "STATUS_INVALID_COMPUTER_NAME" }, { 0xC0000123, "STATUS_FILE_DELETED" }, { 0xC0000124, "STATUS_SPECIAL_ACCOUNT" }, { 0xC0000125, "STATUS_SPECIAL_GROUP" }, { 0xC0000126, "STATUS_SPECIAL_USER" }, { 0xC0000127, "STATUS_MEMBERS_PRIMARY_GROUP" }, { 0xC0000128, "STATUS_FILE_CLOSED" }, { 0xC0000129, "STATUS_TOO_MANY_THREADS" }, { 0xC000012A, "STATUS_THREAD_NOT_IN_PROCESS" }, { 0xC000012B, "STATUS_TOKEN_ALREADY_IN_USE" }, { 0xC000012C, "STATUS_PAGEFILE_QUOTA_EXCEEDED" }, { 0xC000012D, "STATUS_COMMITMENT_LIMIT" }, { 0xC000012E, "STATUS_INVALID_IMAGE_LE_FORMAT" }, { 0xC000012F, "STATUS_INVALID_IMAGE_NOT_MZ" }, { 0xC0000130, "STATUS_INVALID_IMAGE_PROTECT" }, { 0xC0000131, "STATUS_INVALID_IMAGE_WIN_16" }, { 0xC0000132, "STATUS_LOGON_SERVER_CONFLICT" }, { 0xC0000133, "STATUS_TIME_DIFFERENCE_AT_DC" }, { 0xC0000134, "STATUS_SYNCHRONIZATION_REQUIRED" }, { 0xC0000135, "STATUS_DLL_NOT_FOUND" }, { 0xC0000136, "STATUS_OPEN_FAILED" }, { 0xC0000137, "STATUS_IO_PRIVILEGE_FAILED" }, { 0xC0000138, "STATUS_ORDINAL_NOT_FOUND" }, { 0xC0000139, "STATUS_ENTRYPOINT_NOT_FOUND" }, { 0xC000013A, "STATUS_CONTROL_C_EXIT" }, { 0xC000013B, "STATUS_LOCAL_DISCONNECT" }, { 0xC000013C, "STATUS_REMOTE_DISCONNECT" }, { 0xC000013D, "STATUS_REMOTE_RESOURCES" }, { 0xC000013E, "STATUS_LINK_FAILED" }, { 0xC000013F, "STATUS_LINK_TIMEOUT" }, { 0xC0000140, "STATUS_INVALID_CONNECTION" }, { 0xC0000141, "STATUS_INVALID_ADDRESS" }, { 0xC0000142, "STATUS_DLL_INIT_FAILED" }, { 0xC0000143, "STATUS_MISSING_SYSTEMFILE" }, { 0xC0000144, "STATUS_UNHANDLED_EXCEPTION" }, { 0xC0000145, "STATUS_APP_INIT_FAILURE" }, { 0xC0000146, "STATUS_PAGEFILE_CREATE_FAILED" }, { 0xC0000147, "STATUS_NO_PAGEFILE" }, { 0xC0000148, "STATUS_INVALID_LEVEL" }, { 0xC0000149, "STATUS_WRONG_PASSWORD_CORE" }, { 0xC000014A, "STATUS_ILLEGAL_FLOAT_CONTEXT" }, { 0xC000014B, "STATUS_PIPE_BROKEN" }, { 0xC000014C, "STATUS_REGISTRY_CORRUPT" }, { 0xC000014D, "STATUS_REGISTRY_IO_FAILED" }, { 0xC000014E, "STATUS_NO_EVENT_PAIR" }, { 0xC000014F, "STATUS_UNRECOGNIZED_VOLUME" }, { 0xC0000150, "STATUS_SERIAL_NO_DEVICE_INITED" }, { 0xC0000151, "STATUS_NO_SUCH_ALIAS" }, { 0xC0000152, "STATUS_MEMBER_NOT_IN_ALIAS" }, { 0xC0000153, "STATUS_MEMBER_IN_ALIAS" }, { 0xC0000154, "STATUS_ALIAS_EXISTS" }, { 0xC0000155, "STATUS_LOGON_NOT_GRANTED" }, { 0xC0000156, "STATUS_TOO_MANY_SECRETS" }, { 0xC0000157, "STATUS_SECRET_TOO_LONG" }, { 0xC0000158, "STATUS_INTERNAL_DB_ERROR" }, { 0xC0000159, "STATUS_FULLSCREEN_MODE" }, { 0xC000015A, "STATUS_TOO_MANY_CONTEXT_IDS" }, { 0xC000015B, "STATUS_LOGON_TYPE_NOT_GRANTED" }, { 0xC000015C, "STATUS_NOT_REGISTRY_FILE" }, { 0xC000015D, "STATUS_NT_CROSS_ENCRYPTION_REQUIRED" }, { 0xC000015E, "STATUS_DOMAIN_CTRLR_CONFIG_ERROR" }, { 0xC000015F, "STATUS_FT_MISSING_MEMBER" }, { 0xC0000160, "STATUS_ILL_FORMED_SERVICE_ENTRY" }, { 0xC0000161, "STATUS_ILLEGAL_CHARACTER" }, { 0xC0000162, "STATUS_UNMAPPABLE_CHARACTER" }, { 0xC0000163, "STATUS_UNDEFINED_CHARACTER" }, { 0xC0000164, "STATUS_FLOPPY_VOLUME" }, { 0xC0000165, "STATUS_FLOPPY_ID_MARK_NOT_FOUND" }, { 0xC0000166, "STATUS_FLOPPY_WRONG_CYLINDER" }, { 0xC0000167, "STATUS_FLOPPY_UNKNOWN_ERROR" }, { 0xC0000168, "STATUS_FLOPPY_BAD_REGISTERS" }, { 0xC0000169, "STATUS_DISK_RECALIBRATE_FAILED" }, { 0xC000016A, "STATUS_DISK_OPERATION_FAILED" }, { 0xC000016B, "STATUS_DISK_RESET_FAILED" }, { 0xC000016C, "STATUS_SHARED_IRQ_BUSY" }, { 0xC000016D, "STATUS_FT_ORPHANING" }, { 0xC000016E, "STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT" }, { 0xC0000172, "STATUS_PARTITION_FAILURE" }, { 0xC0000173, "STATUS_INVALID_BLOCK_LENGTH" }, { 0xC0000174, "STATUS_DEVICE_NOT_PARTITIONED" }, { 0xC0000175, "STATUS_UNABLE_TO_LOCK_MEDIA" }, { 0xC0000176, "STATUS_UNABLE_TO_UNLOAD_MEDIA" }, { 0xC0000177, "STATUS_EOM_OVERFLOW" }, { 0xC0000178, "STATUS_NO_MEDIA" }, { 0xC000017A, "STATUS_NO_SUCH_MEMBER" }, { 0xC000017B, "STATUS_INVALID_MEMBER" }, { 0xC000017C, "STATUS_KEY_DELETED" }, { 0xC000017D, "STATUS_NO_LOG_SPACE" }, { 0xC000017E, "STATUS_TOO_MANY_SIDS" }, { 0xC000017F, "STATUS_LM_CROSS_ENCRYPTION_REQUIRED" }, { 0xC0000180, "STATUS_KEY_HAS_CHILDREN" }, { 0xC0000181, "STATUS_CHILD_MUST_BE_VOLATILE" }, { 0xC0000182, "STATUS_DEVICE_CONFIGURATION_ERROR" }, { 0xC0000183, "STATUS_DRIVER_INTERNAL_ERROR" }, { 0xC0000184, "STATUS_INVALID_DEVICE_STATE" }, { 0xC0000185, "STATUS_IO_DEVICE_ERROR" }, { 0xC0000186, "STATUS_DEVICE_PROTOCOL_ERROR" }, { 0xC0000187, "STATUS_BACKUP_CONTROLLER" }, { 0xC0000188, "STATUS_LOG_FILE_FULL" }, { 0xC0000189, "STATUS_TOO_LATE" }, { 0xC000018A, "STATUS_NO_TRUST_LSA_SECRET" }, { 0xC000018B, "STATUS_NO_TRUST_SAM_ACCOUNT" }, { 0xC000018C, "STATUS_TRUSTED_DOMAIN_FAILURE" }, { 0xC000018D, "STATUS_TRUSTED_RELATIONSHIP_FAILURE" }, { 0xC000018E, "STATUS_EVENTLOG_FILE_CORRUPT" }, { 0xC000018F, "STATUS_EVENTLOG_CANT_START" }, { 0xC0000190, "STATUS_TRUST_FAILURE" }, { 0xC0000191, "STATUS_MUTANT_LIMIT_EXCEEDED" }, { 0xC0000192, "STATUS_NETLOGON_NOT_STARTED" }, { 0xC0000193, "STATUS_ACCOUNT_EXPIRED" }, { 0xC0000194, "STATUS_POSSIBLE_DEADLOCK" }, { 0xC0000195, "STATUS_NETWORK_CREDENTIAL_CONFLICT" }, { 0xC0000196, "STATUS_REMOTE_SESSION_LIMIT" }, { 0xC0000197, "STATUS_EVENTLOG_FILE_CHANGED" }, { 0xC0000198, "STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT" }, { 0xC0000199, "STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT" }, { 0xC000019A, "STATUS_NOLOGON_SERVER_TRUST_ACCOUNT" }, { 0xC000019B, "STATUS_DOMAIN_TRUST_INCONSISTENT" }, { 0xC000019C, "STATUS_FS_DRIVER_REQUIRED" }, { 0xC0000202, "STATUS_NO_USER_SESSION_KEY" }, { 0xC0000203, "STATUS_USER_SESSION_DELETED" }, { 0xC0000204, "STATUS_RESOURCE_LANG_NOT_FOUND" }, { 0xC0000205, "STATUS_INSUFF_SERVER_RESOURCES" }, { 0xC0000206, "STATUS_INVALID_BUFFER_SIZE" }, { 0xC0000207, "STATUS_INVALID_ADDRESS_COMPONENT" }, { 0xC0000208, "STATUS_INVALID_ADDRESS_WILDCARD" }, { 0xC0000209, "STATUS_TOO_MANY_ADDRESSES" }, { 0xC000020A, "STATUS_ADDRESS_ALREADY_EXISTS" }, { 0xC000020B, "STATUS_ADDRESS_CLOSED" }, { 0xC000020C, "STATUS_CONNECTION_DISCONNECTED" }, { 0xC000020D, "STATUS_CONNECTION_RESET" }, { 0xC000020E, "STATUS_TOO_MANY_NODES" }, { 0xC000020F, "STATUS_TRANSACTION_ABORTED" }, { 0xC0000210, "STATUS_TRANSACTION_TIMED_OUT" }, { 0xC0000211, "STATUS_TRANSACTION_NO_RELEASE" }, { 0xC0000212, "STATUS_TRANSACTION_NO_MATCH" }, { 0xC0000213, "STATUS_TRANSACTION_RESPONDED" }, { 0xC0000214, "STATUS_TRANSACTION_INVALID_ID" }, { 0xC0000215, "STATUS_TRANSACTION_INVALID_TYPE" }, { 0xC0000216, "STATUS_NOT_SERVER_SESSION" }, { 0xC0000217, "STATUS_NOT_CLIENT_SESSION" }, { 0xC0000218, "STATUS_CANNOT_LOAD_REGISTRY_FILE" }, { 0xC0000219, "STATUS_DEBUG_ATTACH_FAILED" }, { 0xC000021A, "STATUS_SYSTEM_PROCESS_TERMINATED" }, { 0xC000021B, "STATUS_DATA_NOT_ACCEPTED" }, { 0xC000021C, "STATUS_NO_BROWSER_SERVERS_FOUND" }, { 0xC000021D, "STATUS_VDM_HARD_ERROR" }, { 0xC000021E, "STATUS_DRIVER_CANCEL_TIMEOUT" }, { 0xC000021F, "STATUS_REPLY_MESSAGE_MISMATCH" }, { 0xC0000220, "STATUS_MAPPED_ALIGNMENT" }, { 0xC0000221, "STATUS_IMAGE_CHECKSUM_MISMATCH" }, { 0xC0000222, "STATUS_LOST_WRITEBEHIND_DATA" }, { 0xC0000223, "STATUS_CLIENT_SERVER_PARAMETERS_INVALID" }, { 0xC0000224, "STATUS_PASSWORD_MUST_CHANGE" }, { 0xC0000225, "STATUS_NOT_FOUND" }, { 0xC0000226, "STATUS_NOT_TINY_STREAM" }, { 0xC0000227, "STATUS_RECOVERY_FAILURE" }, { 0xC0000228, "STATUS_STACK_OVERFLOW_READ" }, { 0xC0000229, "STATUS_FAIL_CHECK" }, { 0xC000022A, "STATUS_DUPLICATE_OBJECTID" }, { 0xC000022B, "STATUS_OBJECTID_EXISTS" }, { 0xC000022C, "STATUS_CONVERT_TO_LARGE" }, { 0xC000022D, "STATUS_RETRY" }, { 0xC000022E, "STATUS_FOUND_OUT_OF_SCOPE" }, { 0xC000022F, "STATUS_ALLOCATE_BUCKET" }, { 0xC0000230, "STATUS_PROPSET_NOT_FOUND" }, { 0xC0000231, "STATUS_MARSHALL_OVERFLOW" }, { 0xC0000232, "STATUS_INVALID_VARIANT" }, { 0xC0000233, "STATUS_DOMAIN_CONTROLLER_NOT_FOUND" }, { 0xC0000234, "STATUS_ACCOUNT_LOCKED_OUT" }, { 0xC0000235, "STATUS_HANDLE_NOT_CLOSABLE" }, { 0xC0000236, "STATUS_CONNECTION_REFUSED" }, { 0xC0000237, "STATUS_GRACEFUL_DISCONNECT" }, { 0xC0000238, "STATUS_ADDRESS_ALREADY_ASSOCIATED" }, { 0xC0000239, "STATUS_ADDRESS_NOT_ASSOCIATED" }, { 0xC000023A, "STATUS_CONNECTION_INVALID" }, { 0xC000023B, "STATUS_CONNECTION_ACTIVE" }, { 0xC000023C, "STATUS_NETWORK_UNREACHABLE" }, { 0xC000023D, "STATUS_HOST_UNREACHABLE" }, { 0xC000023E, "STATUS_PROTOCOL_UNREACHABLE" }, { 0xC000023F, "STATUS_PORT_UNREACHABLE" }, { 0xC0000240, "STATUS_REQUEST_ABORTED" }, { 0xC0000241, "STATUS_CONNECTION_ABORTED" }, { 0xC0000242, "STATUS_BAD_COMPRESSION_BUFFER" }, { 0xC0000243, "STATUS_USER_MAPPED_FILE" }, { 0xC0000244, "STATUS_AUDIT_FAILED" }, { 0xC0000245, "STATUS_TIMER_RESOLUTION_NOT_SET" }, { 0xC0000246, "STATUS_CONNECTION_COUNT_LIMIT" }, { 0xC0000247, "STATUS_LOGIN_TIME_RESTRICTION" }, { 0xC0000248, "STATUS_LOGIN_WKSTA_RESTRICTION" }, { 0xC0000249, "STATUS_IMAGE_MP_UP_MISMATCH" }, { 0xC0000250, "STATUS_INSUFFICIENT_LOGON_INFO" }, { 0xC0000251, "STATUS_BAD_DLL_ENTRYPOINT" }, { 0xC0000252, "STATUS_BAD_SERVICE_ENTRYPOINT" }, { 0xC0000253, "STATUS_LPC_REPLY_LOST" }, { 0xC0000254, "STATUS_IP_ADDRESS_CONFLICT1" }, { 0xC0000255, "STATUS_IP_ADDRESS_CONFLICT2" }, { 0xC0000256, "STATUS_REGISTRY_QUOTA_LIMIT" }, { 0xC0000257, "STATUS_PATH_NOT_COVERED" }, { 0xC0000258, "STATUS_NO_CALLBACK_ACTIVE" }, { 0xC0000259, "STATUS_LICENSE_QUOTA_EXCEEDED" }, { 0xC000025A, "STATUS_PWD_TOO_SHORT" }, { 0xC000025B, "STATUS_PWD_TOO_RECENT" }, { 0xC000025C, "STATUS_PWD_HISTORY_CONFLICT" }, { 0xC000025E, "STATUS_PLUGPLAY_NO_DEVICE" }, { 0xC000025F, "STATUS_UNSUPPORTED_COMPRESSION" }, { 0xC0000260, "STATUS_INVALID_HW_PROFILE" }, { 0xC0000261, "STATUS_INVALID_PLUGPLAY_DEVICE_PATH" }, { 0xC0000262, "STATUS_DRIVER_ORDINAL_NOT_FOUND" }, { 0xC0000263, "STATUS_DRIVER_ENTRYPOINT_NOT_FOUND" }, { 0xC0000264, "STATUS_RESOURCE_NOT_OWNED" }, { 0xC0000265, "STATUS_TOO_MANY_LINKS" }, { 0xC0000266, "STATUS_QUOTA_LIST_INCONSISTENT" }, { 0xC0000267, "STATUS_FILE_IS_OFFLINE" }, { 0xC0000268, "STATUS_EVALUATION_EXPIRATION" }, { 0xC0000269, "STATUS_ILLEGAL_DLL_RELOCATION" }, { 0xC000026A, "STATUS_LICENSE_VIOLATION" }, { 0xC000026B, "STATUS_DLL_INIT_FAILED_LOGOFF" }, { 0xC000026C, "STATUS_DRIVER_UNABLE_TO_LOAD" }, { 0xC000026D, "STATUS_DFS_UNAVAILABLE" }, { 0xC000026E, "STATUS_VOLUME_DISMOUNTED" }, { 0xC000026F, "STATUS_WX86_INTERNAL_ERROR" }, { 0xC0000270, "STATUS_WX86_FLOAT_STACK_CHECK" }, { 0xC0000271, "STATUS_VALIDATE_CONTINUE" }, { 0xC0000272, "STATUS_NO_MATCH" }, { 0xC0000273, "STATUS_NO_MORE_MATCHES" }, { 0xC0000275, "STATUS_NOT_A_REPARSE_POINT" }, { 0xC0000276, "STATUS_IO_REPARSE_TAG_INVALID" }, { 0xC0000277, "STATUS_IO_REPARSE_TAG_MISMATCH" }, { 0xC0000278, "STATUS_IO_REPARSE_DATA_INVALID" }, { 0xC0000279, "STATUS_IO_REPARSE_TAG_NOT_HANDLED" }, { 0xC0000280, "STATUS_REPARSE_POINT_NOT_RESOLVED" }, { 0xC0000281, "STATUS_DIRECTORY_IS_A_REPARSE_POINT" }, { 0xC0000282, "STATUS_RANGE_LIST_CONFLICT" }, { 0xC0000283, "STATUS_SOURCE_ELEMENT_EMPTY" }, { 0xC0000284, "STATUS_DESTINATION_ELEMENT_FULL" }, { 0xC0000285, "STATUS_ILLEGAL_ELEMENT_ADDRESS" }, { 0xC0000286, "STATUS_MAGAZINE_NOT_PRESENT" }, { 0xC0000287, "STATUS_REINITIALIZATION_NEEDED" }, { 0x80000288, "STATUS_DEVICE_REQUIRES_CLEANING" }, { 0x80000289, "STATUS_DEVICE_DOOR_OPEN" }, { 0xC000028A, "STATUS_ENCRYPTION_FAILED" }, { 0xC000028B, "STATUS_DECRYPTION_FAILED" }, { 0xC000028C, "STATUS_RANGE_NOT_FOUND" }, { 0xC000028D, "STATUS_NO_RECOVERY_POLICY" }, { 0xC000028E, "STATUS_NO_EFS" }, { 0xC000028F, "STATUS_WRONG_EFS" }, { 0xC0000290, "STATUS_NO_USER_KEYS" }, { 0xC0000291, "STATUS_FILE_NOT_ENCRYPTED" }, { 0xC0000292, "STATUS_NOT_EXPORT_FORMAT" }, { 0xC0000293, "STATUS_FILE_ENCRYPTED" }, { 0x40000294, "STATUS_WAKE_SYSTEM" }, { 0xC0000295, "STATUS_WMI_GUID_NOT_FOUND" }, { 0xC0000296, "STATUS_WMI_INSTANCE_NOT_FOUND" }, { 0xC0000297, "STATUS_WMI_ITEMID_NOT_FOUND" }, { 0xC0000298, "STATUS_WMI_TRY_AGAIN" }, { 0xC0000299, "STATUS_SHARED_POLICY" }, { 0xC000029A, "STATUS_POLICY_OBJECT_NOT_FOUND" }, { 0xC000029B, "STATUS_POLICY_ONLY_IN_DS" }, { 0xC000029C, "STATUS_VOLUME_NOT_UPGRADED" }, { 0xC000029D, "STATUS_REMOTE_STORAGE_NOT_ACTIVE" }, { 0xC000029E, "STATUS_REMOTE_STORAGE_MEDIA_ERROR" }, { 0xC000029F, "STATUS_NO_TRACKING_SERVICE" }, { 0xC00002A0, "STATUS_SERVER_SID_MISMATCH" }, { 0xC00002A1, "STATUS_DS_NO_ATTRIBUTE_OR_VALUE" }, { 0xC00002A2, "STATUS_DS_INVALID_ATTRIBUTE_SYNTAX" }, { 0xC00002A3, "STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED" }, { 0xC00002A4, "STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS" }, { 0xC00002A5, "STATUS_DS_BUSY" }, { 0xC00002A6, "STATUS_DS_UNAVAILABLE" }, { 0xC00002A7, "STATUS_DS_NO_RIDS_ALLOCATED" }, { 0xC00002A8, "STATUS_DS_NO_MORE_RIDS" }, { 0xC00002A9, "STATUS_DS_INCORRECT_ROLE_OWNER" }, { 0xC00002AA, "STATUS_DS_RIDMGR_INIT_ERROR" }, { 0xC00002AB, "STATUS_DS_OBJ_CLASS_VIOLATION" }, { 0xC00002AC, "STATUS_DS_CANT_ON_NON_LEAF" }, { 0xC00002AD, "STATUS_DS_CANT_ON_RDN" }, { 0xC00002AE, "STATUS_DS_CANT_MOD_OBJ_CLASS" }, { 0xC00002AF, "STATUS_DS_CROSS_DOM_MOVE_FAILED" }, { 0xC00002B0, "STATUS_DS_GC_NOT_AVAILABLE" }, { 0xC00002B1, "STATUS_DIRECTORY_SERVICE_REQUIRED" }, { 0xC00002B2, "STATUS_REPARSE_ATTRIBUTE_CONFLICT" }, { 0xC00002B3, "STATUS_CANT_ENABLE_DENY_ONLY" }, { 0xC00002B4, "STATUS_FLOAT_MULTIPLE_FAULTS" }, { 0xC00002B5, "STATUS_FLOAT_MULTIPLE_TRAPS" }, { 0xC00002B6, "STATUS_DEVICE_REMOVED" }, { 0xC00002B7, "STATUS_JOURNAL_DELETE_IN_PROGRESS" }, { 0xC00002B8, "STATUS_JOURNAL_NOT_ACTIVE" }, { 0xC00002B9, "STATUS_NOINTERFACE" }, { 0xC00002C1, "STATUS_DS_ADMIN_LIMIT_EXCEEDED" }, { 0xC00002C2, "STATUS_DRIVER_FAILED_SLEEP" }, { 0xC00002C3, "STATUS_MUTUAL_AUTHENTICATION_FAILED" }, { 0xC00002C4, "STATUS_CORRUPT_SYSTEM_FILE" }, { 0xC00002C5, "STATUS_DATATYPE_MISALIGNMENT_ERROR" }, { 0xC00002C6, "STATUS_WMI_READ_ONLY" }, { 0xC00002C7, "STATUS_WMI_SET_FAILURE" }, { 0xC00002C8, "STATUS_COMMITMENT_MINIMUM" }, { 0xC00002C9, "STATUS_REG_NAT_CONSUMPTION" }, { 0xC00002CA, "STATUS_TRANSPORT_FULL" }, { 0xC00002CB, "STATUS_DS_SAM_INIT_FAILURE" }, { 0xC00002CC, "STATUS_ONLY_IF_CONNECTED" }, { 0xC00002CD, "STATUS_DS_SENSITIVE_GROUP_VIOLATION" }, { 0xC00002CE, "STATUS_PNP_RESTART_ENUMERATION" }, { 0xC00002CF, "STATUS_JOURNAL_ENTRY_DELETED" }, { 0xC00002D0, "STATUS_DS_CANT_MOD_PRIMARYGROUPID" }, { 0xC00002D1, "STATUS_SYSTEM_IMAGE_BAD_SIGNATURE" }, { 0xC00002D2, "STATUS_PNP_REBOOT_REQUIRED" }, { 0xC00002D3, "STATUS_POWER_STATE_INVALID" }, { 0xC00002D4, "STATUS_DS_INVALID_GROUP_TYPE" }, { 0xC00002D5, "STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN" }, { 0xC00002D6, "STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN" }, { 0xC00002D7, "STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER" }, { 0xC00002D8, "STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER" }, { 0xC00002D9, "STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER" }, { 0xC00002DA, "STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER" }, { 0xC00002DB, "STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER" }, { 0xC00002DC, "STATUS_DS_HAVE_PRIMARY_MEMBERS" }, { 0xC00002DD, "STATUS_WMI_NOT_SUPPORTED" }, { 0xC00002DE, "STATUS_INSUFFICIENT_POWER" }, { 0xC00002DF, "STATUS_SAM_NEED_BOOTKEY_PASSWORD" }, { 0xC00002E0, "STATUS_SAM_NEED_BOOTKEY_FLOPPY" }, { 0xC00002E1, "STATUS_DS_CANT_START" }, { 0xC00002E2, "STATUS_DS_INIT_FAILURE" }, { 0xC00002E3, "STATUS_SAM_INIT_FAILURE" }, { 0xC00002E4, "STATUS_DS_GC_REQUIRED" }, { 0xC00002E5, "STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY" }, { 0xC00002E6, "STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS" }, { 0xC00002E7, "STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED" }, { 0xC00002E8, "STATUS_MULTIPLE_FAULT_VIOLATION" }, { 0xC0000300, "STATUS_NOT_SUPPORTED_ON_SBS" }, { 0xC0009898, "STATUS_WOW_ASSERTION" }, { 0xC0020001, "RPC_NT_INVALID_STRING_BINDING" }, { 0xC0020002, "RPC_NT_WRONG_KIND_OF_BINDING" }, { 0xC0020003, "RPC_NT_INVALID_BINDING" }, { 0xC0020004, "RPC_NT_PROTSEQ_NOT_SUPPORTED" }, { 0xC0020005, "RPC_NT_INVALID_RPC_PROTSEQ" }, { 0xC0020006, "RPC_NT_INVALID_STRING_UUID" }, { 0xC0020007, "RPC_NT_INVALID_ENDPOINT_FORMAT" }, { 0xC0020008, "RPC_NT_INVALID_NET_ADDR" }, { 0xC0020009, "RPC_NT_NO_ENDPOINT_FOUND" }, { 0xC002000A, "RPC_NT_INVALID_TIMEOUT" }, { 0xC002000B, "RPC_NT_OBJECT_NOT_FOUND" }, { 0xC002000C, "RPC_NT_ALREADY_REGISTERED" }, { 0xC002000D, "RPC_NT_TYPE_ALREADY_REGISTERED" }, { 0xC002000E, "RPC_NT_ALREADY_LISTENING" }, { 0xC002000F, "RPC_NT_NO_PROTSEQS_REGISTERED" }, { 0xC0020010, "RPC_NT_NOT_LISTENING" }, { 0xC0020011, "RPC_NT_UNKNOWN_MGR_TYPE" }, { 0xC0020012, "RPC_NT_UNKNOWN_IF" }, { 0xC0020013, "RPC_NT_NO_BINDINGS" }, { 0xC0020014, "RPC_NT_NO_PROTSEQS" }, { 0xC0020015, "RPC_NT_CANT_CREATE_ENDPOINT" }, { 0xC0020016, "RPC_NT_OUT_OF_RESOURCES" }, { 0xC0020017, "RPC_NT_SERVER_UNAVAILABLE" }, { 0xC0020018, "RPC_NT_SERVER_TOO_BUSY" }, { 0xC0020019, "RPC_NT_INVALID_NETWORK_OPTIONS" }, { 0xC002001A, "RPC_NT_NO_CALL_ACTIVE" }, { 0xC002001B, "RPC_NT_CALL_FAILED" }, { 0xC002001C, "RPC_NT_CALL_FAILED_DNE" }, { 0xC002001D, "RPC_NT_PROTOCOL_ERROR" }, { 0xC002001F, "RPC_NT_UNSUPPORTED_TRANS_SYN" }, { 0xC0020021, "RPC_NT_UNSUPPORTED_TYPE" }, { 0xC0020022, "RPC_NT_INVALID_TAG" }, { 0xC0020023, "RPC_NT_INVALID_BOUND" }, { 0xC0020024, "RPC_NT_NO_ENTRY_NAME" }, { 0xC0020025, "RPC_NT_INVALID_NAME_SYNTAX" }, { 0xC0020026, "RPC_NT_UNSUPPORTED_NAME_SYNTAX" }, { 0xC0020028, "RPC_NT_UUID_NO_ADDRESS" }, { 0xC0020029, "RPC_NT_DUPLICATE_ENDPOINT" }, { 0xC002002A, "RPC_NT_UNKNOWN_AUTHN_TYPE" }, { 0xC002002B, "RPC_NT_MAX_CALLS_TOO_SMALL" }, { 0xC002002C, "RPC_NT_STRING_TOO_LONG" }, { 0xC002002D, "RPC_NT_PROTSEQ_NOT_FOUND" }, { 0xC002002E, "RPC_NT_PROCNUM_OUT_OF_RANGE" }, { 0xC002002F, "RPC_NT_BINDING_HAS_NO_AUTH" }, { 0xC0020030, "RPC_NT_UNKNOWN_AUTHN_SERVICE" }, { 0xC0020031, "RPC_NT_UNKNOWN_AUTHN_LEVEL" }, { 0xC0020032, "RPC_NT_INVALID_AUTH_IDENTITY" }, { 0xC0020033, "RPC_NT_UNKNOWN_AUTHZ_SERVICE" }, { 0xC0020034, "EPT_NT_INVALID_ENTRY" }, { 0xC0020035, "EPT_NT_CANT_PERFORM_OP" }, { 0xC0020036, "EPT_NT_NOT_REGISTERED" }, { 0xC0020037, "RPC_NT_NOTHING_TO_EXPORT" }, { 0xC0020038, "RPC_NT_INCOMPLETE_NAME" }, { 0xC0020039, "RPC_NT_INVALID_VERS_OPTION" }, { 0xC002003A, "RPC_NT_NO_MORE_MEMBERS" }, { 0xC002003B, "RPC_NT_NOT_ALL_OBJS_UNEXPORTED" }, { 0xC002003C, "RPC_NT_INTERFACE_NOT_FOUND" }, { 0xC002003D, "RPC_NT_ENTRY_ALREADY_EXISTS" }, { 0xC002003E, "RPC_NT_ENTRY_NOT_FOUND" }, { 0xC002003F, "RPC_NT_NAME_SERVICE_UNAVAILABLE" }, { 0xC0020040, "RPC_NT_INVALID_NAF_ID" }, { 0xC0020041, "RPC_NT_CANNOT_SUPPORT" }, { 0xC0020042, "RPC_NT_NO_CONTEXT_AVAILABLE" }, { 0xC0020043, "RPC_NT_INTERNAL_ERROR" }, { 0xC0020044, "RPC_NT_ZERO_DIVIDE" }, { 0xC0020045, "RPC_NT_ADDRESS_ERROR" }, { 0xC0020046, "RPC_NT_FP_DIV_ZERO" }, { 0xC0020047, "RPC_NT_FP_UNDERFLOW" }, { 0xC0020048, "RPC_NT_FP_OVERFLOW" }, { 0xC0021007, "RPC_P_RECEIVE_ALERTED" }, { 0xC0021008, "RPC_P_CONNECTION_CLOSED" }, { 0xC0021009, "RPC_P_RECEIVE_FAILED" }, { 0xC002100A, "RPC_P_SEND_FAILED" }, { 0xC002100B, "RPC_P_TIMEOUT" }, { 0xC002100C, "RPC_P_SERVER_TRANSPORT_ERROR" }, { 0xC002100E, "RPC_P_EXCEPTION_OCCURED" }, { 0xC0021012, "RPC_P_CONNECTION_SHUTDOWN" }, { 0xC0021015, "RPC_P_THREAD_LISTENING" }, { 0xC0030001, "RPC_NT_NO_MORE_ENTRIES" }, { 0xC0030002, "RPC_NT_SS_CHAR_TRANS_OPEN_FAIL" }, { 0xC0030003, "RPC_NT_SS_CHAR_TRANS_SHORT_FILE" }, { 0xC0030004, "RPC_NT_SS_IN_NULL_CONTEXT" }, { 0xC0030005, "RPC_NT_SS_CONTEXT_MISMATCH" }, { 0xC0030006, "RPC_NT_SS_CONTEXT_DAMAGED" }, { 0xC0030007, "RPC_NT_SS_HANDLES_MISMATCH" }, { 0xC0030008, "RPC_NT_SS_CANNOT_GET_CALL_HANDLE" }, { 0xC0030009, "RPC_NT_NULL_REF_POINTER" }, { 0xC003000A, "RPC_NT_ENUM_VALUE_OUT_OF_RANGE" }, { 0xC003000B, "RPC_NT_BYTE_COUNT_TOO_SMALL" }, { 0xC003000C, "RPC_NT_BAD_STUB_DATA" }, { 0xC0020049, "RPC_NT_CALL_IN_PROGRESS" }, { 0xC002004A, "RPC_NT_NO_MORE_BINDINGS" }, { 0xC002004B, "RPC_NT_GROUP_MEMBER_NOT_FOUND" }, { 0xC002004C, "EPT_NT_CANT_CREATE" }, { 0xC002004D, "RPC_NT_INVALID_OBJECT" }, { 0xC002004F, "RPC_NT_NO_INTERFACES" }, { 0xC0020050, "RPC_NT_CALL_CANCELLED" }, { 0xC0020051, "RPC_NT_BINDING_INCOMPLETE" }, { 0xC0020052, "RPC_NT_COMM_FAILURE" }, { 0xC0020053, "RPC_NT_UNSUPPORTED_AUTHN_LEVEL" }, { 0xC0020054, "RPC_NT_NO_PRINC_NAME" }, { 0xC0020055, "RPC_NT_NOT_RPC_ERROR" }, { 0x40020056, "RPC_NT_UUID_LOCAL_ONLY" }, { 0xC0020057, "RPC_NT_SEC_PKG_ERROR" }, { 0xC0020058, "RPC_NT_NOT_CANCELLED" }, { 0xC0030059, "RPC_NT_INVALID_ES_ACTION" }, { 0xC003005A, "RPC_NT_WRONG_ES_VERSION" }, { 0xC003005B, "RPC_NT_WRONG_STUB_VERSION" }, { 0xC003005C, "RPC_NT_INVALID_PIPE_OBJECT" }, { 0xC003005D, "RPC_NT_INVALID_PIPE_OPERATION" }, { 0xC003005E, "RPC_NT_WRONG_PIPE_VERSION" }, { 0x400200AF, "RPC_NT_SEND_INCOMPLETE" }, { 0, NULL } }; /* * return an NT error string from a SMB buffer */ const char * nt_errstr(uint32_t err) { static char ret[128]; int i; ret[0] = 0; for (i = 0; nt_errors[i].name; i++) { if (err == nt_errors[i].code) return nt_errors[i].name; } snprintf(ret, sizeof(ret), "0x%08x", err); return ret; } Index: vendor/tcpdump/dist/tcpdump.1.in =================================================================== --- vendor/tcpdump/dist/tcpdump.1.in (revision 353143) +++ vendor/tcpdump/dist/tcpdump.1.in (revision 353144) @@ -1,1966 +1,1966 @@ .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $ .\" .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997 .\" The Regents of the University of California. All rights reserved. .\" 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. .\" .TH TCPDUMP 1 "2 February 2017" .SH NAME tcpdump \- dump traffic on a network .SH SYNOPSIS .na .B tcpdump [ .B \-AbdDefhHIJKlLnNOpqStuUvxX# ] [ .B \-B .I buffer_size ] .br .ti +8 [ .B \-c .I count ] .br .ti +8 [ .B \-C .I file_size ] [ .B \-G .I rotate_seconds ] [ .B \-F .I file ] .br .ti +8 [ .B \-i .I interface ] [ .B \-j .I tstamp_type ] [ .B \-m .I module ] [ .B \-M .I secret ] .br .ti +8 [ .B \-\-number ] [ .B \-Q .I in|out|inout ] .ti +8 [ .B \-r .I file ] [ .B \-V .I file ] [ .B \-s .I snaplen ] [ .B \-T .I type ] [ .B \-w .I file ] .br .ti +8 [ .B \-W .I filecount ] .br .ti +8 [ .B \-E .I spi@ipaddr algo:secret,... ] .br .ti +8 [ .B \-y .I datalinktype ] [ .B \-z .I postrotate-command ] [ .B \-Z .I user ] .ti +8 [ .BI \-\-time\-stamp\-precision= tstamp_precision ] .ti +8 [ .B \-\-immediate\-mode ] [ .B \-\-version ] .ti +8 [ .I expression ] .br .ad .SH DESCRIPTION .LP \fITcpdump\fP prints out a description of the contents of packets on a network interface that match the boolean \fIexpression\fP; the description is preceded by a time stamp, printed, by default, as hours, minutes, seconds, and fractions of a second since midnight. It can also be run with the .B \-w flag, which causes it to save the packet data to a file for later analysis, and/or with the .B \-r flag, which causes it to read from a saved packet file rather than to read packets from a network interface. It can also be run with the .B \-V flag, which causes it to read a list of saved packet files. In all cases, only packets that match .I expression will be processed by .IR tcpdump . .LP .I Tcpdump will, if not run with the .B \-c flag, continue capturing packets until it is interrupted by a SIGINT signal (generated, for example, by typing your interrupt character, typically control-C) or a SIGTERM signal (typically generated with the .BR kill (1) command); if run with the .B \-c flag, it will capture packets until it is interrupted by a SIGINT or SIGTERM signal or the specified number of packets have been processed. .LP When .I tcpdump finishes capturing packets, it will report counts of: .IP packets ``captured'' (this is the number of packets that .I tcpdump has received and processed); .IP packets ``received by filter'' (the meaning of this depends on the OS on which you're running .IR tcpdump , and possibly on the way the OS was configured - if a filter was specified on the command line, on some OSes it counts packets regardless of whether they were matched by the filter expression and, even if they were matched by the filter expression, regardless of whether .I tcpdump has read and processed them yet, on other OSes it counts only packets that were matched by the filter expression regardless of whether .I tcpdump has read and processed them yet, and on other OSes it counts only packets that were matched by the filter expression and were processed by .IR tcpdump ); .IP packets ``dropped by kernel'' (this is the number of packets that were dropped, due to a lack of buffer space, by the packet capture mechanism in the OS on which .I tcpdump is running, if the OS reports that information to applications; if not, it will be reported as 0). .LP On platforms that support the SIGINFO signal, such as most BSDs (including Mac OS X) and Digital/Tru64 UNIX, it will report those counts when it receives a SIGINFO signal (generated, for example, by typing your ``status'' character, typically control-T, although on some platforms, such as Mac OS X, the ``status'' character is not set by default, so you must set it with .BR stty (1) in order to use it) and will continue capturing packets. On platforms that do not support the SIGINFO signal, the same can be achieved by using the SIGUSR1 signal. .LP Reading packets from a network interface may require that you have special privileges; see the .B pcap (3PCAP) man page for details. Reading a saved packet file doesn't require special privileges. .SH OPTIONS .TP .B \-A Print each packet (minus its link level header) in ASCII. Handy for capturing web pages. .TP .B \-b Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN notation. .TP .BI \-B " buffer_size" .PD 0 .TP .BI \-\-buffer\-size= buffer_size .PD Set the operating system capture buffer size to \fIbuffer_size\fP, in units of KiB (1024 bytes). .TP .BI \-c " count" Exit after receiving \fIcount\fP packets. .TP .BI \-C " file_size" Before writing a raw packet to a savefile, check whether the file is currently larger than \fIfile_size\fP and, if so, close the current savefile and open a new one. Savefiles after the first savefile will have the name specified with the .B \-w flag, with a number after it, starting at 1 and continuing upward. The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes, not 1,048,576 bytes). .TP .B \-d Dump the compiled packet-matching code in a human readable form to standard output and stop. .TP .B \-dd Dump packet-matching code as a .B C program fragment. .TP .B \-ddd Dump packet-matching code as decimal numbers (preceded with a count). .TP .B \-D .PD 0 .TP .B \-\-list\-interfaces .PD Print the list of the network interfaces available on the system and on which .I tcpdump can capture packets. For each network interface, a number and an interface name, possibly followed by a text description of the interface, is printed. The interface name or the number can be supplied to the .B \-i flag to specify an interface on which to capture. .IP This can be useful on systems that don't have a command to list them (e.g., Windows systems, or UNIX systems lacking .BR "ifconfig \-a" ); the number can be useful on Windows 2000 and later systems, where the interface name is a somewhat complex string. .IP The .B \-D flag will not be supported if .I tcpdump was built with an older version of .I libpcap that lacks the .B pcap_findalldevs() function. .TP .B \-e Print the link-level header on each dump line. This can be used, for example, to print MAC layer addresses for protocols such as Ethernet and IEEE 802.11. .TP .B \-E Use \fIspi@ipaddr algo:secret\fP for decrypting IPsec ESP packets that are addressed to \fIaddr\fP and contain Security Parameter Index value \fIspi\fP. This combination may be repeated with comma or newline separation. .IP Note that setting the secret for IPv4 ESP packets is supported at this time. .IP Algorithms may be \fBdes-cbc\fP, \fB3des-cbc\fP, \fBblowfish-cbc\fP, \fBrc3-cbc\fP, \fBcast128-cbc\fP, or \fBnone\fP. The default is \fBdes-cbc\fP. The ability to decrypt packets is only present if \fItcpdump\fP was compiled with cryptography enabled. .IP \fIsecret\fP is the ASCII text for ESP secret key. If preceded by 0x, then a hex value will be read. .IP The option assumes RFC2406 ESP, not RFC1827 ESP. The option is only for debugging purposes, and the use of this option with a true `secret' key is discouraged. By presenting IPsec secret key onto command line you make it visible to others, via .IR ps (1) and other occasions. .IP In addition to the above syntax, the syntax \fIfile name\fP may be used to have tcpdump read the provided file in. The file is opened upon receiving the first ESP packet, so any special permissions that tcpdump may have been given should already have been given up. .TP .B \-f Print `foreign' IPv4 addresses numerically rather than symbolically (this option is intended to get around serious brain damage in Sun's NIS server \(em usually it hangs forever translating non-local internet numbers). .IP The test for `foreign' IPv4 addresses is done using the IPv4 address and netmask of the interface on which capture is being done. If that address or netmask are not available, available, either because the interface on which capture is being done has no address or netmask or because the capture is being done on the Linux "any" interface, which can capture on more than one interface, this option will not work correctly. .TP .BI \-F " file" Use \fIfile\fP as input for the filter expression. An additional expression given on the command line is ignored. .TP .BI \-G " rotate_seconds" If specified, rotates the dump file specified with the .B \-w option every \fIrotate_seconds\fP seconds. Savefiles will have the name specified by .B \-w which should include a time format as defined by .BR strftime (3). If no time format is specified, each new file will overwrite the previous. .IP If used in conjunction with the .B \-C option, filenames will take the form of `\fIfile\fP'. .TP .B \-h .PD 0 .TP .B \-\-help .PD Print the tcpdump and libpcap version strings, print a usage message, and exit. .TP .B \-\-version .PD Print the tcpdump and libpcap version strings and exit. .TP .B \-H Attempt to detect 802.11s draft mesh headers. .TP .BI \-i " interface" .PD 0 .TP .BI \-\-interface= interface .PD Listen on \fIinterface\fP. If unspecified, \fItcpdump\fP searches the system interface list for the lowest numbered, configured up interface (excluding loopback), which may turn out to be, for example, ``eth0''. .IP On Linux systems with 2.2 or later kernels, an .I interface argument of ``any'' can be used to capture packets from all interfaces. Note that captures on the ``any'' device will not be done in promiscuous mode. .IP If the .B \-D flag is supported, an interface number as printed by that flag can be used as the .I interface argument, if no interface on the system has that number as a name. .TP .B \-I .PD 0 .TP .B \-\-monitor\-mode .PD Put the interface in "monitor mode"; this is supported only on IEEE 802.11 Wi-Fi interfaces, and supported only on some operating systems. .IP Note that in monitor mode the adapter might disassociate from the network with which it's associated, so that you will not be able to use any wireless networks with that adapter. This could prevent accessing files on a network server, or resolving host names or network addresses, if you are capturing in monitor mode and are not connected to another network with another adapter. .IP This flag will affect the output of the .B \-L flag. If .B \-I isn't specified, only those link-layer types available when not in monitor mode will be shown; if .B \-I is specified, only those link-layer types available when in monitor mode will be shown. .TP .BI \-\-immediate\-mode Capture in "immediate mode". In this mode, packets are delivered to tcpdump as soon as they arrive, rather than being buffered for efficiency. This is the default when printing packets rather than saving packets to a ``savefile'' if the packets are being printed to a terminal rather than to a file or pipe. .TP .BI \-j " tstamp_type" .PD 0 .TP .BI \-\-time\-stamp\-type= tstamp_type .PD Set the time stamp type for the capture to \fItstamp_type\fP. The names to use for the time stamp types are given in -.BR pcap-tstamp (@MAN_MISC_INFO@); +.BR \%pcap-tstamp (@MAN_MISC_INFO@); not all the types listed there will necessarily be valid for any given interface. .TP .B \-J .PD 0 .TP .B \-\-list\-time\-stamp\-types .PD List the supported time stamp types for the interface and exit. If the time stamp type cannot be set for the interface, no time stamp types are listed. .TP .BI \-\-time\-stamp\-precision= tstamp_precision When capturing, set the time stamp precision for the capture to \fItstamp_precision\fP. Note that availability of high precision time stamps (nanoseconds) and their actual accuracy is platform and hardware dependent. Also note that when writing captures made with nanosecond accuracy to a savefile, the time stamps are written with nanosecond resolution, and the file is written with a different magic number, to indicate that the time stamps are in seconds and nanoseconds; not all programs that read pcap savefiles will be able to read those captures. .LP When reading a savefile, convert time stamps to the precision specified by \fItimestamp_precision\fP, and display them with that resolution. If the precision specified is less than the precision of time stamps in the file, the conversion will lose precision. .LP The supported values for \fItimestamp_precision\fP are \fBmicro\fP for microsecond resolution and \fBnano\fP for nanosecond resolution. The default is microsecond resolution. .TP .B \-K .PD 0 .TP .B \-\-dont\-verify\-checksums .PD Don't attempt to verify IP, TCP, or UDP checksums. This is useful for interfaces that perform some or all of those checksum calculation in hardware; otherwise, all outgoing TCP checksums will be flagged as bad. .TP .B \-l Make stdout line buffered. Useful if you want to see the data while capturing it. E.g., .IP .RS .RS .nf \fBtcpdump \-l | tee dat\fP .fi .RE .RE .IP or .IP .RS .RS .nf \fBtcpdump \-l > dat & tail \-f dat\fP .fi .RE .RE .IP Note that on Windows,``line buffered'' means ``unbuffered'', so that WinDump will write each character individually if .B \-l is specified. .IP .B \-U is similar to .B \-l in its behavior, but it will cause output to be ``packet-buffered'', so that the output is written to stdout at the end of each packet rather than at the end of each line; this is buffered on all platforms, including Windows. .TP .B \-L .PD 0 .TP .B \-\-list\-data\-link\-types .PD List the known data link types for the interface, in the specified mode, and exit. The list of known data link types may be dependent on the specified mode; for example, on some platforms, a Wi-Fi interface might support one set of data link types when not in monitor mode (for example, it might support only fake Ethernet headers, or might support 802.11 headers but not support 802.11 headers with radio information) and another set of data link types when in monitor mode (for example, it might support 802.11 headers, or 802.11 headers with radio information, only in monitor mode). .TP .BI \-m " module" Load SMI MIB module definitions from file \fImodule\fR. This option can be used several times to load several MIB modules into \fItcpdump\fP. .TP .BI \-M " secret" Use \fIsecret\fP as a shared secret for validating the digests found in TCP segments with the TCP-MD5 option (RFC 2385), if present. .TP .B \-n Don't convert addresses (i.e., host addresses, port numbers, etc.) to names. .TP .B \-N Don't print domain name qualification of host names. E.g., if you give this flag then \fItcpdump\fP will print ``nic'' instead of ``nic.ddn.mil''. .TP .B \-# .PD 0 .TP .B \-\-number .PD Print an optional packet number at the beginning of the line. .TP .B \-O .PD 0 .TP .B \-\-no\-optimize .PD Do not run the packet-matching code optimizer. This is useful only if you suspect a bug in the optimizer. .TP .B \-p .PD 0 .TP .B \-\-no\-promiscuous\-mode .PD \fIDon't\fP put the interface into promiscuous mode. Note that the interface might be in promiscuous mode for some other reason; hence, `-p' cannot be used as an abbreviation for `ether host {local-hw-addr} or ether broadcast'. .TP .BI \-Q " direction" .PD 0 .TP .BI \-\-direction= direction .PD Choose send/receive direction \fIdirection\fR for which packets should be captured. Possible values are `in', `out' and `inout'. Not available on all platforms. .TP .B \-q Quick (quiet?) output. Print less protocol information so output lines are shorter. .TP .BI \-r " file" Read packets from \fIfile\fR (which was created with the .B \-w option or by other tools that write pcap or pcap-ng files). Standard input is used if \fIfile\fR is ``-''. .TP .B \-S .PD 0 .TP .B \-\-absolute\-tcp\-sequence\-numbers .PD Print absolute, rather than relative, TCP sequence numbers. .TP .BI \-s " snaplen" .PD 0 .TP .BI \-\-snapshot\-length= snaplen .PD Snarf \fIsnaplen\fP bytes of data from each packet rather than the default of 262144 bytes. Packets truncated because of a limited snapshot are indicated in the output with ``[|\fIproto\fP]'', where \fIproto\fP is the name of the protocol level at which the truncation has occurred. Note that taking larger snapshots both increases the amount of time it takes to process packets and, effectively, decreases the amount of packet buffering. This may cause packets to be lost. You should limit \fIsnaplen\fP to the smallest number that will capture the protocol information you're interested in. Setting \fIsnaplen\fP to 0 sets it to the default of 262144, for backwards compatibility with recent older versions of .IR tcpdump . .TP .BI \-T " type" Force packets selected by "\fIexpression\fP" to be interpreted the specified \fItype\fR. Currently known types are \fBaodv\fR (Ad-hoc On-demand Distance Vector protocol), \fBcarp\fR (Common Address Redundancy Protocol), \fBcnfp\fR (Cisco NetFlow protocol), \fBlmp\fR (Link Management Protocol), \fBpgm\fR (Pragmatic General Multicast), \fBpgm_zmtp1\fR (ZMTP/1.0 inside PGM/EPGM), \fBresp\fR (REdis Serialization Protocol), \fBradius\fR (RADIUS), \fBrpc\fR (Remote Procedure Call), \fBrtp\fR (Real-Time Applications protocol), \fBrtcp\fR (Real-Time Applications control protocol), \fBsnmp\fR (Simple Network Management Protocol), \fBtftp\fR (Trivial File Transfer Protocol), \fBvat\fR (Visual Audio Tool), \fBwb\fR (distributed White Board), \fBzmtp1\fR (ZeroMQ Message Transport Protocol 1.0) and \fBvxlan\fR (Virtual eXtensible Local Area Network). .IP Note that the \fBpgm\fR type above affects UDP interpretation only, the native PGM is always recognised as IP protocol 113 regardless. UDP-encapsulated PGM is often called "EPGM" or "PGM/UDP". .IP Note that the \fBpgm_zmtp1\fR type above affects interpretation of both native PGM and UDP at once. During the native PGM decoding the application data of an ODATA/RDATA packet would be decoded as a ZeroMQ datagram with ZMTP/1.0 frames. During the UDP decoding in addition to that any UDP packet would be treated as an encapsulated PGM packet. .TP .B \-t \fIDon't\fP print a timestamp on each dump line. .TP .B \-tt Print the timestamp, as seconds since January 1, 1970, 00:00:00, UTC, and fractions of a second since that time, on each dump line. .TP .B \-ttt Print a delta (micro-second resolution) between current and previous line on each dump line. .TP .B \-tttt Print a timestamp, as hours, minutes, seconds, and fractions of a second since midnight, preceded by the date, on each dump line. .TP .B \-ttttt Print a delta (micro-second resolution) between current and first line on each dump line. .TP .B \-u Print undecoded NFS handles. .TP .B \-U .PD 0 .TP .B \-\-packet\-buffered .PD If the .B \-w option is not specified, make the printed packet output ``packet-buffered''; i.e., as the description of the contents of each packet is printed, it will be written to the standard output, rather than, when not writing to a terminal, being written only when the output buffer fills. .IP If the .B \-w option is specified, make the saved raw packet output ``packet-buffered''; i.e., as each packet is saved, it will be written to the output file, rather than being written only when the output buffer fills. .IP The .B \-U flag will not be supported if .I tcpdump was built with an older version of .I libpcap that lacks the .B pcap_dump_flush() function. .TP .B \-v When parsing and printing, produce (slightly more) verbose output. For example, the time to live, identification, total length and options in an IP packet are printed. Also enables additional packet integrity checks such as verifying the IP and ICMP header checksum. .IP When writing to a file with the .B \-w option, report, every 10 seconds, the number of packets captured. .TP .B \-vv Even more verbose output. For example, additional fields are printed from NFS reply packets, and SMB packets are fully decoded. .TP .B \-vvv Even more verbose output. For example, telnet \fBSB\fP ... \fBSE\fP options are printed in full. With .B \-X Telnet options are printed in hex as well. .TP .BI \-V " file" Read a list of filenames from \fIfile\fR. Standard input is used if \fIfile\fR is ``-''. .TP .BI \-w " file" Write the raw packets to \fIfile\fR rather than parsing and printing them out. They can later be printed with the \-r option. Standard output is used if \fIfile\fR is ``-''. .IP This output will be buffered if written to a file or pipe, so a program reading from the file or pipe may not see packets for an arbitrary amount of time after they are received. Use the .B \-U flag to cause packets to be written as soon as they are received. .IP The MIME type \fIapplication/vnd.tcpdump.pcap\fP has been registered with IANA for \fIpcap\fP files. The filename extension \fI.pcap\fP appears to be the most commonly used along with \fI.cap\fP and \fI.dmp\fP. \fITcpdump\fP itself doesn't check the extension when reading capture files and doesn't add an extension when writing them (it uses magic numbers in the file header instead). However, many operating systems and applications will use the extension if it is present and adding one (e.g. .pcap) is recommended. .IP See .BR pcap-savefile (@MAN_FILE_FORMATS@) for a description of the file format. .TP .B \-W Used in conjunction with the .B \-C option, this will limit the number of files created to the specified number, and begin overwriting files from the beginning, thus creating a 'rotating' buffer. In addition, it will name the files with enough leading 0s to support the maximum number of files, allowing them to sort correctly. .IP Used in conjunction with the .B \-G option, this will limit the number of rotated dump files that get created, exiting with status 0 when reaching the limit. If used with .B \-C as well, the behavior will result in cyclical files per timeslice. .TP .B \-x When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex. The smaller of the entire packet or .I snaplen bytes will be printed. Note that this is the entire link-layer packet, so for link layers that pad (e.g. Ethernet), the padding bytes will also be printed when the higher layer packet is shorter than the required padding. .TP .B \-xx When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, .I including its link level header, in hex. .TP .B \-X When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex and ASCII. This is very handy for analysing new protocols. .TP .B \-XX When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, .I including its link level header, in hex and ASCII. .TP .BI \-y " datalinktype" .PD 0 .TP .BI \-\-linktype= datalinktype .PD Set the data link type to use while capturing packets to \fIdatalinktype\fP. .TP .BI \-z " postrotate-command" Used in conjunction with the .B -C or .B -G options, this will make .I tcpdump run " .I postrotate-command file " where .I file is the savefile being closed after each rotation. For example, specifying .B \-z gzip or .B \-z bzip2 will compress each savefile using gzip or bzip2. .IP Note that tcpdump will run the command in parallel to the capture, using the lowest priority so that this doesn't disturb the capture process. .IP And in case you would like to use a command that itself takes flags or different arguments, you can always write a shell script that will take the savefile name as the only argument, make the flags & arguments arrangements and execute the command that you want. .TP .BI \-Z " user" .PD 0 .TP .BI \-\-relinquish\-privileges= user .PD If .I tcpdump is running as root, after opening the capture device or input savefile, but before opening any savefiles for output, change the user ID to .I user and the group ID to the primary group of .IR user . .IP This behavior can also be enabled by default at compile time. .IP "\fI expression\fP" .RS selects which packets will be dumped. If no \fIexpression\fP is given, all packets on the net will be dumped. Otherwise, only packets for which \fIexpression\fP is `true' will be dumped. .LP For the \fIexpression\fP syntax, see .BR pcap-filter (@MAN_MISC_INFO@). .LP The \fIexpression\fP argument can be passed to \fItcpdump\fP as either a single Shell argument, or as multiple Shell arguments, whichever is more convenient. Generally, if the expression contains Shell metacharacters, such as backslashes used to escape protocol names, it is easier to pass it as a single, quoted argument rather than to escape the Shell metacharacters. Multiple arguments are concatenated with spaces before being parsed. .SH EXAMPLES .LP To print all packets arriving at or departing from \fIsundown\fP: .RS .nf \fBtcpdump host sundown\fP .fi .RE .LP To print traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR: .RS .nf \fBtcpdump host helios and \\( hot or ace \\)\fP .fi .RE .LP To print all IP packets between \fIace\fR and any host except \fIhelios\fR: .RS .nf \fBtcpdump ip host ace and not helios\fP .fi .RE .LP To print all traffic between local hosts and hosts at Berkeley: .RS .nf .B tcpdump net ucb-ether .fi .RE .LP To print all ftp traffic through internet gateway \fIsnup\fP: (note that the expression is quoted to prevent the shell from (mis-)interpreting the parentheses): .RS .nf .B tcpdump 'gateway snup and (port ftp or ftp-data)' .fi .RE .LP To print traffic neither sourced from nor destined for local hosts (if you gateway to one other net, this stuff should never make it onto your local net). .RS .nf .B tcpdump ip and not net \fIlocalnet\fP .fi .RE .LP To print the start and end packets (the SYN and FIN packets) of each TCP conversation that involves a non-local host. .RS .nf .B tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP' .fi .RE .LP To print all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets. (IPv6 is left as an exercise for the reader.) .RS .nf .B tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' .fi .RE .LP To print IP packets longer than 576 bytes sent through gateway \fIsnup\fP: .RS .nf .B tcpdump 'gateway snup and ip[2:2] > 576' .fi .RE .LP To print IP broadcast or multicast packets that were .I not sent via Ethernet broadcast or multicast: .RS .nf .B tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224' .fi .RE .LP To print all ICMP packets that are not echo requests/replies (i.e., not ping packets): .RS .nf .B tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply' .fi .RE .SH OUTPUT FORMAT .LP The output of \fItcpdump\fP is protocol dependent. The following gives a brief description and examples of most of the formats. .de HD .sp 1.5 .B .. .HD Timestamps .LP By default, all output lines are preceded by a timestamp. The timestamp is the current clock time in the form .RS .nf \fIhh:mm:ss.frac\fP .fi .RE and is as accurate as the kernel's clock. The timestamp reflects the time the kernel applied a time stamp to the packet. No attempt is made to account for the time lag between when the network interface finished receiving the packet from the network and when the kernel applied a time stamp to the packet; that time lag could include a delay between the time when the network interface finished receiving a packet from the network and the time when an interrupt was delivered to the kernel to get it to read the packet and a delay between the time when the kernel serviced the `new packet' interrupt and the time when it applied a time stamp to the packet. .HD Link Level Headers .LP If the '-e' option is given, the link level header is printed out. On Ethernets, the source and destination addresses, protocol, and packet length are printed. .LP On FDDI networks, the '-e' option causes \fItcpdump\fP to print the `frame control' field, the source and destination addresses, and the packet length. (The `frame control' field governs the interpretation of the rest of the packet. Normal packets (such as those containing IP datagrams) are `async' packets, with a priority value between 0 and 7; for example, `\fBasync4\fR'. Such packets are assumed to contain an 802.2 Logical Link Control (LLC) packet; the LLC header is printed if it is \fInot\fR an ISO datagram or a so-called SNAP packet. .LP On Token Ring networks, the '-e' option causes \fItcpdump\fP to print the `access control' and `frame control' fields, the source and destination addresses, and the packet length. As on FDDI networks, packets are assumed to contain an LLC packet. Regardless of whether the '-e' option is specified or not, the source routing information is printed for source-routed packets. .LP On 802.11 networks, the '-e' option causes \fItcpdump\fP to print the `frame control' fields, all of the addresses in the 802.11 header, and the packet length. As on FDDI networks, packets are assumed to contain an LLC packet. .LP \fI(N.B.: The following description assumes familiarity with the SLIP compression algorithm described in RFC-1144.)\fP .LP On SLIP links, a direction indicator (``I'' for inbound, ``O'' for outbound), packet type, and compression information are printed out. The packet type is printed first. The three types are \fIip\fP, \fIutcp\fP, and \fIctcp\fP. No further link information is printed for \fIip\fR packets. For TCP packets, the connection identifier is printed following the type. If the packet is compressed, its encoded header is printed out. The special cases are printed out as \fB*S+\fIn\fR and \fB*SA+\fIn\fR, where \fIn\fR is the amount by which the sequence number (or sequence number and ack) has changed. If it is not a special case, zero or more changes are printed. A change is indicated by U (urgent pointer), W (window), A (ack), S (sequence number), and I (packet ID), followed by a delta (+n or -n), or a new value (=n). Finally, the amount of data in the packet and compressed header length are printed. .LP For example, the following line shows an outbound compressed TCP packet, with an implicit connection identifier; the ack has changed by 6, the sequence number by 49, and the packet ID by 6; there are 3 bytes of data and 6 bytes of compressed header: .RS .nf \fBO ctcp * A+6 S+49 I+6 3 (6)\fP .fi .RE .HD ARP/RARP Packets .LP Arp/rarp output shows the type of request and its arguments. The format is intended to be self explanatory. Here is a short sample taken from the start of an `rlogin' from host \fIrtsg\fP to host \fIcsam\fP: .RS .nf .sp .5 \f(CWarp who-has csam tell rtsg arp reply csam is-at CSAM\fR .sp .5 .fi .RE The first line says that rtsg sent an arp packet asking for the Ethernet address of internet host csam. Csam replies with its Ethernet address (in this example, Ethernet addresses are in caps and internet addresses in lower case). .LP This would look less redundant if we had done \fItcpdump \-n\fP: .RS .nf .sp .5 \f(CWarp who-has 128.3.254.6 tell 128.3.254.68 arp reply 128.3.254.6 is-at 02:07:01:00:01:c4\fP .fi .RE .LP If we had done \fItcpdump \-e\fP, the fact that the first packet is broadcast and the second is point-to-point would be visible: .RS .nf .sp .5 \f(CWRTSG Broadcast 0806 64: arp who-has csam tell rtsg CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR .sp .5 .fi .RE For the first packet this says the Ethernet source address is RTSG, the destination is the Ethernet broadcast address, the type field contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes. .HD IPv4 Packets .LP If the link-layer header is not being printed, for IPv4 packets, \fBIP\fP is printed after the time stamp. .LP If the .B \-v flag is specified, information from the IPv4 header is shown in parentheses after the \fBIP\fP or the link-layer header. The general format of this information is: .RS .nf .sp .5 tos \fItos\fP, ttl \fIttl\fP, id \fIid\fP, offset \fIoffset\fP, flags [\fIflags\fP], proto \fIproto\fP, length \fIlength\fP, options (\fIoptions\fP) .sp .5 .fi .RE \fItos\fP is the type of service field; if the ECN bits are non-zero, those are reported as \fBECT(1)\fP, \fBECT(0)\fP, or \fBCE\fP. \fIttl\fP is the time-to-live; it is not reported if it is zero. \fIid\fP is the IP identification field. \fIoffset\fP is the fragment offset field; it is printed whether this is part of a fragmented datagram or not. \fIflags\fP are the MF and DF flags; \fB+\fP is reported if MF is set, and \fBDF\P is reported if F is set. If neither are set, \fB.\fP is reported. \fIproto\fP is the protocol ID field. \fIlength\fP is the total length field. \fIoptions\fP are the IP options, if any. .LP Next, for TCP and UDP packets, the source and destination IP addresses and TCP or UDP ports, with a dot between each IP address and its corresponding port, will be printed, with a > separating the source and destination. For other protocols, the addresses will be printed, with a > separating the source and destination. Higher level protocol information, if any, will be printed after that. .LP For fragmented IP datagrams, the first fragment contains the higher level protocol header; fragments after the first contain no higher level protocol header. Fragmentation information will be printed only with the .B \-v flag, in the IP header information, as described above. .HD TCP Packets .LP \fI(N.B.:The following description assumes familiarity with the TCP protocol described in RFC-793. If you are not familiar with the protocol, this description will not be of much use to you.)\fP .LP The general format of a TCP protocol line is: .RS .nf .sp .5 \fIsrc\fP > \fIdst\fP: Flags [\fItcpflags\fP], seq \fIdata-seqno\fP, ack \fIackno\fP, win \fIwindow\fP, urg \fIurgent\fP, options [\fIopts\fP], length \fIlen\fP .sp .5 .fi .RE \fISrc\fP and \fIdst\fP are the source and destination IP addresses and ports. \fITcpflags\fP are some combination of S (SYN), F (FIN), P (PUSH), R (RST), U (URG), W (ECN CWR), E (ECN-Echo) or `.' (ACK), or `none' if no flags are set. \fIData-seqno\fP describes the portion of sequence space covered by the data in this packet (see example below). \fIAckno\fP is sequence number of the next data expected the other direction on this connection. \fIWindow\fP is the number of bytes of receive buffer space available the other direction on this connection. \fIUrg\fP indicates there is `urgent' data in the packet. \fIOpts\fP are TCP options (e.g., mss 1024). \fILen\fP is the length of payload data. .LP \fIIptype\fR, \fISrc\fP, \fIdst\fP, and \fIflags\fP are always present. The other fields depend on the contents of the packet's TCP protocol header and are output only if appropriate. .LP Here is the opening portion of an rlogin from host \fIrtsg\fP to host \fIcsam\fP. .RS .nf .sp .5 \s-2\f(CWIP rtsg.1023 > csam.login: Flags [S], seq 768512:768512, win 4096, opts [mss 1024] IP csam.login > rtsg.1023: Flags [S.], seq, 947648:947648, ack 768513, win 4096, opts [mss 1024] IP rtsg.1023 > csam.login: Flags [.], ack 1, win 4096 IP rtsg.1023 > csam.login: Flags [P.], seq 1:2, ack 1, win 4096, length 1 IP csam.login > rtsg.1023: Flags [.], ack 2, win 4096 IP rtsg.1023 > csam.login: Flags [P.], seq 2:21, ack 1, win 4096, length 19 IP csam.login > rtsg.1023: Flags [P.], seq 1:2, ack 21, win 4077, length 1 IP csam.login > rtsg.1023: Flags [P.], seq 2:3, ack 21, win 4077, urg 1, length 1 IP csam.login > rtsg.1023: Flags [P.], seq 3:4, ack 21, win 4077, urg 1, length 1\fR\s+2 .sp .5 .fi .RE The first line says that TCP port 1023 on rtsg sent a packet to port \fIlogin\fP on csam. The \fBS\fP indicates that the \fISYN\fP flag was set. The packet sequence number was 768512 and it contained no data. (The notation is `first:last' which means `sequence numbers \fIfirst\fP up to but not including \fIlast\fP.) There was no piggy-backed ack, the available receive window was 4096 bytes and there was a max-segment-size option requesting an mss of 1024 bytes. .LP Csam replies with a similar packet except it includes a piggy-backed ack for rtsg's SYN. Rtsg then acks csam's SYN. The `.' means the ACK flag was set. The packet contained no data so there is no data sequence number or length. Note that the ack sequence number is a small integer (1). The first time \fItcpdump\fP sees a TCP `conversation', it prints the sequence number from the packet. On subsequent packets of the conversation, the difference between the current packet's sequence number and this initial sequence number is printed. This means that sequence numbers after the first can be interpreted as relative byte positions in the conversation's data stream (with the first data byte each direction being `1'). `-S' will override this feature, causing the original sequence numbers to be output. .LP On the 6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20 in the rtsg \(-> csam side of the conversation). The PUSH flag is set in the packet. On the 7th line, csam says it's received data sent by rtsg up to but not including byte 21. Most of this data is apparently sitting in the socket buffer since csam's receive window has gotten 19 bytes smaller. Csam also sends one byte of data to rtsg in this packet. On the 8th and 9th lines, csam sends two bytes of urgent, pushed data to rtsg. .LP If the snapshot was small enough that \fItcpdump\fP didn't capture the full TCP header, it interprets as much of the header as it can and then reports ``[|\fItcp\fP]'' to indicate the remainder could not be interpreted. If the header contains a bogus option (one with a length that's either too small or beyond the end of the header), \fItcpdump\fP reports it as ``[\fIbad opt\fP]'' and does not interpret any further options (since it's impossible to tell where they start). If the header length indicates options are present but the IP datagram length is not long enough for the options to actually be there, \fItcpdump\fP reports it as ``[\fIbad hdr length\fP]''. .HD .B Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.) .PP There are 8 bits in the control bits section of the TCP header: .IP .I CWR | ECE | URG | ACK | PSH | RST | SYN | FIN .PP Let's assume that we want to watch packets used in establishing a TCP connection. Recall that TCP uses a 3-way handshake protocol when it initializes a new connection; the connection sequence with regard to the TCP control bits is .PP .RS 1) Caller sends SYN .RE .RS 2) Recipient responds with SYN, ACK .RE .RS 3) Caller sends ACK .RE .PP Now we're interested in capturing packets that have only the SYN bit set (Step 1). Note that we don't want packets from step 2 (SYN-ACK), just a plain initial SYN. What we need is a correct filter expression for \fItcpdump\fP. .PP Recall the structure of a TCP header without options: .PP .nf 0 15 31 ----------------------------------------------------------------- | source port | destination port | ----------------------------------------------------------------- | sequence number | ----------------------------------------------------------------- | acknowledgment number | ----------------------------------------------------------------- | HL | rsvd |C|E|U|A|P|R|S|F| window size | ----------------------------------------------------------------- | TCP checksum | urgent pointer | ----------------------------------------------------------------- .fi .PP A TCP header usually holds 20 octets of data, unless options are present. The first line of the graph contains octets 0 - 3, the second line shows octets 4 - 7 etc. .PP Starting to count with 0, the relevant TCP control bits are contained in octet 13: .PP .nf 0 7| 15| 23| 31 ----------------|---------------|---------------|---------------- | HL | rsvd |C|E|U|A|P|R|S|F| window size | ----------------|---------------|---------------|---------------- | | 13th octet | | | .fi .PP Let's have a closer look at octet no. 13: .PP .nf | | |---------------| |C|E|U|A|P|R|S|F| |---------------| |7 5 3 0| .fi .PP These are the TCP control bits we are interested in. We have numbered the bits in this octet from 0 to 7, right to left, so the PSH bit is bit number 3, while the URG bit is number 5. .PP Recall that we want to capture packets with only SYN set. Let's see what happens to octet 13 if a TCP datagram arrives with the SYN bit set in its header: .PP .nf |C|E|U|A|P|R|S|F| |---------------| |0 0 0 0 0 0 1 0| |---------------| |7 6 5 4 3 2 1 0| .fi .PP Looking at the control bits section we see that only bit number 1 (SYN) is set. .PP Assuming that octet number 13 is an 8-bit unsigned integer in network byte order, the binary value of this octet is .IP 00000010 .PP and its decimal representation is .PP .nf 7 6 5 4 3 2 1 0 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2 .fi .PP We're almost done, because now we know that if only SYN is set, the value of the 13th octet in the TCP header, when interpreted as a 8-bit unsigned integer in network byte order, must be exactly 2. .PP This relationship can be expressed as .RS .B tcp[13] == 2 .RE .PP We can use this expression as the filter for \fItcpdump\fP in order to watch packets which have only SYN set: .RS .B tcpdump -i xl0 tcp[13] == 2 .RE .PP The expression says "let the 13th octet of a TCP datagram have the decimal value 2", which is exactly what we want. .PP Now, let's assume that we need to capture SYN packets, but we don't care if ACK or any other TCP control bit is set at the same time. Let's see what happens to octet 13 when a TCP datagram with SYN-ACK set arrives: .PP .nf |C|E|U|A|P|R|S|F| |---------------| |0 0 0 1 0 0 1 0| |---------------| |7 6 5 4 3 2 1 0| .fi .PP Now bits 1 and 4 are set in the 13th octet. The binary value of octet 13 is .IP 00010010 .PP which translates to decimal .PP .nf 7 6 5 4 3 2 1 0 0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18 .fi .PP Now we can't just use 'tcp[13] == 18' in the \fItcpdump\fP filter expression, because that would select only those packets that have SYN-ACK set, but not those with only SYN set. Remember that we don't care if ACK or any other control bit is set as long as SYN is set. .PP In order to achieve our goal, we need to logically AND the binary value of octet 13 with some other value to preserve the SYN bit. We know that we want SYN to be set in any case, so we'll logically AND the value in the 13th octet with the binary value of a SYN: .PP .nf 00010010 SYN-ACK 00000010 SYN AND 00000010 (we want SYN) AND 00000010 (we want SYN) -------- -------- = 00000010 = 00000010 .fi .PP We see that this AND operation delivers the same result regardless whether ACK or another TCP control bit is set. The decimal representation of the AND value as well as the result of this operation is 2 (binary 00000010), so we know that for packets with SYN set the following relation must hold true: .IP ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 ) .PP This points us to the \fItcpdump\fP filter expression .RS .B tcpdump -i xl0 'tcp[13] & 2 == 2' .RE .PP Some offsets and field values may be expressed as names rather than as numeric values. For example tcp[13] may be replaced with tcp[tcpflags]. The following TCP flag field values are also available: tcp-fin, tcp-syn, tcp-rst, tcp-push, tcp-act, tcp-urg. .PP This can be demonstrated as: .RS .B tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0' .RE .PP Note that you should use single quotes or a backslash in the expression to hide the AND ('&') special character from the shell. .HD .B UDP Packets .LP UDP format is illustrated by this rwho packet: .RS .nf .sp .5 \f(CWactinide.who > broadcast.who: udp 84\fP .sp .5 .fi .RE This says that port \fIwho\fP on host \fIactinide\fP sent a udp datagram to port \fIwho\fP on host \fIbroadcast\fP, the Internet broadcast address. The packet contained 84 bytes of user data. .LP Some UDP services are recognized (from the source or destination port number) and the higher level protocol information printed. In particular, Domain Name service requests (RFC-1034/1035) and Sun RPC calls (RFC-1050) to NFS. .HD UDP Name Server Requests .LP \fI(N.B.:The following description assumes familiarity with the Domain Service protocol described in RFC-1035. If you are not familiar with the protocol, the following description will appear to be written in greek.)\fP .LP Name server requests are formatted as .RS .nf .sp .5 \fIsrc > dst: id op? flags qtype qclass name (len)\fP .sp .5 \f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fR .sp .5 .fi .RE Host \fIh2opolo\fP asked the domain server on \fIhelios\fP for an address record (qtype=A) associated with the name \fIucbvax.berkeley.edu.\fP The query id was `3'. The `+' indicates the \fIrecursion desired\fP flag was set. The query length was 37 bytes, not including the UDP and IP protocol headers. The query operation was the normal one, \fIQuery\fP, so the op field was omitted. If the op had been anything else, it would have been printed between the `3' and the `+'. Similarly, the qclass was the normal one, \fIC_IN\fP, and omitted. Any other qclass would have been printed immediately after the `A'. .LP A few anomalies are checked and may result in extra fields enclosed in square brackets: If a query contains an answer, authority records or additional records section, .IR ancount , .IR nscount , or .I arcount are printed as `[\fIn\fPa]', `[\fIn\fPn]' or `[\fIn\fPau]' where \fIn\fP is the appropriate count. If any of the response bits are set (AA, RA or rcode) or any of the `must be zero' bits are set in bytes two and three, `[b2&3=\fIx\fP]' is printed, where \fIx\fP is the hex value of header bytes two and three. .HD UDP Name Server Responses .LP Name server responses are formatted as .RS .nf .sp .5 \fIsrc > dst: id op rcode flags a/n/au type class data (len)\fP .sp .5 \f(CWhelios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273) helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fR .sp .5 .fi .RE In the first example, \fIhelios\fP responds to query id 3 from \fIh2opolo\fP with 3 answer records, 3 name server records and 7 additional records. The first answer record is type A (address) and its data is internet address 128.32.137.3. The total size of the response was 273 bytes, excluding UDP and IP headers. The op (Query) and response code (NoError) were omitted, as was the class (C_IN) of the A record. .LP In the second example, \fIhelios\fP responds to query 2 with a response code of non-existent domain (NXDomain) with no answers, one name server and no authority records. The `*' indicates that the \fIauthoritative answer\fP bit was set. Since there were no answers, no type, class or data were printed. .LP Other flag characters that might appear are `\-' (recursion available, RA, \fInot\fP set) and `|' (truncated message, TC, set). If the `question' section doesn't contain exactly one entry, `[\fIn\fPq]' is printed. .HD SMB/CIFS decoding .LP \fItcpdump\fP now includes fairly extensive SMB/CIFS/NBT decoding for data on UDP/137, UDP/138 and TCP/139. Some primitive decoding of IPX and NetBEUI SMB data is also done. .LP By default a fairly minimal decode is done, with a much more detailed decode done if -v is used. Be warned that with -v a single SMB packet may take up a page or more, so only use -v if you really want all the gory details. .LP For information on SMB packet formats and what all the fields mean see www.cifs.org or the pub/samba/specs/ directory on your favorite samba.org mirror site. The SMB patches were written by Andrew Tridgell (tridge@samba.org). .HD NFS Requests and Replies .LP Sun NFS (Network File System) requests and replies are printed as: .RS .nf .sp .5 \fIsrc.sport > dst.nfs: NFS request xid xid len op args\fP \fIsrc.nfs > dst.dport: NFS reply xid xid reply stat len op results\fP .sp .5 \f(CW sushi.1023 > wrl.nfs: NFS request xid 26377 112 readlink fh 21,24/10.73165 wrl.nfs > sushi.1023: NFS reply xid 26377 reply ok 40 readlink "../var" sushi.1022 > wrl.nfs: NFS request xid 8219 144 lookup fh 9,74/4096.6878 "xcolors" wrl.nfs > sushi.1022: NFS reply xid 8219 reply ok 128 lookup fh 9,74/4134.3150 \fR .sp .5 .fi .RE In the first line, host \fIsushi\fP sends a transaction with id \fI26377\fP to \fIwrl\fP. The request was 112 bytes, excluding the UDP and IP headers. The operation was a \fIreadlink\fP (read symbolic link) on file handle (\fIfh\fP) 21,24/10.731657119. (If one is lucky, as in this case, the file handle can be interpreted as a major,minor device number pair, followed by the inode number and generation number.) In the second line, \fIwrl\fP replies `ok' with the same transaction id and the contents of the link. .LP In the third line, \fIsushi\fP asks (using a new transaction id) \fIwrl\fP to lookup the name `\fIxcolors\fP' in directory file 9,74/4096.6878. In the fourth line, \fIwrl\fP sends a reply with the respective transaction id. .LP Note that the data printed depends on the operation type. The format is intended to be self explanatory if read in conjunction with an NFS protocol spec. Also note that older versions of tcpdump printed NFS packets in a slightly different format: the transaction id (xid) would be printed instead of the non-NFS port number of the packet. .LP If the \-v (verbose) flag is given, additional information is printed. For example: .RS .nf .sp .5 \f(CW sushi.1023 > wrl.nfs: NFS request xid 79658 148 read fh 21,11/12.195 8192 bytes @ 24576 wrl.nfs > sushi.1023: NFS reply xid 79658 reply ok 1472 read REG 100664 ids 417/0 sz 29388 \fP .sp .5 .fi .RE (\-v also prints the IP header TTL, ID, length, and fragmentation fields, which have been omitted from this example.) In the first line, \fIsushi\fP asks \fIwrl\fP to read 8192 bytes from file 21,11/12.195, at byte offset 24576. \fIWrl\fP replies `ok'; the packet shown on the second line is the first fragment of the reply, and hence is only 1472 bytes long (the other bytes will follow in subsequent fragments, but these fragments do not have NFS or even UDP headers and so might not be printed, depending on the filter expression used). Because the \-v flag is given, some of the file attributes (which are returned in addition to the file data) are printed: the file type (``REG'', for regular file), the file mode (in octal), the uid and gid, and the file size. .LP If the \-v flag is given more than once, even more details are printed. .LP Note that NFS requests are very large and much of the detail won't be printed unless \fIsnaplen\fP is increased. Try using `\fB\-s 192\fP' to watch NFS traffic. .LP NFS reply packets do not explicitly identify the RPC operation. Instead, \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the replies using the transaction ID. If a reply does not closely follow the corresponding request, it might not be parsable. .HD AFS Requests and Replies .LP Transarc AFS (Andrew File System) requests and replies are printed as: .HD .RS .nf .sp .5 \fIsrc.sport > dst.dport: rx packet-type\fP \fIsrc.sport > dst.dport: rx packet-type service call call-name args\fP \fIsrc.sport > dst.dport: rx packet-type service reply call-name args\fP .sp .5 \f(CW elvis.7001 > pike.afsfs: rx data fs call rename old fid 536876964/1/1 ".newsrc.new" new fid 536876964/1/1 ".newsrc" pike.afsfs > elvis.7001: rx data fs reply rename \fR .sp .5 .fi .RE In the first line, host elvis sends a RX packet to pike. This was a RX data packet to the fs (fileserver) service, and is the start of an RPC call. The RPC call was a rename, with the old directory file id of 536876964/1/1 and an old filename of `.newsrc.new', and a new directory file id of 536876964/1/1 and a new filename of `.newsrc'. The host pike responds with a RPC reply to the rename call (which was successful, because it was a data packet and not an abort packet). .LP In general, all AFS RPCs are decoded at least by RPC call name. Most AFS RPCs have at least some of the arguments decoded (generally only the `interesting' arguments, for some definition of interesting). .LP The format is intended to be self-describing, but it will probably not be useful to people who are not familiar with the workings of AFS and RX. .LP If the -v (verbose) flag is given twice, acknowledgement packets and additional header information is printed, such as the RX call ID, call number, sequence number, serial number, and the RX packet flags. .LP If the -v flag is given twice, additional information is printed, such as the RX call ID, serial number, and the RX packet flags. The MTU negotiation information is also printed from RX ack packets. .LP If the -v flag is given three times, the security index and service id are printed. .LP Error codes are printed for abort packets, with the exception of Ubik beacon packets (because abort packets are used to signify a yes vote for the Ubik protocol). .LP Note that AFS requests are very large and many of the arguments won't be printed unless \fIsnaplen\fP is increased. Try using `\fB-s 256\fP' to watch AFS traffic. .LP AFS reply packets do not explicitly identify the RPC operation. Instead, \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the replies using the call number and service ID. If a reply does not closely follow the corresponding request, it might not be parsable. .HD KIP AppleTalk (DDP in UDP) .LP AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated and dumped as DDP packets (i.e., all the UDP header information is discarded). The file .I /etc/atalk.names is used to translate AppleTalk net and node numbers to names. Lines in this file have the form .RS .nf .sp .5 \fInumber name\fP \f(CW1.254 ether 16.1 icsd-net 1.254.110 ace\fR .sp .5 .fi .RE The first two lines give the names of AppleTalk networks. The third line gives the name of a particular host (a host is distinguished from a net by the 3rd octet in the number \- a net number \fImust\fP have two octets and a host number \fImust\fP have three octets.) The number and name should be separated by whitespace (blanks or tabs). The .I /etc/atalk.names file may contain blank lines or comment lines (lines starting with a `#'). .LP AppleTalk addresses are printed in the form .RS .nf .sp .5 \fInet.host.port\fP \f(CW144.1.209.2 > icsd-net.112.220 office.2 > icsd-net.112.220 jssmag.149.235 > icsd-net.2\fR .sp .5 .fi .RE (If the .I /etc/atalk.names doesn't exist or doesn't contain an entry for some AppleTalk host/net number, addresses are printed in numeric form.) In the first example, NBP (DDP port 2) on net 144.1 node 209 is sending to whatever is listening on port 220 of net icsd node 112. The second line is the same except the full name of the source node is known (`office'). The third line is a send from port 235 on net jssmag node 149 to broadcast on the icsd-net NBP port (note that the broadcast address (255) is indicated by a net name with no host number \- for this reason it's a good idea to keep node names and net names distinct in /etc/atalk.names). .LP NBP (name binding protocol) and ATP (AppleTalk transaction protocol) packets have their contents interpreted. Other protocols just dump the protocol name (or number if no name is registered for the protocol) and packet size. \fBNBP packets\fP are formatted like the following examples: .RS .nf .sp .5 \s-2\f(CWicsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*" jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250 techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fR\s+2 .sp .5 .fi .RE The first line is a name lookup request for laserwriters sent by net icsd host 112 and broadcast on net jssmag. The nbp id for the lookup is 190. The second line shows a reply for this request (note that it has the same id) from host jssmag.209 saying that it has a laserwriter resource named "RM1140" registered on port 250. The third line is another reply to the same request saying host techpit has laserwriter "techpit" registered on port 186. \fBATP packet\fP formatting is demonstrated by the following example: .RS .nf .sp .5 \s-2\f(CWjssmag.209.165 > helios.132: atp-req 12266<0-7> 0xae030001 helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000 jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000 jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001 jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fR\s+2 .sp .5 .fi .RE Jssmag.209 initiates transaction id 12266 with host helios by requesting up to 8 packets (the `<0-7>'). The hex number at the end of the line is the value of the `userdata' field in the request. .LP Helios responds with 8 512-byte packets. The `:digit' following the transaction id gives the packet sequence number in the transaction and the number in parens is the amount of data in the packet, excluding the atp header. The `*' on packet 7 indicates that the EOM bit was set. .LP Jssmag.209 then requests that packets 3 & 5 be retransmitted. Helios resends them then jssmag.209 releases the transaction. Finally, jssmag.209 initiates the next request. The `*' on the request indicates that XO (`exactly once') was \fInot\fP set. .SH "SEE ALSO" -stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@), -pcap-filter(@MAN_MISC_INFO@), pcap-tstamp(@MAN_MISC_INFO@) +stty(1), pcap(3PCAP), bpf(4), nit(4P), \%pcap-savefile(@MAN_FILE_FORMATS@), +\%pcap-filter(@MAN_MISC_INFO@), \%pcap-tstamp(@MAN_MISC_INFO@) .LP .RS .I http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap .RE .LP .SH AUTHORS The original authors are: .LP Van Jacobson, Craig Leres and Steven McCanne, all of the Lawrence Berkeley National Laboratory, University of California, Berkeley, CA. .LP It is currently being maintained by tcpdump.org. .LP The current version is available via http: .LP .RS -.I http://www.tcpdump.org/ +.I https://www.tcpdump.org/ .RE .LP The original distribution is available via anonymous ftp: .LP .RS .I ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z .RE .LP IPv6/IPsec support is added by WIDE/KAME project. This program uses Eric Young's SSLeay library, under specific configurations. .SH BUGS To report a security issue please send an e-mail to \%security@tcpdump.org. .LP To report bugs and other problems, contribute patches, request a feature, provide generic feedback etc please see the file .I CONTRIBUTING in the tcpdump source tree root. .LP NIT doesn't let you watch your own outbound traffic, BPF will. We recommend that you use the latter. .LP On Linux systems with 2.0[.x] kernels: .IP packets on the loopback device will be seen twice; .IP packet filtering cannot be done in the kernel, so that all packets must be copied from the kernel in order to be filtered in user mode; .IP all of a packet, not just the part that's within the snapshot length, will be copied from the kernel (the 2.0[.x] packet capture mechanism, if asked to copy only part of a packet to userland, will not report the true length of the packet; this would cause most IP packets to get an error from .BR tcpdump ); .IP capturing on some PPP devices won't work correctly. .LP We recommend that you upgrade to a 2.2 or later kernel. .LP Some attempt should be made to reassemble IP fragments or, at least to compute the right length for the higher level protocol. .LP Name server inverse queries are not dumped correctly: the (empty) question section is printed rather than real query in the answer section. Some believe that inverse queries are themselves a bug and prefer to fix the program generating them rather than \fItcpdump\fP. .LP A packet trace that crosses a daylight savings time change will give skewed time stamps (the time change is ignored). .LP Filter expressions on fields other than those in Token Ring headers will not correctly handle source-routed Token Ring packets. .LP Filter expressions on fields other than those in 802.11 headers will not correctly handle 802.11 data packets with both To DS and From DS set. .LP .BR "ip6 proto" should chase header chain, but at this moment it does not. .BR "ip6 protochain" is supplied for this behavior. .LP Arithmetic expression against transport layer headers, like \fBtcp[0]\fP, does not work against IPv6 packets. It only looks at IPv4 packets. Index: vendor/tcpdump/dist/tcpdump.c =================================================================== --- vendor/tcpdump/dist/tcpdump.c (revision 353143) +++ vendor/tcpdump/dist/tcpdump.c (revision 353144) @@ -1,2672 +1,2649 @@ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000 * 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. * * Support for splitting captures into multiple files with a maximum * file size: * * Copyright (c) 2001 * Seth Webster */ #ifndef lint static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* * tcpdump - dump traffic on a network * * First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory. * Mercilessly hacked and occasionally improved since then via the * combined efforts of Van, Steve McCanne and Craig Leres of LBL. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* * Mac OS X may ship pcap.h from libpcap 0.6 with a libpcap based on * 0.8. That means it has pcap_findalldevs() but the header doesn't * define pcap_if_t, meaning that we can't actually *use* pcap_findalldevs(). */ #ifdef HAVE_PCAP_FINDALLDEVS #ifndef HAVE_PCAP_IF_T #undef HAVE_PCAP_FINDALLDEVS #endif #endif #include #include #ifdef HAVE_FCNTL_H #include #endif #ifdef HAVE_LIBCRYPTO #include #endif #ifdef HAVE_GETOPT_LONG #include #else #include "getopt_long.h" #endif /* Capsicum-specific code requires macros from , which will fail * to compile if has already been included; including the headers * in the opposite order works fine. */ #ifdef HAVE_CAPSICUM #include #include #include #include #endif /* HAVE_CAPSICUM */ #include #include #include #include #include #include #include #ifndef _WIN32 #include #include #include #include #endif /* _WIN32 */ /* capabilities convenience library */ /* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H. * If HAVE_CAP_NG_H is not defined, undefine HAVE_LIBCAP_NG. * Thus, the later tests are done only on HAVE_LIBCAP_NG. */ #ifdef HAVE_LIBCAP_NG #ifdef HAVE_CAP_NG_H #include #else #undef HAVE_LIBCAP_NG #endif /* HAVE_CAP_NG_H */ #endif /* HAVE_LIBCAP_NG */ -#ifdef __FreeBSD__ -#include -#endif /* __FreeBSD__ */ - #include "netdissect.h" #include "interface.h" #include "addrtoname.h" #include "machdep.h" #include "setsignal.h" #include "gmt2local.h" #include "pcap-missing.h" #include "ascii_strcasecmp.h" #include "print.h" #ifndef PATH_MAX #define PATH_MAX 1024 #endif #ifdef SIGINFO #define SIGNAL_REQ_INFO SIGINFO #elif SIGUSR1 #define SIGNAL_REQ_INFO SIGUSR1 #endif static int Bflag; /* buffer size */ static long Cflag; /* rotate dump files after this many bytes */ static int Cflag_count; /* Keep track of which file number we're writing */ static int Dflag; /* list available devices and exit */ /* * This is exported because, in some versions of libpcap, if libpcap * is built with optimizer debugging code (which is *NOT* the default * configuration!), the library *imports*(!) a variable named dflag, * under the expectation that tcpdump is exporting it, to govern * how much debugging information to print when optimizing * the generated BPF code. * * This is a horrible hack; newer versions of libpcap don't import * dflag but, instead, *if* built with optimizer debugging code, * *export* a routine to set that flag. */ int dflag; /* print filter code */ static int Gflag; /* rotate dump files after this many seconds */ static int Gflag_count; /* number of files created with Gflag rotation */ static time_t Gflag_time; /* The last time_t the dump file was rotated. */ static int Lflag; /* list available data link types and exit */ static int Iflag; /* rfmon (monitor) mode */ #ifdef HAVE_PCAP_SET_TSTAMP_TYPE static int Jflag; /* list available time stamp types */ #endif static int jflag = -1; /* packet time stamp source */ static int pflag; /* don't go promiscuous */ #ifdef HAVE_PCAP_SETDIRECTION static int Qflag = -1; /* restrict captured packet by send/receive direction */ #endif static int Uflag; /* "unbuffered" output of dump files */ static int Wflag; /* recycle output files after this number of files */ static int WflagChars; static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */ static int immediate_mode; static int infodelay; static int infoprint; char *program_name; /* Forwards */ static void error(FORMAT_STRING(const char *), ...) NORETURN PRINTFLIKE(1, 2); static void warning(FORMAT_STRING(const char *), ...) PRINTFLIKE(1, 2); static void exit_tcpdump(int) NORETURN; static RETSIGTYPE cleanup(int); static RETSIGTYPE child_cleanup(int); static void print_version(void); static void print_usage(void); static void show_tstamp_types_and_exit(pcap_t *, const char *device) NORETURN; static void show_dlts_and_exit(pcap_t *, const char *device) NORETURN; #ifdef HAVE_PCAP_FINDALLDEVS static void show_devices_and_exit (void) NORETURN; #endif static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *); static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *); static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *); static void droproot(const char *, const char *); #ifdef SIGNAL_REQ_INFO RETSIGTYPE requestinfo(int); #endif #if defined(USE_WIN32_MM_TIMER) #include static UINT timer_id; static void CALLBACK verbose_stats_dump(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR); #elif defined(HAVE_ALARM) static void verbose_stats_dump(int sig); #endif static void info(int); static u_int packets_captured; #ifdef HAVE_PCAP_FINDALLDEVS static const struct tok status_flags[] = { #ifdef PCAP_IF_UP { PCAP_IF_UP, "Up" }, #endif #ifdef PCAP_IF_RUNNING { PCAP_IF_RUNNING, "Running" }, #endif { PCAP_IF_LOOPBACK, "Loopback" }, { 0, NULL } }; #endif static pcap_t *pd; static int supports_monitor_mode; extern int optind; extern int opterr; extern char *optarg; struct dump_info { char *WFileName; char *CurrentFileName; pcap_t *pd; pcap_dumper_t *p; #ifdef HAVE_CAPSICUM int dirfd; #endif }; #if defined(HAVE_PCAP_SET_PARSER_DEBUG) /* * We have pcap_set_parser_debug() in libpcap; declare it (it's not declared * by any libpcap header, because it's a special hack, only available if * libpcap was configured to include it, and only intended for use by * libpcap developers trying to debug the parser for filter expressions). */ #ifdef _WIN32 __declspec(dllimport) #else /* _WIN32 */ extern #endif /* _WIN32 */ void pcap_set_parser_debug(int); #elif defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG) /* * We don't have pcap_set_parser_debug() in libpcap, but we do have * pcap_debug or yydebug. Make a local version of pcap_set_parser_debug() * to set the flag, and define HAVE_PCAP_SET_PARSER_DEBUG. */ static void pcap_set_parser_debug(int value) { #ifdef HAVE_PCAP_DEBUG extern int pcap_debug; pcap_debug = value; #else /* HAVE_PCAP_DEBUG */ extern int yydebug; yydebug = value; #endif /* HAVE_PCAP_DEBUG */ } #define HAVE_PCAP_SET_PARSER_DEBUG #endif #if defined(HAVE_PCAP_SET_OPTIMIZER_DEBUG) /* * We have pcap_set_optimizer_debug() in libpcap; declare it (it's not declared * by any libpcap header, because it's a special hack, only available if * libpcap was configured to include it, and only intended for use by * libpcap developers trying to debug the optimizer for filter expressions). */ #ifdef _WIN32 __declspec(dllimport) #else /* _WIN32 */ extern #endif /* _WIN32 */ void pcap_set_optimizer_debug(int); #endif /* VARARGS */ static void error(const char *fmt, ...) { va_list ap; (void)fprintf(stderr, "%s: ", program_name); va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); va_end(ap); if (*fmt) { fmt += strlen(fmt); if (fmt[-1] != '\n') (void)fputc('\n', stderr); } exit_tcpdump(1); /* NOTREACHED */ } /* VARARGS */ static void warning(const char *fmt, ...) { va_list ap; (void)fprintf(stderr, "%s: WARNING: ", program_name); va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); va_end(ap); if (*fmt) { fmt += strlen(fmt); if (fmt[-1] != '\n') (void)fputc('\n', stderr); } } static void exit_tcpdump(int status) { nd_cleanup(); exit(status); } #ifdef HAVE_PCAP_SET_TSTAMP_TYPE static void show_tstamp_types_and_exit(pcap_t *pc, const char *device) { int n_tstamp_types; int *tstamp_types = 0; const char *tstamp_type_name; int i; n_tstamp_types = pcap_list_tstamp_types(pc, &tstamp_types); if (n_tstamp_types < 0) error("%s", pcap_geterr(pc)); if (n_tstamp_types == 0) { fprintf(stderr, "Time stamp type cannot be set for %s\n", device); exit_tcpdump(0); } fprintf(stderr, "Time stamp types for %s (use option -j to set):\n", device); for (i = 0; i < n_tstamp_types; i++) { tstamp_type_name = pcap_tstamp_type_val_to_name(tstamp_types[i]); if (tstamp_type_name != NULL) { (void) fprintf(stderr, " %s (%s)\n", tstamp_type_name, pcap_tstamp_type_val_to_description(tstamp_types[i])); } else { (void) fprintf(stderr, " %d\n", tstamp_types[i]); } } pcap_free_tstamp_types(tstamp_types); exit_tcpdump(0); } #endif static void show_dlts_and_exit(pcap_t *pc, const char *device) { int n_dlts, i; int *dlts = 0; const char *dlt_name; n_dlts = pcap_list_datalinks(pc, &dlts); if (n_dlts < 0) error("%s", pcap_geterr(pc)); else if (n_dlts == 0 || !dlts) error("No data link types."); /* * If the interface is known to support monitor mode, indicate * whether these are the data link types available when not in * monitor mode, if -I wasn't specified, or when in monitor mode, * when -I was specified (the link-layer types available in * monitor mode might be different from the ones available when * not in monitor mode). */ if (supports_monitor_mode) (void) fprintf(stderr, "Data link types for %s %s (use option -y to set):\n", device, Iflag ? "when in monitor mode" : "when not in monitor mode"); else (void) fprintf(stderr, "Data link types for %s (use option -y to set):\n", device); for (i = 0; i < n_dlts; i++) { dlt_name = pcap_datalink_val_to_name(dlts[i]); if (dlt_name != NULL) { (void) fprintf(stderr, " %s (%s)", dlt_name, pcap_datalink_val_to_description(dlts[i])); /* * OK, does tcpdump handle that type? */ if (!has_printer(dlts[i])) (void) fprintf(stderr, " (printing not supported)"); fprintf(stderr, "\n"); } else { (void) fprintf(stderr, " DLT %d (printing not supported)\n", dlts[i]); } } #ifdef HAVE_PCAP_FREE_DATALINKS pcap_free_datalinks(dlts); #endif exit_tcpdump(0); } #ifdef HAVE_PCAP_FINDALLDEVS static void show_devices_and_exit (void) { pcap_if_t *dev, *devlist; char ebuf[PCAP_ERRBUF_SIZE]; int i; if (pcap_findalldevs(&devlist, ebuf) < 0) error("%s", ebuf); for (i = 0, dev = devlist; dev != NULL; i++, dev = dev->next) { printf("%d.%s", i+1, dev->name); if (dev->description != NULL) printf(" (%s)", dev->description); if (dev->flags != 0) printf(" [%s]", bittok2str(status_flags, "none", dev->flags)); printf("\n"); } pcap_freealldevs(devlist); exit_tcpdump(0); } #endif /* HAVE_PCAP_FINDALLDEVS */ /* * Short options. * * Note that there we use all letters for short options except for g, k, * o, and P, and those are used by other versions of tcpdump, and we should * only use them for the same purposes that the other versions of tcpdump * use them: * * OS X tcpdump uses -g to force non--v output for IP to be on one * line, making it more "g"repable; * * OS X tcpdump uses -k to specify that packet comments in pcap-ng files * should be printed; * * OpenBSD tcpdump uses -o to indicate that OS fingerprinting should be done * for hosts sending TCP SYN packets; * * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather * than pcap files. * * OS X tcpdump also uses -Q to specify expressions that match packet * metadata, including but not limited to the packet direction. * The expression syntax is different from a simple "in|out|inout", * and those expressions aren't accepted by OS X tcpdump, but the * equivalents would be "in" = "dir=in", "out" = "dir=out", and * "inout" = "dir=in or dir=out", and the parser could conceivably * special-case "in", "out", and "inout" as expressions for backwards * compatibility, so all is not (yet) lost. */ /* * Set up flags that might or might not be supported depending on the * version of libpcap we're using. */ #if defined(HAVE_PCAP_CREATE) || defined(_WIN32) #define B_FLAG "B:" #define B_FLAG_USAGE " [ -B size ]" #else /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */ #define B_FLAG #define B_FLAG_USAGE #endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */ #ifdef HAVE_PCAP_CREATE #define I_FLAG "I" #else /* HAVE_PCAP_CREATE */ #define I_FLAG #endif /* HAVE_PCAP_CREATE */ #ifdef HAVE_PCAP_SET_TSTAMP_TYPE #define j_FLAG "j:" #define j_FLAG_USAGE " [ -j tstamptype ]" #define J_FLAG "J" #else /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */ #define j_FLAG #define j_FLAG_USAGE #define J_FLAG #endif /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */ #ifdef HAVE_PCAP_FINDALLDEVS #define D_FLAG "D" #else #define D_FLAG #endif #ifdef HAVE_PCAP_DUMP_FLUSH #define U_FLAG "U" #else #define U_FLAG #endif #ifdef HAVE_PCAP_SETDIRECTION #define Q_FLAG "Q:" #else #define Q_FLAG #endif #define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#" /* * Long options. * * We do not currently have long options corresponding to all short * options; we should probably pick appropriate option names for them. * * However, the short options where the number of times the option is * specified matters, such as -v and -d and -t, should probably not * just map to a long option, as saying * * tcpdump --verbose --verbose * * doesn't make sense; it should be --verbosity={N} or something such * as that. * * For long options with no corresponding short options, we define values * outside the range of ASCII graphic characters, make that the last * component of the entry for the long option, and have a case for that * option in the switch statement. */ #define OPTION_VERSION 128 #define OPTION_TSTAMP_PRECISION 129 #define OPTION_IMMEDIATE_MODE 130 static const struct option longopts[] = { #if defined(HAVE_PCAP_CREATE) || defined(_WIN32) { "buffer-size", required_argument, NULL, 'B' }, #endif { "list-interfaces", no_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { "interface", required_argument, NULL, 'i' }, #ifdef HAVE_PCAP_CREATE { "monitor-mode", no_argument, NULL, 'I' }, #endif #ifdef HAVE_PCAP_SET_TSTAMP_TYPE { "time-stamp-type", required_argument, NULL, 'j' }, { "list-time-stamp-types", no_argument, NULL, 'J' }, #endif #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION { "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION}, #endif { "dont-verify-checksums", no_argument, NULL, 'K' }, { "list-data-link-types", no_argument, NULL, 'L' }, { "no-optimize", no_argument, NULL, 'O' }, { "no-promiscuous-mode", no_argument, NULL, 'p' }, #ifdef HAVE_PCAP_SETDIRECTION { "direction", required_argument, NULL, 'Q' }, #endif { "snapshot-length", required_argument, NULL, 's' }, { "absolute-tcp-sequence-numbers", no_argument, NULL, 'S' }, #ifdef HAVE_PCAP_DUMP_FLUSH { "packet-buffered", no_argument, NULL, 'U' }, #endif { "linktype", required_argument, NULL, 'y' }, #ifdef HAVE_PCAP_SET_IMMEDIATE_MODE { "immediate-mode", no_argument, NULL, OPTION_IMMEDIATE_MODE }, #endif #ifdef HAVE_PCAP_SET_PARSER_DEBUG { "debug-filter-parser", no_argument, NULL, 'Y' }, #endif { "relinquish-privileges", required_argument, NULL, 'Z' }, { "number", no_argument, NULL, '#' }, { "version", no_argument, NULL, OPTION_VERSION }, { NULL, 0, NULL, 0 } }; #ifndef _WIN32 /* Drop root privileges and chroot if necessary */ static void droproot(const char *username, const char *chroot_dir) { struct passwd *pw = NULL; if (chroot_dir && !username) { fprintf(stderr, "%s: Chroot without dropping root is insecure\n", program_name); exit_tcpdump(1); } pw = getpwnam(username); if (pw) { if (chroot_dir) { if (chroot(chroot_dir) != 0 || chdir ("/") != 0) { fprintf(stderr, "%s: Couldn't chroot/chdir to '%.64s': %s\n", program_name, chroot_dir, pcap_strerror(errno)); exit_tcpdump(1); } } #ifdef HAVE_LIBCAP_NG { int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG); - if (ret < 0) { - fprintf(stderr, "error : ret %d\n", ret); - } else { + if (ret < 0) + error("capng_change_id(): return %d\n", ret); + else fprintf(stderr, "dropped privs to %s\n", username); - } } #else if (initgroups(pw->pw_name, pw->pw_gid) != 0 || setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) { fprintf(stderr, "%s: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n", program_name, username, (unsigned long)pw->pw_uid, (unsigned long)pw->pw_gid, pcap_strerror(errno)); exit_tcpdump(1); } else { fprintf(stderr, "dropped privs to %s\n", username); } #endif /* HAVE_LIBCAP_NG */ } else { fprintf(stderr, "%s: Couldn't find user '%.32s'\n", program_name, username); exit_tcpdump(1); } #ifdef HAVE_LIBCAP_NG /* We don't need CAP_SETUID, CAP_SETGID and CAP_SYS_CHROOT any more. */ capng_updatev( CAPNG_DROP, CAPNG_EFFECTIVE | CAPNG_PERMITTED, CAP_SETUID, CAP_SETGID, CAP_SYS_CHROOT, -1); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ } #endif /* _WIN32 */ static int getWflagChars(int x) { int c = 0; x -= 1; while (x > 0) { c += 1; x /= 10; } return c; } static void MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars) { char *filename = malloc(PATH_MAX + 1); if (filename == NULL) error("Makefilename: malloc"); /* Process with strftime if Gflag is set. */ if (Gflag != 0) { struct tm *local_tm; /* Convert Gflag_time to a usable format */ if ((local_tm = localtime(&Gflag_time)) == NULL) { error("MakeTimedFilename: localtime"); } /* There's no good way to detect an error in strftime since a return * value of 0 isn't necessarily failure. */ strftime(filename, PATH_MAX, orig_name, local_tm); } else { strncpy(filename, orig_name, PATH_MAX); } if (cnt == 0 && max_chars == 0) strncpy(buffer, filename, PATH_MAX + 1); else if (snprintf(buffer, PATH_MAX + 1, "%s%0*d", filename, max_chars, cnt) > PATH_MAX) /* Report an error if the filename is too large */ error("too many output files or filename is too long (> %d)", PATH_MAX); free(filename); } static char * get_next_file(FILE *VFile, char *ptr) { char *ret; + size_t len; ret = fgets(ptr, PATH_MAX, VFile); if (!ret) return NULL; - if (ptr[strlen(ptr) - 1] == '\n') - ptr[strlen(ptr) - 1] = '\0'; + len = strlen (ptr); + if (len > 0 && ptr[len - 1] == '\n') + ptr[len - 1] = '\0'; return ret; } #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION static int tstamp_precision_from_string(const char *precision) { if (strncmp(precision, "nano", strlen("nano")) == 0) return PCAP_TSTAMP_PRECISION_NANO; if (strncmp(precision, "micro", strlen("micro")) == 0) return PCAP_TSTAMP_PRECISION_MICRO; return -EINVAL; } static const char * tstamp_precision_to_string(int precision) { switch (precision) { case PCAP_TSTAMP_PRECISION_MICRO: return "micro"; case PCAP_TSTAMP_PRECISION_NANO: return "nano"; default: return "unknown"; } } #endif #ifdef HAVE_CAPSICUM /* * Ensure that, on a dump file's descriptor, we have all the rights * necessary to make the standard I/O library work with an fdopen()ed * FILE * from that descriptor. * * A long time ago, in a galaxy far far away, AT&T decided that, instead * of providing separate APIs for getting and setting the FD_ flags on a * descriptor, getting and setting the O_ flags on a descriptor, and * locking files, they'd throw them all into a kitchen-sink fcntl() call * along the lines of ioctl(), the fact that ioctl() operations are * largely specific to particular character devices but fcntl() operations * are either generic to all descriptors or generic to all descriptors for * regular files nonwithstanding. * * The Capsicum people decided that fine-grained control of descriptor * operations was required, so that you need to grant permission for * reading, writing, seeking, and fcntl-ing. The latter, courtesy of * AT&T's decision, means that "fcntl-ing" isn't a thing, but a motley * collection of things, so there are *individual* fcntls for which * permission needs to be granted. * * The FreeBSD standard I/O people implemented some optimizations that * requires that the standard I/O routines be able to determine whether * the descriptor for the FILE * is open append-only or not; as that * descriptor could have come from an open() rather than an fopen(), * that requires that it be able to do an F_GETFL fcntl() to read * the O_ flags. * * Tcpdump uses ftell() to determine how much data has been written * to a file in order to, when used with -C, determine when it's time * to rotate capture files. ftell() therefore needs to do an lseek() * to find out the file offset and must, thanks to the aforementioned * optimization, also know whether the descriptor is open append-only * or not. * * The net result of all the above is that we need to grant CAP_SEEK, * CAP_WRITE, and CAP_FCNTL with the CAP_FCNTL_GETFL subcapability. * * Perhaps this is the universe's way of saying that either * * 1) there needs to be an fopenat() call and a pcap_dump_openat() call * using it, so that Capsicum-capable tcpdump wouldn't need to do * an fdopen() * * or * * 2) there needs to be a cap_fdopen() call in the FreeBSD standard * I/O library that knows what rights are needed by the standard * I/O library, based on the open mode, and assigns them, perhaps * with an additional argument indicating, for example, whether * seeking should be allowed, so that tcpdump doesn't need to know * what the standard I/O library happens to require this week. */ static void set_dumper_capsicum_rights(pcap_dumper_t *p) { int fd = fileno(pcap_dump_file(p)); cap_rights_t rights; cap_rights_init(&rights, CAP_SEEK, CAP_WRITE, CAP_FCNTL); if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) { error("unable to limit dump descriptor"); } if (cap_fcntls_limit(fd, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) { error("unable to limit dump descriptor fcntls"); } } #endif /* * Copy arg vector into a new buffer, concatenating arguments with spaces. */ static char * copy_argv(register char **argv) { register char **p; register u_int len = 0; char *buf; char *src, *dst; p = argv; if (*p == NULL) return 0; while (*p) len += strlen(*p++) + 1; buf = (char *)malloc(len); if (buf == NULL) error("copy_argv: malloc"); p = argv; dst = buf; while ((src = *p++) != NULL) { while ((*dst++ = *src++) != '\0') ; dst[-1] = ' '; } dst[-1] = '\0'; return buf; } /* * On Windows, we need to open the file in binary mode, so that * we get all the bytes specified by the size we get from "fstat()". * On UNIX, that's not necessary. O_BINARY is defined on Windows; * we define it as 0 if it's not defined, so it does nothing. */ #ifndef O_BINARY #define O_BINARY 0 #endif static char * read_infile(char *fname) { register int i, fd, cc; register char *cp; struct stat buf; fd = open(fname, O_RDONLY|O_BINARY); if (fd < 0) error("can't open %s: %s", fname, pcap_strerror(errno)); if (fstat(fd, &buf) < 0) error("can't stat %s: %s", fname, pcap_strerror(errno)); cp = malloc((u_int)buf.st_size + 1); if (cp == NULL) error("malloc(%d) for %s: %s", (u_int)buf.st_size + 1, fname, pcap_strerror(errno)); cc = read(fd, cp, (u_int)buf.st_size); if (cc < 0) error("read %s: %s", fname, pcap_strerror(errno)); if (cc != buf.st_size) error("short read %s (%d != %d)", fname, cc, (int)buf.st_size); close(fd); /* replace "# comment" with spaces */ for (i = 0; i < cc; i++) { if (cp[i] == '#') while (i < cc && cp[i] != '\n') cp[i++] = ' '; } cp[cc] = '\0'; return (cp); } #ifdef HAVE_PCAP_FINDALLDEVS static long parse_interface_number(const char *device) { long devnum; char *end; devnum = strtol(device, &end, 10); if (device != end && *end == '\0') { /* * It's all-numeric, but is it a valid number? */ if (devnum <= 0) { /* * No, it's not an ordinal. */ error("Invalid adapter index"); } return (devnum); } else { /* * It's not all-numeric; return -1, so our caller * knows that. */ return (-1); } } static char * find_interface_by_number(long devnum) { pcap_if_t *dev, *devlist; long i; char ebuf[PCAP_ERRBUF_SIZE]; char *device; if (pcap_findalldevs(&devlist, ebuf) < 0) error("%s", ebuf); /* * Look for the devnum-th entry in the list of devices (1-based). */ for (i = 0, dev = devlist; i < devnum-1 && dev != NULL; i++, dev = dev->next) ; if (dev == NULL) error("Invalid adapter index"); device = strdup(dev->name); pcap_freealldevs(devlist); return (device); } #endif static pcap_t * open_interface(const char *device, netdissect_options *ndo, char *ebuf) { pcap_t *pc; #ifdef HAVE_PCAP_CREATE int status; char *cp; #endif #ifdef HAVE_PCAP_CREATE pc = pcap_create(device, ebuf); if (pc == NULL) { /* * If this failed with "No such device", that means * the interface doesn't exist; return NULL, so that * the caller can see whether the device name is * actually an interface index. */ if (strstr(ebuf, "No such device") != NULL) return (NULL); error("%s", ebuf); } #ifdef HAVE_PCAP_SET_TSTAMP_TYPE if (Jflag) show_tstamp_types_and_exit(pc, device); #endif #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION status = pcap_set_tstamp_precision(pc, ndo->ndo_tstamp_precision); if (status != 0) error("%s: Can't set %ssecond time stamp precision: %s", device, tstamp_precision_to_string(ndo->ndo_tstamp_precision), pcap_statustostr(status)); #endif #ifdef HAVE_PCAP_SET_IMMEDIATE_MODE if (immediate_mode) { status = pcap_set_immediate_mode(pc, 1); if (status != 0) error("%s: Can't set immediate mode: %s", device, pcap_statustostr(status)); } #endif /* * Is this an interface that supports monitor mode? */ if (pcap_can_set_rfmon(pc) == 1) supports_monitor_mode = 1; else supports_monitor_mode = 0; status = pcap_set_snaplen(pc, ndo->ndo_snaplen); if (status != 0) error("%s: Can't set snapshot length: %s", device, pcap_statustostr(status)); status = pcap_set_promisc(pc, !pflag); if (status != 0) error("%s: Can't set promiscuous mode: %s", device, pcap_statustostr(status)); if (Iflag) { status = pcap_set_rfmon(pc, 1); if (status != 0) error("%s: Can't set monitor mode: %s", device, pcap_statustostr(status)); } status = pcap_set_timeout(pc, 1000); if (status != 0) error("%s: pcap_set_timeout failed: %s", device, pcap_statustostr(status)); if (Bflag != 0) { status = pcap_set_buffer_size(pc, Bflag); if (status != 0) error("%s: Can't set buffer size: %s", device, pcap_statustostr(status)); } #ifdef HAVE_PCAP_SET_TSTAMP_TYPE if (jflag != -1) { status = pcap_set_tstamp_type(pc, jflag); if (status < 0) error("%s: Can't set time stamp type: %s", device, pcap_statustostr(status)); + else if (status > 0) + warning("When trying to set timestamp type '%s' on %s: %s", + pcap_tstamp_type_val_to_name(jflag), device, + pcap_statustostr(status)); } #endif status = pcap_activate(pc); if (status < 0) { /* * pcap_activate() failed. */ cp = pcap_geterr(pc); if (status == PCAP_ERROR) error("%s", cp); else if (status == PCAP_ERROR_NO_SUCH_DEVICE) { /* * Return an error for our caller to handle. */ snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)", device, pcap_statustostr(status), cp); pcap_close(pc); return (NULL); } else if (status == PCAP_ERROR_PERM_DENIED && *cp != '\0') error("%s: %s\n(%s)", device, pcap_statustostr(status), cp); -#ifdef __FreeBSD__ - else if (status == PCAP_ERROR_RFMON_NOTSUP && - strncmp(device, "wlan", 4) == 0) { - char parent[8], newdev[8]; - char sysctl[32]; - size_t s = sizeof(parent); - - snprintf(sysctl, sizeof(sysctl), - "net.wlan.%d.%%parent", atoi(device + 4)); - sysctlbyname(sysctl, parent, &s, NULL, 0); - strlcpy(newdev, device, sizeof(newdev)); - /* Suggest a new wlan device. */ - /* FIXME: incrementing the index this way is not going to work well - * when the index is 9 or greater but the only consequence in this - * specific case would be an error message that looks a bit odd. - */ - newdev[strlen(newdev)-1]++; - error("%s is not a monitor mode VAP\n" - "To create a new monitor mode VAP use:\n" - " ifconfig %s create wlandev %s wlanmode monitor\n" - "and use %s as the tcpdump interface", - device, newdev, parent, newdev); - } -#endif else error("%s: %s", device, pcap_statustostr(status)); } else if (status > 0) { /* * pcap_activate() succeeded, but it's warning us * of a problem it had. */ cp = pcap_geterr(pc); if (status == PCAP_WARNING) warning("%s", cp); else if (status == PCAP_WARNING_PROMISC_NOTSUP && *cp != '\0') warning("%s: %s\n(%s)", device, pcap_statustostr(status), cp); else warning("%s: %s", device, pcap_statustostr(status)); } #ifdef HAVE_PCAP_SETDIRECTION if (Qflag != -1) { status = pcap_setdirection(pc, Qflag); if (status != 0) error("%s: pcap_setdirection() failed: %s", device, pcap_geterr(pc)); } #endif /* HAVE_PCAP_SETDIRECTION */ #else /* HAVE_PCAP_CREATE */ *ebuf = '\0'; pc = pcap_open_live(device, ndo->ndo_snaplen, !pflag, 1000, ebuf); if (pc == NULL) { /* * If this failed with "No such device", that means * the interface doesn't exist; return NULL, so that * the caller can see whether the device name is * actually an interface index. */ if (strstr(ebuf, "No such device") != NULL) return (NULL); error("%s", ebuf); } if (*ebuf) warning("%s", ebuf); #endif /* HAVE_PCAP_CREATE */ return (pc); } int main(int argc, char **argv) { register int cnt, op, i; bpf_u_int32 localnet =0 , netmask = 0; int timezone_offset = 0; register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName; pcap_handler callback; int dlt; const char *dlt_name; struct bpf_program fcode; #ifndef _WIN32 RETSIGTYPE (*oldhandler)(int); #endif struct dump_info dumpinfo; u_char *pcap_userdata; char ebuf[PCAP_ERRBUF_SIZE]; char VFileLine[PATH_MAX + 1]; char *username = NULL; char *chroot_dir = NULL; char *ret = NULL; char *end; #ifdef HAVE_PCAP_FINDALLDEVS pcap_if_t *devlist; long devnum; #endif int status; FILE *VFile; #ifdef HAVE_CAPSICUM cap_rights_t rights; int cansandbox; #endif /* HAVE_CAPSICUM */ int Oflag = 1; /* run filter code optimizer */ int yflag_dlt = -1; const char *yflag_dlt_name = NULL; netdissect_options Ndo; netdissect_options *ndo = &Ndo; /* * Initialize the netdissect code. */ if (nd_init(ebuf, sizeof ebuf) == -1) error("%s", ebuf); memset(ndo, 0, sizeof(*ndo)); ndo_set_function_pointers(ndo); ndo->ndo_snaplen = DEFAULT_SNAPLEN; cnt = -1; device = NULL; infile = NULL; RFileName = NULL; VFileName = NULL; VFile = NULL; WFileName = NULL; dlt = -1; if ((cp = strrchr(argv[0], '/')) != NULL) ndo->program_name = program_name = cp + 1; else ndo->program_name = program_name = argv[0]; #ifdef _WIN32 if (pcap_wsockinit() != 0) error("Attempting to initialize Winsock failed"); #endif /* _WIN32 */ /* * On platforms where the CPU doesn't support unaligned loads, * force unaligned accesses to abort with SIGBUS, rather than * being fixed up (slowly) by the OS kernel; on those platforms, * misaligned accesses are bugs, and we want tcpdump to crash so * that the bugs are reported. */ if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0) error("%s", ebuf); while ( (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1) switch (op) { case 'a': /* compatibility for old -a */ break; case 'A': ++ndo->ndo_Aflag; break; case 'b': ++ndo->ndo_bflag; break; #if defined(HAVE_PCAP_CREATE) || defined(_WIN32) case 'B': Bflag = atoi(optarg)*1024; if (Bflag <= 0) error("invalid packet buffer size %s", optarg); break; #endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */ case 'c': cnt = atoi(optarg); if (cnt <= 0) error("invalid packet count %s", optarg); break; case 'C': Cflag = atoi(optarg) * 1000000; if (Cflag <= 0) error("invalid file size %s", optarg); break; case 'd': ++dflag; break; case 'D': Dflag++; break; case 'L': Lflag++; break; case 'e': ++ndo->ndo_eflag; break; case 'E': #ifndef HAVE_LIBCRYPTO warning("crypto code not compiled in"); #endif ndo->ndo_espsecret = optarg; break; case 'f': ++ndo->ndo_fflag; break; case 'F': infile = optarg; break; case 'G': Gflag = atoi(optarg); if (Gflag < 0) error("invalid number of seconds %s", optarg); /* We will create one file initially. */ Gflag_count = 0; /* Grab the current time for rotation use. */ if ((Gflag_time = time(NULL)) == (time_t)-1) { error("main: can't get current time: %s", pcap_strerror(errno)); } break; case 'h': print_usage(); exit_tcpdump(0); break; case 'H': ++ndo->ndo_Hflag; break; case 'i': device = optarg; break; #ifdef HAVE_PCAP_CREATE case 'I': ++Iflag; break; #endif /* HAVE_PCAP_CREATE */ #ifdef HAVE_PCAP_SET_TSTAMP_TYPE case 'j': jflag = pcap_tstamp_type_name_to_val(optarg); if (jflag < 0) error("invalid time stamp type %s", optarg); break; case 'J': Jflag++; break; #endif case 'l': #ifdef _WIN32 /* * _IOLBF is the same as _IOFBF in Microsoft's C * libraries; the only alternative they offer * is _IONBF. * * XXX - this should really be checking for MSVC++, * not _WIN32, if, for example, MinGW has its own * C library that is more UNIX-compatible. */ setvbuf(stdout, NULL, _IONBF, 0); #else /* _WIN32 */ #ifdef HAVE_SETLINEBUF setlinebuf(stdout); #else setvbuf(stdout, NULL, _IOLBF, 0); #endif #endif /* _WIN32 */ break; case 'K': ++ndo->ndo_Kflag; break; case 'm': if (nd_have_smi_support()) { if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1) error("%s", ebuf); } else { (void)fprintf(stderr, "%s: ignoring option `-m %s' ", program_name, optarg); (void)fprintf(stderr, "(no libsmi support)\n"); } break; case 'M': /* TCP-MD5 shared secret */ #ifndef HAVE_LIBCRYPTO warning("crypto code not compiled in"); #endif ndo->ndo_sigsecret = optarg; break; case 'n': ++ndo->ndo_nflag; break; case 'N': ++ndo->ndo_Nflag; break; case 'O': Oflag = 0; break; case 'p': ++pflag; break; case 'q': ++ndo->ndo_qflag; ++ndo->ndo_suppress_default_print; break; #ifdef HAVE_PCAP_SETDIRECTION case 'Q': if (ascii_strcasecmp(optarg, "in") == 0) Qflag = PCAP_D_IN; else if (ascii_strcasecmp(optarg, "out") == 0) Qflag = PCAP_D_OUT; else if (ascii_strcasecmp(optarg, "inout") == 0) Qflag = PCAP_D_INOUT; else error("unknown capture direction `%s'", optarg); break; #endif /* HAVE_PCAP_SETDIRECTION */ case 'r': RFileName = optarg; break; case 's': ndo->ndo_snaplen = strtol(optarg, &end, 0); if (optarg == end || *end != '\0' || ndo->ndo_snaplen < 0 || ndo->ndo_snaplen > MAXIMUM_SNAPLEN) error("invalid snaplen %s", optarg); else if (ndo->ndo_snaplen == 0) ndo->ndo_snaplen = MAXIMUM_SNAPLEN; break; case 'S': ++ndo->ndo_Sflag; break; case 't': ++ndo->ndo_tflag; break; case 'T': if (ascii_strcasecmp(optarg, "vat") == 0) ndo->ndo_packettype = PT_VAT; else if (ascii_strcasecmp(optarg, "wb") == 0) ndo->ndo_packettype = PT_WB; else if (ascii_strcasecmp(optarg, "rpc") == 0) ndo->ndo_packettype = PT_RPC; else if (ascii_strcasecmp(optarg, "rtp") == 0) ndo->ndo_packettype = PT_RTP; else if (ascii_strcasecmp(optarg, "rtcp") == 0) ndo->ndo_packettype = PT_RTCP; else if (ascii_strcasecmp(optarg, "snmp") == 0) ndo->ndo_packettype = PT_SNMP; else if (ascii_strcasecmp(optarg, "cnfp") == 0) ndo->ndo_packettype = PT_CNFP; else if (ascii_strcasecmp(optarg, "tftp") == 0) ndo->ndo_packettype = PT_TFTP; else if (ascii_strcasecmp(optarg, "aodv") == 0) ndo->ndo_packettype = PT_AODV; else if (ascii_strcasecmp(optarg, "carp") == 0) ndo->ndo_packettype = PT_CARP; else if (ascii_strcasecmp(optarg, "radius") == 0) ndo->ndo_packettype = PT_RADIUS; else if (ascii_strcasecmp(optarg, "zmtp1") == 0) ndo->ndo_packettype = PT_ZMTP1; else if (ascii_strcasecmp(optarg, "vxlan") == 0) ndo->ndo_packettype = PT_VXLAN; else if (ascii_strcasecmp(optarg, "pgm") == 0) ndo->ndo_packettype = PT_PGM; else if (ascii_strcasecmp(optarg, "pgm_zmtp1") == 0) ndo->ndo_packettype = PT_PGM_ZMTP1; else if (ascii_strcasecmp(optarg, "lmp") == 0) ndo->ndo_packettype = PT_LMP; else if (ascii_strcasecmp(optarg, "resp") == 0) ndo->ndo_packettype = PT_RESP; else error("unknown packet type `%s'", optarg); break; case 'u': ++ndo->ndo_uflag; break; #ifdef HAVE_PCAP_DUMP_FLUSH case 'U': ++Uflag; break; #endif case 'v': ++ndo->ndo_vflag; break; case 'V': VFileName = optarg; break; case 'w': WFileName = optarg; break; case 'W': Wflag = atoi(optarg); if (Wflag <= 0) error("invalid number of output files %s", optarg); WflagChars = getWflagChars(Wflag); break; case 'x': ++ndo->ndo_xflag; ++ndo->ndo_suppress_default_print; break; case 'X': ++ndo->ndo_Xflag; ++ndo->ndo_suppress_default_print; break; case 'y': yflag_dlt_name = optarg; yflag_dlt = pcap_datalink_name_to_val(yflag_dlt_name); if (yflag_dlt < 0) error("invalid data link type %s", yflag_dlt_name); break; #ifdef HAVE_PCAP_SET_PARSER_DEBUG case 'Y': { /* Undocumented flag */ pcap_set_parser_debug(1); } break; #endif case 'z': zflag = optarg; break; case 'Z': username = optarg; break; case '#': ndo->ndo_packet_number = 1; break; case OPTION_VERSION: print_version(); exit_tcpdump(0); break; #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION case OPTION_TSTAMP_PRECISION: ndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg); if (ndo->ndo_tstamp_precision < 0) error("unsupported time stamp precision"); break; #endif #ifdef HAVE_PCAP_SET_IMMEDIATE_MODE case OPTION_IMMEDIATE_MODE: immediate_mode = 1; break; #endif default: print_usage(); exit_tcpdump(1); /* NOTREACHED */ } #ifdef HAVE_PCAP_FINDALLDEVS if (Dflag) show_devices_and_exit(); #endif switch (ndo->ndo_tflag) { case 0: /* Default */ case 4: /* Default + Date*/ timezone_offset = gmt2local(0); break; case 1: /* No time stamp */ case 2: /* Unix timeval style */ case 3: /* Microseconds since previous packet */ case 5: /* Microseconds since first packet */ break; default: /* Not supported */ error("only -t, -tt, -ttt, -tttt and -ttttt are supported"); break; } if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL)) error("-f can not be used with -V or -r"); if (VFileName != NULL && RFileName != NULL) error("-V and -r are mutually exclusive."); #ifdef HAVE_PCAP_SET_IMMEDIATE_MODE /* * If we're printing dissected packets to the standard output * rather than saving raw packets to a file, and the standard * output is a terminal, use immediate mode, as the user's * probably expecting to see packets pop up immediately. */ if (WFileName == NULL && isatty(1)) immediate_mode = 1; #endif #ifdef WITH_CHROOT /* if run as root, prepare for chrooting */ if (getuid() == 0 || geteuid() == 0) { /* future extensibility for cmd-line arguments */ if (!chroot_dir) chroot_dir = WITH_CHROOT; } #endif #ifdef WITH_USER /* if run as root, prepare for dropping root privileges */ if (getuid() == 0 || geteuid() == 0) { /* Run with '-Z root' to restore old behaviour */ if (!username) username = WITH_USER; } #endif if (RFileName != NULL || VFileName != NULL) { /* * If RFileName is non-null, it's the pathname of a * savefile to read. If VFileName is non-null, it's * the pathname of a file containing a list of pathnames * (one per line) of savefiles to read. * * In either case, we're reading a savefile, not doing * a live capture. */ #ifndef _WIN32 /* * We don't need network access, so relinquish any set-UID * or set-GID privileges we have (if any). * * We do *not* want set-UID privileges when opening a * trace file, as that might let the user read other * people's trace files (especially if we're set-UID * root). */ if (setgid(getgid()) != 0 || setuid(getuid()) != 0 ) fprintf(stderr, "Warning: setgid/setuid failed !\n"); #endif /* _WIN32 */ if (VFileName != NULL) { if (VFileName[0] == '-' && VFileName[1] == '\0') VFile = stdin; else VFile = fopen(VFileName, "r"); if (VFile == NULL) error("Unable to open file: %s\n", pcap_strerror(errno)); ret = get_next_file(VFile, VFileLine); if (!ret) error("Nothing in %s\n", VFileName); RFileName = VFileLine; } #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION pd = pcap_open_offline_with_tstamp_precision(RFileName, ndo->ndo_tstamp_precision, ebuf); #else pd = pcap_open_offline(RFileName, ebuf); #endif if (pd == NULL) error("%s", ebuf); #ifdef HAVE_CAPSICUM cap_rights_init(&rights, CAP_READ); if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 && errno != ENOSYS) { error("unable to limit pcap descriptor"); } #endif dlt = pcap_datalink(pd); dlt_name = pcap_datalink_val_to_name(dlt); if (dlt_name == NULL) { fprintf(stderr, "reading from file %s, link-type %u\n", RFileName, dlt); } else { fprintf(stderr, "reading from file %s, link-type %s (%s)\n", RFileName, dlt_name, pcap_datalink_val_to_description(dlt)); } } else { /* * We're doing a live capture. */ if (device == NULL) { /* * No interface was specified. Pick one. */ #ifdef HAVE_PCAP_FINDALLDEVS /* * Find the list of interfaces, and pick * the first interface. */ if (pcap_findalldevs(&devlist, ebuf) >= 0 && devlist != NULL) { device = strdup(devlist->name); pcap_freealldevs(devlist); } #else /* HAVE_PCAP_FINDALLDEVS */ /* * Use whatever interface pcap_lookupdev() * chooses. */ device = pcap_lookupdev(ebuf); #endif if (device == NULL) error("%s", ebuf); } /* * Try to open the interface with the specified name. */ pd = open_interface(device, ndo, ebuf); if (pd == NULL) { /* * That failed. If we can get a list of * interfaces, and the interface name * is purely numeric, try to use it as * a 1-based index in the list of * interfaces. */ #ifdef HAVE_PCAP_FINDALLDEVS devnum = parse_interface_number(device); if (devnum == -1) { /* * It's not a number; just report * the open error and fail. */ error("%s", ebuf); } /* * OK, it's a number; try to find the * interface with that index, and try * to open it. * * find_interface_by_number() exits if it * couldn't be found. */ device = find_interface_by_number(devnum); pd = open_interface(device, ndo, ebuf); if (pd == NULL) error("%s", ebuf); #else /* HAVE_PCAP_FINDALLDEVS */ /* * We can't get a list of interfaces; just * fail. */ error("%s", ebuf); #endif /* HAVE_PCAP_FINDALLDEVS */ } /* * Let user own process after socket has been opened. */ #ifndef _WIN32 if (setgid(getgid()) != 0 || setuid(getuid()) != 0) fprintf(stderr, "Warning: setgid/setuid failed !\n"); #endif /* _WIN32 */ #if !defined(HAVE_PCAP_CREATE) && defined(_WIN32) if(Bflag != 0) if(pcap_setbuff(pd, Bflag)==-1){ error("%s", pcap_geterr(pd)); } #endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */ if (Lflag) show_dlts_and_exit(pd, device); if (yflag_dlt >= 0) { #ifdef HAVE_PCAP_SET_DATALINK if (pcap_set_datalink(pd, yflag_dlt) < 0) error("%s", pcap_geterr(pd)); #else /* * We don't actually support changing the * data link type, so we only let them * set it to what it already is. */ if (yflag_dlt != pcap_datalink(pd)) { error("%s is not one of the DLTs supported by this device\n", yflag_dlt_name); } #endif (void)fprintf(stderr, "%s: data link type %s\n", program_name, yflag_dlt_name); (void)fflush(stderr); } i = pcap_snapshot(pd); if (ndo->ndo_snaplen < i) { warning("snaplen raised from %d to %d", ndo->ndo_snaplen, i); ndo->ndo_snaplen = i; } if(ndo->ndo_fflag != 0) { if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) { warning("foreign (-f) flag used but: %s", ebuf); } } } if (infile) cmdbuf = read_infile(infile); else cmdbuf = copy_argv(&argv[optind]); #ifdef HAVE_PCAP_SET_OPTIMIZER_DEBUG pcap_set_optimizer_debug(dflag); #endif if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) error("%s", pcap_geterr(pd)); if (dflag) { bpf_dump(&fcode, dflag); pcap_close(pd); free(cmdbuf); pcap_freecode(&fcode); exit_tcpdump(0); } init_print(ndo, localnet, netmask, timezone_offset); #ifndef _WIN32 (void)setsignal(SIGPIPE, cleanup); (void)setsignal(SIGTERM, cleanup); (void)setsignal(SIGINT, cleanup); #endif /* _WIN32 */ #if defined(HAVE_FORK) || defined(HAVE_VFORK) (void)setsignal(SIGCHLD, child_cleanup); #endif /* Cooperate with nohup(1) */ #ifndef _WIN32 if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL) (void)setsignal(SIGHUP, oldhandler); #endif /* _WIN32 */ #ifndef _WIN32 /* * If a user name was specified with "-Z", attempt to switch to * that user's UID. This would probably be used with sudo, * to allow tcpdump to be run in a special restricted * account (if you just want to allow users to open capture * devices, and can't just give users that permission, * you'd make tcpdump set-UID or set-GID). * * Tcpdump doesn't necessarily write only to one savefile; * the general only way to allow a -Z instance to write to * savefiles as the user under whose UID it's run, rather * than as the user specified with -Z, would thus be to switch * to the original user ID before opening a capture file and * then switch back to the -Z user ID after opening the savefile. * Switching to the -Z user ID only after opening the first * savefile doesn't handle the general case. */ if (getuid() == 0 || geteuid() == 0) { #ifdef HAVE_LIBCAP_NG /* Initialize capng */ capng_clear(CAPNG_SELECT_BOTH); if (username) { capng_updatev( CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE, CAP_SETUID, CAP_SETGID, -1); } if (chroot_dir) { capng_update( CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE, CAP_SYS_CHROOT ); } if (WFileName) { capng_update( CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE ); } capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ if (username || chroot_dir) droproot(username, chroot_dir); } #endif /* _WIN32 */ if (pcap_setfilter(pd, &fcode) < 0) error("%s", pcap_geterr(pd)); #ifdef HAVE_CAPSICUM if (RFileName == NULL && VFileName == NULL) { static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF }; /* * The various libpcap devices use a combination of * read (bpf), ioctl (bpf, netmap), poll (netmap) * so we add the relevant access rights. */ cap_rights_init(&rights, CAP_IOCTL, CAP_READ, CAP_EVENT); if (cap_rights_limit(pcap_fileno(pd), &rights) < 0 && errno != ENOSYS) { error("unable to limit pcap descriptor"); } if (cap_ioctls_limit(pcap_fileno(pd), cmds, sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) { error("unable to limit ioctls on pcap descriptor"); } } #endif if (WFileName) { pcap_dumper_t *p; /* Do not exceed the default PATH_MAX for files. */ dumpinfo.CurrentFileName = (char *)malloc(PATH_MAX + 1); if (dumpinfo.CurrentFileName == NULL) error("malloc of dumpinfo.CurrentFileName"); /* We do not need numbering for dumpfiles if Cflag isn't set. */ if (Cflag != 0) MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, WflagChars); else MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0); p = pcap_dump_open(pd, dumpinfo.CurrentFileName); #ifdef HAVE_LIBCAP_NG /* Give up CAP_DAC_OVERRIDE capability. * Only allow it to be restored if the -C or -G flag have been * set since we may need to create more files later on. */ capng_update( CAPNG_DROP, (Cflag || Gflag ? 0 : CAPNG_PERMITTED) | CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE ); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ if (p == NULL) error("%s", pcap_geterr(pd)); #ifdef HAVE_CAPSICUM set_dumper_capsicum_rights(p); #endif if (Cflag != 0 || Gflag != 0) { #ifdef HAVE_CAPSICUM dumpinfo.WFileName = strdup(basename(WFileName)); if (dumpinfo.WFileName == NULL) { error("Unable to allocate memory for file %s", WFileName); } dumpinfo.dirfd = open(dirname(WFileName), O_DIRECTORY | O_RDONLY); if (dumpinfo.dirfd < 0) { error("unable to open directory %s", dirname(WFileName)); } cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL, CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE); if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 && errno != ENOSYS) { error("unable to limit directory rights"); } if (cap_fcntls_limit(dumpinfo.dirfd, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) { error("unable to limit dump descriptor fcntls"); } #else /* !HAVE_CAPSICUM */ dumpinfo.WFileName = WFileName; #endif callback = dump_packet_and_trunc; dumpinfo.pd = pd; dumpinfo.p = p; pcap_userdata = (u_char *)&dumpinfo; } else { callback = dump_packet; pcap_userdata = (u_char *)p; } #ifdef HAVE_PCAP_DUMP_FLUSH if (Uflag) pcap_dump_flush(p); #endif } else { dlt = pcap_datalink(pd); ndo->ndo_if_printer = get_if_printer(ndo, dlt); callback = print_packet; pcap_userdata = (u_char *)ndo; } #ifdef SIGNAL_REQ_INFO /* * We can't get statistics when reading from a file rather * than capturing from a device. */ if (RFileName == NULL) (void)setsignal(SIGNAL_REQ_INFO, requestinfo); #endif if (ndo->ndo_vflag > 0 && WFileName) { /* * When capturing to a file, "-v" means tcpdump should, * every 10 seconds, "v"erbosely report the number of * packets captured. */ #ifdef USE_WIN32_MM_TIMER /* call verbose_stats_dump() each 1000 +/-100msec */ timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC); setvbuf(stderr, NULL, _IONBF, 0); #elif defined(HAVE_ALARM) (void)setsignal(SIGALRM, verbose_stats_dump); alarm(1); #endif } if (RFileName == NULL) { /* * Live capture (if -V was specified, we set RFileName * to a file from the -V file). Print a message to * the standard error on UN*X. */ if (!ndo->ndo_vflag && !WFileName) { (void)fprintf(stderr, "%s: verbose output suppressed, use -v or -vv for full protocol decode\n", program_name); } else (void)fprintf(stderr, "%s: ", program_name); dlt = pcap_datalink(pd); dlt_name = pcap_datalink_val_to_name(dlt); if (dlt_name == NULL) { (void)fprintf(stderr, "listening on %s, link-type %u, capture size %u bytes\n", device, dlt, ndo->ndo_snaplen); } else { (void)fprintf(stderr, "listening on %s, link-type %s (%s), capture size %u bytes\n", device, dlt_name, pcap_datalink_val_to_description(dlt), ndo->ndo_snaplen); } (void)fflush(stderr); } #ifdef HAVE_CAPSICUM cansandbox = (ndo->ndo_nflag && VFileName == NULL && zflag == NULL); if (cansandbox && cap_enter() < 0 && errno != ENOSYS) error("unable to enter the capability mode"); #endif /* HAVE_CAPSICUM */ do { status = pcap_loop(pd, cnt, callback, pcap_userdata); if (WFileName == NULL) { /* * We're printing packets. Flush the printed output, * so it doesn't get intermingled with error output. */ if (status == -2) { /* * We got interrupted, so perhaps we didn't * manage to finish a line we were printing. * Print an extra newline, just in case. */ putchar('\n'); } (void)fflush(stdout); } if (status == -2) { /* * We got interrupted. If we are reading multiple * files (via -V) set these so that we stop. */ VFileName = NULL; ret = NULL; } if (status == -1) { /* * Error. Report it. */ (void)fprintf(stderr, "%s: pcap_loop: %s\n", program_name, pcap_geterr(pd)); } if (RFileName == NULL) { /* * We're doing a live capture. Report the capture * statistics. */ info(1); } pcap_close(pd); if (VFileName != NULL) { ret = get_next_file(VFile, VFileLine); if (ret) { int new_dlt; RFileName = VFileLine; pd = pcap_open_offline(RFileName, ebuf); if (pd == NULL) error("%s", ebuf); #ifdef HAVE_CAPSICUM cap_rights_init(&rights, CAP_READ); if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 && errno != ENOSYS) { error("unable to limit pcap descriptor"); } #endif new_dlt = pcap_datalink(pd); if (new_dlt != dlt) { /* * The new file has a different * link-layer header type from the * previous one. */ if (WFileName != NULL) { /* * We're writing raw packets * that match the filter to * a pcap file. pcap files * don't support multiple * different link-layer * header types, so we fail * here. */ error("%s: new dlt does not match original", RFileName); } /* * We're printing the decoded packets; * switch to the new DLT. * * To do that, we need to change * the printer, change the DLT name, * and recompile the filter with * the new DLT. */ dlt = new_dlt; ndo->ndo_if_printer = get_if_printer(ndo, dlt); if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) error("%s", pcap_geterr(pd)); } /* * Set the filter on the new file. */ if (pcap_setfilter(pd, &fcode) < 0) error("%s", pcap_geterr(pd)); /* * Report the new file. */ dlt_name = pcap_datalink_val_to_name(dlt); if (dlt_name == NULL) { fprintf(stderr, "reading from file %s, link-type %u\n", RFileName, dlt); } else { fprintf(stderr, "reading from file %s, link-type %s (%s)\n", RFileName, dlt_name, pcap_datalink_val_to_description(dlt)); } } } } while (ret != NULL); free(cmdbuf); pcap_freecode(&fcode); exit_tcpdump(status == -1 ? 1 : 0); } /* make a clean exit on interrupts */ static RETSIGTYPE cleanup(int signo _U_) { #ifdef USE_WIN32_MM_TIMER if (timer_id) timeKillEvent(timer_id); timer_id = 0; #elif defined(HAVE_ALARM) alarm(0); #endif #ifdef HAVE_PCAP_BREAKLOOP /* * We have "pcap_breakloop()"; use it, so that we do as little * as possible in the signal handler (it's probably not safe * to do anything with standard I/O streams in a signal handler - * the ANSI C standard doesn't say it is). */ pcap_breakloop(pd); #else /* * We don't have "pcap_breakloop()"; this isn't safe, but * it's the best we can do. Print the summary if we're * not reading from a savefile - i.e., if we're doing a * live capture - and exit. */ if (pd != NULL && pcap_file(pd) == NULL) { /* * We got interrupted, so perhaps we didn't * manage to finish a line we were printing. * Print an extra newline, just in case. */ putchar('\n'); (void)fflush(stdout); info(1); } exit_tcpdump(0); #endif } /* On windows, we do not use a fork, so we do not care less about waiting a child processes to die */ #if defined(HAVE_FORK) || defined(HAVE_VFORK) static RETSIGTYPE child_cleanup(int signo _U_) { wait(NULL); } #endif /* HAVE_FORK && HAVE_VFORK */ static void info(register int verbose) { struct pcap_stat stats; /* * Older versions of libpcap didn't set ps_ifdrop on some * platforms; initialize it to 0 to handle that. */ stats.ps_ifdrop = 0; if (pcap_stats(pd, &stats) < 0) { (void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd)); infoprint = 0; return; } if (!verbose) fprintf(stderr, "%s: ", program_name); (void)fprintf(stderr, "%u packet%s captured", packets_captured, PLURAL_SUFFIX(packets_captured)); if (!verbose) fputs(", ", stderr); else putc('\n', stderr); (void)fprintf(stderr, "%u packet%s received by filter", stats.ps_recv, PLURAL_SUFFIX(stats.ps_recv)); if (!verbose) fputs(", ", stderr); else putc('\n', stderr); (void)fprintf(stderr, "%u packet%s dropped by kernel", stats.ps_drop, PLURAL_SUFFIX(stats.ps_drop)); if (stats.ps_ifdrop != 0) { if (!verbose) fputs(", ", stderr); else putc('\n', stderr); (void)fprintf(stderr, "%u packet%s dropped by interface\n", stats.ps_ifdrop, PLURAL_SUFFIX(stats.ps_ifdrop)); } else putc('\n', stderr); infoprint = 0; } #if defined(HAVE_FORK) || defined(HAVE_VFORK) #ifdef HAVE_FORK #define fork_subprocess() fork() #else #define fork_subprocess() vfork() #endif static void compress_savefile(const char *filename) { pid_t child; child = fork_subprocess(); if (child == -1) { fprintf(stderr, "compress_savefile: fork failed: %s\n", pcap_strerror(errno)); return; } if (child != 0) { /* Parent process. */ return; } /* * Child process. * Set to lowest priority so that this doesn't disturb the capture. */ #ifdef NZERO setpriority(PRIO_PROCESS, 0, NZERO - 1); #else setpriority(PRIO_PROCESS, 0, 19); #endif if (execlp(zflag, zflag, filename, (char *)NULL) == -1) fprintf(stderr, "compress_savefile: execlp(%s, %s) failed: %s\n", zflag, filename, pcap_strerror(errno)); #ifdef HAVE_FORK exit(1); #else _exit(1); #endif } #else /* HAVE_FORK && HAVE_VFORK */ static void compress_savefile(const char *filename) { fprintf(stderr, "compress_savefile failed. Functionality not implemented under your system\n"); } #endif /* HAVE_FORK && HAVE_VFORK */ static void dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) { struct dump_info *dump_info; ++packets_captured; ++infodelay; dump_info = (struct dump_info *)user; /* * XXX - this won't force the file to rotate on the specified time * boundary, but it will rotate on the first packet received after the * specified Gflag number of seconds. Note: if a Gflag time boundary * and a Cflag size boundary coincide, the time rotation will occur * first thereby cancelling the Cflag boundary (since the file should * be 0). */ if (Gflag != 0) { /* Check if it is time to rotate */ time_t t; /* Get the current time */ if ((t = time(NULL)) == (time_t)-1) { error("dump_and_trunc_packet: can't get current_time: %s", pcap_strerror(errno)); } /* If the time is greater than the specified window, rotate */ if (t - Gflag_time >= Gflag) { #ifdef HAVE_CAPSICUM FILE *fp; int fd; #endif /* Update the Gflag_time */ Gflag_time = t; /* Update Gflag_count */ Gflag_count++; /* * Close the current file and open a new one. */ pcap_dump_close(dump_info->p); /* * Compress the file we just closed, if the user asked for it */ if (zflag != NULL) compress_savefile(dump_info->CurrentFileName); /* * Check to see if we've exceeded the Wflag (when * not using Cflag). */ if (Cflag == 0 && Wflag > 0 && Gflag_count >= Wflag) { (void)fprintf(stderr, "Maximum file limit reached: %d\n", Wflag); info(1); exit_tcpdump(0); /* NOTREACHED */ } if (dump_info->CurrentFileName != NULL) free(dump_info->CurrentFileName); /* Allocate space for max filename + \0. */ dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1); if (dump_info->CurrentFileName == NULL) error("dump_packet_and_trunc: malloc"); /* * Gflag was set otherwise we wouldn't be here. Reset the count * so multiple files would end with 1,2,3 in the filename. * The counting is handled with the -C flow after this. */ Cflag_count = 0; /* * This is always the first file in the Cflag * rotation: e.g. 0 * We also don't need numbering if Cflag is not set. */ if (Cflag != 0) MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, WflagChars); else MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0); #ifdef HAVE_LIBCAP_NG capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ #ifdef HAVE_CAPSICUM fd = openat(dump_info->dirfd, dump_info->CurrentFileName, O_CREAT | O_WRONLY | O_TRUNC, 0644); if (fd < 0) { error("unable to open file %s", dump_info->CurrentFileName); } fp = fdopen(fd, "w"); if (fp == NULL) { error("unable to fdopen file %s", dump_info->CurrentFileName); } dump_info->p = pcap_dump_fopen(dump_info->pd, fp); #else /* !HAVE_CAPSICUM */ dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); #endif #ifdef HAVE_LIBCAP_NG capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ if (dump_info->p == NULL) error("%s", pcap_geterr(pd)); #ifdef HAVE_CAPSICUM set_dumper_capsicum_rights(dump_info->p); #endif } } /* * XXX - this won't prevent capture files from getting * larger than Cflag - the last packet written to the * file could put it over Cflag. */ if (Cflag != 0) { long size = pcap_dump_ftell(dump_info->p); if (size == -1) error("ftell fails on output file"); if (size > Cflag) { #ifdef HAVE_CAPSICUM FILE *fp; int fd; #endif /* * Close the current file and open a new one. */ pcap_dump_close(dump_info->p); /* * Compress the file we just closed, if the user * asked for it. */ if (zflag != NULL) compress_savefile(dump_info->CurrentFileName); Cflag_count++; if (Wflag > 0) { if (Cflag_count >= Wflag) Cflag_count = 0; } if (dump_info->CurrentFileName != NULL) free(dump_info->CurrentFileName); dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1); if (dump_info->CurrentFileName == NULL) error("dump_packet_and_trunc: malloc"); MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars); #ifdef HAVE_LIBCAP_NG capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ #ifdef HAVE_CAPSICUM fd = openat(dump_info->dirfd, dump_info->CurrentFileName, O_CREAT | O_WRONLY | O_TRUNC, 0644); if (fd < 0) { error("unable to open file %s", dump_info->CurrentFileName); } fp = fdopen(fd, "w"); if (fp == NULL) { error("unable to fdopen file %s", dump_info->CurrentFileName); } dump_info->p = pcap_dump_fopen(dump_info->pd, fp); #else /* !HAVE_CAPSICUM */ dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName); #endif #ifdef HAVE_LIBCAP_NG capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE); capng_apply(CAPNG_SELECT_BOTH); #endif /* HAVE_LIBCAP_NG */ if (dump_info->p == NULL) error("%s", pcap_geterr(pd)); #ifdef HAVE_CAPSICUM set_dumper_capsicum_rights(dump_info->p); #endif } } pcap_dump((u_char *)dump_info->p, h, sp); #ifdef HAVE_PCAP_DUMP_FLUSH if (Uflag) pcap_dump_flush(dump_info->p); #endif --infodelay; if (infoprint) info(0); } static void dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) { ++packets_captured; ++infodelay; pcap_dump(user, h, sp); #ifdef HAVE_PCAP_DUMP_FLUSH if (Uflag) pcap_dump_flush((pcap_dumper_t *)user); #endif --infodelay; if (infoprint) info(0); } static void print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp) { ++packets_captured; ++infodelay; pretty_print_packet((netdissect_options *)user, h, sp, packets_captured); --infodelay; if (infoprint) info(0); } #ifdef _WIN32 /* * XXX - there should really be libpcap calls to get the version * number as a string (the string would be generated from #defines * at run time, so that it's not generated from string constants * in the library, as, on many UNIX systems, those constants would * be statically linked into the application executable image, and * would thus reflect the version of libpcap on the system on * which the application was *linked*, not the system on which it's * *running*. * * That routine should be documented, unlike the "version[]" * string, so that UNIX vendors providing their own libpcaps * don't omit it (as a couple of vendors have...). * * Packet.dll should perhaps also export a routine to return the * version number of the Packet.dll code, to supply the * "Wpcap_version" information on Windows. */ char WDversion[]="current-git.tcpdump.org"; #if !defined(HAVE_GENERATED_VERSION) char version[]="current-git.tcpdump.org"; #endif char pcap_version[]="current-git.tcpdump.org"; char Wpcap_version[]="3.1"; #endif #ifdef SIGNAL_REQ_INFO RETSIGTYPE requestinfo(int signo _U_) { if (infodelay) ++infoprint; else info(0); } #endif /* * Called once each second in verbose mode while dumping to file */ #ifdef USE_WIN32_MM_TIMER void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_, DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_) { if (infodelay == 0) fprintf(stderr, "Got %u\r", packets_captured); } #elif defined(HAVE_ALARM) static void verbose_stats_dump(int sig _U_) { if (infodelay == 0) fprintf(stderr, "Got %u\r", packets_captured); alarm(1); } #endif USES_APPLE_DEPRECATED_API static void print_version(void) { extern char version[]; #ifndef HAVE_PCAP_LIB_VERSION #if defined(_WIN32) || defined(HAVE_PCAP_VERSION) extern char pcap_version[]; #else /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */ static char pcap_version[] = "unknown"; #endif /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */ #endif /* HAVE_PCAP_LIB_VERSION */ const char *smi_version_string; #ifdef HAVE_PCAP_LIB_VERSION #ifdef _WIN32 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version); #else /* _WIN32 */ (void)fprintf(stderr, "%s version %s\n", program_name, version); #endif /* _WIN32 */ (void)fprintf(stderr, "%s\n",pcap_lib_version()); #else /* HAVE_PCAP_LIB_VERSION */ #ifdef _WIN32 (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version); (void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version); #else /* _WIN32 */ (void)fprintf(stderr, "%s version %s\n", program_name, version); (void)fprintf(stderr, "libpcap version %s\n", pcap_version); #endif /* _WIN32 */ #endif /* HAVE_PCAP_LIB_VERSION */ #if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION) (void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION)); #endif smi_version_string = nd_smi_version_string(); if (smi_version_string != NULL) (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string); #if defined(__SANITIZE_ADDRESS__) (void)fprintf (stderr, "Compiled with AddressSanitizer/GCC.\n"); #elif defined(__has_feature) # if __has_feature(address_sanitizer) (void)fprintf (stderr, "Compiled with AddressSanitizer/CLang.\n"); # endif #endif /* __SANITIZE_ADDRESS__ or __has_feature */ } USES_APPLE_RST static void print_usage(void) { print_version(); (void)fprintf(stderr, "Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqStu" U_FLAG "vxX#]" B_FLAG_USAGE " [ -c count ]\n", program_name); (void)fprintf(stderr, "\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n"); (void)fprintf(stderr, "\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n"); #ifdef HAVE_PCAP_SETDIRECTION (void)fprintf(stderr, "\t\t[ -Q in|out|inout ]\n"); #endif (void)fprintf(stderr, "\t\t[ -r file ] [ -s snaplen ] "); #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION (void)fprintf(stderr, "[ --time-stamp-precision precision ]\n"); (void)fprintf(stderr, "\t\t"); #endif #ifdef HAVE_PCAP_SET_IMMEDIATE_MODE (void)fprintf(stderr, "[ --immediate-mode ] "); #endif (void)fprintf(stderr, "[ -T type ] [ --version ] [ -V file ]\n"); (void)fprintf(stderr, "\t\t[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]\n"); (void)fprintf(stderr, "\t\t[ -Z user ] [ expression ]\n"); } /* * Local Variables: * c-style: whitesmith * c-basic-offset: 8 * End: */ Index: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-2.out =================================================================== --- vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-2.out (revision 353143) +++ vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-2.out (nonexistent) @@ -1 +0,0 @@ -EXIT CODE 00000100 Index: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-1.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-1.pcap ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-2.pcap ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-1.out =================================================================== --- vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-1.out (revision 353143) +++ vendor/tcpdump/dist/tests/pcap-ng-invalid-vers-1.out (nonexistent) @@ -1 +0,0 @@ -EXIT CODE 00000100 Index: vendor/tcpdump/dist/tests/SMBLIST =================================================================== --- vendor/tcpdump/dist/tests/SMBLIST (nonexistent) +++ vendor/tcpdump/dist/tests/SMBLIST (revision 353144) @@ -0,0 +1,12 @@ +# bad packets from Otto Airamo and Antti Levomäki +nbns-valgrind nbns-valgrind.pcap nbns-valgrind.out -vvv -e + +smb_print_trans-oobr1 smb_print_trans-oobr1.pcapng smb_print_trans-oobr1.out -vv -c4 +# bad packets from Philippe Antoine +smb_print_trans-oobr2 smb_print_trans-oobr2.pcap smb_print_trans-oobr2.out -vv -c1 + +# CVE-2018-10105 bad packets from Luis Rocha +cve-2018-10105_smbprint-readofsize1 cve-2018-10105_smbprint-readofsize1.pcap cve-2018-10105_smbprint-readofsize1.out -vvv +cve-2018-10105_smbutil_withoutasan cve-2018-10105_smbutil_withoutasan.pcap cve-2018-10105_smbutil_withoutasan.out -vvv + + Index: vendor/tcpdump/dist/tests/TESTLIST =================================================================== --- vendor/tcpdump/dist/tests/TESTLIST (revision 353143) +++ vendor/tcpdump/dist/tests/TESTLIST (revision 353144) @@ -1,605 +1,643 @@ # The options -n and -t are useless in TESTLIST. They are already set # in TESTonce. # Various flags applied to a TCP session. # # We cannot rely on, for example, "print-x.out" and # "print-X.out" being different files - we might be running # this on a case-insensitive file system, e.g. a Windows # file system or a case-insensitive HFS+ file system on # Mac OS X. # # Therefore, for "X" and "XX", we have "print-capX.out" # and "print-capXX.out". # print-x print-flags.pcap print-x.out -x print-xx print-flags.pcap print-xx.out -xx print-X print-flags.pcap print-capX.out -X print-XX print-flags.pcap print-capXX.out -XX print-A print-flags.pcap print-A.out -A print-AA print-flags.pcap print-AA.out -AA # BGP tests bgp_vpn_attrset bgp_vpn_attrset.pcap bgp_vpn_attrset.out -v mpbgp-linklocal-nexthop mpbgp-linklocal-nexthop.pcap mpbgp-linklocal-nexthop.out -v bgp_infloop-v bgp-infinite-loop.pcap bgp_infloop-v.out -v bgp-aigp bgp-aigp.pcap bgp-aigp.out -v bgp-large-community bgp-large-community.pcap bgp-large-community.out -v -# EAP tests -eapon1 eapon1.pcap eapon1.out +# EAP tests. eapon1.pcap has NBT packets mixed in, eapon2.pcap removes them. +eapon2 eapon2.pcap eapon2.out # ESP tests esp0 02-sunrise-sunset-esp.pcap esp0.out # more ESP tests in crypto.sh # ISAKMP tests isakmp1 isakmp-delete-segfault.pcap isakmp1.out isakmp2 isakmp-pointer-loop.pcap isakmp2.out isakmp3 isakmp-identification-segfault.pcap isakmp3.out -v # isakmp4 is in crypto.sh isakmp5-v ISAKMP_sa_setup.pcap isakmp5-v.out -v # Link Management Protocol tests lmp lmp.pcap lmp.out -T lmp # lmp-v is now conditionally handled by lmp-v.sh # MPLS tests mpls-ldp-hello mpls-ldp-hello.pcap mpls-ldp-hello.out -v ldp_infloop ldp-infinite-loop.pcap ldp_infloop.out lspping-fec-ldp lspping-fec-ldp.pcap lspping-fec-ldp.out lspping-fec-ldp-v lspping-fec-ldp.pcap lspping-fec-ldp-v.out -v lspping-fec-ldp-vv lspping-fec-ldp.pcap lspping-fec-ldp-vv.out -vv lspping-fec-rsvp lspping-fec-rsvp.pcap lspping-fec-rsvp.out lspping-fec-rsvp-v lspping-fec-rsvp.pcap lspping-fec-rsvp-v.out -v lspping-fec-rsvp-vv lspping-fec-rsvp.pcap lspping-fec-rsvp-vv.out -vv mpls-traceroute mpls-traceroute.pcap mpls-traceroute.out mpls-traceroute-v mpls-traceroute.pcap mpls-traceroute-v.out -v # OSPF tests ospf-gmpls ospf-gmpls.pcap ospf-gmpls.out -v ospf3_ah-vv OSPFv3_with_AH.pcap ospf3_ah-vv.out -v -v ospf3_auth-vv ospf3_auth.pcap ospf3_auth-vv.out -v -v ospf3_bc-vv OSPFv3_broadcast_adjacency.pcap ospf3_bc-vv.out -v -v ospf3_mp-vv OSPFv3_multipoint_adjacencies.pcap ospf3_mp-vv.out -v -v ospf3_nbma-vv OSPFv3_NBMA_adjacencies.pcap ospf3_nbma-vv.out -v -v # fuzzed pcap ospf2-seg-fault-1-v ospf2-seg-fault-1.pcap ospf2-seg-fault-1-v.out -v # IKEv2 tests ikev2four ikev2four.pcap ikev2four.out -v ikev2fourv ikev2four.pcap ikev2fourv.out -v -v -v ikev2fourv4 ikev2four.pcap ikev2fourv4.out -v -v -v -v # ikev2pI2 test in crypto.sh ikev2pI2-segfault ikev2pI2-segfault.pcap ikev2pI2-segfault.out ikev2pI2-segfault-v ikev2pI2-segfault.pcap ikev2pI2-segfault-v.out -v # IETF ROLL RPL packets dio02 rpl-19-pickdag.pcap rpl-19-pickdag.out -v -v dio03 rpl-19-pickdag.pcap rpl-19-pickdagvvv.out -v -v -v dao01 rpl-14-dao.pcap rpl-14-daovvv.out -v -v -v daoack01 rpl-26-senddaoack.pcap rpl-26-senddaovv.out -v -v -v # IPNET encapsulated site e1000g e1000g.pcap e1000g.out # IETF FORCES WG packets and printer forces01 forces1.pcap forces1.out forces01vvv forces1.pcap forces1vvv.out -v -v -v forces01vvvv forces1.pcap forces1vvvv.out -v -v -v -v # need new pcap file, not sure what the differences were? #forces02 forces2.pcap forces2.out #forces02v forces2.pcap forces2v.out -v #forces02vv forces2.pcap forces2vv.out -v -v # 802.1ad, QinQ tests qinq QinQpacket.pcap QinQpacket.out -e qinqv QinQpacket.pcap QinQpacketv.out -e -v # now SFLOW tests sflow1 sflow_multiple_counter_30_pdus.pcap sflow_multiple_counter_30_pdus.out -v sflow2 sflow_multiple_counter_30_pdus.pcap sflow_multiple_counter_30_pdus-nv.out # AHCP and Babel tests ahcp-vv ahcp.pcap ahcp-vv.out -vv babel1 babel.pcap babel1.out babel1v babel.pcap babel1v.out -v babel_auth babel_auth.pcap babel_auth.out -v babel_pad1 babel_pad1.pcap babel_pad1.out babel_rtt babel_rtt.pcap babel_rtt.out -v # PPPoE tests pppoe pppoe.pcap pppoe.out pppoes pppoes.pcap pppoes.out pppoes_id pppoes.pcap pppoes_id.out pppoes 0x3b # PPP tests truncated_aack truncated-aack.pcap trunc_aack.out # IGMP tests igmpv1 IGMP_V1.pcap igmpv1.out igmpv2 IGMP_V2.pcap igmpv2.out igmpv3-queries igmpv3-queries.pcap igmpv3-queries.out mtrace mtrace.pcap mtrace.out dvmrp mrinfo_query.pcap dvmrp.out # ICMPv6 icmpv6 icmpv6.pcap icmpv6.out -vv icmpv6_opt24-v icmpv6_opt24.pcap icmpv6_opt24-v.out -v # SPB tests spb spb.pcap spb.out # SPB BPDUv4 tests spb_bpduv4 spb_bpduv4.pcap spb_bpduv4.out spb_bpduv4-v spb_bpduv4.pcap spb_bpduv4-v.out -v # DCB Tests dcb_ets dcb_ets.pcap dcb_ets.out -vv dcb_pfc dcb_pfc.pcap dcb_pfc.out -vv dcb_qcn dcb_qcn.pcap dcb_qcn.out -vv # EVB tests evb evb.pcap evb.out -vv # STP tests mstp-v MSTP_Intra-Region_BPDUs.pcap mstp-v.out -v stp-v 802.1D_spanning_tree.pcap stp-v.out -v rstp-v 802.1w_rapid_STP.pcap rstp-v.out -v rpvst-v rpvstp-trunk-native-vid5.pcap rpvst-v.out -v # RIP tests ripv1v2 ripv1v2.pcap ripv1v2.out -v ripv2_auth ripv2_auth.pcap ripv2_auth.out -v # DHCPv6 tests dhcpv6-aftr-name dhcpv6-AFTR-Name-RFC6334.pcap dhcpv6-AFTR-Name-RFC6334.out -v dhcpv6-ia-na dhcpv6-ia-na.pcap dhcpv6-ia-na.out -v dhcpv6-ia-pd dhcpv6-ia-pd.pcap dhcpv6-ia-pd.out -v dhcpv6-ia-ta dhcpv6-ia-ta.pcap dhcpv6-ia-ta.out -v dhcpv6-ntp-server dhcpv6-ntp-server.pcap dhcpv6-ntp-server.out -v dhcpv6-sip-server-d dhcpv6-sip-server-d.pcap dhcpv6-sip-server-d.out -v dhcpv6-domain-list dhcpv6-domain-list.pcap dhcpv6-domain-list.out -v dhcpv6-mud dhcpv6-mud.pcap dhcpv6-mud.out -vv # ZeroMQ/PGM tests # ZMTP/1.0 over TCP zmtp1v zmtp1.pcap zmtp1.out -v -T zmtp1 # native PGM pgmv pgm_zmtp1.pcap pgmv.out -v # UDP-encapsulated PGM epgmv epgm_zmtp1.pcap epgmv.out -v -T pgm # ZMTP/1.0 inside native PGM pgm_zmtp1v pgm_zmtp1.pcap pgm_zmtp1v.out -v -T pgm_zmtp1 # ZMTP/1.0 inside UDP-encapsulated PGM epgm_zmtp1v epgm_zmtp1.pcap epgm_zmtp1v.out -v -T pgm_zmtp1 # fuzzed pcap zmtp1-inf-loop-1 zmtp1-inf-loop-1.pcap zmtp1-inf-loop-1.out -T zmtp1 # MS NLB tests msnlb msnlb.pcap msnlb.out msnlb2 msnlb2.pcap msnlb2.out # MPTCP tests mptcp mptcp.pcap mptcp.out mptcp-fclose mptcp-fclose.pcap mptcp-fclose.out # TFO tests tfo tfo-5c1fa7f9ae91.pcap tfo.out # SCPS scps_invalid scps_invalid.pcap scps_invalid.out # IEEE 802.11 tests 802.11_exthdr ieee802.11_exthdr.pcap ieee802.11_exthdr.out -v 802.11_rx-stbc ieee802.11_rx-stbc.pcap ieee802.11_rx-stbc.out # OpenFlow tests of10_p3295-vv of10_p3295.pcap of10_p3295-vv.out -vv of10_s4810-vvvv of10_s4810.pcap of10_s4810-vvvv.out -vvvv of10_pf5240-vv of10_pf5240.pcap of10_pf5240-vv.out -vv of10_7050q-v of10_7050q.pcap of10_7050q-v.out -v of10_7050sx_bsn-vv of10_7050sx_bsn.pcap of10_7050sx_bsn-vv.out -vv +of10_7050sx_bsn-oobr of10_7050sx_bsn-oobr.pcap of10_7050sx_bsn-oobr.out -v # GeoNetworking and CALM FAST tests geonet-calm-fast geonet_and_calm_fast.pcap geonet_and_calm_fast.out -vv # M3UA tests m3ua isup.pcap isup.out m3ua-vv isup.pcap isupvv.out -vv # NFLOG test case moved to nflog-e.sh # syslog test case syslog-v syslog_udp.pcap syslog-v.out -v # DNSSEC from https://bugzilla.redhat.com/show_bug.cgi?id=205842, -vv exposes EDNS DO dnssec-vv dnssec.pcap dnssec-vv.out -vv #IPv6 tests ipv6-bad-version ipv6-bad-version.pcap ipv6-bad-version.out ipv6-routing-header ipv6-routing-header.pcap ipv6-routing-header.out -v # Loopback/CTP test case loopback loopback.pcap loopback.out # DCCP partial checksums tests dccp_partial_csum_v4_simple dccp_partial_csum_v4_simple.pcap dccp_partial_csum_v4_simple.out -vv dccp_partial_csum_v4_longer dccp_partial_csum_v4_longer.pcap dccp_partial_csum_v4_longer.out -vv dccp_partial_csum_v6_simple dccp_partial_csum_v6_simple.pcap dccp_partial_csum_v6_simple.out -vv dccp_partial_csum_v6_longer dccp_partial_csum_v6_longer.pcap dccp_partial_csum_v6_longer.out -vv # VRRP tests vrrp vrrp.pcap vrrp.out vrrp-v vrrp.pcap vrrp-v.out -v # HSRP tests hsrp_1 HSRP_coup.pcap hsrp_1.out hsrp_1-v HSRP_coup.pcap hsrp_1-v.out -v hsrp_2-v HSRP_election.pcap hsrp_2-v.out -v hsrp_3-v HSRP_failover.pcap hsrp_3-v.out -v # PIMv2 tests pimv2_dm-v PIM-DM_pruning.pcap pimv2_dm-v.out -v pimv2_register-v PIM_register_register-stop.pcap pimv2_register-v.out -v pimv2_sm-v PIM-SM_join_prune.pcap pimv2_sm-v.out -v pimv2_bootstrap-v PIMv2_bootstrap.pcap pimv2_bootstrap-v.out -v pimv2_hellos-v PIMv2_hellos.pcap pimv2_hellos-v.out -v # IS-IS tests isis_infloop-v isis-infinite-loop.pcap isis_infloop-v.out -v isis_poi-v isis_poi.pcap isis_poi.out -v isis_poi2-v isis_poi2.pcap isis_poi2.out -v isis_1 ISIS_external_lsp.pcap isis_1.out isis_1-v ISIS_external_lsp.pcap isis_1-v.out -v isis_2-v ISIS_level1_adjacency.pcap isis_2-v.out -v isis_3-v ISIS_level2_adjacency.pcap isis_3-v.out -v isis_4-v ISIS_p2p_adjacency.pcap isis_4-v.out -v # fuzzed pcap # isis-seg-fault-1-v is now conditionally handled by isis-seg-fault-1-v.sh isis-seg-fault-2-v isis-seg-fault-2.pcap isis-seg-fault-2-v.out -v isis-seg-fault-3-v isis-seg-fault-3.pcap isis-seg-fault-3-v.out -v # RSVP tests rsvp_infloop-v rsvp-infinite-loop.pcap rsvp_infloop-v.out -v # fuzzed pcap rsvp-inf-loop-2-v rsvp-inf-loop-2.pcap rsvp-inf-loop-2-v.out -v # HDLC tests hdlc1 chdlc-slarp.pcap hdlc1.out hdlc2 chdlc-slarp-short.pcap hdlc2.out hdlc3 HDLC.pcap hdlc3.out hdlc4 hdlc_slarp.pcap hdlc4.out # DECnet test case decnet DECnet_Phone.pcap decnet.out # RADIUS tests radius-v RADIUS.pcap radius-v.out -v radius-rfc4675 RADIUS-RFC4675.pcap radius-rfc4675-v.out -v radius-rfc5176 RADIUS-RFC5176.pcap radius-rfc5176-v.out -v radius-port1700 RADIUS-port1700.pcap radius-port1700-v.out -v # link-level protocols dtp-v DTP.pcap dtp-v.out -v lacp-ev LACP.pcap lacp-ev.out -e -v lldp_cdp-ev LLDP_and_CDP.pcap lldp_cdp-ev.out -e -v cdp-v 3560_CDP.pcap cdp-v.out -v udld-v UDLD.pcap udld-v.out -v lldp_mud-v lldp_mudurl.pcap lldp_mudurl-v.out -e -v lldp_mud-vv lldp_mudurl.pcap lldp_mudurl-vv.out -e -vv # fuzzed pcap udld-inf-loop-1-v udld-inf-loop-1.pcap udld-inf-loop-1-v.out -v # EIGRP tests eigrp1-v EIGRP_adjacency.pcap eigrp1-v.out -v eigrp2-v EIGRP_goodbye.pcap eigrp2-v.out -v eigrp3-v EIGRP_subnet_down.pcap eigrp3-v.out -v eigrp4-v EIGRP_subnet_up.pcap eigrp4-v.out -v # ATA-over-Ethernet tests aoe_1 AoE_Linux.pcap aoe_1.out aoe_1-v AoE_Linux.pcap aoe_1-v.out -v # Geneve tests geneve-v geneve.pcap geneve-vv.out -vv geneve-vni geneve.pcap geneve-vni.out geneve 0xb geneve-tcp geneve.pcap geneve-tcp.out "geneve && tcp" # DHCP tests dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -v dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -v dhcp-mud dhcp-mud.pcap dhcp-mud.out -vv # MEDSA tests medsa medsa.pcap medsa.out medsa-e medsa.pcap medsa-e.out -e # VXLAN tests vxlan vxlan.pcap vxlan.out -# -e # CVEs 2014 malformed packets from Steffen Bauch cve-2014-8767-OLSR cve-2014-8767-OLSR.pcap cve-2014-8767-OLSR.out -v cve-2014-8768-Geonet cve-2014-8768-Geonet.pcap cve-2014-8768-Geonet.out -v cve-2014-8769-AODV cve-2014-8769-AODV.pcap cve-2014-8769-AODV.out -v # bad packets from Kevin Day # cve-2015-2155 -- fuzz testing on FORCES printer kday1 kday1.pcap kday1.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday2 kday2.pcap kday2.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday3 kday3.pcap kday3.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday4 kday4.pcap kday4.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday5 kday5.pcap kday5.out -v # cve-2015-2154 -- ethernet printer kday6 kday6.pcap kday6.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday7 kday7.pcap kday7.out -v # cve-2015-2153 -- fuzz testing on TCP printer kday8 kday8.pcap kday8.out -v # bad packets from reversex86. cve2015-0261_01 cve2015-0261-ipv6.pcap cve2015-0261-ipv6.out -v cve2015-0261_02 cve2015-0261-crash.pcap cve2015-0261-crash.out -v # OLSRv1 tests olsrv1_1 OLSRv1_HNA_sgw_1.pcap OLSRv1_HNA_sgw_1.out -v # tests with unaligned data, to make sure they work on SPARC unaligned-nfs-1 unaligned-nfs-1.pcap unaligned-nfs-1.out -v # LISP tests lisp_eid_notify lisp_eid_notify.pcap lisp_eid_notify.out -v lisp_eid_register lisp_eid_register.pcap lisp_eid_register.out -v lisp_ipv6_eid lisp_ipv6.pcap lisp_ipv6.out -v # pcap invalid versions (first: version = 1.4 ; second: version = 2.5) pcap-invalid-version-1 pcap-invalid-version-1.pcap pcap-invalid-version-1.out pcap-invalid-version-2 pcap-invalid-version-2.pcap pcap-invalid-version-2.out -# pcap-ng invalid version (first: version = 0.1 ; second: version = 1.1) -pcap-ng-invalid-vers-1 pcap-ng-invalid-vers-1.pcap pcap-ng-invalid-vers-1.out -pcap-ng-invalid-vers-2 pcap-ng-invalid-vers-2.pcap pcap-ng-invalid-vers-2.out +# pcapng invalid version (first: version = 0.1 ; second: version = 1.1) +pcapng-invalid-vers-1 pcapng-invalid-vers-1.pcapng pcapng-invalid-vers-1.out +pcapng-invalid-vers-2 pcapng-invalid-vers-2.pcapng pcapng-invalid-vers-2.out # NSH over VxLAN-GPE nsh-over-vxlan-gpe nsh-over-vxlan-gpe.pcap nsh-over-vxlan-gpe.out nsh-over-vxlan-gpe-v nsh-over-vxlan-gpe.pcap nsh-over-vxlan-gpe-v.out -v nsh-over-vxlan-gpe-vv nsh-over-vxlan-gpe.pcap nsh-over-vxlan-gpe-vv.out -vv nsh-over-vxlan-gpe-vvv nsh-over-vxlan-gpe.pcap nsh-over-vxlan-gpe-vvv.out -vvv # RESP tests resp_1 resp_1_benchmark.pcap resp_1.out resp_2 resp_2_inline.pcap resp_2.out resp_3 resp_3_malicious.pcap resp_3.out # HNCP tests hncp hncp.pcap hncp.out -vvv # BFD tests with authentication fields bfd-raw-auth-simple bfd-raw-auth-simple.pcap bfd-raw-auth-simple.out bfd-raw-auth-simple-v bfd-raw-auth-simple.pcap bfd-raw-auth-simple-v.out -v bfd-raw-auth-md5 bfd-raw-auth-md5.pcap bfd-raw-auth-md5.out bfd-raw-auth-md5-v bfd-raw-auth-md5.pcap bfd-raw-auth-md5-v.out -v bfd-raw-auth-sha1 bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1.out bfd-raw-auth-sha1-v bfd-raw-auth-sha1.pcap bfd-raw-auth-sha1-v.out -v # bad packets from Hanno Böck heap-overflow-1 heap-overflow-1.pcap heap-overflow-1.out -v heap-overflow-2 heap-overflow-2.pcap heap-overflow-2.out -v heapoverflow-atalk_print heapoverflow-atalk_print.pcap heapoverflow-atalk_print.out -v heapoverflow-EXTRACT_16BITS heapoverflow-EXTRACT_16BITS.pcap heapoverflow-EXTRACT_16BITS.out -v heapoverflow-ppp_hdlc_if_print heapoverflow-ppp_hdlc_if_print.pcap heapoverflow-ppp_hdlc_if_print.out -v heapoverflow-q933_printq heapoverflow-q933_printq.pcap heapoverflow-q933_printq.out -v heapoverflow-sl_if_print heapoverflow-sl_if_print.pcap heapoverflow-sl_if_print.out -v heapoverflow-ip_print_demux heapoverflow-ip_print_demux.pcap heapoverflow-ip_print_demux.out -v heapoverflow-in_checksum heapoverflow-in_checksum.pcap heapoverflow-in_checksum.out -v heapoverflow-tcp_print heapoverflow-tcp_print.pcap heapoverflow-tcp_print.out -v gre-heapoverflow-1 gre-heapoverflow-1.pcap gre-heapoverflow-1.out -v gre-heapoverflow-2 gre-heapoverflow-2.pcap gre-heapoverflow-2.out -v calm-fast-mac-lookup-heapoverflow calm-fast-mac-lookup-heapoverflow.pcap calm-fast-mac-lookup-heapoverflow.out -v geonet-mac-lookup-heapoverflow geonet-mac-lookup-heapoverflow.pcap geonet-mac-lookup-heapoverflow.out -v radiotap-heapoverflow radiotap-heapoverflow.pcap radiotap-heapoverflow.out -v isoclns-heapoverflow isoclns-heapoverflow.pcap isoclns-heapoverflow.out -v tcp-auth-heapoverflow tcp-auth-heapoverflow.pcap tcp-auth-heapoverflow.out -v frf15-heapoverflow frf15-heapoverflow.pcap frf15-heapoverflow.out -v atm-oam-heapoverflow atm-oam-heapoverflow.pcap atm-oam-heapoverflow.out -v tcp_header_heapoverflow tcp_header_heapoverflow.pcap tcp_header_heapoverflow.out -v ipcomp-heapoverflow ipcomp-heapoverflow.pcap ipcomp-heapoverflow.out -v llc-xid-heapoverflow llc-xid-heapoverflow.pcap llc-xid-heapoverflow.out -v udp-length-heapoverflow udp-length-heapoverflow.pcap udp-length-heapoverflow.out -v aarp-heapoverflow-1 aarp-heapoverflow-1.pcap aarp-heapoverflow-1.out -v aarp-heapoverflow-2 aarp-heapoverflow-2.pcap aarp-heapoverflow-2.out -v mpls-label-heapoverflow mpls-label-heapoverflow.pcap mpls-label-heapoverflow.out -v bad-ipv4-version-pgm-heapoverflow bad-ipv4-version-pgm-heapoverflow.pcap bad-ipv4-version-pgm-heapoverflow.out -v stp-heapoverflow-1 stp-heapoverflow-1.pcap stp-heapoverflow-1.out -v stp-heapoverflow-2 stp-heapoverflow-2.pcap stp-heapoverflow-2.out -v stp-heapoverflow-3 stp-heapoverflow-3.pcap stp-heapoverflow-3.out -v stp-heapoverflow-4 stp-heapoverflow-4.pcap stp-heapoverflow-4.out -v stp-heapoverflow-5 stp-heapoverflow-5.pcap stp-heapoverflow-5.out -v arp-too-long-tha arp-too-long-tha.pcap arp-too-long-tha.out -v juniper_header-heapoverflow juniper_header-heapoverflow.pcap juniper_header-heapoverflow.out -v tftp-heapoverflow tftp-heapoverflow.pcap tftp-heapoverflow.out -v relts-0x80000000 relts-0x80000000.pcap relts-0x80000000.out -v # bad packets from Brian Carpenter ipv6hdr-heapoverflow ipv6hdr-heapoverflow.pcap ipv6hdr-heapoverflow.out ipv6hdr-heapoverflow-v ipv6hdr-heapoverflow.pcap ipv6hdr-heapoverflow-v.out -v otv-heapoverflow-1 otv-heapoverflow-1.pcap otv-heapoverflow-1.out -c10 otv-heapoverflow-2 otv-heapoverflow-2.pcap otv-heapoverflow-2.out -c10 q933-heapoverflow-2 q933-heapoverflow-2.pcap q933-heapoverflow-2.out atm-heapoverflow atm-heapoverflow.pcap atm-heapoverflow.out -c1 -e ipv6-next-header-oobr-1 ipv6-next-header-oobr-1.pcap ipv6-next-header-oobr-1.out ipv6-next-header-oobr-2 ipv6-next-header-oobr-2.pcap ipv6-next-header-oobr-2.out ipv6-rthdr-oobr ipv6-rthdr-oobr.pcap ipv6-rthdr-oobr.out ieee802.11_tim_ie_oobr ieee802.11_tim_ie_oobr.pcap ieee802.11_tim_ie_oobr.out decnet-shorthdr-oobr decnet-shorthdr-oobr.pcap decnet-shorthdr-oobr.out isakmp-3948-oobr-2 isakmp-3948-oobr-2.pcap isakmp-3948-oobr-2.out ieee802.11_rates_oobr ieee802.11_rates_oobr.pcap ieee802.11_rates_oobr.out ipv6-mobility-header-oobr ipv6-mobility-header-oobr.pcap ipv6-mobility-header-oobr.out beep-oobr beep-oobr.pcap beep-oobr.out # bad packets from Kamil Frankowicz snmp-heapoverflow-1 snmp-heapoverflow-1.pcap snmp-heapoverflow-1.out snmp-heapoverflow-2 snmp-heapoverflow-2.pcap snmp-heapoverflow-2.out isoclns-heapoverflow-2 isoclns-heapoverflow-2.pcap isoclns-heapoverflow-2.out -e -c1 isoclns-heapoverflow-3 isoclns-heapoverflow-3.pcap isoclns-heapoverflow-3.out -e -c1 stp-v4-length-sigsegv stp-v4-length-sigsegv.pcap stp-v4-length-sigsegv.out hoobr_pimv1 hoobr_pimv1.pcap hoobr_pimv1.out hoobr_safeputs hoobr_safeputs.pcap hoobr_safeputs.out isakmp-rfc3948-oobr isakmp-rfc3948-oobr.pcap isakmp-rfc3948-oobr.out isoclns-oobr isoclns-oobr.pcap isoclns-oobr.out nfs-attr-oobr nfs-attr-oobr.pcap nfs-attr-oobr.out decnet-oobr decnet-oobr.pcap decnet-oobr.out oobr_parse_elements oobr_parse_elements.pcap oobr_parse_elements.out hoobr_ripng_print hoobr_ripng_print.pcap hoobr_ripng_print.out hoobr_juniper hoobr_juniper.pcap hoobr_juniper.out hoobr_juniper2 hoobr_juniper2.pcap hoobr_juniper2.out hoobr_juniper3 hoobr_juniper3.pcap hoobr_juniper3.out hoobr_juniper4 hoobr_juniper4.pcap hoobr_juniper4.out hoobr_parse_field hoobr_parse_field.pcap hoobr_parse_field.out hoobr_chdlc_print hoobr_chdlc_print.pcap hoobr_chdlc_print.out hoobr_lookup_nsap hoobr_lookup_nsap.pcap hoobr_lookup_nsap.out hoobr_rt6_print hoobr_rt6_print.pcap hoobr_rt6_print.out hoobr_nfs_printfh hoobr_nfs_printfh.pcap hoobr_nfs_printfh.out hoobr_aodv_extension hoobr_aodv_extension.pcap hoobr_aodv_extension.out hoobr_nfs_xid_map_enter hoobr_nfs_xid_map_enter.pcap hoobr_nfs_xid_map_enter.out # bad packets from Wilfried Kirsch slip-bad-direction slip-bad-direction.pcap slip-bad-direction.out -ve -# bad packets from Otto Airamo and Antti Levomäki -nbns-valgrind nbns-valgrind.pcap nbns-valgrind.out -vvv -e arp-oobr arp-oobr.pcap arp-oobr.out -vvv -e icmp-cksum-oobr-1 icmp-cksum-oobr-1.pcap icmp-cksum-oobr-1.out -vvv -e icmp-cksum-oobr-2 icmp-cksum-oobr-2.pcap icmp-cksum-oobr-2.out -vvv -e icmp-cksum-oobr-3 icmp-cksum-oobr-3.pcap icmp-cksum-oobr-3.out -vvv -e icmp-cksum-oobr-4 icmp-cksum-oobr-4.pcap icmp-cksum-oobr-4.out -vvv -e tok2str-oobr-1 tok2str-oobr-1.pcap tok2str-oobr-1.out -vvv -e tok2str-oobr-2 tok2str-oobr-2.pcap tok2str-oobr-2.out -vvv -e eigrp-tlv-oobr eigrp-tlv-oobr.pcap eigrp-tlv-oobr.out -vvv -e zephyr-oobr zephyr-oobr.pcap zephyr-oobr.out -vvv -e isakmp-no-none-np isakmp-no-none-np.pcap isakmp-no-none-np.out -vvv -e telnet-iac-check-oobr telnet-iac-check-oobr.pcap telnet-iac-check-oobr.out -vvv -e resp_4_infiniteloop resp_4_infiniteloop.pcap resp_4_infiniteloop.out -vvv -e dns_fwdptr dns_fwdptr.pcap dns_fwdptr.out -vvv -e isis-areaaddr-oobr-1 isis-areaaddr-oobr-1.pcap isis-areaaddr-oobr-1.out -vvv -e isis-areaaddr-oobr-2 isis-areaaddr-oobr-2.pcap isis-areaaddr-oobr-2.out -vvv -e isis-extd-ipreach-oobr isis-extd-ipreach-oobr.pcap isis-extd-ipreach-oobr.out -vvv -e lldp-infinite-loop-1 lldp-infinite-loop-1.pcap lldp-infinite-loop-1.out -vvv -e lldp-infinite-loop-2 lldp-infinite-loop-2.pcap lldp-infinite-loop-2.out -vvv -e pimv2-oobr-1 pimv2-oobr-1.pcap pimv2-oobr-1.out -vvv -e pimv2-oobr-2 pimv2-oobr-2.pcap pimv2-oobr-2.out -vvv -e pimv2-oobr-3 pimv2-oobr-3.pcap pimv2-oobr-3.out -vvv -e pimv2-oobr-4 pimv2-oobr-4.pcap pimv2-oobr-4.out -vvv -e 802_15_4-oobr-1 802_15_4-oobr-1.pcap 802_15_4-oobr-1.out -vvv -e 802_15_4-oobr-2 802_15_4-oobr-2.pcap 802_15_4-oobr-2.out -vvv -e 802_15_4-data 802_15_4-data.pcap 802_15_4-data.out -vvv -e 802_15_4_beacon 802_15_4_beacon.pcap 802_15_4_beacon.out -vvv -e lmpv1_busyloop lmpv1_busyloop.pcap lmpv1_busyloop.out -vvv -e juniper_atm1 juniper_atm1.pcap juniper_atm1.out -vvv -e juniper_es juniper_es.pcap juniper_es.out -vvv -e # bad packets from Yannick Formaggio l2tp-avp-overflow l2tp-avp-overflow.pcap l2tp-avp-overflow.out -v pktap-heap-overflow pktap-heap-overflow.pcap pktap-heap-overflow.out -v wb-oobr wb-oobr.pcap wb-oobr.out -v # bad packets from Bhargava Shastry lldp_asan lldp_asan.pcap lldp_asan.out -v extract_read2_asan extract_read2_asan.pcap extract_read2_asan.out -v getname_2_read4_asan getname_2_read4_asan.pcap getname_2_read4_asan.out -v eap_extract_read2_asan eap_extract_read2_asan.pcap eap_extract_read2_asan.out -v esis_snpa_asan esis_snpa_asan.pcap esis_snpa_asan.out -v esis_snpa_asan-2 esis_snpa_asan-2.pcap esis_snpa_asan-2.out -v esis_snpa_asan-3 esis_snpa_asan-3.pcap esis_snpa_asan-3.out -v esis_snpa_asan-4 esis_snpa_asan-4.pcap esis_snpa_asan-4.out -v esis_snpa_asan-5 esis_snpa_asan-5.pcap esis_snpa_asan-5.out -v dhcp6_reconf_asan dhcp6_reconf_asan.pcap dhcp6_reconf_asan.out -v pgm_opts_asan pgm_opts_asan.pcap pgm_opts_asan.out -v pgm_opts_asan_2 pgm_opts_asan_2.pcap pgm_opts_asan_2.out -v pgm_opts_asan_3 pgm_opts_asan_3.pcap pgm_opts_asan_3.out -v pgm_group_addr_asan pgm_group_addr_asan.pcap pgm_group_addr_asan.out -v vtp_asan vtp_asan.pcap vtp_asan.out -v vtp_asan-2 vtp_asan-2.pcap vtp_asan-2.out -v vtp_asan-3 vtp_asan-3.pcap vtp_asan-3.out -v icmp6_mobileprefix_asan icmp6_mobileprefix_asan.pcap icmp6_mobileprefix_asan.out -v ip_printroute_asan ip_printroute_asan.pcap ip_printroute_asan.out -v mobility_opt_asan mobility_opt_asan.pcap mobility_opt_asan.out -v mobility_opt_asan_2 mobility_opt_asan_2.pcap mobility_opt_asan_2.out -v mobility_opt_asan_3 mobility_opt_asan_3.pcap mobility_opt_asan_3.out -v mobility_opt_asan_4 mobility_opt_asan_4.pcap mobility_opt_asan_4.out -v mobility_opt_asan_5 mobility_opt_asan_5.pcap mobility_opt_asan_5.out -v mobility_opt_asan_6 mobility_opt_asan_6.pcap mobility_opt_asan_6.out -v mobility_opt_asan_7 mobility_opt_asan_7.pcap mobility_opt_asan_7.out -v mobility_opt_asan_8 mobility_opt_asan_8.pcap mobility_opt_asan_8.out -v isis_stlv_asan isis_stlv_asan.pcap isis_stlv_asan.out -v isis_stlv_asan-2 isis_stlv_asan-2.pcap isis_stlv_asan-2.out -v isis_stlv_asan-3 isis_stlv_asan-3.pcap isis_stlv_asan-3.out -v isis_stlv_asan-4 isis_stlv_asan-4.pcap isis_stlv_asan-4.out -v isis_sysid_asan isis_sysid_asan.pcap isis_sysid_asan.out -v lldp_mgmt_addr_tlv_asan lldp_mgmt_addr_tlv_asan.pcap lldp_mgmt_addr_tlv_asan.out -v bootp_asan bootp_asan.pcap bootp_asan.out -v bootp_asan-2 bootp_asan-2.pcap bootp_asan-2.out -v ppp_ccp_config_deflate_option_asan ppp_ccp_config_deflate_option_asan.pcap ppp_ccp_config_deflate_option_asan.out -v pim_header_asan pim_header_asan.pcap pim_header_asan.out -v pim_header_asan-2 pim_header_asan-2.pcap pim_header_asan-2.out -v pim_header_asan-3 pim_header_asan-3.pcap pim_header_asan-3.out -v pim_header_asan-4 pim_header_asan-4.pcap pim_header_asan-4.out -v ip6_frag_asan ip6_frag_asan.pcap ip6_frag_asan.out -v radius_attr_asan radius_attr_asan.pcap radius_attr_asan.out -v ospf6_decode_v3_asan ospf6_decode_v3_asan.pcap ospf6_decode_v3_asan.out -v ip_ts_opts_asan ip_ts_opts_asan.pcap ip_ts_opts_asan.out -v isakmpv1-attr-oobr isakmpv1-attr-oobr.pcap isakmpv1-attr-oobr.out -v -# The case below depends on the bug in print-hncp.c, which at the time of -# discovery had codepoints for DHCPv6-Data and DHCPv4-Data swapped around. -# After the bugfix the output will be different because of the different -# code path and will not test the vulnerability unless modified respectively. +isakmp-ikev1_n_print-oobr isakmp-ikev1_n_print-oobr.pcap isakmp-ikev1_n_print-oobr.out -v -c3 +ldp-ldp_tlv_print-oobr ldp-ldp_tlv_print-oobr.pcap ldp-ldp_tlv_print-oobr.out -v -c1 +icmp-icmp_print-oobr-1 icmp-icmp_print-oobr-1.pcap icmp-icmp_print-oobr-1.out -v -c3 +icmp-icmp_print-oobr-2 icmp-icmp_print-oobr-2.pcap icmp-icmp_print-oobr-2.out -v -c3 +rsvp-rsvp_obj_print-oobr rsvp-rsvp_obj_print-oobr.pcap rsvp-rsvp_obj_print-oobr.out -v -c3 +vrrp-vrrp_print-oobr vrrp-vrrp_print-oobr.pcap vrrp-vrrp_print-oobr.out -v -c3 +vrrp-vrrp_print-oobr-2 vrrp-vrrp_print-oobr-2.pcap vrrp-vrrp_print-oobr-2.out -v +bgp-bgp_capabilities_print-oobr-1 bgp-bgp_capabilities_print-oobr-1.pcap bgp-bgp_capabilities_print-oobr-1.out -v -c1 +bgp-bgp_capabilities_print-oobr-2 bgp-bgp_capabilities_print-oobr-2.pcap bgp-bgp_capabilities_print-oobr-2.out -v -c1 +lmp-lmp_print_data_link_subobjs-oobr lmp-lmp_print_data_link_subobjs-oobr.pcap lmp-lmp_print_data_link_subobjs-oobr.out -v -c2 # The .pcap file is truncated after the 1st packet. hncp_dhcpv6data-oobr hncp_dhcpv6data-oobr.pcap hncp_dhcpv6data-oobr.out -v -c1 -# Same comments apply to the case below. hncp_dhcpv4data-oobr hncp_dhcpv4data-oobr.pcap hncp_dhcpv4data-oobr.out -v -c1 vqp-oobr vqp-oobr.pcap vqp-oobr.out -v -c1 bgp_pmsi_tunnel-oobr bgp_pmsi_tunnel-oobr.pcap bgp_pmsi_tunnel-oobr.out -v -c1 bgp_mvpn_6_and_7 bgp_mvpn_6_and_7.pcap bgp_mvpn_6_and_7.out -v -c1 rsvp_fast_reroute-oobr rsvp_fast_reroute-oobr.pcap rsvp_fast_reroute-oobr.out -v -c1 esis_opt_prot-oobr esis_opt_prot-oobr.pcap esis_opt_prot-oobr.out -v -c1 rsvp_uni-oobr-1 rsvp_uni-oobr-1.pcap rsvp_uni-oobr-1.out -v -c1 rsvp_uni-oobr-2 rsvp_uni-oobr-2.pcap rsvp_uni-oobr-2.out -v -c1 rsvp_uni-oobr-3 rsvp_uni-oobr-3.pcap rsvp_uni-oobr-3.out -v -c3 rpki-rtr-oob rpki-rtr-oob.pcap rpki-rtr-oob.out -v -c1 lldp_8023_mtu-oobr lldp_8023_mtu-oobr.pcap lldp_8023_mtu-oobr.out -v -c1 bgp_vpn_rt-oobr bgp_vpn_rt-oobr.pcap bgp_vpn_rt-oobr.out -v -c1 cfm_sender_id-oobr cfm_sender_id-oobr.pcap cfm_sender_id-oobr.out -v -c1 isis-extd-isreach-oobr isis-extd-isreach-oobr.pcap isis-extd-isreach-oobr.out -v -c4 olsr-oobr-1 olsr-oobr-1.pcap olsr-oobr-1.out -v olsr-oobr-2 olsr-oobr-2.pcap olsr-oobr-2.out -v ikev1_id_ipv6_addr_subnet-oobr ikev1_id_ipv6_addr_subnet-oobr.pcap ikev1_id_ipv6_addr_subnet-oobr.out -v isakmp-various-oobr isakmp-various-oobr.pcap isakmp-various-oobr.out -v +aoe-oobr-1 aoe-oobr-1.pcap aoe-oobr-1.out -v -c1 +frf16_magic_ie-oobr frf16_magic_ie-oobr.pcap frf16_magic_ie-oobr.out -v -c1 +rx_serviceid_oobr rx_serviceid_oobr.pcap rx_serviceid_oobr.out -c3 +bgp_mp_reach_nlri-oobr bgp_mp_reach_nlri-oobr.pcap bgp_mp_reach_nlri-oobr.out -v -c1 # bad packets from Katie Holly mlppp-oobr mlppp-oobr.pcap mlppp-oobr.out # bad packets from Kim Gwan Yeong mptcp-dss-oobr mptcp-dss-oobr.pcap mptcp-dss-oobr.out -v icmp6_nodeinfo_oobr icmp6_nodeinfo_oobr.pcap icmp6_nodeinfo_oobr.out # bad packets from Henri Salo rx_ubik-oobr rx_ubik-oobr.pcap rx_ubik-oobr.out -c1 +babel_update_oobr babel_update_oobr.pcap babel_update_oobr.out -c 52 +# bad packets from Junjie Wang +ospf6_print_lshdr-oobr ospf6_print_lshdr-oobr.pcapng ospf6_print_lshdr-oobr.out -vv -c15 +rpl-dao-oobr rpl-dao-oobr.pcapng rpl-dao-oobr.out -vv -c1 +hncp_prefix-oobr hncp_prefix-oobr.pcapng hncp_prefix-oobr.out -vvv + +# bad packets from Ryan Ackroyd +ieee802.11_meshhdr-oobr ieee802.11_meshhdr-oobr.pcap ieee802.11_meshhdr-oobr.out -H -c1 +dccp_options-oobr dccp_options-oobr.pcap dccp_options-oobr.out -vv -c8 + # RTP tests # fuzzed pcap rtp-seg-fault-1 rtp-seg-fault-1.pcap rtp-seg-fault-1.out -v -T rtp rtp-seg-fault-2 rtp-seg-fault-2.pcap rtp-seg-fault-2.out -v -T rtp # NFS tests # fuzzed pcap nfs-seg-fault-1 nfs-seg-fault-1.pcap nfs-seg-fault-1.out # DNS infinite loop tests # # See http://marc.info/?l=tcpdump-workers&m=95552439022555 # dns-zlip-1 dns-zlip-1.pcap dns-zlip-1.out dns-zlip-2 dns-zlip-2.pcap dns-zlip-2.out dns-zlip-3 dns-zlip-3.pcap dns-zlip-3.out + +# CVE-2019-15120 +kh-addrfail-001 kh-addrfail-001.pcap kh-addrfail-001.out +kh-addrfail-002 kh-addrfail-002.pcap kh-addrfail-002.out +kh-addrfail-003 kh-addrfail-003.pcap kh-addrfail-003.out +kh-addrfail-004 kh-addrfail-004.pcap kh-addrfail-004.out +kh-addrfail-005 kh-addrfail-005.pcap kh-addrfail-005.out +kh-addrfail-006 kh-addrfail-006.pcap kh-addrfail-006.out +kh-addrfail-007 kh-addrfail-007.pcap kh-addrfail-007.out +kh-addrfail-008 kh-addrfail-008.pcap kh-addrfail-008.out +kh-addrfail-009 kh-addrfail-009.pcap kh-addrfail-009.out +kh-addrfail-010 kh-addrfail-010.pcap kh-addrfail-010.out +kh-addrfail-011 kh-addrfail-011.pcap kh-addrfail-011.out +kh-tcpdump-001 kh-tcpdump-001.pcap kh-tcpdump-001.out +kh-tcpdump-002 kh-tcpdump-002.pcap kh-tcpdump-002.out + +# CVE-2018-10105 bad packets from Luis Rocha +cve-2018-10105-segv-sflowprint cve-2018-10105-segv-sflowprint.pcapng cve-2018-10105-segv-sflowprint.out -v + + Index: vendor/tcpdump/dist/tests/TESTonce =================================================================== --- vendor/tcpdump/dist/tests/TESTonce (revision 353143) +++ vendor/tcpdump/dist/tests/TESTonce (revision 353144) @@ -1,70 +1,163 @@ #!/usr/bin/env perl -system("mkdir -p NEW DIFF"); +$TCPDUMP = "./tcpdump"; +if ($^O eq 'MSWin32') { + $TCPDUMP = "windump"; +} +if($ENV{TCPDUMP_BIN}) { + $TCPDUMP = $ENV{TCPDUMP_BIN}; +} +use File::Basename; +use POSIX qw( WEXITSTATUS WIFEXITED); + +system("mkdir -p tests/NEW tests/DIFF"); + if(@ARGV != 4) { print "Usage: TESTonce name input output options\n"; exit 20; } $name=$ARGV[0]; $input=$ARGV[1]; $output=$ARGV[2]; $options=$ARGV[3]; my $r; +my $debug = 0; # change to suit. +$outputbase = basename($output); +my $coredump = false; +my $status = 0; +my $linecount = 0; +my $rawstderrlog = "tests/NEW/${outputbase}.raw.stderr"; +my $stderrlog = "tests/NEW/${outputbase}.stderr"; +my $diffstat = 0; +my $errdiffstat = 0; +my $cmd; + if ($^O eq 'MSWin32') { - $r = system "..\\windump -n -t -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff"; + $r = system ".\\${TCPDUMP} -t -n -r $input $options 2>NUL | sed 's/\\r//' | tee tests/NEW/${outputbase} | diff $output - >tests/DIFF/${outputbase}.diff"; # need to do same as below for Cygwin. } else { # we used to do this as a nice pipeline, but the problem is that $r fails to # to be set properly if the tcpdump core dumps. - $r = system "../tcpdump 2>/dev/null -n -t -r $input $options >NEW/$output"; + $cmd = "$TCPDUMP 2>${rawstderrlog} -t -n -r $input $options >tests/NEW/${outputbase}"; + print "CMD: $cmd\n" if $debug; + $r = system $cmd; + if($r == -1) { + # failed to start due to error. + $status = $!; + } if($r != 0) { - # this means tcpdump failed. - open(OUTPUT, ">>"."NEW/$output") || die "fail to open $output\n"; - printf OUTPUT "EXIT CODE %08x\n", $r; + $coredump = false; + $status = 0; + # this means tcpdump failed, which however, might be expected. + open(OUTPUT, ">>"."tests/NEW/${outputbase}") || die "fail to open ${outputbase}\n"; + if( $r & 128 ) { + $coredump = $r & 127; + } + if( WIFEXITED($r)) { + $status = WEXITSTATUS($r); + } + + if($coredump || $status) { + printf OUTPUT "\nEXIT CODE %08x: dump:%d code: %d\n", $r, $coredump, $status; + } else { + printf OUTPUT "\nEXIT CODE %08x\n", $r; + } close(OUTPUT); - $r = 0; + $r = 0; # clear the error so that the diff will occur. } + print "RUNNING DIFF after ${r}\n" if $debug; + + # always run diff. + $cmd = "cat tests/NEW/${outputbase} | diff $output - >tests/DIFF/${outputbase}.diff"; + print "RUNNING: $cmd\n" if $debug; + $r = system $cmd; + if(WIFEXITED($r)) { + $diffstat = WEXITSTATUS($r); + } + + #system("/bin/sh"); + + # process the file, sanitize "reading from" line, and count lines + $linecount = 0; + open(ERRORRAW, "<" . $rawstderrlog); + open(ERROROUT, ">" . $stderrlog); + while() { + next if /^\s*$/; # blank lines are boring + if(/^(reading from file )(.*)(,.*)$/) { + my $filename = basename($2); + print ERROROUT "${1}${filename}${3}\n"; + next; + } + print ERROROUT; + $linecount++; + } + close(ERROROUT); + close(ERRORRAW); + + if ( -f "$output.stderr" ) { + $nr = system "cat $stderrlog | diff $output.stderr - >tests/DIFF/$outputbase.stderr.diff"; + if($r == 0) { + $r = $nr; + } + $errdiffstat = WEXITSTATUS($nr); + } else { + $errdiffstat = "-" + } + if($r == 0) { - $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff"; + if($linecount == 0 && $status == 0) { + print "UNLINK: ${stderrlog}\n" if $debug; + unlink($stderrlog) unless $debug; + } else { + $errdiffstat = "+"; + } } - #print sprintf("END: %08x\n", $r); + + print sprintf("END: %08x\n", $r) if $debug; } if($r == 0) { - printf " %-35s: passed\n", $name; - unlink "DIFF/$output.diff"; - exit 0; + my $stderrlog=""; + if($linecount > 0 && $errdiffstat != "-") { + $stderrlog=sprintf("-- %d lines extra in stderr", $linecount); + } + if(!defined($ENV{"SKIPPASSED"})) { + printf " %-35s: passed%s\n", $name, $stderrlog; + } + unlink "tests/DIFF/$outputbase.diff" unless $debug; + exit 0; } -printf " %-35s: TEST FAILED", $name; -open FOUT, '>>failure-outputs.txt'; -printf FOUT "Failed test: $name\n\n"; +# must have failed! +printf " %-35s: TEST FAILED(exit core=%d/diffstat=%d,%d/r=%d)", $name, $coredump, $diffstat, $errdiffstat, $r; +open FOUT, '>>tests/failure-outputs.txt'; +printf FOUT "\nFailed test: $name\n\n"; close FOUT; -if(-f "DIFF/$output.diff") { - system "cat DIFF/$output.diff >> failure-outputs.txt"; +if(-f "tests/DIFF/$outputbase.diff") { + system "cat tests/DIFF/$outputbase.diff >> tests/failure-outputs.txt"; } if($r == -1) { print " (failed to execute: $!)\n"; exit 30; } # this is not working right, $r == 0x8b00 when there is a core dump. # clearly, we need some platform specific perl magic to take this apart, so look for "core" # too. # In particular, on Solaris 10 SPARC an alignment problem results in SIGILL, # a core dump and $r set to 0x00008a00 ($? == 138 in the shell). if($r & 127 || -f "core") { my $with = ($r & 128) ? 'with' : 'without'; if(-f "core") { $with = "with"; } printf " (terminated with signal %u, %s coredump)\n", ($r & 127), $with; exit ($r & 128) ? 10 : 20; } print "\n"; exit $r >> 8; Index: vendor/tcpdump/dist/tests/TESTrun.sh =================================================================== --- vendor/tcpdump/dist/tests/TESTrun.sh (revision 353143) +++ vendor/tcpdump/dist/tests/TESTrun.sh (revision 353144) @@ -1,69 +1,98 @@ #!/bin/sh -mkdir -p NEW -mkdir -p DIFF -passed=0 -failed=0 -cat /dev/null > failure-outputs.txt +TZ=GMT0; export TZ +srcdir=${SRCDIR-..} +# make it absolute for later use. +pwd +srcdir=`cd $srcdir && pwd` + +# this should be run from the compiled build directory, +# with srcdir= set to wherever the source code is. +# not from the tests directory. +echo RUNNING from ${srcdir} + +passedfile=`pwd`/tests/.passed +failedfile=`pwd`/tests/.failed +failureoutput=`pwd`/tests/failure-outputs.txt +mkdir -p tests/NEW +mkdir -p tests/DIFF +cat /dev/null > ${failureoutput} + runComplexTests() { - for i in *.sh + for i in ${srcdir}/tests/*.sh do - case $i in TEST*.sh) continue;; esac - sh ./$i + case $i in + ${srcdir}/tests/TEST*.sh) continue;; + ${srcdir}/tests/\*.sh) continue;; + esac + : echo Running $i + (sh $i ${srcdir}) done + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` } runSimpleTests() { - passed=`cat .passed` - failed=`cat .failed` only=$1 - cat TESTLIST | while read name input output options + cat ${srcdir}/tests/TESTLIST | while read name input output options do case $name in \#*) continue;; '') continue;; esac rm -f core [ "$only" != "" -a "$name" != "$only" ] && continue - if ./TESTonce $name $input $output "$options" + SRCDIR=${srcdir} + export SRCDIR + # I hate shells with their stupid, useless subshells. + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` + ( + if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options" then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} fi + if [ -d tests/COREFILES ]; then + if [ -f core ]; then mv core tests/COREFILES/$name.core; fi + fi) [ "$only" != "" -a "$name" = "$only" ] && break done # I hate shells with their stupid, useless subshells. - passed=`cat .passed` - failed=`cat .failed` + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` } -echo $passed >.passed -echo $failed >.failed +passed=0 +failed=0 +echo $passed >${passedfile} +echo $failed >${failedfile} if [ $# -eq 0 ] then runComplexTests runSimpleTests elif [ $# -eq 1 ] then runSimpleTests $1 else echo "Usage: $0 [test_name]" exit 30 fi # exit with number of failing tests. echo '------------------------------------------------' printf "%4u tests failed\n" $failed printf "%4u tests passed\n" $passed echo -echo -cat failure-outputs.txt +if [ -z "$SKIPPASSED" ]; then + cat ${failureoutput} +fi echo echo exit $failed Index: vendor/tcpdump/dist/tests/aoe-oobr-1.out =================================================================== --- vendor/tcpdump/dist/tests/aoe-oobr-1.out (nonexistent) +++ vendor/tcpdump/dist/tests/aoe-oobr-1.out (revision 353144) @@ -0,0 +1,3 @@ +AoE length 18, Ver 1, Flags: [Response, MBZ-0x02, MBZ-0x01] + Major: 0x40f6, Minor: 0x02, Command: Reserve/Release, Tag: 0x01010101 + RCmd: Set reserve list, NMacs: 1 [|aoe] Index: vendor/tcpdump/dist/tests/aoe-oobr-1.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/aoe-oobr-1.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/arp-too-long-tha.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: vendor/tcpdump/dist/tests/babel_update_oobr.out =================================================================== --- vendor/tcpdump/dist/tests/babel_update_oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/babel_update_oobr.out (revision 353144) @@ -0,0 +1,66 @@ +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-2M-!M-1M-1M-1M-1M-1M-1M-1M-1M-,.M-0^Vn [|kerberos] +IP 10.0.0.1 > 0.234.154.214: ip-proto-17 +IP 10.0.0.1.88 > 0.234.154.179.24191: v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .*^C@>M-z}M-uM-tM-+M-_M-{S^PM-=OM-^Y [|kerberos] +58:5e:0a:02:f4:0a > 02:8e:00:50:6a:e1, ethertype Unknown (0xb104), length 3892667167: + 0x0000: 020f 0f0f 0f0f 0f0f 0f0f 04b2 a1b1 b1b1 ................ + 0x0010: b1b1 b1b1 b158 5e0a 02f4 0ab1 0402 0f0f .....X^......... + 0x0020: ff80 0f0f 0f0f 0f00 80a1 00b2 b2b2 b20d ................ + 0x0030: 0d3a 3400 0001 00 .:4.... +IP 6.3.218.255.6379 > 0.1.31.99.639: Flags [S.UW], seq 2751463404:2751463426, ack 1006637056, win 45746, urg 25778, length 22: RESP [|RESP] +IP 6.3.208.255.6379 > 0.1.31.99.639: Flags [S.UW], seq 2751463404:2751463426, ack 1006640128, win 45746, urg 25778, length 22: RESP "M-2M-2M-2M-2M-2M-7dM-2M-2M-2M-2M-2" [|RESP] +IP 208.21.10.1.654 > 31.99.100.232.80: aodv rrep 34 prefix 4 hops 11 + dst 237.34.38.84 dseq 32203525 src 232.11.2.0 67108864 ms + ext 0 0 +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-WM-WM-WM-WM-WM-WM-W.@ 680min [|kerberos] +IP 10.0.253.1.88 > 0.234.154.214.24073: v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24073: v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.242.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^U.@^O^D^O^O^O^O^O^O^O^O^O^O^O^O [|kerberos] +IP 10.0.222.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .M-g^C@>M-y}M-uM-tM-+M-` 680min [|kerberos] +01:01:ed:83:e3:ff > 02:8e:00:50:6d:e1, ethertype Unknown (0x0700), length 3892672031: + 0x0000: 4508 8834 d940 4000 4011 4a70 0a00 0001 E..4.@@.@.Jp.... + 0x0010: 00ea 9ad6 0058 5e0a 02f4 0ab1 0402 0f0f .....X^......... + 0x0020: 0f0f 0f0f 0f0f 0f04 b2a1 b1b1 b1b1 b1b1 ................ + 0x0030: b1b1 b100 b016 6e ......n +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^U.@ ^D^R^O^O^O^O^O^O^O^O^O^O^O [|kerberos] +IP 10.0.255.127.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .M-g^C@>M-z}M-uM-tM-^\M-`^VM-^?^?M-=OM-^Y [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O.^B^O^O^O^O^DM-2M-!M-1M-1M-1M-1M-1M-1M-1M-1M-1M-^@M-0^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-#M-^?M-^?d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 0.0.1.0 > 234.154.214.0: ip-proto-106 +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-WM-WM-WM-WM-WM-WM-W.@ 680min [|kerberos] +IP 10.0.253.1.8280 > 0.234.154.214.24073: UDP, bad length 60652 > 32792 +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 le APPL_REQUEST_MUTUAL: (unknown) +01:00:01:00:00:00 > 02:8e:00:50:6a:e1, ethertype Unknown (0x08e8), length 3892667167: + 0x0000: 4408 8034 d92b 4000 4011 3b70 0a00 0001 D..4.+@.@.;p.... + 0x0010: 00ea 9ad6 0058 5e0a 02f4 0ab1 0402 ffff .....X^......... + 0x0020: ff7f 80ff 80d6 00c3 0880 34d9 4040 0040 ..........4.@@.@ + 0x0030: 114a 700a 0016 88 .Jp.... +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: .M-oM-^?M-^?@M-^?M-^@M-V M-WM-WM-WM-WM-WM-WM-WM-W 0min ^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.210.24073: v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-WM-^?M-!^B^O^O^P@M-^?M-^?^O^O^O [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-#M-^?M-^?d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: +IP 10.0.253.1.88 > 0.234.154.214.24073: v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos] +IP 64.0.0.1.88 > 0.234.154.214.24074: v4 le APPL_REQUEST_MUTUAL: (unknown) +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: M-^?M-^?M-^?^?M-^@M-^?M-^@M-V.M-C^HM-^@4M-Y@@@@^QJp^J [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: .M-oM-^?M-^?@M-^?M-^@M-V 75min ^O^O^O^O^O^O^O^O.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos] +IP 10.0.0.1.88 > 0.234.154.214.24074: v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos] +IP 208.21.42.58.6697 > 110.228.104.254.30952: babel 2 (2056) (invalid) Index: vendor/tcpdump/dist/tests/babel_update_oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/babel_update_oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-1.out =================================================================== --- vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-1.out (nonexistent) +++ vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-1.out (revision 353144) @@ -0,0 +1,27 @@ +IP (tos 0x1f,CE, ttl 254, id 38671, offset 0, flags [+, DF, rsvd], proto TCP (6), length 4135, bad cksum 200 (->1fdd)!) + 226.219.0.0.179 > 16.233.34.0.100: Flags [SPUE], seq 347537408:347541483, win 511, urg 65535, options [eol], length 4075: BGP [|BGP] + Open Message (1), length: 59 + Version 255, my AS 65528, Holdtime 4324s, ID 144.8.32.4 + Optional parameters, length: 29 + Option Unknown (0), length: 0 + no decoder for option 0 + Option Capabilities Advertisement (2), length: 8 + Graceful Restart (64), length: 0 + Restart Flags: [none], Restart Time 0s + Unknown (0), length: 0 + no decoder for Capability 0 + 32-Bit AS Number (65), length: 4 + 4 Byte AS 2 + Option Unknown (0), length: 2 + no decoder for option 0 + Option Capabilities Advertisement (2), length: 2 + Unknown (232), length: 3 + no decoder for Capability 232 + 0x0000: 0207 04 + Option Capabilities Advertisement (2), length: 7 + Multiple Routes to a Destination (4), length: 0 + no decoder for Capability 4 + Unknown (8), length: 0 + no decoder for Capability 8 + Route Refresh (Cisco) (128), length: 0 + Graceful Restart (64), length: 0[|BGP] Index: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-1.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-1.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-2.out =================================================================== --- vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-2.out (nonexistent) +++ vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-2.out (revision 353144) @@ -0,0 +1,26 @@ +IP (tos 0x1f,CE, ttl 254, id 38671, offset 0, flags [+, DF, rsvd], proto TCP (6), length 4135, bad cksum 200 (->1fdd)!) + 226.219.0.0.179 > 16.233.34.0.100: Flags [SPUE], seq 347537408:347541483, win 511, urg 65535, options [eol], length 4075: BGP [|BGP] + Open Message (1), length: 59 + Version 255, my AS 65528, Holdtime 4324s, ID 144.8.32.4 + Optional parameters, length: 29 + Option Unknown (0), length: 0 + no decoder for option 0 + Option Capabilities Advertisement (2), length: 8 + Graceful Restart (64), length: 0 + Restart Flags: [none], Restart Time 0s + Unknown (0), length: 0 + no decoder for Capability 0 + 32-Bit AS Number (65), length: 4 + 4 Byte AS 2 + Option Unknown (0), length: 2 + no decoder for option 0 + Option Capabilities Advertisement (2), length: 2 + Unknown (232), length: 3 + no decoder for Capability 232 + 0x0000: 0207 04 + Option Capabilities Advertisement (2), length: 7 + Multiple Routes to a Destination (4), length: 0 + no decoder for Capability 4 + Unknown (8), length: 0 + no decoder for Capability 8 + Multiprotocol Extensions (1), length: 0[|BGP] Index: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/bgp-bgp_capabilities_print-oobr-2.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/bgp_mp_reach_nlri-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/bgp_mp_reach_nlri-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/bgp_mp_reach_nlri-oobr.out (revision 353144) @@ -0,0 +1,277 @@ +IP (tos 0xff,CE, ttl 254, id 32783, offset 0, flags [rsvd], proto TCP (6), length 65535, bad cksum 8e15 (->5bbf)!) + 241.0.128.39.179 > 239.0.0.1.0: Flags [none], seq 4144029695:4144095150, win 65535, options [eol], length 65455: BGP [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Attribute Set (128), length: 32768, Flags [OTPE+f]: [|BGP] [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 0 + Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: + AFI: NSAP (3), SAFI: labeled VPN Unicast (128) + nexthop: invalid len, nh-length: 1, no SNPA + RD: unknown RD format, 00.0000.0000.0d00.0000.0000.00/91, label:15 (bottom) + (illegal prefix length) + Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: + AFI: NSAP (3), SAFI: labeled VPN Unicast (128) + nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.000d.0000, nh-length: 21, no SNPA + (illegal prefix length) + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (80), length: 0 + no Attribute 80 decoder + Unknown Attribute (157), length: 161, Flags [P+d]: + no Attribute 157 decoder + 0x0000: 0280 fdff ffff ffff ffff ffff ffff ffff + 0x0010: ffff ff00 2d02 0003 f1ff 7bc3 b2ff 8000 + 0x0020: 0700 0000 df00 c123 0000 0000 00a1 0200 + 0x0030: 9eff ffff ffff ffff ffff ffff ffff ff94 + 0x0040: 9494 2d02 0003 f1ff 7bc3 b2ff 8000 0700 + 0x0050: 0000 0046 0ee3 0003 8015 00b3 0000 f700 + 0x0060: dfee 0500 0000 0000 0000 0000 0000 0000 + 0x0070: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x0080: 0000 de00 0000 0000 0000 0000 0000 0001 + 0x0090: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x00a0: 00 + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 140 + no Attribute 0 decoder + 0x0000: 0000 0000 0000 0080 27ef 0000 0100 c600 + 0x0010: 007f f3f9 8900 0107 07d4 2d9d a102 80fd + 0x0020: ecff ff04 00ff 4000 0000 ffff ffff ffff + 0x0030: 002d 0200 03f1 ff7b c3b2 ff80 0007 434c + 0x0040: 4945 4e54 0000 00df 00c1 2300 0000 0000 + 0x0050: ff00 0000 ff00 0000 04ff ffff ffff ffff + 0x0060: ffff ffff 002d 0200 03f1 ff7b c3b2 ff80 + 0x0070: 0007 0000 0000 460e e300 0380 1500 b300 + 0x0080: 00f7 00df ee35 0000 0500 0000 + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder[|BGP] [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 223 + Unknown Attribute (193), length: 35 + no Attribute 193 decoder + 0x0000: 0000 0000 00a1 0200 9eff ffff ffff fffc + 0x0010: ffff ffff ffff ffff ff00 2d02 0003 f1ff + 0x0020: 7bc3 b2 + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 0 + Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: + AFI: NSAP (3), SAFI: labeled VPN Unicast (128) + nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.000d.0000, nh-length: 21, no SNPA + (illegal prefix length) + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (80), length: 0 + no Attribute 80 decoder + Unknown Attribute (157), length: 161, Flags [P+d]: + no Attribute 157 decoder + 0x0000: 0280 fdff ffff ffff ffff ffff ffff ffff + 0x0010: ffff ff00 2d02 0003 f1ff 7bc3 b2ff 8000 + 0x0020: 0700 0000 df00 c123 0000 0000 00a1 0200 + 0x0030: 9eff ffff ffff ffff ffff ffff ffff ff94 + 0x0040: 9494 2d02 0003 f1ff 7bc3 b2ff 8000 0700 + 0x0050: 0000 0046 0ee3 0003 8015 00b3 0000 f700 + 0x0060: dfee 0500 0000 0000 0000 0000 0000 0000 + 0x0070: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x0080: 0000 de00 0000 0000 0000 0000 0000 0001 + 0x0090: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x00a0: 00 + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 140 + no Attribute 0 decoder + 0x0000: 0000 0000 0000 0080 27ef 0000 0100 c600 + 0x0010: 007f f3f9 8900 0107 07d4 2d9d a102 80fd + 0x0020: ecff ff04 00ff 4000 0000 ffff ffff ffff + 0x0030: 002d 0200 03f1 ff7b c3b2 ff80 0007 434c + 0x0040: 4945 4e54 0000 00df 00c1 2300 0000 0000 + 0x0050: ff00 0000 ff00 0000 04ff ffff ffff ffff + 0x0060: ffff ffff 002d 0200 03f1 ff7b c3b2 ff80 + 0x0070: 0007 0000 0000 460e e300 0380 1500 b300 + 0x0080: 00f7 00df ee35 0000 0500 0000 + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder[|BGP] [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 223 + Unknown Attribute (193), length: 35 + no Attribute 193 decoder + 0x0000: 0000 0000 00a1 0200 0aff ffff ffff ffff + 0x0010: ffff ffff ffff ffff ff00 2d02 0003 f1ff + 0x0020: 7bc3 b2 + Unknown Attribute (241), length: 255, Flags [+3]: + no Attribute 241 decoder + 0x0000: 7bc3 b2ff 8000 0700 0000 0046 0ee3 0003 + 0x0010: 8001 00b3 0000 f700 dfee 0500 0000 0000 + 0x0020: 0000 0000 0d00 0000 0000 0000 0000 0000 + 0x0030: 0000 0000 0000 00ff 8000 0700 0000 0046 + 0x0040: 0ee3 0003 8015 00cd 0000 f700 dfee 0500 + 0x0050: 0000 0000 0000 0000 1b00 0000 fff5 0000 + 0x0060: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x0070: 0000 0000 0000 0000 5000 2d9d a102 80fd + 0x0080: ffff ffff ffff ffff ffff ffff ffff ffff + 0x0090: 002d 0200 03f1 ff7b c3b2 ff80 0007 0000 + 0x00a0: 00df 00c1 2300 0000 0000 a102 009e ffff + 0x00b0: ffff ffff ffff ffff ffff ffff 9494 942d + 0x00c0: 0200 03f1 ff7b c3b2 ff80 0007 0000 0000 + 0x00d0: 460e e300 0380 1500 b300 00f7 00df ee05 + 0x00e0: 0000 0000 0000 0000 0000 0000 0000 0000 + 0x00f0: 0000 0000 0000 0000 0000 0000 0000 00 + Unknown Attribute (0), length: 0, Flags [OTE+e]: + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0, Flags [+1]: + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 140 + no Attribute 0 decoder + 0x0000: 0000 0000 0000 0080 27ef 0000 0100 c600 + 0x0010: 007f f3f9 8900 0107 07d4 2d9d a102 80fd + 0x0020: ecff ff04 00ff 4000 0000 ffff ffff ffff + 0x0030: 002d 0200 03f1 ff7b c3b2 ff80 0007 434c + 0x0040: 4945 4e54 0000 00df 00c1 2300 0000 0000 + 0x0050: ff00 0000 ff00 0000 04ff ffff ffff ffff + 0x0060: ffff ffff 002d 0200 03f1 ff7b c3b2 ff80 + 0x0070: 0007 0000 0000 460e e300 0380 1500 b300 + 0x0080: 00f7 00df ee35 0000 0500 0000 + Unknown Attribute (0), length: 0 + no Attribute 0 decoder + Unknown Attribute (0), length: 0 + no Attribute 0 decoder[|BGP] [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Unknown Attribute (241), length: 255, Flags [+3]: [|BGP] [|BGP] + Update Message (2), length: 45 + Withdrawn routes: 3 bytes + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 223 + Unknown Attribute (193), length: 35 + no Attribute 193 decoder + 0x0000: 0000 0000 00a1 0200 9eff ffff ffff ffff + 0x0010: ffff ffff ffff ff94 9494 2d02 0003 f1ff + 0x0020: 7bc3 b2 + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 0 + Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: + AFI: NSAP (3), SAFI: labeled VPN Unicast (128) + nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.0000.0000, nh-length: 21, no SNPA + (illegal prefix length) + Attribute Set (128), length: 7, Flags [OTPE+f]: + Origin AS: 0 + Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: + AFI: NSAP (3), SAFI: labeled VPN Unicast (128) + nexthop: RD: unknown RD format, 35.0000.0500.0000.0000.0000.0000, nh-length: 21, no SNPA + (illegal prefix length)[|BGP] Index: vendor/tcpdump/dist/tests/bgp_mp_reach_nlri-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/bgp_mp_reach_nlri-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/crypto.sh =================================================================== --- vendor/tcpdump/dist/tests/crypto.sh (revision 353143) +++ vendor/tcpdump/dist/tests/crypto.sh (revision 353144) @@ -1,147 +1,157 @@ #!/bin/sh +srcdir=${1-..} +: echo crypto.sh using ${srcdir} from `pwd` + +SRCDIR=$srcdir +export SRCDIR + +testdir=${srcdir}/tests + exitcode=0 +passedfile=tests/.passed +failedfile=tests/.failed +passed=`cat ${passedfile}` +failed=`cat ${failedfile}` # Only attempt OpenSSL-specific tests when compiled with the library. -if grep '^#define HAVE_LIBCRYPTO 1$' ../config.h >/dev/null +if grep '^#define HAVE_LIBCRYPTO 1$' config.h >/dev/null then - passed=`cat .passed` - failed=`cat .failed` - if ./TESTonce esp1 02-sunrise-sunset-esp.pcap esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"' + if ${testdir}/TESTonce esp1 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce esp2 08-sunrise-sunset-esp2.pcap esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"' + if ${testdir}//TESTonce esp2 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce esp3 02-sunrise-sunset-esp.pcap esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"' + if ${testdir}/TESTonce esp3 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi # Reading the secret(s) from a file does not work with Capsicum. - if grep '^#define HAVE_CAPSICUM 1$' ../config.h >/dev/null + if grep '^#define HAVE_CAPSICUM 1$' config.h >/dev/null then FORMAT=' %-35s: TEST SKIPPED (compiled w/Capsicum)\n' printf "$FORMAT" esp4 printf "$FORMAT" esp5 printf "$FORMAT" espudp1 printf "$FORMAT" ikev2pI2 printf "$FORMAT" isakmp4 else - if ./TESTonce esp4 08-sunrise-sunset-esp2.pcap esp2.out '-E "file esp-secrets.txt"' + if ${testdir}/TESTonce esp4 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp4.out '-E "file '${testdir}'/esp-secrets.txt"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce esp5 08-sunrise-sunset-aes.pcap esp5.out '-E "file esp-secrets.txt"' + if ${testdir}/TESTonce esp5 ${testdir}/08-sunrise-sunset-aes.pcap ${testdir}/esp5.out '-E "file '${testdir}'/esp-secrets.txt"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce espudp1 espudp1.pcap espudp1.out '-nnnn -E "file esp-secrets.txt"' + if ${testdir}/TESTonce espudp1 ${testdir}/espudp1.pcap ${testdir}/espudp1.out '-nnnn -E "file '${testdir}'/esp-secrets.txt"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce ikev2pI2 ikev2pI2.pcap ikev2pI2.out '-E "file ikev2pI2-secrets.txt" -v -v -v -v' + if ${testdir}/TESTonce ikev2pI2 ${testdir}/ikev2pI2.pcap ${testdir}/ikev2pI2.out '-E "file '${testdir}'/ikev2pI2-secrets.txt" -v -v -v -v' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce isakmp4 isakmp4500.pcap isakmp4.out '-E "file esp-secrets.txt"' + if ${testdir}/TESTonce isakmp4 ${testdir}/isakmp4500.pcap ${testdir}/isakmp4.out '-E "file '${testdir}'/esp-secrets.txt"' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi fi - if ./TESTonce bgp-as-path-oobr-ssl bgp-as-path-oobr.pcap bgp-as-path-oobr-ssl.out '-vvv -e' + if ${testdir}/TESTonce bgp-as-path-oobr-ssl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-ssl.out '-vvv -e' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce bgp-aigp-oobr-ssl bgp-aigp-oobr.pcap bgp-aigp-oobr-ssl.out '-vvv -e' + if ${testdir}/TESTonce bgp-aigp-oobr-ssl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-ssl.out '-vvv -e' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi FORMAT=' %-35s: TEST SKIPPED (compiled w/OpenSSL)\n' printf "$FORMAT" bgp-as-path-oobr-nossl printf "$FORMAT" bgp-aigp-oobr-nossl else FORMAT=' %-35s: TEST SKIPPED (compiled w/o OpenSSL)\n' printf "$FORMAT" esp1 printf "$FORMAT" esp2 printf "$FORMAT" esp3 printf "$FORMAT" esp4 printf "$FORMAT" esp5 printf "$FORMAT" espudp1 printf "$FORMAT" ikev2pI2 printf "$FORMAT" isakmp4 printf "$FORMAT" bgp-as-path-oobr-ssl printf "$FORMAT" bgp-aigp-oobr-ssl - if ./TESTonce bgp-as-path-oobr-nossl bgp-as-path-oobr.pcap bgp-as-path-oobr-nossl.out '-vvv -e' + if ${testdir}/TESTonce bgp-as-path-oobr-nossl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-nossl.out '-vvv -e' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi - if ./TESTonce bgp-aigp-oobr-nossl bgp-aigp-oobr.pcap bgp-aigp-oobr-nossl.out '-vvv -e' + if ${testdir}/TESTonce bgp-aigp-oobr-nossl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-nossl.out '-vvv -e' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi fi exit $exitcode Index: vendor/tcpdump/dist/tests/cve-2018-10105-segv-sflowprint.out =================================================================== --- vendor/tcpdump/dist/tests/cve-2018-10105-segv-sflowprint.out (nonexistent) +++ vendor/tcpdump/dist/tests/cve-2018-10105-segv-sflowprint.out (revision 353144) @@ -0,0 +1,2 @@ +IP (tos 0x0, ttl 64, id 60790, offset 0, flags [none], proto UDP (17), length 896, bad cksum 72f3 (->72f7)!) + 10.0.0.250.3895 > 10.1.2.5.6343: sFlowv5 [length 8 < 28] (invalid) Index: vendor/tcpdump/dist/tests/cve-2018-10105-segv-sflowprint.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/cve-2018-10105-segv-sflowprint.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/cve-2018-10105_smbprint-readofsize1.out =================================================================== --- vendor/tcpdump/dist/tests/cve-2018-10105_smbprint-readofsize1.out (nonexistent) +++ vendor/tcpdump/dist/tests/cve-2018-10105_smbprint-readofsize1.out (revision 353144) @@ -0,0 +1,8 @@ +IP 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], seq 4267808374:4267808462, ack 628292694, win 63102, length 88 SMB PACKET: SMBtrans2 (REPLY) + +IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 1:75, ack 88, win 254, length 74 SMB PACKET: SMBtrans2 (REQUEST) + +IP 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], seq 88:168, ack 75, win 62978, length 80 SMB PACKET: SMBtrans2 (REPLY) + +IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 75:151, ack 168, win 253, length 76 SMB PACKET: SMBtrans2 (REQUEST) + Index: vendor/tcpdump/dist/tests/cve-2018-10105_smbprint-readofsize1.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/cve-2018-10105_smbprint-readofsize1.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/cve-2018-10105_smbutil_withoutasan.out =================================================================== --- vendor/tcpdump/dist/tests/cve-2018-10105_smbutil_withoutasan.out (nonexistent) +++ vendor/tcpdump/dist/tests/cve-2018-10105_smbutil_withoutasan.out (revision 353144) @@ -0,0 +1,101 @@ +IP (tos 0x0, ttl 128, id 376, offset 0, flags [DF], proto TCP (6), length 128) + 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], cksum 0x3e2f (incorrect -> 0x3d49), seq 4267808374:4267808462, ack 628292694, win 63102, length 88 +SMB PACKET: SMBtrans2 (REPLY) +SMB Command = 0x32 +Error class = 0x0 +Error code = 0 (0x0) +Flags1 = 0xFF +Flags2 = 0x7 +Tree ID = 2048 (0x800) +Proc ID = 2848 (0xb20) +UID = 4098 (0x1002) +MID = 1616 (0x650) +Word Count = 10 (0xa) +TRANSACT2_OPEN param_length=2 data_length=24 +TotParam=2 (0x2) +TotData=24 (0x18) +Res1=0x0 +ParamCnt=2 (0x2) +ParamOff=56 (0x38) +ParamDisp0 (0x0) +DataCnt=24 (0x18) +DataOff=60 (0x3c) +DataDisp=0 (0x0) +SetupCnt=0 (0x0) +smb_bcc=29 +Handle=0 (0x0) +Attrib=Data= +Data: (24 bytes) +[000] 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 \0x00\0x00\0x0b\0x00\0x00\0x00\0x00\0x00 \0x00\0x00\0x00\0x00\0x00\0x00\0x00\0x00 +[010] 01 00 00 00 00 00 00 00 \0x01\0x00\0x00\0x00\0x00\0x00\0x00\0x00 + +IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 1:75, ack 88, win 254, length 74 SMB PACKET: SMBtrans2 (REQUEST) + +IP (tos 0x0, ttl 128, id 632, offset 0, flags [DF], proto TCP (6), length 114) + 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], cksum 0x2437 (correct), seq 1:75, ack 88, win 254, length 74 +SMB PACKET: SMBtrans2 (REQUEST) +SMB Command = 0x32 +Error class = 0x0 +Error code = 0 (0x0) +Flags1 = 0x18 +Flags2 = 0x7 +Tree ID = 2048 (0x800) +Proc ID = 2848 (0xb20) +UID = 4098 (0x1002) +MID = 1632 (0x660) +Word Count = 15 (0xf) +TRANSACT2_QFSINFO param_length=2 data_length=0 +TotParam=2 (0x2) +TotData=0 (0x0) +MaxParam=0 (0x0) +MaxData=560 (0x230) +MaxSetup=0 (0x0) +Flags=0x0 +TimeOut=0 (0x0) +Res1=0x0 +ParamCnt=2 (0x2) +ParamOff=68 (0x44) +DataCnt=0 (0x0) +DataOff=0 (0x0) +SetupCnt=1 (0x1) +smb_bcc=5 +InfoLevel=261 (0x105) + + +IP (tos 0x0, ttl 128, id 377, offset 0, flags [DF], proto TCP (6), length 120) + 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], cksum 0xf1fb (incorrect -> 0x1559), seq 88:168, ack 75, win 63028, length 80 +SMB PACKET: SMBtrans2 (REPLY) +SMB Command = 0x32 +Error class = 0x0 +Error code = 0 (0x0) +Flags1 = 0x98 +Flags2 = 0x7 +Tree ID = 0 (0x0) +Proc ID = 0 (0x0) +UID = 0 (0x0) +MID = 0 (0x0) +Word Count = 11 (0xb) +TRANSACT2_QFSINFO param_length=0 data_length=20 +TotParam=0 (0x0) +TotData=0 (0x0) +Res1=0x0 +ParamCnt=0 (0x0) +ParamOff=56 (0x38) +ParamDisp0 (0x0) +DataCnt=20 (0x14) +DataOff=56 (0x38) +DataDisp=0 (0x0) +SetupCnt=0 (0x0) +smb_bcc=65280 +Capabilities=0x700FF +MaxFileLen=255 (0xff) +VolNameLen=4278190088 +Volume=... +data: +[000] FF 00 07 00 FF 00 00 00 08 00 00 FF FF FF FF 00 \0xff\0x00\0x07\0x00\0xff\0x00\0x00\0x00 \0x08\0x00\0x00\0xff\0xff\0xff\0xff\0x00 +[010] 46 00 53 00 F\0x00S\0x00 + + +IP (tos 0x0, ttl 128, id 633, offset 0, flags [DF], proto TCP (6), length 116) + 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], cksum 0x2253 (incorrect -> 0x229b), seq 75:151, ack 168, win 253, length 76 SMB-over-TCP packet:(raw data or continuation?) + Index: vendor/tcpdump/dist/tests/cve-2018-10105_smbutil_withoutasan.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/cve-2018-10105_smbutil_withoutasan.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out =================================================================== --- vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out (revision 353143) +++ vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out (revision 353144) @@ -1,3 +1,4 @@ IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103)[|MOBILITY] IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: (header length 8 is too small for type 6)[|MOBILITY] -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/cve2015-0261-ipv6.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file cve2015-0261-ipv6.pcap, link-type SLIP (SLIP) +tcpdump: pcap_loop: invalid packet capture length 268463617, bigger than snaplen of 65535 Index: vendor/tcpdump/dist/tests/dccp_options-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/dccp_options-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/dccp_options-oobr.out (revision 353144) @@ -0,0 +1,19 @@ +IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xaaf3 (incorrect -> 0x8bf3)) DCCP-Request (service=-189888898) seq 8 +IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68) + 139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, ) DCCP-Response (service=0) (ack=38464816766) seq 1960341146 +IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56) + 139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xf53a (incorrect -> 0xf551)) DCCP-Ack (ack=1960341146) seq 38464816767 +IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152) + 139.133.209.176.46076 > 139.133.209.65.48009: DCCP (CCVal 0, CsCov 6, ) DCCP-DataAck (ack=1960341146) seq 38464816768 +IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfc63 (correct)) DCCP-Ack (ack=38464816768) seq 1960341147 +IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148) + 139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, ) DCCP-DataAck (ack=1960341147) seq 38464816769 +IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52) + 139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0x0165 (correct)) DCCP-Ack (ack=38464816769) seq 1960341148 +00:07:00:42:00:00 > 00:14:22:59:55:51 Null Information, send seq 0, rcv seq 0, Flags [Command], length 148 + 0x0000: 0000 0000 1422 5955 5100 07e9 bd5d 1f08 ....."YUQ....].. + 0x0010: 0045 0000 34ff 2040 0040 2181 8b8b 85d1 .E..4..@.@!..... + 0x0020: b08b 85d1 4199 fc13 8908 00aa f320 0000 ....A........... + 0x0030: 08f4 ae86 7e00 0000 ....~... Index: vendor/tcpdump/dist/tests/dccp_options-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/dccp_options-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/dns-zlip-1.out =================================================================== --- vendor/tcpdump/dist/tests/dns-zlip-1.out (revision 353143) +++ vendor/tcpdump/dist/tests/dns-zlip-1.out (revision 353144) @@ -1 +1 @@ -IP 10.0.0.1.1024 > 146.84.28.88.53: 60777 Type49159 (Class 49168)? [|domain] +IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid) Index: vendor/tcpdump/dist/tests/dns-zlip-2.out =================================================================== --- vendor/tcpdump/dist/tests/dns-zlip-2.out (revision 353143) +++ vendor/tcpdump/dist/tests/dns-zlip-2.out (revision 353144) @@ -1 +1 @@ -IP 10.0.0.1.1024 > 146.84.28.88.53: 18992 Type49164 (Class 49168)? [|domain] +IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid) Index: vendor/tcpdump/dist/tests/dns-zlip-3.out =================================================================== --- vendor/tcpdump/dist/tests/dns-zlip-3.out (revision 353143) +++ vendor/tcpdump/dist/tests/dns-zlip-3.out (revision 353144) @@ -1 +1 @@ -IP 10.0.0.1.1024 > 146.84.28.88.53: 65483 Type49164 (Class 49164)? thisleetostringwillcrashyourlittlenameserverforsurehahahahahah.[|domain] +IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid) Index: vendor/tcpdump/dist/tests/eapon2.out =================================================================== --- vendor/tcpdump/dist/tests/eapon2.out (nonexistent) +++ vendor/tcpdump/dist/tests/eapon2.out (revision 353144) @@ -0,0 +1,61 @@ +ARP, Request who-has 192.168.1.1 tell 192.168.1.249, length 28 +ARP, Reply 192.168.1.1 is-at 00:0d:88:4f:25:91, length 46 +IP 192.168.1.249.68 > 192.168.1.1.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +EAP packet (0) v1, len 5 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +EAPOL start (1) v1, len 0 +EAP packet (0) v1, len 5 +EAP packet (0) v1, len 45 +EAP packet (0) v1, len 20 +EAP packet (0) v1, len 76 +EAP packet (0) v1, len 80 +EAP packet (0) v1, len 28 +EAP packet (0) v1, len 4 +EAPOL key (3) v1, len 57 +EAPOL key (3) v1, len 44 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +EAPOL start (1) v1, len 0 +EAP packet (0) v1, len 5 +EAP packet (0) v1, len 45 +EAP packet (0) v1, len 20 +EAP packet (0) v1, len 76 +EAP packet (0) v1, len 80 +EAP packet (0) v1, len 28 +EAP packet (0) v1, len 4 +EAPOL key (3) v1, len 57 +EAPOL key (3) v1, len 44 +ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28 +ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28 +ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28 +IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133 +IP 169.254.67.194 > 224.0.0.22: igmp v3 report, 1 group record(s) +IP 169.254.67.194 > 224.0.0.22: igmp v3 report, 1 group record(s) +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133 +EAPOL start (1) v1, len 0 +EAP packet (0) v1, len 5 +EAP packet (0) v1, len 45 +EAP packet (0) v1, len 20 +EAP packet (0) v1, len 76 +EAP packet (0) v1, len 80 +EAP packet (0) v1, len 28 +EAP packet (0) v1, len 4 +EAPOL key (3) v1, len 57 +EAPOL key (3) v1, len 44 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300 +EAPOL start (1) v1, len 0 +EAP packet (0) v1, len 5 +EAP packet (0) v1, len 45 +EAP packet (0) v1, len 20 +EAP packet (0) v1, len 76 +EAP packet (0) v1, len 80 +EAP packet (0) v1, len 28 +EAP packet (0) v1, len 4 +EAPOL key (3) v1, len 57 +EAPOL key (3) v1, len 44 Index: vendor/tcpdump/dist/tests/eapon2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/eapon2.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/esp4.out =================================================================== --- vendor/tcpdump/dist/tests/esp4.out (nonexistent) +++ vendor/tcpdump/dist/tests/esp4.out (revision 353144) @@ -0,0 +1,8 @@ +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x1), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x1), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1280, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x2), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x2), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1536, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x3), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x3), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1792, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x4), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x4), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2048, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x5), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x5), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2304, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x6), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x6), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2560, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x7), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x7), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2816, length 64 (ipip-proto-4) (ipip-proto-4) +IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x8), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x8), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 3072, length 64 (ipip-proto-4) (ipip-proto-4) Index: vendor/tcpdump/dist/tests/frf16_magic_ie-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/frf16_magic_ie-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/frf16_magic_ie-oobr.out (revision 353144) @@ -0,0 +1,2 @@ +FRF.16 Control, Flags [Begin, End, Control], Unknown Message (0x00), length 3714318497 + IE Magic Number (3), length 3: (invalid length)[|mfr] Index: vendor/tcpdump/dist/tests/frf16_magic_ie-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/frf16_magic_ie-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/hncp_prefix-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/hncp_prefix-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/hncp_prefix-oobr.out (revision 353144) @@ -0,0 +1,48 @@ +IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 436) fe80::b299:28ff:ffc8:d646.6696 > ff02::59:0:0:1:6.6696: [bad udp cksum 0x2997 -> 0xbbd2!] babel 2 (424) + Hello seqno 58134 interval 4.00s sub-unknown-0x08 sub-pad1 sub-pad1 sub-unknown-0x04 sub-unknown-0x30 sub-diversity 2-2 (bogus) sub-diversity 2-2 (bogus) sub-diversity 2-48 (bogus) (invalid) + Unknown message type 48 + Unknown message type 223 + Pad 1 + Unknown message type 51 + Pad 1 + Pad 1 + Pad 1 + HMAC (invalid) +IP6 (hlim 57, next-header UDP (17) payload length: 332) fe80::218:f3ff:ffa9:914e.8231 > fe80::21e:64ff:fe23:4d34.8231: [bad udp cksum 0xbd4b -> 0x0e98!] hncp (324) + Node endpoint (12) NID: 31:da:78:d2 EPID: 03000000 + Node state (312) NID: 31:da:78:d2 seqno: 19 160.105s hash: 800088c8e0714638 + Peer (16) Peer-NID: 61:69:ed:63 Peer-EPID: 01000000 Local-EPID: 01000000 + HNCP-Version (22) M: 0 P: 4 H: 4 L: 4 User-agent: hnetd/cac971d + External-Connection (52) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Reserved: type=0 (4) + Unassigned: type=510 (4) + Assigned-Prefix (18) EPID: 03000000 Prty: 2 Prefix: fd1f:f88c:e200::/44 + (invalid) + Assigned-Prefix (25) EPID: 01000001 Prty: 0 Prefix: ::/0 + Reserved: type=0 (4) + Reserved: type=0 (4) + [|hncp] + Assigned-Prefix (25) EPID: 03000000 Prty: 2 Prefix: 10.0.101.0/24 + Node-Address (24) EPID: 01000000 IP Address: ::2100:0:ffff:a00:6302 + Node-Address (24) EPID: 01000000 IP Address: fd1f:f88c:e207::f3ff + [|hncp] +IP6 (hlim 64, next-header UDP (17) payload length: 564) fe80::218:f3ff:fea9:914e.8231 > fe80::21e:64ff:fe23:4d34.8231: [bad udp cksum 0xe65a -> 0x7725!] hncp (556) + Node endpoint (12) NID: 31:10:00:00 EPID: 00000000 + Node state (544) NID: 61:69:ed:63 seqno: 12 969.699s hash: 011fffa1da966148 + Peer (16) Peer-NID: 31:da:78:d2 Peer-EPID: 01000000 Local-EPID: 01000000 + Future use: type=64031 (22) + External-Connection (23) + Delegated-Prefix (19) VLSO: 0.599s PLSO: 0.299s Prefix: fd1f:f88c:e207::/48 + Assigned-Prefix (143) EPID: 8b8b8b8b Prty: 11 Prefix: (invalid) + Private use: type=768 (4) + [|hncp] Index: vendor/tcpdump/dist/tests/hncp_prefix-oobr.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/hncp_prefix-oobr.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-1.out =================================================================== --- vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-1.out (nonexistent) +++ vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-1.out (revision 353144) @@ -0,0 +1,7 @@ +IP (tos 0x4, ttl 64, id 3584, offset 0, flags [none], proto ICMP (1), length 23, bad cksum a (->1e0f)!) + 22.3.2.0 > 54.209.0.0: ICMP type-#49, length 3[|icmp] +IP (tos 0x4, ttl 64, id 32512, offset 0, flags [none], proto VRRP (112), length 31, bad cksum 82 (->db96)!) + 22.3.211.0 > 54.209.0.0: vrrp 22.3.211.0 > 54.209.0.0: VRRPv3, Advertisement, (ttl 64), vrid 128, prio 69[|vrrp] +c0:05:ff:ff:40:9d > 00:0c:02:49:96:7e, ethertype Unknown (0xf1ff), length 65570: + 0x0000: 4404 0020 0e00 0000 4070 000a 1603 0200 D.......@p...... + 0x0010: 36d1 0000 3180 bc 6...1.. Index: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-1.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-1.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-2.out =================================================================== --- vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-2.out (nonexistent) +++ vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-2.out (revision 353144) @@ -0,0 +1,5 @@ +IP truncated-ip - 39 bytes missing! (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 68, options (unknown 69 [bad length 83]), bad cksum 9b15 (->b774)!) + 250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254)[|vrrp] +[|fr] +IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto ICMP (1), length 30, options (unknown 201 [bad length 255]), bad cksum 101 (->6470)!) + 1.241.1.250 > 219.91.15.170: ICMP type-#255, length 2[|icmp] Index: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/icmp-icmp_print-oobr-2.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/icmp6_mobileprefix_asan.out =================================================================== --- vendor/tcpdump/dist/tests/icmp6_mobileprefix_asan.out (revision 353143) +++ vendor/tcpdump/dist/tests/icmp6_mobileprefix_asan.out (revision 353144) @@ -1,2 +1,2 @@ -IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header ICMPv6 (58) payload length: 7168) 4f:f829:c:1a1a:1a1a:1a1a:1a37:0 > 16:0:400:0:64fb:9303:f293:8200: ICMP6, mobile router advertisement, length 7168, id 0x9393[|icmp6] +IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header ICMPv6 (58) payload length: 7168) 4f:f829:c:1a1a:1a1a:1a1a:1a37:0 > 16:0:400:0:64fb:9303:f293:8200: ICMP6, mobile router advertisement, length 7168, id 0x9393 [|icmp6] [|ether] Index: vendor/tcpdump/dist/tests/icmp6_nodeinfo_oobr.out =================================================================== --- vendor/tcpdump/dist/tests/icmp6_nodeinfo_oobr.out (revision 353143) +++ vendor/tcpdump/dist/tests/icmp6_nodeinfo_oobr.out (revision 353144) @@ -1 +1 @@ -IP6 a072:7f00:1:7f00:1:e01a:17:6785 > c903::a002:8018:fe30:0:204: ICMP6, who-are-you reply[|icmp6], length 4 +IP6 a072:7f00:1:7f00:1:e01a:17:6785 > c903::a002:8018:fe30:0:204: ICMP6, who-are-you reply [|icmp6], length 4 Index: vendor/tcpdump/dist/tests/icmpv6.out =================================================================== --- vendor/tcpdump/dist/tests/icmpv6.out (revision 353143) +++ vendor/tcpdump/dist/tests/icmpv6.out (revision 353144) @@ -1,26 +1,26 @@ IP6 (hlim 255, next-header ICMPv6 (58) payload length: 176) fe80::b299:28ff:fec8:d66c > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 176 - hop limit 64, Flags [home agent], pref medium, router lifetime 15s, reachable time 0s, retrans time 0s + hop limit 64, Flags [home agent], pref medium, router lifetime 15s, reachable time 0ms, retrans timer 0ms prefix info option (3), length 32 (4): 2222:3333:4444:5555:6600::/72, Flags [onlink, auto], valid time 2592000s, pref. time 604800s 0x0000: 48c0 0027 8d00 0009 3a80 0000 0000 2222 0x0010: 3333 4444 5555 6600 0000 0000 0000 rdnss option (25), length 40 (5): lifetime 5s, addr: abcd::efef addr: 1234:5678::1 0x0000: 0000 0000 0005 abcd 0000 0000 0000 0000 0x0010: 0000 0000 efef 1234 5678 0000 0000 0000 0x0020: 0000 0000 0001 dnssl option (31), length 56 (7): lifetime 5s, domain(s): example.com. example.org. dom1.dom2.tld. 0x0000: 0000 0000 0005 0765 7861 6d70 6c65 0363 0x0010: 6f6d 0007 6578 616d 706c 6503 6f72 6700 0x0020: 0464 6f6d 3104 646f 6d32 0374 6c64 0000 0x0030: 0000 0000 0000 mtu option (5), length 8 (1): 100 0x0000: 0000 0000 0064 source link-address option (1), length 8 (1): b0:99:28:c8:d6:6c 0x0000: b099 28c8 d66c advertisement interval option (7), length 8 (1): 5000ms 0x0000: 0000 0000 1388 homeagent information option (8), length 8 (1): preference 50001, lifetime 15 0x0000: 0000 c351 000f IP6 (hlim 1, next-header Options (0) payload length: 36) fe80::215:17ff:fecc:e546 > ff02::16: HBH (rtalert: 0x0000) (padn) [icmp6 sum ok] ICMP6, multicast listener report v2, 1 group record(s) [gaddr ff02::db8:1122:3344 to_ex { }] IP6 (hlim 1, next-header Options (0) payload length: 36) fe80::b2a8:6eff:fe0c:d4e8 > ff02::1: HBH (rtalert: 0x0000) (padn) [icmp6 sum ok] ICMP6, multicast listener query v2 [max resp delay=10000] [gaddr :: robustness=2 qqi=60] IP6 (hlim 1, next-header Options (0) payload length: 96) fe80::215:17ff:fecc:e546 > ff02::16: HBH (rtalert: 0x0000) (padn) [icmp6 sum ok] ICMP6, multicast listener report v2, 4 group record(s) [gaddr ff02::db8:1122:3344 is_ex { }] [gaddr ff02::1:ffcc:e546 is_ex { }] [gaddr ff02::1:ffa7:10ad is_ex { }] [gaddr ff02::1:ff00:2 is_ex { }] IP6 (hlim 1, next-header Options (0) payload length: 36) fe80::215:17ff:fecc:e546 > ff02::16: HBH (rtalert: 0x0000) (padn) [icmp6 sum ok] ICMP6, multicast listener report v2, 1 group record(s) [gaddr ff02::db8:1122:3344 to_in { }] Index: vendor/tcpdump/dist/tests/icmpv6_opt24-v.out =================================================================== --- vendor/tcpdump/dist/tests/icmpv6_opt24-v.out (revision 353143) +++ vendor/tcpdump/dist/tests/icmpv6_opt24-v.out (revision 353144) @@ -1,16 +1,16 @@ IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120 - hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s + hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0ms, retrans timer 0ms source link-address option (1), length 8 (1): 14:cf:92:87:23:d6 mtu option (5), length 8 (1): 1500 prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s route info option (24), length 16 (2): fd8d:4fb3:5b2e::/48, pref=medium, lifetime=7200s rdnss option (25), length 24 (3): lifetime 1800s, addr: fd8d:4fb3:5b2e::1 dnssl option (31), length 16 (2): lifetime 1800s, domain(s): lan. IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120 - hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s + hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0ms, retrans timer 0ms source link-address option (1), length 8 (1): 14:cf:92:87:23:d6 mtu option (5), length 8 (1): 1500 prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s route info option (24), length 16 (2): fd8d:4fb3:5b2e::/48, pref=medium, lifetime=7200s rdnss option (25), length 24 (3): lifetime 1800s, addr: fd8d:4fb3:5b2e::1 dnssl option (31), length 16 (2): lifetime 1800s, domain(s): lan. Index: vendor/tcpdump/dist/tests/ieee802.11_meshhdr-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/ieee802.11_meshhdr-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/ieee802.11_meshhdr-oobr.out (revision 353144) @@ -0,0 +1 @@ +3472328296059908144us tsft 24.0 Mb/s 12334 MHz Turbo 48dBm noise [|802.11][|802.11] Index: vendor/tcpdump/dist/tests/ieee802.11_meshhdr-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/ieee802.11_meshhdr-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/isakmp-ikev1_n_print-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/isakmp-ikev1_n_print-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/isakmp-ikev1_n_print-oobr.out (revision 353144) @@ -0,0 +1,8 @@ +IP (tos 0x12,ECT(0), ttl 17, id 47119, offset 0, flags [+, DF, rsvd], proto UDP (17), length 296, bad cksum 1ff (->327b)!) + 80.236.128.20.500 > 12.251.0.45.49152: isakmp 2.12 msgid 10101010: child_sa ikev2_auth[V]: + (n: doi=0 proto=128 type=#24577) [|#126] (len mismatch: isakmp 4278190080/ip 268) +IP (tos 0x12,ECT(0), ttl 17, id 21263, offset 72, flags [+, DF, rsvd], proto unknown (40), length 296, bad cksum fbff (->9847)!) + 80.0.128.20 > 12.251.0.45: ip-proto-40 +IP (tos 0x15,ECT(1), ttl 17, id 21263, offset 0, flags [+, DF, rsvd], proto UDP (17), length 296, bad cksum 1ff (->9864)!) + 80.0.128.20.500 > 12.251.0.45.49152: isakmp 2.12 msgid 1010100b: child_sa ikev2_auth[V]: + (n: doi=ipsec proto=#16 type=REPLAY-STATUS spi=04 status=( [|n]) (len mismatch: isakmp 620756992/ip 268) Index: vendor/tcpdump/dist/tests/isakmp-ikev1_n_print-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/isakmp-ikev1_n_print-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/isis-seg-fault-1-v.sh =================================================================== --- vendor/tcpdump/dist/tests/isis-seg-fault-1-v.sh (revision 353143) +++ vendor/tcpdump/dist/tests/isis-seg-fault-1-v.sh (revision 353144) @@ -1,30 +1,37 @@ #!/bin/sh # This "verbose" ISIS protocol test involves a float calculation that # may produce a slightly different result if the compiler is not GCC. # Test only with GCC (similar to GitHub issue #333). exitcode=0 test_name=isis-seg-fault-1-v -if [ ! -f ../Makefile ] +srcdir=${1-..} +: echo $0 using ${srcdir} + +testdir=${srcdir}/tests +passedfile=tests/.passed +failedfile=tests/.failed +passed=`cat ${passedfile}` +failed=`cat ${failedfile}` + +if [ ! -f Makefile ] then printf ' %-35s: TEST SKIPPED (no Makefile)\n' $test_name -elif grep '^CC = .*gcc' ../Makefile >/dev/null +elif grep '^CC = .*gcc' Makefile >/dev/null then - passed=`cat .passed` - failed=`cat .failed` - if ./TESTonce $test_name isis-seg-fault-1.pcap isis-seg-fault-1-v.out '-v' + if ${testdir}/TESTonce $test_name ${testdir}/isis-seg-fault-1.pcap ${testdir}/isis-seg-fault-1-v.out '-v' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi else printf ' %-35s: TEST SKIPPED (compiler is not GCC)\n' $test_name fi exit $exitcode Index: vendor/tcpdump/dist/tests/juniper_header-heapoverflow.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: vendor/tcpdump/dist/tests/kday1.out =================================================================== --- vendor/tcpdump/dist/tests/kday1.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday1.out (revision 353144) @@ -1,2 +1,3 @@ IP6, wrong link-layer encapsulation -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday1.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday1.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday1.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday1.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: invalid packet capture length 138952731, bigger than snaplen of 65535 Index: vendor/tcpdump/dist/tests/kday2.out =================================================================== --- vendor/tcpdump/dist/tests/kday2.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday2.out (revision 353144) @@ -1,22 +1,23 @@ CFMv0 unknown (204), MD Level 0, length 168 First TLV offset 52 0x0000: a300 0000 0080 0000 0000 0000 0000 0000 0x0010: 0000 00aa 6873 54d7 060b 003c 0000 003c 0x0020: d4c3 b2a1 0200 1a00 000b 003c 0000 003c 0x0030: d4c3 b2a1 0200 1a00 0000 0000 3620 0a00 0x0040: b600 0000 b600 0000 40b5 9cbe 3048 0cc4 0x0050: ad37 1005 ffff 05cc 0934 9300 0000 0080 0x0060: 0000 0000 0000 3200 0000 0000 00aa 6873 Port status TLV (0x02), length 26, Status: Unknown (0) Unknown TLV (0x37), length 4101 packet is too short IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x66a1), ack 2339312418, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x8900), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday2.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday2.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday2.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday2.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 3 Index: vendor/tcpdump/dist/tests/kday3.out =================================================================== --- vendor/tcpdump/dist/tests/kday3.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday3.out (revision 353144) @@ -1,20 +1,21 @@ IP (tos 0x10, ttl 64, id 63177, offset 0, flags [DF], proto TCP (6), length 168) 204.9.54.80.22 > 204.9.51.132.50079: Flags [P.], cksum 0x0282 (incorrect -> 0x3217), seq 1819218606:1819218722, ack 1238485076, win 1039, options [nop,nop,TS val 1340592078 ecr 941371882], length 116 IP6, wrong link-layer encapsulation IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x0cf1), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2381534627 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 0, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xa6b3), seq 0:347, ack 1, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday3.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday3.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday3.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday3.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: invalid packet capture length 1817495761, bigger than snaplen of 65535 Index: vendor/tcpdump/dist/tests/kday4.out =================================================================== --- vendor/tcpdump/dist/tests/kday4.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday4.out (revision 353144) @@ -1,33 +1,34 @@ IP (tos 0x10, ttl 64, id 63177, offset 0, flags [none], proto unknown (240), length 168, bad cksum 418f (->80a5)!) 204.9.54.80 > 204.9.51.132: ip-proto-240 148 IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3da6 (->35a6)!) 212.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0x4811), ack 1819218606, win 17918, options [nop,nop,TS val 941371903 ecr 1340592074], length 0 84:b5:9c:be:30:48 Unknown SSAP 0x10 > 0c:c4:7a:08:e9:12 Unknown DSAP 0x44 Information, send seq 0, rcv seq 26, Flags [Command], length 52 0x0000: 4510 0034 f5c8 4000 3e06 4504 cc09 3384 E..4..@.>.E...3. 0x0010: cc09 3650 c39f 0016 49d1 c854 6c6f 1322 ..6P....I..Tlo." 0x0020: 8010 0ffc 858b 0000 0101 080a 381c 3209 ............8.2. 0x0030: 4fe7 cfd4 O... IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52) 204.9.54.80.55936 > 204.9.55.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x725a), ack 3589495407, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xcd5f), seq 3589495407:3589495754, ack 370436242, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xfa70), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv197 (unknown) IP truncated-ip - 768 bytes missing! (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 820, bad cksum 3da6 (->3aa6)!) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], seq 0:768, ack 1, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 768 IP (tos 0x6,ECT(0), ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->4524)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x3f28), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday4.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday4.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday4.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday4.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 1 Index: vendor/tcpdump/dist/tests/kday5.out =================================================================== --- vendor/tcpdump/dist/tests/kday5.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday5.out (revision 353144) @@ -1,22 +1,23 @@ CFMv0 unknown (204), MD Level 0, length 168 First TLV offset 52 0x0000: a300 0000 0080 0000 0000 0000 0000 0000 0x0010: 0000 00aa 6873 54d7 060b 003c 0000 003c 0x0020: d4c3 b2a1 0200 1a00 000b 003c 0000 003c 0x0030: d4c3 b2a1 0200 1a00 0000 0000 3620 0a00 0x0040: b600 0000 b600 0000 40b5 9cbe 3048 0cc4 0x0050: ad37 1005 ffff 05cc 0934 9300 0000 0080 0x0060: 0000 0000 0000 3200 0000 0000 00aa 6873 Port status TLV (0x02), length 26, Status: Unknown (0) Unknown TLV (0x37), length 4101 packet is too short IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x98c3), ack 1819279359, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x183a), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2351322531 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday5.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday5.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday5.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday5.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: invalid packet capture length 168430090, bigger than snaplen of 65535 Index: vendor/tcpdump/dist/tests/kday6.out =================================================================== --- vendor/tcpdump/dist/tests/kday6.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday6.out (revision 353144) @@ -1,350 +1,351 @@ FRF.16 Frag, seq 693, Flags [Begin], UI e8! IS-IS, length 301989913 L1 LSP, hlen: 27, v: 1, pdu-v: 1, sys-id-len: 6 (0), max-area: 131 (131) lsp-id: 8383.8383.834f.00-60, seq: 0x06418fcc, lifetime: 33667s chksum: 0x0900 (unverified), PDU length: 33667, Flags: [ Overload bit set, expense ATT bit set, L1 IS ] Multi-Topology Capability TLV #144, length: 137 O: 0, RES: 4, MTID(s): 3945 unknown subTLV #8, length: 233 [|isis] unknown TLV #213, length: 243 0x0000: 5cca 8010 0410 0594 4510 0410 6e55 0000 0x0010: 0101 080a 8cf3 ac2b 269c 0e2d 0e0e 0e0e 0x0020: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0030: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0040: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0050: 0e0e 0e0e 0e0e 0e0e 0e1b 0100 1201 8383 0x0060: 8383 8383 8383 8383 834f 0060 0641 8fcc 0x0070: 0900 2590 894f 6908 e912 0025 e489 4f0e 0x0080: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0090: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00a0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00b0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00c0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00d0: 7f0e 0e0e 0e0e 0e0e 0e0e 0e0e 0c0e 0e0e 0x00e0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00f0: 0e0e 0e LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 unknown TLV #100, length: 14 0x0000: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 unknown TLV #96, length: 183 0x0000: 0fbb 1627 4ce2 d5f3 5cca 8010 0410 0594 0x0010: 4510 0410 6e55 0000 0101 080a 8cf3 ac2b 0x0020: 269c 3ab9 a568 7354 404c 0c00 f702 0000 0x0030: f702 0000 84b5 9cbe 8cff ffff 0040 ff3e 0x0040: 88cc 0910 0410 0594 0000 0101 080a 269c 0x0050: 318b 8cf3 ac0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0060: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0070: 0e0e 0e0e 0004 0e0e 0e0e 0e0e 8e0e 0e0e 0x0080: 0e0e 0e0e 0e0b 0e0e 0e0e 0e0e 0e0e 0e0e 0x0090: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00a0: 0e00 3e20 0a00 b60d 0000 2000 0000 84b5 0x00b0: aee0 3083 8383 1b Area address(es) TLV #1, length: 0 unknown TLV #18, length: 1 0x0000: 83 Inter-Domain Information Type TLV #131, length: 131 Inter-Domain Information Type: Unknown (0x83) 0x0000: 8383 8383 8383 834f 0060 0641 8fcc 0900 0x0010: 2590 894f 6908 e912 0025 9089 4f69 0800 0x0020: 4500 0034 9040 4001 4006 a516 cc09 370a 0x0030: ccff ffff 7fbb da80 d5f3 5c05 1614 4a2d 0x0040: 8010 0410 6e55 0000 0101 080a 8cf3 ac2b 0x0050: 269c 30b9 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0060: 0e08 0e0e 0e0e 0e01 0e0e 0e0e 0e0e 110e 0x0070: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0080: 0e0e LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 unknown TLV #172, length: 198 0x0000: 2478 f620 70ac 2561 8ae3 3458 2d7a 4ea0 0x0010: d056 a568 7354 180e 0e0e 0e0e 0e0e 0e0e 0x0020: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0030: 0e0d f20e 0e0e 0e0e 0e0e 0e0e 0e04 0e0e 0x0040: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0050: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0060: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0070: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e49 0e0e 0x0080: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0d 0x0090: f20e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00a0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00b0: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x00c0: 0e0e 0e0e 0e0e LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3612 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 5 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3676 unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c44 4444 4444 4444 4444 4444 4444 4444 0x0030: 44b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0040: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0050: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 unknown TLV #183, length: 183 0x0000: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0010: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0020: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0030: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0040: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0050: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0060: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0070: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0080: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0090: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x00a0: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x00b0: b7b7 b7b7 b7b7 b7 unknown TLV #183, length: 183 0x0000: b7b7 b7b7 b7b7 b7b7 b7c0 b7b7 b7b7 b7b7 0x0010: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0020: b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 b7b7 0x0030: b7b7 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0040: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0050: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0060: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0070: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0080: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0090: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x00a0: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x00b0: 5c5c 5c5c 5c5c 5c unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0030: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0040: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0050: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0030: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0040: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0050: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c5c 715c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0030: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0040: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0050: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0030: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0040: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0050: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c unknown TLV #92, length: 92 0x0000: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0010: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0020: 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 5c5c 0x0030: 5c5c 5c5c 5c5c 5c5c 5c10 0594 4510 0410 0x0040: 6e55 0000 0101 080a 8cf3 ac2b 269c 3ab9 0x0050: a568 7354 404c 0c00 f702 0000 unknown TLV #247, length: 2 0x0000: 0000 IPv4 Interface address(es) TLV #132, length: 181 IPv4 interface address: 156.190.140.255 IPv4 interface address: 255.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.14.14 IPv4 interface address: 14.14.28.14 IPv4 interface address: 28.14.21.14 IPv4 interface address: 14.14.14.130 IPv4 interface address: 89.186.4.171 IPv4 interface address: 23.3.1.0 IPv4 interface address: 32.144.252.48 IPv4 interface address: 165.128.255.255 IPv4 interface address: 255.246.232.117 IPv4 interface address: 154.157.104.136 IPv4 interface address: 118.103.188.123 IPv4 interface address: 181.119.205.109 IPv4 interface address: 60.22.90.116 IPv4 interface address: 80.127.192.14 IPv4 interface address: 156.165.230.105 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 61197 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 13 LSP Buffersize: 244 unknown TLV #255, length: 0 unknown TLV #64, length: 6 0x0000: 3e88 cc09 3650 unknown TLV #204, length: 9 0x0000: 370a da80 01bb 0404 04 unknown TLV #11, length: 4 0x0000: 2104 0404 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 unknown TLV #234, length: 4 0x0000: 0404 0404 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 unknown TLV #0, length: 0 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 5 Purge Originator Identifier TLV #13, length: 178 Purge Originator System-ID: e4f9.cb0c.e2cd LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 Partition DIS TLV #4, length: 4 unknown TLV #0, length: 13 0x0000: b2c4 e4f9 cb0c e2cd 2e17 5a0b f3 unknown TLV #180, length: 146 0x0000: 01fa 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0010: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0020: 0e0e 0e28 0e0e 0e0e 0e0e fb0d 0e0e 0e0e 0x0030: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0040: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0050: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0060: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0070: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0080: 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0e0e 0x0090: 0e0e LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 IPv4 Internal Reachability TLV #128, length: 0 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 LSP Buffersize TLV #14, length: 14 LSP Buffersize: 3598 unknown TLV #58, length: 58 0x0000: 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 0x0010: 3a3a 3a [|isis] -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday6.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday6.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday6.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday6.pcap, link-type MFR (FRF.16 Frame Relay) +tcpdump: pcap_loop: invalid packet capture length 976894522, bigger than snaplen of 65535 Index: vendor/tcpdump/dist/tests/kday7.out =================================================================== --- vendor/tcpdump/dist/tests/kday7.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday7.out (revision 353144) @@ -1,33 +1,34 @@ IP (tos 0x10, ttl 64, id 63177, offset 0, flags [none], proto unknown (240), length 168, bad cksum 418f (->80a5)!) 204.9.54.80 > 204.9.51.132: ip-proto-240 148 IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3da6 (->35a6)!) 212.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0x4811), ack 1819218606, win 17918, options [nop,nop,TS val 941371903 ecr 1340592074], length 0 84:b5:9c:be:30:48 Unknown SSAP 0x10 > 0c:c4:7a:08:e9:12 Unknown DSAP 0x44 Information, send seq 0, rcv seq 26, Flags [Command], length 52 0x0000: 4510 0034 f5c8 4000 3e06 4504 cc09 3384 E..4..@.>.E...3. 0x0010: cc09 3650 c39f 0016 49d1 c854 6c6f 1322 ..6P....I..Tlo." 0x0020: 8010 0ffc 858b 0000 0101 080a 381c 3209 ............8.2. 0x0030: 4fe7 cfd4 O... IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52) 204.9.54.80.55936 > 204.9.55.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x725a), ack 3589495407, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xcd5f), seq 3589495407:3589495754, ack 370436242, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xfa86), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv197 (unknown) IP truncated-ip - 768 bytes missing! (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 820, bad cksum 3da6 (->3aa6)!) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], seq 0:768, ack 1, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 768 IP (tos 0x6,ECT(0), ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->4524)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x8d67), ack 1, win 1040, options [nop,nop,TS val 647770294 ecr 2364773722], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x4ba9), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday7.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday7.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday7.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday7.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: invalid packet capture length 138948798, bigger than snaplen of 511 Index: vendor/tcpdump/dist/tests/kday8.out =================================================================== --- vendor/tcpdump/dist/tests/kday8.out (revision 353143) +++ vendor/tcpdump/dist/tests/kday8.out (revision 353144) @@ -1,22 +1,23 @@ CFMv0 unknown (204), MD Level 0, length 168 First TLV offset 52 0x0000: a300 0000 0080 0000 0000 0000 0000 0000 0x0010: 0000 00aa 6873 54d7 060b 003c 0000 003c 0x0020: d4c3 b2a1 0200 1a00 000b 003c 0000 003c 0x0030: d4c3 b2a1 0200 1a00 0000 0000 3620 0a00 0x0040: b600 0000 b600 0000 40b5 9cbe 3048 0cc4 0x0050: ad37 1005 ffff 05cc 0934 9300 0000 0080 0x0060: fffa 0000 0000 3200 0000 0000 00aa 6873 Port status TLV (0x02), length 26, Status: Unknown (0) Unknown TLV (0x37), length 4101 packet is too short IP (tos 0x10, ttl 62, id 64806, offset 0, flags [DF], proto TCP (6), length 52) 204.9.51.132.50079 > 204.9.54.80.22: Flags [.], cksum 0x8611 (incorrect -> 0xa678), ack 1819218606, win 4094, options [nop,nop,TS val 941371775 ecr 4294967242], length 0 IP (tos 0x10, ttl 62, id 62920, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 4504 (->451a)!) 204.9.51.132.50079 > 204.243.53.80.22: Flags [.], cksum 0x858b (incorrect -> 0x85a1), ack 1819218722, win 4092, options [nop,nop,TS val 941371913 ecr 1340592084], length 0 IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 3e8c (->438c)!) 204.9.64.80.55936 > 204.9.40.10.443: Flags [.], cksum 0x0594 (incorrect -> 0x7767), ack 3587398274, win 1040, options [nop,nop,TS val 647770294 ecr 2364779354], length 0 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!) 204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xed9b), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347 RPKI-RTRv177 (unknown) -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kday8.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kday8.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kday8.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file kday8.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 3 Index: vendor/tcpdump/dist/tests/kh-addrfail-001.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-001.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-001.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-001.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-001.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-001.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3929026608_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-001.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-001.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-002.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-002.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-002.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-002.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-002.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-002.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _4281348144_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-002.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-002.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-003.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-003.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-003.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-003.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-003.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-003.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3794808880_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-003.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-003.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-004.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-004.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-004.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-004.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-004.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-004.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _2150641712_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-004.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-004.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-005.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-005.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-005.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-005.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-005.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-005.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1680879664_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-005.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-005.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-006.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-006.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-006.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-006.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-006.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-006.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _2905616432_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-006.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-006.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-007.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-007.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-007.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-007.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-007.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-007.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3710922800_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-007.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-007.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-008.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-008.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-008.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-008.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-008.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-008.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _808464432_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-008.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-008.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-009.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-009.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-009.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-009.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-009.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-009.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1932537904_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-009.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-009.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-010.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-010.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-010.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-010.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-010.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-010.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1915760688_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-010.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-010.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-addrfail-011.out =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-011.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-011.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/kh-addrfail-011.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/kh-addrfail-011.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/kh-addrfail-011.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _4046467120_ < 1048576 (BT_SHB_INSANE_MAX) Index: vendor/tcpdump/dist/tests/kh-addrfail-011.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/kh-addrfail-011.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-tcpdump-001.out =================================================================== --- vendor/tcpdump/dist/tests/kh-tcpdump-001.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-tcpdump-001.out (revision 353144) @@ -0,0 +1,17 @@ +30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: + 0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0020: 3030 00 +30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: + 0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0020: 3030 00 +30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: + 0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0020: 3030 00 +30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: + 0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 + 0x0020: 3030 00 +IP truncated-ip - 14 bytes missing! 48.48.48.48.525 > 48.48.48.48.12336: (tsp_type 0x30) vers 48 seq 12336 [|timed] Index: vendor/tcpdump/dist/tests/kh-tcpdump-001.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/kh-tcpdump-001.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-tcpdump-002.out =================================================================== --- vendor/tcpdump/dist/tests/kh-tcpdump-002.out (nonexistent) +++ vendor/tcpdump/dist/tests/kh-tcpdump-002.out (revision 353144) @@ -0,0 +1 @@ +IP 48.48.48.48.525 > 48.48.48.48.12336: (tsp_type 0x30) vers 48 seq 12336 [|timed] Index: vendor/tcpdump/dist/tests/kh-tcpdump-002.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/kh-tcpdump-002.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/kh-tcpdump-004.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/kh-tcpdump-004.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/l2tp-avp-overflow.out =================================================================== --- vendor/tcpdump/dist/tests/l2tp-avp-overflow.out (revision 353143) +++ vendor/tcpdump/dist/tests/l2tp-avp-overflow.out (revision 353144) @@ -1,39 +1,40 @@ IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->ab7b)!) 127.0.0.229.12416 > 127.0.128.1.1701: l2tp:[TL](560/2056) AVP-#60963() |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) AVP-#48() |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 8752, bad cksum 1f51 (->3890)!) 127.0.0.229.32767 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a90)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->ab5d)!) 127.0.0.0.0 > 0.0.0.0.2048: UDP, bad length 17704 > 12308 [|ether] IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) AVP-#48() |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 8752, bad cksum 1f51 (->3890)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a90)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->ab5d)!) 127.0.0.0.0 > 0.0.0.0.2048: UDP, bad length 17704 > 12308 [|ether] IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) AVP-#48() |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 8752, bad cksum 1f51 (->3890)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a90)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) ACCM(AVP too short) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) AVP-#48() |... IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 8752, bad cksum 1f51 (->3890)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) VENDOR0001:ATTR0023(0530) |... IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!) 127.0.0.229.12416 > 127.236.0.1.1701: l2tp:[TL](560/2056) VENDOR0080:ATTR06a5(19e8) |... -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/l2tp-avp-overflow.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/l2tp-avp-overflow.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/l2tp-avp-overflow.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file l2tp-avp-overflow.pcap, link-type EN10MB (Ethernet) +tcpdump: pcap_loop: invalid packet capture length 2147430448, bigger than snaplen of 58 Index: vendor/tcpdump/dist/tests/ldp-ldp_tlv_print-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/ldp-ldp_tlv_print-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/ldp-ldp_tlv_print-oobr.out (revision 353144) @@ -0,0 +1,6 @@ +IP (tos 0x0, id 4608, offset 0, flags [+, DF, rsvd], proto UDP (17), length 25600, options (EOL), bad cksum 8e (->4023)!) + 24.250.219.0.4098 > 0.0.0.0.646: + LDP, Label-Space-ID: 0.0.127.255:796, pdu-length: 514 + Address Withdraw Message (0x0301), length: 22, Message ID: 0x00001600, Flags: [ignore if unknown] + Unknown TLV (0x0404), length: 0, Flags: [ignore and don't forward if unknown] + Fault-Tolerant Session Parameters TLV (0x0503), length: 8, Flags: [ignore and don't forward if unknown] [|LDP] [|LDP] Index: vendor/tcpdump/dist/tests/ldp-ldp_tlv_print-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/ldp-ldp_tlv_print-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/lmp-lmp_print_data_link_subobjs-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/lmp-lmp_print_data_link_subobjs-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/lmp-lmp_print_data_link_subobjs-oobr.out (revision 353144) @@ -0,0 +1,20 @@ +IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!) + 17.8.8.255.701 > 40.184.42.8.12: + LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212 + Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20 + Flags: [none] + Local Interface ID: 2435832538 (0x912fdada) + Remote Interface ID: 3657433088 (0xda000000) + Subobject, Type: Interface Switching Type (1), Length: 4 + Switching Type: Unknown (0) + Encoding Type: Unknown (0) [|LMP] +IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!) + 17.8.8.255.701 > 40.184.42.8.12: + LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212 + Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20 + Flags: [none] + Local Interface ID: 2435832538 (0x912fdada) + Remote Interface ID: 3657433088 (0xda000000) + Subobject, Type: Interface Switching Type (1), Length: 4 + Switching Type: Unknown (0) + Encoding Type: Unknown (0) [|LMP] Index: vendor/tcpdump/dist/tests/lmp-lmp_print_data_link_subobjs-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/lmp-lmp_print_data_link_subobjs-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/lmp-v.sh =================================================================== --- vendor/tcpdump/dist/tests/lmp-v.sh (revision 353143) +++ vendor/tcpdump/dist/tests/lmp-v.sh (revision 353144) @@ -1,33 +1,41 @@ #!/bin/sh # The "verbose" Link Management Protocol test involves a float calculation that # may produce a slightly different result depending on the architecture and the # compiler (see GitHub issue #333). The reference output was produced using a # GCC build and must reproduce correctly on any other GCC build regardless of # the architecture. exitcode=0 +srcdir=${1-..} +: echo $0 using ${srcdir} +testdir=${srcdir}/tests +passedfile=tests/.passed +failedfile=tests/.failed +passed=`cat ${passedfile}` +failed=`cat ${failedfile}` + # A Windows build may have no file named Makefile and also a version of grep # that won't return an error when the file does not exist. Work around. -if [ ! -f ../Makefile ] +if [ ! -f Makefile ] then printf ' %-35s: TEST SKIPPED (no Makefile)\n' 'lmp-v' -elif grep '^CC = .*gcc' ../Makefile >/dev/null +elif grep '^CC = .*gcc' Makefile >/dev/null then - passed=`cat .passed` - failed=`cat .failed` - if ./TESTonce lmp-v lmp.pcap lmp-v.out '-T lmp -v' + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` + if ${testdir}/TESTonce lmp-v ${testdir}/lmp.pcap ${testdir}/lmp-v.out '-T lmp -v' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi else printf ' %-35s: TEST SKIPPED (compiler is not GCC)\n' 'lmp-v' fi exit $exitcode Index: vendor/tcpdump/dist/tests/lmpv1_busyloop.out =================================================================== --- vendor/tcpdump/dist/tests/lmpv1_busyloop.out (revision 353143) +++ vendor/tcpdump/dist/tests/lmpv1_busyloop.out (revision 353144) @@ -1,42 +1,41 @@ 00:80:ad:91:d8:6f > 00:0b:64:00:10:72, ethertype IPv4 (0x0800), length 725: (tos 0x0, ttl 128, id 35978, offset 0, flags [none], proto UDP (17), length 711) 168.152.32.1.701 > 168.152.32.39.701: [udp sum ok] LMPv1, msg-type: Config, Flags: [Control Channel Down], length: 257 Data Link Object (12), Class-Type: IPv4 (1) Flags: [non-negotiable], length: 516 Flags: [Allocated for user traffic] Local Interface ID: 0.0.2.0 (0x00000200) Remote Interface ID: 2.0.2.0 (0x02000200) Subobject, Type: Wavelength (2), Length: 0 (too short) 0x0000: 0253 e10b 0000 0200 0200 0200 0200 0200 0x0010: 0200 0200 0200 0200 0200 0200 0200 0200 0x0020: 0200 0200 0200 0200 0200 0200 0200 0200 0x0030: 0200 0200 0200 0200 0200 0200 0200 0200 0x0040: 0200 0280 6d00 0200 0200 0200 0200 0200 0x0050: 0200 0200 0200 0200 0200 0200 0200 0200 0x0060: 0200 0200 0200 0200 0200 0200 0200 0200 0x0070: 0200 0200 0200 0200 0200 0200 0200 8202 0x0080: 0002 0002 0002 0002 0002 0002 0002 0002 0x0090: 0002 0002 0002 0002 0002 0002 0002 0002 0x00a0: 0002 0002 0002 0002 0002 0002 0002 0002 0x00b0: 2002 0002 0002 0002 0002 0002 0002 0002 0x00c0: 0000 0200 0200 0002 0002 0000 0200 0200 0x00d0: 0002 0002 0000 0200 0200 0002 0002 0000 0x00e0: 0200 0200 0002 0002 0000 0200 0200 0002 0x00f0: 0002 0000 0200 0200 0002 0002 0000 0200 0x0100: 0200 0002 0002 0000 0200 0200 0002 0002 0x0110: 0000 0200 0200 0002 0002 0000 0200 0200 0x0120: 0002 0002 0000 0200 0200 0002 0002 0000 0x0130: 0200 0200 0002 0002 0000 0200 0200 0002 0x0140: 0002 0000 0200 0200 0002 0002 0000 0200 0x0150: 0200 0002 0002 0000 0200 0200 0002 0002 0x0160: 0000 0200 0200 0002 0002 0000 0200 0200 0x0170: 0002 0002 0000 0200 0200 0002 0002 0000 0x0180: 0200 0200 0002 0002 0000 0200 0200 0002 0x0190: 0002 0000 0200 0200 0002 0002 0000 0200 0x01a0: 0200 0002 0002 0000 0200 0200 0002 0002 0x01b0: 0000 0200 0200 0002 0002 0000 0200 0200 0x01c0: 0002 0002 0000 0200 0200 0002 0002 0000 0x01d0: 0200 0200 0002 0002 0000 0200 0200 0002 0x01e0: 0002 0000 0200 0200 0002 0002 0000 0200 0x01f0: 0200 0002 0002 0000 0200 0200 0002 0002 - Unknown Object (0), Class-Type: Unknown (0) Flags: [non-negotiable], length: 512 - packet exceeded snapshot + Unknown Object (0), Class-Type: Unknown (0) Flags: [non-negotiable], length: 512 [|LMP] Index: vendor/tcpdump/dist/tests/nflog-e.sh =================================================================== --- vendor/tcpdump/dist/tests/nflog-e.sh (revision 353143) +++ vendor/tcpdump/dist/tests/nflog-e.sh (revision 353144) @@ -1,24 +1,30 @@ #!/bin/sh exitcode=0 +srcdir=${1-..} +: echo $0 using ${srcdir} +testdir=${srcdir}/tests +passedfile=tests/.passed +failedfile=tests/.failed +passed=`cat ${passedfile}` +failed=`cat ${failedfile}` + # NFLOG support depends on both DLT_NFLOG and working -if grep '^#define HAVE_PCAP_NFLOG_H 1$' ../config.h >/dev/null +if grep '^#define HAVE_PCAP_NFLOG_H 1$' config.h >/dev/null then - passed=`cat .passed` - failed=`cat .failed` - if ./TESTonce nflog-e nflog.pcap nflog-e.out '-e' + if ${testdir}/TESTonce nflog-e ${testdir}/nflog.pcap ${testdir}/nflog-e.out '-e' then passed=`expr $passed + 1` - echo $passed >.passed + echo $passed >${passedfile} else failed=`expr $failed + 1` - echo $failed >.failed + echo $failed >${failedfile} exitcode=1 fi else printf ' %-35s: TEST SKIPPED (compiled w/o NFLOG)\n' 'nflog-e' fi exit $exitcode Index: vendor/tcpdump/dist/tests/of10_7050sx_bsn-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/of10_7050sx_bsn-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/of10_7050sx_bsn-oobr.out (revision 353144) @@ -0,0 +1,16 @@ +IP (tos 0x0, ttl 64, id 60713, offset 0, flags [DF], proto TCP (6), length 562) + 109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], seq 3422281781:3422282291, ack 774258090, win 252, options [nop,nop,TS val 590230876 ecr 50526785], length 510: OpenFlow + version 1.0, type VENDOR, length 24, xid 0x0000001a, vendor 0x005c16c7 (Big Switch Networks) + subtype SET_IP_MASK, index 1, mask 255.0.14.0 + version 1.0, type VENDOR, length 24, xid 0x0000001b, vendor 0x005c16c7 (Big Switch Networks) + subtype SET_IP_MASK, index 2, mask 255.0.28.0 + version 1.0, type VENDOR, length 24, xid 0x0000001c, vendor 0x005c16c7 (Big Switch Networks) + subtype SET_IP_MASK, index 3, mask 255.0.56.0 + version 1.0, type VENDOR, length 24, xid 0x0000001d, vendor 0x005c16c7 (Big Switch Networks) + subtype SET_IP_MASK, index 4, mask 255.0.112.0 + version 1.0, type VENDOR, length 24, xid 0x0000001e, vendor 0x005c16c7 (Big Switch Networks) + subtype SET_IP_MASK, index 5, mask 255.0.224.0 + version 1.0, type VENDOR, length 24, xid 0x0000001f, vendor 0x005c16c7 (Big Switch Networks) + subtype GET_IP_MASK_REQUEST, index 3 + version 1.0, type VENDOR, length 30, xid 0x00000020, vendor 0x005c16c7 (Big Switch Networks) + subtype SHELL_COMMAND, service 0, data 'show cloc' [|openflow] Index: vendor/tcpdump/dist/tests/of10_7050sx_bsn-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/of10_7050sx_bsn-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/ospf6_print_lshdr-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/ospf6_print_lshdr-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/ospf6_print_lshdr-oobr.out (revision 353144) @@ -0,0 +1,59 @@ +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Neighbor List: +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Neighbor List: +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Neighbor List: +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Neighbor List: +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > ff02::5: OSPFv3, Hello, length 36 + Router-ID 2.2.2.2, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Neighbor List: +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router] + Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1 + Designated Router 1.1.1.1 + Neighbor List: [|ospf3] +IP6 (class 0xe0, flowlabel 0x00100, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28 + Router-ID 2.2.2.2, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00001d46 +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x0000242c +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 168) fe80::1 > fe80::2: OSPFv3, Database Description, length 168 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00001d46 [|ospf3] +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 148) fe80::2 > fe80::1: OSPFv3, Database Description, length 148 + Router-ID 2.2.2.2, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00001d47 [|ospf3] +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28 + Router-ID 1.1.1.1, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00001d47 +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 100) fe80::2 > fe80::1: OSPFv3, LS-Request, length 100 + Router-ID 2.2.2.2, Area 0.0.0.1 + Advertising Router 1.1.1.1 + Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0 [|ospf3] +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 88) fe80::1 > fe80::2: OSPFv3, LS-Request, length 88 + Router-ID 1.1.1.1, Area 0.0.0.1 + Advertising Router 2.2.2.2 + Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0 [|ospf3] +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28 + Router-ID 2.2.2.2, Area 0.0.0.1 + Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00001d48 +IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 288) fe80::1 > fe80:0:ff:ffff:f000::2: OSPFv3, LS-Update, length 288 + Router-ID 1.1.1.1, Area 0.0.0.1 [|ospf3] Index: vendor/tcpdump/dist/tests/ospf6_print_lshdr-oobr.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/ospf6_print_lshdr-oobr.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/pcap-invalid-version-1.out =================================================================== --- vendor/tcpdump/dist/tests/pcap-invalid-version-1.out (revision 353143) +++ vendor/tcpdump/dist/tests/pcap-invalid-version-1.out (revision 353144) @@ -1 +1,2 @@ -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/pcap-invalid-version-1.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/pcap-invalid-version-1.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/pcap-invalid-version-1.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: archaic pcap savefile format Index: vendor/tcpdump/dist/tests/pcap-invalid-version-2.out =================================================================== --- vendor/tcpdump/dist/tests/pcap-invalid-version-2.out (revision 353143) +++ vendor/tcpdump/dist/tests/pcap-invalid-version-2.out (revision 353144) @@ -1 +1,2 @@ -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/pcap-invalid-version-2.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/pcap-invalid-version-2.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/pcap-invalid-version-2.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: unsupported pcap savefile version 2.5 Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out =================================================================== --- vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out (nonexistent) +++ vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: unsupported pcapng savefile version 0.1 Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/pcapng-invalid-vers-1.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out =================================================================== --- vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out (nonexistent) +++ vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out (revision 353144) @@ -0,0 +1,2 @@ + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.out.stderr (revision 353144) @@ -0,0 +1 @@ +tcpdump: unsupported pcapng savefile version 1.1 Index: vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: vendor/tcpdump/dist/tests/pcapng-invalid-vers-2.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: vendor/tcpdump/dist/tests/pktap-heap-overflow.out =================================================================== --- vendor/tcpdump/dist/tests/pktap-heap-overflow.out (revision 353143) +++ vendor/tcpdump/dist/tests/pktap-heap-overflow.out (revision 353144) @@ -1,3 +1,4 @@ [|pktap] [|ppp] -EXIT CODE 00000100 + +EXIT CODE 00000100: dump:0 code: 1 Index: vendor/tcpdump/dist/tests/pktap-heap-overflow.out.stderr =================================================================== --- vendor/tcpdump/dist/tests/pktap-heap-overflow.out.stderr (nonexistent) +++ vendor/tcpdump/dist/tests/pktap-heap-overflow.out.stderr (revision 353144) @@ -0,0 +1,2 @@ +reading from file pktap-heap-overflow.pcap, link-type 149 +tcpdump: pcap_loop: invalid packet capture length 4076008178, bigger than snaplen of 1024 Index: vendor/tcpdump/dist/tests/relts-0x80000000.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: vendor/tcpdump/dist/tests/rpl-19-pickdag.out =================================================================== --- vendor/tcpdump/dist/tests/rpl-19-pickdag.out (revision 353143) +++ vendor/tcpdump/dist/tests/rpl-19-pickdag.out (revision 353144) @@ -1 +1 @@ -IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 +IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 [|rpl] Index: vendor/tcpdump/dist/tests/rpl-19-pickdagvvv.out =================================================================== --- vendor/tcpdump/dist/tests/rpl-19-pickdagvvv.out (revision 353143) +++ vendor/tcpdump/dist/tests/rpl-19-pickdagvvv.out (revision 353144) @@ -1 +1 @@ -IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 0x0000: 0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010: 3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 +IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25 0x0000: 0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010: 3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 [|rpl] Index: vendor/tcpdump/dist/tests/rpl-dao-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/rpl-dao-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/rpl-dao-oobr.out (revision 353144) @@ -0,0 +1 @@ +IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:,seq:0,instance:42,00] opt:subopt:13 len:2 opt:subopt:128 len:15 opt:subopt:13 len:15 [|rpl] Index: vendor/tcpdump/dist/tests/rpl-dao-oobr.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/rpl-dao-oobr.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/rsvp-rsvp_obj_print-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/rsvp-rsvp_obj_print-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/rsvp-rsvp_obj_print-oobr.out (revision 353144) @@ -0,0 +1,7 @@ +TIPC v5.0 226.0.0 > 64.14.1536, headerlength 56 bytes, MessageSize 51914 bytes, Link Changeover Protocol internal, messageType Unknown (0xcacacaca)[|TIPC] +[|ether] +IP (tos 0x0, ttl 14, id 44815, offset 0, flags [+, DF, rsvd], proto RSVP (46), length 40, bad cksum 3280 (->c411)!) + 250.219.91.71 > 20.100.238.255: + RSVPv1 Hello Message (20), Flags: [none], length: 16384, ttl: 0, checksum: 0x000e + Class Type (old) Object (125) Flags: [reject if unknown], Class-Type: 1 (1), length: 4 + [|rsvp] Index: vendor/tcpdump/dist/tests/rsvp-rsvp_obj_print-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/rsvp-rsvp_obj_print-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/rx_serviceid_oobr.out =================================================================== --- vendor/tcpdump/dist/tests/rx_serviceid_oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/rx_serviceid_oobr.out (revision 353144) @@ -0,0 +1,3 @@ +IP 250.15.128.19.68 > 249.251.157.8.63246: BOOTP/DHCP, unknown (0x00), length 8085 +[|ether] +IP 0.0.0.0.0 > 0.0.0.0.7004: rx abort (539) Index: vendor/tcpdump/dist/tests/rx_serviceid_oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/rx_serviceid_oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/smb.sh =================================================================== --- vendor/tcpdump/dist/tests/smb.sh (nonexistent) +++ vendor/tcpdump/dist/tests/smb.sh (revision 353144) @@ -0,0 +1,49 @@ +#!/bin/sh + +srcdir=${1-..} +: echo smb.sh using ${srcdir} from `pwd` + +testdir=${srcdir}/tests + +exitcode=0 +passedfile=tests/.passed +failedfile=tests/.failed +passed=`cat ${passedfile}` +failed=`cat ${failedfile}` + +# Only attempt OpenSSL-specific tests when compiled with the library. + +if grep '^#define ENABLE_SMB 1$' config.h >/dev/null +then + cat ${srcdir}/tests/SMBLIST | while read name input output options + do + case $name in + \#*) continue;; + '') continue;; + esac + rm -f core + [ "$only" != "" -a "$name" != "$only" ] && continue + SRCDIR=${srcdir} + export SRCDIR + # I hate shells with their stupid, useless subshells. + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` + (cd tests # run TESTonce in tests directory + if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options" + then + passed=`expr $passed + 1` + echo $passed >${passedfile} + else + failed=`expr $failed + 1` + echo $failed >${failedfile} + fi + if [ -d COREFILES ]; then + if [ -f core ]; then mv core COREFILES/$name.core; fi + fi) + done + # I hate shells with their stupid, useless subshells. + passed=`cat ${passedfile}` + failed=`cat ${failedfile}` +fi + +exit $exitcode Property changes on: vendor/tcpdump/dist/tests/smb.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/tcpdump/dist/tests/smb_print_trans-oobr1.out =================================================================== --- vendor/tcpdump/dist/tests/smb_print_trans-oobr1.out (nonexistent) +++ vendor/tcpdump/dist/tests/smb_print_trans-oobr1.out (revision 353144) @@ -0,0 +1,39 @@ +IPX a8f87967.00:00:00:00:00:01.0455 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50 +IPX a8f87967.00:00:00:00:00:01.0455 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50 +IPX a8f87967.00:00:00:ff:ff:ff.7f55 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50 +IPX a855000b.41:44:4d:49:4e:54.4553 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 162 +>>> IPX transport Data: (24 bytes) +[000] 54 20 20 20 20 20 20 00 01 02 5F 5F 4D 53 26 52 T \0x00 \0x01\0x02__MS&R +[010] 4F 57 53 45 5F 5F 02 01 OWSE__\0x02\0x01 + +SMB PACKET: SMBtrans (REQUEST) +SMB Command = 0x25 +Error class = 0x0 +Error code = 0 (0x0) +Flags1 = 0x0 +Flags2 = 0x0 +Tree ID = 0 (0x0) +Proc ID = 0 (0x0) +UID = 0 (0x0) +MID = 0 (0x0) +Word Count = 17 (0x11) +TotParamCnt=0 (0x0) +TotDataCnt=42 (0x2a) +MaxParmCnt=0 (0x0) +MaxDataCnt=0 (0x0) +MaxSCnt=0 (0x0) +TransFlags=0x0 +Res1=0x3E8 +Res2=0x0 +Res3=0x0 +ParamCnt=0 (0x0) +ParamOff=0 (0x0) +DataCnt=42 (0x2a) +DataOff=86 (0x56) +SUCnt=3 (0x3) +Data: (6 bytes) +[000] 01 00 01 00 02 00 \0x01\0x00\0x01\0x00\0x02\0x00 +smb_bcc=59 +[|SMB] + + Index: vendor/tcpdump/dist/tests/smb_print_trans-oobr1.pcapng =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/smb_print_trans-oobr1.pcapng ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/smb_print_trans-oobr2.out =================================================================== --- vendor/tcpdump/dist/tests/smb_print_trans-oobr2.out (nonexistent) +++ vendor/tcpdump/dist/tests/smb_print_trans-oobr2.out (revision 353144) @@ -0,0 +1,37 @@ +IP (tos 0x0, ttl 128, id 14471, offset 0, flags [none], proto UDP (17), length 207) + 192.168.1.249.138 > 192.168.1.255.138: +>>> NBT UDP PACKET(138) Res=0x110E ID=0x891D IP=192 (0xc0).168 (0xa8).1 (0x1).249 (0xf9) Port=138 (0x8a) Length=165 (0xa5) Res2=0x0 +SourceName=DJP95S0J NameType=0x00 (Workstation) +DestName=ARBEIT NameType=0x00 (Workstation) + +SMB PACKET: SMBtrans (REQUEST) +SMB Command = 0x25 +Error class = 0x0 +Error code = 0 (0x0) +Flags1 = 0x0 +Flags2 = 0x0 +Tree ID = 0 (0x0) +Proc ID = 0 (0x0) +UID = 0 (0x0) +MID = 0 (0x0) +Word Count = 17 (0x11) +TotParamCnt=0 (0x0) +TotDataCnt=11 (0xb) +MaxParmCnt=0 (0x0) +MaxDataCnt=0 (0x0) +MaxSCnt=0 (0x0) +TransFlags=0x0 +Res1=0x3E8 +Res2=0x0 +Res3=0x0 +ParamCnt=0 (0x0) +ParamOff=0 (0x0) +DataCnt=11 (0xb) +DataOff=86 (0x56) +SUCnt=3 (0x3) +Data: (6 bytes) +[000] 01 00 01 00 02 00 \0x01\0x00\0x01\0x00\0x02\0x00 +smb_bcc=28 +[|SMB] + + Index: vendor/tcpdump/dist/tests/smb_print_trans-oobr2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/smb_print_trans-oobr2.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/stp-v4-length-sigsegv.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: vendor/tcpdump/dist/tests/tftp-heapoverflow.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr-2.out =================================================================== --- vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr-2.out (nonexistent) +++ vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr-2.out (revision 353144) @@ -0,0 +1,20 @@ +IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->c1ae)!) + 0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 269cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7e (->e1b5)!) + 255.251.2.148 > 54.0.0.16: vrrp 255.251.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 2304cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 597f (->e1ae)!) + 0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e154)!) + 0.3.2.148 > 54.90.0.16: vrrp 0.3.2.148 > 54.90.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e1ae)!) + 0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 0, prio 4, intvl 2304cs, length 19, addrs: +IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->c1ae)!) + 0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e1ae)!) + 0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp] +IP (tos 0x2,ECT(0), ttl 34, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 27, bad cksum 7f (->e260)!) + 0.3.2.148 > 54.90.0.16: vrrp 0.3.2.148 > 54.90.0.16: VRRPv3, Advertisement, (ttl 34), vrid 255, prio 17, intvl 256cs, length 7[|vrrp] +IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->17af)!) + 0.3.2.148 > 0.0.0.16: vrrp 0.3.2.148 > 0.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 0, prio 4, intvl 2304cs, length 19, addrs: +IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->2e8a)!) + 242.242.242.242 > 242.242.242.242: vrrp 242.242.242.242 > 242.242.242.242: VRRPv15, unknown type (2), (ttl 35) Index: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr-2.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr-2.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr.out =================================================================== --- vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr.out (nonexistent) +++ vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr.out (revision 353144) @@ -0,0 +1,6 @@ +IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 34, options (unknown 69 [bad length 83]), bad cksum 8e15 (->bc96)!) + 250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 6[|vrrp] +IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 40, options (unknown 69 [bad length 83]), bad cksum 8e15 (->b790)!) + 250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 12, addrs:[|vrrp] +IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 40, options (unknown 69 [bad length 83]), bad cksum 8e15 (->bc90)!) + 250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 12, addrs:[|vrrp] Index: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr.pcap =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/vnd.tcpdump.pcap Property changes on: vendor/tcpdump/dist/tests/vrrp-vrrp_print-oobr.pcap ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/vnd.tcpdump.pcap \ No newline at end of property Index: vendor/tcpdump/dist/util-print.c =================================================================== --- vendor/tcpdump/dist/util-print.c (revision 353143) +++ vendor/tcpdump/dist/util-print.c (revision 353144) @@ -1,951 +1,963 @@ /* * Copyright (c) 1990, 1991, 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. */ /* * txtproto_print() derived from original code by Hannes Gredler * (hannes@gredler.at): * * 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. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #ifdef HAVE_FCNTL_H #include #endif #include #include #include #include #include #include "netdissect.h" #include "ascii_strcasecmp.h" #include "timeval-operations.h" int32_t thiszone; /* seconds offset from gmt to local time */ /* invalid string to print '(invalid)' for malformed or corrupted packets */ const char istr[] = " (invalid)"; /* * timestamp display buffer size, the biggest size of both formats is needed * sizeof("0000000000.000000000") > sizeof("00:00:00.000000000") */ #define TS_BUF_SIZE sizeof("0000000000.000000000") #define TOKBUFSIZE 128 /* * Print out a character, filtering out the non-printable ones */ void fn_print_char(netdissect_options *ndo, u_char c) { if (!ND_ISASCII(c)) { c = ND_TOASCII(c); ND_PRINT((ndo, "M-")); } if (!ND_ISPRINT(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ ND_PRINT((ndo, "^")); } ND_PRINT((ndo, "%c", c)); } /* * Print out a null-terminated filename (or other ascii string). * If ep is NULL, assume no truncation check is needed. * Return true if truncated. * Stop at ep (if given) or before the null char, whichever is first. */ int fn_print(netdissect_options *ndo, register const u_char *s, register const u_char *ep) { register int ret; register u_char c; ret = 1; /* assume truncated */ while (ep == NULL || s < ep) { c = *s++; if (c == '\0') { ret = 0; break; } if (!ND_ISASCII(c)) { c = ND_TOASCII(c); ND_PRINT((ndo, "M-")); } if (!ND_ISPRINT(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ ND_PRINT((ndo, "^")); } ND_PRINT((ndo, "%c", c)); } return(ret); } /* * Print out a null-terminated filename (or other ascii string) from - * a fixed-length buffer. - * If ep is NULL, assume no truncation check is needed. + * a fixed-length field in the packet buffer, or from what remains of + * the packet. + * + * n is the length of the fixed-length field, or the number of bytes + * remaining in the packet based on its on-the-network length. + * + * If ep is non-null, it should point just past the last captured byte + * of the packet, e.g. ndo->ndo_snapend. If ep is NULL, we assume no + * truncation check, other than the checks of the field length/remaining + * packet data length, is needed. + * * Return the number of bytes of string processed, including the - * terminating null, if not truncated. Return 0 if truncated. + * terminating null, if not truncated; as the terminating null is + * included in the count, and as there must be a terminating null, + * this will always be non-zero. Return 0 if truncated. */ u_int fn_printztn(netdissect_options *ndo, register const u_char *s, register u_int n, register const u_char *ep) { register u_int bytes; register u_char c; bytes = 0; for (;;) { if (n == 0 || (ep != NULL && s >= ep)) { /* * Truncated. This includes "no null before we - * got to the end of the fixed-length buffer". + * got to the end of the fixed-length buffer or + * the end of the packet". * * XXX - BOOTP says "null-terminated", which * means the maximum length of the string, in * bytes, is 1 less than the size of the buffer, * as there must always be a terminating null. */ bytes = 0; break; } c = *s++; bytes++; n--; if (c == '\0') { /* End of string */ break; } if (!ND_ISASCII(c)) { c = ND_TOASCII(c); ND_PRINT((ndo, "M-")); } if (!ND_ISPRINT(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ ND_PRINT((ndo, "^")); } ND_PRINT((ndo, "%c", c)); } return(bytes); } /* * Print out a counted filename (or other ascii string). * If ep is NULL, assume no truncation check is needed. * Return true if truncated. * Stop at ep (if given) or after n bytes, whichever is first. */ int fn_printn(netdissect_options *ndo, register const u_char *s, register u_int n, register const u_char *ep) { register u_char c; while (n > 0 && (ep == NULL || s < ep)) { n--; c = *s++; if (!ND_ISASCII(c)) { c = ND_TOASCII(c); ND_PRINT((ndo, "M-")); } if (!ND_ISPRINT(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ ND_PRINT((ndo, "^")); } ND_PRINT((ndo, "%c", c)); } return (n == 0) ? 0 : 1; } /* * Print out a null-padded filename (or other ascii string). * If ep is NULL, assume no truncation check is needed. * Return true if truncated. * Stop at ep (if given) or after n bytes or before the null char, * whichever is first. */ int fn_printzp(netdissect_options *ndo, 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 (!ND_ISASCII(c)) { c = ND_TOASCII(c); ND_PRINT((ndo, "M-")); } if (!ND_ISPRINT(c)) { c ^= 0x40; /* DEL to ?, others to alpha */ ND_PRINT((ndo, "^")); } ND_PRINT((ndo, "%c", c)); } return (n == 0) ? 0 : ret; } /* * Format the timestamp */ static char * ts_format(netdissect_options *ndo #ifndef HAVE_PCAP_SET_TSTAMP_PRECISION _U_ #endif , int sec, int usec, char *buf) { const char *format; #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION switch (ndo->ndo_tstamp_precision) { case PCAP_TSTAMP_PRECISION_MICRO: format = "%02d:%02d:%02d.%06u"; break; case PCAP_TSTAMP_PRECISION_NANO: format = "%02d:%02d:%02d.%09u"; break; default: format = "%02d:%02d:%02d.{unknown}"; break; } #else format = "%02d:%02d:%02d.%06u"; #endif snprintf(buf, TS_BUF_SIZE, format, sec / 3600, (sec % 3600) / 60, sec % 60, usec); return buf; } /* * Format the timestamp - Unix timeval style */ static char * ts_unix_format(netdissect_options *ndo #ifndef HAVE_PCAP_SET_TSTAMP_PRECISION _U_ #endif , int sec, int usec, char *buf) { const char *format; #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION switch (ndo->ndo_tstamp_precision) { case PCAP_TSTAMP_PRECISION_MICRO: format = "%u.%06u"; break; case PCAP_TSTAMP_PRECISION_NANO: format = "%u.%09u"; break; default: format = "%u.{unknown}"; break; } #else format = "%u.%06u"; #endif snprintf(buf, TS_BUF_SIZE, format, (unsigned)sec, (unsigned)usec); return buf; } /* * Print the timestamp */ void ts_print(netdissect_options *ndo, register const struct timeval *tvp) { register int s; struct tm *tm; time_t Time; char buf[TS_BUF_SIZE]; static struct timeval tv_ref; struct timeval tv_result; int negative_offset; int nano_prec; switch (ndo->ndo_tflag) { case 0: /* Default */ s = (tvp->tv_sec + thiszone) % 86400; ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec, buf))); break; case 1: /* No time stamp */ break; case 2: /* Unix timeval style */ ND_PRINT((ndo, "%s ", ts_unix_format(ndo, tvp->tv_sec, tvp->tv_usec, buf))); break; case 3: /* Microseconds/nanoseconds since previous packet */ case 5: /* Microseconds/nanoseconds since first packet */ #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION switch (ndo->ndo_tstamp_precision) { case PCAP_TSTAMP_PRECISION_MICRO: nano_prec = 0; break; case PCAP_TSTAMP_PRECISION_NANO: nano_prec = 1; break; default: nano_prec = 0; break; } #else nano_prec = 0; #endif if (!(netdissect_timevalisset(&tv_ref))) tv_ref = *tvp; /* set timestamp for first packet */ negative_offset = netdissect_timevalcmp(tvp, &tv_ref, <); if (negative_offset) netdissect_timevalsub(&tv_ref, tvp, &tv_result, nano_prec); else netdissect_timevalsub(tvp, &tv_ref, &tv_result, nano_prec); ND_PRINT((ndo, (negative_offset ? "-" : " "))); ND_PRINT((ndo, "%s ", ts_format(ndo, tv_result.tv_sec, tv_result.tv_usec, buf))); if (ndo->ndo_tflag == 3) tv_ref = *tvp; /* set timestamp for previous packet */ break; case 4: /* Default + Date */ s = (tvp->tv_sec + thiszone) % 86400; Time = (tvp->tv_sec + thiszone) - s; tm = gmtime (&Time); if (!tm) ND_PRINT((ndo, "Date fail ")); else ND_PRINT((ndo, "%04d-%02d-%02d %s ", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, ts_format(ndo, s, tvp->tv_usec, buf))); break; } } /* * Print an unsigned relative number of seconds (e.g. hold time, prune timer) * in the form 5m1s. This does no truncation, so 32230861 seconds * is represented as 1y1w1d1h1m1s. */ void unsigned_relts_print(netdissect_options *ndo, uint32_t secs) { static const char *lengths[] = {"y", "w", "d", "h", "m", "s"}; static const u_int seconds[] = {31536000, 604800, 86400, 3600, 60, 1}; const char **l = lengths; const u_int *s = seconds; if (secs == 0) { ND_PRINT((ndo, "0s")); return; } while (secs > 0) { if (secs >= *s) { ND_PRINT((ndo, "%d%s", secs / *s, *l)); secs -= (secs / *s) * *s; } s++; l++; } } /* * Print a signed relative number of seconds (e.g. hold time, prune timer) * in the form 5m1s. This does no truncation, so 32230861 seconds * is represented as 1y1w1d1h1m1s. */ void signed_relts_print(netdissect_options *ndo, int32_t secs) { if (secs < 0) { ND_PRINT((ndo, "-")); if (secs == INT32_MIN) { /* * -2^31; you can't fit its absolute value into * a 32-bit signed integer. * * Just directly pass said absolute value to * unsigned_relts_print() directly. * * (XXX - does ISO C guarantee that -(-2^n), * when calculated and cast to an n-bit unsigned * integer type, will have the value 2^n?) */ unsigned_relts_print(ndo, 2147483648U); } else { /* * We now know -secs will fit into an int32_t; * negate it and pass that to unsigned_relts_print(). */ unsigned_relts_print(ndo, -secs); } return; } unsigned_relts_print(ndo, secs); } /* * this is a generic routine for printing unknown data; * we pass on the linefeed plus indentation string to * get a proper output - returns 0 on error */ int print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len) { if (len < 0) { ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length", ident)); return(0); } if (ndo->ndo_snapend - cp < len) len = ndo->ndo_snapend - cp; if (len < 0) { ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet", ident)); return(0); } hex_print(ndo, ident,cp,len); return(1); /* everything is ok */ } /* * Convert a token value to a string; use "fmt" if not found. */ const char * tok2strbuf(register const struct tok *lp, register const char *fmt, register u_int v, char *buf, size_t bufsize) { if (lp != NULL) { while (lp->s != NULL) { if (lp->v == v) return (lp->s); ++lp; } } if (fmt == NULL) fmt = "#%d"; (void)snprintf(buf, bufsize, fmt, v); return (const char *)buf; } /* * Convert a token value to a string; use "fmt" if not found. */ const char * tok2str(register const struct tok *lp, register const char *fmt, register u_int v) { static char buf[4][TOKBUFSIZE]; static int idx = 0; char *ret; ret = buf[idx]; idx = (idx+1) & 3; return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0])); } /* * Convert a bit token value to a string; use "fmt" if not found. * this is useful for parsing bitfields, the output strings are seperated * if the s field is positive. */ static char * bittok2str_internal(register const struct tok *lp, register const char *fmt, register u_int v, const char *sep) { static char buf[1024+1]; /* our string buffer */ char *bufp = buf; size_t space_left = sizeof(buf), string_size; register u_int rotbit; /* this is the bit we rotate through all bitpositions */ register u_int tokval; const char * sepstr = ""; while (lp != NULL && lp->s != NULL) { tokval=lp->v; /* load our first value */ rotbit=1; while (rotbit != 0) { /* * lets AND the rotating bit with our token value * and see if we have got a match */ if (tokval == (v&rotbit)) { /* ok we have found something */ if (space_left <= 1) return (buf); /* only enough room left for NUL, if that */ string_size = strlcpy(bufp, sepstr, space_left); if (string_size >= space_left) return (buf); /* we ran out of room */ bufp += string_size; space_left -= string_size; if (space_left <= 1) return (buf); /* only enough room left for NUL, if that */ string_size = strlcpy(bufp, lp->s, space_left); if (string_size >= space_left) return (buf); /* we ran out of room */ bufp += string_size; space_left -= string_size; sepstr = sep; break; } rotbit=rotbit<<1; /* no match - lets shift and try again */ } lp++; } if (bufp == buf) /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */ (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v); return (buf); } /* * Convert a bit token value to a string; use "fmt" if not found. * this is useful for parsing bitfields, the output strings are not seperated. */ char * bittok2str_nosep(register const struct tok *lp, register const char *fmt, register u_int v) { return (bittok2str_internal(lp, fmt, v, "")); } /* * Convert a bit token value to a string; use "fmt" if not found. * this is useful for parsing bitfields, the output strings are comma seperated. */ char * bittok2str(register const struct tok *lp, register const char *fmt, register u_int v) { return (bittok2str_internal(lp, fmt, v, ", ")); } /* * Convert a value to a string using an array; the macro * tok2strary() in is the public interface to * this function and ensures that the second argument is * correct for bounds-checking. */ const char * tok2strary_internal(register const char **lp, int n, register const char *fmt, register int v) { static char buf[TOKBUFSIZE]; if (v >= 0 && v < n && lp[v] != NULL) return lp[v]; if (fmt == NULL) fmt = "#%d"; (void)snprintf(buf, sizeof(buf), fmt, v); return (buf); } /* * Convert a 32-bit netmask to prefixlen if possible * the function returns the prefix-len; if plen == -1 * then conversion was not possible; */ int mask2plen(uint32_t mask) { uint32_t bitmasks[33] = { 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff }; int prefix_len = 32; /* let's see if we can transform the mask into a prefixlen */ while (prefix_len >= 0) { if (bitmasks[prefix_len] == mask) break; prefix_len--; } return (prefix_len); } int mask62plen(const u_char *mask) { u_char bitmasks[9] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; int byte; int cidr_len = 0; for (byte = 0; byte < 16; byte++) { u_int bits; for (bits = 0; bits < (sizeof (bitmasks) / sizeof (bitmasks[0])); bits++) { if (mask[byte] == bitmasks[bits]) { cidr_len += bits; break; } } if (mask[byte] != 0xff) break; } return (cidr_len); } /* * Routine to print out information for text-based protocols such as FTP, * HTTP, SMTP, RTSP, SIP, .... */ #define MAX_TOKEN 128 /* * Fetch a token from a packet, starting at the specified index, * and return the length of the token. * * Returns 0 on error; yes, this is indistinguishable from an empty * token, but an "empty token" isn't a valid token - it just means * either a space character at the beginning of the line (this * includes a blank line) or no more tokens remaining on the line. */ static int fetch_token(netdissect_options *ndo, const u_char *pptr, u_int idx, u_int len, u_char *tbuf, size_t tbuflen) { size_t toklen = 0; for (; idx < len; idx++) { if (!ND_TTEST(*(pptr + idx))) { /* ran past end of captured data */ return (0); } if (!isascii(*(pptr + idx))) { /* not an ASCII character */ return (0); } if (isspace(*(pptr + idx))) { /* end of token */ break; } if (!isprint(*(pptr + idx))) { /* not part of a command token or response code */ return (0); } if (toklen + 2 > tbuflen) { /* no room for this character and terminating '\0' */ return (0); } tbuf[toklen] = *(pptr + idx); toklen++; } if (toklen == 0) { /* no token */ return (0); } tbuf[toklen] = '\0'; /* * Skip past any white space after the token, until we see * an end-of-line (CR or LF). */ for (; idx < len; idx++) { if (!ND_TTEST(*(pptr + idx))) { /* ran past end of captured data */ break; } if (*(pptr + idx) == '\r' || *(pptr + idx) == '\n') { /* end of line */ break; } if (!isascii(*(pptr + idx)) || !isprint(*(pptr + idx))) { /* not a printable ASCII character */ break; } if (!isspace(*(pptr + idx))) { /* beginning of next token */ break; } } return (idx); } /* * Scan a buffer looking for a line ending - LF or CR-LF. * Return the index of the character after the line ending or 0 if * we encounter a non-ASCII or non-printable character or don't find * the line ending. */ static u_int print_txt_line(netdissect_options *ndo, const char *protoname, const char *prefix, const u_char *pptr, u_int idx, u_int len) { u_int startidx; u_int linelen; startidx = idx; while (idx < len) { ND_TCHECK(*(pptr+idx)); if (*(pptr+idx) == '\n') { /* * LF without CR; end of line. * Skip the LF and print the line, with the * exception of the LF. */ linelen = idx - startidx; idx++; goto print; } else if (*(pptr+idx) == '\r') { /* CR - any LF? */ if ((idx+1) >= len) { /* not in this packet */ return (0); } ND_TCHECK(*(pptr+idx+1)); if (*(pptr+idx+1) == '\n') { /* * CR-LF; end of line. * Skip the CR-LF and print the line, with * the exception of the CR-LF. */ linelen = idx - startidx; idx += 2; goto print; } /* * CR followed by something else; treat this * as if it were binary data, and don't print * it. */ return (0); } else if (!isascii(*(pptr+idx)) || (!isprint(*(pptr+idx)) && *(pptr+idx) != '\t')) { /* * Not a printable ASCII character and not a tab; * treat this as if it were binary data, and * don't print it. */ return (0); } idx++; } /* * All printable ASCII, but no line ending after that point * in the buffer; treat this as if it were truncated. */ trunc: linelen = idx - startidx; ND_PRINT((ndo, "%s%.*s[!%s]", prefix, (int)linelen, pptr + startidx, protoname)); return (0); print: ND_PRINT((ndo, "%s%.*s", prefix, (int)linelen, pptr + startidx)); return (idx); } void txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len, const char *protoname, const char **cmds, u_int flags) { u_int idx, eol; u_char token[MAX_TOKEN+1]; const char *cmd; int is_reqresp = 0; const char *pnp; if (cmds != NULL) { /* * This protocol has more than just request and * response lines; see whether this looks like a * request or response. */ idx = fetch_token(ndo, pptr, 0, len, token, sizeof(token)); if (idx != 0) { /* Is this a valid request name? */ while ((cmd = *cmds++) != NULL) { if (ascii_strcasecmp((const char *)token, cmd) == 0) { /* Yes. */ is_reqresp = 1; break; } } /* * No - is this a valid response code (3 digits)? * * Is this token the response code, or is the next * token the response code? */ if (flags & RESP_CODE_SECOND_TOKEN) { /* * Next token - get it. */ idx = fetch_token(ndo, pptr, idx, len, token, sizeof(token)); } if (idx != 0) { if (isdigit(token[0]) && isdigit(token[1]) && isdigit(token[2]) && token[3] == '\0') { /* Yes. */ is_reqresp = 1; } } } } else { /* * This protocol has only request and response lines * (e.g., FTP, where all the data goes over a * different connection); assume the payload is * a request or response. */ is_reqresp = 1; } /* Capitalize the protocol name */ for (pnp = protoname; *pnp != '\0'; pnp++) ND_PRINT((ndo, "%c", toupper((u_char)*pnp))); if (is_reqresp) { /* * In non-verbose mode, just print the protocol, followed * by the first line as the request or response info. * * In verbose mode, print lines as text until we run out * of characters or see something that's not a * printable-ASCII line. */ if (ndo->ndo_vflag) { /* * We're going to print all the text lines in the * request or response; just print the length * on the first line of the output. */ ND_PRINT((ndo, ", length: %u", len)); for (idx = 0; idx < len && (eol = print_txt_line(ndo, protoname, "\n\t", pptr, idx, len)) != 0; idx = eol) ; } else { /* * Just print the first text line. */ print_txt_line(ndo, protoname, ": ", pptr, 0, len); } } } void safeputs(netdissect_options *ndo, const u_char *s, const u_int maxlen) { u_int idx = 0; while (idx < maxlen && *s) { safeputchar(ndo, *s); idx++; s++; } } void safeputchar(netdissect_options *ndo, const u_char c) { ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c)); } #ifdef LBL_ALIGN /* * Some compilers try to optimize memcpy(), using the alignment constraint * on the argument pointer type. by using this function, we try to avoid the * optimization. */ void unaligned_memcpy(void *p, const void *q, size_t l) { memcpy(p, q, l); } /* As with memcpy(), so with memcmp(). */ int unaligned_memcmp(const void *p, const void *q, size_t l) { return (memcmp(p, q, l)); } #endif