如何获取有关无线net_devices的信息 [英] How to get information about wireless net_devices

查看:73
本文介绍了如何获取有关无线net_devices的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 NF_INET_PRE_ROUTING 挂钩的Linux内核模块中工作.在那个挂钩中,我需要知道所有net_devices的状态,尤其是无线设备.我可以从 net_device->标记中获取有关设备的一些信息,即 IFF_UP 是设备处于启动状态还是处于关闭状态.但是我需要更多有关无线 net_device 的信息.

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. net_device是无线的还是有线的?
  2. 无线设备是否已连接到无线接入点?
  3. 如果是,是哪个无线接入点(接入点名称)?
  4. 与该设备关联的网关地址(我想我需要从路由表中获取该地址吗?).

推荐答案

如果(net_device-> ieee80211_ptr!= NULL)? ieee80211_ptr cfg80211_registered_device wiphy_to_dev().

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().

网关地址与无线无关.我怀疑 devices 是否具有任何 gateway 信息,但是您需要 net_device 中的接口 name 来查找路由.该路由与 IP 有关,与 device 无关.祝你好运.

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.

这篇关于如何获取有关无线net_devices的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