Add:
[obnox/wireshark/wip.git] / epan / proto.h
1 /* proto.h
2  * Definitions for protocol display
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
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.
14  *
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.
19  *
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.
23  */
24
25
26 /*! @file proto.h
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().
35 */
36
37 #ifndef __PROTO_H__
38 #define __PROTO_H__
39
40 #ifdef HAVE_STDARG_H
41 # include <stdarg.h>
42 #else
43 # include <varargs.h>
44 #endif
45
46 #include <glib.h>
47
48 #include "gnuc_format_check.h"
49 #include "ipv4.h"
50 #include "nstime.h"
51 #include "tvbuff.h"
52 #include "ftypes/ftypes.h"
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif /* __cplusplus */
57
58 /** The header-field index for the special text pseudo-field. Exported by libwireshark.dll */
59 WS_VAR_IMPORT int hf_text_only;
60
61 /** the maximum length of a protocol field string representation */
62 #define ITEM_LABEL_LENGTH       240
63
64 struct _value_string;
65
66 /** Make a const value_string[] look like a _value_string pointer, used to set header_field_info.strings */
67 #define VALS(x) (const struct _value_string*)(x)
68
69 /** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
70 #define TFS(x)  (const struct true_false_string*)(x)
71
72 /** Make a const range_string[] look like a _range_string pointer, used to set
73  * header_field_info.strings */
74 #define RVALS(x) (const struct _range_string*)(x)
75
76 struct _protocol;
77
78 /** Structure for information about a protocol */
79 typedef struct _protocol protocol_t;
80  
81 /** check protocol activation
82  * @todo this macro looks like a hack */
83 #define CHECK_DISPLAY_AS_X(x_handle,index, tvb, pinfo, tree) {  \
84         if (!proto_is_protocol_enabled(find_protocol_by_id(index))) {   \
85                 call_dissector(x_handle,tvb, pinfo, tree);              \
86                 return;                                                 \
87         }                                                               \
88   }
89
90 /** Macro used for reporting errors in dissectors; it throws a
91  * DissectorError exception, with the string passed as an argument
92  * as the message for the exception, so that it can show up in
93  * the Info column and the protocol tree.
94  *
95  * If that string is dynamically allocated, it should be allocated with
96  * ep_alloc(); using ep_strdup_printf() would work.
97  *
98  * If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
99  * it will call abort(), instead, to make it easier to get a stack trace.
100  *
101  * @param message string to use as the message
102  */
103 #define REPORT_DISSECTOR_BUG(message)  \
104   ((getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) ? \
105     abort() : \
106     THROW_MESSAGE(DissectorError, message))
107
108 /** Macro used for assertions in dissectors; it doesn't abort, it just
109  * throws a DissectorError exception, with the assertion failure
110  * message as a parameter, so that it can show up in the protocol tree.
111  *
112  * @param expression expression to test in the assertion
113  */
114 #define DISSECTOR_ASSERT(expression)  \
115   ((void) ((expression) ? (void)0 : \
116    __DISSECTOR_ASSERT (expression, __FILE__, __LINE__)))
117
118 #if 0
119 /* win32: using a debug breakpoint (int 3) can be very handy while debugging, 
120  * as the assert handling of GTK/GLib is currently not very helpful */
121 #define DISSECTOR_ASSERT(expression)  \
122 { if(!(expression)) _asm { int 3}; }
123 #endif
124
125 /** Same as DISSECTOR_ASSERT(), but will throw DissectorError exception
126  * unconditionally, much like GLIB's g_assert_not_reached works.
127  */
128 #define DISSECTOR_ASSERT_NOT_REACHED()  \
129   (REPORT_DISSECTOR_BUG( \
130     ep_strdup_printf("%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"", \
131      __FILE__, __LINE__)))
132
133 #define __DISSECTOR_ASSERT_STRINGIFY(s) # s
134
135 #define __DISSECTOR_ASSERT(expression, file, lineno)  \
136   (REPORT_DISSECTOR_BUG( \
137     ep_strdup_printf("%s:%u: failed assertion \"%s\"", \
138      file, lineno, __DISSECTOR_ASSERT_STRINGIFY(expression))))
139
140 /* BASE_STRUCTURE_RESET constant is used in proto.c to reset the bits
141  * identifying special structures used in translation of value for display. 
142  * Its value means that we may have at most 16 base_display_e values */
143 #define BASE_STRUCTURE_RESET 0x0F
144 /* Following constants have to be ORed with a base_display_e when dissector
145  * want to use specials MACROs (for the moment, only RVALS) for a
146  * header_field_info */
147 #define BASE_RANGE_STRING 0x10
148 /** radix for decimal values, used in header_field_info.display */
149 typedef enum {
150         BASE_NONE,      /**< none */
151         BASE_DEC,       /**< decimal */
152         BASE_HEX,       /**< hexadecimal */
153         BASE_OCT,       /**< octal */
154         BASE_DEC_HEX,   /**< decimal (hexadecimal) */
155         BASE_HEX_DEC    /**< hexadecimal (decimal) */
156 } base_display_e;
157
158 #define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)
159
160 /** information describing a header field */
161 typedef struct _header_field_info header_field_info;
162
163 /** information describing a header field */
164 struct _header_field_info {
165         /* ---------- set by dissector --------- */
166         const char                              *name;      /**< full name of this field */
167         const char                              *abbrev;    /**< abbreviated name of this field */
168         enum ftenum                     type;       /**< field type, one of FT_ (from ftypes.h) */
169         int                                     display;        /**< one of BASE_, or number of field bits for FT_BOOLEAN */
170         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*/
171         guint32                         bitmask;    /**< FT_BOOLEAN only: bitmask of interesting bits */
172         const char                              *blurb;         /**< Brief description of field. */
173
174         /* ------- set by proto routines (prefilled by HFILL macro, see below) ------ */
175         int                             id;             /**< Field ID */
176         int                             parent;         /**< parent protocol tree */
177                 /* This field keeps track of whether a field is 
178                  * referenced in any filter or not and if so how 
179                  * many times. If a filter is being referenced the 
180                  * refcount for the parent protocol is updated as well 
181                  */
182         int                             ref_count;      /**< is this field referenced by a filter or not */
183         int                             bitshift;       /**< bits to shift (FT_BOOLEAN only) */
184         header_field_info               *same_name_next; /**< Link to next hfinfo with same abbrev*/
185         header_field_info               *same_name_prev; /**< Link to previous hfinfo with same abbrev*/
186 };
187
188 /**
189  * HFILL initializes all the "set by proto routines" fields in a
190  * _header_field_info. If new fields are added or removed, it should
191  * be changed as necessary.
192  */
193 #define HFILL 0, 0, 0, 0, NULL, NULL
194
195 /** Used when registering many fields at once, using proto_register_field_array() */
196 typedef struct hf_register_info {
197         int                     *p_id;  /**< written to by register() function */
198         header_field_info       hfinfo; /**< the field info to be registered */
199 } hf_register_info;
200
201
202
203
204 /** string representation, if one of the proto_tree_add_..._format() functions used */
205 typedef struct _item_label_t {
206         char representation[ITEM_LABEL_LENGTH];
207 } item_label_t;
208
209
210 /** Contains the field information for the proto_item. */
211 typedef struct field_info {
212         header_field_info       *hfinfo;    /**< pointer to registered field information */
213         gint                    start;      /**< current start of data in field_info.ds_tvb */
214         gint                    length;     /**< current data length of item in field_info.ds_tvb */
215         gint                    tree_type;  /**< one of ETT_ or -1 */
216         item_label_t            *rep;       /**< string for GUI tree */
217         int                     flags;      /**< bitfield like FI_GENERATED, ... */
218         tvbuff_t                *ds_tvb;    /**< data source tvbuff */
219         fvalue_t                value;
220 } field_info;
221
222
223 /** The protocol field should not be shown in the tree (it's used for filtering only), 
224  * used in field_info.flags. */
225 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
226 #define FI_HIDDEN                       0x0001
227 /** The protocol field should be displayed as "generated by Wireshark",
228  * used in field_info.flags. */
229 #define FI_GENERATED            0x0002
230 /* The protocol field is actually a URL */
231 #define FI_URL                  0x0004
232
233
234 /** convenience macro to get field_info.flags */
235 #define FI_GET_FLAG(fi, flag) (fi->flags & flag)
236 /** convenience macro to set field_info.flags */
237 #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag)
238
239 /** One of these exists for the entire protocol tree. Each proto_node
240  * in the protocol tree points to the same copy. */
241 typedef struct {
242     GHashTable  *interesting_hfids;
243     gboolean    visible;
244     gint        count;
245 } tree_data_t;
246
247 /** Each proto_tree, proto_item is one of these. */
248 typedef struct _proto_node {
249         struct _proto_node *first_child;
250         struct _proto_node *last_child;
251         struct _proto_node *next;
252         struct _proto_node *parent;
253         field_info  *finfo;
254         tree_data_t *tree_data;
255 } proto_node;
256
257 /** A protocol tree element. */
258 typedef proto_node proto_tree;
259 /** A protocol item element. */
260 typedef proto_node proto_item;
261
262 /* expert severities */
263 #define PI_SEVERITY_MASK        0x001C  /* mask usually for internal use only! */
264 /** Usual workflow, e.g. TCP connection establishing */
265 #define PI_CHAT                         0x0004
266 /** Notable messages, e.g. an application returned an "usual" error code like HTTP 404 */
267 #define PI_NOTE                         0x0008
268 /** Warning, e.g. application returned an "unusual" error code */
269 #define PI_WARN                         0x000C
270 /** Serious problems, e.g. [Malformed Packet] */
271 #define PI_ERROR                        0x0010
272
273 /* expert "event groups" */
274 #define PI_GROUP_MASK           0xFF00  /* mask usually for internal use only! */
275 /** The protocol field has a bad checksum, usually PI_WARN */
276 #define PI_CHECKSUM                     0x0100
277 /** The protocol field indicates a sequence problem (e.g. TCP window is zero) */
278 #define PI_SEQUENCE                     0x0200
279 /** The protocol field indicates a bad application response code (e.g. HTTP 404), usually PI_NOTE */
280 #define PI_RESPONSE_CODE        0x0400
281 /** The protocol field indicates an application request (e.g. File Handle == xxxx), usually PI_CHAT */
282 #define PI_REQUEST_CODE     0x0500
283 /** The data is undecoded, the protocol dissection is incomplete here, usually PI_WARN */
284 #define PI_UNDECODED            0x0800
285 /** The protocol field indicates a reassemble (e.g. DCE/RPC defragmentation), usually PI_CHAT (or PI_ERROR) */
286 #define PI_REASSEMBLE           0x1000
287 /** The packet data is malformed, the dissector has "given up", usually PI_ERROR */
288 #define PI_MALFORMED            0x2000
289 /** A generic debugging message (shouldn't remain in production code!), usually PI_ERROR */
290 #define PI_DEBUG                        0x4000
291 /** The protocol field indicates a security probem (e.g. unsecure implementation) */
292 /*#define PI_SECURITY                   0x8000*/
293
294 /* add more, see http://wiki.wireshark.org/Development/ExpertInfo */
295
296
297 /** is this protocol field hidden from the protocol tree display (used for filtering only)? */
298 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
299 #define PROTO_ITEM_IS_HIDDEN(proto_item)        \
300         ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
301 /** mark this protocol field to be hidden from the protocol tree display (used for filtering only) */
302 /* HIDING PROTOCOL FIELDS IS DEPRECATED, IT'S CONSIDERED TO BE BAD GUI DESIGN! */
303 #define PROTO_ITEM_SET_HIDDEN(proto_item)       \
304         ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_HIDDEN) : 0)
305 /** is this protocol field generated by Wireshark (and not read from the packet data)? */
306 #define PROTO_ITEM_IS_GENERATED(proto_item)     \
307         ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
308 /** mark this protocol field as generated by Wireshark (and not read from the packet data) */
309 #define PROTO_ITEM_SET_GENERATED(proto_item)    \
310         ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0)
311 /* is this protocol field actually a URL */
312 #define PROTO_ITEM_IS_URL(proto_item)   \
313         ((proto_item) ? FI_GET_FLAG((proto_item)->finfo, FI_URL) : 0)
314 /* mark this protocol field as a URL */
315 #define PROTO_ITEM_SET_URL(proto_item)  \
316         ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_URL) : 0)
317
318 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
319
320 extern void proto_tree_children_foreach(proto_tree *tree,
321     proto_tree_foreach_func func, gpointer data);
322
323 /** Retrieve the field_info from a proto_item */
324 #define PITEM_FINFO(proto_item)  ((proto_item)->finfo)
325
326 /** Retrieve the tree_data_t from a proto_tree */
327 #define PTREE_DATA(proto_tree)   ((proto_tree)->tree_data)
328
329 /** Sets up memory used by proto routines. Called at program startup */
330 extern void proto_init(void (register_all_protocols)(void),
331     void (register_all_handoffs)(void));
332
333 /** Frees memory used by proto routines. Called at program shutdown */
334 extern void proto_cleanup(void);
335
336 /** This function takes a tree and a protocol id as parameter and
337     will return TRUE/FALSE for whether the protocol or any of the filterable
338     fields in the protocol is referenced by any fitlers.
339     If this function returns FALSE then it is safe to skip any 
340         proto_tree_add_...() calls and just treat the call as if the 
341     dissector was called with tree==NULL.
342     If you reset the tree to NULL by this dissector returning FALSE,
343     you will still need to call any subdissector with the original value of 
344     tree or filtering will break.
345
346     The purpose of this is to optimize wireshark for speed and make it
347     faster for when filters are being used.
348 */
349 extern gboolean proto_field_is_referenced(proto_tree *tree, int proto_id);
350
351
352
353 /** Create a subtree under an existing item.
354  @param ti the parent item of the new subtree
355  @param idx one of the ett_ array elements registered with proto_register_subtree_array()
356  @return the new subtree */
357 extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
358
359 /** Get an existing subtree under an item.
360  @param ti the parent item of the subtree
361  @return the subtree or NULL */
362 extern proto_tree* proto_item_get_subtree(proto_item *ti);
363
364 /** Get the parent of a subtree item.
365  @param ti the child item in the subtree
366  @return parent item or NULL */
367 extern proto_item* proto_item_get_parent(proto_item *ti);
368
369 /** Get Nth generation parent item.
370  @param ti the child item in the subtree
371  @param gen the generation to get (using 1 here is the same as using proto_item_get_parent())
372  @return parent item */
373 extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
374
375 /** Replace text of item after it already has been created.
376  @param ti the item to set the text
377  @param format printf like format string
378  @param ... printf like parameters */
379 extern void proto_item_set_text(proto_item *ti, const char *format, ...)
380         GNUC_FORMAT_CHECK(printf, 2,3);
381
382 /** Append to text of item after it has already been created.
383  @param ti the item to append the text to
384  @param format printf like format string
385  @param ... printf like parameters */
386 extern void proto_item_append_text(proto_item *ti, const char *format, ...)
387         GNUC_FORMAT_CHECK(printf, 2,3);
388
389 /** Set proto_item's length inside tvb, after it has already been created.
390  @param ti the item to set the length
391  @param length the new length ot the item */
392 extern void proto_item_set_len(proto_item *ti, gint length);
393
394 /**
395  * Sets the length of the item based on its start and on the specified
396  * offset, which is the offset past the end of the item; as the start
397  * in the item is relative to the beginning of the data source tvbuff,
398  * we need to pass in a tvbuff.
399  @param ti the item to set the length
400  @param tvb end is relative to this tvbuff 
401  @param end this end offset is relative to the beginning of tvb
402  @todo make usage clearer, I don't understand it!
403  */
404 extern void proto_item_set_end(proto_item *ti, tvbuff_t *tvb, gint end);
405
406 /** Get length of a proto_item. Useful after using proto_tree_add_item()
407  * to add a variable-length field (e.g., FT_NSTRING_UINT8).
408  @param ti the item to get the length from
409  @return the current length */
410 extern int proto_item_get_len(proto_item *ti);
411
412 /**
413  * Sets an expert info to the proto_item.
414  @param ti the item to set the expert info
415  @param group the group of this info (e.g. PI_CHECKSUM)
416  @param severity of this info (e.g. PI_ERROR)
417  @return TRUE if value was written
418  */
419 extern gboolean proto_item_set_expert_flags(proto_item *ti, int group, int severity);
420
421
422
423
424 /** Creates a new proto_tree root.
425  @return the new tree root */
426 extern proto_tree* proto_tree_create_root(void);
427
428 /** Clear memory for entry proto_tree. Clears proto_tree struct also.
429  @param tree the tree to free */
430 extern void proto_tree_free(proto_tree *tree);
431
432 /** Set the tree visible or invisible.
433  Is the parsing being done for a visible proto_tree or an invisible one?
434  By setting this correctly, the proto_tree creation is sped up by not
435  having to call g_vsnprintf and copy strings around.
436  @param tree the tree to be set
437  @param visible ... or not  */
438 extern void
439 proto_tree_set_visible(proto_tree *tree, gboolean visible);
440
441 /** Mark a field/protocol ID as "interesting".
442  @param tree the tree to be set
443  @param hfid the interesting field id
444  @todo what *does* interesting mean? */
445 extern void
446 proto_tree_prime_hfid(proto_tree *tree, int hfid);
447
448 /** Get a parent item of a subtree.
449  @param tree the tree to get the parent from
450  @return parent item */
451 extern proto_item* proto_tree_get_parent(proto_tree *tree);
452
453 /** Get the root tree from any subtree.
454  @param tree the tree to get the root from
455  @return root tree */
456 extern proto_tree* proto_tree_get_root(proto_tree *tree);
457
458 /** Move an existing item behind another existing item.
459  @param tree the tree to which both items belong
460  @param fixed_item the item which keeps it's position
461  @param item_to_move the item which will be moved */
462 extern void proto_tree_move_item(proto_tree *tree, proto_item *fixed_item, proto_item *item_to_move);
463
464
465
466 /** Add an item to a proto_tree, using the text label registered to that item.
467    The item is extracted from the tvbuff handed to it.
468  @param tree the tree to append this item to
469  @param hfindex field index
470  @param tvb the tv buffer of the current data
471  @param start start of data in tvb
472  @param length length of data in tvb
473  @param little_endian big or little endian byte representation
474  @return the newly created item */
475 extern proto_item *
476 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
477     gint start, gint length, gboolean little_endian);
478
479 /** Add a hidden item to a proto_tree.
480  @deprecated use proto_tree_add_item() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
481 extern proto_item *
482 proto_tree_add_item_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb,
483     gint start, gint length, gboolean little_endian);
484
485 /** Add a text-only node to a proto_tree.
486  @param tree the tree to append this item to
487  @param tvb the tv buffer of the current data
488  @param start start of data in tvb
489  @param length length of data in tvb
490  @param format printf like format string
491  @param ... printf like parameters
492  @return the newly created item */
493 extern proto_item *
494 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *format,
495         ...) GNUC_FORMAT_CHECK(printf,5,6);
496
497 /** Add a text-only node to a proto_tree using a variable argument list.
498  @param tree the tree to append this item to
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 ap variable argument list
504  @return the newly created item */
505 extern proto_item *
506 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
507         gint length, const char *format, va_list ap);
508
509
510 /** Add a FT_NONE field to a proto_tree.
511  @param tree the tree to append this item to
512  @param hfindex field index
513  @param tvb the tv buffer of the current data
514  @param start start of data in tvb
515  @param length length of data in tvb
516  @param format printf like format string
517  @param ... printf like parameters
518  @return the newly created item */
519 extern proto_item *
520 proto_tree_add_none_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
521         gint length, const char *format, ...) GNUC_FORMAT_CHECK(printf,6,7);
522
523 /** Add a FT_PROTOCOL to a proto_tree.
524  @param tree the tree to append this item to
525  @param hfindex field index
526  @param tvb the tv buffer of the current data
527  @param start start of data in tvb
528  @param length length of data in tvb
529  @param format printf like format string
530  @param ... printf like parameters
531  @return the newly created item */
532 extern proto_item *
533 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
534         gint length, const char *format, ...) GNUC_FORMAT_CHECK(printf,6,7);
535
536
537
538
539 /** Add a FT_BYTES to a proto_tree.
540  @param tree the tree to append this item to
541  @param hfindex field index
542  @param tvb the tv buffer of the current data
543  @param start start of data in tvb
544  @param length length of data in tvb
545  @param start_ptr pointer to the data to display
546  @return the newly created item */
547 extern proto_item *
548 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
549         gint length, const guint8* start_ptr);
550
551 /** Add a hidden FT_BYTES to a proto_tree.
552  @deprecated use proto_tree_add_bytes() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
553 extern proto_item *
554 proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
555         gint length, const guint8* start_ptr);
556
557 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
558     the string for the value and with the field name being included
559     automatically.
560  @param tree the tree to append this item to
561  @param hfindex field index
562  @param tvb the tv buffer of the current data
563  @param start start of data in tvb
564  @param length length of data in tvb
565  @param start_ptr pointer to the data to display
566  @param format printf like format string
567  @param ... printf like parameters
568  @return the newly created item */
569 extern proto_item *
570 proto_tree_add_bytes_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
571         gint start, gint length, const guint8* start_ptr, const char *format,
572         ...) GNUC_FORMAT_CHECK(printf,7,8);
573
574 /** Add a formatted FT_BYTES to a proto_tree, with the format generating
575     the entire string for the entry, including any field name.
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 start_ptr pointer to the data to display
582  @param format printf like format string
583  @param ... printf like parameters
584  @return the newly created item */
585 extern proto_item *
586 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
587         gint length, const guint8* start_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
588
589 /** Add a FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
590  @param tree the tree to append this item to
591  @param hfindex field index
592  @param tvb the tv buffer of the current data
593  @param start start of data in tvb
594  @param length length of data in tvb
595  @param value_ptr pointer to the data to display
596  @return the newly created item */
597 extern proto_item *
598 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
599         gint length, nstime_t* value_ptr);
600
601 /** Add a hidden FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree.
602  @deprecated use proto_tree_add_time() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
603 extern proto_item *
604 proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
605         gint length, nstime_t* value_ptr);
606
607 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
608     the format generating the string for the value and with the field name
609     being included automatically.
610  @param tree the tree to append this item to
611  @param hfindex field index
612  @param tvb the tv buffer of the current data
613  @param start start of data in tvb
614  @param length length of data in tvb
615  @param value_ptr pointer to the data to display
616  @param format printf like format string
617  @param ... printf like parameters
618  @return the newly created item */
619 extern proto_item *
620 proto_tree_add_time_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
621         gint start, gint length, nstime_t* value_ptr, const char *format, ...)
622         GNUC_FORMAT_CHECK(printf,7,8);
623
624 /** Add a formatted FT_ABSOLUTE_TIME or FT_RELATIVE_TIME to a proto_tree, with
625     the format generating the entire string for the entry, including any field
626     name.
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_ptr pointer to the data to display
633  @param format printf like format string
634  @param ... printf like parameters
635  @return the newly created item */
636 extern proto_item *
637 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
638         gint length, nstime_t* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
639
640 /** Add a FT_IPXNET to a proto_tree.
641  @param tree the tree to append this item to
642  @param hfindex field index
643  @param tvb the tv buffer of the current data
644  @param start start of data in tvb
645  @param length length of data in tvb
646  @param value data to display
647  @return the newly created item */
648 extern proto_item *
649 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
650         gint length, guint32 value);
651
652 /** Add a hidden FT_IPXNET to a proto_tree.
653  @deprecated use proto_tree_add_ipxnet() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
654 extern proto_item *
655 proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
656         gint length, guint32 value);
657
658 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
659     the string for the value and with the field name being included
660     automatically.
661  @param tree the tree to append this item to
662  @param hfindex field index
663  @param tvb the tv buffer of the current data
664  @param start start of data in tvb
665  @param length length of data in tvb
666  @param value data to display
667  @param format printf like format string
668  @param ... printf like parameters
669  @return the newly created item */
670 extern proto_item *
671 proto_tree_add_ipxnet_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
672         gint start, gint length, guint32 value, const char *format, ...)
673         GNUC_FORMAT_CHECK(printf,7,8);
674
675 /** Add a formatted FT_IPXNET to a proto_tree, with the format generating
676     the entire string for the entry, including any field name.
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  @param format printf like format string
684  @param ... printf like parameters
685  @return the newly created item */
686 extern proto_item *
687 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
688         gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
689
690 /** Add a FT_IPv4 to a proto_tree.
691  @param tree the tree to append this item to
692  @param hfindex field index
693  @param tvb the tv buffer of the current data
694  @param start start of data in tvb
695  @param length length of data in tvb
696  @param value data to display
697  @return the newly created item */
698 extern proto_item *
699 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
700         gint length, guint32 value);
701
702 /** Add a hidden FT_IPv4 to a proto_tree.
703  @deprecated use proto_tree_add_ipv4() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
704 extern proto_item *
705 proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
706         gint length, guint32 value);
707
708 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
709     the string for the value and with the field name being included
710     automatically.
711  @param tree the tree to append this item to
712  @param hfindex field index
713  @param tvb the tv buffer of the current data
714  @param start start of data in tvb
715  @param length length of data in tvb
716  @param value data to display
717  @param format printf like format string
718  @param ... printf like parameters
719  @return the newly created item */
720 extern proto_item *
721 proto_tree_add_ipv4_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
722         gint start, gint length, guint32 value, const char *format, ...)
723         GNUC_FORMAT_CHECK(printf,7,8);
724
725 /** Add a formatted FT_IPv4 to a proto_tree, with the format generating
726     the entire string for the entry, including any field name.
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 data to display
733  @param format printf like format string
734  @param ... printf like parameters
735  @return the newly created item */
736 extern proto_item *
737 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
738         gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
739
740 /** Add a FT_IPv6 to a proto_tree.
741  @param tree the tree to append this item to
742  @param hfindex field index
743  @param tvb the tv buffer of the current data
744  @param start start of data in tvb
745  @param length length of data in tvb
746  @param value_ptr data to display
747  @return the newly created item */
748 extern proto_item *
749 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
750         gint length, const guint8* value_ptr);
751
752 /** Add a hidden FT_IPv6 to a proto_tree.
753  @deprecated use proto_tree_add_ipv6() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
754 extern proto_item *
755 proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
756         gint length, const guint8* value_ptr);
757
758 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
759     the string for the value and with the field name being included
760     automatically.
761  @param tree the tree to append this item to
762  @param hfindex field index
763  @param tvb the tv buffer of the current data
764  @param start start of data in tvb
765  @param length length of data in tvb
766  @param value_ptr data to display
767  @param format printf like format string
768  @param ... printf like parameters
769  @return the newly created item */
770 extern proto_item *
771 proto_tree_add_ipv6_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
772         gint start, gint length, const guint8* value_ptr, const char *format,
773         ...) GNUC_FORMAT_CHECK(printf,7,8);
774
775 /** Add a formatted FT_IPv6 to a proto_tree, with the format generating
776     the entire string for the entry, including any field name.
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_ptr data to display
783  @param format printf like format string
784  @param ... printf like parameters
785  @return the newly created item */
786 extern proto_item *
787 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
788         gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
789
790 /** Add a FT_ETHER to a proto_tree.
791  @param tree the tree to append this item to
792  @param hfindex field index
793  @param tvb the tv buffer of the current data
794  @param start start of data in tvb
795  @param length length of data in tvb
796  @param value data to display
797  @return the newly created item */
798 extern proto_item *
799 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
800         gint length, const guint8* value);
801
802 /** Add a hidden FT_ETHER to a proto_tree.
803  @deprecated use proto_tree_add_ether() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
804 extern proto_item *
805 proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
806         gint length, const guint8* value);
807
808 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
809     the string for the value and with the field name being included
810     automatically.
811  @param tree the tree to append this item to
812  @param hfindex field index
813  @param tvb the tv buffer of the current data
814  @param start start of data in tvb
815  @param length length of data in tvb
816  @param value data to display
817  @param format printf like format string
818  @param ... printf like parameters
819  @return the newly created item */
820 extern proto_item *
821 proto_tree_add_ether_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
822         gint start, gint length, const guint8* value, const char *format, ...)
823         GNUC_FORMAT_CHECK(printf,7,8);
824
825 /** Add a formatted FT_ETHER to a proto_tree, with the format generating
826     the entire string for the entry, including any field name.
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 data to display
833  @param format printf like format string
834  @param ... printf like parameters
835  @return the newly created item */
836 extern proto_item *
837 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
838         gint length, const guint8* value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
839
840 /** Add a FT_GUID to a proto_tree.
841  @param tree the tree to append this item to
842  @param hfindex field index
843  @param tvb the tv buffer of the current data
844  @param start start of data in tvb
845  @param length length of data in tvb
846  @param value_ptr data to display
847  @return the newly created item */
848 extern proto_item *
849 proto_tree_add_guid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
850         gint length, const e_guid_t *value_ptr);
851
852 /** Add a hidden FT_GUID to a proto_tree.
853  @deprecated use proto_tree_add_guid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
854 extern proto_item *
855 proto_tree_add_guid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
856         gint length, const e_guid_t *value_ptr);
857
858 /** Add a formatted FT_GUID to a proto_tree, with the format generating
859     the string for the value and with the field name being included
860     automatically.
861  @param tree the tree to append this item to
862  @param hfindex field index
863  @param tvb the tv buffer of the current data
864  @param start start of data in tvb
865  @param length length of data in tvb
866  @param value_ptr data to display
867  @param format printf like format string
868  @param ... printf like parameters
869  @return the newly created item */
870 extern proto_item *
871 proto_tree_add_guid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
872         gint start, gint length, const e_guid_t *value_ptr, const char *format,
873         ...) GNUC_FORMAT_CHECK(printf,7,8);
874
875 /** Add a formatted FT_GUID to a proto_tree, with the format generating
876     the entire string for the entry, including any field name.
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  @param format printf like format string
884  @param ... printf like parameters
885  @return the newly created item */
886 extern proto_item *
887 proto_tree_add_guid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
888         gint length, const e_guid_t *value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
889
890 /** Add a FT_OID to a proto_tree.
891  @param tree the tree to append this item to
892  @param hfindex field index
893  @param tvb the tv buffer of the current data
894  @param start start of data in tvb
895  @param length length of data in tvb
896  @param value_ptr data to display
897  @return the newly created item */
898 extern proto_item *
899 proto_tree_add_oid(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
900         gint length, const guint8* value_ptr);
901
902 /** Add a hidden FT_OID to a proto_tree.
903  @deprecated use proto_tree_add_oid() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
904 extern proto_item *
905 proto_tree_add_oid_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
906         gint length, const guint8* value_ptr);
907
908 /** Add a formatted FT_OID to a proto_tree, with the format generating
909     the string for the value and with the field name being included
910     automatically.
911  @param tree the tree to append this item to
912  @param hfindex field index
913  @param tvb the tv buffer of the current data
914  @param start start of data in tvb
915  @param length length of data in tvb
916  @param value_ptr data to display
917  @param format printf like format string
918  @param ... printf like parameters
919  @return the newly created item */
920 extern proto_item *
921 proto_tree_add_oid_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
922         gint start, gint length, const guint8* value_ptr, const char *format,
923         ...) GNUC_FORMAT_CHECK(printf,7,8);
924
925 /** Add a formatted FT_OID to a proto_tree, with the format generating
926     the entire string for the entry, including any field name.
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_ptr data to display
933  @param format printf like format string
934  @param ... printf like parameters
935  @return the newly created item */
936 extern proto_item *
937 proto_tree_add_oid_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
938         gint length, const guint8* value_ptr, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
939
940 /** Add a FT_STRING to a proto_tree.
941  @param tree the tree to append this item to
942  @param hfindex field index
943  @param tvb the tv buffer of the current data
944  @param start start of data in tvb
945  @param length length of data in tvb
946  @param value data to display
947  @return the newly created item */
948 extern proto_item *
949 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
950         gint length, const char* value);
951
952 /** Add a hidden FT_STRING to a proto_tree.
953  @deprecated use proto_tree_add_string() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
954 extern proto_item *
955 proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
956         gint length, const char* value);
957
958 /** Add a formatted FT_STRING to a proto_tree, with the format generating
959     the string for the value and with the field name being included
960     automatically.
961  @param tree the tree to append this item to
962  @param hfindex field index
963  @param tvb the tv buffer of the current data
964  @param start start of data in tvb
965  @param length length of data in tvb
966  @param value data to display
967  @param format printf like format string
968  @param ... printf like parameters
969  @return the newly created item */
970 extern proto_item *
971 proto_tree_add_string_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
972         gint start, gint length, const char* value, const char *format, ...)
973         GNUC_FORMAT_CHECK(printf,7,8);
974
975 /** Add a formatted FT_STRING to a proto_tree, with the format generating
976     the entire string for the entry, including any field name.
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  @param format printf like format string
984  @param ... printf like parameters
985  @return the newly created item */
986 extern proto_item *
987 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
988         gint length, const char* value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
989
990 /** Add a FT_BOOLEAN to a proto_tree.
991  @param tree the tree to append this item to
992  @param hfindex field index
993  @param tvb the tv buffer of the current data
994  @param start start of data in tvb
995  @param length length of data in tvb
996  @param value data to display
997  @return the newly created item */
998 extern proto_item *
999 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1000         gint length, guint32 value);
1001
1002 /** Add a hidden FT_BOOLEAN to a proto_tree.
1003  @deprecated use proto_tree_add_boolean() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1004 extern proto_item *
1005 proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1006         gint length, guint32 value);
1007
1008 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1009     the string for the value and with the field name being included
1010     automatically.
1011  @param tree the tree to append this item to
1012  @param hfindex field index
1013  @param tvb the tv buffer of the current data
1014  @param start start of data in tvb
1015  @param length length of data in tvb
1016  @param value data to display
1017  @param format printf like format string
1018  @param ... printf like parameters
1019  @return the newly created item */
1020 extern proto_item *
1021 proto_tree_add_boolean_format_value(proto_tree *tree, int hfindex,
1022         tvbuff_t *tvb, gint start, gint length, guint32 value,
1023         const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1024
1025 /** Add a formatted FT_BOOLEAN to a proto_tree, with the format generating
1026     the entire string for the entry, including any field name.
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  @param format printf like format string
1034  @param ... printf like parameters
1035  @return the newly created item */
1036 extern proto_item *
1037 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1038         gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1039
1040 /** Add a FT_FLOAT to a proto_tree.
1041  @param tree the tree to append this item to
1042  @param hfindex field index
1043  @param tvb the tv buffer of the current data
1044  @param start start of data in tvb
1045  @param length length of data in tvb
1046  @param value data to display
1047  @return the newly created item */
1048 extern proto_item *
1049 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1050         gint length, float value);
1051
1052 /** Add a hidden FT_FLOAT to a proto_tree.
1053  @deprecated use proto_tree_add_float() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1054 extern proto_item *
1055 proto_tree_add_float_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1056         gint length, float value);
1057
1058 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1059     the string for the value and with the field name being included
1060     automatically.
1061  @param tree the tree to append this item to
1062  @param hfindex field index
1063  @param tvb the tv buffer of the current data
1064  @param start start of data in tvb
1065  @param length length of data in tvb
1066  @param value data to display
1067  @param format printf like format string
1068  @param ... printf like parameters
1069  @return the newly created item */
1070 extern proto_item *
1071 proto_tree_add_float_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1072         gint start, gint length, float value, const char *format, ...)
1073         GNUC_FORMAT_CHECK(printf,7,8);
1074
1075 /** Add a formatted FT_FLOAT to a proto_tree, with the format generating
1076     the entire string for the entry, including any field name.
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  @param format printf like format string
1084  @param ... printf like parameters
1085  @return the newly created item */
1086 extern proto_item *
1087 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1088         gint length, float value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1089
1090 /** Add a FT_DOUBLE to a proto_tree.
1091  @param tree the tree to append this item to
1092  @param hfindex field index
1093  @param tvb the tv buffer of the current data
1094  @param start start of data in tvb
1095  @param length length of data in tvb
1096  @param value data to display
1097  @return the newly created item */
1098 extern proto_item *
1099 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1100         gint length, double value);
1101
1102 /** Add a hidden FT_DOUBLE to a proto_tree.
1103  @deprecated use proto_tree_add_double() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1104 extern proto_item *
1105 proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1106         gint length, double value);
1107
1108 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1109     the string for the value and with the field name being included
1110     automatically.
1111  @param tree the tree to append this item to
1112  @param hfindex field index
1113  @param tvb the tv buffer of the current data
1114  @param start start of data in tvb
1115  @param length length of data in tvb
1116  @param value data to display
1117  @param format printf like format string
1118  @param ... printf like parameters
1119  @return the newly created item */
1120 extern proto_item *
1121 proto_tree_add_double_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1122         gint start, gint length, double value, const char *format, ...)
1123         GNUC_FORMAT_CHECK(printf,7,8);
1124
1125 /** Add a formatted FT_DOUBLE to a proto_tree, with the format generating
1126     the entire string for the entry, including any field name.
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  @param format printf like format string
1134  @param ... printf like parameters
1135  @return the newly created item */
1136 extern proto_item *
1137 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1138         gint length, double value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1139
1140 /** Add one of FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1141  @param tree the tree to append this item to
1142  @param hfindex field index
1143  @param tvb the tv buffer of the current data
1144  @param start start of data in tvb
1145  @param length length of data in tvb
1146  @param value data to display
1147  @return the newly created item */
1148 extern proto_item *
1149 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1150         gint length, guint32 value);
1151
1152 /** Add a hidden FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree.
1153  @deprecated use proto_tree_add_uint() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1154 extern proto_item *
1155 proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1156         gint length, guint32 value);
1157
1158 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1159     with the format generating the string for the value and with the field
1160     name being included automatically.
1161  @param tree the tree to append this item to
1162  @param hfindex field index
1163  @param tvb the tv buffer of the current data
1164  @param start start of data in tvb
1165  @param length length of data in tvb
1166  @param value data to display
1167  @param format printf like format string
1168  @param ... printf like parameters
1169  @return the newly created item */
1170 extern proto_item *
1171 proto_tree_add_uint_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1172         gint start, gint length, guint32 value, const char *format, ...)
1173         GNUC_FORMAT_CHECK(printf,7,8);
1174
1175 /** Add a formatted FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 to a proto_tree,
1176     with the format generating the entire string for the entry, including any
1177     field name.
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  @param format printf like format string
1185  @param ... printf like parameters
1186  @return the newly created item */
1187 extern proto_item *
1188 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1189         gint length, guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1190
1191 /** Add an FT_UINT64 to a proto_tree.
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  @return the newly created item */
1199 extern proto_item *
1200 proto_tree_add_uint64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1201         gint length, guint64 value);
1202
1203 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1204     the string for the value and with the field name being included
1205     automatically.
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  @param format printf like format string
1213  @param ... printf like parameters
1214  @return the newly created item */
1215 extern proto_item *
1216 proto_tree_add_uint64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1217         gint start, gint length, guint64 value, const char *format, ...)
1218         GNUC_FORMAT_CHECK(printf,7,8);
1219
1220 /** Add a formatted FT_UINT64 to a proto_tree, with the format generating
1221     the entire string for the entry, including any field name.
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  @param format printf like format string
1229  @param ... printf like parameters
1230  @return the newly created item */
1231 extern proto_item *
1232 proto_tree_add_uint64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1233         gint length, guint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1234
1235 /** Add one of FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
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  @return the newly created item */
1243 extern proto_item *
1244 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1245         gint length, gint32 value);
1246
1247 /** Add a hidden FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree.
1248  @deprecated use proto_tree_add_int() and a subsequent call to PROTO_ITEM_SET_HIDDEN() instead */
1249 extern proto_item *
1250 proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1251         gint length, gint32 value);
1252
1253 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1254     with the format generating the string for the value and with the field
1255     name being included automatically.
1256  @param tree the tree to append this item to
1257  @param hfindex field index
1258  @param tvb the tv buffer of the current data
1259  @param start start of data in tvb
1260  @param length length of data in tvb
1261  @param value data to display
1262  @param format printf like format string
1263  @param ... printf like parameters
1264  @return the newly created item */
1265 extern proto_item *
1266 proto_tree_add_int_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1267         gint start, gint length, gint32 value, const char *format, ...)
1268         GNUC_FORMAT_CHECK(printf,7,8);
1269
1270 /** Add a formatted FT_INT8, FT_INT16, FT_INT24 or FT_INT32 to a proto_tree,
1271     with the format generating the entire string for the entry, including
1272     any field name.
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  @param format printf like format string
1280  @param ... printf like parameters
1281  @return the newly created item */
1282 extern proto_item *
1283 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1284         gint length, gint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1285
1286 /** Add an FT_INT64 to a proto_tree.
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  @return the newly created item */
1294 extern proto_item *
1295 proto_tree_add_int64(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1296         gint length, gint64 value);
1297
1298 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1299     the string for the value and with the field name being included
1300     automatically.
1301  @param tree the tree to append this item to
1302  @param hfindex field index
1303  @param tvb the tv buffer of the current data
1304  @param start start of data in tvb
1305  @param length length of data in tvb
1306  @param value data to display
1307  @param format printf like format string
1308  @param ... printf like parameters
1309  @return the newly created item */
1310 extern proto_item *
1311 proto_tree_add_int64_format_value(proto_tree *tree, int hfindex, tvbuff_t *tvb,
1312         gint start, gint length, gint64 value, const char *format, ...)
1313         GNUC_FORMAT_CHECK(printf,7,8);
1314
1315 /** Add a formatted FT_INT64 to a proto_tree, with the format generating
1316     the entire string for the entry, including any field name.
1317  @param tree the tree to append this item to
1318  @param hfindex field index
1319  @param tvb the tv buffer of the current data
1320  @param start start of data in tvb
1321  @param length length of data in tvb
1322  @param value data to display
1323  @param format printf like format string
1324  @param ... printf like parameters
1325  @return the newly created item */
1326 extern proto_item *
1327 proto_tree_add_int64_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
1328         gint length, gint64 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8);
1329
1330 /** Useful for quick debugging. Also sends string to STDOUT, so don't
1331  * leave call to this function in production code.
1332  @param tree the tree to append the text to
1333  @param format printf like format string
1334  @param ... printf like parameters
1335  @return the newly created item */
1336 extern proto_item *
1337 proto_tree_add_debug_text(proto_tree *tree, const char *format, 
1338         ...) GNUC_FORMAT_CHECK(printf,2,3);
1339
1340
1341
1342 /** Append a string to a protocol item.<br>
1343     NOTE: this function will break with the TRY_TO_FAKE_THIS_ITEM()
1344     speed optimization.
1345     Currently only WSP use this function so it is not that bad but try to
1346     avoid using this one if possible.
1347     IF you must use this function you MUST also disable the
1348     TRY_TO_FAKE_THIS_ITEM() optimization for your dissector/function
1349     using proto_item_append_string().
1350     Do that by faking that the tree is visible by setting :
1351     PTREE_DATA(tree)->visible=1;  (see packet-wsp.c)
1352     BEFORE you create the item you are later going to use
1353     proto_item_append_string() on.
1354
1355  @param pi the item to append the string to
1356  @param str the string to append */
1357 extern void
1358 proto_item_append_string(proto_item *pi, const char *str);
1359
1360
1361
1362 /** Fill given label_str with string representation of field
1363  @param fi the item to get the info from
1364  @param label_str the string to fill 
1365  @todo think about changing the parameter profile */
1366 extern void
1367 proto_item_fill_label(field_info *fi, gchar *label_str);
1368
1369
1370 /** Register a new protocol.
1371  @param name the full name of the new protocol
1372  @param short_name abbreviated name of the new protocol
1373  @param filter_name protocol name used for a display filter string 
1374  @return the new protocol handle */
1375 extern int
1376 proto_register_protocol(const char *name, const char *short_name, const char *filter_name);
1377
1378 /** Register a header_field array.
1379  @param parent the protocol handle from proto_register_protocol()
1380  @param hf the hf_register_info array
1381  @param num_records the number of records in hf */
1382 extern void
1383 proto_register_field_array(int parent, hf_register_info *hf, int num_records);
1384
1385 /** Register a protocol subtree (ett) array.
1386  @param indices array of ett indices
1387  @param num_indices the number of records in indices */
1388 extern void
1389 proto_register_subtree_array(gint *const *indices, int num_indices);
1390
1391 /** Returns number of items (protocols or header fields) registered.
1392  @return the number of items */
1393 extern int proto_registrar_n(void);
1394
1395 /** Get name of registered header_field number n.
1396  @param n item # n (0-indexed)
1397  @return the name of this registered item */
1398 extern const char* proto_registrar_get_name(int n);
1399
1400 /** Get abbreviation of registered header_field number n.
1401  @param n item # n (0-indexed)
1402  @return the abbreviation of this registered item */
1403 extern const char* proto_registrar_get_abbrev(int n);
1404
1405 /** Get the header_field information based upon a field or protocol id.
1406  @param hfindex item # n (0-indexed)
1407  @return the registered item */
1408 extern header_field_info* proto_registrar_get_nth(guint hfindex);
1409
1410 /** Get the header_field information based upon a field name.
1411  @param field_name the field name to search for
1412  @return the registered item */
1413 extern header_field_info* proto_registrar_get_byname(const char *field_name);
1414
1415 /** Get enum ftenum FT_ of registered header_field number n.
1416  @param n item # n (0-indexed)
1417  @return the registered item */
1418 extern int proto_registrar_get_ftype(int n);
1419
1420 /** Get parent protocol of registered header_field number n.
1421  @param n item # n (0-indexed)
1422  @return -1 if item _is_ a protocol */
1423 extern int proto_registrar_get_parent(int n);
1424
1425 /** Is item # n a protocol?
1426  @param n item # n (0-indexed)
1427  @return TRUE if it's a protocol, FALSE if it's not */
1428 extern gboolean proto_registrar_is_protocol(int n);
1429
1430 /* Get length of registered field according to field type.
1431  @param n item # n (0-indexed)
1432  @return 0 means undeterminable at registration time, * -1 means unknown field */
1433 extern gint proto_registrar_get_length(int n);
1434
1435
1436 /* Routines to use to iterate over the protocols and their fields;
1437  * they return the item number of the protocol in question or the
1438  * appropriate hfinfo pointer, and keep state in "*cookie". */
1439 extern int proto_get_first_protocol(void **cookie);
1440 extern int proto_get_next_protocol(void **cookie);
1441 extern header_field_info *proto_get_first_protocol_field(int proto_id, void **cookle);
1442 extern header_field_info *proto_get_next_protocol_field(void **cookle);
1443
1444 /** Given a protocol's filter_name.
1445  @param filter_name the filter name to search for
1446  @return proto_id */
1447 extern int proto_get_id_by_filter_name(const gchar* filter_name);
1448
1449 /** Can item # n decoding be disabled?
1450  @param proto_id protocol id (0-indexed)
1451  @return TRUE if it's a protocol, FALSE if it's not */
1452 extern gboolean proto_can_toggle_protocol(int proto_id);
1453
1454 /** Get the "protocol_t" structure for the given protocol's item number.
1455  @param proto_id protocol id (0-indexed) */
1456 extern protocol_t *find_protocol_by_id(int proto_id);
1457
1458 /** Get the protocol's name for the given protocol's item number.
1459  @param proto_id protocol id (0-indexed)
1460  @return its name */
1461 extern const char *proto_get_protocol_name(int proto_id);
1462
1463 /** Get the protocol's item number, for the given protocol's "protocol_t".
1464  @return its proto_id */
1465 extern int proto_get_id(protocol_t *protocol);
1466
1467 /** Get the protocol's short name, for the given protocol's "protocol_t".
1468  @return its short name. */
1469 extern const char *proto_get_protocol_short_name(protocol_t *protocol);
1470
1471 /** Is protocol's decoding enabled ?
1472  @param protocol 
1473  @return TRUE if decoding is enabled, FALSE if not */
1474 extern gboolean proto_is_protocol_enabled(protocol_t *protocol);
1475
1476 /** Get a protocol's filter name by it's item number.
1477  @param proto_id protocol id (0-indexed)
1478  @return its filter name. */
1479 extern const char *proto_get_protocol_filter_name(int proto_id);
1480
1481 /** Enable / Disable protocol of the given item number.
1482  @param proto_id protocol id (0-indexed)
1483  @param enabled enable / disable the protocol */
1484 extern void proto_set_decoding(int proto_id, gboolean enabled);
1485
1486 /** Disable disabling/enabling of protocol of the given item number.
1487  @param proto_id protocol id (0-indexed) */
1488 extern void proto_set_cant_toggle(int proto_id);
1489
1490 /** Checks for existence any protocol or field within a tree.
1491  @param tree "Protocols" are assumed to be a child of the [empty] root node.
1492  @param id ???
1493  @return TRUE = found, FALSE = not found
1494  @todo add explanation of id parameter */
1495 extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id);
1496
1497 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
1498  * tree. Only works with primed trees, and is fast. */
1499 extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
1500
1501 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
1502  * tree. Works with any tree, primed or unprimed, and is slower than
1503  * proto_get_finfo_ptr_array because it has to search through the tree. */
1504 extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
1505
1506 /* Return GPtrArray* of field_info pointers containg all hfindexes that appear in
1507 * tree. */
1508 extern GPtrArray* proto_all_finfos(proto_tree *tree);
1509
1510 /** Dumps a glossary of the protocol registrations to STDOUT */
1511 extern void proto_registrar_dump_protocols(void);
1512
1513 /** Dumps a glossary of the field value strings or true/false strings to STDOUT */
1514 extern void proto_registrar_dump_values(void);
1515
1516 /** Dumps a glossary of the protocol and field registrations to STDOUT.
1517  * Format 1 is the original format. Format 2 includes the base (for integers)
1518  * and the blurb. */
1519 extern void proto_registrar_dump_fields(int format);
1520
1521
1522
1523 /** Points to the first element of an array of Booleans, indexed by
1524    a subtree item type. That array element is TRUE if subtrees of
1525    an item of that type are to be expanded. With MSVC and a 
1526    libwireshark.dll, we need a special declaration. */
1527 WS_VAR_IMPORT gboolean       *tree_is_expanded;
1528
1529 /** Number of elements in the tree_is_expanded array. With MSVC and a 
1530  * libwireshark.dll, we need a special declaration. */
1531 WS_VAR_IMPORT int           num_tree_types;
1532
1533 /** glib doesn't have g_ptr_array_len of all things!*/
1534 #ifndef g_ptr_array_len
1535 #define g_ptr_array_len(a)      ((a)->len)
1536 #endif
1537
1538 /** Get number of bits of a header_field.
1539  @param hfinfo header_field
1540  @return the bitwidth */
1541 extern int
1542 hfinfo_bitwidth(header_field_info *hfinfo);
1543
1544
1545
1546
1547 #include "epan.h"
1548
1549 /** Can we do a "match selected" on this field.
1550  @param finfo field_info
1551  @param edt epan dissecting
1552  @return TRUE if we can do a "match selected" on the field, FALSE otherwise. */
1553 extern gboolean
1554 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
1555
1556 /** Construct a "match selected" display filter string.
1557  @param finfo field_info
1558  @param edt epan dissecting
1559  @return the display filter string */
1560 extern char*
1561 proto_construct_match_selected_string(field_info *finfo, epan_dissect_t *edt);
1562
1563 /** Find field from offset in tvb.
1564  @param tree 
1565  @param offset offset in the tvb
1566  @param tvb the tv buffer
1567  @return the corresponding field_info */
1568 extern field_info*
1569 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
1570
1571
1572 extern proto_item *
1573 proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_hdr, gint ett, const int **fields, gboolean little_endian);
1574
1575 /** Add bitts to a proto_tree, using the text label registered to that item.
1576    The item is extracted from the tvbuff handed to it.
1577  @param tree the tree to append this item to
1578  @param hfindex field index
1579  @param tvb the tv buffer of the current data
1580  @param bit_offset start of data in tvb expressed in bits
1581  @param no_of_bits length of data in tvb expressed in bits
1582  @param little_endian big or little endian byte representation
1583  @return the newly created item */
1584
1585 extern proto_item *
1586 proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
1587
1588 /** Add bitts to a proto_tree, using the text label registered to that item.
1589    The item is extracted from the tvbuff handed to it.
1590  @param tree the tree to append this item to
1591  @param hfindex field index
1592  @param tvb the tv buffer of the current data
1593  @param bit_offset start of data in tvb expressed in bits
1594  @param no_of_bits length of data in tvb expressed in bits
1595  @param return_value if a pointer is passed here the value is returned.
1596  @param little_endian big or little endian byte representation
1597  @return the newly created item */
1598
1599 extern proto_item *
1600 proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint64 *return_value, gboolean little_endian);
1601
1602 #ifdef __cplusplus
1603 }
1604 #endif /* __cplusplus */
1605
1606 #endif /* proto.h */