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().
26 #include "wsutil/nstime.h"
28 #include "value_string.h"
29 #include "packet_info.h"
30 #include "ftypes/ftypes.h"
32 #include "ws_symbol_export.h"
33 #include "ws_attributes.h"
37 #endif /* __cplusplus */
39 /** @defgroup prototree The Protocol Tree
41 * Dissectors use proto_tree_add_* to add items to the protocol tree. In
42 * most cases you'll want to use proto_tree_add_item().
47 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
48 WS_DLL_PUBLIC
int hf_text_only
;
50 /** the maximum length of a protocol field string representation */
51 #define ITEM_LABEL_LENGTH 240
53 #define ITEM_LABEL_UNKNOWN_STR "Unknown"
57 /* Type-check that 'x' is compatible with 'type', should give compiler warnings otherwise. */
58 #define cast_same(type, x) (0 ? (type)0 : (x))
60 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
61 #define VALS(x) (cast_same(const struct _value_string*, (x)))
63 /** Make a const val64_string[] look like a _val64_string pointer, used to set header_field_info.strings */
64 #define VALS64(x) (cast_same(const struct _val64_string*, (x)))
66 /** Something to satisfy checkAPIs when you have a pointer to a value_string_ext (e.g., one built with value_string_ext_new()) */
67 #define VALS_EXT_PTR(x) (cast_same(value_string_ext*, (x)))
69 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
70 #define TFS(x) (cast_same(const struct true_false_string*, (x)))
72 /** Make a const unit_name_string[] look like a unit_name_string pointer, used to set header_field_info.strings */
73 #define UNS(x) (cast_same(const struct unit_name_string*, (x)))
75 typedef void (*custom_fmt_func_t
)(char *, uint32_t);
77 typedef void (*custom_fmt_func_64_t
)(char *, uint64_t);
79 typedef void (*custom_fmt_func_double_t
)(char *, double);
81 /** Make a custom format function pointer look like a void pointer. Used to set header_field_info.strings.
83 * We cast to size_t first, which 1) is guaranteed to be wide enough to
84 * hold a pointer and 2) lets us side-step warnings about casting function
85 * pointers to 'void *'. This violates ISO C but should be fine on POSIX
88 #define CF_FUNC(x) ((const void *) (size_t) (x))
90 /** Make a const range_string[] look like a _range_string pointer, used to set
91 * header_field_info.strings */
92 #define RVALS(x) (cast_same(const struct _range_string*, (x)))
94 /** Cast a ft_framenum_type_t, used to set header_field_info.strings */
95 #define FRAMENUM_TYPE(x) GINT_TO_POINTER(x)
99 /** Structure for information about a protocol */
100 typedef struct _protocol protocol_t
;
102 /** Function used for reporting errors in dissectors; it throws a
103 * DissectorError exception, with a string generated from the format
104 * and arguments to the format, as the message for the exception, so
105 * that it can show up in the Info column and the protocol tree.
107 * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
108 * it will call abort(), instead, to make it easier to get a stack trace.
110 * @param format format string to use for the message
112 WS_DLL_PUBLIC WS_NORETURN
113 void proto_report_dissector_bug(const char *format
, ...)
116 #define REPORT_DISSECTOR_BUG(...) \
117 proto_report_dissector_bug(__VA_ARGS__)
119 /** Macro used to provide a hint to static analysis tools.
120 * (Currently only Visual C++.)
123 /* XXX - Is there a way to say "quit checking at this point"? */
124 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
125 ; __analysis_assume(expression);
127 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
130 /** Macro used for assertions in dissectors; it doesn't abort, it just
131 * throws a DissectorError exception, with the assertion failure
132 * message as a parameter, so that it can show up in the protocol tree.
134 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
135 * conditions that shouldn't happen). It should NOT be used for showing
136 * that a packet is malformed. For that, use expert_infos instead.
138 * @param s expression to test in the assertion
141 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
143 #define __DISSECTOR_ASSERT(expression, file, lineno) \
144 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"%s\"", \
145 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression)))
147 #define __DISSECTOR_ASSERT_HINT(expression, file, lineno, hint) \
148 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"%s\" (%s)", \
149 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression), hint))
151 #define DISSECTOR_ASSERT(expression) \
152 ((void) ((expression) ? (void)0 : \
153 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
154 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
157 * Same as DISSECTOR_ASSERT(), but takes an extra 'hint' parameter that
158 * can be used to provide information as to why the assertion might fail.
160 * @param expression expression to test in the assertion
161 * @param hint message providing extra information
163 #define DISSECTOR_ASSERT_HINT(expression, hint) \
164 ((void) ((expression) ? (void)0 : \
165 __DISSECTOR_ASSERT_HINT (expression, __FILE__, __LINE__, hint))) \
166 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
169 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
170 * as the assert handling of GTK/GLib is currently not very helpful */
171 #define DISSECTOR_ASSERT(expression) \
172 { if(!(expression)) _asm { int 3}; }
175 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
176 * unconditionally, much like GLIB's g_assert_not_reached works.
178 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
179 * conditions that shouldn't happen). It should NOT be used for showing
180 * that a packet is malformed. For that, use expert_infos instead.
183 #define DISSECTOR_ASSERT_NOT_REACHED() \
184 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
187 /** Compare two integers.
189 * This is functionally the same as `DISSECTOR_ASSERT(a op b)` except that it
190 * will display the values of a and b upon failure.
192 * DISSECTOR_ASSERT_CMPINT(a, ==, b);
193 * DISSECTOR_ASSERT_CMPINT(min, <=, max);
195 * This function can currently compare values that fit inside a int64_t.
197 * WARNING: The number of times the arguments are evaluated is undefined. Do
198 * not use expressions with side effects as arguments.
200 * @param a The first integer.
201 * @param op Any binary operator.
202 * @param b The second integer.
203 * @param type the type operator
204 * @param fmt the fmt operator
206 #define __DISSECTOR_ASSERT_CMPINT(a, op, b, type, fmt) \
207 (REPORT_DISSECTOR_BUG("%s:%u: failed assertion " #a " " #op " " #b " (" fmt " " #op " " fmt ")", \
208 __FILE__, __LINE__, (type)a, (type)b))
210 #define DISSECTOR_ASSERT_CMPINT(a, op, b) \
211 ((void) ((a op b) ? (void)0 : \
212 __DISSECTOR_ASSERT_CMPINT (a, op, b, int64_t, "%" PRId64))) \
213 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
215 /** Like DISSECTOR_ASSERT_CMPINT() except the arguments are treated as
218 * This function can currently compare values that fit inside a uint64_t.
220 #define DISSECTOR_ASSERT_CMPUINT(a, op, b) \
221 ((void) ((a op b) ? (void)0 : \
222 __DISSECTOR_ASSERT_CMPINT (a, op, b, uint64_t, "%" PRIu64))) \
223 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
225 /** Like DISSECTOR_ASSERT_CMPUINT() except the values are displayed in
226 * hexadecimal upon assertion failure.
228 #define DISSECTOR_ASSERT_CMPUINTHEX(a, op, b) \
229 ((void) ((a op b) ? (void)0 : \
230 __DISSECTOR_ASSERT_CMPINT (a, op, b, uint64_t, "0x%" PRIX64))) \
231 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
234 * This is similar to DISSECTOR_ASSERT(hfinfo->type == type) except that
235 * it will report the name of the field with the wrong type as well as
238 * @param hfinfo The hfinfo for the field being tested
239 * @param type The type it's expected to have
241 #define __DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
242 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type "#t, \
243 __FILE__, __LINE__, (hfinfo)->abbrev))
245 #define DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
246 ((void) (((hfinfo)->type == t) ? (void)0 : \
247 __DISSECTOR_ASSERT_FIELD_TYPE ((hfinfo), t))) \
248 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == t)
250 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hfinfo) \
251 ((void) ((FT_IS_INTEGER((hfinfo)->type)) ? (void)0 : \
252 REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_CHAR or an FT_{U}INTn type", \
253 __FILE__, __LINE__, (hfinfo)->abbrev))) \
254 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(FT_IS_INTEGER((hfinfo)->type))
256 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
257 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_STRING, FT_STRINGZ, FT_STRINGZPAD, FT_STRINGZTRUNC, or FT_UINT_STRING", \
258 __FILE__, __LINE__, (hfinfo)->abbrev))
260 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
261 ((void) (FT_IS_STRING((hfinfo)->type) ? (void)0 : \
262 __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING ((hfinfo)))) \
263 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(FT_IS_STRING((hfinfo)->type))
265 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
266 (REPORT_DISSECTOR_BUG("%s:%u: field %s is not of type FT_ABSOLUTE_TIME or FT_RELATIVE_TIME", \
267 __FILE__, __LINE__, (hfinfo)->abbrev))
269 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
270 ((void) (((hfinfo)->type == FT_ABSOLUTE_TIME || \
271 (hfinfo)->type == FT_RELATIVE_TIME) ? (void)0 : \
272 __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME ((hfinfo)))) \
273 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == FT_ABSOLUTE_TIME || \
274 (hfinfo)->type == FT_RELATIVE_TIME)
277 * Encoding flags that apply to multiple data types.
280 * The encoding of a field of a particular type may involve more
281 * than just whether it's big-endian or little-endian and its size.
283 * For integral values, that's it, as 99.9999999999999% of the machines
284 * out there are 2's complement binary machines with 8-bit bytes,
285 * so the protocols out there expect that and, for example, any Unisys
286 * 2200 series machines out there just have to translate between 2's
287 * complement and 1's complement (and nobody's put any IBM 709x's on
288 * any networks lately :-)).
292 * for floating-point numbers, in addition to IEEE decimal
293 * floating-point, there's also IBM System/3x0 and PDP-11/VAX
294 * floating-point - most protocols use IEEE binary, but DCE RPC
295 * can use other formats if that's what the sending host uses;
297 * for character strings, there are various character encodings
298 * (various ISO 646 sets, ISO 8859/x, various other national
299 * standards, various DOS and Windows encodings, various Mac
300 * encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
303 * for absolute times, there's UNIX time_t, UNIX time_t followed
304 * by 32-bit microseconds, UNIX time_t followed by 32-bit
305 * nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
307 * We might also, in the future, want to allow a field specifier to
308 * indicate the encoding of the field, or at least its default
309 * encoding, as most fields in most protocols always use the
310 * same encoding (although that's not true of all fields, so we
311 * still need to be able to specify that at run time).
313 * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
314 * bit flags, to be combined, in the future, with other information
315 * to specify the encoding in the last argument to
316 * proto_tree_add_item(), and possibly to specify in a field
317 * definition (e.g., ORed in with the type value).
319 * Currently, proto_tree_add_item() treats its last argument as a
320 * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
321 * the field is little-endian - and other code in epan/proto.c does
322 * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and
323 * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
324 * so that we could put a field type and/or a value such as a character
325 * encoding in the lower bits.
327 #define ENC_BIG_ENDIAN 0x00000000
328 #define ENC_LITTLE_ENDIAN 0x80000000
330 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
331 #define ENC_HOST_ENDIAN ENC_LITTLE_ENDIAN
332 #define ENC_ANTI_HOST_ENDIAN ENC_BIG_ENDIAN
334 #define ENC_HOST_ENDIAN ENC_BIG_ENDIAN
335 #define ENC_ANTI_HOST_ENDIAN ENC_LITTLE_ENDIAN
339 * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
340 * opaque byte-array fields (FT_BYTES), and other fields where there
341 * is no choice of encoding (either because it's "just a bucket
342 * of bytes" or because the encoding is completely fixed), we
343 * have ENC_NA (for "Not Applicable").
345 #define ENC_NA 0x00000000
348 * Encoding for character strings - and for character-encoded values
349 * for non-string types.
351 * Historically, the only place the representation mattered for strings
352 * was with FT_UINT_STRINGs, where we had false for the string length
353 * being big-endian and true for it being little-endian.
355 * We now have encoding values for the character encoding. The encoding
356 * values are encoded in all but the top bit (which is the byte-order
357 * bit, required for FT_UINT_STRING and for UCS-2 and UTF-16 strings)
358 * and the bottom bit (which we ignore for now so that programs that
359 * pass true for the encoding just do ASCII).
361 * For ENC_ASCII, we map ASCII characters with the high bit set to the UTF-8
362 * REPLACEMENT CHARACTER, and do the same for ENC_UTF_8 with invalid UTF-8
363 * sequences. We should also map 0x00 to that as well - null-terminated and
364 * null-padded strings never have NULs in them, but counted strings might.
365 * Either that, or strings should be counted, not null-terminated. Note
366 * that conversion of ASCII and UTF-8 can change the length of the string,
367 * as with any other encoding, due to REPLACEMENT CHARACTERs.
369 * For display, perhaps we should also map control characters to the
370 * Unicode glyphs showing the name of the control character in small
371 * caps, diagonally. (Unfortunately, those only exist for C0, not C1.)
373 * *DO NOT* add anything to this set that is not a character encoding!
375 #define ENC_CHARENCODING_MASK 0x0000FFFE /* mask out byte-order bits and other bits used with string encodings */
376 #define ENC_ASCII 0x00000000
377 #define ENC_ISO_646_IRV ENC_ASCII /* ISO 646 International Reference Version = ASCII */
378 #define ENC_UTF_8 0x00000002
379 #define ENC_UTF_16 0x00000004
380 #define ENC_UCS_2 0x00000006
381 #define ENC_UCS_4 0x00000008
382 #define ENC_ISO_8859_1 0x0000000A
383 #define ENC_ISO_8859_2 0x0000000C
384 #define ENC_ISO_8859_3 0x0000000E
385 #define ENC_ISO_8859_4 0x00000010
386 #define ENC_ISO_8859_5 0x00000012
387 #define ENC_ISO_8859_6 0x00000014
388 #define ENC_ISO_8859_7 0x00000016
389 #define ENC_ISO_8859_8 0x00000018
390 #define ENC_ISO_8859_9 0x0000001A
391 #define ENC_ISO_8859_10 0x0000001C
392 #define ENC_ISO_8859_11 0x0000001E
393 /* #define ENC_ISO_8859_12 0x00000020 ISO 8859-12 was abandoned */
394 #define ENC_ISO_8859_13 0x00000022
395 #define ENC_ISO_8859_14 0x00000024
396 #define ENC_ISO_8859_15 0x00000026
397 #define ENC_ISO_8859_16 0x00000028
398 #define ENC_WINDOWS_1250 0x0000002A
399 #define ENC_3GPP_TS_23_038_7BITS_PACKED 0x0000002C
400 #define ENC_3GPP_TS_23_038_7BITS ENC_3GPP_TS_23_038_7BITS_PACKED
401 #define ENC_EBCDIC 0x0000002E
402 #define ENC_MAC_ROMAN 0x00000030
403 #define ENC_CP437 0x00000032
404 #define ENC_ASCII_7BITS 0x00000034
405 #define ENC_T61 0x00000036
406 #define ENC_EBCDIC_CP037 0x00000038
407 #define ENC_WINDOWS_1252 0x0000003A
408 #define ENC_WINDOWS_1251 0x0000003C
409 #define ENC_CP855 0x0000003E
410 #define ENC_CP866 0x00000040
411 #define ENC_ISO_646_BASIC 0x00000042
412 #define ENC_BCD_DIGITS_0_9 0x00000044 /* Packed BCD, digits 0-9 */
413 #define ENC_KEYPAD_ABC_TBCD 0x00000046 /* Keypad-with-a/b/c "telephony BCD" = 0-9, *, #, a, b, c */
414 #define ENC_KEYPAD_BC_TBCD 0x00000048 /* Keypad-with-B/C "telephony BCD" = 0-9, B, C, *, # */
415 #define ENC_3GPP_TS_23_038_7BITS_UNPACKED 0x0000004C
416 #define ENC_ETSI_TS_102_221_ANNEX_A 0x0000004E /* ETSI TS 102 221 Annex A */
417 #define ENC_GB18030 0x00000050
418 #define ENC_EUC_KR 0x00000052
419 #define ENC_APN_STR 0x00000054 /* The encoding the APN/DNN field follows 3GPP TS 23.003 [2] clause 9.1.*/
420 #define ENC_DECT_STANDARD_8BITS 0x00000056 /* DECT standard character set as defined in ETSI EN 300 175-5 Annex D */
421 #define ENC_DECT_STANDARD_4BITS_TBCD 0x00000058 /* DECT standard 4bits character set as defined in ETSI EN 300 175-5 Annex D (BCD with 0xb = SPACE)*/
422 #define ENC_EBCDIC_CP500 0x00000060
426 * packet-bacapp.c refers to two currently unsupported character sets (where
427 * we just use ASCII currently):
429 * "IBM MS DBCS" - At the very least could be any IBM/MS Double Byte
430 * Character Set for CJK (4 major ones), but also could just be any non
431 * Unicode and non ISO-8859-1 code page. This would be supported via the
432 * various code pages.
433 * JIS C 6226 / JIS X 0206 - Does this refer to ISO-2022-JP, SHIFT-JIS, or
434 * EUC-JP, which are all encoding schemes that support the JIS X 0206
437 * As those are added, change code such as the code in packet-bacapp.c
440 * There's also some other code (e.g., packet-smpp.c) that just ignores
441 * strings if it determines that they are in an unsupported encoding, such
442 * as various encodings of Japanese mentioned above, for example.
447 * This is a modifier for FT_UINT_STRING and FT_UINT_BYTES values;
448 * it indicates that the length field should be interpreted as per
449 * sections 2.5.2.11 Octet String through 2.5.2.14 Long Character
450 * String of the ZigBee Cluster Library Specification, where if all
451 * bits are set in the length field, the string has an invalid value,
452 * and the number of octets in the value is 0.
454 #define ENC_ZIGBEE 0x40000000
457 * This is a modifier for ENC_UTF_16, ENC_UCS_2, and ENC_UCS_4
458 * indicating that if the first two (or four, for UCS-4) octets
459 * are a big-endian or little-endian BOM, use that to determine
460 * the serialization order and ignore the ENC_LITTLE_ENDIAN or
461 * ENC_BIG_ENDIAN flag. This can't collide with ENC_ZIGBEE because
462 * it could be used simultaneously.
464 #define ENC_BOM 0x20000000
467 * For cases where either native type or string encodings could both be
468 * valid arguments, we need something to distinguish which one is being
469 * passed as the argument, because ENC_BIG_ENDIAN and ENC_ASCII are both
470 * 0x00000000. So we use ENC_STR_NUM or ENC_STR_HEX bit-or'ed with
471 * ENC_ASCII and its ilk.
473 * XXX - ENC_STR_NUM is not yet supported by any code in Wireshark,
474 * and these are only used for byte arrays. Presumably they could
475 * also be used for integral values in the future.
477 /* this is for strings as numbers "12345" */
478 #define ENC_STR_NUM 0x01000000
479 /* this is for strings as hex "1a2b3c" */
480 #define ENC_STR_HEX 0x02000000
481 /* a convenience macro for either of the above */
482 #define ENC_STRING 0x03000000
483 /* Kept around for compatibility for Lua scripts; code should use ENC_CHARENCODING_MASK */
484 #define ENC_STR_MASK 0x0000FFFE
487 * For cases where the number is allowed to have a leading '+'/'-'
488 * this can't collide with ENC_SEP_* because they can be used simultaneously
490 * XXX - this is not used anywhere in Wireshark's code, dating back to
491 * at least Wireshark 2.6 and continuing to the current version.
492 * Perhaps the intent was to use it in the future, but 1) I'm not sure
493 * why it would be combined with ENC_SEP_, as byte arrays have no sign
494 * but integral values do, and 2) if we were to support string encodings
495 * for integral types, presumably whether it's signed (FT_INTn) or
496 * unsigned (FT_UINTn) would suffice to indicate whether the value
497 * can be signed or not.
499 #define ENC_NUM_PREF 0x00200000
502 * Encodings for byte arrays.
504 * For cases where the byte array is encoded as a string composed of
505 * pairs of hex digits, possibly with a separator character between
506 * the pairs. That's specified by the encoding having ENC_STR_HEX,
507 * plus one of these values, set.
509 * See hex_str_to_bytes_encoding() in epan/strutil.h for details.
511 #define ENC_SEP_NONE 0x00010000
512 #define ENC_SEP_COLON 0x00020000
513 #define ENC_SEP_DASH 0x00040000
514 #define ENC_SEP_DOT 0x00080000
515 #define ENC_SEP_SPACE 0x00100000
516 /* a convenience macro for the above */
517 #define ENC_SEP_MASK 0x001F0000
519 /* Encodings for BCD strings
520 * Depending if the BCD string has even or odd number of digits
521 * we may need to strip of the last digit/High nibble
523 #define ENC_BCD_ODD_NUM_DIG 0x00010000
524 #define ENC_BCD_SKIP_FIRST 0x00020000
527 * Encodings for time values.
529 * Historically FT_TIMEs were only timespecs; the only question was whether
530 * they were stored in big- or little-endian format.
532 * For backwards compatibility, we interpret an encoding of 1 as meaning
533 * "little-endian timespec", so that passing true is interpreted as that.
537 * ENC_TIME_SECS_NSECS - 8, 12, or 16 bytes. For 8 bytes, the first 4
538 * bytes are seconds and the next 4 bytes are nanoseconds; for 12 bytes,
539 * the first 8 bytes are seconds and the next 4 bytes are nanoseconds;
540 * for 16 bytes, the first 8 bytes are seconds and the next 8 bytes are
541 * nanoseconds. If the time is absolute, the seconds are seconds since
542 * the UN*X epoch (1970-01-01 00:00:00 UTC). (I.e., a UN*X struct
543 * timespec with a 4-byte or 8-byte time_t or a structure with an
544 * 8-byte time_t and an 8-byte nanoseconds field.)
546 * ENC_TIME_NTP - 8 bytes; the first 4 bytes are seconds since the NTP
547 * epoch (1900-01-01 00:00:00 GMT) and the next 4 bytes are 1/2^32's of
548 * a second since that second. (I.e., a 64-bit count of 1/2^32's of a
549 * second since the NTP epoch, with the upper 32 bits first and the
550 * lower 32 bits second, even when little-endian.) A value of 0 is a
551 * special case representing unknown or unsynchronized time. Per the
552 * suggestion in RFC 4330, if bit 0 is not set then the time is assumed
553 * to be in NTP Era 1, beginning on 2036-02-07 06:28:16 UTC. (I.e., the
554 * time displayed will be between 1968-01-20 03:14:08 UTC and
555 * 2104-02-26 09:42:24 UTC.) The 16 byte NTP date format and the 4 byte
556 * NTP short relative time format are not supported.
557 * Encodings that store only the seconds since the NTP epoch without
558 * fractional seconds should use ENC_TIME_SECS_NTP, described below.
560 * ENC_TIME_TOD - 8 bytes, as a count of microseconds since the System/3x0
561 * and z/Architecture epoch (1900-01-01 00:00:00 GMT).
563 * ENC_TIME_RTPS - 8 bytes; the first 4 bytes are seconds since the UN*X
564 * epoch and the next 4 bytes are 1/2^32's of a second since that
565 * second. (I.e., it's the offspring of a mating between UN*X time and
566 * NTP time). It's used by the Object Management Group's Real-Time
567 * Publish-Subscribe Wire Protocol for the Data Distribution Service.
569 * ENC_TIME_SECS_USECS - 8 bytes; the first 4 bytes are seconds and the
570 * next 4 bytes are microseconds. If the time is absolute, the seconds
571 * are seconds since the UN*X epoch. (I.e., a UN*X struct timeval with
574 * ENC_TIME_SECS - 4 to 8 bytes, representing a value in seconds.
575 * If the time is absolute, it's seconds since the UN*X epoch.
577 * ENC_TIME_MSECS - 6 to 8 bytes, representing a value in milliseconds.
578 * If the time is absolute, it's milliseconds since the UN*X epoch.
580 * ENC_TIME_USECS - 8 bytes, representing a value in microseconds.
581 * If the time is absolute, it's microseconds since the UN*X epoch.
583 * ENC_TIME_NSECS - 8 bytes, representing a value in nanoseconds.
584 * If the time is absolute, it's nanoseconds since the UN*X epoch.
586 * ENC_TIME_SECS_NTP - 4 bytes, representing a count of seconds since
587 * the NTP epoch. As with ENC_TIME_NTP, times are assumed to be in
588 * the upper half of NTP Era 0 or the lower half of NTP Era 1.
590 * ENC_TIME_RFC_3971 - 8 bytes, representing a count of 1/64ths of a
591 * second since the UN*X epoch; see section 5.3.1 "Timestamp Option"
594 * ENC_TIME_MSEC_NTP - 6-8 bytes, representing a count of milliseconds since
595 * the NTP epoch. Similar to ENC_TIME_NTP, times before the midpoint of
596 * NTP Era 0 (1968-01-20) are assumed to represent the corresponding
597 * time in NTP Era 1 instead.
599 * ENC_TIME_MIP6 - 8 bytes; the first 48 bits are seconds since the UN*X epoch
600 * and the remaining 16 bits indicate the number of 1/65536's of a second
603 * ENC_TIME_MP4_FILE_SECS - 4-8 bytes, representing a count of seconds since
604 * January 1, 1904, 00:00:00 UTC.
606 * ENC_TIME_ZBEE_ZCL - 4-8 bytes, representing a count of seconds since
607 * January 1, 2000, 00:00:00 UTC.
609 #define ENC_TIME_SECS_NSECS 0x00000000
610 #define ENC_TIME_TIMESPEC 0x00000000 /* for backwards source compatibility */
611 #define ENC_TIME_NTP 0x00000002
612 #define ENC_TIME_TOD 0x00000004
613 #define ENC_TIME_RTPS 0x00000008
614 #define ENC_TIME_NTP_BASE_ZERO 0x00000008 /* for backwards source compatibility */
615 #define ENC_TIME_SECS_USECS 0x00000010
616 #define ENC_TIME_TIMEVAL 0x00000010 /* for backwards source compatibility */
617 #define ENC_TIME_SECS 0x00000012
618 #define ENC_TIME_MSECS 0x00000014
619 #define ENC_TIME_SECS_NTP 0x00000018
620 #define ENC_TIME_RFC_3971 0x00000020
621 #define ENC_TIME_MSEC_NTP 0x00000022
622 #define ENC_TIME_MIP6 0x00000024
623 #define ENC_TIME_MP4_FILE_SECS 0x00000026
624 #define ENC_TIME_CLASSIC_MAC_OS_SECS 0x00000026 /* for backwards source compatibility */
625 #define ENC_TIME_NSECS 0x00000028
626 #define ENC_TIME_USECS 0x00000030
627 #define ENC_TIME_ZBEE_ZCL 0x00000032
630 * For cases where a string encoding contains a timestamp, use one
631 * of these (but only one). These values can collide with the ENC_SEP_
632 * values used when a string encoding contains a byte array, because
633 * you can't do both at the same time. They must not, however,
634 * overlap with the character encoding values.
636 #define ENC_ISO_8601_DATE 0x00010000
637 #define ENC_ISO_8601_TIME 0x00020000
638 #define ENC_ISO_8601_DATE_TIME 0x00030000
639 #define ENC_IMF_DATE_TIME 0x00040000 /* Internet Message Format - RFCs 822, 1123, 2822, 5322 */
640 #define ENC_RFC_822 0x00040000 /* backwards compatibility */
641 #define ENC_RFC_1123 0x00040000 /* backwards source compatibility - not binary */
642 #define ENC_ISO_8601_DATE_TIME_BASIC 0x00100000
643 /* a convenience macro for the above - for internal use only */
644 #define ENC_STR_TIME_MASK 0x001F0000
647 * Encodings for variable-length integral types.
650 /* Use varint format as described in Protobuf protocol
651 * https://developers.google.cn/protocol-buffers/docs/encoding
653 #define ENC_VARINT_PROTOBUF 0x00000002
655 * Decodes a variable-length integer used in QUIC protocol
656 * See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-8.1
658 #define ENC_VARINT_QUIC 0x00000004
660 * Use "zig-zag" varint format as described in Protobuf protocol
661 * See https://developers.google.com/protocol-buffers/docs/encoding?csw=1#types
663 #define ENC_VARINT_ZIGZAG 0x00000008
665 * Decodes a variable-length integer used in DTN protocols
666 * See https://www.rfc-editor.org/rfc/rfc6256.html
668 #define ENC_VARINT_SDNV 0x00000010
670 #define ENC_VARINT_MASK (ENC_VARINT_PROTOBUF|ENC_VARINT_QUIC|ENC_VARINT_ZIGZAG|ENC_VARINT_SDNV)
672 /* Values for header_field_info.display */
674 /* For integral types, the display format is a BASE_* field_display_e value
675 * possibly ORed with BASE_*_STRING */
677 /** FIELD_DISPLAY_E_MASK selects the field_display_e value. */
678 #define FIELD_DISPLAY_E_MASK 0xFF
681 BASE_NONE
= 0, /**< none */
683 /* Integral and float types */
684 BASE_DEC
, /**< decimal [integer, float] */
685 BASE_HEX
, /**< hexadecimal [integer, float] */
686 BASE_OCT
, /**< octal [integer] */
687 BASE_DEC_HEX
, /**< decimal (hexadecimal) [integer] */
688 BASE_HEX_DEC
, /**< hexadecimal (decimal) [integer] */
689 BASE_CUSTOM
, /**< call custom routine to format [integer, float] */
690 BASE_EXP
, /**< exponential [float] */
692 /* Byte separators */
693 SEP_DOT
, /**< hexadecimal bytes with a period (.) between each byte */
694 SEP_DASH
, /**< hexadecimal bytes with a dash (-) between each byte */
695 SEP_COLON
, /**< hexadecimal bytes with a colon (:) between each byte */
696 SEP_SPACE
, /**< hexadecimal bytes with a space between each byte */
699 BASE_NETMASK
, /**< Used for IPv4 address that shouldn't be resolved (like for netmasks) */
702 BASE_PT_UDP
, /**< UDP port */
703 BASE_PT_TCP
, /**< TCP port */
704 BASE_PT_DCCP
, /**< DCCP port */
705 BASE_PT_SCTP
, /**< SCTP port */
708 BASE_OUI
, /**< OUI resolution */
711 ABSOLUTE_TIME_LOCAL
, /**< local time in our time zone, with month and day */
712 ABSOLUTE_TIME_UTC
, /**< UTC, with month and day */
713 ABSOLUTE_TIME_DOY_UTC
, /**< UTC, with 1-origin day-of-year */
714 ABSOLUTE_TIME_NTP_UTC
, /**< UTC, with "NULL" when timestamp is all zeros */
715 ABSOLUTE_TIME_UNIX
, /**< Unix time */
718 BASE_STR_WSP
, /**< Replace all whitespace characters (newline, formfeed, etc) with "space". */
721 #define FIELD_DISPLAY(d) ((d) & FIELD_DISPLAY_E_MASK)
723 #define FIELD_DISPLAY_IS_ABSOLUTE_TIME(d) \
724 (FIELD_DISPLAY(d) >= ABSOLUTE_TIME_LOCAL && FIELD_DISPLAY(d) <= ABSOLUTE_TIME_UNIX)
726 /* Following constants have to be ORed with a field_display_e when dissector
727 * want to use specials value-string MACROs for a header_field_info */
728 #define BASE_RANGE_STRING 0x00000100 /**< Use the supplied range string to convert the field to text */
729 #define BASE_EXT_STRING 0x00000200
730 #define BASE_VAL64_STRING 0x00000400
732 #define BASE_ALLOW_ZERO 0x00000800 /**< Display `<none>` instead of `<MISSING>` for zero sized byte array */
734 #define BASE_UNIT_STRING 0x00001000 /**< Add unit text to the field value */
736 #define BASE_NO_DISPLAY_VALUE 0x00002000 /**< Just display the field name with no value. Intended for
737 byte arrays or header fields above a subtree */
739 #define BASE_PROTOCOL_INFO 0x00004000 /**< protocol_t in [FIELDCONVERT]. Internal use only. */
741 #define BASE_SPECIAL_VALS 0x00008000 /**< field will not display "Unknown" if value_string match is not found */
743 #define BASE_SHOW_ASCII_PRINTABLE 0x00010000 /**< show byte array as ASCII if it's all printable characters */
745 #define BASE_SHOW_UTF_8_PRINTABLE 0x00020000 /**< show byte array as UTF-8 if it's all valid and printable UTF-8 characters */
747 /** BASE_ values that cause the field value to be displayed twice */
748 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
750 /** BASE_PT_ values display decimal and transport port service name */
751 #define IS_BASE_PORT(b) (((b)==BASE_PT_UDP||(b)==BASE_PT_TCP||(b)==BASE_PT_DCCP||(b)==BASE_PT_SCTP))
754 HF_REF_TYPE_NONE
, /**< Field is not referenced */
755 HF_REF_TYPE_INDIRECT
, /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
756 HF_REF_TYPE_DIRECT
, /**< Field is directly referenced */
757 HF_REF_TYPE_PRINT
/**< Field is directly referenced for printing (so don't fake its representation either) */
760 /** information describing a header field */
761 typedef struct _header_field_info header_field_info
;
763 /** information describing a header field */
764 struct _header_field_info
{
765 /* ---------- set by dissector --------- */
766 const char *name
; /**< [FIELDNAME] full name of this field */
767 const char *abbrev
; /**< [FIELDFILTERNAME] filter name of this field */
768 enum ftenum type
; /**< [FIELDTYPE] field type, one of FT_ (from ftypes.h) */
769 int display
; /**< [FIELDDISPLAY] one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
770 const void *strings
; /**< [FIELDCONVERT] value_string, val64_string, range_string or true_false_string,
771 typically converted by VALS(), RVALS() or TFS().
772 If this is an FT_PROTOCOL or BASE_PROTOCOL_INFO then it points to the
773 associated protocol_t structure */
774 uint64_t bitmask
; /**< [BITMASK] bitmask of interesting bits */
775 const char *blurb
; /**< [FIELDDESCR] Brief description of field */
777 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
778 int id
; /**< Field ID */
779 int parent
; /**< parent protocol tree */
780 hf_ref_type ref_type
; /**< is this field referenced by a filter */
781 int same_name_prev_id
; /**< ID of previous hfinfo with same abbrev */
782 header_field_info
*same_name_next
; /**< Link to next hfinfo with same abbrev */
786 * HFILL initializes all the "set by proto routines" fields in a
787 * _header_field_info. If new fields are added or removed, it should
788 * be changed as necessary.
790 #define HFILL -1, 0, HF_REF_TYPE_NONE, -1, NULL
792 #define HFILL_INIT(hf) \
793 (hf).hfinfo.id = -1; \
794 (hf).hfinfo.parent = 0; \
795 (hf).hfinfo.ref_type = HF_REF_TYPE_NONE; \
796 (hf).hfinfo.same_name_prev_id = -1; \
797 (hf).hfinfo.same_name_next = NULL;
799 /** Used when registering many fields at once, using proto_register_field_array() */
800 typedef struct hf_register_info
{
801 int *p_id
; /**< written to by register() function */
802 header_field_info hfinfo
; /**< the field info to be registered */
805 /** string representation, if one of the proto_tree_add_..._format() functions used */
806 typedef struct _item_label_t
{
807 char representation
[ITEM_LABEL_LENGTH
];
808 size_t value_pos
; /**< position of the value in the string */
809 size_t value_len
; /**< length of the value in the string */
812 /** Contains the field information for the proto_item. */
813 typedef struct field_info
{
814 const header_field_info
*hfinfo
; /**< pointer to registered field information */
815 int start
; /**< current start of data in field_info.ds_tvb */
816 int length
; /**< current data length of item in field_info.ds_tvb */
817 int appendix_start
; /**< start of appendix data */
818 int appendix_length
; /**< length of appendix data */
819 int tree_type
; /**< one of ETT_ or -1 */
820 uint32_t flags
; /**< bitfield like FI_GENERATED, ... */
821 item_label_t
*rep
; /**< string for GUI tree */
822 tvbuff_t
*ds_tvb
; /**< data source tvbuff */
824 int total_layer_num
; /**< Hierarchical layer number, for all protocols in the tree. */
825 int proto_layer_num
; /**< Protocol layer number, so 1st, 2nd, 3rd, ... for protocol X. */
830 * This structure describes one segment of a split-bits item
831 * crumb_bit_offset is the bit offset in the input tvb of the first (most significant) bit of this crumb
832 * crumb_bit_length is the number of contiguous bits of this crumb.
833 * The first element of an array of bits_specs describes the most significant crumb of the output value.
834 * The second element of an array of bits_specs describes the next-most significant crumb of the output value, etc.
835 * The array is terminated by a sentinel entry with crumb_bit_length of 0.
839 unsigned crumb_bit_offset
;
840 uint8_t crumb_bit_length
;
844 * Flag fields. Do not assign values greater than 0x000FFFFF unless you
845 * shuffle the expert information upward; see below.
848 /** The protocol field should not be shown in the tree (it's used for filtering only),
849 * used in field_info.flags. */
850 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
851 A user cannot tell by looking at the packet detail that the field exists
852 and that they can filter on its value. */
853 #define FI_HIDDEN 0x00000001
854 /** The protocol field should be displayed as "generated by Wireshark",
855 * used in field_info.flags. */
856 #define FI_GENERATED 0x00000002
857 /** The protocol field is actually a URL */
858 #define FI_URL 0x00000004
860 /** The protocol field value is in little endian */
861 #define FI_LITTLE_ENDIAN 0x00000008
862 /** The protocol field value is in big endian */
863 #define FI_BIG_ENDIAN 0x00000010
864 /** Field value start from nth bit (values from 0x20 - 0x100) */
865 #define FI_BITS_OFFSET(n) (((n) & 7) << 5)
866 /** Field value takes n bits (values from 0x100 - 0x4000) */
867 /* if 0, it means that field takes fi->length * 8 */
868 #define FI_BITS_SIZE(n) (((n) & 63) << 8)
869 /** The protocol field value is a varint */
870 #define FI_VARINT 0x00004000
872 /** convenience macro to get field_info.flags */
873 #define FI_GET_FLAG(fi, flag) ((fi) ? ((fi)->flags & (flag)) : 0)
874 /** convenience macro to set field_info.flags */
875 #define FI_SET_FLAG(fi, flag) \
878 (fi)->flags = (fi)->flags | (flag); \
880 /** convenience macro to reset field_info.flags */
881 #define FI_RESET_FLAG(fi, flag) \
884 (fi)->flags = (fi)->flags & ~(flag); \
887 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
888 #define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
890 /** One of these exists for the entire protocol tree. Each proto_node
891 * in the protocol tree points to the same copy. */
893 GHashTable
*interesting_hfids
;
897 struct _packet_info
*pinfo
;
900 /** Each proto_tree, proto_item is one of these. */
901 typedef struct _proto_node
{
902 struct _proto_node
*first_child
;
903 struct _proto_node
*last_child
;
904 struct _proto_node
*next
;
905 struct _proto_node
*parent
;
907 tree_data_t
*tree_data
;
910 /** A protocol tree element. */
911 typedef proto_node proto_tree
;
912 /** A protocol item element. */
913 typedef proto_node proto_item
;
916 * Expert information.
917 * This is in the flags field; we allocate this from the top down,
918 * so as not to collide with FI_ flags, which are allocated from
922 /* expert severities */
923 #define PI_SEVERITY_MASK 0x00F00000 /**< mask usually for internal use only! */
924 /** Packet comment */
925 #define PI_COMMENT 0x00100000
926 /** Usual workflow, e.g. TCP connection establishing */
927 #define PI_CHAT 0x00200000
928 /** Notable messages, e.g. an application returned an "unusual" error code like HTTP 404 */
929 #define PI_NOTE 0x00400000
930 /** Warning, e.g. application returned an "unusual" error code */
931 #define PI_WARN 0x00600000
932 /** Serious problems, e.g. a malformed packet */
933 #define PI_ERROR 0x00800000
935 /* expert "event groups" */
936 #define PI_GROUP_MASK 0xFF000000 /**< mask usually for internal use only! */
937 /** The protocol field has a bad checksum, usually uses PI_WARN severity */
938 #define PI_CHECKSUM 0x01000000
939 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
940 #define PI_SEQUENCE 0x02000000
941 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE severity */
942 #define PI_RESPONSE_CODE 0x03000000
943 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT severity */
944 #define PI_REQUEST_CODE 0x04000000
945 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN severity */
946 #define PI_UNDECODED 0x05000000
947 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT severity (or PI_ERROR) */
948 #define PI_REASSEMBLE 0x06000000
949 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR severity */
950 #define PI_MALFORMED 0x07000000
951 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR severity */
952 #define PI_DEBUG 0x08000000
953 /** The protocol field violates a protocol specification, usually PI_WARN severity */
954 #define PI_PROTOCOL 0x09000000
955 /** The protocol field indicates a security problem (e.g. insecure implementation) */
956 #define PI_SECURITY 0x0a000000
957 /** The protocol field indicates a packet comment */
958 #define PI_COMMENTS_GROUP 0x0b000000
959 /** The protocol field indicates a decryption problem */
960 #define PI_DECRYPTION 0x0c000000
961 /** The protocol field has incomplete data, decode based on assumed value */
962 #define PI_ASSUMPTION 0x0d000000
963 /** The protocol field has been deprecated, usually PI_NOTE severity */
964 #define PI_DEPRECATED 0x0e000000
965 /** Something happened as part of the receive process (CRC error, short/long frame, etc.) */
966 #define PI_RECEIVE 0x0f000000
967 /** Something happened at the interface layer (out of buffers, hardware error, etc.) */
968 #define PI_INTERFACE 0x10000000
969 /** A bug in a dissector was detected, usually PI_ERROR severity */
970 #define PI_DISSECTOR_BUG 0x11000000
974 * https://gitlab.com/wireshark/wireshark/-/wikis/Development/ExpertInfo
977 /** Retrieve the field_info from a proto_node */
978 #define PNODE_FINFO(proto_node) ((proto_node)->finfo)
980 /** Retrieve the field_info from a proto_item */
981 #define PITEM_FINFO(proto_item) PNODE_FINFO(proto_item)
983 /** Retrieve the field_info from a proto_tree */
984 #define PTREE_FINFO(proto_tree) PNODE_FINFO(proto_tree)
986 /** Retrieve the tree_data_t from a proto_tree */
987 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
989 /** Retrieve the wmem_allocator_t from a proto_node */
990 #define PNODE_POOL(proto_node) ((proto_node)->tree_data->pinfo->pool)
992 /** Is this protocol field hidden from the protocol tree display? Used for filtering only.
993 * Use with caution, HIDING PROTOCOL FIELDS IS CONSIDERED TO BE BAD GUI DESIGN!
994 * @param ti The item to check. May be NULL.
995 * @return true if the item is hidden, false otherwise.
997 static inline bool proto_item_is_hidden(proto_item
*ti
) {
999 return FI_GET_FLAG(PITEM_FINFO(ti
), FI_HIDDEN
);
1003 #define PROTO_ITEM_IS_HIDDEN(ti) proto_item_is_hidden((ti))
1005 /** Mark this protocol field to be hidden from the protocol tree display. Used for filtering only.
1006 * Use with caution, HIDING PROTOCOL FIELDS IS CONSIDERED TO BE BAD GUI DESIGN!
1007 * @param ti The item to hide. May be NULL.
1009 static inline void proto_item_set_hidden(proto_item
*ti
) {
1011 FI_SET_FLAG(PITEM_FINFO(ti
), FI_HIDDEN
);
1014 #define PROTO_ITEM_SET_HIDDEN(ti) proto_item_set_hidden((ti))
1016 /** Mark this protocol field to be visible from the protocol tree display.
1017 * @param ti The item to hide. May be NULL.
1019 static inline void proto_item_set_visible(proto_item
*ti
) {
1021 FI_RESET_FLAG(PITEM_FINFO(ti
), FI_HIDDEN
);
1024 #define PROTO_ITEM_SET_VISIBLE(ti) proto_item_set_visible((ti))
1026 /** Is this protocol field generated by Wireshark (and not read from the packet data)?
1027 * @param ti The item to check. May be NULL.
1028 * @return true if the item is generated, false otherwise.
1030 static inline bool proto_item_is_generated(proto_item
*ti
) {
1032 return FI_GET_FLAG(PITEM_FINFO(ti
), FI_GENERATED
);
1036 #define PROTO_ITEM_IS_GENERATED(ti) proto_item_is_generated((ti))
1038 /** Mark this protocol field as generated by Wireshark (and not read from the packet data).
1039 * @param ti The item to mark as generated. May be NULL.
1041 static inline void proto_item_set_generated(proto_item
*ti
) {
1043 FI_SET_FLAG(PITEM_FINFO(ti
), FI_GENERATED
);
1046 #define PROTO_ITEM_SET_GENERATED(ti) proto_item_set_generated((ti))
1048 /** Is this protocol field actually a URL?
1049 * @brief proto_item_is_url
1050 * @param ti The item to check. May be NULL.
1051 * @return true if the item is a URL, false otherwise.
1053 static inline bool proto_item_is_url(proto_item
*ti
) {
1055 return FI_GET_FLAG(PITEM_FINFO(ti
), FI_URL
);
1059 #define PROTO_ITEM_IS_URL(ti) proto_item_is_url((ti))
1061 /** Mark this protocol field as a URL
1062 * @param ti The item to mark as a URL. May be NULL.
1064 static inline void proto_item_set_url(proto_item
*ti
) {
1066 FI_SET_FLAG(PITEM_FINFO(ti
), FI_URL
);
1069 #define PROTO_ITEM_SET_URL(ti) proto_item_set_url((ti))
1071 typedef void (*proto_tree_foreach_func
)(proto_node
*, void *);
1072 typedef bool (*proto_tree_traverse_func
)(proto_node
*, void *);
1074 WS_DLL_PUBLIC
void proto_tree_children_foreach(proto_tree
*tree
,
1075 proto_tree_foreach_func func
, void *data
);
1078 void (*register_protoinfo
)(void); /* routine to call to register protocol information */
1079 void (*register_handoff
)(void); /* routine to call to register dissector handoff */
1082 /** Register dissector plugin with the plugin system. */
1083 WS_DLL_PUBLIC
void proto_register_plugin(const proto_plugin
*plugin
);
1085 /** Sets up memory used by proto routines. Called at program startup */
1086 void proto_init(GSList
*register_all_plugin_protocols_list
,
1087 GSList
*register_all_plugin_handoffs_list
, register_cb cb
, void *client_data
);
1089 /** Frees memory used by proto routines. Called at program shutdown */
1090 extern void proto_cleanup(void);
1092 /** This function takes a tree and a protocol id as parameter and
1093 will return true/false for whether the protocol or any of the filterable
1094 fields in the protocol is referenced by any filters.
1095 If this function returns false then it is safe to skip any
1096 proto_tree_add_...() calls and just treat the call as if the
1097 dissector was called with tree==NULL.
1098 If you reset the tree to NULL by this dissector returning false,
1099 you will still need to call any subdissector with the original value of
1100 tree or filtering will break.
1102 The purpose of this is to optimize wireshark for speed and make it
1103 faster for when filters are being used.
1105 WS_DLL_PUBLIC
bool proto_field_is_referenced(proto_tree
*tree
, int proto_id
);
1107 /** Create a subtree under an existing item.
1108 @param pi the parent item of the new subtree
1109 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1110 @return the new subtree */
1111 WS_DLL_PUBLIC proto_tree
* proto_item_add_subtree(proto_item
*pi
, const int idx
) G_GNUC_WARN_UNUSED_RESULT
;
1113 /** Get an existing subtree under an item.
1114 @param pi the parent item of the subtree
1115 @return the subtree or NULL */
1116 WS_DLL_PUBLIC proto_tree
* proto_item_get_subtree(proto_item
*pi
);
1118 /** Get the parent of a subtree item.
1119 @param pi the child item in the subtree
1120 @return parent item or NULL */
1121 WS_DLL_PUBLIC proto_item
* proto_item_get_parent(const proto_item
*pi
);
1123 /** Get Nth generation parent item.
1124 @param pi the child item in the subtree
1125 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
1126 @return parent item */
1127 WS_DLL_PUBLIC proto_item
* proto_item_get_parent_nth(proto_item
*pi
, int gen
);
1129 /** Replace text of item after it already has been created.
1130 @param pi the item to set the text
1131 @param format printf like format string
1132 @param ... printf like parameters */
1133 WS_DLL_PUBLIC
void proto_item_set_text(proto_item
*pi
, const char *format
, ...)
1136 /** Append to text of item after it has already been created.
1137 @param pi the item to append the text to
1138 @param format printf like format string
1139 @param ... printf like parameters */
1140 WS_DLL_PUBLIC
void proto_item_append_text(proto_item
*pi
, const char *format
, ...)
1143 /** Prepend to text of item after it has already been created.
1144 @param pi the item to prepend the text to
1145 @param format printf like format string
1146 @param ... printf like parameters */
1147 WS_DLL_PUBLIC
void proto_item_prepend_text(proto_item
*pi
, const char *format
, ...)
1150 /** Set proto_item's length inside tvb, after it has already been created.
1151 @param pi the item to set the length
1152 @param length the new length of the item */
1153 WS_DLL_PUBLIC
void proto_item_set_len(proto_item
*pi
, const int length
);
1156 * Sets the length of the item based on its start and on the specified
1157 * offset, which is the offset past the end of the item; as the start
1158 * in the item is relative to the beginning of the data source tvbuff,
1159 * we need to pass in a tvbuff.
1161 * Given an item created as:
1162 * ti = proto_tree_add_item(*, *, tvb, offset, -1, *);
1164 * proto_item_set_end(ti, tvb, end);
1166 * proto_item_set_len(ti, end - offset);
1168 @param pi the item to set the length
1169 @param tvb end is relative to this tvbuff
1170 @param end this end offset is relative to the beginning of tvb
1171 @todo make usage clearer, I don't understand it!
1173 WS_DLL_PUBLIC
void proto_item_set_end(proto_item
*pi
, tvbuff_t
*tvb
, int end
);
1175 /** Get length of a proto_item. Useful after using proto_tree_add_item()
1176 * to add a variable-length field (e.g., FT_UINT_STRING).
1177 @param pi the item to get the length from
1178 @return the current length */
1179 WS_DLL_PUBLIC
int proto_item_get_len(const proto_item
*pi
);
1181 /** Set the bit offset and length for the specified proto_item.
1182 * @param ti The item to set.
1183 * @param bits_offset The number of bits from the beginning of the field.
1184 * @param bits_len The new length in bits.
1186 WS_DLL_PUBLIC
void proto_item_set_bits_offset_len(proto_item
*ti
, int bits_offset
, int bits_len
);
1188 /** Get the display representation of a proto_item.
1189 * Can be used, for example, to append that to the parent item of
1191 @param scope the wmem scope to use to allocate the string
1192 @param pi the item from which to get the display representation
1193 @return the display representation */
1194 WS_DLL_PUBLIC
char *proto_item_get_display_repr(wmem_allocator_t
*scope
, proto_item
*pi
);
1196 /** Creates a new proto_tree root.
1197 @return the new tree root */
1198 extern proto_tree
* proto_tree_create_root(struct _packet_info
*pinfo
);
1200 void proto_tree_reset(proto_tree
*tree
);
1202 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
1203 @param tree the tree to free */
1204 WS_DLL_PUBLIC
void proto_tree_free(proto_tree
*tree
);
1206 /** Set the tree visible or invisible.
1207 Is the parsing being done for a visible proto_tree or an invisible one?
1208 By setting this correctly, the proto_tree creation is sped up by not
1209 having to call vsnprintf and copy strings around.
1210 @param tree the tree to be set
1211 @param visible ... or not
1212 @return the old value */
1214 proto_tree_set_visible(proto_tree
*tree
, bool visible
);
1216 /** Indicate whether we should fake protocols during dissection (default = true)
1217 @param tree the tree to be set
1218 @param fake_protocols true if we should fake protocols */
1220 proto_tree_set_fake_protocols(proto_tree
*tree
, bool fake_protocols
);
1222 /** Mark a field/protocol ID as "interesting".
1223 * That means that we don't fake the item (because we are filtering on it),
1224 * and we mark its parent protocol (if any) as being indirectly referenced
1225 * (so proto_field_is_referenced() will return true for the protocol as well.)
1226 @param tree the tree to be set (currently ignored)
1227 @param hfid the interesting field id */
1229 proto_tree_prime_with_hfid(proto_tree
*tree
, const int hfid
);
1231 /** Mark a field/protocol ID as something we want to print.
1232 * That means that we don't fake it, and we also don't hide it by
1233 * default even if the tree isn't visible.
1234 @param tree the tree to be set (currently ignored)
1235 @param hfid the field id */
1237 proto_tree_prime_with_hfid_print(proto_tree
*tree
, const int hfid
);
1239 /** Get a parent item of a subtree.
1240 @param tree the tree to get the parent from
1241 @return parent item */
1242 WS_DLL_PUBLIC proto_item
* proto_tree_get_parent(proto_tree
*tree
);
1244 /** Get the parent tree of a subtree.
1245 @param tree the tree to get the parent from
1246 @return parent tree */
1247 WS_DLL_PUBLIC proto_tree
*proto_tree_get_parent_tree(proto_tree
*tree
);
1249 /** Get the root tree from any subtree.
1250 @param tree the tree to get the root from
1251 @return root tree */
1252 WS_DLL_PUBLIC proto_tree
* proto_tree_get_root(proto_tree
*tree
);
1254 /** Move an existing item behind another existing item.
1255 @param tree the tree to which both items belong
1256 @param fixed_item the item which keeps its position
1257 @param item_to_move the item which will be moved */
1258 WS_DLL_PUBLIC
void proto_tree_move_item(proto_tree
*tree
, proto_item
*fixed_item
, proto_item
*item_to_move
);
1261 /** Set start and length of an appendix for a proto_tree.
1262 @param tree the tree to set the appendix start and length
1263 @param tvb the tv buffer of the current data
1264 @param start the start offset of the appendix
1265 @param length the length of the appendix */
1266 WS_DLL_PUBLIC
void proto_tree_set_appendix(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, const int length
);
1269 /** Add an item to a proto_tree, using the text label registered to that item.
1270 The item is extracted from the tvbuff handed to it.
1271 @param tree the tree to append this item to
1273 @param tvb the tv buffer of the current data
1274 @param start start of data in tvb
1275 @param length length of data in tvb
1276 @param encoding data encoding
1277 @return the newly created item */
1278 WS_DLL_PUBLIC proto_item
*
1279 proto_tree_add_item_new(proto_tree
*tree
, header_field_info
*hfinfo
, tvbuff_t
*tvb
,
1280 const int start
, int length
, const unsigned encoding
);
1282 WS_DLL_PUBLIC proto_item
*
1283 proto_tree_add_item(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1284 const int start
, int length
, const unsigned encoding
);
1286 /** Add an item to a proto_tree, using the text label registered to that item.
1287 The item is extracted from the tvbuff handed to it.
1289 Return the length of the item through the pointer.
1290 @param tree the tree to append this item to
1292 @param tvb the tv buffer of the current data
1293 @param start start of data in tvb
1294 @param length length of data in tvb
1295 @param encoding data encoding
1296 @param[out] lenretval points to a int that will be set to the item length
1297 @return the newly created item, and *lenretval is set to the item length */
1298 WS_DLL_PUBLIC proto_item
*
1299 proto_tree_add_item_new_ret_length(proto_tree
*tree
, header_field_info
*hfinfo
, tvbuff_t
*tvb
,
1300 const int start
, int length
, const unsigned encoding
, int *lenretval
);
1302 WS_DLL_PUBLIC proto_item
*
1303 proto_tree_add_item_ret_length(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1304 const int start
, int length
, const unsigned encoding
, int *lenretval
);
1306 /** Add an integer data item to a proto_tree, using the text label registered to that item.
1307 The item is extracted from the tvbuff handed to it, and the retrieved
1308 value is also set to *retval so the caller gets it back for other uses.
1310 This function retrieves the value even if the passed-in tree param is NULL,
1311 so that it can be used by dissectors at all times to both get the value
1312 and set the tree item to it.
1314 Like other proto_tree_add functions, if there is a tree and the value cannot
1315 be decoded from the tvbuff, then an expert info error is reported.
1317 This function accepts ENC_LITTLE_ENDIAN and ENC_BIG_ENDIAN for native number
1318 encoding in the tvbuff
1320 The length argument must
1321 be set to the appropriate size of the native type as in other proto_add routines.
1323 Integers of 8, 16, 24 and 32 bits can be retrieved with the _ret_int and
1324 ret_uint functions; integers of 40, 48, 56, and 64 bits can be retrieved
1325 with the _ret_uint64 function; Boolean values of 8, 16, 24, 32, 40, 48,
1326 56, and 64 bits can be retrieved with the _ret_boolean function.
1328 @param tree the tree to append this item to
1329 @param hfindex field
1330 @param tvb the tv buffer of the current data
1331 @param start start of data in tvb (cannot be negative)
1332 @param length length of data in tvb (for strings can be -1 for remaining)
1333 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_BIG_ENDIAN, ENC_ASCII|ENC_STRING, etc.)
1334 @param[out] retval points to a int32_t or uint32_t which will be set to the value
1335 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
1337 WS_DLL_PUBLIC proto_item
*
1338 proto_tree_add_item_ret_int(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1339 const int start
, int length
, const unsigned encoding
, int32_t *retval
);
1341 WS_DLL_PUBLIC proto_item
*
1342 proto_tree_add_item_ret_int64(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1343 const int start
, int length
, const unsigned encoding
, int64_t *retval
);
1345 WS_DLL_PUBLIC proto_item
*
1346 proto_tree_add_item_ret_uint(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1347 const int start
, int length
, const unsigned encoding
, uint32_t *retval
);
1349 WS_DLL_PUBLIC proto_item
*
1350 proto_tree_add_item_ret_uint64(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1351 const int start
, int length
, const unsigned encoding
, uint64_t *retval
);
1353 WS_DLL_PUBLIC proto_item
*
1354 proto_tree_add_item_ret_varint(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1355 const int start
, int length
, const unsigned encoding
, uint64_t *retval
, int *lenretval
);
1357 WS_DLL_PUBLIC proto_item
*
1358 proto_tree_add_item_ret_boolean(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1359 const int start
, int length
, const unsigned encoding
, bool *retval
);
1361 WS_DLL_PUBLIC proto_item
*
1362 proto_tree_add_item_ret_ipv4(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1363 const int start
, int length
, const unsigned encoding
, ws_in4_addr
*retval
);
1366 * @brief Parse an ipv6 address from the buffer and add it to the tree,
1367 * writing the value to the pointer specified by the caller. The pointer
1370 * @param tree the tree
1371 * @param hfindex the field
1372 * @param tvb the tv buffer
1373 * @param start the start index of data in tvb
1374 * @param length the length of data. calls REPORT_DISSECTOR_BUG if not equal to FT_IPv6_LEN
1375 * @param encoding encodings not yet supported. calls REPORT_DISSECTOR_BUG if not equal to 0
1376 * @param retval where the address should be written, must not be null
1377 * @return the newly created item
1379 WS_DLL_PUBLIC proto_item
*
1380 proto_tree_add_item_ret_ipv6(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1381 const int start
, int length
, const unsigned encoding
, ws_in6_addr
*retval
);
1384 * @brief Parse an ethernet address from the buffer and add it to the tree,
1385 * writing the value to the pointer specified by the caller. The pointer
1388 * @param tree the tree
1389 * @param hfindex the field
1390 * @param tvb the tv buffer
1391 * @param start the start index of data in tvb
1392 * @param length the length of data. calls REPORT_DISSECTOR_BUG if not equal to FT_ETHER_LEN
1393 * @param encoding encodings not yet supported. calls REPORT_DISSECTOR_BUG if not equal to 0
1394 * @param retval a buffer of at least FT_ETHER_LEN bytes for the address, must not be null
1395 * @return the newly created item
1397 WS_DLL_PUBLIC proto_item
*
1398 proto_tree_add_item_ret_ether(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1399 const int start
, int length
, const unsigned encoding
, uint8_t *retval
);
1402 * @brief Parse a float from the buffer and add it to the tree,
1403 * returning the item added and the parsed value via retval.
1405 * @param tree the tree
1406 * @param hfindex the field
1407 * @param tvb the tv buffer
1408 * @param start start index of data in tvb
1409 * @param length the length of data. calls REPORT_DISSECTOR_BUG if not equal to 4
1410 * @param encoding ENC_LITTLE_ENDIAN or ENC_BIG_ENDIAN
1411 * @param[out] retval for the decoded value
1412 * @return the newly created item
1414 WS_DLL_PUBLIC proto_item
*
1415 proto_tree_add_item_ret_float(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1416 const int start
, int length
,
1417 const unsigned encoding
, float *retval
);
1420 * @brief Parse a double from the buffer and add it to the tree,
1421 * returning the item added and the parsed value via retval
1423 * @param tree the tree
1424 * @param hfindex the field
1425 * @param tvb the tv buffer
1426 * @param start start index of data in tvb
1427 * @param length length of data. calls REPORT_DISSECTOR_BUG if not equal to 8
1428 * @param encoding ENC_LITTLE_ENDIAN or ENC_BIG_ENDIAN
1429 * @param[out] retval for the decoded value
1430 * @return the newly created item and retval is set to the decoded value
1432 WS_DLL_PUBLIC proto_item
*
1433 proto_tree_add_item_ret_double(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1434 const int start
, int length
,
1435 const unsigned encoding
, double *retval
);
1437 /** Add an string item to a proto_tree, using the text label registered to
1440 The item is extracted from the tvbuff handed to it, and the retrieved
1441 value and its length are returned through pointers so the caller can use
1442 them. The value is allocated using the wmem scope passed in.
1444 This function retrieves the value and length even if the passed-in tree
1445 param is NULL, so that then can be used by dissectors at all times to
1446 both get the value and set the tree item to it.
1448 Like other proto_tree_add functions, if there is a tree and the value cannot
1449 be decoded from the tvbuff, then an expert info error is reported.
1451 This function accepts string encodings.
1453 @param scope the wmem scope to use to allocate the string
1454 @param tree the tree to append this item to
1455 @param hfindex field
1456 @param tvb the tv buffer of the current data
1457 @param start start of data in tvb (cannot be negative)
1458 @param length length of data in tvb (for strings can be -1 for remaining)
1459 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1460 @param[out] retval points to a uint8_t * that will be set to point to the
1462 @param[out] lenretval points to a int that will be set to the item length
1463 @return the newly created item, *retval is set to the decoded value,
1464 and *lenretval is set to the item length
1466 WS_DLL_PUBLIC proto_item
*
1467 proto_tree_add_item_ret_string_and_length(proto_tree
*tree
, int hfindex
,
1468 tvbuff_t
*tvb
, const int start
, int length
, const unsigned encoding
,
1469 wmem_allocator_t
*scope
, const uint8_t **retval
, int *lenretval
);
1471 /** Add an string item to a proto_tree, using the text label registered to
1474 The item is extracted from the tvbuff handed to it, and the retrieved
1475 value is returned through a pointer so the caller can use it. The value
1476 is allocated using the wmem scope passed in.
1478 This function retrieves the value even if the passed-in tree param is NULL,
1479 so that it can be used by dissectors at all times to both get the value
1480 and set the tree item to it.
1482 Like other proto_tree_add functions, if there is a tree and the value cannot
1483 be decoded from the tvbuff, then an expert info error is reported.
1485 This function accepts string encodings.
1487 @param scope the wmem scope to use to allocate the string
1488 @param tree the tree to append this item to
1489 @param hfindex field
1490 @param tvb the tv buffer of the current data
1491 @param start start of data in tvb (cannot be negative)
1492 @param length length of data in tvb (for strings can be -1 for remaining)
1493 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1494 @param[out] retval points to a uint8_t * that will be set to point to the
1496 @return the newly created item, and *retval is set to the decoded value
1498 WS_DLL_PUBLIC proto_item
*
1499 proto_tree_add_item_ret_string(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1500 const int start
, int length
, const unsigned encoding
,
1501 wmem_allocator_t
*scope
, const uint8_t **retval
);
1503 /** Add an string or byte array item to a proto_tree, using the
1504 text label registered to that item.
1506 This provides a string that is a display representation of the value,
1507 and the length of the item, similar to what
1508 proto_tree_add_item_ret_string_and_length() does.
1510 @param scope the wmem scope to use to allocate the string
1511 @param tree the tree to append this item to
1512 @param hfindex field
1513 @param tvb the tv buffer of the current data
1514 @param start start of data in tvb (cannot be negative)
1515 @param length length of data in tvb (for strings can be -1 for remaining)
1516 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1517 @param[out] retval points to a uint8_t * that will be set to point to the
1519 @param[out] lenretval points to a int that will be set to the item length
1520 @return the newly created item, *retval is set to the display string,
1521 and *lenretval is set to the item length
1523 WS_DLL_PUBLIC proto_item
*
1524 proto_tree_add_item_ret_display_string_and_length(proto_tree
*tree
, int hfindex
,
1526 const int start
, int length
, const unsigned encoding
,
1527 wmem_allocator_t
*scope
, char **retval
, int *lenretval
);
1529 /** Add an string or byte array item to a proto_tree, using the
1530 text label registered to that item.
1532 This provides a string that is a display representation of the value,
1533 similar to what proto_tree_add_item_ret_string() does.
1535 @param tree the tree to append this item to
1536 @param hfindex field
1537 @param tvb the tv buffer of the current data
1538 @param start start of data in tvb (cannot be negative)
1539 @param length length of data in tvb (for strings can be -1 for remaining)
1540 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1541 @param scope the wmem scope to use to allocate the string
1542 @param[out] retval points to a uint8_t * that will be set to point to the
1544 @return the newly created item, *retval is set to the display string
1546 WS_DLL_PUBLIC proto_item
*
1547 proto_tree_add_item_ret_display_string(proto_tree
*tree
, int hfindex
,
1549 const int start
, int length
, const unsigned encoding
,
1550 wmem_allocator_t
*scope
, char **retval
);
1552 /** Add a time item to a proto_tree, using thetext label registered to that item.
1554 This provides a string that is a display representation of the time value
1556 @param tree the tree to append this item to
1557 @param hfindex field
1558 @param tvb the tv buffer of the current data
1559 @param start start of data in tvb (cannot be negative)
1560 @param length length of data in tvb (for strings can be -1 for remaining)
1561 @param encoding data encoding (e.g, ENC_ASCII, ENC_UTF_8, etc.)
1562 @param scope the wmem scope to use to allocate the string
1563 @param[out] retval points to a uint8_t * that will be set to point to the
1565 @return the newly created item, *retval is set to the display string
1567 WS_DLL_PUBLIC proto_item
*
1568 proto_tree_add_item_ret_time_string(proto_tree
*tree
, int hfindex
,
1570 const int start
, int length
, const unsigned encoding
,
1571 wmem_allocator_t
*scope
, char **retval
);
1573 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree.
1574 @param tree the tree to append this item to
1575 @param tvb the tv buffer of the current data
1576 @param start start of data in tvb
1577 @param length length of data in tvb
1578 @param format printf like format string
1579 @param ... printf like parameters
1580 @return the newly created item */
1582 proto_tree_add_text_internal(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, int length
, const char *format
,
1583 ...) G_GNUC_PRINTF(5,6);
1585 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree using a variable argument list.
1586 @param tree the tree to append this item to
1587 @param tvb the tv buffer of the current data
1588 @param start start of data in tvb
1589 @param length length of data in tvb
1590 @param format printf like format string
1591 @param ap variable argument list
1592 @return the newly created item */
1594 proto_tree_add_text_valist_internal(proto_tree
*tree
, tvbuff_t
*tvb
, int start
,
1595 int length
, const char *format
, va_list ap
) G_GNUC_PRINTF(5, 0);
1597 /** Add a text-only node that creates a subtree underneath.
1598 @param tree the tree to append this item to
1599 @param tvb the tv buffer of the current data
1600 @param start start of data in tvb
1601 @param length length of data in tvb
1602 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1603 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1604 @param text label for the tree
1605 @return the newly created tree */
1606 WS_DLL_PUBLIC proto_tree
*
1607 proto_tree_add_subtree(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, int length
, int idx
,
1608 proto_item
**tree_item
, const char *text
);
1610 /** Add a text-only node that creates a subtree underneath.
1611 @param tree the tree to append this item to
1612 @param tvb the tv buffer of the current data
1613 @param start start of data in tvb
1614 @param length length of data in tvb
1615 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1616 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1617 @param format printf like format string
1618 @param ... printf like parameters
1619 @return the newly created tree */
1620 WS_DLL_PUBLIC proto_tree
*
1621 proto_tree_add_subtree_format(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, int length
, int idx
,
1622 proto_item
**tree_item
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1624 /** Add a text-only node to a proto_tree with tvb_format_text() string. */
1626 proto_tree_add_format_text(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, int length
);
1628 /** Add a text-only node to a proto_tree with tvb_format_text_wsp() string. */
1630 proto_tree_add_format_wsp_text(proto_tree
*tree
, tvbuff_t
*tvb
, int start
, int length
);
1632 /** Add a FT_NONE field to a proto_tree.
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 format printf like format string
1639 @param ... printf like parameters
1640 @return the newly created item */
1641 WS_DLL_PUBLIC proto_item
*
1642 proto_tree_add_none_format(proto_tree
*tree
, const int hfindex
, tvbuff_t
*tvb
, const int start
,
1643 int length
, const char *format
, ...) G_GNUC_PRINTF(6,7);
1645 /** Add a FT_PROTOCOL to a proto_tree.
1646 @param tree the tree to append this item to
1647 @param hfindex field index
1648 @param tvb the tv buffer of the current data
1649 @param start start of data in tvb
1650 @param length length of data in tvb
1651 @param format printf like format string
1652 @param ... printf like parameters
1653 @return the newly created item */
1654 WS_DLL_PUBLIC proto_item
*
1655 proto_tree_add_protocol_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1656 int length
, const char *format
, ...) G_GNUC_PRINTF(6,7);
1658 /** Add a FT_BYTES to a proto_tree.
1659 @param tree the tree to append this item to
1660 @param hfindex field index
1661 @param tvb the tv buffer of the current data
1662 @param start start of data in tvb
1663 @param length length of data in tvb
1664 @param start_ptr pointer to the data to display
1665 @return the newly created item */
1666 WS_DLL_PUBLIC proto_item
*
1667 proto_tree_add_bytes(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1668 int length
, const uint8_t* start_ptr
);
1670 /** Add a FT_BYTES to a proto_tree like proto_tree_add_bytes,
1671 but used when the tvb data length does not match the bytes length.
1672 @param tree the tree to append this item to
1673 @param hfindex field index
1674 @param tvb the tv buffer of the current data
1675 @param start start of data in tvb
1676 @param length length of data in tvb
1677 @param start_ptr pointer to the data to display
1678 @param ptr_length length of data in start_ptr
1679 @return the newly created item */
1680 WS_DLL_PUBLIC proto_item
*
1681 proto_tree_add_bytes_with_length(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1682 int length
, const uint8_t *start_ptr
, int ptr_length
);
1684 /** Get and add a byte-array-based FT_* to a proto_tree.
1686 Supported: FT_BYTES, FT_UINT_BYTES, FT_OID, FT_REL_OID, and FT_SYSTEM_ID.
1688 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1689 in for the encoding, and the retrieved byte array is also set to *retval so the
1690 caller gets it back for other uses.
1692 This function retrieves the value even if the passed-in tree param is NULL,
1693 so that it can be used by dissectors at all times to both get the value
1694 and set the tree item to it.
1696 Like other proto_tree_add functions, if there is a tree and the value cannot
1697 be decoded from the tvbuff, then an expert info error is reported. For string
1698 encoding, this means that a failure to decode the hex value from the string
1699 results in an expert info error being added to the tree.
1701 If encoding is string-based, it will convert using tvb_get_string_bytes(); see
1702 that function's comments for details.
1704 @note The GByteArray retval must be pre-constructed using g_byte_array_new().
1706 @param tree the tree to append this item to
1707 @param hfindex field index
1708 @param tvb the tv buffer of the current data
1709 @param start start of data in tvb
1710 @param length length of data in tvb
1711 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, or ENC_UTF_8|ENC_STR_HEX)
1712 @param[in,out] retval points to a GByteArray which will be set to the bytes from the Tvb.
1713 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1714 @param[in,out] err if not NULL, gets set to 0 if no failure, else the errno code (e.g., EINVAL).
1715 @return the newly created item, and retval is set to the decoded value
1717 WS_DLL_PUBLIC proto_item
*
1718 proto_tree_add_bytes_item(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1719 const int start
, int length
, const unsigned encoding
,
1720 GByteArray
*retval
, int *endoff
, int *err
);
1722 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1723 the string for the value and with the field name being included
1725 @param tree the tree to append this item to
1726 @param hfindex field index
1727 @param tvb the tv buffer of the current data
1728 @param start start of data in tvb
1729 @param length length of data in tvb
1730 @param start_ptr pointer to the data to display
1731 @param format printf like format string
1732 @param ... printf like parameters
1733 @return the newly created item */
1734 WS_DLL_PUBLIC proto_item
*
1735 proto_tree_add_bytes_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1736 int start
, int length
, const uint8_t* start_ptr
, const char *format
,
1737 ...) G_GNUC_PRINTF(7,8);
1739 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1740 the entire string for the entry, including any field name.
1741 @param tree the tree to append this item to
1742 @param hfindex field index
1743 @param tvb the tv buffer of the current data
1744 @param start start of data in tvb
1745 @param length length of data in tvb
1746 @param start_ptr pointer to the data to display
1747 @param format printf like format string
1748 @param ... printf like parameters
1749 @return the newly created item */
1750 WS_DLL_PUBLIC proto_item
*
1751 proto_tree_add_bytes_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1752 int length
, const uint8_t* start_ptr
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1754 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1755 @param tree the tree to append this item to
1756 @param hfindex field index
1757 @param tvb the tv buffer of the current data
1758 @param start start of data in tvb
1759 @param length length of data in tvb
1760 @param value_ptr pointer to the data to display
1761 @return the newly created item */
1762 WS_DLL_PUBLIC proto_item
*
1763 proto_tree_add_time(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1764 int length
, const nstime_t
* value_ptr
);
1766 /** Get and add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1767 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1768 in for the encoding, and the retrieved value is also set to *retval so the
1769 caller gets it back for other uses.
1771 This function retrieves the value even if the passed-in tree param is NULL,
1772 so that it can be used by dissectors at all times to both get the value
1773 and set the tree item to it.
1775 Like other proto_tree_add functions, if there is a tree and the value cannot
1776 be decoded from the tvbuff, then an expert info error is reported. For string
1777 encoding, this means that a failure to decode the time value from the string
1778 results in an expert info error being added to the tree.
1780 If encoding is string-based, it will convert using tvb_get_string_time(); see
1781 that function's comments for details.
1783 @note The nstime_t *retval must be pre-allocated as a nstime_t.
1785 @param tree the tree to append this item to
1786 @param hfindex field index
1787 @param tvb the tv buffer of the current data
1788 @param start start of data in tvb
1789 @param length length of data in tvb
1790 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_UTF_8|ENC_ISO_8601_DATE_TIME, etc.)
1791 @param[in,out] retval points to a nstime_t which will be set to the value
1792 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1793 @param[in,out] err if not NULL, gets set to 0 if no failure, else EINVAL.
1794 @return the newly created item, and retval is set to the decoded value
1796 WS_DLL_PUBLIC proto_item
*
1797 proto_tree_add_time_item(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1798 const int start
, int length
, const unsigned encoding
,
1799 nstime_t
*retval
, int *endoff
, int *err
);
1802 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1803 the format generating the string for the value and with the field name
1804 being included automatically.
1805 @param tree the tree to append this item to
1806 @param hfindex field index
1807 @param tvb the tv buffer of the current data
1808 @param start start of data in tvb
1809 @param length length of data in tvb
1810 @param value_ptr pointer to the data to display
1811 @param format printf like format string
1812 @param ... printf like parameters
1813 @return the newly created item */
1814 WS_DLL_PUBLIC proto_item
*
1815 proto_tree_add_time_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1816 int start
, int length
, nstime_t
* value_ptr
, const char *format
, ...)
1819 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1820 the format generating the entire string for the entry, including any field
1822 @param tree the tree to append this item to
1823 @param hfindex field index
1824 @param tvb the tv buffer of the current data
1825 @param start start of data in tvb
1826 @param length length of data in tvb
1827 @param value_ptr pointer to the data to display
1828 @param format printf like format string
1829 @param ... printf like parameters
1830 @return the newly created item */
1831 WS_DLL_PUBLIC proto_item
*
1832 proto_tree_add_time_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1833 int length
, nstime_t
* value_ptr
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1835 /** Add a FT_IPXNET to a proto_tree.
1836 @param tree the tree to append this item to
1837 @param hfindex field index
1838 @param tvb the tv buffer of the current data
1839 @param start start of data in tvb
1840 @param length length of data in tvb
1841 @param value data to display
1842 @return the newly created item */
1843 WS_DLL_PUBLIC proto_item
*
1844 proto_tree_add_ipxnet(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1845 int length
, uint32_t value
);
1847 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1848 the string for the value and with the field name being included
1850 @param tree the tree to append this item to
1851 @param hfindex field index
1852 @param tvb the tv buffer of the current data
1853 @param start start of data in tvb
1854 @param length length of data in tvb
1855 @param value data to display
1856 @param format printf like format string
1857 @param ... printf like parameters
1858 @return the newly created item */
1859 WS_DLL_PUBLIC proto_item
*
1860 proto_tree_add_ipxnet_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1861 int start
, int length
, uint32_t value
, const char *format
, ...)
1864 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1865 the entire string for the entry, including any field name.
1866 @param tree the tree to append this item to
1867 @param hfindex field index
1868 @param tvb the tv buffer of the current data
1869 @param start start of data in tvb
1870 @param length length of data in tvb
1871 @param value data to display
1872 @param format printf like format string
1873 @param ... printf like parameters
1874 @return the newly created item */
1875 WS_DLL_PUBLIC proto_item
*
1876 proto_tree_add_ipxnet_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1877 int length
, uint32_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1879 /** Add a FT_IPv4 to a proto_tree.
1880 @param tree the tree to append this item to
1881 @param hfindex field index
1882 @param tvb the tv buffer of the current data
1883 @param start start of data in tvb
1884 @param length length of data in tvb
1885 @param value data to display
1886 @return the newly created item */
1887 WS_DLL_PUBLIC proto_item
*
1888 proto_tree_add_ipv4(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1889 int length
, ws_in4_addr value
);
1891 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1892 the string for the value and with the field name being included
1894 @param tree the tree to append this item to
1895 @param hfindex field index
1896 @param tvb the tv buffer of the current data
1897 @param start start of data in tvb
1898 @param length length of data in tvb
1899 @param value data to display
1900 @param format printf like format string
1901 @param ... printf like parameters
1902 @return the newly created item */
1903 WS_DLL_PUBLIC proto_item
*
1904 proto_tree_add_ipv4_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1905 int start
, int length
, ws_in4_addr value
, const char *format
, ...)
1908 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1909 the entire string for the entry, including any field name.
1910 @param tree the tree to append this item to
1911 @param hfindex field index
1912 @param tvb the tv buffer of the current data
1913 @param start start of data in tvb
1914 @param length length of data in tvb
1915 @param value data to display
1916 @param format printf like format string
1917 @param ... printf like parameters
1918 @return the newly created item */
1919 WS_DLL_PUBLIC proto_item
*
1920 proto_tree_add_ipv4_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1921 int length
, ws_in4_addr value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1923 /** Add a FT_IPv6 to a proto_tree.
1924 @param tree the tree to append this item to
1925 @param hfindex field index
1926 @param tvb the tv buffer of the current data
1927 @param start start of data in tvb
1928 @param length length of data in tvb
1929 @param value_ptr data to display
1930 @return the newly created item */
1931 WS_DLL_PUBLIC proto_item
*
1932 proto_tree_add_ipv6(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1933 int length
, const ws_in6_addr
*value_ptr
);
1935 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1936 the string for the value and with the field name being included
1938 @param tree the tree to append this item to
1939 @param hfindex field index
1940 @param tvb the tv buffer of the current data
1941 @param start start of data in tvb
1942 @param length length of data in tvb
1943 @param value_ptr data to display
1944 @param format printf like format string
1945 @param ... printf like parameters
1946 @return the newly created item */
1947 WS_DLL_PUBLIC proto_item
*
1948 proto_tree_add_ipv6_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1949 int start
, int length
, const ws_in6_addr
*value_ptr
, const char *format
,
1950 ...) G_GNUC_PRINTF(7,8);
1952 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1953 the entire string for the entry, including any field name.
1954 @param tree the tree to append this item to
1955 @param hfindex field index
1956 @param tvb the tv buffer of the current data
1957 @param start start of data in tvb
1958 @param length length of data in tvb
1959 @param value_ptr data to display
1960 @param format printf like format string
1961 @param ... printf like parameters
1962 @return the newly created item */
1963 WS_DLL_PUBLIC proto_item
*
1964 proto_tree_add_ipv6_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1965 int length
, const ws_in6_addr
*value_ptr
, const char *format
, ...) G_GNUC_PRINTF(7,8);
1967 /** Add a FT_ETHER to a proto_tree.
1968 @param tree the tree to append this item to
1969 @param hfindex field index
1970 @param tvb the tv buffer of the current data
1971 @param start start of data in tvb
1972 @param length length of data in tvb
1973 @param value data to display
1974 @return the newly created item */
1975 WS_DLL_PUBLIC proto_item
*
1976 proto_tree_add_ether(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
1977 int length
, const uint8_t* value
);
1979 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1980 the string for the value and with the field name being included
1982 @param tree the tree to append this item to
1983 @param hfindex field index
1984 @param tvb the tv buffer of the current data
1985 @param start start of data in tvb
1986 @param length length of data in tvb
1987 @param value data to display
1988 @param format printf like format string
1989 @param ... printf like parameters
1990 @return the newly created item */
1991 WS_DLL_PUBLIC proto_item
*
1992 proto_tree_add_ether_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
1993 int start
, int length
, const uint8_t* value
, const char *format
, ...)
1996 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1997 the entire string for the entry, including any field name.
1998 @param tree the tree to append this item to
1999 @param hfindex field index
2000 @param tvb the tv buffer of the current data
2001 @param start start of data in tvb
2002 @param length length of data in tvb
2003 @param value data to display
2004 @param format printf like format string
2005 @param ... printf like parameters
2006 @return the newly created item */
2007 WS_DLL_PUBLIC proto_item
*
2008 proto_tree_add_ether_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2009 int length
, const uint8_t* value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2011 /** Add a FT_GUID to a proto_tree.
2012 @param tree the tree to append this item to
2013 @param hfindex field index
2014 @param tvb the tv buffer of the current data
2015 @param start start of data in tvb
2016 @param length length of data in tvb
2017 @param value_ptr data to display
2018 @return the newly created item */
2019 WS_DLL_PUBLIC proto_item
*
2020 proto_tree_add_guid(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2021 int length
, const e_guid_t
*value_ptr
);
2023 /** Add a formatted FT_GUID to a proto_tree, with the format generating
2024 the string for the value and with the field name being included
2026 @param tree the tree to append this item to
2027 @param hfindex field index
2028 @param tvb the tv buffer of the current data
2029 @param start start of data in tvb
2030 @param length length of data in tvb
2031 @param value_ptr data to display
2032 @param format printf like format string
2033 @param ... printf like parameters
2034 @return the newly created item */
2035 WS_DLL_PUBLIC proto_item
*
2036 proto_tree_add_guid_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2037 int start
, int length
, const e_guid_t
*value_ptr
, const char *format
,
2038 ...) G_GNUC_PRINTF(7,8);
2040 /** Add a formatted FT_GUID to a proto_tree, with the format generating
2041 the entire string for the entry, including any field name.
2042 @param tree the tree to append this item to
2043 @param hfindex field index
2044 @param tvb the tv buffer of the current data
2045 @param start start of data in tvb
2046 @param length length of data in tvb
2047 @param value_ptr data to display
2048 @param format printf like format string
2049 @param ... printf like parameters
2050 @return the newly created item */
2051 WS_DLL_PUBLIC proto_item
*
2052 proto_tree_add_guid_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2053 int length
, const e_guid_t
*value_ptr
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2055 /** Add a FT_OID to a proto_tree.
2056 @param tree the tree to append this item to
2057 @param hfindex field index
2058 @param tvb the tv buffer of the current data
2059 @param start start of data in tvb
2060 @param length length of data in tvb
2061 @param value_ptr data to display
2062 @return the newly created item */
2063 WS_DLL_PUBLIC proto_item
*
2064 proto_tree_add_oid(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2065 int length
, const uint8_t* value_ptr
);
2067 /** Add a formatted FT_OID to a proto_tree, with the format generating
2068 the string for the value and with the field name being included
2070 @param tree the tree to append this item to
2071 @param hfindex field index
2072 @param tvb the tv buffer of the current data
2073 @param start start of data in tvb
2074 @param length length of data in tvb
2075 @param value_ptr data to display
2076 @param format printf like format string
2077 @param ... printf like parameters
2078 @return the newly created item */
2079 WS_DLL_PUBLIC proto_item
*
2080 proto_tree_add_oid_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2081 int start
, int length
, const uint8_t* value_ptr
, const char *format
,
2082 ...) G_GNUC_PRINTF(7,8);
2084 /** Add a formatted FT_OID to a proto_tree, with the format generating
2085 the entire string for the entry, including any field name.
2086 @param tree the tree to append this item to
2087 @param hfindex field index
2088 @param tvb the tv buffer of the current data
2089 @param start start of data in tvb
2090 @param length length of data in tvb
2091 @param value_ptr data to display
2092 @param format printf like format string
2093 @param ... printf like parameters
2094 @return the newly created item */
2095 WS_DLL_PUBLIC proto_item
*
2096 proto_tree_add_oid_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2097 int length
, const uint8_t* value_ptr
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2099 /** Add an FT_STRING, FT_STRINGZ, FT_STRINGZPAD, or FT_STRINGZTRUNC to a
2100 proto_tree. The value passed in should be a UTF-8 encoded null terminated
2101 string, such as produced by tvb_get_string_enc(), regardless of the original
2104 This function is used to add a custom string *value* to the protocol tree.
2105 Do not format the string value for display, for example by using format_text().
2106 The input string represents packet data, not a display label. Formatting
2107 labels is a concern of the UI. Doing that here would change the meaning of the packet
2108 data, restrict the options for formatting later and make display filtering unintuitive
2109 for whitespace and other special characters.
2111 @param tree the tree to append this item to
2112 @param hfindex field index
2113 @param tvb the tv buffer of the current data
2114 @param start start of data in tvb
2115 @param length length of data in tvb
2116 @param value data to display
2117 @return the newly created item */
2118 WS_DLL_PUBLIC proto_item
*
2119 proto_tree_add_string(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2120 int length
, const char* value
);
2122 /** Add a formatted FT_STRING, FT_STRINGZ, FT_STRINGZPAD, or FT_STRINGZTRUNC
2123 to a proto_tree, with the format generating the string for the value
2124 and with the field name being included automatically.
2125 @param tree the tree to append this item to
2126 @param hfindex field index
2127 @param tvb the tv buffer of the current data
2128 @param start start of data in tvb
2129 @param length length of data in tvb
2130 @param value data to display
2131 @param format printf like format string
2132 @param ... printf like parameters
2133 @return the newly created item */
2134 WS_DLL_PUBLIC proto_item
*
2135 proto_tree_add_string_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2136 int start
, int length
, const char* value
, const char *format
, ...)
2139 /** Add a formatted FT_STRING, FT_STRINGZ, FT_STRINGZPAD, or FT_STRINGZTRUNC
2140 to a proto_tree, with the format generating the entire string for the
2141 entry, including any field name.
2142 @param tree the tree to append this item to
2143 @param hfindex field index
2144 @param tvb the tv buffer of the current data
2145 @param start start of data in tvb
2146 @param length length of data in tvb
2147 @param value data to display
2148 @param format printf like format string
2149 @param ... printf like parameters
2150 @return the newly created item */
2151 WS_DLL_PUBLIC proto_item
*
2152 proto_tree_add_string_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2153 int length
, const char* value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2155 /** Add a FT_BOOLEAN to a proto_tree.
2156 @param tree the tree to append this item to
2157 @param hfindex field index
2158 @param tvb the tv buffer of the current data
2159 @param start start of data in tvb
2160 @param length length of data in tvb
2161 @param value data to display
2162 @return the newly created item */
2163 WS_DLL_PUBLIC proto_item
*
2164 proto_tree_add_boolean(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2165 int length
, uint64_t value
);
2167 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
2168 the string for the value and with the field name being included
2170 @param tree the tree to append this item to
2171 @param hfindex field index
2172 @param tvb the tv buffer of the current data
2173 @param start start of data in tvb
2174 @param length length of data in tvb
2175 @param value data to display
2176 @param format printf like format string
2177 @param ... printf like parameters
2178 @return the newly created item */
2179 WS_DLL_PUBLIC proto_item
*
2180 proto_tree_add_boolean_format_value(proto_tree
*tree
, int hfindex
,
2181 tvbuff_t
*tvb
, int start
, int length
, uint64_t value
,
2182 const char *format
, ...) G_GNUC_PRINTF(7,8);
2184 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
2185 the entire string for the entry, including any field name.
2186 @param tree the tree to append this item to
2187 @param hfindex field index
2188 @param tvb the tv buffer of the current data
2189 @param start start of data in tvb
2190 @param length length of data in tvb
2191 @param value data to display
2192 @param format printf like format string
2193 @param ... printf like parameters
2194 @return the newly created item */
2195 WS_DLL_PUBLIC proto_item
*
2196 proto_tree_add_boolean_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2197 int length
, uint64_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2199 /** Add a FT_FLOAT to a proto_tree.
2200 @param tree the tree to append this item to
2201 @param hfindex field index
2202 @param tvb the tv buffer of the current data
2203 @param start start of data in tvb
2204 @param length length of data in tvb
2205 @param value data to display
2206 @return the newly created item */
2207 WS_DLL_PUBLIC proto_item
*
2208 proto_tree_add_float(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2209 int length
, float value
);
2211 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
2212 the string for the value and with the field name being included
2214 @param tree the tree to append this item to
2215 @param hfindex field index
2216 @param tvb the tv buffer of the current data
2217 @param start start of data in tvb
2218 @param length length of data in tvb
2219 @param value data to display
2220 @param format printf like format string
2221 @param ... printf like parameters
2222 @return the newly created item */
2223 WS_DLL_PUBLIC proto_item
*
2224 proto_tree_add_float_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2225 int start
, int length
, float value
, const char *format
, ...)
2228 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
2229 the entire string for the entry, including any field name.
2230 @param tree the tree to append this item to
2231 @param hfindex field index
2232 @param tvb the tv buffer of the current data
2233 @param start start of data in tvb
2234 @param length length of data in tvb
2235 @param value data to display
2236 @param format printf like format string
2237 @param ... printf like parameters
2238 @return the newly created item */
2239 WS_DLL_PUBLIC proto_item
*
2240 proto_tree_add_float_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2241 int length
, float value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2243 /** Add a FT_DOUBLE to a proto_tree.
2244 @param tree the tree to append this item to
2245 @param hfindex field index
2246 @param tvb the tv buffer of the current data
2247 @param start start of data in tvb
2248 @param length length of data in tvb
2249 @param value data to display
2250 @return the newly created item */
2251 WS_DLL_PUBLIC proto_item
*
2252 proto_tree_add_double(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2253 int length
, double value
);
2255 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
2256 the string for the value and with the field name being included
2258 @param tree the tree to append this item to
2259 @param hfindex field index
2260 @param tvb the tv buffer of the current data
2261 @param start start of data in tvb
2262 @param length length of data in tvb
2263 @param value data to display
2264 @param format printf like format string
2265 @param ... printf like parameters
2266 @return the newly created item */
2267 WS_DLL_PUBLIC proto_item
*
2268 proto_tree_add_double_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2269 int start
, int length
, double value
, const char *format
, ...)
2272 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
2273 the entire string for the entry, including any field name.
2274 @param tree the tree to append this item to
2275 @param hfindex field index
2276 @param tvb the tv buffer of the current data
2277 @param start start of data in tvb
2278 @param length length of data in tvb
2279 @param value data to display
2280 @param format printf like format string
2281 @param ... printf like parameters
2282 @return the newly created item */
2283 WS_DLL_PUBLIC proto_item
*
2284 proto_tree_add_double_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2285 int length
, double value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2287 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
2288 @param tree the tree to append this item to
2289 @param hfindex field index
2290 @param tvb the tv buffer of the current data
2291 @param start start of data in tvb
2292 @param length length of data in tvb
2293 @param value data to display
2294 @return the newly created item */
2295 WS_DLL_PUBLIC proto_item
*
2296 proto_tree_add_uint(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2297 int length
, uint32_t value
);
2299 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
2300 with the format generating the string for the value and with the field
2301 name being included automatically.
2302 @param tree the tree to append this item to
2303 @param hfindex field index
2304 @param tvb the tv buffer of the current data
2305 @param start start of data in tvb
2306 @param length length of data in tvb
2307 @param value data to display
2308 @param format printf like format string
2309 @param ... printf like parameters
2310 @return the newly created item */
2311 WS_DLL_PUBLIC proto_item
*
2312 proto_tree_add_uint_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2313 int start
, int length
, uint32_t value
, const char *format
, ...)
2316 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
2317 with the format generating the entire string for the entry, including any
2319 @param tree the tree to append this item to
2320 @param hfindex field index
2321 @param tvb the tv buffer of the current data
2322 @param start start of data in tvb
2323 @param length length of data in tvb
2324 @param value data to display
2325 @param format printf like format string
2326 @param ... printf like parameters
2327 @return the newly created item */
2328 WS_DLL_PUBLIC proto_item
*
2329 proto_tree_add_uint_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2330 int length
, uint32_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2332 /** Add an FT_UINT64 to a proto_tree.
2333 @param tree the tree to append this item to
2334 @param hfindex field index
2335 @param tvb the tv buffer of the current data
2336 @param start start of data in tvb
2337 @param length length of data in tvb
2338 @param value data to display
2339 @return the newly created item */
2340 WS_DLL_PUBLIC proto_item
*
2341 proto_tree_add_uint64(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2342 int length
, uint64_t value
);
2344 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
2345 the string for the value and with the field name being included
2347 @param tree the tree to append this item to
2348 @param hfindex field index
2349 @param tvb the tv buffer of the current data
2350 @param start start of data in tvb
2351 @param length length of data in tvb
2352 @param value data to display
2353 @param format printf like format string
2354 @param ... printf like parameters
2355 @return the newly created item */
2356 WS_DLL_PUBLIC proto_item
*
2357 proto_tree_add_uint64_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2358 int start
, int length
, uint64_t value
, const char *format
, ...)
2361 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
2362 the entire string for the entry, including any field name.
2363 @param tree the tree to append this item to
2364 @param hfindex field index
2365 @param tvb the tv buffer of the current data
2366 @param start start of data in tvb
2367 @param length length of data in tvb
2368 @param value data to display
2369 @param format printf like format string
2370 @param ... printf like parameters
2371 @return the newly created item */
2372 WS_DLL_PUBLIC proto_item
*
2373 proto_tree_add_uint64_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2374 int length
, uint64_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2376 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
2377 @param tree the tree to append this item to
2378 @param hfindex field index
2379 @param tvb the tv buffer of the current data
2380 @param start start of data in tvb
2381 @param length length of data in tvb
2382 @param value data to display
2383 @return the newly created item */
2384 WS_DLL_PUBLIC proto_item
*
2385 proto_tree_add_int(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2386 int length
, int32_t value
);
2388 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
2389 with the format generating the string for the value and with the field
2390 name being included automatically.
2391 @param tree the tree to append this item to
2392 @param hfindex field index
2393 @param tvb the tv buffer of the current data
2394 @param start start of data in tvb
2395 @param length length of data in tvb
2396 @param value data to display
2397 @param format printf like format string
2398 @param ... printf like parameters
2399 @return the newly created item */
2400 WS_DLL_PUBLIC proto_item
*
2401 proto_tree_add_int_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2402 int start
, int length
, int32_t value
, const char *format
, ...)
2405 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
2406 with the format generating the entire string for the entry, including
2408 @param tree the tree to append this item to
2409 @param hfindex field index
2410 @param tvb the tv buffer of the current data
2411 @param start start of data in tvb
2412 @param length length of data in tvb
2413 @param value data to display
2414 @param format printf like format string
2415 @param ... printf like parameters
2416 @return the newly created item */
2417 WS_DLL_PUBLIC proto_item
*
2418 proto_tree_add_int_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2419 int length
, int32_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2421 /** Add an FT_INT64 to a proto_tree.
2422 @param tree the tree to append this item to
2423 @param hfindex field index
2424 @param tvb the tv buffer of the current data
2425 @param start start of data in tvb
2426 @param length length of data in tvb
2427 @param value data to display
2428 @return the newly created item */
2429 WS_DLL_PUBLIC proto_item
*
2430 proto_tree_add_int64(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2431 int length
, int64_t value
);
2433 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
2434 the string for the value and with the field name being included
2436 @param tree the tree to append this item to
2437 @param hfindex field index
2438 @param tvb the tv buffer of the current data
2439 @param start start of data in tvb
2440 @param length length of data in tvb
2441 @param value data to display
2442 @param format printf like format string
2443 @param ... printf like parameters
2444 @return the newly created item */
2445 WS_DLL_PUBLIC proto_item
*
2446 proto_tree_add_int64_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2447 int start
, int length
, int64_t value
, const char *format
, ...)
2450 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
2451 the entire string for the entry, including any field name.
2452 @param tree the tree to append this item to
2453 @param hfindex field index
2454 @param tvb the tv buffer of the current data
2455 @param start start of data in tvb
2456 @param length length of data in tvb
2457 @param value data to display
2458 @param format printf like format string
2459 @param ... printf like parameters
2460 @return the newly created item */
2461 WS_DLL_PUBLIC proto_item
*
2462 proto_tree_add_int64_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2463 int length
, int64_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2465 /** Add a FT_EUI64 to a proto_tree.
2466 @param tree the tree to append this item to
2467 @param hfindex field index
2468 @param tvb the tv buffer of the current data
2469 @param start start of data in tvb
2470 @param length length of data in tvb
2471 @param value data to display
2472 @return the newly created item */
2473 WS_DLL_PUBLIC proto_item
*
2474 proto_tree_add_eui64(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2475 int length
, const uint64_t value
);
2477 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
2478 the string for the value and with the field name being included
2480 @param tree the tree to append this item to
2481 @param hfindex field index
2482 @param tvb the tv buffer of the current data
2483 @param start start of data in tvb
2484 @param length length of data in tvb
2485 @param value data to display
2486 @param format printf like format string
2487 @param ... printf like parameters
2488 @return the newly created item */
2489 WS_DLL_PUBLIC proto_item
*
2490 proto_tree_add_eui64_format_value(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
,
2491 int start
, int length
, const uint64_t value
, const char *format
, ...)
2494 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
2495 the entire string for the entry, including any field name.
2496 @param tree the tree to append this item to
2497 @param hfindex field index
2498 @param tvb the tv buffer of the current data
2499 @param start start of data in tvb
2500 @param length length of data in tvb
2501 @param value data to display
2502 @param format printf like format string
2503 @param ... printf like parameters
2504 @return the newly created item */
2505 WS_DLL_PUBLIC proto_item
*
2506 proto_tree_add_eui64_format(proto_tree
*tree
, int hfindex
, tvbuff_t
*tvb
, int start
,
2507 int length
, const uint64_t value
, const char *format
, ...) G_GNUC_PRINTF(7,8);
2509 /** Structure used in proto_tree_add_mac48_detail below */
2510 typedef struct _mac_hf_list_t
{
2511 int *hf_addr
; // FT_ETHER, BASE_NONE
2512 int *hf_addr_resolved
; // FT_STRING, BASE_NONE
2513 int *hf_oui
; // FT_UINT24, BASE_OUI
2514 int *hf_oui_resolved
; // FT_STRING, BASE_NONE
2515 int *hf_lg
; // FT_BOOLEAN, 24 bits, mask 0x020000
2516 int *hf_ig
; // FT_BOOLEAN, 24 bits, mask 0x010000
2519 /** Add a MAC-48 (Ethernet) address to a proto_tree from the tvb.
2520 Handles full and OUI resolution, IG and LG bits, and hidden
2521 generic fields, all as a subtree of the address item.
2522 @param list_specific the mac_hf_list_t with field indexes for the specific addr type
2523 @param list_generic the mac_hf_list_t with field indexes for the generic addr type
2524 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
2525 @param tvb the tv buffer of the current data
2526 @param tree the tree to append this item to
2527 @param offset start of data in tvb representing the MAC-48 address */
2528 WS_DLL_PUBLIC proto_item
*
2529 proto_tree_add_mac48_detail(const mac_hf_list_t
*list_specific
,
2530 const mac_hf_list_t
*list_generic
,
2531 int idx
, tvbuff_t
*tvb
, proto_tree
*tree
, int offset
);
2533 /** Useful for quick debugging. Also sends string to STDOUT, so don't
2534 leave call to this function in production code.
2535 @param tree the tree to append the text to
2536 @param format printf like format string
2537 @param ... printf like parameters
2538 @return the newly created item */
2539 WS_DLL_PUBLIC proto_item
*
2540 proto_tree_add_debug_text(proto_tree
*tree
, const char *format
,
2541 ...) G_GNUC_PRINTF(2,3);
2543 /** Fill given label_str with a simple string representation of field.
2544 @param finfo the item to get the info from
2545 @param label_str the string to fill
2546 @param value_offset offset to the value in label_str
2547 @todo think about changing the parameter profile */
2549 proto_item_fill_label(const field_info
*finfo
, char *label_str
, size_t *value_offset
);
2551 /** Fill the given display_label_str with the string representation of a field
2552 * formatted according to its type and field display specifier.
2553 * Used to display custom columns and packet diagram values.
2554 @param fi The item to get the info from
2555 @param display_label_str The string to fill
2556 @return The length of the label excluding the terminating '\0'.
2559 proto_item_fill_display_label(const field_info
*fi
, char *display_label_str
, const int label_str_size
);
2561 /** Register a new protocol.
2562 @param name the full name of the new protocol
2563 @param short_name abbreviated name of the new protocol
2564 @param filter_name protocol name used for a display filter string
2565 @return the new protocol handle */
2567 proto_register_protocol(const char *name
, const char *short_name
, const char *filter_name
);
2569 /** Register a "helper" protocol (pino - protocol in name only).
2570 This is for dissectors that need distinguishing names and don't need the other
2571 features (like enable/disable). One use case is a protocol with multiple dissection
2572 functions in a single dissector table needing unique "dissector names" to remove
2573 confusion with Decode As dialog. Another use case is for a dissector table set
2574 up to handle TLVs within a single protocol (and allow "external" TLVs being
2575 registered through the dissector table).
2576 @param name the full name of the new protocol
2577 @param short_name abbreviated name of the new protocol
2578 @param filter_name protocol name used for a display filter string
2579 @param parent_proto the "real" protocol for the helper. The parent decides enable/disable
2580 @param field_type FT_PROTOCOL or FT_BYTES. Allows removal of "protocol highlighting" (FT_BYTES)
2581 if pino is part of TLV.
2582 @return the new protocol handle */
2584 proto_register_protocol_in_name_only(const char *name
, const char *short_name
, const char *filter_name
,
2585 int parent_proto
, enum ftenum field_type
);
2587 /** Deregister a protocol.
2588 This is only used internally for reloading Lua plugins and must not be used
2589 by dissectors or plugins.
2590 @param short_name abbreviated name of the protocol
2591 @return true if protocol is removed */
2593 proto_deregister_protocol(const char *short_name
);
2595 /** Register a protocol alias.
2596 This is for dissectors whose original name has changed, e.g. BOOTP to DHCP.
2597 @param proto_id protocol id returned by proto_register_protocol (0-indexed)
2598 @param alias_name alias for the protocol's filter name */
2600 proto_register_alias(const int proto_id
, const char *alias_name
);
2602 /** This type of function can be registered to get called whenever
2603 a given field was not found but a its prefix is matched;
2604 It can be used to procrastinate the hf array registration.
2605 @param match what's being matched */
2606 typedef void (*prefix_initializer_t
)(const char* match
);
2608 /** Register a new prefix for delayed initialization of field arrays
2609 Note that the initializer function MAY NOT be called before the dissector
2610 is first called. That is, dissectors using this function must be prepared
2611 to call the initializer before beginning dissection; they should do this by
2612 calling proto_registrar_get_byname() on one of the dissector's field names.
2613 @param prefix the prefix for the new protocol
2614 @param initializer function that will initialize the field array for the given prefix */
2616 proto_register_prefix(const char *prefix
, prefix_initializer_t initializer
);
2618 /** Initialize every remaining uninitialized prefix. */
2619 WS_DLL_PUBLIC
void proto_initialize_all_prefixes(void);
2621 /** Register a header_field array.
2622 @param parent the protocol handle from proto_register_protocol()
2623 @param hf the hf_register_info array
2624 @param num_records the number of records in hf */
2626 proto_register_field_array(const int parent
, hf_register_info
*hf
, const int num_records
);
2628 /** Deregister an already registered field.
2629 @param parent the protocol handle from proto_register_protocol()
2630 @param hf_id the field to deregister */
2632 proto_deregister_field (const int parent
, int hf_id
);
2634 /** Add data to be freed when deregistered fields are freed.
2635 @param data a pointer to data to free */
2637 proto_add_deregistered_data (void *data
);
2639 /** Add a memory slice to be freed when deregistered fields are freed.
2640 @param block_size the size of the block
2641 @param mem_block a pointer to the block to free */
2643 proto_add_deregistered_slice (size_t block_size
, void *mem_block
);
2645 /** Free strings in a field.
2646 @param field_type the field type (one of FT_ values)
2647 @param field_display field display value (one of BASE_ values)
2648 @param field_strings field strings */
2650 proto_free_field_strings (ftenum_t field_type
, unsigned int field_display
, const void *field_strings
);
2652 /** Free fields deregistered in proto_deregister_field(). */
2654 proto_free_deregistered_fields (void);
2656 /** Register a protocol subtree (ett) array.
2657 @param indices array of ett indices
2658 @param num_indices the number of records in indices */
2660 proto_register_subtree_array(int * const *indices
, const int num_indices
);
2662 /** Get name of registered header_field number n.
2663 @param n item # n (0-indexed)
2664 @return the name of this registered item */
2665 WS_DLL_PUBLIC
const char* proto_registrar_get_name(const int n
);
2667 /** Get abbreviation of registered header_field number n.
2668 @param n item # n (0-indexed)
2669 @return the abbreviation of this registered item */
2670 WS_DLL_PUBLIC
const char* proto_registrar_get_abbrev(const int n
);
2672 /** Get the header_field information based upon a field or protocol id.
2673 @param hfindex item # n (0-indexed)
2674 @return the registered item */
2675 WS_DLL_PUBLIC header_field_info
* proto_registrar_get_nth(unsigned hfindex
);
2677 /** Get the header_field information based upon a field name.
2678 @param field_name the field name to search for
2679 @return the registered item */
2680 WS_DLL_PUBLIC header_field_info
* proto_registrar_get_byname(const char *field_name
);
2682 /** Get the header_field information based upon a field alias.
2683 @param alias_name the aliased field name to search for
2684 @return the registered item */
2685 WS_DLL_PUBLIC header_field_info
* proto_registrar_get_byalias(const char *alias_name
);
2687 /** Get the header_field id based upon a field name.
2688 @param field_name the field name to search for
2689 @return the field id for the registered item */
2690 WS_DLL_PUBLIC
int proto_registrar_get_id_byname(const char *field_name
);
2692 /** Get enum ftenum FT_ of registered header_field number n.
2693 @param n item # n (0-indexed)
2694 @return the registered item */
2695 WS_DLL_PUBLIC
enum ftenum
proto_registrar_get_ftype(const int n
);
2697 /** Get parent protocol of registered header_field number n.
2698 @param n item # n (0-indexed)
2699 @return -1 if item _is_ a protocol */
2700 WS_DLL_PUBLIC
int proto_registrar_get_parent(const int n
);
2702 /** Is item # n a protocol?
2703 @param n item # n (0-indexed)
2704 @return true if it's a protocol, false if it's not */
2705 WS_DLL_PUBLIC
bool proto_registrar_is_protocol(const int n
);
2707 /** Get length of registered field according to field type.
2708 @param n item # n (0-indexed)
2709 @return 0 means undeterminable at registration time, -1 means unknown field */
2710 extern int proto_registrar_get_length(const int n
);
2713 /** Routines to use to iterate over the protocols and their fields;
2714 * they return the item number of the protocol in question or the
2715 * appropriate hfinfo pointer, and keep state in "*cookie". */
2716 WS_DLL_PUBLIC
int proto_get_first_protocol(void **cookie
);
2717 WS_DLL_PUBLIC
int proto_get_data_protocol(void *cookie
);
2718 WS_DLL_PUBLIC
int proto_get_next_protocol(void **cookie
);
2719 WS_DLL_PUBLIC header_field_info
*proto_get_first_protocol_field(const int proto_id
, void **cookie
);
2720 WS_DLL_PUBLIC header_field_info
*proto_get_next_protocol_field(const int proto_id
, void **cookie
);
2722 /** Check if a protocol name is already registered.
2723 @param name the name to search for
2725 WS_DLL_PUBLIC
bool proto_name_already_registered(const char *name
);
2727 /** Given a protocol's filter_name.
2728 @param filter_name the filter name to search for
2730 WS_DLL_PUBLIC
int proto_get_id_by_filter_name(const char* filter_name
);
2732 /** Given a protocol's short name.
2733 @param short_name the protocol short name to search for
2735 WS_DLL_PUBLIC
int proto_get_id_by_short_name(const char* short_name
);
2737 /** Can item # n decoding be disabled?
2738 @param proto_id protocol id (0-indexed)
2739 @return true if it's a protocol, false if it's not */
2740 WS_DLL_PUBLIC
bool proto_can_toggle_protocol(const int proto_id
);
2742 /** Get the "protocol_t" structure for the given protocol's item number.
2743 @param proto_id protocol id (0-indexed) */
2744 WS_DLL_PUBLIC protocol_t
*find_protocol_by_id(const int proto_id
);
2746 /** Get the protocol's name for the given protocol's item number.
2747 @param proto_id protocol id (0-indexed)
2749 WS_DLL_PUBLIC
const char *proto_get_protocol_name(const int proto_id
);
2751 /** Get the protocol's item number, for the given protocol's "protocol_t".
2752 @return its proto_id */
2753 WS_DLL_PUBLIC
int proto_get_id(const protocol_t
*protocol
);
2755 /** Get the protocol's short name, for the given protocol's "protocol_t".
2756 @return its short name. */
2757 WS_DLL_PUBLIC
const char *proto_get_protocol_short_name(const protocol_t
*protocol
);
2759 /** Get the protocol's long name, for the given protocol's "protocol_t".
2760 @return its long name. */
2761 WS_DLL_PUBLIC
const char *proto_get_protocol_long_name(const protocol_t
*protocol
);
2763 /** Is protocol's decoding enabled ?
2764 @return true if decoding is enabled, false if not */
2765 WS_DLL_PUBLIC
bool proto_is_protocol_enabled(const protocol_t
*protocol
);
2767 /** Is protocol's enabled by default (most are)?
2768 @return true if decoding is enabled by default, false if not */
2769 WS_DLL_PUBLIC
bool proto_is_protocol_enabled_by_default(const protocol_t
*protocol
);
2771 /** Is this a protocol in name only (i.e. not a real one)?
2772 @return true if helper, false if not */
2773 WS_DLL_PUBLIC
bool proto_is_pino(const protocol_t
*protocol
);
2775 /** Get a protocol's filter name by its item number.
2776 @param proto_id protocol id (0-indexed)
2777 @return its filter name. */
2778 WS_DLL_PUBLIC
const char *proto_get_protocol_filter_name(const int proto_id
);
2780 /** Associate a heuristic dissector with a protocol
2781 * INTERNAL USE ONLY!!!
2782 * @param protocol to associate the heuristic with
2783 * @param short_name heuristic dissector's short name
2785 extern void proto_add_heuristic_dissector(protocol_t
*protocol
, const char *short_name
);
2787 /** Apply func to all heuristic dissectors of a protocol
2788 * @param protocol to iterate over heuristics
2789 * @param func function to execute on heuristics
2790 * @param user_data user-specific data for function
2792 WS_DLL_PUBLIC
void proto_heuristic_dissector_foreach(const protocol_t
*protocol
, GFunc func
,
2795 /** Find commonly-used protocols in a layer list.
2796 * @param layers Protocol layer list
2797 * @param is_ip Set to true if the layer list contains IPv4 or IPv6, otherwise
2798 * unchanged. May be NULL.
2799 * @param is_tcp Set to true if the layer list contains TCP, otherwise
2800 * unchanged. May be NULL.
2801 * @param is_udp Set to true if the layer list contains UDP, otherwise
2802 * unchanged. May be NULL.
2803 * @param is_sctp Set to true if the layer list contains SCTP, otherwise
2804 * unchanged. May be NULL.
2805 * @param is_tls Set to true if the layer list contains SSL/TLS, otherwise
2806 * unchanged. May be NULL.
2807 * @param is_rtp Set to true if the layer list contains RTP, otherwise
2808 * unchanged. May be NULL.
2809 * @param is_lte_rlc Set to true if the layer list contains LTE RLC, otherwise
2810 * unchanged. May be NULL.
2812 WS_DLL_PUBLIC
void proto_get_frame_protocols(const wmem_list_t
*layers
,
2813 bool *is_ip
, bool *is_tcp
, bool *is_udp
, bool *is_sctp
,
2814 bool *is_tls
, bool *is_rtp
, bool *is_lte_rlc
);
2816 /** Check whether a protocol, specified by name, is in a layer list.
2817 * @param layers Protocol layer list
2818 * @param proto_name Name of protocol to find
2819 * @return true if the protocol is found, false if it isn't
2821 WS_DLL_PUBLIC
bool proto_is_frame_protocol(const wmem_list_t
*layers
, const char* proto_name
);
2823 /** Create a string of all layers in the packet.
2824 * @param pinfo Pointer to packet info
2825 * @return string of layer names
2827 WS_DLL_PUBLIC
char * proto_list_layers(const packet_info
*pinfo
);
2829 /** Mark protocol with the given item number as disabled by default.
2830 @param proto_id protocol id (0-indexed) */
2831 WS_DLL_PUBLIC
void proto_disable_by_default(const int proto_id
);
2833 /** Enable / Disable protocol of the given item number.
2834 @param proto_id protocol id (0-indexed)
2835 @param enabled enable / disable the protocol */
2836 WS_DLL_PUBLIC
void proto_set_decoding(const int proto_id
, const bool enabled
);
2838 /** Disable all protocols. */
2839 WS_DLL_PUBLIC
void proto_disable_all(void);
2841 /** Re-enable all protocols that are not marked as disabled by default. */
2842 WS_DLL_PUBLIC
void proto_reenable_all(void);
2844 /** Disable disabling/enabling of protocol of the given item number.
2845 @param proto_id protocol id (0-indexed) */
2846 WS_DLL_PUBLIC
void proto_set_cant_toggle(const int proto_id
);
2848 /** Checks for existence any protocol or field within a tree.
2849 @param tree "Protocols" are assumed to be a child of the [empty] root node.
2850 @param id hfindex of protocol or field
2851 @return true = found, false = not found
2852 @todo add explanation of id parameter */
2853 extern bool proto_check_for_protocol_or_field(const proto_tree
* tree
, const int id
);
2855 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2856 tree. Only works with primed trees, and is fast.
2857 @param tree tree of interest
2858 @param hfindex primed hfindex
2859 @return GPtrArray pointer
2861 The caller should *not* free the GPtrArray*; proto_tree_free_node()
2863 WS_DLL_PUBLIC GPtrArray
* proto_get_finfo_ptr_array(const proto_tree
*tree
, const int hfindex
);
2865 /** Return whether we're tracking any interesting fields.
2866 Only works with primed trees, and is fast.
2867 @param tree tree of interest
2868 @return true if we're tracking interesting fields */
2869 WS_DLL_PUBLIC
bool proto_tracking_interesting_fields(const proto_tree
*tree
);
2871 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2872 tree. Works with any tree, primed or unprimed, and is slower than
2873 proto_get_finfo_ptr_array because it has to search through the tree.
2874 @param tree tree of interest
2875 @param hfindex index of field info of interest
2876 @return GPtrArry pointer
2878 The caller does need to free the returned GPtrArray with
2879 g_ptr_array_free(<array>, true). */
2880 WS_DLL_PUBLIC GPtrArray
* proto_find_finfo(proto_tree
*tree
, const int hfindex
);
2882 /** Return GPtrArray* of field_info pointer for first hfindex that appear in
2883 tree. Works with any tree, primed or unprimed, and is slower than
2884 proto_get_finfo_ptr_array because it has to search through the tree.
2885 @param tree tree of interest
2886 @param hfindex index of field info of interest
2887 @return GPtrArry pointer
2889 The caller does need to free the returned GPtrArray with
2890 g_ptr_array_free(<array>, true). */
2891 WS_DLL_PUBLIC GPtrArray
* proto_find_first_finfo(proto_tree
*tree
, const int hfindex
);
2893 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
2895 @param tree tree of interest
2896 @return GPtrArry pointer
2898 The caller does need to free the returned GPtrArray with
2899 g_ptr_array_free(<array>, true). */
2900 WS_DLL_PUBLIC GPtrArray
* proto_all_finfos(proto_tree
*tree
);
2902 /** Dumps a glossary of the protocol registrations to STDOUT */
2903 WS_DLL_PUBLIC
void proto_registrar_dump_protocols(void);
2905 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
2906 WS_DLL_PUBLIC
void proto_registrar_dump_values(void);
2908 /** Dumps a mapping file for loading tshark output into ElasticSearch */
2909 WS_DLL_PUBLIC
void proto_registrar_dump_elastic(const char* filter
);
2911 /** Dumps the number of protocol and field registrations to STDOUT.
2912 @return false if we pre-allocated enough fields, true otherwise. */
2913 WS_DLL_PUBLIC
bool proto_registrar_dump_fieldcount(void);
2915 /** Dumps a glossary of the protocol and field registrations to STDOUT. */
2916 WS_DLL_PUBLIC
void proto_registrar_dump_fields(void);
2918 /** Dumps protocol and field abbreviations to STDOUT which start with prefix. */
2919 WS_DLL_PUBLIC
bool proto_registrar_dump_field_completions(const char *prefix
);
2921 /** Dumps a glossary field types and descriptive names to STDOUT */
2922 WS_DLL_PUBLIC
void proto_registrar_dump_ftypes(void);
2924 /** Get string representation of display field value
2925 @param field_display field display value (one of BASE_ values)
2926 @return string representation of display field value or "Unknown" if doesn't exist */
2927 WS_DLL_PUBLIC
const char* proto_field_display_to_string(int field_display
);
2929 /** Number of elements in the tree_is_expanded array. With MSVC and a
2930 * libwireshark.dll, we need a special declaration. */
2931 WS_DLL_PUBLIC
int num_tree_types
;
2933 /** Returns true if subtrees of that type are to be expanded. */
2934 WS_DLL_PUBLIC
bool tree_expanded(int tree_type
);
2936 /** Sets if subtrees of that type are to be expanded. */
2937 WS_DLL_PUBLIC
void tree_expanded_set(int tree_type
, bool value
);
2940 hfinfo_bitshift(const header_field_info
*hfinfo
);
2942 struct epan_dissect
;
2944 /** Can we do a "match selected" on this field.
2945 @param finfo field_info
2946 @param edt epan dissecting
2947 @return true if we can do a "match selected" on the field, false otherwise. */
2949 proto_can_match_selected(const field_info
*finfo
, struct epan_dissect
*edt
);
2951 /** Construct a "match selected" display filter string.
2952 @param finfo field_info
2953 @param edt epan dissecting
2954 @return the wmem NULL alloced display filter string. Needs to be freed with wmem_free(NULL, ...) */
2956 proto_construct_match_selected_string(const field_info
*finfo
, struct epan_dissect
*edt
);
2958 /** Find field from offset in tvb.
2959 @param tree tree of interest
2960 @param offset offset in the tvb
2961 @param tvb the tv buffer
2962 @return the corresponding field_info */
2963 WS_DLL_PUBLIC field_info
*
2964 proto_find_field_from_offset(proto_tree
*tree
, unsigned offset
, tvbuff_t
*tvb
);
2966 /** Find undecoded bytes in a tree
2967 @param tree tree of interest
2968 @param length the length of the frame
2969 @return an array to be used as bitmap of decoded bytes */
2971 proto_find_undecoded_data(proto_tree
*tree
, unsigned length
);
2973 /** This function will dissect a sequence of bytes that describe a bitmask.
2974 @param tree the tree to append this item to
2975 @param tvb the tv buffer of the current data
2976 @param offset start of data in tvb
2977 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
2978 bitmask to be dissected.
2979 This field will form an expansion under which the individual fields
2980 of the bitmask are dissected and displayed.
2981 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
2982 @param ett subtree index
2983 @param fields an array of pointers to int that lists all the fields of the
2984 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2985 or another integer of the same type/size as hf_hdr with a mask specified.
2986 This array is terminated by a NULL entry.
2987 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2988 FT_integer fields that have a value_string attached will have the
2989 matched string displayed on the expansion line.
2990 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2991 @return the newly created item */
2992 WS_DLL_PUBLIC proto_item
*
2993 proto_tree_add_bitmask(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
2994 const int hf_hdr
, const int ett
, int * const *fields
, const unsigned encoding
);
2996 /** This function will dissect a sequence of bytes that describe a bitmask.
2997 The value of the integer containing the bitmask is returned through
2999 @param tree the tree to append this item to
3000 @param tvb the tv buffer of the current data
3001 @param offset start of data in tvb
3002 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
3003 bitmask to be dissected.
3004 This field will form an expansion under which the individual fields
3005 of the bitmask are dissected and displayed.
3006 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
3007 @param ett subtree index
3008 @param fields an array of pointers to int that lists all the fields of the
3009 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3010 or another integer of the same type/size as hf_hdr with a mask specified.
3011 This array is terminated by a NULL entry.
3012 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3013 FT_integer fields that have a value_string attached will have the
3014 matched string displayed on the expansion line.
3015 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3016 @param[out] retval points to a uint64_t which will be set
3017 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask */
3018 WS_DLL_PUBLIC proto_item
*
3019 proto_tree_add_bitmask_ret_uint64(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3020 const int hf_hdr
, const int ett
, int * const *fields
,
3021 const unsigned encoding
, uint64_t *retval
);
3023 /** This function will dissect a sequence of bytes that describe a bitmask.
3024 This has "filterable" bitmask header functionality of proto_tree_add_bitmask
3025 with the ability to control what data is appended to the header like
3026 proto_tree_add_bitmask_text
3027 @param tree the tree to append this item to
3028 @param tvb the tv buffer of the current data
3029 @param offset start of data in tvb
3030 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
3031 bitmask to be dissected.
3032 This field will form an expansion under which the individual fields
3033 of the bitmask are dissected and displayed.
3034 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
3035 @param ett subtree index
3036 @param fields an array of pointers to int that lists all the fields of the
3037 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3038 or another integer of the same type/size as hf_hdr with a mask specified.
3039 This array is terminated by a NULL entry.
3040 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3041 FT_integer fields that have a value_string attached will have the
3042 matched string displayed on the expansion line.
3043 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3044 @param flags bitmask field using BMT_NO_* flags to determine behavior
3045 @return the newly created item */
3046 WS_DLL_PUBLIC proto_item
*
3047 proto_tree_add_bitmask_with_flags(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3048 const int hf_hdr
, const int ett
, int * const *fields
, const unsigned encoding
, const int flags
);
3050 /** This function will dissect a sequence of bytes that describe a bitmask.
3051 This has "filterable" bitmask header functionality of proto_tree_add_bitmask
3052 with the ability to control what data is appended to the header like
3053 proto_tree_add_bitmask_text
3054 The value of the integer containing the bitmask is returned through
3056 @param tree the tree to append this item to
3057 @param tvb the tv buffer of the current data
3058 @param offset start of data in tvb
3059 @param hf_hdr an 8/16/24/32/40/48/56/64 bit integer that describes the
3060 bitmask to be dissected.
3061 This field will form an expansion under which the individual fields
3062 of the bitmask are dissected and displayed.
3063 This field must be of the type FT_[U]INT{8|16|24|32|40|48|56|64}.
3064 @param ett subtree index
3065 @param fields an array of pointers to int that lists all the fields of the
3066 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3067 or another integer of the same type/size as hf_hdr with a mask specified.
3068 This array is terminated by a NULL entry.
3069 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3070 FT_integer fields that have a value_string attached will have the
3071 matched string displayed on the expansion line.
3072 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3073 @param flags bitmask field using BMT_NO_* flags to determine behavior
3074 @param[out] retval points to a uint64_t which will be set
3075 @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask */
3076 WS_DLL_PUBLIC proto_item
*
3077 proto_tree_add_bitmask_with_flags_ret_uint64(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3078 const int hf_hdr
, const int ett
, int * const *fields
,
3079 const unsigned encoding
, const int flags
, uint64_t *retval
);
3081 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
3082 but with a passed in value (presumably because it can't be retrieved directly from tvb)
3083 @param tree the tree to append this item to
3084 @param tvb the tv buffer of the current data
3085 @param offset start of data in tvb
3086 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
3087 This field will form an expansion under which the individual fields of the
3088 bitmask is dissected and displayed.
3089 This field must be of the type FT_[U]INT{8|16|24|32|64}.
3090 @param ett subtree index
3091 @param fields an array of pointers to int that lists all the fields of the
3092 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3093 or another integer of the same type/size as hf_hdr with a mask specified.
3094 This array is terminated by a NULL entry.
3095 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3096 FT_integer fields that have a value_string attached will have the
3097 matched string displayed on the expansion line.
3098 @param value bitmask value
3099 @return the newly created item */
3100 WS_DLL_PUBLIC proto_item
*
3101 proto_tree_add_bitmask_value(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3102 const int hf_hdr
, const int ett
, int * const *fields
, const uint64_t value
);
3104 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
3105 but with a passed in value (presumably because it can't be retrieved directly from tvb)
3106 This has "filterable" bitmask header functionality of proto_tree_add_bitmask_value
3107 with the ability to control what data is appended to the header like
3108 proto_tree_add_bitmask_text
3109 @param tree the tree to append this item to
3110 @param tvb the tv buffer of the current data
3111 @param offset start of data in tvb
3112 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
3113 This field will form an expansion under which the individual fields of the
3114 bitmask is dissected and displayed.
3115 This field must be of the type FT_[U]INT{8|16|24|32|64}.
3116 @param ett subtree index
3117 @param fields an array of pointers to int that lists all the fields of the
3118 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3119 or another integer of the same type/size as hf_hdr with a mask specified.
3120 This array is terminated by a NULL entry.
3121 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3122 FT_integer fields that have a value_string attached will have the
3123 matched string displayed on the expansion line.
3124 @param value bitmask value
3125 @param flags bitmask field using BMT_NO_* flags to determine behavior
3126 @return the newly created item */
3127 WS_DLL_PUBLIC proto_item
*
3128 proto_tree_add_bitmask_value_with_flags(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3129 const int hf_hdr
, const int ett
, int * const *fields
, const uint64_t value
, const int flags
);
3131 /** This function will dissect a sequence of bytes that describe a bitmask. Similar
3132 to proto_tree_add_bitmask(), but with no "header" item to group all of the fields
3133 @param tree the tree to append this item to
3134 @param tvb the tv buffer of the current data
3135 @param offset start of data in tvb
3136 @param len number of bytes of data
3137 @param fields an array of pointers to int that lists all the fields of the
3138 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3139 or another integer of the same type/size as hf_hdr with a mask specified.
3140 This array is terminated by a NULL entry.
3141 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3142 FT_integer fields that have a value_string attached will have the
3143 matched string displayed on the expansion line.
3144 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN) */
3146 proto_tree_add_bitmask_list(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3147 const int len
, int * const *fields
, const unsigned encoding
);
3149 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask_list(),
3150 but with a return value
3151 @param tree the tree to append this item to
3152 @param tvb the tv buffer of the current data
3153 @param offset start of data in tvb
3154 @param len number of bytes of data
3155 @param fields an array of pointers to int that lists all the fields of the
3156 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3157 or another integer of the same type/size as hf_hdr with a mask specified.
3158 This array is terminated by a NULL entry.
3159 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3160 FT_integer fields that have a value_string attached will have the
3161 matched string displayed on the expansion line.
3162 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3163 @param retval if a pointer is passed here the value is returned. */
3165 proto_tree_add_bitmask_list_ret_uint64(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3166 const int len
, int * const *fields
, const unsigned encoding
, uint64_t *retval
);
3168 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask_list(),
3169 but with a passed in value (presumably because it can't be retrieved directly from tvb)
3170 @param tree the tree to append this item to
3171 @param tvb the tv buffer of the current data
3172 @param offset start of data in tvb
3173 @param len number of bytes of data
3174 @param fields an array of pointers to int that lists all the fields of the
3175 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3176 or another integer of the same type/size as hf_hdr with a mask specified.
3177 This array is terminated by a NULL entry.
3178 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3179 FT_integer fields that have a value_string attached will have the
3180 matched string displayed on the expansion line.
3181 @param value bitmask value */
3183 proto_tree_add_bitmask_list_value(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3184 const int len
, int * const *fields
, const uint64_t value
);
3187 /** This function will dissect a sequence of bytes that describe a bitmask.
3188 @param tree the tree to append this item to
3189 @param tvb the tv buffer of the current data
3190 @param offset start of data in tvb
3191 @param len number of bytes of data
3192 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
3193 This field will form an expansion under which the individual fields of the
3194 bitmask are dissected and displayed.
3195 This field must be of the type FT_[U]INT{8|16|24|32}.
3196 @param ett subtree index
3197 @param fields an array of pointers to int that lists all the fields of the
3198 bitmask. These fields can be either of the type FT_BOOLEAN for flags
3199 or another integer with a mask specified.
3200 This array is terminated by a NULL entry.
3201 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
3202 FT_integer fields that have a value_string attached will have the
3203 matched string displayed on the expansion line.
3204 @param exp expert info field used when decodable_len < len. This also means this function
3205 should be called even when tree == NULL
3206 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3207 @return the newly created item */
3208 WS_DLL_PUBLIC proto_item
*
3209 proto_tree_add_bitmask_len(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
, const unsigned len
,
3210 const int hf_hdr
, const int ett
, int * const *fields
, struct expert_field
* exp
, const unsigned encoding
);
3212 /** Add a text with a subtree of bitfields.
3213 @param tree the tree to append this item to
3214 @param tvb the tv buffer of the current data
3215 @param offset start of data in tvb
3216 @param len length of the field name
3217 @param name field name (NULL if bitfield contents should be used)
3218 @param fallback field name if none of bitfields were usable
3219 @param ett subtree index
3220 @param fields NULL-terminated array of bitfield indexes
3221 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
3222 @param flags bitmask field
3223 @return the newly created item */
3224 WS_DLL_PUBLIC proto_item
*
3225 proto_tree_add_bitmask_text(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
, const unsigned len
,
3226 const char *name
, const char *fallback
,
3227 const int ett
, int * const *fields
, const unsigned encoding
, const int flags
);
3229 #define BMT_NO_FLAGS 0x00 /**< Don't use any flags */
3230 #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */
3231 #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */
3232 #define BMT_NO_FALSE 0x04 /**< Don't add booleans unless they're true */
3233 #define BMT_NO_TFS 0x08 /**< Don't use true_false_string while formatting booleans */
3235 /** Add bits to a proto_tree, using the text label registered to that item.
3236 The item is extracted from the tvbuff handed to it.
3237 @param tree the tree to append this item to
3238 @param hf_index field index. Fields for use with this function should have bitmask==0.
3239 @param tvb the tv buffer of the current data
3240 @param bit_offset start of data in tvb expressed in bits
3241 @param no_of_bits length of data in tvb expressed in bits
3242 @param encoding data encoding
3243 @return the newly created item */
3244 WS_DLL_PUBLIC proto_item
*
3245 proto_tree_add_bits_item(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
, const unsigned bit_offset
,
3246 const int no_of_bits
, const unsigned encoding
);
3248 /** Add bits to a proto_tree, using the text label registered to that item.
3249 * The item is extracted from the tvbuff handed to it as a set
3250 * of crumbs (segments) of contiguous bits, specified by an
3251 * array of crumb_spec elements. The crumbs are assembled to
3252 * create the value. There may be any number of crumbs
3253 * specifying up to a total of 64 bits which may occur anywhere
3254 * within the tvb. If the span of the crumbs within the tvb is 4
3255 * octets or less, a bitmap of the crumbs is produced.
3256 @param tree the tree to append this item to
3257 @param hf_index field index. Fields for use with this function should have bitmask==0.
3258 @param tvb the tv buffer of the current data
3259 @param bit_offset of the first crumb in tvb expressed in bits
3260 @param crumb_spec pointer to crumb_spec array
3261 @param return_value if a pointer is passed here the value is returned.
3262 @return the newly created item */
3263 WS_DLL_PUBLIC proto_item
*
3264 proto_tree_add_split_bits_item_ret_val(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3265 const unsigned bit_offset
, const crumb_spec_t
*crumb_spec
, uint64_t *return_value
);
3267 /** Add bitmap text for a split-bits crumb to a proto_tree,
3268 * using the text label registered to an item. The bitmap is
3269 * extracted from the tvbuff handed to it as a crumb (segment)
3270 * of contiguous bits, specified by one of an array of
3271 * crumb_spec elements. This function is normally called once
3272 * per crumb, after the call to
3273 proto_tree_add_split_bits_item_ret_val
3274 @param tree the tree to append this item to
3275 @param hf_index field index. Fields for use with this function should have bitmask==0.
3276 @param tvb the tv buffer of the current data
3277 @param bit_offset of the first crumb in tvb expressed in bits
3278 @param crumb_spec pointer to crumb_spec array
3279 @param crumb_index into the crumb_spec array for this crumb */
3281 proto_tree_add_split_bits_crumb(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3282 const unsigned bit_offset
, const crumb_spec_t
*crumb_spec
, uint16_t crumb_index
);
3284 /** Add bits to a proto_tree, using the text label registered to that item.
3285 The item is extracted from the tvbuff handed to it.
3286 @param tree the tree to append this item to
3287 @param hf_index field index. Fields for use with this function should have bitmask==0.
3288 @param tvb the tv buffer of the current data
3289 @param bit_offset start of data in tvb expressed in bits
3290 @param no_of_bits length of data in tvb expressed in bits
3291 @param return_value if a pointer is passed here the value is returned.
3292 @param encoding data encoding
3293 @return the newly created item */
3294 WS_DLL_PUBLIC proto_item
*
3295 proto_tree_add_bits_ret_val(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3296 const unsigned bit_offset
, const int no_of_bits
, uint64_t *return_value
, const unsigned encoding
);
3298 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
3299 header field to a proto_tree, with the format generating the
3300 string for the value and with the field name being included automatically.
3301 @param tree the tree to append this item to
3302 @param hf_index field index
3303 @param tvb the tv buffer of the current data
3304 @param bit_offset start of data in tvb expressed in bits
3305 @param no_of_bits length of data in tvb expressed in bit
3306 @param value data to display
3307 @param encoding data encoding
3308 @param format printf like format string
3309 @return the newly created item */
3310 WS_DLL_PUBLIC proto_item
*
3311 proto_tree_add_uint_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3312 const unsigned bit_offset
, const int no_of_bits
, uint32_t value
, const unsigned encoding
,
3313 const char *format
, ...)
3316 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
3317 header field to a proto_tree, with the format generating the
3318 string for the value and with the field name being included automatically.
3319 @param tree the tree to append this item to
3320 @param hf_index field index
3321 @param tvb the tv buffer of the current data
3322 @param bit_offset start of data in tvb expressed in bits
3323 @param no_of_bits length of data in tvb expressed in bit
3324 @param value data to display
3325 @param encoding data encoding
3326 @param format printf like format string
3327 @return the newly created item */
3328 WS_DLL_PUBLIC proto_item
*
3329 proto_tree_add_uint64_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3330 const unsigned bit_offset
, const int no_of_bits
, uint64_t value
, const unsigned encoding
,
3331 const char *format
, ...)
3334 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
3335 the format generating the string for the value and with the field
3336 name being included automatically.
3337 @param tree the tree to append this item to
3338 @param hf_index field index
3339 @param tvb the tv buffer of the current data
3340 @param bit_offset start of data in tvb expressed in bits
3341 @param no_of_bits length of data in tvb expressed in bit
3342 @param value data to display
3343 @param encoding data encoding
3344 @param format printf like format string
3345 @param ... printf like parameters
3346 @return the newly created item */
3348 proto_tree_add_boolean_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3349 const unsigned bit_offset
, const int no_of_bits
, uint64_t value
, const unsigned encoding
,
3350 const char *format
, ...)
3353 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
3354 header field to a proto_tree, with the format generating the
3355 string for the value and with the field name being included automatically.
3356 @param tree the tree to append this item to
3357 @param hf_index field index
3358 @param tvb the tv buffer of the current data
3359 @param bit_offset start of data in tvb expressed in bits
3360 @param no_of_bits length of data in tvb expressed in bit
3361 @param value data to display
3362 @param encoding data encoding
3363 @param format printf like format string
3364 @param ... printf like parameters
3365 @return the newly created item */
3367 proto_tree_add_int_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3368 const unsigned bit_offset
, const int no_of_bits
, int32_t value
, const unsigned encoding
,
3369 const char *format
, ...)
3372 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
3373 header field to a proto_tree, with the format generating the
3374 string for the value and with the field name being included automatically.
3375 @param tree the tree to append this item to
3376 @param hf_index field index
3377 @param tvb the tv buffer of the current data
3378 @param bit_offset start of data in tvb expressed in bits
3379 @param no_of_bits length of data in tvb expressed in bit
3380 @param value data to display
3381 @param encoding data encoding
3382 @param format printf like format string
3383 @param ... printf like parameters
3384 @return the newly created item */
3386 proto_tree_add_int64_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3387 const unsigned bit_offset
, const int no_of_bits
, int64_t value
, const unsigned encoding
,
3388 const char *format
, ...)
3391 /** Add bits for a FT_FLOAT header field to a proto_tree, with
3392 the format generating the string for the value and with the field
3393 name being included automatically.
3394 @param tree the tree to append this item to
3395 @param hf_index field index
3396 @param tvb the tv buffer of the current data
3397 @param bit_offset start of data in tvb expressed in bits
3398 @param no_of_bits length of data in tvb expressed in bit
3399 @param value data to display
3400 @param encoding data encoding
3401 @param format printf like format string
3402 @param ... printf like parameters
3403 @return the newly created item */
3405 proto_tree_add_float_bits_format_value(proto_tree
*tree
, const int hf_index
, tvbuff_t
*tvb
,
3406 const unsigned bit_offset
, const int no_of_bits
, float value
, const unsigned encoding
,
3407 const char *format
, ...)
3411 /** Add a FT_STRING with ENC_3GPP_TS_23_038_7BITS_PACKED encoding to a
3413 @param tree the tree to append this item to
3414 @param hfindex field index
3415 @param tvb the tv buffer of the current data
3416 @param bit_offset start of data in tvb expressed in bits
3417 @param no_of_chars number of 7bits characters to display
3418 @return the newly created item */
3419 WS_DLL_PUBLIC proto_item
*
3420 proto_tree_add_ts_23_038_7bits_packed_item(proto_tree
*tree
, const int hfindex
, tvbuff_t
*tvb
,
3421 const unsigned bit_offset
, const int no_of_chars
);
3423 /** Add a FT_STRING with ENC_ASCII_7BITS encoding to a proto_tree.
3424 @param tree the tree to append this item to
3425 @param hfindex field index
3426 @param tvb the tv buffer of the current data
3427 @param bit_offset start of data in tvb expressed in bits
3428 @param no_of_chars number of 7bits characters to display
3429 @return the newly created item */
3430 WS_DLL_PUBLIC proto_item
*
3431 proto_tree_add_ascii_7bits_item(proto_tree
*tree
, const int hfindex
, tvbuff_t
*tvb
,
3432 const unsigned bit_offset
, const int no_of_chars
);
3434 /** Add a checksum field to a proto_tree.
3435 This standardizes the display of a checksum field as well as any
3436 status and expert info supporting it.
3437 @param tree the tree to append this item to
3438 @param tvb the tv buffer of the current data
3439 @param offset start of data in tvb
3440 @param hf_checksum checksum field index
3441 @param hf_checksum_status optional checksum status field index. If none
3442 exists, just pass -1
3443 @param bad_checksum_expert optional expert info for a bad checksum. If
3444 none exists, just pass NULL
3445 @param pinfo Packet info used for optional expert info. If unused, NULL can
3447 @param computed_checksum Checksum to verify against
3448 @param encoding data encoding of checksum from tvb
3449 @param flags bitmask field of PROTO_CHECKSUM_ options
3450 @return the newly created item */
3451 WS_DLL_PUBLIC proto_item
*
3452 proto_tree_add_checksum(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3453 const int hf_checksum
, const int hf_checksum_status
, struct expert_field
* bad_checksum_expert
,
3454 packet_info
*pinfo
, uint32_t computed_checksum
, const unsigned encoding
, const unsigned flags
);
3456 /** Add a checksum bytes array field to a proto_tree.
3457 This standardizes the display of a checksum field as well as any
3458 status and expert info supporting it.
3459 @param tree the tree to append this item to
3460 @param tvb the tv buffer of the current data
3461 @param offset start of data in tvb
3462 @param hf_checksum checksum field index
3463 @param hf_checksum_status optional checksum status field index. If none
3464 exists, just pass -1
3465 @param bad_checksum_expert optional expert info for a bad checksum. If
3466 none exists, just pass NULL
3467 @param pinfo Packet info used for optional expert info. If unused, NULL can
3469 @param computed_checksum Checksum as bytes array to verify against
3470 @param checksum_len Checksum size in bytes
3471 @param flags bitmask field of PROTO_CHECKSUM_ options. PROTO_CHECKSUM_IN_CKSUM is ignored
3472 @return the newly created item */
3473 WS_DLL_PUBLIC proto_item
*
3474 proto_tree_add_checksum_bytes(proto_tree
*tree
, tvbuff_t
*tvb
, const unsigned offset
,
3475 const int hf_checksum
, const int hf_checksum_status
, struct expert_field
* bad_checksum_expert
,
3476 packet_info
*pinfo
, const uint8_t *computed_checksum
, size_t checksum_len
, const unsigned flags
);
3480 PROTO_CHECKSUM_E_BAD
= 0,
3481 PROTO_CHECKSUM_E_GOOD
,
3482 PROTO_CHECKSUM_E_UNVERIFIED
,
3483 PROTO_CHECKSUM_E_NOT_PRESENT
,
3484 PROTO_CHECKSUM_E_ILLEGAL
3485 } proto_checksum_enum_e
;
3487 #define PROTO_CHECKSUM_NO_FLAGS 0x00 /**< Don't use any flags */
3488 #define PROTO_CHECKSUM_VERIFY 0x01 /**< Compare against computed checksum */
3489 #define PROTO_CHECKSUM_GENERATED 0x02 /**< Checksum is generated only */
3490 #define PROTO_CHECKSUM_IN_CKSUM 0x04 /**< Internet checksum routine used for computation */
3491 #define PROTO_CHECKSUM_ZERO 0x08 /**< Computed checksum must be zero (but correct checksum can't be calculated) */
3492 #define PROTO_CHECKSUM_NOT_PRESENT 0x10 /**< Checksum field is not present (Just populates status field) */
3494 WS_DLL_PUBLIC
const value_string proto_checksum_vals
[];
3496 /** Check if given string is a valid field name
3497 @param field_name the field name to check
3498 @return 0 if valid, else first illegal character */
3499 WS_DLL_PUBLIC
unsigned char
3500 proto_check_field_name(const char *field_name
);
3502 /** Check if given string is a valid field name. Accepts only lower case
3504 @param field_name the field name to check
3505 @return 0 if valid, else first illegal character */
3506 WS_DLL_PUBLIC
unsigned char
3507 proto_check_field_name_lower(const char *field_name
);
3510 /** Set the column text for a custom column
3511 @param tree the tree to append this item to
3512 @param field_id the field ids used for custom column
3513 @param occurrence the occurrence of the field used for custom column
3514 @param display_details if true, use formatted field value
3515 @param result the buffer to fill with the field string
3516 @param expr the filter expression
3517 @param size the size of the string buffer */
3519 proto_custom_set(proto_tree
* tree
, GSList
*field_id
,
3521 bool display_details
,
3523 char *expr
, const int size
);
3525 /** Construct a display filter string for a custom column
3526 @param edt epan dissecting
3527 @param field_id the field ids used for custom column
3528 @param occurrence the occurrence of the field used for custom column
3529 @return allocated display filter string. Needs to be freed with g_free(...) */
3531 proto_custom_get_filter(struct epan_dissect
*edt
, GSList
*field_id
, int occurrence
);
3536 hfinfo_char_value_format_display(int display
, char buf
[7], uint32_t value
);
3540 #endif /* __cplusplus */
3542 #endif /* proto.h */
3545 * Editor modelines - https://www.wireshark.org/tools/modelines.html
3550 * indent-tabs-mode: nil
3553 * vi: set shiftwidth=4 tabstop=8 expandtab:
3554 * :indentSize=4:tabSize=8:noTabs=true: