File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ pub struct Config {
19
19
bpf : Option < String > ,
20
20
buffer_for : std:: time:: Duration ,
21
21
blocking : bool ,
22
+ rfmon : bool ,
22
23
}
23
24
24
25
impl Config {
@@ -93,6 +94,15 @@ impl Config {
93
94
self . blocking = blocking;
94
95
self
95
96
}
97
+
98
+ pub fn rfmon ( & self ) -> bool {
99
+ self . rfmon
100
+ }
101
+
102
+ pub fn with_rfmon ( & mut self , rfmon : bool ) -> & mut Self {
103
+ self . rfmon = rfmon;
104
+ self
105
+ }
96
106
}
97
107
98
108
impl Default for Config {
@@ -106,6 +116,7 @@ impl Default for Config {
106
116
bpf : None ,
107
117
buffer_for : std:: time:: Duration :: from_millis ( 100 ) ,
108
118
blocking : false ,
119
+ rfmon : false ,
109
120
}
110
121
}
111
122
}
Original file line number Diff line number Diff line change @@ -185,6 +185,14 @@ impl PendingHandle {
185
185
}
186
186
}
187
187
188
+ pub fn set_rfmon ( self ) -> Result < Self , Error > {
189
+ if 0 != unsafe { pcap_sys:: pcap_set_rfmon ( self . handle , 1 ) } {
190
+ Err ( pcap_util:: convert_libpcap_error ( self . handle ) )
191
+ } else {
192
+ Ok ( self )
193
+ }
194
+ }
195
+
188
196
pub fn activate ( self ) -> Result < Handle , Error > {
189
197
let h = Handle {
190
198
handle : self . handle ,
@@ -216,6 +224,9 @@ impl std::convert::TryFrom<&Config> for PendingHandle {
216
224
. set_snaplen ( v. snaplen ( ) ) ?
217
225
. set_promiscuous ( ) ?
218
226
. set_buffer_size ( v. buffer_size ( ) ) ?;
227
+ if v. rfmon ( ) {
228
+ pending = pending. set_rfmon ( ) ?;
229
+ }
219
230
}
220
231
221
232
Ok ( pending)
You can’t perform that action at this time.
0 commit comments