Ethereal-dev: [Ethereal-dev] update on packet-scsi.c

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

From: Ming Zhang <mingz@xxxxxxxxxxx>
Date: Sat, 11 Mar 2006 20:51:08 -0500
enhanced packet-scsi.c a bit to decode 3 more scsi commands

getperformance
setcdspeed
readdiscstructure.


 packet-scsi.c |  139
++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 135 insertions(+), 4 deletions(-)

Signed off by Ming Zhang <mingz@xxxxxxxxxxx>

Please merge.

Ming

Index: epan/dissectors/packet-scsi.c
===================================================================
--- epan/dissectors/packet-scsi.c	(revision 17597)
+++ epan/dissectors/packet-scsi.c	(working copy)
@@ -193,6 +193,7 @@ static int hf_scsi_report_key_vendor_res
 static int hf_scsi_report_key_user_changes = -1;
 static int hf_scsi_report_key_region_mask = -1;
 static int hf_scsi_report_key_rpc_scheme = -1;
+static int hf_scsi_setcdspeed_rc = -1;
 static int hf_scsi_getconf_rt = -1;
 static int hf_scsi_getconf_starting_feature = -1;
 static int hf_scsi_getconf_current_profile = -1;
@@ -512,7 +513,10 @@ static const value_string scsi_sbc2_val[
 #define SCSI_MMC_REPORTKEY		0xa4
 #define SCSI_MMC_READ12                 0xa8
 #define SCSI_MMC_WRITE12                0xaa
+#define SCSI_MMC_GETPERFORMANCE         0xac
+#define SCSI_MMC_READDISCSTRUCTURE      0xad
 #define SCSI_MMC_SETSTREAMING           0xb6
+#define SCSI_MMC_SETCDSPEED             0xbb
 static const value_string scsi_mmc_val[] = {
     {SCSI_SBC2_STARTSTOPUNIT, "Start Stop Unit"},
     {SCSI_MMC_READCAPACITY10,	"Read Capacity(10)"},
@@ -529,7 +533,10 @@ static const value_string scsi_mmc_val[]
     {SCSI_MMC_REPORTKEY,	"Report Key"},
     {SCSI_MMC_READ12,		"Read(12)"},
     {SCSI_MMC_WRITE12,		"Write(12)"},
+    {SCSI_MMC_GETPERFORMANCE,   "Get Performance"},
+    {SCSI_MMC_READDISCSTRUCTURE, "Read DISC Structure"},
     {SCSI_MMC_SETSTREAMING,	"Set Streaming"},
+    {SCSI_MMC_SETCDSPEED,       "Set CD Speed"},
     {0, NULL},
 };
 
@@ -776,10 +783,14 @@ static const value_string scsi_smc2_mode
     {0, NULL},
 };
 
+#define SCSI_MMC5_MODEPAGE_MRW     0x03  /* MRW */
+#define SCSI_MMC5_MODEPAGE_WRPARAM 0x05  /* Write Parameters */
 #define SCSI_MMC3_MODEPAGE_MMCAP   0x2A  /* device capabilities */
 
 static const value_string scsi_mmc5_modepage_val[] = {
-    {SCSI_MMC3_MODEPAGE_MMCAP,   "MM Capabilities and Mechanical Status"},
+    {SCSI_MMC5_MODEPAGE_MRW,      "MRW"},
+    {SCSI_MMC5_MODEPAGE_WRPARAM,  "Write Parameters"},
+    {SCSI_MMC3_MODEPAGE_MMCAP,    "MM Capabilities and Mechanical Status"},
     {0x3F,                        "Return All Mode Pages"},
     {0, NULL},
 };
@@ -3847,6 +3858,7 @@ static const value_string scsi_setstream
     {0x05,	"DBI cache zone descriptor"},
     {0,NULL}
 };
+
 static void
 dissect_mmc4_setstreaming (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                      guint offset, gboolean isreq, gboolean iscdb,
@@ -3891,6 +3903,40 @@ dissect_mmc4_setstreaming (tvbuff_t *tvb
     }
 }
 
