mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 23:09:34 +01:00
peap: handle receive for phase two data
This commit is contained in:
parent
487c5cbafc
commit
93d0dac77b
@ -61,6 +61,12 @@ enum peap_flag {
|
|||||||
PEAP_FLAG_L = 0x80,
|
PEAP_FLAG_L = 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct databuf {
|
||||||
|
uint8_t *data;
|
||||||
|
size_t len;
|
||||||
|
size_t capacity;
|
||||||
|
};
|
||||||
|
|
||||||
struct eap_peap_state {
|
struct eap_peap_state {
|
||||||
enum peap_version version;
|
enum peap_version version;
|
||||||
struct l_tls *tunnel;
|
struct l_tls *tunnel;
|
||||||
@ -68,6 +74,8 @@ struct eap_peap_state {
|
|||||||
uint8_t *tx_pdu_buf;
|
uint8_t *tx_pdu_buf;
|
||||||
size_t tx_pdu_buf_len;
|
size_t tx_pdu_buf_len;
|
||||||
|
|
||||||
|
struct databuf *plain_buf;
|
||||||
|
|
||||||
uint8_t *rx_pdu_buf;
|
uint8_t *rx_pdu_buf;
|
||||||
size_t rx_pdu_buf_len;
|
size_t rx_pdu_buf_len;
|
||||||
size_t rx_pdu_buf_offset;
|
size_t rx_pdu_buf_offset;
|
||||||
@ -83,6 +91,49 @@ struct eap_peap_state {
|
|||||||
char *passphrase;
|
char *passphrase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct databuf *databuf_new(size_t capacity)
|
||||||
|
{
|
||||||
|
struct databuf *databuf;
|
||||||
|
|
||||||
|
if (!capacity)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
databuf = l_new(struct databuf, 1);
|
||||||
|
databuf->data = l_malloc(capacity);
|
||||||
|
databuf->capacity = capacity;
|
||||||
|
|
||||||
|
return databuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void databuf_append(struct databuf *databuf, const uint8_t *data,
|
||||||
|
size_t data_len)
|
||||||
|
{
|
||||||
|
size_t new_len;
|
||||||
|
|
||||||
|
if (!databuf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
new_len = databuf->len + data_len;
|
||||||
|
|
||||||
|
if (new_len > databuf->capacity) {
|
||||||
|
databuf->capacity = new_len * 2;
|
||||||
|
databuf->data = l_realloc(databuf->data, databuf->capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(databuf->data + databuf->len, data, data_len);
|
||||||
|
|
||||||
|
databuf->len = new_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void databuf_free(struct databuf *databuf)
|
||||||
|
{
|
||||||
|
if (!databuf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
l_free(databuf->data);
|
||||||
|
l_free(databuf);
|
||||||
|
}
|
||||||
|
|
||||||
static void eap_peap_free_tx_buffer(struct eap_state *eap)
|
static void eap_peap_free_tx_buffer(struct eap_state *eap)
|
||||||
{
|
{
|
||||||
struct eap_peap_state *peap = eap_get_data(eap);
|
struct eap_peap_state *peap = eap_get_data(eap);
|
||||||
@ -119,6 +170,11 @@ static void eap_peap_free(struct eap_state *eap)
|
|||||||
|
|
||||||
eap_peap_free_tx_buffer(eap);
|
eap_peap_free_tx_buffer(eap);
|
||||||
|
|
||||||
|
if (peap->plain_buf) {
|
||||||
|
databuf_free(peap->plain_buf);
|
||||||
|
peap->plain_buf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
eap_peap_free_rx_buffer(eap);
|
eap_peap_free_rx_buffer(eap);
|
||||||
|
|
||||||
eap_set_data(eap, NULL);
|
eap_set_data(eap, NULL);
|
||||||
@ -199,6 +255,13 @@ static void eap_peap_tunnel_data_send(const uint8_t *data, size_t data_len,
|
|||||||
static void eap_peap_tunnel_data_received(const uint8_t *data, size_t data_len,
|
static void eap_peap_tunnel_data_received(const uint8_t *data, size_t data_len,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
|
struct eap_state *eap = user_data;
|
||||||
|
struct eap_peap_state *peap = eap_get_data(eap);
|
||||||
|
|
||||||
|
if (!peap->plain_buf)
|
||||||
|
peap->plain_buf = databuf_new(data_len);
|
||||||
|
|
||||||
|
databuf_append(peap->plain_buf, data, data_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eap_peap_tunnel_ready(const char *peer_identity, void *user_data)
|
static void eap_peap_tunnel_ready(const char *peer_identity, void *user_data)
|
||||||
|
Loading…
Reference in New Issue
Block a user