]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow AP mode extended capabilities to be overridden
authorJouni Malinen <j@w1.fi>
Mon, 22 Mar 2021 09:29:31 +0000 (11:29 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 22 Mar 2021 09:58:21 +0000 (11:58 +0200)
The new hostapd configuration parameters ext_capa_mask and ext_capa can
now be used to mask out or add extended capability bits. While this is
not without CONFIG_TESTING_OPTIONS, the main use case for this is for
testing purposes.

Signed-off-by: Jouni Malinen <j@w1.fi>
hostapd/config_file.c
src/ap/ap_config.h
src/ap/ieee802_11_shared.c

index 2347df3f764bc0d01bcb29b8bd9ba7a155f2d3c3..e05c81366d9b1a03fd8913c39abcbb455bc99822 100644 (file)
@@ -2332,6 +2332,22 @@ fail:
 #endif /* CONFIG_DPP2 */
 
 
+static int get_hex_config(u8 *buf, size_t max_len, int line,
+                         const char *field, const char *val)
+{
+       size_t hlen = os_strlen(val), len = hlen / 2;
+       u8 tmp[EXT_CAPA_MAX_LEN];
+
+       os_memset(tmp, 0, EXT_CAPA_MAX_LEN);
+       if (hlen & 1 || len > EXT_CAPA_MAX_LEN || hexstr2bin(val, tmp, len)) {
+               wpa_printf(MSG_ERROR, "Line %d: Invalid %s", line, field);
+               return -1;
+       }
+       os_memcpy(buf, tmp, EXT_CAPA_MAX_LEN);
+       return 0;
+}
+
+
 static int hostapd_config_fill(struct hostapd_config *conf,
                               struct hostapd_bss_config *bss,
                               const char *buf, char *pos, int line)
@@ -4679,6 +4695,14 @@ static int hostapd_config_fill(struct hostapd_config *conf,
        } else if (os_strcmp(buf, "pasn_comeback_after") == 0) {
                bss->pasn_comeback_after = atoi(pos);
 #endif /* CONFIG_PASN */
+       } else if (os_strcmp(buf, "ext_capa_mask") == 0) {
+               if (get_hex_config(bss->ext_capa_mask, EXT_CAPA_MAX_LEN,
+                                  line, "ext_capa_mask", pos))
+                       return 1;
+       } else if (os_strcmp(buf, "ext_capa") == 0) {
+               if (get_hex_config(bss->ext_capa, EXT_CAPA_MAX_LEN,
+                                  line, "ext_capa", pos))
+                       return 1;
        } else {
                wpa_printf(MSG_ERROR,
                           "Line %d: unknown configuration item '%s'",
index f86cf26ca322e06cee69d13daa52c10b6607ce76..95bd79873a59bb9ad2cce0ab7cd0cc99cdecc0c8 100644 (file)
@@ -267,6 +267,8 @@ struct airtime_sta_weight {
        u8 addr[ETH_ALEN];
 };
 
+#define EXT_CAPA_MAX_LEN 15
+
 /**
  * struct hostapd_bss_config - Per-BSS configuration
  */
@@ -889,6 +891,9 @@ struct hostapd_bss_config {
 #endif /* CONFIG_PASN */
 
        unsigned int unsol_bcast_probe_resp_interval;
+
+       u8 ext_capa_mask[EXT_CAPA_MAX_LEN];
+       u8 ext_capa[EXT_CAPA_MAX_LEN];
 };
 
 /**
index 727de75d7cee84cfde6443c451bf3eda7da446ea..4bff9e5918832f917e356f80d840f24171f71266 100644 (file)
@@ -451,7 +451,7 @@ static void hostapd_ext_capab_byte(struct hostapd_data *hapd, u8 *pos, int idx)
 u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid)
 {
        u8 *pos = eid;
-       u8 len = 12, i;
+       u8 len = EXT_CAPA_MAX_LEN, i;
 
        if (len < hapd->iface->extended_capa_len)
                len = hapd->iface->extended_capa_len;
@@ -465,6 +465,11 @@ u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid)
                        *pos &= ~hapd->iface->extended_capa_mask[i];
                        *pos |= hapd->iface->extended_capa[i];
                }
+
+               if (i < EXT_CAPA_MAX_LEN) {
+                       *pos &= ~hapd->conf->ext_capa_mask[i];
+                       *pos |= hapd->conf->ext_capa[i];
+               }
        }
 
        while (len > 0 && eid[1 + len] == 0) {