diff options
Diffstat (limited to 'epan/dissectors/packet-trmac.c')
-rw-r--r-- | epan/dissectors/packet-trmac.c | 141 |
1 files changed, 78 insertions, 63 deletions
diff --git a/epan/dissectors/packet-trmac.c b/epan/dissectors/packet-trmac.c index b0cdae8dca..12c57773b3 100644 --- a/epan/dissectors/packet-trmac.c +++ b/epan/dissectors/packet-trmac.c @@ -50,6 +50,23 @@ static int hf_trmac_errors_fc = -1; static int hf_trmac_errors_freq = -1; static int hf_trmac_errors_token = -1; static int hf_trmac_naun = -1; +static int hf_trmac_beacon_type = -1; +/* Generated from convert_proto_tree_add_text.pl */ +static int hf_trmac_assign_physical_drop_number = -1; +static int hf_trmac_error_code = -1; +static int hf_trmac_group_address32 = -1; +static int hf_trmac_transmit_status_code = -1; +static int hf_trmac_station_identifier = -1; +static int hf_trmac_sa_of_last_amp_or_smp_frame = -1; +static int hf_trmac_error_report_timer_value = -1; +static int hf_trmac_individual_address_count = -1; +static int hf_trmac_correlator = -1; +static int hf_trmac_group_address_ether = -1; +static int hf_trmac_authorized_access_priority = -1; +static int hf_trmac_physical_drop_number = -1; +static int hf_trmac_authorized_function_classes = -1; +static int hf_trmac_local_ring_number = -1; +static int hf_trmac_functional_addresses = -1; static gint ett_tr_mac = -1; static gint ett_tr_sv = -1; @@ -126,6 +143,13 @@ static const value_string subvector_vs[] = { { 0x00, NULL } }; +static const value_string beacon_vs[] = { + { 0x00, "Recovery mode set" }, + { 0x01, "Signal loss error" }, + { 0x02, "Streaming signal not Claim Token MAC frame" }, + { 0x03, "Streaming signal, Claim Token MAC frame" }, + { 0x00, NULL } +}; /* Sub-vectors */ static int @@ -133,39 +157,30 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) { guint sv_length, sv_id; guint16 beacon_type, ring; - - static const char *beacon[] = { - "Recovery mode set", "Signal loss error", - "Streaming signal not Claim Token MAC frame", - "Streaming signal, Claim Token MAC frame" - }; + guint32 error_report_timer_value; proto_tree *sv_tree, *sv_subtree; proto_item *sv_item, *len_item, *ti; guchar errors[6]; /* isolating or non-isolating */ + sv_item = proto_tree_add_text(tree, tvb, svoff+0, 1, "Subvector"); + sv_tree = proto_item_add_subtree(sv_item, ett_tr_sv); + sv_length = tvb_get_guint8(tvb, svoff+0); + len_item = proto_tree_add_item(sv_tree, hf_trmac_sv_len, tvb, svoff+0, 1, ENC_NA); /* Check the SV length; it must be at least 2, to include the subvector length and indicator. */ if (sv_length < 2) { - ti = proto_tree_add_text(tree, tvb, svoff+0, 1, - "Invalid subvector: length < 2"); - sv_tree = proto_item_add_subtree(ti, ett_tr_sv); - len_item = proto_tree_add_uint(sv_tree, hf_trmac_sv_len, tvb, svoff+0, 1, sv_length); expert_add_info_format_text(pinfo, len_item, &ei_trmac_sv_len, - "Subvector length is zero"); + "Invalid subvector: length < 2"); return 0; /* tells our caller to give up */ } - sv_item = proto_tree_add_text(tree, tvb, svoff+0, sv_length, - "Subvector: length %u", sv_length); - sv_tree = proto_item_add_subtree(sv_item, ett_tr_sv); - len_item = proto_tree_add_uint(sv_tree, hf_trmac_sv_len, tvb, svoff+0, 1, sv_length); sv_id = tvb_get_guint8(tvb, svoff+1); - proto_tree_add_uint(sv_tree, hf_trmac_sv_id, tvb, svoff+1, 1, sv_id); - proto_item_set_text(sv_item, "%s", val_to_str(sv_id, subvector_vs, "Unknown subvector ID 0x%02X")); + proto_tree_add_item(sv_tree, hf_trmac_sv_id, tvb, svoff+1, 1, ENC_NA); + proto_item_append_text(sv_item, " (%s)", val_to_str(sv_id, subvector_vs, "Unknown subvector ID 0x%02X")); switch(sv_id) { case 0x01: /* Beacon Type */ @@ -175,17 +190,10 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) break; } beacon_type = tvb_get_ntohs(tvb, svoff+2); - if (beacon_type < array_length(beacon)) { - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Beacon Type: %s", beacon[beacon_type] ); - proto_item_append_text(sv_item, - ": %s", beacon[beacon_type] ); - } else { - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Beacon Type: Illegal value: %d", beacon_type ); - proto_item_append_text(sv_item, - ": Illegal value: %d", beacon_type ); - } + proto_tree_add_uint_format_value(sv_tree, hf_trmac_beacon_type, tvb, svoff+2, sv_length-2, + beacon_type, "%s", val_to_str(beacon_type, beacon_vs, "Illegal value: %d")); + proto_item_append_text(sv_item, + ": %s", val_to_str(beacon_type, beacon_vs, "Illegal value: %d")); break; case 0x02: /* Upstream Neighbor's Address */ @@ -206,8 +214,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) break; } ring = tvb_get_ntohs(tvb, svoff+2); - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Local Ring Number: 0x%04X (%d)", ring, ring); + proto_tree_add_item(sv_tree, hf_trmac_local_ring_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": 0x%04X (%d)", ring, ring); break; @@ -218,8 +225,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 6"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Assign Physical Drop Number: 0x%08X", tvb_get_ntohl(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_assign_physical_drop_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": 0x%08X", tvb_get_ntohl(tvb, svoff+2) ); break; @@ -230,10 +236,12 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Error Report Timer Value: %d ms", 10 * tvb_get_ntohs(tvb, svoff+2) ); + + error_report_timer_value = 10 * tvb_get_ntohs(tvb, svoff+2); + proto_tree_add_uint_format_value(sv_tree, hf_trmac_error_report_timer_value, tvb, svoff+2, sv_length-2, + error_report_timer_value, "%d ms", error_report_timer_value ); proto_item_append_text(sv_item, - ": %d ms", 10 * tvb_get_ntohs(tvb, svoff+2) ); + ": %d ms", error_report_timer_value ); break; case 0x06: /* Authorized Function Classes */ @@ -242,8 +250,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Authorized Function Classes: %04X", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_authorized_function_classes, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %04X", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -254,8 +261,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Authorized Access Priority: %04X", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_authorized_access_priority, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %04X", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -266,8 +272,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Correlator: %04X", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_correlator, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %04X", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -278,9 +283,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 8"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "SA of Last AMP or SMP Frame: %s", - tvb_ether_to_str(tvb, svoff+2)); + proto_tree_add_item(sv_tree, hf_trmac_sa_of_last_amp_or_smp_frame, tvb, svoff+2, sv_length-2, ENC_NA); proto_item_append_text(sv_item, ": %s", tvb_ether_to_str(tvb, svoff+2)); @@ -292,8 +295,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 6"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Physical Drop Number: 0x%08X", tvb_get_ntohl(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_physical_drop_number, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": 0x%08X", tvb_get_ntohl(tvb, svoff+2) ); break; @@ -335,8 +337,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Individual Address Count: %u", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_individual_address_count, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %u", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -367,9 +368,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 8"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Station Identifier: %s", - tvb_ether_to_str(tvb, svoff+2)); + proto_tree_add_item(sv_tree, hf_trmac_station_identifier, tvb, svoff+2, sv_length-2, ENC_NA); proto_item_append_text(sv_item, ": %s", tvb_ether_to_str(tvb, svoff+2)); @@ -386,8 +385,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Transmit Status Code: %04X", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_transmit_status_code, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %04X", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -399,14 +397,11 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) break; } if (sv_length == 6) { - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Group Address: %08X", tvb_get_ntohl(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_group_address32, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %08X", tvb_get_ntohl(tvb, svoff+2) ); } else { - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Group Address: %s", - tvb_ether_to_str(tvb, svoff+2)); + proto_tree_add_item(sv_tree, hf_trmac_group_address_ether, tvb, svoff+2, sv_length-2, ENC_NA); proto_item_append_text(sv_item, ": %s", tvb_ether_to_str(tvb, svoff+2)); @@ -419,8 +414,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 6"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Functional Addresses: %08X", tvb_get_ntohl(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_functional_addresses, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %08X", tvb_get_ntohl(tvb, svoff+2) ); break; @@ -468,8 +462,7 @@ sv_text(tvbuff_t *tvb, int svoff, packet_info *pinfo, proto_tree *tree) "Subvector length is != 4"); break; } - proto_tree_add_text(sv_tree, tvb, svoff+2, sv_length-2, - "Error Code: %04X", tvb_get_ntohs(tvb, svoff+2) ); + proto_tree_add_item(sv_tree, hf_trmac_error_code, tvb, svoff+2, sv_length-2, ENC_BIG_ENDIAN); proto_item_append_text(sv_item, ": %04X", tvb_get_ntohs(tvb, svoff+2) ); break; @@ -604,7 +597,29 @@ proto_register_trmac(void) { &hf_trmac_naun, { "Upstream Neighbor's Address", "trmac.naun", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }}, - }; + + { &hf_trmac_beacon_type, + { "Beacon Type", "trmac.beacon_type", FT_UINT16, BASE_DEC, VALS(beacon_vs), 0x0, + NULL, HFILL }}, + + /* Generated from convert_proto_tree_add_text.pl */ + { &hf_trmac_local_ring_number, { "Local Ring Number", "trmac.local_ring_number", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_assign_physical_drop_number, { "Assign Physical Drop Number", "trmac.assign_physical_drop_number", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_error_report_timer_value, { "Error Report Timer Value", "trmac.error_report_timer_value", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_authorized_function_classes, { "Authorized Function Classes", "trmac.authorized_function_classes", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_authorized_access_priority, { "Authorized Access Priority", "trmac.authorized_access_priority", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_correlator, { "Correlator", "trmac.correlator", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_sa_of_last_amp_or_smp_frame, { "SA of Last AMP or SMP Frame", "trmac.sa_of_last_amp_or_smp_frame", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_physical_drop_number, { "Physical Drop Number", "trmac.physical_drop_number", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_individual_address_count, { "Individual Address Count", "trmac.individual_address_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_station_identifier, { "Station Identifier", "trmac.station_identifier", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_transmit_status_code, { "Transmit Status Code", "trmac.transmit_status_code", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_group_address32, { "Group Address", "trmac.group_address", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_group_address_ether, { "Group Address", "trmac.group_address", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_functional_addresses, { "Functional Addresses", "trmac.functional_addresses", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + { &hf_trmac_error_code, { "Error Code", "trmac.error_code", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }}, + + }; static gint *ett[] = { &ett_tr_mac, &ett_tr_sv, |