diff options
author | Michael Mann <mmann78@netscape.net> | 2013-11-05 18:47:26 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2013-11-05 18:47:26 +0000 |
commit | b6b78d69dbae80ea0a0efc39400e3e88d5f9e337 (patch) | |
tree | 3b236e73ee8f1d83c07ecc5ab7a67af8bb19cc85 /asn1/cmip | |
parent | 389423aaaac460f5b0fcbaf37b4f3d5cd7941c5b (diff) |
In an effort to reduce the use of pinfo->private_data (and some true global variables), I converted the ASN.1 dissectors that use pinfo->private_data to exchange a SESSION_DATA_STRUCTURE to instead only exchange it in the context of ASN.1. This meant converting dissectors to the "new" style to pass the SESSION_DATA_STRUCTURE as well as providing a pointer to it in asn1_ctx_t.private_data. Yes, it's still "private data", but it's not used by all dissectors like pinfo->private data is.
svn path=/trunk/; revision=53090
Diffstat (limited to 'asn1/cmip')
-rw-r--r-- | asn1/cmip/cmip.cnf | 28 | ||||
-rw-r--r-- | asn1/cmip/packet-cmip-template.c | 43 |
2 files changed, 38 insertions, 33 deletions
diff --git a/asn1/cmip/cmip.cnf b/asn1/cmip/cmip.cnf index d13697c12b..bca82d5202 100644 --- a/asn1/cmip/cmip.cnf +++ b/asn1/cmip/cmip.cnf @@ -272,7 +272,7 @@ RejectProblem #.FN_BODY Attribute/value if(attributeform==ATTRIBUTE_GLOBAL_FORM){ - offset=call_ber_oid_callback(attribute_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(attribute_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); } else if (dissector_try_uint(attribute_id_dissector_table, attribute_local_id, tvb, actx->pinfo, tree)) { offset=tvb_length (tvb); } else { @@ -283,7 +283,7 @@ RejectProblem FN_VARIANT = _str VAL_PTR = &attributevalueassertion_id #.FN_BODY AttributeValueAssertion/value - offset=call_ber_oid_callback(attributevalueassertion_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(attributevalueassertion_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY Invoke/argument switch(opcode){ @@ -438,16 +438,16 @@ RejectProblem FN_VARIANT = _str HF_INDEX = hf_cmip_actionType_OID VAL_PTR = &object_identifier_id #.FN_BODY ActionInfo/actionInfoArg - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_PARS EventTypeId/globalForm FN_VARIANT = _str HF_INDEX = hf_cmip_eventType_OID VAL_PTR = &object_identifier_id #.FN_BODY EventReportArgument/eventInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY EventReply/eventReplyInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY SetArgument/modificationList/_item/attributeValue if(attributeform==ATTRIBUTE_GLOBAL_FORM){ @@ -462,39 +462,39 @@ RejectProblem FN_VARIANT = _str HF_INDEX = hf_cmip_errorId_OID VAL_PTR = &object_identifier_id #.FN_BODY SpecificErrorInfo/errorInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY AttributeError/attributeValue - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY InvalidArgumentValue/eventValue/eventInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY ActionReply/actionReplyInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); # X.721 #.FN_PARS ManagementExtension/identifier FN_VARIANT = _str VAL_PTR = &object_identifier_id #.FN_BODY ManagementExtension/information - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY AttributeValueChangeDefinition/_item/oldAttributeValue - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_BODY AttributeValueChangeDefinition/_item/newAttributeValue - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_PARS ServiceUser/identifier FN_VARIANT = _str VAL_PTR = &object_identifier_id #.FN_BODY ServiceUser/details - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_PARS SupportedFeatures/_item/featureIdentifier FN_VARIANT = _str VAL_PTR = &object_identifier_id #.FN_BODY SupportedFeatures/_item/featureInfo - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, actx->private_data); #.END diff --git a/asn1/cmip/packet-cmip-template.c b/asn1/cmip/packet-cmip-template.c index a37ae95e5d..32be20c9e3 100644 --- a/asn1/cmip/packet-cmip-template.c +++ b/asn1/cmip/packet-cmip-template.c @@ -97,35 +97,35 @@ static const char *objectclass_identifier_id; /* XXX this one should be broken out later and moved into the conformance file */ -static void -dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { - static struct SESSION_DATA_STRUCTURE* session; - proto_item *item = NULL; - proto_tree *tree = NULL; + struct SESSION_DATA_STRUCTURE* session; + proto_item *item; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); - session = (struct SESSION_DATA_STRUCTURE*)pinfo->private_data; + session = (struct SESSION_DATA_STRUCTURE*)data; /* do we have spdu type from the session dissector? */ if( !session ){ - proto_tree_add_text(tree, tvb, 0, -1, + proto_tree_add_text(parent_tree, tvb, 0, -1, "Internal error:can't get spdu type from session dissector."); - return; - } else { - if(session->spdu_type == 0 ) { - proto_tree_add_text(tree, tvb, 0, -1, - "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); - return; - } + return 0; } - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_cmip, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_cmip); + if(session->spdu_type == 0 ) { + proto_tree_add_text(parent_tree, tvb, 0, -1, + "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); + return 0; } + asn1_ctx.private_data = session; + + item = proto_tree_add_item(parent_tree, proto_cmip, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_cmip); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMIP"); col_clear(pinfo->cinfo, COL_INFO); switch(session->spdu_type){ @@ -145,6 +145,8 @@ dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) default: ; } + + return tvb_length(tvb); } /*--- proto_register_cmip ----------------------------------------------*/ @@ -196,6 +198,7 @@ void proto_register_cmip(void) { /* Register protocol */ proto_cmip = proto_register_protocol(PNAME, PSNAME, PFNAME); + new_register_dissector("cmip", dissect_cmip, proto_cmip); /* Register fields and subtrees */ proto_register_field_array(proto_cmip, hf, array_length(hf)); @@ -210,8 +213,10 @@ void proto_register_cmip(void) { /*--- proto_reg_handoff_cmip -------------------------------------------*/ void proto_reg_handoff_cmip(void) { - register_ber_oid_dissector("2.9.0.0.2", dissect_cmip, proto_cmip, "cmip"); - register_ber_oid_dissector("2.9.1.1.4", dissect_cmip, proto_cmip, "joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)"); + dissector_handle_t cmip_handle = find_dissector("cmip"); + + register_ber_oid_dissector_handle("2.9.0.0.2", cmip_handle, proto_cmip, "cmip"); + register_ber_oid_dissector_handle("2.9.1.1.4", cmip_handle, proto_cmip, "joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)"); oid_add_from_string("2.9.3.2.3.1","managedObjectClass(3) alarmRecord(1)"); oid_add_from_string("2.9.3.2.3.2","managedObjectClass(3) attributeValueChangeRecord(2)"); |