eapol: Add eapol_sm_set_require_handshake

Function to allow netdev.c to explicitly tell eapol.c whether to expect
EAP / 4-Way handshake.  This is to potentially make the code more
descriptive, until now we'd look at sm->handshake->ptk_complete to see
if a new PTK was needed.

A 4-Way handshake is required on  association to an AP except after FT.
This commit is contained in:
Andrew Zaborowski 2017-08-18 14:22:55 +02:00 committed by Denis Kenzior
parent 14dcda4d59
commit 23af935e7b
3 changed files with 14 additions and 2 deletions

View File

@ -731,6 +731,7 @@ struct eapol_sm {
bool have_replay:1;
bool started:1;
bool use_eapol_start:1;
bool require_handshake:1;
bool eap_exchanged:1;
struct eap_state *eap;
struct eapol_buffer *early_frame;
@ -764,6 +765,8 @@ struct eapol_sm *eapol_sm_new(struct handshake_state *hs)
if (hs->settings_8021x)
sm->use_eapol_start = true;
sm->require_handshake = true;
return sm;
}
@ -1531,6 +1534,14 @@ void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled)
sm->use_eapol_start = enabled;
}
void eapol_sm_set_require_handshake(struct eapol_sm *sm, bool enabled)
{
sm->require_handshake = enabled;
if (!sm->require_handshake)
sm->use_eapol_start = false;
}
static void eapol_rx_packet(struct eapol_sm *sm,
const uint8_t *frame, size_t len)
{
@ -1651,7 +1662,7 @@ void eapol_register(struct eapol_sm *sm)
void eapol_start(struct eapol_sm *sm)
{
if (!sm->handshake->ptk_complete && !sm->handshake->have_snonce)
if (sm->require_handshake)
sm->timeout = l_timeout_create(2, eapol_timeout, sm, NULL);
sm->started = true;

View File

@ -180,6 +180,7 @@ void eapol_sm_set_protocol_version(struct eapol_sm *sm,
enum eapol_protocol_version protocol_version);
void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled);
void eapol_sm_set_require_handshake(struct eapol_sm *sm, bool enabled);
void eapol_sm_set_user_data(struct eapol_sm *sm, void *user_data);
void eapol_sm_set_event_func(struct eapol_sm *sm, eapol_sm_event_func_t func);

View File

@ -2414,7 +2414,7 @@ int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
eapol_sm_free(netdev->sm);
netdev->sm = eapol_sm_new(netdev->handshake);
eapol_sm_set_use_eapol_start(netdev->sm, false);
eapol_sm_set_require_handshake(netdev->sm, false);
}
netdev->operational = false;