summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>1997-05-27 02:17:42 +0000
committerfenner <fenner@FreeBSD.org>1997-05-27 02:17:42 +0000
commita45d5a033f69ab70d6de3ead1e8c6fd59f87352b (patch)
treebe1f1538067d8b764f3c8883470f914b73adcec2 /contrib/tcpdump
parent3ff0e744409afb9167d172e5c627942dd28ad80f (diff)
downloadFreeBSD-src-a45d5a033f69ab70d6de3ead1e8c6fd59f87352b.zip
FreeBSD-src-a45d5a033f69ab70d6de3ead1e8c6fd59f87352b.tar.gz
Merge tcpdump 3.3.
The print_nfs.c changes are pretty extensive; this is partially because LBL did a lot of cleanup and partially because I removed lots of pointless changes away from the LBL style. PR: 3371 mostly-Submitted by: Chris Timmons <skynyrd@opus.cts.cwu.edu>
Diffstat (limited to 'contrib/tcpdump')
-rw-r--r--contrib/tcpdump/FREEBSD-upgrade4
-rw-r--r--contrib/tcpdump/aclocal.m4505
-rw-r--r--contrib/tcpdump/addrtoname.c28
-rw-r--r--contrib/tcpdump/nfsfh.h4
-rw-r--r--contrib/tcpdump/parsenfsfh.c53
-rw-r--r--contrib/tcpdump/print-arp.c6
-rw-r--r--contrib/tcpdump/print-atalk.c5
-rw-r--r--contrib/tcpdump/print-atm.c4
-rw-r--r--contrib/tcpdump/print-bootp.c4
-rw-r--r--contrib/tcpdump/print-domain.c6
-rw-r--r--contrib/tcpdump/print-ether.c4
-rw-r--r--contrib/tcpdump/print-fddi.c6
-rw-r--r--contrib/tcpdump/print-icmp.c6
-rw-r--r--contrib/tcpdump/print-ip.c40
-rw-r--r--contrib/tcpdump/print-ipx.c13
-rw-r--r--contrib/tcpdump/print-isoclns.c8
-rw-r--r--contrib/tcpdump/print-llc.c8
-rw-r--r--contrib/tcpdump/print-nfs.c468
-rw-r--r--contrib/tcpdump/print-ntp.c6
-rw-r--r--contrib/tcpdump/print-null.c12
-rw-r--r--contrib/tcpdump/print-ppp.c4
-rw-r--r--contrib/tcpdump/print-sl.c7
-rw-r--r--contrib/tcpdump/print-sunrpc.c4
-rw-r--r--contrib/tcpdump/print-udp.c180
-rw-r--r--contrib/tcpdump/tcpdump.155
25 files changed, 493 insertions, 947 deletions
diff --git a/contrib/tcpdump/FREEBSD-upgrade b/contrib/tcpdump/FREEBSD-upgrade
index 061fa50..02c2e36 100644
--- a/contrib/tcpdump/FREEBSD-upgrade
+++ b/contrib/tcpdump/FREEBSD-upgrade
@@ -8,11 +8,11 @@ To upgrade to a newer version of tcpdump, when it is available:
2. Use the command:
cvs import -m 'Virgin import of LBL tcpdump v<version>' \
- src/contrib/tcpdump LBL 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' \
- src/contrib/tcpdump LBL 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.
diff --git a/contrib/tcpdump/aclocal.m4 b/contrib/tcpdump/aclocal.m4
deleted file mode 100644
index 2c017f6..0000000
--- a/contrib/tcpdump/aclocal.m4
+++ /dev/null
@@ -1,505 +0,0 @@
-dnl @(#) $Header: aclocal.m4,v 1.32 96/07/23 22:55:48 leres Exp $ (LBL)
-dnl
-dnl Copyright (c) 1995, 1996
-dnl The Regents of the University of California. All rights reserved.
-dnl
-dnl Redistribution and use in source and binary forms, with or without
-dnl modification, are permitted provided that: (1) source code distributions
-dnl retain the above copyright notice and this paragraph in its entirety, (2)
-dnl distributions including binary code include the above copyright notice and
-dnl this paragraph in its entirety in the documentation or other materials
-dnl provided with the distribution, and (3) all advertising materials mentioning
-dnl features or use of this software display the following acknowledgement:
-dnl ``This product includes software developed by the University of California,
-dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
-dnl the University nor the names of its contributors may be used to endorse
-dnl or promote products derived from this software without specific prior
-dnl written permission.
-dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-dnl
-dnl LBL autoconf macros
-dnl
-
-dnl
-dnl Determine which compiler we're using (cc or gcc)
-dnl If using gcc, determine the version number
-dnl If using cc, require that it support ansi prototypes
-dnl If using gcc, use -O2 (otherwise use -O)
-dnl If using cc, explicitly specify /usr/local/include
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_C_INIT(copt, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (copt set)
-dnl $2 (incls set)
-dnl CC
-dnl ac_cv_gcc_vers
-dnl
-AC_DEFUN(AC_LBL_C_INIT,
- [$1=-O
- $2=""
- if test -z "$CC" ; then
- case "$target_os" in
-
- bsdi*)
- AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
- if test $SHLICC2 = yes ; then
- CC=shlicc2
- export CC
- fi
- ;;
- esac
- fi
- AC_PROG_CC
- if test $ac_cv_prog_gcc = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_gcc_vers=2
- $1=-O2
- else
- AC_MSG_CHECKING(gcc version)
- AC_CACHE_VAL(ac_cv_gcc_vers,
- ac_cv_gcc_vers=`$CC -v 2>&1 | \
- sed -n -e '$s/.* //' -e '$s/\..*//p'`)
- AC_MSG_RESULT($ac_cv_gcc_vers)
- if test $ac_cv_gcc_vers -gt 1 ; then
- $1=-O2
- fi
- fi
- else
- AC_MSG_CHECKING(that $CC handles ansi prototypes)
- AC_CACHE_VAL(ac_cv_cc_ansi_prototypes,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_cc_ansi_prototypes=yes,
- ac_cv_cc_ansi_prototypes=no))
- AC_MSG_RESULT($ac_cv_cc_ansi_prototypes)
- if test $ac_cv_cc_ansi_prototypes = no ; then
- case "$target_os" in
-
- hpux*)
- AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- AC_CACHE_VAL(ac_cv_cc_hpux_cc_aa,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_cc_hpux_cc_aa=yes,
- ac_cv_cc_hpux_cc_aa=no))
- AC_MSG_RESULT($ac_cv_cc_hpux_cc_aa)
- if test $ac_cv_cc_hpux_cc_aa = no ; then
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
- AC_DEFINE(_HPUX_SOURCE)
- ;;
-
- sni*)
- AC_MSG_CHECKING(for SINIX ansi compiler ($CC -kansi))
- savedcflags="$CFLAGS"
- CFLAGS="-kansi"
- AC_CACHE_VAL(ac_cv_cc_sinix_kansi,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_cc_sinix_kansi=yes,
- ac_cv_cc_sinix_kansi=no))
- AC_MSG_RESULT($ac_cv_cc_sinix_kansi)
- if test $ac_cv_cc_sinix_kansi = no ; then
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-kansi $V_CCOPT"
- ;;
-
- *)
- AC_MSG_ERROR(see the INSTALL for more info)
- ;;
- esac
- fi
- $2=-I/usr/local/include
-
- case "$target_os" in
-
- irix*)
- V_CCOPT="$V_CCOPT -xansi -signed -g3"
- ;;
-
- osf*)
- V_CCOPT="$V_CCOPT -g3"
- ;;
-
- ultrix*)
- AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
- AC_CACHE_VAL(ac_cv_cc_const_proto,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [struct a { int b; };
- void c(const struct a *)],
- ac_cv_cc_const_proto=yes,
- ac_cv_cc_const_proto=no))
- AC_MSG_RESULT($ac_cv_cc_const_proto)
- if test $ac_cv_cc_const_proto = no ; then
- AC_DEFINE(const,)
- fi
- ;;
- esac
- fi
-])
-
-dnl
-dnl Use pfopen.c if available and pfopen() not in standard libraries
-dnl Require libpcap
-dnl Look for libpcap in ..
-dnl Use the installed libpcap if there is no local version
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LIBPCAP(pcapdep, incls)
-dnl
-dnl results:
-dnl
-dnl $1 (pcapdep set)
-dnl $2 (incls appended)
-dnl LIBS
-dnl
-AC_DEFUN(AC_LBL_LIBPCAP,
- [pfopen=/usr/examples/packetfilter/pfopen.c
- if test -f $pfopen ; then
- AC_CHECK_FUNCS(pfopen)
- if test $ac_cv_func_pfopen = "no" ; then
- AC_MSG_RESULT(Using $pfopen)
- LIBS="$LIBS $pfopen"
- fi
- fi
- AC_MSG_CHECKING(for local pcap library)
- libpcap=FAIL
- places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
- egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
- for dir in ../libpcap $places libpcap ; do
- if test -r $dir/pcap.c ; then
- libpcap=$dir/libpcap.a
- d=$dir
- dnl continue and select the last one that exists
- fi
- done
- if test $libpcap = FAIL ; then
- AC_MSG_RESULT(not found)
- AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
- if test $libpcap = FAIL ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- else
- $1=$libpcap
- $2="-I$d $$2"
- AC_MSG_RESULT($libpcap)
- fi
- LIBS="$libpcap $LIBS"])
-
-dnl
-dnl Define RETSIGTYPE and RETSIGVAL
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_TYPE_SIGNAL
-dnl
-dnl results:
-dnl
-dnl RETSIGTYPE (defined)
-dnl RETSIGVAL (defined)
-dnl
-AC_DEFUN(AC_LBL_TYPE_SIGNAL,
- [AC_TYPE_SIGNAL
- if test "$ac_cv_type_signal" = void ; then
- AC_DEFINE(RETSIGVAL,)
- else
- AC_DEFINE(RETSIGVAL,(0))
- fi
- case "$target_os" in
-
- irix*)
- AC_DEFINE(_BSD_SIGNALS)
- ;;
-
- *)
- AC_CHECK_FUNCS(sigset)
- if test $ac_cv_func_sigset = yes ; then
- AC_DEFINE(signal, sigset)
- fi
- ;;
- esac])
-
-dnl
-dnl If using gcc, see if fixincludes should be run
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_FIXINCLUDES
-dnl
-AC_DEFUN(AC_LBL_FIXINCLUDES,
- [if test $ac_cv_prog_gcc = yes ; then
- AC_MSG_CHECKING(if fixincludes is needed)
- AC_CACHE_VAL(ac_cv_gcc_fixincludes,
- AC_TRY_COMPILE(
- [/*
- * This generates a "duplicate case value" when fixincludes
- * has not be run.
- */
-# include <sys/types.h>
-# include <sys/time.h>
-# include <sys/ioctl.h>
-# ifdef HAVE_SYS_IOCCOM_H
-# include <sys/ioccom.h>
-# endif],
- [switch (0) {
- case _IO('A', 1):;
- case _IO('B', 1):;
- }],
- ac_cv_gcc_fixincludes=yes,
- ac_cv_gcc_fixincludes=no))
- AC_MSG_RESULT($ac_cv_gcc_fixincludes)
- if test $ac_cv_gcc_fixincludes = no ; then
- # Don't cache failure
- unset ac_cv_gcc_fixincludes
- AC_MSG_ERROR(see the INSTALL for more info)
- fi
- fi])
-
-dnl
-dnl Check for flex, default to lex
-dnl Require flex 2.4 or higher
-dnl Check for bison, default to yacc
-dnl Default to lex/yacc if both flex and bison are not available
-dnl Define the yy prefix string if using flex and bison
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
-dnl
-dnl results:
-dnl
-dnl $1 (lex set)
-dnl $2 (yacc appended)
-dnl $3 (optional flex and bison -P prefix)
-dnl
-AC_DEFUN(AC_LBL_LEX_AND_YACC,
- [AC_CHECK_PROGS($1, flex, lex)
- if test "$$1" = flex ; then
- # The -V flag was added in 2.4
- AC_MSG_CHECKING(for flex 2.4 or higher)
- AC_CACHE_VAL(ac_cv_flex_v24,
- if flex -V >/dev/null 2>&1; then
- ac_cv_flex_v24=yes
- else
- ac_cv_flex_v24=no
- fi)
- AC_MSG_RESULT($ac_cv_flex_v24)
- if test $ac_cv_flex_v24 = no ; then
- s="2.4 or higher required"
- AC_MSG_WARN(ignoring obsolete flex executable ($s))
- $1=lex
- fi
- fi
- AC_CHECK_PROGS($2, bison, yacc)
- if test "$$2" = bison ; then
- $2="$$2 -y"
- fi
- if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
- AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
- $1=lex
- $2=yacc
- fi
- if test "$$1" = flex -a -n "$3" ; then
- $1="$$1 -P$3"
- $2="$$2 -p $3"
- fi])
-
-dnl
-dnl Checks to see if union wait is used with WEXITSTATUS()
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNION_WAIT
-dnl
-dnl results:
-dnl
-dnl DECLWAITSTATUS (defined)
-dnl
-AC_DEFUN(AC_LBL_UNION_WAIT,
- [AC_MSG_CHECKING(if union wait is used)
- AC_CACHE_VAL(ac_cv_union_wait,
- AC_TRY_COMPILE([
- # include <sys/types.h>
- # include <sys/wait.h>],
- [int status;
- u_int i = WEXITSTATUS(status);
- u_int j = waitpid(0, &status, 0);],
- ac_cv_union_wait=no,
- ac_cv_union_wait=yes))
- AC_MSG_RESULT($ac_cv_union_wait)
- if test $ac_cv_union_wait = yes ; then
- AC_DEFINE(DECLWAITSTATUS,union wait)
- else
- AC_DEFINE(DECLWAITSTATUS,int)
- fi])
-
-dnl
-dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_SOCKADDR_SA_LEN
-dnl
-dnl results:
-dnl
-dnl HAVE_SOCKADDR_SA_LEN (defined)
-dnl
-AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
- [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
- AC_CACHE_VAL(ac_cv_sockaddr_has_sa_len,
- AC_TRY_COMPILE([
-# include <sys/types.h>
-# include <sys/socket.h>],
- [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
- ac_cv_sockaddr_has_sa_len=yes,
- ac_cv_sockaddr_has_sa_len=no))
- AC_MSG_RESULT($ac_cv_sockaddr_has_sa_len)
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
- fi])
-
-dnl
-dnl Checks to see if -R is used
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_HAVE_RUN_PATH
-dnl
-dnl results:
-dnl
-dnl ac_cv_have_run_path (yes or no)
-dnl
-AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
- [AC_MSG_CHECKING(for ${CC-cc} -R)
- AC_CACHE_VAL(ac_cv_have_run_path,
- [echo 'main(){}' > conftest.c
- ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
- if test ! -s conftest.out ; then
- ac_cv_have_run_path=yes
- else
- ac_cv_have_run_path=no
- fi
- rm -f conftest*])
- AC_MSG_RESULT($ac_cv_have_run_path)
- ])
-
-dnl
-dnl Checks to see if unaligned memory accesses fail
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_UNALIGNED_ACCESS
-dnl
-dnl results:
-dnl
-dnl LBL_ALIGN (DEFINED)
-dnl
-AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
- [AC_MSG_CHECKING(if unaligned accesses fail)
- AC_CACHE_VAL(ac_cv_unaligned_fail,
- [case "$target_cpu" in
-
- alpha|hp*|mips|sparc)
- ac_cv_unaligned_fail=yes
- ;;
-
- *)
- cat >conftest.c <<EOF
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <stdio.h>
- unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
- main() {
- unsigned int i;
- pid_t pid;
- int status;
- /* avoid "core dumped" message */
- pid = fork();
- if (pid < 0)
- exit(2);
- if (pid > 0) {
- /* parent */
- pid = waitpid(pid, &status, 0);
- if (pid < 0)
- exit(3);
- exit(!WIFEXITED(status));
- }
- /* child */
- i = *(unsigned int *)&a[1];
- printf("%d\n", i);
- exit(0);
- }
-EOF
- ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
- conftest.c $LIBS >/dev/null 2>&1
- if test ! -x conftest ; then
- dnl failed to compile for some reason
- ac_cv_unaligned_fail=yes
- else
- ./conftest >conftest.out
- if test ! -s conftest.out ; then
- ac_cv_unaligned_fail=yes
- else
- ac_cv_unaligned_fail=no
- fi
- fi
- rm -f conftest* core core.conftest
- ;;
- esac])
- AC_MSG_RESULT($ac_cv_unaligned_fail)
- if test $ac_cv_unaligned_fail = yes ; then
- AC_DEFINE(LBL_ALIGN)
- fi])
-
-dnl
-dnl If using gcc and the file .devel exists:
-dnl Compile with -g (if supported) and -Wall
-dnl If using gcc 2, do extra prototype checking
-dnl If an os prototype include exists, symlink os-proto.h to it
-dnl
-dnl usage:
-dnl
-dnl AC_LBL_DEVEL(copt)
-dnl
-dnl results:
-dnl
-dnl $1 (copt appended)
-dnl HAVE_OS_PROTO_H (defined)
-dnl os-proto.h (symlinked)
-dnl
-AC_DEFUN(AC_LBL_DEVEL,
- [rm -f os-proto.h
- if test $ac_cv_prog_gcc = yes -a -f .devel ; then
- if test $ac_cv_prog_gcc_g = yes ; then
- $1="-g $$1"
- fi
- $1="$$1 -Wall"
- if test $ac_cv_gcc_vers -gt 1 ; then
- $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
- fi
- os=`echo $target_os | sed -e 's/\([[0-9]]\)[[0-9.]][[0-9.]]*$/\1/'`
- name="lbl/os-$os.h"
- if test -f $name ; then
- ln -s $name os-proto.h
- AC_DEFINE(HAVE_OS_PROTO_H)
- else
- AC_MSG_WARN(can't find $name)
- fi
- fi])
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index 11d150f..e6b3e41 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -22,8 +22,8 @@
* and address to string conversion routines
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: addrtoname.c,v 1.49 96/07/02 00:19:35 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: addrtoname.c,v 1.54 96/12/05 22:10:19 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
@@ -164,7 +164,7 @@ getname(const u_char *ap)
addr = *(const u_int32_t *)ap;
#else
/*
- * Deal with alignment.
+ * Extract 32 bits in network order, dealing with alignment.
*/
switch ((long)ap & 3) {
@@ -173,26 +173,26 @@ getname(const u_char *ap)
break;
case 2:
-#if BYTE_ORDER == LITTLE_ENDIAN
- addr = ((u_int32_t)*(u_short *)(ap + 2) << 16) |
- (u_int32_t)*(u_short *)ap;
-#else
+#ifdef WORDS_BIGENDIAN
addr = ((u_int32_t)*(u_short *)ap << 16) |
(u_int32_t)*(u_short *)(ap + 2);
+#else
+ addr = ((u_int32_t)*(u_short *)(ap + 2) << 16) |
+ (u_int32_t)*(u_short *)ap;
#endif
break;
default:
-#if BYTE_ORDER == LITTLE_ENDIAN
- addr = ((u_int32_t)ap[3] << 24) |
- ((u_int32_t)ap[2] << 16) |
- ((u_int32_t)ap[1] << 8) |
- (u_int32_t)ap[0];
-#else
+#ifdef WORDS_BIGENDIAN
addr = ((u_int32_t)ap[0] << 24) |
((u_int32_t)ap[1] << 16) |
((u_int32_t)ap[2] << 8) |
(u_int32_t)ap[3];
+#else
+ addr = ((u_int32_t)ap[3] << 24) |
+ ((u_int32_t)ap[2] << 16) |
+ ((u_int32_t)ap[1] << 8) |
+ (u_int32_t)ap[0];
#endif
break;
}
@@ -739,7 +739,7 @@ dnaddr_string(u_short dnaddr)
/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
struct hnamemem *
-newhnamemem()
+newhnamemem(void)
{
register struct hnamemem *p;
static struct hnamemem *ptr = NULL;
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index c1ce79b..d8e9c0d 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -1,5 +1,5 @@
/*
- * $Header: nfsfh.h,v 1.4 95/10/19 20:27:44 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)
*
@@ -24,7 +24,7 @@ typedef struct {
* our internal representation of that.
*/
typedef struct {
- my_devt fsid_dev;
+ my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
u_int32_t fsid_code;
} my_fsid;
diff --git a/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c
index cc79aae..bd5e690 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -1,7 +1,3 @@
-#ifndef lint
-static char *RCSid = "$Header: parsenfsfh.c,v 1.9 95/10/19 20:27:44 leres Exp $";
-#endif
-
/*
* parsenfsfh.c - portable parser for NFS file handles
* uses all sorts of heuristics
@@ -11,6 +7,11 @@ static char *RCSid = "$Header: parsenfsfh.c,v 1.9 95/10/19 20:27:44 leres Exp $"
* Western Research Laboratory
*/
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: parsenfsfh.c,v 1.12 96/12/10 23:25:50 leres Exp $ (LBL)";
+#endif
+
#include <sys/types.h>
#include <sys/time.h>
@@ -216,8 +217,8 @@ int ourself; /* true if file handle was generated on this host */
switch (fhtype) {
case FHT_AUSPEX:
- fsidp->fsid_dev.Minor = fhp[7];
- fsidp->fsid_dev.Major = fhp[6];
+ fsidp->Fsid_dev.Minor = fhp[7];
+ fsidp->Fsid_dev.Major = fhp[6];
fsidp->fsid_code = 0;
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -232,8 +233,8 @@ int ourself; /* true if file handle was generated on this host */
/* XXX could ignore 3 high-order bytes */
temp = make_uint32(fhp[3], fhp[2], fhp[1], fhp[0]);
- fsidp->fsid_dev.Minor = temp & 0xFFFFF;
- fsidp->fsid_dev.Major = (temp>>20) & 0xFFF;
+ fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
+ fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
*inop = temp;
@@ -242,8 +243,8 @@ int ourself; /* true if file handle was generated on this host */
break;
case FHT_IRIX4:
- fsidp->fsid_dev.Minor = fhp[3];
- fsidp->fsid_dev.Major = fhp[2];
+ fsidp->Fsid_dev.Minor = fhp[3];
+ fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = 0;
temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
@@ -254,8 +255,8 @@ int ourself; /* true if file handle was generated on this host */
break;
case FHT_IRIX5:
- fsidp->fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
- fsidp->fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
+ fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
+ fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -271,8 +272,8 @@ int ourself; /* true if file handle was generated on this host */
break;
case FHT_SUNOS4:
- fsidp->fsid_dev.Minor = fhp[3];
- fsidp->fsid_dev.Major = fhp[2];
+ fsidp->Fsid_dev.Minor = fhp[3];
+ fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -284,9 +285,9 @@ int ourself; /* true if file handle was generated on this host */
case FHT_SUNOS5:
temp = make_uint16(fhp[0], fhp[1]);
- fsidp->fsid_dev.Major = (temp>>2) & 0x3FFF;
+ fsidp->Fsid_dev.Major = (temp>>2) & 0x3FFF;
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
- fsidp->fsid_dev.Minor = temp & 0x3FFFF;
+ fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -298,8 +299,8 @@ int ourself; /* true if file handle was generated on this host */
case FHT_ULTRIX:
fsidp->fsid_code = 0;
- fsidp->fsid_dev.Minor = fhp[0];
- fsidp->fsid_dev.Major = fhp[1];
+ fsidp->Fsid_dev.Minor = fhp[0];
+ fsidp->Fsid_dev.Major = fhp[1];
temp = make_uint32(fhp[7], fhp[6], fhp[5], fhp[4]);
*inop = temp;
@@ -319,8 +320,8 @@ int ourself; /* true if file handle was generated on this host */
memset((char *)tempa, 0, sizeof(tempa));
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_dev.Minor = tempa[0] + (tempa[1]<<1);
+ fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
fsidp->fsid_code = 0;
}
@@ -336,8 +337,8 @@ int ourself; /* true if file handle was generated on this host */
break;
case FHT_AIX32:
- fsidp->fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
- fsidp->fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
+ fsidp->Fsid_dev.Minor = make_uint16(fhp[2], fhp[3]);
+ fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -348,9 +349,9 @@ int ourself; /* true if file handle was generated on this host */
break;
case FHT_HPUX9:
- fsidp->fsid_dev.Major = fhp[0];
+ fsidp->Fsid_dev.Major = fhp[0];
temp = make_uint24(fhp[1], fhp[2], fhp[3]);
- fsidp->fsid_dev.Minor = temp;
+ fsidp->Fsid_dev.Minor = temp;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
@@ -372,8 +373,8 @@ int ourself; /* true if file handle was generated on this host */
#endif
/* XXX for now, give "bogus" values to aid debugging */
fsidp->fsid_code = 0;
- fsidp->fsid_dev.Minor = 257;
- fsidp->fsid_dev.Major = 257;
+ fsidp->Fsid_dev.Minor = 257;
+ fsidp->Fsid_dev.Major = 257;
*inop = 1;
/* display will show this string instead of (257,257) */
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index e58aeab..c9533c7 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-arp.c,v 1.39 96/07/17 14:56:17 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-arp.c,v 1.41 96/10/27 14:54:50 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -127,5 +127,5 @@ arp_print(register const u_char *bp, u_int length, u_int caplen)
return;
}
if (hrd != ARPHRD_ETHER)
- printf(" hardware #%d", ap->arp_hrd);
+ printf(" hardware #%d", hrd);
}
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index e81afb1..c8e1c10 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -20,9 +20,10 @@
*
* Format and print AppleTalk packets.
*/
+
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-atalk.c,v 1.43 96/07/23 14:16:55 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-atalk.c,v 1.45 96/12/10 23:24:07 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index e07fa2a..3c0d665 100644
--- a/contrib/tcpdump/print-atm.c
+++ b/contrib/tcpdump/print-atm.c
@@ -19,8 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-atm.c,v 1.7 96/07/23 14:17:21 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-atm.c,v 1.8 96/09/26 23:36:41 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index 4402e49..425c11c 100644
--- a/contrib/tcpdump/print-bootp.c
+++ b/contrib/tcpdump/print-bootp.c
@@ -21,8 +21,8 @@
* Format and print bootp packets.
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-bootp.c,v 1.42 96/07/23 14:17:22 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-bootp.c,v 1.43 96/09/26 23:36:42 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index e6651e7..f995617 100644
--- a/contrib/tcpdump/print-domain.c
+++ b/contrib/tcpdump/print-domain.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-domain.c,v 1.35 96/07/23 14:17:22 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-domain.c,v 1.37 96/12/10 23:21:06 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -323,7 +323,7 @@ ns_rprint(register const u_char *cp, register const u_char *bp)
printf(" %.*s", len, cp);
break;
}
- return (rp); /* XXX This isn't always right*/
+ return (rp); /* XXX This isn't always right */
}
void
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index bab0059..2c92d4f 100644
--- a/contrib/tcpdump/print-ether.c
+++ b/contrib/tcpdump/print-ether.c
@@ -19,8 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-ether.c,v 1.42 96/07/23 14:17:23 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-ether.c,v 1.43 96/09/26 23:36:43 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index c577562..1714735 100644
--- a/contrib/tcpdump/print-fddi.c
+++ b/contrib/tcpdump/print-fddi.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-fddi.c,v 1.31 96/07/14 19:38:59 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-fddi.c,v 1.33 96/12/10 23:20:49 leres Exp $ (LBL)";
#endif
#ifdef HAVE_FDDI
@@ -279,7 +279,7 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
/*
* Get the FDDI addresses into a canonical form
*/
- extract_fddi_addrs(fddip, (char*)ESRC(&ehdr), (char*)EDST(&ehdr));
+ extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
/*
* 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.
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index a94dd13..70139e0 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-icmp.c,v 1.36 96/07/23 14:17:24 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-icmp.c,v 1.38 96/09/26 23:36:44 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -273,7 +273,7 @@ icmp_print(register const u_char *bp, register const u_char *bp2)
ihp = (struct ih_rdiscovery *)&dp->icmp_void;
TCHECK(*ihp);
- (void)strcpy(cp, "lifetime ");
+ (void)strcpy(cp, " lifetime ");
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
if (lifetime < 60)
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index 2f49352..fdad8e2 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/print-ip.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-ip.c,v 1.56 96/07/23 14:17:24 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-ip.c,v 1.62 96/12/10 23:20:31 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -64,17 +64,17 @@ struct tr_query {
u_int tr_src; /* traceroute source */
u_int tr_dst; /* traceroute destination */
u_int tr_raddr; /* traceroute response address */
-#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
+#ifdef WORDS_BIGENDIAN
struct {
- u_int qid : 24; /* traceroute query id */
- u_int ttl : 8; /* traceroute response ttl */
+ u_int ttl : 8; /* traceroute response ttl */
+ u_int qid : 24; /* traceroute query id */
} q;
#else
struct {
- u_int ttl : 8; /* traceroute response ttl */
- u_int qid : 24; /* traceroute query id */
+ u_int qid : 24; /* traceroute query id */
+ u_int ttl : 8; /* traceroute response ttl */
} q;
-#endif /* BYTE_ORDER */
+#endif
};
#define tr_rttl q.ttl
@@ -121,7 +121,7 @@ struct tr_resp {
static void print_mtrace(register const u_char *bp, register u_int len)
{
- register struct tr_query* tr = (struct tr_query*)(bp + 8);
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
printf("mtrace %d: %s to %s reply-to %s", tr->tr_qid,
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
@@ -132,7 +132,7 @@ static void print_mtrace(register const u_char *bp, register u_int len)
static void print_mresp(register const u_char *bp, register u_int len)
{
- register struct tr_query* tr = (struct tr_query*)(bp + 8);
+ register struct tr_query *tr = (struct tr_query *)(bp + 8);
printf("mresp %d: %s to %s reply-to %s", tr->tr_qid,
ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
@@ -209,12 +209,12 @@ igmp_print(register const u_char *bp, register u_int len,
/* Check the IGMP checksum */
u_int32_t sum = 0;
int count;
- const u_short *sp = (u_short*)bp;
+ const u_short *sp = (u_short *)bp;
for (count = len / 2; --count >= 0; )
sum += *sp++;
if (len & 1)
- sum += ntohs(*(unsigned char*) sp << 8);
+ sum += ntohs(*(u_char *) sp << 8);
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
sum = 0xffff & ~sum;
@@ -461,6 +461,22 @@ ip_print(register const u_char *bp, register u_int length)
}
break;
+#ifndef IPPROTO_GRE
+#define IPPROTO_GRE 47
+#endif
+ case IPPROTO_GRE:
+ if (vflag)
+ (void)printf("gre %s > %s: ",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
+ /* do it */
+ gre_print(cp, len);
+ if (! vflag) {
+ printf(" (gre encap)");
+ return;
+ }
+ break;
+
default:
(void)printf("%s > %s:", ipaddr_string(&ip->ip_src),
ipaddr_string(&ip->ip_dst));
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index 8125e41..d49bcb7 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -17,15 +17,14 @@
* 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.
- */
-
-/*
+ *
* Format and print Novell IPX packets.
* Contributed by Brad Parker (brad@fcr.com).
*/
+
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-ipx.c,v 1.16 96/07/23 14:17:24 leres Exp $";
+static const char rcsid[] =
+ "@(#) $Header: print-ipx.c,v 1.19 96/12/10 23:23:52 leres Exp $";
#endif
#include <sys/param.h>
@@ -145,7 +144,7 @@ ipx_sap_print(const u_short *ipx, u_int length)
if (length > 0) {
TCHECK(ipx[1]);
(void)printf(" %x '", EXTRACT_16BITS(&ipx[0]));
- fn_print((char *)&ipx[1], (char *)&ipx[1] + 48);
+ fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
putchar('\'');
}
break;
@@ -160,7 +159,7 @@ ipx_sap_print(const u_short *ipx, u_int length)
for (i = 0; i < 8 && length > 0; i++) {
TCHECK2(ipx[27], 1);
(void)printf(" %x '", EXTRACT_16BITS(&ipx[0]));
- fn_print((char *)&ipx[1], (char *)&ipx[1] + 48);
+ fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
printf("' addr %s",
ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
ipx += 32;
diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c
index d5e1496..bc3e67f 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -17,15 +17,13 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
+ *
* Original code by Matt Thomas, Digital Equipment Corporation
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-isoclns.c,v 1.12 96/07/14 19:39:00 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-isoclns.c,v 1.14 96/12/10 23:26:56 leres Exp $ (LBL)";
#endif
#include <sys/types.h>
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index 523c633..b1f17f9 100644
--- a/contrib/tcpdump/print-llc.c
+++ b/contrib/tcpdump/print-llc.c
@@ -17,16 +17,14 @@
* 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.
- */
-
-/*
+ *
* Code by Matt Thomas, Digital Equipment Corporation
* with an awful lot of hacking by Jeffrey Mogul, DECWRL
*/
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-llc.c,v 1.20 96/07/23 14:17:25 leres Exp $";
+static const char rcsid[] =
+ "@(#) $Header: print-llc.c,v 1.22 96/12/10 23:23:37 leres Exp $";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index c705574..865e36b 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-nfs.c,v 1.56 96/07/23 14:17:25 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-nfs.c,v 1.63 96/12/10 23:18:07 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -36,15 +36,11 @@ static char rcsid[] =
#include <netinet/ip.h>
#include <netinet/ip_var.h>
-#ifdef SOLARIS
-#include <tiuser.h>
-#endif
#include <rpc/rpc.h>
-#include <rpc/pmap_prot.h>
#include <ctype.h>
+#include <pcap.h>
#include <stdio.h>
-#include <errno.h>
#include <string.h>
#include "interface.h"
@@ -61,6 +57,8 @@ static 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_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.
*/
@@ -129,7 +127,6 @@ static struct tok type2str[] = {
int print_int64(const u_int32_t *dp, int how)
{
- static char buf[32];
#ifdef INT64_FORMAT
u_int64_t res;
@@ -166,51 +163,51 @@ 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 (0);
+ return (NULL);
if ((sa3->sa_modeset = ntohl(*dp++))) {
if (dp + 1 > ep)
- return (0);
+ return (NULL);
sa3->sa_mode = ntohl(*dp++);
}
if (dp + 1 > ep)
- return (0);
+ return (NULL);
if ((sa3->sa_uidset = ntohl(*dp++))) {
if (dp + 1 > ep)
- return (0);
+ return (NULL);
sa3->sa_uid = ntohl(*dp++);
}
if (dp + 1 > ep)
- return (0);
+ return (NULL);
if ((sa3->sa_gidset = ntohl(*dp++))) {
if (dp + 1 > ep)
- return (0);
+ return (NULL);
sa3->sa_gid = ntohl(*dp++);
}
if (dp + 1 > ep)
- return (0);
+ return (NULL);
if ((sa3->sa_sizeset = ntohl(*dp++))) {
if (dp + 1 > ep)
- return (0);
+ return (NULL);
sa3->sa_size = ntohl(*dp++);
}
if (dp + 1 > ep)
- return (0);
+ return (NULL);
if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
if (dp + 2 > ep)
- return (0);
+ return (NULL);
sa3->sa_atime.nfsv3_sec = ntohl(*dp++);
sa3->sa_atime.nfsv3_nsec = ntohl(*dp++);
}
if (dp + 1 > ep)
- return (0);
+ return (NULL);
if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) {
if (dp + 2 > ep)
- return (0);
+ return (NULL);
sa3->sa_mtime.nfsv3_sec = ntohl(*dp++);
sa3->sa_mtime.nfsv3_nsec = ntohl(*dp++);
}
@@ -245,6 +242,7 @@ nfsreply_print(register const u_char *bp, u_int length,
register const struct ip *ip;
u_int32_t proc, vers;
+ nfserr = 0; /* assume no error */
rp = (const struct rpc_msg *)bp;
ip = (const struct ip *)bp2;
@@ -272,37 +270,37 @@ nfsreply_print(register const u_char *bp, u_int 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 int length)
{
- register const u_int32_t *dp = (u_int32_t *)&rp->rm_call.cb_cred;
- register const u_int32_t *ep = (u_int32_t *)snapend;
+ register const u_int32_t *dp;
register u_int len;
- if (&dp[2] >= ep)
- return (0);
/*
* find the start of the req data (if we captured it)
*/
- len = ntohl(dp[1]);
- if (dp < ep && len < length) {
- dp += (len + (2 * sizeof(u_int32_t) + 3)) / sizeof(u_int32_t);
+ dp = (u_int32_t *)&rp->rm_call.cb_cred;
+ TCHECK(dp[1]);
+ len = ntohl(dp[1]);
+ if (len < length) {
+ dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
+ TCHECK(dp[1]);
len = ntohl(dp[1]);
- if ((dp < ep) && (len < length)) {
- dp += (len + (2 * sizeof(u_int32_t) + 3)) /
- sizeof(u_int32_t);
- if (dp < ep)
- return (dp);
+ if (len < length) {
+ dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
+ TCHECK2(dp[0], 0);
+ return (dp);
}
}
- return (0);
+trunc:
+ return (NULL);
}
/*
* Print out an NFS file handle and return a pointer to following word.
- * If packet was truncated, return 0.
+ * If packet was truncated, return NULL.
*/
static const u_int32_t *
parsefh(register const u_int32_t *dp, int v3)
@@ -310,23 +308,23 @@ parsefh(register const u_int32_t *dp, int v3)
int len;
if (v3) {
- if (dp + 1 > (u_int32_t *)snapend)
- return (0);
+ TCHECK(dp[0]);
len = (int)ntohl(*dp) / 4;
dp++;
} else
len = NFSX_V2FH / 4;
- if (dp + len <= (u_int32_t *)snapend) {
+ if (TTEST2(*dp, len * sizeof(*dp))) {
nfs_printfh(dp, len);
return (dp + len);
}
- return (0);
+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)
@@ -336,7 +334,7 @@ parsefn(register const u_int32_t *dp)
/* Bail if we don't have the string length */
if ((u_char *)dp > snapend - sizeof(*dp))
- return(0);
+ return (NULL);
/* Fetch string length; convert to host order */
len = *dp++;
@@ -346,9 +344,11 @@ parsefn(register const u_int32_t *dp)
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
if ((u_char *)dp > snapend)
- return (0);
+ return (NULL);
/* XXX seems like we should be checking the length */
+ putchar('"');
(void) fn_printn(cp, len, NULL);
+ putchar('"');
return (dp);
}
@@ -356,14 +356,14 @@ 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, int v3)
{
dp = parsefh(dp, v3);
- if (dp == 0)
- return (0);
+ if (dp == NULL)
+ return (NULL);
putchar(' ');
return (parsefn(dp));
}
@@ -375,14 +375,13 @@ 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;
- register const u_char *ep;
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;
- ep = snapend;
if (!nflag)
(void)printf("%s.%x > %s.nfs: %d",
ipaddr_string(&ip->ip_src),
@@ -415,42 +414,42 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_GETATTR:
printf(" getattr");
- if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_SETATTR:
printf(" setattr");
- if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_LOOKUP:
printf(" lookup");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_ACCESS:
printf(" access");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
TCHECK(*dp);
- printf(" %04x", ntohl(dp[0]));
+ printf(" %04lx", ntohl(dp[0]));
return;
}
break;
case NFSPROC_READLINK:
printf(" readlink");
- if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
case NFSPROC_READ:
printf(" read");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK2(*dp, 3 * sizeof(*dp));
printf(" %lu bytes @ ", ntohl(dp[2]));
@@ -466,8 +465,8 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_WRITE:
printf(" write");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK2(*dp, 3 * sizeof(*dp));
printf(" %lu bytes @ ", ntohl(dp[4]));
@@ -490,24 +489,24 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_CREATE:
printf(" create");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_MKDIR:
printf(" mkdir");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_SYMLINK:
printf(" symlink");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefhn(dp, v3)) != NULL) {
fputs(" -> ", stdout);
- if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
+ if (v3 && (dp = parse_sattr3(dp, &sa3)) == NULL)
break;
- if (parsefn(dp) == 0)
+ if (parsefn(dp) == NULL)
break;
if (v3 && vflag)
print_sattr3(&sa3, vflag);
@@ -517,18 +516,18 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_MKNOD:
printf(" mknod");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
+ 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)) == 0)
+ 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(" %u/%u", ntohl(dp[0]), ntohl(dp[1]));
+ printf(" %lu/%lu", ntohl(dp[0]), ntohl(dp[1]));
dp += 2;
}
if (vflag)
@@ -539,40 +538,40 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_REMOVE:
printf(" remove");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_RMDIR:
printf(" rmdir");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
return;
break;
case NFSPROC_RENAME:
printf(" rename");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefhn(dp, v3)) != NULL) {
fputs(" ->", stdout);
- if (parsefhn(dp, v3) != 0)
+ if (parsefhn(dp, v3) != NULL)
return;
}
break;
case NFSPROC_LINK:
printf(" link");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
fputs(" ->", stdout);
- if (parsefhn(dp, v3) != 0)
+ if (parsefhn(dp, v3) != NULL)
return;
}
break;
case NFSPROC_READDIR:
printf(" readdir");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
if (v3) {
TCHECK2(*dp, 20);
/*
@@ -582,7 +581,7 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" %lu bytes @ ", ntohl(dp[4]));
print_int64(dp, SIGNED);
if (vflag)
- printf(" verf %08lx%08lx", dp[2],
+ printf(" verf %08x%08x", dp[2],
dp[3]);
} else {
TCHECK2(*dp, 2 * sizeof(*dp));
@@ -599,8 +598,8 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_READDIRPLUS:
printf(" readdirplus");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
TCHECK2(*dp, 20);
/*
* We don't try to interpret the offset
@@ -609,7 +608,7 @@ nfsreq_print(register const u_char *bp, u_int length,
printf(" %lu bytes @ ", ntohl(dp[4]));
print_int64(dp, SIGNED);
if (vflag)
- printf(" max %lu verf %08lx%08lx",
+ printf(" max %lu verf %08x%08x",
ntohl(dp[5]), dp[2], dp[3]);
return;
}
@@ -617,7 +616,7 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_FSSTAT:
printf(" fsstat");
- if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0)
+ if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
return;
break;
@@ -631,8 +630,8 @@ nfsreq_print(register const u_char *bp, u_int length,
case NFSPROC_COMMIT:
printf(" commit");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefh(dp, v3)) != 0) {
+ if ((dp = parsereq(rp, length)) != NULL &&
+ (dp = parsefh(dp, v3)) != NULL) {
printf(" %lu bytes @ ", ntohl(dp[2]));
print_int64(dp, UNSIGNED);
return;
@@ -644,7 +643,8 @@ nfsreq_print(register const u_char *bp, u_int length,
return;
}
trunc:
- fputs(" [|nfs]", stdout);
+ if (!nfserr)
+ fputs(" [|nfs]", stdout);
}
/*
@@ -663,26 +663,23 @@ nfs_printfh(register const u_int32_t *dp, const int len)
ino_t ino;
char *sfsname = NULL;
- Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0);
+ Parse_fh((caddr_t *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
if (sfsname) {
- /* file system ID is ASCII, not numeric, for this server OS */
- static char temp[NFSX_V3FHMAX+1];
+ /* file system ID is ASCII, not numeric, for this server OS */
+ static char temp[NFSX_V3FHMAX+1];
- /* Make sure string is null-terminated */
- strncpy(temp, sfsname, NFSX_V3FHMAX);
- /* Remove trailing spaces */
- sfsname = strchr(temp, ' ');
- if (sfsname)
- *sfsname = 0;
+ /* Make sure string is null-terminated */
+ strncpy(temp, sfsname, NFSX_V3FHMAX);
+ /* Remove trailing spaces */
+ sfsname = strchr(temp, ' ');
+ if (sfsname)
+ *sfsname = 0;
- (void)printf(" fh %s/%u", temp, (u_int32_t)ino);
- }
- else {
- (void)printf(" fh %u,%u/%u",
- fsid.fsid_dev.Major,
- fsid.fsid_dev.Minor,
- (u_int32_t)ino);
+ (void)printf(" fh %s/%u", temp, (u_int32_t)ino);
+ } else {
+ (void)printf(" fh %u,%u/%u",
+ fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor, (u_int32_t)ino);
}
}
@@ -730,7 +727,10 @@ xid_map_enter(const struct rpc_msg *rp, const struct ip *ip)
xmep->vers = ntohl(rp->rm_call.cb_vers);
}
-/* Returns NFSPROC_xxx or -1 on failure */
+/*
+ * 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)
@@ -758,7 +758,7 @@ xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc,
} while (i != xid_map_hint);
/* search failed */
- return(-1);
+ return (-1);
}
/*
@@ -767,13 +767,12 @@ 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 int length)
{
register const u_int32_t *dp;
- register const u_int32_t *ep = (const u_int32_t *)snapend;
int len;
enum accept_stat astat;
@@ -793,17 +792,15 @@ parserep(register const struct rpc_msg *rp, register int length)
* which is an "enum" and so occupies one 32-bit word.
*/
dp = ((const u_int32_t *)&rp->rm_reply) + 1;
- if (&dp[1] >= ep)
- return(0);
+ TCHECK2(dp[0], 1);
len = ntohl(dp[1]);
if (len >= length)
- return(0);
+ return (NULL);
/*
* skip past the ar_verf credentials.
*/
dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t);
- if (dp >= ep)
- return(0);
+ TCHECK2(dp[0], 0);
/*
* now we can check the ar_stat field
@@ -816,66 +813,63 @@ parserep(register const struct rpc_msg *rp, register int length)
case PROG_UNAVAIL:
printf(" PROG_UNAVAIL");
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
case PROG_MISMATCH:
printf(" PROG_MISMATCH");
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
case PROC_UNAVAIL:
printf(" PROC_UNAVAIL");
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
case GARBAGE_ARGS:
printf(" GARBAGE_ARGS");
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
case SYSTEM_ERR:
printf(" SYSTEM_ERR");
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
default:
printf(" ar_stat %d", astat);
- return(0);
+ nfserr = 1; /* suppress trunc string */
+ return (NULL);
}
/* successful return */
- if ((sizeof(astat) + ((char *)dp)) < (char *)ep)
- return((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+ if ((sizeof(astat) + ((u_char *)dp)) < snapend)
+ return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
- return (0);
+trunc:
+ return (NULL);
}
-#define T2CHECK(p, l) if ((u_char *)(p) > ((u_char *)snapend) - l) return(0)
-
-/*
- * Not all systems have strerror().
- */
-static char *
-strerr(int errno)
-{
- return (strerror(errno));
-}
+#define T2CHECK(p, l) if ((u_char *)(p) > ((u_char *)snapend) - l) return(NULL)
static const u_int32_t *
parsestatus(const u_int32_t *dp, int *er)
{
- int errno;
- T2CHECK(dp, 4);
+ register int errnum;
- errno = ntohl(dp[0]);
+ TCHECK(dp[0]);
+ errnum = ntohl(dp[0]);
if (er)
- *er = errno;
- if (errno != 0 && !qflag) {
- char *errmsg;
-
- errmsg = strerr(errno);
- if (errmsg)
- printf(" ERROR: '%s'", errmsg);
- else
- printf(" ERROR: %d", errno);
+ *er = errnum;
+ if (errnum != 0) {
+ if (!qflag)
+ printf(" ERROR: %s", pcap_strerror(errnum));
+ nfserr = 1;
+ return (NULL);
}
return (dp + 1);
+trunc:
+ return (NULL);
}
static const u_int32_t *
@@ -887,7 +881,7 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
fap = (const struct nfs_fattr *)dp;
if (verbose) {
- printf(" %s %o ids %d/%d",
+ 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));
@@ -899,14 +893,14 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
}
else {
T2CHECK(dp, 6 * sizeof(*dp));
- printf(" sz %d ", ntohl(fap->fa2_size));
+ printf(" sz %ld ", ntohl(fap->fa2_size));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
T2CHECK(dp, 64);
- printf("nlink %d rdev %d/%d ",
+ printf("nlink %ld rdev %ld/%ld ",
ntohl(fap->fa_nlink),
ntohl(fap->fa3_rdev.specdata1),
ntohl(fap->fa3_rdev.specdata2));
@@ -914,27 +908,27 @@ parsefattr(const u_int32_t *dp, int verbose, int v3)
print_int64((u_int32_t *)&fap->fa2_fsid, HEX);
printf(" nodeid ");
print_int64((u_int32_t *)&fap->fa2_fileid, HEX);
- printf(" a/m/ctime %u.%06u ",
+ printf(" a/m/ctime %lu.%06lu ",
ntohl(fap->fa3_atime.nfsv3_sec),
ntohl(fap->fa3_atime.nfsv3_nsec));
- printf("%u.%06u ",
+ printf("%lu.%06lu ",
ntohl(fap->fa3_mtime.nfsv3_sec),
ntohl(fap->fa3_mtime.nfsv3_nsec));
- printf("%u.%06u ",
+ printf("%lu.%06lu ",
ntohl(fap->fa3_ctime.nfsv3_sec),
ntohl(fap->fa3_ctime.nfsv3_nsec));
} else {
T2CHECK(dp, 48);
- printf("nlink %d rdev %x fsid %x nodeid %x a/m/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("%u.%06u ",
+ printf("%lu.%06lu ",
ntohl(fap->fa2_atime.nfsv2_sec),
ntohl(fap->fa2_atime.nfsv2_usec));
- printf("%u.%06u ",
+ printf("%lu.%06lu ",
ntohl(fap->fa2_mtime.nfsv2_sec),
ntohl(fap->fa2_mtime.nfsv2_usec));
- printf("%u.%06u ",
+ printf("%lu.%06lu ",
ntohl(fap->fa2_ctime.nfsv2_sec),
ntohl(fap->fa2_ctime.nfsv2_usec));
}
@@ -952,7 +946,7 @@ parseattrstat(const u_int32_t *dp, int verbose, int v3)
if (dp == NULL || er)
return (0);
- return ((long)parsefattr(dp, verbose, v3));
+ return (parsefattr(dp, verbose, v3) != NULL);
}
static int
@@ -960,7 +954,8 @@ parsediropres(const u_int32_t *dp)
{
int er;
- if (!(dp = parsestatus(dp, &er)) || er)
+ dp = parsestatus(dp, &er);
+ if (dp == NULL || er)
return (0);
dp = parsefh(dp, 0);
@@ -978,8 +973,10 @@ parselinkres(const u_int32_t *dp, int v3)
dp = parsestatus(dp, &er);
if (dp == NULL || er)
return(0);
- if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
+
+ if (v3 && ((dp = parse_post_op_attr(dp, vflag)) != NULL))
return (0);
+
putchar(' ');
return (parsefn(dp) != NULL);
}
@@ -1000,7 +997,7 @@ parsestatfs(const u_int32_t *dp, int v3)
if (v3) {
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
}
@@ -1025,7 +1022,7 @@ parsestatfs(const u_int32_t *dp, int v3)
printf(" invar %lu", ntohl(sfsp->sf_invarsec));
}
} else {
- printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
+ 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));
@@ -1040,13 +1037,13 @@ parserddires(const u_int32_t *dp)
int er;
dp = parsestatus(dp, &er);
- if (dp == 0 || er)
+ if (dp == NULL || er)
return (0);
if (qflag)
return (1);
T2CHECK(dp, 12);
- printf(" offset %x size %d ", ntohl(dp[0]), ntohl(dp[1]));
+ printf(" offset %lx size %ld ", ntohl(dp[0]), ntohl(dp[1]));
if (dp[2] != 0)
printf("eof");
@@ -1058,7 +1055,7 @@ parse_wcc_attr(const u_int32_t *dp)
{
printf(" sz ");
print_int64(dp, UNSIGNED);
- printf(" mtime %u.%06u ctime %u.%06u", ntohl(dp[2]), ntohl(dp[3]),
+ printf(" mtime %lu.%06lu ctime %lu.%06lu", ntohl(dp[2]), ntohl(dp[3]),
ntohl(dp[4]), ntohl(dp[5]));
return (dp + 6);
}
@@ -1103,8 +1100,8 @@ parse_wcc_data(const u_int32_t *dp, int verbose)
{
if (verbose > 1)
printf(" PRE:");
- if (!(dp = parse_pre_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_pre_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (verbose)
printf(" POST:");
@@ -1116,8 +1113,8 @@ parsecreateopres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
- return (0);
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
if (er)
dp = parse_wcc_data(dp, verbose);
else {
@@ -1125,11 +1122,11 @@ parsecreateopres(const u_int32_t *dp, int verbose)
if (!ntohl(dp[0]))
return (dp + 1);
dp++;
- if (!(dp = parsefh(dp, 1)))
- return (0);
+ if ((dp = parsefh(dp, 1)) == NULL)
+ return (NULL);
if (verbose) {
- if (!(dp = parse_post_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (vflag > 1) {
printf("dir attr:");
dp = parse_wcc_data(dp, verbose);
@@ -1144,9 +1141,9 @@ parsewccres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
- return parse_wcc_data(dp, verbose) != 0;
+ return parse_wcc_data(dp, verbose) != NULL;
}
static const u_int32_t *
@@ -1154,17 +1151,17 @@ parsev3rddirres(const u_int32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
- return (0);
+ if ((dp = parsestatus(dp, &er)) == NULL)
+ return (NULL);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, verbose)))
- return (0);
+ if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
+ return (NULL);
if (er)
return dp;
if (vflag) {
T2CHECK(dp, 8);
- printf(" verf %08lx%08lx", dp[0], dp[1]);
+ printf(" verf %08x%08x", dp[0], dp[1]);
dp += 2;
}
return dp;
@@ -1176,11 +1173,11 @@ parsefsinfo(const u_int32_t *dp)
struct nfsv3_fsinfo *sfp;
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
if (er)
return (1);
@@ -1196,7 +1193,7 @@ parsefsinfo(const u_int32_t *dp)
printf(" rtmult %lu wtmult %lu maxfsz ",
ntohl(sfp->fs_rtmult), ntohl(sfp->fs_wtmult));
print_int64((u_int32_t *)&sfp->fs_maxfilesize, UNSIGNED);
- printf(" delta %u.%06u ", ntohl(sfp->fs_timedelta.nfsv3_sec),
+ printf(" delta %lu.%06lu ", ntohl(sfp->fs_timedelta.nfsv3_sec),
ntohl(sfp->fs_timedelta.nfsv3_nsec));
}
return (1);
@@ -1208,11 +1205,11 @@ parsepathconf(const u_int32_t *dp)
int er;
struct nfsv3_pathconf *spp;
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
return (0);
if (vflag)
printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
return (0);
if (er)
return (1);
@@ -1236,7 +1233,7 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
{
register const u_int32_t *dp;
register int v3;
- register const u_char *ep = snapend;
+
int er;
v3 = (vers == NFS_VER3);
@@ -1257,16 +1254,16 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_GETATTR:
printf(" getattr");
dp = parserep(rp, length);
- if (dp != 0 && parseattrstat(dp, !qflag, v3) != 0)
+ if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0)
return;
break;
case NFSPROC_SETATTR:
printf(" setattr");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
return;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
if (parseattrstat(dp, !qflag, 0) != 0)
@@ -1276,10 +1273,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_LOOKUP:
printf(" lookup");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (er) {
if (vflag > 1) {
@@ -1287,15 +1284,15 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
dp = parse_post_op_attr(dp, vflag);
}
} else {
- if (!(dp = parsefh(dp, v3)))
+ if ((dp = parsefh(dp, v3)) == NULL)
break;
- if ((dp = parse_post_op_attr(dp, vflag)) &&
- vflag > 1) {
+ if (((dp = parse_post_op_attr(dp, vflag)) != NULL) &&
+ (vflag > 1)) {
printf(" post dattr:");
dp = parse_post_op_attr(dp, vflag);
}
}
- if (dp)
+ if (dp != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1306,31 +1303,31 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_ACCESS:
printf(" access");
dp = parserep(rp, length);
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag)
printf(" attr:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
if (!er)
- printf(" c %04x", ntohl(dp[0]));
+ printf(" c %04lx", ntohl(dp[0]));
return;
case NFSPROC_READLINK:
printf(" readlink");
dp = parserep(rp, length);
- if (dp != 0 && parselinkres(dp, v3) != 0)
+ if (dp != NULL && parselinkres(dp, v3) != 0)
return;
break;
case NFSPROC_READ:
printf(" read");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
if (er)
return;
@@ -1349,12 +1346,12 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_WRITE:
printf(" write");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
if (er)
return;
@@ -1376,10 +1373,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_CREATE:
printf(" create");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1389,10 +1386,10 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_MKDIR:
printf(" mkdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
if (parsediropres(dp) != 0)
@@ -1402,101 +1399,101 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_SYMLINK:
printf(" symlink");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_MKNOD:
printf(" mknod");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(dp, vflag) != NULL)
return;
break;
case NFSPROC_REMOVE:
printf(" remove");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_RMDIR:
printf(" rmdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(dp, vflag) != 0)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_RENAME:
printf(" rename");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag) {
printf(" from:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
printf(" to:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
}
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_LINK:
printf(" link");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if ((dp = parsestatus(dp, &er)) == NULL)
break;
if (vflag) {
printf(" file POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
break;
printf(" dir:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if ((dp = parse_wcc_data(dp, vflag)) == NULL)
break;
return;
}
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(dp, &er) != NULL)
return;
}
break;
case NFSPROC_READDIR:
printf(" readdir");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
if (v3) {
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(dp, vflag) != NULL)
return;
} else {
if (parserddires(dp) != 0)
@@ -1506,45 +1503,46 @@ interp_reply(const struct rpc_msg *rp, u_int32_t proc, u_int32_t vers, int lengt
case NFSPROC_READDIRPLUS:
printf(" readdirplus");
- if (!(dp = parserep(rp, length)))
+ if ((dp = parserep(rp, length)) == NULL)
break;
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(dp, vflag) != NULL)
return;
break;
case NFSPROC_FSSTAT:
printf(" fsstat");
dp = parserep(rp, length);
- if (dp != 0 && parsestatfs(dp, v3) != 0)
+ if (dp != NULL && parsestatfs(dp, v3) != NULL)
return;
break;
case NFSPROC_FSINFO:
printf(" fsinfo");
dp = parserep(rp, length);
- if (dp != 0 && parsefsinfo(dp) != 0)
+ if (dp != NULL && parsefsinfo(dp) != NULL)
return;
break;
case NFSPROC_PATHCONF:
printf(" pathconf");
dp = parserep(rp, length);
- if (dp != 0 && parsepathconf(dp) != 0)
+ if (dp != NULL && parsepathconf(dp) != 0)
return;
break;
case NFSPROC_COMMIT:
printf(" commit");
dp = parserep(rp, length);
- if (dp != 0 && parsewccres(dp, vflag) != 0)
+ if (dp != NULL && parsewccres(dp, vflag) != 0)
return;
break;
default:
- printf(" proc-%lu", proc);
+ printf(" proc-%u", proc);
return;
}
trunc:
- fputs(" [|nfs]", stdout);
+ if (!nfserr)
+ fputs(" [|nfs]", stdout);
}
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index eedca7a..926691c 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -24,8 +24,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-ntp.c,v 1.23 96/07/23 14:17:26 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-ntp.c,v 1.25 96/11/05 13:30:37 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -71,7 +71,7 @@ ntp_print(register const u_char *cp, u_int length)
TCHECK(bp->status);
- version = (bp->status & VERSIONMASK) >> 3;
+ version = (int)(bp->status & VERSIONMASK) >> 3;
printf(" v%d", version);
leapind = bp->status & LEAPMASK;
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index eaa8a26..cf845d4 100644
--- a/contrib/tcpdump/print-null.c
+++ b/contrib/tcpdump/print-null.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-null.c,v 1.19 96/07/14 19:39:02 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-null.c,v 1.22 96/12/10 23:18:58 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -46,15 +46,19 @@ struct rtentry;
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
+#include <pcap.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
#include "addrtoname.h"
-#include "pcap.h"
+#include "interface.h"
#define NULL_HDRLEN 4
+#ifndef AF_NS
+#define AF_NS 6 /* XEROX NS protocols */
+#endif
+
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 50c3c2a..f615810 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-ppp.c,v 1.22 96/07/14 19:39:03 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-ppp.c,v 1.24 96/12/10 23:23:12 leres Exp $ (LBL)";
#endif
#ifdef PPP
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index 97a283b..0c6cd8d 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#)$Header: print-sl.c,v 1.38 96/07/15 18:23:25 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-sl.c,v 1.41 96/12/10 23:19:42 leres Exp $ (LBL)";
#endif
#ifdef HAVE_NET_SLIP_H
@@ -139,7 +139,7 @@ sliplink_print(register const u_char *p, register const struct ip *ip,
case TYPE_UNCOMPRESSED_TCP:
/*
- * The connection id is stored in the IP protcol field.
+ * The connection id is stored in the IP protocol field.
* Get it from the link layer since sl_uncompress_tcp()
* has restored the IP header copy to IPPROTO_TCP.
*/
@@ -243,6 +243,7 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
#include <sys/types.h>
#include <sys/time.h>
+#include <pcap.h>
#include <stdio.h>
#include "interface.h"
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 281194a..01c485b 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-sunrpc.c,v 1.24 96/07/23 14:17:27 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-sunrpc.c,v 1.25 96/09/26 23:36:49 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index 7ada5b2..a0914eb 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -20,8 +20,8 @@
*/
#ifndef lint
-static char rcsid[] =
- "@(#) $Header: print-udp.c,v 1.55 96/07/23 14:17:28 leres Exp $ (LBL)";
+static const char rcsid[] =
+ "@(#) $Header: print-udp.c,v 1.58 96/12/10 23:22:07 leres Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -53,7 +53,7 @@ static char rcsid[] =
struct rtcphdr {
u_short rh_flags; /* T:2 P:1 CNT:5 PT:8 */
- u_short rh_len; /* length of message (in bytes) */
+ u_short rh_len; /* length of message (in words) */
u_int rh_ssrc; /* synchronization src id */
};
@@ -77,27 +77,28 @@ struct rtcp_sr {
* Time stamps are middle 32-bits of ntp timestamp.
*/
struct rtcp_rr {
- u_int rr_srcid; /* sender being reported */
- u_int rr_nr; /* no. packets received */
- u_int rr_np; /* no. packets predicted */
+ u_int rr_srcid; /* sender being reported */
+ u_int rr_nl; /* no. packets lost */
+ u_int rr_ls; /* extended last seq number received */
u_int rr_dv; /* jitter (delay variance) */
u_int rr_lsr; /* orig. ts from last rr from this src */
u_int rr_dlsr; /* time from recpt of last rr to xmit time */
};
/*XXX*/
-#define RTCP_PT_SR 0
-#define RTCP_PT_RR 1
-#define RTCP_PT_SDES 2
+#define RTCP_PT_SR 200
+#define RTCP_PT_RR 201
+#define RTCP_PT_SDES 202
#define RTCP_SDES_CNAME 1
#define RTCP_SDES_NAME 2
#define RTCP_SDES_EMAIL 3
#define RTCP_SDES_PHONE 4
#define RTCP_SDES_LOC 5
#define RTCP_SDES_TOOL 6
-#define RTCP_SDES_TXT 7
-#define RTCP_PT_BYE 3
-#define RTCP_PT_APP 4
+#define RTCP_SDES_NOTE 7
+#define RTCP_SDES_PRIV 8
+#define RTCP_PT_BYE 203
+#define RTCP_PT_APP 204
static void
vat_print(const void *hdr, u_int len, register const struct udphdr *up)
@@ -130,24 +131,26 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
{
/* rtp v1 or v2 */
u_int *ip = (u_int *)hdr;
- u_int hasopt, contype, hasmarker;
+ u_int hasopt, hasext, contype, hasmarker;
u_int i0 = ntohl(((u_int *)hdr)[0]);
u_int i1 = ntohl(((u_int *)hdr)[1]);
u_int dlen = ntohs(up->uh_ulen) - sizeof(*up) - 8;
- const char* ptype;
+ const char * ptype;
ip += 2;
len >>= 2;
len -= 2;
+ hasopt = 0;
+ hasext = 0;
if ((i0 >> 30) == 1) {
/* rtp v1 */
hasopt = i0 & 0x800000;
contype = (i0 >> 16) & 0x3f;
hasmarker = i0 & 0x400000;
ptype = "rtpv1";
- } else { /*XXX*/
+ } else {
/* rtp v2 */
- hasopt = i0 & 0x20000000;
+ hasext = i0 & 0x10000000;
contype = (i0 >> 16) & 0x7f;
hasmarker = i0 & 0x800000;
dlen -= 4;
@@ -155,14 +158,16 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
ip += 1;
len -= 1;
}
- printf(" udp/%s %d c%d %s%s %d",
+ printf(" udp/%s %d c%d %s%s %d %u",
ptype,
dlen,
contype,
- hasopt? "+" : "",
+ (hasopt || hasext)? "+" : "",
hasmarker? "*" : "",
- i0 & 0xffff);
+ i0 & 0xffff,
+ i1);
if (vflag) {
+ printf(" %u", i1);
if (hasopt) {
u_int i2, optlen;
do {
@@ -173,50 +178,79 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
return;
}
ip += optlen;
+ len -= optlen;
} while ((int)i2 >= 0);
}
- if (contype == 0x1f)
+ if (hasext) {
+ u_int i2, extlen;
+ i2 = ip[0];
+ extlen = (i2 & 0xffff) + 1;
+ if (extlen > len) {
+ printf(" !ext");
+ return;
+ }
+ ip += extlen;
+ }
+ if (contype == 0x1f) /*XXX H.261 */
printf(" 0x%04x", ip[0] >> 16);
- printf(" %u", i1);
}
}
-static const u_char*
-rtcp_print(const u_char *hdr)
+static const u_char *
+rtcp_print(const u_char *hdr, const u_char *ep)
{
/* rtp v2 control (rtcp) */
- struct rtcp_rr* rr = 0;
- struct rtcp_sr* sr;
- struct rtcphdr* rh = (struct rtcphdr*)hdr;
- u_int len = (ntohs(rh->rh_len) + 1) * 4;
- u_short flags = ntohs(rh->rh_flags);
- int cnt = (flags >> 8) & 0x1f;
- double ts, dts, jitter;
- if (vflag)
- printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ struct rtcp_rr *rr = 0;
+ struct rtcp_sr *sr;
+ struct rtcphdr *rh = (struct rtcphdr *)hdr;
+ u_int len;
+ u_short flags;
+ int cnt;
+ double ts, dts;
+ if ((u_char *)(rh + 1) > ep) {
+ printf(" [|rtcp]");
+ return (ep);
+ }
+ len = (ntohs(rh->rh_len) + 1) * 4;
+ flags = ntohs(rh->rh_flags);
+ cnt = (flags >> 8) & 0x1f;
switch (flags & 0xff) {
case RTCP_PT_SR:
- sr = (struct rtcp_sr*)(rh + 1);
+ sr = (struct rtcp_sr *)(rh + 1);
printf(" sr");
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
printf(" [%d]", len);
- ts = (double)((u_int32_t)ntohl(sr->sr_ts)) / 65536.;
- printf(" @%.2f %up %ub", ts, (u_int32_t)ntohl(sr->sr_np),
- (u_int32_t)ntohl(sr->sr_nb));
- rr = (struct rtcp_rr*)(sr + 1);
+ if (vflag)
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
+ if ((u_char *)(sr + 1) > ep) {
+ printf(" [|rtcp]");
+ return (ep);
+ }
+ ts = (double)((u_int32_t)ntohl(sr->sr_ntp.upper)) +
+ ((double)((u_int32_t)ntohl(sr->sr_ntp.lower)) /
+ 4294967296.0);
+ printf(" @%.2f %u %up %ub", ts, (u_int32_t)ntohl(sr->sr_ts),
+ (u_int32_t)ntohl(sr->sr_np), (u_int32_t)ntohl(sr->sr_nb));
+ rr = (struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
printf(" rr");
if (len != cnt * sizeof(*rr) + sizeof(*rh))
printf(" [%d]", len);
- rr = (struct rtcp_rr*)(rh + 1);
+ rr = (struct rtcp_rr *)(rh + 1);
+ if (vflag)
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
break;
case RTCP_PT_SDES:
printf(" sdes %d", len);
+ if (vflag)
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
case RTCP_PT_BYE:
printf(" bye %d", len);
+ if (vflag)
+ printf(" %u", (u_int32_t)ntohl(rh->rh_ssrc));
cnt = 0;
break;
default:
@@ -227,19 +261,18 @@ rtcp_print(const u_char *hdr)
if (cnt > 1)
printf(" c%d", cnt);
while (--cnt >= 0) {
- if ((u_char*)(rr + 1) > snapend) {
+ if ((u_char *)(rr + 1) > ep) {
printf(" [|rtcp]");
- return (snapend);
+ return (ep);
}
if (vflag)
printf(" %u", (u_int32_t)ntohl(rr->rr_srcid));
ts = (double)((u_int32_t)ntohl(rr->rr_lsr)) / 65536.;
dts = (double)((u_int32_t)ntohl(rr->rr_dlsr)) / 65536.;
- jitter = (double)((u_int32_t)ntohl(rr->rr_dv)) / 65536.;
- printf(" %ur %ue %.2fj @%.2f+%.2f",
- (u_int32_t)ntohl(rr->rr_nr),
- (u_int32_t)ntohl(rr->rr_np),
- jitter, ts, dts);
+ printf(" %ul %us %uj @%.2f+%.2f",
+ (u_int32_t)ntohl(rr->rr_nl) & 0x00ffffff,
+ (u_int32_t)ntohl(rr->rr_ls),
+ (u_int32_t)ntohl(rr->rr_dv), ts, dts);
}
return (hdr + len);
}
@@ -260,8 +293,11 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
register const struct udphdr *up;
register const struct ip *ip;
register const u_char *cp;
+ register const u_char *ep = bp + length;
u_short sport, dport, ulen;
+ if (ep > snapend)
+ ep = snapend;
up = (struct udphdr *)bp;
ip = (struct ip *)bp2;
cp = (u_char *)(up + 1);
@@ -328,43 +364,44 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
udpport_string(sport),
ipaddr_string(&ip->ip_dst),
udpport_string(dport));
- while (cp < snapend)
- cp = rtcp_print(cp);
+ while (cp < ep)
+ cp = rtcp_print(cp, ep);
break;
}
return;
}
- if (! qflag) {
+ if (!qflag) {
register struct rpc_msg *rp;
enum msg_type direction;
rp = (struct rpc_msg *)(up + 1);
- TCHECK(rp->rm_direction);
- direction = (enum msg_type)ntohl(rp->rm_direction);
- if (dport == NFS_PORT && direction == CALL) {
- nfsreq_print((u_char *)rp, length, (u_char *)ip);
- return;
- }
- else if (sport == NFS_PORT && direction == REPLY) {
- nfsreply_print((u_char *)rp, length, (u_char *)ip);
- return;
- }
+ if (TTEST(rp->rm_direction)) {
+ direction = (enum msg_type)ntohl(rp->rm_direction);
+ if (dport == NFS_PORT && direction == CALL) {
+ nfsreq_print((u_char *)rp, length,
+ (u_char *)ip);
+ return;
+ }
+ if (sport == NFS_PORT && direction == REPLY) {
+ nfsreply_print((u_char *)rp, length,
+ (u_char *)ip);
+ return;
+ }
#ifdef notdef
- else if (dport == SUNRPC_PORT && direction == CALL) {
- sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
- return;
- }
-#endif
- else {
- TCHECK2(cp[0], 1);
- if (((struct LAP *)cp)->type == lapDDP &&
- (atalk_port(sport) || atalk_port(dport))) {
- if (vflag)
- fputs("kip ", stdout);
- atalk_print(cp, length);
+ if (dport == SUNRPC_PORT && direction == CALL) {
+ sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
return;
}
+#endif
+ }
+ if (TTEST(((struct LAP *)cp)->type) &&
+ ((struct LAP *)cp)->type == lapDDP &&
+ (atalk_port(sport) || atalk_port(dport))) {
+ if (vflag)
+ fputs("kip ", stdout);
+ atalk_print(cp, length);
+ return;
}
}
(void)printf("%s.%s > %s.%s:",
@@ -401,7 +438,4 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
#undef ISPORT
} else
(void)printf(" udp %u", (u_int32_t)(ulen - sizeof(*up)));
- return;
-trunc:
- fputs("[|udp]", stdout);
}
diff --git a/contrib/tcpdump/tcpdump.1 b/contrib/tcpdump/tcpdump.1
index cbe8839..6b07f45 100644
--- a/contrib/tcpdump/tcpdump.1
+++ b/contrib/tcpdump/tcpdump.1
@@ -1,4 +1,4 @@
-.\" @(#) $Header: tcpdump.1,v 1.61 96/07/14 19:45:00 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
.\" The Regents of the University of California. All rights reserved.
@@ -20,7 +20,7 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "14 July 1996"
+.TH TCPDUMP 1 "29 November 1996"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
@@ -67,6 +67,7 @@ tcpdump \- dump traffic on a network
.LP
\fITcpdump\fP prints out the headers of packets on a network interface
that match the boolean \fIexpression\fP.
+.LP
.B Under SunOS with nit or bpf:
To run
.I tcpdump
@@ -81,9 +82,10 @@ You must have read access to the network pseudo device, e.g.
You must be root or it must be installed setuid to root.
.B Under IRIX with snoop:
You must be root or it must be installed setuid to root.
-.B Under Ultrix:
-Once the super-user has enabled
-promiscuous-mode operation using
+.B Under Linux:
+You must be root or it must be installed setuid to root.
+.B Under Ultrix and Digital UNIX:
+Once the super-user has enabled promiscuous-mode operation using
.IR pfconfig (8),
any user may run
.BR tcpdump .
@@ -825,6 +827,16 @@ socket buffer since csam's receive window has gotten 19 bytes smaller.
Csam also sends one byte of data to rtsg in this packet.
On the 8th and 9th lines,
csam sends two bytes of urgent, pushed data to rtsg.
+.LP
+If the snapshot was small enough that \fBtcpdump\fP didn't capture
+the full TCP header, it interprets as much of the header as it can
+and then reports ``[|\fItcp\fP]'' to indicate the remainder could not
+be interpreted. If the header contains a bogus option (one with a length
+that's either too small or beyond the end of the header), tcpdump reports
+it as ``[\fIbad opt\fP]'' and does not interpret any further options (since
+it's impossible to tell where they start). If the header length indicates
+options are present but the IP datagram length is not long enough for the
+options to actually be there, tcpdump reports it as ``[\fIbad hdr length\fP]''.
.HD
.B
UDP Packets
@@ -1177,33 +1189,22 @@ serviced the `new packet' interrupt.
.SH "SEE ALSO"
traffic(1C), nit(4P), bpf(4), pcap(3)
.SH AUTHORS
-Van Jacobson (van@ee.lbl.gov),
-Craig Leres (leres@ee.lbl.gov) and
-Steven McCanne (mccanne@ee.lbl.gov), all of the
-Lawrence Berkeley Laboratory, University of California, Berkeley, CA.
+Van Jacobson,
+Craig Leres and
+Steven McCanne, all of the
+Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
+.LP
+The current version is available via anonymous ftp:
+.LP
+.RS
+.I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
+.RE
.SH BUGS
-Please send bug reports to tcpdump@ee.lbl.gov or libpcap@ee.lbl.gov.
+Please send bug reports to tcpdump@ee.lbl.gov.
.LP
NIT doesn't let you watch your own outbound traffic, BPF will.
We recommend that you use the latter.
.LP
-\fItcpdump\fP for Ultrix requires Ultrix version 4.0 or later; the kernel
-has to have been built with the \fIpacketfilter\fP pseudo-device driver
-(see
-.IR packetfilter (4)).
-In order to watch either your own outbound or inbound traffic,
-you will need to use Ultrix version 4.2 or later, and you will have
-to have used the
-.IR pfconfig (8)
-command to enable ``copyall'' mode.
-.LP
-Under SunOS 4.1, the packet capture code (or Streams NIT) is not what
-you'd call efficient. Don't plan on doing much with your Sun while
-you're monitoring a busy network.
-.LP
-On Sun systems prior to release 3.2, NIT is very buggy.
-If run on an old system, tcpdump may crash the machine.
-.LP
Some attempt should be made to reassemble IP fragments or, at least
to compute the right length for the higher level protocol.
.LP
OpenPOWER on IntegriCloud