DHCP and a wireless PCMCIA card

I'd joined a new company, and for the first few months I'd had to use maroon as my business laptop. We had decided to go wireless from day one for our new office, and I'd purchased a D-Link router and set of DWL-650+ 22MB wireless cards for our PCs. While this card worked well under Windows, there was no support for FreeBSD: partly because it was a 32-bit card and partly because the DWL-650+ uses a new chip set compared with the 11MB DW-650 card.

I decided I should buy a wireless card that was supported by FreeBSD 4.7. I purchased a Netgear MA401RA, I added a line to the /etc/rc.conf file to invoke DHCP on the wireless interface:

ifconfig_wi0="DHCP"

The problem I had to solve was to configure the wireless card to use the SSID name, channel number and WEP encryption key defined for the wireless hub/router, before the DHCP client tried to get hold of an address from the DHCP server.

The solution that worked was to copy the entry for the MA401RA card from the /etc/defaults/pccard.conf file to the local override file, /etc/pccard.conf file. To this, I added a line to configure the wireless card:

# Netgear MA401RA
card "NETGEAR MA401RA Wireless PC" "Card"
        config  auto "wi" ?
added-> insert /sbin/ifconfig wi0 ssid default channel 6 wepmode on wepkey xx
        insert  /etc/pccard_ether $device start
        remove  /etc/pccard_ether $device stop

An alternative I investigated was to use the /etc/dhclient-entry-hooks file. This file is invoked by dhclient on startup before it tries to request a DHCP address from a server. However, anything I put in this file caused dhclient to die, complaining that it could not find interface "wi0". Maybe I'll investigate when I have more time.

Addendum

It turned out this wasn't really the right way of setting up a wireless card in FreeBSD, as I discovered when upgrading to FreeBSD 4.8. Here's a revised approach.