[PATCH 18/35] nl80211: Config address and register mgmt frames on NAN iface

Andrei Otcheretianski andrei.otcheretianski at intel.com
Mon Oct 20 05:27:53 PDT 2025


Register for management frames on NAN management interface. In addition
allow MAC address configuration.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
 src/drivers/driver_nl80211.c | 44 ++++++++++++++++++++++++++++++++----
 1 file changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1391bfa62d..dea5c32993 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2725,6 +2725,42 @@ static int nl80211_register_action_frame(struct i802_bss *bss,
 }
 
 
+#define NAN_PUB_ACTION ((u8 *) "\x04\x09\x50\x6f\x9a\x13")
+
+static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
+{
+#ifdef CONFIG_NAN
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+
+	if (!(drv->capa.nan_flags &
+	      WPA_DRIVER_FLAGS_NAN_SUPPORT_USERSPACE_DE)) {
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: User space DE is not supported, don't subscribe to NAN public action frames");
+		return 0;
+	}
+
+	if (nl80211_alloc_mgmt_handle(bss))
+		return -1;
+
+	wpa_printf(MSG_DEBUG,
+		   "nl80211: Subscribe to mgmt frames for NAN with handle %p",
+		   bss->nl_mgmt);
+
+	/* NAN SDF Public Action */
+	if (nl80211_register_action_frame2(bss, NAN_PUB_ACTION, 6, true)) {
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: Failed to subscribe to NAN public action frames");
+		nl_destroy_handles(&bss->nl_mgmt);
+		return -1;
+	}
+
+	nl80211_mgmt_handle_register_eloop(bss);
+
+#endif /* CONFIG_NAN */
+
+	return 0;
+}
+
 static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -2797,7 +2833,6 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss)
 		ret = -1;
 #endif /* CONFIG_P2P */
 #ifdef CONFIG_NAN_USD
-#define NAN_PUB_ACTION ((u8 *) "\x04\x09\x50\x6f\x9a\x13")
 	/* NAN SDF Public Action */
 	if (nl80211_register_action_frame2(bss, NAN_PUB_ACTION, 6, true) < 0) {
 		/* fallback to non-multicast */
@@ -2805,7 +2840,6 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss)
 						   false) < 0)
 			ret = -1;
 	}
-#undef NAN_PUB_ACTION
 #endif /* CONFIG_NAN_USD */
 #ifdef CONFIG_DPP
 	/* DPP Public Action */
@@ -6462,7 +6496,8 @@ static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 	if (nla_put_flag(msg, NL80211_ATTR_IFACE_SOCKET_OWNER))
 		goto fail;
 
-	if ((addr && iftype == NL80211_IFTYPE_P2P_DEVICE) &&
+	if ((addr && (iftype == NL80211_IFTYPE_P2P_DEVICE ||
+		      iftype == NL80211_IFTYPE_NAN)) &&
 	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr))
 		goto fail;
 
@@ -7961,9 +7996,8 @@ done:
 	    nl80211_mgmt_subscribe_mesh(bss))
 		return -1;
 
-	/* TODO: Register to NAN management frames */
 	if (nlmode == NL80211_IFTYPE_NAN)
-		return 0;
+		return nl80211_mgmt_subscribe_nan(bss);
 
 	if (!bss->in_deinit && !is_ap_interface(nlmode) &&
 	    !is_mesh_interface(nlmode) &&
-- 
2.49.0




More information about the Hostap mailing list