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 /* indirect_reference, used to pick up the signalling so we know what
54 kind of data is transferred in SES_DATA_TRANSFER_PDUs */
55 static guint32 indir_ref=0;
56 static guint32 app_proto=0;
58 static proto_tree *top_tree=NULL;
60 static int dissect_rtse_EXTERNAL(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_);
63 #include "packet-rtse-hf.c"
65 /* Initialize the subtree pointers */
66 static gint ett_rtse = -1;
67 #include "packet-rtse-ett.c"
70 static dissector_table_t rtse_oid_dissector_table=NULL;
71 static GHashTable *oid_table=NULL;
72 static gint ett_rtse_unknown = -1;
75 register_rtse_oid_dissector_handle(const char *oid, dissector_handle_t dissector, int proto _U_, const char *name)
77 dissector_add_string("rtse.oid", oid, dissector);
78 g_hash_table_insert(oid_table, (gpointer)oid, (gpointer)name);
82 call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
86 next_tvb = tvb_new_subset(tvb, offset, tvb_length_remaining(tvb, offset), tvb_reported_length_remaining(tvb, offset));
87 if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree)){
88 proto_item *item=NULL;
89 proto_tree *next_tree=NULL;
91 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);
93 next_tree=proto_item_add_subtree(item, ett_rtse_unknown);
95 dissect_unknown_ber(pinfo, next_tvb, offset, next_tree);
98 /*XXX until we change the #.REGISTER signature for _PDU()s
99 * into new_dissector_t we have to do this kludge with
100 * manually step past the content in the ANY type.
102 offset+=tvb_length_remaining(tvb, offset);
107 #include "packet-rtse-fn.c"
110 * Dissect RTSE PDUs inside a PPDU.
113 dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
117 proto_item *item=NULL;
118 proto_tree *tree=NULL;
120 /* save parent_tree so subdissectors can create new top nodes */
121 top_tree=parent_tree;
123 /* do we have application context from the acse dissector? */
124 if( !pinfo->private_data ){
126 proto_tree_add_text(parent_tree, tvb, offset, -1,
127 "Internal error:can't get application context from ACSE dissector.");
131 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
136 item = proto_tree_add_item(parent_tree, proto_rtse, tvb, 0, -1, FALSE);
137 tree = proto_item_add_subtree(item, ett_rtse);
139 if (check_col(pinfo->cinfo, COL_PROTOCOL))
140 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTSE");
141 if (check_col(pinfo->cinfo, COL_INFO))
142 col_clear(pinfo->cinfo, COL_INFO);
144 while (tvb_reported_length_remaining(tvb, offset) > 0){
146 offset=dissect_rtse_RTSE_apdus(FALSE, tvb, offset, pinfo , tree, -1);
147 if(offset == old_offset){
148 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte RTSE PDU");
149 offset = tvb_length(tvb);
158 /*--- proto_register_rtse -------------------------------------------*/
159 void proto_register_rtse(void) {
162 static hf_register_info hf[] =
164 #include "packet-rtse-hfarr.c"
167 /* List of subtrees */
168 static gint *ett[] = {
171 #include "packet-rtse-ettarr.c"
174 /* Register protocol */
175 proto_rtse = proto_register_protocol(PNAME, PSNAME, PFNAME);
176 register_dissector("rtse", dissect_rtse, proto_rtse);
177 /* Register fields and subtrees */
178 proto_register_field_array(proto_rtse, hf, array_length(hf));
179 proto_register_subtree_array(ett, array_length(ett));
181 rtse_oid_dissector_table = register_dissector_table("rtse.oid", "RTSE OID Dissectors", FT_STRING, BASE_NONE);
182 oid_table=g_hash_table_new(g_str_hash, g_str_equal);
187 /*--- proto_reg_handoff_rtse --- */
188 void proto_reg_handoff_rtse(void) {