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) {
diff --git a/src/eapol_supp/eapol_supp_sm.c b/src/eapol_supp/eapol_supp_sm.c
index 861eea2..4e66369 100644
--- a/src/eapol_supp/eapol_supp_sm.c
+++ b/src/eapol_supp/eapol_supp_sm.c
@@ -2075,6 +2075,27 @@
}
+static void
+eapol_sm_notify_eap_method_selected(void *ctx,
+ const char* reason_string)
+{
+ struct eapol_sm *sm = ctx;
+
+ if (sm->ctx->eap_method_selected_cb)
+ sm->ctx->eap_method_selected_cb(sm->ctx->ctx, reason_string);
+}
+
+
+static void
+eapol_sm_notify_open_ssl_failure(void *ctx,
+ const char* reason_string)
+{
+ struct eapol_sm *sm = ctx;
+
+ if (sm->ctx->open_ssl_failure_cb)
+ sm->ctx->open_ssl_failure_cb(sm->ctx->ctx, reason_string);
+}
+
static const struct eapol_callbacks eapol_cb =
{
eapol_sm_get_config,
@@ -2095,7 +2116,9 @@
eapol_sm_eap_proxy_notify_sim_status,
eapol_sm_get_eap_proxy_imsi,
#endif /* CONFIG_EAP_PROXY */
- eapol_sm_set_anon_id
+ eapol_sm_set_anon_id,
+ eapol_sm_notify_eap_method_selected,
+ eapol_sm_notify_open_ssl_failure
};
diff --git a/src/eapol_supp/eapol_supp_sm.h b/src/eapol_supp/eapol_supp_sm.h
index 753b947..630a38e 100644
--- a/src/eapol_supp/eapol_supp_sm.h
+++ b/src/eapol_supp/eapol_supp_sm.h
@@ -307,6 +307,20 @@
* Automatically triggers a reconnect when not.
*/
int (*confirm_auth_cb)(void *ctx);
+
+ /**
+ * eap_method_selected_cb - Notification of EAP method selection
+ * @ctx: eapol_ctx from eap_peer_sm_init() call
+ * @reason_string: Information to log about the event
+ */
+ void (*eap_method_selected_cb)(void *ctx, const char* reason_string);
+
+ /**
+ * open_ssl_failure_cb - Notification of an OpenSSL failure
+ * @ctx: eapol_ctx from eap_peer_sm_init() call
+ * @reason_string: Information to log about the event
+ */
+ void (*open_ssl_failure_cb)(void *ctx, const char* reason_string);
};