#!/bin/sh #------------------------------------------------------------------------------ # /usr/sbin/wlanconfig - configure wlan options to device 2.1.9 # # Creation: 05.08.2002 rresch # Last Update: $Id$ #------------------------------------------------------------------------------ # include eislib . /var/install/include/eislib device=$1 if [ -n "$device" ] then if [ "$device" != "`echo $device | sed 's/wds//'`" ] then mecho -err "Warning: cannot configure WDS-Interface: \"$device\" " exit else if [ -f /etc/wlan/wlan.opts ] then if [ -n "`iwconfig \"$device\" 2>/dev/null`" ] then . /etc/wlan/wlan.opts else mecho -err " \"$device\" does not support the Wireless Extensions" exit fi else exit fi fi else echo Usage: $0 \ exit fi if [ "$START_WLAN" = "yes" ] then # Detect type of Card drivername='other' # Has to be set to drivername if detected candomaster='no' # Set it to 'yes' when card is capaple of doing AP-Mode candowpa='no' # Set it to 'yes' if card can do WDS with hostap-wds-tools WLAN_NICK=`hostname` if [ -n "$WLAN_CHANNEL" ] then WLAN_STANDARD=`echo $WLAN_CHANNEL | sed 's/[0-9]//g'` fi for i in /etc/wlan/detect_* do if [ "$drivername" = "other" ] then if [ -f "$i" ] then . $i fi fi done # Running Pre-Base-Config Scripts if [ -f /etc/wlan/pre_${drivername} ] then . /etc/wlan/pre_${drivername} fi if [ -f /etc/wlan/pre_generic ] then . /etc/wlan/pre_generic fi # If Card cannot do master then default to ad-hoc if [ "$candomaster" != "yes" ] then if [ "$WLAN_MODE" = "master" ] then WLAN_MODE="ad-hoc" fi fi # Set WLAN-Mode if [ -n "$WLAN_MODE" ] then iwconfig $1 mode $WLAN_MODE fi # Set WLAN-Nick-Name if [ -n "$WLAN_NICK" ] then iwconfig $1 nick $WLAN_NICK fi # Set WLAN-Transfer-Rate if [ -n "$WLAN_RATE" ] then if [ "$WLAN_RATE" = "auto" ] then iwconfig $1 rate auto 2>/dev/null else iwconfig $1 rate ${WLAN_RATE}M 2>/dev/null fi fi # Set WLAN-ESSID if [ -n "$WLAN_ESSID" ] then iwconfig $1 essid "$WLAN_ESSID" fi # Set Encryption case "$WLAN_ENC" in WEP) iwconfig $1 enc $WLAN_ENC_KEY iwconfig $1 enc restricted ;; WPA-PSK) case "$WLAN_MODE" in master) ( echo "interface=$device" echo "driver=$drivername" echo "logger_syslog=-1" echo "logger_syslog_level=2" echo "logger_stdout=-1" echo "logger_stdout_level=2" echo "dump_file=/tmp/hostapd.dump" echo "ctrl_interface=/var/run/hostapd" echo "ctrl_interface_group=0" echo echo "ssid=$WLAN_ESSID" if [ $WLAN_ACL_MAC_N -gt 0 ] then case $WLAN_ACL_POLICY in open) ;; allow) echo "macaddr_acl=1" echo "accept_mac_file=/etc/wlan/hostapd-${device}.macs" ;; deny) echo "macaddr_acl=0" echo "deny_mac_file=/etc/wlan/hostapd-${device}.macs" ;; esac fi echo "auth_algs=3" echo echo "wpa=3" echo "wpa_passphrase=$WLAN_ENC_KEY" echo "wpa_key_mgmt=WPA-PSK" echo "wpa_pairwise=CCMP TKIP" ) > /etc/wlan/hostapd-${device}.conf if [ $WLAN_ACL_MAC_N -gt 0 ] then ( for idx in `seq 1 $WLAN_ACL_MAC_N` do eval mac='$WLAN_ACL_MAC_'$idx echo "$mac" done ) > /etc/wlan/hostapd-${device}.macs fi /usr/sbin/hostapd -B /etc/wlan/hostapd-${device}.conf ;; managed) ;; esac ;; esac # Set WLAN-Channel if [ -n "$WLAN_CHANNEL" ] then WLAN_CHANNEL=`echo $WLAN_CHANNEL | sed 's/[a-z]//g'` if [ $WLAN_CHANNEL != '0' ] then iwconfig $1 channel $WLAN_CHANNEL fi fi # Set RTS-Feature if [ "$WLAN_RTS" = "yes" ] then iwconfig $1 rts 500 fi # Configure WLAN_AP if [ -n "$WLAN_AP" -a $WLAN_MODE = 'managed' -a "$drivername" != 'hostap' ] then /usr/sbin/iwconfig $device ap $WLAN_AP fi # Running Post-Base-Config Scripts if [ -f /etc/wlan/post_${drivername} ] then . /etc/wlan/post_${drivername} fi ifconfig $1 up fi