GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/hostapd/parse.c Lines: 0 515 0.0 %
Date: 2017-11-07 Branches: 0 376 0.0 %

Line Branch Exec Source
1
#include <stdlib.h>
2
#include <string.h>
3
#define YYBYACC 1
4
#define YYMAJOR 1
5
#define YYMINOR 9
6
#define YYLEX yylex()
7
#define YYEMPTY -1
8
#define yyclearin (yychar=(YYEMPTY))
9
#define yyerrok (yyerrflag=0)
10
#define YYRECOVERING() (yyerrflag!=0)
11
#define YYPREFIX "yy"
12
#line 24 "parse.y"
13
#include <sys/ioctl.h>
14
#include <sys/types.h>
15
#include <sys/socket.h>
16
#include <sys/time.h>
17
#include <sys/queue.h>
18
#include <sys/stat.h>
19
20
#include <net/if.h>
21
#include <net/if_dl.h>
22
#include <net/if_media.h>
23
#include <net/if_arp.h>
24
#include <net/if_llc.h>
25
#include <net/bpf.h>
26
27
#include <netinet/in.h>
28
#include <netinet/if_ether.h>
29
#include <arpa/inet.h>
30
31
#include <net80211/ieee80211.h>
32
#include <net80211/ieee80211_radiotap.h>
33
34
#include <ctype.h>
35
#include <errno.h>
36
#include <event.h>
37
#include <fcntl.h>
38
#include <stdio.h>
39
#include <stdlib.h>
40
#include <stdarg.h>
41
#include <string.h>
42
#include <unistd.h>
43
#include <limits.h>
44
#include <stdint.h>
45
#include <err.h>
46
47
#include "hostapd.h"
48
49
TAILQ_HEAD(files, file)		 files = TAILQ_HEAD_INITIALIZER(files);
50
static struct file {
51
	TAILQ_ENTRY(file)	 entry;
52
	FILE			*stream;
53
	char			*name;
54
	int			 lineno;
55
	int			 errors;
56
} *file, *topfile;
57
struct file	*pushfile(const char *, int);
58
int		 popfile(void);
59
int		 check_file_secrecy(int, const char *);
60
int		 yyparse(void);
61
int		 yylex(void);
62
int		 yyerror(const char *, ...)
63
    __attribute__((__format__ (printf, 1, 2)))
64
    __attribute__((__nonnull__ (1)));
65
int		 kw_cmp(const void *, const void *);
66
int		 lookup(char *);
67
int		 lgetc(int);
68
int		 lungetc(int);
69
int		 findeol(void);
70
71
TAILQ_HEAD(symhead, sym)	 symhead = TAILQ_HEAD_INITIALIZER(symhead);
72
struct sym {
73
	TAILQ_ENTRY(sym)	 entry;
74
	int			 used;
75
	int			 persist;
76
	char			*nam;
77
	char			*val;
78
};
79
int		 symset(const char *, const char *, int);
80
char		*symget(const char *);
81
82
extern struct hostapd_config hostapd_cfg;
83
84
typedef struct {
85
	union {
86
		struct {
87
			u_int8_t		lladdr[IEEE80211_ADDR_LEN];
88
			struct hostapd_table	*table;
89
			u_int32_t		flags;
90
		} reflladdr;
91
		struct {
92
			u_int16_t		alg;
93
			u_int16_t		transaction;
94
		} authalg;
95
		struct in_addr		in;
96
		char			*string;
97
		int64_t			number;
98
		u_int16_t		reason;
99
		enum hostapd_op		op;
100
		struct timeval		timeout;
101
	} v;
102
	int lineno;
103
} YYSTYPE;
104
105
struct hostapd_apme *apme;
106
struct hostapd_table *table;
107
struct hostapd_entry *entry;
108
struct hostapd_frame frame, *frame_ptr;
109
struct hostapd_ieee80211_frame *frame_ieee80211;
110
111
#define HOSTAPD_MATCH(_m, _not)	{					\
112
	frame.f_flags |= (_not) ?					\
113
	    HOSTAPD_FRAME_F_##_m##_N : HOSTAPD_FRAME_F_##_m;		\
114
}
115
#define HOSTAPD_MATCH_TABLE(_m, _not)	{				\
116
	frame.f_flags |= HOSTAPD_FRAME_F_##_m##_TABLE | ((_not) ?	\
117
	    HOSTAPD_FRAME_F_##_m##_N : HOSTAPD_FRAME_F_##_m);		\
118
}
119
#define HOSTAPD_MATCH_RADIOTAP(_x) {					\
120
	if (hostapd_cfg.c_apme_dlt == DLT_IEEE802_11 ||			\
121
	    (hostapd_cfg.c_apme_dlt == 0 &&				\
122
	    HOSTAPD_DLT == DLT_IEEE802_11)) {				\
123
		yyerror("option %s requires radiotap headers", #_x);	\
124
		YYERROR;						\
125
	}								\
126
	frame.f_radiotap |= HOSTAPD_RADIOTAP_F(RSSI);			\
127
	frame.f_flags |= HOSTAPD_FRAME_F_##_x;				\
128
}
129
#define HOSTAPD_IAPP_FLAG(_f, _not) {					\
130
	if (_not)							\
