Wireshark 4.5.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 <[email protected]>
4 *
5 * Based on CORBAv2.4.2 Chapter 15 GIOP Description.
6 *
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <[email protected]>
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
26typedef 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
38typedef 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
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
95typedef 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 */
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 an 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 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
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(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 an 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 packet pool and will be
368 * automatically freed once the packet dissection is finished.
369 * offset is then incremented , to indicate the octets which
370 * have been processed.
371 *
372 * returns number of octets in the sequence
373 *
374 * Note: This function only supports single byte encoding at the
375 * moment until I get a handle on multibyte encoding etc.
376 *
377 */
378
379WS_DLL_PUBLIC uint32_t get_CDR_string(tvbuff_t *tvb, const char **seq, int *offset,
380 bool stream_is_big_endian, int boundary);
381
382
383/* Process a sequence of octets that represent the
384 * Pseudo Object Type "TypeCode". Typecodes are used for example,
385 * by "Any values".
386 * This function also increments offset to the correct position.
387 *
388 * It will parse the TypeCode and output data to the "tree" provided
389 * by the user
390 *
391 * It returns a uint32_t representing a TCKind value.
392 */
393
394WS_DLL_PUBLIC uint32_t get_CDR_typeCode(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int *offset,
395 bool stream_is_big_endian, int boundary, MessageHeader * header );
396
397
398/* Copy a 4 octet sequence from the tvbuff
399 * which represents an unsigned long value, and convert
400 * it to an unsigned long value, taking into account byte order.
401 * offset is first incremented so that it falls on a proper alignment
402 * boundary for unsigned long values.
403 * offset is then incremented by 4, to indicate the 4 octets which
404 * have been processed.
405 */
406
407WS_DLL_PUBLIC uint32_t get_CDR_ulong(tvbuff_t *tvb, int *offset,
408 bool stream_is_big_endian, int boundary);
409
410
411/* Copy an 8 octet sequence from the tvbuff
412 * which represents an unsigned long long value, and convert
413 * it to an unsigned long long value, taking into account byte order.
414 * offset is first incremented so that it falls on a proper alignment
415 * boundary for unsigned long long values.
416 * offset is then incremented by 8, to indicate the 8 octets which
417 * have been processed.
418 */
419
420WS_DLL_PUBLIC uint64_t get_CDR_ulong_long(tvbuff_t *tvb, int *offset,
421 bool stream_is_big_endian, int boundary);
422
423/* Copy a 2 octet sequence from the tvbuff
424 * which represents an unsigned short value, and convert
425 * it to an unsigned short value, taking into account byte order.
426 * offset is first incremented so that it falls on a proper alignment
427 * boundary for unsigned short values.
428 * offset is then incremented by 2, to indicate the 2 octets which
429 * have been processed.
430 */
431
432WS_DLL_PUBLIC uint16_t get_CDR_ushort(tvbuff_t *tvb, int *offset,
433 bool stream_is_big_endian, int boundary);
434
435
436/* Copy a wchar from the tvbuff.
437 * This function also increments offset according to
438 * the wchar size.
439 *
440 * For GIOP 1.1 read 2 octets and return size -2. The
441 * negation means there is no size element in the packet
442 * and therefore no size to add to the tree.
443 *
444 * For GIOP 1.2 read size of wchar and the size
445 * octets. size is returned as a int8_t.
446 *
447 * For both GIOP versions the wchar is returned
448 * as a printable string.
449 *
450 */
451
452/* NOTE: This is very primitive in that it just reads
453 * the wchar as a series of octets and returns them
454 * to the user. No translation is attempted based on
455 * byte orientation, nor on code set. I.e it only
456 * really reads past the wchar and increments the offset
457 * by the length of the octet sequence.
458 */
459
460/* The "decoding" is done according to CORBA chapter 15.
461 * Wchar is not supported for GIOP 1.0.
462 */
463
464WS_DLL_PUBLIC int get_CDR_wchar(wmem_allocator_t *scope, tvbuff_t *tvb,
465 const char **seq, int *offset, MessageHeader * header);
466
467
468/* Copy a wstring from the tvbuff.
469 * This function also increments offset, according to
470 * wstring length. length is returned as uint32_t
471 */
472
473/* NOTE: This is very primitive in that it just reads
474 * the wstring as a series of octets and returns them
475 * to the user. No translation is attempted based on
476 * byte orientation, nor on code set. I.e it only
477 * really reads past the wstring and increments the offset
478 * by the length of the octet sequence.
479 */
480
481/* The "decoding" is done according to CORBA chapter 15.
482 * Wstring is not supported for GIOP 1.0.
483 */
484
485WS_DLL_PUBLIC uint32_t get_CDR_wstring(wmem_allocator_t *scope, tvbuff_t *tvb,
486 const char **seq, int *offset, bool stream_is_big_endian, int boundary,
487 MessageHeader * header);
488
489
490
491/*
492 *
493 * End of get_CDR_xxx accessors.
494 *
495 */
496
497
498
499/* Determine the byte order from the GIOP MessageHeader */
500
501WS_DLL_PUBLIC bool is_big_endian (MessageHeader * header);
502
503/*
504 * get_encap_info() for any encapsulation (eg:sequences)
505 * we come across. updates the new boundary and endianess
506 * and *offset, and returns the sequence length.
507 */
508
509WS_DLL_PUBLIC uint32_t get_CDR_encap_info(tvbuff_t *tvb, proto_tree *tree, int *offset,
510 bool old_stream_is_big_endian, uint32_t old_boundary,
511 bool *new_stream_is_big_endian_ptr, uint32_t *new_boundary_ptr );
512
513/* Take in an array of uint8_t and create a new ephemeral string.
514 * Replace non-printable characters with periods.
515 *
516 * The array may contain \0's so don't use strdup
517 * The string is \0 terminated, and thus longer than
518 * the initial sequence.
519 */
520
521WS_DLL_PUBLIC char * make_printable_string (wmem_allocator_t *scope, const uint8_t *in, uint32_t len);
522
523/*
524 * Enums for TCkind
525 */
526
527enum TCKind {
528 tk_null = 0,
529 tk_void,
530 tk_short,
531 tk_long,
532 tk_ushort,
533 tk_ulong,
534 tk_float,
535 tk_double,
536 tk_boolean,
537 tk_char,
538 tk_octet,
539 tk_any,
540 tk_TypeCode,
541 tk_Principal,
542 tk_objref,
543 tk_struct,
544 tk_union,
545 tk_enum,
546 tk_string,
547 tk_sequence,
548 tk_array,
549 tk_alias,
550 tk_except,
551 tk_longlong,
552 tk_ulonglong,
553 tk_longdouble,
554 tk_wchar,
555 tk_wstring,
556 tk_fixed,
557 tk_value,
558 tk_value_box,
559 tk_native,
560 tk_abstract_interface
561
562 /* - none - 0xffffffff TODO */
563};
564
565#define tk_none 0xffffffff
566
567typedef enum TCKind TCKind_t;
568
569
570/*
571 * ServiceId's for ServiceContextList
572 *
573 * Chapter 13 Corba 2.4.2
574 */
575
576#define IOP_ServiceId_TransactionService 0
577#define IOP_ServiceId_CodeSets 1
578#define IOP_ServiceId_ChainBypassCheck 2
579#define IOP_ServiceId_ChainBypassInfo 3
580#define IOP_ServiceId_LogicalThreadId 4
581#define IOP_ServiceId_BI_DIR_IIOP 5
582#define IOP_ServiceId_SendingContextRunTime 6
583#define IOP_ServiceId_INVOCATION_POLICIES 7
584#define IOP_ServiceId_FORWARD_IDENTITY 8
585#define IOP_ServiceId_UnknownExceptionInfo 9
586
587/* Used for GIOP statistics */
588typedef struct _giop_info_value_t {
589 uint32_t framenum;
590 address *server_addr;
591 const char *client_host;
592 const char *service_host;
593 const char *giop_op;
594 const char *giop_resp;
595 time_t time_ticks;
596 unsigned time_ms;
597 bool first_pass;
599
600
601#define GIOP_TAP_NAME "giop"
602
603#endif /* PACKET_GIOP_H */
Definition address.h:56
Definition packet-giop.h:588
Definition packet_info.h:43
Definition proto.h:901
Definition proto.c:375
Definition wmem_allocator.h:27
Definition packet-giop.h:38
Definition packet-giop.h:26
Definition packet-giop.h:95
Definition tvbuff-int.h:35