diff options
Diffstat (limited to 'contrib/tcpdump')
49 files changed, 787 insertions, 3954 deletions
diff --git a/contrib/tcpdump/FREEBSD-upgrade b/contrib/tcpdump/FREEBSD-upgrade new file mode 100644 index 0000000..02c2e36 --- /dev/null +++ b/contrib/tcpdump/FREEBSD-upgrade @@ -0,0 +1,28 @@ +This directory contains virgin copies of the original distribution files +on a "vendor" branch. Do not, under any circumstances, attempt to upgrade +the files in this directory via patches and a cvs commit. + +To upgrade to a newer version of tcpdump, when it is available: + 1. Unpack the new version into an empty directory. + [Do not make ANY changes to the files.] + + 2. Use the command: + cvs import -m 'Virgin import of LBL tcpdump v<version>' \ + -I linux-include src/contrib/tcpdump LBL v<version> + + For example, to do the import of version 3.2.1, I typed: + cvs import -m 'Virgin import of LBL tcpdump v3.2.1' \ + -I linux-include src/contrib/tcpdump LBL v3_2_1 + + 3. Follow the instructions printed out in step 2 to resolve any + conflicts between local FreeBSD changes and the newer version. + +Do not, under any circumstances, deviate from this procedure. + +To make local changes to tcpdump, simply patch and commit to the main +branch (aka HEAD). Never make local changes on the LBL branch. + +All local changes should be submitted to "tcpdump@ee.lbl.gov" for +inclusion in the next vendor release. + +pst@freebsd.org - 19 Aug 1996 diff --git a/contrib/tcpdump/aclocal.m4 b/contrib/tcpdump/aclocal.m4 deleted file mode 100644 index 4b70105..0000000 --- a/contrib/tcpdump/aclocal.m4 +++ /dev/null @@ -1,1256 +0,0 @@ -dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.106.2.7 2005/11/08 03:00:52 guy Exp $ (LBL) -dnl -dnl Copyright (c) 1995, 1996, 1997, 1998 -dnl The Regents of the University of California. All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that: (1) source code distributions -dnl retain the above copyright notice and this paragraph in its entirety, (2) -dnl distributions including binary code include the above copyright notice and -dnl this paragraph in its entirety in the documentation or other materials -dnl provided with the distribution, and (3) all advertising materials mentioning -dnl features or use of this software display the following acknowledgement: -dnl ``This product includes software developed by the University of California, -dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of -dnl the University nor the names of its contributors may be used to endorse -dnl or promote products derived from this software without specific prior -dnl written permission. -dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -dnl -dnl LBL autoconf macros -dnl - -dnl -dnl Determine which compiler we're using (cc or gcc) -dnl If using gcc, determine the version number -dnl If using cc, require that it support ansi prototypes -dnl If using gcc, use -O2 (otherwise use -O) -dnl If using cc, explicitly specify /usr/local/include -dnl -dnl usage: -dnl -dnl AC_LBL_C_INIT(copt, incls) -dnl -dnl results: -dnl -dnl $1 (copt set) -dnl $2 (incls set) -dnl CC -dnl LDFLAGS -dnl ac_cv_lbl_gcc_vers -dnl LBL_CFLAGS -dnl -AC_DEFUN(AC_LBL_C_INIT, - [AC_PREREQ(2.12) - AC_BEFORE([$0], [AC_PROG_CC]) - AC_BEFORE([$0], [AC_LBL_FIXINCLUDES]) - AC_BEFORE([$0], [AC_LBL_DEVEL]) - AC_ARG_WITH(gcc, [ --without-gcc don't use gcc]) - $1="-O" - $2="" - if test "${srcdir}" != "." ; then - $2="-I\$(srcdir)" - fi - if test "${CFLAGS+set}" = set; then - LBL_CFLAGS="$CFLAGS" - fi - if test -z "$CC" ; then - case "$host_os" in - - bsdi*) - AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) - 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_PROG_CC - if test "$GCC" = yes ; then - if test "$SHLICC2" = yes ; then - ac_cv_lbl_gcc_vers=2 - $1="-O2" - else - AC_MSG_CHECKING(gcc version) - AC_CACHE_VAL(ac_cv_lbl_gcc_vers, - ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \ - sed -e '/^gcc version /!d' \ - -e 's/^gcc version //' \ - -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \ - -e 's/\..*//'`) - AC_MSG_RESULT($ac_cv_lbl_gcc_vers) - if test $ac_cv_lbl_gcc_vers -gt 1 ; then - $1="-O2" - fi - fi - else - AC_MSG_CHECKING(that $CC handles ansi prototypes) - AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [int frob(int, char *)], - ac_cv_lbl_cc_ansi_prototypes=yes, - ac_cv_lbl_cc_ansi_prototypes=no)) - AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes) - if test $ac_cv_lbl_cc_ansi_prototypes = no ; then - case "$host_os" in - - hpux*) - AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) - savedcflags="$CFLAGS" - CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" - AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [int frob(int, char *)], - ac_cv_lbl_cc_hpux_cc_aa=yes, - ac_cv_lbl_cc_hpux_cc_aa=no)) - AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa) - if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then - AC_MSG_ERROR(see the INSTALL doc for more info) - fi - CFLAGS="$savedcflags" - V_CCOPT="-Aa $V_CCOPT" - AC_DEFINE(_HPUX_SOURCE) - ;; - - *) - AC_MSG_ERROR(see the INSTALL doc for more info) - ;; - esac - fi - $2="$$2 -I/usr/local/include" - LDFLAGS="$LDFLAGS -L/usr/local/lib" - - case "$host_os" in - - irix*) - V_CCOPT="$V_CCOPT -xansi -signed -O" - ;; - - osf*) - V_CCOPT="$V_CCOPT -std1 -O" - ;; - - ultrix*) - AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) - AC_CACHE_VAL(ac_cv_lbl_cc_const_proto, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [struct a { int b; }; - void c(const struct a *)], - ac_cv_lbl_cc_const_proto=yes, - ac_cv_lbl_cc_const_proto=no)) - AC_MSG_RESULT($ac_cv_lbl_cc_const_proto) - if test $ac_cv_lbl_cc_const_proto = no ; then - AC_DEFINE(const,) - fi - ;; - esac - fi -]) - - -# -# Try compiling a sample of the type of code that appears in -# gencode.c with "inline", "__inline__", and "__inline". -# -# Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough, -# as it just tests whether a function returning "int" can be inlined; -# at least some versions of HP's C compiler can inline that, but can't -# inline a function that returns a struct pointer. -# -AC_DEFUN(AC_LBL_C_INLINE, - [AC_MSG_CHECKING(for inline) - AC_CACHE_VAL(ac_cv_lbl_inline, [ - ac_cv_lbl_inline="" - ac_lbl_cc_inline=no - for ac_lbl_inline in inline __inline__ __inline - do - AC_TRY_COMPILE( - [#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; - }],,ac_lbl_cc_inline=yes,) - 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]) - if test ! -z "$ac_cv_lbl_inline" ; then - AC_MSG_RESULT($ac_cv_lbl_inline) - else - AC_MSG_RESULT(no) - fi - AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) - -dnl -dnl Use pfopen.c if available and pfopen() not in standard libraries -dnl Require libpcap -dnl Look for libpcap in .. -dnl Use the installed libpcap if there is no local version -dnl -dnl usage: -dnl -dnl AC_LBL_LIBPCAP(pcapdep, incls) -dnl -dnl results: -dnl -dnl $1 (pcapdep set) -dnl $2 (incls appended) -dnl LIBS -dnl LBL_LIBS -dnl -AC_DEFUN(AC_LBL_LIBPCAP, - [AC_REQUIRE([AC_LBL_LIBRARY_NET]) - dnl - dnl save a copy before locating libpcap.a - dnl - LBL_LIBS="$LIBS" - pfopen=/usr/examples/packetfilter/pfopen.c - if test -f $pfopen ; then - AC_CHECK_FUNCS(pfopen) - if test $ac_cv_func_pfopen = "no" ; then - AC_MSG_RESULT(Using $pfopen) - LIBS="$LIBS $pfopen" - fi - fi - AC_MSG_CHECKING(for local pcap library) - libpcap=FAIL - lastdir=FAIL - places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ - egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'` - for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do - basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'` - if test $lastdir = $basedir ; then - dnl skip alphas when an actual release is present - continue; - fi - lastdir=$dir - if test -r $dir/libpcap.a ; then - libpcap=$dir/libpcap.a - d=$dir - dnl continue and select the last one that exists - fi - done - if test $libpcap = FAIL ; then - AC_MSG_RESULT(not found) - AC_CHECK_LIB(pcap, main, libpcap="-lpcap") - if test $libpcap = FAIL ; then - AC_MSG_ERROR(see the INSTALL doc for more info) - fi - dnl - dnl Good old Red Hat Linux puts "pcap.h" in - dnl "/usr/include/pcap"; had the LBL folks done so, - dnl that would have been a good idea, but for - dnl the Red Hat folks to do so just breaks source - dnl compatibility with other systems. - dnl - dnl We work around this by assuming that, as we didn't - dnl find a local libpcap, libpcap is in /usr/lib or - dnl /usr/local/lib and that the corresponding header - dnl file is under one of those directories; if we don't - dnl find it in either of those directories, we check to - dnl see if it's in a "pcap" subdirectory of them and, - dnl if so, add that subdirectory to the "-I" list. - dnl - AC_MSG_CHECKING(for extraneous pcap header directories) - if test \( ! -r /usr/local/include/pcap.h \) -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 - AC_MSG_RESULT(not found) - else - $2="-I$d $$2" - AC_MSG_RESULT(found -- -I$d added) - fi - else - $1=$libpcap - places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \ - egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'` - if test -r $d/pcap.h; then - $2="-I$d $$2" - elif test -r $places/pcap.h; then - $2="-I$places $$2" - else - AC_MSG_ERROR(cannot find pcap.h, see INSTALL) - fi - AC_MSG_RESULT($libpcap) - fi - LIBS="$libpcap $LIBS" - case "$host_os" in - - aix*) - pseexe="/lib/pse.exp" - AC_MSG_CHECKING(for $pseexe) - if test -f $pseexe ; then - AC_MSG_RESULT(yes) - LIBS="$LIBS -I:$pseexe" - fi - # - # We need "-lodm" and "-lcfg", as libpcap requires them on - # AIX, and we just build a static libpcap.a and thus can't - # arrange that when you link with libpcap you automatically - # link with those libraries. - # - LIBS="$LIBS -lodm -lcfg" - ;; - esac - - 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), - [ - AC_LIBOBJ(datalinks) - ]) - AC_CHECK_FUNC(pcap_set_datalink, - AC_DEFINE(HAVE_PCAP_SET_DATALINK)) - AC_CHECK_FUNC(pcap_datalink_name_to_val, - [ - AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL) - AC_CHECK_FUNC(pcap_datalink_val_to_description, - AC_DEFINE(HAVE_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. - AC_CHECK_FUNC(pcap_dump_ftell, - AC_DEFINE(HAVE_PCAP_DUMP_FTELL), - [ - AC_LIBOBJ(pcap_dump_ftell) - ]) -]) - -dnl -dnl Define RETSIGTYPE and RETSIGVAL -dnl -dnl usage: -dnl -dnl AC_LBL_TYPE_SIGNAL -dnl -dnl results: -dnl -dnl RETSIGTYPE (defined) -dnl RETSIGVAL (defined) -dnl -AC_DEFUN(AC_LBL_TYPE_SIGNAL, - [AC_BEFORE([$0], [AC_LBL_LIBPCAP]) - AC_TYPE_SIGNAL - if test "$ac_cv_type_signal" = void ; then - AC_DEFINE(RETSIGVAL,) - else - AC_DEFINE(RETSIGVAL,(0)) - fi - case "$host_os" in - - irix*) - AC_DEFINE(_BSD_SIGNALS) - ;; - - *) - dnl prefer sigaction() to sigset() - AC_CHECK_FUNCS(sigaction) - if test $ac_cv_func_sigaction = no ; then - AC_CHECK_FUNCS(sigset) - fi - ;; - esac]) - -dnl -dnl If using gcc, make sure we have ANSI ioctl definitions -dnl -dnl usage: -dnl -dnl AC_LBL_FIXINCLUDES -dnl -AC_DEFUN(AC_LBL_FIXINCLUDES, - [if test "$GCC" = yes ; then - AC_MSG_CHECKING(for ANSI ioctl definitions) - AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes, - AC_TRY_COMPILE( - [/* - * This generates a "duplicate case value" when fixincludes - * has not be run. - */ -# include <sys/types.h> -# include <sys/time.h> -# include <sys/ioctl.h> -# ifdef HAVE_SYS_IOCCOM_H -# include <sys/ioccom.h> -# endif], - [switch (0) { - case _IO('A', 1):; - case _IO('B', 1):; - }], - ac_cv_lbl_gcc_fixincludes=yes, - ac_cv_lbl_gcc_fixincludes=no)) - AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes) - if test $ac_cv_lbl_gcc_fixincludes = no ; then - # Don't cache failure - unset ac_cv_lbl_gcc_fixincludes - AC_MSG_ERROR(see the INSTALL for more info) - fi - fi]) - -dnl -dnl Check for flex, default to lex -dnl Require flex 2.4 or higher -dnl Check for bison, default to yacc -dnl Default to lex/yacc if both flex and bison are not available -dnl Define the yy prefix string if using flex and bison -dnl -dnl usage: -dnl -dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) -dnl -dnl results: -dnl -dnl $1 (lex set) -dnl $2 (yacc appended) -dnl $3 (optional flex and bison -P prefix) -dnl -AC_DEFUN(AC_LBL_LEX_AND_YACC, - [AC_ARG_WITH(flex, [ --without-flex don't use flex]) - AC_ARG_WITH(bison, [ --without-bison don't use bison]) - if test "$with_flex" = no ; then - $1=lex - else - AC_CHECK_PROGS($1, flex, lex) - fi - if test "$$1" = flex ; then - # The -V flag was added in 2.4 - AC_MSG_CHECKING(for flex 2.4 or higher) - AC_CACHE_VAL(ac_cv_lbl_flex_v24, - if flex -V >/dev/null 2>&1; then - ac_cv_lbl_flex_v24=yes - else - ac_cv_lbl_flex_v24=no - fi) - AC_MSG_RESULT($ac_cv_lbl_flex_v24) - if test $ac_cv_lbl_flex_v24 = no ; then - s="2.4 or higher required" - AC_MSG_WARN(ignoring obsolete flex executable ($s)) - $1=lex - fi - fi - if test "$with_bison" = no ; then - $2=yacc - else - AC_CHECK_PROGS($2, bison, yacc) - fi - if test "$$2" = bison ; then - $2="$$2 -y" - fi - if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then - AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) - $1=lex - $2=yacc - fi - if test "$$1" = flex -a -n "$3" ; then - $1="$$1 -P$3" - $2="$$2 -p $3" - fi]) - -dnl -dnl Checks to see if union wait is used with WEXITSTATUS() -dnl -dnl usage: -dnl -dnl AC_LBL_UNION_WAIT -dnl -dnl results: -dnl -dnl DECLWAITSTATUS (defined) -dnl -AC_DEFUN(AC_LBL_UNION_WAIT, - [AC_MSG_CHECKING(if union wait is used) - AC_CACHE_VAL(ac_cv_lbl_union_wait, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/wait.h>], - [int status; - u_int i = WEXITSTATUS(status); - u_int j = waitpid(0, &status, 0);], - ac_cv_lbl_union_wait=no, - ac_cv_lbl_union_wait=yes)) - AC_MSG_RESULT($ac_cv_lbl_union_wait) - if test $ac_cv_lbl_union_wait = yes ; then - AC_DEFINE(DECLWAITSTATUS,union wait) - else - AC_DEFINE(DECLWAITSTATUS,int) - fi]) - -dnl -dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member -dnl -dnl usage: -dnl -dnl AC_LBL_SOCKADDR_SA_LEN -dnl -dnl results: -dnl -dnl HAVE_SOCKADDR_SA_LEN (defined) -dnl -AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, - [AC_MSG_CHECKING(if sockaddr struct has sa_len member) - AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/socket.h>], - [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], - ac_cv_lbl_sockaddr_has_sa_len=yes, - ac_cv_lbl_sockaddr_has_sa_len=no)) - AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len) - if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN) - fi]) - -dnl -dnl Checks to see if -R is used -dnl -dnl usage: -dnl -dnl AC_LBL_HAVE_RUN_PATH -dnl -dnl results: -dnl -dnl ac_cv_lbl_have_run_path (yes or no) -dnl -AC_DEFUN(AC_LBL_HAVE_RUN_PATH, - [AC_MSG_CHECKING(for ${CC-cc} -R) - AC_CACHE_VAL(ac_cv_lbl_have_run_path, - [echo 'main(){}' > conftest.c - ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 - if test ! -s conftest.out ; then - ac_cv_lbl_have_run_path=yes - else - ac_cv_lbl_have_run_path=no - fi - rm -f conftest*]) - AC_MSG_RESULT($ac_cv_lbl_have_run_path) - ]) - -dnl -dnl Check whether a given format can be used to print 64-bit integers -dnl -AC_DEFUN(AC_LBL_CHECK_64BIT_FORMAT, - [ - AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers]) - AC_RUN_IFELSE( - [ - AC_LANG_SOURCE( - [[ -# ifdef HAVE_INTTYPES_H - #include <inttypes.h> -# endif -# ifdef HAVE_SYS_BITYPES_H - #include <sys/bitypes.h> -# endif - #include <stdio.h> - #include <sys/types.h> - - main() - { - u_int64_t t = 1; - char strbuf[16+1]; - sprintf(strbuf, "%016$1x", t << 32); - if (strcmp(strbuf, "0000000100000000") == 0) - exit(0); - else - exit(1); - } - ]]) - ], - [ - AC_DEFINE(PRId64, "$1d") - AC_DEFINE(PRIo64, "$1o") - AC_DEFINE(PRIx64, "$1x") - AC_DEFINE(PRIu64, "$1u") - AC_MSG_RESULT(yes) - ], - [ - AC_MSG_RESULT(no) - $2 - ]) - ]) - -dnl -dnl Checks to see if unaligned memory accesses fail -dnl -dnl usage: -dnl -dnl AC_LBL_UNALIGNED_ACCESS -dnl -dnl results: -dnl -dnl LBL_ALIGN (DEFINED) -dnl -AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, - [AC_MSG_CHECKING(if unaligned accesses fail) - AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, - [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*|hp*|mips*|sh*|sparc*|ia64|nv1) - ac_cv_lbl_unaligned_fail=yes - ;; - - *) - cat >conftest.c <<EOF -# include <sys/types.h> -# include <sys/wait.h> -# include <stdio.h> - 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 - dnl failed to compile for some reason - 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 conftest* core core.conftest - ;; - esac]) - AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) - if test $ac_cv_lbl_unaligned_fail = yes ; then - AC_DEFINE(LBL_ALIGN) - fi]) - -dnl -dnl If using gcc and the file .devel exists: -dnl Compile with -g (if supported) and -Wall -dnl If using gcc 2 or later, do extra prototype checking and some other -dnl checks -dnl If an os prototype include exists, symlink os-proto.h to it -dnl -dnl usage: -dnl -dnl AC_LBL_DEVEL(copt) -dnl -dnl results: -dnl -dnl $1 (copt appended) -dnl HAVE_OS_PROTO_H (defined) -dnl os-proto.h (symlinked) -dnl -AC_DEFUN(AC_LBL_DEVEL, - [rm -f os-proto.h - if test "${LBL_CFLAGS+set}" = set; then - $1="$$1 ${LBL_CFLAGS}" - fi - if test -f .devel ; then - if test "$GCC" = yes ; then - if test "${LBL_CFLAGS+set}" != set; then - if test "$ac_cv_prog_cc_g" = yes ; then - $1="-g $$1" - fi - $1="$$1 -Wall" - if test $ac_cv_lbl_gcc_vers -gt 1 ; then - $1="$$1 -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wpointer-arith -W" - fi - fi - else - case "$host_os" in - - irix6*) - V_CCOPT="$V_CCOPT -n32" - ;; - - *) - ;; - esac - fi - 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 - AC_DEFINE(HAVE_OS_PROTO_H) - else - AC_MSG_WARN(can't find $name) - fi - fi]) - -dnl -dnl Improved version of AC_CHECK_LIB -dnl -dnl Thanks to John Hawkinson (jhawk@mit.edu) -dnl -dnl usage: -dnl -dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, -dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) -dnl -dnl results: -dnl -dnl LIBS -dnl -dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS" -dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more. -dnl We keep it around for reference purposes in case it's ever -dnl useful in the future. -dnl - -define(AC_LBL_CHECK_LIB, -[AC_MSG_CHECKING([for $2 in -l$1]) -dnl Use a cache variable name containing the library, function -dnl name, and extra libraries to link with, because the test really is -dnl for library $1 defining function $2, when linked with potinal -dnl library $5, not just for library $1. Separate tests with the same -dnl $1 and different $2's or $5's may have different results. -ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'` -AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var, -[ac_save_LIBS="$LIBS" -LIBS="-l$1 $5 $LIBS" -AC_TRY_LINK(dnl -ifelse([$2], [main], , dnl Avoid conflicting decl of main. -[/* Override any gcc2 internal prototype to avoid an error. */ -]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus -extern "C" -#endif -])dnl -[/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char $2(); -]), - [$2()], - eval "ac_cv_lbl_lib_$ac_lib_var=yes", - eval "ac_cv_lbl_lib_$ac_lib_var=no") -LIBS="$ac_save_LIBS" -])dnl -if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then - AC_MSG_RESULT(yes) - ifelse([$3], , -[changequote(, )dnl - ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` -changequote([, ])dnl - AC_DEFINE_UNQUOTED($ac_tr_lib) - LIBS="-l$1 $LIBS" -], [$3]) -else - AC_MSG_RESULT(no) -ifelse([$4], , , [$4 -])dnl -fi -]) - -dnl -dnl AC_LBL_LIBRARY_NET -dnl -dnl This test is for network applications that need socket() and -dnl gethostbyname() -ish functions. Under Solaris, those applications -dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link -dnl with "-lnsl" but should *not* link with "-lsocket" because -dnl libsocket.a breaks a number of things (for instance: -dnl gethostbyname() under IRIX 5.2, and snoop sockets under most -dnl versions of IRIX). -dnl -dnl Unfortunately, many application developers are not aware of this, -dnl and mistakenly write tests that cause -lsocket to be used under -dnl IRIX. It is also easy to write tests that cause -lnsl to be used -dnl under operating systems where neither are necessary (or useful), -dnl such as SunOS 4.1.4, which uses -lnsl for TLI. -dnl -dnl This test exists so that every application developer does not test -dnl this in a different, and subtly broken fashion. - -dnl It has been argued that this test should be broken up into two -dnl seperate tests, one for the resolver libraries, and one for the -dnl libraries necessary for using Sockets API. Unfortunately, the two -dnl are carefully intertwined and allowing the autoconf user to use -dnl them independantly potentially results in unfortunate ordering -dnl dependancies -- as such, such component macros would have to -dnl carefully use indirection and be aware if the other components were -dnl executed. Since other autoconf macros do not go to this trouble, -dnl and almost no applications use sockets without the resolver, this -dnl complexity has not been implemented. -dnl -dnl The check for libresolv is in case you are attempting to link -dnl statically and happen to have a libresolv.a lying around (and no -dnl libnsl.a). -dnl -AC_DEFUN(AC_LBL_LIBRARY_NET, [ - # 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: - AC_SEARCH_LIBS(gethostbyname, nsl socket resolv) - # 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 - AC_CHECK_LIB(socket, gethostbyname, - LIBS="-lsocket -lnsl $LIBS", , -lnsl) - fi - AC_SEARCH_LIBS(socket, socket, , - AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)) - # DLPI needs putmsg under HPUX so test for -lstr while we're at it - AC_SEARCH_LIBS(putmsg, str) - ]) - -dnl Copyright (c) 1999 WIDE Project. All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl 1. Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl 2. Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl 3. Neither the name of the project nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND -dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE -dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -dnl SUCH DAMAGE. - -dnl -dnl Checks to see if AF_INET6 is defined -AC_DEFUN(AC_CHECK_AF_INET6, [ - AC_MSG_CHECKING(for AF_INET6) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/socket.h>], - [int a = AF_INET6], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes ; then - AC_DEFINE(HAVE_AF_INET6) - fi -]) - -dnl -dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member -dnl borrowed from LBL libpcap -AC_DEFUN(AC_CHECK_SA_LEN, [ - AC_MSG_CHECKING(if sockaddr struct has sa_len member) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/socket.h>], - [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes ; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN) - fi -]) - -dnl -dnl Checks for portable prototype declaration macro -AC_DEFUN(AC_CHECK_PORTABLE_PROTO, [ - AC_MSG_CHECKING(for __P) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <unistd.h>], - [int f __P(())], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_PORTABLE_PROTOTYPE) - fi -]) - -dnl checks for u_intXX_t -AC_DEFUN(AC_CHECK_BITTYPES, [ - $1=yes -dnl check for u_int8_t - AC_MSG_CHECKING(for u_int8_t) - AC_CACHE_VAL(ac_cv_u_int8_t, - AC_TRY_COMPILE([ -# include <sys/types.h>], - [u_int8_t i], - ac_cv_u_int8_t=yes, - ac_cv_u_int8_t=no)) - AC_MSG_RESULT($ac_cv_u_int8_t) - if test $ac_cv_u_int8_t = yes; then - AC_DEFINE(HAVE_U_INT8_T) - else - $1=no - fi -dnl check for u_int16_t - AC_MSG_CHECKING(for u_int16_t) - AC_CACHE_VAL(ac_cv_u_int16_t, - AC_TRY_COMPILE([ -# include <sys/types.h>], - [u_int16_t i], - ac_cv_u_int16_t=yes, - ac_cv_u_int16_t=no)) - AC_MSG_RESULT($ac_cv_u_int16_t) - if test $ac_cv_u_int16_t = yes; then - AC_DEFINE(HAVE_U_INT16_T) - else - $1=no - fi -dnl check for u_int32_t - AC_MSG_CHECKING(for u_int32_t) - AC_CACHE_VAL(ac_cv_u_int32_t, - AC_TRY_COMPILE([ -# include <sys/types.h>], - [u_int32_t i], - ac_cv_u_int32_t=yes, - ac_cv_u_int32_t=no)) - AC_MSG_RESULT($ac_cv_u_int32_t) - if test $ac_cv_u_int32_t = yes; then - AC_DEFINE(HAVE_U_INT32_T) - else - $1=no - fi -dnl check for u_int64_t - AC_MSG_CHECKING(for u_int64_t) - AC_CACHE_VAL(ac_cv_u_int64_t, - AC_TRY_COMPILE([ -# include <sys/types.h>], - [u_int64_t i], - ac_cv_u_int64_t=yes, - ac_cv_u_int64_t=no)) - AC_MSG_RESULT($ac_cv_u_int64_t) - if test $ac_cv_u_int64_t = yes; then - AC_DEFINE(HAVE_U_INT64_T) - else - $1=no - fi -]) - -dnl -dnl Checks for addrinfo structure -AC_DEFUN(AC_STRUCT_ADDRINFO, [ - AC_MSG_CHECKING(for addrinfo) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <netdb.h>], - [struct addrinfo a], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_ADDRINFO) - else - AC_DEFINE(NEED_ADDRINFO_H) - fi -]) - -dnl -dnl Checks for NI_MAXSERV -AC_DEFUN(AC_NI_MAXSERV, [ - AC_MSG_CHECKING(for NI_MAXSERV) - AC_CACHE_VAL($1, - AC_EGREP_CPP(yes, [#include <netdb.h> -#ifdef NI_MAXSERV -yes -#endif], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 != yes; then - AC_DEFINE(NEED_ADDRINFO_H) - fi -]) - -dnl -dnl Checks for NI_NAMEREQD -AC_DEFUN(AC_NI_NAMEREQD, [ - AC_MSG_CHECKING(for NI_NAMEREQD) - AC_CACHE_VAL($1, - AC_EGREP_CPP(yes, [#include <netdb.h> -#ifdef NI_NOFQDN -yes -#endif], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 != yes; then - AC_DEFINE(NEED_ADDRINFO_H) - fi -]) - -dnl -dnl Checks for sockaddr_storage structure -AC_DEFUN(AC_STRUCT_SA_STORAGE, [ - AC_MSG_CHECKING(for sockaddr_storage) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/socket.h>], - [struct sockaddr_storage s], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_SOCKADDR_STORAGE) - fi -]) - -dnl -dnl Checks for macro of IP address size -AC_DEFUN(AC_CHECK_ADDRSZ, [ - $1=yes -dnl check for INADDRSZ - AC_MSG_CHECKING(for INADDRSZ) - AC_CACHE_VAL(ac_cv_inaddrsz, - AC_TRY_COMPILE([ -# include <arpa/nameser.h>], - [int a = INADDRSZ], - ac_cv_inaddrsz=yes, - ac_cv_inaddrsz=no)) - AC_MSG_RESULT($ac_cv_inaddrsz) - if test $ac_cv_inaddrsz = yes; then - AC_DEFINE(HAVE_INADDRSZ) - else - $1=no - fi -dnl check for IN6ADDRSZ - AC_MSG_CHECKING(for IN6ADDRSZ) - AC_CACHE_VAL(ac_cv_in6addrsz, - AC_TRY_COMPILE([ -# include <arpa/nameser.h>], - [int a = IN6ADDRSZ], - ac_cv_in6addrsz=yes, - ac_cv_in6addrsz=no)) - AC_MSG_RESULT($ac_cv_in6addrsz) - if test $ac_cv_in6addrsz = yes; then - AC_DEFINE(HAVE_IN6ADDRSZ) - else - $1=no - fi -]) - -dnl -dnl check for RES_USE_INET6 -AC_DEFUN(AC_CHECK_RES_USE_INET6, [ - AC_MSG_CHECKING(for RES_USE_INET6) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <netinet/in.h> -# include <resolv.h>], - [int a = RES_USE_INET6], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_RES_USE_INET6) - fi -]) - -dnl -dnl check for AAAA -AC_DEFUN(AC_CHECK_AAAA, [ - AC_MSG_CHECKING(for AAAA) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <arpa/nameser.h>], - [int a = T_AAAA], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_AAAA) - fi -]) - -dnl -dnl check for struct res_state_ext -AC_DEFUN(AC_STRUCT_RES_STATE_EXT, [ - AC_MSG_CHECKING(for res_state_ext) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <netinet/in.h> -# include <netinet6/in6.h> -# include <resolv.h>], - [struct __res_state_ext e], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_RES_STATE_EXT) - fi -]) - -dnl -dnl check for struct res_state_ext -AC_DEFUN(AC_STRUCT_RES_STATE, [ - AC_MSG_CHECKING(for nsort in res_state) - AC_CACHE_VAL($1, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <netinet/in.h> -# include <netinet6/in6.h> -# include <resolv.h>], - [struct __res_state e; e.nsort = 0], - $1=yes, - $1=no)) - AC_MSG_RESULT($$1) - if test $$1 = yes; then - AC_DEFINE(HAVE_NEW_RES_STATE) - fi -]) - -dnl -dnl check for h_errno -AC_DEFUN(AC_VAR_H_ERRNO, [ - AC_MSG_CHECKING(for h_errno) - AC_CACHE_VAL(ac_cv_var_h_errno, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <netdb.h>], - [int foo = h_errno;], - ac_cv_var_h_errno=yes, - ac_cv_var_h_errno=no)) - AC_MSG_RESULT($ac_cv_var_h_errno) - if test "$ac_cv_var_h_errno" = "yes"; then - AC_DEFINE(HAVE_H_ERRNO) - fi -]) - -dnl -dnl Test for __attribute__ -dnl - -AC_DEFUN(AC_C___ATTRIBUTE__, [ -AC_MSG_CHECKING(for __attribute__) -AC_CACHE_VAL(ac_cv___attribute__, [ -AC_COMPILE_IFELSE( - AC_LANG_SOURCE([[ -#include <stdlib.h> - -static void foo(void) __attribute__ ((noreturn)); - -static void -foo(void) -{ - exit(1); -} - -int -main(int argc, char **argv) -{ - foo(); -} - ]]), -ac_cv___attribute__=yes, -ac_cv___attribute__=no)]) -if test "$ac_cv___attribute__" = "yes"; then - AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) - V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\"" -else - V_DEFS="$V_DEFS -D_U_=\"\"" -fi -AC_MSG_RESULT($ac_cv___attribute__) -]) diff --git a/contrib/tcpdump/acsite.m4 b/contrib/tcpdump/acsite.m4 deleted file mode 100644 index 746faf1..0000000 --- a/contrib/tcpdump/acsite.m4 +++ /dev/null @@ -1,505 +0,0 @@ -dnl @(#) $Header: acsite.m4,v 1.41 96/11/29 15:30:40 leres Exp $ (LBL) -dnl -dnl Copyright (c) 1995, 1996 -dnl The Regents of the University of California. All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that: (1) source code distributions -dnl retain the above copyright notice and this paragraph in its entirety, (2) -dnl distributions including binary code include the above copyright notice and -dnl this paragraph in its entirety in the documentation or other materials -dnl provided with the distribution, and (3) all advertising materials mentioning -dnl features or use of this software display the following acknowledgement: -dnl ``This product includes software developed by the University of California, -dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of -dnl the University nor the names of its contributors may be used to endorse -dnl or promote products derived from this software without specific prior -dnl written permission. -dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -dnl -dnl LBL autoconf macros -dnl - -dnl -dnl Determine which compiler we're using (cc or gcc) -dnl If using gcc, determine the version number -dnl If using cc, require that it support ansi prototypes -dnl If using gcc, use -O2 (otherwise use -O) -dnl If using cc, explicitly specify /usr/local/include -dnl -dnl usage: -dnl -dnl AC_LBL_C_INIT(copt, incls) -dnl -dnl results: -dnl -dnl $1 (copt set) -dnl $2 (incls set) -dnl CC -dnl ac_cv_gcc_vers -dnl LBL_CFLAGS -dnl -dnl XXX need to add test to make sure ac_prog_cc hasn't been called -AC_DEFUN(AC_LBL_C_INIT, - [AC_PREREQ(2.12) - $1=-O - $2="" - if test "${CFLAGS+set}" = set; then - LBL_CFLAGS="$CFLAGS" - fi - if test -z "$CC" ; then - case "$target_os" in - - bsdi*) - AC_CHECK_PROG(SHLICC2, shlicc2, yes, no) - if test $SHLICC2 = yes ; then - CC=shlicc2 - export CC - fi - ;; - esac - fi - AC_PROG_CC - if test $ac_cv_prog_gcc = yes ; then - if test "$SHLICC2" = yes ; then - ac_cv_gcc_vers=2 - $1=-O2 - else - AC_MSG_CHECKING(gcc version) - AC_CACHE_VAL(ac_cv_gcc_vers, - ac_cv_gcc_vers=`$CC -v 2>&1 | \ - sed -n -e '$s/.* //' -e '$s/\..*//p'`) - AC_MSG_RESULT($ac_cv_gcc_vers) - if test $ac_cv_gcc_vers -gt 1 ; then - $1=-O2 - fi - fi - else - AC_MSG_CHECKING(that $CC handles ansi prototypes) - AC_CACHE_VAL(ac_cv_cc_ansi_prototypes, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [int frob(int, char *)], - ac_cv_cc_ansi_prototypes=yes, - ac_cv_cc_ansi_prototypes=no)) - AC_MSG_RESULT($ac_cv_cc_ansi_prototypes) - if test $ac_cv_cc_ansi_prototypes = no ; then - case "$target_os" in - - hpux*) - AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)) - savedcflags="$CFLAGS" - CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS" - AC_CACHE_VAL(ac_cv_cc_hpux_cc_aa, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [int frob(int, char *)], - ac_cv_cc_hpux_cc_aa=yes, - ac_cv_cc_hpux_cc_aa=no)) - AC_MSG_RESULT($ac_cv_cc_hpux_cc_aa) - if test $ac_cv_cc_hpux_cc_aa = no ; then - AC_MSG_ERROR(see the INSTALL for more info) - fi - CFLAGS="$savedcflags" - V_CCOPT="-Aa $V_CCOPT" - AC_DEFINE(_HPUX_SOURCE) - ;; - - *) - AC_MSG_ERROR(see the INSTALL for more info) - ;; - esac - fi - $2=-I/usr/local/include - - case "$target_os" in - - irix*) - V_CCOPT="$V_CCOPT -xansi -signed -g3" - ;; - - osf*) - V_CCOPT="$V_CCOPT -g3" - ;; - - ultrix*) - AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes) - AC_CACHE_VAL(ac_cv_cc_const_proto, - AC_TRY_COMPILE( - [#include <sys/types.h>], - [struct a { int b; }; - void c(const struct a *)], - ac_cv_cc_const_proto=yes, - ac_cv_cc_const_proto=no)) - AC_MSG_RESULT($ac_cv_cc_const_proto) - if test $ac_cv_cc_const_proto = no ; then - AC_DEFINE(const,) - fi - ;; - esac - fi -]) - -dnl -dnl Use pfopen.c if available and pfopen() not in standard libraries -dnl Require libpcap -dnl Look for libpcap in .. -dnl Use the installed libpcap if there is no local version -dnl -dnl usage: -dnl -dnl AC_LBL_LIBPCAP(pcapdep, incls) -dnl -dnl results: -dnl -dnl $1 (pcapdep set) -dnl $2 (incls appended) -dnl LIBS -dnl -AC_DEFUN(AC_LBL_LIBPCAP, - [pfopen=/usr/examples/packetfilter/pfopen.c - if test -f $pfopen ; then - AC_CHECK_FUNCS(pfopen) - if test $ac_cv_func_pfopen = "no" ; then - AC_MSG_RESULT(Using $pfopen) - LIBS="$LIBS $pfopen" - fi - fi - AC_MSG_CHECKING(for local pcap library) - libpcap=FAIL - lastdir=FAIL - places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \ - egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'` - for dir in $places ../libpcap libpcap ; do - basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'` - if test $lastdir = $basedir ; then - dnl skip alphas when an actual release is present - continue; - fi - lastdir=$dir - if test -r $dir/pcap.c ; then - libpcap=$dir/libpcap.a - d=$dir - dnl continue and select the last one that exists - fi - done - if test $libpcap = FAIL ; then - AC_MSG_RESULT(not found) - AC_CHECK_LIB(pcap, main, libpcap="-lpcap") - if test $libpcap = FAIL ; then - AC_MSG_ERROR(see the INSTALL doc for more info) - fi - else - $1=$libpcap - $2="-I$d $$2" - AC_MSG_RESULT($libpcap) - fi - LIBS="$libpcap $LIBS"]) - -dnl -dnl Define RETSIGTYPE and RETSIGVAL -dnl -dnl usage: -dnl -dnl AC_LBL_TYPE_SIGNAL -dnl -dnl results: -dnl -dnl RETSIGTYPE (defined) -dnl RETSIGVAL (defined) -dnl -AC_DEFUN(AC_LBL_TYPE_SIGNAL, - [AC_TYPE_SIGNAL - if test "$ac_cv_type_signal" = void ; then - AC_DEFINE(RETSIGVAL,) - else - AC_DEFINE(RETSIGVAL,(0)) - fi - case "$target_os" in - - irix*) - AC_DEFINE(_BSD_SIGNALS) - ;; - - *) - AC_CHECK_FUNCS(sigset) - if test $ac_cv_func_sigset = yes ; then - AC_DEFINE(signal, sigset) - fi - ;; - esac]) - -dnl -dnl If using gcc, see if fixincludes should be run -dnl -dnl usage: -dnl -dnl AC_LBL_FIXINCLUDES -dnl -AC_DEFUN(AC_LBL_FIXINCLUDES, - [if test $ac_cv_prog_gcc = yes ; then - AC_MSG_CHECKING(if fixincludes is needed) - AC_CACHE_VAL(ac_cv_gcc_fixincludes, - AC_TRY_COMPILE( - [/* - * This generates a "duplicate case value" when fixincludes - * has not be run. - */ -# include <sys/types.h> -# include <sys/time.h> -# include <sys/ioctl.h> -# ifdef HAVE_SYS_IOCCOM_H -# include <sys/ioccom.h> -# endif], - [switch (0) { - case _IO('A', 1):; - case _IO('B', 1):; - }], - ac_cv_gcc_fixincludes=yes, - ac_cv_gcc_fixincludes=no)) - AC_MSG_RESULT($ac_cv_gcc_fixincludes) - if test $ac_cv_gcc_fixincludes = no ; then - # Don't cache failure - unset ac_cv_gcc_fixincludes - AC_MSG_ERROR(see the INSTALL for more info) - fi - fi]) - -dnl -dnl Check for flex, default to lex -dnl Require flex 2.4 or higher -dnl Check for bison, default to yacc -dnl Default to lex/yacc if both flex and bison are not available -dnl Define the yy prefix string if using flex and bison -dnl -dnl usage: -dnl -dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) -dnl -dnl results: -dnl -dnl $1 (lex set) -dnl $2 (yacc appended) -dnl $3 (optional flex and bison -P prefix) -dnl -AC_DEFUN(AC_LBL_LEX_AND_YACC, - [AC_CHECK_PROGS($1, flex, lex) - if test "$$1" = flex ; then - # The -V flag was added in 2.4 - AC_MSG_CHECKING(for flex 2.4 or higher) - AC_CACHE_VAL(ac_cv_flex_v24, - if flex -V >/dev/null 2>&1; then - ac_cv_flex_v24=yes - else - ac_cv_flex_v24=no - fi) - AC_MSG_RESULT($ac_cv_flex_v24) - if test $ac_cv_flex_v24 = no ; then - s="2.4 or higher required" - AC_MSG_WARN(ignoring obsolete flex executable ($s)) - $1=lex - fi - fi - AC_CHECK_PROGS($2, bison, yacc) - if test "$$2" = bison ; then - $2="$$2 -y" - fi - if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then - AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) - $1=lex - $2=yacc - fi - if test "$$1" = flex -a -n "$3" ; then - $1="$$1 -P$3" - $2="$$2 -p $3" - fi]) - -dnl -dnl Checks to see if union wait is used with WEXITSTATUS() -dnl -dnl usage: -dnl -dnl AC_LBL_UNION_WAIT -dnl -dnl results: -dnl -dnl DECLWAITSTATUS (defined) -dnl -AC_DEFUN(AC_LBL_UNION_WAIT, - [AC_MSG_CHECKING(if union wait is used) - AC_CACHE_VAL(ac_cv_union_wait, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/wait.h>], - [int status; - u_int i = WEXITSTATUS(status); - u_int j = waitpid(0, &status, 0);], - ac_cv_union_wait=no, - ac_cv_union_wait=yes)) - AC_MSG_RESULT($ac_cv_union_wait) - if test $ac_cv_union_wait = yes ; then - AC_DEFINE(DECLWAITSTATUS,union wait) - else - AC_DEFINE(DECLWAITSTATUS,int) - fi]) - -dnl -dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member -dnl -dnl usage: -dnl -dnl AC_LBL_SOCKADDR_SA_LEN -dnl -dnl results: -dnl -dnl HAVE_SOCKADDR_SA_LEN (defined) -dnl -AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN, - [AC_MSG_CHECKING(if sockaddr struct has sa_len member) - AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len, - AC_TRY_COMPILE([ -# include <sys/types.h> -# include <sys/socket.h>], - [u_int i = sizeof(((struct sockaddr *)0)->sa_len)], - ac_cv_sockaddr_has_sa_len=yes, - ac_cv_sockaddr_has_sa_len=no)) - AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len) - if test $ac_cv_sockaddr_has_sa_len = yes ; then - AC_DEFINE(HAVE_SOCKADDR_SA_LEN) - fi]) - -dnl -dnl Checks to see if -R is used -dnl -dnl usage: -dnl -dnl AC_LBL_HAVE_RUN_PATH -dnl -dnl results: -dnl -dnl ac_cv_have_run_path (yes or no) -dnl -AC_DEFUN(AC_LBL_HAVE_RUN_PATH, - [AC_MSG_CHECKING(for ${CC-cc} -R) - AC_CACHE_VAL(ac_cv_have_run_path, - [echo 'main(){}' > conftest.c - ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1 - if test ! -s conftest.out ; then - ac_cv_have_run_path=yes - else - ac_cv_have_run_path=no - fi - rm -f conftest*]) - AC_MSG_RESULT($ac_cv_have_run_path) - ]) - -dnl -dnl Checks to see if unaligned memory accesses fail -dnl -dnl usage: -dnl -dnl AC_LBL_UNALIGNED_ACCESS -dnl -dnl results: -dnl -dnl LBL_ALIGN (DEFINED) -dnl -AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, - [AC_MSG_CHECKING(if unaligned accesses fail) - AC_CACHE_VAL(ac_cv_unaligned_fail, - [case "$target_cpu" in - - alpha|hp*|mips|sparc) - ac_cv_unaligned_fail=yes - ;; - - *) - cat >conftest.c <<EOF -# include <sys/types.h> -# include <sys/wait.h> -# include <stdio.h> - 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 - dnl failed to compile for some reason - ac_cv_unaligned_fail=yes - else - ./conftest >conftest.out - if test ! -s conftest.out ; then - ac_cv_unaligned_fail=yes - else - ac_cv_unaligned_fail=no - fi - fi - rm -f conftest* core core.conftest - ;; - esac]) - AC_MSG_RESULT($ac_cv_unaligned_fail) - if test $ac_cv_unaligned_fail = yes ; then - AC_DEFINE(LBL_ALIGN) - fi]) - -dnl -dnl If using gcc and the file .devel exists: -dnl Compile with -g (if supported) and -Wall -dnl If using gcc 2, do extra prototype checking -dnl If an os prototype include exists, symlink os-proto.h to it -dnl -dnl usage: -dnl -dnl AC_LBL_DEVEL(copt) -dnl -dnl results: -dnl -dnl $1 (copt appended) -dnl HAVE_OS_PROTO_H (defined) -dnl os-proto.h (symlinked) -dnl -AC_DEFUN(AC_LBL_DEVEL, - [rm -f os-proto.h - if test "${LBL_CFLAGS+set}" = set; then - $1="$$1 ${LBL_CFLAGS}" - fi - if test $ac_cv_prog_gcc = yes -a -f .devel ; then - if test "${LBL_CFLAGS+set}" != set; then - if test "$ac_cv_prog_cc_g" = yes ; then - $1="-g $$1" - fi - $1="$$1 -Wall" - if test $ac_cv_gcc_vers -gt 1 ; then - $1="$$1 -Wmissing-prototypes -Wstrict-prototypes" - fi - fi - os=`echo $target_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 - AC_DEFINE(HAVE_OS_PROTO_H) - else - AC_MSG_WARN(can't find $name) - fi - fi]) diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c index 53d615f..d2e7b48 100644 --- a/contrib/tcpdump/addrtoname.c +++ b/contrib/tcpdump/addrtoname.c @@ -20,10 +20,12 @@ * * Internet, ethernet, port, and protocol string to address * and address to string conversion routines + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.9 2007/09/14 00:26:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.108.2.7 2005/09/29 07:46:45 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -68,10 +70,6 @@ extern int ether_ntohost(char *, const struct ether_addr *); #include "extract.h" #include "oui.h" -#ifndef ETHER_ADDR_LEN -#define ETHER_ADDR_LEN 6 -#endif - /* * hash tables for whatever-to-name translations * @@ -515,7 +513,7 @@ linkaddr_string(const u_char *ep, const unsigned int len) register char *cp; register struct enamemem *tp; - if (len == ETHER_ADDR_LEN) /* XXX not totally correct... */ + if (len == 6) /* XXX not totally correct... */ return etheraddr_string(ep); tp = lookup_bytestring(ep, len); diff --git a/contrib/tcpdump/dhcp6.h b/contrib/tcpdump/dhcp6.h deleted file mode 100644 index 8381b11..0000000 --- a/contrib/tcpdump/dhcp6.h +++ /dev/null @@ -1,200 +0,0 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6.h,v 1.4 2000/12/17 23:07:48 guy Exp $ (LBL) */ -/* - * Copyright (C) 1998 and 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. - */ -/* - * draft-ietf-dhc-dhcpv6-15 - */ - -#ifndef __DHCP6_H_DEFINED -#define __DHCP6_H_DEFINED - -/* Error Values */ -#define DH6ERR_FAILURE 16 -#define DH6ERR_AUTHFAIL 17 -#define DH6ERR_POORLYFORMED 18 -#define DH6ERR_UNAVAIL 19 -#define DH6ERR_NOBINDING 20 -#define DH6ERR_INVALIDSOURCE 21 -#define DH6ERR_NOSERVER 23 -#define DH6ERR_ICMPERROR 64 - -/* Message type */ -#define DH6_SOLICIT 1 -#define DH6_ADVERT 2 -#define DH6_REQUEST 3 -#define DH6_REPLY 4 -#define DH6_RELEASE 5 -#define DH6_RECONFIG 6 - -/* Predefined addresses */ -#define DH6ADDR_ALLAGENT "ff02::1:2" -#define DH6ADDR_ALLSERVER "ff05::1:3" -#define DH6ADDR_ALLRELAY "ff05::1:4" -#define DH6PORT_DOWNSTREAM "546" -#define DH6PORT_UPSTREAM "547" - -/* Protocol constants */ -#define ADV_CLIENT_WAIT 2 /* sec */ -#define DEFAULT_SOLICIT_HOPCOUNT 4 -#define SERVER_MIN_ADV_DELAY 100 /* msec */ -#define SERVER_MAX_ADV_DELAY 1000 /* msec */ -#define REPLY_MSG_TIMEOUT 2 /* sec */ -#define REQUEST_MSG_MIN_RETRANS 10 /* retransmissions */ -#define RECONF_MSG_MIN_RETRANS 10 /* retransmissions */ -#define RECONF_MSG_RETRANS_INTERVAL 12 /* sec */ -#define RECONF_MMSG_MIN_RESP 2 /* sec */ -#define RECONF_MMSG_MAX_RESP 10 /* sec */ -#define RECONF_MULTICAST_REQUEST_WAIT 120 /* sec */ -#define MIN_SOLICIT_DELAY 1 /* sec */ -#define MAX_SOLICIT_DELAY 5 /* sec */ -#define XID_TIMEOUT 600 /* sec */ - -/* DHCP6 base packet format */ -struct dhcp6_solicit { - u_int8_t dh6sol_msgtype; /* DH6_SOLICIT */ - u_int8_t dh6sol_flags; -#define DH6SOL_CLOSE 0x80 -#define DH6SOL_PREFIX 0x40 - /* XXX: solicit-ID is a 9-bit field...ugly! */ -#define DH6SOL_SOLICIT_ID_MASK 0x01ff -#define DH6SOL_SOLICIT_ID_SHIFT 0 -#define DH6SOL_SOLICIT_ID(x) \ - (((x) & DH6SOL_SOLICIT_ID_MASK) >> DH6SOL_SOLICIT_ID_SHIFT) -#define DH6SOL_SOLICIT_PLEN_MASK 0xfe00 -#define DH6SOL_SOLICIT_PLEN_SHIFT 9 -#define DH6SOL_SOLICIT_PLEN(x) \ - (((x) & DH6SOL_SOLICIT_PLEN_MASK) >> DH6SOL_SOLICIT_PLEN_SHIFT) - u_int16_t dh6sol_plen_id; /* prefix-len and solict-ID */ - struct in6_addr dh6sol_cliaddr; /* client's lladdr */ - struct in6_addr dh6sol_relayaddr; /* relay agent's lladdr */ -}; - -struct dhcp6_advert { - u_int8_t dh6adv_msgtype; /* DH6_ADVERT */ - u_int8_t dh6adv_rsv_id; /* reserved and uppermost bit of ID */ - u_int8_t dh6adv_solcit_id; /* lower 8 bits of solicit-ID */ - u_int8_t dh6adv_pref; - struct in6_addr dh6adv_cliaddr; /* client's link-local addr */ - struct in6_addr dh6adv_relayaddr; /* relay agent's (non-ll) addr */ - struct in6_addr dh6adv_serveraddr; /* server's addr */ - /* extensions */ -}; - -struct dhcp6_request { - u_int8_t dh6req_msgtype; /* DH6_REQUEST */ - u_int8_t dh6req_flags; -#define DH6REQ_CLOSE 0x80 -#define DH6REQ_REBOOT 0x40 - u_int16_t dh6req_xid; /* transaction-ID */ - struct in6_addr dh6req_cliaddr; /* client's lladdr */ - struct in6_addr dh6req_relayaddr; /* relay agent's (non-ll) addr */ - struct in6_addr dh6req_serveraddr; /* server's addr */ - /* extensions */ -}; - -struct dhcp6_reply { - u_int8_t dh6rep_msgtype; /* DH6_REPLY */ - u_int8_t dh6rep_flagandstat; -#define DH6REP_RELAYPRESENT 0x80 -#define DH6REP_STATMASK 0x7f - u_int16_t dh6rep_xid; /* transaction-ID */ - struct in6_addr dh6rep_cliaddr; /* client's lladdr */ - /* struct in6_addr dh6rep_relayaddr; optional: relay address */ - /* extensions */ -}; - -/* XXX: followings are based on older drafts */ -struct dhcp6_release { - u_int8_t dh6rel_msgtype; /* DH6_RELEASE */ - u_int8_t dh6rel_flags; -#define DH6REL_DIRECT 0x80 - u_int16_t dh6rel_xid; /* transaction-ID */ - struct in6_addr dh6rel_cliaddr; /* client's lladdr */ - struct in6_addr dh6rel_relayaddr; /* relay agent's (non-ll) addr */ - struct in6_addr dh6rel_reladdr; /* server's addr to be released */ - /* extensions */ -}; - -struct dhcp6_reconfig { - u_int8_t dh6cfg_msgtype; /* DH6_RECONFIG */ - u_int8_t dh6cfg_flags; -#define DH6REP_NOREPLY 0x80 - u_int16_t dh6cfg_xid; /* transaction-ID */ - struct in6_addr dh6cfg_servaddr; /* server's addr */ - /* extensions */ -}; - -union dhcp6 { - u_int8_t dh6_msgtype; - struct dhcp6_solicit dh6_sol; - struct dhcp6_advert dh6_adv; - struct dhcp6_request dh6_req; - struct dhcp6_reply dh6_rep; - struct dhcp6_release dh6_rel; - struct dhcp6_reconfig dh6_cfg; -}; - -/* DHCP6 extension */ -struct dhcp6e_ipaddr { - u_int16_t dh6eip_type; - u_int16_t dh6eip_len; - u_int8_t dh6eip_status; -#define DH6EX_IP_SUCCESS 0 /* request granted, no errors */ -#define DH6EX_IP_SECFAIL 18 /* Security parameters failed */ -#define DH6EX_IP_AAAAFAIL 20 /* AAAA Record Parameter Problem */ -#define DH6EX_IP_PTRFAIL 21 /* PTR Record Parameter Problem */ -#define DH6EX_IP_PARAMFAIL 22 /* Unable to honor required params */ -#define DH6EX_IP_DNSNAMEFAIL 23 /* DNS name string error */ -#define DH6EX_IP_NODYNDNS 24 /* dynDNS Not Implemented */ -#define DH6EX_IP_NOAUTHDNS 25 /* Authoritative DNS Server not found */ -#define DH6EX_IP_DNSFORMFAIL 33 /* DNS format error */ -#define DH6EX_IP_SERVFAIL 34 /* dynDNS unavailable at this time */ -#define DH6EX_IP_NXDOMAIN 35 /* name does not exist */ -#define DH6EX_IP_NOTIMP 36 /* DNS does not support the Opcode */ -#define DH6EX_IP_REFUSED 37 /* DNS refuses specified operation */ -#define DH6EX_IP_YXDOMAIN 38 /* name does not exist */ -#define DH6EX_IP_YXRRSET 39 /* RRset does not exist */ -#define DH6EX_IP_NXRRSET 40 /* RRset does not exist */ -#define DH6EX_IP_NOTAUTH 41 /* non authoritative name server */ -#define DH6EX_IP_NOTZONE 42 /* prerequisite out of zone */ - u_int8_t dh6eip_flags; -#define DH6EX_IP_CLIANTADDR 0x80 /* C: cliant's addr */ -#define DH6EX_IP_LIFETIME 0x40 /* L: preferred/valid lifetime */ -#define DH6EX_IP_FORCEOPTS 0x20 /* Q: options are mandatory */ -#define DH6EX_IP_AAAA 0x10 /* A: DNS dynamic update for AAAA */ -#define DH6EX_IP_PTR 0x08 /* P: DNS dynamic update for PTR*/ - u_int8_t dh6eip_pad; - u_int8_t dh6eip_prefixlen; - /* struct in6_addr: client's address (if C bit = 1) */ - /* u_int: preferred lifetime (if L bit = 1) */ - /* u_int: valid lifetime (if L bit = 1) */ - /* string: DNS name */ -}; - -#endif /*__DHCP6_H_DEFINED*/ diff --git a/contrib/tcpdump/dhcp6opt.h b/contrib/tcpdump/dhcp6opt.h deleted file mode 100644 index fc6534d..0000000 --- a/contrib/tcpdump/dhcp6opt.h +++ /dev/null @@ -1,81 +0,0 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/Attic/dhcp6opt.h,v 1.4 2001/09/17 21:57:51 fenner Exp $ (LBL) */ -/* - * Copyright (C) 1998 and 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. - */ - -/* - * draft-ietf-dhc-v6exts-11 - */ - -#ifndef __DHCP6OPT_H_DEFINED -#define __DHCP6OPT_H_DEFINED - -#define OL6_N -1 -#define OL6_16N -2 -#define OL6_Z -3 - -#define OT6_NONE 0 -#define OT6_V6 1 -#define OT6_STR 2 -#define OT6_NUM 3 - -struct dhcp6_opt { - u_int code; - int len; - const char *name; - int type; -}; - -/* index to parameters */ -#define DH6T_CLIENT_ADV_WAIT 1 /* milliseconds */ -#define DH6T_DEFAULT_SOLICIT_HOPCOUNT 2 /* times */ -#define DH6T_SERVER_MIN_ADV_DELAY 3 /* milliseconds */ -#define DH6T_SERVER_MAX_ADV_DELAY 4 /* milliseconds */ -#define DH6T_REQUEST_MSG_MIN_RETRANS 5 /* retransmissions */ -#define DH6T_REPLY_MSG_TIMEOUT 6 /* milliseconds */ -#define DH6T_REPLY_MSG_RETRANS_INTERVAL 7 /* milliseconds */ -#define DH6T_RECONF_MSG_TIMEOUT 8 /* milliseconds */ -#define DH6T_RECONF_MSG_MIN_RETRANS 9 /* retransmissions */ -#define DH6T_RECONF_MSG_RETRANS_INTERVAL 10 /* milliseconds */ -#define DH6T_RECONF_MMSG_MIN_RESP 11 /* milliseconds */ -#define DH6T_RECONF_MMSG_MAX_RESP 12 /* milliseconds */ -#define DH6T_MIN_SOLICIT_DELAY 13 /* milliseconds */ -#define DH6T_MAX_SOLICIT_DELAY 14 /* milliseconds */ -#define DH6T_XID_TIMEOUT 15 /* milliseconds */ -#define DH6T_RECONF_MULTICAST_REQUEST_WAIT 16 /* milliseconds */ - -#if 0 -extern struct dhcp6_opt *dh6o_pad; -extern struct dhcp6_opt *dh6o_end; -extern int dhcp6_param[]; -extern void dhcp6opttab_init (void); -extern struct dhcp6_opt *dhcp6opttab_byname (char *); -extern struct dhcp6_opt *dhcp6opttab_bycode (u_int); -#endif - -#endif /*__DHCP6OPT_H_DEFINED*/ diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h index 36dc8e2..1555b4d 100644 --- a/contrib/tcpdump/ethertype.h +++ b/contrib/tcpdump/ethertype.h @@ -18,7 +18,9 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * + * * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.24.2.1 2005/07/10 14:51:10 hannes Exp $ (LBL) + * $FreeBSD$ */ /* @@ -124,6 +126,12 @@ #ifndef ETHERTYPE_PPPOES #define ETHERTYPE_PPPOES 0x8864 #endif +#ifndef ETHERTYPE_PPPOED2 +#define ETHERTYPE_PPPOED2 0x3c12 +#endif +#ifndef ETHERTYPE_PPPOES2 +#define ETHERTYPE_PPPOES2 0x3c13 +#endif #ifndef ETHERTYPE_JUMBO #define ETHERTYPE_JUMBO 0x8870 #endif diff --git a/contrib/tcpdump/ieee802_11.h b/contrib/tcpdump/ieee802_11.h index f578a43..7d5c7fc 100644 --- a/contrib/tcpdump/ieee802_11.h +++ b/contrib/tcpdump/ieee802_11.h @@ -1,4 +1,5 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9.4.3 2007/07/22 20:01:16 guy Exp $ (LBL) */ +/* $FreeBSD$ */ +/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.9 2003/07/22 17:36:57 guy Exp $ (LBL) */ /* * Copyright (c) 2001 * Fortress Technologies @@ -30,6 +31,7 @@ #define IEEE802_11_RA_LEN 6 #define IEEE802_11_TA_LEN 6 #define IEEE802_11_SEQ_LEN 2 +#define IEEE802_11_CTL_LEN 2 #define IEEE802_11_IV_LEN 3 #define IEEE802_11_KID_LEN 1 @@ -72,6 +74,7 @@ /* RESERVED 0xF */ +#define CTRL_BAR 0x8 #define CTRL_PS_POLL 0xA #define CTRL_RTS 0xB #define CTRL_CTS 0xC @@ -79,32 +82,14 @@ #define CTRL_CF_END 0xE #define CTRL_END_ACK 0xF -#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) +#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 /* * Bits in the frame control field. @@ -140,12 +125,6 @@ struct mgmt_header_t { #define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) #define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) -typedef enum { - NOT_PRESENT, - PRESENT, - TRUNCATED -} elem_status_t; - struct ssid_t { u_int8_t element_id; u_int8_t length; @@ -155,7 +134,7 @@ struct ssid_t { struct rates_t { u_int8_t element_id; u_int8_t length; - u_int8_t rate[16]; + u_int8_t rate[8]; }; struct challenge_t { @@ -163,7 +142,6 @@ struct challenge_t { u_int8_t length; u_int8_t text[254]; /* 1-253 + 1 for null */ }; - struct fh_t { u_int8_t element_id; u_int8_t length; @@ -224,29 +202,22 @@ struct tim_t { struct mgmt_body_t { - u_int8_t timestamp[IEEE802_11_TSTAMP_LEN]; + u_int8_t timestamp[8]; u_int16_t beacon_interval; u_int16_t listen_interval; u_int16_t status_code; u_int16_t aid; - u_char ap[IEEE802_11_AP_LEN]; + u_char ap[6]; u_int16_t reason_code; u_int16_t auth_alg; u_int16_t auth_trans_seq_num; - elem_status_t challenge_status; struct challenge_t challenge; u_int16_t capability_info; - elem_status_t ssid_status; struct ssid_t ssid; - elem_status_t rates_status; struct rates_t rates; - elem_status_t ds_status; struct ds_t ds; - elem_status_t cf_status; struct cf_t cf; - elem_status_t fh_status; struct fh_t fh; - elem_status_t tim_status; struct tim_t tim; }; @@ -312,6 +283,20 @@ struct ctrl_end_ack_t { #define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN) +struct ctrl_bar_t { + u_int16_t fc; + u_int16_t dur; + u_int8_t ra[6]; + u_int8_t ta[6]; + u_int16_t ctl; + u_int16_t seq; + u_int8_t fcs[4]; +}; + +#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) + #define IV_IV(iv) ((iv) & 0xFFFFFF) #define IV_PAD(iv) (((iv) >> 24) & 0x3F) #define IV_KEYID(iv) (((iv) >> 30) & 0x03) diff --git a/contrib/tcpdump/ieee802_11_radio.h b/contrib/tcpdump/ieee802_11_radio.h index 05c8a89..a2b2f16 100644 --- a/contrib/tcpdump/ieee802_11_radio.h +++ b/contrib/tcpdump/ieee802_11_radio.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ -/* $NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp $ */ -/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.1.2.1 2006/06/13 22:24:45 guy Exp $ */ +/* $NetBSD: ieee80211_radiotap.h,v 1.3 2003/11/16 09:02:42 dyoung Exp $ */ +/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.1 2004/09/23 21:33:10 dyoung Exp $ */ /*- * Copyright (c) 2003, 2004 David Young. All rights reserved. @@ -47,13 +47,17 @@ * function of...") that I cannot set false expectations for lawyerly * readers. */ -#if defined(__KERNEL__) || defined(_KERNEL) +#ifdef _KERNEL #ifndef DLT_IEEE802_11_RADIO #define DLT_IEEE802_11_RADIO 127 /* 802.11 plus WLAN header */ #endif -#endif /* defined(__KERNEL__) || defined(_KERNEL) */ +#endif /* _KERNEL */ -/* The radio capture header precedes the 802.11 header. */ +/* + * The radio capture header precedes the 802.11 header. + * + * Note well: all radiotap fields are little-endian. + */ struct ieee80211_radiotap_header { u_int8_t it_version; /* Version 0. Only increases * for drastic changes, @@ -87,15 +91,19 @@ struct ieee80211_radiotap_header { * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_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 u_int16_t see below * * For frequency-hopping radios, the hop set (first byte) * and pattern (second byte). * - * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s + * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index * - * Tx/Rx data rate + * 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) @@ -119,7 +127,7 @@ struct ieee80211_radiotap_header { * RF noise power at the antenna, decibel difference from an * arbitrary, fixed reference point. * - * IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless + * IEEE80211_RADIOTAP_BARKER_CODE_LOCK u_int16_t unitless * * Quality of Barker code lock. Unitless. Monotonically * nondecreasing with "better" lock strength. Called "Signal @@ -155,9 +163,16 @@ struct ieee80211_radiotap_header { * Unitless indication of the Rx/Tx antenna for this packet. * The first antenna is antenna 0. * - * IEEE80211_RADIOTAP_FCS u_int32_t data + * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap + * u_int16_t MHz + * u_int8_t channel number + * u_int8_t .5 dBm * - * FCS from frame in network byte order. + * 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. */ enum ieee80211_radiotap_type { IEEE80211_RADIOTAP_TSFT = 0, @@ -174,19 +189,27 @@ enum ieee80211_radiotap_type { IEEE80211_RADIOTAP_ANTENNA = 11, IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, IEEE80211_RADIOTAP_DB_ANTNOISE = 13, + IEEE80211_RADIOTAP_XCHANNEL = 14, IEEE80211_RADIOTAP_EXT = 31 }; #ifndef _KERNEL -/* Channel flags. */ -#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ -#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ -#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ -#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ -#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ -#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ -#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ -#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ +/* Channel flags; some are used only with XCHANNEL */ +#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 */ #endif /* !_KERNEL */ /* For IEEE80211_RADIOTAP_FLAGS */ diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h index 49ba87d..d26eb1c 100644 --- a/contrib/tcpdump/interface.h +++ b/contrib/tcpdump/interface.h @@ -18,7 +18,9 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.21 2007/03/28 07:45:46 hannes Exp $ (LBL) + * + * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.18 2005/09/29 07:46:45 hannes Exp $ (LBL) + * $FreeBSD$ */ #ifndef tcpdump_interface_h @@ -108,10 +110,6 @@ extern char *strsep(char **, const char *); #endif #endif -#ifndef MIN -#define MIN(a,b) ((a)<(b)?(a):(b)) -#endif - extern char *program_name; /* used to generate self-identifying messages */ extern int32_t thiszone; /* seconds offset from gmt to local time */ @@ -156,7 +154,7 @@ extern char *read_infile(char *); extern char *copy_argv(char **); extern void safeputchar(int); -extern void safeputs(const char *, int); +extern void safeputs(const char *); extern const char *isonsap_string(const u_char *, register u_int); extern const char *protoid_string(const u_char *); @@ -206,7 +204,6 @@ extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *); extern void fddi_print(const u_char *, u_int, u_int); extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *); -extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *); extern u_int fr_print(register const u_char *, u_int); extern u_int mfr_print(register const u_char *, u_int); extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *); @@ -231,7 +228,6 @@ extern void ns_print(const u_char *, u_int, int); extern void ntp_print(const u_char *, u_int); extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *); extern void ospf_print(const u_char *, u_int, const u_char *); -extern void olsr_print (const u_char *, u_int); extern void pimv1_print(const u_char *, u_int); extern void cisco_autorp_print(const u_char *, u_int); extern void rsvp_print(const u_char *, u_int); diff --git a/contrib/tcpdump/lbl/gnuc.h b/contrib/tcpdump/lbl/gnuc.h deleted file mode 100644 index 1615d43..0000000 --- a/contrib/tcpdump/lbl/gnuc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/lbl/gnuc.h,v 1.3.1.1 1999/10/07 23:47:13 mcr Exp $ (LBL) */ - -/* Define __P() macro, if necessary */ -#ifndef __P -#if __STDC__ -#define __P(protos) protos -#else -#define __P(protos) () -#endif -#endif - -/* inline foo */ -#ifdef __GNUC__ -#define inline __inline -#else -#define inline -#endif - -/* - * Handle new and old "dead" routine prototypes - * - * For example: - * - * __dead void foo(void) __attribute__((volatile)); - * - */ -#ifdef __GNUC__ -#ifndef __dead -#define __dead volatile -#endif -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -#ifndef __attribute__ -#define __attribute__(args) -#endif -#endif -#else -#ifndef __dead -#define __dead -#endif -#ifndef __attribute__ -#define __attribute__(args) -#endif -#endif diff --git a/contrib/tcpdump/missing/cdecl_ext.h b/contrib/tcpdump/missing/cdecl_ext.h deleted file mode 100644 index 9591db2..0000000 --- a/contrib/tcpdump/missing/cdecl_ext.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - */ -#ifndef HAVE_PORTABLE_PROTOTYPE - -#if defined(__STDC__) || defined(__cplusplus) -#define __P(protos) protos /* full-blown ANSI C */ -#else -#define __P(protos) () /* traditional C preprocessor */ -#endif - -#endif /* !HAVE_PORTABLE_PROTOTYPE */ diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h index 3d47c7d..82c8dd3 100644 --- a/contrib/tcpdump/nfs.h +++ b/contrib/tcpdump/nfs.h @@ -36,6 +36,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD$ * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95 */ diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h index b8a82e4..8a337ba 100644 --- a/contrib/tcpdump/nfsfh.h +++ b/contrib/tcpdump/nfsfh.h @@ -39,6 +39,8 @@ * Jeffrey C. Mogul * Digital Equipment Corporation * Western Research Laboratory + * $FreeBSD$ + * $NetBSD: nfsfh.h,v 1.1.1.2 1997/10/03 17:25:13 christos Exp $ */ /* diff --git a/contrib/tcpdump/nfsv2.h b/contrib/tcpdump/nfsv2.h deleted file mode 100644 index b2c0ff9..0000000 --- a/contrib/tcpdump/nfsv2.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 1994, 1995, 1996 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Rick Macklem at The University of Guelph. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)nfsv2.h 7.11 (Berkeley) 9/30/92 - */ - -/* - * nfs definitions as per the version 2 specs - */ - -/* - * Constants as defined in the Sun NFS Version 2 spec. - * "NFS: Network File System Protocol Specification" RFC1094 - */ - -#define NFS_PORT 2049 -#define NFS_PROG 100003 -#define NFS_VER2 2 -#define NFS_MAXDGRAMDATA 8192 -#define NFS_MAXDATA 32768 -#define NFS_MAXPATHLEN 1024 -#define NFS_MAXNAMLEN 255 -#define NFS_FHSIZE 32 -#define NFS_MAXPKTHDR 404 -#define NFS_MAXPACKET (NFS_MAXPKTHDR+NFS_MAXDATA) -#define NFS_MINPACKET 20 -#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */ - -/* Stat numbers for rpc returns */ -#define NFS_OK 0 -#define NFSERR_PERM 1 -#define NFSERR_NOENT 2 -#define NFSERR_IO 5 -#define NFSERR_NXIO 6 -#define NFSERR_ACCES 13 -#define NFSERR_EXIST 17 -#define NFSERR_NODEV 19 -#define NFSERR_NOTDIR 20 -#define NFSERR_ISDIR 21 -#define NFSERR_FBIG 27 -#define NFSERR_NOSPC 28 -#define NFSERR_ROFS 30 -#define NFSERR_NAMETOL 63 -#define NFSERR_NOTEMPTY 66 -#define NFSERR_DQUOT 69 -#define NFSERR_STALE 70 -#define NFSERR_WFLUSH 99 - -/* Sizes in bytes of various nfs rpc components */ -#define NFSX_FH 32 -#define NFSX_UNSIGNED 4 -#define NFSX_NFSFATTR 68 -#define NFSX_NQFATTR 92 -#define NFSX_NFSSATTR 32 -#define NFSX_NQSATTR 44 -#define NFSX_COOKIE 4 -#define NFSX_NFSSTATFS 20 -#define NFSX_NQSTATFS 28 -#define NFSX_FATTR(isnq) ((isnq) ? NFSX_NQFATTR : NFSX_NFSFATTR) -#define NFSX_SATTR(isnq) ((isnq) ? NFSX_NQSATTR : NFSX_NFSSATTR) -#define NFSX_STATFS(isnq) ((isnq) ? NFSX_NQSTATFS : NFSX_NFSSTATFS) - -/* nfs rpc procedure numbers */ -#define NFSPROC_NULL 0 -#define NFSPROC_GETATTR 1 -#define NFSPROC_SETATTR 2 -#define NFSPROC_NOOP 3 -#define NFSPROC_ROOT NFSPROC_NOOP /* Obsolete */ -#define NFSPROC_LOOKUP 4 -#define NFSPROC_READLINK 5 -#define NFSPROC_READ 6 -#define NFSPROC_WRITECACHE NFSPROC_NOOP /* Obsolete */ -#define NFSPROC_WRITE 8 -#define NFSPROC_CREATE 9 -#define NFSPROC_REMOVE 10 -#define NFSPROC_RENAME 11 -#define NFSPROC_LINK 12 -#define NFSPROC_SYMLINK 13 -#define NFSPROC_MKDIR 14 -#define NFSPROC_RMDIR 15 -#define NFSPROC_READDIR 16 -#define NFSPROC_STATFS 17 - -/* NQ nfs numbers */ -#define NQNFSPROC_READDIRLOOK 18 -#define NQNFSPROC_GETLEASE 19 -#define NQNFSPROC_VACATED 20 -#define NQNFSPROC_EVICTED 21 -#define NQNFSPROC_ACCESS 22 - -#define NFS_NPROCS 23 -/* Conversion macros */ -extern int vttoif_tab[]; -#define vtonfs_mode(t,m) \ - txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \ - MAKEIMODE((t), (m))) -#define nfstov_mode(a) (fxdr_unsigned(u_short, (a))&07777) -#define vtonfs_type(a) txdr_unsigned(nfs_type[((int32_t)(a))]) -#define nfstov_type(a) ntov_type[fxdr_unsigned(u_int32_t,(a))&0x7] - -/* File types */ -typedef enum { - NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 -} tcpdump_nfstype; - -/* Structs for common parts of the rpc's */ -struct nfsv2_time { - u_int32_t nfs_sec; - u_int32_t nfs_usec; -}; - -struct nqnfs_time { - u_int32_t nq_sec; - u_int32_t nq_nsec; -}; - -/* - * File attributes and setable attributes. These structures cover both - * NFS version 2 and the NQNFS protocol. Note that the union is only - * used to that one pointer can refer to both variants. These structures - * go out on the wire and must be densely packed, so no quad data types - * are used. (all fields are int32_t or u_int32_t's or structures of same) - * NB: You can't do sizeof(struct nfsv2_fattr), you must use the - * NFSX_FATTR(isnq) macro. - */ -struct nfsv2_fattr { - u_int32_t fa_type; - u_int32_t fa_mode; - u_int32_t fa_nlink; - u_int32_t fa_uid; - u_int32_t fa_gid; - union { - struct { - u_int32_t nfsfa_size; - u_int32_t nfsfa_blocksize; - u_int32_t nfsfa_rdev; - u_int32_t nfsfa_blocks; - u_int32_t nfsfa_fsid; - u_int32_t nfsfa_fileid; - struct nfsv2_time nfsfa_atime; - struct nfsv2_time nfsfa_mtime; - struct nfsv2_time nfsfa_ctime; - } fa_nfsv2; - struct { - struct { - u_int32_t nqfa_qsize[2]; - } nqfa_size; - u_int32_t nqfa_blocksize; - u_int32_t nqfa_rdev; - struct { - u_int32_t nqfa_qbytes[2]; - } nqfa_bytes; - u_int32_t nqfa_fsid; - u_int32_t nqfa_fileid; - struct nqnfs_time nqfa_atime; - struct nqnfs_time nqfa_mtime; - struct nqnfs_time nqfa_ctime; - u_int32_t nqfa_flags; - u_int32_t nqfa_gen; - struct { - u_int32_t nqfa_qfilerev[2]; - } nqfa_filerev; - } fa_nqnfs; - } fa_un; -}; - -/* and some ugly defines for accessing union components */ -#define fa_nfssize fa_un.fa_nfsv2.nfsfa_size -#define fa_nfsblocksize fa_un.fa_nfsv2.nfsfa_blocksize -#define fa_nfsrdev fa_un.fa_nfsv2.nfsfa_rdev -#define fa_nfsblocks fa_un.fa_nfsv2.nfsfa_blocks -#define fa_nfsfsid fa_un.fa_nfsv2.nfsfa_fsid -#define fa_nfsfileid fa_un.fa_nfsv2.nfsfa_fileid -#define fa_nfsatime fa_un.fa_nfsv2.nfsfa_atime -#define fa_nfsmtime fa_un.fa_nfsv2.nfsfa_mtime -#define fa_nfsctime fa_un.fa_nfsv2.nfsfa_ctime -#define fa_nqsize fa_un.fa_nqnfs.nqfa_size -#define fa_nqblocksize fa_un.fa_nqnfs.nqfa_blocksize -#define fa_nqrdev fa_un.fa_nqnfs.nqfa_rdev -#define fa_nqbytes fa_un.fa_nqnfs.nqfa_bytes -#define fa_nqfsid fa_un.fa_nqnfs.nqfa_fsid -#define fa_nqfileid fa_un.fa_nqnfs.nqfa_fileid -#define fa_nqatime fa_un.fa_nqnfs.nqfa_atime -#define fa_nqmtime fa_un.fa_nqnfs.nqfa_mtime -#define fa_nqctime fa_un.fa_nqnfs.nqfa_ctime -#define fa_nqflags fa_un.fa_nqnfs.nqfa_flags -#define fa_nqgen fa_un.fa_nqnfs.nqfa_gen -#define fa_nqfilerev fa_un.fa_nqnfs.nqfa_filerev - -struct nfsv2_sattr { - u_int32_t sa_mode; - u_int32_t sa_uid; - u_int32_t sa_gid; - union { - struct { - u_int32_t nfssa_size; - struct nfsv2_time nfssa_atime; - struct nfsv2_time nfssa_mtime; - } sa_nfsv2; - struct { - struct { - u_int32_t nqsa_qsize[2]; - } nqsa_size; - struct nqnfs_time nqsa_atime; - struct nqnfs_time nqsa_mtime; - u_int32_t nqsa_flags; - u_int32_t nqsa_rdev; - } sa_nqnfs; - } sa_un; -}; - -/* and some ugly defines for accessing the unions */ -#define sa_nfssize sa_un.sa_nfsv2.nfssa_size -#define sa_nfsatime sa_un.sa_nfsv2.nfssa_atime -#define sa_nfsmtime sa_un.sa_nfsv2.nfssa_mtime -#define sa_nqsize sa_un.sa_nqnfs.nqsa_size -#define sa_nqatime sa_un.sa_nqnfs.nqsa_atime -#define sa_nqmtime sa_un.sa_nqnfs.nqsa_mtime -#define sa_nqflags sa_un.sa_nqnfs.nqsa_flags -#define sa_nqrdev sa_un.sa_nqnfs.nqsa_rdev - -struct nfsv2_statfs { - u_int32_t sf_tsize; - u_int32_t sf_bsize; - u_int32_t sf_blocks; - u_int32_t sf_bfree; - u_int32_t sf_bavail; - u_int32_t sf_files; /* Nqnfs only */ - u_int32_t sf_ffree; /* ditto */ -}; diff --git a/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c index ef1e0ba..2e3da02 100644 --- a/contrib/tcpdump/parsenfsfh.c +++ b/contrib/tcpdump/parsenfsfh.c @@ -38,11 +38,13 @@ * Jeffrey C. Mogul * Digital Equipment Corporation * Western Research Laboratory + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28.2.1 2007/06/15 19:15:04 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.28 2004/03/25 03:30:55 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -79,7 +81,6 @@ static const char rcsid[] _U_ = #define FHT_SUNOS5 9 #define FHT_AIX32 10 #define FHT_HPUX9 11 -#define FHT_BSD44 12 #ifdef ultrix /* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */ @@ -147,10 +148,6 @@ int ourself; /* true if file handle was generated on this host */ #if defined(__osf__) fhtype = FHT_DECOSF; #endif -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \ - || defined(__OpenBSD__) - fhtype = FHT_BSD44; -#endif } /* * This is basically a big decision tree @@ -201,11 +198,8 @@ int ourself; /* true if file handle was generated on this host */ * could be Ultrix, IRIX5, AIX, or SUNOS5 * might be HP-UX (depends on their values for minor devs) */ - if ((fhp[6] == 0) && (fhp[7] == 0)) { - fhtype = FHT_BSD44; - } /*XXX we probably only need to test of these two bytes */ - else if ((fhp[21] == 0) && (fhp[23] == 0)) { + if ((fhp[21] == 0) && (fhp[23] == 0)) { fhtype = FHT_ULTRIX; } else { @@ -271,18 +265,6 @@ int ourself; /* true if file handle was generated on this host */ *osnamep = "Auspex"; break; - case FHT_BSD44: - fsidp->Fsid_dev.Minor = fhp[0]; - fsidp->Fsid_dev.Major = fhp[1]; - fsidp->fsid_code = 0; - - temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]); - *inop = temp; - - if (osnamep) - *osnamep = "BSD 4.4"; - break; - case FHT_DECOSF: fsidp->fsid_code = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]); /* XXX could ignore 3 high-order bytes */ @@ -321,16 +303,10 @@ int ourself; /* true if file handle was generated on this host */ *osnamep = "IRIX5"; break; -#ifdef notdef case FHT_SUNOS3: - /* - * XXX - none of the heuristics above return this. - * Are there any SunOS 3.x systems around to care about? - */ if (osnamep) *osnamep = "SUNOS3"; break; -#endif case FHT_SUNOS4: fsidp->Fsid_dev.Minor = fhp[3]; diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h index 71621ca..9c4b473 100644 --- a/contrib/tcpdump/ppp.h +++ b/contrib/tcpdump/ppp.h @@ -14,6 +14,8 @@ * 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. + * + * $FreeBSD$ */ #define PPP_HDRLEN 4 /* length of PPP header */ diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c index 21e316d..4ce21ec 100644 --- a/contrib/tcpdump/print-802_11.c +++ b/contrib/tcpdump/print-802_11.c @@ -1,3 +1,4 @@ +/* $FreeBSD$ */ /* * Copyright (c) 2001 * Fortress Technologies, Inc. All rights reserved. @@ -22,7 +23,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.15 2007/07/22 23:14:14 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.5 2005/07/30 21:37:50 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -46,54 +47,41 @@ static const char rcsid[] _U_ = #include "ieee802_11.h" #include "ieee802_11_radio.h" -#define PRINT_SSID(p) \ - switch (p.ssid_status) { \ - case TRUNCATED: \ - return 0; \ - case PRESENT: \ - printf(" ("); \ - fn_print(p.ssid.ssid, NULL); \ - printf(")"); \ - break; \ - case NOT_PRESENT: \ - break; \ - } - #define PRINT_RATE(_sep, _r, _suf) \ printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf) #define PRINT_RATES(p) \ - switch (p.rates_status) { \ - case TRUNCATED: \ - return 0; \ - case PRESENT: \ - do { \ - 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) \ - printf(" Mbit]"); \ - } while (0); \ - break; \ - case NOT_PRESENT: \ - break; \ - } - -#define PRINT_DS_CHANNEL(p) \ - switch (p.ds_status) { \ - case TRUNCATED: \ - return 0; \ - case PRESENT: \ - printf(" CH: %u", p.ds.channel); \ - break; \ - case NOT_PRESENT: \ - break; \ +do { \ + 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 = " "; \ } \ - printf("%s", \ - CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" ); + if (p.rates.length != 0) \ + printf(" Mbit]"); \ +} while (0) + +static const int ieee80211_htrates[16] = { + 13, /* IFM_IEEE80211_MCS0 */ + 26, /* IFM_IEEE80211_MCS1 */ + 39, /* IFM_IEEE80211_MCS2 */ + 52, /* IFM_IEEE80211_MCS3 */ + 78, /* IFM_IEEE80211_MCS4 */ + 104, /* IFM_IEEE80211_MCS5 */ + 117, /* IFM_IEEE80211_MCS6 */ + 130, /* IFM_IEEE80211_MCS7 */ + 26, /* IFM_IEEE80211_MCS8 */ + 52, /* IFM_IEEE80211_MCS9 */ + 78, /* IFM_IEEE80211_MCS10 */ + 104, /* IFM_IEEE80211_MCS11 */ + 156, /* IFM_IEEE80211_MCS12 */ + 208, /* IFM_IEEE80211_MCS13 */ + 234, /* IFM_IEEE80211_MCS14 */ + 260, /* IFM_IEEE80211_MCS15 */ +}; +#define PRINT_HT_RATE(_sep, _r, _suf) \ + printf("%s%.1f%s", _sep, (.5 * ieee80211_htrates[(_r) & 0xf]), _suf) static const char *auth_alg_text[]={"Open System","Shared Key","EAP"}; #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0]) @@ -152,141 +140,94 @@ wep_print(const u_char *p) return 1; } -static void +static int parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset) { - /* - * We haven't seen any elements yet. - */ - pbody->challenge_status = NOT_PRESENT; - pbody->ssid_status = NOT_PRESENT; - pbody->rates_status = NOT_PRESENT; - pbody->ds_status = NOT_PRESENT; - pbody->cf_status = NOT_PRESENT; - pbody->tim_status = NOT_PRESENT; - for (;;) { if (!TTEST2(*(p + offset), 1)) - return; + return 1; switch (*(p + offset)) { case E_SSID: - /* Present, possibly truncated */ - pbody->ssid_status = TRUNCATED; if (!TTEST2(*(p + offset), 2)) - return; + return 0; memcpy(&pbody->ssid, p + offset, 2); offset += 2; - if (pbody->ssid.length != 0) { - if (pbody->ssid.length > - sizeof(pbody->ssid.ssid) - 1) - return; - if (!TTEST2(*(p + offset), pbody->ssid.length)) - return; - memcpy(&pbody->ssid.ssid, p + offset, - pbody->ssid.length); - offset += pbody->ssid.length; - } + if (pbody->ssid.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->ssid.length)) + return 0; + memcpy(&pbody->ssid.ssid, p + offset, + pbody->ssid.length); + offset += pbody->ssid.length; pbody->ssid.ssid[pbody->ssid.length] = '\0'; - /* Present and not truncated */ - pbody->ssid_status = PRESENT; break; case E_CHALLENGE: - /* Present, possibly truncated */ - pbody->challenge_status = TRUNCATED; if (!TTEST2(*(p + offset), 2)) - return; + return 0; memcpy(&pbody->challenge, p + offset, 2); offset += 2; - if (pbody->challenge.length != 0) { - if (pbody->challenge.length > - sizeof(pbody->challenge.text) - 1) - return; - if (!TTEST2(*(p + offset), pbody->challenge.length)) - return; - memcpy(&pbody->challenge.text, p + offset, - pbody->challenge.length); - offset += pbody->challenge.length; - } + if (pbody->challenge.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->challenge.length)) + return 0; + memcpy(&pbody->challenge.text, p + offset, + pbody->challenge.length); + offset += pbody->challenge.length; pbody->challenge.text[pbody->challenge.length] = '\0'; - /* Present and not truncated */ - pbody->challenge_status = PRESENT; break; case E_RATES: - /* Present, possibly truncated */ - pbody->rates_status = TRUNCATED; if (!TTEST2(*(p + offset), 2)) - return; + return 0; memcpy(&(pbody->rates), p + offset, 2); offset += 2; - if (pbody->rates.length != 0) { - if (pbody->rates.length > sizeof pbody->rates.rate) - return; - if (!TTEST2(*(p + offset), pbody->rates.length)) - return; - memcpy(&pbody->rates.rate, p + offset, - pbody->rates.length); - offset += pbody->rates.length; - } - /* Present and not truncated */ - pbody->rates_status = PRESENT; + if (pbody->rates.length <= 0) + break; + if (!TTEST2(*(p + offset), pbody->rates.length)) + return 0; + memcpy(&pbody->rates.rate, p + offset, + pbody->rates.length); + offset += pbody->rates.length; break; case E_DS: - /* Present, possibly truncated */ - pbody->ds_status = TRUNCATED; if (!TTEST2(*(p + offset), 3)) - return; + return 0; memcpy(&pbody->ds, p + offset, 3); offset += 3; - /* Present and not truncated */ - pbody->ds_status = PRESENT; break; case E_CF: - /* Present, possibly truncated */ - pbody->cf_status = TRUNCATED; if (!TTEST2(*(p + offset), 8)) - return; + return 0; memcpy(&pbody->cf, p + offset, 8); offset += 8; - /* Present and not truncated */ - pbody->cf_status = PRESENT; break; case E_TIM: - /* Present, possibly truncated */ - pbody->tim_status = TRUNCATED; if (!TTEST2(*(p + offset), 2)) - return; + return 0; memcpy(&pbody->tim, p + offset, 2); offset += 2; if (!TTEST2(*(p + offset), 3)) - return; + return 0; memcpy(&pbody->tim.count, p + offset, 3); offset += 3; if (pbody->tim.length <= 3) break; - if (pbody->tim.length - 3 > sizeof pbody->tim.bitmap) - return; if (!TTEST2(*(p + offset), pbody->tim.length - 3)) - return; + return 0; memcpy(pbody->tim.bitmap, p + (pbody->tim.length - 3), (pbody->tim.length - 3)); offset += pbody->tim.length - 3; - /* Present and not truncated */ - pbody->tim_status = PRESENT; break; default: #if 0 printf("(1) unhandled element_id (%d) ", *(p + offset) ); #endif - if (!TTEST2(*(p + offset), 2)) - return; - if (!TTEST2(*(p + offset + 2), *(p + offset + 1))) - return; offset += *(p + offset + 1) + 2; break; } } + return 1; } /********************************************************************************* @@ -304,20 +245,24 @@ handle_beacon(const u_char *p) if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN)) return 0; - memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); + memcpy(&pbody.timestamp, p, 8); offset += IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; - PRINT_SSID(pbody); + printf(" ("); + fn_print(pbody.ssid.ssid, NULL); + printf(")"); PRINT_RATES(pbody); - printf(" %s", - CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"); - PRINT_DS_CHANNEL(pbody); + printf(" %s CH: %u%s", + CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS", + pbody.ds.channel, + CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" ); return 1; } @@ -337,9 +282,12 @@ handle_assoc_request(const u_char *p) pbody.listen_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_LISTENINT_LEN; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; - PRINT_SSID(pbody); + printf(" ("); + fn_print(pbody.ssid.ssid, NULL); + printf(")"); PRINT_RATES(pbody); return 1; } @@ -362,7 +310,8 @@ handle_assoc_response(const u_char *p) pbody.aid = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_AID_LEN; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 , CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "", @@ -391,10 +340,12 @@ handle_reassoc_request(const u_char *p) memcpy(&pbody.ap, p+offset, IEEE802_11_AP_LEN); offset += IEEE802_11_AP_LEN; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; - PRINT_SSID(pbody); - printf(" AP : %s", etheraddr_string( pbody.ap )); + printf(" ("); + fn_print(pbody.ssid.ssid, NULL); + printf(") AP : %s", etheraddr_string( pbody.ap )); return 1; } @@ -414,9 +365,12 @@ handle_probe_request(const u_char *p) memset(&pbody, 0, sizeof(pbody)); - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; - PRINT_SSID(pbody); + printf(" ("); + fn_print(pbody.ssid.ssid, NULL); + printf(")"); PRINT_RATES(pbody); return 1; @@ -441,11 +395,15 @@ handle_probe_response(const u_char *p) pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; - PRINT_SSID(pbody); + printf(" ("); + fn_print(pbody.ssid.ssid, NULL); + printf(") "); PRINT_RATES(pbody); - PRINT_DS_CHANNEL(pbody); + printf(" CH: %u%s", pbody.ds.channel, + CAPABILITY_PRIVACY(pbody.capability_info) ? ", PRIVACY" : "" ); return 1; } @@ -493,7 +451,8 @@ handle_auth(const u_char *p) pbody.status_code = EXTRACT_LE_16BITS(p + offset); offset += 2; - parse_elements(&pbody, p, offset); + if (!parse_elements(&pbody, p, offset)) + return 0; if ((pbody.auth_alg == 1) && ((pbody.auth_trans_seq_num == 2) || @@ -616,6 +575,17 @@ static int ctrl_body_print(u_int16_t fc, const u_char *p) { switch (FC_SUBTYPE(fc)) { + case CTRL_BAR: + printf("BAR"); + if (!TTEST2(*p, CTRL_BAR_HDRLEN)) + return 0; + if (!eflag) + printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", + etheraddr_string(((const struct ctrl_bar_t *)p)->ra), + etheraddr_string(((const struct ctrl_bar_t *)p)->ta), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); + break; case CTRL_PS_POLL: printf("Power Save-Poll"); if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN)) @@ -687,23 +657,22 @@ static void data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, const u_int8_t **dstp) { - u_int subtype = FC_SUBTYPE(fc); - - if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) || - DATA_FRAME_IS_QOS(subtype)) { - printf("CF "); - if (DATA_FRAME_IS_CF_ACK(subtype)) { - if (DATA_FRAME_IS_CF_POLL(subtype)) - printf("Ack/Poll"); - else - printf("Ack"); - } else { - if (DATA_FRAME_IS_CF_POLL(subtype)) - printf("Poll"); - } - if (DATA_FRAME_IS_QOS(subtype)) - printf("+QoS"); - printf(" "); + switch (FC_SUBTYPE(fc)) { + case DATA_DATA: + case DATA_NODATA: + break; + case DATA_DATA_CF_ACK: + case DATA_NODATA_CF_ACK: + printf("CF Ack "); + break; + case DATA_DATA_CF_POLL: + case DATA_NODATA_CF_POLL: + printf("CF Poll "); + break; + case DATA_DATA_CF_ACK_POLL: + case DATA_NODATA_CF_ACK_POLL: + printf("CF Ack/Poll "); + break; } #define ADDR1 (p + 4) @@ -789,6 +758,13 @@ ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, return; switch (FC_SUBTYPE(fc)) { + case CTRL_BAR: + printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", + etheraddr_string(((const struct ctrl_bar_t *)p)->ra), + etheraddr_string(((const struct ctrl_bar_t *)p)->ta), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), + EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); + break; case CTRL_PS_POLL: printf("BSSID:%s TA:%s ", etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid), @@ -826,13 +802,13 @@ ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, static int extract_header_length(u_int16_t fc) { - int len; - switch (FC_TYPE(fc)) { case T_MGMT: return MGMT_HDRLEN; case T_CTRL: switch (FC_SUBTYPE(fc)) { + case CTRL_BAR: + return CTRL_BAR_HDRLEN; case CTRL_PS_POLL: return CTRL_PS_POLL_HDRLEN; case CTRL_RTS: @@ -849,10 +825,7 @@ extract_header_length(u_int16_t 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; + return (FC_TO_DS(fc) && FC_FROM_DS(fc)) ? 30 : 24; default: printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); return 0; @@ -906,12 +879,8 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp, } } -#ifndef roundup2 -#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ -#endif - static u_int -ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad) +ieee802_11_print(const u_char *p, u_int length, u_int caplen) { u_int16_t fc; u_int hdrlen; @@ -925,8 +894,6 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad) fc = EXTRACT_LE_16BITS(p); hdrlen = extract_header_length(fc); - if (pad) - hdrlen = roundup2(hdrlen, 4); if (caplen < hdrlen) { printf("[|802.11]"); @@ -957,8 +924,6 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad) } 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_WEP(fc)) { if (!wep_print(p)) { @@ -999,11 +964,69 @@ ieee802_11_print(const u_char *p, u_int length, u_int caplen, int pad) u_int ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p) { - return ieee802_11_print(p, h->len, h->caplen, 0); + return ieee802_11_print(p, h->len, h->caplen); +} + +#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(int freq, int flags) +{ + printf("%u MHz", freq); + if (IS_CHAN_FHSS(flags)) + printf(" FHSS"); + if (IS_CHAN_A(flags)) { + if (flags & IEEE80211_CHAN_HALF) + printf(" 11a/10Mhz"); + else if (flags & IEEE80211_CHAN_QUARTER) + printf(" 11a/5Mhz"); + else + printf(" 11a"); + } + if (IS_CHAN_ANYG(flags)) { + if (flags & IEEE80211_CHAN_HALF) + printf(" 11g/10Mhz"); + else if (flags & IEEE80211_CHAN_QUARTER) + printf(" 11g/5Mhz"); + else + printf(" 11g"); + } else if (IS_CHAN_B(flags)) + printf(" 11b"); + if (flags & IEEE80211_CHAN_TURBO) + printf(" Turbo"); + if (flags & IEEE80211_CHAN_HT20) + printf(" ht/20"); + else if (flags & IEEE80211_CHAN_HT40D) + printf(" ht/40-"); + else if (flags & IEEE80211_CHAN_HT40U) + printf(" ht/40+"); + printf(" "); } static int -print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) +print_radiotap_field(struct cpack_state *s, u_int32_t bit) { union { int8_t i8; @@ -1012,15 +1035,11 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) u_int16_t u16; u_int32_t u32; u_int64_t u64; - } u, u2; + } u, u2, u3, u4; int rc; switch (bit) { case IEEE80211_RADIOTAP_FLAGS: - rc = cpack_uint8(s, &u.u8); - if (u.u8 & IEEE80211_RADIOTAP_F_DATAPAD) - *pad = 1; - break; case IEEE80211_RADIOTAP_RATE: case IEEE80211_RADIOTAP_DB_ANTSIGNAL: case IEEE80211_RADIOTAP_DB_ANTNOISE: @@ -1051,6 +1070,18 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) case IEEE80211_RADIOTAP_TSFT: rc = cpack_uint64(s, &u.u64); break; + case IEEE80211_RADIOTAP_XCHANNEL: + rc = cpack_uint32(s, &u.u32); + if (rc != 0) + break; + rc = cpack_uint16(s, &u2.u16); + if (rc != 0) + break; + rc = cpack_uint8(s, &u3.u8); + if (rc != 0) + break; + rc = cpack_uint8(s, &u4.u8); + break; default: /* this bit indicates a field whose * size we do not know, so we cannot @@ -1067,15 +1098,16 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) switch (bit) { case IEEE80211_RADIOTAP_CHANNEL: - printf("%u MHz ", u.u16); - if (u2.u16 != 0) - printf("(0x%04x) ", u2.u16); + print_chaninfo(u.u16, u2.u16); break; case IEEE80211_RADIOTAP_FHSS: printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff); break; case IEEE80211_RADIOTAP_RATE: - PRINT_RATE("", u.u8, " Mb/s "); + if (u.u8 & 0x80) + PRINT_RATE("", u.u8, " Mb/s "); + else + PRINT_HT_RATE("", u.u8, " Mb/s "); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: printf("%ddB signal ", u.i8); @@ -1110,8 +1142,14 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) printf("wep "); if (u.u8 & IEEE80211_RADIOTAP_F_FRAG) printf("fragmented "); +#if 0 + if (u.u8 & IEEE80211_RADIOTAP_F_FCS) + printf("fcs "); + if (u.u8 & IEEE80211_RADIOTAP_F_DATAPAD) + printf("datapad "); +#endif if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS) - printf("bad-fcs "); + printf("badfcs "); break; case IEEE80211_RADIOTAP_ANTENNA: printf("antenna %d ", u.u8); @@ -1119,6 +1157,9 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, int *pad) case IEEE80211_RADIOTAP_TSFT: printf("%" PRIu64 "us tsft ", u.u64); break; + case IEEE80211_RADIOTAP_XCHANNEL: + print_chaninfo(u2.u16, u.u32); + break; } return 0; } @@ -1143,7 +1184,6 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) int bit0; const u_char *iter; u_int len; - int pad; if (caplen < sizeof(*hdr)) { printf("[|802.11]"); @@ -1177,8 +1217,6 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) return caplen; } - /* Assume no Atheros padding between 802.11 header and body */ - pad = 0; for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp; presentp++, bit0 += 32) { for (present = EXTRACT_LE_32BITS(presentp); present; @@ -1190,12 +1228,12 @@ ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen) bit = (enum ieee80211_radiotap_type) (bit0 + BITNO_32(present ^ next_present)); - if (print_radiotap_field(&cpacker, bit, &pad) != 0) + if (print_radiotap_field(&cpacker, bit) != 0) goto out; } } out: - return len + ieee802_11_print(p + len, length - len, caplen - len, pad); + return len + ieee802_11_print(p + len, length - len, caplen - len); #undef BITNO_32 #undef BITNO_16 #undef BITNO_8 @@ -1226,7 +1264,7 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen) } return caphdr_len + ieee802_11_print(p + caphdr_len, - length - caphdr_len, caplen - caphdr_len, 0); + length - caphdr_len, caplen - caphdr_len); } #define PRISM_HDR_LEN 144 @@ -1265,7 +1303,7 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p) } return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN, - length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0); + length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN); } /* diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c index 68e9dc6..3dc2894 100644 --- a/contrib/tcpdump/print-arp.c +++ b/contrib/tcpdump/print-arp.c @@ -17,6 +17,8 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c index f1f45a3..1d575a6 100644 --- a/contrib/tcpdump/print-atalk.c +++ b/contrib/tcpdump/print-atalk.c @@ -19,6 +19,8 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print AppleTalk packets. + * + * $FreeBSD$ */ #ifndef lint @@ -99,6 +101,7 @@ llap_print(register const u_char *bp, u_int length) u_short snet; u_int hdrlen; +#if 0 /* * Our packet is on a 4-byte boundary, as we're either called * directly from a top-level link-layer printer (ltalk_if_print) @@ -110,6 +113,12 @@ llap_print(register const u_char *bp, u_int length) lp = (const struct LAP *)bp; bp += sizeof(*lp); length -= sizeof(*lp); +#else + { + static struct LAP lp_ = {0, 0, lapDDP}; + lp = &lp_; + } +#endif hdrlen = sizeof(*lp); switch (lp->type) { @@ -213,7 +222,7 @@ aarp_print(register const u_char *bp, u_int length) case 2: /* response */ (void)printf("reply %s is-at %s", - AT(pdaddr), etheraddr_string(ap->hdaddr)); + AT(psaddr), etheraddr_string(ap->hsaddr)); return; case 3: /* probe (oy!) */ @@ -567,10 +576,10 @@ ataddr_string(u_short atnet, u_char athost) else continue; - for (tp = &hnametable[i3 & (HASHNAMESIZE-1)]; + for (tp = &hnametable[i2 & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt) ; - tp->addr = i3; + tp->addr = i2; tp->nxt = newhnamemem(); tp->name = strdup(nambuf); } diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c index d664d6e..1fdae6e 100644 --- a/contrib/tcpdump/print-atm.c +++ b/contrib/tcpdump/print-atm.c @@ -17,10 +17,12 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.6 2006/01/25 13:27:24 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.3 2005/07/07 01:24:34 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -43,12 +45,6 @@ static const char rcsid[] _U_ = #include "ether.h" -struct tok oam_f_values[] = { - { OAMF4SC, "OAM F4 (segment)" }, - { OAMF4EC, "OAM F4 (end)" }, - { 0, NULL } -}; - struct tok oam_celltype_values[] = { { 0x1, "Fault Management" }, { 0x2, "Performance Management" }, @@ -141,15 +137,6 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p) printf("[|atm]"); return (caplen); } - - /* Cisco Style NLPID ? */ - if (*p == LLC_UI) { - if (eflag) - printf("CNLPID "); - isoclns_print(p+1, length-1, caplen-1); - return hdrlen; - } - /* * Extract the presumed LLC header into a variable, for quick * testing. @@ -304,10 +291,9 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length, int oam_print (const u_char *p, u_int length, u_int hec) { - u_int32_t cell_header; - u_int16_t cell_type, func_type,vpi,vci,payload,clp; + u_int16_t cell_header, cell_type, func_type,vpi,vci,payload,clp; - cell_header = EXTRACT_32BITS(p+hec); + cell_header = EXTRACT_32BITS(p); cell_type = ((*(p+4+hec))>>4) & 0x0f; func_type = *(p+4+hec) & 0x0f; @@ -316,9 +302,20 @@ oam_print (const u_char *p, u_int length, u_int hec) { payload = (cell_header>>1)&0x7; clp = cell_header&0x1; - printf("%s, vpi %u, vci %u, payload %u, clp %u, ", - tok2str(oam_f_values, "OAM F5", vci), - vpi, vci, payload, clp); + switch (vci) { + case OAMF4SC: + printf("OAM F4 (segment), "); + break; + case OAMF4EC: + printf("OAM F4 (end), "); + break; + default: + printf("OAM F5, "); + break; + } + + if (eflag) + printf("vpi %u, vci %u, payload %u, clp %u, ",vpi,vci,payload,clp); printf("cell-type %s (%u)", tok2str(oam_celltype_values, "unknown", cell_type), diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c index e2086e4..844aecc 100644 --- a/contrib/tcpdump/print-bootp.c +++ b/contrib/tcpdump/print-bootp.c @@ -19,10 +19,12 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print bootp packets. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.9 2007/08/21 22:02:08 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.2 2005/05/06 04:19:39 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -42,7 +44,6 @@ static const char rcsid[] _U_ = static void rfc1048_print(const u_char *); static void cmu_print(const u_char *); -static char *client_fqdn_flags(u_int flags); static char tstr[] = " [|bootp]"; @@ -78,7 +79,7 @@ bootp_print(register const u_char *cp, u_int length) printf(" from %s", etheraddr_string(bp->bp_chaddr)); } - printf(", length %u", length); + printf(", length: %u", length); if (!vflag) return; @@ -87,49 +88,49 @@ bootp_print(register const u_char *cp, u_int length) /* The usual hardware address type is 1 (10Mb Ethernet) */ if (bp->bp_htype != 1) - printf(", htype %d", bp->bp_htype); + printf(", htype-#%d", bp->bp_htype); /* The usual length for 10Mb Ethernet address is 6 bytes */ if (bp->bp_htype != 1 || bp->bp_hlen != 6) - printf(", hlen %d", bp->bp_hlen); + printf(", hlen:%d", bp->bp_hlen); /* Only print interesting fields */ if (bp->bp_hops) - printf(", hops %d", bp->bp_hops); + printf(", hops:%d", bp->bp_hops); if (bp->bp_xid) - printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)); + printf(", xid:0x%x", EXTRACT_32BITS(&bp->bp_xid)); if (bp->bp_secs) - printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs)); + printf(", secs:%d", EXTRACT_16BITS(&bp->bp_secs)); - printf(", Flags [%s]", - bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); - if (vflag > 1) - printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); + printf(", flags: [%s]", + bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); + if (vflag>1) + printf( " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); /* Client's ip address */ TCHECK(bp->bp_ciaddr); if (bp->bp_ciaddr.s_addr) - printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr)); + printf("\n\t Client IP: %s", ipaddr_string(&bp->bp_ciaddr)); /* 'your' ip address (bootp client) */ TCHECK(bp->bp_yiaddr); if (bp->bp_yiaddr.s_addr) - printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr)); + printf("\n\t Your IP: %s", ipaddr_string(&bp->bp_yiaddr)); /* Server's ip address */ TCHECK(bp->bp_siaddr); if (bp->bp_siaddr.s_addr) - printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr)); + printf("\n\t Server IP: %s", ipaddr_string(&bp->bp_siaddr)); /* Gateway's ip address */ TCHECK(bp->bp_giaddr); if (bp->bp_giaddr.s_addr) - printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr)); + printf("\n\t Gateway IP: %s", ipaddr_string(&bp->bp_giaddr)); /* Client's Ethernet address */ if (bp->bp_htype == 1 && bp->bp_hlen == 6) { TCHECK2(bp->bp_chaddr[0], 6); - printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr)); + printf("\n\t Client Ethernet Address: %s", etheraddr_string(bp->bp_chaddr)); } TCHECK2(bp->bp_sname[0], 1); /* check first char only */ @@ -190,23 +191,23 @@ trunc: static 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_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */ + { TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */ + { TAG_GATEWAY, "iDG" }, /* default gateway */ + { TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */ + { TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */ + { TAG_DOMAIN_SERVER, "iNS" }, /* 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_LPR_SERVER, "iLPR" }, /* lpr server (RFC1179) */ { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ - { TAG_HOSTNAME, "aHostname" }, /* ascii hostname */ + { TAG_HOSTNAME, "aHN" }, /* ascii hostname */ { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ { TAG_END, " END" }, /* RFC1497 tags */ { TAG_DUMPPATH, "aDP" }, - { TAG_DOMAINNAME, "aDomain-Name" }, + { TAG_DOMAINNAME, "aDN" }, { TAG_SWAP_SERVER, "iSS" }, { TAG_ROOTPATH, "aRP" }, { TAG_EXTPATH, "aEP" }, @@ -216,16 +217,16 @@ static struct tok tag2str[] = { { TAG_PFILTERS, "pPF" }, { TAG_REASS_SIZE, "sRSZ" }, { TAG_DEF_TTL, "bTTL" }, - { TAG_MTU_TIMEOUT, "lMTU-Timeout" }, - { TAG_MTU_TABLE, "sMTU-Table" }, + { TAG_MTU_TIMEOUT, "lMA" }, + { TAG_MTU_TABLE, "sMT" }, { 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_DO_RDISC, "BRD" }, { TAG_RTR_SOL_ADDR, "iRSA" }, - { TAG_STATIC_ROUTE, "pStatic-Route" }, + { TAG_STATIC_ROUTE, "pSR" }, { TAG_USE_TRAILERS, "BUT" }, { TAG_ARP_TIMEOUT, "lAT" }, { TAG_ETH_ENCAP, "BIE" }, @@ -235,11 +236,11 @@ static struct tok tag2str[] = { { TAG_NIS_DOMAIN, "aYD" }, { TAG_NIS_SERVERS, "iYS" }, { TAG_NTP_SERVERS, "iNTP" }, - { TAG_VENDOR_OPTS, "bVendor-Option" }, - { TAG_NETBIOS_NS, "iNetbios-Name-Server" }, + { TAG_VENDOR_OPTS, "bVO" }, + { TAG_NETBIOS_NS, "iWNS" }, { TAG_NETBIOS_DDS, "iWDD" }, - { TAG_NETBIOS_NODE, "$Netbios-Node" }, - { TAG_NETBIOS_SCOPE, "aNetbios-Scope" }, + { TAG_NETBIOS_NODE, "$WNT" }, + { TAG_NETBIOS_SCOPE, "aWSC" }, { TAG_XWIN_FS, "iXFS" }, { TAG_XWIN_DM, "iXDM" }, { TAG_NIS_P_DOMAIN, "sN+D" }, @@ -253,20 +254,20 @@ static struct tok tag2str[] = { { TAG_IRC_SERVER, "iIRC" }, { TAG_STREETTALK_SRVR, "iSTS" }, { TAG_STREETTALK_STDA, "iSTDA" }, - { TAG_REQUESTED_IP, "iRequested-IP" }, - { TAG_IP_LEASE, "lLease-Time" }, + { TAG_REQUESTED_IP, "iRQ" }, + { TAG_IP_LEASE, "lLT" }, { 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_DHCP_MESSAGE, " DHCP" }, + { TAG_SERVER_ID, "iSID" }, + { TAG_PARM_REQUEST, "bPR" }, { 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" }, + { TAG_VENDOR_CLASS, "aVC" }, + { TAG_CLIENT_ID, "$CID" }, /* RFC 2485 */ { TAG_OPEN_GROUP_UAP, "aUAP" }, /* RFC 2563 */ @@ -278,14 +279,11 @@ static struct tok tag2str[] = { { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ /* 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" }, /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ { TAG_USER_CLASS, "aCLASS" }, { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, { TAG_CLIENT_FQDN, "$FQDN" }, - { TAG_AGENT_CIRCUIT, "$Agent-Information" }, + { TAG_AGENT_CIRCUIT, "bACKT" }, { TAG_AGENT_REMOTE, "bARMT" }, { TAG_AGENT_MASK, "bAMSK" }, { TAG_TZ_STRING, "aTZSTR" }, @@ -340,49 +338,29 @@ static struct tok arp2str[] = { { 0, NULL } }; -static 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 -static struct tok agent_suboption_values[] = { - { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" }, - { 0, NULL } -}; - - static void rfc1048_print(register const u_char *bp) { register u_int16_t tag; - register u_int len; + register u_int len, size; register const char *cp; register char c; - int first, idx; + int first; u_int32_t ul; u_int16_t us; - u_int8_t uc, subopt, suboptlen; + u_int8_t uc; - printf("\n\t Vendor-rfc1048 Extensions"); + printf("\n\t Vendor-rfc1048:"); /* Step over magic cookie */ - printf("\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 (TTEST2(*bp, 1)) { + while (bp + 1 < snapend) { tag = *bp++; - if (tag == TAG_PAD && vflag < 3) + if (tag == TAG_PAD) continue; - if (tag == TAG_END && vflag < 3) + if (tag == TAG_END) return; if (tag == TAG_EXTENDED_OPTION) { TCHECK2(*(bp + 1), 2); @@ -395,54 +373,47 @@ rfc1048_print(register const u_char *bp) } else cp = tok2str(tag2str, "?T%u", tag); c = *cp++; + printf("\n\t %s:", cp); - if (tag == TAG_PAD || tag == TAG_END) - len = 0; - else { - /* Get the length; check for truncation */ - TCHECK2(*bp, 1); - len = *bp++; - } - - printf("\n\t %s Option %u, length %u%s", cp, tag, len, - len > 0 ? ": " : ""); - - if (tag == TAG_PAD && vflag > 2) { - u_int ntag = 1; - while (TTEST2(*bp, 1) && *bp == TAG_PAD) { - bp++; - ntag++; - } - if (ntag > 1) - printf(", occurs %u", ntag); + /* Get the length; check for truncation */ + if (bp + 1 >= snapend) { + fputs(tstr, stdout); + return; } - - if (!TTEST2(*bp, len)) { - printf("[|rfc1048 %u]", len); + len = *bp++; + if (bp + len >= snapend) { + printf("[|bootp %u]", len); return; } if (tag == TAG_DHCP_MESSAGE && len == 1) { uc = *bp++; - printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)); - continue; + switch (uc) { + case DHCPDISCOVER: printf("DISCOVER"); break; + case DHCPOFFER: printf("OFFER"); break; + case DHCPREQUEST: printf("REQUEST"); break; + case DHCPDECLINE: printf("DECLINE"); break; + case DHCPACK: printf("ACK"); break; + case DHCPNAK: printf("NACK"); break; + case DHCPRELEASE: printf("RELEASE"); break; + case DHCPINFORM: printf("INFORM"); break; + default: printf("%u", uc); break; + } + continue; } if (tag == TAG_PARM_REQUEST) { - idx = 0; + first = 1; while (len-- > 0) { uc = *bp++; - cp = tok2str(tag2str, "?Option %u", uc); - if (idx % 4 == 0) - printf("\n\t "); - else - printf(", "); + cp = tok2str(tag2str, "?T%u", uc); + if (!first) + putchar('+'); printf("%s", cp + 1); - idx++; + first = 0; } continue; } - if (tag == TAG_EXTENDED_REQUEST) { first = 1; while (len > 1) { @@ -459,11 +430,12 @@ rfc1048_print(register const u_char *bp) } /* Print data */ + size = len; if (c == '?') { /* Base default formats for unknown tags on data size */ - if (len & 1) + if (size & 1) c = 'b'; - else if (len & 2) + else if (size & 2) c = 's'; else c = 'l'; @@ -474,20 +446,20 @@ rfc1048_print(register const u_char *bp) case 'a': /* ascii strings */ putchar('"'); - if (fn_printn(bp, len, snapend)) { + if (fn_printn(bp, size, snapend)) { putchar('"'); goto trunc; } putchar('"'); - bp += len; - len = 0; + bp += size; + size = 0; break; case 'i': case 'l': case 'L': /* ip addresses/32-bit words */ - while (len >= sizeof(ul)) { + while (size >= sizeof(ul)) { if (!first) putchar(','); ul = EXTRACT_32BITS(bp); @@ -499,14 +471,14 @@ rfc1048_print(register const u_char *bp) else printf("%u", ul); bp += sizeof(ul); - len -= sizeof(ul); + size -= sizeof(ul); first = 0; } break; case 'p': /* IP address pairs */ - while (len >= 2*sizeof(ul)) { + while (size >= 2*sizeof(ul)) { if (!first) putchar(','); memcpy((char *)&ul, (const char *)bp, sizeof(ul)); @@ -515,27 +487,27 @@ rfc1048_print(register const u_char *bp) memcpy((char *)&ul, (const char *)bp, sizeof(ul)); printf("%s)", ipaddr_string(&ul)); bp += sizeof(ul); - len -= 2*sizeof(ul); + size -= 2*sizeof(ul); first = 0; } break; case 's': /* shorts */ - while (len >= sizeof(us)) { + while (size >= sizeof(us)) { if (!first) putchar(','); us = EXTRACT_16BITS(bp); printf("%u", us); bp += sizeof(us); - len -= sizeof(us); + size -= sizeof(us); first = 0; } break; case 'B': /* boolean */ - while (len > 0) { + while (size > 0) { if (!first) putchar(','); switch (*bp) { @@ -550,7 +522,7 @@ rfc1048_print(register const u_char *bp) break; } ++bp; - --len; + --size; first = 0; } break; @@ -559,7 +531,7 @@ rfc1048_print(register const u_char *bp) case 'x': default: /* Bytes */ - while (len > 0) { + while (size > 0) { if (!first) putchar(c == 'x' ? ':' : '.'); if (c == 'x') @@ -567,7 +539,7 @@ rfc1048_print(register const u_char *bp) else printf("%u", *bp); ++bp; - --len; + --size; first = 0; } break; @@ -577,196 +549,78 @@ rfc1048_print(register const u_char *bp) switch (tag) { case TAG_NETBIOS_NODE: - /* this option should be at least 1 byte long */ - if (len < 1) { - printf("ERROR: option %u len %u < 1 bytes", - TAG_NETBIOS_NODE, len); - bp += len; - len = 0; - break; - } tag = *bp++; - --len; + --size; fputs(tok2str(nbo2str, NULL, tag), stdout); break; case TAG_OPT_OVERLOAD: - /* this option should be at least 1 byte long */ - if (len < 1) { - printf("ERROR: option %u len %u < 1 bytes", - TAG_OPT_OVERLOAD, len); - bp += len; - len = 0; - break; - } tag = *bp++; - --len; + --size; fputs(tok2str(oo2str, NULL, tag), stdout); break; case TAG_CLIENT_FQDN: - /* this option should be at least 3 bytes long */ - if (len < 3) { - printf("ERROR: option %u len %u < 3 bytes", - TAG_CLIENT_FQDN, len); - bp += len; - len = 0; + /* option 81 should be at least 4 bytes long */ + if (len < 4) { + printf("ERROR: options 81 len %u < 4 bytes", len); break; } + if (*bp++) + printf("[svrreg]"); if (*bp) - printf("[%s] ", client_fqdn_flags(*bp)); - bp++; - if (*bp || *(bp+1)) - printf("%u/%u ", *bp, *(bp+1)); + printf("%u/%u/", *bp, *(bp+1)); bp += 2; putchar('"'); - if (fn_printn(bp, len - 3, snapend)) { + if (fn_printn(bp, size - 3, snapend)) { putchar('"'); goto trunc; } putchar('"'); - bp += len - 3; - len = 0; + bp += size - 3; + size = 0; break; case TAG_CLIENT_ID: - { int type; - - /* this option should be at least 1 byte long */ - if (len < 1) { - printf("ERROR: option %u len %u < 1 bytes", - TAG_CLIENT_ID, len); - bp += len; - len = 0; - break; - } - type = *bp++; - len--; + { int type = *bp++; + size--; if (type == 0) { putchar('"'); - if (fn_printn(bp, len, snapend)) { + if (fn_printn(bp, size, snapend)) { putchar('"'); goto trunc; } putchar('"'); - bp += len; - len = 0; + bp += size; + size = 0; break; } else { - printf("%s ", tok2str(arp2str, "hardware-type %u,", type)); - while (len > 0) { - if (!first) - putchar(':'); - printf("%02x", *bp); - ++bp; - --len; - first = 0; - } - } - break; - } - - case TAG_AGENT_CIRCUIT: - while (len >= 2) { - subopt = *bp++; - suboptlen = *bp++; - len -= 2; - if (suboptlen > len) { - printf("\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; - } - printf("\n\t %s SubOption %u, length %u: ", - tok2str(agent_suboption_values, "Unknown", subopt), - subopt, - suboptlen); - switch (subopt) { - - case AGENT_SUBOPTION_CIRCUIT_ID: - fn_printn(bp, suboptlen, NULL); - break; - - default: - print_unknown_data(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) { - printf("ERROR: option %u len %u < 5 bytes", - TAG_CLASSLESS_STATIC_RT, len); - bp += len; - len = 0; - break; + printf("[%s]", tok2str(arp2str, "type-%d", type)); } - while (len > 0) { + while (size > 0) { if (!first) - putchar(','); - mask_width = *bp++; - len--; - /* mask_width <= 32 */ - if (mask_width > 32) { - printf("[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) { - printf("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4); - bp += len; - len = 0; - break; - } - putchar('('); - if (mask_width == 0) - printf("default"); - else { - for (i = 0; i < significant_octets ; i++) { - if (i > 0) - putchar('.'); - printf("%d", *bp++); - } - for (i = significant_octets ; i < 4 ; i++) - printf(".0"); - printf("/%d", mask_width); - } - memcpy((char *)&ul, (const char *)bp, sizeof(ul)); - printf(":%s)", ipaddr_string(&ul)); - bp += sizeof(ul); - len -= (significant_octets + 4); + putchar(':'); + printf("%02x", *bp); + ++bp; + --size; first = 0; } - } - break; + break; + } default: printf("[unknown special tag %u, size %u]", - tag, len); - bp += len; - len = 0; + tag, size); + bp += size; + size = 0; break; } break; } /* Data left over? */ - if (len) { - printf("\n\t trailing data length %u", len); - bp += len; + if (size) { + printf("[len %u]", len); + bp += size; } } return; @@ -804,22 +658,3 @@ trunc: fputs(tstr, stdout); #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; -} diff --git a/contrib/tcpdump/print-bxxp.c b/contrib/tcpdump/print-bxxp.c deleted file mode 100644 index 56be54f..0000000 --- a/contrib/tcpdump/print-bxxp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2000, Richard Sharpe - * - * This software may be distributed either under the terms of the - * BSD-style licence that accompanies tcpdump or under the GNU GPL - * version 2 or later. - * - * print-bxxp.c - * - */ - -#ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-bxxp.c,v 1.3 2000/10/05 04:10:01 itojun Exp $"; -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/param.h> -#include <sys/time.h> - -#ifdef HAVE_MEMORY_H -#include <memory.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "interface.h" -#include "extract.h" - -/* Check for a string but not go beyond length - * Return TRUE on match, FALSE otherwise - * - * Looks at the first few chars up to tl1 ... - */ - -int l_strnstart(const u_char *, u_int, const u_char *, u_int); - -int -l_strnstart(register const u_char *tstr1, register u_int tl1, - register const u_char *str2, register u_int l2) -{ - - if (tl1 > l2) - return 0; - - return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0); - -} - -void -bxxp_print(register const u_char *bp, register u_int length) -{ - - if (l_strnstart("REQ ", 4, bp, length)) { /* A REQuest */ - - printf(" BXXP REQ"); - - } - else if (l_strnstart("RSP ", 4, bp, length)) { - - printf(" BXXP RSP"); - - } - else if (l_strnstart("SEQ ", 4, bp, length)) { - - printf(" BXXP SEQ"); - - } - else if (l_strnstart("END", 4, bp, length)) { - - printf(" BXXP END"); - - } - else - printf(" BXXP (payload or undecoded)"); - -} diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c index d4a35d8..08b5cea 100644 --- a/contrib/tcpdump/print-domain.c +++ b/contrib/tcpdump/print-domain.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.8 2007/02/13 19:19:27 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.1 2005/04/20 20:59:00 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -278,20 +280,9 @@ struct tok ns_type2str[] = { { 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" }, @@ -320,32 +311,23 @@ static const u_char * ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns) { register const u_char *np = cp; - register u_int i, class; + register u_int i; cp = ns_nskip(cp); if (cp == NULL || !TTEST2(*cp, 4)) return(NULL); - /* print the qtype */ + /* print the qtype and qclass (if it's not IN) */ i = EXTRACT_16BITS(cp); cp += 2; printf(" %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) - printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); - if (is_mdns) { - if (i & C_QU) - printf(" (QU)"); - else - printf(" (QM)"); - } + if (is_mdns && i == (C_IN|C_CACHE_FLUSH)) + printf(" (Cache flush)"); + else if (i != C_IN) + printf(" %s", tok2str(ns_class2str, "(Class %d)", i)); fputs("? ", stdout); cp = ns_nprint(np, bp); @@ -356,7 +338,7 @@ ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns) static const u_char * ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) { - register u_int i, class, opt_flags = 0; + register u_int class; register u_short typ, len; register const u_char *rp; @@ -370,30 +352,18 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) if (cp == NULL || !TTEST2(*cp, 10)) return (snapend); - /* print the type/qtype */ + /* print the type/qtype and class (if it's not IN) */ typ = EXTRACT_16BITS(cp); cp += 2; - /* print the class (if it's not IN and the type isn't OPT) */ - i = EXTRACT_16BITS(cp); + class = EXTRACT_16BITS(cp); cp += 2; - if (is_mdns) - class = (i & ~C_CACHE_FLUSH); - else - class = i; - if (class != C_IN && typ != T_OPT) + if (is_mdns && class == (C_IN|C_CACHE_FLUSH)) + printf(" (Cache flush)"); + else if (class != C_IN && typ != T_OPT) printf(" %s", tok2str(ns_class2str, "(Class %d)", class)); - if (is_mdns) { - if (i & C_CACHE_FLUSH) - printf(" (Cache flush)"); - } /* ignore ttl */ - cp += 2; - /* if T_OPT, save opt_flags */ - if (typ == T_OPT) - opt_flags = EXTRACT_16BITS(cp); - /* ignore rest of ttl */ - cp += 2; + cp += 4; len = EXTRACT_16BITS(cp); cp += 2; @@ -510,8 +480,6 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns) case T_OPT: printf(" UDPsize=%u", class); - if (opt_flags & 0x8000) - printf(" OK"); break; case T_UNSPECA: /* One long string */ @@ -574,7 +542,7 @@ ns_print(register const u_char *bp, u_int length, int is_mdns) if (DNS_QR(np)) { /* this is a response */ - printf("%d%s%s%s%s%s%s", + printf(" %d%s%s%s%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], ns_resp[DNS_RCODE(np)], @@ -642,7 +610,7 @@ ns_print(register const u_char *bp, u_int length, int is_mdns) } else { /* this is a request */ - printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], + printf(" %d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)], DNS_RD(np) ? "+" : "", DNS_CD(np) ? "%" : ""); diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c index f71a7cc..57a3d8e 100644 --- a/contrib/tcpdump/print-ether.c +++ b/contrib/tcpdump/print-ether.c @@ -17,10 +17,12 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.6 2006/02/20 18:15:03 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.4 2005/07/10 14:47:57 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -47,7 +49,7 @@ const struct tok ethertype_values[] = { { ETHERTYPE_VMAN, "VMAN" }, { ETHERTYPE_PUP, "PUP" }, { ETHERTYPE_ARP, "ARP"}, - { ETHERTYPE_REVARP, "Reverse ARP"}, + { ETHERTYPE_REVARP , "Reverse ARP"}, { ETHERTYPE_NS, "NS" }, { ETHERTYPE_SPRITE, "Sprite" }, { ETHERTYPE_TRAIL, "Trail" }, @@ -128,6 +130,7 @@ ether_print(const u_char *p, u_int length, u_int caplen) /* * Is it (gag) an 802.3 encapsulation? */ + extracted_ether_type = 0; if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep), @@ -242,13 +245,11 @@ ether_encap_print(u_short ether_type, const u_char *p, if (llc_print(p, length, caplen, p - 18, p - 12, extracted_ether_type) == 0) { - ether_hdr_print(p - 18, length + 4); - - if (!suppress_default_print) { - default_print(p - 18, caplen + 4); - } + ether_hdr_print(p - 18, length + 4); } + if (!suppress_default_print) + default_print(p - 18, caplen + 4); return (1); @@ -270,12 +271,11 @@ ether_encap_print(u_short ether_type, const u_char *p, if (llc_print(p, length, caplen, p - 16, p - 10, extracted_ether_type) == 0) { ether_hdr_print(p - 16, length + 2); - - if (!suppress_default_print) { - default_print(p - 16, caplen + 2); - } } + if (!suppress_default_print) + default_print(p - 16, caplen + 2); + return (1); case ETHERTYPE_ISO: @@ -284,6 +284,8 @@ ether_encap_print(u_short ether_type, const u_char *p, case ETHERTYPE_PPPOED: case ETHERTYPE_PPPOES: + case ETHERTYPE_PPPOED2: + case ETHERTYPE_PPPOES2: pppoe_print(p, length); return (1); diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c index eeb7191..9166735 100644 --- a/contrib/tcpdump/print-fddi.c +++ b/contrib/tcpdump/print-fddi.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64.2.2 2005/11/13 12:12:59 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.64.2.1 2005/07/07 01:24:35 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -264,6 +266,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen) caplen -= FDDI_HDRLEN; /* Frame Control field determines interpretation of packet */ + extracted_ethertype = 0; if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c index b53a88b..e1f9686 100644 --- a/contrib/tcpdump/print-fr.c +++ b/contrib/tcpdump/print-fr.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.15 2006/02/01 14:39:56 hannes Exp $ (LBL)"; + "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.32.2.12 2005/08/23 03:15:51 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -111,8 +113,6 @@ static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore, 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 0; /* 2-byte Q.922 address */ @@ -304,10 +304,6 @@ fr_print(register const u_char *p, u_int length) frf15_print(p, length); break; - case NLPID_PPP: - ppp_print(p, length); - break; - default: if (!eflag) fr_hdr_print(length + hdr_len, addr_len, @@ -324,24 +320,6 @@ fr_print(register const u_char *p, u_int length) } -u_int -mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p) -{ - register u_int length = h->len; - register u_int caplen = h->caplen; - - TCHECK2(*p, 2); /* minimum frame header length */ - - if ((length = mfr_print(p, length)) == 0) - return (0); - else - return length; - trunc: - printf("[|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 diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c index e9e8459..1ef5a68 100644 --- a/contrib/tcpdump/print-icmp.c +++ b/contrib/tcpdump/print-icmp.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.6 2007/09/13 17:40:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.81.2.2 2005/07/01 16:13:37 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -62,12 +64,20 @@ struct icmp { u_int16_t icd_seq; } ih_idseq; u_int32_t ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu { + u_int16_t ipm_void; + u_int16_t ipm_nextmtu; + } ih_pmtu; } 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 +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu union { struct id_ts { u_int32_t its_otime; @@ -78,6 +88,12 @@ struct icmp { struct ip idi_ip; /* options and then 64 bits of data */ } id_ip; + struct mpls_ext { + u_int8_t legacy_header[128]; /* extension header starts 128 bytes after ICMP header */ + u_int8_t version_res[2]; + u_int8_t checksum[2]; + u_int8_t data[1]; + } mpls_ext; u_int32_t id_mask; u_int8_t id_data[1]; } icmp_dun; @@ -87,6 +103,9 @@ struct icmp { #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_version icmp_dun.mpls_ext.version_res +#define icmp_mpls_ext_checksum icmp_dun.mpls_ext.checksum +#define icmp_mpls_ext_data icmp_dun.mpls_ext.data }; #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) @@ -101,7 +120,7 @@ struct icmp { * ip header length. */ #define ICMP_MINLEN 8 /* abs minimum */ -#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */ +#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-icmp-mpls-02 */ #define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */ #define ICMP_MASKLEN 12 /* address mask */ #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ @@ -156,9 +175,7 @@ struct icmp { (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) #define ICMP_MPLS_EXT_TYPE(type) \ - ((type) == ICMP_UNREACH || \ - (type) == ICMP_TIMXCEED || \ - (type) == ICMP_PARAMPROB) + ((type) == ICMP_UNREACH || (type) == ICMP_TIMXCEED) /* rfc1700 */ #ifndef ICMP_UNREACH_NET_UNKNOWN #define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */ @@ -261,45 +278,7 @@ struct id_rdiscovery { u_int32_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 { - u_int8_t icmp_type; - u_int8_t icmp_code; - u_int8_t icmp_checksum[2]; - u_int8_t icmp_reserved; - u_int8_t icmp_length; - u_int8_t icmp_reserved2[2]; - u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */ - u_int8_t icmp_ext_version_res[2]; - u_int8_t icmp_ext_checksum[2]; - u_int8_t icmp_ext_data[1]; -}; - +/* draft-bonica-icmp-mpls-02 */ struct icmp_mpls_ext_object_header_t { u_int8_t length[2]; u_int8_t class_num; @@ -335,20 +314,17 @@ icmp_print(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 u_int8_t *obj_tptr; u_int32_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]; dp = (struct icmp *)bp; - ext_dp = (struct icmp_ext_t *)bp; ip = (struct ip *)bp2; str = buf; @@ -570,61 +546,35 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented) } } } - - /* - * print the remnants of the IP packet. - * save the snaplength as this may get overidden in the IP printer. - */ if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) { bp += 8; (void)printf("\n\t"); ip = (struct ip *)bp; snaplen = snapend - bp; - snapend_save = snapend; ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len)); - snapend = snapend_save; } - /* - * Attempt to decode the MPLS extensions only for some ICMP types. - */ if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) { - 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 && - in_cksum((const u_short *)&ext_dp->icmp_ext_version_res, - plen - ICMP_EXTD_MINLEN, 0)) { - return; - } - - printf("\n\tMPLS extension v%u", - ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res))); + TCHECK(*(dp->icmp_mpls_ext_version)); + printf("\n\tMPLS extension v%u",ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version))); /* * Sanity checking of the header. */ - if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) != - ICMP_MPLS_EXT_VERSION) { + if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(dp->icmp_mpls_ext_version)) != ICMP_MPLS_EXT_VERSION) { printf(" packet not supported"); return; } hlen = plen - ICMP_EXTD_MINLEN; - printf(", checksum 0x%04x (%scorrect), length %u", - EXTRACT_16BITS(ext_dp->icmp_ext_checksum), - in_cksum((const u_short *)&ext_dp->icmp_ext_version_res, - plen - ICMP_EXTD_MINLEN, 0) ? "in" : "", + TCHECK2(*(dp->icmp_mpls_ext_checksum), 2); + printf(", checksum 0x%04x (unverified), length %u", /* FIXME */ + EXTRACT_16BITS(dp->icmp_mpls_ext_checksum), hlen); hlen -= 4; /* subtract common header size */ - obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data; + obj_tptr = (u_int8_t *)dp->icmp_mpls_ext_data; while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) { @@ -642,12 +592,8 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented) 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; - } + if (obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t)) + break; obj_tlen-=sizeof(struct icmp_mpls_ext_object_header_t); switch (obj_class_num) { diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c index 07238f5..9ea7141 100644 --- a/contrib/tcpdump/print-ip.c +++ b/contrib/tcpdump/print-ip.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.9 2007/09/14 01:30:02 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.149.2.2 2005/09/20 06:05:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -50,7 +52,6 @@ struct tok ip_option_values[] = { { IPOPT_SSRR, "SSRR" }, { IPOPT_LSRR, "LSRR" }, { IPOPT_RA, "RA" }, - { IPOPT_RFC1393, "traceroute" }, { 0, NULL } }; @@ -74,9 +75,9 @@ ip_printroute(register const u_char *cp, u_int length) printf(" [bad ptr %u]", cp[2]); for (len = 3; len < length; len += 4) { - printf(" %s", ipaddr_string(&cp[len])); + printf("%s", ipaddr_string(&cp[len])); if (ptr > len) - printf(","); + printf (", "); } } @@ -138,17 +139,17 @@ ip_printts(register const u_char *cp, u_int length) const char *type; if (length < 4) { - printf("[bad length %u]", length); + printf("[bad length %d]", length); return; } printf(" TS{"); hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4; if ((length - 4) & (hoplen-1)) - printf("[bad length %u]", length); + printf("[bad length %d]", length); ptr = cp[2] - 1; len = 0; if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1) - printf("[bad ptr %u]", cp[2]); + printf("[bad ptr %d]", cp[2]); switch (cp[3]&0xF) { case IPOPT_TS_TSONLY: printf("TSONLY"); @@ -198,37 +199,29 @@ static void ip_optprint(register const u_char *cp, u_int length) { register u_int option_len; - const char *sep = ""; for (; length > 0; cp += option_len, length -= option_len) { u_int option_code; - printf("%s", sep); - sep = ","; - TCHECK(*cp); option_code = *cp; - printf("%s", - tok2str(ip_option_values,"unknown %u",option_code)); - if (option_code == IPOPT_NOP || option_code == IPOPT_EOL) option_len = 1; else { TCHECK(cp[1]); - option_len = cp[1]; - if (option_len < 2) { - printf(" [bad length %u]", option_len); - return; - } + option_len = cp[1]; } - if (option_len > length) { - printf(" [bad length %u]", option_len); - return; - } + printf("%s (%u) len %u", + tok2str(ip_option_values,"unknown",option_code), + option_code, + option_len); + + if (option_len < 2) + return; TCHECK2(*cp, option_len); @@ -243,17 +236,13 @@ ip_optprint(register const u_char *cp, u_int length) case IPOPT_RR: /* fall through */ case IPOPT_SSRR: case IPOPT_LSRR: - ip_printroute(cp, option_len); + ip_printroute( cp, option_len); break; case IPOPT_RA: - if (option_len < 4) { - printf(" [bad length %u]", option_len); - break; - } TCHECK(cp[3]); if (EXTRACT_16BITS(&cp[2]) != 0) - printf(" value %u", EXTRACT_16BITS(&cp[2])); + printf("value %u", EXTRACT_16BITS(&cp[2])); break; case IPOPT_NOP: /* nothing to print - fall through */ @@ -354,6 +343,12 @@ in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum) return shouldbe; } +#ifndef IP_MF +#define IP_MF 0x2000 +#endif /* IP_MF */ +#ifndef IP_DF +#define IP_DF 0x4000 +#endif /* IP_DF */ #define IP_RES 0x8000 static struct tok ip_frag_values[] = { @@ -424,21 +419,19 @@ again: break; case IPPROTO_TCP: - /* pass on the MF bit plus the offset to detect fragments */ tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, - ipds->off & (IP_MF|IP_OFFMASK)); + (ipds->off &~ 0x6000)); break; case IPPROTO_UDP: - /* pass on the MF bit plus the offset to detect fragments */ udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, - ipds->off & (IP_MF|IP_OFFMASK)); + (ipds->off &~ 0x6000)); break; case IPPROTO_ICMP: /* pass on the MF bit plus the offset to detect fragments */ icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip, - ipds->off & (IP_MF|IP_OFFMASK)); + (ipds->off & 0x3fff)); break; case IPPROTO_PIGP: @@ -634,7 +627,7 @@ ip_print(netdissect_options *ndo, } if (ipds->ip->ip_ttl >= 1) - (void)printf(", ttl %u", ipds->ip->ip_ttl); + (void)printf(", ttl %3u", ipds->ip->ip_ttl); /* * for the firewall guys, print id, offset. @@ -642,19 +635,19 @@ ip_print(netdissect_options *ndo, * For unfragmented datagrams, note the don't fragment flag. */ - (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)", + (void)printf(", id %u, offset %u, flags [%s], proto: %s (%u)", EXTRACT_16BITS(&ipds->ip->ip_id), (ipds->off & 0x1fff) * 8, - bittok2str(ip_frag_values, "none", ipds->off&0xe000), + bittok2str(ip_frag_values, "none", ipds->off&0xe000 ), tok2str(ipproto_values,"unknown",ipds->ip->ip_p), ipds->ip->ip_p); - (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)); + (void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len)); if ((hlen - sizeof(struct ip)) > 0) { - printf(", options ("); + printf(", options ( "); ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip)); - printf(")"); + printf(" )"); } if ((u_char *)ipds->ip + hlen <= snapend) { diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c index 29e5988..5e6902d 100644 --- a/contrib/tcpdump/print-ip6.c +++ b/contrib/tcpdump/print-ip6.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.5 2007/09/21 07:07:52 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.47.2.3 2005/09/20 06:05:38 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -93,7 +95,7 @@ ip6_print(register const u_char *bp, register u_int length) (void)printf("flowlabel 0x%05x, ", flow & 0x000fffff); #endif - (void)printf("hlim %u, next-header %s (%u) payload length: %u) ", + (void)printf("hlim %u, next-header: %s (%u), length: %u) ", ip6->ip6_hlim, tok2str(ipproto_values,"unknown",ip6->ip6_nxt), ip6->ip6_nxt, @@ -225,7 +227,7 @@ ip6_print(register const u_char *bp, register u_int length) return; default: - (void)printf("ip-proto-%d %d", nh, len); + (void)printf("ip-proto-%d %d", ip6->ip6_nxt, len); return; } } diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c index 5309aa4..6459b31 100644 --- a/contrib/tcpdump/print-ipx.c +++ b/contrib/tcpdump/print-ipx.c @@ -20,6 +20,8 @@ * * Format and print Novell IPX packets. * Contributed by Brad Parker (brad@fcr.com). + * + * $FreeBSD$ */ #ifndef lint diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c index d3935fc..7092ef2 100644 --- a/contrib/tcpdump/print-isoclns.c +++ b/contrib/tcpdump/print-isoclns.c @@ -22,11 +22,13 @@ * * Extensively modified by Hannes Gredler (hannes@juniper.net) for more * complete IS-IS & CLNP support. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.25 2007/03/02 09:20:27 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133.2.19 2005/09/20 10:15:22 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -475,7 +477,7 @@ static struct tok isis_lsp_istype_values[] = { { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"}, { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"}, { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"}, - { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"}, + { ISIS_LSP_TYPE_LEVEL_2, "L1L2 IS"}, { 0, NULL } }; @@ -1616,11 +1618,7 @@ static int isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) { char ident_buffer[20]; -#ifdef INET6 u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ -#else - u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */ -#endif u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; if (!TTEST2(*tptr, 4)) @@ -1634,12 +1632,6 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi return (0); status_byte=*(tptr++); bit_length = status_byte&0x3f; - if (bit_length > 32) { - printf("%sIPv4 prefix: bad bit length %u", - ident, - bit_length); - return (0); - } processed++; #ifdef INET6 } else if (afi == IPV6) { @@ -1647,12 +1639,6 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi return (0); status_byte=*(tptr++); bit_length=*(tptr++); - if (bit_length > 128) { - printf("%sIPv6 prefix: bad bit length %u", - ident, - bit_length); - return (0); - } processed+=2; #endif } else @@ -1662,7 +1648,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi if (!TTEST2(*tptr, byte_length)) return (0); - memset(prefix, 0, sizeof prefix); /* clear the copy buffer */ + memset(prefix, 0, sizeof(struct in6_addr)); /* clear the copy buffer */ memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ tptr+=byte_length; processed+=byte_length; @@ -2108,7 +2094,7 @@ static int isis_print (const u_int8_t *p, u_int length) tlv_len); if (tlv_len == 0) /* something is malformed */ - continue; + break; /* now check if we have a decoder otherwise do a hexdump at the end*/ switch (tlv_type) { @@ -2247,14 +2233,13 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_MT_IP_REACH: - mt_len = isis_print_mtid(tptr, "\n\t "); - if (mt_len == 0) { /* did something go wrong ? */ - goto trunctlv; - } - tptr+=mt_len; - tmp-=mt_len; + while (tmp>0) { + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; - while (tmp>0) { ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4); if (ext_ip_len == 0) /* did something go wrong ? */ goto trunctlv; @@ -2275,14 +2260,13 @@ static int isis_print (const u_int8_t *p, u_int length) break; case ISIS_TLV_MT_IP6_REACH: - mt_len = isis_print_mtid(tptr, "\n\t "); - if (mt_len == 0) { /* did something go wrong ? */ - goto trunctlv; - } - tptr+=mt_len; - tmp-=mt_len; - while (tmp>0) { + mt_len = isis_print_mtid(tptr, "\n\t "); + if (mt_len == 0) /* did something go wrong ? */ + goto trunctlv; + tptr+=mt_len; + tmp-=mt_len; + ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6); if (ext_ip_len == 0) /* did something go wrong ? */ goto trunctlv; @@ -2532,7 +2516,7 @@ static int isis_print (const u_int8_t *p, u_int length) if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)) goto trunctlv; - printf(", Remaining holding time %us", EXTRACT_16BITS(tptr)); + printf(", Remaining holding time %us", EXTRACT_16BITS(tptr+1)); tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN; diff --git a/contrib/tcpdump/print-lcp.c b/contrib/tcpdump/print-lcp.c deleted file mode 100644 index ddea9c6..0000000 --- a/contrib/tcpdump/print-lcp.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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. - */ - -#ifndef lint -static const char rcsid[] = -"@(#) $Header: /tcpdump/master/tcpdump/print-lcp.c,v 1.9 2000/10/06 04:23:12 guy Exp $ (LBL)"; -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/param.h> -#include <sys/time.h> -#include <sys/socket.h> - -#include <netinet/in.h> - -#include <stdio.h> -#include <string.h> - -#include "interface.h" -#include "addrtoname.h" -#include "extract.h" /* must come after interface.h */ -#include "ppp.h" - -/* Codes */ -enum { - LCP_CONFREQ = 1, - LCP_CONFACK = 2, - LCP_CONFNAK = 3, - LCP_CONFREJ = 4, - LCP_TERMREQ = 5, - LCP_TERMACK = 6, - LCP_CODEREJ = 7, - LCP_PROTREJ = 8, - LCP_ECHOREQ = 9, - LCP_ECHOREP = 10, - LCP_DISCARD = 11 -}; - -static struct tok lcpcode2str[] = { - { LCP_CONFREQ, "ConfReq" }, - { LCP_CONFACK, "ConfAck" }, - { LCP_CONFNAK, "ConfNak" }, - { LCP_CONFREJ, "ConfRej" }, - { LCP_TERMREQ, "TermReq" }, - { LCP_TERMACK, "TermAck" }, - { LCP_CODEREJ, "CodeRej" }, - { LCP_PROTREJ, "ProtRej" }, - { LCP_ECHOREQ, "EchoReq" }, - { LCP_ECHOREP, "EchoRep" }, - { LCP_DISCARD, "Discard" }, - { 0, NULL } -}; - - -enum { - LCP_RESERVED = 0, - LCP_MRU = 1, - LCP_ASYNCMAP = 2, - LCP_AUTHPROTO = 3, - LCP_QUALPROTO = 4, - LCP_MAGICNUM = 5, - LCP_PCOMP = 7, - LCP_ACFCOMP = 8, - LCP_CALLBACK = 13 -}; - -static struct tok lcpoption2str[] = { - { LCP_RESERVED, "reserved"}, - { LCP_MRU, "mru"}, - { LCP_ASYNCMAP, "asyncmap"}, - { LCP_AUTHPROTO, "auth"}, - { LCP_QUALPROTO, "qual"}, - { LCP_MAGICNUM, "magic"}, - { LCP_PCOMP, "pcomp"}, - { LCP_ACFCOMP, "acfcomp"}, - { LCP_CALLBACK, "callback"}, - { 0, NULL } -}; - -static struct tok lcpauth2str[] = { - {0xc023, "PAP"}, - {0xc223, "CHAP"}, - { 0, NULL } -}; - -static struct tok lcpqual2str[] = { - {0xc025, "LQR"}, - { 0, NULL } -}; - -static struct tok lcpchap2str[] = { - {0x05, "MD5"}, - {0x80, "MS"}, - { 0, NULL } -}; - -void -lcp_print(register const u_char *bp, u_int length) -{ - u_short lcp_code, lcp_id, lcp_length; - const u_char *lcp_data; - - lcp_data = bp+4; - - if (snapend < lcp_data) { - printf(" [LCP|]"); - return; - } - - lcp_code = bp[0]; - lcp_id = bp[1]; - lcp_length = EXTRACT_16BITS(bp+2); - - printf("LCP %s id=0x%x", tok2str(lcpcode2str, "LCP-#%d", lcp_code), lcp_id); - - switch (lcp_code) { - case LCP_CONFREQ: - case LCP_CONFACK: - case LCP_CONFNAK: - case LCP_CONFREJ: - /* Print Options */ - { - u_char lcpopt_type, lcpopt_length; - const u_char *p=lcp_data; - while (p+2 < lcp_data+lcp_length && p+2 < snapend) { - lcpopt_type = p[0]; - lcpopt_length = p[1]; - p+=2; - printf(" <%s ",tok2str(lcpoption2str, "option-#%d", lcpopt_type)); - if (lcpopt_length) - switch (lcpopt_type) { - case LCP_MRU: - if (snapend < p+2) return; - printf("%d",ntohs(*(u_short*)p)); - if (lcpopt_length != 4) printf(" len=%d!",lcpopt_length); - break; - case LCP_AUTHPROTO: - if (snapend < p+2) return; - printf("%s",tok2str(lcpauth2str, "AUTH-%#x", ntohs(*(u_short*)p))); - if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length); - if (lcpopt_length >= 5 && p < snapend) - printf(" %s",tok2str(lcpchap2str, "%#x", p[0])); - break; - case LCP_QUALPROTO: - if (snapend < p+2) return; - printf("%s",tok2str(lcpqual2str, "QUAL-%#x", ntohs(*(u_short*)p))); - if (lcpopt_length < 4) printf(" len=%d!",lcpopt_length); - /* Print data field of auth? */ - break; - case LCP_ASYNCMAP: - case LCP_MAGICNUM: - if (snapend < p+4) return; - printf("%#x", (unsigned)ntohl(*(u_long*)p)); - if (lcpopt_length != 6) printf(" len=%d!",lcpopt_length); - break; - case LCP_PCOMP: - case LCP_ACFCOMP: - case LCP_RESERVED: - if (lcpopt_length != 2) printf(" len=%d!",lcpopt_length); - break; - default: - if (lcpopt_length != 2) printf(" len=%d",lcpopt_length); - break; - } - printf(">"); - p+=lcpopt_length-2; - } - } - break; - case LCP_ECHOREQ: - case LCP_ECHOREP: - case LCP_DISCARD: - if (snapend < lcp_data+4) return; - printf(" magic=%#x", (unsigned)ntohl(*(u_long *) lcp_data)); - lcp_data +=4; - break; - case LCP_PROTREJ: - if (snapend < lcp_data+2) return; - printf(" prot=%s", tok2str(ppptype2str, "PROT-%#x", ntohs(*(u_short *) lcp_data))); - /* TODO print rejected packet too ? */ - break; - case LCP_CODEREJ: - if (snapend < lcp_data+4) return; - printf(" "); - lcp_print(lcp_data, (lcp_length+lcp_data > snapend ? snapend-lcp_data : lcp_length)); - break; - case LCP_TERMREQ: - case LCP_TERMACK: - break; - default: - break; - } - - return; -} diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c index bc41985..3820f32 100644 --- a/contrib/tcpdump/print-llc.c +++ b/contrib/tcpdump/print-llc.c @@ -20,11 +20,13 @@ * * Code by Matt Thomas, Digital Equipment Corporation * with an awful lot of hacking by Jeffrey Mogul, DECWRL + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.10 2007/02/08 07:07:51 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61.2.5 2005/09/29 07:40:13 hannes Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -80,31 +82,20 @@ static const struct tok llc_flag_values[] = { { LLC_GSAP, "Response" }, { LLC_U_POLL, "Poll" }, { LLC_GSAP|LLC_U_POLL, "Final" }, - { LLC_IS_POLL, "Poll" }, { LLC_GSAP|LLC_IS_POLL, "Final" }, { 0, NULL } }; - -static const struct tok llc_ig_flag_values[] = { - { 0, "Individual" }, - { LLC_IG, "Group" }, - { 0, NULL } -}; - - static const struct tok llc_supervisory_values[] = { { 0, "Receiver Ready" }, - { 1, "Receiver not Ready" }, - { 2, "Reject" }, + { 1, "Reject" }, + { 2, "Receiver not Ready" }, { 0, NULL } }; static const struct tok cisco_values[] = { { PID_CISCO_CDP, "CDP" }, - { PID_CISCO_VTP, "VTP" }, - { PID_CISCO_DTP, "DTP" }, { 0, NULL } }; @@ -123,10 +114,6 @@ static const struct tok bridged_values[] = { { 0, NULL }, }; -static const struct tok null_values[] = { - { 0, NULL } -}; - struct oui_tok { u_int32_t oui; const struct tok *tok; @@ -153,8 +140,6 @@ llc_print(const u_char *p, u_int length, u_int caplen, int is_u; register int ret; - *extracted_ethertype = 0; - if (caplen < 3) { (void)printf("[|llc]"); default_print((u_char *)p, caplen); @@ -162,7 +147,9 @@ llc_print(const u_char *p, u_int length, u_int caplen, } dsap_field = *p; + dsap = dsap_field & ~LLC_IG; ssap_field = *(p + 1); + ssap = ssap_field & ~LLC_GSAP; /* * OK, what type of LLC frame is this? The length @@ -194,7 +181,7 @@ llc_print(const u_char *p, u_int length, u_int caplen, is_u = 0; } - if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) { + if (ssap == LLCSAP_GLOBAL && dsap == LLCSAP_GLOBAL) { /* * This is an Ethernet_802.3 IPX frame; it has an * 802.3 header (i.e., an Ethernet header where the @@ -217,22 +204,17 @@ llc_print(const u_char *p, u_int length, u_int caplen, return (1); } - dsap = dsap_field & ~LLC_IG; - ssap = ssap_field & ~LLC_GSAP; - if (eflag) { - printf("LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s", + printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x)", tok2str(llc_values, "Unknown", dsap), dsap, - tok2str(llc_ig_flag_values, "Unknown", dsap_field & LLC_IG), tok2str(llc_values, "Unknown", ssap), - ssap, - tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP)); + ssap); if (is_u) { - printf(", ctrl 0x%02x: ", control); + printf(", cmd 0x%02x: ", control); } else { - printf(", ctrl 0x%04x: ", control); + printf(", cmd 0x%04x: ", control); } } @@ -339,7 +321,7 @@ llc_print(const u_char *p, u_int length, u_int caplen, if (is_u) { printf("Unnumbered, %s, Flags [%s], length %u", tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)), - tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)), + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_U_POLL)), length); p += 3; @@ -355,17 +337,18 @@ llc_print(const u_char *p, u_int length, u_int caplen, } } } else { + if ((control & LLC_S_FMT) == LLC_S_FMT) { (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u", tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)), LLC_IS_NR(control), - tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), length); } else { (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u", LLC_I_NS(control), LLC_IS_NR(control), - tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), + bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), length); } p += 4; @@ -388,7 +371,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, et = EXTRACT_16BITS(p + 3); if (eflag) { - const struct tok *tok = null_values; + const struct tok *tok = NULL; const struct oui_tok *otp; for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) { diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c index 45e8869..8929d73 100644 --- a/contrib/tcpdump/print-nfs.c +++ b/contrib/tcpdump/print-nfs.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.4 2007/06/15 23:17:40 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.106.2.2 2005/05/06 07:57:18 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -287,12 +289,8 @@ nfsreply_print(register const u_char *bp, u_int length, register const u_char *bp2) { register const struct sunrpc_msg *rp; - u_int32_t proc, vers, reply_stat; + u_int32_t proc, vers; char srcid[20], dstid[20]; /*fits 32bit*/ - enum sunrpc_reject_stat rstat; - u_int32_t rlow; - u_int32_t rhigh; - enum sunrpc_auth_stat rwhy; nfserr = 0; /* assume no error */ rp = (const struct sunrpc_msg *)bp; @@ -307,83 +305,13 @@ nfsreply_print(register const u_char *bp, u_int length, EXTRACT_32BITS(&rp->rm_xid)); } print_nfsaddr(bp2, srcid, dstid); - reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat); - switch (reply_stat) { - - case SUNRPC_MSG_ACCEPTED: - (void)printf("reply ok %u", length); - if (xid_map_find(rp, bp2, &proc, &vers) >= 0) - interp_reply(rp, proc, vers, length); - break; - - case SUNRPC_MSG_DENIED: - (void)printf("reply ERR %u: ", length); - rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat); - switch (rstat) { - - case SUNRPC_RPC_MISMATCH: - rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low); - rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high); - (void)printf("RPC Version mismatch (%u-%u)", - rlow, rhigh); - break; - - case SUNRPC_AUTH_ERROR: - rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why); - (void)printf("Auth "); - switch (rwhy) { - - case SUNRPC_AUTH_OK: - (void)printf("OK"); - break; + (void)printf("reply %s %d", + EXTRACT_32BITS(&rp->rm_reply.rp_stat) == SUNRPC_MSG_ACCEPTED? + "ok":"ERR", + length); - case SUNRPC_AUTH_BADCRED: - (void)printf("Bogus Credentials (seal broken)"); - break; - - case SUNRPC_AUTH_REJECTEDCRED: - (void)printf("Rejected Credentials (client should begin new session)"); - break; - - case SUNRPC_AUTH_BADVERF: - (void)printf("Bogus Verifier (seal broken)"); - break; - - case SUNRPC_AUTH_REJECTEDVERF: - (void)printf("Verifier expired or was replayed"); - break; - - case SUNRPC_AUTH_TOOWEAK: - (void)printf("Credentials are too weak"); - break; - - case SUNRPC_AUTH_INVALIDRESP: - (void)printf("Bogus response verifier"); - break; - - case SUNRPC_AUTH_FAILED: - (void)printf("Unknown failure"); - break; - - default: - (void)printf("Invalid failure code %u", - (unsigned int)rwhy); - break; - } - break; - - default: - (void)printf("Unknown reason for rejecting rpc message %u", - (unsigned int)rstat); - break; - } - break; - - default: - (void)printf("reply Unknown rpc response code=%u %u", - reply_stat, length); - break; - } + if (xid_map_find(rp, bp2, &proc, &vers) >= 0) + interp_reply(rp, proc, vers, length); } /* diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c index 606a654..9e8ccfa 100644 --- a/contrib/tcpdump/print-ntp.c +++ b/contrib/tcpdump/print-ntp.c @@ -21,6 +21,8 @@ * Format and print ntp packets. * By Jeffrey Mogul/DECWRL * loosely based on print-bootp.c + * + * $FreeBSD$ */ #ifndef lint diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c index 3d203da..bb6ab3c 100644 --- a/contrib/tcpdump/print-null.c +++ b/contrib/tcpdump/print-null.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.4 2007/02/26 13:31:33 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.3 2005/07/07 01:24:38 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -36,7 +38,6 @@ static const char rcsid[] _U_ = #include "interface.h" #include "addrtoname.h" -#include "af.h" #include "ip.h" #ifdef INET6 @@ -55,6 +56,34 @@ static const char rcsid[] _U_ = */ #define NULL_HDRLEN 4 +/* + * BSD AF_ values. + * + * Unfortunately, the BSDs don't all use the same value for AF_INET6, + * so, because we want to be able to read captures from all of the BSDs, + * we check for all of them. + */ +#define BSD_AF_INET 2 +#define BSD_AF_NS 6 /* XEROX NS protocols */ +#define BSD_AF_ISO 7 +#define BSD_AF_APPLETALK 16 +#define BSD_AF_IPX 23 +#define BSD_AF_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */ +#define BSD_AF_INET6_FREEBSD 28 +#define BSD_AF_INET6_DARWIN 30 + +const struct tok bsd_af_values[] = { + { BSD_AF_INET, "IPv4" }, + { BSD_AF_NS, "NS" }, + { BSD_AF_ISO, "ISO" }, + { BSD_AF_APPLETALK, "Appletalk" }, + { BSD_AF_IPX, "IPX" }, + { BSD_AF_INET6_BSD, "IPv6" }, + { BSD_AF_INET6_FREEBSD, "IPv6" }, + { BSD_AF_INET6_DARWIN, "IPv6" }, + { 0, NULL} +}; + /* * Byte-swap a 32-bit number. @@ -118,27 +147,27 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p) switch (family) { - case BSD_AFNUM_INET: + case BSD_AF_INET: ip_print(gndo, p, length); break; #ifdef INET6 - case BSD_AFNUM_INET6_BSD: - case BSD_AFNUM_INET6_FREEBSD: - case BSD_AFNUM_INET6_DARWIN: + case BSD_AF_INET6_BSD: + case BSD_AF_INET6_FREEBSD: + case BSD_AF_INET6_DARWIN: ip6_print(p, length); break; #endif - case BSD_AFNUM_ISO: + case BSD_AF_ISO: isoclns_print(p, length, caplen); break; - case BSD_AFNUM_APPLETALK: + case BSD_AF_APPLETALK: atalk_print(p, length); break; - case BSD_AFNUM_IPX: + case BSD_AF_IPX: ipx_print(p, length); break; diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c index 39c4e4d..a99d060 100644 --- a/contrib/tcpdump/print-pim.c +++ b/contrib/tcpdump/print-pim.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.4 2006/02/13 01:32:34 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.45.2.3 2005/07/11 20:24:34 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -79,15 +81,6 @@ static struct tok pimv2_hello_option_values[] = { { 0, NULL} }; -#define PIMV2_REGISTER_FLAG_LEN 4 -#define PIMV2_REGISTER_FLAG_BORDER 0x80000000 -#define PIMV2_REGISTER_FLAG_NULL 0x40000000 - -static struct tok pimv2_register_flag_values[] = { - { PIMV2_REGISTER_FLAG_BORDER, "Border" }, - { PIMV2_REGISTER_FLAG_NULL, "Null" }, - { 0, NULL} -}; /* * XXX: We consider a case where IPv6 is not ready yet for portability, @@ -428,13 +421,13 @@ pim_print(register const u_char *bp, register u_int len) switch (PIM_VER(pim->pim_typever)) { case 2: if (!vflag) { - printf("PIMv%u, %s, length %u", + printf("PIMv%u, %s, length: %u", PIM_VER(pim->pim_typever), tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)), len); return; } else { - printf("PIMv%u, length %u\n\t%s", + printf("PIMv%u, length: %u\n\t%s", PIM_VER(pim->pim_typever), len, tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))); @@ -442,7 +435,7 @@ pim_print(register const u_char *bp, register u_int len) } break; default: - printf("PIMv%u, length %u", + printf("PIMv%u, length: %u", PIM_VER(pim->pim_typever), len); break; @@ -634,15 +627,6 @@ pimv2_print(register const u_char *bp, register u_int len) if (pimv2_addr_len != 0) (void)printf(", RFC2117-encoding"); - printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum)); - if (EXTRACT_16BITS(&pim->pim_cksum) == 0) { - printf("(unverified)"); - } else { - printf("(%scorrect)", - TTEST2(bp[0], len) && - in_cksum((const u_short*)bp, len, 0) ? "in" : "" ); - } - switch (PIM_TYPE(pim->pim_typever)) { case PIMV2_TYPE_HELLO: { @@ -654,7 +638,7 @@ pimv2_print(register const u_char *bp, register u_int len) olen = EXTRACT_16BITS(&bp[2]); TCHECK2(bp[0], 4 + olen); - printf("\n\t %s Option (%u), length %u, Value: ", + printf("\n\t %s Option (%u), length: %u, Value: ", tok2str( pimv2_hello_option_values,"Unknown",otype), otype, olen); @@ -747,35 +731,30 @@ pimv2_print(register const u_char *bp, register u_int len) { struct ip *ip; - if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN)) - goto trunc; - - printf(", Flags [ %s ]\n\t", - tok2str(pimv2_register_flag_values, - "none", - EXTRACT_32BITS(bp+4))); - + if (vflag && bp + 8 <= ep) { + (void)printf(" %s%s", bp[4] & 0x80 ? "B" : "", + bp[4] & 0x40 ? "N" : ""); + } bp += 8; len -= 8; + /* encapsulated multicast packet */ + if (bp >= ep) + break; ip = (struct ip *)bp; switch (IP_V(ip)) { - case 0: /* Null header */ - (void)printf("IP-Null-header %s > %s", - ipaddr_string(&ip->ip_src), - ipaddr_string(&ip->ip_dst)); - break; - case 4: /* IPv4 */ + printf(" "); ip_print(gndo, bp, len); break; #ifdef INET6 case 6: /* IPv6 */ + printf(" "); ip6_print(bp, len); break; #endif - default: - (void)printf("IP ver %d", IP_V(ip)); - break; + default: + (void)printf(" IP ver %d", IP_V(ip)); + break; } break; } diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c index 1e99c15..3c48c78 100644 --- a/contrib/tcpdump/print-ppp.c +++ b/contrib/tcpdump/print-ppp.c @@ -20,6 +20,8 @@ * * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more * complete PPP support. + * + * $FreeBSD$ */ /* @@ -31,7 +33,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108.2.6 2005/12/05 11:40:36 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.108.2.4 2005/06/18 23:56:40 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -296,20 +298,6 @@ struct tok ipcpopt_values[] = { { 0, NULL } }; -#define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */ -#define IPCPOPT_IPCOMP_MINLEN 14 - -struct tok ipcpopt_compproto_values[] = { - { PPP_VJC, "VJ-Comp" }, - { IPCPOPT_IPCOMP_HDRCOMP, "IP Header Compression" }, - { 0, NULL } -}; - -struct tok ipcpopt_compproto_subopt_values[] = { - { 1, "RTP-Compression" }, - { 2, "Enhanced RTP-Compression" }, - { 0, NULL } -}; /* IP6CP Config Options */ #define IP6CP_IFID 1 @@ -545,9 +533,8 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length) printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)); /* XXX: need to decode Data? - hexdump for now */ if (len > 8) { - printf("\n\t -----trailing data-----"); - TCHECK2(tptr[4], len-8); - print_unknown_data(tptr+4,"\n\t ",len-8); + printf("\n\t Data"); + print_unknown_data(tptr+4,"\n\t ",len-4); } break; case CPCODES_ID: @@ -979,7 +966,6 @@ static int print_ipcp_config_options(const u_char *p, int length) { int len, opt; - u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen; if (length < 2) return 0; @@ -1014,62 +1000,11 @@ print_ipcp_config_options(const u_char *p, int length) if (len < 4) goto invlen; TCHECK2(*(p + 2), 2); - compproto = EXTRACT_16BITS(p+2); - - printf("%s (0x%02x):", - tok2str(ipcpopt_compproto_values,"Unknown",compproto), - compproto); - - switch (compproto) { - case PPP_VJC: + if (EXTRACT_16BITS(p + 2) == PPP_VJC) { + printf("VJ-Comp"); /* XXX: VJ-Comp parameters should be decoded */ - break; - case IPCPOPT_IPCOMP_HDRCOMP: - if (len < IPCPOPT_IPCOMP_MINLEN) - goto invlen; - - TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN); - printf("\n\t TCP Space %u, non-TCP Space %u" \ - ", maxPeriod %u, maxTime %u, maxHdr %u", - EXTRACT_16BITS(p+4), - EXTRACT_16BITS(p+6), - EXTRACT_16BITS(p+8), - EXTRACT_16BITS(p+10), - EXTRACT_16BITS(p+12)); - - /* suboptions present ? */ - if (len > IPCPOPT_IPCOMP_MINLEN) { - ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN; - p += IPCPOPT_IPCOMP_MINLEN; - - printf("\n\t Suboptions, length %u", ipcomp_subopttotallen); - - while (ipcomp_subopttotallen >= 2) { - TCHECK2(*p, 2); - ipcomp_subopt = *p; - ipcomp_suboptlen = *(p+1); - - /* sanity check */ - if (ipcomp_subopt == 0 || - ipcomp_suboptlen == 0 ) - break; - - /* XXX: just display the suboptions for now */ - printf("\n\t\t%s Suboption #%u, length %u", - tok2str(ipcpopt_compproto_subopt_values, - "Unknown", - ipcomp_subopt), - ipcomp_subopt, - ipcomp_suboptlen); - - ipcomp_subopttotallen -= ipcomp_suboptlen; - p += ipcomp_suboptlen; - } - } - break; - default: - break; - } + } else + printf("unknown-comp-proto %04x", EXTRACT_16BITS(p + 2)); break; case IPCPOPT_ADDR: /* those options share the same format - fall through */ diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c index f28a21a..97389d8 100644 --- a/contrib/tcpdump/print-sl.c +++ b/contrib/tcpdump/print-sl.c @@ -17,6 +17,8 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c index 03e28a4..420ec36 100644 --- a/contrib/tcpdump/print-sunrpc.c +++ b/contrib/tcpdump/print-sunrpc.c @@ -17,6 +17,8 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c index 47fcca6..0a80fb6 100644 --- a/contrib/tcpdump/print-token.c +++ b/contrib/tcpdump/print-token.c @@ -22,10 +22,12 @@ * * Further tweaked to more closely resemble print-fddi.c * Guy Harris <guy@alum.mit.edu> + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.2 2005/11/13 12:13:01 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.25.2.1 2005/07/07 01:24:40 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -153,6 +155,7 @@ token_print(const u_char *p, u_int length, u_int caplen) caplen -= hdr_len; /* Frame Control field determines interpretation of packet */ + extracted_ethertype = 0; if (FRAME_TYPE(trp) == TOKEN_FC_LLC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c index 3f08a1c..089da1a 100644 --- a/contrib/tcpdump/print-udp.c +++ b/contrib/tcpdump/print-udp.c @@ -17,11 +17,13 @@ * 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. + * + * $FreeBSD$ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138.2.1 2007/03/28 07:45:46 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.138 2005/04/07 00:28:17 mcr Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -674,8 +676,6 @@ udp_print(register const u_char *bp, u_int length, lwres_print((const u_char *)(up + 1), length); else if (ISPORT(LDP_PORT)) ldp_print((const u_char *)(up + 1), length); - else if (ISPORT(OLSR_PORT)) - olsr_print((const u_char *)(up + 1), length); else if (ISPORT(MPLS_LSP_PING_PORT)) lspping_print((const u_char *)(up + 1), length); else if (dport == BFD_CONTROL_PORT || diff --git a/contrib/tcpdump/savestr.c b/contrib/tcpdump/savestr.c deleted file mode 100644 index a81227c..0000000 --- a/contrib/tcpdump/savestr.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1997 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.c,v 1.6 2000/07/11 00:49:02 assar Exp $ (LBL)"; -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <sys/types.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifdef HAVE_OS_PROTO_H -#include "os-proto.h" -#endif - -#include "savestr.h" - -/* A replacement for strdup() that cuts down on malloc() overhead */ -char * -savestr(register const char *str) -{ - register u_int size; - register char *p; - static char *strptr = NULL; - static u_int strsize = 0; - - size = strlen(str) + 1; - if (size > strsize) { - strsize = 1024; - if (strsize < size) - strsize = size; - strptr = (char *)malloc(strsize); - if (strptr == NULL) { - fprintf(stderr, "savestr: malloc\n"); - exit(1); - } - } - (void)strcpy(strptr, str); - p = strptr; - strptr += size; - strsize -= size; - return (p); -} diff --git a/contrib/tcpdump/savestr.h b/contrib/tcpdump/savestr.h deleted file mode 100644 index 8fe995e..0000000 --- a/contrib/tcpdump/savestr.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 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. - * - * @(#) $Header: /tcpdump/master/tcpdump/Attic/savestr.h,v 1.1.1.1 1999/10/07 23:47:12 mcr Exp $ (LBL) - */ - -extern char *savestr(const char *); diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/tcpdump-stdinc.h index cd04d09..337d45e 100644 --- a/contrib/tcpdump/tcpdump-stdinc.h +++ b/contrib/tcpdump/tcpdump-stdinc.h @@ -29,7 +29,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * - * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.5 2006/06/23 02:07:27 hannes Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.4 2005/07/09 21:19:45 risso Exp $ (LBL) + * + * $FreeBSD$ */ /* @@ -143,47 +145,8 @@ typedef char* caddr_t; #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT #endif -#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl) - #undef ntohl - #undef ntohs - #undef htonl - #undef htons - - extern __inline__ unsigned long __ntohl (unsigned long x); - extern __inline__ unsigned short __ntohs (unsigned short x); - - #define ntohl(x) __ntohl(x) - #define ntohs(x) __ntohs(x) - #define htonl(x) __ntohl(x) - #define htons(x) __ntohs(x) - - extern __inline__ unsigned long __ntohl (unsigned long x) - { - __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */ - "rorl $16, %0\n\t" /* swap words */ - "xchgb %b0, %h0" /* swap higher bytes */ - : "=q" (x) : "0" (x)); - return (x); - } - - extern __inline__ unsigned short __ntohs (unsigned short x) - { - __asm__ ("xchgb %b0, %h0" /* swap bytes */ - : "=q" (x) : "0" (x)); - return (x); - } -#endif - #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - #endif /* tcpdump_stdinc_h */ diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1 index d13b4de..1dc0340f 100644 --- a/contrib/tcpdump/tcpdump.1 +++ b/contrib/tcpdump/tcpdump.1 @@ -1,4 +1,4 @@ -.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.11 2007/06/15 20:13:49 guy Exp $ (LBL) +.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167.2.6 2005/09/05 09:14:37 guy Exp $ (LBL) .\" .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $ .\" @@ -22,6 +22,8 @@ .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" +.\" $FreeBSD$ +.\" .TH TCPDUMP 1 "18 April 2005" .SH NAME tcpdump \- dump traffic on a network @@ -99,15 +101,19 @@ tcpdump \- dump traffic on a network ] .ti +8 [ +.B \-y +.I datalinktype +] +.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. It can also -be run with the +\fITcpdump\fP prints out the headers of packets on a network interface +that match the boolean \fIexpression\fP. 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 @@ -234,10 +240,7 @@ operation, be enabled on that interface. .TP .B Under BSD (this includes Mac OS X): You must have read access to -.I /dev/bpf* -on systems that don't have a cloning BPF device, or to -.I /dev/bpf -on systems that do. +.IR /dev/bpf* . On BSDs with a devfs (this includes Mac OS X), this might involve more than just having somebody with super-user access setting the ownership or permissions on the BPF devices - it might involve configuring devfs @@ -540,7 +543,7 @@ Standard output is used if \fIfile\fR is ``-''. .TP .B \-W Used in conjunction with the -.B \-C +.I \-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. @@ -549,9 +552,7 @@ the files with enough leading 0s to support the maximum number of files, allowing them to sort correctly. .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. +Print 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 @@ -560,22 +561,16 @@ 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, +Print 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. +Print 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, +Print each packet, .I including its link level header, in hex and ASCII. .TP @@ -651,6 +646,15 @@ protos are: .BR arp , .BR rarp , .BR decnet , +.BR lat , +.BR sca , +.BR moprc , +.BR mopdl , +.BR iso , +.BR esis , +.BR isis , +.BR icmp , +.BR icmp6 , .B tcp and .BR udp . @@ -753,16 +757,8 @@ This syntax does not work in IPv6-enabled configuration at this moment. .IP "\fBdst net \fInet\fR" True if the IPv4/v6 destination address of the packet has a network number of \fInet\fP. -\fINet\fP may be either a name from the networks database -(/etc/networks, etc.) or a network number. -An IPv4 network number can be written as a dotted quad (e.g., 192.168.1.0), -dotted triple (e.g., 192.168.1), dotted pair (e.g, 172.16), or single -number (e.g., 10); the netmask is 255.255.255.255 for a dotted quad -(which means that it's really a host match), 255.255.255.0 for a dotted -triple, 255.255.0.0 for a dotted pair, or 255.0.0.0 for a single number. -An IPv6 network number must be written out fully; the netmask is -ff:ff:ff:ff:ff:ff:ff:ff, so IPv6 "network" matches are really always -host matches, and a network match requires a netmask length. +\fINet\fP may be either a name from /etc/networks +or a network number (see \fInetworks(4)\fP for details). .IP "\fBsrc net \fInet\fR" True if the IPv4/v6 source address of the packet has a network number of \fInet\fP. @@ -2272,7 +2268,7 @@ is made to account for the time lag between when the Ethernet interface removed the packet from the wire and when the kernel serviced the `new packet' interrupt. .SH "SEE ALSO" -stty(1), pcap(3), bpf(4), nit(4P), pfconfig(8) +bpf(4), pcap(3) .SH AUTHORS The original authors are: .LP @@ -2313,6 +2309,13 @@ patches@tcpdump.org NIT doesn't let you watch your own outbound traffic, BPF will. We recommend that you use the latter. .LP +When running +.BR tcpdump +with the +.B \-v +option on a network interface supporting checksum off-loading, +IP packets sourced from this machine will have many false 'bad cksum 0' errors. +.LP On Linux systems with 2.0[.x] kernels: .IP packets on the loopback device will be seen twice; diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index caf419e..1730463 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -30,9 +30,11 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.13 2007/09/12 19:48:51 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.253.2.11 2005/08/23 10:29:41 hannes Exp $ (LBL)"; #endif +/* $FreeBSD$ */ + /* * tcpdump - monitor tcp/ip traffic on an ethernet. * @@ -190,7 +192,7 @@ static struct printer printers[] = { #ifdef DLT_LTALK { ltalk_if_print, DLT_LTALK }, #endif -#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H) +#ifdef DLT_PFLOG { pflog_if_print, DLT_PFLOG }, #endif #ifdef DLT_FR @@ -265,9 +267,6 @@ static struct printer printers[] = { #ifdef DLT_JUNIPER_CHDLC { juniper_chdlc_print, DLT_JUNIPER_CHDLC }, #endif -#ifdef DLT_MFR - { mfr_if_print, DLT_MFR }, -#endif { NULL, 0 }, }; diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h index 8e7fd6d..e466c84 100644 --- a/contrib/tcpdump/token.h +++ b/contrib/tcpdump/token.h @@ -25,6 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD$ */ #define TOKEN_HDRLEN 14 |