如何获得Linux上可用无线网络的列表? [英] How can I get a list of available wireless networks on Linux?

查看:131
本文介绍了如何获得Linux上可用无线网络的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得可用无线网络的列表.理想情况下,这将通过一些C调用进行,但是我不介意是否必须通过系统调用来混淆它.如果所需的C调用或程序不需要某些特殊的第三方程序包,那就更好了.

I would like to get a list of the wireless networks available. Ideally this would be via some C call, but I don't mind if I have to kludge it with a system call. Even better if the required C call or program doesn't require some exotic 3rd party package.

Internet似乎建议我使用sudo iwlist <interface> scan,这似乎确实可以从命令行中解决问题,但是我宁愿不需要root权限.我只想了解基础知识,什么也不想改变.

The internet seems to suggest I use sudo iwlist <interface> scan which does seem to do the trick from the command line, but I'd rather not require root permissions. I only want to see the basics, not change anything.

推荐答案

无线工具" 软件包-其中 iwlist 是一个部分-还包含无线工具帮助程序库.您需要包括 iwlib.h 并与 libiw.a 链接(即添加-liw).然后查找 iw_set_ext 函数的文档. SIOCSIWSCAN 参数将最有用.有关如何使用此界面的示例,请查看KDE库中的KWifiManager源(请参阅:无线工具"源代码,然后看看iwlib iw_set_ext函数也如何用于在iwlist.c中进行扫描.

The Wireless Tools package -- of which iwlist is a part -- also contains a Wireless Tools Helper Library. You need to include iwlib.h and link with libiw.a (i.e. add -liw). Then look up the documentation for the iw_set_ext function. The SIOCSIWSCAN parameter will be of most use. For an example of how to use this interface, take a look at the KWifiManager source in the KDE library (see: Interface_wireless_wirelessextensions::get_available_networks method). Alternatively, you can also download the Wireless Tools source code and take a look at how the iwlib iw_set_ext function is also used for scanning in iwlist.c.

关于特权,我想该进程将需要以root用户身份运行才能执行扫描.我很想知道是否也可以这样做.

As for privileges, I imagine the process will need to run as root to perform the scan. I'd love to know if this could be done otherwise as well.

由于您使用的是Ubuntu 8.04,因此 libiw-dev 软件包应为使用.

Since you are using Ubuntu 8.04 the libiw-dev package should be of use.

这篇关于如何获得Linux上可用无线网络的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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