]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/functions/functions.hostapd
hostapd: Always enable 802.11d
[people/ms/network.git] / src / functions / functions.hostapd
index 1d10b978fff241cd9c1508bef31fc1f143d80a94..a3c34920aeb5ce3fb43615d9c55ebebe0d74f773 100644 (file)
@@ -21,7 +21,7 @@
 
 HOSTAPD_CONTROL_INTERFACE_DIR="/run/hostapd/ctrl"
 
-function hostapd_config_write() {
+hostapd_config_write() {
        local device=${1}
        assert isset device
 
@@ -33,9 +33,8 @@ function hostapd_config_write() {
 
        local broadcast_ssid
        local channel
-       local country_code
+       local country_code="$(wireless_get_reg_domain)"
        local encryption
-       local ieee80211d="1"
        local key
        local mode
        local ssid
@@ -44,33 +43,22 @@ function hostapd_config_write() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --broadcast-ssid=*)
-                               broadcast_ssid=$(cli_get_val ${1})
+                               broadcast_ssid=$(cli_get_val "${1}")
                                ;;
                        --channel=*)
-                               channel=$(cli_get_val ${1})
-                               ;;
-                       --country-code=*)
-                               country_code=$(cli_get_val ${1})
+                               channel=$(cli_get_val "${1}")
                                ;;
                        --encryption=*)
-                               encryption=$(cli_get_val ${1})
-                               ;;
-                       --ieee80211d=*)
-                               local val="$(cli_get_val "${1}")"
-                               if enabled val; then
-                                       ieee80211d="1"
-                               else
-                                       ieee80211d="0"
-                               fi
+                               encryption=$(cli_get_val "${1}")
                                ;;
                        --key=*)
-                               key=$(cli_get_val ${1})
+                               key=$(cli_get_val "${1}")
                                ;;
                        --mode=*)
-                               mode=$(cli_get_val ${1})
+                               mode=$(cli_get_val "${1}")
                                ;;
                        --ssid=*)
-                               ssid=$(cli_get_val ${1})
+                               ssid=$(cli_get_val "${1}")
                                ;;
                        --wmm=*)
                                local val="$(cli_get_val "${1}")"
@@ -93,7 +81,6 @@ function hostapd_config_write() {
        assert isset channel
        assert isinteger channel
 
-       assert isset country_code
        assert isset mode
        assert isset ssid
 
@@ -103,6 +90,12 @@ function hostapd_config_write() {
                assert isset key
        fi
 
+       # Get VHT caps
+       local vht_caps="$(wireless_get_vht_caps "${device}")"
+
+       # Get HT caps
+       local ht_caps="$(wireless_get_ht_caps "${device}")"
+
        # Create configuration directory.
        local config_dir=$(dirname ${file})
        mkdir -p ${HOSTAPD_CONTROL_INTERFACE_DIR} ${config_dir} 2>/dev/null
@@ -138,11 +131,15 @@ function hostapd_config_write() {
        fi
 
        (
+               print "# Default settings"
+
+               # Advertise country code and maximum transmission power
+               print "ieee80211d=1"
+
                print "# Wireless configuration"
                print "channel=${channel}"
                print "country_code=${country_code}"
                print "hw_mode=${hw_mode}"
-               print "ieee80211d=${ieee80211d}"
                print "ieee80211n=${ieee80211n}"
                print "ignore_broadcast_ssid=${ignore_broadcast_ssid}"
 
@@ -155,6 +152,14 @@ function hostapd_config_write() {
                # WMM
                print "wmm_enabled=${wmm}"
 
+               # Enable VHT caps
+               if isset vht_caps; then
+                       print "vht_capab=${vht_caps}"
+               fi
+
+               # Enable HT caps
+               print "ht_capab=${ht_caps}"
+
                print
        ) >> ${file}
 
@@ -195,7 +200,7 @@ function hostapd_config_write() {
        return ${EXIT_OK}
 }
 
-function hostapd_start() {
+hostapd_start() {
        local device=${1}
        assert isset device
 
@@ -212,7 +217,7 @@ function hostapd_start() {
        return ${EXIT_OK}
 }
 
-function hostapd_stop() {
+hostapd_stop() {
        local device=${1}
        assert isset device