3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __EXTCAP_PARSER_H__
23 #define __EXTCAP_PARSER_H__
30 EXTCAP_SENTENCE_UNKNOWN,
32 EXTCAP_SENTENCE_VALUE,
33 EXTCAP_SENTENCE_EXTCAP,
34 EXTCAP_SENTENCE_INTERFACE,
36 } extcap_sentence_type;
49 /* Complex GUI types which are populated with value sentences */
52 EXTCAP_ARG_MULTICHECK,
70 EXTCAP_PARAM_FILE_MUSTEXIST,
71 EXTCAP_PARAM_FILE_EXTENSION,
73 EXTCAP_PARAM_REQUIRED,
74 EXTCAP_PARAM_VALIDATION,
78 /* Values for a given sentence; values are all stored as a call
79 * and a value string, or a valid range, so we only need to store
80 * those and repeat them */
81 typedef struct _extcap_value {
91 /* Complex-ish struct for storing complex values */
92 typedef struct _extcap_complex {
93 extcap_arg_type complex_type;
96 unsigned int uint_value;
102 gboolean value_filled;
105 /* An argument sentence and accompanying options */
106 typedef struct _extcap_arg {
113 gchar * fileextension;
116 gboolean is_required;
120 extcap_arg_type arg_type;
122 extcap_complex *range_start;
123 extcap_complex *range_end;
124 extcap_complex *default_complex;
129 typedef struct _extcap_if {
134 typedef struct _extcap_interface {
139 extcap_sentence_type if_type;
140 struct _extcap_interface *next_interface;
143 typedef struct _extcap_dlt {
148 struct _extcap_dlt *next_dlt;
151 /* Parser internals */
152 typedef struct _extcap_token_param {
156 extcap_param_type param_type;
158 struct _extcap_token_param *next_token;
159 } extcap_token_param;
161 typedef struct _extcap_token_sentence {
164 extcap_token_param *param_list;
166 struct _extcap_token_sentence *next_sentence;
167 } extcap_token_sentence;
173 extcap_interface *extcap_new_interface(void);
174 void extcap_free_interface(extcap_interface *interface);
176 extcap_dlt *extcap_new_dlt(void);
177 void extcap_free_dlt(extcap_dlt *dlt);
179 /* Parse a string into a complex type */
180 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
184 void extcap_free_complex(extcap_complex *comp);
186 /* Print a complex value out for debug */
187 void extcap_printf_complex(extcap_complex *comp);
190 * Return a string representation of a complex type
191 * Caller is responsible for calling g_free on the returned string
193 gchar *extcap_get_complex_as_string(extcap_complex *comp);
195 int extcap_complex_get_int(extcap_complex *comp);
196 unsigned int extcap_complex_get_uint(extcap_complex *comp);
197 long extcap_complex_get_long(extcap_complex *comp);
198 double extcap_complex_get_double(extcap_complex *comp);
199 gboolean extcap_complex_get_bool(extcap_complex *comp);
200 gchar *extcap_complex_get_string(extcap_complex *comp);
202 /* compares the default value of an element with a given parameter */
203 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
205 void extcap_free_tokenized_param(extcap_token_param *v);
206 void extcap_free_tokenized_sentence(extcap_token_sentence *s);
207 void extcap_free_tokenized_sentence_list(extcap_token_sentence *f);
209 /* Turn a sentence into logical tokens, don't validate beyond basic syntax */
210 extcap_token_sentence *extcap_tokenize_sentence(const gchar *s);
212 /* Tokenize a set of sentences (such as the output of a g_spawn_sync) */
213 extcap_token_sentence *extcap_tokenize_sentences(const gchar *s);
215 /* Find an argument in the extcap_arg list which matches the given arg=X number */
216 extcap_arg *extcap_find_numbered_arg(extcap_arg *first, int number);
218 /* Find the first occurrence in a parameter list of a parameter of the given type */
219 extcap_token_param *extcap_find_param_by_type(extcap_token_param *first,
220 extcap_param_type t);
222 void extcap_free_value(extcap_value *v);
224 extcap_arg *extcap_new_arg(void);
226 /* Free a single argument */
227 void extcap_free_arg(extcap_arg *a);
229 /* Free an entire arg list */
230 void extcap_free_arg_list(GList *a);
233 * Parse a tokenized sentence and validate. If a new sentence is created, the result
234 * is returned in 'ra'. On error, < 0 is returned. Not all sentences will create a
235 * new returned sentence (VALUE sentences, for example)
237 extcap_arg * extcap_parse_arg_sentence(GList * args, extcap_token_sentence *s);
239 /* Parse all sentences for args and values */
240 GList * extcap_parse_args(extcap_token_sentence *first_s);
243 * Parse a tokenized set of sentences and validate, looking for interface definitions.
245 int extcap_parse_interface_sentence(extcap_token_sentence *s,
246 extcap_interface **ri);
248 /* Parse all sentences for interfaces */
249 int extcap_parse_interfaces(extcap_token_sentence *first_s,
250 extcap_interface **first_int);
252 /* Parse a tokenized set of sentences and validate, looking for DLT definitions */
253 int extcap_parse_dlt_sentence(extcap_token_sentence *s, extcap_dlt **ri);
255 /* Parse all sentences for DLTs */
256 int extcap_parse_dlts(extcap_token_sentence *first_s, extcap_dlt **first_dlt);
265 * Editor modelines - http://www.wireshark.org/tools/modelines.html
270 * indent-tabs-mode: nil
273 * vi: set shiftwidth=4 tabstop=8 expandtab:
274 * :indentSize=4:tabSize=8:noTabs=true: