blob: 4a2ce48d7c377ac40316e49072a1a9cf7861ea46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
%{
#include <netlink-local.h>
#include <netlink-tc.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
#include <netlink/route/pktloc.h>
%}
%locations
%error-verbose
%define api.pure
%name-prefix "pktloc_"
%parse-param {void *scanner}
%lex-param {void *scanner}
%expect 1
%union {
struct rtnl_pktloc *l;
uint32_t i;
char *s;
}
%{
extern int pktloc_lex(YYSTYPE *, YYLTYPE *, void *);
static void yyerror(YYLTYPE *locp, void *scanner, const char *msg)
{
NL_DBG(1, "Error while parsing packet location file: %s\n", msg);
}
%}
%token <i> ERROR NUMBER LAYER ALIGN
%token <s> NAME
%type <i> mask layer align shift
%type <l> location
%destructor { free($$); } NAME
%start input
%%
input:
/* empty */
| location input
;
location:
NAME align layer NUMBER mask shift
{
struct rtnl_pktloc *loc;
if (!(loc = rtnl_pktloc_alloc())) {
NL_DBG(1, "Allocating a packet location "
"object failed.\n");
YYABORT;
}
loc->name = $1;
loc->align = $2;
loc->layer = $3;
loc->offset = $4;
loc->mask = $5;
loc->shift = $6;
if (rtnl_pktloc_add(loc) < 0) {
NL_DBG(1, "Duplicate packet location entry "
"\"%s\"\n", $1);
}
$$ = loc;
}
;
align:
ALIGN
{ $$ = $1; }
| NUMBER
{ $$ = $1; }
;
layer:
/* empty */
{ $$ = TCF_LAYER_NETWORK; }
| LAYER '+'
{ $$ = $1; }
;
mask:
/* empty */
{ $$ = 0; }
| NUMBER
{ $$ = $1; }
;
shift:
/* empty */
{ $$ = 0; }
| NUMBER
{ $$ = $1; }
;
|