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 /epan/dissectors/packet-scsi-ssc.c | |
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
Diffstat (limited to 'epan/dissectors/packet-scsi-ssc.c')
-rw-r--r-- | epan/dissectors/packet-scsi-ssc.c | 315 |
1 files changed, 92 insertions, 223 deletions
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) |