Thursday, December 13, 2007

nstalling a WLan Card with Atheros Chipset under Debian Linux and NetBSD

http://www.fehu.org/atheros-en.html

Installing a WLan Card with Atheros Chipset under Debian Linux and NetBSD

1. General

1.1 Supported Hardware

1.2 Supported Modes

2. Installation under Debian Linux

2.1 Required Packages

2.2 Installation Process

2.3 Activating the Card

3. Configuration under NetBSD

4. Configuration of wpa_supplicant with WPA-PSK

5. Further Information

5.1 Wireless Applications

5.2 Links

5.3 Manpages



1. General


1.1 Supported Hardware

Basically all cards with a chipset of the type ar5210/ar5211/ar5212 are supported. To be sure, look at http://madwifi.org/wiki/Compatibility. That list will be continously adjusted by users. Another good source of information for chipsets and characteristics is also http://www.wifi.com.ar/doc/wifi/wlan_adapters.html


1.2 Supported Modes

Both the Linux MadWifi driver and the NetBSD driver are based on a binary HAL (Atheros Hardware Abstraction Layer) and its kernel module ath_hal, which enable access to the firmware. That HAL is "closed source" and is developed including an object file by Sam Leffler, employee at Atheros, compiled for different architectures and made available to the OpenSource-community. Which modes are supported and which not depends mainly on the work of that man.

The documentation, forums and mailing lists give information about available modes

  • 802.11a/b/g, in mixed mode
  • 128-bit WEP, WPA-PSK through wpa_supplicant(Linux)
  • Turbo Mode (802.11a only, Channels 42,50,58,152,160)
  • Running the card with specific countrycodes (not in turbo mode!)


2. Installation under Debian Linux

The installation of the kernel drivers is possible both under kernel 2.4 and 2.6.


2.1 Required Packages

The underlaying system is a Debian Sarge with kernel 2.6.7-1-386. Please adapt it to your needs. Following packages must be installed:

cvs
wireless-tools
kernel-headers-2.6.7-1-386
sharutils
uudecode
libc6-dev

2.2 Installation Process

Now it is time to check out the MadWifi drivers from the CVS-repository and install them:

$ cd /usr/src
$ cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/madwifi login
$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/madwifi co madwifi
$ cd madwifi
$ make
$ make install
$ make clean

The installed modules will be located in /lib/modules/2.6.7-1-386/net.


2.3 Activating the Card

General tools for configuring WLan cards can be found in the "wireless-tools" package. They will be explained shortly below:

  • iwconfig edits basic WLan settings like SSID, WEP-Key or channels, among other things. iwconfig(8)
  • iwlist allows scanning, listing frequencies, bit-rates, peers and accesspoints, among other things. iwlist(8)
  • iwpriv allows editing of driver specific (private) settings like turbo mode and frequence ranges, among other things. iwpriv(8)

Before loading the modules it is recommended to verify in which frequence range, subband and channel the accesspoint is running.
The driver works default in 802.11a/b/g in the 5 GHz subband 1+3:

$ iwlist ath0 chan
Channel 01 : 2.412 GHz
Channel 02 : 2.417 GHz
Channel 03 : 2.422 GHz
Channel 04 : 2.427 GHz
Channel 05 : 2.432 GHz
Channel 06 : 2.437 GHz
Channel 07 : 2.442 GHz
Channel 08 : 2.447 GHz
Channel 09 : 2.452 GHz
Channel 10 : 2.457 GHz
Channel 11 : 2.462 GHz
Channel 36 : 5.18 GHz
Channel 40 : 5.2 GHz
Channel 42 : 5.21 GHz
Channel 44 : 5.22 GHz
Channel 48 : 5.24 GHz
Channel 50 : 5.25 GHz
Channel 52 : 5.26 GHz
Channel 56 : 5.28 GHz
Channel 58 : 5.29 GHz
Channel 60 : 5.3 GHz
Channel 64 : 5.32 GHz
Channel 149 : 5.745 GHz
Channel 152 : 5.76 GHz
Channel 153 : 5.765 GHz
Channel 157 : 5.785 GHz
Channel 160 : 5.8 GHz
Channel 161 : 5.805 GHz
Channel 165 : 5.825 GHz

If the card should be operated with these settings, try

$ modprobe ath_pci

To get support for country specific frequencies, it is necessary to assign the parameter "countrycode" while loading the module.
For example: Germany, 5 GHz subband 1+2

