diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-10 07:48:01 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-10 07:48:01 +0000 |
commit | 3fb1d3fc24dae7c5506be7d6bae54ecc97348ba0 (patch) | |
tree | dc5119d72c4bd5e50838971ecc04cd7364e3f6aa | |
parent | bb6af93821af2776feaaf29a9b579c504d5686df (diff) |
sync to latest
58 files changed, 1036 insertions, 648 deletions
diff --git a/usr.sbin/tcpdump/CHANGES b/usr.sbin/tcpdump/CHANGES index 959ea0217ce..2d3f4348d17 100644 --- a/usr.sbin/tcpdump/CHANGES +++ b/usr.sbin/tcpdump/CHANGES @@ -1,6 +1,17 @@ -$OpenBSD: CHANGES,v 1.2 1996/03/04 15:58:52 mickey Exp $ -$NetBSD: CHANGES,v 1.2 1995/03/06 19:09:42 mycroft Exp $ -@(#) Header: CHANGES,v 1.6+ 94/06/20 19:34:38 leres Exp $ (LBL) +$OpenBSD: CHANGES,v 1.3 1996/06/10 07:47:07 deraadt Exp $ +$NetBSD: CHANGES,v 1.3 1996/05/20 00:41:00 fvdl Exp $ +@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/CHANGES,v 1.3 1996/06/10 07:47:07 deraadt Exp $ (LBL) + +v3.0.4 Fri Feb 16 13:35:21 PST 1996 + +- New release purely to raise the version number to adjust for the + mistake the linux contingency made. There are other changes between + this and v3.0.2. + +v3.0.3 Sun Oct 1 18:35:00 GMT 1995 + +- Although there never was a 3.0.3 release, the linux boys cleverly + "released" one in late 1995. v3.0.2 Thu Apr 20 21:28:16 PDT 1995 diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index 1fe432f60e6..b0b73aab7f6 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.2 1996/03/04 15:58:53 mickey Exp $ +# $OpenBSD: Makefile,v 1.3 1996/06/10 07:47:08 deraadt Exp $ # $NetBSD: Makefile,v 1.6 1995/03/07 23:18:39 mycroft Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -20,7 +20,6 @@ # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. # -# @(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/Makefile,v 1.2 1996/03/04 15:58:53 mickey Exp $ (LBL) PROG= tcpdump MAN= tcpdump.8 @@ -36,7 +35,7 @@ SRCS= tcpdump.c addrtoname.c \ print-icmp.c print-sl.c print-ppp.c print-rip.c \ print-snmp.c print-ntp.c print-null.c print-egp.c print-ospf.c \ print-fddi.c print-llc.c print-sunrpc.c \ - print-wb.c print-decnet.c print-isoclns.c print-ipx.c print-skip.c \ + print-wb.c print-decnet.c print-isoclns.c print-ipx.c \ util.c bpf_dump.c parsenfsfh.c version.c AWKS = atime.awk packetdat.awk send-ack.awk stime.awk diff --git a/usr.sbin/tcpdump/README b/usr.sbin/tcpdump/README index b3b740dffa1..374272ff879 100644 --- a/usr.sbin/tcpdump/README +++ b/usr.sbin/tcpdump/README @@ -1,8 +1,8 @@ -$OpenBSD: README,v 1.2 1996/03/04 15:58:54 mickey Exp $ -$NetBSD: README,v 1.3 1995/03/07 23:18:35 mycroft Exp $ +$OpenBSD: README,v 1.3 1996/06/10 07:47:09 deraadt Exp $ +$NetBSD: README,v 1.4 1996/05/20 00:41:01 fvdl Exp $ @(#) Header: README,v 1.39 94/06/20 20:15:16 leres Exp (LBL) -TCPDUMP 3.0.2 +TCPDUMP 3.0.4 Lawrence Berkeley Laboratory Network Research Group tcpdump@ee.lbl.gov diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index 5e26d403548..a89659a17ca 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addrtoname.c,v 1.2 1996/03/04 15:58:55 mickey Exp $ */ +/**//* $OpenBSD: addrtoname.c,v 1.3 1996/06/10 07:47:10 deraadt Exp $ */ /* $NetBSD: addrtoname.c,v 1.4 1995/04/24 13:27:39 cgd Exp $ */ /* diff --git a/usr.sbin/tcpdump/addrtoname.h b/usr.sbin/tcpdump/addrtoname.h index 5eeff108a87..d8bfa938380 100644 --- a/usr.sbin/tcpdump/addrtoname.h +++ b/usr.sbin/tcpdump/addrtoname.h @@ -1,4 +1,4 @@ -/* $OpenBSD: addrtoname.h,v 1.2 1996/03/04 15:58:56 mickey Exp $ */ +/**//* $OpenBSD: addrtoname.h,v 1.3 1996/06/10 07:47:11 deraadt Exp $ */ /* $NetBSD: addrtoname.h,v 1.2 1995/03/06 19:09:50 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/appletalk.h b/usr.sbin/tcpdump/appletalk.h index ca92708b5ac..537c0242c41 100644 --- a/usr.sbin/tcpdump/appletalk.h +++ b/usr.sbin/tcpdump/appletalk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: appletalk.h,v 1.2 1996/03/04 15:58:57 mickey Exp $ */ +/**//* $OpenBSD: appletalk.h,v 1.3 1996/06/10 07:47:12 deraadt Exp $ */ /* $NetBSD: appletalk.h,v 1.2 1995/03/06 19:09:51 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/atime.awk b/usr.sbin/tcpdump/atime.awk index 377df1cb99f..0398a25bdff 100644 --- a/usr.sbin/tcpdump/atime.awk +++ b/usr.sbin/tcpdump/atime.awk @@ -1,4 +1,4 @@ -# $OpenBSD: atime.awk,v 1.2 1996/03/04 15:58:58 mickey Exp $ +# $OpenBSD: atime.awk,v 1.3 1996/06/10 07:47:12 deraadt Exp $ # $NetBSD: atime.awk,v 1.2 1995/03/06 19:09:52 mycroft Exp $ $6 ~ /^ack/ && $5 !~ /[SFR]/ { diff --git a/usr.sbin/tcpdump/bootp.h b/usr.sbin/tcpdump/bootp.h index 5ad4fe99287..fcdf35c468f 100644 --- a/usr.sbin/tcpdump/bootp.h +++ b/usr.sbin/tcpdump/bootp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bootp.h,v 1.2 1996/03/04 15:58:59 mickey Exp $ */ +/**//* $OpenBSD: bootp.h,v 1.3 1996/06/10 07:47:13 deraadt Exp $ */ /* $NetBSD: bootp.h,v 1.2 1995/03/06 19:09:54 mycroft Exp $ */ /* @(#) Header: bootp.h,v 1.6 94/01/13 19:06:29 leres Exp (LBL) */ diff --git a/usr.sbin/tcpdump/bpf_dump.c b/usr.sbin/tcpdump/bpf_dump.c index cb5b6a8fde1..133ef496064 100644 --- a/usr.sbin/tcpdump/bpf_dump.c +++ b/usr.sbin/tcpdump/bpf_dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf_dump.c,v 1.2 1996/03/04 15:59:00 mickey Exp $ */ +/**//* $OpenBSD: bpf_dump.c,v 1.3 1996/06/10 07:47:14 deraadt Exp $ */ /* $NetBSD: bpf_dump.c,v 1.2 1995/03/06 19:09:55 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/decnet.h b/usr.sbin/tcpdump/decnet.h index 847a599f841..e8c7dfe5a7a 100644 --- a/usr.sbin/tcpdump/decnet.h +++ b/usr.sbin/tcpdump/decnet.h @@ -1,4 +1,4 @@ -/* $OpenBSD: decnet.h,v 1.2 1996/03/04 15:59:00 mickey Exp $ */ +/**//* $OpenBSD: decnet.h,v 1.3 1996/06/10 07:47:15 deraadt Exp $ */ /* $NetBSD: decnet.h,v 1.2 1995/03/06 19:09:58 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/ethertype.h b/usr.sbin/tcpdump/ethertype.h index 410503e11cc..dbc5aa41f8e 100644 --- a/usr.sbin/tcpdump/ethertype.h +++ b/usr.sbin/tcpdump/ethertype.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ethertype.h,v 1.2 1996/03/04 15:59:01 mickey Exp $ */ +/**//* $OpenBSD: ethertype.h,v 1.3 1996/06/10 07:47:15 deraadt Exp $ */ /* $NetBSD: ethertype.h,v 1.2 1995/03/06 19:10:06 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/extract.h b/usr.sbin/tcpdump/extract.h index ef5ce02d489..c4133e60303 100644 --- a/usr.sbin/tcpdump/extract.h +++ b/usr.sbin/tcpdump/extract.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extract.h,v 1.2 1996/03/04 15:59:02 mickey Exp $ */ +/**//* $OpenBSD: extract.h,v 1.3 1996/06/10 07:47:16 deraadt Exp $ */ /* $NetBSD: extract.h,v 1.2 1995/03/06 19:10:08 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/fddi.h b/usr.sbin/tcpdump/fddi.h index 8c259700a4d..800284661bc 100644 --- a/usr.sbin/tcpdump/fddi.h +++ b/usr.sbin/tcpdump/fddi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fddi.h,v 1.2 1996/03/04 15:59:03 mickey Exp $ */ +/**//* $OpenBSD: fddi.h,v 1.3 1996/06/10 07:47:17 deraadt Exp $ */ /* $NetBSD: fddi.h,v 1.2 1995/03/06 19:10:10 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index ba0d465245e..c9fc63bc85c 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.h,v 1.2 1996/03/04 15:59:04 mickey Exp $ */ +/**//* $OpenBSD: interface.h,v 1.3 1996/06/10 07:47:18 deraadt Exp $ */ /* $NetBSD: interface.h,v 1.2 1995/03/06 19:10:18 mycroft Exp $ */ /* @@ -136,11 +136,6 @@ extern void sunrpcrequest_print(const u_char *, int, const u_char *); extern void tftp_print(const u_char *, int); extern void wb_print(const void *, int); -extern void skip_print(const u_char *, int, const u_char *); -extern void skip_print_old(const u_char *, int, const u_char *); -extern void ah_print(const u_char *, int, const u_char *); -extern void esp_print(const u_char *, int, const u_char *); - #define min(a,b) ((a)>(b)?(b):(a)) #define max(a,b) ((b)>(a)?(b):(a)) diff --git a/usr.sbin/tcpdump/ipx.h b/usr.sbin/tcpdump/ipx.h index 00133d3fe98..1bc24796028 100644 --- a/usr.sbin/tcpdump/ipx.h +++ b/usr.sbin/tcpdump/ipx.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx.h,v 1.2 1996/03/04 15:59:05 mickey Exp $ */ +/**//* $OpenBSD: ipx.h,v 1.3 1996/06/10 07:47:19 deraadt Exp $ */ /* $NetBSD: ipx.h,v 1.2 1995/03/06 19:10:19 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/llc.h b/usr.sbin/tcpdump/llc.h index 0ce8aad8c4c..34f7ac14d36 100644 --- a/usr.sbin/tcpdump/llc.h +++ b/usr.sbin/tcpdump/llc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: llc.h,v 1.2 1996/03/04 15:59:06 mickey Exp $ */ +/**//* $OpenBSD: llc.h,v 1.3 1996/06/10 07:47:20 deraadt Exp $ */ /* $NetBSD: llc.h,v 1.2 1995/03/06 19:10:20 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/makemib b/usr.sbin/tcpdump/makemib index 8203883261e..15d3e463353 100644 --- a/usr.sbin/tcpdump/makemib +++ b/usr.sbin/tcpdump/makemib @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: makemib,v 1.2 1996/03/04 15:59:07 mickey Exp $ +# $OpenBSD: makemib,v 1.3 1996/06/10 07:47:20 deraadt Exp $ # $NetBSD: makemib,v 1.2 1995/03/06 19:10:22 mycroft Exp $ # # Copyright (c) 1990, by John Robert LoVerso. diff --git a/usr.sbin/tcpdump/md.h b/usr.sbin/tcpdump/md.h index b68ba111dd5..ce5ef2f6230 100644 --- a/usr.sbin/tcpdump/md.h +++ b/usr.sbin/tcpdump/md.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md.h,v 1.2 1996/03/04 15:59:08 mickey Exp $ */ +/**//* $OpenBSD: md.h,v 1.3 1996/06/10 07:47:21 deraadt Exp $ */ /* $NetBSD: md.h,v 1.2 1995/03/06 19:10:33 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/mib.h b/usr.sbin/tcpdump/mib.h index 0f42c69e1eb..2017d5f7a6f 100644 --- a/usr.sbin/tcpdump/mib.h +++ b/usr.sbin/tcpdump/mib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.h,v 1.2 1996/03/04 15:59:08 mickey Exp $ */ +/**//* $OpenBSD: mib.h,v 1.3 1996/06/10 07:47:22 deraadt Exp $ */ /* $NetBSD: mib.h,v 1.2 1995/03/06 19:10:34 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/nfsfh.h b/usr.sbin/tcpdump/nfsfh.h index ccbbd575275..a99bba34308 100644 --- a/usr.sbin/tcpdump/nfsfh.h +++ b/usr.sbin/tcpdump/nfsfh.h @@ -1,5 +1,5 @@ -/* $OpenBSD: nfsfh.h,v 1.2 1996/03/04 15:59:10 mickey Exp $ */ -/* $NetBSD: nfsfh.h,v 1.2 1995/03/06 19:10:39 mycroft Exp $ */ +/**//* $OpenBSD: nfsfh.h,v 1.3 1996/06/10 07:47:23 deraadt Exp $ */ +/* $NetBSD: nfsfh.h,v 1.3 1996/05/20 00:41:03 fvdl Exp $ */ /* * Header: nfsfh.h,v 1.3 94/06/12 14:32:58 leres Exp @@ -34,4 +34,4 @@ typedef struct { #define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\ 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/usr.sbin/tcpdump/nfsv2.h b/usr.sbin/tcpdump/nfsv2.h deleted file mode 100644 index 1df599fc1a0..00000000000 --- a/usr.sbin/tcpdump/nfsv2.h +++ /dev/null @@ -1,263 +0,0 @@ -/* $OpenBSD: nfsv2.h,v 1.2 1996/03/04 15:59:11 mickey Exp $ */ -/* $NetBSD: nfsv2.h,v 1.2 1995/03/06 19:10:40 mycroft Exp $ */ - -/* - * Copyright (c) 1994 - * 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[((long)(a))]) -#define nfstov_type(a) ntov_type[fxdr_unsigned(u_long,(a))&0x7] - -/* File types */ -typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 } nfstype; - -/* Structs for common parts of the rpc's */ -struct nfsv2_time { - u_long nfs_sec; - u_long nfs_usec; -}; - -struct nqnfs_time { - u_long nq_sec; - u_long 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 longs or u_longs 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_long fa_type; - u_long fa_mode; - u_long fa_nlink; - u_long fa_uid; - u_long fa_gid; - union { - struct { - u_long nfsfa_size; - u_long nfsfa_blocksize; - u_long nfsfa_rdev; - u_long nfsfa_blocks; - u_long nfsfa_fsid; - u_long nfsfa_fileid; - struct nfsv2_time nfsfa_atime; - struct nfsv2_time nfsfa_mtime; - struct nfsv2_time nfsfa_ctime; - } fa_nfsv2; - struct { - struct { - u_long nqfa_qsize[2]; - } nqfa_size; - u_long nqfa_blocksize; - u_long nqfa_rdev; - struct { - u_long nqfa_qbytes[2]; - } nqfa_bytes; - u_long nqfa_fsid; - u_long nqfa_fileid; - struct nqnfs_time nqfa_atime; - struct nqnfs_time nqfa_mtime; - struct nqnfs_time nqfa_ctime; - u_long nqfa_flags; - u_long nqfa_gen; - struct { - u_long 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_long sa_mode; - u_long sa_uid; - u_long sa_gid; - union { - struct { - u_long nfssa_size; - struct nfsv2_time nfssa_atime; - struct nfsv2_time nfssa_mtime; - } sa_nfsv2; - struct { - struct { - u_long nqsa_qsize[2]; - } nqsa_size; - struct nqnfs_time nqsa_atime; - struct nqnfs_time nqsa_mtime; - u_long nqsa_flags; - u_long 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_long sf_tsize; - u_long sf_bsize; - u_long sf_blocks; - u_long sf_bfree; - u_long sf_bavail; - u_long sf_files; /* Nqnfs only */ - u_long sf_ffree; /* ditto */ -}; diff --git a/usr.sbin/tcpdump/ntp.h b/usr.sbin/tcpdump/ntp.h index a5442c4d9de..b0c7b03d82d 100644 --- a/usr.sbin/tcpdump/ntp.h +++ b/usr.sbin/tcpdump/ntp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.h,v 1.2 1996/03/04 15:59:11 mickey Exp $ */ +/**//* $OpenBSD: ntp.h,v 1.3 1996/06/10 07:47:25 deraadt Exp $ */ /* $NetBSD: ntp.h,v 1.2 1995/03/06 19:10:41 mycroft Exp $ */ /* Header: ntp.h,v 1.2 93/11/12 21:43:36 mccanne Exp */ diff --git a/usr.sbin/tcpdump/os.h b/usr.sbin/tcpdump/os.h index 06ade544d5d..447f34e02a5 100644 --- a/usr.sbin/tcpdump/os.h +++ b/usr.sbin/tcpdump/os.h @@ -1,5 +1,5 @@ -/* $OpenBSD: os.h,v 1.2 1996/03/04 15:59:12 mickey Exp $ */ -/* $NetBSD: os.h,v 1.2 1995/03/06 19:10:56 mycroft Exp $ */ +/**//* $OpenBSD: os.h,v 1.3 1996/06/10 07:47:26 deraadt Exp $ */ +/* $NetBSD: os.h,v 1.3 1996/05/20 00:41:06 fvdl Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994 @@ -61,3 +61,10 @@ #ifndef RIPCMD_POLLENTRY #define RIPCMD_POLLENTRY 6 #endif + +typedef int64_t int64; +typedef u_int64_t u_int64; + +#define INT64_FORMAT "%qd" +#define U_INT64_FORMAT "%qu" +#define HEX_INT64_FORMAT "%qx" diff --git a/usr.sbin/tcpdump/ospf.h b/usr.sbin/tcpdump/ospf.h index 588cb9e4ac5..017b9353e0c 100644 --- a/usr.sbin/tcpdump/ospf.h +++ b/usr.sbin/tcpdump/ospf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf.h,v 1.2 1996/03/04 15:59:13 mickey Exp $ */ +/**//* $OpenBSD: ospf.h,v 1.3 1996/06/10 07:47:26 deraadt Exp $ */ /* $NetBSD: ospf.h,v 1.2 1995/03/06 19:10:57 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/packetdat.awk b/usr.sbin/tcpdump/packetdat.awk index bbbf21f96db..5fc12a1fd81 100644 --- a/usr.sbin/tcpdump/packetdat.awk +++ b/usr.sbin/tcpdump/packetdat.awk @@ -1,4 +1,4 @@ -# $OpenBSD: packetdat.awk,v 1.2 1996/03/04 15:59:15 mickey Exp $ +# $OpenBSD: packetdat.awk,v 1.3 1996/06/10 07:47:27 deraadt Exp $ # $NetBSD: packetdat.awk,v 1.2 1995/03/06 19:10:59 mycroft Exp $ BEGIN { diff --git a/usr.sbin/tcpdump/parsenfsfh.c b/usr.sbin/tcpdump/parsenfsfh.c index bdebc3f5346..46f8d923e92 100644 --- a/usr.sbin/tcpdump/parsenfsfh.c +++ b/usr.sbin/tcpdump/parsenfsfh.c @@ -1,5 +1,5 @@ -/* $OpenBSD: parsenfsfh.c,v 1.2 1996/03/04 15:59:15 mickey Exp $ */ -/* $NetBSD: parsenfsfh.c,v 1.2 1995/03/06 19:11:00 mycroft Exp $ */ +/**//* $OpenBSD: parsenfsfh.c,v 1.3 1996/06/10 07:47:28 deraadt Exp $ */ +/* $NetBSD: parsenfsfh.c,v 1.3 1996/05/20 00:41:07 fvdl Exp $ */ #ifndef lint static char *RCSid = "Header: parsenfsfh.c,v 1.5 94/01/13 19:06:41 leres Exp"; @@ -84,8 +84,9 @@ typedef unsigned int u_int32x; 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 */ diff --git a/usr.sbin/tcpdump/print-arp.c b/usr.sbin/tcpdump/print-arp.c index 96848072596..30cefdfe6af 100644 --- a/usr.sbin/tcpdump/print-arp.c +++ b/usr.sbin/tcpdump/print-arp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-arp.c,v 1.2 1996/03/04 15:59:16 mickey Exp $ */ +/**//* $OpenBSD: print-arp.c,v 1.3 1996/06/10 07:47:29 deraadt Exp $ */ /* $NetBSD: print-arp.c,v 1.2 1995/03/06 19:11:02 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index dd8afd26757..f0db7b5d6d7 100644 --- a/usr.sbin/tcpdump/print-atalk.c +++ b/usr.sbin/tcpdump/print-atalk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-atalk.c,v 1.2 1996/03/04 15:59:17 mickey Exp $ */ +/**//* $OpenBSD: print-atalk.c,v 1.3 1996/06/10 07:47:30 deraadt Exp $ */ /* $NetBSD: print-atalk.c,v 1.3 1995/03/06 19:11:04 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-bootp.c b/usr.sbin/tcpdump/print-bootp.c index 13903965e2a..d60023b9cfa 100644 --- a/usr.sbin/tcpdump/print-bootp.c +++ b/usr.sbin/tcpdump/print-bootp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-bootp.c,v 1.2 1996/03/04 15:59:18 mickey Exp $ */ +/**//* $OpenBSD: print-bootp.c,v 1.3 1996/06/10 07:47:31 deraadt Exp $ */ /* $NetBSD: print-bootp.c,v 1.2 1995/03/06 19:11:05 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-decnet.c b/usr.sbin/tcpdump/print-decnet.c index 018618c7e4d..e223cfd2a31 100644 --- a/usr.sbin/tcpdump/print-decnet.c +++ b/usr.sbin/tcpdump/print-decnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-decnet.c,v 1.2 1996/03/04 15:59:20 mickey Exp $ */ +/**//* $OpenBSD: print-decnet.c,v 1.3 1996/06/10 07:47:32 deraadt Exp $ */ /* $NetBSD: print-decnet.c,v 1.2 1995/03/06 19:11:07 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-domain.c b/usr.sbin/tcpdump/print-domain.c index 589741481d9..7360117cef6 100644 --- a/usr.sbin/tcpdump/print-domain.c +++ b/usr.sbin/tcpdump/print-domain.c @@ -1,4 +1,5 @@ -/* $OpenBSD: print-domain.c,v 1.2 1996/03/04 15:59:21 mickey Exp $ */ +/* $OpenBSD: print-domain.c,v 1.3 1996/06/10 07:47:33 deraadt Exp $ */ + /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. diff --git a/usr.sbin/tcpdump/print-egp.c b/usr.sbin/tcpdump/print-egp.c index 6135ce7d8da..f16202c8b1a 100644 --- a/usr.sbin/tcpdump/print-egp.c +++ b/usr.sbin/tcpdump/print-egp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-egp.c,v 1.2 1996/03/04 15:59:22 mickey Exp $ */ +/**//* $OpenBSD: print-egp.c,v 1.3 1996/06/10 07:47:33 deraadt Exp $ */ /* $NetBSD: print-egp.c,v 1.2 1995/03/06 19:11:09 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c index 4d3c5490524..f5d2bdd0888 100644 --- a/usr.sbin/tcpdump/print-ether.c +++ b/usr.sbin/tcpdump/print-ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ether.c,v 1.2 1996/03/04 15:59:23 mickey Exp $ */ +/**//* $OpenBSD: print-ether.c,v 1.3 1996/06/10 07:47:34 deraadt Exp $ */ /* $NetBSD: print-ether.c,v 1.3 1995/03/06 19:11:10 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-fddi.c b/usr.sbin/tcpdump/print-fddi.c index 9aedc6d2079..eec7efd78d9 100644 --- a/usr.sbin/tcpdump/print-fddi.c +++ b/usr.sbin/tcpdump/print-fddi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-fddi.c,v 1.2 1996/03/04 15:59:24 mickey Exp $ */ +/**//* $OpenBSD: print-fddi.c,v 1.3 1996/06/10 07:47:35 deraadt Exp $ */ /* $NetBSD: print-fddi.c,v 1.2 1995/03/06 19:11:12 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-icmp.c b/usr.sbin/tcpdump/print-icmp.c index 202d1be30bd..ba9456330cb 100644 --- a/usr.sbin/tcpdump/print-icmp.c +++ b/usr.sbin/tcpdump/print-icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-icmp.c,v 1.2 1996/03/04 15:59:25 mickey Exp $ */ +/**//* $OpenBSD: print-icmp.c,v 1.3 1996/06/10 07:47:36 deraadt Exp $ */ /* $NetBSD: print-icmp.c,v 1.3 1995/03/06 19:11:13 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index ddb10cfcb03..b8540e61f14 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print-ip.c,v 1.2 1996/03/04 15:59:26 mickey Exp $ */ -/* $NetBSD: print-ip.c,v 1.4 1995/04/24 13:27:43 cgd Exp $ */ +/**//* $OpenBSD: print-ip.c,v 1.3 1996/06/10 07:47:38 deraadt Exp $ */ +/* $NetBSD: print-ip.c,v 1.4 1995/04/24 13:27:43 cgd Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -22,33 +22,9 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* - * Copyright (c) 1995 Sun Microsystems, Inc. - * All rights reserved. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - - * IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * SUN MICROSYSTEMS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - - * SUN MICROSYSTEMS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SUN - * MICROSYSTEMS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, - * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -*/ - #ifndef lint static char rcsid[] = - "@(#) Header: print-ip.c,v 1.38 94/06/14 20:17:40 leres Exp $ (LBL)"; + "@(#) Header: print-ip.c,v 1.38 94/06/14 20:17:40 leres Exp (LBL)"; #endif #include <sys/param.h> @@ -330,31 +306,6 @@ ip_print(register const u_char *bp, register int length) return; } break; -#ifndef IPPROTO_SKIP_OLD -#define IPPROTO_SKIP_OLD 79 -#endif - case IPPROTO_SKIP_OLD: - skip_print_old(cp, len, (const u_char *) ip); - break; -#ifndef IPPROTO_ESP -#define IPPROTO_ESP 50 -#endif - case IPPROTO_ESP: - esp_print(cp, len, (const u_char *) ip); - break; -#ifndef IPPROTO_AH -#define IPPROTO_AH 51 -#endif - case IPPROTO_AH: - ah_print(cp, len, (const u_char *) ip); - break; - -#ifndef IPPROTO_SKIP -#define IPPROTO_SKIP 57 -#endif - case IPPROTO_SKIP: - skip_print(cp, len, (const u_char *) ip); - break; default: (void)printf("%s > %s:", ipaddr_string(&ip->ip_src), ipaddr_string(&ip->ip_dst)); diff --git a/usr.sbin/tcpdump/print-ipx.c b/usr.sbin/tcpdump/print-ipx.c index e90061692ab..41f0b9d0665 100644 --- a/usr.sbin/tcpdump/print-ipx.c +++ b/usr.sbin/tcpdump/print-ipx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ipx.c,v 1.2 1996/03/04 15:59:27 mickey Exp $ */ +/**//* $OpenBSD: print-ipx.c,v 1.3 1996/06/10 07:47:39 deraadt Exp $ */ /* $NetBSD: print-ipx.c,v 1.2 1995/03/06 19:11:16 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-isoclns.c b/usr.sbin/tcpdump/print-isoclns.c index 7153e7473d5..9f7229f0d81 100644 --- a/usr.sbin/tcpdump/print-isoclns.c +++ b/usr.sbin/tcpdump/print-isoclns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-isoclns.c,v 1.2 1996/03/04 15:59:28 mickey Exp $ */ +/**//* $OpenBSD: print-isoclns.c,v 1.3 1996/06/10 07:47:40 deraadt Exp $ */ /* $NetBSD: print-isoclns.c,v 1.2 1995/03/06 19:11:17 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-llc.c b/usr.sbin/tcpdump/print-llc.c index b5b3150c66b..6913b3c8684 100644 --- a/usr.sbin/tcpdump/print-llc.c +++ b/usr.sbin/tcpdump/print-llc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-llc.c,v 1.2 1996/03/04 15:59:29 mickey Exp $ */ +/**//* $OpenBSD: print-llc.c,v 1.3 1996/06/10 07:47:41 deraadt Exp $ */ /* $NetBSD: print-llc.c,v 1.2 1995/03/06 19:11:19 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-nfs.c b/usr.sbin/tcpdump/print-nfs.c index 419e097f881..91fe5c6778c 100644 --- a/usr.sbin/tcpdump/print-nfs.c +++ b/usr.sbin/tcpdump/print-nfs.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print-nfs.c,v 1.2 1996/03/04 15:59:30 mickey Exp $ */ -/* $NetBSD: print-nfs.c,v 1.4 1995/04/24 13:27:45 cgd Exp $ */ +/**//* $OpenBSD: print-nfs.c,v 1.3 1996/06/10 07:47:42 deraadt Exp $ */ +/* $NetBSD: print-nfs.c,v 1.5 1996/05/20 00:41:09 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -55,13 +55,187 @@ static char rcsid[] = #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 *); +static void nfs_printfh(const u_int32 *, const int); static void xid_map_enter(const struct rpc_msg *, const struct ip *); -static int32 xid_map_find(const struct rpc_msg *, const struct ip *); -static void interp_reply(const struct rpc_msg *, u_int32, int); +static int32 xid_map_find(const struct rpc_msg *, const struct ip *, u_int32 *, + u_int32 *); +static void interp_reply(const struct rpc_msg *, u_int32, u_int32, int); +static const u_int32 *parse_post_op_attr(const u_int32 *, int); + +/* + * Mapping of old NFS Version 2 RPC numbers to generic numbers. + */ +u_int32 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 token 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 + +int print_int64(const u_int32 *dp, int how) +{ + static char buf[32]; +#ifdef INT64_FORMAT + u_int64 res; + + res = ((u_int64)ntohl(dp[0]) << 32) | (u_int64)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 (sign) + printf("%ld", (int)dp[1]); + else + printf("%lu", (unsigned int)dp[1]); +#endif + return 1; +} + +static const u_int32 * +parse_sattr3(const u_int32 *dp, struct nfsv3_sattr *sa3) +{ + register const u_int32 *ep = (u_int32 *)snapend; + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_modeset = ntohl(*dp++))) { + if (dp + 1 > ep) + return (0); + sa3->sa_mode = ntohl(*dp++); + } + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_uidset = ntohl(*dp++))) { + if (dp + 1 > ep) + return (0); + sa3->sa_uid = ntohl(*dp++); + } + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_gidset = ntohl(*dp++))) { + if (dp + 1 > ep) + return (0); + sa3->sa_gid = ntohl(*dp++); + } + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_sizeset = ntohl(*dp++))) { + if (dp + 1 > ep) + return (0); + sa3->sa_size = ntohl(*dp++); + } + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_atimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { + if (dp + 2 > ep) + return (0); + sa3->sa_atime.nfsv3_sec = ntohl(*dp++); + sa3->sa_atime.nfsv3_nsec = ntohl(*dp++); + } + + if (dp + 1 > ep) + return (0); + if ((sa3->sa_mtimetype = ntohl(*dp++)) == NFSV3SATTRTIME_TOCLIENT) { + if (dp + 2 > ep) + return (0); + 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, int length, @@ -69,7 +243,7 @@ nfsreply_print(register const u_char *bp, int length, { register const struct rpc_msg *rp; register const struct ip *ip; - int32 proc; + u_int32 proc, vers; rp = (const struct rpc_msg *)bp; ip = (const struct ip *)bp2; @@ -92,9 +266,8 @@ nfsreply_print(register const u_char *bp, int length, "ok":"ERR", length); - proc = xid_map_find(rp, ip); - if (proc >= 0) - interp_reply(rp, (u_int32)proc, length); + if (xid_map_find(rp, ip, &proc, &vers) >= 0) + interp_reply(rp, proc, vers, length); } /* @@ -132,11 +305,21 @@ parsereq(register const struct rpc_msg *rp, register int length) * If packet was truncated, return 0. */ static const u_int32 * -parsefh(register const u_int32 *dp) +parsefh(register const u_int32 *dp, int v3) { - if (dp + 8 <= (u_int32 *)snapend) { - nfs_printfh(dp); - return (dp + 8); + int len; + + if (v3) { + if (dp + 1 > (u_int32 *)snapend) + return (0); + len = (int)ntohl(*dp) / 4; + dp++; + } else + len = NFSX_V2FH / 4; + + if (dp + len <= (u_int32 *)snapend) { + nfs_printfh(dp, len); + return (dp + len); } return (0); } @@ -176,9 +359,9 @@ parsefn(register const u_int32 *dp) * If packet was truncated (or there was some other error), return 0. */ static const u_int32 * -parsefhn(register const u_int32 *dp) +parsefhn(register const u_int32 *dp, int v3) { - dp = parsefh(dp); + dp = parsefh(dp, v3); if (dp == 0) return (0); putchar(' '); @@ -192,6 +375,9 @@ nfsreq_print(register const u_char *bp, int length, register const u_char *bp2) register const struct ip *ip; register const u_int32 *dp; register const u_char *ep; + nfstype type; + int proc, v3; + struct nfsv3_sattr sa3; #define TCHECK(p, l) if ((u_char *)(p) > ep - l) break @@ -214,101 +400,162 @@ nfsreq_print(register const u_char *bp, int length, register const u_char *bp2) 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)) != 0 && parsefh(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0) return; break; case NFSPROC_SETATTR: printf(" setattr"); - if ((dp = parsereq(rp, length)) != 0 && parsefh(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0) return; break; -#if NFSPROC_ROOT != NFSPROC_NOOP - case NFSPROC_ROOT: - printf(" root"); - break; -#endif case NFSPROC_LOOKUP: printf(" lookup"); - if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) + return; + break; + + case NFSPROC_ACCESS: + printf(" access"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefh(dp, v3)) != 0) { + TCHECK(dp, 4); + printf(" %04x", ntohl(dp[0])); return; + } break; case NFSPROC_READLINK: printf(" readlink"); - if ((dp = parsereq(rp, length)) != 0 && parsefh(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0) return; break; case NFSPROC_READ: printf(" read"); if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefh(dp)) != 0) { - TCHECK(dp, 3 * sizeof(*dp)); - printf(" %lu bytes @ %lu", - ntohl(dp[1]), ntohl(dp[0])); + (dp = parsefh(dp, v3)) != 0) { + if (v3) { + TCHECK(dp, 3 * sizeof(*dp)); + printf(" %lu bytes @ ", ntohl(dp[2])); + print_int64(dp, UNSIGNED); + } else { + TCHECK(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)) != 0 && - (dp = parsefh(dp)) != 0) { - TCHECK(dp, 4 * sizeof(*dp)); - printf(" %lu (%lu) bytes @ %lu (%lu)", - ntohl(dp[3]), ntohl(dp[2]), - ntohl(dp[1]), ntohl(dp[0])); - return; - } - break; -#endif case NFSPROC_WRITE: printf(" write"); if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefh(dp)) != 0) { - TCHECK(dp, 4 * sizeof(*dp)); - printf(" %lu (%lu) bytes @ %lu (%lu)", - ntohl(dp[3]), ntohl(dp[2]), - ntohl(dp[1]), ntohl(dp[0])); + (dp = parsefh(dp, v3)) != 0) { + if (v3) { + TCHECK(dp, 3 * sizeof(*dp)); + printf(" %lu bytes @ ", ntohl(dp[4])); + print_int64(dp, UNSIGNED); + if (vflag) { + dp += 3; + TCHECK(dp, sizeof(*dp)); + printf(" <%s>", + nfsv3_writemodes[ntohl(*dp)]); + } + } else { + TCHECK(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)) != 0 && parsefhn(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) + return; + break; + + case NFSPROC_MKDIR: + printf(" mkdir"); + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) return; break; + case NFSPROC_SYMLINK: + printf(" symlink"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefhn(dp, v3)) != 0) { + fputs(" -> ", stdout); + if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0) + break; + if (parsefn(dp) == 0) + break; + if (v3 && vflag) + print_sattr3(&sa3, vflag); + return; + } + break; + + case NFSPROC_MKNOD: + printf(" mknod"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefhn(dp, v3)) != 0) { + if (dp + 1 > (u_int32 *)snapend) + break; + type = (nfstype)ntohl(*dp++); + if ((dp = parse_sattr3(dp, &sa3)) == 0) + break; + printf(" %s", tok2str(type2str, "unk-ft %d", type)); + if (vflag && (type == NFCHR || type == NFBLK)) { + if (dp + 2 > (u_int32 *)snapend) + break; + printf(" %u/%u", 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)) != 0 && parsefhn(dp) != 0) + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) + return; + break; + + case NFSPROC_RMDIR: + printf(" rmdir"); + if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0) return; break; case NFSPROC_RENAME: printf(" rename"); if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefhn(dp)) != 0) { + (dp = parsefhn(dp, v3)) != 0) { fputs(" ->", stdout); - if (parsefhn(dp) != 0) + if (parsefhn(dp, v3) != 0) return; } break; @@ -316,53 +563,81 @@ nfsreq_print(register const u_char *bp, int length, register const u_char *bp2) case NFSPROC_LINK: printf(" link"); if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefh(dp)) != 0) { + (dp = parsefh(dp, v3)) != 0) { fputs(" ->", stdout); - if (parsefhn(dp) != 0) + if (parsefhn(dp, v3) != 0) return; } break; - case NFSPROC_SYMLINK: - printf(" symlink"); + case NFSPROC_READDIR: + printf(" readdir"); if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefhn(dp)) != 0) { - fputs(" -> ", stdout); - if (parsefn(dp) != 0) - return; + (dp = parsefh(dp, v3)) != 0) { + if (v3) { + TCHECK(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 %08lx%08lx", dp[2], + dp[3]); + } else { + TCHECK(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)) != 0 && parsefhn(dp) != 0) + case NFSPROC_READDIRPLUS: + printf(" readdirplus"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefh(dp, v3)) != 0) { + TCHECK(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 %08lx%08lx", + ntohl(dp[5]), dp[2], dp[3]); return; + } break; - case NFSPROC_RMDIR: - printf(" rmdir"); - if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp) != 0) + case NFSPROC_FSSTAT: + printf(" fsstat"); + if ((dp = parsereq(rp, length)) != 0 && parsefh(dp, v3) != 0) return; break; - case NFSPROC_READDIR: - printf(" readdir"); - if ((dp = parsereq(rp, length)) != 0 && - (dp = parsefh(dp)) != 0) { - TCHECK(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; - } + case NFSPROC_FSINFO: + printf(" fsinfo"); break; - case NFSPROC_STATFS: - printf(" statfs"); - if ((dp = parsereq(rp, length)) != 0 && parsefh(dp) != 0) + case NFSPROC_PATHCONF: + printf(" pathconf"); + break; + + case NFSPROC_COMMIT: + printf(" commit"); + if ((dp = parsereq(rp, length)) != 0 && + (dp = parsefh(dp, v3)) != 0) { + printf(" %lu bytes @ ", ntohl(dp[2])); + print_int64(dp, UNSIGNED); return; + } break; default: @@ -370,7 +645,6 @@ nfsreq_print(register const u_char *bp, int length, register const u_char *bp2) return; } fputs(" [|nfs]", stdout); -#undef TCHECK } /* @@ -383,20 +657,20 @@ nfsreq_print(register const u_char *bp, int length, register const u_char *bp2) * additional hacking on the parser code. */ static void -nfs_printfh(register const u_int32 *dp) +nfs_printfh(register const u_int32 *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) @@ -422,6 +696,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 proc; /* call proc number (host order) */ + u_int32 vers; /* program version (host order) */ }; /* @@ -451,11 +726,13 @@ 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 NFSPROC_xxx or -1 on failure */ -static int32 -xid_map_find(const struct rpc_msg *rp, const struct ip *ip) +static int +xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32 *proc, + u_int32 *vers) { int i; struct xid_map_entry *xmep; @@ -471,7 +748,9 @@ xid_map_find(const struct rpc_msg *rp, const struct ip *ip) xmep->server.s_addr == sip) { /* match */ xid_map_hint = i; - return ((int32)xmep->proc); + *proc = xmep->proc; + *vers = xmep->vers; + return 0; } if (++i >= XIDMAPSIZE) i = 0; @@ -578,123 +857,178 @@ strerr(int errno) } static const u_int32 * -parsestatus(const u_int32 *dp) +parsestatus(const u_int32 *dp, int *er) { int errno; T2CHECK(dp, 4); errno = ntohl(dp[0]); - if (errno != 0) { + if (er) + *er = errno; + if (errno != 0 && !qflag) { char *errmsg; - if (qflag) - return(0); - errmsg = strerr(errno); if (errmsg) - printf(" ERROR: %s", errmsg); + printf(" ERROR: '%s'", errmsg); else printf(" ERROR: %d", errno); - return(0); } return (dp + 1); } -static struct token type2str[] = { - { NFNON, "NON" }, - { NFREG, "REG" }, - { NFDIR, "DIR" }, - { NFBLK, "BLK" }, - { NFCHR, "CHR" }, - { NFLNK, "LNK" }, - { 0, NULL } -}; - static const u_int32 * -parsefattr(const u_int32 *dp, int verbose) +parsefattr(const u_int32 *dp, int verbose, int v3) { - const struct nfsv2_fattr *fap; + const struct nfs_fattr *fap; - T2CHECK(dp, 4); + T2CHECK(dp, 5 * sizeof(*dp)); - fap = (const struct nfsv2_fattr *)dp; - if (verbose) - printf(" %s %o ids %d/%d sz %d ", + fap = (const struct nfs_fattr *)dp; + if (verbose) { + printf(" %s %o ids %d/%d", tok2str(type2str, "unk-ft %d ", ntohl(fap->fa_type)), ntohl(fap->fa_mode), ntohl(fap->fa_uid), - ntohl(fap->fa_gid), ntohl(fap->fa_nfssize)); + ntohl(fap->fa_gid)); + if (v3) { + T2CHECK(dp, 7 * sizeof(*dp)); + printf(" sz "); + print_int64((u_int32 *)&fap->fa3_size, UNSIGNED); + putchar(' '); + } + else { + T2CHECK(dp, 6 * sizeof(*dp)); + printf(" sz %d ", ntohl(fap->fa2_size)); + } + } /* print lots more stuff */ if (verbose > 1) { - printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ", - ntohl(fap->fa_nlink), ntohl(fap->fa_nfsrdev), - ntohl(fap->fa_nfsfsid), ntohl(fap->fa_nfsfileid)); - printf("%d.%06d ", - ntohl(fap->fa_nfsatime.nfs_sec), - ntohl(fap->fa_nfsatime.nfs_usec)); - printf("%d.%06d ", - ntohl(fap->fa_nfsmtime.nfs_sec), - ntohl(fap->fa_nfsmtime.nfs_usec)); - printf("%d.%06d ", - ntohl(fap->fa_nfsctime.nfs_sec), - ntohl(fap->fa_nfsctime.nfs_usec)); + if (v3) { + T2CHECK(dp, 64); + printf("nlink %d rdev %d/%d ", + ntohl(fap->fa_nlink), + ntohl(fap->fa3_rdev.specdata1), + ntohl(fap->fa3_rdev.specdata2)); + printf("fsid "); + print_int64((u_int32 *)&fap->fa2_fsid, HEX); + printf(" nodeid "); + print_int64((u_int32 *)&fap->fa2_fileid, HEX); + printf(" a/m/ctime %u.%06u ", + ntohl(fap->fa3_atime.nfsv3_sec), + ntohl(fap->fa3_atime.nfsv3_nsec)); + printf("%u.%06u ", + ntohl(fap->fa3_mtime.nfsv3_sec), + ntohl(fap->fa3_mtime.nfsv3_nsec)); + printf("%u.%06u ", + 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 ", + ntohl(fap->fa_nlink), ntohl(fap->fa2_rdev), + ntohl(fap->fa2_fsid), ntohl(fap->fa2_fileid)); + printf("%u.%06u ", + ntohl(fap->fa2_atime.nfsv2_sec), + ntohl(fap->fa2_atime.nfsv2_usec)); + printf("%u.%06u ", + ntohl(fap->fa2_mtime.nfsv2_sec), + ntohl(fap->fa2_mtime.nfsv2_usec)); + printf("%u.%06u ", + ntohl(fap->fa2_ctime.nfsv2_sec), + ntohl(fap->fa2_ctime.nfsv2_usec)); + } } - return ((const u_int32 *)&fap[1]); + return ((const u_int32 *)((unsigned char *)dp + + (v3 ? NFSX_V3FATTR : NFSX_V2FATTR))); } static int -parseattrstat(const u_int32 *dp, int verbose) +parseattrstat(const u_int32 *dp, int verbose, int v3) { - dp = parsestatus(dp); - if (dp == NULL) + int er; + + dp = parsestatus(dp, &er); + if (dp == NULL || er) return (0); - return ((long)parsefattr(dp, verbose)); + return ((long)parsefattr(dp, verbose, v3)); } static int parsediropres(const u_int32 *dp) { - dp = parsestatus(dp); - if (dp == NULL) + int er; + + if (!(dp = parsestatus(dp, &er)) || 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 *dp) +parselinkres(const u_int32 *dp, int v3) { - dp = parsestatus(dp); - if (dp == NULL) - return(0); + int er; + dp = parsestatus(dp, &er); + if (dp == NULL || er) + return(0); + if (v3 && !(dp = parse_post_op_attr(dp, vflag))) + return (0); putchar(' '); return (parsefn(dp) != NULL); } static int -parsestatfs(const u_int32 *dp) +parsestatfs(const u_int32 *dp, int v3) { - const struct nfsv2_statfs *sfsp; + const struct nfs_statfs *sfsp; + int er; - dp = parsestatus(dp); - if (dp == NULL) + dp = parsestatus(dp, &er); + if (dp == NULL || (!v3 && er)) return(0); if (qflag) return(1); - T2CHECK(dp, 20); + if (v3) { + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + } - sfsp = (const struct nfsv2_statfs *)dp; - printf(" tsize %d bsize %d blocks %d bfree %d bavail %d", - ntohl(sfsp->sf_tsize), ntohl(sfsp->sf_bsize), - ntohl(sfsp->sf_blocks), ntohl(sfsp->sf_bfree), - ntohl(sfsp->sf_bavail)); + T2CHECK(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS)); + + sfsp = (const struct nfs_statfs *)dp; + + if (v3) { + printf(" tbytes "); + print_int64((u_int32 *)&sfsp->sf_tbytes, UNSIGNED); + printf(" fbytes "); + print_int64((u_int32 *)&sfsp->sf_fbytes, UNSIGNED); + printf(" abytes "); + print_int64((u_int32 *)&sfsp->sf_abytes, UNSIGNED); + if (vflag) { + printf(" tfiles "); + print_int64((u_int32 *)&sfsp->sf_tfiles, UNSIGNED); + printf(" ffiles "); + print_int64((u_int32 *)&sfsp->sf_ffiles, UNSIGNED); + printf(" afiles "); + print_int64((u_int32 *)&sfsp->sf_afiles, UNSIGNED); + printf(" invar %lu", ntohl(sfsp->sf_invarsec)); + } + } else { + printf(" tsize %d bsize %d blocks %d bfree %d bavail %d", + ntohl(sfsp->sf_tsize), ntohl(sfsp->sf_bsize), + ntohl(sfsp->sf_blocks), ntohl(sfsp->sf_bfree), + ntohl(sfsp->sf_bavail)); + } return (1); } @@ -702,8 +1036,10 @@ parsestatfs(const u_int32 *dp) static int parserddires(const u_int32 *dp) { - dp = parsestatus(dp); - if (dp == 0) + int er; + + dp = parsestatus(dp, &er); + if (dp == 0 || er) return (0); if (qflag) return (1); @@ -716,20 +1052,203 @@ parserddires(const u_int32 *dp) return (1); } +static const u_int32 * +parse_wcc_attr(const u_int32 *dp) +{ + printf(" sz "); + print_int64(dp, UNSIGNED); + printf(" mtime %u.%06u ctime %u.%06u", 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 * +parse_pre_op_attr(const u_int32 *dp, int verbose) +{ + T2CHECK(dp, 4); + if (!ntohl(dp[0])) + return (dp + 1); + dp++; + T2CHECK(dp, 24); + if (verbose > 1) { + return parse_wcc_attr(dp); + } else { + /* If not verbose enough, just skip over wcc_attr */ + return (dp + 6); + } +} + +/* + * Post operation attributes are printed if vflag >= 1 + */ +static const u_int32 * +parse_post_op_attr(const u_int32 *dp, int verbose) +{ + T2CHECK(dp, 4); + if (!ntohl(dp[0])) + return (dp + 1); + dp++; + if (verbose) { + return parsefattr(dp, verbose, 1); + } else + return (dp + (NFSX_V3FATTR / sizeof (u_int32))); +} + +static const u_int32 * +parse_wcc_data(const u_int32 *dp, int verbose) +{ + if (verbose > 1) + printf(" PRE:"); + if (!(dp = parse_pre_op_attr(dp, verbose))) + return (0); + + if (verbose) + printf(" POST:"); + return parse_post_op_attr(dp, verbose); +} + +static const u_int32 * +parsecreateopres(const u_int32 *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (er) + dp = parse_wcc_data(dp, verbose); + else { + T2CHECK(dp, 4); + if (!ntohl(dp[0])) + return (dp + 1); + dp++; + if (!(dp = parsefh(dp, 1))) + return (0); + if (verbose) { + if (!(dp = parse_post_op_attr(dp, verbose))) + return (0); + if (vflag > 1) { + printf("dir attr:"); + dp = parse_wcc_data(dp, verbose); + } + } + } + return (dp); +} + +static int +parsewccres(const u_int32 *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + return parse_wcc_data(dp, verbose) != 0; +} + +static const u_int32 * +parsev3rddirres(const u_int32 *dp, int verbose) +{ + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, verbose))) + return (0); + if (er) + return dp; + if (vflag) { + T2CHECK(dp, 8); + printf(" verf %08lx%08lx", dp[0], dp[1]); + dp += 2; + } + return dp; +} + +static int +parsefsinfo(const u_int32 *dp) +{ + struct nfsv3_fsinfo *sfp; + int er; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + if (er) + return (1); + + T2CHECK(dp, sizeof (struct nfsv3_fsinfo)); + + sfp = (struct nfsv3_fsinfo *)dp; + 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 *)&sfp->fs_maxfilesize, UNSIGNED); + printf(" delta %u.%06u ", ntohl(sfp->fs_timedelta.nfsv3_sec), + ntohl(sfp->fs_timedelta.nfsv3_nsec)); + } + return (1); +} + +static int +parsepathconf(const u_int32 *dp) +{ + int er; + struct nfsv3_pathconf *spp; + + if (!(dp = parsestatus(dp, &er))) + return (0); + if (vflag) + printf(" POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + return (0); + if (er) + return (1); + + T2CHECK(dp, sizeof (struct nfsv3_pathconf)); + + spp = (struct nfsv3_pathconf *)dp; + + printf(" linkmax %lu namemax %lu %s %s %s %s", + ntohl(spp->pc_linkmax), + ntohl(spp->pc_namemax), + ntohl(spp->pc_notrunc) ? "notrunc" : "", + ntohl(spp->pc_chownrestricted) ? "chownres" : "", + ntohl(spp->pc_caseinsensitive) ? "igncase" : "", + ntohl(spp->pc_casepreserving) ? "keepcase" : ""); + return (0); +} + static void -interp_reply(const struct rpc_msg *rp, u_int32 proc, int length) +interp_reply(const struct rpc_msg *rp, u_int32 proc, u_int32 vers, int length) { register const u_int32 *dp; + register int v3; + register const u_char *ep = snapend; + 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; @@ -737,115 +1256,286 @@ interp_reply(const struct rpc_msg *rp, u_int32 proc, int length) case NFSPROC_GETATTR: printf(" getattr"); dp = parserep(rp, length); - if (dp != 0 && parseattrstat(dp, !qflag) != 0) + if (dp != 0 && parseattrstat(dp, !qflag, v3) != 0) return; break; case NFSPROC_SETATTR: printf(" setattr"); - dp = parserep(rp, length); - if (dp != 0 && parseattrstat(dp, !qflag) != 0) + if (!(dp = parserep(rp, length))) return; + if (v3) { + if (parsewccres(dp, vflag)) + 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 != 0 && parsediropres(dp) != 0) - return; + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (er) { + if (vflag > 1) { + printf(" post dattr:"); + dp = parse_post_op_attr(dp, vflag); + } + } else { + if (!(dp = parsefh(dp, v3))) + break; + if ((dp = parse_post_op_attr(dp, vflag)) && + vflag > 1) { + printf(" post dattr:"); + dp = parse_post_op_attr(dp, vflag); + } + } + if (dp) + return; + } else { + if (parsediropres(dp) != 0) + return; + } break; + case NFSPROC_ACCESS: + printf(" access"); + dp = parserep(rp, length); + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) + printf(" attr:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + if (!er) + printf(" c %04x", ntohl(dp[0])); + return; + case NFSPROC_READLINK: printf(" readlink"); dp = parserep(rp, length); - if (dp != 0 && parselinkres(dp) != 0) + if (dp != 0 && parselinkres(dp, v3) != 0) return; break; case NFSPROC_READ: printf(" read"); - dp = parserep(rp, length); - if (dp != 0 && parseattrstat(dp, vflag) != 0) + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + if (er) + return; + if (vflag) { + TCHECK(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 != 0 && parseattrstat(dp, vflag) != 0) - return; + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (!(dp = parse_wcc_data(dp, vflag))) + break; + if (er) + return; + if (vflag) { + TCHECK(dp, 4); + printf("%lu bytes", ntohl(dp[0])); + if (vflag > 1) { + TCHECK(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 != 0 && parsediropres(dp) != 0) + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsediropres(dp) != 0) + return; + } + break; + + case NFSPROC_MKDIR: + printf(" mkdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsediropres(dp) != 0) + return; + } + break; + + case NFSPROC_SYMLINK: + printf(" symlink"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsecreateopres(dp, vflag) != 0) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_MKNOD: + printf(" mknod"); + if (!(dp = parserep(rp, length))) + break; + if (parsecreateopres(dp, vflag) != 0) return; break; case NFSPROC_REMOVE: printf(" remove"); - dp = parserep(rp, length); - if (dp != 0 && parsestatus(dp) != 0) - return; + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsewccres(dp, vflag)) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } + break; + + case NFSPROC_RMDIR: + printf(" rmdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsewccres(dp, vflag)) + return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } break; case NFSPROC_RENAME: printf(" rename"); - dp = parserep(rp, length); - if (dp != 0 && parsestatus(dp) != 0) + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) { + printf(" from:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + printf(" to:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + } return; + } else { + if (parsestatus(dp, &er) != 0) + return; + } break; case NFSPROC_LINK: printf(" link"); - dp = parserep(rp, length); - if (dp != 0 && parsestatus(dp) != 0) - return; + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (!(dp = parsestatus(dp, &er))) + break; + if (vflag) { + printf(" file POST:"); + if (!(dp = parse_post_op_attr(dp, vflag))) + break; + printf(" dir:"); + if (!(dp = parse_wcc_data(dp, vflag))) + break; + return; + } + } else { + if (parsestatus(dp, &er) != 0) + return; + } break; - case NFSPROC_SYMLINK: - printf(" symlink"); - dp = parserep(rp, length); - if (dp != 0 && parsestatus(dp) != 0) + case NFSPROC_READDIR: + printf(" readdir"); + if (!(dp = parserep(rp, length))) + break; + if (v3) { + if (parsev3rddirres(dp, vflag)) + return; + } else { + if (parserddires(dp) != 0) + return; + } + break; + + case NFSPROC_READDIRPLUS: + printf(" readdirplus"); + if (!(dp = parserep(rp, length))) + break; + if (parsev3rddirres(dp, vflag)) return; break; - case NFSPROC_MKDIR: - printf(" mkdir"); + case NFSPROC_FSSTAT: + printf(" fsstat"); dp = parserep(rp, length); - if (dp != 0 && parsediropres(dp) != 0) + if (dp != 0 && parsestatfs(dp, v3) != 0) return; break; - case NFSPROC_RMDIR: - printf(" rmdir"); + case NFSPROC_FSINFO: + printf(" fsinfo"); dp = parserep(rp, length); - if (dp != 0 && parsestatus(dp) != 0) + if (dp != 0 && parsefsinfo(dp) != 0) return; break; - case NFSPROC_READDIR: - printf(" readdir"); + case NFSPROC_PATHCONF: + printf(" pathconf"); dp = parserep(rp, length); - if (dp != 0 && parserddires(dp) != 0) + if (dp != 0 && parsepathconf(dp) != 0) return; break; - case NFSPROC_STATFS: - printf(" statfs"); + case NFSPROC_COMMIT: + printf(" commit"); dp = parserep(rp, length); - if (dp != 0 && parsestatfs(dp) != 0) + if (dp != 0 && parsewccres(dp, vflag) != 0) return; break; diff --git a/usr.sbin/tcpdump/print-ntp.c b/usr.sbin/tcpdump/print-ntp.c index 9a7e8267809..047d7b4b651 100644 --- a/usr.sbin/tcpdump/print-ntp.c +++ b/usr.sbin/tcpdump/print-ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ntp.c,v 1.2 1996/03/04 15:59:31 mickey Exp $ */ +/**//* $OpenBSD: print-ntp.c,v 1.3 1996/06/10 07:47:43 deraadt Exp $ */ /* $NetBSD: print-ntp.c,v 1.2 1995/03/06 19:11:22 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-null.c b/usr.sbin/tcpdump/print-null.c index bb56f295d61..6953c156577 100644 --- a/usr.sbin/tcpdump/print-null.c +++ b/usr.sbin/tcpdump/print-null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-null.c,v 1.2 1996/03/04 15:59:32 mickey Exp $ */ +/**//* $OpenBSD: print-null.c,v 1.3 1996/06/10 07:47:44 deraadt Exp $ */ /* $NetBSD: print-null.c,v 1.3 1995/03/06 19:11:24 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ospf.c b/usr.sbin/tcpdump/print-ospf.c index 0e5e0b91d90..1acbf091817 100644 --- a/usr.sbin/tcpdump/print-ospf.c +++ b/usr.sbin/tcpdump/print-ospf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ospf.c,v 1.2 1996/03/04 15:59:33 mickey Exp $ */ +/**//* $OpenBSD: print-ospf.c,v 1.3 1996/06/10 07:47:44 deraadt Exp $ */ /* $NetBSD: print-ospf.c,v 1.3 1995/03/06 19:11:25 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-ppp.c b/usr.sbin/tcpdump/print-ppp.c index e7eb95f6c2e..c33b8eaac44 100644 --- a/usr.sbin/tcpdump/print-ppp.c +++ b/usr.sbin/tcpdump/print-ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ppp.c,v 1.2 1996/03/04 15:59:34 mickey Exp $ */ +/**//* $OpenBSD: print-ppp.c,v 1.3 1996/06/10 07:47:45 deraadt Exp $ */ /* $NetBSD: print-ppp.c,v 1.3 1995/03/06 19:11:27 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-rip.c b/usr.sbin/tcpdump/print-rip.c index f2ef5069c1f..121d946e8f0 100644 --- a/usr.sbin/tcpdump/print-rip.c +++ b/usr.sbin/tcpdump/print-rip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-rip.c,v 1.2 1996/03/04 15:59:35 mickey Exp $ */ +/**//* $OpenBSD: print-rip.c,v 1.3 1996/06/10 07:47:46 deraadt Exp $ */ /* $NetBSD: print-rip.c,v 1.4 1995/06/20 23:38:49 christos Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-sl.c b/usr.sbin/tcpdump/print-sl.c index 400e3f98140..bdc746a9c5f 100644 --- a/usr.sbin/tcpdump/print-sl.c +++ b/usr.sbin/tcpdump/print-sl.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print-sl.c,v 1.2 1996/03/04 15:59:36 mickey Exp $ */ -/* $NetBSD: print-sl.c,v 1.5 1995/03/06 19:11:29 mycroft Exp $ */ +/**//* $OpenBSD: print-sl.c,v 1.3 1996/06/10 07:47:47 deraadt Exp $ */ +/* $NetBSD: print-sl.c,v 1.6 1996/05/20 00:41:11 fvdl Exp $ */ /* * Copyright (c) 1989, 1990, 1991, 1993, 1994 @@ -24,7 +24,7 @@ #ifndef lint static char rcsid[] = - "@(#)Header: print-sl.c,v 1.28 94/06/10 17:01:38 mccanne Exp (LBL)"; + "@(#)Header: print-sl.c,v 1.28+ 94/06/10 17:01:38 mccanne Exp (LBL)"; #endif #ifdef CSLIP @@ -130,11 +130,11 @@ 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 stode in the IP protcol field. * Get it from the link layer since sl_uncompress_tcp() * has restored the IP header copy to IPPROTO_TCP. */ - lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p; + lastconn = ip->ip_p; hlen = ip->ip_hl; hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off; lastlen[dir][lastconn] = length - (hlen << 2); diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c index e414fb1dfd1..4971e429593 100644 --- a/usr.sbin/tcpdump/print-snmp.c +++ b/usr.sbin/tcpdump/print-snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-snmp.c,v 1.2 1996/03/04 15:59:37 mickey Exp $ */ +/**//* $OpenBSD: print-snmp.c,v 1.3 1996/06/10 07:47:48 deraadt Exp $ */ /* $NetBSD: print-snmp.c,v 1.3 1995/03/06 19:11:30 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-sunrpc.c b/usr.sbin/tcpdump/print-sunrpc.c index d0d32a72378..f2c17034b78 100644 --- a/usr.sbin/tcpdump/print-sunrpc.c +++ b/usr.sbin/tcpdump/print-sunrpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-sunrpc.c,v 1.2 1996/03/04 15:59:39 mickey Exp $ */ +/**//* $OpenBSD: print-sunrpc.c,v 1.3 1996/06/10 07:47:49 deraadt Exp $ */ /* $NetBSD: print-sunrpc.c,v 1.3 1995/03/06 19:11:32 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index f658dc35fcf..e8db63a3357 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print-tcp.c,v 1.2 1996/03/04 15:59:39 mickey Exp $ */ -/* $NetBSD: print-tcp.c,v 1.5 1995/03/06 19:11:33 mycroft Exp $ */ +/**//* $OpenBSD: print-tcp.c,v 1.3 1996/06/10 07:47:50 deraadt Exp $ */ +/* $NetBSD: print-tcp.c,v 1.6.4.1 1996/05/26 18:36:15 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -38,6 +38,8 @@ static char rcsid[] = #include <netinet/tcp.h> #include <netinet/tcpip.h> +#include <rpc/rpc.h> + #include <stdio.h> #ifdef __STDC__ #include <stdlib.h> @@ -47,6 +49,8 @@ static char rcsid[] = #include "interface.h" #include "addrtoname.h" +#include "nfs.h" + #ifndef TCPOPT_WSCALE #define TCPOPT_WSCALE 3 /* window scale factor (rfc1072) */ #endif @@ -93,7 +97,7 @@ tcp_print(register const u_char *bp, register int length, register u_char flags; register int hlen; u_short sport, dport, win, urp; - u_int32 seq, ack; + tcp_seq seq, ack; tp = (struct tcphdr *)bp; ip = (struct ip *)bp2; @@ -112,13 +116,36 @@ tcp_print(register const u_char *bp, register int length, ack = ntohl(tp->th_ack); win = ntohs(tp->th_win); urp = ntohs(tp->th_urp); + hlen = tp->th_off * 4; + length -= hlen; + + /* + * If data present and NFS port used, assume NFS. + * Pass offset of data plus 4 bytes for RPC TCP msg length + * to NFS print routines. + */ + if (!qflag) { + if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && + dport == NFS_PORT) { + nfsreq_print((u_char *)tp + hlen + 4, length, + (u_char *)ip); + return; + } + else if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && + sport == NFS_PORT) { + nfsreply_print((u_char *)tp + hlen + 4, length, + (u_char *)ip); + return; + } + } + (void)printf("%s.%s > %s.%s: ", ipaddr_string(&ip->ip_src), tcpport_string(sport), ipaddr_string(&ip->ip_dst), tcpport_string(dport)); if (qflag) { - (void)printf("tcp %d", length - tp->th_off * 4); + (void)printf("tcp %d", length); return; } if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) { @@ -178,10 +205,8 @@ tcp_print(register const u_char *bp, register int length, seq -= th->seq, ack -= th->ack; } } - hlen = tp->th_off * 4; - length -= hlen; if (length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) - (void)printf(" %u:%u(%d)", seq, seq + length, length); + (void)printf(" %lu:%lu(%d)", seq, seq + length, length); if (flags & TH_ACK) (void)printf(" ack %u", ack); diff --git a/usr.sbin/tcpdump/print-tftp.c b/usr.sbin/tcpdump/print-tftp.c index 1c84102e4e2..da9a1f968da 100644 --- a/usr.sbin/tcpdump/print-tftp.c +++ b/usr.sbin/tcpdump/print-tftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-tftp.c,v 1.2 1996/03/04 15:59:40 mickey Exp $ */ +/**//* $OpenBSD: print-tftp.c,v 1.3 1996/06/10 07:47:51 deraadt Exp $ */ /* $NetBSD: print-tftp.c,v 1.2 1995/03/06 19:11:35 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 084c514fab4..4194233cef6 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print-udp.c,v 1.2 1996/03/04 15:59:41 mickey Exp $ */ -/* $NetBSD: print-udp.c,v 1.3 1995/03/06 19:11:36 mycroft Exp $ */ +/**//* $OpenBSD: print-udp.c,v 1.3 1996/06/10 07:47:52 deraadt Exp $ */ +/* $NetBSD: print-udp.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -55,7 +55,7 @@ static char rcsid[] = #include "addrtoname.h" #include "appletalk.h" -#include "nfsv2.h" +#include "nfs.h" #include "bootp.h" extern int packettype; diff --git a/usr.sbin/tcpdump/print-wb.c b/usr.sbin/tcpdump/print-wb.c index 0af30448698..6185802cc3b 100644 --- a/usr.sbin/tcpdump/print-wb.c +++ b/usr.sbin/tcpdump/print-wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-wb.c,v 1.2 1996/03/04 15:59:42 mickey Exp $ */ +/**//* $OpenBSD: print-wb.c,v 1.3 1996/06/10 07:47:53 deraadt Exp $ */ /* $NetBSD: print-wb.c,v 1.2 1995/03/06 19:11:37 mycroft Exp $ */ /* diff --git a/usr.sbin/tcpdump/send-ack.awk b/usr.sbin/tcpdump/send-ack.awk index 8eb234c161b..c59c6ce9ec6 100644 --- a/usr.sbin/tcpdump/send-ack.awk +++ b/usr.sbin/tcpdump/send-ack.awk @@ -1,4 +1,4 @@ -# $OpenBSD: send-ack.awk,v 1.2 1996/03/04 15:59:43 mickey Exp $ +# $OpenBSD: send-ack.awk,v 1.3 1996/06/10 07:47:54 deraadt Exp $ # $NetBSD: send-ack.awk,v 1.2 1995/03/06 19:11:42 mycroft Exp $ BEGIN { diff --git a/usr.sbin/tcpdump/stime.awk b/usr.sbin/tcpdump/stime.awk index 1faa8fff27a..7699e675c20 100644 --- a/usr.sbin/tcpdump/stime.awk +++ b/usr.sbin/tcpdump/stime.awk @@ -1,4 +1,4 @@ -# $OpenBSD: stime.awk,v 1.2 1996/03/04 15:59:44 mickey Exp $ +# $OpenBSD: stime.awk,v 1.3 1996/06/10 07:47:55 deraadt Exp $ # $NetBSD: stime.awk,v 1.2 1995/03/06 19:11:43 mycroft Exp $ $6 !~ /^ack/ && $5 !~ /[SFR]/ { diff --git a/usr.sbin/tcpdump/tcpdump.8 b/usr.sbin/tcpdump/tcpdump.8 index 9e4f20c7bd4..835976a9ddd 100644 --- a/usr.sbin/tcpdump/tcpdump.8 +++ b/usr.sbin/tcpdump/tcpdump.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tcpdump.8,v 1.2 1996/03/04 15:59:45 mickey Exp $ +.\" $OpenBSD: tcpdump.8,v 1.3 1996/06/10 07:47:56 deraadt Exp $ .\" $NetBSD: tcpdump.8,v 1.3 1995/03/06 19:11:46 mycroft Exp $ .\" .\" @(#) Header: tcpdump.1,v 1.45 94/06/20 18:54:27 leres Exp (LBL) diff --git a/usr.sbin/tcpdump/tcpdump.c b/usr.sbin/tcpdump/tcpdump.c index db5ba53a932..48285b97ce6 100644 --- a/usr.sbin/tcpdump/tcpdump.c +++ b/usr.sbin/tcpdump/tcpdump.c @@ -1,5 +1,5 @@ -/* $OpenBSD: tcpdump.c,v 1.2 1996/03/04 15:59:46 mickey Exp $ */ -/* $NetBSD: tcpdump.c,v 1.3 1995/04/24 13:27:48 cgd Exp $ */ +/**//* $OpenBSD: tcpdump.c,v 1.3 1996/06/10 07:47:58 deraadt Exp $ */ +/* $NetBSD: tcpdump.c,v 1.4.4.1 1996/06/05 18:07:48 cgd Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -21,35 +21,11 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - -/* - * Copyright (c) 1995 Sun Microsystems, Inc. - * All rights reserved. - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that the - * above copyright notice and the following two paragraphs appear in - * all copies of this software. - - * IN NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES - * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * SUN MICROSYSTEMS, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - - * SUN MICROSYSTEMS, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SUN - * MICROSYSTEMS, INC. HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, - * UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -*/ #ifndef lint char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994\nThe Regents of the University of California. All rights reserved.\n"; static char rcsid[] = - "@(#)Header: tcpdump.c,v 1.93 94/06/10 17:01:44 mccanne Exp $ (LBL)"; + "@(#)Header: tcpdump.c,v 1.93 94/06/10 17:01:44 mccanne Exp (LBL)"; #endif /* @@ -89,7 +65,6 @@ int xflag; /* print packet in hex */ int Oflag = 1; /* run filter code optimizer */ int Sflag; /* print raw TCP sequence numbers */ int packettype; -int skipflag; /* Print out SKIP packets */ int dflag; /* print filter code */ @@ -154,7 +129,7 @@ int main(int argc, char **argv) { register int cnt, op; - u_long localnet, netmask; + u_int32_t localnet, netmask; register char *cp, *infile, *cmdbuf, *device, *RFileName, *WFileName; pcap_handler printer; struct bpf_program fcode; @@ -179,7 +154,7 @@ main(int argc, char **argv) program_name = argv[0]; opterr = 0; - while ((op = getopt(argc, argv, "c:defF:i:klnNOpqr:s:StT:vw:xY")) != EOF) + while ((op = getopt(argc, argv, "c:defF:i:lnNOpqr:s:StT:vw:xY")) != EOF) switch (op) { case 'c': cnt = atoi(optarg); @@ -205,10 +180,6 @@ main(int argc, char **argv) device = optarg; break; - case 'k': - skipflag++; - break; - case 'l': setlinebuf(stdout); break; @@ -354,7 +325,7 @@ main(int argc, char **argv) fflush(stderr); } if (pcap_loop(pd, cnt, printer, pcap_userdata) < 0) { - (void)fprintf(stderr, "%s: pcap_loop: %s\n", + (void)fprintf(stderr, "%s: pcap_loop %s\n", program_name, pcap_geterr(pd)); exit(1); } diff --git a/usr.sbin/tcpdump/util.c b/usr.sbin/tcpdump/util.c index 105b6e4029f..9ae7f4bcf10 100644 --- a/usr.sbin/tcpdump/util.c +++ b/usr.sbin/tcpdump/util.c @@ -1,5 +1,5 @@ -/* $OpenBSD: util.c,v 1.2 1996/03/04 15:59:47 mickey Exp $ */ -/* $NetBSD: util.c,v 1.3 1995/03/06 19:11:53 mycroft Exp $ */ +/**//* $OpenBSD: util.c,v 1.3 1996/06/10 07:47:59 deraadt Exp $ */ +/* $NetBSD: util.c,v 1.5 1996/05/20 00:41:19 fvdl Exp $ */ /* * Copyright (c) 1990, 1991, 1993, 1994 @@ -24,7 +24,7 @@ #ifndef lint static char rcsid[] = - "@(#) Header: util.c,v 1.28 94/06/12 14:30:31 leres Exp (LBL)"; + "@(#) Header: util.c,v 1.28+ 94/06/12 14:30:31 leres Exp (LBL)"; #endif #include <stdlib.h> @@ -34,7 +34,7 @@ static char rcsid[] = #include <sys/stat.h> #include <ctype.h> -#ifdef SOLARIS +#ifdef SVR4 #include <fcntl.h> #endif #ifdef __STDC__ @@ -174,7 +174,7 @@ savestr(register const char *str) strsize = 1024; if (strsize < size) strsize = size; - strptr = malloc(strsize); + strptr = (char *)malloc(strsize); if (strptr == NULL) error("savestr: malloc"); } @@ -282,7 +282,7 @@ copy_argv(register char **argv) while (*p) len += strlen(*p++) + 1; - buf = malloc(len); + buf = (char *)malloc(len); p = argv; dst = buf; @@ -310,7 +310,7 @@ read_infile(char *fname) if (fstat(fd, &buf) < 0) error("can't state '%s'", fname); - p = malloc((u_int)buf.st_size); + p = (char *)malloc((u_int)buf.st_size); if (read(fd, p, (int)buf.st_size) != buf.st_size) error("problem reading '%s'", fname); @@ -334,7 +334,7 @@ gmt2local() #else t = tz.tz_minuteswest * -60; if (tm->tm_isdst) - t += 60 * 60; + t += 3600; #endif return (t); #else diff --git a/usr.sbin/tcpdump/version.c b/usr.sbin/tcpdump/version.c index b24722badf2..630a3f34aaa 100644 --- a/usr.sbin/tcpdump/version.c +++ b/usr.sbin/tcpdump/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.2 1996/03/04 15:59:48 mickey Exp $ */ -/* $NetBSD: version.c,v 1.2 1995/03/06 19:11:56 mycroft Exp $ */ +/**//* $OpenBSD: version.c,v 1.3 1996/06/10 07:48:00 deraadt Exp $ */ +/* $NetBSD: version.c,v 1.3 1996/05/20 00:41:20 fvdl Exp $ */ -char version[] = "3.0.2"; +char version[] = "3.0.4"; |