aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00mac.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-12-29 06:55:09 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:59:42 -0500
commitdc822b5db479dc0178d5c04cbb656dad0b6564fb (patch)
treef06d09fb4d70830ce1489f4589cb03a491833955 /drivers/net/wireless/rt2x00/rt2x00mac.c
parentb3093664c931aa06fc50da42e25b3b6dc307a915 (diff)
mac80211: clean up set_key callback
The set_key callback now seems rather odd, passing a MAC address instead of a station struct, and a local address instead of a vif struct. Change that. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Bob Copeland <me@bobcopeland.com> [ath5k] Acked-by: Ivo van Doorn <ivdoorn@gmail.com> [rt2x00] Acked-by: Christian Lamparter <chunkeey@web.de> [p54] Tested-by: Kalle Valo <kalle.valo@nokia.com> [iwl3945] Tested-by: Samuel Ortiz <samuel@sortiz.org> [iwl3945] Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00mac.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index bf7755a21645..3e204406f44f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -502,15 +502,17 @@ static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len)
502} 502}
503 503
504int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 504int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
505 const u8 *local_address, const u8 *address, 505 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
506 struct ieee80211_key_conf *key) 506 struct ieee80211_key_conf *key)
507{ 507{
508 struct rt2x00_dev *rt2x00dev = hw->priv; 508 struct rt2x00_dev *rt2x00dev = hw->priv;
509 struct ieee80211_sta *sta; 509 struct rt2x00_intf *intf = vif_to_intf(vif);
510 int (*set_key) (struct rt2x00_dev *rt2x00dev, 510 int (*set_key) (struct rt2x00_dev *rt2x00dev,
511 struct rt2x00lib_crypto *crypto, 511 struct rt2x00lib_crypto *crypto,
512 struct ieee80211_key_conf *key); 512 struct ieee80211_key_conf *key);
513 struct rt2x00lib_crypto crypto; 513 struct rt2x00lib_crypto crypto;
514 static const u8 bcast_addr[ETH_ALEN] =
515 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
514 516
515 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) 517 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
516 return 0; 518 return 0;
@@ -528,32 +530,25 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
528 if (rt2x00dev->intf_sta_count) 530 if (rt2x00dev->intf_sta_count)
529 crypto.bssidx = 0; 531 crypto.bssidx = 0;
530 else 532 else
531 crypto.bssidx = 533 crypto.bssidx = intf->mac[5] & (rt2x00dev->ops->max_ap_intf - 1);
532 local_address[5] & (rt2x00dev->ops->max_ap_intf - 1);
533 534
534 crypto.cipher = rt2x00crypto_key_to_cipher(key); 535 crypto.cipher = rt2x00crypto_key_to_cipher(key);
535 if (crypto.cipher == CIPHER_NONE) 536 if (crypto.cipher == CIPHER_NONE)
536 return -EOPNOTSUPP; 537 return -EOPNOTSUPP;
537 538
538 crypto.cmd = cmd; 539 crypto.cmd = cmd;
539 crypto.address = address; 540
541 if (sta) {
542 /* some drivers need the AID */
543 crypto.aid = sta->aid;
544 crypto.address = sta->addr;
545 } else
546 crypto.address = bcast_addr;
540 547
541 if (crypto.cipher == CIPHER_TKIP) 548 if (crypto.cipher == CIPHER_TKIP)
542 memcpy_tkip(&crypto, &key->key[0], key->keylen); 549 memcpy_tkip(&crypto, &key->key[0], key->keylen);
543 else 550 else
544 memcpy(&crypto.key, &key->key[0], key->keylen); 551 memcpy(&crypto.key, &key->key[0], key->keylen);
545
546 /*
547 * Discover the Association ID from mac80211.
548 * Some drivers need this information when updating the
549 * hardware key (either adding or removing).
550 */
551 rcu_read_lock();
552 sta = ieee80211_find_sta(hw, address);
553 if (sta)
554 crypto.aid = sta->aid;
555 rcu_read_unlock();
556
557 /* 552 /*
558 * Each BSS has a maximum of 4 shared keys. 553 * Each BSS has a maximum of 4 shared keys.
559 * Shared key index values: 554 * Shared key index values: