Skip to content

Commit 0daa01c

Browse files
committed
rfmon
1 parent 1b87eb4 commit 0daa01c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct Config {
1919
bpf: Option<String>,
2020
buffer_for: std::time::Duration,
2121
blocking: bool,
22+
rfmon: bool,
2223
}
2324

2425
impl Config {
@@ -93,6 +94,15 @@ impl Config {
9394
self.blocking = blocking;
9495
self
9596
}
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+
}
96106
}
97107

98108
impl Default for Config {
@@ -106,6 +116,7 @@ impl Default for Config {
106116
bpf: None,
107117
buffer_for: std::time::Duration::from_millis(100),
108118
blocking: false,
119+
rfmon: false,
109120
}
110121
}
111122
}

src/handle.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ impl PendingHandle {
185185
}
186186
}
187187

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+
188196
pub fn activate(self) -> Result<Handle, Error> {
189197
let h = Handle {
190198
handle: self.handle,
@@ -216,6 +224,9 @@ impl std::convert::TryFrom<&Config> for PendingHandle {
216224
.set_snaplen(v.snaplen())?
217225
.set_promiscuous()?
218226
.set_buffer_size(v.buffer_size())?;
227+
if v.rfmon() {
228+
pending = pending.set_rfmon()?;
229+
}
219230
}
220231

221232
Ok(pending)

0 commit comments

Comments
 (0)