]> The Tcpdump Group git mirrors - tcpdump/commitdiff
V3 FSINFO and PATHCONF requests take a file handle as an argument; parse
authorguy <guy>
Fri, 31 May 2002 09:47:23 +0000 (09:47 +0000)
committerguy <guy>
Fri, 31 May 2002 09:47:23 +0000 (09:47 +0000)
the request header and the file handle.

"parsestatus()" should only return NULL if the packet was truncated, so
that its callers can distinguish "packet truncated" from "NFS reply
status reports an error".

NFS-request-or-reply parsing routines that call "parsestatus()" should
not return 0 if "parsestatus()" returns a non-zero NFS reply status, so
that non-truncated packets with a non-zero NFS reply status aren't
printed as truncated NFS packets.

Fix some "TCHECK2()" calls to pass an object, not a pointer to an
object, as the first argument (the TCHECK/TTEST macros take objects, not
addresses, as the test argument).

NFS-request-or-reply parsing routines should return 0 for truncated
packets and 1 for non-truncated packets, not *vice versa*.

print-nfs.c

index c295fd7a8f7a79653747012a61cf49c19d700c4e..0173de3c395abea8db1fcd3407b2fd6e6f973913 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.91 2002-04-24 06:27:06 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.92 2002-05-31 09:47:23 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -716,10 +716,16 @@ nfsreq_print(register const u_char *bp, u_int length,
 
        case NFSPROC_FSINFO:
                printf(" fsinfo");
+               if ((dp = parsereq(rp, length)) != NULL &&
+                   parsefh(dp, v3) != NULL)
+                       return;
                break;
 
        case NFSPROC_PATHCONF:
                printf(" pathconf");
+               if ((dp = parsereq(rp, length)) != NULL &&
+                   parsefh(dp, v3) != NULL)
+                       return;
                break;
 
        case NFSPROC_COMMIT:
@@ -1028,7 +1034,6 @@ parsestatus(const u_int32_t *dp, int *er)
                        printf(" ERROR: %s",
                            tok2str(status2str, "unk %d", errnum));
                nfserr = 1;
-               return (NULL);
        }
        return (dp + 1);
 trunc:
@@ -1110,8 +1115,10 @@ parseattrstat(const u_int32_t *dp, int verbose, int v3)
        int er;
 
        dp = parsestatus(dp, &er);
-       if (dp == NULL || er)
+       if (dp == NULL)
                return (0);
+       if (er)
+               return (1);
 
        return (parsefattr(dp, verbose, v3) != NULL);
 }
@@ -1121,8 +1128,10 @@ parsediropres(const u_int32_t *dp)
 {
        int er;
 
-       if (!(dp = parsestatus(dp, &er)) || er)
+       if (!(dp = parsestatus(dp, &er)))
                return (0);
+       if (er)
+               return (1);
 
        dp = parsefh(dp, 0);
        if (dp == NULL)
@@ -1137,8 +1146,10 @@ parselinkres(const u_int32_t *dp, int v3)
        int er;
 
        dp = parsestatus(dp, &er);
-       if (dp == NULL || er)
+       if (dp == NULL)
                return(0);
+       if (er)
+               return(1);
        if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
                return (0);
        putchar(' ');
@@ -1152,8 +1163,10 @@ parsestatfs(const u_int32_t *dp, int v3)
        int er;
 
        dp = parsestatus(dp, &er);
-       if (dp == NULL || (!v3 && er))
+       if (dp == NULL)
                return (0);
+       if (!v3 && er)
+               return (1);
 
        if (qflag)
                return(1);
@@ -1165,7 +1178,7 @@ parsestatfs(const u_int32_t *dp, int v3)
                        return (0);
        }
 
-       TCHECK2(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+       TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
 
        sfsp = (const struct nfs_statfs *)dp;
 
@@ -1206,8 +1219,10 @@ parserddires(const u_int32_t *dp)
        int er;
 
        dp = parsestatus(dp, &er);
-       if (dp == NULL || er)
+       if (dp == NULL)
                return (0);
+       if (er)
+               return (1);
        if (qflag)
                return (1);
 
@@ -1243,7 +1258,7 @@ parse_pre_op_attr(const u_int32_t *dp, int verbose)
        if (!ntohl(dp[0]))
                return (dp + 1);
        dp++;
-       TCHECK2(dp, 24);
+       TCHECK2(*dp, 24);
        if (verbose > 1) {
                return parse_wcc_attr(dp);
        } else {
@@ -1380,9 +1395,9 @@ parsefsinfo(const u_int32_t *dp)
                       (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_sec),
                       (u_int32_t) ntohl(sfp->fs_timedelta.nfsv3_nsec));
        }
-       return (0);
-trunc:
        return (1);
+trunc:
+       return (0);
 }
 
 static int
@@ -1410,9 +1425,9 @@ parsepathconf(const u_int32_t *dp)
               ntohl(spp->pc_chownrestricted) ? "chownres" : "",
               ntohl(spp->pc_caseinsensitive) ? "igncase" : "",
               ntohl(spp->pc_casepreserving) ? "keepcase" : "");
-       return (0);
-trunc:
        return (1);
+trunc:
+       return (0);
 }
 
 static void