3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

ftutil: add associate parser

Helper to obtain RSNE, MDE, and FTE from associate frame.
This commit is contained in:
James Prestwood 2019-03-05 09:12:30 -08:00 committed by Denis Kenzior
parent 210b8645b7
commit 5027bd3d0b
2 changed files with 52 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include "src/handshake.h"
#include "src/crypto.h"
#include "src/ftutil.h"
#include "src/mpdu.h"
/*
* Calculate the MIC field of the FTE and write it directly to that FTE,
@ -140,3 +141,50 @@ bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len,
return true;
}
bool ft_parse_associate_resp_frame(const uint8_t *frame, size_t frame_len,
uint16_t *out_status, const uint8_t **rsne,
const uint8_t **mde, const uint8_t **fte)
{
const struct mmpdu_header *mpdu;
const struct mmpdu_association_response *body;
struct ie_tlv_iter iter;
mpdu = mpdu_validate(frame, frame_len);
if (!mpdu)
return false;
body = mmpdu_body(mpdu);
ie_tlv_iter_init(&iter, body->ies, (const uint8_t *) mpdu + frame_len -
body->ies);
while (ie_tlv_iter_next(&iter)) {
switch (ie_tlv_iter_get_tag(&iter)) {
case IE_TYPE_RSN:
if (*rsne)
return false;
*rsne = ie_tlv_iter_get_data(&iter) - 2;
break;
case IE_TYPE_MOBILITY_DOMAIN:
if (*mde)
return false;
*mde = ie_tlv_iter_get_data(&iter) - 2;
break;
case IE_TYPE_FAST_BSS_TRANSITION:
if (*fte)
return false;
*fte = ie_tlv_iter_get_data(&iter) - 2;
break;
}
}
*out_status = body->status_code;
return true;
}

View File

@ -33,3 +33,7 @@ bool ft_parse_authentication_resp_frame(const uint8_t *data, size_t len,
const uint8_t *addr3, uint16_t auth_seq,
uint16_t *out_status, const uint8_t **out_ies,
size_t *out_ies_len);
bool ft_parse_associate_resp_frame(const uint8_t *frame, size_t frame_len,
uint16_t *out_status, const uint8_t **rsne,
const uint8_t **mde, const uint8_t **fte);