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