GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libpcap/grammar.c Lines: 94 339 27.7 %
Date: 2017-11-13 Branches: 52 292 17.8 %

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 yyparse pcap_yyparse
12
#define yylex pcap_yylex
13
#define yyerror pcap_yyerror
14
#define yychar pcap_yychar
15
#define yyval pcap_yyval
16
#define yylval pcap_yylval
17
#define yydebug pcap_yydebug
18
#define yynerrs pcap_yynerrs
19
#define yyerrflag pcap_yyerrflag
20
#define yyss pcap_yyss
21
#define yysslim pcap_yysslim
22
#define yyssp pcap_yyssp
23
#define yyvs pcap_yyvs
24
#define yyvsp pcap_yyvsp
25
#define yystacksize pcap_yystacksize
26
#define yylhs pcap_yylhs
27
#define yylen pcap_yylen
28
#define yydefred pcap_yydefred
29
#define yydgoto pcap_yydgoto
30
#define yysindex pcap_yysindex
31
#define yyrindex pcap_yyrindex
32
#define yygindex pcap_yygindex
33
#define yytable pcap_yytable
34
#define yycheck pcap_yycheck
35
#define yyname pcap_yyname
36
#define yyrule pcap_yyrule
37
#define YYPREFIX "pcap_yy"
38
#line 2 "grammar.y"
39
/*	$OpenBSD: grammar.y,v 1.19 2009/10/27 23:59:30 deraadt Exp $	*/
40
41
/*
42
 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
43
 *	The Regents of the University of California.  All rights reserved.
44
 *
45
 * Redistribution and use in source and binary forms, with or without
46
 * modification, are permitted provided that: (1) source code distributions
47
 * retain the above copyright notice and this paragraph in its entirety, (2)
48
 * distributions including binary code include the above copyright notice and
49
 * this paragraph in its entirety in the documentation or other materials
50
 * provided with the distribution, and (3) all advertising materials mentioning
51
 * features or use of this software display the following acknowledgement:
52
 * ``This product includes software developed by the University of California,
53
 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
54
 * the University nor the names of its contributors may be used to endorse
55
 * or promote products derived from this software without specific prior
56
 * written permission.
57
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
58
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
59
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60
 *
61
 */
62
63
#include <sys/types.h>
64
#include <sys/time.h>
65
#include <sys/socket.h>
66
67
struct mbuf;
68
struct rtentry;
69
70
#include <net/if.h>
71
72
#include <netinet/in.h>
73
#include <netinet/if_ether.h>
74
75
#include <net/pfvar.h>
76
77
#include <net80211/ieee80211.h>
78
79
#include <stdio.h>
80
#include <string.h>
81
82
#include "pcap-int.h"
83
84
#include "gencode.h"
85
#include <pcap-namedb.h>
86
87
#ifdef HAVE_OS_PROTO_H
88
#include "os-proto.h"
89
#endif
90
91
#define QSET(q, p, d, a) (q).proto = (p),\
92
			 (q).dir = (d),\
93
			 (q).addr = (a)
94
95
int n_errors = 0;
96
97
static struct qual qerr = { Q_UNDEF, Q_UNDEF, Q_UNDEF, Q_UNDEF };
98
99
static void
100
yyerror(char *msg)
101
{
102
	++n_errors;
103
	bpf_error("%s", msg);
104
	/* NOTREACHED */
105
}
106
107
#ifndef YYBISON
108
int yyparse(void);
109
110
int
111
pcap_parse()
112
{
113
	return (yyparse());
114
}
115
#endif
116
117
#line 82 "grammar.y"
118
#ifndef YYSTYPE_DEFINED
119
#define YYSTYPE_DEFINED
120
typedef union {
121
	int i;
122
	bpf_u_int32 h;
123
	u_char *e;
124
	char *s;
125
	struct stmt *stmt;
126
	struct arth *a;
127
	struct {
128
		struct qual q;
129
		struct block *b;
130
	} blk;
131
	struct block *rblk;
132
} YYSTYPE;
133
#endif /* YYSTYPE_DEFINED */
134
#line 135 "grammar.c"
135
#define DST 257
136
3
#define SRC 258
137
#define HOST 259
138
3
#define GATEWAY 260
139
#define NET 261
140
3
#define MASK 262
141
3
#define PORT 263
142
#define LESS 264
143
3
#define GREATER 265
144
3
#define PROTO 266
145
#define PROTOCHAIN 267
146
#define BYTE 268
147
#define ARP 269
148
3
#define RARP 270
149
3
#define IP 271
150
#define TCP 272
151
#define UDP 273
152
#define ICMP 274
153
#define IGMP 275
154
#define IGRP 276
155
#define PIM 277
156
#define ATALK 278
157
#define DECNET 279
158
#define LAT 280
159
#define SCA 281
160
#define MOPRC 282
161
#define MOPDL 283
162
#define STP 284
163
#define TK_BROADCAST 285
164
#define TK_MULTICAST 286
165
#define NUM 287
166
#define INBOUND 288
167
#define OUTBOUND 289
168
#define PF_IFNAME 290
169
#define PF_RSET 291
170
#define PF_RNR 292
171
#define PF_SRNR 293
172
#define PF_REASON 294
173
#define PF_ACTION 295
174
#define TYPE 296
175
#define SUBTYPE 297
176
#define DIR 298
177
#define ADDR1 299
178
#define ADDR2 300
179
#define ADDR3 301
180
#define ADDR4 302
181
#define LINK 303
182
#define GEQ 304
183
#define LEQ 305
184
#define NEQ 306
185
#define ID 307
186
#define EID 308
187
#define HID 309
188
#define HID6 310
189
#define LSH 311
190
#define RSH 312
191
#define LEN 313
192
#define IPV6 314
193
#define ICMPV6 315
194
#define AH 316
195
#define ESP 317
196
#define VLAN 318
197
#define OR 319
198
#define AND 320
199
#define UMINUS 321
200
#define YYERRCODE 256
201
const short pcap_yylhs[] =
202
	{                                        -1,
203
    0,    0,   24,    1,    1,    1,    1,    1,   20,   21,
204
    2,    2,    2,    3,    3,    3,    3,    3,    3,    3,
205
    3,   23,   22,    4,    4,    4,    7,    7,    5,    5,
206
    8,    8,    8,    8,    8,    8,    6,    6,    6,    6,
207
    6,    6,    9,    9,   10,   10,   10,   10,   10,   10,
208
   10,   10,   10,   10,   11,   11,   11,   12,   16,   16,
209
   16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
210
   16,   16,   16,   16,   16,   16,   16,   16,   16,   25,
211
   25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
212
   26,   26,   26,   26,   26,   26,   29,   29,   28,   27,
213
   27,   27,   27,   30,   30,   31,   31,   32,   32,   18,
214
   18,   18,   19,   19,   19,   13,   13,   14,   14,   14,
215
   14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
216
   15,   15,   15,   15,   15,   17,   17,
217
};
218
const short pcap_yylen[] =
219
3
	{                                         2,
220
6
    2,    1,    0,    1,    3,    3,    3,    3,    1,    1,
221
3
    1,    1,    3,    1,    3,    3,    1,    3,    1,    1,
222
3
    2,    1,    1,    1,    3,    3,    1,    1,    1,    2,
223
    3,    2,    2,    2,    2,    2,    2,    3,    1,    3,
224
    3,    1,    1,    0,    1,    1,    3,    3,    3,    3,
225
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
226
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
227
    1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
228
    2,    2,    2,    4,    1,    1,    2,    1,    1,    2,
229
    2,    2,    2,    2,    2,    2,    1,    1,    1,    4,
230
    2,    2,    2,    1,    1,    1,    1,    1,    1,    1,
231
    1,    1,    1,    1,    1,    1,    1,    4,    6,    3,
232
    3,    3,    3,    3,    3,    3,    3,    2,    3,    1,
233
    1,    1,    1,    1,    1,    1,    3,
234
};
235
const short pcap_yydefred[] =
236
	{                                      3,
237
    0,    0,    0,    0,    0,   61,   62,   60,   63,   64,
238
   65,   66,   67,   68,   69,   70,   71,   72,   74,   73,
239
   79,  136,   85,   86,    0,    0,    0,    0,    0,    0,
240
   59,  130,   75,   76,   77,   78,    0,   22,    0,   23,
241
    0,    4,   29,    0,    0,    0,  117,    0,  116,    0,
242
    0,   42,   89,   82,   83,    0,   91,   92,   93,   94,
243
   97,   98,   95,   99,   96,   87,    0,  128,    0,    0,
244
   10,    9,    0,    0,   14,   20,    0,    0,   37,   11,
245
   12,    0,    0,    0,    0,   55,   58,   56,   57,   34,
246
   35,   80,   81,    0,    0,    0,   51,   52,   53,   54,
247
    0,   33,   36,   90,  111,  113,  115,    0,    0,    0,
248
    0,    0,    0,    0,    0,  110,  112,  114,    0,    0,
249
    0,    0,    0,    0,   30,  132,  131,  134,  135,  133,
250
    0,    0,    0,    6,    5,    0,    0,    0,    8,    7,
251
    0,    0,    0,   24,    0,    0,    0,   21,    0,    0,
252
    0,    0,  104,  105,    0,  106,  107,  102,  108,  109,
253
  103,   31,    0,    0,    0,    0,    0,    0,  122,  123,
254
    0,    0,    0,   38,  129,  137,   84,    0,   16,   15,
255
   18,   13,    0,    0,   48,   50,   47,   49,    0,  118,
256
    0,   25,   26,  100,    0,  119,
257
};
258
const short pcap_yydgoto[] =
259
	{                                       1,
260
  122,  148,   80,  145,   42,   43,  146,   44,   45,  101,
261
  102,  103,   46,   47,  131,   69,   49,  119,  120,   73,
262
   74,   70,   83,    2,   52,   53,  104,   65,   63,  155,
263
  158,  161,
264
};
265
const short pcap_yysindex[] =
266
	{                                      0,
267
3
    0,  237, -277, -266, -263,    0,    0,    0,    0,    0,
268
6
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
269
3
    0,    0,    0,    0, -274, -260, -232, -225, -275, -254,
270
    0,    0,    0,    0,    0,    0,  -34,    0,  289,    0,
271
 -283,    0,    0,   64,  478,  536,    0,  -25,    0,  237,
272
  237,    0,    0,    0,    0,  126,    0,    0,    0,    0,
273
    0,    0,    0,    0,    0,    0,  -34,    0,  -25,  289,
274
    0,    0,  182,  182,    0,    0,  -45,   21,    0,    0,
275
    0,   64,   64, -228, -226,    0,    0,    0,    0,    0,
276
    0,    0,    0, -273, -268, -264,    0,    0,    0,    0,
277
 -234,    0,    0,    0,    0,    0,    0,  289,  289,  289,
278
  289,  289,  289,  289,  289,    0,    0,    0,  289,  289,
279
  289,  -41,   29,   36,    0,    0,    0,    0,    0,    0,
280
 -207,   36,  156,    0,    0,    0,  182,  182,    0,    0,
281
 -224, -201, -198,    0,   62, -283,   36,    0, -153, -150,
282
 -145, -142,    0,    0, -180,    0,    0,    0,    0,    0,
283
    0,    0,  135,  135,  192,  -38,   -7,   -7,    0,    0,
284
  156,  156,  125,    0,    0,    0,    0,   36,    0,    0,
285
    0,    0,   64,   64,    0,    0,    0,    0, -268,    0,
286
 -162,    0,    0,    0,   35,    0,};
