fix wep encryption setting for madwifi
[openwrt/openwrt.git] / package / madwifi / files / lib / wifi / madwifi.sh
index 8083612af929d2a27a042921587fbe0bf9ba1c0e..1cd727ade711e8c4b301653a3a980d6c4666f05e 100755 (executable)
@@ -125,7 +125,11 @@ enable_atheros() {
                                        iwconfig "$ifname" enc "[$idx]" "${key:-off}"
                                done
                                config_get key "$vif" key
-                               iwconfig "$ifname" enc "${key:-1}"
+                               key="${key:-1}"
+                               case "$key" in
+                                       [1234]) iwconfig "$ifname" enc "[$key]";;
+                                       *) iwconfig "$ifname" enc "$key";;
+                               esac
                        ;;
                        PSK|psk|PSK2|psk2)
                                config_get key "$vif" key
@@ -140,6 +144,12 @@ enable_atheros() {
                        *)
                                config_get ssid "$vif" ssid
                        ;;
+                       adhoc)
+                               config_get addr "$vif" bssid
+                               [ -z "$addr" ] || { 
+                                       iwconfig "$ifname" ap "$addr"
+                               }
+                       ;;
                esac
 
                [ "$mode" = "sta" ] && {
@@ -214,10 +224,6 @@ EOF
                                                #add wpa_supplicant calls here
                                        ;;
                                esac
-                               net_cfg="$(find_net_config "$vif")"
-                               [ -z "$net_cfg" ] || {
-                                       bridge="$(bridge_interface "$net_cfg")"
-                               }
                                wpa_supplicant ${bridge:+ -b $bridge} -Bw -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf
                        ;;
                esac
@@ -229,7 +235,7 @@ EOF
 detect_atheros() {
        cd /proc/sys/dev
        [ -d ath ] || return
-       for dev in wifi*; do
+       for dev in $(ls -d wifi* 2>&-); do
                config_get type "$dev" type
                [ "$type" = atheros ] && return
                cat <<EOF
@@ -241,7 +247,7 @@ config wifi-device  $dev
 #       option rxantenna 0
 #       option distance  2000
 # disable radio to prevent an open ap after reflashing:
-       option radio    0
+       option disabled 1
 
 
 config wifi-iface