summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tcpdump')
-rw-r--r--contrib/tcpdump/FREEBSD-upgrade28
-rw-r--r--contrib/tcpdump/aclocal.m41267
-rw-r--r--contrib/tcpdump/acsite.m4505
-rw-r--r--contrib/tcpdump/addrtoname.c89
-rw-r--r--contrib/tcpdump/dhcp6.h200
-rw-r--r--contrib/tcpdump/dhcp6opt.h81
-rw-r--r--contrib/tcpdump/ethertype.h19
-rw-r--r--contrib/tcpdump/interface.h98
-rw-r--r--contrib/tcpdump/lbl/gnuc.h43
-rw-r--r--contrib/tcpdump/missing/cdecl_ext.h37
-rw-r--r--contrib/tcpdump/nfs.h1
-rw-r--r--contrib/tcpdump/nfsfh.h2
-rw-r--r--contrib/tcpdump/nfsv2.h262
-rw-r--r--contrib/tcpdump/parsenfsfh.c6
-rw-r--r--contrib/tcpdump/ppp.h16
-rw-r--r--contrib/tcpdump/print-arp.c145
-rw-r--r--contrib/tcpdump/print-atalk.c26
-rw-r--r--contrib/tcpdump/print-atm.c106
-rw-r--r--contrib/tcpdump/print-bootp.c4
-rw-r--r--contrib/tcpdump/print-bxxp.c82
-rw-r--r--contrib/tcpdump/print-domain.c4
-rw-r--r--contrib/tcpdump/print-ether.c76
-rw-r--r--contrib/tcpdump/print-fddi.c6
-rw-r--r--contrib/tcpdump/print-fr.c681
-rw-r--r--contrib/tcpdump/print-icmp.c121
-rw-r--r--contrib/tcpdump/print-ip.c544
-rw-r--r--contrib/tcpdump/print-ip6.c90
-rw-r--r--contrib/tcpdump/print-ipx.c25
-rw-r--r--contrib/tcpdump/print-isoclns.c1302
-rw-r--r--contrib/tcpdump/print-lcp.c216
-rw-r--r--contrib/tcpdump/print-llc.c35
-rw-r--r--contrib/tcpdump/print-nfs.c184
-rw-r--r--contrib/tcpdump/print-ntp.c151
-rw-r--r--contrib/tcpdump/print-null.c14
-rw-r--r--contrib/tcpdump/print-pim.c292
-rw-r--r--contrib/tcpdump/print-ppp.c409
-rw-r--r--contrib/tcpdump/print-sl.c8
-rw-r--r--contrib/tcpdump/print-sunrpc.c27
-rw-r--r--contrib/tcpdump/print-token.c6
-rw-r--r--contrib/tcpdump/print-udp.c69
-rw-r--r--contrib/tcpdump/savestr.c68
-rw-r--r--contrib/tcpdump/savestr.h24
-rw-r--r--contrib/tcpdump/tcpdump.1132
-rw-r--r--contrib/tcpdump/tcpdump.c498
-rw-r--r--contrib/tcpdump/token.h1
45 files changed, 1897 insertions, 6103 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 bf62311..0000000
--- a/contrib/tcpdump/aclocal.m4
+++ /dev/null
@@ -1,1267 +0,0 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.106 2005/03/27 03:31:01 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.
-#
-# Make sure we use the V_CCOPT flags, because some of those might
-# disable inlining.
-#
-AC_DEFUN(AC_LBL_C_INLINE,
- [AC_MSG_CHECKING(for inline)
- save_CFLAGS="$CFLAGS"
- CFLAGS="$V_CCOPT"
- 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])
- CFLAGS="$save_CFLAGS"
- 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 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 Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_CHECK_TYPE
-dnl
-dnl results:
-dnl
-dnl int32_t (defined)
-dnl u_int32_t (defined)
-dnl
-AC_DEFUN(AC_LBL_CHECK_TYPE,
- [AC_MSG_CHECKING(for $1 using $CC)
- AC_CACHE_VAL(ac_cv_lbl_have_$1,
- AC_TRY_COMPILE([
-# include "confdefs.h"
-# include <sys/types.h>
-# if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-# endif],
- [$1 i],
- ac_cv_lbl_have_$1=yes,
- ac_cv_lbl_have_$1=no))
- AC_MSG_RESULT($ac_cv_lbl_have_$1)
- if test $ac_cv_lbl_have_$1 = no ; then
- AC_DEFINE($1, $2)
- fi])
-
-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
- #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 -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_TRY_COMPILE([
-#include <stdlib.h>
-],
-[
-static void foo(void) __attribute__ ((noreturn));
-
-static void
-foo(void)
-{
- exit(1);
-}
-],
-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 852c89a..5995d23 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 2005/03/27 22:38:09 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.96.2.6 2004/03/24 04:14:31 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -39,15 +41,11 @@ struct rtentry; /* declarations in <net/if.h> */
#include <net/if.h> /* for "struct ifnet" in "struct arpcom" on Solaris */
#include <netinet/if_ether.h>
#endif /* HAVE_NETINET_IF_ETHER_H */
-#ifdef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
-#include <netinet/ether.h>
-#endif /* NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
+#ifdef HAVE_NETINET_ETHER_H
+#include <netinet/ether.h> /* ether_ntohost on linux */
+#endif /* HAVE_NETINET_ETHER_H */
#endif /* USE_ETHER_NTOHOST */
-#if !defined(HAVE_DECL_ETHER_NTOHOST) || !HAVE_DECL_ETHER_NTOHOST
-extern int ether_ntohost(char *, const struct ether_addr *);
-#endif
-
#include <pcap.h>
#include <pcap-namedb.h>
#include <signal.h>
@@ -107,20 +105,25 @@ win32_gethostbyaddr(const char *addr, int len, int type)
memset(&addr6, 0, sizeof(addr6));
addr6.sin6_family = AF_INET6;
memcpy(&addr6.sin6_addr, addr, len);
+#ifdef __MINGW32__
+ /* MinGW doesn't provide getnameinfo */
+ return NULL;
+#else
if (getnameinfo((struct sockaddr *)&addr6, sizeof(addr6),
- hname, sizeof(hname), NULL, 0, 0)) {
- return NULL;
+ hname, sizeof(hname), NULL, 0, 0)) {
+ return NULL;
} else {
strcpy(host.h_name, hname);
return &host;
}
+#endif /* __MINGW32__ */
break;
default:
return NULL;
}
}
#define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & WIN32 */
+#endif /* INET6 & WIN32*/
#ifdef INET6
struct h6namemem {
@@ -463,25 +466,18 @@ etheraddr_string(register const u_char *ep)
#ifdef USE_ETHER_NTOHOST
if (!nflag) {
char buf2[128];
-
- /*
- * We don't cast it to "const struct ether_addr *"
- * because some systems don't modify the Ethernet
- * address but fail to declare the second argument
- * as a "const" pointer.
- */
- if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) {
+ if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf2);
return (tp->e_name);
}
}
#endif
cp = buf;
- *cp++ = hex[*ep >> 4 ];
+ *cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
for (i = 5; (int)--i >= 0;) {
*cp++ = ':';
- *cp++ = hex[*ep >> 4 ];
+ *cp++ = hex[*ep >> 4 ];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
@@ -492,7 +488,7 @@ etheraddr_string(register const u_char *ep)
const char *
linkaddr_string(const u_char *ep, const unsigned int len)
{
- register u_int i;
+ register u_int i, j;
register char *cp;
register struct enamemem *tp;
@@ -506,11 +502,13 @@ linkaddr_string(const u_char *ep, const unsigned int len)
tp->e_name = cp = (char *)malloc(len*3);
if (tp->e_name == NULL)
error("linkaddr_string: malloc");
- *cp++ = hex[*ep >> 4];
+ if ((j = *ep >> 4) != 0)
+ *cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
*cp++ = ':';
- *cp++ = hex[*ep >> 4];
+ if ((j = *ep >> 4) != 0)
+ *cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
@@ -589,32 +587,27 @@ llcsap_string(u_char sap)
return (tp->name);
}
-#define ISONSAP_MAX_LENGTH 20
const char *
-isonsap_string(const u_char *nsap, register u_int nsap_length)
+isonsap_string(const u_char *nsap)
{
- register u_int nsap_idx;
+ register u_int i, nlen = nsap[0];
register char *cp;
register struct enamemem *tp;
- if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
- error("isonsap_string: illegal length");
-
tp = lookup_nsap(nsap);
if (tp->e_name)
return tp->e_name;
- tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
+ tp->e_name = cp = (char *)malloc(nlen * 2 + 2 + (nlen>>1));
if (cp == NULL)
error("isonsap_string: malloc");
- for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
+ nsap++;
+ for (i = 0; i < nlen; i++) {
*cp++ = hex[*nsap >> 4];
*cp++ = hex[*nsap++ & 0xf];
- if (((nsap_idx & 1) == 0) &&
- (nsap_idx + 1 < nsap_length)) {
- *cp++ = '.';
- }
+ if (((i & 1) == 0) && (i + 1 < nlen))
+ *cp++ = '.';
}
*cp = '\0';
return (tp->e_name);
@@ -715,14 +708,13 @@ init_servarray(void)
endservent();
}
-/* in libpcap.a (nametoaddr.c) */
-#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-__declspec(dllimport)
+/*XXX from libbpfc.a */
+#ifndef WIN32
+extern struct eproto {
#else
-extern
+__declspec( dllimport) struct eproto {
#endif
-const struct eproto {
- const char *s;
+ char *s;
u_short p;
} eproto_db[];
@@ -840,16 +832,9 @@ init_etherarray(void)
continue;
#ifdef USE_ETHER_NTOHOST
- /*
- * Use YP/NIS version of name if available.
- *
- * We don't cast it to "const struct ether_addr *"
- * because some systems don't modify the Ethernet
- * address but fail to declare the second argument
- * as a "const" pointer.
- */
- if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
- tp->e_name = strdup(name);
+ /* Use yp/nis version of name if available */
+ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
+ tp->e_name = strdup(name);
continue;
}
#endif
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 2513fbd..63c0c29 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 2004/10/07 16:04:07 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.20 2003/07/01 19:10:26 guy Exp $ (LBL)
+ *
+ * $FreeBSD$
*/
/*
@@ -33,13 +35,6 @@
* <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
*/
-#ifndef ETHERTYPE_LEN
-#define ETHERTYPE_LEN 2
-#endif
-
-#ifndef ETHERTYPE_GRE_ISO
-#define ETHERTYPE_GRE_ISO 0x00FE /* not really an ethertype only used in GRE */
-#endif
#ifndef ETHERTYPE_PUP
#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
#endif
@@ -121,11 +116,11 @@
#ifndef ETHERTYPE_PPPOES
#define ETHERTYPE_PPPOES 0x8864
#endif
-#ifndef ETHERTYPE_JUMBO
-#define ETHERTYPE_JUMBO 0x8870
+#ifndef ETHERTYPE_PPPOED2
+#define ETHERTYPE_PPPOED2 0x3c12
#endif
-#ifndef ETHERTYPE_EAPOL
-#define ETHERTYPE_EAPOL 0x888e
+#ifndef ETHERTYPE_PPPOES2
+#define ETHERTYPE_PPPOES2 0x3c13
#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h
index 8a36657..a53e59f 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 2005/04/06 21:33:27 mcr Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.217.2.5 2004/03/17 19:47:48 guy Exp $ (LBL)
+ *
+ * $FreeBSD$
*/
#ifndef tcpdump_interface_h
@@ -61,6 +63,30 @@ extern char *strdup(const char *);
extern char *strsep(char **, const char *);
#endif
+struct tok {
+ int v; /* value */
+ const char *s; /* string */
+};
+
+extern int aflag; /* translate network and broadcast addresses */
+extern int dflag; /* print filter code */
+extern int eflag; /* print ethernet header */
+extern int fflag; /* don't translate "foreign" IP address */
+extern int nflag; /* leave addresses as numbers */
+extern int Nflag; /* remove domains from printed host names */
+extern int qflag; /* quick (shorter) output */
+extern int Rflag; /* print sequence # field in AH/ESP*/
+extern int sflag; /* use the libsmi to translate OIDs */
+extern int Sflag; /* print raw TCP sequence numbers */
+extern int tflag; /* print packet arrival time */
+extern int uflag; /* Print undecoded NFS handles */
+extern int vflag; /* verbose */
+extern int xflag; /* print packet in hex */
+extern int Xflag; /* print packet in hex/ascii */
+extern int Aflag; /* print packet only in ascii observing TAB, LF, CR and SPACE as graphical chars */
+extern char *espsecret;
+
+extern int packettype; /* as specified by -T */
#define PT_VAT 1 /* Visual Audio Tool */
#define PT_WB 2 /* distributed White Board */
#define PT_RPC 3 /* Remote Procedure Call */
@@ -108,6 +134,10 @@ extern char *program_name; /* used to generate self-identifying messages */
extern int32_t thiszone; /* seconds offset from gmt to local time */
+extern int snaplen;
+/* global pointer to end of current packet (during printing) */
+extern const u_char *snapend;
+
/*
* True if "l" bytes of "var" were captured.
*
@@ -133,7 +163,9 @@ extern void relts_print(int);
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
+extern const char *tok2str(const struct tok *, const char *, int);
extern int mask2plen(u_int32_t);
+extern char *bittok2str(const struct tok *, const char *, int);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
@@ -149,7 +181,7 @@ extern char *copy_argv(char **);
extern void safeputchar(int);
extern void safeputs(const char *);
-extern const char *isonsap_string(const u_char *, register u_int);
+extern const char *isonsap_string(const u_char *);
extern const char *llcsap_string(u_char);
extern const char *protoid_string(const u_char *);
extern const char *ipxsap_string(u_short);
@@ -161,11 +193,11 @@ extern const char *dnnum_string(u_short);
#include <pcap.h>
extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print_with_offset(const char *, const u_char *, u_int, u_int);
-extern void ascii_print(const char *, const u_char *, u_int);
-extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
+extern void ascii_print_with_offset(const u_char *, const u_char *, u_int, u_int);
+extern void ascii_print(const u_char *, const u_char *, u_int);
+extern void hex_print_with_offset(const u_char *, const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
-extern void hex_print(const char *, const u_char *, u_int);
+extern void hex_print(const u_char *, const u_char *, u_int);
extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
const u_char *, u_short *);
@@ -173,19 +205,20 @@ extern int snap_print(const u_char *, u_int, u_int, u_short *, u_int32_t,
u_short, u_int);
extern void aarp_print(const u_char *, u_int);
extern void aodv_print(const u_char *, u_int, int);
+extern void arp_print(const u_char *, u_int, u_int);
extern void atalk_print(const u_char *, u_int);
extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern int oam_print(const u_char *, u_int);
extern void bootp_print(const u_char *, u_int);
extern void bgp_print(const u_char *, int);
extern void beep_print(const u_char *, u_int);
extern void cnfp_print(const u_char *, const u_char *);
extern void decnet_print(const u_char *, u_int, u_int);
extern void default_print(const u_char *, u_int);
+extern void default_print_unaligned(const u_char *, u_int);
extern void dvmrp_print(const u_char *, u_int);
-extern void egp_print(const u_char *, u_int);
+extern void egp_print(const u_char *);
extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
@@ -205,6 +238,7 @@ extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, u_int, const u_char *, int);
extern void igmp_print(const u_char *, u_int);
extern void igrp_print(const u_char *, u_int, const u_char *);
+extern void ip_print(const u_char *, u_int);
extern void ipN_print(const u_char *, u_int);
extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
extern void ipx_print(const u_char *, u_int);
@@ -223,9 +257,6 @@ 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);
extern void ldp_print(const u_char *, u_int);
-extern void lmp_print(const u_char *, u_int);
-extern void lspping_print(const u_char *, u_int);
-extern void eigrp_print(const u_char *, u_int);
extern void mobile_print(const u_char *, u_int);
extern void pim_print(const u_char *, u_int);
extern u_int pppoe_print(const u_char *, u_int);
@@ -235,7 +266,6 @@ extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void q933_print(const u_char *, u_int);
extern int vjc_print(register const char *, u_short);
extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
extern void rip_print(const u_char *, u_int);
@@ -245,20 +275,17 @@ extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *);
extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
extern void snmp_print(const u_char *, u_int);
extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *);
extern void tcp_print(const u_char *, u_int, const u_char *, int);
extern void tftp_print(const u_char *, u_int);
extern void timed_print(const u_char *);
extern void udp_print(const u_char *, u_int, const u_char *, int);
extern void wb_print(const void *, u_int);
extern int ah_print(register const u_char *);
+extern int esp_print(register const u_char *, register const u_char *, int *, int *);
+extern void isakmp_print(const u_char *, u_int, const u_char *);
extern int ipcomp_print(register const u_char *, int *);
extern void rx_print(register const u_char *, int, int, int, u_char *);
extern void netbeui_print(u_short, const u_char *, int);
@@ -267,7 +294,6 @@ extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *, int);
extern void nbt_udp138_print(const u_char *, int);
extern char *smb_errstr(int, int);
-extern const char *nt_errstr(u_int32_t);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void vrrp_print(const u_char *, u_int, int);
@@ -282,8 +308,6 @@ extern void mpls_lsp_ping_print(const u_char *, u_int);
extern void zephyr_print(const u_char *, int);
extern void hsrp_print(const u_char *, u_int);
extern void bfd_print(const u_char *, u_int, u_int);
-extern void sip_print(const u_char *, u_int);
-extern void syslog_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, u_int);
@@ -305,38 +329,4 @@ extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
struct bpf_program;
extern void bpf_dump(struct bpf_program *, int);
-
#endif
-
-#include "netdissect.h"
-
-/* forward compatibility */
-
-netdissect_options *gndo;
-
-#define eflag gndo->ndo_eflag
-#define fflag gndo->ndo_fflag
-#define nflag gndo->ndo_nflag
-#define Nflag gndo->ndo_Nflag
-#define Oflag gndo->ndo_Oflag
-#define pflag gndo->ndo_pflag
-#define qflag gndo->ndo_qflag
-#define Rflag gndo->ndo_Rflag
-#define sflag gndo->ndo_sflag
-#define Sflag gndo->ndo_Sflag
-#define tflag gndo->ndo_tflag
-#define Uflag gndo->ndo_Uflag
-#define uflag gndo->ndo_uflag
-#define vflag gndo->ndo_vflag
-#define xflag gndo->ndo_xflag
-#define Xflag gndo->ndo_Xflag
-#define Cflag gndo->ndo_Cflag
-#define Aflag gndo->ndo_Aflag
-#define packettype gndo->ndo_packettype
-#define tcpmd5secret gndo->ndo_tcpmd5secret
-#define Wflag gndo->ndo_Wflag
-#define WflagChars gndo->ndo_WflagChars
-#define Cflag_count gndo->ndo_Cflag_count
-#define snaplen gndo->ndo_snaplen
-#define snapend gndo->ndo_snapend
-
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 686d01e..c8180325 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 2004/03/25 03:30:55 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.25.2.2 2003/11/16 08:51:07 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -111,7 +113,7 @@ static int is_UCX(const unsigned char *);
void
Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
register const unsigned char *fh;
-int len _U_;
+int len;
my_fsid *fsidp;
ino_t *inop;
const char **osnamep; /* if non-NULL, return OS name here */
diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h
index 71621ca..6c69ce8 100644
--- a/contrib/tcpdump/ppp.h
+++ b/contrib/tcpdump/ppp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004/10/20 16:14:16 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.14 2003/05/22 15:29:22 hannes Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@@ -14,28 +14,32 @@
* 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 */
+#undef PPP_ADDRESS
#define PPP_ADDRESS 0xff /* The address byte value */
+#undef PPP_CONTROL
#define PPP_CONTROL 0x03 /* The control byte value */
-#define PPP_WITHDIRECTION_IN 0x00 /* non-standard for DLT_PPP_WITHDIRECTION */
-#define PPP_WITHDIRECTION_OUT 0x01 /* non-standard for DLT_PPP_WITHDIRECTION */
-
/* Protocol numbers */
+#ifndef PPP_IP
#define PPP_IP 0x0021 /* Raw IP */
+#endif
#define PPP_OSI 0x0023 /* OSI Network Layer */
#define PPP_NS 0x0025 /* Xerox NS IDP */
#define PPP_DECNET 0x0027 /* DECnet Phase IV */
#define PPP_APPLE 0x0029 /* Appletalk */
+#ifndef PPP_IPX
#define PPP_IPX 0x002b /* Novell IPX */
+#endif
#define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */
#define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */
#define PPP_BRPDU 0x0031 /* Bridging PDU */
#define PPP_STII 0x0033 /* Stream Protocol (ST-II) */
#define PPP_VINES 0x0035 /* Banyan Vines */
-#define PPP_ML 0x003d /* Multi-Link PPP */
#define PPP_IPV6 0x0057 /* IPv6 */
#define PPP_COMP 0x00fd /* Compressed Datagram */
@@ -64,7 +68,7 @@
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
#define PPP_BAP 0xc02d /* BAP */
-#define PPP_MPCP 0xc03d /* Multi-Link */
+#define PPP_MP 0xc03d /* Multi-Link */
#define PPP_SPAP_OLD 0xc123
#define PPP_EAP 0xc227
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index 68e9dc6..e56df75 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.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-arp.c,v 1.64 2004/04/30 16:42:14 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.61.2.2 2003/11/16 08:51:10 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,7 +35,7 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <string.h>
-#include "netdissect.h"
+#include "interface.h"
#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
@@ -158,184 +160,173 @@ struct atmarp_pkthdr {
static u_char ezero[6];
static void
-atmarp_addr_print(netdissect_options *ndo,
- const u_char *ha, u_int ha_len, const u_char *srca,
+atmarp_addr_print(const u_char *ha, u_int ha_len, const u_char *srca,
u_int srca_len)
{
if (ha_len == 0)
- ND_PRINT((ndo, "<No address>"));
+ (void)printf("<No address>");
else {
- ND_PRINT((ndo, "%s", linkaddr_string(ha, ha_len)));
- if (srca_len != 0)
- ND_PRINT((ndo, ",%s",
- linkaddr_string(srca, srca_len)));
+ (void)printf("%s", linkaddr_string(ha, ha_len));
+ if (srca_len != 0)
+ (void)printf(",%s", linkaddr_string(srca, srca_len));
}
}
static void
-atmarp_print(netdissect_options *ndo,
- const u_char *bp, u_int length, u_int caplen)
+atmarp_print(const u_char *bp, u_int length, u_int caplen)
{
const struct atmarp_pkthdr *ap;
u_short pro, hrd, op;
ap = (const struct atmarp_pkthdr *)bp;
- ND_TCHECK(*ap);
+ TCHECK(*ap);
hrd = ATMHRD(ap);
pro = ATMPRO(ap);
op = ATMOP(ap);
- if (!ND_TTEST2(*aar_tpa(ap), ATMTPLN(ap))) {
- ND_PRINT((ndo, "truncated-atmarp"));
- ND_DEFAULTPRINT((const u_char *)ap, length);
+ if (!TTEST2(*aar_tpa(ap), ATMTPLN(ap))) {
+ (void)printf("truncated-atmarp");
+ default_print((const u_char *)ap, length);
return;
}
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
ATMSPLN(ap) != 4 || ATMTPLN(ap) != 4) {
- ND_PRINT((ndo, "atmarp-#%d for proto #%d (%d/%d) hardware #%d",
- op, pro, ATMSPLN(ap), ATMTPLN(ap), hrd));
+ (void)printf("atmarp-#%d for proto #%d (%d/%d) hardware #%d",
+ op, pro, ATMSPLN(ap), ATMTPLN(ap), hrd);
return;
}
if (pro == ETHERTYPE_TRAIL)
- ND_PRINT((ndo, "trailer-"));
+ (void)printf("trailer-");
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "arp who-has %s", ipaddr_string(ATMTPA(ap))));
+ (void)printf("arp who-has %s", ipaddr_string(ATMTPA(ap)));
if (ATMTHLN(ap) != 0) {
- ND_PRINT((ndo, " ("));
- atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap),
+ (void)printf(" (");
+ atmarp_addr_print(ATMTHA(ap), ATMTHLN(ap),
ATMTSA(ap), ATMTSLN(ap));
- ND_PRINT((ndo, ")"));
+ (void)printf(")");
}
- ND_PRINT((ndo, " tell %s", ipaddr_string(ATMSPA(ap))));
+ (void)printf(" tell %s", ipaddr_string(ATMSPA(ap)));
break;
case ARPOP_REPLY:
- ND_PRINT((ndo, "arp reply %s", ipaddr_string(ATMSPA(ap))));
- ND_PRINT((ndo, " is-at "));
- atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
+ (void)printf("arp reply %s", ipaddr_string(ATMSPA(ap)));
+ (void)printf(" is-at ");
+ atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREQUEST:
- ND_PRINT((ndo, "invarp who-is "));
- atmarp_addr_print(ndo, ATMTHA(ap), ATMTHLN(ap), ATMTSA(ap),
+ (void)printf("invarp who-is ");
+ atmarp_addr_print(ATMTHA(ap), ATMTHLN(ap), ATMTSA(ap),
ATMTSLN(ap));
- ND_PRINT((ndo, " tell "));
- atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
+ (void)printf(" tell ");
+ atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
case ARPOP_INVREPLY:
- ND_PRINT((ndo, "invarp reply "));
- atmarp_addr_print(ndo, ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
+ (void)printf("invarp reply ");
+ atmarp_addr_print(ATMSHA(ap), ATMSHLN(ap), ATMSSA(ap),
ATMSSLN(ap));
- ND_PRINT((ndo, " at %s", ipaddr_string(ATMSPA(ap))));
+ (void)printf(" at %s", ipaddr_string(ATMSPA(ap)));
break;
case ATMARPOP_NAK:
- ND_PRINT((ndo, "nak reply for %s",
- ipaddr_string(ATMSPA(ap))));
+ (void)printf("nak reply for %s",
+ ipaddr_string(ATMSPA(ap)));
break;
default:
- ND_PRINT((ndo, "atmarp-#%d", op));
- ND_DEFAULTPRINT((const u_char *)ap, caplen);
+ (void)printf("atmarp-#%d", op);
+ default_print((const u_char *)ap, caplen);
return;
}
return;
trunc:
- ND_PRINT((ndo, "[|atmarp]"));
+ (void)printf("[|atmarp]");
}
void
-arp_print(netdissect_options *ndo,
- const u_char *bp, u_int length, u_int caplen)
+arp_print(const u_char *bp, u_int length, u_int caplen)
{
const struct arp_pkthdr *ap;
u_short pro, hrd, op;
ap = (const struct arp_pkthdr *)bp;
- ND_TCHECK(*ap);
+ TCHECK(*ap);
hrd = HRD(ap);
if (hrd == ARPHRD_ATM2225) {
- atmarp_print(ndo, bp, length, caplen);
+ atmarp_print(bp, length, caplen);
return;
}
pro = PRO(ap);
op = OP(ap);
- if (!ND_TTEST2(*ar_tpa(ap), PLN(ap))) {
- ND_PRINT((ndo, "truncated-arp"));
- ND_DEFAULTPRINT((const u_char *)ap, length);
+ if (!TTEST2(*ar_tpa(ap), PLN(ap))) {
+ (void)printf("truncated-arp");
+ default_print((const u_char *)ap, length);
return;
}
if ((pro != ETHERTYPE_IP && pro != ETHERTYPE_TRAIL) ||
PLN(ap) != 4 || HLN(ap) == 0) {
- ND_PRINT((ndo, "arp-#%d for proto #%d (%d) hardware #%d (%d)",
- op, pro, PLN(ap), hrd, HLN(ap)));
+ (void)printf("arp-#%d for proto #%d (%d) hardware #%d (%d)",
+ op, pro, PLN(ap), hrd, HLN(ap));
return;
}
if (pro == ETHERTYPE_TRAIL)
- ND_PRINT((ndo, "trailer-"));
+ (void)printf("trailer-");
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "arp who-has %s", ipaddr_string(TPA(ap))));
+ (void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
- ND_PRINT((ndo, " (%s)",
- linkaddr_string(THA(ap), HLN(ap))));
- ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
+ (void)printf(" (%s)",
+ linkaddr_string(THA(ap), HLN(ap)));
+ (void)printf(" tell %s", ipaddr_string(SPA(ap)));
break;
case ARPOP_REPLY:
- ND_PRINT((ndo, "arp reply %s", ipaddr_string(SPA(ap))));
- ND_PRINT((ndo, " is-at %s", linkaddr_string(SHA(ap), HLN(ap))));
+ (void)printf("arp reply %s", ipaddr_string(SPA(ap)));
+ (void)printf(" is-at %s", linkaddr_string(SHA(ap), HLN(ap)));
break;
case ARPOP_REVREQUEST:
- ND_PRINT((ndo, "rarp who-is %s tell %s",
- linkaddr_string(THA(ap), HLN(ap)),
- linkaddr_string(SHA(ap), HLN(ap))));
+ (void)printf("rarp who-is %s tell %s",
+ linkaddr_string(THA(ap), HLN(ap)),
+ linkaddr_string(SHA(ap), HLN(ap)));
break;
case ARPOP_REVREPLY:
- ND_PRINT((ndo, "rarp reply %s at %s",
- linkaddr_string(THA(ap), HLN(ap)),
- ipaddr_string(TPA(ap))));
+ (void)printf("rarp reply %s at %s",
+ linkaddr_string(THA(ap), HLN(ap)),
+ ipaddr_string(TPA(ap)));
break;
case ARPOP_INVREQUEST:
- ND_PRINT((ndo, "invarp who-is %s tell %s",
- linkaddr_string(THA(ap), HLN(ap)),
- linkaddr_string(SHA(ap), HLN(ap))));
+ (void)printf("invarp who-is %s tell %s",
+ linkaddr_string(THA(ap), HLN(ap)),
+ linkaddr_string(SHA(ap), HLN(ap)));
break;
case ARPOP_INVREPLY:
- ND_PRINT((ndo,"invarp reply %s at %s",
- linkaddr_string(THA(ap), HLN(ap)),
- ipaddr_string(TPA(ap))));
+ (void)printf("invarp reply %s at %s",
+ linkaddr_string(THA(ap), HLN(ap)),
+ ipaddr_string(TPA(ap)));
break;
default:
- ND_PRINT((ndo, "arp-#%d", op));
- ND_DEFAULTPRINT((const u_char *)ap, caplen);
+ (void)printf("arp-#%d", op);
+ default_print((const u_char *)ap, caplen);
return;
}
if (hrd != ARPHRD_ETHER)
- ND_PRINT((ndo, " hardware #%d", hrd));
+ printf(" hardware #%d", hrd);
return;
trunc:
- ND_PRINT((ndo, "[|arp]"));
+ (void)printf("[|arp]");
}
-
-/*
- * Local Variables:
- * c-style: bsd
- * End:
- */
-
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index f1f45a3..ce6178a 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -19,11 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Format and print AppleTalk packets.
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004/05/01 09:41:50 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.78.2.2 2003/11/16 08:51:11 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -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) {
@@ -172,9 +181,6 @@ atalk_print(register const u_char *bp, u_int length)
register const struct atDDP *dp;
u_short snet;
- if(!eflag)
- printf("AT ");
-
if (length < ddpSize) {
(void)printf(" [|ddp %d]", length);
return;
@@ -183,7 +189,7 @@ atalk_print(register const u_char *bp, u_int length)
snet = EXTRACT_16BITS(&dp->srcNet);
printf("%s.%s", ataddr_string(snet, dp->srcNode),
ddpskt_string(dp->srcSkt));
- printf(" > %s.%s: ",
+ printf(" > %s.%s:",
ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
ddpskt_string(dp->dstSkt));
bp += ddpSize;
@@ -213,7 +219,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!) */
@@ -244,10 +250,6 @@ ddp_print(register const u_char *bp, register u_int length, register int t,
atp_print((const struct atATP *)bp, length);
break;
- case ddpEIGRP:
- eigrp_print(bp, length);
- break;
-
default:
(void)printf(" at-%s %d", tok2str(type2str, NULL, t), length);
break;
@@ -567,10 +569,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 1e2d0c5..549af0e 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 2005/01/19 16:46:27 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.33.2.2 2003/11/16 08:51:11 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -43,54 +45,6 @@ static const char rcsid[] _U_ =
#include "ether.h"
-struct tok oam_celltype_values[] = {
- { 0x1, "Fault Management" },
- { 0x2, "Performance Management" },
- { 0x8, "activate/deactivate" },
- { 0xf, "System Management" },
- { 0, NULL }
-};
-
-struct tok oam_fm_functype_values[] = {
- { 0x0, "AIS" },
- { 0x1, "RDI" },
- { 0x4, "Continuity Check" },
- { 0x8, "Loopback" },
- { 0, NULL }
-};
-
-struct tok oam_pm_functype_values[] = {
- { 0x0, "Forward Monitoring" },
- { 0x1, "Backward Reporting" },
- { 0x2, "Monitoring and Reporting" },
- { 0, NULL }
-};
-
-struct tok oam_ad_functype_values[] = {
- { 0x0, "Performance Monitoring" },
- { 0x1, "Continuity Check" },
- { 0, NULL }
-};
-
-static const struct tok *oam_functype_values[16] = {
- NULL,
- oam_fm_functype_values, /* 1 */
- oam_pm_functype_values, /* 2 */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- oam_ad_functype_values, /* 8 */
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
@@ -120,7 +74,7 @@ atm_llc_print(const u_char *p, int length, int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the LLC/SNAP header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@@ -135,7 +89,6 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
printf("[|atm]");
return (caplen);
}
-
/*
* Extract the presumed LLC header into a variable, for quick
* testing.
@@ -255,9 +208,12 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
printf("broadcast sig: ");
return;
- case OAMF4SC: /* fall through */
+ case OAMF4SC:
+ printf("oamF4(segment): ");
+ return;
+
case OAMF4EC:
- oam_print(p, length);
+ printf("oamF4(end): ");
return;
case METAC:
@@ -286,47 +242,3 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
break;
}
}
-
-int
-oam_print (const u_char *p, u_int length) {
-
- u_int16_t cell_header, cell_type, func_type,vpi,vci,payload,clp;
-
- cell_header = EXTRACT_32BITS(p);
- cell_type = ((*(p+4))>>4) & 0x0f;
- func_type = *(p) & 0x0f;
-
- vpi = (cell_header>>20)&0xff;
- vci = (cell_header>>4)&0xffff;
- payload = (cell_header>>1)&0x7;
- clp = cell_header&0x1;
-
- 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),
- cell_type);
-
- if (oam_functype_values[cell_type] == NULL)
- printf(", func-type unknown (%u)", func_type);
- else
- printf(", func-type %s (%u)",
- bittok2str(oam_functype_values[cell_type],"none",func_type),
- func_type);
-
- printf(", length %u",length);
- return 1;
-}
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index e73915e..aedda0c 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 2004/03/02 07:38:10 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.75.2.3 2004/03/02 07:45:13 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
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 8955281..0aaef01 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 2004/03/23 19:03:03 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.86.2.3 2004/03/28 20:54:00 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index 2a33a12..223a085 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 2005/04/06 21:32:39 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.3 2003/12/29 22:42:21 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -37,24 +39,10 @@ static const char rcsid[] _U_ =
#include "ethertype.h"
#include "ether.h"
-#include "llc.h"
+
+const u_char *snapend;
const struct tok ethertype_values[] = {
- /* not really ethertypes but PIDs that are used
- in the SNAP printer - its more convenient
- to put them into a single tokentable */
- { PID_RFC2684_ETH_FCS, "Ethernet + FCS" },
- { PID_RFC2684_ETH_NOFCS, "Ethernet no FCS" },
- { PID_RFC2684_802_4_FCS, "802.4 + FCS" },
- { PID_RFC2684_802_4_NOFCS, "w/o FCS" },
- { PID_RFC2684_802_5_FCS, "Tokenring + FCS" },
- { PID_RFC2684_802_5_NOFCS, "Tokenring no FCS" },
- { PID_RFC2684_FDDI_FCS, "FDDI + FCS" },
- { PID_RFC2684_FDDI_NOFCS, "FDDI no FCS" },
- { PID_RFC2684_802_6_FCS, "802.6 + FCS" },
- { PID_RFC2684_802_6_NOFCS, "802.6 no FCS" },
- { PID_RFC2684_BPDU, "BPDU" },
- /* the real Ethertypes */
{ ETHERTYPE_IP, "IPv4" },
{ ETHERTYPE_MPLS, "MPLS unicast" },
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
@@ -83,11 +71,7 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_PPP, "PPP" },
{ ETHERTYPE_PPPOED, "PPPoE D" },
{ ETHERTYPE_PPPOES, "PPPoE S" },
- { ETHERTYPE_EAPOL, "EAPOL" },
- { ETHERTYPE_JUMBO, "Jumbo" },
{ ETHERTYPE_LOOPBACK, "Loopback" },
- { ETHERTYPE_ISO, "OSI" },
- { ETHERTYPE_GRE_ISO, "GRE-OSI" },
{ 0, NULL}
};
@@ -169,7 +153,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@@ -202,7 +186,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
switch (ether_type) {
case ETHERTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(p, length);
return (1);
#ifdef INET6
@@ -213,7 +197,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
- arp_print(gndo, p, length, caplen);
+ arp_print(p, length, caplen);
return (1);
case ETHERTYPE_DN:
@@ -266,44 +250,13 @@ ether_encap_print(u_short ether_type, const u_char *p,
return (1);
- case ETHERTYPE_JUMBO:
- ether_type = ntohs(*(u_int16_t *)(p));
- p += 2;
- length -= 2;
- caplen -= 2;
-
- if (ether_type > ETHERMTU) {
- if (eflag)
- printf("ethertype %s, ",
- tok2str(ethertype_values,"0x%04x", ether_type));
- goto recurse;
- }
-
- *extracted_ether_type = 0;
-
- if (llc_print(p, length, caplen, p - 16, p - 10,
- extracted_ether_type) == 0) {
- ether_hdr_print(p - 16, length + 2);
- }
-
- if (!xflag && !qflag)
- default_print(p - 16, caplen + 2);
-
- return (1);
-
- case ETHERTYPE_ISO:
- isoclns_print(p+1, length-1, length-1);
- return(1);
-
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
+ case ETHERTYPE_PPPOED2:
+ case ETHERTYPE_PPPOES2:
pppoe_print(p, length);
return (1);
- case ETHERTYPE_EAPOL:
- eap_print(gndo, p, length);
- return (1);
-
case ETHERTYPE_PPP:
if (length) {
printf(": ");
@@ -328,12 +281,3 @@ ether_encap_print(u_short ether_type, const u_char *p,
return (0);
}
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index d4112e1..e9aeddd 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 2004/03/17 23:24:37 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.61.2.2 2003/11/16 08:51:20 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -298,7 +300,7 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the FDDI header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c
index cc0f6ec..4e568b1 100644
--- a/contrib/tcpdump/print-fr.c
+++ b/contrib/tcpdump/print-fr.c
@@ -17,113 +17,108 @@
* 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 2005/04/06 21:32:39 mcr Exp $ (LBL)";
+static char rcsid[] =
+ "@(#)$Header: /home/ncvs/src/contrib/tcpdump/print-fr.c,v 1.1 1997/12/31 21:50:31 pst Exp $ (LBL)";
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+#ifdef PPP
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
#endif
+#include <net/if.h>
+#include <net/if_var.h>
-#include <tcpdump-stdinc.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
-#include <stdio.h>
-#include <string.h>
+#include <ctype.h>
+#include <netdb.h>
#include <pcap.h>
+#include <signal.h>
+#include <stdio.h>
-#include "addrtoname.h"
-#include "interface.h"
+#include <netinet/if_ether.h>
#include "ethertype.h"
-#include "nlpid.h"
-#include "extract.h"
-#include "oui.h"
-
-static void frf15_print(const u_char *, u_int);
-/*
- * the frame relay header has a variable length
- *
- * the EA bit determines if there is another byte
- * in the header
- *
- * minimum header length is 2 bytes
- * maximum header length is 4 bytes
- *
- * 7 6 5 4 3 2 1 0
- * +----+----+----+----+----+----+----+----+
- * | DLCI (6 bits) | CR | EA |
- * +----+----+----+----+----+----+----+----+
- * | DLCI (4 bits) |FECN|BECN| DE | EA |
- * +----+----+----+----+----+----+----+----+
- * | DLCI (7 bits) | EA |
- * +----+----+----+----+----+----+----+----+
- * | DLCI (6 bits) |SDLC| EA |
- * +----+----+----+----+----+----+----+----+
- */
+#include <net/ppp_defs.h>
+#include "interface.h"
+#include "addrtoname.h"
-#define FR_EA_BIT 0x01
-#define FR_CR_BIT 0x02000000
-#define FR_DE_BIT 0x00020000
-#define FR_BECN_BIT 0x00040000
-#define FR_FECN_BIT 0x00080000
-#define FR_SDLC_BIT 0x00000002
+void q933_print();
+#define FR_EA_BIT(p) ((p)&0x1)
+#define FR_DLCI(b0,b1) ((((b0)&0xFC)<<2)+(((b1)&0xF0)>>4))
-struct tok fr_header_flag_values[] = {
- { FR_CR_BIT, "C!" },
- { FR_DE_BIT, "DE" },
- { FR_BECN_BIT, "BECN" },
- { FR_FECN_BIT, "FECN" },
- { FR_SDLC_BIT, "sdlcore" },
- { 0, NULL }
+struct fr_nlpids {
+ u_short id;
+ char *name;
};
-
-/* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
- * save the flags dep. on address length
- */
-static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore,
- u_int *addr_len, u_int8_t *flags)
+/* find out how many bytes are there in a frame */
+int
+fr_addr_len(const u_char *p)
{
- if ((p[0] & FR_EA_BIT))
- return -1;
-
- *addr_len = 2;
- *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
-
- flags[0] = p[0] & 0x02; /* populate the first flag fields */
- flags[1] = p[1] & 0x0c;
-
- if (p[1] & FR_EA_BIT)
- return 0; /* 2-byte Q.922 address */
+ int i=0;
+
+ while (!FR_EA_BIT(p[i]) && i++ && !FR_EA_BIT(p[i+1])) i++;
+ return (i+1);
+}
- p += 2;
- (*addr_len)++; /* 3- or 4-byte Q.922 address */
- if ((p[0] & FR_EA_BIT) == 0) {
- *dlci = (*dlci << 7) | (p[0] >> 1);
- (*addr_len)++; /* 4-byte Q.922 address */
- p++;
- }
+/* the following is for framerelay */
+#define NLPID_LEN 1 /* NLPID is one byte long */
+#define NLPID_Q933 0x08
+#define NLPID_CLNP 0x81
+#define NLPID_ESIS 0x82
+#define NLPID_ISIS 0x83
+#define NLPID_CONS 0x84
+#define NLPID_IDRP 0x85
+#define NLPID_X25_ESIS 0x8a
+#define NLPID_IP 0xcc
- if ((p[0] & FR_EA_BIT) == 0)
- return -1; /* more than 4 bytes of Q.922 address? */
- flags[3] = p[0] & 0x02;
+static struct fr_nlpids fr_nlpids[256];
+static fr_nlpid_flag =0;
- if (p[0] & 0x02)
- *sdlcore = p[0] >> 2;
- else
- *dlci = (*dlci << 6) | (p[0] >> 2);
+void init_fr_nlpids()
+{
+ int i;
- return 0;
+ if (!fr_nlpid_flag) {
+ for (i=0; i < 256; i++) {
+ fr_nlpids[i].id = 0;
+ fr_nlpids[i].name = "Not Specified";
+ }
+ fr_nlpids[NLPID_Q933].name = "Q.933";
+ fr_nlpids[NLPID_CLNP].name = "CLNP";
+ fr_nlpids[NLPID_ESIS].name = "ESIS";
+ fr_nlpids[NLPID_ISIS].name = "ISIS";
+ fr_nlpids[NLPID_CONS].name = "CONS";
+ fr_nlpids[NLPID_IDRP].name = "IDRP";
+ fr_nlpids[NLPID_X25_ESIS].name = "X25_ESIS";
+ fr_nlpids[NLPID_IP].name = "IP";
+ }
+ fr_nlpid_flag = 1;
}
-/* Frame Relay packet structure, with flags and CRC removed
+/* Framerelay packet structure */
+/*
+ +---------------------------+
+ | flag (7E hexadecimal) |
+---------------------------+
| Q.922 Address* |
+-- --+
@@ -142,221 +137,136 @@ static int parse_q922_addr(const u_char *p, u_int *dlci, u_int *sdlcore,
| . |
| . |
+---------------------------+
+ | Frame Check Sequence |
+ +-- . --+
+ | (two octets) |
+ +---------------------------+
+ | flag (7E hexadecimal) |
+ +---------------------------+
* Q.922 addresses, as presently defined, are two octets and
contain a 10-bit DLCI. In some networks Q.922 addresses
may optionally be increased to three or four octets.
+
*/
-static u_int
-fr_hdrlen(const u_char *p, u_int addr_len, u_int caplen)
+#define FR_PROTOCOL(p) fr_protocol((p))
+
+int
+fr_hdrlen(const u_char *p)
{
- if ((caplen > addr_len + 1 /* UI */ + 1 /* pad */) &&
- !p[addr_len + 1] /* pad exist */)
- return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
- else
- return addr_len + 1 /* UI */ + 1 /* NLPID */;
+ int hlen;
+ hlen = fr_addr_len(p)+1; /* addr_len + 0x03 + padding */
+ if( p[hlen] )
+ return hlen;
+ else
+ return hlen+1;
}
-static void
-fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
+#define LAYER2_LEN(p) (fr_hdrlen((p))+NLPID_LEN)
+
+int
+fr_protocol(const u_char *p)
{
- if (qflag) {
- (void)printf("Q.922, DLCI %u, length %u: ",
- dlci,
- length);
- } else {
- if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
- addr_len,
- dlci,
- bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
- tok2str(nlpid_values,"unknown", nlpid),
- nlpid,
- length);
- else /* must be an ethertype */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
- addr_len,
- dlci,
- bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
- tok2str(ethertype_values, "unknown", nlpid),
- nlpid,
- length);
- }
+ int hlen;
+
+ hlen = fr_addr_len(p) + 1;
+ if (p[hlen]) /* check for padding */
+ return p[hlen];
+ else
+ return p[hlen+1];
}
-u_int
-fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+void
+fr_hdlc_print(const u_char *p, int length)
{
- register u_int length = h->len;
- register u_int caplen = h->caplen;
- u_int16_t extracted_ethertype;
- u_int32_t orgcode;
- register u_short et;
- u_int dlci;
- u_int sdlcore;
- u_int addr_len;
- u_int16_t nlpid;
- u_int hdr_len;
- u_int8_t flags[4];
-
- if (caplen < 4) { /* minimum frame header length */
- printf("[|fr]");
- return caplen;
- }
+ int proto;
+ int i;
+ int hlen;
- if (parse_q922_addr(p, &dlci, &sdlcore, &addr_len, flags)) {
- printf("Q.922, invalid address");
- return caplen;
- }
+ proto = FR_PROTOCOL(p);
- hdr_len = fr_hdrlen(p, addr_len, caplen);
+ init_fr_nlpids();
+ /* this is kinda kludge since it assumed that DLCI is two bytes. */
+ printf("%4d %02x%02x=DLCI(%d) ", length, p[0], p[1], FR_DLCI(p[0],p[1]));
+ printf("%02x %6s: ", proto, fr_nlpids[proto].name);
+}
- if (caplen < hdr_len) {
- printf("[|fr]");
- return caplen;
- }
- if (p[addr_len] != 0x03 && dlci != 0) {
- /* lets figure out if we have cisco style encapsulation: */
- extracted_ethertype = EXTRACT_16BITS(p+addr_len);
+void
+fr_if_print(u_char *user, const struct pcap_pkthdr *h,
+ register const u_char *p)
+{
+ register u_int length = h->len;
+ register u_int caplen = h->caplen;
+ int frame_relay = 0,
+ proto = FR_PROTOCOL(p);
- if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
- if (ether_encap_print(extracted_ethertype,
- p+addr_len+ETHERTYPE_LEN,
- length-addr_len-ETHERTYPE_LEN,
- caplen-addr_len-ETHERTYPE_LEN,
- &extracted_ethertype) == 0)
- /* ether_type not known, probably it wasn't one */
- printf("UI %02x! ", p[addr_len]);
- else
- return hdr_len;
- }
+ ts_print(&h->ts);
- if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */
- if (addr_len != 3)
- printf("Pad! ");
- } else if (addr_len == 3)
- printf("No pad! ");
+ if (caplen < fr_hdrlen(p)) {
+ printf("[|fr]");
+ goto out;
+ }
- nlpid = p[hdr_len - 1];
+ /*
+ * Some printers want to get back at the link level addresses,
+ * and/or check that they're not walking off the end of the packet.
+ * Rather than pass them all the way down, we set these globals.
+ */
+ packetp = p;
+ snapend = p + caplen;
if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, nlpid);
+ fr_hdlc_print(p, length);
- p += hdr_len;
- length -= hdr_len;
- caplen -= hdr_len;
+ length = length - (fr_hdrlen(p) + NLPID_LEN);
- switch (nlpid) {
- case NLPID_IP:
- ip_print(gndo, p, length);
- break;
-#ifdef INET6
- case NLPID_IP6:
- ip6_print(p, length);
+ switch(FR_PROTOCOL(p)) {
+ case NLPID_IP:
+ case ETHERTYPE_IP:
+ ip_print((const u_char *)(p + LAYER2_LEN(p)), length);
break;
-#endif
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
- isoclns_print(p-1, length+1, caplen+1); /* OSI printers need the NLPID field */
+ isoclns_print((const u_char *)(p + LAYER2_LEN(p)), length,
+ caplen, "000000", "000000");
break;
-
- case NLPID_SNAP:
- orgcode = EXTRACT_24BITS(p);
- et = EXTRACT_16BITS(p + 3);
-
- if (eflag)
- (void)printf("SNAP, oui %s (0x%06x), ethertype %s (0x%04x): ",
- tok2str(oui_values,"Unknown",orgcode),
- orgcode,
- tok2str(ethertype_values,"Unknown", et),
- et);
-
- if (snap_print((const u_char *)(p + 5), length - 5,
- caplen - 5, &extracted_ethertype, orgcode, et,
- 0) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- fr_hdr_print(length + hdr_len, hdr_len,
- dlci, flags, nlpid);
- if (!xflag && !qflag)
- default_print(p - hdr_len, caplen + hdr_len);
- }
- break;
-
- case NLPID_Q933:
- q933_print(p, length);
+ case NLPID_Q933:
+ q933_print((const u_char *)(p + LAYER2_LEN(p)), length);
break;
-
- case NLPID_MFR:
- frf15_print(p, length);
- break;
-
default:
- if (!eflag)
- fr_hdr_print(length + hdr_len, addr_len,
- dlci, flags, nlpid);
- if (!xflag)
- default_print(p, caplen);
+ if(!eflag)
+ fr_hdlc_print(p, length);
+ if(!xflag)
+ default_print((const u_char *)(p + LAYER2_LEN(p)),
+ caplen - LAYER2_LEN(p));
}
- return hdr_len;
+ if (xflag)
+ default_print((const u_char *)(p + LAYER2_LEN(p)),
+ caplen - LAYER2_LEN(p));
+out:
+ putchar('\n');
}
+#else
+#include <sys/types.h>
+#include <sys/time.h>
-/* an NLPID of 0xb1 indicates a 2-byte
- * FRF.15 header
- *
- * 7 6 5 4 3 2 1 0
- * +----+----+----+----+----+----+----+----+
- * ~ Q.922 header ~
- * +----+----+----+----+----+----+----+----+
- * | NLPID (8 bits) | NLPID=0xb1
- * +----+----+----+----+----+----+----+----+
- * | B | E | C |seq. (high 4 bits) | R |
- * +----+----+----+----+----+----+----+----+
- * | sequence (low 8 bits) |
- * +----+----+----+----+----+----+----+----+
- */
-
-struct tok frf15_flag_values[] = {
- { 0x80, "Begin" },
- { 0x40, "End" },
- { 0x20, "Control" },
- { 0, NULL }
-};
-
-#define FR_FRF15_FRAGTYPE 0x01
-
-static void
-frf15_print (const u_char *p, u_int length) {
-
- u_int16_t sequence_num, flags;
-
- flags = p[0]&0xe0;
- sequence_num = (p[0]&0x1e)<<7 | p[1];
-
- printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
- sequence_num,
- bittok2str(frf15_flag_values,"none",flags),
- flags&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
- length);
-
-/* TODO:
- * depending on all permutations of the B, E and C bit
- * dig as deep as we can - e.g. on the first (B) fragment
- * there is enough payload to print the IP header
- * on non (B) fragments it depends if the fragmentation
- * model is end-to-end or interface based wether we want to print
- * another Q.922 header
- */
+#include <stdio.h>
+#include "interface.h"
+u_int
+fr_if_print(const struct pcap_pkthdr *h, const u_char *p)
+{
+ error("not configured for ppp");
+ /* NOTREACHED */
}
+#endif
/*
* Q.933 decoding portion for framerelay specific.
@@ -405,205 +315,112 @@ frf15_print (const u_char *p, u_int length) {
#define MSG_TYPE_STATUS 0x7D
#define MSG_TYPE_STATUS_ENQ 0x75
-struct tok fr_q933_msg_values[] = {
- { MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" },
- { MSG_TYPE_ALERT, "Alert" },
- { MSG_TYPE_CALL_PROCEEDING, "Call proceeding" },
- { MSG_TYPE_CONNECT, "Connect" },
- { MSG_TYPE_CONNECT_ACK, "Connect ACK" },
- { MSG_TYPE_PROGRESS, "Progress" },
- { MSG_TYPE_SETUP, "Setup" },
- { MSG_TYPE_DISCONNECT, "Disconnect" },
- { MSG_TYPE_RELEASE, "Release" },
- { MSG_TYPE_RELEASE_COMPLETE, "Release Complete" },
- { MSG_TYPE_RESTART, "Restart" },
- { MSG_TYPE_RESTART_ACK, "Restart ACK" },
- { MSG_TYPE_STATUS, "Status Reply" },
- { MSG_TYPE_STATUS_ENQ, "Status Enquiry" },
- { 0, NULL }
-};
+#define ONE_BYTE_IE_MASK 0xF0
-#define MSG_ANSI_LOCKING_SHIFT 0x95
-
-#define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
-#define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
-#define FR_LMI_ANSI_LINK_VERIFY_IE 0x03
-#define FR_LMI_ANSI_PVC_STATUS_IE 0x07
-
-#define FR_LMI_CCITT_REPORT_TYPE_IE 0x51
-#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
-#define FR_LMI_CCITT_PVC_STATUS_IE 0x57
-
-struct tok fr_q933_ie_values_codeset5[] = {
- { FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" },
- { FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" },
- { FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" },
- { FR_LMI_ANSI_PVC_STATUS_IE, "ANSI PVC Status" },
- { FR_LMI_CCITT_REPORT_TYPE_IE, "CCITT Report Type" },
- { FR_LMI_CCITT_LINK_VERIFY_IE, "CCITT Link Verify" },
- { FR_LMI_CCITT_PVC_STATUS_IE, "CCITT PVC Status" },
- { 0, NULL }
+/* See L2 protocol ID picture above */
+struct q933_header {
+ u_char call_ref; /* usually is 0 for framerelay PVC */
+ u_char msg_type;
};
-#define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0
-#define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
-#define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
+#define REPORT_TYPE_IE 0x01
+#define LINK_VERIFY_IE_91 0x19
+#define LINK_VERIFY_IE_94 0x03
+#define PVC_STATUS_IE 0x07
-struct tok fr_lmi_report_type_ie_values[] = {
- { FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" },
- { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" },
- { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" },
- { 0, NULL }
-};
+#define MAX_IE_SIZE
-/* array of 16 codepages - currently we only support codepage 5 */
-static struct tok *fr_q933_ie_codesets[] = {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- fr_q933_ie_values_codeset5,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
+struct common_ie_header {
+ u_char ie_id;
+ u_char ie_len;
};
+#define FULL_STATUS 0
+#define LINK_VERIFY 1
+#define ASYNC_PVC 2
-struct common_ie_header {
- u_int8_t ie_id;
- u_int8_t ie_len;
-};
void
-q933_print(const u_char *p, u_int length)
+q933_print(const u_char *p, int length)
{
+ struct q933_header *header = (struct q933_header *)(p+1);
const u_char *ptemp = p;
+ int ie_type, ie_len;
+ char *decode_str, temp_str[255];
struct common_ie_header *ie_p;
- int olen;
- int is_ansi = 0;
- u_int dlci,codeset;
-
- if (length < 9) { /* shortest: Q.933a LINK VERIFY */
- printf("[|q.933]");
- return;
- }
-
- codeset = p[2]&0x0f; /* extract the codeset */
-
- if (p[2] == MSG_ANSI_LOCKING_SHIFT)
- is_ansi = 1;
- printf("%s", eflag ? "" : "Q.933, ");
/* printing out header part */
- printf(is_ansi ? "ANSI" : "CCITT ");
-
- if (p[0])
- printf(", Call Ref: 0x%02x", p[0]);
-
- if (vflag)
- printf(", %s (0x%02x), length %u",
- tok2str(fr_q933_msg_values,"unknown message",p[1]),
- p[1],
- length);
- else
- printf(", %s",
- tok2str(fr_q933_msg_values,"unknown message 0x%02x",p[1]));
-
- olen = length; /* preserve the original length for non verbose mode */
-
- if (length < (u_int)(2 - is_ansi)) {
- printf("[|q.933]");
- return;
+ printf("Call Ref: %02x, MSG Type: %02x",
+ header->call_ref, header->msg_type);
+ switch(header->msg_type) {
+ case MSG_TYPE_STATUS:
+ decode_str = "STATUS REPLY";
+ break;
+ case MSG_TYPE_STATUS_ENQ:
+ decode_str = "STATUS ENQUIRY";
+ break;
+ default:
+ decode_str = "UNKNOWN MSG Type";
}
- length -= 2 - is_ansi;
- ptemp += 2 + is_ansi;
+ printf(" %s\n", decode_str);
+
+ length = length - 3;
+ ptemp = ptemp + 3;
/* Loop through the rest of IE */
- while (length > sizeof(struct common_ie_header)) {
+ while( length > 0 ) {
+ if( ptemp[0] & ONE_BYTE_IE_MASK ) {
+ ie_len = 1;
+ printf("\t\tOne byte IE: %02x, Content %02x\n",
+ (*ptemp & 0x70)>>4, (*ptemp & 0x0F));
+ length--;
+ ptemp++;
+ }
+ else { /* Multi-byte IE */
ie_p = (struct common_ie_header *)ptemp;
- if (length < sizeof(struct common_ie_header) ||
- length < sizeof(struct common_ie_header) + ie_p->ie_len) {
- if (vflag) /* not bark if there is just a trailer */
- printf("\n[|q.933]");
- else
- printf(", length %u",olen);
- return;
+ switch (ie_p->ie_id) {
+ case REPORT_TYPE_IE:
+ switch(ptemp[2]) {
+ case FULL_STATUS:
+ decode_str = "FULL STATUS";
+ break;
+ case LINK_VERIFY:
+ decode_str = "LINK VERIFY";
+ break;
+ case ASYNC_PVC:
+ decode_str = "Async PVC Status";
+ break;
+ default:
+ decode_str = "Reserved Value";
+ }
+ break;
+ case LINK_VERIFY_IE_91:
+ case LINK_VERIFY_IE_94:
+ snprintf(temp_str, sizeof(temp_str), "TX Seq: %3d, RX Seq: %3d",
+ ptemp[2], ptemp[3]);
+ decode_str = temp_str;
+ break;
+ case PVC_STATUS_IE:
+ snprintf(temp_str,sizeof(temp_str), "DLCI %d: status %s %s",
+ ((ptemp[2]&0x3f)<<4)+ ((ptemp[3]&0x78)>>3),
+ ptemp[4] & 0x8 ?"new,":" ",
+ ptemp[4] & 0x2 ?"Active":"Inactive");
+ break;
+ default:
+ decode_str = "Non-decoded Value";
}
-
- /* lets do the full IE parsing only in verbose mode
- * however some IEs (DLCI Status, Link Verify)
- * are also intereststing in non-verbose mode */
- if (vflag)
- printf("\n\t%s IE (%u), length %u: ",
- tok2str(fr_q933_ie_codesets[codeset],"unknown",ie_p->ie_id),
- ie_p->ie_id,
- ie_p->ie_len);
-
- switch (ie_p->ie_id) {
-
- case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
- case FR_LMI_CCITT_REPORT_TYPE_IE:
- if (vflag)
- printf("%s (%u)",
- tok2str(fr_lmi_report_type_ie_values,"unknown",ptemp[2]),
- ptemp[2]);
- break;
-
- case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
- case FR_LMI_CCITT_LINK_VERIFY_IE:
- case FR_LMI_ANSI_LINK_VERIFY_IE_91:
- if (!vflag)
- printf(", ");
- printf("TX Seq: %3d, RX Seq: %3d", ptemp[2], ptemp[3]);
- break;
- case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
- case FR_LMI_CCITT_PVC_STATUS_IE:
- if (!vflag)
- printf(", ");
- /* now parse the DLCI information element. */
- if ((ie_p->ie_len < 3) ||
- (ptemp[2] & 0x80) ||
- ((ie_p->ie_len == 3) && !(ptemp[3] & 0x80)) ||
- ((ie_p->ie_len == 4) && ((ptemp[3] & 0x80) || !(ptemp[4] & 0x80))) ||
- ((ie_p->ie_len == 5) && ((ptemp[3] & 0x80) || (ptemp[4] & 0x80) ||
- !(ptemp[5] & 0x80))) ||
- (ie_p->ie_len > 5) ||
- !(ptemp[ie_p->ie_len + 1] & 0x80))
- printf("Invalid DLCI IE");
-
- dlci = ((ptemp[2] & 0x3F) << 4) | ((ptemp[3] & 0x78) >> 3);
- if (ie_p->ie_len == 4)
- dlci = (dlci << 6) | ((ptemp[4] & 0x7E) >> 1);
- else if (ie_p->ie_len == 5)
- dlci = (dlci << 13) | (ptemp[4] & 0x7F) | ((ptemp[5] & 0x7E) >> 1);
-
- printf("DLCI %u: status %s%s", dlci,
- ptemp[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
- ptemp[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
- break;
-
- default:
- if (vflag <= 1)
- print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
- break;
- }
-
- /* do we want to see a hexdump of the IE ? */
- if (vflag> 1)
- print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len);
-
+ printf("\t\tIE: %02X Len: %d, %s\n",
+ ie_p->ie_id, ie_p->ie_len, decode_str);
length = length - ie_p->ie_len - 2;
ptemp = ptemp + ie_p->ie_len + 2;
+ }
}
- if (!vflag)
- printf(", length %u",olen);
+
}
+
+
+
+
+
+
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index aa58bda..ddaf280 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 2005/04/06 21:32:40 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.73.2.3 2004/03/24 00:56:34 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -40,7 +42,6 @@ static const char rcsid[] _U_ =
#include "ip.h"
#include "udp.h"
#include "ipproto.h"
-#include "mpls.h"
/*
* Interface Control Message Protocol Definitions.
@@ -86,12 +87,6 @@ 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;
@@ -101,14 +96,8 @@ 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)
-#define ICMP_MPLS_EXT_VERSION 2
-
/*
* Lower bounds on packet lengths for various types.
* For the error advice packets must first insure that the
@@ -118,7 +107,6 @@ struct icmp {
* ip header length.
*/
#define ICMP_MINLEN 8 /* abs minimum */
-#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 */
@@ -172,8 +160,6 @@ struct icmp {
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
-#define ICMP_MPLS_EXT_TYPE(type) \
- ((type) == ICMP_UNREACH || (type) == ICMP_TIMXCEED)
/* rfc1700 */
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
@@ -276,19 +262,6 @@ struct id_rdiscovery {
u_int32_t ird_pref;
};
-/* draft-bonica-icmp-mpls-02 */
-struct icmp_mpls_ext_object_header_t {
- u_int8_t length[2];
- u_int8_t class_num;
- u_int8_t ctype;
-};
-
-static const struct tok icmp_mpls_ext_obj_values[] = {
- { 1, "MPLS Stack Entry" },
- { 2, "Extended Payload" },
- { 0, NULL}
-};
-
void
icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
{
@@ -298,10 +271,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const char *str, *fmt;
const struct ip *oip;
const struct udphdr *ouh;
- const u_int8_t *obj_tptr;
- u_int32_t raw_label;
- 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;
+ u_int hlen, dport, mtu;
char buf[MAXHOSTNAMELEN + 100];
dp = (struct icmp *)bp;
@@ -509,7 +479,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
break;
}
- (void)printf("ICMP %s, length %u", str, plen);
+ (void)printf("icmp %d: %s", plen, str);
if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
u_int16_t sum, icmp_sum;
if (TTEST2(*bp, plen)) {
@@ -522,88 +492,13 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
}
}
}
- if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
+ if (vflag > 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
bp += 8;
- (void)printf("\n\t");
+ (void)printf(" for ");
ip = (struct ip *)bp;
snaplen = snapend - bp;
- ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
+ ip_print(bp, EXTRACT_16BITS(&ip->ip_len));
}
-
- if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
-
- 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(*(dp->icmp_mpls_ext_version)) != ICMP_MPLS_EXT_VERSION) {
- printf(" packet not supported");
- return;
- }
-
- hlen = plen - ICMP_EXTD_MINLEN;
- 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 *)dp->icmp_mpls_ext_data;
-
- while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
-
- icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
- TCHECK(*icmp_mpls_ext_object_header);
- obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
- obj_class_num = icmp_mpls_ext_object_header->class_num;
- obj_ctype = icmp_mpls_ext_object_header->ctype;
- obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
-
- printf("\n\t %s Object (%u), Class-Type: %u, length %u",
- tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
- obj_class_num,
- obj_ctype,
- obj_tlen);
-
- hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
- 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) {
- case 1:
- switch(obj_ctype) {
- case 1:
- TCHECK2(*obj_tptr, 4);
- raw_label = EXTRACT_32BITS(obj_tptr);
- printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
- if (MPLS_STACK(raw_label))
- printf(", [S]");
- printf(", ttl %u", MPLS_TTL(raw_label));
- break;
- default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
- }
- break;
-
- /*
- * FIXME those are the defined objects that lack a decoder
- * you are welcome to contribute code ;-)
- */
- case 2:
- default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
- break;
- }
- if (hlen < obj_tlen)
- break;
- hlen -= obj_tlen;
- obj_tptr += obj_tlen;
- }
- }
-
return;
trunc:
fputs("[|icmp]", stdout);
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 96739fe..ca4c96d 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 2005/04/07 00:28:17 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.128.2.6 2004/03/24 09:01:39 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -41,23 +43,11 @@ static const char rcsid[] _U_ =
#include "ip.h"
#include "ipproto.h"
-struct tok ip_option_values[] = {
- { IPOPT_EOL, "EOL" },
- { IPOPT_NOP, "NOP" },
- { IPOPT_TS, "timestamp" },
- { IPOPT_SECURITY, "security" },
- { IPOPT_RR, "RR" },
- { IPOPT_SSRR, "SSRR" },
- { IPOPT_LSRR, "LSRR" },
- { IPOPT_RA, "RA" },
- { 0, NULL }
-};
-
/*
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
static void
-ip_printroute(register const u_char *cp, u_int length)
+ip_printroute(const char *type, register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
@@ -66,21 +56,25 @@ ip_printroute(register const u_char *cp, u_int length)
printf(" [bad length %u]", length);
return;
}
+ printf(" %s{", type);
if ((length + 1) & 3)
printf(" [bad length %u]", length);
ptr = cp[2] - 1;
if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
printf(" [bad ptr %u]", cp[2]);
+ type = "";
for (len = 3; len < length; len += 4) {
- printf("%s", ipaddr_string(&cp[len]));
- if (ptr > len)
- printf (", ");
+ if (ptr == len)
+ type = "#";
+ printf("%s%s", type, ipaddr_string(&cp[len]));
+ type = " ";
}
+ printf("%s}", ptr == len? "#" : "");
}
/*
- * If source-routing is present and valid, return the final destination.
+ * If source-routing is present, return the final destination.
* Otherwise, return IP destination.
*
* This is used for UDP and TCP pseudo-header in the checksum
@@ -102,15 +96,14 @@ ip_finddst(const struct ip *ip)
TCHECK(*cp);
tt = *cp;
- if (tt == IPOPT_EOL)
- break;
- else if (tt == IPOPT_NOP)
+ if (tt == IPOPT_NOP || tt == IPOPT_EOL)
len = 1;
else {
TCHECK(cp[1]);
len = cp[1];
- if (len < 2)
- break;
+ }
+ if (len < 2) {
+ return 0;
}
TCHECK2(*cp, len);
switch (tt) {
@@ -118,14 +111,15 @@ ip_finddst(const struct ip *ip)
case IPOPT_SSRR:
case IPOPT_LSRR:
if (len < 7)
- break;
+ return 0;
memcpy(&retval, cp + len - 4, 4);
return retval;
}
}
+ return ip->ip_dst.s_addr;
+
trunc:
- memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
- return retval;
+ return 0;
}
static void
@@ -196,56 +190,75 @@ done:
static void
ip_optprint(register const u_char *cp, u_int length)
{
- register u_int option_len;
+ register u_int len;
- for (; length > 0; cp += option_len, length -= option_len) {
- u_int option_code;
+ for (; length > 0; cp += len, length -= len) {
+ int tt;
TCHECK(*cp);
- option_code = *cp;
-
- if (option_code == IPOPT_NOP ||
- option_code == IPOPT_EOL)
- option_len = 1;
-
+ tt = *cp;
+ if (tt == IPOPT_NOP || tt == IPOPT_EOL)
+ len = 1;
else {
TCHECK(cp[1]);
- option_len = cp[1];
+ len = cp[1];
+ if (len < 2) {
+ printf("[|ip op len %d]", len);
+ return;
+ }
+ TCHECK2(*cp, len);
}
+ switch (tt) {
- 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);
-
- switch (option_code) {
case IPOPT_EOL:
+ printf(" EOL");
+ if (length > 1)
+ printf("-%d", length - 1);
return;
+ case IPOPT_NOP:
+ printf(" NOP");
+ break;
+
case IPOPT_TS:
- ip_printts(cp, option_len);
+ ip_printts(cp, len);
+ break;
+
+#ifndef IPOPT_SECURITY
+#define IPOPT_SECURITY 130
+#endif /* IPOPT_SECURITY */
+ case IPOPT_SECURITY:
+ printf(" SECURITY{%d}", len);
+ break;
+
+ case IPOPT_RR:
+ ip_printroute("RR", cp, len);
break;
- case IPOPT_RR: /* fall through */
case IPOPT_SSRR:
+ ip_printroute("SSRR", cp, len);
+ break;
+
case IPOPT_LSRR:
- ip_printroute( cp, option_len);
+ ip_printroute("LSRR", cp, len);
break;
+#ifndef IPOPT_RA
+#define IPOPT_RA 148 /* router alert */
+#endif
case IPOPT_RA:
- TCHECK(cp[3]);
- if (EXTRACT_16BITS(&cp[2]) != 0)
- printf("value %u", EXTRACT_16BITS(&cp[2]));
+ printf(" RA");
+ if (len != 4)
+ printf("{%d}", len);
+ else {
+ TCHECK(cp[3]);
+ if (cp[2] || cp[3])
+ printf("%d.%d", cp[2], cp[3]);
+ }
break;
- case IPOPT_NOP: /* nothing to print - fall through */
- case IPOPT_SECURITY:
default:
+ printf(" IPOPT-%d{%d}", cp[0], len);
break;
}
}
@@ -356,255 +369,70 @@ static struct tok ip_frag_values[] = {
{ 0, NULL }
};
-struct ip_print_demux_state {
- const struct ip *ip;
- const u_char *cp;
- u_int len, off;
- u_char nh;
- int advance;
-};
-
-static void
-ip_print_demux(netdissect_options *ndo,
- struct ip_print_demux_state *ipds)
-{
- struct protoent *proto;
-
-again:
- switch (ipds->nh) {
-
- case IPPROTO_AH:
- ipds->nh = *ipds->cp;
- ipds->advance = ah_print(ipds->cp);
- if (ipds->advance <= 0)
- break;
- ipds->cp += ipds->advance;
- ipds->len -= ipds->advance;
- goto again;
-
- case IPPROTO_ESP:
- {
- int enh, padlen;
- ipds->advance = esp_print(ndo, ipds->cp, ipds->len,
- (const u_char *)ipds->ip,
- &enh, &padlen);
- if (ipds->advance <= 0)
- break;
- ipds->cp += ipds->advance;
- ipds->len -= ipds->advance + padlen;
- ipds->nh = enh & 0xff;
- goto again;
- }
-
- case IPPROTO_IPCOMP:
- {
- int enh;
- ipds->advance = ipcomp_print(ipds->cp, &enh);
- if (ipds->advance <= 0)
- break;
- ipds->cp += ipds->advance;
- ipds->len -= ipds->advance;
- ipds->nh = enh & 0xff;
- goto again;
- }
-
- case IPPROTO_SCTP:
- sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
- break;
-
- case IPPROTO_TCP:
- tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
- (ipds->off &~ 0x6000));
- break;
-
- case IPPROTO_UDP:
- udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
- (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 & 0x3fff));
- break;
-
- case IPPROTO_PIGP:
- /*
- * XXX - the current IANA protocol number assignments
- * page lists 9 as "any private interior gateway
- * (used by Cisco for their IGRP)" and 88 as
- * "EIGRP" from Cisco.
- *
- * Recent BSD <netinet/in.h> headers define
- * IP_PROTO_PIGP as 9 and IP_PROTO_IGRP as 88.
- * We define IP_PROTO_PIGP as 9 and
- * IP_PROTO_EIGRP as 88; those names better
- * match was the current protocol number
- * assignments say.
- */
- igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
- break;
-
- case IPPROTO_EIGRP:
- eigrp_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_ND:
- ND_PRINT((ndo, " nd %d", ipds->len));
- break;
-
- case IPPROTO_EGP:
- egp_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_OSPF:
- ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
- break;
-
- case IPPROTO_IGMP:
- igmp_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_IPV4:
- /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
- ip_print(gndo, ipds->cp, ipds->len);
- if (! vflag) {
- ND_PRINT((ndo, " (ipip-proto-4)"));
- return;
- }
- break;
-
-#ifdef INET6
- case IPPROTO_IPV6:
- /* ip6-in-ip encapsulation */
- ip6_print(ipds->cp, ipds->len);
- break;
-#endif /*INET6*/
-
- case IPPROTO_RSVP:
- rsvp_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_GRE:
- /* do it */
- gre_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_MOBILE:
- mobile_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_PIM:
- pim_print(ipds->cp, ipds->len);
- break;
-
- case IPPROTO_VRRP:
- vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
- break;
-
- default:
- if ((proto = getprotobynumber(ipds->nh)) != NULL)
- ND_PRINT((ndo, " %s", proto->p_name));
- else
- ND_PRINT((ndo, " ip-proto-%d", ipds->nh));
- ND_PRINT((ndo, " %d", ipds->len));
- break;
- }
-}
-
-void
-ip_print_inner(netdissect_options *ndo,
- const u_char *bp,
- u_int length, u_int nh,
- const u_char *bp2)
-{
- struct ip_print_demux_state ipd;
-
- ipd.ip = (const struct ip *)bp2;
- ipd.cp = bp;
- ipd.len = length;
- ipd.off = 0;
- ipd.nh = nh;
- ipd.advance = 0;
-
- ip_print_demux(ndo, &ipd);
-}
-
-
/*
* print an IP datagram.
*/
void
-ip_print(netdissect_options *ndo,
- const u_char *bp,
- u_int length)
+ip_print(register const u_char *bp, register u_int length)
{
- struct ip_print_demux_state ipd;
- struct ip_print_demux_state *ipds=&ipd;
+ register const struct ip *ip;
+ register u_int hlen, len, len0, off;
const u_char *ipend;
- u_int hlen;
- u_int16_t sum, ip_sum;
+ register const u_char *cp;
+ u_char nh;
+ int advance;
struct protoent *proto;
+ u_int16_t sum, ip_sum;
- ipds->ip = (const struct ip *)bp;
- if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
- printf("IP%u ", IP_V(ipds->ip));
- if (IP_V(ipds->ip) == 6)
+ ip = (const struct ip *)bp;
+ if (IP_V(ip) != 4) { /* print version if != 4 */
+ printf("IP%u ", IP_V(ip));
+ if (IP_V(ip) == 6)
printf(", wrong link-layer encapsulation");
}
- else if (!eflag)
+ else
printf("IP ");
- if ((u_char *)(ipds->ip + 1) > snapend) {
+ if ((u_char *)(ip + 1) > snapend) {
printf("[|ip]");
return;
}
if (length < sizeof (struct ip)) {
- (void)printf("truncated-ip %u", length);
+ (void)printf("truncated-ip %d", length);
return;
}
- hlen = IP_HL(ipds->ip) * 4;
+ hlen = IP_HL(ip) * 4;
if (hlen < sizeof (struct ip)) {
(void)printf("bad-hlen %u", hlen);
return;
}
- ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
- if (length < ipds->len)
+ len = EXTRACT_16BITS(&ip->ip_len);
+ if (length < len)
(void)printf("truncated-ip - %u bytes missing! ",
- ipds->len - length);
- if (ipds->len < hlen) {
-#ifdef GUESS_TSO
- if (ipds->len) {
- (void)printf("bad-len %u", ipds->len);
- return;
- }
- else {
- /* we guess that it is a TSO send */
- ipds->len = length;
- }
-#else
- (void)printf("bad-len %u", ipds->len);
- return;
-#endif /* GUESS_TSO */
+ len - length);
+ if (len < hlen) {
+ (void)printf("bad-len %u", len);
+ return;
}
/*
* Cut off the snapshot length to the end of the IP payload.
*/
- ipend = bp + ipds->len;
+ ipend = bp + len;
if (ipend < snapend)
snapend = ipend;
- ipds->len -= hlen;
+ len -= hlen;
+ len0 = len;
- ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
+ off = EXTRACT_16BITS(&ip->ip_off);
if (vflag) {
- (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
+ (void)printf("(tos 0x%x", (int)ip->ip_tos);
/* ECN bits */
- if (ipds->ip->ip_tos & 0x03) {
- switch (ipds->ip->ip_tos & 0x03) {
+ if (ip->ip_tos & 0x03) {
+ switch (ip->ip_tos & 0x03) {
case 1:
(void)printf(",ECT(1)");
break;
@@ -616,8 +444,8 @@ ip_print(netdissect_options *ndo,
}
}
- if (ipds->ip->ip_ttl >= 1)
- (void)printf(", ttl %3u", ipds->ip->ip_ttl);
+ if (ip->ip_ttl >= 1)
+ (void)printf(", ttl %3u", ip->ip_ttl);
/*
* for the firewall guys, print id, offset.
@@ -625,25 +453,23 @@ 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)",
- EXTRACT_16BITS(&ipds->ip->ip_id),
- (ipds->off & 0x1fff) * 8,
- bittok2str(ip_frag_values, "none", ipds->off&0xe000 ),
- tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
- ipds->ip->ip_p);
+ (void)printf(", id %u, offset %u, flags [%s]",
+ EXTRACT_16BITS(&ip->ip_id),
+ (off & 0x1fff) * 8,
+ bittok2str(ip_frag_values, "none", off & 0xe000 ));
- (void)printf(", length: %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+ (void)printf(", length: %u", EXTRACT_16BITS(&ip->ip_len));
if ((hlen - sizeof(struct ip)) > 0) {
- printf(", options ( ");
- ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+ (void)printf(", optlength: %u (", hlen - (u_int)sizeof(struct ip));
+ ip_optprint((u_char *)(ip + 1), hlen - sizeof(struct ip));
printf(" )");
}
- if ((u_char *)ipds->ip + hlen <= snapend) {
- sum = in_cksum((const u_short *)ipds->ip, hlen, 0);
+ if ((u_char *)ip + hlen <= snapend) {
+ sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
- ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
+ ip_sum = EXTRACT_16BITS(&ip->ip_sum);
(void)printf(", bad cksum %x (->%x)!", ip_sum,
in_cksum_shouldbe(ip_sum, sum));
}
@@ -656,17 +482,133 @@ ip_print(netdissect_options *ndo,
* If this is fragment zero, hand it to the next higher
* level protocol.
*/
- if ((ipds->off & 0x1fff) == 0) {
- ipds->cp = (const u_char *)ipds->ip + hlen;
- ipds->nh = ipds->ip->ip_p;
-
- if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
- ipds->nh != IPPROTO_SCTP) {
- (void)printf("%s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
+ if ((off & 0x1fff) == 0) {
+ cp = (const u_char *)ip + hlen;
+ nh = ip->ip_p;
+
+ if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
+ nh != IPPROTO_SCTP) {
+ (void)printf("%s > %s: ", ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ }
+again:
+ switch (nh) {
+
+ case IPPROTO_AH:
+ nh = *cp;
+ advance = ah_print(cp);
+ if (advance <= 0)
+ break;
+ cp += advance;
+ len -= advance;
+ goto again;
+
+ case IPPROTO_ESP:
+ {
+ int enh, padlen;
+ advance = esp_print(cp, (const u_char *)ip, &enh, &padlen);
+ if (advance <= 0)
+ break;
+ cp += advance;
+ len -= advance + padlen;
+ nh = enh & 0xff;
+ goto again;
+ }
+
+ case IPPROTO_IPCOMP:
+ {
+ int enh;
+ advance = ipcomp_print(cp, &enh);
+ if (advance <= 0)
+ break;
+ cp += advance;
+ len -= advance;
+ nh = enh & 0xff;
+ goto again;
+ }
+
+ case IPPROTO_SCTP:
+ sctp_print(cp, (const u_char *)ip, len);
+ break;
+
+ case IPPROTO_TCP:
+ tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
+ break;
+
+ case IPPROTO_UDP:
+ udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
+ break;
+
+ case IPPROTO_ICMP:
+ /* pass on the MF bit plus the offset to detect fragments */
+ icmp_print(cp, len, (const u_char *)ip, (off & 0x3fff));
+ break;
+
+ case IPPROTO_IGRP:
+ igrp_print(cp, len, (const u_char *)ip);
+ break;
+
+ case IPPROTO_ND:
+ (void)printf(" nd %d", len);
+ break;
+
+ case IPPROTO_EGP:
+ egp_print(cp);
+ break;
+
+ case IPPROTO_OSPF:
+ ospf_print(cp, len, (const u_char *)ip);
+ break;
+
+ case IPPROTO_IGMP:
+ igmp_print(cp, len);
+ break;
+
+ case IPPROTO_IPV4:
+ /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
+ ip_print(cp, len);
+ if (! vflag) {
+ printf(" (ipip-proto-4)");
+ return;
+ }
+ break;
+
+#ifdef INET6
+ case IPPROTO_IPV6:
+ /* ip6-in-ip encapsulation */
+ ip6_print(cp, len);
+ break;
+#endif /*INET6*/
+
+ case IPPROTO_RSVP:
+ rsvp_print(cp, len);
+ break;
+
+ case IPPROTO_GRE:
+ /* do it */
+ gre_print(cp, len);
+ break;
+
+ case IPPROTO_MOBILE:
+ mobile_print(cp, len);
+ break;
+
+ case IPPROTO_PIM:
+ pim_print(cp, len);
+ break;
+
+ case IPPROTO_VRRP:
+ vrrp_print(cp, len, ip->ip_ttl);
+ break;
+
+ default:
+ if ((proto = getprotobynumber(nh)) != NULL)
+ (void)printf(" %s", proto->p_name);
+ else
+ (void)printf(" ip-proto-%d", nh);
+ printf(" %d", len);
+ break;
}
- ip_print_demux(ndo, ipds);
} else {
/* Ultra quiet now means that all this stuff should be suppressed */
if (qflag > 1) return;
@@ -676,13 +618,13 @@ ip_print(netdissect_options *ndo,
* next level protocol header. print the ip addr
* and the protocol.
*/
- if (ipds->off & 0x1fff) {
- (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- if ((proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
+ if (off & 0x1fff) {
+ (void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ if ((proto = getprotobynumber(ip->ip_p)) != NULL)
(void)printf(" %s", proto->p_name);
else
- (void)printf(" ip-proto-%d", ipds->ip->ip_p);
+ (void)printf(" ip-proto-%d", ip->ip_p);
}
}
}
@@ -700,7 +642,7 @@ ipN_print(register const u_char *bp, register u_int length)
memcpy (&hdr, (char *)ip, 4);
switch (IP_V(&hdr)) {
case 4:
- ip_print (gndo, bp, length);
+ ip_print (bp, length);
return;
#ifdef INET6
case 6:
@@ -713,11 +655,5 @@ ipN_print(register const u_char *bp, register u_int length)
}
}
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c
index f4bd603..58a0f26 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 2005/04/06 21:32:40 mcr Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.8 2003/11/24 20:31:22 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -63,43 +65,16 @@ ip6_print(register const u_char *bp, register u_int length)
TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
- (void)printf("truncated-ip6 %u", length);
+ (void)printf("truncated-ip6 %d", length);
return;
}
- if (!eflag)
- printf("IP6 ");
-
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
len = payload_len + sizeof(struct ip6_hdr);
if (length < len)
- (void)printf("truncated-ip6 - %u bytes missing!",
+ (void)printf("truncated-ip6 - %d bytes missing!",
len - length);
- if (vflag) {
- flow = EXTRACT_32BITS(&ip6->ip6_flow);
- printf("(");
-#if 0
- /* rfc1883 */
- if (flow & 0x0f000000)
- (void)printf("pri 0x%02x, ", (flow & 0x0f000000) >> 24);
- if (flow & 0x00ffffff)
- (void)printf("flowlabel 0x%06x, ", flow & 0x00ffffff);
-#else
- /* RFC 2460 */
- if (flow & 0x0ff00000)
- (void)printf("class 0x%02x, ", (flow & 0x0ff00000) >> 20);
- if (flow & 0x000fffff)
- (void)printf("flowlabel 0x%05x, ", flow & 0x000fffff);
-#endif
-
- (void)printf("hlim %u, next-header: %s (%u), length: %u) ",
- ip6->ip6_hlim,
- tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
- ip6->ip6_nxt,
- payload_len);
- }
-
/*
* Cut off the snapshot length to the end of the IP payload.
*/
@@ -133,7 +108,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_FRAGMENT:
advance = frag6_print(cp, (const u_char *)ip6);
if (snapend <= cp + advance)
- return;
+ goto end;
nh = *cp;
fragmented = 1;
break;
@@ -152,23 +127,23 @@ ip6_print(register const u_char *bp, register u_int length)
*/
advance = mobility_print(cp, (const u_char *)ip6);
nh = *cp;
- return;
+ goto end;
case IPPROTO_ROUTING:
advance = rt6_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_SCTP:
sctp_print(cp, (const u_char *)ip6, len);
- return;
+ goto end;
case IPPROTO_TCP:
tcp_print(cp, len, (const u_char *)ip6, fragmented);
- return;
+ goto end;
case IPPROTO_UDP:
udp_print(cp, len, (const u_char *)ip6, fragmented);
- return;
+ goto end;
case IPPROTO_ICMPV6:
icmp6_print(cp, len, (const u_char *)ip6, fragmented);
- return;
+ goto end;
case IPPROTO_AH:
advance = ah_print(cp);
nh = *cp;
@@ -176,7 +151,7 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_ESP:
{
int enh, padlen;
- advance = esp_print(gndo, cp, len, (const u_char *)ip6, &enh, &padlen);
+ advance = esp_print(cp, (const u_char *)ip6, &enh, &padlen);
nh = enh & 0xff;
len -= padlen;
break;
@@ -191,29 +166,56 @@ ip6_print(register const u_char *bp, register u_int length)
case IPPROTO_PIM:
pim_print(cp, len);
- return;
+ goto end;
case IPPROTO_OSPF:
ospf6_print(cp, len);
- return;
+ goto end;
case IPPROTO_IPV6:
ip6_print(cp, len);
- return;
+ goto end;
case IPPROTO_IPV4:
- ip_print(gndo, cp, len);
- return;
+ ip_print(cp, len);
+ goto end;
case IPPROTO_NONE:
(void)printf("no next header");
- return;
+ goto end;
default:
(void)printf("ip-proto-%d %d", ip6->ip6_nxt, len);
- return;
+ goto end;
}
}
+ end:
+
+ flow = EXTRACT_32BITS(&ip6->ip6_flow);
+#if 0
+ /* rfc1883 */
+ if (flow & 0x0f000000)
+ (void)printf(" [pri 0x%x]", (flow & 0x0f000000) >> 24);
+ if (flow & 0x00ffffff)
+ (void)printf(" [flowlabel 0x%x]", flow & 0x00ffffff);
+#else
+ /* RFC 2460 */
+ if (flow & 0x0ff00000)
+ (void)printf(" [class 0x%x]", (flow & 0x0ff00000) >> 20);
+ if (flow & 0x000fffff)
+ (void)printf(" [flowlabel 0x%x]", flow & 0x000fffff);
+#endif
+
+ if (ip6->ip6_hlim <= 1)
+ (void)printf(" [hlim %u]", ip6->ip6_hlim);
+
+ if (vflag) {
+ printf(" (");
+ (void)printf("len %u", payload_len);
+ if (ip6->ip6_hlim > 1)
+ (void)printf(", hlim %d", (int)ip6->ip6_hlim);
+ printf(")");
+ }
return;
trunc:
(void)printf("[|ip6]");
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index 3094cfc..6a6dfb9 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -20,11 +20,13 @@
*
* Format and print Novell IPX packets.
* Contributed by Brad Parker (brad@fcr.com).
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40 2004/05/26 19:57:57 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.34.2.2 2003/11/16 08:51:28 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -56,15 +58,12 @@ ipx_print(const u_char *p, u_int length)
{
const struct ipxHdr *ipx = (const struct ipxHdr *)p;
- if (!eflag)
- printf("IPX ");
-
TCHECK(ipx->srcSkt);
(void)printf("%s.%04x > ",
ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
EXTRACT_16BITS(&ipx->srcSkt));
- (void)printf("%s.%04x: ",
+ (void)printf("%s.%04x:",
ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
EXTRACT_16BITS(&ipx->dstSkt));
@@ -97,7 +96,7 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
switch (dstSkt) {
case IPX_SKT_NCP:
- (void)printf("ipx-ncp %d", length);
+ (void)printf(" ipx-ncp %d", length);
break;
case IPX_SKT_SAP:
ipx_sap_print((u_short *)datap, length);
@@ -106,25 +105,25 @@ ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
ipx_rip_print((u_short *)datap, length);
break;
case IPX_SKT_NETBIOS:
- (void)printf("ipx-netbios %d", length);
+ (void)printf(" ipx-netbios %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_DIAGNOSTICS:
- (void)printf("ipx-diags %d", length);
+ (void)printf(" ipx-diags %d", length);
break;
case IPX_SKT_NWLINK_DGM:
- (void)printf("ipx-nwlink-dgm %d", length);
+ (void)printf(" ipx-nwlink-dgm %d", length);
#ifdef TCPDUMP_DO_SMB
ipx_netbios_print(datap, length);
#endif
break;
case IPX_SKT_EIGRP:
- eigrp_print(datap, length);
+ (void)printf(" ipx-eigrp %d", length);
break;
default:
- (void)printf("ipx-#%x %d", dstSkt, length);
+ (void)printf(" ipx-#%x %d", dstSkt, length);
break;
}
}
@@ -192,7 +191,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
(void)printf("ipx-rip-req");
if (length > 0) {
TCHECK(ipx[3]);
- (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]),
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
}
break;
@@ -200,7 +199,7 @@ ipx_rip_print(const u_short *ipx, u_int length)
(void)printf("ipx-rip-resp");
for (i = 0; i < 50 && length > 0; i++) {
TCHECK(ipx[3]);
- (void)printf(" %u/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ (void)printf(" %x/%d.%d", EXTRACT_32BITS(&ipx[0]),
EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
ipx += 4;
diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c
index 37ecf0b..5dc660f 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -21,12 +21,14 @@
* Original code by Matt Thomas, Digital Equipment Corporation
*
* Extensively modified by Hannes Gredler (hannes@juniper.net) for more
- * complete IS-IS & CLNP support.
+ * complete IS-IS support.
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.133 2005/04/06 21:32:40 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.106.2.5 2004/03/24 01:45:26 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,10 +44,15 @@ static const char rcsid[] _U_ =
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
-#include "nlpid.h"
#include "extract.h"
#include "gmpls.h"
-#include "oui.h"
+
+#define NLPID_CLNS 129 /* 0x81 */
+#define NLPID_ESIS 130 /* 0x82 */
+#define NLPID_ISIS 131 /* 0x83 */
+#define NLPID_IP6 0x8e
+#define NLPID_IP 0xcc
+#define NLPID_NULLNS 0
#define IPV4 1 /* AFI value */
#define IPV6 2 /* AFI value */
@@ -59,35 +66,29 @@ static const char rcsid[] _U_ =
#define LSP_ID_LEN SYSTEM_ID_LEN+2
#define ISIS_VERSION 1
-#define ESIS_VERSION 1
-#define CLNP_VERSION 1
-
-#define ISIS_PDU_TYPE_MASK 0x1F
-#define ESIS_PDU_TYPE_MASK 0x1F
-#define CLNP_PDU_TYPE_MASK 0x1F
-#define CLNP_FLAG_MASK 0xE0
-#define ISIS_LAN_PRIORITY_MASK 0x7F
-
-#define ISIS_PDU_L1_LAN_IIH 15
-#define ISIS_PDU_L2_LAN_IIH 16
-#define ISIS_PDU_PTP_IIH 17
-#define ISIS_PDU_L1_LSP 18
-#define ISIS_PDU_L2_LSP 20
-#define ISIS_PDU_L1_CSNP 24
-#define ISIS_PDU_L2_CSNP 25
-#define ISIS_PDU_L1_PSNP 26
-#define ISIS_PDU_L2_PSNP 27
+#define PDU_TYPE_MASK 0x1F
+#define PRIORITY_MASK 0x7F
+
+#define L1_LAN_IIH 15
+#define L2_LAN_IIH 16
+#define PTP_IIH 17
+#define L1_LSP 18
+#define L2_LSP 20
+#define L1_CSNP 24
+#define L2_CSNP 25
+#define L1_PSNP 26
+#define L2_PSNP 27
static struct tok isis_pdu_values[] = {
- { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
- { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
- { ISIS_PDU_PTP_IIH, "p2p IIH"},
- { ISIS_PDU_L1_LSP, "L1 LSP"},
- { ISIS_PDU_L2_LSP, "L2 LSP"},
- { ISIS_PDU_L1_CSNP, "L1 CSNP"},
- { ISIS_PDU_L2_CSNP, "L2 CSNP"},
- { ISIS_PDU_L1_PSNP, "L1 PSNP"},
- { ISIS_PDU_L2_PSNP, "L2 PSNP"},
+ { L1_LAN_IIH, "L1 Lan IIH"},
+ { L2_LAN_IIH, "L2 Lan IIH"},
+ { PTP_IIH, "p2p IIH"},
+ { L1_LSP, "L1 LSP"},
+ { L2_LSP, "L2 LSP"},
+ { L1_CSNP, "L1 CSNP"},
+ { L2_CSNP, "L2 CSNP"},
+ { L1_PSNP, "L1 PSNP"},
+ { L2_PSNP, "L2 PSNP"},
{ 0, NULL}
};
@@ -99,273 +100,155 @@ static struct tok isis_pdu_values[] = {
* list taken from rfc3359 plus some memory from veterans ;-)
*/
-#define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
-#define ISIS_TLV_IS_REACH 2 /* iso10589 */
-#define ISIS_TLV_ESNEIGH 3 /* iso10589 */
-#define ISIS_TLV_PART_DIS 4 /* iso10589 */
-#define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
-#define ISIS_TLV_ISNEIGH 6 /* iso10589 */
-#define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
-#define ISIS_TLV_PADDING 8 /* iso10589 */
-#define ISIS_TLV_LSP 9 /* iso10589 */
-#define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
-#define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
-#define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
-#define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
-#define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
-#define ISIS_TLV_DECNET_PHASE4 42
-#define ISIS_TLV_LUCENT_PRIVATE 66
-#define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
-#define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
-#define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
-#define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
-#define ISIS_TLV_IPADDR 132 /* rfc1195 */
-#define ISIS_TLV_IPAUTH 133 /* rfc1195 */
-#define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
-#define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
-#define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
-#define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
-#define ISIS_TLV_NORTEL_PRIVATE1 176
-#define ISIS_TLV_NORTEL_PRIVATE2 177
-#define ISIS_TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
-#define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
-#define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
-#define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
-#define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
-#define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
-#define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
-#define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
-#define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
-#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
+#define TLV_AREA_ADDR 1 /* iso10589 */
+#define TLV_IS_REACH 2 /* iso10589 */
+#define TLV_ESNEIGH 3 /* iso10589 */
+#define TLV_PART_DIS 4 /* iso10589 */
+#define TLV_PREFIX_NEIGH 5 /* iso10589 */
+#define TLV_ISNEIGH 6 /* iso10589 */
+#define TLV_ISNEIGH_VARLEN 7 /* iso10589 */
+#define TLV_PADDING 8 /* iso10589 */
+#define TLV_LSP 9 /* iso10589 */
+#define TLV_AUTH 10 /* iso10589, rfc3567 */
+#define TLV_CHECKSUM 12 /* rfc3358 */
+#define TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
+#define TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
+#define TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
+#define TLV_DECNET_PHASE4 42
+#define TLV_LUCENT_PRIVATE 66
+#define TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
+#define TLV_PROTOCOLS 129 /* rfc1195 */
+#define TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
+#define TLV_IDRP_INFO 131 /* rfc1195 */
+#define TLV_IPADDR 132 /* rfc1195 */
+#define TLV_IPAUTH 133 /* rfc1195 */
+#define TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
+#define TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
+#define TLV_HOSTNAME 137 /* rfc2763 */
+#define TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
+#define TLV_NORTEL_PRIVATE1 176
+#define TLV_NORTEL_PRIVATE2 177
+#define TLV_HOLDTIME 198 /* ES-IS */
+#define TLV_RESTART_SIGNALING 211 /* draft-ietf-isis-restart-01 */
+#define TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
+#define TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
+#define TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
+#define TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
+#define TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
+#define TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
+#define TLV_PTP_ADJ 240 /* rfc3373 */
+#define TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
+#define TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-proprietary-tlv-00 */
static struct tok isis_tlv_values[] = {
- { ISIS_TLV_AREA_ADDR, "Area address(es)"},
- { ISIS_TLV_IS_REACH, "IS Reachability"},
- { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
- { ISIS_TLV_PART_DIS, "Partition DIS"},
- { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
- { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
- { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
- { ISIS_TLV_PADDING, "Padding"},
- { ISIS_TLV_LSP, "LSP entries"},
- { ISIS_TLV_AUTH, "Authentication"},
- { ISIS_TLV_CHECKSUM, "Checksum"},
- { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
- { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
- { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
- { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
- { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
- { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
- { ISIS_TLV_PROTOCOLS, "Protocols supported"},
- { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
- { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
- { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
- { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
- { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
- { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
- { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
- { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
- { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
- { ISIS_TLV_HOSTNAME, "Hostname"},
- { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
- { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
- { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
- { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
- { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
- { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
- { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
- { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
- { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
- { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
- { 0, NULL }
-};
-
-#define ESIS_OPTION_PROTOCOLS 129
-#define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
-#define ESIS_OPTION_SECURITY 197 /* iso9542 */
-#define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
-#define ESIS_OPTION_PRIORITY 205 /* iso9542 */
-#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
-#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
-
-static struct tok esis_option_values[] = {
- { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
- { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
- { ESIS_OPTION_SECURITY, "Security" },
- { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
- { ESIS_OPTION_PRIORITY, "Priority" },
- { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
- { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
- { 0, NULL }
-};
-
-#define CLNP_OPTION_DISCARD_REASON 193
-#define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
-#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
-
-static struct tok clnp_option_values[] = {
- { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
- { CLNP_OPTION_PRIORITY, "Priority"},
- { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_class_values[] = {
- { 0x0, "General"},
- { 0x8, "Address"},
- { 0x9, "Source Routeing"},
- { 0xa, "Lifetime"},
- { 0xb, "PDU Discarded"},
- { 0xc, "Reassembly"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_general_values[] = {
- { 0x0, "Reason not specified"},
- { 0x1, "Protocol procedure error"},
- { 0x2, "Incorrect checksum"},
- { 0x3, "PDU discarded due to congestion"},
- { 0x4, "Header syntax error (cannot be parsed)"},
- { 0x5, "Segmentation needed but not permitted"},
- { 0x6, "Incomplete PDU received"},
- { 0x7, "Duplicate option"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_address_values[] = {
- { 0x0, "Destination address unreachable"},
- { 0x1, "Destination address unknown"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_source_routeing_values[] = {
- { 0x0, "Unspecified source routeing error"},
- { 0x1, "Syntax error in source routeing field"},
- { 0x2, "Unknown address in source routeing field"},
- { 0x3, "Path not acceptable"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_lifetime_values[] = {
- { 0x0, "Lifetime expired while data unit in transit"},
- { 0x1, "Lifetime expired during reassembly"},
- { 0, NULL }
-};
-
-static struct tok clnp_option_rfd_pdu_discard_values[] = {
- { 0x0, "Unsupported option not specified"},
- { 0x1, "Unsupported protocol version"},
- { 0x2, "Unsupported security option"},
- { 0x3, "Unsupported source routeing option"},
- { 0x4, "Unsupported recording of route option"},
+ { TLV_AREA_ADDR, "Area address(es)"},
+ { TLV_IS_REACH, "IS Reachability"},
+ { TLV_ESNEIGH, "ES Neighbor(s)"},
+ { TLV_PART_DIS, "Partition DIS"},
+ { TLV_PREFIX_NEIGH, "Prefix Neighbors"},
+ { TLV_ISNEIGH, "IS Neighbor(s)"},
+ { TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
+ { TLV_PADDING, "Padding"},
+ { TLV_LSP, "LSP entries"},
+ { TLV_AUTH, "Authentication"},
+ { TLV_CHECKSUM, "Checksum"},
+ { TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
+ { TLV_EXT_IS_REACH, "Extended IS Reachability"},
+ { TLV_IS_ALIAS_ID, "IS Alias ID"},
+ { TLV_DECNET_PHASE4, "DECnet Phase IV"},
+ { TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
+ { TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
+ { TLV_PROTOCOLS, "Protocols supported"},
+ { TLV_EXT_IP_REACH, "IPv4 External Reachability"},
+ { TLV_IDRP_INFO, "Inter-Domain Information Type"},
+ { TLV_IPADDR, "IPv4 Interface address(es)"},
+ { TLV_IPAUTH, "IPv4 authentication (deprecated)"},
+ { TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
+ { TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
+ { TLV_HOSTNAME, "Hostname"},
+ { TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
+ { TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
+ { TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
+ { TLV_HOLDTIME, "Holdtime"},
+ { TLV_RESTART_SIGNALING, "Restart Signaling"},
+ { TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
+ { TLV_MT_SUPPORTED, "Multi Topology"},
+ { TLV_IP6ADDR, "IPv6 Interface address(es)"},
+ { TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
+ { TLV_IP6_REACH, "IPv6 reachability"},
+ { TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
+ { TLV_PTP_ADJ, "Point-to-point Adjacency State"},
+ { TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
+ { TLV_VENDOR_PRIVATE, "Vendor Private"},
{ 0, NULL }
};
-static struct tok clnp_option_rfd_reassembly_values[] = {
- { 0x0, "Reassembly interference"},
- { 0, NULL }
-};
-
-/* array of 16 error-classes */
-static struct tok *clnp_option_rfd_error_class[] = {
- clnp_option_rfd_general_values,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- clnp_option_rfd_address_values,
- clnp_option_rfd_source_routeing_values,
- clnp_option_rfd_lifetime_values,
- clnp_option_rfd_pdu_discard_values,
- clnp_option_rfd_reassembly_values,
- NULL,
- NULL,
- NULL
-};
-
-
-#define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
-#define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE 12 /* draft-ietf-tewg-diff-te-proto-06 */
-#define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
-#define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
-#define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
+#define SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* draft-ietf-isis-gmpls-extensions */
+#define SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
+#define SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* draft-ietf-isis-gmpls-extensions */
+#define SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* draft-ietf-isis-gmpls-extensions */
static struct tok isis_ext_is_reach_subtlv_values[] = {
- { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
- { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
- { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
- { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
- { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
- { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
- { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
- { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
- { ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE, "Diffserv TE" },
- { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
- { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
- { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
- { 250, "Reserved for cisco specific extensions" },
- { 251, "Reserved for cisco specific extensions" },
- { 252, "Reserved for cisco specific extensions" },
- { 253, "Reserved for cisco specific extensions" },
- { 254, "Reserved for cisco specific extensions" },
- { 255, "Reserved for future expansion" },
+ { SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
+ { SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
+ { SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
+ { SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
+ { SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
+ { SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
+ { SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
+ { SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
+ { SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
+ { SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
+ { SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
+ { 250, "Reserved for cisco specific extensions" },
+ { 251, "Reserved for cisco specific extensions" },
+ { 252, "Reserved for cisco specific extensions" },
+ { 253, "Reserved for cisco specific extensions" },
+ { 254, "Reserved for cisco specific extensions" },
+ { 255, "Reserved for future expansion" },
{ 0, NULL }
};
-#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
-#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
-#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
+#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1
+#define SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2
static struct tok isis_ext_ip_reach_subtlv_values[] = {
- { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
- { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
- { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
+ { SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
+ { SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
{ 0, NULL }
};
-#define ISIS_SUBTLV_AUTH_SIMPLE 1
-#define ISIS_SUBTLV_AUTH_MD5 54
-#define ISIS_SUBTLV_AUTH_MD5_LEN 16
-#define ISIS_SUBTLV_AUTH_PRIVATE 255
+#define SUBTLV_AUTH_SIMPLE 1
+#define SUBTLV_AUTH_MD5 54
+#define SUBTLV_AUTH_MD5_LEN 16
+#define SUBTLV_AUTH_PRIVATE 255
static struct tok isis_subtlv_auth_values[] = {
- { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
- { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
- { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
+ { SUBTLV_AUTH_SIMPLE, "simple text password"},
+ { SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
+ { SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
{ 0, NULL }
};
-#define ISIS_SUBTLV_IDRP_RES 0
-#define ISIS_SUBTLV_IDRP_LOCAL 1
-#define ISIS_SUBTLV_IDRP_ASN 2
+#define SUBTLV_IDRP_RES 0
+#define SUBTLV_IDRP_LOCAL 1
+#define SUBTLV_IDRP_ASN 2
static struct tok isis_subtlv_idrp_values[] = {
- { ISIS_SUBTLV_IDRP_RES, "Reserved"},
- { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
- { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
+ { SUBTLV_IDRP_RES, "Reserved"},
+ { SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
+ { SUBTLV_IDRP_ASN, "AS Number Tag"},
{ 0, NULL}
};
-#define CLNP_SEGMENT_PART 0x80
-#define CLNP_MORE_SEGMENTS 0x40
-#define CLNP_REQUEST_ER 0x20
-
-static struct tok clnp_flag_values[] = {
- { CLNP_SEGMENT_PART, "Segmentation permitted"},
- { CLNP_MORE_SEGMENTS, "more Segments"},
- { CLNP_REQUEST_ER, "request Error Report"},
- { 0, NULL}
-};
+#define ISIS_8BIT_MASK(x) ((x)&0xff)
#define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
#define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
@@ -427,6 +310,13 @@ static struct tok isis_lsp_istype_values[] = {
{ 0, NULL }
};
+static struct tok osi_nlpid_values[] = {
+ { NLPID_CLNS, "CLNS"},
+ { NLPID_IP, "IPv4"},
+ { NLPID_IP6, "IPv6"},
+ { 0, NULL }
+};
+
/*
* Katz's point to point adjacency TLV uses codes to tell us the state of
* the remote adjacency. Enumerate them.
@@ -436,6 +326,7 @@ static struct tok isis_lsp_istype_values[] = {
#define ISIS_PTP_ADJ_INIT 1
#define ISIS_PTP_ADJ_DOWN 2
+
static struct tok isis_ptp_adjancey_values[] = {
{ ISIS_PTP_ADJ_UP, "Up" },
{ ISIS_PTP_ADJ_INIT, "Initializing" },
@@ -451,7 +342,6 @@ struct isis_tlv_ptp_adj {
};
static int osi_cksum(const u_int8_t *, u_int);
-static int clnp_print(const u_int8_t *, u_int);
static void esis_print(const u_int8_t *, u_int);
static int isis_print(const u_int8_t *, u_int);
@@ -546,6 +436,35 @@ struct isis_tlv_lsp {
u_int8_t checksum[2];
};
+static char *
+print_nsap(register const u_int8_t *pptr, register int nsap_length)
+{
+ int nsap_idx;
+ static char nsap_ascii_output[sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx")];
+ char *junk_buf = nsap_ascii_output;
+
+ if (nsap_length < 1 || nsap_length > 20) {
+ snprintf(nsap_ascii_output, sizeof(nsap_ascii_output),
+ "illegal length");
+ return (nsap_ascii_output);
+ }
+
+ for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
+ if (!TTEST2(*pptr, 1))
+ return (0);
+ snprintf(junk_buf,
+ sizeof(nsap_ascii_output) - (junk_buf - nsap_ascii_output),
+ "%02x", *pptr++);
+ junk_buf += strlen(junk_buf);
+ if (((nsap_idx & 1) == 0) &&
+ (nsap_idx + 1 < nsap_length)) {
+ *junk_buf++ = '.';
+ }
+ }
+ *(junk_buf) = '\0';
+ return (nsap_ascii_output);
+}
+
#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
#define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
#define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
@@ -559,21 +478,15 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
header = (const struct isis_common_header *)p;
- if (caplen <= 1) { /* enough bytes on the wire ? */
- printf("|OSI");
- return;
- }
+ printf("%sOSI", caplen < 1 ? "|" : "");
+
+ if (caplen < 1) /* enough bytes on the wire ? */
+ return;
- if (eflag)
- printf("OSI NLPID %s (0x%02x): ",
- tok2str(nlpid_values,"Unknown",*p),
- *p);
-
switch (*p) {
- case NLPID_CLNP:
- if (!clnp_print(p, length))
- print_unknown_data(p,"\n\t",caplen);
+ case NLPID_CLNS:
+ (void)printf(", CLNS, length %u", length);
break;
case NLPID_ESIS:
@@ -586,477 +499,188 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
break;
case NLPID_NULLNS:
- (void)printf(", length: %u", length);
+ (void)printf(", ISO NULLNS, length: %u", length);
break;
- case NLPID_Q933:
- q933_print(p+1, length-1);
- break;
-
- case NLPID_IP:
- ip_print(gndo, p+1, length-1);
- break;
-
-#ifdef INET6
- case NLPID_IP6:
- ip6_print(p+1, length-1);
- break;
-#endif
-
- case NLPID_PPP:
- ppp_print(p+1, length-1);
- break;
-
default:
- if (!eflag)
- printf("OSI NLPID 0x%02x unknown",*p);
- (void)printf(", length: %u", length);
+ (void)printf(", Unknown NLPID 0x%02x, length: %u", p[0], length);
if (caplen > 1)
print_unknown_data(p,"\n\t",caplen);
break;
}
}
-#define CLNP_PDU_ER 1
-#define CLNP_PDU_DT 28
-#define CLNP_PDU_MD 29
-#define CLNP_PDU_ERQ 30
-#define CLNP_PDU_ERP 31
-
-static struct tok clnp_pdu_values[] = {
- { CLNP_PDU_ER, "Error Report"},
- { CLNP_PDU_MD, "MD"},
- { CLNP_PDU_DT, "Data"},
- { CLNP_PDU_ERQ, "Echo Request"},
- { CLNP_PDU_ERP, "Echo Response"},
- { 0, NULL }
-};
-
-struct clnp_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
- u_int8_t version;
- u_int8_t lifetime; /* units of 500ms */
- u_int8_t type;
- u_int8_t segment_length[2];
- u_int8_t cksum[2];
-};
-
-struct clnp_segment_header_t {
- u_int8_t data_unit_id[2];
- u_int8_t segment_offset[2];
- u_int8_t total_length[2];
-};
-
-/*
- * clnp_print
- * Decode CLNP packets. Return 0 on error.
- */
+#define ESIS_REDIRECT 6
+#define ESIS_ESH 2
+#define ESIS_ISH 4
-static int clnp_print (const u_int8_t *pptr, u_int length)
-{
- const u_int8_t *optr,*source_address,*dest_address;
- u_int li,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
- const struct clnp_header_t *clnp_header;
- const struct clnp_segment_header_t *clnp_segment_header;
- u_int8_t rfd_error_major,rfd_error_minor;
-
- clnp_header = (const struct clnp_header_t *) pptr;
- TCHECK(*clnp_header);
-
- li = clnp_header->length_indicator;
- optr = pptr;
-
- if (!eflag)
- printf("CLNP");
-
- /*
- * Sanity checking of the header.
- */
-
- if (clnp_header->version != CLNP_VERSION) {
- printf("version %d packet not supported", clnp_header->version);
- return (0);
- }
-
- /* FIXME further header sanity checking */
-
- clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
- clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
-
- pptr += sizeof(struct clnp_header_t);
- li -= sizeof(struct clnp_header_t);
- dest_address_length = *pptr;
- dest_address = pptr + 1;
-
- pptr += (1 + dest_address_length);
- li -= (1 + dest_address_length);
- source_address_length = *pptr;
- source_address = pptr +1;
-
- pptr += (1 + source_address_length);
- li -= (1 + source_address_length);
-
- if (vflag < 1) {
- printf("%s%s > %s, %s, length %u",
- eflag ? "" : ", ",
- isonsap_string(source_address, source_address_length),
- isonsap_string(dest_address, dest_address_length),
- tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
- length);
- return (1);
- }
- printf("%slength %u",eflag ? "" : ", ",length);
-
- printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x ",
- tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
- clnp_header->length_indicator,
- clnp_header->version,
- clnp_header->lifetime/2,
- (clnp_header->lifetime%2)*5,
- EXTRACT_16BITS(clnp_header->segment_length),
- EXTRACT_16BITS(clnp_header->cksum));
-
- /* do not attempt to verify the checksum if it is zero */
- if (EXTRACT_16BITS(clnp_header->cksum) == 0)
- printf("(unverified)");
- else printf("(%s)", osi_cksum(optr, clnp_header->length_indicator) ? "incorrect" : "correct");
-
- printf("\n\tFlags [%s]",
- bittok2str(clnp_flag_values,"none",clnp_flags));
-
- printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
- source_address_length,
- isonsap_string(source_address, source_address_length),
- dest_address_length,
- isonsap_string(dest_address,dest_address_length));
-
- if (clnp_flags & CLNP_SEGMENT_PART) {
- clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
- printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
- EXTRACT_16BITS(clnp_segment_header->data_unit_id),
- EXTRACT_16BITS(clnp_segment_header->segment_offset),
- EXTRACT_16BITS(clnp_segment_header->total_length));
- pptr+=sizeof(const struct clnp_segment_header_t);
- li-=sizeof(const struct clnp_segment_header_t);
- }
-
- /* now walk the options */
- while (li >= 2) {
- u_int op, opli;
- const u_int8_t *tptr;
-
- if (snapend - pptr < 2)
- return (0);
- if (li < 2) {
- printf(", bad opts/li");
- return (0);
- }
- op = *pptr++;
- opli = *pptr++;
- li -= 2;
- if (opli > li) {
- printf(", opt (%d) too long", op);
- return (0);
- }
- li -= opli;
- tptr = pptr;
-
- if (snapend < pptr)
- return(0);
-
- printf("\n\t %s Option #%u, length %u, value: ",
- tok2str(clnp_option_values,"Unknown",op),
- op,
- opli);
-
- switch (op) {
-
- case CLNP_OPTION_PRIORITY:
- printf("%u", *tptr);
- break;
-
- case CLNP_OPTION_DISCARD_REASON:
- rfd_error_major = (*tptr&0xf0) >> 4;
- rfd_error_minor = *tptr&0x0f;
- printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
- tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
- rfd_error_major,
- tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
- rfd_error_minor);
- break;
-
- /*
- * FIXME those are the defined Options that lack a decoder
- * you are welcome to contribute code ;-)
- */
-
- default:
- print_unknown_data(tptr,"\n\t ",opli);
- break;
- }
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
- pptr += opli;
- }
-
- switch (clnp_pdu_type) {
-
- case CLNP_PDU_ER: /* fall through */
- case CLNP_PDU_ERP:
- if (*(pptr) == NLPID_CLNP) {
- printf("\n\t-----original packet-----\n\t");
- /* FIXME recursion protection */
- clnp_print(pptr, length-clnp_header->length_indicator);
- break;
- }
-
- case CLNP_PDU_DT:
- case CLNP_PDU_MD:
- case CLNP_PDU_ERQ:
-
- default:
- /* dump the PDU specific data */
- if (length-(pptr-optr) > 0) {
- printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
- print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
- }
- }
-
- return (1);
-
- trunc:
- fputs("[|clnp]", stdout);
- return (1);
-
-}
-
-
-#define ESIS_PDU_REDIRECT 6
-#define ESIS_PDU_ESH 2
-#define ESIS_PDU_ISH 4
-
-static struct tok esis_pdu_values[] = {
- { ESIS_PDU_REDIRECT, "redirect"},
- { ESIS_PDU_ESH, "ESH"},
- { ESIS_PDU_ISH, "ISH"},
+static struct tok esis_values[] = {
+ { ESIS_REDIRECT, "redirect"},
+ { ESIS_ESH, "ESH"},
+ { ESIS_ISH, "ISH"},
{ 0, NULL }
};
-struct esis_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
+struct esis_hdr {
u_int8_t version;
u_int8_t reserved;
u_int8_t type;
- u_int8_t holdtime[2];
+ u_int8_t tmo[2];
u_int8_t cksum[2];
};
static void
-esis_print(const u_int8_t *pptr, u_int length)
+esis_print(const u_int8_t *p, u_int length)
{
- const u_int8_t *optr;
- u_int li,esis_pdu_type,source_address_length, source_address_number;
- const struct esis_header_t *esis_header;
-
- if (!eflag)
- printf("ES-IS");
+ const u_int8_t *ep;
+ u_int li;
+ const struct esis_hdr *eh;
if (length <= 2) {
if (qflag)
- printf("bad pkt!");
+ printf(" bad pkt!");
else
- printf("no header at all!");
+ printf(" no header at all!");
return;
}
-
- esis_header = (const struct esis_header_t *) pptr;
- li = esis_header->length_indicator;
- optr = pptr;
-
- /*
- * Sanity checking of the header.
- */
-
- if (esis_header->nlpid != NLPID_ESIS) {
- printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
- return;
- }
-
- if (esis_header->version != ESIS_VERSION) {
- printf(" version %d packet not supported", esis_header->version);
- return;
- }
-
+ li = p[1];
+ eh = (const struct esis_hdr *) &p[2];
+ ep = p + li;
if (li > length) {
- printf(" length indicator(%d) > PDU size (%d)!", li, length);
- return;
+ if (qflag)
+ printf(" bad pkt!");
+ else
+ printf(" LI(%d) > PDU size (%d)!", li, length);
+ return;
}
-
- if (li < sizeof(struct esis_header_t) + 2) {
- printf(" length indicator < min PDU size %d:", li);
- while (--length != 0)
- printf("%02X", *pptr++);
- return;
+ if (li < sizeof(struct esis_hdr) + 2) {
+ if (qflag)
+ printf(" bad pkt!");
+ else {
+ printf(" too short for esis header %d:", li);
+ while (--length != 0)
+ printf("%02X", *p++);
+ }
+ return;
}
- esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
-
- if (vflag < 1) {
- printf("%s%s, length %u",
- eflag ? "" : ", ",
- tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
- length);
- return;
- } else
- printf("%slength %u\n\t%s (%u)",
- eflag ? "" : ", ",
- length,
- tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
- esis_pdu_type);
-
- printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
- printf(", checksum: 0x%04x ", EXTRACT_16BITS(esis_header->cksum));
- /* do not attempt to verify the checksum if it is zero */
- if (EXTRACT_16BITS(esis_header->cksum) == 0)
- printf("(unverified)");
- else printf("(%s)", osi_cksum(pptr, li) ? "incorrect" : "correct");
-
- printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
+ printf(", ES-IS, %s, length %u",
+ tok2str(esis_values,"unknown type: %u",eh->type & 0x1f),
+ length);
- if (vflag > 1)
- print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
+ if(vflag < 1)
+ return;
- pptr += sizeof(struct esis_header_t);
- li -= sizeof(struct esis_header_t);
+ if (vflag && osi_cksum(p, li)) {
+ printf(" bad cksum (got 0x%02x%02x)",
+ eh->cksum[1], eh->cksum[0]);
+ default_print(p, length);
+ return;
+ }
+ if (eh->version != 1) {
+ printf(" unsupported version %d", eh->version);
+ return;
+ }
+ p += sizeof(*eh) + 2;
+ li -= sizeof(*eh) + 2; /* protoid * li */
- switch (esis_pdu_type) {
- case ESIS_PDU_REDIRECT: {
- const u_int8_t *dst, *snpa, *tptr;
+ switch (eh->type & 0x1f) {
+ case ESIS_REDIRECT: {
+ const u_int8_t *dst, *snpa, *is;
- dst = pptr; pptr += *pptr + 1;
- if (pptr > snapend)
+ dst = p; p += *p + 1;
+ if (p > snapend)
return;
- printf("\n\t %s", isonsap_string(dst+1,*dst));
- snpa = pptr; pptr += *pptr + 1;
- tptr = pptr; pptr += *pptr + 1;
- if (pptr > snapend)
+ printf("\n\t\t %s", isonsap_string(dst));
+ snpa = p; p += *p + 1;
+ is = p; p += *p + 1;
+ if (p > snapend)
return;
-
- if (tptr[0] == 0)
- printf("\n\t %s", etheraddr_string(&snpa[1]));
+ if (p > ep) {
+ printf(" [bad li]");
+ return;
+ }
+ if (is[0] == 0)
+ printf(" > %s", etheraddr_string(&snpa[1]));
else
- printf("\n\t %s", isonsap_string(tptr+1,*tptr));
+ printf(" > %s", isonsap_string(is));
+ li = ep - p;
break;
}
- case ESIS_PDU_ESH:
- source_address_number = *pptr;
- pptr++;
- li--;
-
- printf("\n\t Number of Source Addresses: %u", source_address_number);
-
- while (source_address_number > 0) {
- source_address_length = *pptr;
- printf("\n\t NET (length: %u): %s",
- source_address_length,
- isonsap_string(pptr+1,source_address_length));
-
- pptr += source_address_length+1;
- li -= source_address_length+1;
- source_address_number--;
- }
+ case ESIS_ESH:
+ break;
- break;
+ case ESIS_ISH: {
+ const u_int8_t *is;
- case ESIS_PDU_ISH: {
- source_address_length = *pptr;
- printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr+1, source_address_length));
- pptr += source_address_length+1;
- li -= source_address_length +1;
- break;
+ is = p; p += *p + 1;
+ if (p > ep) {
+ printf(" [bad li]");
+ return;
+ }
+ if (p > snapend)
+ return;
+ if (!qflag)
+ printf("\n\tNET: %s", print_nsap(is+1,*is));
+ li = ep - p;
+ break;
}
default:
if (vflag <= 1) {
- if (pptr < snapend)
- print_unknown_data(pptr,"\n\t ",snapend-pptr);
+ if (p < snapend)
+ print_unknown_data(p,"\n\t ",snapend-p);
}
return;
}
- /* now walk the options */
- while (li >= 2) {
- u_int op, opli;
- const u_int8_t *tptr;
-
- if (snapend - pptr < 2)
- return;
- if (li < 2) {
- printf(", bad opts/li");
- return;
- }
- op = *pptr++;
- opli = *pptr++;
- li -= 2;
- if (opli > li) {
- printf(", opt (%d) too long", op);
- return;
- }
- li -= opli;
- tptr = pptr;
-
- if (snapend < pptr)
- return;
-
- printf("\n\t %s Option #%u, length %u, value: ",
- tok2str(esis_option_values,"Unknown",op),
- op,
- opli);
-
- switch (op) {
-
- case ESIS_OPTION_ES_CONF_TIME:
- printf("%us", EXTRACT_16BITS(tptr));
- break;
-
-
- case ESIS_OPTION_PROTOCOLS:
- while (opli>0) {
- printf("%s (0x%02x)",
- tok2str(nlpid_values,
- "unknown",
- *tptr),
- *tptr);
- if (opli>1) /* further NPLIDs ? - put comma */
- printf(", ");
- tptr++;
- opli--;
- }
- break;
-
- /*
- * FIXME those are the defined Options that lack a decoder
- * you are welcome to contribute code ;-)
- */
-
- case ESIS_OPTION_QOS_MAINTENANCE:
- case ESIS_OPTION_SECURITY:
- case ESIS_OPTION_PRIORITY:
- case ESIS_OPTION_ADDRESS_MASK:
- case ESIS_OPTION_SNPA_MASK:
-
- default:
- print_unknown_data(tptr,"\n\t ",opli);
- break;
- }
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
- pptr += opli;
+ /* hexdump - FIXME ? */
+ if (vflag > 1) {
+ if (p < snapend)
+ print_unknown_data(p,"\n\t ",snapend-p);
}
-}
+ if (vflag)
+ while (p < ep && li) {
+ u_int op, opli;
+ const u_int8_t *q;
+
+ if (snapend - p < 2)
+ return;
+ if (li < 2) {
+ printf(", bad opts/li");
+ return;
+ }
+ op = *p++;
+ opli = *p++;
+ li -= 2;
+ if (opli > li) {
+ printf(", opt (%d) too long", op);
+ return;
+ }
+ li -= opli;
+ q = p;
+ p += opli;
+
+ if (snapend < p)
+ return;
+
+ if (op == TLV_HOLDTIME && opli == 2) {
+ printf("\n\tholdtime: %us", EXTRACT_16BITS(q));
+ continue;
+ }
+
+ if (op == TLV_PROTOCOLS && opli >= 1) {
+ printf("\n\t%s (length: %u): %s",
+ tok2str(isis_tlv_values, "unknown", op),
+ opli,
+ tok2str(osi_nlpid_values,"Unknown 0x%02x",*q));
+ continue;
+ }
+
+ print_unknown_data(q,"\n\t ",opli);
+ }
+}
/* shared routine for printing system, node and lsp-ids */
static char *
@@ -1186,8 +810,7 @@ isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
goto trunctlv;
switch(subt) {
- case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
- case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
+ case SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
while (subl >= 4) {
printf(", 0x%08x (=%u)",
EXTRACT_32BITS(tptr),
@@ -1196,7 +819,7 @@ isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
subl-=4;
}
break;
- case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
+ case SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
while (subl >= 8) {
printf(", 0x%08x%08x",
EXTRACT_32BITS(tptr),
@@ -1226,7 +849,7 @@ trunctlv:
static int
isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
- int priority_level,bandwidth_constraint;
+ int priority_level;
union { /* int to float conversion buffer for several subTLVs */
float f;
u_int32_t i;
@@ -1245,28 +868,28 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
goto trunctlv;
switch(subt) {
- case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
- case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
- case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
+ case SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
+ case SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
+ case SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
if (subl >= 4) {
printf(", 0x%08x", EXTRACT_32BITS(tptr));
if (subl == 8) /* draft-ietf-isis-gmpls-extensions */
printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
}
break;
- case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
- case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
+ case SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
+ case SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
if (subl >= 4)
printf(", %s", ipaddr_string(tptr));
break;
- case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
- case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
+ case SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
+ case SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
if (subl >= 4) {
bw.i = EXTRACT_32BITS(tptr);
printf(", %.3f Mbps", bw.f*8/1000000 );
}
break;
- case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
+ case SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
if (subl >= 32) {
for (priority_level = 0; priority_level < 8; priority_level++) {
bw.i = EXTRACT_32BITS(tptr);
@@ -1278,34 +901,18 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *i
}
}
break;
- case ISIS_SUBTLV_EXT_IS_REACH_DIFFSERV_TE:
- printf("%sBandwidth Constraints Model ID: %s (%u)",
- ident,
- tok2str(diffserv_te_bc_values, "unknown", *tptr),
- *tptr);
- tptr++;
- /* decode BCs until the subTLV ends */
- for (bandwidth_constraint = 0; bandwidth_constraint < (subl-1)/4; bandwidth_constraint++) {
- bw.i = EXTRACT_32BITS(tptr);
- printf("%s Bandwidth constraint %d: %.3f Mbps",
- ident,
- bandwidth_constraint,
- bw.f*8/1000000 );
- tptr+=4;
- }
- break;
- case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
+ case SUBTLV_EXT_IS_REACH_TE_METRIC:
if (subl >= 3)
printf(", %u", EXTRACT_24BITS(tptr));
break;
- case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
+ case SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
if (subl >= 2) {
printf(", %s, Priority %u",
bittok2str(gmpls_link_prot_values, "none", *tptr),
*(tptr+1));
}
break;
- case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
+ case SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
if (subl >= 36) {
printf("%s Interface Switching Capability:%s",
ident,
@@ -1364,7 +971,7 @@ isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
tptr+=(NODE_ID_LEN);
- if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
+ if (tlv_type != TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
return(0);
printf(", Metric: %d",EXTRACT_24BITS(tptr));
@@ -1526,7 +1133,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
static int isis_print (const u_int8_t *p, u_int length)
{
- const struct isis_common_header *isis_header;
+ const struct isis_common_header *header;
const struct isis_iih_lan_header *header_iih_lan;
const struct isis_iih_ptp_header *header_iih_ptp;
@@ -1543,13 +1150,13 @@ static int isis_print (const u_int8_t *p, u_int length)
u_int8_t ext_is_len, ext_ip_len, mt_len;
const u_int8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len;
- u_int i,vendor_id;
+ u_int i;
packet_len=length;
optr = p; /* initialize the _o_riginal pointer to the packet start -
need it for parsing the checksum TLV */
- isis_header = (const struct isis_common_header *)p;
- TCHECK(*isis_header);
+ header = (const struct isis_common_header *)p;
+ TCHECK(*header);
pptr = p+(ISIS_COMMON_HEADER_SIZE);
header_iih_lan = (const struct isis_iih_lan_header *)pptr;
header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
@@ -1557,42 +1164,39 @@ static int isis_print (const u_int8_t *p, u_int length)
header_csnp = (const struct isis_csnp_header *)pptr;
header_psnp = (const struct isis_psnp_header *)pptr;
- if (!eflag)
- printf("IS-IS");
-
/*
* Sanity checking of the header.
*/
- if (isis_header->version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->version);
+ if (header->version != ISIS_VERSION) {
+ printf(", version %d packet not supported", header->version);
return (0);
}
- if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
- printf("system ID length of %d is not supported",
- isis_header->id_length);
+ if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) {
+ printf(", system ID length of %d is not supported",
+ header->id_length);
return (0);
}
- if (isis_header->pdu_version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->pdu_version);
+ if (header->pdu_version != ISIS_VERSION) {
+ printf(", version %d packet not supported", header->pdu_version);
return (0);
}
- max_area = isis_header->max_area;
+ max_area = header->max_area;
switch(max_area) {
case 0:
max_area = 3; /* silly shit */
break;
case 255:
- printf("bad packet -- 255 areas");
+ printf(", bad packet -- 255 areas");
return (0);
default:
break;
}
- id_length = isis_header->id_length;
+ id_length = header->id_length;
switch(id_length) {
case 0:
id_length = 6; /* silly shit again */
@@ -1615,45 +1219,44 @@ static int isis_print (const u_int8_t *p, u_int length)
/* toss any non 6-byte sys-ID len PDUs */
if (id_length != 6 ) {
- printf("bad packet -- illegal sys-ID length (%u)", id_length);
+ printf(", bad packet -- illegal sys-ID length (%u)", id_length);
return (0);
}
- pdu_type=isis_header->pdu_type;
+ pdu_type=header->pdu_type;
/* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
if (vflag < 1) {
- printf("%s%s",
- eflag ? "" : ", ",
+ printf(", IS-IS, %s",
tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
switch (pdu_type) {
- case ISIS_PDU_L1_LAN_IIH:
- case ISIS_PDU_L2_LAN_IIH:
+ case L1_LAN_IIH:
+ case L2_LAN_IIH:
printf(", src-id %s",
isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
printf(", lan-id %s, prio %u",
isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
header_iih_lan->priority);
break;
- case ISIS_PDU_PTP_IIH:
+ case PTP_IIH:
printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
break;
- case ISIS_PDU_L1_LSP:
- case ISIS_PDU_L2_LSP:
+ case L1_LSP:
+ case L2_LSP:
printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_32BITS(header_lsp->sequence_number),
EXTRACT_16BITS(header_lsp->remaining_lifetime));
break;
- case ISIS_PDU_L1_CSNP:
- case ISIS_PDU_L2_CSNP:
- printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
+ case L1_CSNP:
+ case L2_CSNP:
+ printf(", src-id %s", isis_print_id(header_csnp->source_id,SYSTEM_ID_LEN));
break;
- case ISIS_PDU_L1_PSNP:
- case ISIS_PDU_L2_PSNP:
- printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
+ case L1_PSNP:
+ case L2_PSNP:
+ printf(", src-id %s", isis_print_id(header_psnp->source_id,SYSTEM_ID_LEN));
break;
}
@@ -1663,19 +1266,19 @@ static int isis_print (const u_int8_t *p, u_int length)
}
/* ok they seem to want to know everything - lets fully decode it */
- printf("%slength %u", eflag ? "" : ", ",length);
+ printf(", IS-IS, length: %u",length);
printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
tok2str(isis_pdu_values,
"unknown, type %u",
pdu_type),
- isis_header->fixed_len,
- isis_header->version,
- isis_header->pdu_version,
+ header->fixed_len,
+ header->version,
+ header->pdu_version,
id_length,
- isis_header->id_length,
+ header->id_length,
max_area,
- isis_header->max_area);
+ header->max_area);
if (vflag > 1) {
if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
@@ -1684,11 +1287,11 @@ static int isis_print (const u_int8_t *p, u_int length)
switch (pdu_type) {
- case ISIS_PDU_L1_LAN_IIH:
- case ISIS_PDU_L2_LAN_IIH:
- if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
+ case L1_LAN_IIH:
+ case L2_LAN_IIH:
+ if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
+ header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
return (0);
}
@@ -1708,7 +1311,7 @@ static int isis_print (const u_int8_t *p, u_int length)
printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
- (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
+ (header_iih_lan->priority) & PRIORITY_MASK,
pdu_len);
if (vflag > 1) {
@@ -1720,10 +1323,10 @@ static int isis_print (const u_int8_t *p, u_int length)
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
break;
- case ISIS_PDU_PTP_IIH:
- if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
+ case PTP_IIH:
+ if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
+ header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
return (0);
}
@@ -1754,11 +1357,11 @@ static int isis_print (const u_int8_t *p, u_int length)
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
break;
- case ISIS_PDU_L1_LSP:
- case ISIS_PDU_L2_LSP:
- if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
+ case L1_LSP:
+ case L2_LSP:
+ if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
+ header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
return (0);
}
@@ -1808,11 +1411,11 @@ static int isis_print (const u_int8_t *p, u_int length)
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
break;
- case ISIS_PDU_L1_CSNP:
- case ISIS_PDU_L2_CSNP:
- if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
+ case L1_CSNP:
+ case L2_CSNP:
+ if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
+ header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
return (0);
}
@@ -1840,11 +1443,11 @@ static int isis_print (const u_int8_t *p, u_int length)
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
break;
- case ISIS_PDU_L1_PSNP:
- case ISIS_PDU_L2_PSNP:
- if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
+ case L1_PSNP:
+ case L2_PSNP:
+ if (header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
printf("- bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
+ header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
return (0);
}
@@ -1907,14 +1510,14 @@ static int isis_print (const u_int8_t *p, u_int length)
/* now check if we have a decoder otherwise do a hexdump at the end*/
switch (tlv_type) {
- case ISIS_TLV_AREA_ADDR:
+ case TLV_AREA_ADDR:
if (!TTEST2(*tptr, 1))
goto trunctlv;
alen = *tptr++;
while (tmp && alen < tmp) {
printf("\n\t Area address (length: %u): %s",
alen,
- isonsap_string(tptr,alen));
+ print_nsap(tptr, alen));
tptr += alen;
tmp -= alen + 1;
if (tmp==0) /* if this is the last area address do not attemt a boundary check */
@@ -1924,7 +1527,7 @@ static int isis_print (const u_int8_t *p, u_int length)
alen = *tptr++;
}
break;
- case ISIS_TLV_ISNEIGH:
+ case TLV_ISNEIGH:
while (tmp >= ETHER_ADDR_LEN) {
if (!TTEST2(*tptr, ETHER_ADDR_LEN))
goto trunctlv;
@@ -1934,7 +1537,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_ISNEIGH_VARLEN:
+ case TLV_ISNEIGH_VARLEN:
if (!TTEST2(*tptr, 1))
goto trunctlv;
lan_alen = *tptr++; /* LAN adress length */
@@ -1949,10 +1552,10 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_PADDING:
+ case TLV_PADDING:
break;
- case ISIS_TLV_MT_IS_REACH:
+ case TLV_MT_IS_REACH:
while (tmp >= 2+NODE_ID_LEN+3+1) {
mt_len = isis_print_mtid(tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
@@ -1969,7 +1572,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_IS_ALIAS_ID:
+ case TLV_IS_ALIAS_ID:
while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
@@ -1979,7 +1582,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_EXT_IS_REACH:
+ case TLV_EXT_IS_REACH:
while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
@@ -1988,7 +1591,7 @@ static int isis_print (const u_int8_t *p, u_int length)
tptr+=ext_is_len;
}
break;
- case ISIS_TLV_IS_REACH:
+ case TLV_IS_REACH:
if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
goto trunctlv;
printf("\n\t %s",
@@ -2007,7 +1610,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_ESNEIGH:
+ case TLV_ESNEIGH:
tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_es_reach)) {
if (!TTEST(*tlv_es_reach))
@@ -2021,13 +1624,13 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
/* those two TLVs share the same format */
- case ISIS_TLV_INT_IP_REACH:
- case ISIS_TLV_EXT_IP_REACH:
+ case TLV_INT_IP_REACH:
+ case TLV_EXT_IP_REACH:
if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
return (1);
break;
- case ISIS_TLV_EXTD_IP_REACH:
+ case TLV_EXTD_IP_REACH:
while (tmp>0) {
ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV4);
if (ext_ip_len == 0) /* did something go wrong ? */
@@ -2037,7 +1640,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_MT_IP_REACH:
+ case TLV_MT_IP_REACH:
while (tmp>0) {
mt_len = isis_print_mtid(tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
@@ -2054,7 +1657,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
#ifdef INET6
- case ISIS_TLV_IP6_REACH:
+ case TLV_IP6_REACH:
while (tmp>0) {
ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", IPV6);
if (ext_ip_len == 0) /* did something go wrong ? */
@@ -2064,7 +1667,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_MT_IP6_REACH:
+ case TLV_MT_IP6_REACH:
while (tmp>0) {
mt_len = isis_print_mtid(tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
@@ -2080,7 +1683,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_IP6ADDR:
+ case TLV_IP6ADDR:
while (tmp>0) {
if (!TTEST2(*tptr, 16))
goto trunctlv;
@@ -2093,7 +1696,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
#endif
- case ISIS_TLV_AUTH:
+ case TLV_AUTH:
if (!TTEST2(*tptr, 1))
goto trunctlv;
@@ -2103,23 +1706,23 @@ static int isis_print (const u_int8_t *p, u_int length)
*tptr));
switch (*tptr) {
- case ISIS_SUBTLV_AUTH_SIMPLE:
+ case SUBTLV_AUTH_SIMPLE:
for(i=1;i<tlv_len;i++) {
if (!TTEST2(*(tptr+i), 1))
goto trunctlv;
printf("%c",*(tptr+i));
}
break;
- case ISIS_SUBTLV_AUTH_MD5:
+ case SUBTLV_AUTH_MD5:
for(i=1;i<tlv_len;i++) {
if (!TTEST2(*(tptr+i), 1))
goto trunctlv;
printf("%02x",*(tptr+i));
}
- if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
+ if (tlv_len != SUBTLV_AUTH_MD5_LEN+1)
printf(", (malformed subTLV) ");
break;
- case ISIS_SUBTLV_AUTH_PRIVATE:
+ case SUBTLV_AUTH_PRIVATE:
default:
if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
return(0);
@@ -2127,7 +1730,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_PTP_ADJ:
+ case TLV_PTP_ADJ:
tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
if(tmp>=1) {
if (!TTEST2(*tptr, 1))
@@ -2161,13 +1764,13 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_PROTOCOLS:
+ case TLV_PROTOCOLS:
printf("\n\t NLPID(s): ");
while (tmp>0) {
if (!TTEST2(*(tptr), 1))
goto trunctlv;
printf("%s (0x%02x)",
- tok2str(nlpid_values,
+ tok2str(osi_nlpid_values,
"unknown",
*tptr),
*tptr);
@@ -2178,13 +1781,13 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_TE_ROUTER_ID:
+ case TLV_TE_ROUTER_ID:
if (!TTEST2(*pptr, 4))
goto trunctlv;
printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
break;
- case ISIS_TLV_IPADDR:
+ case TLV_IPADDR:
while (tmp>0) {
if (!TTEST2(*tptr, 4))
goto trunctlv;
@@ -2194,7 +1797,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_HOSTNAME:
+ case TLV_HOSTNAME:
printf("\n\t Hostname: ");
while (tmp>0) {
if (!TTEST2(*tptr, 1))
@@ -2204,7 +1807,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_SHARED_RISK_GROUP:
+ case TLV_SHARED_RISK_GROUP:
if (!TTEST2(*tptr, NODE_ID_LEN))
goto trunctlv;
printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
@@ -2237,7 +1840,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_LSP:
+ case TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>0) {
if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
@@ -2258,7 +1861,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_CHECKSUM:
+ case TLV_CHECKSUM:
if (!TTEST2(*tptr, 2))
goto trunctlv;
printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
@@ -2272,7 +1875,7 @@ static int isis_print (const u_int8_t *p, u_int length)
else printf("(%s)", osi_cksum(optr, length) ? "incorrect" : "correct");
break;
- case ISIS_TLV_MT_SUPPORTED:
+ case TLV_MT_SUPPORTED:
while (tmp>1) {
/* length can only be a multiple of 2, otherwise there is
something broken -> so decode down until length is 1 */
@@ -2289,7 +1892,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_RESTART_SIGNALING:
+ case TLV_RESTART_SIGNALING:
if (!TTEST2(*tptr, 3))
goto trunctlv;
printf("\n\t Flags [%s], Remaining holding time %us",
@@ -2298,7 +1901,7 @@ static int isis_print (const u_int8_t *p, u_int length)
tptr+=3;
break;
- case ISIS_TLV_IDRP_INFO:
+ case TLV_IDRP_INFO:
if (!TTEST2(*tptr, 1))
goto trunctlv;
printf("\n\t Inter-Domain Information Type: %s",
@@ -2306,13 +1909,13 @@ static int isis_print (const u_int8_t *p, u_int length)
"Unknown (0x%02x)",
*tptr));
switch (*tptr++) {
- case ISIS_SUBTLV_IDRP_ASN:
+ case SUBTLV_IDRP_ASN:
if (!TTEST2(*tptr, 2)) /* fetch AS number */
goto trunctlv;
printf("AS Number: %u",EXTRACT_16BITS(tptr));
break;
- case ISIS_SUBTLV_IDRP_LOCAL:
- case ISIS_SUBTLV_IDRP_RES:
+ case SUBTLV_IDRP_LOCAL:
+ case SUBTLV_IDRP_RES:
default:
if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
return(0);
@@ -2320,13 +1923,13 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_LSP_BUFFERSIZE:
+ case TLV_LSP_BUFFERSIZE:
if (!TTEST2(*tptr, 2))
goto trunctlv;
printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
break;
- case ISIS_TLV_PART_DIS:
+ case TLV_PART_DIS:
while (tmp >= SYSTEM_ID_LEN) {
if (!TTEST2(*tptr, SYSTEM_ID_LEN))
goto trunctlv;
@@ -2336,7 +1939,7 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
- case ISIS_TLV_PREFIX_NEIGH:
+ case TLV_PREFIX_NEIGH:
if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
goto trunctlv;
printf("\n\t Metric Block");
@@ -2352,26 +1955,23 @@ static int isis_print (const u_int8_t *p, u_int length)
if (!TTEST2(*tptr, prefix_len/2))
goto trunctlv;
printf("\n\t\tAddress: %s/%u",
- isonsap_string(tptr,prefix_len/2),
+ print_nsap(tptr,prefix_len/2),
prefix_len*4);
tptr+=prefix_len/2;
tmp-=prefix_len/2;
}
break;
- case ISIS_TLV_IIH_SEQNR:
+ case TLV_IIH_SEQNR:
if (!TTEST2(*tptr, 4)) /* check if four bytes are on the wire */
goto trunctlv;
printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
break;
- case ISIS_TLV_VENDOR_PRIVATE:
+ case TLV_VENDOR_PRIVATE:
if (!TTEST2(*tptr, 3)) /* check if enough byte for a full oui */
goto trunctlv;
- vendor_id = EXTRACT_24BITS(tptr);
- printf("\n\t Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",vendor_id),
- vendor_id);
+ printf("\n\t Vendor OUI Code: 0x%06x", EXTRACT_24BITS(tptr) );
tptr+=3;
tmp-=3;
if (tmp > 0) /* hexdump the rest */
@@ -2383,11 +1983,11 @@ static int isis_print (const u_int8_t *p, u_int length)
* you are welcome to contribute code ;-)
*/
- case ISIS_TLV_DECNET_PHASE4:
- case ISIS_TLV_LUCENT_PRIVATE:
- case ISIS_TLV_IPAUTH:
- case ISIS_TLV_NORTEL_PRIVATE1:
- case ISIS_TLV_NORTEL_PRIVATE2:
+ case TLV_DECNET_PHASE4:
+ case TLV_LUCENT_PRIVATE:
+ case TLV_IPAUTH:
+ case TLV_NORTEL_PRIVATE1:
+ case TLV_NORTEL_PRIVATE2:
default:
if (vflag <= 1) {
@@ -2437,11 +2037,3 @@ osi_cksum(const u_int8_t *tptr, u_int len)
}
return (c0 | c1);
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
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 fb54641..49655b8 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 2005/04/06 21:32:41 mcr Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.53.2.3 2003/12/29 22:33:18 hannes Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -42,7 +44,6 @@ static const char rcsid[] _U_ =
#include "llc.h"
#include "ethertype.h"
-#include "oui.h"
static struct tok llc_values[] = {
{ LLCSAP_NULL, "Null" },
@@ -95,7 +96,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
memcpy((char *)&llc, (char *)p, min(caplen, sizeof(llc)));
if (eflag)
- printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x: ",
+ printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x), cmd 0x%02x, ",
tok2str(llc_values,"Unknown",llc.dsap),
llc.dsap,
tok2str(llc_values,"Unknown",llc.ssap),
@@ -117,12 +118,9 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* such as an 802.11 network; this has appeared in at
* least one capture file.)
*/
-
- if (eflag)
- printf("IPX-802.3: ");
-
- ipx_print(p, length);
- return (1);
+ printf("(NOV-802.3) ");
+ ipx_print(p, length);
+ return (1);
}
if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
@@ -131,7 +129,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
if (llc.ssap == LLCSAP_IP && llc.dsap == LLCSAP_IP) {
- ip_print(gndo, p+4, length-4);
+ ip_print(p+4, length-4);
return (1);
}
@@ -220,14 +218,6 @@ llc_print(const u_char *p, u_int length, u_int caplen,
orgcode = EXTRACT_24BITS(&llc.llc_orgcode[0]);
et = EXTRACT_16BITS(&llc.llc_ethertype[0]);
-
- if (eflag)
- (void)printf("oui %s (0x%06x), ethertype %s (0x%04x): ",
- tok2str(oui_values,"Unknown",orgcode),
- orgcode,
- tok2str(ethertype_values,"Unknown", et),
- et);
-
/*
* XXX - what *is* the right bridge pad value here?
* Does anybody ever bridge one form of LAN traffic
@@ -320,6 +310,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
length -= 4;
caplen -= 4;
}
+ (void)printf(" len=%d", length);
return(1);
}
@@ -438,11 +429,3 @@ snap_print(const u_char *p, u_int length, u_int caplen,
}
return (0);
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index 6fa765d..208faa1 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 2005/01/05 08:16:45 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.99.2.2 2003/11/16 08:51:35 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,6 +32,8 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
+#include <rpc/rpc.h>
+
#include <pcap.h>
#include <stdio.h>
#include <string.h>
@@ -45,16 +49,15 @@ static const char rcsid[] _U_ =
#ifdef INET6
#include "ip6.h"
#endif
-#include "rpc_auth.h"
-#include "rpc_msg.h"
static void nfs_printfh(const u_int32_t *, const u_int);
-static void xid_map_enter(const struct sunrpc_msg *, const u_char *);
-static int32_t xid_map_find(const struct sunrpc_msg *, const u_char *,
+static void xid_map_enter(const struct rpc_msg *, const u_char *);
+static int32_t xid_map_find(const struct rpc_msg *, const u_char *,
u_int32_t *, u_int32_t *);
-static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int);
+static void interp_reply(const struct rpc_msg *, u_int32_t, u_int32_t, int);
static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
+static int print_int64(const u_int32_t *dp, int how);
static void print_nfsaddr(const u_char *, const char *, const char *);
/*
@@ -156,6 +159,59 @@ static struct tok type2str[] = {
{ 0, NULL }
};
+/*
+ * Print out a 64-bit integer. This appears to be different on each system,
+ * try to make the best of it. The integer stored as 2 consecutive XDR
+ * encoded 32-bit integers, to which a pointer is passed.
+ *
+ * Assume that a system that has INT64_FORMAT defined, has a 64-bit
+ * integer datatype and can print it.
+ */
+
+#define UNSIGNED 0
+#define SIGNED 1
+#define HEX 2
+
+static int print_int64(const u_int32_t *dp, int how)
+{
+#ifdef INT64_FORMAT
+ u_int64_t res;
+
+ res = ((u_int64_t)EXTRACT_32BITS(&dp[0]) << 32) | (u_int64_t)EXTRACT_32BITS(&dp[1]);
+ switch (how) {
+ case SIGNED:
+ printf(INT64_FORMAT, res);
+ break;
+ case UNSIGNED:
+ printf(U_INT64_FORMAT, res);
+ break;
+ case HEX:
+ printf(HEX_INT64_FORMAT, res);
+ break;
+ default:
+ return (0);
+ }
+#else
+ u_int32_t high;
+
+ high = EXTRACT_32BITS(&dp[0]);
+
+ switch (how) {
+ case SIGNED:
+ case UNSIGNED:
+ case HEX:
+ if (high != 0)
+ printf("0x%x%08x", high, EXTRACT_32BITS(&dp[1]));
+ else
+ printf("0x%x", EXTRACT_32BITS(&dp[1]));
+ break;
+ default:
+ return (0);
+ }
+#endif
+ return 1;
+}
+
static void
print_nfsaddr(const u_char *bp, const char *s, const char *d)
{
@@ -286,12 +342,12 @@ void
nfsreply_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
- register const struct sunrpc_msg *rp;
+ register const struct rpc_msg *rp;
u_int32_t proc, vers;
char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
- rp = (const struct sunrpc_msg *)bp;
+ rp = (const struct rpc_msg *)bp;
if (!nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
@@ -304,9 +360,9 @@ nfsreply_print(register const u_char *bp, u_int length,
}
print_nfsaddr(bp2, srcid, dstid);
(void)printf("reply %s %d",
- EXTRACT_32BITS(&rp->rm_reply.rp_stat) == SUNRPC_MSG_ACCEPTED?
- "ok":"ERR",
- length);
+ EXTRACT_32BITS(&rp->rm_reply.rp_stat) == MSG_ACCEPTED?
+ "ok":"ERR",
+ length);
if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
interp_reply(rp, proc, vers, length);
@@ -317,7 +373,7 @@ nfsreply_print(register const u_char *bp, u_int length,
* If the packet was truncated, return 0.
*/
static const u_int32_t *
-parsereq(register const struct sunrpc_msg *rp, register u_int length)
+parsereq(register const struct rpc_msg *rp, register u_int length)
{
register const u_int32_t *dp;
register u_int len;
@@ -417,7 +473,7 @@ void
nfsreq_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
- register const struct sunrpc_msg *rp;
+ register const struct rpc_msg *rp;
register const u_int32_t *dp;
nfs_type type;
int v3;
@@ -426,7 +482,7 @@ nfsreq_print(register const u_char *bp, u_int length,
char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
- rp = (const struct sunrpc_msg *)bp;
+ rp = (const struct rpc_msg *)bp;
if (!nflag) {
snprintf(srcid, sizeof(srcid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
@@ -499,9 +555,9 @@ nfsreq_print(register const u_char *bp, u_int length,
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
- EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ printf(" %u bytes @ ",
+ EXTRACT_32BITS(&dp[2]));
+ print_int64(dp, UNSIGNED);
} else {
TCHECK(dp[1]);
printf(" %u bytes @ %u",
@@ -517,11 +573,10 @@ nfsreq_print(register const u_char *bp, u_int length,
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[2]);
- printf(" %u (%u) bytes @ %" PRIu64,
- EXTRACT_32BITS(&dp[4]),
- EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ TCHECK(dp[4]);
+ printf(" %u bytes @ ",
+ EXTRACT_32BITS(&dp[4]));
+ print_int64(dp, UNSIGNED);
if (vflag) {
dp += 3;
TCHECK(dp[0]);
@@ -636,9 +691,9 @@ nfsreq_print(register const u_char *bp, u_int length,
* We shouldn't really try to interpret the
* offset cookie here.
*/
- printf(" %u bytes @ %" PRId64,
- EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
+ printf(" %u bytes @ ",
+ EXTRACT_32BITS(&dp[4]));
+ print_int64(dp, SIGNED);
if (vflag)
printf(" verf %08x%08x", dp[2],
dp[3]);
@@ -665,14 +720,11 @@ nfsreq_print(register const u_char *bp, u_int length,
* We don't try to interpret the offset
* cookie here.
*/
- printf(" %u bytes @ %" PRId64,
- EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag) {
- TCHECK(dp[5]);
+ printf(" %u bytes @ ", EXTRACT_32BITS(&dp[4]));
+ print_int64(dp, SIGNED);
+ if (vflag)
printf(" max %u verf %08x%08x",
EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
- }
return;
}
break;
@@ -702,10 +754,8 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" commit");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
- EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ printf(" %u bytes @ ", EXTRACT_32BITS(&dp[2]));
+ print_int64(dp, UNSIGNED);
return;
}
break;
@@ -811,7 +861,7 @@ int xid_map_next = 0;
int xid_map_hint = 0;
static void
-xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
+xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
{
struct ip *ip = NULL;
#ifdef INET6
@@ -859,7 +909,7 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
* version in vers return, or returns -1 on failure
*/
static int
-xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
+xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
u_int32_t *vers)
{
int i;
@@ -926,11 +976,11 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
* If the packet was truncated, return 0.
*/
static const u_int32_t *
-parserep(register const struct sunrpc_msg *rp, register u_int length)
+parserep(register const struct rpc_msg *rp, register u_int length)
{
register const u_int32_t *dp;
u_int len;
- enum sunrpc_accept_stat astat;
+ enum accept_stat astat;
/*
* Portability note:
@@ -964,30 +1014,30 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
astat = EXTRACT_32BITS(dp);
switch (astat) {
- case SUNRPC_SUCCESS:
+ case SUCCESS:
break;
- case SUNRPC_PROG_UNAVAIL:
+ case PROG_UNAVAIL:
printf(" PROG_UNAVAIL");
nfserr = 1; /* suppress trunc string */
return (NULL);
- case SUNRPC_PROG_MISMATCH:
+ case PROG_MISMATCH:
printf(" PROG_MISMATCH");
nfserr = 1; /* suppress trunc string */
return (NULL);
- case SUNRPC_PROC_UNAVAIL:
+ case PROC_UNAVAIL:
printf(" PROC_UNAVAIL");
nfserr = 1; /* suppress trunc string */
return (NULL);
- case SUNRPC_GARBAGE_ARGS:
+ case GARBAGE_ARGS:
printf(" GARBAGE_ARGS");
nfserr = 1; /* suppress trunc string */
return (NULL);
- case SUNRPC_SYSTEM_ERR:
+ case SYSTEM_ERR:
printf(" SYSTEM_ERR");
nfserr = 1; /* suppress trunc string */
return (NULL);
@@ -1041,8 +1091,8 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
EXTRACT_32BITS(&fap->fa_gid));
if (v3) {
TCHECK(fap->fa3_size);
- printf(" sz %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_size));
+ printf(" sz ");
+ print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED);
} else {
TCHECK(fap->fa2_size);
printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size));
@@ -1056,10 +1106,10 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
- printf(" fsid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid));
- printf(" fileid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid));
+ printf(" fsid ");
+ print_int64((u_int32_t *)&fap->fa3_fsid, HEX);
+ printf(" fileid ");
+ print_int64((u_int32_t *)&fap->fa3_fileid, HEX);
printf(" a/m/ctime %u.%06u",
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
@@ -1167,15 +1217,20 @@ parsestatfs(const u_int32_t *dp, int v3)
sfsp = (const struct nfs_statfs *)dp;
if (v3) {
- printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes));
+ printf(" tbytes ");
+ print_int64((u_int32_t *)&sfsp->sf_tbytes, UNSIGNED);
+ printf(" fbytes ");
+ print_int64((u_int32_t *)&sfsp->sf_fbytes, UNSIGNED);
+ printf(" abytes ");
+ print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED);
if (vflag) {
- printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles),
+ printf(" tfiles ");
+ print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED);
+ printf(" ffiles ");
+ print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED);
+ printf(" afiles ");
+ print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED);
+ printf(" invar %u",
EXTRACT_32BITS(&sfsp->sf_invarsec));
}
} else {
@@ -1219,7 +1274,8 @@ trunc:
static const u_int32_t *
parse_wcc_attr(const u_int32_t *dp)
{
- printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0]));
+ printf(" sz ");
+ print_int64(dp, UNSIGNED);
printf(" mtime %u.%06u ctime %u.%06u",
EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
@@ -1365,10 +1421,10 @@ parsefsinfo(const u_int32_t *dp)
EXTRACT_32BITS(&sfp->fs_wtpref),
EXTRACT_32BITS(&sfp->fs_dtpref));
if (vflag) {
- printf(" rtmult %u wtmult %u maxfsz %" PRIu64,
+ printf(" rtmult %u wtmult %u maxfsz ",
EXTRACT_32BITS(&sfp->fs_rtmult),
- EXTRACT_32BITS(&sfp->fs_wtmult),
- EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize));
+ EXTRACT_32BITS(&sfp->fs_wtmult));
+ print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
printf(" delta %u.%06u ",
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
@@ -1409,7 +1465,7 @@ trunc:
}
static void
-interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
+interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
{
register const u_int32_t *dp;
register int v3;
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index da1e791..a97719f 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -21,11 +21,13 @@
* Format and print ntp packets.
* By Jeffrey Mogul/DECWRL
* loosely based on print-bootp.c
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41 2004/01/28 14:54:50 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.37.2.2 2003/11/16 08:51:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -52,26 +54,6 @@ static void p_sfix(const struct s_fixedpt *);
static void p_ntp_time(const struct l_fixedpt *);
static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *);
-static struct tok ntp_mode_values[] = {
- { MODE_UNSPEC, "unspecified" },
- { MODE_SYM_ACT, "symmetric active" },
- { MODE_SYM_PAS, "symmetric passive" },
- { MODE_CLIENT, "Client" },
- { MODE_SERVER, "Server" },
- { MODE_BROADCAST, "Broadcast" },
- { MODE_RES1, "Reserved" },
- { MODE_RES2, "Reserved" },
- { 0, NULL }
-};
-
-static struct tok ntp_leapind_values[] = {
- { NO_WARNING, "" },
- { PLUS_SEC, "+1s" },
- { MINUS_SEC, "-1s" },
- { ALARM, "clock unsynchronized" },
- { 0, NULL }
-};
-
/*
* Print ntp requests
*/
@@ -82,49 +64,90 @@ ntp_print(register const u_char *cp, u_int length)
int mode, version, leapind;
bp = (struct ntpdata *)cp;
+ /* Note funny sized packets */
+ if (length != sizeof(struct ntpdata))
+ (void)printf(" [len=%d]", length);
TCHECK(bp->status);
version = (int)(bp->status & VERSIONMASK) >> 3;
printf("NTPv%d", version);
+ leapind = bp->status & LEAPMASK;
+ switch (leapind) {
+
+ case NO_WARNING:
+ break;
+
+ case PLUS_SEC:
+ fputs(" +1s", stdout);
+ break;
+
+ case MINUS_SEC:
+ fputs(" -1s", stdout);
+ break;
+ }
+
mode = bp->status & MODEMASK;
- if (!vflag) {
- printf (", %s, length %u",
- tok2str(ntp_mode_values, "Unknown mode", mode),
- length);
- return;
- }
-
- printf (", length %u\n\t%s",
- length,
- tok2str(ntp_mode_values, "Unknown mode", mode));
+ switch (mode) {
- leapind = bp->status & LEAPMASK;
- printf (", Leap indicator: %s (%u)",
- tok2str(ntp_leapind_values, "Unknown", leapind),
- leapind);
+ case MODE_UNSPEC: /* unspecified */
+ fputs(" unspec", stdout);
+ break;
+
+ case MODE_SYM_ACT: /* symmetric active */
+ fputs(" sym_act", stdout);
+ break;
+
+ case MODE_SYM_PAS: /* symmetric passive */
+ fputs(" sym_pas", stdout);
+ break;
+
+ case MODE_CLIENT: /* client */
+ fputs(" client", stdout);
+ break;
+
+ case MODE_SERVER: /* server */
+ fputs(" server", stdout);
+ break;
+
+ case MODE_BROADCAST: /* broadcast */
+ fputs(" bcast", stdout);
+ break;
+
+ case MODE_RES1: /* reserved */
+ fputs(" res1", stdout);
+ break;
+
+ case MODE_RES2: /* reserved */
+ fputs(" res2", stdout);
+ break;
+
+ }
TCHECK(bp->stratum);
- printf(", Stratum %u", bp->stratum);
+ printf(", strat %d", bp->stratum);
TCHECK(bp->ppoll);
- printf(", poll %us", bp->ppoll);
+ printf(", poll %d", bp->ppoll);
/* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
- TCHECK2(bp->root_delay, 0);
- printf(", precision %d", bp->precision);
+ TCHECK2(bp->distance, 0);
+ printf(", prec %d", bp->precision);
+
+ if (!vflag)
+ return;
- TCHECK(bp->root_delay);
- fputs("\n\tRoot Delay: ", stdout);
- p_sfix(&bp->root_delay);
+ TCHECK(bp->distance);
+ fputs(" dist ", stdout);
+ p_sfix(&bp->distance);
- TCHECK(bp->root_dispersion);
- fputs(", Root dispersion: ", stdout);
- p_sfix(&bp->root_dispersion);
+ TCHECK(bp->dispersion);
+ fputs(", disp ", stdout);
+ p_sfix(&bp->dispersion);
TCHECK(bp->refid);
- fputs(", Reference-ID: ", stdout);
+ fputs(", ref ", stdout);
/* Interpretation depends on stratum */
switch (bp->stratum) {
@@ -151,29 +174,21 @@ ntp_print(register const u_char *cp, u_int length)
break;
}
- TCHECK(bp->ref_timestamp);
- fputs("\n\t Reference Timestamp: ", stdout);
- p_ntp_time(&(bp->ref_timestamp));
-
- TCHECK(bp->org_timestamp);
- fputs("\n\t Originator Timestamp: ", stdout);
- p_ntp_time(&(bp->org_timestamp));
-
- TCHECK(bp->rec_timestamp);
- fputs("\n\t Receive Timestamp: ", stdout);
- p_ntp_time(&(bp->rec_timestamp));
-
- TCHECK(bp->xmt_timestamp);
- fputs("\n\t Transmit Timestamp: ", stdout);
- p_ntp_time(&(bp->xmt_timestamp));
+ TCHECK(bp->reftime);
+ putchar('@');
+ p_ntp_time(&(bp->reftime));
- fputs("\n\t Originator - Receive Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
+ TCHECK(bp->org);
+ fputs(" orig ", stdout);
+ p_ntp_time(&(bp->org));
- fputs("\n\t Originator - Transmit Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
+ TCHECK(bp->rec);
+ fputs(" rec ", stdout);
+ p_ntp_delta(&(bp->org), &(bp->rec));
- /* FIXME key-id, authentication */
+ TCHECK(bp->xmt);
+ fputs(" xmt ", stdout);
+ p_ntp_delta(&(bp->org), &(bp->xmt));
return;
@@ -216,9 +231,9 @@ p_ntp_time(register const struct l_fixedpt *lfp)
#ifdef HAVE_STRFTIME
/*
- * print the time in human-readable format.
+ * For extra verbosity, print the time in human-readable format.
*/
- if (i) {
+ if (vflag > 1 && i) {
time_t seconds = i - JAN_1970;
struct tm *tm;
char time_buf[128];
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index 7d24884..a9f08ba 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 2005/04/06 21:32:41 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.49.2.2 2003/11/16 08:51:36 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -125,7 +127,7 @@ null_print(u_int family, u_int length)
/*
* This is the top level routine of the printer. 'p' points
* to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
@@ -163,7 +165,7 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (family) {
case BSD_AF_INET:
- ip_print(gndo, p, length);
+ ip_print(p, length);
break;
#ifdef INET6
@@ -197,9 +199,3 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
return (NULL_HDRLEN);
}
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c
index 9bdbd630..4aa4983 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 2005/04/06 21:32:42 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.37.2.4 2004/03/24 02:52:37 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -29,56 +31,6 @@ static const char rcsid[] _U_ =
#endif
#include <tcpdump-stdinc.h>
-#include "interface.h"
-
-#define PIMV2_TYPE_HELLO 0
-#define PIMV2_TYPE_REGISTER 1
-#define PIMV2_TYPE_REGISTER_STOP 2
-#define PIMV2_TYPE_JOIN_PRUNE 3
-#define PIMV2_TYPE_BOOTSTRAP 4
-#define PIMV2_TYPE_ASSERT 5
-#define PIMV2_TYPE_GRAFT 6
-#define PIMV2_TYPE_GRAFT_ACK 7
-#define PIMV2_TYPE_CANDIDATE_RP 8
-#define PIMV2_TYPE_PRUNE_REFRESH 9
-
-static struct tok pimv2_type_values[] = {
- { PIMV2_TYPE_HELLO, "Hello" },
- { PIMV2_TYPE_REGISTER, "Register" },
- { PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
- { PIMV2_TYPE_JOIN_PRUNE, "Join / Prune" },
- { PIMV2_TYPE_BOOTSTRAP, "Bootstrap" },
- { PIMV2_TYPE_ASSERT, "Assert" },
- { PIMV2_TYPE_GRAFT, "Graft" },
- { PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
- { PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
- { PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
- { 0, NULL}
-};
-
-#define PIMV2_HELLO_OPTION_HOLDTIME 1
-#define PIMV2_HELLO_OPTION_LANPRUNEDELAY 2
-#define PIMV2_HELLO_OPTION_DR_PRIORITY_OLD 18
-#define PIMV2_HELLO_OPTION_DR_PRIORITY 19
-#define PIMV2_HELLO_OPTION_GENID 20
-#define PIMV2_HELLO_OPTION_REFRESH_CAP 21
-#define PIMV2_HELLO_OPTION_BIDIR_CAP 22
-#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
-#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
-
-static struct tok pimv2_hello_option_values[] = {
- { PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
- { PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
- { PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
- { PIMV2_HELLO_OPTION_DR_PRIORITY, "DR Priority" },
- { PIMV2_HELLO_OPTION_GENID, "Generation ID" },
- { PIMV2_HELLO_OPTION_REFRESH_CAP, "State Refresh Capability" },
- { PIMV2_HELLO_OPTION_BIDIR_CAP, "Bi-Directional Capability" },
- { PIMV2_HELLO_OPTION_ADDRESS_LIST, "Address List" },
- { PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD, "Address List (Old)" },
- { 0, NULL}
-};
-
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -413,25 +365,12 @@ pim_print(register const u_char *bp, register u_int len)
#endif
switch (PIM_VER(pim->pim_typever)) {
- case 2:
- if (!vflag) {
- 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",
- PIM_VER(pim->pim_typever),
- len,
- tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
- pimv2_print(bp, len);
- }
- break;
+ case 2: /* avoid hardcoding? */
+ (void)printf("pim v2");
+ pimv2_print(bp, len);
+ break;
default:
- printf("PIMv%u, length: %u",
- PIM_VER(pim->pim_typever),
- len);
+ (void)printf("pim v%d", PIM_VER(pim->pim_typever));
break;
}
return;
@@ -624,86 +563,94 @@ pimv2_print(register const u_char *bp, register u_int len)
TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
- (void)printf(", RFC2117-encoding");
+ (void)printf("[RFC2117-encoding] ");
switch (PIM_TYPE(pim->pim_typever)) {
- case PIMV2_TYPE_HELLO:
+ case 0:
{
u_int16_t otype, olen;
+ (void)printf(" Hello");
bp += 4;
while (bp < ep) {
TCHECK2(bp[0], 4);
otype = EXTRACT_16BITS(&bp[0]);
olen = EXTRACT_16BITS(&bp[2]);
TCHECK2(bp[0], 4 + olen);
-
- printf("\n\t %s Option (%u), length: %u, Value: ",
- tok2str( pimv2_hello_option_values,"Unknown",otype),
- otype,
- olen);
- bp += 4;
-
switch (otype) {
- case PIMV2_HELLO_OPTION_HOLDTIME:
- relts_print(EXTRACT_16BITS(bp));
- break;
+ case 1: /* Hold time */
+ (void)printf(" (Hold-time ");
+ relts_print(EXTRACT_16BITS(&bp[4]));
+ (void)printf(")");
+ break;
- case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
+ case 2: /* LAN Prune Delay */
+ (void)printf(" (LAN-Prune-Delay: ");
if (olen != 4) {
- (void)printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
+ (void)printf("!olen=%d!)", olen);
} else {
char t_bit;
u_int16_t lan_delay, override_interval;
- lan_delay = EXTRACT_16BITS(bp);
- override_interval = EXTRACT_16BITS(bp+2);
+ lan_delay = EXTRACT_16BITS(&bp[4]);
+ override_interval = EXTRACT_16BITS(&bp[6]);
t_bit = (lan_delay & 0x8000)? 1 : 0;
lan_delay &= ~0x8000;
- (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
+ (void)printf("T-bit=%d lan-delay=%dms override-interval=%dms)",
t_bit, lan_delay, override_interval);
}
break;
- case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
- case PIMV2_HELLO_OPTION_DR_PRIORITY:
- switch (olen) {
- case 0:
- printf("Bi-Directional Capability (Old)");
- break;
- case 4:
- printf("%u", EXTRACT_32BITS(bp));
- break;
- default:
- printf("ERROR: Option Lenght != 4 Bytes (%u)", olen);
- break;
- }
- break;
-
- case PIMV2_HELLO_OPTION_GENID:
- (void)printf("0x%08x", EXTRACT_32BITS(bp));
+ case 18: /* Old DR-Priority */
+ if (olen == 4)
+ (void)printf(" (OLD-DR-Priority: %d)",
+ EXTRACT_32BITS(&bp[4]));
+ else
+ goto unknown;
+ break;
+
+
+ case 19: /* DR-Priority */
+ if (olen == 0) {
+ (void)printf(" (OLD-bidir-capable)");
+ break;
+ }
+ (void)printf(" (DR-Priority: ");
+ if (olen != 4) {
+ (void)printf("!olen=%d!)", olen);
+ } else {
+ (void)printf("%d)", EXTRACT_32BITS(&bp[4]));
+ }
+ break;
+
+ case 20:
+ (void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4]));
break;
- case PIMV2_HELLO_OPTION_REFRESH_CAP:
- (void)printf("v%d", *bp);
- if (*(bp+1) != 0) {
- (void)printf(", interval ");
- relts_print(*(bp+1));
+ case 21:
+ (void)printf(" (State Refresh Capable; v%d", bp[4]);
+ if (bp[5] != 0) {
+ (void)printf(" interval ");
+ relts_print(bp[5]);
}
- if (EXTRACT_16BITS(bp+2) != 0) {
- (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
+ if (EXTRACT_16BITS(&bp[6]) != 0) {
+ (void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6]));
}
+ (void)printf(")");
break;
- case PIMV2_HELLO_OPTION_BIDIR_CAP:
+ case 22: /* Bidir-Capable */
+ (void)printf(" (bidir-capable)");
break;
- case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
- case PIMV2_HELLO_OPTION_ADDRESS_LIST:
+ case 24: /* Address List */
+ case 65001: /* Address List (old implementations) */
+ (void)printf(" (%saddr-list",
+ otype == 65001 ? "old" : "");
if (vflag > 1) {
- const u_char *ptr = bp;
- while (ptr < (bp+olen)) {
+ const u_char *ptr = &bp[4];
+ while (ptr < &bp[4 + olen]) {
int advance;
- printf("\n\t ");
+ printf(" ");
advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
if (advance < 0) {
printf("...");
@@ -712,24 +659,23 @@ pimv2_print(register const u_char *bp, register u_int len)
ptr += advance;
}
}
+ (void)printf(")");
break;
default:
- if (vflag <= 1)
- print_unknown_data(bp,"\n\t ",olen);
- break;
+ unknown:
+ if (vflag)
+ (void)printf(" [Hello option %d]", otype);
}
- /* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- print_unknown_data(bp,"\n\t ",olen);
- bp += olen;
+ bp += 4 + olen;
}
break;
}
- case PIMV2_TYPE_REGISTER:
+ case 1:
{
struct ip *ip;
+ (void)printf(" Register");
if (vflag && bp + 8 <= ep) {
(void)printf(" %s%s", bp[4] & 0x80 ? "B" : "",
bp[4] & 0x40 ? "N" : "");
@@ -743,7 +689,7 @@ pimv2_print(register const u_char *bp, register u_int len)
switch (IP_V(ip)) {
case 4: /* IPv4 */
printf(" ");
- ip_print(gndo, bp, len);
+ ip_print(bp, len);
break;
#ifdef INET6
case 6: /* IPv6 */
@@ -758,7 +704,8 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
- case PIMV2_TYPE_REGISTER_STOP:
+ case 2:
+ (void)printf(" Register-Stop");
bp += 4; len -= 4;
if (bp >= ep)
break;
@@ -778,46 +725,9 @@ pimv2_print(register const u_char *bp, register u_int len)
bp += advance; len -= advance;
break;
- case PIMV2_TYPE_JOIN_PRUNE:
- case PIMV2_TYPE_GRAFT:
- case PIMV2_TYPE_GRAFT_ACK:
-
-
- /*
- * 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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |PIM Ver| Type | Addr length | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Unicast-Upstream Neighbor Address |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reserved | Num groups | Holdtime |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Multicast Group Address-1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Number of Joined Sources | Number of Pruned Sources |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Joined Source Address-1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | . |
- * | . |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Joined Source Address-n |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Pruned Source Address-1 |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | . |
- * | . |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Pruned Source Address-n |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | . |
- * | . |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encoded-Multicast Group Address-n |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
+ case 3:
+ case 6:
+ case 7:
{
u_int8_t ngroup;
u_int16_t holdtime;
@@ -825,11 +735,22 @@ pimv2_print(register const u_char *bp, register u_int len)
u_int16_t nprune;
int i, j;
+ switch (PIM_TYPE(pim->pim_typever)) {
+ case 3:
+ (void)printf(" Join/Prune");
+ break;
+ case 6:
+ (void)printf(" Graft");
+ break;
+ case 7:
+ (void)printf(" Graft-ACK");
+ break;
+ }
bp += 4; len -= 4;
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
- (void)printf(", upstream-neighbor: ");
+ (void)printf(" upstream-neighbor=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
break;
@@ -840,11 +761,11 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
- (void)printf("\n\t %u group(s)", ngroup);
+ (void)printf(" groups=%u", ngroup);
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
- (void)printf(", holdtime: ");
+ (void)printf(" holdtime=");
if (holdtime == 0xffff)
- (void)printf("infinite");
+ (void)printf("infty");
else
relts_print(holdtime);
}
@@ -852,7 +773,7 @@ pimv2_print(register const u_char *bp, register u_int len)
for (i = 0; i < ngroup; i++) {
if (bp >= ep)
goto jp_done;
- (void)printf("\n\t group #%u: ", i+1);
+ (void)printf(" (group%d: ", i);
if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
(void)printf("...)");
goto jp_done;
@@ -864,32 +785,36 @@ pimv2_print(register const u_char *bp, register u_int len)
}
njoin = EXTRACT_16BITS(&bp[0]);
nprune = EXTRACT_16BITS(&bp[2]);
- (void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
+ (void)printf(" join=%u", njoin);
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
- (void)printf("\n\t joined source #%u: ",j+1);
+ (void)printf(" ");
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
+ (void)printf(" prune=%u", nprune);
for (j = 0; j < nprune; j++) {
- (void)printf("\n\t pruned source #%u: ",j+1);
+ (void)printf(" ");
if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
(void)printf("...)");
goto jp_done;
}
bp += advance; len -= advance;
}
+ (void)printf(")");
}
jp_done:
break;
}
- case PIMV2_TYPE_BOOTSTRAP:
+ case 4:
{
int i, j, frpcnt;
+
+ (void)printf(" Bootstrap");
bp += 4;
/* Fragment Tag, Hash Mask len, and BSR-priority */
@@ -963,7 +888,8 @@ pimv2_print(register const u_char *bp, register u_int len)
bs_done:
break;
}
- case PIMV2_TYPE_ASSERT:
+ case 5:
+ (void)printf(" Assert");
bp += 4; len -= 4;
if (bp >= ep)
break;
@@ -989,9 +915,11 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
break;
- case PIMV2_TYPE_CANDIDATE_RP:
+ case 8:
{
int i, pfxcnt;
+
+ (void)printf(" Candidate-RP-Advertisement");
bp += 4;
/* Prefix-Cnt, Priority, and Holdtime */
@@ -1027,7 +955,8 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
}
- case PIMV2_TYPE_PRUNE_REFRESH:
+ case 9:
+ (void)printf(" Prune-Refresh");
(void)printf(" src=");
if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
(void)printf("...");
@@ -1062,10 +991,3 @@ pimv2_print(register const u_char *bp, register u_int len)
trunc:
(void)printf("[|pim]");
}
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index a685322..c63b197 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 2005/04/06 21:32:42 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.89.2.4 2004/07/13 16:00:25 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -47,7 +49,6 @@ static const char rcsid[] _U_ =
#include <pcap.h>
#include <stdio.h>
-#include <stdlib.h>
#include "interface.h"
#include "extract.h"
@@ -55,7 +56,6 @@ static const char rcsid[] _U_ =
#include "ppp.h"
#include "chdlc.h"
#include "ethertype.h"
-#include "oui.h"
/*
* The following constatns are defined by IANA. Please refer to
@@ -72,16 +72,13 @@ struct tok ppptype2str[] = {
{ PPP_DECNET, "DECNET" },
{ PPP_APPLE, "APPLE" },
{ PPP_IPX, "IPX" },
- { PPP_VJC, "VJC IP" },
- { PPP_VJNC, "VJNC IP" },
+ { PPP_VJC, "VJC" },
+ { PPP_VJNC, "VJNC" },
{ PPP_BRPDU, "BRPDU" },
{ PPP_STII, "STII" },
{ PPP_VINES, "VINES" },
{ PPP_MPLS_UCAST, "MPLS" },
{ PPP_MPLS_MCAST, "MPLS" },
- { PPP_COMP, "Compressed"},
- { PPP_ML, "MLPPP"},
- { PPP_IPV6, "IP6"},
{ PPP_HELLO, "HELLO" },
{ PPP_LUXCOM, "LUXCOM" },
@@ -94,19 +91,15 @@ struct tok ppptype2str[] = {
{ PPP_IPXCP, "IPXCP" },
{ PPP_STIICP, "STIICP" },
{ PPP_VINESCP, "VINESCP" },
- { PPP_IPV6CP, "IP6CP" },
{ PPP_MPLSCP, "MPLSCP" },
{ PPP_LCP, "LCP" },
{ PPP_PAP, "PAP" },
{ PPP_LQM, "LQM" },
{ PPP_CHAP, "CHAP" },
- { PPP_EAP, "EAP" },
- { PPP_SPAP, "SPAP" },
- { PPP_SPAP_OLD, "Old-SPAP" },
{ PPP_BACP, "BACP" },
{ PPP_BAP, "BAP" },
- { PPP_MPCP, "MLPPP-CP" },
+ { PPP_MP, "ML" },
{ 0, NULL }
};
@@ -205,7 +198,7 @@ static const char *lcpconfopts[] = {
"deprecated(15)", /* used to be a Compund-Frames */
"deprecated(16)", /* used to be a Nominal-Data-Encap */
"MRRU", /* (17) */
- "12-Bit seq #", /* (18) */
+ "SSNHF", /* (18) */
"End-Disc", /* (19) */
"Proprietary", /* (20) */
"DCE-Id", /* (21) */
@@ -220,6 +213,7 @@ static const char *lcpconfopts[] = {
"PPP-Muxing", /* (30) */
};
+/* IPV6CP - to be supported */
/* ECP - to be supported */
/* CCP Config Options */
@@ -283,36 +277,17 @@ static const char *ccpconfopts[] = {
/* SDCP - to be supported */
/* IPCP Config Options */
+
#define IPCPOPT_2ADDR 1 /* RFC1172, RFC1332 (deprecated) */
#define IPCPOPT_IPCOMP 2 /* RFC1332 */
#define IPCPOPT_ADDR 3 /* RFC1332 */
#define IPCPOPT_MOBILE4 4 /* RFC2290 */
+
#define IPCPOPT_PRIDNS 129 /* RFC1877 */
#define IPCPOPT_PRINBNS 130 /* RFC1877 */
#define IPCPOPT_SECDNS 131 /* RFC1877 */
#define IPCPOPT_SECNBNS 132 /* RFC1877 */
-struct tok ipcpopt_values[] = {
- { IPCPOPT_2ADDR, "IP-Addrs" },
- { IPCPOPT_IPCOMP, "IP-Comp" },
- { IPCPOPT_ADDR, "IP-Addr" },
- { IPCPOPT_MOBILE4, "Home-Addr" },
- { IPCPOPT_PRIDNS, "Pri-DNS" },
- { IPCPOPT_PRINBNS, "Pri-NBNS" },
- { IPCPOPT_SECDNS, "Sec-DNS" },
- { IPCPOPT_SECNBNS, "Sec-NBNS" },
- { 0, NULL }
-};
-
-
-/* IP6CP Config Options */
-#define IP6CP_IFID 1
-
-struct tok ip6cpopt_values[] = {
- { IP6CP_IFID, "Interface-ID" },
- { 0, NULL }
-};
-
/* ATCP - to be supported */
/* OSINLCP - to be supported */
/* BVCP - to be supported */
@@ -327,13 +302,6 @@ struct tok ip6cpopt_values[] = {
#define AUTHALG_MSCHAP1 128 /* RFC2433 */
#define AUTHALG_MSCHAP2 129 /* RFC2795 */
-struct tok authalg_values[] = {
- { AUTHALG_CHAPMD5, "MD5" },
- { AUTHALG_MSCHAP1, "MS-CHAPv1" },
- { AUTHALG_MSCHAP2, "MS-CHAPv2" },
- { 0, NULL }
-};
-
/* FCS Alternatives - to be supported */
/* Multilink Endpoint Discriminator (RFC1717) */
@@ -359,12 +327,14 @@ struct tok authalg_values[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
-struct tok chapcode_values[] = {
- { CHAP_CHAL, "Challenge" },
- { CHAP_RESP, "Response" },
- { CHAP_SUCC, "Success" },
- { CHAP_FAIL, "Fail" },
- { 0, NULL}
+#define CHAP_CODEMIN CHAP_CHAL
+#define CHAP_CODEMAX CHAP_FAIL
+
+static const char *chapcode[] = {
+ "Chal", /* (1) */
+ "Resp", /* (2) */
+ "Succ", /* (3) */
+ "Fail", /* (4) */
};
/* PAP */
@@ -373,11 +343,13 @@ struct tok chapcode_values[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
-struct tok papcode_values[] = {
- { PAP_AREQ, "Auth-Req" },
- { PAP_AACK, "Auth-ACK" },
- { PAP_ANAK, "Auth-NACK" },
- { 0, NULL }
+#define PAP_CODEMIN PAP_AREQ
+#define PAP_CODEMAX PAP_ANAK
+
+static const char *papcode[] = {
+ "Auth-Req", /* (1) */
+ "Auth-Ack", /* (2) */
+ "Auth-Nak", /* (3) */
};
/* BAP */
@@ -394,14 +366,11 @@ static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
static void handle_chap (const u_char *p, int length);
static void handle_pap (const u_char *p, int length);
static void handle_bap (const u_char *p, int length);
-static void handle_mlppp(const u_char *p, int length);
static int print_lcp_config_options (const u_char *p, int);
static int print_ipcp_config_options (const u_char *p, int);
-static int print_ip6cp_config_options (const u_char *p, int);
static int print_ccp_config_options (const u_char *p, int);
static int print_bacp_config_options (const u_char *p, int);
static void handle_ppp (u_int proto, const u_char *p, int length);
-static void ppp_hdlc(const u_char *p, int length);
/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
@@ -415,7 +384,7 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
tptr=pptr;
- typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
+ typestr = tok2str(ppptype2str, "unknown", proto);
printf("%s, ",typestr);
if (length < 4) /* FIXME weak boundary checking */
@@ -434,7 +403,7 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
tptr += 2;
if (length <= 4)
- goto print_len_and_return; /* there may be a NULL confreq etc. */
+ return; /* there may be a NULL confreq etc. */
switch (code) {
case CPCODES_VEXT:
@@ -444,9 +413,7 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
printf(", Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
tptr += 4;
TCHECK2(*tptr, 3);
- printf(" Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",EXTRACT_24BITS(tptr)),
- EXTRACT_24BITS(tptr));
+ printf(" OUI 0x%06x", EXTRACT_24BITS(tptr));
/* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
@@ -462,9 +429,6 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
case PPP_IPCP:
pfunc = print_ipcp_config_options;
break;
- case PPP_IPV6CP:
- pfunc = print_ip6cp_config_options;
- break;
case PPP_CCP:
pfunc = print_ccp_config_options;
break;
@@ -473,16 +437,17 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
break;
default:
/*
- * No print routine for the options for
- * this protocol.
+ * This should never happen, but we set
+ * "pfunc" to squelch uninitialized
+ * variable warnings from compilers.
*/
pfunc = NULL;
break;
}
- if (pfunc == NULL) /* catch the above null pointer if unknown CP */
- break;
-
+ if (pfunc == NULL) /* catch the above null pointer if unknown CP */
+ break;
+
if ((j = (*pfunc)(tptr, len)) == 0)
break;
x -= j;
@@ -533,8 +498,6 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
print_unknown_data(pptr-2,"\n\t",length+2);
break;
}
-
- print_len_and_return:
printf(", length %u", length);
if (vflag >1)
@@ -559,7 +522,7 @@ print_lcp_config_options(const u_char *p, int length)
if (length < len)
return 0;
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
- printf(", %s (%u)", lcpconfopts[opt],opt);
+ printf(", %s ", lcpconfopts[opt]);
else {
printf(", unknown LCP option 0x%02x", opt);
return len;
@@ -569,13 +532,11 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_VEXT:
if (len >= 6) {
TCHECK2(*(p + 2), 3);
- printf(" Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
- EXTRACT_24BITS(p+2));
+ printf(" OUI 0x%06x", EXTRACT_24BITS(p+2));
#if 0
TCHECK(p[5]);
- printf(", kind: 0x%02x", p[5]);
- printf(", Value: 0x")
+ printf(" kind 0x%02x", p[5]);
+ printf(" val 0x")
for (i = 0; i < len - 6; i++) {
TCHECK(p[6 + i]);
printf("%02x", p[6 + i]);
@@ -592,26 +553,45 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_ACCM:
if (len == 6) {
TCHECK2(*(p + 2), 4);
- printf(" 0x%08x", EXTRACT_32BITS(p + 2));
+ printf(" %08x", EXTRACT_32BITS(p + 2));
}
break;
case LCPOPT_AP:
if (len >= 4) {
TCHECK2(*(p + 2), 2);
- printf(" %s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
-
switch (EXTRACT_16BITS(p+2)) {
+ case PPP_PAP:
+ printf(" PAP");
+ break;
case PPP_CHAP:
+ printf(" CHAP");
TCHECK(p[4]);
- printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4]));
+ switch (p[4]) {
+ default:
+ printf(", unknown-algorithm-%u", p[4]);
+ break;
+ case AUTHALG_CHAPMD5:
+ printf(", MD5");
+ break;
+ case AUTHALG_MSCHAP1:
+ printf(", MSCHAPv1");
+ break;
+ case AUTHALG_MSCHAP2:
+ printf(", MSCHAPv2");
+ break;
+ }
break;
- case PPP_PAP: /* fall through */
case PPP_EAP:
+ printf(" EAP");
+ break;
case PPP_SPAP:
+ printf(" SPAP");
+ break;
case PPP_SPAP_OLD:
- break;
+ printf(" Old-SPAP");
+ break;
default:
- print_unknown_data(p,"\n\t",len);
+ printf("unknown");
}
}
break;
@@ -717,7 +697,7 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_DEP14:
case LCPOPT_DEP15:
case LCPOPT_DEP16:
- case LCPOPT_MLSSNHF:
+ case LCPOPT_MLSSNHF:
case LCPOPT_PROP:
case LCPOPT_DCEID:
case LCPOPT_MPP:
@@ -738,27 +718,6 @@ trunc:
return 0;
}
-/* ML-PPP*/
-struct tok ppp_ml_flag_values[] = {
- { 0x80, "begin" },
- { 0x40, "end" },
- { 0, NULL }
-};
-
-static void
-handle_mlppp(const u_char *p, int length) {
-
- if (!eflag)
- printf("MLPPP, ");
-
- printf("seq 0x%03x, Flags [%s], length %u",
- (EXTRACT_16BITS(p))&0x0fff, /* only support 12-Bit sequence space for now */
- bittok2str(ppp_ml_flag_values, "none", *p & 0xc0),
- length);
-
- return;
-}
-
/* CHAP */
static void
handle_chap(const u_char *p, int length)
@@ -780,13 +739,16 @@ handle_chap(const u_char *p, int length)
TCHECK(*p);
code = *p;
- printf("CHAP, %s (0x%02x)",
- tok2str(chapcode_values,"unknown",code),
- code);
+ if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX))
+ printf("%s", chapcode[code - 1]);
+ else {
+ printf("0x%02x", code);
+ return;
+ }
p++;
TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ printf("(%u)", *p); /* ID */
p++;
TCHECK2(*p, 2);
@@ -859,13 +821,16 @@ handle_pap(const u_char *p, int length)
TCHECK(*p);
code = *p;
- printf("PAP, %s (0x%02x)",
- tok2str(papcode_values,"unknown",code),
- code);
+ if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
+ printf("%s", papcode[code - 1]);
+ else {
+ printf("0x%02x", code);
+ return;
+ }
p++;
TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ printf("(%u)", *p); /* ID */
p++;
TCHECK2(*p, 2);
@@ -943,85 +908,61 @@ print_ipcp_config_options(const u_char *p, int length)
opt = p[0];
if (length < len)
return 0;
-
- printf(", %s (0x%02x) ",
- tok2str(ipcpopt_values,"unknown",opt),
- opt);
-
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
if (len != 10)
goto invlen;
TCHECK2(*(p + 6), 4);
- printf("src %s, dst %s",
+ printf(", IP-Addrs src %s, dst %s",
ipaddr_string(p + 2),
ipaddr_string(p + 6));
break;
case IPCPOPT_IPCOMP:
if (len < 4)
goto invlen;
+ printf(", IP-Comp");
TCHECK2(*(p + 2), 2);
if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
- printf("VJ-Comp");
+ printf(" VJ-Comp");
/* XXX: VJ-Comp parameters should be decoded */
} else
- printf("unknown-comp-proto %04x", EXTRACT_16BITS(p + 2));
+ printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2));
+ break;
+ case IPCPOPT_ADDR:
+ if (len != 6)
+ goto invlen;
+ TCHECK2(*(p + 2), 4);
+ printf(", IP-Addr %s", ipaddr_string(p + 2));
break;
-
- case IPCPOPT_ADDR: /* those options share the same format - fall through */
case IPCPOPT_MOBILE4:
+ if (len != 6)
+ goto invlen;
+ TCHECK2(*(p + 2), 4);
+ printf(", Home-Addr %s", ipaddr_string(p + 2));
+ break;
case IPCPOPT_PRIDNS:
+ if (len != 6)
+ goto invlen;
+ TCHECK2(*(p + 2), 4);
+ printf(", Pri-DNS %s", ipaddr_string(p + 2));
+ break;
case IPCPOPT_PRINBNS:
- case IPCPOPT_SECDNS:
- case IPCPOPT_SECNBNS:
if (len != 6)
goto invlen;
TCHECK2(*(p + 2), 4);
- printf("%s", ipaddr_string(p + 2));
+ printf(", Pri-NBNS %s", ipaddr_string(p + 2));
break;
- default:
- printf(", unknown-%d", opt);
+ case IPCPOPT_SECDNS:
+ if (len != 6)
+ goto invlen;
+ TCHECK2(*(p + 2), 4);
+ printf(", Sec-DNS %s", ipaddr_string(p + 2));
break;
- }
- return len;
-
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-
-trunc:
- printf("[|ipcp]");
- return 0;
-}
-
-/* IP6CP config options */
-static int
-print_ip6cp_config_options(const u_char *p, int length)
-{
- int len, opt;
-
- if (length < 2)
- return 0;
- TCHECK2(*p, 2);
- len = p[1];
- opt = p[0];
- if (length < len)
- return 0;
-
- printf(", %s (0x%02x) ",
- tok2str(ip6cpopt_values,"unknown",opt),
- opt);
-
- switch (opt) {
- case IP6CP_IFID:
- if (len != 10)
+ case IPCPOPT_SECNBNS:
+ if (len != 6)
goto invlen;
- TCHECK2(*(p + 2), 8);
- printf("%04x:%04x:%04x:%04x",
- EXTRACT_16BITS(p + 2),
- EXTRACT_16BITS(p + 4),
- EXTRACT_16BITS(p + 6),
- EXTRACT_16BITS(p + 8));
+ TCHECK2(*(p + 2), 4);
+ printf(", Sec-NBNS %s", ipaddr_string(p + 2));
break;
default:
printf(", unknown-%d", opt);
@@ -1034,11 +975,10 @@ invlen:
return 0;
trunc:
- printf("[|ip6cp]");
+ printf("[|ipcp]");
return 0;
}
-
/* CCP config options */
static int
print_ccp_config_options(const u_char *p, int length)
@@ -1113,83 +1053,12 @@ trunc:
}
-static void
-ppp_hdlc(const u_char *p, int length)
-{
- u_char *b, *s, *t, c;
- int i, proto;
- const void *se;
-
- b = (u_int8_t *)malloc(length);
- if (b == NULL)
- return;
-
- /*
- * Unescape all the data into a temporary, private, buffer.
- * Do this so that we dont overwrite the original packet
- * contents.
- */
- for (s = (u_char *)p, t = b, i = length; i > 0; i--) {
- c = *s++;
- if (c == 0x7d) {
- if (i > 1) {
- i--;
- c = *s++ ^ 0x20;
- } else
- continue;
- }
- *t++ = c;
- }
-
- se = snapend;
- snapend = t;
-
- /* now lets guess about the payload codepoint format */
- proto = *b; /* start with a one-octet codepoint guess */
-
- switch (proto) {
- case PPP_IP:
- ip_print(gndo, b+1, t - b - 1);
- goto cleanup;
-#ifdef INET6
- case PPP_IPV6:
- ip6_print(b+1, t - b - 1);
- goto cleanup;
-#endif
- default: /* no luck - try next guess */
- break;
- }
-
- proto = EXTRACT_16BITS(b); /* next guess - load two octets */
-
- switch (proto) {
- case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
- proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
- handle_ppp(proto, b+4, t - b - 4);
- break;
- default: /* last guess - proto must be a PPP proto-id */
- handle_ppp(proto, b+2, t - b - 2);
- break;
- }
-
-cleanup:
- snapend = se;
- free(b);
- return;
-}
-
-
/* PPP */
static void
handle_ppp(u_int proto, const u_char *p, int length)
{
- if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
- ppp_hdlc(p-1, length);
- return;
- }
-
switch (proto) {
- case PPP_LCP: /* fall through */
+ case PPP_LCP:
case PPP_IPCP:
case PPP_OSICP:
case PPP_MPLSCP:
@@ -1198,9 +1067,6 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_BACP:
handle_ctrl_proto(proto, p, length);
break;
- case PPP_ML:
- handle_mlppp(p, length);
- break;
case PPP_CHAP:
handle_chap(p, length);
break;
@@ -1211,9 +1077,8 @@ handle_ppp(u_int proto, const u_char *p, int length)
handle_bap(p, length);
break;
case ETHERTYPE_IP: /*XXX*/
- case PPP_VJNC:
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(p, length);
break;
#ifdef INET6
case ETHERTYPE_IPV6: /*XXX*/
@@ -1232,13 +1097,10 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_MPLS_MCAST:
mpls_print(p, length);
break;
- case PPP_COMP:
- printf("compressed PPP data");
- break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
- print_unknown_data(p,"\n\t",length);
- break;
+ printf("unknown PPP protocol (0x%04x)", proto);
+ print_unknown_data(p,"\n\t",length);
+ break;
}
}
@@ -1246,7 +1108,7 @@ handle_ppp(u_int proto, const u_char *p, int length)
u_int
ppp_print(register const u_char *p, u_int length)
{
- u_int proto,ppp_header;
+ u_int proto;
u_int olen = length; /* _o_riginal length */
u_int hdr_len = 0;
@@ -1257,30 +1119,11 @@ ppp_print(register const u_char *p, u_int length)
if (length < 2)
goto trunc;
TCHECK2(*p, 2);
- ppp_header = EXTRACT_16BITS(p);
-
- switch(ppp_header) {
- case (PPP_WITHDIRECTION_IN << 8 | PPP_CONTROL):
- if (eflag) printf("In ");
- p += 2;
- length -= 2;
- hdr_len += 2;
- break;
- case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
- if (eflag) printf("Out ");
- p += 2;
- length -= 2;
- hdr_len += 2;
- break;
- case (PPP_ADDRESS << 8 | PPP_CONTROL):
- p += 2; /* ACFC not used */
- length -= 2;
- hdr_len += 2;
- break;
-
- default:
- break;
- }
+ if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
+ p += 2; /* ACFC not used */
+ length -= 2;
+ hdr_len += 2;
+ }
if (length < 2)
goto trunc;
@@ -1299,7 +1142,7 @@ ppp_print(register const u_char *p, u_int length)
}
if (eflag)
- printf("%s (0x%04x), length %u: ",
+ printf("PPP-%s (0x%04x), length %u: ",
tok2str(ppptype2str, "unknown", proto),
proto,
olen);
@@ -1597,11 +1440,3 @@ printx:
#endif /* __bsdi__ */
return (hdrlength);
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index f28a21a..87f31bb 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.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-sl.c,v 1.65 2005/04/06 21:32:42 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.62.2.2 2003/11/16 08:51:44 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -69,7 +71,7 @@ sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (IP_V(ip)) {
case 4:
- ip_print(gndo, (u_char *)ip, length);
+ ip_print((u_char *)ip, length);
break;
#ifdef INET6
case 6:
@@ -104,7 +106,7 @@ sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
sliplink_print(p, ip, length);
#endif
- ip_print(gndo, (u_char *)ip, length);
+ ip_print((u_char *)ip, length);
return (SLIP_HDRLEN);
}
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 8fa733c..83e16f0 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.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-sunrpc.c,v 1.46 2004/12/27 00:41:31 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.43.2.2 2003/11/16 08:51:47 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,12 +32,13 @@ static const char rcsid[] _U_ =
#include <tcpdump-stdinc.h>
-#ifdef HAVE_GETRPCBYNUMBER
#include <rpc/rpc.h>
#ifdef HAVE_RPC_RPCENT_H
#include <rpc/rpcent.h>
-#endif /* HAVE_RPC_RPCENT_H */
-#endif /* HAVE_GETRPCBYNUMBER */
+#endif
+#ifndef WIN32
+#include <rpc/pmap_prot.h>
+#endif /* WIN32 */
#include <stdio.h>
#include <string.h>
@@ -49,10 +52,6 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
-#include "rpc_auth.h"
-#include "rpc_msg.h"
-#include "pmap_prot.h"
-
static struct tok proc2str[] = {
{ PMAPPROC_NULL, "null" },
{ PMAPPROC_SET, "set" },
@@ -70,7 +69,7 @@ void
sunrpcrequest_print(register const u_char *bp, register u_int length,
register const u_char *bp2)
{
- register const struct sunrpc_msg *rp;
+ register const struct rpc_msg *rp;
register const struct ip *ip;
#ifdef INET6
register const struct ip6_hdr *ip6;
@@ -78,7 +77,7 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
u_int32_t x;
char srcid[20], dstid[20]; /*fits 32bit*/
- rp = (struct sunrpc_msg *)bp;
+ rp = (struct rpc_msg *)bp;
if (!nflag) {
snprintf(srcid, sizeof(srcid), "0x%x",
@@ -136,7 +135,7 @@ static char *
progstr(prog)
u_int32_t prog;
{
-#ifdef HAVE_GETRPCBYNUMBER
+#ifndef WIN32
register struct rpcent *rp;
#endif
static char buf[32];
@@ -144,12 +143,12 @@ progstr(prog)
if (lastprog != 0 && prog == lastprog)
return (buf);
-#ifdef HAVE_GETRPCBYNUMBER
+#ifndef WIN32
rp = getrpcbynumber(prog);
if (rp == NULL)
-#endif
+#endif /* WIN32 */
(void) snprintf(buf, sizeof(buf), "#%u", prog);
-#ifdef HAVE_GETRPCBYNUMBER
+#ifndef WIN32
else
strlcpy(buf, rp->r_name, sizeof(buf));
#endif
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c
index 0633578..4d06706 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 2004/03/17 23:24:38 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.22.2.2 2003/11/16 08:51:51 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -185,7 +187,7 @@ token_print(const u_char *p, u_int length, u_int caplen)
/*
* This is the top level routine of the printer. 'p' points
* to the TR header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * 'h->length' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
u_int
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 87da886..7d910cb 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 2005/04/07 00:28:17 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.124.2.5 2003/11/19 00:19:25 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -35,6 +37,8 @@ static const char rcsid[] _U_ =
#endif
#include <arpa/tftp.h>
+#include <rpc/rpc.h>
+
#include <stdio.h>
#include <string.h>
@@ -50,8 +54,6 @@ static const char rcsid[] _U_ =
#include "ip6.h"
#endif
#include "ipproto.h"
-#include "rpc_auth.h"
-#include "rpc_msg.h"
#include "nameser.h"
#include "nfs.h"
@@ -468,8 +470,8 @@ udp_print(register const u_char *bp, u_int length,
return;
}
if (packettype) {
- register struct sunrpc_msg *rp;
- enum sunrpc_msg_type direction;
+ register struct rpc_msg *rp;
+ enum msg_type direction;
switch (packettype) {
@@ -484,9 +486,9 @@ udp_print(register const u_char *bp, u_int length,
break;
case PT_RPC:
- rp = (struct sunrpc_msg *)(up + 1);
- direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
- if (direction == SUNRPC_CALL)
+ rp = (struct rpc_msg *)(up + 1);
+ direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (direction == CALL)
sunrpcrequest_print((u_char *)rp, length,
(u_char *)ip);
else
@@ -526,7 +528,7 @@ udp_print(register const u_char *bp, u_int length,
#ifdef INET6
ip6 != NULL);
#else
- 0);
+ FALSE);
#endif
break;
}
@@ -534,24 +536,24 @@ udp_print(register const u_char *bp, u_int length,
}
if (!qflag) {
- register struct sunrpc_msg *rp;
- enum sunrpc_msg_type direction;
+ register struct rpc_msg *rp;
+ enum msg_type direction;
- rp = (struct sunrpc_msg *)(up + 1);
+ rp = (struct rpc_msg *)(up + 1);
if (TTEST(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
- if (dport == NFS_PORT && direction == SUNRPC_CALL) {
+ direction = (enum msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (dport == NFS_PORT && direction == CALL) {
nfsreq_print((u_char *)rp, length,
(u_char *)ip);
return;
}
- if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
+ if (sport == NFS_PORT && direction == REPLY) {
nfsreply_print((u_char *)rp, length,
(u_char *)ip);
return;
}
#ifdef notdef
- if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
+ if (dport == SUNRPC_PORT && direction == CALL) {
sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
return;
}
@@ -568,7 +570,7 @@ udp_print(register const u_char *bp, u_int length,
}
udpipaddr_print(ip, sport, dport);
- if (IP_V(ip) == 4 && (vflag > 1) && !fragmented) {
+ if (IP_V(ip) == 4 && vflag && !fragmented) {
int sum = up->uh_sum;
if (sum == 0) {
(void)printf("[no cksum] ");
@@ -613,15 +615,13 @@ udp_print(register const u_char *bp, u_int length,
#ifdef INET6
ip6 != NULL);
#else
- 0);
+ FALSE);
#endif
- else if (ISPORT(ISAKMP_PORT))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
- else if (ISPORT(ISAKMP_PORT_NATT))
- isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (ISPORT(ISAKMP_PORT))
+ isakmp_print((const u_char *)(up + 1), length, bp2);
#if 1 /*???*/
- else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
+ isakmp_print((const u_char *)(up + 1), length, bp2);
#endif
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
snmp_print((const u_char *)(up + 1), length);
@@ -675,29 +675,14 @@ udp_print(register const u_char *bp, u_int length,
else if (ISPORT(LDP_PORT))
ldp_print((const u_char *)(up + 1), length);
else if (ISPORT(MPLS_LSP_PING_PORT))
- lspping_print((const u_char *)(up + 1), length);
+ mpls_lsp_ping_print((const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
dport == BFD_ECHO_PORT )
bfd_print((const u_char *)(up+1), length, dport);
- else if (ISPORT(LMP_PORT))
- lmp_print((const u_char *)(up + 1), length);
- else if (ISPORT(SIP_PORT))
- sip_print((const u_char *)(up + 1), length);
- else if (ISPORT(SYSLOG_PORT))
- syslog_print((const u_char *)(up + 1), length);
else
- (void)printf("UDP, length %u",
+ (void)printf("UDP, length: %u",
(u_int32_t)(ulen - sizeof(*up)));
#undef ISPORT
} else
- (void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
+ (void)printf("UDP, length: %u", (u_int32_t)(ulen - sizeof(*up)));
}
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */
-
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.1 b/contrib/tcpdump/tcpdump.1
index 708ab02..daa1dc0 100644
--- a/contrib/tcpdump/tcpdump.1
+++ b/contrib/tcpdump/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.167 2004/12/28 22:31:25 guy Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.148.2.6 2004/03/28 21:25:03 fenner Exp $ (LBL)
.\"
.\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
.\"
@@ -22,7 +22,9 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "22 March 2004"
+.\" $FreeBSD$
+.\"
+.TH TCPDUMP 1 "7 January 2004"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@@ -54,15 +56,11 @@ tcpdump \- dump traffic on a network
.I module
]
[
-.B \-M
-.I secret
-]
-.br
-.ti +8
-[
.B \-r
.I file
]
+.br
+.ti +8
[
.B \-s
.I snaplen
@@ -78,12 +76,6 @@ tcpdump \- dump traffic on a network
.br
.ti +8
[
-.B \-W
-.I filecount
-]
-.br
-.ti +8
-[
.B \-E
.I spi@ipaddr algo:secret,...
]
@@ -93,9 +85,10 @@ tcpdump \- dump traffic on a network
.B \-y
.I datalinktype
]
+.ti +8
[
-.B \-Z
-.I user
+.B \-y
+.I datalinktype
]
.ti +8
[
@@ -257,7 +250,7 @@ currently larger than \fIfile_size\fP and, if so, close the current
savefile and open a new one. Savefiles after the first savefile will
have the name specified with the
.B \-w
-flag, with a number after it, starting at 1 and continuing upward.
+flag, with a number after it, starting at 2 and continuing upward.
The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
not 1,048,576 bytes).
.TP
@@ -391,10 +384,6 @@ Load SMI MIB module definitions from file \fImodule\fR.
This option
can be used several times to load several MIB modules into \fItcpdump\fP.
.TP
-.B \-M
-Use \fIsecret\fP as a shared secret for validating the digests found in
-TCP segments with the TCP-MD5 option (RFC 2385), if present.
-.TP
.B \-n
Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
.TP
@@ -504,15 +493,11 @@ that lacks the
function.
.TP
.B \-v
-When parsing and printing, produce (slightly more) verbose output.
+(Slightly more) verbose output.
For example, the time to live,
identification, total length and options in an IP packet are printed.
Also enables additional packet integrity checks such as verifying the
IP and ICMP header checksum.
-.IP
-When writing to a file with the
-.B \-w
-option, report, every 10 seconds, the number of packets captured.
.TP
.B \-vv
Even more verbose output.
@@ -534,16 +519,6 @@ them out.
They can later be printed with the \-r option.
Standard output is used if \fIfile\fR is ``-''.
.TP
-.B \-W
-Used in conjunction with the
-.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.
-In addition, it will name
-the files with enough leading 0s to support the maximum number of
-files, allowing them to sort correctly.
-.TP
.B \-x
Print each packet (minus its link level header) in hex.
The smaller of the entire packet or
@@ -569,14 +544,6 @@ its link level header, in hex and ASCII.
.TP
.B \-y
Set the data link type to use while capturing packets to \fIdatalinktype\fP.
-.TP
-.B \-Z
-Drops privileges (if root) and changes user ID to
-.I user
-and the group ID to the primary group of
-.IR user .
-.IP
-This behavior can also be enabled by default at compile time.
.IP "\fI expression\fP"
.RS
selects which packets will be dumped.
@@ -638,6 +605,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 .
@@ -709,18 +685,18 @@ which is equivalent to:
If \fIhost\fR is a name with multiple IP addresses, each address will
be checked for a match.
.IP "\fBether dst \fIehost\fP
-True if the Ethernet destination address is \fIehost\fP.
+True if the ethernet destination address is \fIehost\fP.
\fIEhost\fP
may be either a name from /etc/ethers or a number (see
.IR ethers (3N)
for numeric format).
.IP "\fBether src \fIehost\fP
-True if the Ethernet source address is \fIehost\fP.
+True if the ethernet source address is \fIehost\fP.
.IP "\fBether host \fIehost\fP
-True if either the Ethernet source or destination address is \fIehost\fP.
+True if either the ethernet source or destination address is \fIehost\fP.
.IP "\fBgateway\fP \fIhost\fP
True if the packet used \fIhost\fP as a gateway.
-I.e., the Ethernet
+I.e., the ethernet
source or destination address was \fIhost\fP but neither the IP source
nor the IP destination was \fIhost\fP.
\fIHost\fP must be a name and
@@ -800,9 +776,9 @@ True if the packet is an IP packet (see
.IR ip (4P))
of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
-\fBicmp\fP, \fBicmp6\fP, \fBigmp\fP, \fBigrp\fP, \fBpim\fP, \fBah\fP,
-\fBesp\fP, \fBvrrp\fP, \fBudp\fP, or \fBtcp\fP.
-Note that the identifiers \fBtcp\fP, \fBudp\fP, and \fBicmp\fP are also
+\fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP,
+\fIesp\fP, \fIvrrp\fP, \fIudp\fP, or \fItcp\fP.
+Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also
keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
Note that this primitive does not chase the protocol header chain.
.IP "\fBip6 proto \fIprotocol\fR"
@@ -828,7 +804,7 @@ so this can be somewhat slow.
.IP "\fBip protochain \fIprotocol\fR"
Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
.IP "\fBether broadcast\fR"
-True if the packet is an Ethernet broadcast packet.
+True if the packet is an ethernet broadcast packet.
The \fIether\fP
keyword is optional.
.IP "\fBip broadcast\fR"
@@ -843,8 +819,8 @@ done has no netmask or because the capture is being done on the Linux
"any" interface, which can capture on more than one interface, this
check will not work correctly.
.IP "\fBether multicast\fR"
-True if the packet is an Ethernet multicast packet.
-The \fBether\fP
+True if the packet is an ethernet multicast packet.
+The \fIether\fP
keyword is optional.
This is shorthand for `\fBether[0] & 1 != 0\fP'.
.IP "\fBip multicast\fR"
@@ -854,9 +830,9 @@ True if the packet is an IPv6 multicast packet.
.IP "\fBether proto \fIprotocol\fR"
True if the packet is of ether type \fIprotocol\fR.
\fIProtocol\fP can be a number or one of the names
-\fBip\fP, \fBip6\fP, \fBarp\fP, \fBrarp\fP, \fBatalk\fP, \fBaarp\fP,
-\fBdecnet\fP, \fBsca\fP, \fBlat\fP, \fBmopdl\fP, \fBmoprc\fP,
-\fBiso\fP, \fBstp\fP, \fBipx\fP, or \fBnetbeui\fP.
+\fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP,
+\fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP,
+\fIiso\fP, \fIstp\fP, \fIipx\fP, or \fInetbeui\fP.
Note these identifiers are also keywords
and must be escaped via backslash (\\).
.IP
@@ -879,10 +855,10 @@ The exceptions are:
\fItcpdump\fR checks the DSAP (Destination Service Access Point) and
SSAP (Source Service Access Point) fields of the LLC header;
.TP
-\fBstp\fP and \fBnetbeui\fP
+\fBstp\fP and \fInetbeui\fP
\fItcpdump\fR checks the DSAP of the LLC header;
.TP
-\fBatalk\fP
+\fIatalk\fP
\fItcpdump\fR checks for a SNAP-format packet with an OUI of 0x080007
and the AppleTalk etype.
.RE
@@ -891,7 +867,7 @@ In the case of Ethernet, \fItcpdump\fR checks the Ethernet type field
for most of those protocols. The exceptions are:
.RS
.TP
-\fBiso\fP, \fBstp\fP, and \fBnetbeui\fP
+\fBiso\fP, \fBsap\fP, and \fBnetbeui\fP
\fItcpdump\fR checks for an 802.3 frame and then checks the LLC header as
it does for FDDI, Token Ring, and 802.11;
.TP
@@ -1009,7 +985,7 @@ where \fIp\fR is one of the above protocols.
.IP "\fBiso proto \fIprotocol\fR"
True if the packet is an OSI packet of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
-\fBclnp\fP, \fBesis\fP, or \fBisis\fP.
+\fIclnp\fP, \fIesis\fP, or \fIisis\fP.
.IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
Abbreviations for:
.in +.5i
@@ -1077,8 +1053,7 @@ True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =,
!=, and \fIexpr\fR is an arithmetic expression composed of integer
constants (expressed in standard C syntax), the normal binary operators
[+, -, *, /, &, |, <<, >>], a length operator, and special packet data
-accessors. Note that all comparisons are unsigned, so that, for example,
-0x80000000 and 0xffffffff are > 0.
+accessors.
To access
data inside the packet, use the following syntax:
.in +.5i
@@ -1232,16 +1207,6 @@ tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocal
.fi
.RE
.LP
-To print all IPv4 HTTP packets to and from port 80, i.e. print only
-packets that contain data, not, for example, SYN and FIN packets and
-ACK-only packets. (IPv6 is left as an exercise for the reader.)
-.RS
-.nf
-.B
-tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
-.fi
-.RE
-.LP
To print IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
.RS
.nf
@@ -1252,7 +1217,7 @@ tcpdump 'gateway snup and ip[2:2] > 576'
.LP
To print IP broadcast or multicast packets that were
.I not
-sent via Ethernet broadcast or multicast:
+sent via ethernet broadcast or multicast:
.RS
.nf
.B
@@ -1281,7 +1246,7 @@ gives a brief description and examples of most of the formats.
Link Level Headers
.LP
If the '-e' option is given, the link level header is printed out.
-On Ethernets, the source and destination addresses, protocol,
+On ethernets, the source and destination addresses, protocol,
and packet length are printed.
.LP
On FDDI networks, the '-e' option causes \fItcpdump\fP to print
@@ -1359,9 +1324,9 @@ arp reply csam is-at CSAM\fR
.fi
.RE
The first line says that rtsg sent an arp packet asking
-for the Ethernet address of internet host csam.
+for the ethernet address of internet host csam.
Csam
-replies with its Ethernet address (in this example, Ethernet addresses
+replies with its ethernet address (in this example, ethernet addresses
are in caps and internet addresses in lower case).
.LP
This would look less redundant if we had done \fItcpdump \-n\fP:
@@ -1383,8 +1348,8 @@ CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
.sp .5
.fi
.RE
-For the first packet this says the Ethernet source address is RTSG, the
-destination is the Ethernet broadcast address, the type field
+For the first packet this says the ethernet source address is RTSG, the
+destination is the ethernet broadcast address, the type field
contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
.HD
TCP Packets
@@ -1812,6 +1777,11 @@ Be warned that with -v a single SMB packet
may take up a page or more, so only use -v if you really want all the
gory details.
+If you are decoding SMB sessions containing unicode strings then you
+may wish to set the environment variable USE_UNICODE to 1.
+A patch to
+auto-detect unicode strings would be welcome.
+
For information on SMB packet formats and what all te fields mean see
www.cifs.org or the pub/samba/specs/ directory on your favorite
samba.org mirror site.
@@ -2166,10 +2136,10 @@ and is as accurate as the kernel's clock.
The timestamp reflects the time the kernel first saw the packet.
No attempt
is made to account for the time lag between when the
-Ethernet interface removed the packet from the wire and when the kernel
+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
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 82bf746..4314a1a 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 2005/01/27 18:30:36 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.216.2.10 2004/03/17 19:47:48 guy Exp $ (LBL)";
#endif
+/* $FreeBSD$ */
+
/*
* tcpdump - monitor tcp/ip traffic on an ethernet.
*
@@ -56,22 +58,12 @@ extern int SIZE_BUF;
#define uint UINT
#endif /* WIN32 */
-#ifdef HAVE_SMI_H
-#include <smi.h>
-#endif
-
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef WIN32
-#include <pwd.h>
-#include <grp.h>
-#include <errno.h>
-#endif /* WIN32 */
-#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
#include "machdep.h"
@@ -79,19 +71,33 @@ extern int SIZE_BUF;
#include "gmt2local.h"
#include "pcap-missing.h"
-netdissect_options Gndo;
-netdissect_options *gndo = &Gndo;
-
-/*
- * Define the maximum number of files for the -C flag, and how many
- * characters can be added to a filename for the -C flag (which
- * should be enough to handle MAX_CFLAG - 1).
- */
-#define MAX_CFLAG 1000000
-#define MAX_CFLAG_CHARS 6
-
int dflag; /* print filter code */
+int eflag; /* print ethernet header */
+int fflag; /* don't translate "foreign" IP address */
int Lflag; /* list available data link types and exit */
+int nflag; /* leave addresses as numbers */
+int Nflag; /* remove domains from printed host names */
+int Oflag = 1; /* run filter code optimizer */
+int pflag; /* don't go promiscuous */
+int qflag; /* quick (shorter) output */
+int Rflag = 1; /* print sequence # field in AH/ESP*/
+int sflag = 0; /* use the libsmi to translate OIDs */
+int Sflag; /* print raw TCP sequence numbers */
+int tflag = 1; /* print packet arrival time */
+int Uflag = 0; /* "unbuffered" output of dump files */
+int uflag = 0; /* Print undecoded NFS handles */
+int vflag; /* verbose */
+int xflag; /* print packet in hex */
+int Xflag; /* print packet in ascii as well as hex */
+off_t Cflag = 0; /* rotate dump files after this many bytes */
+int Aflag = 0; /* print packet only in ascii observing LF, CR, TAB, SPACE */
+int dlt = -1; /* if != -1, ask libpcap for the DLT it names */
+
+const char *dlt_name = NULL;
+
+char *espsecret = NULL; /* ESP secret key */
+
+int packettype;
static int infodelay;
static int infoprint;
@@ -106,28 +112,19 @@ static void usage(void) __attribute__((noreturn));
static void show_dlts_and_exit(pcap_t *pd) __attribute__((noreturn));
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
-static void ndo_default_print(netdissect_options *, const u_char *, u_int);
static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
-static void droproot(const char *, const char *);
-static void ndo_error(netdissect_options *ndo, const char *fmt, ...);
-static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
#ifdef SIGINFO
RETSIGTYPE requestinfo(int);
#endif
-#if defined(USE_WIN32_MM_TIMER)
- #include <MMsystem.h>
- static UINT timer_id;
- static void CALLBACK verbose_stats_dump(UINT, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR);
-#elif defined(HAVE_ALARM)
- static void verbose_stats_dump(int sig);
-#endif
-
static void info(int);
static u_int packets_captured;
+/* Length of saved portion of packet. */
+int snaplen = DEFAULT_SNAPLEN;
+
typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
struct printer {
@@ -156,9 +153,6 @@ static struct printer printers[] = {
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
#endif
{ ppp_if_print, DLT_PPP },
-#ifdef DLT_PPP_WITHDIRECTION
- { ppp_if_print, DLT_PPP_WITHDIRECTION },
-#endif
#ifdef DLT_PPP_BSDOS
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
#endif
@@ -214,24 +208,9 @@ static struct printer printers[] = {
#ifdef DLT_ENC
{ enc_if_print, DLT_ENC },
#endif
-#ifdef DLT_SYMANTEC_FIREWALL
- { symantec_if_print, DLT_SYMANTEC_FIREWALL },
-#endif
#ifdef DLT_APPLE_IP_OVER_IEEE1394
{ ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
#endif
-#ifdef DLT_JUNIPER_ATM1
- { juniper_atm1_print, DLT_JUNIPER_ATM1 },
-#endif
-#ifdef DLT_JUNIPER_ATM2
- { juniper_atm2_print, DLT_JUNIPER_ATM2 },
-#endif
-#ifdef DLT_JUNIPER_MLFR
- { juniper_mlfr_print, DLT_JUNIPER_MLFR },
-#endif
-#ifdef DLT_JUNIPER_MLPPP
- { juniper_mlppp_print, DLT_JUNIPER_MLPPP },
-#endif
{ NULL, 0 },
};
@@ -313,12 +292,6 @@ show_dlts_and_exit(pcap_t *pd)
#endif /* WIN32 */
#ifdef HAVE_PCAP_FINDALLDEVS
-#ifndef HAVE_PCAP_IF_T
-#undef HAVE_PCAP_FINDALLDEVS
-#endif
-#endif
-
-#ifdef HAVE_PCAP_FINDALLDEVS
#define D_FLAG "D"
#else
#define D_FLAG
@@ -330,89 +303,12 @@ show_dlts_and_exit(pcap_t *pd)
#define U_FLAG
#endif
-#ifndef WIN32
-/* Drop root privileges and chroot if necessary */
-static void
-droproot(const char *username, const char *chroot_dir)
-{
- struct passwd *pw = NULL;
-
- if (chroot_dir && !username) {
- fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n");
- exit(1);
- }
-
- pw = getpwnam(username);
- if (pw) {
- if (chroot_dir) {
- if (chroot(chroot_dir) != 0 || chdir ("/") != 0) {
- fprintf(stderr, "tcpdump: Couldn't chroot/chdir to '%.64s': %s\n",
- chroot_dir, pcap_strerror(errno));
- exit(1);
- }
- }
- if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
- setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) {
- fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
- username,
- (unsigned long)pw->pw_uid,
- (unsigned long)pw->pw_gid,
- pcap_strerror(errno));
- exit(1);
- }
- }
- else {
- fprintf(stderr, "tcpdump: Couldn't find user '%.32s'\n",
- username);
- exit(1);
- }
-}
-#endif /* WIN32 */
-
-static int
-getWflagChars(int x)
-{
- int c = 0;
-
- x -= 1;
- while (x > 0) {
- c += 1;
- x /= 10;
- }
-
- return c;
-}
-
-
-static void
-MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
-{
- if (cnt == 0 && max_chars == 0)
- strcpy(buffer, orig_name);
- else
- sprintf(buffer, "%s%0*d", orig_name, max_chars, cnt);
-}
-
-static int tcpdump_printf(netdissect_options *ndo _U_,
- const char *fmt, ...)
-{
-
- va_list args;
- int ret;
-
- va_start(args, fmt);
- ret=vfprintf(stdout, fmt, args);
- va_end(args);
-
- return ret;
-}
-
int
main(int argc, char **argv)
{
register int cnt, op, i;
bpf_u_int32 localnet, netmask;
- register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName, *WFileNameAlt;
+ register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName;
pcap_handler callback;
int type;
struct bpf_program fcode;
@@ -423,8 +319,6 @@ main(int argc, char **argv)
struct dump_info dumpinfo;
u_char *pcap_userdata;
char ebuf[PCAP_ERRBUF_SIZE];
- char *username = NULL;
- char *chroot_dir = NULL;
#ifdef HAVE_PCAP_FINDALLDEVS
pcap_if_t *devpointer;
int devnum;
@@ -435,15 +329,6 @@ main(int argc, char **argv)
if(wsockinit() != 0) return 1;
#endif /* WIN32 */
- gndo->ndo_Oflag=1;
- gndo->ndo_Rflag=1;
- gndo->ndo_dlt=-1;
- gndo->ndo_default_print=ndo_default_print;
- gndo->ndo_printf=tcpdump_printf;
- gndo->ndo_error=ndo_error;
- gndo->ndo_warning=ndo_warning;
- gndo->ndo_snaplen = DEFAULT_SNAPLEN;
-
cnt = -1;
device = NULL;
infile = NULL;
@@ -463,7 +348,7 @@ main(int argc, char **argv)
opterr = 0;
while (
- (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:M:nNOpqr:Rs:StT:u" U_FLAG "vw:W:xXy:YZ:")) != -1)
+ (op = getopt(argc, argv, "aA" B_FLAG "c:C:d" D_FLAG "eE:fF:i:lLm:nNOpqr:Rs:StT:u" U_FLAG "vw:xXy:Y")) != -1)
switch (op) {
case 'a':
@@ -528,7 +413,7 @@ main(int argc, char **argv)
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
- gndo->ndo_espsecret = optarg;
+ espsecret = optarg;
break;
case 'f':
@@ -616,14 +501,6 @@ main(int argc, char **argv)
#endif
break;
- case 'M':
- /* TCP-MD5 shared secret */
-#ifndef HAVE_LIBCRYPTO
- warning("crypto code not compiled in");
-#endif
- tcpmd5secret = optarg;
- break;
-
case 'O':
Oflag = 0;
break;
@@ -661,7 +538,7 @@ main(int argc, char **argv)
break;
case 't':
- ++tflag;
+ --tflag;
break;
case 'T':
@@ -705,27 +582,20 @@ main(int argc, char **argv)
WFileName = optarg;
break;
- case 'W':
- Wflag = atoi(optarg);
- if (Wflag < 0)
- error("invalid number of output files %s", optarg);
- WflagChars = getWflagChars(Wflag);
- break;
-
case 'x':
++xflag;
break;
case 'X':
+ ++xflag;
++Xflag;
break;
case 'y':
- gndo->ndo_dltname = optarg;
- gndo->ndo_dlt =
- pcap_datalink_name_to_val(gndo->ndo_dltname);
- if (gndo->ndo_dlt < 0)
- error("invalid data link type %s", gndo->ndo_dltname);
+ dlt_name = optarg;
+ dlt = pcap_datalink_name_to_val(dlt_name);
+ if (dlt < 0)
+ error("invalid data link type %s", dlt_name);
break;
#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
@@ -742,55 +612,13 @@ main(int argc, char **argv)
}
break;
#endif
- case 'Z':
- if (optarg) {
- username = strdup(optarg);
- }
- else {
- usage();
- /* NOTREACHED */
- }
- break;
-
default:
usage();
/* NOTREACHED */
}
- switch (tflag) {
-
- case 0: /* Default */
- case 4: /* Default + Date*/
+ if (tflag > 0)
thiszone = gmt2local(0);
- break;
-
- case 1: /* No time stamp */
- case 2: /* Unix timeval style */
- case 3: /* Microseconds since previous packet */
- break;
-
- default: /* Not supported */
- error("only -t, -tt, -ttt, and -tttt are supported");
- break;
- }
-
-#ifdef WITH_CHROOT
- /* if run as root, prepare for chrooting */
- if (getuid() == 0 || geteuid() == 0) {
- /* future extensibility for cmd-line arguments */
- if (!chroot_dir)
- chroot_dir = WITH_CHROOT;
- }
-#endif
-
-#ifdef WITH_USER
- /* if run as root, prepare for dropping root privileges */
- if (getuid() == 0 || geteuid() == 0) {
- /* Run with '-Z root' to restore old behaviour */
- if (!username)
- username = WITH_USER;
- }
-#endif
if (RFileName != NULL) {
int dlt;
@@ -806,8 +634,7 @@ main(int argc, char **argv)
* people's trace files (especially if we're set-UID
* root).
*/
- if (setgid(getgid()) != 0 || setuid(getuid()) != 0 )
- fprintf(stderr, "Warning: setgid/setuid failed !\n");
+ setuid(getuid());
#endif /* WIN32 */
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
@@ -834,8 +661,11 @@ main(int argc, char **argv)
error("%s", ebuf);
}
#ifdef WIN32
- if(strlen(device) == 1) //we assume that an ASCII string is always longer than 1 char
- { //a Unicode string has a \0 as second byte (so strlen() is 1)
+ if(IsTextUnicode(device,
+ wcslen((short*)device), // Device always ends with a double \0, so this way to determine its
+ // length should be always valid
+ NULL))
+ {
fprintf(stderr, "%s: listening on %ws\n", program_name, device);
}
else
@@ -851,24 +681,11 @@ main(int argc, char **argv)
error("%s", ebuf);
else if (*ebuf)
warning("%s", ebuf);
- /*
- * Let user own process after socket has been opened.
- */
-#ifndef WIN32
- if (setgid(getgid()) != 0 || setuid(getuid()) != 0)
- fprintf(stderr, "Warning: setgid/setuid failed !\n");
-#endif /* WIN32 */
-#ifdef WIN32
- if(UserBufferSize != 1000000)
- if(pcap_setbuff(pd, UserBufferSize)==-1){
- error("%s", pcap_geterr(pd));
- }
-#endif /* WIN32 */
if (Lflag)
show_dlts_and_exit(pd);
- if (gndo->ndo_dlt >= 0) {
+ if (dlt >= 0) {
#ifdef HAVE_PCAP_SET_DATALINK
- if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0)
+ if (pcap_set_datalink(pd, dlt) < 0)
error("%s", pcap_geterr(pd));
#else
/*
@@ -876,13 +693,13 @@ main(int argc, char **argv)
* data link type, so we only let them
* set it to what it already is.
*/
- if (gndo->ndo_dlt != pcap_datalink(pd)) {
+ if (dlt != pcap_datalink(pd)) {
error("%s is not one of the DLTs supported by this device\n",
- gndo->ndo_dltname);
+ dlt_name);
}
#endif
(void)fprintf(stderr, "%s: data link type %s\n",
- program_name, gndo->ndo_dltname);
+ program_name, dlt_name);
(void)fflush(stderr);
}
i = pcap_snapshot(pd);
@@ -895,6 +712,12 @@ main(int argc, char **argv)
netmask = 0;
warning("%s", ebuf);
}
+ /*
+ * Let user own process after socket has been opened.
+ */
+#ifndef WIN32
+ setuid(getuid());
+#endif /* WIN32 */
}
if (infile)
cmdbuf = read_infile(infile);
@@ -924,13 +747,7 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
if (WFileName) {
- pcap_dumper_t *p;
-
- WFileNameAlt = (char *)malloc(strlen(WFileName) + MAX_CFLAG_CHARS + 1);
- if (WFileNameAlt == NULL)
- error("malloc of WFileNameAlt");
- MakeFilename(WFileNameAlt, WFileName, 0, WflagChars);
- p = pcap_dump_open(pd, WFileNameAlt);
+ pcap_dumper_t *p = pcap_dump_open(pd, WFileName);
if (p == NULL)
error("%s", pcap_geterr(pd));
if (Cflag != 0) {
@@ -947,46 +764,18 @@ main(int argc, char **argv)
type = pcap_datalink(pd);
printinfo.printer = lookup_printer(type);
if (printinfo.printer == NULL) {
- gndo->ndo_dltname = pcap_datalink_val_to_name(type);
- if (gndo->ndo_dltname != NULL)
- error("unsupported data link type %s",
- gndo->ndo_dltname);
+ dlt_name = pcap_datalink_val_to_name(type);
+ if (dlt_name != NULL)
+ error("unsupported data link type %s", dlt_name);
else
error("unsupported data link type %d", type);
}
callback = print_packet;
pcap_userdata = (u_char *)&printinfo;
}
-#ifndef WIN32
- /*
- * We cannot do this earlier, because we want to be able to open
- * the file (if done) for writing before giving up permissions.
- */
- if (getuid() == 0 || geteuid() == 0) {
- if (username || chroot_dir)
- droproot(username, chroot_dir);
- }
-#endif /* WIN32 */
#ifdef SIGINFO
(void)setsignal(SIGINFO, requestinfo);
#endif
-
- if (vflag > 0 && WFileName) {
- /*
- * When capturing to a file, "-v" means tcpdump should,
- * every 10 secodns, "v"erbosely report the number of
- * packets captured.
- */
-#ifdef USE_WIN32_MM_TIMER
- /* call verbose_stats_dump() each 1000 +/-100msec */
- timer_id = timeSetEvent(1000, 100, verbose_stats_dump, 0, TIME_PERIODIC);
- setvbuf(stderr, NULL, _IONBF, 0);
-#elif defined(HAVE_ALARM)
- (void)setsignal(SIGALRM, verbose_stats_dump);
- alarm(1);
-#endif
- }
-
#ifndef WIN32
if (RFileName == NULL) {
int dlt;
@@ -1049,14 +838,6 @@ main(int argc, char **argv)
static RETSIGTYPE
cleanup(int signo _U_)
{
-#ifdef USE_WIN32_MM_TIMER
- if (timer_id)
- timeKillEvent(timer_id);
- timer_id = 0;
-#elif defined(HAVE_ALARM)
- alarm(0);
-#endif
-
#ifdef HAVE_PCAP_BREAKLOOP
/*
* We have "pcap_breakloop()"; use it, so that we do as little
@@ -1114,9 +895,37 @@ info(register int verbose)
}
static void
+reverse(char *s)
+{
+ int i, j, c;
+
+ for (i = 0, j = strlen(s) - 1; i < j; i++, j--) {
+ c = s[i];
+ s[i] = s[j];
+ s[j] = c;
+ }
+}
+
+
+static void
+swebitoa(unsigned int n, char *s)
+{
+ unsigned int i;
+
+ i = 0;
+ do {
+ s[i++] = n % 10 + '0';
+ } while ((n /= 10) > 0);
+
+ s[i] = '\0';
+ reverse(s);
+}
+
+static void
dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
struct dump_info *dump_info;
+ static uint cnt = 2;
char *name;
++packets_captured;
@@ -1135,18 +944,14 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
* Close the current file and open a new one.
*/
pcap_dump_close(dump_info->p);
- Cflag_count++;
- if (Wflag > 0) {
- if (Cflag_count >= Wflag)
- Cflag_count = 0;
- } else {
- if (Cflag_count >= MAX_CFLAG)
- error("too many output files");
- }
- name = (char *)malloc(strlen(dump_info->WFileName) + MAX_CFLAG_CHARS + 1);
+ if (cnt >= 1000)
+ error("too many output files");
+ name = (char *) malloc(strlen(dump_info->WFileName) + 4);
if (name == NULL)
error("dump_packet_and_trunc: malloc");
- MakeFilename(name, dump_info->WFileName, Cflag_count, WflagChars);
+ strcpy(name, dump_info->WFileName);
+ swebitoa(cnt, name + strlen(dump_info->WFileName));
+ cnt++;
dump_info->p = pcap_dump_open(dump_info->pd, name);
free(name);
if (dump_info->p == NULL)
@@ -1211,7 +1016,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
/*
* Include the link-layer header.
*/
- hex_print("\n\t", sp, h->caplen);
+ default_print(sp, h->caplen);
} else {
/*
* Don't include the link-layer header - and if
@@ -1219,26 +1024,7 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* print nothing.
*/
if (h->caplen > hdrlen)
- hex_print("\n\t", sp + hdrlen,
- h->caplen - hdrlen);
- }
- } else if (Xflag) {
- /*
- * Print the raw packet data.
- */
- if (Xflag > 1) {
- /*
- * Include the link-layer header.
- */
- ascii_print("\n\t", sp, h->caplen);
- } else {
- /*
- * Don't include the link-layer header - and if
- * we have nothing past the link-layer header,
- * print nothing.
- */
- if (h->caplen > hdrlen)
- ascii_print("\n\t", sp + hdrlen,
+ default_print(sp + hdrlen,
h->caplen - hdrlen);
}
}
@@ -1270,26 +1056,18 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* "Wpcap_version" information on Windows.
*/
char WDversion[]="current-cvs.tcpdump.org";
-#if !defined(HAVE_GENERATED_VERSION)
char version[]="current-cvs.tcpdump.org";
-#endif
char pcap_version[]="current-cvs.tcpdump.org";
- char Wpcap_version[]="3.1";
+ char Wpcap_version[]="3.0 alpha";
#endif
/*
* By default, print the specified data out in hex.
*/
-static void
-ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
-{
- ascii_print("\n\t", bp, length); /* pass on lf and identation string */
-}
-
void
-default_print(const u_char *bp, u_int length)
+default_print(register const u_char *bp, register u_int length)
{
- ndo_default_print(gndo, bp, length);
+ ascii_print("\n\t", bp, length); /* pass on lf and identation string */
}
#ifdef SIGINFO
@@ -1302,29 +1080,6 @@ RETSIGTYPE requestinfo(int signo _U_)
}
#endif
-/*
- * Called once each second in verbose mode while dumping to file
- */
-#ifdef USE_WIN32_MM_TIMER
-void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
- DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
-{
- struct pcap_stat stat;
-
- if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
- fprintf(stderr, "Got %u\r", packets_captured);
-}
-#elif defined(HAVE_ALARM)
-static void verbose_stats_dump(int sig _U_)
-{
- struct pcap_stat stat;
-
- if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
- fprintf(stderr, "Got %u\r", packets_captured);
- alarm(1);
-}
-#endif
-
static void
usage(void)
{
@@ -1338,12 +1093,8 @@ usage(void)
#endif /* HAVE_PCAP_LIB_VERSION */
#ifdef HAVE_PCAP_LIB_VERSION
-#ifdef WIN32
- (void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
-#else /* WIN32 */
(void)fprintf(stderr, "%s version %s\n", program_name, version);
-#endif /* WIN32 */
- (void)fprintf(stderr, "%s\n",pcap_lib_version());
+ (void)fprintf(stderr, "%s\n", pcap_lib_version());
#else /* HAVE_PCAP_LIB_VERSION */
#ifdef WIN32
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
@@ -1356,51 +1107,10 @@ usage(void)
(void)fprintf(stderr,
"Usage: %s [-aAd" D_FLAG "eflLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [-c count] [ -C file_size ]\n", program_name);
(void)fprintf(stderr,
-"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -M secret ]\n");
- (void)fprintf(stderr,
-"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -w file ]\n");
+"\t\t[ -E algo:secret ] [ -F file ] [ -i interface ] [ -r file ]\n");
(void)fprintf(stderr,
-"\t\t[ -W filecount ] [ -y datalinktype ] [ -Z user ]\n");
+"\t\t[ -s snaplen ] [ -T type ] [ -w file ] [ -y datalinktype ]\n");
(void)fprintf(stderr,
"\t\t[ expression ]\n");
exit(1);
}
-
-
-
-/* VARARGS */
-static void
-ndo_error(netdissect_options *ndo _U_, const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
- exit(1);
- /* NOTREACHED */
-}
-
-/* VARARGS */
-static void
-ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: WARNING: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
-}
-
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
OpenPOWER on IntegriCloud