| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
/builds/wireshark/wireshark/extcap_parser.h
Go to the documentation of this file.
1
9
10#ifndef __EXTCAP_PARSER_H__
11#define __EXTCAP_PARSER_H__
12
13#include <stdio.h>
14#include <glib.h>
15#include <string.h>
16
17#include "ui/iface_toolbar.h"
18
22 typedef enum {
23 EXTCAP_SENTENCE_UNKNOWN,
24 EXTCAP_SENTENCE_ARG,
25 EXTCAP_SENTENCE_VALUE,
26 EXTCAP_SENTENCE_EXTCAP,
27 EXTCAP_SENTENCE_INTERFACE,
28 EXTCAP_SENTENCE_DLT,
29 EXTCAP_SENTENCE_CONTROL
30} extcap_sentence_type;
31
35 typedef enum {
36 /* Simple types */
37 EXTCAP_ARG_UNKNOWN,
38 EXTCAP_ARG_INTEGER,
39 EXTCAP_ARG_UNSIGNED,
40 EXTCAP_ARG_LONG,
41 EXTCAP_ARG_DOUBLE,
42 EXTCAP_ARG_BOOLEAN,
43 EXTCAP_ARG_BOOLFLAG,
44 EXTCAP_ARG_STRING,
45 EXTCAP_ARG_PASSWORD,
46 /* Complex GUI types which are populated with value sentences */
47 EXTCAP_ARG_SELECTOR,
48 EXTCAP_ARG_EDIT_SELECTOR,
49 EXTCAP_ARG_RADIO,
50 EXTCAP_ARG_MULTICHECK,
51 EXTCAP_ARG_TABLE,
52 EXTCAP_ARG_FILESELECT,
53 EXTCAP_ARG_TIMESTAMP
54} extcap_arg_type;
55
59 typedef enum {
60 EXTCAP_PARAM_UNKNOWN,
61 EXTCAP_PARAM_ARGNUM,
62 EXTCAP_PARAM_CALL,
63 EXTCAP_PARAM_DISPLAY,
64 EXTCAP_PARAM_TYPE,
65 EXTCAP_PARAM_ARG,
66 EXTCAP_PARAM_DEFAULT,
67 EXTCAP_PARAM_VALUE,
68 EXTCAP_PARAM_RANGE,
69 EXTCAP_PARAM_TOOLTIP,
70 EXTCAP_PARAM_PLACEHOLDER,
71 EXTCAP_PARAM_NAME,
72 EXTCAP_PARAM_ENABLED,
73 EXTCAP_PARAM_FILE_MUSTEXIST,
74 EXTCAP_PARAM_FILE_EXTENSION,
75 EXTCAP_PARAM_GROUP,
76 EXTCAP_PARAM_PARENT,
77 EXTCAP_PARAM_REQUIRED,
78 EXTCAP_PARAM_RELOAD,
79 EXTCAP_PARAM_CONFIGURABLE,
80 EXTCAP_PARAM_PREFIX,
81 EXTCAP_PARAM_SAVE,
82 EXTCAP_PARAM_VALIDATION,
83 EXTCAP_PARAM_VERSION,
84 EXTCAP_PARAM_HELP,
85 EXTCAP_PARAM_CONTROL,
86 EXTCAP_PARAM_ROLE
87} extcap_param_type;
88
90#define ENUM_KEY(s) GUINT_TO_POINTER((unsigned)s)
91
95 typedef struct _extcap_value {
96 int arg_num;
97 char *call;
98 char *display;
99 bool enabled;
100 bool is_default;
101 char *parent;
102} extcap_value;
103
107 typedef struct _extcap_complex {
108 extcap_arg_type complex_type;
109 char *_val;
110} extcap_complex;
111
113#define EXTCAP_PARAM_REQUIRED_SUFFICIENT "sufficient"
114
118 typedef struct _extcap_arg {
119 int arg_num;
120 char *call;
121 char *display;
122 char *tooltip;
123 char *placeholder;
124
125 char *fileextension;
126 bool fileexists;
127
128 bool is_required;
129 bool is_sufficient;
130 bool save;
131 bool reload;
132 bool configurable;
133 char *prefix;
134 char *regexp;
135 char *group;
136
137 extcap_arg_type arg_type;
138 extcap_complex *range_start;
139 extcap_complex *range_end;
140 extcap_complex *default_complex;
141
142 char **pref_valptr;
143 char *device_name;
144 GList *values;
145} extcap_arg;
146
150 typedef struct _extcap_interface {
151 char *call;
152 char *display;
153 char *version;
154 char *help;
155 char *extcap_path;
156 unsigned control;
157
158 extcap_sentence_type if_type;
159} extcap_interface;
160
164 typedef struct _extcap_dlt {
165 int number;
166 char *name;
167 char *display;
168} extcap_dlt;
169
173 typedef struct _extcap_token_sentence {
174 char *sentence;
175 GHashTable *param_list;
176} extcap_token_sentence;
177
178#ifdef __cplusplus
179 extern "C" {
180#endif
181
182/* Parse a string into a complex type */
183
191 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
192 const char *data);
193
199/* Free a complex */
200 void extcap_free_complex(extcap_complex *comp);
201
202/* Print a complex value out for debug */
203
209 void extcap_printf_complex(extcap_complex *comp);
210
216 char *extcap_get_complex_as_string(extcap_complex *comp);
217
224 int extcap_complex_get_int(extcap_complex *comp);
225
232 unsigned extcap_complex_get_uint(extcap_complex *comp);
233
240int64_t extcap_complex_get_long(extcap_complex *comp);
241
248 double extcap_complex_get_double(extcap_complex *comp);
249
256 bool extcap_complex_get_bool(extcap_complex *comp);
257
264 char *extcap_complex_get_string(extcap_complex *comp);
265
266/* compares the default value of an element with a given parameter */
267
275 bool extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
276
285 void extcap_free_arg(extcap_arg *a);
286
292 void extcap_free_toolbar_control(iface_toolbar_control *control);
293
301 void extcap_free_arg_list(GList *a);
302
303
305
306/* Parse all sentences for args and values */
307
314GList * extcap_parse_args(char *output);
315
322GList * extcap_parse_values(char *output);
323
333GList * extcap_parse_interfaces(char *output, GList **control_items);
334
344GList * extcap_parse_dlts(char *output);
345
346#ifdef __cplusplus
347}
348#endif
349
350#endif
351
352/*
353 * Editor modelines - https://www.wireshark.org/tools/modelines.html
354 *
355 * Local variables:
356 * c-basic-offset: 4
357 * tab-width: 8
358 * indent-tabs-mode: nil
359 * End:
360 *
361 * vi: set shiftwidth=4 tabstop=8 expandtab:
362 * :indentSize=4:tabSize=8:noTabs=true:
363 */
extcap_token_sentence
struct _extcap_token_sentence extcap_token_sentence
A single tokenized extcap output sentence with its key/value parameter map.
extcap_arg_type
extcap_arg_type
Data type of an extcap argument, controlling its GUI widget and value parsing.
Definition extcap_parser.h:35
EXTCAP_ARG_TIMESTAMP
@ EXTCAP_ARG_TIMESTAMP
Definition extcap_parser.h:53
EXTCAP_ARG_UNSIGNED
@ EXTCAP_ARG_UNSIGNED
Definition extcap_parser.h:39
EXTCAP_ARG_LONG
@ EXTCAP_ARG_LONG
Definition extcap_parser.h:40
EXTCAP_ARG_EDIT_SELECTOR
@ EXTCAP_ARG_EDIT_SELECTOR
Definition extcap_parser.h:48
EXTCAP_ARG_UNKNOWN
@ EXTCAP_ARG_UNKNOWN
Definition extcap_parser.h:37
EXTCAP_ARG_PASSWORD
@ EXTCAP_ARG_PASSWORD
Definition extcap_parser.h:45
EXTCAP_ARG_TABLE
@ EXTCAP_ARG_TABLE
Definition extcap_parser.h:51
EXTCAP_ARG_MULTICHECK
@ EXTCAP_ARG_MULTICHECK
Definition extcap_parser.h:50
EXTCAP_ARG_BOOLFLAG
@ EXTCAP_ARG_BOOLFLAG
Definition extcap_parser.h:43
EXTCAP_ARG_SELECTOR
@ EXTCAP_ARG_SELECTOR
Definition extcap_parser.h:47
EXTCAP_ARG_STRING
@ EXTCAP_ARG_STRING
Definition extcap_parser.h:44
EXTCAP_ARG_RADIO
@ EXTCAP_ARG_RADIO
Definition extcap_parser.h:49
EXTCAP_ARG_INTEGER
@ EXTCAP_ARG_INTEGER
Definition extcap_parser.h:38
EXTCAP_ARG_FILESELECT
@ EXTCAP_ARG_FILESELECT
Definition extcap_parser.h:52
EXTCAP_ARG_BOOLEAN
@ EXTCAP_ARG_BOOLEAN
Definition extcap_parser.h:42
EXTCAP_ARG_DOUBLE
@ EXTCAP_ARG_DOUBLE
Definition extcap_parser.h:41
extcap_parse_interfaces
GList * extcap_parse_interfaces(char *output, GList **control_items)
Parse all sentences for interfaces.
Definition extcap_parser.c:912
extcap_complex
struct _extcap_complex extcap_complex
A typed scalar value used to represent argument defaults and range bounds.
extcap_compare_is_default
bool extcap_compare_is_default(extcap_arg *element, extcap_complex *test)
Compares an argument's default complex value with a test complex value.
Definition extcap_parser.c:48
extcap_complex_get_uint
unsigned extcap_complex_get_uint(extcap_complex *comp)
Retrieves an unsigned integer value from an extcap complex structure.
Definition extcap_parser.c:71
extcap_parse_complex
extcap_complex * extcap_parse_complex(extcap_arg_type complex_type, const char *data)
Parse a complex value from a string.
Definition extcap_parser.c:37
extcap_complex_get_int
int extcap_complex_get_int(extcap_complex *comp)
Retrieves an integer value from an extcap complex structure.
Definition extcap_parser.c:64
extcap_complex_get_string
char * extcap_complex_get_string(extcap_complex *comp)
Get the string value from an extcap complex structure.
Definition extcap_parser.c:105
extcap_printf_complex
void extcap_printf_complex(extcap_complex *comp)
Prints a complex type using its string representation.
Definition extcap_parser.c:27
extcap_interface
struct _extcap_interface extcap_interface
Describes a single capture interface advertised by an extcap binary.
extcap_free_arg_list
void extcap_free_arg_list(GList *a)
Free an entire arg list.
Definition extcap_parser.c:321
extcap_complex_get_long
int64_t extcap_complex_get_long(extcap_complex *comp)
Retrieves a long value from an extcap complex structure.
Definition extcap_parser.c:77
extcap_free_complex
void extcap_free_complex(extcap_complex *comp)
Free a complex value.
Definition extcap_parser.c:58
extcap_parse_args
GList * extcap_parse_args(char *output)
Parses arguments from extcap output.
Definition extcap_parser.c:639
extcap_param_type
extcap_param_type
Token keys for key/value pairs within a parsed extcap sentence.
Definition extcap_parser.h:59
EXTCAP_PARAM_ROLE
@ EXTCAP_PARAM_ROLE
Definition extcap_parser.h:86
EXTCAP_PARAM_ARG
@ EXTCAP_PARAM_ARG
Definition extcap_parser.h:65
EXTCAP_PARAM_PARENT
@ EXTCAP_PARAM_PARENT
Definition extcap_parser.h:76
EXTCAP_PARAM_PREFIX
@ EXTCAP_PARAM_PREFIX
Definition extcap_parser.h:80
EXTCAP_PARAM_NAME
@ EXTCAP_PARAM_NAME
Definition extcap_parser.h:71
EXTCAP_PARAM_FILE_EXTENSION
@ EXTCAP_PARAM_FILE_EXTENSION
Definition extcap_parser.h:74
EXTCAP_PARAM_VALIDATION
@ EXTCAP_PARAM_VALIDATION
Definition extcap_parser.h:82
EXTCAP_PARAM_GROUP
@ EXTCAP_PARAM_GROUP
Definition extcap_parser.h:75
EXTCAP_PARAM_REQUIRED
@ EXTCAP_PARAM_REQUIRED
Definition extcap_parser.h:77
EXTCAP_PARAM_ARGNUM
@ EXTCAP_PARAM_ARGNUM
Definition extcap_parser.h:61
EXTCAP_PARAM_ENABLED
@ EXTCAP_PARAM_ENABLED
Definition extcap_parser.h:72
EXTCAP_PARAM_HELP
@ EXTCAP_PARAM_HELP
Definition extcap_parser.h:84
EXTCAP_PARAM_RANGE
@ EXTCAP_PARAM_RANGE
Definition extcap_parser.h:68
EXTCAP_PARAM_FILE_MUSTEXIST
@ EXTCAP_PARAM_FILE_MUSTEXIST
Definition extcap_parser.h:73
EXTCAP_PARAM_DEFAULT
@ EXTCAP_PARAM_DEFAULT
Definition extcap_parser.h:66
EXTCAP_PARAM_SAVE
@ EXTCAP_PARAM_SAVE
Definition extcap_parser.h:81
EXTCAP_PARAM_VALUE
@ EXTCAP_PARAM_VALUE
Definition extcap_parser.h:67
EXTCAP_PARAM_CONTROL
@ EXTCAP_PARAM_CONTROL
Definition extcap_parser.h:85
EXTCAP_PARAM_DISPLAY
@ EXTCAP_PARAM_DISPLAY
Definition extcap_parser.h:63
EXTCAP_PARAM_TOOLTIP
@ EXTCAP_PARAM_TOOLTIP
Definition extcap_parser.h:69
EXTCAP_PARAM_VERSION
@ EXTCAP_PARAM_VERSION
Definition extcap_parser.h:83
EXTCAP_PARAM_TYPE
@ EXTCAP_PARAM_TYPE
Definition extcap_parser.h:64
EXTCAP_PARAM_PLACEHOLDER
@ EXTCAP_PARAM_PLACEHOLDER
Definition extcap_parser.h:70
EXTCAP_PARAM_CONFIGURABLE
@ EXTCAP_PARAM_CONFIGURABLE
Definition extcap_parser.h:79
EXTCAP_PARAM_RELOAD
@ EXTCAP_PARAM_RELOAD
Definition extcap_parser.h:78
EXTCAP_PARAM_UNKNOWN
@ EXTCAP_PARAM_UNKNOWN
Definition extcap_parser.h:60
EXTCAP_PARAM_CALL
@ EXTCAP_PARAM_CALL
Definition extcap_parser.h:62
extcap_complex_get_bool
bool extcap_complex_get_bool(extcap_complex *comp)
Retrieves the boolean value from an extcap complex structure.
Definition extcap_parser.c:95
extcap_free_toolbar_control
void extcap_free_toolbar_control(iface_toolbar_control *control)
Free entire toolbar control structure.
Definition extcap_parser.c:303
extcap_complex_get_double
double extcap_complex_get_double(extcap_complex *comp)
Retrieves the double value from an extcap_complex structure.
Definition extcap_parser.c:83
extcap_free_arg
void extcap_free_arg(extcap_arg *a)
Free a single argument.
Definition extcap_parser.c:262
extcap_parse_dlts
GList * extcap_parse_dlts(char *output)
Parse all sentences for DLT (Data Link Type) information.
Definition extcap_parser.c:1003
extcap_sentence_type
extcap_sentence_type
Identifies the type of a parsed extcap output sentence.
Definition extcap_parser.h:22
EXTCAP_SENTENCE_UNKNOWN
@ EXTCAP_SENTENCE_UNKNOWN
Definition extcap_parser.h:23
EXTCAP_SENTENCE_VALUE
@ EXTCAP_SENTENCE_VALUE
Definition extcap_parser.h:25
EXTCAP_SENTENCE_DLT
@ EXTCAP_SENTENCE_DLT
Definition extcap_parser.h:28
EXTCAP_SENTENCE_EXTCAP
@ EXTCAP_SENTENCE_EXTCAP
Definition extcap_parser.h:26
EXTCAP_SENTENCE_ARG
@ EXTCAP_SENTENCE_ARG
Definition extcap_parser.h:24
EXTCAP_SENTENCE_CONTROL
@ EXTCAP_SENTENCE_CONTROL
Definition extcap_parser.h:29
EXTCAP_SENTENCE_INTERFACE
@ EXTCAP_SENTENCE_INTERFACE
Definition extcap_parser.h:27
extcap_arg
struct _extcap_arg extcap_arg
A fully parsed extcap argument sentence with all its associated options.
extcap_get_complex_as_string
char * extcap_get_complex_as_string(extcap_complex *comp)
Get a string representation of a complex type.
Definition extcap_parser.c:33
extcap_dlt
struct _extcap_dlt extcap_dlt
Describes a data link type (DLT) supported by an extcap interface.
extcap_parse_values
GList * extcap_parse_values(char *output)
Parse all sentences for values.
Definition extcap_parser.c:662
extcap_value
struct _extcap_value extcap_value
A single selectable value option associated with a selector, radio, or multicheck argument.
iface_toolbar.h
iface_toolbar_control
struct _iface_toolbar_control iface_toolbar_control
Describes a single control widget within an interface toolbar.
_extcap_arg
A fully parsed extcap argument sentence with all its associated options.
Definition extcap_parser.h:118
_extcap_arg::reload
bool reload
Definition extcap_parser.h:131
_extcap_arg::save
bool save
Definition extcap_parser.h:130
_extcap_arg::call
char * call
Definition extcap_parser.h:120
_extcap_arg::fileextension
char * fileextension
Definition extcap_parser.h:125
_extcap_arg::prefix
char * prefix
Definition extcap_parser.h:133
_extcap_arg::device_name
char * device_name
Definition extcap_parser.h:143
_extcap_arg::tooltip
char * tooltip
Definition extcap_parser.h:122
_extcap_arg::is_sufficient
bool is_sufficient
Definition extcap_parser.h:129
_extcap_arg::arg_type
extcap_arg_type arg_type
Definition extcap_parser.h:137
_extcap_arg::is_required
bool is_required
Definition extcap_parser.h:128
_extcap_arg::range_start
extcap_complex * range_start
Definition extcap_parser.h:138
_extcap_arg::default_complex
extcap_complex * default_complex
Definition extcap_parser.h:140
_extcap_arg::regexp
char * regexp
Definition extcap_parser.h:134
_extcap_arg::values
GList * values
Definition extcap_parser.h:144
_extcap_arg::fileexists
bool fileexists
Definition extcap_parser.h:126
_extcap_arg::display
char * display
Definition extcap_parser.h:121
_extcap_arg::arg_num
int arg_num
Definition extcap_parser.h:119
_extcap_arg::configurable
bool configurable
Definition extcap_parser.h:132
_extcap_arg::placeholder
char * placeholder
Definition extcap_parser.h:123
_extcap_arg::group
char * group
Definition extcap_parser.h:135
_extcap_arg::pref_valptr
char ** pref_valptr
Definition extcap_parser.h:142
_extcap_arg::range_end
extcap_complex * range_end
Definition extcap_parser.h:139
_extcap_complex
A typed scalar value used to represent argument defaults and range bounds.
Definition extcap_parser.h:107
_extcap_complex::_val
char * _val
Definition extcap_parser.h:109
_extcap_complex::complex_type
extcap_arg_type complex_type
Definition extcap_parser.h:108
_extcap_dlt
Describes a data link type (DLT) supported by an extcap interface.
Definition extcap_parser.h:164
_extcap_dlt::display
char * display
Definition extcap_parser.h:167
_extcap_dlt::number
int number
Definition extcap_parser.h:165
_extcap_dlt::name
char * name
Definition extcap_parser.h:166
_extcap_interface
Describes a single capture interface advertised by an extcap binary.
Definition extcap_parser.h:150
_extcap_interface::help
char * help
Definition extcap_parser.h:154
_extcap_interface::control
unsigned control
Definition extcap_parser.h:156
_extcap_interface::call
char * call
Definition extcap_parser.h:151
_extcap_interface::extcap_path
char * extcap_path
Definition extcap_parser.h:155
_extcap_interface::display
char * display
Definition extcap_parser.h:152
_extcap_interface::version
char * version
Definition extcap_parser.h:153
_extcap_interface::if_type
extcap_sentence_type if_type
Definition extcap_parser.h:158
_extcap_token_sentence
A single tokenized extcap output sentence with its key/value parameter map.
Definition extcap_parser.h:173
_extcap_token_sentence::param_list
GHashTable * param_list
Definition extcap_parser.h:175
_extcap_token_sentence::sentence
char * sentence
Definition extcap_parser.h:174
_extcap_value
A single selectable value option associated with a selector, radio, or multicheck argument.
Definition extcap_parser.h:95
_extcap_value::is_default
bool is_default
Definition extcap_parser.h:100
_extcap_value::parent
char * parent
Definition extcap_parser.h:101
_extcap_value::enabled
bool enabled
Definition extcap_parser.h:99
_extcap_value::arg_num
int arg_num
Definition extcap_parser.h:96
_extcap_value::display
char * display
Definition extcap_parser.h:98
_extcap_value::call
char * call
Definition extcap_parser.h:97