Friday, February 22, 2008

How to build hostapd package+openSSL

1. use openssl package to generate cross-compiled crypto libray libssl.a and libcrypto.a
2. Edit Makefile, change
gcc=powerpc-405-linux-gnu-gcc
LIBS += -lssl -lcrypto to LIBS += libssl.a libcrypto.a
3. Edit defconfig, comment/uncomment or add the follwoing lines
#CONFIG_DRIVER_HOSTAP=y
CONFIG_DRIVER_MADWIFI=y
CFLAGS += -I. # include current directory

4. copy defconfig .config
5. copy madwifi driver include directories: include and net80211 into current hostapd directories
mkdir net80211
mkdir include
cp ~/madwifi-ng-r3406-20080326/include/*.h include
cp ~/madwifi-ng-r3406-20080326/net80211/*.h net80211


6. copy ssl include directory into openssl directory
mkdir openssl
cp ~/openssl-0.9.8g/include/openssl/*.h openssl/.

7. run make

===========================
How to cross compile openssl
===========================
0. apply hostapd-0.6.3, openssl-0.9.8.g patch:openssl-0.9.8g-tls-extensions.patch
cd ~/openssl-0.9.8g
patch -p1 <../hostapd-0.6.3/patches/openssl-0.9.8g-tls-extensions.patch

1. run ./Configure, or run_configure
#!/bin/bash
if [ -n "$1" ]
then
rootfs=$1
else
rootfs="/localhome/wli/rootfs"
fi
./Configure --openssldir=$rootfs os/compile:powerpc-405-linux-gnu-gcc
2. Make

Wednesday, February 20, 2008

hostapd configuration setting examples

1. WPA/IEEE802.11i configuration
wpa=1=WPA, 2=802.11I, 3=Both
2. WPA preshared key configuation
wpa_passphrase=my_secrete_key #(ascii 8...63 characters)
or
wpa_psk=12324faa3322.....323(64 hex digits)
or wpa_psk_file=/etc/hostapd/wpa_psk #this is a more granular method with list of (mac, psk) pairs in
wpa_psk file.
e.g wpa_psk file
00:00:00:00:00:00 abcdefghji # all mac address use passphrase abcdefghji
3. WPA preshared key configuation
wpa_pairwise=TKIP CCMP #if only CCMP is specified, group cipher will be CCMP only. Otherwise, it will be TKIP

Sample WPA configuration files(CCMP,passphrase:

interface=ath0
bridge=br0
driver=madwifi
logger_syslog=-1
logger_syslog_level=2
logger_stdout=0
logger_stdout_level=0
debug=0
dump_file=/tmp/hostapd.dump.0.0
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=wende
# Open System auth should be used with 802.1X
auth_algs=1
eapol_key_index_workaround=0
wpa=1
#wpa_passphrase=mypassphrase
wpa_psk_file=/etc/hostapd/wpa_psk
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=600


Thursday, February 14, 2008

Madwifi Utility,wireless tool, wireless extension

Wireless Extension-- a API exposing driver to the user space configuration and statistics of Wireless LANs

Wireless Tools --
a set of tools to manipulate the Wireless Extensions

  • iwconfig manipulate the basic wireless parameters
  • iwlist scanning and list frequencies, bit-rates, encryption keys...
  • iwspy get per node link quality
  • iwpriv manipulate the Wireless Extensions specific to a driver (private)
  • ifrename rename interfaces based on various static criteria


1. athctrl --specify max distance of a sta or master to prevent unnecessary collision

(set CTS/retransmission timeouts and few other parameters based on distance)

athctrl -i ath0 -d 1000 #1000=1000m

2. athchans -i ath0 1-2 #restrict channel search to 1-2

3. 80211stats -i ath0 #display statistics of ath0 interface

1 rx from wrong bssid
12 rx discard due to it's a dup
19 rx discard mgt frames
163 rx element unknown
128 rx frame chan mismatch
15248 rx frame ssid mismatch
1 rx deauthentication
76 tx failed for no node
2 active scans started

4. athstats -i wifi0

36309 tx management frames
4264 tx failed due to too many retries
93995 long on-chip tx retries
76599 tx frames with no ack marked
375 tx frames with short preamble
2814 rx failed due to bad CRC
64 PHY errors
3 OFDM restart
61 CCK restart
618787 beacons transmitted
6604 periodic calibrations
rssi of last ack: 41
1 switched default/rx antenna
Antenna profile:
[1] tx 66658 rx 51961
[2] tx 41817 rx 26
5. cat /proc/sys/dev/wifi0

/proc/sys/dev/wifi0/ackrate /proc/sys/dev/wifi0/radar_print
/proc/sys/dev/wifi0/acktimeout /proc/sys/dev/wifi0/radar_print_all
/proc/sys/dev/wifi0/countrycode /proc/sys/dev/wifi0/regdomain
/proc/sys/dev/wifi0/ctstimeout /proc/sys/dev/wifi0/rp
/proc/sys/dev/wifi0/debug /proc/sys/dev/wifi0/rp_flush
/proc/sys/dev/wifi0/diversity /proc/sys/dev/wifi0/rp_ignored
/proc/sys/dev/wifi0/fftxqmin /proc/sys/dev/wifi0/rxantenna
/proc/sys/dev/wifi0/ledpin /proc/sys/dev/wifi0/slottime
/proc/sys/dev/wifi0/maxvaps /proc/sys/dev/wifi0/softled
/proc/sys/dev/wifi0/panic /proc/sys/dev/wifi0/txantenna
/proc/sys/dev/wifi0/radar_dump /proc/sys/dev/wifi0/txintrperiod
/proc/sys/dev/wifi0/radar_dump_all /proc/sys/dev/wifi0/xrpollcount
/proc/sys/dev/wifi0/radar_ignored /proc/sys/dev/wifi0/xrpollperiod

6. cat /proc/sys/dev/ath0

/proc/sys/dev/ath/calibrate /proc/sys/dev/ath/maxvaps
/proc/sys/dev/ath/countrycode /proc/sys/dev/ath/outdoor
/proc/sys/dev/ath/debug /proc/sys/dev/ath/xchanmode
/proc/sys/dev/ath/hal/


7. wlanconfig
Current Madwifi driver supports multiple APs and concurrent Ap/Station mode operation on the same device. Each instance of AP or station is called Virtual AP(VAP). VAPS share the same underlying phy layer, which is the base device (wifi0) when driver is loaded.

Creating or destroying VAPs are done wlanconfig
wlanconfig VAP create wlandev BaseDevice wlanmode mode [bssid] [-bssid] [nosbeacon]
wlanconfig VAP destroy
wlanconfig VAP list [active|ap|caps|chan|freq|keys|scan|sta|wme]

where mode=[sta|adhoc|ap|monitor |wds|ahdemo]
VAP=can be any name or ath or ath0,ath1,...
examples:

7.1. wlanconfig ath0 list ap|scan #scan nearby APs

SSID BSSID CHAN RATE S:N INT CAPS
FGT01 00:12:bf:14:fa:46 1 54M 18:0 100 EPS WME ATH
FGT-Guest1 06:12:bf:14:fa:46 1 54M 18:0 100 EPS WME ATH
foinet-apple 00:0d:88:e5:74:bf 11 54M 25:0 100 EPSs
FGiefingC 00:0d:88:e5:6f:b4 7 54M 7:0 100 EPSs
Fonet_Ex... 00:13:a6:20:27:10 2 11M 42:0 100 EPS
Foet_Ex... 00:13:a6:20:27:00 4 24M 37:0 100 EPs RSN WPA


7.2. wlanconfig ath0 list active|freq|chan #list active channel

Channel 1 : 2412 Mhz 11g Channel 48 : 5240 Mhz 11a Dynamic
Channel 2 : 2417 Mhz 11g Channel 50 : 5250* Mhz 11a Static
Channel 3 : 2422 Mhz 11g Channel 52 : 5260* Mhz 11a
Channel 4 : 2427 Mhz 11g Channel 56 : 5280* Mhz 11a Dynamic
Channel 5 : 2432 Mhz 11g Channel 58 : 5290* Mhz 11a Static
Channel 6 : 2437 Mhz 11g Dynamic Channel 60 : 5300* Mhz 11a
Channel 7 : 2442 Mhz 11g Channel 64 : 5320* Mhz 11a
Channel 8 : 2447 Mhz 11g Channel 149 : 5745 Mhz 11a
Channel 9 : 2452 Mhz 11g Channel 152 : 5760 Mhz 11a Static
Channel 10 : 2457 Mhz 11g Channel 153 : 5765 Mhz 11a Dynamic
Channel 11 : 2462 Mhz 11g Channel 157 : 5785 Mhz 11a
Channel 36 : 5180 Mhz 11a Channel 160 : 5800 Mhz 11a Static
Channel 40 : 5200 Mhz 11a Dynamic Channel 161 : 5805 Mhz 11a Dynamic
Channel 42 : 5210 Mhz 11a Static Channel 165 : 5825 Mhz 11a
Channel 44 : 5220 Mhz 11a


7.3. wlanconfig ath0 list caps # list base device capabilities

ath0=7782e40f
(WEP,TKIP,AES,AES_CCM,HOSTAP,TXPMGT,SHSLOT,SHPREAMBLE,TKIPMIC,WPA1,WPA2,BURST,WME)

7.4. wlanconfig ath0 list sta # list associated stations with current VAP: ath0


ADDR AID CHAN RATE RSSI DBM IDLE TXSEQ TXFRAG RXSEQ RXFRAG CAPS ACAPS ERP STATE MODE
00:18:e7:1a:e6:da 1 6 6M 57 -38 120 11 10 1358 0 EPSs 0 5 Normal


7.5. wlanconfig ath0 list wme #wifi multimedia


AC_BE cwmin 3 cwmax 10 aifs 2 txopLimit 2048
cwmin 3 cwmax 10 aifs 2 txopLimit 2048
AC_BK cwmin 4 cwmax 10 aifs 7 txopLimit 0
cwmin 4 cwmax 10 aifs 7 txopLimit 0
AC_VI cwmin 3 cwmax 4 aifs 1 txopLimit 3008
cwmin 3 cwmax 4 aifs 2 txopLimit 3008
AC_VO cwmin 2 cwmax 3 aifs 1 txopLimit 1504
cwmin 2 cwmax 3 aifs 2 txopLimit 1504

7.6 wlanconfig ath0 list keys # list key associated with VAP ath0

ath0 3 key sizes : 40, 104, 128bits
4 keys available :
[1]: 1234-5678-90 (40 bits)
[2]: off
[3]: off
[4]: off
Current Transmit Key: [1]
Security mode:restricted


8. iwconfig # used only after VAPs being created successful by wlanconfig command.

Usage: iwconfig [interface]
interface essid {NNN|any|on|off}
interface mode {managed|ad-hoc|master|...}
interface freq N.NNN[k|M|G]
interface channel N
interface bit {N[k|M|G]|auto|fixed}
interface rate {N[k|M|G]|auto|fixed}
interface enc {NNNN-NNNN|off}
interface key {NNNN-NNNN|off}
interface power {period N|timeout N|saving N|off}
interface nickname NNN
interface nwid {NN|on|off}
interface ap {N|off|auto}
interface txpower {NmW|NdBm|off|auto}
interface sens N
interface retry {limit N|lifetime N}
interface rts {N|auto|fixed|off}
interface frag {N|auto|fixed|off}
interface modulation {11g|11a|CCK|OFDMg|...} #
interface commit # force to apply changes done via wireless extension immediately

example

8.1 iwconfig ath0 essid hello #set VAP ath0 to essid name "hello"
8.2 iwconfig ath0