Commit | Line | Data |
---|---|---|
f0706e82 JB |
1 | /* |
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | |
3 | * Copyright 2005-2006, Devicescape Software, Inc. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | */ | |
9 | ||
10 | #include <linux/module.h> | |
11 | #include <linux/init.h> | |
12 | #include <linux/netdevice.h> | |
13 | #include <linux/types.h> | |
14 | #include <linux/slab.h> | |
15 | #include <linux/skbuff.h> | |
16 | #include <linux/etherdevice.h> | |
17 | #include <linux/if_arp.h> | |
18 | #include <linux/wireless.h> | |
19 | #include <net/iw_handler.h> | |
20 | #include <asm/uaccess.h> | |
21 | ||
22 | #include <net/mac80211.h> | |
23 | #include "ieee80211_i.h" | |
f0706e82 JB |
24 | #include "ieee80211_rate.h" |
25 | #include "wpa.h" | |
26 | #include "aes_ccm.h" | |
f0706e82 | 27 | |
b708e610 | 28 | |
f0706e82 | 29 | static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr, |
628a140b JB |
30 | int idx, int alg, int remove, |
31 | int set_tx_key, const u8 *_key, | |
32 | size_t key_len) | |
f0706e82 JB |
33 | { |
34 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
35 | int ret = 0; | |
36 | struct sta_info *sta; | |
11a843b7 | 37 | struct ieee80211_key *key; |
f0706e82 JB |
38 | struct ieee80211_sub_if_data *sdata; |
39 | ||
40 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
41 | ||
139c3a04 VB |
42 | if (idx < 0 || idx >= NUM_DEFAULT_KEYS) { |
43 | printk(KERN_DEBUG "%s: set_encrypt - invalid idx=%d\n", | |
44 | dev->name, idx); | |
45 | return -EINVAL; | |
46 | } | |
47 | ||
f0706e82 JB |
48 | if (is_broadcast_ether_addr(sta_addr)) { |
49 | sta = NULL; | |
f0706e82 | 50 | key = sdata->keys[idx]; |
f0706e82 JB |
51 | } else { |
52 | set_tx_key = 0; | |
139c3a04 VB |
53 | /* |
54 | * According to the standard, the key index of a pairwise | |
55 | * key must be zero. However, some AP are broken when it | |
56 | * comes to WEP key indices, so we work around this. | |
57 | */ | |
58 | if (idx != 0 && alg != ALG_WEP) { | |
f0706e82 JB |
59 | printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for " |
60 | "individual key\n", dev->name); | |
61 | return -EINVAL; | |
62 | } | |
63 | ||
64 | sta = sta_info_get(local, sta_addr); | |
65 | if (!sta) { | |
66 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | |
0795af57 | 67 | DECLARE_MAC_BUF(mac); |
f0706e82 | 68 | printk(KERN_DEBUG "%s: set_encrypt - unknown addr " |
0795af57 JP |
69 | "%s\n", |
70 | dev->name, print_mac(mac, sta_addr)); | |
f0706e82 JB |
71 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ |
72 | ||
73 | return -ENOENT; | |
74 | } | |
75 | ||
76 | key = sta->key; | |
77 | } | |
78 | ||
628a140b | 79 | if (remove) { |
f0706e82 JB |
80 | ieee80211_key_free(key); |
81 | key = NULL; | |
82 | } else { | |
11a843b7 | 83 | /* |
d4e46a3d | 84 | * Automatically frees any old key if present. |
11a843b7 | 85 | */ |
11a843b7 | 86 | key = ieee80211_key_alloc(sdata, sta, alg, idx, key_len, _key); |
f0706e82 JB |
87 | if (!key) { |
88 | ret = -ENOMEM; | |
89 | goto err_out; | |
90 | } | |
f0706e82 JB |
91 | } |
92 | ||
11a843b7 JB |
93 | if (set_tx_key || (!sta && !sdata->default_key && key)) |
94 | ieee80211_set_default_key(sdata, idx); | |
f0706e82 | 95 | |
11a843b7 JB |
96 | ret = 0; |
97 | err_out: | |
f0706e82 JB |
98 | if (sta) |
99 | sta_info_put(sta); | |
100 | return ret; | |
101 | } | |
102 | ||
103 | static int ieee80211_ioctl_siwgenie(struct net_device *dev, | |
104 | struct iw_request_info *info, | |
105 | struct iw_point *data, char *extra) | |
106 | { | |
107 | struct ieee80211_sub_if_data *sdata; | |
f0706e82 | 108 | |
ddd3d2be JB |
109 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
110 | ||
111 | if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) | |
f0706e82 JB |
112 | return -EOPNOTSUPP; |
113 | ||
f0706e82 JB |
114 | if (sdata->type == IEEE80211_IF_TYPE_STA || |
115 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
116 | int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length); | |
117 | if (ret) | |
118 | return ret; | |
d6f2da5b | 119 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
f0706e82 JB |
120 | ieee80211_sta_req_auth(dev, &sdata->u.sta); |
121 | return 0; | |
122 | } | |
123 | ||
f0706e82 JB |
124 | return -EOPNOTSUPP; |
125 | } | |
126 | ||
f0706e82 JB |
127 | static int ieee80211_ioctl_giwname(struct net_device *dev, |
128 | struct iw_request_info *info, | |
129 | char *name, char *extra) | |
130 | { | |
131 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
132 | ||
133 | switch (local->hw.conf.phymode) { | |
134 | case MODE_IEEE80211A: | |
135 | strcpy(name, "IEEE 802.11a"); | |
136 | break; | |
137 | case MODE_IEEE80211B: | |
138 | strcpy(name, "IEEE 802.11b"); | |
139 | break; | |
140 | case MODE_IEEE80211G: | |
141 | strcpy(name, "IEEE 802.11g"); | |
142 | break; | |
f0706e82 JB |
143 | default: |
144 | strcpy(name, "IEEE 802.11"); | |
145 | break; | |
146 | } | |
147 | ||
148 | return 0; | |
149 | } | |
150 | ||
151 | ||
152 | static int ieee80211_ioctl_giwrange(struct net_device *dev, | |
153 | struct iw_request_info *info, | |
154 | struct iw_point *data, char *extra) | |
155 | { | |
156 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
157 | struct iw_range *range = (struct iw_range *) extra; | |
333af2f0 HL |
158 | struct ieee80211_hw_mode *mode = NULL; |
159 | int c = 0; | |
f0706e82 JB |
160 | |
161 | data->length = sizeof(struct iw_range); | |
162 | memset(range, 0, sizeof(struct iw_range)); | |
163 | ||
164 | range->we_version_compiled = WIRELESS_EXT; | |
165 | range->we_version_source = 21; | |
166 | range->retry_capa = IW_RETRY_LIMIT; | |
167 | range->retry_flags = IW_RETRY_LIMIT; | |
168 | range->min_retry = 0; | |
169 | range->max_retry = 255; | |
170 | range->min_rts = 0; | |
171 | range->max_rts = 2347; | |
172 | range->min_frag = 256; | |
173 | range->max_frag = 2346; | |
174 | ||
175 | range->encoding_size[0] = 5; | |
176 | range->encoding_size[1] = 13; | |
177 | range->num_encoding_sizes = 2; | |
178 | range->max_encoding_tokens = NUM_DEFAULT_KEYS; | |
179 | ||
180 | range->max_qual.qual = local->hw.max_signal; | |
181 | range->max_qual.level = local->hw.max_rssi; | |
182 | range->max_qual.noise = local->hw.max_noise; | |
183 | range->max_qual.updated = local->wstats_flags; | |
184 | ||
185 | range->avg_qual.qual = local->hw.max_signal/2; | |
186 | range->avg_qual.level = 0; | |
187 | range->avg_qual.noise = 0; | |
188 | range->avg_qual.updated = local->wstats_flags; | |
189 | ||
190 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | | |
191 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | |
192 | ||
333af2f0 HL |
193 | list_for_each_entry(mode, &local->modes_list, list) { |
194 | int i = 0; | |
195 | ||
196 | if (!(local->enabled_modes & (1 << mode->mode)) || | |
197 | (local->hw_modes & local->enabled_modes & | |
198 | (1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B)) | |
199 | continue; | |
200 | ||
201 | while (i < mode->num_channels && c < IW_MAX_FREQUENCIES) { | |
202 | struct ieee80211_channel *chan = &mode->channels[i]; | |
203 | ||
204 | if (chan->flag & IEEE80211_CHAN_W_SCAN) { | |
205 | range->freq[c].i = chan->chan; | |
206 | range->freq[c].m = chan->freq * 100000; | |
207 | range->freq[c].e = 1; | |
208 | c++; | |
209 | } | |
210 | i++; | |
211 | } | |
212 | } | |
213 | range->num_channels = c; | |
214 | range->num_frequency = c; | |
215 | ||
f0706e82 JB |
216 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa); |
217 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY); | |
218 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); | |
219 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); | |
220 | ||
221 | return 0; | |
222 | } | |
223 | ||
224 | ||
f0706e82 JB |
225 | static int ieee80211_ioctl_siwmode(struct net_device *dev, |
226 | struct iw_request_info *info, | |
227 | __u32 *mode, char *extra) | |
228 | { | |
229 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
230 | int type; | |
231 | ||
232 | if (sdata->type == IEEE80211_IF_TYPE_VLAN) | |
233 | return -EOPNOTSUPP; | |
234 | ||
235 | switch (*mode) { | |
236 | case IW_MODE_INFRA: | |
237 | type = IEEE80211_IF_TYPE_STA; | |
238 | break; | |
239 | case IW_MODE_ADHOC: | |
240 | type = IEEE80211_IF_TYPE_IBSS; | |
241 | break; | |
242 | case IW_MODE_MONITOR: | |
243 | type = IEEE80211_IF_TYPE_MNTR; | |
244 | break; | |
245 | default: | |
246 | return -EINVAL; | |
247 | } | |
248 | ||
249 | if (type == sdata->type) | |
250 | return 0; | |
251 | if (netif_running(dev)) | |
252 | return -EBUSY; | |
253 | ||
254 | ieee80211_if_reinit(dev); | |
255 | ieee80211_if_set_type(dev, type); | |
256 | ||
257 | return 0; | |
258 | } | |
259 | ||
260 | ||
261 | static int ieee80211_ioctl_giwmode(struct net_device *dev, | |
262 | struct iw_request_info *info, | |
263 | __u32 *mode, char *extra) | |
264 | { | |
265 | struct ieee80211_sub_if_data *sdata; | |
266 | ||
267 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
268 | switch (sdata->type) { | |
269 | case IEEE80211_IF_TYPE_AP: | |
270 | *mode = IW_MODE_MASTER; | |
271 | break; | |
272 | case IEEE80211_IF_TYPE_STA: | |
273 | *mode = IW_MODE_INFRA; | |
274 | break; | |
275 | case IEEE80211_IF_TYPE_IBSS: | |
276 | *mode = IW_MODE_ADHOC; | |
277 | break; | |
278 | case IEEE80211_IF_TYPE_MNTR: | |
279 | *mode = IW_MODE_MONITOR; | |
280 | break; | |
281 | case IEEE80211_IF_TYPE_WDS: | |
282 | *mode = IW_MODE_REPEAT; | |
283 | break; | |
284 | case IEEE80211_IF_TYPE_VLAN: | |
285 | *mode = IW_MODE_SECOND; /* FIXME */ | |
286 | break; | |
287 | default: | |
288 | *mode = IW_MODE_AUTO; | |
289 | break; | |
290 | } | |
291 | return 0; | |
292 | } | |
293 | ||
294 | int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq) | |
295 | { | |
296 | struct ieee80211_hw_mode *mode; | |
297 | int c, set = 0; | |
298 | int ret = -EINVAL; | |
299 | ||
300 | list_for_each_entry(mode, &local->modes_list, list) { | |
301 | if (!(local->enabled_modes & (1 << mode->mode))) | |
302 | continue; | |
303 | for (c = 0; c < mode->num_channels; c++) { | |
304 | struct ieee80211_channel *chan = &mode->channels[c]; | |
305 | if (chan->flag & IEEE80211_CHAN_W_SCAN && | |
306 | ((chan->chan == channel) || (chan->freq == freq))) { | |
f0706e82 JB |
307 | local->oper_channel = chan; |
308 | local->oper_hw_mode = mode; | |
58a9ac17 JB |
309 | set = 1; |
310 | break; | |
f0706e82 JB |
311 | } |
312 | } | |
58a9ac17 JB |
313 | if (set) |
314 | break; | |
f0706e82 JB |
315 | } |
316 | ||
317 | if (set) { | |
ece8eddd | 318 | if (local->sta_sw_scanning) |
f0706e82 JB |
319 | ret = 0; |
320 | else | |
321 | ret = ieee80211_hw_config(local); | |
322 | ||
323 | rate_control_clear(local); | |
324 | } | |
325 | ||
326 | return ret; | |
327 | } | |
328 | ||
329 | static int ieee80211_ioctl_siwfreq(struct net_device *dev, | |
330 | struct iw_request_info *info, | |
331 | struct iw_freq *freq, char *extra) | |
332 | { | |
333 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
334 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
335 | ||
336 | if (sdata->type == IEEE80211_IF_TYPE_STA) | |
d6f2da5b | 337 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; |
f0706e82 JB |
338 | |
339 | /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ | |
340 | if (freq->e == 0) { | |
341 | if (freq->m < 0) { | |
342 | if (sdata->type == IEEE80211_IF_TYPE_STA) | |
d6f2da5b JS |
343 | sdata->u.sta.flags |= |
344 | IEEE80211_STA_AUTO_CHANNEL_SEL; | |
f0706e82 JB |
345 | return 0; |
346 | } else | |
347 | return ieee80211_set_channel(local, freq->m, -1); | |
348 | } else { | |
349 | int i, div = 1000000; | |
350 | for (i = 0; i < freq->e; i++) | |
351 | div /= 10; | |
352 | if (div > 0) | |
353 | return ieee80211_set_channel(local, -1, freq->m / div); | |
354 | else | |
355 | return -EINVAL; | |
356 | } | |
357 | } | |
358 | ||
359 | ||
360 | static int ieee80211_ioctl_giwfreq(struct net_device *dev, | |
361 | struct iw_request_info *info, | |
362 | struct iw_freq *freq, char *extra) | |
363 | { | |
364 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
365 | ||
366 | /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level | |
367 | * driver for the current channel with firmware-based management */ | |
368 | ||
369 | freq->m = local->hw.conf.freq; | |
370 | freq->e = 6; | |
371 | ||
372 | return 0; | |
373 | } | |
374 | ||
375 | ||
376 | static int ieee80211_ioctl_siwessid(struct net_device *dev, | |
377 | struct iw_request_info *info, | |
378 | struct iw_point *data, char *ssid) | |
379 | { | |
f0706e82 JB |
380 | struct ieee80211_sub_if_data *sdata; |
381 | size_t len = data->length; | |
382 | ||
383 | /* iwconfig uses nul termination in SSID.. */ | |
384 | if (len > 0 && ssid[len - 1] == '\0') | |
385 | len--; | |
386 | ||
387 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
388 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
389 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
390 | int ret; | |
ddd3d2be | 391 | if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) { |
f0706e82 JB |
392 | if (len > IEEE80211_MAX_SSID_LEN) |
393 | return -EINVAL; | |
394 | memcpy(sdata->u.sta.ssid, ssid, len); | |
395 | sdata->u.sta.ssid_len = len; | |
396 | return 0; | |
397 | } | |
d6f2da5b JS |
398 | if (data->flags) |
399 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; | |
400 | else | |
401 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_SSID_SEL; | |
f0706e82 JB |
402 | ret = ieee80211_sta_set_ssid(dev, ssid, len); |
403 | if (ret) | |
404 | return ret; | |
405 | ieee80211_sta_req_auth(dev, &sdata->u.sta); | |
406 | return 0; | |
407 | } | |
408 | ||
409 | if (sdata->type == IEEE80211_IF_TYPE_AP) { | |
410 | memcpy(sdata->u.ap.ssid, ssid, len); | |
411 | memset(sdata->u.ap.ssid + len, 0, | |
412 | IEEE80211_MAX_SSID_LEN - len); | |
413 | sdata->u.ap.ssid_len = len; | |
414 | return ieee80211_if_config(dev); | |
415 | } | |
416 | return -EOPNOTSUPP; | |
417 | } | |
418 | ||
419 | ||
420 | static int ieee80211_ioctl_giwessid(struct net_device *dev, | |
421 | struct iw_request_info *info, | |
422 | struct iw_point *data, char *ssid) | |
423 | { | |
424 | size_t len; | |
425 | ||
426 | struct ieee80211_sub_if_data *sdata; | |
427 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
428 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
429 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
430 | int res = ieee80211_sta_get_ssid(dev, ssid, &len); | |
431 | if (res == 0) { | |
432 | data->length = len; | |
433 | data->flags = 1; | |
434 | } else | |
435 | data->flags = 0; | |
436 | return res; | |
437 | } | |
438 | ||
439 | if (sdata->type == IEEE80211_IF_TYPE_AP) { | |
440 | len = sdata->u.ap.ssid_len; | |
441 | if (len > IW_ESSID_MAX_SIZE) | |
442 | len = IW_ESSID_MAX_SIZE; | |
443 | memcpy(ssid, sdata->u.ap.ssid, len); | |
444 | data->length = len; | |
445 | data->flags = 1; | |
446 | return 0; | |
447 | } | |
448 | return -EOPNOTSUPP; | |
449 | } | |
450 | ||
451 | ||
452 | static int ieee80211_ioctl_siwap(struct net_device *dev, | |
453 | struct iw_request_info *info, | |
454 | struct sockaddr *ap_addr, char *extra) | |
455 | { | |
f0706e82 JB |
456 | struct ieee80211_sub_if_data *sdata; |
457 | ||
458 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
459 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
460 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
461 | int ret; | |
ddd3d2be | 462 | if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) { |
f0706e82 JB |
463 | memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data, |
464 | ETH_ALEN); | |
465 | return 0; | |
466 | } | |
d6f2da5b JS |
467 | if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) |
468 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL | | |
469 | IEEE80211_STA_AUTO_CHANNEL_SEL; | |
470 | else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data)) | |
471 | sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL; | |
f0706e82 | 472 | else |
d6f2da5b | 473 | sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; |
f0706e82 JB |
474 | ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data); |
475 | if (ret) | |
476 | return ret; | |
477 | ieee80211_sta_req_auth(dev, &sdata->u.sta); | |
478 | return 0; | |
479 | } else if (sdata->type == IEEE80211_IF_TYPE_WDS) { | |
480 | if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data, | |
481 | ETH_ALEN) == 0) | |
482 | return 0; | |
483 | return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data); | |
484 | } | |
485 | ||
486 | return -EOPNOTSUPP; | |
487 | } | |
488 | ||
489 | ||
490 | static int ieee80211_ioctl_giwap(struct net_device *dev, | |
491 | struct iw_request_info *info, | |
492 | struct sockaddr *ap_addr, char *extra) | |
493 | { | |
494 | struct ieee80211_sub_if_data *sdata; | |
495 | ||
496 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
497 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
498 | sdata->type == IEEE80211_IF_TYPE_IBSS) { | |
499 | ap_addr->sa_family = ARPHRD_ETHER; | |
500 | memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN); | |
501 | return 0; | |
502 | } else if (sdata->type == IEEE80211_IF_TYPE_WDS) { | |
503 | ap_addr->sa_family = ARPHRD_ETHER; | |
504 | memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN); | |
505 | return 0; | |
506 | } | |
507 | ||
508 | return -EOPNOTSUPP; | |
509 | } | |
510 | ||
511 | ||
512 | static int ieee80211_ioctl_siwscan(struct net_device *dev, | |
513 | struct iw_request_info *info, | |
107acb23 | 514 | union iwreq_data *wrqu, char *extra) |
f0706e82 | 515 | { |
f0706e82 | 516 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
107acb23 | 517 | struct iw_scan_req *req = NULL; |
f0706e82 JB |
518 | u8 *ssid = NULL; |
519 | size_t ssid_len = 0; | |
520 | ||
521 | if (!netif_running(dev)) | |
522 | return -ENETDOWN; | |
523 | ||
48933dea HS |
524 | if (sdata->type != IEEE80211_IF_TYPE_STA && |
525 | sdata->type != IEEE80211_IF_TYPE_IBSS && | |
526 | sdata->type != IEEE80211_IF_TYPE_AP) { | |
d114f399 JL |
527 | return -EOPNOTSUPP; |
528 | } | |
529 | ||
530 | /* if SSID was specified explicitly then use that */ | |
107acb23 BM |
531 | if (wrqu->data.length == sizeof(struct iw_scan_req) && |
532 | wrqu->data.flags & IW_SCAN_THIS_ESSID) { | |
533 | req = (struct iw_scan_req *)extra; | |
534 | ssid = req->essid; | |
535 | ssid_len = req->essid_len; | |
f0706e82 | 536 | } |
f27b62d3 | 537 | |
f0706e82 JB |
538 | return ieee80211_sta_req_scan(dev, ssid, ssid_len); |
539 | } | |
540 | ||
541 | ||
542 | static int ieee80211_ioctl_giwscan(struct net_device *dev, | |
543 | struct iw_request_info *info, | |
544 | struct iw_point *data, char *extra) | |
545 | { | |
546 | int res; | |
547 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
ece8eddd ZY |
548 | |
549 | if (local->sta_sw_scanning || local->sta_hw_scanning) | |
f0706e82 | 550 | return -EAGAIN; |
ece8eddd | 551 | |
f0706e82 JB |
552 | res = ieee80211_sta_scan_results(dev, extra, data->length); |
553 | if (res >= 0) { | |
554 | data->length = res; | |
555 | return 0; | |
556 | } | |
557 | data->length = 0; | |
558 | return res; | |
559 | } | |
560 | ||
561 | ||
1fd5e589 LF |
562 | static int ieee80211_ioctl_siwrate(struct net_device *dev, |
563 | struct iw_request_info *info, | |
564 | struct iw_param *rate, char *extra) | |
565 | { | |
566 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
567 | struct ieee80211_hw_mode *mode; | |
568 | int i; | |
569 | u32 target_rate = rate->value / 100000; | |
570 | struct ieee80211_sub_if_data *sdata; | |
571 | ||
572 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
573 | if (!sdata->bss) | |
574 | return -ENODEV; | |
575 | mode = local->oper_hw_mode; | |
576 | /* target_rate = -1, rate->fixed = 0 means auto only, so use all rates | |
577 | * target_rate = X, rate->fixed = 1 means only rate X | |
578 | * target_rate = X, rate->fixed = 0 means all rates <= X */ | |
579 | sdata->bss->max_ratectrl_rateidx = -1; | |
580 | sdata->bss->force_unicast_rateidx = -1; | |
581 | if (rate->value < 0) | |
582 | return 0; | |
5cdfed54 | 583 | for (i=0; i < mode->num_rates; i++) { |
1fd5e589 LF |
584 | struct ieee80211_rate *rates = &mode->rates[i]; |
585 | int this_rate = rates->rate; | |
586 | ||
1fd5e589 LF |
587 | if (target_rate == this_rate) { |
588 | sdata->bss->max_ratectrl_rateidx = i; | |
589 | if (rate->fixed) | |
590 | sdata->bss->force_unicast_rateidx = i; | |
5cdfed54 | 591 | return 0; |
1fd5e589 LF |
592 | } |
593 | } | |
5cdfed54 | 594 | return -EINVAL; |
1fd5e589 LF |
595 | } |
596 | ||
b3d88ad4 LF |
597 | static int ieee80211_ioctl_giwrate(struct net_device *dev, |
598 | struct iw_request_info *info, | |
599 | struct iw_param *rate, char *extra) | |
600 | { | |
601 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
602 | struct sta_info *sta; | |
603 | struct ieee80211_sub_if_data *sdata; | |
604 | ||
605 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
606 | if (sdata->type == IEEE80211_IF_TYPE_STA) | |
607 | sta = sta_info_get(local, sdata->u.sta.bssid); | |
608 | else | |
609 | return -EOPNOTSUPP; | |
610 | if (!sta) | |
611 | return -ENODEV; | |
612 | if (sta->txrate < local->oper_hw_mode->num_rates) | |
613 | rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000; | |
614 | else | |
615 | rate->value = 0; | |
616 | sta_info_put(sta); | |
617 | return 0; | |
618 | } | |
619 | ||
61609bc0 MB |
620 | static int ieee80211_ioctl_siwtxpower(struct net_device *dev, |
621 | struct iw_request_info *info, | |
622 | union iwreq_data *data, char *extra) | |
623 | { | |
624 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
625 | bool need_reconfig = 0; | |
6a432955 | 626 | u8 new_power_level; |
61609bc0 MB |
627 | |
628 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | |
629 | return -EINVAL; | |
630 | if (data->txpower.flags & IW_TXPOW_RANGE) | |
631 | return -EINVAL; | |
61609bc0 | 632 | |
6a432955 MN |
633 | if (data->txpower.fixed) { |
634 | new_power_level = data->txpower.value; | |
635 | } else { | |
636 | /* Automatic power level. Get the px power from the current | |
637 | * channel. */ | |
638 | struct ieee80211_channel* chan = local->oper_channel; | |
639 | if (!chan) | |
640 | return -EINVAL; | |
641 | ||
642 | new_power_level = chan->power_level; | |
643 | } | |
644 | ||
645 | if (local->hw.conf.power_level != new_power_level) { | |
646 | local->hw.conf.power_level = new_power_level; | |
61609bc0 MB |
647 | need_reconfig = 1; |
648 | } | |
6a432955 | 649 | |
61609bc0 MB |
650 | if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { |
651 | local->hw.conf.radio_enabled = !(data->txpower.disabled); | |
652 | need_reconfig = 1; | |
653 | } | |
6a432955 | 654 | |
61609bc0 MB |
655 | if (need_reconfig) { |
656 | ieee80211_hw_config(local); | |
657 | /* The return value of hw_config is not of big interest here, | |
658 | * as it doesn't say that it failed because of _this_ config | |
659 | * change or something else. Ignore it. */ | |
660 | } | |
661 | ||
662 | return 0; | |
663 | } | |
664 | ||
fe6aa301 LF |
665 | static int ieee80211_ioctl_giwtxpower(struct net_device *dev, |
666 | struct iw_request_info *info, | |
667 | union iwreq_data *data, char *extra) | |
668 | { | |
669 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
670 | ||
671 | data->txpower.fixed = 1; | |
672 | data->txpower.disabled = !(local->hw.conf.radio_enabled); | |
673 | data->txpower.value = local->hw.conf.power_level; | |
674 | data->txpower.flags = IW_TXPOW_DBM; | |
675 | ||
676 | return 0; | |
677 | } | |
678 | ||
f0706e82 JB |
679 | static int ieee80211_ioctl_siwrts(struct net_device *dev, |
680 | struct iw_request_info *info, | |
681 | struct iw_param *rts, char *extra) | |
682 | { | |
683 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
684 | ||
685 | if (rts->disabled) | |
686 | local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | |
687 | else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD) | |
688 | return -EINVAL; | |
689 | else | |
690 | local->rts_threshold = rts->value; | |
691 | ||
692 | /* If the wlan card performs RTS/CTS in hardware/firmware, | |
693 | * configure it here */ | |
694 | ||
695 | if (local->ops->set_rts_threshold) | |
696 | local->ops->set_rts_threshold(local_to_hw(local), | |
697 | local->rts_threshold); | |
698 | ||
699 | return 0; | |
700 | } | |
701 | ||
702 | static int ieee80211_ioctl_giwrts(struct net_device *dev, | |
703 | struct iw_request_info *info, | |
704 | struct iw_param *rts, char *extra) | |
705 | { | |
706 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
707 | ||
708 | rts->value = local->rts_threshold; | |
709 | rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD); | |
710 | rts->fixed = 1; | |
711 | ||
712 | return 0; | |
713 | } | |
714 | ||
715 | ||
716 | static int ieee80211_ioctl_siwfrag(struct net_device *dev, | |
717 | struct iw_request_info *info, | |
718 | struct iw_param *frag, char *extra) | |
719 | { | |
720 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
721 | ||
722 | if (frag->disabled) | |
723 | local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; | |
724 | else if (frag->value < 256 || | |
725 | frag->value > IEEE80211_MAX_FRAG_THRESHOLD) | |
726 | return -EINVAL; | |
727 | else { | |
728 | /* Fragment length must be even, so strip LSB. */ | |
729 | local->fragmentation_threshold = frag->value & ~0x1; | |
730 | } | |
731 | ||
732 | /* If the wlan card performs fragmentation in hardware/firmware, | |
733 | * configure it here */ | |
734 | ||
735 | if (local->ops->set_frag_threshold) | |
736 | local->ops->set_frag_threshold( | |
737 | local_to_hw(local), | |
738 | local->fragmentation_threshold); | |
739 | ||
740 | return 0; | |
741 | } | |
742 | ||
743 | static int ieee80211_ioctl_giwfrag(struct net_device *dev, | |
744 | struct iw_request_info *info, | |
745 | struct iw_param *frag, char *extra) | |
746 | { | |
747 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
748 | ||
749 | frag->value = local->fragmentation_threshold; | |
750 | frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD); | |
751 | frag->fixed = 1; | |
752 | ||
753 | return 0; | |
754 | } | |
755 | ||
756 | ||
757 | static int ieee80211_ioctl_siwretry(struct net_device *dev, | |
758 | struct iw_request_info *info, | |
759 | struct iw_param *retry, char *extra) | |
760 | { | |
761 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
762 | ||
763 | if (retry->disabled || | |
764 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) | |
765 | return -EINVAL; | |
766 | ||
767 | if (retry->flags & IW_RETRY_MAX) | |
768 | local->long_retry_limit = retry->value; | |
769 | else if (retry->flags & IW_RETRY_MIN) | |
770 | local->short_retry_limit = retry->value; | |
771 | else { | |
772 | local->long_retry_limit = retry->value; | |
773 | local->short_retry_limit = retry->value; | |
774 | } | |
775 | ||
776 | if (local->ops->set_retry_limit) { | |
777 | return local->ops->set_retry_limit( | |
778 | local_to_hw(local), | |
779 | local->short_retry_limit, | |
780 | local->long_retry_limit); | |
781 | } | |
782 | ||
783 | return 0; | |
784 | } | |
785 | ||
786 | ||
787 | static int ieee80211_ioctl_giwretry(struct net_device *dev, | |
788 | struct iw_request_info *info, | |
789 | struct iw_param *retry, char *extra) | |
790 | { | |
791 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
792 | ||
793 | retry->disabled = 0; | |
794 | if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) { | |
795 | /* first return min value, iwconfig will ask max value | |
796 | * later if needed */ | |
797 | retry->flags |= IW_RETRY_LIMIT; | |
798 | retry->value = local->short_retry_limit; | |
799 | if (local->long_retry_limit != local->short_retry_limit) | |
800 | retry->flags |= IW_RETRY_MIN; | |
801 | return 0; | |
802 | } | |
803 | if (retry->flags & IW_RETRY_MAX) { | |
804 | retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; | |
805 | retry->value = local->long_retry_limit; | |
806 | } | |
807 | ||
808 | return 0; | |
809 | } | |
810 | ||
f0706e82 JB |
811 | static int ieee80211_ioctl_siwmlme(struct net_device *dev, |
812 | struct iw_request_info *info, | |
813 | struct iw_point *data, char *extra) | |
814 | { | |
815 | struct ieee80211_sub_if_data *sdata; | |
816 | struct iw_mlme *mlme = (struct iw_mlme *) extra; | |
817 | ||
818 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
819 | if (sdata->type != IEEE80211_IF_TYPE_STA && | |
820 | sdata->type != IEEE80211_IF_TYPE_IBSS) | |
821 | return -EINVAL; | |
822 | ||
823 | switch (mlme->cmd) { | |
824 | case IW_MLME_DEAUTH: | |
825 | /* TODO: mlme->addr.sa_data */ | |
826 | return ieee80211_sta_deauthenticate(dev, mlme->reason_code); | |
827 | case IW_MLME_DISASSOC: | |
828 | /* TODO: mlme->addr.sa_data */ | |
829 | return ieee80211_sta_disassociate(dev, mlme->reason_code); | |
830 | default: | |
831 | return -EOPNOTSUPP; | |
832 | } | |
833 | } | |
834 | ||
835 | ||
836 | static int ieee80211_ioctl_siwencode(struct net_device *dev, | |
837 | struct iw_request_info *info, | |
838 | struct iw_point *erq, char *keybuf) | |
839 | { | |
840 | struct ieee80211_sub_if_data *sdata; | |
841 | int idx, i, alg = ALG_WEP; | |
842 | u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
628a140b | 843 | int remove = 0; |
f0706e82 JB |
844 | |
845 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
846 | ||
847 | idx = erq->flags & IW_ENCODE_INDEX; | |
848 | if (idx == 0) { | |
849 | if (sdata->default_key) | |
850 | for (i = 0; i < NUM_DEFAULT_KEYS; i++) { | |
851 | if (sdata->default_key == sdata->keys[i]) { | |
852 | idx = i; | |
853 | break; | |
854 | } | |
855 | } | |
856 | } else if (idx < 1 || idx > 4) | |
857 | return -EINVAL; | |
858 | else | |
859 | idx--; | |
860 | ||
861 | if (erq->flags & IW_ENCODE_DISABLED) | |
628a140b | 862 | remove = 1; |
f0706e82 JB |
863 | else if (erq->length == 0) { |
864 | /* No key data - just set the default TX key index */ | |
11a843b7 | 865 | ieee80211_set_default_key(sdata, idx); |
f0706e82 JB |
866 | return 0; |
867 | } | |
868 | ||
869 | return ieee80211_set_encryption( | |
870 | dev, bcaddr, | |
628a140b | 871 | idx, alg, remove, |
f0706e82 JB |
872 | !sdata->default_key, |
873 | keybuf, erq->length); | |
874 | } | |
875 | ||
876 | ||
877 | static int ieee80211_ioctl_giwencode(struct net_device *dev, | |
878 | struct iw_request_info *info, | |
879 | struct iw_point *erq, char *key) | |
880 | { | |
881 | struct ieee80211_sub_if_data *sdata; | |
882 | int idx, i; | |
883 | ||
884 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
885 | ||
886 | idx = erq->flags & IW_ENCODE_INDEX; | |
887 | if (idx < 1 || idx > 4) { | |
888 | idx = -1; | |
889 | if (!sdata->default_key) | |
890 | idx = 0; | |
891 | else for (i = 0; i < NUM_DEFAULT_KEYS; i++) { | |
892 | if (sdata->default_key == sdata->keys[i]) { | |
893 | idx = i; | |
894 | break; | |
895 | } | |
896 | } | |
897 | if (idx < 0) | |
898 | return -EINVAL; | |
899 | } else | |
900 | idx--; | |
901 | ||
902 | erq->flags = idx + 1; | |
903 | ||
904 | if (!sdata->keys[idx]) { | |
905 | erq->length = 0; | |
906 | erq->flags |= IW_ENCODE_DISABLED; | |
907 | return 0; | |
908 | } | |
909 | ||
8f20fc24 | 910 | memcpy(key, sdata->keys[idx]->conf.key, |
11a843b7 | 911 | min_t(int, erq->length, sdata->keys[idx]->conf.keylen)); |
8f20fc24 | 912 | erq->length = sdata->keys[idx]->conf.keylen; |
f0706e82 JB |
913 | erq->flags |= IW_ENCODE_ENABLED; |
914 | ||
915 | return 0; | |
916 | } | |
917 | ||
918 | static int ieee80211_ioctl_siwauth(struct net_device *dev, | |
919 | struct iw_request_info *info, | |
920 | struct iw_param *data, char *extra) | |
921 | { | |
f0706e82 JB |
922 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
923 | int ret = 0; | |
924 | ||
925 | switch (data->flags & IW_AUTH_INDEX) { | |
926 | case IW_AUTH_WPA_VERSION: | |
927 | case IW_AUTH_CIPHER_PAIRWISE: | |
928 | case IW_AUTH_CIPHER_GROUP: | |
929 | case IW_AUTH_WPA_ENABLED: | |
930 | case IW_AUTH_RX_UNENCRYPTED_EAPOL: | |
f0706e82 | 931 | case IW_AUTH_KEY_MGMT: |
5b98b1f7 | 932 | break; |
b1357a81 JB |
933 | case IW_AUTH_DROP_UNENCRYPTED: |
934 | sdata->drop_unencrypted = !!data->value; | |
935 | break; | |
5b98b1f7 | 936 | case IW_AUTH_PRIVACY_INVOKED: |
f0706e82 JB |
937 | if (sdata->type != IEEE80211_IF_TYPE_STA) |
938 | ret = -EINVAL; | |
939 | else { | |
5b98b1f7 | 940 | sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED; |
f0706e82 | 941 | /* |
5b98b1f7 JB |
942 | * Privacy invoked by wpa_supplicant, store the |
943 | * value and allow associating to a protected | |
944 | * network without having a key up front. | |
f0706e82 | 945 | */ |
5b98b1f7 JB |
946 | if (data->value) |
947 | sdata->u.sta.flags |= | |
948 | IEEE80211_STA_PRIVACY_INVOKED; | |
f0706e82 JB |
949 | } |
950 | break; | |
951 | case IW_AUTH_80211_AUTH_ALG: | |
952 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
953 | sdata->type == IEEE80211_IF_TYPE_IBSS) | |
954 | sdata->u.sta.auth_algs = data->value; | |
955 | else | |
956 | ret = -EOPNOTSUPP; | |
957 | break; | |
f0706e82 JB |
958 | default: |
959 | ret = -EOPNOTSUPP; | |
960 | break; | |
961 | } | |
962 | return ret; | |
963 | } | |
964 | ||
965 | /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ | |
966 | static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) | |
967 | { | |
968 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | |
969 | struct iw_statistics *wstats = &local->wstats; | |
970 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
971 | struct sta_info *sta = NULL; | |
972 | ||
973 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
974 | sdata->type == IEEE80211_IF_TYPE_IBSS) | |
975 | sta = sta_info_get(local, sdata->u.sta.bssid); | |
976 | if (!sta) { | |
977 | wstats->discard.fragment = 0; | |
978 | wstats->discard.misc = 0; | |
979 | wstats->qual.qual = 0; | |
980 | wstats->qual.level = 0; | |
981 | wstats->qual.noise = 0; | |
982 | wstats->qual.updated = IW_QUAL_ALL_INVALID; | |
983 | } else { | |
984 | wstats->qual.level = sta->last_rssi; | |
985 | wstats->qual.qual = sta->last_signal; | |
986 | wstats->qual.noise = sta->last_noise; | |
987 | wstats->qual.updated = local->wstats_flags; | |
988 | sta_info_put(sta); | |
989 | } | |
990 | return wstats; | |
991 | } | |
992 | ||
993 | static int ieee80211_ioctl_giwauth(struct net_device *dev, | |
994 | struct iw_request_info *info, | |
995 | struct iw_param *data, char *extra) | |
996 | { | |
997 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
998 | int ret = 0; | |
999 | ||
1000 | switch (data->flags & IW_AUTH_INDEX) { | |
1001 | case IW_AUTH_80211_AUTH_ALG: | |
1002 | if (sdata->type == IEEE80211_IF_TYPE_STA || | |
1003 | sdata->type == IEEE80211_IF_TYPE_IBSS) | |
1004 | data->value = sdata->u.sta.auth_algs; | |
1005 | else | |
1006 | ret = -EOPNOTSUPP; | |
1007 | break; | |
1008 | default: | |
1009 | ret = -EOPNOTSUPP; | |
1010 | break; | |
1011 | } | |
1012 | return ret; | |
1013 | } | |
1014 | ||
1015 | ||
1016 | static int ieee80211_ioctl_siwencodeext(struct net_device *dev, | |
1017 | struct iw_request_info *info, | |
1018 | struct iw_point *erq, char *extra) | |
1019 | { | |
1020 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
1021 | struct iw_encode_ext *ext = (struct iw_encode_ext *) extra; | |
628a140b | 1022 | int uninitialized_var(alg), idx, i, remove = 0; |
f0706e82 JB |
1023 | |
1024 | switch (ext->alg) { | |
1025 | case IW_ENCODE_ALG_NONE: | |
628a140b | 1026 | remove = 1; |
f0706e82 JB |
1027 | break; |
1028 | case IW_ENCODE_ALG_WEP: | |
1029 | alg = ALG_WEP; | |
1030 | break; | |
1031 | case IW_ENCODE_ALG_TKIP: | |
1032 | alg = ALG_TKIP; | |
1033 | break; | |
1034 | case IW_ENCODE_ALG_CCMP: | |
1035 | alg = ALG_CCMP; | |
1036 | break; | |
1037 | default: | |
1038 | return -EOPNOTSUPP; | |
1039 | } | |
1040 | ||
1041 | if (erq->flags & IW_ENCODE_DISABLED) | |
628a140b | 1042 | remove = 1; |
f0706e82 JB |
1043 | |
1044 | idx = erq->flags & IW_ENCODE_INDEX; | |
1045 | if (idx < 1 || idx > 4) { | |
1046 | idx = -1; | |
1047 | if (!sdata->default_key) | |
1048 | idx = 0; | |
1049 | else for (i = 0; i < NUM_DEFAULT_KEYS; i++) { | |
1050 | if (sdata->default_key == sdata->keys[i]) { | |
1051 | idx = i; | |
1052 | break; | |
1053 | } | |
1054 | } | |
1055 | if (idx < 0) | |
1056 | return -EINVAL; | |
1057 | } else | |
1058 | idx--; | |
1059 | ||
1060 | return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg, | |
628a140b | 1061 | remove, |
f0706e82 JB |
1062 | ext->ext_flags & |
1063 | IW_ENCODE_EXT_SET_TX_KEY, | |
1064 | ext->key, ext->key_len); | |
1065 | } | |
1066 | ||
1067 | ||
f0706e82 JB |
1068 | /* Structures to export the Wireless Handlers */ |
1069 | ||
1070 | static const iw_handler ieee80211_handler[] = | |
1071 | { | |
1072 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ | |
1073 | (iw_handler) ieee80211_ioctl_giwname, /* SIOCGIWNAME */ | |
1074 | (iw_handler) NULL, /* SIOCSIWNWID */ | |
1075 | (iw_handler) NULL, /* SIOCGIWNWID */ | |
1076 | (iw_handler) ieee80211_ioctl_siwfreq, /* SIOCSIWFREQ */ | |
1077 | (iw_handler) ieee80211_ioctl_giwfreq, /* SIOCGIWFREQ */ | |
1078 | (iw_handler) ieee80211_ioctl_siwmode, /* SIOCSIWMODE */ | |
1079 | (iw_handler) ieee80211_ioctl_giwmode, /* SIOCGIWMODE */ | |
1080 | (iw_handler) NULL, /* SIOCSIWSENS */ | |
1081 | (iw_handler) NULL, /* SIOCGIWSENS */ | |
1082 | (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ | |
1083 | (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */ | |
1084 | (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ | |
1085 | (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ | |
1086 | (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */ | |
1087 | (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */ | |
5d4ecd93 JB |
1088 | (iw_handler) NULL, /* SIOCSIWSPY */ |
1089 | (iw_handler) NULL, /* SIOCGIWSPY */ | |
1090 | (iw_handler) NULL, /* SIOCSIWTHRSPY */ | |
1091 | (iw_handler) NULL, /* SIOCGIWTHRSPY */ | |
f0706e82 JB |
1092 | (iw_handler) ieee80211_ioctl_siwap, /* SIOCSIWAP */ |
1093 | (iw_handler) ieee80211_ioctl_giwap, /* SIOCGIWAP */ | |
1094 | (iw_handler) ieee80211_ioctl_siwmlme, /* SIOCSIWMLME */ | |
1095 | (iw_handler) NULL, /* SIOCGIWAPLIST */ | |
1096 | (iw_handler) ieee80211_ioctl_siwscan, /* SIOCSIWSCAN */ | |
1097 | (iw_handler) ieee80211_ioctl_giwscan, /* SIOCGIWSCAN */ | |
1098 | (iw_handler) ieee80211_ioctl_siwessid, /* SIOCSIWESSID */ | |
1099 | (iw_handler) ieee80211_ioctl_giwessid, /* SIOCGIWESSID */ | |
1100 | (iw_handler) NULL, /* SIOCSIWNICKN */ | |
1101 | (iw_handler) NULL, /* SIOCGIWNICKN */ | |
1102 | (iw_handler) NULL, /* -- hole -- */ | |
1103 | (iw_handler) NULL, /* -- hole -- */ | |
1fd5e589 | 1104 | (iw_handler) ieee80211_ioctl_siwrate, /* SIOCSIWRATE */ |
b3d88ad4 | 1105 | (iw_handler) ieee80211_ioctl_giwrate, /* SIOCGIWRATE */ |
f0706e82 JB |
1106 | (iw_handler) ieee80211_ioctl_siwrts, /* SIOCSIWRTS */ |
1107 | (iw_handler) ieee80211_ioctl_giwrts, /* SIOCGIWRTS */ | |
1108 | (iw_handler) ieee80211_ioctl_siwfrag, /* SIOCSIWFRAG */ | |
1109 | (iw_handler) ieee80211_ioctl_giwfrag, /* SIOCGIWFRAG */ | |
61609bc0 | 1110 | (iw_handler) ieee80211_ioctl_siwtxpower, /* SIOCSIWTXPOW */ |
fe6aa301 | 1111 | (iw_handler) ieee80211_ioctl_giwtxpower, /* SIOCGIWTXPOW */ |
f0706e82 JB |
1112 | (iw_handler) ieee80211_ioctl_siwretry, /* SIOCSIWRETRY */ |
1113 | (iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */ | |
1114 | (iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */ | |
1115 | (iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */ | |
1116 | (iw_handler) NULL, /* SIOCSIWPOWER */ | |
1117 | (iw_handler) NULL, /* SIOCGIWPOWER */ | |
1118 | (iw_handler) NULL, /* -- hole -- */ | |
1119 | (iw_handler) NULL, /* -- hole -- */ | |
1120 | (iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */ | |
1121 | (iw_handler) NULL, /* SIOCGIWGENIE */ | |
1122 | (iw_handler) ieee80211_ioctl_siwauth, /* SIOCSIWAUTH */ | |
1123 | (iw_handler) ieee80211_ioctl_giwauth, /* SIOCGIWAUTH */ | |
1124 | (iw_handler) ieee80211_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */ | |
1125 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ | |
1126 | (iw_handler) NULL, /* SIOCSIWPMKSA */ | |
1127 | (iw_handler) NULL, /* -- hole -- */ | |
1128 | }; | |
1129 | ||
f0706e82 JB |
1130 | const struct iw_handler_def ieee80211_iw_handler_def = |
1131 | { | |
1132 | .num_standard = ARRAY_SIZE(ieee80211_handler), | |
f0706e82 | 1133 | .standard = (iw_handler *) ieee80211_handler, |
f0706e82 JB |
1134 | .get_wireless_stats = ieee80211_get_wireless_stats, |
1135 | }; |