[Fli4l_dev] fli4l 3.7.0-rev22124 & opt_wlan

Robert Resch fli4l at robert.reschpara.de
So Jun 3 22:04:09 CEST 2012


Am 03.06.2012 21:15, schrieb Robert Resch:

> Iss im nächsten Tarball korrigiert.

Bzw. die betreffende Files hier im Attachment.

(Verzeichnis: opt/files/usr/local/wlan)

Robert

-------------- nächster Teil --------------
#!/bin/sh

drivername=`grep $device /var/run/netdrivers.conf | sed "s/^$device=//"`

# Get corresponding phy-device with the mac from /var/run/wlanphy.conf
if [ -f /var/run/wlanphy.conf ]
then
  # get the mac-address of the selected device
  mac=`ip link show $device | sed -n 'y/abcdef/ABCDEF/;s/.*\(\([0-9A-F]\{2\}:\)\{5\}[0-9A-F]\{2\}\).\+/\1/p'`
  # strip the first byte because this one changes in VAP-Usage only from 00
  mac5=`echo $mac | sed 's/^...//'`
  # read phy-device-name
  phy=`sed -n "s/=[0-9A-F]\{2\}:$mac5//p" /var/run/wlanphy.conf`
  
  # If found we have a cfg80211 device - now we ask iw for details
  if [ -n "$phy" ]
  then
    ismac80211="yes"
    candowpa="yes"	# All cfg80211 drivers should be able to do WPA
    if [ -n "`iw phy $phy info | sed -n 's/.*\* AP$/AP/p'`" ]
    then
      candomaster="yes"
    fi
    if [ -n "`iw phy $phy info | grep -i HT[24]0`" ]
    then
      cando_n="yes"
      if [ -n "`iw phy $phy info | grep -i HT40`" ]
      then
        cando_n40="yes"
      else
        cando_n40="no"
      fi
    fi
    if [ -n "`iw phy $phy info | grep AP\/VLAN`" ]
    then
      cando_vlan="yes"
    fi
  fi
else
  case "$drivername" in
    ath_pci)
      candomaster="yes"
      candowpa="yes"
      ismac80211="no"
      cando_n="no"
    ;;
  esac
fi
-------------- nächster Teil --------------
#!/bin/sh

generic_hostapd_cryptconfig ()
{
  if [ "$WLAN_WPA_KEY_MGMT" ]
  then
  cat <<EOF
wpa=$WLAN_WPA_TYPE
wpa_passphrase=$WLAN_WPA_PSK
wpa_key_mgmt=WPA-PSK
wpa_pairwise=$WLAN_WPA_ENCRYPTION
EOF
  else
    if [ $WLAN_ENC_N -gt 0 -a "$WLAN_ENC_MODE" != "off" ]
    then
      echo wep_default_key=`expr $WLAN_ENC_ACTIVE - 1`
      case $WLAN_ENC_MODE in
        open) auth_algs=1 ;;
        on) auth_algs=3 ;;
        restricted) auth_algs=2 ;;
      esac
      echo auth_algs=$auth_algs
      for i in `seq 1 $WLAN_ENC_N`
      do
        eval wepkey=\$WLAN_ENC_$i
        if [ -n "`echo $wepkey | sed -n '/^s:/p'`" ]
        then
          echo wep_key`expr $i - 1`=\"`echo $wepkey | sed 's/^s://'`\"
        fi
      done
    fi
  fi
}

generic_hostapd_aclconfig ()
{
  if [ -z "$idx" ]
  then
    aclfile=/etc/hostapd.${device}.acl
  else
    aclfile=/etc/hostapd.${device}_${idx}.acl
  fi
  if [ "$WLAN_ACL_MAC_N" -eq 0 ]
  then
    echo macaddr_acl=0
  else
    if [ "$WLAN_ACL_POLICY" == "allow" -o "$WLAN_ACL_POLICY" == "deny" ]
    then
      > $aclfile
      if [ "$WLAN_ACL_POLICY" == "allow" ]
      then
        echo macaddr_acl=1
        echo accept_mac_file=$aclfile
      else
        echo macaddr_acl=0
        echo deny_mac_file=$aclfile
      fi
      for idx in `seq 1 $WLAN_ACL_MAC_N`
      do
        eval mac='$WLAN_ACL_MAC_'$idx
        echo $mac >> $aclfile
      done
    else
      echo macaddr_acl=0
    fi
  fi
}