287
const short pcap_yyrindex[] =
288
	{                                      0,
289
    0,  143,    0,    0,    0,    0,    0,    0,    0,    0,
290
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
291
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
292
    0,    0,    0,    0,    0,    0,   11,    0,    0,    0,
293
  130,    0,    0,    0,    0,    0,    0,    1,    0,  524,
294
  524,    0,    0,    0,    0,    0,    0,    0,    0,    0,
295
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
296
    0,    0,  524,  524,    0,    0,   16,   18,    0,    0,
297
    0,    0,    0,  -18,  323,    0,    0,    0,    0,    0,
298
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
299
  337,    0,    0,    0,    0,    0,    0,    0,    0,    0,
300
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
301
    0,    0,  574,  610,    0,    0,    0,    0,    0,    0,
302
    0,    0,    0,    0,    0,    3,  524,  524,    0,    0,
303
    0,    0,    0,    0, -196,    0, -187,    0,    0,    0,
304
    0,    0,    0,    0,   20,    0,    0,    0,    0,    0,
305
    0,    0,   49,   78,   60,   88,   13,   38,    0,    0,
306
   26,   28,    0,    0,    0,    0,    0,  114,    0,    0,
307
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
308
    0,    0,    0,    0,    0,    0,};
309
const short pcap_yygindex[] =
310
	{                                      0,
311
  132,   40,  -65,    0,  -43,    0,    0,    0,    0,    0,
312
   34,    0,  598,   32,    0,  158,  614,    0,    0,   -5,
313
   -2,  612,  592,    0,    0,    0,    0,    0,    0,    0,
314
  -44,    0,
315
};
316
#define YYTABLESIZE 922
317
const short pcap_yytable[] =
318
	{                                     174,
319
   39,  142,   12,  114,  112,   40,  113,  125,  115,   54,
320
   88,   61,  120,  153,   46,   17,  144,   19,  156,  101,
321
   55,   46,  159,   56,   86,   40,   88,   41,   89,  135,
322
  140,   62,   57,  154,  114,   71,   72,  121,  157,  115,
323
  116,   39,  160,   12,  116,  116,   58,  116,  126,  116,
324
  120,   88,   64,  120,   59,  120,   17,  120,   19,  125,
325
  101,   60,  116,  116,  116,  121,   40,  143,   41,  175,
326
  120,  144,  120,  120,  120,  121,  176,  127,  121,  177,
327
  121,  123,  121,   79,  179,  180,  126,  124,  181,  126,
328
  149,  150,  151,  152,  125,  121,   38,  121,  121,  121,
329
  125,  123,  182,   40,  185,  120,  126,  186,  126,  126,
330
  126,  187,  134,  139,  188,  127,  189,  125,  127,  125,
331
  125,  125,   28,   28,  195,  124,  116,  196,  124,    1,
332
  121,   27,   27,   41,  162,  127,  120,  127,  127,  127,
333
  183,  126,    2,  184,  194,  124,    0,  124,  124,  124,
334
    0,  116,  125,    0,    0,  116,  116,    0,  116,   48,
335
  116,  121,  111,  127,    0,    0,  114,  112,  123,  113,
336
  127,  115,  126,  116,  116,  116,  114,  112,    0,  113,
337
  124,  115,  191,  125,    0,  130,  129,  128,    0,    0,
338
    0,    0,    0,  111,    0,    0,    0,  114,  112,    0,
339
  113,  127,  115,    0,    0,    0,    0,   48,   48,    0,
340
    0,  124,    0,    0,   38,    0,  141,  190,    0,    0,
341
    0,   40,  192,  193,    0,    0,   39,    0,    0,  111,
342
   48,   48,    0,  114,  112,    0,  113,  116,  115,    0,
343
   46,    0,   46,    0,   46,    0,    0,    0,  110,  126,
344
    0,    0,   22,    0,    0,    0,    0,   43,   43,   43,
345
   43,   43,    0,   43,    0,    0,   43,   43,   46,   38,
346
    0,    0,  108,  109,    0,    0,   40,   71,   72,  110,
347
    0,   39,    0,    0,    0,   43,   43,    0,   46,   46,
348
   46,   46,    0,    0,   48,   48,   43,   43,   43,   43,
349
   43,   43,   43,    0,    0,    0,  116,  116,  116,    0,
350
    0,    0,    0,  116,  116,    0,  120,  120,  120,   39,
351
   39,   12,   12,  120,  120,    0,    0,    0,   40,   88,
352
   88,  120,  120,   39,   17,   17,   19,   19,  101,  101,
353
    0,  121,  121,  121,   40,   40,   41,   41,  121,  121,
354
   22,    0,  126,  126,  126,   45,  121,  121,    0,  126,
355
  126,    0,   45,  125,  125,  125,    0,  126,  126,   32,
356
   75,   76,   77,   78,    0,    0,   32,    0,  125,  125,
357
    0,  127,  127,  127,    0,    0,    0,    0,  127,  127,
358
    0,  124,  124,  124,    0,    0,  127,  127,    0,   44,
359
   44,   44,   44,   44,    0,   44,  124,  124,   44,   44,
360
    0,    0,    0,    0,    0,    0,    0,  116,  116,  116,
361
    0,    0,    0,    0,  116,  116,    0,   44,   44,    0,
362
    0,    0,   27,   27,    0,  108,  109,    0,   44,   44,
363
   44,   44,   44,   44,   44,    3,    4,    0,    0,    5,
364
    6,    7,    8,    9,   10,   11,   12,   13,   14,   15,
365
   16,   17,   18,   19,   20,   21,  108,  109,   22,   23,
366
   24,   25,   26,   27,   28,   29,   30,    0,    0,    0,
367
    0,    0,    0,    0,   31,    0,    0,    0,   75,   76,
368
   77,   78,    0,    0,   32,   33,   34,   35,   36,   37,
369
    3,    4,  108,  109,    5,    6,    7,    8,    9,   10,
370
   11,   12,   13,   14,   15,   16,   17,   18,   19,   20,
371
   21,    0,    0,   22,   23,   24,   25,   26,   27,   28,
372
   29,   30,    0,    0,    0,    0,    0,    0,    0,   31,
373
    0,    0,    0,    0,    0,    0,    0,    0,    0,   32,
374
   33,   34,   35,   36,   37,    0,    0,    6,    7,    8,
375
    9,   10,   11,   12,   13,   14,   15,   16,   17,   18,
376
   19,   20,   21,  111,    0,   22,    0,  114,  112,    0,
377
  113,   45,  115,   45,    0,   45,    0,    0,    0,    0,
378
    0,   31,    0,   51,    0,  118,  117,  116,    0,    0,
379
    0,   32,   33,   34,   35,   36,    0,    0,    0,   45,
380
    0,  117,    0,   50,    0,  117,  117,    0,  117,    0,
381
  117,    0,    0,   32,    0,    0,    0,    0,    0,   45,
382
   45,   45,   45,  117,  117,  117,   68,    0,    0,    0,
383
    0,   51,   51,   32,   32,   32,   32,  116,   67,    0,
384
   66,  116,  116,    0,  116,   82,  116,   81,    0,  110,
385
    0,   50,   50,  124,  138,  138,    0,  133,    0,  116,
386
  116,  116,    0,    0,    0,    0,    0,    0,   67,    0,
387
  132,    0,    0,  124,  137,  137,  136,  136,    0,    0,
388
    0,    0,    0,   67,   82,  147,   81,  117,    0,    0,
389
    0,    0,    0,    0,    0,  163,  164,  165,  166,  167,
390
  168,  169,  170,    0,    0,    0,  171,  172,  173,    0,
391
    0,    0,    0,    0,    0,    0,    0,    0,  138,  138,
392
    0,    0,    0,  116,   84,   85,   86,   87,   88,    0,
393
   89,    0,    0,   90,   91,    0,    0,    0,   50,  137,
394
  178,  136,    0,    0,    0,    0,    0,    0,    0,    0,
395
    0,    0,   92,   93,    0,    0,    0,    0,    0,    0,
396
    0,    0,    0,   94,   95,   96,   97,   98,   99,  100,
397
   44,   44,   44,   44,   44,    0,   44,    0,    0,   44,
398
   44,    0,    0,    0,   82,   82,   81,   81,    0,    0,
399
    0,    0,    0,    0,    0,    0,    0,    0,   44,   44,
400
    0,    0,    0,    0,    0,    0,    0,    0,    0,   44,
401
   44,   44,   44,   44,   44,   44,    0,    0,    0,    0,
402
    0,    0,    0,    0,    0,    0,    0,    0,    0,  105,
403
  106,  107,    0,    0,    0,    0,  108,  109,    0,    0,
404
3
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
405
3
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
406
    0,    0,    0,    0,    0,    0,    0,  117,  117,  117,
407
    0,    0,    0,    0,  117,  117,    0,    0,    0,    0,
408
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
409
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
410
6
    0,    0,    0,  116,  116,  116,    0,    0,    0,    0,
411
6
  116,  116,
412
};
413
3
const short pcap_yycheck[] =
414
3
	{                                      41,
415
    0,   47,    0,   42,   43,   40,   45,   51,   47,  287,
416
    0,  287,    0,  287,   33,    0,   82,    0,  287,    0,
417
  287,   40,  287,  287,  259,    0,  261,    0,  263,   73,
418
   74,  307,  307,  307,   42,  319,  320,    0,  307,   47,
419
   38,   41,  307,   41,   42,   43,  307,   45,    0,   47,
420
   38,   41,  307,   41,  287,   43,   41,   45,   41,    0,
421
   41,  287,   60,   61,   62,   91,   41,   47,   41,   41,
422
   58,  137,   60,   61,   62,   38,   41,    0,   41,  287,
423
   43,   50,   45,   44,  309,  287,   38,    0,  287,   41,
424
  319,  320,  319,  320,  138,   58,   33,   60,   61,   62,
425
   41,   70,   41,   40,  258,   93,   58,  258,   60,   61,
426
   62,  257,   73,   74,  257,   38,  297,   58,   41,   60,
427
   61,   62,  319,  320,  287,   38,  124,   93,   41,    0,
428
   93,  319,  320,    2,  101,   58,  124,   60,   61,   62,
429
  146,   93,    0,  146,  189,   58,   -1,   60,   61,   62,
430
   -1,   38,   93,   -1,   -1,   42,   43,   -1,   45,    2,
431
   47,  124,   38,   38,   -1,   -1,   42,   43,  137,   45,
432
   93,   47,  124,   60,   61,   62,   42,   43,   -1,   45,
433
   93,   47,   58,  124,   -1,   60,   61,   62,   -1,   -1,
434
   -1,   -1,   -1,   38,   -1,   -1,   -1,   42,   43,   -1,
435
   45,  124,   47,   -1,   -1,   -1,   -1,   50,   51,   -1,
436
   -1,  124,   -1,   -1,   33,   -1,  262,   93,   -1,   -1,
437
   -1,   40,  183,  184,   -1,   -1,   45,   -1,   -1,   38,
438
   73,   74,   -1,   42,   43,   -1,   45,  124,   47,   -1,
439
  259,   -1,  261,   -1,  263,   -1,   -1,   -1,  124,  124,
440
   -1,   -1,  287,   -1,   -1,   -1,   -1,  257,  258,  259,
441
  260,  261,   -1,  263,   -1,   -1,  266,  267,  287,   33,
442
   -1,   -1,  311,  312,   -1,   -1,   40,  319,  320,  124,
443
   -1,   45,   -1,   -1,   -1,  285,  286,   -1,  307,  308,
444
  309,  310,   -1,   -1,  137,  138,  296,  297,  298,  299,
445
  300,  301,  302,   -1,   -1,   -1,  304,  305,  306,   -1,
446
   -1,   -1,   -1,  311,  312,   -1,  304,  305,  306,  319,
447
  320,  319,  320,  311,  312,   -1,   -1,   -1,   40,  319,
448
  320,  319,  320,   45,  319,  320,  319,  320,  319,  320,
449
   -1,  304,  305,  306,  319,  320,  319,  320,  311,  312,
450
  287,   -1,  304,  305,  306,   33,  319,  320,   -1,  311,
451
  312,   -1,   40,  304,  305,  306,   -1,  319,  320,   33,
452
  307,  308,  309,  310,   -1,   -1,   40,   -1,  319,  320,
453
   -1,  304,  305,  306,   -1,   -1,   -1,   -1,  311,  312,
454
   -1,  304,  305,  306,   -1,   -1,  319,  320,   -1,  257,
455
  258,  259,  260,  261,   -1,  263,  319,  320,  266,  267,
456
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,
457
   -1,   -1,   -1,   -1,  311,  312,   -1,  285,  286,   -1,
458
   -1,   -1,  319,  320,   -1,  311,  312,   -1,  296,  297,
459
  298,  299,  300,  301,  302,  264,  265,   -1,   -1,  268,
460
  269,  270,  271,  272,  273,  274,  275,  276,  277,  278,
461
  279,  280,  281,  282,  283,  284,  311,  312,  287,  288,
462
  289,  290,  291,  292,  293,  294,  295,   -1,   -1,   -1,
463
   -1,   -1,   -1,   -1,  303,   -1,   -1,   -1,  307,  308,
464
  309,  310,   -1,   -1,  313,  314,  315,  316,  317,  318,
465
  264,  265,  311,  312,  268,  269,  270,  271,  272,  273,
466
  274,  275,  276,  277,  278,  279,  280,  281,  282,  283,
467
  284,   -1,   -1,  287,  288,  289,  290,  291,  292,  293,
468
  294,  295,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  303,
469
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  313,
470
  314,  315,  316,  317,  318,   -1,   -1,  269,  270,  271,
471
  272,  273,  274,  275,  276,  277,  278,  279,  280,  281,
472
  282,  283,  284,   38,   -1,  287,   -1,   42,   43,   -1,
473
   45,  259,   47,  261,   -1,  263,   -1,   -1,   -1,   -1,
474
   -1,  303,   -1,    2,   -1,   60,   61,   62,   -1,   -1,
475
   -1,  313,  314,  315,  316,  317,   -1,   -1,   -1,  287,
476
   -1,   38,   -1,    2,   -1,   42,   43,   -1,   45,   -1,
477
   47,   -1,   -1,  287,   -1,   -1,   -1,   -1,   -1,  307,
478
  308,  309,  310,   60,   61,   62,   39,   -1,   -1,   -1,
479
   -1,   50,   51,  307,  308,  309,  310,   38,   37,   -1,
480
   37,   42,   43,   -1,   45,   44,   47,   44,   -1,  124,
481
   -1,   50,   51,   50,   73,   74,   -1,   70,   -1,   60,
482
   61,   62,   -1,   -1,   -1,   -1,   -1,   -1,   67,   -1,
483
   67,   -1,   -1,   70,   73,   74,   73,   74,   -1,   -1,
484
   -1,   -1,   -1,   82,   83,   82,   83,  124,   -1,   -1,
485
   -1,   -1,   -1,   -1,   -1,  108,  109,  110,  111,  112,
486
  113,  114,  115,   -1,   -1,   -1,  119,  120,  121,   -1,
487
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  137,  138,
488
   -1,   -1,   -1,  124,  257,  258,  259,  260,  261,   -1,
489
  263,   -1,   -1,  266,  267,   -1,   -1,   -1,  137,  138,
490
  137,  138,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
491
   -1,   -1,  285,  286,   -1,   -1,   -1,   -1,   -1,   -1,
492
   -1,   -1,   -1,  296,  297,  298,  299,  300,  301,  302,
493
  257,  258,  259,  260,  261,   -1,  263,   -1,   -1,  266,
494
  267,   -1,   -1,   -1,  183,  184,  183,  184,   -1,   -1,
495
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  285,  286,
496
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  296,
497
  297,  298,  299,  300,  301,  302,   -1,   -1,   -1,   -1,
498
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,
499
  305,  306,   -1,   -1,   -1,   -1,  311,  312,   -1,   -1,
500
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
501
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
502
   -1,   -1,   -1,   -1,   -1,   -1,   -1,  304,  305,  306,
503
   -1,   -1,   -1,   -1,  311,  312,   -1,   -1,   -1,   -1,
504
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
505
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
506
   -1,   -1,   -1,  304,  305,  306,   -1,   -1,   -1,   -1,
507
  311,  312,
508
};
509
#define YYFINAL 1
510
#ifndef YYDEBUG
511
#define YYDEBUG 0
512
#endif
513
#define YYMAXTOKEN 321
514
#if YYDEBUG
515
const char * const pcap_yyname[] =
516
	{
517
"end-of-file",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,
518
"'!'",0,0,0,0,"'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,0,0,
519
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,
520
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,
521
"'|'",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,
522
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,
523
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,
524
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"DST","SRC","HOST","GATEWAY","NET","MASK","PORT",
525
"LESS","GREATER","PROTO","PROTOCHAIN","BYTE","ARP","RARP","IP","TCP","UDP",
526
"ICMP","IGMP","IGRP","PIM","ATALK","DECNET","LAT","SCA","MOPRC","MOPDL","STP",
527
"TK_BROADCAST","TK_MULTICAST","NUM","INBOUND","OUTBOUND","PF_IFNAME","PF_RSET",
528
"PF_RNR","PF_SRNR","PF_REASON","PF_ACTION","TYPE","SUBTYPE","DIR","ADDR1",
529
"ADDR2","ADDR3","ADDR4","LINK","GEQ","LEQ","NEQ","ID","EID","HID","HID6","LSH",
530
"RSH","LEN","IPV6","ICMPV6","AH","ESP","VLAN","OR","AND","UMINUS",
531
};
532
const char * const pcap_yyrule[] =
533
	{"$accept : prog",
534
"prog : null expr",
535
"prog : null",
536
"null :",
537
"expr : term",
538
"expr : expr and term",
539
"expr : expr and id",
540
"expr : expr or term",
541
"expr : expr or id",
542
"and : AND",
543
"or : OR",
544
"id : nid",
545
"id : pnum",
546
"id : paren pid ')'",
547
"nid : ID",
548
"nid : HID '/' NUM",
549
"nid : HID MASK HID",
550
"nid : HID",
551
"nid : HID6 '/' NUM",
552
"nid : HID6",
553
"nid : EID",
554
"nid : not id",
555
"not : '!'",
556
"paren : '('",
557
"pid : nid",
558
"pid : qid and id",
559
"pid : qid or id",
560
"qid : pnum",
561
"qid : pid",
562
"term : rterm",
563
"term : not term",
564
"head : pqual dqual aqual",
565
"head : pqual dqual",
566
"head : pqual aqual",
567
"head : pqual PROTO",
568
"head : pqual PROTOCHAIN",
569
"head : pqual ndaqual",
570
"rterm : head id",
571
"rterm : paren expr ')'",
572
"rterm : pname",
573
"rterm : arth relop arth",
574
"rterm : arth irelop arth",
575
"rterm : other",
576
"pqual : pname",
577
"pqual :",
578
"dqual : SRC",
579
"dqual : DST",
580
"dqual : SRC OR DST",
581
"dqual : DST OR SRC",
582
"dqual : SRC AND DST",
583
"dqual : DST AND SRC",
584
"dqual : ADDR1",
585
"dqual : ADDR2",
586
"dqual : ADDR3",
587
"dqual : ADDR4",
588
"aqual : HOST",
589
"aqual : NET",
590
"aqual : PORT",
591
"ndaqual : GATEWAY",
592
"pname : LINK",
593
"pname : IP",
594
"pname : ARP",
595
"pname : RARP",
596
"pname : TCP",
597
"pname : UDP",
598
"pname : ICMP",
599
"pname : IGMP",
600
"pname : IGRP",
601
"pname : PIM",
602
"pname : ATALK",
603
"pname : DECNET",
604
"pname : LAT",
605
"pname : SCA",
606
"pname : MOPDL",
607
"pname : MOPRC",
608
"pname : IPV6",
609
"pname : ICMPV6",
610
"pname : AH",
611
"pname : ESP",
612
"pname : STP",
613
"other : pqual TK_BROADCAST",
614
"other : pqual TK_MULTICAST",
615
"other : LESS NUM",
616
"other : GREATER NUM",
617
"other : BYTE NUM byteop NUM",
618
"other : INBOUND",
619
"other : OUTBOUND",
620
"other : VLAN pnum",
621
"other : VLAN",
622
"other : pfvar",
623
"other : pqual p80211",
624
"pfvar : PF_IFNAME ID",
625
"pfvar : PF_RSET ID",
626
"pfvar : PF_RNR NUM",
627
"pfvar : PF_SRNR NUM",
628
"pfvar : PF_REASON reason",
629
"pfvar : PF_ACTION action",
630
"reason : NUM",
631
"reason : ID",
632
"action : ID",
633
"p80211 : TYPE type SUBTYPE subtype",
634
"p80211 : TYPE type",
635
"p80211 : SUBTYPE subtype",
636
"p80211 : DIR dir",
637
"type : NUM",
638
"type : ID",
639
"subtype : NUM",
640
"subtype : ID",
641
"dir : NUM",
642
"dir : ID",
643
"relop : '>'",
644
"relop : GEQ",
645
"relop : '='",
646
"irelop : LEQ",
647
"irelop : '<'",
648
"irelop : NEQ",
649
"arth : pnum",
650
"arth : narth",
651
"narth : pname '[' arth ']'",
652
"narth : pname '[' arth ':' NUM ']'",
653
"narth : arth '+' arth",
654
"narth : arth '-' arth",
655
"narth : arth '*' arth",
656
"narth : arth '/' arth",
657
"narth : arth '&' arth",
658
"narth : arth '|' arth",
659
"narth : arth LSH arth",
660
"narth : arth RSH arth",
661
"narth : '-' arth",
662
"narth : paren narth ')'",
663
"narth : LEN",
664
"byteop : '&'",
665
"byteop : '|'",
666
"byteop : '<'",
667
"byteop : '>'",
668
"byteop : '='",
669
"pnum : NUM",
670
"pnum : paren pnum ')'",
671
};
672
#endif
673
#ifdef YYSTACKSIZE
674
#undef YYMAXDEPTH
675
#define YYMAXDEPTH YYSTACKSIZE
676
#else
677
#ifdef YYMAXDEPTH
678
#define YYSTACKSIZE YYMAXDEPTH
679
#else
680
#define YYSTACKSIZE 10000
681
#define YYMAXDEPTH 10000
682
#endif
683
#endif
684
#define YYINITSTACKSIZE 200
685
/* LINTUSED */
686
int yydebug;
687
int yynerrs;
688
int yyerrflag;
689
int yychar;
690
short *yyssp;
691
YYSTYPE *yyvsp;
692
YYSTYPE yyval;
693
YYSTYPE yylval;
694
short *yyss;
695
short *yysslim;
696
YYSTYPE *yyvs;
697
unsigned int yystacksize;
698
int yyparse(void);
699
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
700
static int yygrowstack(void)
701
{
702
    unsigned int newsize;
703
    long sslen;
704
    short *newss;
705
    YYSTYPE *newvs;
706
707
6
    if ((newsize = yystacksize) == 0)
708
3
        newsize = YYINITSTACKSIZE;
709
    else if (newsize >= YYMAXDEPTH)
710
        return -1;
711
    else if ((newsize *= 2) > YYMAXDEPTH)
712
        newsize = YYMAXDEPTH;
713
3
    sslen = yyssp - yyss;
714
#ifdef SIZE_MAX
715
#define YY_SIZE_MAX SIZE_MAX
716
#else
717
#define YY_SIZE_MAX 0xffffffffU
718
#endif
719

6
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newss)
720
        goto bail;
