-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scan: Add support of query scan results
Work was based on #9 by Rayzeq. Introduce `Nl80211ScanHandle::dump()` equal to `iw dev DEVICE scan dump`. Example code included as `examples/dump_nl80211_scan.rs` Signed-off-by: Gris Ge <[email protected]>
- Loading branch information
Showing
11 changed files
with
1,515 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::env::args; | ||
|
||
use anyhow::{bail, Context, Error}; | ||
use futures::stream::TryStreamExt; | ||
|
||
fn main() -> Result<(), Error> { | ||
let argv: Vec<_> = args().collect(); | ||
|
||
if argv.len() < 2 { | ||
eprintln!("Usage: dump_nl80211_scan <interface index>"); | ||
bail!("Required arguments not given"); | ||
} | ||
|
||
let err_msg = format!("Invalid interface index value: {}", argv[1]); | ||
let index = argv[1].parse::<u32>().context(err_msg)?; | ||
|
||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.enable_io() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(dump_scan(index)); | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn dump_scan(if_index: u32) { | ||
let (connection, handle, _) = wl_nl80211::new_connection().unwrap(); | ||
tokio::spawn(connection); | ||
|
||
let mut scan_handle = handle.scan().dump(if_index).execute().await; | ||
|
||
let mut msgs = Vec::new(); | ||
while let Some(msg) = scan_handle.try_next().await.unwrap() { | ||
msgs.push(msg); | ||
} | ||
assert!(!msgs.is_empty()); | ||
for msg in msgs { | ||
println!("{:?}", msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.