131
		hostapd_cfg.c_iapp.i_flags &= ~(HOSTAPD_IAPP_F_##_f);	\
132
	else								\
133
		hostapd_cfg.c_iapp.i_flags |= (HOSTAPD_IAPP_F_##_f);	\
134
}
135
136
#line 137 "parse.c"
137
#define MODE 257
138
#define INTERFACE 258
139
#define IAPP 259
140
#define HOSTAP 260
141
#define MULTICAST 261
142
#define BROADCAST 262
143
#define SET 263
144
#define SEC 264
145
#define USEC 265
146
#define HANDLE 266
147
#define TYPE 267
148
#define SUBTYPE 268
149
#define FROM 269
150
#define TO 270
151
#define BSSID 271
152
#define WITH 272
153
#define FRAME 273
154
#define RADIOTAP 274
155
#define NWID 275
156
#define PASSIVE 276
157
#define MANAGEMENT 277
158
#define DATA 278
159
#define PROBE 279
160
#define BEACON 280
161
#define ATIM 281
162
#define ANY 282
163
#define DS 283
164
#define NO 284
165
#define DIR 285
166
#define RESEND 286
167
#define RANDOM 287
168
#define AUTH 288
169
#define DEAUTH 289
170
#define ASSOC 290
171
#define DISASSOC 291
172
#define REASSOC 292
173
#define REQUEST 293
174
#define RESPONSE 294
175
#define PCAP 295
176
#define RATE 296
177
#define ERROR 297
178
#define CONST 298
179
#define TABLE 299
180
#define NODE 300
181
#define DELETE 301
182
#define ADD 302
183
#define LOG 303
184
#define VERBOSE 304
185
#define LIMIT 305
186
#define QUICK 306
187
#define SKIP 307
188
#define REASON 308
189
#define UNSPECIFIED 309
190
#define EXPIRE 310
191
#define LEAVE 311
192
#define TOOMANY 312
193
#define NOT 313
194
#define AUTHED 314
195
#define ASSOCED 315
196
#define RESERVED 316
197
#define RSN 317
198
#define REQUIRED 318
199
#define INCONSISTENT 319
200
#define IE 320
201
#define INVALID 321
202
#define MIC 322
203
#define FAILURE 323
204
#define OPEN 324
205
#define ADDRESS 325
206
#define PORT 326
207
#define ON 327
208
#define NOTIFY 328
209
#define TTL 329
210
#define INCLUDE 330
211
#define ROUTE 331
212
#define ROAMING 332
213
#define RSSI 333
214
#define TXRATE 334
215
#define FREQ 335
216
#define HOPPER 336
217
#define DELAY 337
218
#define NE 338
219
#define LE 339
220
#define GE 340
221
#define ARROW 341
222
#define STRING 342
223
#define NUMBER 343
224
#define YYERRCODE 256
225
const short yylhs[] =
226
	{                                        -1,
227
    0,    0,    0,    0,    0,    0,    0,    0,   17,   19,
228
   19,   19,   19,   19,   19,   19,   19,   19,   26,   26,
229
   28,   28,   29,   29,   30,   30,   24,   24,   22,   22,
230
   32,   32,   33,   23,   23,   35,   35,   36,   37,   37,
231
   39,   42,   20,   27,   27,   45,   45,   46,   46,   46,
232
   46,   38,   38,   38,   41,   41,   41,   41,   41,   41,
233
   47,   47,   49,   50,   50,   40,   40,   51,   51,   48,
234
   43,   43,   43,   44,   44,   52,   52,   52,   52,   63,
235
   63,   63,   64,   64,   64,   64,   64,   64,   64,   64,
236
   64,   64,   64,   65,   65,   68,   68,   69,   66,   66,
237
   10,   10,   67,    7,    7,    7,    7,    7,    7,    7,
238
    7,    7,    7,    7,    7,    7,    7,    7,   53,   53,
239
   53,   70,   70,   70,   70,   54,   54,   54,   55,   55,
240
   55,   56,   56,   56,   57,   57,   71,   71,   72,   72,
241
   72,    6,    6,   58,   58,   73,   59,   59,   60,   61,
242
   62,    5,    5,    5,    8,   75,   18,   74,   74,   76,
243
   76,   77,   77,   77,    9,    9,   21,    2,    2,    2,
244
   78,   78,   81,   79,   80,   80,   80,    1,   83,   83,
245
    3,    4,   25,   25,   82,   84,   34,   34,   31,   31,
246
   15,   15,   15,   11,   11,   11,   11,   11,   11,   11,
247
   11,   11,   12,   13,   14,   16,
248
};
249
const short yylen[] =
250
	{                                         2,
251
    0,    2,    3,    3,    3,    3,    3,    3,    2,    4,
252
    5,    5,    4,    5,    4,    6,    6,    5,    4,    2,
253
    0,    2,    0,    2,    0,    2,    1,    1,    5,    1,
254
    1,    3,    1,    5,    1,    1,    3,    1,    0,    3,
255
    0,    0,   10,    5,    1,    1,    3,    3,    2,    3,
256
    3,    0,    1,    1,    0,    3,    3,    3,    4,    2,
257
    0,    1,    3,    1,    1,    1,    7,    0,    1,    5,
258
    0,    3,    3,    0,    5,    0,    2,    3,    4,    0,
259
    2,    3,    3,    3,    2,    1,    2,    2,    2,    2,
260
    2,    2,    2,    0,    1,    2,    1,    3,    0,    1,
261
    2,    2,    1,    0,    2,    3,    3,    3,    3,    3,
262
    3,    3,    4,    2,    3,    3,    3,    3,    0,    2,
263
    3,    2,    2,    2,    3,    0,    2,    3,    0,    2,
264
    3,    0,    2,    3,    0,    1,    2,    1,    3,    3,
265
    3,    1,    1,    2,    3,    2,    0,    2,    2,    2,
266
    2,    1,    1,    1,    3,    0,    4,    0,    1,    2,
267
    1,    1,    3,    5,    2,    1,    3,    2,    2,    2,
268
    1,    3,    0,    3,    0,    3,    2,    1,    0,    2,
269
    1,    1,    0,    1,    1,    1,    0,    2,    0,    1,
270
    0,    1,    1,    0,    1,    1,    1,    1,    1,    1,
271
    1,    1,    1,    1,    1,    1,
272
};
273
const short yydefred[] =
274
	{                                      1,
275
    0,    0,    0,    0,    0,    0,    0,    2,    0,    0,
276
    0,    0,    0,    8,   41,    0,    0,    0,  156,    9,
277
    0,    3,    4,    5,    6,    7,    0,    0,    0,    0,
278
    0,    0,    0,    0,    0,    0,    0,  166,    0,   53,
279
   54,    0,    0,    0,   15,    0,    0,    0,    0,   27,
280
   28,   13,   33,    0,   10,   30,    0,    0,  155,  162,
281
    0,  157,    0,  161,  165,    0,    0,    0,    0,    0,
282
   20,  184,   14,  193,    0,  192,    0,   18,   45,    0,
283
    0,  190,    0,   38,    0,   11,   35,  206,   12,    0,
284
  160,    0,   69,   66,   42,    0,  178,   22,    0,   24,
285
    0,   49,    0,    0,    0,   16,   17,    0,   31,    0,
286
  181,  163,  173,    0,  171,   40,    0,    0,    0,    0,
287
   19,    0,   46,   48,   51,   50,    0,    0,    0,    0,
288
   36,    0,    0,    0,    0,    0,   77,    0,    0,    0,
289
   26,    0,    0,  188,   29,   32,    0,    0,  185,  186,
290
  174,    0,    0,  164,  172,    0,    0,   60,    0,    0,
291
    0,    0,    0,   78,  120,    0,    0,    0,   44,   47,
292
   34,   37,    0,  177,    0,   58,    0,   57,    0,   64,
293
   65,    0,   62,   56,    0,    0,   43,    0,   79,    0,
294
    0,    0,    0,  121,  127,    0,    0,    0,    0,  176,
295
    0,    0,  144,    0,    0,  182,    0,  154,  152,  153,
296
   59,   72,   73,    0,   81,    0,  124,  123,    0,  122,
297
  143,  128,  142,  130,    0,    0,    0,  180,   63,    0,
298
  145,  148,    0,    0,  168,  169,  170,    0,    0,    0,
299
   86,    0,    0,    0,    0,    0,   82,  125,  131,  133,
300
    0,    0,    0,    0,   67,    0,  138,  146,  149,    0,
301
    0,    0,    0,    0,    0,   85,    0,   97,    0,  100,
302
   87,    0,  103,   88,   89,   91,   90,   92,   93,  134,
303
  198,  199,  201,  200,  202,  195,  197,  196,    0,    0,
304
    0,  137,  150,    0,   70,   75,   83,   84,    0,   96,
305
  101,  102,    0,    0,  105,    0,  114,    0,    0,    0,
306
  203,  139,  204,  140,  205,  141,  151,   98,  106,  107,
307
  108,  112,  109,    0,  110,  111,  115,  116,  117,  118,
308
  113,
309
};
310
const short yydgoto[] =
311
	{                                       1,
312
   98,  208,  209,  210,  211,  222,  273,  223,   39,  270,
313
  289,  312,  314,  316,   77,   89,    9,   10,   11,   12,
314
   13,   55,   86,   52,   73,   45,   78,   69,   71,  121,
315
   83,  108,   56,  129,  130,   87,   67,   42,   27,   95,
316
  136,  117,  162,  187,  122,   79,  184,  178,  176,  182,
317
   96,  119,  140,  168,  198,  227,  255,  179,  205,  234,
318
  261,  295,  189,  247,  266,  271,  274,  267,  268,  194,
319
  256,  257,  231,   62,   37,   63,   64,  114,  115,  151,
320
  132,  152,  200,  153,
321
};
322
const short yysindex[] =
323
	{                                      0,
324
  -10,   37, -217, -208,    5, -288,    1,    0,   60,   88,
325
   95,  100,  108,    0,    0, -229, -236, -241,    0,    0,
326
 -214,    0,    0,    0,    0,    0, -218, -141, -207, -131,
327
 -185, -170, -226, -115, -231,  109, -103,    0, -169,    0,
328
    0, -140, -136, -122,    0,  -57,  -19,  -97,  -78,    0,
329
    0,    0,    0,  210,    0,    0, -112, -121,    0,    0,
330
  210,    0, -103,    0,    0,  -18, -188, -116, -122, -114,
331
    0,    0,    0,    0,  210,    0, -249,    0,    0,    5,
332
    5,    0, -111,    0,  210,    0,    0,    0,    0, -108,
333
    0, -110,    0,    0,    0,  -44,    0,    0, -101,    0,
334
  -18,    0, -104,  -99,  -95,    0,    0,   30,    0, -102,
335
    0,    0,    0,   30,    0,    0,  -34,  -20,  -46, -100,
336
    0,   30,    0,    0,    0,    0,  210,  116, -111,   30,
337
    0,    3,  117,  -94, -213,  -61,    0, -146,   78,  -24,
338
    0,  122,  -18,    0,    0,    0,  126, -102,    0,    0,
339
    0, -116,  -94,    0,    0,  -15,  -13,    0, -160,  -55,
340
  -88,  -39,  -12,    0,    0, -144,   89,  -11,    0,    0,
341
    0,    0,  213,    0,   -4,    0, -133,    0,  -17,    0,
342
    0,  -29,    0,    0, -105,  -66,    0,   90,    0,   -2,
343
   -1,   10,   13,    0,    0,  -54,   91,   12,  -58,    0,
344
  -55,   18,    0, -144,   43,    0, -178,    0,    0,    0,
345
    0,    0,    0,  250,    0,  -98,    0,    0,   63,    0,
346
    0,    0,    0,    0,  -54,  132, -221,    0,    0,  -98,
347
    0,    0,  -29,   77,    0,    0,    0,    9, -126,   73,
348
    0,   29,   47, -124,   47, -119,    0,    0,    0,    0,
349
  -54,  -30,  -30,  -30,    0, -221,    0,    0,    0,  -29,
350
   85,   97,   73,   73,  -18,    0,   73,    0, -117,    0,
351
    0, -245,    0,    0,    0,    0,    0,    0,    0,    0,
352
    0,    0,    0,    0,    0,    0,    0,    0,   15,   24,
353
   40,    0,    0,  -29,    0,    0,    0,    0,   42,    0,
354
    0,    0, -132, -158,    0, -118,    0, -109,   64,   74,
355
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
356
    0,    0,    0,   56,    0,    0,    0,    0,    0,    0,
357
    0,};
358
const short yyrindex[] =
359
	{                                      0,
360
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
361
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
362
    0,    0,    0,    0,    0,    0,   -6,    0,    0,    0,
363
    0,    0,    0,    0,    0,    0,  409,    0,  412,    0,
364
    0,    2,   14,   88,    0,  415, -195,    0,    0,    0,
365
    0,    0,    0,   92,    0,    0,    0,    0,    0,    0,
366
 -107,    0,  420,    0,    0,   94,   34,    0,   -3,    0,
367
    0,    0,    0,    0,  180,    0,    0,    0,    0,    0,
368
    0,    0,    0,    0,   92,    0,    0,    0,    0,    0,
369
    0,    0,    0,    0,    0,   46,    0,    0,  100,    0,
370
 -195,    0,    0,    0,    0,    0,    0, -106,    0,    0,
371
    0,    0,    0, -106,    0,    0,   45,  -79,  146,    0,
372
    0,  175,    0,    0,    0,    0,  170,    0,    0, -106,
373
    0,   -9,    0,    0,    0,   -5,    0,    0, -120,  141,
374
    0,    0, -195,    0,    0,    0,    0,    0,    0,    0,
375
    0,    0,    0,    0,    0,    0,    0,    0,    0,   49,
376
    0,  421,   53,    0,    0,    0,  -50,  128,    0,    0,
377
    0,    0,   -8,    0,    0,    0,    0,    0,  166,    0,
378
    0,    0,    0,    0,    0,    0,    0,  -74,    0,    0,
379
    0,    0,    0,    0,    0,    0,  -50,  151,    0,    0,
380
   49,    0,    0,    0,    0,    0,    0,    0,    0,    0,
381
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
382
    0,    0,    0,    0,    0,  -50,    6,    0,    0,    0,
383
    0,    0,    0,    0,    0,    0,    0,    0,    0,   93,
384
    0,  105,  124,    0,  124,    0,    0,    0,    0,    0,
385
    0,  101,  101,  101,    0,   87,    0,    0,    0,    0,
386
    0,    0,   93,   93,   94,    0,  136,    0,    0,    0,
387
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
388
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
389
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
390
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
391
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
392
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
393
    0,};
394
const short yygindex[] =
395
	{                                      0,
396
  296,    0,  -67,    0, -199, -168,    0,   28,    0,    0,
397
  -53,    0,    0,    0,  -40,    0,    0,    0,    0,    0,
398
    0,    0,    0,    0,    0,    0,    0,    0,  381,    0,
399
   58,    0,  -45,  -64,    0,  -68,    0,    0,    0,    0,
400
    0,    0,    0,    0,    0,  -62,  251,    0,    0,    0,
401
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
402
    0,    0,    0,  223,  -52,    0,  215,    0,  188,  260,
403
    0,  209,    0,    0,    0,    0,  403,    0,  333,    0,
404
    0,    0,    0,    0,
405
};
406
#define YYTABLESIZE 512
407
const short yytable[] =
408
	{                                       8,
409
  175,  179,  287,   52,   71,   18,   23,   54,  207,  191,
410
   85,   39,   76,   76,   76,  135,  112,  189,  189,   61,
411
   33,   34,  113,   21,  102,   92,   57,   28,   29,  284,
412
  286,  285,   19,  259,  175,  179,   30,  109,  123,   82,
413
  150,  131,  303,   68,  304,  156,   14,   50,   15,  134,
414
   16,   17,  103,   20,   55,   76,  249,  143,   61,  157,
415
  293,   21,   80,  305,   18,  148,  113,  306,   51,   22,
416
  307,  308,  158,  127,  309,  104,  310,  138,  191,  172,
417
  170,  105,  280,  146,   93,  174,  159,   40,   41,  160,
418
  235,  236,  237,   94,  317,   31,  136,   23,  166,   35,
419
   36,   32,   94,   75,   24,   58,  191,  106,  107,   25,
420
   76,  252,  253,  254,   99,  175,  179,   26,   90,   43,
421
   44,   76,   76,   76,  190,  191,  196,   38,  221,  191,
422
  163,  164,  101,  104,   46,  191,   47,  129,  192,  193,
423
  180,  181,  110,  202,  203,   95,   48,  216,  191,  191,
424
  126,  321,  322,  323,  324,  119,  225,  221,  212,  213,
425
  132,   49,  191,  191,   76,  128,  263,  264,  275,  276,
426
   59,  133,   65,  278,  279,  301,  302,  319,  320,  142,
427
  239,  240,  241,  221,  144,  251,   66,  147,   68,  242,
428
  243,  244,  245,  246,   60,  325,  326,  191,  191,  290,
429
  291,   80,  189,   70,  191,  191,  191,  187,  327,  328,
430
  297,  298,  189,  191,  191,  191,  191,  191,   72,   82,
431
   81,   88,  118,  124,  299,   97,   53,  120,  100,   84,
432
   53,  116,  125,  111,  189,  187,  126,  135,  139,   84,
433
  145,  154,  141,  161,  167,    2,  169,  111,  183,    3,
434
  171,  175,    4,  177,  185,  188,  186,  206,  197,  199,
435
   52,  137,   52,   52,   52,   52,   52,  204,   39,  201,
436
   39,   39,   39,   39,   39,   52,  214,  135,   52,  219,
437
  217,  218,  226,   39,  228,  230,   39,  111,    5,   52,
438
   71,  191,   74,   74,   74,  220,  238,   39,   52,  189,
439
   68,  135,   68,   68,   68,   68,   39,  281,  282,  283,
440
  135,  233,  111,  288,   76,   76,   76,   76,   68,    6,
441
   52,   80,   80,   80,   80,   23,   52,   52,   52,   68,
442
   76,    7,  175,  179,   39,   39,   39,   80,   68,   21,
443
   55,   76,   21,  149,   61,  248,  260,  265,   80,   55,
444
   76,  262,  269,   61,  272,  294,  311,   80,  136,  165,
445
  296,   94,   94,   94,   94,  313,   68,   68,   68,  331,
446
  195,  215,  224,   99,   99,   99,   99,   94,   76,   76,
447
   76,  315,  136,  318,  329,   80,   80,   80,   94,   99,
448
   74,  136,  104,  104,  104,  104,  330,   94,  129,  129,
449
   99,   74,   74,   74,   95,   95,   95,   95,  104,   99,
450
  126,  126,  126,  250,  119,  119,  119,  119,  158,  104,
451
   95,  167,  132,  129,  183,   94,   94,   94,  104,  159,
452
   74,   95,  129,  189,  147,  191,  126,   99,   99,   99,
453
   95,  119,  194,  189,   74,  126,  132,  173,  187,   99,
454
  119,  229,  258,  189,  300,  132,  104,  104,  104,  277,
455
  129,  129,  129,  232,  292,   91,  155,    0,   95,   95,
456
   95,  189,    0,  126,  126,  126,  187,    0,  119,  119,
457
  119,  189,  189,  132,  132,  132,    0,  187,    0,    0,
458
    0,    0,  189,    0,  189,    0,    0,    0,    0,  187,
459
  189,    0,    0,    0,  189,  187,    0,    0,    0,    0,
460
  189,  189,
461
};
462
const short yycheck[] =
463
	{                                      10,
464
   10,   10,   33,   10,   10,   60,   10,  123,   38,   60,
465
  123,   10,   33,   33,   33,   10,  125,  125,  125,  123,
466
  257,  258,   90,   10,  274,   66,  258,  257,  258,   60,
467
   61,   62,    5,  233,   44,   44,  266,   83,  101,   10,
468
   38,  110,  288,   10,  290,  259,   10,  274,  266,  114,
469
  259,  260,  302,  342,   10,   10,  225,  122,   10,  273,
470
  260,   61,   10,  309,   60,  130,  134,  313,  295,   10,
471
  316,  317,  286,   44,  320,  325,  322,  118,  274,  148,
472
  143,  331,  251,  129,  273,  153,  300,  306,  307,  303,
473
  269,  270,  271,  282,  294,  325,   10,   10,  139,  336,
474
  342,  331,   10,  123,   10,  337,  302,   80,   81,   10,
475
   33,  333,  334,  335,   10,  125,  125,   10,   61,  261,
476
  262,   33,   33,   33,  269,  270,  167,  342,  196,  325,
477
  277,  278,   75,   10,  342,  331,  268,   10,  283,  284,
478
  301,  302,   85,  277,  278,   10,  332,  188,  269,  270,
479
   10,  310,  311,  312,  313,   10,  197,  225,  264,  265,
480
   10,  332,  283,  284,   33,  108,  293,  294,  293,  294,
481
   62,  114,  342,  293,  294,  293,  294,  310,  311,  122,
482
  279,  280,  281,  251,  127,  226,  327,  130,  325,  288,
483
  289,  290,  291,  292,  298,  314,  315,  277,  278,  253,
484
  254,  299,   33,  326,  279,  280,  281,   33,  318,  319,
485
  263,  264,   33,  288,  289,  290,  291,  292,  276,   10,
486
  299,  343,  267,  328,  265,  342,  342,  329,  343,  342,
487
  342,  342,  332,  342,  342,  342,  332,  272,  285,  342,
488
  125,  125,  343,  305,  269,  256,  125,  342,  304,  260,
489
  125,  267,  263,  267,  343,  268,  296,  287,  270,   47,
490
  267,  282,  269,  270,  271,  272,  273,  285,  267,  274,
491
  269,  270,  271,  272,  273,  282,  343,  272,  285,  270,
492
  283,  283,  271,  282,  343,  268,  285,  342,  299,  296,
493
  296,  342,  313,  313,  313,  283,   47,  296,  305,  125,
494
  267,  296,  269,  270,  271,  272,  305,  338,  339,  340,
495
  305,  269,  342,  344,  269,  270,  271,  272,  285,  330,
496
  327,  269,  270,  271,  272,  329,  333,  334,  335,  296,
497
  285,  342,  342,  342,  333,  334,  335,  285,  305,  326,
498
  296,  296,  329,  341,  296,  283,  270,  275,  296,  305,
499
  305,  343,  324,  305,  308,  271,  342,  305,  272,  282,
500
  264,  269,  270,  271,  272,  342,  333,  334,  335,  314,
501
  282,  282,  282,  269,  270,  271,  272,  285,  333,  334,
502
  335,  342,  296,  342,  321,  333,  334,  335,  296,  285,
503
  313,  305,  269,  270,  271,  272,  323,  305,  271,  272,
504
  296,  313,  313,  313,  269,  270,  271,  272,  285,  305,
505
  270,  271,  272,  282,  269,  270,  271,  272,   10,  296,
506
  285,   10,  272,  296,   10,  333,  334,  335,  305,   10,
507
   10,  296,  305,  342,  269,  342,  296,  333,  334,  335,
508
  305,  296,  342,  274,  313,  305,  296,  152,  274,   69,
509
  305,  201,  230,  274,  267,  305,  333,  334,  335,  245,
510
  333,  334,  335,  204,  256,   63,  134,   -1,  333,  334,
511
  335,  302,   -1,  333,  334,  335,  302,   -1,  333,  334,
512
  335,  302,  313,  333,  334,  335,   -1,  313,   -1,   -1,
513
   -1,   -1,  313,   -1,  325,   -1,   -1,   -1,   -1,  325,
514
  331,   -1,   -1,   -1,  325,  331,   -1,   -1,   -1,   -1,
515
  331,  342,
516
};
517
#define YYFINAL 1
518
#ifndef YYDEBUG
519
#define YYDEBUG 0
520
#endif
521
#define YYMAXTOKEN 344
522
#if YYDEBUG
523
const char * const yyname[] =
524
	{
525
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
526
0,0,"'!'",0,0,0,0,"'&'",0,0,0,0,0,"','",0,0,"'/'",0,0,0,0,0,0,0,0,0,0,0,0,"'<'",
527
"'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
528
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,
529
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
530
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
531
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
532
0,0,0,0,"MODE","INTERFACE","IAPP","HOSTAP","MULTICAST","BROADCAST","SET","SEC",
533
"USEC","HANDLE","TYPE","SUBTYPE","FROM","TO","BSSID","WITH","FRAME","RADIOTAP",
534
"NWID","PASSIVE","MANAGEMENT","DATA","PROBE","BEACON","ATIM","ANY","DS","NO",
535
"DIR","RESEND","RANDOM","AUTH","DEAUTH","ASSOC","DISASSOC","REASSOC","REQUEST",
536
"RESPONSE","PCAP","RATE","ERROR","CONST","TABLE","NODE","DELETE","ADD","LOG",
537
"VERBOSE","LIMIT","QUICK","SKIP","REASON","UNSPECIFIED","EXPIRE","LEAVE",
538
"TOOMANY","NOT","AUTHED","ASSOCED","RESERVED","RSN","REQUIRED","INCONSISTENT",
539
"IE","INVALID","MIC","FAILURE","OPEN","ADDRESS","PORT","ON","NOTIFY","TTL",
540
"INCLUDE","ROUTE","ROAMING","RSSI","TXRATE","FREQ","HOPPER","DELAY","NE","LE",
541
"GE","ARROW","STRING","NUMBER","\"==\"",
542
};
543
const char * const yyrule[] =
544
	{"$accept : grammar",
545
"grammar :",
546
"grammar : grammar '\\n'",
547
"grammar : grammar include '\\n'",
548
"grammar : grammar tabledef '\\n'",
549
"grammar : grammar option '\\n'",
550
"grammar : grammar event '\\n'",
551
"grammar : grammar varset '\\n'",
552
"grammar : grammar error '\\n'",
553
"include : INCLUDE STRING",
554
"option : SET HOSTAP INTERFACE hostapifaces",
555
"option : SET HOSTAP HOPPER INTERFACE hopperifaces",
556
"option : SET HOSTAP HOPPER DELAY timeout",
557
"option : SET HOSTAP MODE hostapmode",
558
"option : SET IAPP INTERFACE STRING passive",
559
"option : SET IAPP MODE iappmode",
560
"option : SET IAPP ADDRESS ROAMING TABLE table",
561
"option : SET IAPP ROUTE ROAMING TABLE table",
562
"option : SET IAPP HANDLE SUBTYPE iappsubtypes",
563
"iappmode : MULTICAST iappmodeaddr iappmodeport iappmodettl",
564
"iappmode : BROADCAST iappmodeport",
565
"iappmodeaddr :",
566
"iappmodeaddr : ADDRESS ipv4addr",
567
"iappmodeport :",
568
"iappmodeport : PORT NUMBER",
569
"iappmodettl :",
570
"iappmodettl : TTL NUMBER",
571
"hostapmode : RADIOTAP",
572
"hostapmode : PCAP",
573
"hostapifaces : '{' optnl hostapifacelist optnl '}'",
574
"hostapifaces : hostapiface",
575
"hostapifacelist : hostapiface",
576
"hostapifacelist : hostapifacelist comma hostapiface",
577
"hostapiface : STRING",
578
"hopperifaces : '{' optnl hopperifacelist optnl '}'",
579
"hopperifaces : hopperiface",
580
"hopperifacelist : hopperiface",
581
"hopperifacelist : hopperifacelist comma hopperiface",
582
"hopperiface : STRING",
583
"hostapmatch :",
584
"hostapmatch : ON not STRING",
585
"$$1 :",
586
"$$2 :",
587
"event : HOSTAP HANDLE $$1 eventopt hostapmatch frmmatch $$2 action limit rate",
588
"iappsubtypes : '{' optnl iappsubtypelist optnl '}'",
589
"iappsubtypes : iappsubtype",
590
"iappsubtypelist : iappsubtype",
591
"iappsubtypelist : iappsubtypelist comma iappsubtype",
592
"iappsubtype : not ADD NOTIFY",
593
"iappsubtype : not RADIOTAP",
594
"iappsubtype : not ROUTE ROAMING",
595
"iappsubtype : not ADDRESS ROAMING",
596
"eventopt :",
597
"eventopt : QUICK",
598
"eventopt : SKIP",
599
"action :",
600
"action : WITH LOG verbose",
601
"action : WITH FRAME frmaction",
602
"action : WITH IAPP iapp",
603
"action : WITH NODE nodeopt frmactionaddr",
604
"action : WITH RESEND",
605
"verbose :",
606
"verbose : VERBOSE",
607
"iapp : TYPE RADIOTAP verbose",
608
"nodeopt : DELETE",
609
"nodeopt : ADD",
610
"frmmatch : ANY",
611
"frmmatch : frm frmmatchtype frmmatchdir frmmatchfrom frmmatchto frmmatchbssid frmmatchrtap",
612
"frm :",
613
"frm : FRAME",
614
"frmaction : frmactiontype frmactiondir frmactionfrom frmactionto frmactionbssid",
615
"limit :",
616
"limit : LIMIT NUMBER SEC",
617
"limit : LIMIT NUMBER USEC",
618
"rate :",
619
"rate : RATE NUMBER '/' NUMBER SEC",
620
"frmmatchtype :",
621
"frmmatchtype : TYPE ANY",
622
"frmmatchtype : TYPE not DATA",
623
"frmmatchtype : TYPE not MANAGEMENT frmmatchmgmt",
624
"frmmatchmgmt :",
625
"frmmatchmgmt : SUBTYPE ANY",
626
"frmmatchmgmt : SUBTYPE not frmsubtype",
627
"frmsubtype : PROBE REQUEST frmelems",
628
"frmsubtype : PROBE RESPONSE frmelems",
629
"frmsubtype : BEACON frmelems",
630
"frmsubtype : ATIM",
631
"frmsubtype : AUTH frmauth",
632
"frmsubtype : DEAUTH frmreason",
633
"frmsubtype : ASSOC REQUEST",
634
"frmsubtype : DISASSOC frmreason",
635
"frmsubtype : ASSOC RESPONSE",
636
"frmsubtype : REASSOC REQUEST",
637
"frmsubtype : REASSOC RESPONSE",
638
"frmelems :",
639
"frmelems : frmelems_l",
640
"frmelems_l : frmelems_l frmelem",
641
"frmelems_l : frmelem",
642
"frmelem : NWID not STRING",
643
"frmauth :",
644
"frmauth : authalg",
645
"authalg : OPEN REQUEST",
646
"authalg : OPEN RESPONSE",
647
"frmreason : frmreason_l",
648
"frmreason_l :",
649
"frmreason_l : REASON UNSPECIFIED",
650
"frmreason_l : REASON AUTH EXPIRE",
651
"frmreason_l : REASON AUTH LEAVE",
652
"frmreason_l : REASON ASSOC EXPIRE",
653
"frmreason_l : REASON ASSOC TOOMANY",
654
"frmreason_l : REASON NOT AUTHED",
655
"frmreason_l : REASON NOT ASSOCED",
656
"frmreason_l : REASON ASSOC LEAVE",
657
"frmreason_l : REASON ASSOC NOT AUTHED",
658
"frmreason_l : REASON RESERVED",
659
"frmreason_l : REASON RSN REQUIRED",
660
"frmreason_l : REASON RSN INCONSISTENT",
661
"frmreason_l : REASON IE INVALID",
662
"frmreason_l : REASON MIC FAILURE",
663
"frmmatchdir :",
664
"frmmatchdir : DIR ANY",
665
"frmmatchdir : DIR not frmdir",
666
"frmdir : NO DS",
667
"frmdir : TO DS",
668
"frmdir : FROM DS",
669
"frmdir : DS TO DS",
670
"frmmatchfrom :",
671
"frmmatchfrom : FROM ANY",
672
"frmmatchfrom : FROM not frmmatchaddr",
673
"frmmatchto :",
674
"frmmatchto : TO ANY",
675
"frmmatchto : TO not frmmatchaddr",
676
"frmmatchbssid :",
677
"frmmatchbssid : BSSID ANY",
678
"frmmatchbssid : BSSID not frmmatchaddr",
679
"frmmatchrtap :",
680
"frmmatchrtap : frmmatchrtap_l",
681
"frmmatchrtap_l : frmmatchrtap_l frmmatchrtapopt",
682
"frmmatchrtap_l : frmmatchrtapopt",
683
"frmmatchrtapopt : RSSI unaryop percent",
684
"frmmatchrtapopt : TXRATE unaryop txrate",
685
"frmmatchrtapopt : FREQ unaryop freq",
686
"frmmatchaddr : table",
687
"frmmatchaddr : lladdr",
688
"frmactiontype : TYPE DATA",
689
"frmactiontype : TYPE MANAGEMENT frmactionmgmt",
690
"frmactionmgmt : SUBTYPE frmsubtype",
691
"frmactiondir :",
692
"frmactiondir : DIR frmdir",
693
"frmactionfrom : FROM frmactionaddr",
694
"frmactionto : TO frmactionaddr",
695
"frmactionbssid : BSSID frmactionaddr",
696
"frmactionaddr : lladdr",
697
"frmactionaddr : randaddr",
698
"frmactionaddr : refaddr",
699
"table : '<' STRING '>'",
700
"$$3 :",
701
"tabledef : TABLE table $$3 tableopts",
702
"tableopts :",
703
"tableopts : tableopts_l",
704
"tableopts_l : tableopts_l tableopt",
705
"tableopts_l : tableopt",
706
"tableopt : CONST",
707
"tableopt : '{' optnl '}'",
708
"tableopt : '{' optnl tableaddrlist optnl '}'",
709
"string : string STRING",
710
"string : STRING",
711
"varset : STRING '=' string",
712
"refaddr : '&' FROM",
713
"refaddr : '&' TO",
714
"refaddr : '&' BSSID",
715
"tableaddrlist : tableaddrentry",
716
"tableaddrlist : tableaddrlist comma tableaddrentry",
717
"$$4 :",
718
"tableaddrentry : lladdr $$4 tableaddropt",
719
"tableaddropt :",
720
"tableaddropt : assign ipv4addr ipv4netmask",
721
"tableaddropt : mask lladdr",
722
"ipv4addr : STRING",
723
"ipv4netmask :",
724
"ipv4netmask : '/' NUMBER",
725
"lladdr : STRING",
726
"randaddr : RANDOM",
727
"passive :",
728
"passive : PASSIVE",
729
"assign : ARROW",
730
"mask : '&'",
731
"comma :",
732
"comma : ',' optnl",
733
"optnl :",
734
"optnl : '\\n'",
735
"not :",
736
"not : '!'",
737
"not : NOT",
738
"unaryop :",
739
"unaryop : '='",
740
"unaryop : \"==\"",
741
"unaryop : '!'",
742
"unaryop : NE",
743
"unaryop : LE",
744
"unaryop : '<'",
745
"unaryop : GE",
746
"unaryop : '>'",
747
"percent : STRING",
748
"txrate : STRING",
749
"freq : STRING",
750
"timeout : NUMBER",
751
};
752
#endif
753
#ifdef YYSTACKSIZE
754
#undef YYMAXDEPTH
755
#define YYMAXDEPTH YYSTACKSIZE
756
#else
757
#ifdef YYMAXDEPTH
758
#define YYSTACKSIZE YYMAXDEPTH
759
#else
760
#define YYSTACKSIZE 10000
761
#define YYMAXDEPTH 10000
762
#endif
763
#endif
764
#define YYINITSTACKSIZE 200
765
/* LINTUSED */
766
int yydebug;
767
int yynerrs;
768
int yyerrflag;
769
int yychar;
770
short *yyssp;
771
YYSTYPE *yyvsp;
772
YYSTYPE yyval;
773
YYSTYPE yylval;
774
short *yyss;
775
short *yysslim;
776
YYSTYPE *yyvs;
777
unsigned int yystacksize;
778
int yyparse(void);
779
#line 1226 "parse.y"
780
781
/*
782
 * Parser and lexer
783
 */
784
785
struct keywords {
786
	char *k_name;
787
	int k_val;
788
};
789
790
int
791
kw_cmp(const void *a, const void *b)
792
{
793
	return strcmp(a, ((const struct keywords *)b)->k_name);
794
}
795
796
int
797
lookup(char *token)
798
{
799
	/* Keep this list sorted */
800
	static const struct keywords keywords[] = {
801
		{ "add",		ADD },
802
		{ "address",		ADDRESS },
803
		{ "any",		ANY },
804
		{ "assoc",		ASSOC },
805
		{ "assoced",		ASSOCED },
806
		{ "atim",		ATIM },
807
		{ "auth",		AUTH },
808
		{ "authed",		AUTHED },
809
		{ "beacon",		BEACON },
810
		{ "broadcast",		BROADCAST },
811
		{ "bssid",		BSSID },
812
		{ "const",		CONST },
813
		{ "data",		DATA },
814
		{ "deauth",		DEAUTH },
815
		{ "delay",		DELAY },
816
		{ "delete",		DELETE },
817
		{ "dir",		DIR },
818
		{ "disassoc",		DISASSOC },
819
		{ "ds",			DS },
820
		{ "expire",		EXPIRE },
821
		{ "failure",		FAILURE },
822
		{ "frame",		FRAME },
823
		{ "freq",		FREQ },
824
		{ "from",		FROM },
825
		{ "handle",		HANDLE },
826
		{ "hopper",		HOPPER },
827
		{ "hostap",		HOSTAP },
828
		{ "iapp",		IAPP },
829
		{ "ie",			IE },
830
		{ "include",		INCLUDE },
831
		{ "inconsistent",	INCONSISTENT },
832
		{ "interface",		INTERFACE },
833
		{ "invalid",		INVALID },
834
		{ "leave",		LEAVE },
835
		{ "limit",		LIMIT },
836
		{ "log",		LOG },
837
		{ "management",		MANAGEMENT },
838
		{ "mic",		MIC },
839
		{ "mode",		MODE },
840
		{ "multicast",		MULTICAST },
841
		{ "no",			NO },
842
		{ "node",		NODE },
843
		{ "not",		NOT },
844
		{ "notify",		NOTIFY },
845
		{ "nwid",		NWID },
846
		{ "on",			ON },
847
		{ "open",		OPEN },
848
		{ "passive",		PASSIVE },
849
		{ "pcap",		PCAP },
850
		{ "port",		PORT },
851
		{ "probe",		PROBE },
852
		{ "quick",		QUICK },
853
		{ "radiotap",		RADIOTAP },
854
		{ "random",		RANDOM },
855
		{ "rate",		RATE },
856
		{ "reason",		REASON },
857
		{ "reassoc",		REASSOC },
858
		{ "request",		REQUEST },
859
		{ "required",		REQUIRED },
860
		{ "resend",		RESEND },
861
		{ "reserved",		RESERVED },
862
		{ "response",		RESPONSE },
863
		{ "roaming",		ROAMING },
864
		{ "route",		ROUTE },
865
		{ "rsn",		RSN },
866
		{ "sec",		SEC },
867
		{ "set",		SET },
868
		{ "signal",		RSSI },
869
		{ "skip",		SKIP },
870
		{ "subtype",		SUBTYPE },
871
		{ "table",		TABLE },
872
		{ "to",			TO },
873
		{ "toomany",		TOOMANY },
874
		{ "ttl",		TTL },
875
		{ "txrate",		TXRATE },
876
		{ "type",		TYPE },
877
		{ "unspecified",	UNSPECIFIED },
878
		{ "usec",		USEC },
879
		{ "verbose",		VERBOSE },
880
		{ "with",		WITH }
881
	};
882
	const struct keywords *p;
883
884
	p = bsearch(token, keywords, sizeof(keywords) / sizeof(keywords[0]),
885
	    sizeof(keywords[0]), kw_cmp);
886
887
	return (p == NULL ? STRING : p->k_val);
888
}
889
890
#define MAXPUSHBACK	128
891
892
u_char	*parsebuf;
893
int	 parseindex;
894
u_char	 pushback_buffer[MAXPUSHBACK];
895
int	 pushback_index = 0;
896
897
int
898
lgetc(int quotec)
899
{
900
	int		c, next;
901
902
	if (parsebuf) {
903
		/* Read character from the parsebuffer instead of input. */
904
		if (parseindex >= 0) {
905
			c = parsebuf[parseindex++];
906
			if (c != '\0')
907
				return (c);
908
			parsebuf = NULL;
909
		} else
910
			parseindex++;
911
	}
912
913
	if (pushback_index)
914
		return (pushback_buffer[--pushback_index]);
915
916
	if (quotec) {
917
		if ((c = getc(file->stream)) == EOF) {
918
			yyerror("reached end of file while parsing "
919
			    "quoted string");
920
			if (file == topfile || popfile() == EOF)
921
				return (EOF);
922
			return (quotec);
923
		}
924
		return (c);
925
	}
926
927
	while ((c = getc(file->stream)) == '\\') {
928
		next = getc(file->stream);
929
		if (next != '\n') {
930
			c = next;
931
			break;
932
		}
933
		yylval.lineno = file->lineno;
934
		file->lineno++;
935
	}
936
937
	while (c == EOF) {
938
		if (file == topfile || popfile() == EOF)
939
			return (EOF);
940
		c = getc(file->stream);
941
	}
942
	return (c);
943
}
944
945
int
946
lungetc(int c)
947
{
948
	if (c == EOF)
949
		return (EOF);
950
	if (parsebuf) {
951
		parseindex--;
952
		if (parseindex >= 0)
953
			return (c);
954
	}
955
	if (pushback_index < MAXPUSHBACK-1)
956
		return (pushback_buffer[pushback_index++] = c);
957
	else
958
		return (EOF);
959
}
960
961
int
962
findeol(void)
963
{
964
	int	c;
965
966
	parsebuf = NULL;
967
968
	/* skip to either EOF or the first real EOL */
969
	while (1) {
970
		if (pushback_index)
971
			c = pushback_buffer[--pushback_index];
972
		else
973
			c = lgetc(0);
974
		if (c == '\n') {
975
			file->lineno++;
976
			break;
977
		}
978
		if (c == EOF)
979
			break;
980
	}
981
	return (ERROR);
982
}
983
984
int
985
yylex(void)
986
{
987
	u_char	 buf[8096];
988
	u_char	*p, *val;
989
	int	 quotec, next, c;
990
	int	 token;
991
992
top:
993
	p = buf;
994
	while ((c = lgetc(0)) == ' ' || c == '\t')
995
		; /* nothing */
996
997
	yylval.lineno = file->lineno;
998
	if (c == '#')
999
		while ((c = lgetc(0)) != '\n' && c != EOF)
1000
			; /* nothing */
1001
	if (c == '$' && parsebuf == NULL) {
1002
		while (1) {
1003
			if ((c = lgetc(0)) == EOF)
1004
				return (0);
1005
1006
			if (p + 1 >= buf + sizeof(buf) - 1) {
1007
				yyerror("string too long");
1008
				return (findeol());
1009
			}
1010
			if (isalnum(c) || c == '_') {
1011
				*p++ = c;
1012
				continue;
1013
			}
1014
			*p = '\0';
1015
			lungetc(c);
1016
			break;
1017
		}
1018
		val = symget(buf);
1019
		if (val == NULL) {
1020
			yyerror("macro \"%s\" not defined", buf);
1021
			return (findeol());
1022
		}
1023
		parsebuf = val;
1024
		parseindex = 0;
1025
		goto top;
1026
	}
1027
1028
	switch (c) {
1029
	case '\'':
1030
	case '"':
1031
		quotec = c;
1032
		while (1) {
1033
			if ((c = lgetc(quotec)) == EOF)
1034
				return (0);
1035
			if (c == '\n') {
1036
				file->lineno++;
1037
				continue;
1038
			} else if (c == '\\') {
1039
				if ((next = lgetc(quotec)) == EOF)
1040
					return (0);
1041
				if (next == quotec || c == ' ' || c == '\t')
1042
					c = next;
1043
				else if (next == '\n') {
1044
					file->lineno++;
1045
					continue;
1046
				} else
1047
					lungetc(next);
1048
			} else if (c == quotec) {
1049
				*p = '\0';
1050
				break;
1051
			} else if (c == '\0') {
1052
				yyerror("syntax error");
1053
				return (findeol());
1054
			}
1055
			if (p + 1 >= buf + sizeof(buf) - 1) {
1056
				yyerror("string too long");
1057
				return (findeol());
1058
			}
1059
			*p++ = c;
1060
		}
1061
		yylval.v.string = strdup(buf);
1062
		if (yylval.v.string == NULL)
1063
			hostapd_fatal("yylex: strdup");
1064
		return (STRING);
1065
	case '-':
1066
		next = lgetc(0);
1067
		if (next == '>')
1068
			return (ARROW);
1069
		lungetc(next);
1070
		break;
1071
	case '!':
1072
		next = lgetc(0);
1073
		if (next == '=')
1074
			return (NE);
1075
		lungetc(next);
1076
		break;
1077
	case '<':
1078
		next = lgetc(0);
1079
		if (next == '=')
1080
			return (LE);
1081
		lungetc(next);
1082
		break;
1083
	case '>':
1084
		next = lgetc(0);
1085
		if (next == '=')
1086
			return (GE);
1087
		lungetc(next);
1088
		break;
1089
	}
1090
1091
#define allowed_to_end_number(x) \
1092
	(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
1093
1094
	if (c == '-' || isdigit(c)) {
1095
		do {
1096
			*p++ = c;
1097
			if ((unsigned)(p-buf) >= sizeof(buf)) {
1098
				yyerror("string too long");
1099
				return (findeol());
1100
			}
1101
		} while ((c = lgetc(0)) != EOF && isdigit(c));
1102
		lungetc(c);
1103
		if (p == buf + 1 && buf[0] == '-')
1104
			goto nodigits;
1105
		if (c == EOF || allowed_to_end_number(c)) {
1106
			const char *errstr = NULL;
1107
1108
			*p = '\0';
1109
			yylval.v.number = strtonum(buf, LLONG_MIN,
1110
			    LLONG_MAX, &errstr);
1111
			if (errstr) {
1112
				yyerror("\"%s\" invalid number: %s",
1113
				    buf, errstr);
1114
				return (findeol());
1115
			}
1116
			return (NUMBER);
1117
		} else {
1118
nodigits:
1119
			while (p > buf + 1)
1120
				lungetc(*--p);
1121
			c = *--p;
1122
			if (c == '-')
1123
				return (c);
1124
		}
1125
	}
1126
1127
#define allowed_in_string(x) \
1128
	(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
1129
	x != '{' && x != '}' && x != '<' && x != '>' && \
1130
	x != '!' && x != '=' && x != '/' && x != '#' && \
1131
	x != ','))
1132
1133
	if (isalnum(c) || c == ':' || c == '_' || c == '*') {
1134
		do {
1135
			*p++ = c;
1136
			if ((unsigned)(p-buf) >= sizeof(buf)) {
1137
				yyerror("string too long");
1138
				return (findeol());
1139
			}
1140
		} while ((c = lgetc(0)) != EOF && (allowed_in_string(c)));
1141
		lungetc(c);
1142
		*p = '\0';
1143
		if ((token = lookup(buf)) == STRING)
1144
			if ((yylval.v.string = strdup(buf)) == NULL)
1145
				hostapd_fatal("yylex: strdup");
1146
		return (token);
1147
	}
1148
	if (c == '\n') {
1149
		yylval.lineno = file->lineno;
1150
		file->lineno++;
1151
	}
1152
	if (c == EOF)
1153
		return (0);
1154
	return (c);
1155
}
1156
1157
int
1158
symset(const char *nam, const char *val, int persist)
1159
{
1160
	struct sym	*sym;
1161
1162
	TAILQ_FOREACH(sym, &symhead, entry) {
1163
		if (strcmp(nam, sym->nam) == 0)
1164
			break;
1165
	}
1166
1167
	if (sym != NULL) {
1168
		if (sym->persist == 1)
1169
			return (0);
1170
		else {
1171
			free(sym->nam);
1172
			free(sym->val);
1173
			TAILQ_REMOVE(&symhead, sym, entry);
1174
			free(sym);
1175
		}
1176
	}
1177
	if ((sym = calloc(1, sizeof(*sym))) == NULL)
1178
		return (-1);
1179
1180
	sym->nam = strdup(nam);
1181
	if (sym->nam == NULL) {
1182
		free(sym);
1183
		return (-1);
1184
	}
1185
	sym->val = strdup(val);
1186
	if (sym->val == NULL) {
1187
		free(sym->nam);
1188
		free(sym);
1189
		return (-1);
1190
	}
1191
	sym->used = 0;
1192
	sym->persist = persist;
1193
	TAILQ_INSERT_TAIL(&symhead, sym, entry);
1194
1195
	hostapd_log(HOSTAPD_LOG_DEBUG, "%s = \"%s\"", sym->nam, sym->val);
1196
1197
	return (0);
1198
}
1199
1200
int
1201
hostapd_parse_symset(char *s)
1202
{
1203
	char	*sym, *val;
1204
	int	ret;
1205
	size_t	len;
1206
1207
	if ((val = strrchr(s, '=')) == NULL)
1208
		return (-1);
1209
1210
	len = strlen(s) - strlen(val) + 1;
1211
	if ((sym = malloc(len)) == NULL)
1212
		hostapd_fatal("cmdline_symset: malloc");
1213
1214
	(void)strlcpy(sym, s, len);
1215
1216
	ret = symset(sym, val + 1, 1);
1217
1218
	free(sym);
1219
1220
	return (ret);
1221
}
1222
1223
char *
1224
symget(const char *nam)
1225
{
1226
	struct sym	*sym;
1227
1228
	TAILQ_FOREACH(sym, &symhead, entry) {
1229
		if (strcmp(nam, sym->nam) == 0) {
1230
			sym->used = 1;
1231
			return (sym->val);
1232
		}
1233
	}
1234
	return (NULL);
1235
}
1236
1237
int
1238
check_file_secrecy(int fd, const char *fname)
1239
{
1240
	struct stat	st;
1241
1242
	if (fstat(fd, &st)) {
1243
		warn("cannot stat %s", fname);
1244
		return (-1);
1245
	}
1246
	if (st.st_uid != 0 && st.st_uid != getuid()) {
1247
		warnx("%s: owner not root or current user", fname);
1248
		return (-1);
1249
	}
1250
	if (st.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)) {
1251
		warnx("%s: group writable or world read/writable", fname);
1252
		return (-1);
1253
	}
1254
	return (0);
1255
}
1256
1257
struct file *
1258
pushfile(const char *name, int secret)
1259
{
1260
	struct file	*nfile;
1261
1262
	if ((nfile = calloc(1, sizeof(struct file))) == NULL) {
1263
		warn("out of memory");
1264
		return (NULL);
1265
	}
1266
	if ((nfile->name = strdup(name)) == NULL) {
1267
		warn("out of memory");
1268
		free(nfile);
1269
		return (NULL);
1270
	}
1271
	if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
1272
		warn("%s", nfile->name);
1273
		free(nfile->name);
1274
		free(nfile);
1275
		return (NULL);
1276
	} else if (secret &&
1277
	    check_file_secrecy(fileno(nfile->stream), nfile->name)) {
1278
		fclose(nfile->stream);
1279
		free(nfile->name);
1280
		free(nfile);
1281
		return (NULL);
1282
	}
