All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dpp: Add Started, Role, and URI properties to API
@ 2022-06-24 16:43 Jesse Lentz
  2022-06-24 16:43 ` [PATCH 2/2] doc: Add new DeviceProvisioning API properties Jesse Lentz
  2022-06-27 17:08 ` [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Denis Kenzior
  0 siblings, 2 replies; 5+ messages in thread
From: Jesse Lentz @ 2022-06-24 16:43 UTC (permalink / raw)
  To: iwd; +Cc: Jesse Lentz

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(+)

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)
-- 
2.36.1


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

* [PATCH 2/2] doc: Add new DeviceProvisioning API properties
  2022-06-24 16:43 [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Jesse Lentz
@ 2022-06-24 16:43 ` Jesse Lentz
  2022-06-27 16:37   ` James Prestwood
  2022-06-27 17:08 ` [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Denis Kenzior
  1 sibling, 1 reply; 5+ messages in thread
From: Jesse Lentz @ 2022-06-24 16:43 UTC (permalink / raw)
  To: iwd; +Cc: Jesse Lentz

Document the Started, Role, and URI properties of the DeviceProvisioning
API.
---
 doc/device-provisioning-api.txt | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/device-provisioning-api.txt b/doc/device-provisioning-api.txt
index 0aba2557..ac204f46 100644
--- a/doc/device-provisioning-api.txt
+++ b/doc/device-provisioning-api.txt
@@ -56,3 +56,18 @@ Methods		string StartEnrollee()
 						net.connman.iwd.NotConfigured
 						net.connman.iwd.NotSupported
 						net.connman.iwd.Busy
+
+Properties	boolean Started [readonly]
+
+			True if DPP is currently active.
+
+		string Role [readonly, optional]
+
+			Indicates the DPP role. Possible values are "enrollee"
+			or "configurator". This property is only available when
+			Started is true.
+
+		string URI [readonly, optional]
+
+			Indicates the DPP URI. This property is only available
+			when Started is true.
-- 
2.36.1


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

* Re: [PATCH 2/2] doc: Add new DeviceProvisioning API properties
  2022-06-24 16:43 ` [PATCH 2/2] doc: Add new DeviceProvisioning API properties Jesse Lentz
@ 2022-06-27 16:37   ` James Prestwood
  2022-06-27 19:34     ` Jesse Lentz
  0 siblings, 1 reply; 5+ messages in thread
From: James Prestwood @ 2022-06-27 16:37 UTC (permalink / raw)
  To: Jesse Lentz, iwd

Hi Jesse,

On Fri, 2022-06-24 at 12:43 -0400, Jesse Lentz wrote:
> Document the Started, Role, and URI properties of the
> DeviceProvisioning
> API.
> ---
>  doc/device-provisioning-api.txt | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/doc/device-provisioning-api.txt b/doc/device-
> provisioning-api.txt
> index 0aba2557..ac204f46 100644
> --- a/doc/device-provisioning-api.txt
> +++ b/doc/device-provisioning-api.txt
> @@ -56,3 +56,18 @@ Methods              string StartEnrollee()
>                                                 net.connman.iwd.NotCo
> nfigured
>                                                 net.connman.iwd.NotSu
> pported
>                                                 net.connman.iwd.Busy
> +
> +Properties     boolean Started [readonly]
> +
> +                       True if DPP is currently active.
> +
> +               string Role [readonly, optional]
> +
> +                       Indicates the DPP role. Possible values are
> "enrollee"
> +                       or "configurator". This property is only
> available when
> +                       Started is true.
> +
> +               string URI [readonly, optional]
> +
> +                       Indicates the DPP URI. This property is only
> available
> +                       when Started is true.

This looks good to me.

Just a note for next time, please send with a "v2" prefix. This lets
Patchwork remove old patch sets automatically.

Thanks,
James


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

* Re: [PATCH 1/2] dpp: Add Started, Role, and URI properties to API
  2022-06-24 16:43 [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Jesse Lentz
  2022-06-24 16:43 ` [PATCH 2/2] doc: Add new DeviceProvisioning API properties Jesse Lentz
@ 2022-06-27 17:08 ` Denis Kenzior
  1 sibling, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2022-06-27 17:08 UTC (permalink / raw)
  To: Jesse Lentz, iwd

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


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

* Re: [PATCH 2/2] doc: Add new DeviceProvisioning API properties
  2022-06-27 16:37   ` James Prestwood
@ 2022-06-27 19:34     ` Jesse Lentz
  0 siblings, 0 replies; 5+ messages in thread
From: Jesse Lentz @ 2022-06-27 19:34 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

> This looks good to me.
>
> Just a note for next time, please send with a "v2" prefix. This lets
> Patchwork remove old patch sets automatically.

Will do, thanks.

Sincerely,
Jesse

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

end of thread, other threads:[~2022-06-27 19:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 16:43 [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Jesse Lentz
2022-06-24 16:43 ` [PATCH 2/2] doc: Add new DeviceProvisioning API properties Jesse Lentz
2022-06-27 16:37   ` James Prestwood
2022-06-27 19:34     ` Jesse Lentz
2022-06-27 17:08 ` [PATCH 1/2] dpp: Add Started, Role, and URI properties to API Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.