[PATCH 72/92] nl80211: Register for NAFs and protected NAFs on NAN Data

Andrei Otcheretianski andrei.otcheretianski at intel.com
Wed Apr 22 05:24:03 PDT 2026


From: Ilan Peer <ilan.peer at intel.com>

Register for receiving NAFs and protected NAFs on NAN Data
interfaces, as this needs to be supported according to
the Wi-Fi Aware specification v4.0.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/drivers/driver_nl80211.c | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 5ca18ee71e..d13fbc5ec7 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -2732,8 +2732,10 @@ static int nl80211_register_action_frame(struct i802_bss *bss,
 #define NAN_SDF_ACTION ((const u8 *) "\x04\x09\x50\x6f\x9a\x13")
 #define NAN_PROTECTED_SDF_ACTION ((const u8 *) "\x09\x09\x50\x6f\x9a\x13")
 #define NAN_NAF_ACTION ((const u8 *) "\x04\x09\x50\x6f\x9a\x18")
+#define NAN_PROTECTED_NAF_ACTION ((const u8 *) "\x09\x09\x50\x6f\x9a\x18")
 
-static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
+static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss,
+				      enum nl80211_iftype nlmode)
 {
 #ifdef CONFIG_NAN
 	struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -2750,11 +2752,12 @@ static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
 		return -1;
 
 	wpa_printf(MSG_DEBUG,
-		   "nl80211: Subscribe to mgmt frames for NAN with handle %p",
-		   bss->nl_mgmt);
+		   "nl80211: Subscribe to mgmt frames for NAN with handle %p: nlmode=%u",
+		   bss->nl_mgmt, nlmode);
 
 	/* NAN SDF Public Action */
-	if (nl80211_register_action_frame2(bss, NAN_SDF_ACTION, 6, true) < 0) {
+	if (nlmode == NL80211_IFTYPE_NAN &&
+	    nl80211_register_action_frame2(bss, NAN_SDF_ACTION, 6, true) < 0) {
 		/* fallback to non-multicast */
 		if (nl80211_register_action_frame2(bss, NAN_SDF_ACTION, 6,
 						   false) < 0) {
@@ -2771,9 +2774,11 @@ static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
 		nl_destroy_handles(&bss->nl_mgmt);
 		return -1;
 	}
+
 #ifdef CONFIG_PASN
 	/* NAN SDF Public Action */
-	if (nl80211_register_action_frame2(bss, NAN_PROTECTED_SDF_ACTION, 6,
+	if (nlmode == NL80211_IFTYPE_NAN &&
+	    nl80211_register_action_frame2(bss, NAN_PROTECTED_SDF_ACTION, 6,
 					   true)) {
 		wpa_printf(MSG_DEBUG,
 			   "nl80211: Failed to subscribe to NAN PROTECTED SDFs");
@@ -2782,7 +2787,8 @@ static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
 	}
 
 	/* register for PASN Authentication frames */
-	if (nl80211_register_frame(bss, bss->nl_mgmt, type, (u8 *)"\x07\x00", 2,
+	if (nlmode == NL80211_IFTYPE_NAN &&
+	    nl80211_register_frame(bss, bss->nl_mgmt, type, (u8 *)"\x07\x00", 2,
 				   false)) {
 		wpa_printf(MSG_DEBUG,
 			   "nl80211: Failed to subscribe to NAN public action frames");
@@ -2791,6 +2797,15 @@ static int nl80211_mgmt_subscribe_nan(struct i802_bss *bss)
 	}
 #endif /* CONFIG_PASN */
 
+	/* NAF Public Action: protected dual */
+	if (nl80211_register_action_frame2(bss, NAN_PROTECTED_NAF_ACTION,
+					   6, true)) {
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: Failed to subscribe to Protected NAFs");
+		nl_destroy_handles(&bss->nl_mgmt);
+		return -1;
+	}
+
 	nl80211_mgmt_handle_register_eloop(bss);
 
 #endif /* CONFIG_NAN */
@@ -8189,8 +8204,9 @@ done:
 	    nl80211_mgmt_subscribe_mesh(bss))
 		return -1;
 
-	if (nlmode == NL80211_IFTYPE_NAN)
-		return nl80211_mgmt_subscribe_nan(bss);
+	if (nlmode == NL80211_IFTYPE_NAN ||
+	    nlmode == NL80211_IFTYPE_NAN_DATA)
+		return nl80211_mgmt_subscribe_nan(bss, nlmode);
 
 	if (!bss->in_deinit && !is_ap_interface(nlmode) &&
 	    !is_mesh_interface(nlmode) &&
@@ -9863,7 +9879,8 @@ static int wpa_driver_nl80211_send_action(struct i802_bss *bss,
 		offchanok = 0;
 
 	if (!freq && (is_sta_interface(drv->nlmode) ||
-		      drv->nlmode == NL80211_IFTYPE_NAN))
+		      drv->nlmode == NL80211_IFTYPE_NAN ||
+		      drv->nlmode == NL80211_IFTYPE_NAN_DATA))
 		offchanok = 0;
 
 	wpa_printf(MSG_DEBUG,
-- 
2.53.0




More information about the Hostap mailing list