2 * Minimal BPF assembler
4 * Instead of libpcap high-level filter expressions, it can be quite
5 * useful to define filters in low-level BPF assembler (that is kept
6 * close to Steven McCanne and Van Jacobson's original BPF paper).
7 * In particular for BPF JIT implementors, JIT security auditors, or
8 * just for defining BPF expressions that contain extensions which are
9 * not supported by compilers.
13 * 1) read Documentation/networking/filter.txt
14 * 2) Run `bpf_asm [-c] <filter-prog file>` to translate into binary
15 * blob that is loadable with xt_bpf, cls_bpf et al. Note: -c will
16 * pretty print a C-like construct.
18 * Copyright 2013 Daniel Borkmann <borkmann@redhat.com>
19 * Licensed under the GNU General Public License, version 2.0 (GPLv2)
26 extern void bpf_asm_compile(FILE *fp
, bool cstyle
);
28 int main(int argc
, char **argv
)
34 for (i
= 1; i
< argc
; i
++) {
35 if (!strncmp("-c", argv
[i
], 2)) {
40 fp
= fopen(argv
[i
], "r");
49 bpf_asm_compile(fp
, cstyle
);