mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-16 17:09:24 +01:00
network: Move known_frequency queue management
Isolate the known_frequency queue management to a function and place that function in knownnetworks.c where it now belongs. Since we no longer have network_info objects for unknown networks, only frequencies for known networks are tracked
This commit is contained in:
parent
67eeb0386d
commit
227bcce40b
@ -276,6 +276,37 @@ struct scan_freq_set *known_networks_get_recent_frequencies(
|
||||
return set;
|
||||
}
|
||||
|
||||
static bool known_frequency_match(const void *a, const void *b)
|
||||
{
|
||||
const struct known_frequency *known_freq = a;
|
||||
const uint32_t *frequency = b;
|
||||
|
||||
return known_freq->frequency == *frequency;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a frequency to the 'known' set of frequencies that this network
|
||||
* operates on. The list is sorted according to most-recently seen
|
||||
*/
|
||||
int known_network_add_frequency(struct network_info *info, uint32_t frequency)
|
||||
{
|
||||
struct known_frequency *known_freq;
|
||||
|
||||
if (!info->known_frequencies)
|
||||
info->known_frequencies = l_queue_new();
|
||||
|
||||
known_freq = l_queue_remove_if(info->known_frequencies,
|
||||
known_frequency_match, &frequency);
|
||||
if (!known_freq) {
|
||||
known_freq = l_new(struct known_frequency, 1);
|
||||
known_freq->frequency = frequency;
|
||||
}
|
||||
|
||||
l_queue_push_head(info->known_frequencies, known_freq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct l_dbus_message *known_network_forget(struct l_dbus *dbus,
|
||||
struct l_dbus_message *message,
|
||||
void *user_data)
|
||||
|
@ -42,3 +42,4 @@ 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);
|
||||
int known_network_add_frequency(struct network_info *info, uint32_t frequency);
|
||||
|
@ -592,36 +592,14 @@ void network_connect_failed(struct network *network)
|
||||
l_queue_clear(network->blacklist, NULL);
|
||||
}
|
||||
|
||||
static bool known_frequency_match(const void *a, const void *b)
|
||||
{
|
||||
const struct known_frequency *known_freq = a;
|
||||
const uint32_t *frequency = b;
|
||||
|
||||
return known_freq->frequency == *frequency;
|
||||
}
|
||||
|
||||
bool network_bss_add(struct network *network, struct scan_bss *bss)
|
||||
{
|
||||
struct known_frequency *known_freq;
|
||||
|
||||
if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare,
|
||||
NULL))
|
||||
return false;
|
||||
|
||||
if (network->info) {
|
||||
if (!network->info->known_frequencies)
|
||||
network->info->known_frequencies = l_queue_new();
|
||||
|
||||
known_freq = l_queue_remove_if(network->info->known_frequencies,
|
||||
known_frequency_match,
|
||||
&bss->frequency);
|
||||
if (!known_freq) {
|
||||
known_freq = l_new(struct known_frequency, 1);
|
||||
known_freq->frequency = bss->frequency;
|
||||
}
|
||||
|
||||
l_queue_push_head(network->info->known_frequencies, known_freq);
|
||||
}
|
||||
if (network->info)
|
||||
known_network_add_frequency(network->info, bss->frequency);
|
||||
|
||||
if (!util_mem_is_zero(bss->hessid, 6))
|
||||
memcpy(network->hessid, bss->hessid, 6);
|
||||
|
Loading…
Reference in New Issue
Block a user