1 |
--- ppp-2.4.2/pppd/options.c.pcap 2004-01-13 05:02:07.000000000 +0100 |
2 |
+++ ppp-2.4.2/pppd/options.c 2004-09-15 11:39:34.832772935 +0200 |
3 |
@@ -56,7 +56,6 @@ |
4 |
#endif |
5 |
#ifdef PPP_FILTER |
6 |
#include <pcap.h> |
7 |
-#include <pcap-int.h> /* XXX: To get struct pcap */ |
8 |
#endif |
9 |
|
10 |
#include "pppd.h" |
11 |
@@ -122,7 +121,6 @@ |
12 |
#ifdef PPP_FILTER |
13 |
struct bpf_program pass_filter;/* Filter program for packets to pass */ |
14 |
struct bpf_program active_filter; /* Filter program for link-active pkts */ |
15 |
-pcap_t pc; /* Fake struct pcap so we can compile expr */ |
16 |
#endif |
17 |
|
18 |
char *current_option; /* the name of the option being parsed */ |
19 |
@@ -1439,12 +1437,18 @@ |
20 |
setpassfilter(argv) |
21 |
char **argv; |
22 |
{ |
23 |
- pc.linktype = DLT_PPP; |
24 |
- pc.snapshot = PPP_HDRLEN; |
25 |
+ pcap_t* pc = pcap_open_dead (DLT_PPP, PPP_HDRLEN); |
26 |
+ if (!pc) { |
27 |
+ option_error("error in pass-filter expression: pcap_open_dead failed\n"); |
28 |
+ return 0; |
29 |
+ } |
30 |
|
31 |
- if (pcap_compile(&pc, &pass_filter, *argv, 1, netmask) == 0) |
32 |
+ if (pcap_compile(pc, &pass_filter, *argv, 1, netmask) == 0) { |
33 |
+ pcap_close(pc); |
34 |
return 1; |
35 |
- option_error("error in pass-filter expression: %s\n", pcap_geterr(&pc)); |
36 |
+ } |
37 |
+ option_error("error in pass-filter expression: %s\n", pcap_geterr(pc)); |
38 |
+ pcap_close(pc); |
39 |
return 0; |
40 |
} |
41 |
|
42 |
@@ -1455,12 +1459,18 @@ |
43 |
setactivefilter(argv) |
44 |
char **argv; |
45 |
{ |
46 |
- pc.linktype = DLT_PPP; |
47 |
- pc.snapshot = PPP_HDRLEN; |
48 |
+ pcap_t* pc = pcap_open_dead (DLT_PPP, PPP_HDRLEN); |
49 |
+ if (!pc) { |
50 |
+ option_error("error in pass-filter expression: pcap_open_dead failed\n"); |
51 |
+ return 0; |
52 |
+ } |
53 |
|
54 |
- if (pcap_compile(&pc, &active_filter, *argv, 1, netmask) == 0) |
55 |
+ if (pcap_compile(pc, &active_filter, *argv, 1, netmask) == 0) { |
56 |
+ pcap_close(pc); |
57 |
return 1; |
58 |
- option_error("error in active-filter expression: %s\n", pcap_geterr(&pc)); |
59 |
+ } |
60 |
+ option_error("error in active-filter expression: %s\n", pcap_geterr(pc)); |
61 |
+ pcap_close(pc); |
62 |
return 0; |
63 |
} |
64 |
#endif |