From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 3/7] ft: break up FT action parsing into two steps
Date: Wed, 12 May 2021 12:21:40 -0700 [thread overview]
Message-ID: <20210512192144.348398-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20210512192144.348398-1-prestwoj@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3951 bytes --]
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.
---
src/ft.c | 30 ++++++++++++++++++++----------
src/ft.h | 10 ++++++++--
src/netdev.c | 18 ++++++++++++++++--
3 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/src/ft.c b/src/ft.c
index de754fd8..13733019 100644
--- a/src/ft.c
+++ b/src/ft.c
@@ -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;
}
diff --git a/src/ft.h b/src/ft.h
index 3d1cfe30..6167e0d7 100644
--- a/src/ft.h
+++ b/src/ft.h
@@ -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,
diff --git a/src/netdev.c b/src/netdev.c
index 9e7fc821..65627b9f 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -3769,12 +3769,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;
--
2.31.1
next prev parent reply other threads:[~2021-05-12 19:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 19:21 [PATCH 1/7] station: factor out logic for choosing FT James Prestwood
2021-05-12 19:21 ` [PATCH 2/7] station: remove ap_directed_roam check for over-DS James Prestwood
2021-05-12 19:21 ` James Prestwood [this message]
2021-05-12 19:21 ` [PATCH 4/7] netdev: handle multiple concurrent FT-over-DS action frames James Prestwood
2021-05-12 19:21 ` [PATCH 5/7] station: send FT-over-DS actions upon connection James Prestwood
2021-05-12 19:21 ` [PATCH 6/7] netdev: remove callback/userdata/timeout from FT-over-DS action James Prestwood
2021-05-12 19:21 ` [PATCH 7/7] auto-t: update FT-over-DS test for new behavior James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210512192144.348398-3-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.