Helper function to get MLD address from Basic Multi-Link element

Add a utility function to fetch Multi-Link Device (MLD) address from a
Basic Multi-Link element.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
This commit is contained in:
Shivani Baranwal 2022-09-08 20:14:14 +05:30 committed by Jouni Malinen
parent 9a8bd7be0f
commit cc29cadf2e
2 changed files with 20 additions and 0 deletions

View file

@ -2772,3 +2772,22 @@ 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)
{
const size_t mld_addr_pos =
2 /* Control field */ +
1 /* Common Info Length field */;
const size_t fixed_len = mld_addr_pos +
ETH_ALEN /* MLD MAC Address field */;
if (len < fixed_len)
return NULL;
if ((buf[0] & MULTI_LINK_CONTROL_TYPE_MASK) !=
MULTI_LINK_CONTROL_TYPE_BASIC)
return NULL;
return &buf[mld_addr_pos];
}

View file

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