public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function
@ 2024-07-22 18:29 James Prestwood
  2024-07-22 18:29 ` [PATCH v2 2/5] station: add station_get_autoconnect James Prestwood
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: James Prestwood @ 2024-07-22 18:29 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function
@ 2024-07-24 15:46 James Prestwood
  2024-07-24 15:46 ` [PATCH v2 3/5] dpp: explicitly disconnect station if enrollee is started James Prestwood
  0 siblings, 1 reply; 10+ messages in thread
From: James Prestwood @ 2024-07-24 15:46 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-07-24 15:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-22 18:29 [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function James Prestwood
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 15:46 ` [PATCH v2 3/5] dpp: explicitly disconnect station if enrollee is started James Prestwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox