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.
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include "ws_symbol_export.h"
34 * Useful visible data/structs
37 #define GIOP_HEADER_SIZE 12
38 #define GIOP_MAGIC_NUMBER 0x47494F50 /* "GIOP" */
40 typedef struct Version {
47 * Useful data collected from message header. Note, this
48 * struct encapsulates useful data from GIOP header, as well
49 * as request_id and reply_status for use by sub dissectors.
52 typedef struct MessageHeader {
58 guint8 flags; /* byte_order in 1.0 */
61 guint32 req_id; /* request id in MSG */
63 /* MSG dependant data */
65 guint32 rep_status; /* reply status in MSG if available */
66 gchar *exception_id; /* exception string if a USER EXCEPTION occurs */
70 typedef enum MsgType {
78 Fragment /* GIOP 1.1 only */
89 typedef enum ReplyStatusType {
94 LOCATION_FORWARD_PERM, /* new for GIOP 1.2 */
95 NEEDS_ADDRESSING_MODE /* new for GIOP 1.2 */
99 * Prototype for sub dissector function calls.
102 typedef gboolean (giop_sub_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, int *,
103 MessageHeader *, const gchar * , gchar *);
106 * Generic Subdissector handle, wraps user info.
109 typedef struct giop_sub_handle {
110 giop_sub_dissector_t *sub_fn; /* ptr to sub dissector function */
111 const gchar *sub_name; /* subdissector string name */
112 protocol_t *sub_proto; /* protocol_t for subprotocol */
115 /* Main GIOP entry point */
117 extern gboolean dissect_giop(tvbuff_t *, packet_info *, proto_tree *); /* new interface */
120 * GIOP Users register interest via this function.
121 * This is for heuristic dissection
124 WS_DLL_PUBLIC void register_giop_user(giop_sub_dissector_t *sub, const gchar *name,
128 * GIOP Users remove interest via this function.
129 * This is for heuristic dissection
132 extern void delete_giop_user(giop_sub_dissector_t *sub, gchar *name);
136 * GIOP Users register their module and interface names via this function.
137 * This is for explicit dissection.
140 WS_DLL_PUBLIC void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name,
141 const gchar *module, int sub_proto);
144 * GIOP Users remove their module and interface names via this function.
145 * This is for explicit dissection.
148 extern void delete_giop_user_module(giop_sub_dissector_t *sub, gchar *name,
153 * General CDR accessors start here. They are listed in alphabetical
154 * order. They may however, belong to 1 of 3 distinct CDR data types.
157 * - OMG IDL Constructed Types
158 * - Pseudo Object Types
161 * Altough some of these look redundant, I have separated them
162 * out for all CDR types, to assist in auto generation of
163 * IDL dissectors later, see idl2wrs -- FS
169 * Gets data of type any. This is encoded as a TypeCode
170 * followed by the encoded value.
172 * Data is added to tree directly if present.
175 WS_DLL_PUBLIC void get_CDR_any(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item,
176 gint *offset, gboolean stream_is_big_endian,
177 int boundary, MessageHeader * header);
180 /* Copy a 1 octet sequence from the tvbuff
181 * which represents a boolean value, and convert
182 * it to a boolean value.
183 * Offset is then incremented by 1, to indicate the 1 octet which
184 * has been processed.
187 WS_DLL_PUBLIC gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset);
190 /* Copy a 1 octet sequence from the tvbuff
191 * which represents a char, and convert
192 * it to an char value.
193 * offset is then incremented by 1, to indicate the 1 octet which
194 * has been processed.
197 WS_DLL_PUBLIC guint8 get_CDR_char(tvbuff_t *tvb, int *offset);
202 * Floating Point Data Type double IEEE 754-1985
204 * Copy an 8 octet sequence from the tvbuff
205 * which represents a double value, and convert
206 * it to a double value, taking into account byte order.
207 * offset is first incremented so that it falls on a proper alignment
208 * boundary for double values.
209 * offset is then incremented by 8, to indicate the 8 octets which
210 * have been processed.
213 WS_DLL_PUBLIC gdouble get_CDR_double(tvbuff_t *tvb, int *offset,
214 gboolean stream_is_big_endian, int boundary);
217 /* Copy a 4 octet sequence from the tvbuff
218 * which represents an enum value, and convert
219 * it to an enum value, taking into account byte order.
220 * offset is first incremented so that it falls on a proper alignment
221 * boundary for an enum (4)
222 * offset is then incremented by 4, to indicate the 4 octets which
223 * have been processed.
225 * Enum values are encoded as unsigned long.
228 WS_DLL_PUBLIC guint32 get_CDR_enum(tvbuff_t *tvb, int *offset,
229 gboolean stream_is_big_endian, int boundary);
234 * Copy an octet sequence from the tvbuff
235 * which represents a Fixed point decimal type, and create a string representing
236 * a Fixed point decimal type. There are no alignment restrictions.
237 * Size and scale of fixed decimal type is determined by IDL.
239 * digits - IDL specified number of "digits" for this fixed type
240 * scale - IDL specified "scale" for this fixed type
243 * eg: typedef fixed <5,2> fixed_t;
244 * could represent numbers like 123.45, 789.12,
247 * As the fixed type could be any size, I will not try to fit it into our
248 * simple types like gdouble or glong etc. I will just create a string buffer holding
249 * a representation (after scale is applied), and with a decimal point or zero padding
250 * inserted at the right place if necessary. The string is null terminated
252 * so string may look like
255 * "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
257 * According to spec, digits <= 31
258 * and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
263 WS_DLL_PUBLIC void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item,
264 gchar **seq, gint *offset, guint32 digits, gint32 scale);
268 * Floating Point Data Type float IEEE 754-1985
270 * Copy a 4 octet sequence from the tvbuff
271 * which represents a float value, and convert
272 * it to a float value, taking into account byte order.
273 * offset is first incremented so that it falls on a proper alignment
274 * boundary for float values.
275 * offset is then incremented by 4, to indicate the 4 octets which
276 * have been processed.
279 WS_DLL_PUBLIC gfloat get_CDR_float(tvbuff_t *tvb, int *offset,
280 gboolean stream_is_big_endian, int boundary);
284 * Decode an Interface type, and display it on the tree.
287 WS_DLL_PUBLIC void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo,
288 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
291 /* Copy a 4 octet sequence from the tvbuff
292 * which represents a signed long value, and convert
293 * it to an signed long vaule, taking into account byte order.
294 * offset is first incremented so that it falls on a proper alignment
295 * boundary for long values.
296 * offset is then incremented by 4, to indicate the 4 octets which
297 * have been processed.
300 WS_DLL_PUBLIC gint32 get_CDR_long(tvbuff_t *tvb, int *offset,
301 gboolean stream_is_big_endian, int boundary);
305 /* Copy a 16 octet sequence from the tvbuff
306 * which represents a long double value, and convert
307 * it to a long double value, taking into account byte order.
308 * offset is first incremented so that it falls on a proper alignment
309 * boundary for long double values.
310 * offset is then incremented by 16, to indicate the 16 octets which
311 * have been processed.
314 #ifdef G_HAVE_GLONG_DOUBLE
316 WS_DLL_PUBLIC glong_double get_CDR_long_double(tvbuff_t *tvb, int *offset,
317 gboolean stream_is_big_endian, int boundary);
320 /* FIX -- Cast long double to gdouble until I figure this out -- FS*/
322 WS_DLL_PUBLIC gdouble get_CDR_long_double(tvbuff_t *tvb, int *offset,
323 gboolean stream_is_big_endian, int boundary);
328 /* Copy an 8 octet sequence from the tvbuff
329 * which represents a signed long long value, and convert
330 * it to a signed long long value, taking into account byte order.
331 * offset is first incremented so that it falls on a proper alignment
332 * boundary for long long values.
333 * offset is then incremented by 8, to indicate the 8 octets which
334 * have been processed.
337 WS_DLL_PUBLIC gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset,
338 gboolean stream_is_big_endian, int boundary);
341 * Decode an Object type, and display it on the tree.
344 WS_DLL_PUBLIC void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo,
345 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
348 /* Copy a 1 octet sequence from the tvbuff
349 * which represents a octet, and convert
350 * it to an octet value.
351 * offset is then incremented by 1, to indicate the 1 octet which
352 * has been processed.
355 WS_DLL_PUBLIC guint8 get_CDR_octet(tvbuff_t *tvb, int *offset);
358 /* Copy a sequence of octets from the tvbuff.
359 * Caller of this function must remember to free the
360 * array pointed to by seq.
361 * This function also increments offset by len.
364 WS_DLL_PUBLIC void get_CDR_octet_seq(tvbuff_t *tvb, const gchar **seq, int *offset, guint32 len);
366 /* Copy a 2 octet sequence from the tvbuff
367 * which represents a signed short value, and convert
368 * it to a signed short value, taking into account byte order.
369 * offset is first incremented so that it falls on a proper alignment
370 * boundary for short values.
371 * offset is then incremented by 2, to indicate the 2 octets which
372 * have been processed.
375 WS_DLL_PUBLIC gint16 get_CDR_short(tvbuff_t *tvb, int *offset,
376 gboolean stream_is_big_endian, int boundary);
379 extern void giop_add_CDR_string(proto_tree *tree, tvbuff_t *tvb, int *offset,
380 gboolean stream_is_big_endian, int boundary,
383 /* Copy an octet sequence from the tvbuff
384 * which represents a string, and convert
385 * it to an string value, taking into account byte order.
386 * offset is first incremented so that it falls on a proper alignment
387 * boundary for string values. (begins with an unsigned long LI)
389 * String sequence is copied to a buffer "seq". This must
390 * be freed by the calling program.
391 * offset is then incremented , to indicate the octets which
392 * have been processed.
394 * returns number of octets in the sequence
396 * Note: This function only supports single byte encoding at the
397 * moment until I get a handle on multibyte encoding etc.
401 WS_DLL_PUBLIC guint32 get_CDR_string(tvbuff_t *tvb, const gchar **seq, int *offset,
402 gboolean stream_is_big_endian, int boundary);
405 /* Process a sequence of octets that represent the
406 * Pseudo Object Type "TypeCode". Typecodes are used for example,
408 * This function also increments offset to the correct position.
410 * It will parse the TypeCode and output data to the "tree" provided
413 * It returns a guint32 representing a TCKind value.
416 WS_DLL_PUBLIC guint32 get_CDR_typeCode(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, gint *offset,
417 gboolean stream_is_big_endian, int boundary, MessageHeader * header );
419 /* Copy a 4 octet sequence from the tvbuff
420 * which represents an unsigned long value, and convert
421 * it to an unsigned long value, taking into account byte order.
422 * offset is first incremented so that it falls on a proper alignment
423 * boundary for unsigned long values.
424 * offset is then incremented by 4, to indicate the 4 octets which
425 * have been processed.
428 WS_DLL_PUBLIC guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset,
429 gboolean stream_is_big_endian, int boundary);
432 /* Copy an 8 octet sequence from the tvbuff
433 * which represents an unsigned long long value, and convert
434 * it to an unsigned long long value, taking into account byte order.
435 * offset is first incremented so that it falls on a proper alignment
436 * boundary for unsigned long long values.
437 * offset is then incremented by 8, to indicate the 8 octets which
438 * have been processed.
441 WS_DLL_PUBLIC guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
442 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 WS_DLL_PUBLIC 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 WS_DLL_PUBLIC gint get_CDR_wchar(tvbuff_t *tvb, const 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 WS_DLL_PUBLIC guint32 get_CDR_wstring(tvbuff_t *tvb, const 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 WS_DLL_PUBLIC 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 WS_DLL_PUBLIC 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 );
537 /* Take in an array of char and create a new ephemeral string.
538 * Replace non-printable characters with periods.
540 * The array may contain \0's so dont use strdup
541 * The string is \0 terminated, and thus longer than
542 * the initial sequence.
545 WS_DLL_PUBLIC gchar * make_printable_string (const gchar *in, guint32 len);
584 tk_abstract_interface
586 /* - none - 0xffffffff TODO */
589 #define tk_none 0xffffffff
591 typedef enum TCKind TCKind_t;
595 * ServiceId's for ServiceContextList
597 * Chapter 13 Corba 2.4.2
600 #define IOP_ServiceId_TransactionService 0
601 #define IOP_ServiceId_CodeSets 1
602 #define IOP_ServiceId_ChainBypassCheck 2
603 #define IOP_ServiceId_ChainBypassInfo 3
604 #define IOP_ServiceId_LogicalThreadId 4
605 #define IOP_ServiceId_BI_DIR_IIOP 5
606 #define IOP_ServiceId_SendingContextRunTime 6
607 #define IOP_ServiceId_INVOCATION_POLICIES 7
608 #define IOP_ServiceId_FORWARD_IDENTITY 8
609 #define IOP_ServiceId_UnknownExceptionInfo 9
611 #endif /* PACKET_GIOP_H */