aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/dsp
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/dsp
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/dsp')
-rw-r--r--asn1/dsp/packet-dsp-template.c34
1 files changed, 18 insertions, 16 deletions
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));