| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
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 uint8_t major;
28 uint8_t 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 uint8_t magic[4];
43 Version GIOP_version;
44 uint8_t flags; /* byte_order in 1.0 */
45 uint8_t message_type;
46 uint32_t message_size;
47
48 /* MSG dependent data */
49
50 uint32_t req_id; /* request id in MSG */
51 uint32_t rep_status; /* reply status in MSG if available */
52 char *exception_id; /* exception string if a USER EXCEPTION occurs */
53
54} MessageHeader;
55
56typedef 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
75typedef 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
88typedef bool (giop_sub_dissector_t)(tvbuff_t *, packet_info *, proto_tree *, int *,
89 MessageHeader *, const char * , char *);
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 char *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
103extern bool 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
110WS_DLL_PUBLIC void register_giop_user(giop_sub_dissector_t *sub, const char *name,
111 int sub_proto);
112
113/*
114 * GIOP Users remove interest via this function.
115 * This is for heuristic dissection
116 */
117
118extern void delete_giop_user(giop_sub_dissector_t *sub, char *name);
119
120
121/*
122 * GIOP Users register their module and interface names via this function.
123 * This is for explicit dissection.
124 */
125
126WS_DLL_PUBLIC void register_giop_user_module(giop_sub_dissector_t *sub, const char *name,
127 const char *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
134extern void delete_giop_user_module(giop_sub_dissector_t *sub, char *name,
135 char *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 * Although 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
161WS_DLL_PUBLIC void get_CDR_any(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item,
162 int *offset, bool 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
173WS_DLL_PUBLIC bool 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 a char value.
179 * offset is then incremented by 1, to indicate the 1 octet which
180 * has been processed.
181 */
182
183WS_DLL_PUBLIC uint8_t 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
199WS_DLL_PUBLIC double get_CDR_double(tvbuff_t *tvb, int *offset,
200 bool 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
214WS_DLL_PUBLIC uint32_t get_CDR_enum(tvbuff_t *tvb, int *offset,
215 bool 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 double or long 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
249WS_DLL_PUBLIC void get_CDR_fixed(tvbuff_t *tvb, packet_info *pinfo, proto_item *item,
250 char **seq, int *offset, uint32_t digits, int32_t 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
265WS_DLL_PUBLIC float get_CDR_float(tvbuff_t *tvb, int *offset,
266 bool stream_is_big_endian, int boundary);
267
268
269/*
270 * Decode an Interface type, and display it on the tree.
271 */
272
273WS_DLL_PUBLIC void get_CDR_interface(tvbuff_t *tvb, packet_info *pinfo,
274 proto_tree *tree, int *offset, bool 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 a signed long value, 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
286WS_DLL_PUBLIC int32_t get_CDR_long(tvbuff_t *tvb, int *offset,
287 bool 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/* FIX -- Cast long double to double until I figure this out -- FS*/
301
302WS_DLL_PUBLIC double get_CDR_long_double(tvbuff_t *tvb, int *offset,
303 bool stream_is_big_endian, int boundary);
304
305
306
307/* Copy an 8 octet sequence from the tvbuff
308 * which represents a signed long long value, and convert
309 * it to a signed long long value, taking into account byte order.
310 * offset is first incremented so that it falls on a proper alignment
311 * boundary for long long values.
312 * offset is then incremented by 8, to indicate the 8 octets which
313 * have been processed.
314 */
315
316WS_DLL_PUBLIC int64_t get_CDR_long_long(tvbuff_t *tvb, int *offset,
317 bool stream_is_big_endian, int boundary);
318
319/*
320 * Decode an Object type, and display it on the tree.
321 */
322
323WS_DLL_PUBLIC void get_CDR_object(tvbuff_t *tvb, packet_info *pinfo,
324 proto_tree *tree, int *offset, bool stream_is_big_endian, int boundary);
325
326
327/* Copy a 1 octet sequence from the tvbuff
328 * which represents a octet, and convert
329 * it to an octet value.
330 * offset is then incremented by 1, to indicate the 1 octet which
331 * has been processed.
332 */
333
334WS_DLL_PUBLIC uint8_t get_CDR_octet(tvbuff_t *tvb, int *offset);
335
336
337/* Copy a sequence of octets from the tvbuff.
338 * This function also increments offset by len.
339 */
340
341WS_DLL_PUBLIC void get_CDR_octet_seq(wmem_allocator_t *scope, tvbuff_t *tvb, const uint8_t **seq, int *offset, uint32_t len);
342
343/* Copy a 2 octet sequence from the tvbuff
344 * which represents a signed short value, and convert
345 * it to a signed short value, taking into account byte order.
346 * offset is first incremented so that it falls on a proper alignment
347 * boundary for short values.
348 * offset is then incremented by 2, to indicate the 2 octets which
349 * have been processed.
350 */
351
352WS_DLL_PUBLIC int16_t get_CDR_short(tvbuff_t *tvb, int *offset,
353 bool stream_is_big_endian, int boundary);
354
355
356WS_DLL_PUBLIC void giop_add_CDR_string(wmem_allocator_t* scope, proto_tree *tree, tvbuff_t *tvb, int *offset,
357 bool stream_is_big_endian, int boundary,
358 int hf);
359
360/* Copy an octet sequence from the tvbuff
361 * which represents a string, and convert
362 * it to a string value, taking into account byte order.
363 * offset is first incremented so that it falls on a proper alignment
364 * boundary for string values. (begins with an unsigned long LI)
365 *
366 * String sequence is copied to a buffer "seq".
367 * Memory is allocated in scope pool and will be automatically freed.
368 * offset is then incremented, to indicate the octets which
369 * have been processed.
370 *
371 * returns number of octets in the sequence
372 *
373 * Note: This function only supports single byte encoding at the
374 * moment until I get a handle on multibyte encoding etc.
375 *
376 */
377
378WS_DLL_PUBLIC uint32_t get_CDR_string(wmem_allocator_t* scope, tvbuff_t *tvb, const char **seq, int *offset,
379 bool stream_is_big_endian, int boundary);
380
381
382/* Process a sequence of octets that represent the
383 * Pseudo Object Type "TypeCode". Typecodes are used for example,
384 * by "Any values".
385 * This function also increments offset to the correct position.
386 *
387 * It will parse the TypeCode and output data to the "tree" provided
388 * by the user
389 *
390 * It returns a uint32_t representing a TCKind value.
391 */
392
393WS_DLL_PUBLIC uint32_t get_CDR_typeCode(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int *offset,
394 bool stream_is_big_endian, int boundary, MessageHeader * header );
395
396
397/* Copy a 4 octet sequence from the tvbuff
398 * which represents an unsigned long value, and convert
399 * it to an unsigned long value, taking into account byte order.
400 * offset is first incremented so that it falls on a proper alignment
401 * boundary for unsigned long values.
402 * offset is then incremented by 4, to indicate the 4 octets which
403 * have been processed.
404 */
405
406WS_DLL_PUBLIC uint32_t get_CDR_ulong(tvbuff_t *tvb, int *offset,
407 bool stream_is_big_endian, int boundary);
408
409
410/* Copy an 8 octet sequence from the tvbuff
411 * which represents an unsigned long long value, and convert
412 * it to an unsigned long long value, taking into account byte order.
413 * offset is first incremented so that it falls on a proper alignment
414 * boundary for unsigned long long values.
415 * offset is then incremented by 8, to indicate the 8 octets which
416 * have been processed.
417 */
418
419WS_DLL_PUBLIC uint64_t get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
420 bool stream_is_big_endian, int boundary);
421
422/* Copy a 2 octet sequence from the tvbuff
423 * which represents an unsigned short value, and convert
424 * it to an unsigned short value, taking into account byte order.
425 * offset is first incremented so that it falls on a proper alignment
426 * boundary for unsigned short values.
427 * offset is then incremented by 2, to indicate the 2 octets which
428 * have been processed.
429 */
430
431WS_DLL_PUBLIC uint16_t get_CDR_ushort(tvbuff_t *tvb, int *offset,
432 bool stream_is_big_endian, int boundary);
433
434
435/* Copy a wchar from the tvbuff.
436 * This function also increments offset according to
437 * the wchar size.
438 *
439 * For GIOP 1.1 read 2 octets and return size -2. The
440 * negation means there is no size element in the packet
441 * and therefore no size to add to the tree.
442 *
443 * For GIOP 1.2 read size of wchar and the size
444 * octets. size is returned as a int8_t.
445 *
446 * For both GIOP versions the wchar is returned
447 * as a printable string.
448 *
449 */
450
451/* NOTE: This is very primitive in that it just reads
452 * the wchar as a series of octets and returns them
453 * to the user. No translation is attempted based on
454 * byte orientation, nor on code set. I.e it only
455 * really reads past the wchar and increments the offset
456 * by the length of the octet sequence.
457 */
458
459/* The "decoding" is done according to CORBA chapter 15.
460 * Wchar is not supported for GIOP 1.0.
461 */
462
463WS_DLL_PUBLIC int get_CDR_wchar(wmem_allocator_t *scope, tvbuff_t *tvb,
464 const char **seq, int *offset, MessageHeader * header);
465
466
467/* Copy a wstring from the tvbuff.
468 * This function also increments offset, according to
469 * wstring length. length is returned as uint32_t
470 */
471
472/* NOTE: This is very primitive in that it just reads
473 * the wstring as a series of octets and returns them
474 * to the user. No translation is attempted based on
475 * byte orientation, nor on code set. I.e it only
476 * really reads past the wstring and increments the offset
477 * by the length of the octet sequence.
478 */
479
480/* The "decoding" is done according to CORBA chapter 15.
481 * Wstring is not supported for GIOP 1.0.
482 */
483
484WS_DLL_PUBLIC uint32_t get_CDR_wstring(wmem_allocator_t *scope, tvbuff_t *tvb,
485 const char **seq, int *offset, bool stream_is_big_endian, int boundary,
486 MessageHeader * header);
487
488
489
490/*
491 *
492 * End of get_CDR_xxx accessors.
493 *
494 */
495
496
497
498/* Determine the byte order from the GIOP MessageHeader */
499
500WS_DLL_PUBLIC bool is_big_endian (MessageHeader * header);
501
502/*
503 * get_encap_info() for any encapsulation (eg:sequences)
504 * we come across. updates the new boundary and endianness
505 * and *offset, and returns the sequence length.
506 */
507
508WS_DLL_PUBLIC uint32_t get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, int *offset,
509 bool old_stream_is_big_endian, uint32_t old_boundary,
510 bool *new_stream_is_big_endian_ptr, uint32_t *new_boundary_ptr );
511
512/* Take in an array of uint8_t and create a new ephemeral string.
513 * Replace non-printable characters with periods.
514 *
515 * The array may contain \0's so don't use strdup
516 * The string is \0 terminated, and thus longer than
517 * the initial sequence.
518 */
519
520WS_DLL_PUBLIC char * make_printable_string (wmem_allocator_t *scope, const uint8_t *in, uint32_t len);
521
522/*
523 * Enums for TCkind
524 */
525
526enum TCKind {
527 tk_null = 0,
528 tk_void,
529 tk_short,
530 tk_long,
531 tk_ushort,
532 tk_ulong,
533 tk_float,
534 tk_double,
535 tk_boolean,
536 tk_char,
537 tk_octet,
538 tk_any,
539 tk_TypeCode,
540 tk_Principal,
541 tk_objref,
542 tk_struct,
543 tk_union,
544 tk_enum,
545 tk_string,
546 tk_sequence,
547 tk_array,
548 tk_alias,
549 tk_except,
550 tk_longlong,
551 tk_ulonglong,
552 tk_longdouble,
553 tk_wchar,
554 tk_wstring,
555 tk_fixed,
556 tk_value,
557 tk_value_box,
558 tk_native,
559 tk_abstract_interface
560
561 /* - none - 0xffffffff TODO */
562};
563
564#define tk_none 0xffffffff
565
566typedef enum TCKind TCKind_t;
567
568
569/*
570 * ServiceId's for ServiceContextList
571 *
572 * Chapter 13 Corba 2.4.2
573 */
574
575#define IOP_ServiceId_TransactionService 0
576#define IOP_ServiceId_CodeSets 1
577#define IOP_ServiceId_ChainBypassCheck 2
578#define IOP_ServiceId_ChainBypassInfo 3
579#define IOP_ServiceId_LogicalThreadId 4
580#define IOP_ServiceId_BI_DIR_IIOP 5
581#define IOP_ServiceId_SendingContextRunTime 6
582#define IOP_ServiceId_INVOCATION_POLICIES 7
583#define IOP_ServiceId_FORWARD_IDENTITY 8
584#define IOP_ServiceId_UnknownExceptionInfo 9
585
586/* Used for GIOP statistics */
587 typedef struct _giop_info_value_t {
588 uint32_t framenum;
589 address *server_addr;
590 const char *client_host;
591 const char *service_host;
592 const char *giop_op;
593 const char *giop_resp;
594 time_t time_ticks;
595 unsigned time_ms;
596 bool first_pass;
597} giop_info_value_t;
598
599
600#define GIOP_TAP_NAME "giop"
601
602#endif /* PACKET_GIOP_H */
_address
Definition address.h:58
_giop_info_value_t
Definition packet-giop.h:587
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_protocol
Definition proto.c:381
_wmem_allocator_t
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
MessageHeader
Definition packet-giop.h:38
Version
Definition packet-giop.h:26
giop_sub_handle
Definition packet-giop.h:95
tvbuff
Definition tvbuff-int.h:35