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:
parent
0cccbea904
commit
dcf419ee7f
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
25
src/wsc.c
25
src/wsc.c
@ -363,17 +363,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
static void wsc_netdev_event(struct netdev *netdev, enum netdev_event event,
|
||||
void *event_data, void *user_data)
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user