您的位置:首页 > 其它

wpa_supplicant移植与使用(转)

2013-12-02 09:11 477 查看
下载wpa_supplicant最新版和openssl(编译wpa_supplicant需要openssl的库)

我这里使用的是wpa_supplicant-0.7.3.tar.gz和openssl-0.9.8e.tar.gz。

分别解压wpa_supplicant-0.7.3.tar.gz和openssl-0.9.8e.tar.gz,把wpa_supplicant-0.7.3里面的patches文件夹下的openssl-0.9.8e-tls-extensions.patch文件拷贝到openssl-0.9.8e目录下,运行:

pathc–p1

然后建立openssl的安装目录,建议安装在openssl-0.9.8e目录下,因为生成的库等只在交叉编译wpa_supplicant时使用,这样可以保持系统干净。

进入openssl-0.9.8e目录修改Makefile,修改如下:

CC=arm-linux-uclibcgnueabi-gcc

AR=arm-linux-uclibcgnueabi-ar$(ARFLAGS) r

RANLIB=arm-linux-uclibcgnueabi-ranlib

INSTALLTOP=刚才你建立的安装目录,要使用绝对路径,不然在make install的时候会出错

OPENSSLDIR=刚才你建立的安装目录,要使用绝对路径,不然在make
install的时候会出错

然后,执行make&&make
install。

编译wpa_supplicant:

首先建立配置文件:

cp
defconfig .config

然后修改.config,增加以下内容:

CC=arm-linux-uclibcgnueabi-gcc-L/home/gu/ssl/lib

CFLAGS+=-I openssl安装目录/include

LIBS+=-Lopenssl安装目录/lib

make;

最后,生成所需要的可执行程序。

wpa_supplicant的使用主要是配置wpa_supplicant.conf,以下是一个配置文件的例子:

#可有可无,没有的话无法用wpa_cli terminate来关闭wpa_supplicant

ctrl_interface=/var/run/wpa_supplicant

# 确保只有root用户能读取WPA的配置,可有可无,尤其是在嵌入式设备上

ctrl_interface_group=0

# 使用wpa_supplicant来扫描和选择AP,也可以设置成0或2,但只有1才能正确工作

ap_scan=1

network={

#AP的名字

ssid="my_network"

#AP的key

psk="my_key"

}

配置文件弄好后就可以运行wpa_supplicant了:


wpa_supplicant–B
–iwlan0 –c
/etc/tkip.conf

后台运行wpa_supplicant(自动打开wifi模块wlan0,自动搜索AP并连接),参数-B为后台运行,-i为wifi设备,-c指定wpa_supplicant配置文件

wlan0自动获取IP:

udhcpc–i
wlan0

接下来就可以看下网络是否连通了:

iwconfig

udhcpc -i wlan0 -n
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: