[PATCH 48/97] NAN: Add a testing configuration for protected NAN multicast follow up
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Apr 28 13:05:49 PDT 2026
From: Ilan Peer <ilan.peer at intel.com>
Add a testing configuration, that when enabled would send NAN
multicast follow up frames as dual protected.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/common/nan_de.c | 40 +++++++++++++++++++++++++++++++--
src/common/nan_de.h | 2 ++
wpa_supplicant/nan_supplicant.c | 9 ++++++++
3 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/src/common/nan_de.c b/src/common/nan_de.c
index 0e2fb8a854..f9715a0cdc 100644
--- a/src/common/nan_de.c
+++ b/src/common/nan_de.c
@@ -130,6 +130,15 @@ struct nan_de {
/* RSSI threshold for close proximity, or zero if not limited */
int rssi_threshold;
+
+#ifdef CONFIG_TESTING_OPTIONS
+ /*
+ * When set, multicast follow up SDFs would be sent as
+ * Protected Dual of Public. This can be used to test protection
+ * of NAN multicast management frames.
+ */
+ bool tx_mcast_fu_dual_prot;
+#endif /* CONFIG_TESTING_OPTIONS */
};
@@ -249,8 +258,10 @@ static void nan_de_unpause_state(struct nan_de_service *srv)
srv->sel_peer_id = 0;
}
+
static struct wpabuf * nan_de_alloc_sdf(struct nan_de *de, const u8 *dst,
- size_t len)
+ size_t len,
+ enum nan_service_control_type type)
{
struct wpabuf *buf;
u8 category = WLAN_ACTION_PUBLIC;
@@ -258,6 +269,16 @@ static struct wpabuf * nan_de_alloc_sdf(struct nan_de *de, const u8 *dst,
if (de->cb.is_peer_paired && de->cb.is_peer_paired(de->cb.ctx, dst))
category = WLAN_ACTION_PROTECTED_DUAL;
+#ifdef CONFIG_TESTING_OPTIONS
+ if (de->tx_mcast_fu_dual_prot &&
+ is_multicast_ether_addr(dst) &&
+ type == NAN_SRV_CTRL_FOLLOW_UP) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Send multicast followup as protected DUAL");
+ category = WLAN_ACTION_PROTECTED_DUAL;
+ }
+#endif /* CONFIG_TESTING_OPTIONS */
+
buf = wpabuf_alloc(2 + 4 + len);
if (buf) {
wpabuf_put_u8(buf, category);
@@ -378,7 +399,7 @@ static void nan_de_tx_sdf(struct nan_de *de, struct nan_de_service *srv,
list_len * (sizeof(struct nan_sec_ctxt) + PMKID_LEN);
}
- buf = nan_de_alloc_sdf(de, dst, len);
+ buf = nan_de_alloc_sdf(de, dst, len, type);
if (!buf)
return;
@@ -2623,3 +2644,18 @@ bool nan_de_service_supports_csid(struct nan_de *de, int handle, int csid)
/* Check if the CSID is in the service's cipher suite list */
return int_array_includes(srv->cipher_suites_list, csid);
}
+
+#ifdef CONFIG_TESTING_OPTIONS
+
+void nan_de_set_tx_mcast_fu_dual_prot(struct nan_de *de,
+ bool tx_mcast_fu_dual_prot)
+{
+ wpa_printf(MSG_DEBUG,
+ "NAN: Set tx_mcast_follow_up_dual_prot: %u->%u",
+ de->tx_mcast_fu_dual_prot,
+ tx_mcast_fu_dual_prot);
+
+ de->tx_mcast_fu_dual_prot = tx_mcast_fu_dual_prot;
+}
+
+#endif /* CONFIG_TESTING_OPTIONS */
diff --git a/src/common/nan_de.h b/src/common/nan_de.h
index e376725191..3acda64a44 100644
--- a/src/common/nan_de.h
+++ b/src/common/nan_de.h
@@ -273,6 +273,8 @@ bool nan_de_is_valid_instance_id(struct nan_de *de, int handle,
bool publish, u8 *service_id);
u16 nan_de_get_service_bootstrap_methods(struct nan_de *de, int handle);
bool nan_de_service_supports_csid(struct nan_de *de, int handle, int csid);
+void nan_de_set_tx_mcast_fu_dual_prot(struct nan_de *de,
+ bool tx_mcast_fu_dual_prot);
int nan_de_stop_listen(struct nan_de *de, int handle);
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 4acd636c32..2559613d7f 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -1673,6 +1673,15 @@ int wpas_nan_set(struct wpa_supplicant *wpa_s, char *cmd)
return nan_set_mgmt_group_cipher(wpa_s->nan, cipher);
}
+#ifdef CONFIG_TESTING_OPTIONS
+ if (os_strcmp("tx_mcast_fu_dual_prot", cmd) == 0) {
+ bool val = !!atoi(param);
+
+ nan_de_set_tx_mcast_fu_dual_prot(wpa_s->nan_de, val);
+ return 0;
+ }
+#endif /* CONFIG_TESTING_OPTIONS */
+
wpa_printf(MSG_INFO, "NAN: Unknown NAN_SET cmd='%s'", cmd);
return -1;
}
--
2.53.0
More information about the Hostap
mailing list