Skip to content

Commit fc914fb

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

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
@@ -391,7 +391,7 @@ DIAG_OFF_BISON_BYACC
391391

392392
%token DST SRC HOST GATEWAY
393393
%token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
394-
%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP CARP
394+
%token ARP RARP IP SCTP TCP TCPFLAGS UDP ICMP IGMP IGRP PIM VRRP CARP
395395
%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
396396
%token TK_BROADCAST TK_MULTICAST
397397
%token NUM INBOUND OUTBOUND
@@ -854,7 +854,10 @@ irelop: LEQ { $$ = BPF_JGT; }
854854
arth: pnum { CHECK_PTR_VAL(($$ = gen_loadi(cstate, $1))); }
855855
| narth
856856
;
857-
narth: pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
857+
tcpflags: TCPFLAGS
858+
;
859+
narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, gen_loadi(cstate, 12), 2))); }
860+
| pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
858861
| pname '[' arth ':' NUM ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, $5))); }
859862
| arth '+' arth { CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_ADD, $1, $3))); }
860863
| 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
@@ -283,6 +283,7 @@ rarp return RARP;
283283
ip return IP;
284284
sctp return SCTP;
285285
tcp return TCP;
286+
tcpflags return TCPFLAGS;
286287
udp return UDP;
287288
icmp return ICMP;
288289
igmp return IGMP;
@@ -490,7 +491,6 @@ icmp6-multicastrouteradvert { yylval->h = 151; return NUM; }
490491
icmp6-multicastroutersolicit { yylval->h = 152; return NUM; }
491492
icmp6-multicastrouterterm { yylval->h = 153; return NUM; }
492493

493-
tcpflags { yylval->h = 13; return NUM; }
494494
tcp-fin { yylval->h = 0x01; return NUM; }
495495
tcp-syn { yylval->h = 0x02; return NUM; }
496496
tcp-rst { yylval->h = 0x04; return NUM; }
@@ -499,6 +499,7 @@ tcp-ack { yylval->h = 0x10; return NUM; }
499499
tcp-urg { yylval->h = 0x20; return NUM; }
500500
tcp-ece { yylval->h = 0x40; return NUM; }
501501
tcp-cwr { yylval->h = 0x80; return NUM; }
502+
tcp-ae { yylval->h = 0x100; return NUM; }
502503
[A-Za-z0-9]([-_.A-Za-z0-9]*[.A-Za-z0-9])? {
503504
yylval->s = sdup(yyextra, (char *)yytext); return ID; }
504505
"\\"[^ !()\n\t]+ { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; }

0 commit comments

Comments
 (0)