diff options
author | Michael Mann <mmann78@netscape.net> | 2014-08-08 09:19:29 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-08-09 01:57:08 +0000 |
commit | cd02af56a1e39c66b44fd7957aff3b7b77a59e9d (patch) | |
tree | 4a3e859751bb73268115a607e9dffcec008bb411 /asn1/q932/packet-q932-template.c | |
parent | bb15274a4a82fcab1c06935fa1e249f436420a02 (diff) |
Eliminate (almost all) proto_tree_add_text calls from ASN.1 dissectors.
This mostly involved adding expert info capabilities to many of the dissectors so that they could correctly flag error conditions.
Only remaining proto_tree_add_text calls are in H248.cnf, which has a convoluted way of using hf_ data to make its tree.
Change-Id: I6412150c2ec1977d7fa38f3f0ed416680bdfb141
Reviewed-on: https://code.wireshark.org/review/3500
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'asn1/q932/packet-q932-template.c')
-rw-r--r-- | asn1/q932/packet-q932-template.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/asn1/q932/packet-q932-template.c b/asn1/q932/packet-q932-template.c index 8fe66eac00..e1cf733d6d 100644 --- a/asn1/q932/packet-q932-template.c +++ b/asn1/q932/packet-q932-template.c @@ -24,6 +24,7 @@ #include "config.h" #include <epan/packet.h> +#include <epan/expert.h> #include <epan/strutil.h> #include <epan/asn1.h> #include <epan/prefs.h> @@ -51,6 +52,12 @@ static gint ett_q932 = -1; static gint ett_q932_ie = -1; #include "packet-q932-ett.c" +static expert_field ei_q932_dse_not_supported = EI_INIT; +static expert_field ei_q932_acse_not_supported = EI_INIT; +static expert_field ei_q932_unknown_component = EI_INIT; +static expert_field ei_q932_asn1_encoded = EI_INIT; + + /* Preferences */ /* ROSE context */ @@ -179,12 +186,12 @@ dissect_q932_facility_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr case 17 : /* abort */ offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL); offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL); - proto_tree_add_text(tree, tvb, offset, len, "DSE APDU (not supported)"); + proto_tree_add_expert(tree, pinfo, &ei_q932_dse_not_supported, tvb, offset, len); break; default: offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL); offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL); - proto_tree_add_text(tree, tvb, offset, len, "Unknown Component"); + proto_tree_add_expert(tree, pinfo, &ei_q932_unknown_component, tvb, offset, len); } break; case BER_CLASS_APP: @@ -197,18 +204,18 @@ dissect_q932_facility_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr case 4 : /* abrt */ offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL); offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL); - proto_tree_add_text(tree, tvb, offset, len, "ACSE APDU (not supported)"); + proto_tree_add_expert(tree, pinfo, &ei_q932_acse_not_supported, tvb, offset, len); break; default: offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL); offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL); - proto_tree_add_text(tree, tvb, offset, len, "Unknown Component"); + proto_tree_add_expert(tree, pinfo, &ei_q932_unknown_component, tvb, offset, len); } break; default: offset = dissect_ber_identifier(pinfo, tree, tvb, hoffset, NULL, NULL, NULL); offset = dissect_ber_length(pinfo, tree, tvb, offset, NULL, NULL); - proto_tree_add_text(tree, tvb, offset, len, "Unknown Component"); + proto_tree_add_expert(tree, pinfo, &ei_q932_unknown_component, tvb, offset, len); } offset = eoffset; } @@ -216,10 +223,11 @@ dissect_q932_facility_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr /*--- dissect_q932_ni_ie -------------------------------------------------------*/ static void -dissect_q932_ni_ie(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int length) { +dissect_q932_ni_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int length) { int remain = length; guint8 octet = 0; guint32 value = 0; + proto_item* ti; while ((remain > 0) && !(octet & 0x80)) { octet = tvb_get_guint8(tvb, offset++); @@ -227,10 +235,10 @@ dissect_q932_ni_ie(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree value <<= 7; value |= octet & 0x7F; } - proto_tree_add_uint(tree, hf_q932_nd, tvb, offset - (length - remain), length - remain, value); + ti = proto_tree_add_uint(tree, hf_q932_nd, tvb, offset - (length - remain), length - remain, value); if (remain > 0) { - proto_tree_add_text(tree, tvb, offset - remain, remain, "ASN.1 Encoded Data Structure(NOT IMPLEMENTED): %s", tvb_bytes_to_ep_str(tvb, offset - remain, remain)); + expert_add_info(pinfo, ti, &ei_q932_asn1_encoded); } } @@ -308,7 +316,15 @@ void proto_register_q932(void) { #include "packet-q932-ettarr.c" }; - module_t *q932_module; + static ei_register_info ei[] = { + { &ei_q932_dse_not_supported, { "q932.dse_not_supported", PI_UNDECODED, PI_WARN, "DSE APDU (not supported)", EXPFILL }}, + { &ei_q932_acse_not_supported, { "q932.acse_not_supported", PI_UNDECODED, PI_WARN, "ACSE APDU (not supported)", EXPFILL }}, + { &ei_q932_unknown_component, { "q932.unknown_component", PI_UNDECODED, PI_WARN, "Unknown Component", EXPFILL }}, + { &ei_q932_asn1_encoded, { "q932.asn1_encoded", PI_UNDECODED, PI_WARN, "ASN.1 Encoded Data Structure(NOT IMPLEMENTED)", EXPFILL }}, + }; + + module_t *q932_module; + expert_module_t* expert_q932; static const enum_val_t facility_encoding[] = { {"Facility as QSIG", "Dissect facility as QSIG", 0}, @@ -323,6 +339,8 @@ void proto_register_q932(void) { /* Register fields and subtrees */ proto_register_field_array(proto_q932, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_q932 = expert_register_protocol(proto_q932); + expert_register_field_array(expert_q932, ei, array_length(ei)); rose_ctx_init(&q932_rose_ctx); |