views:

178

answers:

2

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.

+3  A: 

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.

ephemient
That should do the trick. However, I was silently hoping for some nice wrapper library...
viraptor
Sorry, I haven't seen any nice wrappers for this particular functionality. :(
ephemient
+1  A: 

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.

8jean
Unfortunately NM doesn't work correctly with my card - that's why I wanted my own notification.
viraptor
Sadly, if NM doesn't work correctly with your card, it probably means the driver is doing something wrong and thus it's quite possible that nothing without polling will work. What card do you have, and can it be fixed to work with NM?
ephemient