diff mbox series

[4/8] wiphy: add wiphy_get_allowed_freqs

Message ID 20230925185422.2242494-4-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [1/8] scan: add [Rank].BandModifier2_4Ghz | expand

Commit Message

James Prestwood Sept. 25, 2023, 6:54 p.m. UTC
This is more or less copied from scan_get_allowed_freqs but is
going to be needed by station (basically just saves the need for
station to do the same clone/constrain sequence itself).

One slight alteration is now a band mask can be passed in which
provides more flexibility for additional filtering.
---
 src/wiphy.c | 15 +++++++++++++++
 src/wiphy.h |  2 ++
 2 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/src/wiphy.c b/src/wiphy.c
index ccff701e..dcd9e210 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -500,6 +500,21 @@  const struct scan_freq_set *wiphy_get_supported_freqs(
 	return wiphy->supported_freqs;
 }
 
+struct scan_freq_set *wiphy_get_allowed_freqs(const struct wiphy *wiphy,
+						uint32_t band_mask)
+{
+	struct scan_freq_set *allowed = scan_freq_set_clone(
+						wiphy->supported_freqs,
+						band_mask);
+
+	if (!wiphy_constrain_freq_set(wiphy, allowed)) {
+		scan_freq_set_free(allowed);
+		allowed = NULL;
+	}
+
+	return allowed;
+}
+
 static struct band *wiphy_get_band(const struct wiphy *wiphy, enum band_freq band)
 {
 	switch (band) {
diff --git a/src/wiphy.h b/src/wiphy.h
index 9f24d171..cabb21c4 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -100,6 +100,8 @@  const char *wiphy_get_path(struct wiphy *wiphy);
 uint32_t wiphy_get_supported_bands(struct wiphy *wiphy);
 const struct scan_freq_set *wiphy_get_supported_freqs(
 						const struct wiphy *wiphy);
+struct scan_freq_set *wiphy_get_allowed_freqs(const struct wiphy *wiphy,
+						uint32_t band_mask);
 
 const struct band_freq_attrs *wiphy_get_frequency_info(
 						const struct wiphy *wiphy,