Root/package/ppp/utils/pfc.c

1/*
2 * Taken from fli4l 3.0
3 * Make sure you compile it against the same libpcap version used in OpenWrt
4 */
5
6#include <stdlib.h>
7#include <sys/types.h>
8#include <sys/time.h>
9#include <string.h>
10
11#include <linux/types.h>
12#include <linux/ppp_defs.h>
13
14#include <pcap.h>
15#include <pcap-bpf.h>
16
17int main (int argc, char ** argv)
18{
19    pcap_t *pc; /* Fake struct pcap so we can compile expr */
20    struct bpf_program filter; /* Filter program for link-active pkts */
21    u_int32_t netmask=0;
22
23    int dflag = 3;
24    if (argc == 4)
25    {
26    if (!strcmp (argv[1], "-d"))
27    {
28        dflag = atoi (argv[2]);
29        argv += 2;
30        argc -=2;
31    }
32    }
33    if (argc != 2)
34    {
35    printf ("usage; %s [ -d <debug_level> ] expression\n", argv[0]);
36    return 1;
37    }
38
39    pc = pcap_open_dead(DLT_PPP_PPPD, PPP_HDRLEN);
40    if (pcap_compile(pc, &filter, argv[1], 1, netmask) == 0)
41    {
42    printf ("#\n# Expression: %s\n#\n", argv[1]);
43    bpf_dump (&filter, dflag);
44    return 0;
45    }
46    else
47    {
48    printf("error in active-filter expression: %s\n", pcap_geterr(pc));
49    }
50    return 1;
51}
52

Archive Download this file



interactive