eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit d03b06db85a777f91c12368b2f50cd421740ce41
parent 4b3e82f742a92e441f8c63b8b7a80e16eec13893
Author: James Prestwood <prestwoj@gmail.com>
Date:   Fri, 26 Jan 2024 12:22:40 -0800

network: add network_update_known_frequencies

In order to support an ordered list of known frequencies the list
should be in order of last seen BSS frequencies with the highest
ranked ones first. To accomplish this without adding a lot of
complexity the frequencies can be pushed into the list as long as
they are pushed in reverse rank order (lowest rank first, highest
last). This ensures that very high ranked BSS's will always get
superseded by subsequent scans if not seen.

This adds a new network API to update the known frequency list
based on the current newtork->bss_list. This assumes that station
always wipes the BSS list on scans and populates with only fresh
BSS entries. After the scan this API can be called and it will
reverse the list, then add each frequency.

Diffstat:
Msrc/network.c | 37++++++++++++++++++++++++++++---------
Msrc/network.h | 2++
2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/network.c b/src/network.c @@ -802,21 +802,13 @@ const struct network_info *network_get_info(const struct network *network) return network->info; } -static void add_known_frequency(void *data, void *user_data) -{ - struct scan_bss *bss = data; - struct network_info *info = user_data; - - known_network_add_frequency(info, bss->frequency); -} - void network_set_info(struct network *network, struct network_info *info) { if (info) { network->info = info; network->info->seen_count++; - l_queue_foreach(network->bss_list, add_known_frequency, info); + network_update_known_frequencies(network); } else { network->info->seen_count--; network->info = NULL; @@ -1087,6 +1079,33 @@ static bool match_hotspot_network(const struct network_info *info, return true; } +bool network_update_known_frequencies(struct network *network) +{ + const struct l_queue_entry *e; + struct l_queue *reversed; + + if (!network->info) + return false; + + reversed = l_queue_new(); + + for (e = l_queue_get_entries(network->bss_list); e; e = e->next) { + struct scan_bss *bss = e->data; + + l_queue_push_head(reversed, bss); + } + + for (e = l_queue_get_entries(reversed); e; e = e->next) { + struct scan_bss *bss = e->data; + + known_network_add_frequency(network->info, bss->frequency); + } + + l_queue_destroy(reversed, NULL); + + return true; +} + bool network_bss_add(struct network *network, struct scan_bss *bss) { if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare, diff --git a/src/network.h b/src/network.h @@ -61,6 +61,8 @@ void network_set_info(struct network *network, struct network_info *info); void network_set_force_default_owe_group(struct network *network); bool network_get_force_default_owe_group(struct network *network); +bool network_update_known_frequencies(struct network *network); + int network_can_connect_bss(struct network *network, const struct scan_bss *bss); int network_autoconnect(struct network *network, struct scan_bss *bss);