Deleted Added
full compact
19a20,21
> *
> * $FreeBSD: head/contrib/tcpdump/print-nfs.c 75118 2001-04-03 07:50:46Z fenner $
24c26
< "@(#) $Header: print-nfs.c,v 1.65 97/08/17 13:24:22 leres Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.87 2000/10/07 05:53:12 itojun Exp $ (LBL)";
26a29,32
> #ifdef HAVE_CONFIG_H
> #include "config.h"
> #endif
>
31c37,38
< #include <net/if.h>
---
> struct mbuf;
> struct rtentry;
34,37d40
< #include <net/ethernet.h>
< #include <netinet/in_systm.h>
< #include <netinet/ip.h>
< #include <netinet/ip_var.h>
48d50
< #include "extract.h" /* must come after interface.h */
53,56c55,63
< static void nfs_printfh(const u_int32_t *, const int);
< static void xid_map_enter(const struct rpc_msg *, const struct ip *);
< static int32_t xid_map_find(const struct rpc_msg *, const struct ip *, u_int32_t *,
< u_int32_t *);
---
> #include "ip.h"
> #ifdef INET6
> #include "ip6.h"
> #endif
>
> static void nfs_printfh(const u_int32_t *, const u_int);
> static void xid_map_enter(const struct rpc_msg *, const u_char *);
> static int32_t xid_map_find(const struct rpc_msg *, const u_char *,
> u_int32_t *, u_int32_t *);
58a66,68
> static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
> static int print_int64(const u_int32_t *dp, int how);
> static void print_nfsaddr(const u_char *, const char *, const char *);
60,61d69
< static int nfserr; /* true if we error rather than trunc */
<
94,97c102,148
< const char *nfsv3_writemodes[NFSV3WRITE_NMODES] = {
< "unstable",
< "datasync",
< "filesync"
---
> /*
> * NFS V2 and V3 status values.
> *
> * Some of these come from the RFCs for NFS V2 and V3, with the message
> * strings taken from the FreeBSD C library "errlst.c".
> *
> * Others are errors that are not in the RFC but that I suspect some
> * NFS servers could return; the values are FreeBSD errno values, as
> * the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
> * was primarily BSD-derived.
> */
> static struct tok status2str[] = {
> { 1, "Operation not permitted" }, /* EPERM */
> { 2, "No such file or directory" }, /* ENOENT */
> { 5, "Input/output error" }, /* EIO */
> { 6, "Device not configured" }, /* ENXIO */
> { 11, "Resource deadlock avoided" }, /* EDEADLK */
> { 12, "Cannot allocate memory" }, /* ENOMEM */
> { 13, "Permission denied" }, /* EACCES */
> { 17, "File exists" }, /* EEXIST */
> { 18, "Cross-device link" }, /* EXDEV */
> { 19, "Operation not supported by device" }, /* ENODEV */
> { 20, "Not a directory" }, /* ENOTDIR */
> { 21, "Is a directory" }, /* EISDIR */
> { 22, "Invalid argument" }, /* EINVAL */
> { 26, "Text file busy" }, /* ETXTBSY */
> { 27, "File too large" }, /* EFBIG */
> { 28, "No space left on device" }, /* ENOSPC */
> { 30, "Read-only file system" }, /* EROFS */
> { 31, "Too many links" }, /* EMLINK */
> { 45, "Operation not supported" }, /* EOPNOTSUPP */
> { 62, "Too many levels of symbolic links" }, /* ELOOP */
> { 63, "File name too long" }, /* ENAMETOOLONG */
> { 66, "Directory not empty" }, /* ENOTEMPTY */
> { 69, "Disc quota exceeded" }, /* EDQUOT */
> { 70, "Stale NFS file handle" }, /* ESTALE */
> { 71, "Too many levels of remote in path" }, /* EREMOTE */
> { 99, "Write cache flushed to disk" }, /* NFSERR_WFLUSH (not used) */
> { 10001, "Illegal NFS file handle" }, /* NFS3ERR_BADHANDLE */
> { 10002, "Update synchronization mismatch" }, /* NFS3ERR_NOT_SYNC */
> { 10003, "READDIR/READDIRPLUS cookie is stale" }, /* NFS3ERR_BAD_COOKIE */
> { 10004, "Operation not supported" }, /* NFS3ERR_NOTSUPP */
> { 10005, "Buffer or request is too small" }, /* NFS3ERR_TOOSMALL */
> { 10006, "Unspecified error on server" }, /* NFS3ERR_SERVERFAULT */
> { 10007, "Object of that type not supported" }, /* NFS3ERR_BADTYPE */
> { 10008, "Request couldn't be completed in time" }, /* NFS3ERR_JUKEBOX */
> { 0, NULL }
99a151,157
> static struct tok nfsv3_writemodes[] = {
> { 0, "unstable" },
> { 1, "datasync" },
> { 2, "filesync" },
> { 0, NULL }
> };
>
124,128c182
< #define INT64_FORMAT "%qd"
< #define U_INT64_FORMAT "%qu"
< #define HEX_INT64_FORMAT "%qx"
<
< int print_int64(const u_int32_t *dp, int how)
---
> static int print_int64(const u_int32_t *dp, int how)
148,155c202,211
< /*
< * XXX - throw upper 32 bits away.
< * Could also go for hex: printf("0x%x%x", dp[0], dp[1]);
< */
< if (how == SIGNED)
< printf("%ld", (int)dp[1]);
< else
< printf("%lu", (unsigned int)dp[1]);
---
> switch (how) {
> case SIGNED:
> case UNSIGNED:
> case HEX:
> printf("0x%x%08x", (u_int32_t)ntohl(dp[0]),
> (u_int32_t)ntohl(dp[1]));
> break;
> default:
> return (0);
> }
159a216,254
> static void
> print_nfsaddr(const u_char *bp, const char *s, const char *d)
> {
> struct ip *ip;
> #ifdef INET6
> struct ip6_hdr *ip6;
> char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
> #else
> #ifndef INET_ADDRSTRLEN
> #define INET_ADDRSTRLEN 16
> #endif
> char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN];
> #endif
>
> srcaddr[0] = dstaddr[0] = '\0';
> switch (IP_V((struct ip *)bp)) {
> case 4:
> ip = (struct ip *)bp;
> strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
> strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
> break;
> #ifdef INET6
> case 6:
> ip6 = (struct ip6_hdr *)bp;
> strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
> sizeof(srcaddr));
> strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
> sizeof(dstaddr));
> break;
> #endif
> default:
> strlcpy(srcaddr, "?", sizeof(srcaddr));
> strlcpy(dstaddr, "?", sizeof(dstaddr));
> break;
> }
>
> (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
> }
>
163,166c258
< register const u_int32_t *ep = (u_int32_t *)snapend;
<
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
168,169c260
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
173,174c264
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
176,177c266
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
181,182c270
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
184,185c272
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
189,190c276
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
192,193c278
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
197,198c282
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
200,201c284
< if (dp + 2 > ep)
< return (NULL);
---
> TCHECK(dp[1]);
206,207c289
< if (dp + 1 > ep)
< return (NULL);
---
> TCHECK(dp[0]);
209,210c291
< if (dp + 2 > ep)
< return (NULL);
---
> TCHECK(dp[1]);
215a297,298
> trunc:
> return NULL;
218c301,303
< void
---
> static int nfserr; /* true if we error rather than trunc */
>
> static void
242d326
< register const struct ip *ip;
243a328
> char srcid[20], dstid[20]; /*fits 32bit*/
247d331
< ip = (const struct ip *)bp2;
249,255c333,345
< if (!nflag)
< (void)printf("%s.nfs > %s.%u: reply %s %d",
< ipaddr_string(&ip->ip_src),
< ipaddr_string(&ip->ip_dst),
< (u_int32_t)ntohl(rp->rm_xid),
< ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
< "ok":"ERR",
---
> if (!nflag) {
> strlcpy(srcid, "nfs", sizeof(srcid));
> snprintf(dstid, sizeof(dstid), "%u",
> (u_int32_t)ntohl(rp->rm_xid));
> } else {
> snprintf(srcid, sizeof(srcid), "%u", NFS_PORT);
> snprintf(dstid, sizeof(dstid), "%u",
> (u_int32_t)ntohl(rp->rm_xid));
> }
> print_nfsaddr(bp2, srcid, dstid);
> (void)printf("reply %s %d",
> ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
> "ok":"ERR",
257,265d346
< else
< (void)printf("%s.%u > %s.%u: reply %s %d",
< ipaddr_string(&ip->ip_src),
< NFS_PORT,
< ipaddr_string(&ip->ip_dst),
< (u_int32_t)ntohl(rp->rm_xid),
< ntohl(rp->rm_reply.rp_stat) == MSG_ACCEPTED?
< "ok":"ERR",
< length);
267c348
< if (xid_map_find(rp, ip, &proc, &vers) >= 0)
---
> if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
273c354
< * If the packet was truncated, return NULL.
---
> * If the packet was truncated, return 0.
276c357
< parsereq(register const struct rpc_msg *rp, register int length)
---
> parsereq(register const struct rpc_msg *rp, register u_int length)
303c384
< * If packet was truncated, return NULL.
---
> * If packet was truncated, return 0.
327c408
< * If packet was truncated, return NULL.
---
> * If packet was truncated, return 0.
336,337c417
< if ((u_char *)dp > snapend - sizeof(*dp))
< return (NULL);
---
> TCHECK(*dp);
342a423,424
> TCHECK2(*dp, ((len + 3) & ~3));
>
346,347d427
< if ((u_char *)dp > snapend)
< return (NULL);
353a434,435
> trunc:
> return NULL;
359c441
< * If packet was truncated (or there was some other error), return NULL.
---
> * If packet was truncated (or there was some other error), return 0.
376d457
< register const struct ip *ip;
378,379c459,461
< nfstype type;
< int proc, v3;
---
> nfs_type type;
> int v3;
> u_int32_t proc;
380a463
> char srcid[20], dstid[20]; /*fits 32bit*/
384,397c467,477
< ip = (const struct ip *)bp2;
< if (!nflag)
< (void)printf("%s.%u > %s.nfs: %d",
< ipaddr_string(&ip->ip_src),
< (u_int32_t)ntohl(rp->rm_xid),
< ipaddr_string(&ip->ip_dst),
< length);
< else
< (void)printf("%s.%u > %s.%u: %d",
< ipaddr_string(&ip->ip_src),
< (u_int32_t)ntohl(rp->rm_xid),
< ipaddr_string(&ip->ip_dst),
< NFS_PORT,
< length);
---
> if (!nflag) {
> snprintf(srcid, sizeof(srcid), "%u",
> (u_int32_t)ntohl(rp->rm_xid));
> strlcpy(dstid, "nfs", sizeof(dstid));
> } else {
> snprintf(srcid, sizeof(srcid), "%u",
> (u_int32_t)ntohl(rp->rm_xid));
> snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
> }
> print_nfsaddr(bp2, srcid, dstid);
> (void)printf("%d", length);
399c479
< xid_map_enter(rp, ip); /* record proc number for later on */
---
> xid_map_enter(rp, bp2); /* record proc number for later on */
417c497,498
< if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefh(dp, v3) != NULL)
423c504,505
< if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefh(dp, v3) != NULL)
429c511,512
< if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefhn(dp, v3) != NULL)
437,438c520,521
< TCHECK(*dp);
< printf(" %04lx", ntohl(dp[0]));
---
> TCHECK(dp[0]);
> printf(" %04x", (u_int32_t)ntohl(dp[0]));
445c528,529
< if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefh(dp, v3) != NULL)
454,455c538,540
< TCHECK2(*dp, 3 * sizeof(*dp));
< printf(" %lu bytes @ ", ntohl(dp[2]));
---
> TCHECK(dp[2]);
> printf(" %u bytes @ ",
> (u_int32_t) ntohl(dp[2]));
458,460c543,546
< TCHECK2(*dp, 2 * sizeof(*dp));
< printf(" %lu bytes @ %lu",
< ntohl(dp[1]), ntohl(dp[0]));
---
> TCHECK(dp[1]);
> printf(" %u bytes @ %u",
> (u_int32_t)ntohl(dp[1]),
> (u_int32_t)ntohl(dp[0]));
471,472c557,559
< TCHECK2(*dp, 3 * sizeof(*dp));
< printf(" %lu bytes @ ", ntohl(dp[4]));
---
> TCHECK(dp[4]);
> printf(" %u bytes @ ",
> (u_int32_t) ntohl(dp[4]));
476c563
< TCHECK2(*dp, sizeof(*dp));
---
> TCHECK(dp[0]);
478c565,566
< nfsv3_writemodes[ntohl(*dp)]);
---
> tok2str(nfsv3_writemodes,
> NULL, ntohl(*dp)));
481,484c569,574
< TCHECK2(*dp, 4 * sizeof(*dp));
< printf(" %lu (%lu) bytes @ %lu (%lu)",
< ntohl(dp[3]), ntohl(dp[2]),
< ntohl(dp[1]), ntohl(dp[0]));
---
> TCHECK(dp[3]);
> printf(" %u (%u) bytes @ %u (%u)",
> (u_int32_t)ntohl(dp[3]),
> (u_int32_t)ntohl(dp[2]),
> (u_int32_t)ntohl(dp[1]),
> (u_int32_t)ntohl(dp[0]));
492c582,583
< if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefhn(dp, v3) != NULL)
498c589
< if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
504,507c595,598
< if ((dp = parsereq(rp, length)) != NULL &&
< (dp = parsefhn(dp, v3)) != NULL) {
< fputs(" -> ", stdout);
< if (v3 && (dp = parse_sattr3(dp, &sa3)) == NULL)
---
> if ((dp = parsereq(rp, length)) != 0 &&
> (dp = parsefhn(dp, v3)) != 0) {
> fputs(" ->", stdout);
> if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
509c600
< if (parsefn(dp) == NULL)
---
> if (parsefn(dp) == 0)
519,521c610,614
< if ((dp = parsereq(rp, length)) != NULL &&
< (dp = parsefhn(dp, v3)) != NULL) {
< if (dp + 1 > (u_int32_t *)snapend)
---
> if ((dp = parsereq(rp, length)) != 0 &&
> (dp = parsefhn(dp, v3)) != 0) {
> TCHECK(*dp);
> type = (nfs_type)ntohl(*dp++);
> if ((dp = parse_sattr3(dp, &sa3)) == 0)
523,525d615
< type = (nfstype)ntohl(*dp++);
< if ((dp = parse_sattr3(dp, &sa3)) == NULL)
< break;
528,530c618,621
< if (dp + 2 > (u_int32_t *)snapend)
< break;
< printf(" %lu/%lu", ntohl(dp[0]), ntohl(dp[1]));
---
> TCHECK(dp[1]);
> printf(" %u/%u",
> (u_int32_t)ntohl(dp[0]),
> (u_int32_t)ntohl(dp[1]));
541c632,633
< if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefhn(dp, v3) != NULL)
547c639,640
< if ((dp = parsereq(rp, length)) != NULL && parsefhn(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefhn(dp, v3) != NULL)
576c669
< TCHECK2(*dp, 20);
---
> TCHECK(dp[4]);
581c674,675
< printf(" %lu bytes @ ", ntohl(dp[4]));
---
> printf(" %u bytes @ ",
> (u_int32_t) ntohl(dp[4]));
587c681
< TCHECK2(*dp, 2 * sizeof(*dp));
---
> TCHECK(dp[1]);
592,593c686,688
< printf(" %lu bytes @ %ld", ntohl(dp[1]),
< ntohl(dp[0]));
---
> printf(" %u bytes @ %d",
> (u_int32_t)ntohl(dp[1]),
> (u_int32_t)ntohl(dp[0]));
603c698
< TCHECK2(*dp, 20);
---
> TCHECK(dp[4]);
608c703
< printf(" %lu bytes @ ", ntohl(dp[4]));
---
> printf(" %u bytes @ ", (u_int32_t) ntohl(dp[4]));
611,612c706,707
< printf(" max %lu verf %08x%08x",
< ntohl(dp[5]), dp[2], dp[3]);
---
> printf(" max %u verf %08x%08x",
> (u_int32_t) ntohl(dp[5]), dp[2], dp[3]);
619c714,715
< if ((dp = parsereq(rp, length)) != NULL && parsefh(dp, v3) != NULL)
---
> if ((dp = parsereq(rp, length)) != NULL &&
> parsefh(dp, v3) != NULL)
635c731
< printf(" %lu bytes @ ", ntohl(dp[2]));
---
> printf(" %u bytes @ ", (u_int32_t) ntohl(dp[2]));
642c738
< printf(" proc-%lu", ntohl(rp->rm_call.cb_proc));
---
> printf(" proc-%u", (u_int32_t)ntohl(rp->rm_call.cb_proc));
644a741
>
660c757
< nfs_printfh(register const u_int32_t *dp, const int len)
---
> nfs_printfh(register const u_int32_t *dp, const u_int len)
666c763
< Parse_fh((caddr_t *)dp, len, &fsid, &ino, NULL, &sfsname, 0);
---
> Parse_fh((caddr_t*)dp, len, &fsid, &ino, NULL, &sfsname, 0);
673a771
> temp[sizeof(temp) - 1] = '\0';
679c777
< (void)printf(" fh %s/%u", temp, (u_int32_t)ino);
---
> (void)printf(" fh %s/", temp);
681,682c779,780
< (void)printf(" fh %u,%u/%u",
< fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor, (u_int32_t)ino);
---
> (void)printf(" fh %d,%d/",
> fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
683a782,787
>
> if(fsid.Fsid_dev.Minor == 257 && uflag)
> /* Print the undecoded handle */
> (void)printf("%s", fsid.Opaque_Handle);
> else
> (void)printf("%ld", (long) ino);
693c797,802
< u_int32_t xid; /* transaction ID (net order) */
---
> u_int32_t xid; /* transaction ID (net order) */
> int ipver; /* IP version (4 or 6) */
> #ifdef INET6
> struct in6_addr client; /* client IP address (net order) */
> struct in6_addr server; /* server IP address (net order) */
> #else
696,697c805,807
< u_int32_t proc; /* call proc number (host order) */
< u_int32_t vers; /* program version (host order) */
---
> #endif
> u_int32_t proc; /* call proc number (host order) */
> u_int32_t vers; /* program version (host order) */
714c824
< xid_map_enter(const struct rpc_msg *rp, const struct ip *ip)
---
> xid_map_enter(const struct rpc_msg *rp, const u_char *bp)
715a826,829
> struct ip *ip = NULL;
> #ifdef INET6
> struct ip6_hdr *ip6 = NULL;
> #endif
717a832,844
> switch (IP_V((struct ip *)bp)) {
> case 4:
> ip = (struct ip *)bp;
> break;
> #ifdef INET6
> case 6:
> ip6 = (struct ip6_hdr *)bp;
> break;
> #endif
> default:
> return;
> }
>
724,725c851,862
< xmep->client = ip->ip_src;
< xmep->server = ip->ip_dst;
---
> if (ip) {
> xmep->ipver = 4;
> memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
> memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
> }
> #ifdef INET6
> else if (ip6) {
> xmep->ipver = 6;
> memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
> memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
> }
> #endif
735c872
< xid_map_find(const struct rpc_msg *rp, const struct ip *ip, u_int32_t *proc,
---
> xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc,
741,742c878,882
< u_int32_t clip = ip->ip_dst.s_addr;
< u_int32_t sip = ip->ip_src.s_addr;
---
> struct ip *ip = (struct ip *)bp;
> #ifdef INET6
> struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
> #endif
> int cmp;
745c885
< i = xid_map_hint;
---
> i = xid_map_hint;
748,749c888,914
< if (xmep->xid == xid && xmep->client.s_addr == clip &&
< xmep->server.s_addr == sip) {
---
> cmp = 1;
> if (xmep->ipver != IP_V(ip) || xmep->xid != xid)
> goto nextitem;
> switch (xmep->ipver) {
> case 4:
> if (memcmp(&ip->ip_src, &xmep->server,
> sizeof(ip->ip_src)) != 0 ||
> memcmp(&ip->ip_dst, &xmep->client,
> sizeof(ip->ip_dst)) != 0) {
> cmp = 0;
> }
> break;
> #ifdef INET6
> case 6:
> if (memcmp(&ip6->ip6_src, &xmep->server,
> sizeof(ip6->ip6_src)) != 0 ||
> memcmp(&ip6->ip6_dst, &xmep->client,
> sizeof(ip6->ip6_dst)) != 0) {
> cmp = 0;
> }
> break;
> #endif
> default:
> cmp = 0;
> break;
> }
> if (cmp) {
755a921
> nextitem:
761c927
< return (0);
---
> return (-1);
770c936
< * If the packet was truncated, return NULL.
---
> * If the packet was truncated, return 0.
773c939
< parserep(register const struct rpc_msg *rp, register int length)
---
> parserep(register const struct rpc_msg *rp, register u_int length)
776c942
< int len;
---
> u_int len;
795c961
< TCHECK2(dp[0], 1);
---
> TCHECK(dp[1]);
845,847c1011,1012
< if ((sizeof(astat) + ((u_char *)dp)) < snapend)
< return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
<
---
> TCHECK2(*dp, sizeof(astat));
> return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
849c1014
< return (NULL);
---
> return (0);
852d1016
<
856c1020
< register int errnum;
---
> int errnum;
858a1023
>
864c1029,1030
< printf(" ERROR: %s", pcap_strerror(errnum));
---
> printf(" ERROR: %s",
> tok2str(status2str, "unk %d", errnum));
870c1036
< return (NULL);
---
> return NULL;
881,884c1047,1052
< 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));
---
> printf(" %s %o ids %d/%d",
> tok2str(type2str, "unk-ft %d ",
> (u_int32_t)ntohl(fap->fa_type)),
> (u_int32_t)ntohl(fap->fa_mode),
> (u_int32_t)ntohl(fap->fa_uid),
> (u_int32_t) ntohl(fap->fa_gid));
892c1060
< printf(" sz %ld ", ntohl(fap->fa2_size));
---
> printf(" sz %d ", (u_int32_t) ntohl(fap->fa2_size));
899,902c1067,1070
< printf("nlink %ld rdev %ld/%ld ",
< ntohl(fap->fa_nlink),
< ntohl(fap->fa3_rdev.specdata1),
< ntohl(fap->fa3_rdev.specdata2));
---
> printf("nlink %d rdev %d/%d ",
> (u_int32_t)ntohl(fap->fa_nlink),
> (u_int32_t) ntohl(fap->fa3_rdev.specdata1),
> (u_int32_t) ntohl(fap->fa3_rdev.specdata2));
907,915c1075,1083
< printf(" a/m/ctime %lu.%06lu ",
< ntohl(fap->fa3_atime.nfsv3_sec),
< ntohl(fap->fa3_atime.nfsv3_nsec));
< printf("%lu.%06lu ",
< ntohl(fap->fa3_mtime.nfsv3_sec),
< ntohl(fap->fa3_mtime.nfsv3_nsec));
< printf("%lu.%06lu ",
< ntohl(fap->fa3_ctime.nfsv3_sec),
< ntohl(fap->fa3_ctime.nfsv3_nsec));
---
> printf(" a/m/ctime %u.%06u ",
> (u_int32_t) ntohl(fap->fa3_atime.nfsv3_sec),
> (u_int32_t) ntohl(fap->fa3_atime.nfsv3_nsec));
> printf("%u.%06u ",
> (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_sec),
> (u_int32_t) ntohl(fap->fa3_mtime.nfsv3_nsec));
> printf("%u.%06u ",
> (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_sec),
> (u_int32_t) ntohl(fap->fa3_ctime.nfsv3_nsec));
918,929c1086,1099
< printf("nlink %ld rdev %lx fsid %lx nodeid %lx a/m/ctime ",
< ntohl(fap->fa_nlink), ntohl(fap->fa2_rdev),
< ntohl(fap->fa2_fsid), ntohl(fap->fa2_fileid));
< printf("%lu.%06lu ",
< ntohl(fap->fa2_atime.nfsv2_sec),
< ntohl(fap->fa2_atime.nfsv2_usec));
< printf("%lu.%06lu ",
< ntohl(fap->fa2_mtime.nfsv2_sec),
< ntohl(fap->fa2_mtime.nfsv2_usec));
< printf("%lu.%06lu ",
< ntohl(fap->fa2_ctime.nfsv2_sec),
< ntohl(fap->fa2_ctime.nfsv2_usec));
---
> printf("nlink %d rdev %x fsid %x nodeid %x a/m/ctime ",
> (u_int32_t) ntohl(fap->fa_nlink),
> (u_int32_t) ntohl(fap->fa2_rdev),
> (u_int32_t) ntohl(fap->fa2_fsid),
> (u_int32_t) ntohl(fap->fa2_fileid));
> printf("%u.%06u ",
> (u_int32_t) ntohl(fap->fa2_atime.nfsv2_sec),
> (u_int32_t) ntohl(fap->fa2_atime.nfsv2_usec));
> printf("%u.%06u ",
> (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_sec),
> (u_int32_t) ntohl(fap->fa2_mtime.nfsv2_usec));
> printf("%u.%06u ",
> (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_sec),
> (u_int32_t) ntohl(fap->fa2_ctime.nfsv2_usec));
955,956c1125
< dp = parsestatus(dp, &er);
< if (dp == NULL || er)
---
> if (!(dp = parsestatus(dp, &er)) || er)
974,975c1143
<
< if (v3 && ((dp = parse_post_op_attr(dp, vflag)) != NULL))
---
> if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
977d1144
<
990c1157
< return(0);
---
> return (0);
998c1165
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1020c1187,1188
< printf(" invar %lu", ntohl(sfsp->sf_invarsec));
---
> printf(" invar %u",
> (u_int32_t) ntohl(sfsp->sf_invarsec));
1023,1026c1191,1196
< 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));
---
> printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
> (u_int32_t)ntohl(sfsp->sf_tsize),
> (u_int32_t)ntohl(sfsp->sf_bsize),
> (u_int32_t)ntohl(sfsp->sf_blocks),
> (u_int32_t)ntohl(sfsp->sf_bfree),
> (u_int32_t)ntohl(sfsp->sf_bavail));
1040c1210
< if (dp == NULL || er)
---
> if (dp == 0 || er)
1046c1216,1217
< printf(" offset %lx size %ld ", ntohl(dp[0]), ntohl(dp[1]));
---
> printf(" offset %x size %d ",
> (u_int32_t)ntohl(dp[0]), (u_int32_t)ntohl(dp[1]));
1048c1219
< printf("eof");
---
> printf(" eof");
1060,1061c1231,1233
< printf(" mtime %lu.%06lu ctime %lu.%06lu", ntohl(dp[2]), ntohl(dp[3]),
< ntohl(dp[4]), ntohl(dp[5]));
---
> printf(" mtime %u.%06u ctime %u.%06u",
> (u_int32_t)ntohl(dp[2]), (u_int32_t)ntohl(dp[3]),
> (u_int32_t)ntohl(dp[4]), (u_int32_t)ntohl(dp[5]));
1109,1110c1281,1282
< if ((dp = parse_pre_op_attr(dp, verbose)) == NULL)
< return (NULL);
---
> if (!(dp = parse_pre_op_attr(dp, verbose)))
> return (0);
1122,1123c1294,1295
< if ((dp = parsestatus(dp, &er)) == NULL)
< return (NULL);
---
> if (!(dp = parsestatus(dp, &er)))
> return (0);
1131,1132c1303,1304
< if ((dp = parsefh(dp, 1)) == NULL)
< return (NULL);
---
> if (!(dp = parsefh(dp, 1)))
> return (0);
1134,1135c1306,1307
< if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
< return (NULL);
---
> if (!(dp = parse_post_op_attr(dp, verbose)))
> return (0);
1152c1324
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1154c1326
< return parse_wcc_data(dp, verbose) != NULL;
---
> return parse_wcc_data(dp, verbose) != 0;
1162,1163c1334,1335
< if ((dp = parsestatus(dp, &er)) == NULL)
< return (NULL);
---
> if (!(dp = parsestatus(dp, &er)))
> return (0);
1166,1167c1338,1339
< if ((dp = parse_post_op_attr(dp, verbose)) == NULL)
< return (NULL);
---
> if (!(dp = parse_post_op_attr(dp, verbose)))
> return (0);
1186c1358
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1190c1362
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1197,1200c1369,1374
< 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));
---
> printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
> (u_int32_t) ntohl(sfp->fs_rtmax),
> (u_int32_t) ntohl(sfp->fs_rtpref),
> (u_int32_t) ntohl(sfp->fs_wtmax),
> (u_int32_t) ntohl(sfp->fs_wtpref),
> (u_int32_t) ntohl(sfp->fs_dtpref));
1202,1203c1376,1378
< printf(" rtmult %lu wtmult %lu maxfsz ",
< ntohl(sfp->fs_rtmult), ntohl(sfp->fs_wtmult));
---
> printf(" rtmult %u wtmult %u maxfsz ",
> (u_int32_t) ntohl(sfp->fs_rtmult),
> (u_int32_t) ntohl(sfp->fs_wtmult));
1205,1206c1380,1382
< printf(" delta %lu.%06lu ", ntohl(sfp->fs_timedelta.nfsv3_sec),
< ntohl(sfp->fs_timedelta.nfsv3_nsec));
---
> printf(" delta %u.%06u ",
> (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec),
> (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec));
1208,1209d1383
< return (1);
< trunc:
1210a1385,1386
> trunc:
> return (1);
1219c1395
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1223c1399
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1231,1233c1407,1409
< printf(" linkmax %lu namemax %lu %s %s %s %s",
< ntohl(spp->pc_linkmax),
< ntohl(spp->pc_namemax),
---
> printf(" linkmax %u namemax %u %s %s %s %s",
> (u_int32_t) ntohl(spp->pc_linkmax),
> (u_int32_t) ntohl(spp->pc_namemax),
1238,1239d1413
< return (1);
< trunc:
1240a1415,1416
> trunc:
> return (1);
1242c1418
<
---
>
1248d1423
<
1275c1450
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1278c1453
< if (parsewccres(dp, vflag) != 0)
---
> if (parsewccres(dp, vflag))
1288c1463
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1291c1466
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1299c1474
< if ((dp = parsefh(dp, v3)) == NULL)
---
> if (!(dp = parsefh(dp, v3)))
1301,1302c1476,1477
< if (((dp = parse_post_op_attr(dp, vflag)) != NULL) &&
< (vflag > 1)) {
---
> if ((dp = parse_post_op_attr(dp, vflag)) &&
> vflag > 1) {
1307c1482
< if (dp != NULL)
---
> if (dp)
1318c1493
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1322c1497
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1325c1500
< printf(" c %04lx", ntohl(dp[0]));
---
> printf(" c %04x", (u_int32_t)ntohl(dp[0]));
1337c1512
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1340c1515
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1342c1517
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1347,1348c1522,1523
< TCHECK2(*dp, 8);
< printf("%lu bytes", ntohl(dp[0]));
---
> TCHECK(dp[1]);
> printf("%u bytes", (u_int32_t) ntohl(dp[0]));
1361c1536
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1364c1539
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1366c1541
< if ((dp = parse_wcc_data(dp, vflag)) == NULL)
---
> if (!(dp = parse_wcc_data(dp, vflag)))
1371,1372c1546,1547
< TCHECK2(*dp, 4);
< printf("%lu bytes", ntohl(dp[0]));
---
> TCHECK(dp[0]);
> printf("%u bytes", (u_int32_t) ntohl(dp[0]));
1374c1549
< TCHECK2(*dp, 4);
---
> TCHECK(dp[1]);
1376c1551,1552
< nfsv3_writemodes[ntohl(dp[1])]);
---
> tok2str(nfsv3_writemodes,
> NULL, ntohl(dp[1])));
1388c1564
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1391c1567
< if (parsecreateopres(dp, vflag) != NULL)
---
> if (parsecreateopres(dp, vflag) != 0)
1401c1577
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1404c1580
< if (parsecreateopres(dp, vflag) != NULL)
---
> if (parsecreateopres(dp, vflag) != 0)
1414c1590
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1417c1593
< if (parsecreateopres(dp, vflag) != NULL)
---
> if (parsecreateopres(dp, vflag) != 0)
1420c1596
< if (parsestatus(dp, &er) != NULL)
---
> if (parsestatus(dp, &er) != 0)
1427c1603
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1429c1605
< if (parsecreateopres(dp, vflag) != NULL)
---
> if (parsecreateopres(dp, vflag) != 0)
1435c1611
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1438c1614
< if (parsewccres(dp, vflag) != 0)
---
> if (parsewccres(dp, vflag))
1441c1617
< if (parsestatus(dp, &er) != NULL)
---
> if (parsestatus(dp, &er) != 0)
1448c1624
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1451c1627
< if (parsewccres(dp, vflag) != 0)
---
> if (parsewccres(dp, vflag))
1454c1630
< if (parsestatus(dp, &er) != NULL)
---
> if (parsestatus(dp, &er) != 0)
1461c1637
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1464c1640
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1468c1644
< if ((dp = parse_wcc_data(dp, vflag)) == NULL)
---
> if (!(dp = parse_wcc_data(dp, vflag)))
1471c1647
< if ((dp = parse_wcc_data(dp, vflag)) == NULL)
---
> if (!(dp = parse_wcc_data(dp, vflag)))
1476c1652
< if (parsestatus(dp, &er) != NULL)
---
> if (parsestatus(dp, &er) != 0)
1483c1659
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1486c1662
< if ((dp = parsestatus(dp, &er)) == NULL)
---
> if (!(dp = parsestatus(dp, &er)))
1490c1666
< if ((dp = parse_post_op_attr(dp, vflag)) == NULL)
---
> if (!(dp = parse_post_op_attr(dp, vflag)))
1493c1669
< if ((dp = parse_wcc_data(dp, vflag)) == NULL)
---
> if (!(dp = parse_wcc_data(dp, vflag)))
1498c1674
< if (parsestatus(dp, &er) != NULL)
---
> if (parsestatus(dp, &er) != 0)
1505c1681
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1508c1684
< if (parsev3rddirres(dp, vflag) != NULL)
---
> if (parsev3rddirres(dp, vflag))
1518c1694
< if ((dp = parserep(rp, length)) == NULL)
---
> if (!(dp = parserep(rp, length)))
1520c1696
< if (parsev3rddirres(dp, vflag) != NULL)
---
> if (parsev3rddirres(dp, vflag))
1527c1703
< if (dp != NULL && parsestatfs(dp, v3) != NULL)
---
> if (dp != NULL && parsestatfs(dp, v3) != 0)
1534c1710
< if (dp != NULL && parsefsinfo(dp) != NULL)
---
> if (dp != NULL && parsefsinfo(dp) != 0)
1556d1731
<