From f9e980d91e081613e5dcc7899c28fbdfc7a4c172 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 18 Mar 2019 21:24:02 +0100 Subject: [PATCH] hostapd: Apply channel bandwidth to configuration Signed-off-by: Michael Tremer --- src/functions/functions.hostapd | 26 ++++++++++++++++++++++++++ src/helpers/hostapd-config-helper | 1 + src/hooks/ports/wireless-ap | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/functions/functions.hostapd b/src/functions/functions.hostapd index b8559947..57f8c1e4 100644 --- a/src/functions/functions.hostapd +++ b/src/functions/functions.hostapd @@ -35,6 +35,7 @@ hostapd_config_write() { local broadcast_ssid local channel + local channel_bandwidth local country_code="$(wireless_get_reg_domain)" local dfs="on" local encryption @@ -51,6 +52,9 @@ hostapd_config_write() { --channel=*) channel=$(cli_get_val "${1}") ;; + --channel-bandwidth=*) + channel_bandwidth="$(cli_get_val "${1}")" + ;; --dfs=*) dfs="$(cli_get_val "${1}")" ;; @@ -107,10 +111,17 @@ hostapd_config_write() { assert isset key fi + # Check channel bandwidth for validity + if isset channel_bandwidth && ! wireless_channel_bandwidth_is_valid "${mode}" "${channel_bandwidth}"; then + error "Invalid channel bandwidth for ${mode}: ${channel_bandwidth}" + return ${EXIT_ERROR} + fi + # 802.11ac/n flags local ieee80211ac local ieee80211n local vht_caps + local vht_oper_chwidth="0" local ht_caps local hw_mode @@ -149,6 +160,18 @@ hostapd_config_write() { # Fetch HT caps ht_caps="$(wireless_get_ht_caps "${device}")" + + case "${channel_bandwidth}" in + 80) + vht_oper_chwidth="1" + ;; + 160) + vht_oper_chwidth="2" + ;; + 80+80) + vht_oper_chwidth="3" + ;; + esac ;; esac @@ -221,6 +244,9 @@ hostapd_config_write() { # Enable HT caps print "ht_capab=${ht_caps}" + # Wider Channels + print "vht_oper_chwidth=${vht_oper_chwidth}" + print ) >> ${file} diff --git a/src/helpers/hostapd-config-helper b/src/helpers/hostapd-config-helper index 30d3456f..8af3097f 100644 --- a/src/helpers/hostapd-config-helper +++ b/src/helpers/hostapd-config-helper @@ -40,6 +40,7 @@ case "${action}" in hostapd_config_write ${port} ${config_file} \ --broadcast-ssid="${BROADCAST_SSID}" \ --channel="${CHANNEL}" \ + --channel-bandwidth="${CHANNEL_BANDWIDTH}" \ --dfs="${DFS}" \ --encryption="${ENCRYPTION}" \ --key="${KEY}" \ diff --git a/src/hooks/ports/wireless-ap b/src/hooks/ports/wireless-ap index 5e000146..983f0f97 100644 --- a/src/hooks/ports/wireless-ap +++ b/src/hooks/ports/wireless-ap @@ -127,7 +127,7 @@ hook_parse_cmdline() { # 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" + error "Channel Bandwidth '${CHANNEL_BANDWIDTH}' is not supported for ${MODE}" return ${EXIT_ERROR} fi -- 2.39.2