+static const value_string scsi_setcdspeed_rc_val[] = {
+    {0x00,	"CLV and none-pure CAV"},
+    {0x01,	"Pure CAV"},
+    {0x02,	"Reserved"},
+    {0x03,	"Reserved"},
+    {0,NULL}
+};
+
+static void
+dissect_mmc4_setcdspeed (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
+                     guint offset, gboolean isreq, gboolean iscdb,
+                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
+
+{
+    guint8 flags, type;
+
+    if (tree && isreq && iscdb) {
+        proto_tree_add_item (tree, hf_scsi_setcdspeed_rc, tvb, offset+0, 1, 0);
+
+        proto_tree_add_text (tree, tvb, offset+1, 2,
+                             "Logical Unit Read Speed(bytes/sec): %u",
+                             tvb_get_ntohs (tvb, offset+1));
+        proto_tree_add_text (tree, tvb, offset+3, 2,
+                             "Logical Unit Write Speed(bytes/sec): %u",
+                             tvb_get_ntohs (tvb, offset+3));
+
+        flags = tvb_get_guint8 (tvb, offset+10);
+        proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
+                                    flags,
+                                    "Vendor Unique = %u, NACA = %u, Link = %u",
+                                    flags & 0xC0, flags & 0x4, flags & 0x1);
+    }
+}
+
 static const value_string scsi_getconf_rt_val[] = {
     {0x00,	"Return all features"},
     {0x01,	"Return all current features"},
@@ -4222,6 +4268,41 @@ dissect_mmc4_readtocpmaatip (tvbuff_t *t
     }
 }
 
+static void
+dissect_mmc4_getperformance (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
+                     guint offset, gboolean isreq, gboolean iscdb,
+                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
+
+{
+    guint8 flags;
+
+    if (tree && isreq && iscdb) {
+        flags = tvb_get_guint8 (tvb, offset);
+        proto_tree_add_text (tree, tvb, offset, 1, 
+                             "Data Type: %u",
+                             flags & 0x1f);
+
+        proto_tree_add_text (tree, tvb, offset+1, 4, 
+                             "Starting LBA: %u",
+                             tvb_get_ntohs (tvb, offset+1));
+
+        proto_tree_add_text (tree, tvb, offset+7, 2, 
+                             "Maximum Number of Descriptors: %u",
+                             tvb_get_ntohs (tvb, offset+7));
+
+        flags = tvb_get_guint8 (tvb, offset+9);
+        proto_tree_add_text (tree, tvb, offset+9, 1, 
+                             "Type: %u",
+                             flags);
+
+        flags = tvb_get_guint8 (tvb, offset+10);
+        proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
+                                    flags,
+                                    "Vendor Unique = %u, NACA = %u, Link = %u",
+                                    flags & 0xC0, flags & 0x4, flags & 0x1);
+
+    }
+}
 
 static void
 dissect_mmc4_synchronizecache (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
@@ -4245,6 +4326,7 @@ dissect_mmc4_synchronizecache (tvbuff_t 
 
     }
 }
+
 static void
 dissect_mmc4_readbuffercapacity (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                      guint offset, gboolean isreq, gboolean iscdb,
@@ -4282,6 +4364,7 @@ dissect_mmc4_readbuffercapacity (tvbuff_
         }
     }
 }
+
 static void
 dissect_mmc4_reservetrack (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                      guint offset, gboolean isreq, gboolean iscdb,
@@ -4308,6 +4391,7 @@ static const value_string scsi_rti_addre
     {0x02,	"Session Number"},
     {0,NULL}
 };
+
 static void
 dissect_mmc4_readtrackinformation (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                      guint offset, gboolean isreq, gboolean iscdb,
@@ -4376,6 +4460,7 @@ static const value_string scsi_disc_info
     {0x03,	"Complete Session"},
     {0,NULL}
 };
+
 static const value_string scsi_disc_info_disc_status_val[] = {
     {0x00,	"Empty Disc"},
     {0x01,	"Incomplete Disc"},
@@ -4383,6 +4468,7 @@ static const value_string scsi_disc_info
     {0x03,	"Others"},
     {0,NULL}
 };
