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