From 4584b955420cd8d2fcae767c86b853fde4bccc6e Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Thu, 23 May 2013 11:08:03 +0200 Subject: bpfc: allow bpf programs to be passed to cpp This patch allows bpf programs to be passed to the C preprocessor before handing over to bpfc. Example: #define ETH_P_IP 0x800 ldh [12] jne #ETH_P_IP, drop ldb [23] jneq #6, drop ldh [20] jset #0x1fff, drop ldxb 4 * ([14] & 0xf) ldh [x + 14] jeq #0x16, pass ldh [x + 16] jne #0x16, drop pass: ret #-1 drop: ret #0 Compile with: bpfc -i foo -p Suggested-by: John Lange Signed-off-by: Daniel Borkmann --- bpf_lexer.l | 1 + 1 file changed, 1 insertion(+) (limited to 'bpf_lexer.l') diff --git a/bpf_lexer.l b/bpf_lexer.l index a2ff90a..185faae 100644 --- a/bpf_lexer.l +++ b/bpf_lexer.l @@ -119,6 +119,7 @@ label [a-zA-Z_][a-zA-Z0-9_]+ "/*"([^\*]|\*[^/])*"*/" { /* NOP */ } ";"[^\n]* {/* NOP */} +^#.* {/* NOP */} "\n" { yylineno++; } [ \t]+ {/* NOP */ } . { printf("Unknown character '%s'", yytext); -- cgit v1.2.3-54-g00ecf