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.m4706
-rw-r--r--contrib/tcpdump/addrtoname.c43
-rw-r--r--contrib/tcpdump/ethertype.h3
-rw-r--r--contrib/tcpdump/nfs.h446
-rw-r--r--contrib/tcpdump/nfsfh.h6
-rw-r--r--contrib/tcpdump/nfsv2.h262
-rw-r--r--contrib/tcpdump/parsenfsfh.c12
-rw-r--r--contrib/tcpdump/print-arp.c8
-rw-r--r--contrib/tcpdump/print-atalk.c47
-rw-r--r--contrib/tcpdump/print-atm.c28
-rw-r--r--contrib/tcpdump/print-bootp.c11
-rw-r--r--contrib/tcpdump/print-domain.c22
-rw-r--r--contrib/tcpdump/print-ether.c17
-rw-r--r--contrib/tcpdump/print-fddi.c9
-rw-r--r--contrib/tcpdump/print-fr.c424
-rw-r--r--contrib/tcpdump/print-icmp.c2
-rw-r--r--contrib/tcpdump/print-ip.c44
-rw-r--r--contrib/tcpdump/print-ipx.c4
-rw-r--r--contrib/tcpdump/print-isoclns.c456
-rw-r--r--contrib/tcpdump/print-llc.c7
-rw-r--r--contrib/tcpdump/print-nfs.c1185
-rw-r--r--contrib/tcpdump/print-ntp.c8
-rw-r--r--contrib/tcpdump/print-null.c16
-rw-r--r--contrib/tcpdump/print-ppp.c538
-rw-r--r--contrib/tcpdump/print-sl.c57
-rw-r--r--contrib/tcpdump/print-sunrpc.c6
-rw-r--r--contrib/tcpdump/print-udp.c13
-rw-r--r--contrib/tcpdump/tcpdump.127
29 files changed, 2876 insertions, 1559 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 d8227a9..0000000
--- a/contrib/tcpdump/aclocal.m4
+++ /dev/null
@@ -1,706 +0,0 @@
-dnl @(#) $Header: aclocal.m4,v 1.63 98/06/12 03:44:50 leres 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/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"
- 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
-
- alpha|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)
- ])
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index 6996b5c..e6b3e41 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: addrtoname.c,v 1.61 97/06/15 13:20:18 leres Exp $ (LBL)";
+ "@(#) $Header: addrtoname.c,v 1.54 96/12/05 22:10:19 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -37,7 +37,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <arpa/inet.h>
@@ -45,12 +45,6 @@ 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>
@@ -60,8 +54,6 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
#include "llc.h"
-#include "savestr.h"
-#include "setsignal.h"
/* Forwards */
static RETSIGTYPE nohostname(int);
@@ -216,18 +208,16 @@ getname(const u_char *ap)
/*
* Only print names when:
* (1) -n was not given.
- * (2) Address is foreign and -f was given. (If -f was not
- * give, f_netmask and f_local are 0 and the test
- * evaluates to true)
- * (3) -a was given or the host portion is not all ones
- * nor all zeros (i.e. not a network or broadcast address)
+ * (2) Address is foreign and -f was given. If -f was not
+ * present, f_netmask and f_local are 0 and the second
+ * test will succeed.
+ * (3) The host portion is not 0 (i.e., a network address).
+ * (4) The host portion is not broadcast.
*/
- if (!nflag &&
- (addr & f_netmask) == f_localnet &&
- (aflag ||
- !((addr & ~netmask) == 0 || (addr | netmask) == 0xffffffff))) {
+ if (!nflag && (addr & f_netmask) == f_localnet
+ && (addr &~ netmask) != 0 && (addr | netmask) != 0xffffffff) {
if (!setjmp(getname_env)) {
- (void)setsignal(SIGALRM, nohostname);
+ (void)signal(SIGALRM, nohostname);
(void)alarm(20);
hp = gethostbyaddr((char *)&addr, 4, AF_INET);
(void)alarm(0);
@@ -317,7 +307,7 @@ lookup_nsap(register const u_char *nsap)
tp->e_nsap = (u_char *)malloc(nlen + 1);
if (tp->e_nsap == NULL)
error("lookup_nsap: malloc");
- memcpy((char *)tp->e_nsap, (char *)nsap, nlen + 1);
+ memcpy(tp->e_nsap, nsap, nlen + 1);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
error("lookup_nsap: calloc");
@@ -477,15 +467,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);
@@ -706,7 +697,7 @@ init_llcsaparray(void)
* of the local network. mask is its subnet mask.
*/
void
-init_addrtoname(u_int32_t localnet, u_int32_t mask)
+init_addrtoname(int fflag, u_int32_t localnet, u_int32_t mask)
{
netmask = mask;
if (fflag) {
diff --git a/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h
index 2403073..1d62670 100644
--- a/contrib/tcpdump/ethertype.h
+++ b/contrib/tcpdump/ethertype.h
@@ -71,6 +71,9 @@
#ifndef ETHERTYPE_AARP
#define ETHERTYPE_AARP 0x80f3
#endif
+#ifndef ETHERTYPE_IPX
+#define ETHERTYPE_IPX 0x8137
+#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif
diff --git a/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h
new file mode 100644
index 0000000..045ebb1
--- /dev/null
+++ b/contrib/tcpdump/nfs.h
@@ -0,0 +1,446 @@
+/* $NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp $ */
+
+/*
+ * Copyright (c) 1989, 1993
+ * 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.
+ *
+ * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
+ */
+
+/*
+ * nfs definitions as per the Version 2 and 3 specs
+ */
+
+/*
+ * Constants as defined in the Sun NFS Version 2 and 3 specs.
+ * "NFS: Network File System Protocol Specification" RFC1094
+ * and in the "NFS: Network File System Version 3 Protocol
+ * Specification"
+ */
+
+#define NFS_PORT 2049
+#define NFS_PROG 100003
+#define NFS_VER2 2
+#define NFS_VER3 3
+#define NFS_V2MAXDATA 8192
+#define NFS_MAXDGRAMDATA 16384
+#define NFS_MAXDATA 32768
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#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 (version 2 and 3) */
+#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_XDEV 18 /* Version 3 only */
+#define NFSERR_NODEV 19
+#define NFSERR_NOTDIR 20
+#define NFSERR_ISDIR 21
+#define NFSERR_INVAL 22 /* Version 3 only */
+#define NFSERR_FBIG 27
+#define NFSERR_NOSPC 28
+#define NFSERR_ROFS 30
+#define NFSERR_MLINK 31 /* Version 3 only */
+#define NFSERR_NAMETOL 63
+#define NFSERR_NOTEMPTY 66
+#define NFSERR_DQUOT 69
+#define NFSERR_STALE 70
+#define NFSERR_REMOTE 71 /* Version 3 only */
+#define NFSERR_WFLUSH 99 /* Version 2 only */
+#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
+#define NFSERR_NOT_SYNC 10002
+#define NFSERR_BAD_COOKIE 10003
+#define NFSERR_NOTSUPP 10004
+#define NFSERR_TOOSMALL 10005
+#define NFSERR_SERVERFAULT 10006
+#define NFSERR_BADTYPE 10007
+#define NFSERR_JUKEBOX 10008
+#define NFSERR_TRYLATER NFSERR_JUKEBOX
+#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
+
+#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
+#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
+#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
+
+/* Sizes in bytes of various nfs rpc components */
+#define NFSX_UNSIGNED 4
+
+/* specific to NFS Version 2 */
+#define NFSX_V2FH 32
+#define NFSX_V2FATTR 68
+#define NFSX_V2SATTR 32
+#define NFSX_V2COOKIE 4
+#define NFSX_V2STATFS 20
+
+/* specific to NFS Version 3 */
+#if 0
+#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
+#endif
+#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
+#define NFSX_V3FATTR 84
+#define NFSX_V3SATTR 60 /* max. all fields filled in */
+#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
+#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
+#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
+#define NFSX_V3COOKIEVERF 8
+#define NFSX_V3WRITEVERF 8
+#define NFSX_V3CREATEVERF 8
+#define NFSX_V3STATFS 52
+#define NFSX_V3FSINFO 48
+#define NFSX_V3PATHCONF 24
+
+/* variants for both versions */
+#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
+ NFSX_V2FH)
+#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
+#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
+#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
+#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
+#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
+ NFSX_V2FATTR)
+#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
+#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
+#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
+#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
+#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
+#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
+ (2 * NFSX_UNSIGNED))
+#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
+
+/* nfs rpc procedure numbers (before version mapping) */
+#define NFSPROC_NULL 0
+#define NFSPROC_GETATTR 1
+#define NFSPROC_SETATTR 2
+#define NFSPROC_LOOKUP 3
+#define NFSPROC_ACCESS 4
+#define NFSPROC_READLINK 5
+#define NFSPROC_READ 6
+#define NFSPROC_WRITE 7
+#define NFSPROC_CREATE 8
+#define NFSPROC_MKDIR 9
+#define NFSPROC_SYMLINK 10
+#define NFSPROC_MKNOD 11
+#define NFSPROC_REMOVE 12
+#define NFSPROC_RMDIR 13
+#define NFSPROC_RENAME 14
+#define NFSPROC_LINK 15
+#define NFSPROC_READDIR 16
+#define NFSPROC_READDIRPLUS 17
+#define NFSPROC_FSSTAT 18
+#define NFSPROC_FSINFO 19
+#define NFSPROC_PATHCONF 20
+#define NFSPROC_COMMIT 21
+
+/* And leasing (nqnfs) procedure numbers (must be last) */
+#define NQNFSPROC_GETLEASE 22
+#define NQNFSPROC_VACATED 23
+#define NQNFSPROC_EVICTED 24
+
+#define NFSPROC_NOOP 25
+#define NFS_NPROCS 26
+
+/* Actual Version 2 procedure numbers */
+#define NFSV2PROC_NULL 0
+#define NFSV2PROC_GETATTR 1
+#define NFSV2PROC_SETATTR 2
+#define NFSV2PROC_NOOP 3
+#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
+#define NFSV2PROC_LOOKUP 4
+#define NFSV2PROC_READLINK 5
+#define NFSV2PROC_READ 6
+#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
+#define NFSV2PROC_WRITE 8
+#define NFSV2PROC_CREATE 9
+#define NFSV2PROC_REMOVE 10
+#define NFSV2PROC_RENAME 11
+#define NFSV2PROC_LINK 12
+#define NFSV2PROC_SYMLINK 13
+#define NFSV2PROC_MKDIR 14
+#define NFSV2PROC_RMDIR 15
+#define NFSV2PROC_READDIR 16
+#define NFSV2PROC_STATFS 17
+
+/*
+ * Constants used by the Version 3 protocol for various RPCs
+ */
+#define NFSV3SATTRTIME_DONTCHANGE 0
+#define NFSV3SATTRTIME_TOSERVER 1
+#define NFSV3SATTRTIME_TOCLIENT 2
+
+#define NFSV3ATTRTIME_NMODES 3
+
+#define NFSV3ACCESS_READ 0x01
+#define NFSV3ACCESS_LOOKUP 0x02
+#define NFSV3ACCESS_MODIFY 0x04
+#define NFSV3ACCESS_EXTEND 0x08
+#define NFSV3ACCESS_DELETE 0x10
+#define NFSV3ACCESS_EXECUTE 0x20
+
+#define NFSV3WRITE_UNSTABLE 0
+#define NFSV3WRITE_DATASYNC 1
+#define NFSV3WRITE_FILESYNC 2
+
+#define NFSV3WRITE_NMODES 3
+
+#define NFSV3CREATE_UNCHECKED 0
+#define NFSV3CREATE_GUARDED 1
+#define NFSV3CREATE_EXCLUSIVE 2
+
+#define NFSV3CREATE_NMODES 3
+
+#define NFSV3FSINFO_LINK 0x01
+#define NFSV3FSINFO_SYMLINK 0x02
+#define NFSV3FSINFO_HOMOGENEOUS 0x08
+#define NFSV3FSINFO_CANSETTIME 0x10
+
+/* Conversion macros */
+#define vtonfsv2_mode(t,m) \
+ txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
+ MAKEIMODE((t), (m)))
+#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
+#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777)
+#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
+#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
+#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
+#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
+
+/* File types */
+typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
+ NFSOCK=6, NFFIFO=7 } nfstype;
+
+/* Structs for common parts of the rpc's */
+/*
+ * File Handle (32 bytes for version 2), variable up to 64 for version 3.
+ * File Handles of up to NFS_SMALLFH in size are stored directly in the
+ * nfs node, whereas larger ones are malloc'd. (This never happens when
+ * NFS_SMALLFH is set to 64.)
+ * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
+ */
+#ifndef NFS_SMALLFH
+#define NFS_SMALLFH 64
+#endif
+union nfsfh {
+/* fhandle_t fh_generic; */
+ u_char fh_bytes[NFS_SMALLFH];
+};
+typedef union nfsfh nfsfh_t;
+
+struct nfsv2_time {
+ u_int32_t nfsv2_sec;
+ u_int32_t nfsv2_usec;
+};
+typedef struct nfsv2_time nfstime2;
+
+struct nfsv3_time {
+ u_int32_t nfsv3_sec;
+ u_int32_t nfsv3_nsec;
+};
+typedef struct nfsv3_time nfstime3;
+
+/*
+ * Quads are defined as arrays of 2 longs to ensure dense packing for the
+ * protocol and to facilitate xdr conversion.
+ */
+struct nfs_uquad {
+ u_int32_t nfsuquad[2];
+};
+typedef struct nfs_uquad nfsuint64;
+
+/*
+ * Used to convert between two u_longs and a u_quad_t.
+ */
+union nfs_quadconvert {
+ u_int32_t lval[2];
+ u_quad_t qval;
+};
+typedef union nfs_quadconvert nfsquad_t;
+
+/*
+ * NFS Version 3 special file number.
+ */
+struct nfsv3_spec {
+ u_int32_t specdata1;
+ u_int32_t specdata2;
+};
+typedef struct nfsv3_spec nfsv3spec;
+
+/*
+ * File attributes and setable attributes. These structures cover both
+ * NFS version 2 and the version 3 protocol. Note that the union is only
+ * used so 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 longs or u_longs or structures of same)
+ * NB: You can't do sizeof(struct nfs_fattr), you must use the
+ * NFSX_FATTR(v3) macro.
+ */
+struct nfs_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 nfsv2fa_size;
+ u_int32_t nfsv2fa_blocksize;
+ u_int32_t nfsv2fa_rdev;
+ u_int32_t nfsv2fa_blocks;
+ u_int32_t nfsv2fa_fsid;
+ u_int32_t nfsv2fa_fileid;
+ nfstime2 nfsv2fa_atime;
+ nfstime2 nfsv2fa_mtime;
+ nfstime2 nfsv2fa_ctime;
+ } fa_nfsv2;
+ struct {
+ nfsuint64 nfsv3fa_size;
+ nfsuint64 nfsv3fa_used;
+ nfsv3spec nfsv3fa_rdev;
+ nfsuint64 nfsv3fa_fsid;
+ nfsuint64 nfsv3fa_fileid;
+ nfstime3 nfsv3fa_atime;
+ nfstime3 nfsv3fa_mtime;
+ nfstime3 nfsv3fa_ctime;
+ } fa_nfsv3;
+ } fa_un;
+};
+
+/* and some ugly defines for accessing union components */
+#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
+#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
+#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
+#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
+#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
+#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
+#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
+#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
+#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
+#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
+#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
+#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
+#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
+#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
+#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
+#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
+#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
+
+struct nfsv2_sattr {
+ u_int32_t sa_mode;
+ u_int32_t sa_uid;
+ u_int32_t sa_gid;
+ u_int32_t sa_size;
+ nfstime2 sa_atime;
+ nfstime2 sa_mtime;
+};
+
+/*
+ * NFS Version 3 sattr structure for the new node creation case.
+ */
+struct nfsv3_sattr {
+ u_int32_t sa_modeset;
+ u_int32_t sa_mode;
+ u_int32_t sa_uidset;
+ u_int32_t sa_uid;
+ u_int32_t sa_gidset;
+ u_int32_t sa_gid;
+ u_int32_t sa_sizeset;
+ u_int32_t sa_size;
+ u_int32_t sa_atimetype;
+ nfstime3 sa_atime;
+ u_int32_t sa_mtimetype;
+ nfstime3 sa_mtime;
+};
+
+struct nfs_statfs {
+ union {
+ struct {
+ u_int32_t nfsv2sf_tsize;
+ u_int32_t nfsv2sf_bsize;
+ u_int32_t nfsv2sf_blocks;
+ u_int32_t nfsv2sf_bfree;
+ u_int32_t nfsv2sf_bavail;
+ } sf_nfsv2;
+ struct {
+ nfsuint64 nfsv3sf_tbytes;
+ nfsuint64 nfsv3sf_fbytes;
+ nfsuint64 nfsv3sf_abytes;
+ nfsuint64 nfsv3sf_tfiles;
+ nfsuint64 nfsv3sf_ffiles;
+ nfsuint64 nfsv3sf_afiles;
+ u_int32_t nfsv3sf_invarsec;
+ } sf_nfsv3;
+ } sf_un;
+};
+
+#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
+#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
+#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
+#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
+#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
+#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
+#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
+#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
+#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
+#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
+#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
+#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
+
+struct nfsv3_fsinfo {
+ u_int32_t fs_rtmax;
+ u_int32_t fs_rtpref;
+ u_int32_t fs_rtmult;
+ u_int32_t fs_wtmax;
+ u_int32_t fs_wtpref;
+ u_int32_t fs_wtmult;
+ u_int32_t fs_dtpref;
+ nfsuint64 fs_maxfilesize;
+ nfstime3 fs_timedelta;
+ u_int32_t fs_properties;
+};
+
+struct nfsv3_pathconf {
+ u_int32_t pc_linkmax;
+ u_int32_t pc_namemax;
+ u_int32_t pc_notrunc;
+ u_int32_t pc_chownrestricted;
+ u_int32_t pc_caseinsensitive;
+ u_int32_t pc_casepreserving;
+};
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index 5881d52..d8e9c0d 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -1,5 +1,5 @@
/*
- * $Header: nfsfh.h,v 1.6 96/12/16 03:40:31 leres Exp $
+ * $Header: nfsfh.h,v 1.5 96/08/20 14:33:23 leres Exp $
*
* nfsfh.h - NFS file handle definitions (for portable use)
*
@@ -29,6 +29,6 @@ typedef struct {
} my_fsid;
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
- dev_eq(a.Fsid_dev, b.Fsid_dev))
+ dev_eq(a.fsid_dev, b.fsid_dev))
-extern void Parse_fh(caddr_t *, my_fsid *, ino_t *, char **, char **, int);
+extern void Parse_fh(caddr_t *, int, my_fsid *, ino_t *, char **, char **, int);
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 d7969bb..bd5e690 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -9,16 +9,14 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: parsenfsfh.c,v 1.14 97/06/15 13:20:27 leres Exp $ (LBL)";
+ "@(#) $Header: parsenfsfh.c,v 1.12 96/12/10 23:25:50 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -77,8 +75,9 @@ static const char rcsid[] =
static int is_UCX(unsigned char *);
void
-Parse_fh(fh, fsidp, inop, osnamep, fsnamep, ourself)
+Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
register caddr_t *fh;
+int len;
my_fsid *fsidp;
ino_t *inop;
char **osnamep; /* if non-NULL, return OS name here */
@@ -314,14 +313,13 @@ int ourself; /* true if file handle was generated on this host */
if (sizeof(*fsidp) >= 14) {
if (sizeof(*fsidp) > 14)
memset((char *)fsidp, 0, sizeof(*fsidp));
- /* just use the whole thing */
- memcpy((char *)fsidp, (char *)fh, 14);
+ memcpy((char *)fsidp, fh, 14); /* just use the whole thing */
}
else {
u_int32_t tempa[4]; /* at least 16 bytes, maybe more */
memset((char *)tempa, 0, sizeof(tempa));
- memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
+ memcpy((char *)tempa, fh, 14); /* ensure alignment */
fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1);
fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
fsidp->fsid_code = 0;
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index adafdf5..c9533c7 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-arp.c,v 1.43 97/06/15 13:20:27 leres Exp $ (LBL)";
+ "@(#) $Header: print-arp.c,v 1.41 96/10/27 14:54:50 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -33,13 +33,11 @@ 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>
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index 6ece6e7..c8e1c10 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-atalk.c,v 1.48 97/05/28 12:50:58 leres Exp $ (LBL)";
+ "@(#) $Header: print-atalk.c,v 1.45 96/12/10 23:24:07 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -40,7 +40,7 @@ struct rtentry;
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
@@ -55,7 +55,6 @@ struct rtentry;
#include "ethertype.h"
#include "extract.h" /* must come after interface.h */
#include "appletalk.h"
-#include "savestr.h"
static struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
@@ -103,9 +102,16 @@ atalk_print(register const u_char *bp, u_int length)
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:
@@ -163,9 +169,9 @@ aarp_print(register const u_char *bp, u_int length)
printf("aarp ");
ap = (const struct aarp *)bp;
- if (ap->htype == 1 && ap->ptype == ETHERTYPE_ATALK &&
+ if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
- switch (ap->op) {
+ switch (ntohs(ap->op)) {
case 1: /* request */
(void)printf("who-has %s tell %s",
@@ -174,7 +180,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!) */
@@ -406,11 +412,11 @@ print_cstring(register const char *cp, register const u_char *ep)
length = *cp++;
/* Spec says string can be at most 32 bytes long */
- if (length > 32) {
- (void)printf("[len=%u]", length);
+ if (length < 0 || length > 32) {
+ (void)printf("[len=%d]", length);
return (0);
}
- while ((int)--length >= 0) {
+ while (--length >= 0) {
if (cp >= (char *)ep) {
fputs(tstr, stdout);
return (0);
@@ -499,26 +505,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 %s", &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 %s", &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);
}
@@ -543,10 +547,9 @@ ataddr_string(u_short atnet, u_char athost)
tp->addr = (atnet << 8) | athost;
tp->nxt = newhnamemem();
if (athost != 255)
- (void)sprintf(nambuf, "%d.%d.%d",
- atnet >> 8, atnet & 0xff, athost);
+ (void)sprintf(nambuf, "%d.%d", atnet, athost);
else
- (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff);
+ (void)sprintf(nambuf, "%d", atnet);
tp->name = savestr(nambuf);
return (tp->name);
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index de58566..2181830 100644
--- a/contrib/tcpdump/print-atm.c
+++ b/contrib/tcpdump/print-atm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 1995, 1996, 1997
+ * Copyright (c) 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-atm.c,v 1.9 97/05/28 12:52:40 leres Exp $ (LBL)";
+ "@(#) $Header: print-atm.c,v 1.8 96/09/26 23:36:41 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -31,10 +31,12 @@ static const char rcsid[] =
struct mbuf;
struct rtentry;
#endif
+
#include <net/if.h>
+#include <net/if_var.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -46,9 +48,9 @@ struct rtentry;
#include <stdio.h>
#include <pcap.h>
-#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "interface.h"
/*
* This is the top level routine of the printer. 'p' is the points
@@ -69,7 +71,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 ",
@@ -132,14 +145,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: ",
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 0b032b4..425c11c 100644
--- a/contrib/tcpdump/print-bootp.c
+++ b/contrib/tcpdump/print-bootp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-bootp.c,v 1.46 98/07/18 13:33:58 leres Exp $ (LBL)";
+ "@(#) $Header: print-bootp.c,v 1.43 96/09/26 23:36:42 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -36,12 +36,9 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <ctype.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
#include <stdio.h>
#include <string.h>
@@ -148,7 +145,6 @@ bootp_print(register const u_char *cp, u_int length,
fputs(tstr + 1, stdout);
return;
}
- putchar('"');
}
TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_file) {
@@ -158,7 +154,6 @@ bootp_print(register const u_char *cp, u_int length,
fputs(tstr + 1, stdout);
return;
}
- putchar('"');
}
/* Decode the vendor buffer */
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index c96fb07..31c7b51 100644
--- a/contrib/tcpdump/print-domain.c
+++ b/contrib/tcpdump/print-domain.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-domain.c,v 1.39 97/06/13 12:56:28 leres Exp $ (LBL)";
+ "@(#) $Header: print-domain.c,v 1.37 96/12/10 23:21:06 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -35,7 +35,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -44,12 +44,8 @@ struct rtentry;
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
-#ifdef NOERROR
#undef NOERROR /* Solaris sucks */
-#endif
-#ifdef NOERROR
#undef T_UNSPEC /* SINIX does too */
-#endif
#include <arpa/nameser.h>
#include <stdio.h>
@@ -220,18 +216,6 @@ static struct tok type2str[] = {
{ T_GPOS, "GPOS" },
{ T_AAAA, "AAAA" },
{ T_LOC , "LOC " },
-#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" },
{ T_AXFR, "AXFR" },
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index 07a5d12..cabbe2b 100644
--- a/contrib/tcpdump/print-ether.c
+++ b/contrib/tcpdump/print-ether.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-ether.c,v 1.44 97/05/26 17:18:13 leres Exp $ (LBL)";
+ "@(#) $Header: print-ether.c,v 1.43 96/09/26 23:36:43 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -34,7 +34,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -158,6 +158,13 @@ int
ether_encap_print(u_short ethertype, const u_char *p,
u_int length, u_int caplen)
{
+ if (ethertype == 0x8100) { /* IEEE 802.1Q vlan tagging encapsulation */
+ printf ("[vlan %d] ", ntohs(*(u_short *)p) & 0x17ff);
+ ethertype = ntohs(((u_short *)p)[1]);
+ p += 4;
+ length -= 4;
+ caplen -= 4;
+ }
extracted_ethertype = ethertype;
switch (ethertype) {
@@ -185,6 +192,10 @@ ether_encap_print(u_short ethertype, const u_char *p,
aarp_print(p, length);
return (1);
+ case ETHERTYPE_IPX:
+ ipx_print(p, length);
+ return (1);
+
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index 3c1813a..1714735 100644
--- a/contrib/tcpdump/print-fddi.c
+++ b/contrib/tcpdump/print-fddi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-fddi.c,v 1.36 97/05/26 17:13:35 leres Exp $ (LBL)";
+ "@(#) $Header: print-fddi.c,v 1.33 96/12/10 23:20:49 leres Exp $ (LBL)";
#endif
#ifdef HAVE_FDDI
@@ -38,13 +38,14 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -57,7 +58,7 @@ struct rtentry;
/*
* Some FDDI interfaces use bit-swapped addresses.
*/
-#if defined(ultrix) || defined(__alpha) || defined(__bsdi)
+#if defined(ultrix) || defined(__alpha)
int fddi_bitswap = 0;
#else
int fddi_bitswap = 1;
diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c
new file mode 100644
index 0000000..80364d3
--- /dev/null
+++ b/contrib/tcpdump/print-fr.c
@@ -0,0 +1,424 @@
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char rcsid[] =
+ "@(#)$Header: /home/ncvs/src/contrib/tcpdump/print-fr.c,v 1.1 1997/12/31 21:50:31 pst Exp $ (LBL)";
+#endif
+
+#ifdef PPP
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+
+#if __STDC__
+struct mbuf;
+struct rtentry;
+#endif
+#include <net/if.h>
+#include <net/if_var.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip.h>
+
+#include <ctype.h>
+#include <netdb.h>
+#include <pcap.h>
+#include <signal.h>
+#include <stdio.h>
+
+#include <netinet/if_ether.h>
+#include "ethertype.h"
+
+#include <net/ppp_defs.h>
+#include "interface.h"
+#include "addrtoname.h"
+
+
+void q933_print();
+
+#define FR_EA_BIT(p) ((p)&0x1)
+#define FR_DLCI(b0,b1) ((((b0)&0xFC)<<2)+(((b1)&0xF0)>>4))
+
+struct fr_nlpids {
+ u_short id;
+ char *name;
+};
+
+/* find out how many bytes are there in a frame */
+int
+fr_addr_len(const u_char *p)
+{
+ int i=0;
+
+ while (!FR_EA_BIT(p[i]) && i++ && !FR_EA_BIT(p[i+1])) i++;
+ return (i+1);
+}
+
+/* the following is for framerelay */
+#define NLPID_LEN 1 /* NLPID is one byte long */
+#define NLPID_Q933 0x08
+#define NLPID_CLNP 0x81
+#define NLPID_ESIS 0x82
+#define NLPID_ISIS 0x83
+#define NLPID_CONS 0x84
+#define NLPID_IDRP 0x85
+#define NLPID_X25_ESIS 0x8a
+#define NLPID_IP 0xcc
+
+
+static struct fr_nlpids fr_nlpids[256];
+static fr_nlpid_flag =0;
+
+void init_fr_nlpids()
+{
+ int i;
+
+ if (!fr_nlpid_flag) {
+ for (i=0; i < 256; i++) {
+ fr_nlpids[i].id = 0;
+ fr_nlpids[i].name = "Not Specified";
+ }
+ fr_nlpids[NLPID_Q933].name = "Q.933";
+ fr_nlpids[NLPID_CLNP].name = "CLNP";
+ fr_nlpids[NLPID_ESIS].name = "ESIS";
+ fr_nlpids[NLPID_ISIS].name = "ISIS";
+ fr_nlpids[NLPID_CONS].name = "CONS";
+ fr_nlpids[NLPID_IDRP].name = "IDRP";
+ fr_nlpids[NLPID_X25_ESIS].name = "X25_ESIS";
+ fr_nlpids[NLPID_IP].name = "IP";
+ }
+ fr_nlpid_flag = 1;
+}
+
+/* Framerelay packet structure */
+
+/*
+ +---------------------------+
+ | flag (7E hexadecimal) |
+ +---------------------------+
+ | Q.922 Address* |
+ +-- --+
+ | |
+ +---------------------------+
+ | Control (UI = 0x03) |
+ +---------------------------+
+ | Optional Pad (0x00) |
+ +---------------------------+
+ | NLPID |
+ +---------------------------+
+ | . |
+ | . |
+ | . |
+ | Data |
+ | . |
+ | . |
+ +---------------------------+
+ | Frame Check Sequence |
+ +-- . --+
+ | (two octets) |
+ +---------------------------+
+ | flag (7E hexadecimal) |
+ +---------------------------+
+
+ * Q.922 addresses, as presently defined, are two octets and
+ contain a 10-bit DLCI. In some networks Q.922 addresses
+ may optionally be increased to three or four octets.
+
+*/
+
+#define FR_PROTOCOL(p) fr_protocol((p))
+
+int
+fr_hdrlen(const u_char *p)
+{
+ int hlen;
+ hlen = fr_addr_len(p)+1; /* addr_len + 0x03 + padding */
+ if( p[hlen] )
+ return hlen;
+ else
+ return hlen+1;
+}
+
+#define LAYER2_LEN(p) (fr_hdrlen((p))+NLPID_LEN)
+
+int
+fr_protocol(const u_char *p)
+{
+ int hlen;
+
+ hlen = fr_addr_len(p) + 1;
+ if (p[hlen]) /* check for padding */
+ return p[hlen];
+ else
+ return p[hlen+1];
+}
+
+void
+fr_hdlc_print(const u_char *p, int length)
+{
+ int proto;
+ int i;
+ int hlen;
+
+ proto = FR_PROTOCOL(p);
+
+ init_fr_nlpids();
+ /* this is kinda kludge since it assumed that DLCI is two bytes. */
+ printf("%4d %02x%02x=DLCI(%d) ", length, p[0], p[1], FR_DLCI(p[0],p[1]));
+ printf("%02x %6s: ", proto, fr_nlpids[proto].name);
+}
+
+
+
+void
+fr_if_print(u_char *user, const struct pcap_pkthdr *h,
+ register const u_char *p)
+{
+ register u_int length = h->len;
+ register u_int caplen = h->caplen;
+ int frame_relay = 0,
+ proto = FR_PROTOCOL(p);
+
+
+ ts_print(&h->ts);
+
+ if (caplen < fr_hdrlen(p)) {
+ printf("[|fr]");
+ 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;
+
+ if (eflag)
+ fr_hdlc_print(p, length);
+
+ length = length - (fr_hdrlen(p) + NLPID_LEN);
+
+
+ switch(FR_PROTOCOL(p)) {
+ case NLPID_IP:
+ case ETHERTYPE_IP:
+ ip_print((const u_char *)(p + LAYER2_LEN(p)), length);
+ break;
+ case NLPID_CLNP:
+ case NLPID_ESIS:
+ case NLPID_ISIS:
+ isoclns_print((const u_char *)(p + LAYER2_LEN(p)), length,
+ caplen, "000000", "000000");
+ break;
+ case NLPID_Q933:
+ q933_print((const u_char *)(p + LAYER2_LEN(p)), length);
+ break;
+ default:
+ if(!eflag)
+ fr_hdlc_print(p, length);
+ if(!xflag)
+ default_print((const u_char *)(p + LAYER2_LEN(p)),
+ caplen - LAYER2_LEN(p));
+ }
+
+ if (xflag)
+ default_print((const u_char *)(p + LAYER2_LEN(p)),
+ caplen - LAYER2_LEN(p));
+out:
+ putchar('\n');
+}
+#else
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <stdio.h>
+
+#include "interface.h"
+void
+fr_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ error("not configured for ppp");
+ /* NOTREACHED */
+}
+#endif
+
+/*
+ * Q.933 decoding portion for framerelay specific.
+ */
+
+/* Q.933 packet format
+ Format of Other Protocols
+ using Q.933 NLPID
+ +-------------------------------+
+ | Q.922 Address |
+ +---------------+---------------+
+ |Control 0x03 | NLPID 0x08 |
+ +---------------+---------------+
+ | L2 Protocol ID |
+ | octet 1 | octet 2 |
+ +-------------------------------+
+ | L3 Protocol ID |
+ | octet 2 | octet 2 |
+ +-------------------------------+
+ | Protocol Data |
+ +-------------------------------+
+ | FCS |
+ +-------------------------------+
+ */
+
+/* L2 (Octet 1)- Call Reference Usually is 0x0 */
+
+/*
+ * L2 (Octet 2)- Message Types definition 1 byte long.
+ */
+/* Call Establish */
+#define MSG_TYPE_ESC_TO_NATIONAL 0x00
+#define MSG_TYPE_ALERT 0x01
+#define MSG_TYPE_CALL_PROCEEDING 0x02
+#define MSG_TYPE_CONNECT 0x07
+#define MSG_TYPE_CONNECT_ACK 0x0F
+#define MSG_TYPE_PROGRESS 0x03
+#define MSG_TYPE_SETUP 0x05
+/* Call Clear */
+#define MSG_TYPE_DISCONNECT 0x45
+#define MSG_TYPE_RELEASE 0x4D
+#define MSG_TYPE_RELEASE_COMPLETE 0x5A
+#define MSG_TYPE_RESTART 0x46
+#define MSG_TYPE_RESTART_ACK 0x4E
+/* Status */
+#define MSG_TYPE_STATUS 0x7D
+#define MSG_TYPE_STATUS_ENQ 0x75
+
+#define ONE_BYTE_IE_MASK 0xF0
+
+/* See L2 protocol ID picture above */
+struct q933_header {
+ u_char call_ref; /* usually is 0 for framerelay PVC */
+ u_char msg_type;
+};
+
+#define REPORT_TYPE_IE 0x01
+#define LINK_VERIFY_IE_91 0x19
+#define LINK_VERIFY_IE_94 0x03
+#define PVC_STATUS_IE 0x07
+
+#define MAX_IE_SIZE
+
+struct common_ie_header {
+ u_char ie_id;
+ u_char ie_len;
+};
+
+#define FULL_STATUS 0
+#define LINK_VERIFY 1
+#define ASYNC_PVC 2
+
+
+void
+q933_print(const u_char *p, int length)
+{
+ struct q933_header *header = (struct q933_header *)(p+1);
+ const u_char *ptemp = p;
+ int ie_type, ie_len;
+ char *decode_str, temp_str[255];
+ struct common_ie_header *ie_p;
+
+
+ /* printing out header part */
+ printf("Call Ref: %02x, MSG Type: %02x",
+ header->call_ref, header->msg_type);
+ switch(header->msg_type) {
+ case MSG_TYPE_STATUS:
+ decode_str = "STATUS REPLY";
+ break;
+ case MSG_TYPE_STATUS_ENQ:
+ decode_str = "STATUS ENQUIRY";
+ break;
+ default:
+ decode_str = "UNKNOWN MSG Type";
+ }
+ printf(" %s\n", decode_str);
+
+ length = length - 3;
+ ptemp = ptemp + 3;
+
+ /* Loop through the rest of IE */
+ while( length > 0 ) {
+ if( ptemp[0] & ONE_BYTE_IE_MASK ) {
+ ie_len = 1;
+ printf("\t\tOne byte IE: %02x, Content %02x\n",
+ (*ptemp & 0x70)>>4, (*ptemp & 0x0F));
+ length--;
+ ptemp++;
+ }
+ else { /* Multi-byte IE */
+ ie_p = (struct common_ie_header *)ptemp;
+ switch (ie_p->ie_id) {
+ case REPORT_TYPE_IE:
+ switch(ptemp[2]) {
+ case FULL_STATUS:
+ decode_str = "FULL STATUS";
+ break;
+ case LINK_VERIFY:
+ decode_str = "LINK VERIFY";
+ break;
+ case ASYNC_PVC:
+ decode_str = "Async PVC Status";
+ break;
+ default:
+ decode_str = "Reserved Value";
+ }
+ break;
+ case LINK_VERIFY_IE_91:
+ case LINK_VERIFY_IE_94:
+ sprintf(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",
+ ((ptemp[2]&0x3f)<<4)+ ((ptemp[3]&0x78)>>3),
+ ptemp[4] & 0x8 ?"new,":" ",
+ ptemp[4] & 0x2 ?"Active":"Inactive");
+ break;
+ default:
+ decode_str = "Non-decoded Value";
+ }
+ printf("\t\tIE: %02X Len: %d, %s\n",
+ ie_p->ie_id, ie_p->ie_len, decode_str);
+ length = length - ie_p->ie_len - 2;
+ ptemp = ptemp + ie_p->ie_len + 2;
+ }
+ }
+
+}
+
+
+
+
+
+
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index c72988d..70139e0 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -35,7 +35,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 30e13a1..fdad8e2 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/print-ip.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-ip.c,v 1.66 97/05/28 12:51:43 leres Exp $ (LBL)";
+ "@(#) $Header: print-ip.c,v 1.62 96/12/10 23:20:31 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -37,9 +37,6 @@ static const char rcsid[] =
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -158,22 +155,30 @@ igmp_print(register const u_char *bp, register u_int len,
TCHECK2(bp[0], 8);
switch (bp[0]) {
case 0x11:
- (void)printf("igmp query");
+ (void)printf("igmp %s query", bp[1] ? "v2" : "v1");
+ if (bp[1] && bp[1] != 100)
+ (void)printf(" [intvl %d]", bp[1]);
if (*(int *)&bp[4])
(void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
if (len != 8)
(void)printf(" [len %d]", len);
break;
case 0x12:
- (void)printf("igmp report %s", ipaddr_string(&bp[4]));
+ 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);
- break;
- case 0x16:
- (void)printf("igmp nreport %s", ipaddr_string(&bp[4]));
+ 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");
@@ -194,10 +199,10 @@ igmp_print(register const u_char *bp, register u_int len,
break;
default:
(void)printf("igmp-%d", bp[0] & 0xf);
+ if (bp[1])
+ (void)printf(" [b1=0x%02x]", bp[1]);
break;
}
- if ((bp[0] >> 4) != 1)
- (void)printf(" [v%d]", bp[0] >> 4);
TCHECK2(bp[0], len);
if (vflag) {
@@ -299,6 +304,12 @@ ip_optprint(register const u_char *cp, u_int length)
ip_printroute("LSRR", cp, len);
break;
+ case IPOPT_RA:
+ printf(" RA{%d}", len);
+ if (cp[2] != 0 || cp[3] != 0)
+ printf(" [b23=0x04%x]", cp[2] << 8 | cp[3]);
+ break;
+
default:
printf(" IPOPT-%d{%d}", cp[0], len);
break;
@@ -434,15 +445,18 @@ ip_print(register const u_char *bp, register u_int length)
igmp_print(cp, len, (const u_char *)ip);
break;
- case 4:
- /* DVMRP multicast tunnel (ip-in-ip encapsulation) */
+#ifndef IPPROTO_IPIP
+#define IPPROTO_IPIP 4
+#endif
+ case IPPROTO_IPIP:
+ /* ip-in-ip encapsulation */
if (vflag)
(void)printf("%s > %s: ",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
ip_print(cp, len);
if (! vflag) {
- printf(" (ipip)");
+ printf(" (encap)");
return;
}
break;
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index ccd6b53..d49bcb7 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -190,7 +190,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;
@@ -198,7 +198,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 629dfe0..376cbba 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -23,7 +23,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-isoclns.c,v 1.15 96/12/31 21:27:41 leres Exp $ (LBL)";
+ "@(#) $Header: print-isoclns.c,v 1.14 96/12/10 23:26:56 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -37,26 +37,149 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <stdio.h>
#include "interface.h"
#include "addrtoname.h"
#include "ethertype.h"
+#include "extract.h"
-#define CLNS 129
-#define ESIS 130
-#define ISIS 131
-#define NULLNS 0
+#define NLPID_CLNS 129 /* 0x81 */
+#define NLPID_ESIS 130 /* 0x82 */
+#define NLPID_ISIS 131 /* 0x83 */
+#define NLPID_NULLNS 0
-static int osi_cksum(const u_char *, u_int, const u_char *, u_char *, u_char *);
+
+/*
+ * IS-IS is defined in ISO 10589. Look there for protocol definitions.
+ */
+
+#define SYSTEM_ID_LEN sizeof(struct ether_addr)
+#define ISIS_VERSION 1
+#define PDU_TYPE_MASK 0x1F
+#define PRIORITY_MASK 0x7F
+
+#define L1_LAN_IIH 15
+#define L2_LAN_IIH 16
+#define PTP_IIH 17
+#define L1_LS_PDU 18
+#define L2_LS_PDU 19
+#define L1_COMPLETE_SEQ_PDU 24
+#define L2_COMPLETE_SEQ_PDU 25
+
+/*
+ * A TLV is a tuple of a type, length and a value and is normally used for
+ * encoding information in all sorts of places. This is an enumeration of
+ * the well known types.
+ */
+
+#define TLV_AREA_ADDR 1
+#define TLV_IS_REACH 2
+#define TLV_ES_REACH 3
+#define TLV_SUMMARY 5
+#define TLV_ISNEIGH 6
+#define TLV_PADDING 8
+#define TLV_LSP 9
+#define TLV_AUTHENT 10
+#define TLV_IP_REACH 128
+#define TLV_PROTOCOLS 129
+#define TLV_IP_EXTERN 130
+#define TLV_IDRP_INFO 131
+#define TLV_IPADDR 132
+#define TLV_IPAUTH 133
+#define TLV_PTP_ADJ 240
+
+/*
+ * Katz's point to point adjacency TLV uses codes to tell us the state of
+ * the remote adjacency. Enumerate them.
+ */
+
+#define ISIS_PTP_ADJ_UP 0
+#define ISIS_PTP_ADJ_INIT 1
+#define ISIS_PTP_ADJ_DOWN 2
+
+static int osi_cksum(const u_char *, int, u_char *);
static void esis_print(const u_char *, u_int);
+static int isis_print(const u_char *, u_int);
+
+
+struct isis_ptp_adjancey_values {
+ u_char id;
+ char *name;
+};
+
+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"
+};
+
+struct isis_common_header {
+ u_char nlpid;
+ u_char fixed_len;
+ u_char version; /* Protocol version? */
+ u_char id_length;
+ u_char enc_pdu_type; /* 3 MSbs are reserved */
+ u_char pkt_version; /* Packet format version? */
+ u_char reserved;
+ u_char enc_max_area;
+};
+
+struct isis_header {
+ u_char nlpid;
+ u_char fixed_len;
+ u_char version; /* Protocol version? */
+ u_char id_length;
+ u_char enc_pdu_type; /* 3 MSbs are reserved */
+ u_char pkt_version; /* Packet format version? */
+ u_char reserved;
+ u_char enc_max_area;
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char enc_priority;
+ u_char enc_lan_id[SYSTEM_ID_LEN+1];
+};
+struct isis_lan_header {
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char enc_priority;
+ u_char enc_lan_id[SYSTEM_ID_LEN+1];
+};
+
+struct isis_ptp_header {
+ u_char circuit;
+ u_char enc_source_id[SYSTEM_ID_LEN];
+ u_char enc_holding_time[2];
+ u_char enc_packet_len[2];
+ u_char loc_circuit_id;
+};
+
+#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
+#define ISIS_HEADER_SIZE (15+(SYSTEM_ID_LEN<<1))
+#define ISIS_PTP_HEADER_SIZE (14+SYSTEM_ID_LEN)
+#define L1_LS_PDU_HEADER_SIZE (21+SYSTEM_ID_LEN)
+#define L2_LS_PDU_HEADER_SIZE L1_LS_PDU_HEADER_SIZE
+#define L1_COMPLETE_SEQ_PDU_HEADER_SIZE 33
+#define L2_COMPLETE_SEQ_PDU_HEADER_SIZE L1_COMPLETE_SEQ_PDU_HEADER_SIZE
+
+
void
isoclns_print(const u_char *p, u_int length, u_int caplen,
const u_char *esrc, const u_char *edst)
{
+ u_char pdu_type;
+ struct isis_header *header;
+
+ header = (struct isis_header *)p;
+ pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
+
if (caplen < 1) {
printf("[|iso-clns] ");
if (!eflag)
@@ -68,17 +191,16 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
switch (*p) {
- case CLNS:
- /* esis_print(&p, &length); */
- printf("iso-clns");
+ case NLPID_CLNS:
+ printf("iso clns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
break;
- case ESIS:
- printf("iso-esis");
+ case NLPID_ESIS:
+ printf("iso esis");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -86,20 +208,21 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
esis_print(p, length);
return;
- case ISIS:
- printf("iso-isis");
- if (!eflag)
- (void)printf(" %s > %s",
+ case NLPID_ISIS:
+ printf("iso isis");
+ if (!eflag) {
+ if(pdu_type != PTP_IIH)
+ (void)printf(" %s > %s",
etheraddr_string(esrc),
etheraddr_string(edst));
- /* isis_print(&p, &length); */
+ }
(void)printf(" len=%d ", length);
- if (caplen > 1)
- default_print_unaligned(p, caplen);
+ if (!isis_print(p, length))
+ default_print_unaligned(p, caplen);
break;
- case NULLNS:
- printf("iso-nullns");
+ case NLPID_NULLNS:
+ printf("iso nullns");
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -107,7 +230,7 @@ isoclns_print(const u_char *p, u_int length, u_int caplen,
break;
default:
- printf("iso-clns %02x", p[0]);
+ printf("iso clns %02x", p[0]);
if (!eflag)
(void)printf(" %s > %s",
etheraddr_string(esrc),
@@ -160,7 +283,7 @@ esis_print(const u_char *p, u_int length)
printf(" bad pkt!");
else {
printf(" too short for esis header %d:", li);
- while (--length != 0)
+ while (--length >= 0)
printf("%02X", *p++);
}
return;
@@ -185,9 +308,10 @@ esis_print(const u_char *p, u_int length)
}
off[0] = eh->cksum[0];
off[1] = eh->cksum[1];
- if (vflag && osi_cksum(p, li, eh->cksum, cksum, off)) {
- printf(" bad cksum (got %02x%02x want %02x%02x)",
- eh->cksum[1], eh->cksum[0], cksum[1], cksum[0]);
+ if (vflag && osi_cksum(p, li, off)) {
+ printf(" bad cksum (got %02x%02x)",
+ eh->cksum[1], eh->cksum[0]);
+ default_print(p, length);
return;
}
if (eh->version != 1) {
@@ -204,7 +328,7 @@ esis_print(const u_char *p, u_int length)
dst = p; p += *p + 1;
if (p > snapend)
return;
- printf(" %s", isonsap_string(dst));
+ printf("\n\t\t\t %s", isonsap_string(dst));
snpa = p; p += *p + 1;
is = p; p += *p + 1;
if (p > snapend)
@@ -235,7 +359,8 @@ esis_print(const u_char *p, u_int length)
}
if (p > snapend)
return;
- printf(" %s", isonsap_string(is));
+ if (!qflag)
+ printf("\n\t\t\t %s", isonsap_string(is));
li = ep - p;
break;
}
@@ -282,36 +407,267 @@ esis_print(const u_char *p, u_int length)
}
}
+/*
+ * print_nsap
+ * Print out an NSAP.
+ */
+
+void
+print_nsap (register const u_char *cp, register int length)
+{
+ int i;
+
+ for (i = 0; i < length; i++) {
+ printf("%02x", *cp++);
+ if (((i & 1) == 0) && (i + 1 < length)) {
+ printf(".");
+ }
+
+ }
+}
+
+/*
+ * isis_print
+ * Decode IS-IS packets. Return 0 on error.
+ *
+ * So far, this is only smart enough to print IIH's. Someday...
+ */
+
static int
-osi_cksum(register const u_char *p, register u_int len,
- const u_char *toff, u_char *cksum, u_char *off)
+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, *pptr, type, len, *tptr, tmp, alen;
+ u_short packet_len, holding_time;
+ int i;
+
+ header_ptp = (struct isis_ptp_header *)header = (struct isis_header *)p;
+ printf("\n\t\t\t");
+
+ /*
+ * Sanity checking of the header.
+ */
+ if (header->nlpid != NLPID_ISIS) {
+ printf(" coding error!");
+ return(0);
+ }
+
+ if (header->version != ISIS_VERSION) {
+ printf(" version %d packet not supported", header->version);
+ return(0);
+ }
+
+ if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) {
+ printf(" system ID length of %d is not supported",
+ header->id_length);
+ return(0);
+ }
+
+ if ((header->fixed_len != ISIS_HEADER_SIZE) &&
+ (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",
+ header->fixed_len);
+ return(0);
+ }
+
+ pdu_type = header->enc_pdu_type & PDU_TYPE_MASK;
+ if ((pdu_type != L1_LAN_IIH) && (pdu_type != L2_LAN_IIH) &&
+ (pdu_type != PTP_IIH) &&
+ (pdu_type != L1_COMPLETE_SEQ_PDU) &&
+ (pdu_type != L2_COMPLETE_SEQ_PDU) ) {
+ printf(" PDU type (%d) not supported", pdu_type);
+ return;
+ }
+
+ if (header->pkt_version != ISIS_VERSION) {
+ printf(" version %d packet not supported", header->pkt_version);
+ return;
+ }
+
+ max_area = header->enc_max_area;
+ switch(max_area) {
+ case 0:
+ max_area = 3; /* silly shit */
+ break;
+ case 255:
+ printf(" bad packet -- 255 areas");
+ return(0);
+ default:
+ break;
+ }
+
+ switch (header->circuit) {
+ case 0:
+ printf(" PDU with circuit type 0");
+ return(0);
+ case 1:
+ if (pdu_type == L2_LAN_IIH) {
+ printf(" L2 IIH on an L1 only circuit");
+ return(0);
+ }
+ break;
+ case 2:
+ if (pdu_type == L1_LAN_IIH) {
+ printf(" L1 IIH on an L2 only circuit");
+ return(0);
+ }
+ break;
+ case 3:
+ break;
+ default:
+ printf(" unknown circuit type");
+ return(0);
+ }
+
+ holding_time = EXTRACT_16BITS(header->enc_holding_time);
+
+ packet_len = EXTRACT_16BITS(header->enc_packet_len);
+ if ((packet_len < ISIS_HEADER_SIZE) ||
+ (packet_len > length)) {
+ printf(" bogus packet length %d, real length %d", packet_len,
+ length);
+ return(0);
+ }
+
+ if(pdu_type != PTP_IIH)
+ priority = header->enc_priority & PRIORITY_MASK;
+
+ /*
+ * Now print the fixed header.
+ */
+ switch (pdu_type) {
+ case L1_LAN_IIH:
+ printf(" L1 lan iih, ");
+ break;
+ case L2_LAN_IIH:
+ printf(" L2 lan iih, ");
+ break;
+ case PTP_IIH:
+ printf(" PTP iih, ");
+ break;
+ }
+
+ printf("circuit ");
+ switch (header->circuit) {
+ case 1:
+ printf("l1 only, ");
+ break;
+ case 2:
+ printf("l2 only, ");
+ break;
+ case 3:
+ printf("l1-l2, ");
+ break;
+ }
+
+ printf ("holding time %d ", holding_time);
+ printf ("\n\t\t\t source %s, length %d",
+ etheraddr_string(header->enc_source_id), packet_len);
+ if((pdu_type==L1_LAN_IIH)||(pdu_type==L2_LAN_IIH))
+ printf ("\n\t\t\t lan id %s(%d)", etheraddr_string(header->enc_lan_id),
+ header->enc_lan_id[SYSTEM_ID_LEN]);
+
+ /*
+ * Now print the TLV's.
+ */
+ if(pdu_type==PTP_IIH) {
+ packet_len -= ISIS_PTP_HEADER_SIZE;
+ pptr = (char *)p + ISIS_PTP_HEADER_SIZE;
+ } else {
+ packet_len -= ISIS_HEADER_SIZE;
+ pptr = (char *)p + ISIS_HEADER_SIZE;
+ }
+ while (packet_len >= 2) {
+ if (pptr >= snapend) {
+ printf("\n\t\t\t packet exceeded snapshot");
+ return(1);
+ }
+ type = *pptr++;
+ len = *pptr++;
+ packet_len -= 2;
+ if (len > packet_len) {
+ break;
+ }
+
+ switch (type) {
+ case TLV_AREA_ADDR:
+ printf("\n\t\t\t area addresses");
+ tmp = len;
+ tptr = pptr;
+ alen = *tptr++;
+ while (tmp && alen < tmp) {
+ printf("\n\t\t\t ");
+ print_nsap(tptr, alen);
+ printf(" (%d)", alen);
+ tptr += alen;
+ tmp -= alen + 1;
+ alen = *tptr++;
+ }
+ break;
+ case TLV_ISNEIGH:
+ printf("\n\t\t\t neighbor addresses");
+ tmp = len;
+ tptr = pptr;
+ while (tmp >= sizeof(struct ether_addr)) {
+ printf("\n\t\t\t %s", etheraddr_string(tptr));
+ tmp -= sizeof(struct ether_addr);
+ tptr += sizeof(struct ether_addr);
+ }
+ break;
+ case TLV_PADDING:
+ printf("\n\t\t\t padding for %d bytes", len);
+ break;
+ case TLV_AUTHENT:
+ printf("\n\t\t\t authentication data");
+ default_print(pptr, len);
+ break;
+ case TLV_PTP_ADJ:
+ printf("\n\t\t\t PTP adjacency status %s",
+ isis_ptp_adjancey_values[*pptr].name);
+ break;
+ case TLV_PROTOCOLS:
+ printf("\n\t\t\t Supports protocols %s", (len>1)? "are":"is");
+ for(i=0;i<len;i++)
+ printf(" %02X", (u_char)*(pptr+i));
+ break;
+ case TLV_IPADDR:
+ printf("\n\t\t\t IP address: %s", ipaddr_string(pptr));
+ break;
+ default:
+ printf("\n\t\t\t unknown TLV, type %d, length %d", type, len);
+ break;
+ }
+
+ pptr += len;
+ packet_len -= len;
+ }
+
+ if (packet_len != 0) {
+ printf("\n\t\t\t %d straggler bytes", packet_len);
+ }
+ return(1);
+}
+
+/*
+ * Verify the checksum. See 8473-1, Appendix C, section C.4.
+ */
+
+static int
+osi_cksum(register const u_char *p, register int len, u_char *off)
{
- int x, y, f = (len - ((toff - p) + 1));
int32_t c0 = 0, c1 = 0;
- if ((cksum[0] = off[0]) == 0 && (cksum[1] = off[1]) == 0)
+ if ((off[0] == 0) && (off[1] == 0))
return 0;
- off[0] = off[1] = 0;
- while ((int)--len >= 0) {
+ while (--len >= 0) {
c0 += *p++;
- c1 += c0;
c0 %= 255;
+ c1 += c0;
c1 %= 255;
}
- x = (c0 * f - c1);
- if (x < 0)
- x = 255 - (-x % 255);
- else
- x %= 255;
- y = -1 * (x + c0);
- if (y < 0)
- y = 255 - (-y % 255);
- else
- y %= 255;
-
- off[0] = x;
- off[1] = y;
-
- return (off[0] != cksum[0] || off[1] != cksum[1]);
+ return (c0 | c1);
}
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index da68156..b1f17f9 100644
--- a/contrib/tcpdump/print-llc.c
+++ b/contrib/tcpdump/print-llc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-llc.c,v 1.24 97/01/01 20:56:48 leres Exp $";
+ "@(#) $Header: print-llc.c,v 1.22 96/12/10 23:23:37 leres Exp $";
#endif
#include <sys/param.h>
@@ -34,6 +34,7 @@ static const char rcsid[] =
#include <ctype.h>
#include <netdb.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -185,7 +186,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
caplen -= 4;
}
(void)printf(" len=%d", length);
- if (caplen > 0) {
+ 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 a8e371e..fd71a46 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,21 +21,17 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-nfs.c,v 1.65 97/08/17 13:24:22 leres Exp $ (LBL)";
+ "@(#) $Header: print-nfs.c,v 1.63 96/12/10 23:18:07 leres Exp $ (LBL)";
#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 <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -49,32 +45,209 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
+#include "extract.h" /* must come after interface.h */
-#include "nfsv2.h"
+#include "nfs.h"
#include "nfsfh.h"
-static void nfs_printfh(const 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 u_int32_t xid_map_find(const struct rpc_msg *, const struct ip *,
- u_int32_t *);
-static void interp_reply(const struct rpc_msg *, u_int32_t, u_int);
+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 int nfserr; /* true if we error rather than trunc */
+/*
+ * Mapping of old NFS Version 2 RPC numbers to generic numbers.
+ */
+u_int32_t nfsv3_procid[NFS_NPROCS] = {
+ NFSPROC_NULL,
+ NFSPROC_GETATTR,
+ NFSPROC_SETATTR,
+ NFSPROC_NOOP,
+ NFSPROC_LOOKUP,
+ NFSPROC_READLINK,
+ NFSPROC_READ,
+ NFSPROC_NOOP,
+ NFSPROC_WRITE,
+ NFSPROC_CREATE,
+ NFSPROC_REMOVE,
+ NFSPROC_RENAME,
+ NFSPROC_LINK,
+ NFSPROC_SYMLINK,
+ NFSPROC_MKDIR,
+ NFSPROC_RMDIR,
+ NFSPROC_READDIR,
+ NFSPROC_FSSTAT,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP,
+ NFSPROC_NOOP
+};
+
+const char *nfsv3_writemodes[NFSV3WRITE_NMODES] = {
+ "unstable",
+ "datasync",
+ "filesync"
+};
+
+static struct tok type2str[] = {
+ { NFNON, "NON" },
+ { NFREG, "REG" },
+ { NFDIR, "DIR" },
+ { NFBLK, "BLK" },
+ { NFCHR, "CHR" },
+ { NFLNK, "LNK" },
+ { NFFIFO, "FIFO" },
+ { 0, NULL }
+};
+
+/*
+ * Print out a 64-bit integer. This appears to be different on each system,
+ * try to make the best of it. The integer stored as 2 consecutive XDR
+ * encoded 32-bit integers, to which a pointer is passed.
+ *
+ * Assume that a system that has INT64_FORMAT defined, has a 64-bit
+ * integer datatype and can print it.
+ */
+
+#define UNSIGNED 0
+#define SIGNED 1
+#define HEX 2
+
+#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;
+
+ res = ((u_int64_t)ntohl(dp[0]) << 32) | (u_int64_t)ntohl(dp[1]);
+ switch (how) {
+ case SIGNED:
+ printf(INT64_FORMAT, res);
+ break;
+ case UNSIGNED:
+ printf(U_INT64_FORMAT, res);
+ break;
+ case HEX:
+ printf(HEX_INT64_FORMAT, res);
+ break;
+ default:
+ return (0);
+ }
+#else
+ /*
+ * 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 const u_int32_t *
+parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
+{
+ register const u_int32_t *ep = (u_int32_t *)snapend;
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_modeset = ntohl(*dp++))) {
+ if (dp + 1 > ep)
+ return (NULL);
+ sa3->sa_mode = ntohl(*dp++);
+ }
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_uidset = ntohl(*dp++))) {
+ if (dp + 1 > ep)
+ return (NULL);
+ sa3->sa_uid = ntohl(*dp++);
+ }
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_gidset = ntohl(*dp++))) {
+ if (dp + 1 > ep)
+ return (NULL);
+ sa3->sa_gid = ntohl(*dp++);
+ }
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_sizeset = ntohl(*dp++))) {
+ if (dp + 1 > ep)
+ return (NULL);
+ sa3->sa_size = ntohl(*dp++);
+ }
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
+ if (dp + 2 > ep)
+ return (NULL);
+ sa3->sa_atime.nfsv3_sec = ntohl(*dp++);
+ sa3->sa_atime.nfsv3_nsec = ntohl(*dp++);
+ }
+
+ if (dp + 1 > ep)
+ return (NULL);
+ if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
+ if (dp + 2 > ep)
+ return (NULL);
+ sa3->sa_mtime.nfsv3_sec = ntohl(*dp++);
+ sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++);
+ }
+
+ return dp;
+}
+
+void
+print_sattr3(const struct nfsv3_sattr *sa3, int verbose)
+{
+ if (sa3->sa_modeset)
+ printf(" mode %o", sa3->sa_mode);
+ if (sa3->sa_uidset)
+ printf(" uid %u", sa3->sa_uid);
+ if (sa3->sa_gidset)
+ printf(" gid %u", sa3->sa_gid);
+ if (verbose > 1) {
+ if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT)
+ printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec,
+ sa3->sa_atime.nfsv3_nsec);
+ if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT)
+ printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
+ sa3->sa_mtime.nfsv3_nsec);
+ }
+}
+
void
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;
+ u_int32_t proc, vers;
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
ip = (const struct ip *)bp2;
if (!nflag)
- (void)printf("%s.nfs > %s.%u: reply %s %d",
+ (void)printf("%s.nfs > %s.%x: reply %s %d",
ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst),
(u_int32_t)ntohl(rp->rm_xid),
@@ -82,7 +255,7 @@ nfsreply_print(register const u_char *bp, u_int length,
"ok":"ERR",
length);
else
- (void)printf("%s.%u > %s.%u: reply %s %d",
+ (void)printf("%s.%x > %s.%x: reply %s %d",
ipaddr_string(&ip->ip_src),
NFS_PORT,
ipaddr_string(&ip->ip_dst),
@@ -91,16 +264,16 @@ nfsreply_print(register const u_char *bp, u_int length,
"ok":"ERR",
length);
- if (xid_map_find(rp, ip, &proc))
- interp_reply(rp, proc, length);
+ 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;
@@ -127,21 +300,31 @@ 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)
+parsefh(register const u_int32_t *dp, int v3)
{
- if (dp + 8 <= (u_int32_t *)snapend) {
- nfs_printfh(dp);
- return (dp + 8);
+ int len;
+
+ if (v3) {
+ TCHECK(dp[0]);
+ len = (int)ntohl(*dp) / 4;
+ dp++;
+ } else
+ len = NFSX_V2FH / 4;
+
+ if (TTEST2(*dp, len * sizeof(*dp))) {
+ nfs_printfh(dp, len);
+ return (dp + len);
}
+trunc:
return (NULL);
}
/*
* Print out a file name and return pointer to 32-bit word past it.
- * If packet was truncated, return 0.
+ * If packet was truncated, return NULL.
*/
static const u_int32_t *
parsefn(register const u_int32_t *dp)
@@ -173,12 +356,12 @@ parsefn(register const u_int32_t *dp)
/*
* 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)
+parsefhn(register const u_int32_t *dp, int v3)
{
- dp = parsefh(dp);
+ dp = parsefh(dp, v3);
if (dp == NULL)
return (NULL);
putchar(' ');
@@ -192,18 +375,21 @@ nfsreq_print(register const u_char *bp, u_int length,
register const struct rpc_msg *rp;
register const struct ip *ip;
register const u_int32_t *dp;
+ nfstype type;
+ int proc, v3;
+ struct nfsv3_sattr sa3;
nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
ip = (const struct ip *)bp2;
if (!nflag)
- (void)printf("%s.%u > %s.nfs: %d",
+ (void)printf("%s.%x > %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",
+ (void)printf("%s.%x > %s.%x: %d",
ipaddr_string(&ip->ip_src),
(u_int32_t)ntohl(rp->rm_xid),
ipaddr_string(&ip->ip_dst),
@@ -212,106 +398,162 @@ nfsreq_print(register const u_char *bp, u_int length,
xid_map_enter(rp, ip); /* record proc number for later on */
- switch (ntohl(rp->rm_call.cb_proc)) {
-#ifdef NFSPROC_NOOP
+ v3 = (ntohl(rp->rm_call.cb_vers) == NFS_VER3);
+ proc = ntohl(rp->rm_call.cb_proc);
+
+ if (!v3 && proc < NFS_NPROCS)
+ proc = nfsv3_procid[proc];
+
+ switch (proc) {
case NFSPROC_NOOP:
printf(" nop");
return;
-#else
-#define NFSPROC_NOOP -1
-#endif
case NFSPROC_NULL:
printf(" null");
return;
case NFSPROC_GETATTR:
printf(" getattr");
- if ((dp = parsereq(rp, length)) != NULL && parsefh(dp) != 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) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
-#if NFSPROC_ROOT != NFSPROC_NOOP
- case NFSPROC_ROOT:
- printf(" root");
- break;
-#endif
case NFSPROC_LOOKUP:
printf(" lookup");
- if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
+ return;
+ break;
+
+ case NFSPROC_ACCESS:
+ printf(" access");
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
+ TCHECK(*dp);
+ printf(" %04lx", ntohl(dp[0]));
return;
+ }
break;
case NFSPROC_READLINK:
printf(" readlink");
- if ((dp = parsereq(rp, length)) != NULL && parsefh(dp) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_READ:
printf(" read");
if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp)) != NULL) {
- TCHECK2(dp[0], 3 * sizeof(*dp));
- printf(" %u bytes @ %u",
- (u_int32_t)ntohl(dp[1]),
- (u_int32_t)ntohl(dp[0]));
+ (dp = parsefh(dp, v3)) != NULL) {
+ if (v3) {
+ TCHECK2(*dp, 3 * sizeof(*dp));
+ printf(" %lu bytes @ ", ntohl(dp[2]));
+ print_int64(dp, UNSIGNED);
+ } else {
+ TCHECK2(*dp, 2 * sizeof(*dp));
+ printf(" %lu bytes @ %lu",
+ ntohl(dp[1]), ntohl(dp[0]));
+ }
return;
}
break;
-#if NFSPROC_WRITECACHE != NFSPROC_NOOP
- case NFSPROC_WRITECACHE:
- printf(" writecache");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp)) != NULL) {
- TCHECK2(dp[0], 4 * sizeof(*dp));
- 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]));
- return;
- }
- break;
-#endif
case NFSPROC_WRITE:
printf(" write");
if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp)) != NULL) {
- TCHECK2(dp[0], 4 * sizeof(*dp));
- 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]));
+ (dp = parsefh(dp, v3)) != NULL) {
+ if (v3) {
+ TCHECK2(*dp, 3 * sizeof(*dp));
+ printf(" %lu bytes @ ", ntohl(dp[4]));
+ print_int64(dp, UNSIGNED);
+ if (vflag) {
+ dp += 3;
+ TCHECK2(*dp, sizeof(*dp));
+ printf(" <%s>",
+ nfsv3_writemodes[ntohl(*dp)]);
+ }
+ } else {
+ TCHECK2(*dp, 4 * sizeof(*dp));
+ printf(" %lu (%lu) bytes @ %lu (%lu)",
+ ntohl(dp[3]), ntohl(dp[2]),
+ ntohl(dp[1]), ntohl(dp[0]));
+ }
return;
}
break;
case NFSPROC_CREATE:
printf(" create");
- if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp) != NULL)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
+ case NFSPROC_MKDIR:
+ printf(" mkdir");
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
+ return;
+ break;
+
+ case NFSPROC_SYMLINK:
+ printf(" symlink");
+ 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) == NULL)
+ break;
+ if (v3 && vflag)
+ print_sattr3(&sa3, vflag);
+ return;
+ }
+ break;
+
+ case NFSPROC_MKNOD:
+ printf(" mknod");
+ 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)) {
+ if (dp + 2 > (u_int32_t *)snapend)
+ break;
+ printf(" %lu/%lu", ntohl(dp[0]), ntohl(dp[1]));
+ dp += 2;
+ }
+ if (vflag)
+ print_sattr3(&sa3, vflag);
+ return;
+ }
+ break;
+
case NFSPROC_REMOVE:
printf(" remove");
- if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp) != 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)
return;
break;
case NFSPROC_RENAME:
printf(" rename");
if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefhn(dp)) != NULL) {
+ (dp = parsefhn(dp, v3)) != NULL) {
fputs(" ->", stdout);
- if (parsefhn(dp) != NULL)
+ if (parsefhn(dp, v3) != NULL)
return;
}
break;
@@ -319,59 +561,85 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_LINK:
printf(" link");
if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp)) != NULL) {
+ (dp = parsefh(dp, v3)) != NULL) {
fputs(" ->", stdout);
- if (parsefhn(dp) != NULL)
+ if (parsefhn(dp, v3) != NULL)
return;
}
break;
- case NFSPROC_SYMLINK:
- printf(" symlink");
+ case NFSPROC_READDIR:
+ printf(" readdir");
if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefhn(dp)) != NULL) {
- fputs(" -> ", stdout);
- if (parsefn(dp) != NULL)
- return;
+ (dp = parsefh(dp, v3)) != NULL) {
+ if (v3) {
+ TCHECK2(*dp, 20);
+ /*
+ * We shouldn't really try to interpret the
+ * offset cookie here.
+ */
+ printf(" %lu bytes @ ", ntohl(dp[4]));
+ print_int64(dp, SIGNED);
+ if (vflag)
+ printf(" verf %08x%08x", dp[2],
+ dp[3]);
+ } else {
+ TCHECK2(*dp, 2 * sizeof(*dp));
+ /*
+ * Print the offset as signed, since -1 is
+ * common, but offsets > 2^31 aren't.
+ */
+ printf(" %lu bytes @ %ld", ntohl(dp[1]),
+ ntohl(dp[0]));
+ }
+ return;
}
break;
- case NFSPROC_MKDIR:
- printf(" mkdir");
- if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp) != NULL)
+ case NFSPROC_READDIRPLUS:
+ printf(" readdirplus");
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
+ TCHECK2(*dp, 20);
+ /*
+ * We don't try to interpret the offset
+ * cookie here.
+ */
+ printf(" %lu bytes @ ", ntohl(dp[4]));
+ print_int64(dp, SIGNED);
+ if (vflag)
+ printf(" max %lu verf %08x%08x",
+ ntohl(dp[5]), dp[2], dp[3]);
return;
+ }
break;
- case NFSPROC_RMDIR:
- printf(" rmdir");
- if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp) != NULL)
+ case NFSPROC_FSSTAT:
+ printf(" fsstat");
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
- case NFSPROC_READDIR:
- printf(" readdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp)) != NULL) {
- TCHECK2(dp[0], 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]));
- return;
- }
+ case NFSPROC_FSINFO:
+ printf(" fsinfo");
break;
- case NFSPROC_STATFS:
- printf(" statfs");
- if ((dp = parsereq(rp, length)) != NULL && parsefh(dp) != NULL)
+ case NFSPROC_PATHCONF:
+ printf(" pathconf");
+ break;
+
+ case NFSPROC_COMMIT:
+ printf(" commit");
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
+ 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:
@@ -389,20 +657,20 @@ trunc:
* additional hacking on the parser code.
*/
static void
-nfs_printfh(register const u_int32_t *dp)
+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, &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 */
- static char temp[NFS_FHSIZE+1];
+ static char temp[NFSX_V3FHMAX+1];
/* Make sure string is null-terminated */
- strncpy(temp, sfsname, NFS_FHSIZE);
+ strncpy(temp, sfsname, NFSX_V3FHMAX);
/* Remove trailing spaces */
sfsname = strchr(temp, ' ');
if (sfsname)
@@ -426,6 +694,7 @@ struct xid_map_entry {
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
u_int32_t proc; /* call proc number (host order) */
+ u_int32_t vers; /* program version (host order) */
};
/*
@@ -455,11 +724,16 @@ xid_map_enter(const struct rpc_msg *rp, const struct ip *ip)
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);
}
-/* Returns true and sets proc success or false on failure */
-static u_int32_t
-xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc)
+/*
+ * Returns 0 and puts NFSPROC_xxx in proc return and
+ * version in vers return, or returns -1 on failure
+ */
+static int
+xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc,
+ u_int32_t *vers)
{
int i;
struct xid_map_entry *xmep;
@@ -476,14 +750,15 @@ xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc)
/* match */
xid_map_hint = i;
*proc = xmep->proc;
- return (1);
+ *vers = xmep->vers;
+ return 0;
}
if (++i >= XIDMAPSIZE)
i = 0;
} while (i != xid_map_hint);
/* search failed */
- return (0);
+ return (-1);
}
/*
@@ -492,13 +767,13 @@ xid_map_find(const struct rpc_msg *rp, const struct ip *ip, 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;
/*
@@ -574,17 +849,20 @@ trunc:
return (NULL);
}
+
static const u_int32_t *
-parsestatus(const u_int32_t *dp)
+parsestatus(const u_int32_t *dp, int *er)
{
register int errnum;
TCHECK(dp[0]);
errnum = ntohl(dp[0]);
+ if (er)
+ *er = errnum;
if (errnum != 0) {
if (!qflag)
printf(" ERROR: %s", pcap_strerror(errnum));
- nfserr = 1; /* suppress trunc string */
+ nfserr = 1;
return (NULL);
}
return (dp + 1);
@@ -592,89 +870,109 @@ trunc:
return (NULL);
}
-static struct tok type2str[] = {
- { NFNON, "NON" },
- { NFREG, "REG" },
- { NFDIR, "DIR" },
- { NFBLK, "BLK" },
- { NFCHR, "CHR" },
- { NFLNK, "LNK" },
- { 0, NULL }
-};
-
static const u_int32_t *
-parsefattr(const u_int32_t *dp, int verbose)
+parsefattr(const u_int32_t *dp, int verbose, int v3)
{
- const struct nfsv2_fattr *fap;
+ const struct nfs_fattr *fap;
- fap = (const struct nfsv2_fattr *)dp;
+ fap = (const struct nfs_fattr *)dp;
+ TCHECK(fap->fa_gid);
if (verbose) {
- TCHECK(fap->fa_nfssize);
- printf(" %s %o ids %u/%u sz %u ",
- 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),
- (u_int32_t)ntohl(fap->fa_nfssize));
+ 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 ");
+ print_int64((u_int32_t *)&fap->fa3_size, UNSIGNED);
+ putchar(' ');
+ } else {
+ TCHECK(fap->fa2_size);
+ printf(" sz %ld ", ntohl(fap->fa2_size));
+ }
}
/* print lots more stuff */
if (verbose > 1) {
- TCHECK(fap->fa_nfsfileid);
- printf("nlink %u rdev %x fsid %x nodeid %x a/m/ctime ",
- (u_int32_t)ntohl(fap->fa_nlink),
- (u_int32_t)ntohl(fap->fa_nfsrdev),
- (u_int32_t)ntohl(fap->fa_nfsfsid),
- (u_int32_t)ntohl(fap->fa_nfsfileid));
- TCHECK(fap->fa_nfsatime);
- printf("%u.%06u ",
- (u_int32_t)ntohl(fap->fa_nfsatime.nfs_sec),
- (u_int32_t)ntohl(fap->fa_nfsatime.nfs_usec));
- TCHECK(fap->fa_nfsmtime);
- printf("%u.%06u ",
- (u_int32_t)ntohl(fap->fa_nfsmtime.nfs_sec),
- (u_int32_t)ntohl(fap->fa_nfsmtime.nfs_usec));
- TCHECK(fap->fa_nfsctime);
- printf("%u.%06u ",
- (u_int32_t)ntohl(fap->fa_nfsctime.nfs_sec),
- (u_int32_t)ntohl(fap->fa_nfsctime.nfs_usec));
+ if (v3) {
+ TCHECK(fap->fa3_ctime);
+ 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 %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 %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 *)&fap[1]);
+ return ((const u_int32_t *)((unsigned char *)dp +
+ (v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
trunc:
return (NULL);
}
static int
-parseattrstat(const u_int32_t *dp, int verbose)
+parseattrstat(const u_int32_t *dp, int verbose, int v3)
{
+ int er;
- dp = parsestatus(dp);
- if (dp == NULL)
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
return (0);
- return (parsefattr(dp, verbose) != NULL);
+ return (parsefattr(dp, verbose, v3) != NULL);
}
static int
parsediropres(const u_int32_t *dp)
{
+ int er;
- dp = parsestatus(dp);
- if (dp == NULL)
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
return (0);
- dp = parsefh(dp);
+ dp = parsefh(dp, 0);
if (dp == NULL)
return (0);
- return (parsefattr(dp, vflag) != NULL);
+ return (parsefattr(dp, vflag, 0) != NULL);
}
static int
-parselinkres(const u_int32_t *dp)
+parselinkres(const u_int32_t *dp, int v3)
{
- dp = parsestatus(dp);
- if (dp == NULL)
+ int er;
+
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
+ return(0);
+
+ if (v3 && ((dp = parse_post_op_attr(dp, vflag)) != NULL))
return (0);
putchar(' ');
@@ -682,23 +980,50 @@ parselinkres(const u_int32_t *dp)
}
static int
-parsestatfs(const u_int32_t *dp)
+parsestatfs(const u_int32_t *dp, int v3)
{
- const struct nfsv2_statfs *sfsp;
+ const struct nfs_statfs *sfsp;
+ int er;
- dp = parsestatus(dp);
- if (dp == NULL)
- return (0);
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || (!v3 && er))
+ return(0);
+
+ if (qflag)
+ return(1);
+
+ if (v3) {
+ if (vflag)
+ printf(" POST:");
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ return (0);
+ }
- if (!qflag) {
- sfsp = (const struct nfsv2_statfs *)dp;
- TCHECK(sfsp->sf_bavail);
- printf(" tsize %u bsize %u blocks %u bfree %u bavail %u",
- (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));
+ TCHECK2(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+
+ sfsp = (const struct nfs_statfs *)dp;
+
+ if (v3) {
+ printf(" tbytes ");
+ print_int64((u_int32_t *)&sfsp->sf_tbytes, UNSIGNED);
+ printf(" fbytes ");
+ print_int64((u_int32_t *)&sfsp->sf_fbytes, UNSIGNED);
+ printf(" abytes ");
+ print_int64((u_int32_t *)&sfsp->sf_abytes, UNSIGNED);
+ if (vflag) {
+ printf(" tfiles ");
+ print_int64((u_int32_t *)&sfsp->sf_tfiles, UNSIGNED);
+ printf(" ffiles ");
+ print_int64((u_int32_t *)&sfsp->sf_ffiles, UNSIGNED);
+ printf(" afiles ");
+ print_int64((u_int32_t *)&sfsp->sf_afiles, UNSIGNED);
+ printf(" invar %lu", ntohl(sfsp->sf_invarsec));
+ }
+ } else {
+ 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);
@@ -709,38 +1034,231 @@ trunc:
static int
parserddires(const u_int32_t *dp)
{
- dp = parsestatus(dp);
- if (dp == NULL)
+ int er;
+
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
return (0);
- if (!qflag) {
+ if (qflag)
+ return (1);
+
+ TCHECK(dp[2]);
+ printf(" offset %lx size %ld ", ntohl(dp[0]), ntohl(dp[1]));
+ if (dp[2] != 0)
+ printf("eof");
+
+ return (1);
+trunc:
+ return (0);
+}
+
+static const u_int32_t *
+parse_wcc_attr(const u_int32_t *dp)
+{
+ printf(" sz ");
+ print_int64(dp, UNSIGNED);
+ printf(" mtime %lu.%06lu ctime %lu.%06lu", ntohl(dp[2]), ntohl(dp[3]),
+ ntohl(dp[4]), ntohl(dp[5]));
+ return (dp + 6);
+}
+
+/*
+ * Pre operation attributes. Print only if vflag > 1.
+ */
+static const u_int32_t *
+parse_pre_op_attr(const u_int32_t *dp, int verbose)
+{
+ TCHECK(dp[0]);
+ if (!ntohl(dp[0]))
+ return (dp + 1);
+ dp++;
+ TCHECK2(dp, 24);
+ if (verbose > 1) {
+ return parse_wcc_attr(dp);
+ } else {
+ /* If not verbose enough, just skip over wcc_attr */
+ return (dp + 6);
+ }
+trunc:
+ return (NULL);
+}
+
+/*
+ * Post operation attributes are printed if vflag >= 1
+ */
+static const u_int32_t *
+parse_post_op_attr(const u_int32_t *dp, int verbose)
+{
+ TCHECK(dp[0]);
+ if (!ntohl(dp[0]))
+ return (dp + 1);
+ dp++;
+ if (verbose) {
+ return parsefattr(dp, verbose, 1);
+ } else
+ return (dp + (NFSX_V3FATTR / sizeof (u_int32_t)));
+trunc:
+ return (NULL);
+}
+
+static const u_int32_t *
+parse_wcc_data(const u_int32_t *dp, int verbose)
+{
+ if (verbose > 1)
+ printf(" PRE:");
+ if ((dp = parse_pre_op_attr(dp, verbose)) == NULL)
+ return (NULL);
+
+ if (verbose)
+ printf(" POST:");
+ return parse_post_op_attr(dp, verbose);
+}
+
+static const u_int32_t *
+parsecreateopres(const u_int32_t *dp, int verbose)
+{
+ int er;
+
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
+ if (er)
+ dp = parse_wcc_data(dp, verbose);
+ else {
TCHECK(dp[0]);
- printf(" offset %x", (u_int32_t)ntohl(dp[0]));
+ if (!ntohl(dp[0]))
+ return (dp + 1);
+ dp++;
+ if ((dp = parsefh(dp, 1)) == NULL)
+ return (NULL);
+ if (verbose) {
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
+ if (vflag > 1) {
+ printf("dir attr:");
+ dp = parse_wcc_data(dp, verbose);
+ }
+ }
+ }
+ return (dp);
+trunc:
+ return (NULL);
+}
+
+static int
+parsewccres(const u_int32_t *dp, int verbose)
+{
+ int er;
+
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (0);
+ return parse_wcc_data(dp, verbose) != NULL;
+}
+
+static const u_int32_t *
+parsev3rddirres(const u_int32_t *dp, int verbose)
+{
+ int er;
+
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
+ if (vflag)
+ printf(" POST:");
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
+ if (er)
+ return dp;
+ if (vflag) {
TCHECK(dp[1]);
- printf(" size %u", (u_int32_t)ntohl(dp[1]));
- TCHECK(dp[2]);
- if (dp[2] != 0)
- printf(" eof");
+ printf(" verf %08x%08x", dp[0], dp[1]);
+ dp += 2;
}
+ return dp;
+trunc:
+ return (NULL);
+}
+static int
+parsefsinfo(const u_int32_t *dp)
+{
+ struct nfsv3_fsinfo *sfp;
+ int er;
+
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (0);
+ if (vflag)
+ printf(" POST:");
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ return (0);
+ if (er)
+ return (1);
+
+ sfp = (struct nfsv3_fsinfo *)dp;
+ TCHECK(*sfp);
+ 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 %lu wtmult %lu maxfsz ",
+ ntohl(sfp->fs_rtmult), ntohl(sfp->fs_wtmult));
+ print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
+ printf(" delta %lu.%06lu ", ntohl(sfp->fs_timedelta.nfsv3_sec),
+ ntohl(sfp->fs_timedelta.nfsv3_nsec));
+ }
return (1);
trunc:
return (0);
}
+static int
+parsepathconf(const u_int32_t *dp)
+{
+ int er;
+ struct nfsv3_pathconf *spp;
+
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (0);
+ if (vflag)
+ printf(" POST:");
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ return (0);
+ if (er)
+ return (1);
+
+ spp = (struct nfsv3_pathconf *)dp;
+ TCHECK(*spp);
+
+ 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 (1);
+trunc:
+ return (0);
+}
+
static void
-interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int length)
+interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
{
register const u_int32_t *dp;
+ register int v3;
+
+ int er;
+
+ v3 = (vers == NFS_VER3);
+
+ if (!v3 && proc < NFS_NPROCS)
+ proc = nfsv3_procid[proc];
switch (proc) {
-#ifdef NFSPROC_NOOP
case NFSPROC_NOOP:
printf(" nop");
return;
-#else
-#define NFSPROC_NOOP -1
-#endif
+
case NFSPROC_NULL:
printf(" null");
return;
@@ -748,115 +1266,286 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int length)
case NFSPROC_GETATTR:
printf(" getattr");
dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, !qflag) != 0)
+ if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0)
return;
break;
case NFSPROC_SETATTR:
printf(" setattr");
- dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, !qflag) != 0)
+ if ((dp = parserep(rp, length)) == NULL)
return;
+ if (v3) {
+ if (parsewccres(dp, vflag) != 0)
+ return;
+ } else {
+ if (parseattrstat(dp, !qflag, 0) != 0)
+ return;
+ }
break;
-#if NFSPROC_ROOT != NFSPROC_NOOP
- case NFSPROC_ROOT:
- printf(" root");
- break;
-#endif
case NFSPROC_LOOKUP:
printf(" lookup");
- dp = parserep(rp, length);
- if (dp != NULL && parsediropres(dp) != 0)
- return;
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if (er) {
+ if (vflag > 1) {
+ printf(" post dattr:");
+ dp = parse_post_op_attr(dp, vflag);
+ }
+ } else {
+ if ((dp = parsefh(dp, v3)) == NULL)
+ break;
+ if (((dp = parse_post_op_attr(dp, vflag)) != NULL) &&
+ (vflag > 1)) {
+ printf(" post dattr:");
+ dp = parse_post_op_attr(dp, vflag);
+ }
+ }
+ if (dp != NULL)
+ return;
+ } else {
+ if (parsediropres(dp) != 0)
+ return;
+ }
break;
+ case NFSPROC_ACCESS:
+ printf(" access");
+ dp = parserep(rp, length);
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if (vflag)
+ printf(" attr:");
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ break;
+ if (!er)
+ printf(" c %04lx", ntohl(dp[0]));
+ return;
+
case NFSPROC_READLINK:
printf(" readlink");
dp = parserep(rp, length);
- if (dp != NULL && parselinkres(dp) != 0)
+ if (dp != NULL && parselinkres(dp, v3) != 0)
return;
break;
case NFSPROC_READ:
printf(" read");
- dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, vflag) != 0)
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ break;
+ if (er)
+ return;
+ if (vflag) {
+ TCHECK2(*dp, 8);
+ printf("%lu bytes", ntohl(dp[0]));
+ if (ntohl(dp[1]))
+ printf(" EOF");
+ }
return;
+ } else {
+ if (parseattrstat(dp, vflag, 0) != 0)
+ return;
+ }
break;
-#if NFSPROC_WRITECACHE != NFSPROC_NOOP
- case NFSPROC_WRITECACHE:
- printf(" writecache");
- break;
-#endif
case NFSPROC_WRITE:
printf(" write");
- dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, vflag) != 0)
- return;
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
+ break;
+ if (er)
+ return;
+ if (vflag) {
+ TCHECK2(*dp, 4);
+ printf("%lu bytes", ntohl(dp[0]));
+ if (vflag > 1) {
+ TCHECK2(*dp, 4);
+ printf(" <%s>",
+ nfsv3_writemodes[ntohl(dp[1])]);
+ }
+ return;
+ }
+ } else {
+ if (parseattrstat(dp, vflag, v3) != 0)
+ return;
+ }
break;
case NFSPROC_CREATE:
printf(" create");
- dp = parserep(rp, length);
- if (dp != NULL && parsediropres(dp) != 0)
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsecreateopres(dp, vflag) != NULL)
+ return;
+ } else {
+ if (parsediropres(dp) != 0)
+ return;
+ }
+ break;
+
+ case NFSPROC_MKDIR:
+ printf(" mkdir");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsecreateopres(dp, vflag) != NULL)
+ return;
+ } else {
+ if (parsediropres(dp) != 0)
+ return;
+ }
+ break;
+
+ case NFSPROC_SYMLINK:
+ printf(" symlink");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsecreateopres(dp, vflag) != NULL)
+ return;
+ } else {
+ if (parsestatus(dp, &er) != NULL)
+ return;
+ }
+ break;
+
+ case NFSPROC_MKNOD:
+ printf(" mknod");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (parsecreateopres(dp, vflag) != NULL)
return;
break;
case NFSPROC_REMOVE:
printf(" remove");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatus(dp) != 0)
- return;
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsewccres(dp, vflag) != 0)
+ return;
+ } else {
+ if (parsestatus(dp, &er) != NULL)
+ return;
+ }
+ break;
+
+ case NFSPROC_RMDIR:
+ printf(" rmdir");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsewccres(dp, vflag) != 0)
+ return;
+ } else {
+ if (parsestatus(dp, &er) != NULL)
+ return;
+ }
break;
case NFSPROC_RENAME:
printf(" rename");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatus(dp) != 0)
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if (vflag) {
+ printf(" from:");
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
+ break;
+ printf(" to:");
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
+ break;
+ }
return;
+ } else {
+ if (parsestatus(dp, &er) != NULL)
+ return;
+ }
break;
case NFSPROC_LINK:
printf(" link");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatus(dp) != 0)
- return;
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ break;
+ if (vflag) {
+ printf(" file POST:");
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
+ break;
+ printf(" dir:");
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
+ break;
+ return;
+ }
+ } else {
+ if (parsestatus(dp, &er) != NULL)
+ return;
+ }
break;
- case NFSPROC_SYMLINK:
- printf(" symlink");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatus(dp) != 0)
+ case NFSPROC_READDIR:
+ printf(" readdir");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (v3) {
+ if (parsev3rddirres(dp, vflag) != NULL)
+ return;
+ } else {
+ if (parserddires(dp) != 0)
+ return;
+ }
+ break;
+
+ case NFSPROC_READDIRPLUS:
+ printf(" readdirplus");
+ if ((dp = parserep(rp, length)) == NULL)
+ break;
+ if (parsev3rddirres(dp, vflag) != NULL)
return;
break;
- case NFSPROC_MKDIR:
- printf(" mkdir");
+ case NFSPROC_FSSTAT:
+ printf(" fsstat");
dp = parserep(rp, length);
- if (dp != NULL && parsediropres(dp) != 0)
+ if (dp != NULL && parsestatfs(dp, v3) != NULL)
return;
break;
- case NFSPROC_RMDIR:
- printf(" rmdir");
+ case NFSPROC_FSINFO:
+ printf(" fsinfo");
dp = parserep(rp, length);
- if (dp != NULL && parsestatus(dp) != 0)
+ if (dp != NULL && parsefsinfo(dp) != NULL)
return;
break;
- case NFSPROC_READDIR:
- printf(" readdir");
+ case NFSPROC_PATHCONF:
+ printf(" pathconf");
dp = parserep(rp, length);
- if (dp != NULL && parserddires(dp) != 0)
+ if (dp != NULL && parsepathconf(dp) != 0)
return;
break;
- case NFSPROC_STATFS:
- printf(" statfs");
+ case NFSPROC_COMMIT:
+ printf(" commit");
dp = parserep(rp, length);
- if (dp != NULL && parsestatfs(dp) != 0)
+ if (dp != NULL && parsewccres(dp, vflag) != 0)
return;
break;
@@ -864,6 +1553,8 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int length)
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 dc14ba1..926691c 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-ntp.c,v 1.26 97/06/13 12:56:37 leres Exp $ (LBL)";
+ "@(#) $Header: print-ntp.c,v 1.25 96/11/05 13:30:37 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -39,7 +39,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <ctype.h>
#include <stdio.h>
@@ -47,9 +47,7 @@ struct rtentry;
#include "interface.h"
#include "addrtoname.h"
-#ifdef MODEMASK
#undef MODEMASK /* Solaris sucks */
-#endif
#include "ntp.h"
static void p_sfix(const struct s_fixedpt *);
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index a5bbd27..cf845d4 100644
--- a/contrib/tcpdump/print-null.c
+++ b/contrib/tcpdump/print-null.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-null.c,v 1.24 97/05/28 12:52:47 leres Exp $ (LBL)";
+ "@(#) $Header: print-null.c,v 1.22 96/12/10 23:18:58 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -39,7 +39,7 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
@@ -50,19 +50,15 @@ struct rtentry;
#include <stdio.h>
#include <string.h>
-#include "interface.h"
#include "addrtoname.h"
+#include "interface.h"
+
+#define NULL_HDRLEN 4
#ifndef AF_NS
#define AF_NS 6 /* XEROX NS protocols */
#endif
-/*
- * 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(const u_char *p, const struct ip *ip, u_int length)
{
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index 6532382..bd5e805 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,9 +21,10 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-ppp.c,v 1.26 97/06/12 14:21:29 leres Exp $ (LBL)";
+ "@(#) $Header: print-ppp.c,v 1.24 96/12/10 23:23:12 leres Exp $ (LBL)";
#endif
+#ifdef PPP
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>
@@ -43,78 +44,453 @@ struct rtentry;
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
+#include <signal.h>
#include <stdio.h>
+#include <net/ethernet.h>
+#include "ethertype.h"
+
+#include <net/ppp_defs.h>
#include "interface.h"
#include "addrtoname.h"
-#include "ppp.h"
-/* XXX This goes somewhere else. */
-#define PPP_HDRLEN 4
+struct protonames {
+ u_short protocol;
+ char *name;
+};
+
+static struct protonames protonames[] = {
+ /*
+ * Protocol field values.
+ */
+ 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 */
+
+#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
+#define LCPOPT_ACCM 2
+#define LCPOPT_AP 3
+#define LCPOPT_QP 4
+#define LCPOPT_MN 5
+#define LCPOPT_PFC 7
+#define LCPOPT_ACFC 8
+
+#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",
+};
+
+/* CHAP */
+
+#define CHAP_CHAL 1
+#define CHAP_RESP 2
+#define CHAP_SUCC 3
+#define CHAP_FAIL 4
+
+#define CHAP_CODEMIN 1
+#define CHAP_CODEMAX 4
+
+static char *chapcode[] = {
+ "Challenge",
+ "Response",
+ "Success",
+ "Failure",
+};
+
+/* PAP */
+
+#define PAP_AREQ 1
+#define PAP_AACK 2
+#define PAP_ANAK 3
+
+#define PAP_CODEMIN 1
+#define PAP_CODEMAX 3
+
+static char *papcode[] = {
+ "Authenticate-Request",
+ "Authenticate-Ack",
+ "Authenticate-Nak",
+};
+
+/* IPCP */
+
+#define IPCP_2ADDR 1
+#define IPCP_CP 2
+#define IPCP_ADDR 3
+
+static int handle_lcp(const u_char *p, int length);
+static int print_lcp_config_options(u_char *p);
+static int handle_chap(const u_char *p, int length);
+static int handle_ipcp(const u_char *p, int length);
+static int handle_pap(const u_char *p, int length);
-/* Standard PPP printer */
void
-ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
- register const u_char *p)
+ppp_hdlc_print(const u_char *p, int length)
{
- register u_int length = h->len;
- register u_int caplen = h->caplen;
- const struct ip *ip;
+ int proto = PPP_PROTOCOL(p);
+ int i, j, x;
+ u_char *ptr;
- ts_print(&h->ts);
+ 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);
- if (caplen < PPP_HDRLEN) {
- printf("[|ppp]");
- goto out;
+ 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);
}
+}
- /*
- * 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;
+/* print LCP frame */
- if (eflag)
- printf("%c %4d %02x %04x: ", p[0] ? 'O' : 'I', length,
- p[1], ntohs(*(u_short *)&p[2]));
+static int
+handle_lcp(const u_char *p, int length)
+{
+ int x, j;
+ u_char *ptr;
- length -= PPP_HDRLEN;
- ip = (struct ip *)(p + PPP_HDRLEN);
- ip_print((const u_char *)ip, length);
+ x = *(p+4);
- if (xflag)
- default_print((const u_char *)ip, caplen - PPP_HDRLEN);
-out:
- putchar('\n');
+ if((x >= LCP_MIN) && (x <= LCP_MAX))
+ {
+ printf("%s", lcpcodes[x-1]);
+ }
+ else
+ {
+ printf("0x%02x", x);
+ return;
+ }
+
+ length -= 4;
+
+ switch(x)
+ {
+ case LCP_CONF_REQ:
+ case LCP_CONF_ACK:
+ case LCP_CONF_NAK:
+ case LCP_CONF_REJ:
+ x = length;
+ ptr = (u_char *)p+8;
+ do
+ {
+ if((j = print_lcp_config_options(ptr)) == 0)
+ break;
+ x -= j;
+ ptr += j;
+ }
+ while(x > 0);
+ break;
+
+ case LCP_ECHO_REQ:
+ case LCP_ECHO_RPL:
+ printf(", Magic-Number=%d", ((*(p+8) << 24) + (*(p+9) << 16) + (*(p+10) << 8) + (*(p+11))));
+ break;
+ case LCP_TERM_REQ:
+ case LCP_TERM_ACK:
+ case LCP_CODE_REJ:
+ case LCP_PROT_REJ:
+ case LCP_DISC_REQ:
+ default:
+ break;
+ }
}
-/* proto type to string mapping */
-static struct tok ptype2str[] = {
- { PPP_VJC, "VJC" },
- { PPP_VJNC, "VJNC" },
- { PPP_OSI, "OSI" },
- { PPP_LCP, "LCP" },
- { PPP_IPCP, "IPCP" },
- { 0, NULL }
-};
+/* LCP config options */
+
+static int
+print_lcp_config_options(u_char *p)
+{
+ int len = *(p+1);
+ int opt = *p;
+
+ if((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
+ printf(", %s", lcpconfopts[opt]);
+
+ switch(opt)
+ {
+ case LCPOPT_MRU:
+ if(len == 4)
+ printf("=%d", (*(p+2) << 8) + *(p+3));
+ break;
+ case LCPOPT_AP:
+ if(len >= 4)
+ {
+ if(*(p+2) == 0xc0 && *(p+3) == 0x23)
+ {
+ printf(" PAP");
+ }
+ else if(*(p+2) == 0xc2 && *(p+3) == 0x23)
+ {
+ printf(" CHAP/");
+ switch(*(p+4))
+ {
+ default:
+ printf("unknown-algorithm-%d", *(p+4));
+ break;
+ case 5:
+ printf("MD5");
+ break;
+ case 0x80:
+ printf("Microsoft");
+ break;
+ }
+ }
+ else if(*(p+2) == 0xc2 && *(p+3) == 0x27)
+ {
+ printf(" EAP");
+ }
+ else if(*(p+2) == 0xc0 && *(p+3) == 0x27)
+ {
+ printf(" SPAP");
+ }
+ else if(*(p+2) == 0xc1 && *(p+3) == 0x23)
+ {
+ printf(" Old-SPAP");
+ }
+ else
+ {
+ printf("unknown");
+ }
+ }
+ break;
+ case LCPOPT_QP:
+ if(len >= 4)
+ {
+ if(*(p+2) == 0xc0 && *(p+3) == 0x25)
+ printf(" LQR");
+ else
+ printf(" unknown");
+ }
+ break;
+ case LCPOPT_MN:
+ if(len == 6)
+ {
+ printf("=%d", ((*(p+2) << 24) + (*(p+3) << 16) + (*(p+4) << 8) + (*(p+5))));
+ }
+ break;
+ case LCPOPT_PFC:
+ printf(" PFC");
+ break;
+ case LCPOPT_ACFC:
+ printf(" ACFC");
+ break;
+ }
+ return(len);
+}
+
+/* CHAP */
+
+static int
+handle_chap(const u_char *p, int length)
+{
+ int x, j;
+ u_char *ptr;
+
+ x = *(p+4);
-#define PPP_BSDI_HDRLEN 24
+ if((x >= CHAP_CODEMIN) && (x <= CHAP_CODEMAX))
+ {
+ printf("%s", chapcode[x-1]);
+ }
+ else
+ {
+ printf("0x%02x", x);
+ return;
+ }
+
+ length -= 4;
+
+ switch(x)
+ {
+ case CHAP_CHAL:
+ case CHAP_RESP:
+ printf(", Value=");
+ x = *(p+8); /* value size */
+ ptr = (u_char *)p+9;
+ while(--x >= 0)
+ printf("%02x", *ptr++);
+ x = length - *(p+8) - 1;
+ printf(", Name=");
+ while(--x >= 0)
+ printf("%c", *ptr++);
+ break;
+ }
+}
+
+/* PAP */
+
+static int
+handle_pap(const u_char *p, int length)
+{
+ int x, j;
+ u_char *ptr;
+
+ x = *(p+4);
+
+ if((x >= PAP_CODEMIN) && (x <= PAP_CODEMAX))
+ {
+ printf("%s", papcode[x-1]);
+ }
+ else
+ {
+ printf("0x%02x", x);
+ return;
+ }
-/* BSD/OS specific PPP printer */
+ length -= 4;
+
+ switch(x)
+ {
+ case PAP_AREQ:
+ printf(", Peer-Id=");
+ x = *(p+8); /* peerid size */
+ ptr = (u_char *)p+9;
+ while(--x >= 0)
+ printf("%c", *ptr++);
+ x = *ptr++;
+ printf(", Passwd=");
+ while(--x >= 0)
+ printf("%c", *ptr++);
+ break;
+ case PAP_AACK:
+ case PAP_ANAK:
+ break;
+ }
+}
+
+/* IPCP */
+
+static int
+handle_ipcp(const u_char *p, int length)
+{
+ int x, j;
+
+ x = *(p+8);
+
+ length -= 4;
+
+ switch(x)
+ {
+ case IPCP_2ADDR:
+ printf("IP-Addresses");
+ printf(", Src=%d.%d.%d.%d", *(p+10), *(p+11), *(p+12), *(p+13));
+ printf(", Dst=%d.%d.%d.%d", *(p+14), *(p+15), *(p+16), *(p+17));
+ break;
+
+ case IPCP_CP:
+ printf("IP-Compression-Protocol");
+ break;
+
+ case IPCP_ADDR:
+ printf("IP-Address=%d.%d.%d.%d", *(p+10), *(p+11), *(p+12), *(p+13));
+ break;
+ }
+}
+
void
-ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
+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;
- register int hdrlength;
- u_short ptype;
ts_print(&h->ts);
- if (caplen < PPP_BSDI_HDRLEN) {
+ if (caplen < PPP_HDRLEN) {
printf("[|ppp]");
goto out;
}
@@ -126,43 +502,47 @@ ppp_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h,
*/
packetp = p;
snapend = p + caplen;
- hdrlength = 0;
- if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
- printf("%02x %02x ", p[0], p[1]);
- p += 2;
- hdrlength = 2;
- }
+ if (eflag)
+ ppp_hdlc_print(p, length);
- if (eflag)
- printf("%d ", length);
- /* Retrieve the protocol type */
- if (*p & 01) {
- /* Compressed protocol field */
- ptype = *p;
- if (eflag)
- printf("%02x ", ptype);
- p++;
- hdrlength += 1;
- } else {
- /* Un-compressed protocol field */
- ptype = ntohs(*(u_short *)p);
- if (eflag)
- printf("%04x ", ptype);
- p += 2;
- hdrlength += 2;
- }
-
- length -= hdrlength;
+ length -= PPP_HDRLEN;
- if (ptype == PPP_IP)
- ip_print(p, length);
- else
- printf("%s ", tok2str(ptype2str, "proto-#%d", ptype));
+ switch(PPP_PROTOCOL(p)) {
+ case PPP_IP:
+ case ETHERTYPE_IP:
+ ip_print((const u_char *)(p + PPP_HDRLEN), length);
+ break;
+ case PPP_IPX:
+ case ETHERTYPE_IPX:
+ ipx_print((const u_char *)(p + PPP_HDRLEN), length);
+ break;
+
+ default:
+ if(!eflag)
+ ppp_hdlc_print(p, length);
+ if(!xflag)
+ default_print((const u_char *)(p + PPP_HDRLEN),
+ caplen - PPP_HDRLEN);
+ }
if (xflag)
- default_print((const u_char *)p, caplen - hdrlength);
+ default_print((const u_char *)(p + PPP_HDRLEN),
+ caplen - PPP_HDRLEN);
out:
putchar('\n');
}
+#else
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <stdio.h>
+
+#include "interface.h"
+void
+ppp_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
+{
+ error("not configured for ppp");
+ /* NOTREACHED */
+}
+#endif
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index a97a495..0c6cd8d 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-sl.c,v 1.42 97/06/12 14:21:35 leres Exp $ (LBL)";
+ "@(#) $Header: print-sl.c,v 1.41 96/12/10 23:19:42 leres Exp $ (LBL)";
#endif
#ifdef HAVE_NET_SLIP_H
@@ -41,7 +41,7 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
@@ -54,6 +54,7 @@ struct rtentry;
#include <ctype.h>
#include <netdb.h>
#include <pcap.h>
+#include <signal.h>
#include <stdio.h>
#include "interface.h"
@@ -74,8 +75,6 @@ static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
#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)
{
@@ -112,45 +111,6 @@ sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
putchar('\n');
}
-
-void
-sl_bsdos_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
-{
- register u_int caplen = h->caplen;
- register u_int length = h->len;
- register const struct ip *ip;
-
- ts_print(&h->ts);
-
- if (caplen < SLIP_HDRLEN) {
- printf("[|slip]");
- 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;
-
- length -= SLIP_HDRLEN;
-
- ip = (struct ip *)(p + SLIP_HDRLEN);
-
-#ifdef notdef
- if (eflag)
- sliplink_print(p, ip, length);
-#endif
-
- ip_print((u_char *)ip, length);
-
- if (xflag)
- default_print((u_char *)ip, caplen - SLIP_HDRLEN);
- out:
- putchar('\n');
-}
-
static void
sliplink_print(register const u_char *p, register const struct ip *ip,
register u_int length)
@@ -287,7 +247,6 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
#include <stdio.h>
#include "interface.h"
-
void
sl_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
{
@@ -295,12 +254,4 @@ 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 8bd9ae8..01c485b 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-sunrpc.c,v 1.26 96/12/31 21:27:43 leres Exp $ (LBL)";
+ "@(#) $Header: print-sunrpc.c,v 1.25 96/09/26 23:36:49 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -35,7 +35,7 @@ struct rtentry;
#include <net/if.h>
#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -119,7 +119,7 @@ progstr(prog)
{
register struct rpcent *rp;
static char buf[32];
- static int lastprog = 0;
+ static lastprog = 0;
if (lastprog != 0 && prog == lastprog)
return (buf);
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 0cba30d..a0914eb 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: print-udp.c,v 1.60 97/07/27 21:58:48 leres Exp $ (LBL)";
+ "@(#) $Header: print-udp.c,v 1.58 96/12/10 23:22:07 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -35,16 +35,9 @@ static const char rcsid[] =
#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
#include <arpa/tftp.h>
#include <rpc/rpc.h>
@@ -55,7 +48,7 @@ static const char rcsid[] =
#include "addrtoname.h"
#include "appletalk.h"
-#include "nfsv2.h"
+#include "nfs.h"
#include "bootp.h"
struct rtcphdr {
diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1
index d1be277..6b07f45 100644
--- a/contrib/tcpdump/tcpdump.1
+++ b/contrib/tcpdump/tcpdump.1
@@ -1,6 +1,6 @@
-.\" @(#) $Header: tcpdump.1,v 1.67 97/06/30 16:31:50 leres Exp $ (LBL)
+.\" @(#) $Header: tcpdump.1,v 1.65 96/11/29 01:03:01 leres Exp $ (LBL)
.\"
-.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
+.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
.\" The Regents of the University of California. All rights reserved.
.\" All rights reserved.
.\"
@@ -20,14 +20,14 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "30 June 1997"
+.TH TCPDUMP 1 "29 November 1996"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
.na
.B tcpdump
[
-.B \-adeflnNOpqStvx
+.B \-deflnNOpqStvx
] [
.B \-c
.I count
@@ -72,7 +72,7 @@ that match the boolean \fIexpression\fP.
To run
.I tcpdump
you must have read access to
-.I /dev/nit
+.I /dev/net
or
.IR /dev/bpf* .
.B Under Solaris with dlpi:
@@ -94,9 +94,6 @@ You must have read access to
.IR /dev/bpf* .
.SH OPTIONS
.TP
-.B \-a
-Attempt to convert network and broadcast addresses to names.
-.TP
.B \-c
Exit after receiving \fIcount\fP packets.
.TP
@@ -270,6 +267,9 @@ protos are:
.BR sca ,
.BR moprc ,
.BR mopdl ,
+.BR iso ,
+.BR esis ,
+.BR isis ,
.B tcp
and
.BR udp .
@@ -450,7 +450,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, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR"
+.IP "\fBip\fR, \fBarp\fR, \fBrarp\fR, \fBdecnet\fR, \fBiso\fR"
Abbreviations for:
.in +.5i
.nf
@@ -476,6 +476,15 @@ Abbreviations for:
.fi
.in -.5i
where \fIp\fR is one of the above protocols.
+.IP "\fBesis\fR, \fBisis\fR"
+Abbreviations for:
+.in +.5i
+.nf
+\fBiso proto \fIp\fR
+.fi
+.in -.5i
+where \fIp\fR is one of the above protocols.
+Note that \fItcpdump\fR does an incomplete job of parsing these protocols.
.IP "\fIexpr relop expr\fR"
True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
and \fIexpr\fR is an arithmetic expression composed of integer constants
OpenPOWER on IntegriCloud