generic_hostapd_essid ()
{
  if [ "$WLAN_NOESSID" = "yes" ]
  then
    echo ignore_broadcast_ssid=1
  fi
}

#if [ "$WLAN_WPA_KEY_MGMT" -a "$WLAN_MODE" = master ]; then
if [ "$WLAN_MODE" = master ]; then

    case $drivername in
        ath_pci) 
            hostapd_driver=madwifi 
            ;;
        hostap) 
            hostapd_driver=hostap 
	    WLAN_STANDARD='b'
            ;;
        prism54)
            hostapd_driver=prism54
            ;;
        *)
	    if [ "$ismac80211" != "yes" ]
	    then
              log_error "hostapd: cannot find suitable driver for $drivername"
              hostapd_driver=
	    else
	      hostapd_driver=nl80211
	    fi
            ;;
    esac
    if [ "$WLAN_WPA_DEBUG" = yes ]
    then
      loglevel=0
    else
      loglevel=2
    fi
    if [ "$hostapd_driver" ]; then
	cat <<EOF > /etc/hostapd.$device
interface=$device
driver=$hostapd_driver
logger_syslog=-1
logger_syslog_level=$loglevel
logger_stdout=-1
logger_stdout_level=$loglevel
dump_file=/tmp/hostapd.$device.dump
ctrl_interface=/var/run/hostapd.$device
ctrl_interface_group=0
ssid=$WLAN_ESSID
auth_algs=3
own_ip_addr=127.0.0.1
eapol_version=1
EOF
	if [ -n "$bridge_devname" -a -z "$WLAN_BRIDGE" ]
	then
	  echo bridge=$bridge_devname >> /etc/hostapd.$device
	fi
	if [ -n "$WLAN_BRIDGE" ]
	then
	  echo bridge=$WLAN_BRIDGE
	fi
	generic_hostapd_cryptconfig >> /etc/hostapd.$device
	idx=''
	generic_hostapd_aclconfig >> /etc/hostapd.$device
	generic_hostapd_essid >> /etc/hostapd.$device
	if [ -n "$WLAN_CHANNEL" ]
	then
	    echo channel=$WLAN_CHANNEL >> /etc/hostapd.$device
	    if [ -n "$WLAN_STANDARD" ]
	    then
		case $WLAN_STANDARD in
		  a|A) echo hw_mode=a >> /etc/hostapd.$device ;;
		  b|B) echo hw_mode=b >> /etc/hostapd.$device ;;
		  *) echo hw_mode=g >> /etc/hostapd.$device ;;
		esac
	    else
	        if [ $WLAN_CHANNEL -gt 0 -a $WLAN_CHANNEL -lt 15 ]
		then
		   WLAN_STANDARD='g'
		else
		   WLAN_STANDARD='a'
		fi
		echo hw_mode=`echo $WLAN_STANDARD | sed 't/ABG/abg/'` >> /etc/hostapd.$device
	    fi
	fi
	if [ "$WLAN_RATE" != "auto" -a -n "$WLAN_RATE" ]
	then
	  case $WLAN_STANDARD in
	    b|B) ratelist="10 20 55 110" ;;
	    g|G) ratelist="10 20 55 60 90 110 120 180 240 360 480 540" ;;
	    a|A) ratelist="60 90 120 180 240 360 480 540" ;;
	    *) ratelist="" ;;
	  esac
	  maxrate="${WLAN_RATE}0"
	  if [ "$maxrate" == "5.50" ]
	  then
	    maxrate=55
	  fi
	  if [ -n "$ratelist" ]
	  then
	    rates=''
	    for rate in $ratelist
	    do
	      if [ "$rate" -le "$maxrate" ]
	      then
		rates="$rates ${rate}"
	      fi
	      if [ "$rate" -ge "$maxrate" ]
	      then
		break
	      fi
	    done
	    if [ -n "$rates" ]
	    then
	      rates=`echo $rates | sed 's/^ //'`
	      echo supported_rates=$rates >> /etc/hostapd.$device
	    fi
	  fi
	fi
	if [ "$cando_n" = "yes" -a -n "$WLAN_N" ]
	then
	  echo ieee80211n=1 >> /etc/hostapd.$device
	  # Enable WMM only on WPA2 as there are security-holes in WPA1 with WMM
	  #if [ "$WLAN_WPA_TYPE" != "1" -a "$WLAN_WPA_TYPE" != "3" ]
	  #then
	  #    echo wmm_enabled=1 >> /etc/hostapd.$device
	  #fi
	  # Actvate 40 MHz Channels when Uppercase 'N' is selected.
	  HTCAP=''
	  if [ "$cando_n40" = "yes" -a "$WLAN_N" = "N" ]
	  then
	    if [ $WLAN_CHANNEL -ge 1 -a $WLAN_CHANNEL -le 9 ]
	    then
	      HTCAP='HT40+'
	    fi
	    if [ $WLAN_CHANNEL -ge 5 -a $WLAN_CHANNEL -le 13 ]
	    then
	      HTCAP='HT40-'
	    fi
	    if [ $WLAN_CHANNEL -ge 36 -a $WLAN_CHANNEL -le 52 ]
	    then
	      HTCAP='HT40+'
	    fi
	    if [ $WLAN_CHANNEL -ge 48 -a $WLAN_CHANNEL -le 60 ]
	    then
	      HTCAP='HT40-'
	    fi
	  fi
	  if [ "$HTCAP" ]
	  then
	    echo ht_capab=[$HTCAP] >> /etc/hostapd.$device
	    echo wmm_enabled=1 >> /etc/hostapd.$device
	  fi
	else
	    echo ieee80211n=0 >> /etc/hostapd.$device
	fi
	
	# VAP?
	# disable VAP at this position as this collides with the other implementation
	# and hostapd doesn't handle bridging correct with vap's
	# I'll keep the code for the case hostapd will be fixed in future as this one is the
	# clean way.
	#num=`sed -n '$=' <$WLAN_IDX`
	#if [ 0$num -gt 1 -a "$cando_vlan" = "yes" ]
	#then
	#  idx=1
	#  cat $WLAN_IDX |\
	#  while read filename
	#  do
	#    if [ $idx -ne 1 -a $idx -le 4 ] # Skip first line as we alread did this one
	#    then
	#      case $idx in
	#              2) mf='06' ;;
	#              3) mf='0A' ;;
	#              4) mf='0E' ;;
	#              *) mf='00' ;;
	#      esac
	#      echo bss=${device}_${idx}
	#      echo bssid=`echo $MAC_ADD | sed "s/..\(.*\)/$mf\1/"`
	#      . $filename
	#      echo ssid=$WLAN_ESSID
	#      if [ -n "$WLAN_BRIDGE" ]
	#      then
	#        echo bridge=$WLAN_BRIDGE
	#      fi
	#      generic_hostapd_cryptconfig
	#      generic_hostapd_aclconfig
	#      generic_hostapd_essid
	#    fi
	#    idx=`expr $idx + 1`
	#  done >>/etc/hostapd.$device
	#fi
	
	pidf=/var/run/hostapd_$device.pid
	if [ -f $pidf -a "$WLAN_RELOAD" != yes ]; then
	    kill $( cat $pidf ) || log_error "hostapd: cannot kill/restart hostapd for $device"
	    # hostapd startet nicht, wenn das device vorher UP ist.
	    ip link set dev $device down
	    sleep 2
	fi
	
	# debugging is enabled in config file and goes to stderr;
	# if hostapd goes into background, debuggin to stdout is
	# automatically disabled
	if [ "$WLAN_RELOAD" = yes ]
	then
	  if [ ! -f $pidf ]
	  then
	    pid=`ps | grep $pidf | grep -v grep | sed 's/^ *\([0-9]\+\) *.*/\1/'`
	    if [ -n "$pid" ]
	    then
	      echo $pid >$pidf
	      kill -HUP $pid
	    fi
	    unset $pid
	  else
	    kill -HUP `cat $pidf`
	  fi
	else
	  if [ "$WLAN_WPA_DEBUG" = yes ]
	  then
	    debug='-dd'
	  else
	    debug=''
	  fi
	  /usr/sbin/hostapd $debug -B -P $pidf /etc/hostapd.$device
	  if [ $? -ne 0 ]
	  then
	    ip link set dev $device down
	    exit 42
	  fi
	fi
	unset pidf
    fi
fi

# Available drivers:
# hostap = Host AP driver (Intersil Prism2/2.5/3) [default]
#       (this can also be used with Linuxant DriverLoader)
# prism54 = Prism54.org driver (Intersil Prism GT/Duette/Indigo)
#       not yet fully implemented
# madwifi = MADWIFI 802.11 support (Atheros, etc.)
# nl80211 = MAC80211 (new Linux WLAN Interface)
# wired = wpa_supplicant wired Ethernet driver
# Configured drivers:
# hostap, prism54, madwifi


Mehr Informationen über die Mailingliste Fli4l_dev