aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/rtse
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/rtse
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/rtse')
-rw-r--r--asn1/rtse/packet-rtse-template.c45
-rw-r--r--asn1/rtse/rtse.cnf15
2 files changed, 33 insertions, 27 deletions
diff --git a/asn1/rtse/packet-rtse-template.c b/asn1/rtse/packet-rtse-template.c
index 10a306ff4a..6ddd05d159 100644
--- a/asn1/rtse/packet-rtse-template.c
+++ b/asn1/rtse/packet-rtse-template.c
@@ -46,8 +46,6 @@
/* Initialize the protocol and registered fields */
static int proto_rtse = -1;
-static struct SESSION_DATA_STRUCTURE* session = NULL;
-
static gboolean open_request=FALSE;
static guint32 app_proto=0;
@@ -142,12 +140,12 @@ register_rtse_oid_dissector_handle(const char *oid, dissector_handle_t dissector
}
static int
-call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
+call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, void* data)
{
tvbuff_t *next_tvb;
next_tvb = tvb_new_subset_remaining(tvb, offset);
- if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, NULL)){
+ if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, data)){
proto_item *item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "RTSE: 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_rtse_unknown);
@@ -170,14 +168,14 @@ call_rtse_external_type_callback(gboolean implicit_tag _U_, tvbuff_t *tvb, int o
{
const char *oid = NULL;
- if (actx->external.indirect_ref_present) {
+ if (actx->external.indirect_ref_present) {
oid = (const char *)find_oid_by_pres_ctx_id(actx->pinfo, actx->external.indirect_reference);
} else if (actx->external.direct_ref_present) {
- oid = actx->external.direct_reference;
+ oid = actx->external.direct_reference;
}
if (oid)
- offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree);
+ offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, actx->private_data);
return offset;
}
@@ -187,13 +185,13 @@ call_rtse_external_type_callback(gboolean implicit_tag _U_, tvbuff_t *tvb, int o
/*
* Dissect RTSE PDUs inside a PPDU.
*/
-static void
-dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
+static int
+dissect_rtse(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;
tvbuff_t *next_tvb = NULL;
tvbuff_t *data_tvb = NULL;
@@ -201,6 +199,7 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
guint32 fragment_length;
guint32 rtse_id = 0;
gboolean data_handled = FALSE;
+ struct SESSION_DATA_STRUCTURE* session;
conversation_t *conversation = NULL;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
@@ -209,19 +208,20 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
top_tree=parent_tree;
/* do we have application context from the acse 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 application context from ACSE dissector.");
}
- return ;
- } else {
- session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
-
+ return 0;
}
+ session = ( (struct SESSION_DATA_STRUCTURE*)data);
+
+ asn1_ctx.private_data = session;
+
col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE");
- col_clear(pinfo->cinfo, COL_INFO);
+ col_clear(pinfo->cinfo, COL_INFO);
if (rtse_reassemble &&
((session->spdu_type == SES_DATA_TRANSFER) ||
@@ -241,10 +241,10 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
next_tvb = process_reassembled_data (tvb, offset, pinfo, "Reassembled RTSE",
frag_msg, &rtse_frag_items, NULL, parent_tree);
}
- if(parent_tree){
- item = proto_tree_add_item(parent_tree, proto_rtse, next_tvb ? next_tvb : tvb, 0, -1, ENC_NA);
- tree = proto_item_add_subtree(item, ett_rtse);
- }
+
+ item = proto_tree_add_item(parent_tree, proto_rtse, next_tvb ? next_tvb : tvb, 0, -1, ENC_NA);
+ tree = proto_item_add_subtree(item, ett_rtse);
+
if (rtse_reassemble && session->spdu_type == SES_DATA_TRANSFER) {
/* strip off the OCTET STRING encoding - including any CONSTRUCTED OCTET STRING */
dissect_ber_octet_string(FALSE, &asn1_ctx, tree, tvb, offset, hf_rtse_segment_data, &data_tvb);
@@ -298,6 +298,7 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
top_tree = NULL;
+ return tvb_length(tvb);
}
static void rtse_reassemble_init (void)
@@ -371,7 +372,7 @@ void proto_register_rtse(void) {
/* Register protocol */
proto_rtse = proto_register_protocol(PNAME, PSNAME, PFNAME);
- register_dissector("rtse", dissect_rtse, proto_rtse);
+ new_register_dissector("rtse", dissect_rtse, proto_rtse);
/* Register fields and subtrees */
proto_register_field_array(proto_rtse, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
diff --git a/asn1/rtse/rtse.cnf b/asn1/rtse/rtse.cnf
index f37206ebd5..b20927dda9 100644
--- a/asn1/rtse/rtse.cnf
+++ b/asn1/rtse/rtse.cnf
@@ -6,6 +6,7 @@ RTORJapdu
RTABapdu
#.FN_BODY RTORJapdu/userDataRJ
+ struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
const char *oid = NULL;
switch(app_proto) {
@@ -25,32 +26,35 @@ RTABapdu
oid = "applicationProtocol.12";
if(oid) {
- if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL)
+ if(session != NULL)
session->ros_op = (ROS_OP_BIND | ROS_OP_ERROR);
- offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree);
+ offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, session);
}
#.FN_BODY RTABapdu/userdataAB
/*XXX not implemented yet */
#.FN_BODY RTORQapdu
+ struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
- if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL)
+ if(session != NULL)
session->ros_op = (ROS_OP_BIND | ROS_OP_ARGUMENT);
open_request=TRUE;
%(DEFAULT_BODY)s
open_request=FALSE;
#.FN_BODY RTOACapdu
+ struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
- if((session = (struct SESSION_DATA_STRUCTURE*)(actx->pinfo->private_data)) != NULL)
+ if(session != NULL)
session->ros_op = (ROS_OP_BIND | ROS_OP_RESULT);
%(DEFAULT_BODY)s
#.FN_BODY ConnectionData/open
+ struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
const char *oid = NULL;
switch(app_proto) {
@@ -71,13 +75,14 @@ RTABapdu
if(oid) {
- offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree);
+ offset = call_rtse_oid_callback(oid, tvb, offset, actx->pinfo, top_tree ? top_tree : tree, session);
}
/* else XXX: need to flag we can't find the presentation context */
#.FN_BODY RTTRapdu
tvbuff_t *next_tvb = NULL;
+ struct SESSION_DATA_STRUCTURE* session = (struct SESSION_DATA_STRUCTURE*)actx->private_data;
offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &next_tvb);