XO as AP

From OLPC
Jump to: navigation, search

This documents describes how to set up the XO as an access point using the built-in wireless card.

Setting up the Thinfirm driver / firmware

The access point functionality only works with the libertastf driver, which is not the one bundled in the official builds. To set up this driver follow the instructions at Libertas Thinfirmware HOWTO.

Getting and compiling Hostapd

Hostapd requires a more recent version of libnl than the one included in the OLPC builds. An up to date libnl rpm can be downloaded here. (If you compile hostapd on a different host, you may also have to upgrade libnl and libnl-dev there)

Download hostapd;

git-clone  git://w1.fi/srv/git/hostap.git
cd hostap
git checkout 886a807fb5

The latest tested version on an XO-1 is 886a807fb5. Some more recent versions do not work - in particular, 0b86f67..., current as of 2010-05-19, does not work with the setup described herein.

To compile it, go to the directory hostapd, copy defconfig to .config. On .config:

  1. Uncomment CONFIG_DRIVER_NL80211=y.
  2. To make hostapd use the headers from a kernel different that the one running in you machine, at the end add the lines:
CONFIG_KERNEL_LOC = /path/to/your/kernel-tree
CFLAGS += -I$(CONFIG_KERNEL_LOC)/include

Then compile with make and copy hostapd and hostapd_cli to the target XO.

If you get compilation errors involving missing "netlink/" and/or "openssl/" files, install the libnl and openssl development packages. In Fedora, the incantation is:

# sudo yum install libnl-devel
# sudo yum install openssl-devel

The corresponding Debian package names are (I think) libnl-dev and libssl-dev.

If hostapd was not compiled in a fedora system, it may complain when executing about not finding the library /lib/libssl.so.0.9.8. If that is the case, you can easily fix it doing, on the target XO:

# cd /lib
# ln -s /lib/libssl.so.0.9.8b /lib/libssl.so.0.9.8
# ln -s /lib/libcrypto.so.0.9.8b /lib/libcrypto.so.0.9.8

I [wmb] compiled hostapd on Fedora 12, and when I ran it on the XO, it complained about libssl.so.10 and libcrypto.so.10. I solved that problem by copying those files from /usr/lib/lib{ssl,crypto}.so.10 on the host system into /lib on the XO.

Start hostapd

Copy a hostapd configuration file (example) and customize it. The most relevant fields are ssid and channel. Then start the access point with:

# hostapd -d hostapd.conf

Then other machines will be able to associate to the new created access point. A same-subnet IP address must be assigned to each machine, either manually, via dhcp or link-local, to make them able to connect to each other.

Bridging support

It is easy to set up a bridge between the XO BSS and a wired network. First it is necessary to obtain the bridge utils package with:

# yum install bridge-utils

Assuming the XO is connected via eth0 (e.g. a usb ethernet dongle) the steps would be:

# # This step is necessary for the interface to acquire its real MAC address
# ifconfig wlan0 up
# ifconfig wlan0 down
# brctl addbr br0
# ifconfig eth0 0.0.0.0
# brctl addif br0 wlan0
# brctl addif br0 eth0
# # Bridged interfaces do not forward traffic during the first 30 seconds, while they learn the network structure
# sleep 30
# dhclient br0
# hostapd hostapd.conf

Now, if the wired network offers routing and dhcp capabilities, any client that connect to the XO AP will be able to acquire an IP address via dhcp and access the external network.

WPA support

To activate WPA, edit hostapd.conf to set the appropriate values to wpa and either wpa_psk or wpa_passphrase. Then restart hostapd. A recent version of hostapd is needed for WPA support. Version 886a807fb5 from hostapd git is known to work.