From cd02af56a1e39c66b44fd7957aff3b7b77a59e9d Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 8 Aug 2014 09:19:29 -0400 Subject: 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 Reviewed-by: Michael Mann --- asn1/qsig/packet-qsig-template.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'asn1/qsig') diff --git a/asn1/qsig/packet-qsig-template.c b/asn1/qsig/packet-qsig-template.c index cad737acff..304ab88d02 100644 --- a/asn1/qsig/packet-qsig-template.c +++ b/asn1/qsig/packet-qsig-template.c @@ -24,6 +24,7 @@ #include "config.h" #include +#include #include #include @@ -308,6 +309,10 @@ static gint ett_qsig_unknown_extension = -1; #include "packet-qsig-ett.c" static gint ett_cnq_PSS1InformationElement = -1; +static expert_field ei_qsig_unsupported_arg_type = EI_INIT; +static expert_field ei_qsig_unsupported_result_type = EI_INIT; +static expert_field ei_qsig_unsupported_error_type = EI_INIT; + /* Preferences */ /* Subdissectors */ @@ -420,7 +425,7 @@ dissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = op_ptr->arg_pdu(tvb, pinfo, qsig_tree, NULL); else if (tvb_reported_length_remaining(tvb, offset) > 0) { - proto_tree_add_text(qsig_tree, tvb, offset, -1, "UNSUPPORTED ARGUMENT TYPE (QSIG)"); + proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_error_type, tvb, offset, -1); offset += tvb_captured_length_remaining(tvb, offset); } @@ -474,7 +479,7 @@ dissect_qsig_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = op_ptr->res_pdu(tvb, pinfo, qsig_tree, NULL); else if (tvb_reported_length_remaining(tvb, offset) > 0) { - proto_tree_add_text(qsig_tree, tvb, offset, -1, "UNSUPPORTED RESULT TYPE (QSIG)"); + proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_result_type, tvb, offset, -1); offset += tvb_captured_length_remaining(tvb, offset); } @@ -523,7 +528,7 @@ dissect_qsig_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = err_ptr->err_pdu(tvb, pinfo, qsig_tree, NULL); else if (tvb_reported_length_remaining(tvb, offset) > 0) { - proto_tree_add_text(qsig_tree, tvb, offset, -1, "UNSUPPORTED ERROR TYPE (QSIG)"); + proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_error_type, tvb, offset, -1); offset += tvb_captured_length_remaining(tvb, offset); } @@ -668,12 +673,22 @@ void proto_register_qsig(void) { &ett_cnq_PSS1InformationElement, }; + static ei_register_info ei[] = { + { &ei_qsig_unsupported_arg_type, { "qsig.unsupported.arg_type", PI_UNDECODED, PI_WARN, "UNSUPPORTED ARGUMENT TYPE (QSIG)", EXPFILL }}, + { &ei_qsig_unsupported_result_type, { "qsig.unsupported.result_type", PI_UNDECODED, PI_WARN, "UNSUPPORTED RESULT TYPE (QSIG)", EXPFILL }}, + { &ei_qsig_unsupported_error_type, { "qsig.unsupported.error_type", PI_UNDECODED, PI_WARN, "UNSUPPORTED ERROR TYPE (QSIG)", EXPFILL }}, + }; + + expert_module_t* expert_qsig; + /* Register protocol and dissector */ proto_qsig = proto_register_protocol(PNAME, PSNAME, PFNAME); /* Register fields and subtrees */ proto_register_field_array(proto_qsig, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_qsig = expert_register_protocol(proto_qsig); + expert_register_field_array(expert_qsig, ei, array_length(ei)); /* Register dissector tables */ extension_dissector_table = register_dissector_table("qsig.ext", "QSIG Extension", FT_STRING, BASE_NONE); -- cgit v1.2.3