[PATCH 29/92] wpa_supplicant: Implement the NAN pairing result callback

Andrei Otcheretianski andrei.otcheretianski at intel.com
Wed Apr 22 05:23:20 PDT 2026


From: Avraham Stern <avraham.stern at intel.com>

When the NAN module reports the pairing result, print an event
with the peer address, the used AKMP and the PASN status.

Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
 src/common/wpa_ctrl.h           |  7 ++++++
 wpa_supplicant/nan_supplicant.c | 39 +++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index f726be6c37..e7aae67fa4 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -255,6 +255,13 @@ extern "C" {
 #define NAN_BOOTSTRAP_SUCCESS "NAN-BOOTSTRAP-SUCCESS "
 #define NAN_BOOTSTRAP_FAILURE "NAN-BOOTSTRAP-FAILURE "
 
+/* NAN Pairing status
+ * <peer address> akmp=<SAE|PASN> cipher=<CCMP|GCMP-256> status=<success|failure>
+ */
+#define NAN_PAIRING_STATUS "NAN-PAIRING-STATUS "
+
+
+
 /* MESH events */
 #define MESH_GROUP_STARTED "MESH-GROUP-STARTED "
 #define MESH_GROUP_REMOVED "MESH-GROUP-REMOVED "
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index aef545b691..68605d65b6 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -854,6 +854,44 @@ static int wpas_nan_pasn_send_cb(void *ctx, const u8 *data, size_t data_len)
 
 	return wpa_drv_send_mlme(wpa_s, data, data_len, 0, 0, 0);
 }
+
+static int wpas_nan_pasn_auth_status_cb(void *ctx, const u8 *peer_addr,
+					int akmp, int cipher, u8 status,
+					struct wpa_ptk *ptk)
+{
+	struct wpa_supplicant *wpa_s = ctx;
+	enum wpa_alg alg;
+	u8 seq[6];
+
+	wpa_msg_global(wpa_s, MSG_INFO,
+		       NAN_PAIRING_STATUS MACSTR " akmp=%s cipher=%s status=%s",
+		       MAC2STR(peer_addr),
+		       wpa_key_mgmt_txt(akmp, WPA_PROTO_RSN),
+		       wpa_cipher_txt(cipher),
+		       status == WLAN_STATUS_SUCCESS ? "success" : "failure");
+
+	if (status != WLAN_STATUS_SUCCESS)
+		return 0;
+
+	if (!ptk) {
+		wpa_printf(MSG_DEBUG,
+			   "NAN: No PTK provided after pairing with peer "
+			   MACSTR, MAC2STR(peer_addr));
+		return -1;
+	}
+
+	alg = cipher == WPA_CIPHER_CCMP ? WPA_ALG_CCMP : WPA_ALG_GCMP_256;
+	os_memset(seq, 0, sizeof(seq));
+	if (wpa_drv_set_key(wpa_s, -1, alg, peer_addr, 0, 1, seq, sizeof(seq),
+			    ptk->tk, ptk->tk_len, KEY_FLAG_PAIRWISE_RX_TX)) {
+		wpa_printf(MSG_DEBUG,
+			   "NAN: Failed to install NM-TK for peer " MACSTR,
+			   MAC2STR(peer_addr));
+		return -1;
+	}
+
+	return 0;
+}
 #endif /* CONFIG_PASN */
 
 
@@ -877,6 +915,7 @@ int wpas_nan_init(struct wpa_supplicant *wpa_s)
 	nan.update_config = wpas_nan_update_config_cb;
 #ifdef CONFIG_PASN
 	nan.send_pasn = wpas_nan_pasn_send_cb;
+	nan.pairing_result_cb = wpas_nan_pasn_auth_status_cb;
 #endif /* CONFIG_PASN */
 
 	/* NDP */
-- 
2.53.0




More information about the Hostap mailing list