diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-05-11 07:54:58 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-05-13 15:44:32 -0400 |
commit | 08645126dd24872c2e27014f93968f7312e29176 (patch) | |
tree | 2011cb3cb2f70d35278ef3b39ea696a058fb7b29 /net/wireless/nl80211.c | |
parent | 7be69c0b9aa93ef655db4d46e5654996489d62f5 (diff) |
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>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r-- | net/wireless/nl80211.c | 57 |
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(¶ms, 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); |