public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 12/16] dpp: replace SharedCodeAgent with DeviceProvisioningAgent
Date: Tue, 24 Sep 2024 05:04:43 -0700	[thread overview]
Message-ID: <20240924120447.251761-12-prestwoj@gmail.com> (raw)
In-Reply-To: <20240924120447.251761-1-prestwoj@gmail.com>

This fully removes the SharedCodeAgent which was specific to the PKEX
protocol and replaces it with the more generalized
DeviceProvisioningAgent. The new agent should still implement the
shared code method and effectively behave no differently in that
regard.

The main difference as far as the API is the new agent must be
registered via the AgentManager interface, not passed in via the
method arguments to ConfigureEnrollee().
---
 src/dpp.c | 63 ++++++++++++-------------------------------------------
 1 file changed, 13 insertions(+), 50 deletions(-)

diff --git a/src/dpp.c b/src/dpp.c
index 7b700018..d1912eaf 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -106,13 +106,6 @@ enum dpp_interface {
 	DPP_INTERFACE_PKEX,
 };
 
-struct pkex_agent {
-	char *owner;
-	char *path;
-	unsigned int disconnect_watch;
-	uint32_t pending_id;
-};
-
 struct dpp_sm {
 	struct netdev *netdev;
 	char *uri;
@@ -140,7 +133,6 @@ struct dpp_sm {
 	enum dpp_interface interface;
 
 	uint32_t agent_request_id;
-	struct pkex_agent *agent;
 
 	/*
 	 * List of frequencies to jump between. The presence of this list is
@@ -2088,7 +2080,7 @@ static void dpp_offchannel_timeout(int error, void *user_data)
 
 	switch (dpp->state) {
 	case DPP_STATE_PKEX_EXCHANGE:
-		if (dpp->role != DPP_CAPABILITY_CONFIGURATOR || !dpp->agent)
+		if (dpp->role != DPP_CAPABILITY_CONFIGURATOR || !dpp_agent_name)
 			break;
 
 		/*
@@ -2097,7 +2089,7 @@ static void dpp_offchannel_timeout(int error, void *user_data)
 		 * for our response so cancel the request and continue waiting
 		 * for another request
 		 */
-		if (dpp->agent->pending_id) {
+		if (dpp->agent_request_id) {
 			dpp_free_pending_pkex_data(dpp);
 			dpp_agent_cancel(dpp);
 		}
@@ -3228,10 +3220,10 @@ static void dpp_pkex_agent_reply(struct l_dbus_message *message,
 	const char *error, *text;
 	const char *code;
 
-	dpp->agent->pending_id = 0;
+	dpp->agent_request_id = 0;
 
-	l_debug("SharedCodeAgent %s path %s replied", dpp->agent->owner,
-			dpp->agent->path);
+	l_debug("DeviceProvisioningAgent %s path %s replied", dpp_agent_name,
+			dpp_agent_path);
 
 	if (l_dbus_message_get_error(message, &error, &text)) {
 		l_error("RequestSharedCode(%s) returned %s(\"%s\")",
@@ -3240,7 +3232,7 @@ static void dpp_pkex_agent_reply(struct l_dbus_message *message,
 	}
 
 	if (!l_dbus_message_get_arguments(message, "s", &code)) {
-		l_debug("Invalid arguments, check SharedCodeAgent!");
+		l_debug("Invalid arguments, check DeviceProvisioningAgent!");
 		goto reset;
 	}
 
@@ -3257,25 +3249,25 @@ static bool dpp_pkex_agent_request(struct dpp_sm *dpp)
 {
 	struct l_dbus_message *msg;
 
-	if (!dpp->agent)
+	if (!dpp_agent_name)
 		return false;
 
-	if (L_WARN_ON(dpp->agent->pending_id))
+	if (L_WARN_ON(dpp->agent_request_id))
 		return false;
 
 	msg = l_dbus_message_new_method_call(dbus_get_bus(),
-						dpp->agent->owner,
-						dpp->agent->path,
-						IWD_SHARED_CODE_AGENT_INTERFACE,
+						dpp_agent_name,
+						dpp_agent_path,
+						IWD_DPP_AGENT_INTERFACE,
 						"RequestSharedCode");
 	l_dbus_message_set_arguments(msg, "s", dpp->pkex_id);
 
 
-	dpp->agent->pending_id = l_dbus_send_with_reply(dbus_get_bus(),
+	dpp->agent_request_id = l_dbus_send_with_reply(dbus_get_bus(),
 							msg,
 							dpp_pkex_agent_reply,
 							dpp, NULL);
-	return dpp->agent->pending_id != 0;
+	return dpp->agent_request_id != 0;
 }
 
 static void dpp_handle_pkex_exchange_request(struct dpp_sm *dpp,
@@ -4648,32 +4640,6 @@ invalid_args:
 	return dbus_error_invalid_args(message);
 }
 
-static void pkex_agent_disconnect(struct l_dbus *dbus, void *user_data)
-{
-	struct dpp_sm *dpp = user_data;
-
-	l_debug("SharedCodeAgent %s disconnected", dpp->agent->path);
-
-	dpp_reset(dpp);
-}
-
-static void dpp_create_agent(struct dpp_sm *dpp, const char *path,
-					struct l_dbus_message *message)
-{
-	const char *sender = l_dbus_message_get_sender(message);
-
-	dpp->agent = l_new(struct pkex_agent, 1);
-	dpp->agent->owner = l_strdup(sender);
-	dpp->agent->path = l_strdup(path);
-	dpp->agent->disconnect_watch = l_dbus_add_disconnect_watch(
-							dbus_get_bus(),
-							sender,
-							pkex_agent_disconnect,
-							dpp, NULL);
-
-	l_debug("Registered a SharedCodeAgent on path %s", path);
-}
-
 static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp,
 					const char *key, const char *identifier,
 					const char *agent_path,
@@ -4708,9 +4674,6 @@ static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp,
 	if (key)
 		dpp->pkex_key = l_strdup(key);
 
-	if (agent_path)
-		dpp_create_agent(dpp, agent_path, message);
-
 	dpp->role = DPP_CAPABILITY_CONFIGURATOR;
 	dpp->state = DPP_STATE_PKEX_EXCHANGE;
 	dpp->interface = DPP_INTERFACE_PKEX;
-- 
2.34.1


  parent reply	other threads:[~2024-09-24 12:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 12:04 [PATCH 01/16] ie: add IE_AKM_IS_PSK James Prestwood
2024-09-24 12:04 ` [PATCH 02/16] dpp-util: refactor dpp_configuration_new into a _psk helper James Prestwood
2024-09-24 12:04 ` [PATCH 03/16] dpp: fix some return/cleanup issues for error cases James Prestwood
2024-09-24 12:04 ` [PATCH 04/16] dpp-util: refactor dpp_configuration_to_json for only PSK networks James Prestwood
2024-09-24 12:04 ` [PATCH 05/16] dpp: refactor dpp_send_config_response to take JSON as a parameter James Prestwood
2024-09-24 12:04 ` [PATCH 06/16] dpp: refactor dpp_configuration_start to take the " James Prestwood
2024-09-24 12:04 ` [PATCH 07/16] dpp: refactor config writing, add checks for PSK James Prestwood
2024-09-24 12:04 ` [PATCH 08/16] dpp-util: check the AKM is "psk" before further parsing the object James Prestwood
2024-09-24 12:04 ` [PATCH 09/16] dbus: add generic DPP agent interface James Prestwood
2024-09-24 12:04 ` [PATCH 10/16] dpp: replace PKEX agent with generic DPP agent James Prestwood
2024-09-24 12:04 ` [PATCH 11/16] agent: add APIs for DeviceProvisioningAgent James Prestwood
2024-09-24 12:04 ` James Prestwood [this message]
2024-09-24 12:04 ` [PATCH 13/16] dpp: remove agent path from StartConfigurator James Prestwood
2024-09-24 12:04 ` [PATCH 14/16] auto-t: update utils to use DeviceProvisioningAgent James Prestwood
2024-09-24 12:04 ` [PATCH 15/16] auto-t: update PKEX test " James Prestwood
2024-09-24 12:04 ` [PATCH 16/16] doc: Document new DeviceProvisioningAgent 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=20240924120447.251761-12-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