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/hostapd/Android.mk b/hostapd/Android.mk
index 3590b09..91cdefe 100644
--- a/hostapd/Android.mk
+++ b/hostapd/Android.mk
@@ -69,6 +69,10 @@
 endif
 endif
 
+ifdef CONFIG_TESTING_OPTIONS
+L_CFLAGS += -DCONFIG_TESTING_OPTIONS
+CONFIG_WPS_TESTING=y
+endif
 
 ifndef CONFIG_OS
 ifdef CONFIG_NATIVE_WINDOWS
diff --git a/hostapd/android.config b/hostapd/android.config
index f791daa..fd3c1a1 100644
--- a/hostapd/android.config
+++ b/hostapd/android.config
@@ -244,3 +244,11 @@
 # This can be used to enable functionality to improve interworking with
 # external networks.
 CONFIG_INTERWORKING=y
+
+# Testing options
+# This can be used to enable some testing options (see also the example
+# configuration file) that are useful for testing clients that
+# connect to this hostapd. These options allow, for example, to drop a
+# certain percentage of probe requests or auth/(re)assoc frames.
+# Each test case requires a flag set in hostapd.conf or through hostapd_cli
+#CONFIG_TESTING_OPTIONS=y
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index ce32f3c..efbfd80 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -4184,6 +4184,10 @@
 		bss->oci_freq_override_fils_assoc = atoi(pos);
 	} else if (os_strcmp(buf, "oci_freq_override_wnm_sleep") == 0) {
 		bss->oci_freq_override_wnm_sleep = atoi(pos);
+	} else if (os_strcmp(buf, "skip_send_eapol") == 0) {
+		conf->skip_send_eapol = atoi(pos);
+	} else if (os_strcmp(buf, "enable_eapol_large_timeout") == 0) {
+		conf->enable_eapol_large_timeout = atoi(pos);
 #endif /* CONFIG_TESTING_OPTIONS */
 #ifdef CONFIG_SAE
 	} else if (os_strcmp(buf, "sae_password") == 0) {
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 30fa47f..02b41fd 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1504,6 +1504,10 @@
 			wpa_auth_set_ocv_override_freq(
 				hapd->wpa_auth,
 				WPA_AUTH_OCV_OVERRIDE_FILS_ASSOC, atoi(value));
+		else if (os_strcasecmp(cmd, "skip_send_eapol") == 0)
+			wpa_auth_set_skip_send_eapol(hapd->wpa_auth, atoi(value));
+		else if (os_strcasecmp(cmd, "enable_eapol_large_timeout") == 0)
+			wpa_auth_set_enable_eapol_large_timeout(hapd->wpa_auth, atoi(value));
 #endif /* CONFIG_TESTING_OPTIONS */
 	}