commit c44da224706b8d394232bbc64faa99124bda7f50
parent 5be3de74840deca082ae0e936c1d373fb48bfb19
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Thu, 11 Apr 2019 12:14:27 -0700
wiphy: Add freq set constrain API
Diffstat:
4 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/scan.c b/src/scan.c
@@ -1725,6 +1725,23 @@ void scan_freq_set_foreach(const struct scan_freq_set *freqs,
}
}
+void scan_freq_set_constrain(struct scan_freq_set *set,
+ const struct scan_freq_set *constraint)
+{
+ struct l_uintset *intersection;
+
+ intersection = l_uintset_intersect(constraint->channels_5ghz,
+ set->channels_5ghz);
+ if (!intersection)
+ /* This shouldn't ever be the case. */
+ return;
+
+ l_uintset_free(set->channels_5ghz);
+ set->channels_5ghz = intersection;
+
+ set->channels_2ghz &= constraint->channels_2ghz;
+}
+
bool scan_init(struct l_genl_family *in)
{
const struct l_settings *config = iwd_get_config();
diff --git a/src/scan.h b/src/scan.h
@@ -126,6 +126,8 @@ 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);
+void scan_freq_set_constrain(struct scan_freq_set *set,
+ const struct scan_freq_set *constraint);
bool scan_ifindex_add(uint32_t ifindex);
bool scan_ifindex_remove(uint32_t ifindex);
diff --git a/src/wiphy.c b/src/wiphy.c
@@ -306,6 +306,18 @@ bool wiphy_supports_adhoc_rsn(struct wiphy *wiphy)
return wiphy->support_adhoc_rsn;
}
+bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
+ struct scan_freq_set *set)
+{
+ scan_freq_set_constrain(set, wiphy->supported_freqs);
+
+ if (!scan_freq_set_get_bands(set))
+ /* The set is empty. */
+ return false;
+
+ return true;
+}
+
static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask)
{
uint16_t supported_mask = wiphy->supported_iftypes & mask;
diff --git a/src/wiphy.h b/src/wiphy.h
@@ -25,6 +25,7 @@
struct wiphy;
struct scan_bss;
+struct scan_freq_set;
enum wiphy_state_watch_event {
WIPHY_STATE_WATCH_EVENT_POWERED,
@@ -50,6 +51,9 @@ struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name);
bool wiphy_destroy(struct wiphy *wiphy);
void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg);
+bool wiphy_constrain_freq_set(const struct wiphy *wiphy,
+ struct scan_freq_set *set);
+
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(