721
6
    newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) :
722
3
      (short *)malloc(newsize * sizeof *newss); /* overflow check above */
723
3
    if (newss == NULL)
724
        goto bail;
725
3
    yyss = newss;
726
3
    yyssp = newss + sslen;
727

6
    if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs)
728
        goto bail;
729
6
    newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) :
730
3
      (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */
731
3
    if (newvs == NULL)
732
        goto bail;
733
3
    yyvs = newvs;
734
3
    yyvsp = newvs + sslen;
735
3
    yystacksize = newsize;
736
3
    yysslim = yyss + newsize - 1;
737
3
    return 0;
738
bail:
739
    if (yyss)
740
            free(yyss);
741
    if (yyvs)
742
            free(yyvs);
743
    yyss = yyssp = NULL;
744
    yyvs = yyvsp = NULL;
745
    yystacksize = 0;
746
    return -1;
747
3
}
748
749
#define YYABORT goto yyabort
750
#define YYREJECT goto yyabort
751
#define YYACCEPT goto yyaccept
752
#define YYERROR goto yyerrlab
753
int
754
yyparse(void)
755
{
756
    int yym, yyn, yystate;
757
#if YYDEBUG
758
    const char *yys;
759
760
    if ((yys = getenv("YYDEBUG")))
761
    {
762
        yyn = *yys;
763
        if (yyn >= '0' && yyn <= '9')
764
            yydebug = yyn - '0';
765
    }
766
#endif /* YYDEBUG */
767
768
6
    yynerrs = 0;
769
3
    yyerrflag = 0;
770
3
    yychar = (-1);
771
772

6
    if (yyss == NULL && yygrowstack()) goto yyoverflow;
773
3
    yyssp = yyss;
774
3
    yyvsp = yyvs;
775
3
    *yyssp = yystate = 0;
776
777
yyloop:
778
78
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
779
33
    if (yychar < 0)
780
    {
781
27
        if ((yychar = yylex()) < 0) yychar = 0;
782
#if YYDEBUG
783
        if (yydebug)
784
        {
785
            yys = 0;
786
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
787
            if (!yys) yys = "illegal-symbol";
788
            printf("%sdebug: state %d, reading %d (%s)\n",
789
                    YYPREFIX, yystate, yychar, yys);
790
        }
791
#endif
792
27
    }
793

129
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
794
63
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
795
    {
796
#if YYDEBUG
797
        if (yydebug)
798
            printf("%sdebug: state %d, shifting to state %d\n",
799
                    YYPREFIX, yystate, yytable[yyn]);
800
#endif
801

24
        if (yyssp >= yysslim && yygrowstack())
802
        {
803
            goto yyoverflow;
804
        }
805
24
        *++yyssp = yystate = yytable[yyn];
806
24
        *++yyvsp = yylval;
807
24
        yychar = (-1);
808
24
        if (yyerrflag > 0)  --yyerrflag;
809
24
        goto yyloop;
810
    }
811

36
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
812
18
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
813
    {
814
9
        yyn = yytable[yyn];
815
9
        goto yyreduce;
816
    }
817
    if (yyerrflag) goto yyinrecovery;
818
#if defined(__GNUC__)
819
    goto yynewerror;
820
#endif
821
yynewerror:
822
    yyerror("syntax error");
823
#if defined(__GNUC__)
824
    goto yyerrlab;
825
#endif
826
yyerrlab:
827
    ++yynerrs;
828
yyinrecovery:
829
    if (yyerrflag < 3)
830
    {
831
        yyerrflag = 3;
832
        for (;;)
833
        {
834
            if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
835
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
836
            {
837
#if YYDEBUG
838
                if (yydebug)
839
                    printf("%sdebug: state %d, error recovery shifting\
840
 to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
841
#endif
842
                if (yyssp >= yysslim && yygrowstack())
843
                {
844
                    goto yyoverflow;
845
                }
846
                *++yyssp = yystate = yytable[yyn];
847
                *++yyvsp = yylval;
848
                goto yyloop;
849
            }
850
            else
851
            {
852
#if YYDEBUG
853
                if (yydebug)
854
                    printf("%sdebug: error recovery discarding state %d\n",
855
                            YYPREFIX, *yyssp);
856
#endif
857
                if (yyssp <= yyss) goto yyabort;
858
                --yyssp;
859
                --yyvsp;
860
            }
861
        }
862
    }
863
    else
864
    {
865
        if (yychar == 0) goto yyabort;
866
#if YYDEBUG
867
        if (yydebug)
868
        {
869
            yys = 0;
870
            if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
871
            if (!yys) yys = "illegal-symbol";
872
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
873
                    YYPREFIX, yystate, yychar, yys);
874
        }
875
#endif
876
        yychar = (-1);
877
        goto yyloop;
878
    }
879
yyreduce:
880
#if YYDEBUG
881
    if (yydebug)
882
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
883
                YYPREFIX, yystate, yyn, yyrule[yyn]);
