Commit c17e28d1 authored by Johannes Berg's avatar Johannes Berg

mac80211: use element iteration macro in parsing

Instead of open-coding the element walk, use the new macro.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 0f3b07f0
...@@ -895,8 +895,7 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, ...@@ -895,8 +895,7 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
struct ieee802_11_elems *elems, struct ieee802_11_elems *elems,
u64 filter, u32 crc) u64 filter, u32 crc)
{ {
size_t left = len; struct element *elem;
const u8 *pos = start;
bool calc_crc = filter != 0; bool calc_crc = filter != 0;
DECLARE_BITMAP(seen_elems, 256); DECLARE_BITMAP(seen_elems, 256);
const u8 *ie; const u8 *ie;
...@@ -906,18 +905,11 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, ...@@ -906,18 +905,11 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
elems->ie_start = start; elems->ie_start = start;
elems->total_len = len; elems->total_len = len;
while (left >= 2) { for_each_element(elem, start, len) {
u8 id, elen;
bool elem_parse_failed; bool elem_parse_failed;
u8 id = elem->id;
id = *pos++; u8 elen = elem->datalen;
elen = *pos++; const u8 *pos = elem->data;
left -= 2;
if (elen > left) {
elems->parse_error = true;
break;
}
switch (id) { switch (id) {
case WLAN_EID_SSID: case WLAN_EID_SSID:
...@@ -960,8 +952,6 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, ...@@ -960,8 +952,6 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
*/ */
if (test_bit(id, seen_elems)) { if (test_bit(id, seen_elems)) {
elems->parse_error = true; elems->parse_error = true;
left -= elen;
pos += elen;
continue; continue;
} }
break; break;
...@@ -1244,12 +1234,9 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, ...@@ -1244,12 +1234,9 @@ u32 ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action,
elems->parse_error = true; elems->parse_error = true;
else else
__set_bit(id, seen_elems); __set_bit(id, seen_elems);
left -= elen;
pos += elen;
} }
if (left != 0) if (!for_each_element_completed(elem, start, len))
elems->parse_error = true; elems->parse_error = true;
return crc; return crc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment