From 07e6876ef54c7bc508e861fb620e69bdd365e227 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 16 Sep 2019 13:14:13 -0700 Subject: [PATCH] knownnetworks: add roam frequency getter Gets a newly created scan_freq_set containing the most recent frequencies for the network. The currently connected BSS frequency (passed as a parameters) will not be included in the set. --- src/knownnetworks.c | 30 ++++++++++++++++++++++++++++++ src/knownnetworks.h | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index 28a85c7a..3d4a411e 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -271,6 +271,36 @@ void network_info_set_uuid(struct network_info *info, const uint8_t *uuid) info->has_uuid = true; } +struct scan_freq_set *network_info_get_roam_frequencies( + const struct network_info *info, + uint32_t current_freq, + uint8_t max) +{ + struct scan_freq_set *freqs; + const struct l_queue_entry *entry; + + freqs = scan_freq_set_new(); + + for (entry = l_queue_get_entries(info->known_frequencies); entry && max; + entry = entry->next) { + struct known_frequency *kn = entry->data; + + if (kn->frequency == current_freq) + continue; + + scan_freq_set_add(freqs, kn->frequency); + + max--; + } + + if (scan_freq_set_isempty(freqs)) { + scan_freq_set_free(freqs); + return NULL; + } + + return freqs; +} + bool network_info_match_hessid(const struct network_info *info, const uint8_t *hessid) { diff --git a/src/knownnetworks.h b/src/knownnetworks.h index 54397562..12008cae 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -108,6 +108,10 @@ const struct iovec *network_info_get_extra_ies(const struct network_info *info, /* Gets the UUID, or generates one if not yet created */ const uint8_t *network_info_get_uuid(struct network_info *info); void network_info_set_uuid(struct network_info *info, const uint8_t *uuid); +struct scan_freq_set *network_info_get_roam_frequencies( + const struct network_info *info, + uint32_t current_freq, + uint8_t max); bool network_info_match_hessid(const struct network_info *info, const uint8_t *hessid);