* [PATCH 02/14] station: use network_bss_list_prune
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-08 14:29 ` Denis Kenzior
2024-08-07 18:14 ` [PATCH 03/14] network: remove network_bss_list_clear James Prestwood
` (11 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
Use this to clear only entires that were not found in the newest
scan results.
---
src/station.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/station.c b/src/station.c
index e373b03b..2c4d686b 100644
--- a/src/station.c
+++ b/src/station.c
@@ -943,7 +943,7 @@ void station_set_scan_results(struct station *station,
l_queue_foreach_remove(new_bss_list, bss_free_if_ssid_not_utf8, NULL);
while ((network = l_queue_pop_head(station->networks_sorted)))
- network_bss_list_clear(network);
+ network_bss_list_prune(network, new_bss_list);
l_queue_clear(station->hidden_bss_list_sorted, NULL);
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 02/14] station: use network_bss_list_prune
2024-08-07 18:14 ` [PATCH 02/14] station: use network_bss_list_prune James Prestwood
@ 2024-08-08 14:29 ` Denis Kenzior
2024-08-08 14:44 ` James Prestwood
0 siblings, 1 reply; 17+ messages in thread
From: Denis Kenzior @ 2024-08-08 14:29 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 8/7/24 1:14 PM, James Prestwood wrote:
> Use this to clear only entires that were not found in the newest
> scan results.
> ---
> src/station.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/station.c b/src/station.c
> index e373b03b..2c4d686b 100644
> --- a/src/station.c
> +++ b/src/station.c
> @@ -943,7 +943,7 @@ void station_set_scan_results(struct station *station,
> l_queue_foreach_remove(new_bss_list, bss_free_if_ssid_not_utf8, NULL);
>
> while ((network = l_queue_pop_head(station->networks_sorted)))
> - network_bss_list_clear(network);
> + network_bss_list_prune(network, new_bss_list);
You're sending the new list without vetting whether the SSID matches the
network. That will likely come to haunt you later.
>
> l_queue_clear(station->hidden_bss_list_sorted, NULL);
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 02/14] station: use network_bss_list_prune
2024-08-08 14:29 ` Denis Kenzior
@ 2024-08-08 14:44 ` James Prestwood
0 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-08 14:44 UTC (permalink / raw)
To: Denis Kenzior, iwd
Hi Denis,
On 8/8/24 7:29 AM, Denis Kenzior wrote:
> Hi James,
>
> On 8/7/24 1:14 PM, James Prestwood wrote:
>> Use this to clear only entires that were not found in the newest
>> scan results.
>> ---
>> src/station.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/station.c b/src/station.c
>> index e373b03b..2c4d686b 100644
>> --- a/src/station.c
>> +++ b/src/station.c
>> @@ -943,7 +943,7 @@ void station_set_scan_results(struct station
>> *station,
>> l_queue_foreach_remove(new_bss_list, bss_free_if_ssid_not_utf8,
>> NULL);
>> while ((network = l_queue_pop_head(station->networks_sorted)))
>> - network_bss_list_clear(network);
>> + network_bss_list_prune(network, new_bss_list);
>
> You're sending the new list without vetting whether the SSID matches
> the network. That will likely come to haunt you later.
Yes, one of several problems with this. Its also ~O(N^2) so with v2 I'll
be using a different approach. Slightly more optimized, and fixes the
issue you mentioned.
>
>> l_queue_clear(station->hidden_bss_list_sorted, NULL);
> Regards,
> -Denis
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 03/14] network: remove network_bss_list_clear
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
2024-08-07 18:14 ` [PATCH 02/14] station: use network_bss_list_prune James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 04/14] dbus: Add net.connman.iwd.BasicServiceSet interface James Prestwood
` (10 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
src/network.c | 6 ------
src/network.h | 1 -
2 files changed, 7 deletions(-)
diff --git a/src/network.c b/src/network.c
index 6d7e5ec4..c63d53b8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1184,12 +1184,6 @@ bool network_bss_list_isempty(struct network *network)
return l_queue_isempty(network->bss_list);
}
-void network_bss_list_clear(struct network *network)
-{
- l_queue_destroy(network->bss_list, NULL);
- network->bss_list = l_queue_new();
-}
-
struct network_prune_data {
struct network *network;
struct l_queue *new_list;
diff --git a/src/network.h b/src/network.h
index be81c150..29bc57ee 100644
--- a/src/network.h
+++ b/src/network.h
@@ -70,7 +70,6 @@ void network_connect_failed(struct network *network, bool in_handshake);
bool network_bss_add(struct network *network, struct scan_bss *bss);
bool network_bss_update(struct network *network, struct scan_bss *bss);
bool network_bss_list_isempty(struct network *network);
-void network_bss_list_clear(struct network *network);
void network_bss_list_prune(struct network *network, struct l_queue *new_list);
struct scan_bss *network_bss_list_pop(struct network *network);
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 04/14] dbus: Add net.connman.iwd.BasicServiceSet interface
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
2024-08-07 18:14 ` [PATCH 02/14] station: use network_bss_list_prune James Prestwood
2024-08-07 18:14 ` [PATCH 03/14] network: remove network_bss_list_clear James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 05/14] network: implement net.connman.iwd.BasicServiceSet James Prestwood
` (9 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
src/dbus.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/dbus.h b/src/dbus.h
index b43412d7..14814b5d 100644
--- a/src/dbus.h
+++ b/src/dbus.h
@@ -48,6 +48,7 @@
#define IWD_NETCONFIG_AGENT_INTERFACE \
"net.connman.iwd.NetworkConfigurationAgent"
#define IWD_SHARED_CODE_AGENT_INTERFACE "net.connman.iwd.SharedCodeAgent"
+#define IWD_BSS_INTERFACE "net.connman.iwd.BasicServiceSet"
#define IWD_BASE_PATH "/net/connman/iwd"
#define IWD_AGENT_MANAGER_PATH IWD_BASE_PATH
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 05/14] network: implement net.connman.iwd.BasicServiceSet
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (2 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 04/14] dbus: Add net.connman.iwd.BasicServiceSet interface James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 06/14] network: add BasicServiceSets property on the network object James Prestwood
` (8 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This ties the addition/removal of scan_bss objects from a network
object to BasicServiceSet objects. If a "new" object is added when
one with the same address already existed, no DBus object changes
are made (only the user data is updated with the new scan_bss).
Currently the only property on a BasicServiceSet object is the
"Bssid".
---
src/network.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++---
src/network.h | 2 ++
2 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/src/network.c b/src/network.c
index c63d53b8..e3f5bee8 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1136,13 +1136,64 @@ static bool match_addr(const void *a, const void *b)
return memcmp(bss->addr, b, 6) == 0;
}
+const char *network_bss_get_path(struct network *network,
+ struct scan_bss *bss)
+{
+ static char path[256];
+
+ snprintf(path, sizeof(path), "%s/%02x%02x%02x%02x%02x%02x",
+ network->object_path, MAC_STR(bss->addr));
+
+ return path;
+}
+
+static bool network_unregister_bss(void *a, void *user_data)
+{
+ struct scan_bss *bss = a;
+ struct network *network = user_data;
+
+ l_dbus_unregister_object(dbus_get_bus(),
+ network_bss_get_path(network, bss));
+
+ return true;
+}
+
+static bool network_register_bss(struct network *network, struct scan_bss *bss,
+ bool update)
+{
+ const char *path = network_bss_get_path(network, bss);
+
+ if (update)
+ return l_dbus_object_set_data(dbus_get_bus(),
+ network_bss_get_path(network, bss),
+ IWD_BSS_INTERFACE, bss);
+
+ if (!l_dbus_object_add_interface(dbus_get_bus(), path,
+ IWD_BSS_INTERFACE, bss))
+ return false;
+
+ if (!l_dbus_object_add_interface(dbus_get_bus(), path,
+ L_DBUS_INTERFACE_PROPERTIES, bss))
+ return false;
+
+ return true;
+}
+
bool network_bss_add(struct network *network, struct scan_bss *bss)
{
- l_queue_remove_if(network->bss_list, match_addr, bss->addr);
+ bool removed = l_queue_remove_if(network->bss_list,
+ match_addr, bss->addr) != NULL;
+
+ if (!l_queue_insert(network->bss_list, bss,
+ scan_bss_rank_compare, NULL)) {
+ /* This is essentially impossible... */
+ if (L_WARN_ON(removed))
+ network_unregister_bss(bss, network);
- if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare,
- NULL))
return false;
+ }
+
+ L_WARN_ON(!network_register_bss(network, bss, removed));
/* Done if BSS is not HS20 or we already have network_info set */
if (!bss->hs20_capable)
@@ -1194,8 +1245,10 @@ static bool scan_bss_prune_missing(void *a, void *user_data)
struct scan_bss *bss = a;
struct network_prune_data *data = user_data;
- if (!l_queue_find(data->new_list, match_addr, bss->addr))
+ if (!l_queue_find(data->new_list, match_addr, bss->addr)) {
+ network_unregister_bss(bss, data->network);
return true;
+ }
return false;
}
@@ -1213,7 +1266,12 @@ void network_bss_list_prune(struct network *network, struct l_queue *new_list)
struct scan_bss *network_bss_list_pop(struct network *network)
{
- return l_queue_pop_head(network->bss_list);
+ struct scan_bss *bss = l_queue_pop_head(network->bss_list);
+
+ if (bss)
+ network_unregister_bss(bss, network);
+
+ return bss;
}
struct scan_bss *network_bss_find_by_addr(struct network *network,
@@ -1931,6 +1989,8 @@ void network_remove(struct network *network, int reason)
if (network->info)
network->info->seen_count -= 1;
+ l_queue_foreach_remove(network->bss_list,
+ network_unregister_bss, network);
l_queue_destroy(network->bss_list, NULL);
l_queue_destroy(network->blacklist, NULL);
@@ -2178,6 +2238,24 @@ static void setup_network_interface(struct l_dbus_interface *interface)
network_property_get_known_network, NULL);
}
+static bool network_bss_property_get_bssid(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_builder *builder,
+ void *user_data)
+{
+ struct scan_bss *bss = user_data;
+
+ l_dbus_message_builder_append_basic(builder, 's',
+ util_address_to_string(bss->addr));
+ return true;
+}
+
+static void setup_bss_interface(struct l_dbus_interface *interface)
+{
+ l_dbus_interface_property(interface, "Bssid", 0, "s",
+ network_bss_property_get_bssid, NULL);
+}
+
static int network_init(void)
{
if (!l_dbus_register_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE,
@@ -2185,6 +2263,11 @@ static int network_init(void)
l_error("Unable to register %s interface",
IWD_NETWORK_INTERFACE);
+ if (!l_dbus_register_interface(dbus_get_bus(), IWD_BSS_INTERFACE,
+ setup_bss_interface, NULL, false))
+ l_error("Unable to register %s interface",
+ IWD_BSS_INTERFACE);
+
known_networks_watch =
known_networks_watch_add(known_networks_changed, NULL, NULL);
@@ -2202,6 +2285,7 @@ static void network_exit(void)
event_watch = 0;
l_dbus_unregister_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE);
+ l_dbus_unregister_interface(dbus_get_bus(), IWD_BSS_INTERFACE);
}
IWD_MODULE(network, network_init, network_exit)
diff --git a/src/network.h b/src/network.h
index 29bc57ee..62ed834b 100644
--- a/src/network.h
+++ b/src/network.h
@@ -69,6 +69,8 @@ int network_autoconnect(struct network *network, struct scan_bss *bss);
void network_connect_failed(struct network *network, bool in_handshake);
bool network_bss_add(struct network *network, struct scan_bss *bss);
bool network_bss_update(struct network *network, struct scan_bss *bss);
+const char *network_bss_get_path(struct network *network,
+ struct scan_bss *bss);
bool network_bss_list_isempty(struct network *network);
void network_bss_list_prune(struct network *network, struct l_queue *new_list);
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 06/14] network: add BasicServiceSets property on the network object
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (3 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 05/14] network: implement net.connman.iwd.BasicServiceSet James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 07/14] station: add ConnectedBss property James Prestwood
` (7 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This will hold an array of object paths pointing to each
BasicServiceSet object.
---
src/network.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/network.c b/src/network.c
index e3f5bee8..de56eaaf 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1176,6 +1176,9 @@ static bool network_register_bss(struct network *network, struct scan_bss *bss,
L_DBUS_INTERFACE_PROPERTIES, bss))
return false;
+ l_dbus_property_changed(dbus_get_bus(), network->object_path,
+ IWD_NETWORK_INTERFACE, "BasicServiceSets");
+
return true;
}
@@ -1938,6 +1941,28 @@ static bool network_property_get_known_network(struct l_dbus *dbus,
return true;
}
+static bool network_property_get_basic_service_sets(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_builder *builder,
+ void *user_data)
+{
+ struct network *network = user_data;
+ const struct l_queue_entry *e;
+
+ l_dbus_message_builder_enter_array(builder, "o");
+
+ for (e = l_queue_get_entries(network->bss_list); e; e = e->next) {
+ struct scan_bss *bss = e->data;
+ const char *path = network_bss_get_path(network, bss);
+
+ l_dbus_message_builder_append_basic(builder, 'o', path);
+ }
+
+ l_dbus_message_builder_leave_array(builder);
+
+ return true;
+}
+
bool network_register(struct network *network, const char *path)
{
if (!l_dbus_object_add_interface(dbus_get_bus(), path,
@@ -2236,6 +2261,9 @@ static void setup_network_interface(struct l_dbus_interface *interface)
l_dbus_interface_property(interface, "KnownNetwork", 0, "o",
network_property_get_known_network, NULL);
+
+ l_dbus_interface_property(interface, "BasicServiceSets", 0, "ao",
+ network_property_get_basic_service_sets, NULL);
}
static bool network_bss_property_get_bssid(struct l_dbus *dbus,
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 07/14] station: add ConnectedBss property
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (4 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 06/14] network: add BasicServiceSets property on the network object James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 08/14] doc: document BasicServiceSet API James Prestwood
` (6 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This property is a path that corresponds to a BasicServiceSet
object, the one the station is currently connected to.
---
src/station.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/station.c b/src/station.c
index 2c4d686b..5a6360de 100644
--- a/src/station.c
+++ b/src/station.c
@@ -4363,6 +4363,23 @@ static bool station_property_get_connected_network(struct l_dbus *dbus,
return true;
}
+static bool station_property_get_connected_bss(struct l_dbus *dbus,
+ struct l_dbus_message *message,
+ struct l_dbus_message_builder *builder,
+ void *user_data)
+{
+ struct station *station = user_data;
+
+ if (!station->connected_network)
+ return false;
+
+ l_dbus_message_builder_append_basic(builder, 'o',
+ network_bss_get_path(station->connected_network,
+ station->connected_bss));
+
+ return true;
+}
+
static bool station_property_get_scanning(struct l_dbus *dbus,
struct l_dbus_message *message,
struct l_dbus_message_builder *builder,
@@ -4770,6 +4787,9 @@ static void station_setup_interface(struct l_dbus_interface *interface)
l_dbus_interface_property(interface, "ConnectedNetwork", 0, "o",
station_property_get_connected_network,
NULL);
+ l_dbus_interface_property(interface, "ConnectedBss", 0, "o",
+ station_property_get_connected_bss,
+ NULL);
l_dbus_interface_property(interface, "Scanning", 0, "b",
station_property_get_scanning, NULL);
l_dbus_interface_property(interface, "State", 0, "s",
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 08/14] doc: document BasicServiceSet API
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (5 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 07/14] station: add ConnectedBss property James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-08 14:42 ` Denis Kenzior
2024-08-07 18:14 ` [PATCH 09/14] client: separate property header and values into two functions James Prestwood
` (5 subsequent siblings)
12 siblings, 1 reply; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
doc/basic-service-set.txt | 10 ++++++++++
doc/network-api.txt | 5 +++++
doc/station-api.txt | 6 ++++++
3 files changed, 21 insertions(+)
create mode 100644 doc/basic-service-set.txt
diff --git a/doc/basic-service-set.txt b/doc/basic-service-set.txt
new file mode 100644
index 00000000..2ebb63be
--- /dev/null
+++ b/doc/basic-service-set.txt
@@ -0,0 +1,10 @@
+Basic service set hierarchy
+=================
+
+Service net.connman.iwd
+Interface net.connman.iwd.BasicServiceSet
+Object path /net/connman/iwd/{phy0,phy1,...}/{1,2,...}/Xxx
+
+Properties string Bssid [readonly]
+
+ MAC address of BSS
diff --git a/doc/network-api.txt b/doc/network-api.txt
index e4a34411..3aa68382 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -50,3 +50,8 @@ Properties string Name [readonly]
corresponding to this Network. If the network
is not provisioned or has not been connected to
before, the property is omitted.
+
+ a(o) BasicServiceSets [readonly]
+
+ Contains a list of paths of each individual
+ BasicServiceSet object.
diff --git a/doc/station-api.txt b/doc/station-api.txt
index 05dd137e..7b067620 100644
--- a/doc/station-api.txt
+++ b/doc/station-api.txt
@@ -164,6 +164,12 @@ Properties string State [readonly]
for networks. net.connman.iwd.Network objects are
updated when this property goes from true to false.
+ object ConnectedBss [readonly, optional]
+
+ net.connman.iwd.BasicServiceSet object represeting the
+ BSS the device is currently connected to or to which
+ a connection is in progress.
+
SignalLevelAgent hierarchy
==========================
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 08/14] doc: document BasicServiceSet API
2024-08-07 18:14 ` [PATCH 08/14] doc: document BasicServiceSet API James Prestwood
@ 2024-08-08 14:42 ` Denis Kenzior
0 siblings, 0 replies; 17+ messages in thread
From: Denis Kenzior @ 2024-08-08 14:42 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 8/7/24 1:14 PM, James Prestwood wrote:
> ---
> doc/basic-service-set.txt | 10 ++++++++++
> doc/network-api.txt | 5 +++++
> doc/station-api.txt | 6 ++++++
> 3 files changed, 21 insertions(+)
> create mode 100644 doc/basic-service-set.txt
>
> diff --git a/doc/basic-service-set.txt b/doc/basic-service-set.txt
> new file mode 100644
> index 00000000..2ebb63be
> --- /dev/null
> +++ b/doc/basic-service-set.txt
> @@ -0,0 +1,10 @@
> +Basic service set hierarchy
> +=================
> +
> +Service net.connman.iwd
> +Interface net.connman.iwd.BasicServiceSet
> +Object path /net/connman/iwd/{phy0,phy1,...}/{1,2,...}/Xxx
> +
> +Properties string Bssid [readonly]
Lets call this Address to be consistent with .Device,
.Station.GetHiddenAccessPoints, etc
> +
> + MAC address of BSS
> diff --git a/doc/network-api.txt b/doc/network-api.txt
> index e4a34411..3aa68382 100644
> --- a/doc/network-api.txt
> +++ b/doc/network-api.txt
> @@ -50,3 +50,8 @@ Properties string Name [readonly]
> corresponding to this Network. If the network
> is not provisioned or has not been connected to
> before, the property is omitted.
> +
> + a(o) BasicServiceSets [readonly]
Should just be ao, there's no encompassing structure. Lets just call this
ServiceSet maybe? Or ExtendedServiceSet if you want to use the spec terminology.
> +
> + Contains a list of paths of each individual
> + BasicServiceSet object.
> diff --git a/doc/station-api.txt b/doc/station-api.txt
> index 05dd137e..7b067620 100644
> --- a/doc/station-api.txt
> +++ b/doc/station-api.txt
> @@ -164,6 +164,12 @@ Properties string State [readonly]
> for networks. net.connman.iwd.Network objects are
> updated when this property goes from true to false.
>
> + object ConnectedBss [readonly, optional]
ConnectedBasicServiceSet? We also use AccessPoint terminology in
GetHiddenAccessPoints, so maybe ConnectedAccessPoint? This is Station after all.
> +
> + net.connman.iwd.BasicServiceSet object represeting the
> + BSS the device is currently connected to or to which
> + a connection is in progress.
> +
> SignalLevelAgent hierarchy
> ==========================
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 09/14] client: separate property header and values into two functions
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (6 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 08/14] doc: document BasicServiceSet API James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 10/14] client: add net.connman.iwd.BasicServiceSet definition James Prestwood
` (4 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
There are certain cases where we may not want to display the entire
header for a given set of properties. For example displaying a list
of proxy interfaces. Add finer control by separating out the header
and the prop/value display into two functions.
---
client/dbus-proxy.c | 38 +++++++++++++++++++++++++++++---------
client/dbus-proxy.h | 7 +++++++
2 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
index 42b8427f..1e50d902 100644
--- a/client/dbus-proxy.c
+++ b/client/dbus-proxy.c
@@ -47,10 +47,10 @@ static struct l_dbus *dbus;
static struct l_queue *proxy_interfaces;
static struct l_queue *proxy_interface_types;
-void proxy_properties_display(const struct proxy_interface *proxy,
- const char *caption, const char *margin,
- unsigned int name_column_width,
- unsigned int value_column_width)
+void proxy_properties_display_inline(const struct proxy_interface *proxy,
+ const char *margin,
+ unsigned int name_column_width,
+ unsigned int value_column_width)
{
const void *data;
const struct proxy_interface_property *properties;
@@ -59,11 +59,6 @@ void proxy_properties_display(const struct proxy_interface *proxy,
if (!proxy->type->properties)
return;
- display_table_header(caption, "%s%-*s %-*s %-*s", margin,
- 8, "Settable",
- name_column_width, "Property",
- value_column_width, "Value");
-
data = proxy_interface_get_data(proxy);
properties = proxy->type->properties;
@@ -82,6 +77,31 @@ void proxy_properties_display(const struct proxy_interface *proxy,
}
}
+void proxy_properties_display_header(const char *caption, const char *margin,
+ unsigned int name_column_width,
+ unsigned int value_column_width)
+{
+ display_table_header(caption, "%s%-*s %-*s %-*s", margin,
+ 8, "Settable",
+ name_column_width, "Property",
+ value_column_width, "Value");
+}
+
+void proxy_properties_display(const struct proxy_interface *proxy,
+ const char *caption, const char *margin,
+ unsigned int name_column_width,
+ unsigned int value_column_width)
+{
+ if (!proxy->type->properties)
+ return;
+
+ proxy_properties_display_header(caption, margin, name_column_width,
+ value_column_width);
+
+ proxy_properties_display_inline(proxy, margin, name_column_width,
+ value_column_width);
+}
+
static const void *proxy_interface_property_tostr(
const struct proxy_interface *proxy,
const char *name)
diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
index 98b0a2a4..f0a5d38a 100644
--- a/client/dbus-proxy.h
+++ b/client/dbus-proxy.h
@@ -95,6 +95,13 @@ void proxy_properties_display(const struct proxy_interface *proxy,
const char *caption, const char *margin,
unsigned int name_column_width,
unsigned int value_column_width);
+void proxy_properties_display_inline(const struct proxy_interface *proxy,
+ const char *margin,
+ unsigned int name_column_width,
+ unsigned int value_column_width);
+void proxy_properties_display_header(const char *caption, const char *margin,
+ unsigned int name_column_width,
+ unsigned int value_column_width);
char *proxy_property_str_completion(const struct proxy_interface_type *type,
proxy_property_match_func_t function,
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 10/14] client: add net.connman.iwd.BasicServiceSet definition
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (7 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 09/14] client: separate property header and values into two functions James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 11/14] client: Add BasicServiceSets property to network James Prestwood
` (3 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
client/dbus-proxy.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h
index f0a5d38a..32300f41 100644
--- a/client/dbus-proxy.h
+++ b/client/dbus-proxy.h
@@ -41,6 +41,7 @@ struct proxy_interface;
#define IWD_DPP_INTERFACE "net.connman.iwd.DeviceProvisioning"
#define IWD_DPP_PKEX_INTERFACE \
"net.connman.iwd.SharedCodeDeviceProvisioning"
+#define IWD_BSS_INTERFACE "net.connman.iwd.BasicServiceSet"
typedef bool (*proxy_property_match_func_t) (const void *a, const void *b);
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 11/14] client: Add BasicServiceSets property to network
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (8 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 10/14] client: add net.connman.iwd.BasicServiceSet definition James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 12/14] client: add BasicServiceSet interface James Prestwood
` (2 subsequent siblings)
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
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..2bb986ce 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_bss(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_bss(const void *data)
+{
+ const struct network *network = data;
+ static char count[4];
+
+ snprintf(count, 4, "%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},
+ { "BasicServiceSets", "ao", update_bss, get_bss },
{ }
};
@@ -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
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 12/14] client: add BasicServiceSet interface
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (9 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 11/14] client: Add BasicServiceSets property to network James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 13/14] client: refactor cmd_connect() and add find_network() James Prestwood
2024-08-07 18:14 ` [PATCH 14/14] client: add station command "get-bsses" James Prestwood
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
---
Makefile.am | 1 +
client/bss.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 client/bss.c
diff --git a/Makefile.am b/Makefile.am
index 0c152216..d438a5ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -319,6 +319,7 @@ client_iwctl_SOURCES = client/main.c \
client/daemon.c client/daemon.h \
client/dpp.c client/dpp-pkex.c \
client/station-debug.c \
+ client/bss.c \
src/util.c src/util.h \
src/band.c src/band.h
diff --git a/client/bss.c b/client/bss.c
new file mode 100644
index 00000000..273831a5
--- /dev/null
+++ b/client/bss.c
@@ -0,0 +1,110 @@
+/*
+ *
+ * Wireless daemon for Linux
+ *
+ * Copyright (C) 2024, Locus Robotics
+ *
+ * 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ell/ell.h>
+#include "ell/useful.h"
+
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/bss.h"
+
+struct bss {
+ char *bssid;
+};
+
+static const char *get_bssid(const void *data)
+{
+ const struct bss *bss = data;
+
+ return bss->bssid;
+}
+
+static void update_bssid(void *data, struct l_dbus_message_iter *variant)
+{
+ struct bss *bss = data;
+ const char *value;
+
+ l_free(bss->bssid);
+
+ if (!l_dbus_message_iter_get_variant(variant, "s", &value)) {
+ bss->bssid = NULL;
+
+ return;
+ }
+
+ bss->bssid = l_strdup(value);
+}
+
+static const struct proxy_interface_property bss_properties[] = {
+ { "Bssid", "s", update_bssid, get_bssid },
+ { }
+};
+
+static void *bss_create(void)
+{
+ return l_new(struct bss, 1);
+}
+
+static void bss_destroy(void *data)
+{
+ struct bss *bss = data;
+
+ l_free(bss->bssid);
+ l_free(bss);
+}
+
+static void bss_display_inline(const char *margin, const void *data)
+{
+ const struct bss *bss = data;
+
+ display("%s%s\n", margin, bss->bssid);
+}
+
+static const struct proxy_interface_type_ops ops = {
+ .create = bss_create,
+ .destroy = bss_destroy,
+ .display = bss_display_inline,
+};
+
+static struct proxy_interface_type bss_interface_type = {
+ .interface = IWD_BSS_INTERFACE,
+ .properties = bss_properties,
+ .ops = &ops,
+};
+
+static int bss_interface_init(void)
+{
+ proxy_interface_type_register(&bss_interface_type);
+
+ return 0;
+}
+
+static void bss_interface_exit(void)
+{
+ proxy_interface_type_unregister(&bss_interface_type);
+}
+
+INTERFACE_TYPE(bss_interface_type, bss_interface_init, bss_interface_exit)
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 13/14] client: refactor cmd_connect() and add find_network()
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (10 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 12/14] client: add BasicServiceSet interface James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
2024-08-07 18:14 ` [PATCH 14/14] client: add station command "get-bsses" James Prestwood
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This will do all the lookup/searching needed to find a network
proxy object.
---
client/station.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/client/station.c b/client/station.c
index affb7f15..58aac29e 100644
--- a/client/station.c
+++ b/client/station.c
@@ -283,28 +283,26 @@ static char *connect_cmd_arg_completion(const char *text, int state,
return network_name_completion(device, text, state);
}
-static enum cmd_status cmd_connect(const char *device_name,
- char **argv, int argc)
+static const struct proxy_interface *find_network(const char *device_name,
+ const char *name,
+ const char *type)
{
struct network_args network_args;
struct l_queue *match;
const struct proxy_interface *network_proxy;
const struct proxy_interface *device_proxy;
- if (argc < 1)
- return CMD_STATUS_INVALID_ARGS;
-
device_proxy = device_proxy_find_by_name(device_name);
if (!device_proxy)
- return CMD_STATUS_INVALID_VALUE;
+ return NULL;
- network_args.name = argv[0];
- network_args.type = argc >= 2 ? argv[1] : NULL;
+ network_args.name = name;
+ network_args.type = type;
match = network_match_by_device_and_args(device_proxy, &network_args);
if (!match) {
display("Invalid network name '%s'\n", network_args.name);
- return CMD_STATUS_INVALID_VALUE;
+ return NULL;
}
if (l_queue_length(match) > 1) {
@@ -315,11 +313,28 @@ static enum cmd_status cmd_connect(const char *device_name,
l_queue_destroy(match, NULL);
- return CMD_STATUS_INVALID_VALUE;
+ return NULL;
}
network_proxy = l_queue_pop_head(match);
l_queue_destroy(match, NULL);
+
+ return network_proxy;
+}
+
+static enum cmd_status cmd_connect(const char *device_name,
+ char **argv, int argc)
+{
+ const struct proxy_interface *network_proxy;
+
+ if (argc < 1)
+ return CMD_STATUS_INVALID_ARGS;
+
+ network_proxy = find_network(device_name, argv[0],
+ argc >= 2 ? argv[1] : NULL);
+ if (!network_proxy)
+ return CMD_STATUS_INVALID_VALUE;
+
network_connect(network_proxy);
return CMD_STATUS_TRIGGERED;
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 14/14] client: add station command "get-bsses"
2024-08-07 18:14 [PATCH 01/14] network: add network_bss_list_prune James Prestwood
` (11 preceding siblings ...)
2024-08-07 18:14 ` [PATCH 13/14] client: refactor cmd_connect() and add find_network() James Prestwood
@ 2024-08-07 18:14 ` James Prestwood
12 siblings, 0 replies; 17+ messages in thread
From: James Prestwood @ 2024-08-07 18:14 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This command will get the BasicServiceSet list for a given network.
If no network is supplied, its assumed to be the current network.
---
client/station.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/client/station.c b/client/station.c
index 58aac29e..5066a9f1 100644
--- a/client/station.c
+++ b/client/station.c
@@ -723,6 +723,55 @@ static enum cmd_status cmd_show(const char *device_name,
return CMD_STATUS_TRIGGERED;
}
+
+static enum cmd_status cmd_get_bsses(const char *device_name,
+ char **argv, int argc)
+{
+ const struct proxy_interface *station_i =
+ device_proxy_find(device_name, IWD_STATION_INTERFACE);
+ const struct station *station = proxy_interface_get_data(station_i);
+ struct l_queue *bss_list;
+ const struct l_queue_entry *e;
+ const struct proxy_interface *network_proxy;
+ char header[256];
+
+ if (argc > 0)
+ network_proxy = find_network(device_name, argv[0],
+ argc >= 2 ? argv[1] : NULL);
+ else
+ network_proxy = station->connected_network;
+
+ if (!network_proxy) {
+ display_error("Can't find network");
+ return CMD_STATUS_INVALID_ARGS;
+ }
+
+ bss_list = network_get_bss_list(network_proxy);
+ if (!bss_list) {
+ display_error("No BSS list for network");
+ return CMD_STATUS_FAILED;
+ }
+
+ sprintf(header, "%s BasicServiceSets", network_get_name(network_proxy));
+
+ proxy_properties_display_header(header, MARGIN, 10, 18);
+
+ for (e = l_queue_get_entries(bss_list); e; e = e->next) {
+ const char *path = e->data;
+ const struct proxy_interface *bss_i = proxy_interface_find(
+ IWD_BSS_INTERFACE, path);
+
+ if (!bss_i)
+ continue;
+
+ display_table_row(MARGIN, 1, strlen(path), path);
+ proxy_properties_display_inline(bss_i, MARGIN, 10, 18);
+ display_table_row(MARGIN, 1, 1, "");
+ }
+
+ return CMD_STATUS_DONE;
+}
+
static const struct command station_commands[] = {
{ NULL, "list", NULL, cmd_list, "List devices in Station mode", true },
{ "<wlan>", "connect",
@@ -747,6 +796,8 @@ static const struct command station_commands[] = {
"Get hidden APs", true },
{ "<wlan>", "scan", NULL, cmd_scan, "Scan for networks" },
{ "<wlan>", "show", NULL, cmd_show, "Show station info", true },
+ { "<wlan>", "get-bsses", "[network] [security]", cmd_get_bsses,
+ "Get BSS's for a network", true },
{ }
};
--
2.34.1
^ permalink raw reply related [flat|nested] 17+ messages in thread