简介
hostapd
AP 侧进程,可以构建一个独立 AP 或者一个 RADIUS 认证服务器
wpa_supplicant
STA 侧进程,包含了 802.1x、WPA 的请求工作
wpad
= hostapd + wpa_supplicant,使用:wpad [hostapd | wpa_supplicant] [arguments]
编译所需源码文件
hostapd$ tree
.
├── hostapd-2.9.tar.gz
├── libnl-3.2.25.tar.gz
├── openssl-1.1.1a.tar.gz
└── wpa_supplicant-2.9.tar.gz
下载链接
-
hostapd-2.9.tar.gz
,wpa_supplicant-2.9.tar.gz
http://w1.fi/releases/ -
libnl-3.2.25.tar.gz
http://www.infradead.org/~tgr/libnl/ -
openssl-1.1.1a
http://www.infradead.org/~tgr/libnl/files/
依赖
hostapd 和 wpa_supplicant 均依赖 libnl 和 openssl
所以先编译 libnl 和 openssl,再编译 hostapd 和 wpa_supplicant。
libnl
$ tar -xvf libnl-3.2.25.tar.gz
$ cd libnl-3.2.25/
$ mkdir _install
$ ./configure CC=arm-linux-gnueabihf-gcc --prefix=$(pwd)/_install --host=arm-linux-gnueabihf
$ make
$ make install
openssl
$ tar -xvf openssl-1.1.1a
$ cd openssl-1.1.1a/
$ ./config no-asm shared --prefix=$(pwd)/__install
$ vim Makefile
-CROSS_COMPILE=
+CROSS_COMPILE=arm-linux-gnueabihf-
-CNF_CFLAGS=-pthread -m64
+CNF_CFLAGS=-pthread
$ make
$ make install
hostapd
$ tar -xvf hostapd-2.9.tar.gz
$ cd hostapd-2.9/hostapd
$ cp defconfig .config
$ vim .config
CONFIG_LIBNL32=y
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/include/libnl3
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/include
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/lib
$ vim Makefile
+CC=arm-linux-gnueabihf-gcc
ifndef CC
CC=gcc
endif
$ make
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libnl-3.0' found
报错,提示通过 pkg-config 没有搜索到 libnl-3.0 库,需要通过 PKG_CONFIG_PATH 环境变量指明 libnl-3.0.pc 所在的目录,以至于能够找到 libnl-3.0 库。
我们可以手动执行命令
pkg-config --list-all
,可以看到列表中确实没有 libnl-3.0 库,因为在前面步骤中,我们是把 libnl-3.0 库安装在源码所在目录的,并且我们是交叉编译,编译出来的库也都是 ARM 架构的,也不应该安装到宿主机的默认动态库目录中。
解决办法:
$ export PKG_CONFIG_PATH=/home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib/pkgconfig/
$ make
wpa_supplicant
$ tar -xvf wpa_supplicant-2.9.tar.gz
$ cd wpa_supplicant-2.9/wpa_supplicant/
$ cp defconfig .config
$ vim .config
CONFIG_LIBNL32=y
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/include/libnl3
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/include
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/lib
$ vim Makefile
+CC=arm-linux-gnueabihf-gcc
ifndef CC
CC=gcc
endif
$ make
...
dbus/dbus_dict_helpers.c:10:10: fatal error: dbus/dbus.h: 没有那个文件或目录
10 | #include <dbus/dbus.h>
| ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1991:dbus/dbus_dict_helpers.o] 错误 1
报错,提示找不到 dbus/dbus.h 文件
解决办法,我们不需要 dbus 功能,所以直接关闭该功能
vim .config
# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
-CONFIG_CTRL_IFACE_DBUS_NEW=y
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
-CONFIG_CTRL_IFACE_DBUS_INTRO=y
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
make
over