2 * Definitions for protocol display
4 * $Id: proto.h,v 1.6 1999/08/14 01:26:39 gram Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TIME_H
41 typedef struct GNode proto_tree;
42 typedef struct GNode proto_item;
45 #define ITEM_LABEL_LENGTH 240
47 /* In order to make a const value_string[] look like a value_string*, I
49 #define VALS(x) (struct value_string*)(x)
54 FT_NONE, /* used for protocol labels (thus no field type) */
55 FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */
71 FT_TEXT_ONLY, /* non-filterable, used when converting ethereal
72 from old-style proto_tree to new-style proto_tree */
73 NUM_FIELD_TYPES /* last item number plus one */
76 /* information describing a header field */
77 typedef struct header_field_info {
81 struct value_string *vals;
82 int id; /* assigned by order of registration */
83 int parent; /* parent protocol */
86 /* Used when registering many fields at once */
87 typedef struct hf_register_info {
88 int *p_id; /* pointer to int; written to by register() function */
89 header_field_info hfinfo;
93 /* 'boolean' is a reserved word on win32 */
94 #define boolean truth_value
97 /* Info stored in each proto_item GNode */
98 typedef struct field_info {
99 struct header_field_info *hfinfo;
102 gint tree_type; /* ETT_* */
103 char *representation; /* for GUI tree */
108 struct timeval abs_time; /* the whole struct, not a pointer */
115 typedef struct proto_tree_search_info {
117 GArray *result_array;
118 const guint8 *packet_data;
119 } proto_tree_search_info;
121 void proto_init(void);
122 void proto_item_set_len(proto_item *ti, gint length);
123 proto_tree* proto_tree_create_root(void);
124 void proto_tree_free(proto_tree *tree);
125 proto_tree* proto_item_add_subtree(proto_item *ti, gint idx);
128 proto_register_field(char *name, char *abbrev, enum ftenum type, int parent,
129 struct value_string* vals);
132 proto_register_protocol(char *name, char *abbrev);
135 proto_register_field_array(int parent, hf_register_info *hf, int num_records);
138 proto_tree_add_item(proto_tree *tree, int hfindex, gint start,
142 proto_tree_add_item_hidden(proto_tree *tree, int hfindex, gint start,
146 proto_tree_add_item_format(proto_tree *tree, int hfindex, gint start,
150 proto_tree_add_text(proto_tree *tree, gint start, gint length, ...);
153 proto_item_fill_label(field_info *fi, gchar *label_str);
155 /* useful functions for external routines to get info about registered protos and fields */
156 int proto_registrar_n(void);
157 char* proto_registrar_get_abbrev(int n);
158 int proto_registrar_get_ftype(int n);
159 int proto_registrar_get_parent(int n);
160 gboolean proto_registrar_is_protocol(int n);
161 proto_item* proto_find_field(proto_tree* tree, int id);
162 proto_item* proto_find_protocol(proto_tree* tree, int protocol_id);
163 void proto_get_field_values(proto_tree* subtree, GNodeTraverseFunc fill_array_func,
164 proto_tree_search_info *sinfo);
166 /* Dumps a glossary of the protocol and field registrations to STDOUT */
167 void proto_registrar_dump(void);