ppp/ppp-filter.patch

52 lines
1.5 KiB
Diff
Raw Normal View History

--- pppd/demand.c.orig
+++ pppd/demand.c
@@ -45,6 +45,7 @@
#include <sys/socket.h>
#ifdef PPP_FILTER
#include <pcap-bpf.h>
+#include <linux/if_ether.h>
#endif
#include "pppd.h"
@@ -340,6 +341,7 @@ active_packet(p, len)
return 0;
proto = PPP_PROTOCOL(p);
#ifdef PPP_FILTER
+ *p = 1; /* set outbound for the filter rule */
p[0] = 1; /* outbound packet indicator */
if ((pass_filter.bf_len != 0
&& bpf_filter(pass_filter.bf_insns, p, len, len) == 0)
@@ -349,6 +351,7 @@ active_packet(p, len)
return 0;
}
p[0] = 0xff;
+ *p = 0xff; /* restore original ppp header */
#endif
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) {
--- pppd/options.c.orig
+++ pppd/options.c
@@ -1505,6 +1505,10 @@ setpassfilter(argv)
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
+ if (!pc) {
+ option_error("error in pass-filter expression: pcap_open_dead failed\n");
+ return 0;
+ }
if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == -1) {
option_error("error in pass-filter expression: %s\n",
pcap_geterr(pc));
@@ -1526,6 +1530,11 @@ setactivefilter(argv)
int ret = 1;
pc = pcap_open_dead(DLT_PPP_PPPD, 65535);
+ if (!pc) {
+ option_error("error in active-filter expression: pcap_open_dead failed\n");
+ return 0;
+ }
+
if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == -1) {
option_error("error in active-filter expression: %s\n",
pcap_geterr(pc));