From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function
Date: Mon, 22 Jul 2024 11:29:28 -0700 [thread overview]
Message-ID: <20240722182932.4091008-1-prestwoj@gmail.com> (raw)
In order to slightly rework the DPP state machine to handle
automatically disconnecting (for enrollees) functions need to be
created that isolate everything needed to start DPP/PKEX in case
a disconnect needs to be done first.
---
src/dpp.c | 64 +++++++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 28 deletions(-)
diff --git a/src/dpp.c b/src/dpp.c
index 567fe8d2..6f05aae9 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -3927,12 +3927,34 @@ static void dpp_start_presence(struct dpp_sm *dpp, uint32_t *limit_freqs,
dpp_start_offchannel(dpp, dpp->current_freq);
}
+static void dpp_start_enrollee(struct dpp_sm *dpp)
+{
+ uint32_t freq = band_channel_to_freq(6, BAND_FREQ_2_4_GHZ);
+
+ dpp->uri = dpp_generate_uri(dpp->own_asn1, dpp->own_asn1_len, 2,
+ netdev_get_address(dpp->netdev), &freq,
+ 1, NULL, NULL);
+
+ l_ecdh_generate_key_pair(dpp->curve, &dpp->proto_private,
+ &dpp->own_proto_public);
+
+ l_debug("DPP Start Enrollee: %s", dpp->uri);
+
+ /*
+ * Going off spec here. Select a single channel to send presence
+ * announcements on. This will be advertised in the URI. The full
+ * presence procedure can be implemented if it is ever needed.
+ */
+ dpp_start_presence(dpp, &freq, 1);
+
+ dpp_property_changed_notify(dpp);
+}
+
static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus,
struct l_dbus_message *message,
void *user_data)
{
struct dpp_sm *dpp = user_data;
- uint32_t freq = band_channel_to_freq(6, BAND_FREQ_2_4_GHZ);
struct station *station = station_find(netdev_get_ifindex(dpp->netdev));
if (dpp->state != DPP_STATE_NOTHING ||
@@ -3949,30 +3971,14 @@ static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus,
} else if (!station)
l_debug("No station device, continuing anyways...");
- dpp->uri = dpp_generate_uri(dpp->own_asn1, dpp->own_asn1_len, 2,
- netdev_get_address(dpp->netdev), &freq,
- 1, NULL, NULL);
-
dpp->state = DPP_STATE_PRESENCE;
dpp->role = DPP_CAPABILITY_ENROLLEE;
dpp->interface = DPP_INTERFACE_DPP;
- l_ecdh_generate_key_pair(dpp->curve, &dpp->proto_private,
- &dpp->own_proto_public);
-
- l_debug("DPP Start Enrollee: %s", dpp->uri);
+ dpp_start_enrollee(dpp);
dpp->pending = l_dbus_message_ref(message);
- /*
- * Going off spec here. Select a single channel to send presence
- * announcements on. This will be advertised in the URI. The full
- * presence procedure can be implemented if it is ever needed.
- */
- dpp_start_presence(dpp, &freq, 1);
-
- dpp_property_changed_notify(dpp);
-
return NULL;
}
@@ -4246,19 +4252,12 @@ static void dpp_pkex_scan_destroy(void *user_data)
dpp->pkex_scan_id = 0;
}
-static bool dpp_start_pkex_enrollee(struct dpp_sm *dpp, const char *key,
- const char *identifier)
+static bool dpp_start_pkex_enrollee(struct dpp_sm *dpp)
{
_auto_(l_ecc_point_free) struct l_ecc_point *qi = NULL;
- if (identifier)
- dpp->pkex_id = l_strdup(identifier);
-
- dpp->pkex_key = l_strdup(key);
memcpy(dpp->peer_addr, broadcast, 6);
- dpp->role = DPP_CAPABILITY_ENROLLEE;
- dpp->state = DPP_STATE_PKEX_EXCHANGE;
- dpp->interface = DPP_INTERFACE_PKEX;
+
/*
* In theory a driver could support a lesser duration than 200ms. This
* complicates things since we would need to tack on additional
@@ -4376,7 +4375,16 @@ static struct l_dbus_message *dpp_dbus_pkex_start_enrollee(struct l_dbus *dbus,
if (!dpp_parse_pkex_args(message, &key, &id))
goto invalid_args;
- if (!dpp_start_pkex_enrollee(dpp, key, id))
+ dpp->pkex_key = l_strdup(key);
+
+ if (id)
+ dpp->pkex_id = l_strdup(id);
+
+ dpp->role = DPP_CAPABILITY_ENROLLEE;
+ dpp->state = DPP_STATE_PKEX_EXCHANGE;
+ dpp->interface = DPP_INTERFACE_PKEX;
+
+ if (!dpp_start_pkex_enrollee(dpp))
goto invalid_args;
return l_dbus_message_new_method_return(message);
--
2.34.1
next reply other threads:[~2024-07-22 18:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 18:29 James Prestwood [this message]
2024-07-22 18:29 ` [PATCH v2 2/5] station: add station_get_autoconnect James Prestwood
2024-07-22 18:29 ` [PATCH v2 3/5] dpp: explicitly disconnect station if enrollee is started James Prestwood
2024-07-24 14:30 ` Denis Kenzior
2024-07-24 14:53 ` James Prestwood
2024-07-24 15:15 ` Denis Kenzior
2024-07-24 15:17 ` James Prestwood
2024-07-22 18:29 ` [PATCH v2 4/5] auto-t: add DPP tests for state change checks James Prestwood
2024-07-22 18:29 ` [PATCH v2 5/5] auto-t: fix several DPP tests after station state changes James Prestwood
-- strict thread matches above, loose matches on Subject: below --
2024-07-24 15:46 [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function James Prestwood
2024-07-24 20:27 ` 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=20240722182932.4091008-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=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