From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH v2 3/6] netdev: separate over-air and over-ds netdev APIs
Date: Thu, 29 Apr 2021 12:41:00 -0700 [thread overview]
Message-ID: <20210429194103.207447-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20210429194103.207447-1-prestwoj@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3867 bytes --]
---
src/netdev.c | 68 ++++++++++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 29 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
index 25891092..232d098d 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -3658,10 +3658,25 @@ static void prepare_ft(struct netdev *netdev, struct scan_bss *target_bss)
{
struct netdev_handshake_state *nhs;
+ /*
+ * We reuse the handshake_state object and reset what's needed.
+ * Could also create a new object and copy most of the state but
+ * we would end up doing more work.
+ */
+ memcpy(netdev->prev_snonce, netdev->handshake->snonce, 32);
+
memcpy(netdev->prev_bssid, netdev->handshake->aa, 6);
netdev->prev_frequency = netdev->frequency;
netdev->frequency = target_bss->frequency;
+ handshake_state_set_authenticator_address(netdev->handshake,
+ target_bss->addr);
+
+ if (target_bss->rsne)
+ handshake_state_set_authenticator_ie(netdev->handshake,
+ target_bss->rsne);
+ memcpy(netdev->handshake->mde + 2, target_bss->mde, 3);
+
netdev->associated = false;
netdev->operational = false;
netdev->in_ft = true;
@@ -3809,8 +3824,7 @@ static const struct wiphy_radio_work_item_ops ft_work_ops = {
.do_work = netdev_ft_work_ready,
};
-static int fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
- bool over_air,
+int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
netdev_connect_cb_t cb)
{
if (!netdev->operational)
@@ -3823,32 +3837,13 @@ static int fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
prepare_ft(netdev, target_bss);
- /*
- * We reuse the handshake_state object and reset what's needed.
- * Could also create a new object and copy most of the state but
- * we would end up doing more work.
- */
- memcpy(netdev->prev_snonce, netdev->handshake->snonce, 32);
handshake_state_new_snonce(netdev->handshake);
- handshake_state_set_authenticator_address(netdev->handshake,
- target_bss->addr);
-
- if (target_bss->rsne)
- handshake_state_set_authenticator_ie(netdev->handshake,
- target_bss->rsne);
- memcpy(netdev->handshake->mde + 2, target_bss->mde, 3);
-
netdev->connect_cb = cb;
- if (over_air)
- netdev->ap = ft_over_air_sm_new(netdev->handshake,
+ netdev->ap = ft_over_air_sm_new(netdev->handshake,
netdev_ft_tx_authenticate,
netdev_ft_tx_associate, netdev);
- else
- netdev->ap = ft_over_ds_sm_new(netdev->handshake,
- netdev_ft_over_ds_tx_authenticate,
- netdev_ft_tx_associate, netdev);
wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
&ft_work_ops);
@@ -3856,17 +3851,32 @@ static int fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
return 0;
}
-int netdev_fast_transition(struct netdev *netdev, struct scan_bss *target_bss,
- netdev_connect_cb_t cb)
-{
- return fast_transition(netdev, target_bss, true, cb);
-}
-
int netdev_fast_transition_over_ds(struct netdev *netdev,
struct scan_bss *target_bss,
netdev_connect_cb_t cb)
{
- return fast_transition(netdev, target_bss, false, cb);
+ if (!netdev->operational)
+ return -ENOTCONN;
+
+ if (!netdev->handshake->mde || !target_bss->mde_present ||
+ l_get_le16(netdev->handshake->mde + 2) !=
+ l_get_le16(target_bss->mde))
+ return -EINVAL;
+
+ prepare_ft(netdev, target_bss);
+
+ handshake_state_new_snonce(netdev->handshake);
+
+ netdev->connect_cb = cb;
+
+ netdev->ap = ft_over_ds_sm_new(netdev->handshake,
+ netdev_ft_over_ds_tx_authenticate,
+ netdev_ft_tx_associate, netdev);
+
+ wiphy_radio_work_insert(netdev->wiphy, &netdev->work, 1,
+ &ft_work_ops);
+
+ return 0;
}
static void netdev_preauth_cb(const uint8_t *pmk, void *user_data)
--
2.26.2
next prev parent reply other threads:[~2021-04-29 19:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 19:40 [PATCH v2 1/6] ft: create class for FT-over-DS targets James Prestwood
2021-04-29 19:40 ` [PATCH v2 2/6] ft: separate over-air from over-ds initializers James Prestwood
2021-04-29 19:41 ` James Prestwood [this message]
2021-04-29 19:41 ` [PATCH v2 4/6] ft: netdev: refactor FT-over-DS into two stages James Prestwood
2021-04-29 20:33 ` Denis Kenzior
2021-04-29 19:41 ` [PATCH v2 5/6] station: separate FT-over-DS stages James Prestwood
2021-04-29 19:41 ` [PATCH v2 6/6] ft: netdev: add return value to tx_associate James Prestwood
2021-04-29 20:23 ` [PATCH v2 1/6] ft: create class for FT-over-DS targets Denis Kenzior
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=20210429194103.207447-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox