[PATCH 39/58] NAN: Add a function for adding the CSIA attribute
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Thu Feb 19 12:24:55 PST 2026
From: Avraham Stern <avraham.stern at intel.com>
Add a function for adding the Cipher Suite Information attribute.
Signed-off-by: Avraham Stern <avraham.stern at intel.com>
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski at intel.com>
---
src/nan/nan_i.h | 2 ++
src/nan/nan_util.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h
index ccba63503c..8f64c3d332 100644
--- a/src/nan/nan_i.h
+++ b/src/nan/nan_i.h
@@ -586,4 +586,6 @@ int nan_crypto_key_mic(const u8 *buf, size_t len, const u8 *kck,
void nan_sec_reset(struct nan_data *nan, struct nan_ndp_sec *ndp_sec);
int nan_sec_rx(struct nan_data *nan, struct nan_peer *peer,
struct nan_msg *msg);
+int nan_add_csia(struct wpabuf *buf, u8 capab, size_t cs_list_len,
+ struct nan_cipher_suite *cs_list);
#endif /* NAN_I_H */
diff --git a/src/nan/nan_util.c b/src/nan/nan_util.c
index 7a7c276e50..840b39c4b0 100644
--- a/src/nan/nan_util.c
+++ b/src/nan/nan_util.c
@@ -343,6 +343,47 @@ void nan_add_dev_capa_attr(struct nan_data *nan, struct wpabuf *buf)
}
+/*
+ * nan_add_csia - Add Cipher Suite Information Attribute (CSIA) to a buffer
+ *
+ * @buf: Buffer to add the attribute to
+ * @capab: Capabilities field (1 octet)
+ * @cs_list_len: Number of cipher suites in the list
+ * @cs_list: Array of cipher suite structures (see &struct nan_cipher_suite)
+ *
+ * This function constructs and appends a NAN Cipher Suite Information Attribute
+ * to the provided buffer.
+ *
+ * Returns: 0 on success, -1 on failure (insufficient buffer space)
+ */
+int nan_add_csia(struct wpabuf *buf, u8 capab, size_t cs_list_len,
+ struct nan_cipher_suite *cs_list)
+{
+ size_t i;
+
+ /* Capabilities (1 octet) + Cipher Suite List */
+ size_t attr_len = sizeof(capab) + cs_list_len * sizeof(*cs_list);
+
+ if (wpabuf_tailroom(buf) <
+ (unsigned int)(NAN_ATTR_HDR_LEN + attr_len)) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: Not enough space to add CSIA attribute");
+ return -1;
+ }
+
+ wpabuf_put_u8(buf, NAN_ATTR_CSIA);
+ wpabuf_put_le16(buf, attr_len);
+ wpabuf_put_u8(buf, capab);
+
+ for (i = 0; i < cs_list_len; i++) {
+ wpabuf_put_u8(buf, cs_list[i].csid);
+ wpabuf_put_u8(buf, cs_list[i].instance_id);
+ }
+
+ return 0;
+}
+
+
/**
* nan_chan_to_chan_idx_map - convert an op_class and chan to channel
* bitmap
--
2.52.0
More information about the Hostap
mailing list