aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2019-02-08 16:57:51 (GMT)
committerJouni Malinen <j@w1.fi>2019-02-11 11:37:22 (GMT)
commitb64479742953ad7227f1b691c27a0288528f9503 (patch)
treed819e07c3f24d92051c77398d05f0c58967f9f4c
parent9008048f0f33cfb939ba8397b2a2891bd1f6416e (diff)
downloadhostap-b64479742953ad7227f1b691c27a0288528f9503.zip
hostap-b64479742953ad7227f1b691c27a0288528f9503.tar.gz
hostap-b64479742953ad7227f1b691c27a0288528f9503.tar.bz2
common: Use for_each_element_id() in mb_ies_info_by_ies()
The change is bigger because here we need to catch the error condition if the last element doesn't fit. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--src/common/ieee802_11_common.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c
index 17f623c..79aa66a 100644
--- a/src/common/ieee802_11_common.c
+++ b/src/common/ieee802_11_common.c
@@ -1322,27 +1322,27 @@ const char * fc2str(u16 fc)
int mb_ies_info_by_ies(struct mb_ies_info *info, const u8 *ies_buf,
size_t ies_len)
{
+ const struct element *elem;
+
os_memset(info, 0, sizeof(*info));
- while (ies_buf && ies_len >= 2 &&
- info->nof_ies < MAX_NOF_MB_IES_SUPPORTED) {
- size_t len = 2 + ies_buf[1];
+ if (!ies_buf)
+ return 0;
- if (len > ies_len) {
- wpa_hexdump(MSG_DEBUG, "Truncated IEs",
- ies_buf, ies_len);
- return -1;
- }
+ for_each_element_id(elem, WLAN_EID_MULTI_BAND, ies_buf, ies_len) {
+ if (info->nof_ies >= MAX_NOF_MB_IES_SUPPORTED)
+ return 0;
- if (ies_buf[0] == WLAN_EID_MULTI_BAND) {
- wpa_printf(MSG_DEBUG, "MB IE of %zu bytes found", len);
- info->ies[info->nof_ies].ie = ies_buf + 2;
- info->ies[info->nof_ies].ie_len = ies_buf[1];
- info->nof_ies++;
- }
+ wpa_printf(MSG_DEBUG, "MB IE of %u bytes found",
+ elem->datalen + 2);
+ info->ies[info->nof_ies].ie = elem->data;
+ info->ies[info->nof_ies].ie_len = elem->datalen;
+ info->nof_ies++;
+ }
- ies_len -= len;
- ies_buf += len;
+ if (!for_each_element_completed(elem, ies_buf, ies_len)) {
+ wpa_hexdump(MSG_DEBUG, "Truncated IEs", ies_buf, ies_len);
+ return -1;
}
return 0;