The objective of this post is to install hostapd on the ARM target and ready to go for its use. This post explains the instructions on how to setup dependent hostapd libraries and cross-compile the sources against ARM platform running Linux. Read this post which explains the steps to bring up the target with Linux.
Hostapd is a user space daemon for access point and authentication servers. It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server. Hostapd is designed to be a daemon program that runs in the background and acts as the backend component controlling authentication. It supports separate frontend programs and an example text-based frontend, hostapd_cli, is included with hostapd.
Refer to Hostapd page for more information on hostapd features.
The following dependent libraries need to be installed on the target in order to run HostApd.
The libnl suite is a collection of libraries providing APIs to netlink based Linux kernel interfaces. Netlink is a socket based IPC mechanism primarily between the kernel and user space processes. It was designed to be a more flexible successor to IOCTL to provide mainly networking related kernel configuration and monitoring interfaces. The IOCTL risks polluting the kernel and damaging the stability of the system. Netlink socket is simple, only a constant (protocol type) needs to be added to netlink.h. Then the kernel module and application can talk using socket-style APIs immediately.
Threaded Netlink Application
It was common practice to use the process identifier (PID) as the local port number in Netlink. This became unpractical with the introduction of threaded Netlink applications and applications requiring multiple sockets. Therefore libnl generates unique port numbers based on the process identifier and adds an offset to it allowing for multiple sockets to be used. The initial socket will still equal to the process identifier for backwards compatibility reasons.
With reference to the figure below, it shows the common Netlink communication in User space and kernel. Refer to this web page which explains the following Netlink communication mechanisms and important APIs.
- User space to Kernel
- User space to User space
- Listening to kernel multicast notifications
The libnl interfaces are split into several small libraries to not force applications to link against a single, bloated library. Basically, there are following types of libnl libraries available.
libnl: Core library implementing the fundamentals required to use the netlink protocol such as socket handling, message construction and parsing, and sending and receiving of data. This library is kept small and minimalistic. Other libraries of the suite depend on this library.
libnl-route: API to the configuration interfaces of the NETLINK_ROUTE family including network interfaces, routes, addresses, neighbours, and traffic control.
libnl-genl: API to the generic netlink protocol, an extended version of the netlink protocol.
libnl-nf: API to netlink based netfilter configuration and monitoring interfaces (conntrack, log, queue)x
OpenSSL is a cryptography toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) network protocols and related cryptography standards required by them. The OpenSSL program is a command line tool for using the various cryptography functions of OpenSSL's crypto library from the shell.
Install Netlink protocol library sources (libnl)
1. Download the Libnl open-source package. Extract the file and go to root folder of the package.
$ tar -xzf libnl-3.2.24.tar.gz
$ cd libnl-3.2.24
2. Configure the Libnl and make sure to set the configure variables to correct toolchain against which the source need to be compiled. After configuration, run the build command.
$ ./configure --host=arm-linux-gnueabi --prefix=/usr/arm-linux-gnueabi
$ make install
3. Copy the generated shared objects (.so files) to the target root filesystem.
$ cp /usr/arm-linux-gnueabi/lib/libnl-genl-3.so.200 <target_rootfs>/lib/
$ cp /usr/arm-linux-gnueabi/lib/libnl-3.so.200 <target_rootfs>/lib/
Target command (ldconfig)
Configure dynamic linker run-time bindings by executing below command on the target. This creates the necessary links and update to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).
The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated.
$ ldconfig -v
Install OpenSSL library sources
- Download the OpenSSL open-source package. Extract the file and go to root folder of the package.
$ tar -xzf openssl-1.0.1h.tar.gz
$ cd openssl-1.0.1h
2. Export the environment variables which will be used by cross-compiler.
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabi-
3. Configure the OpenSSL as below and make sure to mention "shared" to generate a shared object (.so files) which will be copied to the target for run-time shared object library of OpenSSL. After configuration completes, run the build command as shown below. The "make install" will install the binaries on the host machine which will then be copied to the target.
$ ./Configure linux-generic32 shared --prefix=/usr/arm-linux-gnueabi
$ make install
4. Copy the generated shared objects (.so files) to the target root filesystem.
$ cp /usr/arm-linux-gnueabi/lib/libcrypto.so.1.0.0 <target_rootfs>/lib/
$ cp /usr/arm-linux-gnueabi/lib/libssl.so.1.0.0 <target_rootfs>/lib/
Install hostapd sources
1. Download the HostApd open-source package. Extract the file and go to root folder of the package.
$ tar -xzf hostapd-2.2.tar.gz
$ cd hostapd-2.2/hostapd
2. Copy the existing "defconfig" file to ".config". Edit the .config as shown below.
$ cp defconfig .config
$ vi .config
Now edit .config and make sure to set the following:
CFLAGS += -I/usr/include/libnl3
3. Cross-compile the sources and install the binaries to destination folder.
$ make CC=arm-linux-gnueabi-gcc install DESTDIR=<target_rootfs>
- Create a hostapd configuration file with name "hostpd.conf" (could be any name though) and copy the following content.
- Make sure the following kernel drivers are already installed. Follow this blog to bringup the target with necessary drivers.
Module Size Used by
brcmfmac 209662 0
brcmutil 8504 1 brcmfmac
cfg80211 236740 1 brcmfmac
compat 2028 2 brcmfmac,cfg80211
- Start the hostapd by following command.
- sudo hostapd ./hostapd.conf -B
- The "hostapd_cli" command line tool shall be used to debug/get configuration details of hostapd.
- hostapd_cli -i wlan0 -p /tmp/hostapd/
Copyright (c) 2004-2014, Jouni Malinen <firstname.lastname@example.org> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
mib get MIB variables (dot1x, dot11, radius)
sta <addr> get MIB variables for one station
all_sta get MIB variables for all stations
new_sta <addr> add a new station
deauthenticate <addr> deauthenticate a station
disassociate <addr> disassociate a station
sa_query <addr> send SA Query to a station
get_config show current configuration
help show this usage help
interface [ifname] show interfaces/select interface
level <debug level> change debug level
license show full hostapd_cli license
quit exit hostapd_cli
> AP-STA-CONNECTED X:X:X:X:X:X
The DHCP demon could be different for different platforms such as udhcp, dhcp, etc. The following explains the DHCP configuration using "udhcp". The udhcpd is the DHCP Server demon which is part of BusyBox and is included by default with core OS (no need to install any additional package). It is a perfect candidate for simple and lightweight DHCP Server.
- Create the config script using the “sudo vi /opt/wlan0.sh” command and copy the text as attached with this post (wlan0.sh).
- Assign execute permission to “wlan0.sh” script
- sudo chmod 777 /opt/wlan0.sh
- Execute the script to configure the “wlan0” interface using the following command. This will take care of configuring the wlan0 interface with unique IP address with netmask.
- sudo /opt/wlan0.sh
- Check the interface "wlan0". The interface should be assigned with IP address now.
wlan0 Link encap:Ethernet HWaddr 00:90:4c:c5:12:38
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
- Create a DHCP Configuration file with the “sudo vi /etc/udhcpd.conf” command and fill it will following template.
option subnet 255.255.255.0
option router 192.168.10.1
option lease 43200
option dns 192.168.10.1
option domain local
- Start the DHCP process using the following command
- sudo udhcpd /etc/udhcpd.conf
- You can use following commands to verify if the DHCP process is running properly using the following commands. The DHCP server listens at UDP port 67.
- ps -ef | grep udhcpd
913 root udhcpd /etc/ 933 tc grep udhcpd
- sudo netstat -anp | grep udhcpd
netstat: /proc/net/tcp6: No such file or directory
udp 0 0 0.0.0.0:67 0.0.0.0:* 913/udhcpd
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
wlan0.sh 657 bytes