Add ignore_auth_resp control interface debug parameter
authorMikael Kanstrup <mikael.kanstrup@sonymobile.com>
Tue, 20 Sep 2016 06:40:04 +0000 (08:40 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 23 Sep 2016 14:36:55 +0000 (17:36 +0300)
Implement "SET ignore_auth_resp <0/1>" command to simulate auth/assoc
response loss and EAPOL RX packet loss by ignoring corresponding
incoming events.

Signed-off-by: Mikael Kanstrup <mikael.kanstrup@sonymobile.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/events.c
wpa_supplicant/wpa_cli.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index 39aa7e6..0a46ed8 100644 (file)
@@ -511,6 +511,8 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                wpa_s->test_failure = atoi(value);
        } else if (os_strcasecmp(cmd, "p2p_go_csa_on_inv") == 0) {
                wpa_s->p2p_go_csa_on_inv = !!atoi(value);
+       } else if (os_strcasecmp(cmd, "ignore_auth_resp") == 0) {
+               wpa_s->ignore_auth_resp = !!atoi(value);
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifndef CONFIG_NO_CONFIG_BLOBS
        } else if (os_strcmp(cmd, "blob") == 0) {
@@ -7199,6 +7201,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
        wpa_s->extra_roc_dur = 0;
        wpa_s->test_failure = WPAS_TEST_FAILURE_NONE;
        wpa_s->p2p_go_csa_on_inv = 0;
+       wpa_s->ignore_auth_resp = 0;
        wpa_sm_set_test_assoc_ie(wpa_s->wpa, NULL);
 #endif /* CONFIG_TESTING_OPTIONS */
 
index ba30780..ed96228 100644 (file)
@@ -3445,6 +3445,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                sme_event_auth(wpa_s, data);
                break;
        case EVENT_ASSOC:
+#ifdef CONFIG_TESTING_OPTIONS
+               if (wpa_s->ignore_auth_resp) {
+                       wpa_printf(MSG_INFO,
+                                  "EVENT_ASSOC - ignore_auth_resp active!");
+                       break;
+               }
+#endif /* CONFIG_TESTING_OPTIONS */
                wpa_supplicant_event_assoc(wpa_s, data);
                if (data && data->assoc_info.authorized)
                        wpa_supplicant_event_assoc_auth(wpa_s, data);
@@ -3459,6 +3466,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                    data ? &data->disassoc_info : NULL);
                break;
        case EVENT_DEAUTH:
+#ifdef CONFIG_TESTING_OPTIONS
+               if (wpa_s->ignore_auth_resp) {
+                       wpa_printf(MSG_INFO,
+                                  "EVENT_DEAUTH - ignore_auth_resp active!");
+                       break;
+               }
+#endif /* CONFIG_TESTING_OPTIONS */
                wpas_event_deauth(wpa_s,
                                  data ? &data->deauth_info : NULL);
                break;
index ca3d8f8..a848b77 100644 (file)
@@ -451,7 +451,10 @@ static char ** wpa_cli_complete_set(const char *str, int pos)
                "tdls_external_control", "osu_dir", "wowlan_triggers",
                "p2p_search_delay", "mac_addr", "rand_addr_lifetime",
                "preassoc_mac_addr", "key_mgmt_offload", "passive_scan",
-               "reassoc_same_bss_optim", "wps_priority"
+               "reassoc_same_bss_optim", "wps_priority",
+#ifdef CONFIG_TESTING_OPTIONS
+               "ignore_auth_resp",
+#endif /* CONFIG_TESTING_OPTIONS */
        };
        int i, num_fields = ARRAY_SIZE(fields);
 
index df18c0c..1a1d5ee 100644 (file)
@@ -3377,6 +3377,13 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
        wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
        wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len);
 
+#ifdef CONFIG_TESTING_OPTIONS
+       if (wpa_s->ignore_auth_resp) {
+               wpa_printf(MSG_INFO, "RX EAPOL - ignore_auth_resp active!");
+               return;
+       }
+#endif /* CONFIG_TESTING_OPTIONS */
+
 #ifdef CONFIG_PEERKEY
        if (wpa_s->wpa_state > WPA_ASSOCIATED && wpa_s->current_ssid &&
            wpa_s->current_ssid->peerkey &&
index f3f96a3..39ed1f2 100644 (file)
@@ -1024,6 +1024,7 @@ struct wpa_supplicant {
        unsigned int extra_roc_dur;
        enum wpa_supplicant_test_failure test_failure;
        unsigned int p2p_go_csa_on_inv:1;
+       unsigned int ignore_auth_resp:1;
 #endif /* CONFIG_TESTING_OPTIONS */
 
        struct wmm_ac_assoc_data *wmm_ac_assoc_info;