Notify the framework when an auxiliary event
occurs in wpa_supplicant.

Auxiliary events include:
  - EAP_METHOD_SELECTED
  - SSID_TEMP_DISABLED
  - OPEN_SSL_FAILURE

Bug: 226140098
Bug: 165342942
Test: Manual test - trigger events and check that
      onAuxilliaryEvent callback was called.
Change-Id: Ia1f137ddc1a4d91049668d6436652a0ad749c74f
diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c
index 7dcfe4f..5fd370f 100644
--- a/src/eap_peer/eap.c
+++ b/src/eap_peer/eap.c
@@ -429,6 +429,17 @@
 	wpa_msg(sm->msg_ctx, MSG_INFO, WPA_EVENT_EAP_METHOD
 		"EAP vendor %u method %u (%s) selected",
 		sm->reqVendor, method, sm->m->name);
+
+	if (sm->eapol_cb->notify_eap_method_selected) {
+		char *format_str = "EAP vendor %u method %u (%s) selected";
+		int msg_len = snprintf(NULL, 0, format_str,
+			sm->reqVendor, method, sm->m->name) + 1;
+		char *msg = os_malloc(msg_len);
+		snprintf(msg, msg_len, format_str,
+			sm->reqVendor, method, sm->m->name);
+		sm->eapol_cb->notify_eap_method_selected(sm->eapol_ctx, msg);
+		os_free(msg);
+	}
 	return;
 
 nak:
diff --git a/src/eap_peer/eap.h b/src/eap_peer/eap.h
index a40d007..aae1a41 100644
--- a/src/eap_peer/eap.h
+++ b/src/eap_peer/eap.h
@@ -281,6 +281,20 @@
 	 * @len: Length of anonymous identity in octets
 	 */
 	void (*set_anon_id)(void *ctx, const u8 *id, size_t len);
+
+	/**
+	 * notify_eap_method_selected - Report that the EAP method was selected
+	 * @ctx: eapol_ctx from eap_peer_sm_init() call
+	 * @reason_string: Information to log about the event
+	 */
+	void (*notify_eap_method_selected)(void *ctx, const char* reason_string);
+
+	/**
+	 * notify_open_ssl_failure - Report that an OpenSSL failure occurred
+	 * @ctx: eapol_ctx from eap_peer_sm_init() call
+	 * @reason_string: Information to log about the event
+	 */
+	void (*notify_open_ssl_failure)(void *ctx, const char* reason_string);
 };
 
 /**
diff --git a/src/eap_peer/eap_tls_common.c b/src/eap_peer/eap_tls_common.c
index 0e00801..1aaca36 100644
--- a/src/eap_peer/eap_tls_common.c
+++ b/src/eap_peer/eap_tls_common.c
@@ -778,6 +778,10 @@
 		wpa_printf(MSG_DEBUG, "SSL: Failed - tls_out available to "
 			   "report error (len=%u)",
 			   (unsigned int) wpabuf_len(data->tls_out));
+		if (sm->eapol_cb->notify_open_ssl_failure) {
+			sm->eapol_cb->notify_open_ssl_failure(sm->eapol_ctx,
+				"TLS processing has failed");
+		}
 		ret = -1;
 		/* TODO: clean pin if engine used? */
 		if (wpabuf_len(data->tls_out) == 0) {