Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@xxxxxxxxxxxxxxxx> --- src/common/proximity_ranging.c | 64 ++++++++++++++++++++++++++++++++++ src/common/proximity_ranging.h | 31 ++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/src/common/proximity_ranging.c b/src/common/proximity_ranging.c index d87856b12..c39753b33 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 || !capab->device_name) + 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 4f5c59f9b..0d31fb1a0 100644 --- a/src/common/proximity_ranging.h +++ b/src/common/proximity_ranging.h @@ -58,6 +58,37 @@ struct pr_channels { size_t reg_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*/ +#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 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap