diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-02-21 14:09:09 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-03-06 10:35:49 -0500 |
commit | f62fab735e99af2190eba03f565adaca5c002882 (patch) | |
tree | 450eb619c553539cc7515b16499d77a698b17029 /net/wireless/mlme.c | |
parent | dd5ecfeac8d1a96d0aba6bbcaec431756f8d8854 (diff) |
cfg80211: refactor association parameters
cfg80211_mlme_assoc() has grown far too many arguments,
make the caller build almost all of the driver struct
and pass that to the function instead.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/mlme.c')
-rw-r--r-- | net/wireless/mlme.c | 64 |
1 files changed, 16 insertions, 48 deletions
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index c82adfee7697..390198bf4b36 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -363,26 +363,18 @@ void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa, | |||
363 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 363 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
364 | struct net_device *dev, | 364 | struct net_device *dev, |
365 | struct ieee80211_channel *chan, | 365 | struct ieee80211_channel *chan, |
366 | const u8 *bssid, const u8 *prev_bssid, | 366 | const u8 *bssid, |
367 | const u8 *ssid, int ssid_len, | 367 | const u8 *ssid, int ssid_len, |
368 | const u8 *ie, int ie_len, bool use_mfp, | 368 | struct cfg80211_assoc_request *req) |
369 | struct cfg80211_crypto_settings *crypt, | ||
370 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
371 | struct ieee80211_ht_cap *ht_capa_mask, | ||
372 | struct ieee80211_vht_cap *vht_capa, | ||
373 | struct ieee80211_vht_cap *vht_capa_mask) | ||
374 | { | 369 | { |
375 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 370 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
376 | struct cfg80211_assoc_request req; | ||
377 | int err; | 371 | int err; |
378 | bool was_connected = false; | 372 | bool was_connected = false; |
379 | 373 | ||
380 | ASSERT_WDEV_LOCK(wdev); | 374 | ASSERT_WDEV_LOCK(wdev); |
381 | 375 | ||
382 | memset(&req, 0, sizeof(req)); | 376 | if (wdev->current_bss && req->prev_bssid && |
383 | 377 | ether_addr_equal(wdev->current_bss->pub.bssid, req->prev_bssid)) { | |
384 | if (wdev->current_bss && prev_bssid && | ||
385 | ether_addr_equal(wdev->current_bss->pub.bssid, prev_bssid)) { | ||
386 | /* | 378 | /* |
387 | * Trying to reassociate: Allow this to proceed and let the old | 379 | * Trying to reassociate: Allow this to proceed and let the old |
388 | * association to be dropped when the new one is completed. | 380 | * association to be dropped when the new one is completed. |
@@ -394,47 +386,30 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
394 | } else if (wdev->current_bss) | 386 | } else if (wdev->current_bss) |
395 | return -EALREADY; | 387 | return -EALREADY; |
396 | 388 | ||
397 | req.ie = ie; | 389 | cfg80211_oper_and_ht_capa(&req->ht_capa_mask, |
398 | req.ie_len = ie_len; | ||
399 | memcpy(&req.crypto, crypt, sizeof(req.crypto)); | ||
400 | req.use_mfp = use_mfp; | ||
401 | req.prev_bssid = prev_bssid; | ||
402 | req.flags = assoc_flags; | ||
403 | if (ht_capa) | ||
404 | memcpy(&req.ht_capa, ht_capa, sizeof(req.ht_capa)); | ||
405 | if (ht_capa_mask) | ||
406 | memcpy(&req.ht_capa_mask, ht_capa_mask, | ||
407 | sizeof(req.ht_capa_mask)); | ||
408 | cfg80211_oper_and_ht_capa(&req.ht_capa_mask, | ||
409 | rdev->wiphy.ht_capa_mod_mask); | 390 | rdev->wiphy.ht_capa_mod_mask); |
410 | if (vht_capa) | 391 | cfg80211_oper_and_vht_capa(&req->vht_capa_mask, |
411 | memcpy(&req.vht_capa, vht_capa, sizeof(req.vht_capa)); | ||
412 | if (vht_capa_mask) | ||
413 | memcpy(&req.vht_capa_mask, vht_capa_mask, | ||
414 | sizeof(req.vht_capa_mask)); | ||
415 | cfg80211_oper_and_vht_capa(&req.vht_capa_mask, | ||
416 | rdev->wiphy.vht_capa_mod_mask); | 392 | rdev->wiphy.vht_capa_mod_mask); |
417 | 393 | ||
418 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, | 394 | req->bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, |
419 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); | 395 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
420 | if (!req.bss) { | 396 | if (!req->bss) { |
421 | if (was_connected) | 397 | if (was_connected) |
422 | wdev->sme_state = CFG80211_SME_CONNECTED; | 398 | wdev->sme_state = CFG80211_SME_CONNECTED; |
423 | return -ENOENT; | 399 | return -ENOENT; |
424 | } | 400 | } |
425 | 401 | ||
426 | err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel, | 402 | err = cfg80211_can_use_chan(rdev, wdev, chan, CHAN_MODE_SHARED); |
427 | CHAN_MODE_SHARED); | ||
428 | if (err) | 403 | if (err) |
429 | goto out; | 404 | goto out; |
430 | 405 | ||
431 | err = rdev_assoc(rdev, dev, &req); | 406 | err = rdev_assoc(rdev, dev, req); |
432 | 407 | ||
433 | out: | 408 | out: |
434 | if (err) { | 409 | if (err) { |
435 | if (was_connected) | 410 | if (was_connected) |
436 | wdev->sme_state = CFG80211_SME_CONNECTED; | 411 | wdev->sme_state = CFG80211_SME_CONNECTED; |
437 | cfg80211_put_bss(&rdev->wiphy, req.bss); | 412 | cfg80211_put_bss(&rdev->wiphy, req->bss); |
438 | } | 413 | } |
439 | 414 | ||
440 | return err; | 415 | return err; |
@@ -443,24 +418,17 @@ out: | |||
443 | int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 418 | int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
444 | struct net_device *dev, | 419 | struct net_device *dev, |
445 | struct ieee80211_channel *chan, | 420 | struct ieee80211_channel *chan, |
446 | const u8 *bssid, const u8 *prev_bssid, | 421 | const u8 *bssid, |
447 | const u8 *ssid, int ssid_len, | 422 | const u8 *ssid, int ssid_len, |
448 | const u8 *ie, int ie_len, bool use_mfp, | 423 | struct cfg80211_assoc_request *req) |
449 | struct cfg80211_crypto_settings *crypt, | ||
450 | u32 assoc_flags, struct ieee80211_ht_cap *ht_capa, | ||
451 | struct ieee80211_ht_cap *ht_capa_mask, | ||
452 | struct ieee80211_vht_cap *vht_capa, | ||
453 | struct ieee80211_vht_cap *vht_capa_mask) | ||
454 | { | 424 | { |
455 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 425 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
456 | int err; | 426 | int err; |
457 | 427 | ||
458 | mutex_lock(&rdev->devlist_mtx); | 428 | mutex_lock(&rdev->devlist_mtx); |
459 | wdev_lock(wdev); | 429 | wdev_lock(wdev); |
460 | err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, | 430 | err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, |
461 | ssid, ssid_len, ie, ie_len, use_mfp, crypt, | 431 | ssid, ssid_len, req); |
462 | assoc_flags, ht_capa, ht_capa_mask, | ||
463 | vht_capa, vht_capa_mask); | ||
464 | wdev_unlock(wdev); | 432 | wdev_unlock(wdev); |
465 | mutex_unlock(&rdev->devlist_mtx); | 433 | mutex_unlock(&rdev->devlist_mtx); |
466 | 434 | ||