1283
	nfile->lineno = 1;
1284
	TAILQ_INSERT_TAIL(&files, nfile, entry);
1285
	return (nfile);
1286
}
1287
1288
int
1289
popfile(void)
1290
{
1291
	struct file	*prev;
1292
1293
	if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
1294
		prev->errors += file->errors;
1295
1296
	TAILQ_REMOVE(&files, file, entry);
1297
	fclose(file->stream);
1298
	free(file->name);
1299
	free(file);
1300
	file = prev;
1301
	return (file ? 0 : EOF);
1302
}
1303
1304
int
1305
hostapd_parse_file(struct hostapd_config *cfg)
1306
{
1307
	struct sym *sym, *next;
1308
	int errors = 0;
1309
	int ret;
1310
1311
	if ((file = pushfile(cfg->c_config, 1)) == NULL)
1312
		hostapd_fatal("failed to open the main config file: %s\n",
1313
		    cfg->c_config);
1314
	topfile = file;
1315
1316
	/* Init tables and data structures */
1317
	TAILQ_INIT(&cfg->c_apmes);
1318
	TAILQ_INIT(&cfg->c_tables);
1319
	TAILQ_INIT(&cfg->c_frames);
1320
	cfg->c_iapp.i_multicast.sin_addr.s_addr = INADDR_ANY;
1321
	cfg->c_iapp.i_flags = HOSTAPD_IAPP_F_DEFAULT;
1322
	cfg->c_iapp.i_ttl = IP_DEFAULT_MULTICAST_TTL;
1323
	cfg->c_apme_hopdelay.tv_sec = HOSTAPD_HOPPER_MDELAY / 1000;
1324
	cfg->c_apme_hopdelay.tv_usec = (HOSTAPD_HOPPER_MDELAY % 1000) * 1000;
1325
1326
	ret = yyparse();
1327
	errors = file->errors;
1328
	popfile();
1329
1330
	/* Free macros and check which have not been used. */
1331
	TAILQ_FOREACH_SAFE(sym, &symhead, entry, next) {
1332
		if (!sym->used)
1333
			hostapd_log(HOSTAPD_LOG_VERBOSE,
1334
			    "warning: macro '%s' not used", sym->nam);
1335
		if (!sym->persist) {
1336
			free(sym->nam);
1337
			free(sym->val);
1338
			TAILQ_REMOVE(&symhead, sym, entry);
1339
			free(sym);
1340
		}
1341
	}
1342
1343
	return (errors ? EINVAL : ret);
1344
}
1345
1346
int
1347
yyerror(const char *fmt, ...)
1348
{
1349
	va_list		 ap;
1350
	char		*msg;
1351
1352
	file->errors++;
1353
1354
	va_start(ap, fmt);
1355
	if (vasprintf(&msg, fmt, ap) == -1)
1356
		hostapd_fatal("yyerror vasprintf");
1357
	va_end(ap);
1358
	fprintf(stderr, "%s:%d: %s\n", file->name, yylval.lineno, msg);
1359
	fflush(stderr);
1360
	free(msg);
1361
1362
	return (0);
1363
}
1364
#line 1357 "parse.c"
1365
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
1366
static int yygrowstack(void)
1367
{
1368
    unsigned int newsize;
1369
    long sslen;
1370
    short *newss;
1371
    YYSTYPE *newvs;
1372
1373
    if ((newsize = yystacksize) == 0)
1374
        newsize = YYINITSTACKSIZE;
1375
    else if (newsize >= YYMAXDEPTH)
1376
        return -1;
1377
    else if ((newsize *= 2) > YYMAXDEPTH)
1378
        newsize = YYMAXDEPTH;
1379
    sslen = yyssp - yyss;
1380
#ifdef SIZE_MAX
1381
#define YY_SIZE_MAX SIZE_MAX
1382
#else
1383
#define YY_SIZE_MAX 0xffffffffU
1384
#endif
1385
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newss)
1386
        goto bail;
