All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] main: Add D-Bus Daemon.GetInfo method
@ 2021-05-05 22:29 Andrew Zaborowski
  2021-05-05 22:29 ` [PATCH 2/2] doc: Daemon DBus interface documentation Andrew Zaborowski
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Zaborowski @ 2021-05-05 22:29 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2983 bytes --]

Expose the state directory/storage directory path on D-Bus because it
can't be known to clients until IWD runs, and client might need to
occasionally fiddle with the network config files.  While there also
expose the IWD version string, similar to how some other D-Bus services
do.
---
 src/dbus.h |  1 +
 src/main.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/src/dbus.h b/src/dbus.h
index 4936dc6c..b3896108 100644
--- a/src/dbus.h
+++ b/src/dbus.h
@@ -24,6 +24,7 @@
 
 #define IWD_SERVICE "net.connman.iwd"
 
+#define IWD_DAEMON_INTERFACE "net.connman.iwd.Daemon"
 #define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
 #define IWD_WIPHY_INTERFACE "net.connman.iwd.Adapter"
 #define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"
diff --git a/src/main.c b/src/main.c
index 2ee6188c..f65fa7f4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -185,6 +185,16 @@ static void request_name_callback(struct l_dbus *dbus, bool success,
 	if (!l_dbus_object_manager_enable(dbus, "/"))
 		l_warn("Unable to register the ObjectManager");
 
+	if (!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
+						IWD_DAEMON_INTERFACE,
+						NULL) ||
+			!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
+						L_DBUS_INTERFACE_PROPERTIES,
+						NULL))
+		l_info("Unable to add %s and/or %s at %s",
+			IWD_DAEMON_INTERFACE, L_DBUS_INTERFACE_PROPERTIES,
+			IWD_BASE_PATH);
+
 	/* TODO: Always request nl80211 for now, ignoring auto-loading */
 	l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
 				NULL, NULL);
@@ -194,12 +204,44 @@ fail_exit:
 	l_main_quit();
 }
 
+static struct l_dbus_message *iwd_dbus_get_info(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						void *user_data)
+{
+	struct l_dbus_message *reply;
+	struct l_dbus_message_builder *builder;
+	L_AUTO_FREE_VAR(char *, storage_dir) = storage_get_path(NULL);
+
+	reply = l_dbus_message_new_method_return(message);
+	builder = l_dbus_message_builder_new(reply);
+	l_dbus_message_builder_enter_array(builder, "{sv}");
+
+	dbus_append_dict_basic(builder, "StateDirectory", 's', storage_dir);
+	dbus_append_dict_basic(builder, "Version", 's', VERSION);
+
+	l_dbus_message_builder_leave_array(builder);
+	l_dbus_message_builder_finalize(builder);
+	l_dbus_message_builder_destroy(builder);
+
+	return reply;
+}
+
+static void iwd_setup_deamon_interface(struct l_dbus_interface *interface)
+{
+	l_dbus_interface_method(interface, "GetInfo", 0, iwd_dbus_get_info,
+				"a{sv}", "", "info");
+}
+
 static void dbus_ready(void *user_data)
 {
 	struct l_dbus *dbus = user_data;
 
 	l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
 				request_name_callback, NULL);
+
+	l_dbus_register_interface(dbus, IWD_DAEMON_INTERFACE,
+					iwd_setup_deamon_interface,
+					NULL, false);
 }
 
 static void dbus_disconnected(void *user_data)
-- 
2.27.0

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

* [PATCH 2/2] doc: Daemon DBus interface documentation
  2021-05-05 22:29 [PATCH 1/2] main: Add D-Bus Daemon.GetInfo method Andrew Zaborowski
@ 2021-05-05 22:29 ` Andrew Zaborowski
  2021-05-06 16:20   ` Ryan Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Zaborowski @ 2021-05-05 22:29 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

---
 doc/daemon-api.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 doc/daemon-api.txt

diff --git a/doc/daemon-api.txt b/doc/daemon-api.txt
new file mode 100644
index 00000000..8256bb10
--- /dev/null
+++ b/doc/daemon-api.txt
@@ -0,0 +1,24 @@
+Daemon hierarchy
+================
+
+Service		net.connman.iwd
+Interface	net.connman.iwd.Deamon [Experimental]
+Object path	/net/connman/iwd
+
+Methods		dict GetInfo()
+
+			Returns basic IWD daemon's status and configuration
+			properties.  Their values are global and may be useful
+			for D-Bus clients interacting with IWD, not so much
+			for the user.  The returned dictionary (a{sv}) maps
+			string keys to values of types defined per key.
+			Clients should ignore unknown keys.
+
+			The following key/value pairs are defined currently:
+
+			string Version - IWD release version,
+
+			string StateDirectory - Absolute path to the IWD
+			state directory where network configuration and
+			runtime state files are kept (see $STATE_DIRECTORY in
+			iwd(8) and iwd.network(5)).
-- 
2.27.0

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

* Re: [PATCH 2/2] doc: Daemon DBus interface documentation
  2021-05-05 22:29 ` [PATCH 2/2] doc: Daemon DBus interface documentation Andrew Zaborowski
