Add test option for specifying hardcoded BSS Load element
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 6 Aug 2013 15:23:22 +0000 (18:23 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 18 Oct 2013 11:13:45 +0000 (14:13 +0300)
The new bss_load_test parameter can be used to configure hostapd to
advertise a fixed BSS Load element in Beacon and Probe Response frames
for testing purposes. This functionality is disabled in the build by
default and can be enabled with CONFIG_TESTING_OPTIONS=y.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.h
src/ap/beacon.c

index 3a3ae0b..fdd7504 100644 (file)
@@ -3002,6 +3002,25 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                PARSE_TEST_PROBABILITY(ignore_assoc_probability)
                PARSE_TEST_PROBABILITY(ignore_reassoc_probability)
                PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability)
+               } else if (os_strcmp(buf, "bss_load_test") == 0) {
+                       WPA_PUT_LE16(bss->bss_load_test, atoi(pos));
+                       pos = os_strchr(pos, ':');
+                       if (pos == NULL) {
+                               wpa_printf(MSG_ERROR, "Line %d: Invalid "
+                                          "bss_load_test", line);
+                               return 1;
+                       }
+                       pos++;
+                       bss->bss_load_test[2] = atoi(pos);
+                       pos = os_strchr(pos, ':');
+                       if (pos == NULL) {
+                               wpa_printf(MSG_ERROR, "Line %d: Invalid "
+                                          "bss_load_test", line);
+                               return 1;
+                       }
+                       pos++;
+                       WPA_PUT_LE16(&bss->bss_load_test[3], atoi(pos));
+                       bss->bss_load_test_set = 1;
 #endif /* CONFIG_TESTING_OPTIONS */
                } else if (os_strcmp(buf, "vendor_elements") == 0) {
                        struct wpabuf *elems;
index a2e4cd4..eeb0055 100644 (file)
@@ -416,6 +416,12 @@ wmm_ac_vo_acm=0
 # associated stations in the BSS. By default, this bridging is allowed.
 #ap_isolate=1
 
+# Fixed BSS Load value for testing purposes
+# This field can be used to configure hostapd to add a fixed BSS Load element
+# into Beacon and Probe Response frames for testing purposes. The format is
+# <station count>:<channel utilization>:<available admission capacity>
+#bss_load_test=12:80:20000
+
 ##### IEEE 802.11n related configuration ######################################
 
 # ieee80211n: Whether IEEE 802.11n (HT) is enabled
index 803998a..4f6a739 100644 (file)
@@ -467,6 +467,11 @@ struct hostapd_bss_config {
 
        unsigned int sae_anti_clogging_threshold;
        int *sae_groups;
+
+#ifdef CONFIG_TESTING_OPTIONS
+       u8 bss_load_test[5];
+       u8 bss_load_test_set;
+#endif /* CONFIG_TESTING_OPTIONS */
 };
 
 
index 2f4ba23..360001f 100644 (file)
 
 #ifdef NEED_AP_MLME
 
+static u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len)
+{
+#ifdef CONFIG_TESTING_OPTIONS
+       if (hapd->conf->bss_load_test_set) {
+               if (2 + 5 > len)
+                       return eid;
+               *eid++ = WLAN_EID_BSS_LOAD;
+               *eid++ = 5;
+               os_memcpy(eid, hapd->conf->bss_load_test, 5);
+               eid += 5;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+       return eid;
+}
+
+
 static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
 {
        u8 erp = 0;
@@ -251,6 +267,8 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
        /* RSN, MDIE, WPA */
        pos = hostapd_eid_wpa(hapd, pos, epos - pos);
 
+       pos = hostapd_eid_bss_load(hapd, pos, epos - pos);
+
 #ifdef CONFIG_IEEE80211N
        pos = hostapd_eid_ht_capabilities(hapd, pos);
        pos = hostapd_eid_ht_operation(hapd, pos);
@@ -662,6 +680,9 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
        tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
                                  tailpos);
 
+       tailpos = hostapd_eid_bss_load(hapd, tailpos,
+                                      tail + BEACON_TAIL_BUF_SIZE - tailpos);
+
 #ifdef CONFIG_IEEE80211N
        tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
        tailpos = hostapd_eid_ht_operation(hapd, tailpos);