]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Enhance NFS access request messages.
authorLucas C. Villa Real <[email protected]>
Tue, 26 Jan 2010 20:09:24 +0000 (12:09 -0800)
committerGuy Harris <[email protected]>
Tue, 26 Jan 2010 20:09:24 +0000 (12:09 -0800)
When debugging NFS operations one may find it easier to get the actual access
flags decoded rather than having to look up the NFS access flags to find which
permissions were requested by the client.

Reviewed-by: Guy Harris <[email protected]>
CREDITS
nfs.h
print-nfs.c

diff --git a/CREDITS b/CREDITS
index 2a51e8082f5966e593f2f7661c73a97b36390659..d3629b57d58cbe962a1a37ac580aeb3d8a911c84 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -101,6 +101,7 @@ Additional people who have contributed patches:
        Lennert Buytenhek               <buytenh at gnu dot org>
        Loris Degioanni                 <loris at netgroup-serv dot polito dot it>
        Love Hörnquist-Ã…strand                <lha at stacken dot kth dot se>
+       Lucas C. Villa Real             <lucasvr at us dot ibm dot com>
        Luis Martin Garcia              <luis dot mgarc at gmail dot com>
        Maciej W. Rozycki               <macro at ds2 dot pg dot gda dot pl>
        Manu Pathak                     <mapathak at cisco dot com>
diff --git a/nfs.h b/nfs.h
index e43f7ffccdda6ddb4052537cc3fd60ea73668bf2..a5b502582aeb6da7d1c21ff0d383112ab4897c9b 100644 (file)
--- a/nfs.h
+++ b/nfs.h
 #define NFSV3ACCESS_EXTEND             0x08
 #define NFSV3ACCESS_DELETE             0x10
 #define NFSV3ACCESS_EXECUTE            0x20
+#define NFSV3ACCESS_FULL               0x3f
 
 #define NFSV3WRITE_UNSTABLE            0
 #define NFSV3WRITE_DATASYNC            1
index 1ed2cdfbfceb1b15644143373283d46f7f50b50e..4d17757f311457e72a5e12eb7847c67fdc52229f 100644 (file)
@@ -508,6 +508,7 @@ nfsreq_print(register const u_char *bp, u_int length,
        nfs_type type;
        int v3;
        u_int32_t proc;
+       u_int32_t access_flags;
        struct nfsv3_sattr sa3;
        char srcid[20], dstid[20];      /*fits 32bit*/
 
@@ -570,7 +571,37 @@ nfsreq_print(register const u_char *bp, u_int length,
                if ((dp = parsereq(rp, length)) != NULL &&
                    (dp = parsefh(dp, v3)) != NULL) {
                        TCHECK(dp[0]);
-                       printf(" %04x", EXTRACT_32BITS(&dp[0]));
+                       access_flags = EXTRACT_32BITS(&dp[0]);
+                       if (access_flags & ~NFSV3ACCESS_FULL) {
+                               /* NFSV3ACCESS definitions aren't up to date */
+                               printf(" %04x", access_flags);
+                       } else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) {
+                               printf(" NFS_ACCESS_FULL");
+                       } else {
+                               char separator = ' ';
+                               if (access_flags & NFSV3ACCESS_READ) {
+                                       printf(" NFS_ACCESS_READ");
+                                       separator = '|';
+                               }
+                               if (access_flags & NFSV3ACCESS_LOOKUP) {
+                                       printf("%cNFS_ACCESS_LOOKUP", separator);
+                                       separator = '|';
+                               }
+                               if (access_flags & NFSV3ACCESS_MODIFY) {
+                                       printf("%cNFS_ACCESS_MODIFY", separator);
+                                       separator = '|';
+                               }
+                               if (access_flags & NFSV3ACCESS_EXTEND) {
+                                       printf("%cNFS_ACCESS_EXTEND", separator);
+                                       separator = '|';
+                               }
+                               if (access_flags & NFSV3ACCESS_DELETE) {
+                                       printf("%cNFS_ACCESS_DELETE", separator);
+                                       separator = '|';
+                               }
+                               if (access_flags & NFSV3ACCESS_EXECUTE)
+                                       printf("%cNFS_ACCESS_EXECUTE", separator);
+                       }
                        return;
                }
                break;