From: Michael Tremer Date: Tue, 25 Nov 2025 11:31:56 +0000 (+0100) Subject: hostapd: Read the correct capabilities for the right band X-Git-Tag: v2.29-core199~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77d9e3e4c2f3c0f573ac40318950e106755a236d;p=ipfire-2.x.git hostapd: Read the correct capabilities for the right band Some modules don't support the same capabilities in the 2.4/5 GHz bands. Therefore we need to abort parsing once we have found the correct capabilities. Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/packages/hostapd b/src/initscripts/packages/hostapd index 931591b84..5384badab 100644 --- a/src/initscripts/packages/hostapd +++ b/src/initscripts/packages/hostapd @@ -126,10 +126,18 @@ write_config() { local eht_mac_flags=0 local eht_phy_flags=0 - local ht_caps=() - local vht_caps=() - local he_caps=() - local eht_caps=() + # Set some default BAND if none is set + if [ -z "${BAND}" ]; then + # Use 2.4 GHz for 802.11g/n and assume 5 GHz for anything else + case "${HW_MODE}" in + gn) + BAND="2g" + ;; + *) + BAND="5g" + ;; + esac + fi # Fetch PHY information local line @@ -153,9 +161,27 @@ write_config() { "Capabilities: "*) ht_flags="${line:14}" ;; + + # Check if we are in the right band + "* 2412.0 MHz"*) + if [ "${BAND}" = "2g" ]; then + break + fi + ;; + + "* 5180.0 MHz"*) + if [ "${BAND}" = "5g" ]; then + break + fi + ;; esac done <<<"$(iw phy "${phy}" info)" + local ht_caps=() + local vht_caps=() + local he_caps=() + local eht_caps=() + # HT Capabilities for flag in ${!HT_CAPS[@]}; do if (( ${ht_flags} & ${flag} )); then @@ -300,19 +326,6 @@ write_config() { esac fi - # Set some default BAND if none is set - if [ -z "${BAND}" ]; then - # Use 2.4 GHz for 802.11g/n and assume 5 GHz for anything else - case "${HW_MODE}" in - gn) - BAND="2g" - ;; - *) - BAND="5g" - ;; - esac - fi - # Header echo "# Automatically generated configuration" echo "# DO NOT EDIT"