Add options in hostapd to inject connection failures.

Add hostapd_cli set commands for skip_send_eapol and enable_eapol_large_timeout.
1) with skip_send_eapol=1, AP won't send m0/m2 frames.
2) with enable_eapol_large_timeout=1, AP will time out 50 seconds after m0 or m2.
These two flags can also be set in hostapd.conf. By default, both are
set to 0.

With skip_send_eapol=1 and enable_eapol_large_timeout=0, AP will deauthenticate STA during 4-way handshake.
With skip_send_eapol=1 and enable_eapol_large_timeout=1, STA will hit auth timeout.

Bug: 174201865
Test: manual test with hostapd_cli set commands and check if STA hits
the above connection failures.

Change-Id: I3df1ab11a54b81254ce7efdd6c5e4d95a9314ddc
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 9d74bfc..e48894f 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -188,6 +188,10 @@
 {
 	if (!wpa_auth->cb->send_eapol)
 		return -1;
+#ifdef CONFIG_TESTING_OPTIONS
+	if (wpa_auth->conf.skip_send_eapol)
+		return 0;
+#endif
 	return wpa_auth->cb->send_eapol(wpa_auth->cb_ctx, addr, data, data_len,
 					encrypt);
 }
@@ -1663,7 +1667,7 @@
 
 	wpa_auth_set_eapol(wpa_auth, sm->addr, WPA_EAPOL_inc_EapolFramesTx, 1);
 	wpa_auth_send_eapol(wpa_auth, sm->addr, (u8 *) hdr, len,
-			    sm->pairwise_set);
+			sm->pairwise_set);
 	os_free(hdr);
 }
 
@@ -1698,6 +1702,11 @@
 #ifdef TEST_FUZZ
 	timeout_ms = 1;
 #endif /* TEST_FUZZ */
+#ifdef CONFIG_TESTING_OPTIONS
+	if(wpa_auth->conf.enable_eapol_large_timeout) {
+		timeout_ms = 50 * 1000;
+	}
+#endif
 	wpa_printf(MSG_DEBUG,
 		   "WPA: Use EAPOL-Key timeout of %u ms (retry counter %u)",
 		   timeout_ms, ctr);
@@ -5612,4 +5621,19 @@
 	}
 }
 
+void wpa_auth_set_skip_send_eapol(struct wpa_authenticator *wpa_auth,
+				     u8 val)
+{
+	if (wpa_auth)
+		wpa_auth->conf.skip_send_eapol = val;
+}
+
+void wpa_auth_set_enable_eapol_large_timeout(struct wpa_authenticator *wpa_auth,
+				     u8 val)
+{
+	if (wpa_auth)
+		wpa_auth->conf.enable_eapol_large_timeout = val;
+}
+
+
 #endif /* CONFIG_TESTING_OPTIONS */