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 --- epan/dissectors/packet-ansi_tcap.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'epan/dissectors/packet-ansi_tcap.c') diff --git a/epan/dissectors/packet-ansi_tcap.c b/epan/dissectors/packet-ansi_tcap.c index b850febaec..0735243b2e 100644 --- a/epan/dissectors/packet-ansi_tcap.c +++ b/epan/dissectors/packet-ansi_tcap.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -124,7 +125,7 @@ static int hf_ansi_tcap_paramSequence = -1; /* T_paramSequence */ static int hf_ansi_tcap_paramSet = -1; /* T_paramSet */ /*--- End of included file: packet-ansi_tcap-hf.c ---*/ -#line 64 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 65 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" /* Initialize the subtree pointers */ static gint ett_tcap = -1; @@ -135,6 +136,8 @@ static gint ett_otid = -1; static gint ett_dtid = -1; static gint ett_ansi_tcap_stat = -1; +static expert_field ei_ansi_tcap_dissector_not_implemented = EI_INIT; + static struct tcapsrt_info_t * gp_tcapsrt_info; static gboolean tcap_subdissector_used=FALSE; @@ -170,7 +173,7 @@ static gint ett_ansi_tcap_T_paramSequence = -1; static gint ett_ansi_tcap_T_paramSet = -1; /*--- End of included file: packet-ansi_tcap-ett.c ---*/ -#line 83 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 86 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" #define MAX_SSN 254 @@ -412,22 +415,20 @@ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){ guint8 family = (ansi_tcap_private.d.OperationCode_national & 0x7f00)>>8; guint8 specifier = (guint8)(ansi_tcap_private.d.OperationCode_national & 0xff); if(!dissector_try_uint(ansi_tcap_national_opcode_table, ansi_tcap_private.d.OperationCode_national, tvb, actx->pinfo, tcap_top_tree)){ - item = proto_tree_add_text(tree, tvb, 0, -1, + proto_tree_add_expert_format(tree, actx->pinfo, &ei_ansi_tcap_dissector_not_implemented, tvb, 0, -1, "Dissector for ANSI TCAP NATIONAL code:0x%x(Family %u, Specifier %u) \n" "not implemented. Contact Wireshark developers if you want this supported(Spec required)", ansi_tcap_private.d.OperationCode_national, family, specifier); - PROTO_ITEM_SET_GENERATED(item); return FALSE; } return TRUE; }else if(ansi_tcap_private.d.OperationCode == 1){ /* private */ if((ansi_tcap_private.d.OperationCode_private & 0x0900) != 0x0900){ - item = proto_tree_add_text(tree, tvb, 0, -1, + proto_tree_add_expert_format(tree, actx->pinfo, &ei_ansi_tcap_dissector_not_implemented, tvb, 0, -1, "Dissector for ANSI TCAP PRIVATE code:%u not implemented.\n" "Contact Wireshark developers if you want this supported(Spec required)", ansi_tcap_private.d.OperationCode_private); - PROTO_ITEM_SET_GENERATED(item); return FALSE; } } @@ -1389,7 +1390,7 @@ dissect_ansi_tcap_PackageType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int /*--- End of included file: packet-ansi_tcap-fn.c ---*/ -#line 358 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 359 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" @@ -1733,7 +1734,7 @@ proto_register_ansi_tcap(void) NULL, HFILL }}, /*--- End of included file: packet-ansi_tcap-hfarr.c ---*/ -#line 493 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 494 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" }; /* Setup protocol subtree array */ @@ -1771,9 +1772,15 @@ proto_register_ansi_tcap(void) &ett_ansi_tcap_T_paramSet, /*--- End of included file: packet-ansi_tcap-ettarr.c ---*/ -#line 504 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 505 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" }; + static ei_register_info ei[] = { + { &ei_ansi_tcap_dissector_not_implemented, { "ansi_tcap.dissector_not_implemented", PI_UNDECODED, PI_WARN, "Dissector not implemented", EXPFILL }}, + }; + + expert_module_t* expert_ansi_tcap; + static const enum_val_t ansi_tcap_response_matching_type_values[] = { {"Only Transaction ID will be used in Invoke/response matching", "Transaction ID only", 0}, {"Transaction ID and Source will be used in Invoke/response matching", "Transaction ID and Source", 1}, @@ -1781,7 +1788,6 @@ proto_register_ansi_tcap(void) {NULL, NULL, -1} }; - /* Register the protocol name and description */ proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap); @@ -1791,6 +1797,8 @@ proto_register_ansi_tcap(void) /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_ansi_tcap, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_ansi_tcap = expert_register_protocol(proto_ansi_tcap); + expert_register_field_array(expert_ansi_tcap, ei, array_length(ei)); ansi_tcap_module = prefs_register_protocol(proto_ansi_tcap, proto_reg_handoff_ansi_tcap); -- cgit v1.2.3