diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-03-27 09:38:07 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-04-08 03:16:58 -0400 |
commit | 79ba1d8910f517c3bd39d794ddb1a5b4c03795c4 (patch) | |
tree | faff88285c710cacce1c04beda8074b57b17801a | |
parent | 1946bed95707ef75d85e94ebe106ce7a119ca831 (diff) |
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: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | include/linux/ieee80211.h | 10 | ||||
-rw-r--r-- | net/mac80211/ieee80211_i.h | 3 | ||||
-rw-r--r-- | net/mac80211/mlme.c | 6 | ||||
-rw-r--r-- | net/mac80211/util.c | 6 |
4 files changed, 18 insertions, 7 deletions
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index d10b5bba3268..e46fea8b972e 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h | |||
@@ -1955,6 +1955,16 @@ enum ieee80211_timeout_interval_type { | |||
1955 | WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, | 1955 | WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, |
1956 | }; | 1956 | }; |
1957 | 1957 | ||
1958 | /** | ||
1959 | * struct ieee80211_timeout_interval_ie - Timeout Interval element | ||
1960 | * @type: type, see &enum ieee80211_timeout_interval_type | ||
1961 | * @value: timeout interval value | ||
1962 | */ | ||
1963 | struct ieee80211_timeout_interval_ie { | ||
1964 | u8 type; | ||
1965 | __le32 value; | ||
1966 | } __packed; | ||
1967 | |||
1958 | /* BACK action code */ | 1968 | /* BACK action code */ |
1959 | enum ieee80211_back_actioncode { | 1969 | enum ieee80211_back_actioncode { |
1960 | WLAN_ACTION_ADDBA_REQ = 0, | 1970 | WLAN_ACTION_ADDBA_REQ = 0, |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 6ad019d32623..c783e996bcce 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -1180,7 +1180,7 @@ struct ieee802_11_elems { | |||
1180 | const struct ieee80211_channel_sw_ie *ch_switch_ie; | 1180 | const struct ieee80211_channel_sw_ie *ch_switch_ie; |
1181 | const u8 *country_elem; | 1181 | const u8 *country_elem; |
1182 | const u8 *pwr_constr_elem; | 1182 | const u8 *pwr_constr_elem; |
1183 | const u8 *timeout_int; | 1183 | const struct ieee80211_timeout_interval_ie *timeout_int; |
1184 | const u8 *opmode_notif; | 1184 | const u8 *opmode_notif; |
1185 | 1185 | ||
1186 | /* length of them, respectively */ | 1186 | /* length of them, respectively */ |
@@ -1198,7 +1198,6 @@ struct ieee802_11_elems { | |||
1198 | u8 prep_len; | 1198 | u8 prep_len; |
1199 | u8 perr_len; | 1199 | u8 perr_len; |
1200 | u8 country_elem_len; | 1200 | u8 country_elem_len; |
1201 | u8 timeout_int_len; | ||
1202 | 1201 | ||
1203 | /* whether a parse error occurred while retrieving these elements */ | 1202 | /* whether a parse error occurred while retrieving these elements */ |
1204 | bool parse_error; | 1203 | bool parse_error; |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 157d951df7a4..304d6cfc6250 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -2629,10 +2629,10 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2629 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); | 2629 | ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); |
2630 | 2630 | ||
2631 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && | 2631 | if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY && |
2632 | elems.timeout_int && elems.timeout_int_len == 5 && | 2632 | elems.timeout_int && |
2633 | elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) { | 2633 | elems.timeout_int->type == WLAN_TIMEOUT_ASSOC_COMEBACK) { |
2634 | u32 tu, ms; | 2634 | u32 tu, ms; |
2635 | tu = get_unaligned_le32(elems.timeout_int + 1); | 2635 | tu = le32_to_cpu(elems.timeout_int->value); |
2636 | ms = tu * 1024 / 1000; | 2636 | ms = tu * 1024 / 1000; |
2637 | sdata_info(sdata, | 2637 | sdata_info(sdata, |
2638 | "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", | 2638 | "%pM rejected association temporarily; comeback duration %u TU (%u ms)\n", |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 4839dec5c9ac..f9581c6378ae 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -874,8 +874,10 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
874 | elems->pwr_constr_elem = pos; | 874 | elems->pwr_constr_elem = pos; |
875 | break; | 875 | break; |
876 | case WLAN_EID_TIMEOUT_INTERVAL: | 876 | case WLAN_EID_TIMEOUT_INTERVAL: |
877 | elems->timeout_int = pos; | 877 | if (elen >= sizeof(struct ieee80211_timeout_interval_ie)) |
878 | elems->timeout_int_len = elen; | 878 | elems->timeout_int = (void *)pos; |
879 | else | ||
880 | elem_parse_failed = true; | ||
879 | break; | 881 | break; |
880 | default: | 882 | default: |
881 | break; | 883 | break; |