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.m41057
-rw-r--r--contrib/tcpdump/acsite.m4505
-rw-r--r--contrib/tcpdump/addrtoname.c33
-rw-r--r--contrib/tcpdump/ethertype.h29
-rw-r--r--contrib/tcpdump/interface.h96
-rw-r--r--contrib/tcpdump/nfs.h5
-rw-r--r--contrib/tcpdump/nfsfh.h4
-rw-r--r--contrib/tcpdump/nfsv2.h262
-rw-r--r--contrib/tcpdump/parsenfsfh.c25
-rw-r--r--contrib/tcpdump/ppp.h19
-rw-r--r--contrib/tcpdump/print-arp.c85
-rw-r--r--contrib/tcpdump/print-atalk.c107
-rw-r--r--contrib/tcpdump/print-atm.c41
-rw-r--r--contrib/tcpdump/print-bootp.c103
-rw-r--r--contrib/tcpdump/print-domain.c409
-rw-r--r--contrib/tcpdump/print-ether.c76
-rw-r--r--contrib/tcpdump/print-fddi.c33
-rw-r--r--contrib/tcpdump/print-fr.c9
-rw-r--r--contrib/tcpdump/print-icmp.c246
-rw-r--r--contrib/tcpdump/print-ip.c237
-rw-r--r--contrib/tcpdump/print-ip6.c67
-rw-r--r--contrib/tcpdump/print-ipx.c20
-rw-r--r--contrib/tcpdump/print-isoclns.c45
-rw-r--r--contrib/tcpdump/print-llc.c95
-rw-r--r--contrib/tcpdump/print-nfs.c813
-rw-r--r--contrib/tcpdump/print-ntp.c11
-rw-r--r--contrib/tcpdump/print-null.c102
-rw-r--r--contrib/tcpdump/print-pim.c20
-rw-r--r--contrib/tcpdump/print-ppp.c1299
-rw-r--r--contrib/tcpdump/print-sl.c78
-rw-r--r--contrib/tcpdump/print-sunrpc.c74
-rw-r--r--contrib/tcpdump/print-token.c237
-rw-r--r--contrib/tcpdump/print-udp.c243
-rw-r--r--contrib/tcpdump/tcpdump.1423
-rw-r--r--contrib/tcpdump/tcpdump.c123
-rw-r--r--contrib/tcpdump/token.h47
37 files changed, 1874 insertions, 5232 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 06eca60..0000000
--- a/contrib/tcpdump/aclocal.m4
+++ /dev/null
@@ -1,1057 +0,0 @@
-dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.73 2001/01/02 22:18:27 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 "$target_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 "$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_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 "$target_os" in
-
- irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -g3"
- ;;
-
- osf*)
- V_CCOPT="$V_CCOPT -std1 -g3"
- ;;
-
- 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
-])
-
-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 .. | 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/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
- else
- $1=$libpcap
- if test -r $d/pcap.h; then
- $2="-I$d $$2"
- elif test -r $srcdir/../libpcap/pcap.h; then
- $2="-I$d -I$srcdir/../libpcap $$2"
- else
- AC_MSG_ERROR(cannot find pcap.h, see INSTALL)
- fi
- AC_MSG_RESULT($libpcap)
- fi
- LIBS="$libpcap $LIBS"
- case "$target_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
- ;;
- esac])
-
-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 "$target_os" in
-
- irix*)
- AC_DEFINE(_BSD_SIGNALS)
- ;;
-
- *)
- dnl prefer sigset() to sigaction()
- AC_CHECK_FUNCS(sigset)
- if test $ac_cv_func_sigset = no ; then
- AC_CHECK_FUNCS(sigaction)
- 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 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 "$target_cpu" in
-
- # XXX: should also check that they don't do weird things (like on arm)
- alpha*|arm*|hp*|mips|sparc)
- 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, 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 -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"
- fi
- fi
- else
- case "$target_os" in
-
- irix6*)
- V_CCOPT="$V_CCOPT -n32"
- ;;
-
- *)
- ;;
- esac
- 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])
-
-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
-
-define(AC_LBL_CHECK_LIB,
-[AC_MSG_CHECKING([for $2 in -l$1])
-dnl Use a cache variable name containing both the library and function name,
-dnl because the test really is for library $1 defining function $2, not
-dnl just for library $1. Separate tests with the same $1 and different $2's
-dnl 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):
- AC_CHECK_FUNC(gethostbyname, ,
- # Some OSes (eg. Solaris) place it in libnsl:
- AC_LBL_CHECK_LIB(nsl, gethostbyname, ,
- # Some strange OSes (SINIX) have it in libsocket:
- AC_LBL_CHECK_LIB(socket, gethostbyname, ,
- # Unfortunately libsocket sometimes depends on libnsl.
- # AC_CHECK_LIB's API is essentially broken so the
- # following ugliness is necessary:
- AC_LBL_CHECK_LIB(socket, gethostbyname,
- LIBS="-lsocket -lnsl $LIBS",
- AC_CHECK_LIB(resolv, gethostbyname),
- -lnsl))))
- AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
- AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
- -lnsl)))
- # DLPI needs putmsg under HPUX so test for -lstr while we're at it
- AC_CHECK_LIB(str, putmsg)
- ])
-
-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
-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__])
-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 600b329..c1f2208 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.69.2.1 2001/01/17 18:29:58 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.64 1999/11/21 09:36:44 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,13 +36,17 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
#include <net/if.h>
#include <netinet/in.h>
-#ifdef HAVE_NETINET_IF_ETHER_H
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
+
+#ifdef INET6
+#include <netinet/ip6.h>
#endif
#include <arpa/inet.h>
@@ -49,6 +55,12 @@ struct rtentry;
#include <netdb.h>
#include <pcap.h>
#include <pcap-namedb.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -485,6 +497,7 @@ protoid_string(register const u_char *pi)
char *
llcsap_string(u_char sap)
{
+ register char *cp;
register struct hnamemem *tp;
register u_int32_t i = sap;
char buf[sizeof("sap 00")];
@@ -496,7 +509,12 @@ llcsap_string(u_char sap)
tp->addr = i;
tp->nxt = newhnamemem();
- snprintf(buf, sizeof(buf), "sap %02x", sap & 0xff);
+ cp = buf;
+ (void)strcpy(cp, "sap ");
+ cp += strlen(cp);
+ *cp++ = hex[sap >> 4 & 0xf];
+ *cp++ = hex[sap & 0xf];
+ *cp++ = '\0';
tp->name = savestr(buf);
return (tp->name);
}
@@ -512,15 +530,16 @@ isonsap_string(const u_char *nsap)
if (tp->e_name)
return tp->e_name;
- tp->e_name = cp = (char *)malloc(nlen * 2 + 2);
+ tp->e_name = cp = (char *)malloc(nlen * 2 + 2 + (nlen>>1));
if (cp == NULL)
error("isonsap_string: malloc");
nsap++;
- *cp++ = '/';
- for (i = nlen; (int)--i >= 0;) {
+ for (i = 0; i < nlen; i++) {
*cp++ = hex[*nsap >> 4];
*cp++ = hex[*nsap++ & 0xf];
+ if (((i & 1) == 0) && (i + 1 < nlen))
+ *cp++ = '.';
}
*cp = '\0';
return (tp->e_name);
diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h
index d1a653b..56bfa3c 100644
--- a/contrib/tcpdump/ethertype.h
+++ b/contrib/tcpdump/ethertype.h
@@ -18,33 +18,12 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.12 2000/09/23 08:03:30 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.7.2.1 2000/01/29 22:00:12 fenner Exp $ (LBL)
+ * $FreeBSD$
*/
-/*
- * Ethernet types.
- *
- * We wrap the declarations with #ifdef, so that if a file includes
- * <netinet/if_ether.h>, which may declare some of these, we don't
- * get a bunch of complaints from the C compiler about redefinitions
- * of these values.
- *
- * We declare all of them here so that no file has to include
- * <netinet/if_ether.h> if all it needs are ETHERTYPE_ values.
- */
+/* Types missing from some systems */
-#ifndef ETHERTYPE_PUP
-#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
-#endif
-#ifndef ETHERTYPE_IP
-#define ETHERTYPE_IP 0x0800 /* IP protocol */
-#endif
-#ifndef ETHERTYPE_ARP
-#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
-#endif
-#ifndef ETHERTYPE_REVARP
-#define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */
-#endif
#ifndef ETHERTYPE_NS
#define ETHERTYPE_NS 0x0600
#endif
@@ -97,7 +76,7 @@
#define ETHERTYPE_8021Q 0x8100
#endif
#ifndef ETHERTYPE_IPX
-#define ETHERTYPE_IPX 0x8137
+#define ETHERTYPE_IPX 0x8137
#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h
index 89b05d5..f9081bb7 100644
--- a/contrib/tcpdump/interface.h
+++ b/contrib/tcpdump/interface.h
@@ -18,42 +18,17 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.149 2001/01/02 22:47:06 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.118 1999/12/22 15:44:09 itojun Exp $ (LBL)
+ * $FreeBSD$
*/
#ifndef tcpdump_interface_h
#define tcpdump_interface_h
+#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
-#include <sys/types.h>
-#include <sys/time.h>
-
-#ifndef HAVE___ATTRIBUTE__
-#define __attribute__(x)
-#endif
-
-/* snprintf et al */
-
-#include <stdarg.h>
-
-#if !defined(HAVE_SNPRINTF)
-int snprintf (char *str, size_t sz, const char *format, ...)
- __attribute__ ((format (printf, 3, 4)));
-#endif
-
-#if !defined(HAVE_VSNPRINTF)
-int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
- __attribute__((format (printf, 3, 0)));
-#endif
-
-#ifndef HAVE_STRLCAT
-extern size_t strlcat (char *, const char *, size_t);
-#endif
-#ifndef HAVE_STRLCPY
-extern size_t strlcpy (char *, const char *, size_t);
-#endif
struct tok {
int v; /* value */
@@ -71,11 +46,11 @@ 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 char *ahsecret;
extern char *espsecret;
extern int packettype; /* as specified by -T */
@@ -85,7 +60,6 @@ extern int packettype; /* as specified by -T */
#define PT_RTP 4 /* Real-Time Applications protocol */
#define PT_RTCP 5 /* Real-Time Applications control protocol */
#define PT_SNMP 6 /* Simple Network Management Protocol */
-#define PT_CNFP 7 /* Cisco NetFlow protocol */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -111,8 +85,30 @@ extern int packettype; /* as specified by -T */
#define LITTLE_ENDIAN 1234
#endif
+#ifdef ETHER_HEADER_HAS_EA
+#define ESRC(ep) ((ep)->ether_shost.ether_addr_octet)
+#define EDST(ep) ((ep)->ether_dhost.ether_addr_octet)
+#else
#define ESRC(ep) ((ep)->ether_shost)
#define EDST(ep) ((ep)->ether_dhost)
+#endif
+
+#ifdef ETHER_ARP_HAS_X
+#define SHA(ap) ((ap)->arp_xsha)
+#define THA(ap) ((ap)->arp_xtha)
+#define SPA(ap) ((ap)->arp_xspa)
+#define TPA(ap) ((ap)->arp_xtpa)
+#else
+#ifdef ETHER_ARP_HAS_EA
+#define SHA(ap) ((ap)->arp_sha.ether_addr_octet)
+#define THA(ap) ((ap)->arp_tha.ether_addr_octet)
+#else
+#define SHA(ap) ((ap)->arp_sha)
+#define THA(ap) ((ap)->arp_tha)
+#endif
+#define SPA(ap) ((ap)->arp_spa)
+#define TPA(ap) ((ap)->arp_tpa)
+#endif
#ifndef NTOHL
#define NTOHL(x) (x) = ntohl(x)
@@ -143,7 +139,9 @@ extern const u_char *snapend;
/* Bail if "var" was not captured */
#define TCHECK(var) TCHECK2(var, sizeof(var))
+#ifdef __STDC__
struct timeval;
+#endif
extern void ts_print(const struct timeval *);
extern void relts_print(int);
@@ -155,16 +153,15 @@ extern char *dnaddr_string(u_short);
extern void wrapup(int);
-extern void error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
+#if __STDC__
+extern __dead void error(const char *, ...)
+ __attribute__((volatile, format (printf, 1, 2)));
extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
+#endif
extern char *read_infile(char *);
extern char *copy_argv(char **);
-extern void safeputchar(int);
-extern void safeputs(const char *);
-
extern char *isonsap_string(const u_char *);
extern char *llcsap_string(u_char);
extern char *protoid_string(const u_char *);
@@ -173,24 +170,24 @@ extern char *dnnum_string(u_short);
/* The printer routines. */
+#ifdef __STDC__
struct pcap_pkthdr;
+#endif
extern void ascii_print_with_offset(const u_char *, u_int, u_int);
extern void ascii_print(const u_char *, u_int);
extern void hex_print_with_offset(const u_char *, u_int, u_int);
extern void telnet_print(const u_char *, u_int);
extern void hex_print(const u_char *, u_int);
-extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
+extern int ether_encap_print(u_short, const u_char *, u_int, u_int);
extern int llc_print(const u_char *, u_int, u_int, const u_char *,
- const u_char *, u_short *);
+ const u_char *);
extern void aarp_print(const u_char *, u_int);
extern void arp_print(const u_char *, u_int, u_int);
extern void atalk_print(const u_char *, u_int);
extern void atm_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void bootp_print(const u_char *, u_int, u_short, u_short);
extern void bgp_print(const u_char *, int);
-extern void bxxp_print(const u_char *, u_int);
-extern void cnfp_print(const u_char *cp, u_int len, const u_char *bp);
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);
@@ -203,15 +200,12 @@ extern void token_if_print(u_char *, const struct pcap_pkthdr *,
extern void fddi_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
extern void gre_print(const u_char *, u_int);
extern void icmp_print(const u_char *, u_int, const u_char *);
-extern void igmp_print(const u_char *, u_int, const u_char *);
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 void ipx_print(const u_char *, u_int);
extern void isoclns_print(const u_char *, u_int, u_int, const u_char *,
const u_char *);
extern void krb_print(const u_char *, u_int);
-extern void llap_print(const u_char *, u_int);
extern void nfsreply_print(const u_char *, u_int, const u_char *);
extern void nfsreq_print(const u_char *, u_int, const u_char *);
extern void ns_print(const u_char *, u_int);
@@ -223,10 +217,7 @@ extern void cisco_autorp_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 void pppoe_print(const u_char *, u_int);
-extern void ppp_print(register const u_char *, u_int);
extern void ppp_if_print(u_char *, const struct pcap_pkthdr *, const u_char *);
-extern void ppp_hdlc_if_print(u_char *, const struct pcap_pkthdr *,
- const u_char *);
extern void ppp_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern int vjc_print(register const char *, register u_int, u_short);
@@ -239,20 +230,18 @@ extern void sl_bsdos_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
extern void chdlc_if_print(u_char *, const struct pcap_pkthdr *,
const u_char *);
-extern void sll_if_print(u_char *, 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 void tcp_print(const u_char *, u_int, const u_char *, int);
+extern void tcp_print(const u_char *, u_int, const u_char *);
extern void tftp_print(const u_char *, u_int);
-extern void timed_print(const u_char *, u_int);
-extern void udp_print(const u_char *, u_int, const u_char *, int);
+extern void udp_print(const u_char *, u_int, const u_char *);
extern void wb_print(const void *, u_int);
extern int ah_print(register const u_char *, register const u_char *);
extern int esp_print(register const u_char *, register const u_char *, int *);
extern void isakmp_print(const u_char *, u_int, const u_char *);
extern int ipcomp_print(register const u_char *, 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 *, const u_char *);
+extern void netbeui_print(const u_char *, const u_char *);
extern void ipx_netbios_print(const u_char *, const u_char *);
extern void nbt_tcp_print(const u_char *, int);
extern void nbt_udp137_print(const u_char *data, int);
@@ -261,11 +250,6 @@ extern char *smb_errstr(int, int);
extern void print_data(const unsigned char *, int);
extern void l2tp_print(const u_char *, u_int);
extern void lcp_print(const u_char *, u_int);
-extern void vrrp_print(const u_char *bp, u_int len, int ttl);
-extern void cdp_print(const u_char *p, u_int length, u_int caplen,
- const u_char *esrc, const u_char *edst);
-extern void stp_print(const u_char *p, u_int length);
-extern void radius_print(const u_char *, u_int);
#ifdef INET6
extern void ip6_print(const u_char *, int);
@@ -277,6 +261,6 @@ extern void icmp6_print(const u_char *, const u_char *);
extern void ripng_print(const u_char *, int);
extern int rt6_print(const u_char *, const u_char *);
extern void ospf6_print(const u_char *, u_int);
-extern void dhcp6_print(const u_char *, u_int, u_int16_t, u_int16_t);
+extern void dhcp6_print(const u_char *, u_int, u_short, u_short);
#endif /*INET6*/
extern u_short in_cksum(const u_short *addr, register int len, u_short csum);
diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h
index 6de8369..0887148 100644
--- a/contrib/tcpdump/nfs.h
+++ b/contrib/tcpdump/nfs.h
@@ -35,6 +35,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
*/
@@ -245,7 +246,7 @@
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
- NFSOCK=6, NFFIFO=7 } nfs_type;
+ NFSOCK=6, NFFIFO=7 } nfstype;
/* Structs for common parts of the rpc's */
/*
@@ -294,7 +295,7 @@ typedef struct nfs_uquad nfsuint64;
*/
union nfs_quadconvert {
u_int32_t lval[2];
- u_int64_t qval;
+ u_quad_t qval;
};
typedef union nfs_quadconvert nfsquad_t;
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index 8160d0f..8a4541e 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -1,11 +1,12 @@
/*
- * $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.9 2000/06/01 01:16:36 assar Exp $
+ * $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.8 1999/12/15 06:49:05 fenner Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
* 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 $ */
/*
@@ -25,7 +26,6 @@ typedef struct {
*/
typedef struct {
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
- char Opaque_Handle[2 * 32 + 1];
u_int32_t fsid_code;
} my_fsid;
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 0f4c3a5..c59ad6a 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -5,11 +5,13 @@
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.18 2000/07/01 03:39:00 assar Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.16 1999/11/21 09:36:47 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -20,6 +22,9 @@ static const char rcsid[] =
#include <sys/time.h>
#include <ctype.h>
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
#include <stdio.h>
#include <string.h>
@@ -90,7 +95,6 @@ int ourself; /* true if file handle was generated on this host */
register unsigned char *fhp = (unsigned char *)fh;
u_int32_t temp;
int fhtype = FHT_UNKNOWN;
- int i;
if (ourself) {
/* File handle generated on this host, no need for guessing */
@@ -368,18 +372,15 @@ int ourself; /* true if file handle was generated on this host */
case FHT_UNKNOWN:
#ifdef DEBUG
- /* XXX debugging */
- int i;
- for (i = 0; i < 32; i++)
- (void)fprintf(stderr, "%x.", fhp[i]);
- (void)fprintf(stderr, "\n");
+ {
+ /* XXX debugging */
+ int i;
+ for (i = 0; i < 32; i++)
+ (void)fprintf(stderr, "%x.", fhp[i]);
+ (void)fprintf(stderr, "\n");
+ }
#endif
/* XXX for now, give "bogus" values to aid debugging */
-
- /* Save the actual handle, so it can be display with -u */
- for (i = 0; i < 32; i++)
- (void)sprintf(&(fsidp->Opaque_Handle[i*2]), "%.2X", fhp[i]);
-
fsidp->fsid_code = 0;
fsidp->Fsid_dev.Minor = 257;
fsidp->Fsid_dev.Major = 257;
diff --git a/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h
index 00d3548..da79154 100644
--- a/contrib/tcpdump/ppp.h
+++ b/contrib/tcpdump/ppp.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.11 2000/10/09 01:53:19 guy Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.8 1999/11/21 03:43:56 assar Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@@ -14,25 +14,30 @@
* 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 */
/* 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_IPV6 0x0057 /* IPv6 */
#define PPP_HELLO 0x0201 /* 802.1d Hello Packets */
#define PPP_LUXCOM 0x0231 /* Luxcom */
@@ -46,15 +51,9 @@
#define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */
#define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */
#define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */
-#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
-#define PPP_CCP 0x80fd /* Compress Control Protocol */
#define PPP_LCP 0xc021 /* Link Control Protocol */
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
#define PPP_LQM 0xc025 /* Link Quality Monitoring */
#define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */
-#define PPP_BACP 0xc02b /* Bandwidth Allocation Control Protocol */
-#define PPP_BAP 0xc02d /* BAP */
-#define PPP_MP 0xc03d /* Multi-Link */
-
extern struct tok ppptype2str[];
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index 7b693a2..2af4bc1 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.49 2000/10/10 05:05:07 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.44 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,84 +32,29 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/socket.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+#include <net/if_var.h>
#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ether.h"
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
-/*
- * Address Resolution Protocol.
- *
- * See RFC 826 for protocol description. ARP packets are variable
- * in size; the arphdr structure defines the fixed-length portion.
- * Protocol type values are the same as those for 10 Mb/s Ethernet.
- * It is followed by the variable-sized fields ar_sha, arp_spa,
- * arp_tha and arp_tpa in that order, according to the lengths
- * specified. Field names used correspond to RFC 826.
- */
-struct arphdr {
- u_short ar_hrd; /* format of hardware address */
-#define ARPHRD_ETHER 1 /* ethernet hardware format */
-#define ARPHRD_IEEE802 6 /* token-ring hardware format */
-#define ARPHRD_FRELAY 15 /* frame relay hardware format */
- u_short ar_pro; /* format of protocol address */
- u_char ar_hln; /* length of hardware address */
- u_char ar_pln; /* length of protocol address */
- u_short ar_op; /* one of: */
-#define ARPOP_REQUEST 1 /* request to resolve address */
-#define ARPOP_REPLY 2 /* response to previous request */
-#define ARPOP_REVREQUEST 3 /* request protocol address given hardware */
-#define ARPOP_REVREPLY 4 /* response giving protocol address */
-#define ARPOP_INVREQUEST 8 /* request to identify peer */
-#define ARPOP_INVREPLY 9 /* response identifying peer */
-/*
- * The remaining fields are variable in size,
- * according to the sizes above.
- */
-#ifdef COMMENT_ONLY
- u_char ar_sha[]; /* sender hardware address */
- u_char ar_spa[]; /* sender protocol address */
- u_char ar_tha[]; /* target hardware address */
- u_char ar_tpa[]; /* target protocol address */
-#endif
-};
-
-#define ARP_HDRLEN 8
-
-/*
- * Ethernet Address Resolution Protocol.
- *
- * See RFC 826 for protocol description. Structure below is adapted
- * to resolving internet addresses. Field names used correspond to
- * RFC 826.
- */
-struct ether_arp {
- struct arphdr ea_hdr; /* fixed-size header */
- u_char arp_sha[6]; /* sender hardware address */
- u_char arp_spa[4]; /* sender protocol address */
- u_char arp_tha[6]; /* target hardware address */
- u_char arp_tpa[4]; /* target protocol address */
-};
-#define arp_hrd ea_hdr.ar_hrd
-#define arp_pro ea_hdr.ar_pro
-#define arp_hln ea_hdr.ar_hln
-#define arp_pln ea_hdr.ar_pln
-#define arp_op ea_hdr.ar_op
-
-#define ETHER_ARP_HDRLEN (ARP_HDRLEN + 6 + 4 + 6 + 4)
-
-#define SHA(ap) ((ap)->arp_sha)
-#define THA(ap) ((ap)->arp_tha)
-#define SPA(ap) ((ap)->arp_spa)
-#define TPA(ap) ((ap)->arp_tpa)
-
/* Compatibility */
#ifndef REVARP_REQUEST
#define REVARP_REQUEST 3
@@ -130,7 +77,7 @@ arp_print(register const u_char *bp, u_int length, u_int caplen)
printf("[|arp]");
return;
}
- if (length < ETHER_ARP_HDRLEN) {
+ if (length < sizeof(struct ether_arp)) {
(void)printf("truncated-arp");
default_print((u_char *)ap, length);
return;
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index 820b7db..2b77ecd 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.64 2000/10/30 06:22:14 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.51 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,12 +36,24 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <net/ethernet.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
@@ -59,13 +73,13 @@ static struct tok type2str[] = {
};
struct aarp {
- u_int16_t htype, ptype;
- u_int8_t halen, palen;
- u_int16_t op;
- u_int8_t hsaddr[6];
- u_int8_t psaddr[4];
- u_int8_t hdaddr[6];
- u_int8_t pdaddr[4];
+ u_short htype, ptype;
+ u_char halen, palen;
+ u_short op;
+ u_char hsaddr[6];
+ u_char psaddr[4];
+ u_char hdaddr[6];
+ u_char pdaddr[4];
};
static char tstr[] = "[|atalk]";
@@ -84,19 +98,26 @@ static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
static const char *ddpskt_string(int);
/*
- * Print AppleTalk LLAP packets.
+ * Print AppleTalk Datagram Delivery Protocol packets.
*/
void
-llap_print(register const u_char *bp, u_int length)
+atalk_print(register const u_char *bp, u_int length)
{
register const struct LAP *lp;
register const struct atDDP *dp;
register const struct atShortDDP *sdp;
u_short snet;
+#if 0
lp = (struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
+#else
+ {
+ static struct LAP lp_ = {0, 0, lapDDP};
+ lp = &lp_;
+ }
+#endif
switch (lp->type) {
case lapShortDDP:
@@ -144,33 +165,6 @@ llap_print(register const u_char *bp, u_int length)
}
}
-/*
- * Print EtherTalk/TokenTalk packets (or FDDITalk, or whatever it's called
- * when it runs over FDDI; yes, I've seen FDDI captures with AppleTalk
- * packets in them).
- */
-void
-atalk_print(register const u_char *bp, u_int length)
-{
- register const struct atDDP *dp;
- u_short snet;
-
- if (length < ddpSize) {
- (void)printf(" [|ddp %d]", length);
- return;
- }
- dp = (const struct atDDP *)bp;
- snet = EXTRACT_16BITS(&dp->srcNet);
- printf("%s.%s", ataddr_string(snet, dp->srcNode),
- ddpskt_string(dp->srcSkt));
- printf(" > %s.%s:",
- ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
- ddpskt_string(dp->dstSkt));
- bp += ddpSize;
- length -= ddpSize;
- ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
-}
-
/* XXX should probably pass in the snap header and do checks like arp_print() */
void
aarp_print(register const u_char *bp, u_int length)
@@ -192,7 +186,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!) */
@@ -200,14 +194,10 @@ aarp_print(register const u_char *bp, u_int length)
AT(pdaddr), AT(psaddr));
return;
}
- (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
- length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
- ap->halen, ap->palen);
+ (void)printf("len %d op %d htype %d ptype %#x halen %d palen %d",
+ length, ap->op, ap->htype, ap->ptype, ap->halen, ap->palen );
}
-/*
- * Print AppleTalk Datagram Delivery Protocol packets.
- */
static void
ddp_print(register const u_char *bp, register u_int length, register int t,
register u_short snet, register u_char snode, u_char skt)
@@ -521,26 +511,24 @@ ataddr_string(u_short atnet, u_char athost)
if (first && (first = 0, !nflag)
&& (fp = fopen("/etc/atalk.names", "r"))) {
char line[256];
- int i1, i2, i3;
+ int i1, i2;
while (fgets(line, sizeof(line), fp)) {
if (line[0] == '\n' || line[0] == 0 || line[0] == '#')
continue;
- if (sscanf(line, "%d.%d.%d %256s", &i1, &i2, &i3,
- nambuf) == 4)
+ if (sscanf(line, "%d.%d %s", &i1, &i2, nambuf) == 3)
/* got a hostname. */
- i3 |= ((i1 << 8) | i2) << 8;
- else if (sscanf(line, "%d.%d %256s", &i1, &i2,
- nambuf) == 3)
+ i2 |= (i1 << 8);
+ else if (sscanf(line, "%d %s", &i1, nambuf) == 2)
/* got a net name */
- i3 = (((i1 << 8) | i2) << 8) | 255;
+ i2 = (i1 << 8) | 255;
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 = savestr(nambuf);
}
@@ -557,8 +545,7 @@ ataddr_string(u_short atnet, u_char athost)
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
- (void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
- tp2->name, athost);
+ (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", tp2->name, athost);
tp->name = savestr(nambuf);
return (tp->name);
}
@@ -566,11 +553,9 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
- (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d",
- atnet >> 8, atnet & 0xff, athost);
+ (void)sprintf(nambuf, "%d.%d", atnet, athost);
else
- (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8,
- atnet & 0xff);
+ (void)sprintf(nambuf, "%d", atnet);
tp->name = savestr(nambuf);
return (tp->name);
@@ -590,7 +575,7 @@ ddpskt_string(register int skt)
static char buf[8];
if (nflag) {
- (void)snprintf(buf, sizeof(buf), "%d", skt);
+ (void)sprintf(buf, "%d", skt);
return (buf);
}
return (tok2str(skt2str, "%d", skt));
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index d978086..8fb95e7 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.20 2000/12/22 22:45:09 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.12 1999/11/21 09:36:48 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,7 +33,22 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+
+#include <net/if.h>
+#include <net/if_var.h>
+
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <stdio.h>
#include <pcap.h>
@@ -59,7 +76,18 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
printf("[|atm]");
goto out;
}
- if (p[0] != 0xaa || p[1] != 0xaa || p[2] != 0x03) {
+
+ if (p[4] == 0xaa || p[5] == 0xaa || p[6] == 0x03) {
+ /* if first 4 bytes are cookie/vpci */
+ if (eflag) {
+ printf("%04x ",
+ p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]);
+ }
+ p += 4;
+ length -= 4;
+ caplen -= 4;
+ }
+ else if (p[0] != 0xaa || p[1] != 0xaa || p[2] != 0x03) {
/*XXX assume 802.6 MAC header from fore driver */
if (eflag)
printf("%04x%04x %04x%04x ",
@@ -128,14 +156,15 @@ atm_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
/* default_print for now */
#endif
default:
- /* ether_type not known, print raw packet */
+ /* ether_type not known, forward it to llc_print */
if (!eflag)
printf("%02x %02x %02x %02x-%02x-%02x %04x: ",
- packetp[0], packetp[1], packetp[2], /* dsap/ssap/ctrl */
- packetp[3], packetp[4], packetp[5], /* manufacturer's code */
+ p[0], p[1], p[2], /* dsap/ssap/ctrl */
+ p[3], p[4], p[5], /* manufacturer's code */
ethertype);
if (!xflag && !qflag)
- default_print(p, caplen);
+ /* default_print(p, caplen); */
+ llc_print(p-8,length+8,caplen+8,"000000","000000");
}
if (xflag)
default_print(p, caplen);
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index e564a29..7e15815 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.56 2000/12/04 00:00:08 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.48 1999/11/21 09:36:49 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,19 +35,24 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
#include <ctype.h>
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
#include <stdio.h>
#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "extract.h"
-#include "ether.h"
#include "bootp.h"
static void rfc1048_print(const u_char *, u_int);
@@ -174,7 +181,7 @@ bootp_print(register const u_char *cp, u_int length,
else {
u_int32_t ul;
- ul = EXTRACT_32BITS(&bp->bp_vend);
+ memcpy((char *)&ul, (char *)bp->bp_vend, sizeof(ul));
if (ul != 0)
printf("vend-#0x%x", ul);
}
@@ -189,7 +196,7 @@ static struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
{ TAG_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */
- { TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */
+ { TAG_TIME_OFFSET, "lTZ" }, /* seconds from UTC */
{ TAG_GATEWAY, "iDG" }, /* default gateway */
{ TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */
{ TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */
@@ -264,46 +271,7 @@ static struct tok tag2str[] = {
{ TAG_RENEWAL_TIME, "lRN" },
{ TAG_REBIND_TIME, "lRB" },
{ TAG_VENDOR_CLASS, "bVC" },
- { TAG_CLIENT_ID, "xCID" },
-/* RFC 2485 */
- { TAG_OPEN_GROUP_UAP, "aUAP" },
-/* RFC 2563 */
- { TAG_DISABLE_AUTOCONF, "BNOAUTO" },
-/* RFC 2610 */
- { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */
- { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */
-/* RFC 2937 */
- { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */
-/* RFC 3011 */
- { TAG_IP4_SUBNET_SELECT, "iSUBNET" },
-/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
- { TAG_USER_CLASS, "aCLASS" },
- { TAG_SLP_NAMING_AUTH, "aSLP-NA" },
- { TAG_CLIENT_FQDN, "bFQDN" }, /* XXX 'b' */
- { TAG_AGENT_CIRCUIT, "bACKT" },
- { TAG_AGENT_REMOTE, "bARMT" },
- { TAG_AGENT_MASK, "bAMSK" },
- { TAG_TZ_STRING, "aTZSTR" },
- { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */
- { TAG_AUTH, "bAUTH" }, /* XXX 'b' */
- { TAG_VINES_SERVERS, "iVINES" },
- { TAG_SERVER_RANK, "sRANK" },
- { TAG_CLIENT_ARCH, "sARCH" },
- { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */
- { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
- { TAG_LDAP_URL, "aLDAP" },
- { TAG_6OVER4, "i6o4" },
- { TAG_PRINTER_NAME, "aPRTR" },
- { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
- { TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
- { TAG_NETINFO_PARENT, "iNI" },
- { TAG_NETINFO_PARENT_TAG, "aNITAG" },
- { TAG_URL, "aURL" },
- { TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
- { 0, NULL }
-};
-/* 2-byte extended tags */
-static struct tok xtag2str[] = {
+ { TAG_CLIENT_ID, "bCID" },
{ 0, NULL }
};
@@ -330,16 +298,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
continue;
if (tag == TAG_END)
return;
- if (tag == TAG_EXTENDED_OPTION) {
- TCHECK2(*(bp + 1), 2);
- tag = EXTRACT_16BITS(bp + 1);
- /* XXX we don't know yet if the IANA will
- * preclude overlap of 1-byte and 2-byte spaces.
- * If not, we need to offset tag after this step.
- */
- cp = tok2str(xtag2str, "?xT%d", tag);
- } else
- cp = tok2str(tag2str, "?T%d", tag);
+ cp = tok2str(tag2str, "?T%d", tag);
c = *cp++;
printf(" %s:", cp);
@@ -374,21 +333,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
first = 1;
while (len-- > 0) {
c = *bp++;
- cp = tok2str(tag2str, "?T%d", c);
- if (!first)
- putchar('+');
- printf("%s", cp + 1);
- first = 0;
- }
- continue;
- }
- if (tag == TAG_EXTENDED_REQUEST) {
- first = 1;
- while (len > 1) {
- len -= 2;
- c = EXTRACT_16BITS(bp);
- bp += 2;
- cp = tok2str(xtag2str, "?xT%d", c);
+ cp = tok2str(tag2str, "?%d", c);
if (!first)
putchar('+');
printf("%s", cp + 1);
@@ -422,17 +367,13 @@ rfc1048_print(register const u_char *bp, register u_int length)
case 'i':
case 'l':
- case 'L':
/* ip addresses/32-bit words */
while (size >= sizeof(ul)) {
if (!first)
putchar(',');
- ul = EXTRACT_32BITS(bp);
- if (c == 'i') {
- ul = htonl(ul);
+ memcpy((char *)&ul, (char *)bp, sizeof(ul));
+ if (c == 'i')
printf("%s", ipaddr_string(&ul));
- } else if (c == 'L')
- printf("%d", ul);
else
printf("%u", ul);
bp += sizeof(ul);
@@ -462,7 +403,7 @@ rfc1048_print(register const u_char *bp, register u_int length)
while (size >= sizeof(us)) {
if (!first)
putchar(',');
- us = EXTRACT_16BITS(bp);
+ memcpy((char *)&us, (char *)bp, sizeof(us));
printf("%d", us);
bp += sizeof(us);
size -= sizeof(us);
@@ -493,13 +434,12 @@ rfc1048_print(register const u_char *bp, register u_int length)
break;
case 'b':
- case 'x':
default:
/* Bytes */
while (size > 0) {
if (!first)
- putchar (c == 'x' ? ':' : '.');
- printf (c == 'x' ? "%02x" : "%d", *bp);
+ putchar('.');
+ printf("%d", *bp);
++bp;
--size;
first = 0;
@@ -510,9 +450,6 @@ rfc1048_print(register const u_char *bp, register u_int length)
if (size)
printf("[len %d]", len);
}
- return;
-trunc:
- printf("|[rfc1048]");
}
static void
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index 77da8df..50f2ce2 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.64 2001/01/02 23:24:51 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.42 1999/11/21 09:36:50 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,8 +32,22 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/socket.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
@@ -39,7 +55,7 @@ static const char rcsid[] =
#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
#endif
-#include "nameser.h"
+#include <arpa/nameser.h>
#include <stdio.h>
#include <string.h>
@@ -110,14 +126,7 @@ static const char rcsid[] =
#define T_NAPTR 35 /* Naming Authority PoinTeR */
#endif
#ifndef T_A6
-#define T_A6 38 /* IP6 address */
-#endif
-#ifndef T_DNAME
-#define T_DNAME 39 /* non-terminal redirection */
-#endif
-
-#ifndef T_OPT
-#define T_OPT 41 /* EDNS0 option (meta-RR) */
+#define T_A6 38 /* IP6 address (ipngwg-dns-lookups) */
#endif
#ifndef T_UNSPEC
@@ -155,22 +164,8 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
if (((i = *cp++) & INDIR_MASK) == INDIR_MASK)
return (cp + 1);
- if (cp >= snapend)
- return(NULL);
while (i && cp < snapend) {
- if ((i & INDIR_MASK) == EDNS0_MASK) {
- int bitlen, bytelen;
-
- if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
- return(NULL); /* unknown ELT */
- if ((bitlen = *cp++) == 0)
- bitlen = 256;
- bytelen = (bitlen + 7) / 8;
- cp += bytelen;
- } else
- cp += i;
- if (cp >= snapend)
- return(NULL);
+ cp += i;
i = *cp++;
}
return (cp);
@@ -178,135 +173,33 @@ ns_nskip(register const u_char *cp, register const u_char *bp)
/* print a <domain-name> */
static const u_char *
-blabel_print(const u_char *cp)
-{
- int bitlen, slen, b;
- int truncated = 0;
- const u_char *bitp, *lim;
- char tc;
-
- if (cp >= snapend)
- return(NULL);
- if ((bitlen = *cp) == 0)
- bitlen = 256;
- slen = (bitlen + 3) / 4;
- if ((lim = cp + 1 + slen) > snapend) {
- truncated = 1;
- lim = snapend;
- }
-
- /* print the bit string as a hex string */
- printf("\\[x");
- for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++)
- printf("%02x", *bitp);
- if (bitp == lim)
- printf("...");
- else if (b > 4) {
- tc = *bitp++;
- printf("%02x", tc & (0xff << (8 - b)));
- } else if (b > 0) {
- tc = *bitp++;
- printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
- }
- printf("/%d]", bitlen);
-
- return(truncated ? NULL : lim);
-}
-
-static int
-labellen(const u_char *cp)
+ns_nprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
+ register const u_char *rp;
+ register int compress;
- if (cp >= snapend)
- return(-1);
- i = *cp;
- if ((i & INDIR_MASK) == EDNS0_MASK) {
- int bitlen, elt;
-
- if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL)
- return(-1);
- if (cp + 1 >= snapend)
- return(-1);
- if ((bitlen = *(cp + 1)) == 0)
- bitlen = 256;
- return(((bitlen + 7) / 8) + 1);
+ i = *cp++;
+ rp = cp + i;
+ if ((i & INDIR_MASK) == INDIR_MASK) {
+ rp = cp + 1;
+ compress = 1;
} else
- return(i);
-}
-
-static const u_char *
-ns_nprint(register const u_char *cp, register const u_char *bp)
-{
- register u_int i, l;
- register const u_char *rp = NULL;
- register int compress = 0;
- int chars_processed;
- int elt;
- int data_size = snapend - bp;
-
- if ((l = labellen(cp)) < 0)
- return(NULL);
- if (cp >= snapend)
- return(NULL);
- chars_processed = 1;
- if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
compress = 0;
- rp = cp + l;
- }
-
if (i != 0)
while (i && cp < snapend) {
if ((i & INDIR_MASK) == INDIR_MASK) {
- if (!compress) {
- rp = cp + 1;
- compress = 1;
- }
cp = bp + (((i << 8) | *cp) & 0x3fff);
- if (cp >= snapend)
- return(NULL);
- if ((l = labellen(cp)) < 0)
- return(NULL);
i = *cp++;
- chars_processed++;
-
- /*
- * If we've looked at every character in
- * the message, this pointer will make
- * us look at some character again,
- * which means we're looping.
- */
- if (chars_processed >= data_size) {
- printf("<LOOP>");
- return (NULL);
- }
continue;
}
- if ((i & INDIR_MASK) == EDNS0_MASK) {
- elt = (i & ~INDIR_MASK);
- switch(elt) {
- case EDNS0_ELT_BITLABEL:
- blabel_print(cp);
- break;
- default:
- /* unknown ELT */
- printf("<ELT %d>", elt);
- return(NULL);
- }
- } else {
- if (fn_printn(cp, l, snapend))
- break;
- }
-
- cp += l;
- chars_processed += l;
+ if (fn_printn(cp, i, snapend))
+ break;
+ cp += i;
putchar('.');
- if (cp >= snapend || (l = labellen(cp)) < 0)
- return(NULL);
i = *cp++;
- chars_processed++;
if (!compress)
- rp += l + 1;
+ rp += i + 1;
}
else
putchar('.');
@@ -319,8 +212,6 @@ ns_cprint(register const u_char *cp, register const u_char *bp)
{
register u_int i;
- if (cp >= snapend)
- return NULL;
i = *cp++;
(void)fn_printn(cp, i, snapend);
return (cp + i);
@@ -363,10 +254,17 @@ static struct tok type2str[] = {
{ T_ATMA, "ATMA " },
{ T_NAPTR, "NAPTR " },
{ T_A6, "A6 " },
- { T_DNAME, "DNAME " },
- { T_OPT, "OPT " },
+#ifndef T_UINFO
+#define T_UINFO 100
+#endif
{ T_UINFO, "UINFO" },
+#ifndef T_UID
+#define T_UID 101
+#endif
{ T_UID, "UID" },
+#ifndef T_GID
+#define T_GID 102
+#endif
{ T_GID, "GID" },
{ T_UNSPEC, "UNSPEC" },
{ T_UNSPECA, "UNSPECA" },
@@ -386,7 +284,7 @@ static struct tok class2str[] = {
};
/* print a query */
-static const u_char *
+static void
ns_qprint(register const u_char *cp, register const u_char *bp)
{
register const u_char *np = cp;
@@ -394,8 +292,8 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
cp = ns_nskip(cp, bp);
- if (cp + 4 > snapend || cp == NULL)
- return(NULL);
+ if (cp + 4 > snapend)
+ return;
/* print the qtype and qclass (if it's not IN) */
i = *cp++ << 8;
@@ -407,35 +305,33 @@ ns_qprint(register const u_char *cp, register const u_char *bp)
printf(" %s", tok2str(class2str, "(Class %d)", i));
fputs("? ", stdout);
- cp = ns_nprint(np, bp);
- return(cp ? cp + 4 : NULL);
+ ns_nprint(np, bp);
}
/* print a reply */
static const u_char *
ns_rprint(register const u_char *cp, register const u_char *bp)
{
- register u_int class;
+ register u_int i;
register u_short typ, len;
register const u_char *rp;
if (vflag) {
putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
- return NULL;
+ cp = ns_nprint(cp, bp);
} else
cp = ns_nskip(cp, bp);
- if (cp + 10 > snapend || cp == NULL)
+ if (cp + 10 > snapend)
return (snapend);
/* print the type/qtype and class (if it's not IN) */
typ = *cp++ << 8;
typ |= *cp++;
- class = *cp++ << 8;
- class |= *cp++;
- if (class != C_IN && typ != T_OPT)
- printf(" %s", tok2str(class2str, "(Class %d)", class));
+ i = *cp++ << 8;
+ i |= *cp++;
+ if (i != C_IN)
+ printf(" %s", tok2str(class2str, "(Class %d)", i));
/* ignore ttl */
cp += 4;
@@ -446,13 +342,9 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
rp = cp + len;
printf(" %s", tok2str(type2str, "Type%d", typ));
- if (rp > snapend)
- return(NULL);
-
switch (typ) {
+
case T_A:
- if (cp + sizeof(struct in_addr) > snapend)
- return(NULL);
printf(" %s", ipaddr_string(cp));
break;
@@ -460,41 +352,15 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
case T_CNAME:
case T_PTR:
#ifdef T_DNAME
- case T_DNAME:
+ case T_DNAME: /*XXX not checked as there's no server support yet*/
#endif
putchar(' ');
- if (ns_nprint(cp, bp) == NULL)
- return(NULL);
+ (void)ns_nprint(cp, bp);
break;
- case T_SOA:
- if (!vflag)
- break;
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
- return(NULL);
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
- return(NULL);
- if (cp + 5 * 4 > snapend)
- return(NULL);
- printf(" %u", EXTRACT_32BITS(cp));
- cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
- cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
- cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
- cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
- cp += 4;
- break;
case T_MX:
putchar(' ');
- if (cp + 2 > snapend)
- return(NULL);
- if (ns_nprint(cp + 2, bp) == NULL)
- return(NULL);
+ (void)ns_nprint(cp + 2, bp);
printf(" %d", EXTRACT_16BITS(cp));
break;
@@ -505,43 +371,25 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
#ifdef INET6
case T_AAAA:
- if (cp + sizeof(struct in6_addr) > snapend)
- return(NULL);
printf(" %s", ip6addr_string(cp));
break;
- case T_A6:
+ case T_A6: /*XXX not checked as there's no server support yet*/
{
struct in6_addr a;
- int pbit, pbyte;
-
- pbit = *cp;
- pbyte = (pbit & ~7) / 8;
- if (pbit > 128) {
- printf(" %u(bad plen)", pbit);
- break;
- } else if (pbit < 128) {
- memset(&a, 0, sizeof(a));
- memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
- printf(" %u %s", pbit, ip6addr_string(&a));
- }
- if (pbit > 0) {
- putchar(' ');
- if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
- return(NULL);
- }
+ int pbyte;
+
+ pbyte = (*cp + 7) / 8;
+ memset(&a, 0, sizeof(a));
+ memcpy(&a, cp + 1, pbyte);
+ printf(" %u %s ", *cp, ip6addr_string(&a));
+ (void)ns_nprint(cp + 1 + pbyte, bp);
break;
}
#endif /*INET6*/
- case T_OPT:
- printf(" UDPsize=%u", class);
- break;
-
case T_UNSPECA: /* One long string */
- if (cp + len > snapend)
- return(NULL);
- fn_printn(cp, len, snapend);
+ printf(" %.*s", len, cp);
break;
}
return (rp); /* XXX This isn't always right */
@@ -552,7 +400,7 @@ ns_print(register const u_char *bp, u_int length)
{
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
- register const u_char *cp = NULL;
+ register const u_char *cp;
np = (const HEADER *)bp;
/* get the byte-order right */
@@ -561,76 +409,44 @@ ns_print(register const u_char *bp, u_int length)
nscount = ntohs(np->nscount);
arcount = ntohs(np->arcount);
- if (DNS_QR(np)) {
+ if (np->qr) {
/* this is a response */
- printf(" %d%s%s%s%s%s%s",
+ printf(" %d%s%s%s%s%s",
ntohs(np->id),
- ns_ops[DNS_OPCODE(np)],
- ns_resp[DNS_RCODE(np)],
- DNS_AA(np)? "*" : "",
- DNS_RA(np)? "" : "-",
- DNS_TC(np)? "|" : "",
- DNS_CD(np)? "%" : "");
-
+ ns_ops[np->opcode],
+ ns_resp[np->rcode],
+ np->aa? "*" : "",
+ np->ra? "" : "-",
+ np->tc? "|" : "");
if (qdcount != 1)
printf(" [%dq]", qdcount);
/* Print QUESTION section on -vv */
if (vflag > 1) {
- fputs(" q:", stdout);
- if ((cp = ns_qprint((const u_char *)(np + 1), bp))
- == NULL)
- goto trunc;
- } else {
- if ((cp = ns_nskip((const u_char *)(np + 1), bp))
- == NULL)
- goto trunc;
- cp += 4;
- }
+ fputs(" q: ", stdout);
+ cp = ns_nprint((const u_char *)(np + 1), bp);
+ } else
+ cp = ns_nskip((const u_char *)(np + 1), bp);
printf(" %d/%d/%d", ancount, nscount, arcount);
if (ancount--) {
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
+ cp = ns_rprint(cp + 4, bp);
while (ancount-- && cp < snapend) {
putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
- /* Print NS and AR sections on -vv */
- if (vflag > 1) {
- if (nscount-- && cp < snapend) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (nscount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
- if (arcount-- && cp < snapend) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (arcount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
+ cp = ns_rprint(cp, bp);
}
}
}
else {
/* this is a request */
- printf(" %d%s%s%s", ntohs(np->id), ns_ops[DNS_OPCODE(np)],
- DNS_RD(np) ? "+" : "",
- DNS_AD(np) ? "$" : "");
+ printf(" %d%s%s",
+ ntohs(np->id),
+ ns_ops[np->opcode],
+ np->rd? "+" : "");
/* any weirdness? */
- if (*(((u_short *)np)+1) & htons(0x6cf))
+ if (*(((u_short *)np)+1) & htons(0x6ff))
printf(" [b2&3=0x%x]", ntohs(*(((u_short *)np)+1)));
- if (DNS_OPCODE(np) == IQUERY) {
+ if (np->opcode == IQUERY) {
if (qdcount)
printf(" [%dq]", qdcount);
if (ancount != 1)
@@ -647,60 +463,7 @@ ns_print(register const u_char *bp, u_int length)
if (arcount)
printf(" [%dau]", arcount);
- if (qdcount--) {
- cp = ns_qprint((const u_char *)(np + 1),
- (const u_char *)np);
- if (!cp)
- goto trunc;
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (qdcount-- && cp < snapend) {
- cp = ns_qprint((const u_char *)cp,
- (const u_char *)np);
- if (!cp)
- goto trunc;
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
-
- /* Print remaining sections on -vv */
- if (vflag > 1) {
- if (ancount--) {
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (ancount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
- if (nscount-- && cp < snapend) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (nscount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
- if (arcount-- && cp < snapend) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- while (arcount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp)) == NULL)
- goto trunc;
- }
- }
- }
+ ns_qprint((const u_char *)(np + 1), (const u_char *)np);
}
printf(" (%d)", length);
- return;
-
- trunc:
- printf("[|domain]");
- return;
}
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index d10a86e..d33028d 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.61 2000/12/22 22:45:10 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.48 1999/11/21 09:36:51 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -31,20 +33,32 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <stdio.h>
#include <pcap.h>
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
-#include "ether.h"
-
const u_char *packetp;
const u_char *snapend;
@@ -67,6 +81,8 @@ ether_print(register const u_char *bp, u_int length)
length);
}
+static u_short extracted_ethertype;
+
/*
* This is the top level routine of the printer. 'p' is the points
* to the ether header of the packet, 'h->tv' is the timestamp,
@@ -80,11 +96,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
u_int length = h->len;
struct ether_header *ep;
u_short ether_type;
- u_short extracted_ethertype;
ts_print(&h->ts);
- if (caplen < ETHER_HDRLEN) {
+ if (caplen < sizeof(struct ether_header)) {
printf("[|ether]");
goto out;
}
@@ -100,10 +115,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
packetp = p;
snapend = p + caplen;
- length -= ETHER_HDRLEN;
- caplen -= ETHER_HDRLEN;
+ length -= sizeof(struct ether_header);
+ caplen -= sizeof(struct ether_header);
ep = (struct ether_header *)p;
- p += ETHER_HDRLEN;
+ p += sizeof(struct ether_header);
ether_type = ntohs(ep->ether_type);
@@ -113,11 +128,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
extracted_ethertype = 0;
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
- &extracted_ethertype) == 0) {
+ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print((u_char *)ep, length + ETHER_HDRLEN);
+ ether_print((u_char *)ep, length);
if (extracted_ethertype) {
printf("(LLC %s) ",
etherproto_string(htons(extracted_ethertype)));
@@ -125,11 +139,10 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (!xflag && !qflag)
default_print(p, caplen);
}
- } else if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ethertype) == 0) {
+ } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print((u_char *)ep, length + ETHER_HDRLEN);
+ ether_print((u_char *)ep, length + sizeof(*ep));
if (!xflag && !qflag)
default_print(p, caplen);
}
@@ -145,18 +158,16 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
*
* Returns non-zero if it can do so, zero if the ethertype is unknown.
*
- * The Ethernet type code is passed through a pointer; if it was
- * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
- * the 802.1Q payload, for the benefit of lower layers that might
- * want to know what it is.
+ * Stuffs the ether type into a global for the benefit of lower layers
+ * that might want to know what it is.
*/
int
ether_encap_print(u_short ethertype, const u_char *p,
- u_int length, u_int caplen, u_short *extracted_ethertype)
+ u_int length, u_int caplen)
{
recurse:
- *extracted_ethertype = ethertype;
+ extracted_ethertype = ethertype;
switch (ethertype) {
@@ -194,30 +205,29 @@ ether_encap_print(u_short ethertype, const u_char *p,
return (1);
case ETHERTYPE_8021Q:
- printf("802.1Q vlan#%d P%d%s ",
- ntohs(*(u_int16_t *)p) & 0xfff,
- ntohs(*(u_int16_t *)p) >> 13,
- (ntohs(*(u_int16_t *)p) & 0x1000) ? " CFI" : "");
- ethertype = ntohs(*(u_int16_t *)(p + 2));
+ printf("802.1Q vlan#%d P%d%s",
+ ntohs(*(unsigned short*)p)&0xFFF,
+ ntohs(*(unsigned short*)p)>>13,
+ (ntohs(*(unsigned short*)p)&0x1000) ? " CFI" : "");
+ ethertype = ntohs(*(unsigned short*)(p+2));
p += 4;
length -= 4;
caplen -= 4;
- if (ethertype > ETHERMTU)
+ if (ethertype > ETHERMTU)
goto recurse;
- *extracted_ethertype = 0;
+ extracted_ethertype = 0;
- if (llc_print(p, length, caplen, p - 18, p - 12,
- extracted_ethertype) == 0) {
+ if (llc_print(p, length, caplen, p-18, p-12) == 0) {
/* ether_type not known, print raw packet */
if (!eflag)
- ether_print(p - 18, length + 4);
- if (*extracted_ethertype) {
+ ether_print(p-18, length+4);
+ if (extracted_ethertype) {
printf("(LLC %s) ",
- etherproto_string(htons(*extracted_ethertype)));
+ etherproto_string(htons(extracted_ethertype)));
}
if (!xflag && !qflag)
- default_print(p - 18, caplen + 4);
+ default_print(p-18, caplen+4);
}
return (1);
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index d0286de..d2526fa 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.50 2000/12/23 20:48:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.40 1999/12/14 16:49:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,7 +36,16 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/ioctl.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
#include <ctype.h>
#include <netdb.h>
@@ -46,7 +57,6 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "ethertype.h"
-#include "ether.h"
#include "fddi.h"
/*
@@ -88,6 +98,8 @@ int fddi_bitswap = 1;
* - vj
*/
+#define FDDI_HDRLEN (sizeof(struct fddi_header))
+
static u_char fddi_bit_swap[] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@@ -279,10 +291,10 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
*/
snapend = p + caplen;
/*
- * Actually, the only printers that use packetp are print-arp.c
- * and print-bootp.c, and they assume that packetp points to an
- * Ethernet header. The right thing to do is to fix them to know
- * which link type is in use when they excavate. XXX
+ * Actually, the only printer that uses packetp is print-bootp.c,
+ * and it assumes that packetp points to an Ethernet header. The
+ * right thing to do is to fix print-bootp.c to know which link
+ * type is in use when it excavates. XXX
*/
packetp = (u_char *)&ehdr;
@@ -298,14 +310,14 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
extracted_ethertype = 0;
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
+ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr))
+ == 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!eflag)
- fddi_print(fddip, length + FDDI_HDRLEN,
+ fddi_print(fddip, length,
ESRC(&ehdr), EDST(&ehdr));
if (extracted_ethertype) {
printf("(LLC %s) ",
@@ -319,8 +331,7 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
else {
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!eflag)
- fddi_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
- EDST(&ehdr));
+ fddi_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
if (!xflag && !qflag)
default_print(p, caplen);
}
diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c
index f082488..7039338 100644
--- a/contrib/tcpdump/print-fr.c
+++ b/contrib/tcpdump/print-fr.c
@@ -17,11 +17,13 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD$
*/
#ifndef lint
static char rcsid[] =
- "@(#)$Header: /cvs/juniper/src/freebsd/contrib/tcpdump/print-fr.c,v 1.2 1997/07/18 20:24:15 boonmark Exp $ (LBL)";
+ "@(#)$Header: /home/ncvs/src/contrib/tcpdump/print-fr.c,v 1.1 1997/12/31 21:50:31 pst Exp $ (LBL)";
#endif
#ifdef PPP
@@ -36,6 +38,7 @@ struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
+#include <net/if_var.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -394,12 +397,12 @@ q933_print(const u_char *p, int length)
break;
case LINK_VERIFY_IE_91:
case LINK_VERIFY_IE_94:
- sprintf(temp_str,"TX Seq: %3d, RX Seq: %3d",
+ 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:
- sprintf(temp_str,"DLCI %d: status %s %s",
+ 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");
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index 59f6465..a4b3dd6 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.57 2000/10/10 05:03:32 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999/11/22 04:28:21 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,139 +34,29 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <stdio.h>
#include <string.h>
-#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
#include "interface.h"
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-#include "ip.h"
-#include "udp.h"
-
-/*
- * Interface Control Message Protocol Definitions.
- * Per RFC 792, September 1981.
- */
-
-/*
- * Structure of an icmp header.
- */
-struct icmp {
- u_int8_t icmp_type; /* type of message, see below */
- u_int8_t icmp_code; /* type sub code */
- u_int16_t icmp_cksum; /* ones complement cksum of struct */
- union {
- u_int8_t ih_pptr; /* ICMP_PARAMPROB */
- struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
- struct ih_idseq {
- u_int16_t icd_id;
- u_int16_t icd_seq;
- } ih_idseq;
- u_int32_t ih_void;
-
- /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
- struct ih_pmtu {
- u_int16_t ipm_void;
- u_int16_t ipm_nextmtu;
- } ih_pmtu;
- } icmp_hun;
-#define icmp_pptr icmp_hun.ih_pptr
-#define icmp_gwaddr icmp_hun.ih_gwaddr
-#define icmp_id icmp_hun.ih_idseq.icd_id
-#define icmp_seq icmp_hun.ih_idseq.icd_seq
-#define icmp_void icmp_hun.ih_void
-#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
-#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
- union {
- struct id_ts {
- u_int32_t its_otime;
- u_int32_t its_rtime;
- u_int32_t its_ttime;
- } id_ts;
- struct id_ip {
- struct ip idi_ip;
- /* options and then 64 bits of data */
- } id_ip;
- u_int32_t id_mask;
- u_int8_t id_data[1];
- } icmp_dun;
-#define icmp_otime icmp_dun.id_ts.its_otime
-#define icmp_rtime icmp_dun.id_ts.its_rtime
-#define icmp_ttime icmp_dun.id_ts.its_ttime
-#define icmp_ip icmp_dun.id_ip.idi_ip
-#define icmp_mask icmp_dun.id_mask
-#define icmp_data icmp_dun.id_data
-};
-
-/*
- * Lower bounds on packet lengths for various types.
- * For the error advice packets must first insure that the
- * packet is large enought to contain the returned ip header.
- * Only then can we do the check to see if 64 bits of packet
- * data have been returned, since we need to check the returned
- * ip header length.
- */
-#define ICMP_MINLEN 8 /* abs minimum */
-#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
-#define ICMP_MASKLEN 12 /* address mask */
-#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
-#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
- /* N.B.: must separately check that ip_hl >= 5 */
-
-/*
- * Definition of type and code field values.
- */
-#define ICMP_ECHOREPLY 0 /* echo reply */
-#define ICMP_UNREACH 3 /* dest unreachable, codes: */
-#define ICMP_UNREACH_NET 0 /* bad net */
-#define ICMP_UNREACH_HOST 1 /* bad host */
-#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
-#define ICMP_UNREACH_PORT 3 /* bad port */
-#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
-#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
-#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
-#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
-#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
-#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
-#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
-#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
-#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
-#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
-#define ICMP_REDIRECT 5 /* shorter route, codes: */
-#define ICMP_REDIRECT_NET 0 /* for network */
-#define ICMP_REDIRECT_HOST 1 /* for host */
-#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
-#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
-#define ICMP_ECHO 8 /* echo service */
-#define ICMP_ROUTERADVERT 9 /* router advertisement */
-#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
-#define ICMP_TIMXCEED 11 /* time exceeded, code: */
-#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
-#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
-#define ICMP_PARAMPROB 12 /* ip header bad */
-#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
-#define ICMP_TSTAMP 13 /* timestamp request */
-#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
-#define ICMP_IREQ 15 /* information request */
-#define ICMP_IREQREPLY 16 /* information reply */
-#define ICMP_MASKREQ 17 /* address mask request */
-#define ICMP_MASKREPLY 18 /* address mask reply */
-
-#define ICMP_MAXTYPE 18
-
-#define ICMP_INFOTYPE(type) \
- ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
- (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
- (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
- (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
- (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
/* rfc1700 */
#ifndef ICMP_UNREACH_NET_UNKNOWN
#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
@@ -199,6 +91,14 @@ struct icmp {
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
#endif
+/* rfc1256 */
+#ifndef ICMP_ROUTERADVERT
+#define ICMP_ROUTERADVERT 9 /* router advertisement */
+#endif
+#ifndef ICMP_ROUTERSOLICIT
+#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
+#endif
+
/* Most of the icmp types */
static struct tok icmp2str[] = {
{ ICMP_ECHOREPLY, "echo reply" },
@@ -251,15 +151,15 @@ static struct tok type2str[] = {
/* rfc1191 */
struct mtu_discovery {
- u_int16_t unused;
- u_int16_t nexthopmtu;
+ short unused;
+ short nexthopmtu;
};
/* rfc1256 */
struct ih_rdiscovery {
- u_int8_t ird_addrnum;
- u_int8_t ird_addrsiz;
- u_int16_t ird_lifetime;
+ u_char ird_addrnum;
+ u_char ird_addrsiz;
+ u_short ird_lifetime;
};
struct id_rdiscovery {
@@ -298,16 +198,15 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
case ICMP_UNREACH_PROTOCOL:
TCHECK(dp->icmp_ip.ip_p);
- (void)snprintf(buf, sizeof(buf),
- "%s protocol %d unreachable",
- ipaddr_string(&dp->icmp_ip.ip_dst),
- dp->icmp_ip.ip_p);
+ (void)snprintf(buf, sizeof(buf), "%s protocol %d unreachable",
+ ipaddr_string(&dp->icmp_ip.ip_dst),
+ dp->icmp_ip.ip_p);
break;
case ICMP_UNREACH_PORT:
TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
- hlen = IP_HL(oip) * 4;
+ hlen = oip->ip_hl * 4;
ouh = (struct udphdr *)(((u_char *)oip) + hlen);
dport = ntohs(ouh->uh_dport);
switch (oip->ip_p) {
@@ -336,20 +235,20 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
case ICMP_UNREACH_NEEDFRAG:
- {
+ {
register const struct mtu_discovery *mp;
+
mp = (struct mtu_discovery *)&dp->icmp_void;
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
- if (mtu) {
- (void)snprintf(buf, sizeof(buf),
- "%s unreachable - need to frag (mtu %d)",
- ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
- } else {
- (void)snprintf(buf, sizeof(buf),
- "%s unreachable - need to frag",
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ if (mtu)
+ (void)snprintf(buf, sizeof(buf),
+ "%s unreachable - need to frag (mtu %d)",
+ ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
+ else
+ (void)snprintf(buf, sizeof(buf),
+ "%s unreachable - need to frag",
+ ipaddr_string(&dp->icmp_ip.ip_dst));
}
- }
break;
default:
@@ -371,54 +270,49 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
case ICMP_ROUTERADVERT:
- {
+ {
register const struct ih_rdiscovery *ihp;
register const struct id_rdiscovery *idp;
u_int lifetime, num, size;
- (void)snprintf(buf, sizeof(buf), "router advertisement");
+ (void)strcpy(buf, "router advertisement");
cp = buf + strlen(buf);
ihp = (struct ih_rdiscovery *)&dp->icmp_void;
TCHECK(*ihp);
- (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
+ (void)strcpy(cp, " lifetime ");
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
- if (lifetime < 60) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
- lifetime);
- } else if (lifetime < 60 * 60) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
+ if (lifetime < 60)
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u", lifetime);
+ else if (lifetime < 60 * 60)
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u:%02u",
lifetime / 60, lifetime % 60);
- } else {
- (void)snprintf(cp, sizeof(buf) - (cp - buf),
- "%u:%02u:%02u",
+ else
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u:%02u:%02u",
lifetime / 3600,
(lifetime % 3600) / 60,
lifetime % 60);
- }
cp = buf + strlen(buf);
num = ihp->ird_addrnum;
- (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num);
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), " %d:", num);
cp = buf + strlen(buf);
size = ihp->ird_addrsiz;
if (size != 2) {
- (void)snprintf(cp, sizeof(buf) - (cp - buf),
- " [size %d]", size);
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), " [size %d]", size);
break;
}
idp = (struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
TCHECK(*idp);
- (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
+ (void)snprintf(cp, sizeof(buf) - strlen(buf), " {%s %u}",
ipaddr_string(&idp->ird_addr),
EXTRACT_32BITS(&idp->ird_pref));
cp = buf + strlen(buf);
- ++idp;
}
- }
+ }
break;
case ICMP_TIMXCEED:
@@ -434,46 +328,26 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2)
break;
default:
- (void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
- dp->icmp_code);
+ (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", dp->icmp_code);
break;
}
break;
case ICMP_PARAMPROB:
if (dp->icmp_code)
- (void)snprintf(buf, sizeof(buf),
- "parameter problem - code %d", dp->icmp_code);
+ (void)snprintf(buf, sizeof(buf), "parameter problem - code %d",
+ dp->icmp_code);
else {
TCHECK(dp->icmp_pptr);
- (void)snprintf(buf, sizeof(buf),
- "parameter problem - octet %d", dp->icmp_pptr);
+ (void)snprintf(buf, sizeof(buf), "parameter problem - octet %d",
+ dp->icmp_pptr);
}
break;
case ICMP_MASKREPLY:
TCHECK(dp->icmp_mask);
(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
- (unsigned)ntohl(dp->icmp_mask));
- break;
-
- case ICMP_TSTAMP:
- TCHECK(dp->icmp_seq);
- (void)snprintf(buf, sizeof(buf),
- "time stamp query id %u seq %u",
- (unsigned)ntohs(dp->icmp_id),
- (unsigned)ntohs(dp->icmp_seq));
- break;
-
- case ICMP_TSTAMPREPLY:
- TCHECK(dp->icmp_ttime);
- (void)snprintf(buf, sizeof(buf),
- "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx",
- (unsigned)ntohs(dp->icmp_id),
- (unsigned)ntohs(dp->icmp_seq),
- (unsigned long)ntohl(dp->icmp_otime),
- (unsigned long)ntohl(dp->icmp_rtime),
- (unsigned long)ntohl(dp->icmp_ttime));
+ (u_int32_t)ntohl(dp->icmp_mask));
break;
default:
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 869c9da..fe06efd 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.92 2001/01/02 23:00:01 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.79 1999/12/22 06:27:21 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,7 +35,16 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,13 +54,172 @@ static const char rcsid[] =
#include "interface.h"
#include "extract.h" /* must come after interface.h */
-#include "ip.h"
-
/* Compatibility */
#ifndef IPPROTO_ND
#define IPPROTO_ND 77
#endif
+#ifndef IN_CLASSD
+#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
+#endif
+
+/* (following from ipmulti/mrouted/prune.h) */
+
+/*
+ * The packet format for a traceroute request.
+ */
+struct tr_query {
+ u_int tr_src; /* traceroute source */
+ u_int tr_dst; /* traceroute destination */
+ u_int tr_raddr; /* traceroute response address */
+ u_int tr_rttlqid; /* response ttl and qid */
+};
+
+#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
+#define TR_GETQID(x) ((x) & 0x00ffffff)
+
+/*
+ * Traceroute response format. A traceroute response has a tr_query at the
+ * beginning, followed by one tr_resp for each hop taken.
+ */
+struct tr_resp {
+ u_int tr_qarr; /* query arrival time */
+ u_int tr_inaddr; /* incoming interface address */
+ u_int tr_outaddr; /* outgoing interface address */
+ u_int tr_rmtaddr; /* parent address in source tree */
+ u_int tr_vifin; /* input packet count on interface */
+ u_int tr_vifout; /* output packet count on interface */
+ u_int tr_pktcnt; /* total incoming packets for src-grp */
+ u_char tr_rproto; /* routing proto deployed on router */
+ u_char tr_fttl; /* ttl required to forward on outvif */
+ u_char tr_smask; /* subnet mask for src addr */
+ u_char tr_rflags; /* forwarding error codes */
+};
+
+/* defs within mtrace */
+#define TR_QUERY 1
+#define TR_RESP 2
+
+/* fields for tr_rflags (forwarding error codes) */
+#define TR_NO_ERR 0
+#define TR_WRONG_IF 1
+#define TR_PRUNED 2
+#define TR_OPRUNED 3
+#define TR_SCOPED 4
+#define TR_NO_RTE 5
+#define TR_NO_FWD 7
+#define TR_NO_SPACE 0x81
+#define TR_OLD_ROUTER 0x82
+
+/* fields for tr_rproto (routing protocol) */
+#define TR_PROTO_DVMRP 1
+#define TR_PROTO_MOSPF 2
+#define TR_PROTO_PIM 3
+#define TR_PROTO_CBT 4
+
+static void print_mtrace(register const u_char *bp, register u_int len)
+{
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
+
+ printf("mtrace %lu: %s to %s reply-to %s",
+ (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
+ ipaddr_string(&tr->tr_raddr));
+ if (IN_CLASSD(ntohl(tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+}
+
+static void print_mresp(register const u_char *bp, register u_int len)
+{
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
+
+ printf("mresp %lu: %s to %s reply-to %s",
+ (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
+ ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
+ ipaddr_string(&tr->tr_raddr));
+ if (IN_CLASSD(ntohl(tr->tr_raddr)))
+ printf(" with-ttl %d", TR_GETTTL(ntohl(tr->tr_rttlqid)));
+}
+
+static void
+igmp_print(register const u_char *bp, register u_int len,
+ register const u_char *bp2)
+{
+ register const struct ip *ip;
+
+ ip = (const struct ip *)bp2;
+ (void)printf("%s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+
+ if (qflag) {
+ (void)printf("igmp");
+ return;
+ }
+
+ TCHECK2(bp[0], 8);
+ switch (bp[0]) {
+ case 0x11:
+ (void)printf("igmp %s query", bp[1] ? "v2" : "v1");
+ if (bp[1] && bp[1] != 100)
+ (void)printf(" [intvl %d]", bp[1]);
+ (void)printf("igmp query");
+ if (EXTRACT_32BITS(&bp[4]))
+ (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
+ if (len != 8)
+ (void)printf(" [len %d]", len);
+ break;
+ case 0x12:
+ case 0x16:
+ (void)printf("igmp %s report %s",
+ (bp[0] & 0x0f) == 6 ? "v2" : "v1",
+ ipaddr_string(&bp[4]));
+ if (len != 8)
+ (void)printf(" [len %d]", len);
+ if (bp[1])
+ (void)printf(" [b1=0x%x]", bp[1]);
+ break;
+ case 0x17:
+ (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ if (len != 8)
+ (void)printf(" [len %d]", len);
+ if (bp[1])
+ (void)printf(" [b1=0x%x]", bp[1]);
+ break;
+ case 0x13:
+ (void)printf("igmp dvmrp");
+ if (len < 8)
+ (void)printf(" [len %d]", len);
+ else
+ dvmrp_print(bp, len);
+ break;
+ case 0x14:
+ (void)printf("igmp pimv1");
+ pimv1_print(bp, len);
+ break;
+ case 0x1e:
+ print_mresp(bp, len);
+ break;
+ case 0x1f:
+ print_mtrace(bp, len);
+ break;
+ default:
+ (void)printf("igmp-%d", bp[0] & 0xf);
+ if (bp[1])
+ (void)printf(" [b1=0x%02x]", bp[1]);
+ break;
+ }
+
+ if (vflag && TTEST2(bp[0], len)) {
+ /* Check the IGMP checksum */
+ if (in_cksum((const u_short*)bp, len, 0))
+ printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
+ }
+ return;
+trunc:
+ fputs("[|igmp]", stdout);
+}
+
/*
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
@@ -142,15 +312,7 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += len, length -= len) {
int tt = *cp;
- if (tt == IPOPT_NOP || tt == IPOPT_EOL)
- len = 1;
- else {
- if (&cp[1] >= snapend) {
- printf("[|ip]");
- return;
- }
- len = cp[1];
- }
+ len = (tt == IPOPT_NOP || tt == IPOPT_EOL) ? 1 : cp[1];
if (len <= 0) {
printf("[|ip op len %d]", len);
return;
@@ -293,11 +455,7 @@ ip_print(register const u_char *bp, register u_int length)
(void)printf("truncated-ip %d", length);
return;
}
- hlen = IP_HL(ip) * 4;
- if (hlen < sizeof (struct ip)) {
- (void)printf("bad-hlen %d", hlen);
- return;
- }
+ hlen = ip->ip_hl * 4;
len = ntohs(ip->ip_len);
if (length < len)
@@ -363,11 +521,11 @@ again:
}
case IPPROTO_TCP:
- tcp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
+ tcp_print(cp, len, (const u_char *)ip);
break;
case IPPROTO_UDP:
- udp_print(cp, len, (const u_char *)ip, (off &~ 0x6000));
+ udp_print(cp, len, (const u_char *)ip);
break;
case IPPROTO_ICMP:
@@ -481,17 +639,6 @@ again:
pim_print(cp, len);
break;
-#ifndef IPPROTO_VRRP
-#define IPPROTO_VRRP 112
-#endif
- case IPPROTO_VRRP:
- if (vflag)
- (void)printf("vrrp %s > %s: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
- vrrp_print(cp, len, ip->ip_ttl);
- break;
-
default:
#if 0
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
@@ -561,8 +708,6 @@ again:
(void)printf("%sid %d", sep, (int)ntohs(ip->ip_id));
sep = ", ";
}
- (void)printf("%slen %d", sep, (int)ntohs(ip->ip_len));
- sep = ", ";
if ((u_char *)ip + hlen <= snapend) {
sum = in_cksum((const u_short *)ip, hlen, 0);
if (sum != 0) {
@@ -578,29 +723,3 @@ again:
printf(")");
}
}
-
-void
-ipN_print(register const u_char *bp, register u_int length)
-{
- struct ip *ip, hdr;
-
- ip = (struct ip *)bp;
- if (length < 4) {
- (void)printf("truncated-ip %d", length);
- return;
- }
- memcpy (&hdr, (char *)ip, 4);
- switch (IP_V(&hdr)) {
- case 4:
- ip_print (bp, length);
- return;
-#ifdef INET6
- case 6:
- ip6_print (bp, length);
- return;
-#endif
- default:
- (void)printf("unknown ip %d", IP_V(&hdr));
- return;
- }
-}
diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c
index 71cd41c..04dee43 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.16 2000/11/17 19:08:15 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.2.2.1 2000/01/11 06:58:25 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,16 +38,23 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <stdio.h>
+#ifdef __STDC__
#include <stdlib.h>
+#endif
#include <unistd.h>
-#include <string.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ip6.h"
+#include <netinet/ip6.h>
/*
* print an IP6 datagram.
@@ -54,30 +63,29 @@ void
ip6_print(register const u_char *bp, register int length)
{
register const struct ip6_hdr *ip6;
- register int advance;
+ register int hlen;
register int len;
register const u_char *cp;
int nh;
- int fragmented = 0;
u_int flow;
ip6 = (const struct ip6_hdr *)bp;
-#ifdef LBL_ALIGN
+#ifdef TCPDUMP_ALIGN
/*
- * The IP6 header is not 16-byte aligned, so copy into abuf.
+ * The IP header is not word aligned, so copy into abuf.
* This will never happen with BPF. It does happen raw packet
* dumps from -r.
*/
- if ((u_long)ip6 & 15) {
+ if ((int)ip & (sizeof(long)-1)) {
static u_char *abuf;
- if (abuf == NULL)
- abuf = malloc(snaplen);
- memcpy(abuf, ip6, min(length, snaplen));
- snapend += abuf - (u_char *)ip6;
+ if (abuf == 0)
+ abuf = (u_char *)malloc(snaplen);
+ bcopy((char *)ip, (char *)abuf, min(length, snaplen));
+ snapend += abuf - (u_char *)ip;
packetp = abuf;
- ip6 = (struct ip6_hdr *)abuf;
+ ip = (struct ip6_hdr *)abuf;
}
#endif
if ((u_char *)(ip6 + 1) > snapend) {
@@ -88,17 +96,17 @@ ip6_print(register const u_char *bp, register int length)
(void)printf("truncated-ip6 %d", length);
return;
}
- advance = sizeof(struct ip6_hdr);
+ hlen = sizeof(struct ip6_hdr);
len = ntohs(ip6->ip6_plen);
- if (length < len + advance)
+ if (length < len + hlen)
(void)printf("truncated-ip6 - %d bytes missing!",
- len + advance - length);
+ len + hlen - length);
cp = (const u_char *)ip6;
nh = ip6->ip6_nxt;
while (cp < snapend) {
- cp += advance;
+ cp += hlen;
if (cp == (u_char *)(ip6 + 1)
&& nh != IPPROTO_TCP && nh != IPPROTO_UDP) {
@@ -108,43 +116,42 @@ ip6_print(register const u_char *bp, register int length)
switch (nh) {
case IPPROTO_HOPOPTS:
- advance = hbhopt_print(cp);
+ hlen = hbhopt_print(cp);
nh = *cp;
break;
case IPPROTO_DSTOPTS:
- advance = dstopt_print(cp);
+ hlen = dstopt_print(cp);
nh = *cp;
break;
case IPPROTO_FRAGMENT:
- advance = frag6_print(cp, (const u_char *)ip6);
- if (snapend <= cp + advance)
+ hlen = frag6_print(cp, (const u_char *)ip6);
+ if (snapend <= cp + hlen)
goto end;
nh = *cp;
- fragmented = 1;
break;
case IPPROTO_ROUTING:
- advance = rt6_print(cp, (const u_char *)ip6);
+ hlen = rt6_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_TCP:
tcp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
- (const u_char *)ip6, fragmented);
+ (const u_char *)ip6);
goto end;
case IPPROTO_UDP:
udp_print(cp, len + sizeof(struct ip6_hdr) - (cp - bp),
- (const u_char *)ip6, fragmented);
+ (const u_char *)ip6);
goto end;
case IPPROTO_ICMPV6:
icmp6_print(cp, (const u_char *)ip6);
goto end;
case IPPROTO_AH:
- advance = ah_print(cp, (const u_char *)ip6);
+ hlen = ah_print(cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_ESP:
{
int enh;
- advance = esp_print(cp, (const u_char *)ip6, &enh);
+ cp += esp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
@@ -156,16 +163,12 @@ ip6_print(register const u_char *bp, register int length)
case IPPROTO_IPCOMP:
{
int enh;
- advance = ipcomp_print(cp, (const u_char *)ip6, &enh);
+ cp += ipcomp_print(cp, (const u_char *)ip6, &enh);
if (enh < 0)
goto end;
nh = enh & 0xff;
break;
}
-
-#ifndef IPPROTO_PIM
-#define IPPROTO_PIM 103
-#endif
case IPPROTO_PIM:
pim_print(cp, len);
goto end;
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index 4925719..c178123 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.27 2000/09/29 04:58:41 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.22 1999/11/21 09:36:54 fenner Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,8 +38,16 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
-
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+
+#ifdef __STDC__
#include <stdlib.h>
+#endif
#include <stdio.h>
#include <string.h>
@@ -84,7 +94,7 @@ ipxaddr_string(u_int32_t net, const u_char *node)
{
static char line[256];
- snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x",
+ sprintf(line, "%x.%02x:%02x:%02x:%02x:%02x:%02x",
net, node[0], node[1], node[2], node[3], node[4], node[5]);
return line;
@@ -185,7 +195,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;
@@ -193,7 +203,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 aaf360a..399ec8b 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -19,11 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Original code by Matt Thomas, Digital Equipment Corporation
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.22 2000/10/11 04:04:33 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.16 1999/11/21 09:36:55 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,14 +36,20 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <net/ethernet.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
-#include "ether.h"
#include "extract.h"
#define NLPID_CLNS 129 /* 0x81 */
@@ -54,7 +62,7 @@ static const char rcsid[] =
* IS-IS is defined in ISO 10589. Look there for protocol definitions.
*/
-#define SYSTEM_ID_LEN ETHER_ADDR_LEN
+#define SYSTEM_ID_LEN sizeof(struct ether_addr)
#define ISIS_VERSION 1
#define PDU_TYPE_MASK 0x1F
#define PRIORITY_MASK 0x7F
@@ -109,9 +117,9 @@ struct isis_ptp_adjancey_values {
};
static struct isis_ptp_adjancey_values isis_ptp_adjancey_values[] = {
- { ISIS_PTP_ADJ_UP, "UP" },
- { ISIS_PTP_ADJ_INIT, "INIT" },
- { ISIS_PTP_ADJ_DOWN, "DOWN" }
+ ISIS_PTP_ADJ_UP, "UP",
+ ISIS_PTP_ADJ_INIT, "INIT",
+ ISIS_PTP_ADJ_DOWN, "DOWN"
};
struct isis_common_header {
@@ -258,6 +266,7 @@ esis_print(const u_char *p, u_int length)
const u_char *ep;
int li = p[1];
const struct esis_hdr *eh = (const struct esis_hdr *) &p[2];
+ u_char cksum[2];
u_char off[2];
if (length == 2) {
@@ -409,7 +418,7 @@ esis_print(const u_char *p, u_int length)
* Print out an NSAP.
*/
-static void
+void
print_nsap (register const u_char *cp, register int length)
{
int i;
@@ -435,13 +444,11 @@ isis_print (const u_char *p, u_int length)
{
struct isis_header *header;
struct isis_ptp_header *header_ptp;
- u_char pdu_type, max_area, priority, type, len, tmp, alen;
- const u_char *pptr, *tptr;
+ u_char pdu_type, max_area, priority, *pptr, type, len, *tptr, tmp, alen;
u_short packet_len, holding_time;
int i;
- header = (struct isis_header *)p;
- header_ptp = (struct isis_ptp_header *)header;
+ header_ptp = (struct isis_ptp_header *)header = (struct isis_header *)p;
printf("\n\t\t\t");
/*
@@ -467,7 +474,7 @@ isis_print (const u_char *p, u_int length)
(header->fixed_len != ISIS_PTP_HEADER_SIZE) &&
(header->fixed_len != L1_LS_PDU_HEADER_SIZE) &&
(header-> fixed_len != L1_COMPLETE_SEQ_PDU_HEADER_SIZE) ) {
- printf(" bogus fixed header length %u",
+ printf(" bogus fixed header length",
header->fixed_len);
return(0);
}
@@ -478,12 +485,12 @@ isis_print (const u_char *p, u_int length)
(pdu_type != L1_COMPLETE_SEQ_PDU) &&
(pdu_type != L2_COMPLETE_SEQ_PDU) ) {
printf(" PDU type (%d) not supported", pdu_type);
- return(0);
+ return;
}
if (header->pkt_version != ISIS_VERSION) {
printf(" version %d packet not supported", header->pkt_version);
- return(0);
+ return;
}
max_area = header->enc_max_area;
@@ -574,10 +581,10 @@ isis_print (const u_char *p, u_int length)
*/
if(pdu_type==PTP_IIH) {
packet_len -= ISIS_PTP_HEADER_SIZE;
- pptr = p + ISIS_PTP_HEADER_SIZE;
+ pptr = (char *)p + ISIS_PTP_HEADER_SIZE;
} else {
packet_len -= ISIS_HEADER_SIZE;
- pptr = p + ISIS_HEADER_SIZE;
+ pptr = (char *)p + ISIS_HEADER_SIZE;
}
while (packet_len >= 2) {
if (pptr >= snapend) {
@@ -610,10 +617,10 @@ isis_print (const u_char *p, u_int length)
printf("\n\t\t\t neighbor addresses");
tmp = len;
tptr = pptr;
- while (tmp >= ETHER_ADDR_LEN) {
+ while (tmp >= sizeof(struct ether_addr)) {
printf("\n\t\t\t %s", etheraddr_string(tptr));
- tmp -= ETHER_ADDR_LEN;
- tptr += ETHER_ADDR_LEN;
+ tmp -= sizeof(struct ether_addr);
+ tptr += sizeof(struct ether_addr);
}
break;
case TLV_PADDING:
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index 988fdfe..3216f4d 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.32 2000/12/18 07:55:36 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.27 1999/12/22 06:27:21 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -64,11 +66,10 @@ static struct tok cmd2str[] = {
*/
int
llc_print(const u_char *p, u_int length, u_int caplen,
- const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
+ const u_char *esrc, const u_char *edst)
{
struct llc llc;
register u_short et;
- u_int16_t control;
register int ret;
if (caplen < 3) {
@@ -84,61 +85,13 @@ llc_print(const u_char *p, u_int length, u_int caplen,
ipx_print(p, length);
return (1);
}
-
- /* Cisco Discovery Protocol - SNAP & ether type 0x2000 */
- if(llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP &&
- llc.llcui == LLC_UI &&
- llc.ethertype[0] == 0x20 && llc.ethertype[1] == 0x00 ) {
- cdp_print( p, length, caplen, esrc, edst);
- return (1);
- }
-
- if (llc.ssap == LLCSAP_8021D && llc.dsap == LLCSAP_8021D) {
- stp_print(p, length);
- return (1);
- }
- if (llc.ssap == 0xf0 && llc.dsap == 0xf0
- && (!(llc.llcu & LLC_S_FMT) || llc.llcu == LLC_U_FMT)) {
+ if (llc.ssap == 0xf0 && llc.dsap == 0xf0) {
/*
* we don't actually have a full netbeui parser yet, but the
* smb parser can handle many smb-in-netbeui packets, which
* is very useful, so we call that
- *
- * We don't call it for S frames, however, just I frames
- * (which are frames that don't have the low-order bit,
- * LLC_S_FMT, set in the first byte of the control field)
- * and UI frames (whose control field is just 3, LLC_U_FMT).
*/
-
- /*
- * Skip the DSAP and LSAP.
- */
- p += 2;
- length -= 2;
- caplen -= 2;
-
- /*
- * OK, what type of LLC frame is this? The length
- * of the control field depends on that - I frames
- * have a two-byte control field, and U frames have
- * a one-byte control field.
- */
- if (llc.llcu == LLC_U_FMT) {
- control = llc.llcu;
- p += 1;
- length -= 1;
- caplen -= 1;
- } else {
- /*
- * The control field in I and S frames is
- * little-endian.
- */
- control = EXTRACT_LE_16BITS(&llc.llcu);
- p += 2;
- length -= 2;
- caplen -= 2;
- }
- netbeui_print(control, p, p + min(caplen, length));
+ netbeui_print(p + 2, p + min(caplen, length));
return (1);
}
if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
@@ -163,8 +116,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
/* This is an encapsulated Ethernet packet */
et = EXTRACT_16BITS(&llc.ethertype[0]);
- ret = ether_encap_print(et, p, length, caplen,
- extracted_ethertype);
+ ret = ether_encap_print(et, p, length, caplen);
if (ret)
return (ret);
}
@@ -191,12 +143,9 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
if ((llc.llcu & LLC_U_FMT) == LLC_U_FMT) {
- u_int16_t cmd;
const char *m;
char f;
-
- cmd = LLC_U_CMD(llc.llcu);
- m = tok2str(cmd2str, "%02x", cmd);
+ m = tok2str(cmd2str, "%02x", LLC_U_CMD(llc.llcu));
switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
@@ -220,38 +169,35 @@ llc_print(const u_char *p, u_int length, u_int caplen,
}
}
- if (cmd == LLC_UI && f == 'C') {
+ if (!strcmp(m,"ui") && f=='C') {
/*
* we don't have a proper ipx decoder yet, but there
* is a partial one in the smb code
*/
ipx_netbios_print(p,p+min(caplen,length));
}
+
} else {
char f;
-
- /*
- * The control field in I and S frames is little-endian.
- */
- control = EXTRACT_LE_16BITS(&llc.llcu);
- switch ((llc.ssap & LLC_GSAP) | (control & LLC_IS_POLL)) {
+ llc.llcis = ntohs(llc.llcis);
+ switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
case 0: f = 'C'; break;
case LLC_GSAP: f = 'R'; break;
- case LLC_IS_POLL: f = 'P'; break;
- case LLC_GSAP|LLC_IS_POLL: f = 'F'; break;
+ case LLC_U_POLL: f = 'P'; break;
+ case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
default: f = '?'; break;
}
- if ((control & LLC_S_FMT) == LLC_S_FMT) {
+ if ((llc.llcu & LLC_S_FMT) == LLC_S_FMT) {
static char *llc_s[] = { "rr", "rej", "rnr", "03" };
(void)printf("%s (r=%d,%c)",
- llc_s[LLC_S_CMD(control)],
- LLC_IS_NR(control),
+ llc_s[LLC_S_CMD(llc.llcis)],
+ LLC_IS_NR(llc.llcis),
f);
} else {
(void)printf("I (s=%d,r=%d,%c)",
- LLC_I_NS(control),
- LLC_IS_NR(control),
+ LLC_I_NS(llc.llcis),
+ LLC_IS_NR(llc.llcis),
f);
}
p += 4;
@@ -259,5 +205,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
caplen -= 4;
}
(void)printf(" len=%d", length);
+ if (caplen > 0 && !qflag) {
+ default_print_unaligned(p, caplen);
+ }
return(1);
}
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index b520160..bfaf438 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -21,21 +21,20 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.87 2000/10/07 05:53:12 itojun Exp $ (LBL)";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+ "@(#) $Header: print-nfs.c,v 1.65 97/08/17 13:24:22 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
-struct mbuf;
-struct rtentry;
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <rpc/rpc.h>
@@ -46,24 +45,19 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
#include "nfs.h"
#include "nfsfh.h"
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
-
-static void nfs_printfh(const u_int32_t *, const u_int);
-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 nfs_printfh(const u_int32_t *, const int);
+static void xid_map_enter(const struct rpc_msg *, const struct ip *);
+static int32_t xid_map_find(const struct rpc_msg *, const struct ip *, u_int32_t *,
+ u_int32_t *);
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 *);
+
+static int nfserr; /* true if we error rather than trunc */
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
@@ -97,60 +91,10 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NOOP
};
-/*
- * NFS V2 and V3 status values.
- *
- * Some of these come from the RFCs for NFS V2 and V3, with the message
- * strings taken from the FreeBSD C library "errlst.c".
- *
- * Others are errors that are not in the RFC but that I suspect some
- * NFS servers could return; the values are FreeBSD errno values, as
- * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
- * was primarily BSD-derived.
- */
-static struct tok status2str[] = {
- { 1, "Operation not permitted" }, /* EPERM */
- { 2, "No such file or directory" }, /* ENOENT */
- { 5, "Input/output error" }, /* EIO */
- { 6, "Device not configured" }, /* ENXIO */
- { 11, "Resource deadlock avoided" }, /* EDEADLK */
- { 12, "Cannot allocate memory" }, /* ENOMEM */
- { 13, "Permission denied" }, /* EACCES */
- { 17, "File exists" }, /* EEXIST */
- { 18, "Cross-device link" }, /* EXDEV */
- { 19, "Operation not supported by device" }, /* ENODEV */
- { 20, "Not a directory" }, /* ENOTDIR */
- { 21, "Is a directory" }, /* EISDIR */
- { 22, "Invalid argument" }, /* EINVAL */
- { 26, "Text file busy" }, /* ETXTBSY */
- { 27, "File too large" }, /* EFBIG */
- { 28, "No space left on device" }, /* ENOSPC */
- { 30, "Read-only file system" }, /* EROFS */
- { 31, "Too many links" }, /* EMLINK */
- { 45, "Operation not supported" }, /* EOPNOTSUPP */
- { 62, "Too many levels of symbolic links" }, /* ELOOP */
- { 63, "File name too long" }, /* ENAMETOOLONG */
- { 66, "Directory not empty" }, /* ENOTEMPTY */
- { 69, "Disc quota exceeded" }, /* EDQUOT */
- { 70, "Stale NFS file handle" }, /* ESTALE */
- { 71, "Too many levels of remote in path" }, /* EREMOTE */
- { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
- { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
- { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
- { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
- { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
- { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
- { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
- { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
- { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
- { 0, NULL }
-};
-
-static struct tok nfsv3_writemodes[] = {
- { 0, "unstable" },
- { 1, "datasync" },
- { 2, "filesync" },
- { 0, NULL }
+const char *nfsv3_writemodes[NFSV3WRITE_NMODES] = {
+ "unstable",
+ "datasync",
+ "filesync"
};
static struct tok type2str[] = {
@@ -177,7 +121,11 @@ static struct tok type2str[] = {
#define SIGNED 1
#define HEX 2
-static int print_int64(const u_int32_t *dp, int how)
+#define INT64_FORMAT "%qd"
+#define U_INT64_FORMAT "%qu"
+#define HEX_INT64_FORMAT "%qx"
+
+int print_int64(const u_int32_t *dp, int how)
{
#ifdef INT64_FORMAT
u_int64_t res;
@@ -197,108 +145,77 @@ static int print_int64(const u_int32_t *dp, int how)
return (0);
}
#else
- switch (how) {
- case SIGNED:
- case UNSIGNED:
- case HEX:
- printf("0x%x%08x", (u_int32_t)ntohl(dp[0]),
- (u_int32_t)ntohl(dp[1]));
- break;
- default:
- return (0);
- }
+ /*
+ * XXX - throw upper 32 bits away.
+ * Could also go for hex: printf("0x%x%x", dp[0], dp[1]);
+ */
+ if (how == SIGNED)
+ printf("%ld", (int)dp[1]);
+ else
+ printf("%lu", (unsigned int)dp[1]);
#endif
return 1;
}
-static void
-print_nfsaddr(const u_char *bp, const char *s, const char *d)
-{
- struct ip *ip;
-#ifdef INET6
- struct ip6_hdr *ip6;
- char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
-#else
-#ifndef INET_ADDRSTRLEN
-#define INET_ADDRSTRLEN 16
-#endif
- char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN];
-#endif
-
- srcaddr[0] = dstaddr[0] = '\0';
- switch (IP_V((struct ip *)bp)) {
- case 4:
- ip = (struct ip *)bp;
- strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
- strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
- break;
-#ifdef INET6
- case 6:
- ip6 = (struct ip6_hdr *)bp;
- strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
- sizeof(srcaddr));
- strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
- sizeof(dstaddr));
- break;
-#endif
- default:
- strlcpy(srcaddr, "?", sizeof(srcaddr));
- strlcpy(dstaddr, "?", sizeof(dstaddr));
- break;
- }
-
- (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
-}
-
static const u_int32_t *
parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
{
- TCHECK(dp[0]);
+ register const u_int32_t *ep = (u_int32_t *)snapend;
+
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_modeset = ntohl(*dp++))) {
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
sa3->sa_mode = ntohl(*dp++);
}
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_uidset = ntohl(*dp++))) {
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
sa3->sa_uid = ntohl(*dp++);
}
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_gidset = ntohl(*dp++))) {
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
sa3->sa_gid = ntohl(*dp++);
}
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_sizeset = ntohl(*dp++))) {
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
sa3->sa_size = ntohl(*dp++);
}
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ if (dp + 2 > ep)
+ return (NULL);
sa3->sa_atime.nfsv3_sec = ntohl(*dp++);
sa3->sa_atime.nfsv3_nsec = ntohl(*dp++);
}
- TCHECK(dp[0]);
+ if (dp + 1 > ep)
+ return (NULL);
if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ if (dp + 2 > ep)
+ return (NULL);
sa3->sa_mtime.nfsv3_sec = ntohl(*dp++);
sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++);
}
return dp;
-trunc:
- return NULL;
}
-static int nfserr; /* true if we error rather than trunc */
-
-static void
+void
print_sattr3(const struct nfsv3_sattr *sa3, int verbose)
{
if (sa3->sa_modeset)
@@ -322,37 +239,41 @@ nfsreply_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
+ register const struct ip *ip;
u_int32_t proc, vers;
- char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
-
- if (!nflag) {
- strlcpy(srcid, "nfs", sizeof(srcid));
- snprintf(dstid, sizeof(dstid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
- } else {
- snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
- snprintf(dstid, sizeof(dstid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
- }
- print_nfsaddr(bp2, srcid, dstid);
- (void)printf("reply %s %d",
- ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
- "ok":"ERR",
+ ip = (const struct ip *)bp2;
+
+ if (!nflag)
+ (void)printf("%s.nfs > %s.%u: reply %s %d",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
+ "ok":"ERR",
+ length);
+ else
+ (void)printf("%s.%u > %s.%u: reply %s %d",
+ ipaddr_string(&ip->ip_src),
+ NFS_PORT,
+ ipaddr_string(&ip->ip_dst),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
+ "ok":"ERR",
length);
- if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
+ if (xid_map_find(rp, ip, &proc, &vers) >= 0)
interp_reply(rp, proc, vers, length);
}
/*
* Return a pointer to the first file handle in the packet.
- * If the packet was truncated, return 0.
+ * If the packet was truncated, return NULL.
*/
static const u_int32_t *
-parsereq(register const struct rpc_msg *rp, register u_int length)
+parsereq(register const struct rpc_msg *rp, register int length)
{
register const u_int32_t *dp;
register u_int len;
@@ -379,7 +300,7 @@ trunc:
/*
* Print out an NFS file handle and return a pointer to following word.
- * If packet was truncated, return 0.
+ * If packet was truncated, return NULL.
*/
static const u_int32_t *
parsefh(register const u_int32_t *dp, int v3)
@@ -403,7 +324,7 @@ trunc:
/*
* Print out a file name and return pointer to 32-bit word past it.
- * If packet was truncated, return 0.
+ * If packet was truncated, return NULL.
*/
static const u_int32_t *
parsefn(register const u_int32_t *dp)
@@ -412,31 +333,30 @@ parsefn(register const u_int32_t *dp)
register const u_char *cp;
/* Bail if we don't have the string length */
- TCHECK(*dp);
+ if ((u_char *)dp > snapend - sizeof(*dp))
+ return (NULL);
/* Fetch string length; convert to host order */
len = *dp++;
NTOHL(len);
- TCHECK2(*dp, ((len + 3) & ~3));
-
cp = (u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
+ if ((u_char *)dp > snapend)
+ return (NULL);
/* XXX seems like we should be checking the length */
putchar('"');
(void) fn_printn(cp, len, NULL);
putchar('"');
return (dp);
-trunc:
- return NULL;
}
/*
* Print out file handle and file name.
* Return pointer to 32-bit word past file name.
- * If packet was truncated (or there was some other error), return 0.
+ * If packet was truncated (or there was some other error), return NULL.
*/
static const u_int32_t *
parsefhn(register const u_int32_t *dp, int v3)
@@ -453,28 +373,30 @@ nfsreq_print(register const u_char *bp, u_int length,
register const u_char *bp2)
{
register const struct rpc_msg *rp;
+ register const struct ip *ip;
register const u_int32_t *dp;
- nfs_type type;
- int v3;
- u_int32_t proc;
+ nfstype type;
+ int proc, v3;
struct nfsv3_sattr sa3;
- char srcid[20], dstid[20]; /*fits 32bit*/
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
- if (!nflag) {
- snprintf(srcid, sizeof(srcid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
- strlcpy(dstid, "nfs", sizeof(dstid));
- } else {
- snprintf(srcid, sizeof(srcid), "%u",
- (u_int32_t)ntohl(rp->rm_xid));
- snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
- }
- print_nfsaddr(bp2, srcid, dstid);
- (void)printf("%d", length);
+ ip = (const struct ip *)bp2;
+ if (!nflag)
+ (void)printf("%s.%u > %s.nfs: %d",
+ ipaddr_string(&ip->ip_src),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ipaddr_string(&ip->ip_dst),
+ length);
+ else
+ (void)printf("%s.%u > %s.%u: %d",
+ ipaddr_string(&ip->ip_src),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ipaddr_string(&ip->ip_dst),
+ NFS_PORT,
+ length);
- xid_map_enter(rp, bp2); /* record proc number for later on */
+ xid_map_enter(rp, ip); /* record proc number for later on */
v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3);
proc = ntohl(rp->rm_call.cb_proc);
@@ -492,22 +414,19 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_GETATTR:
printf(" getattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_SETATTR:
printf(" setattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_LOOKUP:
printf(" lookup");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
@@ -515,16 +434,15 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" access");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[0]);
- printf(" %04x", (u_int32_t)ntohl(dp[0]));
+ TCHECK(*dp);
+ printf(" %04lx", ntohl(dp[0]));
return;
}
break;
case NFSPROC_READLINK:
printf(" readlink");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
@@ -533,15 +451,13 @@ 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 bytes @ ",
- (u_int32_t) ntohl(dp[2]));
+ TCHECK2(*dp, 3 * sizeof(*dp));
+ printf(" %lu bytes @ ", ntohl(dp[2]));
print_int64(dp, UNSIGNED);
} else {
- TCHECK(dp[1]);
- printf(" %u bytes @ %u",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ TCHECK2(*dp, 2 * sizeof(*dp));
+ printf(" %lu bytes @ %lu",
+ ntohl(dp[1]), ntohl(dp[0]));
}
return;
}
@@ -552,24 +468,20 @@ 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[4]);
- printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[4]));
+ TCHECK2(*dp, 3 * sizeof(*dp));
+ printf(" %lu bytes @ ", ntohl(dp[4]));
print_int64(dp, UNSIGNED);
if (vflag) {
dp += 3;
- TCHECK(dp[0]);
+ TCHECK2(*dp, sizeof(*dp));
printf(" <%s>",
- tok2str(nfsv3_writemodes,
- NULL, ntohl(*dp)));
+ nfsv3_writemodes[ntohl(*dp)]);
}
} else {
- TCHECK(dp[3]);
- printf(" %u (%u) bytes @ %u (%u)",
- (u_int32_t)ntohl(dp[3]),
- (u_int32_t)ntohl(dp[2]),
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ TCHECK2(*dp, 4 * sizeof(*dp));
+ printf(" %lu (%lu) bytes @ %lu (%lu)",
+ ntohl(dp[3]), ntohl(dp[2]),
+ ntohl(dp[1]), ntohl(dp[0]));
}
return;
}
@@ -577,25 +489,24 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_CREATE:
printf(" create");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_MKDIR:
printf(" mkdir");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_SYMLINK:
printf(" symlink");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- fputs(" ->", stdout);
- if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefhn(dp, v3)) != NULL) {
+ fputs(" -> ", stdout);
+ if (v3 && (dp = parse_sattr3(dp, &sa3)) == NULL)
break;
- if (parsefn(dp) == 0)
+ if (parsefn(dp) == NULL)
break;
if (v3 && vflag)
print_sattr3(&sa3, vflag);
@@ -605,18 +516,18 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_MKNOD:
printf(" mknod");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- TCHECK(*dp);
- type = (nfs_type)ntohl(*dp++);
- if ((dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefhn(dp, v3)) != NULL) {
+ if (dp + 1 > (u_int32_t *)snapend)
+ break;
+ type = (nfstype)ntohl(*dp++);
+ if ((dp = parse_sattr3(dp, &sa3)) == NULL)
break;
printf(" %s", tok2str(type2str, "unk-ft %d", type));
if (vflag && (type == NFCHR || type == NFBLK)) {
- TCHECK(dp[1]);
- printf(" %u/%u",
- (u_int32_t)ntohl(dp[0]),
- (u_int32_t)ntohl(dp[1]));
+ if (dp + 2 > (u_int32_t *)snapend)
+ break;
+ printf(" %lu/%lu", ntohl(dp[0]), ntohl(dp[1]));
dp += 2;
}
if (vflag)
@@ -627,15 +538,13 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_REMOVE:
printf(" remove");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_RMDIR:
printf(" rmdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
@@ -664,26 +573,24 @@ 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[4]);
+ TCHECK2(*dp, 20);
/*
* We shouldn't really try to interpret the
* offset cookie here.
*/
- printf(" %u bytes @ ",
- (u_int32_t) ntohl(dp[4]));
+ printf(" %lu bytes @ ", ntohl(dp[4]));
print_int64(dp, SIGNED);
if (vflag)
printf(" verf %08x%08x", dp[2],
dp[3]);
} else {
- TCHECK(dp[1]);
+ TCHECK2(*dp, 2 * sizeof(*dp));
/*
* Print the offset as signed, since -1 is
* common, but offsets > 2^31 aren't.
*/
- printf(" %u bytes @ %d",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ printf(" %lu bytes @ %ld", ntohl(dp[1]),
+ ntohl(dp[0]));
}
return;
}
@@ -693,24 +600,23 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" readdirplus");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[4]);
+ TCHECK2(*dp, 20);
/*
* We don't try to interpret the offset
* cookie here.
*/
- printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4]));
+ printf(" %lu bytes @ ", ntohl(dp[4]));
print_int64(dp, SIGNED);
if (vflag)
- printf(" max %u verf %08x%08x",
- (u_int32_t) ntohl(dp[5]), dp[2], dp[3]);
+ printf(" max %lu verf %08x%08x",
+ ntohl(dp[5]), dp[2], dp[3]);
return;
}
break;
case NFSPROC_FSSTAT:
printf(" fsstat");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
@@ -726,17 +632,16 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" commit");
if ((dp = parsereq(rp, length)) != NULL &&
(dp = parsefh(dp, v3)) != NULL) {
- printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2]));
+ printf(" %lu bytes @ ", ntohl(dp[2]));
print_int64(dp, UNSIGNED);
return;
}
break;
default:
- printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc));
+ printf(" proc-%lu", ntohl(rp->rm_call.cb_proc));
return;
}
-
trunc:
if (!nfserr)
fputs(" [|nfs]", stdout);
@@ -752,13 +657,13 @@ trunc:
* additional hacking on the parser code.
*/
static void
-nfs_printfh(register const u_int32_t *dp, const u_int len)
+nfs_printfh(register const u_int32_t *dp, const int len)
{
my_fsid fsid;
ino_t ino;
char *sfsname = NULL;
- Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0);
+ Parse_fh((caddr_t *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
if (sfsname) {
/* file system ID is ASCII, not numeric, for this server OS */
@@ -766,23 +671,16 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
/* Make sure string is null-terminated */
strncpy(temp, sfsname, NFSX_V3FHMAX);
- temp[sizeof(temp) - 1] = '\0';
/* Remove trailing spaces */
sfsname = strchr(temp, ' ');
if (sfsname)
*sfsname = 0;
- (void)printf(" fh %s/", temp);
+ (void)printf(" fh %s/%u", temp, (u_int32_t)ino);
} else {
- (void)printf(" fh %d,%d/",
- fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
+ (void)printf(" fh %u,%u/%u",
+ fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor, (u_int32_t)ino);
}
-
- if(fsid.Fsid_dev.Minor == 257 && uflag)
- /* Print the undecoded handle */
- (void)printf("%s", fsid.Opaque_Handle);
- else
- (void)printf("%ld", (long) ino);
}
/*
@@ -792,17 +690,11 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
*/
struct xid_map_entry {
- u_int32_t xid; /* transaction ID (net order) */
- int ipver; /* IP version (4 or 6) */
-#ifdef INET6
- struct in6_addr client; /* client IP address (net order) */
- struct in6_addr server; /* server IP address (net order) */
-#else
+ u_int32_t xid; /* transaction ID (net order) */
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
-#endif
- u_int32_t proc; /* call proc number (host order) */
- u_int32_t vers; /* program version (host order) */
+ u_int32_t proc; /* call proc number (host order) */
+ u_int32_t vers; /* program version (host order) */
};
/*
@@ -819,45 +711,18 @@ int xid_map_next = 0;
int xid_map_hint = 0;
static void
-xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
+xid_map_enter(const struct rpc_msg *rp, const struct ip *ip)
{
- struct ip *ip = NULL;
-#ifdef INET6
- struct ip6_hdr *ip6 = NULL;
-#endif
struct xid_map_entry *xmep;
- switch (IP_V((struct ip *)bp)) {
- case 4:
- ip = (struct ip *)bp;
- break;
-#ifdef INET6
- case 6:
- ip6 = (struct ip6_hdr *)bp;
- break;
-#endif
- default:
- return;
- }
-
xmep = &xid_map[xid_map_next];
if (++xid_map_next >= XIDMAPSIZE)
xid_map_next = 0;
xmep->xid = rp->rm_xid;
- if (ip) {
- xmep->ipver = 4;
- memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
- memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
- }
-#ifdef INET6
- else if (ip6) {
- xmep->ipver = 6;
- memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
- memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
- }
-#endif
+ xmep->client = ip->ip_src;
+ xmep->server = ip->ip_dst;
xmep->proc = ntohl(rp->rm_call.cb_proc);
xmep->vers = ntohl(rp->rm_call.cb_vers);
}
@@ -867,62 +732,33 @@ xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
* version in vers return, or returns -1 on failure
*/
static int
-xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
+xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc,
u_int32_t *vers)
{
int i;
struct xid_map_entry *xmep;
u_int32_t xid = rp->rm_xid;
- struct ip *ip = (struct ip *)bp;
-#ifdef INET6
- struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
-#endif
- int cmp;
+ u_int32_t clip = ip->ip_dst.s_addr;
+ u_int32_t sip = ip->ip_src.s_addr;
/* Start searching from where we last left off */
- i = xid_map_hint;
+ i = xid_map_hint;
do {
xmep = &xid_map[i];
- cmp = 1;
- if (xmep->ipver != IP_V(ip) || xmep->xid != xid)
- goto nextitem;
- switch (xmep->ipver) {
- case 4:
- if (memcmp(&ip->ip_src, &xmep->server,
- sizeof(ip->ip_src)) != 0 ||
- memcmp(&ip->ip_dst, &xmep->client,
- sizeof(ip->ip_dst)) != 0) {
- cmp = 0;
- }
- break;
-#ifdef INET6
- case 6:
- if (memcmp(&ip6->ip6_src, &xmep->server,
- sizeof(ip6->ip6_src)) != 0 ||
- memcmp(&ip6->ip6_dst, &xmep->client,
- sizeof(ip6->ip6_dst)) != 0) {
- cmp = 0;
- }
- break;
-#endif
- default:
- cmp = 0;
- break;
- }
- if (cmp) {
+ if (xmep->xid == xid && xmep->client.s_addr == clip &&
+ xmep->server.s_addr == sip) {
/* match */
xid_map_hint = i;
*proc = xmep->proc;
*vers = xmep->vers;
return 0;
}
- nextitem:
if (++i >= XIDMAPSIZE)
i = 0;
} while (i != xid_map_hint);
/* search failed */
- return (-1);
+ return (0);
}
/*
@@ -931,13 +767,13 @@ xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
/*
* Return a pointer to the beginning of the actual results.
- * If the packet was truncated, return 0.
+ * If the packet was truncated, return NULL.
*/
static const u_int32_t *
-parserep(register const struct rpc_msg *rp, register u_int length)
+parserep(register const struct rpc_msg *rp, register int length)
{
register const u_int32_t *dp;
- u_int len;
+ int len;
enum accept_stat astat;
/*
@@ -956,7 +792,7 @@ parserep(register const struct rpc_msg *rp, register u_int length)
* which is an "enum" and so occupies one 32-bit word.
*/
dp = ((const u_int32_t *)&rp->rm_reply) + 1;
- TCHECK(dp[1]);
+ TCHECK2(dp[0], 1);
len = ntohl(dp[1]);
if (len >= length)
return (NULL);
@@ -1006,32 +842,32 @@ parserep(register const struct rpc_msg *rp, register u_int length)
return (NULL);
}
/* successful return */
- TCHECK2(*dp, sizeof(astat));
- return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+ if ((sizeof(astat) + ((u_char *)dp)) < snapend)
+ return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+
trunc:
- return (0);
+ return (NULL);
}
+
static const u_int32_t *
parsestatus(const u_int32_t *dp, int *er)
{
- int errnum;
+ register int errnum;
TCHECK(dp[0]);
-
errnum = ntohl(dp[0]);
if (er)
*er = errnum;
if (errnum != 0) {
if (!qflag)
- printf(" ERROR: %s",
- tok2str(status2str, "unk %d", errnum));
+ printf(" ERROR: %s", pcap_strerror(errnum));
nfserr = 1;
return (NULL);
}
return (dp + 1);
trunc:
- return NULL;
+ return (NULL);
}
static const u_int32_t *
@@ -1042,12 +878,10 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
fap = (const struct nfs_fattr *)dp;
TCHECK(fap->fa_gid);
if (verbose) {
- printf(" %s %o ids %d/%d",
- tok2str(type2str, "unk-ft %d ",
- (u_int32_t)ntohl(fap->fa_type)),
- (u_int32_t)ntohl(fap->fa_mode),
- (u_int32_t)ntohl(fap->fa_uid),
- (u_int32_t) ntohl(fap->fa_gid));
+ printf(" %s %lo ids %ld/%ld",
+ tok2str(type2str, "unk-ft %d ", ntohl(fap->fa_type)),
+ ntohl(fap->fa_mode), ntohl(fap->fa_uid),
+ ntohl(fap->fa_gid));
if (v3) {
TCHECK(fap->fa3_size);
printf(" sz ");
@@ -1055,46 +889,44 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
putchar(' ');
} else {
TCHECK(fap->fa2_size);
- printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size));
+ printf(" sz %ld ", ntohl(fap->fa2_size));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
TCHECK(fap->fa3_ctime);
- printf("nlink %d rdev %d/%d ",
- (u_int32_t)ntohl(fap->fa_nlink),
- (u_int32_t) ntohl(fap->fa3_rdev.specdata1),
- (u_int32_t) ntohl(fap->fa3_rdev.specdata2));
+ printf("nlink %ld rdev %ld/%ld ",
+ ntohl(fap->fa_nlink),
+ ntohl(fap->fa3_rdev.specdata1),
+ ntohl(fap->fa3_rdev.specdata2));
printf("fsid ");
print_int64((u_int32_t *)&fap->fa2_fsid, HEX);
printf(" nodeid ");
print_int64((u_int32_t *)&fap->fa2_fileid, HEX);
- printf(" a/m/ctime %u.%06u ",
- (u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec));
- printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec));
- printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec),
- (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec));
+ printf(" a/m/ctime %lu.%06lu ",
+ ntohl(fap->fa3_atime.nfsv3_sec),
+ ntohl(fap->fa3_atime.nfsv3_nsec));
+ printf("%lu.%06lu ",
+ ntohl(fap->fa3_mtime.nfsv3_sec),
+ ntohl(fap->fa3_mtime.nfsv3_nsec));
+ printf("%lu.%06lu ",
+ ntohl(fap->fa3_ctime.nfsv3_sec),
+ ntohl(fap->fa3_ctime.nfsv3_nsec));
} else {
TCHECK(fap->fa2_ctime);
- printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ",
- (u_int32_t) ntohl(fap->fa_nlink),
- (u_int32_t) ntohl(fap->fa2_rdev),
- (u_int32_t) ntohl(fap->fa2_fsid),
- (u_int32_t) ntohl(fap->fa2_fileid));
- printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec));
- printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_usec));
- printf("%u.%06u ",
- (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec),
- (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec));
+ printf("nlink %ld rdev %lx fsid %lx nodeid %lx a/m/ctime ",
+ ntohl(fap->fa_nlink), ntohl(fap->fa2_rdev),
+ ntohl(fap->fa2_fsid), ntohl(fap->fa2_fileid));
+ printf("%lu.%06lu ",
+ ntohl(fap->fa2_atime.nfsv2_sec),
+ ntohl(fap->fa2_atime.nfsv2_usec));
+ printf("%lu.%06lu ",
+ ntohl(fap->fa2_mtime.nfsv2_sec),
+ ntohl(fap->fa2_mtime.nfsv2_usec));
+ printf("%lu.%06lu ",
+ ntohl(fap->fa2_ctime.nfsv2_sec),
+ ntohl(fap->fa2_ctime.nfsv2_usec));
}
}
return ((const u_int32_t *)((unsigned char *)dp +
@@ -1120,7 +952,8 @@ parsediropres(const u_int32_t *dp)
{
int er;
- if (!(dp = parsestatus(dp, &er)) || er)
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
return (0);
dp = parsefh(dp, 0);
@@ -1138,8 +971,10 @@ parselinkres(const u_int32_t *dp, int v3)
dp = parsestatus(dp, &er);
if (dp == NULL || er)
return(0);
- if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
+
+ if (v3 && ((dp = parse_post_op_attr(dp, vflag)) != NULL))
return (0);
+
putchar(' ');
return (parsefn(dp) != NULL);
}
@@ -1152,7 +987,7 @@ parsestatfs(const u_int32_t *dp, int v3)
dp = parsestatus(dp, &er);
if (dp == NULL || (!v3 && er))
- return (0);
+ return(0);
if (qflag)
return(1);
@@ -1160,7 +995,7 @@ parsestatfs(const u_int32_t *dp, int v3)
if (v3) {
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
}
@@ -1182,16 +1017,13 @@ parsestatfs(const u_int32_t *dp, int v3)
print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED);
printf(" afiles ");
print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED);
- printf(" invar %u",
- (u_int32_t) ntohl(sfsp->sf_invarsec));
+ printf(" invar %lu", ntohl(sfsp->sf_invarsec));
}
} else {
- printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
- (u_int32_t)ntohl(sfsp->sf_tsize),
- (u_int32_t)ntohl(sfsp->sf_bsize),
- (u_int32_t)ntohl(sfsp->sf_blocks),
- (u_int32_t)ntohl(sfsp->sf_bfree),
- (u_int32_t)ntohl(sfsp->sf_bavail));
+ printf(" tsize %ld bsize %ld blocks %ld bfree %ld bavail %ld",
+ ntohl(sfsp->sf_tsize), ntohl(sfsp->sf_bsize),
+ ntohl(sfsp->sf_blocks), ntohl(sfsp->sf_bfree),
+ ntohl(sfsp->sf_bavail));
}
return (1);
@@ -1205,16 +1037,15 @@ parserddires(const u_int32_t *dp)
int er;
dp = parsestatus(dp, &er);
- if (dp == 0 || er)
+ if (dp == NULL || er)
return (0);
if (qflag)
return (1);
TCHECK(dp[2]);
- printf(" offset %x size %d ",
- (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1]));
+ printf(" offset %lx size %ld ", ntohl(dp[0]), ntohl(dp[1]));
if (dp[2] != 0)
- printf(" eof");
+ printf("eof");
return (1);
trunc:
@@ -1226,9 +1057,8 @@ parse_wcc_attr(const u_int32_t *dp)
{
printf(" sz ");
print_int64(dp, UNSIGNED);
- printf(" mtime %u.%06u ctime %u.%06u",
- (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]),
- (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5]));
+ printf(" mtime %lu.%06lu ctime %lu.%06lu", ntohl(dp[2]), ntohl(dp[3]),
+ ntohl(dp[4]), ntohl(dp[5]));
return (dp + 6);
}
@@ -1276,8 +1106,8 @@ parse_wcc_data(const u_int32_t *dp, int verbose)
{
if (verbose > 1)
printf(" PRE:");
- if (!(dp = parse_pre_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_pre_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (verbose)
printf(" POST:");
@@ -1289,8 +1119,8 @@ parsecreateopres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
- return (0);
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
if (er)
dp = parse_wcc_data(dp, verbose);
else {
@@ -1298,11 +1128,11 @@ parsecreateopres(const u_int32_t *dp, int verbose)
if (!ntohl(dp[0]))
return (dp + 1);
dp++;
- if (!(dp = parsefh(dp, 1)))
- return (0);
+ if ((dp = parsefh(dp, 1)) == NULL)
+ return (NULL);
if (verbose) {
- if (!(dp = parse_post_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (vflag > 1) {
printf("dir attr:");
dp = parse_wcc_data(dp, verbose);
@@ -1319,9 +1149,9 @@ parsewccres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
- return parse_wcc_data(dp, verbose) != 0;
+ return parse_wcc_data(dp, verbose) != NULL;
}
static const u_int32_t *
@@ -1329,12 +1159,12 @@ parsev3rddirres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
- return (0);
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (er)
return dp;
if (vflag) {
@@ -1353,35 +1183,31 @@ parsefsinfo(const u_int32_t *dp)
struct nfsv3_fsinfo *sfp;
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
if (er)
return (1);
sfp = (struct nfsv3_fsinfo *)dp;
TCHECK(*sfp);
- printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
- (u_int32_t) ntohl(sfp->fs_rtmax),
- (u_int32_t) ntohl(sfp->fs_rtpref),
- (u_int32_t) ntohl(sfp->fs_wtmax),
- (u_int32_t) ntohl(sfp->fs_wtpref),
- (u_int32_t) ntohl(sfp->fs_dtpref));
+ printf(" rtmax %lu rtpref %lu wtmax %lu wtpref %lu dtpref %lu",
+ ntohl(sfp->fs_rtmax), ntohl(sfp->fs_rtpref),
+ ntohl(sfp->fs_wtmax), ntohl(sfp->fs_wtpref),
+ ntohl(sfp->fs_dtpref));
if (vflag) {
- printf(" rtmult %u wtmult %u maxfsz ",
- (u_int32_t) ntohl(sfp->fs_rtmult),
- (u_int32_t) ntohl(sfp->fs_wtmult));
+ printf(" rtmult %lu wtmult %lu maxfsz ",
+ ntohl(sfp->fs_rtmult), ntohl(sfp->fs_wtmult));
print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
- printf(" delta %u.%06u ",
- (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec),
- (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec));
+ printf(" delta %lu.%06lu ", ntohl(sfp->fs_timedelta.nfsv3_sec),
+ ntohl(sfp->fs_timedelta.nfsv3_nsec));
}
- return (0);
-trunc:
return (1);
+trunc:
+ return (0);
}
static int
@@ -1390,11 +1216,11 @@ parsepathconf(const u_int32_t *dp)
int er;
struct nfsv3_pathconf *spp;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
if (er)
return (1);
@@ -1402,23 +1228,24 @@ parsepathconf(const u_int32_t *dp)
spp = (struct nfsv3_pathconf *)dp;
TCHECK(*spp);
- printf(" linkmax %u namemax %u %s %s %s %s",
- (u_int32_t) ntohl(spp->pc_linkmax),
- (u_int32_t) ntohl(spp->pc_namemax),
+ printf(" linkmax %lu namemax %lu %s %s %s %s",
+ ntohl(spp->pc_linkmax),
+ ntohl(spp->pc_namemax),
ntohl(spp->pc_notrunc) ? "notrunc" : "",
ntohl(spp->pc_chownrestricted) ? "chownres" : "",
ntohl(spp->pc_caseinsensitive) ? "igncase" : "",
ntohl(spp->pc_casepreserving) ? "keepcase" : "");
- return (0);
-trunc:
return (1);
+trunc:
+ return (0);
}
-
+
static void
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;
+
int er;
v3 = (vers == NFS_VER3);
@@ -1445,10 +1272,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_SETATTR:
printf(" setattr");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
return;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
if (parseattrstat(dp, !qflag, 0) != 0)
@@ -1458,10 +1285,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_LOOKUP:
printf(" lookup");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (er) {
if (vflag > 1) {
@@ -1469,15 +1296,15 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
dp = parse_post_op_attr(dp, vflag);
}
} else {
- if (!(dp = parsefh(dp, v3)))
+ if ((dp = parsefh(dp, v3)) == NULL)
break;
- if ((dp = parse_post_op_attr(dp, vflag)) &&
- vflag > 1) {
+ if (((dp = parse_post_op_attr(dp, vflag)) != NULL) &&
+ (vflag > 1)) {
printf(" post dattr:");
dp = parse_post_op_attr(dp, vflag);
}
}
- if (dp)
+ if (dp != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1488,14 +1315,14 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_ACCESS:
printf(" access");
dp = parserep(rp, length);
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag)
printf(" attr:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
if (!er)
- printf(" c %04x", (u_int32_t)ntohl(dp[0]));
+ printf(" c %04lx", ntohl(dp[0]));
return;
case NFSPROC_READLINK:
@@ -1507,18 +1334,18 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_READ:
printf(" read");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
if (er)
return;
if (vflag) {
- TCHECK(dp[1]);
- printf("%u bytes", (u_int32_t) ntohl(dp[0]));
+ TCHECK2(*dp, 8);
+ printf("%lu bytes", ntohl(dp[0]));
if (ntohl(dp[1]))
printf(" EOF");
}
@@ -1531,23 +1358,22 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_WRITE:
printf(" write");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
if (er)
return;
if (vflag) {
- TCHECK(dp[0]);
- printf("%u bytes", (u_int32_t) ntohl(dp[0]));
+ TCHECK2(*dp, 4);
+ printf("%lu bytes", ntohl(dp[0]));
if (vflag > 1) {
- TCHECK(dp[1]);
+ TCHECK2(*dp, 4);
printf(" <%s>",
- tok2str(nfsv3_writemodes,
- NULL, ntohl(dp[1])));
+ nfsv3_writemodes[ntohl(dp[1])]);
}
return;
}
@@ -1559,10 +1385,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_CREATE:
printf(" create");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1572,10 +1398,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_MKDIR:
printf(" mkdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1585,101 +1411,101 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_SYMLINK:
printf(" symlink");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_MKNOD:
printf(" mknod");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
break;
case NFSPROC_REMOVE:
printf(" remove");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_RMDIR:
printf(" rmdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_RENAME:
printf(" rename");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag) {
printf(" from:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
printf(" to:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
}
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_LINK:
printf(" link");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag) {
printf(" file POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
printf(" dir:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
return;
}
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_READDIR:
printf(" readdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(dp, vflag) != NULL)
return;
} else {
if (parserddires(dp) != 0)
@@ -1689,23 +1515,23 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_READDIRPLUS:
printf(" readdirplus");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(dp, vflag) != NULL)
return;
break;
case NFSPROC_FSSTAT:
printf(" fsstat");
dp = parserep(rp, length);
- if (dp != NULL && parsestatfs(dp, v3) != 0)
+ if (dp != NULL && parsestatfs(dp, v3) != NULL)
return;
break;
case NFSPROC_FSINFO:
printf(" fsinfo");
dp = parserep(rp, length);
- if (dp != NULL && parsefsinfo(dp) != 0)
+ if (dp != NULL && parsefsinfo(dp) != NULL)
return;
break;
@@ -1727,6 +1553,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
printf(" proc-%u", proc);
return;
}
+
trunc:
if (!nfserr)
fputs(" [|nfs]", stdout);
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index fd2712e..1009872 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.31 2000/10/06 04:23:13 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.27 1999/11/21 09:36:57 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -36,7 +38,14 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
#include <netinet/in.h>
+#include <net/ethernet.h>
#include <ctype.h>
#include <stdio.h>
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index 55602a4..64c7df3 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.40 2000/12/16 22:00:50 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.30 1999/12/22 06:27:21 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -34,100 +36,84 @@ static const char rcsid[] =
#include <sys/file.h>
#include <sys/ioctl.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <net/ethernet.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
#include <pcap.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
-
-#include "ip.h"
#ifdef INET6
-#include "ip6.h"
+#include <netinet/ip6.h>
#endif
+#include "interface.h"
+#include "addrtoname.h"
+
#ifndef AF_NS
#define AF_NS 6 /* XEROX NS protocols */
#endif
/*
- * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order
- * 32-bit integer that specifies the family, e.g. AF_INET.
- *
- * Note here that "host" refers to the host on which the packets were
- * captured; that isn't necessarily *this* host.
- *
- * The OpenBSD DLT_LOOP packet header is the same, except that the integer
- * is in network byte order.
+ * The DLT_NULL packet header is 4 bytes long. It contains a network
+ * order 32 bit integer that specifies the family, e.g. AF_INET
*/
#define NULL_HDRLEN 4
static void
-null_print(u_int family, u_int length)
+null_print(const u_char *p, const struct ip *ip, u_int length)
{
- if (nflag)
- printf("AF %u ", family);
- else {
- switch (family) {
+ u_int family;
- case AF_INET:
- printf("ip ");
- break;
+ memcpy((char *)&family, (char *)p, sizeof(family));
+
+ if (nflag) {
+ /* XXX just dump the header */
+ return;
+ }
+ switch (family) {
+
+ case AF_INET:
+ printf("ip: ");
+ break;
#ifdef INET6
- case AF_INET6:
- printf("ip6 ");
- break;
+ case AF_INET6:
+ printf("ip6: ");
+ break;
#endif
- case AF_NS:
- printf("ns ");
- break;
+ case AF_NS:
+ printf("ns: ");
+ break;
- default:
- printf("AF %u ", family);
- break;
- }
+ default:
+ printf("AF %d: ", family);
+ break;
}
- printf("%d: ", length);
}
-/*
- * Byte-swap a 32-bit number.
- * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on
- * big-endian platforms.)
- */
-#define SWAPLONG(y) \
-((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
-
void
null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const struct ip *ip;
- u_int family;
ts_print(&h->ts);
- memcpy((char *)&family, (char *)p, sizeof(family));
-
- /*
- * This isn't necessarily in our host byte order; if this is
- * a DLT_LOOP capture, it's in network byte order, and if
- * this is a DLT_NULL capture from a machine with the opposite
- * byte-order, it's in the opposite byte order from ours.
- *
- * If the upper 16 bits aren't all zero, assume it's byte-swapped.
- */
- if ((family & 0xFFFF0000) != 0)
- family = SWAPLONG(family);
-
/*
* 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.
@@ -141,9 +127,9 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
ip = (struct ip *)(p + NULL_HDRLEN);
if (eflag)
- null_print(family, length);
+ null_print(p, ip, length);
- switch (IP_V(ip)) {
+ switch (ip->ip_v) {
case 4:
ip_print((const u_char *)ip, length);
break;
@@ -153,7 +139,7 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
break;
#endif /* INET6 */
default:
- printf("ip v%d", IP_V(ip));
+ printf("ip v%d", ip->ip_v);
break;
}
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c
index 06ba458..96bf683 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.23 2000/10/03 02:55:00 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.15.2.1 2000/01/25 18:29:05 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -33,6 +35,8 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -62,8 +66,6 @@ struct pim {
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
-
static void pimv2_print(register const u_char *bp, register u_int len);
static void
@@ -316,7 +318,7 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
TCHECK2(bp[0], 4);
(void)printf(" RP %s", ipaddr_string(bp));
TCHECK(bp[4]);
- switch (bp[4] & 0x3) {
+ switch(bp[4] & 0x3) {
case 0: printf(" PIMv?");
break;
case 1: printf(" PIMv1");
@@ -358,7 +360,7 @@ pim_print(register const u_char *bp, register u_int len)
TCHECK(pim->pim_rsv);
#endif
- switch (PIM_VER(pim->pim_typever)) {
+ switch(PIM_VER(pim->pim_typever)) {
case 2: /* avoid hardcoding? */
(void)printf("pim v2");
pimv2_print(bp, len);
@@ -634,7 +636,7 @@ pimv2_print(register const u_char *bp, register u_int len)
if (bp >= ep)
break;
ip = (struct ip *)bp;
- switch (IP_V(ip)) {
+ switch(ip->ip_v) {
case 4: /* IPv4 */
printf(" ");
ip_print(bp, len);
@@ -646,7 +648,7 @@ pimv2_print(register const u_char *bp, register u_int len)
break;
#endif
default:
- (void)printf(" IP ver %d", IP_V(ip));
+ (void)printf(" IP ver %d", ip->ip_v);
break;
}
break;
@@ -799,12 +801,12 @@ pimv2_print(register const u_char *bp, register u_int len)
(void)printf("...)");
goto bs_done;
}
- (void)printf(" RPcnt=%d", bp[0]);
+ (void)printf(" RPcnt=%d", frpcnt = bp[0]);
if (bp + 1 >= ep) {
(void)printf("...)");
goto bs_done;
}
- (void)printf(" FRPcnt=%d", frpcnt = bp[1]);
+ (void)printf(" FRPcnt=%d", bp[1]);
bp += 4;
for (j = 0; j < frpcnt && bp < ep; j++) {
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index 5dc1b83..3c831d3 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -18,20 +18,12 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more
- * complete PPP support.
- */
-
-/*
- * TODO:
- * o resolve XXX as much as possible
- * o MP support
- * o BAP support
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.58 2000/12/27 11:09:08 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.33.2.1 2000/01/29 07:31:17 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -40,77 +32,96 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
-#ifdef __bsdi__
-#include <net/slcompress.h>
-#include <net/if_ppp.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
#include <stdio.h>
+#ifdef __bsdi__
+#include <net/slcompress.h>
+#include <net/if_ppp.h>
+#endif
+#include <net/ethernet.h>
+#include "ethertype.h"
+
+#include <net/ppp_defs.h>
#include "interface.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
-#include "chdlc.h"
-#include "ethertype.h"
-/*
- * The following constatns are defined by IANA. Please refer to
- * http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
- * for the up-to-date information.
- */
+struct protonames {
+ u_short protocol;
+ char *name;
+};
-/* Control Protocols (LCP/IPCP/CCP etc.) Codes */
-
-#define CPCODES_VEXT 0 /* Vendor-Specific (RFC2153) */
-#define CPCODES_CONF_REQ 1 /* Configure-Request */
-#define CPCODES_CONF_ACK 2 /* Configure-Ack */
-#define CPCODES_CONF_NAK 3 /* Configure-Nak */
-#define CPCODES_CONF_REJ 4 /* Configure-Reject */
-#define CPCODES_TERM_REQ 5 /* Terminate-Request */
-#define CPCODES_TERM_ACK 6 /* Terminate-Ack */
-#define CPCODES_CODE_REJ 7 /* Code-Reject */
-#define CPCODES_PROT_REJ 8 /* Protocol-Reject (LCP only) */
-#define CPCODES_ECHO_REQ 9 /* Echo-Request (LCP only) */
-#define CPCODES_ECHO_RPL 10 /* Echo-Reply (LCP only) */
-#define CPCODES_DISC_REQ 11 /* Discard-Request (LCP only) */
-#define CPCODES_ID 12 /* Identification (LCP only) */
-#define CPCODES_TIME_REM 13 /* Time-Remaining (LCP only) */
-#define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) */
-#define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
-
-#define CPCODES_MIN CPCODES_VEXT
-#define CPCODES_MAX CPCODES_RESET_REP
-
-static const char *cpcodes[] = {
+static struct protonames protonames[] = {
/*
- * Control Protocol code values (RFC1661)
+ * Protocol field values.
*/
- "Vend-Ext", /* (0) RFC2153 */
- "Conf-Req", /* (1) */
- "Conf-Ack", /* (2) */
- "Conf-Nak", /* (3) */
- "Conf-Rej", /* (4) */
- "Term-Req", /* (5) */
- "Term-Ack", /* (6) */
- "Code-Rej", /* (7) */
- "Prot-Rej", /* (8) */
- "Echo-Req", /* (9) */
- "Echo-Rep", /* (10) */
- "Disc-Req", /* (11) */
- "Ident", /* (12) RFC1570 */
- "Time-Rem", /* (13) RFC1570 */
- "Reset-Req", /* (14) RFC1962 */
- "Reset-Ack", /* (15) RFC1962 */
+ PPP_IP, "IP", /* Internet Protocol */
+ PPP_XNS, "XNS", /* Xerox NS */
+ PPP_IPX, "IPX", /* IPX Datagram (RFC1552) */
+ PPP_VJC_COMP, "VJC_UNCOMP", /* VJ compressed TCP */
+ PPP_VJC_UNCOMP, "VJC_UNCOMP", /* VJ uncompressed TCP */
+ PPP_COMP, "COMP", /* compressed packet */
+ PPP_IPCP, "IPCP", /* IP Control Protocol */
+ PPP_IPXCP, "IPXCP", /* IPX Control Protocol (RFC1552) */
+ PPP_CCP, "CCP", /* Compression Control Protocol */
+ PPP_LCP, "LCP", /* Link Control Protocol */
+ PPP_PAP, "PAP", /* Password Authentication Protocol */
+ PPP_LQR, "LQR", /* Link Quality Report protocol */
+ PPP_CHAP, "CHAP", /* Cryptographic Handshake Auth. Proto*/
};
-/* LCP Config Options */
+/* LCP */
+
+#define LCP_CONF_REQ 1
+#define LCP_CONF_ACK 2
+#define LCP_CONF_NAK 3
+#define LCP_CONF_REJ 4
+#define LCP_TERM_REQ 5
+#define LCP_TERM_ACK 6
+#define LCP_CODE_REJ 7
+#define LCP_PROT_REJ 8
+#define LCP_ECHO_REQ 9
+#define LCP_ECHO_RPL 10
+#define LCP_DISC_REQ 11
+
+#define LCP_MIN LCP_CONF_REQ
+#define LCP_MAX LCP_DISC_REQ
+
+static char *lcpcodes[] = {
+ /*
+ * LCP code values (RFC1661, pp26)
+ */
+ "Configure-Request",
+ "Configure-Ack",
+ "Configure-Nak",
+ "Configure-Reject",
+ "Terminate-Request",
+ "Terminate-Ack",
+ "Code-Reject",
+ "Protocol-Reject",
+ "Echo-Request",
+ "Echo-Reply",
+ "Discard-Request",
+};
#define LCPOPT_VEXT 0
#define LCPOPT_MRU 1
@@ -118,175 +129,40 @@ static const char *cpcodes[] = {
#define LCPOPT_AP 3
#define LCPOPT_QP 4
#define LCPOPT_MN 5
-#define LCPOPT_DEP6 6
#define LCPOPT_PFC 7
#define LCPOPT_ACFC 8
-#define LCPOPT_FCSALT 9
-#define LCPOPT_SDP 10
-#define LCPOPT_NUMMODE 11
-#define LCPOPT_DEP12 12
-#define LCPOPT_CBACK 13
-#define LCPOPT_DEP14 14
-#define LCPOPT_DEP15 15
-#define LCPOPT_DEP16 16
-#define LCPOPT_MLMRRU 17
-#define LCPOPT_MLSSNHF 18
-#define LCPOPT_MLED 19
-#define LCPOPT_PROP 20
-#define LCPOPT_DCEID 21
-#define LCPOPT_MPP 22
-#define LCPOPT_LD 23
-#define LCPOPT_LCPAOPT 24
-#define LCPOPT_COBS 25
-#define LCPOPT_PE 26
-#define LCPOPT_MLHF 27
-#define LCPOPT_I18N 28
-#define LCPOPT_SDLOS 29
-#define LCPOPT_PPPMUX 30
-
-#define LCPOPT_MIN LCPOPT_VEXT
-#define LCPOPT_MAX LCPOPT_PPPMUX
-
-static const char *lcpconfopts[] = {
- "Vend-Ext", /* (0) */
- "MRU", /* (1) */
- "ACCM", /* (2) */
- "Auth-Prot", /* (3) */
- "Qual-Prot", /* (4) */
- "Magic-Num", /* (5) */
- "deprecated(6)", /* used to be a Quality Protocol */
- "PFC", /* (7) */
- "ACFC", /* (8) */
- "FCS-Alt", /* (9) */
- "SDP", /* (10) */
- "Num-Mode", /* (11) */
- "deprecated(12)", /* used to be a Multi-Link-Procedure*/
- "Call-Back", /* (13) */
- "deprecated(14)", /* used to be a Connect-Time */
- "deprecated(15)", /* used to be a Compund-Frames */
- "deprecated(16)", /* used to be a Nominal-Data-Encap */
- "MRRU", /* (17) */
- "SSNHF", /* (18) */
- "End-Disc", /* (19) */
- "Proprietary", /* (20) */
- "DCE-Id", /* (21) */
- "MP+", /* (22) */
- "Link-Disc", /* (23) */
- "LCP-Auth-Opt", /* (24) */
- "COBS", /* (25) */
- "Prefix-elision", /* (26) */
- "Multilink-header-Form",/* (27) */
- "I18N", /* (28) */
- "SDL-over-SONET/SDH", /* (29) */
- "PPP-Muxing", /* (30) */
-};
-/* IPV6CP - to be supported */
-/* ECP - to be supported */
-
-/* CCP Config Options */
-
-#define CCPOPT_OUI 0 /* RFC1962 */
-#define CCPOPT_PRED1 1 /* RFC1962 */
-#define CCPOPT_PRED2 2 /* RFC1962 */
-#define CCPOPT_PJUMP 3 /* RFC1962 */
-/* 4-15 unassigned */
-#define CCPOPT_HPPPC 16 /* RFC1962 */
-#define CCPOPT_STACLZS 17 /* RFC1974 */
-#define CCPOPT_MPPC 18 /* RFC2118 */
-#define CCPOPT_GFZA 19 /* RFC1962 */
-#define CCPOPT_V42BIS 20 /* RFC1962 */
-#define CCPOPT_BSDCOMP 21 /* RFC1977 */
-/* 22 unassigned */
-#define CCPOPT_LZSDCP 23 /* RFC1967 */
-#define CCPOPT_MVRCA 24 /* RFC1975 */
-#define CCPOPT_DEC 25 /* RFC1976 */
-#define CCPOPT_DEFLATE 26 /* RFC1979 */
-/* 27-254 unassigned */
-#define CCPOPT_RESV 255 /* RFC1962 */
-
-#define CCPOPT_MIN CCPOPT_OUI
-#define CCPOPT_MAX CCPOPT_DEFLATE /* XXX: should be CCPOPT_RESV but... */
-
-static const char *ccpconfopts[] = {
- "OUI", /* (0) */
- "Pred-1", /* (1) */
- "Pred-2", /* (2) */
- "Puddle", /* (3) */
- "unassigned(4)", /* (4) */
- "unassigned(5)", /* (5) */
- "unassigned(6)", /* (6) */
- "unassigned(7)", /* (7) */
- "unassigned(8)", /* (8) */
- "unassigned(9)", /* (9) */
- "unassigned(10)", /* (10) */
- "unassigned(11)", /* (11) */
- "unassigned(12)", /* (12) */
- "unassigned(13)", /* (13) */
- "unassigned(14)", /* (14) */
- "unassigned(15)", /* (15) */
- "HP-PPC", /* (16) */
- "Stac-LZS", /* (17) */
- "MPPC", /* (18) */
- "Gand-FZA", /* (19) */
- "V.42bis", /* (20) */
- "BSD-Comp", /* (21) */
- "unassigned(22)", /* (22) */
- "LZS-DCP", /* (23) */
- "MVRCA", /* (24) */
- "DEC", /* (25) */
- "Deflate", /* (26) */
+#define LCPOPT_MIN 0
+#define LCPOPT_MAX 24
+
+static char *lcpconfopts[] = {
+ "Vendor-Ext",
+ "Max-Rx-Unit",
+ "Async-Ctrl-Char-Map",
+ "Auth-Prot",
+ "Quality-Prot",
+ "Magic-Number",
+ "unassigned (6)",
+ "Prot-Field-Compr",
+ "Add-Ctrl-Field-Compr",
+ "FCS-Alternatives",
+ "Self-Describing-Pad",
+ "Numbered-Mode",
+ "Multi-Link-Procedure",
+ "Call-Back",
+ "Connect-Time",
+ "Compund-Frames",
+ "Nominal-Data-Encap",
+ "Multilink-MRRU",
+ "Multilink-SSNHF",
+ "Multilink-ED",
+ "Proprietary",
+ "DCE-Identifier",
+ "Multilink-Plus-Proc",
+ "Link-Discriminator",
+ "LCP-Auth-Option",
};
-/* BACP Config Options */
-
-#define BACPOPT_FPEER 1 /* RFC2125 */
-
-/* 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 */
-
-/* ATCP - to be supported */
-/* OSINLCP - to be supported */
-/* BVCP - to be supported */
-/* BCP - to be supported */
-/* IPXCP - to be supported */
-
-/* Auth Algorithms */
-
-/* 0-4 Reserved (RFC1994) */
-#define AUTHALG_CHAPMD5 5 /* RFC1994 */
-#define AUTHALG_MSCHAP1 128 /* RFC2433 */
-#define AUTHALG_MSCHAP2 129 /* RFC2795 */
-
-/* FCS Alternatives - to be supported */
-
-/* Multilink Endpoint Discriminator (RFC1717) */
-#define MEDCLASS_NULL 0 /* Null Class */
-#define MEDCLASS_LOCAL 1 /* Locally Assigned */
-#define MEDCLASS_IPV4 2 /* Internet Protocol (IPv4) */
-#define MEDCLASS_MAC 3 /* IEEE 802.1 global MAC address */
-#define MEDCLASS_MNB 4 /* PPP Magic Number Block */
-#define MEDCLASS_PSNDN 5 /* Public Switched Network Director Number */
-
-/* PPP LCP Callback */
-#define CALLBACK_AUTH 0 /* Location determined by user auth */
-#define CALLBACK_DSTR 1 /* Dialing string */
-#define CALLBACK_LID 2 /* Location identifier */
-#define CALLBACK_E164 3 /* E.164 number */
-#define CALLBACK_X500 4 /* X.500 distinguished name */
-#define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
-
/* CHAP */
#define CHAP_CHAL 1
@@ -294,14 +170,14 @@ static const char *ccpconfopts[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
-#define CHAP_CODEMIN CHAP_CHAL
-#define CHAP_CODEMAX CHAP_FAIL
+#define CHAP_CODEMIN 1
+#define CHAP_CODEMAX 4
-static const char *chapcode[] = {
- "Chal", /* (1) */
- "Resp", /* (2) */
- "Succ", /* (3) */
- "Fail", /* (4) */
+static char *chapcode[] = {
+ "Challenge",
+ "Response",
+ "Success",
+ "Failure",
};
/* PAP */
@@ -310,223 +186,129 @@ static const char *chapcode[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
-#define PAP_CODEMIN PAP_AREQ
-#define PAP_CODEMAX PAP_ANAK
+#define PAP_CODEMIN 1
+#define PAP_CODEMAX 3
-static const char *papcode[] = {
- "Auth-Req", /* (1) */
- "Auth-Ack", /* (2) */
- "Auth-Nak", /* (3) */
+static char *papcode[] = {
+ "Authenticate-Request",
+ "Authenticate-Ack",
+ "Authenticate-Nak",
};
-/* BAP */
-#define BAP_CALLREQ 1
-#define BAP_CALLRES 2
-#define BAP_CBREQ 3
-#define BAP_CBRES 4
-#define BAP_LDQREQ 5
-#define BAP_LDQRES 6
-#define BAP_CSIND 7
-#define BAP_CSRES 8
-
-static const char *ppp_protoname (u_int proto);
-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 int print_lcp_config_options (const u_char *p, int);
-static int print_ipcp_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 const char *
-ppp_protoname(u_int proto)
-{
- static char buf[20];
+/* IPCP */
- switch (proto) {
- case PPP_IP: return "IP";
- case PPP_IPV6: return "IPv6";
-#ifdef PPP_XNS
- case PPP_XNS: return "XNS";
-#endif
- case PPP_IPX: return "IPX";
- case PPP_VJC: return "VJC";
- case PPP_VJNC: return "VJNC";
-#ifdef PPP_COMP
- case PPP_COMP: return "COMP";
-#endif
- case PPP_IPCP: return "IPCP";
- case PPP_IPV6CP: return "IPv6CP";
- case PPP_IPXCP: return "IPXCP";
- case PPP_CCP: return "CCP";
- case PPP_LCP: return "LCP";
- case PPP_PAP: return "PAP";
-#ifdef PPP_LQR
- case PPP_LQR: return "LQR";
-#endif
- case PPP_CHAP: return "CHAP";
- case PPP_BACP: return "BACP";
- case PPP_BAP: return "BAP";
- default:
- snprintf(buf, sizeof(buf), "unknown-0x%04x", proto);
- return buf;
+#define IPCP_2ADDR 1
+#define IPCP_CP 2
+#define IPCP_ADDR 3
+
+static void do_ppp_print __P((const u_char *, u_int, u_int));
+static void handle_lcp __P((const u_char *p, int length));
+static int print_lcp_config_options __P((const u_char *p));
+static void handle_chap __P((const u_char *p, int length));
+static void handle_ipcp __P((const u_char *p, int length));
+static void handle_pap __P((const u_char *p, int length));
+
+void
+ppp_hdlc_print(const u_char *p, int length)
+{
+ int proto = PPP_PROTOCOL(p);
+ int i, j, x;
+ u_char *ptr;
+
+ printf("ID-%03d ", *(p+5));
+
+ for (i = (sizeof(protonames) / sizeof(protonames[0])) - 1; i >= 0; --i)
+ {
+ if (proto == protonames[i].protocol)
+ {
+ printf("%s: ", protonames[i].name);
+
+ switch(proto)
+ {
+ case PPP_LCP:
+ handle_lcp(p, length);
+ break;
+ case PPP_CHAP:
+ handle_chap(p, length);
+ break;
+ case PPP_PAP:
+ handle_pap(p, length);
+ break;
+ case PPP_IPCP:
+ handle_ipcp(p, length);
+ break;
+ }
+ break;
+ }
+ }
+ if (i < 0)
+ {
+ printf("%04x: ", proto);
}
}
-/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
+/* print LCP frame */
static void
-handle_ctrl_proto(u_int proto, const u_char *p, int length)
+handle_lcp(const u_char *p, int length)
{
- u_int code, len;
- int (*pfunc)(const u_char *, int);
int x, j;
+ const u_char *ptr;
- if (length < 1) {
- printf("[|%s]", ppp_protoname(proto));
- return;
- } else if (length < 4) {
- printf("[|%s 0x%02x]", ppp_protoname(proto), *p);
- return;
- }
+ x = p[4];
- code = *p;
- if ((code >= CPCODES_MIN) && (code <= CPCODES_MAX))
- printf("%s", cpcodes[code]);
+ if ((x >= LCP_MIN) && (x <= LCP_MAX))
+ printf("%s", lcpcodes[x - 1]);
else {
- printf("0x%02x", code);
+ printf("0x%02x", x);
return;
}
- p++;
- printf("(%u)", *p); /* ID */
- p++;
-
- len = EXTRACT_16BITS(p);
- p += 2;
-
- if (length <= 4)
- return; /* there may be a NULL confreq etc. */
-
- switch (code) {
- case CPCODES_VEXT:
- if (length < 11)
- break;
- printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
- p += 4;
- printf(" OUI=%02x%02x%02x", p[0], p[1], p[2]);
- /* XXX: need to decode Kind and Value(s)? */
- break;
- case CPCODES_CONF_REQ:
- case CPCODES_CONF_ACK:
- case CPCODES_CONF_NAK:
- case CPCODES_CONF_REJ:
- x = len - 4; /* Code(1), Identifier(1) and Length(2) */
+ length -= 4;
+
+ switch (x) {
+ case LCP_CONF_REQ:
+ case LCP_CONF_ACK:
+ case LCP_CONF_NAK:
+ case LCP_CONF_REJ:
+ x = length;
+ ptr = p + 8;
do {
- switch (proto) {
- case PPP_LCP:
- pfunc = print_lcp_config_options;
- break;
- case PPP_IPCP:
- pfunc = print_ipcp_config_options;
- break;
- case PPP_CCP:
- pfunc = print_ccp_config_options;
- break;
- case PPP_BACP:
- pfunc = print_bacp_config_options;
- break;
- default:
- /*
- * This should never happen, but we set
- * "pfunc" to squelch uninitialized
- * variable warnings from compilers.
- */
- pfunc = NULL;
- break;
- }
- if ((j = (*pfunc)(p, len)) == 0)
+ if ((j = print_lcp_config_options(ptr)) == 0)
break;
x -= j;
- p += j;
+ ptr += j;
} while (x > 0);
break;
- case CPCODES_TERM_REQ:
- case CPCODES_TERM_ACK:
- /* XXX: need to decode Data? */
- break;
- case CPCODES_CODE_REJ:
- /* XXX: need to decode Rejected-Packet? */
- break;
- case CPCODES_PROT_REJ:
- if (length < 6)
- break;
- printf(", Rejected-Protocol=%04x", EXTRACT_16BITS(p));
- /* XXX: need to decode Rejected-Information? */
- break;
- case CPCODES_ECHO_REQ:
- case CPCODES_ECHO_RPL:
- case CPCODES_DISC_REQ:
- case CPCODES_ID:
- if (length < 8)
- break;
- printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
- /* XXX: need to decode Data? */
- break;
- case CPCODES_TIME_REM:
- if (length < 12)
- break;
- printf(", Magic-Num=%08x", EXTRACT_32BITS(p));
- printf(" Seconds-Remaining=%u", EXTRACT_32BITS(p + 4));
- /* XXX: need to decode Message? */
+ case LCP_ECHO_REQ:
+ case LCP_ECHO_RPL:
+ printf(", Magic-Number=%u",
+ EXTRACT_32BITS(p+8));
break;
+ case LCP_TERM_REQ:
+ case LCP_TERM_ACK:
+ case LCP_CODE_REJ:
+ case LCP_PROT_REJ:
+ case LCP_DISC_REQ:
default:
- printf(", unknown-Codes-0x%02x", code);
break;
}
}
/* LCP config options */
static int
-print_lcp_config_options(const u_char *p, int length)
+print_lcp_config_options(const u_char *p)
{
- int len, opt;
-
- if (length < 2)
- return 0;
- len = p[1];
- opt = p[0];
- if (length < len)
- return 0;
+ int len = p[1];
+ int opt = p[0];
+
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
printf(", %s", lcpconfopts[opt]);
- else {
- printf(", unknwhown-%d", opt);
- return len;
- }
switch (opt) {
- case LCPOPT_VEXT:
- if (len >= 6) {
- printf(" OUI=%02x%02x%02x", p[2], p[3], p[4]);
-#if 0
- printf(" kind=%02x", p[5]);
- printf(" val=")
- for (i = 0; i < len - 6; i++) {
- printf("%02x", p[6 + i]);
- }
-#endif
- }
- break;
case LCPOPT_MRU:
if (len == 4)
- printf("=%u", EXTRACT_16BITS(p + 2));
- break;
- case LCPOPT_ACCM:
- if (len == 6)
- printf("=%08x", EXTRACT_32BITS(p + 2));
+ printf("=%d", (*(p+2) << 8) + *(p+3));
break;
case LCPOPT_AP:
if (len >= 4) {
@@ -538,14 +320,11 @@ print_lcp_config_options(const u_char *p, int length)
default:
printf("unknown-algorithm-%u", p[4]);
break;
- case AUTHALG_CHAPMD5:
+ case 5:
printf("MD5");
break;
- case AUTHALG_MSCHAP1:
- printf("MSCHAPv1");
- break;
- case AUTHALG_MSCHAP2:
- printf("MSCHAPv2");
+ case 0x80:
+ printf("Microsoft");
break;
}
}
@@ -569,100 +348,14 @@ print_lcp_config_options(const u_char *p, int length)
break;
case LCPOPT_MN:
if (len == 6)
- printf("=%08x", EXTRACT_32BITS(p + 2));
+ printf("=%u", EXTRACT_32BITS(p+2));
break;
case LCPOPT_PFC:
+ printf(" PFC");
break;
case LCPOPT_ACFC:
+ printf(" ACFC");
break;
- case LCPOPT_LD:
- if (len == 4)
- printf("=%04x", EXTRACT_16BITS(p + 2));
- break;
- case LCPOPT_CBACK:
- if (len < 3)
- break;
- switch (p[2]) { /* Operation */
- case CALLBACK_AUTH:
- printf(" UserAuth");
- break;
- case CALLBACK_DSTR:
- printf(" DialString");
- break;
- case CALLBACK_LID:
- printf(" LocalID");
- break;
- case CALLBACK_E164:
- printf(" E.164");
- break;
- case CALLBACK_X500:
- printf(" X.500");
- break;
- case CALLBACK_CBCP:
- printf(" CBCP");
- break;
- default:
- printf(" unknown-operation=%u", p[2]);
- break;
- }
- break;
- case LCPOPT_MLMRRU:
- if (len == 4)
- printf("=%u", EXTRACT_16BITS(p + 2));
- break;
- case LCPOPT_MLED:
- if (len < 3)
- break;
- switch (p[2]) { /* class */
- case MEDCLASS_NULL:
- printf(" Null");
- break;
- case MEDCLASS_LOCAL:
- printf(" Local"); /* XXX */
- break;
- case MEDCLASS_IPV4:
- if (len != 7)
- break;
- printf(" IPv4=%s", ipaddr_string(p + 3));
- break;
- case MEDCLASS_MAC:
- if (len != 9)
- break;
- printf(" MAC=%02x:%02x:%02x:%02x:%02x:%02x",
- p[3], p[4], p[5], p[6], p[7], p[8]);
- break;
- case MEDCLASS_MNB:
- printf(" Magic-Num-Block"); /* XXX */
- break;
- case MEDCLASS_PSNDN:
- printf(" PSNDN"); /* XXX */
- break;
- }
- break;
-
-/* XXX: to be supported */
-#if 0
- case LCPOPT_DEP6:
- case LCPOPT_FCSALT:
- case LCPOPT_SDP:
- case LCPOPT_NUMMODE:
- case LCPOPT_DEP12:
- case LCPOPT_DEP14:
- case LCPOPT_DEP15:
- case LCPOPT_DEP16:
- case LCPOPT_MLSSNHF:
- case LCPOPT_PROP:
- case LCPOPT_DCEID:
- case LCPOPT_MPP:
- case LCPOPT_LCPAOPT:
- case LCPOPT_COBS:
- case LCPOPT_PE:
- case LCPOPT_MLHF:
- case LCPOPT_I18N:
- case LCPOPT_SDLOS:
- case LCPOPT_PPPMUX:
- break;
-#endif
}
return len;
}
@@ -671,514 +364,183 @@ print_lcp_config_options(const u_char *p, int length)
static void
handle_chap(const u_char *p, int length)
{
- u_int code, len;
- int val_size, name_size, msg_size;
- const u_char *p0;
- int i;
+ int x;
+ const u_char *ptr;
- p0 = p;
- if (length < 1) {
- printf("[|chap]");
- return;
- } else if (length < 4) {
- printf("[|chap 0x%02x]", *p);
- return;
- }
+ x = p[4];
- code = *p;
- if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX))
- printf("%s", chapcode[code - 1]);
+ if ((x >= CHAP_CODEMIN) && (x <= CHAP_CODEMAX))
+ printf("%s", chapcode[x - 1]);
else {
- printf("0x%02x", code);
+ printf("0x%02x", x);
return;
}
- p++;
-
- printf("(%u)", *p); /* ID */
- p++;
- len = EXTRACT_16BITS(p);
- p += 2;
-
- /*
- * Note that this is a generic CHAP decoding routine. Since we
- * don't know which flavor of CHAP (i.e. CHAP-MD5, MS-CHAPv1,
- * MS-CHAPv2) is used at this point, we can't decode packet
- * specifically to each algorithms. Instead, we simply decode
- * the GCD (Gratest Common Denominator) for all algorithms.
- */
- switch (code) {
+ length -= 4;
+
+ switch (p[4]) {
case CHAP_CHAL:
case CHAP_RESP:
- if (length - (p - p0) < 1)
- return;
- val_size = *p; /* value size */
- p++;
- if (length - (p - p0) < val_size)
- return;
printf(", Value=");
- for (i = 0; i < val_size; i++)
- printf("%02x", *p++);
- name_size = len - (p - p0);
+ x = p[8]; /* value size */
+ ptr = p + 9;
+ while (--x >= 0)
+ printf("%02x", *ptr++);
+ x = length - p[8] - 1;
printf(", Name=");
- for (i = 0; i < name_size; i++)
- safeputchar(*p++);
- break;
- case CHAP_SUCC:
- case CHAP_FAIL:
- msg_size = len - (p - p0);
- printf(", Msg=");
- for (i = 0; i< msg_size; i++)
- safeputchar(*p++);
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\\%03o", *ptr);
+ ptr++;
+ }
break;
}
}
-/* PAP (see RFC 1334) */
+/* PAP */
static void
handle_pap(const u_char *p, int length)
{
- u_int code, len;
- int peerid_len, passwd_len, msg_len;
- const u_char *p0;
- int i;
+ int x;
+ const u_char *ptr;
- p0 = p;
- if (length < 1) {
- printf("[|pap]");
- return;
- } else if (length < 4) {
- printf("[|pap 0x%02x]", *p);
- return;
- }
+ x = p[4];
- code = *p;
- if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX))
- printf("%s", papcode[code - 1]);
+ if ((x >= PAP_CODEMIN) && (x <= PAP_CODEMAX))
+ printf("%s", papcode[x - 1]);
else {
- printf("0x%02x", code);
+ printf("0x%02x", x);
return;
}
- p++;
-
- printf("(%u)", *p); /* ID */
- p++;
-
- len = EXTRACT_16BITS(p);
- p += 2;
- switch (code) {
+ length -= 4;
+
+ switch (x) {
case PAP_AREQ:
- if (length - (p - p0) < 1)
- return;
- peerid_len = *p; /* Peer-ID Length */
- p++;
- if (length - (p - p0) < peerid_len)
- return;
- printf(", Peer=");
- for (i = 0; i < peerid_len; i++)
- safeputchar(*p++);
-
- if (length - (p - p0) < 1)
- return;
- passwd_len = *p; /* Password Length */
- p++;
- if (length - (p - p0) < passwd_len)
- return;
- printf(", Name=");
- for (i = 0; i < passwd_len; i++)
- safeputchar(*p++);
+ printf(", Peer-Id=");
+ x = p[8]; /* peerid size */
+ ptr = p + 9;
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\\%03o", *ptr);
+ ptr++;
+ }
+ x = *ptr++;
+ printf(", Passwd=");
+ while (--x >= 0) {
+ if (isprint(*ptr))
+ printf("%c", *ptr);
+ else
+ printf("\\%03o", *ptr);
+ ptr++;
+ }
break;
case PAP_AACK:
case PAP_ANAK:
- if (length - (p - p0) < 1)
- return;
- msg_len = *p; /* Msg-Length */
- p++;
- if (length - (p - p0) < msg_len)
- return;
- printf(", Msg=");
- for (i = 0; i< msg_len; i++)
- safeputchar(*p++);
break;
}
- return;
}
-/* BAP */
+/* IPCP */
static void
-handle_bap(const u_char *p, int length)
-{
- /* XXX: to be supported!! */
-}
-
-
-/* IPCP config options */
-static int
-print_ipcp_config_options(const u_char *p, int length)
+handle_ipcp(const u_char *p, int length)
{
- int len, opt;
-
- if (length < 2)
- return 0;
- len = p[1];
- opt = p[0];
- if (length < len)
- return 0;
- switch (opt) {
- case IPCPOPT_2ADDR: /* deprecated */
- if (len != 10)
- goto invlen;
- 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");
- if (EXTRACT_16BITS(p + 2) == PPP_VJC) {
- printf(" VJ-Comp");
- /* XXX: VJ-Comp parameters should be decoded */
- } else
- printf(" unknown-comp-proto=%04x", EXTRACT_16BITS(p + 2));
- break;
- case IPCPOPT_ADDR:
- if (len != 6)
- goto invlen;
- printf(", IP-Addr=%s", ipaddr_string(p + 2));
- break;
- case IPCPOPT_MOBILE4:
- if (len != 6)
- goto invlen;
- printf(", Home-Addr=%s", ipaddr_string(p + 2));
- break;
- case IPCPOPT_PRIDNS:
- if (len != 6)
- goto invlen;
- printf(", Pri-DNS=%s", ipaddr_string(p + 2));
+ length -= 4;
+
+ switch (p[8]) {
+ case IPCP_2ADDR:
+ printf("IP-Addresses");
+ printf(", src=%s", ipaddr_string(p + 10));
+ printf(", drc=%s", ipaddr_string(p + 14));
break;
- case IPCPOPT_PRINBNS:
- if (len != 6)
- goto invlen;
- printf(", Pri-NBNS=%s", ipaddr_string(p + 2));
+
+ case IPCP_CP:
+ printf("IP-Compression-Protocol");
break;
- case IPCPOPT_SECDNS:
- if (len != 6)
- goto invlen;
- printf(", Sec-DNS=%s", ipaddr_string(p + 2));
- break;
- case IPCPOPT_SECNBNS:
- if (len != 6)
- goto invlen;
- printf(", Sec-NBNS=%s", ipaddr_string(p + 2));
- break;
- default:
- printf(", unknown-%d", opt);
- break;
- }
- return len;
-
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-}
-/* CCP config options */
-static int
-print_ccp_config_options(const u_char *p, int length)
-{
- int len, opt;
-
- if (length < 2)
- return 0;
- len = p[1];
- opt = p[0];
- if (length < len)
- return 0;
- if ((opt >= CCPOPT_MIN) && (opt <= CCPOPT_MAX))
- printf(", %s", ccpconfopts[opt]);
-#if 0 /* XXX */
- switch (opt) {
- case CCPOPT_OUI:
- case CCPOPT_PRED1:
- case CCPOPT_PRED2:
- case CCPOPT_PJUMP:
- case CCPOPT_HPPPC:
- case CCPOPT_STACLZS:
- case CCPOPT_MPPC:
- case CCPOPT_GFZA:
- case CCPOPT_V42BIS:
- case CCPOPT_BSDCOMP:
- case CCPOPT_LZSDCP:
- case CCPOPT_MVRCA:
- case CCPOPT_DEC:
- case CCPOPT_DEFLATE:
- case CCPOPT_RESV:
- break;
-
- default:
- printf(", unknown-%d", opt);
+ case IPCP_ADDR:
+ printf("IP-Address=%s", ipaddr_string(p + 10));
break;
}
-#endif
- return len;
-}
-
-/* BACP config options */
-static int
-print_bacp_config_options(const u_char *p, int length)
-{
- int len, opt;
-
- if (length < 2)
- return 0;
- len = p[1];
- opt = p[0];
- if (length < len)
- return 0;
- if (opt == BACPOPT_FPEER) {
- printf(", Favored-Peer");
- printf(" Magic-Num=%08x", EXTRACT_32BITS(p + 2));
- } else {
- printf(", unknown-option-%d", opt);
- }
- return len;
}
-
-
-/* PPP */
-static void
-handle_ppp(u_int proto, const u_char *p, int length)
-{
- switch (proto) {
- case PPP_LCP:
- case PPP_IPCP:
- case PPP_CCP:
- case PPP_BACP:
- handle_ctrl_proto(proto, p, length);
- break;
- case PPP_CHAP:
- handle_chap(p, length);
- break;
- case PPP_PAP:
- handle_pap(p, length);
- break;
- case PPP_BAP: /* XXX: not yet completed */
- handle_bap(p, length);
- break;
- case ETHERTYPE_IP: /*XXX*/
- case PPP_IP:
- ip_print(p, length);
- break;
-#ifdef INET6
- case ETHERTYPE_IPV6: /*XXX*/
- case PPP_IPV6:
- ip6_print(p, length);
- break;
-#endif
- case ETHERTYPE_IPX: /*XXX*/
- case PPP_IPX:
- ipx_print(p, length);
- break;
- }
-}
-
+
/* Standard PPP printer */
void
-ppp_print(register const u_char *p, u_int length)
-{
- u_int proto;
- u_int full_length = length;
-
- /*
- * Here, we assume that p points to the Address and Control
- * field (if they present).
- */
- if (length < 2)
- goto trunc;
- if (*p == PPP_ADDRESS && *(p + 1) == PPP_CONTROL) {
- p += 2; /* ACFC not used */
- length -= 2;
- }
-
- if (length < 2)
- goto trunc;
- if (*p % 2) {
- proto = *p; /* PFC is used */
- p++;
- length--;
- } else {
- proto = EXTRACT_16BITS(p);
- p += 2;
- length -= 2;
- }
-
- printf("%s %d: ", ppp_protoname(proto), full_length);
-
- handle_ppp(proto, p, length);
- return;
-trunc:
- printf("[|ppp]");
-}
-
-
-/* PPP I/F printer */
-void
ppp_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;
+ const struct ip *ip;
+ u_int proto;
ts_print(&h->ts);
if (caplen < PPP_HDRLEN) {
- printf("[|ppp]");
- goto out;
+ puts("[|ppp]");
+ return;
}
/*
* 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. */
-
+ * Rather than pass them all the way down, we set these globals.
+ */
+ proto = ntohs(*(u_short *)&p[2]);
packetp = p;
snapend = p + caplen;
-#if 0
- /*
- * XXX: seems to assume that there are 2 octets prepended to an
- * actual PPP frame. The 1st octet looks like Input/Output flag
- * while 2nd octet is unknown, at least to me
- * (mshindo@mshindo.net).
- *
- * That was what the original tcpdump code did.
- *
- * FreeBSD's "if_ppp.c" *does* set the first octet to 1 for outbound
- * packets and 0 for inbound packets - but only if the
- * protocol field has the 0x8000 bit set (i.e., it's a network
- * control protocol); it does so before running the packet through
- * "bpf_filter" to see if it should be discarded, and to see
- * if we should update the time we sent the most recent packet...
- *
- * ...but it puts the original address field back after doing
- * so.
- *
- * NetBSD's "if_ppp.c" doesn't set the first octet in that fashion.
- *
- * I don't know if any PPP implementation handed up to a BPF
- * device packets with the first octet being 1 for outbound and
- * 0 for inbound packets, so I (guy@alum.mit.edu) don't know
- * whether that ever needs to be checked or not.
- *
- * Note that NetBSD has a DLT_PPP_SERIAL, which it uses for PPP,
- * and its tcpdump appears to assume that the frame always
- * begins with an address field and a control field, and that
- * the address field might be 0x0f or 0x8f, for Cisco
- * point-to-point with HDLC framing as per section 4.3.1 of RFC
- * 1547, as well as 0xff, for PPP in HDLC-like framing as per
- * RFC 1662.
- *
- * (Is the Cisco framing in question what DLT_C_HDLC, in
- * BSD/OS, is?)
- */
- if (eflag)
- printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
-#endif
-
- ppp_print(p, length);
-
- if (xflag)
- default_print(p, caplen);
-out:
- putchar('\n');
+ do_ppp_print(p, length, caplen);
}
/*
- * PPP I/F printer to use if we know that RFC 1662-style PPP in HDLC-like
- * framing, or Cisco PPP with HDLC framing as per section 4.3.1 of RFC 1547,
- * is being used (i.e., we don't check for PPP_ADDRESS and PPP_CONTROL,
- * discard them *if* those are the first two octets, and parse the remaining
- * packet as a PPP packet, as "ppp_print()" does).
- *
- * This handles, for example, DLT_PPP_SERIAL in NetBSD.
+ * Actually do the job
*/
-void
-ppp_hdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
- register const u_char *p)
+static void
+do_ppp_print(const u_char *p, u_int length, u_int caplen)
{
- register u_int length = h->len;
- register u_int caplen = h->caplen;
- u_int proto;
-
- if (caplen < 2) {
- printf("[|ppp]");
- goto out;
- }
-
- /*
- * 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;
-
- switch (p[0]) {
-
- case PPP_ADDRESS:
- if (caplen < 4) {
- printf("[|ppp]");
- goto out;
- }
-
- ts_print(&h->ts);
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
- p += 2;
- length -= 2;
+ if (eflag)
+ ppp_hdlc_print(p, length);
- proto = EXTRACT_16BITS(p);
- p += 2;
- length -= 2;
- printf("%s: ", ppp_protoname(proto));
+ length -= PPP_HDRLEN;
- handle_ppp(proto, p, length);
+ switch(PPP_PROTOCOL(p)) {
+ case PPP_IP:
+ case ETHERTYPE_IP:
+ ip_print((const u_char *)(p + PPP_HDRLEN), length);
break;
-
- case CHDLC_UNICAST:
- case CHDLC_BCAST:
- /*
- * Have the Cisco HDLC print routine do all the work.
- */
- chdlc_if_print(user, h, p);
- return;
+ case PPP_IPX:
+ case ETHERTYPE_IPX:
+ ipx_print((const u_char *)(p + PPP_HDRLEN), length);
+ break;
+#ifdef INET6
+ case ETHERTYPE_IPV6: /*XXX*/
+#ifdef PPP_IPV6
+ case PPP_IPV6:
+#endif
+ ip6_print((const u_char *)(p + PPP_HDRLEN), length);
+ break;
+#endif
default:
- ts_print(&h->ts);
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
- p += 2;
- length -= 2;
-
- /*
- * XXX - NetBSD's "ppp_netbsd_serial_if_print()" treats
- * the next two octets as an Ethernet type; does that
- * ever happen?
- */
- printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
- break;
+ if(!eflag)
+ ppp_hdlc_print(p, length);
+ if(!xflag)
+ default_print((const u_char *)(p + PPP_HDRLEN),
+ caplen - PPP_HDRLEN);
}
if (xflag)
- default_print(p, caplen);
+ default_print((const u_char *)(p + PPP_HDRLEN),
+ caplen - PPP_HDRLEN);
out:
putchar('\n');
}
-
-
struct tok ppptype2str[] = {
{ PPP_IP, "IP" },
{ PPP_OSI, "OSI" },
@@ -1199,18 +561,15 @@ struct tok ppptype2str[] = {
{ PPP_OSICP, "OSICP" },
{ PPP_NSCP, "NSCP" },
{ PPP_DECNETCP, "DECNETCP" },
- { PPP_APPLECP, "APPLECP" },
+ { PPP_APPLECP, "APPLECP" },
{ PPP_IPXCP, "IPXCP" },
{ PPP_STIICP, "STIICP" },
- { PPP_VINESCP, "VINESCP" },
+ { PPP_VINESCP, "VINESCP" },
{ PPP_LCP, "LCP" },
{ PPP_PAP, "PAP" },
{ PPP_LQM, "LQM" },
{ PPP_CHAP, "CHAP" },
- { PPP_BACP, "BACP" },
- { PPP_BAP, "BAP" },
- { PPP_MP, "MP" },
{ 0, NULL }
};
@@ -1225,7 +584,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
register u_int length = h->len;
register u_int caplen = h->caplen;
register int hdrlength;
- u_int16_t ptype;
+ u_short ptype;
const u_char *q;
int i;
@@ -1247,26 +606,26 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", p[0], p[1]);
p += 2;
hdrlength = 2;
}
- if (eflag)
+ if (eflag)
printf("%d ", length);
/* Retrieve the protocol type */
if (*p & 01) {
/* Compressed protocol field */
ptype = *p;
- if (eflag)
+ if (eflag)
printf("%02x ", ptype);
p++;
hdrlength += 1;
} else {
/* Un-compressed protocol field */
- ptype = ntohs(*(u_int16_t *)p);
- if (eflag)
+ ptype = ntohs(*(u_short *)p);
+ if (eflag)
printf("%04x ", ptype);
p += 2;
hdrlength += 2;
@@ -1283,7 +642,7 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
ph = (struct ppp_header *)q;
if (ph->phdr_addr == PPP_ADDRESS
&& ph->phdr_ctl == PPP_CONTROL) {
- if (eflag)
+ if (eflag)
printf("%02x %02x ", q[0], q[1]);
ptype = ntohs(ph->phdr_type);
if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
@@ -1298,9 +657,9 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
printf("] ");
}
}
+ if (eflag)
+ printf("%d ", length);
}
- if (eflag)
- printf("%d ", length);
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
@@ -1309,31 +668,15 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
ptype = vjc_print(q, length - (q - p), ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
- switch (ptype) {
- case PPP_IP:
+ if (ptype == PPP_IP)
ip_print(p, length);
- break;
-#ifdef INET6
- case PPP_IPV6:
- ip6_print(p, length);
- break;
-#endif
- }
goto printx;
case PPP_VJNC:
ptype = vjc_print(q, length - (q - p), ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
- switch (ptype) {
- case PPP_IP:
+ if (ptype == PPP_IP)
ip_print(p, length);
- break;
-#ifdef INET6
- case PPP_IPV6:
- ip6_print(p, length);
- break;
-#endif
- }
goto printx;
default:
if (eflag) {
@@ -1352,18 +695,10 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
length -= hdrlength;
p += hdrlength;
- switch (ptype) {
- case PPP_IP:
+ if (ptype == PPP_IP)
ip_print(p, length);
- break;
-#ifdef INET6
- case PPP_IPV6:
- ip6_print(p, length);
- break;
-#endif
- default:
+ else
printf("%s ", tok2str(ppptype2str, "proto-#%d", ptype));
- }
printx:
if (xflag)
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index c89a9a3..c2f622b 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -17,21 +17,43 @@
* 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.56 2000/10/10 05:06:10 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.46 1999/11/21 12:38:24 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#ifdef HAVE_NET_SLIP_H
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/timeb.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+
+#if __STDC__
+struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <net/ethernet.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/tcp.h>
+
+#include <net/slcompress.h>
+#include <net/slip.h>
#include <ctype.h>
#include <netdb.h>
@@ -42,17 +64,22 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "extract.h" /* must come after interface.h */
-#include "ip.h"
-#include "tcp.h"
-#include "slip.h"
-#include "slcompress.h"
-
static u_int lastlen[2][256];
static u_int lastconn = 255;
static void sliplink_print(const u_char *, const struct ip *, u_int);
static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
+/* XXX BSD/OS 2.1 compatibility */
+#if !defined(SLIP_HDRLEN) && defined(SLC_BPFHDR)
+#define SLIP_HDRLEN SLC_BPFHDR
+#define SLX_DIR 0
+#define SLX_CHDR (SLC_BPFHDRLEN - 1)
+#define CHDR_LEN (SLC_BPFHDR - SLC_BPFHDRLEN)
+#endif
+
+/* XXX needs more hacking to work right */
+
void
sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
@@ -81,7 +108,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
if (eflag)
sliplink_print(p, ip, length);
- switch (IP_V(ip)) {
+ switch (ip->ip_v) {
case 4:
ip_print((u_char *)ip, length);
break;
@@ -91,7 +118,7 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
break;
#endif
default:
- printf ("ip v%d", IP_V(ip));
+ printf ("ip v%d", ip->ip_v);
}
if (xflag)
@@ -172,8 +199,8 @@ sliplink_print(register const u_char *p, register const struct ip *ip,
* has restored the IP header copy to IPPROTO_TCP.
*/
lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p;
- hlen = IP_HL(ip);
- hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]);
+ hlen = ip->ip_hl;
+ hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off;
lastlen[dir][lastconn] = length - (hlen << 2);
printf("utcp %d: ", lastconn);
break;
@@ -262,8 +289,33 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
* 'cp - chdr' is the length of the compressed header.
* 'length - hlen' is the amount of data in the packet.
*/
- hlen = IP_HL(ip);
- hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]);
+ hlen = ip->ip_hl;
+ hlen += ((struct tcphdr *)&((int32_t *)ip)[hlen])->th_off;
lastlen[dir][lastconn] = length - (hlen << 2);
- printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr));
+ printf(" %d (%d)", lastlen[dir][lastconn], cp - chdr);
+}
+#else
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <pcap.h>
+#include <stdio.h>
+
+#include "interface.h"
+
+void
+sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+
+ error("not configured for slip");
+ /* NOTREACHED */
}
+
+void
+sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+
+ error("not configured for slip");
+ /* NOTREACHED */
+}
+#endif
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 7ab39d0..ddac913 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.39 2000/10/07 05:53:13 itojun Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.29 1999/11/21 09:37:02 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -32,10 +34,17 @@ static const char rcsid[] =
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
struct mbuf;
struct rtentry;
+#endif
+#include <net/if.h>
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
#include <rpc/rpc.h>
#ifdef HAVE_RPC_RPCENT_H
@@ -51,11 +60,6 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
-
static struct tok proc2str[] = {
{ PMAPPROC_NULL, "null" },
{ PMAPPROC_SET, "set" },
@@ -75,44 +79,24 @@ sunrpcrequest_print(register const u_char *bp, register u_int length,
{
register const struct rpc_msg *rp;
register const struct ip *ip;
-#ifdef INET6
- register const struct ip6_hdr *ip6;
-#endif
u_int32_t x;
- char srcid[20], dstid[20]; /*fits 32bit*/
rp = (struct rpc_msg *)bp;
-
- if (!nflag) {
- snprintf(srcid, sizeof(srcid), "0x%x",
- (u_int32_t)ntohl(rp->rm_xid));
- strlcpy(dstid, "sunrpc", sizeof(dstid));
- } else {
- snprintf(srcid, sizeof(srcid), "0x%x",
- (u_int32_t)ntohl(rp->rm_xid));
- snprintf(dstid, sizeof(dstid), "0x%x", PMAPPORT);
- }
-
- switch (IP_V((struct ip *)bp2)) {
- case 4:
- ip = (struct ip *)bp2;
- printf("%s.%s > %s.%s: %d",
- ipaddr_string(&ip->ip_src), srcid,
- ipaddr_string(&ip->ip_dst), dstid, length);
- break;
-#ifdef INET6
- case 6:
- ip6 = (struct ip6_hdr *)bp2;
- printf("%s.%s > %s.%s: %d",
- ip6addr_string(&ip6->ip6_src), srcid,
- ip6addr_string(&ip6->ip6_dst), dstid, length);
- break;
-#endif
- default:
- printf("%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length);
- break;
- }
-
+ ip = (struct ip *)bp2;
+
+ if (!nflag)
+ (void)printf("%s.%x > %s.sunrpc: %d",
+ ipaddr_string(&ip->ip_src),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ipaddr_string(&ip->ip_dst),
+ length);
+ else
+ (void)printf("%s.%x > %s.%x: %d",
+ ipaddr_string(&ip->ip_src),
+ (u_int32_t)ntohl(rp->rm_xid),
+ ipaddr_string(&ip->ip_dst),
+ PMAPPORT,
+ length);
printf(" %s", tok2str(proc2str, " proc #%u",
(u_int32_t)ntohl(rp->rm_call.cb_proc)));
x = ntohl(rp->rm_call.cb_rpcvers);
@@ -147,8 +131,10 @@ progstr(prog)
return (buf);
rp = getrpcbynumber(prog);
if (rp == NULL)
- (void) snprintf(buf, sizeof(buf), "#%u", prog);
- else
- strlcpy(buf, rp->r_name, sizeof(buf));
+ (void) sprintf(buf, "#%u", prog);
+ else {
+ strncpy(buf, rp->r_name, sizeof(buf)-1);
+ buf[sizeof(buf)-1] = '\0';
+ }
return (buf);
}
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c
index aff3607..0edbf2f 100644
--- a/contrib/tcpdump/print-token.c
+++ b/contrib/tcpdump/print-token.c
@@ -20,90 +20,85 @@
*
* Hacked version of print-ether.c Larry Lile <lile@stdio.com>
*
- * Further tweaked to more closely resemble print-fddi.c
- * Guy Harris <guy@alum.mit.edu>
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.11 2000/12/23 20:48:13 guy Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+ "@(#) $Header: /home/ncvs/src/contrib/tcpdump/print-token.c,v 1.1 1999/02/20 11:17:55 julian Exp $";
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+
+#include "token.h"
+
#include <netinet/in.h>
+#include <net/ethernet.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcpip.h>
-#include <pcap.h>
#include <stdio.h>
-#include <string.h>
+#include <pcap.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "llc.h"
-#include "ether.h"
-#include "token.h"
-
-/* Extract src, dst addresses */
-static inline void
-extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst)
-{
- memcpy(fdst, (char *)trp->token_dhost, 6);
- memcpy(fsrc, (char *)trp->token_shost, 6);
-}
+const u_char *packetp;
+const u_char *snapend;
-/*
- * Print the TR MAC header
- */
static inline void
-token_print(register const struct token_header *trp, register u_int length,
- register const u_char *fsrc, register const u_char *fdst)
+token_print(register const u_char *bp, u_int length)
{
- char *srcname, *dstname;
-
- srcname = etheraddr_string(fsrc);
- dstname = etheraddr_string(fdst);
-
- if (vflag)
- (void) printf("%02x %02x %s %s %d: ",
- trp->token_ac,
- trp->token_fc,
- srcname, dstname,
- length);
+ register const struct token_header *tp;
+ register const struct llc *lp;
+ u_short ether_type;
+
+ tp = (const struct token_header *)bp;
+ lp = (struct llc *)(bp + TOKEN_HDR_LEN);
+
+ if (IS_SOURCE_ROUTED) {
+ tp->ether_shost[0] = tp->ether_shost[0] & 0x7f;
+ lp = (struct llc *)(bp + TOKEN_HDR_LEN + RIF_LENGTH);
+ }
+
+ /*
+ * Ethertype on ethernet is a short, but ethertype in an llc-snap has
+ * been defined as 2 u_chars. This is a stupid little hack to fix
+ * this for now but something better should be done using ntohs()
+ * XXX
+ */
+ ether_type = ((u_short)lp->ethertype[1] << 16) | lp->ethertype[0];
+
+ if (qflag)
+ (void)printf("%s %s %d: ",
+ etheraddr_string(ESRC(tp)),
+ etheraddr_string(EDST(tp)),
+ length);
else
- printf("%s %s %d: ", srcname, dstname, length);
+ (void)printf("%s %s %s %d: ",
+ etheraddr_string(ESRC(tp)),
+ etheraddr_string(EDST(tp)),
+ etherproto_string(ether_type),
+ length);
}
-static char *broadcast_indicator[] = {
- "Non-Broadcast", "Non-Broadcast",
- "Non-Broadcast", "Non-Broadcast",
- "All-routes", "All-routes",
- "Single-route", "Single-route"
-};
-
-static char *direction[] = {
- "Forward", "Backward"
-};
-
-static char *largest_frame[] = {
- "516",
- "1500",
- "2052",
- "4472",
- "8144",
- "11407",
- "17800",
- "??"
-};
-
/*
* This is the top level routine of the printer. 'p' is the points
- * to the TR header of the packet, 'tvp' is the timestamp,
+ * to the ether header of the packet, 'tvp' is the timestamp,
* 'length' is the length of the packet off the wire, and 'caplen'
* is the number of bytes actually captured.
*/
@@ -112,99 +107,83 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- struct token_header *trp;
+ struct token_header *tp;
+ u_short ether_type;
u_short extracted_ethertype;
- struct ether_header ehdr;
- u_int route_len = 0, seg;
+ u_int route_len = 0, seg;
+ struct llc *lp;
- trp = (struct token_header *)p;
+ tp = (struct token_header *)p;
ts_print(&h->ts);
- if (caplen < TOKEN_HDRLEN) {
+ if (caplen < TOKEN_HDR_LEN) {
printf("[|token-ring]");
goto out;
}
- /*
- * Get the TR addresses into a canonical form
- */
- extract_token_addrs(trp, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
+
/*
* Some printers want to get back at the ethernet 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.
*/
- snapend = p + caplen;
- /*
- * Actually, the only printers that use packetp are print-arp.c
- * and print-bootp.c, and they assume that packetp points to an
- * Ethernet header. The right thing to do is to fix them to know
- * which link type is in use when they excavate. XXX
- */
- packetp = (u_char *)&ehdr;
-
- /* Adjust for source routing information in the MAC header */
- if (IS_SOURCE_ROUTED(trp)) {
- /* Clear source-routed bit */
- *ESRC(&ehdr) &= 0x7f;
-
- if (eflag)
- token_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
-
- route_len = RIF_LENGTH(trp);
- if (vflag) {
- printf("%s ", broadcast_indicator[BROADCAST(trp)]);
- printf("%s", direction[DIRECTION(trp)]);
+ tp = (struct token_header *)p;
+
+ /* Adjust for source routing information in the MAC header */
+ if (IS_SOURCE_ROUTED) {
+
+ if (eflag)
+ token_print(p, length);
+
+ route_len = RIF_LENGTH;
+ if (vflag) {
+ if (vflag > 1)
+ printf("ac %x fc %x ", tp->ac, tp->fc);
+ ether_type = ntohs((int)lp->ethertype);
+
+ printf("%s ", broadcast_indicator[BROADCAST]);
+ printf("%s", direction[DIRECTION]);
- for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(" [%d:%d]", RING_NUMBER(trp, seg),
- BRIDGE_NUMBER(trp, seg));
- } else {
- printf("rt = %x", ntohs(trp->token_rcf));
+ for (seg = 0; seg < SEGMENT_COUNT; seg++)
+ printf(" [%d:%d]", RING_NUMBER(seg), BRIDGE_NUMBER(seg));
+ } else {
+ printf("rt = %x", ntohs(tp->rcf));
- for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(":%x", ntohs(trp->token_rseg[seg]));
- }
- printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
- } else {
- if (eflag)
- token_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
- }
+ for (seg = 0; seg < SEGMENT_COUNT; seg++)
+ printf(":%x", ntohs(tp->rseg[seg]));
+ }
+ printf(" (%s) ", largest_frame[LARGEST_FRAME]);
+ } else {
+ if (eflag)
+ token_print(p, length);
+ }
+
+ /* Set pointer to llc header, adjusted for routing information */
+ lp = (struct llc *)(p + TOKEN_HDR_LEN + route_len);
+
+ packetp = p;
+ snapend = p + caplen;
- /* Skip over token ring MAC header and routing information */
- length -= TOKEN_HDRLEN + route_len;
- p += TOKEN_HDRLEN + route_len;
- caplen -= TOKEN_HDRLEN + route_len;
+ /* Skip over token ring MAC header */
+ length -= TOKEN_HDR_LEN + route_len;
+ caplen -= TOKEN_HDR_LEN + route_len;
+ p += TOKEN_HDR_LEN + route_len;
- /* Frame Control field determines interpretation of packet */
extracted_ethertype = 0;
- if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
- /* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- token_print(trp,
- length + TOKEN_HDRLEN + route_len,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!xflag && !qflag)
- default_print(p, caplen);
- }
- } else {
- /* Some kinds of TR packet we cannot handle intelligently */
- /* XXX - dissect MAC packets if frame type is 0 */
+ /* Try to print the LLC-layer header & higher layers */
+ if (llc_print(p, length, caplen, ESRC(tp), EDST(tp)) == 0) {
+ /* ether_type not known, print raw packet */
if (!eflag)
- token_print(trp, length + TOKEN_HDRLEN + route_len,
- ESRC(&ehdr), EDST(&ehdr));
+ token_print((u_char *)tp, length);
+ if (extracted_ethertype) {
+ printf("(LLC %s) ",
+ etherproto_string(htons(extracted_ethertype)));
+ }
if (!xflag && !qflag)
default_print(p, caplen);
}
if (xflag)
default_print(p, caplen);
-out:
+ out:
putchar('\n');
}
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 70daef1..9a64fb3 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[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.90 2000/12/23 20:55:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.70 1999/12/22 06:27:23 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -30,9 +32,22 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+#ifdef NOERROR
+#undef NOERROR /* Solaris sucks */
+#endif
+#ifdef T_UNSPEC
+#undef T_UNSPEC /* SINIX does too */
+#endif
+#include <arpa/nameser.h>
#ifdef SEGSIZE
#undef SEGSIZE
#endif
@@ -41,38 +56,27 @@ static const char rcsid[] =
#include <rpc/rpc.h>
#include <stdio.h>
-#include <string.h>
+
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
#include "interface.h"
#include "addrtoname.h"
#include "appletalk.h"
-#include "udp.h"
-
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
-
-#ifdef NOERROR
-#undef NOERROR /* Solaris sucks */
-#endif
-#ifdef T_UNSPEC
-#undef T_UNSPEC /* SINIX does too */
-#endif
-#include "nameser.h"
#include "nfs.h"
#include "bootp.h"
struct rtcphdr {
- u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
- u_int16_t rh_len; /* length of message (in words) */
- u_int32_t rh_ssrc; /* synchronization src id */
+ u_short rh_flags; /* T:2 P:1 CNT:5 PT:8 */
+ u_short rh_len; /* length of message (in words) */
+ u_int rh_ssrc; /* synchronization src id */
};
typedef struct {
- u_int32_t upper; /* more significant 32 bits */
- u_int32_t lower; /* less significant 32 bits */
+ u_int upper; /* more significant 32 bits */
+ u_int lower; /* less significant 32 bits */
} ntp64;
/*
@@ -80,9 +84,9 @@ typedef struct {
*/
struct rtcp_sr {
ntp64 sr_ntp; /* 64-bit ntp timestamp */
- u_int32_t sr_ts; /* reference media timestamp */
- u_int32_t sr_np; /* no. packets sent */
- u_int32_t sr_nb; /* no. bytes sent */
+ u_int sr_ts; /* reference media timestamp */
+ u_int sr_np; /* no. packets sent */
+ u_int sr_nb; /* no. bytes sent */
};
/*
@@ -90,12 +94,12 @@ struct rtcp_sr {
* Time stamps are middle 32-bits of ntp timestamp.
*/
struct rtcp_rr {
- u_int32_t rr_srcid; /* sender being reported */
- u_int32_t rr_nl; /* no. packets lost */
- u_int32_t rr_ls; /* extended last seq number received */
- u_int32_t rr_dv; /* jitter (delay variance) */
- u_int32_t rr_lsr; /* orig. ts from last rr from this src */
- u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
+ u_int rr_srcid; /* sender being reported */
+ u_int rr_nl; /* no. packets lost */
+ u_int rr_ls; /* extended last seq number received */
+ u_int rr_dv; /* jitter (delay variance) */
+ u_int rr_lsr; /* orig. ts from last rr from this src */
+ u_int rr_dlsr; /* time from recpt of last rr to xmit time */
};
/*XXX*/
@@ -117,7 +121,7 @@ static void
vat_print(const void *hdr, u_int len, register const struct udphdr *up)
{
/* vat/vt audio */
- u_int ts = *(u_int16_t *)hdr;
+ u_int ts = *(u_short *)hdr;
if ((ts & 0xf060) != 0) {
/* probably vt */
(void)printf(" udp/vt %u %d / %d",
@@ -125,8 +129,8 @@ vat_print(const void *hdr, u_int len, register const struct udphdr *up)
ts & 0x3ff, ts >> 10);
} else {
/* probably vat */
- u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
- u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
+ u_int i0 = ntohl(((u_int *)hdr)[0]);
+ u_int i1 = ntohl(((u_int *)hdr)[1]);
printf(" udp/vat %u c%d %u%s",
(u_int32_t)(ntohs(up->uh_ulen) - sizeof(*up) - 8),
i0 & 0xffff,
@@ -145,8 +149,8 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
/* rtp v1 or v2 */
u_int *ip = (u_int *)hdr;
u_int hasopt, hasext, contype, hasmarker;
- u_int32_t i0 = (u_int32_t)ntohl(((u_int *)hdr)[0]);
- u_int32_t i1 = (u_int32_t)ntohl(((u_int *)hdr)[1]);
+ u_int i0 = ntohl(((u_int *)hdr)[0]);
+ u_int i1 = ntohl(((u_int *)hdr)[1]);
u_int dlen = ntohs(up->uh_ulen) - sizeof(*up) - 8;
const char * ptype;
@@ -180,7 +184,7 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
i0 & 0xffff,
i1);
if (vflag) {
- printf(" %u", (u_int32_t)ntohl(((u_int *)hdr)[2]));
+ printf(" %u", i1);
if (hasopt) {
u_int i2, optlen;
do {
@@ -217,7 +221,7 @@ rtcp_print(const u_char *hdr, const u_char *ep)
struct rtcp_sr *sr;
struct rtcphdr *rh = (struct rtcphdr *)hdr;
u_int len;
- u_int16_t flags;
+ u_short flags;
int cnt;
double ts, dts;
if ((u_char *)(rh + 1) > ep) {
@@ -234,7 +238,7 @@ rtcp_print(const u_char *hdr, const u_char *ep)
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
printf(" [%d]", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
if ((u_char *)(sr + 1) > ep) {
printf(" [|rtcp]");
return (ep);
@@ -252,18 +256,18 @@ rtcp_print(const u_char *hdr, const u_char *ep)
printf(" [%d]", len);
rr = (struct rtcp_rr *)(rh + 1);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
break;
case RTCP_PT_SDES:
printf(" sdes %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
case RTCP_PT_BYE:
printf(" bye %d", len);
if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
default:
@@ -290,100 +294,6 @@ rtcp_print(const u_char *hdr, const u_char *ep)
return (hdr + len);
}
-static int udp_cksum(register const struct ip *ip,
- register const struct udphdr *up,
- register int len)
-{
- int i, tlen;
- union phu {
- struct phdr {
- u_int32_t src;
- u_int32_t dst;
- u_char mbz;
- u_char proto;
- u_int16_t len;
- } ph;
- u_int16_t pa[6];
- } phu;
- register const u_int16_t *sp;
- u_int32_t sum;
- tlen = ntohs(ip->ip_len) - ((const char *)up-(const char*)ip);
-
- /* pseudo-header.. */
- phu.ph.len = htons(tlen);
- phu.ph.mbz = 0;
- phu.ph.proto = IPPROTO_UDP;
- memcpy(&phu.ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
- memcpy(&phu.ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
-
- sp = &phu.pa[0];
- sum = sp[0]+sp[1]+sp[2]+sp[3]+sp[4]+sp[5];
-
- sp = (const u_int16_t *)up;
-
- for (i=0; i<(tlen&~1); i+= 2)
- sum += *sp++;
-
- if (tlen & 1) {
- sum += htons( (*(const u_int8_t *)sp) << 8);
- }
-
- while (sum > 0xffff)
- sum = (sum & 0xffff) + (sum >> 16);
- sum = ~sum & 0xffff;
-
- return (sum);
-}
-
-#ifdef INET6
-static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
- int len)
-{
- int i, tlen;
- register const u_int16_t *sp;
- u_int32_t sum;
- union {
- struct {
- struct in6_addr ph_src;
- struct in6_addr ph_dst;
- u_int32_t ph_len;
- u_int8_t ph_zero[3];
- u_int8_t ph_nxt;
- } ph;
- u_int16_t pa[20];
- } phu;
-
- tlen = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr) -
- ((const char *)up - (const char*)ip6);
-
- /* pseudo-header */
- memset(&phu, 0, sizeof(phu));
- phu.ph.ph_src = ip6->ip6_src;
- phu.ph.ph_dst = ip6->ip6_dst;
- phu.ph.ph_len = htonl(tlen);
- phu.ph.ph_nxt = IPPROTO_UDP;
-
- sum = 0;
- for (i = 0; i < sizeof(phu.pa) / sizeof(phu.pa[0]); i++)
- sum += phu.pa[i];
-
- sp = (const u_int16_t *)up;
-
- for (i = 0; i < (tlen & ~1); i += 2)
- sum += *sp++;
-
- if (tlen & 1)
- sum += htons((*(const u_int8_t *)sp) << 8);
-
- while (sum > 0xffff)
- sum = (sum & 0xffff) + (sum >> 16);
- sum = ~sum & 0xffff;
-
- return (sum);
-}
-#endif
-
-
/* XXX probably should use getservbyname() and cache answers */
#define TFTP_PORT 69 /*XXX*/
#define KERBEROS_PORT 88 /*XXX*/
@@ -392,7 +302,6 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
#define NTP_PORT 123 /*XXX*/
#define SNMPTRAP_PORT 162 /*XXX*/
#define ISAKMP_PORT 500 /*XXX*/
-#define TIMED_PORT 525 /*XXX*/
#define RIP_PORT 520 /*XXX*/
#define KERBEROS_SEC_PORT 750 /*XXX*/
#define L2TP_PORT 1701 /*XXX*/
@@ -403,10 +312,6 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
#define NETBIOS_NS_PORT 137
#define NETBIOS_DGRAM_PORT 138
#define CISCO_AUTORP_PORT 496 /*XXX*/
-#define RADIUS_PORT 1645
-#define RADIUS_NEW_PORT 1812
-#define RADIUS_ACCOUNTING_PORT 1646
-#define RADIUS_NEW_ACCOUNTING_PORT 1813
#ifdef INET6
#define RIPNG_PORT 521 /*XXX*/
@@ -415,14 +320,13 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
#endif
void
-udp_print(register const u_char *bp, u_int length,
- register const u_char *bp2, int fragmented)
+udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
{
register const struct udphdr *up;
register const struct ip *ip;
register const u_char *cp;
register const u_char *ep = bp + length;
- u_int16_t sport, dport, ulen;
+ u_short sport, dport, ulen;
#ifdef INET6
register const struct ip6_hdr *ip6;
#endif
@@ -432,7 +336,7 @@ udp_print(register const u_char *bp, u_int length,
up = (struct udphdr *)bp;
ip = (struct ip *)bp2;
#ifdef INET6
- if (IP_V(ip) == 6)
+ if (ip->ip_v == 6)
ip6 = (struct ip6_hdr *)bp2;
else
ip6 = NULL;
@@ -454,13 +358,6 @@ udp_print(register const u_char *bp, u_int length,
sport = ntohs(up->uh_sport);
dport = ntohs(up->uh_dport);
ulen = ntohs(up->uh_ulen);
- if (ulen < 8) {
- (void)printf("%s > %s: truncated-udplength %d",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst),
- ulen);
- return;
- }
if (packettype) {
register struct rpc_msg *rp;
enum msg_type direction;
@@ -523,15 +420,6 @@ udp_print(register const u_char *bp, u_int length,
udpport_string(dport));
snmp_print((const u_char *)(up + 1), length);
break;
-
- case PT_CNFP:
- (void)printf("%s.%s > %s.%s:",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
- cnfp_print(cp, length, (const u_char *)ip);
- break;
}
return;
}
@@ -565,7 +453,7 @@ udp_print(register const u_char *bp, u_int length,
(atalk_port(sport) || atalk_port(dport))) {
if (vflag)
fputs("kip ", stdout);
- llap_print(cp, length);
+ atalk_print(cp, length);
return;
}
}
@@ -602,38 +490,10 @@ udp_print(register const u_char *bp, u_int length,
}
#endif
- if (IP_V(ip) == 4 && vflag && !fragmented) {
- int sum = up->uh_sum;
- if (sum == 0) {
- (void)printf(" [no cksum]");
- } else if (TTEST2(cp[0], length)) {
- sum = udp_cksum(ip, up, length);
- if (sum != 0)
- (void)printf(" [bad udp cksum %x!]", sum);
- else
- (void)printf(" [udp sum ok]");
- }
- }
-#ifdef INET6
- if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !fragmented) {
- int sum = up->uh_sum;
- /* for IPv6, UDP checksum is mandatory */
- if (TTEST2(cp[0], length)) {
- sum = udp6_cksum(ip6, up, length);
- if (sum != 0)
- (void)printf(" [bad udp cksum %x!]", sum);
- else
- (void)printf(" [udp sum ok]");
- }
- }
-#endif
-
if (!qflag) {
#define ISPORT(p) (dport == (p) || sport == (p))
if (ISPORT(NAMESERVER_PORT))
ns_print((const u_char *)(up + 1), length);
- else if (ISPORT(TIMED_PORT))
- timed_print((const u_char *)(up + 1), length);
else if (ISPORT(TFTP_PORT))
tftp_print((const u_char *)(up + 1), length);
else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
@@ -686,11 +546,6 @@ udp_print(register const u_char *bp, u_int length,
wb_print((const void *)(up + 1), length);
else if (ISPORT(CISCO_AUTORP_PORT))
cisco_autorp_print((const void *)(up + 1), length);
- else if (ISPORT(RADIUS_PORT) ||
- ISPORT(RADIUS_NEW_PORT) ||
- ISPORT(RADIUS_ACCOUNTING_PORT) ||
- ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
- radius_print((const u_char *)(up+1), length);
else
(void)printf(" udp %u",
(u_int32_t)(ulen - sizeof(*up)));
diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1
index e639407..500bb00 100644
--- a/contrib/tcpdump/tcpdump.1
+++ b/contrib/tcpdump/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.92.2.2 2001/01/18 04:38:31 guy Exp $ (LBL)
+.\" @(#) $Header: /tcpdump/master/tcpdump/tcpdump.1,v 1.72.2.2 2000/01/29 16:42:03 itojun Exp $ (LBL)
.\"
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@@ -20,7 +20,9 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "3 January 2001"
+.\" $FreeBSD$
+.\"
+.TH TCPDUMP 1 "30 June 1997"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@@ -66,10 +68,6 @@ tcpdump \- dump traffic on a network
.br
.ti +8
[
-.B \-E
-.I algo:secret
-]
-[
.I expression
]
.br
@@ -87,7 +85,7 @@ you must have read access to
or
.IR /dev/bpf* .
.B Under Solaris with dlpi:
-You must have read/write access to the network pseudo device, e.g.
+You must have read access to the network pseudo device, e.g.
.IR /dev/le .
.B Under HP-UX with dlpi:
You must be root or it must be installed setuid to root.
@@ -126,27 +124,6 @@ Dump packet-matching code as decimal numbers (preceded with a count).
.B \-e
Print the link-level header on each dump line.
.TP
-.B \-E
-Use \fIalgo:secret\fP for decrypting IPsec ESP packets. Algorithms may be
-\fBdes-cbc\fP,
-\fB3des-cbc\fP,
-\fBblowfish-cbc\fP,
-\fBrc3-cbc\fP,
-\fBcast128-cbc\fP, or
-\fBnone\fP.
-The default is \fBdes-cbc\fP.
-The ability to decrypt packets is only present if \fItcpdump\fP was compiled
-with cryptography enabled.
-\fIsecret\fP the ascii text for ESP secret key.
-We cannot take arbitrary binary value at this moment.
-The option assumes RFC2406 ESP, not RFC1827 ESP.
-The option is only for debugging purposes, and
-the use of this option with truly `secret' key is discouraged.
-By presenting IPsec secret key onto command line
-you make it visible to others, via
-.IR ps (1)
-and other occasions.
-.TP
.B \-f
Print `foreign' internet addresses numerically rather than symbolically
(this option is intended to get around serious brain damage in
@@ -162,12 +139,6 @@ Listen on \fIinterface\fP.
If unspecified, \fItcpdump\fP searches the system interface list for the
lowest numbered, configured up interface (excluding loopback).
Ties are broken by choosing the earliest match.
-.IP
-On Linux systems with 2.2 or later kernels, an
-.I interface
-argument of ``any'' can be used to capture packets from all interfaces.
-Note that captures on the ``any'' device will not be done in promiscuous
-mode.
.TP
.B \-l
Make stdout line buffered. Useful if you want to see the data
@@ -186,7 +157,7 @@ instead of ``nic.ddn.mil''.
.TP
.B \-m
Load SMI MIB module definitions from file \fImodule\fR. This option
-can be used several times to load several MIB modules into \fItcpdump\fP.
+can be used several times to load several MIB modules into tcpdump.
.TP
.B \-O
Do not run the packet-matching code optimizer. This is useful only
@@ -218,13 +189,11 @@ Note that taking larger snapshots both increases
the amount of time it takes to process packets and, effectively,
decreases the amount of packet buffering. This may cause packets to be
lost. You should limit \fIsnaplen\fP to the smallest number that will
-capture the protocol information you're interested in. Setting
-\fIsnaplen\fP to 0 means use the required length to catch whole packets.
+capture the protocol information you're interested in.
.TP
.B \-T
Force packets selected by "\fIexpression\fP" to be interpreted the
specified \fItype\fR. Currently known types are
-\fBcnfp\fR (Cisco NetFlow protocol),
\fBrpc\fR (Remote Procedure Call),
\fBrtp\fR (Real-Time Applications protocol),
\fBrtcp\fR (Real-Time Applications control protocol),
@@ -249,10 +218,8 @@ Print absolute, rather than relative, TCP sequence numbers.
Print an unformatted timestamp on each dump line.
.TP
.B \-v
-(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.
+(Slightly more) verbose output. For example, the time to live
+and type of service information in an IP packet is printed.
.TP
.B \-vv
Even more verbose output. For example, additional fields are
@@ -310,7 +277,7 @@ qualifier,
is assumed.
.IP \fIdir\fP
qualifiers specify a particular transfer direction to and/or from
-.IR id .
+.I id.
Possible directions are
.BR src ,
.BR dst ,
@@ -332,12 +299,20 @@ qualifiers restrict the match to a particular protocol. Possible
protos are:
.BR ether ,
.BR fddi ,
-.BR tr ,
.BR ip ,
.BR ip6 ,
.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 .
@@ -353,10 +328,7 @@ network interface.'' FDDI headers contain Ethernet-like source
and destination addresses, and often contain Ethernet-like packet
types, so you can filter on these FDDI fields just as with the
analogous Ethernet fields. FDDI headers also contain other fields,
-but you cannot name them explicitly in a filter expression.
-.LP
-Similarly, `tr' is an alias for `ether'; the previous paragraph's
-statements about FDDI headers also apply to Token Ring headers.]
+but you cannot name them explicitly in a filter expression.]
.LP
In addition to the above, there are some special `primitive' keywords
that don't follow the pattern:
@@ -479,12 +451,11 @@ This is equivalent to:
.fi
.in -.5i
.IP "\fBip proto \fIprotocol\fR"
-True if the packet is an IP packet (see
+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
-\fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP,
-\fIesp\fP, \fIudp\fP, or \fItcp\fP.
+\fIicmp\fP, \fIigrp\fP, \fIudp\fP, \fInd\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 protocol header chain.
@@ -527,10 +498,8 @@ True if the packet is an IP multicast packet.
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
-\fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP,
-\fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP, or
-\fIiso\fP.
+\fIProtocol\fP can be a number or a name like
+\fIip\fP, \fIip6\fP, \fIarp\fP, or \fIrarp\fP.
Note these identifiers are also keywords
and must be escaped via backslash (\\).
[In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), the
@@ -538,7 +507,7 @@ protocol identification comes from the 802.2 Logical Link Control
(LLC) header, which is usually layered on top of the FDDI header.
\fITcpdump\fP assumes, when filtering on the protocol identifier,
that all FDDI packets include an LLC header, and that the LLC header
-is in so-called SNAP format. The same applies to Token Ring.]
+is in so-called SNAP format.]
.IP "\fBdecnet src \fIhost\fR"
True if the DECNET source address is
.IR host ,
@@ -551,7 +520,7 @@ True if the DECNET destination address is
.IP "\fBdecnet host \fIhost\fR"
True if either the DECNET source or destination address is
.IR host .
-.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR"
+.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR, \fBiso\fR"
Abbreviations for:
.in +.5i
.nf
@@ -569,13 +538,6 @@ Abbreviations for:
where \fIp\fR is one of the above protocols.
Note that
\fItcpdump\fP does not currently know how to parse these protocols.
-.IP "\fBvlan \fI[vlan_id]\fR"
-True if the packet is an IEEE 802.1Q VLAN packet.
-If \fI[vlan_id]\fR is specified, only true is the packet has the specified
-\fIvlan_id\fR.
-Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
-changes the decoding offsets for the remainder of \fIexpression\fR
-on the assumption that the packet is a VLAN packet.
.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
Abbreviations for:
.in +.5i
@@ -584,11 +546,7 @@ Abbreviations for:
.fi
.in -.5i
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
-\fIclnp\fP, \fIesis\fP, or \fIisis\fP.
-.IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
+.IP "\fBesis\fR, \fBisis\fR"
Abbreviations for:
.in +.5i
.nf
@@ -609,7 +567,7 @@ data inside the packet, use the following syntax:
\fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
.fi
.in -.5i
-\fIProto\fR is one of \fBether, fddi, tr,
+\fIProto\fR is one of \fBether, fddi,
ip, arp, rarp, tcp, udp, icmp\fR or \fBip6\fR, and
indicates the protocol layer for the index operation.
Note that \fItcp, udp\fR and other upper-layer protocol types only
@@ -669,8 +627,8 @@ which should not be confused with
.fi
.in -.5i
.LP
-Expression arguments can be passed to \fItcpdump\fP as either a single
-argument or as multiple arguments, whichever is more convenient.
+Expression arguments can be passed to tcpdump as either a single argument
+or as multiple arguments, whichever is more convenient.
Generally, if the expression contains Shell metacharacters, it is
easier to pass it as a single, quoted argument.
Multiple arguments are concatenated with spaces before being parsed.
@@ -785,13 +743,6 @@ are assumed to contain an 802.2 Logical Link Control (LLC) packet;
the LLC header is printed if it is \fInot\fR an ISO datagram or a
so-called SNAP packet.
.LP
-On Token Ring networks, the '-e' option causes \fItcpdump\fP to print
-the `access control' and `frame control' fields, the source and
-destination addresses, and the packet length. As on FDDI networks,
-packets are assumed to contain an LLC packet. Regardless of whether
-the '-e' option is specified or not, the source routing information is
-printed for source-routed packets.
-.LP
\fI(N.B.: The following description assumes familiarity with
the SLIP compression algorithm described in RFC-1144.)\fP
.LP
@@ -833,7 +784,7 @@ host \fIrtsg\fP to host \fIcsam\fP:
.nf
.sp .5
\f(CWarp who-has csam tell rtsg
-arp reply csam is-at CSAM\fR
+arp reply csam is-at CSAM\fP
.sp .5
.fi
.RE
@@ -857,7 +808,7 @@ broadcast and the second is point-to-point would be visible:
.nf
.sp .5
\f(CWRTSG Broadcast 0806 64: arp who-has csam tell rtsg
-CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
+CSAM RTSG 0806 64: arp reply csam is-at CSAM\fP
.sp .5
.fi
.RE
@@ -869,7 +820,7 @@ TCP Packets
.LP
\fI(N.B.:The following description assumes familiarity with
the TCP protocol described in RFC-793. If you are not familiar
-with the protocol, neither this description nor \fItcpdump\fP will
+with the protocol, neither this description nor tcpdump will
be of much use to you.)\fP
.LP
The general format of a tcp protocol line is:
@@ -909,7 +860,7 @@ csam.login > rtsg.1023: . ack 2 win 4096
rtsg.1023 > csam.login: P 2:21(19) ack 1 win 4096
csam.login > rtsg.1023: P 1:2(1) ack 21 win 4077
csam.login > rtsg.1023: P 2:3(1) ack 21 win 4077 urg 1
-csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fR\s+2
+csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fP\s+2
.sp .5
.fi
.RE
@@ -929,7 +880,7 @@ ack for rtsg's SYN. Rtsg then acks csam's SYN. The `.' means no
flags were set.
The packet contained no data so there is no data sequence number.
Note that the ack sequence
-number is a small integer (1). The first time \fItcpdump\fP sees a
+number is a small integer (1). The first time \fBtcpdump\fP sees a
tcp `conversation', it prints the sequence number from the packet.
On subsequent packets of the conversation, the difference between
the current packet's sequence number and this initial sequence number
@@ -949,201 +900,15 @@ Csam also sends one byte of data to rtsg in this packet.
On the 8th and 9th lines,
csam sends two bytes of urgent, pushed data to rtsg.
.LP
-If the snapshot was small enough that \fItcpdump\fP didn't capture
+If the snapshot was small enough that \fBtcpdump\fP didn't capture
the full TCP header, it interprets as much of the header as it can
and then reports ``[|\fItcp\fP]'' to indicate the remainder could not
be interpreted. If the header contains a bogus option (one with a length
-that's either too small or beyond the end of the header), \fItcpdump\fP
-reports it as ``[\fIbad opt\fP]'' and does not interpret any further
-options (since it's impossible to tell where they start). If the header
-length indicates options are present but the IP datagram length is not
-long enough for the options to actually be there, \fItcpdump\fP reports
-it as ``[\fIbad hdr length\fP]''.
-.HD
-.B Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.)
-.PP
-There are 6 bits in the control bits section of the TCP header:
-.IP
-.I URG | ACK | PSH | RST | SYN | FIN
-.PP
-Let's assume that we want to watch packets used in establishing
-a TCP connection. Recall that TCP uses a 3-way handshake protocol
-when it initializes a new connection; the connection sequence with
-regard to the TCP control bits is
-.PP
-.RS
-1) Caller sends SYN
-.RE
-.RS
-2) Recipient responds with SYN, ACK
-.RE
-.RS
-3) Caller sends ACK
-.RE
-.PP
-Now we're interested in capturing packets that have only the
-SYN bit set (Step 1). Note that we don't want packets from step 2
-(SYN-ACK), just a plain initial SYN. What we need is a correct filter
-expression for \fItcpdump\fP.
-.PP
-Recall the structure of a TCP header without options:
-.PP
-.nf
- 0 15 31
------------------------------------------------------------------
-| source port | destination port |
------------------------------------------------------------------
-| sequence number |
------------------------------------------------------------------
-| acknowledgment number |
------------------------------------------------------------------
-| HL | reserved |U|A|P|R|S|F| window size |
------------------------------------------------------------------
-| TCP checksum | urgent pointer |
------------------------------------------------------------------
-.fi
-.PP
-A TCP header usually holds 20 octets of data, unless options are
-present. The fist line of the graph contains octets 0 - 3, the
-second line shows octets 4 - 7 etc.
-.PP
-Starting to count with 0, the relevant TCP control bits are contained
-in octet 13:
-.PP
-.nf
- 0 7| 15| 23| 31
-----------------|---------------|---------------|----------------
-| HL | reserved |U|A|P|R|S|F| window size |
-----------------|---------------|---------------|----------------
-| | 13th octet | | |
-.fi
-.PP
-Let's have a closer look at octet no. 13:
-.PP
-.nf
- | |
- |---------------|
- | |U|A|P|R|S|F|
- |---------------|
- |7 5 3 0|
-.fi
-.PP
-We see that this octet contains 2 bytes from the reserved field.
-According to RFC 793 this field is reserved for future use and must
-be 0. The remaining 6 bits are the TCP control bits we are interested
-in. We have numbered the bits in this octet from 0 to 7, right to
-left, so the PSH bit is bit number 3, while the URG bit is number 5.
-.PP
-Recall that we want to capture packets with only SYN set.
-Let's see what happens to octet 13 if a TCP datagram arrives
-with the SYN bit set in its header:
-.PP
-.nf
- | |U|A|P|R|S|F|
- |---------------|
- |0 0 0 0 0 0 1 0|
- |---------------|
- |7 6 5 4 3 2 1 0|
-.fi
-.PP
-We already mentioned that bits number 7 and 6 belong to the
-reserved field, so they must must be 0. Looking at the
-control bits section we see that only bit number 1 (SYN) is set.
-.PP
-Assuming that octet number 13 is an 8-bit unsigned integer in
-network byte order, the binary value of this octet is
-.IP
-00000010
-.PP
-and its decimal representation is
-.PP
-.nf
- 7 6 5 4 3 2 1 0
-0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2
-.fi
-.PP
-We're almost done, because now we know that if only SYN is set,
-the value of the 13th octet in the TCP header, when interpreted
-as a 8-bit unsigned integer in network byte order, must be exactly 2.
-.PP
-This relationship can be expressed as
-.RS
-.B
-tcp[13] == 2
-.RE
-.PP
-We can use this expression as the filter for \fItcpdump\fP in order
-to watch packets which have only SYN set:
-.RS
-.B
-tcpdump -i xl0 tcp[13] == 2
-.RE
-.PP
-The expression says "let the 13th octet of a TCP datagram have
-the decimal value 2", which is exactly what we want.
-.PP
-Now, let's assume that we need to capture SYN packets, but we
-don't care if ACK or any other TCP control bit is set at the
-same time. Let's see what happens to octet 13 when a TCP datagram
-with SYN-ACK set arrives:
-.PP
-.nf
- | |U|A|P|R|S|F|
- |---------------|
- |0 0 0 1 0 0 1 0|
- |---------------|
- |7 6 5 4 3 2 1 0|
-.fi
-.PP
-Now bits 1 and 4 are set in the 13th octet. The binary value of
-octet 13 is
-.IP
- 00010010
-.PP
-which translates to decimal
-.PP
-.nf
- 7 6 5 4 3 2 1 0
-0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18
-.fi
-.PP
-Now we can't just use 'tcp[13] == 18' in the \fItcpdump\fP filter
-expression, because that would select only those packets that have
-SYN-ACK set, but not those with only SYN set. Remember that we don't care
-if ACK or any other control bit is set as long as SYN is set.
-.PP
-In order to achieve our goal, we need to logically AND the
-binary value of octet 13 with some other value to preserve
-the SYN bit. We know that we want SYN to be set in any case,
-so we'll logically AND the value in the 13th octet with
-the binary value of a SYN:
-.PP
-.nf
-
- 00010010 SYN-ACK 00000010 SYN
- AND 00000010 (we want SYN) AND 00000010 (we want SYN)
- -------- --------
- = 00000010 = 00000010
-.fi
-.PP
-We see that this AND operation delivers the same result
-regardless whether ACK or another TCP control bit is set.
-The decimal representation of the AND value as well as
-the result of this operation is 2 (binary 00000010),
-so we know that for packets with SYN set the following
-relation must hold true:
-.IP
-( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
-.PP
-This points us to the \fItcpdump\fP filter expression
-.RS
-.B
- tcpdump -i xl0 'tcp[13] & 2 == 2'
-.RE
-.PP
-Note that you should use single quotes or a backslash
-in the expression to hide the AND ('&') special character
-from the shell.
+that's either too small or beyond the end of the header), tcpdump reports
+it as ``[\fIbad opt\fP]'' and does not interpret any further options (since
+it's impossible to tell where they start). If the header length indicates
+options are present but the IP datagram length is not long enough for the
+options to actually be there, tcpdump reports it as ``[\fIbad hdr length\fP]''.
.HD
.B
UDP Packets
@@ -1178,7 +943,7 @@ Name server requests are formatted as
.sp .5
\fIsrc > dst: id op? flags qtype qclass name (len)\fP
.sp .5
-\f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fR
+\f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fP
.sp .5
.fi
.RE
@@ -1215,7 +980,7 @@ Name server responses are formatted as
\fIsrc > dst: id op rcode flags a/n/au type class data (len)\fP
.sp .5
\f(CWhelios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
-helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fR
+helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fP
.sp .5
.fi
.RE
@@ -1246,7 +1011,7 @@ has worked well for me.
.HD
SMB/CIFS decoding
.LP
-\fItcpdump\fP now includes fairly extensive SMB/CIFS/NBT decoding for data
+tcpdump now includes fairly extensive SMB/CIFS/NBT decoding for data
on UDP/137, UDP/138 and TCP/139. Some primitive decoding of IPX and
NetBEUI SMB data is also done.
@@ -1281,7 +1046,7 @@ sushi.201b > wrl.nfs:
144 lookup fh 9,74/4096.6878 "xcolors"
wrl.nfs > sushi.201b:
reply ok 128 lookup fh 9,74/4134.3150
-\fR
+\fP
.sp .5
.fi
.RE
@@ -1315,7 +1080,7 @@ wrl.nfs > sushi.1372a:
.sp .5
.fi
.RE
-(\-v also prints the IP header TTL, ID, length, and fragmentation fields,
+(\-v also prints the IP header TTL, ID, and fragmentation fields,
which have been omitted from this example.) In the first line,
\fIsushi\fP asks \fIwrl\fP to read 8192 bytes from file 21,11/12.195,
at byte offset 24576. \fIWrl\fP replies `ok'; the packet shown on the
@@ -1338,7 +1103,7 @@ NFS reply packets do not explicitly identify the RPC operation. Instead,
replies using the transaction ID. If a reply does not closely follow the
corresponding request, it might not be parsable.
.HD
-AFS Requests and Replies
+AFS Request and Replies
.LP
Transarc AFS (Andrew File System) requests and replies are printed
as:
@@ -1355,7 +1120,7 @@ elvis.7001 > pike.afsfs:
rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
new fid 536876964/1/1 ".newsrc"
pike.afsfs > elvis.7001: rx data fs reply rename
-\fR
+\fP
.sp .5
.fi
.RE
@@ -1375,16 +1140,11 @@ The format is intended to be self-describing, but it will probably
not be useful to people who are not familiar with the workings of
AFS and RX.
.LP
-If the -v (verbose) flag is given twice, acknowledgement packets and
-additional header information is printed, such as the the RX call ID,
-call number, sequence number, serial number, and the RX packet flags.
+If the -v (verbose) flag is given twice, additional information is printed,
+such as the the RX call ID, call number, sequence number, serial number,
+and the RX packet flags.
.LP
-If the -v flag is given twice, additional information is printed,
-such as the the RX call ID, serial number, and the RX packet flags.
-The MTU negotiation information is also printed from RX ack packets.
-.LP
-If the -v flag is given three times, the security index and service id
-are printed.
+If the -v flag is given again, the security index and service id are printed.
.LP
Error codes are printed for abort packets, with the exception of Ubik
beacon packets (because abort packets are used to signify a yes vote
@@ -1416,7 +1176,7 @@ Lines in this file have the form
\f(CW1.254 ether
16.1 icsd-net
-1.254.110 ace\fR
+1.254.110 ace\fP
.sp .5
.fi
.RE
@@ -1439,7 +1199,7 @@ Appletalk addresses are printed in the form
\f(CW144.1.209.2 > icsd-net.112.220
office.2 > icsd-net.112.220
-jssmag.149.235 > icsd-net.2\fR
+jssmag.149.235 > icsd-net.2\fP
.sp .5
.fi
.RE
@@ -1467,7 +1227,7 @@ protocol) and packet size.
.sp .5
\s-2\f(CWicsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
-techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fR\s+2
+techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fP\s+2
.sp .5
.fi
.RE
@@ -1496,7 +1256,7 @@ jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001
helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001
-jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fR\s+2
+jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fP\s+2
.sp .5
.fi
.RE
@@ -1578,24 +1338,14 @@ is made to account for the time lag between when the
ethernet interface removed the packet from the wire and when the kernel
serviced the `new packet' interrupt.
.SH "SEE ALSO"
-traffic(1C), nit(4P), bpf(4), pcap(3)
+bpf(4), pcap(3)
.SH AUTHORS
-The original authors are:
-.LP
Van Jacobson,
Craig Leres and
Steven McCanne, all of the
Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
.LP
-It is currently being maintained by tcpdump.org.
-.LP
-The current version is available via http:
-.LP
-.RS
-.I http://www.tcpdump.org/
-.RE
-.LP
-The original distribution is available via anonymous ftp:
+The current version is available via anonymous ftp:
.LP
.RS
.I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
@@ -1604,61 +1354,40 @@ The original distribution is available via anonymous ftp:
IPv6/IPsec support is added by WIDE/KAME project.
This program uses Eric Young's SSLeay library, under specific configuration.
.SH BUGS
-Please send problems, bugs, questions, desirable enhancements, etc. to:
-.LP
-.RS
-tcpdump-workers@tcpdump.org
-.RE
-.LP
-Please send source code contributions, etc. to:
-.LP
-.RS
-patches@tcpdump.org
-.RE
+Please send bug reports to tcpdump@ee.lbl.gov.
.LP
NIT doesn't let you watch your own outbound traffic, BPF will.
We recommend that you use the latter.
.LP
-On Linux systems with 2.0[.x] kernels:
-.IP
-packets on the loopback device will be seen twice;
-.IP
-packet filtering cannot be done in the kernel, so that all packets must
-be copied from the kernel in order to be filtered in user mode;
-.IP
-all of a packet, not just the part that's within the snapshot length,
-will be copied from the kernel (the 2.0[.x] packet capture mechanism, if
-asked to copy only part of a packet to userland, will not report the
-true length of the packet; this would cause most IP packets to get an
-error from
-.BR tcpdump ).
-.LP
-We recommend that you upgrade to a 2.2 or later kernel.
-.LP
Some attempt should be made to reassemble IP fragments or, at least
to compute the right length for the higher level protocol.
.LP
-Name server inverse queries are not dumped correctly: the (empty)
+Name server inverse queries are not dumped correctly: The (empty)
question section is printed rather than real query in the answer
section. Some believe that inverse queries are themselves a bug and
-prefer to fix the program generating them rather than \fItcpdump\fP.
+prefer to fix the program generating them rather than tcpdump.
+.LP
+Apple Ethertalk DDP packets could be dumped as easily as KIP DDP
+packets but aren't.
+Even if we were inclined to do anything to promote the use of
+Ethertalk (we aren't), LBL doesn't allow Ethertalk on any of its
+networks so we'd would have no way of testing this code.
.LP
A packet trace that crosses a daylight savings time change will give
skewed time stamps (the time change is ignored).
.LP
-Filter expressions that manipulate FDDI or Token Ring headers assume
-that all FDDI and Token Ring packets are SNAP-encapsulated Ethernet
-packets. This is true for IP, ARP, and DECNET Phase IV, but is not true
-for protocols such as ISO CLNS. Therefore, the filter may inadvertently
-accept certain packets that do not properly match the filter expression.
-.LP
-Filter expressions on fields other than those that manipulate Token Ring
-headers will not correctly handle source-routed Token Ring packets.
+Filters expressions that manipulate FDDI headers assume that all FDDI
+packets are encapsulated Ethernet packets. This is true for IP, ARP,
+and DECNET Phase IV, but is not true for protocols such as ISO CLNS.
+Therefore, the filter may inadvertently accept certain packets that
+do not properly match the filter expression.
.LP
.BR "ip6 proto"
should chase header chain, but at this moment it does not.
-.BR "ip6 protochain"
-is supplied for this behavior.
+.BR tcp
+or
+.BR udp
+should chase header chain too.
.LP
Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
does not work against IPv6 packets.
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 4749271..daf95fe 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -24,9 +24,11 @@ static const char copyright[] =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.158 2000/12/21 10:43:24 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.138.2.1 2000/01/11 07:34:00 fenner Exp $ (LBL)";
#endif
+/* $FreeBSD$ */
+
/*
* tcpdump - monitor tcp/ip traffic on an ethernet.
*
@@ -52,6 +54,8 @@ static const char rcsid[] =
#include <unistd.h>
#include <ctype.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
#include "interface.h"
#include "addrtoname.h"
@@ -72,11 +76,11 @@ 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; /* Print undecoded NFS handles */
int vflag; /* verbose */
int xflag; /* print packet in hex */
int Xflag; /* print packet in ascii as well as hex */
+char *ahsecret = NULL; /* AH secret key */
char *espsecret = NULL; /* ESP secret key */
int packettype;
@@ -86,9 +90,12 @@ char *program_name;
int32_t thiszone; /* seconds offset from gmt to local time */
+/* Externs */
+extern void bpf_dump(struct bpf_program *, int);
+
/* Forwards */
-static RETSIGTYPE cleanup(int);
-static void usage(void) __attribute__((noreturn));
+RETSIGTYPE cleanup(int);
+extern __dead void usage(void) __attribute__((volatile));
/* Length of saved portion of packet. */
int snaplen = DEFAULT_SNAPLEN;
@@ -107,28 +114,16 @@ static struct printer printers[] = {
#ifdef DLT_CIP
{ cip_if_print, DLT_CIP },
#endif
-#ifdef DLT_ATM_CLIP
- { cip_if_print, DLT_ATM_CLIP },
-#endif
{ sl_if_print, DLT_SLIP },
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
{ ppp_if_print, DLT_PPP },
{ ppp_bsdos_if_print, DLT_PPP_BSDOS },
{ fddi_if_print, DLT_FDDI },
{ null_if_print, DLT_NULL },
-#ifdef DLT_LOOP
- { null_if_print, DLT_LOOP },
-#endif
{ raw_if_print, DLT_RAW },
{ atm_if_print, DLT_ATM_RFC1483 },
-#ifdef DLT_C_HDLC
- { chdlc_if_print, DLT_C_HDLC },
-#endif
-#ifdef DLT_PPP_SERIAL
- { ppp_hdlc_if_print, DLT_PPP_SERIAL },
-#endif
-#ifdef DLT_LINUX_SLL
- { sll_if_print, DLT_LINUX_SLL },
+#ifdef DLT_CHDLC
+ { chdlc_if_print, DLT_CHDLC },
#endif
{ NULL, 0 },
};
@@ -142,7 +137,7 @@ lookup_printer(int type)
if (type == p->type)
return p->f;
- error("unknown data link type %d", type);
+ error("unknown data link type 0x%x", type);
/* NOTREACHED */
}
@@ -174,7 +169,7 @@ main(int argc, char **argv)
else
program_name = argv[0];
- if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
+ if (abort_on_misalignment(ebuf) < 0)
error("%s", ebuf);
#ifdef LIBSMI
@@ -183,13 +178,22 @@ main(int argc, char **argv)
opterr = 0;
while (
- (op = getopt(argc, argv, "ac:deE:fF:i:lm:nNOpqr:Rs:StT:uvw:xXY")) != -1)
+ (op = getopt(argc, argv, "ac:deE:fF:i:lnNm:Opqr:Rs:StT:vw:xXY")) != EOF)
switch (op) {
case 'a':
++aflag;
break;
+#if 0
+ case 'A':
+#ifndef CRYPTO
+ warning("crypto code not compiled in");
+#endif
+ ahsecret = optarg;
+ break;
+#endif
+
case 'c':
cnt = atoi(optarg);
if (cnt <= 0)
@@ -205,7 +209,7 @@ main(int argc, char **argv)
break;
case 'E':
-#ifndef HAVE_LIBCRYPTO
+#ifndef CRYPTO
warning("crypto code not compiled in");
#endif
espsecret = optarg;
@@ -271,17 +275,11 @@ main(int argc, char **argv)
Rflag = 0;
break;
- case 's': {
- char *end;
-
- snaplen = strtol(optarg, &end, 0);
- if (optarg == end || *end != '\0'
- || snaplen < 0 || snaplen > 65535)
+ case 's':
+ snaplen = atoi(optarg);
+ if (snaplen <= 0)
error("invalid snaplen %s", optarg);
- else if (snaplen == 0)
- snaplen = 65535;
break;
- }
case 'S':
++Sflag;
@@ -304,16 +302,10 @@ main(int argc, char **argv)
packettype = PT_RTCP;
else if (strcasecmp(optarg, "snmp") == 0)
packettype = PT_SNMP;
- else if (strcasecmp(optarg, "cnfp") == 0)
- packettype = PT_CNFP;
else
error("unknown packet type `%s'", optarg);
break;
- case 'u':
- ++uflag;
- break;
-
case 'v':
++vflag;
break;
@@ -327,7 +319,7 @@ main(int argc, char **argv)
break;
case 'X':
- ++xflag;
+ ++xflag;
++Xflag;
break;
@@ -436,7 +428,7 @@ main(int argc, char **argv)
}
/* make a clean exit on interrupts */
-static RETSIGTYPE
+RETSIGTYPE
cleanup(int signo)
{
struct pcap_stat stat;
@@ -458,6 +450,55 @@ cleanup(int signo)
exit(0);
}
+/* dump the buffer in `emacs-hexl' style */
+void
+default_print_hexl(const u_char *cp, unsigned int length, unsigned int offset)
+{
+ unsigned int i, j, jm;
+ int c;
+ char ln[128];
+
+ printf("\n");
+ for (i = 0; i < length; i += 0x10) {
+ snprintf(ln,
+ sizeof(ln),
+ " %04x: ", (unsigned int)(i + offset));
+ jm = length - i;
+ jm = jm > 16 ? 16 : jm;
+
+ for (j = 0; j < jm; j++) {
+ if ((j % 2) == 1)
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%02x ", (unsigned int)cp[i+j]);
+ else
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%02x", (unsigned int)cp[i+j]);
+ }
+ for (; j < 16; j++) {
+ if ((j % 2) == 1)
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ " ");
+ else
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ " ");
+ }
+
+ snprintf(ln + strlen(ln), sizeof(ln) - strlen(ln), " ");
+ for (j = 0; j < jm; j++) {
+ c = cp[i+j];
+ c = isprint(c) ? c : '.';
+ snprintf(ln + strlen(ln),
+ sizeof(ln) - strlen(ln),
+ "%c", c);
+ }
+ printf("%s\n", ln);
+ }
+}
+
/* Like default_print() but data need not be aligned */
void
default_print_unaligned(register const u_char *cp, register u_int length)
@@ -493,7 +534,7 @@ default_print(register const u_char *bp, register u_int length)
default_print_unaligned(bp, length);
}
-static void
+__dead void
usage(void)
{
extern char version[];
@@ -502,7 +543,7 @@ usage(void)
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
(void)fprintf(stderr,
-"Usage: %s [-adeflnNOpqStuvxX] [-c count] [ -F file ]\n", program_name);
+"Usage: %s [-adeflnNOpqStvxX] [-c count] [ -F file ]\n", program_name);
(void)fprintf(stderr,
"\t\t[ -i interface ] [ -r file ] [ -s snaplen ]\n");
(void)fprintf(stderr,
diff --git a/contrib/tcpdump/token.h b/contrib/tcpdump/token.h
index 9565969..98d2c59 100644
--- a/contrib/tcpdump/token.h
+++ b/contrib/tcpdump/token.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.3 2000/10/03 02:55:03 itojun Exp $ (LBL) */
/*
* Copyright (c) 1998, Larry Lile
* All rights reserved.
@@ -27,26 +26,34 @@
*
*/
-#define TOKEN_HDRLEN 14
-#define TOKEN_RING_MAC_LEN 6
-#define ROUTING_SEGMENT_MAX 16
-#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
-#define TOKEN_FC_LLC 1
+#define TOKEN_HDR_LEN 14
+#define TOKEN_RING_MAC_LEN 6
+#define ROUTING_SEGMENT_MAX 16
+#define IS_SOURCE_ROUTED (tp->ether_shost[0] & 0x80)
+#define BROADCAST ((ntohs(tp->rcf) & 0xE000) >> 13)
+#define RIF_LENGTH ((ntohs(tp->rcf) & 0x1f00) >> 8)
+#define DIRECTION ((ntohs(tp->rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME ((ntohs(tp->rcf) & 0x0070) >> 4)
+#define RING_NUMBER(x) ((ntohs(tp->rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(x) ((ntohs(tp->rseg[x]) & 0x000f))
+#define SEGMENT_COUNT ((RIF_LENGTH - 2) / 2)
+
+char *broadcast_indicator[] = { "Non-Broadcast", "Non-Broadcast",
+ "Non-Broadcast", "Non-Broadcast",
+ "All-routes", "All-routes",
+ "Single-route", "Single-route"};
+
+char *direction[] = { "Forward", "Backward"};
+
+char *largest_frame[] = { "516", "1500", "2052", "4472", "8144",
+ "11407", "17800", ""};
-#define BROADCAST(trp) ((ntohs((trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp) ((ntohs((trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp) ((ntohs((trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp) ((ntohs((trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x) ((ntohs((trp)->token_rseg[x]) & 0x000f))
-#define SEGMENT_COUNT(trp) ((RIF_LENGTH(trp) - 2) / 2)
struct token_header {
- u_int8_t token_ac;
- u_int8_t token_fc;
- u_int8_t token_dhost[TOKEN_RING_MAC_LEN];
- u_int8_t token_shost[TOKEN_RING_MAC_LEN];
- u_int16_t token_rcf;
- u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
+ u_char ac;
+ u_char fc;
+ u_char ether_dhost[TOKEN_RING_MAC_LEN];
+ u_char ether_shost[TOKEN_RING_MAC_LEN];
+ u_short rcf;
+ u_short rseg[ROUTING_SEGMENT_MAX];
};
OpenPOWER on IntegriCloud