aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/acse
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-11-05 18:47:26 +0000
committerMichael Mann <mmann78@netscape.net>2013-11-05 18:47:26 +0000
commitb6b78d69dbae80ea0a0efc39400e3e88d5f9e337 (patch)
tree3b236e73ee8f1d83c07ecc5ab7a67af8bb19cc85 /asn1/acse
parent389423aaaac460f5b0fcbaf37b4f3d5cd7941c5b (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/acse')
-rw-r--r--asn1/acse/acse.cnf8
-rw-r--r--asn1/acse/packet-acse-template.c67
2 files changed, 38 insertions, 37 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");
}