]> git.ipfire.org Git - people/ms/network.git/commitdiff
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 e19f9b3f16d34103d00c9b4dcc75227439313044..b8559947d81ef56dd751467b9bef1df4fd97cec2 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 96287a524de6141305728093184527af46502e29..064ca7b636232789541816d95b8ed4e380b7afc3 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 3608e1195c2c496bccdfdb9e83b918840a95b297..221866ec63342056034a178c1e5df24262baa130 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 b8f734ea101a62374da742179cd4b88673b5e648..de2e663e11090756c67bd74eb047ee1b98186e68 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}
 }