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 | |
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')
-rw-r--r-- | asn1/acse/acse.cnf | 8 | ||||
-rw-r--r-- | asn1/acse/packet-acse-template.c | 67 | ||||
-rw-r--r-- | asn1/cmip/cmip.cnf | 28 | ||||
-rw-r--r-- | asn1/cmip/packet-cmip-template.c | 43 | ||||
-rw-r--r-- | asn1/disp/packet-disp-template.c | 34 | ||||
-rw-r--r-- | asn1/dop/dop.cnf | 32 | ||||
-rw-r--r-- | asn1/dop/packet-dop-template.c | 39 | ||||
-rw-r--r-- | asn1/dsp/packet-dsp-template.c | 34 | ||||
-rw-r--r-- | asn1/idmp/idmp.cnf | 16 | ||||
-rw-r--r-- | asn1/idmp/packet-idmp-template.c | 27 | ||||
-rw-r--r-- | asn1/p1/p1.cnf | 8 | ||||
-rw-r--r-- | asn1/p1/packet-p1-template.c | 28 | ||||
-rw-r--r-- | asn1/pres/packet-pres-template.c | 66 | ||||
-rw-r--r-- | asn1/pres/pres.cnf | 5 | ||||
-rw-r--r-- | asn1/ros/packet-ros-template.c | 35 | ||||
-rw-r--r-- | asn1/ros/packet-ros-template.h | 2 | ||||
-rw-r--r-- | asn1/ros/ros.cnf | 36 | ||||
-rw-r--r-- | asn1/rtse/packet-rtse-template.c | 45 | ||||
-rw-r--r-- | asn1/rtse/rtse.cnf | 15 |
19 files changed, 292 insertions, 276 deletions
diff --git a/asn1/acse/acse.cnf b/asn1/acse/acse.cnf index b3d815032d..ec0d8c0063 100644 --- a/asn1/acse/acse.cnf +++ b/asn1/acse/acse.cnf @@ -46,7 +46,7 @@ PDV-list/presentation-data-values/octet-aligned pDVList_octet_aligned FN_VARIANT = _str VAL_PTR = &object_identifier_id #.FN_BODY Authentication-value-other/other-mechanism-value - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree, actx->private_data); #.FN_BODY PDV-list/presentation-data-values/simple-ASN1-type /*XXX not implemented yet */ @@ -69,6 +69,8 @@ PDV-list/presentation-data-values/octet-aligned pDVList_octet_aligned #.FN_BODY EXTERNALt/_untag/indirect-reference char *oid; + struct SESSION_DATA_STRUCTURE* session = actx->private_data; + offset = dissect_ber_integer(FALSE, actx, tree, tvb, offset, hf_acse_indirect_reference, &indir_ref); @@ -85,10 +87,10 @@ PDV-list/presentation-data-values/octet-aligned pDVList_octet_aligned FN_VARIANT = _str VAL_PTR = &object_identifier_id #.FN_BODY EXTERNALt/_untag/encoding/single-ASN1-type - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, actx->private_data); #.FN_BODY EXTERNALt/_untag/encoding/octet-aligned - offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, NULL); + offset=call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, actx->private_data); #.FN_BODY AARQ-apdu col_append_str(actx->pinfo->cinfo, COL_INFO, "A-Associate-Request"); diff --git a/asn1/acse/packet-acse-template.c b/asn1/acse/packet-acse-template.c index 0684dfb865..d8b1a46119 100644 --- a/asn1/acse/packet-acse-template.c +++ b/asn1/acse/packet-acse-template.c @@ -76,8 +76,6 @@ static gint ett_acse = -1; static expert_field ei_acse_dissector_not_available = EI_INIT; -static struct SESSION_DATA_STRUCTURE* session = NULL; - static const char *object_identifier_id; /* indirect_reference, used to pick up the signalling so we know what kind of data is transferred in SES_DATA_TRANSFER_PDUs */ @@ -156,13 +154,14 @@ find_oid_by_ctx_id(packet_info *pinfo _U_, guint32 idx) /* * Dissect ACSE PDUs inside a PPDU. */ -static void -dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; char *oid; + struct SESSION_DATA_STRUCTURE* session; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); @@ -173,24 +172,26 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) proto_tree_add_text(parent_tree, tvb, offset, tvb_reported_length_remaining(tvb,offset), "User data"); - return; /* no, it isn't a ACSE PDU */ + return 0; /* no, it isn't a ACSE PDU */ } /* do we have spdu type from the session dissector? */ - if( !pinfo->private_data ){ + if( data == NULL){ if(parent_tree){ REPORT_DISSECTOR_BUG("Can't get SPDU type from session dissector."); } - return ; - } else { - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); - if(session->spdu_type == 0 ) { - if(parent_tree){ - REPORT_DISSECTOR_BUG( - wmem_strdup_printf(wmem_packet_scope(), "Wrong spdu type %x from session dissector.",session->spdu_type)); - return ; - } + return 0; + } + + session = ( (struct SESSION_DATA_STRUCTURE*)data); + if(session->spdu_type == 0 ) { + if(parent_tree){ + REPORT_DISSECTOR_BUG( + wmem_strdup_printf(wmem_packet_scope(), "Wrong spdu type %x from session dissector.",session->spdu_type)); + return 0; } } + + asn1_ctx.private_data = session; /* save parent_tree so subdissectors can create new top nodes */ top_tree=parent_tree; @@ -220,33 +221,29 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) tvb, offset, -1); } top_tree = NULL; - return; + return 0; default: top_tree = NULL; - return; + return 0; } if(session->spdu_type == CLSES_UNIT_DATA) { /* create display subtree for the connectionless protocol */ - if(parent_tree) - { - item = proto_tree_add_item(parent_tree, proto_clacse, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_acse); - } + item = proto_tree_add_item(parent_tree, proto_clacse, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_acse); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CL-ACSE"); - col_clear(pinfo->cinfo, COL_INFO); + col_clear(pinfo->cinfo, COL_INFO); } else { /* create display subtree for the protocol */ - if(parent_tree) - { - item = proto_tree_add_item(parent_tree, proto_acse, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_acse); - } + item = proto_tree_add_item(parent_tree, proto_acse, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_acse); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ACSE"); - col_clear(pinfo->cinfo, COL_INFO); + col_clear(pinfo->cinfo, COL_INFO); } /* we can't make any additional checking here */ @@ -260,7 +257,8 @@ dissect_acse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } -top_tree = NULL; + top_tree = NULL; + return tvb_length(tvb); } /*--- proto_register_acse ----------------------------------------------*/ @@ -285,7 +283,7 @@ void proto_register_acse(void) { /* Register protocol */ proto_acse = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("acse", dissect_acse, proto_acse); + new_register_dissector("acse", dissect_acse, proto_acse); /* Register connectionless protocol */ proto_clacse = proto_register_protocol(CLPNAME, CLPSNAME, CLPFNAME); @@ -302,9 +300,10 @@ void proto_register_acse(void) { /*--- proto_reg_handoff_acse -------------------------------------------*/ void proto_reg_handoff_acse(void) { /*#include "packet-acse-dis-tab.c"*/ + dissector_handle_t acse_handle = find_dissector("acse"); oid_add_from_string("id-aCSE","2.2.3.1.1"); - register_ber_oid_dissector(ACSE_APDU_OID, dissect_acse, proto_acse, "id-as-acse"); + register_ber_oid_dissector_handle(ACSE_APDU_OID, acse_handle, proto_acse, "id-as-acse"); } 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)"); diff --git a/asn1/disp/packet-disp-template.c b/asn1/disp/packet-disp-template.c index 961cf9dcf7..ef4e2f0570 100644 --- a/asn1/disp/packet-disp-template.c +++ b/asn1/disp/packet-disp-template.c @@ -61,8 +61,6 @@ static void prefs_register_disp(void); /* forward declaration for use in prefere /* Initialize the protocol and registered fields */ static int proto_disp = -1; -static struct SESSION_DATA_STRUCTURE* session = NULL; - #include "packet-disp-hf.c" /* Initialize the subtree pointers */ @@ -74,13 +72,14 @@ static gint ett_disp = -1; /* * Dissect DISP PDUs inside a ROS PDUs */ -static void -dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; + struct SESSION_DATA_STRUCTURE* session; int (*disp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL; const char *disp_op_name; asn1_ctx_t asn1_ctx; @@ -88,20 +87,21 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* do we have operation information from the ROS dissector? */ - if( !pinfo->private_data ){ + if( data == NULL ){ if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error: can't get operation information from ROS dissector."); } - return ; - } else { - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); + return 0; } - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_disp, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_disp); - } + session = ((struct SESSION_DATA_STRUCTURE*)data); + + asn1_ctx.private_data = session; + + item = proto_tree_add_item(parent_tree, proto_disp, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_disp); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "DISP"); col_clear(pinfo->cinfo, COL_INFO); @@ -172,7 +172,7 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; default: proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DISP PDU"); - return; + return tvb_length(tvb); } if(disp_dissector) { @@ -187,6 +187,8 @@ dissect_disp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } } + + return tvb_length(tvb); } @@ -208,7 +210,7 @@ void proto_register_disp(void) { /* Register protocol */ proto_disp = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("disp", dissect_disp, proto_disp); + new_register_dissector("disp", dissect_disp, proto_disp); /* Register fields and subtrees */ proto_register_field_array(proto_disp, hf, array_length(hf)); diff --git a/asn1/dop/dop.cnf b/asn1/dop/dop.cnf index bb6f148ae5..d1f90318ea 100644 --- a/asn1/dop/dop.cnf +++ b/asn1/dop/dop.cnf @@ -107,67 +107,67 @@ OpBindingErrorParam/bindingType BindingType #.FN_BODY EstablishOperationalBindingArgumentData/initiator/symmetric - offset = call_dop_oid_callback("establish.symmetric", tvb, offset, actx->pinfo, tree, "symmetric"); + offset = call_dop_oid_callback("establish.symmetric", tvb, offset, actx->pinfo, tree, "symmetric", actx->private_data); #.FN_BODY EstablishOperationalBindingArgumentData/initiator/roleA-initiates - offset = call_dop_oid_callback("establish.rolea", tvb, offset, actx->pinfo, tree, "roleA"); + offset = call_dop_oid_callback("establish.rolea", tvb, offset, actx->pinfo, tree, "roleA", actx->private_data); #.FN_BODY EstablishOperationalBindingArgumentData/initiator/roleB-initiates - offset = call_dop_oid_callback("establish.roleb", tvb, offset, actx->pinfo, tree, "roleB"); + offset = call_dop_oid_callback("establish.roleb", tvb, offset, actx->pinfo, tree, "roleB", actx->private_data); #.FN_BODY ModifyOperationalBindingArgumentData/initiator/symmetric - offset = call_dop_oid_callback("modify.symmetric", tvb, offset, actx->pinfo, tree, "symmetric"); + offset = call_dop_oid_callback("modify.symmetric", tvb, offset, actx->pinfo, tree, "symmetric", actx->private_data); #.FN_BODY ModifyOperationalBindingArgumentData/initiator/roleA-initiates - offset = call_dop_oid_callback("modify.rolea", tvb, offset, actx->pinfo, tree, "roleA"); + offset = call_dop_oid_callback("modify.rolea", tvb, offset, actx->pinfo, tree, "roleA", actx->private_data); #.FN_BODY ModifyOperationalBindingArgumentData/initiator/roleB-initiates - offset = call_dop_oid_callback("modify.roleb", tvb, offset, actx->pinfo, tree, "roleB"); + offset = call_dop_oid_callback("modify.roleb", tvb, offset, actx->pinfo, tree, "roleB", actx->private_data); #.FN_BODY TerminateOperationalBindingArgumentData/initiator/symmetric - offset = call_dop_oid_callback("terminate.symmetric", tvb, offset, actx->pinfo, tree, "symmetric"); + offset = call_dop_oid_callback("terminate.symmetric", tvb, offset, actx->pinfo, tree, "symmetric", actx->private_data); #.FN_BODY TerminateOperationalBindingArgumentData/initiator/roleA-initiates - offset = call_dop_oid_callback("terminate.rolea", tvb, offset, actx->pinfo, tree, "roleA"); + offset = call_dop_oid_callback("terminate.rolea", tvb, offset, actx->pinfo, tree, "roleA", actx->private_data); #.FN_BODY TerminateOperationalBindingArgumentData/initiator/roleB-initiates - offset = call_dop_oid_callback("terminate.roleb", tvb, offset, actx->pinfo, tree, "roleB"); + offset = call_dop_oid_callback("terminate.roleb", tvb, offset, actx->pinfo, tree, "roleB", actx->private_data); #.FN_BODY EstablishOperationalBindingArgumentData/agreement - offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL); + offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL, actx->private_data); #.FN_BODY EstablishOperationalBindingResult/initiator/symmetric - offset = call_dop_oid_callback("establish.symmetric", tvb, offset, actx->pinfo, tree, "symmetric"); + offset = call_dop_oid_callback("establish.symmetric", tvb, offset, actx->pinfo, tree, "symmetric", actx->private_data); #.FN_BODY EstablishOperationalBindingResult/initiator/roleA-replies - offset = call_dop_oid_callback("establish.rolea", tvb, offset, actx->pinfo, tree, "roleA"); + offset = call_dop_oid_callback("establish.rolea", tvb, offset, actx->pinfo, tree, "roleA", actx->private_data); #.FN_BODY EstablishOperationalBindingResult/initiator/roleB-replies - offset = call_dop_oid_callback("establish.roleb", tvb, offset, actx->pinfo, tree, "roleB"); + offset = call_dop_oid_callback("establish.roleb", tvb, offset, actx->pinfo, tree, "roleB", actx->private_data); #.FN_BODY OpBindingErrorParam/agreementProposal - offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL); + offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL, actx->private_data); #.FN_BODY ModifyOperationalBindingResultData/newAgreement - offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL); + offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL, actx->private_data); #.FN_BODY ModifyOperationalBindingArgumentData/newAgreement - offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL); + offset = call_dop_oid_callback("agreement", tvb, offset, actx->pinfo, tree, NULL, actx->private_data); #.FN_BODY OperationalBindingID/identifier VAL_PTR = &value diff --git a/asn1/dop/packet-dop-template.c b/asn1/dop/packet-dop-template.c index e8033d785a..28c3f138c7 100644 --- a/asn1/dop/packet-dop-template.c +++ b/asn1/dop/packet-dop-template.c @@ -58,10 +58,9 @@ static void prefs_register_dop(void); /* forward declaration for use in preferen /* Initialize the protocol and registered fields */ static int proto_dop = -1; -static struct SESSION_DATA_STRUCTURE* session = NULL; static const char *binding_type = NULL; /* binding_type */ -static int call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info); +static int call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info, void* data); #include "packet-dop-hf.c" @@ -86,7 +85,7 @@ static void append_oid(packet_info *pinfo, const char *oid) #include "packet-dop-fn.c" static int -call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info) +call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, const char *col_info, void* data) { char* binding_param; @@ -94,7 +93,7 @@ call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet col_append_fstr(pinfo->cinfo, COL_INFO, " %s", col_info); - if (dissector_try_string(dop_dissector_table, binding_param, tvb, pinfo, tree, NULL)) { + if (dissector_try_string(dop_dissector_table, binding_param, tvb, pinfo, tree, data)) { offset = tvb_reported_length (tvb); } else { proto_item *item=NULL; @@ -115,13 +114,14 @@ call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet /* * Dissect DOP PDUs inside a ROS PDUs */ -static void -dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; + struct SESSION_DATA_STRUCTURE* session; int (*dop_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL; const char *dop_op_name; asn1_ctx_t asn1_ctx; @@ -129,23 +129,24 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* do we have operation information from the ROS dissector? */ - if( !pinfo->private_data ){ + if( data == NULL ){ if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error: can't get operation information from ROS dissector."); } - return ; - } else { - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); + return 0; } - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_dop, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_dop); - } + session = ( (struct SESSION_DATA_STRUCTURE*)data ); + + item = proto_tree_add_item(parent_tree, proto_dop, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_dop); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "DOP"); col_clear(pinfo->cinfo, COL_INFO); + asn1_ctx.private_data = session; + switch(session->ros_op & ROS_OP_MASK) { case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */ dop_dissector = dissect_dop_DSAOperationalManagementBindArgument; @@ -213,7 +214,7 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; default: proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DOP PDU"); - return; + return tvb_length(tvb); } if(dop_dissector) { @@ -228,6 +229,8 @@ dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } } + + return tvb_length(tvb); } @@ -258,7 +261,7 @@ void proto_register_dop(void) { /* Register protocol */ proto_dop = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("dop", dissect_dop, proto_dop); + new_register_dissector("dop", dissect_dop, proto_dop); dop_dissector_table = register_dissector_table("dop.oid", "DOP OID Dissectors", FT_STRING, BASE_NONE); diff --git a/asn1/dsp/packet-dsp-template.c b/asn1/dsp/packet-dsp-template.c index 946119212c..4a9870ea30 100644 --- a/asn1/dsp/packet-dsp-template.c +++ b/asn1/dsp/packet-dsp-template.c @@ -55,8 +55,6 @@ static void prefs_register_dsp(void); /* forward declaration for use in preferen /* Initialize the protocol and registered fields */ static int proto_dsp = -1; -static struct SESSION_DATA_STRUCTURE* session = NULL; - #include "packet-dsp-hf.c" /* Initialize the subtree pointers */ @@ -68,13 +66,14 @@ static gint ett_dsp = -1; /* * Dissect X518 PDUs inside a ROS PDUs */ -static void -dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; + struct SESSION_DATA_STRUCTURE* session; int (*dsp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL; const char *dsp_op_name; asn1_ctx_t asn1_ctx; @@ -82,23 +81,24 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* do we have operation information from the ROS dissector? */ - if( !pinfo->private_data ){ + if( data == NULL ){ if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error: can't get operation information from ROS dissector."); } - return ; - } else { - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); + return 0; } - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_dsp); - } + session = ( (struct SESSION_DATA_STRUCTURE*)data); + + item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_dsp); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAP"); col_clear(pinfo->cinfo, COL_INFO); + asn1_ctx.private_data = session; + switch(session->ros_op & ROS_OP_MASK) { case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */ dsp_dissector = dissect_dsp_DSASystemBindArgument; @@ -244,7 +244,7 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; default: proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DSP PDU"); - return; + return tvb_length(tvb); } if(dsp_dissector) { @@ -259,6 +259,8 @@ dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } } + + return tvb_length(tvb); } @@ -281,7 +283,7 @@ void proto_register_dsp(void) { /* Register protocol */ proto_dsp = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("dsp", dissect_dsp, proto_dsp); + new_register_dissector("dsp", dissect_dsp, proto_dsp); /* Register fields and subtrees */ proto_register_field_array(proto_dsp, hf, array_length(hf)); diff --git a/asn1/idmp/idmp.cnf b/asn1/idmp/idmp.cnf index 0b74ec29ac..a98458204a 100644 --- a/asn1/idmp/idmp.cnf +++ b/asn1/idmp/idmp.cnf @@ -28,8 +28,9 @@ IDM-PDU/result idm_result IdmResult/invokeID idm_invokeID #.FN_BODY IdmBind/argument + struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_ARGUMENT), top_tree); + return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_ARGUMENT), top_tree, session); #.END @@ -37,8 +38,9 @@ IdmResult/invokeID idm_invokeID #.FN_BODY IdmBindResult/result + struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_RESULT), top_tree); + return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND | ROS_OP_RESULT), top_tree, session); #.END @@ -47,23 +49,25 @@ IdmResult/invokeID idm_invokeID #.END #.FN_BODY IdmBindError/error + struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND| ROS_OP_ERROR), top_tree); + return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_BIND| ROS_OP_ERROR), top_tree, session); #.END #.FN_PARS Code/local VAL_PTR = &opcode #.FN_BODY Request/argument + struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_ARGUMENT | opcode), top_tree); + return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_ARGUMENT | opcode), top_tree, session); #.END #.FN_BODY IdmResult/result + struct SESSION_DATA_STRUCTURE *session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_RESULT | opcode), top_tree); - + return call_idmp_oid_callback(tvb, offset, actx->pinfo, (ROS_OP_INVOKE | ROS_OP_RESULT | opcode), top_tree, session); #.END diff --git a/asn1/idmp/packet-idmp-template.c b/asn1/idmp/packet-idmp-template.c index d50de532df..075bd6d929 100644 --- a/asn1/idmp/packet-idmp-template.c +++ b/asn1/idmp/packet-idmp-template.c @@ -108,11 +108,9 @@ static const fragment_items idmp_frag_items = { }; -static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree _U_) +static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, int op, proto_tree *tree, struct SESSION_DATA_STRUCTURE *session) { - struct SESSION_DATA_STRUCTURE *session; - - if((session = (struct SESSION_DATA_STRUCTURE*)pinfo->private_data) != NULL) { + if(session != NULL) { if((!saved_protocolID) && (op == (ROS_OP_BIND | ROS_OP_RESULT))) { /* save for subsequent operations - should be into session data */ @@ -121,7 +119,7 @@ static int call_idmp_oid_callback(tvbuff_t *tvb, int offset, packet_info *pinfo, /* mimic ROS! */ session->ros_op = op; - offset = call_ros_oid_callback(saved_protocolID ? saved_protocolID : protocolID, tvb, offset, pinfo, top_tree); + offset = call_ros_oid_callback(saved_protocolID ? saved_protocolID : protocolID, tvb, offset, pinfo, tree, session); } return offset; @@ -148,10 +146,9 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t { int offset = 0; - proto_item *item = NULL; - proto_tree *tree = NULL; + proto_item *item; + proto_tree *tree; asn1_ctx_t asn1_ctx; - void *save_private_data; struct SESSION_DATA_STRUCTURE session; gboolean idmp_final; guint32 idmp_length; @@ -171,10 +168,8 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t /* save parent_tree so subdissectors can create new top nodes */ top_tree=parent_tree; - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_idmp); - } + item = proto_tree_add_item(parent_tree, proto_idmp, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_idmp); col_set_str(pinfo->cinfo, COL_PROTOCOL, "IDMP"); @@ -186,6 +181,8 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t proto_tree_add_item(tree, hf_idmp_length, tvb, offset, 4, ENC_BIG_ENDIAN); idmp_length = tvb_get_ntohl(tvb, offset); offset += 4; + asn1_ctx.private_data = &session; + if(idmp_reassemble) { pinfo->fragmented = !idmp_final; @@ -228,12 +225,8 @@ static void dissect_idmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_t } /* not reassembling - just dissect */ if(idmp_final) { - save_private_data = pinfo->private_data; - pinfo->private_data = &session; - + asn1_ctx.private_data = &session; dissect_idmp_IDM_PDU(FALSE, tvb, offset, &asn1_ctx, tree, hf_idmp_PDU); - - pinfo->private_data = save_private_data; } } diff --git a/asn1/p1/p1.cnf b/asn1/p1/p1.cnf index 6e24dc8ba2..f58377ca1e 100644 --- a/asn1/p1/p1.cnf +++ b/asn1/p1/p1.cnf @@ -549,7 +549,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" expert_add_info(actx->pinfo, item, &ei_p1_unknown_standard_extension); } } else if (actx->external.direct_ref_present) { - offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL); + offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data); name = oid_resolved_from_string(actx->external.direct_reference); proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference); } @@ -562,7 +562,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" const char *name; if (actx->external.direct_reference) { - offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL); + offset = call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data); name = oid_resolved_from_string(actx->external.direct_reference); proto_item_append_text(tree, " (%%s)", name ? name : actx->external.direct_reference); } else { @@ -673,7 +673,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" if (next_tvb) { if (ctx && ctx->content_type_id) { - (void) call_ber_oid_callback(ctx->content_type_id, next_tvb, 0, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, NULL); + (void) call_ber_oid_callback(ctx->content_type_id, next_tvb, 0, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); } else if (ctx && ctx->report_unknown_content_type) { proto_item *item = NULL; proto_tree *next_tree = NULL; @@ -1153,7 +1153,7 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" #.FN_BODY TokenTypeData if(actx->external.direct_reference) - call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, NULL); + call_ber_oid_callback(actx->external.direct_reference, tvb, offset, actx->pinfo, tree, actx->private_data); #.FN_PARS Credentials VAL_PTR = &credentials diff --git a/asn1/p1/packet-p1-template.c b/asn1/p1/packet-p1-template.c index 107d7fd85f..bd73ccdabb 100644 --- a/asn1/p1/packet-p1-template.c +++ b/asn1/p1/packet-p1-template.c @@ -221,13 +221,13 @@ dissect_p1_mts_apdu (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) /* * Dissect P1 PDUs inside a PPDU. */ -static void -dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; struct SESSION_DATA_STRUCTURE* session; int (*p1_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) = NULL; const char *p1_op_name; @@ -239,20 +239,21 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE); /* do we have operation information from the ROS dissector? */ - if( !pinfo->private_data ){ + if( data == NULL ){ if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error: can't get operation information from ROS dissector."); } - return; + return 0; } - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); + session = ( (struct SESSION_DATA_STRUCTURE*)data ); + + asn1_ctx.private_data = session; + + item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_p1); - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_p1); - } col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1"); col_clear(pinfo->cinfo, COL_INFO); @@ -279,7 +280,7 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; default: proto_tree_add_text(tree, tvb, offset, -1,"Unsupported P1 PDU"); - return; + return tvb_length(tvb); } col_set_str(pinfo->cinfo, COL_INFO, p1_op_name); @@ -293,6 +294,7 @@ dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } } p1_initialize_content_globals (&asn1_ctx, NULL, FALSE); + return tvb_length(tvb); } @@ -348,7 +350,7 @@ void proto_register_p1(void) { /* Register protocol */ proto_p1 = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("p1", dissect_p1, proto_p1); + new_register_dissector("p1", dissect_p1, proto_p1); proto_p3 = proto_register_protocol("X.411 Message Access Service", "P3", "p3"); diff --git a/asn1/pres/packet-pres-template.c b/asn1/pres/packet-pres-template.c index de4c08463b..3da29d1b73 100644 --- a/asn1/pres/packet-pres-template.c +++ b/asn1/pres/packet-pres-template.c @@ -58,10 +58,6 @@ static int proto_pres = -1; /* Initialize the connectionles protocol */ static int proto_clpres = -1; - -/* type of session envelop */ -static struct SESSION_DATA_STRUCTURE* session = NULL; - /* pointers for acse dissector */ proto_tree *global_tree = NULL; packet_info *global_pinfo = NULL; @@ -230,37 +226,36 @@ pres_free_cb(void *r) * Dissect an PPDU. */ static int -dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* local_session) { proto_item *ti; - proto_tree *pres_tree = NULL; + proto_tree *pres_tree; + struct SESSION_DATA_STRUCTURE* session; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* do we have spdu type from the session dissector? */ - if( !pinfo->private_data ){ - if(tree){ - proto_tree_add_text(tree, tvb, offset, -1, + if( local_session == NULL ){ + proto_tree_add_text(tree, tvb, offset, -1, "Internal error:can't get spdu type from session dissector."); - return 0; - } - }else{ - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); - if(session->spdu_type == 0 ){ - if(tree){ - proto_tree_add_text(tree, tvb, offset, -1, - "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); - return 0; - } - } + return 0; } + + session = local_session; + if(session->spdu_type == 0 ){ + proto_tree_add_text(tree, tvb, offset, -1, + "Internal error:wrong spdu type %x from session dissector.",session->spdu_type); + return 0; + } + /* set up type of PPDU */ col_add_str(pinfo->cinfo, COL_INFO, val_to_str(session->spdu_type, ses_vals, "Unknown PPDU type (0x%02x)")); - if (tree){ - ti = proto_tree_add_item(tree, proto_pres, tvb, offset, -1, ENC_NA); - pres_tree = proto_item_add_subtree(ti, ett_pres); - } + + asn1_ctx.private_data = session; + + ti = proto_tree_add_item(tree, proto_pres, tvb, offset, -1, ENC_NA); + pres_tree = proto_item_add_subtree(ti, ett_pres); switch(session->spdu_type){ case SES_CONNECTION_REQUEST: @@ -296,12 +291,13 @@ dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) return offset; } -static void -dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0, old_offset; + struct SESSION_DATA_STRUCTURE* session; - session = ((struct SESSION_DATA_STRUCTURE*)(pinfo->private_data)); + session = ((struct SESSION_DATA_STRUCTURE*)data); /* first, try to check length */ /* do we have at least 4 bytes */ @@ -309,7 +305,7 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) if (session && session->spdu_type != SES_MAJOR_SYNC_POINT) { proto_tree_add_text(parent_tree, tvb, offset, tvb_reported_length_remaining(tvb,offset),"User data"); - return; /* no, it isn't a presentation PDU */ + return 0; /* no, it isn't a presentation PDU */ } } @@ -335,7 +331,7 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) /* dissect the packet */ dissect_UD_type_PDU(tvb, pinfo, clpres_tree); - return; + return tvb_length(tvb); } /* we can't make any additional checking here */ @@ -348,22 +344,24 @@ dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) /* This is a reassembly initiated in packet-ses */ char *oid = find_oid_by_pres_ctx_id (pinfo, session->pres_ctx_id); if (oid) { - call_ber_oid_callback (oid, tvb, offset, pinfo, parent_tree, NULL); + call_ber_oid_callback (oid, tvb, offset, pinfo, parent_tree, session); } else { proto_tree_add_text(parent_tree, tvb, offset, tvb_reported_length_remaining(tvb,offset),"User data"); } - return; - } + return tvb_length(tvb); + } while (tvb_reported_length_remaining(tvb, offset) > 0){ old_offset = offset; - offset = dissect_ppdu(tvb, offset, pinfo, parent_tree); + offset = dissect_ppdu(tvb, offset, pinfo, parent_tree, session); if(offset <= old_offset){ proto_tree_add_text(parent_tree, tvb, offset, -1,"Invalid offset"); THROW(ReportedBoundsError); } } + + return tvb_length(tvb); } @@ -432,7 +430,7 @@ void proto_register_pres(void) { /* Register protocol */ proto_pres = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("pres", dissect_pres, proto_pres); + new_register_dissector("pres", dissect_pres, proto_pres); /* Register connectionless protocol (just for the description) */ proto_clpres = proto_register_protocol(CLPNAME, CLPSNAME, CLPFNAME); diff --git a/asn1/pres/pres.cnf b/asn1/pres/pres.cnf index 414b3b958d..194d2d9c8d 100644 --- a/asn1/pres/pres.cnf +++ b/asn1/pres/pres.cnf @@ -41,7 +41,7 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason oid=find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier); if(oid){ next_tvb = tvb_new_subset_remaining(tvb, offset); - call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, NULL); + call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, actx->private_data); } else { proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available, tvb, offset, -1); @@ -55,7 +55,7 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason oid=find_oid_by_pres_ctx_id(actx->pinfo, presentation_context_identifier); if(oid){ dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, &next_tvb); - call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, NULL); + call_ber_oid_callback(oid, next_tvb, offset, actx->pinfo, global_tree, actx->private_data); } else { proto_tree_add_expert(tree, actx->pinfo, &ei_pres_dissector_not_available, tvb, offset, -1); @@ -72,6 +72,7 @@ CPR-PPDU/normal-mode-parameters/provider-reason cPR_PPDU__provider-reason #.FN_BODY Presentation-context-identifier const char *name; char *oid; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; %(DEFAULT_BODY)s diff --git a/asn1/ros/packet-ros-template.c b/asn1/ros/packet-ros-template.c index 4cbf770875..dd3929a602 100644 --- a/asn1/ros/packet-ros-template.c +++ b/asn1/ros/packet-ros-template.c @@ -135,7 +135,7 @@ static new_dissector_t ros_lookup_err_dissector(gint32 errcode, const ros_err_t } -static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* session) { ros_info_t *rinfo; gint32 opcode_lcl = 0; @@ -145,9 +145,6 @@ static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinf const value_string *lookup; proto_item *item=NULL; proto_tree *ros_tree=NULL; - struct SESSION_DATA_STRUCTURE* session = NULL; - - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); if((session != NULL) && ((rinfo = (ros_info_t*)g_hash_table_lookup(protocol_table, oid)) != NULL)) { @@ -207,14 +204,14 @@ static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinf } int -call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* session) { tvbuff_t *next_tvb; next_tvb = tvb_new_subset_remaining(tvb, offset); - if(!ros_try_string(oid, next_tvb, pinfo, tree) && - !dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree, NULL)){ + if(!ros_try_string(oid, next_tvb, pinfo, tree, session) && + !dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree, session)){ proto_item *item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "ROS: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); proto_tree *next_tree=proto_item_add_subtree(item, ett_ros_unknown); @@ -374,13 +371,13 @@ ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gui /* * Dissect ROS PDUs inside a PPDU. */ -static void -dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; proto_tree *next_tree=NULL; conversation_t *conversation; ros_conv_info_t *ros_info = NULL; @@ -396,9 +393,10 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error:can't get application context from ACSE dissector."); } - return ; + return 0; } + asn1_ctx.private_data = data; conversation = find_or_create_conversation(pinfo); /* @@ -417,14 +415,13 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) ros_info->next = ros_info_items; ros_info_items = ros_info; - } + } /* pinfo->private_data = ros_info; */ - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_ros); - } + item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_ros); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ROS"); col_clear(pinfo->cinfo, COL_INFO); @@ -443,6 +440,8 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) break; } } + + return tvb_length(tvb); } static void @@ -506,7 +505,7 @@ void proto_register_ros(void) { /* Register protocol */ proto_ros = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("ros", dissect_ros, proto_ros); + new_register_dissector("ros", dissect_ros, proto_ros); /* Register fields and subtrees */ proto_register_field_array(proto_ros, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff --git a/asn1/ros/packet-ros-template.h b/asn1/ros/packet-ros-template.h index f3ca3c04d1..90ffb724d9 100644 --- a/asn1/ros/packet-ros-template.h +++ b/asn1/ros/packet-ros-template.h @@ -75,6 +75,6 @@ typedef struct _ros_info_t { void register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name, gboolean uses_rtse); void register_ros_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name, gboolean uses_rtse); -int call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree); +int call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* session); #endif /* PACKET_ROS_H */ diff --git a/asn1/ros/ros.cnf b/asn1/ros/ros.cnf index 6f7ebfda9c..1aeec52b3c 100644 --- a/asn1/ros/ros.cnf +++ b/asn1/ros/ros.cnf @@ -30,7 +30,7 @@ Reject/problem/returnResult rejectResult #.FN_BODY Invoke/argument char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "invoke argument"); @@ -42,12 +42,12 @@ Reject/problem/returnResult rejectResult session->ros_op = (ROS_OP_INVOKE | ROS_OP_ARGUMENT); /* now add the opcode */ session->ros_op |= opcode; - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ReturnResult/result/result char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "return result"); @@ -59,12 +59,12 @@ Reject/problem/returnResult rejectResult session->ros_op = (ROS_OP_INVOKE | ROS_OP_RESULT); /* now add the opcode */ session->ros_op |= opcode; - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ReturnError/parameter char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "return result"); @@ -76,12 +76,12 @@ Reject/problem/returnResult rejectResult session->ros_op = (ROS_OP_INVOKE | ROS_OP_ERROR); /* now add the opcode (really the error code) */ session->ros_op |= opcode; - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/bind-invoke char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "bind-invoke"); @@ -89,12 +89,12 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_BIND | ROS_OP_ARGUMENT); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/bind-result char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "bind-result"); @@ -102,12 +102,12 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_BIND | ROS_OP_RESULT); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/bind-error char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "bind-error"); @@ -115,13 +115,13 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_BIND | ROS_OP_ERROR); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/unbind-invoke char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "unbind-invoke"); @@ -129,13 +129,13 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_UNBIND | ROS_OP_ARGUMENT); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/unbind-result char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "unbind-result"); @@ -143,12 +143,12 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_UNBIND | ROS_OP_RESULT); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/unbind-error char *oid; - struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->pinfo->private_data; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE *)actx->private_data; /* not sure what the length should be - -1 for now */ proto_tree_add_text(tree, tvb, offset,-1, "unbind-error"); @@ -156,7 +156,7 @@ Reject/problem/returnResult rejectResult if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) { /* this should be ROS! */ session->ros_op = (ROS_OP_UNBIND | ROS_OP_ERROR); - offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree); + offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree, session); } #.FN_BODY ROS/reject diff --git a/asn1/rtse/packet-rtse-template.c b/asn1/rtse/packet-rtse-template.c index 10a306ff4a..6ddd05d159 100644 --- a/asn1/rtse/packet-rtse-template.c +++ b/asn1/rtse/packet-rtse-template.c @@ -46,8 +46,6 @@ /* Initialize the protocol and registered fields */ static int proto_rtse = -1; -static struct SESSION_DATA_STRUCTURE* session = NULL; - static gboolean open_request=FALSE; static guint32 app_proto=0; @@ -142,12 +140,12 @@ register_rtse_oid_dissector_handle(const char *oid, dissector_handle_t dissector } static int -call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) +call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, void* data) { tvbuff_t *next_tvb; next_tvb = tvb_new_subset_remaining(tvb, offset); - if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, NULL)){ + if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, data)){ proto_item *item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "RTSE: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); proto_tree *next_tree=proto_item_add_subtree(item, ett_rtse_unknown); @@ -170,14 +168,14 @@ call_rtse_external_type_callback(gboolean implicit_tag _U_, tvbuff_t *tvb, int o { const char *oid = NULL; - if (actx->external.indirect_ref_present) { + if (actx->external.indirect_ref_present) { oid = (const char *)find_oid_by_pres_ctx_id(actx->pinfo, actx->external.indirect_reference); } else if (actx->external.direct_ref_present) { - oid = actx->external.direct_reference; + oid = actx->external.direct_reference; } if (oid) - offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree); + offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, actx->private_data); return offset; } @@ -187,13 +185,13 @@ call_rtse_external_type_callback(gboolean implicit_tag _U_, tvbuff_t *tvb, int o /* * Dissect RTSE PDUs inside a PPDU. */ -static void -dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) +static int +dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { int offset = 0; int old_offset; - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_item *item; + proto_tree *tree; proto_tree *next_tree=NULL; tvbuff_t *next_tvb = NULL; tvbuff_t *data_tvb = NULL; @@ -201,6 +199,7 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) guint32 fragment_length; guint32 rtse_id = 0; gboolean data_handled = FALSE; + struct SESSION_DATA_STRUCTURE* session; conversation_t *conversation = NULL; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); @@ -209,19 +208,20 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) top_tree=parent_tree; /* do we have application context from the acse dissector? */ - if( !pinfo->private_data ){ + if( data == NULL ){ if(parent_tree){ proto_tree_add_text(parent_tree, tvb, offset, -1, "Internal error:can't get application context from ACSE dissector."); } - return ; - } else { - session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) ); - + return 0; } + session = ( (struct SESSION_DATA_STRUCTURE*)data); + + asn1_ctx.private_data = session; + col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE"); - col_clear(pinfo->cinfo, COL_INFO); + col_clear(pinfo->cinfo, COL_INFO); if (rtse_reassemble && ((session->spdu_type == SES_DATA_TRANSFER) || @@ -241,10 +241,10 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) next_tvb = process_reassembled_data (tvb, offset, pinfo, "Reassembled RTSE", frag_msg, &rtse_frag_items, NULL, parent_tree); } - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_rtse, next_tvb ? next_tvb : tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_rtse); - } + + item = proto_tree_add_item(parent_tree, proto_rtse, next_tvb ? next_tvb : tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_rtse); + if (rtse_reassemble && session->spdu_type == SES_DATA_TRANSFER) { /* strip off the OCTET STRING encoding - including any CONSTRUCTED OCTET STRING */ dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, offset, hf_rtse_segment_data, &data_tvb); @@ -298,6 +298,7 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) } top_tree = NULL; + return tvb_length(tvb); } static void rtse_reassemble_init (void) @@ -371,7 +372,7 @@ void proto_register_rtse(void) { /* Register protocol */ proto_rtse = proto_register_protocol(PNAME, PSNAME, PFNAME); - register_dissector("rtse", dissect_rtse, proto_rtse); + new_register_dissector("rtse", dissect_rtse, proto_rtse); /* Register fields and subtrees */ proto_register_field_array(proto_rtse, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff --git a/asn1/rtse/rtse.cnf b/asn1/rtse/rtse.cnf index f37206ebd5..b20927dda9 100644 --- a/asn1/rtse/rtse.cnf +++ b/asn1/rtse/rtse.cnf @@ -6,6 +6,7 @@ RTORJapdu RTABapdu #.FN_BODY RTORJapdu/userDataRJ + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; const char *oid = NULL; switch(app_proto) { @@ -25,32 +26,35 @@ RTABapdu oid = "applicationProtocol.12"; if(oid) { - if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL) + if(session != NULL) session->ros_op = (ROS_OP_BIND | ROS_OP_ERROR); - offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree); + offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, session); } #.FN_BODY RTABapdu/userdataAB /*XXX not implemented yet */ #.FN_BODY RTORQapdu + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL) + if(session != NULL) session->ros_op = (ROS_OP_BIND | ROS_OP_ARGUMENT); open_request=TRUE; %(DEFAULT_BODY)s open_request=FALSE; #.FN_BODY RTOACapdu + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; - if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL) + if(session != NULL) session->ros_op = (ROS_OP_BIND | ROS_OP_RESULT); %(DEFAULT_BODY)s #.FN_BODY ConnectionData/open + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; const char *oid = NULL; switch(app_proto) { @@ -71,13 +75,14 @@ RTABapdu if(oid) { - offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree); + offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, session); } /* else XXX: need to flag we can't find the presentation context */ #.FN_BODY RTTRapdu tvbuff_t *next_tvb = NULL; + struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data; offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &next_tvb); |