mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
peap: Introduce PEAP state
Introduction of the state struct will allow to hold the additional state variables related to the implementation of PEAP.
This commit is contained in:
parent
f909c6db26
commit
5273a3b581
@ -41,6 +41,10 @@
|
|||||||
* PEAPv1: draft-josefsson-pppext-eap-tls-eap-05
|
* PEAPv1: draft-josefsson-pppext-eap-tls-eap-05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct peap_state {
|
||||||
|
struct eap_state *phase2;
|
||||||
|
};
|
||||||
|
|
||||||
static void eap_peap_phase2_send_response(const uint8_t *pdu, size_t pdu_len,
|
static void eap_peap_phase2_send_response(const uint8_t *pdu, size_t pdu_len,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
@ -116,6 +120,7 @@ static int eap_extensions_handle_result_avp(struct eap_state *eap,
|
|||||||
size_t data_len,
|
size_t data_len,
|
||||||
uint8_t *response)
|
uint8_t *response)
|
||||||
{
|
{
|
||||||
|
struct peap_state *peap_state;
|
||||||
uint16_t type;
|
uint16_t type;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t result;
|
uint16_t result;
|
||||||
@ -143,8 +148,9 @@ static int eap_extensions_handle_result_avp(struct eap_state *eap,
|
|||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case EAP_EXTENSIONS_RESULT_SUCCCESS:
|
case EAP_EXTENSIONS_RESULT_SUCCCESS:
|
||||||
result = eap_method_is_success(
|
peap_state = eap_tls_common_get_variant_data(eap);
|
||||||
eap_tls_common_get_variant_data(eap)) ?
|
|
||||||
|
result = eap_method_is_success(peap_state->phase2) ?
|
||||||
EAP_EXTENSIONS_RESULT_SUCCCESS :
|
EAP_EXTENSIONS_RESULT_SUCCCESS :
|
||||||
EAP_EXTENSIONS_RESULT_FAILURE;
|
EAP_EXTENSIONS_RESULT_FAILURE;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
@ -225,6 +231,7 @@ static bool eap_peap_tunnel_handle_request(struct eap_state *eap,
|
|||||||
const uint8_t *pkt,
|
const uint8_t *pkt,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
|
struct peap_state *peap_state;
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
|
|
||||||
if (len > 4 && pkt[4] == EAP_TYPE_EXTENSIONS) {
|
if (len > 4 && pkt[4] == EAP_TYPE_EXTENSIONS) {
|
||||||
@ -247,6 +254,8 @@ static bool eap_peap_tunnel_handle_request(struct eap_state *eap,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peap_state = eap_tls_common_get_variant_data(eap);
|
||||||
|
|
||||||
if (eap_tls_common_get_negotiated_version(eap) == EAP_TLS_VERSION_0) {
|
if (eap_tls_common_get_negotiated_version(eap) == EAP_TLS_VERSION_0) {
|
||||||
if (len < 1)
|
if (len < 1)
|
||||||
return false;
|
return false;
|
||||||
@ -259,32 +268,37 @@ static bool eap_peap_tunnel_handle_request(struct eap_state *eap,
|
|||||||
*/
|
*/
|
||||||
eap_save_last_id(eap, &id);
|
eap_save_last_id(eap, &id);
|
||||||
|
|
||||||
__eap_handle_request(eap_tls_common_get_variant_data(eap), id,
|
__eap_handle_request(peap_state->phase2, id, pkt, len);
|
||||||
pkt, len);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
eap_rx_packet(eap_tls_common_get_variant_data(eap), pkt, len);
|
eap_rx_packet(peap_state->phase2, pkt, len);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eap_peap_state_reset(void *phase2)
|
static void eap_peap_state_reset(void *variant_data)
|
||||||
{
|
{
|
||||||
if (!phase2)
|
struct peap_state *peap_state = variant_data;
|
||||||
|
|
||||||
|
if (!peap_state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eap_reset(phase2);
|
eap_reset(peap_state->phase2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eap_peap_state_destroy(void *phase2)
|
static void eap_peap_state_destroy(void *variant_data)
|
||||||
{
|
{
|
||||||
if (!phase2)
|
struct peap_state *peap_state = variant_data;
|
||||||
|
|
||||||
|
if (!peap_state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eap_reset(phase2);
|
eap_reset(peap_state->phase2);
|
||||||
eap_free(phase2);
|
eap_free(peap_state->phase2);
|
||||||
|
|
||||||
|
l_free(peap_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eap_peap_settings_check(struct l_settings *settings,
|
static int eap_peap_settings_check(struct l_settings *settings,
|
||||||
@ -323,6 +337,7 @@ static bool eap_peap_settings_load(struct eap_state *eap,
|
|||||||
const char *prefix)
|
const char *prefix)
|
||||||
{
|
{
|
||||||
char setting_key_prefix[72];
|
char setting_key_prefix[72];
|
||||||
|
struct peap_state *peap_state;
|
||||||
void *phase2;
|
void *phase2;
|
||||||
|
|
||||||
phase2 = eap_new(eap_peap_phase2_send_response,
|
phase2 = eap_new(eap_peap_phase2_send_response,
|
||||||
@ -343,11 +358,14 @@ static bool eap_peap_settings_load(struct eap_state *eap,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peap_state = l_new(struct peap_state, 1);
|
||||||
|
peap_state->phase2 = phase2;
|
||||||
|
|
||||||
snprintf(setting_key_prefix, sizeof(setting_key_prefix), "%sPEAP-",
|
snprintf(setting_key_prefix, sizeof(setting_key_prefix), "%sPEAP-",
|
||||||
prefix);
|
prefix);
|
||||||
|
|
||||||
if (!eap_tls_common_settings_load(eap, settings, setting_key_prefix,
|
if (!eap_tls_common_settings_load(eap, settings, setting_key_prefix,
|
||||||
&eap_ttls_ops, phase2))
|
&eap_ttls_ops, peap_state))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user