How to get information about wireless net_devices

一曲冷凌霜 提交于 2021-02-10 05:30:27

问题


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.

  1. Is net_device wireless / wired?
  2. Is wireless devices connected to wireless access point?
  3. If yes which wireless access point (name of access point)?
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!