diff mbox series

[11/16] agent: add APIs for DeviceProvisioningAgent

Message ID 20240924120447.251761-11-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [01/16] ie: add IE_AKM_IS_PSK | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Sept. 24, 2024, 12:04 p.m. UTC
This adds {Register,Unregister}DeviceProvisioningAgent to the
AgentManager interface. These are simple wrappers which just call
into DPP.
---
 src/agent.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
diff mbox series

Patch

diff --git a/src/agent.c b/src/agent.c
index 0f718b87..bf0a88ea 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -32,6 +32,7 @@ 
 #include "src/agent.h"
 #include "src/iwd.h"
 #include "src/module.h"
+#include "src/dpp.h"
 
 static unsigned int next_request_id = 0;
 
@@ -639,6 +640,54 @@  static struct l_dbus_message *netconfig_agent_unregister(struct l_dbus *dbus,
 	return reply;
 }
 
+static struct l_dbus_message *device_provisioning_agent_register(
+						struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						void *user_data)
+{
+	struct l_dbus_message *reply;
+	const char *path;
+	int r;
+
+	l_debug("");
+
+	if (!l_dbus_message_get_arguments(message, "o", &path))
+		return dbus_error_invalid_args(message);
+
+	r = dpp_register_agent(l_dbus_message_get_sender(message), path);
+	if (r)
+		return dbus_error_from_errno(r, message);
+
+	l_debug("device provisioning agent %s path %s",
+		l_dbus_message_get_sender(message), path);
+
+	reply = l_dbus_message_new_method_return(message);
+	l_dbus_message_set_arguments(reply, "");
+	return reply;
+}
+
+static struct l_dbus_message *device_provisioning_agent_unregister(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+					void *user_data)
+{
+	struct l_dbus_message *reply;
+	const char *path;
+	int r;
+
+	l_debug("");
+
+	if (!l_dbus_message_get_arguments(message, "o", &path))
+		return dbus_error_invalid_args(message);
+
+	r = dpp_unregister_agent(l_dbus_message_get_sender(message), path);
+	if (r)
+		return dbus_error_from_errno(r, message);
+
+	reply = l_dbus_message_new_method_return(message);
+	l_dbus_message_set_arguments(reply, "");
+	return reply;
+}
+
 static void setup_agent_interface(struct l_dbus_interface *interface)
 {
 	l_dbus_interface_method(interface, "RegisterAgent", 0,
@@ -654,6 +703,15 @@  static void setup_agent_interface(struct l_dbus_interface *interface)
 	l_dbus_interface_method(interface,
 				"UnregisterNetworkConfigurationAgent", 0,
 				netconfig_agent_unregister, "", "o", "path");
+
+	l_dbus_interface_method(interface,
+				"RegisterDeviceProvisioningAgent", 0,
+				device_provisioning_agent_register,
+				"", "o", "path");
+	l_dbus_interface_method(interface,
+				"UnregisterDeviceProvisioningAgent", 0,
+				device_provisioning_agent_unregister,
+				"", "o", "path");
 }
 
 static bool release_agent(void *data, void *user_data)