]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PR: Proximity Ranging element construction for USD
authorPeddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
Sat, 26 Apr 2025 17:52:36 +0000 (23:22 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 17 Oct 2025 10:21:44 +0000 (13:21 +0300)
Signed-off-by: Peddolla Harshavardhan Reddy <peddolla@qti.qualcomm.com>
src/common/ieee802_11_defs.h
src/common/proximity_ranging.c
src/common/proximity_ranging.h

index ae5fdefb7759755c853a7058d3960ae7a5a1db09..9782acfb68657b9dbfeb0c1881854a083684710c 100644 (file)
@@ -1495,6 +1495,9 @@ struct ieee80211_ampe_ie {
 #define RSNE_OVERRIDE_2_IE_VENDOR_TYPE 0x506f9a2a
 #define RSNXE_OVERRIDE_IE_VENDOR_TYPE 0x506f9a2b
 #define RSN_SELECTION_IE_VENDOR_TYPE 0x506f9a2c
+/* Proximity Ranging (PR) */
+#define PR_IE_VENDOR_TYPE 0x506f9a2e
+#define PR_OUI_TYPE 0x2e
 
 #define MULTI_AP_SUB_ELEM_TYPE 0x06
 #define MULTI_AP_PROFILE_SUB_ELEM_TYPE 0x07
index 1f8b4e3d950b0f386231ea74fbc156eba14931a4..5c566f606baed8f87e1f98aa43dff04dbe89d7e6 100644 (file)
@@ -9,6 +9,7 @@
 #include "includes.h"
 
 #include "utils/common.h"
+#include "common/ieee802_11_defs.h"
 #include "proximity_ranging.h"
 
 
@@ -48,3 +49,53 @@ void pr_deinit(struct pr_data *pr)
        os_free(pr);
        wpa_printf(MSG_DEBUG, "PR: Deinit done");
 }
+
+
+static struct wpabuf * pr_encaps_elem(const struct wpabuf *subelems,
+                                     u32 ie_type)
+{
+       struct wpabuf *ie = NULL;
+       const u8 *pos, *end;
+       size_t len = 0;
+
+       if (!subelems)
+               return NULL;
+
+       len = wpabuf_len(subelems) + 1000;
+       ie = wpabuf_alloc(len);
+       if (!ie)
+               return NULL;
+
+       pos = wpabuf_head(subelems);
+       end = pos + wpabuf_len(subelems);
+
+       while (end > pos) {
+               size_t frag_len = end - pos;
+
+               if (frag_len > 251)
+                       frag_len = 251;
+               wpabuf_put_u8(ie, WLAN_EID_VENDOR_SPECIFIC);
+               wpabuf_put_u8(ie, 4 + frag_len);
+               wpabuf_put_be32(ie, ie_type);
+               wpabuf_put_data(ie, pos, frag_len);
+               pos += frag_len;
+       }
+       return ie;
+}
+
+
+struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr)
+{
+       u32 ie_type;
+       struct wpabuf *buf, *buf2;
+
+       buf = wpabuf_alloc(1000);
+       if (!buf)
+               return NULL;
+
+       ie_type = (OUI_WFA << 8) | PR_OUI_TYPE;
+       buf2 = pr_encaps_elem(buf, ie_type);
+       wpabuf_free(buf);
+
+       return buf2;
+}
index f26952fc2f9f42eed6f25f24bf7f1b5ca7260725..04336e0185e45eb7a0052795aa915a5a8a3f0773 100644 (file)
@@ -178,5 +178,6 @@ struct pr_data {
 
 struct pr_data * pr_init(const struct pr_config *cfg);
 void pr_deinit(struct pr_data *pr);
+struct wpabuf * pr_prepare_usd_elems(struct pr_data *pr);
 
 #endif /* PROXIMITY_RANGING_H */