[PATCH 47/92] wpa_supplicant: Add NAN-NIK-RECEIVED notification

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


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

Add a control interface notification for a received NAN NIK. The
notification includes the NIK, its version and lifetime, used AKMP
and the associated PMK.

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

diff --git a/src/common/wpa_ctrl.h b/src/common/wpa_ctrl.h
index e7aae67fa4..31ca1529cc 100644
--- a/src/common/wpa_ctrl.h
+++ b/src/common/wpa_ctrl.h
@@ -254,6 +254,7 @@ extern "C" {
 #define NAN_BOOTSTRAP_REQUEST "NAN-BOOTSTRAP-REQUEST "
 #define NAN_BOOTSTRAP_SUCCESS "NAN-BOOTSTRAP-SUCCESS "
 #define NAN_BOOTSTRAP_FAILURE "NAN-BOOTSTRAP-FAILURE "
+#define NAN_NIK_RECEIVED "NAN-NIK-RECEIVED "
 
 /* NAN Pairing status
  * <peer address> akmp=<SAE|PASN> cipher=<CCMP|GCMP-256> status=<success|failure>
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index 29c1a2163e..769208f7c5 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -949,6 +949,11 @@ static int wpas_nan_update_pairing_credentials_cb(void *ctx, const u8 *nik,
 
 	wpa_printf(MSG_INFO, "NAN: Stored NIK as device identity (id=%d)",
 		   ik->id);
+
+	/* Notify control interface about received NIK */
+	wpas_notify_nan_nik_received(wpa_s, nik, nik_len, cipher_ver, akmp,
+				     npk, npk_len, nik_lifetime, ik->id);
+
 	return ik->id;
 
 fail:
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 3ebba574bb..b5a81cc564 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -1241,6 +1241,41 @@ void wpas_notify_nan_bootstrap_failure(struct wpa_supplicant *wpa_s,
 		       MAC2STR(peer_nmi), pbm, reason);
 }
 
+
+void wpas_notify_nan_nik_received(struct wpa_supplicant *wpa_s,
+				  const u8 *nik, size_t nik_len,
+				  int cipher_ver, int akmp,
+				  const u8 *npk, size_t npk_len,
+				  int nik_lifetime, int identity_id)
+{
+	char *nik_hex, *npk_hex;
+
+	nik_hex = os_malloc(2 * nik_len + 1);
+	npk_hex = os_malloc(2 * npk_len + 1);
+
+	if (!nik_hex || !npk_hex) {
+		wpa_printf(MSG_ERROR,
+			   "NAN NIK received: Failed to allocate memory");
+		goto out;
+	}
+
+	wpa_snprintf_hex(nik_hex, 2 * nik_len + 1, nik, nik_len);
+	wpa_snprintf_hex(npk_hex, 2 * npk_len + 1, npk, npk_len);
+
+	wpa_msg_global(wpa_s, MSG_INFO,
+		       NAN_NIK_RECEIVED "nik=%s cipher_version=%d akmp=%s "
+		       "pmk=%s lifetime=%d identity_id=%d",
+		       nik_hex, cipher_ver,
+		       wpa_key_mgmt_txt(akmp, WPA_PROTO_RSN),
+		       npk_hex, nik_lifetime, identity_id);
+
+	os_memset(nik_hex, 0, 2 * nik_len + 1);
+	os_memset(npk_hex, 0, 2 * npk_len + 1);
+out:
+	os_free(nik_hex);
+	os_free(npk_hex);
+}
+
 #endif /* CONFIG_NAN || CONFIG_NAN_USD */
 
 
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index e51562986d..c3e8ef933a 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -205,6 +205,11 @@ void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
 void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
 					  int subscribe_id,
 					  enum nan_de_reason reason);
+void wpas_notify_nan_nik_received(struct wpa_supplicant *wpa_s,
+				  const u8 *nik, size_t nik_len,
+				  int cipher_ver, int akmp,
+				  const u8 *npk, size_t npk_len,
+				  int nik_lifetime, int identity_id);
 void wpas_notify_pr_pasn_result(struct wpa_supplicant *wpa_s, u8 role,
 				u8 protocol_type, u8 op_class, u8 op_channel,
 				const char *country);
-- 
2.53.0




More information about the Hostap mailing list