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