3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +01:00

util: add scan_freq_set_clone

This creates a new scan_freq_set from an input set which only contains
frequencies from bands included in the mask.
This commit is contained in:
James Prestwood 2022-08-04 15:02:47 -07:00 committed by Denis Kenzior
parent 8c01edf74b
commit 0bc44a038b
2 changed files with 23 additions and 0 deletions

View File

@ -554,3 +554,24 @@ uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
return freqs; return freqs;
} }
struct scan_freq_set *scan_freq_set_clone(const struct scan_freq_set *set,
uint32_t band_mask)
{
struct scan_freq_set *new = l_new(struct scan_freq_set, 1);
if (band_mask & BAND_FREQ_2_4_GHZ)
new->channels_2ghz = set->channels_2ghz;
if (band_mask & BAND_FREQ_5_GHZ)
new->channels_5ghz = l_uintset_clone(set->channels_5ghz);
else
new->channels_5ghz = l_uintset_new_from_range(1, 200);
if (band_mask & BAND_FREQ_6_GHZ)
new->channels_6ghz = l_uintset_clone(set->channels_6ghz);
else
new->channels_6ghz = l_uintset_new_from_range(1, 233);
return new;
}

View File

@ -124,6 +124,8 @@ void scan_freq_set_subtract(struct scan_freq_set *set,
bool scan_freq_set_isempty(const struct scan_freq_set *set); bool scan_freq_set_isempty(const struct scan_freq_set *set);
uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set, uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
size_t *len_out); size_t *len_out);
struct scan_freq_set *scan_freq_set_clone(const struct scan_freq_set *set,
uint32_t band_mask);
DEFINE_CLEANUP_FUNC(scan_freq_set_free); DEFINE_CLEANUP_FUNC(scan_freq_set_free);