1 --- a/pppd/Makefile.linux
2 +++ b/pppd/Makefile.linux
3 @@ -50,6 +50,9 @@ MPPE=y
4 # and that the kernel driver support PPP packet filtering.
7 +# Support for precompiled filters
10 # Uncomment the next line to enable multilink PPP (enabled by default)
11 # Linux distributions: Please leave multilink ENABLED in your builds
13 @@ -175,6 +178,14 @@ CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)
17 +ifdef PRECOMPILED_FILTER
18 +PPPDSRCS += pcap_pcc.c
19 +HEADERS += pcap_pcc.h
20 +PPPDOBJS += pcap_pcc.o
21 +LIBS += $(STAGING_DIR)/usr/lib/libpcap.a
22 +CFLAGS += -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I$(STAGING_DIR)/usr/include
26 PPPDSRCS += ipv6cp.c eui64.c
27 HEADERS += ipv6cp.h eui64.h
34 +#include <pcap-bpf.h>
36 * There have been 3 or 4 different names for this in libpcap CVS, but
37 * this seems to be what they have settled on...
38 @@ -160,6 +161,13 @@ static int setlogfile __P((char **));
39 static int loadplugin __P((char **));
42 +#ifdef PPP_PRECOMPILED_FILTER
43 +#include "pcap_pcc.h"
44 +static int setprecompiledpassfilter __P((char **));
45 +static int setprecompiledactivefilter __P((char **));
50 static int setpassfilter __P((char **));
51 static int setactivefilter __P((char **));
52 @@ -317,6 +325,14 @@ option_t general_options[] = {
53 "set filter for active pkts", OPT_PRIO },
56 +#ifdef PPP_PRECOMPILED_FILTER
57 + { "precompiled-pass-filter", 1, setprecompiledpassfilter,
58 + "set precompiled filter for packets to pass", OPT_PRIO },
60 + { "precompiled-active-filter", 1, setprecompiledactivefilter,
61 + "set precompiled filter for active pkts", OPT_PRIO },
65 { "maxoctets", o_int, &maxoctets,
66 "Set connection traffic limit",
67 @@ -1463,6 +1479,29 @@ callfile(argv)
71 +#ifdef PPP_PRECOMPILED_FILTER
73 + * setprecompiledpassfilter - Set the pass filter for packets using a
74 + * precompiled expression
77 +setprecompiledpassfilter(argv)
80 + return pcap_pre_compiled (*argv, &pass_filter);
84 + * setactivefilter - Set the active filter for packets
87 +setprecompiledactivefilter(argv)
90 + return pcap_pre_compiled (*argv, &active_filter);
96 * setpassfilter - Set the pass filter for packets
101 +#include <pcap-bpf.h>
108 +int pcap_pre_compiled (char * fname, struct bpf_program *p)
111 + int line = 0, size = 0, index=0, ret=1;
112 + FILE *f = fopen (fname, "r");
115 + option_error("error opening precompiled active-filter '%s': %s",
116 + fname, strerror (errno));
119 + while (fgets (buf, 127, f))
134 + struct bpf_insn * insn = & p->bf_insns[index];
135 + unsigned code, jt, jf, k;
136 + if (sscanf (buf, "%u %u %u %u", &code, &jt, &jf, &k) != 4)
148 + if (sscanf (buf, "%u", &size) != 1)
153 + p->bf_insns = (struct bpf_insn *)
154 + malloc (size * sizeof (struct bpf_insn));
159 + option_error("error in precompiled active-filter,"
160 + " expected %d expressions, got %dn",
168 + option_error("error in precompiled active-filter"
169 + " expression line %s:%d (wrong size)\n",
175 +++ b/pppd/pcap_pcc.h
182 +int pcap_pre_compiled (char * fname, struct bpf_program *p);
183 +#endif /* PCAP_PCC_H */