hostapd: Disable DFS automatically when not supported by hardware
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 Mar 2019 19:10:56 +0000 (20:10 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 Mar 2019 19:14:56 +0000 (20:14 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.hostapd
src/functions/functions.phy
src/functions/functions.wireless
src/network

index e19f9b3..b855994 100644 (file)
@@ -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"
index 96287a5..064ca7b 100644 (file)
@@ -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
+}
index 3608e11..221866e 100644 (file)
@@ -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}"
+}
index b8f734e..de2e663 100644 (file)
@@ -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}
 }