命令如何扫描无线网络

命令如何扫描无线网络

本文介绍了iwlist()命令如何扫描无线网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道iwlist命令如何扫描Linux中可用的无线网络.我阅读了源代码,并使用SIOCSIWSCAN触发了ioctl来触发扫描,并使用SIOCGIWSCAN获得了扫描结果.但是这些系统调用如何捕获和分析信标帧?

I want to know how iwlist command scans the wireless networks available, in linux. I read its source code and there was an ioctl call using SIOCSIWSCAN to trigger the scan and SIOCGIWSCAN to get the scan results. But how the beacon frames are captured and analyzed by these system calls?

推荐答案

iwlist(8)和其他无线工具为支持 Linux无线扩展(WEXT).每个驱动程序都将向WEXT注册处理程序,以实现此接口定义的特定于设备的操作.对于扫描,这两个处理程序是触发器扫描(命令SIOCSIWSCAN)和获取扫描结果(命令SIOCGIWSCAN).设备完成扫描后,它将通过 netlink 接口将SIOCGIWSCAN事件发送到WEXT.然后,侦听此套接字的应用程序可以发出SIOCGIWSCAN命令以从设备获取扫描结果.请注意,设备可以自由选择执行扫描的方式.例如,它可以通过发出探测请求来被动地侦听信标或主动进行扫描.

iwlist(8) and the other wireless tools provide a common front end to different wireless device drivers that support Linux Wireless Extensions (WEXT). Each driver will register handlers with WEXT that implement the device specific operations defined by this interface. For scanning, the two handlers are trigger scan (command SIOCSIWSCAN) and get scan results (command SIOCGIWSCAN). After the device completes a scan, it sends a SIOCGIWSCAN event to WEXT via a netlink interface. An application listening to this socket can then issue a SIOCGIWSCAN command to get the scan results from the device. Note that the device is free to implement the scan how ever it chooses. For example, it can passively listen for beacons or actively scan by sending out probe requests.

由于存在传统方式(ioctl)和新方式(netlink-cfg80211),因此上述内容在发送命令到设备的机制上故意含糊不清.但是要举一个具体的例子,请考虑传统方式. ioctl调用在WEXT模块中实现,但是处理此命令的代码在设备驱动程序中实现.当用户空间应用程序创建一个ioctl时,WEXT查找设备驱动程序的处理程序并运行它.

The above is purposely vague on the mechanics of sending commands to a device because there is the traditional way (ioctl) and the new way (netlink - cfg80211). But to take a concrete example, consider the traditional way. The ioctl calls are implemented in the WEXT module but the code that handles this command is implemented in the device driver. When a user space application makes an ioctl, WEXT looks up the device driver's handler and runs it.

这篇关于iwlist()命令如何扫描无线网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:27