2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
16 #include "bpf_parser.tab.h"
19 extern void yyerror(const char *);
37 number_dec {digit_n}|{digit_s}{digit}*
38 number_hex {digit_n}{hex_x}{hex}+
41 label {label_s}{label_me}+
45 "ldb" { return OP_LDB; }
46 "ldh" { return OP_LDH; }
47 "ld" { return OP_LD; }
48 "ldx" { return OP_LDX; }
49 "ldxb" { return OP_LDXB; }
50 "st" { return OP_ST; }
51 "stx" { return OP_STX; }
52 "jmp"|"ja" { return OP_JMP; }
53 "jeq" { return OP_JEQ; }
54 "jgt" { return OP_JGT; }
55 "jge" { return OP_JGE; }
56 "jset" { return OP_JSET; }
57 "add" { return OP_ADD; }
58 "sub" { return OP_SUB; }
59 "mul" { return OP_MUL; }
60 "div" { return OP_DIV; }
61 "and" { return OP_AND; }
62 "or" { return OP_OR; }
63 "lsh" { return OP_LSH; }
64 "rsh" { return OP_RSH; }
65 "ret" { return OP_RET; }
66 "tax" { return OP_TAX; }
67 "txa" { return OP_TXA; }
68 "len"|"pktlen" { return K_PKT_LEN; }
69 "proto" { return K_PROTO; }
70 "type" { return K_TYPE; }
71 "ifidx" { return K_IFIDX; }
72 "nla" { return K_NLATTR; }
73 "nlan" { return K_NLATTR_NEST; }
74 "mark" { return K_MARK; }
75 "queue" { return K_QUEUE; }
76 "hatype" { return K_HATYPE; }
77 "rxhash" { return K_RXHASH; }
78 "cpu" { return K_CPU; }
93 "/*"([^\*]|\*[^/])*"*/" { return K_COMMENT; }
95 {number_hex} { yylval.number = strtoul(yytext, NULL, 16);
98 {number_dec} { yylval.number = strtol(yytext, NULL, 10);
101 {label} { yylval.label = xstrdup(yytext);
104 ";"[^\n]* {/* NOP */}
107 . { printf("Unknown character '%s'", yytext);
108 yyerror("lex Unknown character"); }