From: Michael Tremer Date: Mon, 18 Mar 2019 19:50:44 +0000 (+0100) Subject: wireless-ap: Add CLI to set channel bandwidth X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=commitdiff_plain;h=54094fc7ae1bc17e8d8361f7758d9404f1eeff02 wireless-ap: Add CLI to set channel bandwidth Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.wireless b/src/functions/functions.wireless index 221866ec..0437d27b 100644 --- a/src/functions/functions.wireless +++ b/src/functions/functions.wireless @@ -29,6 +29,14 @@ 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" +) + cli_wireless() { local action=${1} shift 1 @@ -309,6 +317,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 diff --git a/src/hooks/ports/wireless-ap b/src/hooks/ports/wireless-ap index 49c0a843..8b626bf3 100644 --- a/src/hooks/ports/wireless-ap +++ b/src/hooks/ports/wireless-ap @@ -29,6 +29,7 @@ HOOK_SETTINGS="${HOOK_SETTINGS} ENCRYPTION KEY" ADDRESS=$(mac_generate) BROADCAST_SSID=on CHANNEL=0 +CHANNEL_BANDWIDTH= ENCRYPTION="" KEY="" SSID= @@ -67,6 +68,9 @@ hook_parse_cmdline() { --channel=*) CHANNEL=$(cli_get_val "${1}") ;; + --channel-bandwidth=*) + CHANNEL_BANDWIDTH="$(cli_get_val "${1}")" + ;; --dfs=*) DFS="$(cli_get_val "${1}")" @@ -121,6 +125,12 @@ hook_parse_cmdline() { return ${EXIT_ERROR} fi + # Channel bandwidth must match the mode + if isset CHANNEL_BANDWIDTH && ! wireless_channel_bandwidth_is_valid "${MODE}" "${CHANNEL_BANDWIDTH}"; then + error "Channel Bandwidth '${CHANNEL_BANDWIDTH}' is not supported" + return ${EXIT_ERROR} + fi + # Save address of phy do identify it again PHY=$(phy_get ${PHY}) PHY=$(phy_get_address ${PHY})