summaryrefslogtreecommitdiff
path: root/asn1/idmp
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/idmp
parent389423aaaac460f5b0fcbaf37b4f3d5cd7941c5b (diff)
downloadwireshark-b6b78d69dbae80ea0a0efc39400e3e88d5f9e337.tar.gz
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/idmp')
-rw-r--r--asn1/idmp/idmp.cnf16
-rw-r--r--asn1/idmp/packet-idmp-template.c27
2 files changed, 20 insertions, 23 deletions
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;
}
}