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 |
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 --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 */