ft: break up FT action parsing into two steps

This is to prepare for multiple concurrent FT-over-DS action frames.
A list will be kept in netdev and for lookup reasons it needs to
parse the start of the frame to grab the aa/spa addresses. In this
call the IEs are also returned and passed to the new
ft_over_ds_parse_action_response.

For now the address checks have been moved into netdev, but this will
eventually turn into a queue lookup.
This commit is contained in:
James Prestwood 2021-05-12 16:01:40 -07:00 committed by Denis Kenzior
parent 80712face4
commit ff333a112b
3 changed files with 44 additions and 14 deletions

View File

@ -452,7 +452,7 @@ static bool mde_equal(const uint8_t *mde1, const uint8_t *mde2)
return memcmp(mde1, mde1, mde1[1] + 2) == 0;
}
static bool ft_over_ds_process_ies(struct ft_ds_info *info,
bool ft_over_ds_parse_action_ies(struct ft_ds_info *info,
struct handshake_state *hs,
const uint8_t *ies,
size_t ies_len)
@ -523,11 +523,15 @@ ft_error:
return -EBADMSG;
}
int ft_over_ds_parse_action_response(struct ft_ds_info *info,
struct handshake_state *hs,
const uint8_t *frame, size_t frame_len)
int ft_over_ds_parse_action_response(const uint8_t *frame, size_t frame_len,
const uint8_t **spa_out,
const uint8_t **aa_out,
const uint8_t **ies_out,
size_t *ies_len)
{
uint16_t status;
const uint8_t *aa;
const uint8_t *spa;
if (frame_len < 16)
return -EINVAL;
@ -540,17 +544,23 @@ int ft_over_ds_parse_action_response(struct ft_ds_info *info,
if (frame[1] != 2)
return -EINVAL;
if (memcmp(frame + 2, info->spa, 6))
return -ENOENT;
if (memcmp(frame + 8, info->aa, 6))
return -ENOENT;
spa = frame + 2;
aa = frame + 8;
status = l_get_le16(frame + 14);
if (status != 0)
return (int)status;
if (!ft_over_ds_process_ies(info, hs, frame + 16, frame_len - 16))
return -EBADMSG;
if (spa_out)
*spa_out = spa;
if (aa_out)
*aa_out = aa;
if (ies_out && ies_len) {
*ies_out = frame + 16;
*ies_len = frame_len - 16;
}
return 0;
}

View File

@ -47,9 +47,15 @@ bool ft_build_authenticate_ies(struct handshake_state *hs,
const uint8_t *new_snonce, uint8_t *buf,
size_t *len);
int ft_over_ds_parse_action_response(struct ft_ds_info *info,
int ft_over_ds_parse_action_response(const uint8_t *frame, size_t frame_len,
const uint8_t **spa_out,
const uint8_t **aa_out,
const uint8_t **ies_out,
size_t *ies_len);
bool ft_over_ds_parse_action_ies(struct ft_ds_info *info,
struct handshake_state *hs,
const uint8_t *frame, size_t frame_len);
const uint8_t *ies,
size_t ies_len);
struct auth_proto *ft_over_air_sm_new(struct handshake_state *hs,
ft_tx_authenticate_func_t tx_auth,

View File

@ -3774,12 +3774,26 @@ static void netdev_ft_response_frame_event(const struct mmpdu_header *hdr,
struct netdev_ft_over_ds_info *info = netdev->ft_ds_info;
int ret;
uint16_t status_code = MMPDU_STATUS_CODE_UNSPECIFIED;
const uint8_t *aa;
const uint8_t *spa;
const uint8_t *ies;
size_t ies_len;
if (!info)
return;
ret = ft_over_ds_parse_action_response(&info->super, netdev->handshake,
body, body_len);
ret = ft_over_ds_parse_action_response(body, body_len, &spa, &aa,
&ies, &ies_len);
if (ret != 0)
return;
if (memcmp(spa, info->super.spa, 6))
return;
if (memcmp(aa, info->super.aa, 6))
return;
ret = ft_over_ds_parse_action_ies(&info->super, netdev->handshake,
ies, ies_len);
if (ret < 0)
return;