Hostapd的功能就是作为softAP的认证服务器,负责控制管理stations(通常可以认为带无线网卡的PC)的接入和认证。hostapd一般与wpa_supplicant同时提供,这个东西是实现WPA加密认证的。
cp defconfig .config
vi .config
CFLAGS += -I/home/imx6s/third/libnl-3.2.25/include/
CFLAGS += -I/home/imx6s/third/openssl-1.0.1e/include/
CFLAGS +=-I/home/imx6s/linux-3.0.101/include/
LIBS += -L/home/imx6s/third/libnl-3.2.25/lib-lnl-3
LIBS += -L/home/imx6s/third/openssl-1.0.1e/-lssl -lcrypto
CC=arm-linux-gcc
make
../src/drivers/drivers.o:(.data+0x0):undefined reference to `wpa_driver_nl80211_ops'
../src/crypto/crypto_openssl.o: In function`md4_vector':
/home/imx6s/third/RTL8188-hostapd-master/hostapd/../src/crypto/crypto_openssl.c:117:undefined reference to `EVP_md4'
这个错其实跟openssl的lib有关系,将EVP_md4改为EVP_md5就可以了。
../src/drivers/driver_nl80211.c:1695:2:error: too few arguments to function 'genl_ctrl_alloc_cache'
vi .config 先mask掉
#CONFIG_DRIVER_NL80211=y
但安装时hostapd -d/etc/hostapd.conf &,出现如下问题:
Configuration file: /etc/hostapd.conf
Line 2: invalid/unknown driver 'nl80211'
看来这个driver的编译问题是必须要解决的。
从官网上下载的hostapd-1.0版本编译的时候会出错,因为它没有支持nl80211的驱动。
(../src/drivers/driver_nl80211.c:95:9: error:too few arguments to function ‘genl_ctrl_alloc_cache’)
从git clonegit://w1.fi/srv/git/hostap.git hostapd这里下载编译才没有错误。
新建 vi /etc/hostapd/hostapd.conf
interface=wlan0
#interface=wlan0
driver=nl80211
#driver=madwifi
ssid=YOUR_SSID
channel=9
hw_mode=g
macaddr_acl=0
ignore_broadcast_ssid=0
auth_algs=1
wpa=3
wpa_passphrase=YOUR_PASSPHRASE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
最后执行:hostapd-d /etc/hostapd/hostapd.conf
同时,libnl也不要用最新的libnl3.2.25,改为libnl-1.1.4。明显这是hostapd没有随libnl同步更新所导致的。
开启NAT功能后就可以连接WAN了。
iptables -t nat -A POSTROUTING -o eth0 -jMASQUERADE
测试脚本:
insmod/lib/modules/mlan.ko;insmod /lib/modules/sd8xxx.ko drv_mode=2 cfg80211_wext=12
ifconfig uap0192.168.0.1
udhcpd/etc/udhcpd.conf
hostapd -d/etc/hostapd.conf &