1387
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
1388
      (short *)malloc(newsize * sizeof *newss); /* overflow check above */
1389
    if (newss == NULL)
1390
        goto bail;
1391
    yyss = newss;
1392
    yyssp = newss + sslen;
1393
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs)
1394
        goto bail;
1395
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
1396
      (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */
1397
    if (newvs == NULL)
1398
        goto bail;
1399
    yyvs = newvs;
1400
    yyvsp = newvs + sslen;
1401
    yystacksize = newsize;
1402
    yysslim = yyss + newsize - 1;
1403
    return 0;
1404
bail:
1405
    if (yyss)
1406
            free(yyss);
1407
    if (yyvs)
1408
            free(yyvs);
1409
    yyss = yyssp = NULL;
1410
    yyvs = yyvsp = NULL;
1411
    yystacksize = 0;
1412
    return -1;
1413
}
1414
1415
#define YYABORT goto yyabort
1416
#define YYREJECT goto yyabort
1417
#define YYACCEPT goto yyaccept
1418
#define YYERROR goto yyerrlab
1419
int
1420
yyparse(void)
1421
{
1422
    int yym, yyn, yystate;
1423
#if YYDEBUG
1424
    const char *yys;
1425
1426
    if ((yys = getenv("YYDEBUG")))
1427
    {
1428
        yyn = *yys;
1429
        if (yyn >= '0' && yyn <= '9')
1430
            yydebug = yyn - '0';
1431
    }
1432
#endif /* YYDEBUG */
1433
1434
    yynerrs = 0;
1435
    yyerrflag = 0;
1436
    yychar = (-1);
1437
1438
    if (yyss == NULL && yygrowstack()) goto yyoverflow;
1439
    yyssp = yyss;
1440
    yyvsp = yyvs;
1441
    *yyssp = yystate = 0;
1442
1443
yyloop:
1444
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1445
    if (yychar < 0)
1446
    {
1447
        if ((yychar = yylex()) < 0) yychar = 0;
1448
#if YYDEBUG
1449
        if (yydebug)
1450
        {
1451
            yys = 0;
1452
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1453
            if (!yys) yys = "illegal-symbol";
1454
            printf("%sdebug: state %d, reading %d (%s)\n",
1455
                    YYPREFIX, yystate, yychar, yys);
1456
        }
1457
#endif
1458
    }
1459
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
1460
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1461
    {
1462
#if YYDEBUG
1463
        if (yydebug)
1464
            printf("%sdebug: state %d, shifting to state %d\n",
1465
                    YYPREFIX, yystate, yytable[yyn]);
1466
#endif
1467
        if (yyssp >= yysslim && yygrowstack())
1468
        {
1469
            goto yyoverflow;
1470
        }
1471
        *++yyssp = yystate = yytable[yyn];
1472
        *++yyvsp = yylval;
1473
        yychar = (-1);
1474
        if (yyerrflag > 0)  --yyerrflag;
1475
        goto yyloop;
1476
    }
1477
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
1478
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
1479
    {
1480
        yyn = yytable[yyn];
1481
        goto yyreduce;
1482
    }
1483
    if (yyerrflag) goto yyinrecovery;
1484
#if defined(__GNUC__)
1485
    goto yynewerror;
1486
#endif
1487
yynewerror:
1488
    yyerror("syntax error");
1489
#if defined(__GNUC__)
1490
    goto yyerrlab;
1491
#endif
1492
yyerrlab:
1493
    ++yynerrs;
1494
yyinrecovery:
1495
    if (yyerrflag < 3)
1496
    {
1497
        yyerrflag = 3;
1498
        for (;;)
1499
        {
1500
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
1501
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
1502
            {
1503
#if YYDEBUG
1504
                if (yydebug)
1505
                    printf("%sdebug: state %d, error recovery shifting\
1506
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
1507
#endif
1508
                if (yyssp >= yysslim && yygrowstack())
1509
                {
1510
                    goto yyoverflow;
1511
                }
1512
                *++yyssp = yystate = yytable[yyn];
1513
                *++yyvsp = yylval;
1514
                goto yyloop;
1515
            }
1516
            else
1517
            {
1518
#if YYDEBUG
1519
                if (yydebug)
1520
                    printf("%sdebug: error recovery discarding state %d\n",
1521
                            YYPREFIX, *yyssp);
1522
#endif
1523
                if (yyssp <= yyss) goto yyabort;
1524
                --yyssp;
1525
                --yyvsp;
1526
            }
1527
        }
1528
    }
1529
    else
1530
    {
1531
        if (yychar == 0) goto yyabort;
1532
#if YYDEBUG
1533
        if (yydebug)
1534
        {
1535
            yys = 0;
1536
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1537
            if (!yys) yys = "illegal-symbol";
1538
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1539
                    YYPREFIX, yystate, yychar, yys);
1540
        }
1541
#endif
1542
        yychar = (-1);
1543
        goto yyloop;
1544
    }
1545
yyreduce:
1546
#if YYDEBUG
1547
    if (yydebug)
1548
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1549
                YYPREFIX, yystate, yyn, yyrule[yyn]);
