2 * Routines for ROS packet dissection
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/conversation.h>
37 #include "packet-ber.h"
38 #include "packet-pres.h"
39 #include "packet-ros.h"
41 #define PNAME "X.880 OSI Remote Operations Service"
45 /* Initialize the protocol and registered fields */
48 static struct SESSION_DATA_STRUCTURE* session = NULL;
50 static proto_tree *top_tree=NULL;
51 static guint32 opcode;
53 #include "packet-ros-hf.c"
55 /* Initialize the subtree pointers */
56 static gint ett_ros = -1;
57 #include "packet-ros-ett.c"
59 static dissector_table_t ros_oid_dissector_table=NULL;
60 static GHashTable *oid_table=NULL;
61 static gint ett_ros_unknown = -1;
64 register_ros_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name)
66 dissector_add_string("ros.oid", oid, dissector);
67 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
71 call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
75 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_reported_length_remaining(tvb, offset));
76 if(!dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree)){
77 proto_item *item=NULL;
78 proto_tree *next_tree=NULL;
80 item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "RTSE: Dissector for OID:%s not implemented. Contact Ethereal developers if you want this supported", oid);
82 next_tree=proto_item_add_subtree(item, ett_ros_unknown);
84 dissect_unknown_ber(pinfo, next_tvb, offset, next_tree);
87 /*XXX until we change the #.REGISTER signature for _PDU()s
88 * into new_dissector_t we have to do this kludge with
89 * manually step past the content in the ANY type.
91 offset+=tvb_length_remaining(tvb, offset);
96 #include "packet-ros-fn.c"
100 * Dissect ROS PDUs inside a PPDU.
103 dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
107 proto_item *item=NULL;
108 proto_tree *tree=NULL;
110 /* save parent_tree so subdissectors can create new top nodes */
111 top_tree=parent_tree;
113 /* do we have application context from the acse dissector? */
114 if( !pinfo->private_data ){
116 proto_tree_add_text(parent_tree, tvb, offset, -1,
117 "Internal error:can't get application context from ACSE dissector.");
121 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
126 item = proto_tree_add_item(parent_tree, proto_ros, tvb, 0, -1, FALSE);
127 tree = proto_item_add_subtree(item, ett_ros);
129 if (check_col(pinfo->cinfo, COL_PROTOCOL))
130 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ROS");
131 if (check_col(pinfo->cinfo, COL_INFO))
132 col_clear(pinfo->cinfo, COL_INFO);
134 while (tvb_reported_length_remaining(tvb, offset) > 0){
136 offset=dissect_ros_ROS(FALSE, tvb, offset, pinfo , tree, -1);
137 if(offset == old_offset){
138 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte ROS PDU");
139 offset = tvb_length(tvb);
146 /*--- proto_register_ros -------------------------------------------*/
147 void proto_register_ros(void) {
150 static hf_register_info hf[] =
152 #include "packet-ros-hfarr.c"
155 /* List of subtrees */
156 static gint *ett[] = {
159 #include "packet-ros-ettarr.c"
162 /* Register protocol */
163 proto_ros = proto_register_protocol(PNAME, PSNAME, PFNAME);
164 register_dissector("ros", dissect_ros, proto_ros);
165 /* Register fields and subtrees */
166 proto_register_field_array(proto_ros, hf, array_length(hf));
167 proto_register_subtree_array(ett, array_length(ett));
169 ros_oid_dissector_table = register_dissector_table("ros.oid", "ROS OID Dissectors", FT_STRING, BASE_NONE);
170 oid_table=g_hash_table_new(g_str_hash, g_str_equal);
174 /*--- proto_reg_handoff_ros --- */
175 void proto_reg_handoff_ros(void) {