2 * Definitions for protocol display
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 The protocol tree related functions.<BR>
28 A protocol tree will hold all necessary data to display the whole dissected packet.
29 Creating a protocol tree is done in a two stage process:
30 A static part at program startup, and a dynamic part when the dissection with the real packet data is done.<BR>
31 The "static" information is provided by creating a hf_register_info hf[] array, and register it using the
32 proto_register_field_array() function. This is usually done at dissector registering.<BR>
33 The "dynamic" information is added to the protocol tree by calling one of the proto_tree_add_...() functions,
34 e.g. proto_tree_add_bytes().
52 #include "ftypes/ftypes.h"
57 #endif /* __cplusplus */
59 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
60 WS_VAR_IMPORT int hf_text_only;
62 /** the maximum length of a protocol field string representation */
63 #define ITEM_LABEL_LENGTH 240
67 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
68 #define VALS(x) (const struct _value_string*)(x)
70 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
71 #define TFS(x) (const struct true_false_string*)(x)
73 typedef void (*custom_fmt_func_t)(gchar *, guint32);
75 /** Make a const range_string[] look like a _range_string pointer, used to set
76 * header_field_info.strings */
77 #define RVALS(x) (const struct _range_string*)(x)
81 /** Structure for information about a protocol */
82 typedef struct _protocol protocol_t;
84 /** check protocol activation
85 * @todo this macro looks like a hack */
86 #define CHECK_DISPLAY_AS_X(x_handle,index, tvb, pinfo, tree) { \
87 if (!proto_is_protocol_enabled(find_protocol_by_id(index))) { \
88 call_dissector(x_handle,tvb, pinfo, tree); \
93 /** Macro used for reporting errors in dissectors; it throws a
94 * DissectorError exception, with the string passed as an argument
95 * as the message for the exception, so that it can show up in
96 * the Info column and the protocol tree.
98 * If that string is dynamically allocated, it should be allocated with
99 * ep_alloc(); using ep_strdup_printf() would work.
101 * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
102 * it will call abort(), instead, to make it easier to get a stack trace.
104 * @param message string to use as the message
106 #define REPORT_DISSECTOR_BUG(message) \
107 ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) ? \
109 THROW_MESSAGE(DissectorError, message))
111 /** Macro used for assertions in dissectors; it doesn't abort, it just
112 * throws a DissectorError exception, with the assertion failure
113 * message as a parameter, so that it can show up in the protocol tree.
115 * @param expression expression to test in the assertion
117 #define DISSECTOR_ASSERT(expression) \
118 ((void) ((expression) ? (void)0 : \
119 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__)))
122 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
123 * as the assert handling of GTK/GLib is currently not very helpful */
124 #define DISSECTOR_ASSERT(expression) \
125 { if(!(expression)) _asm { int 3}; }
128 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
129 * unconditionally, much like GLIB's g_assert_not_reached works.
131 #define DISSECTOR_ASSERT_NOT_REACHED() \
132 (REPORT_DISSECTOR_BUG( \
133 ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
134 __FILE__, __LINE__)))
136 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
138 #define __DISSECTOR_ASSERT(expression, file, lineno) \
139 (REPORT_DISSECTOR_BUG( \
140 ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
141 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
144 * The encoding of a field of a particular type may involve more
145 * than just whether it's big-endian or little-endian and its size.
147 * For integral values, that's it, as 99.9999999999999% of the machines
148 * out there are 2's complement binary machines with 8-bit bytes,
149 * so the protocols out there expect that and, for example, any Unisys
150 * 2200 series machines out there just have to translate between 2's
151 * complement and 1's complement (and nobody's put any IBM 709x's on
152 * any networks lately :-)).
156 * for floating-point numbers, in addition to IEEE decimal
157 * floating-point, there's also IBM System/3x0 and PDP-11/VAX
158 * floating-point - most protocols use IEEE binary, but DCE RPC
159 * can use other formats if that's what the sending host uses;
161 * for character strings, there are various character encodings
162 * (various ISO 646 sets, ISO 8859/x, various other national
163 * standards, various DOS and Windows encodings, various Mac
164 * encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
167 * for absolute times, there's UNIX time_t, UNIX time_t followed
168 * by 32-bit microseconds, UNIX time_t followed by 32-bit
169 * nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
171 * We might also, in the future, want to allow a field specifier to
172 * indicate the encoding of the field, or at least its default
173 * encoding, as most fields in most protocols always use the
174 * same encoding (although that's not true of all fields, so we
175 * still need to be able to specify that at run time).
177 * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
178 * bit flags, to be combined, in the future, with other information
179 * to specify the encoding in the last argument to
180 * proto_tree_add_item(), and possibly to specify in a field
181 * definition (e.g., ORed in with the type value).
183 * Currently, proto_tree_add_item() treats its last argument as a
184 * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
185 * the field is little-endian - and other code in epan/proto.c does
186 * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and
187 * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
188 * so that we could put a field type and/or a value such as a character
189 * encoding in the lower bits.
191 * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
192 * opaque byte-array fields (FT_BYTES), and other fields where there
193 * is no choice of encoding (either because it's "just a bucket
194 * of bytes" or because the encoding is completely fixed), we
195 * have ENC_NA (for "Not Applicable").
197 #define ENC_BIG_ENDIAN 0x00000000
198 #define ENC_LITTLE_ENDIAN 0x80000000
200 #define ENC_NA 0x00000000
202 /* Values for header_field_info.display */
204 /* For integral types, the display format is a base_display_e value
205 * possibly ORed with BASE_RANGE_STRING. */
207 /** BASE_DISPLAY_E_MASK selects the base_display_e value. Its current
208 * value means that we may have at most 16 base_display_e values. */
209 #define BASE_DISPLAY_E_MASK 0x0F
212 BASE_NONE, /**< none */
213 BASE_DEC, /**< decimal */
214 BASE_HEX, /**< hexadecimal */
215 BASE_OCT, /**< octal */
216 BASE_DEC_HEX, /**< decimal (hexadecimal) */
217 BASE_HEX_DEC, /**< hexadecimal (decimal) */
218 BASE_CUSTOM /**< call custom routine (in ->strings) to format */
221 /* Following constants have to be ORed with a base_display_e when dissector
222 * want to use specials MACROs (for the moment, only RVALS) for a
223 * header_field_info */
224 #define BASE_RANGE_STRING 0x10
225 #define BASE_EXT_STRING 0x20
227 /** BASE_ values that cause the field value to be displayed twice */
228 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
230 /* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e
231 * as per time_fmt.h. */
234 HF_REF_TYPE_NONE, /**< Field is not referenced */
235 HF_REF_TYPE_INDIRECT, /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
236 HF_REF_TYPE_DIRECT /**< Field is directly referenced */
239 /** information describing a header field */
240 typedef struct _header_field_info header_field_info;
242 /** information describing a header field */
243 struct _header_field_info {
244 /* ---------- set by dissector --------- */
245 const char *name; /**< full name of this field */
246 const char *abbrev; /**< abbreviated name of this field */
247 enum ftenum type; /**< field type, one of FT_ (from ftypes.h) */
248 int display; /**< one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
249 const void *strings; /**< value_string, range_string or true_false_string,
250 typically converted by VALS(), RVALS() or TFS().
251 If this is an FT_PROTOCOL then it points to the
252 associated protocol_t structure */
253 guint32 bitmask; /**< bitmask of interesting bits */
254 const char *blurb; /**< Brief description of field */
256 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
257 int id; /**< Field ID */
258 int parent; /**< parent protocol tree */
259 hf_ref_type ref_type; /**< is this field referenced by a filter */
260 int bitshift; /**< bits to shift */
261 header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev */
262 header_field_info *same_name_prev; /**< Link to previous hfinfo with same abbrev */
266 * HFILL initializes all the "set by proto routines" fields in a
267 * _header_field_info. If new fields are added or removed, it should
268 * be changed as necessary.
270 #define HFILL 0, 0, HF_REF_TYPE_NONE, 0, NULL, NULL
272 /** Used when registering many fields at once, using proto_register_field_array() */
273 typedef struct hf_register_info {
274 int *p_id; /**< written to by register() function */
275 header_field_info hfinfo; /**< the field info to be registered */
281 /** string representation, if one of the proto_tree_add_..._format() functions used */
282 typedef struct _item_label_t {
283 char representation[ITEM_LABEL_LENGTH];
287 /** Contains the field information for the proto_item. */
288 typedef struct field_info {
289 header_field_info *hfinfo; /**< pointer to registered field information */
290 gint start; /**< current start of data in field_info.ds_tvb */
291 gint length; /**< current data length of item in field_info.ds_tvb */
292 gint appendix_start; /**< start of appendix data */
293 gint appendix_length; /**< length of appendix data */
294 gint tree_type; /**< one of ETT_ or -1 */
295 item_label_t *rep; /**< string for GUI tree */
296 guint32 flags; /**< bitfield like FI_GENERATED, ... */
297 tvbuff_t *ds_tvb; /**< data source tvbuff */
303 * Flag fields. Do not assign values greater than 0x00000080 unless you
304 * shuffle the expert information upward; see below.
307 /** The protocol field should not be shown in the tree (it's used for filtering only),
308 * used in field_info.flags. */
309 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
310 A user cannot tell by looking at the packet detail that the field exists
311 and that they can filter on its value. */
312 #define FI_HIDDEN 0x00000001
313 /** The protocol field should be displayed as "generated by Wireshark",
314 * used in field_info.flags. */
315 #define FI_GENERATED 0x00000002
316 /** The protocol field is actually a URL */
317 #define FI_URL 0x00000004
319 /** The protocol field value is in little endian */
320 #define FI_LITTLE_ENDIAN 0x00000008
321 /** The protocol field value is in big endian */
322 #define FI_BIG_ENDIAN 0x00000010
323 /** Field value start from nth bit (values from 0x20 - 0x100) */
324 #define FI_BITS_OFFSET(n) ((n & 7) << 5)
325 /** Field value takes n bits (values from 0x100 - 0x4000) */
326 /* if 0, it means that field takes fi->length * 8 */
327 #define FI_BITS_SIZE(n) ((n & 63) << 8)
329 /** convenience macro to get field_info.flags */
330 #define FI_GET_FLAG(fi, flag) ((fi) ? (fi->flags & flag) : 0)
331 /** convenience macro to set field_info.flags */
332 #define FI_SET_FLAG(fi, flag) \
335 (fi)->flags = (fi)->flags | (flag); \
338 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
339 #define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
341 /** One of these exists for the entire protocol tree. Each proto_node
342 * in the protocol tree points to the same copy. */
344 GHashTable *interesting_hfids;
346 gboolean fake_protocols;
350 /** Each proto_tree, proto_item is one of these. */
351 typedef struct _proto_node {
352 struct _proto_node *first_child;
353 struct _proto_node *last_child;
354 struct _proto_node *next;
355 struct _proto_node *parent;
357 tree_data_t *tree_data;
360 /** A protocol tree element. */
361 typedef proto_node proto_tree;
362 /** A protocol item element. */
363 typedef proto_node proto_item;
366 * Expert information.
367 * This is in the flags field; we allocate this from the top down,
368 * so as not to collide with FI_ flags, which are allocated from
372 /* expert severities */
373 #define PI_SEVERITY_MASK 0x00F00000 /**< mask usually for internal use only! */
374 /** Usual workflow, e.g. TCP connection establishing */
375 #define PI_CHAT 0x00200000
376 /** Notable messages, e.g. an application returned an "usual" error code like HTTP 404 */
377 #define PI_NOTE 0x00400000
378 /** Warning, e.g. application returned an "unusual" error code */
379 #define PI_WARN 0x00600000
380 /** Serious problems, e.g. [Malformed Packet] */
381 #define PI_ERROR 0x00800000
383 /* expert "event groups" */
384 #define PI_GROUP_MASK 0xFF000000 /**< mask usually for internal use only! */
385 /** The protocol field has a bad checksum, usually PI_WARN */
387 #define PI_CHECKSUM 0x01000000
388 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
389 #define PI_SEQUENCE 0x02000000
390 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
391 #define PI_RESPONSE_CODE 0x03000000
392 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
393 #define PI_REQUEST_CODE 0x04000000
394 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
395 #define PI_UNDECODED 0x05000000
396 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
397 #define PI_REASSEMBLE 0x06000000
398 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR */
399 #define PI_MALFORMED 0x07000000
400 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR */
401 #define PI_DEBUG 0x08000000
402 /** The protocol field violates a protocol specification, usually PI_WARN */
403 #define PI_PROTOCOL 0x09000000
404 /* The protocol field indicates a security probem (e.g. unsecure implementation) */
405 #define PI_SECURITY 0x0a000000
407 /* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
410 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
411 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
412 #define PROTO_ITEM_IS_HIDDEN(proto_item) \
413 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
414 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
415 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
416 #define PROTO_ITEM_SET_HIDDEN(proto_item) \
419 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
421 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
422 #define PROTO_ITEM_IS_GENERATED(proto_item) \
423 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
424 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
425 #define PROTO_ITEM_SET_GENERATED(proto_item) \
428 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
430 /** is this protocol field actually a URL? */
431 #define PROTO_ITEM_IS_URL(proto_item) \
432 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
433 /** mark this protocol field as a URL */
434 #define PROTO_ITEM_SET_URL(proto_item) \
437 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
440 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
441 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);
443 extern gboolean proto_tree_traverse_post_order(proto_tree *tree,
444 proto_tree_traverse_func func, gpointer data);
446 extern void proto_tree_children_foreach(proto_tree *tree,
447 proto_tree_foreach_func func, gpointer data);
449 /** Retrieve the field_info from a proto_node */
450 #define PNODE_FINFO(proto_node) ((proto_node)->finfo)
452 /** Retrieve the field_info from a proto_item */
453 #define PITEM_FINFO(proto_item) PNODE_FINFO(proto_item)
455 /** Retrieve the field_info from a proto_tree */
456 #define PTREE_FINFO(proto_tree) PNODE_FINFO(proto_tree)
458 /** Retrieve the tree_data_t from a proto_tree */
459 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
461 /** Sets up memory used by proto routines. Called at program startup */
462 extern void proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_data),
463 void (register_all_handoffs_func)(register_cb cb, gpointer client_data),
464 register_cb cb, void *client_data);
467 /** Frees memory used by proto routines. Called at program shutdown */
468 extern void proto_cleanup(void);
470 /** This function takes a tree and a protocol id as parameter and
471 will return TRUE/FALSE for whether the protocol or any of the filterable
472 fields in the protocol is referenced by any fitlers.
473 If this function returns FALSE then it is safe to skip any
474 proto_tree_add_...() calls and just treat the call as if the
475 dissector was called with tree==NULL.
476 If you reset the tree to NULL by this dissector returning FALSE,
477 you will still need to call any subdissector with the original value of
478 tree or filtering will break.
480 The purpose of this is to optimize wireshark for speed and make it
481 faster for when filters are being used.
483 extern gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
487 /** Create a subtree under an existing item.
488 @param ti the parent item of the new subtree
489 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
490 @return the new subtree */
491 extern proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx);
493 /** Get an existing subtree under an item.
494 @param ti the parent item of the subtree
495 @return the subtree or NULL */
496 extern proto_tree* proto_item_get_subtree(const proto_item *ti);
498 /** Get the parent of a subtree item.
499 @param ti the child item in the subtree
500 @return parent item or NULL */
501 extern proto_item* proto_item_get_parent(const proto_item *ti);
503 /** Get Nth generation parent item.
504 @param ti the child item in the subtree
505 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
506 @return parent item */
507 extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
509 /** Replace text of item after it already has been created.
510 @param ti the item to set the text
511 @param format printf like format string
512 @param ... printf like parameters */
513 extern void proto_item_set_text(proto_item *ti, const char *format, ...)
516 /** Append to text of item after it has already been created.
517 @param ti the item to append the text to
518 @param format printf like format string
519 @param ... printf like parameters */
520 extern void proto_item_append_text(proto_item *ti, const char *format, ...)
523 /** Prepend to text of item after it has already been created.
524 @param ti the item to prepend the text to
525 @param format printf like format string
526 @param ... printf like parameters */
527 extern void proto_item_prepend_text(proto_item *ti, const char *format, ...)
530 /** Set proto_item's length inside tvb, after it has already been created.
531 @param ti the item to set the length
532 @param length the new length ot the item */
533 extern void proto_item_set_len(proto_item *ti, const gint length);
536 * Sets the length of the item based on its start and on the specified
537 * offset, which is the offset past the end of the item; as the start
538 * in the item is relative to the beginning of the data source tvbuff,
539 * we need to pass in a tvbuff.
540 @param ti the item to set the length
541 @param tvb end is relative to this tvbuff
542 @param end this end offset is relative to the beginning of tvb
543 @todo make usage clearer, I don't understand it!
545 extern void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
547 /** Get length of a proto_item. Useful after using proto_tree_add_item()
548 * to add a variable-length field (e.g., FT_NSTRING_UINT8).
549 @param ti the item to get the length from
550 @return the current length */
551 extern int proto_item_get_len(const proto_item *ti);
554 * Sets an expert info to the proto_item.
555 @param ti the item to set the expert info
556 @param group the group of this info (e.g. PI_CHECKSUM)
557 @param severity of this info (e.g. PI_ERROR)
558 @return TRUE if value was written
560 extern gboolean proto_item_set_expert_flags(proto_item *ti, const int group, const guint severity);
565 /** Creates a new proto_tree root.
566 @return the new tree root */
567 extern proto_tree* proto_tree_create_root(void);
569 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
570 @param tree the tree to free */
571 extern void proto_tree_free(proto_tree *tree);
573 /** Set the tree visible or invisible.
574 Is the parsing being done for a visible proto_tree or an invisible one?
575 By setting this correctly, the proto_tree creation is sped up by not
576 having to call g_vsnprintf and copy strings around.
577 @param tree the tree to be set
578 @param visible ... or not
579 @return the old value */
581 proto_tree_set_visible(proto_tree *tree, gboolean visible);
583 /** Indicate whether we should fake protocols during dissection (default = TRUE)
584 @param tree the tree to be set
585 @param fake_protocols TRUE if we should fake protocols */
587 proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
589 /** Mark a field/protocol ID as "interesting".
590 @param tree the tree to be set
591 @param hfid the interesting field id
592 @todo what *does* interesting mean? */
594 proto_tree_prime_hfid(proto_tree *tree, const int hfid);
596 /** Get a parent item of a subtree.
597 @param tree the tree to get the parent from
598 @return parent item */
599 extern proto_item* proto_tree_get_parent(const proto_tree *tree);
601 /** Get the root tree from any subtree.
602 @param tree the tree to get the root from
604 extern proto_tree* proto_tree_get_root(proto_tree *tree);
606 /** Move an existing item behind another existing item.
607 @param tree the tree to which both items belong
608 @param fixed_item the item which keeps it's position
609 @param item_to_move the item which will be moved */
610 extern void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
613 /** Set start and length of an appendix for a proto_tree.
614 @param tree the tree to set the appendix start and length
615 @param tvb the tv buffer of the current data
616 @param start the start offset of the appendix
617 @param length the length of the appendix */
618 extern void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length);
621 /** Add an item to a proto_tree, using the text label registered to that item.
622 The item is extracted from the tvbuff handed to it.
623 @param tree the tree to append this item to
624 @param hfindex field index
625 @param tvb the tv buffer of the current data
626 @param start start of data in tvb
627 @param length length of data in tvb
628 @param encoding data encoding
629 @return the newly created item */
631 proto_tree_add_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
632 const gint start, gint length, const guint encoding);
634 /** Add a text-only node to a proto_tree.
635 @param tree the tree to append this item to
636 @param tvb the tv buffer of the current data
637 @param start start of data in tvb
638 @param length length of data in tvb
639 @param format printf like format string
640 @param ... printf like parameters
641 @return the newly created item */
643 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
644 ...) G_GNUC_PRINTF(5,6);
646 /** Add a text-only node to a proto_tree using a variable argument list.
647 @param tree the tree to append this item to
648 @param tvb the tv buffer of the current data
649 @param start start of data in tvb
650 @param length length of data in tvb
651 @param format printf like format string
652 @param ap variable argument list
653 @return the newly created item */
655 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
656 gint length, const char *format, va_list ap);
659 /** Add a FT_NONE field to a proto_tree.
660 @param tree the tree to append this item to
661 @param hfindex field index
662 @param tvb the tv buffer of the current data
663 @param start start of data in tvb
664 @param length length of data in tvb
665 @param format printf like format string
666 @param ... printf like parameters
667 @return the newly created item */
669 proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start,
670 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
672 /** Add a FT_PROTOCOL to a proto_tree.
673 @param tree the tree to append this item to
674 @param hfindex field index
675 @param tvb the tv buffer of the current data
676 @param start start of data in tvb
677 @param length length of data in tvb
678 @param format printf like format string
679 @param ... printf like parameters
680 @return the newly created item */
682 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
683 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
688 /** Add a FT_BYTES to a proto_tree.
689 @param tree the tree to append this item to
690 @param hfindex field index
691 @param tvb the tv buffer of the current data
692 @param start start of data in tvb
693 @param length length of data in tvb
694 @param start_ptr pointer to the data to display
695 @return the newly created item */
697 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
698 gint length, const guint8* start_ptr);
700 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
701 the string for the value and with the field name being included
703 @param tree the tree to append this item to
704 @param hfindex field index
705 @param tvb the tv buffer of the current data
706 @param start start of data in tvb
707 @param length length of data in tvb
708 @param start_ptr pointer to the data to display
709 @param format printf like format string
710 @param ... printf like parameters
711 @return the newly created item */
713 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
714 gint start, gint length, const guint8* start_ptr, const char *format,
715 ...) G_GNUC_PRINTF(7,8);
717 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
718 the entire string for the entry, including any field name.
719 @param tree the tree to append this item to
720 @param hfindex field index
721 @param tvb the tv buffer of the current data
722 @param start start of data in tvb
723 @param length length of data in tvb
724 @param start_ptr pointer to the data to display
725 @param format printf like format string
726 @param ... printf like parameters
727 @return the newly created item */
729 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
730 gint length, const guint8* start_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
732 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
733 @param tree the tree to append this item to
734 @param hfindex field index
735 @param tvb the tv buffer of the current data
736 @param start start of data in tvb
737 @param length length of data in tvb
738 @param value_ptr pointer to the data to display
739 @return the newly created item */
741 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
742 gint length, nstime_t* value_ptr);
744 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
745 the format generating the string for the value and with the field name
746 being included automatically.
747 @param tree the tree to append this item to
748 @param hfindex field index
749 @param tvb the tv buffer of the current data
750 @param start start of data in tvb
751 @param length length of data in tvb
752 @param value_ptr pointer to the data to display
753 @param format printf like format string
754 @param ... printf like parameters
755 @return the newly created item */
757 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
758 gint start, gint length, nstime_t* value_ptr, const char *format, ...)
761 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
762 the format generating the entire string for the entry, including any field
764 @param tree the tree to append this item to
765 @param hfindex field index
766 @param tvb the tv buffer of the current data
767 @param start start of data in tvb
768 @param length length of data in tvb
769 @param value_ptr pointer to the data to display
770 @param format printf like format string
771 @param ... printf like parameters
772 @return the newly created item */
774 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
775 gint length, nstime_t* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
777 /** Add a FT_IPXNET to a proto_tree.
778 @param tree the tree to append this item to
779 @param hfindex field index
780 @param tvb the tv buffer of the current data
781 @param start start of data in tvb
782 @param length length of data in tvb
783 @param value data to display
784 @return the newly created item */
786 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
787 gint length, guint32 value);
789 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
790 the string for the value and with the field name being included
792 @param tree the tree to append this item to
793 @param hfindex field index
794 @param tvb the tv buffer of the current data
795 @param start start of data in tvb
796 @param length length of data in tvb
797 @param value data to display
798 @param format printf like format string
799 @param ... printf like parameters
800 @return the newly created item */
802 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
803 gint start, gint length, guint32 value, const char *format, ...)
806 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
807 the entire string for the entry, including any field name.
808 @param tree the tree to append this item to
809 @param hfindex field index
810 @param tvb the tv buffer of the current data
811 @param start start of data in tvb
812 @param length length of data in tvb
813 @param value data to display
814 @param format printf like format string
815 @param ... printf like parameters
816 @return the newly created item */
818 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
819 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
821 /** Add a FT_IPv4 to a proto_tree.
822 @param tree the tree to append this item to
823 @param hfindex field index
824 @param tvb the tv buffer of the current data
825 @param start start of data in tvb
826 @param length length of data in tvb
827 @param value data to display
828 @return the newly created item */
830 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
831 gint length, guint32 value);
833 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
834 the string for the value and with the field name being included
836 @param tree the tree to append this item to
837 @param hfindex field index
838 @param tvb the tv buffer of the current data
839 @param start start of data in tvb
840 @param length length of data in tvb
841 @param value data to display
842 @param format printf like format string
843 @param ... printf like parameters
844 @return the newly created item */
846 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
847 gint start, gint length, guint32 value, const char *format, ...)
850 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
851 the entire string for the entry, including any field name.
852 @param tree the tree to append this item to
853 @param hfindex field index
854 @param tvb the tv buffer of the current data
855 @param start start of data in tvb
856 @param length length of data in tvb
857 @param value data to display
858 @param format printf like format string
859 @param ... printf like parameters
860 @return the newly created item */
862 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
863 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
865 /** Add a FT_IPv6 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 value_ptr data to display
872 @return the newly created item */
874 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
875 gint length, const guint8* value_ptr);
877 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
878 the string for the value and with the field name being included
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 value_ptr data to display
886 @param format printf like format string
887 @param ... printf like parameters
888 @return the newly created item */
890 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
891 gint start, gint length, const guint8* value_ptr, const char *format,
892 ...) G_GNUC_PRINTF(7,8);
894 /** Add a formatted FT_IPv6 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 value_ptr data to display
902 @param format printf like format string
903 @param ... printf like parameters
904 @return the newly created item */
906 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
907 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
909 /** Add a FT_ETHER 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 data to display
916 @return the newly created item */
918 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
919 gint length, const guint8* value);
921 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
922 the string for the value and with the field name being included
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 data to display
930 @param format printf like format string
931 @param ... printf like parameters
932 @return the newly created item */
934 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
935 gint start, gint length, const guint8* value, const char *format, ...)
938 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
939 the entire string for the entry, including any field name.
940 @param tree the tree to append this item to
941 @param hfindex field index
942 @param tvb the tv buffer of the current data
943 @param start start of data in tvb
944 @param length length of data in tvb
945 @param value data to display
946 @param format printf like format string
947 @param ... printf like parameters
948 @return the newly created item */
950 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
951 gint length, const guint8* value, const char *format, ...) G_GNUC_PRINTF(7,8);
953 /** Add a FT_GUID to a proto_tree.
954 @param tree the tree to append this item to
955 @param hfindex field index
956 @param tvb the tv buffer of the current data
957 @param start start of data in tvb
958 @param length length of data in tvb
959 @param value_ptr data to display
960 @return the newly created item */
962 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
963 gint length, const e_guid_t *value_ptr);
965 /** Add a formatted FT_GUID to a proto_tree, with the format generating
966 the string for the value and with the field name being included
968 @param tree the tree to append this item to
969 @param hfindex field index
970 @param tvb the tv buffer of the current data
971 @param start start of data in tvb
972 @param length length of data in tvb
973 @param value_ptr data to display
974 @param format printf like format string
975 @param ... printf like parameters
976 @return the newly created item */
978 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
979 gint start, gint length, const e_guid_t *value_ptr, const char *format,
980 ...) G_GNUC_PRINTF(7,8);
982 /** Add a formatted FT_GUID to a proto_tree, with the format generating
983 the entire string for the entry, including any field name.
984 @param tree the tree to append this item to
985 @param hfindex field index
986 @param tvb the tv buffer of the current data
987 @param start start of data in tvb
988 @param length length of data in tvb
989 @param value_ptr data to display
990 @param format printf like format string
991 @param ... printf like parameters
992 @return the newly created item */
994 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
995 gint length, const e_guid_t *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
997 /** Add a FT_OID to a proto_tree.
998 @param tree the tree to append this item to
999 @param hfindex field index
1000 @param tvb the tv buffer of the current data
1001 @param start start of data in tvb
1002 @param length length of data in tvb
1003 @param value_ptr data to display
1004 @return the newly created item */
1006 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1007 gint length, const guint8* value_ptr);
1009 /** Add a formatted FT_OID to a proto_tree, with the format generating
1010 the string for the value and with the field name being included
1012 @param tree the tree to append this item to
1013 @param hfindex field index
1014 @param tvb the tv buffer of the current data
1015 @param start start of data in tvb
1016 @param length length of data in tvb
1017 @param value_ptr data to display
1018 @param format printf like format string
1019 @param ... printf like parameters
1020 @return the newly created item */
1022 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1023 gint start, gint length, const guint8* value_ptr, const char *format,
1024 ...) G_GNUC_PRINTF(7,8);
1026 /** Add a formatted FT_OID to a proto_tree, with the format generating
1027 the entire string for the entry, including any field name.
1028 @param tree the tree to append this item to
1029 @param hfindex field index
1030 @param tvb the tv buffer of the current data
1031 @param start start of data in tvb
1032 @param length length of data in tvb
1033 @param value_ptr data to display
1034 @param format printf like format string
1035 @param ... printf like parameters
1036 @return the newly created item */
1038 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1039 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1041 /** Add a FT_STRING to a proto_tree.
1042 @param tree the tree to append this item to
1043 @param hfindex field index
1044 @param tvb the tv buffer of the current data
1045 @param start start of data in tvb
1046 @param length length of data in tvb
1047 @param value data to display
1048 @return the newly created item */
1050 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1051 gint length, const char* value);
1053 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1054 the string for the value and with the field name being included
1056 @param tree the tree to append this item to
1057 @param hfindex field index
1058 @param tvb the tv buffer of the current data
1059 @param start start of data in tvb
1060 @param length length of data in tvb
1061 @param value data to display
1062 @param format printf like format string
1063 @param ... printf like parameters
1064 @return the newly created item */
1066 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1067 gint start, gint length, const char* value, const char *format, ...)
1070 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1071 the entire string for the entry, including any field name.
1072 @param tree the tree to append this item to
1073 @param hfindex field index
1074 @param tvb the tv buffer of the current data
1075 @param start start of data in tvb
1076 @param length length of data in tvb
1077 @param value data to display
1078 @param format printf like format string
1079 @param ... printf like parameters
1080 @return the newly created item */
1082 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1083 gint length, const char* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1085 /** Add a FT_BOOLEAN to a proto_tree.
1086 @param tree the tree to append this item to
1087 @param hfindex field index
1088 @param tvb the tv buffer of the current data
1089 @param start start of data in tvb
1090 @param length length of data in tvb
1091 @param value data to display
1092 @return the newly created item */
1094 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1095 gint length, guint32 value);
1097 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1098 the string for the value and with the field name being included
1100 @param tree the tree to append this item to
1101 @param hfindex field index
1102 @param tvb the tv buffer of the current data
1103 @param start start of data in tvb
1104 @param length length of data in tvb
1105 @param value data to display
1106 @param format printf like format string
1107 @param ... printf like parameters
1108 @return the newly created item */
1110 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1111 tvbuff_t *tvb, gint start, gint length, guint32 value,
1112 const char *format, ...) G_GNUC_PRINTF(7,8);
1114 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1115 the entire string for the entry, including any field name.
1116 @param tree the tree to append this item to
1117 @param hfindex field index
1118 @param tvb the tv buffer of the current data
1119 @param start start of data in tvb
1120 @param length length of data in tvb
1121 @param value data to display
1122 @param format printf like format string
1123 @param ... printf like parameters
1124 @return the newly created item */
1126 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1127 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1129 /** Add a FT_FLOAT to a proto_tree.
1130 @param tree the tree to append this item to
1131 @param hfindex field index
1132 @param tvb the tv buffer of the current data
1133 @param start start of data in tvb
1134 @param length length of data in tvb
1135 @param value data to display
1136 @return the newly created item */
1138 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1139 gint length, float value);
1141 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1142 the string for the value and with the field name being included
1144 @param tree the tree to append this item to
1145 @param hfindex field index
1146 @param tvb the tv buffer of the current data
1147 @param start start of data in tvb
1148 @param length length of data in tvb
1149 @param value data to display
1150 @param format printf like format string
1151 @param ... printf like parameters
1152 @return the newly created item */
1154 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1155 gint start, gint length, float value, const char *format, ...)
1158 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1159 the entire string for the entry, including any field name.
1160 @param tree the tree to append this item to
1161 @param hfindex field index
1162 @param tvb the tv buffer of the current data
1163 @param start start of data in tvb
1164 @param length length of data in tvb
1165 @param value data to display
1166 @param format printf like format string
1167 @param ... printf like parameters
1168 @return the newly created item */
1170 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1171 gint length, float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1173 /** Add a FT_DOUBLE to a proto_tree.
1174 @param tree the tree to append this item to
1175 @param hfindex field index
1176 @param tvb the tv buffer of the current data
1177 @param start start of data in tvb
1178 @param length length of data in tvb
1179 @param value data to display
1180 @return the newly created item */
1182 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1183 gint length, double value);
1185 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1186 the string for the value and with the field name being included
1188 @param tree the tree to append this item to
1189 @param hfindex field index
1190 @param tvb the tv buffer of the current data
1191 @param start start of data in tvb
1192 @param length length of data in tvb
1193 @param value data to display
1194 @param format printf like format string
1195 @param ... printf like parameters
1196 @return the newly created item */
1198 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1199 gint start, gint length, double value, const char *format, ...)
1202 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1203 the entire string for the entry, including any field name.
1204 @param tree the tree to append this item to
1205 @param hfindex field index
1206 @param tvb the tv buffer of the current data
1207 @param start start of data in tvb
1208 @param length length of data in tvb
1209 @param value data to display
1210 @param format printf like format string
1211 @param ... printf like parameters
1212 @return the newly created item */
1214 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1215 gint length, double value, const char *format, ...) G_GNUC_PRINTF(7,8);
1217 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1218 @param tree the tree to append this item to
1219 @param hfindex field index
1220 @param tvb the tv buffer of the current data
1221 @param start start of data in tvb
1222 @param length length of data in tvb
1223 @param value data to display
1224 @return the newly created item */
1226 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1227 gint length, guint32 value);
1229 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1230 with the format generating the string for the value and with the field
1231 name being included automatically.
1232 @param tree the tree to append this item to
1233 @param hfindex field index
1234 @param tvb the tv buffer of the current data
1235 @param start start of data in tvb
1236 @param length length of data in tvb
1237 @param value data to display
1238 @param format printf like format string
1239 @param ... printf like parameters
1240 @return the newly created item */
1242 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1243 gint start, gint length, guint32 value, const char *format, ...)
1246 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1247 with the format generating the entire string for the entry, including any
1249 @param tree the tree to append this item to
1250 @param hfindex field index
1251 @param tvb the tv buffer of the current data
1252 @param start start of data in tvb
1253 @param length length of data in tvb
1254 @param value data to display
1255 @param format printf like format string
1256 @param ... printf like parameters
1257 @return the newly created item */
1259 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1260 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1262 /** Add an FT_UINT64 to a proto_tree.
1263 @param tree the tree to append this item to
1264 @param hfindex field index
1265 @param tvb the tv buffer of the current data
1266 @param start start of data in tvb
1267 @param length length of data in tvb
1268 @param value data to display
1269 @return the newly created item */
1271 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1272 gint length, guint64 value);
1274 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1275 the string for the value and with the field name being included
1277 @param tree the tree to append this item to
1278 @param hfindex field index
1279 @param tvb the tv buffer of the current data
1280 @param start start of data in tvb
1281 @param length length of data in tvb
1282 @param value data to display
1283 @param format printf like format string
1284 @param ... printf like parameters
1285 @return the newly created item */
1287 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1288 gint start, gint length, guint64 value, const char *format, ...)
1291 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1292 the entire string for the entry, including any field name.
1293 @param tree the tree to append this item to
1294 @param hfindex field index
1295 @param tvb the tv buffer of the current data
1296 @param start start of data in tvb
1297 @param length length of data in tvb
1298 @param value data to display
1299 @param format printf like format string
1300 @param ... printf like parameters
1301 @return the newly created item */
1303 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1304 gint length, guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1306 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1307 @param tree the tree to append this item to
1308 @param hfindex field index
1309 @param tvb the tv buffer of the current data
1310 @param start start of data in tvb
1311 @param length length of data in tvb
1312 @param value data to display
1313 @return the newly created item */
1315 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1316 gint length, gint32 value);
1318 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1319 with the format generating the string for the value and with the field
1320 name being included automatically.
1321 @param tree the tree to append this item to
1322 @param hfindex field index
1323 @param tvb the tv buffer of the current data
1324 @param start start of data in tvb
1325 @param length length of data in tvb
1326 @param value data to display
1327 @param format printf like format string
1328 @param ... printf like parameters
1329 @return the newly created item */
1331 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1332 gint start, gint length, gint32 value, const char *format, ...)
1335 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1336 with the format generating the entire string for the entry, including
1338 @param tree the tree to append this item to
1339 @param hfindex field index
1340 @param tvb the tv buffer of the current data
1341 @param start start of data in tvb
1342 @param length length of data in tvb
1343 @param value data to display
1344 @param format printf like format string
1345 @param ... printf like parameters
1346 @return the newly created item */
1348 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1349 gint length, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1351 /** Add an FT_INT64 to a proto_tree.
1352 @param tree the tree to append this item to
1353 @param hfindex field index
1354 @param tvb the tv buffer of the current data
1355 @param start start of data in tvb
1356 @param length length of data in tvb
1357 @param value data to display
1358 @return the newly created item */
1360 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1361 gint length, gint64 value);
1363 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1364 the string for the value and with the field name being included
1366 @param tree the tree to append this item to
1367 @param hfindex field index
1368 @param tvb the tv buffer of the current data
1369 @param start start of data in tvb
1370 @param length length of data in tvb
1371 @param value data to display
1372 @param format printf like format string
1373 @param ... printf like parameters
1374 @return the newly created item */
1376 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1377 gint start, gint length, gint64 value, const char *format, ...)
1380 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1381 the entire string for the entry, including any field name.
1382 @param tree the tree to append this item to
1383 @param hfindex field index
1384 @param tvb the tv buffer of the current data
1385 @param start start of data in tvb
1386 @param length length of data in tvb
1387 @param value data to display
1388 @param format printf like format string
1389 @param ... printf like parameters
1390 @return the newly created item */
1392 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1393 gint length, gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1395 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1396 leave call to this function in production code.
1397 @param tree the tree to append the text to
1398 @param format printf like format string
1399 @param ... printf like parameters
1400 @return the newly created item */
1402 proto_tree_add_debug_text(proto_tree *tree, const char *format,
1403 ...) G_GNUC_PRINTF(2,3);
1407 /** Append a string to a protocol item.<br>
1408 NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1410 Currently only WSP use this function so it is not that bad but try to
1411 avoid using this one if possible.
1412 IF you must use this function you MUST also disable the
1413 TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1414 using proto_item_append_string().
1415 Do that by faking that the tree is visible by calling
1416 proto_tree_set_visible(tree, TRUE) (see packet-wsp.c)
1417 BEFORE you create the item you are later going to use
1418 proto_item_append_string() on.
1419 @param pi the item to append the string to
1420 @param str the string to append */
1422 proto_item_append_string(proto_item *pi, const char *str);
1426 /** Fill given label_str with string representation of field
1427 @param fi the item to get the info from
1428 @param label_str the string to fill
1429 @todo think about changing the parameter profile */
1431 proto_item_fill_label(field_info *fi, gchar *label_str);
1434 /** Register a new protocol.
1435 @param name the full name of the new protocol
1436 @param short_name abbreviated name of the new protocol
1437 @param filter_name protocol name used for a display filter string
1438 @return the new protocol handle */
1440 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
1442 /** Mark protocol as private
1443 @param proto_id the handle of the protocol */
1445 proto_mark_private(const int proto_id);
1447 /** Return if protocol is private
1448 @param proto_id the handle of the protocol
1449 @return TRUE if it is a private protocol, FALSE is not. */
1451 proto_is_private(const int proto_id);
1453 /** This is the type of function can be registered to get called whenever
1454 a given field was not found but a its prefix is matched
1455 it can be used to procrastinate the hf array registration
1456 @param match what's being matched */
1457 typedef void (*prefix_initializer_t)(const char* match);
1459 /** Register a new prefix for delayed initialization of field arrays
1460 @param prefix the prefix for the new protocol
1461 @param initializer function that will initialize the field array for the given prefix */
1463 proto_register_prefix(const char *prefix, prefix_initializer_t initializer);
1465 /** Initialize every remaining uninitialized prefix. */
1466 extern void proto_initialize_all_prefixes(void);
1468 /** Register a header_field array.
1469 @param parent the protocol handle from proto_register_protocol()
1470 @param hf the hf_register_info array
1471 @param num_records the number of records in hf */
1473 proto_register_field_array(const int parent, hf_register_info *hf, const int num_records);
1475 /** Register a protocol subtree (ett) array.
1476 @param indices array of ett indices
1477 @param num_indices the number of records in indices */
1479 proto_register_subtree_array(gint *const *indices, const int num_indices);
1481 /** Returns number of items (protocols or header fields) registered.
1482 @return the number of items */
1483 extern int proto_registrar_n(void);
1485 /** Get name of registered header_field number n.
1486 @param n item # n (0-indexed)
1487 @return the name of this registered item */
1488 extern const char* proto_registrar_get_name(const int n);
1490 /** Get abbreviation of registered header_field number n.
1491 @param n item # n (0-indexed)
1492 @return the abbreviation of this registered item */
1493 extern const char* proto_registrar_get_abbrev(const int n);
1495 /** Get the header_field information based upon a field or protocol id.
1496 @param hfindex item # n (0-indexed)
1497 @return the registered item */
1498 extern header_field_info* proto_registrar_get_nth(guint hfindex);
1500 /** Get the header_field information based upon a field name.
1501 @param field_name the field name to search for
1502 @return the registered item */
1503 extern header_field_info* proto_registrar_get_byname(const char *field_name);
1505 /** Get enum ftenum FT_ of registered header_field number n.
1506 @param n item # n (0-indexed)
1507 @return the registered item */
1508 extern int proto_registrar_get_ftype(const int n);
1510 /** Get parent protocol of registered header_field number n.
1511 @param n item # n (0-indexed)
1512 @return -1 if item _is_ a protocol */
1513 extern int proto_registrar_get_parent(const int n);
1515 /** Is item # n a protocol?
1516 @param n item # n (0-indexed)
1517 @return TRUE if it's a protocol, FALSE if it's not */
1518 extern gboolean proto_registrar_is_protocol(const int n);
1520 /** Get length of registered field according to field type.
1521 @param n item # n (0-indexed)
1522 @return 0 means undeterminable at registration time, -1 means unknown field */
1523 extern gint proto_registrar_get_length(const int n);
1526 /** Routines to use to iterate over the protocols and their fields;
1527 * they return the item number of the protocol in question or the
1528 * appropriate hfinfo pointer, and keep state in "*cookie". */
1529 extern int proto_get_first_protocol(void **cookie);
1530 extern int proto_get_next_protocol(void **cookie);
1531 extern header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookle);
1532 extern header_field_info *proto_get_next_protocol_field(void **cookle);
1534 /** Given a protocol's filter_name.
1535 @param filter_name the filter name to search for
1537 extern int proto_get_id_by_filter_name(const gchar* filter_name);
1539 /** Can item # n decoding be disabled?
1540 @param proto_id protocol id (0-indexed)
1541 @return TRUE if it's a protocol, FALSE if it's not */
1542 extern gboolean proto_can_toggle_protocol(const int proto_id);
1544 /** Get the "protocol_t" structure for the given protocol's item number.
1545 @param proto_id protocol id (0-indexed) */
1546 extern protocol_t *find_protocol_by_id(const int proto_id);
1548 /** Get the protocol's name for the given protocol's item number.
1549 @param proto_id protocol id (0-indexed)
1551 extern const char *proto_get_protocol_name(const int proto_id);
1553 /** Get the protocol's item number, for the given protocol's "protocol_t".
1554 @return its proto_id */
1555 extern int proto_get_id(const protocol_t *protocol);
1557 /** Get the protocol's short name, for the given protocol's "protocol_t".
1558 @return its short name. */
1559 extern const char *proto_get_protocol_short_name(const protocol_t *protocol);
1561 /** Get the protocol's long name, for the given protocol's "protocol_t".
1562 @return its long name. */
1563 extern const char *proto_get_protocol_long_name(const protocol_t *protocol);
1565 /** Is protocol's decoding enabled ?
1567 @return TRUE if decoding is enabled, FALSE if not */
1568 extern gboolean proto_is_protocol_enabled(const protocol_t *protocol);
1570 /** Get a protocol's filter name by it's item number.
1571 @param proto_id protocol id (0-indexed)
1572 @return its filter name. */
1573 extern const char *proto_get_protocol_filter_name(const int proto_id);
1575 /** Enable / Disable protocol of the given item number.
1576 @param proto_id protocol id (0-indexed)
1577 @param enabled enable / disable the protocol */
1578 extern void proto_set_decoding(const int proto_id, const gboolean enabled);
1580 /** Enable all protocols */
1581 extern void proto_enable_all(void);
1583 /** Disable disabling/enabling of protocol of the given item number.
1584 @param proto_id protocol id (0-indexed) */
1585 extern void proto_set_cant_toggle(const int proto_id);
1587 /** Checks for existence any protocol or field within a tree.
1588 @param tree "Protocols" are assumed to be a child of the [empty] root node.
1589 @param id hfindex of protocol or field
1590 @return TRUE = found, FALSE = not found
1591 @todo add explanation of id parameter */
1592 extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id);
1594 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1595 tree. Only works with primed trees, and is fast.
1596 @param tree tree of interest
1597 @param hfindex primed hfindex
1598 @return GPtrArry pointer */
1599 extern GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
1601 /** Return whether we're tracking any interesting fields.
1602 Only works with primed trees, and is fast.
1603 @param tree tree of interest
1604 @return TRUE if we're tracking interesting fields */
1605 extern gboolean proto_tracking_interesting_fields(const proto_tree *tree);
1607 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1608 tree. Works with any tree, primed or unprimed, and is slower than
1609 proto_get_finfo_ptr_array because it has to search through the tree.
1610 @param tree tree of interest
1611 @param hfindex index of field info of interest
1612 @return GPtrArry pointer */
1613 extern GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex);
1615 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
1617 @param tree tree of interest
1618 @return GPtrArry pointer */
1619 extern GPtrArray* proto_all_finfos(proto_tree *tree);
1621 /** Dumps a glossary of the protocol registrations to STDOUT */
1622 extern void proto_registrar_dump_protocols(void);
1624 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
1625 extern void proto_registrar_dump_values(void);
1627 /** Dumps a glossary of the protocol and field registrations to STDOUT.
1628 * Format 1 is the original format. Format 2 includes the base (for integers)
1630 extern void proto_registrar_dump_fields(const int format);
1634 /** Points to the first element of an array of Booleans, indexed by
1635 a subtree item type. That array element is TRUE if subtrees of
1636 an item of that type are to be expanded. With MSVC and a
1637 libwireshark.dll, we need a special declaration. */
1638 WS_VAR_IMPORT gboolean *tree_is_expanded;
1640 /** Number of elements in the tree_is_expanded array. With MSVC and a
1641 * libwireshark.dll, we need a special declaration. */
1642 WS_VAR_IMPORT int num_tree_types;
1644 /** glib doesn't have g_ptr_array_len of all things!*/
1645 #ifndef g_ptr_array_len
1646 #define g_ptr_array_len(a) ((a)?(a)->len:0)
1649 /** Get number of bits of a header_field.
1650 @param hfinfo header_field
1651 @return the bitwidth */
1653 hfinfo_bitwidth(const header_field_info *hfinfo);
1660 /** Can we do a "match selected" on this field.
1661 @param finfo field_info
1662 @param edt epan dissecting
1663 @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
1665 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
1667 /** Construct a "match selected" display filter string.
1668 @param finfo field_info
1669 @param edt epan dissecting
1670 @return the display filter string */
1672 proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt);
1674 /** Find field from offset in tvb.
1675 @param tree tree of interest
1676 @param offset offset in the tvb
1677 @param tvb the tv buffer
1678 @return the corresponding field_info */
1680 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
1682 /** This function will dissect a sequence of bytes that describe a bitmask.
1683 @param tree the tree to append this item to
1684 @param tvb the tv buffer of the current data
1685 @param offset start of data in tvb
1686 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
1687 This field will form an expansion under which the individual fields of the
1688 bitmask is dissected and displayed.
1689 This field must be of the type FT_[U]INT{8|16|24|32}.
1690 @param ett subtree index
1691 @param fields an array of pointers to int that lists all the fields of the
1692 bitmask. These fields can be either of the type FT_BOOLEAN for flags
1693 or another integer of the same type/size as hf_hdr with a mask specified.
1694 This array is terminated by a NULL entry.
1695 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
1696 FT_integer fields that have a value_string attached will have the
1697 matched string displayed on the expansion line.
1698 @param little_endian big or little endian byte representation
1699 @return the newly created item */
1701 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
1702 const int hf_hdr, const gint ett, const int **fields, const gboolean little_endian);
1704 /** Add a text with a subtree of bitfields.
1705 @param tree the tree to append this item to
1706 @param tvb the tv buffer of the current data
1707 @param offset start of data in tvb
1708 @param len length of the field name
1709 @param name field name (NULL if bitfield contents should be used)
1710 @param fallback field name if none of bitfields were usable
1711 @param ett subtree index
1712 @param fields NULL-terminated array of bitfield indexes
1713 @param little_endian big or little endian byte representation
1714 @param little_endian big or little endian byte representation
1716 @return the newly created item */
1718 proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
1719 const char *name, const char *fallback,
1720 const gint ett, const int **fields, const gboolean little_endian, const int flags);
1722 #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */
1723 #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */
1724 #define BMT_NO_FALSE 0x04 /**< Don't add booleans unless they're TRUE */
1725 #define BMT_NO_TFS 0x08 /**< Don't use true_false_string while formatting booleans */
1727 /** Add bits to a proto_tree, using the text label registered to that item.
1728 The item is extracted from the tvbuff handed to it.
1729 @param tree the tree to append this item to
1730 @param hf_index field index. Fields for use with this function should have bitmask==0.
1731 @param tvb the tv buffer of the current data
1732 @param bit_offset start of data in tvb expressed in bits
1733 @param no_of_bits length of data in tvb expressed in bits
1734 @param little_endian big or little endian byte representation
1735 @return the newly created item */
1737 proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian);
1739 /** Add bits to a proto_tree, using the text label registered to that item.
1740 The item is extracted from the tvbuff handed to it.
1741 @param tree the tree to append this item to
1742 @param hf_index field index. Fields for use with this function should have bitmask==0.
1743 @param tvb the tv buffer of the current data
1744 @param bit_offset start of data in tvb expressed in bits
1745 @param no_of_bits length of data in tvb expressed in bits
1746 @param return_value if a pointer is passed here the value is returned.
1747 @param little_endian big or little endian byte representation
1748 @return the newly created item */
1750 proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint64 *return_value, const gboolean little_endian);
1752 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
1753 header field to a proto_tree, with the format generating the
1754 string for the value and with the field name being included automatically.
1755 @param tree the tree to append this item to
1756 @param hf_index field index
1757 @param tvb the tv buffer of the current data
1758 @param bit_offset start of data in tvb expressed in bits
1759 @param no_of_bits length of data in tvb expressed in bit
1760 @param value data to display
1761 @param format printf like format string
1762 @return the newly created item */
1764 proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits,
1765 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1767 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with
1768 the format generating the string for the value and with the field
1769 name being included automatically.
1770 @param tree the tree to append this item to
1771 @param hf_index field index
1772 @param tvb the tv buffer of the current data
1773 @param bit_offset start of data in tvb expressed in bits
1774 @param no_of_bits length of data in tvb expressed in bit
1775 @param value data to display
1776 @param format printf like format string
1777 @param ... printf like parameters
1778 @return the newly created item */
1780 proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits,
1781 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1783 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
1784 header field to a proto_tree, with the format generating the
1785 string for the value and with the field name being included automatically.
1786 @param tree the tree to append this item to
1787 @param hf_index field index
1788 @param tvb the tv buffer of the current data
1789 @param bit_offset start of data in tvb expressed in bits
1790 @param no_of_bits length of data in tvb expressed in bit
1791 @param value data to display
1792 @param format printf like format string
1793 @param ... printf like parameters
1794 @return the newly created item */
1796 proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits,
1797 gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1799 /** Add bits for a FT_FLOAT header field to a proto_tree, with
1800 the format generating the string for the value and with the field
1801 name being included automatically.
1802 @param tree the tree to append this item to
1803 @param hf_index field index
1804 @param tvb the tv buffer of the current data
1805 @param bit_offset start of data in tvb expressed in bits
1806 @param no_of_bits length of data in tvb expressed in bit
1807 @param value data to display
1808 @param format printf like format string
1809 @param ... printf like parameters
1810 @return the newly created item */
1812 proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits,
1813 float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1815 /** Check if given string is a valid field name
1816 @param field_name the field name to check
1817 @return 0 if valid, else first illegal character */
1819 proto_check_field_name(const gchar *field_name);
1822 /** Check if given string is a valid field name
1823 @param tree the tree to append this item to
1824 @param field_id the field id used for custom column
1825 @param occurrence the occurrence of the field used for custom column
1826 @param result the buffer to fill with the field string
1827 @param expr the filter expression
1828 @param size the size of the string buffer */
1830 proto_custom_set(proto_tree* tree, const int field_id,
1833 gchar *expr, const int size );
1837 #endif /* __cplusplus */
1839 #endif /* proto.h */