Question

I'd like to fire some callback every time my network card sends new info about the available networks. I don't really mind if I need to poll the information myself either. I just don't want to rely on spawning "iwlist scan last" every second, but that's exactly the information I need (network name + channel + encryption type).

Is there a library that implements a function like that? (or are there some ioctl calls to do that?)

I'm only interested in an ndiswrapper module if that matters.

Was it helpful?

Solution

If NetworkManager is running, it is accessible via its DBUS API -- see the WirelessNetworkAppeared and WirelessNetworkDisappeared events.

Otherwise, you'll have to deal with wext yourself (this is what NM uses underneath), you'd be interested in the IWEVREGISTERED and IWEVEXPIRED events coming over the NETLINK_ROUTE interface.

OTHER TIPS

If you don't want to use DBUS, you can also just drop a script/program into /etc/NetworkManager/dispatcher.d/, where it will be called by NetworkManager upon certain events.

See "man 8 NetworkManager" for the types of events and arguments passed to the script. The script will be executed as root, though, wich may not be what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top