madwifi: remove wds type of wifi-iface without essid, imho it never worked properly...
[openwrt/svn-archive/archive.git] / package / madwifi / files / lib / wifi / madwifi.sh
index 5a25eddae20f2f4202e603910f4daedb99e0f928..010391e35a7b82db3cf809209f66839b26be90fb 100755 (executable)
@@ -14,18 +14,17 @@ scan_atheros() {
                
                config_get mode "$vif" mode
                case "$mode" in
-                       adhoc|ahdemo|sta|ap)
+                       adhoc|ahdemo|sta|ap|monitor)
                                append $mode "$vif"
                        ;;
                        wds)
-                               config_get addr "$vif" bssid
                                config_get ssid "$vif" ssid
-                               [ -z "$addr" -a -n "$ssid" ] && {
-                                       config_set "$vif" wds 1
-                                       config_set "$vif" mode sta
-                                       mode="sta"
-                                       addr="$ssid"
-                               }
+                               [ -z "$ssid" ] && continue
+
+                               config_set "$vif" wds 1
+                               config_set "$vif" mode sta
+                               mode="sta"
+                               addr="$ssid"
                                ${addr:+append $mode "$vif"}
                        ;;
                        *) echo "$device($vif): Invalid mode, ignored."; continue;;
@@ -43,7 +42,7 @@ scan_atheros() {
                *) echo "$device: Invalid mode combination in config"; return 1;;
        esac
 
-       config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }"
+       config_set "$device" vifs "${ap:+$ap }${adhoc:+$adhoc }${ahdemo:+$ahdemo }${sta:+$sta }${wds:+$wds }${monitor:+$monitor}"
 }
 
 
@@ -97,6 +96,8 @@ enable_atheros() {
                [ "$first" = 1 ] && {
                        # only need to change freq band and channel on the first vif
                        config_get agmode "$device" agmode
+                       [ -z "$agmode" ] && config_get agmode "$device" mode
+
                        pureg=0
                        case "$agmode" in
                                *b) agmode=11b;;
@@ -105,9 +106,6 @@ enable_atheros() {
                                *a) agmode=11a;;
                                *) agmode=auto;;
                        esac
-                       iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null 
-                       ifconfig "$ifname" up
-                       sleep 1
                        iwpriv "$ifname" mode "$agmode"
                        iwpriv "$ifname" pureg "$pureg"
                        iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null 
@@ -121,6 +119,9 @@ enable_atheros() {
                        iwpriv "$ifname" ff "$ff"
                fi
 
+               config_get wdssep "$vif" wdssep
+               [ -n "$wdssep" ] && iwpriv "$ifname" wdssep "$wdssep"
+
                config_get wds "$vif" wds
                case "$wds" in
                        1|on|enabled) wds=1;;
@@ -148,10 +149,6 @@ enable_atheros() {
                esac
 
                case "$mode" in
-                       wds)
-                               config_get addr "$vif" bssid
-                               iwpriv "$ifname" wds_add "$addr"
-                       ;;
                        adhoc|ahdemo)
                                config_get addr "$vif" bssid
                                [ -z "$addr" ] || { 
@@ -191,12 +188,15 @@ enable_atheros() {
                config_get rts "$vif" rts
                [ -n "$rts" ] && iwconfig "$ifname" rts "${rts%%.*}"
 
-               config_get_bool doth "$vif" 80211h
-               [ -n "$doth" ] && iwpriv "$ifname" doth "$doth"
-
                config_get_bool comp "$vif" compression
                [ -n "$comp" ] && iwpriv "$ifname" compression "$comp"
 
+               config_get_bool minrate "$vif" minrate
+               [ -n "$minrate" ] && iwpriv "$ifname" minrate "$minrate"
+
+               config_get_bool maxrate "$vif" maxrate
+               [ -n "$maxrate" ] && iwpriv "$ifname" maxrate "$maxrate"
+
                config_get_bool burst "$vif" bursting
                [ -n "$burst" ] && iwpriv "$ifname" burst "$burst"
 
@@ -212,6 +212,9 @@ enable_atheros() {
                config_get_bool turbo "$vif" turbo
                [ -n "$turbo" ] && iwpriv "$ifname" turbo "$turbo"
 
+               config_get_bool doth "$vif" doth 0
+               [ -n "$doth" ] && iwpriv "$ifname" doth "$doth"
+
                config_get maclist "$vif" maclist
                [ -n "$maclist" ] && {
                        # flush MAC list
@@ -236,8 +239,6 @@ enable_atheros() {
                esac
 
                ifconfig "$ifname" up
-               iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null 
-
                local net_cfg bridge
                net_cfg="$(find_net_config "$vif")"
                [ -z "$net_cfg" ] || {
@@ -263,26 +264,34 @@ enable_atheros() {
                                fi
                        ;;
                        wds|sta)
-                               case "$enc" in 
+                               config_get_bool usepassphrase "$vif" passphrase 1
+                               case "$enc" in
                                        PSK|psk|PSK2|psk2)
                                                case "$enc" in
                                                        PSK|psk)
                                                                proto='proto=WPA'
-                                                               passphrase="${key}"
+                                                               if [ "$usepassphrase" = "1" ]; then
+                                                                       passphrase="psk=\"${key}\""
+                                                               else
+                                                                       passphrase="psk=${key}"
+                                                               fi
                                                                ;;
                                                        PSK2|psk2)
                                                                proto='proto=RSN'
-                                                               passphrase=`wpa_passphrase ${ssid} "${key}" | grep psk | grep -v \#| cut -d= -f2`
+                                                                if [ "$usepassphrase" = "1" ]; then
+                                                                        passphrase="psk=\"${key}\""
+                                                                else
+                                                                        passphrase="psk=${key}"
+                                                                fi
                                                                ;;
                                                esac
-                                               
                                                cat > /var/run/wpa_supplicant-$ifname.conf <<EOF
 network={
        scan_ssid=1
        ssid="$ssid"
        key_mgmt=WPA-PSK
        $proto
-       psk=$passphrase
+       $passphrase
 }
 EOF
                                        ;;
@@ -290,7 +299,7 @@ EOF
                                                #add wpa_supplicant calls here
                                        ;;
                                esac
-                               [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -B -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
+                               [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -B -D madwifi -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
                        ;;
                esac
                first=0