lorawan: Fix Join Request and Join Accept
[metze/wireshark/wip.git] / extcap_parser.h
1 /* extcap_parser.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
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.
11  *
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.
16  *
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.
20  */
21
22 #ifndef __EXTCAP_PARSER_H__
23 #define __EXTCAP_PARSER_H__
24
25 #include <stdio.h>
26 #include <glib.h>
27 #include <string.h>
28
29 #include <config.h>
30
31 typedef enum {
32     EXTCAP_SENTENCE_UNKNOWN,
33     EXTCAP_SENTENCE_ARG,
34     EXTCAP_SENTENCE_VALUE,
35     EXTCAP_SENTENCE_EXTCAP,
36     EXTCAP_SENTENCE_INTERFACE,
37     EXTCAP_SENTENCE_DLT,
38     EXTCAP_SENTENCE_CONTROL
39 } extcap_sentence_type;
40
41 typedef enum {
42     /* Simple types */
43     EXTCAP_ARG_UNKNOWN,
44     EXTCAP_ARG_INTEGER,
45     EXTCAP_ARG_UNSIGNED,
46     EXTCAP_ARG_LONG,
47     EXTCAP_ARG_DOUBLE,
48     EXTCAP_ARG_BOOLEAN,
49     EXTCAP_ARG_BOOLFLAG,
50     EXTCAP_ARG_STRING,
51     EXTCAP_ARG_PASSWORD,
52     /* Complex GUI types which are populated with value sentences */
53     EXTCAP_ARG_SELECTOR,
54     EXTCAP_ARG_RADIO,
55     EXTCAP_ARG_MULTICHECK,
56     EXTCAP_ARG_FILESELECT,
57     EXTCAP_ARG_TIMESTAMP
58 } extcap_arg_type;
59
60 typedef enum {
61     /* value types */
62     EXTCAP_PARAM_UNKNOWN,
63     EXTCAP_PARAM_ARGNUM,
64     EXTCAP_PARAM_CALL,
65     EXTCAP_PARAM_DISPLAY,
66     EXTCAP_PARAM_TYPE,
67     EXTCAP_PARAM_ARG,
68     EXTCAP_PARAM_DEFAULT,
69     EXTCAP_PARAM_VALUE,
70     EXTCAP_PARAM_RANGE,
71     EXTCAP_PARAM_TOOLTIP,
72     EXTCAP_PARAM_PLACEHOLDER,
73     EXTCAP_PARAM_NAME,
74     EXTCAP_PARAM_ENABLED,
75     EXTCAP_PARAM_FILE_MUSTEXIST,
76     EXTCAP_PARAM_FILE_EXTENSION,
77     EXTCAP_PARAM_PARENT,
78     EXTCAP_PARAM_REQUIRED,
79     EXTCAP_PARAM_SAVE,
80     EXTCAP_PARAM_VALIDATION,
81     EXTCAP_PARAM_VERSION,
82     EXTCAP_PARAM_HELP,
83     EXTCAP_PARAM_CONTROL,
84     EXTCAP_PARAM_ROLE
85 } extcap_param_type;
86
87 #define ENUM_KEY(s) GUINT_TO_POINTER((guint)s)
88
89 /* Values for a given sentence; values are all stored as a call
90  * and a value string, or a valid range, so we only need to store
91  * those and repeat them */
92 typedef struct _extcap_value {
93     int arg_num;
94
95     gchar *call;
96     gchar *display;
97     gboolean enabled;
98     gboolean is_default;
99     gchar *parent;
100 } extcap_value;
101
102 /* Complex-ish struct for storing complex values */
103 typedef struct _extcap_complex {
104     extcap_arg_type complex_type;
105     gchar * _val;
106 } extcap_complex;
107
108 /* An argument sentence and accompanying options */
109 typedef struct _extcap_arg {
110     int arg_num;
111
112     gchar *call;
113     gchar *display;
114     gchar *tooltip;
115     gchar *placeholder;
116
117     gchar * fileextension;
118     gboolean fileexists;
119
120     gboolean is_required;
121     gboolean save;
122
123     gchar * regexp;
124
125     extcap_arg_type arg_type;
126
127     extcap_complex *range_start;
128     extcap_complex *range_end;
129     extcap_complex *default_complex;
130
131     gchar ** pref_valptr; /**< A copy of the pointer containing the current preference value. */
132     gchar * device_name;
133
134     GList * values;
135 } extcap_arg;
136
137 typedef struct _extcap_interface {
138     gchar * call;
139     gchar * display;
140     gchar * version;
141     gchar * help;
142     gchar * extcap_path;
143
144     extcap_sentence_type if_type;
145 } extcap_interface;
146
147 typedef struct _extcap_dlt {
148     gint number;
149     gchar *name;
150     gchar *display;
151 } extcap_dlt;
152
153 typedef struct _extcap_token_sentence {
154     gchar *sentence;
155
156     GHashTable *param_list;
157 } extcap_token_sentence;
158
159 #ifdef __cplusplus
160 extern "C" {
161 #endif
162
163 /* Parse a string into a complex type */
164 extcap_complex *extcap_parse_complex(extcap_arg_type complex_type,
165         const gchar *data);
166
167 /* Free a complex */
168 void extcap_free_complex(extcap_complex *comp);
169
170 /* Print a complex value out for debug */
171 void extcap_printf_complex(extcap_complex *comp);
172
173 /*
174  * Return a string representation of a complex type
175  * Caller is responsible for calling g_free on the returned string
176  */
177 gchar *extcap_get_complex_as_string(extcap_complex *comp);
178
179 gint extcap_complex_get_int(extcap_complex *comp);
180 guint extcap_complex_get_uint(extcap_complex *comp);
181 gint64 extcap_complex_get_long(extcap_complex *comp);
182 gdouble extcap_complex_get_double(extcap_complex *comp);
183 gboolean extcap_complex_get_bool(extcap_complex *comp);
184 gchar *extcap_complex_get_string(extcap_complex *comp);
185
186 /* compares the default value of an element with a given parameter */
187 gboolean extcap_compare_is_default(extcap_arg *element, extcap_complex *test);
188
189
190 /* Free a single argument */
191 void extcap_free_arg(extcap_arg *a);
192
193 /* Free an entire arg list */
194 void extcap_free_arg_list(GList *a);
195
196
197 /** Parser for extcap data */
198
199 /* Parse all sentences for args and values */
200 GList * extcap_parse_args(gchar *output);
201
202 /* Parse all sentences for interfaces */
203 GList * extcap_parse_interfaces(gchar *output, GList **control_items);
204
205 /* Parse all sentences for DLTs */
206 GList * extcap_parse_dlts(gchar *output);
207
208 #ifdef __cplusplus
209 }
210 #endif
211
212 #endif
213
214 /*
215  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
216  *
217  * Local variables:
218  * c-basic-offset: 4
219  * tab-width: 8
220  * indent-tabs-mode: nil
221  * End:
222  *
223  * vi: set shiftwidth=4 tabstop=8 expandtab:
224  * :indentSize=4:tabSize=8:noTabs=true:
225  */