2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
9 /* yaac-func-prefix: zz */
13 - intermediate representation
14 - code optimization (symbolic reduction?)
15 - linearization (jumps, etc)
28 #include "bpf_hla_parser.tab.h"
29 #include "bpf_symtab.h"
35 #define YYERROR_VERBOSE 0
37 #define YYENABLE_NLS 1
38 #define YYLTYPE_IS_TRIVIAL 1
42 extern
int zzlex
(void);
43 extern
void zzerror
(const char *);
47 int compile_hla_filter
(char *file
, int verbose
, int debug
);
56 %token K_NAME K_DEF K_PKT K_RET K_IF K_ELIF K_ELSE
57 %token K_MACRO_IPV4 K_MACRO_IPV6 K_MACRO_IP K_MACRO_UDP K_MACRO_TCP
61 %token
'(' ')' '{' '}' '=' ';' '+' '-' '&' '|' '^' '!' '<' '>' '*' '/' '%' ','
68 : { printf
("Not supported yet!\n"); }
73 static void stage_1_compile
(void)
78 int compile_hla_filter
(char *file
, int verbose
, int debug
)
87 if
(!strncmp
("-", file
, strlen
("-")))
90 zzin
= fopen
(file
, "r");
92 panic
("Cannot open file!\n");
94 fd
= dup
(fileno
(stdout
));
96 slprintf
(file_tmp
, sizeof
(file_tmp
), ".%s", file
);
97 if
(freopen
(file_tmp
, "w", stdout
) == NULL
)
98 panic
("Cannot reopen file!\n");
105 dup2
(fd
, fileno
(stdout
));
109 fsetpos
(stdout
, &pos
);
114 bpf_symtab_cleanup
();
121 void zzerror
(const char *err
)
123 panic
("Syntax error at line %d: %s! %s!\n",
124 zzlineno
, zztext
, err
);