From 405785cd0bcd4d056f5d9244aa74bbcebfa4efb5 Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Fri, 22 Mar 2019 14:17:44 -0700 Subject: [PATCH] scan: Add scan_freq_set_merge API --- src/scan.c | 16 ++++++++++++++++ src/scan.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/scan.c b/src/scan.c index 42d120ce..4b907481 100644 --- a/src/scan.c +++ b/src/scan.c @@ -1657,6 +1657,22 @@ uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs) return bands; } +static void scan_channels_5ghz_add(uint32_t channel, void *user_data) +{ + struct l_uintset *to = user_data; + + l_uintset_put(to, channel); +} + +void scan_freq_set_merge(struct scan_freq_set *to, + const struct scan_freq_set *from) +{ + to->channels_2ghz |= from->channels_2ghz; + + l_uintset_foreach(from->channels_5ghz, scan_channels_5ghz_add, + to->channels_5ghz); +} + struct channels_5ghz_foreach_data { scan_freq_set_func_t func; void *user_data; diff --git a/src/scan.h b/src/scan.h index 23c52ac0..f17aa227 100644 --- a/src/scan.h +++ b/src/scan.h @@ -123,6 +123,8 @@ bool scan_freq_set_contains(struct scan_freq_set *freqs, uint32_t freq); uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs); void scan_freq_set_foreach(const struct scan_freq_set *freqs, scan_freq_set_func_t func, void *user_data); +void scan_freq_set_merge(struct scan_freq_set *to, + const struct scan_freq_set *from); bool scan_ifindex_add(uint32_t ifindex); bool scan_ifindex_remove(uint32_t ifindex);