检查无线AP是否连接
我正在编写一个Linux无线网络扫描仪,它提供有关接入点的信息,但它还必须检查接入点是否已连接并且可以进行通信(即加密工作正常)。通过ioctl(.., SIOCGIWAP, ..)来检查它是不够的,因为它并没有真正检查WPA密钥是否正确以及AP是否可以通信。
我要检查无线接口是否与 AP 关联的操作是:
- 检查 ioctl(...,SIOCGIWAP,...) 是否返回某个 AP 的 MAC 地址
- 检查接口是否配置了 IP (我知道在静态配置的情况下它不会提供任何信息,但我可以接受)
- 检查AP和客户端使用的加密(例如WEP,WPA,WPA2)是否相同(以确保在更改加密方法后在AP端,不会被主动检测为已连接)。
我陷入了最新的困境 - 我可以检测 AP 使用的加密,但我真的不知道如何检查我的主机使用的加密。你知道如何检查吗?或者也许您知道更好的方法来确定 AP 和客户端之间的连接是否正常工作(我不想使用 ICMP 或类似的东西 - 我的工具必须很快,因此可以在本地完成所有操作)
I am writing a linux wireless network scanner that provides information about access points, but it also must check if an access point is connected and can be communicated (i.e. encryption works properly). It is not enough to check it by ioctl(.., SIOCGIWAP, ..)
, because it does not really check if the WPA key is correct and that AP can be communicated.
What I am doing to check if a wireless interface is associated with an AP is:
- check if
ioctl(...,SIOCGIWAP,...)
returns MAC address of some AP - check if interface has IP configured (I know that it will give no information in case of static configuration, but I can live with that)
- check if encryption (e.g. WEP, WPA, WPA2) used by AP and client is the same (to ensure that after change of encryption method at the AP side, it will not be positively detected as connected).
I got stuck with the latest point - I can detect the encryption used by the AP, but I really do not know how to check what encryption is used by my host. Do you have idea how to check that? Or maybe you know better ways to determine if connection between AP and client is workning (I do not want to use ICMP or anything like this - my tool must be quick and thus do everything locally)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 SIOCGIWENCODE 调用 ioctl 查询加密密钥的打开或关闭(区分开放和加密)。
使用 SIOCGIWESSID 调用 ioctl 查询 ESSID,然后可以在主机和 AP 之间进行 ESSID 匹配。
使用 SIOCGIWENCODEEXT 调用 ioctl 会查询加密类型(区分 WEP、WPA 和 WPA2 等),但前提是无线卡的内核驱动程序支持该类型。
Calling ioctl with SIOCGIWENCODE queries encryption key on or off (which distinguishes between Open and Encrypted).
Calling ioctl with SIOCGIWESSID queries the ESSID, you can then play ESSID matching between the host and AP.
Calling ioctl with SIOCGIWENCODEEXT queries the encryption type (which distinguishes between WEP, WPA and WPA2,etc) but only if it is supported by the wireless card's kernel driver.