blob: 07e7e8c6aab8fc061c239ec8d70bf8b6896d8807 (
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
/*
* lib/route/cls/ematch_grammar.l ematch expression grammar
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* Copyright (c) 2010 Thomas Graf <tgraf@suug.ch>
*/
%{
#include <netlink-local.h>
#include <netlink-tc.h>
#include <netlink/netlink.h>
#include <netlink/route/cls/ematch.h>
#include <netlink/route/cls/ematch/cmp.h>
#include "ematch_syntax.h"
%}
%option 8bit
%option reentrant
%option warn
%option noyywrap
%option noinput
%option nounput
%option bison-bridge
%option prefix="ematch_"
%x QUOTE
%%
[ \t\r\n]+
\" {
NL_DBG(4, "Beginning of quote\n");
yylval->q.len = 32;
if (!(yylval->q.data = calloc(1, yylval->q.len)))
return ERROR;
yylval->q.index = 0;
BEGIN(QUOTE);
}
<QUOTE>[^\\\n\"]+ {
memcpy(yylval->q.data + yylval->q.index, yytext,
strlen(yytext));
yylval->q.index += strlen(yytext);
}
<QUOTE>\" {
BEGIN(0);
return QUOTED;
}
[[:digit:]]+ |
0[xX][[:xdigit:]]+ {
yylval->i = strtoul(yytext, NULL, 0);
return NUMBER;
}
eq |
"=" return KW_EQ;
gt |
">" return KW_GT;
lt |
"<" return KW_LT;
[aA][nN][dD] |
"&&" { yylval->i = TCF_EM_REL_AND; return LOGIC; }
[oO][rR] |
"||" { yylval->i = TCF_EM_REL_OR; return LOGIC; }
[nN][oO][tT] |
"!" return NOT;
[cC][mM][pP] { yylval->i = TCF_EM_CMP; return EMATCH_CMP; }
[pP][aA][tT][tT][eE][rR][nN] { yylval->i = TCF_EM_NBYTE; return EMATCH_NBYTE; }
[tT][eE][xX][tT] { yylval->i = TCF_EM_TEXT; return EMATCH_TEXT; }
[mM][eE][tT][aA] { yylval->i = TCF_EM_META; return EMATCH_META; }
"(" return KW_OPEN;
")" return KW_CLOSE;
[mM][aA][sS][kK] |
"&" return KW_MASK;
[sS][hH][iI][fF][tT] |
">>" return KW_SHIFT;
[aA][tT] return KW_AT;
"+" return KW_PLUS;
[fF][rR][oO][mM] return KW_FROM;
[tT][oO] return KW_TO;
[uU]8 { yylval->i = TCF_EM_ALIGN_U8; return ALIGN; }
[uU]16 { yylval->i = TCF_EM_ALIGN_U16; return ALIGN; }
[uU]32 { yylval->i = TCF_EM_ALIGN_U32; return ALIGN; }
[lL][iI][nN][kK] |
[eE][tT][hH] { yylval->i = TCF_LAYER_LINK; return LAYER; }
[nN][eE][tT] |
[iI][pP]6 |
[iI][pP] { yylval->i = TCF_LAYER_NETWORK; return LAYER; }
[tT][rR][aA][nN][sS][pP][oO][rR][tT] |
[tT][cC][pP] { yylval->i = TCF_LAYER_TRANSPORT; return LAYER; }
random return META_RANDOM;
loadavg_0 return META_LOADAVG_0;
loadavg_1 return META_LOADAVG_1;
loadavg_2 return META_LOADAVG_2;
dev return META_DEV;
prio return META_PRIO;
proto return META_PROTO;
pkttype return META_PKTTYPE;
pktlen return META_PKTLEN;
datalen return META_DATALEN;
maclen return META_MACLEN;
mark return META_MARK;
tcindex return META_TCINDEX;
rtclassid return META_RTCLASSID;
rtiif return META_RTIIF;
sk_family return META_SK_FAMILY;
sk_state return META_SK_STATE;
sk_reuse return META_SK_REUSE;
sk_refcnt return META_SK_REFCNT;
sk_rcvbuf return META_SK_RCVBUF;
sk_sndbuf return META_SK_SNDBUF;
sk_shutdown return META_SK_SHUTDOWN;
sk_proto return META_SK_PROTO;
sk_type return META_SK_TYPE;
sk_rmem_alloc return META_SK_RMEM_ALLOC;
sk_wmem_alloc return META_SK_WMEM_ALLOC;
sk_wmem_queued return META_SK_WMEM_QUEUED;
sk_rcv_qlen return META_SK_RCV_QLEN;
sk_snd_qlen return META_SK_SND_QLEN;
sk_err_qlen return META_SK_ERR_QLEN;
sk_forward_allocs return META_SK_FORWARD_ALLOCS;
sk_allocs return META_SK_ALLOCS;
sk_route_caps return META_SK_ROUTE_CAPS;
sk_hash return META_SK_HASH;
sk_lingertime return META_SK_LINGERTIME;
sk_ack_backlog return META_SK_ACK_BACKLOG;
sk_max_ack_backlog return META_SK_MAX_ACK_BACKLOG;
sk_prio return META_SK_PRIO;
sk_rcvlowat return META_SK_RCVLOWAT;
sk_rcvtimeo return META_SK_RCVTIMEO;
sk_sndtimeo return META_SK_SNDTIMEO;
sk_sendmsg_off return META_SK_SENDMSG_OFF;
sk_write_pending return META_SK_WRITE_PENDING;
vlan return META_VLAN;
rxhash return META_RXHASH;
devname return META_DEVNAME;
sk_bound_if return META_SK_BOUND_IF;
[^ \t\r\n+()=<>&|\"]+ {
yylval->s = strdup(yytext);
if (yylval->s == NULL)
return ERROR;
NL_DBG(4, "lex STR=%s\n", yylval->s);
return STR;
}
|