From 22ab0e73a2a5b60ebf5314b60a129202e3a577d8 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 6 Oct 2015 15:23:09 -0500 Subject: [PATCH] scan: Add scan_freq_set_get_bands --- src/scan.c | 16 ++++++++++++++++ src/scan.h | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/scan.c b/src/scan.c index a6f81f34..12d2f305 100644 --- a/src/scan.c +++ b/src/scan.c @@ -1144,6 +1144,22 @@ bool scan_freq_set_contains(struct scan_freq_set *freqs, uint32_t freq) return false; } +uint32_t scan_freq_set_get_bands(struct scan_freq_set *freqs) +{ + uint32_t bands = 0; + uint32_t max; + + if (freqs->channels_2ghz) + bands |= SCAN_BAND_2_4_GHZ; + + max = l_uintset_get_max(freqs->channels_5ghz); + + if (l_uintset_find_min(freqs->channels_5ghz) <= max) + bands |= SCAN_BAND_5_GHZ; + + return bands; +} + bool scan_init(struct l_genl_family *in) { nl80211 = in; diff --git a/src/scan.h b/src/scan.h index 662295a2..32da4e74 100644 --- a/src/scan.h +++ b/src/scan.h @@ -28,8 +28,8 @@ enum scan_ssid_security { }; enum scan_band { - SCAN_BAND_2_4_GHZ, - SCAN_BAND_5_GHZ, + SCAN_BAND_2_4_GHZ = 0x1, + SCAN_BAND_5_GHZ = 0x2, }; enum scan_state { @@ -98,6 +98,7 @@ struct scan_freq_set *scan_freq_set_new(void); void scan_freq_set_free(struct scan_freq_set *freqs); bool scan_freq_set_add(struct scan_freq_set *freqs, uint32_t freq); 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); bool scan_ifindex_add(uint32_t ifindex); bool scan_ifindex_remove(uint32_t ifindex);