From: Michael Tremer Date: Wed, 19 Sep 2018 16:45:32 +0000 (+0100) Subject: hostapd: Add support for 802.11ac X-Git-Tag: 010~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c26292250e14cf4efbc9eb8f2ace430677c749d;p=network.git hostapd: Add support for 802.11ac Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.hostapd b/src/functions/functions.hostapd index a3c34920..3f64e79b 100644 --- a/src/functions/functions.hostapd +++ b/src/functions/functions.hostapd @@ -21,6 +21,8 @@ HOSTAPD_CONTROL_INTERFACE_DIR="/run/hostapd/ctrl" +HOSTAPD_SUPPORTED_MODES="802.11a 802.11a/n 802.11ac 802.11g 802.11g/n" + hostapd_config_write() { local device=${1} assert isset device @@ -56,6 +58,11 @@ hostapd_config_write() { ;; --mode=*) mode=$(cli_get_val "${1}") + + if ! isoneof mode ${HOSTAPD_SUPPORTED_MODES}; then + error "Unsupported mode: ${mode}" + return ${EXIT_ERROR} + fi ;; --ssid=*) ssid=$(cli_get_val "${1}") @@ -75,6 +82,12 @@ hostapd_config_write() { shift done + # Check if mode is set + if ! isset mode; then + error "Mode is not set" + return ${EXIT_ERROR} + fi + assert isset broadcast_ssid assert isbool broadcast_ssid @@ -90,11 +103,50 @@ hostapd_config_write() { assert isset key fi - # Get VHT caps - local vht_caps="$(wireless_get_vht_caps "${device}")" + # 802.11ac/n flags + local ieee80211ac + local ieee80211n + local vht_caps + local ht_caps + + local hw_mode + case "${mode}" in + 802.11a) + hw_mode="a" + ;; + + 802.11a/n) + hw_mode="a" + ieee80211n="1" + + # Fetch HT caps + ht_caps="$(wireless_get_ht_caps "${device}")" + ;; + + 802.11g) + hw_mode="g" + ;; + + 802.11g/n) + hw_mode="g" + ieee80211n="1" + + # Fetch HT caps + ht_caps="$(wireless_get_ht_caps "${device}")" + ;; + + 802.11ac) + hw_mode="a" + ieee80211ac="1" + ieee80211n="1" - # Get HT caps - local ht_caps="$(wireless_get_ht_caps "${device}")" + # Fetch VHT caps + vht_caps="$(wireless_get_vht_caps "${device}")" + + # Fetch HT caps + ht_caps="$(wireless_get_ht_caps "${device}")" + ;; + esac # Create configuration directory. local config_dir=$(dirname ${file}) @@ -118,29 +170,30 @@ hostapd_config_write() { ignore_broadcast_ssid="1" fi - local hw_mode ieee80211n="0" - if [ "${mode}" = "n" ]; then - if [ ${channel} -le 15 ]; then - hw_mode="g" - else - hw_mode="a" - fi - ieee80211n="1" - else - hw_mode="${mode}" - fi - ( print "# Default settings" # Advertise country code and maximum transmission power print "ieee80211d=1" + # Enable Radar Detection + print "ieee80211h=1" + + print # empty line + print "# Wireless configuration" + print "hw_mode=${hw_mode}" + + if isset ieee80211ac; then + print "ieee80211ac=${ieee80211ac}" + fi + + if isset ieee80211n; then + print "ieee80211n=${ieee80211n}" + fi + print "channel=${channel}" print "country_code=${country_code}" - print "hw_mode=${hw_mode}" - print "ieee80211n=${ieee80211n}" print "ignore_broadcast_ssid=${ignore_broadcast_ssid}" if contains_spaces "${ssid}"; then diff --git a/src/hooks/ports/wireless-ap b/src/hooks/ports/wireless-ap index 4b31a8b2..f132be64 100644 --- a/src/hooks/ports/wireless-ap +++ b/src/hooks/ports/wireless-ap @@ -31,7 +31,6 @@ BROADCAST_SSID=on CHANNEL=1 ENCRYPTION="" KEY="" -MODE="g" SSID= hook_check_settings() { @@ -41,7 +40,7 @@ hook_check_settings() { assert isbool BROADCAST_SSID assert isset CHANNEL assert isset MODE - assert isoneof MODE a b g n + assert isoneof MODE ${HOSTAPD_SUPPORTED_MODES} assert isset PHY assert ismac PHY assert isset SSID @@ -75,6 +74,12 @@ hook_parse_cmdline() { ;; --mode=*) MODE=$(cli_get_val "${1}") + + if ! isoneof MODE ${HOSTAPD_SUPPORTED_MODES}; then + error "Unsupported mode: ${MODE}" + error "Mode must be one of ${HOSTAPD_SUPPORTED_MODES}" + return ${EXIT_ERROR} + fi ;; --phy=*) PHY=$(cli_get_val "${1}") @@ -89,6 +94,12 @@ hook_parse_cmdline() { shift done + # MODE must be set + if ! isset MODE; then + error "--mode is not set" + return ${EXIT_ERROR} + fi + # Save address of phy do identify it again PHY=$(phy_get ${PHY}) PHY=$(phy_get_address ${PHY})