diff mbox series

[v2,08/17] Add API to get MLD address from basic ML IE

Message ID 20220908144423.2222859-9-quic_vjakkam@quicinc.com
State Accepted
Headers show
Series MLD STA: Add support for open MLO connection when driver's SME in use | expand

Commit Message

Veerendranath Jakkam Sept. 8, 2022, 2:44 p.m. UTC
From: Shivani Baranwal <quic_shivbara@quicinc.com>

Add utility API to fetch Multi-Link Device(MLD) address from
basic Multi-Link(ML) IE.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
---
 src/common/ieee802_11_common.c | 21 +++++++++++++++++++++
 src/common/ieee802_11_common.h |  1 +
 2 files changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 0eac3f84c..8b3b7d3af 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -2771,3 +2771,24 @@  const u8 * get_ml_ie(const u8 *ies, size_t len, u8 type)
 
 	return NULL;
 }
+
+const u8 * get_basic_mle_mld_addr(const u8 *buf, size_t len)
+{
+#define BASIC_ML_IE_FIXED_LENGTH \
+		(2 + /* Control field */ \
+		 1 + /* Common info length field */ \
+		 6) /* MLD mac address field */
+	if (len < BASIC_ML_IE_FIXED_LENGTH)
+		return NULL;
+#undef BASIC_ML_IE_FIXED_LENGTH
+
+	if ((buf[0] & MULTI_LINK_CONTROL_TYPE_MASK) !=
+	     MULTI_LINK_CONTROL_TYPE_BASIC)
+		return NULL;
+
+#define BASIC_ML_IE_MLD_ADDR_IDX \
+		(2 + /* Control field */ \
+		 1) /* Common Info length field */
+	return &buf[BASIC_ML_IE_MLD_ADDR_IDX];
+#undef BASIC_ML_IE_MLD_ADDR_IDX
+}
diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h
index bd2c9fbf5..c3a3234b3 100644
--- a/src/common/ieee802_11_common.h
+++ b/src/common/ieee802_11_common.h
@@ -344,5 +344,6 @@  struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
 struct wpabuf * ieee802_11_defrag(struct ieee802_11_elems *elems,
 				  u8 eid, u8 eid_ext);
 const u8 * get_ml_ie(const u8 *ies, size_t len, u8 type);
+const u8 * get_basic_mle_mld_addr(const u8 *buf, size_t len);
 
 #endif /* IEEE802_11_COMMON_H */