hostapd: fix frequency setting for IBSS/RSN
[openwrt/svn-archive/archive.git] / package / network / services / hostapd / files / netifd.sh
index 83803575b4c28a5537fe46eb37dd832b6cdf662a..b2c437d8243f9c8404e6885380687ed328ba2a47 100644 (file)
@@ -18,12 +18,12 @@ hostapd_append_wep_key() {
                                zidx=$(($idx - 1))
                                json_get_var ckey "key${idx}"
                                [ -n "$ckey" ] && \
-                                       append network_data "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
+                                       append $var "wep_key${zidx}=$(prepare_key_wep "$ckey")" "$N$T"
                        done
                        wep_keyidx=$((key - 1))
                ;;
                *)
-                       append network_data "wep_key0=$(prepare_key_wep "$key")" "$N$T"
+                       append $var "wep_key0=$(prepare_key_wep "$key")" "$N$T"
                ;;
        esac
 }
@@ -86,7 +86,7 @@ hostapd_common_add_bss_config() {
        config_add_boolean wds wmm hidden
 
        config_add_int maxassoc max_inactivity
-       config_add_boolean disassoc_low_ack ap_isolate short_preamble
+       config_add_boolean disassoc_low_ack isolate short_preamble
 
        config_add_int \
                wep_rekey eap_reauth_period \
@@ -137,12 +137,12 @@ hostapd_set_bss_options() {
 
        json_get_vars \
                wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey \
-               maxassoc max_inactivity disassoc_low_ack ap_isolate auth_cache \
+               maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
                wps_pushbutton wps_label ext_registrar \
                wps_device_type wps_device_name wps_manufacturer wps_pin \
                macfilter ssid wmm hidden short_preamble
 
-       set_default ap_isolate 0
+       set_default isolate 0
        set_default maxassoc 0
        set_default max_inactivity 0
        set_default short_preamble 1
@@ -151,8 +151,8 @@ hostapd_set_bss_options() {
        set_default wmm 1
 
        append bss_conf "ctrl_interface=/var/run/hostapd"
-       if [ "$ap_isolate" -gt 0 ]; then
-               append bss_conf "ap_isolate=$ap_isolate" "$N"
+       if [ "$isolate" -gt 0 ]; then
+               append bss_conf "ap_isolate=$isolate" "$N"
        fi
        if [ "$maxassoc" -gt 0 ]; then
                append bss_conf "max_num_sta=$maxassoc" "$N"
@@ -233,8 +233,9 @@ hostapd_set_bss_options() {
                ;;
                wep)
                        local wep_keyidx=0
-                       hostapd_append_wep_key network_data
-                       append bss_conf "wep_default_key=$wep_key" "$N"
+                       json_get_vars key
+                       hostapd_append_wep_key bss_conf
+                       append bss_conf "wep_default_key=$wep_keyidx" "$N"
                        [ -n "$wep_rekey" ] && append bss_conf "wep_rekey_period=$wep_rekey" "$N"
                ;;
        esac
@@ -446,12 +447,14 @@ wpa_supplicant_add_network() {
 
        local wpa_key_mgmt="WPA-PSK"
        local scan_ssid="1"
+       local freq
 
        [[ "$_w_mode" = "adhoc" ]] && {
                append network_data "mode=1" "$N$T"
-               [ -n "$fixed_frequency" ] || {
+               [ -n "$channel" ] && {
+                       freq="$(get_freq "$phy" "$channel")"
                        append network_data "fixed_freq=1" "$N$T"
-                       append network_data "frequency=$fixed_frequency" "$N$T"
+                       append network_data "frequency=$freq" "$N$T"
                }
 
                scan_ssid=0