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 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "ws_symbol_export.h"
32 * Useful visible data/structs
35 #define GIOP_HEADER_SIZE 12
36 #define GIOP_MAGIC_NUMBER 0x47494F50 /* "GIOP" */
38 typedef struct Version {
45 * Useful data collected from message header. Note, this
46 * struct encapsulates useful data from GIOP header, as well
47 * as request_id and reply_status for use by sub dissectors.
50 typedef struct MessageHeader {
56 guint8 flags; /* byte_order in 1.0 */
59 guint32 req_id; /* request id in MSG */
61 /* MSG dependant data */
63 guint32 rep_status; /* reply status in MSG if available */
64 gchar *exception_id; /* exception string if a USER EXCEPTION occurs */
68 typedef enum MsgType {
76 Fragment /* GIOP 1.1 only */
87 typedef enum ReplyStatusType {
92 LOCATION_FORWARD_PERM, /* new for GIOP 1.2 */
93 NEEDS_ADDRESSING_MODE /* new for GIOP 1.2 */
97 * Prototype for sub dissector function calls.
100 typedef gboolean (giop_sub_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, int *,
101 MessageHeader *, const gchar * , gchar *);
104 * Generic Subdissector handle, wraps user info.
107 typedef struct giop_sub_handle {
108 giop_sub_dissector_t *sub_fn; /* ptr to sub dissector function */
109 const gchar *sub_name; /* subdissector string name */
110 protocol_t *sub_proto; /* protocol_t for subprotocol */
113 /* Main GIOP entry point */
115 extern gboolean dissect_giop(tvbuff_t *, packet_info *, proto_tree *); /* new interface */
118 * GIOP Users register interest via this function.
119 * This is for heuristic dissection
122 WS_DLL_PUBLIC void register_giop_user(giop_sub_dissector_t *sub, const gchar *name,
126 * GIOP Users remove interest via this function.
127 * This is for heuristic dissection
130 extern void delete_giop_user(giop_sub_dissector_t *sub, gchar *name);
134 * GIOP Users register their module and interface names via this function.
135 * This is for explicit dissection.
138 WS_DLL_PUBLIC void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name,
139 const gchar *module, int sub_proto);
142 * GIOP Users remove their module and interface names via this function.
143 * This is for explicit dissection.
146 extern void delete_giop_user_module(giop_sub_dissector_t *sub, gchar *name,
151 * General CDR accessors start here. They are listed in alphabetical
152 * order. They may however, belong to 1 of 3 distinct CDR data types.
155 * - OMG IDL Constructed Types
156 * - Pseudo Object Types
159 * Altough some of these look redundant, I have separated them
160 * out for all CDR types, to assist in auto generation of
161 * IDL dissectors later, see idl2wrs -- FS
167 * Gets data of type any. This is encoded as a TypeCode
168 * followed by the encoded value.
170 * Data is added to tree directly if present.
173 WS_DLL_PUBLIC void get_CDR_any(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item,
174 gint *offset, gboolean stream_is_big_endian,
175 int boundary, MessageHeader * header);
178 /* Copy a 1 octet sequence from the tvbuff
179 * which represents a boolean value, and convert
180 * it to a boolean value.
181 * Offset is then incremented by 1, to indicate the 1 octet which
182 * has been processed.
185 WS_DLL_PUBLIC gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset);
188 /* Copy a 1 octet sequence from the tvbuff
189 * which represents a char, and convert
190 * it to an char value.
191 * offset is then incremented by 1, to indicate the 1 octet which
192 * has been processed.
195 WS_DLL_PUBLIC guint8 get_CDR_char(tvbuff_t *tvb, int *offset);
200 * Floating Point Data Type double IEEE 754-1985
202 * Copy an 8 octet sequence from the tvbuff
203 * which represents a double value, and convert
204 * it to a double value, taking into account byte order.
205 * offset is first incremented so that it falls on a proper alignment
206 * boundary for double values.
207 * offset is then incremented by 8, to indicate the 8 octets which
208 * have been processed.
211 WS_DLL_PUBLIC gdouble get_CDR_double(tvbuff_t *tvb, int *offset,
212 gboolean stream_is_big_endian, int boundary);
215 /* Copy a 4 octet sequence from the tvbuff
216 * which represents an enum value, and convert
217 * it to an enum value, taking into account byte order.
218 * offset is first incremented so that it falls on a proper alignment
219 * boundary for an enum (4)
220 * offset is then incremented by 4, to indicate the 4 octets which
221 * have been processed.
223 * Enum values are encoded as unsigned long.
226 WS_DLL_PUBLIC guint32 get_CDR_enum(tvbuff_t *tvb, int *offset,
227 gboolean stream_is_big_endian, int boundary);
232 * Copy an octet sequence from the tvbuff
233 * which represents a Fixed point decimal type, and create a string representing
234 * a Fixed point decimal type. There are no alignment restrictions.
235 * Size and scale of fixed decimal type is determined by IDL.
237 * digits - IDL specified number of "digits" for this fixed type
238 * scale - IDL specified "scale" for this fixed type
241 * eg: typedef fixed <5,2> fixed_t;
242 * could represent numbers like 123.45, 789.12,
245 * As the fixed type could be any size, I will not try to fit it into our
246 * simple types like gdouble or glong etc. I will just create a string buffer holding
247 * a representation (after scale is applied), and with a decimal point or zero padding
248 * inserted at the right place if necessary. The string is null terminated
250 * so string may look like
253 * "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
255 * According to spec, digits <= 31
256 * and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
261 WS_DLL_PUBLIC void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item,
262 gchar **seq, gint *offset, guint32 digits, gint32 scale);
266 * Floating Point Data Type float IEEE 754-1985
268 * Copy a 4 octet sequence from the tvbuff
269 * which represents a float value, and convert
270 * it to a float value, taking into account byte order.
271 * offset is first incremented so that it falls on a proper alignment
272 * boundary for float values.
273 * offset is then incremented by 4, to indicate the 4 octets which
274 * have been processed.
277 WS_DLL_PUBLIC gfloat get_CDR_float(tvbuff_t *tvb, int *offset,
278 gboolean stream_is_big_endian, int boundary);
282 * Decode an Interface type, and display it on the tree.
285 WS_DLL_PUBLIC void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo,
286 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
289 /* Copy a 4 octet sequence from the tvbuff
290 * which represents a signed long value, and convert
291 * it to an signed long vaule, taking into account byte order.
292 * offset is first incremented so that it falls on a proper alignment
293 * boundary for long values.
294 * offset is then incremented by 4, to indicate the 4 octets which
295 * have been processed.
298 WS_DLL_PUBLIC gint32 get_CDR_long(tvbuff_t *tvb, int *offset,
299 gboolean stream_is_big_endian, int boundary);
303 /* Copy a 16 octet sequence from the tvbuff
304 * which represents a long double value, and convert
305 * it to a long double value, taking into account byte order.
306 * offset is first incremented so that it falls on a proper alignment
307 * boundary for long double values.
308 * offset is then incremented by 16, to indicate the 16 octets which
309 * have been processed.
312 #ifdef G_HAVE_GLONG_DOUBLE
314 WS_DLL_PUBLIC glong_double get_CDR_long_double(tvbuff_t *tvb, int *offset,
315 gboolean stream_is_big_endian, int boundary);
318 /* FIX -- Cast long double to gdouble until I figure this out -- FS*/
320 WS_DLL_PUBLIC gdouble get_CDR_long_double(tvbuff_t *tvb, int *offset,
321 gboolean stream_is_big_endian, int boundary);
326 /* Copy an 8 octet sequence from the tvbuff
327 * which represents a signed long long value, and convert
328 * it to a signed long long value, taking into account byte order.
329 * offset is first incremented so that it falls on a proper alignment
330 * boundary for long long values.
331 * offset is then incremented by 8, to indicate the 8 octets which
332 * have been processed.
335 WS_DLL_PUBLIC gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset,
336 gboolean stream_is_big_endian, int boundary);
339 * Decode an Object type, and display it on the tree.
342 WS_DLL_PUBLIC void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo,
343 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
346 /* Copy a 1 octet sequence from the tvbuff
347 * which represents a octet, and convert
348 * it to an octet value.
349 * offset is then incremented by 1, to indicate the 1 octet which
350 * has been processed.
353 WS_DLL_PUBLIC guint8 get_CDR_octet(tvbuff_t *tvb, int *offset);
356 /* Copy a sequence of octets from the tvbuff.
357 * Memory is allocated in packet pool and will be
358 * automatically freed once the packet dissection is finished.
359 * This function also increments offset by len.
362 WS_DLL_PUBLIC void get_CDR_octet_seq(tvbuff_t *tvb, const gchar **seq, int *offset, guint32 len);
364 /* Copy a 2 octet sequence from the tvbuff
365 * which represents a signed short value, and convert
366 * it to a signed short value, taking into account byte order.
367 * offset is first incremented so that it falls on a proper alignment
368 * boundary for short values.
369 * offset is then incremented by 2, to indicate the 2 octets which
370 * have been processed.
373 WS_DLL_PUBLIC gint16 get_CDR_short(tvbuff_t *tvb, int *offset,
374 gboolean stream_is_big_endian, int boundary);
377 extern void giop_add_CDR_string(proto_tree *tree, tvbuff_t *tvb, int *offset,
378 gboolean stream_is_big_endian, int boundary,
381 /* Copy an octet sequence from the tvbuff
382 * which represents a string, and convert
383 * it to an string value, taking into account byte order.
384 * offset is first incremented so that it falls on a proper alignment
385 * boundary for string values. (begins with an unsigned long LI)
387 * String sequence is copied to a buffer "seq".
388 * Memory is allocated in packet pool and will be
389 * automatically freed once the packet dissection is finished.
390 * offset is then incremented , to indicate the octets which
391 * have been processed.
393 * returns number of octets in the sequence
395 * Note: This function only supports single byte encoding at the
396 * moment until I get a handle on multibyte encoding etc.
400 WS_DLL_PUBLIC guint32 get_CDR_string(tvbuff_t *tvb, const gchar **seq, int *offset,
401 gboolean stream_is_big_endian, int boundary);
404 /* Process a sequence of octets that represent the
405 * Pseudo Object Type "TypeCode". Typecodes are used for example,
407 * This function also increments offset to the correct position.
409 * It will parse the TypeCode and output data to the "tree" provided
412 * It returns a guint32 representing a TCKind value.
415 WS_DLL_PUBLIC guint32 get_CDR_typeCode(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, gint *offset,
416 gboolean stream_is_big_endian, int boundary, MessageHeader * header );
418 /* Copy a 4 octet sequence from the tvbuff
419 * which represents an unsigned long value, and convert
420 * it to an unsigned 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 values.
423 * offset is then incremented by 4, to indicate the 4 octets which
424 * have been processed.
427 WS_DLL_PUBLIC guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset,
428 gboolean stream_is_big_endian, int boundary);
431 /* Copy an 8 octet sequence from the tvbuff
432 * which represents an unsigned long long value, and convert
433 * it to an unsigned long long value, taking into account byte order.
434 * offset is first incremented so that it falls on a proper alignment
435 * boundary for unsigned long long values.
436 * offset is then incremented by 8, to indicate the 8 octets which
437 * have been processed.
440 WS_DLL_PUBLIC guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
441 gboolean stream_is_big_endian, int boundary);
443 /* Copy a 2 octet sequence from the tvbuff
444 * which represents an unsigned short value, and convert
445 * it to an unsigned short value, taking into account byte order.
446 * offset is first incremented so that it falls on a proper alignment
447 * boundary for unsigned short values.
448 * offset is then incremented by 2, to indicate the 2 octets which
449 * have been processed.
452 WS_DLL_PUBLIC guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset,
453 gboolean stream_is_big_endian, int boundary);
456 /* Copy a wchar from the tvbuff.
457 * Memory is allocated in packet pool and will be
458 * automatically freed once the packet dissection is finished.
459 * This function also increments offset according to
462 * For GIOP 1.1 read 2 octets and return size -2. The
463 * negation means there is no size element in the packet
464 * and therefore no size to add to the tree.
466 * For GIOP 1.2 read size of wchar and the size
467 * octets. size is returned as a gint8.
469 * For both GIOP versions the wchar is returned
470 * as a printable string.
474 /* NOTE: This is very primitive in that it just reads
475 * the wchar as a series of octets and returns them
476 * to the user. No translation is attempted based on
477 * byte orientation, nor on code set. I.e it only
478 * really reads past the wchar and increments the offset
479 * by the length of the octet sequence.
482 /* The "decoding" is done according to CORBA chapter 15.
483 * Wchar is not supported for GIOP 1.0.
486 WS_DLL_PUBLIC gint get_CDR_wchar(tvbuff_t *tvb, const gchar **seq, int *offset,
487 MessageHeader * header);
490 /* Copy a wstring from the tvbuff.
491 * Memory is allocated in packet pool and will be
492 * automatically freed once the packet dissection is finished.
493 * This function also increments offset, according to
494 * wstring length. length is returned as guint32
497 /* NOTE: This is very primitive in that it just reads
498 * the wstring as a series of octets and returns them
499 * to the user. No translation is attempted based on
500 * byte orientation, nor on code set. I.e it only
501 * really reads past the wstring and increments the offset
502 * by the length of the octet sequence.
505 /* The "decoding" is done according to CORBA chapter 15.
506 * Wstring is not supported for GIOP 1.0.
509 WS_DLL_PUBLIC guint32 get_CDR_wstring(tvbuff_t *tvb, const gchar **seq, int *offset,
510 gboolean stream_is_big_endian, int boundary, MessageHeader * header);
516 * End of get_CDR_xxx accessors.
522 /* Determine the byte order from the GIOP MessageHeader */
524 WS_DLL_PUBLIC gboolean is_big_endian (MessageHeader * header);
527 * get_encap_info() for any encapsulation (eg:sequences)
528 * we come across. updates the new boundary and endianess
529 * and *offset, and returns the sequence length.
532 WS_DLL_PUBLIC guint32 get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, gint *offset,
533 gboolean old_stream_is_big_endian, guint32 old_boundary,
534 gboolean *new_stream_is_big_endian_ptr, guint32 *new_boundary_ptr );
536 /* Take in an array of char and create a new ephemeral string.
537 * Replace non-printable characters with periods.
539 * The array may contain \0's so dont use strdup
540 * The string is \0 terminated, and thus longer than
541 * the initial sequence.
544 WS_DLL_PUBLIC gchar * make_printable_string (const gchar *in, guint32 len);
583 tk_abstract_interface
585 /* - none - 0xffffffff TODO */
588 #define tk_none 0xffffffff
590 typedef enum TCKind TCKind_t;
594 * ServiceId's for ServiceContextList
596 * Chapter 13 Corba 2.4.2
599 #define IOP_ServiceId_TransactionService 0
600 #define IOP_ServiceId_CodeSets 1
601 #define IOP_ServiceId_ChainBypassCheck 2
602 #define IOP_ServiceId_ChainBypassInfo 3
603 #define IOP_ServiceId_LogicalThreadId 4
604 #define IOP_ServiceId_BI_DIR_IIOP 5
605 #define IOP_ServiceId_SendingContextRunTime 6
606 #define IOP_ServiceId_INVOCATION_POLICIES 7
607 #define IOP_ServiceId_FORWARD_IDENTITY 8
608 #define IOP_ServiceId_UnknownExceptionInfo 9
610 #endif /* PACKET_GIOP_H */