#!/bin/sh # # wlan # jms1@jms1.net 2001-09-28 # # handles setup and teardown of wireless network # # note that this script works for a fixed-config (plx or pci) card, where # the module gets installed once at system boot and stays there forever. # i'm not at all sure how the pcmcia stuff works. # # 2001-11-18 jms1@jms1.net - removing my actual SSID and encryption key # to make the file suitable for http://www.jms1.net/wlan/ # (and yes, there's a hot cup of kenya aa on my desk right now...) # # the lines below make the script work nicely with redhat's "chkconfig" # command (and "ntsysv" and "tksysv" as well.) # # chkconfig: 2345 8 92 # description: Installs and configures wireless lan card for ad-hoc mode ######################################## # configuration MODULE=prism2_plx DEVICE=wlan0 SSID=fn0rd CHANNEL=6 KEY=00:c0:ff:ee:00:c0:ff:ee:00:c0:ff:ee:00 #KEY=none ######################################## if [ -x /sbin/wlanctl-ng ] ; then WLANCTL=/sbin/wlanctl-ng else echo /sbin/wlanctl-ng not found. exit 1 fi if [ $# -lt 1 ] ; then usage ; exit 1 ; fi action=$1 case "$action" in start) echo -n "Starting WLAN card:" ######################################## # load the module to support the card if ! /sbin/modprobe $MODULE ; then echo "Failed to load $MODULE module." exit 1 fi ######################################## # Do an explicit reset to force the card to a known # state, just in case we're doing a second "start" # without doing a "stop" first (testing.) $WLANCTL $DEVICE dot11req_reset setdefaultmib=false ######################################## # set up encryption keys if [ "x$KEY" = "xnone" ] ; then $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11ExcludeUnencrypted=false $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11PrivacyInvoked=false echo "Disabled WEP encryption." else ######################################## # see if the card's firmware supports encryption result=`$WLANCTL $DEVICE dot11req_mibget mibattribute=dot11PrivacyOptionImplemented` if [ $? = 0 ] ; then eval $result eval $mibattribute else echo "mibget failed." exit 1 fi if [ $dot11PrivacyOptionImplemented = "false" ] ; then echo "Cannot enable privacy, dot11PrivacyOptionImplemented=false." exit 1 else $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11WEPDefaultKey0=$KEY $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11WEPDefaultKeyID=0 $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11ExcludeUnencrypted=true $WLANCTL $DEVICE dot11req_mibset mibattribute=dot11PrivacyInvoked=true echo "Configured WEP encryption." fi fi ######################################## # start 802.11b ad-hoc mode /sbin/wlanctl-ng wlan0 dot11req_start \ ssid=$SSID \ bsstype=independent \ beaconperiod=100 \ dtimperiod=3 \ cfpollable=false \ cfpollreq=false \ cfpperiod=3 \ cfpmaxduration=100 \ probedelay=100 \ dschannel=$CHANNEL \ basicrate1=2 \ basicrate2=4 \ operationalrate1=2 \ operationalrate2=4 \ operationalrate3=11 \ operationalrate4=22 ;; stop) echo -n "Shutting down WLAN card:" ######################################## # should we assume that the interface is already down? # if not (if you want to manually shut down the interface) # then un-comment this line. # # the "stop" portion of this script would normally only be run # during system shutdown, and the chkconfig sequencing (the "92" # at the top of the script) makes it run this after "network" # has run, which means the interface will already be down. # # of course, it doesn't hurt to run it again, just to be sure. # the module won't un-load without downing the interface first. /sbin/ifdown $DEVICE ######################################## # Do a reset to make sure card is not still trying to generate interrupts. $WLANCTL $DEVICE dot11req_reset setdefaultmib=false ######################################## # pull the modules out of memory /sbin/rmmod -r $MODULE ;; status) echo "No status. Try \"ifconfig ${DEVICE}\" instead." ;; restart|reload) $0 stop $0 start EXITCODE=$? ;; *) echo "$0 {start|stop|restart}" ;; esac