Skip to contentSkip to conversation

client: Add shared code DBus interface

PATCH In review James Prestwood 2 participants 8 messages Nov 9, 2023 – Nov 10, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 client: Add shared code DBus interface

---
 client/dbus-proxy.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
client/dbus-proxy.h +3 -1
index 0b4fec43..cd1b2305 100644
@@ -2,7 +2,7 @@
  *
  *  Wireless daemon for Linux
  *
- *  Copyright (C) 2017-2019  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2013  Intel Corporation. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -38,6 +38,8 @@ struct proxy_interface;
 #define IWD_AP_DIAGNOSTIC_INTERFACE      "net.connman.iwd.AccessPointDiagnostic"
 #define IWD_DAEMON_INTERFACE             "net.connman.iwd.Daemon"
 #define IWD_DPP_INTERFACE                "net.connman.iwd.DeviceProvisioning"
+#define IWD_DPP_PKEX_INTERFACE \
+				"net.connman.iwd.SharedCodeDeviceProvisioning"
 
 typedef bool (*proxy_property_match_func_t) (const void *a, const void *b);
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 client: add helper to call method via builder

There was no way to call a method with anything except basic arguments. Add a helper to use a builder to create more complex args.

---
 client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++-
 client/dbus-proxy.h |  9 +++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
client/dbus-proxy.c +35 -1
index 42b8427f..de252427 100644
@@ -2,7 +2,7 @@
  *
  *  Wireless daemon for Linux
  *
- *  Copyright (C) 2017-2020  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2023  Intel Corporation. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy,
 	return true;
 }
 
+struct l_dbus_message_builder *proxy_interface_new_builder(
+				const struct proxy_interface *proxy,
+				const char *name)
+{
+	struct l_dbus_message *call = l_dbus_message_new_method_call(dbus,
+						IWD_SERVICE, proxy->path,
+						proxy->type->interface, name);
+
+	return l_dbus_message_builder_new(call);
+}
+
+bool proxy_interface_method_call_from_builder(
+					const struct proxy_interface *proxy,
+					struct l_dbus_message_builder *builder,
+					l_dbus_message_func_t callback)
+{
+	struct proxy_callback_data *callback_data;
+	struct l_dbus_message *call;
+
+	if (!proxy || !builder)
+		return false;
+
+	call = l_dbus_message_builder_finalize(builder);
+
+	callback_data = l_new(struct proxy_callback_data, 1);
+	callback_data->callback = callback;
+	callback_data->user_data = (void *) proxy;
+
+	l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data,
+									l_free);
+
+	return true;
+}
+
 void *proxy_interface_get_data(const struct proxy_interface *proxy)
 {
 	return proxy->data;
client/dbus-proxy.h +9 -0
index cd1b2305..94625b85 100644
@@ -90,6 +90,15 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy,
 					const char *name, const char *signature,
 					l_dbus_message_func_t callback, ...);
 
+bool proxy_interface_method_call_from_builder(
+					const struct proxy_interface *proxy,
+					struct l_dbus_message_builder *builder,
+					l_dbus_message_func_t callback);
+
+struct l_dbus_message_builder *proxy_interface_new_builder(
+				const struct proxy_interface *proxy,
+				const char *name);
+
 void proxy_properties_display(const struct proxy_interface *proxy,
 				const char *caption, const char *margin,
 				unsigned int name_column_width,
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/3] client: add helper to call method via builder

Hi James,

Quoted 13 lines · James Prestwood

There was no way to call a method with anything except basic arguments. Add a helper to use a builder to create more complex args.

---
  client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++-
  client/dbus-proxy.h |  9 +++++++++
  2 files changed, 44 insertions(+), 1 deletion(-)
client/dbus-proxy.c +0 -0
index 42b8427f..de252427 100644

client/dbus-proxy.c line 5

Quoted 5 lines
client/dbus-proxy.c +1 -1
@@ -2,7 +2,7 @@
   *
   *  Wireless daemon for Linux
   *
- *  Copyright (C) 2017-2020  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2023  Intel Corporation. All rights reserved.

Is this correct?

Quoted 6 lines
client/dbus-proxy.c +0 -0
   *
   *  This library is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU Lesser General Public
@@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct proxy_interface *proxy,
  	return true;
  }

