2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
4 * Swiss federal institute of technology (ETH Zurich)
5 * Subject to the GPL, version 2.
13 #include <sys/fsuid.h>
20 static const char *short_options
= "vhi:VdbD";
21 static const struct option long_options
[] = {
22 {"input", required_argument
, NULL
, 'i'},
23 {"verbose", no_argument
, NULL
, 'V'},
24 {"decimal", no_argument
, NULL
, 'D'},
25 {"bypass", no_argument
, NULL
, 'b'},
26 {"dump", no_argument
, NULL
, 'd'},
27 {"version", no_argument
, NULL
, 'v'},
28 {"help", no_argument
, NULL
, 'h'},
32 extern int compile_filter(char *file
, int verbose
, int bypass
, int decimal
);
34 static void help(void)
36 printf("\nbpfc %s, a tiny BPF compiler\n", VERSION_STRING
);
37 puts("http://www.netsniff-ng.org\n\n"
38 "Usage: bpfc [options] || bpfc <program>\n"
40 " -i|--input <program/-> Berkeley Packet Filter file/stdin\n"
41 " -D|--decimal Decimal output, e.g. for xt_bpf\n"
42 " -V|--verbose Be more verbose\n"
43 " -b|--bypass Bypass filter validation (e.g. for bug testing)\n"
44 " -d|--dump Dump supported instruction table\n"
45 " -v|--version Print version\n"
46 " -h|--help Print this help\n\n"
50 " bpfc - (read from stdin)\n\n"
51 "Please report bugs to <bugs@netsniff-ng.org>\n"
52 "Copyright (C) 2011-2013 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,\n"
53 "Swiss federal institute of technology (ETH Zurich)\n"
54 "License: GNU GPL version 2.0\n"
55 "This is free software: you are free to change and redistribute it.\n"
56 "There is NO WARRANTY, to the extent permitted by law.\n");
60 static void version(void)
62 printf("\nbpfc %s, a tiny BPF compiler\n", VERSION_STRING
);
63 puts("http://www.netsniff-ng.org\n\n"
64 "Please report bugs to <bugs@netsniff-ng.org>\n"
65 "Copyright (C) 2011-2013 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,\n"
66 "Swiss federal institute of technology (ETH Zurich)\n"
67 "License: GNU GPL version 2.0\n"
68 "This is free software: you are free to change and redistribute it.\n"
69 "There is NO WARRANTY, to the extent permitted by law.\n");
73 int main(int argc
, char **argv
)
75 int ret
, verbose
= 0, c
, opt_index
, bypass
= 0, decimal
= 0;
84 while ((c
= getopt_long(argc
, argv
, short_options
,
85 long_options
, &opt_index
)) != EOF
) {
106 file
= xstrdup(optarg
);
111 panic("Option -%c requires an argument!\n",
115 printf("Unknown option character `0x%X\'!\n", optopt
);
124 file
= xstrdup(argv
[1]);
126 panic("No Berkeley Packet Filter program specified!\n");
128 ret
= compile_filter(file
, verbose
, bypass
, decimal
);