Linux in a Wireless World

By Stew Benedict | Nov 15, 2000 | Print this Page
http://www.enterprisenetworkingplanet.com/netsysm/article.php/624951/Linux-in-a-Wireless-World.htm

Want to join the wireless networking revolution, but you're running Linux? Not to fear! Linux has plenty of support for wireless networking devices. In this article, I'll review your wireless options.

The Wireless Networking Page

Your first stop should be the Linux Wireless Networking page. This page gives a pretty comprehensive look at the various hardware and software options available. Once you've reviewed the options, you need to decide how you want to implement wireless in your particular scenario. There are a couple of ways to go: You can use ad-hoc mode, which is a peer-to-peer setup; or you can install an access point to tie into your normal network. Thanks to Linux's flexibility, you can use the ad-hoc connection to implement the latter with a little routing magic.

On my network, I ended up with a pair of Compaq 2Mbps PCMCIA wireless cards, with a pair of PCI adapters that accept the cards. On my laptop, I use the card; on the server, I use the card and the adapter. These cards are based on the Harris Prism chipset, and you can downloaded the necessary software here. You may also need the Linux PCMCIA drivers, which can be found here.

Laptop Setup

To set up a laptop, you'll need the Linux PCMCIA drivers, your kernel sources, and the linux-wlan drivers. You'll also need the kernel source, which is generally in /usr/src/linux. You set up the PCMCIA services as follows. First, as root:

cp pcmcia-cs-3.1.19.tar.gz /usr/src
cd /usr/src
tar -xzf pcmcia-cs-3.1.19.tar.gz
cd pcmcia-cs-3.1.19
make config
make all

If you finish this without errors, then:

make install

Next, set up Wlan, again as root:

cp linux-wlan-0.3.4.tar.gz /usr/src
cd /usr/src
tar -xzf linux-wlan-0.3.4.tar.gz

Now you need to edit config.mk, using your preferred Linux test editor:

LINUX_SRC=/usr/src/linux
PCMCIA_SRC=/usr/src/pcmcia-cs-3.1.19
MODULES_DIR=/lib/modules/2.2.9-19mdk
INST_EXEDIR=/sbin
DESTDIR=
MAKE_ISA=n
MAKE_CS=y

By default, the MAKE_ISA value is y and MAKE_CS is n. However, you want the MAKE_CS value to be , because it's for the PCMCIA card. The Linux kernel stores its modules in the modules entry. The PCMCIA_SRC entry is the directory you created earlier. Save this file and continue:

make clean
make all

If there are no errors, continue with:

make install

Once you make and install wlan, you need to do a couple of manual things:

cp wlan.config wlan wlan.opts /etc/pcmcia
cd /etc/pcmcia
chmod 0755 wlan wlan.opts

The drivers are now in place, and you need to do some configuration work. Let's start with PCMCIA. Under Linux, the PCMCIA drivers run a cardmgr daemon that watches for inserts and removals of cards. Cardmgr looks at the card's signature and configures the system appropriately via shell scripts.

These scripts all reside in /etc/pcmcia, and will use normal system tools to configure the cards by loading/removing appropriate modules and running any other configuration tasks necessary. Like most things in Linux, they are all plain-text scripts, so you can customize them to your liking once you understand how they work.

In addition, a command-line program, cardctl, lets you query and change the card-slot configuration. A GUI application, cardinfo, performs nearly the same tasks, but wrapped in a GUI for X window.

You need to edit /etc/pcmcia/config and add the following line, near the bottom:

source ./wlan.config

You will also need to edit wlan.opts and set up your network configuration. The important lines are as follows:

# Scan for which SSID?
SCAN_SSID=""
DESIRED_SSID="AYS_NET"

# Scan for which BSS and type?
SCAN_BSSID="ff:ff:ff:ff:ff:ff"
SCAN_BSSTYPE=both               # both|ind|infr
SCAN_TYPE=active                # active|passive

# Define scan range
SCAN_STARTCH=1
SCAN_ENDCH=11
SCAN_TIMEPERCHANNEL=100

# Create a BSS if one not detected?
CREATEBSS=no

Essentially, you're saying to scan for Basic Service Set (BSS) AYS_NET at startup, and if it isn't found, to not create your own BSS. The IDs and channels are left at the defaults, so the driver scans all available channels. If you were in a multi-wlan environment, you might want to limit the search appropriately.

For my Compaq cards, there was no appropriate entry in wlan.config, so I had to do some research to create my own.

When a card is recognized properly and configured, cardmgr issues two high-pitched beeps. If the hardware is recognized but not set up, you will hear one high and one low beep. If the card is not recognized, cardmgr emits just one low beep, which is what I got for the Compaq card. As root, I ran the following:

[root@omnibook]# cardctl ident
Socket 0:
    no product info available
Socket 1:
    product info: "Compaq", "2Mbps_Wireless_LAN_Card", "", ""
    manfid: 0x0138, 0x0000
    function: 6 (network)

This result seemed like a good sign; at least it looked like the card I wanted. I then looked at some of the other entries in wlan.config, and based on the previous output, created the following entry:

card "Compaq"
manfid 0x0138, 0x0000
bind "am930_cs" 

This got me the initial high beep and left me to set up the networking scripts to tie the card into the TCP/IP network. Doing so requires editing /etc/pcmcia/network.opts:

