Skip to content

Commit 2a4dbe1

Browse files
committed
Add support of parsing netlink message reply of iw phy
Expanding `Nl80211Attr` to support parsing reply of `iw phy` on linux kernel 6.10.10. Tested on archlinux by command: ```bash cargo run --example dump_nl80211_wiphy ``` Signed-off-by: Gris Ge <fge@redhat.com>
1 parent 19d03a5 commit 2a4dbe1

31 files changed

+6537
-234
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "wl-nl80211"
44
version = "0.1.2"
55
authors = ["Gris Ge <fge@redhat.com>"]
66
license = "MIT"
7-
edition = "2018"
7+
edition = "2021"
88
description = "Linux kernel wireless(802.11) netlink Library"
99
homepage = "https://github.com/rust-netlink/wl-nl80211"
1010
repository = "https://github.com/rust-netlink/wl-nl80211"
@@ -25,6 +25,7 @@ smol_socket = ["netlink-proto/smol_socket", "async-std"]
2525
[dependencies]
2626
anyhow = "1.0.44"
2727
async-std = { version = "1.9.0", optional = true}
28+
bitflags = "2"
2829
byteorder = "1.4.3"
2930
futures = "0.3.17"
3031
log = "0.4.14"

examples/dump_nl80211_wiphy.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
use futures::stream::TryStreamExt;
4+
5+
fn main() {
6+
let rt = tokio::runtime::Builder::new_current_thread()
7+
.enable_io()
8+
.build()
9+
.unwrap();
10+
rt.block_on(get_wireless_physics());
11+
}
12+
13+
async fn get_wireless_physics() {
14+
let (connection, handle, _) = wl_nl80211::new_connection().unwrap();
15+
tokio::spawn(connection);
16+
17+
let mut phy_handle = handle.wireless_physic().get().execute().await;
18+
19+
let mut msgs = Vec::new();
20+
while let Some(msg) = phy_handle.try_next().await.unwrap() {
21+
msgs.push(msg);
22+
}
23+
assert!(!msgs.is_empty());
24+
for msg in msgs {
25+
println!("{:?}", msg);
26+
}
27+
}

0 commit comments

Comments
 (0)