aboutsummaryrefslogtreecommitdiffstats
path: root/asn1
diff options
context:
space:
mode:
authorGraeme Lunt <graeme.lunt@smhs.co.uk>2006-05-01 10:17:59 +0000
committerGraeme Lunt <graeme.lunt@smhs.co.uk>2006-05-01 10:17:59 +0000
commitf48115ba5c9d7375ce4cc70728e350c33e55d1cf (patch)
treed0f40354347f3c37caec40c546340a56ddeba218 /asn1
parent2ebbe973de68706c043d18056f3da74326bf0531 (diff)
Operation request/result correlation and timing.
svn path=/trunk/; revision=18058
Diffstat (limited to 'asn1')
-rw-r--r--asn1/ros/packet-ros-template.c223
-rw-r--r--asn1/ros/ros.asn26
-rw-r--r--asn1/ros/ros.cnf22
3 files changed, 244 insertions, 27 deletions
diff --git a/asn1/ros/packet-ros-template.c b/asn1/ros/packet-ros-template.c
index b0c97dcb2f..8fc592e33e 100644
--- a/asn1/ros/packet-ros-template.c
+++ b/asn1/ros/packet-ros-template.c
@@ -30,6 +30,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/conversation.h>
+#include <epan/emem.h>
#include <stdio.h>
#include <string.h>
@@ -49,9 +50,31 @@ static struct SESSION_DATA_STRUCTURE* session = NULL;
static proto_tree *top_tree=NULL;
static guint32 opcode;
+static guint32 invokeid;
static dissector_handle_t ros_handle = NULL;
+typedef struct ros_conv_info_t {
+ struct ros_conv_info_t *next;
+ GHashTable *unmatched; /* unmatched operations */
+ GHashTable *matched; /* matched operations */
+} ros_conv_info_t;
+
+static ros_conv_info_t *ros_info_items = NULL;
+
+typedef struct ros_call_response {
+ gboolean is_request;
+ guint32 req_frame;
+ nstime_t req_time;
+ guint32 rep_frame;
+ guint invokeId;
+} ros_call_response_t;
+
+static int hf_ros_response_in = -1;
+static int hf_ros_response_to = -1;
+static int hf_ros_time = -1;
+
+
#include "packet-ros-hf.c"
/* Initialize the subtree pointers */
@@ -99,8 +122,140 @@ call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *p
return offset;
}
-#include "packet-ros-fn.c"
+static guint
+ros_info_hash_matched(gconstpointer k)
+{
+ const ros_call_response_t *key = k;
+
+ return key->invokeId;
+}
+
+static gint
+ros_info_equal_matched(gconstpointer k1, gconstpointer k2)
+{
+ const ros_call_response_t *key1 = k1;
+ const ros_call_response_t *key2 = k2;
+
+ if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
+ return 0;
+ }
+ /* a response may span multiple frames
+ if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
+ return 0;
+ }
+ */
+
+ return key1->invokeId==key2->invokeId;
+}
+
+static guint
+ros_info_hash_unmatched(gconstpointer k)
+{
+ const ros_call_response_t *key = k;
+
+ return key->invokeId;
+}
+
+static gint
+ros_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
+{
+ const ros_call_response_t *key1 = k1;
+ const ros_call_response_t *key2 = k2;
+
+ return key1->invokeId==key2->invokeId;
+}
+
+static ros_call_response_t *
+ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint invokeId, gboolean isInvoke)
+{
+ ros_call_response_t rcr, *rcrp=NULL;
+ ros_conv_info_t *ros_info = ros_info_items;
+
+ /* first see if we have already matched this */
+
+ rcr.invokeId=invokeId;
+ rcr.is_request = isInvoke;
+
+ if(isInvoke) {
+ rcr.req_frame=pinfo->fd->num;
+ rcr.rep_frame=0;
+ } else {
+ rcr.req_frame=0;
+ rcr.rep_frame=pinfo->fd->num;
+ }
+
+ rcrp=g_hash_table_lookup(ros_info->matched, &rcr);
+
+ if(rcrp) {
+ /* we have found a match */
+ rcrp->is_request=rcr.is_request;
+
+ } else {
+
+ /* we haven't found a match - try and match it up */
+
+ if(isInvoke) {
+ /* this a a request - add it to the unmatched list */
+
+ /* check that we dont already have one of those in the
+ unmatched list and if so remove it */
+
+ rcr.invokeId=invokeId;
+
+ rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
+
+ if(rcrp){
+ g_hash_table_remove(ros_info->unmatched, rcrp);
+ }
+
+ /* if we cant reuse the old one, grab a new chunk */
+ if(!rcrp){
+ rcrp=se_alloc(sizeof(ros_call_response_t));
+ }
+ rcrp->invokeId=invokeId;
+ rcrp->req_frame=pinfo->fd->num;
+ rcrp->req_time=pinfo->fd->abs_ts;
+ rcrp->rep_frame=0;
+ rcrp->is_request=TRUE;
+ g_hash_table_insert(ros_info->unmatched, rcrp, rcrp);
+ return NULL;
+
+ } else {
+
+ /* this is a result - it should be in our unmatched list */
+
+ rcr.invokeId=invokeId;
+ rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
+
+ if(rcrp){
+
+ if(!rcrp->rep_frame){
+ g_hash_table_remove(ros_info->unmatched, rcrp);
+ rcrp->rep_frame=pinfo->fd->num;
+ rcrp->is_request=FALSE;
+ g_hash_table_insert(ros_info->matched, rcrp, rcrp);
+ }
+ }
+ }
+ }
+
+ if(rcrp){ /* we have found a match */
+
+ if(rcrp->is_request){
+ proto_tree_add_uint(tree, hf_ros_response_in, tvb, 0, 0, rcrp->rep_frame);
+ } else {
+ nstime_t ns;
+ proto_tree_add_uint(tree, hf_ros_response_to, tvb, 0, 0, rcrp->req_frame);
+ nstime_delta(&ns, &pinfo->fd->abs_ts, &rcrp->req_time);
+ proto_tree_add_time(tree, hf_ros_time, tvb, 0, 0, &ns);
+ }
+ }
+
+ return rcrp;
+}
+
+#include "packet-ros-fn.c"
/*
* Dissect ROS PDUs inside a PPDU.
@@ -112,6 +267,8 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
int old_offset;
proto_item *item=NULL;
proto_tree *tree=NULL;
+ conversation_t *conversation;
+ ros_conv_info_t *ros_info = NULL;
/* save parent_tree so subdissectors can create new top nodes */
top_tree=parent_tree;
@@ -128,6 +285,40 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
+ /*
+ * Do we have a conversation for this connection?
+ */
+ conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport,
+ pinfo->destport, 0);
+ if (conversation == NULL) {
+ /* We don't yet have a conversation, so create one. */
+ conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport,
+ pinfo->destport, 0);
+
+ }
+
+ /*
+ * Do we already have our info
+ */
+ ros_info = conversation_get_proto_data(conversation, proto_ros);
+ if (ros_info == NULL) {
+
+ /* No. Attach that information to the conversation. */
+
+ ros_info = se_alloc(sizeof(ros_conv_info_t));
+ ros_info->matched=g_hash_table_new(ros_info_hash_matched, ros_info_equal_matched);
+ ros_info->unmatched=g_hash_table_new(ros_info_hash_unmatched, ros_info_equal_unmatched);
+
+ conversation_add_proto_data(conversation, proto_ros, ros_info);
+
+ 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, FALSE);
tree = proto_item_add_subtree(item, ett_ros);
@@ -148,6 +339,22 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
}
+static void
+ros_reinit(void)
+{
+ ros_conv_info_t *ros_info;
+
+ /* Free up state attached to the ros_info structures */
+ for (ros_info = ros_info_items; ros_info != NULL; ros_info = ros_info->next) {
+ g_hash_table_destroy(ros_info->matched);
+ ros_info->matched=NULL;
+ g_hash_table_destroy(ros_info->unmatched);
+ ros_info->unmatched=NULL;
+ }
+
+ ros_info_items = NULL;
+
+}
/*--- proto_register_ros -------------------------------------------*/
void proto_register_ros(void) {
@@ -155,6 +362,19 @@ void proto_register_ros(void) {
/* List of fields */
static hf_register_info hf[] =
{
+ { &hf_ros_response_in,
+ { "Response In", "ros.response_in",
+ FT_FRAMENUM, BASE_DEC, NULL, 0x0,
+ "The response to this remote operation invocation is in this frame", HFILL }},
+ { &hf_ros_response_to,
+ { "Response To", "ros.response_to",
+ FT_FRAMENUM, BASE_DEC, NULL, 0x0,
+ "This is a response to the remote operation invocation in this frame", HFILL }},
+ { &hf_ros_time,
+ { "Time", "ros.time",
+ FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
+ "The time between the Invoke and the Response", HFILL }},
+
#include "packet-ros-hfarr.c"
};
@@ -177,6 +397,7 @@ void proto_register_ros(void) {
ros_handle = find_dissector("ros");
+ register_init_routine(ros_reinit);
}
diff --git a/asn1/ros/ros.asn b/asn1/ros/ros.asn
index 5b7f20f789..84db801cc3 100644
--- a/asn1/ros/ros.asn
+++ b/asn1/ros/ros.asn
@@ -141,18 +141,18 @@ ReturnErrorProblem ::= INTEGER {
unrecognizedInvocation(0), errorResponseUnexpected(1), unrecognizedError(2),
unexpectedError(3), mistypedParameter(4)}
-RejectProblem ::= INTEGER {
- general-unrecognizedPDU(0), general-mistypedPDU(1),
- general-badlyStructuredPDU(2), invoke-duplicateInvocation(10),
- invoke-unrecognizedOperation(11), invoke-mistypedArgument(12),
- invoke-resourceLimitation(13), invoke-releaseInProgress(14),
- invoke-unrecognizedLinkedId(15), invoke-linkedResponseUnexpected(16),
- invoke-unexpectedLinkedOperation(17),
- returnResult-unrecognizedInvocation(20),
- returnResult-resultResponseUnexpected(21), returnResult-mistypedResult(22),
- returnError-unrecognizedInvocation(30),
- returnError-errorResponseUnexpected(31), returnError-unrecognizedError(32),
- returnError-unexpectedError(33), returnError-mistypedParameter(34)}
+--RejectProblem ::= INTEGER {
+-- general-unrecognizedPDU(0), general-mistypedPDU(1),
+-- general-badlyStructuredPDU(2), invoke-duplicateInvocation(10),
+-- invoke-unrecognizedOperation(11), invoke-mistypedArgument(12),
+-- invoke-resourceLimitation(13), invoke-releaseInProgress(14),
+-- invoke-unrecognizedLinkedId(15), invoke-linkedResponseUnexpected(16),
+-- invoke-unexpectedLinkedOperation(17),
+-- returnResult-unrecognizedInvocation(20),
+-- returnResult-resultResponseUnexpected(21), returnResult-mistypedResult(22),
+-- returnError-unrecognizedInvocation(30),
+-- returnError-errorResponseUnexpected(31), returnError-unrecognizedError(32),
+-- returnError-unexpectedError(33), returnError-mistypedParameter(34)}
InvokeId ::= CHOICE {present INTEGER,
absent NULL
@@ -183,7 +183,7 @@ Code ::= CHOICE {
global OBJECT IDENTIFIER
}
-Priority ::= INTEGER
+--Priority ::= INTEGER
END -- end of generic ROS PDU definitions
diff --git a/asn1/ros/ros.cnf b/asn1/ros/ros.cnf
index 511f97c9d2..9c3f33b7c1 100644
--- a/asn1/ros/ros.cnf
+++ b/asn1/ros/ros.cnf
@@ -11,26 +11,18 @@ ReturnResult/result/result operationResult
Reject/problem/returnError rejectError
Reject/problem/returnResult rejectResult
-#.FN_BODY OperationCode
+#.FN_PARS OperationCode VAL_PTR = &opcode
- offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_index,
- &opcode);
-
-#.FN_BODY ErrorCode
-
- offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_index,
- &opcode);
-
-#.FN_BODY errcode
-
- offset = dissect_ber_integer(FALSE, pinfo, tree, tvb, offset, hf_index,
- &opcode);
+#.FN_PARS ErrorCode VAL_PTR = &opcode
+#.FN_PARS INTEGER VAL_PTR = &invokeid
#.FN_BODY T_argument
char *oid;
/* not sure what the length should be - -1 for now */
proto_tree_add_text(tree, tvb, offset,-1, "invoke argument");
+
+ ros_match_call_response(tvb, pinfo, tree, invokeid, TRUE);
if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(pinfo, session->pres_ctx_id))) {
/* this should be ROS! */
@@ -44,6 +36,8 @@ Reject/problem/returnResult rejectResult
char *oid;
/* not sure what the length should be - -1 for now */
proto_tree_add_text(tree, tvb, offset,-1, "return result");
+
+ ros_match_call_response(tvb, pinfo, tree, invokeid, FALSE);
if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(pinfo, session->pres_ctx_id))) {
/* this should be ROS! */
@@ -57,6 +51,8 @@ Reject/problem/returnResult rejectResult
char *oid;
/* not sure what the length should be - -1 for now */
proto_tree_add_text(tree, tvb, offset,-1, "return result");
+
+ ros_match_call_response(tvb, pinfo, tree, invokeid, FALSE);
if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(pinfo, session->pres_ctx_id))) {
/* this should be ROS! */