aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c57
1 files changed, 19 insertions, 38 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a39e4644778b..f88dbbec7521 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * This is the new netlink-based wireless configuration interface. 2 * This is the new netlink-based wireless configuration interface.
3 * 3 *
4 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net> 4 * Copyright 2006-2009 Johannes Berg <johannes@sipsolutions.net>
5 */ 5 */
6 6
7#include <linux/if.h> 7#include <linux/if.h>
@@ -1073,6 +1073,14 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
1073 } 1073 }
1074 1074
1075 err = func(&drv->wiphy, dev, key_idx); 1075 err = func(&drv->wiphy, dev, key_idx);
1076#ifdef CONFIG_WIRELESS_EXT
1077 if (!err) {
1078 if (func == drv->ops->set_default_key)
1079 dev->ieee80211_ptr->wext.default_key = key_idx;
1080 else
1081 dev->ieee80211_ptr->wext.default_mgmt_key = key_idx;
1082 }
1083#endif
1076 1084
1077 out: 1085 out:
1078 cfg80211_put_dev(drv); 1086 cfg80211_put_dev(drv);
@@ -1111,45 +1119,9 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
1111 if (info->attrs[NL80211_ATTR_MAC]) 1119 if (info->attrs[NL80211_ATTR_MAC])
1112 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 1120 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
1113 1121
1114 if (key_idx > 5) 1122 if (cfg80211_validate_key_settings(&params, key_idx, mac_addr))
1115 return -EINVAL; 1123 return -EINVAL;
1116 1124
1117 /*
1118 * Disallow pairwise keys with non-zero index unless it's WEP
1119 * (because current deployments use pairwise WEP keys with
1120 * non-zero indizes but 802.11i clearly specifies to use zero)
1121 */
1122 if (mac_addr && key_idx &&
1123 params.cipher != WLAN_CIPHER_SUITE_WEP40 &&
1124 params.cipher != WLAN_CIPHER_SUITE_WEP104)
1125 return -EINVAL;
1126
1127 /* TODO: add definitions for the lengths to linux/ieee80211.h */
1128 switch (params.cipher) {
1129 case WLAN_CIPHER_SUITE_WEP40:
1130 if (params.key_len != 5)
1131 return -EINVAL;
1132 break;
1133 case WLAN_CIPHER_SUITE_TKIP:
1134 if (params.key_len != 32)
1135 return -EINVAL;
1136 break;
1137 case WLAN_CIPHER_SUITE_CCMP:
1138 if (params.key_len != 16)
1139 return -EINVAL;
1140 break;
1141 case WLAN_CIPHER_SUITE_WEP104:
1142 if (params.key_len != 13)
1143 return -EINVAL;
1144 break;
1145 case WLAN_CIPHER_SUITE_AES_CMAC:
1146 if (params.key_len != 16)
1147 return -EINVAL;
1148 break;
1149 default:
1150 return -EINVAL;
1151 }
1152
1153 rtnl_lock(); 1125 rtnl_lock();
1154 1126
1155 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1127 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)
1210 1182
1211 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr); 1183 err = drv->ops->del_key(&drv->wiphy, dev, key_idx, mac_addr);
1212 1184
1185#ifdef CONFIG_WIRELESS_EXT
1186 if (!err) {
1187 if (key_idx == dev->ieee80211_ptr->wext.default_key)
1188 dev->ieee80211_ptr->wext.default_key = -1;
1189 else if (key_idx == dev->ieee80211_ptr->wext.default_mgmt_key)
1190 dev->ieee80211_ptr->wext.default_mgmt_key = -1;
1191 }
1192#endif
1193
1213 out: 1194 out:
1214 cfg80211_put_dev(drv); 1195 cfg80211_put_dev(drv);
1215 dev_put(dev); 1196 dev_put(dev);