diff options
author | Michael Mann <mmann78@netscape.net> | 2014-11-17 20:04:30 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-11-20 16:09:09 +0000 |
commit | e77261f6593b8c25635fc32d78f0f0c3c57bb902 (patch) | |
tree | fcd6d1234ff83f86f5977f288a6de82f1da4a19b /epan/dissectors/packet-scsi-ssc.c | |
parent | 9611e751aed1b1358d4f7028572004af11878469 (diff) |
Eliminate proto_tree_add_text from some dissectors.
Change-Id: Ib160211198ca02f7eacf29d04568628c11f208a5
Reviewed-on: https://code.wireshark.org/review/5407
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-scsi-ssc.c')
-rw-r--r-- | epan/dissectors/packet-scsi-ssc.c | 204 |
1 files changed, 124 insertions, 80 deletions
diff --git a/epan/dissectors/packet-scsi-ssc.c b/epan/dissectors/packet-scsi-ssc.c index 10a51672be..eb30e3c730 100644 --- a/epan/dissectors/packet-scsi-ssc.c +++ b/epan/dissectors/packet-scsi-ssc.c @@ -85,6 +85,34 @@ static int hf_scsi_ssc_verify16_immed = -1; static int hf_scsi_ssc_medium_type = -1; static int hf_scsi_ssc_media = -1; static int hf_scsi_ssc_capacity_prop_value = -1; +/* Generated from convert_proto_tree_add_text.pl */ +static int hf_scsi_ssc_readposition_block_number = -1; +static int hf_scsi_ssc_readposition_file_number = -1; +static int hf_scsi_ssc_readposition_parameter_len = -1; +static int hf_scsi_ssc_readblocklimits_max_block_length_limit = -1; +static int hf_scsi_ssc_readposition_set_number = -1; +static int hf_scsi_ssc_readblocklimits_granularity = -1; +static int hf_scsi_ssc_readposition_flags = -1; +static int hf_scsi_ssc_readposition_bop = -1; +static int hf_scsi_ssc_readposition_eop = -1; +static int hf_scsi_ssc_readposition_mpu = -1; +static int hf_scsi_ssc_readposition_bcu = -1; +static int hf_scsi_ssc_readposition_bycu = -1; +static int hf_scsi_ssc_readposition_bpu = -1; +static int hf_scsi_ssc_readposition_perr = -1; + + +static int hf_scsi_ssc_readposition_additional_length = -1; +static int hf_scsi_ssc_readposition_num_blocks_buffer = -1; +static int hf_scsi_ssc_readposition_last_block_location = -1; +static int hf_scsi_ssc_erase6_immed = -1; +static int hf_scsi_ssc_erase6_long = -1; +static int hf_scsi_ssc_readblocklimits_min_block_length_limit = -1; +static int hf_scsi_ssc_readposition_service_action = -1; +static int hf_scsi_ssc_readposition_num_bytes_buffer = -1; +static int hf_scsi_ssc_readposition_first_block_location = -1; +static int hf_scsi_ssc_space16_parameter_len = -1; +static int hf_scsi_ssc_readposition_partition_number = -1; static gint ett_scsi_erase = -1; static gint ett_scsi_formatmedium = -1; @@ -93,6 +121,7 @@ static gint ett_scsi_loadunload = -1; static gint ett_scsi_locate = -1; static gint ett_scsi_bam = -1; static gint ett_scsi_read6 = -1; +static gint ett_scsi_ssc_readposition_flags = -1; static void @@ -467,13 +496,13 @@ dissect_ssc_readblocklimits (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * } else if (!iscdb) { granularity = tvb_get_guint8 (tvb, offset); - proto_tree_add_text (tree, tvb, offset, 1, "Granularity: %u (%u %s)", - granularity, 1 << granularity, + proto_tree_add_uint_format_value(tree, hf_scsi_ssc_readblocklimits_granularity, tvb, offset, 1, + 1 << granularity, "%u %s", 1 << granularity, plurality(1 << granularity, "byte", "bytes")); - proto_tree_add_text (tree, tvb, offset+1, 3, "Maximum Block Length Limit: %u bytes", - tvb_get_ntoh24 (tvb, offset+1)); - proto_tree_add_text (tree, tvb, offset+4, 2, "Minimum Block Length Limit: %u bytes", - tvb_get_ntohs (tvb, offset+4)); + proto_tree_add_uint_format_value(tree, hf_scsi_ssc_readblocklimits_max_block_length_limit, tvb, offset+1, 3, + tvb_get_ntoh24 (tvb, offset+1), "%u bytes", tvb_get_ntoh24 (tvb, offset+1)); + proto_tree_add_uint_format_value(tree, hf_scsi_ssc_readblocklimits_min_block_length_limit, tvb, offset+4, 2, + tvb_get_ntohs (tvb, offset+4), "%u bytes", tvb_get_ntohs (tvb, offset+4)); } } @@ -586,17 +615,12 @@ dissect_ssc_erase6 (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 (!tree) return; - flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_text (tree, tvb, offset, 1, - "IMMED: %u, LONG: %u", - (flags & 0x02) >> 1, - flags & 0x01); + proto_tree_add_item(tree, hf_scsi_ssc_erase6_immed, tvb, offset, 1, ENC_NA); + proto_tree_add_item(tree, hf_scsi_ssc_erase6_long, tvb, offset, 1, ENC_NA); proto_tree_add_bitmask(tree, tvb, offset+4, hf_scsi_control, ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN); @@ -657,9 +681,7 @@ dissect_ssc_space16 (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, if (isreq && iscdb) { proto_tree_add_item (tree, hf_scsi_ssc_space6_code, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item (tree, hf_scsi_ssc_space16_count, tvb, offset+3, 8, ENC_BIG_ENDIAN); - proto_tree_add_text (tree, tvb, offset+11, 2, - "Parameter Len: %u", - tvb_get_ntohs (tvb, offset+11)); + proto_tree_add_item(tree, hf_scsi_ssc_space16_parameter_len, tvb, offset+11, 2, ENC_BIG_ENDIAN); proto_tree_add_bitmask(tree, tvb, offset+14, hf_scsi_control, ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN); } @@ -729,18 +751,12 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre if (isreq && iscdb) { service_action = tvb_get_guint8 (tvb, offset) & 0x1F; - proto_tree_add_text (tree, tvb, offset, 1, - "Service Action: %s", - val_to_str (service_action, - service_action_vals, - "Unknown (0x%02x)")); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_service_action, tvb, offset, 1, ENC_NA); /* Remember the service action so we can decode the reply */ if (cdata != NULL) { cdata->itlq->flags = service_action; } - proto_tree_add_text (tree, tvb, offset+6, 2, - "Parameter Len: %u", - tvb_get_ntohs (tvb, offset+6)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_parameter_len, tvb, offset+6, 2, ENC_BIG_ENDIAN); proto_tree_add_bitmask(tree, tvb, offset+8, hf_scsi_control, ett_scsi_control, cdb_control_fields, ENC_BIG_ENDIAN); } @@ -752,12 +768,20 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre switch (service_action) { case SHORT_FORM_BLOCK_ID: case SHORT_FORM_VENDOR_SPECIFIC: + { + static const int * block_id_flags[] = { + &hf_scsi_ssc_readposition_bop, + &hf_scsi_ssc_readposition_eop, + &hf_scsi_ssc_readposition_bcu, + &hf_scsi_ssc_readposition_bycu, + &hf_scsi_ssc_readposition_bpu, + &hf_scsi_ssc_readposition_perr, + NULL + }; + flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_text (tree, tvb, offset, 1, - "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, BPU: %u, PERR: %u", - (flags & 0x80) >> 7, (flags & 0x40) >> 6, - (flags & BCU) >> 5, (flags & BYCU) >> 4, - (flags & BPU) >> 2, (flags & 0x02) >> 1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_readposition_flags, + ett_scsi_ssc_readposition_flags, block_id_flags, ENC_NA); offset += 1; proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -766,14 +790,10 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre offset += 2; /* reserved */ if (!(flags & BPU)) { - proto_tree_add_text (tree, tvb, offset, 4, - "First Block Location: %u", - tvb_get_ntohl (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_first_block_location, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_text (tree, tvb, offset, 4, - "Last Block Location: %u", - tvb_get_ntohl (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_last_block_location, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; } else offset += 8; @@ -781,93 +801,91 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre offset += 1; /* reserved */ if (!(flags & BCU)) { - proto_tree_add_text (tree, tvb, offset, 3, - "Number of Blocks in Buffer: %u", - tvb_get_ntoh24 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_num_blocks_buffer, tvb, offset, 3, ENC_BIG_ENDIAN); } offset += 3; if (!(flags & BYCU)) { - proto_tree_add_text (tree, tvb, offset, 4, - "Number of Bytes in Buffer: %u", - tvb_get_ntohl (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_num_bytes_buffer, tvb, offset, 4, ENC_BIG_ENDIAN); } /*offset += 4;*/ + } break; case LONG_FORM: + { + static const int * long_form_flags[] = { + &hf_scsi_ssc_readposition_bop, + &hf_scsi_ssc_readposition_eop, + &hf_scsi_ssc_readposition_mpu, + &hf_scsi_ssc_readposition_bcu, + NULL + }; + flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_text (tree, tvb, offset, 1, - "BOP: %u, EOP: %u, MPU: %u, BPU: %u", - (flags & 0x80) >> 7, (flags & 0x40) >> 6, - (flags & MPU) >> 3, (flags & BPU) >> 2); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_readposition_flags, + ett_scsi_ssc_readposition_flags, long_form_flags, ENC_NA); offset += 1; offset += 3; /* reserved */ if (!(flags & BPU)) { - proto_tree_add_text (tree, tvb, offset, 4, - "Partition Number: %u", - tvb_get_ntohl (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_partition_number, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; - proto_tree_add_text (tree, tvb, offset, 8, - "Block Number: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_block_number, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; } else offset += 12; if (!(flags & MPU)) { - proto_tree_add_text (tree, tvb, offset, 8, - "File Number: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_file_number, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - proto_tree_add_text (tree, tvb, offset, 8, - "Set Number: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_set_number, tvb, offset, 8, ENC_BIG_ENDIAN); /*offset += 8;*/ - } else + } else { /*offset += 16;*/ + } + } break; case EXTENDED_FORM: + { + static const int * extended_form_flags[] = { + &hf_scsi_ssc_readposition_bop, + &hf_scsi_ssc_readposition_eop, + &hf_scsi_ssc_readposition_bcu, + &hf_scsi_ssc_readposition_bycu, + &hf_scsi_ssc_readposition_mpu, + &hf_scsi_ssc_readposition_bpu, + &hf_scsi_ssc_readposition_perr, + NULL + }; + flags = tvb_get_guint8 (tvb, offset); - proto_tree_add_text (tree, tvb, offset, 1, - "BOP: %u, EOP: %u, BCU: %u, BYCU: %u, MPU: %u, BPU: %u, PERR: %u", - (flags & 0x80) >> 7, (flags & 0x40) >> 6, - (flags & BCU) >> 5, (flags & BYCU) >> 4, - (flags & MPU) >> 3, (flags & BPU) >> 2, - (flags & 0x02) >> 1); + proto_tree_add_bitmask(tree, tvb, offset, hf_scsi_ssc_readposition_flags, + ett_scsi_ssc_readposition_flags, extended_form_flags, ENC_NA); offset += 1; proto_tree_add_item (tree, hf_scsi_ssc_partition, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - proto_tree_add_text (tree, tvb, offset, 2, - "Additional Length: %u", - tvb_get_ntohs (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_additional_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; offset += 1; /* reserved */ if (!(flags & BCU)) { - proto_tree_add_text (tree, tvb, offset, 3, - "Number of Blocks in Buffer: %u", - tvb_get_ntoh24 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_num_blocks_buffer, tvb, offset, 3, ENC_BIG_ENDIAN); } offset += 3; if (!(flags & BPU)) { - proto_tree_add_text (tree, tvb, offset, 8, - "First Block Location: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_first_block_location, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; - proto_tree_add_text (tree, tvb, offset, 8, - "Last Block Location: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_last_block_location, tvb, offset, 8, ENC_BIG_ENDIAN); offset += 8; } else offset += 16; @@ -875,11 +893,10 @@ dissect_ssc_readposition (tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre offset += 1; /* reserved */ if (!(flags & BYCU)) { - proto_tree_add_text (tree, tvb, offset, 8, - "Number of Bytes in Buffer: %" G_GINT64_MODIFIER "u", - tvb_get_ntoh64 (tvb, offset)); + proto_tree_add_item(tree, hf_scsi_ssc_readposition_num_bytes_buffer, tvb, offset, 8, ENC_BIG_ENDIAN); } /*offset += 8;*/ + } break; default: @@ -1332,6 +1349,32 @@ proto_register_scsi_ssc(void) { &hf_scsi_ssc_capacity_prop_value, {"Capacity Proportion Value", "scsi_ssc.cpv", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL}}, + /* Generated from convert_proto_tree_add_text.pl */ + { &hf_scsi_ssc_readblocklimits_granularity, { "Granularity", "scsi_ssc.readblocklimits.granularity", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readblocklimits_max_block_length_limit, { "Maximum Block Length Limit", "scsi_ssc.readblocklimits.max_block_length_limit", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readblocklimits_min_block_length_limit, { "Minimum Block Length Limit", "scsi_ssc.readblocklimits.min_block_length_limit", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_erase6_immed, { "IMMED", "scsi_ssc.erase6.immed", FT_UINT8, BASE_DEC, NULL, 0x02, NULL, HFILL }}, + { &hf_scsi_ssc_erase6_long, { "LONG", "scsi_ssc.erase6.long", FT_UINT8, BASE_DEC, NULL, 0x01, NULL, HFILL }}, + { &hf_scsi_ssc_space16_parameter_len, { "Parameter Len", "scsi_ssc.space16.parameter_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_service_action, { "Service Action", "scsi_ssc.readposition.service_action", FT_UINT8, BASE_DEC, VALS(service_action_vals), 0x1F, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_parameter_len, { "Parameter Len", "scsi_ssc.readposition.parameter_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_flags, { "Flags", "scsi_ssc.readposition.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_bop, { "BOP", "scsi_ssc.readposition.bop", FT_UINT8, BASE_DEC, NULL, 0x80, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_eop, { "EOP", "scsi_ssc.readposition.eop", FT_UINT8, BASE_DEC, NULL, 0x40, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_mpu, { "EOP", "scsi_ssc.readposition.mpu", FT_UINT8, BASE_DEC, NULL, MPU, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_bcu, { "BCU", "scsi_ssc.readposition.bcu", FT_UINT8, BASE_DEC, NULL, BCU, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_bycu, { "BYCU", "scsi_ssc.readposition.bycu", FT_UINT8, BASE_DEC, NULL, BYCU, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_bpu, { "BPU", "scsi_ssc.readposition.bpu", FT_UINT8, BASE_DEC, NULL, BPU, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_perr, { "PERR", "scsi_ssc.readposition.perr", FT_UINT8, BASE_DEC, NULL, 0x02, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_first_block_location, { "First Block Location", "scsi_ssc.readposition.first_block_location", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_last_block_location, { "Last Block Location", "scsi_ssc.readposition.last_block_location", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_num_blocks_buffer, { "Number of Blocks in Buffer", "scsi_ssc.readposition.num_blocks_buffer", FT_UINT24, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_num_bytes_buffer, { "Number of Bytes in Buffer", "scsi_ssc.readposition.num_bytes_buffer", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_partition_number, { "Partition Number", "scsi_ssc.readposition.partition_number", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_block_number, { "Block Number", "scsi_ssc.readposition.block_number", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_file_number, { "File Number", "scsi_ssc.readposition.file_number", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_set_number, { "Set Number", "scsi_ssc.readposition.set_number", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_scsi_ssc_readposition_additional_length, { "Additional Length", "scsi_ssc.readposition.additional_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, }; @@ -1343,7 +1386,8 @@ proto_register_scsi_ssc(void) &ett_scsi_loadunload, &ett_scsi_locate, &ett_scsi_bam, - &ett_scsi_read6 + &ett_scsi_read6, + &ett_scsi_ssc_readposition_flags }; |