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/ros | |
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/ros')
-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 |
3 files changed, 36 insertions, 37 deletions
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 |