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