From: Michael Tremer Date: Mon, 18 Mar 2019 19:10:56 +0000 (+0100) Subject: hostapd: Disable DFS automatically when not supported by hardware X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=commitdiff_plain;h=dc6d97fbf2064365f5b84496a77227b4e3ca03d6 hostapd: Disable DFS automatically when not supported by hardware Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.hostapd b/src/functions/functions.hostapd index e19f9b3f..b8559947 100644 --- a/src/functions/functions.hostapd +++ b/src/functions/functions.hostapd @@ -181,7 +181,7 @@ hostapd_config_write() { print "ieee80211d=1" # Enable Radar Detection - if enabled dfs; then + if enabled dfs && wireless_supports_dfs "${device}"; then print "ieee80211h=1" else print "ieee80211h=0" diff --git a/src/functions/functions.phy b/src/functions/functions.phy index 96287a52..064ca7b6 100644 --- a/src/functions/functions.phy +++ b/src/functions/functions.phy @@ -188,3 +188,25 @@ phy_supports_ht_capability() { list_match "${capability}" $(__phy_list_ht_capabilities "${phy}") } + +# Returns TRUE if the PHY supports DFS +phy_supports_dfs() { + local phy="${1}" + assert isset phy + + local driver="$(phy_get_driver "${phy}")" + if ! isset driver; then + return ${EXIT_ERROR} + fi + + # This is basically a whilelist of drivers which support this + # There is no better detection + case "${driver}" in + ath10k_*|ath9k|ath5k) + return ${EXIT_TRUE} + ;; + *) + return ${EXIT_FALSE} + ;; + esac +} diff --git a/src/functions/functions.wireless b/src/functions/functions.wireless index 3608e119..221866ec 100644 --- a/src/functions/functions.wireless +++ b/src/functions/functions.wireless @@ -515,3 +515,16 @@ wireless_get_vht_caps() { network-phy-list-vht-caps "${phy}" } + +wireless_supports_dfs() { + local device="${1}" + assert isset device + + local phy="$(device_get_phy "${device}")" + if ! isset phy; then + log ERROR "Could not determine PHY for ${device}" + return ${EXIT_ERROR} + fi + + phy_supports_dfs "${phy}" +} diff --git a/src/network b/src/network index b8f734ea..de2e663e 100644 --- a/src/network +++ b/src/network @@ -277,6 +277,13 @@ cli_device_status_phy() { cli_space fi + cli_headline 2 "Features" + + cli_print_fmt1 2 "DFS" \ + "$(phy_supports_dfs "${phy}" && print "Supported" || print "Not Supported")" + + cli_space + return ${EXIT_OK} }