1550
#endif
1551
    yym = yylen[yyn];
1552
    if (yym)
1553
        yyval = yyvsp[1-yym];
1554
    else
1555
        memset(&yyval, 0, sizeof yyval);
1556
    switch (yyn)
1557
    {
1558
case 8:
1559
#line 186 "parse.y"
1560
{ file->errors++; }
1561
break;
1562
case 9:
1563
#line 190 "parse.y"
1564
{
1565
			struct file *nfile;
1566
1567
			if ((nfile =
1568
			    pushfile(yyvsp[0].v.string, 1)) == NULL) {
1569
				yyerror("failed to include file %s", yyvsp[0].v.string);
1570
				free(yyvsp[0].v.string);
1571
				YYERROR;
1572
			}
1573
			free(yyvsp[0].v.string);
1574
1575
			file = nfile;
1576
			lungetc('\n');
1577
		}
1578
break;
1579
case 10:
1580
#line 206 "parse.y"
1581
{
1582
			if (!TAILQ_EMPTY(&hostapd_cfg.c_apmes))
1583
				hostapd_cfg.c_flags |= HOSTAPD_CFG_F_APME;
1584
		}
1585
break;
1586
case 12:
1587
#line 212 "parse.y"
1588
{
1589
			bcopy(&yyvsp[0].v.timeout, &hostapd_cfg.c_apme_hopdelay,
1590
			    sizeof(struct timeval));
1591
		}
1592
break;
1593
case 14:
1594
#line 218 "parse.y"
1595
{
1596
			if (strlcpy(hostapd_cfg.c_iapp.i_iface, yyvsp[-1].v.string,
1597
			    sizeof(hostapd_cfg.c_iapp.i_iface)) >=
1598
			    sizeof(hostapd_cfg.c_iapp.i_iface)) {
1599
				yyerror("invalid interface %s", yyvsp[-1].v.string);
1600
				free(yyvsp[-1].v.string);
1601
				YYERROR;
1602
			}
1603
1604
			hostapd_cfg.c_flags |= HOSTAPD_CFG_F_IAPP;
1605
1606
			hostapd_log(HOSTAPD_LOG_DEBUG,
1607
			    "%s: IAPP interface added", yyvsp[-1].v.string);
1608
1609
			free(yyvsp[-1].v.string);
1610
		}
1611
break;
1612
case 16:
1613
#line 236 "parse.y"
1614
{
1615
			if ((hostapd_cfg.c_iapp.i_addr_tbl =
1616
			    hostapd_table_lookup(&hostapd_cfg, yyvsp[0].v.string)) == NULL) {
1617
				yyerror("undefined table <%s>", yyvsp[0].v.string);
1618
				free(yyvsp[0].v.string);
1619
				YYERROR;
1620
			}
1621
			free(yyvsp[0].v.string);
1622
		}
1623
break;
1624
case 17:
1625
#line 246 "parse.y"
1626
{
1627
			if ((hostapd_cfg.c_iapp.i_route_tbl =
1628
			    hostapd_table_lookup(&hostapd_cfg, yyvsp[0].v.string)) == NULL) {
1629
				yyerror("undefined table <%s>", yyvsp[0].v.string);
1630
				free(yyvsp[0].v.string);
1631
				YYERROR;
1632
			}
1633
			free(yyvsp[0].v.string);
1634
		}
1635
break;
1636
case 19:
1637
#line 259 "parse.y"
1638
{
1639
			hostapd_cfg.c_flags &= ~HOSTAPD_CFG_F_BRDCAST;
1640
		}
1641
break;
1642
case 20:
1643
#line 263 "parse.y"
1644
{
1645
			hostapd_cfg.c_flags |= HOSTAPD_CFG_F_BRDCAST;
1646
		}
1647
break;
1648
case 22:
1649
#line 270 "parse.y"
1650
{
1651
			bcopy(&yyvsp[0].v.in, &hostapd_cfg.c_iapp.i_multicast.sin_addr,
1652
			    sizeof(struct in_addr));
1653
		}
1654
break;
1655
case 24:
1656
#line 278 "parse.y"
1657
{
1658
			if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > UINT16_MAX) {
1659
				yyerror("port out of range: %lld", yyvsp[0].v.number);
1660
				YYERROR;
1661
			}
1662
			hostapd_cfg.c_iapp.i_addr.sin_port = htons(yyvsp[0].v.number);
1663
		}
