Commit 79ba1d89 authored by Johannes Berg's avatar Johannes Berg

mac80211: parse Timeout Interval Element using a struct

Instead of open-coding the accesses and length check do
the length check in the IE parser and assign a struct
pointer for use in the remaining code.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 1946bed9
...@@ -1955,6 +1955,16 @@ enum ieee80211_timeout_interval_type { ...@@ -1955,6 +1955,16 @@ enum ieee80211_timeout_interval_type {
WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
}; };
/**
* struct ieee80211_timeout_interval_ie - Timeout Interval element
* @type: type, see &enum ieee80211_timeout_interval_type
* @value: timeout interval value
*/
struct ieee80211_timeout_interval_ie {
u8 type;
__le32 value;
} __packed;
/* BACK action code */ /* BACK action code */
enum ieee80211_back_actioncode { enum ieee80211_back_actioncode {
WLAN_ACTION_ADDBA_REQ = 0, WLAN_ACTION_ADDBA_REQ = 0,
......
...@@ -1180,7 +1180,7 @@ struct ieee802_11_elems { ...@@ -1180,7 +1180,7 @@ struct ieee802_11_elems {
const struct ieee80211_channel_sw_ie *ch_switch_ie; const struct ieee80211_channel_sw_ie *ch_switch_ie;
const u8 *country_elem; const u8 *country_elem;
const u8 *pwr_constr_elem; const u8 *pwr_constr_elem;
const u8 *timeout_int; const struct ieee80211_timeout_interval_ie *timeout_int;
const u8 *opmode_notif; const u8 *opmode_notif;
/* length of them, respectively */ /* length of them, respectively */
...@@ -1198,7 +1198,6 @@ struct ieee802_11_elems { ...@@ -1198,7 +1198,6 @@ struct ieee802_11_elems {
u8 prep_len; u8 prep_len;
u8 perr_len; u8 perr_len;
u8 country_elem_len; u8 country_elem_len;
u8 timeout_int_len;
/* whether a parse error occurred while retrieving these elements */ /* whether a parse error occurred while retrieving these elements */
bool parse_error; bool parse_error;
......
...@@ -2629,10 +2629,10 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, ...@@ -2629,10 +2629,10 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
elems.timeout_int && elems.timeout_int_len == 5 && elems.timeout_int &&
elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { elems.timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) {
u32 tu, ms; u32 tu, ms;
tu = get_unaligned_le32(elems.timeout_int + 1); tu = le32_to_cpu(elems.timeout_int->value);
ms = tu * 1024 / 1000; ms = tu * 1024 / 1000;
sdata_info(sdata, sdata_info(sdata,
"%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n",
......
...@@ -874,8 +874,10 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, ...@@ -874,8 +874,10 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
elems->pwr_constr_elem = pos; elems->pwr_constr_elem = pos;
break; break;
case WLAN_EID_TIMEOUT_INTERVAL: case WLAN_EID_TIMEOUT_INTERVAL:
elems->timeout_int = pos; if (elen >= sizeof(struct ieee80211_timeout_interval_ie))
elems->timeout_int_len = elen; elems->timeout_int = (void *)pos;
else
elem_parse_failed = true;
break; break;
default: default:
break; break;
......
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