Linux下使用wpa_supplicant连接WPA…
来源:互联网 发布:html2fpdf.php下载 编辑:程序博客网 时间:2024/04/28 19:02
Step bystep:
1、运行wpa_supplicant程序;
执行:/system/bin/wpa_supplicant-d -Dwext -iwlan0 -c/data/misc/wifi/wpa_supplicant.conf
其中:
-d:增加调试信息
-Dwext:wext,驱动名称
-iwlan0:wlan0,网络接口名称
/system/bin/wpa_supplicant:wpa_supplicant可执行程序path
/data/misc/wifi/wpa_supplicant.conf:wpa_supplicant的配置文件path
2、运行命令行工具wpa_cli;
执行 :wpa_cli-iwlan0 -p/data/system/wpa_supplicant
注,-p/data/system/wpa_supplicant中的wpa_supplicant并不是可执行程序,而是个控制套接字。
此时会进入交互模式。其中交互模式的命令如下表:
Fullcommand
Shortcommand
Description
status
stat
displays the current connection status
disconnect
disc
prevents wpa_supplicant from connecting to anyaccess point
quit
q
exits wpa_cli
terminate
term
kills wpa_supplicant
reconfigure
recon
reloads wpa_supplicant with the configuration filesupplied (-c parameter)
scan
scan
scans for available access points (only scans it,doesn't display anything)
scan_result
scan_r
displays the results of the last scan
list_networks
list_n
displays a list of configured networks and theirstatus (active or not, enabled or disabled)
select_network
select_n
select a network among those defined to initiate aconnection (ie select_network 0)
enable_network
enable_n
makes a configured network available for selection(ie enable_network 0)
disable_network
disable_n
makes a configured network unavailable for selection(ie disable_network 0)
remove_network
remove_n
removes a network and its configuration from thelist (ie remove_network 0)
add_network
add_n
adds a new network to the list. Its id will becreated automatically
set_network
set_n
shows a very short list of available options toconfigure a network when supplied with no parameters.
See next section for a list of extremely usefulparameters to be used with set_network and get_network.
get_network
get_n
displays the required parameter for the specifiednetwork. See next section for a list of parameters
save_config
save_c
saves the configuration
设置网络的基本格式:set_network[]
显示网络信息的基本格式:get_network
相应的参数如下表:
Key
Description
Parameters
ssid
Access point name
string
id_str
String identifying the network
string
priority
Connection priority over other APs
number (0 being the default low priority)
bssid
Mac address of the access point
mac address
scan_ssid
Enable/disbale ssid scan
0, 1, 2
key_mgmt
Type of key management
WPA-PSK, WPA_EAP, None
pairwise
Pairwise ciphers for WPA
CCMP, TKIP
group=TKIP
Group ciphers for WPA
CCMP, TKIP, WEP104, WEP40
psk
Pre-Shared Key (clear or encrypted)
string
wep_key0
WEP key (up to 4: wep_key[0123])
string
eap
Extensible Authentication Protocol
MD5, MSCHAPV2, OTP, GTC, TLS, PEAP, TTLS
identity
EAP identity string
string
password
EAP password
string
ca_cert
Pathname to CA certificate file
/full/path/to/certificate
client_cert
Pathname to client certificate
/full/path/to/certificate (PEM/DER)
private_key
Pathname to a client private key file
/full/path/to/private_key (PEM/DER/PFX)
eg.1、连接无加密的AP
>add_network
>set_network0 ssid "666"
>set_network0 key_mgmt NONE
>enable_network0
>quit
eg.2、连接WEP加密AP
>add_network
>set_network1 ssid "666"
>set_network1 key_mgmt NONE
>set_network1 wep_key0 "your ap password"
>enable_network1
eg.3、连接WPA-PSK/WPA2-PSK加密的AP
>add_network
>set_network2 ssid "666"
>set_network2 psk "your pre-shared key"
>enable_network2
到此,wifi模块就能连接上AP了。
3、以上是通过命令行工具wpa_cli来实现wifi网络的连接。当然,也可以通过wpa_supplicant的配置文件来实现连接。
再回顾下运行wpa_supplicant时执行的命令:
/system/bin/wpa_supplicant -d -Dwext -iwlan0-c/data/misc/wifi/wpa_supplicant.conf
我们在执行时加上了-c/data/misc/wifi/wpa_supplicant.conf,我们可以将我们要连接的AP的设置以一定的格式写入wpa_supplicant.conf配置文件中即可。
eg.
ctrl_interface=DIR=/data/system/wpa_supplicant
network={
ssid="my access point"
proto=WPA
key_mgmt=WPA-PSK
psk="you pass words"
}
具体格式可参考:http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=wpa_supplicant/wpa_supplicant.conf
- Linux下使用wpa_supplicant连接WPA…
- Linux下使用wpa_supplicant连接WPA…
- Linux下使用wpa_supplicant连接WPA加密方式的WIFI
- Linux下使用wpa_supplicant连接WPA加密方式的WIFI
- 转载:Linux下使用wpa_supplicant连接WPA加密方式的WIFI
- RHEL等Linux系统使用wpa_supplicant以WPA-PSK/WPA2-PSK连接WIFI
- wpa_supplicant--忘记网络后,wpa自动连接规则
- linux下的wpa_supplicant工具使用
- Ubuntu下wpa_supplicant命令导致WPA: 4-Way Handshake failed
- linux下编译wpa_supplicant …
- linux下编译wpa_supplicant
- window下wpa_supplicant使用
- Linux命令行 wifi wpa密码连接
- 在Linux下实现无线WPA
- Linux下移植和配置wpa_supplicant
- Arch下配置连接wpa加密wifi的方法
- 嵌入式Linux连接WPA加密方式的路由器方法
- Linux无线网络设置(wpa_supplicant的使用)
- wpa_supplicant, wpa_cli用法
- wpa_supplicant, wpa_cli用法
- wpa_supplicant 笔记
- wpa_supplicant 笔记
- Linux下使用wpa_supplicant连接WPA…
- Linux下使用wpa_supplicant连接WPA…
- android之wifi开发(一)
- android之wifi开发(一)
- 非常详细的Android wifi&nbsp…
- 非常详细的Android wifi&nbsp…
- Android WIFI框架分析(1)
- Android WIFI框架分析(1)
- android移植wifis
- android移植wifis