Use a single define MAX_NUM_MLD_LINKS for the maximum number of links

There is no need to maintain a separate MAX_NUM_MLO_LINKS define for
practically the same thing.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2024-03-02 11:21:48 +02:00
parent 11f26fed64
commit 9ed51186e8
6 changed files with 42 additions and 42 deletions

View file

@ -1104,7 +1104,7 @@ static int wpa_ft_parse_ftie(const u8 *ie, size_t ie_len,
link_id = pos[2] & 0x0f; link_id = pos[2] & 0x0f;
wpa_printf(MSG_DEBUG, "FT: MLO GTK (Link ID %u)", wpa_printf(MSG_DEBUG, "FT: MLO GTK (Link ID %u)",
link_id); link_id);
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
break; break;
parse->valid_mlo_gtks |= BIT(link_id); parse->valid_mlo_gtks |= BIT(link_id);
parse->mlo_gtk[link_id] = pos; parse->mlo_gtk[link_id] = pos;
@ -1119,7 +1119,7 @@ static int wpa_ft_parse_ftie(const u8 *ie, size_t ie_len,
link_id = pos[2 + 6] & 0x0f; link_id = pos[2 + 6] & 0x0f;
wpa_printf(MSG_DEBUG, "FT: MLO IGTK (Link ID %u)", wpa_printf(MSG_DEBUG, "FT: MLO IGTK (Link ID %u)",
link_id); link_id);
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
break; break;
parse->valid_mlo_igtks |= BIT(link_id); parse->valid_mlo_igtks |= BIT(link_id);
parse->mlo_igtk[link_id] = pos; parse->mlo_igtk[link_id] = pos;
@ -1134,7 +1134,7 @@ static int wpa_ft_parse_ftie(const u8 *ie, size_t ie_len,
link_id = pos[2 + 6] & 0x0f; link_id = pos[2 + 6] & 0x0f;
wpa_printf(MSG_DEBUG, "FT: MLO BIGTK (Link ID %u)", wpa_printf(MSG_DEBUG, "FT: MLO BIGTK (Link ID %u)",
link_id); link_id);
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
break; break;
parse->valid_mlo_bigtks |= BIT(link_id); parse->valid_mlo_bigtks |= BIT(link_id);
parse->mlo_bigtk[link_id] = pos; parse->mlo_bigtk[link_id] = pos;
@ -1353,7 +1353,7 @@ int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse,
/* TODO: This count should be done based on all _requested_, /* TODO: This count should be done based on all _requested_,
* not _accepted_ links. */ * not _accepted_ links. */
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
if (parse->mlo_gtk[link_id]) { if (parse->mlo_gtk[link_id]) {
if (parse->rsn) if (parse->rsn)
prot_ie_count--; prot_ie_count--;
@ -3551,7 +3551,7 @@ static int wpa_parse_generic(const u8 *pos, struct wpa_eapol_ie_parse *ie)
selector == RSN_KEY_DATA_MLO_GTK) { selector == RSN_KEY_DATA_MLO_GTK) {
link_id = (p[0] & RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_MASK) >> link_id = (p[0] & RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_MASK) >>
RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_SHIFT; RSN_MLO_GTK_KDE_PREFIX0_LINK_ID_SHIFT;
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
return 2; return 2;
ie->valid_mlo_gtks |= BIT(link_id); ie->valid_mlo_gtks |= BIT(link_id);
@ -3569,7 +3569,7 @@ static int wpa_parse_generic(const u8 *pos, struct wpa_eapol_ie_parse *ie)
selector == RSN_KEY_DATA_MLO_IGTK) { selector == RSN_KEY_DATA_MLO_IGTK) {
link_id = (p[8] & RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_MASK) >> link_id = (p[8] & RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_MASK) >>
RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_SHIFT; RSN_MLO_IGTK_KDE_PREFIX8_LINK_ID_SHIFT;
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
return 2; return 2;
ie->valid_mlo_igtks |= BIT(link_id); ie->valid_mlo_igtks |= BIT(link_id);
@ -3587,7 +3587,7 @@ static int wpa_parse_generic(const u8 *pos, struct wpa_eapol_ie_parse *ie)
selector == RSN_KEY_DATA_MLO_BIGTK) { selector == RSN_KEY_DATA_MLO_BIGTK) {
link_id = (p[8] & RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_MASK) >> link_id = (p[8] & RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_MASK) >>
RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_SHIFT; RSN_MLO_BIGTK_KDE_PREFIX8_LINK_ID_SHIFT;
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
return 2; return 2;
ie->valid_mlo_bigtks |= BIT(link_id); ie->valid_mlo_bigtks |= BIT(link_id);
@ -3605,7 +3605,7 @@ static int wpa_parse_generic(const u8 *pos, struct wpa_eapol_ie_parse *ie)
selector == RSN_KEY_DATA_MLO_LINK) { selector == RSN_KEY_DATA_MLO_LINK) {
link_id = (p[0] & RSN_MLO_LINK_KDE_LI_LINK_ID_MASK) >> link_id = (p[0] & RSN_MLO_LINK_KDE_LI_LINK_ID_MASK) >>
RSN_MLO_LINK_KDE_LI_LINK_ID_SHIFT; RSN_MLO_LINK_KDE_LI_LINK_ID_SHIFT;
if (link_id >= MAX_NUM_MLO_LINKS) if (link_id >= MAX_NUM_MLD_LINKS)
return 2; return 2;
ie->valid_mlo_links |= BIT(link_id); ie->valid_mlo_links |= BIT(link_id);

View file

@ -9,6 +9,8 @@
#ifndef WPA_COMMON_H #ifndef WPA_COMMON_H
#define WPA_COMMON_H #define WPA_COMMON_H
#include "common/defs.h"
/* IEEE 802.11i */ /* IEEE 802.11i */
#define PMKID_LEN 16 #define PMKID_LEN 16
#define PMK_LEN 32 #define PMK_LEN 32
@ -557,8 +559,6 @@ int wpa_compare_rsn_ie(int ft_initial_assoc,
const u8 *ie2, size_t ie2len); const u8 *ie2, size_t ie2len);
int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid, bool replace); int wpa_insert_pmkid(u8 *ies, size_t *ies_len, const u8 *pmkid, bool replace);
#define MAX_NUM_MLO_LINKS 15
struct wpa_ft_ies { struct wpa_ft_ies {
const u8 *mdie; const u8 *mdie;
size_t mdie_len; size_t mdie_len;
@ -596,14 +596,14 @@ struct wpa_ft_ies {
const u8 *rsnxe; const u8 *rsnxe;
size_t rsnxe_len; size_t rsnxe_len;
u16 valid_mlo_gtks; /* bitmap of valid link GTK subelements */ u16 valid_mlo_gtks; /* bitmap of valid link GTK subelements */
const u8 *mlo_gtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_gtk[MAX_NUM_MLD_LINKS];
size_t mlo_gtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_gtk_len[MAX_NUM_MLD_LINKS];
u16 valid_mlo_igtks; /* bitmap of valid link IGTK subelements */ u16 valid_mlo_igtks; /* bitmap of valid link IGTK subelements */
const u8 *mlo_igtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_igtk[MAX_NUM_MLD_LINKS];
size_t mlo_igtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_igtk_len[MAX_NUM_MLD_LINKS];
u16 valid_mlo_bigtks; /* bitmap of valid link BIGTK subelements */ u16 valid_mlo_bigtks; /* bitmap of valid link BIGTK subelements */
const u8 *mlo_bigtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_bigtk[MAX_NUM_MLD_LINKS];
size_t mlo_bigtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_bigtk_len[MAX_NUM_MLD_LINKS];
struct wpabuf *fte_buf; struct wpabuf *fte_buf;
}; };
@ -700,17 +700,17 @@ struct wpa_eapol_ie_parse {
const u8 *wmm; const u8 *wmm;
size_t wmm_len; size_t wmm_len;
u16 valid_mlo_gtks; /* bitmap of valid link GTK KDEs */ u16 valid_mlo_gtks; /* bitmap of valid link GTK KDEs */
const u8 *mlo_gtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_gtk[MAX_NUM_MLD_LINKS];
size_t mlo_gtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_gtk_len[MAX_NUM_MLD_LINKS];
u16 valid_mlo_igtks; /* bitmap of valid link IGTK KDEs */ u16 valid_mlo_igtks; /* bitmap of valid link IGTK KDEs */
const u8 *mlo_igtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_igtk[MAX_NUM_MLD_LINKS];
size_t mlo_igtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_igtk_len[MAX_NUM_MLD_LINKS];
u16 valid_mlo_bigtks; /* bitmap of valid link BIGTK KDEs */ u16 valid_mlo_bigtks; /* bitmap of valid link BIGTK KDEs */
const u8 *mlo_bigtk[MAX_NUM_MLO_LINKS]; const u8 *mlo_bigtk[MAX_NUM_MLD_LINKS];
size_t mlo_bigtk_len[MAX_NUM_MLO_LINKS]; size_t mlo_bigtk_len[MAX_NUM_MLD_LINKS];
u16 valid_mlo_links; /* bitmap of valid MLO link KDEs */ u16 valid_mlo_links; /* bitmap of valid MLO link KDEs */
const u8 *mlo_link[MAX_NUM_MLO_LINKS]; const u8 *mlo_link[MAX_NUM_MLD_LINKS];
size_t mlo_link_len[MAX_NUM_MLO_LINKS]; size_t mlo_link_len[MAX_NUM_MLD_LINKS];
}; };
int wpa_parse_kde_ies(const u8 *buf, size_t len, struct wpa_eapol_ie_parse *ie); int wpa_parse_kde_ies(const u8 *buf, size_t len, struct wpa_eapol_ie_parse *ie);

View file

@ -491,7 +491,7 @@ static void rx_data_eapol_key_2_of_4(struct wlantest *wt, const u8 *dst,
} }
} }
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
const u8 *addr; const u8 *addr;
if (!ie.mlo_link[link_id]) if (!ie.mlo_link[link_id])
@ -886,7 +886,7 @@ static void learn_kde_keys(struct wlantest *wt, struct wlantest_bss *bss,
} }
} }
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
const u8 *addr; const u8 *addr;
if (!ie.mlo_link[link_id]) if (!ie.mlo_link[link_id])
@ -1099,7 +1099,7 @@ static void rx_data_eapol_key_3_of_4(struct wlantest *wt, const u8 *dst,
rsne = ie.rsn_ie; rsne = ie.rsn_ie;
rsne_len = ie.rsn_ie_len; rsne_len = ie.rsn_ie_len;
for (link_id = 0; !rsne && link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; !rsne && link_id < MAX_NUM_MLD_LINKS; link_id++) {
const u8 *addr, *pos, *end; const u8 *addr, *pos, *end;
if (!ie.mlo_link[link_id]) if (!ie.mlo_link[link_id])

View file

@ -280,7 +280,7 @@ static void parse_basic_ml(const u8 *ie, size_t len, bool ap,
} }
wpa_printf(MSG_DEBUG, "STA MAC Address: " MACSTR, wpa_printf(MSG_DEBUG, "STA MAC Address: " MACSTR,
MAC2STR(pos)); MAC2STR(pos));
if (sta && link_id < MAX_NUM_MLO_LINKS) { if (sta && link_id < MAX_NUM_MLD_LINKS) {
os_memcpy(sta->link_addr[link_id], pos, os_memcpy(sta->link_addr[link_id], pos,
ETH_ALEN); ETH_ALEN);
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
@ -998,7 +998,7 @@ static void dump_mld_info(struct wlantest *wt, struct wlantest_sta *sta)
os_memset(zero, 0, ETH_ALEN); os_memset(zero, 0, ETH_ALEN);
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
bss = bss_find_mld(wt, sta->bss->mld_mac_addr, link_id); bss = bss_find_mld(wt, sta->bss->mld_mac_addr, link_id);
if (!bss && if (!bss &&
is_zero_ether_addr(sta->link_addr[link_id])) is_zero_ether_addr(sta->link_addr[link_id]))
@ -1560,10 +1560,10 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
if (elems.basic_mle) { if (elems.basic_mle) {
int i; int i;
extra = wpabuf_alloc(MAX_NUM_MLO_LINKS * ETH_ALEN); extra = wpabuf_alloc(MAX_NUM_MLD_LINKS * ETH_ALEN);
if (!extra) if (!extra)
goto out; goto out;
for (i = 0; i < MAX_NUM_MLO_LINKS; i++) { for (i = 0; i < MAX_NUM_MLD_LINKS; i++) {
if (!is_zero_ether_addr(sta->link_addr[i])) if (!is_zero_ether_addr(sta->link_addr[i]))
wpabuf_put_data(extra, wpabuf_put_data(extra,
sta->link_addr[i], sta->link_addr[i],
@ -1607,7 +1607,7 @@ static void rx_mgmt_reassoc_req(struct wlantest *wt, const u8 *data,
wpa_hexdump(MSG_MSGDUMP, "FT: RSNXE", wpa_hexdump(MSG_MSGDUMP, "FT: RSNXE",
parse.rsnxe ? parse.rsnxe - 2 : NULL, parse.rsnxe ? parse.rsnxe - 2 : NULL,
parse.rsnxe ? parse.rsnxe_len + 2 : 0); parse.rsnxe ? parse.rsnxe_len + 2 : 0);
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; for (link_id = 0; link_id < MAX_NUM_MLD_LINKS;
link_id++) { link_id++) {
if (is_zero_ether_addr(sta->link_addr[link_id])) if (is_zero_ether_addr(sta->link_addr[link_id]))
continue; continue;
@ -1889,7 +1889,7 @@ static void process_fte_group_keys_mlo(struct wlantest *wt,
{ {
int link_id; int link_id;
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
struct wlantest_bss *l_bss; struct wlantest_bss *l_bss;
struct wlantest_sta *l_sta; struct wlantest_sta *l_sta;
@ -2169,13 +2169,13 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
u8 rsne_buf[257]; u8 rsne_buf[257];
size_t rsne_len; size_t rsne_len;
extra = wpabuf_alloc(MAX_NUM_MLO_LINKS * ETH_ALEN); extra = wpabuf_alloc(MAX_NUM_MLD_LINKS * ETH_ALEN);
rsne = wpabuf_alloc(MAX_NUM_MLO_LINKS * 256); rsne = wpabuf_alloc(MAX_NUM_MLD_LINKS * 256);
rsnxe = wpabuf_alloc(MAX_NUM_MLO_LINKS * 256); rsnxe = wpabuf_alloc(MAX_NUM_MLD_LINKS * 256);
if (!extra || !rsne || !rsnxe) if (!extra || !rsne || !rsnxe)
goto out; goto out;
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; for (link_id = 0; link_id < MAX_NUM_MLD_LINKS;
link_id++) { link_id++) {
struct wpa_ie_data ie_data; struct wpa_ie_data ie_data;
@ -2297,7 +2297,7 @@ static void rx_mgmt_reassoc_resp(struct wlantest *wt, const u8 *data,
elems.ftie - 2, elems.fte_defrag_len + 2); elems.ftie - 2, elems.fte_defrag_len + 2);
wpa_hexdump_buf(MSG_MSGDUMP, "FT: RSNE", rsne); wpa_hexdump_buf(MSG_MSGDUMP, "FT: RSNE", rsne);
wpa_hexdump_buf(MSG_MSGDUMP, "FT: RSNXE", rsnxe); wpa_hexdump_buf(MSG_MSGDUMP, "FT: RSNXE", rsnxe);
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; for (link_id = 0; link_id < MAX_NUM_MLD_LINKS;
link_id++) { link_id++) {
struct wlantest_bss *l_bss; struct wlantest_bss *l_bss;

View file

@ -46,7 +46,7 @@ struct wlantest_sta * sta_find_mlo(struct wlantest *wt,
return NULL; return NULL;
dl_list_for_each(sta, &bss->sta, struct wlantest_sta, list) { dl_list_for_each(sta, &bss->sta, struct wlantest_sta, list) {
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; link_id++) { for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) {
if (ether_addr_equal(sta->link_addr[link_id], addr)) if (ether_addr_equal(sta->link_addr[link_id], addr))
return sta; return sta;
} }
@ -63,7 +63,7 @@ struct wlantest_sta * sta_find_mlo(struct wlantest *wt,
return sta; return sta;
if (ether_addr_equal(sta->mld_mac_addr, addr)) if (ether_addr_equal(sta->mld_mac_addr, addr))
return sta; return sta;
for (link_id = 0; link_id < MAX_NUM_MLO_LINKS; for (link_id = 0; link_id < MAX_NUM_MLD_LINKS;
link_id++) { link_id++) {
if (ether_addr_equal(sta->link_addr[link_id], if (ether_addr_equal(sta->link_addr[link_id],
addr)) addr))
@ -336,7 +336,7 @@ void sta_new_ptk(struct wlantest *wt, struct wlantest_sta *sta,
continue; continue;
if (ether_addr_equal(sta->addr, osta->addr)) if (ether_addr_equal(sta->addr, osta->addr))
match = true; match = true;
for (link_id = 0; !match && link_id < MAX_NUM_MLO_LINKS; for (link_id = 0; !match && link_id < MAX_NUM_MLD_LINKS;
link_id++) { link_id++) {
if (ether_addr_equal(osta->link_addr[link_id], if (ether_addr_equal(osta->link_addr[link_id],
sta->addr)) sta->addr))

View file

@ -56,7 +56,7 @@ struct wlantest_sta {
struct wlantest_bss *bss; struct wlantest_bss *bss;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
u8 mld_mac_addr[ETH_ALEN]; u8 mld_mac_addr[ETH_ALEN];
u8 link_addr[MAX_NUM_MLO_LINKS][ETH_ALEN]; u8 link_addr[MAX_NUM_MLD_LINKS][ETH_ALEN];
enum { enum {
STATE1 /* not authenticated */, STATE1 /* not authenticated */,
STATE2 /* authenticated */, STATE2 /* authenticated */,