]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/functions/functions.wireless
wireless-ap: Allow setting the wireless environment (indoor/outdoor)
[people/ms/network.git] / src / functions / functions.wireless
index 3608e1195c2c496bccdfdb9e83b918840a95b297..12204c07879b6794c99f94e9d13b0442674cb4ce 100644 (file)
@@ -29,6 +29,17 @@ WIRELESS_DEFAULT_ENCRYPTION_MODE="NONE"
 WIRELESS_VALID_ENCRYPTION_MODES="WPA2-PSK-SHA256 WPA2-PSK \
        WPA-PSK-SHA256 WPA-PSK NONE"
 
+declare -A WIRELESS_CHANNEL_BANDWIDTHS=(
+       ["802.11ac"]="20 40 80 160 80+80"
+       ["802.11a/n"]="20 40"
+       ["802.11a"]="20 40"
+       ["802.11g/n"]="20 40"
+       ["802.11g"]="20 40"
+)
+
+WIRELESS_ENVIRONMENTS=( "indoor+outdoor" "indoor" "outdoor" )
+WIRELESS_DEFAULT_ENVIRONMENT="${WIRELESS_ENVIRONMENTS[0]}"
+
 cli_wireless() {
        local action=${1}
        shift 1
@@ -309,6 +320,18 @@ wireless_channel_is_valid() {
        return ${EXIT_FALSE}
 }
 
+wireless_channel_bandwidth_is_valid() {
+       local mode="${1}"
+       assert isset mode
+
+       local bandwidth="${2}"
+       assert isset bandwidth
+
+       local bandwidths="${WIRELESS_CHANNEL_BANDWIDTHS["${mode}"]}"
+
+       list_match "${bandwidth}" ${bandwidths}
+}
+
 wireless_channel_is_ht40_plus() {
        local channel="${1}"
        assert isinteger channel
@@ -515,3 +538,35 @@ wireless_get_vht_caps() {
 
        network-phy-list-vht-caps "${phy}"
 }
+
+wireless_supports_acs() {
+       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_acs "${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}"
+}
+
+wireless_environment_is_valid() {
+       local environment="${1}"
+
+       list_match "${environment}" "${WIRELESS_ENVIRONMENTS[@]}"
+}