client/dbus-proxy.c bool proxy_interface_method_call(const struct proxy_interface *proxy, · line 640

Quoted 10 lines
client/dbus-proxy.c +9 -0
 
+struct l_dbus_message_builder *proxy_interface_new_builder(
+				const struct proxy_interface *proxy,
+				const char *name)
+{
+	struct l_dbus_message *call = l_dbus_message_new_method_call(dbus,
+						IWD_SERVICE, proxy->path,
+						proxy->type->interface, name);
+
+	return l_dbus_message_builder_new(call);

Do you really need this 2 line function for a single call site?

Quoted 18 lines
client/dbus-proxy.c +18 -0
+}
+
+bool proxy_interface_method_call_from_builder(
+					const struct proxy_interface *proxy,
+					struct l_dbus_message_builder *builder,
+					l_dbus_message_func_t callback)
+{
+	struct proxy_callback_data *callback_data;
+	struct l_dbus_message *call;
+
+	if (!proxy || !builder)
+		return false;
+
+	call = l_dbus_message_builder_finalize(builder);
+
+	callback_data = l_new(struct proxy_callback_data, 1);
+	callback_data->callback = callback;
+	callback_data->user_data = (void *) proxy;

client/dbus-proxy.c bool proxy_interface_method_call(const struct proxy_interface *proxy, · line 668

Quoted 10 lines
client/dbus-proxy.c +7 -0
+
+	l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data,
+									l_free);
+
+	return true;
+}
+
  void *proxy_interface_get_data(const struct proxy_interface *proxy)
  {
  	return proxy->data;

Regards,
-Denis

#3 lore raw

Re: [PATCH 2/3] client: add helper to call method via builder

Hi Denis,

Quoted 11 lines · Denis Kenzior

Hi James,

Quoted 8 lines · James Prestwood

There was no way to call a method with anything except basic arguments. Add a helper to use a builder to create more complex args.
---
  client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++- client/dbus-proxy.h |  9 +++++++++

  2 files changed, 44 insertions(+), 1 deletion(-)
Quoted 12 lines

client/dbus-proxy.c line 5

Quoted 10 lines
client/dbus-proxy.c +1 -1
index 42b8427f..de252427 100644
@@ -2,7 +2,7 @@
    *
    *  Wireless daemon for Linux
    *
- *  Copyright (C) 2017-2020  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2023  Intel Corporation. All rights reserved.

Is this correct?

I'm generally terrible about updating the dates on the copyright and really never do it. Decided I'd try and do better this time :)

But I'm not actually sure how this works. Should there be multiple copyright notices if different companies touch existing files? or should we just leave the copyrights as-is if the file already exists.

Quoted 11 lines
Quoted 11 lines
client/dbus-proxy.c +3 -0
    *
    *  This library is free software; you can redistribute it and/or
    *  modify it under the terms of the GNU Lesser General Public
@@ -629,6 +629,40 @@ bool proxy_interface_method_call(const struct 
 proxy_interface *proxy,
       return true;
   }
+struct l_dbus_message_builder *proxy_interface_new_builder(
+                const struct proxy_interface *proxy,
+                const char *name)
Quoted 8 lines

client/dbus-proxy.c bool proxy_interface_method_call(const struct proxy_interface *proxy, · line 640

Quoted 6 lines
client/dbus-proxy.c +6 -0
+{
+    struct l_dbus_message *call = l_dbus_message_new_method_call(dbus,
+                        IWD_SERVICE, proxy->path,
+                        proxy->type->interface, name);
+
+    return l_dbus_message_builder_new(call);

Do you really need this 2 line function for a single call site?

With knowledge that l_dbus_message_set_arguments can handle dictionaries I don't need this patch at all :)

Quoted 33 lines
Quoted 19 lines
client/dbus-proxy.c +18 -0
+}
+
+bool proxy_interface_method_call_from_builder(
+                    const struct proxy_interface *proxy,
+                    struct l_dbus_message_builder *builder,
+                    l_dbus_message_func_t callback)
+{
+    struct proxy_callback_data *callback_data;
+    struct l_dbus_message *call;
+
+    if (!proxy || !builder)
+        return false;
+
+    call = l_dbus_message_builder_finalize(builder);
+
+    callback_data = l_new(struct proxy_callback_data, 1);
+    callback_data->callback = callback;
+    callback_data->user_data = (void *) proxy;

client/dbus-proxy.c bool proxy_interface_method_call(const struct proxy_interface *proxy, · line 668

Quoted 10 lines
client/dbus-proxy.c +7 -0
+
+    l_dbus_send_with_reply(dbus, call, proxy_callback, callback_data,
+                                    l_free);
+
+    return true;
+}
+
   void *proxy_interface_get_data(const struct proxy_interface *proxy)
   {
       return proxy->data;

Regards,
-Denis

#4 lore raw

Re: [PATCH 2/3] client: add helper to call method via builder

Hi Denis,

Quoted 27 lines · James Prestwood

Hi Denis,

Quoted 11 lines · Denis Kenzior

Hi James,

Quoted 8 lines · James Prestwood

There was no way to call a method with anything except basic arguments. Add a helper to use a builder to create more complex args.
---
  client/dbus-proxy.c | 36 +++++++++++++++++++++++++++++++++++- client/dbus-proxy.h |  9 +++++++++

  2 files changed, 44 insertions(+), 1 deletion(-)
Quoted 12 lines

client/dbus-proxy.c line 5

Quoted 10 lines
client/dbus-proxy.c +1 -1
index 42b8427f..de252427 100644
@@ -2,7 +2,7 @@
    *
    *  Wireless daemon for Linux
    *
- *  Copyright (C) 2017-2020  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2023  Intel Corporation. All rights reserved.

Is this correct?

Quoted 3 lines

I'm generally terrible about updating the dates on the copyright and really never do it. Decided I'd try and do better this time :)

But I'm not actually sure how this works. Should there be multiple copyright notices if different companies touch existing files? or should we just leave the copyrights as-is if the file already exists.

Nevermind, took a look at the kernel and they just append the companies/dates. It had been so long at Intel I forgot how all this worked :)

Thanks,
James

#5 lore raw

PATCH 3/3 client: add client commands for shared code configuration

In reply to James Prestwood

The StartConfigurator() call was left out since there would be no functional difference to the user in iwctl. Its expected that human users of the shared code API provide the code/id ahead of time, i.e. use ConfigureEnrollee/StartEnrollee.

---
 Makefile.am       |   3 +-
 client/dpp-pkex.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 344 insertions(+), 1 deletion(-)
 create mode 100644 client/dpp-pkex.c
Makefile.am +2 -1
index 2e962153..d0247faf 100644
@@ -314,7 +314,8 @@ client_iwctl_SOURCES = client/main.c \
 			client/wsc.c client/station.c \
 			client/diagnostic.c client/diagnostic.h \
 			client/daemon.c client/daemon.h \
-			client/dpp.c client/station-debug.c \
+			client/dpp.c client/dpp-pkex.c \
+			client/station-debug.c \
 			src/util.c src/util.h \
 			src/band.c src/band.h
 
client/dpp-pkex.c new file +342 -0

342 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH 3/3] client: add client commands for shared code configuration

Hi James,

Quoted 10 lines · James Prestwood

The StartConfigurator() call was left out since there would be no functional difference to the user in iwctl. Its expected that human users of the shared code API provide the code/id ahead of time, i.e. use ConfigureEnrollee/StartEnrollee.

---
  Makefile.am       |   3 +-
  client/dpp-pkex.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 344 insertions(+), 1 deletion(-)

create mode 100644 client/dpp-pkex.c

<snip>

client/dpp-pkex.c line 6

Quoted 12 lines
client/dpp-pkex.c new file +6 -0
new file mode 100644
index 00000000..7a6934e1
@@ -0,0 +1,342 @@
+/*
+ *
+ *  Wireless daemon for Linux
+ *
+ *  Copyright (C) 2023  Intel Corporation. All rights reserved.
+ *

This looks incorrect. Copy-paste?

Quoted 16 lines
client/dpp-pkex.c new file +16 -0
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+

<snip>

Quoted 23 lines
client/dpp-pkex.c new file +23 -0
+static enum cmd_status cmd_enroll_or_configure(const char *device_name,
+						char **argv, int argc,
+						const char *method)
+{
+	struct l_dbus_message_builder *builder;
+	const struct proxy_interface *pkex;
+	const char *key;
+	const char *id = NULL;
+
+	pkex = device_proxy_find(device_name, IWD_DPP_PKEX_INTERFACE);
+	if (!pkex) {
+		display("No pkex pkex on device: '%s'\n", device_name);
+		return CMD_STATUS_INVALID_VALUE;
+	}
+
+	if (argc < 1)
+		return CMD_STATUS_INVALID_ARGS;
+
+	key = argv[0];
+
+	if (argc > 1)
+		id = argv[1];
+

client/dpp-pkex.c line 162

Quoted 10 lines
client/dpp-pkex.c new file +10 -0
+	builder = proxy_interface_new_builder(pkex, method);
+
+	l_dbus_message_builder_enter_array(builder, "{sv}");
+
+	append_dict_basic(builder, "Code", 's', key);
+
+	if (id)
+		append_dict_basic(builder, "Identifier", 's', id);
+
+	l_dbus_message_builder_leave_array(builder);

This can all be done as:

l_dbus_message_set_arguments(msg, "a{sv}", 2,

				"Code", "s", key,
				"Identifier", "s", id);

client/dpp-pkex.c line 170

Quoted 8 lines
client/dpp-pkex.c new file +8 -0
+
+	proxy_interface_method_call_from_builder(pkex, builder,
+						check_errors_method_callback);
+	l_dbus_message_builder_destroy(builder);
+
+	return CMD_STATUS_TRIGGERED;
+}
+

Regards,
-Denis

#7 lore raw
In reply to James Prestwood

Hi James,

Quoted 9 lines · James Prestwood
---
  client/dbus-proxy.h | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
client/dbus-proxy.h +0 -0
index 0b4fec43..cd1b2305 100644

client/dbus-proxy.h line 5

Quoted 5 lines
client/dbus-proxy.h +1 -1
@@ -2,7 +2,7 @@
   *
   *  Wireless daemon for Linux
   *
- *  Copyright (C) 2017-2019  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2013  Intel Corporation. All rights reserved.

Uh?

client/dbus-proxy.h line 8

Quoted 3 lines
client/dbus-proxy.h +0 -0
   *
   *  This library is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU Lesser General Public

Regards,
-Denis