2008年12月27日星期六

Setup MadWifi on Centos5

字号MadWifi is a Linux driver for Wireless LAN devices with Atheros chipsets. The developer team currently provide three drivers, MadWifi, ath5k and ath9k.

MadWifi is one of the most advanced WLAN drivers available for Linux today. It is stable and has an established userbase. The driver itself is open source but depends on the proprietary Hardware Abstraction Layer (HAL) that is available in binary form only. The current stable release is v0.9.4.

ath5k is a relatively new and emerging driver and does not depend on the HAL. It is intended to replace MadWifi in the long run and exceed it feature-wise. ath5k is where most of our development resources are spent on now.

ath9k is the youngest of the three drivers. Initial development was done by Atheros, who then released the complete source code to the community. ath9k supports all currently available 802.11n chipsets from Atheros. For now please see here for further information.

Getting MADWiFi Sources

Download a MadWifi release from sourceforge.net and unpack it. Open a shell terminal in the MadWifi source directory.

Removing old modules

For this step you must be logged on as root.

First, set all your MadWifi devices down:

ifconfig ath0 down
ifconfig wifi0 down
#Repeat these 2 ifconfig lines for every MadWifi device you have (ath1, etc)

Assuming that you're inside the MadWifi directory, execute the following scripts to remove the current modules from your system and its memory:

cd scripts
./madwifi-unload
./find-madwifi-modules.sh $(uname -r)
cd ..

You should then be asked if you are sure that you want to remove the old modules.

Building MadWifi

Now that you have the MadWifi code, it's time to compile it into the actual driver. Thankfully, this is easy.

Assuming that you've met all of the requirements above, and you're inside the MadWifi directory, you can just type:

make
Which will start the build process. Watch for any questions you might be prompted to answer - when it finishes, quickly scan through for any errors. Maybe you will get the following error. It's already fixed,
just follow it.

Ticket #1956 (closed defect: wontfix) madwifi-0.9.4 compilation problem for new RHEL5.2 kernel, 2.6.18-92.el5

Reported by: hs@nhn.ou.edu Assigned to:
Priority: minor Milestone:
Component: madwifi: driver Version: v0.9.4
Keywords:
Cc:
Patch is attached: 0 Pending:

Description (Last modified by mrenzmann)

Hi,

I just upgraded my laptop to RHEL5.2, kernel 2.6.18-92.el5, yesterday, and then got the newest madwifi version, 0.9.4, since 0.9.3 wouldn't compile anymore, but 0.9.4 doesn't, either. I got the following error:

[root@laphep5 current]# make
Checking requirements... ok.
Checking kernel configuration... ok.
make -C /lib/modules/2.6.18-92.el5/build SUBDIRS=/home/local/rpm/wireless/enterasys/madwifi-0.9.4 modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-92.el5-i686'
CC [M] /home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/if_ath.o
In file included from :1:
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:140: error: redefinition of 'skb_end_pointer'
include/linux/skbuff.h:417: error: previous definition of 'skb_end_pointer' was here
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:145: error: redefinition of 'skb_tail_pointer'
include/linux/skbuff.h:835: error: previous definition of 'skb_tail_pointer' was here
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:150: error: redefinition of 'skb_set_network_header'
include/linux/skbuff.h:1021: error: previous definition of 'skb_set_network_header' was here
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:155: error: redefinition of 'skb_reset_network_header'
include/linux/skbuff.h:1016: error: previous definition of 'skb_reset_network_header' was here
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:160: error: redefinition of 'skb_mac_header'
include/linux/skbuff.h:1036: error: previous definition of 'skb_mac_header' was here
/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/../include/compat.h:165: error: redefinition of 'skb_reset_mac_header'
include/linux/skbuff.h:1046: error: previous definition of 'skb_reset_mac_header' was here
make[3]: *** [/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath/if_ath.o] Error 1
make[2]: *** [/home/local/rpm/wireless/enterasys/madwifi-0.9.4/ath] Error 2
make[1]: *** [_module_/home/local/rpm/wireless/enterasys/madwifi-0.9.4] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-92.el5-i686'
make: *** [modules] Error 2

I managed to "fix" it -- well, get it to compile -- by removing the KERNEL_VERSION(2,6,22) section from include/compat.h (see below), since that's where the errors seem to come from.

Not sure why that was necessary, since this is still kernel 2.6.18, but I was just glad it worked, and I'll leave the proper fix to you. :)

Thanks a lot for a great driver,

Horst Severini

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
#include
static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
{
return skb->end;
}

static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
{
return skb->tail;
}

