问题
I am working in Linux kernel module which is using NF_INET_PRE_ROUTING
hook. In that hook I need to know the status of all my net_devices, specially wireless devices. I am able get some information about devices from net_device->flags
i.e IFF_UP
is device up or down. But I need some more detail about the wireless net_device
.
- Is net_device wireless / wired?
- Is wireless devices connected to wireless access point?
- If yes which wireless access point (name of access point)?
- Gateway address associated with that device (I think, I need to get this from routing table?).
回答1:
if(net_device->ieee80211_ptr != NULL)
? The ieee80211_ptr
is a struct wireless_dev*. This structure should give you access to most of the values you requested. In struct wireless_dev
is struct wiphy *wiphy;
, you can use this to get a cfg80211_registered_device with wiphy_to_dev()
.
The gateway address is unrelated to wireless. I doubt devices
have any gateway information but you need the interface name
in net_device
to find the route. The route is IP related and has nothing to do with a device
. Good luck.
回答2:
See iwconfig, iwlist, and other utilities.
来源:https://stackoverflow.com/questions/15119928/how-to-get-information-about-wireless-net-devices