-
Notifications
You must be signed in to change notification settings - Fork 14
Use multicast to wait for new scan results #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
b356ed2
to
0a027c1
Compare
Nice work. The /*
* WARNING: DO NOT COPY THIS CODE INTO YOUR APPLICATION
*
* This code has a bug, which requires creating a separate
* nl80211 socket to fix:
* It is possible for a NL80211_CMD_NEW_SCAN_RESULTS or
* NL80211_CMD_SCAN_ABORTED message to be sent by the kernel
* before (!) we listen to it, because we only start listening
* after we send our scan request.
*
* Doing it the other way around has a race condition as well,
* if you first open the events socket you may get a notification
* for a previous scan.
*
* The only proper way to fix this would be to listen to events
* before sending the command, and for the kernel to send the
* scan request along with the event, so that you can match up
* whether the scan you requested was finished or aborted (this
* may result in processing a scan that another application
* requested, but that doesn't seem to be a problem).
*
* Alas, the kernel doesn't do that (yet).
*/ It seems to me your example code is doing exactly what |
iw comment indicate we should not reuse the socket for both requesting scan and wait scan result.
For abstraction, you can do:
|
I've also stumbled upon this comment. But I assume
From my experience with this approach: I seem to get the messages consistently.
I've only enabled the "nl80211" "scan" group for now. But there are many more groups available Should I just enable all groups as it is done in Something similar to that? enum Family {
Nl80211,
/// ...
}
enum Nl80211Groups {
Config,
Scan,
Regulatory,
// ...
}
wl_nl80211::new_multicast_connection(groups: HashSet<Nl80211Groups>) -> Result<...>;
genetlink::new_multicast_connection(family: Family, groups: GenlGroups<Nl80211Groups>) -> Result<...>; |
This rust-netlink/genetlink#12 seems to be very useful to have before introducing a |
Let's wait genetlink to provide multicast support there. |
This extends the example to wait for new scan results via the multicast object.
This might be to low level, but provides a usecase to abstract multicast attachment.
A proper abstraction shouldn't probably be part of this crate but rather
genetlink
I assume.