commit dcf419ee7f0a08fad04cede3f07f2215be59b170
parent 0cccbea9047f85c5123acc8dafeb5620d70b7104
Author: Andrew Zaborowski <andrew.zaborowski@intel.com>
Date: Mon, 28 Oct 2019 15:05:00 +0100
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.
Diffstat:
4 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/src/eapol.c b/src/eapol.c
@@ -2167,10 +2167,8 @@ static void eapol_eap_event_cb(unsigned int event,
{
struct eapol_sm *sm = user_data;
- if (!sm->event_func)
- return;
-
- sm->event_func(event, event_data, sm->user_data);
+ handshake_event(sm->handshake, HANDSHAKE_EVENT_EAP_NOTIFY, event,
+ event_data);
}
void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled)
diff --git a/src/handshake.h b/src/handshake.h
@@ -50,6 +50,7 @@ enum handshake_event {
HANDSHAKE_EVENT_COMPLETE,
HANDSHAKE_EVENT_FAILED,
HANDSHAKE_EVENT_REKEY_FAILED,
+ HANDSHAKE_EVENT_EAP_NOTIFY,
};
typedef void (*handshake_event_func_t)(struct handshake_state *hs,
diff --git a/src/station.c b/src/station.c
@@ -676,6 +676,7 @@ static void station_handshake_event(struct handshake_state *hs,
break;
case HANDSHAKE_EVENT_COMPLETE:
case HANDSHAKE_EVENT_SETTING_KEYS_FAILED:
+ case HANDSHAKE_EVENT_EAP_NOTIFY:
/*
* currently we dont care about any other events. The
* netdev_connect_cb will notify us when the connection is
diff --git a/src/wsc.c b/src/wsc.c
@@ -363,16 +363,7 @@ static void wsc_credential_obtained(struct wsc *wsc,
static void wsc_eapol_event(uint32_t event, const void *event_data,
void *user_data)
{
- struct wsc *wsc = user_data;
-
- 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);
- }
+ l_debug("Got event: %d", 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,
...)
{
+ struct wsc *wsc = user_data;
va_list args;
va_start(args, user_data);
@@ -413,6 +405,21 @@ static void wsc_handshake_event(struct handshake_state *hs,
case HANDSHAKE_EVENT_FAILED:
netdev_handshake_failed(hs, va_arg(args, int));
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:
break;
}