-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED Signed-off-by: Gris Ge <[email protected]>
- Loading branch information
Showing
23 changed files
with
4,241 additions
and
111 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ name = "wl-nl80211" | |
version = "0.1.2" | ||
authors = ["Gris Ge <[email protected]>"] | ||
license = "MIT" | ||
edition = "2018" | ||
edition = "2021" | ||
description = "Linux kernel wireless(802.11) netlink Library" | ||
homepage = "https://github.com/rust-netlink/wl-nl80211" | ||
repository = "https://github.com/rust-netlink/wl-nl80211" | ||
|
@@ -25,6 +25,7 @@ smol_socket = ["netlink-proto/smol_socket", "async-std"] | |
[dependencies] | ||
anyhow = "1.0.44" | ||
async-std = { version = "1.9.0", optional = true} | ||
bitflags = "2" | ||
byteorder = "1.4.3" | ||
futures = "0.3.17" | ||
log = "0.4.14" | ||
|
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,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
use futures::stream::TryStreamExt; | ||
|
||
fn main() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.enable_io() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(get_wireless_physics()); | ||
} | ||
|
||
async fn get_wireless_physics() { | ||
let (connection, handle, _) = wl_nl80211::new_connection().unwrap(); | ||
tokio::spawn(connection); | ||
|
||
let mut phy_handle = handle.wireless_physic().get().execute().await; | ||
|
||
let mut msgs = Vec::new(); | ||
while let Some(msg) = phy_handle.try_next().await.unwrap() { | ||
msgs.push(msg); | ||
} | ||
assert!(!msgs.is_empty()); | ||
for msg in msgs { | ||
println!("{:?}", msg); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,46 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pub(crate) fn write_u16(buffer: &mut [u8], value: u16) { | ||
buffer[..2].copy_from_slice(&value.to_ne_bytes()) | ||
} | ||
|
||
pub(crate) fn write_u16_le(buffer: &mut [u8], value: u16) { | ||
buffer[..2].copy_from_slice(&value.to_le_bytes()) | ||
} | ||
|
||
pub(crate) fn write_u32(buffer: &mut [u8], value: u32) { | ||
buffer[..4].copy_from_slice(&value.to_ne_bytes()) | ||
} | ||
|
||
pub(crate) fn write_u64(buffer: &mut [u8], value: u64) { | ||
buffer[..8].copy_from_slice(&value.to_ne_bytes()) | ||
} | ||
|
||
pub(crate) fn get_bit(data: &[u8], pos: usize) -> bool { | ||
let index: usize = pos / 8; | ||
let bit_pos: usize = pos % 8; | ||
if data.len() < index { | ||
panic!( | ||
"BUG: get_bit(): out of index: got data {:?} pos {pos}", | ||
data | ||
); | ||
} | ||
(data[index] & 1u8 << bit_pos) >= 1 | ||
} | ||
|
||
pub(crate) fn get_bits_as_u8(data: &[u8], start: usize, end: usize) -> u8 { | ||
if (end - start) >= 8 { | ||
panic!( | ||
"BUG: get_bits_as_u8(): more than 8 bits defined by \ | ||
start({start}) and end({end})" | ||
); | ||
} | ||
|
||
let mut ret = 0u8; | ||
for pos in start..(end + 1) { | ||
if get_bit(data, pos) { | ||
ret |= 1 << (pos - start); | ||
} | ||
} | ||
ret | ||
} |
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
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
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
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.