2 * Definitions for protocol display
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 The protocol tree related functions.<BR>
26 A protocol tree will hold all necessary data to display the whole dissected packet.
27 Creating a protocol tree is done in a two stage process:
28 A static part at program startup, and a dynamic part when the dissection with the real packet data is done.<BR>
29 The "static" information is provided by creating a hf_register_info hf[] array, and register it using the
30 proto_register_field_array() function. This is usually done at dissector registering.<BR>
31 The "dynamic" information is added to the protocol tree by calling one of the proto_tree_add_...() functions,
32 e.g. proto_tree_add_bytes().
42 #include <epan/wmem/wmem.h>
45 #include "wsutil/nstime.h"
48 #include "ftypes/ftypes.h"
50 #include "ws_symbol_export.h"
54 #endif /* __cplusplus */
56 /** @defgroup prototree The Protocol Tree
58 * Dissectors use proto_tree_add_* to add items to the protocol tree. In
59 * most cases you'll want to use proto_tree_add_item().
64 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
65 WS_DLL_PUBLIC int hf_text_only;
67 /** the maximum length of a protocol field string representation */
68 #define ITEM_LABEL_LENGTH 240
73 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
74 #define VALS(x) (const struct _value_string*)(x)
76 /** Make a const val64_string[] look like a _val64_string pointer, used to set header_field_info.strings */
77 #define VALS64(x) (const struct _val64_string*)(x)
79 /** Something to satisfy checkAPIs when you have a pointer to a value_string_ext (e.g., one built with value_string_ext_new()) */
80 #define VALS_EXT_PTR(x) (x)
82 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
83 #define TFS(x) (const struct true_false_string*)(x)
85 typedef void (*custom_fmt_func_t)(gchar *, guint32);
87 typedef void (*custom_fmt_func_64_t)(gchar *, guint64);
89 /** Make a custom format function pointer look like a void pointer. Used to set header_field_info.strings.
91 * We cast to gsize first, which 1) is guaranteed to be wide enough to
92 * hold a pointer and 2) lets us side-step warnings about casting function
93 * pointers to 'void *'. This violates ISO C but should be fine on POSIX
96 #define CF_FUNC(x) ((const void *) (gsize) (x))
98 /** Make a const range_string[] look like a _range_string pointer, used to set
99 * header_field_info.strings */
100 #define RVALS(x) (const struct _range_string*)(x)
102 /** Cast a ft_framenum_type_t, used to set header_field_info.strings */
103 #define FRAMENUM_TYPE(x) GINT_TO_POINTER(x)
107 /** Structure for information about a protocol */
108 typedef struct _protocol protocol_t;
110 /** Function used for reporting errors in dissectors; it throws a
111 * DissectorError exception, with the string passed as an argument
112 * as the message for the exception, so that it can show up in
113 * the Info column and the protocol tree.
115 * If that string is dynamically allocated, it should be allocated with
116 * wmem_alloc() with wmem_packet_scope(); using wmem_strdup_printf() would work.
118 * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
119 * it will call abort(), instead, to make it easier to get a stack trace.
121 * @param message string to use as the message
123 WS_DLL_PUBLIC WS_MSVC_NORETURN void proto_report_dissector_bug(const char *message) G_GNUC_NORETURN;
125 #define REPORT_DISSECTOR_BUG(message) \
126 proto_report_dissector_bug(message)
128 /** Macro used to provide a hint to static analysis tools.
129 * (Currently only Visual C++.)
132 /* XXX - Is there a way to say "quit checking at this point"? */
133 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
134 ; __analysis_assume(expression);
136 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
139 /** Macro used for assertions in dissectors; it doesn't abort, it just
140 * throws a DissectorError exception, with the assertion failure
141 * message as a parameter, so that it can show up in the protocol tree.
143 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
144 * conditions that shouldn't happen). It should NOT be used for showing
145 * that a packet is malformed. For that, use expert_infos instead.
147 * @param s expression to test in the assertion
150 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
152 #define __DISSECTOR_ASSERT(expression, file, lineno) \
153 (REPORT_DISSECTOR_BUG( \
154 wmem_strdup_printf(wmem_packet_scope(), \
155 "%s:%u: failed assertion \"%s\"", \
156 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
158 #define __DISSECTOR_ASSERT_HINT(expression, file, lineno, hint) \
159 (REPORT_DISSECTOR_BUG( \
160 wmem_strdup_printf(wmem_packet_scope(), \
161 "%s:%u: failed assertion \"%s\" (%s)", \
162 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression), hint)))
164 #define DISSECTOR_ASSERT(expression) \
165 ((void) ((expression) ? (void)0 : \
166 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
167 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
170 * Same as DISSECTOR_ASSERT(), but takes an extra 'hint' parameter that
171 * can be used to provide information as to why the assertion might fail.
173 * @param expression expression to test in the assertion
174 * @param hint message providing extra information
176 #define DISSECTOR_ASSERT_HINT(expression, hint) \
177 ((void) ((expression) ? (void)0 : \
178 __DISSECTOR_ASSERT_HINT (expression, __FILE__, __LINE__, hint))) \
179 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
182 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
183 * as the assert handling of GTK/GLib is currently not very helpful */
184 #define DISSECTOR_ASSERT(expression) \
185 { if(!(expression)) _asm { int 3}; }
188 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
189 * unconditionally, much like GLIB's g_assert_not_reached works.
191 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
192 * conditions that shouldn't happen). It should NOT be used for showing
193 * that a packet is malformed. For that, use expert_infos instead.
196 #define DISSECTOR_ASSERT_NOT_REACHED() \
197 (REPORT_DISSECTOR_BUG( \
198 wmem_strdup_printf(wmem_packet_scope(), \
199 "%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
200 __FILE__, __LINE__)))
202 /** Compare two integers.
204 * This is functionally the same as `DISSECTOR_ASSERT(a op b)` except that it
205 * will display the values of a and b upon failure.
207 * DISSECTOR_ASSERT_CMPINT(a, ==, b);
208 * DISSECTOR_ASSERT_CMPINT(min, <=, max);
210 * This function can currently compare values that fit inside a gint64.
212 * WARNING: The number of times the arguments are evaluated is undefined. Do
213 * not use expressions with side effects as arguments.
215 * @param a The first integer.
216 * @param op Any binary operator.
217 * @param b The second integer.
218 * @param type the type operator
219 * @param fmt the fmt operator
221 #define __DISSECTOR_ASSERT_CMPINT(a, op, b, type, fmt) \
222 (REPORT_DISSECTOR_BUG( \
223 wmem_strdup_printf(wmem_packet_scope(), \
224 "%s:%u: failed assertion " #a " " #op " " #b " (" fmt " " #op " " fmt ")", \
225 __FILE__, __LINE__, (type)a, (type)b)))
227 #define DISSECTOR_ASSERT_CMPINT(a, op, b) \
228 ((void) ((a op b) ? (void)0 : \
229 __DISSECTOR_ASSERT_CMPINT (a, op, b, gint64, "%" G_GINT64_MODIFIER "d"))) \
230 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
232 /** Like DISSECTOR_ASSERT_CMPINT() except the arguments are treated as
235 * This function can currently compare values that fit inside a guint64.
237 #define DISSECTOR_ASSERT_CMPUINT(a, op, b) \
238 ((void) ((a op b) ? (void)0 : \
239 __DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "%" G_GINT64_MODIFIER "u"))) \
240 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
242 /** Like DISSECTOR_ASSERT_CMPUINT() except the values are displayed in
243 * hexadecimal upon assertion failure.
245 #define DISSECTOR_ASSERT_CMPUINTHEX(a, op, b) \
246 ((void) ((a op b) ? (void)0 : \
247 __DISSECTOR_ASSERT_CMPINT (a, op, b, guint64, "0x%" G_GINT64_MODIFIER "X"))) \
248 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(a op b)
251 * This is similar to DISSECTOR_ASSERT(hfinfo->type == type) except that
252 * it will report the name of the field with the wrong type as well as
255 * @param hfinfo The hfinfo for the field being tested
256 * @param type The type it's expected to have
258 #define __DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
259 (REPORT_DISSECTOR_BUG( \
260 wmem_strdup_printf(wmem_packet_scope(), \
261 "%s:%u: field %s is not of type "#t, \
262 __FILE__, __LINE__, (hfinfo)->abbrev)))
264 #define DISSECTOR_ASSERT_FIELD_TYPE(hfinfo, t) \
265 ((void) (((hfinfo)->type == t) ? (void)0 : \
266 __DISSECTOR_ASSERT_FIELD_TYPE ((hfinfo), t))) \
267 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == t)
269 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_INTEGRAL(hfinfo) \
270 ((void) ((IS_FT_INT((hfinfo)->type) || \
271 IS_FT_UINT((hfinfo)->type)) ? (void)0 : \
272 REPORT_DISSECTOR_BUG( \
273 wmem_strdup_printf(wmem_packet_scope(), \
274 "%s:%u: field %s is not of an FT_{U}INTn type", \
275 __FILE__, __LINE__, (hfinfo)->abbrev)))) \
276 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(IS_FT_INT((hfinfo)->type) || \
277 IS_FT_UINT((hfinfo)->type))
279 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
280 ((void) (((hfinfo)->type == FT_ABSOLUTE_TIME || \
281 (hfinfo)->type == FT_RELATIVE_TIME) ? (void)0 : \
282 __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME ((hfinfo)))) \
283 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == FT_ABSOLUTE_TIME || \
284 (hfinfo)->type == FT_RELATIVE_TIME)
286 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
287 (REPORT_DISSECTOR_BUG( \
288 wmem_strdup_printf(wmem_packet_scope(), \
289 "%s:%u: field %s is not of type FT_STRING, FT_STRINGZ, or FT_STRINGZPAD", \
290 __FILE__, __LINE__, (hfinfo)->abbrev)))
292 #define DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo) \
293 ((void) (((hfinfo)->type == FT_STRING || (hfinfo)->type == FT_STRINGZ || \
294 (hfinfo)->type == FT_STRINGZPAD) ? (void)0 : \
295 __DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING ((hfinfo)))) \
296 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT((hfinfo)->type == FT_STRING || \
297 (hfinfo)->type == FT_STRINGZ || \
298 (hfinfo)->type == FT_STRINGZPAD)
300 #define __DISSECTOR_ASSERT_FIELD_TYPE_IS_TIME(hfinfo) \
301 (REPORT_DISSECTOR_BUG( \
302 wmem_strdup_printf(wmem_packet_scope(), \
303 "%s:%u: field %s is not of type FT_ABSOLUTE_TIME or FT_RELATIVE_TIME", \
304 __FILE__, __LINE__, (hfinfo)->abbrev)))
307 * The encoding of a field of a particular type may involve more
308 * than just whether it's big-endian or little-endian and its size.
310 * For integral values, that's it, as 99.9999999999999% of the machines
311 * out there are 2's complement binary machines with 8-bit bytes,
312 * so the protocols out there expect that and, for example, any Unisys
313 * 2200 series machines out there just have to translate between 2's
314 * complement and 1's complement (and nobody's put any IBM 709x's on
315 * any networks lately :-)).
319 * for floating-point numbers, in addition to IEEE decimal
320 * floating-point, there's also IBM System/3x0 and PDP-11/VAX
321 * floating-point - most protocols use IEEE binary, but DCE RPC
322 * can use other formats if that's what the sending host uses;
324 * for character strings, there are various character encodings
325 * (various ISO 646 sets, ISO 8859/x, various other national
326 * standards, various DOS and Windows encodings, various Mac
327 * encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
330 * for absolute times, there's UNIX time_t, UNIX time_t followed
331 * by 32-bit microseconds, UNIX time_t followed by 32-bit
332 * nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
334 * We might also, in the future, want to allow a field specifier to
335 * indicate the encoding of the field, or at least its default
336 * encoding, as most fields in most protocols always use the
337 * same encoding (although that's not true of all fields, so we
338 * still need to be able to specify that at run time).
340 * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
341 * bit flags, to be combined, in the future, with other information
342 * to specify the encoding in the last argument to
343 * proto_tree_add_item(), and possibly to specify in a field
344 * definition (e.g., ORed in with the type value).
346 * Currently, proto_tree_add_item() treats its last argument as a
347 * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
348 * the field is little-endian - and other code in epan/proto.c does
349 * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and
350 * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
351 * so that we could put a field type and/or a value such as a character
352 * encoding in the lower bits.
354 #define ENC_BIG_ENDIAN 0x00000000
355 #define ENC_LITTLE_ENDIAN 0x80000000
357 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
358 #define ENC_HOST_ENDIAN ENC_LITTLE_ENDIAN
360 #define ENC_HOST_ENDIAN ENC_BIG_ENDIAN
365 * Historically FT_TIMEs were only timespecs; the only question was whether
366 * they were stored in big- or little-endian format.
368 * For backwards compatibility, we interpret an encoding of 1 as meaning
369 * "little-endian timespec", so that passing TRUE is interpreted as that.
371 #define ENC_TIME_TIMESPEC 0x00000000 /* "struct timespec" */
372 #define ENC_TIME_NTP 0x00000002 /* NTP times */
373 #define ENC_TIME_TOD 0x00000004 /* System/3xx and z/Architecture time-of-day clock */
376 * Historically, the only place the representation mattered for strings
377 * was with FT_UINT_STRINGs, where we had FALSE for the string length
378 * being big-endian and TRUE for it being little-endian.
380 * We now have encoding values for the character encoding. The encoding
381 * values are encoded in all but the top bit (which is the byte-order
382 * bit, required for FT_UINT_STRING and for UCS-2 and UTF-16 strings)
383 * and the bottom bit (which we ignore for now so that programs that
384 * pass TRUE for the encoding just do ASCII). (The encodings are given
385 * directly as even numbers in hex, so that make-init-lua.pl can just
386 * turn them into numbers for use in init.lua.)
388 * We don't yet process ASCII and UTF-8 differently. Ultimately, for
389 * ASCII, all bytes with the 8th bit set should be mapped to some "this
390 * is not a valid character" code point, as ENC_ASCII should mean "this
391 * is ASCII, not some extended variant thereof". We should also map
392 * 0x00 to that as well - null-terminated and null-padded strings
393 * never have NULs in them, but counted strings might. (Either that,
394 * or the values for strings should be counted, not null-terminated.)
395 * For UTF-8, invalid UTF-8 sequences should be mapped to the same
398 * For display, perhaps we should also map control characters to the
399 * Unicode glyphs showing the name of the control character in small
400 * caps, diagonally. (Unfortunately, those only exist for C0, not C1.)
402 #define ENC_CHARENCODING_MASK 0x7FFFFFFE /* mask out byte-order bits */
403 #define ENC_ASCII 0x00000000
404 #define ENC_UTF_8 0x00000002
405 #define ENC_UTF_16 0x00000004
406 #define ENC_UCS_2 0x00000006
407 #define ENC_UCS_4 0x00000008
408 #define ENC_ISO_8859_1 0x0000000A
409 #define ENC_ISO_8859_2 0x0000000C
410 #define ENC_ISO_8859_3 0x0000000E
411 #define ENC_ISO_8859_4 0x00000010
412 #define ENC_ISO_8859_5 0x00000012
413 #define ENC_ISO_8859_6 0x00000014
414 #define ENC_ISO_8859_7 0x00000016
415 #define ENC_ISO_8859_8 0x00000018
416 #define ENC_ISO_8859_9 0x0000001A
417 #define ENC_ISO_8859_10 0x0000001C
418 #define ENC_ISO_8859_11 0x0000001E
419 /* #define ENC_ISO_8859_12 0x00000020 ISO 8859-12 was abandoned */
420 #define ENC_ISO_8859_13 0x00000022
421 #define ENC_ISO_8859_14 0x00000024
422 #define ENC_ISO_8859_15 0x00000026
423 #define ENC_ISO_8859_16 0x00000028
424 #define ENC_WINDOWS_1250 0x0000002A
425 #define ENC_3GPP_TS_23_038_7BITS 0x0000002C
426 #define ENC_EBCDIC 0x0000002E
427 #define ENC_MAC_ROMAN 0x00000030
428 #define ENC_CP437 0x00000032
429 #define ENC_ASCII_7BITS 0x00000034
434 * These could probably be used by existing code:
439 * As those are added, change code such as the code in packet-bacapp.c
444 * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
445 * opaque byte-array fields (FT_BYTES), and other fields where there
446 * is no choice of encoding (either because it's "just a bucket
447 * of bytes" or because the encoding is completely fixed), we
448 * have ENC_NA (for "Not Applicable").
450 #define ENC_NA 0x00000000
452 /* For cases where either native type or string encodings could both be
453 * valid arguments, we need something to distinguish which one is being
454 * passed as the argument, because ENC_BIG_ENDIAN and ENC_ASCII are both
455 * 0x00000000. So we use ENC_STR_NUM or ENC_STR_HEX bit-or'ed with
456 * ENC_ASCII and its ilk.
458 /* this is for strings as numbers "12345" */
459 #define ENC_STR_NUM 0x01000000
460 /* this is for strings as hex "1a2b3c" */
461 #define ENC_STR_HEX 0x02000000
462 /* a convenience macro for either of the above */
463 #define ENC_STRING 0x03000000
464 /* mask out ENC_STR_* and related bits - should this replace ENC_CHARENCODING_MASK? */
465 #define ENC_STR_MASK 0x0000FFFE
467 /* for cases where the number is allowed to have a leading '+'/'-' */
468 /* this can't collide with ENC_SEP_* because they can be used simultaneously */
469 #define ENC_NUM_PREF 0x00200000
471 /* For cases where a string encoding contains hex, bit-or one or more
472 * of these for the allowed separator(s), as well as with ENC_STR_HEX.
473 * See hex_str_to_bytes_encoding() in epan/strutil.h for details.
475 #define ENC_SEP_NONE 0x00010000
476 #define ENC_SEP_COLON 0x00020000
477 #define ENC_SEP_DASH 0x00040000
478 #define ENC_SEP_DOT 0x00080000
479 #define ENC_SEP_SPACE 0x00100000
480 /* a convenience macro for the above */
481 #define ENC_SEP_MASK 0x001F0000
483 /* For cases where a string encoding contains a timestamp, use one
484 * of these (but only one). These values can collide with above, because
485 * you can't do both at the same time.
487 #define ENC_ISO_8601_DATE 0x00010000
488 #define ENC_ISO_8601_TIME 0x00020000
489 #define ENC_ISO_8601_DATE_TIME 0x00030000
490 #define ENC_RFC_822 0x00040000
491 #define ENC_RFC_1123 0x00080000
492 /* a convenience macro for the above - for internal use only */
493 #define ENC_STR_TIME_MASK 0x000F0000
495 /* Values for header_field_info.display */
497 /* For integral types, the display format is a BASE_* field_display_e value
498 * possibly ORed with BASE_*_STRING */
500 /** FIELD_DISPLAY_E_MASK selects the field_display_e value. */
501 #define FIELD_DISPLAY_E_MASK 0xFF
505 BASE_NONE = 0, /**< none */
506 BASE_DEC = 1, /**< decimal */
507 BASE_HEX = 2, /**< hexadecimal */
508 BASE_OCT = 3, /**< octal */
509 BASE_DEC_HEX = 4, /**< decimal (hexadecimal) */
510 BASE_HEX_DEC = 5, /**< hexadecimal (decimal) */
511 BASE_CUSTOM = 6, /**< call custom routine (in ->strings) to format */
514 STR_ASCII = BASE_NONE, /**< shows non-printable ASCII characters as C-style escapes */
515 /* XXX, support for format_text_wsp() ? */
516 STR_UNICODE = 7, /**< shows non-printable UNICODE characters as \\uXXXX (XXX for now non-printable characters display depends on UI) */
519 SEP_DOT = 8, /**< hexadecimal bytes with a period (.) between each byte */
520 SEP_DASH = 9, /**< hexadecimal bytes with a dash (-) between each byte */
521 SEP_COLON = 10, /**< hexadecimal bytes with a colon (:) between each byte */
522 SEP_SPACE = 11, /**< hexadecimal bytes with a space between each byte */
525 BASE_NETMASK = 12, /**< Used for IPv4 address that shouldn't be resolved (like for netmasks) */
528 BASE_PT_UDP = 13, /**< UDP port */
529 BASE_PT_TCP = 14, /**< TCP port */
530 BASE_PT_DCCP = 15, /**< DCCP port */
531 BASE_PT_SCTP = 16 /**< SCTP port */
534 #define FIELD_DISPLAY(d) ((d) & FIELD_DISPLAY_E_MASK)
536 /* Following constants have to be ORed with a field_display_e when dissector
537 * want to use specials value-string MACROs for a header_field_info */
538 #define BASE_RANGE_STRING 0x100
539 #define BASE_EXT_STRING 0x200
540 #define BASE_VAL64_STRING 0x400
542 /** BASE_ values that cause the field value to be displayed twice */
543 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
545 /** BASE_PT_ values display decimal and transport port service name */
546 #define IS_BASE_PORT(b) (((b)==BASE_PT_UDP||(b)==BASE_PT_TCP||(b)==BASE_PT_DCCP||(b)==BASE_PT_SCTP))
548 /* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e
549 * as per time_fmt.h. */
552 HF_REF_TYPE_NONE, /**< Field is not referenced */
553 HF_REF_TYPE_INDIRECT, /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
554 HF_REF_TYPE_DIRECT /**< Field is directly referenced */
557 /** information describing a header field */
558 typedef struct _header_field_info header_field_info;
560 /** information describing a header field */
561 struct _header_field_info {
562 /* ---------- set by dissector --------- */
563 const char *name; /**< [FIELDNAME] full name of this field */
564 const char *abbrev; /**< [FIELDABBREV] abbreviated name of this field */
565 enum ftenum type; /**< [FIELDTYPE] field type, one of FT_ (from ftypes.h) */
566 int display; /**< [FIELDDISPLAY] one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
567 const void *strings; /**< [FIELDCONVERT] value_string, val64_string, range_string or true_false_string,
568 typically converted by VALS(), RVALS() or TFS().
569 If this is an FT_PROTOCOL then it points to the
570 associated protocol_t structure */
571 guint64 bitmask; /**< [BITMASK] bitmask of interesting bits */
572 const char *blurb; /**< [FIELDDESCR] Brief description of field */
574 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
575 int id; /**< Field ID */
576 int parent; /**< parent protocol tree */
577 hf_ref_type ref_type; /**< is this field referenced by a filter */
578 int same_name_prev_id; /**< ID of previous hfinfo with same abbrev */
579 header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev */
583 * HFILL initializes all the "set by proto routines" fields in a
584 * _header_field_info. If new fields are added or removed, it should
585 * be changed as necessary.
587 #define HFILL -1, 0, HF_REF_TYPE_NONE, -1, NULL
589 #define HFILL_INIT(hf) \
591 hf.hfinfo.parent = 0; \
592 hf.hfinfo.ref_type = HF_REF_TYPE_NONE; \
593 hf.hfinfo.same_name_prev_id = -1; \
594 hf.hfinfo.same_name_next = NULL;
596 /** Used when registering many fields at once, using proto_register_field_array() */
597 typedef struct hf_register_info {
598 int *p_id; /**< written to by register() function */
599 header_field_info hfinfo; /**< the field info to be registered */
605 /** string representation, if one of the proto_tree_add_..._format() functions used */
606 typedef struct _item_label_t {
607 char representation[ITEM_LABEL_LENGTH];
611 /** Contains the field information for the proto_item. */
612 typedef struct field_info {
613 header_field_info *hfinfo; /**< pointer to registered field information */
614 gint start; /**< current start of data in field_info.ds_tvb */
615 gint length; /**< current data length of item in field_info.ds_tvb */
616 gint appendix_start; /**< start of appendix data */
617 gint appendix_length; /**< length of appendix data */
618 gint tree_type; /**< one of ETT_ or -1 */
619 guint32 flags; /**< bitfield like FI_GENERATED, ... */
620 item_label_t *rep; /**< string for GUI tree */
621 tvbuff_t *ds_tvb; /**< data source tvbuff */
627 * This structure describes one segment of a split-bits item
628 * crumb_bit_offset is the bit offset in the input tvb of the first (most significant) bit of this crumb
629 * crumb_bit_length is the number of contiguous bits of this crumb.
630 * The first element of an array of bits_specs describes the most significant crumb of the output value.
631 * The second element of an array of bits_specs describes the next-most significant crumb of the output value, etc.
632 * The array is terminated by a sentinal entry with crumb_bit_length of 0.
636 guint crumb_bit_offset;
637 guint8 crumb_bit_length;
641 * Flag fields. Do not assign values greater than 0x00000080 unless you
642 * shuffle the expert information upward; see below.
645 /** The protocol field should not be shown in the tree (it's used for filtering only),
646 * used in field_info.flags. */
647 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
648 A user cannot tell by looking at the packet detail that the field exists
649 and that they can filter on its value. */
650 #define FI_HIDDEN 0x00000001
651 /** The protocol field should be displayed as "generated by Wireshark",
652 * used in field_info.flags. */
653 #define FI_GENERATED 0x00000002
654 /** The protocol field is actually a URL */
655 #define FI_URL 0x00000004
657 /** The protocol field value is in little endian */
658 #define FI_LITTLE_ENDIAN 0x00000008
659 /** The protocol field value is in big endian */
660 #define FI_BIG_ENDIAN 0x00000010
661 /** Field value start from nth bit (values from 0x20 - 0x100) */
662 #define FI_BITS_OFFSET(n) (((n) & 7) << 5)
663 /** Field value takes n bits (values from 0x100 - 0x4000) */
664 /* if 0, it means that field takes fi->length * 8 */
665 #define FI_BITS_SIZE(n) (((n) & 63) << 8)
667 /** convenience macro to get field_info.flags */
668 #define FI_GET_FLAG(fi, flag) ((fi) ? ((fi)->flags & (flag)) : 0)
669 /** convenience macro to set field_info.flags */
670 #define FI_SET_FLAG(fi, flag) \
673 (fi)->flags = (fi)->flags | (flag); \
675 /** convenience macro to reset field_info.flags */
676 #define FI_RESET_FLAG(fi, flag) \
679 (fi)->flags = (fi)->flags & ~(flag); \
682 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
683 #define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
685 /** One of these exists for the entire protocol tree. Each proto_node
686 * in the protocol tree points to the same copy. */
688 GHashTable *interesting_hfids;
690 gboolean fake_protocols;
692 struct _packet_info *pinfo;
695 /** Each proto_tree, proto_item is one of these. */
696 typedef struct _proto_node {
697 struct _proto_node *first_child;
698 struct _proto_node *last_child;
699 struct _proto_node *next;
700 struct _proto_node *parent;
702 tree_data_t *tree_data;
705 /** A protocol tree element. */
706 typedef proto_node proto_tree;
707 /** A protocol item element. */
708 typedef proto_node proto_item;
711 * Expert information.
712 * This is in the flags field; we allocate this from the top down,
713 * so as not to collide with FI_ flags, which are allocated from
717 /* do not modify the PI_SEVERITY_MASK name - it's used by make-init-lua.pl */
718 /* expert severities */
719 #define PI_SEVERITY_MASK 0x00F00000 /**< mask usually for internal use only! */
720 /** Packet comment */
721 #define PI_COMMENT 0x00100000
722 /** Usual workflow, e.g. TCP connection establishing */
723 #define PI_CHAT 0x00200000
724 /** Notable messages, e.g. an application returned an "unusual" error code like HTTP 404 */
725 #define PI_NOTE 0x00400000
726 /** Warning, e.g. application returned an "unusual" error code */
727 #define PI_WARN 0x00600000
728 /** Serious problems, e.g. a malformed packet */
729 #define PI_ERROR 0x00800000
731 /* do not modify the PI_GROUP_MASK name - it's used by make-init-lua.pl */
732 /* expert "event groups" */
733 #define PI_GROUP_MASK 0xFF000000 /**< mask usually for internal use only! */
734 /** The protocol field has a bad checksum, usually uses PI_WARN severity */
735 #define PI_CHECKSUM 0x01000000
736 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
737 #define PI_SEQUENCE 0x02000000
738 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE severity */
739 #define PI_RESPONSE_CODE 0x03000000
740 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT severity */
741 #define PI_REQUEST_CODE 0x04000000
742 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN severity */
743 #define PI_UNDECODED 0x05000000
744 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT severity (or PI_ERROR) */
745 #define PI_REASSEMBLE 0x06000000
746 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR severity */
747 #define PI_MALFORMED 0x07000000
748 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR severity */
749 #define PI_DEBUG 0x08000000
750 /** The protocol field violates a protocol specification, usually PI_WARN severity */
751 #define PI_PROTOCOL 0x09000000
752 /** The protocol field indicates a security problem (e.g. insecure implementation) */
753 #define PI_SECURITY 0x0a000000
754 /** The protocol field indicates a packet comment */
755 #define PI_COMMENTS_GROUP 0x0b000000
756 /** The protocol field indicates a decryption problem */
757 #define PI_DECRYPTION 0x0c000000
759 /* add more, see https://wiki.wireshark.org/Development/ExpertInfo */
762 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
763 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
764 #define PROTO_ITEM_IS_HIDDEN(proto_item) \
765 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
766 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
767 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
768 #define PROTO_ITEM_SET_HIDDEN(proto_item) \
771 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
773 /** mark this protocol field to be visible from the protocol tree display */
774 #define PROTO_ITEM_SET_VISIBLE(proto_item) \
777 FI_RESET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
780 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
781 #define PROTO_ITEM_IS_GENERATED(proto_item) \
782 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
783 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
784 #define PROTO_ITEM_SET_GENERATED(proto_item) \
787 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
789 /** is this protocol field actually a URL? */
790 #define PROTO_ITEM_IS_URL(proto_item) \
791 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
792 /** mark this protocol field as a URL */
793 #define PROTO_ITEM_SET_URL(proto_item) \
796 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
799 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
800 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);
802 extern gboolean proto_tree_traverse_post_order(proto_tree *tree,
803 proto_tree_traverse_func func, gpointer data);
805 WS_DLL_PUBLIC void proto_tree_children_foreach(proto_tree *tree,
806 proto_tree_foreach_func func, gpointer data);
808 /** Retrieve the field_info from a proto_node */
809 #define PNODE_FINFO(proto_node) ((proto_node)->finfo)
811 /** Retrieve the field_info from a proto_item */
812 #define PITEM_FINFO(proto_item) PNODE_FINFO(proto_item)
814 /** Retrieve the field_info from a proto_tree */
815 #define PTREE_FINFO(proto_tree) PNODE_FINFO(proto_tree)
817 /** Retrieve the tree_data_t from a proto_tree */
818 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
820 /** Retrieve the wmem_allocator_t from a proto_node */
821 #define PNODE_POOL(proto_node) ((proto_node)->tree_data->pinfo->pool)
824 /** Register dissector plugin type with the plugin system.
825 Called by epan_register_plugin_types(); do not call it yourself. */
826 extern void register_dissector_plugin_type(void);
829 /** Sets up memory used by proto routines. Called at program startup */
830 void proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_data),
831 void (register_all_handoffs_func)(register_cb cb, gpointer client_data),
832 register_cb cb, void *client_data);
835 /** Frees memory used by proto routines. Called at program shutdown */
836 extern void proto_cleanup(void);
838 /** This function takes a tree and a protocol id as parameter and
839 will return TRUE/FALSE for whether the protocol or any of the filterable
840 fields in the protocol is referenced by any fitlers.
841 If this function returns FALSE then it is safe to skip any
842 proto_tree_add_...() calls and just treat the call as if the
843 dissector was called with tree==NULL.
844 If you reset the tree to NULL by this dissector returning FALSE,
845 you will still need to call any subdissector with the original value of
846 tree or filtering will break.
848 The purpose of this is to optimize wireshark for speed and make it
849 faster for when filters are being used.
851 WS_DLL_PUBLIC gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
853 /** Create a subtree under an existing item.
854 @param ti the parent item of the new subtree
855 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
856 @return the new subtree */
857 WS_DLL_PUBLIC proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx) G_GNUC_WARN_UNUSED_RESULT;
859 /** Get an existing subtree under an item.
860 @param ti the parent item of the subtree
861 @return the subtree or NULL */
862 WS_DLL_PUBLIC proto_tree* proto_item_get_subtree(proto_item *ti);
864 /** Get the parent of a subtree item.
865 @param ti the child item in the subtree
866 @return parent item or NULL */
867 WS_DLL_PUBLIC proto_item* proto_item_get_parent(const proto_item *ti);
869 /** Get Nth generation parent item.
870 @param ti the child item in the subtree
871 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
872 @return parent item */
873 WS_DLL_PUBLIC proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
875 /** Replace text of item after it already has been created.
876 @param ti the item to set the text
877 @param format printf like format string
878 @param ... printf like parameters */
879 WS_DLL_PUBLIC void proto_item_set_text(proto_item *ti, const char *format, ...)
882 /** Append to text of item after it has already been created.
883 @param ti the item to append the text to
884 @param format printf like format string
885 @param ... printf like parameters */
886 WS_DLL_PUBLIC void proto_item_append_text(proto_item *ti, const char *format, ...)
889 /** Prepend to text of item after it has already been created.
890 @param ti the item to prepend the text to
891 @param format printf like format string
892 @param ... printf like parameters */
893 WS_DLL_PUBLIC void proto_item_prepend_text(proto_item *ti, const char *format, ...)
896 /** Set proto_item's length inside tvb, after it has already been created.
897 @param ti the item to set the length
898 @param length the new length ot the item */
899 WS_DLL_PUBLIC void proto_item_set_len(proto_item *ti, const gint length);
902 * Sets the length of the item based on its start and on the specified
903 * offset, which is the offset past the end of the item; as the start
904 * in the item is relative to the beginning of the data source tvbuff,
905 * we need to pass in a tvbuff.
906 @param ti the item to set the length
907 @param tvb end is relative to this tvbuff
908 @param end this end offset is relative to the beginning of tvb
909 @todo make usage clearer, I don't understand it!
911 WS_DLL_PUBLIC void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
913 /** Get length of a proto_item. Useful after using proto_tree_add_item()
914 * to add a variable-length field (e.g., FT_NSTRING_UINT8).
915 @param ti the item to get the length from
916 @return the current length */
917 WS_DLL_PUBLIC int proto_item_get_len(const proto_item *ti);
921 /** Creates a new proto_tree root.
922 @return the new tree root */
923 extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
925 void proto_tree_reset(proto_tree *tree);
927 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
928 @param tree the tree to free */
929 WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
931 /** Set the tree visible or invisible.
932 Is the parsing being done for a visible proto_tree or an invisible one?
933 By setting this correctly, the proto_tree creation is sped up by not
934 having to call g_vsnprintf and copy strings around.
935 @param tree the tree to be set
936 @param visible ... or not
937 @return the old value */
938 WS_DLL_PUBLIC gboolean
939 proto_tree_set_visible(proto_tree *tree, gboolean visible);
941 /** Indicate whether we should fake protocols during dissection (default = TRUE)
942 @param tree the tree to be set
943 @param fake_protocols TRUE if we should fake protocols */
945 proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
947 /** Mark a field/protocol ID as "interesting".
948 @param tree the tree to be set (currently ignored)
949 @param hfid the interesting field id
950 @todo what *does* interesting mean? */
952 proto_tree_prime_hfid(proto_tree *tree, const int hfid);
954 /** Get a parent item of a subtree.
955 @param tree the tree to get the parent from
956 @return parent item */
957 WS_DLL_PUBLIC proto_item* proto_tree_get_parent(proto_tree *tree);
959 /** Get the parent tree of a subtree.
960 @param tree the tree to get the parent from
961 @return parent tree */
962 WS_DLL_PUBLIC proto_tree *proto_tree_get_parent_tree(proto_tree *tree);
964 /** Get the root tree from any subtree.
965 @param tree the tree to get the root from
967 WS_DLL_PUBLIC proto_tree* proto_tree_get_root(proto_tree *tree);
969 /** Move an existing item behind another existing item.
970 @param tree the tree to which both items belong
971 @param fixed_item the item which keeps its position
972 @param item_to_move the item which will be moved */
973 WS_DLL_PUBLIC void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
976 /** Set start and length of an appendix for a proto_tree.
977 @param tree the tree to set the appendix start and length
978 @param tvb the tv buffer of the current data
979 @param start the start offset of the appendix
980 @param length the length of the appendix */
981 WS_DLL_PUBLIC void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length);
984 /** Add an item to a proto_tree, using the text label registered to that item.
985 The item is extracted from the tvbuff handed to it.
986 @param tree the tree to append this item to
988 @param tvb the tv buffer of the current data
989 @param start start of data in tvb
990 @param length length of data in tvb
991 @param encoding data encoding
992 @return the newly created item */
993 WS_DLL_PUBLIC proto_item *
994 proto_tree_add_item_new(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
995 const gint start, gint length, const guint encoding);
997 WS_DLL_PUBLIC proto_item *
998 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
999 const gint start, gint length, const guint encoding);
1001 /** Add an item to a proto_tree, using the text label registered to that item.
1002 The item is extracted from the tvbuff handed to it, and the retrieved
1003 value is also set to *retval so the caller gets it back for other uses.
1005 This function retrieves the value even if the passed-in tree param is NULL,
1006 so that it can be used by dissectors at all times to both get the value
1007 and set the tree item to it.
1009 Like other proto_tree_add functions, if there is a tree and the value cannot
1010 be decoded from the tvbuff, then an expert info error is reported.
1012 This function accepts ENC_LITTLE_ENDIAN and ENC_BIG_ENDIAN for native number
1013 encoding in the tvbuff
1015 The length argument must
1016 be set to the appropriate size of the native type as in other proto_add routines.
1018 Integers of 8, 16, 24 and 32 bits can be retreived with these functions.
1020 @param tree the tree to append this item to
1021 @param hfindex field
1022 @param tvb the tv buffer of the current data
1023 @param start start of data in tvb (cannot be negative)
1024 @param length length of data in tvb (for strings can be -1 for remaining)
1025 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_BIG_ENDIAN, ENC_ASCII|ENC_STRING, etc.)
1026 @param[out] retval points to a gint/guint 8/16/32/64 or gfloat/gdouble which will be set
1027 @return the newly created item, and value is set to the decoded value
1029 WS_DLL_PUBLIC proto_item *
1030 proto_tree_add_item_ret_int(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1031 const gint start, gint length, const guint encoding, gint32 *retval);
1033 WS_DLL_PUBLIC proto_item *
1034 proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1035 const gint start, gint length, const guint encoding, guint32 *retval);
1037 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree.
1038 @param tree the tree to append this item to
1039 @param tvb the tv buffer of the current data
1040 @param start start of data in tvb
1041 @param length length of data in tvb
1042 @param format printf like format string
1043 @param ... printf like parameters
1044 @return the newly created item */
1046 proto_tree_add_text_internal(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
1047 ...) G_GNUC_PRINTF(5,6);
1049 /** (INTERNAL USE ONLY) Add a text-only node to a proto_tree using a variable argument list.
1050 @param tree the tree to append this item to
1051 @param tvb the tv buffer of the current data
1052 @param start start of data in tvb
1053 @param length length of data in tvb
1054 @param format printf like format string
1055 @param ap variable argument list
1056 @return the newly created item */
1058 proto_tree_add_text_valist_internal(proto_tree *tree, tvbuff_t *tvb, gint start,
1059 gint length, const char *format, va_list ap)
1060 G_GNUC_PRINTF(5, 0);
1062 /** Add a text-only node that creates a subtree underneath.
1063 @param tree the tree to append this item to
1064 @param tvb the tv buffer of the current data
1065 @param start start of data in tvb
1066 @param length length of data in tvb
1067 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1068 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1069 @param text label for the tree
1070 @return the newly created tree */
1071 WS_DLL_PUBLIC proto_tree *
1072 proto_tree_add_subtree(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *text);
1074 /** Add a text-only node that creates a subtree underneath.
1075 @param tree the tree to append this item to
1076 @param tvb the tv buffer of the current data
1077 @param start start of data in tvb
1078 @param length length of data in tvb
1079 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
1080 @param tree_item item returned with tree creation. Can be NULL if going to be unused
1081 @param format printf like format string
1082 @param ... printf like parameters
1083 @return the newly created tree */
1084 WS_DLL_PUBLIC proto_tree *
1085 proto_tree_add_subtree_format(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, gint idx, proto_item **tree_item, const char *format, ...) G_GNUC_PRINTF(7,8);
1087 /** Add a text-only node to a proto_tree with tvb_format_text() string. */
1089 proto_tree_add_format_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length);
1091 /** Add a text-only node to a proto_tree with tvb_format_text_wsp() string. */
1093 proto_tree_add_format_wsp_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length);
1095 /** Add a FT_NONE field to a proto_tree.
1096 @param tree the tree to append this item to
1097 @param hfindex field index
1098 @param tvb the tv buffer of the current data
1099 @param start start of data in tvb
1100 @param length length of data in tvb
1101 @param format printf like format string
1102 @param ... printf like parameters
1103 @return the newly created item */
1104 WS_DLL_PUBLIC proto_item *
1105 proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start,
1106 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
1108 /** Add a FT_PROTOCOL to a proto_tree.
1109 @param tree the tree to append this item to
1110 @param hfindex field index
1111 @param tvb the tv buffer of the current data
1112 @param start start of data in tvb
1113 @param length length of data in tvb
1114 @param format printf like format string
1115 @param ... printf like parameters
1116 @return the newly created item */
1117 WS_DLL_PUBLIC proto_item *
1118 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1119 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
1124 /** Add a FT_BYTES to a proto_tree.
1125 @param tree the tree to append this item to
1126 @param hfindex field index
1127 @param tvb the tv buffer of the current data
1128 @param start start of data in tvb
1129 @param length length of data in tvb
1130 @param start_ptr pointer to the data to display
1131 @return the newly created item */
1132 WS_DLL_PUBLIC proto_item *
1133 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1134 gint length, const guint8* start_ptr);
1136 /** Add a FT_BYTES to a proto_tree like proto_tree_add_bytes,
1137 but used when the tvb data length does not match the bytes length.
1138 @param tree the tree to append this item to
1139 @param hfindex field index
1140 @param tvb the tv buffer of the current data
1141 @param start start of data in tvb
1142 @param length length of data in tvb
1143 @param start_ptr pointer to the data to display
1144 @param ptr_length length of data in start_ptr
1145 @return the newly created item */
1146 WS_DLL_PUBLIC proto_item *
1147 proto_tree_add_bytes_with_length(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1148 gint length, const guint8 *start_ptr, gint ptr_length);
1150 /** Get and add a byte-array-based FT_* to a proto_tree.
1152 Supported: FT_BYTES, FT_UINT_BYTES, FT_OID, FT_REL_OID, and FT_SYSTEM_ID.
1154 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1155 in for the encoding, and the retrieved byte array is also set to *retval so the
1156 caller gets it back for other uses.
1158 This function retrieves the value even if the passed-in tree param is NULL,
1159 so that it can be used by dissectors at all times to both get the value
1160 and set the tree item to it.
1162 Like other proto_tree_add functions, if there is a tree and the value cannot
1163 be decoded from the tvbuff, then an expert info error is reported. For string
1164 encoding, this means that a failure to decode the hex value from the string
1165 results in an expert info error being added to the tree.
1167 If encoding is string-based, it will convert using tvb_get_string_bytes(); see
1168 that function's comments for details.
1170 @note The GByteArray retval must be pre-constructed using g_byte_array_new().
1172 @param tree the tree to append this item to
1173 @param hfindex field index
1174 @param tvb the tv buffer of the current data
1175 @param start start of data in tvb
1176 @param length length of data in tvb
1177 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, or ENC_UTF_8|ENC_STR_HEX)
1178 @param[in,out] retval points to a GByteArray which will be set to the bytes from the Tvb.
1179 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1180 @param[in,out] err if not NULL, gets set to 0 if no failure, else the errno code (e.g., EDOM, ERANGE).
1181 @return the newly created item, and retval is set to the decoded value
1183 WS_DLL_PUBLIC proto_item *
1184 proto_tree_add_bytes_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1185 const gint start, gint length, const guint encoding,
1186 GByteArray *retval, gint *endoff, gint *err);
1188 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1189 the string for the value and with the field name being included
1191 @param tree the tree to append this item to
1192 @param hfindex field index
1193 @param tvb the tv buffer of the current data
1194 @param start start of data in tvb
1195 @param length length of data in tvb
1196 @param start_ptr pointer to the data to display
1197 @param format printf like format string
1198 @param ... printf like parameters
1199 @return the newly created item */
1200 WS_DLL_PUBLIC proto_item *
1201 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1202 gint start, gint length, const guint8* start_ptr, const char *format,
1203 ...) G_GNUC_PRINTF(7,8);
1205 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
1206 the entire string for the entry, including any field name.
1207 @param tree the tree to append this item to
1208 @param hfindex field index
1209 @param tvb the tv buffer of the current data
1210 @param start start of data in tvb
1211 @param length length of data in tvb
1212 @param start_ptr pointer to the data to display
1213 @param format printf like format string
1214 @param ... printf like parameters
1215 @return the newly created item */
1216 WS_DLL_PUBLIC proto_item *
1217 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1218 gint length, const guint8* start_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1220 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1221 @param tree the tree to append this item to
1222 @param hfindex field index
1223 @param tvb the tv buffer of the current data
1224 @param start start of data in tvb
1225 @param length length of data in tvb
1226 @param value_ptr pointer to the data to display
1227 @return the newly created item */
1228 WS_DLL_PUBLIC proto_item *
1229 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1230 gint length, const nstime_t* value_ptr);
1232 /** Get and add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
1233 The item is extracted from the tvbuff handed to it, based on the ENC_* passed
1234 in for the encoding, and the retrieved value is also set to *retval so the
1235 caller gets it back for other uses.
1237 This function retrieves the value even if the passed-in tree param is NULL,
1238 so that it can be used by dissectors at all times to both get the value
1239 and set the tree item to it.
1241 Like other proto_tree_add functions, if there is a tree and the value cannot
1242 be decoded from the tvbuff, then an expert info error is reported. For string
1243 encoding, this means that a failure to decode the time value from the string
1244 results in an expert info error being added to the tree.
1246 If encoding is string-based, it will convert using tvb_get_string_time(); see
1247 that function's comments for details.
1249 @note The nstime_t *retval must be pre-allocated as a nstime_t.
1251 @param tree the tree to append this item to
1252 @param hfindex field index
1253 @param tvb the tv buffer of the current data
1254 @param start start of data in tvb
1255 @param length length of data in tvb
1256 @param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_UTF_8|ENC_ISO_8601_DATE_TIME, etc.)
1257 @param[in,out] retval points to a nstime_t which will be set to the value
1258 @param[in,out] endoff if not NULL, gets set to the character after those consumed.
1259 @param[in,out] err if not NULL, gets set to 0 if no failure, else the errno code (e.g., EDOM, ERANGE).
1260 @return the newly created item, and retval is set to the decoded value
1262 WS_DLL_PUBLIC proto_item *
1263 proto_tree_add_time_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1264 const gint start, gint length, const guint encoding,
1265 nstime_t *retval, gint *endoff, gint *err);
1268 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1269 the format generating the string for the value and with the field name
1270 being included automatically.
1271 @param tree the tree to append this item to
1272 @param hfindex field index
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 value_ptr pointer to the data to display
1277 @param format printf like format string
1278 @param ... printf like parameters
1279 @return the newly created item */
1280 WS_DLL_PUBLIC proto_item *
1281 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1282 gint start, gint length, nstime_t* value_ptr, const char *format, ...)
1285 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
1286 the format generating the entire string for the entry, including any field
1288 @param tree the tree to append this item to
1289 @param hfindex field index
1290 @param tvb the tv buffer of the current data
1291 @param start start of data in tvb
1292 @param length length of data in tvb
1293 @param value_ptr pointer to the data to display
1294 @param format printf like format string
1295 @param ... printf like parameters
1296 @return the newly created item */
1297 WS_DLL_PUBLIC proto_item *
1298 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1299 gint length, nstime_t* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1301 /** Add a FT_IPXNET to a proto_tree.
1302 @param tree the tree to append this item to
1303 @param hfindex field index
1304 @param tvb the tv buffer of the current data
1305 @param start start of data in tvb
1306 @param length length of data in tvb
1307 @param value data to display
1308 @return the newly created item */
1309 WS_DLL_PUBLIC proto_item *
1310 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1311 gint length, guint32 value);
1313 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1314 the string for the value and with the field name being included
1316 @param tree the tree to append this item to
1317 @param hfindex field index
1318 @param tvb the tv buffer of the current data
1319 @param start start of data in tvb
1320 @param length length of data in tvb
1321 @param value data to display
1322 @param format printf like format string
1323 @param ... printf like parameters
1324 @return the newly created item */
1325 WS_DLL_PUBLIC proto_item *
1326 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1327 gint start, gint length, guint32 value, const char *format, ...)
1330 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
1331 the entire string for the entry, including any field name.
1332 @param tree the tree to append this item to
1333 @param hfindex field index
1334 @param tvb the tv buffer of the current data
1335 @param start start of data in tvb
1336 @param length length of data in tvb
1337 @param value data to display
1338 @param format printf like format string
1339 @param ... printf like parameters
1340 @return the newly created item */
1341 WS_DLL_PUBLIC proto_item *
1342 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1343 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1345 /** Add a FT_IPv4 to a proto_tree.
1346 @param tree the tree to append this item to
1347 @param hfindex field index
1348 @param tvb the tv buffer of the current data
1349 @param start start of data in tvb
1350 @param length length of data in tvb
1351 @param value data to display
1352 @return the newly created item */
1353 WS_DLL_PUBLIC proto_item *
1354 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1355 gint length, guint32 value);
1357 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1358 the string for the value and with the field name being included
1360 @param tree the tree to append this item to
1361 @param hfindex field index
1362 @param tvb the tv buffer of the current data
1363 @param start start of data in tvb
1364 @param length length of data in tvb
1365 @param value data to display
1366 @param format printf like format string
1367 @param ... printf like parameters
1368 @return the newly created item */
1369 WS_DLL_PUBLIC proto_item *
1370 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1371 gint start, gint length, guint32 value, const char *format, ...)
1374 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1375 the entire string for the entry, including any field name.
1376 @param tree the tree to append this item to
1377 @param hfindex field index
1378 @param tvb the tv buffer of the current data
1379 @param start start of data in tvb
1380 @param length length of data in tvb
1381 @param value data to display
1382 @param format printf like format string
1383 @param ... printf like parameters
1384 @return the newly created item */
1385 WS_DLL_PUBLIC proto_item *
1386 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1387 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1389 /** Add a FT_IPv6 to a proto_tree.
1390 @param tree the tree to append this item to
1391 @param hfindex field index
1392 @param tvb the tv buffer of the current data
1393 @param start start of data in tvb
1394 @param length length of data in tvb
1395 @param value_ptr data to display
1396 @return the newly created item */
1397 WS_DLL_PUBLIC proto_item *
1398 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1399 gint length, const struct e_in6_addr *value_ptr);
1401 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1402 the string for the value and with the field name being included
1404 @param tree the tree to append this item to
1405 @param hfindex field index
1406 @param tvb the tv buffer of the current data
1407 @param start start of data in tvb
1408 @param length length of data in tvb
1409 @param value_ptr data to display
1410 @param format printf like format string
1411 @param ... printf like parameters
1412 @return the newly created item */
1413 WS_DLL_PUBLIC proto_item *
1414 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1415 gint start, gint length, const struct e_in6_addr *value_ptr, const char *format,
1416 ...) G_GNUC_PRINTF(7,8);
1418 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1419 the entire string for the entry, including any field name.
1420 @param tree the tree to append this item to
1421 @param hfindex field index
1422 @param tvb the tv buffer of the current data
1423 @param start start of data in tvb
1424 @param length length of data in tvb
1425 @param value_ptr data to display
1426 @param format printf like format string
1427 @param ... printf like parameters
1428 @return the newly created item */
1429 WS_DLL_PUBLIC proto_item *
1430 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1431 gint length, const struct e_in6_addr *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1433 /** Add a FT_ETHER to a proto_tree.
1434 @param tree the tree to append this item to
1435 @param hfindex field index
1436 @param tvb the tv buffer of the current data
1437 @param start start of data in tvb
1438 @param length length of data in tvb
1439 @param value data to display
1440 @return the newly created item */
1441 WS_DLL_PUBLIC proto_item *
1442 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1443 gint length, const guint8* value);
1445 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1446 the string for the value and with the field name being included
1448 @param tree the tree to append this item to
1449 @param hfindex field index
1450 @param tvb the tv buffer of the current data
1451 @param start start of data in tvb
1452 @param length length of data in tvb
1453 @param value data to display
1454 @param format printf like format string
1455 @param ... printf like parameters
1456 @return the newly created item */
1457 WS_DLL_PUBLIC proto_item *
1458 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1459 gint start, gint length, const guint8* value, const char *format, ...)
1462 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1463 the entire string for the entry, including any field name.
1464 @param tree the tree to append this item to
1465 @param hfindex field index
1466 @param tvb the tv buffer of the current data
1467 @param start start of data in tvb
1468 @param length length of data in tvb
1469 @param value data to display
1470 @param format printf like format string
1471 @param ... printf like parameters
1472 @return the newly created item */
1473 WS_DLL_PUBLIC proto_item *
1474 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1475 gint length, const guint8* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1477 /** Add a FT_GUID to a proto_tree.
1478 @param tree the tree to append this item to
1479 @param hfindex field index
1480 @param tvb the tv buffer of the current data
1481 @param start start of data in tvb
1482 @param length length of data in tvb
1483 @param value_ptr data to display
1484 @return the newly created item */
1485 WS_DLL_PUBLIC proto_item *
1486 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1487 gint length, const e_guid_t *value_ptr);
1489 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1490 the string for the value and with the field name being included
1492 @param tree the tree to append this item to
1493 @param hfindex field index
1494 @param tvb the tv buffer of the current data
1495 @param start start of data in tvb
1496 @param length length of data in tvb
1497 @param value_ptr data to display
1498 @param format printf like format string
1499 @param ... printf like parameters
1500 @return the newly created item */
1501 WS_DLL_PUBLIC proto_item *
1502 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1503 gint start, gint length, const e_guid_t *value_ptr, const char *format,
1504 ...) G_GNUC_PRINTF(7,8);
1506 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1507 the entire string for the entry, including any field name.
1508 @param tree the tree to append this item to
1509 @param hfindex field index
1510 @param tvb the tv buffer of the current data
1511 @param start start of data in tvb
1512 @param length length of data in tvb
1513 @param value_ptr data to display
1514 @param format printf like format string
1515 @param ... printf like parameters
1516 @return the newly created item */
1517 WS_DLL_PUBLIC proto_item *
1518 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1519 gint length, const e_guid_t *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1521 /** Add a FT_OID to a proto_tree.
1522 @param tree the tree to append this item to
1523 @param hfindex field index
1524 @param tvb the tv buffer of the current data
1525 @param start start of data in tvb
1526 @param length length of data in tvb
1527 @param value_ptr data to display
1528 @return the newly created item */
1530 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1531 gint length, const guint8* value_ptr);
1533 /** Add a formatted FT_OID to a proto_tree, with the format generating
1534 the string for the value and with the field name being included
1536 @param tree the tree to append this item to
1537 @param hfindex field index
1538 @param tvb the tv buffer of the current data
1539 @param start start of data in tvb
1540 @param length length of data in tvb
1541 @param value_ptr data to display
1542 @param format printf like format string
1543 @param ... printf like parameters
1544 @return the newly created item */
1546 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1547 gint start, gint length, const guint8* value_ptr, const char *format,
1548 ...) G_GNUC_PRINTF(7,8);
1550 /** Add a formatted FT_OID to a proto_tree, with the format generating
1551 the entire string for the entry, including any field name.
1552 @param tree the tree to append this item to
1553 @param hfindex field index
1554 @param tvb the tv buffer of the current data
1555 @param start start of data in tvb
1556 @param length length of data in tvb
1557 @param value_ptr data to display
1558 @param format printf like format string
1559 @param ... printf like parameters
1560 @return the newly created item */
1562 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1563 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1565 /** Add a FT_STRING or FT_STRINGZPAD to a proto_tree.
1566 @param tree the tree to append this item to
1567 @param hfindex field index
1568 @param tvb the tv buffer of the current data
1569 @param start start of data in tvb
1570 @param length length of data in tvb
1571 @param value data to display
1572 @return the newly created item */
1573 WS_DLL_PUBLIC proto_item *
1574 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1575 gint length, const char* value);
1577 /** Add a formatted FT_STRING or FT_STRINGZPAD to a proto_tree, with the
1578 format generating the string for the value and with the field name
1579 being included automatically.
1580 @param tree the tree to append this item to
1581 @param hfindex field index
1582 @param tvb the tv buffer of the current data
1583 @param start start of data in tvb
1584 @param length length of data in tvb
1585 @param value data to display
1586 @param format printf like format string
1587 @param ... printf like parameters
1588 @return the newly created item */
1589 WS_DLL_PUBLIC proto_item *
1590 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1591 gint start, gint length, const char* value, const char *format, ...)
1594 /** Add a formatted FT_STRING or FT_STRINGZPAD to a proto_tree, with the
1595 format generating the entire string for the entry, including any field
1597 @param tree the tree to append this item to
1598 @param hfindex field index
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 value data to display
1603 @param format printf like format string
1604 @param ... printf like parameters
1605 @return the newly created item */
1606 WS_DLL_PUBLIC proto_item *
1607 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1608 gint length, const char* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1610 /** Add a FT_BOOLEAN to a proto_tree.
1611 @param tree the tree to append this item to
1612 @param hfindex field index
1613 @param tvb the tv buffer of the current data
1614 @param start start of data in tvb
1615 @param length length of data in tvb
1616 @param value data to display
1617 @return the newly created item */
1618 WS_DLL_PUBLIC proto_item *
1619 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1620 gint length, guint32 value);
1622 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1623 the string for the value and with the field name being included
1625 @param tree the tree to append this item to
1626 @param hfindex field index
1627 @param tvb the tv buffer of the current data
1628 @param start start of data in tvb
1629 @param length length of data in tvb
1630 @param value data to display
1631 @param format printf like format string
1632 @param ... printf like parameters
1633 @return the newly created item */
1634 WS_DLL_PUBLIC proto_item *
1635 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1636 tvbuff_t *tvb, gint start, gint length, guint32 value,
1637 const char *format, ...) G_GNUC_PRINTF(7,8);
1639 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1640 the entire string for the entry, including any field name.
1641 @param tree the tree to append this item to
1642 @param hfindex field index
1643 @param tvb the tv buffer of the current data
1644 @param start start of data in tvb
1645 @param length length of data in tvb
1646 @param value data to display
1647 @param format printf like format string
1648 @param ... printf like parameters
1649 @return the newly created item */
1650 WS_DLL_PUBLIC proto_item *
1651 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1652 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1654 /** Add a FT_FLOAT to a proto_tree.
1655 @param tree the tree to append this item to
1656 @param hfindex field index
1657 @param tvb the tv buffer of the current data
1658 @param start start of data in tvb
1659 @param length length of data in tvb
1660 @param value data to display
1661 @return the newly created item */
1662 WS_DLL_PUBLIC proto_item *
1663 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1664 gint length, float value);
1666 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1667 the string for the value and with the field name being included
1669 @param tree the tree to append this item to
1670 @param hfindex field index
1671 @param tvb the tv buffer of the current data
1672 @param start start of data in tvb
1673 @param length length of data in tvb
1674 @param value data to display
1675 @param format printf like format string
1676 @param ... printf like parameters
1677 @return the newly created item */
1678 WS_DLL_PUBLIC proto_item *
1679 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1680 gint start, gint length, float value, const char *format, ...)
1683 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1684 the entire string for the entry, including any field name.
1685 @param tree the tree to append this item to
1686 @param hfindex field index
1687 @param tvb the tv buffer of the current data
1688 @param start start of data in tvb
1689 @param length length of data in tvb
1690 @param value data to display
1691 @param format printf like format string
1692 @param ... printf like parameters
1693 @return the newly created item */
1694 WS_DLL_PUBLIC proto_item *
1695 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1696 gint length, float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1698 /** Add a FT_DOUBLE to a proto_tree.
1699 @param tree the tree to append this item to
1700 @param hfindex field index
1701 @param tvb the tv buffer of the current data
1702 @param start start of data in tvb
1703 @param length length of data in tvb
1704 @param value data to display
1705 @return the newly created item */
1706 WS_DLL_PUBLIC proto_item *
1707 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1708 gint length, double value);
1710 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1711 the string for the value and with the field name being included
1713 @param tree the tree to append this item to
1714 @param hfindex field index
1715 @param tvb the tv buffer of the current data
1716 @param start start of data in tvb
1717 @param length length of data in tvb
1718 @param value data to display
1719 @param format printf like format string
1720 @param ... printf like parameters
1721 @return the newly created item */
1722 WS_DLL_PUBLIC proto_item *
1723 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1724 gint start, gint length, double value, const char *format, ...)
1727 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1728 the entire string for the entry, including any field name.
1729 @param tree the tree to append this item to
1730 @param hfindex field index
1731 @param tvb the tv buffer of the current data
1732 @param start start of data in tvb
1733 @param length length of data in tvb
1734 @param value data to display
1735 @param format printf like format string
1736 @param ... printf like parameters
1737 @return the newly created item */
1738 WS_DLL_PUBLIC proto_item *
1739 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1740 gint length, double value, const char *format, ...) G_GNUC_PRINTF(7,8);
1742 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1743 @param tree the tree to append this item to
1744 @param hfindex field index
1745 @param tvb the tv buffer of the current data
1746 @param start start of data in tvb
1747 @param length length of data in tvb
1748 @param value data to display
1749 @return the newly created item */
1750 WS_DLL_PUBLIC proto_item *
1751 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1752 gint length, guint32 value);
1754 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1755 with the format generating the string for the value and with the field
1756 name being included automatically.
1757 @param tree the tree to append this item to
1758 @param hfindex field index
1759 @param tvb the tv buffer of the current data
1760 @param start start of data in tvb
1761 @param length length of data in tvb
1762 @param value data to display
1763 @param format printf like format string
1764 @param ... printf like parameters
1765 @return the newly created item */
1766 WS_DLL_PUBLIC proto_item *
1767 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1768 gint start, gint length, guint32 value, const char *format, ...)
1771 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1772 with the format generating the entire string for the entry, including any
1774 @param tree the tree to append this item to
1775 @param hfindex field index
1776 @param tvb the tv buffer of the current data
1777 @param start start of data in tvb
1778 @param length length of data in tvb
1779 @param value data to display
1780 @param format printf like format string
1781 @param ... printf like parameters
1782 @return the newly created item */
1783 WS_DLL_PUBLIC proto_item *
1784 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1785 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1787 /** Add an FT_UINT64 to a proto_tree.
1788 @param tree the tree to append this item to
1789 @param hfindex field index
1790 @param tvb the tv buffer of the current data
1791 @param start start of data in tvb
1792 @param length length of data in tvb
1793 @param value data to display
1794 @return the newly created item */
1795 WS_DLL_PUBLIC proto_item *
1796 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1797 gint length, guint64 value);
1799 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1800 the string for the value and with the field name being included
1802 @param tree the tree to append this item to
1803 @param hfindex field index
1804 @param tvb the tv buffer of the current data
1805 @param start start of data in tvb
1806 @param length length of data in tvb
1807 @param value data to display
1808 @param format printf like format string
1809 @param ... printf like parameters
1810 @return the newly created item */
1811 WS_DLL_PUBLIC proto_item *
1812 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1813 gint start, gint length, guint64 value, const char *format, ...)
1816 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1817 the entire string for the entry, including any field name.
1818 @param tree the tree to append this item to
1819 @param hfindex field index
1820 @param tvb the tv buffer of the current data
1821 @param start start of data in tvb
1822 @param length length of data in tvb
1823 @param value data to display
1824 @param format printf like format string
1825 @param ... printf like parameters
1826 @return the newly created item */
1827 WS_DLL_PUBLIC proto_item *
1828 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1829 gint length, guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1831 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1832 @param tree the tree to append this item to
1833 @param hfindex field index
1834 @param tvb the tv buffer of the current data
1835 @param start start of data in tvb
1836 @param length length of data in tvb
1837 @param value data to display
1838 @return the newly created item */
1839 WS_DLL_PUBLIC proto_item *
1840 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1841 gint length, gint32 value);
1843 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1844 with the format generating the string for the value and with the field
1845 name being included automatically.
1846 @param tree the tree to append this item to
1847 @param hfindex field index
1848 @param tvb the tv buffer of the current data
1849 @param start start of data in tvb
1850 @param length length of data in tvb
1851 @param value data to display
1852 @param format printf like format string
1853 @param ... printf like parameters
1854 @return the newly created item */
1855 WS_DLL_PUBLIC proto_item *
1856 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1857 gint start, gint length, gint32 value, const char *format, ...)
1860 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1861 with the format generating the entire string for the entry, including
1863 @param tree the tree to append this item to
1864 @param hfindex field index
1865 @param tvb the tv buffer of the current data
1866 @param start start of data in tvb
1867 @param length length of data in tvb
1868 @param value data to display
1869 @param format printf like format string
1870 @param ... printf like parameters
1871 @return the newly created item */
1872 WS_DLL_PUBLIC proto_item *
1873 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1874 gint length, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1876 /** Add an FT_INT64 to a proto_tree.
1877 @param tree the tree to append this item to
1878 @param hfindex field index
1879 @param tvb the tv buffer of the current data
1880 @param start start of data in tvb
1881 @param length length of data in tvb
1882 @param value data to display
1883 @return the newly created item */
1884 WS_DLL_PUBLIC proto_item *
1885 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1886 gint length, gint64 value);
1888 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1889 the string for the value and with the field name being included
1891 @param tree the tree to append this item to
1892 @param hfindex field index
1893 @param tvb the tv buffer of the current data
1894 @param start start of data in tvb
1895 @param length length of data in tvb
1896 @param value data to display
1897 @param format printf like format string
1898 @param ... printf like parameters
1899 @return the newly created item */
1900 WS_DLL_PUBLIC proto_item *
1901 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1902 gint start, gint length, gint64 value, const char *format, ...)
1905 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1906 the entire string for the entry, including any field name.
1907 @param tree the tree to append this item to
1908 @param hfindex field index
1909 @param tvb the tv buffer of the current data
1910 @param start start of data in tvb
1911 @param length length of data in tvb
1912 @param value data to display
1913 @param format printf like format string
1914 @param ... printf like parameters
1915 @return the newly created item */
1916 WS_DLL_PUBLIC proto_item *
1917 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1918 gint length, gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1920 /** Add a FT_EUI64 to a proto_tree.
1921 @param tree the tree to append this item to
1922 @param hfindex field index
1923 @param tvb the tv buffer of the current data
1924 @param start start of data in tvb
1925 @param length length of data in tvb
1926 @param value data to display
1927 @return the newly created item */
1928 WS_DLL_PUBLIC proto_item *
1929 proto_tree_add_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1930 gint length, const guint64 value);
1932 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
1933 the string for the value and with the field name being included
1935 @param tree the tree to append this item to
1936 @param hfindex field index
1937 @param tvb the tv buffer of the current data
1938 @param start start of data in tvb
1939 @param length length of data in tvb
1940 @param value data to display
1941 @param format printf like format string
1942 @param ... printf like parameters
1943 @return the newly created item */
1944 WS_DLL_PUBLIC proto_item *
1945 proto_tree_add_eui64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1946 gint start, gint length, const guint64 value, const char *format, ...)
1949 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
1950 the entire string for the entry, including any field name.
1951 @param tree the tree to append this item to
1952 @param hfindex field index
1953 @param tvb the tv buffer of the current data
1954 @param start start of data in tvb
1955 @param length length of data in tvb
1956 @param value data to display
1957 @param format printf like format string
1958 @param ... printf like parameters
1959 @return the newly created item */
1960 WS_DLL_PUBLIC proto_item *
1961 proto_tree_add_eui64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1962 gint length, const guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1965 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1966 leave call to this function in production code.
1967 @param tree the tree to append the text to
1968 @param format printf like format string
1969 @param ... printf like parameters
1970 @return the newly created item */
1971 WS_DLL_PUBLIC proto_item *
1972 proto_tree_add_debug_text(proto_tree *tree, const char *format,
1973 ...) G_GNUC_PRINTF(2,3);
1977 /** Append a string to a protocol item.<br>
1978 NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1980 Currently only WSP use this function so it is not that bad but try to
1981 avoid using this one if possible.
1982 IF you must use this function you MUST also disable the
1983 TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1984 using proto_item_append_string().
1985 Do that by faking that the tree is visible by calling
1986 proto_tree_set_visible(tree, TRUE) (see packet-wsp.c)
1987 BEFORE you create the item you are later going to use
1988 proto_item_append_string() on.
1989 @param pi the item to append the string to
1990 @param str the string to append */
1992 proto_item_append_string(proto_item *pi, const char *str);
1996 /** Fill given label_str with string representation of field
1997 @param fi the item to get the info from
1998 @param label_str the string to fill
1999 @todo think about changing the parameter profile */
2001 proto_item_fill_label(field_info *fi, gchar *label_str);
2004 /** Register a new protocol.
2005 @param name the full name of the new protocol
2006 @param short_name abbreviated name of the new protocol
2007 @param filter_name protocol name used for a display filter string
2008 @return the new protocol handle */
2010 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
2012 /** Deregister a protocol.
2013 @param short_name abbreviated name of the protocol
2014 @return TRUE if protocol is removed */
2015 WS_DLL_PUBLIC gboolean
2016 proto_deregister_protocol(const char *short_name);
2018 /** This type of function can be registered to get called whenever
2019 a given field was not found but a its prefix is matched;
2020 It can be used to procrastinate the hf array registration.
2021 @param match what's being matched */
2022 typedef void (*prefix_initializer_t)(const char* match);
2024 /** Register a new prefix for delayed initialization of field arrays
2025 @param prefix the prefix for the new protocol
2026 @param initializer function that will initialize the field array for the given prefix */
2028 proto_register_prefix(const char *prefix, prefix_initializer_t initializer);
2030 /** Initialize every remaining uninitialized prefix. */
2031 WS_DLL_PUBLIC void proto_initialize_all_prefixes(void);
2033 WS_DLL_PUBLIC void proto_register_fields_manual(const int parent, header_field_info **hfi, const int num_records);
2034 WS_DLL_PUBLIC void proto_register_fields_section(const int parent, header_field_info *hfi, const int num_records);
2036 /** Register a header_field array.
2037 @param parent the protocol handle from proto_register_protocol()
2038 @param hf the hf_register_info array
2039 @param num_records the number of records in hf */
2041 proto_register_field_array(const int parent, hf_register_info *hf, const int num_records);
2043 /** Deregister an already registered field.
2044 @param parent the protocol handle from proto_register_protocol()
2045 @param hf_id the field to deregister */
2047 proto_deregister_field (const int parent, gint hf_id);
2049 /** Add data to be freed when deregistered fields are freed.
2050 @param data a pointer to data to free */
2052 proto_add_deregistered_data (void *data);
2054 /** Free fields deregistered in proto_deregister_field(). */
2056 proto_free_deregistered_fields (void);
2058 /** Register a protocol subtree (ett) array.
2059 @param indices array of ett indices
2060 @param num_indices the number of records in indices */
2062 proto_register_subtree_array(gint *const *indices, const int num_indices);
2064 /** Get name of registered header_field number n.
2065 @param n item # n (0-indexed)
2066 @return the name of this registered item */
2067 WS_DLL_PUBLIC const char* proto_registrar_get_name(const int n);
2069 /** Get abbreviation of registered header_field number n.
2070 @param n item # n (0-indexed)
2071 @return the abbreviation of this registered item */
2072 WS_DLL_PUBLIC const char* proto_registrar_get_abbrev(const int n);
2074 /** Get the header_field information based upon a field or protocol id.
2075 @param hfindex item # n (0-indexed)
2076 @return the registered item */
2077 WS_DLL_PUBLIC header_field_info* proto_registrar_get_nth(guint hfindex);
2079 /** Get the header_field information based upon a field name.
2080 @param field_name the field name to search for
2081 @return the registered item */
2082 WS_DLL_PUBLIC header_field_info* proto_registrar_get_byname(const char *field_name);
2084 /** Get the header_field id based upon a field name.
2085 @param field_name the field name to search for
2086 @return the field id for the registered item */
2087 extern int proto_registrar_get_id_byname(const char *field_name);
2089 /** Get enum ftenum FT_ of registered header_field number n.
2090 @param n item # n (0-indexed)
2091 @return the registered item */
2092 WS_DLL_PUBLIC enum ftenum proto_registrar_get_ftype(const int n);
2094 /** Get parent protocol of registered header_field number n.
2095 @param n item # n (0-indexed)
2096 @return -1 if item _is_ a protocol */
2097 WS_DLL_PUBLIC int proto_registrar_get_parent(const int n);
2099 /** Is item # n a protocol?
2100 @param n item # n (0-indexed)
2101 @return TRUE if it's a protocol, FALSE if it's not */
2102 WS_DLL_PUBLIC gboolean proto_registrar_is_protocol(const int n);
2104 /** Get length of registered field according to field type.
2105 @param n item # n (0-indexed)
2106 @return 0 means undeterminable at registration time, -1 means unknown field */
2107 extern gint proto_registrar_get_length(const int n);
2110 /** Routines to use to iterate over the protocols and their fields;
2111 * they return the item number of the protocol in question or the
2112 * appropriate hfinfo pointer, and keep state in "*cookie". */
2113 WS_DLL_PUBLIC int proto_get_first_protocol(void **cookie);
2114 WS_DLL_PUBLIC int proto_get_data_protocol(void *cookie);
2115 WS_DLL_PUBLIC int proto_get_next_protocol(void **cookie);
2116 WS_DLL_PUBLIC header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookie);
2117 WS_DLL_PUBLIC header_field_info *proto_get_next_protocol_field(const int proto_id, void **cookie);
2119 /** Given a protocol's filter_name.
2120 @param filter_name the filter name to search for
2122 WS_DLL_PUBLIC int proto_get_id_by_filter_name(const gchar* filter_name);
2124 /** Given a protocol's short name.
2125 @param short_name the protocol short name to search for
2127 WS_DLL_PUBLIC int proto_get_id_by_short_name(const gchar* short_name);
2129 /** Can item # n decoding be disabled?
2130 @param proto_id protocol id (0-indexed)
2131 @return TRUE if it's a protocol, FALSE if it's not */
2132 WS_DLL_PUBLIC gboolean proto_can_toggle_protocol(const int proto_id);
2134 /** Get the "protocol_t" structure for the given protocol's item number.
2135 @param proto_id protocol id (0-indexed) */
2136 WS_DLL_PUBLIC protocol_t *find_protocol_by_id(const int proto_id);
2138 /** Get the protocol's name for the given protocol's item number.
2139 @param proto_id protocol id (0-indexed)
2141 WS_DLL_PUBLIC const char *proto_get_protocol_name(const int proto_id);
2143 /** Get the protocol's item number, for the given protocol's "protocol_t".
2144 @return its proto_id */
2145 WS_DLL_PUBLIC int proto_get_id(const protocol_t *protocol);
2147 /** Get the protocol's short name, for the given protocol's "protocol_t".
2148 @return its short name. */
2149 WS_DLL_PUBLIC const char *proto_get_protocol_short_name(const protocol_t *protocol);
2151 /** Get the protocol's long name, for the given protocol's "protocol_t".
2152 @return its long name. */
2153 WS_DLL_PUBLIC const char *proto_get_protocol_long_name(const protocol_t *protocol);
2155 /** Is protocol's decoding enabled ?
2156 @return TRUE if decoding is enabled, FALSE if not */
2157 WS_DLL_PUBLIC gboolean proto_is_protocol_enabled(const protocol_t *protocol);
2159 /** Get a protocol's filter name by its item number.
2160 @param proto_id protocol id (0-indexed)
2161 @return its filter name. */
2162 WS_DLL_PUBLIC const char *proto_get_protocol_filter_name(const int proto_id);
2164 /** Associate a heuristic dissector with a protocol
2165 * INTERNAL USE ONLY!!!
2166 * @param protocol to associate the heuristic with
2167 * @param short_name heuristic dissector's short name
2169 extern void proto_add_heuristic_dissector(protocol_t *protocol, const char *short_name);
2171 /** Apply func to all heuristic dissectors of a protocol
2172 * @param protocol to iterate over heuristics
2173 * @param func function to execute on heuristics
2174 * @param user_data user-specific data for function
2176 WS_DLL_PUBLIC void proto_heuristic_dissector_foreach(const protocol_t *protocol, GFunc func, gpointer user_data);
2179 /** Find commonly-used protocols in a layer list.
2180 * @param layers Protocol layer list
2181 * @param is_ip Set to TRUE if the layer list contains IPv4 or IPv6, otherwise
2182 * unchanged. May be NULL.
2183 * @param is_tcp Set to TRUE if the layer list contains TCP, otherwise
2184 * unchanged. May be NULL.
2185 * @param is_udp Set to TRUE if the layer list contains UDP, otherwise
2186 * unchanged. May be NULL.
2187 * @param is_sctp Set to TRUE if the layer list contains SCTP, otherwise
2188 * unchanged. May be NULL.
2189 * @param is_ssl Set to TRUE if the layer list contains SSL/TLS, otherwise
2190 * unchanged. May be NULL.
2191 * @param is_rtp Set to TRUE if the layer list contains RTP, otherwise
2192 * unchanged. May be NULL.
2193 * @param is_lte_rlc Set to TRUE if the layer list contains LTE RLC, otherwise
2194 * unchanged. May be NULL.
2196 WS_DLL_PUBLIC void proto_get_frame_protocols(const wmem_list_t *layers,
2197 gboolean *is_ip, gboolean *is_tcp, gboolean *is_udp, gboolean *is_sctp,
2198 gboolean *is_ssl, gboolean *is_rtp, gboolean *is_lte_rlc);
2200 /** Find a protocol by name in a layer list.
2201 * @param layers Protocol layer list
2202 * @param proto_name Name of protocol to find
2204 WS_DLL_PUBLIC gboolean proto_is_frame_protocol(const wmem_list_t *layers, const char* proto_name);
2206 /** Enable / Disable protocol of the given item number.
2207 @param proto_id protocol id (0-indexed)
2208 @param enabled enable / disable the protocol */
2209 WS_DLL_PUBLIC void proto_set_decoding(const int proto_id, const gboolean enabled);
2211 /** Enable all protocols */
2212 WS_DLL_PUBLIC void proto_enable_all(void);
2214 /** Disable disabling/enabling of protocol of the given item number.
2215 @param proto_id protocol id (0-indexed) */
2216 WS_DLL_PUBLIC void proto_set_cant_toggle(const int proto_id);
2218 /** Checks for existence any protocol or field within a tree.
2219 @param tree "Protocols" are assumed to be a child of the [empty] root node.
2220 @param id hfindex of protocol or field
2221 @return TRUE = found, FALSE = not found
2222 @todo add explanation of id parameter */
2223 extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id);
2225 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2226 tree. Only works with primed trees, and is fast.
2227 @param tree tree of interest
2228 @param hfindex primed hfindex
2229 @return GPtrArry pointer */
2230 WS_DLL_PUBLIC GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
2232 /** Return whether we're tracking any interesting fields.
2233 Only works with primed trees, and is fast.
2234 @param tree tree of interest
2235 @return TRUE if we're tracking interesting fields */
2236 WS_DLL_PUBLIC gboolean proto_tracking_interesting_fields(const proto_tree *tree);
2238 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
2239 tree. Works with any tree, primed or unprimed, and is slower than
2241 proto_get_finfo_ptr_array because it has to search through the tree.
2242 @param tree tree of interest
2243 @param hfindex index of field info of interest
2244 @return GPtrArry pointer */
2245 WS_DLL_PUBLIC GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex);
2247 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
2249 @param tree tree of interest
2250 @return GPtrArry pointer */
2251 WS_DLL_PUBLIC GPtrArray* proto_all_finfos(proto_tree *tree);
2253 /** Dumps a glossary of the protocol registrations to STDOUT */
2254 WS_DLL_PUBLIC void proto_registrar_dump_protocols(void);
2256 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
2257 WS_DLL_PUBLIC void proto_registrar_dump_values(void);
2259 /** Dumps the number of protocol and field registrations to STDOUT.
2260 @return FALSE if we pre-allocated enough fields, TRUE otherwise. */
2261 WS_DLL_PUBLIC gboolean proto_registrar_dump_fieldcount(void);
2263 /** Dumps a glossary of the protocol and field registrations to STDOUT. */
2264 WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
2266 /** Dumps a glossary field types and descriptive names to STDOUT */
2267 WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
2270 /** Number of elements in the tree_is_expanded array. With MSVC and a
2271 * libwireshark.dll, we need a special declaration. */
2272 WS_DLL_PUBLIC int num_tree_types;
2274 /** Returns TRUE if subtrees of that type are to be expanded. */
2275 WS_DLL_PUBLIC gboolean tree_expanded(int tree_type);
2277 /** Sets if subtrees of that type are to be expanded. */
2278 WS_DLL_PUBLIC void tree_expanded_set(int tree_type, gboolean value);
2280 /** glib doesn't have g_ptr_array_len of all things!*/
2281 #ifndef g_ptr_array_len
2282 #define g_ptr_array_len(a) ((a)?(a)->len:0)
2285 /** Get number of bits of a header_field.
2286 @param hfinfo header_field
2287 @return the bitwidth */
2289 hfinfo_bitwidth(const header_field_info *hfinfo);
2292 hfinfo_bitshift(const header_field_info *hfinfo);
2294 struct epan_dissect;
2296 /** Can we do a "match selected" on this field.
2297 @param finfo field_info
2298 @param edt epan dissecting
2299 @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
2300 WS_DLL_PUBLIC gboolean
2301 proto_can_match_selected(field_info *finfo, struct epan_dissect *edt);
2303 /** Construct a "match selected" display filter string.
2304 @param finfo field_info
2305 @param edt epan dissecting
2306 @return the wmem NULL alloced display filter string. Needs to be freed with wmem_free(NULL, ...) */
2308 proto_construct_match_selected_string(field_info *finfo, struct epan_dissect *edt);
2310 /** Find field from offset in tvb.
2311 @param tree tree of interest
2312 @param offset offset in the tvb
2313 @param tvb the tv buffer
2314 @return the corresponding field_info */
2315 WS_DLL_PUBLIC field_info*
2316 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
2318 /** Find undecoded bytes in a tree
2319 @param tree tree of interest
2320 @param length the length of the frame
2321 @return an array to be used as bitmap of decoded bytes */
2322 WS_DLL_PUBLIC gchar*
2323 proto_find_undecoded_data(proto_tree *tree, guint length);
2325 /** This function will dissect a sequence of bytes that describe a bitmask.
2326 @param tree the tree to append this item to
2327 @param tvb the tv buffer of the current data
2328 @param offset start of data in tvb
2329 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
2330 This field will form an expansion under which the individual fields of the
2331 bitmask is dissected and displayed.
2332 This field must be of the type FT_[U]INT{8|16|24|32}.
2333 @param ett subtree index
2334 @param fields an array of pointers to int that lists all the fields of the
2335 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2336 or another integer of the same type/size as hf_hdr with a mask specified.
2337 This array is terminated by a NULL entry.
2338 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2339 FT_integer fields that have a value_string attached will have the
2340 matched string displayed on the expansion line.
2341 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2342 @return the newly created item */
2343 WS_DLL_PUBLIC proto_item *
2344 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2345 const int hf_hdr, const gint ett, const int **fields, const guint encoding);
2347 /** This function will dissect a sequence of bytes that describe a bitmask.
2348 * This has "filterable" bitmask header functionality of proto_tree_add_bitmask
2349 * with the ability to control what data is appended to the header like
2350 * proto_tree_add_bitmask_text
2351 @param tree the tree to append this item to
2352 @param tvb the tv buffer of the current data
2353 @param offset start of data in tvb
2354 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
2355 This field will form an expansion under which the individual fields of the
2356 bitmask is dissected and displayed.
2357 This field must be of the type FT_[U]INT{8|16|24|32}.
2358 @param ett subtree index
2359 @param fields an array of pointers to int that lists all the fields of the
2360 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2361 or another integer of the same type/size as hf_hdr with a mask specified.
2362 This array is terminated by a NULL entry.
2363 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2364 FT_integer fields that have a value_string attached will have the
2365 matched string displayed on the expansion line.
2366 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2367 @param flags bitmask field using BMT_NO_* flags to determine behavior
2368 @return the newly created item */
2369 WS_DLL_PUBLIC proto_item *
2370 proto_tree_add_bitmask_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2371 const int hf_hdr, const gint ett, const int **fields, const guint encoding, const int flags);
2373 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
2374 but with a passed in value (presumably because it can't be retrieved directly from tvb)
2375 @param tree the tree to append this item to
2376 @param tvb the tv buffer of the current data
2377 @param offset start of data in tvb
2378 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
2379 This field will form an expansion under which the individual fields of the
2380 bitmask is dissected and displayed.
2381 This field must be of the type FT_[U]INT{8|16|24|32|64}.
2382 @param ett subtree index
2383 @param fields an array of pointers to int that lists all the fields of the
2384 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2385 or another integer of the same type/size as hf_hdr with a mask specified.
2386 This array is terminated by a NULL entry.
2387 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2388 FT_integer fields that have a value_string attached will have the
2389 matched string displayed on the expansion line.
2390 @param value bitmask value
2391 @return the newly created item */
2392 WS_DLL_PUBLIC proto_item *
2393 proto_tree_add_bitmask_value(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2394 const int hf_hdr, const gint ett, const int **fields, const guint64 value);
2396 /** This function will dissect a value that describe a bitmask. Similar to proto_tree_add_bitmask(),
2397 but with a passed in value (presumably because it can't be retrieved directly from tvb)
2398 This has "filterable" bitmask header functionality of proto_tree_add_bitmask_value
2399 with the ability to control what data is appended to the header like
2400 proto_tree_add_bitmask_text
2401 @param tree the tree to append this item to
2402 @param tvb the tv buffer of the current data
2403 @param offset start of data in tvb
2404 @param hf_hdr an 8/16/24/32/64 bit integer that describes the bitmask to be dissected.
2405 This field will form an expansion under which the individual fields of the
2406 bitmask is dissected and displayed.
2407 This field must be of the type FT_[U]INT{8|16|24|32|64}.
2408 @param ett subtree index
2409 @param fields an array of pointers to int that lists all the fields of the
2410 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2411 or another integer of the same type/size as hf_hdr with a mask specified.
2412 This array is terminated by a NULL entry.
2413 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2414 FT_integer fields that have a value_string attached will have the
2415 matched string displayed on the expansion line.
2416 @param value bitmask value
2417 @param flags bitmask field using BMT_NO_* flags to determine behavior
2418 @return the newly created item */
2419 WS_DLL_PUBLIC proto_item *
2420 proto_tree_add_bitmask_value_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2421 const int hf_hdr, const gint ett, const int **fields, const guint64 value, const int flags);
2423 /** This function will dissect a sequence of bytes that describe a bitmask. Similar
2424 to proto_tree_add_bitmask(), but with no "header" item to group all of the fields
2425 @param tree the tree to append this item to
2426 @param tvb the tv buffer of the current data
2427 @param offset start of data in tvb
2428 @param len number of bytes of data
2429 @param fields an array of pointers to int that lists all the fields of the
2430 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2431 or another integer of the same type/size as hf_hdr with a mask specified.
2432 This array is terminated by a NULL entry.
2433 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2434 FT_integer fields that have a value_string attached will have the
2435 matched string displayed on the expansion line.
2436 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2439 proto_tree_add_bitmask_list(proto_tree *tree, tvbuff_t *tvb, const guint offset,
2440 const int len, const int **fields, const guint encoding);
2444 /** This function will dissect a sequence of bytes that describe a bitmask.
2445 @param tree the tree to append this item to
2446 @param tvb the tv buffer of the current data
2447 @param offset start of data in tvb
2448 @param len number of bytes of data
2449 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
2450 This field will form an expansion under which the individual fields of the
2451 bitmask are dissected and displayed.
2452 This field must be of the type FT_[U]INT{8|16|24|32}.
2453 @param ett subtree index
2454 @param fields an array of pointers to int that lists all the fields of the
2455 bitmask. These fields can be either of the type FT_BOOLEAN for flags
2456 or another integer with a mask specified.
2457 This array is terminated by a NULL entry.
2458 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
2459 FT_integer fields that have a value_string attached will have the
2460 matched string displayed on the expansion line.
2461 @param exp expert info field used when decodable_len < len. This also means this function
2462 should be called even when tree == NULL
2463 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2464 @return the newly created item */
2465 WS_DLL_PUBLIC proto_item *
2466 proto_tree_add_bitmask_len(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
2467 const int hf_hdr, const gint ett, const int **fields, struct expert_field* exp, const guint encoding);
2469 /** Add a text with a subtree of bitfields.
2470 @param tree the tree to append this item to
2471 @param tvb the tv buffer of the current data
2472 @param offset start of data in tvb
2473 @param len length of the field name
2474 @param name field name (NULL if bitfield contents should be used)
2475 @param fallback field name if none of bitfields were usable
2476 @param ett subtree index
2477 @param fields NULL-terminated array of bitfield indexes
2478 @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2479 @param flags bitmask field
2480 @return the newly created item */
2481 WS_DLL_PUBLIC proto_item *
2482 proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
2483 const char *name, const char *fallback,
2484 const gint ett, const int **fields, const guint encoding, const int flags);
2486 #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */
2487 #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */
2488 #define BMT_NO_FALSE 0x04 /**< Don't add booleans unless they're TRUE */
2489 #define BMT_NO_TFS 0x08 /**< Don't use true_false_string while formatting booleans */
2491 /** Add bits to a proto_tree, using the text label registered to that item.
2492 The item is extracted from the tvbuff handed to it.
2493 @param tree the tree to append this item to
2494 @param hf_index field index. Fields for use with this function should have bitmask==0.
2495 @param tvb the tv buffer of the current data
2496 @param bit_offset start of data in tvb expressed in bits
2497 @param no_of_bits length of data in tvb expressed in bits
2498 @param encoding data encoding
2499 @return the newly created item */
2500 WS_DLL_PUBLIC proto_item *
2501 proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, const guint encoding);
2503 /** Add bits to a proto_tree, using the text label registered to that item.
2504 * The item is extracted from the tvbuff handed to it as a set
2505 * of crumbs (segments) of contiguous bits, specified by an
2506 * array of crumb_spec elements. The crumbs are assembled to
2507 * create the value. There may be any number of crumbs
2508 * specifying up to a total of 64 bits which may occur anywhere
2509 * within the tvb. If the span of the crumbs within the tvb is 4
2510 * octets or less, a bitmap of the crumbs is produced.
2511 @param tree the tree to append this item to
2512 @param hf_index field index. Fields for use with this function should have bitmask==0.
2513 @param tvb the tv buffer of the current data
2514 @param bit_offset of the first crumb in tvb expressed in bits
2515 @param crumb_spec pointer to crumb_spec array
2516 @param return_value if a pointer is passed here the value is returned.
2517 @return the newly created item */
2519 proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
2520 const guint bit_offset, const crumb_spec_t *crumb_spec,
2521 guint64 *return_value);
2524 /** Add bitmap text for a split-bits crumb to a proto_tree,
2525 * using the text label registered to an item. The bitmap is
2526 * extracted from the tvbuff handed to it as a crumb (segment)
2527 * of contiguous bits, specified by one of an array of
2528 * crumb_spec elements. This function is normally called once
2529 * per crumb, after the call to
2530 proto_tree_add_split_bits_item_ret_val
2531 @param tree the tree to append this item to
2532 @param hf_index field index. Fields for use with this function should have bitmask==0.
2533 @param tvb the tv buffer of the current data
2534 @param bit_offset of the first crumb in tvb expressed in bits
2535 @param crumb_spec pointer to crumb_spec array
2536 @param crumb_index into the crumb_spec array for this crumb */
2538 proto_tree_add_split_bits_crumb(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset,
2539 const crumb_spec_t *crumb_spec, guint16 crumb_index);
2541 /** Add bits to a proto_tree, using the text label registered to that item.
2542 The item is extracted from the tvbuff handed to it.
2543 @param tree the tree to append this item to
2544 @param hf_index field index. Fields for use with this function should have bitmask==0.
2545 @param tvb the tv buffer of the current data
2546 @param bit_offset start of data in tvb expressed in bits
2547 @param no_of_bits length of data in tvb expressed in bits
2548 @param return_value if a pointer is passed here the value is returned.
2549 @param encoding data encoding
2550 @return the newly created item */
2551 WS_DLL_PUBLIC proto_item *
2552 proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, guint64 *return_value, const guint encoding);
2554 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
2555 header field to a proto_tree, with the format generating the
2556 string for the value and with the field name being included automatically.
2557 @param tree the tree to append this item to
2558 @param hf_index field index
2559 @param tvb the tv buffer of the current data
2560 @param bit_offset start of data in tvb expressed in bits
2561 @param no_of_bits length of data in tvb expressed in bit
2562 @param value data to display
2563 @param format printf like format string
2564 @return the newly created item */
2565 WS_DLL_PUBLIC proto_item *
2566 proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2567 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2569 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
2570 header field to a proto_tree, with the format generating the
2571 string for the value and with the field name being included automatically.
2572 @param tree the tree to append this item to
2573 @param hf_index field index
2574 @param tvb the tv buffer of the current data
2575 @param bit_offset start of data in tvb expressed in bits
2576 @param no_of_bits length of data in tvb expressed in bit
2577 @param value data to display
2578 @param format printf like format string
2579 @return the newly created item */
2580 WS_DLL_PUBLIC proto_item *
2581 proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2582 guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2584 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
2585 the format generating the string for the value and with the field
2586 name being included automatically.
2587 @param tree the tree to append this item to
2588 @param hf_index field index
2589 @param tvb the tv buffer of the current data
2590 @param bit_offset start of data in tvb expressed in bits
2591 @param no_of_bits length of data in tvb expressed in bit
2592 @param value data to display
2593 @param format printf like format string
2594 @param ... printf like parameters
2595 @return the newly created item */
2597 proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2598 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2600 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
2601 the format generating the string for the value and with the field
2602 name being included automatically.
2603 @param tree the tree to append this item to
2604 @param hf_index field index
2605 @param tvb the tv buffer of the current data
2606 @param bit_offset start of data in tvb expressed in bits
2607 @param no_of_bits length of data in tvb expressed in bit
2608 @param value data to display
2609 @param format printf like format string
2610 @param ... printf like parameters
2611 @return the newly created item */
2613 proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2614 guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2616 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
2617 header field to a proto_tree, with the format generating the
2618 string for the value and with the field name being included automatically.
2619 @param tree the tree to append this item to
2620 @param hf_index field index
2621 @param tvb the tv buffer of the current data
2622 @param bit_offset start of data in tvb expressed in bits
2623 @param no_of_bits length of data in tvb expressed in bit
2624 @param value data to display
2625 @param format printf like format string
2626 @param ... printf like parameters
2627 @return the newly created item */
2629 proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2630 gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2632 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
2633 header field to a proto_tree, with the format generating the
2634 string for the value and with the field name being included automatically.
2635 @param tree the tree to append this item to
2636 @param hf_index field index
2637 @param tvb the tv buffer of the current data
2638 @param bit_offset start of data in tvb expressed in bits
2639 @param no_of_bits length of data in tvb expressed in bit
2640 @param value data to display
2641 @param format printf like format string
2642 @param ... printf like parameters
2643 @return the newly created item */
2645 proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2646 gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2648 /** Add bits for a FT_FLOAT header field to a proto_tree, with
2649 the format generating the string for the value and with the field
2650 name being included automatically.
2651 @param tree the tree to append this item to
2652 @param hf_index field index
2653 @param tvb the tv buffer of the current data
2654 @param bit_offset start of data in tvb expressed in bits
2655 @param no_of_bits length of data in tvb expressed in bit
2656 @param value data to display
2657 @param format printf like format string
2658 @param ... printf like parameters
2659 @return the newly created item */
2661 proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits,
2662 float value, const char *format, ...) G_GNUC_PRINTF(7,8);
2665 /** Add a FT_STRING with ENC_3GPP_TS_23_038_7BITS encoding to a proto_tree.
2666 @param tree the tree to append this item to
2667 @param hfindex field index
2668 @param tvb the tv buffer of the current data
2669 @param bit_offset start of data in tvb expressed in bits
2670 @param no_of_chars number of 7bits characters to display
2671 @return the newly created item */
2672 WS_DLL_PUBLIC proto_item *
2673 proto_tree_add_ts_23_038_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
2674 const guint bit_offset, const gint no_of_chars);
2676 /** Add a FT_STRING with ENC_ASCII_7BITS encoding to a proto_tree.
2677 @param tree the tree to append this item to
2678 @param hfindex field index
2679 @param tvb the tv buffer of the current data
2680 @param bit_offset start of data in tvb expressed in bits
2681 @param no_of_chars number of 7bits characters to display
2682 @return the newly created item */
2683 WS_DLL_PUBLIC proto_item *
2684 proto_tree_add_ascii_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
2685 const guint bit_offset, const gint no_of_chars);
2687 /** Check if given string is a valid field name
2688 @param field_name the field name to check
2689 @return 0 if valid, else first illegal character */
2690 WS_DLL_PUBLIC guchar
2691 proto_check_field_name(const gchar *field_name);
2694 /** Check if given string is a valid field name
2695 @param tree the tree to append this item to
2696 @param field_id the field id used for custom column
2697 @param occurrence the occurrence of the field used for custom column
2698 @param result the buffer to fill with the field string
2699 @param expr the filter expression
2700 @param size the size of the string buffer */
2702 proto_custom_set(proto_tree* tree, GSList *field_id,
2705 gchar *expr, const int size );
2707 /* #define HAVE_HFI_SECTION_INIT */
2709 #ifdef HAVE_HFI_SECTION_INIT
2710 #define HFI_INIT(proto) __attribute__((section( "_data_" G_STRINGIFY(proto)))) __attribute__((aligned(sizeof(void *))))
2712 #define proto_register_fields(proto, hfi, count) \
2714 extern header_field_info __start__data_ ##proto[]; \
2715 extern header_field_info __stop__data_ ##proto[]; \
2717 proto_register_fields_section(proto, __start__data_ ##proto, (int) (__stop__data_ ##proto - __start__data_ ##proto)); \
2720 #define HFI_INIT(proto)
2721 #define proto_register_fields(proto, hfi, count) \
2722 proto_register_fields_manual(proto, hfi, count)
2725 #ifdef NEW_PROTO_TREE_API
2726 #define proto_tree_add_item(tree, hfinfo, tvb, start, length, encoding) \
2727 proto_tree_add_item_new(tree, hfinfo, tvb, start, length, encoding)
2729 #define proto_tree_add_boolean(tree, hfinfo, tvb, start, length, value) \
2730 proto_tree_add_boolean(tree, (hfinfo)->id, tvb, start, length, value)
2732 #define proto_tree_add_string(tree, hfinfo, tvb, start, length, value) \
2733 proto_tree_add_string(tree, (hfinfo)->id, tvb, start, length, value)
2735 #define proto_tree_add_time(tree, hfinfo, tvb, start, length, value) \
2736 proto_tree_add_time(tree, (hfinfo)->id, tvb, start, length, value)
2738 #define proto_tree_add_int(tree, hfinfo, tvb, start, length, value) \
2739 proto_tree_add_int(tree, (hfinfo)->id, tvb, start, length, value)
2741 #define proto_tree_add_uint(tree, hfinfo, tvb, start, length, value) \
2742 proto_tree_add_uint(tree, (hfinfo)->id, tvb, start, length, value)
2744 #define proto_tree_add_float_format_value(tree, hfinfo, \
2745 tvb, start, length, value, format, ...) \
2746 proto_tree_add_float_format_value(tree, (hfinfo)->id, \
2747 tvb, start, length, value, format, __VA_ARGS__)
2754 #endif /* __cplusplus */
2756 #endif /* proto.h */