3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 05:39:24 +01:00

eapol: Move the EAP events to handshake event handler

On EAP events, call the handshake_event handler with the new event type
HANDSHAKE_EVENT_EAP_NOTIFY isntead of the eapol_event callback.

This allows the handler to be set before calling
netdev_connect/netdev_connect_wsc.  It's also in theory more type-safe
because we don't need the cast in netdev_connect_wsc anymore.
This commit is contained in:
Andrew Zaborowski 2019-10-28 15:05:00 +01:00 committed by Denis Kenzior
parent 0cccbea904
commit dcf419ee7f
4 changed files with 21 additions and 14 deletions

View File

@ -2167,10 +2167,8 @@ static void eapol_eap_event_cb(unsigned int event,
{ {
struct eapol_sm *sm = user_data; struct eapol_sm *sm = user_data;
if (!sm->event_func) handshake_event(sm->handshake, HANDSHAKE_EVENT_EAP_NOTIFY, event,
return; event_data);
sm->event_func(event, event_data, sm->user_data);
} }
void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled) void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled)

View File

@ -50,6 +50,7 @@ enum handshake_event {
HANDSHAKE_EVENT_COMPLETE, HANDSHAKE_EVENT_COMPLETE,
HANDSHAKE_EVENT_FAILED, HANDSHAKE_EVENT_FAILED,
HANDSHAKE_EVENT_REKEY_FAILED, HANDSHAKE_EVENT_REKEY_FAILED,
HANDSHAKE_EVENT_EAP_NOTIFY,
}; };
typedef void (*handshake_event_func_t)(struct handshake_state *hs, typedef void (*handshake_event_func_t)(struct handshake_state *hs,

View File

@ -676,6 +676,7 @@ static void station_handshake_event(struct handshake_state *hs,
break; break;
case HANDSHAKE_EVENT_COMPLETE: case HANDSHAKE_EVENT_COMPLETE:
case HANDSHAKE_EVENT_SETTING_KEYS_FAILED: case HANDSHAKE_EVENT_SETTING_KEYS_FAILED:
case HANDSHAKE_EVENT_EAP_NOTIFY:
/* /*
* currently we dont care about any other events. The * currently we dont care about any other events. The
* netdev_connect_cb will notify us when the connection is * netdev_connect_cb will notify us when the connection is

View File

@ -363,16 +363,7 @@ static void wsc_credential_obtained(struct wsc *wsc,
static void wsc_eapol_event(uint32_t event, const void *event_data, static void wsc_eapol_event(uint32_t event, const void *event_data,
void *user_data) void *user_data)
{ {
struct wsc *wsc = user_data; l_debug("Got event: %d", event);
switch (event) {
case EAP_WSC_EVENT_CREDENTIAL_OBTAINED:
wsc_credential_obtained(wsc,
(const struct wsc_credential *) event_data);
break;
default:
l_debug("Got event: %d", event);
}
} }
static void wsc_netdev_event(struct netdev *netdev, enum netdev_event event, static void wsc_netdev_event(struct netdev *netdev, enum netdev_event event,
@ -405,6 +396,7 @@ static void wsc_handshake_event(struct handshake_state *hs,
enum handshake_event event, void *user_data, enum handshake_event event, void *user_data,
...) ...)
{ {
struct wsc *wsc = user_data;
va_list args; va_list args;
va_start(args, user_data); va_start(args, user_data);
@ -413,6 +405,21 @@ static void wsc_handshake_event(struct handshake_state *hs,
case HANDSHAKE_EVENT_FAILED: case HANDSHAKE_EVENT_FAILED:
netdev_handshake_failed(hs, va_arg(args, int)); netdev_handshake_failed(hs, va_arg(args, int));
break; break;
case HANDSHAKE_EVENT_EAP_NOTIFY:
{
unsigned int eap_event = va_arg(args, unsigned int);
switch (eap_event) {
case EAP_WSC_EVENT_CREDENTIAL_OBTAINED:
wsc_credential_obtained(wsc,
va_arg(args, const struct wsc_credential *));
break;
default:
l_debug("Got event: %d", eap_event);
}
break;
}
default: default:
break; break;
} }