diff mbox series

[09/18] Add API to get MLD address from ML IE

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

Commit Message

Veerendranath Jakkam July 28, 2022, 1:45 p.m. UTC
From: Shivani Baranwal <quic_shivbara@quicinc.com>

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

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

Comments

Jouni Malinen Aug. 31, 2022, 7:50 p.m. UTC | #1
On Thu, Jul 28, 2022 at 07:15:38PM +0530, Veerendranath Jakkam wrote:
> Add utility API to fetch Multi-Link Device(MLD) address from
> Multi-Link(ML) IE.

> diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
> +#define MULTI_LINK_IE_MINIMUM_BYTES 9
> +#define ML_IE_MLD_ADDR_OFFSET \
> +		(2 + /* Control field */ \
> +		 1) /* Common Info length field */
> +void wpa_get_mld_addr(u8 *mld_addr, const u8 *buf, size_t len)
> +{
> +	if (len < MULTI_LINK_IE_MINIMUM_BYTES)
> +		wpa_printf(MSG_ERROR, "Incomplete Multi-Link IE");
> +
> +	buf += ML_IE_MLD_ADDR_OFFSET;
> +	len -= ML_IE_MLD_ADDR_OFFSET;
> +
> +	/*
> +	 * Getting AP mld addr
> +	 */
> +	memcpy(mld_addr, buf, ETH_ALEN);
> +}

How is this supposed to handle all different types of Multi-Link
element? Is this only for the Basic Multi-Link element? If so, shouldn't
this verify that the element being parsed here does indeed have the Type
subfield set to 0 (Basic) before trying to parse the Common Info field?
It would also seem reasonable to verify that the Common Info Length
field has a value that is large enough to include the MLD MAC Address
field.
diff mbox series

Patch

diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index c8ee90cd7..f781a13ea 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -2755,3 +2755,21 @@  struct wpabuf * ieee802_11_defrag(struct ieee802_11_elems *elems,
 
 	return ieee802_11_defrag_data(elems, eid, eid_ext, data, len);
 }
+
+#define MULTI_LINK_IE_MINIMUM_BYTES 9
+#define ML_IE_MLD_ADDR_OFFSET \
+		(2 + /* Control field */ \
+		 1) /* Common Info length field */
+void wpa_get_mld_addr(u8 *mld_addr, const u8 *buf, size_t len)
+{
+	if (len < MULTI_LINK_IE_MINIMUM_BYTES)
+		wpa_printf(MSG_ERROR, "Incomplete Multi-Link IE");
+
+	buf += ML_IE_MLD_ADDR_OFFSET;
+	len -= ML_IE_MLD_ADDR_OFFSET;
+
+	/*
+	 * Getting AP mld addr
+	 */
+	memcpy(mld_addr, buf, ETH_ALEN);
+}
diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h
index 94e1d7b8b..e481af8da 100644
--- a/src/common/ieee802_11_common.h
+++ b/src/common/ieee802_11_common.h
@@ -343,5 +343,6 @@  struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
 				       const u8 *data, u8 len);
 struct wpabuf * ieee802_11_defrag(struct ieee802_11_elems *elems,
 				  u8 eid, u8 eid_ext);
+void wpa_get_mld_addr(u8 *mld_addr, const u8 *buf, size_t len);
 
 #endif /* IEEE802_11_COMMON_H */