Blob Blame History Raw
--- ppp-2.4.2/pppd/options.c.pcap	2004-01-13 05:02:07.000000000 +0100
+++ ppp-2.4.2/pppd/options.c	2004-09-15 11:39:34.832772935 +0200
@@ -56,7 +56,6 @@
 #endif
 #ifdef PPP_FILTER
 #include <pcap.h>
-#include <pcap-int.h>	/* XXX: To get struct pcap */
 #endif
 
 #include "pppd.h"
@@ -122,7 +121,6 @@
 #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 */
-pcap_t  pc;			/* Fake struct pcap so we can compile expr */
 #endif
 
 char *current_option;		/* the name of the option being parsed */
@@ -1439,12 +1437,18 @@
 setpassfilter(argv)
     char **argv;
 {
-    pc.linktype = DLT_PPP;
-    pc.snapshot = PPP_HDRLEN;
+    pcap_t* pc = pcap_open_dead (DLT_PPP, PPP_HDRLEN);
+    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) == 0)
+    if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == 0) {
+        pcap_close(pc);
 	return 1;
-    option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc));
+    }
+    option_error("error in pass-filter expression: %s\n", pcap_geterr(pc));
+    pcap_close(pc);
     return 0;
 }
 
@@ -1455,12 +1459,18 @@
 setactivefilter(argv)
     char **argv;
 {
-    pc.linktype = DLT_PPP;
-    pc.snapshot = PPP_HDRLEN;
+    pcap_t* pc = pcap_open_dead (DLT_PPP, PPP_HDRLEN);
+    if (!pc) {
+        option_error("error in pass-filter expression: pcap_open_dead failed\n");
+	return 0;
+    }
  
-    if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0)
+    if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == 0) {
+        pcap_close(pc);
 	return 1;
-    option_error("error in active-filter expression: %s\n", pcap_geterr(&pc));
+    }
+    option_error("error in active-filter expression: %s\n", pcap_geterr(pc));
+    pcap_close(pc);
     return 0;
 }
 #endif