libnl: /data/src/libnl3/lib/route/cls/ematch_syntax.c Source File

libnl 3.7.0

ematch_syntax.c
1 /* A Bison parser, made by GNU Bison 3.8.2. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48 /* Identify Bison output, and Bison version. */
49 #define YYBISON 30802
50
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.8.2"
53
54 /* Skeleton name. */
55 #define YYSKELETON_NAME "yacc.c"
56
57 /* Pure parsers. */
58 #define YYPURE 1
59
60 /* Push parsers. */
61 #define YYPUSH 0
62
63 /* Pull parsers. */
64 #define YYPULL 1
65
66
67 /* Substitute the variable and function names. */
68 #define yyparse ematch_parse
69 #define yylex ematch_lex
70 #define yyerror ematch_error
71 #define yydebug ematch_debug
72 #define yynerrs ematch_nerrs
73
74 /* First part of user prologue. */
75 #line 6 "lib/route/cls/ematch_syntax.y"
76
77 #include <netlink-private/netlink.h>
78 #include <netlink-private/tc.h>
79 #include <netlink/netlink.h>
80 #include <netlink/utils.h>
81 #include <netlink/route/pktloc.h>
82 #include <netlink/route/cls/ematch.h>
83 #include <netlink/route/cls/ematch/cmp.h>
84 #include <netlink/route/cls/ematch/nbyte.h>
85 #include <netlink/route/cls/ematch/text.h>
86 #include <netlink/route/cls/ematch/meta.h>
87 #include <linux/tc_ematch/tc_em_meta.h>
88 #include <linux/tc_ematch/tc_em_cmp.h>
89
90 #define META_ALLOC rtnl_meta_value_alloc_id
91 #define META_ID(name) TCF_META_ID_##name
92 #define META_INT TCF_META_TYPE_INT
93 #define META_VAR TCF_META_TYPE_VAR
94
95 #line 96 "lib/route/cls/ematch_syntax.c"
96
97 # ifndef YY_CAST
98 # ifdef __cplusplus
99 # define YY_CAST(Type, Val) static_cast<Type> (Val)
100 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
101 # else
102 # define YY_CAST(Type, Val) ((Type) (Val))
103 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
104 # endif
105 # endif
106 # ifndef YY_NULLPTR
107 # if defined __cplusplus
108 # if 201103L <= __cplusplus
109 # define YY_NULLPTR nullptr
110 # else
111 # define YY_NULLPTR 0
112 # endif
113 # else
114 # define YY_NULLPTR ((void*)0)
115 # endif
116 # endif
117
118 #include "ematch_syntax.h"
119 /* Symbol kind. */
120 enum yysymbol_kind_t
121 {
122 YYSYMBOL_YYEMPTY = -2,
123 YYSYMBOL_YYEOF = 0, /* "end of file" */
124 YYSYMBOL_YYerror = 1, /* error */
125 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
126 YYSYMBOL_ERROR = 3, /* ERROR */
127 YYSYMBOL_LOGIC = 4, /* LOGIC */
128 YYSYMBOL_NOT = 5, /* NOT */
129 YYSYMBOL_OPERAND = 6, /* OPERAND */
130 YYSYMBOL_NUMBER = 7, /* NUMBER */
131 YYSYMBOL_ALIGN = 8, /* ALIGN */
132 YYSYMBOL_LAYER = 9, /* LAYER */
133 YYSYMBOL_KW_OPEN = 10, /* "(" */
134 YYSYMBOL_KW_CLOSE = 11, /* ")" */
135 YYSYMBOL_KW_PLUS = 12, /* "+" */
136 YYSYMBOL_KW_MASK = 13, /* "mask" */
137 YYSYMBOL_KW_SHIFT = 14, /* ">>" */
138 YYSYMBOL_KW_AT = 15, /* "at" */
139 YYSYMBOL_EMATCH_CMP = 16, /* "cmp" */
140 YYSYMBOL_EMATCH_NBYTE = 17, /* "pattern" */
141 YYSYMBOL_EMATCH_TEXT = 18, /* "text" */
142 YYSYMBOL_EMATCH_META = 19, /* "meta" */
143 YYSYMBOL_KW_EQ = 20, /* "=" */
144 YYSYMBOL_KW_GT = 21, /* ">" */
145 YYSYMBOL_KW_LT = 22, /* "<" */
146 YYSYMBOL_KW_FROM = 23, /* "from" */
147 YYSYMBOL_KW_TO = 24, /* "to" */
148 YYSYMBOL_META_RANDOM = 25, /* "random" */
149 YYSYMBOL_META_LOADAVG_0 = 26, /* "loadavg_0" */
150 YYSYMBOL_META_LOADAVG_1 = 27, /* "loadavg_1" */
151 YYSYMBOL_META_LOADAVG_2 = 28, /* "loadavg_2" */
152 YYSYMBOL_META_DEV = 29, /* "dev" */
153 YYSYMBOL_META_PRIO = 30, /* "prio" */
154 YYSYMBOL_META_PROTO = 31, /* "proto" */
155 YYSYMBOL_META_PKTTYPE = 32, /* "pkttype" */
156 YYSYMBOL_META_PKTLEN = 33, /* "pktlen" */
157 YYSYMBOL_META_DATALEN = 34, /* "datalen" */
158 YYSYMBOL_META_MACLEN = 35, /* "maclen" */
159 YYSYMBOL_META_MARK = 36, /* "mark" */
160 YYSYMBOL_META_TCINDEX = 37, /* "tcindex" */
161 YYSYMBOL_META_RTCLASSID = 38, /* "rtclassid" */
162 YYSYMBOL_META_RTIIF = 39, /* "rtiif" */
163 YYSYMBOL_META_SK_FAMILY = 40, /* "sk_family" */
164 YYSYMBOL_META_SK_STATE = 41, /* "sk_state" */
165 YYSYMBOL_META_SK_REUSE = 42, /* "sk_reuse" */
166 YYSYMBOL_META_SK_REFCNT = 43, /* "sk_refcnt" */
167 YYSYMBOL_META_SK_RCVBUF = 44, /* "sk_rcvbuf" */
168 YYSYMBOL_META_SK_SNDBUF = 45, /* "sk_sndbuf" */
169 YYSYMBOL_META_SK_SHUTDOWN = 46, /* "sk_shutdown" */
170 YYSYMBOL_META_SK_PROTO = 47, /* "sk_proto" */
171 YYSYMBOL_META_SK_TYPE = 48, /* "sk_type" */
172 YYSYMBOL_META_SK_RMEM_ALLOC = 49, /* "sk_rmem_alloc" */
173 YYSYMBOL_META_SK_WMEM_ALLOC = 50, /* "sk_wmem_alloc" */
174 YYSYMBOL_META_SK_WMEM_QUEUED = 51, /* "sk_wmem_queued" */
175 YYSYMBOL_META_SK_RCV_QLEN = 52, /* "sk_rcv_qlen" */
176 YYSYMBOL_META_SK_SND_QLEN = 53, /* "sk_snd_qlen" */
177 YYSYMBOL_META_SK_ERR_QLEN = 54, /* "sk_err_qlen" */
178 YYSYMBOL_META_SK_FORWARD_ALLOCS = 55, /* "sk_forward_allocs" */
179 YYSYMBOL_META_SK_ALLOCS = 56, /* "sk_allocs" */
180 YYSYMBOL_META_SK_ROUTE_CAPS = 57, /* "sk_route_caps" */
181 YYSYMBOL_META_SK_HASH = 58, /* "sk_hash" */
182 YYSYMBOL_META_SK_LINGERTIME = 59, /* "sk_lingertime" */
183 YYSYMBOL_META_SK_ACK_BACKLOG = 60, /* "sk_ack_backlog" */
184 YYSYMBOL_META_SK_MAX_ACK_BACKLOG = 61, /* "sk_max_ack_backlog" */
185 YYSYMBOL_META_SK_PRIO = 62, /* "sk_prio" */
186 YYSYMBOL_META_SK_RCVLOWAT = 63, /* "sk_rcvlowat" */
187 YYSYMBOL_META_SK_RCVTIMEO = 64, /* "sk_rcvtimeo" */
188 YYSYMBOL_META_SK_SNDTIMEO = 65, /* "sk_sndtimeo" */
189 YYSYMBOL_META_SK_SENDMSG_OFF = 66, /* "sk_sendmsg_off" */
190 YYSYMBOL_META_SK_WRITE_PENDING = 67, /* "sk_write_pending" */
191 YYSYMBOL_META_VLAN = 68, /* "vlan" */
192 YYSYMBOL_META_RXHASH = 69, /* "rxhash" */
193 YYSYMBOL_META_DEVNAME = 70, /* "devname" */
194 YYSYMBOL_META_SK_BOUND_IF = 71, /* "sk_bound_if" */
195 YYSYMBOL_STR = 72, /* STR */
196 YYSYMBOL_QUOTED = 73, /* QUOTED */
197 YYSYMBOL_YYACCEPT = 74, /* $accept */
198 YYSYMBOL_input = 75, /* input */
199 YYSYMBOL_expr = 76, /* expr */
200 YYSYMBOL_match = 77, /* match */
201 YYSYMBOL_ematch = 78, /* ematch */
202 YYSYMBOL_cmp_match = 79, /* cmp_match */
203 YYSYMBOL_cmp_expr = 80, /* cmp_expr */
204 YYSYMBOL_text_from = 81, /* text_from */
205 YYSYMBOL_text_to = 82, /* text_to */
206 YYSYMBOL_meta_value = 83, /* meta_value */
207 YYSYMBOL_meta_int_id = 84, /* meta_int_id */
208 YYSYMBOL_meta_var_id = 85, /* meta_var_id */
209 YYSYMBOL_pattern = 86, /* pattern */
210 YYSYMBOL_pktloc = 87, /* pktloc */
211 YYSYMBOL_align = 88, /* align */
212 YYSYMBOL_mask = 89, /* mask */
213 YYSYMBOL_shift = 90, /* shift */
214 YYSYMBOL_operand = 91 /* operand */
215 };
216 typedef enum yysymbol_kind_t yysymbol_kind_t;
217
218
219 /* Second part of user prologue. */
220 #line 46 "lib/route/cls/ematch_syntax.y"
221
222 extern int ematch_lex(YYSTYPE *, void *);
223
224 #define ematch_error yyerror
225 static void yyerror(void *scanner, char **errp, struct nl_list_head *root, const char *msg)
226 {
227 if (msg)
228 *errp = strdup(msg);
229 else
230 *errp = NULL;
231 }
232
233 #line 234 "lib/route/cls/ematch_syntax.c"
234
235
236 #ifdef short
237 # undef short
238 #endif
239
240 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
241 <limits.h> and (if available) <stdint.h> are included
242 so that the code can choose integer types of a good width. */
243
244 #ifndef __PTRDIFF_MAX__
245 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
246 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
247 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
248 # define YY_STDINT_H
249 # endif
250 #endif
251
252 /* Narrow types that promote to a signed type and that can represent a
253 signed or unsigned integer of at least N bits. In tables they can
254 save space and decrease cache pressure. Promoting to a signed type
255 helps avoid bugs in integer arithmetic. */
256
257 #ifdef __INT_LEAST8_MAX__
258 typedef __INT_LEAST8_TYPE__ yytype_int8;
259 #elif defined YY_STDINT_H
260 typedef int_least8_t yytype_int8;
261 #else
262 typedef signed char yytype_int8;
263 #endif
264
265 #ifdef __INT_LEAST16_MAX__
266 typedef __INT_LEAST16_TYPE__ yytype_int16;
267 #elif defined YY_STDINT_H
268 typedef int_least16_t yytype_int16;
269 #else
270 typedef short yytype_int16;
271 #endif
272
273 /* Work around bug in HP-UX 11.23, which defines these macros
274 incorrectly for preprocessor constants. This workaround can likely
275 be removed in 2023, as HPE has promised support for HP-UX 11.23
276 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
277 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
278 #ifdef __hpux
279 # undef UINT_LEAST8_MAX
280 # undef UINT_LEAST16_MAX
281 # define UINT_LEAST8_MAX 255
282 # define UINT_LEAST16_MAX 65535
283 #endif
284
285 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
286 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
287 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
288 && UINT_LEAST8_MAX <= INT_MAX)
289 typedef uint_least8_t yytype_uint8;
290 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
291 typedef unsigned char yytype_uint8;
292 #else
293 typedef short yytype_uint8;
294 #endif
295
296 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
297 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
298 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
299 && UINT_LEAST16_MAX <= INT_MAX)
300 typedef uint_least16_t yytype_uint16;
301 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
302 typedef unsigned short yytype_uint16;
303 #else
304 typedef int yytype_uint16;
305 #endif
306
307 #ifndef YYPTRDIFF_T
308 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
309 # define YYPTRDIFF_T __PTRDIFF_TYPE__
310 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
311 # elif defined PTRDIFF_MAX
312 # ifndef ptrdiff_t
313 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
314 # endif
315 # define YYPTRDIFF_T ptrdiff_t
316 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
317 # else
318 # define YYPTRDIFF_T long
319 # define YYPTRDIFF_MAXIMUM LONG_MAX
320 # endif
321 #endif
322
323 #ifndef YYSIZE_T
324 # ifdef __SIZE_TYPE__
325 # define YYSIZE_T __SIZE_TYPE__
326 # elif defined size_t
327 # define YYSIZE_T size_t
328 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
329 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
330 # define YYSIZE_T size_t
331 # else
332 # define YYSIZE_T unsigned
333 # endif
334 #endif
335
336 #define YYSIZE_MAXIMUM \
337 YY_CAST (YYPTRDIFF_T, \
338 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
339 ? YYPTRDIFF_MAXIMUM \
340 : YY_CAST (YYSIZE_T, -1)))
341
342 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
343
344
345 /* Stored state numbers (used for stacks). */
346 typedef yytype_int8 yy_state_t;
347
348 /* State numbers in computations. */
349 typedef int yy_state_fast_t;
350
351 #ifndef YY_
352 # if defined YYENABLE_NLS && YYENABLE_NLS
353 # if ENABLE_NLS
354 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
355 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
356 # endif
357 # endif
358 # ifndef YY_
359 # define YY_(Msgid) Msgid
360 # endif
361 #endif
362
363
364 #ifndef YY_ATTRIBUTE_PURE
365 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
366 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
367 # else
368 # define YY_ATTRIBUTE_PURE
369 # endif
370 #endif
371
372 #ifndef YY_ATTRIBUTE_UNUSED
373 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
374 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
375 # else
376 # define YY_ATTRIBUTE_UNUSED
377 # endif
378 #endif
379
380 /* Suppress unused-variable warnings by "using" E. */
381 #if ! defined lint || defined __GNUC__
382 # define YY_USE(E) ((void) (E))
383 #else
384 # define YY_USE(E) /* empty */
385 #endif
386
387 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
388 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
389 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
390 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
391 _Pragma ("GCC diagnostic push") \
392 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
393 # else
394 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
395 _Pragma ("GCC diagnostic push") \
396 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
397 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
398 # endif
399 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
400 _Pragma ("GCC diagnostic pop")
401 #else
402 # define YY_INITIAL_VALUE(Value) Value
403 #endif
404 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
405 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
406 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
407 #endif
408 #ifndef YY_INITIAL_VALUE
409 # define YY_INITIAL_VALUE(Value) /* Nothing. */
410 #endif
411
412 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
413 # define YY_IGNORE_USELESS_CAST_BEGIN \
414 _Pragma ("GCC diagnostic push") \
415 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
416 # define YY_IGNORE_USELESS_CAST_END \
417 _Pragma ("GCC diagnostic pop")
418 #endif
419 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
420 # define YY_IGNORE_USELESS_CAST_BEGIN
421 # define YY_IGNORE_USELESS_CAST_END
422 #endif
423
424
425 #define YY_ASSERT(E) ((void) (0 && (E)))
426
427 #if 1
428
429 /* The parser invokes alloca or malloc; define the necessary symbols. */
430
431 # ifdef YYSTACK_USE_ALLOCA
432 # if YYSTACK_USE_ALLOCA
433 # ifdef __GNUC__
434 # define YYSTACK_ALLOC __builtin_alloca
435 # elif defined __BUILTIN_VA_ARG_INCR
436 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
437 # elif defined _AIX
438 # define YYSTACK_ALLOC __alloca
439 # elif defined _MSC_VER
440 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
441 # define alloca _alloca
442 # else
443 # define YYSTACK_ALLOC alloca
444 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
445 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
446 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
447 # ifndef EXIT_SUCCESS
448 # define EXIT_SUCCESS 0
449 # endif
450 # endif
451 # endif
452 # endif
453 # endif
454
455 # ifdef YYSTACK_ALLOC
456 /* Pacify GCC's 'empty if-body' warning. */
457 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
458 # ifndef YYSTACK_ALLOC_MAXIMUM
459 /* The OS might guarantee only one guard page at the bottom of the stack,
460 and a page size can be as small as 4096 bytes. So we cannot safely
461 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
462 to allow for a few compiler-allocated temporary stack slots. */
463 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
464 # endif
465 # else
466 # define YYSTACK_ALLOC YYMALLOC
467 # define YYSTACK_FREE YYFREE
468 # ifndef YYSTACK_ALLOC_MAXIMUM
469 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
470 # endif
471 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
472 && ! ((defined YYMALLOC || defined malloc) \
473 && (defined YYFREE || defined free)))
474 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
475 # ifndef EXIT_SUCCESS
476 # define EXIT_SUCCESS 0
477 # endif
478 # endif
479 # ifndef YYMALLOC
480 # define YYMALLOC malloc
481 # if ! defined malloc && ! defined EXIT_SUCCESS
482 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
483 # endif
484 # endif
485 # ifndef YYFREE
486 # define YYFREE free
487 # if ! defined free && ! defined EXIT_SUCCESS
488 void free (void *); /* INFRINGES ON USER NAME SPACE */
489 # endif
490 # endif
491 # endif
492 #endif /* 1 */
493
494 #if (! defined yyoverflow \
495 && (! defined __cplusplus \
496 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
497
498 /* A type that is properly aligned for any stack member. */
499 union yyalloc
500 {
501 yy_state_t yyss_alloc;
502 YYSTYPE yyvs_alloc;
503 };
504
505 /* The size of the maximum gap between one aligned stack and the next. */
506 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
507
508 /* The size of an array large to enough to hold all stacks, each with
509 N elements. */
510 # define YYSTACK_BYTES(N) \
511 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
512 + YYSTACK_GAP_MAXIMUM)
513
514 # define YYCOPY_NEEDED 1
515
516 /* Relocate STACK from its old location to the new one. The
517 local variables YYSIZE and YYSTACKSIZE give the old and new number of
518 elements in the stack, and YYPTR gives the new location of the
519 stack. Advance YYPTR to a properly aligned location for the next
520 stack. */
521 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
522 do \
523 { \
524 YYPTRDIFF_T yynewbytes; \
525 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
526 Stack = &yyptr->Stack_alloc; \
527 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
528 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
529 } \
530 while (0)
531
532 #endif
533
534 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
535 /* Copy COUNT objects from SRC to DST. The source and destination do
536 not overlap. */
537 # ifndef YYCOPY
538 # if defined __GNUC__ && 1 < __GNUC__
539 # define YYCOPY(Dst, Src, Count) \
540 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
541 # else
542 # define YYCOPY(Dst, Src, Count) \
543 do \
544 { \
545 YYPTRDIFF_T yyi; \
546 for (yyi = 0; yyi < (Count); yyi++) \
547 (Dst)[yyi] = (Src)[yyi]; \
548 } \
549 while (0)
550 # endif
551 # endif
552 #endif /* !YYCOPY_NEEDED */
553
554 /* YYFINAL -- State number of the termination state. */
555 #define YYFINAL 26
556 /* YYLAST -- Last index in YYTABLE. */
557 #define YYLAST 138
558
559 /* YYNTOKENS -- Number of terminals. */
560 #define YYNTOKENS 74
561 /* YYNNTS -- Number of nonterminals. */
562 #define YYNNTS 18
563 /* YYNRULES -- Number of rules. */
564 #define YYNRULES 84
565 /* YYNSTATES -- Number of states. */
566 #define YYNSTATES 118
567
568 /* YYMAXUTOK -- Last valid token kind. */
569 #define YYMAXUTOK 328
570
571
572 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
573 as returned by yylex, with out-of-bounds checking. */
574 #define YYTRANSLATE(YYX) \
575 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
576 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
577 : YYSYMBOL_YYUNDEF)
578
579 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
580 as returned by yylex. */
581 static const yytype_int8 yytranslate[] =
582 {
583 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
588 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
591 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
594 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
609 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
610 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
611 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
612 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
613 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
614 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
615 65, 66, 67, 68, 69, 70, 71, 72, 73
616 };
617
618 #if YYDEBUG
619 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
620 static const yytype_int16 yyrline[] =
621 {
622 0, 145, 145, 147, 154, 158, 170, 175, 183, 198,
623 216, 243, 262, 290, 292, 297, 318, 319, 325, 326,
624 331, 333, 335, 337, 342, 343, 344, 345, 346, 347,
625 348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
626 358, 359, 360, 361, 362, 363, 364, 365, 366, 367,
627 368, 369, 370, 371, 372, 373, 374, 375, 376, 377,
628 378, 379, 380, 381, 382, 383, 384, 385, 386, 390,
629 391, 398, 402, 431, 444, 470, 471, 473, 479, 480,
630 486, 487, 492, 494, 496
631 };
632 #endif
633
634 /** Accessing symbol of state STATE. */
635 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
636
637 #if 1
638 /* The user-facing name of the symbol whose (internal) number is
639 YYSYMBOL. No bounds checking. */
640 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
641
642 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
643 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
644 static const char *const yytname[] =
645 {
646 "\"end of file\"", "error", "\"invalid token\"", "ERROR", "LOGIC",
647 "NOT", "OPERAND", "NUMBER", "ALIGN", "LAYER", "\"(\"", "\")\"", "\"+\"",
648 "\"mask\"", "\">>\"", "\"at\"", "\"cmp\"", "\"pattern\"", "\"text\"",
649 "\"meta\"", "\"=\"", "\">\"", "\"<\"", "\"from\"", "\"to\"",
650 "\"random\"", "\"loadavg_0\"", "\"loadavg_1\"", "\"loadavg_2\"",
651 "\"dev\"", "\"prio\"", "\"proto\"", "\"pkttype\"", "\"pktlen\"",
652 "\"datalen\"", "\"maclen\"", "\"mark\"", "\"tcindex\"", "\"rtclassid\"",
653 "\"rtiif\"", "\"sk_family\"", "\"sk_state\"", "\"sk_reuse\"",
654 "\"sk_refcnt\"", "\"sk_rcvbuf\"", "\"sk_sndbuf\"", "\"sk_shutdown\"",
655 "\"sk_proto\"", "\"sk_type\"", "\"sk_rmem_alloc\"", "\"sk_wmem_alloc\"",
656 "\"sk_wmem_queued\"", "\"sk_rcv_qlen\"", "\"sk_snd_qlen\"",
657 "\"sk_err_qlen\"", "\"sk_forward_allocs\"", "\"sk_allocs\"",
658 "\"sk_route_caps\"", "\"sk_hash\"", "\"sk_lingertime\"",
659 "\"sk_ack_backlog\"", "\"sk_max_ack_backlog\"", "\"sk_prio\"",
660 "\"sk_rcvlowat\"", "\"sk_rcvtimeo\"", "\"sk_sndtimeo\"",
661 "\"sk_sendmsg_off\"", "\"sk_write_pending\"", "\"vlan\"", "\"rxhash\"",
662 "\"devname\"", "\"sk_bound_if\"", "STR", "QUOTED", "$accept", "input",
663 "expr", "match", "ematch", "cmp_match", "cmp_expr", "text_from",
664 "text_to", "meta_value", "meta_int_id", "meta_var_id", "pattern",
665 "pktloc", "align", "mask", "shift", "operand", YY_NULLPTR
666 };
667
668 static const char *
669 yysymbol_name (yysymbol_kind_t yysymbol)
670 {
671 return yytname[yysymbol];
672 }
673 #endif
674
675 #define YYPACT_NINF (-63)
676
677 #define yypact_value_is_default(Yyn) \
678 ((Yyn) == YYPACT_NINF)
679
680 #define YYTABLE_NINF (-76)
681
682 #define yytable_value_is_error(Yyn) \
683 0
684
685 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
686 STATE-NUM. */
687 static const yytype_int8 yypact[] =
688 {
689 -4, 15, -13, -8, 11, 10, 14, 25, 29, -63,
690 26, -63, 37, -63, -63, -63, 16, 33, -63, -63,
691 -63, 32, 1, 1, -28, 65, -63, 11, -63, -63,
692 -63, 38, 34, -63, 36, 28, -24, -63, -63, -63,
693 -63, -63, -63, -63, -63, -63, -63, -63, -63, -63,
694 -63, -63, -63, -63, -63, -63, -63, -63, -63, -63,
695 -63, -63, -63, -63, -63, -63, -63, -63, -63, -63,
696 -63, -63, -63, -63, -63, -63, -63, -63, -63, -63,
697 -63, -63, -63, -63, -63, -63, 16, 39, 39, -63,
698 -63, 43, -63, -62, 31, 65, 44, 42, -63, 42,
699 -63, -63, 41, 1, 35, 45, -63, 50, -63, -63,
700 -63, -63, 1, 47, -63, -63, -63, -63
701 };
702
703 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
704 Performed when YYTABLE does not specify something else to do. Zero
705 means the default is an error. */
706 static const yytype_int8 yydefact[] =
707 {
708 2, 75, 0, 0, 75, 0, 0, 0, 0, 73,
709 0, 3, 4, 7, 8, 14, 0, 0, 6, 77,
710 76, 0, 75, 75, 0, 0, 1, 75, 82, 83,
711 84, 0, 0, 12, 0, 0, 0, 21, 24, 25,
712 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
713 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
714 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
715 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
716 66, 67, 68, 69, 70, 20, 0, 80, 80, 5,
717 15, 0, 13, 0, 16, 0, 0, 78, 23, 78,
718 72, 71, 0, 75, 18, 0, 81, 0, 22, 74,
719 9, 17, 75, 0, 11, 79, 19, 10
720 };
721
722 /* YYPGOTO[NTERM-NUM]. */
723 static const yytype_int8 yypgoto[] =
724 {
725 -63, -63, 13, -63, 59, -63, 40, -63, -63, -34,
726 -63, -63, -63, -23, -63, -36, -22, -21
727 };
728
729 /* YYDEFGOTO[NTERM-NUM]. */
730 static const yytype_int8 yydefgoto[] =
731 {
732 0, 10, 11, 12, 13, 14, 15, 104, 113, 86,
733 87, 88, 102, 16, 17, 108, 97, 31
734 };
735
736 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
737 positive, shift that token. If negative, reduce the rule whose
738 number is the opposite. If YYTABLE_NINF, syntax error. */
739 static const yytype_int8 yytable[] =
740 {
741 35, 1, 19, 2, 3, -75, 4, 20, 2, 3,
742 100, 101, 5, 6, 7, 8, 1, 21, 2, 3,
743 22, 4, 2, 3, 23, 4, 26, 5, 6, 7,
744 8, 5, 6, 7, 8, 24, 28, 29, 30, 25,
745 89, 27, 32, 33, 36, 90, 91, 92, 93, 94,
746 99, 106, 110, 96, 103, 107, 114, 115, 117, 112,
747 18, 105, 34, 109, 0, 95, 98, 0, 9, 0,
748 0, 0, 37, 9, 0, 0, 0, 0, 0, 0,
749 111, 0, 0, 9, 0, 0, 0, 9, 0, 116,
750 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
751 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
752 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
753 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
754 78, 79, 80, 81, 82, 83, 84, 0, 85
755 };
756
757 static const yytype_int8 yycheck[] =
758 {
759 23, 5, 15, 7, 8, 9, 10, 15, 7, 8,
760 72, 73, 16, 17, 18, 19, 5, 4, 7, 8,
761 10, 10, 7, 8, 10, 10, 0, 16, 17, 18,
762 19, 16, 17, 18, 19, 10, 20, 21, 22, 10,
763 27, 4, 9, 11, 72, 7, 12, 11, 20, 73,
764 7, 7, 11, 14, 23, 13, 11, 7, 11, 24,
765 1, 95, 22, 99, -1, 86, 88, -1, 72, -1,
766 -1, -1, 7, 72, -1, -1, -1, -1, -1, -1,
767 103, -1, -1, 72, -1, -1, -1, 72, -1, 112,
768 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
769 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
770 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
771 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
772 65, 66, 67, 68, 69, 70, 71, -1, 73
773 };
774
775 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
776 state STATE-NUM. */
777 static const yytype_int8 yystos[] =
778 {
779 0, 5, 7, 8, 10, 16, 17, 18, 19, 72,
780 75, 76, 77, 78, 79, 80, 87, 88, 78, 15,
781 15, 76, 10, 10, 10, 10, 0, 4, 20, 21,
782 22, 91, 9, 11, 80, 87, 72, 7, 25, 26,
783 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
784 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
785 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
786 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
787 67, 68, 69, 70, 71, 73, 83, 84, 85, 76,
788 7, 12, 11, 20, 73, 91, 14, 90, 90, 7,
789 72, 73, 86, 23, 81, 83, 7, 13, 89, 89,
790 11, 87, 24, 82, 11, 7, 87, 11
791 };
792
793 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
794 static const yytype_int8 yyr1[] =
795 {
796 0, 74, 75, 75, 76, 76, 77, 77, 78, 78,
797 78, 78, 78, 79, 79, 80, 81, 81, 82, 82,
798 83, 83, 83, 83, 84, 84, 84, 84, 84, 84,
799 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
800 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
801 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
802 84, 84, 84, 84, 84, 84, 84, 84, 84, 85,
803 85, 86, 86, 87, 87, 88, 88, 88, 89, 89,
804 90, 90, 91, 91, 91
805 };
806
807 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
808 static const yytype_int8 yyr2[] =
809 {
810 0, 2, 0, 1, 1, 3, 2, 1, 1, 6,
811 7, 6, 3, 4, 1, 3, 0, 2, 0, 2,
812 1, 1, 3, 2, 1, 1, 1, 1, 1, 1,
813 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
814 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
815 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
816 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
817 1, 1, 1, 1, 5, 0, 2, 2, 0, 2,
818 0, 2, 1, 1, 1
819 };
820
821
822 enum { YYENOMEM = -2 };
823
824 #define yyerrok (yyerrstatus = 0)
825 #define yyclearin (yychar = YYEMPTY)
826
827 #define YYACCEPT goto yyacceptlab
828 #define YYABORT goto yyabortlab
829 #define YYERROR goto yyerrorlab
830 #define YYNOMEM goto yyexhaustedlab
831
832
833 #define YYRECOVERING() (!!yyerrstatus)
834
835 #define YYBACKUP(Token, Value) \
836 do \
837 if (yychar == YYEMPTY) \
838 { \
839 yychar = (Token); \
840 yylval = (Value); \
841 YYPOPSTACK (yylen); \
842 yystate = *yyssp; \
843 goto yybackup; \
844 } \
845 else \
846 { \
847 yyerror (scanner, errp, root, YY_("syntax error: cannot back up")); \
848 YYERROR; \
849 } \
850 while (0)
851
852 /* Backward compatibility with an undocumented macro.
853 Use YYerror or YYUNDEF. */
854 #define YYERRCODE YYUNDEF
855
856
857 /* Enable debugging if requested. */
858 #if YYDEBUG
859
860 # ifndef YYFPRINTF
861 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
862 # define YYFPRINTF fprintf
863 # endif
864
865 # define YYDPRINTF(Args) \
866 do { \
867 if (yydebug) \
868 YYFPRINTF Args; \
869 } while (0)
870
871
872
873
874 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
875 do { \
876 if (yydebug) \
877 { \
878 YYFPRINTF (stderr, "%s ", Title); \
879 yy_symbol_print (stderr, \
880 Kind, Value, scanner, errp, root); \
881 YYFPRINTF (stderr, "\n"); \
882 } \
883 } while (0)
884
885
886 /*-----------------------------------.
887 | Print this symbol's value on YYO. |
888 `-----------------------------------*/
889
890 static void
891 yy_symbol_value_print (FILE *yyo,
892 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *scanner, char **errp, struct nl_list_head *root)
893 {
894 FILE *yyoutput = yyo;
895 YY_USE (yyoutput);
896 YY_USE (scanner);
897 YY_USE (errp);
898 YY_USE (root);
899 if (!yyvaluep)
900 return;
901 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
902 YY_USE (yykind);
903 YY_IGNORE_MAYBE_UNINITIALIZED_END
904 }
905
906
907 /*---------------------------.
908 | Print this symbol on YYO. |
909 `---------------------------*/
910
911 static void
912 yy_symbol_print (FILE *yyo,
913 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *scanner, char **errp, struct nl_list_head *root)
914 {
915 YYFPRINTF (yyo, "%s %s (",
916 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
917
918 yy_symbol_value_print (yyo, yykind, yyvaluep, scanner, errp, root);
919 YYFPRINTF (yyo, ")");
920 }
921
922 /*------------------------------------------------------------------.
923 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
924 | TOP (included). |
925 `------------------------------------------------------------------*/
926
927 static void
928 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
929 {
930 YYFPRINTF (stderr, "Stack now");
931 for (; yybottom <= yytop; yybottom++)
932 {
933 int yybot = *yybottom;
934 YYFPRINTF (stderr, " %d", yybot);
935 }
936 YYFPRINTF (stderr, "\n");
937 }
938
939 # define YY_STACK_PRINT(Bottom, Top) \
940 do { \
941 if (yydebug) \
942 yy_stack_print ((Bottom), (Top)); \
943 } while (0)
944
945
946 /*------------------------------------------------.
947 | Report that the YYRULE is going to be reduced. |
948 `------------------------------------------------*/
949
950 static void
951 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
952 int yyrule, void *scanner, char **errp, struct nl_list_head *root)
953 {
954 int yylno = yyrline[yyrule];
955 int yynrhs = yyr2[yyrule];
956 int yyi;
957 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
958 yyrule - 1, yylno);
959 /* The symbols being reduced. */
960 for (yyi = 0; yyi < yynrhs; yyi++)
961 {
962 YYFPRINTF (stderr, " $%d = ", yyi + 1);
963 yy_symbol_print (stderr,
964 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
965 &yyvsp[(yyi + 1) - (yynrhs)], scanner, errp, root);
966 YYFPRINTF (stderr, "\n");
967 }
968 }
969
970 # define YY_REDUCE_PRINT(Rule) \
971 do { \
972 if (yydebug) \
973 yy_reduce_print (yyssp, yyvsp, Rule, scanner, errp, root); \
974 } while (0)
975
976 /* Nonzero means print parse trace. It is left uninitialized so that
977 multiple parsers can coexist. */
978 int yydebug;
979 #else /* !YYDEBUG */
980 # define YYDPRINTF(Args) ((void) 0)
981 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
982 # define YY_STACK_PRINT(Bottom, Top)
983 # define YY_REDUCE_PRINT(Rule)
984 #endif /* !YYDEBUG */
985
986
987 /* YYINITDEPTH -- initial size of the parser's stacks. */
988 #ifndef YYINITDEPTH
989 # define YYINITDEPTH 200
990 #endif
991
992 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
993 if the built-in stack extension method is used).
994
995 Do not make this value too large; the results are undefined if
996 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
997 evaluated with infinite-precision integer arithmetic. */
998
999 #ifndef YYMAXDEPTH
1000 # define YYMAXDEPTH 10000
1001 #endif
1002
1003
1004 /* Context of a parse error. */
1005 typedef struct
1006 {
1007 yy_state_t *yyssp;
1008 yysymbol_kind_t yytoken;
1009 } yypcontext_t;
1010
1011 /* Put in YYARG at most YYARGN of the expected tokens given the
1012 current YYCTX, and return the number of tokens stored in YYARG. If
1013 YYARG is null, return the number of expected tokens (guaranteed to
1014 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1015 Return 0 if there are more than YYARGN expected tokens, yet fill
1016 YYARG up to YYARGN. */
1017 static int
1018 yypcontext_expected_tokens (const yypcontext_t *yyctx,
1019 yysymbol_kind_t yyarg[], int yyargn)
1020 {
1021 /* Actual size of YYARG. */
1022 int yycount = 0;
1023 int yyn = yypact[+*yyctx->yyssp];
1024 if (!yypact_value_is_default (yyn))
1025 {
1026 /* Start YYX at -YYN if negative to avoid negative indexes in
1027 YYCHECK. In other words, skip the first -YYN actions for
1028 this state because they are default actions. */
1029 int yyxbegin = yyn < 0 ? -yyn : 0;
1030 /* Stay within bounds of both yycheck and yytname. */
1031 int yychecklim = YYLAST - yyn + 1;
1032 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1033 int yyx;
1034 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1035 if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
1036 && !yytable_value_is_error (yytable[yyx + yyn]))
1037 {
1038 if (!yyarg)
1039 ++yycount;
1040 else if (yycount == yyargn)
1041 return 0;
1042 else
1043 yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1044 }
1045 }
1046 if (yyarg && yycount == 0 && 0 < yyargn)
1047 yyarg[0] = YYSYMBOL_YYEMPTY;
1048 return yycount;
1049 }
1050
1051
1052
1053
1054 #ifndef yystrlen
1055 # if defined __GLIBC__ && defined _STRING_H
1056 # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1057 # else
1058 /* Return the length of YYSTR. */
1059 static YYPTRDIFF_T
1060 yystrlen (const char *yystr)
1061 {
1062 YYPTRDIFF_T yylen;
1063 for (yylen = 0; yystr[yylen]; yylen++)
1064 continue;
1065 return yylen;
1066 }
1067 # endif
1068 #endif
1069
1070 #ifndef yystpcpy
1071 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1072 # define yystpcpy stpcpy
1073 # else
1074 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1075 YYDEST. */
1076 static char *
1077 yystpcpy (char *yydest, const char *yysrc)
1078 {
1079 char *yyd = yydest;
1080 const char *yys = yysrc;
1081
1082 while ((*yyd++ = *yys++) != '\0')
1083 continue;
1084
1085 return yyd - 1;
1086 }
1087 # endif
1088 #endif
1089
1090 #ifndef yytnamerr
1091 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1092 quotes and backslashes, so that it's suitable for yyerror. The
1093 heuristic is that double-quoting is unnecessary unless the string
1094 contains an apostrophe, a comma, or backslash (other than
1095 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1096 null, do not copy; instead, return the length of what the result
1097 would have been. */
1098 static YYPTRDIFF_T
1099 yytnamerr (char *yyres, const char *yystr)
1100 {
1101 if (*yystr == '"')
1102 {
1103 YYPTRDIFF_T yyn = 0;
1104 char const *yyp = yystr;
1105 for (;;)
1106 switch (*++yyp)
1107 {
1108 case '\'':
1109 case ',':
1110 goto do_not_strip_quotes;
1111
1112 case '\\':
1113 if (*++yyp != '\\')
1114 goto do_not_strip_quotes;
1115 else
1116 goto append;
1117
1118 append:
1119 default:
1120 if (yyres)
1121 yyres[yyn] = *yyp;
1122 yyn++;
1123 break;
1124
1125 case '"':
1126 if (yyres)
1127 yyres[yyn] = '\0';
1128 return yyn;
1129 }
1130 do_not_strip_quotes: ;
1131 }
1132
1133 if (yyres)
1134 return yystpcpy (yyres, yystr) - yyres;
1135 else
1136 return yystrlen (yystr);
1137 }
1138 #endif
1139
1140
1141 static int
1142 yy_syntax_error_arguments (const yypcontext_t *yyctx,
1143 yysymbol_kind_t yyarg[], int yyargn)
1144 {
1145 /* Actual size of YYARG. */
1146 int yycount = 0;
1147 /* There are many possibilities here to consider:
1148 - If this state is a consistent state with a default action, then
1149 the only way this function was invoked is if the default action
1150 is an error action. In that case, don't check for expected
1151 tokens because there are none.
1152 - The only way there can be no lookahead present (in yychar) is if
1153 this state is a consistent state with a default action. Thus,
1154 detecting the absence of a lookahead is sufficient to determine
1155 that there is no unexpected or expected token to report. In that
1156 case, just report a simple "syntax error".
1157 - Don't assume there isn't a lookahead just because this state is a
1158 consistent state with a default action. There might have been a
1159 previous inconsistent state, consistent state with a non-default
1160 action, or user semantic action that manipulated yychar.
1161 - Of course, the expected token list depends on states to have
1162 correct lookahead information, and it depends on the parser not
1163 to perform extra reductions after fetching a lookahead from the
1164 scanner and before detecting a syntax error. Thus, state merging
1165 (from LALR or IELR) and default reductions corrupt the expected
1166 token list. However, the list is correct for canonical LR with
1167 one exception: it will still contain any token that will not be
1168 accepted due to an error action in a later state.
1169 */
1170 if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1171 {
1172 int yyn;
1173 if (yyarg)
1174 yyarg[yycount] = yyctx->yytoken;
1175 ++yycount;
1176 yyn = yypcontext_expected_tokens (yyctx,
1177 yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1178 if (yyn == YYENOMEM)
1179 return YYENOMEM;
1180 else
1181 yycount += yyn;
1182 }
1183 return yycount;
1184 }
1185
1186 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1187 about the unexpected token YYTOKEN for the state stack whose top is
1188 YYSSP.
1189
1190 Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1191 not large enough to hold the message. In that case, also set
1192 *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1193 required number of bytes is too large to store. */
1194 static int
1195 yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1196 const yypcontext_t *yyctx)
1197 {
1198 enum { YYARGS_MAX = 5 };
1199 /* Internationalized format string. */
1200 const char *yyformat = YY_NULLPTR;
1201 /* Arguments of yyformat: reported tokens (one for the "unexpected",
1202 one per "expected"). */
1203 yysymbol_kind_t yyarg[YYARGS_MAX];
1204 /* Cumulated lengths of YYARG. */
1205 YYPTRDIFF_T yysize = 0;
1206
1207 /* Actual size of YYARG. */
1208 int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1209 if (yycount == YYENOMEM)
1210 return YYENOMEM;
1211
1212 switch (yycount)
1213 {
1214 #define YYCASE_(N, S) \
1215 case N: \
1216 yyformat = S; \
1217 break
1218 default: /* Avoid compiler warnings. */
1219 YYCASE_(0, YY_("syntax error"));
1220 YYCASE_(1, YY_("syntax error, unexpected %s"));
1221 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1222 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1223 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1224 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1225 #undef YYCASE_
1226 }
1227
1228 /* Compute error message size. Don't count the "%s"s, but reserve
1229 room for the terminator. */
1230 yysize = yystrlen (yyformat) - 2 * yycount + 1;
1231 {
1232 int yyi;
1233 for (yyi = 0; yyi < yycount; ++yyi)
1234 {
1235 YYPTRDIFF_T yysize1
1236 = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1237 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1238 yysize = yysize1;
1239 else
1240 return YYENOMEM;
1241 }
1242 }
1243
1244 if (*yymsg_alloc < yysize)
1245 {
1246 *yymsg_alloc = 2 * yysize;
1247 if (! (yysize <= *yymsg_alloc
1248 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1249 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1250 return -1;
1251 }
1252
1253 /* Avoid sprintf, as that infringes on the user's name space.
1254 Don't have undefined behavior even if the translation
1255 produced a string with the wrong number of "%s"s. */
1256 {
1257 char *yyp = *yymsg;
1258 int yyi = 0;
1259 while ((*yyp = *yyformat) != '\0')
1260 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1261 {
1262 yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1263 yyformat += 2;
1264 }
1265 else
1266 {
1267 ++yyp;
1268 ++yyformat;
1269 }
1270 }
1271 return 0;
1272 }
1273
1274
1275 /*-----------------------------------------------.
1276 | Release the memory associated to this symbol. |
1277 `-----------------------------------------------*/
1278
1279 static void
1280 yydestruct (const char *yymsg,
1281 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void *scanner, char **errp, struct nl_list_head *root)
1282 {
1283 YY_USE (yyvaluep);
1284 YY_USE (scanner);
1285 YY_USE (errp);
1286 YY_USE (root);
1287 if (!yymsg)
1288 yymsg = "Deleting";
1289 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1290
1291 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1292 switch (yykind)
1293 {
1294 case YYSYMBOL_STR: /* STR */
1295 #line 136 "lib/route/cls/ematch_syntax.y"
1296 { free(((*yyvaluep).s)); NL_DBG(2, "string destructor\n"); }
1297 #line 1298 "lib/route/cls/ematch_syntax.c"
1298 break;
1299
1300 case YYSYMBOL_QUOTED: /* QUOTED */
1301 #line 138 "lib/route/cls/ematch_syntax.y"
1302 { free(((*yyvaluep).q).data); NL_DBG(2, "quoted destructor\n"); }
1303 #line 1304 "lib/route/cls/ematch_syntax.c"
1304 break;
1305
1306 case YYSYMBOL_text_from: /* text_from */
1307 #line 137 "lib/route/cls/ematch_syntax.y"
1308 { rtnl_pktloc_put(((*yyvaluep).loc)); NL_DBG(2, "pktloc destructor\n"); }
1309 #line 1310 "lib/route/cls/ematch_syntax.c"
1310 break;
1311
1312 case YYSYMBOL_text_to: /* text_to */
1313 #line 137 "lib/route/cls/ematch_syntax.y"
1314 { rtnl_pktloc_put(((*yyvaluep).loc)); NL_DBG(2, "pktloc destructor\n"); }
1315 #line 1316 "lib/route/cls/ematch_syntax.c"
1316 break;
1317
1318 case YYSYMBOL_meta_value: /* meta_value */
1319 #line 139 "lib/route/cls/ematch_syntax.y"
1320 { rtnl_meta_value_put(((*yyvaluep).mv)); NL_DBG(2, "meta value destructor\n"); }
1321 #line 1322 "lib/route/cls/ematch_syntax.c"
1322 break;
1323
1324 case YYSYMBOL_pattern: /* pattern */
1325 #line 138 "lib/route/cls/ematch_syntax.y"
1326 { free(((*yyvaluep).q).data); NL_DBG(2, "quoted destructor\n"); }
1327 #line 1328 "lib/route/cls/ematch_syntax.c"
1328 break;
1329
1330 case YYSYMBOL_pktloc: /* pktloc */
1331 #line 137 "lib/route/cls/ematch_syntax.y"
1332 { rtnl_pktloc_put(((*yyvaluep).loc)); NL_DBG(2, "pktloc destructor\n"); }
1333 #line 1334 "lib/route/cls/ematch_syntax.c"
1334 break;
1335
1336 default:
1337 break;
1338 }
1339 YY_IGNORE_MAYBE_UNINITIALIZED_END
1340 }
1341
1342
1343
1344
1345
1346
1347 /*----------.
1348 | yyparse. |
1349 `----------*/
1350
1351 int
1352 yyparse (void *scanner, char **errp, struct nl_list_head *root)
1353 {
1354 /* Lookahead token kind. */
1355 int yychar;
1356
1357
1358 /* The semantic value of the lookahead symbol. */
1359 /* Default value used for initialization, for pacifying older GCCs
1360 or non-GCC compilers. */
1361 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1362 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1363
1364 /* Number of syntax errors so far. */
1365 int yynerrs = 0;
1366
1367 yy_state_fast_t yystate = 0;
1368 /* Number of tokens to shift before error messages enabled. */
1369 int yyerrstatus = 0;
1370
1371 /* Refer to the stacks through separate pointers, to allow yyoverflow
1372 to reallocate them elsewhere. */
1373
1374 /* Their size. */
1375 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1376
1377 /* The state stack: array, bottom, top. */
1378 yy_state_t yyssa[YYINITDEPTH];
1379 yy_state_t *yyss = yyssa;
1380 yy_state_t *yyssp = yyss;
1381
1382 /* The semantic value stack: array, bottom, top. */
1383 YYSTYPE yyvsa[YYINITDEPTH];
1384 YYSTYPE *yyvs = yyvsa;
1385 YYSTYPE *yyvsp = yyvs;
1386
1387 int yyn;
1388 /* The return value of yyparse. */
1389 int yyresult;
1390 /* Lookahead symbol kind. */
1391 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1392 /* The variables used to return semantic value and location from the
1393 action routines. */
1394 YYSTYPE yyval;
1395
1396 /* Buffer for error messages, and its allocated size. */
1397 char yymsgbuf[128];
1398 char *yymsg = yymsgbuf;
1399 YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1400
1401 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1402
1403 /* The number of symbols on the RHS of the reduced rule.
1404 Keep to zero when no symbol should be popped. */
1405 int yylen = 0;
1406
1407 YYDPRINTF ((stderr, "Starting parse\n"));
1408
1409 yychar = YYEMPTY; /* Cause a token to be read. */
1410
1411 goto yysetstate;
1412
1413
1414 /*------------------------------------------------------------.
1415 | yynewstate -- push a new state, which is found in yystate. |
1416 `------------------------------------------------------------*/
1417 yynewstate:
1418 /* In all cases, when you get here, the value and location stacks
1419 have just been pushed. So pushing a state here evens the stacks. */
1420 yyssp++;
1421
1422
1423 /*--------------------------------------------------------------------.
1424 | yysetstate -- set current state (the top of the stack) to yystate. |
1425 `--------------------------------------------------------------------*/
1426 yysetstate:
1427 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1428 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1429 YY_IGNORE_USELESS_CAST_BEGIN
1430 *yyssp = YY_CAST (yy_state_t, yystate);
1431 YY_IGNORE_USELESS_CAST_END
1432 YY_STACK_PRINT (yyss, yyssp);
1433
1434 if (yyss + yystacksize - 1 <= yyssp)
1435 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1436 YYNOMEM;
1437 #else
1438 {
1439 /* Get the current used size of the three stacks, in elements. */
1440 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1441
1442 # if defined yyoverflow
1443 {
1444 /* Give user a chance to reallocate the stack. Use copies of
1445 these so that the &'s don't force the real ones into
1446 memory. */
1447 yy_state_t *yyss1 = yyss;
1448 YYSTYPE *yyvs1 = yyvs;
1449
1450 /* Each stack pointer address is followed by the size of the
1451 data in use in that stack, in bytes. This used to be a
1452 conditional around just the two extra args, but that might
1453 be undefined if yyoverflow is a macro. */
1454 yyoverflow (YY_("memory exhausted"),
1455 &yyss1, yysize * YYSIZEOF (*yyssp),
1456 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1457 &yystacksize);
1458 yyss = yyss1;
1459 yyvs = yyvs1;
1460 }
1461 # else /* defined YYSTACK_RELOCATE */
1462 /* Extend the stack our own way. */
1463 if (YYMAXDEPTH <= yystacksize)
1464 YYNOMEM;
1465 yystacksize *= 2;
1466 if (YYMAXDEPTH < yystacksize)
1467 yystacksize = YYMAXDEPTH;
1468
1469 {
1470 yy_state_t *yyss1 = yyss;
1471 union yyalloc *yyptr =
1472 YY_CAST (union yyalloc *,
1473 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1474 if (! yyptr)
1475 YYNOMEM;
1476 YYSTACK_RELOCATE (yyss_alloc, yyss);
1477 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1478 # undef YYSTACK_RELOCATE
1479 if (yyss1 != yyssa)
1480 YYSTACK_FREE (yyss1);
1481 }
1482 # endif
1483
1484 yyssp = yyss + yysize - 1;
1485 yyvsp = yyvs + yysize - 1;
1486
1487 YY_IGNORE_USELESS_CAST_BEGIN
1488 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1489 YY_CAST (long, yystacksize)));
1490 YY_IGNORE_USELESS_CAST_END
1491
1492 if (yyss + yystacksize - 1 <= yyssp)
1493 YYABORT;
1494 }
1495 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1496
1497
1498 if (yystate == YYFINAL)
1499 YYACCEPT;
1500
1501 goto yybackup;
1502
1503
1504 /*-----------.
1505 | yybackup. |
1506 `-----------*/
1507 yybackup:
1508 /* Do appropriate processing given the current state. Read a
1509 lookahead token if we need one and don't already have one. */
1510
1511 /* First try to decide what to do without reference to lookahead token. */
1512 yyn = yypact[yystate];
1513 if (yypact_value_is_default (yyn))
1514 goto yydefault;
1515
1516 /* Not known => get a lookahead token if don't already have one. */
1517
1518 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1519 if (yychar == YYEMPTY)
1520 {
1521 YYDPRINTF ((stderr, "Reading a token\n"));
1522 yychar = yylex (&yylval, scanner);
1523 }
1524
1525 if (yychar <= YYEOF)
1526 {
1527 yychar = YYEOF;
1528 yytoken = YYSYMBOL_YYEOF;
1529 YYDPRINTF ((stderr, "Now at end of input.\n"));
1530 }
1531 else if (yychar == YYerror)
1532 {
1533 /* The scanner already issued an error message, process directly
1534 to error recovery. But do not keep the error token as
1535 lookahead, it is too special and may lead us to an endless
1536 loop in error recovery. */
1537 yychar = YYUNDEF;
1538 yytoken = YYSYMBOL_YYerror;
1539 goto yyerrlab1;
1540 }
1541 else
1542 {
1543 yytoken = YYTRANSLATE (yychar);
1544 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1545 }
1546
1547 /* If the proper action on seeing token YYTOKEN is to reduce or to
1548 detect an error, take that action. */
1549 yyn += yytoken;
1550 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1551 goto yydefault;
1552 yyn = yytable[yyn];
1553 if (yyn <= 0)
1554 {
1555 if (yytable_value_is_error (yyn))
1556 goto yyerrlab;
1557 yyn = -yyn;
1558 goto yyreduce;
1559 }
1560
1561 /* Count tokens shifted since error; after three, turn off error
1562 status. */
1563 if (yyerrstatus)
1564 yyerrstatus--;
1565
1566 /* Shift the lookahead token. */
1567 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1568 yystate = yyn;
1569 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1570 *++yyvsp = yylval;
1571 YY_IGNORE_MAYBE_UNINITIALIZED_END
1572
1573 /* Discard the shifted token. */
1574 yychar = YYEMPTY;
1575 goto yynewstate;
1576
1577
1578 /*-----------------------------------------------------------.
1579 | yydefault -- do the default action for the current state. |
1580 `-----------------------------------------------------------*/
1581 yydefault:
1582 yyn = yydefact[yystate];
1583 if (yyn == 0)
1584 goto yyerrlab;
1585 goto yyreduce;
1586
1587
1588 /*-----------------------------.
1589 | yyreduce -- do a reduction. |
1590 `-----------------------------*/
1591 yyreduce:
1592 /* yyn is the number of a rule to reduce with. */
1593 yylen = yyr2[yyn];
1594
1595 /* If YYLEN is nonzero, implement the default value of the action:
1596 '$$ = $1'.
1597
1598 Otherwise, the following line sets YYVAL to garbage.
1599 This behavior is undocumented and Bison
1600 users should not rely upon it. Assigning to YYVAL
1601 unconditionally makes the parser a bit smaller, and it avoids a
1602 GCC warning that YYVAL may be used uninitialized. */
1603 yyval = yyvsp[1-yylen];
1604
1605
1606 YY_REDUCE_PRINT (yyn);
1607 switch (yyn)
1608 {
1609 case 3: /* input: expr */
1610 #line 148 "lib/route/cls/ematch_syntax.y"
1611 {
1612 nl_list_add_tail(root, &(yyvsp[0].e)->e_list);
1613 }
1614 #line 1615 "lib/route/cls/ematch_syntax.c"
1615 break;
1616
1617 case 4: /* expr: match */
1618 #line 155 "lib/route/cls/ematch_syntax.y"
1619 {
1620 (yyval.e) = (yyvsp[0].e);
1621 }
1622 #line 1623 "lib/route/cls/ematch_syntax.c"
1623 break;
1624
1625 case 5: /* expr: match LOGIC expr */
1626 #line 159 "lib/route/cls/ematch_syntax.y"
1627 {
1628 rtnl_ematch_set_flags((yyvsp[-2].e), (yyvsp[-1].i));
1629
1630 /* make ematch new head */
1631 nl_list_add_tail(&(yyvsp[-2].e)->e_list, &(yyvsp[0].e)->e_list);
1632
1633 (yyval.e) = (yyvsp[-2].e);
1634 }
1635 #line 1636 "lib/route/cls/ematch_syntax.c"
1636 break;
1637
1638 case 6: /* match: NOT ematch */
1639 #line 171 "lib/route/cls/ematch_syntax.y"
1640 {
1641 rtnl_ematch_set_flags((yyvsp[0].e), TCF_EM_INVERT);
1642 (yyval.e) = (yyvsp[0].e);
1643 }
1644 #line 1645 "lib/route/cls/ematch_syntax.c"
1645 break;
1646
1647 case 7: /* match: ematch */
1648 #line 176 "lib/route/cls/ematch_syntax.y"
1649 {
1650 (yyval.e) = (yyvsp[0].e);
1651 }
1652 #line 1653 "lib/route/cls/ematch_syntax.c"
1653 break;
1654
1655 case 8: /* ematch: cmp_match */
1656 #line 184 "lib/route/cls/ematch_syntax.y"
1657 {
1658 struct rtnl_ematch *e;
1659
1660 if (!(e = rtnl_ematch_alloc())) {
1661 *errp = strdup("Unable to allocate ematch object");
1662 YYABORT;
1663 }
1664
1665 if (rtnl_ematch_set_kind(e, TCF_EM_CMP) < 0)
1666 BUG();
1667
1668 rtnl_ematch_cmp_set(e, &(yyvsp[0].cmp));
1669 (yyval.e) = e;
1670 }
1671 #line 1672 "lib/route/cls/ematch_syntax.c"
1672 break;
1673
1674 case 9: /* ematch: "pattern" "(" pktloc "=" pattern ")" */
1675 #line 199 "lib/route/cls/ematch_syntax.y"
1676 {
1677 struct rtnl_ematch *e;
1678
1679 if (!(e = rtnl_ematch_alloc())) {
1680 *errp = strdup("Unable to allocate ematch object");
1681 YYABORT;
1682 }
1683
1684 if (rtnl_ematch_set_kind(e, TCF_EM_NBYTE) < 0)
1685 BUG();
1686
1687 rtnl_ematch_nbyte_set_offset(e, (yyvsp[-3].loc)->layer, (yyvsp[-3].loc)->offset);
1688 rtnl_pktloc_put((yyvsp[-3].loc));
1689 rtnl_ematch_nbyte_set_pattern(e, (uint8_t *) (yyvsp[-1].q).data, (yyvsp[-1].q).index);
1690
1691 (yyval.e) = e;
1692 }
1693 #line 1694 "lib/route/cls/ematch_syntax.c"
1694 break;
1695
1696 case 10: /* ematch: "text" "(" STR QUOTED text_from text_to ")" */
1697 #line 217 "lib/route/cls/ematch_syntax.y"
1698 {
1699 struct rtnl_ematch *e;
1700
1701 if (!(e = rtnl_ematch_alloc())) {
1702 *errp = strdup("Unable to allocate ematch object");
1703 YYABORT;
1704 }
1705
1706 if (rtnl_ematch_set_kind(e, TCF_EM_TEXT) < 0)
1707 BUG();
1708
1709 rtnl_ematch_text_set_algo(e, (yyvsp[-4].s));
1710 rtnl_ematch_text_set_pattern(e, (yyvsp[-3].q).data, (yyvsp[-3].q).index);
1711
1712 if ((yyvsp[-2].loc)) {
1713 rtnl_ematch_text_set_from(e, (yyvsp[-2].loc)->layer, (yyvsp[-2].loc)->offset);
1714 rtnl_pktloc_put((yyvsp[-2].loc));
1715 }
1716
1717 if ((yyvsp[-1].loc)) {
1718 rtnl_ematch_text_set_to(e, (yyvsp[-1].loc)->layer, (yyvsp[-1].loc)->offset);
1719 rtnl_pktloc_put((yyvsp[-1].loc));
1720 }
1721
1722 (yyval.e) = e;
1723 }
1724 #line 1725 "lib/route/cls/ematch_syntax.c"
1725 break;
1726
1727 case 11: /* ematch: "meta" "(" meta_value operand meta_value ")" */
1728 #line 244 "lib/route/cls/ematch_syntax.y"
1729 {
1730 struct rtnl_ematch *e;
1731
1732 if (!(e = rtnl_ematch_alloc())) {
1733 *errp = strdup("Unable to allocate ematch object");
1734 YYABORT;
1735 }
1736
1737 if (rtnl_ematch_set_kind(e, TCF_EM_META) < 0)
1738 BUG();
1739
1740 rtnl_ematch_meta_set_lvalue(e, (yyvsp[-3].mv));
1741 rtnl_ematch_meta_set_rvalue(e, (yyvsp[-1].mv));
1742 rtnl_ematch_meta_set_operand(e, (yyvsp[-2].i));
1743
1744 (yyval.e) = e;
1745 }
1746 #line 1747 "lib/route/cls/ematch_syntax.c"
1747 break;
1748
1749 case 12: /* ematch: "(" expr ")" */
1750 #line 263 "lib/route/cls/ematch_syntax.y"
1751 {
1752 struct rtnl_ematch *e;
1753
1754 if (!(e = rtnl_ematch_alloc())) {
1755 *errp = strdup("Unable to allocate ematch object");
1756 YYABORT;
1757 }
1758
1759 if (rtnl_ematch_set_kind(e, TCF_EM_CONTAINER) < 0)
1760 BUG();
1761
1762 /* Make e->childs the list head of a the ematch sequence */
1763 nl_list_add_tail(&e->e_childs, &(yyvsp[-1].e)->e_list);
1764
1765 (yyval.e) = e;
1766 }
1767 #line 1768 "lib/route/cls/ematch_syntax.c"
1768 break;
1769
1770 case 13: /* cmp_match: "cmp" "(" cmp_expr ")" */
1771 #line 291 "lib/route/cls/ematch_syntax.y"
1772 { (yyval.cmp) = (yyvsp[-1].cmp); }
1773 #line 1774 "lib/route/cls/ematch_syntax.c"
1774 break;
1775
1776 case 14: /* cmp_match: cmp_expr */
1777 #line 293 "lib/route/cls/ematch_syntax.y"
1778 { (yyval.cmp) = (yyvsp[0].cmp); }
1779 #line 1780 "lib/route/cls/ematch_syntax.c"
1780 break;
1781
1782 case 15: /* cmp_expr: pktloc operand NUMBER */
1783 #line 298 "lib/route/cls/ematch_syntax.y"
1784 {
1785 if ((yyvsp[-2].loc)->align == TCF_EM_ALIGN_U16 ||
1786 (yyvsp[-2].loc)->align == TCF_EM_ALIGN_U32)
1787 (yyval.cmp).flags = TCF_EM_CMP_TRANS;
1788
1789 memset(&(yyval.cmp), 0, sizeof((yyval.cmp)));
1790
1791 (yyval.cmp).mask = (yyvsp[-2].loc)->mask;
1792 (yyval.cmp).off = (yyvsp[-2].loc)->offset;
1793 (yyval.cmp).align = (yyvsp[-2].loc)->align;
1794 (yyval.cmp).layer = (yyvsp[-2].loc)->layer;
1795 (yyval.cmp).opnd = (yyvsp[-1].i);
1796 (yyval.cmp).val = (yyvsp[0].i);
1797
1798 rtnl_pktloc_put((yyvsp[-2].loc));
1799 }
1800 #line 1801 "lib/route/cls/ematch_syntax.c"
1801 break;
1802
1803 case 16: /* text_from: %empty */
1804 #line 318 "lib/route/cls/ematch_syntax.y"
1805 { (yyval.loc) = NULL; }
1806 #line 1807 "lib/route/cls/ematch_syntax.c"
1807 break;
1808
1809 case 17: /* text_from: "from" pktloc */
1810 #line 320 "lib/route/cls/ematch_syntax.y"
1811 { (yyval.loc) = (yyvsp[0].loc); }
1812 #line 1813 "lib/route/cls/ematch_syntax.c"
1813 break;
1814
1815 case 18: /* text_to: %empty */
1816 #line 325 "lib/route/cls/ematch_syntax.y"
1817 { (yyval.loc) = NULL; }
1818 #line 1819 "lib/route/cls/ematch_syntax.c"
1819 break;
1820
1821 case 19: /* text_to: "to" pktloc */
1822 #line 327 "lib/route/cls/ematch_syntax.y"
1823 { (yyval.loc) = (yyvsp[0].loc); }
1824 #line 1825 "lib/route/cls/ematch_syntax.c"
1825 break;
1826
1827 case 20: /* meta_value: QUOTED */
1828 #line 332 "lib/route/cls/ematch_syntax.y"
1829 { (yyval.mv) = rtnl_meta_value_alloc_var((yyvsp[0].q).data, (yyvsp[0].q).len); }
1830 #line 1831 "lib/route/cls/ematch_syntax.c"
1831 break;
1832
1833 case 21: /* meta_value: NUMBER */
1834 #line 334 "lib/route/cls/ematch_syntax.y"
1835 { (yyval.mv) = rtnl_meta_value_alloc_int((yyvsp[0].i)); }
1836 #line 1837 "lib/route/cls/ematch_syntax.c"
1837 break;
1838
1839 case 22: /* meta_value: meta_int_id shift mask */
1840 #line 336 "lib/route/cls/ematch_syntax.y"
1841 { (yyval.mv) = META_ALLOC(META_INT, (yyvsp[-2].i), (yyvsp[-1].i), (yyvsp[0].i64)); }
1842 #line 1843 "lib/route/cls/ematch_syntax.c"
1843 break;
1844
1845 case 23: /* meta_value: meta_var_id shift */
1846 #line 338 "lib/route/cls/ematch_syntax.y"
1847 { (yyval.mv) = META_ALLOC(META_VAR, (yyvsp[-1].i), (yyvsp[0].i), 0); }
1848 #line 1849 "lib/route/cls/ematch_syntax.c"
1849 break;
1850
1851 case 24: /* meta_int_id: "random" */
1852 #line 342 "lib/route/cls/ematch_syntax.y"
1853 { (yyval.i) = META_ID(RANDOM); }
1854 #line 1855 "lib/route/cls/ematch_syntax.c"
1855 break;
1856
1857 case 25: /* meta_int_id: "loadavg_0" */
1858 #line 343 "lib/route/cls/ematch_syntax.y"
1859 { (yyval.i) = META_ID(LOADAVG_0); }
1860 #line 1861 "lib/route/cls/ematch_syntax.c"
1861 break;
1862
1863 case 26: /* meta_int_id: "loadavg_1" */
1864 #line 344 "lib/route/cls/ematch_syntax.y"
1865 { (yyval.i) = META_ID(LOADAVG_1); }
1866 #line 1867 "lib/route/cls/ematch_syntax.c"
1867 break;
1868
1869 case 27: /* meta_int_id: "loadavg_2" */
1870 #line 345 "lib/route/cls/ematch_syntax.y"
1871 { (yyval.i) = META_ID(LOADAVG_2); }
1872 #line 1873 "lib/route/cls/ematch_syntax.c"
1873 break;
1874
1875 case 28: /* meta_int_id: "dev" */
1876 #line 346 "lib/route/cls/ematch_syntax.y"
1877 { (yyval.i) = META_ID(DEV); }
1878 #line 1879 "lib/route/cls/ematch_syntax.c"
1879 break;
1880
1881 case 29: /* meta_int_id: "prio" */
1882 #line 347 "lib/route/cls/ematch_syntax.y"
1883 { (yyval.i) = META_ID(PRIORITY); }
1884 #line 1885 "lib/route/cls/ematch_syntax.c"
1885 break;
1886
1887 case 30: /* meta_int_id: "proto" */
1888 #line 348 "lib/route/cls/ematch_syntax.y"
1889 { (yyval.i) = META_ID(PROTOCOL); }
1890 #line 1891 "lib/route/cls/ematch_syntax.c"
1891 break;
1892
1893 case 31: /* meta_int_id: "pkttype" */
1894 #line 349 "lib/route/cls/ematch_syntax.y"
1895 { (yyval.i) = META_ID(PKTTYPE); }
1896 #line 1897 "lib/route/cls/ematch_syntax.c"
1897 break;
1898
1899 case 32: /* meta_int_id: "pktlen" */
1900 #line 350 "lib/route/cls/ematch_syntax.y"
1901 { (yyval.i) = META_ID(PKTLEN); }
1902 #line 1903 "lib/route/cls/ematch_syntax.c"
1903 break;
1904
1905 case 33: /* meta_int_id: "datalen" */
1906 #line 351 "lib/route/cls/ematch_syntax.y"
1907 { (yyval.i) = META_ID(DATALEN); }
1908 #line 1909 "lib/route/cls/ematch_syntax.c"
1909 break;
1910
1911 case 34: /* meta_int_id: "maclen" */
1912 #line 352 "lib/route/cls/ematch_syntax.y"
1913 { (yyval.i) = META_ID(MACLEN); }
1914 #line 1915 "lib/route/cls/ematch_syntax.c"
1915 break;
1916
1917 case 35: /* meta_int_id: "mark" */
1918 #line 353 "lib/route/cls/ematch_syntax.y"
1919 { (yyval.i) = META_ID(NFMARK); }
1920 #line 1921 "lib/route/cls/ematch_syntax.c"
1921 break;
1922
1923 case 36: /* meta_int_id: "tcindex" */
1924 #line 354 "lib/route/cls/ematch_syntax.y"
1925 { (yyval.i) = META_ID(TCINDEX); }
1926 #line 1927 "lib/route/cls/ematch_syntax.c"
1927 break;
1928
1929 case 37: /* meta_int_id: "rtclassid" */
1930 #line 355 "lib/route/cls/ematch_syntax.y"
1931 { (yyval.i) = META_ID(RTCLASSID); }
1932 #line 1933 "lib/route/cls/ematch_syntax.c"
1933 break;
1934
1935 case 38: /* meta_int_id: "rtiif" */
1936 #line 356 "lib/route/cls/ematch_syntax.y"
1937 { (yyval.i) = META_ID(RTIIF); }
1938 #line 1939 "lib/route/cls/ematch_syntax.c"
1939 break;
1940
1941 case 39: /* meta_int_id: "sk_family" */
1942 #line 357 "lib/route/cls/ematch_syntax.y"
1943 { (yyval.i) = META_ID(SK_FAMILY); }
1944 #line 1945 "lib/route/cls/ematch_syntax.c"
1945 break;
1946
1947 case 40: /* meta_int_id: "sk_state" */
1948 #line 358 "lib/route/cls/ematch_syntax.y"
1949 { (yyval.i) = META_ID(SK_STATE); }
1950 #line 1951 "lib/route/cls/ematch_syntax.c"
1951 break;
1952
1953 case 41: /* meta_int_id: "sk_reuse" */
1954 #line 359 "lib/route/cls/ematch_syntax.y"
1955 { (yyval.i) = META_ID(SK_REUSE); }
1956 #line 1957 "lib/route/cls/ematch_syntax.c"
1957 break;
1958
1959 case 42: /* meta_int_id: "sk_refcnt" */
1960 #line 360 "lib/route/cls/ematch_syntax.y"
1961 { (yyval.i) = META_ID(SK_REFCNT); }
1962 #line 1963 "lib/route/cls/ematch_syntax.c"
1963 break;
1964
1965 case 43: /* meta_int_id: "sk_rcvbuf" */
1966 #line 361 "lib/route/cls/ematch_syntax.y"
1967 { (yyval.i) = META_ID(SK_RCVBUF); }
1968 #line 1969 "lib/route/cls/ematch_syntax.c"
1969 break;
1970
1971 case 44: /* meta_int_id: "sk_sndbuf" */
1972 #line 362 "lib/route/cls/ematch_syntax.y"
1973 { (yyval.i) = META_ID(SK_SNDBUF); }
1974 #line 1975 "lib/route/cls/ematch_syntax.c"
1975 break;
1976
1977 case 45: /* meta_int_id: "sk_shutdown" */
1978 #line 363 "lib/route/cls/ematch_syntax.y"
1979 { (yyval.i) = META_ID(SK_SHUTDOWN); }
1980 #line 1981 "lib/route/cls/ematch_syntax.c"
1981 break;
1982
1983 case 46: /* meta_int_id: "sk_proto" */
1984 #line 364 "lib/route/cls/ematch_syntax.y"
1985 { (yyval.i) = META_ID(SK_PROTO); }
1986 #line 1987 "lib/route/cls/ematch_syntax.c"
1987 break;
1988
1989 case 47: /* meta_int_id: "sk_type" */
1990 #line 365 "lib/route/cls/ematch_syntax.y"
1991 { (yyval.i) = META_ID(SK_TYPE); }
1992 #line 1993 "lib/route/cls/ematch_syntax.c"
1993 break;
1994
1995 case 48: /* meta_int_id: "sk_rmem_alloc" */
1996 #line 366 "lib/route/cls/ematch_syntax.y"
1997 { (yyval.i) = META_ID(SK_RMEM_ALLOC); }
1998 #line 1999 "lib/route/cls/ematch_syntax.c"
1999 break;
2000
2001 case 49: /* meta_int_id: "sk_wmem_alloc" */
2002 #line 367 "lib/route/cls/ematch_syntax.y"
2003 { (yyval.i) = META_ID(SK_WMEM_ALLOC); }
2004 #line 2005 "lib/route/cls/ematch_syntax.c"
2005 break;
2006
2007 case 50: /* meta_int_id: "sk_wmem_queued" */
2008 #line 368 "lib/route/cls/ematch_syntax.y"
2009 { (yyval.i) = META_ID(SK_WMEM_QUEUED); }
2010 #line 2011 "lib/route/cls/ematch_syntax.c"
2011 break;
2012
2013 case 51: /* meta_int_id: "sk_rcv_qlen" */
2014 #line 369 "lib/route/cls/ematch_syntax.y"
2015 { (yyval.i) = META_ID(SK_RCV_QLEN); }
2016 #line 2017 "lib/route/cls/ematch_syntax.c"
2017 break;
2018
2019 case 52: /* meta_int_id: "sk_snd_qlen" */
2020 #line 370 "lib/route/cls/ematch_syntax.y"
2021 { (yyval.i) = META_ID(SK_SND_QLEN); }
2022 #line 2023 "lib/route/cls/ematch_syntax.c"
2023 break;
2024
2025 case 53: /* meta_int_id: "sk_err_qlen" */
2026 #line 371 "lib/route/cls/ematch_syntax.y"
2027 { (yyval.i) = META_ID(SK_ERR_QLEN); }
2028 #line 2029 "lib/route/cls/ematch_syntax.c"
2029 break;
2030
2031 case 54: /* meta_int_id: "sk_forward_allocs" */
2032 #line 372 "lib/route/cls/ematch_syntax.y"
2033 { (yyval.i) = META_ID(SK_FORWARD_ALLOCS); }
2034 #line 2035 "lib/route/cls/ematch_syntax.c"
2035 break;
2036
2037 case 55: /* meta_int_id: "sk_allocs" */
2038 #line 373 "lib/route/cls/ematch_syntax.y"
2039 { (yyval.i) = META_ID(SK_ALLOCS); }
2040 #line 2041 "lib/route/cls/ematch_syntax.c"
2041 break;
2042
2043 case 56: /* meta_int_id: "sk_route_caps" */
2044 #line 374 "lib/route/cls/ematch_syntax.y"
2045 { (yyval.i) = __TCF_META_ID_SK_ROUTE_CAPS; }
2046 #line 2047 "lib/route/cls/ematch_syntax.c"
2047 break;
2048
2049 case 57: /* meta_int_id: "sk_hash" */
2050 #line 375 "lib/route/cls/ematch_syntax.y"
2051 { (yyval.i) = META_ID(SK_HASH); }
2052 #line 2053 "lib/route/cls/ematch_syntax.c"
2053 break;
2054
2055 case 58: /* meta_int_id: "sk_lingertime" */
2056 #line 376 "lib/route/cls/ematch_syntax.y"
2057 { (yyval.i) = META_ID(SK_LINGERTIME); }
2058 #line 2059 "lib/route/cls/ematch_syntax.c"
2059 break;
2060
2061 case 59: /* meta_int_id: "sk_ack_backlog" */
2062 #line 377 "lib/route/cls/ematch_syntax.y"
2063 { (yyval.i) = META_ID(SK_ACK_BACKLOG); }
2064 #line 2065 "lib/route/cls/ematch_syntax.c"
2065 break;
2066
2067 case 60: /* meta_int_id: "sk_max_ack_backlog" */
2068 #line 378 "lib/route/cls/ematch_syntax.y"
2069 { (yyval.i) = META_ID(SK_MAX_ACK_BACKLOG); }
2070 #line 2071 "lib/route/cls/ematch_syntax.c"
2071 break;
2072
2073 case 61: /* meta_int_id: "sk_prio" */
2074 #line 379 "lib/route/cls/ematch_syntax.y"
2075 { (yyval.i) = META_ID(SK_PRIO); }
2076 #line 2077 "lib/route/cls/ematch_syntax.c"
2077 break;
2078
2079 case 62: /* meta_int_id: "sk_rcvlowat" */
2080 #line 380 "lib/route/cls/ematch_syntax.y"
2081 { (yyval.i) = META_ID(SK_RCVLOWAT); }
2082 #line 2083 "lib/route/cls/ematch_syntax.c"
2083 break;
2084
2085 case 63: /* meta_int_id: "sk_rcvtimeo" */
2086 #line 381 "lib/route/cls/ematch_syntax.y"
2087 { (yyval.i) = META_ID(SK_RCVTIMEO); }
2088 #line 2089 "lib/route/cls/ematch_syntax.c"
2089 break;
2090
2091 case 64: /* meta_int_id: "sk_sndtimeo" */
2092 #line 382 "lib/route/cls/ematch_syntax.y"
2093 { (yyval.i) = META_ID(SK_SNDTIMEO); }
2094 #line 2095 "lib/route/cls/ematch_syntax.c"
2095 break;
2096
2097 case 65: /* meta_int_id: "sk_sendmsg_off" */
2098 #line 383 "lib/route/cls/ematch_syntax.y"
2099 { (yyval.i) = META_ID(SK_SENDMSG_OFF); }
2100 #line 2101 "lib/route/cls/ematch_syntax.c"
2101 break;
2102
2103 case 66: /* meta_int_id: "sk_write_pending" */
2104 #line 384 "lib/route/cls/ematch_syntax.y"
2105 { (yyval.i) = META_ID(SK_WRITE_PENDING); }
2106 #line 2107 "lib/route/cls/ematch_syntax.c"
2107 break;
2108
2109 case 67: /* meta_int_id: "vlan" */
2110 #line 385 "lib/route/cls/ematch_syntax.y"
2111 { (yyval.i) = META_ID(VLAN_TAG); }
2112 #line 2113 "lib/route/cls/ematch_syntax.c"
2113 break;
2114
2115 case 68: /* meta_int_id: "rxhash" */
2116 #line 386 "lib/route/cls/ematch_syntax.y"
2117 { (yyval.i) = META_ID(RXHASH); }
2118 #line 2119 "lib/route/cls/ematch_syntax.c"
2119 break;
2120
2121 case 69: /* meta_var_id: "devname" */
2122 #line 390 "lib/route/cls/ematch_syntax.y"
2123 { (yyval.i) = META_ID(DEV); }
2124 #line 2125 "lib/route/cls/ematch_syntax.c"
2125 break;
2126
2127 case 70: /* meta_var_id: "sk_bound_if" */
2128 #line 391 "lib/route/cls/ematch_syntax.y"
2129 { (yyval.i) = META_ID(SK_BOUND_IF); }
2130 #line 2131 "lib/route/cls/ematch_syntax.c"
2131 break;
2132
2133 case 71: /* pattern: QUOTED */
2134 #line 399 "lib/route/cls/ematch_syntax.y"
2135 {
2136 (yyval.q) = (yyvsp[0].q);
2137 }
2138 #line 2139 "lib/route/cls/ematch_syntax.c"
2139 break;
2140
2141 case 72: /* pattern: STR */
2142 #line 403 "lib/route/cls/ematch_syntax.y"
2143 {
2144 struct nl_addr *addr;
2145
2146 if (nl_addr_parse((yyvsp[0].s), AF_UNSPEC, &addr) == 0) {
2147 (yyval.q).len = nl_addr_get_len(addr);
2148
2149 (yyval.q).index = min_t(int, (yyval.q).len, nl_addr_get_prefixlen(addr)/8);
2150
2151 if (!((yyval.q).data = calloc(1, (yyval.q).len))) {
2152 nl_addr_put(addr);
2153 YYABORT;
2154 }
2155
2156 memcpy((yyval.q).data, nl_addr_get_binary_addr(addr), (yyval.q).len);
2157 nl_addr_put(addr);
2158 } else {
2159 if (asprintf(errp, "invalid pattern \"%s\"", (yyvsp[0].s)) == -1)
2160 *errp = NULL;
2161 YYABORT;
2162 }
2163 }
2164 #line 2165 "lib/route/cls/ematch_syntax.c"
2165 break;
2166
2167 case 73: /* pktloc: STR */
2168 #line 432 "lib/route/cls/ematch_syntax.y"
2169 {
2170 struct rtnl_pktloc *loc;
2171
2172 if (rtnl_pktloc_lookup((yyvsp[0].s), &loc) < 0) {
2173 if (asprintf(errp, "Packet location \"%s\" not found", (yyvsp[0].s)) == -1)
2174 *errp = NULL;
2175 YYABORT;
2176 }
2177
2178 (yyval.loc) = loc;
2179 }
2180 #line 2181 "lib/route/cls/ematch_syntax.c"
2181 break;
2182
2183 case 74: /* pktloc: align LAYER "+" NUMBER mask */
2184 #line 445 "lib/route/cls/ematch_syntax.y"
2185 {
2186 struct rtnl_pktloc *loc;
2187
2188 if ((yyvsp[0].i64) && (!(yyvsp[-4].i) || (yyvsp[-4].i) > TCF_EM_ALIGN_U32)) {
2189 *errp = strdup("mask only allowed for alignments u8|u16|u32");
2190 YYABORT;
2191 }
2192
2193 if (!(loc = rtnl_pktloc_alloc())) {
2194 *errp = strdup("Unable to allocate packet location object");
2195 YYABORT;
2196 }
2197
2198 loc->name = strdup("<USER-DEFINED>");
2199 loc->align = (yyvsp[-4].i);
2200 loc->layer = (yyvsp[-3].i);
2201 loc->offset = (yyvsp[-1].i);
2202 loc->mask = (yyvsp[0].i64);
2203
2204 (yyval.loc) = loc;
2205 }
2206 #line 2207 "lib/route/cls/ematch_syntax.c"
2207 break;
2208
2209 case 75: /* align: %empty */
2210 #line 470 "lib/route/cls/ematch_syntax.y"
2211 { (yyval.i) = 0; }
2212 #line 2213 "lib/route/cls/ematch_syntax.c"
2213 break;
2214
2215 case 76: /* align: ALIGN "at" */
2216 #line 472 "lib/route/cls/ematch_syntax.y"
2217 { (yyval.i) = (yyvsp[-1].i); }
2218 #line 2219 "lib/route/cls/ematch_syntax.c"
2219 break;
2220
2221 case 77: /* align: NUMBER "at" */
2222 #line 474 "lib/route/cls/ematch_syntax.y"
2223 { (yyval.i) = (yyvsp[-1].i); }
2224 #line 2225 "lib/route/cls/ematch_syntax.c"
2225 break;
2226
2227 case 78: /* mask: %empty */
2228 #line 479 "lib/route/cls/ematch_syntax.y"
2229 { (yyval.i64) = 0; }
2230 #line 2231 "lib/route/cls/ematch_syntax.c"
2231 break;
2232
2233 case 79: /* mask: "mask" NUMBER */
2234 #line 481 "lib/route/cls/ematch_syntax.y"
2235 { (yyval.i64) = (yyvsp[0].i); }
2236 #line 2237 "lib/route/cls/ematch_syntax.c"
2237 break;
2238
2239 case 80: /* shift: %empty */
2240 #line 486 "lib/route/cls/ematch_syntax.y"
2241 { (yyval.i) = 0; }
2242 #line 2243 "lib/route/cls/ematch_syntax.c"
2243 break;
2244
2245 case 81: /* shift: ">>" NUMBER */
2246 #line 488 "lib/route/cls/ematch_syntax.y"
2247 { (yyval.i) = (yyvsp[0].i); }
2248 #line 2249 "lib/route/cls/ematch_syntax.c"
2249 break;
2250
2251 case 82: /* operand: "=" */
2252 #line 493 "lib/route/cls/ematch_syntax.y"
2253 { (yyval.i) = TCF_EM_OPND_EQ; }
2254 #line 2255 "lib/route/cls/ematch_syntax.c"
2255 break;
2256
2257 case 83: /* operand: ">" */
2258 #line 495 "lib/route/cls/ematch_syntax.y"
2259 { (yyval.i) = TCF_EM_OPND_GT; }
2260 #line 2261 "lib/route/cls/ematch_syntax.c"
2261 break;
2262
2263 case 84: /* operand: "<" */
2264 #line 497 "lib/route/cls/ematch_syntax.y"
2265 { (yyval.i) = TCF_EM_OPND_LT; }
2266 #line 2267 "lib/route/cls/ematch_syntax.c"
2267 break;
2268
2269
2270 #line 2271 "lib/route/cls/ematch_syntax.c"
2271
2272 default: break;
2273 }
2274 /* User semantic actions sometimes alter yychar, and that requires
2275 that yytoken be updated with the new translation. We take the
2276 approach of translating immediately before every use of yytoken.
2277 One alternative is translating here after every semantic action,
2278 but that translation would be missed if the semantic action invokes
2279 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2280 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2281 incorrect destructor might then be invoked immediately. In the
2282 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2283 to an incorrect destructor call or verbose syntax error message
2284 before the lookahead is translated. */
2285 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
2286
2287 YYPOPSTACK (yylen);
2288 yylen = 0;
2289
2290 *++yyvsp = yyval;
2291
2292 /* Now 'shift' the result of the reduction. Determine what state
2293 that goes to, based on the state we popped back to and the rule
2294 number reduced by. */
2295 {
2296 const int yylhs = yyr1[yyn] - YYNTOKENS;
2297 const int yyi = yypgoto[yylhs] + *yyssp;
2298 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2299 ? yytable[yyi]
2300 : yydefgoto[yylhs]);
2301 }
2302
2303 goto yynewstate;
2304
2305
2306 /*--------------------------------------.
2307 | yyerrlab -- here on detecting error. |
2308 `--------------------------------------*/
2309 yyerrlab:
2310 /* Make sure we have latest lookahead translation. See comments at
2311 user semantic actions for why this is necessary. */
2312 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2313 /* If not already recovering from an error, report this error. */
2314 if (!yyerrstatus)
2315 {
2316 ++yynerrs;
2317 {
2318 yypcontext_t yyctx
2319 = {yyssp, yytoken};
2320 char const *yymsgp = YY_("syntax error");
2321 int yysyntax_error_status;
2322 yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
2323 if (yysyntax_error_status == 0)
2324 yymsgp = yymsg;
2325 else if (yysyntax_error_status == -1)
2326 {
2327 if (yymsg != yymsgbuf)
2328 YYSTACK_FREE (yymsg);
2329 yymsg = YY_CAST (char *,
2330 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
2331 if (yymsg)
2332 {
2333 yysyntax_error_status
2334 = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
2335 yymsgp = yymsg;
2336 }
2337 else
2338 {
2339 yymsg = yymsgbuf;
2340 yymsg_alloc = sizeof yymsgbuf;
2341 yysyntax_error_status = YYENOMEM;
2342 }
2343 }
2344 yyerror (scanner, errp, root, yymsgp);
2345 if (yysyntax_error_status == YYENOMEM)
2346 YYNOMEM;
2347 }
2348 }
2349
2350 if (yyerrstatus == 3)
2351 {
2352 /* If just tried and failed to reuse lookahead token after an
2353 error, discard it. */
2354
2355 if (yychar <= YYEOF)
2356 {
2357 /* Return failure if at end of input. */
2358 if (yychar == YYEOF)
2359 YYABORT;
2360 }
2361 else
2362 {
2363 yydestruct ("Error: discarding",
2364 yytoken, &yylval, scanner, errp, root);
2365 yychar = YYEMPTY;
2366 }
2367 }
2368
2369 /* Else will try to reuse lookahead token after shifting the error
2370 token. */
2371 goto yyerrlab1;
2372
2373
2374 /*---------------------------------------------------.
2375 | yyerrorlab -- error raised explicitly by YYERROR. |
2376 `---------------------------------------------------*/
2377 yyerrorlab:
2378 /* Pacify compilers when the user code never invokes YYERROR and the
2379 label yyerrorlab therefore never appears in user code. */
2380 if (0)
2381 YYERROR;
2382 ++yynerrs;
2383
2384 /* Do not reclaim the symbols of the rule whose action triggered
2385 this YYERROR. */
2386 YYPOPSTACK (yylen);
2387 yylen = 0;
2388 YY_STACK_PRINT (yyss, yyssp);
2389 yystate = *yyssp;
2390 goto yyerrlab1;
2391
2392
2393 /*-------------------------------------------------------------.
2394 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2395 `-------------------------------------------------------------*/
2396 yyerrlab1:
2397 yyerrstatus = 3; /* Each real token shifted decrements this. */
2398
2399 /* Pop stack until we find a state that shifts the error token. */
2400 for (;;)
2401 {
2402 yyn = yypact[yystate];
2403 if (!yypact_value_is_default (yyn))
2404 {
2405 yyn += YYSYMBOL_YYerror;
2406 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2407 {
2408 yyn = yytable[yyn];
2409 if (0 < yyn)
2410 break;
2411 }
2412 }
2413
2414 /* Pop the current state because it cannot handle the error token. */
2415 if (yyssp == yyss)
2416 YYABORT;
2417
2418
2419 yydestruct ("Error: popping",
2420 YY_ACCESSING_SYMBOL (yystate), yyvsp, scanner, errp, root);
2421 YYPOPSTACK (1);
2422 yystate = *yyssp;
2423 YY_STACK_PRINT (yyss, yyssp);
2424 }
2425
2426 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2427 *++yyvsp = yylval;
2428 YY_IGNORE_MAYBE_UNINITIALIZED_END
2429
2430
2431 /* Shift the error token. */
2432 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2433
2434 yystate = yyn;
2435 goto yynewstate;
2436
2437
2438 /*-------------------------------------.
2439 | yyacceptlab -- YYACCEPT comes here. |
2440 `-------------------------------------*/
2441 yyacceptlab:
2442 yyresult = 0;
2443 goto yyreturnlab;
2444
2445
2446 /*-----------------------------------.
2447 | yyabortlab -- YYABORT comes here. |
2448 `-----------------------------------*/
2449 yyabortlab:
2450 yyresult = 1;
2451 goto yyreturnlab;
2452
2453
2454 /*-----------------------------------------------------------.
2455 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2456 `-----------------------------------------------------------*/
2457 yyexhaustedlab:
2458 yyerror (scanner, errp, root, YY_("memory exhausted"));
2459 yyresult = 2;
2460 goto yyreturnlab;
2461
2462
2463 /*----------------------------------------------------------.
2464 | yyreturnlab -- parsing is finished, clean up and return. |
2465 `----------------------------------------------------------*/
2466 yyreturnlab:
2467 if (yychar != YYEMPTY)
2468 {
2469 /* Make sure we have latest lookahead translation. See comments at
2470 user semantic actions for why this is necessary. */
2471 yytoken = YYTRANSLATE (yychar);
2472 yydestruct ("Cleanup: discarding lookahead",
2473 yytoken, &yylval, scanner, errp, root);
2474 }
2475 /* Do not reclaim the symbols of the rule whose action triggered
2476 this YYABORT or YYACCEPT. */
2477 YYPOPSTACK (yylen);
2478 YY_STACK_PRINT (yyss, yyssp);
2479 while (yyssp != yyss)
2480 {
2481 yydestruct ("Cleanup: popping",
2482 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, scanner, errp, root);
2483 YYPOPSTACK (1);
2484 }
2485 #ifndef yyoverflow
2486 if (yyss != yyssa)
2487 YYSTACK_FREE (yyss);
2488 #endif
2489 if (yymsg != yymsgbuf)
2490 YYSTACK_FREE (yymsg);
2491 return yyresult;
2492 }
2493
nl_addr_get_binary_addr
void * nl_addr_get_binary_addr(const struct nl_addr *addr)
Get binary address of abstract address object.
Definition: addr.c:935
nl_addr_parse
int nl_addr_parse(const char *addrstr, int hint, struct nl_addr **result)
Allocate abstract address based on character string.
Definition: addr.c:292
nl_addr_get_prefixlen
unsigned int nl_addr_get_prefixlen(const struct nl_addr *addr)
Return prefix length of abstract address object.
Definition: addr.c:970
nl_addr_get_len
unsigned int nl_addr_get_len(const struct nl_addr *addr)
Get length of binary address of abstract address object.
Definition: addr.c:947
nl_addr_put
void nl_addr_put(struct nl_addr *addr)
Decrease the reference counter of an abstract address.
Definition: addr.c:533
rtnl_ematch_alloc
struct rtnl_ematch * rtnl_ematch_alloc(void)
Allocate ematch object.
Definition: ematch.c:103
rtnl_pktloc_lookup
int rtnl_pktloc_lookup(const char *name, struct rtnl_pktloc **result)
Lookup packet location alias.
Definition: pktloc.c:167
rtnl_pktloc_alloc
struct rtnl_pktloc * rtnl_pktloc_alloc(void)
Allocate packet location object.
Definition: pktloc.c:180
rtnl_pktloc_put
void rtnl_pktloc_put(struct rtnl_pktloc *loc)
Return reference of a packet location.
Definition: pktloc.c:197
nl_list_head
Definition: list.h:12
rtnl_pktloc
Definition: pktloc.h:20
yypcontext_t
Definition: ematch_syntax.c:1006
YYSTYPE
Definition: ematch_syntax.h:211
yyalloc
Definition: ematch_syntax.c:500