1664
break;
1665
case 26:
1666
#line 289 "parse.y"
1667
{
1668
			if (yyvsp[0].v.number < 1 || yyvsp[0].v.number > UINT8_MAX) {
1669
				yyerror("ttl out of range: %lld", yyvsp[0].v.number);
1670
				YYERROR;
1671
			}
1672
			hostapd_cfg.c_iapp.i_ttl = yyvsp[0].v.number;
1673
		}
1674
break;
1675
case 27:
1676
#line 299 "parse.y"
1677
{
1678
			hostapd_cfg.c_apme_dlt = DLT_IEEE802_11_RADIO;
1679
		}
1680
break;
1681
case 28:
1682
#line 303 "parse.y"
1683
{
1684
			hostapd_cfg.c_apme_dlt = DLT_IEEE802_11;
1685
		}
1686
break;
1687
case 33:
1688
#line 317 "parse.y"
1689
{
1690
			if (hostapd_apme_add(&hostapd_cfg, yyvsp[0].v.string) != 0) {
1691
				yyerror("failed to add hostap interface");
1692
				YYERROR;
1693
			}
1694
			free(yyvsp[0].v.string);
1695
		}
1696
break;
1697
case 38:
1698
#line 335 "parse.y"
1699
{
1700
			if ((apme = hostapd_apme_addhopper(&hostapd_cfg,
1701
			    yyvsp[0].v.string)) == NULL) {
1702
				yyerror("failed to add hopper %s", yyvsp[0].v.string);
1703
				free(yyvsp[0].v.string);
1704
				YYERROR;
1705
			}
1706
			free(yyvsp[0].v.string);
1707
		}
1708
break;
1709
case 40:
1710
#line 348 "parse.y"
1711
{
1712
			if ((frame.f_apme =
1713
			    hostapd_apme_lookup(&hostapd_cfg, yyvsp[0].v.string)) == NULL) {
1714
				yyerror("undefined hostap interface");
1715
				free(yyvsp[0].v.string);
1716
				YYERROR;
1717
			}
1718
			free(yyvsp[0].v.string);
1719
1720
			HOSTAPD_MATCH(APME, yyvsp[-1].v.number);
1721
		}
1722
break;
1723
case 41:
1724
#line 362 "parse.y"
1725
{
1726
			bzero(&frame, sizeof(struct hostapd_frame));
1727
			/* IEEE 802.11 frame to match */
1728
			frame_ieee80211 = &frame.f_frame;
1729
		}
1730
break;
1731
case 42:
1732
#line 366 "parse.y"
1733
{
1734
			/* IEEE 802.11 raw frame to send as an action */
1735
			frame_ieee80211 = &frame.f_action_data.a_frame;
1736
		}
1737
break;
1738
case 43:
1739
#line 369 "parse.y"
1740
{
1741
			if ((frame_ptr = calloc(1, sizeof(struct hostapd_frame)))
1742
			    == NULL) {
1743
				yyerror("calloc");
1744
				YYERROR;
1745
			}
1746
1747
			if (gettimeofday(&frame.f_last, NULL) == -1)
1748
				hostapd_fatal("gettimeofday");
1749
			timeradd(&frame.f_last, &frame.f_limit, &frame.f_then);
1750
1751
			bcopy(&frame, frame_ptr, sizeof(struct hostapd_frame));
1752
			TAILQ_INSERT_TAIL(&hostapd_cfg.c_frames,
1753
			    frame_ptr, f_entries);
1754
		}
1755
break;
1756
case 48:
1757
#line 395 "parse.y"
1758
{
1759
			HOSTAPD_IAPP_FLAG(ADD_NOTIFY, yyvsp[-2].v.number);
1760
		}
1761
break;
1762
case 49:
1763
#line 399 "parse.y"
1764
{
1765
			HOSTAPD_IAPP_FLAG(RADIOTAP, yyvsp[-1].v.number);
1766
		}
1767
break;
1768
case 50:
1769
#line 403 "parse.y"
1770
{
1771
			HOSTAPD_IAPP_FLAG(ROAMING_ROUTE, yyvsp[-2].v.number);
1772
		}
1773
break;
1774
case 51:
1775
#line 407 "parse.y"
1776
{
1777
			HOSTAPD_IAPP_FLAG(ROAMING_ADDRESS, yyvsp[-2].v.number);
1778
		}
1779
break;
1780
case 52:
1781
#line 413 "parse.y"
1782
{
1783
			frame.f_flags |= HOSTAPD_FRAME_F_RET_OK;
1784
		}
1785
break;
1786
case 53:
1787
#line 417 "parse.y"
1788
{
1789
			frame.f_flags |= HOSTAPD_FRAME_F_RET_QUICK;
1790
		}
1791
break;
1792
case 54:
1793
#line 421 "parse.y"
1794
{
1795
			frame.f_flags |= HOSTAPD_FRAME_F_RET_SKIP;
1796
		}
1797
break;
1798
case 55:
1799
#line 427 "parse.y"
1800
{
1801
			frame.f_action = HOSTAPD_ACTION_NONE;
1802
		}
1803
break;
1804
case 56:
1805
#line 431 "parse.y"
1806
{
1807
			frame.f_action = HOSTAPD_ACTION_LOG;
1808
		}
1809
break;
1810
case 57:
1811
#line 435 "parse.y"
1812
{
1813
			frame.f_action = HOSTAPD_ACTION_FRAME;
1814
		}
1815
break;
1816
case 59:
1817
#line 440 "parse.y"
1818
{
1819
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_REF_M) == 0) {
1820
				bcopy(yyvsp[0].v.reflladdr.lladdr, frame.f_action_data.a_lladdr,
1821
				    IEEE80211_ADDR_LEN);
1822
			} else
1823
				frame.f_action_data.a_flags |= yyvsp[0].v.reflladdr.flags;
1824
		}
1825
break;
1826
case 60:
1827
#line 448 "parse.y"
1828
{
1829
			frame.f_action = HOSTAPD_ACTION_RESEND;
1830
		}
1831
break;
1832
case 62:
1833
#line 455 "parse.y"
1834
{
1835
			frame.f_action_flags |= HOSTAPD_ACTION_VERBOSE;
1836
		}
1837
break;
1838
case 63:
1839
#line 461 "parse.y"
1840
{
1841
			frame.f_action = HOSTAPD_ACTION_RADIOTAP;
1842
		}
1843
break;
1844
case 64:
1845
#line 467 "parse.y"
1846
{
1847
			frame.f_action = HOSTAPD_ACTION_DELNODE;
1848
		}
1849
break;
1850
case 65:
1851
#line 471 "parse.y"
1852
{
1853
			frame.f_action = HOSTAPD_ACTION_ADDNODE;
1854
		}
1855
break;
1856
case 72:
1857
#line 490 "parse.y"
1858
{
1859
			if (yyvsp[-1].v.number < 0 || yyvsp[-1].v.number > LONG_MAX) {
1860
				yyerror("limit out of range: %lld sec", yyvsp[-1].v.number);
1861
				YYERROR;
1862
			}
1863
			frame.f_limit.tv_sec = yyvsp[-1].v.number;
1864
		}
1865
break;
1866
case 73:
1867
#line 498 "parse.y"
1868
{
1869
			if (yyvsp[-1].v.number < 0 || yyvsp[-1].v.number > LONG_MAX) {
1870
				yyerror("limit out of range: %lld usec", yyvsp[-1].v.number);
1871
				YYERROR;
1872
			}
1873
			frame.f_limit.tv_usec = yyvsp[-1].v.number;
1874
		}
1875
break;
1876
case 75:
1877
#line 509 "parse.y"
1878
{
1879
			if ((yyvsp[-3].v.number < 1 || yyvsp[-3].v.number > LONG_MAX) ||
1880
			    (yyvsp[-1].v.number < 1 || yyvsp[-1].v.number > LONG_MAX)) {
1881
				yyerror("rate out of range: %lld/%lld sec",
1882
				    yyvsp[-3].v.number, yyvsp[-1].v.number);
1883
				YYERROR;
1884
			}
1885
1886
			if (!(yyvsp[-3].v.number && yyvsp[-1].v.number)) {
1887
				yyerror("invalid rate");
1888
				YYERROR;
1889
			}
1890
1891
			frame.f_rate = yyvsp[-3].v.number;
1892
			frame.f_rate_intval = yyvsp[-1].v.number;
1893
		}
1894
break;
1895
case 78:
1896
#line 530 "parse.y"
1897
{
1898
			frame_ieee80211->i_fc[0] |=
1899
			    IEEE80211_FC0_TYPE_DATA;
1900
			HOSTAPD_MATCH(TYPE, yyvsp[-1].v.number);
1901
		}
1902
break;
1903
case 79:
1904
#line 536 "parse.y"
1905
{
1906
			frame_ieee80211->i_fc[0] |=
1907
			    IEEE80211_FC0_TYPE_MGT;
1908
			HOSTAPD_MATCH(TYPE, yyvsp[-2].v.number);
1909
		}
1910
break;
1911
case 82:
1912
#line 546 "parse.y"
1913
{
1914
			HOSTAPD_MATCH(SUBTYPE, yyvsp[-1].v.number);
1915
		}
1916
break;
1917
case 83:
1918
#line 552 "parse.y"
1919
{
1920
			frame_ieee80211->i_fc[0] |=
1921
			    IEEE80211_FC0_SUBTYPE_PROBE_REQ;
1922
		}
1923
break;
1924
case 84:
1925
#line 557 "parse.y"
1926
{
1927
			frame_ieee80211->i_fc[0] |=
1928
			    IEEE80211_FC0_SUBTYPE_PROBE_RESP;
1929
		}
1930
break;
1931
case 85:
1932
#line 562 "parse.y"
1933
{
1934
			frame_ieee80211->i_fc[0] |=
1935
			    IEEE80211_FC0_SUBTYPE_BEACON;
1936
		}
1937
break;
1938
case 86:
1939
#line 567 "parse.y"
1940
{
1941
			frame_ieee80211->i_fc[0] |=
1942
			    IEEE80211_FC0_SUBTYPE_ATIM;
1943
		}
1944
break;
1945
case 87:
1946
#line 572 "parse.y"
1947
{
1948
			frame_ieee80211->i_fc[0] |=
1949
			    IEEE80211_FC0_SUBTYPE_AUTH;
1950
		}
1951
break;
1952
case 88:
1953
#line 577 "parse.y"
1954
{
1955
			frame_ieee80211->i_fc[0] |=
1956
			    IEEE80211_FC0_SUBTYPE_DEAUTH;
1957
		}
1958
break;
1959
case 89:
1960
#line 582 "parse.y"
1961
{
1962
			frame_ieee80211->i_fc[0] |=
1963
			    IEEE80211_FC0_SUBTYPE_ASSOC_REQ;
1964
		}
1965
break;
1966
case 90:
1967
#line 587 "parse.y"
1968
{
1969
			frame_ieee80211->i_fc[0] |=
1970
			    IEEE80211_FC0_SUBTYPE_DISASSOC;
1971
		}