$ modprobe ath_pci countrycode=276
$ iwlist ath0 chan
ath0 255 channels in total; available frequencies :
Channel 01 : 2.412 GHz
Channel 02 : 2.417 GHz
Channel 03 : 2.422 GHz
Channel 04 : 2.427 GHz
Channel 05 : 2.432 GHz
Channel 06 : 2.437 GHz
Channel 07 : 2.442 GHz
Channel 08 : 2.447 GHz
Channel 09 : 2.452 GHz
Channel 10 : 2.457 GHz
Channel 11 : 2.462 GHz
Channel 12 : 2.467 GHz
Channel 13 : 2.472 GHz
Channel 36 : 5.18 GHz
Channel 40 : 5.2 GHz
Channel 44 : 5.22 GHz
Channel 48 : 5.24 GHz
Channel 52 : 5.26 GHz
Channel 56 : 5.28 GHz
Channel 60 : 5.3 GHz
Channel 64 : 5.32 GHz
Channel 100 : 5.5 GHz
Channel 104 : 5.52 GHz
Channel 108 : 5.54 GHz
Channel 112 : 5.56 GHz
Channel 116 : 5.58 GHz
Channel 120 : 5.6 GHz
Channel 124 : 5.62 GHz
Channel 128 : 5.64 GHz
Channel 132 : 5.66 GHz
Channel 136 : 5.68 GHz
Channel 140 : 5.7 GHz
Current Frequency:2.412GHz (channel 01)

These "countrycodes" can be viewed at http://www.unicode.org/onlinedat/countries.html. They are stored in the EEPROM of the card and aren't writeable.

If the modules are loaded with false settings unload the driver

$ modprobe -r ath_pci

and go on with experimentation.

If the card should be bound to 802.11a,b or g, do

$ iwpriv ath0 mode X

where X stands for 0=802.11a/b/g, 1=802.11a, 2=802.11b, or 3=802.11g.

The turbo mode is only possible in the 5Ghz band and limited to a few channels in subband 1+3. The countrycodes must not be set!

$ modprobe ath_pci
$ iwpriv ath0 mode 1
$ iwpriv ath0 turbo 1
$ iwlist ath0 chan
ath0 255 channels in total; available frequencies :
Channel 42 : 5.21 GHz
Channel 50 : 5.25 GHz
Channel 58 : 5.29 GHz
Channel 152 : 5.76 GHz
Channel 160 : 5.8 GHz
Current Frequency:5.21GHz (channel 42)

But even with the latest drivers it wasn't possible to convince Linux to enable turbo mode... After allocating an IP you get the error message "ath0: unable to reset hardware; hal status 12"

An example for connecting to an AP with WEP

$ modprobe ath_pci countrycode=276
$ iwconfig ath0 essid blabla
$ iwconfig ath0 key 14929429325878194789834632
$ ifconfig ath0 192.168.1.66

If you want to save your settings for automatical loading after a reboot, you have to adapt /etc/modprobe.d/aliases for 2.6, or alternatively for 2.4 /etc/modutils/aliases, and /etc/network/interfaces.

$ echo "alias ath0 ath_pci"  >> /etc/modprobe.d/aliases
$ echo "options ath_pci countrycode=276" >> /etc/modprobe.d/aliases
$ update-modules
$ cat /etc/network/interface
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Wireless
auto ath0

# static
#iface ath0 inet static
# address 192.168.1.66
# netmask 255.255.255.0
# broadcast 192.168.1.255
# up /sbin/iwpriv ath0 mode 3
# up /sbin/iwconfig ath0 essid "blabla" rate 54M key 14929429325878194789834632

# dhcp
iface ath0 inet dhcp
pre-up /sbin/iwpriv ath0 mode 3
pre-up /sbin/iwconfig ath0 essid "blabla" rate 54M key 14929429325878194789834632

3. Installation under NetBSD

Tested and documented: Hubert Feyrer


With NetBSD the setup is easier because the driver is already in the kernel provided that you use NetBSD 2.0 or higher.
The drivers default settings, the various modes, limitations etc. are equal to the Linux MadWifi driver due to the identical HAL.

Listing the modes can be done with

$ ifconfig -m ath0

To use the 5-GHz band, run

$ ifconfig ath0 ssid blabla media autoselect mode 11a

Enabling the turbo mode

$ ifconfig ath0 ssid blabla chan 58 media autoselect mode 11a mediaopt turbo"

The "countrycode" is adjustable with the following command:

sysctl -w hw.ath.countrycode=276

To configure the card automatically after a system boot add the following information to /etc/rc.conf, for instance :
...

