Use multicast to wait for new scan results#36
Use multicast to wait for new scan results#36Sh3Rm4n wants to merge 1 commit intorust-netlink:mainfrom
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. |
|
Not dig into this generic netlink code yet, could you check whether rust-netlink/rtnetlink#130 can be used here or not. |
|
Looks promising, I'll try it out next week |
0a027c1 to
2356e30
Compare
I think it is helpful to create a new constructor But this does not work: As the group IDs are not fixed, but can vary between device. So we have to combine this with the work of rust-netlink/genetlink#12 and also the new |
|
I see the point now. Since the genetlink PR is not updating. I will pick it up and continue the work. |
|
I've picked up the stalled PR here rust-netlink/genetlink#16 |
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
genetlinkI assume.