@ 2021-05-06 16:20   ` Ryan Smith
  2021-05-06 20:52     ` Andrew Zaborowski
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan Smith @ 2021-05-06 16:20 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]

Hi Andrew,
Thanks for your work on IWD! There's a typo on the documentation. See
below...

On Wed, May 5, 2021 at 4:29 PM Andrew Zaborowski <
andrew.zaborowski@intel.com> wrote:

> ---
>  doc/daemon-api.txt | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 doc/daemon-api.txt
>
> diff --git a/doc/daemon-api.txt b/doc/daemon-api.txt
> new file mode 100644
> index 00000000..8256bb10
> --- /dev/null
> +++ b/doc/daemon-api.txt
> @@ -0,0 +1,24 @@
> +Daemon hierarchy
> +================
> +
> +Service                net.connman.iwd
> +Interface      net.connman.iwd.Deamon [Experimental]
>

Should be net.connman.iwd.Daemon


> +Object path    /net/connman/iwd
> +
> +Methods                dict GetInfo()
> +
> +                       Returns basic IWD daemon's status and configuration
> +                       properties.  Their values are global and may be
> useful
> +                       for D-Bus clients interacting with IWD, not so much
> +                       for the user.  The returned dictionary (a{sv}) maps
> +                       string keys to values of types defined per key.
> +                       Clients should ignore unknown keys.
> +
> +                       The following key/value pairs are defined
> currently:
> +
> +                       string Version - IWD release version,
> +
> +                       string StateDirectory - Absolute path to the IWD
> +                       state directory where network configuration and
> +                       runtime state files are kept (see $STATE_DIRECTORY
> in
> +                       iwd(8) and iwd.network(5)).
> --
> 2.27.0
> _______________________________________________
> iwd mailing list -- iwd(a)lists.01.org
> To unsubscribe send an email to iwd-leave(a)lists.01.org


Thanks,
Ryan Smith

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 2710 bytes --]

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

* Re: [PATCH 2/2] doc: Daemon DBus interface documentation
  2021-05-06 16:20   ` Ryan Smith
@ 2021-05-06 20:52     ` Andrew Zaborowski
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Zaborowski @ 2021-05-06 20:52 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

Hi Ryan,

On Thu, 6 May 2021 at 18:20, Ryan Smith <ryan.smith@density.io> wrote:
>
> Hi Andrew,
> Thanks for your work on IWD! There's a typo on the documentation. See below...

Good catch, will fix and resend.
Best regards

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

* [PATCH 2/2] doc: Daemon DBus interface documentation
  2021-05-06 21:28 [PATCH 1/2] main: Add D-Bus Daemon.GetInfo method Andrew Zaborowski
@ 2021-05-06 21:28 ` Andrew Zaborowski
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Zaborowski @ 2021-05-06 21:28 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

---
 doc/daemon-api.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 doc/daemon-api.txt

diff --git a/doc/daemon-api.txt b/doc/daemon-api.txt
new file mode 100644
index 00000000..8256bb10
--- /dev/null
+++ b/doc/daemon-api.txt
@@ -0,0 +1,24 @@
+Daemon hierarchy
+================
+
+Service		net.connman.iwd
+Interface	net.connman.iwd.Daemon [Experimental]
+Object path	/net/connman/iwd
+
+Methods		dict GetInfo()
+
+			Returns basic IWD daemon's status and configuration
+			properties.  Their values are global and may be useful
+			for D-Bus clients interacting with IWD, not so much
+			for the user.  The returned dictionary (a{sv}) maps
+			string keys to values of types defined per key.
+			Clients should ignore unknown keys.
+
+			The following key/value pairs are defined currently:
+
+			string Version - IWD release version,
+
+			string StateDirectory - Absolute path to the IWD
+			state directory where network configuration and
+			runtime state files are kept (see $STATE_DIRECTORY in
+			iwd(8) and iwd.network(5)).
-- 
2.27.0

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

end of thread, other threads:[~2021-05-06 21:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 22:29 [PATCH 1/2] main: Add D-Bus Daemon.GetInfo method Andrew Zaborowski
2021-05-05 22:29 ` [PATCH 2/2] doc: Daemon DBus interface documentation Andrew Zaborowski
2021-05-06 16:20   ` Ryan Smith
2021-05-06 20:52     ` Andrew Zaborowski
2021-05-06 21:28 [PATCH 1/2] main: Add D-Bus Daemon.GetInfo method Andrew Zaborowski
2021-05-06 21:28 ` [PATCH 2/2] doc: Daemon DBus interface documentation Andrew Zaborowski

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.