add huawei_ether module
[tomato.git] / release / src / router / xl2tpd / contrib / pfc.c
blob9c6c2e823feb0e35eca8446e5c01ca94a7862435
1 /*
2 * Taken from fli4l 3.0
3 * Make sure you compile it against the same libpcap version used in OpenWrt
4 */
6 #include <stdlib.h>
7 #include <sys/types.h>
8 #include <sys/time.h>
9 #include <string.h>
11 #ifdef LINUX
12 # include <linux/types.h>
13 # include <linux/ppp_defs.h>
14 # include <pcap-bpf.h>
15 #endif
17 #ifdef OPENBSD
18 # include <net/ppp_defs.h>
19 #endif
21 #ifdef SOLARIS
22 # include <net/ppp_defs.h>
23 # define u_int32_t unsigned int
24 #endif
26 #include <pcap.h>
28 int main (int argc, char ** argv)
30 pcap_t *pc; /* Fake struct pcap so we can compile expr */
31 struct bpf_program filter; /* Filter program for link-active pkts */
32 u_int32_t netmask=0;
34 int dflag = 3;
35 if (argc == 4)
37 if (!strcmp (argv[1], "-d"))
39 dflag = atoi (argv[2]);
40 argv += 2;
41 argc -=2;
44 if (argc != 2)
46 printf ("usage; %s [ -d <debug_level> ] expression\n", argv[0]);
47 return 1;
50 pc = pcap_open_dead(DLT_PPP_PPPD, PPP_HDRLEN);
51 if (pcap_compile(pc, &filter, argv[1], 1, netmask) == 0)
53 printf ("#\n# Expression: %s\n#\n", argv[1]);
54 bpf_dump (&filter, dflag);
55 return 0;
57 else
59 printf("error in active-filter expression: %s\n", pcap_geterr(pc));
61 return 1;