Try to improve the "Kerberos requested but not OpenSSL" message.
[jelmer/wireshark.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 #ifdef HAVE_STDARG_H
39 # include <stdarg.h>
40 #else
41 # include <varargs.h>
42 #endif
43
44 #include <glib.h>
45
46 #include <epan/emem.h>
47 #include <epan/wmem/wmem.h>
48
49 #include "ipv4.h"
50 #include "wsutil/nstime.h"
51 #include "time_fmt.h"
52 #include "tvbuff.h"
53 #include "ftypes/ftypes.h"
54 #include "register.h"
55 #include "ws_symbol_export.h"
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif /* __cplusplus */
60
61 /** @defgroup prototree The Protocol Tree
62  *
63  * Dissectors use proto_tree_add_* to add items to the protocol tree. In
64  * most cases you'll want to use proto_tree_add_item(). In general
65  * proto_tree_add_text() should be avoided unless you explicitly don't
66  * want to allow filtering.
67  *
68  * @{
69  */
70
71 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
72 WS_DLL_PUBLIC int hf_text_only;
73
74 /** the maximum length of a protocol field string representation */
75 #define ITEM_LABEL_LENGTH       240
76
77 struct _value_string;
78 struct expert_field;
79
80 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
81 #define VALS(x) (const struct _value_string*)(x)
82
83 /** Make a const val64_string[] look like a _val64_string pointer, used to set header_field_info.strings */
84 #define VALS64(x)   (const struct _val64_string*)(x)
85
86 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
87 #define TFS(x)  (const struct true_false_string*)(x)
88
89 typedef void (*custom_fmt_func_t)(gchar *, guint32);
90
91 /** Make a const range_string[] look like a _range_string pointer, used to set
92  * header_field_info.strings */
93 #define RVALS(x) (const struct _range_string*)(x)
94
95 struct _protocol;
96
97 /** Structure for information about a protocol */
98 typedef struct _protocol protocol_t;
99
100 /** Function used for reporting errors in dissectors; it throws a
101  * DissectorError exception, with the string passed as an argument
102  * as the message for the exception, so that it can show up in
103  * the Info column and the protocol tree.
104  *
105  * If that string is dynamically allocated, it should be allocated with
106  * ep_alloc(); using ep_strdup_printf() would work.
107  *
108  * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
109  * it will call abort(), instead, to make it easier to get a stack trace.
110  *
111  * @param message string to use as the message
112  */
113 WS_DLL_PUBLIC WS_MSVC_NORETURN void proto_report_dissector_bug(const char *message) G_GNUC_NORETURN;
114
115 #define REPORT_DISSECTOR_BUG(message)  \
116         proto_report_dissector_bug(message)
117
118 /** Macro used to provide a hint to static analysis tools.
119  * (Currently only Visual C++.)
120  */
121 #if _MSC_VER >= 1400
122 /* XXX - Is there a way to say "quit checking at this point"? */
123 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
124   ; __analysis_assume(expression);
125 #else
126 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
127 #endif
128
129 /** Macro used for assertions in dissectors; it doesn't abort, it just
130  * throws a DissectorError exception, with the assertion failure
131  * message as a parameter, so that it can show up in the protocol tree.
132  *
133  * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
134  * conditions that shouldn't happen).  It should NOT be used for showing
135  * that a packet is malformed.  For that, use expert_infos instead.
136  *
137  * @param expression expression to test in the assertion
138  */
139
140 #define DISSECTOR_ASSERT(expression)  \
141   ((void) ((expression) ? (void)0 : \
142    __DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
143    __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
144
145 /**
146  * Same as DISSECTOR_ASSERT(), but takes an extra 'hint' parameter that
147  * can be used to provide information as to why the assertion might fail.
148  *
149  * @param expression expression to test in the assertion
150  * @param hint message providing extra information
151  */
152 #define DISSECTOR_ASSERT_HINT(expression, hint)  \
153   ((void) ((expression) ? (void)0 : \
154    __DISSECTOR_ASSERT_HINT (expression, __FILE__, __LINE__, hint))) \
155    __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
156
157 #if 0
158 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
159  * as the assert handling of GTK/GLib is currently not very helpful */
160 #define DISSECTOR_ASSERT(expression)  \
161 { if(!(expression)) _asm { int 3}; }
162 #endif
163
164 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
165  * unconditionally, much like GLIB's g_assert_not_reached works.
166  *
167  * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
168  * conditions that shouldn't happen).  It should NOT be used for showing
169  * that a packet is malformed.  For that, use expert_infos instead.
170  *
171  */
172 #define DISSECTOR_ASSERT_NOT_REACHED()  \
173   (REPORT_DISSECTOR_BUG( \
174     ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
175      __FILE__, __LINE__)))
176
177 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
178
179 #define __DISSECTOR_ASSERT(expression, file, lineno)  \
180   (REPORT_DISSECTOR_BUG( \
181     ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
182      file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
183
184 #define __DISSECTOR_ASSERT_HINT(expression, file, lineno, hint)  \
185   (REPORT_DISSECTOR_BUG( \
186     ep_strdup_printf("%s:%u: failed assertion \"%s\" (%s)", \
187      file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression), hint)))
188
189 /*
190  * The encoding of a field of a particular type may involve more
191  * than just whether it's big-endian or little-endian and its size.
192  *
193  * For integral values, that's it, as 99.9999999999999% of the machines
194  * out there are 2's complement binary machines with 8-bit bytes,
195  * so the protocols out there expect that and, for example, any Unisys
196  * 2200 series machines out there just have to translate between 2's
197  * complement and 1's complement (and nobody's put any IBM 709x's on
198  * any networks lately :-)).
199  *
200  * However:
201  *
202  *      for floating-point numbers, in addition to IEEE decimal
203  *      floating-point, there's also IBM System/3x0 and PDP-11/VAX
204  *      floating-point - most protocols use IEEE binary, but DCE RPC
205  *      can use other formats if that's what the sending host uses;
206  *
207  *      for character strings, there are various character encodings
208  *      (various ISO 646 sets, ISO 8859/x, various other national
209  *      standards, various DOS and Windows encodings, various Mac
210  *      encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
211  *      etc.);
212  *
213  *      for absolute times, there's UNIX time_t, UNIX time_t followed
214  *      by 32-bit microseconds, UNIX time_t followed by 32-bit
215  *      nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
216  *
217  * We might also, in the future, want to allow a field specifier to
218  * indicate the encoding of the field, or at least its default
219  * encoding, as most fields in most protocols always use the
220  * same encoding (although that's not true of all fields, so we
221  * still need to be able to specify that at run time).
222  *
223  * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
224  * bit flags, to be combined, in the future, with other information
225  * to specify the encoding in the last argument to
226  * proto_tree_add_item(), and possibly to specify in a field
227  * definition (e.g., ORed in with the type value).
228  *
229  * Currently, proto_tree_add_item() treats its last argument as a
230  * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
231  * the field is little-endian - and other code in epan/proto.c does
232  * the same.  We therefore define ENC_BIG_ENDIAN as 0x00000000 and
233  * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
234  * so that we could put a field type and/or a value such as a character
235  * encoding in the lower bits.
236  */
237 #define ENC_BIG_ENDIAN          0x00000000
238 #define ENC_LITTLE_ENDIAN       0x80000000
239
240 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
241     #define ENC_HOST_ENDIAN ENC_LITTLE_ENDIAN
242 #else
243     #define ENC_HOST_ENDIAN ENC_BIG_ENDIAN
244 #endif
245
246
247 /*
248  * Historically FT_TIMEs were only timespecs; the only question was whether
249  * they were stored in big- or little-endian format.
250  *
251  * For backwards compatibility, we interpret an encoding of 1 as meaning
252  * "little-endian timespec", so that passing TRUE is interpreted as that.
253  */
254 #define ENC_TIME_TIMESPEC       0x00000000      /* "struct timespec" */
255 #define ENC_TIME_NTP            0x00000002      /* NTP times */
256 #define ENC_TIME_TOD            0x00000004      /* System/3xx and z/Architecture time-of-day clock */
257
258 /*
259  * Historically, the only place the representation mattered for strings
260  * was with FT_UINT_STRINGs, where we had FALSE for the string length
261  * being big-endian and TRUE for it being little-endian.
262  *
263  * We now have encoding values for the character encoding.  The encoding
264  * values are encoded in all but the top bit (which is the byte-order
265  * bit, required for FT_UINT_STRING and for UCS-2 and UTF-16 strings)
266  * and the bottom bit (which we ignore for now so that programs that
267  * pass TRUE for the encoding just do ASCII).  (The encodings are given
268  * directly as even numbers in hex, so that make-init-lua.pl can just
269  * turn them into numbers for use in init.lua.)
270  *
271  * We don't yet process ASCII and UTF-8 differently.  Ultimately, for
272  * ASCII, all bytes with the 8th bit set should be mapped to some "this
273  * is not a valid character" code point, as ENC_ASCII should mean "this
274  * is ASCII, not some extended variant thereof".  We should also map
275  * 0x00 to that as well - null-terminated and null-padded strings
276  * never have NULs in them, but counted strings might.  (Either that,
277  * or the values for strings should be counted, not null-terminated.)
278  * For UTF-8, invalid UTF-8 sequences should be mapped to the same
279  * code point.
280  *
281  * For display, perhaps we should also map control characters to the
282  * Unicode glyphs showing the name of the control character in small
283  * caps, diagonally.  (Unfortunately, those only exist for C0, not C1.)
284  */
285 #define ENC_CHARENCODING_MASK           0x7FFFFFFE      /* mask out byte-order bits */
286 #define ENC_ASCII                       0x00000000
287 #define ENC_UTF_8                       0x00000002
288 #define ENC_UTF_16                      0x00000004
289 #define ENC_UCS_2                       0x00000006
290 #define ENC_UCS_4                       0x00000008
291 #define ENC_ISO_8859_1                  0x0000000A
292 #define ENC_ISO_8859_2                  0x0000000C
293 #define ENC_ISO_8859_3                  0x0000000E
294 #define ENC_ISO_8859_4                  0x00000010
295 #define ENC_ISO_8859_5                  0x00000012
296 #define ENC_ISO_8859_6                  0x00000014
297 #define ENC_ISO_8859_7                  0x00000016
298 #define ENC_ISO_8859_8                  0x00000018
299 #define ENC_ISO_8859_9                  0x0000001A
300 #define ENC_ISO_8859_10                 0x0000001C
301 #define ENC_ISO_8859_11                 0x0000001E
302 /* #define ENC_ISO_8859_12                      0x00000020 ISO 8859-12 was abandoned */
303 #define ENC_ISO_8859_13                 0x00000022
304 #define ENC_ISO_8859_14                 0x00000024
305 #define ENC_ISO_8859_15                 0x00000026
306 #define ENC_ISO_8859_16                 0x00000028
307 #define ENC_WINDOWS_1250                0x0000002A
308 #define ENC_3GPP_TS_23_038_7BITS        0x0000002C
309 #define ENC_EBCDIC                      0x0000002E
310
311 /*
312  * TODO:
313  *
314  * These could probably be used by existing code:
315  *
316  *      "IBM MS DBCS"
317  *      JIS C 6226
318  *      7-bit encodings such as 7 bits ASCII used in packet-ansi_637.c
319  *
320  * As those are added, change code such as the code in packet-bacapp.c
321  * to use them.
322  */
323
324 /*
325  * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
326  * opaque byte-array fields (FT_BYTES), and other fields where there
327  * is no choice of encoding (either because it's "just a bucket
328  * of bytes" or because the encoding is completely fixed), we
329  * have ENC_NA (for "Not Applicable").
330  */
331 #define ENC_NA                  0x00000000
332
333 /* Values for header_field_info.display */
334
335 /* For integral types, the display format is a BASE_* field_display_e value
336  * possibly ORed with BASE_*_STRING */
337
338 /** FIELD_DISPLAY_E_MASK selects the field_display_e value.  Its current
339  * value means that we may have at most 16 field_display_e values. */
340 #define FIELD_DISPLAY_E_MASK 0x0F
341
342 typedef enum {
343 /* Integral types */
344         BASE_NONE    = 0,   /**< none */
345         BASE_DEC     = 1,   /**< decimal */
346         BASE_HEX     = 2,   /**< hexadecimal */
347         BASE_OCT     = 3,   /**< octal */
348         BASE_DEC_HEX = 4,   /**< decimal (hexadecimal) */
349         BASE_HEX_DEC = 5,   /**< hexadecimal (decimal) */
350         BASE_CUSTOM  = 6,   /**< call custom routine (in ->strings) to format */
351
352 /* String types */
353         STR_ASCII    = BASE_NONE, /**< shows non-printable ASCII characters as C-style escapes */
354         /* XXX, support for format_text_wsp() ? */
355         STR_UNICODE  = 7          /**< shows non-printable UNICODE characters as \uXXXX (XXX for now non-printable characters display depends on UI) */
356 } field_display_e;
357
358 /* Following constants have to be ORed with a field_display_e when dissector
359  * want to use specials value-string MACROs for a header_field_info */
360 #define BASE_RANGE_STRING 0x10
361 #define BASE_EXT_STRING   0x20
362 #define BASE_VAL64_STRING 0x40
363
364 /** BASE_ values that cause the field value to be displayed twice */
365 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
366
367 /* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e
368  * as per time_fmt.h. */
369
370 typedef enum {
371     HF_REF_TYPE_NONE,       /**< Field is not referenced */
372     HF_REF_TYPE_INDIRECT,   /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
373     HF_REF_TYPE_DIRECT      /**< Field is directly referenced */
374 } hf_ref_type;
375
376 /** information describing a header field */
377 typedef struct _header_field_info header_field_info;
378
379 /** information describing a header field */
380 struct _header_field_info {
381         /* ---------- set by dissector --------- */
382         const char              *name;           /**< [FIELDNAME] full name of this field */
383         const char              *abbrev;         /**< [FIELDABBREV] abbreviated name of this field */
384         enum ftenum              type;           /**< [FIELDTYPE] field type, one of FT_ (from ftypes.h) */
385         int                          display;        /**< [FIELDDISPLAY] one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
386         const void              *strings;        /**< [FIELDCONVERT] value_string, val64_string, range_string or true_false_string,
387                                                       typically converted by VALS(), RVALS() or TFS().
388                                                       If this is an FT_PROTOCOL then it points to the
389                                                       associated protocol_t structure */
390         guint32                  bitmask;        /**< [BITMASK] bitmask of interesting bits */
391         const char              *blurb;          /**< [FIELDDESCR] Brief description of field */
392
393         /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
394         int                                  id;                /**< Field ID */
395         int                                      parent;            /**< parent protocol tree */
396         hf_ref_type                      ref_type;          /**< is this field referenced by a filter */
397         int                  same_name_prev_id; /**< ID of previous hfinfo with same abbrev */
398         header_field_info       *same_name_next;    /**< Link to next hfinfo with same abbrev */
399 };
400
401 /**
402  * HFILL initializes all the "set by proto routines" fields in a
403  * _header_field_info. If new fields are added or removed, it should
404  * be changed as necessary.
405  */
406 #define HFILL -1, 0, HF_REF_TYPE_NONE, -1, NULL
407
408 #define HFILL_INIT(hf)   \
409         hf.hfinfo.id                            = -1;   \
410         hf.hfinfo.parent                        = 0;   \
411         hf.hfinfo.ref_type                      = HF_REF_TYPE_NONE;   \
412         hf.hfinfo.same_name_prev_id     = -1;   \
413         hf.hfinfo.same_name_next        = NULL;
414
415 /** Used when registering many fields at once, using proto_register_field_array() */
416 typedef struct hf_register_info {
417         int                             *p_id;  /**< written to by register() function */
418         header_field_info               hfinfo; /**< the field info to be registered */
419 } hf_register_info;
420
421
422
423
424 /** string representation, if one of the proto_tree_add_..._format() functions used */
425 typedef struct _item_label_t {
426         char representation[ITEM_LABEL_LENGTH];
427 } item_label_t;
428
429
430 /** Contains the field information for the proto_item. */
431 typedef struct field_info {
432         header_field_info       *hfinfo;          /**< pointer to registered field information */
433         gint                     start;           /**< current start of data in field_info.ds_tvb */
434         gint                     length;          /**< current data length of item in field_info.ds_tvb */
435         gint                     appendix_start;  /**< start of appendix data */
436         gint                     appendix_length; /**< length of appendix data */
437         gint                     tree_type;       /**< one of ETT_ or -1 */
438         guint32                  flags;           /**< bitfield like FI_GENERATED, ... */
439         item_label_t            *rep;             /**< string for GUI tree */
440         tvbuff_t                *ds_tvb;          /**< data source tvbuff */
441         fvalue_t                 value;
442 } field_info;
443
444
445 /*
446  * This structure describes one segment of a split-bits item
447  * crumb_bit_offset is the bit offset in the input tvb of the first (most significant) bit of this crumb
448  * crumb_bit_length is the number of contiguous bits of this crumb.
449  * The first element of an array of bits_specs describes the most significant crumb of the output value.
450  * The second element of an array of bits_specs describes the next-most significant crumb of the output value, etc.
451  * The array is terminated by a sentinal entry with crumb_bit_length of 0.
452 */
453 typedef struct
454 {
455     guint  crumb_bit_offset;
456     guint8 crumb_bit_length;
457 }crumb_spec_t;
458
459 /*
460  * Flag fields.  Do not assign values greater than 0x00000080 unless you
461  * shuffle the expert information upward; see below.
462  */
463
464 /** The protocol field should not be shown in the tree (it's used for filtering only),
465  * used in field_info.flags. */
466 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
467    A user cannot tell by looking at the packet detail that the field exists
468    and that they can filter on its value. */
469 #define FI_HIDDEN               0x00000001
470 /** The protocol field should be displayed as "generated by Wireshark",
471  * used in field_info.flags. */
472 #define FI_GENERATED            0x00000002
473 /** The protocol field is actually a URL */
474 #define FI_URL                  0x00000004
475
476 /** The protocol field value is in little endian */
477 #define FI_LITTLE_ENDIAN        0x00000008
478 /** The protocol field value is in big endian */
479 #define FI_BIG_ENDIAN           0x00000010
480 /** Field value start from nth bit (values from 0x20 - 0x100) */
481 #define FI_BITS_OFFSET(n)       (((n) & 7) << 5)
482 /** Field value takes n bits (values from 0x100 - 0x4000) */
483 /* if 0, it means that field takes fi->length * 8 */
484 #define FI_BITS_SIZE(n)         (((n) & 63) << 8)
485
486 /** convenience macro to get field_info.flags */
487 #define FI_GET_FLAG(fi, flag)   ((fi) ? ((fi)->flags & (flag)) : 0)
488 /** convenience macro to set field_info.flags */
489 #define FI_SET_FLAG(fi, flag) \
490     do { \
491       if (fi) \
492         (fi)->flags = (fi)->flags | (flag); \
493     } while(0)
494 /** convenience macro to reset field_info.flags */
495 #define FI_RESET_FLAG(fi, flag) \
496     do { \
497       if (fi) \
498         (fi)->flags = (fi)->flags & ~(flag); \
499     } while(0)
500
501 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
502 #define FI_GET_BITS_SIZE(fi)   (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
503
504 /** One of these exists for the entire protocol tree. Each proto_node
505  * in the protocol tree points to the same copy. */
506 typedef struct {
507     GHashTable  *interesting_hfids;
508     gboolean     visible;
509     gboolean     fake_protocols;
510     gint         count;
511     struct _packet_info *pinfo;
512 } tree_data_t;
513
514 /** Each proto_tree, proto_item is one of these. */
515 typedef struct _proto_node {
516         struct _proto_node *first_child;
517         struct _proto_node *last_child;
518         struct _proto_node *next;
519         struct _proto_node *parent;
520         field_info  *finfo;
521         tree_data_t *tree_data;
522 } proto_node;
523
524 /** A protocol tree element. */
525 typedef proto_node proto_tree;
526 /** A protocol item element. */
527 typedef proto_node proto_item;
528
529 /*
530  * Expert information.
531  * This is in the flags field; we allocate this from the top down,
532  * so as not to collide with FI_ flags, which are allocated from
533  * the bottom up.
534  */
535
536 /* expert severities */
537 #define PI_SEVERITY_MASK        0x00F00000      /**< mask usually for internal use only! */
538 /** Packet is commented */
539 #define PI_COMMENT              0x00100000
540 /** Usual workflow, e.g. TCP connection establishing */
541 #define PI_CHAT                 0x00200000
542 /** Notable messages, e.g. an application returned an "usual" error code like HTTP 404 */
543 #define PI_NOTE                 0x00400000
544 /** Warning, e.g. application returned an "unusual" error code */
545 #define PI_WARN                 0x00600000
546 /** Serious problems, e.g. [Malformed Packet] */
547 #define PI_ERROR                0x00800000
548
549 /* expert "event groups" */
550 #define PI_GROUP_MASK           0xFF000000      /**< mask usually for internal use only! */
551 /** The protocol field has a bad checksum, usually PI_WARN */
552 #define PI_CHECKSUM             0x01000000
553 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
554 #define PI_SEQUENCE             0x02000000
555 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
556 #define PI_RESPONSE_CODE        0x03000000
557 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
558 #define PI_REQUEST_CODE         0x04000000
559 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
560 #define PI_UNDECODED            0x05000000
561 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
562 #define PI_REASSEMBLE           0x06000000
563 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR */
564 #define PI_MALFORMED            0x07000000
565 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR */
566 #define PI_DEBUG                0x08000000
567 /** The protocol field violates a protocol specification, usually PI_WARN */
568 #define PI_PROTOCOL             0x09000000
569 /** The protocol field indicates a security probem (e.g. unsecure implementation) */
570 #define PI_SECURITY             0x0a000000
571 /** The protocol field indicates a packet comment */
572 #define PI_COMMENTS_GROUP       0x0b000000
573
574 /* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
575
576
577 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
578 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
579 #define PROTO_ITEM_IS_HIDDEN(proto_item)        \
580         ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
581 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
582 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
583 #define PROTO_ITEM_SET_HIDDEN(proto_item)       \
584   do { \
585     if (proto_item) \
586       FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
587   } while(0)
588 /** mark this protocol field to be visible from the protocol tree display */
589 #define PROTO_ITEM_SET_VISIBLE(proto_item)       \
590   do { \
591     if (proto_item) \
592       FI_RESET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
593   } while(0)
594
595 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
596 #define PROTO_ITEM_IS_GENERATED(proto_item)     \
597         ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
598 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
599 #define PROTO_ITEM_SET_GENERATED(proto_item)    \
600     do { \
601       if (proto_item) \
602         FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
603     } while(0)
604 /** is this protocol field actually a URL? */
605 #define PROTO_ITEM_IS_URL(proto_item)   \
606         ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
607 /** mark this protocol field as a URL */
608 #define PROTO_ITEM_SET_URL(proto_item)  \
609     do { \
610       if (proto_item) \
611         FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
612     } while(0)
613
614 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
615 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);
616
617 extern gboolean proto_tree_traverse_post_order(proto_tree *tree,
618     proto_tree_traverse_func func, gpointer data);
619
620 WS_DLL_PUBLIC void proto_tree_children_foreach(proto_tree *tree,
621     proto_tree_foreach_func func, gpointer data);
622
623 /** Retrieve the field_info from a proto_node */
624 #define PNODE_FINFO(proto_node)  ((proto_node)->finfo)
625
626 /** Retrieve the field_info from a proto_item */
627 #define PITEM_FINFO(proto_item)  PNODE_FINFO(proto_item)
628
629 /** Retrieve the field_info from a proto_tree */
630 #define PTREE_FINFO(proto_tree)  PNODE_FINFO(proto_tree)
631
632 /** Retrieve the tree_data_t from a proto_tree */
633 #define PTREE_DATA(proto_tree)   ((proto_tree)->tree_data)
634
635 /** Retrieve the wmem_allocator_t from a proto_node */
636 #define PNODE_POOL(proto_node)   ((proto_node)->tree_data->pinfo->pool)
637
638 #ifdef HAVE_PLUGINS
639 /** Register dissector plugin type with the plugin system.
640     Called by epan_register_plugin_types(); do not call it yourself. */
641 extern void register_dissector_plugin_type(void);
642 #endif
643
644 /** Sets up memory used by proto routines. Called at program startup */
645 void proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_data),
646                        void (register_all_handoffs_func)(register_cb cb, gpointer client_data),
647                        register_cb cb, void *client_data);
648
649
650 /** Frees memory used by proto routines. Called at program shutdown */
651 extern void proto_cleanup(void);
652
653 /** This function takes a tree and a protocol id as parameter and
654     will return TRUE/FALSE for whether the protocol or any of the filterable
655     fields in the protocol is referenced by any fitlers.
656     If this function returns FALSE then it is safe to skip any
657     proto_tree_add_...() calls and just treat the call as if the
658     dissector was called with tree==NULL.
659     If you reset the tree to NULL by this dissector returning FALSE,
660     you will still need to call any subdissector with the original value of
661     tree or filtering will break.
662
663     The purpose of this is to optimize wireshark for speed and make it
664     faster for when filters are being used.
665 */
666 WS_DLL_PUBLIC gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
667
668 /** Create a subtree under an existing item.
669  @param ti the parent item of the new subtree
670  @param idx one of the ett_ array elements registered with proto_register_subtree_array()
671  @return the new subtree */
672 WS_DLL_PUBLIC proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx) G_GNUC_WARN_UNUSED_RESULT;
673
674 /** Get an existing subtree under an item.
675  @param ti the parent item of the subtree
676  @return the subtree or NULL */
677 WS_DLL_PUBLIC proto_tree* proto_item_get_subtree(proto_item *ti);
678
679 /** Get the parent of a subtree item.
680  @param ti the child item in the subtree
681  @return parent item or NULL */
682 WS_DLL_PUBLIC proto_item* proto_item_get_parent(const proto_item *ti);
683
684 /** Get Nth generation parent item.
685  @param ti the child item in the subtree
686  @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
687  @return parent item */
688 WS_DLL_PUBLIC proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
689
690 /** Replace text of item after it already has been created.
691  @param ti the item to set the text
692  @param format printf like format string
693  @param ... printf like parameters */
694 WS_DLL_PUBLIC void proto_item_set_text(proto_item *ti, const char *format, ...)
695         G_GNUC_PRINTF(2,3);
696
697 /** Append to text of item after it has already been created.
698  @param ti the item to append the text to
699  @param format printf like format string
700  @param ... printf like parameters */
701 WS_DLL_PUBLIC void proto_item_append_text(proto_item *ti, const char *format, ...)
702         G_GNUC_PRINTF(2,3);
703
704 /** Prepend to text of item after it has already been created.
705  @param ti the item to prepend the text to
706  @param format printf like format string
707  @param ... printf like parameters */
708 WS_DLL_PUBLIC void proto_item_prepend_text(proto_item *ti, const char *format, ...)
709         G_GNUC_PRINTF(2,3);
710
711 /** Set proto_item's length inside tvb, after it has already been created.
712  @param ti the item to set the length
713  @param length the new length ot the item */
714 WS_DLL_PUBLIC void proto_item_set_len(proto_item *ti, const gint length);
715
716 /**
717  * Sets the length of the item based on its start and on the specified
718  * offset, which is the offset past the end of the item; as the start
719  * in the item is relative to the beginning of the data source tvbuff,
720  * we need to pass in a tvbuff.
721  @param ti the item to set the length
722  @param tvb end is relative to this tvbuff
723  @param end this end offset is relative to the beginning of tvb
724  @todo make usage clearer, I don't understand it!
725  */
726 WS_DLL_PUBLIC void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
727
728 /** Get length of a proto_item. Useful after using proto_tree_add_item()
729  * to add a variable-length field (e.g., FT_NSTRING_UINT8).
730  @param ti the item to get the length from
731  @return the current length */
732 WS_DLL_PUBLIC int proto_item_get_len(const proto_item *ti);
733
734
735
736 /** Creates a new proto_tree root.
737  @return the new tree root */
738 extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
739
740 void proto_tree_reset(proto_tree *tree);
741
742 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
743  @param tree the tree to free */
744 WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
745
746 /** Set the tree visible or invisible.
747  Is the parsing being done for a visible proto_tree or an invisible one?
748  By setting this correctly, the proto_tree creation is sped up by not
749  having to call g_vsnprintf and copy strings around.
750  @param tree the tree to be set
751  @param visible ... or not
752  @return the old value */
753 WS_DLL_PUBLIC gboolean
754 proto_tree_set_visible(proto_tree *tree, gboolean visible);
755
756 /** Indicate whether we should fake protocols during dissection (default = TRUE)
757  @param tree the tree to be set
758  @param fake_protocols TRUE if we should fake protocols */
759 extern void
760 proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
761
762 /** Mark a field/protocol ID as "interesting".
763  @param tree the tree to be set
764  @param hfid the interesting field id
765  @todo what *does* interesting mean? */
766 extern void
767 proto_tree_prime_hfid(proto_tree *tree, const int hfid);
768
769 /** Get a parent item of a subtree.
770  @param tree the tree to get the parent from
771  @return parent item */
772 WS_DLL_PUBLIC proto_item* proto_tree_get_parent(proto_tree *tree);
773
774 /** Get the root tree from any subtree.
775  @param tree the tree to get the root from
776  @return root tree */
777 WS_DLL_PUBLIC proto_tree* proto_tree_get_root(proto_tree *tree);
778
779 /** Move an existing item behind another existing item.
780  @param tree the tree to which both items belong
781  @param fixed_item the item which keeps its position
782  @param item_to_move the item which will be moved */
783 WS_DLL_PUBLIC void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
784
785
786 /** Set start and length of an appendix for a proto_tree.
787   @param tree the tree to set the appendix start and length
788   @param tvb the tv buffer of the current data
789   @param start the start offset of the appendix
790   @param length the length of the appendix */
791 WS_DLL_PUBLIC void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length);
792
793
794 /** Add an item to a proto_tree, using the text label registered to that item.
795    The item is extracted from the tvbuff handed to it.
796  @param tree the tree to append this item to
797  @param hfinfo field
798  @param tvb the tv buffer of the current data
799  @param start start of data in tvb
800  @param length length of data in tvb
801  @param encoding data encoding
802  @return the newly created item */
803 WS_DLL_PUBLIC proto_item *
804 proto_tree_add_item_new(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
805     const gint start, gint length, const guint encoding);
806
807 WS_DLL_PUBLIC proto_item *
808 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
809                     const gint start, gint length, const guint encoding);
810
811 /** Add a text-only node to a proto_tree.
812  @param tree the tree to append this item to
813  @param tvb the tv buffer of the current data
814  @param start start of data in tvb
815  @param length length of data in tvb
816  @param format printf like format string
817  @param ... printf like parameters
818  @return the newly created item */
819 WS_DLL_PUBLIC proto_item *
820 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
821         ...) G_GNUC_PRINTF(5,6);
822
823 /** Add a text-only node to a proto_tree using a variable argument list.
824  @param tree the tree to append this item to
825  @param tvb the tv buffer of the current data
826  @param start start of data in tvb
827  @param length length of data in tvb
828  @param format printf like format string
829  @param ap variable argument list
830  @return the newly created item */
831 proto_item *
832 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
833         gint length, const char *format, va_list ap);
834
835
836 /** Add a FT_NONE field to a proto_tree.
837  @param tree the tree to append this item to
838  @param hfindex field index
839  @param tvb the tv buffer of the current data
840  @param start start of data in tvb
841  @param length length of data in tvb
842  @param format printf like format string
843  @param ... printf like parameters
844  @return the newly created item */
845 WS_DLL_PUBLIC proto_item *
846 proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start,
847         gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
848
849 /** Add a FT_PROTOCOL to a proto_tree.
850  @param tree the tree to append this item to
851  @param hfindex field index
852  @param tvb the tv buffer of the current data
853  @param start start of data in tvb
854  @param length length of data in tvb
855  @param format printf like format string
856  @param ... printf like parameters
857  @return the newly created item */
858 WS_DLL_PUBLIC proto_item *
859 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
860         gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
861
862
863
864
865 /** Add a FT_BYTES to a proto_tree.
866  @param tree the tree to append this item to
867  @param hfindex field index
868  @param tvb the tv buffer of the current data
869  @param start start of data in tvb
870  @param length length of data in tvb
871  @param start_ptr pointer to the data to display
872  @return the newly created item */
873 WS_DLL_PUBLIC proto_item *
874 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
875         gint length, const guint8* start_ptr);
876
877 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
878     the string for the value and with the field name being included
879     automatically.
880  @param tree the tree to append this item to
881  @param hfindex field index
882  @param tvb the tv buffer of the current data
883  @param start start of data in tvb
884  @param length length of data in tvb
885  @param start_ptr pointer to the data to display
886  @param format printf like format string
887  @param ... printf like parameters
888  @return the newly created item */
889 WS_DLL_PUBLIC proto_item *
890 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
891         gint start, gint length, const guint8* start_ptr, const char *format,
892         ...) G_GNUC_PRINTF(7,8);
893
894 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
895     the entire string for the entry, including any field name.
896  @param tree the tree to append this item to
897  @param hfindex field index
898  @param tvb the tv buffer of the current data
899  @param start start of data in tvb
900  @param length length of data in tvb
901  @param start_ptr pointer to the data to display
902  @param format printf like format string
903  @param ... printf like parameters
904  @return the newly created item */
905 WS_DLL_PUBLIC proto_item *
906 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
907         gint length, const guint8* start_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
908
909 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
910  @param tree the tree to append this item to
911  @param hfindex field index
912  @param tvb the tv buffer of the current data
913  @param start start of data in tvb
914  @param length length of data in tvb
915  @param value_ptr pointer to the data to display
916  @return the newly created item */
917 WS_DLL_PUBLIC proto_item *
918 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
919         gint length, const nstime_t* value_ptr);
920
921 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
922     the format generating the string for the value and with the field name
923     being included automatically.
924  @param tree the tree to append this item to
925  @param hfindex field index
926  @param tvb the tv buffer of the current data
927  @param start start of data in tvb
928  @param length length of data in tvb
929  @param value_ptr pointer to the data to display
930  @param format printf like format string
931  @param ... printf like parameters
932  @return the newly created item */
933 WS_DLL_PUBLIC proto_item *
934 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
935         gint start, gint length, nstime_t* value_ptr, const char *format, ...)
936         G_GNUC_PRINTF(7,8);
937
938 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
939     the format generating the entire string for the entry, including any field
940     name.
941  @param tree the tree to append this item to
942  @param hfindex field index
943  @param tvb the tv buffer of the current data
944  @param start start of data in tvb
945  @param length length of data in tvb
946  @param value_ptr pointer to the data to display
947  @param format printf like format string
948  @param ... printf like parameters
949  @return the newly created item */
950 WS_DLL_PUBLIC proto_item *
951 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
952         gint length, nstime_t* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
953
954 /** Add a FT_IPXNET to a proto_tree.
955  @param tree the tree to append this item to
956  @param hfindex field index
957  @param tvb the tv buffer of the current data
958  @param start start of data in tvb
959  @param length length of data in tvb
960  @param value data to display
961  @return the newly created item */
962 WS_DLL_PUBLIC proto_item *
963 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
964         gint length, guint32 value);
965
966 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
967     the string for the value and with the field name being included
968     automatically.
969  @param tree the tree to append this item to
970  @param hfindex field index
971  @param tvb the tv buffer of the current data
972  @param start start of data in tvb
973  @param length length of data in tvb
974  @param value data to display
975  @param format printf like format string
976  @param ... printf like parameters
977  @return the newly created item */
978 WS_DLL_PUBLIC proto_item *
979 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
980         gint start, gint length, guint32 value, const char *format, ...)
981         G_GNUC_PRINTF(7,8);
982
983 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
984     the entire string for the entry, including any field name.
985  @param tree the tree to append this item to
986  @param hfindex field index
987  @param tvb the tv buffer of the current data
988  @param start start of data in tvb
989  @param length length of data in tvb
990  @param value data to display
991  @param format printf like format string
992  @param ... printf like parameters
993  @return the newly created item */
994 WS_DLL_PUBLIC proto_item *
995 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
996         gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
997
998 /** Add a FT_IPv4 to a proto_tree.
999  @param tree the tree to append this item to
1000  @param hfindex field index
1001  @param tvb the tv buffer of the current data
1002  @param start start of data in tvb
1003  @param length length of data in tvb
1004  @param value data to display
1005  @return the newly created item */
1006 WS_DLL_PUBLIC proto_item *
1007 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1008         gint length, guint32 value);
1009
1010 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1011     the string for the value and with the field name being included
1012     automatically.
1013  @param tree the tree to append this item to
1014  @param hfindex field index
1015  @param tvb the tv buffer of the current data
1016  @param start start of data in tvb
1017  @param length length of data in tvb
1018  @param value data to display
1019  @param format printf like format string
1020  @param ... printf like parameters
1021  @return the newly created item */
1022 WS_DLL_PUBLIC proto_item *
1023 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1024         gint start, gint length, guint32 value, const char *format, ...)
1025         G_GNUC_PRINTF(7,8);
1026
1027 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
1028     the entire string for the entry, including any field name.
1029  @param tree the tree to append this item to
1030  @param hfindex field index
1031  @param tvb the tv buffer of the current data
1032  @param start start of data in tvb
1033  @param length length of data in tvb
1034  @param value data to display
1035  @param format printf like format string
1036  @param ... printf like parameters
1037  @return the newly created item */
1038 WS_DLL_PUBLIC proto_item *
1039 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1040         gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1041
1042 /** Add a FT_IPv6 to a proto_tree.
1043  @param tree the tree to append this item to
1044  @param hfindex field index
1045  @param tvb the tv buffer of the current data
1046  @param start start of data in tvb
1047  @param length length of data in tvb
1048  @param value_ptr data to display
1049  @return the newly created item */
1050 WS_DLL_PUBLIC proto_item *
1051 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1052         gint length, const guint8* value_ptr);
1053
1054 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1055     the string for the value and with the field name being included
1056     automatically.
1057  @param tree the tree to append this item to
1058  @param hfindex field index
1059  @param tvb the tv buffer of the current data
1060  @param start start of data in tvb
1061  @param length length of data in tvb
1062  @param value_ptr data to display
1063  @param format printf like format string
1064  @param ... printf like parameters
1065  @return the newly created item */
1066 WS_DLL_PUBLIC proto_item *
1067 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1068         gint start, gint length, const guint8* value_ptr, const char *format,
1069         ...) G_GNUC_PRINTF(7,8);
1070
1071 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
1072     the entire string for the entry, including any field name.
1073  @param tree the tree to append this item to
1074  @param hfindex field index
1075  @param tvb the tv buffer of the current data
1076  @param start start of data in tvb
1077  @param length length of data in tvb
1078  @param value_ptr data to display
1079  @param format printf like format string
1080  @param ... printf like parameters
1081  @return the newly created item */
1082 WS_DLL_PUBLIC proto_item *
1083 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1084         gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1085
1086 /** Add a FT_AX25 to a proto_tree.
1087  @param tree the tree to append this item to
1088  @param hfindex field index
1089  @param tvb the tv buffer of the current data
1090  @param start start of data in tvb
1091  @param length length of data in tvb
1092  @param value data to display
1093  @return the newly created item */
1094 extern proto_item *
1095 proto_tree_add_ax25(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1096         gint length, const guint8* value);
1097
1098 /** Add a FT_ETHER to a proto_tree.
1099  @param tree the tree to append this item to
1100  @param hfindex field index
1101  @param tvb the tv buffer of the current data
1102  @param start start of data in tvb
1103  @param length length of data in tvb
1104  @param value data to display
1105  @return the newly created item */
1106 WS_DLL_PUBLIC proto_item *
1107 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1108         gint length, const guint8* value);
1109
1110 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1111     the string for the value and with the field name being included
1112     automatically.
1113  @param tree the tree to append this item to
1114  @param hfindex field index
1115  @param tvb the tv buffer of the current data
1116  @param start start of data in tvb
1117  @param length length of data in tvb
1118  @param value data to display
1119  @param format printf like format string
1120  @param ... printf like parameters
1121  @return the newly created item */
1122 WS_DLL_PUBLIC proto_item *
1123 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1124         gint start, gint length, const guint8* value, const char *format, ...)
1125         G_GNUC_PRINTF(7,8);
1126
1127 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
1128     the entire string for the entry, including any field name.
1129  @param tree the tree to append this item to
1130  @param hfindex field index
1131  @param tvb the tv buffer of the current data
1132  @param start start of data in tvb
1133  @param length length of data in tvb
1134  @param value data to display
1135  @param format printf like format string
1136  @param ... printf like parameters
1137  @return the newly created item */
1138 WS_DLL_PUBLIC proto_item *
1139 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1140         gint length, const guint8* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1141
1142 /** Add a FT_GUID to a proto_tree.
1143  @param tree the tree to append this item to
1144  @param hfindex field index
1145  @param tvb the tv buffer of the current data
1146  @param start start of data in tvb
1147  @param length length of data in tvb
1148  @param value_ptr data to display
1149  @return the newly created item */
1150 WS_DLL_PUBLIC proto_item *
1151 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1152         gint length, const e_guid_t *value_ptr);
1153
1154 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1155     the string for the value and with the field name being included
1156     automatically.
1157  @param tree the tree to append this item to
1158  @param hfindex field index
1159  @param tvb the tv buffer of the current data
1160  @param start start of data in tvb
1161  @param length length of data in tvb
1162  @param value_ptr data to display
1163  @param format printf like format string
1164  @param ... printf like parameters
1165  @return the newly created item */
1166 WS_DLL_PUBLIC proto_item *
1167 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1168         gint start, gint length, const e_guid_t *value_ptr, const char *format,
1169         ...) G_GNUC_PRINTF(7,8);
1170
1171 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1172     the entire string for the entry, including any field name.
1173  @param tree the tree to append this item to
1174  @param hfindex field index
1175  @param tvb the tv buffer of the current data
1176  @param start start of data in tvb
1177  @param length length of data in tvb
1178  @param value_ptr data to display
1179  @param format printf like format string
1180  @param ... printf like parameters
1181  @return the newly created item */
1182 WS_DLL_PUBLIC proto_item *
1183 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1184         gint length, const e_guid_t *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1185
1186 /** Add a FT_OID to a proto_tree.
1187  @param tree the tree to append this item to
1188  @param hfindex field index
1189  @param tvb the tv buffer of the current data
1190  @param start start of data in tvb
1191  @param length length of data in tvb
1192  @param value_ptr data to display
1193  @return the newly created item */
1194 extern proto_item *
1195 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1196         gint length, const guint8* value_ptr);
1197
1198 /** Add a formatted FT_OID to a proto_tree, with the format generating
1199     the string for the value and with the field name being included
1200     automatically.
1201  @param tree the tree to append this item to
1202  @param hfindex field index
1203  @param tvb the tv buffer of the current data
1204  @param start start of data in tvb
1205  @param length length of data in tvb
1206  @param value_ptr data to display
1207  @param format printf like format string
1208  @param ... printf like parameters
1209  @return the newly created item */
1210 extern proto_item *
1211 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1212         gint start, gint length, const guint8* value_ptr, const char *format,
1213         ...) G_GNUC_PRINTF(7,8);
1214
1215 /** Add a formatted FT_OID to a proto_tree, with the format generating
1216     the entire string for the entry, including any field name.
1217  @param tree the tree to append this item to
1218  @param hfindex field index
1219  @param tvb the tv buffer of the current data
1220  @param start start of data in tvb
1221  @param length length of data in tvb
1222  @param value_ptr data to display
1223  @param format printf like format string
1224  @param ... printf like parameters
1225  @return the newly created item */
1226 extern proto_item *
1227 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1228         gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1229
1230 /** Add a FT_STRING to a proto_tree.
1231  @param tree the tree to append this item to
1232  @param hfindex field index
1233  @param tvb the tv buffer of the current data
1234  @param start start of data in tvb
1235  @param length length of data in tvb
1236  @param value data to display
1237  @return the newly created item */
1238 WS_DLL_PUBLIC proto_item *
1239 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1240         gint length, const char* value);
1241
1242 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1243     the string for the value and with the field name being included
1244     automatically.
1245  @param tree the tree to append this item to
1246  @param hfindex field index
1247  @param tvb the tv buffer of the current data
1248  @param start start of data in tvb
1249  @param length length of data in tvb
1250  @param value data to display
1251  @param format printf like format string
1252  @param ... printf like parameters
1253  @return the newly created item */
1254 WS_DLL_PUBLIC proto_item *
1255 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1256         gint start, gint length, const char* value, const char *format, ...)
1257         G_GNUC_PRINTF(7,8);
1258
1259 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1260     the entire string for the entry, including any field name.
1261  @param tree the tree to append this item to
1262  @param hfindex field index
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 value data to display
1267  @param format printf like format string
1268  @param ... printf like parameters
1269  @return the newly created item */
1270 WS_DLL_PUBLIC proto_item *
1271 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1272         gint length, const char* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1273
1274 /** Add a FT_BOOLEAN to a proto_tree.
1275  @param tree the tree to append this item to
1276  @param hfindex field index
1277  @param tvb the tv buffer of the current data
1278  @param start start of data in tvb
1279  @param length length of data in tvb
1280  @param value data to display
1281  @return the newly created item */
1282 WS_DLL_PUBLIC proto_item *
1283 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1284         gint length, guint32 value);
1285
1286 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1287     the string for the value and with the field name being included
1288     automatically.
1289  @param tree the tree to append this item to
1290  @param hfindex field index
1291  @param tvb the tv buffer of the current data
1292  @param start start of data in tvb
1293  @param length length of data in tvb
1294  @param value data to display
1295  @param format printf like format string
1296  @param ... printf like parameters
1297  @return the newly created item */
1298 WS_DLL_PUBLIC proto_item *
1299 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1300         tvbuff_t *tvb, gint start, gint length, guint32 value,
1301         const char *format, ...) G_GNUC_PRINTF(7,8);
1302
1303 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1304     the entire string for the entry, including any field name.
1305  @param tree the tree to append this item to
1306  @param hfindex field index
1307  @param tvb the tv buffer of the current data
1308  @param start start of data in tvb
1309  @param length length of data in tvb
1310  @param value data to display
1311  @param format printf like format string
1312  @param ... printf like parameters
1313  @return the newly created item */
1314 WS_DLL_PUBLIC proto_item *
1315 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1316         gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1317
1318 /** Add a FT_FLOAT to a proto_tree.
1319  @param tree the tree to append this item to
1320  @param hfindex field index
1321  @param tvb the tv buffer of the current data
1322  @param start start of data in tvb
1323  @param length length of data in tvb
1324  @param value data to display
1325  @return the newly created item */
1326 WS_DLL_PUBLIC proto_item *
1327 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1328         gint length, float value);
1329
1330 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1331     the string for the value and with the field name being included
1332     automatically.
1333  @param tree the tree to append this item to
1334  @param hfindex field index
1335  @param tvb the tv buffer of the current data
1336  @param start start of data in tvb
1337  @param length length of data in tvb
1338  @param value data to display
1339  @param format printf like format string
1340  @param ... printf like parameters
1341  @return the newly created item */
1342 WS_DLL_PUBLIC proto_item *
1343 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1344         gint start, gint length, float value, const char *format, ...)
1345         G_GNUC_PRINTF(7,8);
1346
1347 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1348     the entire string for the entry, including any field name.
1349  @param tree the tree to append this item to
1350  @param hfindex field index
1351  @param tvb the tv buffer of the current data
1352  @param start start of data in tvb
1353  @param length length of data in tvb
1354  @param value data to display
1355  @param format printf like format string
1356  @param ... printf like parameters
1357  @return the newly created item */
1358 WS_DLL_PUBLIC proto_item *
1359 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1360         gint length, float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1361
1362 /** Add a FT_DOUBLE to a proto_tree.
1363  @param tree the tree to append this item to
1364  @param hfindex field index
1365  @param tvb the tv buffer of the current data
1366  @param start start of data in tvb
1367  @param length length of data in tvb
1368  @param value data to display
1369  @return the newly created item */
1370 WS_DLL_PUBLIC proto_item *
1371 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1372         gint length, double value);
1373
1374 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1375     the string for the value and with the field name being included
1376     automatically.
1377  @param tree the tree to append this item to
1378  @param hfindex field index
1379  @param tvb the tv buffer of the current data
1380  @param start start of data in tvb
1381  @param length length of data in tvb
1382  @param value data to display
1383  @param format printf like format string
1384  @param ... printf like parameters
1385  @return the newly created item */
1386 WS_DLL_PUBLIC proto_item *
1387 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1388         gint start, gint length, double value, const char *format, ...)
1389         G_GNUC_PRINTF(7,8);
1390
1391 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1392     the entire string for the entry, including any field name.
1393  @param tree the tree to append this item to
1394  @param hfindex field index
1395  @param tvb the tv buffer of the current data
1396  @param start start of data in tvb
1397  @param length length of data in tvb
1398  @param value data to display
1399  @param format printf like format string
1400  @param ... printf like parameters
1401  @return the newly created item */
1402 WS_DLL_PUBLIC proto_item *
1403 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1404         gint length, double value, const char *format, ...) G_GNUC_PRINTF(7,8);
1405
1406 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1407  @param tree the tree to append this item to
1408  @param hfindex field index
1409  @param tvb the tv buffer of the current data
1410  @param start start of data in tvb
1411  @param length length of data in tvb
1412  @param value data to display
1413  @return the newly created item */
1414 WS_DLL_PUBLIC proto_item *
1415 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1416         gint length, guint32 value);
1417
1418 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1419     with the format generating the string for the value and with the field
1420     name being included automatically.
1421  @param tree the tree to append this item to
1422  @param hfindex field index
1423  @param tvb the tv buffer of the current data
1424  @param start start of data in tvb
1425  @param length length of data in tvb
1426  @param value data to display
1427  @param format printf like format string
1428  @param ... printf like parameters
1429  @return the newly created item */
1430 WS_DLL_PUBLIC proto_item *
1431 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1432         gint start, gint length, guint32 value, const char *format, ...)
1433         G_GNUC_PRINTF(7,8);
1434
1435 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1436     with the format generating the entire string for the entry, including any
1437     field name.
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 value data to display
1444  @param format printf like format string
1445  @param ... printf like parameters
1446  @return the newly created item */
1447 WS_DLL_PUBLIC proto_item *
1448 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1449         gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1450
1451 /** Add an FT_UINT64 to a proto_tree.
1452  @param tree the tree to append this item to
1453  @param hfindex field index
1454  @param tvb the tv buffer of the current data
1455  @param start start of data in tvb
1456  @param length length of data in tvb
1457  @param value data to display
1458  @return the newly created item */
1459 WS_DLL_PUBLIC proto_item *
1460 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1461         gint length, guint64 value);
1462
1463 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1464     the string for the value and with the field name being included
1465     automatically.
1466  @param tree the tree to append this item to
1467  @param hfindex field index
1468  @param tvb the tv buffer of the current data
1469  @param start start of data in tvb
1470  @param length length of data in tvb
1471  @param value data to display
1472  @param format printf like format string
1473  @param ... printf like parameters
1474  @return the newly created item */
1475 WS_DLL_PUBLIC proto_item *
1476 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1477         gint start, gint length, guint64 value, const char *format, ...)
1478         G_GNUC_PRINTF(7,8);
1479
1480 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1481     the entire string for the entry, including any field name.
1482  @param tree the tree to append this item to
1483  @param hfindex field index
1484  @param tvb the tv buffer of the current data
1485  @param start start of data in tvb
1486  @param length length of data in tvb
1487  @param value data to display
1488  @param format printf like format string
1489  @param ... printf like parameters
1490  @return the newly created item */
1491 WS_DLL_PUBLIC proto_item *
1492 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1493         gint length, guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1494
1495 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1496  @param tree the tree to append this item to
1497  @param hfindex field index
1498  @param tvb the tv buffer of the current data
1499  @param start start of data in tvb
1500  @param length length of data in tvb
1501  @param value data to display
1502  @return the newly created item */
1503 WS_DLL_PUBLIC proto_item *
1504 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1505         gint length, gint32 value);
1506
1507 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1508     with the format generating the string for the value and with the field
1509     name being included automatically.
1510  @param tree the tree to append this item to
1511  @param hfindex field index
1512  @param tvb the tv buffer of the current data
1513  @param start start of data in tvb
1514  @param length length of data in tvb
1515  @param value data to display
1516  @param format printf like format string
1517  @param ... printf like parameters
1518  @return the newly created item */
1519 WS_DLL_PUBLIC proto_item *
1520 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1521         gint start, gint length, gint32 value, const char *format, ...)
1522         G_GNUC_PRINTF(7,8);
1523
1524 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1525     with the format generating the entire string for the entry, including
1526     any field name.
1527  @param tree the tree to append this item to
1528  @param hfindex field index
1529  @param tvb the tv buffer of the current data
1530  @param start start of data in tvb
1531  @param length length of data in tvb
1532  @param value data to display
1533  @param format printf like format string
1534  @param ... printf like parameters
1535  @return the newly created item */
1536 WS_DLL_PUBLIC proto_item *
1537 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1538         gint length, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1539
1540 /** Add an FT_INT64 to a proto_tree.
1541  @param tree the tree to append this item to
1542  @param hfindex field index
1543  @param tvb the tv buffer of the current data
1544  @param start start of data in tvb
1545  @param length length of data in tvb
1546  @param value data to display
1547  @return the newly created item */
1548 WS_DLL_PUBLIC proto_item *
1549 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1550         gint length, gint64 value);
1551
1552 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1553     the string for the value and with the field name being included
1554     automatically.
1555  @param tree the tree to append this item to
1556  @param hfindex field index
1557  @param tvb the tv buffer of the current data
1558  @param start start of data in tvb
1559  @param length length of data in tvb
1560  @param value data to display
1561  @param format printf like format string
1562  @param ... printf like parameters
1563  @return the newly created item */
1564 WS_DLL_PUBLIC proto_item *
1565 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1566         gint start, gint length, gint64 value, const char *format, ...)
1567         G_GNUC_PRINTF(7,8);
1568
1569 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1570     the entire string for the entry, including any field name.
1571  @param tree the tree to append this item to
1572  @param hfindex field index
1573  @param tvb the tv buffer of the current data
1574  @param start start of data in tvb
1575  @param length length of data in tvb
1576  @param value data to display
1577  @param format printf like format string
1578  @param ... printf like parameters
1579  @return the newly created item */
1580 WS_DLL_PUBLIC proto_item *
1581 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1582         gint length, gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1583
1584 /** Add a FT_EUI64 to a proto_tree.
1585  @param tree the tree to append this item to
1586  @param hfindex field index
1587  @param tvb the tv buffer of the current data
1588  @param start start of data in tvb
1589  @param length length of data in tvb
1590  @param value data to display
1591  @return the newly created item */
1592 WS_DLL_PUBLIC proto_item *
1593 proto_tree_add_eui64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1594         gint length, const guint64 value);
1595
1596 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
1597     the string for the value and with the field name being included
1598     automatically.
1599  @param tree the tree to append this item to
1600  @param hfindex field index
1601  @param tvb the tv buffer of the current data
1602  @param start start of data in tvb
1603  @param length length of data in tvb
1604  @param value data to display
1605  @param format printf like format string
1606  @param ... printf like parameters
1607  @return the newly created item */
1608 WS_DLL_PUBLIC proto_item *
1609 proto_tree_add_eui64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1610         gint start, gint length, const guint64 value, const char *format, ...)
1611         G_GNUC_PRINTF(7,8);
1612
1613 /** Add a formatted FT_EUI64 to a proto_tree, with the format generating
1614     the entire string for the entry, including any field name.
1615  @param tree the tree to append this item to
1616  @param hfindex field index
1617  @param tvb the tv buffer of the current data
1618  @param start start of data in tvb
1619  @param length length of data in tvb
1620  @param value data to display
1621  @param format printf like format string
1622  @param ... printf like parameters
1623  @return the newly created item */
1624 WS_DLL_PUBLIC proto_item *
1625 proto_tree_add_eui64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1626         gint length, const guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1627
1628
1629 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1630     leave call to this function in production code.
1631  @param tree the tree to append the text to
1632  @param format printf like format string
1633  @param ... printf like parameters
1634  @return the newly created item */
1635 WS_DLL_PUBLIC proto_item *
1636 proto_tree_add_debug_text(proto_tree *tree, const char *format,
1637         ...) G_GNUC_PRINTF(2,3);
1638
1639
1640
1641 /** Append a string to a protocol item.<br>
1642     NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1643     speed optimization.
1644     Currently only WSP use this function so it is not that bad but try to
1645     avoid using this one if possible.
1646     IF you must use this function you MUST also disable the
1647     TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1648     using proto_item_append_string().
1649     Do that by faking that the tree is visible by calling
1650     proto_tree_set_visible(tree, TRUE) (see packet-wsp.c)
1651     BEFORE you create the item you are later going to use
1652     proto_item_append_string() on.
1653  @param pi the item to append the string to
1654  @param str the string to append */
1655 WS_DLL_PUBLIC void
1656 proto_item_append_string(proto_item *pi, const char *str);
1657
1658
1659
1660 /** Fill given label_str with string representation of field
1661  @param fi the item to get the info from
1662  @param label_str the string to fill
1663  @todo think about changing the parameter profile */
1664 WS_DLL_PUBLIC void
1665 proto_item_fill_label(field_info *fi, gchar *label_str);
1666
1667
1668 /** Register a new protocol.
1669  @param name the full name of the new protocol
1670  @param short_name abbreviated name of the new protocol
1671  @param filter_name protocol name used for a display filter string
1672  @return the new protocol handle */
1673 WS_DLL_PUBLIC int
1674 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
1675
1676 /** Mark protocol as private
1677  @param proto_id the handle of the protocol */
1678 WS_DLL_PUBLIC
1679 void
1680 proto_mark_private(const int proto_id);
1681
1682 /** Return if protocol is private
1683  @param proto_id the handle of the protocol
1684  @return TRUE if it is a private protocol, FALSE is not. */
1685 WS_DLL_PUBLIC gboolean
1686 proto_is_private(const int proto_id);
1687
1688 /** This type of function can be registered to get called whenever
1689     a given field was not found but a its prefix is matched;
1690     It can be used to procrastinate the hf array registration.
1691    @param match  what's being matched */
1692 typedef void (*prefix_initializer_t)(const char* match);
1693
1694 /** Register a new prefix for delayed initialization of field arrays
1695 @param prefix the prefix for the new protocol
1696 @param initializer function that will initialize the field array for the given prefix */
1697 WS_DLL_PUBLIC void
1698 proto_register_prefix(const char *prefix,  prefix_initializer_t initializer);
1699
1700 /** Initialize every remaining uninitialized prefix. */
1701 WS_DLL_PUBLIC void proto_initialize_all_prefixes(void);
1702
1703 WS_DLL_PUBLIC void proto_register_fields_manual(const int parent, header_field_info **hfi, const int num_records);
1704 WS_DLL_PUBLIC void proto_register_fields_section(const int parent, header_field_info *hfi, const int num_records);
1705
1706 /** Register a header_field array.
1707  @param parent the protocol handle from proto_register_protocol()
1708  @param hf the hf_register_info array
1709  @param num_records the number of records in hf */
1710 WS_DLL_PUBLIC void
1711 proto_register_field_array(const int parent, hf_register_info *hf, const int num_records);
1712
1713 /** Unregister an already registered field.
1714  @param parent the protocol handle from proto_register_protocol()
1715  @param hf_id the field to unregister */
1716 WS_DLL_PUBLIC void
1717 proto_unregister_field (const int parent, gint hf_id);
1718
1719 /** Register a protocol subtree (ett) array.
1720  @param indices array of ett indices
1721  @param num_indices the number of records in indices */
1722 WS_DLL_PUBLIC void
1723 proto_register_subtree_array(gint *const *indices, const int num_indices);
1724
1725 /** Returns number of items (protocols or header fields) registered.
1726  @return the number of items */
1727 WS_DLL_PUBLIC int proto_registrar_n(void);
1728
1729 /** Get name of registered header_field number n.
1730  @param n item # n (0-indexed)
1731  @return the name of this registered item */
1732 extern const char* proto_registrar_get_name(const int n);
1733
1734 /** Get abbreviation of registered header_field number n.
1735  @param n item # n (0-indexed)
1736  @return the abbreviation of this registered item */
1737 WS_DLL_PUBLIC const char* proto_registrar_get_abbrev(const int n);
1738
1739 /** Get the header_field information based upon a field or protocol id.
1740  @param hfindex item # n (0-indexed)
1741  @return the registered item */
1742 WS_DLL_PUBLIC header_field_info* proto_registrar_get_nth(guint hfindex);
1743
1744 /** Get the header_field information based upon a field name.
1745  @param field_name the field name to search for
1746  @return the registered item */
1747 WS_DLL_PUBLIC header_field_info* proto_registrar_get_byname(const char *field_name);
1748
1749 /** Get the header_field id based upon a field name.
1750  @param field_name the field name to search for
1751  @return the field id for the registered item */
1752 extern int proto_registrar_get_id_byname(const char *field_name);
1753
1754 /** Get enum ftenum FT_ of registered header_field number n.
1755  @param n item # n (0-indexed)
1756  @return the registered item */
1757 WS_DLL_PUBLIC enum ftenum proto_registrar_get_ftype(const int n);
1758
1759 /** Get parent protocol of registered header_field number n.
1760  @param n item # n (0-indexed)
1761  @return -1 if item _is_ a protocol */
1762 WS_DLL_PUBLIC int proto_registrar_get_parent(const int n);
1763
1764 /** Is item # n a protocol?
1765  @param n item # n (0-indexed)
1766  @return TRUE if it's a protocol, FALSE if it's not */
1767 WS_DLL_PUBLIC gboolean proto_registrar_is_protocol(const int n);
1768
1769 /** Get length of registered field according to field type.
1770  @param n item # n (0-indexed)
1771  @return 0 means undeterminable at registration time, -1 means unknown field */
1772 extern gint proto_registrar_get_length(const int n);
1773
1774
1775 /** Routines to use to iterate over the protocols and their fields;
1776  * they return the item number of the protocol in question or the
1777  * appropriate hfinfo pointer, and keep state in "*cookie". */
1778 WS_DLL_PUBLIC int proto_get_first_protocol(void **cookie);
1779 WS_DLL_PUBLIC int proto_get_data_protocol(void *cookie);
1780 WS_DLL_PUBLIC int proto_get_next_protocol(void **cookie);
1781 WS_DLL_PUBLIC header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookle);
1782 WS_DLL_PUBLIC header_field_info *proto_get_next_protocol_field(void **cookle);
1783
1784 /** Given a protocol's filter_name.
1785  @param filter_name the filter name to search for
1786  @return proto_id */
1787 WS_DLL_PUBLIC int proto_get_id_by_filter_name(const gchar* filter_name);
1788
1789 /** Can item # n decoding be disabled?
1790  @param proto_id protocol id (0-indexed)
1791  @return TRUE if it's a protocol, FALSE if it's not */
1792 WS_DLL_PUBLIC gboolean proto_can_toggle_protocol(const int proto_id);
1793
1794 /** Get the "protocol_t" structure for the given protocol's item number.
1795  @param proto_id protocol id (0-indexed) */
1796 WS_DLL_PUBLIC protocol_t *find_protocol_by_id(const int proto_id);
1797
1798 /** Get the protocol's name for the given protocol's item number.
1799  @param proto_id protocol id (0-indexed)
1800  @return its name */
1801 WS_DLL_PUBLIC const char *proto_get_protocol_name(const int proto_id);
1802
1803 /** Get the protocol's item number, for the given protocol's "protocol_t".
1804  @return its proto_id */
1805 WS_DLL_PUBLIC int proto_get_id(const protocol_t *protocol);
1806
1807 /** Get the protocol's short name, for the given protocol's "protocol_t".
1808  @return its short name. */
1809 WS_DLL_PUBLIC const char *proto_get_protocol_short_name(const protocol_t *protocol);
1810
1811 /** Get the protocol's long name, for the given protocol's "protocol_t".
1812  @return its long name. */
1813 WS_DLL_PUBLIC const char *proto_get_protocol_long_name(const protocol_t *protocol);
1814
1815 /** Is protocol's decoding enabled ?
1816  @return TRUE if decoding is enabled, FALSE if not */
1817 WS_DLL_PUBLIC gboolean proto_is_protocol_enabled(const protocol_t *protocol);
1818
1819 /** Get a protocol's filter name by its item number.
1820  @param proto_id protocol id (0-indexed)
1821  @return its filter name. */
1822 WS_DLL_PUBLIC const char *proto_get_protocol_filter_name(const int proto_id);
1823
1824 /** Find commonly-used protocols in a layer list.
1825  * @param layers Protocol layer list
1826  * @param is_ip Set to TRUE if the layer list contains IPv4 or IPv6, otherwise
1827  * unchanged. May be NULL.
1828  * @param is_tcp Set to TRUE if the layer list contains TCP, otherwise
1829  * unchanged. May be NULL.
1830  * @param is_udp Set to TRUE if the layer list contains UDP, otherwise
1831  * unchanged. May be NULL.
1832  * @param is_sctp Set to TRUE if the layer list contains SCTP, otherwise
1833  * unchanged. May be NULL.
1834  * @param is_ssl Set to TRUE if the layer list contains SSL/TLS, otherwise
1835  * unchanged. May be NULL.
1836  */
1837 WS_DLL_PUBLIC void proto_get_frame_protocols(const wmem_list_t *layers,
1838       gboolean *is_ip, gboolean *is_tcp, gboolean *is_udp, gboolean *is_sctp, gboolean *is_ssl);
1839
1840 /** Enable / Disable protocol of the given item number.
1841  @param proto_id protocol id (0-indexed)
1842  @param enabled enable / disable the protocol */
1843 WS_DLL_PUBLIC void proto_set_decoding(const int proto_id, const gboolean enabled);
1844
1845 /** Enable all protocols */
1846 WS_DLL_PUBLIC void proto_enable_all(void);
1847
1848 /** Disable disabling/enabling of protocol of the given item number.
1849  @param proto_id protocol id (0-indexed) */
1850 WS_DLL_PUBLIC void proto_set_cant_toggle(const int proto_id);
1851
1852 /** Checks for existence any protocol or field within a tree.
1853  @param tree "Protocols" are assumed to be a child of the [empty] root node.
1854  @param id hfindex of protocol or field
1855  @return TRUE = found, FALSE = not found
1856  @todo add explanation of id parameter */
1857 extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id);
1858
1859 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1860     tree. Only works with primed trees, and is fast.
1861  @param tree tree of interest
1862  @param hfindex primed hfindex
1863  @return GPtrArry pointer */
1864 WS_DLL_PUBLIC GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
1865
1866 /** Return whether we're tracking any interesting fields.
1867     Only works with primed trees, and is fast.
1868  @param tree tree of interest
1869  @return TRUE if we're tracking interesting fields */
1870 WS_DLL_PUBLIC gboolean proto_tracking_interesting_fields(const proto_tree *tree);
1871
1872 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1873     tree. Works with any tree, primed or unprimed, and is slower than
1874 WS_DLL_PUBLIC
1875     proto_get_finfo_ptr_array because it has to search through the tree.
1876  @param tree tree of interest
1877  @param hfindex index of field info of interest
1878  @return GPtrArry pointer */
1879 WS_DLL_PUBLIC GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex);
1880
1881 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
1882     in tree.
1883  @param tree tree of interest
1884  @return GPtrArry pointer */
1885 WS_DLL_PUBLIC GPtrArray* proto_all_finfos(proto_tree *tree);
1886
1887 /** Dumps a glossary of the protocol registrations to STDOUT */
1888 WS_DLL_PUBLIC void proto_registrar_dump_protocols(void);
1889
1890 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
1891 WS_DLL_PUBLIC void proto_registrar_dump_values(void);
1892
1893 /** Dumps a glossary of the protocol and field registrations to STDOUT. */
1894 WS_DLL_PUBLIC void proto_registrar_dump_fields(void);
1895
1896 /** Dumps a glossary field types and descriptive names to STDOUT */
1897 WS_DLL_PUBLIC void proto_registrar_dump_ftypes(void);
1898
1899
1900 /** Number of elements in the tree_is_expanded array. With MSVC and a
1901  * libwireshark.dll, we need a special declaration. */
1902 WS_DLL_PUBLIC int           num_tree_types;
1903
1904 /** Returns TRUE if subtrees of that type are to be expanded. */
1905 WS_DLL_PUBLIC gboolean tree_expanded(int tree_type);
1906
1907 /** Sets if subtrees of that type are to be expanded. */
1908 WS_DLL_PUBLIC void tree_expanded_set(int tree_type, gboolean value);
1909
1910 /** glib doesn't have g_ptr_array_len of all things!*/
1911 #ifndef g_ptr_array_len
1912 #define g_ptr_array_len(a)      ((a)?(a)->len:0)
1913 #endif
1914
1915 /** Get number of bits of a header_field.
1916  @param hfinfo header_field
1917  @return the bitwidth */
1918 extern int
1919 hfinfo_bitwidth(const header_field_info *hfinfo);
1920
1921 WS_DLL_PUBLIC int
1922 hfinfo_bitshift(const header_field_info *hfinfo);
1923
1924 struct epan_dissect;
1925
1926 /** Can we do a "match selected" on this field.
1927  @param finfo field_info
1928  @param edt epan dissecting
1929  @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
1930 WS_DLL_PUBLIC gboolean
1931 proto_can_match_selected(field_info *finfo, struct epan_dissect *edt);
1932
1933 /** Construct a "match selected" display filter string.
1934  @param finfo field_info
1935  @param edt epan dissecting
1936  @return the display filter string */
1937 WS_DLL_PUBLIC char*
1938 proto_construct_match_selected_string(field_info *finfo, struct epan_dissect *edt);
1939
1940 /** Find field from offset in tvb.
1941  @param tree tree of interest
1942  @param offset offset in the tvb
1943  @param tvb the tv buffer
1944  @return the corresponding field_info */
1945 WS_DLL_PUBLIC field_info*
1946 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
1947
1948 /** This function will dissect a sequence of bytes that describe a bitmask.
1949  @param tree the tree to append this item to
1950  @param tvb the tv buffer of the current data
1951  @param offset start of data in tvb
1952  @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
1953         This field will form an expansion under which the individual fields of the
1954         bitmask is dissected and displayed.
1955         This field must be of the type FT_[U]INT{8|16|24|32}.
1956  @param ett subtree index
1957  @param fields an array of pointers to int that lists all the fields of the
1958         bitmask. These fields can be either of the type FT_BOOLEAN for flags
1959         or another integer of the same type/size as hf_hdr with a mask specified.
1960         This array is terminated by a NULL entry.
1961         FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
1962         FT_integer fields that have a value_string attached will have the
1963         matched string displayed on the expansion line.
1964  @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
1965  @return the newly created item */
1966 WS_DLL_PUBLIC proto_item *
1967 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
1968                 const int hf_hdr, const gint ett, const int **fields, const guint encoding);
1969
1970 /** This function will dissect a sequence of bytes that describe a bitmask.
1971  @param tree the tree to append this item to
1972  @param tvb the tv buffer of the current data
1973  @param offset start of data in tvb
1974  @param len number of bytes of data
1975  @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
1976         This field will form an expansion under which the individual fields of the
1977         bitmask are dissected and displayed.
1978         This field must be of the type FT_[U]INT{8|16|24|32}.
1979  @param ett subtree index
1980  @param fields an array of pointers to int that lists all the fields of the
1981         bitmask. These fields can be either of the type FT_BOOLEAN for flags
1982         or another integer with a mask specified.
1983         This array is terminated by a NULL entry.
1984         FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
1985         FT_integer fields that have a value_string attached will have the
1986         matched string displayed on the expansion line.
1987  @param exp expert info field used when decodable_len < len.  This also means this function
1988         should be called even when tree == NULL
1989  @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
1990  @return the newly created item */
1991 WS_DLL_PUBLIC proto_item *
1992 proto_tree_add_bitmask_len(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
1993                 const int hf_hdr, const gint ett, const int **fields, struct expert_field* exp, const guint encoding);
1994
1995 /** Add a text with a subtree of bitfields.
1996  @param tree the tree to append this item to
1997  @param tvb the tv buffer of the current data
1998  @param offset start of data in tvb
1999  @param len length of the field name
2000  @param name field name (NULL if bitfield contents should be used)
2001  @param fallback field name if none of bitfields were usable
2002  @param ett subtree index
2003  @param fields NULL-terminated array of bitfield indexes
2004  @param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
2005  @param flags bitmask field
2006  @return the newly created item */
2007 WS_DLL_PUBLIC proto_item *
2008 proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
2009                 const char *name, const char *fallback,
2010                 const gint ett, const int **fields, const guint encoding, const int flags);
2011
2012 #define BMT_NO_APPEND   0x01    /**< Don't change the title at all */
2013 #define BMT_NO_INT      0x02    /**< Don't add integral (non-boolean) fields to title */
2014 #define BMT_NO_FALSE    0x04    /**< Don't add booleans unless they're TRUE */
2015 #define BMT_NO_TFS      0x08    /**< Don't use true_false_string while formatting booleans */
2016
2017 /** Add bits to a proto_tree, using the text label registered to that item.
2018    The item is extracted from the tvbuff handed to it.
2019  @param tree the tree to append this item to
2020  @param hf_index field index. Fields for use with this function should have bitmask==0.
2021  @param tvb the tv buffer of the current data
2022  @param bit_offset start of data in tvb expressed in bits
2023  @param no_of_bits length of data in tvb expressed in bits
2024  @param encoding data encoding
2025  @return the newly created item */
2026 WS_DLL_PUBLIC proto_item *
2027 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);
2028
2029 /** Add bits to a proto_tree, using the text label registered to that item.
2030 *  The item is extracted from the tvbuff handed to it as a set
2031 *  of crumbs (segments) of contiguous bits, specified by an
2032 *  array of crumb_spec elements.  The crumbs are assembled to
2033 *  create the value.  There may be any number of crumbs
2034 *  specifying up to a total of 64 bits which may occur anywhere
2035 *  within the tvb. If the span of the crumbs within the tvb is 4
2036 *  octets or less, a bitmap of the crumbs is produced.
2037  @param tree the tree to append this item to
2038  @param hf_index field index. Fields for use with this function should have bitmask==0.
2039  @param tvb the tv buffer of the current data
2040  @param bit_offset of the first crumb in tvb expressed in bits
2041  @param crumb_spec pointer to crumb_spec array
2042  @param return_value if a pointer is passed here the value is returned.
2043  @return the newly created item */
2044 extern proto_item *
2045 proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
2046                             const guint bit_offset, const crumb_spec_t *crumb_spec,
2047                             guint64 *return_value);
2048
2049
2050 /** Add bitmap text for a split-bits crumb to a proto_tree,
2051 *  using the text label registered to an item. The bitmap is
2052 *  extracted from the tvbuff handed to it as a crumb (segment)
2053 *  of contiguous bits, specified by one of an array of
2054 *  crumb_spec elements. This function is normally called once
2055 *  per crumb, after the call to
2056    proto_tree_add_split_bits_item_ret_val
2057  @param tree the tree to append this item to
2058  @param hf_index field index. Fields for use with this function should have bitmask==0.
2059  @param tvb the tv buffer of the current data
2060  @param bit_offset of the first crumb in tvb expressed in bits
2061  @param crumb_spec pointer to crumb_spec array
2062  @param crumb_index into the crumb_spec array for this crumb */
2063 void
2064 proto_tree_add_split_bits_crumb(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const guint bit_offset,
2065                                 const crumb_spec_t *crumb_spec, guint16 crumb_index);
2066
2067 /** Add bits to a proto_tree, using the text label registered to that item.
2068    The item is extracted from the tvbuff handed to it.
2069  @param tree the tree to append this item to
2070  @param hf_index field index. Fields for use with this function should have bitmask==0.
2071  @param tvb the tv buffer of the current data
2072  @param bit_offset start of data in tvb expressed in bits
2073  @param no_of_bits length of data in tvb expressed in bits
2074  @param return_value if a pointer is passed here the value is returned.
2075  @param encoding data encoding
2076  @return the newly created item */
2077 WS_DLL_PUBLIC proto_item *
2078 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);
2079
2080 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
2081     header field to a proto_tree, with the format generating the
2082     string for the value and with the field name being included automatically.
2083  @param tree the tree to append this item to
2084  @param hf_index field index
2085  @param tvb the tv buffer of the current data
2086  @param bit_offset start of data in tvb expressed in bits
2087  @param no_of_bits length of data in tvb expressed in bit
2088  @param value data to display
2089  @param format printf like format string
2090  @return the newly created item */
2091 WS_DLL_PUBLIC proto_item *
2092 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,
2093         guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2094
2095 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
2096     the format generating the string for the value and with the field
2097     name being included automatically.
2098  @param tree the tree to append this item to
2099  @param hf_index field index
2100  @param tvb the tv buffer of the current data
2101  @param bit_offset start of data in tvb expressed in bits
2102  @param no_of_bits length of data in tvb expressed in bit
2103  @param value data to display
2104  @param format printf like format string
2105  @param ... printf like parameters
2106  @return the newly created item */
2107 proto_item *
2108 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,
2109         guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2110
2111 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
2112     header field to a proto_tree, with the format generating the
2113     string for the value and with the field name being included automatically.
2114  @param tree the tree to append this item to
2115  @param hf_index field index
2116  @param tvb the tv buffer of the current data
2117  @param bit_offset start of data in tvb expressed in bits
2118  @param no_of_bits length of data in tvb expressed in bit
2119  @param value data to display
2120  @param format printf like format string
2121  @param ... printf like parameters
2122  @return the newly created item */
2123 proto_item *
2124 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,
2125         gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
2126
2127 /** Add bits for a FT_FLOAT header field to a proto_tree, with
2128     the format generating the string for the value and with the field
2129     name being included automatically.
2130  @param tree the tree to append this item to
2131  @param hf_index field index
2132  @param tvb the tv buffer of the current data
2133  @param bit_offset start of data in tvb expressed in bits
2134  @param no_of_bits length of data in tvb expressed in bit
2135  @param value data to display
2136  @param format printf like format string
2137  @param ... printf like parameters
2138  @return the newly created item */
2139 proto_item *
2140 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,
2141         float value, const char *format, ...) G_GNUC_PRINTF(7,8);
2142
2143
2144 /** Add a FT_STRING with ENC_3GPP_TS_23_038_7BITS encoding to a proto_tree.
2145  @param tree the tree to append this item to
2146  @param hfindex field index
2147  @param tvb the tv buffer of the current data
2148  @param bit_offset start of data in tvb expressed in bits
2149  @param no_of_chars number of 7bits characters to display
2150  @return the newly created item */
2151 WS_DLL_PUBLIC proto_item *
2152 proto_tree_add_ts_23_038_7bits_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
2153         const guint bit_offset, const gint no_of_chars);
2154
2155 /** Check if given string is a valid field name
2156  @param field_name the field name to check
2157  @return 0 if valid, else first illegal character */
2158 WS_DLL_PUBLIC guchar
2159 proto_check_field_name(const gchar *field_name);
2160
2161
2162 /** Check if given string is a valid field name
2163  @param tree the tree to append this item to
2164  @param field_id the field id used for custom column
2165  @param occurrence the occurrence of the field used for custom column
2166  @param result the buffer to fill with the field string
2167  @param expr the filter expression
2168  @param size the size of the string buffer */
2169 const gchar *
2170 proto_custom_set(proto_tree* tree, const int field_id,
2171                              gint occurrence,
2172                              gchar *result,
2173                              gchar *expr, const int size );
2174
2175 /* #define HAVE_HFI_SECTION_INIT */
2176
2177 #ifdef HAVE_HFI_SECTION_INIT
2178  #define HFI_INIT(proto) __attribute__((section( "_data_" G_STRINGIFY(proto)))) __attribute__((aligned(sizeof(void *))))
2179
2180  #define proto_register_fields(proto, hfi, count) \
2181         do { \
2182         extern header_field_info __start__data_ ##proto[]; \
2183         extern header_field_info __stop__data_ ##proto[]; \
2184 \
2185         proto_register_fields_section(proto, __start__data_ ##proto, (int) (__stop__data_ ##proto - __start__data_ ##proto)); \
2186         } while(0)
2187 #else
2188  #define HFI_INIT(proto)
2189  #define proto_register_fields(proto, hfi, count) \
2190         proto_register_fields_manual(proto, hfi, count)
2191 #endif
2192
2193 #ifdef NEW_PROTO_TREE_API
2194 #define proto_tree_add_item(tree, hfinfo, tvb, start, length, encoding) \
2195         proto_tree_add_item_new(tree, hfinfo, tvb, start, length, encoding)
2196
2197 #define proto_tree_add_boolean(tree, hfinfo, tvb, start, length, value) \
2198         proto_tree_add_boolean(tree, (hfinfo)->id, tvb, start, length, value)
2199
2200 #define proto_tree_add_string(tree, hfinfo, tvb, start, length, value) \
2201         proto_tree_add_string(tree, (hfinfo)->id, tvb, start, length, value)
2202
2203 #define proto_tree_add_time(tree, hfinfo, tvb, start, length, value) \
2204         proto_tree_add_time(tree, (hfinfo)->id, tvb, start, length, value)
2205
2206 #define proto_tree_add_int(tree, hfinfo, tvb, start, length, value) \
2207         proto_tree_add_int(tree, (hfinfo)->id, tvb, start, length, value)
2208
2209 #define proto_tree_add_uint(tree, hfinfo, tvb, start, length, value) \
2210         proto_tree_add_uint(tree, (hfinfo)->id, tvb, start, length, value)
2211 #endif
2212
2213 /** @} */
2214
2215 #ifdef __cplusplus
2216 }
2217 #endif /* __cplusplus */
2218
2219 #endif /* proto.h */