Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

packet-giop.h
1 /* packet-giop.h
2 * Declaration of routines for GIOP/IIOP (CDR) dissection
3 * Copyright 2000, Frank Singleton <frank.singleton@ericsson.com>
4 *
5 * Based on CORBAv2.4.2 Chapter 15 GIOP Description.
6 *
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14 #ifndef PACKET_GIOP_H
15 #define PACKET_GIOP_H
16
17 #include "ws_symbol_export.h"
18
19 /*
20 * Useful visible data/structs
21 */
22
23 #define GIOP_HEADER_SIZE 12
24 #define GIOP_MAGIC_NUMBER 0x47494F50 /* "GIOP" */
25
26 typedef struct Version {
27 guint8 major;
28 guint8 minor;
29 } Version;
30
31
32 /*
33 * Useful data collected from message header. Note, this
34 * struct encapsulates useful data from GIOP header, as well
35 * as request_id and reply_status for use by sub dissectors.
36 */
37
38 typedef struct MessageHeader {
39
40 /* Common Data */
41
42 guint8 magic[4];
43 Version GIOP_version;
44 guint8 flags; /* byte_order in 1.0 */
45 guint8 message_type;
46 guint32 message_size;
47
48 /* MSG dependent data */
49
50 guint32 req_id; /* request id in MSG */
51 guint32 rep_status; /* reply status in MSG if available */
52 gchar *exception_id; /* exception string if a USER EXCEPTION occurs */
53
54 } MessageHeader;
55
56 typedef enum MsgType {
57 Request = 0,
58 Reply,
59 CancelRequest,
60 LocateRequest,
61 LocateReply,
62 CloseConnection,
63 MessageError,
64 Fragment /* GIOP 1.1 only */
65
66 } MsgType;
67
68
69
70 /*
71 * Reply Status
72 *
73 */
74
75 typedef enum ReplyStatusType {
76 NO_EXCEPTION = 0,
77 USER_EXCEPTION,
78 SYSTEM_EXCEPTION,
79 LOCATION_FORWARD,
80 LOCATION_FORWARD_PERM, /* new for GIOP 1.2 */
81 NEEDS_ADDRESSING_MODE /* new for GIOP 1.2 */
82 } ReplyStatusType;
83
84 /*
85 * Prototype for sub dissector function calls.
86 */
87
88 typedef gboolean (giop_sub_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, int *,
89 MessageHeader *, const gchar * , gchar *);
90
91 /*
92 * Generic Subdissector handle, wraps user info.
93 */
94
95 typedef struct giop_sub_handle {
96 giop_sub_dissector_t *sub_fn; /* ptr to sub dissector function */
97 const gchar *sub_name; /* subdissector string name */
98 protocol_t *sub_proto; /* protocol_t for subprotocol */
99 } giop_sub_handle_t;
100
101 /* Main GIOP entry point */
102
103 extern gboolean dissect_giop(tvbuff_t *, packet_info *, proto_tree *); /* new interface */
104
105 /*
106 * GIOP Users register interest via this function.
107 * This is for heuristic dissection
108 */
109
110 WS_DLL_PUBLIC void register_giop_user(giop_sub_dissector_t *sub, const gchar *name,
111 int sub_proto);
112
113 /*
114 * GIOP Users remove interest via this function.
115 * This is for heuristic dissection
116 */
117
118 extern void delete_giop_user(giop_sub_dissector_t *sub, gchar *name);
119
120
121 /*
122 * GIOP Users register their module and interface names via this function.
123 * This is for explicit dissection.
124 */
125
126 WS_DLL_PUBLIC void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name,
127 const gchar *module, int sub_proto);
128
129 /*
130 * GIOP Users remove their module and interface names via this function.
131 * This is for explicit dissection.
132 */
133
134 extern void delete_giop_user_module(giop_sub_dissector_t *sub, gchar *name,
135 gchar *module);
136
137
138 /*
139 * General CDR accessors start here. They are listed in alphabetical
140 * order. They may however, belong to 1 of 3 distinct CDR data types.
141 *
142 * - Primitive
143 * - OMG IDL Constructed Types
144 * - Pseudo Object Types
145 *
146 *
147 * Altough some of these look redundant, I have separated them
148 * out for all CDR types, to assist in auto generation of
149 * IDL dissectors later, see idl2wrs -- FS
150 *
151 */
152
153
154 /*
155 * Gets data of type any. This is encoded as a TypeCode
156 * followed by the encoded value.
157 *
158 * Data is added to tree directly if present.
159 */
160
161 WS_DLL_PUBLIC void get_CDR_any(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item,
162 gint *offset, gboolean stream_is_big_endian,
163 int boundary, MessageHeader * header);
164
165
166 /* Copy a 1 octet sequence from the tvbuff
167 * which represents a boolean value, and convert
168 * it to a boolean value.
169 * Offset is then incremented by 1, to indicate the 1 octet which
170 * has been processed.
171 */
172
173 WS_DLL_PUBLIC gboolean get_CDR_boolean(tvbuff_t *tvb, int *offset);
174
175
176 /* Copy a 1 octet sequence from the tvbuff
177 * which represents a char, and convert
178 * it to an char value.
179 * offset is then incremented by 1, to indicate the 1 octet which
180 * has been processed.
181 */
182
183 WS_DLL_PUBLIC guint8 get_CDR_char(tvbuff_t *tvb, int *offset);
184
185
186
187 /*
188 * Floating Point Data Type double IEEE 754-1985
189 *
190 * Copy an 8 octet sequence from the tvbuff
191 * which represents a double value, and convert
192 * it to a double value, taking into account byte order.
193 * offset is first incremented so that it falls on a proper alignment
194 * boundary for double values.
195 * offset is then incremented by 8, to indicate the 8 octets which
196 * have been processed.
197 */
198
199 WS_DLL_PUBLIC gdouble get_CDR_double(tvbuff_t *tvb, int *offset,
200 gboolean stream_is_big_endian, int boundary);
201
202
203 /* Copy a 4 octet sequence from the tvbuff
204 * which represents an enum value, and convert
205 * it to an enum value, taking into account byte order.
206 * offset is first incremented so that it falls on a proper alignment
207 * boundary for an enum (4)
208 * offset is then incremented by 4, to indicate the 4 octets which
209 * have been processed.
210 *
211 * Enum values are encoded as unsigned long.
212 */
213
214 WS_DLL_PUBLIC guint32 get_CDR_enum(tvbuff_t *tvb, int *offset,
215 gboolean stream_is_big_endian, int boundary);
216
217
218
219 /*
220 * Copy an octet sequence from the tvbuff
221 * which represents a Fixed point decimal type, and create a string representing
222 * a Fixed point decimal type. There are no alignment restrictions.
223 * Size and scale of fixed decimal type is determined by IDL.
224 *
225 * digits - IDL specified number of "digits" for this fixed type
226 * scale - IDL specified "scale" for this fixed type
227 *
228 *
229 * eg: typedef fixed <5,2> fixed_t;
230 * could represent numbers like 123.45, 789.12,
231 *
232 *
233 * As the fixed type could be any size, I will not try to fit it into our
234 * simple types like gdouble or glong etc. I will just create a string buffer holding
235 * a representation (after scale is applied), and with a decimal point or zero padding
236 * inserted at the right place if necessary. The string is null terminated
237 *
238 * so string may look like
239 *
240 *
241 * "+1.234" or "-3456.78" or "1234567309475760377365465897891" or "-2789000000" etc
242 *
243 * According to spec, digits <= 31
244 * and scale is positive (except for constants eg: 1000 has digit=1 and implied scale = -3)
245 * or <4,0> ?
246 *
247 */
248
249 WS_DLL_PUBLIC void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item,
250 gchar **seq, gint *offset, guint32 digits, gint32 scale);
251
252
253 /*
254 * Floating Point Data Type float IEEE 754-1985
255 *
256 * Copy a 4 octet sequence from the tvbuff
257 * which represents a float value, and convert
258 * it to a float value, taking into account byte order.
259 * offset is first incremented so that it falls on a proper alignment
260 * boundary for float values.
261 * offset is then incremented by 4, to indicate the 4 octets which
262 * have been processed.
263 */
264
265 WS_DLL_PUBLIC gfloat get_CDR_float(tvbuff_t *tvb, int *offset,
266 gboolean stream_is_big_endian, int boundary);
267
268
269 /*
270 * Decode an Interface type, and display it on the tree.
271 */
272
273 WS_DLL_PUBLIC void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo,
274 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
275
276
277 /* Copy a 4 octet sequence from the tvbuff
278 * which represents a signed long value, and convert
279 * it to an signed long vaule, taking into account byte order.
280 * offset is first incremented so that it falls on a proper alignment
281 * boundary for long values.
282 * offset is then incremented by 4, to indicate the 4 octets which
283 * have been processed.
284 */
285
286 WS_DLL_PUBLIC gint32 get_CDR_long(tvbuff_t *tvb, int *offset,
287 gboolean stream_is_big_endian, int boundary);
288
289
290
291 /* Copy a 16 octet sequence from the tvbuff
292 * which represents a long double value, and convert
293 * it to a long double value, taking into account byte order.
294 * offset is first incremented so that it falls on a proper alignment
295 * boundary for long double values.
296 * offset is then incremented by 16, to indicate the 16 octets which
297 * have been processed.
298 */
299
300 #ifdef G_HAVE_GLONG_DOUBLE
301
302 WS_DLL_PUBLIC glong_double get_CDR_long_double(tvbuff_t *tvb, int *offset,
303 gboolean stream_is_big_endian, int boundary);
304 #else
305
306 /* FIX -- Cast long double to gdouble until I figure this out -- FS*/
307
308 WS_DLL_PUBLIC gdouble get_CDR_long_double(tvbuff_t *tvb, int *offset,
309 gboolean stream_is_big_endian, int boundary);
310
311 #endif
312
313
314 /* Copy an 8 octet sequence from the tvbuff
315 * which represents a signed long long value, and convert
316 * it to a signed long long value, taking into account byte order.
317 * offset is first incremented so that it falls on a proper alignment
318 * boundary for long long values.
319 * offset is then incremented by 8, to indicate the 8 octets which
320 * have been processed.
321 */
322
323 WS_DLL_PUBLIC gint64 get_CDR_long_long(tvbuff_t *tvb, int *offset,
324 gboolean stream_is_big_endian, int boundary);
325
326 /*
327 * Decode an Object type, and display it on the tree.
328 */
329
330 WS_DLL_PUBLIC void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo,
331 proto_tree *tree, int *offset, gboolean stream_is_big_endian, int boundary);
332
333
334 /* Copy a 1 octet sequence from the tvbuff
335 * which represents a octet, and convert
336 * it to an octet value.
337 * offset is then incremented by 1, to indicate the 1 octet which
338 * has been processed.
339 */
340
341 WS_DLL_PUBLIC guint8 get_CDR_octet(tvbuff_t *tvb, int *offset);
342
343
344 /* Copy a sequence of octets from the tvbuff.
345 * Memory is allocated in packet pool and will be
346 * automatically freed once the packet dissection is finished.
347 * This function also increments offset by len.
348 */
349
350 WS_DLL_PUBLIC void get_CDR_octet_seq(tvbuff_t *tvb, const gchar **seq, int *offset, guint32 len);
351
352 /* Copy a 2 octet sequence from the tvbuff
353 * which represents a signed short value, and convert
354 * it to a signed short value, taking into account byte order.
355 * offset is first incremented so that it falls on a proper alignment
356 * boundary for short values.
357 * offset is then incremented by 2, to indicate the 2 octets which
358 * have been processed.
359 */
360
361 WS_DLL_PUBLIC gint16 get_CDR_short(tvbuff_t *tvb, int *offset,
362 gboolean stream_is_big_endian, int boundary);
363
364
365 extern void giop_add_CDR_string(proto_tree *tree, tvbuff_t *tvb, int *offset,
366 gboolean stream_is_big_endian, int boundary,
367 int hf);
368
369 /* Copy an octet sequence from the tvbuff
370 * which represents a string, and convert
371 * it to an string value, taking into account byte order.
372 * offset is first incremented so that it falls on a proper alignment
373 * boundary for string values. (begins with an unsigned long LI)
374 *
375 * String sequence is copied to a buffer "seq".
376 * Memory is allocated in packet pool and will be
377 * automatically freed once the packet dissection is finished.
378 * offset is then incremented , to indicate the octets which
379 * have been processed.
380 *
381 * returns number of octets in the sequence
382 *
383 * Note: This function only supports single byte encoding at the
384 * moment until I get a handle on multibyte encoding etc.
385 *
386 */
387
388 WS_DLL_PUBLIC guint32 get_CDR_string(tvbuff_t *tvb, const gchar **seq, int *offset,
389 gboolean stream_is_big_endian, int boundary);
390
391
392 /* Process a sequence of octets that represent the
393 * Pseudo Object Type "TypeCode". Typecodes are used for example,
394 * by "Any values".
395 * This function also increments offset to the correct position.
396 *
397 * It will parse the TypeCode and output data to the "tree" provided
398 * by the user
399 *
400 * It returns a guint32 representing a TCKind value.
401 */
402
403 WS_DLL_PUBLIC guint32 get_CDR_typeCode(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, gint *offset,
404 gboolean stream_is_big_endian, int boundary, MessageHeader * header );
405
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.
413 */
414
415 WS_DLL_PUBLIC guint32 get_CDR_ulong(tvbuff_t *tvb, int *offset,
416 gboolean stream_is_big_endian, int boundary);
417
418
419 /* Copy an 8 octet sequence from the tvbuff
420 * which represents an unsigned long long value, and convert
421 * it to an unsigned long 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 long values.
424 * offset is then incremented by 8, to indicate the 8 octets which
425 * have been processed.
426 */
427
428 WS_DLL_PUBLIC guint64 get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
429 gboolean stream_is_big_endian, int boundary);
430
431 /* Copy a 2 octet sequence from the tvbuff
432 * which represents an unsigned short value, and convert
433 * it to an unsigned short value, taking into account byte order.
434 * offset is first incremented so that it falls on a proper alignment
435 * boundary for unsigned short values.
436 * offset is then incremented by 2, to indicate the 2 octets which
437 * have been processed.
438 */
439
440 WS_DLL_PUBLIC guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset,
441 gboolean stream_is_big_endian, int boundary);
442
443
444 /* Copy a wchar from the tvbuff.
445 * Memory is allocated in packet pool and will be
446 * automatically freed once the packet dissection is finished.
447 * This function also increments offset according to
448 * the wchar size.
449 *
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.
453 *
454 * For GIOP 1.2 read size of wchar and the size
455 * octets. size is returned as a gint8.
456 *
457 * For both GIOP versions the wchar is returned
458 * as a printable string.
459 *
460 */
461
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.
468 */
469
470 /* The "decoding" is done according to CORBA chapter 15.
471 * Wchar is not supported for GIOP 1.0.
472 */
473
474 WS_DLL_PUBLIC gint get_CDR_wchar(tvbuff_t *tvb, const gchar **seq, int *offset,
475 MessageHeader * header);
476
477
478 /* Copy a wstring from the tvbuff.
479 * Memory is allocated in packet pool and will be
480 * automatically freed once the packet dissection is finished.
481 * This function also increments offset, according to
482 * wstring length. length is returned as guint32
483 */
484
485 /* NOTE: This is very primitive in that it just reads
486 * the wstring as a series of octets and returns them
487 * to the user. No translation is attempted based on
488 * byte orientation, nor on code set. I.e it only
489 * really reads past the wstring and increments the offset
490 * by the length of the octet sequence.
491 */
492
493 /* The "decoding" is done according to CORBA chapter 15.
494 * Wstring is not supported for GIOP 1.0.
495 */
496
497 WS_DLL_PUBLIC guint32 get_CDR_wstring(tvbuff_t *tvb, const gchar **seq, int *offset,
498 gboolean stream_is_big_endian, int boundary, MessageHeader * header);
499
500
501
502 /*
503 *
504 * End of get_CDR_xxx accessors.
505 *
506 */
507
508
509
510 /* Determine the byte order from the GIOP MessageHeader */
511
512 WS_DLL_PUBLIC gboolean is_big_endian (MessageHeader * header);
513
514 /*
515 * get_encap_info() for any encapsulation (eg:sequences)
516 * we come across. updates the new boundary and endianess
517 * and *offset, and returns the sequence length.
518 */
519
520 WS_DLL_PUBLIC guint32 get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, gint *offset,
521 gboolean old_stream_is_big_endian, guint32 old_boundary,
522 gboolean *new_stream_is_big_endian_ptr, guint32 *new_boundary_ptr );
523
524 /* Take in an array of char and create a new ephemeral string.
525 * Replace non-printable characters with periods.
526 *
527 * The array may contain \0's so don't use strdup
528 * The string is \0 terminated, and thus longer than
529 * the initial sequence.
530 */
531
532 WS_DLL_PUBLIC gchar * make_printable_string (const gchar *in, guint32 len);
533
534 /*
535 * Enums for TCkind
536 */
537
538 enum TCKind {
539 tk_null = 0,
540 tk_void,
541 tk_short,
542 tk_long,
543 tk_ushort,
544 tk_ulong,
545 tk_float,
546 tk_double,
547 tk_boolean,
548 tk_char,
549 tk_octet,
550 tk_any,
551 tk_TypeCode,
552 tk_Principal,
553 tk_objref,
554 tk_struct,
555 tk_union,
556 tk_enum,
557 tk_string,
558 tk_sequence,
559 tk_array,
560 tk_alias,
561 tk_except,
562 tk_longlong,
563 tk_ulonglong,
564 tk_longdouble,
565 tk_wchar,
566 tk_wstring,
567 tk_fixed,
568 tk_value,
569 tk_value_box,
570 tk_native,
571 tk_abstract_interface
572
573 /* - none - 0xffffffff TODO */
574 };
575
576 #define tk_none 0xffffffff
577
578 typedef enum TCKind TCKind_t;
579
580
581 /*
582 * ServiceId's for ServiceContextList
583 *
584 * Chapter 13 Corba 2.4.2
585 */
586
587 #define IOP_ServiceId_TransactionService 0
588 #define IOP_ServiceId_CodeSets 1
589 #define IOP_ServiceId_ChainBypassCheck 2
590 #define IOP_ServiceId_ChainBypassInfo 3
591 #define IOP_ServiceId_LogicalThreadId 4
592 #define IOP_ServiceId_BI_DIR_IIOP 5
593 #define IOP_ServiceId_SendingContextRunTime 6
594 #define IOP_ServiceId_INVOCATION_POLICIES 7
595 #define IOP_ServiceId_FORWARD_IDENTITY 8
596 #define IOP_ServiceId_UnknownExceptionInfo 9
597
598 /* Used for GIOP statistics */
599 typedef struct _giop_info_value_t {
600 guint32 framenum;
601 address *server_addr;
602 const gchar *client_host;
603 const gchar *service_host;
604 const gchar *giop_op;
605 const gchar *giop_resp;
606 time_t time_ticks;
607 guint time_ms;
608 gboolean first_pass;
609 } giop_info_value_t;
610
611
612 #define GIOP_TAP_NAME "giop"
613
614 #endif /* PACKET_GIOP_H */
giop_sub_handle
Definition: packet-giop.h:95
_packet_info
Definition: packet_info.h:44
_giop_info_value_t
Definition: packet-giop.h:599
tvbuff
Definition: tvbuff-int.h:35
MessageHeader
Definition: packet-giop.h:38
_proto_node
Definition: proto.h:759
_protocol
Definition: proto.c:312
_address
Definition: address.h:47
Version
Definition: packet-giop.h:26