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 -D . 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>
43 #include <epan/expert.h>
48 #include "packet-ber.h"
49 #include "packet-pres.h"
50 #include "packet-ros.h"
52 #define PNAME "X.880 OSI Remote Operations Service"
56 /* Initialize the protocol and registered fields */
59 static struct SESSION_DATA_STRUCTURE* session = NULL;
61 static proto_tree *top_tree=NULL;
62 static guint32 opcode;
63 static guint32 invokeid;
65 static dissector_handle_t ros_handle = NULL;
67 typedef struct ros_conv_info_t {
68 struct ros_conv_info_t *next;
69 GHashTable *unmatched; /* unmatched operations */
70 GHashTable *matched; /* matched operations */
73 static ros_conv_info_t *ros_info_items = NULL;
75 typedef struct ros_call_response {
81 } ros_call_response_t;
83 static int hf_ros_response_in = -1;
84 static int hf_ros_response_to = -1;
85 static int hf_ros_time = -1;
89 /*--- Included file: packet-ros-hf.c ---*/
90 #line 1 "packet-ros-hf.c"
91 static int hf_ros_invoke = -1; /* Invoke */
92 static int hf_ros_returnResult = -1; /* ReturnResult */
93 static int hf_ros_returnError = -1; /* ReturnError */
94 static int hf_ros_reject = -1; /* T_reject */
95 static int hf_ros_bind_invoke = -1; /* T_bind_invoke */
96 static int hf_ros_bind_result = -1; /* T_bind_result */
97 static int hf_ros_bind_error = -1; /* T_bind_error */
98 static int hf_ros_unbind_invoke = -1; /* T_unbind_invoke */
99 static int hf_ros_unbind_result = -1; /* T_unbind_result */
100 static int hf_ros_unbind_error = -1; /* T_unbind_error */
101 static int hf_ros_invokeId = -1; /* InvokeId */
102 static int hf_ros_linkedId = -1; /* INTEGER */
103 static int hf_ros_opcode = -1; /* OperationCode */
104 static int hf_ros_argument = -1; /* T_argument */
105 static int hf_ros_result = -1; /* T_result */
106 static int hf_ros_operationResult = -1; /* OperationResult */
107 static int hf_ros_errcode = -1; /* ErrorCode */
108 static int hf_ros_parameter = -1; /* T_parameter */
109 static int hf_ros_problem = -1; /* T_problem */
110 static int hf_ros_general = -1; /* GeneralProblem */
111 static int hf_ros_invokeProblem = -1; /* InvokeProblem */
112 static int hf_ros_rejectResult = -1; /* ReturnResultProblem */
113 static int hf_ros_rejectError = -1; /* ReturnErrorProblem */
114 static int hf_ros_present = -1; /* T_present */
115 static int hf_ros_absent = -1; /* NULL */
116 static int hf_ros_local = -1; /* INTEGER */
117 static int hf_ros_global = -1; /* OBJECT_IDENTIFIER */
119 /*--- End of included file: packet-ros-hf.c ---*/
120 #line 81 "packet-ros-template.c"
122 /* Initialize the subtree pointers */
123 static gint ett_ros = -1;
125 /*--- Included file: packet-ros-ett.c ---*/
126 #line 1 "packet-ros-ett.c"
127 static gint ett_ros_ROS = -1;
128 static gint ett_ros_Invoke = -1;
129 static gint ett_ros_ReturnResult = -1;
130 static gint ett_ros_T_result = -1;
131 static gint ett_ros_ReturnError = -1;
132 static gint ett_ros_Reject = -1;
133 static gint ett_ros_T_problem = -1;
134 static gint ett_ros_InvokeId = -1;
135 static gint ett_ros_Code = -1;
137 /*--- End of included file: packet-ros-ett.c ---*/
138 #line 85 "packet-ros-template.c"
140 static dissector_table_t ros_oid_dissector_table=NULL;
142 static GHashTable *oid_table=NULL;
143 static GHashTable *protocol_table=NULL;
144 static gint ett_ros_unknown = -1;
147 register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name, gboolean uses_rtse)
149 dissector_add_string("ros.oid", oid, dissector);
150 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
153 /* if we are not using RTSE, then we must register ROS with BER (ACSE) */
154 register_ber_oid_dissector_handle(oid, ros_handle, proto, name);
158 register_ros_protocol_info(const char *oid, const ros_info_t *rinfo, int proto _U_, const char *name, gboolean uses_rtse)
160 g_hash_table_insert(protocol_table, (gpointer)oid, (gpointer)rinfo);
161 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
164 /* if we are not using RTSE, then we must register ROS with BER (ACSE) */
165 register_ber_oid_dissector_handle(oid, ros_handle, proto, name);
168 static new_dissector_t ros_lookup_opr_dissector(gint32 opcode, const ros_opr_t *operations, gboolean argument)
170 /* we don't know what order asn2wrs/module definition is, so ... */
172 for(;operations->arg_pdu != (new_dissector_t)(-1); operations++)
173 if(operations->opcode == opcode)
174 return argument ? operations->arg_pdu : operations->res_pdu;
180 static new_dissector_t ros_lookup_err_dissector(gint32 errcode, const ros_err_t *errors)
182 /* we don't know what order asn2wrs/module definition is, so ... */
184 for(;errors->err_pdu != (new_dissector_t) (-1); errors++) {
185 if(errors->errcode == errcode)
186 return errors->err_pdu;
193 static gboolean ros_try_string(const char *oid, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
197 const gchar *opname = NULL;
198 const gchar *suffix = NULL;
200 new_dissector_t opdissector = NULL;
201 const value_string *lookup;
202 proto_item *item=NULL;
203 proto_tree *ros_tree=NULL;
205 if((rinfo = (ros_info_t*)g_hash_table_lookup(protocol_table, oid)) != NULL) {
208 item = proto_tree_add_item(tree, *(rinfo->proto), tvb, 0, -1, FALSE);
209 ros_tree = proto_item_add_subtree(item, *(rinfo->ett_proto));
212 if (check_col(pinfo->cinfo, COL_PROTOCOL))
213 col_set_str(pinfo->cinfo, COL_PROTOCOL, rinfo->name);
215 /* if this is a bind operation */
216 if((session->ros_op & ROS_OP_TYPE_MASK) == ROS_OP_BIND) {
217 /* use the in-built operation codes */
218 if((session->ros_op & ROS_OP_PDU_MASK) == ROS_OP_ERROR)
219 opcode = err_ros_bind;
221 opcode = op_ros_bind;
223 /* otherwise just take the opcode */
224 opcode = session->ros_op & ROS_OP_OPCODE_MASK;
226 /* default lookup in the operations */
227 lookup = rinfo->opr_code_strings;
229 switch(session->ros_op & ROS_OP_PDU_MASK) {
230 case ROS_OP_ARGUMENT:
231 opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, TRUE);
232 suffix = "_argument";
235 opdissector = ros_lookup_opr_dissector(opcode, rinfo->opr_code_dissectors, FALSE);
239 opdissector = ros_lookup_err_dissector(opcode, rinfo->err_code_dissectors);
240 lookup = rinfo->err_code_strings;
248 opname = val_to_str(opcode, lookup, "Unknown opcode (%d)");
250 if (check_col(pinfo->cinfo, COL_INFO)) {
251 col_set_str(pinfo->cinfo, COL_INFO, opname);
253 col_append_str(pinfo->cinfo, COL_INFO, suffix);
256 offset = (*opdissector)(tvb, pinfo, ros_tree);
266 call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
270 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_reported_length_remaining(tvb, offset));
272 if(!ros_try_string(oid, next_tvb, pinfo, tree) &&
273 !dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree)){
274 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);
275 proto_tree *next_tree=proto_item_add_subtree(item, ett_ros_unknown);
277 expert_add_info_format (pinfo, item, PI_UNDECODED, PI_WARN,
278 "ROS: Dissector for OID %s not implemented", oid);
279 dissect_unknown_ber(pinfo, next_tvb, offset, next_tree);
282 /*XXX until we change the #.REGISTER signature for _PDU()s
283 * into new_dissector_t we have to do this kludge with
284 * manually step past the content in the ANY type.
286 offset+=tvb_length_remaining(tvb, offset);
293 ros_info_hash_matched(gconstpointer k)
295 const ros_call_response_t *key = k;
297 return key->invokeId;
301 ros_info_equal_matched(gconstpointer k1, gconstpointer k2)
303 const ros_call_response_t *key1 = k1;
304 const ros_call_response_t *key2 = k2;
306 if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
309 /* a response may span multiple frames
310 if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
315 return key1->invokeId==key2->invokeId;
319 ros_info_hash_unmatched(gconstpointer k)
321 const ros_call_response_t *key = k;
323 return key->invokeId;
327 ros_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
329 const ros_call_response_t *key1 = k1;
330 const ros_call_response_t *key2 = k2;
332 return key1->invokeId==key2->invokeId;
335 static ros_call_response_t *
336 ros_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint invokeId, gboolean isInvoke)
338 ros_call_response_t rcr, *rcrp=NULL;
339 ros_conv_info_t *ros_info = ros_info_items;
341 /* first see if we have already matched this */
343 rcr.invokeId=invokeId;
344 rcr.is_request = isInvoke;
347 rcr.req_frame=pinfo->fd->num;
351 rcr.rep_frame=pinfo->fd->num;
354 rcrp=g_hash_table_lookup(ros_info->matched, &rcr);
357 /* we have found a match */
358 rcrp->is_request=rcr.is_request;
362 /* we haven't found a match - try and match it up */
365 /* this a a request - add it to the unmatched list */
367 /* check that we dont already have one of those in the
368 unmatched list and if so remove it */
370 rcr.invokeId=invokeId;
372 rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
375 g_hash_table_remove(ros_info->unmatched, rcrp);
378 /* if we cant reuse the old one, grab a new chunk */
380 rcrp=se_alloc(sizeof(ros_call_response_t));
382 rcrp->invokeId=invokeId;
383 rcrp->req_frame=pinfo->fd->num;
384 rcrp->req_time=pinfo->fd->abs_ts;
386 rcrp->is_request=TRUE;
387 g_hash_table_insert(ros_info->unmatched, rcrp, rcrp);
392 /* this is a result - it should be in our unmatched list */
394 rcr.invokeId=invokeId;
395 rcrp=g_hash_table_lookup(ros_info->unmatched, &rcr);
399 if(!rcrp->rep_frame){
400 g_hash_table_remove(ros_info->unmatched, rcrp);
401 rcrp->rep_frame=pinfo->fd->num;
402 rcrp->is_request=FALSE;
403 g_hash_table_insert(ros_info->matched, rcrp, rcrp);
409 if(rcrp){ /* we have found a match */
410 proto_item *item = NULL;
412 if(rcrp->is_request){
413 item=proto_tree_add_uint(tree, hf_ros_response_in, tvb, 0, 0, rcrp->rep_frame);
414 PROTO_ITEM_SET_GENERATED (item);
417 item=proto_tree_add_uint(tree, hf_ros_response_to, tvb, 0, 0, rcrp->req_frame);
418 PROTO_ITEM_SET_GENERATED (item);
419 nstime_delta(&ns, &pinfo->fd->abs_ts, &rcrp->req_time);
420 item=proto_tree_add_time(tree, hf_ros_time, tvb, 0, 0, &ns);
421 PROTO_ITEM_SET_GENERATED (item);
429 /*--- Included file: packet-ros-fn.c ---*/
430 #line 1 "packet-ros-fn.c"
434 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_) {
435 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
444 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_) {
445 offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
451 const value_string ros_InvokeId_vals[] = {
457 static const ber_choice_t InvokeId_choice[] = {
458 { 0, &hf_ros_present , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_T_present },
459 { 1, &hf_ros_absent , BER_CLASS_UNI, BER_UNI_TAG_NULL, BER_FLAGS_NOOWNTAG, dissect_ros_NULL },
460 { 0, NULL, 0, 0, 0, NULL }
464 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_) {
465 offset = dissect_ber_choice(actx, tree, tvb, offset,
466 InvokeId_choice, hf_index, ett_ros_InvokeId,
475 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_) {
476 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
485 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_) {
486 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
495 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_) {
498 /* not sure what the length should be - -1 for now */
499 proto_tree_add_text(tree, tvb, offset,-1, "invoke argument");
501 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, TRUE);
503 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
504 /* this should be ROS! */
505 session->ros_op = (ROS_OP_INVOKE | ROS_OP_ARGUMENT);
506 /* now add the opcode */
507 session->ros_op |= opcode;
508 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
517 static const ber_sequence_t Invoke_sequence[] = {
518 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
519 { &hf_ros_linkedId , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ros_INTEGER },
520 { &hf_ros_opcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_OperationCode },
521 { &hf_ros_argument , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_argument },
522 { NULL, 0, 0, 0, NULL }
526 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_) {
527 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
528 Invoke_sequence, hf_index, ett_ros_Invoke);
536 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_) {
539 /* not sure what the length should be - -1 for now */
540 proto_tree_add_text(tree, tvb, offset,-1, "return result");
542 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, FALSE);
544 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
545 /* this should be ROS! */
546 session->ros_op = (ROS_OP_INVOKE | ROS_OP_RESULT);
547 /* now add the opcode */
548 session->ros_op |= opcode;
549 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
558 static const ber_sequence_t T_result_sequence[] = {
559 { &hf_ros_opcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_OperationCode },
560 { &hf_ros_operationResult , BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_ros_OperationResult },
561 { NULL, 0, 0, 0, NULL }
565 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_) {
566 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
567 T_result_sequence, hf_index, ett_ros_T_result);
573 static const ber_sequence_t ReturnResult_sequence[] = {
574 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
575 { &hf_ros_result , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_result },
576 { NULL, 0, 0, 0, NULL }
580 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_) {
581 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
582 ReturnResult_sequence, hf_index, ett_ros_ReturnResult);
590 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_) {
591 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
600 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_) {
603 /* not sure what the length should be - -1 for now */
604 proto_tree_add_text(tree, tvb, offset,-1, "return result");
606 ros_match_call_response(tvb, actx->pinfo, tree, invokeid, FALSE);
608 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
609 /* this should be ROS! */
610 session->ros_op = (ROS_OP_INVOKE | ROS_OP_ERROR);
611 /* now add the opcode (really the error code) */
612 session->ros_op |= opcode;
613 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
623 static const ber_sequence_t ReturnError_sequence[] = {
624 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
625 { &hf_ros_errcode , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_ErrorCode },
626 { &hf_ros_parameter , BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ros_T_parameter },
627 { NULL, 0, 0, 0, NULL }
631 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_) {
632 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
633 ReturnError_sequence, hf_index, ett_ros_ReturnError);
639 static const value_string ros_GeneralProblem_vals[] = {
640 { 0, "unrecognizedPDU" },
641 { 1, "mistypedPDU" },
642 { 2, "badlyStructuredPDU" },
648 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_) {
652 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
656 if (check_col(actx->pinfo->cinfo, COL_INFO)) {
657 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s", val_to_str(problem, ros_GeneralProblem_vals, "GeneralProblem(%d)"));
666 static const value_string ros_InvokeProblem_vals[] = {
667 { 0, "duplicateInvocation" },
668 { 1, "unrecognizedOperation" },
669 { 2, "mistypedArgument" },
670 { 3, "resourceLimitation" },
671 { 4, "releaseInProgress" },
672 { 5, "unrecognizedLinkedId" },
673 { 6, "linkedResponseUnexpected" },
674 { 7, "unexpectedLinkedOperation" },
680 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_) {
684 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
688 if (check_col(actx->pinfo->cinfo, COL_INFO)) {
689 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s", val_to_str(problem, ros_InvokeProblem_vals, "InvokeProblem(%d)"));
698 static const value_string ros_ReturnResultProblem_vals[] = {
699 { 0, "unrecognizedInvocation" },
700 { 1, "resultResponseUnexpected" },
701 { 2, "mistypedResult" },
707 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_) {
711 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
715 if (check_col(actx->pinfo->cinfo, COL_INFO)) {
716 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s", val_to_str(problem, ros_ReturnResultProblem_vals, "ReturnResultProblem(%d)"));
725 static const value_string ros_ReturnErrorProblem_vals[] = {
726 { 0, "unrecognizedInvocation" },
727 { 1, "errorResponseUnexpected" },
728 { 2, "unrecognizedError" },
729 { 3, "unexpectedError" },
730 { 4, "mistypedParameter" },
736 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_) {
740 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
744 if (check_col(actx->pinfo->cinfo, COL_INFO)) {
745 col_append_fstr(actx->pinfo->cinfo, COL_INFO, " %s", val_to_str(problem, ros_ReturnErrorProblem_vals, "ReturnErrorProblem(%d)"));
754 static const value_string ros_T_problem_vals[] = {
757 { 2, "returnResult" },
758 { 3, "returnError" },
762 static const ber_choice_t T_problem_choice[] = {
763 { 0, &hf_ros_general , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ros_GeneralProblem },
764 { 1, &hf_ros_invokeProblem , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ros_InvokeProblem },
765 { 2, &hf_ros_rejectResult , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ros_ReturnResultProblem },
766 { 3, &hf_ros_rejectError , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ros_ReturnErrorProblem },
767 { 0, NULL, 0, 0, 0, NULL }
771 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_) {
772 offset = dissect_ber_choice(actx, tree, tvb, offset,
773 T_problem_choice, hf_index, ett_ros_T_problem,
780 static const ber_sequence_t Reject_sequence[] = {
781 { &hf_ros_invokeId , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_InvokeId },
782 { &hf_ros_problem , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ros_T_problem },
783 { NULL, 0, 0, 0, NULL }
787 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_) {
788 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
789 Reject_sequence, hf_index, ett_ros_Reject);
797 dissect_ros_T_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_) {
799 if(check_col(actx->pinfo->cinfo, COL_INFO))
800 col_set_str(actx->pinfo->cinfo, COL_INFO, "Reject");
801 offset = dissect_ros_Reject(implicit_tag, tvb, offset, actx, tree, hf_index);
812 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_) {
815 /* not sure what the length should be - -1 for now */
816 proto_tree_add_text(tree, tvb, offset,-1, "bind-invoke");
818 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
819 /* this should be ROS! */
820 session->ros_op = (ROS_OP_BIND | ROS_OP_ARGUMENT);
821 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
832 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_) {
835 /* not sure what the length should be - -1 for now */
836 proto_tree_add_text(tree, tvb, offset,-1, "bind-result");
838 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
839 /* this should be ROS! */
840 session->ros_op = (ROS_OP_BIND | ROS_OP_RESULT);
841 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
852 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_) {
855 /* not sure what the length should be - -1 for now */
856 proto_tree_add_text(tree, tvb, offset,-1, "bind-error");
858 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
859 /* this should be ROS! */
860 session->ros_op = (ROS_OP_BIND | ROS_OP_ERROR);
861 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
873 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_) {
876 /* not sure what the length should be - -1 for now */
877 proto_tree_add_text(tree, tvb, offset,-1, "unbind-invoke");
879 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
880 /* this should be ROS! */
881 session->ros_op = (ROS_OP_UNBIND | ROS_OP_ARGUMENT);
882 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
894 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_) {
897 /* not sure what the length should be - -1 for now */
898 proto_tree_add_text(tree, tvb, offset,-1, "unbind-result");
900 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
901 /* this should be ROS! */
902 session->ros_op = (ROS_OP_UNBIND | ROS_OP_RESULT);
903 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
914 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_) {
917 /* not sure what the length should be - -1 for now */
918 proto_tree_add_text(tree, tvb, offset,-1, "unbind-error");
920 if(session && session->pres_ctx_id && (oid = find_oid_by_pres_ctx_id(actx->pinfo, session->pres_ctx_id))) {
921 /* this should be ROS! */
922 session->ros_op = (ROS_OP_UNBIND | ROS_OP_ERROR);
923 offset = call_ros_oid_callback(oid, tvb, offset, actx->pinfo, top_tree);
932 const value_string ros_ROS_vals[] = {
934 { 2, "returnResult" },
935 { 3, "returnError" },
937 { 16, "bind-invoke" },
938 { 17, "bind-result" },
939 { 18, "bind-error" },
940 { 19, "unbind-invoke" },
941 { 20, "unbind-result" },
942 { 21, "unbind-error" },
946 static const ber_choice_t ROS_choice[] = {
947 { 1, &hf_ros_invoke , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ros_Invoke },
948 { 2, &hf_ros_returnResult , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ros_ReturnResult },
949 { 3, &hf_ros_returnError , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ros_ReturnError },
950 { 4, &hf_ros_reject , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_ros_T_reject },
951 { 16, &hf_ros_bind_invoke , BER_CLASS_CON, 16, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_invoke },
952 { 17, &hf_ros_bind_result , BER_CLASS_CON, 17, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_result },
953 { 18, &hf_ros_bind_error , BER_CLASS_CON, 18, BER_FLAGS_IMPLTAG, dissect_ros_T_bind_error },
954 { 19, &hf_ros_unbind_invoke , BER_CLASS_CON, 19, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_invoke },
955 { 20, &hf_ros_unbind_result , BER_CLASS_CON, 20, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_result },
956 { 21, &hf_ros_unbind_error , BER_CLASS_CON, 21, BER_FLAGS_IMPLTAG, dissect_ros_T_unbind_error },
957 { 0, NULL, 0, 0, 0, NULL }
961 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_) {
962 offset = dissect_ber_choice(actx, tree, tvb, offset,
963 ROS_choice, hf_index, ett_ros_ROS,
972 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_) {
973 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
979 const value_string ros_Code_vals[] = {
985 static const ber_choice_t Code_choice[] = {
986 { 0, &hf_ros_local , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ros_INTEGER },
987 { 1, &hf_ros_global , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_ros_OBJECT_IDENTIFIER },
988 { 0, NULL, 0, 0, 0, NULL }
992 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_) {
993 offset = dissect_ber_choice(actx, tree, tvb, offset,
994 Code_choice, hf_index, ett_ros_Code,
1001 /*--- End of included file: packet-ros-fn.c ---*/
1002 #line 375 "packet-ros-template.c"
1005 * Dissect ROS PDUs inside a PPDU.
1008 dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
1012 proto_item *item=NULL;
1013 proto_tree *tree=NULL;
1014 proto_tree *next_tree=NULL;
1015 conversation_t *conversation;
1016 ros_conv_info_t *ros_info = NULL;
1017 asn1_ctx_t asn1_ctx;
1018 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1020 /* save parent_tree so subdissectors can create new top nodes */
1021 top_tree=parent_tree;
1023 /* do we have application context from the acse dissector? */
1024 if( !pinfo->private_data ){
1026 proto_tree_add_text(parent_tree, tvb, offset, -1,
1027 "Internal error:can't get application context from ACSE dissector.");
1031 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
1036 * Do we have a conversation for this connection?
1038 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1039 pinfo->ptype, pinfo->srcport,
1040 pinfo->destport, 0);
1041 if (conversation == NULL) {
1042 /* We don't yet have a conversation, so create one. */
1043 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1044 pinfo->ptype, pinfo->srcport,
1045 pinfo->destport, 0);
1050 * Do we already have our info
1052 ros_info = conversation_get_proto_data(conversation, proto_ros);
1053 if (ros_info == NULL) {
1055 /* No. Attach that information to the conversation. */
1057 ros_info = se_alloc(sizeof(ros_conv_info_t));
1058 ros_info->matched=g_hash_table_new(ros_info_hash_matched, ros_info_equal_matched);
1059 ros_info->unmatched=g_hash_table_new(ros_info_hash_unmatched, ros_info_equal_unmatched);
1061 conversation_add_proto_data(conversation, proto_ros, ros_info);
1063 ros_info->next = ros_info_items;
1064 ros_info_items = ros_info;
1067 /* pinfo->private_data = ros_info; */
1070 item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, FALSE);
1071 tree = proto_item_add_subtree(item, ett_ros);
1073 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ROS");
1074 if (check_col(pinfo->cinfo, COL_INFO))
1075 col_clear(pinfo->cinfo, COL_INFO);
1077 while (tvb_reported_length_remaining(tvb, offset) > 0){
1079 offset=dissect_ros_ROS(FALSE, tvb, offset, &asn1_ctx , tree, -1);
1080 if(offset == old_offset){
1081 item = proto_tree_add_text(tree, tvb, offset, -1,"Unknown ROS PDU");
1084 expert_add_info_format (pinfo, item, PI_UNDECODED, PI_WARN, "Unknown ROS PDU");
1085 next_tree=proto_item_add_subtree(item, ett_ros_unknown);
1086 dissect_unknown_ber(pinfo, tvb, offset, next_tree);
1089 offset = tvb_length(tvb);
1098 ros_conv_info_t *ros_info;
1100 /* Free up state attached to the ros_info structures */
1101 for (ros_info = ros_info_items; ros_info != NULL; ros_info = ros_info->next) {
1102 g_hash_table_destroy(ros_info->matched);
1103 ros_info->matched=NULL;
1104 g_hash_table_destroy(ros_info->unmatched);
1105 ros_info->unmatched=NULL;
1108 ros_info_items = NULL;
1112 /*--- proto_register_ros -------------------------------------------*/
1113 void proto_register_ros(void) {
1115 /* List of fields */
1116 static hf_register_info hf[] =
1118 { &hf_ros_response_in,
1119 { "Response In", "ros.response_in",
1120 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1121 "The response to this remote operation invocation is in this frame", HFILL }},
1122 { &hf_ros_response_to,
1123 { "Response To", "ros.response_to",
1124 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
1125 "This is a response to the remote operation invocation in this frame", HFILL }},
1127 { "Time", "ros.time",
1128 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
1129 "The time between the Invoke and the Response", HFILL }},
1132 /*--- Included file: packet-ros-hfarr.c ---*/
1133 #line 1 "packet-ros-hfarr.c"
1135 { "invoke", "ros.invoke",
1136 FT_NONE, BASE_NONE, NULL, 0,
1137 "ros.Invoke", HFILL }},
1138 { &hf_ros_returnResult,
1139 { "returnResult", "ros.returnResult",
1140 FT_NONE, BASE_NONE, NULL, 0,
1141 "ros.ReturnResult", HFILL }},
1142 { &hf_ros_returnError,
1143 { "returnError", "ros.returnError",
1144 FT_NONE, BASE_NONE, NULL, 0,
1145 "ros.ReturnError", HFILL }},
1147 { "reject", "ros.reject",
1148 FT_NONE, BASE_NONE, NULL, 0,
1149 "ros.T_reject", HFILL }},
1150 { &hf_ros_bind_invoke,
1151 { "bind-invoke", "ros.bind_invoke",
1152 FT_NONE, BASE_NONE, NULL, 0,
1153 "ros.T_bind_invoke", HFILL }},
1154 { &hf_ros_bind_result,
1155 { "bind-result", "ros.bind_result",
1156 FT_NONE, BASE_NONE, NULL, 0,
1157 "ros.T_bind_result", HFILL }},
1158 { &hf_ros_bind_error,
1159 { "bind-error", "ros.bind_error",
1160 FT_NONE, BASE_NONE, NULL, 0,
1161 "ros.T_bind_error", HFILL }},
1162 { &hf_ros_unbind_invoke,
1163 { "unbind-invoke", "ros.unbind_invoke",
1164 FT_NONE, BASE_NONE, NULL, 0,
1165 "ros.T_unbind_invoke", HFILL }},
1166 { &hf_ros_unbind_result,
1167 { "unbind-result", "ros.unbind_result",
1168 FT_NONE, BASE_NONE, NULL, 0,
1169 "ros.T_unbind_result", HFILL }},
1170 { &hf_ros_unbind_error,
1171 { "unbind-error", "ros.unbind_error",
1172 FT_NONE, BASE_NONE, NULL, 0,
1173 "ros.T_unbind_error", HFILL }},
1175 { "invokeId", "ros.invokeId",
1176 FT_UINT32, BASE_DEC, VALS(ros_InvokeId_vals), 0,
1177 "ros.InvokeId", HFILL }},
1179 { "linkedId", "ros.linkedId",
1180 FT_INT32, BASE_DEC, NULL, 0,
1181 "ros.INTEGER", HFILL }},
1183 { "opcode", "ros.opcode",
1184 FT_INT32, BASE_DEC, NULL, 0,
1185 "ros.OperationCode", HFILL }},
1187 { "argument", "ros.argument",
1188 FT_NONE, BASE_NONE, NULL, 0,
1189 "ros.T_argument", HFILL }},
1191 { "result", "ros.result",
1192 FT_NONE, BASE_NONE, NULL, 0,
1193 "ros.T_result", HFILL }},
1194 { &hf_ros_operationResult,
1195 { "result", "ros.result",
1196 FT_NONE, BASE_NONE, NULL, 0,
1197 "ros.OperationResult", HFILL }},
1199 { "errcode", "ros.errcode",
1200 FT_INT32, BASE_DEC, NULL, 0,
1201 "ros.ErrorCode", HFILL }},
1202 { &hf_ros_parameter,
1203 { "parameter", "ros.parameter",
1204 FT_NONE, BASE_NONE, NULL, 0,
1205 "ros.T_parameter", HFILL }},
1207 { "problem", "ros.problem",
1208 FT_UINT32, BASE_DEC, VALS(ros_T_problem_vals), 0,
1209 "ros.T_problem", HFILL }},
1211 { "general", "ros.general",
1212 FT_INT32, BASE_DEC, VALS(ros_GeneralProblem_vals), 0,
1213 "ros.GeneralProblem", HFILL }},
1214 { &hf_ros_invokeProblem,
1215 { "invoke", "ros.invoke",
1216 FT_INT32, BASE_DEC, VALS(ros_InvokeProblem_vals), 0,
1217 "ros.InvokeProblem", HFILL }},
1218 { &hf_ros_rejectResult,
1219 { "returnResult", "ros.returnResult",
1220 FT_INT32, BASE_DEC, VALS(ros_ReturnResultProblem_vals), 0,
1221 "ros.ReturnResultProblem", HFILL }},
1222 { &hf_ros_rejectError,
1223 { "returnError", "ros.returnError",
1224 FT_INT32, BASE_DEC, VALS(ros_ReturnErrorProblem_vals), 0,
1225 "ros.ReturnErrorProblem", HFILL }},
1227 { "present", "ros.present",
1228 FT_INT32, BASE_DEC, NULL, 0,
1229 "ros.T_present", HFILL }},
1231 { "absent", "ros.absent",
1232 FT_NONE, BASE_NONE, NULL, 0,
1233 "ros.NULL", HFILL }},
1235 { "local", "ros.local",
1236 FT_INT32, BASE_DEC, NULL, 0,
1237 "ros.INTEGER", HFILL }},
1239 { "global", "ros.global",
1240 FT_OID, BASE_NONE, NULL, 0,
1241 "ros.OBJECT_IDENTIFIER", HFILL }},
1243 /*--- End of included file: packet-ros-hfarr.c ---*/
1244 #line 505 "packet-ros-template.c"
1247 /* List of subtrees */
1248 static gint *ett[] = {
1252 /*--- Included file: packet-ros-ettarr.c ---*/
1253 #line 1 "packet-ros-ettarr.c"
1256 &ett_ros_ReturnResult,
1258 &ett_ros_ReturnError,
1264 /*--- End of included file: packet-ros-ettarr.c ---*/
1265 #line 512 "packet-ros-template.c"
1268 /* Register protocol */
1269 proto_ros = proto_register_protocol(PNAME, PSNAME, PFNAME);
1270 register_dissector("ros", dissect_ros, proto_ros);
1271 /* Register fields and subtrees */
1272 proto_register_field_array(proto_ros, hf, array_length(hf));
1273 proto_register_subtree_array(ett, array_length(ett));
1275 ros_oid_dissector_table = register_dissector_table("ros.oid", "ROS OID Dissectors", FT_STRING, BASE_NONE);
1276 oid_table=g_hash_table_new(g_str_hash, g_str_equal);
1277 protocol_table=g_hash_table_new(g_str_hash, g_str_equal);
1279 ros_handle = find_dissector("ros");
1281 register_init_routine(ros_reinit);
1285 /*--- proto_reg_handoff_ros --- */
1286 void proto_reg_handoff_ros(void) {