1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -e -p ros -c ros.cnf -s packet-ros-template ros.asn Remote-Operations-Information-Objects.asn */
6 /* Input file: packet-ros-template.c */
8 #line 1 "packet-ros-template.c"
10 * Routines for ROS packet dissection
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 #include <epan/packet.h>
40 #include <epan/conversation.h>
41 #include <epan/emem.h>
42 #include <epan/asn1.h>
47 #include "packet-ber.h"
48 #include "packet-pres.h"
49 #include "packet-ros.h"
51 #define PNAME "X.880 OSI Remote Operations Service"
55 /* Initialize the protocol and registered fields */
58 static struct SESSION_DATA_STRUCTURE* session = NULL;
60 static proto_tree *top_tree=NULL;
61 static guint32 opcode;
62 static guint32 invokeid;
64 static dissector_handle_t ros_handle = NULL;
66 typedef struct ros_conv_info_t {
67 struct ros_conv_info_t *next;
68 GHashTable *unmatched; /* unmatched operations */
69 GHashTable *matched; /* matched operations */
72 static ros_conv_info_t *ros_info_items = NULL;
74 typedef struct ros_call_response {
80 } ros_call_response_t;
82 static int hf_ros_response_in = -1;
83 static int hf_ros_response_to = -1;
84 static int hf_ros_time = -1;
88 /*--- Included file: packet-ros-hf.c ---*/
89 #line 1 "packet-ros-hf.c"
90 static int hf_ros_invoke = -1; /* Invoke */
91 static int hf_ros_returnResult = -1; /* ReturnResult */
92 static int hf_ros_returnError = -1; /* ReturnError */
93 static int hf_ros_reject = -1; /* Reject */
94 static int hf_ros_bind_invoke = -1; /* T_bind_invoke */
95 static int hf_ros_bind_result = -1; /* T_bind_result */
96 static int hf_ros_bind_error = -1; /* T_bind_error */
97 static int hf_ros_unbind_invoke = -1; /* T_unbind_invoke */
98 static int hf_ros_unbind_result = -1; /* T_unbind_result */
99 static int hf_ros_unbind_error = -1; /* T_unbind_error */
100 static int hf_ros_invokeId = -1; /* InvokeId */
101 static int hf_ros_linkedId = -1; /* INTEGER */
102 static int hf_ros_opcode = -1; /* OperationCode */
103 static int hf_ros_argument = -1; /* T_argument */
104 static int hf_ros_result = -1; /* T_result */
105 static int hf_ros_operationResult = -1; /* OperationResult */
106 static int hf_ros_errcode = -1; /* ErrorCode */
107 static int hf_ros_parameter = -1; /* T_parameter */
108 static int hf_ros_problem = -1; /* T_problem */
109 static int hf_ros_general = -1; /* GeneralProblem */
110 static int hf_ros_invokeProblem = -1; /* InvokeProblem */
111 static int hf_ros_rejectResult = -1; /* ReturnResultProblem */
112 static int hf_ros_rejectError = -1; /* ReturnErrorProblem */
113 static int hf_ros_present = -1; /* T_present */
114 static int hf_ros_absent = -1; /* NULL */
115 static int hf_ros_local = -1; /* INTEGER */
116 static int hf_ros_global = -1; /* OBJECT_IDENTIFIER */
118 /*--- End of included file: packet-ros-hf.c ---*/
119 #line 80 "packet-ros-template.c"
121 /* Initialize the subtree pointers */
122 static gint ett_ros = -1;
124 /*--- Included file: packet-ros-ett.c ---*/
125 #line 1 "packet-ros-ett.c"
126 static gint ett_ros_ROS = -1;
127 static gint ett_ros_Invoke = -1;
128 static gint ett_ros_ReturnResult = -1;
129 static gint ett_ros_T_result = -1;
130 static gint ett_ros_ReturnError = -1;
131 static gint ett_ros_Reject = -1;
132 static gint ett_ros_T_problem = -1;
133 static gint ett_ros_InvokeId = -1;
134 static gint ett_ros_Code = -1;
136 /*--- End of included file: packet-ros-ett.c ---*/
137 #line 84 "packet-ros-template.c"
139 static dissector_table_t ros_oid_dissector_table=NULL;
141 static GHashTable *oid_table=NULL;
142 static GHashTable *protocol_table=NULL;
143 static gint ett_ros_unknown = -1;
146 register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name, gboolean uses_rtse)
148 dissector_add_string("ros.oid", oid, dissector);
149 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
152 /* if we are not using RTSE, then we must register ROS with BER (ACSE) */
153 register_ber_oid_dissector_handle(oid, ros_handle, proto, name);
157 register_ros_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name, gboolean uses_rtse)
159 g_hash_table_insert(protocol_table, (gpointer)oid, (gpointer)rinfo);
160 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
163 /* if we are not using RTSE, then we must register ROS with BER (ACSE) */
164 register_ber_oid_dissector_handle(oid, ros_handle, proto, name);
167 static new_dissector_t ros_lookup_opr_dissector(gint32 opcode, const ros_opr_t *operations, gboolean argument)
169 /* we don't know what order asn2wrs/module definition is, so ... */
171 for(;operations->arg_pdu != (new_dissector_t)(-1); operations++)
172 if(operations->opcode == opcode)
173 return argument ? operations->arg_pdu : operations->res_pdu;
179 static new_dissector_t ros_lookup_err_dissector(gint32 errcode, const ros_err_t *errors)
181 /* we don't know what order asn2wrs/module definition is, so ... */
183 for(;errors->err_pdu != (new_dissector_t) (-1); errors++) {
184 if(errors->errcode == errcode)
185 return errors->err_pdu;
192 static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
196 const gchar *opname = NULL;
197 const gchar *suffix = NULL;
199 new_dissector_t opdissector = NULL;
200 const value_string *lookup;
201 proto_item *item=NULL;
202 proto_tree *ros_tree=NULL;
204 if((rinfo = (ros_info_t*)g_hash_table_lookup(protocol_table, oid)) != NULL) {
207 item = proto_tree_add_item(tree, *(rinfo->proto), tvb, 0, -1, FALSE);
208 ros_tree = proto_item_add_subtree(item, *(rinfo->ett_proto));
211 if (check_col(pinfo->cinfo, COL_PROTOCOL))
212 col_set_str(pinfo->cinfo, COL_PROTOCOL, rinfo->name);
214 /* if this is a bind operation */
215 if((session->ros_op & ROS_OP_TYPE_MASK) == ROS_OP_BIND) {
216 /* use the in-built operation codes */
217 if((session->ros_op & ROS_OP_PDU_MASK) == ROS_OP_ERROR)
218 opcode = err_ros_bind;
220 opcode = op_ros_bind;
222 /* otherwise just take the opcode */
223 opcode = session->ros_op & ROS_OP_OPCODE_MASK;
225 /* default lookup in the operations */
226 lookup = rinfo->opr_code_strings;
228 switch(session->ros_op & ROS_OP_PDU_MASK) {
229 case ROS_OP_ARGUMENT:
230 opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, TRUE);
231 suffix = "_argument";
234 opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, FALSE);
238 opdissector = ros_lookup_err_dissector(opcode, rinfo->err_code_dissectors);
239 lookup = rinfo->err_code_strings;
247 opname = val_to_str(opcode, lookup, "Unknown opcode (%d)");
249 if (check_col(pinfo->cinfo, COL_INFO)) {
250 col_set_str(pinfo->cinfo, COL_INFO, opname);
252 col_append_fstr(pinfo->cinfo, COL_INFO, suffix);
255 offset = (*opdissector)(tvb, pinfo, ros_tree);
265 call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
269 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_reported_length_remaining(tvb, offset));
271 if(!ros_try_string(oid, next_tvb, pinfo, tree) &&
272 !dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree)){
273 proto_item *item=NULL;
274 proto_tree *next_tree=NULL;
276 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);
278 next_tree=proto_item_add_subtree(item, ett_ros_unknown);
280 dissect_unknown_ber(pinfo, next_tvb, offset, next_tree);
283 /*XXX until we change the #.REGISTER signature for _PDU()s
284 * into new_dissector_t we have to do this kludge with
285 * manually step past the content in the ANY type.
287 offset+=tvb_length_remaining(tvb, offset);
294 ros_info_hash_matched(gconstpointer k)
296 const ros_call_response_t *key = k;
298 return key->invokeId;
302 ros_info_equal_matched(gconstpointer k1, gconstpointer k2)
304 const ros_call_response_t *key1 = k1;
305 const ros_call_response_t *key2 = k2;
307 if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
310 /* a response may span multiple frames
311 if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
316 return key1->invokeId==key2->invokeId;
320 ros_info_hash_unmatched(gconstpointer k)
322 const ros_call_response_t *key = k;
324 return key->invokeId;
328 ros_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
330 const ros_call_response_t *key1 = k1;
331 const ros_call_response_t *key2 = k2;
333 return key1->invokeId==key2->invokeId;
336 static ros_call_response_t *
337 ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint invokeId, gboolean isInvoke)
339 ros_call_response_t rcr, *rcrp=NULL;
340 ros_conv_info_t *ros_info = ros_info_items;
342 /* first see if we have already matched this */
344 rcr.invokeId=invokeId;
345 rcr.is_request = isInvoke;
348 rcr.req_frame=pinfo->fd->num;
352 rcr.rep_frame=pinfo->fd->num;
355 rcrp=g_hash_table_lookup(ros_info->matched, &rcr);
358 /* we have found a match */
359 rcrp->is_request=rcr.is_request;
363 /* we haven't found a match - try and match it up */
366 /* this a a request - add it to the unmatched list */
368 /* check that we dont already have one of those in the
369 unmatched list and if so remove it */
371 rcr.invokeId=invokeId;
373 rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
376 g_hash_table_remove(ros_info->unmatched, rcrp);
379 /* if we cant reuse the old one, grab a new chunk */
381 rcrp=se_alloc(sizeof(ros_call_response_t));
383 rcrp->invokeId=invokeId;
384 rcrp->req_frame=pinfo->fd->num;
385 rcrp->req_time=pinfo->fd->abs_ts;
387 rcrp->is_request=TRUE;
388 g_hash_table_insert(ros_info->unmatched, rcrp, rcrp);
393 /* this is a result - it should be in our unmatched list */
395 rcr.invokeId=invokeId;
396 rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
400 if(!rcrp->rep_frame){
401 g_hash_table_remove(ros_info->unmatched, rcrp);
402 rcrp->rep_frame=pinfo->fd->num;
403 rcrp->is_request=FALSE;
404 g_hash_table_insert(ros_info->matched, rcrp, rcrp);
410 if(rcrp){ /* we have found a match */
411 proto_item *item = NULL;
413 if(rcrp->is_request){
414 item=proto_tree_add_uint(tree, hf_ros_response_in, tvb, 0, 0, rcrp->rep_frame);
415 PROTO_ITEM_SET_GENERATED (item);
418 item=proto_tree_add_uint(tree, hf_ros_response_to, tvb, 0, 0, rcrp->req_frame);
419 PROTO_ITEM_SET_GENERATED (item);
420 nstime_delta(&ns, &pinfo->fd->abs_ts, &rcrp->req_time);
421 item=proto_tree_add_time(tree, hf_ros_time, tvb, 0, 0, &ns);
422 PROTO_ITEM_SET_GENERATED (item);
430 /*--- Included file: packet-ros-fn.c ---*/
431 #line 1 "packet-ros-fn.c"
435 dissect_ros_T_present(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
436 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
445 dissect_ros_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
446 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
452 const value_string ros_InvokeId_vals[] = {
458 static const ber_choice_t InvokeId_choice[] = {
459 { 0, &hf_ros_present , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_T_present },
460 { 1, &hf_ros_absent , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_ros_NULL },
461 { 0, NULL, 0, 0, 0, NULL }
465 dissect_ros_InvokeId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
466 offset = dissect_ber_choice(actx, tree, tvb, offset,
467 InvokeId_choice, hf_index, ett_ros_InvokeId,
476 dissect_ros_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
477 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
486 dissect_ros_OperationCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
487 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
496 dissect_ros_T_argument(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
499 /* not sure what the length should be - -1 for now */
500 proto_tree_add_text(tree, tvb, offset,-1, "invoke argument");
502 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, TRUE);
504 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
505 /* this should be ROS! */
506 session->ros_op = (ROS_OP_INVOKE | ROS_OP_ARGUMENT);
507 /* now add the opcode */
508 session->ros_op |= opcode;
509 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
518 static const ber_sequence_t Invoke_sequence[] = {
519 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
520 { &hf_ros_linkedId , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ros_INTEGER },
521 { &hf_ros_opcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_OperationCode },
522 { &hf_ros_argument , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_argument },
523 { NULL, 0, 0, 0, NULL }
527 dissect_ros_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
528 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
529 Invoke_sequence, hf_index, ett_ros_Invoke);
537 dissect_ros_OperationResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
540 /* not sure what the length should be - -1 for now */
541 proto_tree_add_text(tree, tvb, offset,-1, "return result");
543 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, FALSE);
545 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
546 /* this should be ROS! */
547 session->ros_op = (ROS_OP_INVOKE | ROS_OP_RESULT);
548 /* now add the opcode */
549 session->ros_op |= opcode;
550 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
559 static const ber_sequence_t T_result_sequence[] = {
560 { &hf_ros_opcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_OperationCode },
561 { &hf_ros_operationResult , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_ros_OperationResult },
562 { NULL, 0, 0, 0, NULL }
566 dissect_ros_T_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
567 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
568 T_result_sequence, hf_index, ett_ros_T_result);
574 static const ber_sequence_t ReturnResult_sequence[] = {
575 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
576 { &hf_ros_result , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_result },
577 { NULL, 0, 0, 0, NULL }
581 dissect_ros_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
582 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
583 ReturnResult_sequence, hf_index, ett_ros_ReturnResult);
591 dissect_ros_ErrorCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
592 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
601 dissect_ros_T_parameter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
604 /* not sure what the length should be - -1 for now */
605 proto_tree_add_text(tree, tvb, offset,-1, "return result");
607 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, FALSE);
609 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
610 /* this should be ROS! */
611 session->ros_op = (ROS_OP_INVOKE | ROS_OP_ERROR);
612 /* now add the opcode (really the error code) */
613 session->ros_op |= opcode;
614 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
624 static const ber_sequence_t ReturnError_sequence[] = {
625 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
626 { &hf_ros_errcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_ErrorCode },
627 { &hf_ros_parameter , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_parameter },
628 { NULL, 0, 0, 0, NULL }
632 dissect_ros_ReturnError(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
633 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
634 ReturnError_sequence, hf_index, ett_ros_ReturnError);
640 static const value_string ros_GeneralProblem_vals[] = {
641 { 0, "unrecognizedPDU" },
642 { 1, "mistypedPDU" },
643 { 2, "badlyStructuredPDU" },
649 dissect_ros_GeneralProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
650 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
657 static const value_string ros_InvokeProblem_vals[] = {
658 { 0, "duplicateInvocation" },
659 { 1, "unrecognizedOperation" },
660 { 2, "mistypedArgument" },
661 { 3, "resourceLimitation" },
662 { 4, "releaseInProgress" },
663 { 5, "unrecognizedLinkedId" },
664 { 6, "linkedResponseUnexpected" },
665 { 7, "unexpectedLinkedOperation" },
671 dissect_ros_InvokeProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
672 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
679 static const value_string ros_ReturnResultProblem_vals[] = {
680 { 0, "unrecognizedInvocation" },
681 { 1, "resultResponseUnexpected" },
682 { 2, "mistypedResult" },
688 dissect_ros_ReturnResultProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
689 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
696 static const value_string ros_ReturnErrorProblem_vals[] = {
697 { 0, "unrecognizedInvocation" },
698 { 1, "errorResponseUnexpected" },
699 { 2, "unrecognizedError" },
700 { 3, "unexpectedError" },
701 { 4, "mistypedParameter" },
707 dissect_ros_ReturnErrorProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
708 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
715 static const value_string ros_T_problem_vals[] = {
718 { 2, "returnResult" },
719 { 3, "returnError" },
723 static const ber_choice_t T_problem_choice[] = {
724 { 0, &hf_ros_general , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ros_GeneralProblem },
725 { 1, &hf_ros_invokeProblem , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ros_InvokeProblem },
726 { 2, &hf_ros_rejectResult , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ros_ReturnResultProblem },
727 { 3, &hf_ros_rejectError , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ros_ReturnErrorProblem },
728 { 0, NULL, 0, 0, 0, NULL }
732 dissect_ros_T_problem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
733 offset = dissect_ber_choice(actx, tree, tvb, offset,
734 T_problem_choice, hf_index, ett_ros_T_problem,
741 static const ber_sequence_t Reject_sequence[] = {
742 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
743 { &hf_ros_problem , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_T_problem },
744 { NULL, 0, 0, 0, NULL }
748 dissect_ros_Reject(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
749 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
750 Reject_sequence, hf_index, ett_ros_Reject);
758 dissect_ros_T_bind_invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
761 /* not sure what the length should be - -1 for now */
762 proto_tree_add_text(tree, tvb, offset,-1, "bind-invoke");
764 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
765 /* this should be ROS! */
766 session->ros_op = (ROS_OP_BIND | ROS_OP_ARGUMENT);
767 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
778 dissect_ros_T_bind_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
781 /* not sure what the length should be - -1 for now */
782 proto_tree_add_text(tree, tvb, offset,-1, "bind-result");
784 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
785 /* this should be ROS! */
786 session->ros_op = (ROS_OP_BIND | ROS_OP_RESULT);
787 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
798 dissect_ros_T_bind_error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
801 /* not sure what the length should be - -1 for now */
802 proto_tree_add_text(tree, tvb, offset,-1, "bind-error");
804 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
805 /* this should be ROS! */
806 session->ros_op = (ROS_OP_BIND | ROS_OP_ERROR);
807 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
819 dissect_ros_T_unbind_invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
822 /* not sure what the length should be - -1 for now */
823 proto_tree_add_text(tree, tvb, offset,-1, "unbind-invoke");
825 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
826 /* this should be ROS! */
827 session->ros_op = (ROS_OP_UNBIND | ROS_OP_ARGUMENT);
828 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
840 dissect_ros_T_unbind_result(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
843 /* not sure what the length should be - -1 for now */
844 proto_tree_add_text(tree, tvb, offset,-1, "unbind-result");
846 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
847 /* this should be ROS! */
848 session->ros_op = (ROS_OP_UNBIND | ROS_OP_RESULT);
849 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
860 dissect_ros_T_unbind_error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
863 /* not sure what the length should be - -1 for now */
864 proto_tree_add_text(tree, tvb, offset,-1, "unbind-error");
866 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
867 /* this should be ROS! */
868 session->ros_op = (ROS_OP_UNBIND | ROS_OP_ERROR);
869 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
877 static const value_string ros_ROS_vals[] = {
879 { 2, "returnResult" },
880 { 3, "returnError" },
882 { 16, "bind-invoke" },
883 { 17, "bind-result" },
884 { 18, "bind-error" },
885 { 19, "unbind-invoke" },
886 { 20, "unbind-result" },
887 { 21, "unbind-error" },
891 static const ber_choice_t ROS_choice[] = {
892 { 1, &hf_ros_invoke , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ros_Invoke },
893 { 2, &hf_ros_returnResult , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ros_ReturnResult },
894 { 3, &hf_ros_returnError , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ros_ReturnError },
895 { 4, &hf_ros_reject , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_ros_Reject },
896 { 16, &hf_ros_bind_invoke , BER_CLASS_CON, 16, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_invoke },
897 { 17, &hf_ros_bind_result , BER_CLASS_CON, 17, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_result },
898 { 18, &hf_ros_bind_error , BER_CLASS_CON, 18, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_error },
899 { 19, &hf_ros_unbind_invoke , BER_CLASS_CON, 19, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_invoke },
900 { 20, &hf_ros_unbind_result , BER_CLASS_CON, 20, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_result },
901 { 21, &hf_ros_unbind_error , BER_CLASS_CON, 21, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_error },
902 { 0, NULL, 0, 0, 0, NULL }
906 dissect_ros_ROS(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
907 offset = dissect_ber_choice(actx, tree, tvb, offset,
908 ROS_choice, hf_index, ett_ros_ROS,
917 dissect_ros_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
918 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
924 const value_string ros_Code_vals[] = {
930 static const ber_choice_t Code_choice[] = {
931 { 0, &hf_ros_local , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_INTEGER },
932 { 1, &hf_ros_global , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_ros_OBJECT_IDENTIFIER },
933 { 0, NULL, 0, 0, 0, NULL }
937 dissect_ros_Code(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
938 offset = dissect_ber_choice(actx, tree, tvb, offset,
939 Code_choice, hf_index, ett_ros_Code,
948 dissect_ros_Priority(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
949 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
956 /*--- End of included file: packet-ros-fn.c ---*/
957 #line 376 "packet-ros-template.c"
960 * Dissect ROS PDUs inside a PPDU.
963 dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
967 proto_item *item=NULL;
968 proto_tree *tree=NULL;
969 conversation_t *conversation;
970 ros_conv_info_t *ros_info = NULL;
972 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
974 /* save parent_tree so subdissectors can create new top nodes */
975 top_tree=parent_tree;
977 /* do we have application context from the acse dissector? */
978 if( !pinfo->private_data ){
980 proto_tree_add_text(parent_tree, tvb, offset, -1,
981 "Internal error:can't get application context from ACSE dissector.");
985 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
990 * Do we have a conversation for this connection?
992 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
993 pinfo->ptype, pinfo->srcport,
995 if (conversation == NULL) {
996 /* We don't yet have a conversation, so create one. */
997 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
998 pinfo->ptype, pinfo->srcport,
1004 * Do we already have our info
1006 ros_info = conversation_get_proto_data(conversation, proto_ros);
1007 if (ros_info == NULL) {
1009 /* No. Attach that information to the conversation. */
1011 ros_info = se_alloc(sizeof(ros_conv_info_t));
1012 ros_info->matched=g_hash_table_new(ros_info_hash_matched, ros_info_equal_matched);
1013 ros_info->unmatched=g_hash_table_new(ros_info_hash_unmatched, ros_info_equal_unmatched);
1015 conversation_add_proto_data(conversation, proto_ros, ros_info);
1017 ros_info->next = ros_info_items;
1018 ros_info_items = ros_info;
1021 /* pinfo->private_data = ros_info; */
1024 item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, FALSE);
1025 tree = proto_item_add_subtree(item, ett_ros);
1027 if (check_col(pinfo->cinfo, COL_PROTOCOL))
1028 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ROS");
1029 if (check_col(pinfo->cinfo, COL_INFO))
1030 col_clear(pinfo->cinfo, COL_INFO);
1032 while (tvb_reported_length_remaining(tvb, offset) > 0){
1034 offset=dissect_ros_ROS(FALSE, tvb, offset, &asn1_ctx , tree, -1);
1035 if(offset == old_offset){
1036 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte ROS PDU");
1037 offset = tvb_length(tvb);
1046 ros_conv_info_t *ros_info;
1048 /* Free up state attached to the ros_info structures */
1049 for (ros_info = ros_info_items; ros_info != NULL; ros_info = ros_info->next) {
1050 g_hash_table_destroy(ros_info->matched);
1051 ros_info->matched=NULL;
1052 g_hash_table_destroy(ros_info->unmatched);
1053 ros_info->unmatched=NULL;
1056 ros_info_items = NULL;
1060 /*--- proto_register_ros -------------------------------------------*/
1061 void proto_register_ros(void) {
1063 /* List of fields */
1064 static hf_register_info hf[] =
1066 { &hf_ros_response_in,
1067 { "Response In", "ros.response_in",
1068 FT_FRAMENUM, BASE_DEC, NULL, 0x0,
1069 "The response to this remote operation invocation is in this frame", HFILL }},
1070 { &hf_ros_response_to,
1071 { "Response To", "ros.response_to",
1072 FT_FRAMENUM, BASE_DEC, NULL, 0x0,
1073 "This is a response to the remote operation invocation in this frame", HFILL }},
1075 { "Time", "ros.time",
1076 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
1077 "The time between the Invoke and the Response", HFILL }},
1080 /*--- Included file: packet-ros-hfarr.c ---*/
1081 #line 1 "packet-ros-hfarr.c"
1083 { "invoke", "ros.invoke",
1084 FT_NONE, BASE_NONE, NULL, 0,
1085 "ros.Invoke", HFILL }},
1086 { &hf_ros_returnResult,
1087 { "returnResult", "ros.returnResult",
1088 FT_NONE, BASE_NONE, NULL, 0,
1089 "ros.ReturnResult", HFILL }},
1090 { &hf_ros_returnError,
1091 { "returnError", "ros.returnError",
1092 FT_NONE, BASE_NONE, NULL, 0,
1093 "ros.ReturnError", HFILL }},
1095 { "reject", "ros.reject",
1096 FT_NONE, BASE_NONE, NULL, 0,
1097 "ros.Reject", HFILL }},
1098 { &hf_ros_bind_invoke,
1099 { "bind-invoke", "ros.bind_invoke",
1100 FT_NONE, BASE_NONE, NULL, 0,
1101 "ros.T_bind_invoke", HFILL }},
1102 { &hf_ros_bind_result,
1103 { "bind-result", "ros.bind_result",
1104 FT_NONE, BASE_NONE, NULL, 0,
1105 "ros.T_bind_result", HFILL }},
1106 { &hf_ros_bind_error,
1107 { "bind-error", "ros.bind_error",
1108 FT_NONE, BASE_NONE, NULL, 0,
1109 "ros.T_bind_error", HFILL }},
1110 { &hf_ros_unbind_invoke,
1111 { "unbind-invoke", "ros.unbind_invoke",
1112 FT_NONE, BASE_NONE, NULL, 0,
1113 "ros.T_unbind_invoke", HFILL }},
1114 { &hf_ros_unbind_result,
1115 { "unbind-result", "ros.unbind_result",
1116 FT_NONE, BASE_NONE, NULL, 0,
1117 "ros.T_unbind_result", HFILL }},
1118 { &hf_ros_unbind_error,
1119 { "unbind-error", "ros.unbind_error",
1120 FT_NONE, BASE_NONE, NULL, 0,
1121 "ros.T_unbind_error", HFILL }},
1123 { "invokeId", "ros.invokeId",
1124 FT_UINT32, BASE_DEC, VALS(ros_InvokeId_vals), 0,
1125 "ros.InvokeId", HFILL }},
1127 { "linkedId", "ros.linkedId",
1128 FT_INT32, BASE_DEC, NULL, 0,
1129 "ros.INTEGER", HFILL }},
1131 { "opcode", "ros.opcode",
1132 FT_INT32, BASE_DEC, NULL, 0,
1133 "ros.OperationCode", HFILL }},
1135 { "argument", "ros.argument",
1136 FT_NONE, BASE_NONE, NULL, 0,
1137 "ros.T_argument", HFILL }},
1139 { "result", "ros.result",
1140 FT_NONE, BASE_NONE, NULL, 0,
1141 "ros.T_result", HFILL }},
1142 { &hf_ros_operationResult,
1143 { "result", "ros.result",
1144 FT_NONE, BASE_NONE, NULL, 0,
1145 "ros.OperationResult", HFILL }},
1147 { "errcode", "ros.errcode",
1148 FT_INT32, BASE_DEC, NULL, 0,
1149 "ros.ErrorCode", HFILL }},
1150 { &hf_ros_parameter,
1151 { "parameter", "ros.parameter",
1152 FT_NONE, BASE_NONE, NULL, 0,
1153 "ros.T_parameter", HFILL }},
1155 { "problem", "ros.problem",
1156 FT_UINT32, BASE_DEC, VALS(ros_T_problem_vals), 0,
1157 "ros.T_problem", HFILL }},
1159 { "general", "ros.general",
1160 FT_INT32, BASE_DEC, VALS(ros_GeneralProblem_vals), 0,
1161 "ros.GeneralProblem", HFILL }},
1162 { &hf_ros_invokeProblem,
1163 { "invoke", "ros.invoke",
1164 FT_INT32, BASE_DEC, VALS(ros_InvokeProblem_vals), 0,
1165 "ros.InvokeProblem", HFILL }},
1166 { &hf_ros_rejectResult,
1167 { "returnResult", "ros.returnResult",
1168 FT_INT32, BASE_DEC, VALS(ros_ReturnResultProblem_vals), 0,
1169 "ros.ReturnResultProblem", HFILL }},
1170 { &hf_ros_rejectError,
1171 { "returnError", "ros.returnError",
1172 FT_INT32, BASE_DEC, VALS(ros_ReturnErrorProblem_vals), 0,
1173 "ros.ReturnErrorProblem", HFILL }},
1175 { "present", "ros.present",
1176 FT_INT32, BASE_DEC, NULL, 0,
1177 "ros.T_present", HFILL }},
1179 { "absent", "ros.absent",
1180 FT_NONE, BASE_NONE, NULL, 0,
1181 "ros.NULL", HFILL }},
1183 { "local", "ros.local",
1184 FT_INT32, BASE_DEC, NULL, 0,
1185 "ros.INTEGER", HFILL }},
1187 { "global", "ros.global",
1188 FT_OID, BASE_NONE, NULL, 0,
1189 "ros.OBJECT_IDENTIFIER", HFILL }},
1191 /*--- End of included file: packet-ros-hfarr.c ---*/
1192 #line 498 "packet-ros-template.c"
1195 /* List of subtrees */
1196 static gint *ett[] = {
1200 /*--- Included file: packet-ros-ettarr.c ---*/
1201 #line 1 "packet-ros-ettarr.c"
1204 &ett_ros_ReturnResult,
1206 &ett_ros_ReturnError,
1212 /*--- End of included file: packet-ros-ettarr.c ---*/
1213 #line 505 "packet-ros-template.c"
1216 /* Register protocol */
1217 proto_ros = proto_register_protocol(PNAME, PSNAME, PFNAME);
1218 register_dissector("ros", dissect_ros, proto_ros);
1219 /* Register fields and subtrees */
1220 proto_register_field_array(proto_ros, hf, array_length(hf));
1221 proto_register_subtree_array(ett, array_length(ett));
1223 ros_oid_dissector_table = register_dissector_table("ros.oid", "ROS OID Dissectors", FT_STRING, BASE_NONE);
1224 oid_table=g_hash_table_new(g_str_hash, g_str_equal);
1225 protocol_table=g_hash_table_new(g_str_hash, g_str_equal);
1227 ros_handle = find_dissector("ros");
1229 register_init_routine(ros_reinit);
1233 /*--- proto_reg_handoff_ros --- */
1234 void proto_reg_handoff_ros(void) {