From: James Prestwood <prestwoj at gmail.com>
To: iwd at lists.01.org
Subject: [PATCH 5/5] dpp: handle CHANNEL attribute in auth request
Date: Fri, 07 Jan 2022 14:31:12 -0800 [thread overview]
Message-ID: <20220107223112.715855-5-prestwoj@gmail.com> (raw)
In-Reply-To: 20220107223112.715855-1-prestwoj@gmail.com
[-- Attachment #1: Type: text/plain, Size: 4110 bytes --]
When this attribute is included, the initiator is requesting all
future frames be sent on this channel. There is no reason for a
configurator to act on this attribute (at least for now) so the
request frame will be dropped in this case. Enrollees will act
on it by switching to the new channel and sending the authentication
response.
---
src/dpp.c | 77 +++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 58 insertions(+), 19 deletions(-)
diff --git a/src/dpp.c b/src/dpp.c
index 68a7d2bf..86f040e7 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -91,6 +91,7 @@ struct dpp_sm {
size_t freqs_idx;
uint32_t dwell;
uint32_t current_freq;
+ uint32_t new_freq;
struct scan_freq_set *presence_list;
uint32_t offchannel_id;
@@ -169,6 +170,7 @@ static void dpp_reset(struct dpp_sm *dpp)
}
dpp->state = DPP_STATE_NOTHING;
+ dpp->new_freq = 0;
explicit_bzero(dpp->r_nonce, dpp->nonce_len);
explicit_bzero(dpp->i_nonce, dpp->nonce_len);
@@ -1237,14 +1239,29 @@ static void dpp_roc_started(void *user_data)
struct dpp_sm *dpp = user_data;
/*
- * If not in presence procedure or in a configurator role, just stay
- * on channel.
+ * - If a configurator, nothing to do but wait for a request
+ * - If in the presence state continue sending announcements.
+ * - If authenticating, and this is a result of a channel switch send
+ * the authenticate response now.
*/
- if (dpp->state != DPP_STATE_PRESENCE ||
- dpp->role == DPP_CAPABILITY_CONFIGURATOR)
+ if (dpp->role == DPP_CAPABILITY_CONFIGURATOR)
return;
- dpp_presence_announce(dpp);
+ switch (dpp->state) {
+ case DPP_STATE_PRESENCE:
+ dpp_presence_announce(dpp);
+ break;
+ case DPP_STATE_AUTHENTICATING:
+ if (dpp->new_freq) {
+ dpp->current_freq = dpp->new_freq;
+ dpp->new_freq = 0;
+ send_authenticate_response(dpp);
+ }
+
+ break;
+ default:
+ break;
+ }
}
static void dpp_start_offchannel(struct dpp_sm *dpp, uint32_t freq);
@@ -1331,6 +1348,7 @@ static void authenticate_request(struct dpp_sm *dpp, const uint8_t *from,
uint64_t k1[L_ECC_MAX_DIGITS];
const void *ad0 = body + 2;
const void *ad1 = body + 8;
+ uint32_t freq;
if (dpp->state != DPP_STATE_PRESENCE)
return;
@@ -1370,20 +1388,39 @@ static void authenticate_request(struct dpp_sm *dpp, const uint8_t *from,
}
break;
- /*
- * TODO: Go on this channel for remainder of auth protocol.
- *
- * "the Responder determines whether it can use the requested
- * channel for the following exchanges. If so, it sends the DPP
- * Authentication Response frame on that channel. If not, it
- * discards the DPP Authentication Request frame without
- * replying to it."
- *
- * For the time being this feature is not being implemented and
- * the frame will be dropped.
- */
+
case DPP_ATTR_CHANNEL:
- return;
+ if (len != 2)
+ return;
+
+ freq = oci_to_frequency(l_get_u8(data),
+ l_get_u8(data + 1));
+
+ if (freq == dpp->current_freq)
+ break;
+
+ /*
+ * Configurators are already connected to a network, so
+ * to preserve wireless performance the enrollee will
+ * be required to be on this channel, not a channel it
+ * requests.
+ */
+ if (dpp->role == DPP_CAPABILITY_CONFIGURATOR)
+ return;
+
+ /*
+ * Otherwise, as an enrollee, we can jump to whatever
+ * channel the configurator requests
+ */
+ dpp->new_freq = freq;
+
+ l_debug("Configurator requested a new frequency %u",
+ dpp->new_freq);
+
+ offchannel_cancel(dpp->wdev_id, dpp->offchannel_id);
+ dpp_start_offchannel(dpp, dpp->new_freq);
+
+ break;
default:
break;
}
@@ -1477,7 +1514,9 @@ static void authenticate_request(struct dpp_sm *dpp, const uint8_t *from,
dpp->state = DPP_STATE_AUTHENTICATING;
dpp_reset_protocol_timer(dpp);
- send_authenticate_response(dpp);
+ /* Don't send if the frequency is changing */
+ if (!dpp->new_freq)
+ send_authenticate_response(dpp);
return;
--
2.31.1
reply other threads:[~2022-01-07 22:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220107223112.715855-5-prestwoj@gmail.com \
--to=iwd@lists.linux.dev \
/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