aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/p1
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/p1
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/p1')
-rw-r--r--asn1/p1/p1.cnf8
-rw-r--r--asn1/p1/packet-p1-template.c28
2 files changed, 19 insertions, 17 deletions
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");