Add EAPOL authenticator event callback

This avoids direct calls to WPA authenticator from eapol_sm.c.
This commit is contained in:
Jouni Malinen 2009-11-29 19:31:50 +02:00
parent c02d52b405
commit 382942004f
3 changed files with 27 additions and 3 deletions

View File

@ -18,7 +18,6 @@
#include "eapol_sm.h"
#include "eloop.h"
#include "common/eapol_common.h"
#include "wpa.h"
#include "sta_info.h"
#include "eap_server/eap.h"
#include "state_machine.h"
@ -611,7 +610,8 @@ SM_STATE(REAUTH_TIMER, REAUTHENTICATE)
SM_ENTRY_MA(REAUTH_TIMER, REAUTHENTICATE, reauth_timer);
sm->reAuthenticate = TRUE;
wpa_auth_sm_event(sm->sta->wpa_sm, WPA_REAUTH_EAPOL);
sm->eapol->cb.eapol_event(sm->hapd, sm->sta,
EAPOL_AUTH_REAUTHENTICATE);
}
@ -935,7 +935,8 @@ restart:
}
if (eapol_sm_sta_entry_alive(eapol, addr))
wpa_auth_sm_notify(sm->sta->wpa_sm);
sm->eapol->cb.eapol_event(sm->hapd, sm->sta,
EAPOL_AUTH_SM_CHANGE);
}

View File

@ -63,6 +63,11 @@ typedef enum {
EAPOL_LOGGER_DEBUG, EAPOL_LOGGER_INFO, EAPOL_LOGGER_WARNING
} eapol_logger_level;
enum eapol_event {
EAPOL_AUTH_SM_CHANGE,
EAPOL_AUTH_REAUTHENTICATE
};
struct eapol_auth_cb {
void (*eapol_send)(void *ctx, void *sta_ctx, u8 type, const u8 *data,
size_t datalen);
@ -77,6 +82,7 @@ struct eapol_auth_cb {
void (*set_port_authorized)(void *ctx, void *sta_ctx, int authorized);
void (*abort_auth)(void *ctx, void *sta_ctx);
void (*tx_key)(void *ctx, void *sta_ctx);
void (*eapol_event)(void *ctx, void *sta_ctx, enum eapol_event type);
};
/**

View File

@ -1642,6 +1642,22 @@ static void _ieee802_1x_tx_key(void *ctx, void *sta_ctx)
}
static void ieee802_1x_eapol_event(void *ctx, void *sta_ctx,
enum eapol_event type)
{
/* struct hostapd_data *hapd = ctx; */
struct sta_info *sta = sta_ctx;
switch (type) {
case EAPOL_AUTH_SM_CHANGE:
wpa_auth_sm_notify(sta->wpa_sm);
break;
case EAPOL_AUTH_REAUTHENTICATE:
wpa_auth_sm_event(sta->wpa_sm, WPA_REAUTH_EAPOL);
break;
}
}
int ieee802_1x_init(struct hostapd_data *hapd)
{
int i;
@ -1679,6 +1695,7 @@ int ieee802_1x_init(struct hostapd_data *hapd)
cb.set_port_authorized = ieee802_1x_set_port_authorized;
cb.abort_auth = _ieee802_1x_abort_auth;
cb.tx_key = _ieee802_1x_tx_key;
cb.eapol_event = ieee802_1x_eapol_event;
hapd->eapol_auth = eapol_auth_init(&conf, &cb);
if (hapd->eapol_auth == NULL)