884
#endif
885
54
    yym = yylen[yyn];
886
54
    if (yym)
887
51
        yyval = yyvsp[1-yym];
888
    else
889
3
        memset(&yyval, 0, sizeof yyval);
890































90
    switch (yyn)
891
    {
892
case 1:
893
#line 135 "grammar.y"
894
{
895
	finish_parse(yyvsp[0].blk.b);
896
}
897
break;
898
case 3:
899
#line 140 "grammar.y"
900
{ yyval.blk.q = qerr; }
901
break;
902
case 5:
903
#line 143 "grammar.y"
904
{ gen_and(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
905
break;
906
case 6:
907
#line 144 "grammar.y"
908
{ gen_and(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
909
break;
910
case 7:
911
#line 145 "grammar.y"
912
{ gen_or(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
913
break;
914
case 8:
915
#line 146 "grammar.y"
916
{ gen_or(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
917
break;
918
case 9:
919
#line 148 "grammar.y"
920
{ yyval.blk = yyvsp[-1].blk; }
921
break;
922
case 10:
923
#line 150 "grammar.y"
924
{ yyval.blk = yyvsp[-1].blk; }
925
break;
926
case 12:
927
#line 153 "grammar.y"
928
{ yyval.blk.b = gen_ncode(NULL, (bpf_u_int32)yyvsp[0].i,
929
						   yyval.blk.q = yyvsp[-1].blk.q); }
930
break;
931
case 13:
932
#line 155 "grammar.y"
933
{ yyval.blk = yyvsp[-1].blk; }
934
break;
935
case 14:
936
#line 157 "grammar.y"
937
{ yyval.blk.b = gen_scode(yyvsp[0].s, yyval.blk.q = yyvsp[-1].blk.q); }
938
break;
939
case 15:
940
#line 158 "grammar.y"
941
{ yyval.blk.b = gen_mcode(yyvsp[-2].s, NULL, yyvsp[0].i,
942
				    yyval.blk.q = yyvsp[-3].blk.q); }
943
break;
944
case 16:
945
#line 160 "grammar.y"
946
{ yyval.blk.b = gen_mcode(yyvsp[-2].s, yyvsp[0].s, 0,
947
				    yyval.blk.q = yyvsp[-3].blk.q); }
948
break;
949
case 17:
950
#line 162 "grammar.y"
951
{
952
				  /* Decide how to parse HID based on proto */
953
				  yyval.blk.q = yyvsp[-1].blk.q;
954
				  switch (yyval.blk.q.proto) {
955
				  case Q_DECNET:
956
					yyval.blk.b = gen_ncode(yyvsp[0].s, 0, yyval.blk.q);
957
					break;
958
				  default:
959
					yyval.blk.b = gen_ncode(yyvsp[0].s, 0, yyval.blk.q);
960
					break;
961
				  }
962
				}
963
break;
964
case 18:
965
#line 174 "grammar.y"
966
{
967
#ifdef INET6
968
				  yyval.blk.b = gen_mcode6(yyvsp[-2].s, NULL, yyvsp[0].i,
969
				    yyval.blk.q = yyvsp[-3].blk.q);
970
#else
971
				  bpf_error("'ip6addr/prefixlen' not supported "
972
					"in this configuration");
973
#endif /*INET6*/
974
				}
975
break;
976
case 19:
977
#line 183 "grammar.y"
978
{
979
#ifdef INET6
980
				  yyval.blk.b = gen_mcode6(yyvsp[0].s, 0, 128,
981
				    yyval.blk.q = yyvsp[-1].blk.q);
982
#else
983
				  bpf_error("'ip6addr' not supported "
984
					"in this configuration");
985
#endif /*INET6*/
986
				}
987
break;
988
case 20:
989
#line 192 "grammar.y"
990
{ yyval.blk.b = gen_ecode(yyvsp[0].e, yyval.blk.q = yyvsp[-1].blk.q); }
991
break;
992
case 21:
993
#line 193 "grammar.y"
994
{ gen_not(yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
995
break;
996
case 22:
997
#line 195 "grammar.y"
998
{ yyval.blk = yyvsp[-1].blk; }
999
break;
1000
case 23:
1001
#line 197 "grammar.y"
1002
{ yyval.blk = yyvsp[-1].blk; }
1003
break;
1004
case 25:
1005
#line 200 "grammar.y"
1006
{ gen_and(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
1007
break;
1008
case 26:
1009
#line 201 "grammar.y"
1010
{ gen_or(yyvsp[-2].blk.b, yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
1011
break;
1012
case 27:
1013
#line 203 "grammar.y"
1014
{ yyval.blk.b = gen_ncode(NULL, (bpf_u_int32)yyvsp[0].i,
1015
						   yyval.blk.q = yyvsp[-1].blk.q); }
1016
break;
1017
case 30:
1018
#line 208 "grammar.y"
1019
{ gen_not(yyvsp[0].blk.b); yyval.blk = yyvsp[0].blk; }
1020
break;
1021
case 31:
1022
#line 210 "grammar.y"
1023
{ QSET(yyval.blk.q, yyvsp[-2].i, yyvsp[-1].i, yyvsp[0].i); }
1024
break;
1025
case 32:
1026
#line 211 "grammar.y"
1027
{ QSET(yyval.blk.q, yyvsp[-1].i, yyvsp[0].i, Q_DEFAULT); }
1028
break;
1029
case 33:
1030
#line 212 "grammar.y"
1031
{ QSET(yyval.blk.q, yyvsp[-1].i, Q_DEFAULT, yyvsp[0].i); }
1032
break;
1033
case 34:
1034
#line 213 "grammar.y"
1035
{ QSET(yyval.blk.q, yyvsp[-1].i, Q_DEFAULT, Q_PROTO); }
1036
break;
1037
case 35:
1038
#line 214 "grammar.y"
1039
{ QSET(yyval.blk.q, yyvsp[-1].i, Q_DEFAULT, Q_PROTOCHAIN); }
1040
break;
1041
case 36:
1042
#line 215 "grammar.y"
1043
{ QSET(yyval.blk.q, yyvsp[-1].i, Q_DEFAULT, yyvsp[0].i); }
1044
break;
1045
case 37:
1046
#line 217 "grammar.y"
1047
{ yyval.blk = yyvsp[0].blk; }
1048
break;
1049
case 38:
1050
#line 218 "grammar.y"
1051
{ yyval.blk.b = yyvsp[-1].blk.b; yyval.blk.q = yyvsp[-2].blk.q; }
1052
break;
1053
case 39:
1054
#line 219 "grammar.y"
1055
{ yyval.blk.b = gen_proto_abbrev(yyvsp[0].i); yyval.blk.q = qerr; }
1056
break;
1057
case 40:
1058
#line 220 "grammar.y"
1059
{ yyval.blk.b = gen_relation(yyvsp[-1].i, yyvsp[-2].a, yyvsp[0].a, 0);
1060
				  yyval.blk.q = qerr; }
1061
break;
1062
case 41:
1063
#line 222 "grammar.y"
1064
{ yyval.blk.b = gen_relation(yyvsp[-1].i, yyvsp[-2].a, yyvsp[0].a, 1);
1065
				  yyval.blk.q = qerr; }
1066
break;
1067
case 42:
1068
#line 224 "grammar.y"
1069
{ yyval.blk.b = yyvsp[0].rblk; yyval.blk.q = qerr; }
1070
break;
1071
case 44:
1072
#line 228 "grammar.y"
1073
{ yyval.i = Q_DEFAULT; }
1074
break;
1075
case 45:
1076
#line 231 "grammar.y"
1077
{ yyval.i = Q_SRC; }
1078
break;
1079
case 46:
1080
#line 232 "grammar.y"
1081
{ yyval.i = Q_DST; }
1082
break;
1083
case 47:
1084
#line 233 "grammar.y"
1085
{ yyval.i = Q_OR; }
1086
break;
1087
case 48:
1088
#line 234 "grammar.y"
1089
{ yyval.i = Q_OR; }
1090
break;
1091
case 49:
1092
#line 235 "grammar.y"
1093
{ yyval.i = Q_AND; }
1094
break;
1095
case 50:
1096
#line 236 "grammar.y"
1097
{ yyval.i = Q_AND; }
1098
break;
1099
case 51:
1100
#line 237 "grammar.y"
1101
{ yyval.i = Q_ADDR1; }
1102
break;
1103
case 52:
1104
#line 238 "grammar.y"
1105
{ yyval.i = Q_ADDR2; }
1106
break;
1107
case 53:
1108
#line 239 "grammar.y"
1109
{ yyval.i = Q_ADDR3; }
1110
break;
1111
case 54:
1112
#line 240 "grammar.y"
1113
{ yyval.i = Q_ADDR4; }
1114
break;
1115
case 55:
1116
#line 244 "grammar.y"
1117
{ yyval.i = Q_HOST; }
1118
break;
1119
case 56:
1120
#line 245 "grammar.y"
1121
{ yyval.i = Q_NET; }
1122
break;
1123
case 57:
1124
#line 246 "grammar.y"
1125
{ yyval.i = Q_PORT; }
1126
break;
1127
case 58:
1128
#line 249 "grammar.y"
1129
{ yyval.i = Q_GATEWAY; }
1130
break;
1131
case 59:
1132
#line 251 "grammar.y"
1133
{ yyval.i = Q_LINK; }
1134
break;
1135
case 60:
1136
#line 252 "grammar.y"
1137
{ yyval.i = Q_IP; }
1138
break;
1139
case 61:
1140
#line 253 "grammar.y"
1141
{ yyval.i = Q_ARP; }
1142
break;
1143
case 62:
1144
#line 254 "grammar.y"
1145
{ yyval.i = Q_RARP; }
1146
break;
1147
case 63:
1148
#line 255 "grammar.y"
1149
{ yyval.i = Q_TCP; }
1150
break;
1151
case 64:
1152
#line 256 "grammar.y"
1153
{ yyval.i = Q_UDP; }
1154
break;
1155
case 65:
1156
#line 257 "grammar.y"
1157
{ yyval.i = Q_ICMP; }
1158
break;
1159
case 66:
1160
#line 258 "grammar.y"
1161
{ yyval.i = Q_IGMP; }
1162
break;
1163
case 67:
1164
#line 259 "grammar.y"
1165
{ yyval.i = Q_IGRP; }
1166
break;
1167
case 68:
1168
#line 260 "grammar.y"
1169
{ yyval.i = Q_PIM; }
1170
break;
1171
case 69:
1172
#line 261 "grammar.y"
1173
{ yyval.i = Q_ATALK; }
1174
break;
1175
case 70:
1176
#line 262 "grammar.y"
1177
{ yyval.i = Q_DECNET; }
1178
break;
1179
case 71:
1180
#line 263 "grammar.y"
1181
{ yyval.i = Q_LAT; }
1182
break;
1183
case 72:
1184
#line 264 "grammar.y"
1185
{ yyval.i = Q_SCA; }
1186
break;
1187
case 73:
1188
#line 265 "grammar.y"
1189
{ yyval.i = Q_MOPDL; }
1190
break;
1191
case 74:
1192
#line 266 "grammar.y"
1193
{ yyval.i = Q_MOPRC; }
1194
break;
1195
case 75:
1196
#line 267 "grammar.y"
1197
{ yyval.i = Q_IPV6; }
1198
break;
1199
case 76:
1200
#line 268 "grammar.y"
1201
{ yyval.i = Q_ICMPV6; }
1202
break;
1203
case 77:
1204
#line 269 "grammar.y"
1205
{ yyval.i = Q_AH; }
1206
break;
1207
case 78:
1208
#line 270 "grammar.y"
1209
{ yyval.i = Q_ESP; }
1210
break;
1211
case 79:
1212
#line 271 "grammar.y"
1213
{ yyval.i = Q_STP; }
1214
break;
1215
case 80:
1216
#line 273 "grammar.y"
1217
{ yyval.rblk = gen_broadcast(yyvsp[-1].i); }
1218
break;
1219
case 81:
1220
#line 274 "grammar.y"
1221
{ yyval.rblk = gen_multicast(yyvsp[-1].i); }
1222
break;
1223
case 82:
1224
#line 275 "grammar.y"
1225
{ yyval.rblk = gen_less(yyvsp[0].i); }
1226
break;
1227
case 83:
1228
#line 276 "grammar.y"
1229
{ yyval.rblk = gen_greater(yyvsp[0].i); }
1230
break;
1231
case 84:
1232
#line 277 "grammar.y"
1233
{ yyval.rblk = gen_byteop(yyvsp[-1].i, yyvsp[-2].i, yyvsp[0].i); }
1234
break;
1235
case 85:
1236
#line 278 "grammar.y"
1237
{ yyval.rblk = gen_inbound(0); }
1238
break;
1239
case 86:
1240
#line 279 "grammar.y"
1241
{ yyval.rblk = gen_inbound(1); }
1242
break;
1243
case 87:
1244
#line 280 "grammar.y"
1245
{ yyval.rblk = gen_vlan(yyvsp[0].i); }
1246
break;
1247
case 88:
1248
#line 281 "grammar.y"
1249
{ yyval.rblk = gen_vlan(-1); }
1250
break;
1251
case 89:
1252
#line 282 "grammar.y"
1253
{ yyval.rblk = yyvsp[0].rblk; }
1254
break;
1255
case 90:
1256
#line 283 "grammar.y"
1257
{ yyval.rblk = yyvsp[0].rblk; }
1258
break;
1259
case 91:
1260
#line 286 "grammar.y"
1261
{ yyval.rblk = gen_pf_ifname(yyvsp[0].s); }
1262
break;
1263
case 92:
1264
#line 287 "grammar.y"
1265
{ yyval.rblk = gen_pf_ruleset(yyvsp[0].s); }
1266
break;
1267
case 93:
1268
#line 288 "grammar.y"
1269
{ yyval.rblk = gen_pf_rnr(yyvsp[0].i); }
1270
break;
1271
case 94:
1272
#line 289 "grammar.y"
1273
{ yyval.rblk = gen_pf_srnr(yyvsp[0].i); }
1274
break;
1275
case 95:
1276
#line 290 "grammar.y"
1277
{ yyval.rblk = gen_pf_reason(yyvsp[0].i); }
1278
break;
1279
case 96:
1280
#line 291 "grammar.y"
1281
{ yyval.rblk = gen_pf_action(yyvsp[0].i); }
1282
break;
1283
case 97:
1284
#line 294 "grammar.y"
1285
{ yyval.i = yyvsp[0].i; }
1286
break;
1287
case 98:
1288
#line 295 "grammar.y"
1289
{ const char *reasons[] = PFRES_NAMES;
1290
				  int i;
1291
				  for (i = 0; reasons[i]; i++) {
1292
					  if (strcasecmp(yyvsp[0].s, reasons[i]) == 0) {
1293
						  yyval.i = i;
1294
						  break;
1295
					  }
1296
				  }
1297
				  if (reasons[i] == NULL)
1298
					  bpf_error("unknown PF reason");
1299
				}
1300
break;
1301
case 99:
1302
#line 308 "grammar.y"
1303
{ if (strcasecmp(yyvsp[0].s, "pass") == 0 ||
1304
				      strcasecmp(yyvsp[0].s, "accept") == 0)
1305
					yyval.i = PF_PASS;
1306
				  else if (strcasecmp(yyvsp[0].s, "drop") == 0 ||
1307
				      strcasecmp(yyvsp[0].s, "block") == 0)
1308
					yyval.i = PF_DROP;
1309
				  else if (strcasecmp(yyvsp[0].s, "match") == 0)
1310
					yyval.i = PF_MATCH;
1311
				  else if (strcasecmp(yyvsp[0].s, "rdr") == 0)
1312
				  	yyval.i = PF_RDR;
1313
				  else if (strcasecmp(yyvsp[0].s, "nat") == 0)
1314
				  	yyval.i = PF_NAT;
1315
				  else if (strcasecmp(yyvsp[0].s, "binat") == 0)
1316
				  	yyval.i = PF_BINAT;
1317
				  else if (strcasecmp(yyvsp[0].s, "scrub") == 0)
1318
				  	yyval.i = PF_SCRUB;
1319
				  else
1320
					  bpf_error("unknown PF action");
1321
				}
1322
break;
1323
case 100:
1324
#line 330 "grammar.y"
1325
{ yyval.rblk = gen_p80211_type(yyvsp[-2].i | yyvsp[0].i,
1326
					IEEE80211_FC0_TYPE_MASK |
1327
					IEEE80211_FC0_SUBTYPE_MASK);
1328
				}
1329
break;
1330
case 101:
1331
#line 334 "grammar.y"
1332
{ yyval.rblk = gen_p80211_type(yyvsp[0].i,
1333
					IEEE80211_FC0_TYPE_MASK); }
1334
break;
1335
case 102:
1336
#line 336 "grammar.y"
1337
{ yyval.rblk = gen_p80211_type(yyvsp[0].i,
1338
					IEEE80211_FC0_SUBTYPE_MASK); }
1339
break;
1340
case 103:
1341
#line 338 "grammar.y"
1342
{ yyval.rblk = gen_p80211_fcdir(yyvsp[0].i); }
1343
break;
1344
case 105:
1345
#line 342 "grammar.y"
1346
{ if (strcasecmp(yyvsp[0].s, "data") == 0)
1347
					yyval.i = IEEE80211_FC0_TYPE_DATA;
1348
				  else if (strcasecmp(yyvsp[0].s, "mgt") == 0 ||
1349
					strcasecmp(yyvsp[0].s, "management") == 0)
1350
					yyval.i = IEEE80211_FC0_TYPE_MGT;
1351
				  else if (strcasecmp(yyvsp[0].s, "ctl") == 0 ||
1352
					strcasecmp(yyvsp[0].s, "control") == 0)
1353
					yyval.i = IEEE80211_FC0_TYPE_CTL;
1354
				  else
1355
					  bpf_error("unknown 802.11 type");
1356
				}
1357
break;
1358
case 107:
1359
#line 356 "grammar.y"
1360
{ if (strcasecmp(yyvsp[0].s, "assocreq") == 0)
1361
					yyval.i = IEEE80211_FC0_SUBTYPE_ASSOC_REQ;
1362
				  else if (strcasecmp(yyvsp[0].s, "assocresp") == 0)
1363
					yyval.i = IEEE80211_FC0_SUBTYPE_ASSOC_RESP;
1364
				  else if (strcasecmp(yyvsp[0].s, "reassocreq") == 0)
1365
					yyval.i = IEEE80211_FC0_SUBTYPE_REASSOC_REQ;
1366
				  else if (strcasecmp(yyvsp[0].s, "reassocresp") == 0)
1367
					yyval.i = IEEE80211_FC0_SUBTYPE_REASSOC_RESP;
1368
				  else if (strcasecmp(yyvsp[0].s, "probereq") == 0)
1369
					yyval.i = IEEE80211_FC0_SUBTYPE_PROBE_REQ;
1370
				  else if (strcasecmp(yyvsp[0].s, "proberesp") == 0)
1371
					yyval.i = IEEE80211_FC0_SUBTYPE_PROBE_RESP;
1372
				  else if (strcasecmp(yyvsp[0].s, "beacon") == 0)
1373
					yyval.i = IEEE80211_FC0_SUBTYPE_BEACON;
1374
				  else if (strcasecmp(yyvsp[0].s, "atim") == 0)
1375
					yyval.i = IEEE80211_FC0_SUBTYPE_ATIM;
1376
				  else if (strcasecmp(yyvsp[0].s, "disassoc") == 0 ||
1377
				      strcasecmp(yyvsp[0].s, "disassociation") == 0)
1378
					yyval.i = IEEE80211_FC0_SUBTYPE_DISASSOC;
1379
				  else if (strcasecmp(yyvsp[0].s, "auth") == 0 ||
1380
				      strcasecmp(yyvsp[0].s, "authentication") == 0)
1381
					yyval.i = IEEE80211_FC0_SUBTYPE_AUTH;
1382
				  else if (strcasecmp(yyvsp[0].s, "deauth") == 0 ||
1383
				      strcasecmp(yyvsp[0].s, "deauthentication") == 0)
1384
					yyval.i = IEEE80211_FC0_SUBTYPE_DEAUTH;
1385
				  else if (strcasecmp(yyvsp[0].s, "data") == 0)
1386
					yyval.i = IEEE80211_FC0_SUBTYPE_DATA;
1387
				  else
1388
					  bpf_error("unknown 802.11 subtype");
1389
				}
1390
break;
1391
case 109:
1392
#line 389 "grammar.y"
1393
{ if (strcasecmp(yyvsp[0].s, "nods") == 0)
1394
					yyval.i = IEEE80211_FC1_DIR_NODS;
1395
				  else if (strcasecmp(yyvsp[0].s, "tods") == 0)
1396
					yyval.i = IEEE80211_FC1_DIR_TODS;
1397
				  else if (strcasecmp(yyvsp[0].s, "fromds") == 0)
1398
					yyval.i = IEEE80211_FC1_DIR_FROMDS;
1399
				  else if (strcasecmp(yyvsp[0].s, "dstods") == 0)
1400
					yyval.i = IEEE80211_FC1_DIR_DSTODS;
1401
				  else
1402
					bpf_error("unknown 802.11 direction");
1403
				}
1404
break;
1405
case 110:
1406
#line 402 "grammar.y"
1407
{ yyval.i = BPF_JGT; }
1408
break;
1409
case 111:
1410
#line 403 "grammar.y"
1411
{ yyval.i = BPF_JGE; }
1412
break;
1413
case 112:
1414
#line 404 "grammar.y"
1415
{ yyval.i = BPF_JEQ; }
1416
break;
1417
case 113:
1418
#line 406 "grammar.y"
1419
{ yyval.i = BPF_JGT; }
1420
break;
1421
case 114:
1422
#line 407 "grammar.y"
1423
{ yyval.i = BPF_JGE; }
1424
break;
1425
case 115:
1426
#line 408 "grammar.y"
1427
{ yyval.i = BPF_JEQ; }
1428
break;
1429
case 116:
1430
#line 410 "grammar.y"
1431
{ yyval.a = gen_loadi(yyvsp[0].i); }
1432
break;
1433
case 118:
1434
#line 413 "grammar.y"
1435
{ yyval.a = gen_load(yyvsp[-3].i, yyvsp[-1].a, 1); }
1436
break;
1437
case 119:
1438
#line 414 "grammar.y"
1439
{ yyval.a = gen_load(yyvsp[-5].i, yyvsp[-3].a, yyvsp[-1].i); }
1440
break;
1441
case 120:
1442
#line 415 "grammar.y"
1443
{ yyval.a = gen_arth(BPF_ADD, yyvsp[-2].a, yyvsp[0].a); }
1444
break;
1445
case 121:
1446
#line 416 "grammar.y"
1447
{ yyval.a = gen_arth(BPF_SUB, yyvsp[-2].a, yyvsp[0].a); }
1448
break;
1449
case 122:
1450
#line 417 "grammar.y"
1451
{ yyval.a = gen_arth(BPF_MUL, yyvsp[-2].a, yyvsp[0].a); }
1452
break;
1453
case 123:
1454
#line 418 "grammar.y"
1455
{ yyval.a = gen_arth(BPF_DIV, yyvsp[-2].a, yyvsp[0].a); }
1456
break;
1457
case 124:
1458
#line 419 "grammar.y"
1459
{ yyval.a = gen_arth(BPF_AND, yyvsp[-2].a, yyvsp[0].a); }
1460
break;
1461
case 125:
1462
#line 420 "grammar.y"
1463
{ yyval.a = gen_arth(BPF_OR, yyvsp[-2].a, yyvsp[0].a); }
1464
break;
1465
case 126:
1466
#line 421 "grammar.y"
1467
{ yyval.a = gen_arth(BPF_LSH, yyvsp[-2].a, yyvsp[0].a); }
1468
break;
1469
case 127:
1470
#line 422 "grammar.y"
1471
{ yyval.a = gen_arth(BPF_RSH, yyvsp[-2].a, yyvsp[0].a); }
1472
break;
1473
case 128:
1474
#line 423 "grammar.y"
1475
{ yyval.a = gen_neg(yyvsp[0].a); }
1476
break;
1477
case 129:
1478
#line 424 "grammar.y"
1479
{ yyval.a = yyvsp[-1].a; }
1480
break;
1481
case 130:
1482
#line 425 "grammar.y"
1483
{ yyval.a = gen_loadlen(); }
1484
break;
1485
case 131:
1486
#line 427 "grammar.y"
1487
{ yyval.i = '&'; }
1488
break;
1489
case 132:
1490
#line 428 "grammar.y"
1491
{ yyval.i = '|'; }
1492
break;
1493
case 133:
1494
#line 429 "grammar.y"
1495
{ yyval.i = '<'; }
1496
break;
1497
case 134:
1498
#line 430 "grammar.y"
1499
{ yyval.i = '>'; }
1500
break;
1501
case 135:
1502
#line 431 "grammar.y"
1503
54
{ yyval.i = '='; }
1504
54
break;
1505
54
case 137:
1506
54
#line 434 "grammar.y"
1507
54
{ yyval.i = yyvsp[-1].i; }
1508
break;
1509
#line 1502 "grammar.c"
1510
    }
1511
    yyssp -= yym;
1512
    yystate = *yyssp;
1513
    yyvsp -= yym;
1514
    yym = yylhs[yyn];
1515
3
    if (yystate == 0 && yym == 0)
1516
3
    {
1517
3
#if YYDEBUG
1518
        if (yydebug)
1519
            printf("%sdebug: after reduction, shifting from state 0 to\
1520
 state %d\n", YYPREFIX, YYFINAL);
1521
#endif
1522
        yystate = YYFINAL;
1523
        *++yyssp = YYFINAL;
1524
        *++yyvsp = yyval;
1525
        if (yychar < 0)
1526
        {
1527
            if ((yychar = yylex()) < 0) yychar = 0;
1528
#if YYDEBUG
1529
            if (yydebug)
1530
            {
1531
3
                yys = 0;
1532
                if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1533
                if (!yys) yys = "illegal-symbol";
1534

165
                printf("%sdebug: state %d, reading %d (%s)\n",
1535
75
                        YYPREFIX, YYFINAL, yychar, yys);
1536
21
            }
1537
#endif
1538
30
        }
1539
        if (yychar == 0) goto yyaccept;
1540
        goto yyloop;
1541
    }
1542
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1543
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1544

51
        yystate = yytable[yyn];
1545
    else
1546
        yystate = yydgoto[yym];
1547
#if YYDEBUG
1548
51
    if (yydebug)
1549
51
        printf("%sdebug: after reduction, shifting from state %d \
1550
51
to state %d\n", YYPREFIX, *yyssp, yystate);
1551
#endif
1552
    if (yyssp >= yysslim && yygrowstack())
1553
    {
1554
        goto yyoverflow;
1555
    }
1556
    *++yyssp = yystate;
1557
    *++yyvsp = yyval;
1558
    goto yyloop;
1559
yyoverflow:
1560
    yyerror("yacc stack overflow");
1561
yyabort:
1562
    if (yyss)
1563
3
            free(yyss);
1564
3
    if (yyvs)
1565
3
            free(yyvs);
1566
3
    yyss = yyssp = NULL;
1567
3
    yyvs = yyvsp = NULL;
1568
3
    yystacksize = 0;
1569
3
    return (1);
1570
3
yyaccept:
1571
3
    if (yyss)
1572
            free(yyss);
1573
    if (yyvs)
1574
            free(yyvs);
1575
    yyss = yyssp = NULL;
1576
    yyvs = yyvsp = NULL;
1577
    yystacksize = 0;
1578
    return (0);
1579
}