From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v2 10/13] client: Add BasicServiceSets property to network
Date: Thu, 8 Aug 2024 10:42:33 -0700 [thread overview]
Message-ID: <20240808174236.218750-10-prestwoj@gmail.com> (raw)
In-Reply-To: <20240808174236.218750-1-prestwoj@gmail.com>
The property itself is an array of paths, but this is difficult
to fit nicely within a terminal. Instead just display the count
of BSS's. Displaying a detailed list of BSS's will be done via
a separate command.
---
client/network.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
client/network.h | 2 ++
2 files changed, 51 insertions(+)
diff --git a/client/network.c b/client/network.c
index 6b79bcd1..7431183b 100644
--- a/client/network.c
+++ b/client/network.c
@@ -35,6 +35,7 @@ struct network {
char *identity;
char *name;
char *type;
+ struct l_queue *bss_list;
const struct proxy_interface *device;
};
@@ -146,11 +147,58 @@ static void update_type(void *data, struct l_dbus_message_iter *variant)
network->type = l_strdup(value);
}
+static bool match_path(const void *a, const void *user_data)
+{
+ const char *path1 = a;
+ const char *path2 = user_data;
+
+ return !strcmp(path1, path2);
+}
+
+static void update_ess(void *data, struct l_dbus_message_iter *variant)
+{
+ struct network *network = data;
+ struct l_dbus_message_iter array;
+ const char *path;
+
+ if (!network->bss_list)
+ network->bss_list = l_queue_new();
+
+ if (!l_dbus_message_iter_get_variant(variant, "ao", &array))
+ return;
+
+ while (l_dbus_message_iter_next_entry(&array, &path)) {
+ l_free(l_queue_remove_if(network->bss_list, match_path, path));
+ l_queue_push_head(network->bss_list, l_strdup(path));
+ }
+}
+
+static const char *get_ess(const void *data)
+{
+ const struct network *network = data;
+ static char count[10];
+
+ snprintf(count, 10, "Count %u", l_queue_length(network->bss_list));
+
+ return count;
+}
+
+struct l_queue *network_get_bss_list(
+ const struct proxy_interface *network_proxy)
+{
+ const struct network *network = proxy_interface_get_data(network_proxy);
+ if (!network)
+ return NULL;
+
+ return network->bss_list;
+}
+
static const struct proxy_interface_property network_properties[] = {
{ "Name", "s", update_name, get_name },
{ "Connected", "b", update_connected},
{ "Device", "o", update_device},
{ "Type", "s", update_type},
+ { "ExtendedServiceSet", "ao", update_ess, get_ess },
{ }
};
@@ -186,6 +234,7 @@ static void network_destroy(void *data)
l_free(network->name);
l_free(network->type);
l_free(network->identity);
+ l_queue_destroy(network->bss_list, l_free);
network->device = NULL;
diff --git a/client/network.h b/client/network.h
index 41624749..56d74e3f 100644
--- a/client/network.h
+++ b/client/network.h
@@ -37,3 +37,5 @@ char *network_name_completion(const struct proxy_interface *device,
struct l_queue *network_match_by_device_and_args(
const struct proxy_interface *device,
const struct network_args *args);
+struct l_queue *network_get_bss_list(
+ const struct proxy_interface *network_proxy);
--
2.34.1
next prev parent reply other threads:[~2024-08-08 17:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 17:42 [PATCH v2 01/13] dbus: Add net.connman.iwd.BasicServiceSet interface James Prestwood
2024-08-08 17:42 ` [PATCH v2 02/13] network: Add BasicServiceSet object James Prestwood
2024-08-08 17:42 ` [PATCH v2 03/13] station: use network_bss_{start,stop}_update James Prestwood
2024-08-08 17:42 ` [PATCH v2 04/13] network: add ExtendedServiceSet DBus property James Prestwood
2024-08-08 17:42 ` [PATCH v2 05/13] network: remove network_bss_list_clear James Prestwood
2024-08-08 17:42 ` [PATCH v2 06/13] station: add ConnectedAccessPoint property James Prestwood
2024-08-08 17:42 ` [PATCH v2 07/13] doc: document BasicServiceSet API James Prestwood
2024-08-08 17:42 ` [PATCH v2 08/13] client: separate property header and values into two functions James Prestwood
2024-08-08 17:42 ` [PATCH v2 09/13] client: add net.connman.iwd.BasicServiceSet definition James Prestwood
2024-08-08 17:42 ` James Prestwood [this message]
2024-08-08 17:42 ` [PATCH v2 11/13] client: add BasicServiceSet interface James Prestwood
2024-08-08 17:42 ` [PATCH v2 12/13] client: refactor cmd_connect() and add find_network() James Prestwood
2024-08-08 17:42 ` [PATCH v2 13/13] client: add station command "get-bsses" James Prestwood
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=20240808174236.218750-10-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/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