2 * Definitions for protocol display
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
13 The protocol tree related functions.<BR>
14 A protocol tree will hold all necessary data to display the whole dissected packet.
15 Creating a protocol tree is done in a two stage process:
16 A static part at program startup, and a dynamic part when the dissection with the real packet data is done.<BR>
17 The "static" information is provided by creating a hf_register_info hf[] array, and register it using the
18 proto_register_field_array() function. This is usually done at dissector registering.<BR>
19 The "dynamic" information is added to the protocol tree by calling one of the proto_tree_add_...() functions,
20 e.g. proto_tree_add_bytes().
30 #include <epan/wmem/wmem.h>
33 #include "wsutil/nstime.h"
36 #include "value_string.h"
38 #include "packet_info.h"
39 #include "ftypes/ftypes.h"
41 #include "ws_symbol_export.h"
42 #include "ws_attributes.h"
44 #include "wsutil/plugins.h"
49 #endif /* __cplusplus */
51 /** @defgroup prototree The Protocol Tree
53 * Dissectors use proto_tree_add_* to add items to the protocol tree. In
54 * most cases you'll want to use proto_tree_add_item().
59 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
60 WS_DLL_PUBLIC int hf_text_only;
62 /** the maximum length of a protocol field string representation */
63 #define ITEM_LABEL_LENGTH 240
65 #define ITEM_LABEL_UNKNOWN_STR "Unknown"
69 /* Type-check that 'x' is compatible with 'type', should give compiler warnings otherwise. */
70 #define cast_same(type, x) (0 ? (type)0 : (x))
72 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
73 #define VALS(x) (cast_same(const struct _value_string*, (x)))
75 /** Make a const val64_string[] look like a _val64_string pointer, used to set header_field_info.strings */
76 #define VALS64(x) (cast_same(const struct _val64_string*, (x)))
78 /** Something to satisfy checkAPIs when you have a pointer to a value_string_ext (e.g., one built with value_string_ext_new()) */
79 #define VALS_EXT_PTR(x) (cast_same(value_string_ext*, (x)))
81 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
82 #define TFS(x) (cast_same(const struct true_false_string*, (x)))
84 typedef void (*custom_fmt_func_t)(gchar *, guint32);
86 typedef void (*custom_fmt_func_64_t)(gchar *, guint64);
88 /** Make a custom format function pointer look like a void pointer. Used to set header_field_info.strings.
90 * We cast to gsize first, which 1) is guaranteed to be wide enough to
91 * hold a pointer and 2) lets us side-step warnings about casting function
92 * pointers to 'void *'. This violates ISO C but should be fine on POSIX
95 #define CF_FUNC(x) ((const void *) (gsize) (x))
97 /** Make a const range_string[] look like a _range_string pointer, used to set
98 * header_field_info.strings */
99 #define RVALS(x) (cast_same(const struct _range_string*, (x)))
101 /** Cast a ft_framenum_type_t, used to set header_field_info.strings */
102 #define FRAMENUM_TYPE(x) GINT_TO_POINTER(x)
106 /** Structure for information about a protocol */
107 typedef struct _protocol protocol_t;
109 /** Function used for reporting errors in dissectors; it throws a
110 * DissectorError exception, with a string generated from the format
111 * and arguments to the format, as the message for the exception, so
112 * that it can show up in the Info column and the protocol tree.
114 * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
115 * it will call abort(), instead, to make it easier to get a stack trace.
117 * @param format format string to use for the message
119 WS_DLL_PUBLIC WS_NORETURN
120 void proto_report_dissector_bug(const char *format, ...)
123 #define REPORT_DISSECTOR_BUG(...) \
124 proto_report_dissector_bug(__VA_ARGS__)
126 /** Macro used to provide a hint to static analysis tools.
127 * (Currently only Visual C++.)
130 /* XXX - Is there a way to say "quit checking at this point"? */
131 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
132 ; __analysis_assume(expression);
134 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
137 /** Macro used for assertions in dissectors; it doesn't abort, it just
138 * throws a DissectorError exception, with the assertion failure
139 * message as a parameter, so that it can show up in the protocol tree.
141 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
142 * conditions that shouldn't happen). It should NOT be used for showing
143 * that a packet is malformed. For that, use expert_infos instead.
145 * @param s expression to test in the assertion
148 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
150 #define __DISSECTOR_ASSERT(expression, file, lineno) \
151 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"%s\"", \
152 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression)))
154 #define __DISSECTOR_ASSERT_HINT(expression, file, lineno, hint) \
155 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"%s\" (%s)", \
156 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression), hint))
158 #define DISSECTOR_ASSERT(expression) \
159 ((void) ((expression) ? (void)0 : \
160 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
161 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
164 * Same as DISSECTOR_ASSERT(), but takes an extra 'hint' parameter that
165 * can be used to provide information as to why the assertion might fail.
167 * @param expression expression to test in the assertion
168 * @param hint message providing extra information
170 #define DISSECTOR_ASSERT_HINT(expression, hint) \
171 ((void) ((expression) ? (void)0 : \
172 __DISSECTOR_ASSERT_HINT (expression, __FILE__, __LINE__, hint))) \
173 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
176 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
177 * as the assert handling of GTK/GLib is currently not very helpful */
178 #define DISSECTOR_ASSERT(expression) \
179 { if(!(expression)) _asm { int 3}; }
182 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
183 * unconditionally, much like GLIB's g_assert_not_reached works.
185 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
186 * conditions that shouldn't happen). It should NOT be used for showing
187 * that a packet is malformed. For that, use expert_infos instead.
190 #define DISSECTOR_ASSERT_NOT_REACHED() \
191 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
194 /** Compare two integers.
196 * This is functionally the same as `DISSECTOR_ASSERT(a op b)` except that it
197 * will display the values of a and b upon failure.
199 * DISSECTOR_ASSERT_CMPINT(a, ==, b);
200 * DISSECTOR_ASSERT_CMPINT(min, <=, max);
202 * This function can currently compare values that fit inside a gint64.
204 * WARNING: The number of times the arguments are evaluated is undefined. Do
205 * not use expressions with side effects as arguments.
207 * @param a The first integer.
208 * @param op Any binary operator.
209 * @param b The second integer.
210 * @param type the type operator
211 * @param fmt the fmt operator
213 #define __DISSECTOR_ASSERT_CMPINT(a, op, b, type, fmt) \
214 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion " #a " " #op " " #b " (" fmt " " #op " " fmt ")", \
215 __FILE__, __LINE__, (type)a, (type)b))
217 #define DISSECTOR_ASSERT_CMPINT(a, op, b) \
218 ((void) ((a op b) ? (void)0 : \
219 __DISSECTOR_ASSERT_CMPINT (a, op, b, gint64, "%" G_GINT64_MODIFIER "d"))) \
220 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
222 /** Like DISSECTOR_ASSERT_CMPINT() except the arguments are treated as
225 * This function can currently compare values that fit inside a guint64.
227 #define DISSECTOR_ASSERT_CMPUINT(a, op, b) \
228 ((void) ((a op b) ? (void)0 : \
229 __DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "%" G_GINT64_MODIFIER "u"))) \
230 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
232 /** Like DISSECTOR_ASSERT_CMPUINT() except the values are displayed in
233 * hexadecimal upon assertion failure.
235 #define DISSECTOR_ASSERT_CMPUINTHEX(a, op, b) \
236 ((void) ((a op b) ? (void)0 : \
237 __DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "0x%" G_GINT64_MODIFIER "X"))) \
238 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
241 * This is similar to DISSECTOR_ASSERT(hfinfo->type == type) except that
242 * it will report the name of the field with the wrong type as well as
245 * @param hfinfo The hfinfo for the field being tested
246 * @param type The type it's expected to have
248 #define __DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
249 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type "#t, \
250 __FILE__, __LINE__, (hfinfo)->abbrev))
252 #define DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
253 ((void) (((hfinfo)->type == t) ? (void)0 : \
254 __DISSECTOR_ASSERT_FIELD_TYPE ((hfinfo), t))) \
255 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == t)
257 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hfinfo) \
258 ((void) ((IS_FT_INT((hfinfo)->type) || \
259 IS_FT_UINT((hfinfo)->type)) ? (void)0 : \
260 REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_CHAR or an FT_{U}INTn type", \
261 __FILE__, __LINE__, (hfinfo)->abbrev))) \
262 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(IS_FT_INT((hfinfo)->type) || \
263 IS_FT_UINT((hfinfo)->type))
265 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
266 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_STRING, FT_STRINGZ, or FT_STRINGZPAD", \
267 __FILE__, __LINE__, (hfinfo)->abbrev))
269 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
270 ((void) (((hfinfo)->type == FT_STRING || (hfinfo)->type == FT_STRINGZ || \
271 (hfinfo)->type == FT_STRINGZPAD) ? (void)0 : \
272 __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING ((hfinfo)))) \
273 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == FT_STRING || \
274 (hfinfo)->type == FT_STRINGZ || \
275 (hfinfo)->type == FT_STRINGZPAD)
277 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
278 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_ABSOLUTE_TIME or FT_RELATIVE_TIME", \
279 __FILE__, __LINE__, (hfinfo)->abbrev))
281 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
282 ((void) (((hfinfo)->type == FT_ABSOLUTE_TIME || \
283 (hfinfo)->type == FT_RELATIVE_TIME) ? (void)0 : \
284 __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME ((hfinfo)))) \
285 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == FT_ABSOLUTE_TIME || \
286 (hfinfo)->type == FT_RELATIVE_TIME)
289 * The encoding of a field of a particular type may involve more
290 * than just whether it's big-endian or little-endian and its size.
292 * For integral values, that's it, as 99.9999999999999% of the machines
293 * out there are 2's complement binary machines with 8-bit bytes,
294 * so the protocols out there expect that and, for example, any Unisys
295 * 2200 series machines out there just have to translate between 2's
296 * complement and 1's complement (and nobody's put any IBM 709x's on
297 * any networks lately :-)).
301 * for floating-point numbers, in addition to IEEE decimal
302 * floating-point, there's also IBM System/3x0 and PDP-11/VAX
303 * floating-point - most protocols use IEEE binary, but DCE RPC
304 * can use other formats if that's what the sending host uses;
306 * for character strings, there are various character encodings
307 * (various ISO 646 sets, ISO 8859/x, various other national
308 * standards, various DOS and Windows encodings, various Mac
309 * encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
312 * for absolute times, there's UNIX time_t, UNIX time_t followed
313 * by 32-bit microseconds, UNIX time_t followed by 32-bit
314 * nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
316 * We might also, in the future, want to allow a field specifier to
317 * indicate the encoding of the field, or at least its default
318 * encoding, as most fields in most protocols always use the
319 * same encoding (although that's not true of all fields, so we
320 * still need to be able to specify that at run time).
322 * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
323 * bit flags, to be combined, in the future, with other information
324 * to specify the encoding in the last argument to
325 * proto_tree_add_item(), and possibly to specify in a field
326 * definition (e.g., ORed in with the type value).
328 * Currently, proto_tree_add_item() treats its last argument as a
329 * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
330 * the field is little-endian - and other code in epan/proto.c does
331 * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and
332 * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
333 * so that we could put a field type and/or a value such as a character
334 * encoding in the lower bits.
336 #define ENC_BIG_ENDIAN 0x00000000
337 #define ENC_LITTLE_ENDIAN 0x80000000
339 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
340 #define ENC_HOST_ENDIAN ENC_LITTLE_ENDIAN
342 #define ENC_HOST_ENDIAN ENC_BIG_ENDIAN
346 * Historically FT_TIMEs were only timespecs; the only question was whether
347 * they were stored in big- or little-endian format.
349 * For backwards compatibility, we interpret an encoding of 1 as meaning
350 * "little-endian timespec", so that passing TRUE is interpreted as that.
354 * ENC_TIME_SECS_NSECS - 8, 12, or 16 bytes. For 8 bytes, the first 4
355 * bytes are seconds and the next 4 bytes are nanoseconds; for 12 bytes,
356 * the first 8 bytes are seconds and the next 4 bytes are nanoseconds;
357 * for 16 bytes, the first 8 bytes are seconds and the next 8 bytes are
358 * nanoseconds. If the time is absolute, the seconds are seconds since
359 * the UN*X epoch (1970-01-01 00:00:00 UTC). (I.e., a UN*X struct
360 * timespec with a 4-byte or 8-byte time_t or a structure with an
361 * 8-byte time_t and an 8-byte nanoseconds field.)
363 * ENC_TIME_NTP - 8 bytes; the first 4 bytes are seconds since the NTP
364 * epoch (1901-01-01 00:00:00 GMT) and the next 4 bytes are 1/2^32's of
365 * a second since that second. (I.e., a 64-bit count of 1/2^32's of a
366 * second since the NTP epoch, with the upper 32 bits first and the
367 * lower 32 bits second, even when little-endian.)
369 * ENC_TIME_TOD - 8 bytes, as a count of microseconds since the System/3x0
370 * and z/Architecture epoch (1900-01-01 00:00:00 GMT).
372 * ENC_TIME_RTPS - 8 bytes; the first 4 bytes are seconds since the UN*X
373 * epoch and the next 4 bytes are are 1/2^32's of a second since that
374 * second. (I.e., it's the offspring of a mating between UN*X time and
375 * NTP time.) It's used by the Object Management Group's Real-Time
376 * Publish-Subscribe Wire Protocol for the Data Distribution Service.
378 * ENC_TIME_SECS_USECS - 8 bytes; the first 4 bytes are seconds and the
379 * next 4 bytes are microseconds. If the time is absolute, the seconds
380 * are seconds since the UN*X epoch. (I.e., a UN*X struct timeval with
383 * ENC_TIME_SECS - 4 to 8 bytes, representing a value in seconds.
384 * If the time is absolute, it's seconds since the UN*X epoch.
386 * ENC_TIME_MSECS - 6 to 8 bytes, representing a value in milliseconds.
387 * If the time is absolute, it's milliseconds since the UN*X epoch.
389 * ENC_TIME_SECS_NTP - 4 bytes, representing a count of seconds since
390 * the NTP epoch. (I.e., seconds since the NTP epoch.)
392 * ENC_TIME_RFC_3971 - 8 bytes, representing a count of 1/64ths of a
393 * second since the UN*X epoch; see section 5.3.1 "Timestamp Option"
396 * ENC_TIME_MSEC_NTP - 4-8 bytes, representing a count of milliseconds since
397 * the NTP epoch. (I.e., milliseconds since the NTP epoch.)
399 * The backwards-compatibility names are defined as hex numbers so that
400 * the script to generate init.lua will add them as global variables,
401 * along with the new names.
403 #define ENC_TIME_SECS_NSECS 0x00000000
404 #define ENC_TIME_TIMESPEC 0x00000000 /* for backwards source compatibility */
405 #define ENC_TIME_NTP 0x00000002
406 #define ENC_TIME_TOD 0x00000004
407 #define ENC_TIME_RTPS 0x00000008
408 #define ENC_TIME_NTP_BASE_ZERO 0x00000008 /* for backwards source compatibility */
409 #define ENC_TIME_SECS_USECS 0x00000010
410 #define ENC_TIME_TIMEVAL 0x00000010 /* for backwards source compatibility */
411 #define ENC_TIME_SECS 0x00000012
412 #define ENC_TIME_MSECS 0x00000014
413 #define ENC_TIME_SECS_NTP 0x00000018
414 #define ENC_TIME_RFC_3971 0x00000020
415 #define ENC_TIME_MSEC_NTP 0x00000022
418 * Historically, the only place the representation mattered for strings
419 * was with FT_UINT_STRINGs, where we had FALSE for the string length
420 * being big-endian and TRUE for it being little-endian.
422 * We now have encoding values for the character encoding. The encoding
423 * values are encoded in all but the top bit (which is the byte-order
424 * bit, required for FT_UINT_STRING and for UCS-2 and UTF-16 strings)
425 * and the bottom bit (which we ignore for now so that programs that
426 * pass TRUE for the encoding just do ASCII). (The encodings are given
427 * directly as even numbers in hex, so that make-init-lua.pl can just
428 * turn them into numbers for use in init.lua.)
430 * We don't yet process ASCII and UTF-8 differently. Ultimately, for
431 * ASCII, all bytes with the 8th bit set should be mapped to some "this
432 * is not a valid character" code point, as ENC_ASCII should mean "this
433 * is ASCII, not some extended variant thereof". We should also map
434 * 0x00 to that as well - null-terminated and null-padded strings
435 * never have NULs in them, but counted strings might. (Either that,
436 * or the values for strings should be counted, not null-terminated.)
437 * For UTF-8, invalid UTF-8 sequences should be mapped to the same
440 * For display, perhaps we should also map control characters to the
441 * Unicode glyphs showing the name of the control character in small
442 * caps, diagonally. (Unfortunately, those only exist for C0, not C1.)
444 #define ENC_CHARENCODING_MASK 0x7FFFFFFE /* mask out byte-order bits */
445 #define ENC_ASCII 0x00000000
446 #define ENC_UTF_8 0x00000002
447 #define ENC_UTF_16 0x00000004
448 #define ENC_UCS_2 0x00000006
449 #define ENC_UCS_4 0x00000008
450 #define ENC_ISO_8859_1 0x0000000A
451 #define ENC_ISO_8859_2 0x0000000C
452 #define ENC_ISO_8859_3 0x0000000E
453 #define ENC_ISO_8859_4 0x00000010
454 #define ENC_ISO_8859_5 0x00000012
455 #define ENC_ISO_8859_6 0x00000014
456 #define ENC_ISO_8859_7 0x00000016
457 #define ENC_ISO_8859_8 0x00000018
458 #define ENC_ISO_8859_9 0x0000001A
459 #define ENC_ISO_8859_10 0x0000001C
460 #define ENC_ISO_8859_11 0x0000001E
461 /* #define ENC_ISO_8859_12 0x00000020 ISO 8859-12 was abandoned */
462 #define ENC_ISO_8859_13 0x00000022
463 #define ENC_ISO_8859_14 0x00000024
464 #define ENC_ISO_8859_15 0x00000026
465 #define ENC_ISO_8859_16 0x00000028
466 #define ENC_WINDOWS_1250 0x0000002A
467 #define ENC_3GPP_TS_23_038_7BITS 0x0000002C
468 #define ENC_EBCDIC 0x0000002E
469 #define ENC_MAC_ROMAN 0x00000030
470 #define ENC_CP437 0x00000032
471 #define ENC_ASCII_7BITS 0x00000034
472 #define ENC_T61 0x00000036
473 #define ENC_EBCDIC_CP037 0x00000038
474 #define ENC_ZIGBEE 0x0000003A
480 * These could probably be used by existing code:
485 * As those are added, change code such as the code in packet-bacapp.c
490 * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
491 * opaque byte-array fields (FT_BYTES), and other fields where there
492 * is no choice of encoding (either because it's "just a bucket
493 * of bytes" or because the encoding is completely fixed), we
494 * have ENC_NA (for "Not Applicable").
496 #define ENC_NA 0x00000000
498 /* For cases where either native type or string encodings could both be
499 * valid arguments, we need something to distinguish which one is being
500 * passed as the argument, because ENC_BIG_ENDIAN and ENC_ASCII are both
501 * 0x00000000. So we use ENC_STR_NUM or ENC_STR_HEX bit-or'ed with
502 * ENC_ASCII and its ilk.
504 /* this is for strings as numbers "12345" */
505 #define ENC_STR_NUM 0x01000000
506 /* this is for strings as hex "1a2b3c" */
507 #define ENC_STR_HEX 0x02000000
508 /* a convenience macro for either of the above */
509 #define ENC_STRING 0x03000000
510 /* mask out ENC_STR_* and related bits - should this replace ENC_CHARENCODING_MASK? */
511 #define ENC_STR_MASK 0x0000FFFE
513 /* for cases where the number is allowed to have a leading '+'/'-' */
514 /* this can't collide with ENC_SEP_* because they can be used simultaneously */
515 #define ENC_NUM_PREF 0x00200000
517 /* Use varint format as described in Protobuf protocol
518 * https://developers.google.cn/protocol-buffers/docs/encoding
520 #define ENC_VARINT_PROTOBUF 0x00000002
522 * Decodes a variable-length integer used in QUIC protocol
523 * See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-8.1
525 #define ENC_VARINT_QUIC 0x00000004
527 /* For cases where a string encoding contains hex, bit-or one or more
528 * of these for the allowed separator(s), as well as with ENC_STR_HEX.
529 * See hex_str_to_bytes_encoding() in epan/strutil.h for details.
531 #define ENC_SEP_NONE 0x00010000
532 #define ENC_SEP_COLON 0x00020000
533 #define ENC_SEP_DASH 0x00040000
534 #define ENC_SEP_DOT 0x00080000
535 #define ENC_SEP_SPACE 0x00100000
536 /* a convenience macro for the above */
537 #define ENC_SEP_MASK 0x001F0000
539 /* For cases where a string encoding contains a timestamp, use one
540 * of these (but only one). These values can collide with above, because
541 * you can't do both at the same time.
543 #define ENC_ISO_8601_DATE 0x00010000
544 #define ENC_ISO_8601_TIME 0x00020000
545 #define ENC_ISO_8601_DATE_TIME 0x00030000
546 #define ENC_RFC_822 0x00040000
547 #define ENC_RFC_1123 0x00080000
548 /* a convenience macro for the above - for internal use only */
549 #define ENC_STR_TIME_MASK 0x000F0000
551 /* Values for header_field_info.display */
553 /* For integral types, the display format is a BASE_* field_display_e value
554 * possibly ORed with BASE_*_STRING */
556 /** FIELD_DISPLAY_E_MASK selects the field_display_e value. */
557 #define FIELD_DISPLAY_E_MASK 0xFF
560 * Note that this enum values are parsed in make-init-lua.pl so make sure
561 * any changes here still makes valid entries in init.lua.
565 BASE_NONE = 0, /**< none */
566 BASE_DEC = 1, /**< decimal */
567 BASE_HEX = 2, /**< hexadecimal */
568 BASE_OCT = 3, /**< octal */
569 BASE_DEC_HEX = 4, /**< decimal (hexadecimal) */
570 BASE_HEX_DEC = 5, /**< hexadecimal (decimal) */
571 BASE_CUSTOM = 6, /**< call custom routine (in ->strings) to format */
574 BASE_FLOAT = BASE_NONE, /**< decimal-format float */
577 STR_ASCII = 0, /**< shows non-printable ASCII characters as C-style escapes */
578 /* XXX, support for format_text_wsp() ? */
579 STR_UNICODE = 7, /**< shows non-printable UNICODE characters as \\uXXXX (XXX for now non-printable characters display depends on UI) */
581 /* Byte separators */
582 SEP_DOT = 8, /**< hexadecimal bytes with a period (.) between each byte */
583 SEP_DASH = 9, /**< hexadecimal bytes with a dash (-) between each byte */
584 SEP_COLON = 10, /**< hexadecimal bytes with a colon (:) between each byte */
585 SEP_SPACE = 11, /**< hexadecimal bytes with a space between each byte */
588 BASE_NETMASK = 12, /**< Used for IPv4 address that shouldn't be resolved (like for netmasks) */
591 BASE_PT_UDP = 13, /**< UDP port */
592 BASE_PT_TCP = 14, /**< TCP port */
593 BASE_PT_DCCP = 15, /**< DCCP port */
594 BASE_PT_SCTP = 16, /**< SCTP port */
597 BASE_OUI = 17 /**< OUI resolution */
601 #define FIELD_DISPLAY(d) ((d) & FIELD_DISPLAY_E_MASK)
603 /* Following constants have to be ORed with a field_display_e when dissector
604 * want to use specials value-string MACROs for a header_field_info */
605 #define BASE_RANGE_STRING 0x0100
606 #define BASE_EXT_STRING 0x0200
607 #define BASE_VAL64_STRING 0x0400
608 #define BASE_ALLOW_ZERO 0x0800 /**< Display <none> instead of <MISSING> for zero sized byte array */
609 #define BASE_UNIT_STRING 0x1000 /**< Add unit text to the field value */
610 #define BASE_NO_DISPLAY_VALUE 0x2000 /**< Just display the field name with no value. Intended for
611 byte arrays or header fields above a subtree */
612 #define BASE_PROTOCOL_INFO 0x4000 /**< protocol_t in [FIELDCONVERT]. Internal use only. */
613 #define BASE_SPECIAL_VALS 0x8000 /**< field will not display "Unknown" if value_string match is not found */
615 /** BASE_ values that cause the field value to be displayed twice */
616 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
618 /** BASE_PT_ values display decimal and transport port service name */
619 #define IS_BASE_PORT(b) (((b)==BASE_PT_UDP||(b)==BASE_PT_TCP||(b)==BASE_PT_DCCP||(b)==BASE_PT_SCTP))
621 /* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e
622 * as per time_fmt.h. */
625 HF_REF_TYPE_NONE, /**< Field is not referenced */
626 HF_REF_TYPE_INDIRECT, /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
627 HF_REF_TYPE_DIRECT /**< Field is directly referenced */
630 /** information describing a header field */
631 typedef struct _header_field_info header_field_info;
633 /** information describing a header field */
634 struct _header_field_info {
635 /* ---------- set by dissector --------- */
636 const char *name; /**< [FIELDNAME] full name of this field */
637 const char *abbrev; /**< [FIELDABBREV] abbreviated name of this field */
638 enum ftenum type; /**< [FIELDTYPE] field type, one of FT_ (from ftypes.h) */
639 int display; /**< [FIELDDISPLAY] one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
640 const void *strings; /**< [FIELDCONVERT] value_string, val64_string, range_string or true_false_string,
641 typically converted by VALS(), RVALS() or TFS().
642 If this is an FT_PROTOCOL or BASE_PROTOCOL_INFO then it points to the
643 associated protocol_t structure */
644 guint64 bitmask; /**< [BITMASK] bitmask of interesting bits */
645 const char *blurb; /**< [FIELDDESCR] Brief description of field */
647 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
648 int id; /**< Field ID */
649 int parent; /**< parent protocol tree */
650 hf_ref_type ref_type; /**< is this field referenced by a filter */
651 int same_name_prev_id; /**< ID of previous hfinfo with same abbrev */
652 header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev */
656 * HFILL initializes all the "set by proto routines" fields in a
657 * _header_field_info. If new fields are added or removed, it should
658 * be changed as necessary.
660 #define HFILL -1, 0, HF_REF_TYPE_NONE, -1, NULL
662 #define HFILL_INIT(hf) \
663 (hf).hfinfo.id = -1; \
664 (hf).hfinfo.parent = 0; \
665 (hf).hfinfo.ref_type = HF_REF_TYPE_NONE; \
666 (hf).hfinfo.same_name_prev_id = -1; \
667 (hf).hfinfo.same_name_next = NULL;
669 /** Used when registering many fields at once, using proto_register_field_array() */
670 typedef struct hf_register_info {
671 int *p_id; /**< written to by register() function */
672 header_field_info hfinfo; /**< the field info to be registered */
678 /** string representation, if one of the proto_tree_add_..._format() functions used */
679 typedef struct _item_label_t {
680 char representation[ITEM_LABEL_LENGTH];
684 /** Contains the field information for the proto_item. */
685 typedef struct field_info {
686 header_field_info *hfinfo; /**< pointer to registered field information */
687 gint start; /**< current start of data in field_info.ds_tvb */
688 gint length; /**< current data length of item in field_info.ds_tvb */
689 gint appendix_start; /**< start of appendix data */
690 gint appendix_length; /**< length of appendix data */
691 gint tree_type; /**< one of ETT_ or -1 */
692 guint32 flags; /**< bitfield like FI_GENERATED, ... */
693 item_label_t *rep; /**< string for GUI tree */
694 tvbuff_t *ds_tvb; /**< data source tvbuff */
700 * This structure describes one segment of a split-bits item
701 * crumb_bit_offset is the bit offset in the input tvb of the first (most significant) bit of this crumb
702 * crumb_bit_length is the number of contiguous bits of this crumb.
703 * The first element of an array of bits_specs describes the most significant crumb of the output value.
704 * The second element of an array of bits_specs describes the next-most significant crumb of the output value, etc.
705 * The array is terminated by a sentinel entry with crumb_bit_length of 0.
709 guint crumb_bit_offset;
710 guint8 crumb_bit_length;
714 * Flag fields. Do not assign values greater than 0x00000080 unless you
715 * shuffle the expert information upward; see below.
718 /** The protocol field should not be shown in the tree (it's used for filtering only),
719 * used in field_info.flags. */
720 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
721 A user cannot tell by looking at the packet detail that the field exists
722 and that they can filter on its value. */
723 #define FI_HIDDEN 0x00000001
724 /** The protocol field should be displayed as "generated by Wireshark",
725 * used in field_info.flags. */
726 #define FI_GENERATED 0x00000002
727 /** The protocol field is actually a URL */
728 #define FI_URL 0x00000004
730 /** The protocol field value is in little endian */
731 #define FI_LITTLE_ENDIAN 0x00000008
732 /** The protocol field value is in big endian */
733 #define FI_BIG_ENDIAN 0x00000010
734 /** Field value start from nth bit (values from 0x20 - 0x100) */
735 #define FI_BITS_OFFSET(n) (((n) & 7) << 5)
736 /** Field value takes n bits (values from 0x100 - 0x4000) */
737 /* if 0, it means that field takes fi->length * 8 */
738 #define FI_BITS_SIZE(n) (((n) & 63) << 8)
739 /** The protocol field value is a varint */
740 #define FI_VARINT 0x00004000
742 /** convenience macro to get field_info.flags */
743 #define FI_GET_FLAG(fi, flag) ((fi) ? ((fi)->flags & (flag)) : 0)
744 /** convenience macro to set field_info.flags */
745 #define FI_SET_FLAG(fi, flag) \
748 (fi)->flags = (fi)->flags | (flag); \
750 /** convenience macro to reset field_info.flags */
751 #define FI_RESET_FLAG(fi, flag) \
754 (fi)->flags = (fi)->flags & ~(flag); \
757 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
758 #define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
760 /** One of these exists for the entire protocol tree. Each proto_node
761 * in the protocol tree points to the same copy. */
763 GHashTable *interesting_hfids;
765 gboolean fake_protocols;
767 struct _packet_info *pinfo;
770 /** Each proto_tree, proto_item is one of these. */
771 typedef struct _proto_node {
772 struct _proto_node *first_child;
773 struct _proto_node *last_child;
774 struct _proto_node *next;
775 struct _proto_node *parent;
777 tree_data_t *tree_data;
780 /** A protocol tree element. */
781 typedef proto_node proto_tree;
782 /** A protocol item element. */
783 typedef proto_node proto_item;
786 * Expert information.
787 * This is in the flags field; we allocate this from the top down,
788 * so as not to collide with FI_ flags, which are allocated from
792 /* do not modify the PI_SEVERITY_MASK name - it's used by make-init-lua.pl */
793 /* expert severities */
794 #define PI_SEVERITY_MASK 0x00F00000 /**< mask usually for internal use only! */
795 /** Packet comment */
796 #define PI_COMMENT 0x00100000
797 /** Usual workflow, e.g. TCP connection establishing */
798 #define PI_CHAT 0x00200000
799 /** Notable messages, e.g. an application returned an "unusual" error code like HTTP 404 */
800 #define PI_NOTE 0x00400000
801 /** Warning, e.g. application returned an "unusual" error code */
802 #define PI_WARN 0x00600000
803 /** Serious problems, e.g. a malformed packet */
804 #define PI_ERROR 0x00800000
806 /* do not modify the PI_GROUP_MASK name - it's used by make-init-lua.pl */
807 /* expert "event groups" */
808 #define PI_GROUP_MASK 0xFF000000 /**< mask usually for internal use only! */
809 /** The protocol field has a bad checksum, usually uses PI_WARN severity */
810 #define PI_CHECKSUM 0x01000000
811 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
812 #define PI_SEQUENCE 0x02000000
813 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE severity */
814 #define PI_RESPONSE_CODE 0x03000000
815 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT severity */
816 #define PI_REQUEST_CODE 0x04000000
817 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN severity */
818 #define PI_UNDECODED 0x05000000
819 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT severity (or PI_ERROR) */
820 #define PI_REASSEMBLE 0x06000000
821 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR severity */
822 #define PI_MALFORMED 0x07000000
823 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR severity */
824 #define PI_DEBUG 0x08000000
825 /** The protocol field violates a protocol specification, usually PI_WARN severity */
826 #define PI_PROTOCOL 0x09000000
827 /** The protocol field indicates a security problem (e.g. insecure implementation) */
828 #define PI_SECURITY 0x0a000000
829 /** The protocol field indicates a packet comment */
830 #define PI_COMMENTS_GROUP 0x0b000000
831 /** The protocol field indicates a decryption problem */
832 #define PI_DECRYPTION 0x0c000000
833 /** The protocol field has incomplete data, decode based on assumed value */
834 #define PI_ASSUMPTION 0x0d000000
835 /** The protocol field has been deprecated, usually PI_NOTE severity */
836 #define PI_DEPRECATED 0x0e000000
838 /* add more, see https://wiki.wireshark.org/Development/ExpertInfo */
841 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
842 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
843 #define PROTO_ITEM_IS_HIDDEN(proto_item) \
844 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
845 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
846 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
847 #define PROTO_ITEM_SET_HIDDEN(proto_item) \
850 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
852 /** mark this protocol field to be visible from the protocol tree display */
853 #define PROTO_ITEM_SET_VISIBLE(proto_item) \
856 FI_RESET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
859 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
860 #define PROTO_ITEM_IS_GENERATED(proto_item) \
861 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
862 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
863 #define PROTO_ITEM_SET_GENERATED(proto_item) \
866 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
868 /** is this protocol field actually a URL? */
869 #define PROTO_ITEM_IS_URL(proto_item) \
870 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
871 /** mark this protocol field as a URL */
872 #define PROTO_ITEM_SET_URL(proto_item) \
875 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
878 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
879 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);
881 extern gboolean proto_tree_traverse_post_order(proto_tree *tree,
882 proto_tree_traverse_func func, gpointer data);
884 WS_DLL_PUBLIC void proto_tree_children_foreach(proto_tree *tree,
885 proto_tree_foreach_func func, gpointer data);
887 /** Retrieve the field_info from a proto_node */
888 #define PNODE_FINFO(proto_node) ((proto_node)->finfo)
890 /** Retrieve the field_info from a proto_item */
891 #define PITEM_FINFO(proto_item) PNODE_FINFO(proto_item)
893 /** Retrieve the field_info from a proto_tree */
894 #define PTREE_FINFO(proto_tree) PNODE_FINFO(proto_tree)
896 /** Retrieve the tree_data_t from a proto_tree */
897 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
899 /** Retrieve the wmem_allocator_t from a proto_node */
900 #define PNODE_POOL(proto_node) ((proto_node)->tree_data->pinfo->pool)
904 void (*register_protoinfo)(void); /* routine to call to register protocol information */
905 void (*register_handoff)(void); /* routine to call to register dissector handoff */
908 /** Register dissector plugin with the plugin system. */
909 WS_DLL_PUBLIC void proto_register_plugin(const proto_plugin *plugin);
912 /** Sets up memory used by proto routines. Called at program startup */
913 void proto_init(GSList *register_all_plugin_protocols_list,
914 GSList *register_all_plugin_handoffs_list,
915 register_cb cb, void *client_data);
918 /** Frees memory used by proto routines. Called at program shutdown */
919 extern void proto_cleanup(void);
921 /** This function takes a tree and a protocol id as parameter and
922 will return TRUE/FALSE for whether the protocol or any of the filterable
923 fields in the protocol is referenced by any fitlers.
924 If this function returns FALSE then it is safe to skip any
925 proto_tree_add_...() calls and just treat the call as if the
926 dissector was called with tree==NULL.
927 If you reset the tree to NULL by this dissector returning FALSE,
928 you will still need to call any subdissector with the original value of
929 tree or filtering will break.
931 The purpose of this is to optimize wireshark for speed and make it
932 faster for when filters are being used.
934 WS_DLL_PUBLIC gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
936 /** Create a subtree under an existing item.
937 @param ti the parent item of the new subtree
938 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
939 @return the new subtree */
940 WS_DLL_PUBLIC proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx) G_GNUC_WARN_UNUSED_RESULT;
942 /** Get an existing subtree under an item.
943 @param ti the parent item of the subtree
944 @return the subtree or NULL */
945 WS_DLL_PUBLIC proto_tree* proto_item_get_subtree(proto_item *ti);
947 /** Get the parent of a subtree item.
948 @param ti the child item in the subtree
949 @return parent item or NULL */
950 WS_DLL_PUBLIC proto_item* proto_item_get_parent(const proto_item *ti);
952 /** Get Nth generation parent item.
953 @param ti the child item in the subtree
954 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
955 @return parent item */
956 WS_DLL_PUBLIC proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
958 /** Replace text of item after it already has been created.
959 @param ti the item to set the text
960 @param format printf like format string
961 @param ... printf like parameters */
962 WS_DLL_PUBLIC void proto_item_set_text(proto_item *ti, const char *format, ...)
965 /** Append to text of item after it has already been created.
966 @param ti the item to append the text to
967 @param format printf like format string
968 @param ... printf like parameters */
969 WS_DLL_PUBLIC void proto_item_append_text(proto_item *ti, const char *format, ...)
972 /** Prepend to text of item after it has already been created.
973 @param ti the item to prepend the text to
974 @param format printf like format string
975 @param ... printf like parameters */
976 WS_DLL_PUBLIC void proto_item_prepend_text(proto_item *ti, const char *format, ...)
979 /** Set proto_item's length inside tvb, after it has already been created.
980 @param ti the item to set the length
981 @param length the new length ot the item */
982 WS_DLL_PUBLIC void proto_item_set_len(proto_item *ti, const gint length);
985 * Sets the length of the item based on its start and on the specified
986 * offset, which is the offset past the end of the item; as the start
987 * in the item is relative to the beginning of the data source tvbuff,
988 * we need to pass in a tvbuff.
989 @param ti the item to set the length
990 @param tvb end is relative to this tvbuff
991 @param end this end offset is relative to the beginning of tvb
992 @todo make usage clearer, I don't understand it!
994 WS_DLL_PUBLIC void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
996 /** Get length of a proto_item. Useful after using proto_tree_add_item()
997 * to add a variable-length field (e.g., FT_NSTRING_UINT8).
998 @param ti the item to get the length from
999 @return the current length */
1000 WS_DLL_PUBLIC int proto_item_get_len(const proto_item *ti);
1004 /** Creates a new proto_tree root.
1005 @return the new tree root */
1006 extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
1008 void proto_tree_reset(proto_tree *tree);
1010 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
1011 @param tree the tree to free */
1012 WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
1014 /** Set the tree visible or invisible.
1015 Is the parsing being done for a visible proto_tree or an invisible one?
1016 By setting this correctly, the proto_tree creation is sped up by not
1017 having to call g_vsnprintf and copy strings around.
1018 @param tree the tree to be set
1019 @param visible ... or not
1020 @return the old value */
1021 WS_DLL_PUBLIC gboolean
1022 proto_tree_set_visible(proto_tree *tree, gboolean visible);
1024 /** Indicate whether we should fake protocols during dissection (default = TRUE)
1025 @param tree the tree to be set
1026 @param fake_protocols TRUE if we should fake protocols */
1028 proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
1030 /** Mark a field/protocol ID as "interesting".
1031 @param tree the tree to be set (currently ignored)
1032 @param hfid the interesting field id
1033 @todo what *does* interesting mean? */
1035 proto_tree_prime_with_hfid(proto_tree *tree, const int hfid);
1037 /** Get a parent item of a subtree.
1038 @param tree the tree to get the parent from
1039 @return parent item */
1040 WS_DLL_PUBLIC proto_item* proto_tree_get_parent(proto_tree *tree);
1042 /** Get the parent tree of a subtree.
1043 @param tree the tree to get the parent from
1044 @return parent tree */
1045 WS_DLL_PUBLIC proto_tree *proto_tree_get_parent_tree(proto_tree *tree);
1047 /** Get the root tree from any subtree.
1048 @param tree the tree to get the root from
1049 @return root tree */
1050 WS_DLL_PUBLIC proto_tree* proto_tree_get_root(proto_tree *tree);
1052 /** Move an existing item behind another existing item.
1053 @param tree the tree to which both items belong
1054 @param fixed_item the item which keeps its position
1055 @param item_to_move the item which will be moved */
1056 WS_DLL_PUBLIC void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
1059 /** Set start and length of an appendix for a proto_tree.
1060 @param tree the tree to set the appendix start and length
1061 @param tvb the tv buffer of the current data
1062 @param start the start offset of the appendix
1063 @param length the length of the appendix */
1064 WS_DLL_PUBLIC void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length);
1067 /** Add an item to a proto_tree, using the text label registered to that item.
1068 The item is extracted from the tvbuff handed to it.
1069 @param tree the tree to append this item to
1071 @param tvb the tv buffer of the current data
1072 @param start start of data in tvb
1073 @param length length of data in tvb
1074 @param encoding data encoding
1075 @return the newly created item */
1076 WS_DLL_PUBLIC proto_item *
1077 proto_tree_add_item_new(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
1078 const gint start, gint length, const guint encoding);
1080 WS_DLL_PUBLIC proto_item *
1081 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1082 const gint start, gint length, const guint encoding);
1084 /** Add an item to a proto_tree, using the text label registered to that item.
1085 The item is extracted from the tvbuff handed to it.
1087 Return the length of the item through the pointer.
1088 @param tree the tree to append this item to
1090 @param tvb the tv buffer of the current data
1091 @param start start of data in tvb
1092 @param length length of data in tvb
1093 @param encoding data encoding
1094 @param[out] lenretval points to a gint that will be set to the item length
1095 @return the newly created item, and *lenretval is set to the item length */
1096 WS_DLL_PUBLIC proto_item *
1097 proto_tree_add_item_new_ret_length(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
1098 const gint start, gint length, const guint encoding, gint *lenretval);
1100 WS_DLL_PUBLIC proto_item *
1101 proto_tree_add_item_ret_length(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1102 const gint start, gint length,
1103 const guint encoding, gint *lenretval);
1105 /** Add an integer data item to a proto_tree, using the text label registered to that item.
1106 The item is extracted from the tvbuff handed to it, and the retrieved
1107 value is also set to *retval so the caller gets it back for other uses.
1109 This function retrieves the value even if the passed-in tree param is NULL,
1110 so that it can be used by dissectors at all times to both get the value
1111 and set the tree item to it.
1113 Like other proto_tree_add functions, if there is a tree and the value cannot
1114 be decoded from the tvbuff, then an expert info error is reported.
1116 This function accepts ENC_LITTLE_ENDIAN and ENC_BIG_ENDIAN for native number
1117 encoding in the tvbuff
1119 The length argument must
1120 be set to the appropriate size of the native type as in other proto_add routines.
1122 Integers of 8, 16, 24 and 32 bits can be retrieved with the _ret_int and
1123 ret_uint functions; integers of 40, 48, 56, and 64 bits can be retrieved
1124 with the _ret_uint64 function; Boolean values of 8, 16, 24, 32, 40, 48,
1125 56, and 64 bits can be retrieved with the _ret_boolean function.
1127 @param tree the tree to append this item to
1128 @param hfindex field
1129 @param tvb the tv buffer of the current data
1130 @param start start of data in tvb (cannot be negative)
1131 @param length length of data in tvb (for strings can be -1 for remaining)
1132 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_BIG_ENDIAN, ENC_ASCII|ENC_STRING, etc.)
1133 @param[out] retval points to a gint32 or guint32 which will be set to the value
1134 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
1136 WS_DLL_PUBLIC proto_item *
1137 proto_tree_add_item_ret_int(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1138 const gint start, gint length, const guint encoding, gint32 *retval);
1140 WS_DLL_PUBLIC proto_item *
1141 proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1142 const gint start, gint length, const guint encoding, guint32 *retval);
1144 WS_DLL_PUBLIC proto_item *
1145 proto_tree_add_item_ret_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1146 const gint start, gint length, const guint encoding, guint64 *retval);
1148 WS_DLL_PUBLIC proto_item *
1149 proto_tree_add_item_ret_varint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1150 const gint start, gint length, const guint encoding, guint64 *retval, gint *lenretval);
1152 WS_DLL_PUBLIC proto_item *
1153 proto_tree_add_item_ret_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1154 const gint start, gint length, const guint encoding, gboolean *retval);
1156 /** Add an string item to a proto_tree, using the text label registered to
1159 The item is extracted from the tvbuff handed to it, and the retrieved
1160 value and its length are returned through pointers so the caller can use
1161 them. The value is allocated using the wmem scope passed in.
1163 This function retrieves the value and length even if the passed-in tree
1164 param is NULL, so that then can be used by dissectors at all times to
1165 both get the value and set the tree item to it.
1167 Like other proto_tree_add functions, if there is a tree and the value cannot
1168 be decoded from the tvbuff, then an expert info error is reported.
1170 This function accepts string encodings.
1172 @param scope the wmem scope to use to allocate the string
1173 @param tree the tree to append this item to
1174 @param hfindex field
1175 @param tvb the tv buffer of the current data
1176 @param start start of data in tvb (cannot be negative)
1177 @param length length of data in tvb (for strings can be -1 for remaining)
1178 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1179 @param[out] retval points to a guint8 * that will be set to point to the
1181 @param[out] lenretval points to a gint that will be set to the item length
1182 @return the newly created item, *retval is set to the decoded value,
1183 and *lenretval is set to the item length
1185 WS_DLL_PUBLIC proto_item *
1186 proto_tree_add_item_ret_string_and_length(proto_tree *tree, int hfindex,
1187 tvbuff_t *tvb, const gint start, gint length, const guint encoding,
1188 wmem_allocator_t *scope, const guint8 **retval, gint *lenretval);
1190 /** Add an string item to a proto_tree, using the text label registered to
1193 The item is extracted from the tvbuff handed to it, and the retrieved
1194 value is returned through a pointer so the caller can use it. The value
1195 is allocated using the wmem scope passed in.
1197 This function retrieves the value even if the passed-in tree param is NULL,
1198 so that it can be used by dissectors at all times to both get the value
1199 and set the tree item to it.
1201 Like other proto_tree_add functions, if there is a tree and the value cannot
1202 be decoded from the tvbuff, then an expert info error is reported.
1204 This function accepts string encodings.
1206 @param scope the wmem scope to use to allocate the string
1207 @param tree the tree to append this item to
1208 @param hfindex field
1209 @param tvb the tv buffer of the current data
1210 @param start start of data in tvb (cannot be negative)
1211 @param length length of data in tvb (for strings can be -1 for remaining)
1212 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1213 @param[out] retval points to a guint8 * that will be set to point to the
1215 @return the newly created item, and *retval is set to the decoded value
1217 WS_DLL_PUBLIC proto_item *
1218 proto_tree_add_item_ret_string(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1219 const gint start, gint length, const guint encoding,
1220 wmem_allocator_t *scope, const guint8 **retval);
1222 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree.
1223 @param tree the tree to append this item to
1224 @param tvb the tv buffer of the current data
1225 @param start start of data in tvb
1226 @param length length of data in tvb
1227 @param format printf like format string
1228 @param ... printf like parameters
1229 @return the newly created item */
1231 proto_tree_add_text_internal(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
1232 ...) G_GNUC_PRINTF(5,6);
1234 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree using a variable argument list.
1235 @param tree the tree to append this item to
1236 @param tvb the tv buffer of the current data
1237 @param start start of data in tvb
1238 @param length length of data in tvb
1239 @param format printf like format string
1240 @param ap variable argument list
1241 @return the newly created item */
1243 proto_tree_add_text_valist_internal(proto_tree *tree, tvbuff_t *tvb, gint start,
1244 gint length, const char *format, va_list ap)
1245 G_GNUC_PRINTF(5, 0);
1247 /** Add a text-only node that creates a subtree underneath.
1248 @param tree the tree to append this item to
1249 @param tvb the tv buffer of the current data
1250 @param start start of data in tvb
1251 @param length length of data in tvb
1252 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1253 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1254 @param text label for the tree
1255 @return the newly created tree */
1256 WS_DLL_PUBLIC proto_tree *
1257 proto_tree_add_subtree(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *text);
1259 /** Add a text-only node that creates a subtree underneath.
1260 @param tree the tree to append this item to
1261 @param tvb the tv buffer of the current data
1262 @param start start of data in tvb
1263 @param length length of data in tvb
1264 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1265 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1266 @param format printf like format string
1267 @param ... printf like parameters
1268 @return the newly created tree */
1269 WS_DLL_PUBLIC proto_tree *
1270 proto_tree_add_subtree_format(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *format, ...) G_GNUC_PRINTF(7,8);
1272 /** Add a text-only node to a proto_tree with tvb_format_text() string. */
1274 proto_tree_add_format_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length);
1276 /** Add a text-only node to a proto_tree with tvb_format_text_wsp() string. */
1278 proto_tree_add_format_wsp_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length);
1280 /** Add a FT_NONE field to a proto_tree.
1281 @param tree the tree to append this item to
1282 @param hfindex field index
1283 @param tvb the tv buffer of the current data
1284 @param start start of data in tvb
1285 @param length length of data in tvb
1286 @param format printf like format string
1287 @param ... printf like parameters
1288 @return the newly created item */
1289 WS_DLL_PUBLIC proto_item *
1290 proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start,
1291 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
1293 /** Add a FT_PROTOCOL to a proto_tree.
1294 @param tree the tree to append this item to
1295 @param hfindex field index
1296 @param tvb the tv buffer of the current data
1297 @param start start of data in tvb
1298 @param length length of data in tvb
1299 @param format printf like format string
1300 @param ... printf like parameters
1301 @return the newly created item */
1302 WS_DLL_PUBLIC proto_item *
1303 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1304 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
1309 /** Add a FT_BYTES to a proto_tree.
1310 @param tree the tree to append this item to
1311 @param hfindex field index
1312 @param tvb the tv buffer of the current data
1313 @param start start of data in tvb
1314 @param length length of data in tvb
1315 @param start_ptr pointer to the data to display
1316 @return the newly created item */
1317 WS_DLL_PUBLIC proto_item *
1318 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1319 gint length, const guint8* start_ptr);
1321 /** Add a FT_BYTES to a proto_tree like proto_tree_add_bytes,
1322 but used when the tvb data length does not match the bytes length.
1323 @param tree the tree to append this item to
1324 @param hfindex field index
1325 @param tvb the tv buffer of the current data
1326 @param start start of data in tvb
1327 @param length length of data in tvb
1328 @param start_ptr pointer to the data to display
1329 @param ptr_length length of data in start_ptr
1330 @return the newly created item */
1331 WS_DLL_PUBLIC proto_item *
1332 proto_tree_add_bytes_with_length(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1333 gint length, const guint8 *start_ptr, gint ptr_length);
1335 /** Get and add a byte-array-based FT_* to a proto_tree.
1337 Supported: FT_BYTES, FT_UINT_BYTES, FT_OID, FT_REL_OID, and FT_SYSTEM_ID.
1339 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1340 in for the encoding, and the retrieved byte array is also set to *retval so the
1341 caller gets it back for other uses.
1343 This function retrieves the value even if the passed-in tree param is NULL,
1344 so that it can be used by dissectors at all times to both get the value
1345 and set the tree item to it.
1347 Like other proto_tree_add functions, if there is a tree and the value cannot
1348 be decoded from the tvbuff, then an expert info error is reported. For string
1349 encoding, this means that a failure to decode the hex value from the string
1350 results in an expert info error being added to the tree.
1352 If encoding is string-based, it will convert using tvb_get_string_bytes(); see
1353 that function's comments for details.
1355 @note The GByteArray retval must be pre-constructed using g_byte_array_new().
1357 @param tree the tree to append this item to
1358 @param hfindex field index
1359 @param tvb the tv buffer of the current data
1360 @param start start of data in tvb
1361 @param length length of data in tvb
1362 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, or ENC_UTF_8|ENC_STR_HEX)
1363 @param[in,out] retval points to a GByteArray which will be set to the bytes from the Tvb.
1364 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1365 @param[in,out] err if not NULL, gets set to 0 if no failure, else the errno code (e.g., EDOM, ERANGE).
1366 @return the newly created item, and retval is set to the decoded value
1368 WS_DLL_PUBLIC proto_item *
1369 proto_tree_add_bytes_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1370 const gint start, gint length, const guint encoding,
1371 GByteArray *retval, gint *endoff, gint *err);
1373 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1374 the string for the value and with the field name being included
1376 @param tree the tree to append this item to
1377 @param hfindex field index
1378 @param tvb the tv buffer of the current data
1379 @param start start of data in tvb
1380 @param length length of data in tvb
1381 @param start_ptr pointer to the data to display
1382 @param format printf like format string
1383 @param ... printf like parameters
1384 @return the newly created item */
1385 WS_DLL_PUBLIC proto_item *
1386 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1387 gint start, gint length, const guint8* start_ptr, const char *format,
1388 ...) G_GNUC_PRINTF(7,8);
1390 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1391 the entire string for the entry, including any field name.
1392 @param tree the tree to append this item to
1393 @param hfindex field index
1394 @param tvb the tv buffer of the current data
1395 @param start start of data in tvb
1396 @param length length of data in tvb
1397 @param start_ptr pointer to the data to display
1398 @param format printf like format string
1399 @param ... printf like parameters
1400 @return the newly created item */
1401 WS_DLL_PUBLIC proto_item *
1402 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1403 gint length, const guint8* start_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1405 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1406 @param tree the tree to append this item to
1407 @param hfindex field index
1408 @param tvb the tv buffer of the current data
1409 @param start start of data in tvb
1410 @param length length of data in tvb
1411 @param value_ptr pointer to the data to display
1412 @return the newly created item */
1413 WS_DLL_PUBLIC proto_item *
1414 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1415 gint length, const nstime_t* value_ptr);
1417 /** Get and add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1418 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1419 in for the encoding, and the retrieved value is also set to *retval so the
1420 caller gets it back for other uses.
1422 This function retrieves the value even if the passed-in tree param is NULL,
1423 so that it can be used by dissectors at all times to both get the value
1424 and set the tree item to it.
1426 Like other proto_tree_add functions, if there is a tree and the value cannot
1427 be decoded from the tvbuff, then an expert info error is reported. For string
1428 encoding, this means that a failure to decode the time value from the string
1429 results in an expert info error being added to the tree.
1431 If encoding is string-based, it will convert using tvb_get_string_time(); see
1432 that function's comments for details.
1434 @note The nstime_t *retval must be pre-allocated as a nstime_t.
1436 @param tree the tree to append this item to
1437 @param hfindex field index
1438 @param tvb the tv buffer of the current data
1439 @param start start of data in tvb
1440 @param length length of data in tvb
1441 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_UTF_8|ENC_ISO_8601_DATE_TIME, etc.)
1442 @param[in,out] retval points to a nstime_t which will be set to the value
1443 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1444 @param[in,out] err if not NULL, gets set to 0 if no failure, else the errno code (e.g., EDOM, ERANGE).
1445 @return the newly created item, and retval is set to the decoded value
1447 WS_DLL_PUBLIC proto_item *
1448 proto_tree_add_time_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1449 const gint start, gint length, const guint encoding,
1450 nstime_t *retval, gint *endoff, gint *err);
1453 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1454 the format generating the string for the value and with the field name
1455 being included automatically.
1456 @param tree the tree to append this item to
1457 @param hfindex field index
1458 @param tvb the tv buffer of the current data
1459 @param start start of data in tvb
1460 @param length length of data in tvb
1461 @param value_ptr pointer to the data to display
1462 @param format printf like format string
1463 @param ... printf like parameters
1464 @return the newly created item */
1465 WS_DLL_PUBLIC proto_item *
1466 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1467 gint start, gint length, nstime_t* value_ptr, const char *format, ...)
1470 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1471 the format generating the entire string for the entry, including any field
1473 @param tree the tree to append this item to
1474 @param hfindex field index
1475 @param tvb the tv buffer of the current data
1476 @param start start of data in tvb
1477 @param length length of data in tvb
1478 @param value_ptr pointer to the data to display
1479 @param format printf like format string
1480 @param ... printf like parameters
1481 @return the newly created item */
1482 WS_DLL_PUBLIC proto_item *
1483 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1484 gint length, nstime_t* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1486 /** Add a FT_IPXNET to a proto_tree.
1487 @param tree the tree to append this item to
1488 @param hfindex field index
1489 @param tvb the tv buffer of the current data
1490 @param start start of data in tvb
1491 @param length length of data in tvb
1492 @param value data to display
1493 @return the newly created item */
1494 WS_DLL_PUBLIC proto_item *
1495 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1496 gint length, guint32 value);
1498 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1499 the string for the value and with the field name being included
1501 @param tree the tree to append this item to
1502 @param hfindex field index
1503 @param tvb the tv buffer of the current data
1504 @param start start of data in tvb
1505 @param length length of data in tvb
1506 @param value data to display
1507 @param format printf like format string
1508 @param ... printf like parameters
1509 @return the newly created item */
1510 WS_DLL_PUBLIC proto_item *
1511 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1512 gint start, gint length, guint32 value, const char *format, ...)
1515 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1516 the entire string for the entry, including any field name.
1517 @param tree the tree to append this item to
1518 @param hfindex field index
1519 @param tvb the tv buffer of the current data
1520 @param start start of data in tvb
1521 @param length length of data in tvb
1522 @param value data to display
1523 @param format printf like format string
1524 @param ... printf like parameters
1525 @return the newly created item */
1526 WS_DLL_PUBLIC proto_item *
1527 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1528 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1530 /** Add a FT_IPv4 to a proto_tree.
1531 @param tree the tree to append this item to
1532 @param hfindex field index
1533 @param tvb the tv buffer of the current data
1534 @param start start of data in tvb
1535 @param length length of data in tvb
1536 @param value data to display
1537 @return the newly created item */
1538 WS_DLL_PUBLIC proto_item *
1539 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1540 gint length, guint32 value);
1542 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1543 the string for the value and with the field name being included
1545 @param tree the tree to append this item to
1546 @param hfindex field index
1547 @param tvb the tv buffer of the current data
1548 @param start start of data in tvb
1549 @param length length of data in tvb
1550 @param value data to display
1551 @param format printf like format string
1552 @param ... printf like parameters
1553 @return the newly created item */
1554 WS_DLL_PUBLIC proto_item *
1555 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1556 gint start, gint length, guint32 value, const char *format, ...)
1559 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1560 the entire string for the entry, including any field name.
1561 @param tree the tree to append this item to
1562 @param hfindex field index
1563 @param tvb the tv buffer of the current data
1564 @param start start of data in tvb
1565 @param length length of data in tvb
1566 @param value data to display
1567 @param format printf like format string
1568 @param ... printf like parameters
1569 @return the newly created item */
1570 WS_DLL_PUBLIC proto_item *
1571 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1572 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1574 /** Add a FT_IPv6 to a proto_tree.
1575 @param tree the tree to append this item to
1576 @param hfindex field index
1577 @param tvb the tv buffer of the current data
1578 @param start start of data in tvb
1579 @param length length of data in tvb
1580 @param value_ptr data to display
1581 @return the newly created item */
1582 WS_DLL_PUBLIC proto_item *
1583 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1584 gint length, const ws_in6_addr *value_ptr);
1586 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1587 the string for the value and with the field name being included
1589 @param tree the tree to append this item to
1590 @param hfindex field index
1591 @param tvb the tv buffer of the current data
1592 @param start start of data in tvb
1593 @param length length of data in tvb
1594 @param value_ptr data to display
1595 @param format printf like format string
1596 @param ... printf like parameters
1597 @return the newly created item */
1598 WS_DLL_PUBLIC proto_item *
1599 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1600 gint start, gint length, const ws_in6_addr *value_ptr, const char *format,
1601 ...) G_GNUC_PRINTF(7,8);
1603 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1604 the entire string for the entry, including any field name.
1605 @param tree the tree to append this item to
1606 @param hfindex field index
1607 @param tvb the tv buffer of the current data
1608 @param start start of data in tvb
1609 @param length length of data in tvb
1610 @param value_ptr data to display
1611 @param format printf like format string
1612 @param ... printf like parameters
1613 @return the newly created item */
1614 WS_DLL_PUBLIC proto_item *
1615 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1616 gint length, const ws_in6_addr *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1618 /** Add a FT_ETHER to a proto_tree.
1619 @param tree the tree to append this item to
1620 @param hfindex field index
1621 @param tvb the tv buffer of the current data
1622 @param start start of data in tvb
1623 @param length length of data in tvb
1624 @param value data to display
1625 @return the newly created item */
1626 WS_DLL_PUBLIC proto_item *
1627 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1628 gint length, const guint8* value);
1630 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1631 the string for the value and with the field name being included
1633 @param tree the tree to append this item to
1634 @param hfindex field index
1635 @param tvb the tv buffer of the current data
1636 @param start start of data in tvb
1637 @param length length of data in tvb
1638 @param value data to display
1639 @param format printf like format string
1640 @param ... printf like parameters
1641 @return the newly created item */
1642 WS_DLL_PUBLIC proto_item *
1643 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1644 gint start, gint length, const guint8* value, const char *format, ...)
1647 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1648 the entire string for the entry, including any field name.
1649 @param tree the tree to append this item to
1650 @param hfindex field index
1651 @param tvb the tv buffer of the current data
1652 @param start start of data in tvb
1653 @param length length of data in tvb
1654 @param value data to display
1655 @param format printf like format string
1656 @param ... printf like parameters
1657 @return the newly created item */
1658 WS_DLL_PUBLIC proto_item *
1659 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1660 gint length, const guint8* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1662 /** Add a FT_GUID to a proto_tree.
1663 @param tree the tree to append this item to
1664 @param hfindex field index
1665 @param tvb the tv buffer of the current data
1666 @param start start of data in tvb
1667 @param length length of data in tvb
1668 @param value_ptr data to display
1669 @return the newly created item */
1670 WS_DLL_PUBLIC proto_item *
1671 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1672 gint length, const e_guid_t *value_ptr);
1674 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1675 the string for the value and with the field name being included
1677 @param tree the tree to append this item to
1678 @param hfindex field index
1679 @param tvb the tv buffer of the current data
1680 @param start start of data in tvb
1681 @param length length of data in tvb
1682 @param value_ptr data to display
1683 @param format printf like format string
1684 @param ... printf like parameters
1685 @return the newly created item */
1686 WS_DLL_PUBLIC proto_item *
1687 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1688 gint start, gint length, const e_guid_t *value_ptr, const char *format,
1689 ...) G_GNUC_PRINTF(7,8);
1691 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1692 the entire string for the entry, including any field name.
1693 @param tree the tree to append this item to
1694 @param hfindex field index
1695 @param tvb the tv buffer of the current data
1696 @param start start of data in tvb
1697 @param length length of data in tvb
1698 @param value_ptr data to display
1699 @param format printf like format string
1700 @param ... printf like parameters
1701 @return the newly created item */
1702 WS_DLL_PUBLIC proto_item *
1703 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1704 gint length, const e_guid_t *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1706 /** Add a FT_OID to a proto_tree.
1707 @param tree the tree to append this item to
1708 @param hfindex field index
1709 @param tvb the tv buffer of the current data
1710 @param start start of data in tvb
1711 @param length length of data in tvb
1712 @param value_ptr data to display
1713 @return the newly created item */
1715 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1716 gint length, const guint8* value_ptr);
1718 /** Add a formatted FT_OID to a proto_tree, with the format generating
1719 the string for the value and with the field name being included
1721 @param tree the tree to append this item to
1722 @param hfindex field index
1723 @param tvb the tv buffer of the current data
1724 @param start start of data in tvb
1725 @param length length of data in tvb
1726 @param value_ptr data to display
1727 @param format printf like format string
1728 @param ... printf like parameters
1729 @return the newly created item */
1731 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1732 gint start, gint length, const guint8* value_ptr, const char *format,
1733 ...) G_GNUC_PRINTF(7,8);
1735 /** Add a formatted FT_OID to a proto_tree, with the format generating
1736 the entire string for the entry, including any field name.
1737 @param tree the tree to append this item to
1738 @param hfindex field index
1739 @param tvb the tv buffer of the current data
1740 @param start start of data in tvb
1741 @param length length of data in tvb
1742 @param value_ptr data to display
1743 @param format printf like format string
1744 @param ... printf like parameters
1745 @return the newly created item */
1747 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1748 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1750 /** Add a FT_STRING or FT_STRINGZPAD to a proto_tree.
1751 @param tree the tree to append this item to
1752 @param hfindex field index
1753 @param tvb the tv buffer of the current data
1754 @param start start of data in tvb
1755 @param length length of data in tvb
1756 @param value data to display
1757 @return the newly created item */
1758 WS_DLL_PUBLIC proto_item *
1759 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1760 gint length, const char* value);
1762 /** Add a formatted FT_STRING or FT_STRINGZPAD to a proto_tree, with the
1763 format generating the string for the value and with the field name
1764 being included automatically.
1765 @param tree the tree to append this item to
1766 @param hfindex field index
1767 @param tvb the tv buffer of the current data
1768 @param start start of data in tvb
1769 @param length length of data in tvb
1770 @param value data to display
1771 @param format printf like format string
1772 @param ... printf like parameters
1773 @return the newly created item */
1774 WS_DLL_PUBLIC proto_item *
1775 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1776 gint start, gint length, const char* value, const char *format, ...)
1779 /** Add a formatted FT_STRING or FT_STRINGZPAD to a proto_tree, with the
1780 format generating the entire string for the entry, including any field
1782 @param tree the tree to append this item to
1783 @param hfindex field index
1784 @param tvb the tv buffer of the current data
1785 @param start start of data in tvb
1786 @param length length of data in tvb
1787 @param value data to display
1788 @param format printf like format string
1789 @param ... printf like parameters
1790 @return the newly created item */
1791 WS_DLL_PUBLIC proto_item *
1792 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1793 gint length, const char* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1795 /** Add a FT_BOOLEAN to a proto_tree.
1796 @param tree the tree to append this item to
1797 @param hfindex field index
1798 @param tvb the tv buffer of the current data
1799 @param start start of data in tvb
1800 @param length length of data in tvb
1801 @param value data to display
1802 @return the newly created item */
1803 WS_DLL_PUBLIC proto_item *
1804 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1805 gint length, guint32 value);
1807 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1808 the string for the value and with the field name being included
1810 @param tree the tree to append this item to
1811 @param hfindex field index
1812 @param tvb the tv buffer of the current data
1813 @param start start of data in tvb
1814 @param length length of data in tvb
1815 @param value data to display
1816 @param format printf like format string
1817 @param ... printf like parameters
1818 @return the newly created item */
1819 WS_DLL_PUBLIC proto_item *
1820 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1821 tvbuff_t *tvb, gint start, gint length, guint32 value,
1822 const char *format, ...) G_GNUC_PRINTF(7,8);
1824 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1825 the entire string for the entry, including any field name.
1826 @param tree the tree to append this item to
1827 @param hfindex field index
1828 @param tvb the tv buffer of the current data
1829 @param start start of data in tvb
1830 @param length length of data in tvb
1831 @param value data to display
1832 @param format printf like format string
1833 @param ... printf like parameters
1834 @return the newly created item */
1835 WS_DLL_PUBLIC proto_item *
1836 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1837 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1839 /** Add a FT_FLOAT to a proto_tree.
1840 @param tree the tree to append this item to
1841 @param hfindex field index
1842 @param tvb the tv buffer of the current data
1843 @param start start of data in tvb
1844 @param length length of data in tvb
1845 @param value data to display
1846 @return the newly created item */
1847 WS_DLL_PUBLIC proto_item *
1848 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1849 gint length, float value);
1851 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1852 the string for the value and with the field name being included
1854 @param tree the tree to append this item to
1855 @param hfindex field index
1856 @param tvb the tv buffer of the current data
1857 @param start start of data in tvb
1858 @param length length of data in tvb
1859 @param value data to display
1860 @param format printf like format string
1861 @param ... printf like parameters
1862 @return the newly created item */
1863 WS_DLL_PUBLIC proto_item *
1864 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1865 gint start, gint length, float value, const char *format, ...)
1868 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1869 the entire string for the entry, including any field name.
1870 @param tree the tree to append this item to
1871 @param hfindex field index
1872 @param tvb the tv buffer of the current data
1873 @param start start of data in tvb
1874 @param length length of data in tvb
1875 @param value data to display
1876 @param format printf like format string
1877 @param ... printf like parameters
1878 @return the newly created item */
1879 WS_DLL_PUBLIC proto_item *
1880 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1881 gint length, float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1883 /** Add a FT_DOUBLE to a proto_tree.
1884 @param tree the tree to append this item to
1885 @param hfindex field index
1886 @param tvb the tv buffer of the current data
1887 @param start start of data in tvb
1888 @param length length of data in tvb
1889 @param value data to display
1890 @return the newly created item */
1891 WS_DLL_PUBLIC proto_item *
1892 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1893 gint length, double value);
1895 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1896 the string for the value and with the field name being included
1898 @param tree the tree to append this item to
1899 @param hfindex field index
1900 @param tvb the tv buffer of the current data
1901 @param start start of data in tvb
1902 @param length length of data in tvb
1903 @param value data to display
1904 @param format printf like format string
1905 @param ... printf like parameters
1906 @return the newly created item */
1907 WS_DLL_PUBLIC proto_item *
1908 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1909 gint start, gint length, double value, const char *format, ...)
1912 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1913 the entire string for the entry, including any field name.
1914 @param tree the tree to append this item to
1915 @param hfindex field index
1916 @param tvb the tv buffer of the current data
1917 @param start start of data in tvb
1918 @param length length of data in tvb
1919 @param value data to display
1920 @param format printf like format string
1921 @param ... printf like parameters
1922 @return the newly created item */
1923 WS_DLL_PUBLIC proto_item *
1924 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1925 gint length, double value, const char *format, ...) G_GNUC_PRINTF(7,8);
1927 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1928 @param tree the tree to append this item to
1929 @param hfindex field index
1930 @param tvb the tv buffer of the current data
1931 @param start start of data in tvb
1932 @param length length of data in tvb
1933 @param value data to display
1934 @return the newly created item */
1935 WS_DLL_PUBLIC proto_item *
1936 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1937 gint length, guint32 value);
1939 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1940 with the format generating the string for the value and with the field
1941 name being included automatically.
1942 @param tree the tree to append this item to
1943 @param hfindex field index
1944 @param tvb the tv buffer of the current data
1945 @param start start of data in tvb
1946 @param length length of data in tvb
1947 @param value data to display
1948 @param format printf like format string
1949 @param ... printf like parameters
1950 @return the newly created item */
1951 WS_DLL_PUBLIC proto_item *
1952 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1953 gint start, gint length, guint32 value, const char *format, ...)
1956 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1957 with the format generating the entire string for the entry, including any
1959 @param tree the tree to append this item to
1960 @param hfindex field index
1961 @param tvb the tv buffer of the current data
1962 @param start start of data in tvb
1963 @param length length of data in tvb
1964 @param value data to display
1965 @param format printf like format string
1966 @param ... printf like parameters
1967 @return the newly created item */
1968 WS_DLL_PUBLIC proto_item *
1969 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1970 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1972 /** Add an FT_UINT64 to a proto_tree.
1973 @param tree the tree to append this item to
1974 @param hfindex field index
1975 @param tvb the tv buffer of the current data
1976 @param start start of data in tvb
1977 @param length length of data in tvb
1978 @param value data to display
1979 @return the newly created item */
1980 WS_DLL_PUBLIC proto_item *
1981 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1982 gint length, guint64 value);
1984 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1985 the string for the value and with the field name being included
1987 @param tree the tree to append this item to
1988 @param hfindex field index
1989 @param tvb the tv buffer of the current data
1990 @param start start of data in tvb
1991 @param length length of data in tvb
1992 @param value data to display
1993 @param format printf like format string
1994 @param ... printf like parameters
1995 @return the newly created item */
1996 WS_DLL_PUBLIC proto_item *
1997 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1998 gint start, gint length, guint64 value, const char *format, ...)
2001 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
2002 the entire string for the entry, including any field name.
2003 @param tree the tree to append this item to
2004 @param hfindex field index
2005 @param tvb the tv buffer of the current data
2006 @param start start of data in tvb
2007 @param length length of data in tvb
2008 @param value data to display
2009 @param format printf like format string
2010 @param ... printf like parameters
2011 @return the newly created item */
2012 WS_DLL_PUBLIC proto_item *
2013 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2014 gint length, guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2016 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
2017 @param tree the tree to append this item to
2018 @param hfindex field index
2019 @param tvb the tv buffer of the current data
2020 @param start start of data in tvb
2021 @param length length of data in tvb
2022 @param value data to display
2023 @return the newly created item */
2024 WS_DLL_PUBLIC proto_item *
2025 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2026 gint length, gint32 value);
2028 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
2029 with the format generating the string for the value and with the field
2030 name being included automatically.
2031 @param tree the tree to append this item to
2032 @param hfindex field index
2033 @param tvb the tv buffer of the current data
2034 @param start start of data in tvb
2035 @param length length of data in tvb
2036 @param value data to display
2037 @param format printf like format string
2038 @param ... printf like parameters
2039 @return the newly created item */
2040 WS_DLL_PUBLIC proto_item *
2041 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
2042 gint start, gint length, gint32 value, const char *format, ...)
2045 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
2046 with the format generating the entire string for the entry, including
2048 @param tree the tree to append this item to
2049 @param hfindex field index
2050 @param tvb the tv buffer of the current data
2051 @param start start of data in tvb
2052 @param length length of data in tvb
2053 @param value data to display
2054 @param format printf like format string
2055 @param ... printf like parameters
2056 @return the newly created item */
2057 WS_DLL_PUBLIC proto_item *
2058 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2059 gint length, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2061 /** Add an FT_INT64 to a proto_tree.
2062 @param tree the tree to append this item to
2063 @param hfindex field index
2064 @param tvb the tv buffer of the current data
2065 @param start start of data in tvb
2066 @param length length of data in tvb
2067 @param value data to display
2068 @return the newly created item */
2069 WS_DLL_PUBLIC proto_item *
2070 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2071 gint length, gint64 value);
2073 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
2074 the string for the value and with the field name being included
2076 @param tree the tree to append this item to
2077 @param hfindex field index
2078 @param tvb the tv buffer of the current data
2079 @param start start of data in tvb
2080 @param length length of data in tvb
2081 @param value data to display
2082 @param format printf like format string
2083 @param ... printf like parameters
2084 @return the newly created item */
2085 WS_DLL_PUBLIC proto_item *
2086 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
2087 gint start, gint length, gint64 value, const char *format, ...)
2090 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
2091 the entire string for the entry, including any field name.
2092 @param tree the tree to append this item to
2093 @param hfindex field index
2094 @param tvb the tv buffer of the current data
2095 @param start start of data in tvb
2096 @param length length of data in tvb
2097 @param value data to display
2098 @param format printf like format string
2099 @param ... printf like parameters
2100 @return the newly created item */
2101 WS_DLL_PUBLIC proto_item *
2102 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2103 gint length, gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2105 /** Add a FT_EUI64 to a proto_tree.
2106 @param tree the tree to append this item to
2107 @param hfindex field index
2108 @param tvb the tv buffer of the current data
2109 @param start start of data in tvb
2110 @param length length of data in tvb
2111 @param value data to display
2112 @return the newly created item */
2113 WS_DLL_PUBLIC proto_item *
2114 proto_tree_add_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2115 gint length, const guint64 value);
2117 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
2118 the string for the value and with the field name being included
2120 @param tree the tree to append this item to
2121 @param hfindex field index
2122 @param tvb the tv buffer of the current data
2123 @param start start of data in tvb
2124 @param length length of data in tvb
2125 @param value data to display
2126 @param format printf like format string
2127 @param ... printf like parameters
2128 @return the newly created item */
2129 WS_DLL_PUBLIC proto_item *
2130 proto_tree_add_eui64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
2131 gint start, gint length, const guint64 value, const char *format, ...)
2134 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
2135 the entire string for the entry, including any field name.
2136 @param tree the tree to append this item to
2137 @param hfindex field index
2138 @param tvb the tv buffer of the current data
2139 @param start start of data in tvb
2140 @param length length of data in tvb
2141 @param value data to display
2142 @param format printf like format string
2143 @param ... printf like parameters
2144 @return the newly created item */
2145 WS_DLL_PUBLIC proto_item *
2146 proto_tree_add_eui64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
2147 gint length, const guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2150 /** Useful for quick debugging. Also sends string to STDOUT, so don't
2151 leave call to this function in production code.
2152 @param tree the tree to append the text to
2153 @param format printf like format string
2154 @param ... printf like parameters
2155 @return the newly created item */
2156 WS_DLL_PUBLIC proto_item *
2157 proto_tree_add_debug_text(proto_tree *tree, const char *format,
2158 ...) G_GNUC_PRINTF(2,3);
2161 /** Fill given label_str with string representation of field
2162 @param fi the item to get the info from
2163 @param label_str the string to fill
2164 @todo think about changing the parameter profile */
2166 proto_item_fill_label(field_info *fi, gchar *label_str);
2169 /** Register a new protocol.
2170 @param name the full name of the new protocol
2171 @param short_name abbreviated name of the new protocol
2172 @param filter_name protocol name used for a display filter string
2173 @return the new protocol handle */
2175 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
2177 /** Register a "helper" protocol (pino - protocol in name only).
2178 This is for dissectors that need distinguishing names and don't need the other
2179 features (like enable/disable). One use case is a protocol with multiple dissection
2180 functions in a single dissector table needing unique "dissector names" to remove
2181 confusion with Decode As dialog. Another use case is for a dissector table set
2182 up to handle TLVs within a single protocol (and allow "external" TLVs being
2183 registered through the dissector table).
2184 @param name the full name of the new protocol
2185 @param short_name abbreviated name of the new protocol
2186 @param filter_name protocol name used for a display filter string
2187 @param parent_proto the "real" protocol for the helper. The parent decides enable/disable
2188 @param field_type FT_PROTOCOL or FT_BYTES. Allows removal of "protocol highlighting" (FT_BYTES)
2189 if pino is part of TLV.
2190 @return the new protocol handle */
2192 proto_register_protocol_in_name_only(const char *name, const char *short_name, const char *filter_name, int parent_proto, enum ftenum field_type);
2194 /** Deregister a protocol.
2195 @param short_name abbreviated name of the protocol
2196 @return TRUE if protocol is removed */
2198 proto_deregister_protocol(const char *short_name);
2200 /** Register a protocol alias.
2201 This is for dissectors whose original name has changed, e.g. BOOTP to DHCP.
2202 @param proto_id protocol id returned by proto_register_protocol (0-indexed)
2203 @param alias_name alias for the protocol's filter name */
2205 proto_register_alias(const int proto_id, const char *alias_name);
2207 /** This type of function can be registered to get called whenever
2208 a given field was not found but a its prefix is matched;
2209 It can be used to procrastinate the hf array registration.
2210 @param match what's being matched */
2211 typedef void (*prefix_initializer_t)(const char* match);
2213 /** Register a new prefix for delayed initialization of field arrays
2214 Note that the initializer function MAY NOT be called before the dissector
2215 is first called. That is, dissectors using this function must be prepared
2216 to call the initializer before beginning dissection; they should do this by
2217 calling proto_registrar_get_byname() on one of the dissector's field names.
2218 @param prefix the prefix for the new protocol
2219 @param initializer function that will initialize the field array for the given prefix */
2221 proto_register_prefix(const char *prefix, prefix_initializer_t initializer);
2223 /** Initialize every remaining uninitialized prefix. */
2224 WS_DLL_PUBLIC void proto_initialize_all_prefixes(void);
2226 WS_DLL_PUBLIC void proto_register_fields_manual(const int parent, header_field_info **hfi, const int num_records);
2227 WS_DLL_PUBLIC void proto_register_fields_section(const int parent, header_field_info *hfi, const int num_records);
2229 /** Register a header_field array.
2230 @param parent the protocol handle from proto_register_protocol()
2231 @param hf the hf_register_info array
2232 @param num_records the number of records in hf */
2234 proto_register_field_array(const int parent, hf_register_info *hf, const int num_records);
2236 /** Deregister an already registered field.
2237 @param parent the protocol handle from proto_register_protocol()
2238 @param hf_id the field to deregister */
2240 proto_deregister_field (const int parent, gint hf_id);
2242 /** Add data to be freed when deregistered fields are freed.
2243 @param data a pointer to data to free */
2245 proto_add_deregistered_data (void *data);
2247 /** Free fields deregistered in proto_deregister_field(). */
2249 proto_free_deregistered_fields (void);
2251 /** Register a protocol subtree (ett) array.
2252 @param indices array of ett indices
2253 @param num_indices the number of records in indices */
2255 proto_register_subtree_array(gint *const *indices, const int num_indices);
2257 /** Get name of registered header_field number n.
2258 @param n item # n (0-indexed)
2259 @return the name of this registered item */
2260 WS_DLL_PUBLIC const char* proto_registrar_get_name(const int n);
2262 /** Get abbreviation of registered header_field number n.
2263 @param n item # n (0-indexed)
2264 @return the abbreviation of this registered item */
2265 WS_DLL_PUBLIC const char* proto_registrar_get_abbrev(const int n);
2267 /** Get the header_field information based upon a field or protocol id.
2268 @param hfindex item # n (0-indexed)
2269 @return the registered item */
2270 WS_DLL_PUBLIC header_field_info* proto_registrar_get_nth(guint hfindex);
2272 /** Get the header_field information based upon a field name.
2273 @param field_name the field name to search for
2274 @return the registered item */
2275 WS_DLL_PUBLIC header_field_info* proto_registrar_get_byname(const char *field_name);
2277 /** Get the header_field information based upon a field alias.
2278 @param alias_name the aliased field name to search for
2279 @return the registered item */
2280 WS_DLL_PUBLIC header_field_info* proto_registrar_get_byalias(const char *alias_name);
2282 /** Get the header_field id based upon a field name.
2283 @param field_name the field name to search for
2284 @return the field id for the registered item */
2285 WS_DLL_PUBLIC int proto_registrar_get_id_byname(const char *field_name);
2287 /** Get enum ftenum FT_ of registered header_field number n.
2288 @param n item # n (0-indexed)
2289 @return the registered item */
2290 WS_DLL_PUBLIC enum ftenum proto_registrar_get_ftype(const int n);
2292 /** Get parent protocol of registered header_field number n.
2293 @param n item # n (0-indexed)
2294 @return -1 if item _is_ a protocol */
2295 WS_DLL_PUBLIC int proto_registrar_get_parent(const int n);
2297 /** Is item # n a protocol?
2298 @param n item # n (0-indexed)
2299 @return TRUE if it's a protocol, FALSE if it's not */
2300 WS_DLL_PUBLIC gboolean proto_registrar_is_protocol(const int n);
2302 /** Get length of registered field according to field type.
2303 @param n item # n (0-indexed)
2304 @return 0 means undeterminable at registration time, -1 means unknown field */
2305 extern gint proto_registrar_get_length(const int n);
2308 /** Routines to use to iterate over the protocols and their fields;
2309 * they return the item number of the protocol in question or the
2310 * appropriate hfinfo pointer, and keep state in "*cookie". */
2311 WS_DLL_PUBLIC int proto_get_first_protocol(void **cookie);
2312 WS_DLL_PUBLIC int proto_get_data_protocol(void *cookie);
2313 WS_DLL_PUBLIC int proto_get_next_protocol(void **cookie);
2314 WS_DLL_PUBLIC header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookie);
2315 WS_DLL_PUBLIC header_field_info *proto_get_next_protocol_field(const int proto_id, void **cookie);
2317 /** Check if a protocol name is already registered.
2318 @param name the name to search for
2320 WS_DLL_PUBLIC int proto_name_already_registered(const gchar *name);
2322 /** Given a protocol's filter_name.
2323 @param filter_name the filter name to search for
2325 WS_DLL_PUBLIC int proto_get_id_by_filter_name(const gchar* filter_name);
2327 /** Given a protocol's short name.
2328 @param short_name the protocol short name to search for
2330 WS_DLL_PUBLIC int proto_get_id_by_short_name(const gchar* short_name);
2332 /** Can item # n decoding be disabled?
2333 @param proto_id protocol id (0-indexed)
2334 @return TRUE if it's a protocol, FALSE if it's not */
2335 WS_DLL_PUBLIC gboolean proto_can_toggle_protocol(const int proto_id);
2337 /** Get the "protocol_t" structure for the given protocol's item number.
2338 @param proto_id protocol id (0-indexed) */
2339 WS_DLL_PUBLIC protocol_t *find_protocol_by_id(const int proto_id);
2341 /** Get the protocol's name for the given protocol's item number.
2342 @param proto_id protocol id (0-indexed)
2344 WS_DLL_PUBLIC const char *proto_get_protocol_name(const int proto_id);
2346 /** Get the protocol's item number, for the given protocol's "protocol_t".
2347 @return its proto_id */
2348 WS_DLL_PUBLIC int proto_get_id(const protocol_t *protocol);
2350 /** Get the protocol's short name, for the given protocol's "protocol_t".
2351 @return its short name. */
2352 WS_DLL_PUBLIC const char *proto_get_protocol_short_name(const protocol_t *protocol);
2354 /** Get the protocol's long name, for the given protocol's "protocol_t".
2355 @return its long name. */
2356 WS_DLL_PUBLIC const char *proto_get_protocol_long_name(const protocol_t *protocol);
2358 /** Is protocol's decoding enabled ?
2359 @return TRUE if decoding is enabled, FALSE if not */
2360 WS_DLL_PUBLIC gboolean proto_is_protocol_enabled(const protocol_t *protocol);
2362 /** Is protocol's enabled by default (most are)?
2363 @return TRUE if decoding is enabled by default, FALSE if not */
2364 WS_DLL_PUBLIC gboolean proto_is_protocol_enabled_by_default(const protocol_t *protocol);
2366 /** Is this a protocol in name only (i.e. not a real one)?
2367 @return TRUE if helper, FALSE if not */
2368 WS_DLL_PUBLIC gboolean proto_is_pino(const protocol_t *protocol);
2370 /** Get a protocol's filter name by its item number.
2371 @param proto_id protocol id (0-indexed)
2372 @return its filter name. */
2373 WS_DLL_PUBLIC const char *proto_get_protocol_filter_name(const int proto_id);
2375 /** Associate a heuristic dissector with a protocol
2376 * INTERNAL USE ONLY!!!
2377 * @param protocol to associate the heuristic with
2378 * @param short_name heuristic dissector's short name
2380 extern void proto_add_heuristic_dissector(protocol_t *protocol, const char *short_name);
2382 /** Apply func to all heuristic dissectors of a protocol
2383 * @param protocol to iterate over heuristics
2384 * @param func function to execute on heuristics
2385 * @param user_data user-specific data for function
2387 WS_DLL_PUBLIC void proto_heuristic_dissector_foreach(const protocol_t *protocol, GFunc func, gpointer user_data);
2390 /** Find commonly-used protocols in a layer list.
2391 * @param layers Protocol layer list
2392 * @param is_ip Set to TRUE if the layer list contains IPv4 or IPv6, otherwise
2393 * unchanged. May be NULL.
2394 * @param is_tcp Set to TRUE if the layer list contains TCP, otherwise
2395 * unchanged. May be NULL.
2396 * @param is_udp Set to TRUE if the layer list contains UDP, otherwise
2397 * unchanged. May be NULL.
2398 * @param is_sctp Set to TRUE if the layer list contains SCTP, otherwise
2399 * unchanged. May be NULL.
2400 * @param is_ssl Set to TRUE if the layer list contains SSL/TLS, otherwise
2401 * unchanged. May be NULL.
2402 * @param is_rtp Set to TRUE if the layer list contains RTP, otherwise
2403 * unchanged. May be NULL.
2404 * @param is_lte_rlc Set to TRUE if the layer list contains LTE RLC, otherwise
2405 * unchanged. May be NULL.
2407 WS_DLL_PUBLIC void proto_get_frame_protocols(const wmem_list_t *layers,
2408 gboolean *is_ip, gboolean *is_tcp, gboolean *is_udp, gboolean *is_sctp,
2409 gboolean *is_ssl, gboolean *is_rtp, gboolean *is_lte_rlc);
2411 /** Check whether a protocol, specified by name, is in a layer list.
2412 * @param layers Protocol layer list
2413 * @param proto_name Name of protocol to find
2414 * @return TRUE if the protocol is found, FALSE if it isn't
2416 WS_DLL_PUBLIC gboolean proto_is_frame_protocol(const wmem_list_t *layers, const char* proto_name);
2418 /** Mark protocol with the given item number as disabled by default.
2419 @param proto_id protocol id (0-indexed) */
2420 WS_DLL_PUBLIC void proto_disable_by_default(const int proto_id);
2422 /** Enable / Disable protocol of the given item number.
2423 @param proto_id protocol id (0-indexed)
2424 @param enabled enable / disable the protocol */
2425 WS_DLL_PUBLIC void proto_set_decoding(const int proto_id, const gboolean enabled);
2427 /** Re-enable all protocols that are not marked as disabled by default. */
2428 WS_DLL_PUBLIC void proto_reenable_all(void);
2430 /** Disable disabling/enabling of protocol of the given item number.
2431 @param proto_id protocol id (0-indexed) */
2432 WS_DLL_PUBLIC void proto_set_cant_toggle(const int proto_id);
2434 /** Checks for existence any protocol or field within a tree.
2435 @param tree "Protocols" are assumed to be a child of the [empty] root node.
2436 @param id hfindex of protocol or field
2437 @return TRUE = found, FALSE = not found
2438 @todo add explanation of id parameter */
2439 extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id);
2441 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2442 tree. Only works with primed trees, and is fast.
2443 @param tree tree of interest
2444 @param hfindex primed hfindex
2445 @return GPtrArray pointer */
2446 WS_DLL_PUBLIC GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
2448 /** Return whether we're tracking any interesting fields.
2449 Only works with primed trees, and is fast.
2450 @param tree tree of interest
2451 @return TRUE if we're tracking interesting fields */
2452 WS_DLL_PUBLIC gboolean proto_tracking_interesting_fields(const proto_tree *tree);
2454 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2455 tree. Works with any tree, primed or unprimed, and is slower than
2456 proto_get_finfo_ptr_array because it has to search through the tree.
2457 @param tree tree of interest
2458 @param hfindex index of field info of interest
2459 @return GPtrArry pointer */
2460 WS_DLL_PUBLIC GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex);
2462 /** Return GPtrArray* of field_info pointer for first hfindex that appear in
2463 tree. Works with any tree, primed or unprimed, and is slower than
2464 proto_get_finfo_ptr_array because it has to search through the tree.
2465 @param tree tree of interest
2466 @param hfindex index of field info of interest
2467 @return GPtrArry pointer */
2468 WS_DLL_PUBLIC GPtrArray* proto_find_first_finfo(proto_tree *tree, const int hfindex);
2470 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
2472 @param tree tree of interest
2473 @return GPtrArry pointer */
2474 WS_DLL_PUBLIC GPtrArray* proto_all_finfos(proto_tree *tree);
2476 /** Dumps a glossary of the protocol registrations to STDOUT */
2477 WS_DLL_PUBLIC void proto_registrar_dump_protocols(void);
2479 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
2480 WS_DLL_PUBLIC void proto_registrar_dump_values(void);
2482 #ifdef HAVE_JSONGLIB
2483 /** Dumps a mapping file for loading tshark output into ElasticSearch */
2484 WS_DLL_PUBLIC void proto_registrar_dump_elastic(const gchar* filter);
2487 /** Dumps the number of protocol and field registrations to STDOUT.
2488 @return FALSE if we pre-allocated enough fields, TRUE otherwise. */
2489 WS_DLL_PUBLIC gboolean proto_registrar_dump_fieldcount(void);
2491 /** Dumps a glossary of the protocol and field registrations to STDOUT. */
2492 WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
2494 /** Dumps a glossary field types and descriptive names to STDOUT */
2495 WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
2497 /** Get string representation of display field value
2498 @param field_display field display value (one of BASE_ values)
2499 @return string representation of display field value or "Unknown" if doesn't exist */
2500 WS_DLL_PUBLIC const char* proto_field_display_to_string(int field_display);
2502 /** Number of elements in the tree_is_expanded array. With MSVC and a
2503 * libwireshark.dll, we need a special declaration. */
2504 WS_DLL_PUBLIC int num_tree_types;
2506 /** Returns TRUE if subtrees of that type are to be expanded. */
2507 WS_DLL_PUBLIC gboolean tree_expanded(int tree_type);
2509 /** Sets if subtrees of that type are to be expanded. */
2510 WS_DLL_PUBLIC void tree_expanded_set(int tree_type, gboolean value);
2512 /** glib doesn't have g_ptr_array_len of all things!*/
2513 #ifndef g_ptr_array_len
2514 #define g_ptr_array_len(a) ((a)?(a)->len:0)
2518 hfinfo_bitshift(const header_field_info *hfinfo);
2520 struct epan_dissect;
2522 /** Can we do a "match selected" on this field.
2523 @param finfo field_info
2524 @param edt epan dissecting
2525 @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
2526 WS_DLL_PUBLIC gboolean
2527 proto_can_match_selected(field_info *finfo, struct epan_dissect *edt);
2529 /** Construct a "match selected" display filter string.
2530 @param finfo field_info
2531 @param edt epan dissecting
2532 @return the wmem NULL alloced display filter string. Needs to be freed with wmem_free(NULL, ...) */
2534 proto_construct_match_selected_string(field_info *finfo, struct epan_dissect *edt);
2536 /** Find field from offset in tvb.
2537 @param tree tree of interest
2538 @param offset offset in the tvb
2539 @param tvb the tv buffer
2540 @return the corresponding field_info */
2541 WS_DLL_PUBLIC field_info*
2542 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
2544 /** Find undecoded bytes in a tree
2545 @param tree tree of interest
2546 @param length the length of the frame
2547 @return an array to be used as bitmap of decoded bytes */
2548 WS_DLL_PUBLIC gchar*
2549 proto_find_undecoded_data(proto_tree *tree, guint length);
2551 /** This function will dissect a sequence of bytes that describe a bitmask.
2552 @param tree the tree to append this item to
2553 @param tvb the tv buffer of the current data
2554 @param offset start of data in tvb
2555 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
2556 bitmask to be dissected.
2557 This field will form an expansion under which the individual fields
2558 of the bitmask are dissected and displayed.
2559 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
2560 @param ett subtree index
2561 @param fields an array of pointers to int that lists all the fields of the
2562 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2563 or another integer of the same type/size as hf_hdr with a mask specified.
2564 This array is terminated by a NULL entry.
2565 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2566 FT_integer fields that have a value_string attached will have the
2567 matched string displayed on the expansion line.
2568 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2569 @return the newly created item */
2570 WS_DLL_PUBLIC proto_item *
2571 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2572 const int hf_hdr, const gint ett, const int **fields, const guint encoding);
2574 /** This function will dissect a sequence of bytes that describe a bitmask.
2575 The value of the integer containing the bitmask is returned through
2577 @param tree the tree to append this item to
2578 @param tvb the tv buffer of the current data
2579 @param offset start of data in tvb
2580 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
2581 bitmask to be dissected.
2582 This field will form an expansion under which the individual fields
2583 of the bitmask are dissected and displayed.
2584 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
2585 @param ett subtree index
2586 @param fields an array of pointers to int that lists all the fields of the
2587 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2588 or another integer of the same type/size as hf_hdr with a mask specified.
2589 This array is terminated by a NULL entry.
2590 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2591 FT_integer fields that have a value_string attached will have the
2592 matched string displayed on the expansion line.
2593 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2594 @param[out] retval points to a guint64 which will be set
2595 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
2597 WS_DLL_PUBLIC proto_item *
2598 proto_tree_add_bitmask_ret_uint64(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2599 const int hf_hdr, const gint ett, const int **fields,
2600 const guint encoding, guint64 *retval);
2602 /** This function will dissect a sequence of bytes that describe a bitmask.
2603 This has "filterable" bitmask header functionality of proto_tree_add_bitmask
2604 with the ability to control what data is appended to the header like
2605 proto_tree_add_bitmask_text
2606 @param tree the tree to append this item to
2607 @param tvb the tv buffer of the current data
2608 @param offset start of data in tvb
2609 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
2610 bitmask to be dissected.
2611 This field will form an expansion under which the individual fields
2612 of the bitmask are dissected and displayed.
2613 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
2614 @param ett subtree index
2615 @param fields an array of pointers to int that lists all the fields of the
2616 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2617 or another integer of the same type/size as hf_hdr with a mask specified.
2618 This array is terminated by a NULL entry.
2619 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2620 FT_integer fields that have a value_string attached will have the
2621 matched string displayed on the expansion line.
2622 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2623 @param flags bitmask field using BMT_NO_* flags to determine behavior
2624 @return the newly created item */
2625 WS_DLL_PUBLIC proto_item *
2626 proto_tree_add_bitmask_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2627 const int hf_hdr, const gint ett, const int **fields, const guint encoding, const int flags);
2629 /** This function will dissect a sequence of bytes that describe a bitmask.
2630 This has "filterable" bitmask header functionality of proto_tree_add_bitmask
2631 with the ability to control what data is appended to the header like
2632 proto_tree_add_bitmask_text
2633 The value of the integer containing the bitmask is returned through
2635 @param tree the tree to append this item to
2636 @param tvb the tv buffer of the current data
2637 @param offset start of data in tvb
2638 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
2639 bitmask to be dissected.
2640 This field will form an expansion under which the individual fields
2641 of the bitmask are dissected and displayed.
2642 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
2643 @param ett subtree index
2644 @param fields an array of pointers to int that lists all the fields of the
2645 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2646 or another integer of the same type/size as hf_hdr with a mask specified.
2647 This array is terminated by a NULL entry.
2648 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2649 FT_integer fields that have a value_string attached will have the
2650 matched string displayed on the expansion line.
2651 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2652 @param flags bitmask field using BMT_NO_* flags to determine behavior
2653 @param[out] retval points to a guint64 which will be set
2654 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
2656 WS_DLL_PUBLIC proto_item *
2657 proto_tree_add_bitmask_with_flags_ret_uint64(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2658 const int hf_hdr, const gint ett, const int **fields,
2659 const guint encoding, const int flags, guint64 *retval);
2661 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
2662 but with a passed in value (presumably because it can't be retrieved directly from tvb)
2663 @param tree the tree to append this item to
2664 @param tvb the tv buffer of the current data
2665 @param offset start of data in tvb
2666 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
2667 This field will form an expansion under which the individual fields of the
2668 bitmask is dissected and displayed.
2669 This field must be of the type FT_[U]INT{8|16|24|32|64}.
2670 @param ett subtree index
2671 @param fields an array of pointers to int that lists all the fields of the
2672 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2673 or another integer of the same type/size as hf_hdr with a mask specified.
2674 This array is terminated by a NULL entry.
2675 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2676 FT_integer fields that have a value_string attached will have the
2677 matched string displayed on the expansion line.
2678 @param value bitmask value
2679 @return the newly created item */
2680 WS_DLL_PUBLIC proto_item *
2681 proto_tree_add_bitmask_value(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2682 const int hf_hdr, const gint ett, const int **fields, const guint64 value);
2684 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
2685 but with a passed in value (presumably because it can't be retrieved directly from tvb)
2686 This has "filterable" bitmask header functionality of proto_tree_add_bitmask_value
2687 with the ability to control what data is appended to the header like
2688 proto_tree_add_bitmask_text
2689 @param tree the tree to append this item to
2690 @param tvb the tv buffer of the current data
2691 @param offset start of data in tvb
2692 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
2693 This field will form an expansion under which the individual fields of the
2694 bitmask is dissected and displayed.
2695 This field must be of the type FT_[U]INT{8|16|24|32|64}.
2696 @param ett subtree index
2697 @param fields an array of pointers to int that lists all the fields of the
2698 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2699 or another integer of the same type/size as hf_hdr with a mask specified.
2700 This array is terminated by a NULL entry.
2701 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2702 FT_integer fields that have a value_string attached will have the
2703 matched string displayed on the expansion line.
2704 @param value bitmask value
2705 @param flags bitmask field using BMT_NO_* flags to determine behavior
2706 @return the newly created item */
2707 WS_DLL_PUBLIC proto_item *
2708 proto_tree_add_bitmask_value_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2709 const int hf_hdr, const gint ett, const int **fields, const guint64 value, const int flags);
2711 /** This function will dissect a sequence of bytes that describe a bitmask. Similar
2712 to proto_tree_add_bitmask(), but with no "header" item to group all of the fields
2713 @param tree the tree to append this item to
2714 @param tvb the tv buffer of the current data
2715 @param offset start of data in tvb
2716 @param len number of bytes of data
2717 @param fields an array of pointers to int that lists all the fields of the
2718 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2719 or another integer of the same type/size as hf_hdr with a mask specified.
2720 This array is terminated by a NULL entry.
2721 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2722 FT_integer fields that have a value_string attached will have the
2723 matched string displayed on the expansion line.
2724 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2727 proto_tree_add_bitmask_list(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2728 const int len, const int **fields, const guint encoding);
2730 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask_list(),
2731 but with a passed in value (presumably because it can't be retrieved directly from tvb)
2732 @param tree the tree to append this item to
2733 @param tvb the tv buffer of the current data
2734 @param offset start of data in tvb
2735 @param len number of bytes of data
2736 @param fields an array of pointers to int that lists all the fields of the
2737 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2738 or another integer of the same type/size as hf_hdr with a mask specified.
2739 This array is terminated by a NULL entry.
2740 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2741 FT_integer fields that have a value_string attached will have the
2742 matched string displayed on the expansion line.
2743 @param value bitmask value */
2745 proto_tree_add_bitmask_list_value(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2746 const int len, const int **fields, const guint64 value);
2749 /** This function will dissect a sequence of bytes that describe a bitmask.
2750 @param tree the tree to append this item to
2751 @param tvb the tv buffer of the current data
2752 @param offset start of data in tvb
2753 @param len number of bytes of data
2754 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
2755 This field will form an expansion under which the individual fields of the
2756 bitmask are dissected and displayed.
2757 This field must be of the type FT_[U]INT{8|16|24|32}.
2758 @param ett subtree index
2759 @param fields an array of pointers to int that lists all the fields of the
2760 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2761 or another integer with a mask specified.
2762 This array is terminated by a NULL entry.
2763 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2764 FT_integer fields that have a value_string attached will have the
2765 matched string displayed on the expansion line.
2766 @param exp expert info field used when decodable_len < len. This also means this function
2767 should be called even when tree == NULL
2768 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2769 @return the newly created item */
2770 WS_DLL_PUBLIC proto_item *
2771 proto_tree_add_bitmask_len(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
2772 const int hf_hdr, const gint ett, const int **fields, struct expert_field* exp, const guint encoding);
2774 /** Add a text with a subtree of bitfields.
2775 @param tree the tree to append this item to
2776 @param tvb the tv buffer of the current data
2777 @param offset start of data in tvb
2778 @param len length of the field name
2779 @param name field name (NULL if bitfield contents should be used)
2780 @param fallback field name if none of bitfields were usable
2781 @param ett subtree index
2782 @param fields NULL-terminated array of bitfield indexes
2783 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2784 @param flags bitmask field
2785 @return the newly created item */
2786 WS_DLL_PUBLIC proto_item *
2787 proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
2788 const char *name, const char *fallback,
2789 const gint ett, const int **fields, const guint encoding, const int flags);
2791 #define BMT_NO_FLAGS 0x00 /**< Don't use any flags */
2792 #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */
2793 #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */
2794 #define BMT_NO_FALSE 0x04 /**< Don't add booleans unless they're TRUE */
2795 #define BMT_NO_TFS 0x08 /**< Don't use true_false_string while formatting booleans */
2797 /** Add bits to a proto_tree, using the text label registered to that item.
2798 The item is extracted from the tvbuff handed to it.
2799 @param tree the tree to append this item to
2800 @param hf_index field index. Fields for use with this function should have bitmask==0.
2801 @param tvb the tv buffer of the current data
2802 @param bit_offset start of data in tvb expressed in bits
2803 @param no_of_bits length of data in tvb expressed in bits
2804 @param encoding data encoding
2805 @return the newly created item */
2806 WS_DLL_PUBLIC proto_item *
2807 proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, const guint encoding);
2809 /** Add bits to a proto_tree, using the text label registered to that item.
2810 * The item is extracted from the tvbuff handed to it as a set
2811 * of crumbs (segments) of contiguous bits, specified by an
2812 * array of crumb_spec elements. The crumbs are assembled to
2813 * create the value. There may be any number of crumbs
2814 * specifying up to a total of 64 bits which may occur anywhere
2815 * within the tvb. If the span of the crumbs within the tvb is 4
2816 * octets or less, a bitmap of the crumbs is produced.
2817 @param tree the tree to append this item to
2818 @param hf_index field index. Fields for use with this function should have bitmask==0.
2819 @param tvb the tv buffer of the current data
2820 @param bit_offset of the first crumb in tvb expressed in bits
2821 @param crumb_spec pointer to crumb_spec array
2822 @param return_value if a pointer is passed here the value is returned.
2823 @return the newly created item */
2824 WS_DLL_PUBLIC proto_item *
2825 proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
2826 const guint bit_offset, const crumb_spec_t *crumb_spec,
2827 guint64 *return_value);
2830 /** Add bitmap text for a split-bits crumb to a proto_tree,
2831 * using the text label registered to an item. The bitmap is
2832 * extracted from the tvbuff handed to it as a crumb (segment)
2833 * of contiguous bits, specified by one of an array of
2834 * crumb_spec elements. This function is normally called once
2835 * per crumb, after the call to
2836 proto_tree_add_split_bits_item_ret_val
2837 @param tree the tree to append this item to
2838 @param hf_index field index. Fields for use with this function should have bitmask==0.
2839 @param tvb the tv buffer of the current data
2840 @param bit_offset of the first crumb in tvb expressed in bits
2841 @param crumb_spec pointer to crumb_spec array
2842 @param crumb_index into the crumb_spec array for this crumb */
2844 proto_tree_add_split_bits_crumb(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset,
2845 const crumb_spec_t *crumb_spec, guint16 crumb_index);
2847 /** Add bits to a proto_tree, using the text label registered to that item.
2848 The item is extracted from the tvbuff handed to it.
2849 @param tree the tree to append this item to
2850 @param hf_index field index. Fields for use with this function should have bitmask==0.
2851 @param tvb the tv buffer of the current data
2852 @param bit_offset start of data in tvb expressed in bits
2853 @param no_of_bits length of data in tvb expressed in bits
2854 @param return_value if a pointer is passed here the value is returned.
2855 @param encoding data encoding
2856 @return the newly created item */
2857 WS_DLL_PUBLIC proto_item *
2858 proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, guint64 *return_value, const guint encoding);
2860 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
2861 header field to a proto_tree, with the format generating the
2862 string for the value and with the field name being included automatically.
2863 @param tree the tree to append this item to
2864 @param hf_index field index
2865 @param tvb the tv buffer of the current data
2866 @param bit_offset start of data in tvb expressed in bits
2867 @param no_of_bits length of data in tvb expressed in bit
2868 @param value data to display
2869 @param format printf like format string
2870 @return the newly created item */
2871 WS_DLL_PUBLIC proto_item *
2872 proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2873 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2875 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
2876 header field to a proto_tree, with the format generating the
2877 string for the value and with the field name being included automatically.
2878 @param tree the tree to append this item to
2879 @param hf_index field index
2880 @param tvb the tv buffer of the current data
2881 @param bit_offset start of data in tvb expressed in bits
2882 @param no_of_bits length of data in tvb expressed in bit
2883 @param value data to display
2884 @param format printf like format string
2885 @return the newly created item */
2886 WS_DLL_PUBLIC proto_item *
2887 proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2888 guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2890 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
2891 the format generating the string for the value and with the field
2892 name being included automatically.
2893 @param tree the tree to append this item to
2894 @param hf_index field index
2895 @param tvb the tv buffer of the current data
2896 @param bit_offset start of data in tvb expressed in bits
2897 @param no_of_bits length of data in tvb expressed in bit
2898 @param value data to display
2899 @param format printf like format string
2900 @param ... printf like parameters
2901 @return the newly created item */
2903 proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2904 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2906 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
2907 the format generating the string for the value and with the field
2908 name being included automatically.
2909 @param tree the tree to append this item to
2910 @param hf_index field index
2911 @param tvb the tv buffer of the current data
2912 @param bit_offset start of data in tvb expressed in bits
2913 @param no_of_bits length of data in tvb expressed in bit
2914 @param value data to display
2915 @param format printf like format string
2916 @param ... printf like parameters
2917 @return the newly created item */
2919 proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2920 guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2922 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
2923 header field to a proto_tree, with the format generating the
2924 string for the value and with the field name being included automatically.
2925 @param tree the tree to append this item to
2926 @param hf_index field index
2927 @param tvb the tv buffer of the current data
2928 @param bit_offset start of data in tvb expressed in bits
2929 @param no_of_bits length of data in tvb expressed in bit
2930 @param value data to display
2931 @param format printf like format string
2932 @param ... printf like parameters
2933 @return the newly created item */
2935 proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2936 gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2938 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
2939 header field to a proto_tree, with the format generating the
2940 string for the value and with the field name being included automatically.
2941 @param tree the tree to append this item to
2942 @param hf_index field index
2943 @param tvb the tv buffer of the current data
2944 @param bit_offset start of data in tvb expressed in bits
2945 @param no_of_bits length of data in tvb expressed in bit
2946 @param value data to display
2947 @param format printf like format string
2948 @param ... printf like parameters
2949 @return the newly created item */
2951 proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2952 gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2954 /** Add bits for a FT_FLOAT header field to a proto_tree, with
2955 the format generating the string for the value and with the field
2956 name being included automatically.
2957 @param tree the tree to append this item to
2958 @param hf_index field index
2959 @param tvb the tv buffer of the current data
2960 @param bit_offset start of data in tvb expressed in bits
2961 @param no_of_bits length of data in tvb expressed in bit
2962 @param value data to display
2963 @param format printf like format string
2964 @param ... printf like parameters
2965 @return the newly created item */
2967 proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2968 float value, const char *format, ...) G_GNUC_PRINTF(7,8);
2971 /** Add a FT_STRING with ENC_3GPP_TS_23_038_7BITS encoding to a proto_tree.
2972 @param tree the tree to append this item to
2973 @param hfindex field index
2974 @param tvb the tv buffer of the current data
2975 @param bit_offset start of data in tvb expressed in bits
2976 @param no_of_chars number of 7bits characters to display
2977 @return the newly created item */
2978 WS_DLL_PUBLIC proto_item *
2979 proto_tree_add_ts_23_038_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
2980 const guint bit_offset, const gint no_of_chars);
2982 /** Add a FT_STRING with ENC_ASCII_7BITS encoding to a proto_tree.
2983 @param tree the tree to append this item to
2984 @param hfindex field index
2985 @param tvb the tv buffer of the current data
2986 @param bit_offset start of data in tvb expressed in bits
2987 @param no_of_chars number of 7bits characters to display
2988 @return the newly created item */
2989 WS_DLL_PUBLIC proto_item *
2990 proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
2991 const guint bit_offset, const gint no_of_chars);
2993 /** Add a checksum filed to a proto_tree.
2994 This standardizes the display of a checksum field as well as any
2995 status and expert info supporting it.
2996 @param tree the tree to append this item to
2997 @param tvb the tv buffer of the current data
2998 @param offset start of data in tvb
2999 @param hf_checksum checksum field index
3000 @param hf_checksum_status optional checksum status field index. If none
3001 exists, just pass -1
3002 @param bad_checksum_expert optional expert info for a bad checksum. If
3003 none exists, just pass NULL
3004 @param pinfo Packet info used for optional expert info. If unused, NULL can
3006 @param computed_checksum Checksum to verify against
3007 @param encoding data encoding of checksum from tvb
3008 @param flags bitmask field of PROTO_CHECKSUM_ options
3009 @return the newly created item */
3010 WS_DLL_PUBLIC proto_item *
3011 proto_tree_add_checksum(proto_tree *tree, tvbuff_t *tvb, const guint offset,
3012 const int hf_checksum, const int hf_checksum_status, struct expert_field* bad_checksum_expert,
3013 packet_info *pinfo, guint32 computed_checksum, const guint encoding, const guint flags);
3017 PROTO_CHECKSUM_E_BAD = 0,
3018 PROTO_CHECKSUM_E_GOOD,
3019 PROTO_CHECKSUM_E_UNVERIFIED,
3020 PROTO_CHECKSUM_E_NOT_PRESENT
3022 } proto_checksum_enum_e;
3024 #define PROTO_CHECKSUM_NO_FLAGS 0x00 /**< Don't use any flags */
3025 #define PROTO_CHECKSUM_VERIFY 0x01 /**< Compare against computed checksum */
3026 #define PROTO_CHECKSUM_GENERATED 0x02 /**< Checksum is generated only */
3027 #define PROTO_CHECKSUM_IN_CKSUM 0x04 /**< Internet checksum routine used for computation */
3028 #define PROTO_CHECKSUM_ZERO 0x08 /**< Computed checksum must be zero (but correct checksum can't be calculated) */
3029 #define PROTO_CHECKSUM_NOT_PRESENT 0x10 /**< Checksum field is not present (Just populates status field) */
3031 WS_DLL_PUBLIC const value_string proto_checksum_vals[];
3034 /** Check if given string is a valid field name
3035 @param field_name the field name to check
3036 @return 0 if valid, else first illegal character */
3037 WS_DLL_PUBLIC guchar
3038 proto_check_field_name(const gchar *field_name);
3041 /** Check if given string is a valid field name
3042 @param tree the tree to append this item to
3043 @param field_id the field id used for custom column
3044 @param occurrence the occurrence of the field used for custom column
3045 @param result the buffer to fill with the field string
3046 @param expr the filter expression
3047 @param size the size of the string buffer */
3049 proto_custom_set(proto_tree* tree, GSList *field_id,
3052 gchar *expr, const int size );
3054 /* #define HAVE_HFI_SECTION_INIT */
3056 #ifdef HAVE_HFI_SECTION_INIT
3057 #define HFI_INIT(proto) __attribute__((section( "_data_" G_STRINGIFY(proto)))) __attribute__((aligned(sizeof(void *))))
3059 #define proto_register_fields(proto, hfi, count) \
3061 extern header_field_info __start__data_ ##proto[]; \
3062 extern header_field_info __stop__data_ ##proto[]; \
3064 proto_register_fields_section(proto, __start__data_ ##proto, (int) (__stop__data_ ##proto - __start__data_ ##proto)); \
3067 #define HFI_INIT(proto)
3068 #define proto_register_fields(proto, hfi, count) \
3069 proto_register_fields_manual(proto, hfi, count)
3072 #ifdef NEW_PROTO_TREE_API
3073 #define proto_tree_add_item(tree, hfinfo, tvb, start, length, encoding) \
3074 proto_tree_add_item_new(tree, hfinfo, tvb, start, length, encoding)
3076 #define proto_tree_add_item_ret_length(tree, hfinfo, tvb, start, length, encoding, retval) \
3077 proto_tree_add_item_new_ret_length(tree, hfinfo, tvb, start, length, encoding, retval)
3079 #define proto_tree_add_boolean(tree, hfinfo, tvb, start, length, value) \
3080 proto_tree_add_boolean(tree, (hfinfo)->id, tvb, start, length, value)
3082 #define proto_tree_add_boolean_format(tree, hfinfo, tvb, start, length, value, format, ...) \
3083 proto_tree_add_boolean_format(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3085 #define proto_tree_add_string(tree, hfinfo, tvb, start, length, value) \
3086 proto_tree_add_string(tree, (hfinfo)->id, tvb, start, length, value)
3088 #define proto_tree_add_string_format(tree, hfinfo, tvb, start, length, value, format, ...) \
3089 proto_tree_add_string_format(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3091 #define proto_tree_add_item_ret_string(tree, hfinfo, tvb, start, length, encoding, scope, retval) \
3092 proto_tree_add_item_ret_string(tree, (hfinfo)->id, tvb, start, length, encoding, scope, retval)
3094 #define proto_tree_add_time(tree, hfinfo, tvb, start, length, value) \
3095 proto_tree_add_time(tree, (hfinfo)->id, tvb, start, length, value)
3097 #define proto_tree_add_int(tree, hfinfo, tvb, start, length, value) \
3098 proto_tree_add_int(tree, (hfinfo)->id, tvb, start, length, value)
3100 #define proto_tree_add_int_format(tree, hfinfo, tvb, start, length, value, format, ...) \
3101 proto_tree_add_int_format(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3103 #define proto_tree_add_uint(tree, hfinfo, tvb, start, length, value) \
3104 proto_tree_add_uint(tree, (hfinfo)->id, tvb, start, length, value)
3106 #define proto_tree_add_uint_format(tree, hfinfo, tvb, start, length, value, format, ...) \
3107 proto_tree_add_uint_format(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3109 #define proto_tree_add_uint_format_value(tree, hfinfo, tvb, start, length, value, format, ...) \
3110 proto_tree_add_uint_format_value(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3112 #define proto_tree_add_item_ret_uint(tree, hfinfo, tvb, start, length, encoding, retval) \
3113 proto_tree_add_item_ret_uint(tree, (hfinfo)->id, tvb, start, length, encoding, retval)
3115 #define proto_tree_add_uint64(tree, hfinfo, tvb, start, length, value) \
3116 proto_tree_add_uint64(tree, (hfinfo)->id, tvb, start, length, value)
3118 #define proto_tree_add_float(tree, hfinfo, tvb, start, length, value) \
3119 proto_tree_add_float(tree, (hfinfo)->id, tvb, start, length, value)
3121 #define proto_tree_add_float_format_value(tree, hfinfo, tvb, start, length, value, format, ...) \
3122 proto_tree_add_float_format_value(tree, (hfinfo)->id, tvb, start, length, value, format, __VA_ARGS__)
3124 #define proto_tree_add_double(tree, hfinfo, tvb, start, length, value) \
3125 proto_tree_add_double(tree, (hfinfo)->id, tvb, start, length, value)
3127 #define proto_tree_add_bytes_format(tree, hfinfo, tvb, start, length, format, ...) \
3128 proto_tree_add_bytes_format(tree, (hfinfo)->id, tvb, start, length, format, __VA_ARGS__)
3130 #define proto_tree_add_bytes_format_value(tree, hfinfo, tvb, start, length, format, ...) \
3131 proto_tree_add_bytes_format_value(tree, (hfinfo)->id, tvb, start, length, format, __VA_ARGS__)
3133 #define proto_tree_add_bitmask(tree, tvb, start, hfinfo, ett, fields, encoding) \
3134 proto_tree_add_bitmask(tree, tvb, start, (hfinfo)->id, ett, fields, encoding)
3136 #define proto_tree_add_bitmask_with_flags(tree, tvb, start, hfinfo, ett, fields, encoding, flags) \
3137 proto_tree_add_bitmask_with_flags(tree, tvb, start, (hfinfo)->id, ett, fields, encoding, flags)
3139 #define proto_tree_add_bitmask_with_flags_ret_uint64(tree, tvb, start, hfinfo, ett, fields, encoding, flags, retval) \
3140 proto_tree_add_bitmask_with_flags_ret_uint64(tree, tvb, start, (hfinfo)->id, ett, fields, encoding, flags, retval)
3142 #define proto_tree_add_none_format(tree, hfinfo, tvb, start, length, format, ...) \
3143 proto_tree_add_none_format(tree, (hfinfo)->id, tvb, start, length, format, __VA_ARGS__)
3145 #define proto_tree_add_checksum(tree, tvb, offset, hf_checksum, hf_checksum_status, \
3146 bad_checksum_expert, pinfo, computed_checksum, encoding, flags) \
3147 proto_tree_add_checksum(tree, tvb, offset, (hf_checksum)->id, hf_checksum_status, \
3148 bad_checksum_expert, pinfo, computed_checksum, encoding, flags)
3156 #endif /* __cplusplus */
3158 #endif /* proto.h */