3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

client: Add BasicServiceSets property to network

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.
This commit is contained in:
James Prestwood 2024-08-12 08:46:10 -07:00 committed by Denis Kenzior
parent 0e3322b5da
commit 05166d0999
2 changed files with 51 additions and 0 deletions

View File

@ -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;

View File

@ -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);