hostapd: add support for acs_chan_bias option
[openwrt/staging/wigyori.git] / package / network / services / hostapd / files / hostapd.sh
index 988ebc7757fedfba3eba464a973824622c3af8c3..2c015f9c4b28705ef68e2c825dac46b616859544 100644 (file)
@@ -64,6 +64,9 @@ hostapd_common_add_device_config() {
        config_add_string country
        config_add_boolean country_ie doth
        config_add_string require_mode
+       config_add_boolean legacy_rates
+
+       config_add_string acs_chan_bias
 
        hostapd_add_log_config
 }
@@ -75,12 +78,15 @@ hostapd_prepare_device_config() {
        local base="${config%%.conf}"
        local base_cfg=
 
-       json_get_vars country country_ie beacon_int doth require_mode
+       json_get_vars country country_ie beacon_int:100 doth require_mode legacy_rates acs_chan_bias
 
        hostapd_set_log_options base_cfg
 
        set_default country_ie 1
        set_default doth 1
+       set_default legacy_rates 1
+
+       [ "$hwmode" = "b" ] && legacy_rates=1
 
        [ -n "$country" ] && {
                append base_cfg "country_code=$country" "$N"
@@ -88,28 +94,38 @@ hostapd_prepare_device_config() {
                [ "$country_ie" -gt 0 ] && append base_cfg "ieee80211d=1" "$N"
                [ "$hwmode" = "a" -a "$doth" -gt 0 ] && append base_cfg "ieee80211h=1" "$N"
        }
-       [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
+
+       [ -n "$acs_chan_bias" ] && append base_cfg "acs_chan_bias=$acs_chan_bias" "$N"
 
        local brlist= br
        json_get_values basic_rate_list basic_rate
-       for br in $basic_rate_list; do
-               hostapd_add_rate brlist "$br"
-       done
+       local rlist= r
+       json_get_values rate_list supported_rates
+
+       [ -n "$hwmode" ] && append base_cfg "hw_mode=$hwmode" "$N"
+       [ "$legacy_rates" -eq 0 ] && set_default require_mode g
+
+       [ "$hwmode" = "g" ] && {
+               [ "$legacy_rates" -eq 0 ] && set_default rate_list "6000 9000 12000 18000 24000 36000 48000 54000"
+               [ -n "$require_mode" ] && set_default basic_rate_list "6000 12000 24000"
+       }
+
        case "$require_mode" in
-               g) brlist="60 120 240" ;;
                n) append base_cfg "require_ht=1" "$N";;
                ac) append base_cfg "require_vht=1" "$N";;
        esac
 
-       local rlist= r
-       json_get_values rate_list supported_rates
        for r in $rate_list; do
                hostapd_add_rate rlist "$r"
        done
 
+       for br in $basic_rate_list; do
+               hostapd_add_rate brlist "$br"
+       done
+
        [ -n "$rlist" ] && append base_cfg "supported_rates=$rlist" "$N"
        [ -n "$brlist" ] && append base_cfg "basic_rates=$brlist" "$N"
-       [ -n "$beacon_int" ] && append base_cfg "beacon_int=$beacon_int" "$N"
+       append base_cfg "beacon_int=$beacon_int" "$N"
 
        cat > "$config" <<EOF
 driver=$driver
@@ -696,9 +712,7 @@ wpa_supplicant_add_network() {
                        ;;
                esac
        }
-       local beacon_int brates mrate
        [ -n "$bssid" ] && append network_data "bssid=$bssid" "$N$T"
-       [ -n "$beacon_int" ] && append network_data "beacon_int=$beacon_int" "$N$T"
 
        local bssid_blacklist bssid_whitelist
        json_get_values bssid_blacklist bssid_blacklist