mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-26 02:19:26 +01:00
station: Take scanned frequencies into account
Instead of manually managing whether to expire BSSes or not, use the scanned frequency set instead. This makes the API slightly easier to understand (dropping two boolean arguments in a row) and also a bit more future-proof.
This commit is contained in:
parent
ccbd32503b
commit
eac2410c83
@ -386,6 +386,7 @@ static bool bss_match(const void *a, const void *b)
|
|||||||
struct bss_expiration_data {
|
struct bss_expiration_data {
|
||||||
struct scan_bss *connected_bss;
|
struct scan_bss *connected_bss;
|
||||||
uint64_t now;
|
uint64_t now;
|
||||||
|
const struct scan_freq_set *freqs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCAN_RESULT_BSS_RETENTION_TIME (30 * 1000000)
|
#define SCAN_RESULT_BSS_RETENTION_TIME (30 * 1000000)
|
||||||
@ -399,6 +400,10 @@ static bool bss_free_if_expired(void *data, void *user_data)
|
|||||||
/* Do not expire the currently connected BSS. */
|
/* Do not expire the currently connected BSS. */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* Keep any BSSes that are not on the frequency list */
|
||||||
|
if (!scan_freq_set_contains(expiration_data->freqs, bss->frequency))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (l_time_before(expiration_data->now,
|
if (l_time_before(expiration_data->now,
|
||||||
bss->time_stamp + SCAN_RESULT_BSS_RETENTION_TIME))
|
bss->time_stamp + SCAN_RESULT_BSS_RETENTION_TIME))
|
||||||
return false;
|
return false;
|
||||||
@ -408,11 +413,13 @@ static bool bss_free_if_expired(void *data, void *user_data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void station_bss_list_remove_expired_bsses(struct station *station)
|
static void station_bss_list_remove_expired_bsses(struct station *station,
|
||||||
|
const struct scan_freq_set *freqs)
|
||||||
{
|
{
|
||||||
struct bss_expiration_data data = {
|
struct bss_expiration_data data = {
|
||||||
.now = l_time_now(),
|
.now = l_time_now(),
|
||||||
.connected_bss = station->connected_bss,
|
.connected_bss = station->connected_bss,
|
||||||
|
.freqs = freqs,
|
||||||
};
|
};
|
||||||
|
|
||||||
l_queue_foreach_remove(station->bss_list, bss_free_if_expired, &data);
|
l_queue_foreach_remove(station->bss_list, bss_free_if_expired, &data);
|
||||||
@ -612,9 +619,9 @@ static bool station_start_anqp(struct station *station, struct network *network,
|
|||||||
* inside station module or scans running in other state machines, e.g. wsc
|
* inside station module or scans running in other state machines, e.g. wsc
|
||||||
*/
|
*/
|
||||||
void station_set_scan_results(struct station *station,
|
void station_set_scan_results(struct station *station,
|
||||||
struct l_queue *new_bss_list,
|
struct l_queue *new_bss_list,
|
||||||
bool add_to_autoconnect,
|
const struct scan_freq_set *freqs,
|
||||||
bool expire)
|
bool add_to_autoconnect)
|
||||||
{
|
{
|
||||||
const struct l_queue_entry *bss_entry;
|
const struct l_queue_entry *bss_entry;
|
||||||
struct network *network;
|
struct network *network;
|
||||||
@ -628,8 +635,7 @@ void station_set_scan_results(struct station *station,
|
|||||||
l_queue_destroy(station->autoconnect_list, l_free);
|
l_queue_destroy(station->autoconnect_list, l_free);
|
||||||
station->autoconnect_list = l_queue_new();
|
station->autoconnect_list = l_queue_new();
|
||||||
|
|
||||||
if (expire)
|
station_bss_list_remove_expired_bsses(station, freqs);
|
||||||
station_bss_list_remove_expired_bsses(station);
|
|
||||||
|
|
||||||
for (bss_entry = l_queue_get_entries(station->bss_list); bss_entry;
|
for (bss_entry = l_queue_get_entries(station->bss_list); bss_entry;
|
||||||
bss_entry = bss_entry->next) {
|
bss_entry = bss_entry->next) {
|
||||||
@ -1029,7 +1035,7 @@ static bool new_scan_results(int err, struct l_queue *bss_list,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
autoconnect = station_is_autoconnecting(station);
|
autoconnect = station_is_autoconnecting(station);
|
||||||
station_set_scan_results(station, bss_list, autoconnect, true);
|
station_set_scan_results(station, bss_list, freqs, autoconnect);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1096,7 +1102,7 @@ static bool station_quick_scan_results(int err, struct l_queue *bss_list,
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
autoconnect = station_is_autoconnecting(station);
|
autoconnect = station_is_autoconnecting(station);
|
||||||
station_set_scan_results(station, bss_list, autoconnect, true);
|
station_set_scan_results(station, bss_list, freqs, autoconnect);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (station->state == STATION_STATE_AUTOCONNECT_QUICK)
|
if (station->state == STATION_STATE_AUTOCONNECT_QUICK)
|
||||||
@ -3012,11 +3018,10 @@ static bool station_dbus_scan_results(int err, struct l_queue *bss_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
autoconnect = station_is_autoconnecting(station);
|
autoconnect = station_is_autoconnecting(station);
|
||||||
|
station_set_scan_results(station, bss_list, freqs, autoconnect);
|
||||||
|
|
||||||
last_subset = next_idx >= L_ARRAY_SIZE(station->scan_freqs_order) ||
|
last_subset = next_idx >= L_ARRAY_SIZE(station->scan_freqs_order) ||
|
||||||
station->scan_freqs_order[next_idx] == NULL;
|
station->scan_freqs_order[next_idx] == NULL;
|
||||||
|
|
||||||
station_set_scan_results(station, bss_list, autoconnect, last_subset);
|
|
||||||
|
|
||||||
station->dbus_scan_subset_idx = next_idx;
|
station->dbus_scan_subset_idx = next_idx;
|
||||||
|
|
||||||
if (last_subset || !station_dbus_scan_subset(station))
|
if (last_subset || !station_dbus_scan_subset(station))
|
||||||
|
@ -27,6 +27,7 @@ struct netdev;
|
|||||||
struct station;
|
struct station;
|
||||||
enum security;
|
enum security;
|
||||||
struct scan_bss;
|
struct scan_bss;
|
||||||
|
struct scan_freq_set;
|
||||||
struct network;
|
struct network;
|
||||||
|
|
||||||
enum station_state {
|
enum station_state {
|
||||||
@ -65,7 +66,8 @@ struct network *station_network_find(struct station *station, const char *ssid,
|
|||||||
enum security security);
|
enum security security);
|
||||||
|
|
||||||
void station_set_scan_results(struct station *station, struct l_queue *bss_list,
|
void station_set_scan_results(struct station *station, struct l_queue *bss_list,
|
||||||
bool add_to_autoconnect, bool expire);
|
const struct scan_freq_set *freqs,
|
||||||
|
bool add_to_autoconnect);
|
||||||
|
|
||||||
enum station_state station_get_state(struct station *station);
|
enum station_state station_get_state(struct station *station);
|
||||||
uint32_t station_add_state_watch(struct station *station,
|
uint32_t station_add_state_watch(struct station *station,
|
||||||
|
@ -788,7 +788,7 @@ static bool push_button_scan_results(int err, struct l_queue *bss_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wsc_cancel_scan(wsc);
|
wsc_cancel_scan(wsc);
|
||||||
station_set_scan_results(wsc->station, bss_list, false, true);
|
station_set_scan_results(wsc->station, bss_list, freqs, false);
|
||||||
|
|
||||||
l_debug("Found AP to connect to: %s",
|
l_debug("Found AP to connect to: %s",
|
||||||
util_address_to_string(target->addr));
|
util_address_to_string(target->addr));
|
||||||
@ -934,7 +934,7 @@ static bool pin_scan_results(int err, struct l_queue *bss_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wsc_cancel_scan(wsc);
|
wsc_cancel_scan(wsc);
|
||||||
station_set_scan_results(wsc->station, bss_list, false, true);
|
station_set_scan_results(wsc->station, bss_list, freqs, false);
|
||||||
|
|
||||||
l_debug("Found AP to connect to: %s",
|
l_debug("Found AP to connect to: %s",
|
||||||
util_address_to_string(target->addr));
|
util_address_to_string(target->addr));
|
||||||
|
Loading…
Reference in New Issue
Block a user