[PATCH 05/34] PR: API to add ranging capabilities in USD PR IE
Peddolla Harshavardhan Reddy
peddolla at qti.qualcomm.com
Thu Jun 19 08:36:58 PDT 2025
Add changes to create Proximity Ranging capability buffer that will
be a part of a larger proximity ranging IE that is used to advertise
the ranging capabilities of device. The capabilities are fetched
from the global proximity ranging context. The capabilities include
name of the device, PASN authentication support, EDCA ranging support,
NTB ranging support and such.
Signed-off-by: Peddolla Harshavardhan Reddy <peddolla at qti.qualcomm.com>
---
src/common/proximity_ranging.c | 64 ++++++++++++++++++++++++++++++++++
src/common/proximity_ranging.h | 35 +++++++++++++++++++
2 files changed, 99 insertions(+)
diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c
index a3f640bce..da0ea65ee 100644
--- a/src/common/proximity_ranging.c
+++ b/src/common/proximity_ranging.c
@@ -142,15 +142,79 @@ static struct wpabuf * pr_encaps_ie(const struct wpabuf *subelems, u32 ie_type)
}
+static void pr_get_ranging_capabilities(struct pr_data *pr,
+ struct pr_capabilities *capab)
+{
+ os_memset(capab, 0, sizeof(struct pr_capabilities));
+
+ if (pr->cfg->dev_name)
+ os_strlcpy(capab->device_name, pr->cfg->dev_name,
+ WPS_DEV_NAME_MAX_LEN);
+
+ if (pr->cfg->edca_ista_support || pr->cfg->edca_rsta_support)
+ capab->edca_support = true;
+
+ if (pr->cfg->ntb_ista_support || pr->cfg->ntb_rsta_support)
+ capab->ntb_support = true;
+
+ capab->secure_he_ltf = pr->cfg->secure_he_ltf;
+ capab->pasn_type = pr->cfg->pasn_type;
+ capab->support_6ghz = pr->cfg->support_6ghz;
+}
+
+
+static void pr_buf_add_ranging_capa_info(struct wpabuf *buf,
+ struct pr_capabilities *capab)
+{
+ u8 *len;
+ u8 capa_6g = 0;
+ u8 protocol_type = 0;
+
+ if (!buf || !capab)
+ return;
+
+ wpabuf_put_u8(buf, PR_ATTR_RANGING_CAPABILITY);
+ len = wpabuf_put(buf, 2); /* IE length to be filled */
+
+ if (capab->edca_support)
+ protocol_type |= PR_EDCA_BASED_RANGING;
+ if (capab->ntb_support && capab->secure_he_ltf)
+ protocol_type |= PR_NTB_SECURE_LTF_BASED_RANGING;
+ if (capab->ntb_support)
+ protocol_type |= PR_NTB_OPEN_BASED_RANGING;
+
+ wpabuf_put_u8(buf, protocol_type);
+ wpabuf_put_u8(buf, capab->pasn_type);
+
+ if (capab->support_6ghz)
+ capa_6g |= BIT(0);
+
+ wpabuf_put_u8(buf, capa_6g);
+
+ /*Device name*/
+ wpabuf_put_data(buf, capab->device_name, WPS_DEV_NAME_MAX_LEN);
+
+ wpa_printf(MSG_INFO, "PR: Device name: %s", capab->device_name);
+
+ WPA_PUT_LE16(len, (u8 *) wpabuf_put(buf, 0) - len - 2);
+ wpa_hexdump(MSG_DEBUG, "PR: * Device capability info",
+ len + 2, (u8 *) wpabuf_put(buf, 0) - len - 2);
+}
+
+
struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr, const char *country)
{
u32 ie_type;
struct wpabuf *buf, *buf2;
+ struct pr_capabilities pr_caps;
buf = wpabuf_alloc(1000);
if (!buf)
return NULL;
+ pr_get_ranging_capabilities(pr, &pr_caps);
+ pr_buf_add_ranging_capa_info(buf, &pr_caps);
+
ie_type = (OUI_WFA << 8) | PR_OUI_TYPE;
buf2 = pr_encaps_ie(buf, ie_type);
wpabuf_free(buf);
diff --git a/src/common/proximity_ranging.h b/src/common/proximity_ranging.h
index ec6539eac..831e731a1 100644
--- a/src/common/proximity_ranging.h
+++ b/src/common/proximity_ranging.h
@@ -58,6 +58,41 @@ struct pr_channels {
size_t op_classes;
};
+struct pr_capabilities {
+ u8 pasn_type;
+
+ char device_name[WPS_DEV_NAME_MAX_LEN + 1];
+
+ bool edca_support;
+
+ bool ntb_support;
+
+ bool secure_he_ltf;
+
+ bool support_6ghz;
+};
+
+
+enum pr_attr_id {
+ PR_ATTR_STATUS = 0,
+ PR_ATTR_RANGING_CAPABILITY = 1,
+ PR_ATTR_EDCA_CAPABILITY = 2,
+ PR_ATTR_NTB_CAPABILITY = 3,
+ PR_ATTR_OPERATION_MODE = 4,
+ PR_ATTR_DEVICE_IDENTITY_RESOLUTION = 6,
+ PR_ATTR_DEVICE_IDENTITY_KEY = 7,
+ PR_ATTR_VENDOR_SPECIFIC = 221,
+};
+
+/**
+ * Proximity Ranging capabilities,
+ * Proximity Ranging Implementation Considerations for P2P Operation 2025,
+ * 3.3.2, Table 7.
+ */
+#define PR_EDCA_BASED_RANGING BIT(0)
+#define PR_NTB_SECURE_LTF_BASED_RANGING BIT(1)
+#define PR_NTB_OPEN_BASED_RANGING BIT(2)
+
/**
* struct pr_device_info - Proximity ranging peer information
*/
--
2.34.1
More information about the Hostap
mailing list