From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH v3 1/4] network: add network_update_known_frequencies
Date: Fri, 26 Jan 2024 12:22:40 -0800 [thread overview]
Message-ID: <20240126202243.91947-1-prestwoj@gmail.com> (raw)
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.
---
src/network.c | 40 ++++++++++++++++++++++++++++------------
src/network.h | 2 ++
2 files changed, 30 insertions(+), 12 deletions(-)
v4:
* Added an API to do the insertion once all the BSS's have been added
to the network object.
* I'm also ok adding something to ELL like:
l_queue_new_reverse(list);
The current reverse is in-place, so I cant really use it unless I
wanted to reverse twice to get it back to decending order.
diff --git a/src/network.c b/src/network.c
index 4723334e..287e2be0 100644
--- 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,15 +1079,39 @@ 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,
NULL))
return false;
- if (network->info)
- known_network_add_frequency(network->info, bss->frequency);
-
/* Done if BSS is not HS20 or we already have network_info set */
if (!bss->hs20_capable)
return true;
diff --git a/src/network.h b/src/network.h
index f29649f7..ea619f3f 100644
--- 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);
--
2.34.1
next reply other threads:[~2024-01-26 20:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 20:22 James Prestwood [this message]
2024-01-26 20:22 ` [PATCH v3 2/4] station: use network_update_known_frequencies James Prestwood
2024-01-26 20:22 ` [PATCH v3 3/4] station: knownnetworks: limit quick scans to 5 freqs per network James Prestwood
2024-01-26 20:22 ` [PATCH v3 4/4] auto-t: add test for known frequency sorting/maximum James Prestwood
2024-01-30 2:54 ` [PATCH v3 1/4] network: add network_update_known_frequencies Denis Kenzior
2024-01-30 12:30 ` 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=20240126202243.91947-1-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