diff options
author | Avinash Patil <patila@marvell.com> | 2012-06-28 23:30:26 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-07-09 16:35:58 -0400 |
commit | ea4c12f02b826221510d3040469f3f8bca921d6a (patch) | |
tree | 737db28559e64922afaad4c1652e0c32b462b48d /drivers/net/wireless/mwifiex | |
parent | adb6ed0c5a8b906b3d75f4d0b1b2e252795029c0 (diff) |
mwifiex: separate IE parsing for Head/Tail IEs and beacon_ies etc
While Head/Tail IEs may contain RSN/WPA IEs which needs to be set
for all mgmt subtypes, beacon_ies, probe_resp_ies, assoc_resp_ies
are for specific mgmt subtypes. Move them to separate function.
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r-- | drivers/net/wireless/mwifiex/ie.c | 119 |
1 files changed, 65 insertions, 54 deletions
diff --git a/drivers/net/wireless/mwifiex/ie.c b/drivers/net/wireless/mwifiex/ie.c index 4a38fd8a5e1d..018ae4a1b544 100644 --- a/drivers/net/wireless/mwifiex/ie.c +++ b/drivers/net/wireless/mwifiex/ie.c | |||
@@ -217,62 +217,17 @@ mwifiex_update_uap_custom_ie(struct mwifiex_private *priv, | |||
217 | return ret; | 217 | return ret; |
218 | } | 218 | } |
219 | 219 | ||
220 | /* This function parses different IEs- Tail IEs, beacon IEs, probe response IEs, | 220 | /* This function parses beacon IEs, probe response IEs, association response IEs |
221 | * association response IEs from cfg80211_ap_settings function and sets these IE | 221 | * from cfg80211_ap_settings->beacon and sets these IE to FW. |
222 | * to FW. | ||
223 | */ | 222 | */ |
224 | int mwifiex_set_mgmt_ies(struct mwifiex_private *priv, | 223 | static int mwifiex_set_mgmt_beacon_data_ies(struct mwifiex_private *priv, |
225 | struct cfg80211_beacon_data *data) | 224 | struct cfg80211_beacon_data *data) |
226 | { | 225 | { |
227 | struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL; | 226 | struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL, *ar_ie = NULL; |
228 | struct mwifiex_ie *ar_ie = NULL, *gen_ie = NULL; | ||
229 | struct ieee_types_header *rsn_ie = NULL, *wpa_ie = NULL; | ||
230 | u16 beacon_idx = MWIFIEX_AUTO_IDX_MASK, pr_idx = MWIFIEX_AUTO_IDX_MASK; | 227 | u16 beacon_idx = MWIFIEX_AUTO_IDX_MASK, pr_idx = MWIFIEX_AUTO_IDX_MASK; |
231 | u16 ar_idx = MWIFIEX_AUTO_IDX_MASK, rsn_idx = MWIFIEX_AUTO_IDX_MASK; | 228 | u16 ar_idx = MWIFIEX_AUTO_IDX_MASK; |
232 | u16 mask, ie_len = 0; | ||
233 | const u8 *vendor_ie; | ||
234 | int ret = 0; | 229 | int ret = 0; |
235 | 230 | ||
236 | if (data->tail && data->tail_len) { | ||
237 | gen_ie = kzalloc(sizeof(struct mwifiex_ie), GFP_KERNEL); | ||
238 | if (!gen_ie) | ||
239 | return -ENOMEM; | ||
240 | gen_ie->ie_index = cpu_to_le16(rsn_idx); | ||
241 | mask = MGMT_MASK_BEACON | MGMT_MASK_PROBE_RESP | | ||
242 | MGMT_MASK_ASSOC_RESP; | ||
243 | gen_ie->mgmt_subtype_mask = cpu_to_le16(mask); | ||
244 | |||
245 | rsn_ie = (void *)cfg80211_find_ie(WLAN_EID_RSN, | ||
246 | data->tail, data->tail_len); | ||
247 | if (rsn_ie) { | ||
248 | memcpy(gen_ie->ie_buffer, rsn_ie, rsn_ie->len + 2); | ||
249 | ie_len = rsn_ie->len + 2; | ||
250 | gen_ie->ie_length = cpu_to_le16(ie_len); | ||
251 | } | ||
252 | |||
253 | vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, | ||
254 | WLAN_OUI_TYPE_MICROSOFT_WPA, | ||
255 | data->tail, data->tail_len); | ||
256 | if (vendor_ie) { | ||
257 | wpa_ie = (struct ieee_types_header *)vendor_ie; | ||
258 | memcpy(gen_ie->ie_buffer + ie_len, | ||
259 | wpa_ie, wpa_ie->len + 2); | ||
260 | ie_len += wpa_ie->len + 2; | ||
261 | gen_ie->ie_length = cpu_to_le16(ie_len); | ||
262 | } | ||
263 | |||
264 | if (rsn_ie || wpa_ie) { | ||
265 | if (mwifiex_update_uap_custom_ie(priv, gen_ie, &rsn_idx, | ||
266 | NULL, NULL, | ||
267 | NULL, NULL)) { | ||
268 | ret = -1; | ||
269 | goto done; | ||
270 | } | ||
271 | |||
272 | priv->rsn_idx = rsn_idx; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | if (data->beacon_ies && data->beacon_ies_len) { | 231 | if (data->beacon_ies && data->beacon_ies_len) { |
277 | beacon_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL); | 232 | beacon_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL); |
278 | if (!beacon_ie) { | 233 | if (!beacon_ie) { |
@@ -309,8 +264,8 @@ int mwifiex_set_mgmt_ies(struct mwifiex_private *priv, | |||
309 | } | 264 | } |
310 | 265 | ||
311 | ar_ie->ie_index = cpu_to_le16(ar_idx); | 266 | ar_ie->ie_index = cpu_to_le16(ar_idx); |
312 | mask = MGMT_MASK_ASSOC_RESP | MGMT_MASK_REASSOC_RESP; | 267 | ar_ie->mgmt_subtype_mask = cpu_to_le16(MGMT_MASK_ASSOC_RESP | |
313 | ar_ie->mgmt_subtype_mask = cpu_to_le16(mask); | 268 | MGMT_MASK_REASSOC_RESP); |
314 | ar_ie->ie_length = cpu_to_le16(data->assocresp_ies_len); | 269 | ar_ie->ie_length = cpu_to_le16(data->assocresp_ies_len); |
315 | memcpy(ar_ie->ie_buffer, data->assocresp_ies, | 270 | memcpy(ar_ie->ie_buffer, data->assocresp_ies, |
316 | data->assocresp_ies_len); | 271 | data->assocresp_ies_len); |
@@ -332,11 +287,67 @@ done: | |||
332 | kfree(beacon_ie); | 287 | kfree(beacon_ie); |
333 | kfree(pr_ie); | 288 | kfree(pr_ie); |
334 | kfree(ar_ie); | 289 | kfree(ar_ie); |
335 | kfree(gen_ie); | ||
336 | 290 | ||
337 | return ret; | 291 | return ret; |
338 | } | 292 | } |
339 | 293 | ||
294 | /* This function parses different IEs-tail IEs, beacon IEs, probe response IEs, | ||
295 | * association response IEs from cfg80211_ap_settings function and sets these IE | ||
296 | * to FW. | ||
297 | */ | ||
298 | int mwifiex_set_mgmt_ies(struct mwifiex_private *priv, | ||
299 | struct cfg80211_beacon_data *info) | ||
300 | { | ||
301 | struct mwifiex_ie *gen_ie; | ||
302 | struct ieee_types_header *rsn_ie, *wpa_ie = NULL; | ||
303 | u16 rsn_idx = MWIFIEX_AUTO_IDX_MASK, ie_len = 0; | ||
304 | const u8 *vendor_ie; | ||
305 | |||
306 | if (info->tail && info->tail_len) { | ||
307 | gen_ie = kzalloc(sizeof(struct mwifiex_ie), GFP_KERNEL); | ||
308 | if (!gen_ie) | ||
309 | return -ENOMEM; | ||
310 | gen_ie->ie_index = cpu_to_le16(rsn_idx); | ||
311 | gen_ie->mgmt_subtype_mask = cpu_to_le16(MGMT_MASK_BEACON | | ||
312 | MGMT_MASK_PROBE_RESP | | ||
313 | MGMT_MASK_ASSOC_RESP); | ||
314 | |||
315 | rsn_ie = (void *)cfg80211_find_ie(WLAN_EID_RSN, | ||
316 | info->tail, info->tail_len); | ||
317 | if (rsn_ie) { | ||
318 | memcpy(gen_ie->ie_buffer, rsn_ie, rsn_ie->len + 2); | ||
319 | ie_len = rsn_ie->len + 2; | ||
320 | gen_ie->ie_length = cpu_to_le16(ie_len); | ||
321 | } | ||
322 | |||
323 | vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, | ||
324 | WLAN_OUI_TYPE_MICROSOFT_WPA, | ||
325 | info->tail, | ||
326 | info->tail_len); | ||
327 | if (vendor_ie) { | ||
328 | wpa_ie = (struct ieee_types_header *)vendor_ie; | ||
329 | memcpy(gen_ie->ie_buffer + ie_len, | ||
330 | wpa_ie, wpa_ie->len + 2); | ||
331 | ie_len += wpa_ie->len + 2; | ||
332 | gen_ie->ie_length = cpu_to_le16(ie_len); | ||
333 | } | ||
334 | |||
335 | if (rsn_ie || wpa_ie) { | ||
336 | if (mwifiex_update_uap_custom_ie(priv, gen_ie, &rsn_idx, | ||
337 | NULL, NULL, | ||
338 | NULL, NULL)) { | ||
339 | kfree(gen_ie); | ||
340 | return -1; | ||
341 | } | ||
342 | priv->rsn_idx = rsn_idx; | ||
343 | } | ||
344 | |||
345 | kfree(gen_ie); | ||
346 | } | ||
347 | |||
348 | return mwifiex_set_mgmt_beacon_data_ies(priv, info); | ||
349 | } | ||
350 | |||
340 | /* This function removes management IE set */ | 351 | /* This function removes management IE set */ |
341 | int mwifiex_del_mgmt_ies(struct mwifiex_private *priv) | 352 | int mwifiex_del_mgmt_ies(struct mwifiex_private *priv) |
342 | { | 353 | { |