[PATCH 3/4] NAN: Add force_conditional_sched testing option
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Jun 4 00:01:10 PDT 2026
Allow forcing NDP schedule to use conditional time bitmap instead of
committed for testing purposes.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
wpa_supplicant/nan_supplicant.c | 48 ++++++++++++++++++++++---------
wpa_supplicant/wpa_supplicant_i.h | 3 ++
2 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index b842293dfc..47a83560d5 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -1928,6 +1928,11 @@ int wpas_nan_set(struct wpa_supplicant *wpa_s, char *cmd)
nan_de_set_tx_mcast_follow_up_prot(wpa_s->nan_de, val);
return 0;
}
+
+ if (os_strcmp("force_conditional_sched", cmd) == 0) {
+ wpa_s->nan_force_conditional_sched = !!atoi(param);
+ return 0;
+ }
#endif /* CONFIG_TESTING_OPTIONS */
if (os_strcmp("max_ndl_idle_period", cmd) == 0) {
@@ -2412,6 +2417,7 @@ wpas_nan_fill_ndp_schedule_chan(struct wpa_supplicant *wpa_s,
const struct nan_schedule_channel *chan)
{
struct nan_chan_schedule *chan_sched;
+ struct nan_time_bitmap *tbm;
const u8 *bitmap_data;
size_t bitmap_len;
@@ -2439,11 +2445,21 @@ wpas_nan_fill_ndp_schedule_chan(struct wpa_supplicant *wpa_s,
chan_sched->chan.center_freq2 = chan->center_freq2;
chan_sched->chan.bandwidth = chan->bandwidth;
- chan_sched->committed.duration = wpa_s->nan_capa.slot_duration >> 5;
- chan_sched->committed.period = ffs(wpa_s->nan_capa.schedule_period) - 7;
- chan_sched->committed.offset = 0;
- chan_sched->committed.len = bitmap_len;
- os_memcpy(chan_sched->committed.bitmap, bitmap_data, bitmap_len);
+ tbm = &chan_sched->committed;
+#ifdef CONFIG_TESTING_OPTIONS
+ if (wpa_s->nan_force_conditional_sched) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Using conditional TBM for schedule channel");
+ tbm = &chan_sched->conditional;
+ }
+#endif /* CONFIG_TESTING_OPTIONS */
+
+ tbm->duration = wpa_s->nan_capa.slot_duration >> 5;
+ tbm->period = ffs(wpa_s->nan_capa.schedule_period) - 7;
+ tbm->offset = 0;
+ tbm->len = bitmap_len;
+ os_memcpy(tbm->bitmap, bitmap_data, bitmap_len);
+
wpa_printf(MSG_DEBUG,
"NAN: NDP schedule channel added: map_id=%d freq=%d center_freq1=%d center_freq2=%d bandwidth=%d",
chan_sched->map_id,
@@ -2559,6 +2575,7 @@ static int wpas_nan_select_ndc_copy_peers(struct wpa_supplicant *wpa_s,
static int wpas_nan_select_ndc(struct wpa_supplicant *wpa_s,
struct nan_ndp_params *ndp)
{
+ struct nan_time_bitmap *tbm;
int i;
/* NDC attribute in request is optional, let the peer decide */
@@ -2570,8 +2587,15 @@ static int wpas_nan_select_ndc(struct wpa_supplicant *wpa_s,
ndp->u.resp.status == NAN_NDP_STATUS_ACCEPTED)
return wpas_nan_select_ndc_copy_peers(wpa_s, ndp);
- os_memcpy(&ndp->sched.ndc, &ndp->sched.chans[0].committed,
- sizeof(ndp->sched.ndc));
+ tbm = &ndp->sched.chans[0].committed;
+#ifdef CONFIG_TESTING_OPTIONS
+ if (wpa_s->nan_force_conditional_sched) {
+ wpa_printf(MSG_DEBUG, "NAN: Using conditional TBM for NDC selection");
+ tbm = &ndp->sched.chans[0].conditional;
+ }
+#endif /* CONFIG_TESTING_OPTIONS */
+
+ os_memcpy(&ndp->sched.ndc, tbm, sizeof(ndp->sched.ndc));
os_memset(ndp->sched.ndc.bitmap, 0, sizeof(ndp->sched.ndc.bitmap));
ndp->sched.ndc_map_id = ndp->sched.chans[0].map_id;
@@ -2590,14 +2614,13 @@ static int wpas_nan_select_ndc(struct wpa_supplicant *wpa_s,
byte_idx = dw_bit / 8;
bit_in_byte = dw_bit % 8;
- if (ndp->sched.chans[0].committed.bitmap[byte_idx] &
- BIT(bit_in_byte)) {
+ if (tbm->bitmap[byte_idx] & BIT(bit_in_byte)) {
ndp->sched.ndc.bitmap[byte_idx] = BIT(bit_in_byte);
return 0;
}
} else if (ndp->sched.chans[0].chan.freq == 2437 &&
wpa_s->nan_capa.slot_duration == 16) {
- if (ndp->sched.chans[0].committed.bitmap[0] & 0x02) {
+ if (tbm->bitmap[0] & 0x02) {
ndp->sched.ndc.bitmap[0] = 0x02;
return 0;
}
@@ -2605,10 +2628,9 @@ static int wpas_nan_select_ndc(struct wpa_supplicant *wpa_s,
/* For other cases, select the first available slot */
for (i = 0; i < NAN_TIME_BITMAP_MAX_LEN; i++) {
- if (ndp->sched.chans[0].committed.bitmap[i]) {
+ if (tbm->bitmap[i]) {
ndp->sched.ndc.bitmap[i] =
- ndp->sched.chans[0].committed.bitmap[i] &
- (~ndp->sched.chans[0].committed.bitmap[i] + 1);
+ tbm->bitmap[i] & (~tbm->bitmap[i] + 1);
break;
}
}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index c2f42143e2..0d59c31ae6 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -1756,6 +1756,9 @@ struct wpa_supplicant {
struct nan_channels nan_override_potential_avail;
unsigned int nan_ndi_ndp_refcount; /* Active NDP count on this NDI */
struct nan_gtk ndi_gtk;
+#ifdef CONFIG_TESTING_OPTIONS
+ bool nan_force_conditional_sched;
+#endif /* CONFIG_TESTING_OPTIONS */
#endif /* CONFIG_NAN */
#ifdef CONFIG_ENC_ASSOC
bool assoc_resp_encrypted; /* Whether (Re)Association Response frame
--
2.53.0
More information about the Hostap
mailing list