diff options
author | Mikhail Koreshkov <drkor@hotbox.ru> | 2015-04-13 21:59:12 +0300 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2015-05-10 11:18:12 +0000 |
commit | c1567a0948e50ded08947aae270dfd3bcd487486 (patch) | |
tree | 7da065da278134521a6c2c34d223e01d6a08c5f3 /epan/dissectors/packet-q931.c | |
parent | be8f9c4cf38594368702eeb0c70e920461a10e6e (diff) |
Q931: separate ett for each information element
Add separate ett for all possible information elements.
It's better to expand only necessary subtree but not all
Change-Id: If84359e28547ce5dcf753dc1bee691ece7f29ace
Reviewed-on: https://code.wireshark.org/review/8054
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-q931.c')
-rw-r--r-- | epan/dissectors/packet-q931.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/epan/dissectors/packet-q931.c b/epan/dissectors/packet-q931.c index 3da40991fb..a8a2feb882 100644 --- a/epan/dissectors/packet-q931.c +++ b/epan/dissectors/packet-q931.c @@ -204,7 +204,8 @@ static int hf_q931_data = -1; static int hf_q931_layer_1_in_band_negotiation = -1; static gint ett_q931 = -1; -static gint ett_q931_ie = -1; +#define NUM_IE 256 +static gint ett_q931_ie[NUM_IE]; static gint ett_q931_segments = -1; static gint ett_q931_segment = -1; @@ -2550,7 +2551,7 @@ dissect_q931_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, return; } /* Segmented message IE */ - ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie, NULL, + ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], NULL, val_to_str(info_element, q931_info_element_vals[0], "Unknown information element (0x%02X)")); proto_tree_add_text(ie_tree, tvb, offset, 1, "Information element: %s", val_to_str(info_element, q931_info_element_vals[0], "Unknown (0x%02X)")); @@ -2724,7 +2725,7 @@ dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree, info_element_len = tvb_get_ntohs(tvb, offset + 1); if (q931_tree != NULL) { ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, - 1+2+info_element_len, ett_q931_ie, NULL, + 1+2+info_element_len, ett_q931_ie[info_element], NULL, val_to_str(info_element, q931_info_element_vals[codeset], "Unknown information element (0x%02X)")); @@ -2796,7 +2797,7 @@ dissect_q931_IEs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree, } } - ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie, &ti, + ie_tree = proto_tree_add_subtree(q931_tree, tvb, offset, 1+1+info_element_len, ett_q931_ie[info_element], &ti, val_to_str(info_element, q931_info_element_vals[codeset], "Unknown information element (0x%02X)")); proto_tree_add_text(ie_tree, tvb, offset, 1, "Information element: %s", val_to_str(info_element, q931_info_element_vals[codeset], "Unknown (0x%02X)")); @@ -3196,6 +3197,9 @@ q931_init(void) { void proto_register_q931(void) { + guint i; + guint last_offset; + static hf_register_info hf[] = { { &hf_q931_discriminator, { "Protocol discriminator", "q931.disc", FT_UINT8, BASE_HEX, NULL, 0x0, @@ -3828,12 +3832,9 @@ proto_register_q931(void) NULL, HFILL } }, }; - static gint *ett[] = { - &ett_q931, - &ett_q931_ie, - &ett_q931_segments, - &ett_q931_segment, - }; +#define NUM_INDIVIDUAL_ELEMS 3 + static gint *ett[NUM_INDIVIDUAL_ELEMS + NUM_IE]; + static ei_register_info ei[] = { { &ei_q931_invalid_length, { "q931.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }}, }; @@ -3841,6 +3842,18 @@ proto_register_q931(void) module_t *q931_module; expert_module_t* expert_q931; + ett[0] = &ett_q931; + ett[1] = &ett_q931_segments; + ett[2] = &ett_q931_segment; + + last_offset = NUM_INDIVIDUAL_ELEMS; + + for (i=0; i < NUM_IE; i++, last_offset++) + { + ett_q931_ie[i] = -1; + ett[last_offset] = &ett_q931_ie[i]; + } + proto_q931 = proto_register_protocol("Q.931", "Q.931", "q931"); proto_register_field_array (proto_q931, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); |