]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PR: Add ranging capabilities in USD PR element
authorPeddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
Sat, 26 Apr 2025 18:12:19 +0000 (23:42 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 17 Oct 2025 10:22:51 +0000 (13:22 +0300)
Create Proximity Ranging capability buffer that will be a part of a
larger Proximity Ranging element that is used to advertise the ranging
capabilities of the 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@qti.qualcomm.com>
src/common/proximity_ranging.c
src/common/proximity_ranging.h

index d6a41e5ac6d145d63cf3c9f8cbf9d2cd03245b3e..a41c1005d3bcf789bf619f084a6110f2755a106f 100644 (file)
@@ -140,15 +140,80 @@ static struct wpabuf * pr_encaps_elem(const struct wpabuf *subelems,
 }
 
 
+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,
+                          sizeof(capab->device_name));
+
+       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,
+                                        const struct pr_capabilities *capab)
+{
+       u8 *len;
+       u8 capa_6g = 0;
+       u8 protocol_type = 0;
+       size_t _len;
+
+       /* Proximity Ranging Capability Attribute */
+       wpabuf_put_u8(buf, PR_ATTR_RANGING_CAPABILITY);
+       len = wpabuf_put(buf, 2); /* Attribute length to be filled */
+
+       /* Ranging Protocol Type */
+       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);
+
+       /* PASN Type */
+       wpabuf_put_u8(buf, capab->pasn_type);
+
+       /* 6GHz band */
+       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_DEBUG, "PR: Device name: %s", capab->device_name);
+
+       _len = (u8 *) wpabuf_put(buf, 0) - len - 2;
+       WPA_PUT_LE16(len, _len);
+       wpa_hexdump(MSG_DEBUG, "PR: * Capability Attribute", len + 2, _len);
+}
+
+
 struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
 {
        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_elem(buf, ie_type);
        wpabuf_free(buf);
index 52871947d6e08621ccbedd8ac78d9d7d986068ed..f2f0ca488eee07e52925e8b22a80e61e0c06da2f 100644 (file)
@@ -10,6 +10,7 @@
 #define PROXIMITY_RANGING_H
 
 #include "utils/list.h"
+#include "wps/wps_defs.h"
 
 /**
  * PR_MAX_OP_CLASSES - Maximum number of operating classes
@@ -90,6 +91,45 @@ enum ntb_format_and_bw_value {
        NTB_FORMAT_AND_BW_HE160_SINGLE_LO = 5,
 };
 
+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;
+};
+
+/*
+ * Proximity Ranging Attribute IDs
+ * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
+ * Table 4 (Proximity Ranging Attribute ID list).
+ */
+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_WLAN_AP_INFO = 5,
+       PR_ATTR_DEVICE_IDENTITY_RESOLUTION = 6,
+       PR_ATTR_VENDOR_SPECIFIC = 221,
+};
+
+/*
+ * Proximity Ranging capabilities in Ranging Protocol Type field,
+ * Proximity Ranging Implementation Considerations for P2P Operation Draft 1.8,
+ * Table 7 (Proximity Ranging Capability Attribute format).
+ */
+#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
  */