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