Search code examples
linuxnetwork-programmingwirelessnotifications

Which API provides wireless networks notifications in linux?


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.


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.