]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Helper function to get MLD address from Basic Multi-Link element
authorShivani Baranwal <quic_shivbara@quicinc.com>
Thu, 8 Sep 2022 14:44:14 +0000 (20:14 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 15 Sep 2022 13:00:38 +0000 (16:00 +0300)
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>
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h

index 54db7c82e398c7cfd7e743c11c2591ce4947525b..1bc262a4cfd1ed0bda737dc193947bf5bf538787 100644 (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];
+}
index bd2c9fbf5f1806f4dea6bbd2ab31beffbad3015d..c3a3234b3e7a874acd193fd99f10dae055430e7b 100644 (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 */