From 9518cb7c7c04d1334a68271e29222855592d10cb Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Thu, 17 Nov 2011 20:05:03 +0000 Subject: [PATCH] Add a dissector table for National operation codes. svn path=/trunk/; revision=39912 --- asn1/ansi_tcap/packet-ansi_tcap-template.c | 20 +++++++++++----- epan/dissectors/packet-ansi_tcap.c | 28 ++++++++++++++-------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/asn1/ansi_tcap/packet-ansi_tcap-template.c b/asn1/ansi_tcap/packet-ansi_tcap-template.c index 063fd5bf8a..511a61e930 100644 --- a/asn1/ansi_tcap/packet-ansi_tcap-template.c +++ b/asn1/ansi_tcap/packet-ansi_tcap-template.c @@ -78,6 +78,9 @@ static gboolean tcap_subdissector_used=FALSE; static struct tcaphash_context_t * gp_tcap_context=NULL; +/* Note the high bit should be masked off when registering in this table (0x7fff)*/ +static dissector_table_t ansi_tcap_national_opcode_table; /* National Operation Codes */ + #include "packet-ansi_tcap-ett.c" #define MAX_SSN 254 @@ -325,12 +328,15 @@ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){ /* national */ guint8 family = (ansi_tcap_private.d.OperationCode_national & 0x7f00)>>8; guint8 specifier = (guint8)(ansi_tcap_private.d.OperationCode_national & 0xff); - item = proto_tree_add_text(tree, 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; + 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, + "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){ @@ -519,6 +525,8 @@ proto_register_ansi_tcap(void) proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap); + /* Note the high bit should be masked off when registering in this table (0x7fff)*/ + ansi_tcap_national_opcode_table = register_dissector_table("ansi_tcap.nat.opcode", "ANSI TCAP National Opcodes", FT_UINT16, BASE_DEC); /* 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)); diff --git a/epan/dissectors/packet-ansi_tcap.c b/epan/dissectors/packet-ansi_tcap.c index 029218be9d..ce74925ae9 100644 --- a/epan/dissectors/packet-ansi_tcap.c +++ b/epan/dissectors/packet-ansi_tcap.c @@ -142,6 +142,9 @@ static gboolean tcap_subdissector_used=FALSE; static struct tcaphash_context_t * gp_tcap_context=NULL; +/* Note the high bit should be masked off when registering in this table (0x7fff)*/ +static dissector_table_t ansi_tcap_national_opcode_table; /* National Operation Codes */ + /*--- Included file: packet-ansi_tcap-ett.c ---*/ #line 1 "../../asn1/ansi_tcap/packet-ansi_tcap-ett.c" @@ -169,7 +172,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 82 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 85 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" #define MAX_SSN 254 @@ -416,12 +419,15 @@ find_tcap_subdissector(tvbuff_t *tvb, asn1_ctx_t *actx, proto_tree *tree){ /* national */ guint8 family = (ansi_tcap_private.d.OperationCode_national & 0x7f00)>>8; guint8 specifier = (guint8)(ansi_tcap_private.d.OperationCode_national & 0xff); - item = proto_tree_add_text(tree, 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; + 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, + "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){ @@ -1402,7 +1408,7 @@ dissect_ansi_tcap_PackageType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int /*--- End of included file: packet-ansi_tcap-fn.c ---*/ -#line 360 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 366 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" @@ -1748,7 +1754,7 @@ proto_register_ansi_tcap(void) NULL, HFILL }}, /*--- End of included file: packet-ansi_tcap-hfarr.c ---*/ -#line 497 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 503 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" }; /* Setup protocol subtree array */ @@ -1786,7 +1792,7 @@ proto_register_ansi_tcap(void) &ett_ansi_tcap_T_paramSet, /*--- End of included file: packet-ansi_tcap-ettarr.c ---*/ -#line 508 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" +#line 514 "../../asn1/ansi_tcap/packet-ansi_tcap-template.c" }; static enum_val_t ansi_tcap_response_matching_type_values[] = { @@ -1801,6 +1807,8 @@ proto_register_ansi_tcap(void) proto_ansi_tcap = proto_register_protocol(PNAME, PSNAME, PFNAME); register_dissector("ansi_tcap", dissect_ansi_tcap, proto_ansi_tcap); + /* Note the high bit should be masked off when registering in this table (0x7fff)*/ + ansi_tcap_national_opcode_table = register_dissector_table("ansi_tcap.nat.opcode", "ANSI TCAP National Opcodes", FT_UINT16, BASE_DEC); /* 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));