]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Add testing option to override own WPA/RSN IE(s)
authorJouni Malinen <j@w1.fi>
Sat, 8 Aug 2015 15:18:03 +0000 (18:18 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 8 Aug 2015 15:18:03 +0000 (18:18 +0300)
This allows the new own_ie_override=<hexdump> configuration parameter to
be used to replace the normally generated WPA/RSN IE(s) for testing
purposes in CONFIG_TESTING_OPTIONS=y builds.

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

index 0edf6afc7639810e1e53161cc77cd5dbc35ad732..f8ca6da6e61f03644df1da5928d4327670144548 100644 (file)
@@ -3268,6 +3268,24 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                bss->bss_load_test_set = 1;
        } else if (os_strcmp(buf, "radio_measurements") == 0) {
                bss->radio_measurements = atoi(pos);
+       } else if (os_strcmp(buf, "own_ie_override") == 0) {
+               struct wpabuf *tmp;
+               size_t len = os_strlen(pos) / 2;
+
+               tmp = wpabuf_alloc(len);
+               if (!tmp)
+                       return 1;
+
+               if (hexstr2bin(pos, wpabuf_put(tmp, len), len)) {
+                       wpabuf_free(tmp);
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: Invalid own_ie_override '%s'",
+                                  line, pos);
+                       return 1;
+               }
+
+               wpabuf_free(bss->own_ie_override);
+               bss->own_ie_override = tmp;
 #endif /* CONFIG_TESTING_OPTIONS */
        } else if (os_strcmp(buf, "vendor_elements") == 0) {
                struct wpabuf *elems;
index 455013aa7c1edf9ffeeeb3c7d8571f38fa09ce9d..8727375490ccd614d021d7c0bb5158a33ecc6748 100644 (file)
@@ -561,6 +561,10 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 
        os_free(conf->server_id);
 
+#ifdef CONFIG_TESTING_OPTIONS
+       wpabuf_free(conf->own_ie_override);
+#endif /* CONFIG_TESTING_OPTIONS */
+
        os_free(conf);
 }
 
index b319587d4d3a4cc2b579e3e6433eae783e16ec32..07550bd3671b6e68df80c4a12b6533c4418e9594 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd / Configuration definitions and helpers functions
- * Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -544,6 +544,7 @@ struct hostapd_bss_config {
 #ifdef CONFIG_TESTING_OPTIONS
        u8 bss_load_test[5];
        u8 bss_load_test_set;
+       struct wpabuf *own_ie_override;
 #endif /* CONFIG_TESTING_OPTIONS */
 
 #define MESH_ENABLED BIT(0)
index e7478064fc38f6d63d864efb15665cd3e866d2ea..7c76700aa96b4a7b4433277f7ef652467e046733 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd - IEEE 802.11i-2004 / WPA Authenticator
- * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2015, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -14,6 +14,8 @@
 #include "common/wpa_common.h"
 #include "common/ieee802_11_defs.h"
 
+#define MAX_OWN_IE_OVERRIDE 256
+
 #ifdef _MSC_VER
 #pragma pack(push, 1)
 #endif /* _MSC_VER */
@@ -164,6 +166,8 @@ struct wpa_auth_config {
        int ap_mlme;
 #ifdef CONFIG_TESTING_OPTIONS
        double corrupt_gtk_rekey_mic_probability;
+       u8 own_ie_override[MAX_OWN_IE_OVERRIDE];
+       size_t own_ie_override_len;
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifdef CONFIG_P2P
        u8 ip_addr_go[4];
index d65dc631fc0d606cf2a4d2f6ab26c853dae74484..f98cc50599e3764c1c1aef578cb457dab14f1d96 100644 (file)
@@ -92,6 +92,13 @@ static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf,
 #ifdef CONFIG_TESTING_OPTIONS
        wconf->corrupt_gtk_rekey_mic_probability =
                iconf->corrupt_gtk_rekey_mic_probability;
+       if (conf->own_ie_override &&
+           wpabuf_len(conf->own_ie_override) <= MAX_OWN_IE_OVERRIDE) {
+               wconf->own_ie_override_len = wpabuf_len(conf->own_ie_override);
+               os_memcpy(wconf->own_ie_override,
+                         wpabuf_head(conf->own_ie_override),
+                         wconf->own_ie_override_len);
+       }
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifdef CONFIG_P2P
        os_memcpy(wconf->ip_addr_go, conf->ip_addr_go, 4);
index cf2a71260e0d6b7985e60a1fa04859b6bc3b0f34..eafb828b8d60e4cc0c9c8033c2a84fa92f6e8d0f 100644 (file)
@@ -378,6 +378,23 @@ int wpa_auth_gen_wpa_ie(struct wpa_authenticator *wpa_auth)
        u8 *pos, buf[128];
        int res;
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (wpa_auth->conf.own_ie_override_len) {
+               wpa_hexdump(MSG_DEBUG, "WPA: Forced own IE(s) for testing",
+                           wpa_auth->conf.own_ie_override,
+                           wpa_auth->conf.own_ie_override_len);
+               os_free(wpa_auth->wpa_ie);
+               wpa_auth->wpa_ie =
+                       os_malloc(wpa_auth->conf.own_ie_override_len);
+               if (wpa_auth->wpa_ie == NULL)
+                       return -1;
+               os_memcpy(wpa_auth->wpa_ie, wpa_auth->conf.own_ie_override,
+                         wpa_auth->conf.own_ie_override_len);
+               wpa_auth->wpa_ie_len = wpa_auth->conf.own_ie_override_len;
+               return 0;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
        pos = buf;
 
        if (wpa_auth->conf.wpa == WPA_PROTO_OSEN) {