diff mbox series

[v4,1/3] util: add scan_freq_set_copy_bands

Message ID 20220804220249.508207-1-prestwoj@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [v4,1/3] util: add scan_freq_set_copy_bands | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-alpine-ci-incremental_build success Incremental Build with patches
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood Aug. 4, 2022, 10:02 p.m. UTC
This creates a new scan_freq_set from an input set which only contains
frequencies from bands included in the mask.
---
 src/util.c | 21 +++++++++++++++++++++
 src/util.h |  2 ++
 2 files changed, 23 insertions(+)

Comments

Denis Kenzior Aug. 5, 2022, 4:54 p.m. UTC | #1
Hi James,

On 8/4/22 17:02, James Prestwood wrote:
> This creates a new scan_freq_set from an input set which only contains
> frequencies from bands included in the mask.
> ---
>   src/util.c | 21 +++++++++++++++++++++
>   src/util.h |  2 ++
>   2 files changed, 23 insertions(+)

<snip>

> +struct scan_freq_set *scan_freq_set_copy_bands(const struct scan_freq_set *set,
> +						uint32_t band_mask);

I renamed this scan_freq_set_clone() and applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/util.c b/src/util.c
index ebaff6a0..64d85cbc 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_copy_bands(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 0b7832fb..9d3ec604 100644
--- a/src/util.h
+++ b/src/util.h
@@ -123,5 +123,7 @@  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_copy_bands(const struct scan_freq_set *set,
+						uint32_t band_mask);
 
 #endif /* __UTIL_H */