wireless-ap: Allow to disable DFS in configuration
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 Mar 2019 18:58:25 +0000 (19:58 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 Mar 2019 18:58:25 +0000 (19:58 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.hostapd
src/helpers/hostapd-config-helper
src/hooks/ports/wireless-ap

index 3f64e79..e19f9b3 100644 (file)
@@ -36,6 +36,7 @@ hostapd_config_write() {
        local broadcast_ssid
        local channel
        local country_code="$(wireless_get_reg_domain)"
+       local dfs="on"
        local encryption
        local key
        local mode
@@ -50,6 +51,9 @@ hostapd_config_write() {
                        --channel=*)
                                channel=$(cli_get_val "${1}")
                                ;;
+                       --dfs=*)
+                               dfs="$(cli_get_val "${1}")"
+                               ;;
                        --encryption=*)
                                encryption=$(cli_get_val "${1}")
                                ;;
@@ -177,7 +181,11 @@ hostapd_config_write() {
                print "ieee80211d=1"
 
                # Enable Radar Detection
-               print "ieee80211h=1"
+               if enabled dfs; then
+                       print "ieee80211h=1"
+               else
+                       print "ieee80211h=0"
+               fi
 
                print # empty line
 
index cb12af0..30d3456 100644 (file)
@@ -40,6 +40,7 @@ case "${action}" in
                hostapd_config_write ${port} ${config_file} \
                        --broadcast-ssid="${BROADCAST_SSID}" \
                        --channel="${CHANNEL}" \
+                       --dfs="${DFS}" \
                        --encryption="${ENCRYPTION}" \
                        --key="${KEY}" \
                        --mode="${MODE}" \
index 52ca238..49c0a84 100644 (file)
@@ -33,12 +33,16 @@ ENCRYPTION=""
 KEY=""
 SSID=
 
+# Perform radar detection by default when possible
+DFS="on"
+
 hook_check_settings() {
        assert isset ADDRESS
        assert ismac ADDRESS
        assert isset BROADCAST_SSID
        assert isbool BROADCAST_SSID
        assert isset CHANNEL
+       assert isbool DFS
        assert isset MODE
        assert isoneof MODE ${HOSTAPD_SUPPORTED_MODES}
        assert isset PHY
@@ -63,6 +67,18 @@ hook_parse_cmdline() {
                        --channel=*)
                                CHANNEL=$(cli_get_val "${1}")
                                ;;
+                       --dfs=*)
+                               DFS="$(cli_get_val "${1}")"
+
+                               if enabled DFS; then
+                                       DFS="on"
+                               elif disabled DFS; then
+                                       DFS="off"
+                               else
+                                       error "Invalid value for DFS: ${DFS}"
+                                       return ${EXIT_ERROR}
+                               fi
+                               ;;
                        --encryption=*)
                                ENCRYPTION=$(cli_get_val "${1}")
                                ;;