1972
break;
1973
case 91:
1974
#line 592 "parse.y"
1975
{
1976
			frame_ieee80211->i_fc[0] |=
1977
			    IEEE80211_FC0_SUBTYPE_ASSOC_RESP;
1978
		}
1979
break;
1980
case 92:
1981
#line 597 "parse.y"
1982
{
1983
			frame_ieee80211->i_fc[0] |=
1984
			    IEEE80211_FC0_SUBTYPE_REASSOC_REQ;
1985
		}
1986
break;
1987
case 93:
1988
#line 602 "parse.y"
1989
{
1990
			frame_ieee80211->i_fc[0] |=
1991
			    IEEE80211_FC0_SUBTYPE_REASSOC_RESP;
1992
		}
1993
break;
1994
case 100:
1995
#line 621 "parse.y"
1996
{
1997
			if ((frame_ieee80211->i_data = malloc(6)) == NULL) {
1998
				yyerror("failed to allocate auth");
1999
				YYERROR;
2000
			}
2001
			((u_int16_t *)frame_ieee80211->i_data)[0] =
2002
				yyvsp[0].v.authalg.alg;
2003
			((u_int16_t *)frame_ieee80211->i_data)[1] =
2004
				yyvsp[0].v.authalg.transaction;
2005
			((u_int16_t *)frame_ieee80211->i_data)[0] = 0;
2006
			frame_ieee80211->i_data_len = 6;
2007
		}
2008
break;
2009
case 101:
2010
#line 636 "parse.y"
2011
{
2012
			yyval.v.authalg.alg = htole16(IEEE80211_AUTH_ALG_OPEN);
2013
			yyval.v.authalg.transaction = htole16(IEEE80211_AUTH_OPEN_REQUEST);
2014
		}
2015
break;
2016
case 102:
2017
#line 641 "parse.y"
2018
{
2019
			yyval.v.authalg.alg = htole16(IEEE80211_AUTH_ALG_OPEN);
2020
			yyval.v.authalg.transaction = htole16(IEEE80211_AUTH_OPEN_RESPONSE);
2021
		}
2022
break;
2023
case 103:
2024
#line 648 "parse.y"
2025
{
2026
			if (yyvsp[0].v.reason != 0) {
2027
				if ((frame_ieee80211->i_data =
2028
				    malloc(sizeof(u_int16_t))) == NULL) {
2029
					yyerror("failed to allocate "
2030
					    "reason code %u", yyvsp[0].v.reason);
2031
					YYERROR;
2032
				}
2033
				*(u_int16_t *)frame_ieee80211->i_data =
2034
				    htole16(yyvsp[0].v.reason);
2035
				frame_ieee80211->i_data_len = sizeof(u_int16_t);
2036
			}
2037
		}
2038
break;
2039
case 104:
2040
#line 664 "parse.y"
2041
{
2042
			yyval.v.reason = 0;
2043
		}
2044
break;
2045
case 105:
2046
#line 668 "parse.y"
2047
{
2048
			yyval.v.reason = IEEE80211_REASON_UNSPECIFIED;
2049
		}
2050
break;
2051
case 106:
2052
#line 672 "parse.y"
2053
{
2054
			yyval.v.reason = IEEE80211_REASON_AUTH_EXPIRE;
2055
		}
2056
break;
2057
case 107:
2058
#line 676 "parse.y"
2059
{
2060
			yyval.v.reason = IEEE80211_REASON_AUTH_LEAVE;
2061
		}
2062
break;
2063
case 108:
2064
#line 680 "parse.y"
2065
{
2066
			yyval.v.reason = IEEE80211_REASON_ASSOC_EXPIRE;
2067
		}
2068
break;
2069
case 109:
2070
#line 684 "parse.y"
2071
{
2072
			yyval.v.reason = IEEE80211_REASON_ASSOC_TOOMANY;
2073
		}
2074
break;
2075
case 110:
2076
#line 688 "parse.y"
2077
{
2078
			yyval.v.reason = IEEE80211_REASON_NOT_AUTHED;
2079
		}
2080
break;
2081
case 111:
2082
#line 692 "parse.y"
2083
{
2084
			yyval.v.reason = IEEE80211_REASON_NOT_ASSOCED;
2085
		}
2086
break;
2087
case 112:
2088
#line 696 "parse.y"
2089
{
2090
			yyval.v.reason = IEEE80211_REASON_ASSOC_LEAVE;
2091
		}
2092
break;
2093
case 113:
2094
#line 700 "parse.y"
2095
{
2096
			yyval.v.reason = IEEE80211_REASON_NOT_AUTHED;
2097
		}
2098
break;
2099
case 114:
2100
#line 704 "parse.y"
2101
{
2102
			yyval.v.reason = 10;	/* XXX unknown */
2103
		}
2104
break;
2105
case 115:
2106
#line 708 "parse.y"
2107
{
2108
			yyval.v.reason = IEEE80211_REASON_RSN_REQUIRED;
2109
		}
2110
break;
2111
case 116:
2112
#line 712 "parse.y"
2113
{
2114
			yyval.v.reason = IEEE80211_REASON_RSN_INCONSISTENT;
2115
		}
2116
break;
2117
case 117:
2118
#line 716 "parse.y"
2119
{
2120
			yyval.v.reason = IEEE80211_REASON_IE_INVALID;
2121
		}
2122
break;
2123
case 118:
2124
#line 720 "parse.y"
2125
{
2126
			yyval.v.reason = IEEE80211_REASON_MIC_FAILURE;
2127
		}
2128
break;
2129
case 121:
2130
#line 728 "parse.y"
2131
{
2132
			HOSTAPD_MATCH(DIR, yyvsp[-1].v.number);
2133
		}
2134
break;
2135
case 122:
2136
#line 734 "parse.y"
2137
{
2138
			frame_ieee80211->i_fc[1] |= IEEE80211_FC1_DIR_NODS;
2139
		}
2140
break;
2141
case 123:
2142
#line 738 "parse.y"
2143
{
2144
			frame_ieee80211->i_fc[1] |= IEEE80211_FC1_DIR_TODS;
2145
		}
2146
break;
2147
case 124:
2148
#line 742 "parse.y"
2149
{
2150
			frame_ieee80211->i_fc[1] |= IEEE80211_FC1_DIR_FROMDS;
2151
		}
2152
break;
2153
case 125:
2154
#line 746 "parse.y"
2155
{
2156
			frame_ieee80211->i_fc[1] |= IEEE80211_FC1_DIR_DSTODS;
2157
		}
2158
break;
2159
case 128:
2160
#line 754 "parse.y"
2161
{
2162
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_OPT_TABLE) == 0) {
2163
				bcopy(yyvsp[0].v.reflladdr.lladdr, &frame_ieee80211->i_from,
2164
				    IEEE80211_ADDR_LEN);
2165
				HOSTAPD_MATCH(FROM, yyvsp[-1].v.number);
2166
			} else {
2167
				frame.f_from = yyvsp[0].v.reflladdr.table;
2168
				HOSTAPD_MATCH_TABLE(FROM, yyvsp[-1].v.number);
2169
			}
2170
		}
2171
break;
2172
case 131:
2173
#line 769 "parse.y"
2174
{
2175
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_OPT_TABLE) == 0) {
2176
				bcopy(yyvsp[0].v.reflladdr.lladdr, &frame_ieee80211->i_to,
2177
				    IEEE80211_ADDR_LEN);
2178
				HOSTAPD_MATCH(TO, yyvsp[-1].v.number);
2179
			} else {
2180
				frame.f_to = yyvsp[0].v.reflladdr.table;
2181
				HOSTAPD_MATCH_TABLE(TO, yyvsp[-1].v.number);
2182
			}
2183
		}
2184
break;
2185
case 134:
2186
#line 784 "parse.y"
2187
{
2188
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_OPT_TABLE) == 0) {
2189
				bcopy(yyvsp[0].v.reflladdr.lladdr, &frame_ieee80211->i_bssid,
2190
				    IEEE80211_ADDR_LEN);
2191
				HOSTAPD_MATCH(BSSID, yyvsp[-1].v.number);
2192
			} else {
2193
				frame.f_bssid = yyvsp[0].v.reflladdr.table;
2194
				HOSTAPD_MATCH_TABLE(BSSID, yyvsp[-1].v.number);
2195
			}
2196
		}
2197
break;
2198
case 139:
2199
#line 805 "parse.y"
2200
{
2201
			if ((yyvsp[-1].v.op == HOSTAPD_OP_GT && yyvsp[0].v.number == 100) ||
2202
			    (yyvsp[-1].v.op == HOSTAPD_OP_LE && yyvsp[0].v.number == 100) ||
2203
			    (yyvsp[-1].v.op == HOSTAPD_OP_LT && yyvsp[0].v.number == 0) ||
2204
			    (yyvsp[-1].v.op == HOSTAPD_OP_GE && yyvsp[0].v.number == 0)) {
2205
				yyerror("absurd unary comparison");
2206
				YYERROR;
2207
			}
2208
2209
			frame.f_rssi_op = yyvsp[-1].v.op;
2210
			frame.f_rssi = yyvsp[0].v.number;
2211
			HOSTAPD_MATCH_RADIOTAP(RSSI);
2212
		}
2213
break;
2214
case 140:
2215
#line 819 "parse.y"
2216
{
2217
			frame.f_txrate_op = yyvsp[-1].v.op;
2218
			frame.f_txrate = yyvsp[0].v.number;
2219
			HOSTAPD_MATCH_RADIOTAP(RATE);
2220
		}
2221
break;
2222
case 141:
2223
#line 825 "parse.y"
2224
{
2225
			frame.f_chan_op = yyvsp[-1].v.op;
2226
			frame.f_chan = yyvsp[0].v.number;
2227
			HOSTAPD_MATCH_RADIOTAP(CHANNEL);
2228
		}
2229
break;
2230
case 142:
2231
#line 833 "parse.y"
2232
{
2233
			if ((yyval.v.reflladdr.table =
2234
			    hostapd_table_lookup(&hostapd_cfg, yyvsp[0].v.string)) == NULL) {
2235
				yyerror("undefined table <%s>", yyvsp[0].v.string);
2236
				free(yyvsp[0].v.string);
2237
				YYERROR;
2238
			}
2239
			yyval.v.reflladdr.flags = HOSTAPD_ACTION_F_OPT_TABLE;
2240
			free(yyvsp[0].v.string);
2241
		}
2242
break;
2243
case 143:
2244
#line 844 "parse.y"
2245
{
2246
			bcopy(yyvsp[0].v.reflladdr.lladdr, yyval.v.reflladdr.lladdr, IEEE80211_ADDR_LEN);
2247
			yyval.v.reflladdr.flags = HOSTAPD_ACTION_F_OPT_LLADDR;
2248
		}
2249
break;
2250
case 144:
2251
#line 851 "parse.y"
2252
{
2253
			frame_ieee80211->i_fc[0] |= IEEE80211_FC0_TYPE_DATA;
2254
		}
2255
break;
2256
case 145:
2257
#line 855 "parse.y"
2258
{
2259
			frame_ieee80211->i_fc[0] |= IEEE80211_FC0_TYPE_MGT;
2260
		}
2261
break;
2262
case 147:
2263
#line 864 "parse.y"
2264
{
2265
			frame.f_action_data.a_flags |=
2266
			    HOSTAPD_ACTION_F_OPT_DIR_AUTO;
2267
		}
2268
break;
2269
case 149:
2270
#line 872 "parse.y"
2271
{
2272
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_REF_M) == 0) {
2273
				bcopy(yyvsp[0].v.reflladdr.lladdr, frame_ieee80211->i_from,
2274
				    IEEE80211_ADDR_LEN);
2275
			} else
2276
				frame.f_action_data.a_flags |=
2277
				    (yyvsp[0].v.reflladdr.flags << HOSTAPD_ACTION_F_REF_FROM_S);
2278
		}
2279
break;
2280
case 150:
2281
#line 883 "parse.y"
2282
{
2283
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_REF_M) == 0) {
2284
				bcopy(yyvsp[0].v.reflladdr.lladdr, frame_ieee80211->i_to,
2285
				    IEEE80211_ADDR_LEN);
2286
			} else
2287
				frame.f_action_data.a_flags |=
2288
				    (yyvsp[0].v.reflladdr.flags << HOSTAPD_ACTION_F_REF_TO_S);
2289
		}
2290
break;
2291
case 151:
2292
#line 894 "parse.y"
2293
{
2294
			if ((yyvsp[0].v.reflladdr.flags & HOSTAPD_ACTION_F_REF_M) == 0) {
2295
				bcopy(yyvsp[0].v.reflladdr.lladdr, frame_ieee80211->i_bssid,
2296
				    IEEE80211_ADDR_LEN);
2297
			} else
2298
				frame.f_action_data.a_flags |=
2299
				    (yyvsp[0].v.reflladdr.flags << HOSTAPD_ACTION_F_REF_BSSID_S);
2300
		}
2301
break;
2302
case 152:
2303
#line 905 "parse.y"
2304
{
2305
			bcopy(yyvsp[0].v.reflladdr.lladdr, yyval.v.reflladdr.lladdr, IEEE80211_ADDR_LEN);
2306
			yyval.v.reflladdr.flags = yyvsp[0].v.reflladdr.flags;
2307
		}
2308
break;
2309
case 153:
2310
#line 910 "parse.y"
2311
{
2312
			yyval.v.reflladdr.flags = yyvsp[0].v.reflladdr.flags;
2313
		}
