Skip to content

Commit 4b8ca33

Browse files
committed
"tcp[tcpflags]" allow access to all flag bits including tcp-ae
1 parent e3e4c57 commit 4b8ca33

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

grammar.y.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ DIAG_OFF_BISON_BYACC
389389

390390
%token DST SRC HOST GATEWAY
391391
%token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
392-
%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP CARP
392+
%token ARP RARP IP SCTP TCP TCPFLAGS UDP ICMP IGMP IGRP PIM VRRP CARP
393393
%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
394394
%token TK_BROADCAST TK_MULTICAST
395395
%token NUM INBOUND OUTBOUND
@@ -852,7 +852,10 @@ irelop: LEQ { $$ = BPF_JGT; }
852852
arth: pnum { CHECK_PTR_VAL(($$ = gen_loadi(cstate, $1))); }
853853
| narth
854854
;
855-
narth: pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
855+
tcpflags: TCPFLAGS
856+
;
857+
narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, gen_loadi(cstate, 12), 2))); }
858+
| pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
856859
| pname '[' arth ':' NUM ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, $5))); }
857860
| arth '+' arth { CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_ADD, $1, $3))); }
858861
| arth '-' arth { CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_SUB, $1, $3))); }

scanner.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ rarp return RARP;
276276
ip return IP;
277277
sctp return SCTP;
278278
tcp return TCP;
279+
tcpflags return TCPFLAGS;
279280
udp return UDP;
280281
icmp return ICMP;
281282
igmp return IGMP;
@@ -483,7 +484,6 @@ icmp6-multicastrouteradvert { yylval->h = 151; return NUM; }
483484
icmp6-multicastroutersolicit { yylval->h = 152; return NUM; }
484485
icmp6-multicastrouterterm { yylval->h = 153; return NUM; }
485486

486-
tcpflags { yylval->h = 13; return NUM; }
487487
tcp-fin { yylval->h = 0x01; return NUM; }
488488
tcp-syn { yylval->h = 0x02; return NUM; }
489489
tcp-rst { yylval->h = 0x04; return NUM; }
@@ -492,6 +492,7 @@ tcp-ack { yylval->h = 0x10; return NUM; }
492492
tcp-urg { yylval->h = 0x20; return NUM; }
493493
tcp-ece { yylval->h = 0x40; return NUM; }
494494
tcp-cwr { yylval->h = 0x80; return NUM; }
495+
tcp-ae { yylval->h = 0x100; return NUM; }
495496
[A-Za-z0-9]([-_.A-Za-z0-9]*[.A-Za-z0-9])? {
496497
yylval->s = sdup(yyextra, (char *)yytext); return ID; }
497498
"\\"[^ !()\n\t]+ { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }

0 commit comments

Comments
 (0)