+
 static const value_string scsi_disc_info_bgfs_val[] = {
     {0x00,	"Blank or not CD-RW/DVD-RW"},
     {0x01,	"Background Format started but is not running nor complete"},
@@ -4390,6 +4476,7 @@ static const value_string scsi_disc_info
     {0x03,	"Backgroung Format has completed"},
     {0,NULL}
 };
+
 static const value_string scsi_disc_info_disc_type_val[] = {
     {0x00,	"CD-DA or CD-ROM Disc"},
     {0x10,	"CD-I Disc"},
@@ -4444,6 +4531,47 @@ dissect_mmc4_readdiscinformation (tvbuff
 }
 
 static void
+dissect_mmc4_readdiscstructure (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
+                     guint offset, gboolean isreq, gboolean iscdb,
+                     guint payload_len _U_, scsi_task_data_t *cdata _U_)
+
+{
+    guint8 flags;
+
+    if (tree && isreq && iscdb) {
+        flags = tvb_get_guint8 (tvb, offset);
+        proto_tree_add_text (tree, tvb, offset, 1,
+                             "Sub-Command: %u",
+                             flags & 0x0f);
+
+        proto_tree_add_text (tree, tvb, offset+1, 4,
+                             "Address: %u",
+                             tvb_get_ntohs (tvb, offset+1));
+
+        proto_tree_add_text (tree, tvb, offset+5, 1,
+                             "Layer Number: %u",
+                             tvb_get_ntohs (tvb, offset+5));
+
+        proto_tree_add_text (tree, tvb, offset+6, 1,
+                             "Format Code: %u",
+                             tvb_get_ntohs (tvb, offset+6));
+
+        proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+7, 2, 0);
+
+        flags = tvb_get_guint8 (tvb, offset+9);
+        proto_tree_add_text (tree, tvb, offset+9, 1,
+                             "AGID: %u",
+                             flags & 0xc0);
+
+        flags = tvb_get_guint8 (tvb, offset+10);
+        proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+10, 1,
+                                    flags,
+                                    "Vendor Unique = %u, NACA = %u, Link = %u",
+                                    flags & 0xC0, flags & 0x4, flags & 0x1);
+    }
+}
+
+static void
 dissect_sbc2_readcapacity10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
                            guint offset, gboolean isreq, gboolean iscdb,
                            guint payload_len _U_, scsi_task_data_t *cdata _U_)
@@ -6950,8 +7078,8 @@ static scsi_cdb_table_t mmc[256] = {
 /*MMC 0xa9*/{NULL},
 /*MMC 0xaa*/{dissect_sbc2_readwrite12},
 /*MMC 0xab*/{NULL},
-/*MMC 0xac*/{NULL},
-/*MMC 0xad*/{NULL},
+/*MMC 0xac*/{dissect_mmc4_getperformance},
+/*MMC 0xad*/{dissect_mmc4_readdiscstructure},
 /*MMC 0xae*/{NULL},
 /*MMC 0xaf*/{NULL},
 /*MMC 0xb0*/{NULL},
@@ -6965,7 +7093,7 @@ static scsi_cdb_table_t mmc[256] = {
 /*MMC 0xb8*/{NULL},
 /*MMC 0xb9*/{NULL},
 /*MMC 0xba*/{NULL},
-/*MMC 0xbb*/{NULL},
+/*MMC 0xbb*/{dissect_mmc4_setcdspeed},
 /*MMC 0xbc*/{NULL},
 /*MMC 0xbd*/{NULL},
 /*MMC 0xbe*/{NULL},
@@ -7590,6 +7718,9 @@ proto_register_scsi (void)
         { &hf_scsi_report_key_rpc_scheme,
           {"RPC Scheme", "scsi.report_key.rpc_scheme", FT_UINT8, BASE_HEX,
            VALS(scsi_report_key_rpc_scheme_val), 0, "", HFILL}},
+        { &hf_scsi_setcdspeed_rc,
+          {"Rotational Control", "scsi.setcdspeed.rc", FT_UINT8, BASE_HEX,
+           VALS(scsi_setcdspeed_rc_val), 0x03, "", HFILL}},
         { &hf_scsi_getconf_rt,
           {"RT", "scsi.getconf.rt", FT_UINT8, BASE_HEX,
            VALS(scsi_getconf_rt_val), 0x03, "", HFILL}},