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