]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nfs.c
Clean up ISAKMP dissection, use nd_ types and EXTRACT_ macros.
[tcpdump] / print-nfs.c
index a4823842a7be7e365684eba865bfbf68b61ceda0..04c98becb29becb051a54e8dd63c2b0af5ae23c6 100644 (file)
@@ -320,10 +320,10 @@ print_sattr3(netdissect_options *ndo,
 
 void
 nfsreply_print(netdissect_options *ndo,
-               register const u_char *bp, u_int length,
-               register const u_char *bp2)
+               const u_char *bp, u_int length,
+               const u_char *bp2)
 {
-       register const struct sunrpc_msg *rp;
+       const struct sunrpc_msg *rp;
        char srcid[20], dstid[20];      /*fits 32bit*/
 
        nfserr = 0;             /* assume no error */
@@ -351,10 +351,10 @@ trunc:
 
 void
 nfsreply_noaddr_print(netdissect_options *ndo,
-                      register const u_char *bp, u_int length,
-                      register const u_char *bp2)
+                      const u_char *bp, u_int length,
+                      const u_char *bp2)
 {
-       register const struct sunrpc_msg *rp;
+       const struct sunrpc_msg *rp;
        uint32_t proc, vers, reply_stat;
        enum sunrpc_reject_stat rstat;
        uint32_t rlow;
@@ -416,10 +416,10 @@ trunc:
  */
 static const uint32_t *
 parsereq(netdissect_options *ndo,
-         register const struct sunrpc_msg *rp, register u_int length)
+         const struct sunrpc_msg *rp, u_int length)
 {
-       register const uint32_t *dp;
-       register u_int len;
+       const uint32_t *dp;
+       u_int len;
 
        /*
         * find the start of the req data (if we captured it)
@@ -433,7 +433,7 @@ parsereq(netdissect_options *ndo,
                len = EXTRACT_BE_U_4(dp + 1);
                if (len < length) {
                        dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
-                       ND_TCHECK2(dp[0], 0);
+                       ND_TCHECK_LEN(dp, 0);
                        return (dp);
                }
        }
@@ -447,7 +447,7 @@ trunc:
  */
 static const uint32_t *
 parsefh(netdissect_options *ndo,
-        register const uint32_t *dp, int v3)
+        const uint32_t *dp, int v3)
 {
        u_int len;
 
@@ -458,7 +458,7 @@ parsefh(netdissect_options *ndo,
        } else
                len = NFSX_V2FH / 4;
 
-       if (ND_TTEST2(*dp, len * sizeof(*dp))) {
+       if (ND_TTEST_LEN(dp, len * sizeof(*dp))) {
                nfs_printfh(ndo, dp, len);
                return (dp + len);
        }
@@ -472,19 +472,19 @@ trunc:
  */
 static const uint32_t *
 parsefn(netdissect_options *ndo,
-        register const uint32_t *dp)
+        const uint32_t *dp)
 {
-       register uint32_t len;
-       register const u_char *cp;
+       uint32_t len;
+       const u_char *cp;
 
        /* Bail if we don't have the string length */
        ND_TCHECK(*dp);
 
-       /* Fetch string length; convert to host order */
-       len = *dp++;
-       NTOHL(len);
+       /* Fetch big-endian string length */
+       len = EXTRACT_BE_U_4(dp);
+       dp++;
 
-       ND_TCHECK2(*dp, ((len + 3) & ~3));
+       ND_TCHECK_LEN(dp, ((len + 3) & ~3));
 
        cp = (const u_char *)dp;
        /* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
@@ -508,7 +508,7 @@ trunc:
  */
 static const uint32_t *
 parsefhn(netdissect_options *ndo,
-         register const uint32_t *dp, int v3)
+         const uint32_t *dp, int v3)
 {
        dp = parsefh(ndo, dp, v3);
        if (dp == NULL)
@@ -519,11 +519,11 @@ parsefhn(netdissect_options *ndo,
 
 void
 nfsreq_noaddr_print(netdissect_options *ndo,
-                    register const u_char *bp, u_int length,
-                    register const u_char *bp2)
+                    const u_char *bp, u_int length,
+                    const u_char *bp2)
 {
-       register const struct sunrpc_msg *rp;
-       register const uint32_t *dp;
+       const struct sunrpc_msg *rp;
+       const uint32_t *dp;
        nfs_type type;
        int v3;
        uint32_t proc;
@@ -717,7 +717,9 @@ nfsreq_noaddr_print(netdissect_options *ndo,
                                    EXTRACT_BE_U_4(dp + 4),
                                    EXTRACT_BE_U_8(dp)));
                                if (ndo->ndo_vflag)
-                                       ND_PRINT((ndo, " verf %08x%08x", dp[2], dp[3]));
+                                       ND_PRINT((ndo, " verf %08x%08x",
+                                                 EXTRACT_BE_U_4(dp + 2),
+                                                 EXTRACT_BE_U_4(dp + 3)));
                        } else {
                                ND_TCHECK(dp[1]);
                                /*
@@ -746,7 +748,9 @@ nfsreq_noaddr_print(netdissect_options *ndo,
                        if (ndo->ndo_vflag) {
                                ND_TCHECK(dp[5]);
                                ND_PRINT((ndo, " max %u verf %08x%08x",
-                                      EXTRACT_BE_U_4(dp + 5), dp[2], dp[3]));
+                                         EXTRACT_BE_U_4(dp + 5),
+                                         EXTRACT_BE_U_4(dp + 2),
+                                         EXTRACT_BE_U_4(dp + 3)));
                        }
                        return;
                }
@@ -783,7 +787,7 @@ trunc:
  */
 static void
 nfs_printfh(netdissect_options *ndo,
-            register const uint32_t *dp, const u_int len)
+            const uint32_t *dp, const u_int len)
 {
        my_fsid fsid;
        uint32_t ino;
@@ -796,7 +800,7 @@ nfs_printfh(netdissect_options *ndo,
 
                ND_PRINT((ndo, " fh["));
                for (i=0; i<len; i++) {
-                       ND_PRINT((ndo, "%s%x", sep, dp[i]));
+                       ND_PRINT((ndo, "%s%x", sep, EXTRACT_BE_U_4(dp + i)));
                        sep = ":";
                }
                ND_PRINT((ndo, "]"));
@@ -974,9 +978,9 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
  */
 static const uint32_t *
 parserep(netdissect_options *ndo,
-         register const struct sunrpc_msg *rp, register u_int length)
+         const struct sunrpc_msg *rp, u_int length)
 {
-       register const uint32_t *dp;
+       const uint32_t *dp;
        u_int len;
        enum sunrpc_accept_stat astat;
 
@@ -1016,7 +1020,7 @@ parserep(netdissect_options *ndo,
                return (NULL);
        }
        /* successful return */
-       ND_TCHECK2(*dp, sizeof(astat));
+       ND_TCHECK_LEN(dp, sizeof(astat));
        return ((const uint32_t *) (sizeof(astat) + ((const char *)dp)));
 trunc:
        return (0);
@@ -1186,7 +1190,7 @@ parsestatfs(netdissect_options *ndo,
                        return (0);
        }
 
-       ND_TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+       ND_TCHECK_LEN(dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
 
        sfsp = (const struct nfs_statfs *)dp;
 
@@ -1233,7 +1237,7 @@ parserddires(netdissect_options *ndo,
        ND_TCHECK(dp[2]);
        ND_PRINT((ndo, " offset 0x%x size %d ",
               EXTRACT_BE_U_4(dp), EXTRACT_BE_U_4(dp + 1)));
-       if (dp[2] != 0)
+       if (EXTRACT_BE_U_4(dp + 2) != 0)
                ND_PRINT((ndo, " eof"));
 
        return (1);
@@ -1264,7 +1268,7 @@ parse_pre_op_attr(netdissect_options *ndo,
        if (!EXTRACT_BE_U_4(dp))
                return (dp + 1);
        dp++;
-       ND_TCHECK2(*dp, 24);
+       ND_TCHECK_LEN(dp, 24);
        if (verbose > 1) {
                return parse_wcc_attr(ndo, dp);
        } else {
@@ -1366,7 +1370,8 @@ parsev3rddirres(netdissect_options *ndo,
                return dp;
        if (ndo->ndo_vflag) {
                ND_TCHECK(dp[1]);
-               ND_PRINT((ndo, " verf %08x%08x", dp[0], dp[1]));
+               ND_PRINT((ndo, " verf %08x%08x",
+                         EXTRACT_BE_U_4(dp), EXTRACT_BE_U_4(dp + 1)));
                dp += 2;
        }
        return dp;
@@ -1447,8 +1452,8 @@ static void
 interp_reply(netdissect_options *ndo,
              const struct sunrpc_msg *rp, uint32_t proc, uint32_t vers, int length)
 {
-       register const uint32_t *dp;
-       register int v3;
+       const uint32_t *dp;
+       int v3;
        int er;
 
        v3 = (vers == NFS_VER3);