]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
hostapd: Read the correct capabilities for the right band
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Nov 2025 11:31:56 +0000 (12:31 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Nov 2025 11:31:56 +0000 (12:31 +0100)
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 <michael.tremer@ipfire.org>
src/initscripts/packages/hostapd

index 931591b8450779dc3baf64c8e4a6937d3ed6bf66..5384badaba0f1974b3ea5cc1c75089f289bdc0e5 100644 (file)
@@ -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"