diff options
author | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2010-12-06 22:00:08 +0000 |
---|---|---|
committer | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2010-12-06 22:00:08 +0000 |
commit | c0565d89362a36ca02780196fa69f2330ffee5c3 (patch) | |
tree | 8163eef2e4fd2b7f1c0114a7ba829fe95280b883 | |
parent | 36deb61faaefbb1047e6b582ae8ebbc388b2887b (diff) |
Improve dissection of bit-oriented fields. Patch from Richard Sharpe via
bug #5466 with some minor whitespace modifications from me and a fix of an
invalid offset introduced with the patch. Fuzz testing still needs to be done.
I can't seem to get the fuzz tester to work with the capture files attached to
the bug report.
svn path=/trunk/; revision=35137
-rw-r--r-- | epan/dissectors/packet-scsi-mmc.c | 151 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi-sbc.c | 479 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi-smc.c | 81 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi-ssc.c | 315 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi.c | 273 | ||||
-rw-r--r-- | epan/dissectors/packet-scsi.h | 2 |
6 files changed, 427 insertions, 874 deletions
diff --git a/epan/dissectors/packet-scsi-mmc.c b/epan/dissectors/packet-scsi-mmc.c index 64370687e5..71d9ab58dd 100644 --- a/epan/dissectors/packet-scsi-mmc.c +++ b/epan/dissectors/packet-scsi-mmc.c @@ -356,7 +356,6 @@ dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; gint32 len; guint old_offset; tvbuff_t *volatile tvb_v = tvb; @@ -365,18 +364,13 @@ dissect_mmc4_getconfiguration (tvbuff_t *tvb, packet_info *pinfo _U_, if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_mmc_getconf_rt, tvb_v, offset_v+0, 1, 0); proto_tree_add_item (tree, hf_scsi_mmc_getconf_starting_feature, tvb_v, offset_v+1, 2, 0); - proto_tree_add_item (tree, hf_scsi_alloclen16, tvb_v, offset_v+6, 2, 0); /* we need the alloc_len in the response */ if(cdata){ cdata->itlq->alloc_len=tvb_get_ntohs(tvb_v, offset_v+6); } - - flags = tvb_get_guint8 (tvb_v, offset_v+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb_v, offset_v+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(!isreq) { if(!cdata){ @@ -531,7 +525,7 @@ dissect_mmc4_readtocpmaatip (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags, format; + guint8 format; gint16 len; if (tree && isreq && iscdb) { @@ -565,13 +559,8 @@ dissect_mmc4_readtocpmaatip (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * } proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { len=tvb_get_ntohs(tvb, offset); @@ -647,17 +636,10 @@ dissect_mmc4_readdiscinformation (tvbuff_t *tvb, packet_info *pinfo _U_, proto_t guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, 0, 2, 0); @@ -698,25 +680,22 @@ dissect_mmc4_readdiscstructure (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre proto_tree_add_text (tree, tvb, offset+1, 4, "Address: %u", tvb_get_ntohl (tvb, offset+1)); - proto_tree_add_text (tree, tvb, offset+5, 1, "Layer Number: %u", tvb_get_guint8 (tvb, offset+5)); cdata->itlq->flags=tvb_get_guint8 (tvb, offset+6); proto_tree_add_uint (tree, hf_scsi_mmc_read_dvd_format, tvb, offset+6, 1, cdata->itlq->flags); - + 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); + + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { proto_item *ti; @@ -815,26 +794,20 @@ proto_tree *tree, 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_ntohl (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); - + + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -844,20 +817,13 @@ dissect_mmc4_synchronizecache (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_mmc_synccache_immed, tvb, offset, 1, 0); proto_tree_add_item (tree, hf_scsi_mmc_synccache_reladr, tvb, offset, 1, 0); proto_tree_add_item (tree, hf_scsi_mmc_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_mmc_num_blocks, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -896,7 +862,7 @@ dissect_mmc4_reportkey (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags, agid, key_format, key_class; + guint8 agid, key_format, key_class; proto_item *ti; if (tree && isreq && iscdb) { @@ -922,11 +888,8 @@ dissect_mmc4_reportkey (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, /* save key_class/key_format so we can decode the response */ cdata->itlq->flags=(key_format<<8)|key_class; - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { switch(cdata->itlq->flags){ @@ -961,7 +924,7 @@ dissect_mmc4_readtrackinformation (tvbuff_t *tvb, packet_info *pinfo _U_, proto_ guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags, addresstype; + guint8 addresstype; if (tree && isreq && iscdb) { addresstype=tvb_get_guint8(tvb, offset)&0x03; @@ -982,13 +945,8 @@ dissect_mmc4_readtrackinformation (tvbuff_t *tvb, packet_info *pinfo _U_, proto_ } proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, 0, 2, 0); @@ -1036,12 +994,8 @@ dissect_mmc4_geteventstatusnotification (tvbuff_t *tvb, packet_info *pinfo _U_, flags); proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1052,17 +1006,10 @@ dissect_mmc4_reservetrack (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_mmc_reservation_size, tvb, offset+4, 4, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1083,8 +1030,6 @@ dissect_mmc4_close_track (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre guint payload_len _U_, scsi_task_data_t *cdata _U_) { - int flags; - if (tree && isreq && iscdb) { /* immediate */ proto_tree_add_item (tree, hf_scsi_mmc_closetrack_immed, tvb, offset, 1, 0); @@ -1104,12 +1049,8 @@ dissect_mmc4_close_track (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre /* reserved */ offset+=3; - flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1120,8 +1061,6 @@ dissect_mmc4_readbuffercapacity (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (tree && isreq && iscdb) { cdata->itlq->flags=0; proto_tree_add_item (tree, hf_scsi_mmc_rbc_block, tvb, offset, 1, 0); @@ -1130,13 +1069,8 @@ dissect_mmc4_readbuffercapacity (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr } proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); - + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && (!isreq)) { proto_tree_add_item (tree, hf_scsi_mmc_data_length, tvb, offset, 2, 0); @@ -1165,23 +1099,16 @@ dissect_mmc4_setcdspeed (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_mmc_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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1198,7 +1125,7 @@ dissect_mmc4_setstreaming (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags, type; + guint8 type; proto_item *ti; if (tree && isreq && iscdb) { @@ -1206,12 +1133,8 @@ dissect_mmc4_setstreaming (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr cdata->itlq->flags=type; proto_tree_add_item (tree, hf_scsi_mmc_setstreaming_type, tvb, offset+7, 1, 0); proto_tree_add_item (tree, hf_scsi_mmc_setstreaming_param_len, tvb, offset+8, 2, 0); - - 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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } if(tree && isreq && (!iscdb)) { switch(cdata->itlq->flags){ diff --git a/epan/dissectors/packet-scsi-sbc.c b/epan/dissectors/packet-scsi-sbc.c index 5e0a5e90b1..118b798245 100644 --- a/epan/dissectors/packet-scsi-sbc.c +++ b/epan/dissectors/packet-scsi-sbc.c @@ -166,7 +166,6 @@ dissect_sbc_formatunit (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; static const int *fuflags_fields[] = { &hf_scsi_sbc_fuflags_fmtpinfo, &hf_scsi_sbc_fuflags_rto_req, @@ -181,17 +180,12 @@ dissect_sbc_formatunit (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_formatunit_flags, ett_scsi_format_unit, fuflags_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_formatunit_vendor, tvb, offset+1, - 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_formatunit_interleave, tvb, offset+2, - 2, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_formatunit_flags, + ett_scsi_format_unit, fuflags_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_formatunit_vendor, tvb, offset+1, 1, 0); + proto_tree_add_item (tree, hf_scsi_sbc_formatunit_interleave, tvb, offset+2, 2, 0); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } /* TODO : add dissection of DATA */ } @@ -201,8 +195,6 @@ dissect_sbc_read6 (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 (isreq && iscdb) { if (check_col (pinfo->cinfo, COL_INFO)) col_append_fstr (pinfo->cinfo, COL_INFO, "(LBA: 0x%06x, Len: %u)", @@ -213,11 +205,8 @@ dissect_sbc_read6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_sbc_rdwr6_lba, tvb, offset, 3, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr6_xferlen, tvb, offset+3, 1, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -226,8 +215,6 @@ dissect_sbc_write6 (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 (isreq && iscdb) { if (check_col (pinfo->cinfo, COL_INFO)) col_append_fstr (pinfo->cinfo, COL_INFO, "(LBA: 0x%06x, Len: %u)", @@ -238,11 +225,8 @@ dissect_sbc_write6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (tree && isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_sbc_rdwr6_lba, tvb, offset, 3, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr6_xferlen, tvb, offset+3, 1, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -252,7 +236,6 @@ dissect_sbc_prefetch10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *prefetch_fields[] = { &hf_scsi_sbc_prefetch_immed, NULL @@ -266,18 +249,13 @@ dissect_sbc_prefetch10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_prefetch_flags, ett_scsi_prefetch, prefetch_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_prefetch_flags, + ett_scsi_prefetch, prefetch_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -287,7 +265,6 @@ dissect_sbc_synchronizecache10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *sync_fields[] = { &hf_scsi_sbc_synccache_sync_nv, &hf_scsi_sbc_synccache_immed, @@ -302,18 +279,13 @@ dissect_sbc_synchronizecache10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_synccache_flags, ett_scsi_synccache, sync_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_synccache_flags, + ett_scsi_synccache, sync_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -323,7 +295,6 @@ dissect_sbc_synchronizecache16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *sync_fields[] = { &hf_scsi_sbc_synccache_sync_nv, &hf_scsi_sbc_synccache_immed, @@ -338,17 +309,13 @@ dissect_sbc_synchronizecache16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_synccache_flags, ett_scsi_synccache, sync_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_synccache_flags, + ett_scsi_synccache, sync_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr16_lba, tvb, offset+1, 8, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+9, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -358,7 +325,6 @@ dissect_sbc_prefetch16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *prefetch_fields[] = { &hf_scsi_sbc_prefetch_immed, NULL @@ -372,17 +338,13 @@ dissect_sbc_prefetch16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_prefetch_flags, ett_scsi_prefetch, prefetch_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_prefetch_flags, + ett_scsi_prefetch, prefetch_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr16_lba, tvb, offset+1, 8, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+9, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -392,7 +354,6 @@ dissect_sbc_read10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *rdwr10_fields[] = { &hf_scsi_sbc_rdprotect, &hf_scsi_sbc_dpo, @@ -409,17 +370,13 @@ dissect_sbc_read10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -429,7 +386,6 @@ dissect_sbc_xdread10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *xdread10_fields[] = { &hf_scsi_sbc_xorpinfo, NULL @@ -443,17 +399,13 @@ dissect_sbc_xdread10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdread_flags, ett_scsi_xdread, xdread10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdread_flags, + ett_scsi_xdread, xdread10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -463,7 +415,6 @@ dissect_sbc_xdwrite10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *xdwrite10_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -481,17 +432,13 @@ dissect_sbc_xdwrite10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdwrite_flags, ett_scsi_xdwrite, xdwrite10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdwrite_flags, + ett_scsi_xdwrite, xdwrite10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -501,7 +448,6 @@ dissect_sbc_xdwriteread10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *xdwriteread10_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -520,17 +466,13 @@ dissect_sbc_xdwriteread10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdwriteread_flags, ett_scsi_xdwriteread, xdwriteread10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xdwriteread_flags, + ett_scsi_xdwriteread, xdwriteread10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -540,7 +482,6 @@ dissect_sbc_xpwrite10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *xpwrite10_fields[] = { &hf_scsi_sbc_dpo, &hf_scsi_sbc_fua, @@ -557,17 +498,13 @@ dissect_sbc_xpwrite10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xpwrite_flags, ett_scsi_xpwrite, xpwrite10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_xpwrite_flags, + ett_scsi_xpwrite, xpwrite10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -577,7 +514,6 @@ dissect_sbc_write10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *rdwr10_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -594,17 +530,13 @@ dissect_sbc_write10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -613,7 +545,6 @@ dissect_sbc_read12 (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; static const int *rdwr12_fields[] = { &hf_scsi_sbc_rdprotect, &hf_scsi_sbc_dpo, @@ -630,17 +561,13 @@ dissect_sbc_read12 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr12_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr12_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+5, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); - - 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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } void @@ -648,7 +575,6 @@ dissect_sbc_write12 (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; static const int *rdwr12_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -665,17 +591,13 @@ dissect_sbc_write12 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr12_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr12_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+5, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); - - 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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -684,7 +606,6 @@ dissect_sbc_read16 (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; static const int *rdwr16_fields[] = { &hf_scsi_sbc_rdprotect, &hf_scsi_sbc_dpo, @@ -701,17 +622,13 @@ dissect_sbc_read16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr16_lba, tvb, offset+1, 8, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+9, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } static void @@ -719,7 +636,6 @@ dissect_sbc_write16 (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; static const int *rdwr16_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -736,17 +652,13 @@ dissect_sbc_write16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, ett_scsi_rdwr, rdwr16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_read_flags, + ett_scsi_rdwr, rdwr16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr16_lba, tvb, offset+1, 8, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+9, 4, 0); proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -772,7 +684,6 @@ dissect_sbc_startstopunit (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr guint offset, gboolean isreq _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *ssu_fields[] = { &hf_scsi_sbc_ssu_immed, NULL @@ -788,16 +699,12 @@ dissect_sbc_startstopunit (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_ssu_immed_flags, ett_scsi_ssu_immed, ssu_fields, FALSE); - - proto_tree_add_bitmask(tree, tvb, offset+3, hf_scsi_sbc_ssu_pwr_flags, ett_scsi_ssu_pwr, pwr_fields, FALSE); - - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_ssu_immed_flags, + ett_scsi_ssu_immed, ssu_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+3, hf_scsi_sbc_ssu_pwr_flags, + ett_scsi_ssu_pwr, pwr_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -807,7 +714,6 @@ dissect_sbc_verify10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *verify10_fields[] = { &hf_scsi_sbc_vrprotect, &hf_scsi_sbc_dpo, @@ -823,17 +729,13 @@ dissect_sbc_verify10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, ett_scsi_verify, verify10_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_verify_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - - proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, + ett_scsi_verify, verify10_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_verify_lba, tvb, offset+1, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); + proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen, tvb, offset+6, 2, 0); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -843,7 +745,6 @@ dissect_sbc_verify12 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *verify12_fields[] = { &hf_scsi_sbc_vrprotect, &hf_scsi_sbc_dpo, @@ -859,19 +760,13 @@ dissect_sbc_verify12 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, ett_scsi_verify, verify12_fields, FALSE); - - - proto_tree_add_item (tree, hf_scsi_sbc_verify_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen32, tvb, offset+5, 4, 0); - - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); - - 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); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, + ett_scsi_verify, verify12_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_verify_lba, tvb, offset+1, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen32, tvb, offset+5, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -881,7 +776,6 @@ dissect_sbc_verify16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *verify16_fields[] = { &hf_scsi_sbc_vrprotect, &hf_scsi_sbc_dpo, @@ -897,17 +791,13 @@ dissect_sbc_verify16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, ett_scsi_verify, verify16_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_verify_lba64, tvb, offset+1, 8, 0); - proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen32, tvb, offset+9, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_verify_flags, + ett_scsi_verify, verify16_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_verify_lba64, tvb, offset+1, 8, 0); + proto_tree_add_item (tree, hf_scsi_sbc_verify_vlen32, tvb, offset+9, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -919,7 +809,6 @@ dissect_sbc_wrverify10 (tvbuff_t *tvb, packet_info *pinfo _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *wrverify10_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -935,18 +824,13 @@ dissect_sbc_wrverify10 (tvbuff_t *tvb, packet_info *pinfo _U_, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, ett_scsi_wrverify, wrverify10_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen, tvb, offset+6, - 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, + ett_scsi_wrverify, wrverify10_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba, tvb, offset+1, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen, tvb, offset+6, 2, 0); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -956,7 +840,6 @@ dissect_sbc_wrverify12 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *wrverify12_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -972,18 +855,13 @@ dissect_sbc_wrverify12 (tvbuff_t *tvb, packet_info *pinfo _U_, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, ett_scsi_wrverify, wrverify12_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen32, tvb, offset+5, - 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); - - 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); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, + ett_scsi_wrverify, wrverify12_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba, tvb, offset+1, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen32, tvb, offset+5, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+9, 1, 0); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -993,7 +871,6 @@ dissect_sbc_wrverify16 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *wrverify16_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_dpo, @@ -1009,28 +886,21 @@ dissect_sbc_wrverify16 (tvbuff_t *tvb, packet_info *pinfo _U_, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, ett_scsi_wrverify, wrverify16_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba64, tvb, offset+1, 8, 0); - proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen32, tvb, offset+9, - 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_wrverify_flags, + ett_scsi_wrverify, wrverify16_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_lba64, tvb, offset+1, 8, 0); + proto_tree_add_item (tree, hf_scsi_sbc_wrverify_xferlen32, tvb, offset+9, 4, 0); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } - void dissect_sbc_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_) { - guint8 flags; guint32 len, block_len, tot_len; const char *un; static const int *pmi_fields[] = { @@ -1042,16 +912,11 @@ dissect_sbc_readcapacity10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t return; if (isreq && iscdb) { - proto_tree_add_item (tree, hf_scsi_sbc_readcapacity_lba, tvb, offset+1, - 4, 0); - proto_tree_add_bitmask(tree, tvb, offset+7, hf_scsi_sbc_pmi_flags, ett_scsi_pmi, pmi_fields, FALSE); - - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_item (tree, hf_scsi_sbc_readcapacity_lba, tvb, offset+1, 4, 0); + proto_tree_add_bitmask(tree, tvb, offset+7, hf_scsi_sbc_pmi_flags, + ett_scsi_pmi, pmi_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!iscdb) { len = tvb_get_ntohl (tvb, offset); @@ -1073,7 +938,6 @@ dissect_sbc_readdefectdata10 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *defect_fields[] = { &hf_scsi_sbc_defect_list_format, &hf_scsi_sbc_req_plist, @@ -1085,14 +949,11 @@ dissect_sbc_readdefectdata10 (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_sbc_readdefdata_flags, ett_scsi_defectdata, defect_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_sbc_readdefdata_flags, + ett_scsi_defectdata, defect_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_alloclen16, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } /* TODO : add dissection of DATA */ } @@ -1104,7 +965,6 @@ dissect_sbc_readlong10 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *corrct_fields[] = { &hf_scsi_sbc_corrct, NULL @@ -1114,16 +974,12 @@ dissect_sbc_readlong10 (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_corrct_flags, ett_scsi_corrct, corrct_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_corrct_flags, + ett_scsi_corrct, corrct_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_alloclen16, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1133,20 +989,15 @@ dissect_sbc_writelong10 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; if (!tree) return; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_alloclen16, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1156,7 +1007,6 @@ dissect_sbc_writesame10 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *writesame10_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_pbdata, @@ -1168,18 +1018,13 @@ dissect_sbc_writesame10 (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_writesame_flags, ett_scsi_writesame, writesame10_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_writesame_flags, + ett_scsi_writesame, writesame10_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr10_lba, tvb, offset+1, 4, 0); - - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); - + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+5, 1, 0); proto_tree_add_item (tree, hf_scsi_sbc_alloclen16, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -1189,7 +1034,6 @@ dissect_sbc_writesame16 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *writesame16_fields[] = { &hf_scsi_sbc_wrprotect, &hf_scsi_sbc_pbdata, @@ -1201,28 +1045,22 @@ dissect_sbc_writesame16 (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_writesame_flags, ett_scsi_writesame, writesame16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_writesame_flags, + ett_scsi_writesame, writesame16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_rdwr16_lba, tvb, offset+1, 8, 0); proto_tree_add_item (tree, hf_scsi_sbc_rdwr12_xferlen, tvb, offset+9, 4, 0); - proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_item (tree, hf_scsi_sbc_group, tvb, offset+13, 1, 0); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } - static void dissect_sbc_readdefectdata12 (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; static const int *defect_fields[] = { &hf_scsi_sbc_defect_list_format, &hf_scsi_sbc_req_plist, @@ -1234,14 +1072,11 @@ dissect_sbc_readdefectdata12 (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_readdefdata_flags, ett_scsi_defectdata, defect_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_readdefdata_flags, + ett_scsi_defectdata, defect_fields, FALSE); proto_tree_add_item (tree, hf_scsi_sbc_alloclen32, tvb, offset+5, 4, 0); - 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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } /* TODO : add dissection of DATA */ } @@ -1253,7 +1088,6 @@ dissect_sbc_reassignblocks (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *reassign_fields[] = { &hf_scsi_sbc_reassignblocks_longlba, &hf_scsi_sbc_reassignblocks_longlist, @@ -1264,13 +1098,10 @@ dissect_sbc_reassignblocks (tvbuff_t *tvb, packet_info *pinfo _U_, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_reassignblks_flags, ett_scsi_reassign_blocks, reassign_fields, FALSE); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_reassignblks_flags, + ett_scsi_reassign_blocks, reassign_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } /* TODO : add dissection of DATA */ } @@ -1295,7 +1126,7 @@ dissect_sbc_serviceactionin16 (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 service_action, flags; + guint8 service_action; guint32 block_len; guint64 len, tot_len; char *un; @@ -1333,11 +1164,8 @@ dissect_sbc_serviceactionin16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_sbc_pmi_flags, ett_scsi_pmi, pmi_fields, FALSE); offset++; - flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); offset++; break; @@ -1363,11 +1191,8 @@ dissect_sbc_serviceactionin16 (tvbuff_t *tvb, packet_info *pinfo _U_, /* CORRCT bit */ offset++; - flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); offset++; break; diff --git a/epan/dissectors/packet-scsi-smc.c b/epan/dissectors/packet-scsi-smc.c index 9214c9920a..4113d15a94 100644 --- a/epan/dissectors/packet-scsi-smc.c +++ b/epan/dissectors/packet-scsi-smc.c @@ -69,7 +69,6 @@ dissect_smc_exchangemedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *exchg_fields[] = { &hf_scsi_smc_inv1, &hf_scsi_smc_inv2, @@ -84,15 +83,10 @@ dissect_smc_exchangemedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t proto_tree_add_item (tree, hf_scsi_smc_sa, tvb, offset+3, 2, 0); proto_tree_add_item (tree, hf_scsi_smc_fda, tvb, offset+5, 2, 0); proto_tree_add_item (tree, hf_scsi_smc_sda, tvb, offset+7, 2, 0); - - - proto_tree_add_bitmask(tree, tvb, offset+9, hf_scsi_smc_medium_flags, ett_scsi_exchange_medium, exchg_fields, FALSE); - - 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); + proto_tree_add_bitmask(tree, tvb, offset+9, hf_scsi_smc_medium_flags, + ett_scsi_exchange_medium, exchg_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -101,7 +95,6 @@ dissect_smc_position_to_element (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *pte_fields[] = { &hf_scsi_smc_invert, NULL @@ -113,14 +106,10 @@ dissect_smc_position_to_element (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_smc_mta, tvb, offset+1, 2, 0); proto_tree_add_item (tree, hf_scsi_smc_da, tvb, offset+3, 2, 0); - - proto_tree_add_bitmask(tree, tvb, offset+7, hf_scsi_smc_medium_flags, ett_scsi_exchange_medium, pte_fields, FALSE); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+7, hf_scsi_smc_medium_flags, + ett_scsi_exchange_medium, pte_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -129,17 +118,12 @@ dissect_smc_initialize_element_status (tvbuff_t *tvb, packet_info *pinfo _U_, pr guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree) return; if (isreq && iscdb) { - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -148,7 +132,6 @@ dissect_smc_initialize_element_status_with_range (tvbuff_t *tvb, packet_info *pi guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *range_fields[] = { &hf_scsi_smc_fast, &hf_scsi_smc_range, @@ -159,17 +142,12 @@ dissect_smc_initialize_element_status_with_range (tvbuff_t *tvb, packet_info *pi return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_smc_range_flags, ett_scsi_range, range_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_smc_range_flags, + ett_scsi_range, range_fields, FALSE); proto_tree_add_item (tree, hf_scsi_smc_sa, tvb, offset+1, 2, 0); - proto_tree_add_item (tree, hf_scsi_smc_num_elements, tvb, offset+5, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -178,21 +156,14 @@ dissect_smc_openclose_importexport_element (tvbuff_t *tvb, packet_info *pinfo _U guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree) return; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_smc_ea, tvb, offset+1, 2, 0); - proto_tree_add_item (tree, hf_scsi_smc_action_code, tvb, offset+3, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } void @@ -200,7 +171,6 @@ dissect_smc_movemedium (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; static const int *move_fields[] = { &hf_scsi_smc_invert, NULL @@ -213,14 +183,10 @@ dissect_smc_movemedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, proto_tree_add_item (tree, hf_scsi_smc_mta, tvb, offset+1, 2, 0); proto_tree_add_item (tree, hf_scsi_smc_sa, tvb, offset+3, 2, 0); proto_tree_add_item (tree, hf_scsi_smc_da, tvb, offset+5, 2, 0); - - proto_tree_add_bitmask(tree, tvb, offset+9, hf_scsi_smc_range_flags, ett_scsi_move, move_fields, FALSE); - - 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); + proto_tree_add_bitmask(tree, tvb, offset+9, hf_scsi_smc_range_flags, + ett_scsi_move, move_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -528,11 +494,8 @@ dissect_smc_readelementstatus (tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_text (tree, tvb, offset+6, 3, "Allocation Length: %u", tvb_get_ntoh24 (tvb, offset+6)); - 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); + proto_tree_add_bitmask(tree, tvb, offset+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!isreq) { proto_tree_add_text (tree, tvb, offset, 2, diff --git a/epan/dissectors/packet-scsi-ssc.c b/epan/dissectors/packet-scsi-ssc.c index 15a6df8658..260ea074cc 100644 --- a/epan/dissectors/packet-scsi-ssc.c +++ b/epan/dissectors/packet-scsi-ssc.c @@ -103,7 +103,6 @@ dissect_ssc_read6 (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; static const int *read6_fields[] = { &hf_scsi_ssc_sili, &hf_scsi_ssc_fixed, @@ -117,14 +116,11 @@ dissect_ssc_read6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, read6_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, read6_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -133,7 +129,6 @@ dissect_ssc_recoverbuffereddata (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *recover_fields[] = { &hf_scsi_ssc_sili, &hf_scsi_ssc_fixed, @@ -147,14 +142,11 @@ dissect_ssc_recoverbuffereddata (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, recover_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, recover_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -163,7 +155,6 @@ dissect_ssc_reportdensitysupport (tvbuff_t *tvb, packet_info *pinfo _U_, proto_t guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *rd_fields[] = { &hf_scsi_ssc_medium_type, &hf_scsi_ssc_media, @@ -180,14 +171,11 @@ dissect_ssc_reportdensitysupport (tvbuff_t *tvb, packet_info *pinfo _U_, proto_t return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rd_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, rd_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+6, 2, 0); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { /* XXX decode the data */ } @@ -198,7 +186,6 @@ dissect_ssc_readreverse6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *rr6_fields[] = { &hf_scsi_ssc_bytord, &hf_scsi_ssc_sili, @@ -213,14 +200,11 @@ dissect_ssc_readreverse6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rr6_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, rr6_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, 0); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -229,7 +213,6 @@ dissect_ssc_read16 (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; static const int *read6_fields[] = { &hf_scsi_ssc_sili, &hf_scsi_ssc_fixed, @@ -243,19 +226,13 @@ dissect_ssc_read16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, read6_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, read6_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -264,7 +241,6 @@ dissect_ssc_write16 (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; static const int *write16_fields[] = { &hf_scsi_ssc_fcs, &hf_scsi_ssc_lcs, @@ -279,19 +255,13 @@ dissect_ssc_write16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, write16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, write16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -300,7 +270,6 @@ dissect_ssc_writefilemarks16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *wf16_fields[] = { &hf_scsi_ssc_fcs, &hf_scsi_ssc_lcs, @@ -315,19 +284,13 @@ dissect_ssc_writefilemarks16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, wf16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, wf16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -336,7 +299,6 @@ dissect_ssc_verify16 (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; static const int *verify16_fields[] = { &hf_scsi_ssc_verify16_immed, &hf_scsi_ssc_bytcmp, @@ -351,19 +313,13 @@ dissect_ssc_verify16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, verify16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, verify16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - proto_tree_add_item (tree, hf_scsi_ssc_ver16_verlen, tvb, offset+11, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -372,7 +328,6 @@ dissect_ssc_verify6 (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; static const int *verify6_fields[] = { &hf_scsi_ssc_verify16_immed, &hf_scsi_ssc_bytcmp, @@ -387,15 +342,11 @@ dissect_ssc_verify6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, verify6_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, verify6_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_ver16_verlen, tvb, offset+1, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -404,7 +355,6 @@ dissect_ssc_readreverse16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *rr16_fields[] = { &hf_scsi_ssc_bytord, &hf_scsi_ssc_sili, @@ -419,19 +369,13 @@ dissect_ssc_readreverse16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tr } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rr16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, rr16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+11, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -440,7 +384,6 @@ dissect_ssc_write6 (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; static const int *write6_fields[] = { &hf_scsi_ssc_immed, NULL @@ -453,16 +396,11 @@ dissect_ssc_write6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, write6_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, - FALSE); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, write6_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -471,7 +409,6 @@ dissect_ssc_writefilemarks6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *wf6_fields[] = { &hf_scsi_ssc_immed, NULL @@ -484,16 +421,11 @@ dissect_ssc_writefilemarks6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * } if (tree && isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, wf6_fields, FALSE); - - proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, - FALSE); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, wf6_fields, FALSE); + proto_tree_add_item (tree, hf_scsi_ssc_rdwr6_xferlen, tvb, offset+1, 3, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -502,7 +434,6 @@ dissect_ssc_loadunload (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; static const int *loadunload_immed_fields[] = { &hf_scsi_ssc_immed, NULL @@ -526,15 +457,12 @@ dissect_ssc_loadunload (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_loadunload_immed_flags, ett_scsi_loadunload_immed, loadunload_immed_fields, FALSE); - - proto_tree_add_bitmask(tree, tvb, offset+3, hf_scsi_ssc_loadunload_flags, ett_scsi_loadunload, loadunload_fields, FALSE); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_loadunload_immed_flags, + ett_scsi_loadunload_immed, loadunload_immed_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+3, hf_scsi_ssc_loadunload_flags, + ett_scsi_loadunload, loadunload_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -544,17 +472,14 @@ dissect_ssc_readblocklimits (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags, granularity; + guint8 granularity; if (!tree) return; if (isreq && iscdb) { - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!iscdb) { granularity = tvb_get_guint8 (tvb, offset); @@ -573,7 +498,6 @@ dissect_ssc_rewind (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; static const int *rewind_fields[] = { &hf_scsi_ssc_immed, NULL @@ -587,13 +511,9 @@ dissect_ssc_rewind (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, col_append_fstr (pinfo->cinfo, COL_INFO, "(Immed: %u)", tvb_get_guint8 (tvb, offset) & 0x01); - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rewind_fields, FALSE); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, rewind_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -602,7 +522,6 @@ dissect_ssc_setcapacity (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; static const int *sc_fields[] = { &hf_scsi_ssc_immed, NULL @@ -612,15 +531,11 @@ dissect_ssc_setcapacity (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, ett_scsi_read6, sc_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_read6_flags, + ett_scsi_read6, sc_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_capacity_prop_value, tvb, offset+2, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -630,7 +545,6 @@ dissect_ssc_locate10 (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; static const int *locate_fields[] = { &hf_scsi_ssc_bt, &hf_scsi_ssc_cp, @@ -642,17 +556,12 @@ dissect_ssc_locate10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, ett_scsi_locate, locate_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, + ett_scsi_locate, locate_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_locate10_loid, tvb, offset+2, 4, 0); - proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+7, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -662,7 +571,6 @@ dissect_ssc_locate16 (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; static const int *locate_fields[] = { &hf_scsi_ssc_dest_type, &hf_scsi_ssc_cp, @@ -678,19 +586,14 @@ dissect_ssc_locate16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, ett_scsi_locate, locate_fields, FALSE); - - proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_ssc_bam_flags, ett_scsi_bam, bam_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_locate_flags, + ett_scsi_locate, locate_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_ssc_bam_flags, + ett_scsi_bam, bam_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_locate16_loid, tvb, offset+3, 8, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -712,11 +615,8 @@ dissect_ssc_erase6 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, (flags & 0x02) >> 1, flags & 0x01); - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -726,7 +626,6 @@ dissect_ssc_erase16 (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; static const int *erase16_fields[] = { &hf_scsi_ssc_fcs, &hf_scsi_ssc_lcs, @@ -739,41 +638,28 @@ dissect_ssc_erase16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_erase_flags, ett_scsi_erase, erase16_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_erase_flags, + ett_scsi_erase, erase16_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset+2, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_lbi, tvb, offset+3, 8, 0); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } - static void dissect_ssc_space6 (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) return; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_ssc_space6_code, tvb, offset, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_space6_count, tvb, offset+1, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -782,25 +668,17 @@ dissect_ssc_space16 (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) return; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_ssc_space6_code, tvb, offset, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_space16_count, tvb, offset+3, 8, 0); - proto_tree_add_text (tree, tvb, offset+11, 2, "Parameter Len: %u", tvb_get_ntohs (tvb, offset+11)); - - flags = tvb_get_guint8 (tvb, offset+14); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+14, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -830,7 +708,6 @@ dissect_ssc_formatmedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *formatmedium_fields[] = { &hf_scsi_ssc_verify, &hf_scsi_ssc_immed, @@ -841,17 +718,12 @@ dissect_ssc_formatmedium (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_formatmedium_flags, ett_scsi_formatmedium, formatmedium_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_formatmedium_flags, + ett_scsi_formatmedium, formatmedium_fields, FALSE); proto_tree_add_item (tree, hf_scsi_ssc_format, tvb, offset+1, 1, 0); - proto_tree_add_item (tree, hf_scsi_ssc_rdwr10_xferlen, tvb, offset+2, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -886,11 +758,8 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre proto_tree_add_text (tree, tvb, offset+6, 2, "Parameter Len: %u", tvb_get_ntohs (tvb, offset+6)); - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!isreq) { if (cdata) diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index 016f9b0e56..5825fbc4d2 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -100,9 +100,20 @@ #include "packet-scsi-smc.h" static int proto_scsi = -1; +static int hf_scsi_inq_control_vendor_specific = -1; +static int hf_scsi_inq_control_reserved = -1; +static int hf_scsi_inq_control_naca = -1; +static int hf_scsi_inq_control_obs1 = -1; +static int hf_scsi_inq_control_obs2 = -1; +static int hf_scsi_inq_control = -1; +static int hf_scsi_control_vendor_specific = -1; +static int hf_scsi_control_reserved = -1; +static int hf_scsi_control_naca = -1; +static int hf_scsi_control_obs1 = -1; +static int hf_scsi_control_obs2 = -1; int hf_scsi_control = -1; int hf_scsi_alloclen16 = -1; -static int hf_scsi_alloclen32 = -1; +static int hf_scsi_alloclen32 = -1; static int hf_scsi_time = -1; static int hf_scsi_request_frame = -1; static int hf_scsi_response_frame = -1; @@ -278,6 +289,8 @@ static int hf_scsi_log_ta_wmoa = -1; static gint ett_scsi = -1; static gint ett_scsi_page = -1; + gint ett_scsi_control = -1; +static gint ett_scsi_inq_control = -1; static gint ett_scsi_inq_peripheral = -1; static gint ett_scsi_inq_acaflags = -1; static gint ett_scsi_inq_rmbflags = -1; @@ -299,6 +312,18 @@ static gboolean scsi_defragment = FALSE; static GHashTable *scsi_fragment_table = NULL; static GHashTable *scsi_reassembled_table = NULL; +/* + * Required by all commands + */ +const int *cdb_control_fields[6] = { + &hf_scsi_control_vendor_specific, + &hf_scsi_control_reserved, + &hf_scsi_control_naca, + &hf_scsi_control_obs1, + &hf_scsi_control_obs2, + NULL +}; + static void scsi_defragment_init(void) { @@ -1379,6 +1404,11 @@ static const true_false_string scsi_modesns_qerr_val = { "Blocked tasks shall resume after ACA/CA is cleared", }; +static const true_false_string scsi_naca_tfs = { + "Normal ACA is set", + "Normal ACA is not set" +}; + static const true_false_string normaca_tfs = { "NormACA is SUPPORTED", "Normaca is NOT supported", @@ -2251,7 +2281,15 @@ dissect_spc_inquiry (tvbuff_t *tvb, packet_info *pinfo, tvbuff_t *volatile tvb_v = tvb; volatile guint offset_v = offset; - static const int *peripheal_fields[] = { + static const int *inq_control_fields[] = { + &hf_scsi_inq_control_vendor_specific, + &hf_scsi_inq_control_reserved, + &hf_scsi_inq_control_naca, + &hf_scsi_inq_control_obs1, + &hf_scsi_inq_control_obs2, + NULL + }; + static const int *peripheral_fields[] = { &hf_scsi_inq_qualifier, &hf_scsi_inq_devtype, NULL @@ -2304,11 +2342,8 @@ dissect_spc_inquiry (tvbuff_t *tvb, packet_info *pinfo, cdata->itlq->alloc_len=tvb_get_guint8(tvb_v, offset_v+3); } - flags = tvb_get_guint8 (tvb_v, offset_v+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb_v, offset_v+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb_v, offset_v+4, hf_scsi_inq_control, + ett_scsi_inq_control, inq_control_fields, FALSE); } else if (!isreq) { if (!cdata) { return; @@ -2329,7 +2364,7 @@ dissect_spc_inquiry (tvbuff_t *tvb, packet_info *pinfo, TRY_SCSI_CDB_ALLOC_LEN(pinfo, tvb_v, offset_v, cdata->itlq->alloc_len); /* Qualifier and DeviceType */ - proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheal_fields, FALSE); + proto_tree_add_bitmask(tree, tvb_v, offset_v, hf_scsi_inq_peripheral, ett_scsi_inq_peripheral, peripheral_fields, FALSE); offset_v+=1; /* RMB */ @@ -2514,7 +2549,6 @@ dissect_spc_logselect (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; static const int *ppcflags_fields[] = { &hf_scsi_log_pcr, &hf_scsi_log_sp, @@ -2529,17 +2563,12 @@ dissect_spc_logselect (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags, ett_scsi_log_ppc, ppcflags_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags, + ett_scsi_log_ppc, ppcflags_fields, FALSE); proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_log_pc_flags, ett_scsi_log_pc, pcflags_fields, FALSE); - proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { } @@ -2563,7 +2592,6 @@ dissect_spc_logsense (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; static const int *ppcflags_fields[] = { &hf_scsi_log_ppc, &hf_scsi_log_sp, @@ -2579,19 +2607,15 @@ dissect_spc_logsense (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return; if (isreq && iscdb) { - proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags, ett_scsi_log_ppc, ppcflags_fields, FALSE); - - proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_log_pc_flags, ett_scsi_log_pc, pcflags_fields, FALSE); - + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_log_ppc_flags, + ett_scsi_log_ppc, ppcflags_fields, FALSE); + proto_tree_add_bitmask(tree, tvb, offset+1, hf_scsi_log_pc_flags, + ett_scsi_log_pc, pcflags_fields, FALSE); proto_tree_add_text (tree, tvb, offset+4, 2, "Parameter Pointer: 0x%04x", tvb_get_ntohs (tvb, offset+4)); proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!isreq) { if (!cdata) { return; @@ -3405,17 +3429,12 @@ dissect_spc_modeselect6 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_modesel_flags, tvb, offset, 1, flags, "PF = %u, SP = %u", flags & 0x10, flags & 0x1); proto_tree_add_item (tree, hf_scsi_paramlen, tvb, offset+3, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { /* Mode Parameter has the following format: @@ -3504,17 +3523,12 @@ dissect_spc_modeselect10 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_modesel_flags, tvb, offset, 1, flags, "PF = %u, SP = %u", flags & 0x10, flags & 0x1); proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { /* Mode Parameter has the following format: @@ -3659,18 +3673,13 @@ dissect_spc_modesense6 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_modesns_flags, tvb, offset, 1, flags, "DBD = %u", flags & 0x8); proto_tree_add_item (tree, hf_scsi_modesns_pc, tvb, offset+1, 1, 0); dissect_scsi_pagecode (tvb, pinfo, tree, offset+1, cdata); proto_tree_add_item (tree, hf_scsi_alloclen, tvb, offset+3, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { /* Mode sense response has the following format: @@ -3753,19 +3762,14 @@ dissect_spc_modesense10 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_modesns_flags, tvb, offset, 1, flags, "LLBAA = %u, DBD = %u", flags & 0x10, flags & 0x8); proto_tree_add_item (tree, hf_scsi_modesns_pc, tvb, offset+1, 1, 0); dissect_scsi_pagecode (tvb, pinfo, tree, offset+1, cdata); proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { /* Mode sense response has the following format: @@ -3852,12 +3856,8 @@ dissect_spc_preventallowmediaremoval (tvbuff_t *tvb, packet_info *pinfo _U_, pro proto_tree_add_text (tree, tvb, offset+3, 1, "Persistent: %u, Prevent: %u", flags & 0x02, flags & 0x01); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -3874,15 +3874,10 @@ dissect_spc_persistentreservein (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tr return; if (isreq && iscdb) { - proto_tree_add_item (tree, hf_scsi_persresvin_svcaction, tvb, offset, - 1, 0); + proto_tree_add_item (tree, hf_scsi_persresvin_svcaction, tvb, offset, 1, 0); proto_tree_add_item (tree, hf_scsi_alloclen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); /* We store the service action since we want to interpret the data */ cdata->itlq->flags = tvb_get_guint8 (tvb, offset); } @@ -3930,23 +3925,16 @@ dissect_spc_persistentreserveout (tvbuff_t *tvb, packet_info *pinfo _U_, proto_t guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree) return; if (isreq && iscdb) { - proto_tree_add_item (tree, hf_scsi_persresvout_svcaction, tvb, offset, - 1, 0); + proto_tree_add_item (tree, hf_scsi_persresvout_svcaction, tvb, offset, 1, 0); proto_tree_add_item (tree, hf_scsi_persresv_scope, tvb, offset+1, 1, 0); proto_tree_add_item (tree, hf_scsi_persresv_type, tvb, offset+1, 1, 0); proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else { } @@ -3957,17 +3945,12 @@ dissect_spc_release6 (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) return; if (isreq && iscdb) { - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -3983,7 +3966,6 @@ dissect_spc_release10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_release_flags, tvb, offset, 1, flags, "Flags: 3rd Party ID = %u, LongID = %u", @@ -3993,12 +3975,8 @@ dissect_spc_release10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, offset+2, 1, 0); } proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -4017,24 +3995,18 @@ dissect_spc_reportluns (tvbuff_t *tvb, packet_info *pinfo _U_, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; gint listlen; tvbuff_t *volatile tvb_v = tvb; volatile guint offset_v = offset; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_select_report, tvb_v, offset_v+1, 1, 0); - proto_tree_add_item (tree, hf_scsi_alloclen32, tvb_v, offset_v+5, 4, 0); if(cdata){ cdata->itlq->alloc_len=tvb_get_ntohl(tvb_v, offset_v+5); } - - flags = tvb_get_guint8 (tvb_v, offset_v+10); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb_v, offset_v+10, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset_v+10, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!isreq) { if (!cdata) { return; @@ -4098,19 +4070,13 @@ dissect_spc_requestsense (tvbuff_t * tvb, packet_info *pinfo _U_, proto_tree *tr guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree) return; if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_alloclen, tvb, offset+3, 1, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } else if (!isreq) dissect_scsi_fix_snsinfo(tvb, tree, offset); @@ -4121,17 +4087,12 @@ dissect_spc_reserve6 (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) return; if (isreq && iscdb) { - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -4147,7 +4108,6 @@ dissect_spc_reserve10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (isreq && iscdb) { flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_uint_format (tree, hf_scsi_release_flags, tvb, offset, 1, flags, "Flags: 3rd Party ID = %u, LongID = %u", @@ -4157,12 +4117,8 @@ dissect_spc_reserve10 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, offset+2, 1, 0); } proto_tree_add_item (tree, hf_scsi_paramlen16, tvb, offset+6, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -4171,17 +4127,13 @@ dissect_spc_testunitready (tvbuff_t * tvb, packet_info *pinfo _U_, proto_tree *t guint offset, gboolean isreq, gboolean iscdb, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; if (!tree) return; if (isreq && iscdb) { - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+4, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } } @@ -4195,8 +4147,6 @@ dissect_spc_senddiagnostic (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t guint offset, gboolean isreq, gboolean iscdb _U_, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree && !isreq) return; @@ -4206,12 +4156,8 @@ dissect_spc_senddiagnostic (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *t proto_tree_add_boolean (tree, hf_scsi_senddiag_devoff, tvb, offset, 1, 0); proto_tree_add_boolean (tree, hf_scsi_senddiag_unitoff, tvb, offset, 1, 0); proto_tree_add_uint (tree, hf_scsi_paramlen16, tvb, offset+2, 2, 0); - - flags = tvb_get_guint8 (tvb, offset+4); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } void @@ -4219,8 +4165,6 @@ dissect_spc_writebuffer (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree guint offset, gboolean isreq, gboolean iscdb _U_, guint payload_len _U_, scsi_task_data_t *cdata _U_) { - guint8 flags; - if (!tree && !isreq) return; @@ -4228,12 +4172,8 @@ dissect_spc_writebuffer (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree proto_tree_add_uint (tree, hf_scsi_wb_bufferid, tvb, offset+1, 1, 0); proto_tree_add_uint (tree, hf_scsi_wb_bufoffset, tvb, offset+2, 3, 0); proto_tree_add_uint (tree, hf_scsi_paramlen24, tvb, offset+5, 3, 0); - - flags = tvb_get_guint8 (tvb, offset+8); - proto_tree_add_uint_format (tree, hf_scsi_control, tvb, offset+8, 1, - flags, - "Vendor Unique = %u, NACA = %u, Link = %u", - flags & 0xC0, flags & 0x4, flags & 0x1); + proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, + ett_scsi_control, cdb_control_fields, FALSE); } static void @@ -4252,10 +4192,6 @@ dissect_scsi_varlencdb (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, } } - - - - void dissect_scsi_rsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, itlq_nexus_t *itlq, itl_nexus_t *itl, @@ -5012,6 +4948,24 @@ proto_register_scsi (void) { &hf_scsi_control, {"Control", "scsi.cdb.control", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}}, + { &hf_scsi_control_vendor_specific, + {"Vendor specific", "scsi.cdb.control.vendorspecific", FT_UINT8, + BASE_HEX, NULL, 0xC0, NULL, HFILL}}, + { &hf_scsi_control_reserved, + {"Reserved", "scsi.cdb.control.reserved", FT_UINT8, BASE_HEX, NULL, + 0x38, NULL, HFILL}}, + { &hf_scsi_control_naca, + {"NACA", "scsi.cdb.control.naca", FT_BOOLEAN, 8, + TFS(&scsi_naca_tfs), 0x04, NULL, HFILL}}, + { &hf_scsi_control_obs1, + {"Obsolete", "scsi.cdb.control.obs1", FT_UINT8, BASE_HEX, + NULL, 0x02, NULL, HFILL}}, + { &hf_scsi_control_obs2, + {"Obsolete", "scsi.cdb.control.obs2", FT_UINT8, BASE_HEX, + NULL, 0x01, NULL, HFILL}}, + { &hf_scsi_inq_control, + {"Control", "scsi.cdb.inq.control", FT_UINT8, BASE_HEX, NULL, 0x0, + NULL, HFILL}}, { &hf_scsi_inquiry_flags, {"Inquiry Flags", "scsi.inquiry.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}}, @@ -5171,6 +5125,21 @@ proto_register_scsi (void) { &hf_scsi_inq_acaflags, {"Inquiry ACA Flags", "scsi.inquiry.acaflags", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL}}, + { &hf_scsi_inq_control_vendor_specific, + {"Vendor specific", "scsi.inquiry.control.vendorspecific", FT_UINT8, + BASE_HEX, NULL, 0xC0, NULL, HFILL}}, + { &hf_scsi_inq_control_reserved, + {"Reserved", "scsi.inquiry.control.reserved", FT_UINT8, BASE_HEX, + NULL, 0x38, NULL, HFILL}}, + { &hf_scsi_inq_control_naca, + {"NACA", "scsi.inquiry.control.naca", FT_BOOLEAN, 8, + TFS(&scsi_naca_tfs), 0x04, NULL, HFILL}}, + { &hf_scsi_inq_control_obs1, + {"Obsolete", "scsi.inquiry.control.obs1", FT_UINT8, BASE_HEX, + NULL, 0x02, NULL, HFILL}}, + { &hf_scsi_inq_control_obs2, + {"Obsolete", "scsi.inquiry.control.obs2", FT_UINT8, BASE_HEX, + NULL, 0x01, NULL, HFILL}}, { &hf_scsi_inq_rmbflags, {"Inquiry RMB Flags", "scsi.inquiry.rmbflags", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL}}, @@ -5528,6 +5497,8 @@ proto_register_scsi (void) static gint *ett[] = { &ett_scsi, &ett_scsi_page, + &ett_scsi_control, + &ett_scsi_inq_control, &ett_scsi_inq_peripheral, &ett_scsi_inq_acaflags, &ett_scsi_inq_rmbflags, diff --git a/epan/dissectors/packet-scsi.h b/epan/dissectors/packet-scsi.h index f2284ab3fa..0192c75e80 100644 --- a/epan/dissectors/packet-scsi.h +++ b/epan/dissectors/packet-scsi.h @@ -212,6 +212,8 @@ void dissect_scsi_snsinfo (tvbuff_t *, packet_info *, proto_tree *, guint, guint WS_VAR_IMPORT const value_string scsi_mmc_vals[]; +extern const int *cdb_control_fields[6]; +extern gint ett_scsi_control; extern int hf_scsi_control; extern int hf_scsi_alloclen16; |