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 to provide a hint to static analysis tools.
112 * (Currently only Visual C++.)
115 /* XXX - Is there a way to say "quit checking at this point"? */
116 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression) \
117 ; __analysis_assume(expression);
119 #define __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
122 /** Macro used for assertions in dissectors; it doesn't abort, it just
123 * throws a DissectorError exception, with the assertion failure
124 * message as a parameter, so that it can show up in the protocol tree.
126 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
127 * conditions that shouldn't happen). It should NOT be used for showing
128 * that a packet is malformed. For that, use expert_infos instead.
130 * @param expression expression to test in the assertion
133 #define DISSECTOR_ASSERT(expression) \
134 ((void) ((expression) ? (void)0 : \
135 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__))) \
136 __DISSECTOR_ASSERT_STATIC_ANALYSIS_HINT(expression)
139 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
140 * as the assert handling of GTK/GLib is currently not very helpful */
141 #define DISSECTOR_ASSERT(expression) \
142 { if(!(expression)) _asm { int 3}; }
145 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
146 * unconditionally, much like GLIB's g_assert_not_reached works.
148 * NOTE: this should only be used to detect bugs in the dissector (e.g., logic
149 * conditions that shouldn't happen). It should NOT be used for showing
150 * that a packet is malformed. For that, use expert_infos instead.
153 #define DISSECTOR_ASSERT_NOT_REACHED() \
154 (REPORT_DISSECTOR_BUG( \
155 ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
156 __FILE__, __LINE__)))
158 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
160 #define __DISSECTOR_ASSERT(expression, file, lineno) \
161 (REPORT_DISSECTOR_BUG( \
162 ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
163 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
166 * The encoding of a field of a particular type may involve more
167 * than just whether it's big-endian or little-endian and its size.
169 * For integral values, that's it, as 99.9999999999999% of the machines
170 * out there are 2's complement binary machines with 8-bit bytes,
171 * so the protocols out there expect that and, for example, any Unisys
172 * 2200 series machines out there just have to translate between 2's
173 * complement and 1's complement (and nobody's put any IBM 709x's on
174 * any networks lately :-)).
178 * for floating-point numbers, in addition to IEEE decimal
179 * floating-point, there's also IBM System/3x0 and PDP-11/VAX
180 * floating-point - most protocols use IEEE binary, but DCE RPC
181 * can use other formats if that's what the sending host uses;
183 * for character strings, there are various character encodings
184 * (various ISO 646 sets, ISO 8859/x, various other national
185 * standards, various DOS and Windows encodings, various Mac
186 * encodings, UTF-8, UTF-16, other extensions to ASCII, EBCDIC,
189 * for absolute times, there's UNIX time_t, UNIX time_t followed
190 * by 32-bit microseconds, UNIX time_t followed by 32-bit
191 * nanoseconds, DOS date/time, Windows FILETIME, NTP time, etc..
193 * We might also, in the future, want to allow a field specifier to
194 * indicate the encoding of the field, or at least its default
195 * encoding, as most fields in most protocols always use the
196 * same encoding (although that's not true of all fields, so we
197 * still need to be able to specify that at run time).
199 * So, for now, we define ENC_BIG_ENDIAN and ENC_LITTLE_ENDIAN as
200 * bit flags, to be combined, in the future, with other information
201 * to specify the encoding in the last argument to
202 * proto_tree_add_item(), and possibly to specify in a field
203 * definition (e.g., ORed in with the type value).
205 * Currently, proto_tree_add_item() treats its last argument as a
206 * Boolean - if it's zero, the field is big-endian, and if it's non-zero,
207 * the field is little-endian - and other code in epan/proto.c does
208 * the same. We therefore define ENC_BIG_ENDIAN as 0x00000000 and
209 * ENC_LITTLE_ENDIAN as 0x80000000 - we're using the high-order bit
210 * so that we could put a field type and/or a value such as a character
211 * encoding in the lower bits.
213 * For protocols (FT_PROTOCOL), aggregate items with subtrees (FT_NONE),
214 * opaque byte-array fields (FT_BYTES), and other fields where there
215 * is no choice of encoding (either because it's "just a bucket
216 * of bytes" or because the encoding is completely fixed), we
217 * have ENC_NA (for "Not Applicable").
219 #define ENC_BIG_ENDIAN 0x00000000
220 #define ENC_LITTLE_ENDIAN 0x80000000
223 * Historically FT_TIMEs were only timespecs; the only question was whether
224 * they were stored in big- or little-endian format.
226 * For backwards compatibility, we interpret an encoding of 1 as meaning
227 * "little-endian timespec", so that passing TRUE is interpreted as that.
229 #define ENC_TIME_TIMESPEC 0
230 #define ENC_TIME_NTP 2
232 #define ENC_NA 0x00000000
234 /* Values for header_field_info.display */
236 /* For integral types, the display format is a base_display_e value
237 * possibly ORed with BASE_RANGE_STRING. */
239 /** BASE_DISPLAY_E_MASK selects the base_display_e value. Its current
240 * value means that we may have at most 16 base_display_e values. */
241 #define BASE_DISPLAY_E_MASK 0x0F
244 BASE_NONE, /**< none */
245 BASE_DEC, /**< decimal */
246 BASE_HEX, /**< hexadecimal */
247 BASE_OCT, /**< octal */
248 BASE_DEC_HEX, /**< decimal (hexadecimal) */
249 BASE_HEX_DEC, /**< hexadecimal (decimal) */
250 BASE_CUSTOM /**< call custom routine (in ->strings) to format */
253 /* Following constants have to be ORed with a base_display_e when dissector
254 * want to use specials MACROs (for the moment, only RVALS) for a
255 * header_field_info */
256 #define BASE_RANGE_STRING 0x10
257 #define BASE_EXT_STRING 0x20
259 /** BASE_ values that cause the field value to be displayed twice */
260 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
262 /* For FT_ABSOLUTE_TIME, the display format is an absolute_time_display_e
263 * as per time_fmt.h. */
266 HF_REF_TYPE_NONE, /**< Field is not referenced */
267 HF_REF_TYPE_INDIRECT, /**< Field is indirectly referenced (only applicable for FT_PROTOCOL) via. its child */
268 HF_REF_TYPE_DIRECT /**< Field is directly referenced */
271 /** information describing a header field */
272 typedef struct _header_field_info header_field_info;
274 /** information describing a header field */
275 struct _header_field_info {
276 /* ---------- set by dissector --------- */
277 const char *name; /**< full name of this field */
278 const char *abbrev; /**< abbreviated name of this field */
279 enum ftenum type; /**< field type, one of FT_ (from ftypes.h) */
280 int display; /**< one of BASE_, or field bit-width if FT_BOOLEAN and non-zero bitmask */
281 const void *strings; /**< value_string, range_string or true_false_string,
282 typically converted by VALS(), RVALS() or TFS().
283 If this is an FT_PROTOCOL then it points to the
284 associated protocol_t structure */
285 guint32 bitmask; /**< bitmask of interesting bits */
286 const char *blurb; /**< Brief description of field */
288 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
289 int id; /**< Field ID */
290 int parent; /**< parent protocol tree */
291 hf_ref_type ref_type; /**< is this field referenced by a filter */
292 int bitshift; /**< bits to shift */
293 header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev */
294 header_field_info *same_name_prev; /**< Link to previous hfinfo with same abbrev */
298 * HFILL initializes all the "set by proto routines" fields in a
299 * _header_field_info. If new fields are added or removed, it should
300 * be changed as necessary.
302 #define HFILL 0, 0, HF_REF_TYPE_NONE, 0, NULL, NULL
304 /** Used when registering many fields at once, using proto_register_field_array() */
305 typedef struct hf_register_info {
306 int *p_id; /**< written to by register() function */
307 header_field_info hfinfo; /**< the field info to be registered */
313 /** string representation, if one of the proto_tree_add_..._format() functions used */
314 typedef struct _item_label_t {
315 char representation[ITEM_LABEL_LENGTH];
319 /** Contains the field information for the proto_item. */
320 typedef struct field_info {
321 header_field_info *hfinfo; /**< pointer to registered field information */
322 gint start; /**< current start of data in field_info.ds_tvb */
323 gint length; /**< current data length of item in field_info.ds_tvb */
324 gint appendix_start; /**< start of appendix data */
325 gint appendix_length; /**< length of appendix data */
326 gint tree_type; /**< one of ETT_ or -1 */
327 item_label_t *rep; /**< string for GUI tree */
328 guint32 flags; /**< bitfield like FI_GENERATED, ... */
329 tvbuff_t *ds_tvb; /**< data source tvbuff */
335 * Flag fields. Do not assign values greater than 0x00000080 unless you
336 * shuffle the expert information upward; see below.
339 /** The protocol field should not be shown in the tree (it's used for filtering only),
340 * used in field_info.flags. */
341 /** HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN!
342 A user cannot tell by looking at the packet detail that the field exists
343 and that they can filter on its value. */
344 #define FI_HIDDEN 0x00000001
345 /** The protocol field should be displayed as "generated by Wireshark",
346 * used in field_info.flags. */
347 #define FI_GENERATED 0x00000002
348 /** The protocol field is actually a URL */
349 #define FI_URL 0x00000004
351 /** The protocol field value is in little endian */
352 #define FI_LITTLE_ENDIAN 0x00000008
353 /** The protocol field value is in big endian */
354 #define FI_BIG_ENDIAN 0x00000010
355 /** Field value start from nth bit (values from 0x20 - 0x100) */
356 #define FI_BITS_OFFSET(n) ((n & 7) << 5)
357 /** Field value takes n bits (values from 0x100 - 0x4000) */
358 /* if 0, it means that field takes fi->length * 8 */
359 #define FI_BITS_SIZE(n) ((n & 63) << 8)
361 /** convenience macro to get field_info.flags */
362 #define FI_GET_FLAG(fi, flag) ((fi) ? (fi->flags & flag) : 0)
363 /** convenience macro to set field_info.flags */
364 #define FI_SET_FLAG(fi, flag) \
367 (fi)->flags = (fi)->flags | (flag); \
370 #define FI_GET_BITS_OFFSET(fi) (FI_GET_FLAG(fi, FI_BITS_OFFSET(7)) >> 5)
371 #define FI_GET_BITS_SIZE(fi) (FI_GET_FLAG(fi, FI_BITS_SIZE(63)) >> 8)
373 /** One of these exists for the entire protocol tree. Each proto_node
374 * in the protocol tree points to the same copy. */
376 GHashTable *interesting_hfids;
378 gboolean fake_protocols;
382 /** Each proto_tree, proto_item is one of these. */
383 typedef struct _proto_node {
384 struct _proto_node *first_child;
385 struct _proto_node *last_child;
386 struct _proto_node *next;
387 struct _proto_node *parent;
389 tree_data_t *tree_data;
392 /** A protocol tree element. */
393 typedef proto_node proto_tree;
394 /** A protocol item element. */
395 typedef proto_node proto_item;
398 * Expert information.
399 * This is in the flags field; we allocate this from the top down,
400 * so as not to collide with FI_ flags, which are allocated from
404 /* expert severities */
405 #define PI_SEVERITY_MASK 0x00F00000 /**< mask usually for internal use only! */
406 /** Usual workflow, e.g. TCP connection establishing */
407 #define PI_CHAT 0x00200000
408 /** Notable messages, e.g. an application returned an "usual" error code like HTTP 404 */
409 #define PI_NOTE 0x00400000
410 /** Warning, e.g. application returned an "unusual" error code */
411 #define PI_WARN 0x00600000
412 /** Serious problems, e.g. [Malformed Packet] */
413 #define PI_ERROR 0x00800000
415 /* expert "event groups" */
416 #define PI_GROUP_MASK 0xFF000000 /**< mask usually for internal use only! */
417 /** The protocol field has a bad checksum, usually PI_WARN */
419 #define PI_CHECKSUM 0x01000000
420 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
421 #define PI_SEQUENCE 0x02000000
422 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
423 #define PI_RESPONSE_CODE 0x03000000
424 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
425 #define PI_REQUEST_CODE 0x04000000
426 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
427 #define PI_UNDECODED 0x05000000
428 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
429 #define PI_REASSEMBLE 0x06000000
430 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR */
431 #define PI_MALFORMED 0x07000000
432 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR */
433 #define PI_DEBUG 0x08000000
434 /** The protocol field violates a protocol specification, usually PI_WARN */
435 #define PI_PROTOCOL 0x09000000
436 /* The protocol field indicates a security probem (e.g. unsecure implementation) */
437 #define PI_SECURITY 0x0a000000
439 /* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
442 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
443 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
444 #define PROTO_ITEM_IS_HIDDEN(proto_item) \
445 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN) : 0)
446 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
447 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
448 #define PROTO_ITEM_SET_HIDDEN(proto_item) \
451 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_HIDDEN); \
453 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
454 #define PROTO_ITEM_IS_GENERATED(proto_item) \
455 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED) : 0)
456 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
457 #define PROTO_ITEM_SET_GENERATED(proto_item) \
460 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_GENERATED); \
462 /** is this protocol field actually a URL? */
463 #define PROTO_ITEM_IS_URL(proto_item) \
464 ((proto_item) ? FI_GET_FLAG(PITEM_FINFO(proto_item), FI_URL) : 0)
465 /** mark this protocol field as a URL */
466 #define PROTO_ITEM_SET_URL(proto_item) \
469 FI_SET_FLAG(PITEM_FINFO(proto_item), FI_URL); \
472 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
473 typedef gboolean (*proto_tree_traverse_func)(proto_node *, gpointer);
475 extern gboolean proto_tree_traverse_post_order(proto_tree *tree,
476 proto_tree_traverse_func func, gpointer data);
478 extern void proto_tree_children_foreach(proto_tree *tree,
479 proto_tree_foreach_func func, gpointer data);
481 /** Retrieve the field_info from a proto_node */
482 #define PNODE_FINFO(proto_node) ((proto_node)->finfo)
484 /** Retrieve the field_info from a proto_item */
485 #define PITEM_FINFO(proto_item) PNODE_FINFO(proto_item)
487 /** Retrieve the field_info from a proto_tree */
488 #define PTREE_FINFO(proto_tree) PNODE_FINFO(proto_tree)
490 /** Retrieve the tree_data_t from a proto_tree */
491 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
493 /** Sets up memory used by proto routines. Called at program startup */
494 extern void proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_data),
495 void (register_all_handoffs_func)(register_cb cb, gpointer client_data),
496 register_cb cb, void *client_data);
499 /** Frees memory used by proto routines. Called at program shutdown */
500 extern void proto_cleanup(void);
502 /** This function takes a tree and a protocol id as parameter and
503 will return TRUE/FALSE for whether the protocol or any of the filterable
504 fields in the protocol is referenced by any fitlers.
505 If this function returns FALSE then it is safe to skip any
506 proto_tree_add_...() calls and just treat the call as if the
507 dissector was called with tree==NULL.
508 If you reset the tree to NULL by this dissector returning FALSE,
509 you will still need to call any subdissector with the original value of
510 tree or filtering will break.
512 The purpose of this is to optimize wireshark for speed and make it
513 faster for when filters are being used.
515 extern gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
519 /** Create a subtree under an existing item.
520 @param ti the parent item of the new subtree
521 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
522 @return the new subtree */
523 extern proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx);
525 /** Get an existing subtree under an item.
526 @param ti the parent item of the subtree
527 @return the subtree or NULL */
528 extern proto_tree* proto_item_get_subtree(const proto_item *ti);
530 /** Get the parent of a subtree item.
531 @param ti the child item in the subtree
532 @return parent item or NULL */
533 extern proto_item* proto_item_get_parent(const proto_item *ti);
535 /** Get Nth generation parent item.
536 @param ti the child item in the subtree
537 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
538 @return parent item */
539 extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
541 /** Replace text of item after it already has been created.
542 @param ti the item to set the text
543 @param format printf like format string
544 @param ... printf like parameters */
545 extern void proto_item_set_text(proto_item *ti, const char *format, ...)
548 /** Append to text of item after it has already been created.
549 @param ti the item to append the text to
550 @param format printf like format string
551 @param ... printf like parameters */
552 extern void proto_item_append_text(proto_item *ti, const char *format, ...)
555 /** Prepend to text of item after it has already been created.
556 @param ti the item to prepend the text to
557 @param format printf like format string
558 @param ... printf like parameters */
559 extern void proto_item_prepend_text(proto_item *ti, const char *format, ...)
562 /** Set proto_item's length inside tvb, after it has already been created.
563 @param ti the item to set the length
564 @param length the new length ot the item */
565 extern void proto_item_set_len(proto_item *ti, const gint length);
568 * Sets the length of the item based on its start and on the specified
569 * offset, which is the offset past the end of the item; as the start
570 * in the item is relative to the beginning of the data source tvbuff,
571 * we need to pass in a tvbuff.
572 @param ti the item to set the length
573 @param tvb end is relative to this tvbuff
574 @param end this end offset is relative to the beginning of tvb
575 @todo make usage clearer, I don't understand it!
577 extern void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
579 /** Get length of a proto_item. Useful after using proto_tree_add_item()
580 * to add a variable-length field (e.g., FT_NSTRING_UINT8).
581 @param ti the item to get the length from
582 @return the current length */
583 extern int proto_item_get_len(const proto_item *ti);
586 * Sets an expert info to the proto_item.
587 @param ti the item to set the expert info
588 @param group the group of this info (e.g. PI_CHECKSUM)
589 @param severity of this info (e.g. PI_ERROR)
590 @return TRUE if value was written
592 extern gboolean proto_item_set_expert_flags(proto_item *ti, const int group, const guint severity);
597 /** Creates a new proto_tree root.
598 @return the new tree root */
599 extern proto_tree* proto_tree_create_root(void);
601 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
602 @param tree the tree to free */
603 extern void proto_tree_free(proto_tree *tree);
605 /** Set the tree visible or invisible.
606 Is the parsing being done for a visible proto_tree or an invisible one?
607 By setting this correctly, the proto_tree creation is sped up by not
608 having to call g_vsnprintf and copy strings around.
609 @param tree the tree to be set
610 @param visible ... or not
611 @return the old value */
613 proto_tree_set_visible(proto_tree *tree, gboolean visible);
615 /** Indicate whether we should fake protocols during dissection (default = TRUE)
616 @param tree the tree to be set
617 @param fake_protocols TRUE if we should fake protocols */
619 proto_tree_set_fake_protocols(proto_tree *tree, gboolean fake_protocols);
621 /** Mark a field/protocol ID as "interesting".
622 @param tree the tree to be set
623 @param hfid the interesting field id
624 @todo what *does* interesting mean? */
626 proto_tree_prime_hfid(proto_tree *tree, const int hfid);
628 /** Get a parent item of a subtree.
629 @param tree the tree to get the parent from
630 @return parent item */
631 extern proto_item* proto_tree_get_parent(const proto_tree *tree);
633 /** Get the root tree from any subtree.
634 @param tree the tree to get the root from
636 extern proto_tree* proto_tree_get_root(proto_tree *tree);
638 /** Move an existing item behind another existing item.
639 @param tree the tree to which both items belong
640 @param fixed_item the item which keeps it's position
641 @param item_to_move the item which will be moved */
642 extern void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
645 /** Set start and length of an appendix for a proto_tree.
646 @param tree the tree to set the appendix start and length
647 @param tvb the tv buffer of the current data
648 @param start the start offset of the appendix
649 @param length the length of the appendix */
650 extern void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length);
653 /** Add an item to a proto_tree, using the text label registered to that item.
654 The item is extracted from the tvbuff handed to it.
655 @param tree the tree to append this item to
656 @param hfindex field index
657 @param tvb the tv buffer of the current data
658 @param start start of data in tvb
659 @param length length of data in tvb
660 @param encoding data encoding
661 @return the newly created item */
663 proto_tree_add_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
664 const gint start, gint length, const guint encoding);
666 /** Add a text-only node to a proto_tree.
667 @param tree the tree to append this item to
668 @param tvb the tv buffer of the current data
669 @param start start of data in tvb
670 @param length length of data in tvb
671 @param format printf like format string
672 @param ... printf like parameters
673 @return the newly created item */
675 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
676 ...) G_GNUC_PRINTF(5,6);
678 /** Add a text-only node to a proto_tree using a variable argument list.
679 @param tree the tree to append this item to
680 @param tvb the tv buffer of the current data
681 @param start start of data in tvb
682 @param length length of data in tvb
683 @param format printf like format string
684 @param ap variable argument list
685 @return the newly created item */
687 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
688 gint length, const char *format, va_list ap);
691 /** Add a FT_NONE field to a proto_tree.
692 @param tree the tree to append this item to
693 @param hfindex field index
694 @param tvb the tv buffer of the current data
695 @param start start of data in tvb
696 @param length length of data in tvb
697 @param format printf like format string
698 @param ... printf like parameters
699 @return the newly created item */
701 proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start,
702 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
704 /** Add a FT_PROTOCOL to a proto_tree.
705 @param tree the tree to append this item to
706 @param hfindex field index
707 @param tvb the tv buffer of the current data
708 @param start start of data in tvb
709 @param length length of data in tvb
710 @param format printf like format string
711 @param ... printf like parameters
712 @return the newly created item */
714 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
715 gint length, const char *format, ...) G_GNUC_PRINTF(6,7);
720 /** Add a FT_BYTES to a proto_tree.
721 @param tree the tree to append this item to
722 @param hfindex field index
723 @param tvb the tv buffer of the current data
724 @param start start of data in tvb
725 @param length length of data in tvb
726 @param start_ptr pointer to the data to display
727 @return the newly created item */
729 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
730 gint length, const guint8* start_ptr);
732 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
733 the string for the value and with the field name being included
735 @param tree the tree to append this item to
736 @param hfindex field index
737 @param tvb the tv buffer of the current data
738 @param start start of data in tvb
739 @param length length of data in tvb
740 @param start_ptr pointer to the data to display
741 @param format printf like format string
742 @param ... printf like parameters
743 @return the newly created item */
745 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
746 gint start, gint length, const guint8* start_ptr, const char *format,
747 ...) G_GNUC_PRINTF(7,8);
749 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
750 the entire string for the entry, including any field name.
751 @param tree the tree to append this item to
752 @param hfindex field index
753 @param tvb the tv buffer of the current data
754 @param start start of data in tvb
755 @param length length of data in tvb
756 @param start_ptr pointer to the data to display
757 @param format printf like format string
758 @param ... printf like parameters
759 @return the newly created item */
761 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
762 gint length, const guint8* start_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
764 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
765 @param tree the tree to append this item to
766 @param hfindex field index
767 @param tvb the tv buffer of the current data
768 @param start start of data in tvb
769 @param length length of data in tvb
770 @param value_ptr pointer to the data to display
771 @return the newly created item */
773 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
774 gint length, nstime_t* value_ptr);
776 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
777 the format generating the string for the value and with the field name
778 being included automatically.
779 @param tree the tree to append this item to
780 @param hfindex field index
781 @param tvb the tv buffer of the current data
782 @param start start of data in tvb
783 @param length length of data in tvb
784 @param value_ptr pointer to the data to display
785 @param format printf like format string
786 @param ... printf like parameters
787 @return the newly created item */
789 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
790 gint start, gint length, nstime_t* value_ptr, const char *format, ...)
793 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
794 the format generating the entire string for the entry, including any field
796 @param tree the tree to append this item to
797 @param hfindex field index
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 value_ptr pointer to the data to display
802 @param format printf like format string
803 @param ... printf like parameters
804 @return the newly created item */
806 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
807 gint length, nstime_t* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
809 /** Add a FT_IPXNET to a proto_tree.
810 @param tree the tree to append this item to
811 @param hfindex field index
812 @param tvb the tv buffer of the current data
813 @param start start of data in tvb
814 @param length length of data in tvb
815 @param value data to display
816 @return the newly created item */
818 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
819 gint length, guint32 value);
821 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
822 the string for the value and with the field name being included
824 @param tree the tree to append this item to
825 @param hfindex field index
826 @param tvb the tv buffer of the current data
827 @param start start of data in tvb
828 @param length length of data in tvb
829 @param value data to display
830 @param format printf like format string
831 @param ... printf like parameters
832 @return the newly created item */
834 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
835 gint start, gint length, guint32 value, const char *format, ...)
838 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
839 the entire string for the entry, including any field name.
840 @param tree the tree to append this item to
841 @param hfindex field index
842 @param tvb the tv buffer of the current data
843 @param start start of data in tvb
844 @param length length of data in tvb
845 @param value data to display
846 @param format printf like format string
847 @param ... printf like parameters
848 @return the newly created item */
850 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
851 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
853 /** Add a FT_IPv4 to a proto_tree.
854 @param tree the tree to append this item to
855 @param hfindex field index
856 @param tvb the tv buffer of the current data
857 @param start start of data in tvb
858 @param length length of data in tvb
859 @param value data to display
860 @return the newly created item */
862 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
863 gint length, guint32 value);
865 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
866 the string for the value and with the field name being included
868 @param tree the tree to append this item to
869 @param hfindex field index
870 @param tvb the tv buffer of the current data
871 @param start start of data in tvb
872 @param length length of data in tvb
873 @param value data to display
874 @param format printf like format string
875 @param ... printf like parameters
876 @return the newly created item */
878 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
879 gint start, gint length, guint32 value, const char *format, ...)
882 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
883 the entire string for the entry, including any field name.
884 @param tree the tree to append this item to
885 @param hfindex field index
886 @param tvb the tv buffer of the current data
887 @param start start of data in tvb
888 @param length length of data in tvb
889 @param value data to display
890 @param format printf like format string
891 @param ... printf like parameters
892 @return the newly created item */
894 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
895 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
897 /** Add a FT_IPv6 to a proto_tree.
898 @param tree the tree to append this item to
899 @param hfindex field index
900 @param tvb the tv buffer of the current data
901 @param start start of data in tvb
902 @param length length of data in tvb
903 @param value_ptr data to display
904 @return the newly created item */
906 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
907 gint length, const guint8* value_ptr);
909 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
910 the string for the value and with the field name being included
912 @param tree the tree to append this item to
913 @param hfindex field index
914 @param tvb the tv buffer of the current data
915 @param start start of data in tvb
916 @param length length of data in tvb
917 @param value_ptr data to display
918 @param format printf like format string
919 @param ... printf like parameters
920 @return the newly created item */
922 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
923 gint start, gint length, const guint8* value_ptr, const char *format,
924 ...) G_GNUC_PRINTF(7,8);
926 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
927 the entire string for the entry, including any field name.
928 @param tree the tree to append this item to
929 @param hfindex field index
930 @param tvb the tv buffer of the current data
931 @param start start of data in tvb
932 @param length length of data in tvb
933 @param value_ptr data to display
934 @param format printf like format string
935 @param ... printf like parameters
936 @return the newly created item */
938 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
939 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
941 /** Add a FT_ETHER to a proto_tree.
942 @param tree the tree to append this item to
943 @param hfindex field index
944 @param tvb the tv buffer of the current data
945 @param start start of data in tvb
946 @param length length of data in tvb
947 @param value data to display
948 @return the newly created item */
950 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
951 gint length, const guint8* value);
953 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
954 the string for the value and with the field name being included
956 @param tree the tree to append this item to
957 @param hfindex field index
958 @param tvb the tv buffer of the current data
959 @param start start of data in tvb
960 @param length length of data in tvb
961 @param value data to display
962 @param format printf like format string
963 @param ... printf like parameters
964 @return the newly created item */
966 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
967 gint start, gint length, const guint8* value, const char *format, ...)
970 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
971 the entire string for the entry, including any field name.
972 @param tree the tree to append this item to
973 @param hfindex field index
974 @param tvb the tv buffer of the current data
975 @param start start of data in tvb
976 @param length length of data in tvb
977 @param value data to display
978 @param format printf like format string
979 @param ... printf like parameters
980 @return the newly created item */
982 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
983 gint length, const guint8* value, const char *format, ...) G_GNUC_PRINTF(7,8);
985 /** Add a FT_GUID to a proto_tree.
986 @param tree the tree to append this item to
987 @param hfindex field index
988 @param tvb the tv buffer of the current data
989 @param start start of data in tvb
990 @param length length of data in tvb
991 @param value_ptr data to display
992 @return the newly created item */
994 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
995 gint length, const e_guid_t *value_ptr);
997 /** Add a formatted FT_GUID to a proto_tree, with the format generating
998 the string for the value and with the field name being included
1000 @param tree the tree to append this item to
1001 @param hfindex field index
1002 @param tvb the tv buffer of the current data
1003 @param start start of data in tvb
1004 @param length length of data in tvb
1005 @param value_ptr data to display
1006 @param format printf like format string
1007 @param ... printf like parameters
1008 @return the newly created item */
1010 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1011 gint start, gint length, const e_guid_t *value_ptr, const char *format,
1012 ...) G_GNUC_PRINTF(7,8);
1014 /** Add a formatted FT_GUID to a proto_tree, with the format generating
1015 the entire string for the entry, including any field name.
1016 @param tree the tree to append this item to
1017 @param hfindex field index
1018 @param tvb the tv buffer of the current data
1019 @param start start of data in tvb
1020 @param length length of data in tvb
1021 @param value_ptr data to display
1022 @param format printf like format string
1023 @param ... printf like parameters
1024 @return the newly created item */
1026 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1027 gint length, const e_guid_t *value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1029 /** Add a FT_OID to a proto_tree.
1030 @param tree the tree to append this item to
1031 @param hfindex field index
1032 @param tvb the tv buffer of the current data
1033 @param start start of data in tvb
1034 @param length length of data in tvb
1035 @param value_ptr data to display
1036 @return the newly created item */
1038 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1039 gint length, const guint8* value_ptr);
1041 /** Add a formatted FT_OID to a proto_tree, with the format generating
1042 the string for the value and with the field name being included
1044 @param tree the tree to append this item to
1045 @param hfindex field index
1046 @param tvb the tv buffer of the current data
1047 @param start start of data in tvb
1048 @param length length of data in tvb
1049 @param value_ptr data to display
1050 @param format printf like format string
1051 @param ... printf like parameters
1052 @return the newly created item */
1054 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1055 gint start, gint length, const guint8* value_ptr, const char *format,
1056 ...) G_GNUC_PRINTF(7,8);
1058 /** Add a formatted FT_OID to a proto_tree, with the format generating
1059 the entire string for the entry, including any field name.
1060 @param tree the tree to append this item to
1061 @param hfindex field index
1062 @param tvb the tv buffer of the current data
1063 @param start start of data in tvb
1064 @param length length of data in tvb
1065 @param value_ptr data to display
1066 @param format printf like format string
1067 @param ... printf like parameters
1068 @return the newly created item */
1070 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1071 gint length, const guint8* value_ptr, const char *format, ...) G_GNUC_PRINTF(7,8);
1073 /** Add a FT_STRING to a proto_tree.
1074 @param tree the tree to append this item to
1075 @param hfindex field index
1076 @param tvb the tv buffer of the current data
1077 @param start start of data in tvb
1078 @param length length of data in tvb
1079 @param value data to display
1080 @return the newly created item */
1082 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1083 gint length, const char* value);
1085 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1086 the string for the value and with the field name being included
1088 @param tree the tree to append this item to
1089 @param hfindex field index
1090 @param tvb the tv buffer of the current data
1091 @param start start of data in tvb
1092 @param length length of data in tvb
1093 @param value data to display
1094 @param format printf like format string
1095 @param ... printf like parameters
1096 @return the newly created item */
1098 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1099 gint start, gint length, const char* value, const char *format, ...)
1102 /** Add a formatted FT_STRING to a proto_tree, with the format generating
1103 the entire string for the entry, including any field name.
1104 @param tree the tree to append this item to
1105 @param hfindex field index
1106 @param tvb the tv buffer of the current data
1107 @param start start of data in tvb
1108 @param length length of data in tvb
1109 @param value data to display
1110 @param format printf like format string
1111 @param ... printf like parameters
1112 @return the newly created item */
1114 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1115 gint length, const char* value, const char *format, ...) G_GNUC_PRINTF(7,8);
1117 /** Add a FT_BOOLEAN to a proto_tree.
1118 @param tree the tree to append this item to
1119 @param hfindex field index
1120 @param tvb the tv buffer of the current data
1121 @param start start of data in tvb
1122 @param length length of data in tvb
1123 @param value data to display
1124 @return the newly created item */
1126 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1127 gint length, guint32 value);
1129 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1130 the string for the value and with the field name being included
1132 @param tree the tree to append this item to
1133 @param hfindex field index
1134 @param tvb the tv buffer of the current data
1135 @param start start of data in tvb
1136 @param length length of data in tvb
1137 @param value data to display
1138 @param format printf like format string
1139 @param ... printf like parameters
1140 @return the newly created item */
1142 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1143 tvbuff_t *tvb, gint start, gint length, guint32 value,
1144 const char *format, ...) G_GNUC_PRINTF(7,8);
1146 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1147 the entire string for the entry, including any field name.
1148 @param tree the tree to append this item to
1149 @param hfindex field index
1150 @param tvb the tv buffer of the current data
1151 @param start start of data in tvb
1152 @param length length of data in tvb
1153 @param value data to display
1154 @param format printf like format string
1155 @param ... printf like parameters
1156 @return the newly created item */
1158 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1159 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1161 /** Add a FT_FLOAT to a proto_tree.
1162 @param tree the tree to append this item to
1163 @param hfindex field index
1164 @param tvb the tv buffer of the current data
1165 @param start start of data in tvb
1166 @param length length of data in tvb
1167 @param value data to display
1168 @return the newly created item */
1170 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1171 gint length, float value);
1173 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1174 the string for the value and with the field name being included
1176 @param tree the tree to append this item to
1177 @param hfindex field index
1178 @param tvb the tv buffer of the current data
1179 @param start start of data in tvb
1180 @param length length of data in tvb
1181 @param value data to display
1182 @param format printf like format string
1183 @param ... printf like parameters
1184 @return the newly created item */
1186 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1187 gint start, gint length, float value, const char *format, ...)
1190 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1191 the entire string for the entry, including any field name.
1192 @param tree the tree to append this item to
1193 @param hfindex field index
1194 @param tvb the tv buffer of the current data
1195 @param start start of data in tvb
1196 @param length length of data in tvb
1197 @param value data to display
1198 @param format printf like format string
1199 @param ... printf like parameters
1200 @return the newly created item */
1202 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1203 gint length, float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1205 /** Add a FT_DOUBLE to a proto_tree.
1206 @param tree the tree to append this item to
1207 @param hfindex field index
1208 @param tvb the tv buffer of the current data
1209 @param start start of data in tvb
1210 @param length length of data in tvb
1211 @param value data to display
1212 @return the newly created item */
1214 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1215 gint length, double value);
1217 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1218 the string for the value and with the field name being included
1220 @param tree the tree to append this item to
1221 @param hfindex field index
1222 @param tvb the tv buffer of the current data
1223 @param start start of data in tvb
1224 @param length length of data in tvb
1225 @param value data to display
1226 @param format printf like format string
1227 @param ... printf like parameters
1228 @return the newly created item */
1230 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1231 gint start, gint length, double value, const char *format, ...)
1234 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1235 the entire string for the entry, including any field name.
1236 @param tree the tree to append this item to
1237 @param hfindex field index
1238 @param tvb the tv buffer of the current data
1239 @param start start of data in tvb
1240 @param length length of data in tvb
1241 @param value data to display
1242 @param format printf like format string
1243 @param ... printf like parameters
1244 @return the newly created item */
1246 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1247 gint length, double value, const char *format, ...) G_GNUC_PRINTF(7,8);
1249 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1250 @param tree the tree to append this item to
1251 @param hfindex field index
1252 @param tvb the tv buffer of the current data
1253 @param start start of data in tvb
1254 @param length length of data in tvb
1255 @param value data to display
1256 @return the newly created item */
1258 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1259 gint length, guint32 value);
1261 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1262 with the format generating the string for the value and with the field
1263 name being included automatically.
1264 @param tree the tree to append this item to
1265 @param hfindex field index
1266 @param tvb the tv buffer of the current data
1267 @param start start of data in tvb
1268 @param length length of data in tvb
1269 @param value data to display
1270 @param format printf like format string
1271 @param ... printf like parameters
1272 @return the newly created item */
1274 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1275 gint start, gint length, guint32 value, const char *format, ...)
1278 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1279 with the format generating the entire string for the entry, including any
1281 @param tree the tree to append this item to
1282 @param hfindex field index
1283 @param tvb the tv buffer of the current data
1284 @param start start of data in tvb
1285 @param length length of data in tvb
1286 @param value data to display
1287 @param format printf like format string
1288 @param ... printf like parameters
1289 @return the newly created item */
1291 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1292 gint length, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1294 /** Add an FT_UINT64 to a proto_tree.
1295 @param tree the tree to append this item to
1296 @param hfindex field index
1297 @param tvb the tv buffer of the current data
1298 @param start start of data in tvb
1299 @param length length of data in tvb
1300 @param value data to display
1301 @return the newly created item */
1303 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1304 gint length, guint64 value);
1306 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1307 the string for the value and with the field name being included
1309 @param tree the tree to append this item to
1310 @param hfindex field index
1311 @param tvb the tv buffer of the current data
1312 @param start start of data in tvb
1313 @param length length of data in tvb
1314 @param value data to display
1315 @param format printf like format string
1316 @param ... printf like parameters
1317 @return the newly created item */
1319 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1320 gint start, gint length, guint64 value, const char *format, ...)
1323 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1324 the entire string for the entry, including any field name.
1325 @param tree the tree to append this item to
1326 @param hfindex field index
1327 @param tvb the tv buffer of the current data
1328 @param start start of data in tvb
1329 @param length length of data in tvb
1330 @param value data to display
1331 @param format printf like format string
1332 @param ... printf like parameters
1333 @return the newly created item */
1335 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1336 gint length, guint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1338 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1339 @param tree the tree to append this item to
1340 @param hfindex field index
1341 @param tvb the tv buffer of the current data
1342 @param start start of data in tvb
1343 @param length length of data in tvb
1344 @param value data to display
1345 @return the newly created item */
1347 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1348 gint length, gint32 value);
1350 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1351 with the format generating the string for the value and with the field
1352 name being included automatically.
1353 @param tree the tree to append this item to
1354 @param hfindex field index
1355 @param tvb the tv buffer of the current data
1356 @param start start of data in tvb
1357 @param length length of data in tvb
1358 @param value data to display
1359 @param format printf like format string
1360 @param ... printf like parameters
1361 @return the newly created item */
1363 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1364 gint start, gint length, gint32 value, const char *format, ...)
1367 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1368 with the format generating the entire string for the entry, including
1370 @param tree the tree to append this item to
1371 @param hfindex field index
1372 @param tvb the tv buffer of the current data
1373 @param start start of data in tvb
1374 @param length length of data in tvb
1375 @param value data to display
1376 @param format printf like format string
1377 @param ... printf like parameters
1378 @return the newly created item */
1380 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1381 gint length, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1383 /** Add an FT_INT64 to a proto_tree.
1384 @param tree the tree to append this item to
1385 @param hfindex field index
1386 @param tvb the tv buffer of the current data
1387 @param start start of data in tvb
1388 @param length length of data in tvb
1389 @param value data to display
1390 @return the newly created item */
1392 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1393 gint length, gint64 value);
1395 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1396 the string for the value and with the field name being included
1398 @param tree the tree to append this item to
1399 @param hfindex field index
1400 @param tvb the tv buffer of the current data
1401 @param start start of data in tvb
1402 @param length length of data in tvb
1403 @param value data to display
1404 @param format printf like format string
1405 @param ... printf like parameters
1406 @return the newly created item */
1408 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1409 gint start, gint length, gint64 value, const char *format, ...)
1412 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1413 the entire string for the entry, including any field name.
1414 @param tree the tree to append this item to
1415 @param hfindex field index
1416 @param tvb the tv buffer of the current data
1417 @param start start of data in tvb
1418 @param length length of data in tvb
1419 @param value data to display
1420 @param format printf like format string
1421 @param ... printf like parameters
1422 @return the newly created item */
1424 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1425 gint length, gint64 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1427 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1428 leave call to this function in production code.
1429 @param tree the tree to append the text to
1430 @param format printf like format string
1431 @param ... printf like parameters
1432 @return the newly created item */
1434 proto_tree_add_debug_text(proto_tree *tree, const char *format,
1435 ...) G_GNUC_PRINTF(2,3);
1439 /** Append a string to a protocol item.<br>
1440 NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1442 Currently only WSP use this function so it is not that bad but try to
1443 avoid using this one if possible.
1444 IF you must use this function you MUST also disable the
1445 TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1446 using proto_item_append_string().
1447 Do that by faking that the tree is visible by calling
1448 proto_tree_set_visible(tree, TRUE) (see packet-wsp.c)
1449 BEFORE you create the item you are later going to use
1450 proto_item_append_string() on.
1451 @param pi the item to append the string to
1452 @param str the string to append */
1454 proto_item_append_string(proto_item *pi, const char *str);
1458 /** Fill given label_str with string representation of field
1459 @param fi the item to get the info from
1460 @param label_str the string to fill
1461 @todo think about changing the parameter profile */
1463 proto_item_fill_label(field_info *fi, gchar *label_str);
1466 /** Register a new protocol.
1467 @param name the full name of the new protocol
1468 @param short_name abbreviated name of the new protocol
1469 @param filter_name protocol name used for a display filter string
1470 @return the new protocol handle */
1472 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
1474 /** Mark protocol as private
1475 @param proto_id the handle of the protocol */
1477 proto_mark_private(const int proto_id);
1479 /** Return if protocol is private
1480 @param proto_id the handle of the protocol
1481 @return TRUE if it is a private protocol, FALSE is not. */
1483 proto_is_private(const int proto_id);
1485 /** This is the type of function can be registered to get called whenever
1486 a given field was not found but a its prefix is matched
1487 it can be used to procrastinate the hf array registration
1488 @param match what's being matched */
1489 typedef void (*prefix_initializer_t)(const char* match);
1491 /** Register a new prefix for delayed initialization of field arrays
1492 @param prefix the prefix for the new protocol
1493 @param initializer function that will initialize the field array for the given prefix */
1495 proto_register_prefix(const char *prefix, prefix_initializer_t initializer);
1497 /** Initialize every remaining uninitialized prefix. */
1498 extern void proto_initialize_all_prefixes(void);
1500 /** Register a header_field array.
1501 @param parent the protocol handle from proto_register_protocol()
1502 @param hf the hf_register_info array
1503 @param num_records the number of records in hf */
1505 proto_register_field_array(const int parent, hf_register_info *hf, const int num_records);
1507 /** Register a protocol subtree (ett) array.
1508 @param indices array of ett indices
1509 @param num_indices the number of records in indices */
1511 proto_register_subtree_array(gint *const *indices, const int num_indices);
1513 /** Returns number of items (protocols or header fields) registered.
1514 @return the number of items */
1515 extern int proto_registrar_n(void);
1517 /** Get name of registered header_field number n.
1518 @param n item # n (0-indexed)
1519 @return the name of this registered item */
1520 extern const char* proto_registrar_get_name(const int n);
1522 /** Get abbreviation of registered header_field number n.
1523 @param n item # n (0-indexed)
1524 @return the abbreviation of this registered item */
1525 extern const char* proto_registrar_get_abbrev(const int n);
1527 /** Get the header_field information based upon a field or protocol id.
1528 @param hfindex item # n (0-indexed)
1529 @return the registered item */
1530 extern header_field_info* proto_registrar_get_nth(guint hfindex);
1532 /** Get the header_field information based upon a field name.
1533 @param field_name the field name to search for
1534 @return the registered item */
1535 extern header_field_info* proto_registrar_get_byname(const char *field_name);
1537 /** Get enum ftenum FT_ of registered header_field number n.
1538 @param n item # n (0-indexed)
1539 @return the registered item */
1540 extern int proto_registrar_get_ftype(const int n);
1542 /** Get parent protocol of registered header_field number n.
1543 @param n item # n (0-indexed)
1544 @return -1 if item _is_ a protocol */
1545 extern int proto_registrar_get_parent(const int n);
1547 /** Is item # n a protocol?
1548 @param n item # n (0-indexed)
1549 @return TRUE if it's a protocol, FALSE if it's not */
1550 extern gboolean proto_registrar_is_protocol(const int n);
1552 /** Get length of registered field according to field type.
1553 @param n item # n (0-indexed)
1554 @return 0 means undeterminable at registration time, -1 means unknown field */
1555 extern gint proto_registrar_get_length(const int n);
1558 /** Routines to use to iterate over the protocols and their fields;
1559 * they return the item number of the protocol in question or the
1560 * appropriate hfinfo pointer, and keep state in "*cookie". */
1561 extern int proto_get_first_protocol(void **cookie);
1562 extern int proto_get_next_protocol(void **cookie);
1563 extern header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookle);
1564 extern header_field_info *proto_get_next_protocol_field(void **cookle);
1566 /** Given a protocol's filter_name.
1567 @param filter_name the filter name to search for
1569 extern int proto_get_id_by_filter_name(const gchar* filter_name);
1571 /** Can item # n decoding be disabled?
1572 @param proto_id protocol id (0-indexed)
1573 @return TRUE if it's a protocol, FALSE if it's not */
1574 extern gboolean proto_can_toggle_protocol(const int proto_id);
1576 /** Get the "protocol_t" structure for the given protocol's item number.
1577 @param proto_id protocol id (0-indexed) */
1578 extern protocol_t *find_protocol_by_id(const int proto_id);
1580 /** Get the protocol's name for the given protocol's item number.
1581 @param proto_id protocol id (0-indexed)
1583 extern const char *proto_get_protocol_name(const int proto_id);
1585 /** Get the protocol's item number, for the given protocol's "protocol_t".
1586 @return its proto_id */
1587 extern int proto_get_id(const protocol_t *protocol);
1589 /** Get the protocol's short name, for the given protocol's "protocol_t".
1590 @return its short name. */
1591 extern const char *proto_get_protocol_short_name(const protocol_t *protocol);
1593 /** Get the protocol's long name, for the given protocol's "protocol_t".
1594 @return its long name. */
1595 extern const char *proto_get_protocol_long_name(const protocol_t *protocol);
1597 /** Is protocol's decoding enabled ?
1599 @return TRUE if decoding is enabled, FALSE if not */
1600 extern gboolean proto_is_protocol_enabled(const protocol_t *protocol);
1602 /** Get a protocol's filter name by it's item number.
1603 @param proto_id protocol id (0-indexed)
1604 @return its filter name. */
1605 extern const char *proto_get_protocol_filter_name(const int proto_id);
1607 /** Enable / Disable protocol of the given item number.
1608 @param proto_id protocol id (0-indexed)
1609 @param enabled enable / disable the protocol */
1610 extern void proto_set_decoding(const int proto_id, const gboolean enabled);
1612 /** Enable all protocols */
1613 extern void proto_enable_all(void);
1615 /** Disable disabling/enabling of protocol of the given item number.
1616 @param proto_id protocol id (0-indexed) */
1617 extern void proto_set_cant_toggle(const int proto_id);
1619 /** Checks for existence any protocol or field within a tree.
1620 @param tree "Protocols" are assumed to be a child of the [empty] root node.
1621 @param id hfindex of protocol or field
1622 @return TRUE = found, FALSE = not found
1623 @todo add explanation of id parameter */
1624 extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id);
1626 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1627 tree. Only works with primed trees, and is fast.
1628 @param tree tree of interest
1629 @param hfindex primed hfindex
1630 @return GPtrArry pointer */
1631 extern GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex);
1633 /** Return whether we're tracking any interesting fields.
1634 Only works with primed trees, and is fast.
1635 @param tree tree of interest
1636 @return TRUE if we're tracking interesting fields */
1637 extern gboolean proto_tracking_interesting_fields(const proto_tree *tree);
1639 /** Return GPtrArray* of field_info pointers for all hfindex that appear in
1640 tree. Works with any tree, primed or unprimed, and is slower than
1641 proto_get_finfo_ptr_array because it has to search through the tree.
1642 @param tree tree of interest
1643 @param hfindex index of field info of interest
1644 @return GPtrArry pointer */
1645 extern GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex);
1647 /** Return GPtrArray* of field_info pointers containg all hfindexes that appear
1649 @param tree tree of interest
1650 @return GPtrArry pointer */
1651 extern GPtrArray* proto_all_finfos(proto_tree *tree);
1653 /** Dumps a glossary of the protocol registrations to STDOUT */
1654 extern void proto_registrar_dump_protocols(void);
1656 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
1657 extern void proto_registrar_dump_values(void);
1659 /** Dumps a glossary of the protocol and field registrations to STDOUT.
1660 * Format 1 is the original format. Format 2 includes the base (for integers)
1662 extern void proto_registrar_dump_fields(const int format);
1666 /** Points to the first element of an array of Booleans, indexed by
1667 a subtree item type. That array element is TRUE if subtrees of
1668 an item of that type are to be expanded. With MSVC and a
1669 libwireshark.dll, we need a special declaration. */
1670 WS_VAR_IMPORT gboolean *tree_is_expanded;
1672 /** Number of elements in the tree_is_expanded array. With MSVC and a
1673 * libwireshark.dll, we need a special declaration. */
1674 WS_VAR_IMPORT int num_tree_types;
1676 /** glib doesn't have g_ptr_array_len of all things!*/
1677 #ifndef g_ptr_array_len
1678 #define g_ptr_array_len(a) ((a)?(a)->len:0)
1681 /** Get number of bits of a header_field.
1682 @param hfinfo header_field
1683 @return the bitwidth */
1685 hfinfo_bitwidth(const header_field_info *hfinfo);
1692 /** Can we do a "match selected" on this field.
1693 @param finfo field_info
1694 @param edt epan dissecting
1695 @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
1697 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
1699 /** Construct a "match selected" display filter string.
1700 @param finfo field_info
1701 @param edt epan dissecting
1702 @return the display filter string */
1704 proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt);
1706 /** Find field from offset in tvb.
1707 @param tree tree of interest
1708 @param offset offset in the tvb
1709 @param tvb the tv buffer
1710 @return the corresponding field_info */
1712 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
1714 /** This function will dissect a sequence of bytes that describe a bitmask.
1715 @param tree the tree to append this item to
1716 @param tvb the tv buffer of the current data
1717 @param offset start of data in tvb
1718 @param hf_hdr an 8/16/24/32 bit integer that describes the bitmask to be dissected.
1719 This field will form an expansion under which the individual fields of the
1720 bitmask is dissected and displayed.
1721 This field must be of the type FT_[U]INT{8|16|24|32}.
1722 @param ett subtree index
1723 @param fields an array of pointers to int that lists all the fields of the
1724 bitmask. These fields can be either of the type FT_BOOLEAN for flags
1725 or another integer of the same type/size as hf_hdr with a mask specified.
1726 This array is terminated by a NULL entry.
1727 FT_BOOLEAN bits that are set to 1 will have the name added to the expansion.
1728 FT_integer fields that have a value_string attached will have the
1729 matched string displayed on the expansion line.
1730 @param little_endian big or little endian byte representation
1731 @return the newly created item */
1733 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
1734 const int hf_hdr, const gint ett, const int **fields, const gboolean little_endian);
1736 /** Add a text with a subtree of bitfields.
1737 @param tree the tree to append this item to
1738 @param tvb the tv buffer of the current data
1739 @param offset start of data in tvb
1740 @param len length of the field name
1741 @param name field name (NULL if bitfield contents should be used)
1742 @param fallback field name if none of bitfields were usable
1743 @param ett subtree index
1744 @param fields NULL-terminated array of bitfield indexes
1745 @param little_endian big or little endian byte representation
1746 @param little_endian big or little endian byte representation
1748 @return the newly created item */
1750 proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len,
1751 const char *name, const char *fallback,
1752 const gint ett, const int **fields, const gboolean little_endian, const int flags);
1754 #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */
1755 #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */
1756 #define BMT_NO_FALSE 0x04 /**< Don't add booleans unless they're TRUE */
1757 #define BMT_NO_TFS 0x08 /**< Don't use true_false_string while formatting booleans */
1759 /** Add bits to a proto_tree, using the text label registered to that item.
1760 The item is extracted from the tvbuff handed to it.
1761 @param tree the tree to append this item to
1762 @param hf_index field index. Fields for use with this function should have bitmask==0.
1763 @param tvb the tv buffer of the current data
1764 @param bit_offset start of data in tvb expressed in bits
1765 @param no_of_bits length of data in tvb expressed in bits
1766 @param little_endian big or little endian byte representation
1767 @return the newly created item */
1769 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);
1771 /** Add bits to a proto_tree, using the text label registered to that item.
1772 The item is extracted from the tvbuff handed to it.
1773 @param tree the tree to append this item to
1774 @param hf_index field index. Fields for use with this function should have bitmask==0.
1775 @param tvb the tv buffer of the current data
1776 @param bit_offset start of data in tvb expressed in bits
1777 @param no_of_bits length of data in tvb expressed in bits
1778 @param return_value if a pointer is passed here the value is returned.
1779 @param little_endian big or little endian byte representation
1780 @return the newly created item */
1782 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);
1784 /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
1785 header field to a proto_tree, with the format generating the
1786 string for the value and with the field name being included automatically.
1787 @param tree the tree to append this item to
1788 @param hf_index field index
1789 @param tvb the tv buffer of the current data
1790 @param bit_offset start of data in tvb expressed in bits
1791 @param no_of_bits length of data in tvb expressed in bit
1792 @param value data to display
1793 @param format printf like format string
1794 @return the newly created item */
1796 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,
1797 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1799 /** Add bits for a FT_BOOLEAN 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_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits,
1813 guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1815 /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
1816 header field to a proto_tree, with the format generating the
1817 string for the value and with the field name being included automatically.
1818 @param tree the tree to append this item to
1819 @param hf_index field index
1820 @param tvb the tv buffer of the current data
1821 @param bit_offset start of data in tvb expressed in bits
1822 @param no_of_bits length of data in tvb expressed in bit
1823 @param value data to display
1824 @param format printf like format string
1825 @param ... printf like parameters
1826 @return the newly created item */
1828 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,
1829 gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8);
1831 /** Add bits for a FT_FLOAT header field to a proto_tree, with
1832 the format generating the string for the value and with the field
1833 name being included automatically.
1834 @param tree the tree to append this item to
1835 @param hf_index field index
1836 @param tvb the tv buffer of the current data
1837 @param bit_offset start of data in tvb expressed in bits
1838 @param no_of_bits length of data in tvb expressed in bit
1839 @param value data to display
1840 @param format printf like format string
1841 @param ... printf like parameters
1842 @return the newly created item */
1844 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,
1845 float value, const char *format, ...) G_GNUC_PRINTF(7,8);
1847 /** Check if given string is a valid field name
1848 @param field_name the field name to check
1849 @return 0 if valid, else first illegal character */
1851 proto_check_field_name(const gchar *field_name);
1854 /** Check if given string is a valid field name
1855 @param tree the tree to append this item to
1856 @param field_id the field id used for custom column
1857 @param occurrence the occurrence of the field used for custom column
1858 @param result the buffer to fill with the field string
1859 @param expr the filter expression
1860 @param size the size of the string buffer */
1862 proto_custom_set(proto_tree* tree, const int field_id,
1865 gchar *expr, const int size );
1869 #endif /* __cplusplus */
1871 #endif /* proto.h */