ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: [Ethereal-dev] [patch] Updates to NFSv4 dissector (packet-nfs.[ch])

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Mike Frisch <mfrisch@xxxxxxxxxx>
Date: Tue, 1 Jun 2004 12:03:50 -0400
This patch adds support for NFSv4 RELEASE_LOCKOWNER and ILLEGAL
operations.  Also included is a minor modification to the NFSv4 NULLPROC
dissection.
Index: packet-nfs.c
===================================================================
RCS file: /cvsroot/ethereal/packet-nfs.c,v
retrieving revision 1.96
diff -u -r1.96 packet-nfs.c
--- packet-nfs.c	25 Feb 2004 09:31:06 -0000	1.96
+++ packet-nfs.c	1 Jun 2004 16:00:49 -0000
@@ -1,7 +1,7 @@
 /* packet-nfs.c
  * Routines for nfs dissection
  * Copyright 1999, Uwe Girlich <Uwe.Girlich@xxxxxxxxxxx>
- * Copyright 2000-2002, Mike Frisch <frisch@xxxxxxxxxxxxxxx> (NFSv4 decoding)
+ * Copyright 2000-2004, Mike Frisch <frisch@xxxxxxxxxxxxxxx> (NFSv4 decoding)
  * $Id: packet-nfs.c,v 1.96 2004/02/25 09:31:06 guy Exp $
  *
  * Ethereal - Network traffic analyzer
@@ -378,6 +378,8 @@
 static gint ett_nfs_setclientid_confirm4 = -1;
 static gint ett_nfs_verify4 = -1;
 static gint ett_nfs_write4 = -1;
+static gint ett_nfs_release_lockowner4 = -1;
+static gint ett_nfs_illegal4 = -1;
 static gint ett_nfs_verifier4 = -1;
 static gint ett_nfs_opaque = -1;
 static gint ett_nfs_dirlist4 = -1;
@@ -6668,6 +6670,8 @@
 	{	NFS4_OP_SETCLIENTID_CONFIRM,	"SETCLIENTID_CONFIRM"	},
 	{	NFS4_OP_VERIFY,					"VERIFY"	},
 	{	NFS4_OP_WRITE,						"WRITE"	},
+	{	NFS4_OP_RELEASE_LOCKOWNER,		"RELEASE_LOCKOWNER"	},
+	{	NFS4_OP_ILLEGAL,					"ILLEGAL"	},
 	{ 0, NULL }
 };
 
@@ -6708,7 +6712,8 @@
 	 &ett_nfs_setclientid4 ,
 	 &ett_nfs_setclientid_confirm4 ,
 	 &ett_nfs_verify4 ,
-	 &ett_nfs_write4
+	 &ett_nfs_write4,
+    &ett_nfs_release_lockowner4,
 };
 
 static int
@@ -7080,12 +7085,20 @@
 			opcode);
 		offset += 4;
 
-		if (opcode < NFS4_OP_ACCESS || opcode > NFS4_OP_WRITE)
+		/* the opcodes are not contiguous */
+		if ((opcode < NFS4_OP_ACCESS || opcode > NFS4_OP_WRITE)	&&
+			(opcode != NFS4_OP_ILLEGAL))
 			break;
 
 		if (fitem == NULL)	break;
 
-		newftree = proto_item_add_subtree(fitem, *nfsv4_operation_ett[opcode-3]);
+		/* all of the V4 ops are contiguous, except for NFS4_OP_ILLEGAL */
+		if (opcode == NFS4_OP_ILLEGAL)
+			newftree = proto_item_add_subtree(fitem, ett_nfs_illegal4);
+		else
+			newftree = proto_item_add_subtree(fitem, 
+				*nfsv4_operation_ett[opcode - 3]);
+
 		if (newftree == NULL)	break;
 
 		switch(opcode)
@@ -7334,6 +7347,14 @@
 			offset = dissect_nfsdata(tvb, offset, newftree, hf_nfs_data);
 			break;
 
+		case NFS4_OP_RELEASE_LOCKOWNER:
+			offset = dissect_nfs_lock_owner4(tvb, offset, newftree);
+			break;
+
+		/* In theory, it's possible to get this opcode */
+		case NFS4_OP_ILLEGAL:
+			break;
+
 		default:
 			break;
 		}
@@ -7412,7 +7433,9 @@
 		opcode = tvb_get_ntohl(tvb, offset);
 
 		/* sanity check for bogus packets */
-		if (opcode < NFS4_OP_ACCESS || opcode > NFS4_OP_WRITE)	break;
+		if ((opcode < NFS4_OP_ACCESS || opcode > NFS4_OP_WRITE) &&
+			(opcode != NFS4_OP_ILLEGAL))
+			break;
 
 		fitem = proto_tree_add_uint(ftree, hf_nfs_resop4, tvb, offset, 4,
 			opcode);
@@ -7420,7 +7443,12 @@
 
 		if (fitem == NULL)	break;		/* error adding new item to tree */
 
-		newftree = proto_item_add_subtree(fitem, *nfsv4_operation_ett[opcode-3]);
+		/* all of the V4 ops are contiguous, except for NFS4_OP_ILLEGAL */
+		if (opcode == NFS4_OP_ILLEGAL)
+			newftree = proto_item_add_subtree(fitem, ett_nfs_illegal4);
+		else
+			newftree = proto_item_add_subtree(fitem, 
+				*nfsv4_operation_ett[opcode - 3]);
 
 		if (newftree == NULL)
 			break;		/* error adding new subtree to operation item */
@@ -7665,9 +7693,12 @@
 
 /* end of NFS Version 3 */
 
+/* the call to dissect_nfs3_null_call & dissect_nfs3_null_reply is 
+ * intentional.  The V4 NULLPROC is the same as V3.
+ */
 static const vsff nfs4_proc[] = {
 	{ 0, "NULL",
-	NULL, NULL },
+	dissect_nfs3_null_call,		dissect_nfs3_null_reply },
 	{ 1, "COMPOUND",
 	dissect_nfs4_compound_call, dissect_nfs4_compound_reply },
 	{ 0, NULL, NULL, NULL }
@@ -8697,6 +8728,8 @@
 		&ett_nfs_setclientid_confirm4,
 		&ett_nfs_verify4,
 		&ett_nfs_write4,
+		&ett_nfs_release_lockowner4,
+		&ett_nfs_illegal4,
 		&ett_nfs_verifier4,
 		&ett_nfs_opaque,
 		&ett_nfs_dirlist4,
Index: packet-nfs.h
===================================================================
RCS file: /cvsroot/ethereal/packet-nfs.h,v
retrieving revision 1.17
diff -u -r1.17 packet-nfs.h
--- packet-nfs.h	28 Sep 2003 01:52:57 -0000	1.17
+++ packet-nfs.h	1 Jun 2004 16:00:55 -0000
@@ -84,6 +84,8 @@
 #define NFS4_OP_SETCLIENTID_CONFIRM		36
 #define NFS4_OP_VERIFY						37
 #define NFS4_OP_WRITE						38
+#define NFS4_OP_RELEASE_LOCKOWNER		39
+#define NFS4_OP_ILLEGAL						10044
 
 /* for write */
 #define UNSTABLE 0