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
This commit is contained in:
Gabriel Biren
2022-03-07 17:59:41 +00:00
parent c1a2144e79
commit 3a2ec2ce7c
13 changed files with 195 additions and 2 deletions

View File

@@ -429,6 +429,17 @@ SM_STATE(EAP, GET_METHOD)
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:

View File

@@ -281,6 +281,20 @@ struct eapol_callbacks {
* @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);
};
/**

View File

@@ -778,6 +778,10 @@ int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
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) {

View File

@@ -2075,6 +2075,27 @@ static void eapol_sm_set_anon_id(void *ctx, const u8 *id, size_t len)
}
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 @@ static const struct eapol_callbacks eapol_cb =
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
};

View File

@@ -307,6 +307,20 @@ struct eapol_ctx {
* 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);
};

View File

@@ -22,6 +22,7 @@ extern "C"
}
using aidl::android::hardware::wifi::supplicant::AidlManager;
using aidl::android::hardware::wifi::supplicant::AuxiliarySupplicantEventCode;
using aidl::android::hardware::wifi::supplicant::DppEventType;
using aidl::android::hardware::wifi::supplicant::DppFailureCode;
using aidl::android::hardware::wifi::supplicant::DppProgressCode;
@@ -961,3 +962,42 @@ void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s,
cert_hash,
cert);
}
void wpas_aidl_notify_auxiliary_event(struct wpa_supplicant *wpa_s,
AuxiliarySupplicantEventCode event_code, const char *reason_string)
{
if (!wpa_s)
return;
AidlManager *aidl_manager = AidlManager::getInstance();
if (!aidl_manager)
return;
wpa_printf(MSG_DEBUG, "Notify auxiliary event, code=%d",
static_cast<int>(event_code));
aidl_manager->notifyAuxiliaryEvent(wpa_s, event_code, reason_string);
}
void wpas_aidl_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
const char *reason_string)
{
wpas_aidl_notify_auxiliary_event(wpa_s,
AuxiliarySupplicantEventCode::EAP_METHOD_SELECTED,
reason_string);
}
void wpas_aidl_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
const char *reason_string)
{
wpas_aidl_notify_auxiliary_event(wpa_s,
AuxiliarySupplicantEventCode::SSID_TEMP_DISABLED,
reason_string);
}
void wpas_aidl_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
const char *reason_string)
{
wpas_aidl_notify_auxiliary_event(wpa_s,
AuxiliarySupplicantEventCode::OPEN_SSL_FAILURE,
reason_string);
}

View File

@@ -133,6 +133,12 @@ extern "C"
int num_altsubject,
const char *cert_hash,
const struct wpabuf *cert);
void wpas_aidl_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
const char *reason_string);
void wpas_aidl_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
const char *reason_string);
void wpas_aidl_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
const char *reason_string);
#else // CONFIG_CTRL_IFACE_AIDL
static inline int wpas_aidl_register_interface(struct wpa_supplicant *wpa_s)
{
@@ -293,6 +299,15 @@ void wpas_aidl_notify_ceritification(struct wpa_supplicant *wpa_s,
const char *cert_hash,
const struct wpabuf *cert)
{}
void wpas_aidl_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
const char *reason_string)
{}
void wpas_aidl_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
const char *reason_string)
{}
void wpas_aidl_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
const char *reason_string)
{}
#endif // CONFIG_CTRL_IFACE_AIDL
#ifdef _cplusplus

View File

@@ -1546,7 +1546,8 @@ void AidlManager::notifyEapError(struct wpa_supplicant *wpa_s, int error_code)
misc_utils::charBufToString(wpa_s->ifname),
std::bind(
&ISupplicantStaIfaceCallback::onEapFailure,
std::placeholders::_1, std::vector<uint8_t>(), error_code));
std::placeholders::_1,
macAddrToVec(wpa_s->bssid), error_code));
}
/**
@@ -1967,6 +1968,22 @@ void AidlManager::notifyCertification(struct wpa_supplicant *wpa_s,
misc_utils::charBufToString(wpa_s->ifname), current_ssid->id, func);
}
void AidlManager::notifyAuxiliaryEvent(struct wpa_supplicant *wpa_s,
AuxiliarySupplicantEventCode event_code, const char *reason_string)
{
if (!wpa_s)
return;
const std::function<
ndk::ScopedAStatus(std::shared_ptr<ISupplicantStaIfaceCallback>)>
func = std::bind(
&ISupplicantStaIfaceCallback::onAuxiliarySupplicantEvent,
std::placeholders::_1, event_code, macAddrToVec(wpa_s->bssid),
misc_utils::charBufToString(reason_string));
callWithEachStaIfaceCallback(
misc_utils::charBufToString(wpa_s->ifname), func);
}
/**
* Retrieve the |ISupplicantP2pIface| aidl object reference using the provided
* ifname.

View File

@@ -150,6 +150,9 @@ public:
int num_altsubject,
const char *cert_hash,
const struct wpabuf *cert);
void notifyAuxiliaryEvent(struct wpa_supplicant *wpa_s,
AuxiliarySupplicantEventCode event_code,
const char *reason_string);
// Methods called from aidl objects.
void notifyExtRadioWorkStart(struct wpa_supplicant *wpa_s, uint32_t id);

View File

@@ -1287,3 +1287,20 @@ void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
#endif /* CONFIG_INTERWORKING */
void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
const char* reason_string)
{
wpas_aidl_notify_eap_method_selected(wpa_s, reason_string);
}
void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
const char *reason_string)
{
wpas_aidl_notify_ssid_temp_disabled(wpa_s, reason_string);
}
void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
const char *reason_string)
{
wpas_aidl_notify_open_ssl_failure(wpa_s, reason_string);
}

