Ethereal-dev: [Ethereal-dev] Patch for packet-scsi.c with variable length CDB

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

Date: Mon, 11 Mar 2002 22:50:20 -0800
Hi,

Here is a patch that decodes just the barebones variable-length CDB. 

Dinesh
--
Index: packet-scsi.c
===================================================================
RCS file: /cvsroot/ethereal/packet-scsi.c,v
retrieving revision 1.5
diff -u -u -r1.5 packet-scsi.c
--- packet-scsi.c	2002/02/13 01:17:58	1.5
+++ packet-scsi.c	2002/03/12 06:41:51
@@ -156,6 +156,8 @@
 static int hf_scsi_persresv_key          = -1;
 static int hf_scsi_persresv_scopeaddr    = -1;
 static int hf_scsi_sscopcode             = -1;
+static int hf_scsi_add_cdblen = -1;
+static int hf_scsi_svcaction = -1;
 
 
 static gint ett_scsi         = -1;
@@ -196,6 +198,7 @@
 #define SCSI_SPC2_SETDEVICEID            0xA4
 #define SCSI_SPC2_TESTUNITRDY            0x00
 #define SCSI_SPC2_WRITEBUFFER            0x3B
+#define SCSI_SPC2_VARLENCDB              0x7F
 
 static const value_string scsi_spc2_val[] = {
     {SCSI_SPC2_EXTCOPY           , "Extended Copy"},
@@ -221,6 +224,7 @@
     {SCSI_SPC2_RESERVE10         , "Reserve (10)"},
     {SCSI_SPC2_TESTUNITRDY       , "Test Unit Ready"},
     {SCSI_SPC2_WRITEBUFFER       , "Write Buffer"},
+    {SCSI_SPC2_VARLENCDB         , "Var Len CDB"},
     {0, NULL},
 };
 
@@ -2620,6 +2624,22 @@
     }
 }
 
+static void
+dissect_scsi_varlencdb (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+                        guint offset, gboolean isreq, gboolean iscdb)
+{
+    guint8 flags;
+
+    if (!tree)
+        return;
+    
+    if (isreq && iscdb) {
+        proto_tree_add_item (tree, hf_scsi_control, tvb, offset, 1, 0);
+        proto_tree_add_item (tree, hf_scsi_add_cdblen, tvb, offset+6, 1, 0);
+        proto_tree_add_item (tree, hf_scsi_svcaction, tvb, offset+7, 2, 0);
+    }
+}
+
 void
 dissect_scsi_rsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
@@ -2866,6 +2886,11 @@
                                       TRUE, TRUE);
             break;
 
+        case SCSI_SPC2_VARLENCDB:
+            dissect_scsi_varlencdb (tvb, pinfo, scsi_tree, offset+1,
+                                    TRUE, TRUE);
+            break;
+
         default:
             call_dissector (data_handle, tvb, pinfo, scsi_tree);
             break;
@@ -3384,6 +3409,12 @@
            0x0, "", HFILL}},
         { &hf_scsi_persresv_scopeaddr,
           {"Scope Address", "scsi.spc2.resv.scopeaddr", FT_BYTES, BASE_HEX, NULL,
+           0x0, "", HFILL}},
+        { &hf_scsi_add_cdblen,
+          {"Additional CDB Length", "scsi.spc2.addcdblen", FT_UINT8, BASE_DEC,
+           NULL, 0x0, "", HFILL}},
+        { &hf_scsi_svcaction,
+          {"Service Action", "scsi.spc2.svcaction", FT_UINT16, BASE_HEX, NULL,
            0x0, "", HFILL}},
     };
 

-- 
Out beyond the ideas of right-doing and wrong-doing there is a field. I'll meet
you there. - Rumi