From a72e0eb63d7f53dc658e0bf69f4aa09b5d74d350 Mon Sep 17 00:00:00 2001 From: Aloka Dixit Date: Fri, 25 Sep 2020 11:51:37 -0700 Subject: [PATCH] Add RSN extension element in multiple BSSID element This patch adds RSN extension element in multiple BSSID element when SAE Hash-to-Element method is used for nontransmitted profiles. Signed-off-by: Aloka Dixit --- src/ap/beacon.c | 2 +- src/ap/ieee802_11.c | 28 ++++++++++++++++++++-------- src/ap/ieee802_11.h | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index be59d20729ef..2897f14aa4fb 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -319,7 +319,7 @@ static u8 * hostapd_get_mde(struct hostapd_data *hapd, u8 *pos, size_t len) } -static u8 * hostapd_get_rsnxe(struct hostapd_data *hapd, u8 *pos, size_t len) +u8 * hostapd_get_rsnxe(struct hostapd_data *hapd, u8 *pos, size_t len) { const u8 *ie; diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 65a556e3a606..579c1f538f9a 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -5654,17 +5654,29 @@ static int hostapd_eid_multiple_bssid_chunk_len(struct hostapd_data *hapd, int *count) { /* ID + size + count */ - int i, len = 3; + int i, len = 3, nontx_profile_len; + size_t ies_len = 0; + struct hostapd_data *bss; for (i = *count; i < hapd->iface->num_bss; i++) { - struct hostapd_data *bss = hapd->iface->bss[i]; - /* 11 mbssid + ssid len + 32 RSN */ - int ssid_len = 11 + bss->conf->ssid.ssid_len + 32; + bss = hapd->iface->bss[i]; + + /* + * Sublement ID: 1 byte + * Length: 1 byte + * Nontransmitted capabilities: 4 bytes + * Multiple BSSID Index Element: 5 bytes + * SSID element: 2 + variable + */ + nontx_profile_len = 13 + bss->conf->ssid.ssid_len; + + if (wpa_auth_get_wpa_ie(bss->wpa_auth, &ies_len)) + nontx_profile_len += ies_len; - if (len + ssid_len > 255) { + if (len + nontx_profile_len > 255) { goto multiple_bssid_too_big; } - len += ssid_len; + len += nontx_profile_len; } multiple_bssid_too_big: @@ -5689,7 +5701,7 @@ static u8 * hostapd_eid_multiple_bssid_chunk(struct hostapd_data *hapd, u8 *eid, u8 *end, int *count, u8 is_beacon) { - u8 *size_offset, *num_offset, num = 0; + u8 *size_offset, *num_offset; int i; *eid++ = WLAN_EID_MULTIPLE_BSSID; @@ -5725,13 +5737,13 @@ static u8 * hostapd_eid_multiple_bssid_chunk(struct hostapd_data *hapd, *index_size_offset = (eid - index_size_offset) - 1; eid = hostapd_get_rsne(bss, eid, end - eid); + eid = hostapd_get_rsnxe(bss, eid, end - eid); *bss_size_offset = (eid - bss_size_offset) - 1; if ((eid - size_offset) - 1 > 255) { eid = pos; goto multiple_bssid_too_big; } - num++; } multiple_bssid_too_big: diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h index 9ccfe6c10bd4..2fa2a7d44edc 100644 --- a/src/ap/ieee802_11.h +++ b/src/ap/ieee802_11.h @@ -203,5 +203,5 @@ int get_tx_parameters(struct sta_info *sta, int ap_max_chanwidth, void auth_sae_process_commit(void *eloop_ctx, void *user_ctx); u8 * hostapd_eid_rsnxe(struct hostapd_data *hapd, u8 *eid, size_t len); u8 * hostapd_get_rsne(struct hostapd_data *hapd, u8 *pos, size_t len); - +u8 * hostapd_get_rsnxe(struct hostapd_data *hapd, u8 *pos, size_t len); #endif /* IEEE802_11_H */ -- 2.25.0