mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 02:19:26 +01:00
knownnetworks: Add lookup API for recent frequencies
The returned scan_freq_set contains the known frequencies from the top most recently connected networks.
This commit is contained in:
parent
02b3ab6793
commit
5c9138ed7d
@ -39,6 +39,7 @@
|
||||
#include "src/network.h"
|
||||
#include "src/dbus.h"
|
||||
#include "src/knownnetworks.h"
|
||||
#include "src/scan.h"
|
||||
|
||||
static struct l_queue *known_networks;
|
||||
static size_t num_known_hidden_networks;
|
||||
@ -205,6 +206,43 @@ struct network_info *known_networks_find(const char *ssid,
|
||||
return l_queue_find(known_networks, network_info_match, &query);
|
||||
}
|
||||
|
||||
struct scan_freq_set *known_networks_get_recent_frequencies(
|
||||
uint8_t num_networks_tosearch)
|
||||
{
|
||||
/*
|
||||
* This search function assumes that the known networks are always
|
||||
* sorted by the last connection time with the most recent ones being on
|
||||
* top. Therefore, we just need to get the top NUM of networks from the
|
||||
* list.
|
||||
*/
|
||||
const struct l_queue_entry *network_entry;
|
||||
const struct l_queue_entry *freq_entry;
|
||||
struct scan_freq_set *set;
|
||||
|
||||
if (!num_networks_tosearch)
|
||||
return NULL;
|
||||
|
||||
set = scan_freq_set_new();
|
||||
|
||||
for (network_entry = l_queue_get_entries(known_networks);
|
||||
network_entry && num_networks_tosearch;
|
||||
network_entry = network_entry->next,
|
||||
num_networks_tosearch--) {
|
||||
const struct network_info *network = network_entry->data;
|
||||
|
||||
for (freq_entry = l_queue_get_entries(
|
||||
network->known_frequencies);
|
||||
freq_entry; freq_entry = freq_entry->next) {
|
||||
const struct known_frequency *known_freq =
|
||||
freq_entry->data;
|
||||
|
||||
scan_freq_set_add(set, known_freq->frequency);
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
static struct l_dbus_message *known_network_forget(struct l_dbus *dbus,
|
||||
struct l_dbus_message *message,
|
||||
void *user_data)
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
enum security;
|
||||
struct network_info;
|
||||
struct scan_freq_set;
|
||||
|
||||
typedef bool (*known_networks_foreach_func_t)(const struct network_info *info,
|
||||
void *user_data);
|
||||
@ -37,3 +38,6 @@ struct network_info *known_networks_find(const char *ssid,
|
||||
enum security security);
|
||||
|
||||
const char *known_network_get_path(const struct network_info *network);
|
||||
|
||||
struct scan_freq_set *known_networks_get_recent_frequencies(
|
||||
uint8_t num_networks_tosearch);
|
||||
|
Loading…
Reference in New Issue
Block a user