From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 04/11] hwsim: change radio Create() to take a dictionary
Date: Thu, 17 Dec 2020 11:36:04 -0800 [thread overview]
Message-ID: <20201217193611.1177006-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20201217193611.1177006-1-prestwoj@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]
The Create() API was limited to only taking a Name and boolean
(for p2p enabling). The actual hwsim nl80211 API can take more
attributes than this (which are actually utilized when creating
from the command line). To get the DBus API up to the same
functionality the two arguments in Create were replaced with
a single dictionary. This allows for extending later if more
arguments are needed.
---
tools/hwsim.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/tools/hwsim.c b/tools/hwsim.c
index c17792bf..6a1eb348 100644
--- a/tools/hwsim.c
+++ b/tools/hwsim.c
@@ -1599,20 +1599,38 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
void *user_data)
{
struct l_genl_msg *new_msg;
- const char *name;
- bool p2p;
+ struct l_dbus_message_iter dict;
+ struct l_dbus_message_iter variant;
+ const char *key;
+ const char *name = NULL;
+ bool p2p = false;
if (pending_create_msg)
return dbus_error_busy(message);
- if (!l_dbus_message_get_arguments(message, "sb", &name, &p2p))
- return dbus_error_invalid_args(message);
+ if (!l_dbus_message_get_arguments(message, "a{sv}", &dict))
+ goto invalid;
+
+ while (l_dbus_message_iter_next_entry(&dict, &key, &variant)) {
+ bool ret = false;
- new_msg = l_genl_msg_new_sized(HWSIM_CMD_NEW_RADIO, 16 + strlen(name));
+ if (!strcmp(key, "Name"))
+ ret = l_dbus_message_iter_get_variant(&variant,
+ "s", &name);
+ else if (!strcmp(key, "P2P"))
+ ret = l_dbus_message_iter_get_variant(&variant,
+ "b", &p2p);
+
+ if (!ret)
+ goto invalid;
+ }
+
+ new_msg = l_genl_msg_new_sized(HWSIM_CMD_NEW_RADIO,
+ 16 + name ? strlen(name) : 0);
l_genl_msg_append_attr(new_msg, HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
0, NULL);
- if (name[0])
+ if (name)
l_genl_msg_append_attr(new_msg, HWSIM_ATTR_RADIO_NAME,
strlen(name) + 1, name);
@@ -1627,12 +1645,15 @@ static struct l_dbus_message *radio_manager_create(struct l_dbus *dbus,
pending_create_radio_id = 0;
return NULL;
+
+invalid:
+ return dbus_error_invalid_args(message);
}
static void setup_radio_manager_interface(struct l_dbus_interface *interface)
{
l_dbus_interface_method(interface, "CreateRadio", 0,
- radio_manager_create, "o", "sb",
+ radio_manager_create, "o", "a{sv}",
"path", "name", "p2p_device");
}
--
2.26.2
next prev parent reply other threads:[~2020-12-17 19:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-17 19:36 [PATCH 01/11] hwsim: add --no-register option James Prestwood
2020-12-17 19:36 ` [PATCH 02/11] hwsim: check pending_create_msg before replying James Prestwood
2020-12-17 19:36 ` [PATCH 03/11] auto-t: fix hwsim.py to use Destroy rather than Remove James Prestwood
2020-12-17 19:36 ` James Prestwood [this message]
2020-12-17 19:36 ` [PATCH 05/11] auto-t: update hwsim radio create to use dictionary James Prestwood
2020-12-17 19:36 ` [PATCH 06/11] test-runner: add wait_for_dbus_service James Prestwood
2020-12-17 19:36 ` [PATCH 07/11] test-runner: start hwsim always (optionally --no-register) James Prestwood
2020-12-17 19:36 ` [PATCH 08/11] hwsim: add iftype/cipher disabling through DBus James Prestwood
2020-12-17 19:36 ` [PATCH 09/11] auto-t: add iftype/cipher disable to hwsim.py James Prestwood
2020-12-17 19:36 ` [PATCH 10/11] test-runner: Use DBus for hwsim radios James Prestwood
2020-12-17 19:36 ` [PATCH 11/11] auto-t: fix hwsim.py spoof frame James Prestwood
2020-12-18 2:15 ` [PATCH 01/11] hwsim: add --no-register option Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201217193611.1177006-4-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox