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().
48 #include "gnuc_format_check.h"
52 #include "ftypes/ftypes.h"
54 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
55 WS_VAR_IMPORT int hf_text_only;
57 /** the maximum length of a protocol field string representation */
58 #define ITEM_LABEL_LENGTH 240
62 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
63 #define VALS(x) (const struct _value_string*)(x)
65 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
66 #define TFS(x) (const struct true_false_string*)(x)
70 /** Structure for information about a protocol */
71 typedef struct _protocol protocol_t;
73 /** check protocol activation
74 * @todo this macro looks like a hack */
75 #define CHECK_DISPLAY_AS_X(x_handle,index, tvb, pinfo, tree) { \
76 if (!proto_is_protocol_enabled(find_protocol_by_id(index))) { \
77 call_dissector(x_handle,tvb, pinfo, tree); \
82 /** Macro used for reporting errors in dissectors; it throws a
83 * DissectorError exception, with the string passed as an argument
84 * as the message for the exception, so that it can show up in
85 * the Info column and the protocol tree.
87 * If that string is dynamically allocated, it should be allocated with
88 * ep_alloc(); using ep_strdup_printf() would work.
90 * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
91 * it will call abort(), instead, to make it easier to get a stack trace.
93 * @param message string to use as the message
95 #define REPORT_DISSECTOR_BUG(message) \
96 ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) ? \
98 THROW_MESSAGE(DissectorError, message))
100 /** Macro used for assertions in dissectors; it doesn't abort, it just
101 * throws a DissectorError exception, with the assertion failure
102 * message as a parameter, so that it can show up in the protocol tree.
104 * @param expression expression to test in the assertion
106 #define DISSECTOR_ASSERT(expression) \
107 ((void) ((expression) ? (void)0 : \
108 __DISSECTOR_ASSERT (expression, __FILE__, __LINE__)))
111 /* win32: using a debug breakpoint (int 3) can be very handy while debugging,
112 * as the assert handling of GTK/GLib is currently not very helpful */
113 #define DISSECTOR_ASSERT(expression) \
114 { if(!(expression)) _asm { int 3}; }
117 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
118 * unconditionally, much like GLIB's g_assert_not_reached works.
120 #define DISSECTOR_ASSERT_NOT_REACHED() \
121 (REPORT_DISSECTOR_BUG( \
122 ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
123 __FILE__, __LINE__)))
125 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
127 #define __DISSECTOR_ASSERT(expression, file, lineno) \
128 (REPORT_DISSECTOR_BUG( \
129 ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
130 file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
132 /** radix for decimal values, used in header_field_info.display */
134 BASE_NONE, /**< none */
135 BASE_DEC, /**< decimal */
136 BASE_HEX, /**< hexadecimal */
137 BASE_OCT, /**< octal */
138 BASE_DEC_HEX, /**< decimal (hexadecimal) */
139 BASE_HEX_DEC /**< hexadecimal (decimal) */
142 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
144 /** information describing a header field */
145 typedef struct _header_field_info header_field_info;
147 /** information describing a header field */
148 struct _header_field_info {
149 /* ---------- set by dissector --------- */
150 const char *name; /**< full name of this field */
151 const char *abbrev; /**< abbreviated name of this field */
152 enum ftenum type; /**< field type, one of FT_ (from ftypes.h) */
153 int display; /**< one of BASE_, or number of field bits for FT_BOOLEAN */
154 const void *strings; /**< _value_string (or true_false_string for FT_BOOLEAN), typically converted by VALS() or TFS() If this is an FT_PROTOCOL then it points to the associated protocol_t structure*/
155 guint32 bitmask; /**< FT_BOOLEAN only: bitmask of interesting bits */
156 const char *blurb; /**< Brief description of field. */
158 /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
159 int id; /**< Field ID */
160 int parent; /**< parent protocol tree */
161 /* This field keeps track of whether a field is
162 * referenced in any filter or not and if so how
163 * many times. If a filter is being referenced the
164 * refcount for the parent protocol is updated as well
166 int ref_count; /**< is this field referenced by a filter or not */
167 int bitshift; /**< bits to shift (FT_BOOLEAN only) */
168 header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev*/
169 header_field_info *same_name_prev; /**< Link to previous hfinfo with same abbrev*/
173 * HFILL initializes all the "set by proto routines" fields in a
174 * _header_field_info. If new fields are added or removed, it should
175 * be changed as necessary.
177 #define HFILL 0, 0, 0, 0, NULL, NULL
179 /** Used when registering many fields at once, using proto_register_field_array() */
180 typedef struct hf_register_info {
181 int *p_id; /**< written to by register() function */
182 header_field_info hfinfo; /**< the field info to be registered */
188 /** string representation, if one of the proto_tree_add_..._format() functions used */
189 typedef struct _item_label_t {
190 char representation[ITEM_LABEL_LENGTH];
194 /** Contains the field information for the proto_item. */
195 typedef struct field_info {
196 header_field_info *hfinfo; /**< pointer to registered field information */
197 gint start; /**< current start of data in field_info.ds_tvb */
198 gint length; /**< current data length of item in field_info.ds_tvb */
199 gint tree_type; /**< one of ETT_ or -1 */
200 item_label_t *rep; /**< string for GUI tree */
201 int flags; /**< bitfield like FI_GENERATED, ... */
202 tvbuff_t *ds_tvb; /**< data source tvbuff */
207 /** The protocol field should not be shown in the tree (it's used for filtering only),
208 * used in field_info.flags. */
209 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
210 #define FI_HIDDEN 0x0001
211 /** The protocol field should be displayed as "generated by Wireshark",
212 * used in field_info.flags. */
213 #define FI_GENERATED 0x0002
214 /* The protocol field is actually a URL */
215 #define FI_URL 0x0004
218 /** convenience macro to get field_info.flags */
219 #define FI_GET_FLAG(fi, flag) (fi->flags & flag)
220 /** convenience macro to set field_info.flags */
221 #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag)
223 /** One of these exists for the entire protocol tree. Each proto_node
224 * in the protocol tree points to the same copy. */
226 GHashTable *interesting_hfids;
231 /** Each proto_tree, proto_item is one of these. */
232 typedef struct _proto_node {
233 struct _proto_node *first_child;
234 struct _proto_node *last_child;
235 struct _proto_node *next;
236 struct _proto_node *parent;
238 tree_data_t *tree_data;
241 /** A protocol tree element. */
242 typedef proto_node proto_tree;
243 /** A protocol item element. */
244 typedef proto_node proto_item;
246 /* expert severities */
247 #define PI_SEVERITY_MASK 0x001C /* mask usually for internal use only! */
248 /** Usual workflow, e.g. TCP connection establishing */
249 #define PI_CHAT 0x0004
250 /** Notable messages, e.g. an application returned an "usual" error code like HTTP 404 */
251 #define PI_NOTE 0x0008
252 /** Warning, e.g. application returned an "unusual" error code */
253 #define PI_WARN 0x000C
254 /** Serious problems, e.g. [Malformed Packet] */
255 #define PI_ERROR 0x0010
257 /* expert "event groups" */
258 #define PI_GROUP_MASK 0xFF00 /* mask usually for internal use only! */
259 /** The protocol field has a bad checksum, usually PI_WARN */
260 #define PI_CHECKSUM 0x0100
261 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
262 #define PI_SEQUENCE 0x0200
263 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
264 #define PI_RESPONSE_CODE 0x0400
265 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
266 #define PI_REQUEST_CODE 0x0500
267 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
268 #define PI_UNDECODED 0x0800
269 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
270 #define PI_REASSEMBLE 0x1000
271 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR */
272 #define PI_MALFORMED 0x2000
273 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR */
274 #define PI_DEBUG 0x4000
275 /** The protocol field indicates a security probem (e.g. unsecure implementation) */
276 /*#define PI_SECURITY 0x8000*/
278 /* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
281 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
282 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
283 #define PROTO_ITEM_IS_HIDDEN(proto_item) \
284 ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
285 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
286 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
287 #define PROTO_ITEM_SET_HIDDEN(proto_item) \
288 ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
289 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
290 #define PROTO_ITEM_IS_GENERATED(proto_item) \
291 ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
292 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
293 #define PROTO_ITEM_SET_GENERATED(proto_item) \
294 ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
295 /* is this protocol field actually a URL */
296 #define PROTO_ITEM_IS_URL(proto_item) \
297 ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_URL) : 0)
298 /* mark this protocol field as a URL */
299 #define PROTO_ITEM_SET_URL(proto_item) \
300 ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_URL) : 0)
302 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
304 extern void proto_tree_children_foreach(proto_tree *tree,
305 proto_tree_foreach_func func, gpointer data);
307 /** Retrieve the field_info from a proto_item */
308 #define PITEM_FINFO(proto_item) ((proto_item)->finfo)
310 /** Retrieve the tree_data_t from a proto_tree */
311 #define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
315 /** Sets up memory used by proto routines. Called at program startup */
316 extern void proto_init(const char *plugin_dir,
317 void (register_all_protocols)(void), void (register_all_handoffs)(void));
319 /** Frees memory used by proto routines. Called at program shutdown */
320 extern void proto_cleanup(void);
322 /** This function takes a tree and a protocol id as parameter and
323 will return TRUE/FALSE for whether the protocol or any of the filterable
324 fields in the protocol is referenced by any fitlers.
325 If this function returns FALSE then it is safe to skip any
326 proto_tree_add_...() calls and just treat the call as if the
327 dissector was called with tree==NULL.
328 If you reset the tree to NULL by this dissector returning FALSE,
329 you will still need to call any subdissector with the original value of
330 tree or filtering will break.
332 The purpose of this is to optimize wireshark for speed and make it
333 faster for when filters are being used.
335 extern gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
339 /** Create a subtree under an existing item.
340 @param ti the parent item of the new subtree
341 @param idx one of the ett_ array elements registered with proto_register_subtree_array()
342 @return the new subtree */
343 extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
345 /** Get an existing subtree under an item.
346 @param ti the parent item of the subtree
347 @return the subtree or NULL */
348 extern proto_tree* proto_item_get_subtree(proto_item *ti);
350 /** Get the parent of a subtree item.
351 @param ti the child item in the subtree
352 @return parent item or NULL */
353 extern proto_item* proto_item_get_parent(proto_item *ti);
355 /** Get Nth generation parent item.
356 @param ti the child item in the subtree
357 @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
358 @return parent item */
359 extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
361 /** Replace text of item after it already has been created.
362 @param ti the item to set the text
363 @param format printf like format string
364 @param ... printf like parameters */
365 extern void proto_item_set_text(proto_item *ti, const char *format, ...)
366 GNUC_FORMAT_CHECK(printf, 2,3);
368 /** Append to text of item after it has already been created.
369 @param ti the item to append the text to
370 @param format printf like format string
371 @param ... printf like parameters */
372 extern void proto_item_append_text(proto_item *ti, const char *format, ...)
373 GNUC_FORMAT_CHECK(printf, 2,3);
375 /** Set proto_item's length inside tvb, after it has already been created.
376 @param ti the item to set the length
377 @param length the new length ot the item */
378 extern void proto_item_set_len(proto_item *ti, gint length);
381 * Sets the length of the item based on its start and on the specified
382 * offset, which is the offset past the end of the item; as the start
383 * in the item is relative to the beginning of the data source tvbuff,
384 * we need to pass in a tvbuff.
385 @param ti the item to set the length
386 @param tvb end is relative to this tvbuff
387 @param end this end offset is relative to the beginning of tvb
388 @todo make usage clearer, I don't understand it!
390 extern void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
392 /** Get length of a proto_item. Useful after using proto_tree_add_item()
393 * to add a variable-length field (e.g., FT_NSTRING_UINT8).
394 @param ti the item to get the length from
395 @return the current length */
396 extern int proto_item_get_len(proto_item *ti);
399 * Sets an expert info to the proto_item.
400 @param ti the item to set the expert info
401 @param group the group of this info (e.g. PI_CHECKSUM)
402 @param severity of this info (e.g. PI_ERROR)
403 @return TRUE if value was written
405 extern gboolean proto_item_set_expert_flags(proto_item *ti, int group, int severity);
410 /** Creates a new proto_tree root.
411 @return the new tree root */
412 extern proto_tree* proto_tree_create_root(void);
414 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
415 @param tree the tree to free */
416 extern void proto_tree_free(proto_tree *tree);
418 /** Set the tree visible or invisible.
419 Is the parsing being done for a visible proto_tree or an invisible one?
420 By setting this correctly, the proto_tree creation is sped up by not
421 having to call g_vsnprintf and copy strings around.
422 @param tree the tree to be set
423 @param visible ... or not */
425 proto_tree_set_visible(proto_tree *tree, gboolean visible);
427 /** Mark a field/protocol ID as "interesting".
428 @param tree the tree to be set
429 @param hfid the interesting field id
430 @todo what *does* interesting mean? */
432 proto_tree_prime_hfid(proto_tree *tree, int hfid);
434 /** Get a parent item of a subtree.
435 @param tree the tree to get the parent from
436 @return parent item */
437 extern proto_item* proto_tree_get_parent(proto_tree *tree);
439 /** Get the root tree from any subtree.
440 @param tree the tree to get the root from
442 extern proto_tree* proto_tree_get_root(proto_tree *tree);
444 /** Move an existing item behind another existing item.
445 @param tree the tree to which both items belong
446 @param fixed_item the item which keeps it's position
447 @param item_to_move the item which will be moved */
448 extern void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
452 /** Add an item to a proto_tree, using the text label registered to that item.
453 The item is extracted from the tvbuff handed to it.
454 @param tree the tree to append this item to
455 @param hfindex field index
456 @param tvb the tv buffer of the current data
457 @param start start of data in tvb
458 @param length length of data in tvb
459 @param little_endian big or little endian byte representation
460 @return the newly created item */
462 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
463 gint start, gint length, gboolean little_endian);
465 /** Add a hidden item to a proto_tree.
466 @deprecated use proto_tree_add_item() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
468 proto_tree_add_item_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb,
469 gint start, gint length, gboolean little_endian);
471 /** Add a text-only node to a proto_tree.
472 @param tree the tree to append this item to
473 @param tvb the tv buffer of the current data
474 @param start start of data in tvb
475 @param length length of data in tvb
476 @param format printf like format string
477 @param ... printf like parameters
478 @return the newly created item */
480 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
481 ...) GNUC_FORMAT_CHECK(printf,5,6);
483 /** Add a text-only node to a proto_tree using a variable argument list.
484 @param tree the tree to append this item to
485 @param tvb the tv buffer of the current data
486 @param start start of data in tvb
487 @param length length of data in tvb
488 @param format printf like format string
489 @param ap variable argument list
490 @return the newly created item */
492 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
493 gint length, const char *format, va_list ap);
496 /** Add a FT_NONE field to a proto_tree.
497 @param tree the tree to append this item to
498 @param hfindex field index
499 @param tvb the tv buffer of the current data
500 @param start start of data in tvb
501 @param length length of data in tvb
502 @param format printf like format string
503 @param ... printf like parameters
504 @return the newly created item */
506 proto_tree_add_none_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
507 gint length, const char *format, ...) GNUC_FORMAT_CHECK(printf,6,7);
509 /** Add a FT_PROTOCOL to a proto_tree.
510 @param tree the tree to append this item to
511 @param hfindex field index
512 @param tvb the tv buffer of the current data
513 @param start start of data in tvb
514 @param length length of data in tvb
515 @param format printf like format string
516 @param ... printf like parameters
517 @return the newly created item */
519 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
520 gint length, const char *format, ...) GNUC_FORMAT_CHECK(printf,6,7);
525 /** Add a FT_BYTES to a proto_tree.
526 @param tree the tree to append this item to
527 @param hfindex field index
528 @param tvb the tv buffer of the current data
529 @param start start of data in tvb
530 @param length length of data in tvb
531 @param start_ptr pointer to the data to display
532 @return the newly created item */
534 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
535 gint length, const guint8* start_ptr);
537 /** Add a hidden FT_BYTES to a proto_tree.
538 @deprecated use proto_tree_add_bytes() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
540 proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
541 gint length, const guint8* start_ptr);
543 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
544 the string for the value and with the field name being included
546 @param tree the tree to append this item to
547 @param hfindex field index
548 @param tvb the tv buffer of the current data
549 @param start start of data in tvb
550 @param length length of data in tvb
551 @param start_ptr pointer to the data to display
552 @param format printf like format string
553 @param ... printf like parameters
554 @return the newly created item */
556 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
557 gint start, gint length, const guint8* start_ptr, const char *format,
558 ...) GNUC_FORMAT_CHECK(printf,7,8);
560 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
561 the entire string for the entry, including any field name.
562 @param tree the tree to append this item to
563 @param hfindex field index
564 @param tvb the tv buffer of the current data
565 @param start start of data in tvb
566 @param length length of data in tvb
567 @param start_ptr pointer to the data to display
568 @param format printf like format string
569 @param ... printf like parameters
570 @return the newly created item */
572 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
573 gint length, const guint8* start_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
575 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
576 @param tree the tree to append this item to
577 @param hfindex field index
578 @param tvb the tv buffer of the current data
579 @param start start of data in tvb
580 @param length length of data in tvb
581 @param value_ptr pointer to the data to display
582 @return the newly created item */
584 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
585 gint length, nstime_t* value_ptr);
587 /** Add a hidden FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
588 @deprecated use proto_tree_add_time() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
590 proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
591 gint length, nstime_t* value_ptr);
593 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
594 the format generating the string for the value and with the field name
595 being included automatically.
596 @param tree the tree to append this item to
597 @param hfindex field index
598 @param tvb the tv buffer of the current data
599 @param start start of data in tvb
600 @param length length of data in tvb
601 @param value_ptr pointer to the data to display
602 @param format printf like format string
603 @param ... printf like parameters
604 @return the newly created item */
606 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
607 gint start, gint length, nstime_t* value_ptr, const char *format, ...)
608 GNUC_FORMAT_CHECK(printf,7,8);
610 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
611 the format generating the entire string for the entry, including any field
613 @param tree the tree to append this item to
614 @param hfindex field index
615 @param tvb the tv buffer of the current data
616 @param start start of data in tvb
617 @param length length of data in tvb
618 @param value_ptr pointer to the data to display
619 @param format printf like format string
620 @param ... printf like parameters
621 @return the newly created item */
623 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
624 gint length, nstime_t* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
626 /** Add a FT_IPXNET to a proto_tree.
627 @param tree the tree to append this item to
628 @param hfindex field index
629 @param tvb the tv buffer of the current data
630 @param start start of data in tvb
631 @param length length of data in tvb
632 @param value data to display
633 @return the newly created item */
635 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
636 gint length, guint32 value);
638 /** Add a hidden FT_IPXNET to a proto_tree.
639 @deprecated use proto_tree_add_ipxnet() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
641 proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
642 gint length, guint32 value);
644 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
645 the string for the value and with the field name being included
647 @param tree the tree to append this item to
648 @param hfindex field index
649 @param tvb the tv buffer of the current data
650 @param start start of data in tvb
651 @param length length of data in tvb
652 @param value data to display
653 @param format printf like format string
654 @param ... printf like parameters
655 @return the newly created item */
657 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
658 gint start, gint length, guint32 value, const char *format, ...)
659 GNUC_FORMAT_CHECK(printf,7,8);
661 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
662 the entire string for the entry, including any field name.
663 @param tree the tree to append this item to
664 @param hfindex field index
665 @param tvb the tv buffer of the current data
666 @param start start of data in tvb
667 @param length length of data in tvb
668 @param value data to display
669 @param format printf like format string
670 @param ... printf like parameters
671 @return the newly created item */
673 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
674 gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
676 /** Add a FT_IPv4 to a proto_tree.
677 @param tree the tree to append this item to
678 @param hfindex field index
679 @param tvb the tv buffer of the current data
680 @param start start of data in tvb
681 @param length length of data in tvb
682 @param value data to display
683 @return the newly created item */
685 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
686 gint length, guint32 value);
688 /** Add a hidden FT_IPv4 to a proto_tree.
689 @deprecated use proto_tree_add_ipv4() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
691 proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
692 gint length, guint32 value);
694 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
695 the string for the value and with the field name being included
697 @param tree the tree to append this item to
698 @param hfindex field index
699 @param tvb the tv buffer of the current data
700 @param start start of data in tvb
701 @param length length of data in tvb
702 @param value data to display
703 @param format printf like format string
704 @param ... printf like parameters
705 @return the newly created item */
707 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
708 gint start, gint length, guint32 value, const char *format, ...)
709 GNUC_FORMAT_CHECK(printf,7,8);
711 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
712 the entire string for the entry, including any field name.
713 @param tree the tree to append this item to
714 @param hfindex field index
715 @param tvb the tv buffer of the current data
716 @param start start of data in tvb
717 @param length length of data in tvb
718 @param value data to display
719 @param format printf like format string
720 @param ... printf like parameters
721 @return the newly created item */
723 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
724 gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
726 /** Add a FT_IPv6 to a proto_tree.
727 @param tree the tree to append this item to
728 @param hfindex field index
729 @param tvb the tv buffer of the current data
730 @param start start of data in tvb
731 @param length length of data in tvb
732 @param value_ptr data to display
733 @return the newly created item */
735 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
736 gint length, const guint8* value_ptr);
738 /** Add a hidden FT_IPv6 to a proto_tree.
739 @deprecated use proto_tree_add_ipv6() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
741 proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
742 gint length, const guint8* value_ptr);
744 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
745 the string for the value and with the field name being included
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 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_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
758 gint start, gint length, const guint8* value_ptr, const char *format,
759 ...) GNUC_FORMAT_CHECK(printf,7,8);
761 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
762 the entire string for the entry, including any field name.
763 @param tree the tree to append this item to
764 @param hfindex field index
765 @param tvb the tv buffer of the current data
766 @param start start of data in tvb
767 @param length length of data in tvb
768 @param value_ptr data to display
769 @param format printf like format string
770 @param ... printf like parameters
771 @return the newly created item */
773 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
774 gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
776 /** Add a FT_ETHER to a proto_tree.
777 @param tree the tree to append this item to
778 @param hfindex field index
779 @param tvb the tv buffer of the current data
780 @param start start of data in tvb
781 @param length length of data in tvb
782 @param value data to display
783 @return the newly created item */
785 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
786 gint length, const guint8* value);
788 /** Add a hidden FT_ETHER to a proto_tree.
789 @deprecated use proto_tree_add_ether() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
791 proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
792 gint length, const guint8* value);
794 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
795 the string for the value and with the field name being included
797 @param tree the tree to append this item to
798 @param hfindex field index
799 @param tvb the tv buffer of the current data
800 @param start start of data in tvb
801 @param length length of data in tvb
802 @param value data to display
803 @param format printf like format string
804 @param ... printf like parameters
805 @return the newly created item */
807 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
808 gint start, gint length, const guint8* value, const char *format, ...)
809 GNUC_FORMAT_CHECK(printf,7,8);
811 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
812 the entire string for the entry, including any field name.
813 @param tree the tree to append this item to
814 @param hfindex field index
815 @param tvb the tv buffer of the current data
816 @param start start of data in tvb
817 @param length length of data in tvb
818 @param value data to display
819 @param format printf like format string
820 @param ... printf like parameters
821 @return the newly created item */
823 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
824 gint length, const guint8* value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
826 /** Add a FT_GUID to a proto_tree.
827 @param tree the tree to append this item to
828 @param hfindex field index
829 @param tvb the tv buffer of the current data
830 @param start start of data in tvb
831 @param length length of data in tvb
832 @param value_ptr data to display
833 @return the newly created item */
835 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
836 gint length, const e_guid_t *value_ptr);
838 /** Add a hidden FT_GUID to a proto_tree.
839 @deprecated use proto_tree_add_guid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
841 proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
842 gint length, const e_guid_t *value_ptr);
844 /** Add a formatted FT_GUID to a proto_tree, with the format generating
845 the string for the value and with the field name being included
847 @param tree the tree to append this item to
848 @param hfindex field index
849 @param tvb the tv buffer of the current data
850 @param start start of data in tvb
851 @param length length of data in tvb
852 @param value_ptr data to display
853 @param format printf like format string
854 @param ... printf like parameters
855 @return the newly created item */
857 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
858 gint start, gint length, const e_guid_t *value_ptr, const char *format,
859 ...) GNUC_FORMAT_CHECK(printf,7,8);
861 /** Add a formatted FT_GUID to a proto_tree, with the format generating
862 the entire string for the entry, including any field name.
863 @param tree the tree to append this item to
864 @param hfindex field index
865 @param tvb the tv buffer of the current data
866 @param start start of data in tvb
867 @param length length of data in tvb
868 @param value_ptr data to display
869 @param format printf like format string
870 @param ... printf like parameters
871 @return the newly created item */
873 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
874 gint length, const e_guid_t *value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
876 /** Add a FT_OID to a proto_tree.
877 @param tree the tree to append this item to
878 @param hfindex field index
879 @param tvb the tv buffer of the current data
880 @param start start of data in tvb
881 @param length length of data in tvb
882 @param value_ptr data to display
883 @return the newly created item */
885 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
886 gint length, const guint8* value_ptr);
888 /** Add a hidden FT_OID to a proto_tree.
889 @deprecated use proto_tree_add_oid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
891 proto_tree_add_oid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
892 gint length, const guint8* value_ptr);
894 /** Add a formatted FT_OID to a proto_tree, with the format generating
895 the string for the value and with the field name being included
897 @param tree the tree to append this item to
898 @param hfindex field index
899 @param tvb the tv buffer of the current data
900 @param start start of data in tvb
901 @param length length of data in tvb
902 @param value_ptr data to display
903 @param format printf like format string
904 @param ... printf like parameters
905 @return the newly created item */
907 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
908 gint start, gint length, const guint8* value_ptr, const char *format,
909 ...) GNUC_FORMAT_CHECK(printf,7,8);
911 /** Add a formatted FT_OID to a proto_tree, with the format generating
912 the entire string for the entry, including any field name.
913 @param tree the tree to append this item to
914 @param hfindex field index
915 @param tvb the tv buffer of the current data
916 @param start start of data in tvb
917 @param length length of data in tvb
918 @param value_ptr data to display
919 @param format printf like format string
920 @param ... printf like parameters
921 @return the newly created item */
923 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
924 gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
926 /** Add a FT_STRING to a proto_tree.
927 @param tree the tree to append this item to
928 @param hfindex field index
929 @param tvb the tv buffer of the current data
930 @param start start of data in tvb
931 @param length length of data in tvb
932 @param value data to display
933 @return the newly created item */
935 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
936 gint length, const char* value);
938 /** Add a hidden FT_STRING to a proto_tree.
939 @deprecated use proto_tree_add_string() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
941 proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
942 gint length, const char* value);
944 /** Add a formatted FT_STRING to a proto_tree, with the format generating
945 the string for the value and with the field name being included
947 @param tree the tree to append this item to
948 @param hfindex field index
949 @param tvb the tv buffer of the current data
950 @param start start of data in tvb
951 @param length length of data in tvb
952 @param value data to display
953 @param format printf like format string
954 @param ... printf like parameters
955 @return the newly created item */
957 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
958 gint start, gint length, const char* value, const char *format, ...)
959 GNUC_FORMAT_CHECK(printf,7,8);
961 /** Add a formatted FT_STRING to a proto_tree, with the format generating
962 the entire string for the entry, including any field name.
963 @param tree the tree to append this item to
964 @param hfindex field index
965 @param tvb the tv buffer of the current data
966 @param start start of data in tvb
967 @param length length of data in tvb
968 @param value data to display
969 @param format printf like format string
970 @param ... printf like parameters
971 @return the newly created item */
973 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
974 gint length, const char* value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
976 /** Add a FT_BOOLEAN to a proto_tree.
977 @param tree the tree to append this item to
978 @param hfindex field index
979 @param tvb the tv buffer of the current data
980 @param start start of data in tvb
981 @param length length of data in tvb
982 @param value data to display
983 @return the newly created item */
985 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
986 gint length, guint32 value);
988 /** Add a hidden FT_BOOLEAN to a proto_tree.
989 @deprecated use proto_tree_add_boolean() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
991 proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
992 gint length, guint32 value);
994 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
995 the string for the value and with the field name being included
997 @param tree the tree to append this item to
998 @param hfindex field index
999 @param tvb the tv buffer of the current data
1000 @param start start of data in tvb
1001 @param length length of data in tvb
1002 @param value data to display
1003 @param format printf like format string
1004 @param ... printf like parameters
1005 @return the newly created item */
1007 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1008 tvbuff_t *tvb, gint start, gint length, guint32 value,
1009 const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1011 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1012 the entire string for the entry, including any field name.
1013 @param tree the tree to append this item to
1014 @param hfindex field index
1015 @param tvb the tv buffer of the current data
1016 @param start start of data in tvb
1017 @param length length of data in tvb
1018 @param value data to display
1019 @param format printf like format string
1020 @param ... printf like parameters
1021 @return the newly created item */
1023 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1024 gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1026 /** Add a FT_FLOAT to a proto_tree.
1027 @param tree the tree to append this item to
1028 @param hfindex field index
1029 @param tvb the tv buffer of the current data
1030 @param start start of data in tvb
1031 @param length length of data in tvb
1032 @param value data to display
1033 @return the newly created item */
1035 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1036 gint length, float value);
1038 /** Add a hidden FT_FLOAT to a proto_tree.
1039 @deprecated use proto_tree_add_float() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1041 proto_tree_add_float_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1042 gint length, float value);
1044 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1045 the string for the value and with the field name being included
1047 @param tree the tree to append this item to
1048 @param hfindex field index
1049 @param tvb the tv buffer of the current data
1050 @param start start of data in tvb
1051 @param length length of data in tvb
1052 @param value data to display
1053 @param format printf like format string
1054 @param ... printf like parameters
1055 @return the newly created item */
1057 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1058 gint start, gint length, float value, const char *format, ...)
1059 GNUC_FORMAT_CHECK(printf,7,8);
1061 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1062 the entire string for the entry, including any field name.
1063 @param tree the tree to append this item to
1064 @param hfindex field index
1065 @param tvb the tv buffer of the current data
1066 @param start start of data in tvb
1067 @param length length of data in tvb
1068 @param value data to display
1069 @param format printf like format string
1070 @param ... printf like parameters
1071 @return the newly created item */
1073 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1074 gint length, float value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1076 /** Add a FT_DOUBLE to a proto_tree.
1077 @param tree the tree to append this item to
1078 @param hfindex field index
1079 @param tvb the tv buffer of the current data
1080 @param start start of data in tvb
1081 @param length length of data in tvb
1082 @param value data to display
1083 @return the newly created item */
1085 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1086 gint length, double value);
1088 /** Add a hidden FT_DOUBLE to a proto_tree.
1089 @deprecated use proto_tree_add_double() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1091 proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1092 gint length, double value);
1094 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1095 the string for the value and with the field name being included
1097 @param tree the tree to append this item to
1098 @param hfindex field index
1099 @param tvb the tv buffer of the current data
1100 @param start start of data in tvb
1101 @param length length of data in tvb
1102 @param value data to display
1103 @param format printf like format string
1104 @param ... printf like parameters
1105 @return the newly created item */
1107 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1108 gint start, gint length, double value, const char *format, ...)
1109 GNUC_FORMAT_CHECK(printf,7,8);
1111 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1112 the entire string for the entry, including any field name.
1113 @param tree the tree to append this item to
1114 @param hfindex field index
1115 @param tvb the tv buffer of the current data
1116 @param start start of data in tvb
1117 @param length length of data in tvb
1118 @param value data to display
1119 @param format printf like format string
1120 @param ... printf like parameters
1121 @return the newly created item */
1123 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1124 gint length, double value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1126 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1127 @param tree the tree to append this item to
1128 @param hfindex field index
1129 @param tvb the tv buffer of the current data
1130 @param start start of data in tvb
1131 @param length length of data in tvb
1132 @param value data to display
1133 @return the newly created item */
1135 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1136 gint length, guint32 value);
1138 /** Add a hidden FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1139 @deprecated use proto_tree_add_uint() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1141 proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1142 gint length, guint32 value);
1144 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1145 with the format generating the string for the value and with the field
1146 name being included automatically.
1147 @param tree the tree to append this item to
1148 @param hfindex field index
1149 @param tvb the tv buffer of the current data
1150 @param start start of data in tvb
1151 @param length length of data in tvb
1152 @param value data to display
1153 @param format printf like format string
1154 @param ... printf like parameters
1155 @return the newly created item */
1157 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1158 gint start, gint length, guint32 value, const char *format, ...)
1159 GNUC_FORMAT_CHECK(printf,7,8);
1161 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1162 with the format generating the entire string for the entry, including any
1164 @param tree the tree to append this item to
1165 @param hfindex field index
1166 @param tvb the tv buffer of the current data
1167 @param start start of data in tvb
1168 @param length length of data in tvb
1169 @param value data to display
1170 @param format printf like format string
1171 @param ... printf like parameters
1172 @return the newly created item */
1174 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1175 gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1177 /** Add an FT_UINT64 to a proto_tree.
1178 @param tree the tree to append this item to
1179 @param hfindex field index
1180 @param tvb the tv buffer of the current data
1181 @param start start of data in tvb
1182 @param length length of data in tvb
1183 @param value data to display
1184 @return the newly created item */
1186 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1187 gint length, guint64 value);
1189 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1190 the string for the value and with the field name being included
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_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1203 gint start, gint length, guint64 value, const char *format, ...)
1204 GNUC_FORMAT_CHECK(printf,7,8);
1206 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1207 the entire string for the entry, including any field name.
1208 @param tree the tree to append this item to
1209 @param hfindex field index
1210 @param tvb the tv buffer of the current data
1211 @param start start of data in tvb
1212 @param length length of data in tvb
1213 @param value data to display
1214 @param format printf like format string
1215 @param ... printf like parameters
1216 @return the newly created item */
1218 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1219 gint length, guint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1221 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1222 @param tree the tree to append this item to
1223 @param hfindex field index
1224 @param tvb the tv buffer of the current data
1225 @param start start of data in tvb
1226 @param length length of data in tvb
1227 @param value data to display
1228 @return the newly created item */
1230 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1231 gint length, gint32 value);
1233 /** Add a hidden FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1234 @deprecated use proto_tree_add_int() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1236 proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1237 gint length, gint32 value);
1239 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1240 with the format generating the string for the value and with the field
1241 name being included automatically.
1242 @param tree the tree to append this item to
1243 @param hfindex field index
1244 @param tvb the tv buffer of the current data
1245 @param start start of data in tvb
1246 @param length length of data in tvb
1247 @param value data to display
1248 @param format printf like format string
1249 @param ... printf like parameters
1250 @return the newly created item */
1252 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1253 gint start, gint length, gint32 value, const char *format, ...)
1254 GNUC_FORMAT_CHECK(printf,7,8);
1256 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1257 with the format generating the entire string for the entry, including
1259 @param tree the tree to append this item to
1260 @param hfindex field index
1261 @param tvb the tv buffer of the current data
1262 @param start start of data in tvb
1263 @param length length of data in tvb
1264 @param value data to display
1265 @param format printf like format string
1266 @param ... printf like parameters
1267 @return the newly created item */
1269 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1270 gint length, gint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1272 /** Add an FT_INT64 to a proto_tree.
1273 @param tree the tree to append this item to
1274 @param hfindex field index
1275 @param tvb the tv buffer of the current data
1276 @param start start of data in tvb
1277 @param length length of data in tvb
1278 @param value data to display
1279 @return the newly created item */
1281 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1282 gint length, gint64 value);
1284 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1285 the string for the value and with the field name being included
1287 @param tree the tree to append this item to
1288 @param hfindex field index
1289 @param tvb the tv buffer of the current data
1290 @param start start of data in tvb
1291 @param length length of data in tvb
1292 @param value data to display
1293 @param format printf like format string
1294 @param ... printf like parameters
1295 @return the newly created item */
1297 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1298 gint start, gint length, gint64 value, const char *format, ...)
1299 GNUC_FORMAT_CHECK(printf,7,8);
1301 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1302 the entire string for the entry, including any field name.
1303 @param tree the tree to append this item to
1304 @param hfindex field index
1305 @param tvb the tv buffer of the current data
1306 @param start start of data in tvb
1307 @param length length of data in tvb
1308 @param value data to display
1309 @param format printf like format string
1310 @param ... printf like parameters
1311 @return the newly created item */
1313 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1314 gint length, gint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1316 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1317 * leave call to this function in production code.
1318 @param tree the tree to append the text to
1319 @param format printf like format string
1320 @param ... printf like parameters
1321 @return the newly created item */
1323 proto_tree_add_debug_text(proto_tree *tree, const char *format,
1324 ...) GNUC_FORMAT_CHECK(printf,2,3);
1328 /** Append a string to a protocol item.<br>
1329 NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1331 Currently only WSP use this function so it is not that bad but try to
1332 avoid using this one if possible.
1333 IF you must use this function you MUST also disable the
1334 TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1335 using proto_item_append_string().
1336 Do that by faking that the tree is visible by setting :
1337 PTREE_DATA(tree)->visible=1; (see packet-wsp.c)
1338 BEFORE you create the item you are later going to use
1339 proto_item_append_string() on.
1341 @param pi the item to append the string to
1342 @param str the string to append */
1344 proto_item_append_string(proto_item *pi, const char *str);
1348 /** Fill given label_str with string representation of field
1349 @param fi the item to get the info from
1350 @param label_str the string to fill
1351 @todo think about changing the parameter profile */
1353 proto_item_fill_label(field_info *fi, gchar *label_str);
1356 /** Register a new protocol.
1357 @param name the full name of the new protocol
1358 @param short_name abbreviated name of the new protocol
1359 @param filter_name protocol name used for a display filter string
1360 @return the new protocol handle */
1362 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
1364 /** Register a header_field array.
1365 @param parent the protocol handle from proto_register_protocol()
1366 @param hf the hf_register_info array
1367 @param num_records the number of records in hf */
1369 proto_register_field_array(int parent, hf_register_info *hf, int num_records);
1371 /** Register a protocol subtree (ett) array.
1372 @param indices array of ett indices
1373 @param num_indices the number of records in indices */
1375 proto_register_subtree_array(gint *const *indices, int num_indices);
1377 /** Returns number of items (protocols or header fields) registered.
1378 @return the number of items */
1379 extern int proto_registrar_n(void);
1381 /** Get name of registered header_field number n.
1382 @param n item # n (0-indexed)
1383 @return the name of this registered item */
1384 extern const char* proto_registrar_get_name(int n);
1386 /** Get abbreviation of registered header_field number n.
1387 @param n item # n (0-indexed)
1388 @return the abbreviation of this registered item */
1389 extern const char* proto_registrar_get_abbrev(int n);
1391 /** Get the header_field information based upon a field or protocol id.
1392 @param hfindex item # n (0-indexed)
1393 @return the registered item */
1394 extern header_field_info* proto_registrar_get_nth(guint hfindex);
1396 /** Get the header_field information based upon a field name.
1397 @param field_name the field name to search for
1398 @return the registered item */
1399 extern header_field_info* proto_registrar_get_byname(const char *field_name);
1401 /** Get enum ftenum FT_ of registered header_field number n.
1402 @param n item # n (0-indexed)
1403 @return the registered item */
1404 extern int proto_registrar_get_ftype(int n);
1406 /** Get parent protocol of registered header_field number n.
1407 @param n item # n (0-indexed)
1408 @return -1 if item _is_ a protocol */
1409 extern int proto_registrar_get_parent(int n);
1411 /** Is item # n a protocol?
1412 @param n item # n (0-indexed)
1413 @return TRUE if it's a protocol, FALSE if it's not */
1414 extern gboolean proto_registrar_is_protocol(int n);
1416 /* Get length of registered field according to field type.
1417 @param n item # n (0-indexed)
1418 @return 0 means undeterminable at registration time, * -1 means unknown field */
1419 extern gint proto_registrar_get_length(int n);
1422 /* Routines to use to iterate over the protocols and their fields;
1423 * they return the item number of the protocol in question or the
1424 * appropriate hfinfo pointer, and keep state in "*cookie". */
1425 extern int proto_get_first_protocol(void **cookie);
1426 extern int proto_get_next_protocol(void **cookie);
1427 extern header_field_info *proto_get_first_protocol_field(int proto_id, void **cookle);
1428 extern header_field_info *proto_get_next_protocol_field(void **cookle);
1430 /** Given a protocol's filter_name.
1431 @param filter_name the filter name to search for
1433 extern int proto_get_id_by_filter_name(const gchar* filter_name);
1435 /** Can item # n decoding be disabled?
1436 @param proto_id protocol id (0-indexed)
1437 @return TRUE if it's a protocol, FALSE if it's not */
1438 extern gboolean proto_can_toggle_protocol(int proto_id);
1440 /** Get the "protocol_t" structure for the given protocol's item number.
1441 @param proto_id protocol id (0-indexed) */
1442 extern protocol_t *find_protocol_by_id(int proto_id);
1444 /** Get the protocol's name for the given protocol's item number.
1445 @param proto_id protocol id (0-indexed)
1447 extern const char *proto_get_protocol_name(int proto_id);
1449 /** Get the protocol's item number, for the given protocol's "protocol_t".
1450 @return its proto_id */
1451 extern int proto_get_id(protocol_t *protocol);
1453 /** Get the protocol's short name, for the given protocol's "protocol_t".
1454 @return its short name. */
1455 extern const char *proto_get_protocol_short_name(protocol_t *protocol);
1457 /** Is protocol's decoding enabled ?
1459 @return TRUE if decoding is enabled, FALSE if not */
1460 extern gboolean proto_is_protocol_enabled(protocol_t *protocol);
1462 /** Get a protocol's filter name by it's item number.
1463 @param proto_id protocol id (0-indexed)
1464 @return its filter name. */
1465 extern const char *proto_get_protocol_filter_name(int proto_id);
1467 /** Enable / Disable protocol of the given item number.
1468 @param proto_id protocol id (0-indexed)
1469 @param enabled enable / disable the protocol */
1470 extern void proto_set_decoding(int proto_id, gboolean enabled);
1472 /** Disable disabling/enabling of protocol of the given item number.
1473 @param proto_id protocol id (0-indexed) */
1474 extern void proto_set_cant_toggle(int proto_id);
1476 /** Checks for existence any protocol or field within a tree.
1477 @param tree "Protocols" are assumed to be a child of the [empty] root node.
1479 @return TRUE = found, FALSE = not found
1480 @todo add explanation of id parameter */
1481 extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id);
1483 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
1484 * tree. Only works with primed trees, and is fast. */
1485 extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
1487 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
1488 * tree. Works with any tree, primed or unprimed, and is slower than
1489 * proto_get_finfo_ptr_array because it has to search through the tree. */
1490 extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
1492 /* Return GPtrArray* of field_info pointers containg all hfindexes that appear in
1494 extern GPtrArray* proto_all_finfos(proto_tree *tree);
1496 /** Dumps a glossary of the protocol registrations to STDOUT */
1497 extern void proto_registrar_dump_protocols(void);
1499 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
1500 extern void proto_registrar_dump_values(void);
1502 /** Dumps a glossary of the protocol and field registrations to STDOUT.
1503 * Format 1 is the original format. Format 2 includes the base (for integers)
1505 extern void proto_registrar_dump_fields(int format);
1509 /** Points to the first element of an array of Booleans, indexed by
1510 a subtree item type. That array element is TRUE if subtrees of
1511 an item of that type are to be expanded. With MSVC and a
1512 libwireshark.dll, we need a special declaration. */
1513 WS_VAR_IMPORT gboolean *tree_is_expanded;
1515 /** Number of elements in the tree_is_expanded array. With MSVC and a
1516 * libwireshark.dll, we need a special declaration. */
1517 WS_VAR_IMPORT int num_tree_types;
1519 /** glib doesn't have g_ptr_array_len of all things!*/
1520 #ifndef g_ptr_array_len
1521 #define g_ptr_array_len(a) ((a)->len)
1524 /** Get number of bits of a header_field.
1525 @param hfinfo header_field
1526 @return the bitwidth */
1528 hfinfo_bitwidth(header_field_info *hfinfo);
1535 /** Can we do a "match selected" on this field.
1536 @param finfo field_info
1537 @param edt epan dissecting
1538 @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
1540 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
1542 /** Construct a display filter string.
1543 @param finfo field_info
1544 @param edt epan dissecting
1545 @return the display filter string */
1547 proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt);
1549 /** Find field from offset in tvb.
1551 @param offset offset in the tvb
1552 @param tvb the tv buffer
1553 @return the corresponding field_info */
1555 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
1557 #endif /* proto.h */