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.7 2001/10/31 07:47:25 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 extern 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 extern void register_giop_user(giop_sub_dissector_t *sub, gchar *name,
125 * GIOP Users remove interest via this function.
126 * This is for heuristic dissection
129 extern void delete_giop_user(giop_sub_dissector_t *sub, gchar *name);
133 * GIOP Users register their module and interface names via this function.
134 * This is for explicit dissection.
137 extern void register_giop_user_module(giop_sub_dissector_t *sub, gchar *name,
138 gchar *module, int sub_proto);
141 * GIOP Users remove their module and interface names via this function.
142 * This is for explicit dissection.
145 extern void delete_giop_user_module(giop_sub_dissector_t *sub, gchar *name,
150 * General CDR accessors start here. They are listed in alphabetical
151 * order. They may however, belong to 1 of 3 distinct CDR data types.
154 * - OMG IDL Constructed Types
155 * - Pseudo Object Types
158 * Altough some of these look redundant, I have separated them
159 * out for all CDR types, to assist in auto generation of
160 * IDL dissectors later, see idl2eth -- FS
166 * Gets data of type any. This is encoded as a TypeCode
167 * followed by the encoded value.
169 * Data is added to tree directly if present.
172 extern void get_CDR_any(tvbuff_t *tvb, proto_tree *tree, gint *offset,
173 gboolean stream_is_big_endian, int boundary, MessageHeader * header );
176 /* Copy a 1 octet sequence from the tvbuff
177 * which represents a boolean value, and convert
178 * it to a boolean value.
179 * Offset is then incremented by 1, to indicate the 1 octet which
180 * has been processed.
183 extern gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset);
186 /* Copy a 1 octet sequence from the tvbuff
187 * which represents a char, and convert
188 * it to an char value.
189 * offset is then incremented by 1, to indicate the 1 octet which
190 * has been processed.
193 extern guint8 get_CDR_char(tvbuff_t *tvb, int *offset);
198 * Floating Point Data Type double IEEE 754-1985
200 * Copy an 8 octet sequence from the tvbuff
201 * which represents a double value, and convert
202 * it to a double value, taking into account byte order.
203 * offset is first incremented so that it falls on a proper alignment
204 * boundary for double values.
205 * offset is then incremented by 8, to indicate the 8 octets which
206 * have been processed.
209 extern gdouble get_CDR_double(tvbuff_t *tvb, int *offset,
210 gboolean stream_is_big_endian, int boundary);
213 /* Copy a 4 octet sequence from the tvbuff
214 * which represents an enum value, and convert
215 * it to an enum value, taking into account byte order.
216 * offset is first incremented so that it falls on a proper alignment
217 * boundary for an enum (4)
218 * offset is then incremented by 4, to indicate the 4 octets which
219 * have been processed.
221 * Enum values are encoded as unsigned long.
224 extern guint32 get_CDR_enum(tvbuff_t *tvb, int *offset,
225 gboolean stream_is_big_endian, int boundary);
230 * Copy an octet sequence from the tvbuff
231 * which represents a Fixed point decimal type, and create a string representing
232 * a Fixed point decimal type. There are no alignment restrictions.
233 * Size and scale of fixed decimal type is determined by IDL.
235 * digits - IDL specified number of "digits" for this fixed type
236 * scale - IDL specified "scale" for this fixed type
239 * eg: typedef fixed <5,2> fixed_t;
240 * could represent numbers like 123.45, 789.12,
243 * As the fixed type could be any size, I will not try to fit it into our
244 * simple types like gdouble or glong etc. I will just create a string buffer holding
245 * a representation (after scale is applied), and with a decimal point or zero padding
246 * inserted at the right place if necessary. The string is null terminated
248 * so string may look like
251 * "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
253 * According to spec, digits <= 31
254 * and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
257 * User must remember to free the buffer
261 extern void get_CDR_fixed(tvbuff_t *tvb, gchar **seq, gint *offset,
262 guint32 digits, gint32 scale);
267 * Floating Point Data Type float IEEE 754-1985
269 * Copy a 4 octet sequence from the tvbuff
270 * which represents a float value, and convert
271 * it to a float value, taking into account byte order.
272 * offset is first incremented so that it falls on a proper alignment
273 * boundary for float values.
274 * offset is then incremented by 4, to indicate the 4 octets which
275 * have been processed.
278 extern gfloat get_CDR_float(tvbuff_t *tvb, int *offset,
279 gboolean stream_is_big_endian, int boundary);
283 * Decode an Interface type, and display it on the tree.
286 extern void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo,
287 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
290 /* Copy a 4 octet sequence from the tvbuff
291 * which represents a signed long value, and convert
292 * it to an signed long vaule, taking into account byte order.
293 * offset is first incremented so that it falls on a proper alignment
294 * boundary for long values.
295 * offset is then incremented by 4, to indicate the 4 octets which
296 * have been processed.
299 extern gint32 get_CDR_long(tvbuff_t *tvb, int *offset,
300 gboolean stream_is_big_endian, int boundary);
304 /* Copy a 16 octet sequence from the tvbuff
305 * which represents a long double value, and convert
306 * it to a long double value, taking into account byte order.
307 * offset is first incremented so that it falls on a proper alignment
308 * boundary for long double values.
309 * offset is then incremented by 16, to indicate the 16 octets which
310 * have been processed.
313 #ifdef G_HAVE_GLONG_DOUBLE
315 extern glong_double get_CDR_long_double(tvbuff_t *tvb, int *offset,
316 gboolean stream_is_big_endian, int boundary);
319 /* FIX -- Cast long double to gdouble until I figure this out -- FS*/
321 extern gdouble get_CDR_long_double(tvbuff_t *tvb, int *offset,
322 gboolean stream_is_big_endian, int boundary);
327 /* Copy an 8 octet sequence from the tvbuff
328 * which represents a signed long long value, and convert
329 * it to a signed long long value, taking into account byte order.
330 * offset is first incremented so that it falls on a proper alignment
331 * boundary for long long values.
332 * offset is then incremented by 8, to indicate the 8 octets which
333 * have been processed.
337 extern gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset,
338 gboolean stream_is_big_endian, int boundary);
342 * Decode an Object type, and display it on the tree.
345 extern void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo,
346 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
349 /* Copy a 1 octet sequence from the tvbuff
350 * which represents a octet, and convert
351 * it to an octet value.
352 * offset is then incremented by 1, to indicate the 1 octet which
353 * has been processed.
356 extern guint8 get_CDR_octet(tvbuff_t *tvb, int *offset);
359 /* Copy a sequence of octets from the tvbuff.
360 * Caller of this function must remember to free the
361 * array pointed to by seq.
362 * This function also increments offset by len.
365 extern void get_CDR_octet_seq(tvbuff_t *tvb, gchar **seq, int *offset, int len);
367 /* Copy a 2 octet sequence from the tvbuff
368 * which represents a signed short value, and convert
369 * it to a signed short value, taking into account byte order.
370 * offset is first incremented so that it falls on a proper alignment
371 * boundary for short values.
372 * offset is then incremented by 2, to indicate the 2 octets which
373 * have been processed.
376 extern gint16 get_CDR_short(tvbuff_t *tvb, int *offset,
377 gboolean stream_is_big_endian, int boundary);
380 /* Copy an octet sequence from the tvbuff
381 * which represents a string, and convert
382 * it to an string value, taking into account byte order.
383 * offset is first incremented so that it falls on a proper alignment
384 * boundary for string values. (begins with an unsigned long LI)
386 * String sequence is copied to a buffer "seq". This must
387 * be freed by the calling program.
388 * offset is then incremented , to indicate the octets which
389 * have been processed.
391 * returns number of octets in the sequence
393 * Note: This function only supports single byte encoding at the
394 * moment until I get a handle on multibyte encoding etc.
398 extern guint32 get_CDR_string(tvbuff_t *tvb, gchar **seq, int *offset,
399 gboolean stream_is_big_endian, int boundary);
402 /* Process a sequence of octets that represent the
403 * Pseudo Object Type "TypeCode". Typecodes are used for example,
405 * This function also increments offset to the correct position.
407 * It will parse the TypeCode and output data to the "tree" provided
410 * It returns a guint32 representing a TCKind value.
413 extern guint32 get_CDR_typeCode(tvbuff_t *tvb, proto_tree *tree, gint *offset,
414 gboolean stream_is_big_endian, int boundary, MessageHeader * header );
416 /* Copy a 4 octet sequence from the tvbuff
417 * which represents an unsigned long value, and convert
418 * it to an unsigned long value, taking into account byte order.
419 * offset is first incremented so that it falls on a proper alignment
420 * boundary for unsigned long values.
421 * offset is then incremented by 4, to indicate the 4 octets which
422 * have been processed.
425 extern guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset,
426 gboolean stream_is_big_endian, int boundary);
429 /* Copy an 8 octet sequence from the tvbuff
430 * which represents an unsigned long long value, and convert
431 * it to an unsigned long long value, taking into account byte order.
432 * offset is first incremented so that it falls on a proper alignment
433 * boundary for unsigned long long values.
434 * offset is then incremented by 8, to indicate the 8 octets which
435 * have been processed.
439 extern guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
440 gboolean stream_is_big_endian, int boundary);
444 /* Copy a 2 octet sequence from the tvbuff
445 * which represents an unsigned short value, and convert
446 * it to an unsigned short value, taking into account byte order.
447 * offset is first incremented so that it falls on a proper alignment
448 * boundary for unsigned short values.
449 * offset is then incremented by 2, to indicate the 2 octets which
450 * have been processed.
453 extern guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset,
454 gboolean stream_is_big_endian, int boundary);
457 /* Copy a wchar from the tvbuff.
458 * Caller of this function must remember to free the
459 * array pointed to by seq.
460 * This function also increments offset according to
463 * For GIOP 1.1 read 2 octets and return size -2. The
464 * negation means there is no size element in the packet
465 * and therefore no size to add to the tree.
467 * For GIOP 1.2 read size of wchar and the size
468 * octets. size is returned as a gint8.
470 * For both GIOP versions the wchar is returned
471 * as a printable string.
475 /* NOTE: This is very primitive in that it just reads
476 * the wchar as a series of octets and returns them
477 * to the user. No translation is attempted based on
478 * byte orientation, nor on code set. I.e it only
479 * really reads past the wchar and increments the offset
480 * by the length of the octet sequence.
483 /* The "decoding" is done according to CORBA chapter 15.
484 * Wchar is not supported for GIOP 1.0.
487 extern gint8 get_CDR_wchar(tvbuff_t *tvb, gchar **seq, int *offset,
488 MessageHeader * header);
491 /* Copy a wstring from the tvbuff.
492 * Caller of this function must remember to free the
493 * array pointed to by seq.
494 * This function also increments offset, according to
495 * wstring length. length is returned as guint32
498 /* NOTE: This is very primitive in that it just reads
499 * the wstring as a series of octets and returns them
500 * to the user. No translation is attempted based on
501 * byte orientation, nor on code set. I.e it only
502 * really reads past the wstring and increments the offset
503 * by the length of the octet sequence.
506 /* The "decoding" is done according to CORBA chapter 15.
507 * Wstring is not supported for GIOP 1.0.
510 extern guint32 get_CDR_wstring(tvbuff_t *tvb, gchar **seq, int *offset,
511 gboolean stream_is_big_endian, int boundary, MessageHeader * header);
517 * End of get_CDR_xxx accessors.
523 /* Determine the byte order from the GIOP MessageHeader */
525 extern gboolean is_big_endian (MessageHeader * header);
528 * get_encap_info() for any encapsulation (eg:sequences)
529 * we come across. updates the new boundary and endianess
530 * and *offset, and returns the sequence length.
533 extern guint32 get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, gint *offset,
534 gboolean old_stream_is_big_endian, guint32 old_boundary,
535 gboolean *new_stream_is_big_endian_ptr, guint32 *new_boundary_ptr );
576 tk_abstract_interface,
578 /* - none - 0xffffffff TODO */
581 #define tk_none 0xffffffff
583 typedef enum TCKind TCKind_t;
587 * ServiceId's for ServiceContextList
589 * Chapter 13 Corba 2.4.2
592 #define IOP_ServiceId_TransactionService 0
593 #define IOP_ServiceId_CodeSets 1
594 #define IOP_ServiceId_ChainBypassCheck 2
595 #define IOP_ServiceId_ChainBypassInfo 3
596 #define IOP_ServiceId_LogicalThreadId 4
597 #define IOP_ServiceId_BI_DIR_IIOP 5
598 #define IOP_ServiceId_SendingContextRunTime 6
599 #define IOP_ServiceId_INVOCATION_POLICIES 7
600 #define IOP_ServiceId_FORWARD_IDENTITY 8
601 #define IOP_ServiceId_UnknownExceptionInfo 9
603 #endif /* PACKET_GIOP_H */