Skip to content

Commit

Permalink
mask tcp[tcpflags] with 0x0fff to provide tcp flags only
Browse files Browse the repository at this point in the history
  • Loading branch information
rscheff committed Dec 30, 2023
1 parent 31f3525 commit cb04b97
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion grammar.y.in
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,10 @@ arth: pnum { CHECK_PTR_VAL(($$ = gen_loadi(cstate, $1))); }
;
tcpflags: TCPFLAGS
;
narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, gen_loadi(cstate, 12), 2))); }
narth: pname '[' tcpflags ']' { CHECK_PTR_VAL(($$ =
gen_arth(cstate, BPF_AND,
gen_load(cstate, $1, gen_loadi(cstate, 12), 2),
gen_loadi(cstate, 0x0FFF)))); }
| pname '[' arth ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, 1))); }
| pname '[' arth ':' NUM ']' { CHECK_PTR_VAL(($$ = gen_load(cstate, $1, $3, $5))); }
| arth '+' arth { CHECK_PTR_VAL(($$ = gen_arth(cstate, BPF_ADD, $1, $3))); }
Expand Down

0 comments on commit cb04b97

Please sign in to comment.