From Tomas Kukosa: add APIs to get the parent of a protocol tree item
[obnox/wireshark/wip.git] / epan / proto.h
1 /* proto.h
2  * Definitions for protocol display
3  *
4  * $Id: proto.h,v 1.57 2004/03/25 23:55:21 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
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 #ifndef __PROTO_H__
26 #define __PROTO_H__
27
28 #ifdef HAVE_STDARG_H
29 # include <stdarg.h>
30 #else
31 # include <varargs.h>
32 #endif
33
34 #include <glib.h>
35
36 #include "ipv4.h"
37 #include "nstime.h"
38 #include "tvbuff.h"
39 #include "ftypes/ftypes.h"
40
41 /* The header-field index for the special text pseudo-field */
42 extern int hf_text_only;
43
44 struct _value_string;
45
46 #define ITEM_LABEL_LENGTH       240
47
48 /* In order to make a const value_string[] look like a value_string*, I
49  * need this macro */
50 #define VALS(x) (const struct _value_string*)(x)
51
52 /* ... and similarly, */
53 #define TFS(x)  (const struct true_false_string*)(x)
54
55 struct _protocol;
56
57 typedef struct _protocol protocol_t;
58  
59 /* check protocol activation */
60 #define CHECK_DISPLAY_AS_X(x_handle,index, tvb, pinfo, tree) {  \
61         if (!proto_is_protocol_enabled(find_protocol_by_id(index))) {   \
62                 call_dissector(x_handle,tvb, pinfo, tree);              \
63                 return;                                                 \
64         }                                                               \
65   }
66
67 enum {
68         BASE_NONE,
69         BASE_DEC,
70         BASE_HEX,
71         BASE_OCT
72 };
73
74 typedef struct _header_field_info header_field_info;
75
76 /* information describing a header field */
77 struct _header_field_info {
78         /* ---------- set by dissector --------- */
79         char                            *name;
80         char                            *abbrev;
81         enum ftenum                     type;
82         int                             display;        /* for integers only, so far. Base */
83         const void                      *strings;       /* val_string or true_false_string */
84         guint32                         bitmask;
85         char                            *blurb;         /* Brief description of field. */
86
87         /* ---------- set by proto routines --------- */
88         int                             id;             /* Field ID */
89         int                             parent;         /* parent protocol */
90         int                             bitshift;       /* bits to shift */
91         header_field_info               *same_name_next; /* Link to next hfinfo with same abbrev*/
92         header_field_info               *same_name_prev; /* Link to previous hfinfo with same abbrev*/
93 };
94
95 /*
96  * HFILL initializes all the "set by proto routines" fields in a
97  * "header_field_info"; if new fields are added or removed, it should
98  * be changed as necessary.
99  */
100 #define HFILL 0, 0, 0, NULL, NULL
101
102 /* Used when registering many fields at once */
103 typedef struct hf_register_info {
104         int                     *p_id;  /* pointer to int; written to by register() function */
105         header_field_info       hfinfo;
106 } hf_register_info;
107
108
109 typedef struct _item_label_t {
110         char representation[ITEM_LABEL_LENGTH];
111 } item_label_t;
112
113 /* Contains the field information for the proto_item. */
114 typedef struct field_info {
115         header_field_info               *hfinfo;
116         gint                            start;
117         gint                            length;
118         gint                            tree_type; /* ETT_* */
119         item_label_t                    *rep; /* string for GUI tree */
120         int                             visible;
121         tvbuff_t                        *ds_tvb;  /* data source tvbuff */
122         fvalue_t                        value;
123 } field_info;
124
125 /* One of these exists for the entire protocol tree. Each proto_node
126  * in the protocol tree points to the same copy. */
127 typedef struct {
128     GHashTable  *interesting_hfids;
129     gboolean    visible;
130 } tree_data_t;
131
132 /* Each proto_tree, proto_item is one of these. */
133 typedef struct _proto_node {
134         struct _proto_node *first_child;
135         struct _proto_node *last_child;
136         struct _proto_node *next;
137         struct _proto_node *parent;
138         field_info  *finfo;
139         tree_data_t *tree_data;
140 } proto_node;
141
142 typedef proto_node proto_tree;
143 typedef proto_node proto_item;
144
145 typedef void (*proto_tree_foreach_func)(proto_node *, gpointer);
146
147 extern void proto_tree_children_foreach(proto_tree *tree,
148     proto_tree_foreach_func func, gpointer data);
149
150 /* Retrieve the field_info from a proto_item */
151 #define PITEM_FINFO(t)  ((t)->finfo)
152
153 /* Retrieve the tree_data_t from a proto_tree */
154 #define PTREE_DATA(t)   ((t)->tree_data)
155
156 /* Sets up memory used by proto routines. Called at program startup */
157 extern void proto_init(const char *plugin_dir,
158     void (register_all_protocols)(void), void (register_all_handoffs)(void));
159
160 /* Frees memory used by proto routines. Called at program shutdown */
161 extern void proto_cleanup(void);
162
163 /* Set text of proto_item after having already been created. */
164 #if __GNUC__ >= 2
165 extern void proto_item_set_text(proto_item *ti, const char *format, ...)
166         __attribute__((format (printf, 2, 3)));
167 #else
168 extern void proto_item_set_text(proto_item *ti, const char *format, ...);
169 #endif
170
171 /* Append to text of proto_item after having already been created. */
172 #if __GNUC__ >= 2
173 extern void proto_item_append_text(proto_item *ti, const char *format, ...)
174         __attribute__((format (printf, 2, 3)));
175 #else
176 extern void proto_item_append_text(proto_item *ti, const char *format, ...);
177 #endif
178
179 /* Set length of proto_item after having already been created. */
180 extern void proto_item_set_len(proto_item *ti, gint length);
181
182 /*
183  * Sets the length of the item based on its start and on the specified
184  * offset, which is the offset past the end of the item; as the start
185  * in the item is relative to the beginning of the data source tvbuff,
186  * we need to pass in a tvbuff - the end offset is relative to the beginning
187  * of that tvbuff.
188  */
189 extern void proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end);
190
191 /* Get length of proto_item. Useful after using proto_tree_add_item()
192  * to add a variable-length field (e.g., FT_NSTRING_UINT8) */
193 extern int proto_item_get_len(proto_item *ti);
194
195 /* Creates new proto_tree root */
196 extern proto_tree* proto_tree_create_root(void);
197
198 /* Mark a field/protocol ID as "interesting". */
199 extern void
200 proto_tree_prime_hfid(proto_tree *tree, int hfid);
201
202 /* Clear memory for entry proto_tree. Clears proto_tree struct also. */
203 extern void proto_tree_free(proto_tree *tree);
204
205 /* Create a subtree under an existing item; returns tree pointer */
206 extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
207
208 /* Get a subtree under an item; returns tree pointer */
209 extern proto_tree* proto_item_get_subtree(proto_item *ti);
210
211 /* Get a parent item; returns item pointer */
212 extern proto_item* proto_item_get_parent(proto_item *ti);
213
214 /* Get Nth generation parent item; returns item pointer */
215 extern proto_item* proto_item_get_parent_nth(proto_item *ti, int gen);
216
217 /* Get a parent item of subtree; returns item pointer */
218 extern proto_item* proto_tree_get_parent(proto_tree *tree);
219
220 extern int
221 proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
222         struct _value_string* vals);
223
224 extern int
225 proto_register_protocol(char *name, char *short_name, char *filter_name);
226
227 extern void
228 proto_register_field_array(int parent, hf_register_info *hf, int num_records);
229
230 extern void
231 proto_register_subtree_array(gint **indices, int num_indices);
232
233 /* Add an item to a proto_tree, using the text label registered to that item;
234    the item is extracted from the tvbuff handed to it. */
235 extern proto_item *
236 proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
237     gint start, gint length, gboolean little_endian);
238
239 extern proto_item *
240 proto_tree_add_item_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb,
241     gint start, gint length, gboolean little_endian);
242
243 /* Add a FT_NONE to a proto_tree */
244 #if __GNUC__ >= 2
245 extern proto_item *
246 proto_tree_add_none_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
247         gint length, const char *format, ...)
248         __attribute__((format (printf, 6, 7)));
249 #else
250 extern proto_item *
251 proto_tree_add_none_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
252         gint length, const char *format, ...);
253 #endif
254
255 /* Add a FT_PROTOCOL to a proto_tree */
256 #if __GNUC__ >= 2
257 extern proto_item *
258 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
259         gint length, const char *format, ...)
260         __attribute__((format (printf, 6, 7)));
261 #else
262 extern proto_item *
263 proto_tree_add_protocol_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
264         gint length, const char *format, ...);
265 #endif
266
267 /* Add a FT_BYTES to a proto_tree */
268 extern proto_item *
269 proto_tree_add_bytes(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
270         gint length, const guint8* start_ptr);
271
272 extern proto_item *
273 proto_tree_add_bytes_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
274         gint length, const guint8* start_ptr);
275
276 #if __GNUC__ >= 2
277 extern proto_item *
278 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
279         gint length, const guint8* start_ptr, const char *format, ...)
280         __attribute__((format (printf, 7, 8)));
281 #else
282 extern proto_item *
283 proto_tree_add_bytes_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
284         gint length, const guint8* start_ptr, const char *format, ...);
285 #endif
286
287 /* Add a FT_*TIME to a proto_tree */
288 extern proto_item *
289 proto_tree_add_time(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
290         gint length, nstime_t* value_ptr);
291
292 extern proto_item *
293 proto_tree_add_time_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
294         gint length, nstime_t* value_ptr);
295
296 #if __GNUC__ >= 2
297 extern proto_item *
298 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
299         gint length, nstime_t* value_ptr, const char *format, ...)
300         __attribute__((format (printf, 7, 8)));
301 #else
302 extern proto_item *
303 proto_tree_add_time_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
304         gint length, nstime_t* value_ptr, const char *format, ...);
305 #endif
306
307 /* Add a FT_IPXNET to a proto_tree */
308 extern proto_item *
309 proto_tree_add_ipxnet(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
310         gint length, guint32 value);
311
312 extern proto_item *
313 proto_tree_add_ipxnet_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
314         gint length, guint32 value);
315
316 #if __GNUC__ >= 2
317 extern proto_item *
318 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
319         gint length, guint32 value, const char *format, ...)
320         __attribute__((format (printf, 7, 8)));
321 #else
322 extern proto_item *
323 proto_tree_add_ipxnet_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
324         gint length, guint32 value, const char *format, ...);
325 #endif
326
327 /* Add a FT_IPv4 to a proto_tree */
328 extern proto_item *
329 proto_tree_add_ipv4(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
330         gint length, guint32 value);
331
332 extern proto_item *
333 proto_tree_add_ipv4_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
334         gint length, guint32 value);
335
336 #if __GNUC__ >= 2
337 extern proto_item *
338 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
339         gint length, guint32 value, const char *format, ...)
340         __attribute__((format (printf, 7, 8)));
341 #else
342 extern proto_item *
343 proto_tree_add_ipv4_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
344         gint length, guint32 value, const char *format, ...);
345 #endif
346
347 /* Add a FT_IPv6 to a proto_tree */
348 extern proto_item *
349 proto_tree_add_ipv6(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
350         gint length, const guint8* value_ptr);
351
352 extern proto_item *
353 proto_tree_add_ipv6_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
354         gint length, const guint8* value_ptr);
355
356 #if __GNUC__ >= 2
357 extern proto_item *
358 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
359         gint length, const guint8* value_ptr, const char *format, ...)
360         __attribute__((format (printf, 7, 8)));
361 #else
362 extern proto_item *
363 proto_tree_add_ipv6_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
364         gint length, const guint8* value_ptr, const char *format, ...);
365 #endif
366
367 /* Add a FT_ETHER to a proto_tree */
368 extern proto_item *
369 proto_tree_add_ether(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
370         gint length, const guint8* value);
371
372 extern proto_item *
373 proto_tree_add_ether_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
374         gint length, const guint8* value);
375
376 #if __GNUC__ >= 2
377 extern proto_item *
378 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
379         gint length, const guint8* value, const char *format, ...)
380         __attribute__((format (printf, 7, 8)));
381 #else
382 extern proto_item *
383 proto_tree_add_ether_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
384         gint length, const guint8* value, const char *format, ...);
385 #endif
386
387 /* Add a FT_STRING to a proto_tree */
388 extern proto_item *
389 proto_tree_add_string(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
390         gint length, const char* value);
391
392 extern proto_item *
393 proto_tree_add_string_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
394         gint length, const char* value);
395
396 #if __GNUC__ >= 2
397 extern proto_item *
398 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
399         gint length, const char* value, const char *format, ...)
400         __attribute__((format (printf, 7, 8)));
401 #else
402 extern proto_item *
403 proto_tree_add_string_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
404         gint length, const char* value, const char *format, ...);
405 #endif
406
407 extern void
408 proto_item_append_string(proto_item *pi, const char *str);
409
410 /* Add a FT_BOOLEAN to a proto_tree */
411 extern proto_item *
412 proto_tree_add_boolean(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
413         gint length, guint32 value);
414
415 extern proto_item *
416 proto_tree_add_boolean_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
417         gint length, guint32 value);
418
419 #if __GNUC__ >= 2
420 extern proto_item *
421 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
422         gint length, guint32 value, const char *format, ...)
423         __attribute__((format (printf, 7, 8)));
424 #else
425 extern proto_item *
426 proto_tree_add_boolean_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
427         gint length, guint32 value, const char *format, ...);
428 #endif
429
430 /* Add a FT_FLOAT to a proto_tree */
431 extern proto_item *
432 proto_tree_add_float(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
433         gint length, float value);
434
435 extern proto_item *
436 proto_tree_add_float_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
437         gint length, float value);
438
439 #if __GNUC__ >= 2
440 extern proto_item *
441 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
442         gint length, float value, const char *format, ...)
443         __attribute__((format (printf, 7, 8)));
444 #else
445 extern proto_item *
446 proto_tree_add_float_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
447         gint length, float value, const char *format, ...);
448 #endif
449
450 /* Add a FT_DOUBLE to a proto_tree */
451 extern proto_item *
452 proto_tree_add_double(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
453         gint length, double value);
454
455 extern proto_item *
456 proto_tree_add_double_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
457         gint length, double value);
458
459 #if __GNUC__ >= 2
460 extern proto_item *
461 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
462         gint length, double value, const char *format, ...)
463         __attribute__((format (printf, 7, 8)));
464 #else
465 extern proto_item *
466 proto_tree_add_double_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
467         gint length, double value, const char *format, ...);
468 #endif
469
470 /* Add any FT_UINT* to a proto_tree */
471 extern proto_item *
472 proto_tree_add_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
473         gint length, guint32 value);
474
475 extern proto_item *
476 proto_tree_add_uint_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
477         gint length, guint32 value);
478
479 #if __GNUC__ >= 2
480 extern proto_item *
481 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
482         gint length, guint32 value, const char *format, ...)
483         __attribute__((format (printf, 7, 8)));
484 #else
485 extern proto_item *
486 proto_tree_add_uint_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
487         gint length, guint32 value, const char *format, ...);
488 #endif
489
490 /* Add any FT_INT* to a proto_tree */
491 extern proto_item *
492 proto_tree_add_int(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
493         gint length, gint32 value);
494
495 extern proto_item *
496 proto_tree_add_int_hidden(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
497         gint length, gint32 value);
498
499 #if __GNUC__ >= 2
500 extern proto_item *
501 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
502         gint length, gint32 value, const char *format, ...)
503         __attribute__((format (printf, 7, 8)));
504 #else
505 extern proto_item *
506 proto_tree_add_int_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
507         gint length, gint32 value, const char *format, ...);
508 #endif
509
510
511 /* Add a text-only node to the proto_tree */
512 #if __GNUC__ >= 2
513 extern proto_item *
514 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *,
515         ...) __attribute__((format (printf, 5, 6)));
516 #else
517 extern proto_item *
518 proto_tree_add_text(proto_tree *tree, tvbuff_t *tvb, gint start, gint length, const char *,
519         ...);
520 #endif
521
522 extern proto_item *
523 proto_tree_add_text_valist(proto_tree *tree, tvbuff_t *tvb, gint start,
524         gint length, const char *format, va_list ap);
525
526
527 /* Useful for quick debugging. Also sends string to STDOUT, so don't
528  * leave call to this function in production code. */
529 #if __GNUC__ >= 2
530 extern proto_item *
531 proto_tree_add_debug_text(proto_tree *tree, const char *format, ...)
532         __attribute__((format (printf, 2, 3)));
533 #else
534 extern proto_item *
535 proto_tree_add_debug_text(proto_tree *tree, const char *format, ...);
536 #endif
537
538 extern void
539 proto_item_fill_label(field_info *fi, gchar *label_str);
540
541 extern void
542 proto_tree_set_visible(proto_tree *tree, gboolean visible);
543
544 /* Returns number of items (protocols or header fields) registered. */
545 extern int proto_registrar_n(void);
546
547 /* Returns char* to name for item # n (0-indexed) */
548 extern char* proto_registrar_get_name(int n);
549
550 /* Returns char* to abbrev for item # n (0-indexed) */
551 extern char* proto_registrar_get_abbrev(int n);
552
553 /* get the header field information based upon a field or protocol id */
554 extern header_field_info* proto_registrar_get_nth(guint hfindex);
555
556 /* get the header field information based upon a field name */
557 extern header_field_info* proto_registrar_get_byname(char *field_name);
558
559 /* Returns enum ftenum for item # n */
560 extern int proto_registrar_get_ftype(int n);
561
562 /* Returns parent protocol for item # n.
563  * Returns -1 if item _is_ a protocol */
564 extern int proto_registrar_get_parent(int n);
565
566 /* Is item #n a protocol? */
567 extern gboolean proto_registrar_is_protocol(int n);
568
569 /* Is protocol's decoding enabled ? */
570 extern gboolean proto_is_protocol_enabled(protocol_t *protocol);
571
572 /* Can item #n decoding be disabled? */
573 extern gboolean proto_can_toggle_protocol(int proto_id);
574
575 /* Routines to use to iterate over the protocols and their fields;
576  * they return the item number of the protocol in question or the
577  * appropriate hfinfo pointer, and keep state in "*cookie". */
578 extern int proto_get_first_protocol(void **cookie);
579 extern int proto_get_next_protocol(void **cookie);
580 extern header_field_info *proto_get_first_protocol_field(int proto_id, void **cookle);
581 extern header_field_info *proto_get_next_protocol_field(void **cookle);
582
583 /* Given a protocol's "protocol_t", return its proto_id */
584 extern int proto_get_id(protocol_t *protocol);
585
586 /* Given a protocol's filter_name, return its proto_id */
587 extern int proto_get_id_by_filter_name(gchar* filter_name);
588
589 /* Given a protocol's item number, find the "protocol_t" structure for it */
590 extern protocol_t *find_protocol_by_id(int proto_id);
591
592 /* Given a protocol's item number, return its name. */
593 extern char *proto_get_protocol_name(int n);
594
595 /* Given a protocol's "protocol_t", return its short name. */
596 extern char *proto_get_protocol_short_name(protocol_t *protocol);
597
598 /* Given a protocol's item number, return its filter name. */
599 extern char *proto_get_protocol_filter_name(int proto_id);
600
601 /* Enable / Disable protocol */
602 extern void proto_set_decoding(int proto_id, gboolean enabled);
603
604 /* Disable disabling/enabling of protocol */
605 extern void proto_set_cant_toggle(int proto_id);
606
607 /* Get length of registered field according to field type.
608  * 0 means undeterminable at registration time.
609  * -1 means unknown field */
610 extern gint proto_registrar_get_length(int n);
611
612 /* Checks for existence any protocol or field within a tree.
613  * "Protocols" are assumed to be a child of the [empty] root node.
614  * TRUE = found, FALSE = not found */
615 extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id);
616
617 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
618  * tree. Only works with primed trees, and is fast. */
619 extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex);
620
621 /* Return GPtrArray* of field_info pointers for all hfindex that appear in
622  * tree. Works with any tree, primed or unprimed, and is slower than
623  * proto_get_finfo_ptr_array because it has to search through the tree. */
624 extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex);
625
626 /* Dumps a glossary of the protocol registrations to STDOUT */
627 extern void proto_registrar_dump_protocols(void);
628
629 /* Dumps a glossary of the protocol and field registrations to STDOUT */
630 extern void proto_registrar_dump_fields(void);
631
632 /* Points to the first element of an array of Booleans, indexed by
633    a subtree item type; that array element is TRUE if subtrees of
634    an item of that type are to be expanded. */
635 extern gboolean      *tree_is_expanded;
636
637 /* Number of elements in that array. */
638 extern int           num_tree_types;
639
640 /* glib doesn't have g_ptr_array_len of all things!*/
641 #ifndef g_ptr_array_len
642 #define g_ptr_array_len(a)      ((a)->len)
643 #endif
644
645 extern int
646 hfinfo_bitwidth(header_field_info *hfinfo);
647
648 #include "epan.h"
649
650 /*
651  * Returns TRUE if we can do a "match selected" on the field, FALSE
652  * otherwise.
653  */
654 extern gboolean
655 proto_can_match_selected(field_info *finfo, epan_dissect_t *edt);
656
657 extern char*
658 proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt);
659
660 extern field_info*
661 proto_find_field_from_offset(proto_tree *tree, guint offset, tvbuff_t *tvb);
662
663 #endif /* proto.h */