hostapd v2.6 交叉编译及测试

交叉编译通过,实测可用。在此记录一下,备忘。

hostapd v2.6依赖libnl和openssl,因此,需要先交叉编译它俩。需要注意,openssl不同版本API不同,如果不能匹配hostapd v2.6会导致编译报错。libnl我用的是libnl-3.2.23,可以用,因此没有尝试其他版本。

源码下载地址:点此下载

1、交叉编译libnl

解压后进入libnl根目录

执行:./configure --host=mips-linux-gnu --prefix=/home/beihj/mips-gcc472-glibc216-32bit/mips-linux-gnu/libc/uclibc/usr PKG_CONFIG_PATH=/home/beihj/mips-gcc472-glibc216-32bit/mips-linux-gnu/libc/uclibc/usr/lib/pkgconfig  CC=/home/beihj/mips-gcc472-glibc216-32bit/bin/mips-linux-uclibc-gnu-gcc

其中,--prefix是源码编译完成后的安装路径,最好安装在交叉编译链中,这样编译其他源代码对libnl有依赖时,可不必特别指明libnl库的路径。在交叉编译链中库安装多了以后,你会发现你的交叉编译链越来越好用了。

PKG_CONFIG_PATH是.pc文件的搜索路径

CC是交叉编译工具的路径

--prefix、PKG_CONFIG_PATH、CC都需要换成自己相应的路径

接下来,make ,这时会报错:

        addr.c:1027: error: 'AF_RDS' undeclared here (not in a function)
        addr.c:1033: error: 'AF_CAN' undeclared here (not in a function)
        addr.c:1034: error: 'AF_TIPC' undeclared here (not in a function)
        addr.c:1038: error: 'AF_ISDN' undeclared here (not in a function)
        addr.c:1039: error: 'AF_PHONET' undeclared here (not in a function)
        make[2]: *** [addr.lo] Error 1
        make[2]: Leaving directory `/work/projects/libnl-3.2.23/lib'
        make[1]: *** [all] Error 2
        make[1]: Leaving directory `/work/projects/libnl-3.2.23/lib'

        make: *** [all-recursive] Error 1

解决方法:libnl-3.2.23/lib/addr.c 中增加下面这些宏

        /* Supported address families. */
        #define AF_RDS                21        /* RDS sockets                         */
        #define AF_CAN                29        /* Controller Area Network      */
        #define AF_ISDN                34        /* mISDN sockets                 */

        #define AF_PHONET        35        /* Phonet sockets                */

再次 make,编译完成后,执行 make install安装libnl库

2、交叉编译openssl

解压后进入openssl根目录,执行./config no-asm shared --prefix=/home/beihj/mips-gcc472-glibc216-32bit/mips-linux-gnu/libc/uclibc/usr/usr

然后修改Makefile文件:将CC、AR、RANLIB、MAKEDEPPROG改为自己相应的交叉编译工具

CC= mips-linux-uclibc-gnu-gcc

AR= mips-linux-uclibc-gnu-ar $(ARFLAGS) r

RANLIB= mips-linux-uclibc-gnu-ranlib

MAKEDEPPROG= mips-linux-uclibc-gnu-gcc

然后,执行make;make install

3、交叉编译hostapd

解压后进入hosdtapd-2.6/hostapd

cp defconfig .config

打开 .config 将CONFIG_LIBNL32前面的注释去掉,这样编译的时候就会去找libnl3.2的库

修改Makefile

CC=arm-linux-gcc      /* 去掉前面的宏定义 */

make 

编译完成后会在hostapd根目录下生成hostapd和hostapd_cli

4、测试

hostapd和hostapd_cli放到开发板上 usr/bin目录下

ifconfig eth0 down

ifconfig wlan0 up                                                               

ifconfig wlan0 192.168.0.10 netmask 255.255.255.0                             

udhcpd /etc/udhcpd.conf &                                                      

hostapd -d /etc/hostapd.conf &

/etc/udhcpd.conf文件内容修改如下:

# The start and end of the IP lease block

start           192.168.0.10   #default: 192.168.0.20

end            192.168.0.100  #default: 192.168.0.254

# The interface that udhcpd will use

interface       wlan0           #default: eth0

分配的IP要与wlan0设置的IP处于同一网段,interface设置为wlan0。

/etc/hostapd.conf文件内容如下:

interface=wlan0

ssid=XXX /* 自己任意设定 */

channel=9

hw_mode=g

ignore_broadcast_ssid=0

auth_algs=1

wpa=3

wpa_passphrase=******** /* 密码自己任意设定 */

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCM

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值