一、下载源码
http://hostap.epitest.fi/wpa_supplicant/
下载wpa_supplicant-0.7.3.tar.gz (openssl用到0.7.3提供的补丁)
#tar xvfz wpa_supplicant-0.7.3.tar.gz
下载www.openssl.org/source/openssl-0.9.8e.tar.gz
#tar zxvf openssl-0.9.8e.tar.gz
二、编译openssl库
将wpa_supplicant中的补丁拷贝到openssl中
# cp wpa_supplicant-0.7.3/patches/openssl-0.9.8e-tls-extensions.patch openssl-0.9.8e/
#cd openssl-0.9.8e
#mkdir /usr/local/ssl
#vim Makefile
CC= arm-linux-gnu-gcc
AR= arm-linux-gnu-ar $(ARFLAGS) r
RANLIB= arm-linux-gnu-ranlib
INSTALLTOP=/usr/local/ssl
OPENSSLDIR=/usr/local/ssl
#make
#make install
在/usr/local/ssl目录下安装了ssl库
#ls /usr/local/ssl
#bincertsincludelibmanmiscopenssl.cnfprivate
后面编译wpa_supplicant要依赖openssl中的lib和include
三、编译wpa_supplicant
进入wpa_supplicant-0.7.3.tar.gz解压生成的wpa_supplicant-0.7.3/wpa_supplicant目录中:
#cp defconfig .config
#vim .config
CC=arm-linux-gcc-L/usr/local/ssl/lib/
#CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
CFLAGS += -I/usr/local/ssl/include
#CPPFLAGS += -I../src/include -I../../src/router/openssl/include
LIBS += -L/usr/local/ssl/lib
#make
经过编译后的wpa_supplicant源程序可以看到两个主要的可执行工具:wpa_supplicant和wpa_cli。wpa_supplicant是核心程序,它和wpa_cli的关系就是服务和客户端的关系:后台运行wpa_supplicant,使用wpa_cli来搜索、设置、和连接网络。
四、配置wpa_supplicant
(1)首先拷贝wpa_supplicant和wpa-psk-tkip.conf到开发板根文件系统中,并改名wpa-psk-tkip.conf为wpa_supplicant.conf
#cp wpa_supplicant /rootfs/filesystem/bin
#cp wpa_supplicant-0.7.3/wpa_supplicant/examples/wpa-psk-tkip.conf/rootfs/filesystem/etc/wpa_supplicant.conf
(2)修改wpa_supplicant.conf配置文件
#vim /rootfs/filesystem/etc/wpa_supplicant.conf
修改内容如下:
# WPA-PSK/TKIP
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="TianYuan" //填写无线网络的的用户名
key_mgmt=WPA-PSK
proto=WPA
pairwise=TKIP
group=TKIP
psk="TYDT2011" //填写密码
}
(3)连接AP
#ifconfig eth0 down
#ifconfig wlan0 up
在开发板终端输入wpa_supplicant回车,会显示帮助信息,最后有个:
example:
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
拷贝example用法,执行:
# wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf &(需要一直放在后台运行)
打印信息有:
Trying to associate with 00:26:f2:0d:5a:c4 (SSID='FS2410' freq=2412 MHz)
Associated with 00:23:68:28:4e:a8
CTRL-EVENT-DISCONNECTED bssid=00:23:68:28:4e:a8 reason=0
Associated with 00:26:f2:0d:5a:c4
WPA: Key negotiation completed with 00:26:f2:0d:5a:c4
CTRL-EVENT-CONNECTED - Connection to 00:26:f2:0d:5a:c4 completed (auth)
……
#ifconfig wlan0 192.168.0.235 netmask 255.255.255.0
#route add default gw 192.168.0.1
(4)#测试
ping百度 和网关 都可以ping通
页:
[1]