2 * Declaration of routines for GIOP/IIOP (CDR) dissection
3 * Copyright 2000, Frank Singleton <frank.singleton@ericsson.com>
5 * Based on CORBAv2.4.2 Chapter 15 GIOP Description.
7 * $Id: packet-giop.h,v 1.6 2001/08/03 20:51:49 guy Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 * Useful visible data/structs
35 #define GIOP_HEADER_SIZE 12
37 typedef struct Version {
44 * Useful data collected from message header. Note, this
45 * struct encapsulates useful data from GIOP header, as well
46 * as request_id and reply_status for use by sub dissectors.
49 typedef struct MessageHeader {
55 guint8 flags; /* byte_order in 1.0 */
58 guint32 req_id; /* request id in MSG */
60 /* MSG dependant data */
62 guint32 rep_status; /* reply status in MSG if available */
63 gchar *exception_id; /* exception string if a USER EXCEPTION occurs */
67 typedef enum MsgType {
75 Fragment /* GIOP 1.1 only */
86 typedef enum ReplyStatusType {
91 LOCATION_FORWARD_PERM, /* new for GIOP 1.2 */
92 NEEDS_ADDRESSING_MODE /* new for GIOP 1.2 */
96 * Prototype for sub dissector function calls.
99 typedef gboolean (giop_sub_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, int *,
100 MessageHeader *, gchar * , gchar *);
103 * Generic Subdissector handle, wraps user info.
106 typedef struct giop_sub_handle {
107 giop_sub_dissector_t *sub_fn; /* ptr to sub dissector function */
108 gchar *sub_name; /* subdissector string name */
109 int sub_proto; /* proto_XXX value from proto_register_protocol() */
112 /* Main GIOP entry point */
114 gboolean dissect_giop(tvbuff_t *, packet_info *, proto_tree *); /* new interface */
117 * GIOP Users register interest via this function.
118 * This is for heuristic dissection
121 void register_giop_user(giop_sub_dissector_t *sub, gchar *name, int sub_proto);
124 * GIOP Users remove interest via this function.
125 * This is for heuristic dissection
128 void delete_giop_user(giop_sub_dissector_t *sub, gchar *name);
132 * GIOP Users register their module and interface names via this function.
133 * This is for explicit dissection.
136 void register_giop_user_module(giop_sub_dissector_t *sub, gchar *name, gchar *module, int sub_proto);
139 * GIOP Users remove their module and interface names via this function.
140 * This is for explicit dissection.
143 void delete_giop_user_module(giop_sub_dissector_t *sub, gchar *name, gchar *module);
147 * General CDR accessors start here. They are listed in alphabetical
148 * order. They may however, belong to 1 of 3 distinct CDR data types.
151 * - OMG IDL Constructed Types
152 * - Pseudo Object Types
155 * Altough some of these look redundant, I have separated them
156 * out for all CDR types, to assist in auto generation of
157 * IDL dissectors later, see idl2eth -- FS
163 * Gets data of type any. This is encoded as a TypeCode
164 * followed by the encoded value.
166 * Data is added to tree directly if present.
169 void get_CDR_any(tvbuff_t *tvb, proto_tree *tree, gint *offset, gboolean stream_is_big_endian,
170 int boundary, MessageHeader * header );
173 /* Copy a 1 octet sequence from the tvbuff
174 * which represents a boolean value, and convert
175 * it to a boolean value.
176 * Offset is then incremented by 1, to indicate the 1 octet which
177 * has been processed.
180 gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset);
183 /* Copy a 1 octet sequence from the tvbuff
184 * which represents a char, and convert
185 * it to an char value.
186 * offset is then incremented by 1, to indicate the 1 octet which
187 * has been processed.
190 guint8 get_CDR_char(tvbuff_t *tvb, int *offset);
195 * Floating Point Data Type double IEEE 754-1985
197 * Copy an 8 octet sequence from the tvbuff
198 * which represents a double value, and convert
199 * it to a double value, taking into account byte order.
200 * offset is first incremented so that it falls on a proper alignment
201 * boundary for double values.
202 * offset is then incremented by 8, to indicate the 8 octets which
203 * have been processed.
206 gdouble get_CDR_double(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
209 /* Copy a 4 octet sequence from the tvbuff
210 * which represents an enum value, and convert
211 * it to an enum value, taking into account byte order.
212 * offset is first incremented so that it falls on a proper alignment
213 * boundary for an enum (4)
214 * offset is then incremented by 4, to indicate the 4 octets which
215 * have been processed.
217 * Enum values are encoded as unsigned long.
220 guint32 get_CDR_enum(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
225 * Copy an octet sequence from the tvbuff
226 * which represents a Fixed point decimal type, and create a string representing
227 * a Fixed point decimal type. There are no alignment restrictions.
228 * Size and scale of fixed decimal type is determined by IDL.
230 * digits - IDL specified number of "digits" for this fixed type
231 * scale - IDL specified "scale" for this fixed type
234 * eg: typedef fixed <5,2> fixed_t;
235 * could represent numbers like 123.45, 789.12,
238 * As the fixed type could be any size, I will not try to fit it into our
239 * simple types like gdouble or glong etc. I will just create a string buffer holding
240 * a representation (after scale is applied), and with a decimal point or zero padding
241 * inserted at the right place if necessary. The string is null terminated
243 * so string may look like
246 * "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
248 * According to spec, digits <= 31
249 * and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
252 * User must remember to free the buffer
256 void get_CDR_fixed(tvbuff_t *tvb, gchar **seq, gint *offset, guint32 digits, gint32 scale);
261 * Floating Point Data Type float IEEE 754-1985
263 * Copy a 4 octet sequence from the tvbuff
264 * which represents a float value, and convert
265 * it to a float value, taking into account byte order.
266 * offset is first incremented so that it falls on a proper alignment
267 * boundary for float values.
268 * offset is then incremented by 4, to indicate the 4 octets which
269 * have been processed.
272 gfloat get_CDR_float(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
276 * Decode an Interface type, and display it on the tree.
279 void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
280 gboolean stream_is_big_endian, int boundary);
283 /* Copy a 4 octet sequence from the tvbuff
284 * which represents a signed long value, and convert
285 * it to an signed long vaule, taking into account byte order.
286 * offset is first incremented so that it falls on a proper alignment
287 * boundary for long values.
288 * offset is then incremented by 4, to indicate the 4 octets which
289 * have been processed.
292 gint32 get_CDR_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
296 /* Copy a 16 octet sequence from the tvbuff
297 * which represents a long double value, and convert
298 * it to a long double value, taking into account byte order.
299 * offset is first incremented so that it falls on a proper alignment
300 * boundary for long double values.
301 * offset is then incremented by 16, to indicate the 16 octets which
302 * have been processed.
305 #ifdef G_HAVE_GLONG_DOUBLE
307 glong_double get_CDR_long_double(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian,
311 /* FIX -- Cast long double to gdouble until I figure this out -- FS*/
313 gdouble get_CDR_long_double(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian,
319 /* Copy an 8 octet sequence from the tvbuff
320 * which represents a signed long long value, and convert
321 * it to a signed long long value, taking into account byte order.
322 * offset is first incremented so that it falls on a proper alignment
323 * boundary for long long values.
324 * offset is then incremented by 8, to indicate the 8 octets which
325 * have been processed.
329 gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
333 * Decode an Object type, and display it on the tree.
336 void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int *offset,
337 gboolean stream_is_big_endian, int boundary);
340 /* Copy a 1 octet sequence from the tvbuff
341 * which represents a octet, and convert
342 * it to an octet value.
343 * offset is then incremented by 1, to indicate the 1 octet which
344 * has been processed.
347 guint8 get_CDR_octet(tvbuff_t *tvb, int *offset);
350 /* Copy a sequence of octets from the tvbuff.
351 * Caller of this function must remember to free the
352 * array pointed to by seq.
353 * This function also increments offset by len.
356 void get_CDR_octet_seq(tvbuff_t *tvb, gchar **seq, int *offset, int len);
358 /* Copy a 2 octet sequence from the tvbuff
359 * which represents a signed short value, and convert
360 * it to a signed short value, taking into account byte order.
361 * offset is first incremented so that it falls on a proper alignment
362 * boundary for short values.
363 * offset is then incremented by 2, to indicate the 2 octets which
364 * have been processed.
367 gint16 get_CDR_short(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
370 /* Copy an octet sequence from the tvbuff
371 * which represents a string, and convert
372 * it to an string value, taking into account byte order.
373 * offset is first incremented so that it falls on a proper alignment
374 * boundary for string values. (begins with an unsigned long LI)
376 * String sequence is copied to a buffer "seq". This must
377 * be freed by the calling program.
378 * offset is then incremented , to indicate the octets which
379 * have been processed.
381 * returns number of octets in the sequence
383 * Note: This function only supports single byte encoding at the
384 * moment until I get a handle on multibyte encoding etc.
388 guint32 get_CDR_string(tvbuff_t *tvb, gchar **seq, int *offset, gboolean stream_is_big_endian,
392 /* Process a sequence of octets that represent the
393 * Pseudo Object Type "TypeCode". Typecodes are used for example,
395 * This function also increments offset to the correct position.
397 * It will parse the TypeCode and output data to the "tree" provided
400 * It returns a guint32 representing a TCKind value.
403 guint32 get_CDR_typeCode(tvbuff_t *tvb, proto_tree *tree, gint *offset, gboolean stream_is_big_endian,
404 int boundary, MessageHeader * header );
406 /* Copy a 4 octet sequence from the tvbuff
407 * which represents an unsigned long value, and convert
408 * it to an unsigned long value, taking into account byte order.
409 * offset is first incremented so that it falls on a proper alignment
410 * boundary for unsigned long values.
411 * offset is then incremented by 4, to indicate the 4 octets which
412 * have been processed.
415 guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
418 /* Copy an 8 octet sequence from the tvbuff
419 * which represents an unsigned long long value, and convert
420 * it to an unsigned long long value, taking into account byte order.
421 * offset is first incremented so that it falls on a proper alignment
422 * boundary for unsigned long long values.
423 * offset is then incremented by 8, to indicate the 8 octets which
424 * have been processed.
428 guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
432 /* Copy a 2 octet sequence from the tvbuff
433 * which represents an unsigned short value, and convert
434 * it to an unsigned short value, taking into account byte order.
435 * offset is first incremented so that it falls on a proper alignment
436 * boundary for unsigned short values.
437 * offset is then incremented by 2, to indicate the 2 octets which
438 * have been processed.
441 guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian, int boundary);
444 /* Copy a wchar from the tvbuff.
445 * Caller of this function must remember to free the
446 * array pointed to by seq.
447 * This function also increments offset according to
450 * For GIOP 1.1 read 2 octets and return size -2. The
451 * negation means there is no size element in the packet
452 * and therefore no size to add to the tree.
454 * For GIOP 1.2 read size of wchar and the size
455 * octets. size is returned as a gint8.
457 * For both GIOP versions the wchar is returned
458 * as a printable string.
462 /* NOTE: This is very primitive in that it just reads
463 * the wchar as a series of octets and returns them
464 * to the user. No translation is attempted based on
465 * byte orientation, nor on code set. I.e it only
466 * really reads past the wchar and increments the offset
467 * by the length of the octet sequence.
470 /* The "decoding" is done according to CORBA chapter 15.
471 * Wchar is not supported for GIOP 1.0.
474 gint8 get_CDR_wchar(tvbuff_t *tvb, gchar **seq, int *offset, MessageHeader * header);
477 /* Copy a wstring from the tvbuff.
478 * Caller of this function must remember to free the
479 * array pointed to by seq.
480 * This function also increments offset, according to
481 * wstring length. length is returned as guint32
484 /* NOTE: This is very primitive in that it just reads
485 * the wstring as a series of octets and returns them
486 * to the user. No translation is attempted based on
487 * byte orientation, nor on code set. I.e it only
488 * really reads past the wstring and increments the offset
489 * by the length of the octet sequence.
492 /* The "decoding" is done according to CORBA chapter 15.
493 * Wstring is not supported for GIOP 1.0.
496 guint32 get_CDR_wstring(tvbuff_t *tvb, gchar **seq, int *offset, gboolean stream_is_big_endian,
497 int boundary, MessageHeader * header);
503 * End of get_CDR_xxx accessors.
509 /* Determine the byte order from the GIOP MessageHeader */
511 gboolean is_big_endian (MessageHeader * header);
514 * get_encap_info() for any encapsulation (eg:sequences)
515 * we come across. updates the new boundary and endianess
516 * and *offset, and returns the sequence length.
519 guint32 get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, gint *offset,
520 gboolean old_stream_is_big_endian, guint32 old_boundary,
521 gboolean *new_stream_is_big_endian_ptr, guint32 *new_boundary_ptr );
562 tk_abstract_interface,
564 /* - none - 0xffffffff TODO */
567 #define tk_none 0xffffffff
569 typedef enum TCKind TCKind_t;
573 * ServiceId's for ServiceContextList
575 * Chapter 13 Corba 2.4.2
578 #define IOP_ServiceId_TransactionService 0
579 #define IOP_ServiceId_CodeSets 1
580 #define IOP_ServiceId_ChainBypassCheck 2
581 #define IOP_ServiceId_ChainBypassInfo 3
582 #define IOP_ServiceId_LogicalThreadId 4
583 #define IOP_ServiceId_BI_DIR_IIOP 5
584 #define IOP_ServiceId_SendingContextRunTime 6
585 #define IOP_ServiceId_INVOCATION_POLICIES 7
586 #define IOP_ServiceId_FORWARD_IDENTITY 8
587 #define IOP_ServiceId_UnknownExceptionInfo 9
589 #endif /* PACKET_GIOP_H */