diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-05 04:32:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-09-05 04:32:47 +0000 |
commit | b71266f31dfafe8f3e5d070002f8723933b73b70 (patch) | |
tree | d8bb8433daa58479a56c78421ffcb4a5c295091a /usr.sbin/pppd/demand.c | |
parent | 37097dc262c90509c88f1b095ef6a287b23412b0 (diff) |
ppp 2.3.1
Diffstat (limited to 'usr.sbin/pppd/demand.c')
-rw-r--r-- | usr.sbin/pppd/demand.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/usr.sbin/pppd/demand.c b/usr.sbin/pppd/demand.c index dfe8212a729..f249bceb375 100644 --- a/usr.sbin/pppd/demand.c +++ b/usr.sbin/pppd/demand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: demand.c,v 1.3 1996/12/23 13:22:40 mickey Exp $ */ +/* $OpenBSD: demand.c,v 1.4 1997/09/05 04:32:37 millert Exp $ */ /* * demand.c - Support routines for demand-dialling. @@ -20,7 +20,11 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: demand.c,v 1.3 1996/12/23 13:22:40 mickey Exp $"; +#if 0 +static char rcsid[] = "Id: demand.c,v 1.6 1997/04/30 05:51:56 paulus Exp"; +#else +static char rcsid[] = "$OpenBSD: demand.c,v 1.4 1997/09/05 04:32:37 millert Exp $"; +#endif #endif #include <stdio.h> @@ -38,12 +42,15 @@ static char rcsid[] = "$OpenBSD: demand.c,v 1.3 1996/12/23 13:22:40 mickey Exp $ #include <sys/stat.h> #include <sys/socket.h> #include <net/if.h> +#ifdef PPP_FILTER +#include <net/bpf.h> +#include <pcap.h> +#endif #include "pppd.h" #include "fsm.h" #include "ipcp.h" #include "lcp.h" -#include "bpf_compile.h" char *frame; int framelen; @@ -88,7 +95,7 @@ demand_conf() ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0); ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0); -#if 0 +#ifdef PPP_FILTER set_filters(&pass_filter, &active_filter); #endif @@ -249,6 +256,10 @@ loop_chars(p, n) * decide whether to bring up the link or not, and, if we want * to transmit this frame later, put it on the pending queue. * Return value is 1 if we need to bring up the link, 0 otherwise. + * We assume that the kernel driver has already applied the + * pass_filter, so we won't get packets it rejected. + * We apply the active_filter to see if we want this packet to + * bring up the link. */ int loop_frame(frame, len) @@ -257,7 +268,7 @@ loop_frame(frame, len) { struct packet *pkt; - /* log_packet(frame, len, "from loop: "); */ + /* log_packet(frame, len, "from loop: ", LOG_DEBUG); */ if (len < PPP_HDRLEN) return 0; if ((PPP_PROTOCOL(frame) & 0x8000) != 0) @@ -321,20 +332,23 @@ active_packet(p, len) { int proto, i; struct protent *protp; - + if (len < PPP_HDRLEN) - return 0; + return 0; proto = PPP_PROTOCOL(p); +#ifdef PPP_FILTER + if (active_filter.bf_len != 0 + && bpf_filter(active_filter.bf_insns, frame, len, len) == 0) + return 0; +#endif for (i = 0; (protp = protocols[i]) != NULL; ++i) { - if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { - if (!protp->enabled_flag) - return 0; - if (protp->active_pkt == NULL) - return 1; - return (*protp->active_pkt)(p, len); - } + if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { + if (!protp->enabled_flag) + return 0; + if (protp->active_pkt == NULL) + return 1; + return (*protp->active_pkt)(p, len); + } } - return 0; /* not a supported protocol !!?? */ -} - - + return 0; /* not a supported protocol !!?? */ +} |