* [PATCH v2 2/3] scan: add scan_freq_set_serialize
@ 2021-11-30 17:48 James Prestwood
0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2021-11-30 17:48 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]
This serializes a scan_freq_set into a uint32_t array.
---
src/util.c | 33 +++++++++++++++++++++++++++++++++
src/util.h | 2 ++
2 files changed, 35 insertions(+)
diff --git a/src/util.c b/src/util.c
index 381894f4..c0d5e258 100644
--- a/src/util.c
+++ b/src/util.c
@@ -470,3 +470,36 @@ void scan_freq_set_constrain(struct scan_freq_set *set,
set->channels_2ghz &= constraint->channels_2ghz;
}
+
+static void add_foreach(uint32_t freq, void *user_data)
+{
+ uint32_t **list = user_data;
+
+ **list = freq;
+
+ *list = *list + 1;
+}
+
+uint32_t *scan_freq_set_to_fixed_array(const struct scan_freq_set *set,
+ size_t *len_out)
+{
+ uint8_t count = 0;
+ uint32_t *freqs;
+
+ count = __builtin_popcount(set->channels_2ghz) +
+ l_uintset_count(set->channels_5ghz);
+
+ if (!count)
+ return NULL;
+
+ freqs = l_new(uint32_t, count);
+
+ scan_freq_set_foreach(set, add_foreach, &freqs);
+
+ /* Move pointer back to start of list */
+ freqs -= count;
+
+ *len_out = count;
+
+ return freqs;
+}
diff --git a/src/util.h b/src/util.h
index 8cced9cd..b55a7ea7 100644
--- a/src/util.h
+++ b/src/util.h
@@ -115,5 +115,7 @@ void scan_freq_set_merge(struct scan_freq_set *to,
void scan_freq_set_constrain(struct scan_freq_set *set,
const struct scan_freq_set *constraint);
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);
#endif /* __UTIL_H */
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 2/3] scan: add scan_freq_set_serialize
@ 2021-11-30 18:26 Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2021-11-30 18:26 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
Hi James,
On 11/30/21 11:48 AM, James Prestwood wrote:
> This serializes a scan_freq_set into a uint32_t array.
Looks like you didn't update 'serialize' to _fixed_array in the commit header.
> ---
> src/util.c | 33 +++++++++++++++++++++++++++++++++
> src/util.h | 2 ++
> 2 files changed, 35 insertions(+)
>
Please respin to use l_uintset_size.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-30 18:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30 17:48 [PATCH v2 2/3] scan: add scan_freq_set_serialize James Prestwood
-- strict thread matches above, loose matches on Subject: below --
2021-11-30 18:26 Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox