$NetBSD: patch-ag,v 1.1.1.1 1999/10/08 04:34:43 dbj Exp $ Index: pppd/options.c diff -u pppd/options.c:1.1.1.5 pppd/options.c:1.30 --- pppd/options.c:1.1.1.5 Tue Aug 24 13:25:41 1999 +++ pppd/options.c Tue Aug 24 19:07:44 1999 @@ -108,8 +119,14 @@ struct option_info ptycommand_info; #ifdef PPP_FILTER -struct bpf_program pass_filter;/* Filter program for packets to pass */ -struct bpf_program active_filter; /* Filter program for link-active pkts */ +/* Filter program for packets to pass */ +struct bpf_program pass_filter_in; +struct bpf_program pass_filter_out; + +/* Filter program for link-active packets */ +struct bpf_program active_filter_in; +struct bpf_program active_filter_out; + pcap_t pc; /* Fake struct pcap so we can compile expr */ #endif @@ -136,11 +153,12 @@ static int setlogfile __P((char **)); #ifdef PPP_FILTER -static int setpassfilter __P((char **)); -static int setactivefilter __P((char **)); +static int setpassfilter_in __P((char **)); +static int setpassfilter_out __P((char **)); +static int setactivefilter_in __P((char **)); +static int setactivefilter_out __P((char **)); #endif - static option_t *find_option __P((char *name)); static int process_option __P((option_t *, char **)); static int n_arguments __P((option_t *)); @@ -250,10 +268,14 @@ #ifdef PPP_FILTER { "pdebug", o_int, &dflag, "libpcap debugging" }, - { "pass-filter", 1, setpassfilter, - "set filter for packets to pass" }, - { "active-filter", 1, setactivefilter, - "set filter for active pkts" }, + { "pass-filter-in", 1, setpassfilter_in, + "set filter for packets to pass inwards" }, + { "pass-filter-out", 1, setpassfilter_out, + "set filter for packets to pass outwards" }, + { "active-filter-in", 1, setactivefilter_in, + "set filter for active pkts inwards" }, + { "active-filter-out", 1, setactivefilter_out, + "set filter for active pkts outwards" }, #endif { NULL } @@ -274,6 +296,7 @@ auth Require authentication from peer\n\ connect

Invoke shell command

to set up the serial line\n\ crtscts Use hardware RTS/CTS flow control\n\ + cdtrcts Use hardware DTR/CTS flow control (if supported)\n\ defaultroute Add default route through interface\n\ file Take options from file \n\ modem Use modem control lines\n\ @@ -1185,44 +1208,68 @@ #ifdef PPP_FILTER /* - * setpdebug - Set libpcap debugging level. + * setpassfilter_in - Set the incoming pass filter */ static int -setpdebug(argv) +setpassfilter_in(argv) char **argv; { - return int_option(*argv, &dflag); + pc.linktype = DLT_PPP_SERIAL; + pc.snapshot = PPP_HDRLEN; + + if (pcap_compile(&pc, &pass_filter_in, *argv, 1, netmask) == 0) + return 1; + option_error("error in pass-filter-in expression: %s\n", pcap_geterr(&pc)); + return 0; } /* - * setpassfilter - Set the pass filter for packets + * setpassfilter_out - Set the outgoing pass filter */ static int -setpassfilter(argv) +setpassfilter_out(argv) char **argv; { - pc.linktype = DLT_PPP; + pc.linktype = DLT_PPP_SERIAL; pc.snapshot = PPP_HDRLEN; - if (pcap_compile(&pc, &pass_filter, *argv, 1, netmask) == 0) + if (pcap_compile(&pc, &pass_filter_out, *argv, 1, netmask) == 0) + return 1; + option_error("error in pass-filter-out expression: %s\n", pcap_geterr(&pc)); + return 0; +} + +/* + * setactivefilter_in - Set the incoming active filter + */ +static int +setactivefilter_in(argv) + char **argv; +{ + pc.linktype = DLT_PPP_SERIAL; + pc.snapshot = PPP_HDRLEN; + + if (pcap_compile(&pc, &active_filter_in, *argv, 1, netmask) == 0) return 1; - option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc)); + option_error("error in active-filter-in expression: %s\n", + pcap_geterr(&pc)); return 0; } /* - * setactivefilter - Set the active filter for packets + * setactivefilter_out - Set the outgoing active filter */ static int -setactivefilter(argv) +setactivefilter_out(argv) char **argv; { - pc.linktype = DLT_PPP; + pc.linktype = DLT_PPP_SERIAL; pc.snapshot = PPP_HDRLEN; - if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0) + if (pcap_compile(&pc, &active_filter_out, *argv, 1, netmask) == 0) return 1; - option_error("error in active-filter expression: %s\n", pcap_geterr(&pc)); + option_error("error in active-filter-out expression: %s\n", + pcap_geterr(&pc)); return 0; } #endif