[PATCH 20/92] NAN: Handle PASN auth frame Tx status
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Wed Apr 22 05:23:11 PDT 2026
From: Avraham Stern <avraham.stern at intel.com>
Add a function to handle the PASN auth frame Tx status and trigger
the pairing result after the last PASN frame.
Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
src/nan/nan.h | 25 ++++++++++++++++++++
src/nan/nan_pairing.c | 55 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/src/nan/nan.h b/src/nan/nan.h
index 41a24ab8c9..90ada88959 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -606,6 +606,22 @@ struct nan_config {
* Returns: 0 on success, -1 on failure
*/
int (*send_pasn)(void *ctx, const u8 *data, size_t data_len);
+
+ /**
+ * pairing_status_cb - Callback for reporting NAN pairing result
+ *
+ * @ctx: Callback context from cb_ctx
+ * @peer_addr: Peer NAN device address
+ * @akmp: AKMP used in the pairing
+ * @cipher: Cipher used in the pairing
+ * @status: Status of the pairing (WLAN_STATUS_* )
+ * @ptk: Derived PTK for the pairing (valid only if status is success)
+ * Returns: 0 if status is WLAN_STATUS_SUCCESS and the key was
+ * installed successfully or status is
+ * WLAN_STATUS_UNSPECIFIED_FAILURE, -1 otherwise
+ */
+ int (*pairing_result_cb)(void *ctx, const u8 *peer_addr, int akmp,
+ int cipher, u8 status, struct wpa_ptk *ptk);
};
struct nan_data * nan_init(const struct nan_config *cfg);
@@ -682,6 +698,8 @@ int nan_pairing_initiate_pasn_auth(struct nan_data *nan_data, const u8 *addr,
u8 auth_mode, int cipher, int handle,
u8 peer_instance_id, bool responder,
const char *password);
+int nan_pairing_pasn_auth_tx_status(struct nan_data *nan, const u8 *data,
+ size_t data_len, bool acked);
#else
static inline int nan_pairing_add_attrs(struct nan_data *nan_data,
struct wpabuf *buf)
@@ -697,6 +715,13 @@ int nan_pairing_initiate_pasn_auth(struct nan_data *nan_data, const u8 *addr,
{
return -1;
}
+
+static inline int nan_pairing_pasn_auth_tx_status(struct nan_data *nan,
+ const u8 *data,
+ size_t data_len, bool acked)
+{
+ return -1;
+}
#endif /* CONFIG_PASN */
#endif /* NAN_H */
diff --git a/src/nan/nan_pairing.c b/src/nan/nan_pairing.c
index 3fb32631b0..c3a7d44245 100644
--- a/src/nan/nan_pairing.c
+++ b/src/nan/nan_pairing.c
@@ -436,3 +436,58 @@ int nan_pairing_initiate_pasn_auth(struct nan_data *nan_data, const u8 *addr,
return ret;
}
+
+
+/*
+ * nan_pairing_pasn_auth_tx_status - Handle PASN authentication frame TX status
+ *
+ * @nan: Pointer to NAN data structure
+ * @data: Pointer to the transmitted frame data
+ * @data_len: Length of the transmitted frame data in bytes
+ * @acked: Boolean indicating whether the frame was acknowledged
+ *
+ * This function processes the transmission status of a PASN authentication
+ * frame used in NAN pairing and triggers the pairing result callback in case
+ * PASN is done.
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int nan_pairing_pasn_auth_tx_status(struct nan_data *nan, const u8 *data,
+ size_t data_len, bool acked)
+{
+ int ret = 0;
+ struct nan_peer *peer;
+ struct pasn_data *pasn;
+ const struct ieee80211_mgmt *mgmt =
+ (const struct ieee80211_mgmt *) data;
+
+ if (!nan || !data ||
+ data_len < offsetof(struct ieee80211_mgmt, u.auth.variable))
+ return -1;
+
+ peer = nan_get_peer(nan, mgmt->da);
+ if (!peer || !peer->pairing.pasn) {
+ wpa_printf(MSG_DEBUG, "NAN: Pairing: Peer not found " MACSTR,
+ MAC2STR(mgmt->da));
+ return -1;
+ }
+
+ pasn = peer->pairing.pasn;
+
+ ret = wpa_pasn_auth_tx_status(pasn, data, data_len, acked);
+ if (ret == 1) {
+ ret = nan->cfg->pairing_result_cb(nan->cfg->cb_ctx,
+ peer->nmi_addr,
+ pasn->akmp, pasn->cipher,
+ pasn->status, &pasn->ptk);
+ if (pasn->status != WLAN_STATUS_SUCCESS || ret < 0) {
+ nan_pairing_deinit_peer(peer);
+ return -1;
+ }
+ }
+
+ wpabuf_free(pasn->frame);
+ pasn->frame = NULL;
+
+ return 0;
+}
--
2.53.0
More information about the Hostap
mailing list