#
# WaveLAN+Internet Config
# static
#ifconfig_ath0="10.0.0.1 netmask 255.255.0.0 ssid blabla chan 58 media autoselect mode 11a mediaopt turbo"

# dhcp
ifconfig_ath0="mode 11a nwkey 0x14929429325878194789834632 ssid fehu.org"
dhclient=YES
dhclient_flags="ath0"

...

Further information:
* ath(4) Manpage
* http://www.netbsd.org/Documentation/network/wavelan.html



4. Configuration of wpa_supplicant with WPA-PSK


Unfortunately at the moment WPA is only possible with Linux.
The next steps explain how to enable WPA-PSK authentication (WPA-Personal) with wpa_supplicant-0.3.8 .

First install libssl-dev, then download wpa_supplicant

cd /usr/src
$ wget http://hostap.epitest.fi/releases/wpa_supplicant-0.3.8.tar.gz

Now let's install the drivers. To compile them you have to create a .config in the same directory. Either edit defconfig and copy it to .config , or make a new file like me. I will show the content with "cat"

$ tar xvzf wpa_supplicant-0.3.8.tar.gz
$ cd wpa_supplicant-0.3.8
$ cat .config

CONFIG_DRIVER_MADWIFI=y
CFLAGS += -I/usr/src/madwifi
CONFIG_DRIVER_WEXT=y
CONFIG_IEEE8021X_EAPOL=y
CONFIG_EAP_MD5=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_TLS=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_TTLS=y
CONFIG_EAP_GTC=y
CONFIG_EAP_OTP=y
CONFIG_EAP_LEAP=y
CONFIG_PKCS12=y
CONFIG_CTRL_IFACE=y

$ make && make install

Then you have to build a configuration-file for wpa_supplicant. Again either edit wpa_supplicant.conf and copy it to somewhere or make a new file. I called it wpa-fehu.conf and placed it in /etc. The content is

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
network={
ssid="fehu.org"
scan_ssid=1
priority=5
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
#psk="mysecretpassword"
psk=283fe364eb0ce1352c1831dee1ed08481eda8ba62583d6c6589a386cbd6957af
}

In "psk=" you have to insert your Pre-Shared-Key. To get this key wpa_supplicant provides a tool called "wpa_passphrase"

$ wpa_passphrase fehu.org mysecretpassword
network={
ssid="fehu.org"
#psk="mysecretpassword"
psk=283fe364eb0ce1352c1831dee1ed08481eda8ba62583d6c6589a386cbd6957af
}

Start wpa_supplicant. After a few seconds your card should be connected to your AP. The option "-d" is only necessary for debugging

$ wpa_supplicant -w -i ath0 -c /etc/wpa-fehu.conf -D madwifi -d

If you want automatical configuration at boot time, adapt /etc/network/interfaces

$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Wireless
auto ath0

# static
#iface ath0 inet static
# address 192.168.1.66
# netmask 255.255.255.0
# broadcast 192.168.1.255
# up /sbin/iwconfig ath0 rate 54M
# up /usr/local/sbin/wpa_supplicant -B -w -i ath0 -Dmadwifi -c /etc/wpa-fehu.conf

# dhcp
iface ath0 inet dhcp
pre-up /usr/local/sbin/wpa_supplicant -B -w -i ath0 -Dmadwifi -c /etc/wpa-fehu.conf
pre-up /sbin/iwconfig ath0 rate 54M


5. Further information


5.1 Wireless Applications

* http://apradar.sourceforge.net/ ApRadar
* http://www.janmorgenstern.de/projects-software.html Wavemon
* http://www.open1x.org/ Open Source Implementation of IEEE 802.1X
* http://www.simandl.cz/stranky/linux/wifimon/wifimon_a.htm wifimon
* http://airsnort.shmoo.com/ Airsnort
* http://www.kismetwireless.net/ Kismet
* http://sourceforge.net/projects/wmwave/ wmwave

5.2 Links

* http://www.mattfoster.clara.co.uk./madwifi-faq.htm Unofficial MadWifi-Faq
* http://sourceforge.net/projects/madwifi MadWifi Project Page
* http://sourceforge.net/mail/?group_id=82936 MadWifi Mailinglisten
* http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html Wireless Toolsy

5.3 Manpages

Linux:

NetBSD:

No comments:

如何发掘出更多退休的钱?

如何发掘出更多退休的钱? http://bbs.wenxuecity.com/bbs/tzlc/1328415.html 按照常规的说法,退休的收入必须得有退休前的80%,或者是4% withdrawal rule,而且每年还得要加2-3%对付通胀,这是一个很大...