2314
break;
2315
case 154:
2316
#line 914 "parse.y"
2317
{
2318
			yyval.v.reflladdr.flags = yyvsp[0].v.reflladdr.flags;
2319
		}
2320
break;
2321
case 155:
2322
#line 919 "parse.y"
2323
{
2324
			if (strlen(yyvsp[-1].v.string) >= HOSTAPD_TABLE_NAMELEN) {
2325
				yyerror("table name %s too long, max %u",
2326
				    yyvsp[-1].v.string, HOSTAPD_TABLE_NAMELEN - 1);
2327
				free(yyvsp[-1].v.string);
2328
				YYERROR;
2329
			}
2330
			yyval.v.string = yyvsp[-1].v.string;
2331
		}
2332
break;
2333
case 156:
2334
#line 930 "parse.y"
2335
{
2336
			if ((table =
2337
			    hostapd_table_add(&hostapd_cfg, yyvsp[0].v.string)) == NULL) {
2338
				yyerror("failed to add table: %s", yyvsp[0].v.string);
2339
				free(yyvsp[0].v.string);
2340
				YYERROR;
2341
			}
2342
			free(yyvsp[0].v.string);
2343
		}
2344
break;
2345
case 157:
2346
#line 938 "parse.y"
2347
{
2348
			table = NULL;
2349
		}
2350
break;
2351
case 162:
2352
#line 951 "parse.y"
2353
{
2354
			if (table->t_flags & HOSTAPD_TABLE_F_CONST) {
2355
				yyerror("option already specified");
2356
				YYERROR;
2357
			}
2358
			table->t_flags |= HOSTAPD_TABLE_F_CONST;
2359
		}
2360
break;
2361
case 165:
2362
#line 963 "parse.y"
2363
{
2364
			if (asprintf(&yyval.v.string, "%s %s", yyvsp[-1].v.string, yyvsp[0].v.string) == -1)
2365
				hostapd_fatal("string: asprintf");
2366
			free(yyvsp[-1].v.string);
2367
			free(yyvsp[0].v.string);
2368
		}
2369
break;
2370
case 167:
2371
#line 973 "parse.y"
2372
{
2373
			char *s = yyvsp[-2].v.string;
2374
			while (*s++) {
2375
				if (isspace((unsigned char)*s)) {
2376
					yyerror("macro name cannot contain "
2377
					    "whitespace");
2378
					YYERROR;
2379
				}
2380
			}
2381
			if (symset(yyvsp[-2].v.string, yyvsp[0].v.string, 0) == -1)
2382
				hostapd_fatal("cannot store variable");
2383
			free(yyvsp[-2].v.string);
2384
			free(yyvsp[0].v.string);
2385
		}
2386
break;
2387
case 168:
2388
#line 990 "parse.y"
2389
{
2390
			yyval.v.reflladdr.flags |= HOSTAPD_ACTION_F_REF_FROM;
2391
		}
2392
break;
2393
case 169:
2394
#line 994 "parse.y"
2395
{
2396
			yyval.v.reflladdr.flags |= HOSTAPD_ACTION_F_REF_TO;
2397
		}
2398
break;
2399
case 170:
2400
#line 998 "parse.y"
2401
{
2402
			yyval.v.reflladdr.flags |= HOSTAPD_ACTION_F_REF_BSSID;
2403
		}
2404
break;
2405
case 173:
2406
#line 1008 "parse.y"
2407
{
2408
			if ((entry = hostapd_entry_add(table,
2409
			    yyvsp[0].v.reflladdr.lladdr)) == NULL) {
2410
				yyerror("failed to add entry: %s",
2411
				    etheraddr_string(yyvsp[0].v.reflladdr.lladdr));
2412
				YYERROR;
2413
			}
2414
		}
2415
break;
2416
case 174:
2417
#line 1015 "parse.y"
2418
{
2419
			entry = NULL;
2420
		}
2421
break;
2422
case 176:
2423
#line 1022 "parse.y"
2424
{
2425
			entry->e_flags |= HOSTAPD_ENTRY_F_INADDR;
2426
			entry->e_inaddr.in_af = AF_INET;
2427
			bcopy(&yyvsp[-1].v.in, &entry->e_inaddr.in_v4,
2428
			    sizeof(struct in_addr));
2429
		}
2430
break;
2431
case 177:
2432
#line 1029 "parse.y"
2433
{
2434
			entry->e_flags |= HOSTAPD_ENTRY_F_MASK;
2435
			bcopy(yyvsp[0].v.reflladdr.lladdr, entry->e_mask, IEEE80211_ADDR_LEN);
2436
2437
			/* Update entry position in the table */
2438
			hostapd_entry_update(table, entry);
2439
		}
2440
break;
2441
case 178:
2442
#line 1039 "parse.y"
2443
{
2444
			if (inet_net_pton(AF_INET, yyvsp[0].v.string, &yyval.v.in, sizeof(yyval.v.in)) == -1) {
2445
				yyerror("invalid address: %s\n", yyvsp[0].v.string);
2446
				free(yyvsp[0].v.string);
2447
				YYERROR;
2448
			}
2449
			free(yyvsp[0].v.string);
2450
		}
2451
break;
2452
case 179:
2453
#line 1050 "parse.y"
2454
{
2455
			entry->e_inaddr.in_netmask = -1;
2456
		}
2457
break;
2458
case 180:
2459
#line 1054 "parse.y"
2460
{
2461
			if (yyvsp[0].v.number < 0 || yyvsp[0].v.number > 32) {
2462
				yyerror("netmask out of range: %lld", yyvsp[0].v.number);
2463
				YYERROR;
2464
			}
2465
			entry->e_inaddr.in_netmask = yyvsp[0].v.number;
2466
		}
2467
break;
2468
case 181:
2469
#line 1064 "parse.y"
2470
{
2471
			struct ether_addr *ea;
2472
2473
			if ((ea = ether_aton(yyvsp[0].v.string)) == NULL) {
2474
				yyerror("invalid address: %s\n", yyvsp[0].v.string);
2475
				free(yyvsp[0].v.string);
2476
				YYERROR;
2477
			}
2478
			free(yyvsp[0].v.string);
2479
2480
			bcopy(ea, yyval.v.reflladdr.lladdr, IEEE80211_ADDR_LEN);
2481
			yyval.v.reflladdr.flags = HOSTAPD_ACTION_F_OPT_LLADDR;
2482
		}
2483
break;
2484
case 182:
2485
#line 1080 "parse.y"
2486
{
2487
			yyval.v.reflladdr.flags |= HOSTAPD_ACTION_F_REF_RANDOM;
2488
		}
2489
break;
2490
case 184:
2491
#line 1087 "parse.y"
2492
{
2493
			hostapd_cfg.c_flags |= HOSTAPD_CFG_F_IAPP_PASSIVE;
2494
		}
2495
break;
2496
case 191:
2497
#line 1107 "parse.y"
2498
{
2499
			yyval.v.number = 0;
2500
		}
2501
break;
2502
case 192:
2503
#line 1111 "parse.y"
2504
{
2505
			yyval.v.number = 1;
2506
		}
2507
break;
2508
case 193:
2509
#line 1115 "parse.y"
2510
{
2511
			yyval.v.number = 1;
2512
		}
2513
break;
2514
case 194:
2515
#line 1121 "parse.y"
2516
{
2517
			yyval.v.op = HOSTAPD_OP_EQ;
2518
		}
2519
break;
2520
case 195:
2521
#line 1125 "parse.y"
2522
{
2523
			yyval.v.op = HOSTAPD_OP_EQ;
2524
		}
2525
break;
2526
case 196:
2527
#line 1129 "parse.y"
2528
{
2529
			yyval.v.op = HOSTAPD_OP_EQ;
2530
		}
2531
break;
2532
case 197:
2533
#line 1133 "parse.y"
2534
{
2535
			yyval.v.op = HOSTAPD_OP_NE;
2536
		}
2537
break;
2538
case 198:
2539
#line 1137 "parse.y"
2540
{
2541
			yyval.v.op = HOSTAPD_OP_NE;
2542
		}
2543
break;
2544
case 199:
2545
#line 1141 "parse.y"
2546
{
2547
			yyval.v.op = HOSTAPD_OP_LE;
2548
		}
2549
break;
2550
case 200:
2551
#line 1145 "parse.y"
2552
{
2553
			yyval.v.op = HOSTAPD_OP_LT;
2554
		}
2555
break;
2556
case 201:
2557
#line 1149 "parse.y"
2558
{
2559
			yyval.v.op = HOSTAPD_OP_GE;
2560
		}
2561
break;
2562
case 202:
2563
#line 1153 "parse.y"
2564
{
2565
			yyval.v.op = HOSTAPD_OP_GT;
2566
		}
2567
break;
2568
case 203:
2569
#line 1159 "parse.y"
2570
{
2571
			double val;
2572
			char *cp;
2573
2574
			val = strtod(yyvsp[0].v.string, &cp);
2575
			if (cp == NULL || strcmp(cp, "%") != 0 ||
2576
			    val < 0 || val > 100) {
2577
				yyerror("invalid percentage: %s", yyvsp[0].v.string);
2578
				free(yyvsp[0].v.string);
2579
				YYERROR;
2580
			}
2581
			free(yyvsp[0].v.string);
2582
			yyval.v.number = val;
2583
		}
2584
break;
2585
case 204:
2586
#line 1176 "parse.y"
2587
{
2588
			double val;
2589
			char *cp;
2590
2591
			val = strtod(yyvsp[0].v.string, &cp) * 2;
2592
			if (cp == NULL || strcasecmp(cp, "mb") != 0 ||
2593
			    val != (int)val) {
2594
				yyerror("invalid rate: %s", yyvsp[0].v.string);
2595
				free(yyvsp[0].v.string);
2596
				YYERROR;
2597
			}
2598
			free(yyvsp[0].v.string);
2599
			yyval.v.number = val;
2600
		}
2601
break;
2602
case 205:
2603
#line 1193 "parse.y"
2604
{
2605
			double val;
2606
			char *cp;
2607
2608
			val = strtod(yyvsp[0].v.string, &cp);
2609
			if (cp != NULL) {
2610
				if (strcasecmp(cp, "ghz") == 0) {
2611
					yyval.v.number = val * 1000;
2612
				} else if (strcasecmp(cp, "mhz") == 0) {
2613
					yyval.v.number = val;
2614
				} else
2615
					cp = NULL;
2616
			}
2617
			if (cp == NULL) {
2618
				yyerror("invalid frequency: %s", yyvsp[0].v.string);
2619
				free(yyvsp[0].v.string);
2620
				YYERROR;
2621
			}
2622
			free(yyvsp[0].v.string);
2623
		}
2624
break;
2625
case 206:
2626
#line 1216 "parse.y"
2627
{
2628
			if (yyvsp[0].v.number < 1 || yyvsp[0].v.number > LONG_MAX) {
2629
				yyerror("timeout out of range: %lld", yyvsp[0].v.number);
2630
				YYERROR;
2631
			}
2632
			yyval.v.timeout.tv_sec = yyvsp[0].v.number / 1000;
2633
			yyval.v.timeout.tv_usec = (yyvsp[0].v.number % 1000) * 1000;
2634
		}
2635
break;
2636
#line 2629 "parse.c"
2637
    }
2638
    yyssp -= yym;
2639
    yystate = *yyssp;
2640
    yyvsp -= yym;
2641
    yym = yylhs[yyn];
2642
    if (yystate == 0 && yym == 0)
2643
    {
2644
#if YYDEBUG
2645
        if (yydebug)
2646
            printf("%sdebug: after reduction, shifting from state 0 to\
2647
 state %d\n", YYPREFIX, YYFINAL);
2648
#endif
2649
        yystate = YYFINAL;
2650
        *++yyssp = YYFINAL;
2651
        *++yyvsp = yyval;
2652
        if (yychar < 0)
2653
        {
2654
            if ((yychar = yylex()) < 0) yychar = 0;
2655
#if YYDEBUG
2656
            if (yydebug)
2657
            {
2658
                yys = 0;
2659
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
2660
                if (!yys) yys = "illegal-symbol";
2661
                printf("%sdebug: state %d, reading %d (%s)\n",
2662
                        YYPREFIX, YYFINAL, yychar, yys);
2663
            }
2664
#endif
2665
        }
2666
        if (yychar == 0) goto yyaccept;
2667
        goto yyloop;
2668
    }
2669
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
2670
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
2671
        yystate = yytable[yyn];
2672
    else
2673
        yystate = yydgoto[yym];
2674
#if YYDEBUG
2675
    if (yydebug)
2676
        printf("%sdebug: after reduction, shifting from state %d \
2677
to state %d\n", YYPREFIX, *yyssp, yystate);
2678
#endif
2679
    if (yyssp >= yysslim && yygrowstack())
2680
    {
2681
        goto yyoverflow;
2682
    }
2683
    *++yyssp = yystate;
2684
    *++yyvsp = yyval;
2685
    goto yyloop;
2686
yyoverflow:
2687
    yyerror("yacc stack overflow");
2688
yyabort:
2689
    if (yyss)
2690
            free(yyss);
2691
    if (yyvs)
2692
            free(yyvs);
2693
    yyss = yyssp = NULL;
2694
    yyvs = yyvsp = NULL;
2695
    yystacksize = 0;
2696
    return (1);
2697
yyaccept:
2698
    if (yyss)
2699
            free(yyss);
2700
    if (yyvs)
2701
            free(yyvs);
2702
    yyss = yyssp = NULL;
2703
    yyvs = yyvsp = NULL;
2704
    yystacksize = 0;
2705
    return (0);
2706
}