diff --git a/src/util.c b/src/util.c index ebaff6a0..dfee77fa 100644 --- a/src/util.c +++ b/src/util.c @@ -554,3 +554,24 @@ uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set, 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; +} diff --git a/src/util.h b/src/util.h index 6315198a..cc45059f 100644 --- a/src/util.h +++ b/src/util.h @@ -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); uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set, 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);