[PATCH 2/5] Implement IGNORE_AUTH_RESP control interface debug command

Mikael Kanstrup mikael.kanstrup at sonymobile.com
Mon Sep 19 23:40:04 PDT 2016


Implement IGNORE_AUTH_RESP command to simulate auth/assoc response loss
and eapol rx packet loss by ignoring corresponding incoming events.

Signed-off-by: Mikael Kanstrup <mikael.kanstrup at sonymobile.com>
---
 wpa_supplicant/ctrl_iface.c       |  7 +++++++
 wpa_supplicant/events.c           | 14 ++++++++++++++
 wpa_supplicant/wpa_cli.c          |  6 ++++--
 wpa_supplicant/wpa_supplicant.c   |  7 +++++++
 wpa_supplicant/wpa_supplicant_i.h |  3 +++
 5 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 9543fd1..b926c36 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -7195,6 +7195,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->global->ignore_auth_resp = 0;
 	wpa_sm_set_test_assoc_ie(wpa_s->wpa, NULL);
 #endif /* CONFIG_TESTING_OPTIONS */
 
@@ -9757,6 +9758,12 @@ static int wpas_global_ctrl_iface_set(struct wpa_global *global, char *cmd)
 		return 0;
 	}
 #endif /* CONFIG_WIFI_DISPLAY */
+#ifdef CONFIG_TESTING_OPTIONS
+	if (os_strcasecmp(cmd, "ignore_auth_resp") == 0) {
+		global->ignore_auth_resp = !!atoi(value);
+		return 0;
+	}
+#endif /* CONFIG_TESTING_OPTIONS */
 
 	/* Restore cmd to its original value to allow redirection */
 	value[-1] = ' ';
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index ef62d70..3b8e310 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -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->global->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->global->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;
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index ca3d8f8..842a10d 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -293,7 +293,6 @@ static int wpa_cli_cmd_status(struct wpa_ctrl *ctrl, int argc, char *argv[])
 	return wpa_ctrl_command(ctrl, "STATUS");
 }
 
-
 static int wpa_cli_cmd_ping(struct wpa_ctrl *ctrl, int argc, char *argv[])
 {
 	return wpa_ctrl_command(ctrl, "PING");
@@ -451,7 +450,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);
 
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 0785576..65bc4fe 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -3372,6 +3372,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->global->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 &&
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index f3f96a3..dd13d5e 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -300,6 +300,9 @@ struct wpa_global {
 #endif /* CONFIG_WIFI_DISPLAY */
 
 	struct psk_list_entry *add_psk; /* From group formation */
+#ifdef CONFIG_TESTING_OPTIONS
+	int ignore_auth_resp;
+#endif /* CONFIG_TESTING_OPTIONS */
 };
 
 
-- 
2.9.0.137.gcf4c2cf




More information about the Hostap mailing list