mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-18 00:30:47 +01:00
eap: Add retransmission support
This commit is contained in:
parent
32d623a09e
commit
bd9e1883ee
31
src/eap.c
31
src/eap.c
@ -173,17 +173,25 @@ static void eap_send_identity_response(struct eap_state *eap, char *identity)
|
|||||||
eap_send_response(eap, EAP_TYPE_IDENTITY, buf, len + 5);
|
eap_send_response(eap, EAP_TYPE_IDENTITY, buf, len + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eap_handle_request(struct eap_state *eap,
|
static void eap_handle_request(struct eap_state *eap, uint16_t id,
|
||||||
const uint8_t *pkt, size_t len)
|
const uint8_t *pkt, size_t len)
|
||||||
{
|
{
|
||||||
enum eap_type type;
|
enum eap_type type;
|
||||||
uint8_t buf[10];
|
uint8_t buf[10];
|
||||||
int buf_len;
|
int buf_len;
|
||||||
|
void (*op)(struct eap_state *eap,
|
||||||
|
const uint8_t *pkt, size_t len);
|
||||||
|
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
/* Invalid packets to be ignored */
|
/* Invalid packets to be ignored */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (id == eap->last_id)
|
||||||
|
op = eap->method->handle_retransmit;
|
||||||
|
else
|
||||||
|
op = eap->method->handle_request;
|
||||||
|
|
||||||
|
eap->last_id = id;
|
||||||
type = pkt[0];
|
type = pkt[0];
|
||||||
|
|
||||||
if (type >= __EAP_TYPE_MIN_METHOD) {
|
if (type >= __EAP_TYPE_MIN_METHOD) {
|
||||||
@ -196,7 +204,7 @@ static void eap_handle_request(struct eap_state *eap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != EAP_TYPE_EXPANDED) {
|
if (type != EAP_TYPE_EXPANDED) {
|
||||||
eap->method->handle_request(eap, pkt + 1, len - 1);
|
op(eap, pkt + 1, len - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +215,7 @@ static void eap_handle_request(struct eap_state *eap,
|
|||||||
if (len < 8)
|
if (len < 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eap->method->handle_request(eap, pkt + 8, len - 8);
|
op(eap, pkt + 8, len - 8);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,22 +274,7 @@ void eap_rx_packet(struct eap_state *eap, const uint8_t *pkt, size_t len)
|
|||||||
|
|
||||||
switch ((enum eap_code) code) {
|
switch ((enum eap_code) code) {
|
||||||
case EAP_CODE_REQUEST:
|
case EAP_CODE_REQUEST:
|
||||||
if (id == eap->last_id) {
|
eap_handle_request(eap, id, pkt + 4, eap_len - 4);
|
||||||
/*
|
|
||||||
* We should resend the last response if this ever
|
|
||||||
* happens and if one was sent already. This can
|
|
||||||
* happen if the request_credentials callback needs
|
|
||||||
* to wait for user input. We can assume a reliable
|
|
||||||
* lower layer but the retransmission behaviour is
|
|
||||||
* decided by the authenticator (Section 4.3).
|
|
||||||
*/
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
eap->last_id = id;
|
|
||||||
|
|
||||||
eap_handle_request(eap, pkt + 4, eap_len - 4);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EAP_CODE_FAILURE:
|
case EAP_CODE_FAILURE:
|
||||||
|
@ -98,6 +98,8 @@ struct eap_method {
|
|||||||
|
|
||||||
void (*handle_request)(struct eap_state *eap,
|
void (*handle_request)(struct eap_state *eap,
|
||||||
const uint8_t *pkt, size_t len);
|
const uint8_t *pkt, size_t len);
|
||||||
|
void (*handle_retransmit)(struct eap_state *eap,
|
||||||
|
const uint8_t *pkt, size_t len);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct eap_method_desc {
|
struct eap_method_desc {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user