View File

@@ -208,5 +208,11 @@ void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
const char *type, int bh, int bss_load,
int conn_capab);
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s);
void wpas_notify_eap_method_selected(struct wpa_supplicant *wpa_s,
const char* reason_string);
void wpas_notify_ssid_temp_disabled(struct wpa_supplicant *wpa_s,
const char *reason_string);
void wpas_notify_open_ssl_failure(struct wpa_supplicant *wpa_s,
const char *reason_string);
#endif /* NOTIFY_H */

View File

@@ -8145,6 +8145,17 @@ void wpas_auth_failed(struct wpa_supplicant *wpa_s, char *reason)
"id=%d ssid=\"%s\" auth_failures=%u duration=%d reason=%s",
ssid->id, wpa_ssid_txt(ssid->ssid, ssid->ssid_len),
ssid->auth_failures, dur, reason);
char *format_str = "id=%d ssid=\"%s\" auth_failures=%u duration=%d reason=%s";
int msg_len = snprintf(NULL, 0, format_str,
ssid->id, wpa_ssid_txt(ssid->ssid, ssid->ssid_len),
ssid->auth_failures, dur, reason) + 1;
char *msg = os_malloc(msg_len);
snprintf(msg, msg_len, format_str,
ssid->id, wpa_ssid_txt(ssid->ssid, ssid->ssid_len),
ssid->auth_failures, dur, reason);
wpas_notify_ssid_temp_disabled(wpa_s, msg);
os_free(msg);
}

View File

@@ -1159,6 +1159,22 @@ static void wpa_supplicant_set_anon_id(void *ctx, const u8 *id, size_t len)
}
}
}
static void wpa_supplicant_eap_method_selected_cb(void *ctx,
const char* reason_string)
{
struct wpa_supplicant *wpa_s = ctx;
wpas_notify_eap_method_selected(wpa_s, reason_string);
}
static void wpa_supplicant_open_ssl_failure_cb(void *ctx,
const char* reason_string)
{
struct wpa_supplicant *wpa_s = ctx;
wpas_notify_open_ssl_failure(wpa_s, reason_string);
}
#endif /* IEEE8021X_EAPOL */
@@ -1205,6 +1221,8 @@ int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
ctx->eap_error_cb = wpa_supplicant_eap_error_cb;
ctx->confirm_auth_cb = wpa_supplicant_eap_auth_start_cb;
ctx->set_anon_id = wpa_supplicant_set_anon_id;
ctx->eap_method_selected_cb = wpa_supplicant_eap_method_selected_cb;
ctx->open_ssl_failure_cb = wpa_supplicant_open_ssl_failure_cb;
ctx->cb_ctx = wpa_s;
wpa_s->eapol = eapol_sm_init(ctx);
if (wpa_s->eapol == NULL) {