mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 10:32:33 +01:00
network: Introduce a concept of known frequencies
Each known network (previously connected) will have a set of known frequencies associated with it, e.g. a set of frequencies from all BSSs observed. The list of known frequencies is sorted with the most recently observed frequency in the head.
This commit is contained in:
parent
8881910662
commit
c3e79a4f2a
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2016 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2016-2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -26,6 +26,10 @@ struct network_info;
|
||||
typedef bool (*known_networks_foreach_func_t)(const struct network_info *info,
|
||||
void *user_data);
|
||||
|
||||
struct known_frequency {
|
||||
uint32_t frequency;
|
||||
};
|
||||
|
||||
bool known_networks_foreach(known_networks_foreach_func_t function,
|
||||
void *user_data);
|
||||
bool known_networks_has_hidden(void);
|
||||
|
@ -259,6 +259,8 @@ void network_info_free(void *data)
|
||||
{
|
||||
struct network_info *network = data;
|
||||
|
||||
l_queue_destroy(network->known_frequencies, l_free);
|
||||
|
||||
l_free(network);
|
||||
}
|
||||
|
||||
@ -629,10 +631,35 @@ 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)
|
||||
{
|
||||
return l_queue_insert(network->bss_list, bss,
|
||||
scan_bss_rank_compare, NULL);
|
||||
struct known_frequency *known_freq;
|
||||
|
||||
if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare,
|
||||
NULL))
|
||||
return false;
|
||||
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool network_bss_list_isempty(struct network *network)
|
||||
|
@ -73,6 +73,7 @@ void network_blacklist_add(struct network *network, struct scan_bss *bss);
|
||||
struct network_info {
|
||||
char ssid[33];
|
||||
enum security type;
|
||||
struct l_queue *known_frequencies;
|
||||
struct timespec connected_time; /* Time last connected */
|
||||
int seen_count; /* Ref count for network.info */
|
||||
bool is_hidden:1;
|
||||
|
Loading…
Reference in New Issue
Block a user