wpa_supplicant是一个开源软件项目,它实现了Station对无线网络进行管理和控制的功能。wpa_supplicant有两个版本,分别是6和8。版本6中没有网卡作为Soft AP相关源码。目录结构如下:
·hostapd:当手机进入Soft AP模式时,手机将扮演AP的角色,故需要hostapd来提供AP的功能。
·wpa_supplicant:Station模式,也叫Managed模式。
·src:hostapd和wpa_supplicant中都包含了一些通用的数据结构和处理方法,这些内容都放在此src目录中。
以下凡是对wpa_supplicant都简称为WPAS
软件架构
WPAS是C/S结构中的Server端,Linux/UNIX平台中,Client端利用Unix域socket与其通信。linux平台目前常用的Client端wpa_cli(无界面的命令行程序)和wpa_gui(UI用Qt实现)。
我们就是仿照wpa_cli来做我们自己的连接程序。下面就来看看wpa_cli是如何工作的。
准备工作
先移植好WPAS,然后用如下命令启动server端:
wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
配置文件/etc/wpa_supplicant.conf 可以先写如下信息
ctrl_interface=/var/run/wpa_supplicant
1
启动成功后就可以执行wpa_cli客户端了。
wpa_cli支持两种模式:交互模式和命令行模式
交互模式就是直接执行wpa_cli,然后输入各种命令即可
root@am335x:~# wpa_cli
wpa_cli v0.6.9
Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi> and contributors
This program is free software. You can distribute it and/or modify it
under the terms of the GNU General Public License version 2.
Alternatively, this software may be distributed under the terms of the
BSD license. See README and COPYING for more details.
Selected interface 'wlan0'
Interactive mode
> status
bssid=74:1f:4a:b2:e5:b3
ssid=QK-2
id=2
pairwise_cipher=WEP-104
group_cipher=WEP-104
key_mgmt=NONE
wpa_state=COMPLETED
ip_address=192.168.100.13
>
---------------------
作者:浓咖啡jy
来源:CSDN
原文:https://blog.csdn.net/jy1075518049/article/details/51015141?utm_source=copy
版权声明:本文为博主原创文章,转载请附上博文链接!