static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
{
skb->nh.raw = skb->data + offset;
}

static inline void skb_reset_network_header(struct sk_buff *skb)
{
skb->nh.raw = skb->data;
}

static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
{
return skb->mac.raw;
}

static inline void skb_reset_mac_header(struct sk_buff *skb)
{
skb->mac.raw = skb->data;
}
#endif

Installing MadWifi

This step will take the built MadWifi, and install it on your system. Once again, make does all of the work for you.

This step needs to be done as root, so either type su and enter root's password, or if you have it set up (e.g. Ubuntu), prefix the following command with sudo.

To install the driver, type:

make install

This will copy all of the modules, tools and man pages to the correct directories on your system. You've now completed the basic install.

Loading the MadWifi Module

This step will load the MadWifi driver module into your running system. This essentially lets all other software know how to talk to your MadWifi hardware.

This step needs to be done as root, so either type su and enter root's password, or if you have it set up (e.g. Ubuntu), prefix the following command with sudo.

To load the driver module, type:

modprobe ath_pci

If after running this command ifconfig doesn't show the additional wireless interface you might need to reboot. If you have any problems with building the MadWifi driver, please refer to UserDocs/BuildProblems.

Creating an Interface

MADWiFi supports virtual access points, which means you can create more than one wireless device per wireless card. By default, a sta mode VAP is created, which is MadWifi talk for a 'managed mode wireless interface'.

If your svn snapshot is more recent than the 23rd January 2006, (r1407) than you can skip the following step:

If not, then follow these instructions to make a normal station mode interface. Type (as root):

wlanconfig ath0 create wlandev wifi0 wlanmode sta

If wlanconfig doesn't work, you retry it after executing 'wlanconfig ath0 destroy'.

Now, if you type iwconfig, you should see a list like the following:

eth0 no wireless extensions. lo no wireless extensions. wifi0 no wireless extensions. ath0 IEEE 802.11g ESSID:"" Mode:Managed Frequency:2.457 GHz Access Point: 00:00:00:00:00:00 Bit Rate:0 kb/s Tx-Power:20 dBm Sensitivity=0/3 Retry:off RTS thr:off Fragment thr:off Power Management:off Link Quality=0/94 Signal level=-95 dBm Noise level=-95 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0

Then we need to bring up the wireless interface. This is done by typing (as root):

ifconfig ath0 up

There is more information on the creating of interfaces in UserDocs.

Scanning for Access Points

If you know that there are some APs around, having a quick scan can be an excellent way of getting some instant gratification, and knowledge that everything's working OK.

The first step is to insert the scanning module. Type (as root):

modprobe wlan_scan_sta

Next, you can do the actual scan, which can be done in two ways.

The first way is specific to MadWifi. and gives you a nice, succinct results table.

This is done by issuing the command (again, as root):

wlanconfig ath0 list scan

This should give you a list that looks something like this:

SSID BSSID CHAN RATE S:N INT CAPS eddie 00:06:25:e8:3a:05 6 54M 36:0 100 EPs

The second way is the more usual way of scanning (and works with other wireless cards), it also gives you somewhat more information, and is therefore a bit less easy to read. The command is:

iwlist ath0 scan

Which gives an output which looks like this:

ath0 Scan completed : Cell 01 - Address: 00:06:25:E8:3A:05 ESSID:"eddie" Mode:Master Frequency:2.437 GHz (Channel 6) Quality=37/94 Signal level=-58 dBm Noise level=-95 dBm Encryption key:on Bit Rate:1 Mb/s Bit Rate:2 Mb/s Bit Rate:5.5 Mb/s Bit Rate:11 Mb/s Bit Rate:18 Mb/s Bit Rate:24 Mb/s Bit Rate:36 Mb/s Bit Rate:54 Mb/s Bit Rate:6 Mb/s Bit Rate:9 Mb/s Bit Rate:12 Mb/s Bit Rate:48 Mb/s Extra:bcn_int=100

Especially useful is the line reading Encryption key:on, which indicates that this AP is running some kind of WEP.

If you get a message such as:

ath0 Failed to read scan data : Resource temporarily unavailable

instead of actual scan results, and you are in an environment that requires a shared encryption key, try running:

iwconfig ath0 key iwpriv ath0 authmode 2

This will tell the card that it is operating in a restricted, shared-key environment, and thus it needs to use the key you supply with iwconfig. To use an open system key (which is often considered more secure) use iwpriv authmode 1:

iwconfig ath0 key iwpriv ath0 authmode 1

Once this is done, re-run the scan, and you may see proper results.


没有评论: