1 Index: ppp-2.4.3/pppd/Makefile.linux
2 ===================================================================
3 --- ppp-2.4.3.orig/pppd/Makefile.linux 2007-06-04 13:22:14.133706632 +0200
4 +++ ppp-2.4.3/pppd/Makefile.linux 2007-06-04 13:22:14.320678208 +0200
6 # and that the kernel driver support PPP packet filtering.
9 +# Support for precompiled filters
12 # Uncomment the next line to enable multilink PPP (enabled by default)
13 # Linux distributions: Please leave multilink ENABLED in your builds
19 +ifdef PRECOMPILED_FILTER
20 +PPPDSRCS += pcap_pcc.c
21 +HEADERS += pcap_pcc.h
22 +PPPDOBJS += pcap_pcc.o
23 +LIBS += $(STAGING_DIR)/usr/lib/libpcap.a
24 +CFLAGS += -DPPP_FILTER -DPPP_PRECOMPILED_FILTER -I$(STAGING_DIR)/usr/include
28 PPPDSRCS += ipv6cp.c eui64.c
29 HEADERS += ipv6cp.h eui64.h
30 Index: ppp-2.4.3/pppd/demand.c
31 ===================================================================
32 --- ppp-2.4.3.orig/pppd/demand.c 2007-06-04 13:22:11.613089824 +0200
33 +++ ppp-2.4.3/pppd/demand.c 2007-06-04 13:22:14.320678208 +0200
36 proto = PPP_PROTOCOL(p);
38 + *p = 1; /* set outbound for the filter rule */
39 if (pass_filter.bf_len != 0
40 && bpf_filter(pass_filter.bf_insns, p, len, len) == 0)
42 if (active_filter.bf_len != 0
43 && bpf_filter(active_filter.bf_insns, p, len, len) == 0)
45 + *p = 0xff; /* restore original ppp header */
47 for (i = 0; (protp = protocols[i]) != NULL; ++i) {
48 if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) {
49 Index: ppp-2.4.3/pppd/options.c
50 ===================================================================
51 --- ppp-2.4.3.orig/pppd/options.c 2007-06-04 13:22:09.005486240 +0200
52 +++ ppp-2.4.3/pppd/options.c 2007-06-04 13:22:14.321678056 +0200
58 - * DLT_PPP_WITH_DIRECTION is in current libpcap cvs, and should be in
59 - * libpcap-0.8.4. Until that is released, use DLT_PPP - but that means
60 - * we lose the inbound and outbound qualifiers.
62 -#ifndef DLT_PPP_WITH_DIRECTION
63 -#define DLT_PPP_WITH_DIRECTION DLT_PPP
65 +#include <pcap-bpf.h>
70 static int loadplugin __P((char **));
73 +#ifdef PPP_PRECOMPILED_FILTER
74 +#include "pcap_pcc.h"
75 +static int setprecompiledpassfilter __P((char **));
76 +static int setprecompiledactivefilter __P((char **));
81 static int setpassfilter __P((char **));
82 static int setactivefilter __P((char **));
84 "set filter for active pkts", OPT_PRIO },
87 +#ifdef PPP_PRECOMPILED_FILTER
88 + { "precompiled-pass-filter", 1, setprecompiledpassfilter,
89 + "set precompiled filter for packets to pass", OPT_PRIO },
91 + { "precompiled-active-filter", 1, setprecompiledactivefilter,
92 + "set precompiled filter for active pkts", OPT_PRIO },
96 { "maxoctets", o_int, &maxoctets,
97 "Set connection traffic limit",
98 @@ -1447,6 +1455,29 @@
102 +#ifdef PPP_PRECOMPILED_FILTER
104 + * setprecompiledpassfilter - Set the pass filter for packets using a
105 + * precompiled expression
108 +setprecompiledpassfilter(argv)
111 + return pcap_pre_compiled (*argv, &pass_filter);
115 + * setactivefilter - Set the active filter for packets
118 +setprecompiledactivefilter(argv)
121 + return pcap_pre_compiled (*argv, &active_filter);
127 * setpassfilter - Set the pass filter for packets
128 @@ -1458,7 +1489,7 @@
132 - pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
133 + pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
134 if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) {
135 option_error("error in pass-filter expression: %s\n",
137 @@ -1479,7 +1510,7 @@
141 - pc = pcap_open_dead(DLT_PPP_WITH_DIRECTION, 65535);
142 + pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
143 if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) {
144 option_error("error in active-filter expression: %s\n",
146 Index: ppp-2.4.3/pppd/pcap_pcc.c
147 ===================================================================
148 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
149 +++ ppp-2.4.3/pppd/pcap_pcc.c 2007-06-04 13:22:14.321678056 +0200
152 +#include <pcap-bpf.h>
159 +int pcap_pre_compiled (char * fname, struct bpf_program *p)
162 + int line = 0, size = 0, index=0, ret=1;
163 + FILE *f = fopen (fname, "r");
166 + option_error("error opening precompiled active-filter '%s': %s",
167 + fname, strerror (errno));
170 + while (fgets (buf, 127, f))
185 + struct bpf_insn * insn = & p->bf_insns[index];
186 + unsigned code, jt, jf, k;
187 + if (sscanf (buf, "%u %u %u %u", &code, &jt, &jf, &k) != 4)
199 + if (sscanf (buf, "%u", &size) != 1)
204 + p->bf_insns = (struct bpf_insn *)
205 + malloc (size * sizeof (struct bpf_insn));
210 + option_error("error in precompiled active-filter,"
211 + " expected %d expressions, got %dn",
219 + option_error("error in precompiled active-filter"
220 + " expression line %s:%d (wrong size)\n",
225 Index: ppp-2.4.3/pppd/pcap_pcc.h
226 ===================================================================
227 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
228 +++ ppp-2.4.3/pppd/pcap_pcc.h 2007-06-04 13:22:14.321678056 +0200
235 +int pcap_pre_compiled (char * fname, struct bpf_program *p);
236 +#endif /* PCAP_PCC_H */