# IP address
IPADDR="192.168.193.40"
# Netmask
NETMASK="255.255.255.0"
# Network address
NETWORK="192.168.193.0"
# Gateway address
GATEWAY="192.168.193.1"
# Domain name
DOMAIN="ays.net"
# Nameserver #1
DNS_1="207.217.126.81"

There's more, and you can set up multiple names for different schemes, but the previous lines show the critical parts. Now start the cardmgr daemon:

/etc/rc.d/init.d/pcmcia start

That's ityou should see the following message on the console when you insert the card:

am930: Io=0x100 Iraq=3
am930: Firmware Banner: PCnetMobile:v2.01 101498 PI005
f/w version:2.01  date:101498 pi:5
ethconv=rfc1042

If not, then you'll need to go back, review your config files, and look at the log entries in /VAR/log/messages. Chances are you've made a typo, or the card is not being recognized. Any changes to files in /etc/pcmcia require restarting the cardmgr daemon with

/etc/rc.d/init.d/pcmcia restart

Until the server end is set up, you will still get the low beep and no network configuration.

Server Setup

On the server, I had to add the PCI card PCMCIA adapter to the machine. As a result, I had to shut down the server and open the case. Normally, under Linux, this task and kernel updates are the only reasons you need to reboot. Most changes can be done with the system running. I installed the card and then rebooted:

[root@moe /root]# cat /proc/pci:

Bus  0, device  15, function  0:
PCMCIA bridge: Cirrus Logic CL 6729 (rev 7).
Slow devsel. IRQ 3. 
I/O at 0xa800 [0xa801].

The card was recognized. (In case you aren't aware, the /proc directory under Linux contains a virtual filespace that details all your hardware and software interfaces with the kernel. You can discover a wealth of information by exploring these files.)

On the server, you must do a little more work to get PCMCIA working. You need to edit /etc/sysconfig/pcmcia to help the cardmgr daemon set up the adapter:

PCMCIA=yes
PCIC=i82365
PCIC_OPTS="irq_mode=1 fast_pci=1 do_scan=0 irq_list=3,4,5"
CORE_OPTS=
CARDMGR_OPTS=

In my case, this took considerable trial and error, and I locked up the machine several times before I achieved a successful setup. The Cirrus controllers have some issues that require special setup in /etc/sysconfig/pcmcia, and the system is still not happy if I bring up cardmgr services with no card in the slot. Because this card is more or less stationary, I can live with that; and I can change cards by stopping and restarting the cardmgr service:

/etc/rc.d/init.d/pcmcia stop
swap cards
/etc/rc.d/init.d/pcmcia start

The setup for wlan.config is a little different on the server. This time you do want to create a BSS when you start up:

# Create a BSS if one not detected?
      CREATEBSS=yes
      CREATE_SSID="AYS_NET"   # Pick your own SSID and channel!!!
      CREATE_CHANNEL=1
      CREATE_BCN_INT=100

The server is already running a conventional Ethernet configuration on subnet 192.168.192.0, with an IP address of 192.168.192.1 assigned to itself. For the wireless network, you want a separate subnet, so you'll use 192.168.193.0, assigning 192.168.193.1 to the server. You enter this information in /etc/pcmcia/network.opts, as before:

# Host's IP address, netmask, network address, broadcast address
IPADDR="192.168.193.1"
NETMASK="255.255.255.0"

All the client machines should have the server's IP for the appropriate subnet setup as a gateway for TCP/IP. This is the normal setup I use for IP masquerading and sharing an Internet connection. The server should have IP forwarding enabled. On a Red Hat style system, it will be enabled by the following line in /etc/sysconfig/network:

FORWARD_IPV4=true

Running /etc/rc.d/init.d/pcmcia on the server should generate the two high beeps and display the following on the console:

am930: Io=0x100 irq=3
am930: Firmware Banner: PCnetMobile:v2.01 101498 PI005
f/w version:2.01  date:101498 pi:5
ethconv=rfc1042
AdHoc BSS created, channel=1, rate=20 SSID=AYS_NET

When you run the command ifconfig command, you should now have two Ethernet entries: eth0 and eth1. Now, removing and reinstalling the card generates the two high beeps, and a line like this appears at the end of /VAR/log/messages:

Nov  5 19:34:33 omnibook cardmgr[8131]: + wlan joined BSS, channel=01
bssid=3e:fd:16:00:00:00 ssid="AYS_NET"

You should now be able to access the rest of your network. In my casual testing, I found little difference in performance from the 10Mbs PCMCIA wired Ethernet card.

CrossLinks

Conclusion

I hope you've found this guide useful in setting up a wirelesss network in Linux. For other cards, the driver may be a little different, but the basic concepts are the same. A number of vendors make cards using the Prism and PrismII chipset, and the procedure should be about the same for those cards. //

Stew Benedict is a Systems Administrator for an automotive manufacturer in Cleveland, OH. He also is a freelance consultant, running AYS Enterprises, specializing in printed circuit design, MSAccess solutions for the Windows platforms, and utilizing Linux as a low cost alternative to commercial operating systems and software. He has been using and promoting Linux since about 1994. When not basking in the glow of a CRT, Stew enjoys time with his wife, daughter, and 2 dogs at his future (not too much longer!) retirement home overlooking Norris Lake in the foothills of the Smokies in Tennessee.