3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #ifndef __EXTCAP_PARSER_H__
11 #define __EXTCAP_PARSER_H__
17 #include "ui/iface_toolbar.h"
20 EXTCAP_SENTENCE_UNKNOWN
,
22 EXTCAP_SENTENCE_VALUE
,
23 EXTCAP_SENTENCE_EXTCAP
,
24 EXTCAP_SENTENCE_INTERFACE
,
26 EXTCAP_SENTENCE_CONTROL
27 } extcap_sentence_type
;
40 /* Complex GUI types which are populated with value sentences */
42 EXTCAP_ARG_EDIT_SELECTOR
,
44 EXTCAP_ARG_MULTICHECK
,
45 EXTCAP_ARG_FILESELECT
,
61 EXTCAP_PARAM_PLACEHOLDER
,
64 EXTCAP_PARAM_FILE_MUSTEXIST
,
65 EXTCAP_PARAM_FILE_EXTENSION
,
68 EXTCAP_PARAM_REQUIRED
,
71 EXTCAP_PARAM_VALIDATION
,
78 #define ENUM_KEY(s) GUINT_TO_POINTER((unsigned)s)
80 /* Values for a given sentence; values are all stored as a call
81 * and a value string, or a valid range, so we only need to store
82 * those and repeat them */
83 typedef struct _extcap_value
{
93 /* Complex-ish struct for storing complex values */
94 typedef struct _extcap_complex
{
95 extcap_arg_type complex_type
;
99 /* An argument sentence and accompanying options */
100 typedef struct _extcap_arg
{
108 char * fileextension
;
120 extcap_arg_type arg_type
;
122 extcap_complex
*range_start
;
123 extcap_complex
*range_end
;
124 extcap_complex
*default_complex
;
126 char ** pref_valptr
; /**< A copy of the pointer containing the current preference value. */
132 typedef struct _extcap_interface
{
139 extcap_sentence_type if_type
;
142 typedef struct _extcap_dlt
{
148 typedef struct _extcap_token_sentence
{
151 GHashTable
*param_list
;
152 } extcap_token_sentence
;
158 /* Parse a string into a complex type */
159 extcap_complex
*extcap_parse_complex(extcap_arg_type complex_type
,
163 void extcap_free_complex(extcap_complex
*comp
);
165 /* Print a complex value out for debug */
166 void extcap_printf_complex(extcap_complex
*comp
);
169 * Return a string representation of a complex type
170 * Caller is responsible for calling g_free on the returned string
172 char *extcap_get_complex_as_string(extcap_complex
*comp
);
174 int extcap_complex_get_int(extcap_complex
*comp
);
175 unsigned extcap_complex_get_uint(extcap_complex
*comp
);
176 int64_t extcap_complex_get_long(extcap_complex
*comp
);
177 double extcap_complex_get_double(extcap_complex
*comp
);
178 bool extcap_complex_get_bool(extcap_complex
*comp
);
179 char *extcap_complex_get_string(extcap_complex
*comp
);
181 /* compares the default value of an element with a given parameter */
182 bool extcap_compare_is_default(extcap_arg
*element
, extcap_complex
*test
);
185 /* Free a single argument */
186 void extcap_free_arg(extcap_arg
*a
);
188 /* Free entire toolbar control structure */
189 void extcap_free_toolbar_control(iface_toolbar_control
*control
);
191 /* Free an entire arg list */
192 void extcap_free_arg_list(GList
*a
);
195 /** Parser for extcap data */
197 /* Parse all sentences for args and values */
198 GList
* extcap_parse_args(char *output
);
200 /* Parse all sentences for values */
201 GList
* extcap_parse_values(char *output
);
203 /* Parse all sentences for interfaces */
204 GList
* extcap_parse_interfaces(char *output
, GList
**control_items
);
206 /* Parse all sentences for DLTs */
207 GList
* extcap_parse_dlts(char *output
);
216 * Editor modelines - https://www.wireshark.org/tools/modelines.html
221 * indent-tabs-mode: nil
224 * vi: set shiftwidth=4 tabstop=8 expandtab:
225 * :indentSize=4:tabSize=8:noTabs=true: