cfg80211: implement wext key handling
Move key handling wireless extension ioctls from mac80211 to cfg80211 so that all drivers that implement the cfg80211 operations get wext compatibility. Note that this drops the SIOCGIWENCODE ioctl support for getting IW_ENCODE_RESTRICTED/IW_ENCODE_OPEN. This means that iwconfig will no longer report "Security mode:open" or "Security mode:restricted" for mac80211. However, what we displayed there (the authentication algo used) was actually wrong -- linux/wireless.h states that this setting is meant to differentiate between "Refuse non-encoded packets" and "Accept non-encoded packets". (Combined with "cfg80211: fix a couple of bugs with key ioctls". -- JWL) Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
7be69c0b9a
commit
08645126dd
+19
-38
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This is the new netlink-based wireless configuration interface.
|
||||
*
|
||||
* Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright 2006-2009 Johannes Berg <johannes@sipsolutions.net>
|
||||
*/
|
||||
|
||||
#include <linux/if.h>
|
||||
@@ -1073,6 +1073,14 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
|
||||
}
|
||||
|
||||
err = func(&drv->wiphy, dev, key_idx);
|
||||
#ifdef CONFIG_WIRELESS_EXT
|
||||
if (!err) {
|
||||
if (func == drv->ops->set_default_key)
|
||||
dev->ieee80211_ptr->wext.default_key = key_idx;
|
||||
else
|
||||
dev->ieee80211_ptr->wext.default_mgmt_key = key_idx;
|
||||
}
|
||||
#endif
|
||||
|
||||
out:
|
||||
cfg80211_put_dev(drv);
|
||||
@@ -1111,45 +1119,9 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
|
||||
if (info->attrs[NL80211_ATTR_MAC])
|
||||
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
||||
|
||||
if (key_idx > 5)
|
||||
if (cfg80211_validate_key_settings(¶ms, key_idx, mac_addr))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* Disallow pairwise keys with non-zero index unless it's WEP
|
||||
* (because current deployments use pairwise WEP keys with
|
||||
* non-zero indizes but 802.11i clearly specifies to use zero)
|
||||
*/
|
||||
if (mac_addr && key_idx &&
|
||||
params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
|
||||
params.cipher != WLAN_CIPHER_SUITE_WEP104)
|
||||
return -EINVAL;
|
||||
|
||||
/* TODO: add definitions for the lengths to linux/ieee80211.h */
|
||||
switch (params.cipher) {
|
||||
case WLAN_CIPHER_SUITE_WEP40:
|
||||
if (params.key_len != 5)
|
||||
return -EINVAL;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
if (params.key_len != 32)
|
||||
return -EINVAL;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
if (params.key_len != 16)
|
||||
return -EINVAL;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
if (params.key_len != 13)
|
||||
return -EINVAL;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
if (params.key_len != 16)
|
||||
return -EINVAL;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev);
|
||||
@@ -1210,6 +1182,15 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
|
||||
|
||||
err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
|
||||
|
||||
#ifdef CONFIG_WIRELESS_EXT
|
||||
if (!err) {
|
||||
if (key_idx == dev->ieee80211_ptr->wext.default_key)
|
||||
dev->ieee80211_ptr->wext.default_key = -1;
|
||||
else if (key_idx == dev->ieee80211_ptr->wext.default_mgmt_key)
|
||||
dev->ieee80211_ptr->wext.default_mgmt_key = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
out:
|
||||
cfg80211_put_dev(drv);
|
||||
dev_put(dev);
|
||||
|
||||
Reference in New Issue
Block a user