diff mbox series

[1/2] dpp: Add Started, Role, and URI properties to API

Message ID 20220624164346.254771-1-jesse@twosheds.org (mailing list archive)
State Accepted, archived
Headers show
Series [1/2] dpp: Add Started, Role, and URI properties to API | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-testrunner fail test-runner - FAIL:

Commit Message

Jesse Lentz June 24, 2022, 4:43 p.m. UTC
Add three new properties to the DeviceProvisioning API: Started, Role,
and URI.
---
Unlike the previously proposed State property, the Started property
proposed in this patch only requires l_dbus_property_changed() calls
near the dbus entry points.

 src/dpp.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

Comments

Denis Kenzior June 27, 2022, 5:08 p.m. UTC | #1
Hi Jesse,

On 6/24/22 11:43, Jesse Lentz wrote:
> Add three new properties to the DeviceProvisioning API: Started, Role,
> and URI.
> ---
> Unlike the previously proposed State property, the Started property
> proposed in this patch only requires l_dbus_property_changed() calls
> near the dbus entry points.
> 
>   src/dpp.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 77 insertions(+)
> 

Both applied, thanks.

Regards,
-Dens
diff mbox series

Patch

diff --git a/src/dpp.c b/src/dpp.c
index 0102dc58..2c8832ff 100644
--- a/src/dpp.c
+++ b/src/dpp.c
@@ -149,6 +149,71 @@  struct dpp_sm {
 	bool roc_started : 1;
 };
 
+static bool dpp_get_started(struct l_dbus *dbus,
+				struct l_dbus_message *message,
+				struct l_dbus_message_builder *builder,
+				void *user_data)
+{
+	struct dpp_sm *dpp = user_data;
+	bool started = (dpp->state != DPP_STATE_NOTHING);
+
+	l_dbus_message_builder_append_basic(builder, 'b', &started);
+
+	return true;
+}
+
+static bool dpp_get_role(struct l_dbus *dbus,
+				struct l_dbus_message *message,
+				struct l_dbus_message_builder *builder,
+				void *user_data)
+{
+	struct dpp_sm *dpp = user_data;
+	const char *role;
+
+	if (dpp->state == DPP_STATE_NOTHING)
+		return false;
+
+	switch (dpp->role) {
+	case DPP_CAPABILITY_ENROLLEE:
+		role = "enrollee";
+		break;
+	case DPP_CAPABILITY_CONFIGURATOR:
+		role = "configurator";
+		break;
+	default:
+		return false;
+	}
+
+	l_dbus_message_builder_append_basic(builder, 's', role);
+	return true;
+}
+
+static bool dpp_get_uri(struct l_dbus *dbus,
+				struct l_dbus_message *message,
+				struct l_dbus_message_builder *builder,
+				void *user_data)
+{
+	struct dpp_sm *dpp = user_data;
+
+	if (dpp->state == DPP_STATE_NOTHING)
+		return false;
+
+	l_dbus_message_builder_append_basic(builder, 's', dpp->uri);
+	return true;
+}
+
+static void dpp_property_changed_notify(struct dpp_sm *dpp)
+{
+	const char *path = netdev_get_path(dpp->netdev);
+
+	l_dbus_property_changed(dbus_get_bus(), path, IWD_DPP_INTERFACE,
+				"Started");
+	l_dbus_property_changed(dbus_get_bus(), path, IWD_DPP_INTERFACE,
+				"Role");
+	l_dbus_property_changed(dbus_get_bus(), path, IWD_DPP_INTERFACE,
+				"URI");
+}
+
 static void *dpp_serialize_iovec(struct iovec *iov, size_t iov_len,
 				size_t *out_len)
 {
@@ -262,6 +327,8 @@  static void dpp_reset(struct dpp_sm *dpp)
 	explicit_bzero(dpp->auth_tag, dpp->key_len);
 
 	dpp_free_auth_data(dpp);
+
+	dpp_property_changed_notify(dpp);
 }
 
 static void dpp_free(struct dpp_sm *dpp)
@@ -2432,6 +2499,8 @@  static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus,
 
 	scan_periodic_stop(dpp->wdev_id);
 
+	dpp_property_changed_notify(dpp);
+
 	return NULL;
 }
 
@@ -2562,6 +2631,8 @@  static struct l_dbus_message *dpp_start_configurator_common(
 
 	scan_periodic_stop(dpp->wdev_id);
 
+	dpp_property_changed_notify(dpp);
+
 	l_debug("DPP Start Configurator: %s", dpp->uri);
 
 	reply = l_dbus_message_new_method_return(message);
@@ -2606,6 +2677,12 @@  static void dpp_setup_interface(struct l_dbus_interface *interface)
 				dpp_dbus_configure_enrollee, "", "s", "uri");
 	l_dbus_interface_method(interface, "Stop", 0,
 				dpp_dbus_stop, "", "");
+
+	l_dbus_interface_property(interface, "Started", 0, "b", dpp_get_started,
+					NULL);
+	l_dbus_interface_property(interface, "Role", 0, "s", dpp_get_role,
+					NULL);
+	l_dbus_interface_property(interface, "URI", 0, "s", dpp_get_uri, NULL);
 }
 
 static void dpp_destroy_interface(void *user_data)