2 * Routines for RTSE 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-acse.h"
40 #include "packet-ros.h"
41 #include "packet-rtse.h"
43 #define PNAME "X.228 OSI Reliable Transfer Service"
47 /* Initialize the protocol and registered fields */
50 static struct SESSION_DATA_STRUCTURE* session = NULL;
52 static char object_identifier_id[MAX_OID_STR_LEN];
53 static gboolean open_request=FALSE;
54 /* indirect_reference, used to pick up the signalling so we know what
55 kind of data is transferred in SES_DATA_TRANSFER_PDUs */
56 static guint32 indir_ref=0;
57 static guint32 app_proto=0;
59 static proto_tree *top_tree=NULL;
61 static dissector_handle_t rtse_handle = NULL;
62 static dissector_handle_t ros_handle = NULL;
64 #include "packet-rtse-hf.c"
66 /* Initialize the subtree pointers */
67 static gint ett_rtse = -1;
68 #include "packet-rtse-ett.c"
71 static dissector_table_t rtse_oid_dissector_table=NULL;
72 static GHashTable *oid_table=NULL;
73 static gint ett_rtse_unknown = -1;
76 register_rtse_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name, gboolean uses_ros)
79 /* save the name - but not used */
80 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
82 /* register RTSE with the BER (ACSE) */
83 register_ber_oid_dissector_handle(oid, rtse_handle, proto, name);
86 /* make sure we call ROS ... */
87 dissector_add_string("rtse.oid", oid, ros_handle);
89 /* and then tell ROS how to dissect the AS*/
90 register_ros_oid_dissector_handle(oid, dissector, proto, name, TRUE);
93 /* otherwise we just remember how to dissect the AS */
94 dissector_add_string("rtse.oid", oid, dissector);
99 call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
103 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_reported_length_remaining(tvb, offset));
104 if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree)){
105 proto_item *item=NULL;
106 proto_tree *next_tree=NULL;
108 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);
110 next_tree=proto_item_add_subtree(item, ett_rtse_unknown);
112 dissect_unknown_ber(pinfo, next_tvb, offset, next_tree);
115 /*XXX until we change the #.REGISTER signature for _PDU()s
116 * into new_dissector_t we have to do this kludge with
117 * manually step past the content in the ANY type.
119 offset+=tvb_length_remaining(tvb, offset);
124 #include "packet-rtse-fn.c"
127 * Dissect RTSE PDUs inside a PPDU.
130 dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
134 proto_item *item=NULL;
135 proto_tree *tree=NULL;
137 /* save parent_tree so subdissectors can create new top nodes */
138 top_tree=parent_tree;
140 /* do we have application context from the acse dissector? */
141 if( !pinfo->private_data ){
143 proto_tree_add_text(parent_tree, tvb, offset, -1,
144 "Internal error:can't get application context from ACSE dissector.");
148 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
153 item = proto_tree_add_item(parent_tree, proto_rtse, tvb, 0, -1, FALSE);
154 tree = proto_item_add_subtree(item, ett_rtse);
156 if (check_col(pinfo->cinfo, COL_PROTOCOL))
157 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE");
158 if (check_col(pinfo->cinfo, COL_INFO))
159 col_clear(pinfo->cinfo, COL_INFO);
161 while (tvb_reported_length_remaining(tvb, offset) > 0){
163 offset=dissect_rtse_RTSE_apdus(FALSE, tvb, offset, pinfo , tree, -1);
164 if(offset == old_offset){
165 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte RTSE PDU");
166 offset = tvb_length(tvb);
175 /*--- proto_register_rtse -------------------------------------------*/
176 void proto_register_rtse(void) {
179 static hf_register_info hf[] =
181 #include "packet-rtse-hfarr.c"
184 /* List of subtrees */
185 static gint *ett[] = {
188 #include "packet-rtse-ettarr.c"
191 /* Register protocol */
192 proto_rtse = proto_register_protocol(PNAME, PSNAME, PFNAME);
193 register_dissector("rtse", dissect_rtse, proto_rtse);
194 /* Register fields and subtrees */
195 proto_register_field_array(proto_rtse, hf, array_length(hf));
196 proto_register_subtree_array(ett, array_length(ett));
198 rtse_oid_dissector_table = register_dissector_table("rtse.oid", "RTSE OID Dissectors", FT_STRING, BASE_NONE);
199 oid_table=g_hash_table_new(g_str_hash, g_str_equal);
201 rtse_handle = find_dissector("rtse");
202 ros_handle = find_dissector("ros");
207 /*--- proto_reg_handoff_rtse --- */
208 void proto_reg_handoff_rtse(void) {