[RFC v2 07/99] NAN: Add a function to add device capability attribute
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Dec 23 03:51:11 PST 2025
From: Ilan Peer <ilan.peer at intel.com>
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/nan/nan.h | 21 +++++++++++++++++++++
src/nan/nan_i.h | 2 +-
src/nan/nan_util.c | 22 ++++++++++++++++++++++
wpa_supplicant/nan_supplicant.c | 20 ++++++++++++++++++++
4 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/src/nan/nan.h b/src/nan/nan.h
index d6025a6b09..7bfb05b583 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -11,9 +11,30 @@
struct nan_cluster_config;
+/*
+ * struct nan_device_capabilities - NAN device capabilities.
+ *
+ * @cdw_info: Committed DW information
+ * @supported_bands: Supported bands
+ * @op_mode: Operation mode
+ * @n_antennas: Number of antennas
+ * @channel_switch_time: Maximal channel switch time
+ * @capa: Device capabilities
+ */
+struct nan_device_capabilities {
+ u16 cdw_info;
+ u8 supported_bands;
+ u8 op_mode;
+ u8 n_antennas;
+ u16 channel_switch_time;
+ u8 capa;
+};
+
struct nan_config {
void *cb_ctx;
+ struct nan_device_capabilities dev_capa;
+
/**
* start - Start NAN
* @ctx: Callback context from cb_ctx
diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h
index 62b27881e9..1338549925 100644
--- a/src/nan/nan_i.h
+++ b/src/nan/nan_i.h
@@ -89,5 +89,5 @@ int nan_parse_attrs(struct nan_data *nan, const u8 *data, size_t len,
int nan_parse_naf(struct nan_data *nan, const struct ieee80211_mgmt *mgmt,
size_t len, struct nan_msg *msg);
void nan_attrs_clear(struct nan_data *nan, struct nan_attrs *attrs);
-
+void nan_add_dev_capa_attr(struct nan_data *nan, struct wpabuf *buf);
#endif
diff --git a/src/nan/nan_util.c b/src/nan/nan_util.c
index 4e034ecfd9..987928da2b 100644
--- a/src/nan/nan_util.c
+++ b/src/nan/nan_util.c
@@ -306,3 +306,25 @@ int nan_parse_naf(struct nan_data *nan, const struct ieee80211_mgmt *mgmt,
len - IEEE80211_MIN_ACTION_LEN(naf),
&msg->attrs);
}
+
+
+/*
+ * nan_add_dev_capa_attr - Add NAN device capability attribute
+ *
+ * @nan: NAN module context from nan_init()
+ * @buf: wpabuf to which the attribute would be added
+ */
+void nan_add_dev_capa_attr(struct nan_data *nan, struct wpabuf *buf)
+{
+ wpabuf_put_u8(buf, NAN_ATTR_DEVICE_CAPABILITY);
+ wpabuf_put_le16(buf, sizeof(struct nan_device_capa));
+
+ /* Device capabilities apply to the device, so set map ID = 0 */
+ wpabuf_put_u8(buf, 0);
+ wpabuf_put_le16(buf, nan->cfg->dev_capa.cdw_info);
+ wpabuf_put_u8(buf, nan->cfg->dev_capa.supported_bands);
+ wpabuf_put_u8(buf, nan->cfg->dev_capa.op_mode);
+ wpabuf_put_u8(buf, nan->cfg->dev_capa.n_antennas);
+ wpabuf_put_le16(buf, nan->cfg->dev_capa.channel_switch_time);
+ wpabuf_put_u8(buf, nan->cfg->dev_capa.capa);
+}
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index ce972a0fdf..30742859d3 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -77,6 +77,26 @@ int wpas_nan_init(struct wpa_supplicant *wpa_s)
nan.stop = wpas_nan_stop_cb;
nan.update_config = wpas_nan_update_config_cb;
+ /*
+ * TODO: Set the device capabilities based on configuration and driver
+ * data. For now do not set 'n_antennas', 'channel_switch_time' and
+ * 'capa', i.e., indicating that the information is not available. This
+ * information should also be retrieved from the driver.
+ */
+ nan.dev_capa.cdw_info =
+ ((1 << NAN_CDW_INFO_2G_POS) & NAN_CDW_INFO_2G_MASK) |
+ ((1 << NAN_CDW_INFO_5G_POS) & NAN_CDW_INFO_5G_MASK);
+
+ nan.dev_capa.supported_bands = NAN_DEV_CAPA_SBAND_2G;
+ if (wpa_s->nan_drv_flags &
+ WPA_DRIVER_FLAGS_NAN_SUPPORT_DUAL_BAND)
+ nan.dev_capa.supported_bands |= NAN_DEV_CAPA_SBAND_5G;
+
+ /* TODO: set based on driver capabilities */
+ nan.dev_capa.op_mode = NAN_DEV_CAPA_OP_MODE_PHY_MODE_VHT |
+ NAN_DEV_CAPA_OP_MODE_PHY_MODE_HE |
+ NAN_DEV_CAPA_OP_MODE_HE_VHT_160;
+
wpa_s->nan = nan_init(&nan);
if (!wpa_s->nan) {
wpa_printf(MSG_DEBUG, "NAN: Failed to init");
--
2.49.0
More information about the Hostap
mailing list