| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
/builds/wireshark/wireshark/extcap_parser.h
Go to the documentation of this file.
1
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
19 typedef enum {
20 EXTCAP_SENTENCE_UNKNOWN,
21 EXTCAP_SENTENCE_ARG,
22 EXTCAP_SENTENCE_VALUE,
23 EXTCAP_SENTENCE_EXTCAP,
24 EXTCAP_SENTENCE_INTERFACE,
25 EXTCAP_SENTENCE_DLT,
26 EXTCAP_SENTENCE_CONTROL
27} extcap_sentence_type;
28
29 typedef enum {
30 /* Simple types */
31 EXTCAP_ARG_UNKNOWN,
32 EXTCAP_ARG_INTEGER,
33 EXTCAP_ARG_UNSIGNED,
34 EXTCAP_ARG_LONG,
35 EXTCAP_ARG_DOUBLE,
36 EXTCAP_ARG_BOOLEAN,
37 EXTCAP_ARG_BOOLFLAG,
38 EXTCAP_ARG_STRING,
39 EXTCAP_ARG_PASSWORD,
40 /* Complex GUI types which are populated with value sentences */
41 EXTCAP_ARG_SELECTOR,
42 EXTCAP_ARG_EDIT_SELECTOR,
43 EXTCAP_ARG_RADIO,
44 EXTCAP_ARG_MULTICHECK,
45 EXTCAP_ARG_TABLE,
46 EXTCAP_ARG_FILESELECT,
47 EXTCAP_ARG_TIMESTAMP
48} extcap_arg_type;
49
50 typedef enum {
51 /* value types */
52 EXTCAP_PARAM_UNKNOWN,
53 EXTCAP_PARAM_ARGNUM,
54 EXTCAP_PARAM_CALL,
55 EXTCAP_PARAM_DISPLAY,
56 EXTCAP_PARAM_TYPE,
57 EXTCAP_PARAM_ARG,
58 EXTCAP_PARAM_DEFAULT,
59 EXTCAP_PARAM_VALUE,
60 EXTCAP_PARAM_RANGE,
61 EXTCAP_PARAM_TOOLTIP,
62 EXTCAP_PARAM_PLACEHOLDER,
63 EXTCAP_PARAM_NAME,
64 EXTCAP_PARAM_ENABLED,
65 EXTCAP_PARAM_FILE_MUSTEXIST,
66 EXTCAP_PARAM_FILE_EXTENSION,
67 EXTCAP_PARAM_GROUP,
68 EXTCAP_PARAM_PARENT,
69 EXTCAP_PARAM_REQUIRED,
70 EXTCAP_PARAM_RELOAD,
71 EXTCAP_PARAM_CONFIGURABLE,
72 EXTCAP_PARAM_PREFIX,
73 EXTCAP_PARAM_SAVE,
74 EXTCAP_PARAM_VALIDATION,
75 EXTCAP_PARAM_VERSION,
76 EXTCAP_PARAM_HELP,
77 EXTCAP_PARAM_CONTROL,
78 EXTCAP_PARAM_ROLE
79} extcap_param_type;
80
81#define ENUM_KEY(s) GUINT_TO_POINTER((unsigned)s)
82
83/* Values for a given sentence; values are all stored as a call
84 * and a value string, or a valid range, so we only need to store
85 * those and repeat them */
86 typedef struct _extcap_value {
87 int arg_num;
88
89 char *call;
90 char *display;
91 bool enabled;
92 bool is_default;
93 char *parent;
94} extcap_value;
95
96/* Complex-ish struct for storing complex values */
97 typedef struct _extcap_complex {
98 extcap_arg_type complex_type;
99 char * _val;
100} extcap_complex;
101
102/* required=sufficient has a special meaning */
103#define EXTCAP_PARAM_REQUIRED_SUFFICIENT "sufficient"
104
105/* An argument sentence and accompanying options */
106 typedef struct _extcap_arg {
107 int arg_num;
108
109 char *call;
110 char *display;
111 char *tooltip;
112 char *placeholder;
113
114 char * fileextension;
115 bool fileexists;
116
117 bool is_required;
118 bool is_sufficient;
119 bool save;
120
121 bool reload;
122
123 bool configurable;
124 char * prefix;
125
126 char * regexp;
127
128 char * group;
129
130 extcap_arg_type arg_type;
131
132 extcap_complex *range_start;
133 extcap_complex *range_end;
134 extcap_complex *default_complex;
135
136 char ** pref_valptr;
137 char * device_name;
138
139 GList * values;
140} extcap_arg;
141
142 typedef struct _extcap_interface {
143 char * call;
144 char * display;
145 char * version;
146 char * help;
147 char * extcap_path;
148
149 extcap_sentence_type if_type;
150} extcap_interface;
151
152 typedef struct _extcap_dlt {
153 int number;
154 char *name;
155 char *display;
156} extcap_dlt;
157
158 typedef struct _extcap_token_sentence {
159 char *sentence;
160
161 GHashTable *param_list;
162} extcap_token_sentence;
163
164#ifdef __cplusplus
165 extern "C" {
166#endif
167
168/* Parse a string into a complex type */
169
177 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
178 const char *data);
179
185/* Free a complex */
186 void extcap_free_complex(extcap_complex *comp);
187
188/* Print a complex value out for debug */
189
195 void extcap_printf_complex(extcap_complex *comp);
196
202 char *extcap_get_complex_as_string(extcap_complex *comp);
203
210 int extcap_complex_get_int(extcap_complex *comp);
211
218 unsigned extcap_complex_get_uint(extcap_complex *comp);
219
226int64_t extcap_complex_get_long(extcap_complex *comp);
227
234 double extcap_complex_get_double(extcap_complex *comp);
235
242 bool extcap_complex_get_bool(extcap_complex *comp);
243
250 char *extcap_complex_get_string(extcap_complex *comp);
251
252/* compares the default value of an element with a given parameter */
253
261 bool extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
262
271 void extcap_free_arg(extcap_arg *a);
272
278 void extcap_free_toolbar_control(iface_toolbar_control *control);
279
287 void extcap_free_arg_list(GList *a);
288
289
292/* Parse all sentences for args and values */
293GList * extcap_parse_args(char *output);
294
301GList * extcap_parse_values(char *output);
302
312GList * extcap_parse_interfaces(char *output, GList **control_items);
313
323GList * extcap_parse_dlts(char *output);
324
325#ifdef __cplusplus
326}
327#endif
328
329#endif
330
331/*
332 * Editor modelines - https://www.wireshark.org/tools/modelines.html
333 *
334 * Local variables:
335 * c-basic-offset: 4
336 * tab-width: 8
337 * indent-tabs-mode: nil
338 * End:
339 *
340 * vi: set shiftwidth=4 tabstop=8 expandtab:
341 * :indentSize=4:tabSize=8:noTabs=true:
342 */
extcap_parse_interfaces
GList * extcap_parse_interfaces(char *output, GList **control_items)
Parse all sentences for interfaces.
Definition extcap_parser.c:903
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_free_arg_list
void extcap_free_arg_list(GList *a)
Free an entire arg list.
Definition extcap_parser.c:320
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)
Definition extcap_parser.c:638
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:302
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:994
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_parse_values
GList * extcap_parse_values(char *output)
Parse all sentences for values.
Definition extcap_parser.c:661
iface_toolbar.h
_extcap_arg
Definition extcap_parser.h:106
_extcap_arg::pref_valptr
char ** pref_valptr
Definition extcap_parser.h:136
_extcap_complex
Definition extcap_parser.h:97
_extcap_dlt
Definition extcap_parser.h:152
_extcap_interface
Definition extcap_parser.h:142
_extcap_token_sentence
Definition extcap_parser.h:158
_extcap_value
Definition extcap_parser.h:86
_iface_toolbar_control
Definition iface_toolbar.h:44