sync 8.09 with changes from trunk
[openwrt/svn-archive/archive.git] / package / madwifi / files / lib / wifi / madwifi.sh
index cc340977b2692fe2ad9541e2e3e9b5d79a33adad..e4e99822bd0e840a09967a43e2051b1fdfdcf019 100755 (executable)
@@ -78,13 +78,17 @@ enable_atheros() {
 
        local first=1
        for vif in $vifs; do
+               local start_hostapd
                nosbeacon=
                config_get ifname "$vif" ifname
                config_get enc "$vif" encryption
                config_get eap_type "$vif" eap_type
                config_get mode "$vif" mode
                
-               [ "$mode" = sta ] && config_get nosbeacon "$device" nosbeacon
+               case "$mode" in
+                       sta) config_get nosbeacon "$device" nosbeacon;;
+                       adhoc) config_get nosbeacon "$vif" sw_merge;;
+               esac
                
                config_get ifname "$vif" ifname
                ifname=$(wlanconfig "$ifname" create wlandev "$device" wlanmode "$mode" ${nosbeacon:+nosbeacon})
@@ -137,7 +141,6 @@ enable_atheros() {
                        [ -n "$wdssep" ] && iwpriv "$ifname" wdssep "$wdssep"
                }
 
-               wpa=
                case "$enc" in
                        WEP|wep)
                                for idx in 1 2 3 4; do
@@ -151,7 +154,8 @@ enable_atheros() {
                                        *) iwconfig "$ifname" enc "$key";;
                                esac
                        ;;
-                       PSK|psk|PSK2|psk2)
+                       psk*|wpa*)
+                               start_hostapd=1
                                config_get key "$vif" key
                        ;;
                esac
@@ -181,6 +185,9 @@ enable_atheros() {
                config_get distance "$device" distance
                [ -n "$distance" ] && athctrl -i "$device" -d "$distance" >&-
 
+               config_get_bool softled "$device" softled 1
+               [ -n "$softled" ] && sysctl -w dev."$device".softled="$softled" >&-
+
                config_get txpwr "$vif" txpower
                [ -n "$txpwr" ] && iwconfig "$ifname" txpower "${txpwr%%.*}"
 
@@ -254,6 +261,7 @@ enable_atheros() {
                        config_set "$vif" bridge "$bridge"
                        start_net "$ifname" "$net_cfg"
                }
+               [ -n "$ssid" ] && iwconfig "$ifname" essid on
                iwconfig "$ifname" essid "$ssid"
                set_wifi_up "$vif" "$ifname"
                case "$mode" in
@@ -261,7 +269,7 @@ enable_atheros() {
                                config_get_bool isolate "$vif" isolate 0
                                iwpriv "$ifname" ap_bridge "$((isolate^1))"
 
-                               if eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
+                               if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
                                        hostapd_setup_vif "$vif" madwifi || {
                                                echo "enable_atheros($device): Failed to set up hostapd for interface $ifname" >&2
                                                # make sure this wifi interface won't accidentally stay open without encryption