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 * Memory is allocated in packet pool and will be
360 * automatically freed once the packet dissection is finished.
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".
390 * Memory is allocated in packet pool and will be
391 * automatically freed once the packet dissection is finished.
392 * offset is then incremented , to indicate the octets which
393 * have been processed.
395 * returns number of octets in the sequence
397 * Note: This function only supports single byte encoding at the
398 * moment until I get a handle on multibyte encoding etc.
402 WS_DLL_PUBLIC guint32
get_CDR_string(tvbuff_t
*tvb
, const gchar
**seq
, int *offset
,
403 gboolean stream_is_big_endian
, int boundary
);
406 /* Process a sequence of octets that represent the
407 * Pseudo Object Type "TypeCode". Typecodes are used for example,
409 * This function also increments offset to the correct position.
411 * It will parse the TypeCode and output data to the "tree" provided
414 * It returns a guint32 representing a TCKind value.
417 WS_DLL_PUBLIC guint32
get_CDR_typeCode(tvbuff_t
*tvb
, packet_info
* pinfo
, proto_tree
*tree
, gint
*offset
,
418 gboolean stream_is_big_endian
, int boundary
, MessageHeader
* header
);
420 /* Copy a 4 octet sequence from the tvbuff
421 * which represents an unsigned long value, and convert
422 * it to an unsigned long value, taking into account byte order.
423 * offset is first incremented so that it falls on a proper alignment
424 * boundary for unsigned long values.
425 * offset is then incremented by 4, to indicate the 4 octets which
426 * have been processed.
429 WS_DLL_PUBLIC guint32
get_CDR_ulong(tvbuff_t
*tvb
, int *offset
,
430 gboolean stream_is_big_endian
, int boundary
);
433 /* Copy an 8 octet sequence from the tvbuff
434 * which represents an unsigned long long value, and convert
435 * it to an unsigned long long value, taking into account byte order.
436 * offset is first incremented so that it falls on a proper alignment
437 * boundary for unsigned long long values.
438 * offset is then incremented by 8, to indicate the 8 octets which
439 * have been processed.
442 WS_DLL_PUBLIC guint64
get_CDR_ulong_long(tvbuff_t
*tvb
, int *offset
,
443 gboolean stream_is_big_endian
, int boundary
);
445 /* Copy a 2 octet sequence from the tvbuff
446 * which represents an unsigned short value, and convert
447 * it to an unsigned short value, taking into account byte order.
448 * offset is first incremented so that it falls on a proper alignment
449 * boundary for unsigned short values.
450 * offset is then incremented by 2, to indicate the 2 octets which
451 * have been processed.
454 WS_DLL_PUBLIC guint16
get_CDR_ushort(tvbuff_t
*tvb
, int *offset
,
455 gboolean stream_is_big_endian
, int boundary
);
458 /* Copy a wchar from the tvbuff.
459 * Memory is allocated in packet pool and will be
460 * automatically freed once the packet dissection is finished.
461 * This function also increments offset according to
464 * For GIOP 1.1 read 2 octets and return size -2. The
465 * negation means there is no size element in the packet
466 * and therefore no size to add to the tree.
468 * For GIOP 1.2 read size of wchar and the size
469 * octets. size is returned as a gint8.
471 * For both GIOP versions the wchar is returned
472 * as a printable string.
476 /* NOTE: This is very primitive in that it just reads
477 * the wchar as a series of octets and returns them
478 * to the user. No translation is attempted based on
479 * byte orientation, nor on code set. I.e it only
480 * really reads past the wchar and increments the offset
481 * by the length of the octet sequence.
484 /* The "decoding" is done according to CORBA chapter 15.
485 * Wchar is not supported for GIOP 1.0.
488 WS_DLL_PUBLIC gint
get_CDR_wchar(tvbuff_t
*tvb
, const gchar
**seq
, int *offset
,
489 MessageHeader
* header
);
492 /* Copy a wstring from the tvbuff.
493 * Memory is allocated in packet pool and will be
494 * automatically freed once the packet dissection is finished.
495 * This function also increments offset, according to
496 * wstring length. length is returned as guint32
499 /* NOTE: This is very primitive in that it just reads
500 * the wstring as a series of octets and returns them
501 * to the user. No translation is attempted based on
502 * byte orientation, nor on code set. I.e it only
503 * really reads past the wstring and increments the offset
504 * by the length of the octet sequence.
507 /* The "decoding" is done according to CORBA chapter 15.
508 * Wstring is not supported for GIOP 1.0.
511 WS_DLL_PUBLIC guint32
get_CDR_wstring(tvbuff_t
*tvb
, const gchar
**seq
, int *offset
,
512 gboolean stream_is_big_endian
, int boundary
, MessageHeader
* header
);
518 * End of get_CDR_xxx accessors.
524 /* Determine the byte order from the GIOP MessageHeader */
526 WS_DLL_PUBLIC gboolean
is_big_endian (MessageHeader
* header
);
529 * get_encap_info() for any encapsulation (eg:sequences)
530 * we come across. updates the new boundary and endianess
531 * and *offset, and returns the sequence length.
534 WS_DLL_PUBLIC guint32
get_CDR_encap_info(tvbuff_t
*tvb
, proto_tree
*tree
, gint
*offset
,
535 gboolean old_stream_is_big_endian
, guint32 old_boundary
,
536 gboolean
*new_stream_is_big_endian_ptr
, guint32
*new_boundary_ptr
);
538 /* Take in an array of char and create a new ephemeral string.
539 * Replace non-printable characters with periods.
541 * The array may contain \0's so dont use strdup
542 * The string is \0 terminated, and thus longer than
543 * the initial sequence.
546 WS_DLL_PUBLIC gchar
* make_printable_string (const gchar
*in
, guint32 len
);
585 tk_abstract_interface
587 /* - none - 0xffffffff TODO */
590 #define tk_none 0xffffffff
592 typedef enum TCKind TCKind_t
;
596 * ServiceId's for ServiceContextList
598 * Chapter 13 Corba 2.4.2
601 #define IOP_ServiceId_TransactionService 0
602 #define IOP_ServiceId_CodeSets 1
603 #define IOP_ServiceId_ChainBypassCheck 2
604 #define IOP_ServiceId_ChainBypassInfo 3
605 #define IOP_ServiceId_LogicalThreadId 4
606 #define IOP_ServiceId_BI_DIR_IIOP 5
607 #define IOP_ServiceId_SendingContextRunTime 6
608 #define IOP_ServiceId_INVOCATION_POLICIES 7
609 #define IOP_ServiceId_FORWARD_IDENTITY 8
610 #define IOP_ServiceId_UnknownExceptionInfo 9
612 #endif /* PACKET_GIOP_H */