Johannes Berg | fee5267 | 2008-11-26 22:36:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * cfg80211 - wext compat code |
| 3 | * |
| 4 | * This is temporary code until all wireless functionality is migrated |
| 5 | * into cfg80211, when that happens all the exports here go away and |
| 6 | * we directly assign the wireless handlers of wireless interfaces. |
| 7 | * |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 8 | * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net> |
Johannes Berg | fee5267 | 2008-11-26 22:36:31 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/wireless.h> |
| 12 | #include <linux/nl80211.h> |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 13 | #include <linux/if_arp.h> |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 14 | #include <linux/etherdevice.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Johannes Berg | fee5267 | 2008-11-26 22:36:31 +0100 | [diff] [blame] | 16 | #include <net/iw_handler.h> |
Johannes Berg | fee5267 | 2008-11-26 22:36:31 +0100 | [diff] [blame] | 17 | #include <net/cfg80211.h> |
Johannes Berg | 262eb9b2 | 2011-07-13 10:39:09 +0200 | [diff] [blame^] | 18 | #include <net/cfg80211-wext.h> |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 19 | #include "wext-compat.h" |
Johannes Berg | fee5267 | 2008-11-26 22:36:31 +0100 | [diff] [blame] | 20 | #include "core.h" |
| 21 | |
| 22 | int cfg80211_wext_giwname(struct net_device *dev, |
| 23 | struct iw_request_info *info, |
| 24 | char *name, char *extra) |
| 25 | { |
| 26 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 27 | struct ieee80211_supported_band *sband; |
| 28 | bool is_ht = false, is_a = false, is_b = false, is_g = false; |
| 29 | |
| 30 | if (!wdev) |
| 31 | return -EOPNOTSUPP; |
| 32 | |
| 33 | sband = wdev->wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 34 | if (sband) { |
| 35 | is_a = true; |
| 36 | is_ht |= sband->ht_cap.ht_supported; |
| 37 | } |
| 38 | |
| 39 | sband = wdev->wiphy->bands[IEEE80211_BAND_2GHZ]; |
| 40 | if (sband) { |
| 41 | int i; |
| 42 | /* Check for mandatory rates */ |
| 43 | for (i = 0; i < sband->n_bitrates; i++) { |
| 44 | if (sband->bitrates[i].bitrate == 10) |
| 45 | is_b = true; |
| 46 | if (sband->bitrates[i].bitrate == 60) |
| 47 | is_g = true; |
| 48 | } |
| 49 | is_ht |= sband->ht_cap.ht_supported; |
| 50 | } |
| 51 | |
| 52 | strcpy(name, "IEEE 802.11"); |
| 53 | if (is_a) |
| 54 | strcat(name, "a"); |
| 55 | if (is_b) |
| 56 | strcat(name, "b"); |
| 57 | if (is_g) |
| 58 | strcat(name, "g"); |
| 59 | if (is_ht) |
| 60 | strcat(name, "n"); |
| 61 | |
| 62 | return 0; |
| 63 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 64 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwname); |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 65 | |
| 66 | int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info, |
| 67 | u32 *mode, char *extra) |
| 68 | { |
| 69 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 70 | struct cfg80211_registered_device *rdev; |
| 71 | struct vif_params vifparams; |
| 72 | enum nl80211_iftype type; |
Johannes Berg | ac7f9cf | 2009-03-21 17:07:59 +0100 | [diff] [blame] | 73 | int ret; |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 74 | |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 75 | rdev = wiphy_to_dev(wdev->wiphy); |
| 76 | |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 77 | switch (*mode) { |
| 78 | case IW_MODE_INFRA: |
| 79 | type = NL80211_IFTYPE_STATION; |
| 80 | break; |
| 81 | case IW_MODE_ADHOC: |
| 82 | type = NL80211_IFTYPE_ADHOC; |
| 83 | break; |
| 84 | case IW_MODE_REPEAT: |
| 85 | type = NL80211_IFTYPE_WDS; |
| 86 | break; |
| 87 | case IW_MODE_MONITOR: |
| 88 | type = NL80211_IFTYPE_MONITOR; |
| 89 | break; |
| 90 | default: |
| 91 | return -EINVAL; |
| 92 | } |
| 93 | |
Johannes Berg | ac7f9cf | 2009-03-21 17:07:59 +0100 | [diff] [blame] | 94 | if (type == wdev->iftype) |
| 95 | return 0; |
| 96 | |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 97 | memset(&vifparams, 0, sizeof(vifparams)); |
| 98 | |
Johannes Berg | 3d54d25 | 2009-08-21 14:51:05 +0200 | [diff] [blame] | 99 | cfg80211_lock_rdev(rdev); |
| 100 | ret = cfg80211_change_iface(rdev, dev, type, NULL, &vifparams); |
| 101 | cfg80211_unlock_rdev(rdev); |
Johannes Berg | ac7f9cf | 2009-03-21 17:07:59 +0100 | [diff] [blame] | 102 | |
| 103 | return ret; |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 104 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 105 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwmode); |
Johannes Berg | e60c774 | 2008-11-26 23:31:40 +0100 | [diff] [blame] | 106 | |
| 107 | int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info, |
| 108 | u32 *mode, char *extra) |
| 109 | { |
| 110 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 111 | |
| 112 | if (!wdev) |
| 113 | return -EOPNOTSUPP; |
| 114 | |
| 115 | switch (wdev->iftype) { |
| 116 | case NL80211_IFTYPE_AP: |
| 117 | *mode = IW_MODE_MASTER; |
| 118 | break; |
| 119 | case NL80211_IFTYPE_STATION: |
| 120 | *mode = IW_MODE_INFRA; |
| 121 | break; |
| 122 | case NL80211_IFTYPE_ADHOC: |
| 123 | *mode = IW_MODE_ADHOC; |
| 124 | break; |
| 125 | case NL80211_IFTYPE_MONITOR: |
| 126 | *mode = IW_MODE_MONITOR; |
| 127 | break; |
| 128 | case NL80211_IFTYPE_WDS: |
| 129 | *mode = IW_MODE_REPEAT; |
| 130 | break; |
| 131 | case NL80211_IFTYPE_AP_VLAN: |
| 132 | *mode = IW_MODE_SECOND; /* FIXME */ |
| 133 | break; |
| 134 | default: |
| 135 | *mode = IW_MODE_AUTO; |
| 136 | break; |
| 137 | } |
| 138 | return 0; |
| 139 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 140 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwmode); |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 141 | |
| 142 | |
| 143 | int cfg80211_wext_giwrange(struct net_device *dev, |
| 144 | struct iw_request_info *info, |
| 145 | struct iw_point *data, char *extra) |
| 146 | { |
| 147 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 148 | struct iw_range *range = (struct iw_range *) extra; |
| 149 | enum ieee80211_band band; |
Johannes Berg | 9834c07 | 2009-07-06 19:40:51 +0200 | [diff] [blame] | 150 | int i, c = 0; |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 151 | |
| 152 | if (!wdev) |
| 153 | return -EOPNOTSUPP; |
| 154 | |
| 155 | data->length = sizeof(struct iw_range); |
| 156 | memset(range, 0, sizeof(struct iw_range)); |
| 157 | |
| 158 | range->we_version_compiled = WIRELESS_EXT; |
| 159 | range->we_version_source = 21; |
| 160 | range->retry_capa = IW_RETRY_LIMIT; |
| 161 | range->retry_flags = IW_RETRY_LIMIT; |
| 162 | range->min_retry = 0; |
| 163 | range->max_retry = 255; |
| 164 | range->min_rts = 0; |
| 165 | range->max_rts = 2347; |
| 166 | range->min_frag = 256; |
| 167 | range->max_frag = 2346; |
| 168 | |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 169 | range->max_encoding_tokens = 4; |
| 170 | |
| 171 | range->max_qual.updated = IW_QUAL_NOISE_INVALID; |
| 172 | |
| 173 | switch (wdev->wiphy->signal_type) { |
| 174 | case CFG80211_SIGNAL_TYPE_NONE: |
| 175 | break; |
| 176 | case CFG80211_SIGNAL_TYPE_MBM: |
| 177 | range->max_qual.level = -110; |
| 178 | range->max_qual.qual = 70; |
| 179 | range->avg_qual.qual = 35; |
| 180 | range->max_qual.updated |= IW_QUAL_DBM; |
| 181 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; |
| 182 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; |
| 183 | break; |
| 184 | case CFG80211_SIGNAL_TYPE_UNSPEC: |
| 185 | range->max_qual.level = 100; |
| 186 | range->max_qual.qual = 100; |
| 187 | range->avg_qual.qual = 50; |
| 188 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; |
| 189 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; |
| 190 | break; |
| 191 | } |
| 192 | |
| 193 | range->avg_qual.level = range->max_qual.level / 2; |
| 194 | range->avg_qual.noise = range->max_qual.noise / 2; |
| 195 | range->avg_qual.updated = range->max_qual.updated; |
| 196 | |
Johannes Berg | 9834c07 | 2009-07-06 19:40:51 +0200 | [diff] [blame] | 197 | for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) { |
| 198 | switch (wdev->wiphy->cipher_suites[i]) { |
David Kilroy | 3daf0975 | 2009-06-18 23:21:14 +0100 | [diff] [blame] | 199 | case WLAN_CIPHER_SUITE_TKIP: |
David Kilroy | 27bea66 | 2009-06-18 23:21:17 +0100 | [diff] [blame] | 200 | range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP | |
| 201 | IW_ENC_CAPA_WPA); |
David Kilroy | 3daf0975 | 2009-06-18 23:21:14 +0100 | [diff] [blame] | 202 | break; |
| 203 | |
| 204 | case WLAN_CIPHER_SUITE_CCMP: |
David Kilroy | 27bea66 | 2009-06-18 23:21:17 +0100 | [diff] [blame] | 205 | range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP | |
| 206 | IW_ENC_CAPA_WPA2); |
David Kilroy | 3daf0975 | 2009-06-18 23:21:14 +0100 | [diff] [blame] | 207 | break; |
David Kilroy | 2ab658f | 2009-06-18 23:21:16 +0100 | [diff] [blame] | 208 | |
| 209 | case WLAN_CIPHER_SUITE_WEP40: |
| 210 | range->encoding_size[range->num_encoding_sizes++] = |
| 211 | WLAN_KEY_LEN_WEP40; |
| 212 | break; |
| 213 | |
| 214 | case WLAN_CIPHER_SUITE_WEP104: |
| 215 | range->encoding_size[range->num_encoding_sizes++] = |
| 216 | WLAN_KEY_LEN_WEP104; |
| 217 | break; |
David Kilroy | 3daf0975 | 2009-06-18 23:21:14 +0100 | [diff] [blame] | 218 | } |
| 219 | } |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 220 | |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 221 | for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 222 | struct ieee80211_supported_band *sband; |
| 223 | |
| 224 | sband = wdev->wiphy->bands[band]; |
| 225 | |
| 226 | if (!sband) |
| 227 | continue; |
| 228 | |
| 229 | for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { |
| 230 | struct ieee80211_channel *chan = &sband->channels[i]; |
| 231 | |
| 232 | if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { |
| 233 | range->freq[c].i = |
| 234 | ieee80211_frequency_to_channel( |
| 235 | chan->center_freq); |
| 236 | range->freq[c].m = chan->center_freq; |
| 237 | range->freq[c].e = 6; |
| 238 | c++; |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | range->num_channels = c; |
| 243 | range->num_frequency = c; |
| 244 | |
| 245 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa); |
| 246 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); |
| 247 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); |
| 248 | |
David Kilroy | 51cd4aa | 2009-06-18 23:21:15 +0100 | [diff] [blame] | 249 | if (wdev->wiphy->max_scan_ssids > 0) |
| 250 | range->scan_capa |= IW_SCAN_CAPA_ESSID; |
Johannes Berg | 4aa188e | 2009-02-18 19:32:08 +0100 | [diff] [blame] | 251 | |
| 252 | return 0; |
| 253 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 254 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrange); |
Johannes Berg | 691597c | 2009-04-19 19:57:45 +0200 | [diff] [blame] | 255 | |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 256 | |
| 257 | /** |
| 258 | * cfg80211_wext_freq - get wext frequency for non-"auto" |
| 259 | * @wiphy: the wiphy |
| 260 | * @freq: the wext freq encoding |
| 261 | * |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 262 | * Returns a frequency, or a negative error code, or 0 for auto. |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 263 | */ |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 264 | int cfg80211_wext_freq(struct wiphy *wiphy, struct iw_freq *freq) |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 265 | { |
Johannes Berg | 0b25858 | 2009-05-08 09:42:33 +0200 | [diff] [blame] | 266 | /* |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 267 | * Parse frequency - return 0 for auto and |
Johannes Berg | 0b25858 | 2009-05-08 09:42:33 +0200 | [diff] [blame] | 268 | * -EINVAL for impossible things. |
| 269 | */ |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 270 | if (freq->e == 0) { |
Bruno Randolf | 59eb21a | 2011-01-17 13:37:28 +0900 | [diff] [blame] | 271 | enum ieee80211_band band = IEEE80211_BAND_2GHZ; |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 272 | if (freq->m < 0) |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 273 | return 0; |
Bruno Randolf | 59eb21a | 2011-01-17 13:37:28 +0900 | [diff] [blame] | 274 | if (freq->m > 14) |
| 275 | band = IEEE80211_BAND_5GHZ; |
| 276 | return ieee80211_channel_to_frequency(freq->m, band); |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 277 | } else { |
| 278 | int i, div = 1000000; |
| 279 | for (i = 0; i < freq->e; i++) |
| 280 | div /= 10; |
Johannes Berg | 0b25858 | 2009-05-08 09:42:33 +0200 | [diff] [blame] | 281 | if (div <= 0) |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 282 | return -EINVAL; |
| 283 | return freq->m / div; |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 284 | } |
Johannes Berg | 04a773a | 2009-04-19 21:24:32 +0200 | [diff] [blame] | 285 | } |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 286 | |
| 287 | int cfg80211_wext_siwrts(struct net_device *dev, |
| 288 | struct iw_request_info *info, |
| 289 | struct iw_param *rts, char *extra) |
| 290 | { |
| 291 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 292 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 293 | u32 orts = wdev->wiphy->rts_threshold; |
| 294 | int err; |
| 295 | |
| 296 | if (rts->disabled || !rts->fixed) |
| 297 | wdev->wiphy->rts_threshold = (u32) -1; |
| 298 | else if (rts->value < 0) |
| 299 | return -EINVAL; |
| 300 | else |
| 301 | wdev->wiphy->rts_threshold = rts->value; |
| 302 | |
| 303 | err = rdev->ops->set_wiphy_params(wdev->wiphy, |
| 304 | WIPHY_PARAM_RTS_THRESHOLD); |
| 305 | if (err) |
| 306 | wdev->wiphy->rts_threshold = orts; |
| 307 | |
| 308 | return err; |
| 309 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 310 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwrts); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 311 | |
| 312 | int cfg80211_wext_giwrts(struct net_device *dev, |
| 313 | struct iw_request_info *info, |
| 314 | struct iw_param *rts, char *extra) |
| 315 | { |
| 316 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 317 | |
| 318 | rts->value = wdev->wiphy->rts_threshold; |
| 319 | rts->disabled = rts->value == (u32) -1; |
| 320 | rts->fixed = 1; |
| 321 | |
| 322 | return 0; |
| 323 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 324 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrts); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 325 | |
| 326 | int cfg80211_wext_siwfrag(struct net_device *dev, |
| 327 | struct iw_request_info *info, |
| 328 | struct iw_param *frag, char *extra) |
| 329 | { |
| 330 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 331 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 332 | u32 ofrag = wdev->wiphy->frag_threshold; |
| 333 | int err; |
| 334 | |
| 335 | if (frag->disabled || !frag->fixed) |
| 336 | wdev->wiphy->frag_threshold = (u32) -1; |
| 337 | else if (frag->value < 256) |
| 338 | return -EINVAL; |
| 339 | else { |
| 340 | /* Fragment length must be even, so strip LSB. */ |
| 341 | wdev->wiphy->frag_threshold = frag->value & ~0x1; |
| 342 | } |
| 343 | |
| 344 | err = rdev->ops->set_wiphy_params(wdev->wiphy, |
| 345 | WIPHY_PARAM_FRAG_THRESHOLD); |
| 346 | if (err) |
| 347 | wdev->wiphy->frag_threshold = ofrag; |
| 348 | |
| 349 | return err; |
| 350 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 351 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwfrag); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 352 | |
| 353 | int cfg80211_wext_giwfrag(struct net_device *dev, |
| 354 | struct iw_request_info *info, |
| 355 | struct iw_param *frag, char *extra) |
| 356 | { |
| 357 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 358 | |
| 359 | frag->value = wdev->wiphy->frag_threshold; |
| 360 | frag->disabled = frag->value == (u32) -1; |
| 361 | frag->fixed = 1; |
| 362 | |
| 363 | return 0; |
| 364 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 365 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwfrag); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 366 | |
| 367 | int cfg80211_wext_siwretry(struct net_device *dev, |
| 368 | struct iw_request_info *info, |
| 369 | struct iw_param *retry, char *extra) |
| 370 | { |
| 371 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 372 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 373 | u32 changed = 0; |
| 374 | u8 olong = wdev->wiphy->retry_long; |
| 375 | u8 oshort = wdev->wiphy->retry_short; |
| 376 | int err; |
| 377 | |
| 378 | if (retry->disabled || |
| 379 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) |
| 380 | return -EINVAL; |
| 381 | |
| 382 | if (retry->flags & IW_RETRY_LONG) { |
| 383 | wdev->wiphy->retry_long = retry->value; |
| 384 | changed |= WIPHY_PARAM_RETRY_LONG; |
| 385 | } else if (retry->flags & IW_RETRY_SHORT) { |
| 386 | wdev->wiphy->retry_short = retry->value; |
| 387 | changed |= WIPHY_PARAM_RETRY_SHORT; |
| 388 | } else { |
| 389 | wdev->wiphy->retry_short = retry->value; |
| 390 | wdev->wiphy->retry_long = retry->value; |
| 391 | changed |= WIPHY_PARAM_RETRY_LONG; |
| 392 | changed |= WIPHY_PARAM_RETRY_SHORT; |
| 393 | } |
| 394 | |
| 395 | if (!changed) |
| 396 | return 0; |
| 397 | |
| 398 | err = rdev->ops->set_wiphy_params(wdev->wiphy, changed); |
| 399 | if (err) { |
| 400 | wdev->wiphy->retry_short = oshort; |
| 401 | wdev->wiphy->retry_long = olong; |
| 402 | } |
| 403 | |
| 404 | return err; |
| 405 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 406 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwretry); |
Jouni Malinen | b9a5f8ca | 2009-04-20 18:39:05 +0200 | [diff] [blame] | 407 | |
| 408 | int cfg80211_wext_giwretry(struct net_device *dev, |
| 409 | struct iw_request_info *info, |
| 410 | struct iw_param *retry, char *extra) |
| 411 | { |
| 412 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 413 | |
| 414 | retry->disabled = 0; |
| 415 | |
| 416 | if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) { |
| 417 | /* |
| 418 | * First return short value, iwconfig will ask long value |
| 419 | * later if needed |
| 420 | */ |
| 421 | retry->flags |= IW_RETRY_LIMIT; |
| 422 | retry->value = wdev->wiphy->retry_short; |
| 423 | if (wdev->wiphy->retry_long != wdev->wiphy->retry_short) |
| 424 | retry->flags |= IW_RETRY_LONG; |
| 425 | |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | if (retry->flags & IW_RETRY_LONG) { |
| 430 | retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; |
| 431 | retry->value = wdev->wiphy->retry_long; |
| 432 | } |
| 433 | |
| 434 | return 0; |
| 435 | } |
Johannes Berg | ba44cb7 | 2009-04-20 18:49:39 +0200 | [diff] [blame] | 436 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwretry); |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 437 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 438 | static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 439 | struct net_device *dev, bool pairwise, |
| 440 | const u8 *addr, bool remove, bool tx_key, |
| 441 | int idx, struct key_params *params) |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 442 | { |
| 443 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 444 | int err, i; |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 445 | bool rejoin = false; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 446 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 447 | if (pairwise && !addr) |
| 448 | return -EINVAL; |
| 449 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 450 | if (!wdev->wext.keys) { |
| 451 | wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys), |
| 452 | GFP_KERNEL); |
| 453 | if (!wdev->wext.keys) |
| 454 | return -ENOMEM; |
| 455 | for (i = 0; i < 6; i++) |
| 456 | wdev->wext.keys->params[i].key = |
| 457 | wdev->wext.keys->data[i]; |
| 458 | } |
| 459 | |
| 460 | if (wdev->iftype != NL80211_IFTYPE_ADHOC && |
| 461 | wdev->iftype != NL80211_IFTYPE_STATION) |
| 462 | return -EOPNOTSUPP; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 463 | |
| 464 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 465 | if (!wdev->current_bss) |
| 466 | return -ENOLINK; |
| 467 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 468 | if (!rdev->ops->set_default_mgmt_key) |
| 469 | return -EOPNOTSUPP; |
| 470 | |
| 471 | if (idx < 4 || idx > 5) |
| 472 | return -EINVAL; |
| 473 | } else if (idx < 0 || idx > 3) |
| 474 | return -EINVAL; |
| 475 | |
| 476 | if (remove) { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 477 | err = 0; |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 478 | if (wdev->current_bss) { |
| 479 | /* |
| 480 | * If removing the current TX key, we will need to |
| 481 | * join a new IBSS without the privacy bit clear. |
| 482 | */ |
| 483 | if (idx == wdev->wext.default_key && |
| 484 | wdev->iftype == NL80211_IFTYPE_ADHOC) { |
| 485 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); |
| 486 | rejoin = true; |
| 487 | } |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 488 | |
| 489 | if (!pairwise && addr && |
| 490 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
| 491 | err = -ENOENT; |
| 492 | else |
| 493 | err = rdev->ops->del_key(&rdev->wiphy, dev, idx, |
| 494 | pairwise, addr); |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 495 | } |
Vivek Natarajan | d55fb89 | 2009-11-24 11:54:10 -0500 | [diff] [blame] | 496 | wdev->wext.connect.privacy = false; |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 497 | /* |
| 498 | * Applications using wireless extensions expect to be |
| 499 | * able to delete keys that don't exist, so allow that. |
| 500 | */ |
| 501 | if (err == -ENOENT) |
| 502 | err = 0; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 503 | if (!err) { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 504 | if (!addr) { |
| 505 | wdev->wext.keys->params[idx].key_len = 0; |
| 506 | wdev->wext.keys->params[idx].cipher = 0; |
| 507 | } |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 508 | if (idx == wdev->wext.default_key) |
| 509 | wdev->wext.default_key = -1; |
| 510 | else if (idx == wdev->wext.default_mgmt_key) |
| 511 | wdev->wext.default_mgmt_key = -1; |
| 512 | } |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 513 | |
| 514 | if (!err && rejoin) |
| 515 | err = cfg80211_ibss_wext_join(rdev, wdev); |
Johannes Berg | e3da574 | 2009-05-18 19:56:36 +0200 | [diff] [blame] | 516 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 517 | return err; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 518 | } |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 519 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 520 | if (addr) |
| 521 | tx_key = false; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 522 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 523 | if (cfg80211_validate_key_settings(rdev, params, idx, pairwise, addr)) |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 524 | return -EINVAL; |
| 525 | |
| 526 | err = 0; |
| 527 | if (wdev->current_bss) |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 528 | err = rdev->ops->add_key(&rdev->wiphy, dev, idx, |
| 529 | pairwise, addr, params); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 530 | if (err) |
| 531 | return err; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 532 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 533 | if (!addr) { |
| 534 | wdev->wext.keys->params[idx] = *params; |
| 535 | memcpy(wdev->wext.keys->data[idx], |
| 536 | params->key, params->key_len); |
| 537 | wdev->wext.keys->params[idx].key = |
| 538 | wdev->wext.keys->data[idx]; |
| 539 | } |
| 540 | |
Zhu Yi | 1f00fca | 2009-07-20 11:47:43 +0800 | [diff] [blame] | 541 | if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 || |
| 542 | params->cipher == WLAN_CIPHER_SUITE_WEP104) && |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 543 | (tx_key || (!addr && wdev->wext.default_key == -1))) { |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 544 | if (wdev->current_bss) { |
| 545 | /* |
| 546 | * If we are getting a new TX key from not having |
| 547 | * had one before we need to join a new IBSS with |
| 548 | * the privacy bit set. |
| 549 | */ |
| 550 | if (wdev->iftype == NL80211_IFTYPE_ADHOC && |
| 551 | wdev->wext.default_key == -1) { |
| 552 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); |
| 553 | rejoin = true; |
| 554 | } |
Johannes Berg | dbd2fd6 | 2010-12-09 19:58:59 +0100 | [diff] [blame] | 555 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, |
| 556 | idx, true, true); |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 557 | } |
| 558 | if (!err) { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 559 | wdev->wext.default_key = idx; |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 560 | if (rejoin) |
| 561 | err = cfg80211_ibss_wext_join(rdev, wdev); |
| 562 | } |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 563 | return err; |
| 564 | } |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 565 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 566 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && |
| 567 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { |
| 568 | if (wdev->current_bss) |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 569 | err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, |
| 570 | dev, idx); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 571 | if (!err) |
| 572 | wdev->wext.default_mgmt_key = idx; |
| 573 | return err; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 574 | } |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 575 | |
| 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev, |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 580 | struct net_device *dev, bool pairwise, |
| 581 | const u8 *addr, bool remove, bool tx_key, |
| 582 | int idx, struct key_params *params) |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 583 | { |
| 584 | int err; |
| 585 | |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 586 | /* devlist mutex needed for possible IBSS re-join */ |
| 587 | mutex_lock(&rdev->devlist_mtx); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 588 | wdev_lock(dev->ieee80211_ptr); |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 589 | err = __cfg80211_set_encryption(rdev, dev, pairwise, addr, |
| 590 | remove, tx_key, idx, params); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 591 | wdev_unlock(dev->ieee80211_ptr); |
Johannes Berg | 98d3a7c | 2009-11-18 13:03:43 +0100 | [diff] [blame] | 592 | mutex_unlock(&rdev->devlist_mtx); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 593 | |
| 594 | return err; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | int cfg80211_wext_siwencode(struct net_device *dev, |
| 598 | struct iw_request_info *info, |
| 599 | struct iw_point *erq, char *keybuf) |
| 600 | { |
| 601 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 602 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 603 | int idx, err; |
| 604 | bool remove = false; |
| 605 | struct key_params params; |
| 606 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 607 | if (wdev->iftype != NL80211_IFTYPE_STATION && |
| 608 | wdev->iftype != NL80211_IFTYPE_ADHOC) |
| 609 | return -EOPNOTSUPP; |
| 610 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 611 | /* no use -- only MFP (set_default_mgmt_key) is optional */ |
| 612 | if (!rdev->ops->del_key || |
| 613 | !rdev->ops->add_key || |
| 614 | !rdev->ops->set_default_key) |
| 615 | return -EOPNOTSUPP; |
| 616 | |
| 617 | idx = erq->flags & IW_ENCODE_INDEX; |
| 618 | if (idx == 0) { |
| 619 | idx = wdev->wext.default_key; |
| 620 | if (idx < 0) |
| 621 | idx = 0; |
| 622 | } else if (idx < 1 || idx > 4) |
| 623 | return -EINVAL; |
| 624 | else |
| 625 | idx--; |
| 626 | |
| 627 | if (erq->flags & IW_ENCODE_DISABLED) |
| 628 | remove = true; |
| 629 | else if (erq->length == 0) { |
| 630 | /* No key data - just set the default TX key index */ |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 631 | err = 0; |
| 632 | wdev_lock(wdev); |
| 633 | if (wdev->current_bss) |
Johannes Berg | dbd2fd6 | 2010-12-09 19:58:59 +0100 | [diff] [blame] | 634 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, |
| 635 | idx, true, true); |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 636 | if (!err) |
| 637 | wdev->wext.default_key = idx; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 638 | wdev_unlock(wdev); |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 639 | return err; |
| 640 | } |
| 641 | |
| 642 | memset(¶ms, 0, sizeof(params)); |
| 643 | params.key = keybuf; |
| 644 | params.key_len = erq->length; |
| 645 | if (erq->length == 5) |
| 646 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 647 | else if (erq->length == 13) |
| 648 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 649 | else if (!remove) |
| 650 | return -EINVAL; |
| 651 | |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 652 | return cfg80211_set_encryption(rdev, dev, false, NULL, remove, |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 653 | wdev->wext.default_key == -1, |
| 654 | idx, ¶ms); |
| 655 | } |
| 656 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwencode); |
| 657 | |
| 658 | int cfg80211_wext_siwencodeext(struct net_device *dev, |
| 659 | struct iw_request_info *info, |
| 660 | struct iw_point *erq, char *extra) |
| 661 | { |
| 662 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 663 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 664 | struct iw_encode_ext *ext = (struct iw_encode_ext *) extra; |
| 665 | const u8 *addr; |
| 666 | int idx; |
| 667 | bool remove = false; |
| 668 | struct key_params params; |
| 669 | u32 cipher; |
| 670 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 671 | if (wdev->iftype != NL80211_IFTYPE_STATION && |
| 672 | wdev->iftype != NL80211_IFTYPE_ADHOC) |
| 673 | return -EOPNOTSUPP; |
| 674 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 675 | /* no use -- only MFP (set_default_mgmt_key) is optional */ |
| 676 | if (!rdev->ops->del_key || |
| 677 | !rdev->ops->add_key || |
| 678 | !rdev->ops->set_default_key) |
| 679 | return -EOPNOTSUPP; |
| 680 | |
| 681 | switch (ext->alg) { |
| 682 | case IW_ENCODE_ALG_NONE: |
| 683 | remove = true; |
| 684 | cipher = 0; |
| 685 | break; |
| 686 | case IW_ENCODE_ALG_WEP: |
| 687 | if (ext->key_len == 5) |
| 688 | cipher = WLAN_CIPHER_SUITE_WEP40; |
| 689 | else if (ext->key_len == 13) |
| 690 | cipher = WLAN_CIPHER_SUITE_WEP104; |
| 691 | else |
| 692 | return -EINVAL; |
| 693 | break; |
| 694 | case IW_ENCODE_ALG_TKIP: |
| 695 | cipher = WLAN_CIPHER_SUITE_TKIP; |
| 696 | break; |
| 697 | case IW_ENCODE_ALG_CCMP: |
| 698 | cipher = WLAN_CIPHER_SUITE_CCMP; |
| 699 | break; |
| 700 | case IW_ENCODE_ALG_AES_CMAC: |
| 701 | cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 702 | break; |
| 703 | default: |
| 704 | return -EOPNOTSUPP; |
| 705 | } |
| 706 | |
| 707 | if (erq->flags & IW_ENCODE_DISABLED) |
| 708 | remove = true; |
| 709 | |
| 710 | idx = erq->flags & IW_ENCODE_INDEX; |
| 711 | if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) { |
| 712 | if (idx < 4 || idx > 5) { |
| 713 | idx = wdev->wext.default_mgmt_key; |
| 714 | if (idx < 0) |
| 715 | return -EINVAL; |
| 716 | } else |
| 717 | idx--; |
| 718 | } else { |
| 719 | if (idx < 1 || idx > 4) { |
| 720 | idx = wdev->wext.default_key; |
| 721 | if (idx < 0) |
| 722 | return -EINVAL; |
| 723 | } else |
| 724 | idx--; |
| 725 | } |
| 726 | |
| 727 | addr = ext->addr.sa_data; |
| 728 | if (is_broadcast_ether_addr(addr)) |
| 729 | addr = NULL; |
| 730 | |
| 731 | memset(¶ms, 0, sizeof(params)); |
| 732 | params.key = ext->key; |
| 733 | params.key_len = ext->key_len; |
| 734 | params.cipher = cipher; |
| 735 | |
Jouni Malinen | faa8fdc | 2009-05-11 21:57:58 +0300 | [diff] [blame] | 736 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { |
| 737 | params.seq = ext->rx_seq; |
| 738 | params.seq_len = 6; |
| 739 | } |
| 740 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 741 | return cfg80211_set_encryption( |
Johannes Berg | e31b821 | 2010-10-05 19:39:30 +0200 | [diff] [blame] | 742 | rdev, dev, |
| 743 | !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY), |
| 744 | addr, remove, |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 745 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, |
| 746 | idx, ¶ms); |
| 747 | } |
| 748 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwencodeext); |
| 749 | |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 750 | int cfg80211_wext_giwencode(struct net_device *dev, |
| 751 | struct iw_request_info *info, |
| 752 | struct iw_point *erq, char *keybuf) |
| 753 | { |
| 754 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 755 | int idx; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 756 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 757 | if (wdev->iftype != NL80211_IFTYPE_STATION && |
| 758 | wdev->iftype != NL80211_IFTYPE_ADHOC) |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 759 | return -EOPNOTSUPP; |
| 760 | |
| 761 | idx = erq->flags & IW_ENCODE_INDEX; |
| 762 | if (idx == 0) { |
| 763 | idx = wdev->wext.default_key; |
| 764 | if (idx < 0) |
| 765 | idx = 0; |
| 766 | } else if (idx < 1 || idx > 4) |
| 767 | return -EINVAL; |
| 768 | else |
| 769 | idx--; |
| 770 | |
| 771 | erq->flags = idx + 1; |
| 772 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 773 | if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) { |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 774 | erq->flags |= IW_ENCODE_DISABLED; |
| 775 | erq->length = 0; |
| 776 | return 0; |
| 777 | } |
| 778 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 779 | erq->length = min_t(size_t, erq->length, |
| 780 | wdev->wext.keys->params[idx].key_len); |
| 781 | memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length); |
| 782 | erq->flags |= IW_ENCODE_ENABLED; |
| 783 | |
| 784 | return 0; |
Johannes Berg | 0864512 | 2009-05-11 13:54:58 +0200 | [diff] [blame] | 785 | } |
| 786 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwencode); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 787 | |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 788 | int cfg80211_wext_siwfreq(struct net_device *dev, |
| 789 | struct iw_request_info *info, |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 790 | struct iw_freq *wextfreq, char *extra) |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 791 | { |
| 792 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 793 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 794 | int freq, err; |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 795 | |
| 796 | switch (wdev->iftype) { |
| 797 | case NL80211_IFTYPE_STATION: |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 798 | return cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra); |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 799 | case NL80211_IFTYPE_ADHOC: |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 800 | return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra); |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 801 | case NL80211_IFTYPE_MONITOR: |
| 802 | case NL80211_IFTYPE_WDS: |
| 803 | case NL80211_IFTYPE_MESH_POINT: |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 804 | freq = cfg80211_wext_freq(wdev->wiphy, wextfreq); |
| 805 | if (freq < 0) |
| 806 | return freq; |
| 807 | if (freq == 0) |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 808 | return -EINVAL; |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 809 | mutex_lock(&rdev->devlist_mtx); |
Daniel J Blueman | 4f919a3 | 2011-02-22 00:11:06 +0800 | [diff] [blame] | 810 | wdev_lock(wdev); |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 811 | err = cfg80211_set_freq(rdev, wdev, freq, NL80211_CHAN_NO_HT); |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 812 | wdev_unlock(wdev); |
Daniel J Blueman | 4f919a3 | 2011-02-22 00:11:06 +0800 | [diff] [blame] | 813 | mutex_unlock(&rdev->devlist_mtx); |
Johannes Berg | 59bbb6f | 2009-08-07 17:22:35 +0200 | [diff] [blame] | 814 | return err; |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 815 | default: |
| 816 | return -EOPNOTSUPP; |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 817 | } |
| 818 | } |
Jussi Kivilinna | a8b875e | 2009-08-13 20:39:31 +0300 | [diff] [blame] | 819 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwfreq); |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 820 | |
| 821 | int cfg80211_wext_giwfreq(struct net_device *dev, |
| 822 | struct iw_request_info *info, |
| 823 | struct iw_freq *freq, char *extra) |
| 824 | { |
| 825 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 826 | |
| 827 | switch (wdev->iftype) { |
| 828 | case NL80211_IFTYPE_STATION: |
| 829 | return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); |
| 830 | case NL80211_IFTYPE_ADHOC: |
| 831 | return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); |
| 832 | default: |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 833 | if (!wdev->channel) |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 834 | return -EINVAL; |
Johannes Berg | f444de0 | 2010-05-05 15:25:02 +0200 | [diff] [blame] | 835 | freq->m = wdev->channel->center_freq; |
Johannes Berg | 0e82ffe | 2009-07-27 12:01:50 +0200 | [diff] [blame] | 836 | freq->e = 6; |
| 837 | return 0; |
| 838 | } |
| 839 | } |
| 840 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwfreq); |
| 841 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 842 | int cfg80211_wext_siwtxpower(struct net_device *dev, |
| 843 | struct iw_request_info *info, |
| 844 | union iwreq_data *data, char *extra) |
| 845 | { |
| 846 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 847 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 848 | enum nl80211_tx_power_setting type; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 849 | int dbm = 0; |
| 850 | |
| 851 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) |
| 852 | return -EINVAL; |
| 853 | if (data->txpower.flags & IW_TXPOW_RANGE) |
| 854 | return -EINVAL; |
| 855 | |
| 856 | if (!rdev->ops->set_tx_power) |
| 857 | return -EOPNOTSUPP; |
| 858 | |
| 859 | /* only change when not disabling */ |
| 860 | if (!data->txpower.disabled) { |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 861 | rfkill_set_sw_state(rdev->rfkill, false); |
| 862 | |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 863 | if (data->txpower.fixed) { |
| 864 | /* |
| 865 | * wext doesn't support negative values, see |
| 866 | * below where it's for automatic |
| 867 | */ |
| 868 | if (data->txpower.value < 0) |
| 869 | return -EINVAL; |
| 870 | dbm = data->txpower.value; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 871 | type = NL80211_TX_POWER_FIXED; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 872 | /* TODO: do regulatory check! */ |
| 873 | } else { |
| 874 | /* |
| 875 | * Automatic power level setting, max being the value |
| 876 | * passed in from userland. |
| 877 | */ |
| 878 | if (data->txpower.value < 0) { |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 879 | type = NL80211_TX_POWER_AUTOMATIC; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 880 | } else { |
| 881 | dbm = data->txpower.value; |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 882 | type = NL80211_TX_POWER_LIMITED; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 883 | } |
| 884 | } |
| 885 | } else { |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 886 | rfkill_set_sw_state(rdev->rfkill, true); |
| 887 | schedule_work(&rdev->rfkill_sync); |
| 888 | return 0; |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 889 | } |
| 890 | |
Juuso Oikarinen | fa61cf7 | 2010-06-23 12:12:37 +0300 | [diff] [blame] | 891 | return rdev->ops->set_tx_power(wdev->wiphy, type, DBM_TO_MBM(dbm)); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 892 | } |
| 893 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwtxpower); |
| 894 | |
| 895 | int cfg80211_wext_giwtxpower(struct net_device *dev, |
| 896 | struct iw_request_info *info, |
| 897 | union iwreq_data *data, char *extra) |
| 898 | { |
| 899 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 900 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 901 | int err, val; |
| 902 | |
| 903 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) |
| 904 | return -EINVAL; |
| 905 | if (data->txpower.flags & IW_TXPOW_RANGE) |
| 906 | return -EINVAL; |
| 907 | |
| 908 | if (!rdev->ops->get_tx_power) |
| 909 | return -EOPNOTSUPP; |
| 910 | |
| 911 | err = rdev->ops->get_tx_power(wdev->wiphy, &val); |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 912 | if (err) |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 913 | return err; |
| 914 | |
| 915 | /* well... oh well */ |
| 916 | data->txpower.fixed = 1; |
Johannes Berg | 1f87f7d | 2009-06-02 13:01:41 +0200 | [diff] [blame] | 917 | data->txpower.disabled = rfkill_blocked(rdev->rfkill); |
Johannes Berg | 7643a2c | 2009-06-02 13:01:39 +0200 | [diff] [blame] | 918 | data->txpower.value = val; |
| 919 | data->txpower.flags = IW_TXPOW_DBM; |
| 920 | |
| 921 | return 0; |
| 922 | } |
| 923 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwtxpower); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 924 | |
| 925 | static int cfg80211_set_auth_alg(struct wireless_dev *wdev, |
| 926 | s32 auth_alg) |
| 927 | { |
| 928 | int nr_alg = 0; |
| 929 | |
| 930 | if (!auth_alg) |
| 931 | return -EINVAL; |
| 932 | |
| 933 | if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM | |
| 934 | IW_AUTH_ALG_SHARED_KEY | |
| 935 | IW_AUTH_ALG_LEAP)) |
| 936 | return -EINVAL; |
| 937 | |
| 938 | if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) { |
| 939 | nr_alg++; |
| 940 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; |
| 941 | } |
| 942 | |
| 943 | if (auth_alg & IW_AUTH_ALG_SHARED_KEY) { |
| 944 | nr_alg++; |
| 945 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; |
| 946 | } |
| 947 | |
| 948 | if (auth_alg & IW_AUTH_ALG_LEAP) { |
| 949 | nr_alg++; |
| 950 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; |
| 951 | } |
| 952 | |
| 953 | if (nr_alg > 1) |
| 954 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; |
| 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions) |
| 960 | { |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 961 | if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA | |
Gábor Stefanik | 323d566 | 2009-07-12 02:03:48 +0200 | [diff] [blame] | 962 | IW_AUTH_WPA_VERSION_WPA2| |
| 963 | IW_AUTH_WPA_VERSION_DISABLED)) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 964 | return -EINVAL; |
| 965 | |
Gábor Stefanik | 323d566 | 2009-07-12 02:03:48 +0200 | [diff] [blame] | 966 | if ((wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) && |
| 967 | (wpa_versions & (IW_AUTH_WPA_VERSION_WPA| |
| 968 | IW_AUTH_WPA_VERSION_WPA2))) |
| 969 | return -EINVAL; |
| 970 | |
| 971 | if (wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) |
| 972 | wdev->wext.connect.crypto.wpa_versions &= |
| 973 | ~(NL80211_WPA_VERSION_1|NL80211_WPA_VERSION_2); |
| 974 | |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 975 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA) |
| 976 | wdev->wext.connect.crypto.wpa_versions |= |
| 977 | NL80211_WPA_VERSION_1; |
| 978 | |
| 979 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2) |
| 980 | wdev->wext.connect.crypto.wpa_versions |= |
| 981 | NL80211_WPA_VERSION_2; |
| 982 | |
| 983 | return 0; |
| 984 | } |
| 985 | |
Johannes Berg | 4f5dadc | 2009-07-07 03:56:10 +0200 | [diff] [blame] | 986 | static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 987 | { |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 988 | if (cipher & IW_AUTH_CIPHER_WEP40) |
| 989 | wdev->wext.connect.crypto.cipher_group = |
| 990 | WLAN_CIPHER_SUITE_WEP40; |
| 991 | else if (cipher & IW_AUTH_CIPHER_WEP104) |
| 992 | wdev->wext.connect.crypto.cipher_group = |
| 993 | WLAN_CIPHER_SUITE_WEP104; |
| 994 | else if (cipher & IW_AUTH_CIPHER_TKIP) |
| 995 | wdev->wext.connect.crypto.cipher_group = |
| 996 | WLAN_CIPHER_SUITE_TKIP; |
| 997 | else if (cipher & IW_AUTH_CIPHER_CCMP) |
| 998 | wdev->wext.connect.crypto.cipher_group = |
| 999 | WLAN_CIPHER_SUITE_CCMP; |
| 1000 | else if (cipher & IW_AUTH_CIPHER_AES_CMAC) |
| 1001 | wdev->wext.connect.crypto.cipher_group = |
| 1002 | WLAN_CIPHER_SUITE_AES_CMAC; |
Jouni Malinen | c5f8289 | 2009-11-01 11:18:49 +0200 | [diff] [blame] | 1003 | else if (cipher & IW_AUTH_CIPHER_NONE) |
| 1004 | wdev->wext.connect.crypto.cipher_group = 0; |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 1005 | else |
| 1006 | return -EINVAL; |
| 1007 | |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
Johannes Berg | 4f5dadc | 2009-07-07 03:56:10 +0200 | [diff] [blame] | 1011 | static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 1012 | { |
| 1013 | int nr_ciphers = 0; |
| 1014 | u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; |
| 1015 | |
| 1016 | if (cipher & IW_AUTH_CIPHER_WEP40) { |
| 1017 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40; |
| 1018 | nr_ciphers++; |
| 1019 | } |
| 1020 | |
| 1021 | if (cipher & IW_AUTH_CIPHER_WEP104) { |
| 1022 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104; |
| 1023 | nr_ciphers++; |
| 1024 | } |
| 1025 | |
| 1026 | if (cipher & IW_AUTH_CIPHER_TKIP) { |
| 1027 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP; |
| 1028 | nr_ciphers++; |
| 1029 | } |
| 1030 | |
| 1031 | if (cipher & IW_AUTH_CIPHER_CCMP) { |
| 1032 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP; |
| 1033 | nr_ciphers++; |
| 1034 | } |
| 1035 | |
| 1036 | if (cipher & IW_AUTH_CIPHER_AES_CMAC) { |
| 1037 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC; |
| 1038 | nr_ciphers++; |
| 1039 | } |
| 1040 | |
| 1041 | BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5); |
| 1042 | |
| 1043 | wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; |
| 1044 | |
| 1045 | return 0; |
| 1046 | } |
| 1047 | |
| 1048 | |
Johannes Berg | 4f5dadc | 2009-07-07 03:56:10 +0200 | [diff] [blame] | 1049 | static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 1050 | { |
| 1051 | int nr_akm_suites = 0; |
| 1052 | |
| 1053 | if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X | |
| 1054 | IW_AUTH_KEY_MGMT_PSK)) |
| 1055 | return -EINVAL; |
| 1056 | |
| 1057 | if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) { |
| 1058 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = |
| 1059 | WLAN_AKM_SUITE_8021X; |
| 1060 | nr_akm_suites++; |
| 1061 | } |
| 1062 | |
| 1063 | if (key_mgt & IW_AUTH_KEY_MGMT_PSK) { |
| 1064 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = |
| 1065 | WLAN_AKM_SUITE_PSK; |
| 1066 | nr_akm_suites++; |
| 1067 | } |
| 1068 | |
| 1069 | wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; |
| 1070 | |
| 1071 | return 0; |
| 1072 | } |
| 1073 | |
| 1074 | int cfg80211_wext_siwauth(struct net_device *dev, |
| 1075 | struct iw_request_info *info, |
| 1076 | struct iw_param *data, char *extra) |
| 1077 | { |
| 1078 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1079 | |
| 1080 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 1081 | return -EOPNOTSUPP; |
| 1082 | |
| 1083 | switch (data->flags & IW_AUTH_INDEX) { |
| 1084 | case IW_AUTH_PRIVACY_INVOKED: |
| 1085 | wdev->wext.connect.privacy = data->value; |
| 1086 | return 0; |
| 1087 | case IW_AUTH_WPA_VERSION: |
| 1088 | return cfg80211_set_wpa_version(wdev, data->value); |
| 1089 | case IW_AUTH_CIPHER_GROUP: |
| 1090 | return cfg80211_set_cipher_group(wdev, data->value); |
| 1091 | case IW_AUTH_KEY_MGMT: |
| 1092 | return cfg80211_set_key_mgt(wdev, data->value); |
| 1093 | case IW_AUTH_CIPHER_PAIRWISE: |
| 1094 | return cfg80211_set_cipher_pairwise(wdev, data->value); |
| 1095 | case IW_AUTH_80211_AUTH_ALG: |
| 1096 | return cfg80211_set_auth_alg(wdev, data->value); |
| 1097 | case IW_AUTH_WPA_ENABLED: |
| 1098 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: |
| 1099 | case IW_AUTH_DROP_UNENCRYPTED: |
| 1100 | case IW_AUTH_MFP: |
| 1101 | return 0; |
| 1102 | default: |
| 1103 | return -EOPNOTSUPP; |
| 1104 | } |
| 1105 | } |
| 1106 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwauth); |
| 1107 | |
| 1108 | int cfg80211_wext_giwauth(struct net_device *dev, |
| 1109 | struct iw_request_info *info, |
| 1110 | struct iw_param *data, char *extra) |
| 1111 | { |
| 1112 | /* XXX: what do we need? */ |
| 1113 | |
| 1114 | return -EOPNOTSUPP; |
| 1115 | } |
| 1116 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth); |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1117 | |
| 1118 | int cfg80211_wext_siwpower(struct net_device *dev, |
| 1119 | struct iw_request_info *info, |
| 1120 | struct iw_param *wrq, char *extra) |
| 1121 | { |
| 1122 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1123 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
Kalle Valo | ffb9eb3 | 2010-02-17 17:58:10 +0200 | [diff] [blame] | 1124 | bool ps = wdev->ps; |
| 1125 | int timeout = wdev->ps_timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1126 | int err; |
| 1127 | |
| 1128 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 1129 | return -EINVAL; |
| 1130 | |
| 1131 | if (!rdev->ops->set_power_mgmt) |
| 1132 | return -EOPNOTSUPP; |
| 1133 | |
| 1134 | if (wrq->disabled) { |
| 1135 | ps = false; |
| 1136 | } else { |
| 1137 | switch (wrq->flags & IW_POWER_MODE) { |
| 1138 | case IW_POWER_ON: /* If not specified */ |
| 1139 | case IW_POWER_MODE: /* If set all mask */ |
| 1140 | case IW_POWER_ALL_R: /* If explicitely state all */ |
| 1141 | ps = true; |
| 1142 | break; |
| 1143 | default: /* Otherwise we ignore */ |
| 1144 | return -EINVAL; |
| 1145 | } |
| 1146 | |
| 1147 | if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) |
| 1148 | return -EINVAL; |
| 1149 | |
| 1150 | if (wrq->flags & IW_POWER_TIMEOUT) |
| 1151 | timeout = wrq->value / 1000; |
| 1152 | } |
| 1153 | |
| 1154 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout); |
| 1155 | if (err) |
| 1156 | return err; |
| 1157 | |
Kalle Valo | ffb9eb3 | 2010-02-17 17:58:10 +0200 | [diff] [blame] | 1158 | wdev->ps = ps; |
| 1159 | wdev->ps_timeout = timeout; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1160 | |
| 1161 | return 0; |
| 1162 | |
| 1163 | } |
| 1164 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwpower); |
| 1165 | |
| 1166 | int cfg80211_wext_giwpower(struct net_device *dev, |
| 1167 | struct iw_request_info *info, |
| 1168 | struct iw_param *wrq, char *extra) |
| 1169 | { |
| 1170 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1171 | |
Kalle Valo | ffb9eb3 | 2010-02-17 17:58:10 +0200 | [diff] [blame] | 1172 | wrq->disabled = !wdev->ps; |
Johannes Berg | bc92afd | 2009-07-01 21:26:57 +0200 | [diff] [blame] | 1173 | |
| 1174 | return 0; |
| 1175 | } |
| 1176 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwpower); |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1177 | |
Johannes Berg | 562e482 | 2009-07-27 12:01:51 +0200 | [diff] [blame] | 1178 | static int cfg80211_wds_wext_siwap(struct net_device *dev, |
| 1179 | struct iw_request_info *info, |
| 1180 | struct sockaddr *addr, char *extra) |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1181 | { |
| 1182 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1183 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 1184 | int err; |
| 1185 | |
| 1186 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS)) |
| 1187 | return -EINVAL; |
| 1188 | |
| 1189 | if (addr->sa_family != ARPHRD_ETHER) |
| 1190 | return -EINVAL; |
| 1191 | |
| 1192 | if (netif_running(dev)) |
| 1193 | return -EBUSY; |
| 1194 | |
| 1195 | if (!rdev->ops->set_wds_peer) |
| 1196 | return -EOPNOTSUPP; |
| 1197 | |
| 1198 | err = rdev->ops->set_wds_peer(wdev->wiphy, dev, (u8 *) &addr->sa_data); |
| 1199 | if (err) |
| 1200 | return err; |
| 1201 | |
| 1202 | memcpy(&wdev->wext.bssid, (u8 *) &addr->sa_data, ETH_ALEN); |
| 1203 | |
| 1204 | return 0; |
| 1205 | } |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1206 | |
Johannes Berg | 562e482 | 2009-07-27 12:01:51 +0200 | [diff] [blame] | 1207 | static int cfg80211_wds_wext_giwap(struct net_device *dev, |
| 1208 | struct iw_request_info *info, |
| 1209 | struct sockaddr *addr, char *extra) |
Johannes Berg | ab737a4 | 2009-07-01 21:26:58 +0200 | [diff] [blame] | 1210 | { |
| 1211 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1212 | |
| 1213 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS)) |
| 1214 | return -EINVAL; |
| 1215 | |
| 1216 | addr->sa_family = ARPHRD_ETHER; |
| 1217 | memcpy(&addr->sa_data, wdev->wext.bssid, ETH_ALEN); |
| 1218 | |
| 1219 | return 0; |
| 1220 | } |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1221 | |
| 1222 | int cfg80211_wext_siwrate(struct net_device *dev, |
| 1223 | struct iw_request_info *info, |
| 1224 | struct iw_param *rate, char *extra) |
| 1225 | { |
| 1226 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1227 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 1228 | struct cfg80211_bitrate_mask mask; |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1229 | u32 fixed, maxrate; |
| 1230 | struct ieee80211_supported_band *sband; |
| 1231 | int band, ridx; |
| 1232 | bool match = false; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1233 | |
| 1234 | if (!rdev->ops->set_bitrate_mask) |
| 1235 | return -EOPNOTSUPP; |
| 1236 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1237 | memset(&mask, 0, sizeof(mask)); |
| 1238 | fixed = 0; |
John W. Linville | 5423326 | 2010-01-27 09:44:48 -0500 | [diff] [blame] | 1239 | maxrate = (u32)-1; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1240 | |
| 1241 | if (rate->value < 0) { |
| 1242 | /* nothing */ |
| 1243 | } else if (rate->fixed) { |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1244 | fixed = rate->value / 100000; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1245 | } else { |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1246 | maxrate = rate->value / 100000; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1247 | } |
| 1248 | |
Jouni Malinen | 37eb0b1 | 2010-01-06 13:09:08 +0200 | [diff] [blame] | 1249 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
| 1250 | sband = wdev->wiphy->bands[band]; |
| 1251 | if (sband == NULL) |
| 1252 | continue; |
| 1253 | for (ridx = 0; ridx < sband->n_bitrates; ridx++) { |
| 1254 | struct ieee80211_rate *srate = &sband->bitrates[ridx]; |
| 1255 | if (fixed == srate->bitrate) { |
| 1256 | mask.control[band].legacy = 1 << ridx; |
| 1257 | match = true; |
| 1258 | break; |
| 1259 | } |
| 1260 | if (srate->bitrate <= maxrate) { |
| 1261 | mask.control[band].legacy |= 1 << ridx; |
| 1262 | match = true; |
| 1263 | } |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | if (!match) |
| 1268 | return -EINVAL; |
| 1269 | |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1270 | return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); |
| 1271 | } |
| 1272 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwrate); |
| 1273 | |
| 1274 | int cfg80211_wext_giwrate(struct net_device *dev, |
| 1275 | struct iw_request_info *info, |
| 1276 | struct iw_param *rate, char *extra) |
| 1277 | { |
| 1278 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1279 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 1280 | /* we are under RTNL - globally locked - so can use a static struct */ |
| 1281 | static struct station_info sinfo; |
Johannes Berg | a71d62d | 2009-07-07 23:41:27 +0200 | [diff] [blame] | 1282 | u8 addr[ETH_ALEN]; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1283 | int err; |
| 1284 | |
| 1285 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 1286 | return -EOPNOTSUPP; |
| 1287 | |
| 1288 | if (!rdev->ops->get_station) |
| 1289 | return -EOPNOTSUPP; |
| 1290 | |
Johannes Berg | a71d62d | 2009-07-07 23:41:27 +0200 | [diff] [blame] | 1291 | err = 0; |
| 1292 | wdev_lock(wdev); |
Samuel Ortiz | 6c230c0 | 2009-07-03 02:00:48 +0200 | [diff] [blame] | 1293 | if (wdev->current_bss) |
Johannes Berg | a71d62d | 2009-07-07 23:41:27 +0200 | [diff] [blame] | 1294 | memcpy(addr, wdev->current_bss->pub.bssid, ETH_ALEN); |
Samuel Ortiz | 6c230c0 | 2009-07-03 02:00:48 +0200 | [diff] [blame] | 1295 | else |
Johannes Berg | a71d62d | 2009-07-07 23:41:27 +0200 | [diff] [blame] | 1296 | err = -EOPNOTSUPP; |
| 1297 | wdev_unlock(wdev); |
| 1298 | if (err) |
| 1299 | return err; |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1300 | |
| 1301 | err = rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo); |
| 1302 | if (err) |
| 1303 | return err; |
| 1304 | |
| 1305 | if (!(sinfo.filled & STATION_INFO_TX_BITRATE)) |
| 1306 | return -EOPNOTSUPP; |
| 1307 | |
John W. Linville | 254416a | 2009-12-09 16:43:52 -0500 | [diff] [blame] | 1308 | rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); |
Johannes Berg | 9930380 | 2009-07-01 21:26:59 +0200 | [diff] [blame] | 1309 | |
| 1310 | return 0; |
| 1311 | } |
| 1312 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwrate); |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1313 | |
| 1314 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ |
| 1315 | struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) |
| 1316 | { |
| 1317 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1318 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 1319 | /* we are under RTNL - globally locked - so can use static structs */ |
| 1320 | static struct iw_statistics wstats; |
| 1321 | static struct station_info sinfo; |
Johannes Berg | c56c571 | 2009-07-10 16:54:07 +0200 | [diff] [blame] | 1322 | u8 bssid[ETH_ALEN]; |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1323 | |
| 1324 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) |
| 1325 | return NULL; |
| 1326 | |
| 1327 | if (!rdev->ops->get_station) |
| 1328 | return NULL; |
| 1329 | |
Johannes Berg | c56c571 | 2009-07-10 16:54:07 +0200 | [diff] [blame] | 1330 | /* Grab BSSID of current BSS, if any */ |
| 1331 | wdev_lock(wdev); |
| 1332 | if (!wdev->current_bss) { |
| 1333 | wdev_unlock(wdev); |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1334 | return NULL; |
Johannes Berg | c56c571 | 2009-07-10 16:54:07 +0200 | [diff] [blame] | 1335 | } |
| 1336 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); |
| 1337 | wdev_unlock(wdev); |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1338 | |
Johannes Berg | c56c571 | 2009-07-10 16:54:07 +0200 | [diff] [blame] | 1339 | if (rdev->ops->get_station(&rdev->wiphy, dev, bssid, &sinfo)) |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1340 | return NULL; |
| 1341 | |
| 1342 | memset(&wstats, 0, sizeof(wstats)); |
| 1343 | |
| 1344 | switch (rdev->wiphy.signal_type) { |
| 1345 | case CFG80211_SIGNAL_TYPE_MBM: |
| 1346 | if (sinfo.filled & STATION_INFO_SIGNAL) { |
| 1347 | int sig = sinfo.signal; |
| 1348 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; |
| 1349 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; |
| 1350 | wstats.qual.updated |= IW_QUAL_DBM; |
| 1351 | wstats.qual.level = sig; |
| 1352 | if (sig < -110) |
| 1353 | sig = -110; |
| 1354 | else if (sig > -40) |
| 1355 | sig = -40; |
| 1356 | wstats.qual.qual = sig + 110; |
| 1357 | break; |
| 1358 | } |
| 1359 | case CFG80211_SIGNAL_TYPE_UNSPEC: |
| 1360 | if (sinfo.filled & STATION_INFO_SIGNAL) { |
| 1361 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; |
| 1362 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED; |
| 1363 | wstats.qual.level = sinfo.signal; |
| 1364 | wstats.qual.qual = sinfo.signal; |
| 1365 | break; |
| 1366 | } |
| 1367 | default: |
| 1368 | wstats.qual.updated |= IW_QUAL_LEVEL_INVALID; |
| 1369 | wstats.qual.updated |= IW_QUAL_QUAL_INVALID; |
| 1370 | } |
| 1371 | |
| 1372 | wstats.qual.updated |= IW_QUAL_NOISE_INVALID; |
Ben Greear | 5a5c731 | 2010-10-07 16:39:20 -0700 | [diff] [blame] | 1373 | if (sinfo.filled & STATION_INFO_RX_DROP_MISC) |
| 1374 | wstats.discard.misc = sinfo.rx_dropped_misc; |
| 1375 | if (sinfo.filled & STATION_INFO_TX_FAILED) |
| 1376 | wstats.discard.retries = sinfo.tx_failed; |
Johannes Berg | 8990646 | 2009-07-01 21:27:00 +0200 | [diff] [blame] | 1377 | |
| 1378 | return &wstats; |
| 1379 | } |
| 1380 | EXPORT_SYMBOL_GPL(cfg80211_wireless_stats); |
Johannes Berg | 562e482 | 2009-07-27 12:01:51 +0200 | [diff] [blame] | 1381 | |
| 1382 | int cfg80211_wext_siwap(struct net_device *dev, |
| 1383 | struct iw_request_info *info, |
| 1384 | struct sockaddr *ap_addr, char *extra) |
| 1385 | { |
| 1386 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1387 | |
| 1388 | switch (wdev->iftype) { |
| 1389 | case NL80211_IFTYPE_ADHOC: |
| 1390 | return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra); |
| 1391 | case NL80211_IFTYPE_STATION: |
| 1392 | return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra); |
| 1393 | case NL80211_IFTYPE_WDS: |
| 1394 | return cfg80211_wds_wext_siwap(dev, info, ap_addr, extra); |
| 1395 | default: |
| 1396 | return -EOPNOTSUPP; |
| 1397 | } |
| 1398 | } |
| 1399 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwap); |
| 1400 | |
| 1401 | int cfg80211_wext_giwap(struct net_device *dev, |
| 1402 | struct iw_request_info *info, |
| 1403 | struct sockaddr *ap_addr, char *extra) |
| 1404 | { |
| 1405 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1406 | |
| 1407 | switch (wdev->iftype) { |
| 1408 | case NL80211_IFTYPE_ADHOC: |
| 1409 | return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra); |
| 1410 | case NL80211_IFTYPE_STATION: |
| 1411 | return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra); |
| 1412 | case NL80211_IFTYPE_WDS: |
| 1413 | return cfg80211_wds_wext_giwap(dev, info, ap_addr, extra); |
| 1414 | default: |
| 1415 | return -EOPNOTSUPP; |
| 1416 | } |
| 1417 | } |
| 1418 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwap); |
Johannes Berg | 1f9298f | 2009-07-27 12:01:52 +0200 | [diff] [blame] | 1419 | |
| 1420 | int cfg80211_wext_siwessid(struct net_device *dev, |
| 1421 | struct iw_request_info *info, |
| 1422 | struct iw_point *data, char *ssid) |
| 1423 | { |
| 1424 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1425 | |
| 1426 | switch (wdev->iftype) { |
| 1427 | case NL80211_IFTYPE_ADHOC: |
| 1428 | return cfg80211_ibss_wext_siwessid(dev, info, data, ssid); |
| 1429 | case NL80211_IFTYPE_STATION: |
| 1430 | return cfg80211_mgd_wext_siwessid(dev, info, data, ssid); |
| 1431 | default: |
| 1432 | return -EOPNOTSUPP; |
| 1433 | } |
| 1434 | } |
| 1435 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwessid); |
| 1436 | |
| 1437 | int cfg80211_wext_giwessid(struct net_device *dev, |
| 1438 | struct iw_request_info *info, |
| 1439 | struct iw_point *data, char *ssid) |
| 1440 | { |
| 1441 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1442 | |
Johannes Berg | 42da2f9 | 2010-08-30 12:24:54 +0200 | [diff] [blame] | 1443 | data->flags = 0; |
| 1444 | data->length = 0; |
| 1445 | |
Johannes Berg | 1f9298f | 2009-07-27 12:01:52 +0200 | [diff] [blame] | 1446 | switch (wdev->iftype) { |
| 1447 | case NL80211_IFTYPE_ADHOC: |
| 1448 | return cfg80211_ibss_wext_giwessid(dev, info, data, ssid); |
| 1449 | case NL80211_IFTYPE_STATION: |
| 1450 | return cfg80211_mgd_wext_giwessid(dev, info, data, ssid); |
| 1451 | default: |
| 1452 | return -EOPNOTSUPP; |
| 1453 | } |
| 1454 | } |
| 1455 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwessid); |
Johannes Berg | a9a1162 | 2009-07-27 12:01:53 +0200 | [diff] [blame] | 1456 | |
Samuel Ortiz | 2944b2c | 2009-11-25 00:01:01 +0100 | [diff] [blame] | 1457 | int cfg80211_wext_siwpmksa(struct net_device *dev, |
| 1458 | struct iw_request_info *info, |
| 1459 | struct iw_point *data, char *extra) |
| 1460 | { |
| 1461 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 1462 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
| 1463 | struct cfg80211_pmksa cfg_pmksa; |
| 1464 | struct iw_pmksa *pmksa = (struct iw_pmksa *)extra; |
| 1465 | |
| 1466 | memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa)); |
| 1467 | |
| 1468 | if (wdev->iftype != NL80211_IFTYPE_STATION) |
| 1469 | return -EINVAL; |
| 1470 | |
| 1471 | cfg_pmksa.bssid = pmksa->bssid.sa_data; |
| 1472 | cfg_pmksa.pmkid = pmksa->pmkid; |
| 1473 | |
| 1474 | switch (pmksa->cmd) { |
| 1475 | case IW_PMKSA_ADD: |
| 1476 | if (!rdev->ops->set_pmksa) |
| 1477 | return -EOPNOTSUPP; |
| 1478 | |
| 1479 | return rdev->ops->set_pmksa(&rdev->wiphy, dev, &cfg_pmksa); |
| 1480 | |
| 1481 | case IW_PMKSA_REMOVE: |
| 1482 | if (!rdev->ops->del_pmksa) |
| 1483 | return -EOPNOTSUPP; |
| 1484 | |
| 1485 | return rdev->ops->del_pmksa(&rdev->wiphy, dev, &cfg_pmksa); |
| 1486 | |
| 1487 | case IW_PMKSA_FLUSH: |
| 1488 | if (!rdev->ops->flush_pmksa) |
| 1489 | return -EOPNOTSUPP; |
| 1490 | |
| 1491 | return rdev->ops->flush_pmksa(&rdev->wiphy, dev); |
| 1492 | |
| 1493 | default: |
| 1494 | return -EOPNOTSUPP; |
| 1495 | } |
| 1496 | } |
John W. Linville | c28991a | 2010-07-20 12:22:40 -0400 | [diff] [blame] | 1497 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwpmksa); |
Samuel Ortiz | 2944b2c | 2009-11-25 00:01:01 +0100 | [diff] [blame] | 1498 | |
Johannes Berg | a9a1162 | 2009-07-27 12:01:53 +0200 | [diff] [blame] | 1499 | static const iw_handler cfg80211_handlers[] = { |
| 1500 | [IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname, |
| 1501 | [IW_IOCTL_IDX(SIOCSIWFREQ)] = (iw_handler) cfg80211_wext_siwfreq, |
| 1502 | [IW_IOCTL_IDX(SIOCGIWFREQ)] = (iw_handler) cfg80211_wext_giwfreq, |
| 1503 | [IW_IOCTL_IDX(SIOCSIWMODE)] = (iw_handler) cfg80211_wext_siwmode, |
| 1504 | [IW_IOCTL_IDX(SIOCGIWMODE)] = (iw_handler) cfg80211_wext_giwmode, |
| 1505 | [IW_IOCTL_IDX(SIOCGIWRANGE)] = (iw_handler) cfg80211_wext_giwrange, |
| 1506 | [IW_IOCTL_IDX(SIOCSIWAP)] = (iw_handler) cfg80211_wext_siwap, |
| 1507 | [IW_IOCTL_IDX(SIOCGIWAP)] = (iw_handler) cfg80211_wext_giwap, |
| 1508 | [IW_IOCTL_IDX(SIOCSIWMLME)] = (iw_handler) cfg80211_wext_siwmlme, |
| 1509 | [IW_IOCTL_IDX(SIOCSIWSCAN)] = (iw_handler) cfg80211_wext_siwscan, |
| 1510 | [IW_IOCTL_IDX(SIOCGIWSCAN)] = (iw_handler) cfg80211_wext_giwscan, |
| 1511 | [IW_IOCTL_IDX(SIOCSIWESSID)] = (iw_handler) cfg80211_wext_siwessid, |
| 1512 | [IW_IOCTL_IDX(SIOCGIWESSID)] = (iw_handler) cfg80211_wext_giwessid, |
| 1513 | [IW_IOCTL_IDX(SIOCSIWRATE)] = (iw_handler) cfg80211_wext_siwrate, |
| 1514 | [IW_IOCTL_IDX(SIOCGIWRATE)] = (iw_handler) cfg80211_wext_giwrate, |
| 1515 | [IW_IOCTL_IDX(SIOCSIWRTS)] = (iw_handler) cfg80211_wext_siwrts, |
| 1516 | [IW_IOCTL_IDX(SIOCGIWRTS)] = (iw_handler) cfg80211_wext_giwrts, |
| 1517 | [IW_IOCTL_IDX(SIOCSIWFRAG)] = (iw_handler) cfg80211_wext_siwfrag, |
| 1518 | [IW_IOCTL_IDX(SIOCGIWFRAG)] = (iw_handler) cfg80211_wext_giwfrag, |
| 1519 | [IW_IOCTL_IDX(SIOCSIWTXPOW)] = (iw_handler) cfg80211_wext_siwtxpower, |
| 1520 | [IW_IOCTL_IDX(SIOCGIWTXPOW)] = (iw_handler) cfg80211_wext_giwtxpower, |
| 1521 | [IW_IOCTL_IDX(SIOCSIWRETRY)] = (iw_handler) cfg80211_wext_siwretry, |
| 1522 | [IW_IOCTL_IDX(SIOCGIWRETRY)] = (iw_handler) cfg80211_wext_giwretry, |
| 1523 | [IW_IOCTL_IDX(SIOCSIWENCODE)] = (iw_handler) cfg80211_wext_siwencode, |
| 1524 | [IW_IOCTL_IDX(SIOCGIWENCODE)] = (iw_handler) cfg80211_wext_giwencode, |
| 1525 | [IW_IOCTL_IDX(SIOCSIWPOWER)] = (iw_handler) cfg80211_wext_siwpower, |
| 1526 | [IW_IOCTL_IDX(SIOCGIWPOWER)] = (iw_handler) cfg80211_wext_giwpower, |
| 1527 | [IW_IOCTL_IDX(SIOCSIWGENIE)] = (iw_handler) cfg80211_wext_siwgenie, |
| 1528 | [IW_IOCTL_IDX(SIOCSIWAUTH)] = (iw_handler) cfg80211_wext_siwauth, |
| 1529 | [IW_IOCTL_IDX(SIOCGIWAUTH)] = (iw_handler) cfg80211_wext_giwauth, |
| 1530 | [IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= (iw_handler) cfg80211_wext_siwencodeext, |
Samuel Ortiz | 2944b2c | 2009-11-25 00:01:01 +0100 | [diff] [blame] | 1531 | [IW_IOCTL_IDX(SIOCSIWPMKSA)] = (iw_handler) cfg80211_wext_siwpmksa, |
Johannes Berg | a9a1162 | 2009-07-27 12:01:53 +0200 | [diff] [blame] | 1532 | }; |
| 1533 | |
| 1534 | const struct iw_handler_def cfg80211_wext_handler = { |
| 1535 | .num_standard = ARRAY_SIZE(cfg80211_handlers), |
| 1536 | .standard = cfg80211_handlers, |
| 1537 | .get_wireless_stats = cfg80211_wireless_stats, |
| 1538 | }; |