]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - net/mac80211/ieee80211_ioctl.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[linux-2.6-omap-h63xx.git] / net / mac80211 / ieee80211_ioctl.c
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"
24 #include "hostapd_ioctl.h"
25 #include "ieee80211_rate.h"
26 #include "wpa.h"
27 #include "aes_ccm.h"
28 #include "debugfs_key.h"
29
30 static int ieee80211_regdom = 0x10; /* FCC */
31 module_param(ieee80211_regdom, int, 0444);
32 MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
33
34 /*
35  * If firmware is upgraded by the vendor, additional channels can be used based
36  * on the new Japanese regulatory rules. This is indicated by setting
37  * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel
38  * module.
39  */
40 static int ieee80211_japan_5ghz /* = 0 */;
41 module_param(ieee80211_japan_5ghz, int, 0444);
42 MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
43
44 static void ieee80211_set_hw_encryption(struct net_device *dev,
45                                         struct sta_info *sta, u8 addr[ETH_ALEN],
46                                         struct ieee80211_key *key)
47 {
48         struct ieee80211_key_conf *keyconf = NULL;
49         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
50
51         /* default to sw encryption; this will be cleared by low-level
52          * driver if the hw supports requested encryption */
53         if (key)
54                 key->force_sw_encrypt = 1;
55
56         if (key && local->ops->set_key &&
57             (keyconf = ieee80211_key_data2conf(local, key))) {
58                 if (local->ops->set_key(local_to_hw(local), SET_KEY, addr,
59                                        keyconf, sta ? sta->aid : 0)) {
60                         key->force_sw_encrypt = 1;
61                         key->hw_key_idx = HW_KEY_IDX_INVALID;
62                 } else {
63                         key->force_sw_encrypt =
64                                 !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
65                         key->hw_key_idx =
66                                 keyconf->hw_key_idx;
67
68                 }
69         }
70         kfree(keyconf);
71 }
72
73
74 static int ieee80211_set_encryption(struct net_device *dev, u8 *sta_addr,
75                                     int idx, int alg, int set_tx_key,
76                                     const u8 *_key, size_t key_len)
77 {
78         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
79         int ret = 0;
80         struct sta_info *sta;
81         struct ieee80211_key *key, *old_key;
82         int try_hwaccel = 1;
83         struct ieee80211_key_conf *keyconf;
84         struct ieee80211_sub_if_data *sdata;
85
86         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
87
88         if (is_broadcast_ether_addr(sta_addr)) {
89                 sta = NULL;
90                 if (idx >= NUM_DEFAULT_KEYS) {
91                         printk(KERN_DEBUG "%s: set_encrypt - invalid idx=%d\n",
92                                dev->name, idx);
93                         return -EINVAL;
94                 }
95                 key = sdata->keys[idx];
96
97                 /* TODO: consider adding hwaccel support for these; at least
98                  * Atheros key cache should be able to handle this since AP is
99                  * only transmitting frames with default keys. */
100                 /* FIX: hw key cache can be used when only one virtual
101                  * STA is associated with each AP. If more than one STA
102                  * is associated to the same AP, software encryption
103                  * must be used. This should be done automatically
104                  * based on configured station devices. For the time
105                  * being, this can be only set at compile time. */
106         } else {
107                 set_tx_key = 0;
108                 if (idx != 0) {
109                         printk(KERN_DEBUG "%s: set_encrypt - non-zero idx for "
110                                "individual key\n", dev->name);
111                         return -EINVAL;
112                 }
113
114                 sta = sta_info_get(local, sta_addr);
115                 if (!sta) {
116 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG
117                         printk(KERN_DEBUG "%s: set_encrypt - unknown addr "
118                                MAC_FMT "\n",
119                                dev->name, MAC_ARG(sta_addr));
120 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
121
122                         return -ENOENT;
123                 }
124
125                 key = sta->key;
126         }
127
128         /* FIX:
129          * Cannot configure default hwaccel keys with WEP algorithm, if
130          * any of the virtual interfaces is using static WEP
131          * configuration because hwaccel would otherwise try to decrypt
132          * these frames.
133          *
134          * For now, just disable WEP hwaccel for broadcast when there is
135          * possibility of conflict with default keys. This can maybe later be
136          * optimized by using non-default keys (at least with Atheros ar521x).
137          */
138         if (!sta && alg == ALG_WEP && !local->default_wep_only &&
139             sdata->type != IEEE80211_IF_TYPE_IBSS &&
140             sdata->type != IEEE80211_IF_TYPE_AP) {
141                 try_hwaccel = 0;
142         }
143
144         if (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) {
145                 /* Software encryption cannot be used with devices that hide
146                  * encryption from the host system, so always try to use
147                  * hardware acceleration with such devices. */
148                 try_hwaccel = 1;
149         }
150
151         if ((local->hw.flags & IEEE80211_HW_NO_TKIP_WMM_HWACCEL) &&
152             alg == ALG_TKIP) {
153                 if (sta && (sta->flags & WLAN_STA_WME)) {
154                 /* Hardware does not support hwaccel with TKIP when using WMM.
155                  */
156                         try_hwaccel = 0;
157                 }
158                 else if (sdata->type == IEEE80211_IF_TYPE_STA) {
159                         sta = sta_info_get(local, sdata->u.sta.bssid);
160                         if (sta) {
161                                 if (sta->flags & WLAN_STA_WME) {
162                                         try_hwaccel = 0;
163                                 }
164                                 sta_info_put(sta);
165                                 sta = NULL;
166                         }
167                 }
168         }
169
170         if (alg == ALG_NONE) {
171                 keyconf = NULL;
172                 if (try_hwaccel && key &&
173                     key->hw_key_idx != HW_KEY_IDX_INVALID &&
174                     local->ops->set_key &&
175                     (keyconf = ieee80211_key_data2conf(local, key)) != NULL &&
176                     local->ops->set_key(local_to_hw(local), DISABLE_KEY,
177                                        sta_addr, keyconf, sta ? sta->aid : 0)) {
178                         printk(KERN_DEBUG "%s: set_encrypt - low-level disable"
179                                " failed\n", dev->name);
180                         ret = -EINVAL;
181                 }
182                 kfree(keyconf);
183
184                 if (set_tx_key || sdata->default_key == key) {
185                         ieee80211_debugfs_key_remove_default(sdata);
186                         sdata->default_key = NULL;
187                 }
188                 ieee80211_debugfs_key_remove(key);
189                 if (sta)
190                         sta->key = NULL;
191                 else
192                         sdata->keys[idx] = NULL;
193                 ieee80211_key_free(key);
194                 key = NULL;
195         } else {
196                 old_key = key;
197                 key = ieee80211_key_alloc(sta ? NULL : sdata, idx, key_len,
198                                           GFP_KERNEL);
199                 if (!key) {
200                         ret = -ENOMEM;
201                         goto err_out;
202                 }
203
204                 /* default to sw encryption; low-level driver sets these if the
205                  * requested encryption is supported */
206                 key->hw_key_idx = HW_KEY_IDX_INVALID;
207                 key->force_sw_encrypt = 1;
208
209                 key->alg = alg;
210                 key->keyidx = idx;
211                 key->keylen = key_len;
212                 memcpy(key->key, _key, key_len);
213                 if (set_tx_key)
214                         key->default_tx_key = 1;
215
216                 if (alg == ALG_CCMP) {
217                         /* Initialize AES key state here as an optimization
218                          * so that it does not need to be initialized for every
219                          * packet. */
220                         key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
221                                 key->key);
222                         if (!key->u.ccmp.tfm) {
223                                 ret = -ENOMEM;
224                                 goto err_free;
225                         }
226                 }
227
228                 if (set_tx_key || sdata->default_key == old_key) {
229                         ieee80211_debugfs_key_remove_default(sdata);
230                         sdata->default_key = NULL;
231                 }
232                 ieee80211_debugfs_key_remove(old_key);
233                 if (sta)
234                         sta->key = key;
235                 else
236                         sdata->keys[idx] = key;
237                 ieee80211_key_free(old_key);
238                 ieee80211_debugfs_key_add(local, key);
239                 if (sta)
240                         ieee80211_debugfs_key_sta_link(key, sta);
241
242                 if (try_hwaccel &&
243                     (alg == ALG_WEP || alg == ALG_TKIP || alg == ALG_CCMP))
244                         ieee80211_set_hw_encryption(dev, sta, sta_addr, key);
245         }
246
247         if (set_tx_key || (!sta && !sdata->default_key && key)) {
248                 sdata->default_key = key;
249                 if (key)
250                         ieee80211_debugfs_key_add_default(sdata);
251
252                 if (local->ops->set_key_idx &&
253                     local->ops->set_key_idx(local_to_hw(local), idx))
254                         printk(KERN_DEBUG "%s: failed to set TX key idx for "
255                                "low-level driver\n", dev->name);
256         }
257
258         if (sta)
259                 sta_info_put(sta);
260
261         return 0;
262
263 err_free:
264         ieee80211_key_free(key);
265 err_out:
266         if (sta)
267                 sta_info_put(sta);
268         return ret;
269 }
270
271 static int ieee80211_ioctl_siwgenie(struct net_device *dev,
272                                     struct iw_request_info *info,
273                                     struct iw_point *data, char *extra)
274 {
275         struct ieee80211_sub_if_data *sdata;
276         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
277
278         if (local->user_space_mlme)
279                 return -EOPNOTSUPP;
280
281         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
282         if (sdata->type == IEEE80211_IF_TYPE_STA ||
283             sdata->type == IEEE80211_IF_TYPE_IBSS) {
284                 int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length);
285                 if (ret)
286                         return ret;
287                 sdata->u.sta.auto_bssid_sel = 0;
288                 ieee80211_sta_req_auth(dev, &sdata->u.sta);
289                 return 0;
290         }
291
292         if (sdata->type == IEEE80211_IF_TYPE_AP) {
293                 kfree(sdata->u.ap.generic_elem);
294                 sdata->u.ap.generic_elem = kmalloc(data->length, GFP_KERNEL);
295                 if (!sdata->u.ap.generic_elem)
296                         return -ENOMEM;
297                 memcpy(sdata->u.ap.generic_elem, extra, data->length);
298                 sdata->u.ap.generic_elem_len = data->length;
299                 return ieee80211_if_config(dev);
300         }
301         return -EOPNOTSUPP;
302 }
303
304 static int ieee80211_ioctl_set_radio_enabled(struct net_device *dev,
305                                              int val)
306 {
307         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
308         struct ieee80211_conf *conf = &local->hw.conf;
309
310         conf->radio_enabled = val;
311         return ieee80211_hw_config(wdev_priv(dev->ieee80211_ptr));
312 }
313
314 static int ieee80211_ioctl_giwname(struct net_device *dev,
315                                    struct iw_request_info *info,
316                                    char *name, char *extra)
317 {
318         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
319
320         switch (local->hw.conf.phymode) {
321         case MODE_IEEE80211A:
322                 strcpy(name, "IEEE 802.11a");
323                 break;
324         case MODE_IEEE80211B:
325                 strcpy(name, "IEEE 802.11b");
326                 break;
327         case MODE_IEEE80211G:
328                 strcpy(name, "IEEE 802.11g");
329                 break;
330         case MODE_ATHEROS_TURBO:
331                 strcpy(name, "5GHz Turbo");
332                 break;
333         default:
334                 strcpy(name, "IEEE 802.11");
335                 break;
336         }
337
338         return 0;
339 }
340
341
342 static int ieee80211_ioctl_giwrange(struct net_device *dev,
343                                  struct iw_request_info *info,
344                                  struct iw_point *data, char *extra)
345 {
346         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
347         struct iw_range *range = (struct iw_range *) extra;
348
349         data->length = sizeof(struct iw_range);
350         memset(range, 0, sizeof(struct iw_range));
351
352         range->we_version_compiled = WIRELESS_EXT;
353         range->we_version_source = 21;
354         range->retry_capa = IW_RETRY_LIMIT;
355         range->retry_flags = IW_RETRY_LIMIT;
356         range->min_retry = 0;
357         range->max_retry = 255;
358         range->min_rts = 0;
359         range->max_rts = 2347;
360         range->min_frag = 256;
361         range->max_frag = 2346;
362
363         range->encoding_size[0] = 5;
364         range->encoding_size[1] = 13;
365         range->num_encoding_sizes = 2;
366         range->max_encoding_tokens = NUM_DEFAULT_KEYS;
367
368         range->max_qual.qual = local->hw.max_signal;
369         range->max_qual.level = local->hw.max_rssi;
370         range->max_qual.noise = local->hw.max_noise;
371         range->max_qual.updated = local->wstats_flags;
372
373         range->avg_qual.qual = local->hw.max_signal/2;
374         range->avg_qual.level = 0;
375         range->avg_qual.noise = 0;
376         range->avg_qual.updated = local->wstats_flags;
377
378         range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
379                           IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
380
381         IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
382         IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
383         IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
384         IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
385
386         return 0;
387 }
388
389
390 struct ieee80211_channel_range {
391         short start_freq;
392         short end_freq;
393         unsigned char power_level;
394         unsigned char antenna_max;
395 };
396
397 static const struct ieee80211_channel_range ieee80211_fcc_channels[] = {
398         { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */,
399         { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */,
400         { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */,
401         { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */,
402         { 0 }
403 };
404
405 static const struct ieee80211_channel_range ieee80211_mkk_channels[] = {
406         { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */,
407         { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */,
408         { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */,
409         { 0 }
410 };
411
412
413 static const struct ieee80211_channel_range *channel_range =
414         ieee80211_fcc_channels;
415
416
417 static void ieee80211_unmask_channel(struct net_device *dev, int mode,
418                                      struct ieee80211_channel *chan)
419 {
420         int i;
421
422         chan->flag = 0;
423
424         if (ieee80211_regdom == 64 &&
425             (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
426                 /* Do not allow Turbo modes in Japan. */
427                 return;
428         }
429
430         for (i = 0; channel_range[i].start_freq; i++) {
431                 const struct ieee80211_channel_range *r = &channel_range[i];
432                 if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
433                         if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz &&
434                             chan->freq >= 5260 && chan->freq <= 5320) {
435                                 /*
436                                  * Skip new channels in Japan since the
437                                  * firmware was not marked having been upgraded
438                                  * by the vendor.
439                                  */
440                                 continue;
441                         }
442
443                         if (ieee80211_regdom == 0x10 &&
444                             (chan->freq == 5190 || chan->freq == 5210 ||
445                              chan->freq == 5230)) {
446                                     /* Skip MKK channels when in FCC domain. */
447                                     continue;
448                         }
449
450                         chan->flag |= IEEE80211_CHAN_W_SCAN |
451                                 IEEE80211_CHAN_W_ACTIVE_SCAN |
452                                 IEEE80211_CHAN_W_IBSS;
453                         chan->power_level = r->power_level;
454                         chan->antenna_max = r->antenna_max;
455
456                         if (ieee80211_regdom == 64 &&
457                             (chan->freq == 5170 || chan->freq == 5190 ||
458                              chan->freq == 5210 || chan->freq == 5230)) {
459                                 /*
460                                  * New regulatory rules in Japan have backwards
461                                  * compatibility with old channels in 5.15-5.25
462                                  * GHz band, but the station is not allowed to
463                                  * use active scan on these old channels.
464                                  */
465                                 chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN;
466                         }
467
468                         if (ieee80211_regdom == 64 &&
469                             (chan->freq == 5260 || chan->freq == 5280 ||
470                              chan->freq == 5300 || chan->freq == 5320)) {
471                                 /*
472                                  * IBSS is not allowed on 5.25-5.35 GHz band
473                                  * due to radar detection requirements.
474                                  */
475                                 chan->flag &= ~IEEE80211_CHAN_W_IBSS;
476                         }
477
478                         break;
479                 }
480         }
481 }
482
483
484 static int ieee80211_unmask_channels(struct net_device *dev)
485 {
486         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
487         struct ieee80211_hw_mode *mode;
488         int c;
489
490         list_for_each_entry(mode, &local->modes_list, list) {
491                 for (c = 0; c < mode->num_channels; c++) {
492                         ieee80211_unmask_channel(dev, mode->mode,
493                                                  &mode->channels[c]);
494                 }
495         }
496         return 0;
497 }
498
499
500 int ieee80211_init_client(struct net_device *dev)
501 {
502         if (ieee80211_regdom == 0x40)
503                 channel_range = ieee80211_mkk_channels;
504         ieee80211_unmask_channels(dev);
505         return 0;
506 }
507
508
509 static int ieee80211_ioctl_siwmode(struct net_device *dev,
510                                    struct iw_request_info *info,
511                                    __u32 *mode, char *extra)
512 {
513         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
514         int type;
515
516         if (sdata->type == IEEE80211_IF_TYPE_VLAN)
517                 return -EOPNOTSUPP;
518
519         switch (*mode) {
520         case IW_MODE_INFRA:
521                 type = IEEE80211_IF_TYPE_STA;
522                 break;
523         case IW_MODE_ADHOC:
524                 type = IEEE80211_IF_TYPE_IBSS;
525                 break;
526         case IW_MODE_MONITOR:
527                 type = IEEE80211_IF_TYPE_MNTR;
528                 break;
529         default:
530                 return -EINVAL;
531         }
532
533         if (type == sdata->type)
534                 return 0;
535         if (netif_running(dev))
536                 return -EBUSY;
537
538         ieee80211_if_reinit(dev);
539         ieee80211_if_set_type(dev, type);
540
541         return 0;
542 }
543
544
545 static int ieee80211_ioctl_giwmode(struct net_device *dev,
546                                    struct iw_request_info *info,
547                                    __u32 *mode, char *extra)
548 {
549         struct ieee80211_sub_if_data *sdata;
550
551         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
552         switch (sdata->type) {
553         case IEEE80211_IF_TYPE_AP:
554                 *mode = IW_MODE_MASTER;
555                 break;
556         case IEEE80211_IF_TYPE_STA:
557                 *mode = IW_MODE_INFRA;
558                 break;
559         case IEEE80211_IF_TYPE_IBSS:
560                 *mode = IW_MODE_ADHOC;
561                 break;
562         case IEEE80211_IF_TYPE_MNTR:
563                 *mode = IW_MODE_MONITOR;
564                 break;
565         case IEEE80211_IF_TYPE_WDS:
566                 *mode = IW_MODE_REPEAT;
567                 break;
568         case IEEE80211_IF_TYPE_VLAN:
569                 *mode = IW_MODE_SECOND;         /* FIXME */
570                 break;
571         default:
572                 *mode = IW_MODE_AUTO;
573                 break;
574         }
575         return 0;
576 }
577
578 int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq)
579 {
580         struct ieee80211_hw_mode *mode;
581         int c, set = 0;
582         int ret = -EINVAL;
583
584         list_for_each_entry(mode, &local->modes_list, list) {
585                 if (!(local->enabled_modes & (1 << mode->mode)))
586                         continue;
587                 for (c = 0; c < mode->num_channels; c++) {
588                         struct ieee80211_channel *chan = &mode->channels[c];
589                         if (chan->flag & IEEE80211_CHAN_W_SCAN &&
590                             ((chan->chan == channel) || (chan->freq == freq))) {
591                                 /* Use next_mode as the mode preference to
592                                  * resolve non-unique channel numbers. */
593                                 if (set && mode->mode != local->next_mode)
594                                         continue;
595
596                                 local->oper_channel = chan;
597                                 local->oper_hw_mode = mode;
598                                 set++;
599                         }
600                 }
601         }
602
603         if (set) {
604                 if (local->sta_scanning)
605                         ret = 0;
606                 else
607                         ret = ieee80211_hw_config(local);
608
609                 rate_control_clear(local);
610         }
611
612         return ret;
613 }
614
615 static int ieee80211_ioctl_siwfreq(struct net_device *dev,
616                                    struct iw_request_info *info,
617                                    struct iw_freq *freq, char *extra)
618 {
619         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
620         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
621
622         if (sdata->type == IEEE80211_IF_TYPE_STA)
623                 sdata->u.sta.auto_channel_sel = 0;
624
625         /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
626         if (freq->e == 0) {
627                 if (freq->m < 0) {
628                         if (sdata->type == IEEE80211_IF_TYPE_STA)
629                                 sdata->u.sta.auto_channel_sel = 1;
630                         return 0;
631                 } else
632                         return ieee80211_set_channel(local, freq->m, -1);
633         } else {
634                 int i, div = 1000000;
635                 for (i = 0; i < freq->e; i++)
636                         div /= 10;
637                 if (div > 0)
638                         return ieee80211_set_channel(local, -1, freq->m / div);
639                 else
640                         return -EINVAL;
641         }
642 }
643
644
645 static int ieee80211_ioctl_giwfreq(struct net_device *dev,
646                                    struct iw_request_info *info,
647                                    struct iw_freq *freq, char *extra)
648 {
649         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
650
651         /* TODO: in station mode (Managed/Ad-hoc) might need to poll low-level
652          * driver for the current channel with firmware-based management */
653
654         freq->m = local->hw.conf.freq;
655         freq->e = 6;
656
657         return 0;
658 }
659
660
661 static int ieee80211_ioctl_siwessid(struct net_device *dev,
662                                     struct iw_request_info *info,
663                                     struct iw_point *data, char *ssid)
664 {
665         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
666         struct ieee80211_sub_if_data *sdata;
667         size_t len = data->length;
668
669         /* iwconfig uses nul termination in SSID.. */
670         if (len > 0 && ssid[len - 1] == '\0')
671                 len--;
672
673         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
674         if (sdata->type == IEEE80211_IF_TYPE_STA ||
675             sdata->type == IEEE80211_IF_TYPE_IBSS) {
676                 int ret;
677                 if (local->user_space_mlme) {
678                         if (len > IEEE80211_MAX_SSID_LEN)
679                                 return -EINVAL;
680                         memcpy(sdata->u.sta.ssid, ssid, len);
681                         sdata->u.sta.ssid_len = len;
682                         return 0;
683                 }
684                 sdata->u.sta.auto_ssid_sel = !data->flags;
685                 ret = ieee80211_sta_set_ssid(dev, ssid, len);
686                 if (ret)
687                         return ret;
688                 ieee80211_sta_req_auth(dev, &sdata->u.sta);
689                 return 0;
690         }
691
692         if (sdata->type == IEEE80211_IF_TYPE_AP) {
693                 memcpy(sdata->u.ap.ssid, ssid, len);
694                 memset(sdata->u.ap.ssid + len, 0,
695                        IEEE80211_MAX_SSID_LEN - len);
696                 sdata->u.ap.ssid_len = len;
697                 return ieee80211_if_config(dev);
698         }
699         return -EOPNOTSUPP;
700 }
701
702
703 static int ieee80211_ioctl_giwessid(struct net_device *dev,
704                                     struct iw_request_info *info,
705                                     struct iw_point *data, char *ssid)
706 {
707         size_t len;
708
709         struct ieee80211_sub_if_data *sdata;
710         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
711         if (sdata->type == IEEE80211_IF_TYPE_STA ||
712             sdata->type == IEEE80211_IF_TYPE_IBSS) {
713                 int res = ieee80211_sta_get_ssid(dev, ssid, &len);
714                 if (res == 0) {
715                         data->length = len;
716                         data->flags = 1;
717                 } else
718                         data->flags = 0;
719                 return res;
720         }
721
722         if (sdata->type == IEEE80211_IF_TYPE_AP) {
723                 len = sdata->u.ap.ssid_len;
724                 if (len > IW_ESSID_MAX_SIZE)
725                         len = IW_ESSID_MAX_SIZE;
726                 memcpy(ssid, sdata->u.ap.ssid, len);
727                 data->length = len;
728                 data->flags = 1;
729                 return 0;
730         }
731         return -EOPNOTSUPP;
732 }
733
734
735 static int ieee80211_ioctl_siwap(struct net_device *dev,
736                                  struct iw_request_info *info,
737                                  struct sockaddr *ap_addr, char *extra)
738 {
739         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
740         struct ieee80211_sub_if_data *sdata;
741
742         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
743         if (sdata->type == IEEE80211_IF_TYPE_STA ||
744             sdata->type == IEEE80211_IF_TYPE_IBSS) {
745                 int ret;
746                 if (local->user_space_mlme) {
747                         memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data,
748                                ETH_ALEN);
749                         return 0;
750                 }
751                 if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) {
752                         sdata->u.sta.auto_bssid_sel = 1;
753                         sdata->u.sta.auto_channel_sel = 1;
754                 } else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data))
755                         sdata->u.sta.auto_bssid_sel = 1;
756                 else
757                         sdata->u.sta.auto_bssid_sel = 0;
758                 ret = ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
759                 if (ret)
760                         return ret;
761                 ieee80211_sta_req_auth(dev, &sdata->u.sta);
762                 return 0;
763         } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
764                 if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
765                            ETH_ALEN) == 0)
766                         return 0;
767                 return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data);
768         }
769
770         return -EOPNOTSUPP;
771 }
772
773
774 static int ieee80211_ioctl_giwap(struct net_device *dev,
775                                  struct iw_request_info *info,
776                                  struct sockaddr *ap_addr, char *extra)
777 {
778         struct ieee80211_sub_if_data *sdata;
779
780         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
781         if (sdata->type == IEEE80211_IF_TYPE_STA ||
782             sdata->type == IEEE80211_IF_TYPE_IBSS) {
783                 ap_addr->sa_family = ARPHRD_ETHER;
784                 memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
785                 return 0;
786         } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
787                 ap_addr->sa_family = ARPHRD_ETHER;
788                 memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
789                 return 0;
790         }
791
792         return -EOPNOTSUPP;
793 }
794
795
796 static int ieee80211_ioctl_siwscan(struct net_device *dev,
797                                    struct iw_request_info *info,
798                                    struct iw_point *data, char *extra)
799 {
800         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
801         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
802         u8 *ssid = NULL;
803         size_t ssid_len = 0;
804
805         if (!netif_running(dev))
806                 return -ENETDOWN;
807
808         if (local->scan_flags & IEEE80211_SCAN_MATCH_SSID) {
809                 if (sdata->type == IEEE80211_IF_TYPE_STA ||
810                     sdata->type == IEEE80211_IF_TYPE_IBSS) {
811                         ssid = sdata->u.sta.ssid;
812                         ssid_len = sdata->u.sta.ssid_len;
813                 } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
814                         ssid = sdata->u.ap.ssid;
815                         ssid_len = sdata->u.ap.ssid_len;
816                 } else
817                         return -EINVAL;
818         }
819         return ieee80211_sta_req_scan(dev, ssid, ssid_len);
820 }
821
822
823 static int ieee80211_ioctl_giwscan(struct net_device *dev,
824                                    struct iw_request_info *info,
825                                    struct iw_point *data, char *extra)
826 {
827         int res;
828         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
829         if (local->sta_scanning)
830                 return -EAGAIN;
831         res = ieee80211_sta_scan_results(dev, extra, data->length);
832         if (res >= 0) {
833                 data->length = res;
834                 return 0;
835         }
836         data->length = 0;
837         return res;
838 }
839
840
841 static int ieee80211_ioctl_giwrate(struct net_device *dev,
842                                   struct iw_request_info *info,
843                                   struct iw_param *rate, char *extra)
844 {
845         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
846         struct sta_info *sta;
847         struct ieee80211_sub_if_data *sdata;
848
849         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
850         if (sdata->type == IEEE80211_IF_TYPE_STA)
851                 sta = sta_info_get(local, sdata->u.sta.bssid);
852         else
853                 return -EOPNOTSUPP;
854         if (!sta)
855                 return -ENODEV;
856         if (sta->txrate < local->oper_hw_mode->num_rates)
857                 rate->value = local->oper_hw_mode->rates[sta->txrate].rate * 100000;
858         else
859                 rate->value = 0;
860         sta_info_put(sta);
861         return 0;
862 }
863
864 static int ieee80211_ioctl_siwrts(struct net_device *dev,
865                                   struct iw_request_info *info,
866                                   struct iw_param *rts, char *extra)
867 {
868         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
869
870         if (rts->disabled)
871                 local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
872         else if (rts->value < 0 || rts->value > IEEE80211_MAX_RTS_THRESHOLD)
873                 return -EINVAL;
874         else
875                 local->rts_threshold = rts->value;
876
877         /* If the wlan card performs RTS/CTS in hardware/firmware,
878          * configure it here */
879
880         if (local->ops->set_rts_threshold)
881                 local->ops->set_rts_threshold(local_to_hw(local),
882                                              local->rts_threshold);
883
884         return 0;
885 }
886
887 static int ieee80211_ioctl_giwrts(struct net_device *dev,
888                                   struct iw_request_info *info,
889                                   struct iw_param *rts, char *extra)
890 {
891         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
892
893         rts->value = local->rts_threshold;
894         rts->disabled = (rts->value >= IEEE80211_MAX_RTS_THRESHOLD);
895         rts->fixed = 1;
896
897         return 0;
898 }
899
900
901 static int ieee80211_ioctl_siwfrag(struct net_device *dev,
902                                    struct iw_request_info *info,
903                                    struct iw_param *frag, char *extra)
904 {
905         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
906
907         if (frag->disabled)
908                 local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD;
909         else if (frag->value < 256 ||
910                  frag->value > IEEE80211_MAX_FRAG_THRESHOLD)
911                 return -EINVAL;
912         else {
913                 /* Fragment length must be even, so strip LSB. */
914                 local->fragmentation_threshold = frag->value & ~0x1;
915         }
916
917         /* If the wlan card performs fragmentation in hardware/firmware,
918          * configure it here */
919
920         if (local->ops->set_frag_threshold)
921                 local->ops->set_frag_threshold(
922                         local_to_hw(local),
923                         local->fragmentation_threshold);
924
925         return 0;
926 }
927
928 static int ieee80211_ioctl_giwfrag(struct net_device *dev,
929                                    struct iw_request_info *info,
930                                    struct iw_param *frag, char *extra)
931 {
932         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
933
934         frag->value = local->fragmentation_threshold;
935         frag->disabled = (frag->value >= IEEE80211_MAX_RTS_THRESHOLD);
936         frag->fixed = 1;
937
938         return 0;
939 }
940
941
942 static int ieee80211_ioctl_siwretry(struct net_device *dev,
943                                     struct iw_request_info *info,
944                                     struct iw_param *retry, char *extra)
945 {
946         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
947
948         if (retry->disabled ||
949             (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
950                 return -EINVAL;
951
952         if (retry->flags & IW_RETRY_MAX)
953                 local->long_retry_limit = retry->value;
954         else if (retry->flags & IW_RETRY_MIN)
955                 local->short_retry_limit = retry->value;
956         else {
957                 local->long_retry_limit = retry->value;
958                 local->short_retry_limit = retry->value;
959         }
960
961         if (local->ops->set_retry_limit) {
962                 return local->ops->set_retry_limit(
963                         local_to_hw(local),
964                         local->short_retry_limit,
965                         local->long_retry_limit);
966         }
967
968         return 0;
969 }
970
971
972 static int ieee80211_ioctl_giwretry(struct net_device *dev,
973                                     struct iw_request_info *info,
974                                     struct iw_param *retry, char *extra)
975 {
976         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
977
978         retry->disabled = 0;
979         if (retry->flags == 0 || retry->flags & IW_RETRY_MIN) {
980                 /* first return min value, iwconfig will ask max value
981                  * later if needed */
982                 retry->flags |= IW_RETRY_LIMIT;
983                 retry->value = local->short_retry_limit;
984                 if (local->long_retry_limit != local->short_retry_limit)
985                         retry->flags |= IW_RETRY_MIN;
986                 return 0;
987         }
988         if (retry->flags & IW_RETRY_MAX) {
989                 retry->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
990                 retry->value = local->long_retry_limit;
991         }
992
993         return 0;
994 }
995
996 static int ieee80211_ioctl_clear_keys(struct net_device *dev)
997 {
998         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
999         struct ieee80211_key_conf key;
1000         int i;
1001         u8 addr[ETH_ALEN];
1002         struct ieee80211_key_conf *keyconf;
1003         struct ieee80211_sub_if_data *sdata;
1004         struct sta_info *sta;
1005
1006         memset(addr, 0xff, ETH_ALEN);
1007         read_lock(&local->sub_if_lock);
1008         list_for_each_entry(sdata, &local->sub_if_list, list) {
1009                 for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1010                         keyconf = NULL;
1011                         if (sdata->keys[i] &&
1012                             !sdata->keys[i]->force_sw_encrypt &&
1013                             local->ops->set_key &&
1014                             (keyconf = ieee80211_key_data2conf(local,
1015                                                                sdata->keys[i])))
1016                                 local->ops->set_key(local_to_hw(local),
1017                                                    DISABLE_KEY, addr,
1018                                                    keyconf, 0);
1019                         kfree(keyconf);
1020                         ieee80211_key_free(sdata->keys[i]);
1021                         sdata->keys[i] = NULL;
1022                 }
1023                 sdata->default_key = NULL;
1024         }
1025         read_unlock(&local->sub_if_lock);
1026
1027         spin_lock_bh(&local->sta_lock);
1028         list_for_each_entry(sta, &local->sta_list, list) {
1029                 keyconf = NULL;
1030                 if (sta->key && !sta->key->force_sw_encrypt &&
1031                     local->ops->set_key &&
1032                     (keyconf = ieee80211_key_data2conf(local, sta->key)))
1033                         local->ops->set_key(local_to_hw(local), DISABLE_KEY,
1034                                            sta->addr, keyconf, sta->aid);
1035                 kfree(keyconf);
1036                 ieee80211_key_free(sta->key);
1037                 sta->key = NULL;
1038         }
1039         spin_unlock_bh(&local->sta_lock);
1040
1041         memset(&key, 0, sizeof(key));
1042         if (local->ops->set_key &&
1043                     local->ops->set_key(local_to_hw(local), REMOVE_ALL_KEYS,
1044                                        NULL, &key, 0))
1045                 printk(KERN_DEBUG "%s: failed to remove hwaccel keys\n",
1046                        dev->name);
1047
1048         return 0;
1049 }
1050
1051
1052 static int
1053 ieee80211_ioctl_force_unicast_rate(struct net_device *dev,
1054                                    struct ieee80211_sub_if_data *sdata,
1055                                    int rate)
1056 {
1057         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1058         struct ieee80211_hw_mode *mode;
1059         int i;
1060
1061         if (sdata->type != IEEE80211_IF_TYPE_AP)
1062                 return -ENOENT;
1063
1064         if (rate == 0) {
1065                 sdata->u.ap.force_unicast_rateidx = -1;
1066                 return 0;
1067         }
1068
1069         mode = local->oper_hw_mode;
1070         for (i = 0; i < mode->num_rates; i++) {
1071                 if (mode->rates[i].rate == rate) {
1072                         sdata->u.ap.force_unicast_rateidx = i;
1073                         return 0;
1074                 }
1075         }
1076         return -EINVAL;
1077 }
1078
1079
1080 static int
1081 ieee80211_ioctl_max_ratectrl_rate(struct net_device *dev,
1082                                   struct ieee80211_sub_if_data *sdata,
1083                                   int rate)
1084 {
1085         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1086         struct ieee80211_hw_mode *mode;
1087         int i;
1088
1089         if (sdata->type != IEEE80211_IF_TYPE_AP)
1090                 return -ENOENT;
1091
1092         if (rate == 0) {
1093                 sdata->u.ap.max_ratectrl_rateidx = -1;
1094                 return 0;
1095         }
1096
1097         mode = local->oper_hw_mode;
1098         for (i = 0; i < mode->num_rates; i++) {
1099                 if (mode->rates[i].rate == rate) {
1100                         sdata->u.ap.max_ratectrl_rateidx = i;
1101                         return 0;
1102                 }
1103         }
1104         return -EINVAL;
1105 }
1106
1107
1108 static void ieee80211_key_enable_hwaccel(struct ieee80211_local *local,
1109                                          struct ieee80211_key *key)
1110 {
1111         struct ieee80211_key_conf *keyconf;
1112         u8 addr[ETH_ALEN];
1113
1114         if (!key || key->alg != ALG_WEP || !key->force_sw_encrypt ||
1115             (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
1116                 return;
1117
1118         memset(addr, 0xff, ETH_ALEN);
1119         keyconf = ieee80211_key_data2conf(local, key);
1120         if (keyconf && local->ops->set_key &&
1121             local->ops->set_key(local_to_hw(local),
1122                                SET_KEY, addr, keyconf, 0) == 0) {
1123                 key->force_sw_encrypt =
1124                         !!(keyconf->flags & IEEE80211_KEY_FORCE_SW_ENCRYPT);
1125                 key->hw_key_idx = keyconf->hw_key_idx;
1126         }
1127         kfree(keyconf);
1128 }
1129
1130
1131 static void ieee80211_key_disable_hwaccel(struct ieee80211_local *local,
1132                                           struct ieee80211_key *key)
1133 {
1134         struct ieee80211_key_conf *keyconf;
1135         u8 addr[ETH_ALEN];
1136
1137         if (!key || key->alg != ALG_WEP || key->force_sw_encrypt ||
1138             (local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP))
1139                 return;
1140
1141         memset(addr, 0xff, ETH_ALEN);
1142         keyconf = ieee80211_key_data2conf(local, key);
1143         if (keyconf && local->ops->set_key)
1144                 local->ops->set_key(local_to_hw(local), DISABLE_KEY,
1145                                    addr, keyconf, 0);
1146         kfree(keyconf);
1147         key->force_sw_encrypt = 1;
1148 }
1149
1150
1151 static int ieee80211_ioctl_default_wep_only(struct ieee80211_local *local,
1152                                             int value)
1153 {
1154         int i;
1155         struct ieee80211_sub_if_data *sdata;
1156
1157         local->default_wep_only = value;
1158         read_lock(&local->sub_if_lock);
1159         list_for_each_entry(sdata, &local->sub_if_list, list)
1160                 for (i = 0; i < NUM_DEFAULT_KEYS; i++)
1161                         if (value)
1162                                 ieee80211_key_enable_hwaccel(local,
1163                                                              sdata->keys[i]);
1164                         else
1165                                 ieee80211_key_disable_hwaccel(local,
1166                                                               sdata->keys[i]);
1167         read_unlock(&local->sub_if_lock);
1168
1169         return 0;
1170 }
1171
1172
1173 void ieee80211_update_default_wep_only(struct ieee80211_local *local)
1174 {
1175         int i = 0;
1176         struct ieee80211_sub_if_data *sdata;
1177
1178         read_lock(&local->sub_if_lock);
1179         list_for_each_entry(sdata, &local->sub_if_list, list) {
1180
1181                 if (sdata->dev == local->mdev)
1182                         continue;
1183
1184                 /* If there is an AP interface then depend on userspace to
1185                    set default_wep_only correctly. */
1186                 if (sdata->type == IEEE80211_IF_TYPE_AP) {
1187                         read_unlock(&local->sub_if_lock);
1188                         return;
1189                 }
1190
1191                 i++;
1192         }
1193
1194         read_unlock(&local->sub_if_lock);
1195
1196         if (i <= 1)
1197                 ieee80211_ioctl_default_wep_only(local, 1);
1198         else
1199                 ieee80211_ioctl_default_wep_only(local, 0);
1200 }
1201
1202
1203 static int ieee80211_ioctl_prism2_param(struct net_device *dev,
1204                                         struct iw_request_info *info,
1205                                         void *wrqu, char *extra)
1206 {
1207         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1208         struct ieee80211_sub_if_data *sdata;
1209         int *i = (int *) extra;
1210         int param = *i;
1211         int value = *(i + 1);
1212         int ret = 0;
1213
1214         if (!capable(CAP_NET_ADMIN))
1215                 return -EPERM;
1216
1217         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1218
1219         switch (param) {
1220         case PRISM2_PARAM_IEEE_802_1X:
1221                 if (local->ops->set_ieee8021x)
1222                         ret = local->ops->set_ieee8021x(local_to_hw(local),
1223                                                         value);
1224                 if (ret)
1225                         printk(KERN_DEBUG "%s: failed to set IEEE 802.1X (%d) "
1226                                "for low-level driver\n", dev->name, value);
1227                 else
1228                         sdata->ieee802_1x = value;
1229                 break;
1230
1231         case PRISM2_PARAM_ANTSEL_TX:
1232                 local->hw.conf.antenna_sel_tx = value;
1233                 if (ieee80211_hw_config(local))
1234                         ret = -EINVAL;
1235                 break;
1236
1237         case PRISM2_PARAM_ANTSEL_RX:
1238                 local->hw.conf.antenna_sel_rx = value;
1239                 if (ieee80211_hw_config(local))
1240                         ret = -EINVAL;
1241                 break;
1242
1243         case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
1244                 local->cts_protect_erp_frames = value;
1245                 break;
1246
1247         case PRISM2_PARAM_DROP_UNENCRYPTED:
1248                 sdata->drop_unencrypted = value;
1249                 break;
1250
1251         case PRISM2_PARAM_PREAMBLE:
1252                 local->short_preamble = value;
1253                 break;
1254
1255         case PRISM2_PARAM_STAT_TIME:
1256                 if (!local->stat_time && value) {
1257                         local->stat_timer.expires = jiffies + HZ * value / 100;
1258                         add_timer(&local->stat_timer);
1259                 } else if (local->stat_time && !value) {
1260                         del_timer_sync(&local->stat_timer);
1261                 }
1262                 local->stat_time = value;
1263                 break;
1264         case PRISM2_PARAM_SHORT_SLOT_TIME:
1265                 if (value)
1266                         local->hw.conf.flags |= IEEE80211_CONF_SHORT_SLOT_TIME;
1267                 else
1268                         local->hw.conf.flags &= ~IEEE80211_CONF_SHORT_SLOT_TIME;
1269                 if (ieee80211_hw_config(local))
1270                         ret = -EINVAL;
1271                 break;
1272
1273         case PRISM2_PARAM_NEXT_MODE:
1274                 local->next_mode = value;
1275                 break;
1276
1277         case PRISM2_PARAM_CLEAR_KEYS:
1278                 ret = ieee80211_ioctl_clear_keys(dev);
1279                 break;
1280
1281         case PRISM2_PARAM_RADIO_ENABLED:
1282                 ret = ieee80211_ioctl_set_radio_enabled(dev, value);
1283                 break;
1284
1285         case PRISM2_PARAM_ANTENNA_MODE:
1286                 local->hw.conf.antenna_mode = value;
1287                 if (ieee80211_hw_config(local))
1288                         ret = -EINVAL;
1289                 break;
1290
1291         case PRISM2_PARAM_STA_ANTENNA_SEL:
1292                 local->sta_antenna_sel = value;
1293                 break;
1294
1295         case PRISM2_PARAM_FORCE_UNICAST_RATE:
1296                 ret = ieee80211_ioctl_force_unicast_rate(dev, sdata, value);
1297                 break;
1298
1299         case PRISM2_PARAM_MAX_RATECTRL_RATE:
1300                 ret = ieee80211_ioctl_max_ratectrl_rate(dev, sdata, value);
1301                 break;
1302
1303         case PRISM2_PARAM_RATE_CTRL_NUM_UP:
1304                 local->rate_ctrl_num_up = value;
1305                 break;
1306
1307         case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
1308                 local->rate_ctrl_num_down = value;
1309                 break;
1310
1311         case PRISM2_PARAM_TX_POWER_REDUCTION:
1312                 if (value < 0)
1313                         ret = -EINVAL;
1314                 else
1315                         local->hw.conf.tx_power_reduction = value;
1316                 break;
1317
1318         case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
1319                 local->key_tx_rx_threshold = value;
1320                 break;
1321
1322         case PRISM2_PARAM_DEFAULT_WEP_ONLY:
1323                 ret = ieee80211_ioctl_default_wep_only(local, value);
1324                 break;
1325
1326         case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
1327                 local->wifi_wme_noack_test = value;
1328                 break;
1329
1330         case PRISM2_PARAM_SCAN_FLAGS:
1331                 local->scan_flags = value;
1332                 break;
1333
1334         case PRISM2_PARAM_MIXED_CELL:
1335                 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1336                     sdata->type != IEEE80211_IF_TYPE_IBSS)
1337                         ret = -EINVAL;
1338                 else
1339                         sdata->u.sta.mixed_cell = !!value;
1340                 break;
1341
1342         case PRISM2_PARAM_HW_MODES:
1343                 local->enabled_modes = value;
1344                 break;
1345
1346         case PRISM2_PARAM_CREATE_IBSS:
1347                 if (sdata->type != IEEE80211_IF_TYPE_IBSS)
1348                         ret = -EINVAL;
1349                 else
1350                         sdata->u.sta.create_ibss = !!value;
1351                 break;
1352         case PRISM2_PARAM_WMM_ENABLED:
1353                 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1354                     sdata->type != IEEE80211_IF_TYPE_IBSS)
1355                         ret = -EINVAL;
1356                 else
1357                         sdata->u.sta.wmm_enabled = !!value;
1358                 break;
1359         case PRISM2_PARAM_RADAR_DETECT:
1360                 local->hw.conf.radar_detect = value;
1361                 break;
1362         case PRISM2_PARAM_SPECTRUM_MGMT:
1363                 local->hw.conf.spect_mgmt = value;
1364                 break;
1365         default:
1366                 ret = -EOPNOTSUPP;
1367                 break;
1368         }
1369
1370         return ret;
1371 }
1372
1373
1374 static int ieee80211_ioctl_get_prism2_param(struct net_device *dev,
1375                                             struct iw_request_info *info,
1376                                             void *wrqu, char *extra)
1377 {
1378         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1379         struct ieee80211_sub_if_data *sdata;
1380         int *param = (int *) extra;
1381         int ret = 0;
1382
1383         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1384
1385         switch (*param) {
1386         case PRISM2_PARAM_IEEE_802_1X:
1387                 *param = sdata->ieee802_1x;
1388                 break;
1389
1390         case PRISM2_PARAM_ANTSEL_TX:
1391                 *param = local->hw.conf.antenna_sel_tx;
1392                 break;
1393
1394         case PRISM2_PARAM_ANTSEL_RX:
1395                 *param = local->hw.conf.antenna_sel_rx;
1396                 break;
1397
1398         case PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES:
1399                 *param = local->cts_protect_erp_frames;
1400                 break;
1401
1402         case PRISM2_PARAM_DROP_UNENCRYPTED:
1403                 *param = sdata->drop_unencrypted;
1404                 break;
1405
1406         case PRISM2_PARAM_PREAMBLE:
1407                 *param = local->short_preamble;
1408                 break;
1409
1410         case PRISM2_PARAM_STAT_TIME:
1411                 *param = local->stat_time;
1412                 break;
1413         case PRISM2_PARAM_SHORT_SLOT_TIME:
1414                 *param = !!(local->hw.conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME);
1415                 break;
1416
1417         case PRISM2_PARAM_NEXT_MODE:
1418                 *param = local->next_mode;
1419                 break;
1420
1421         case PRISM2_PARAM_ANTENNA_MODE:
1422                 *param = local->hw.conf.antenna_mode;
1423                 break;
1424
1425         case PRISM2_PARAM_STA_ANTENNA_SEL:
1426                 *param = local->sta_antenna_sel;
1427                 break;
1428
1429         case PRISM2_PARAM_RATE_CTRL_NUM_UP:
1430                 *param = local->rate_ctrl_num_up;
1431                 break;
1432
1433         case PRISM2_PARAM_RATE_CTRL_NUM_DOWN:
1434                 *param = local->rate_ctrl_num_down;
1435                 break;
1436
1437         case PRISM2_PARAM_TX_POWER_REDUCTION:
1438                 *param = local->hw.conf.tx_power_reduction;
1439                 break;
1440
1441         case PRISM2_PARAM_KEY_TX_RX_THRESHOLD:
1442                 *param = local->key_tx_rx_threshold;
1443                 break;
1444
1445         case PRISM2_PARAM_DEFAULT_WEP_ONLY:
1446                 *param = local->default_wep_only;
1447                 break;
1448
1449         case PRISM2_PARAM_WIFI_WME_NOACK_TEST:
1450                 *param = local->wifi_wme_noack_test;
1451                 break;
1452
1453         case PRISM2_PARAM_SCAN_FLAGS:
1454                 *param = local->scan_flags;
1455                 break;
1456
1457         case PRISM2_PARAM_HW_MODES:
1458                 *param = local->enabled_modes;
1459                 break;
1460
1461         case PRISM2_PARAM_CREATE_IBSS:
1462                 if (sdata->type != IEEE80211_IF_TYPE_IBSS)
1463                         ret = -EINVAL;
1464                 else
1465                         *param = !!sdata->u.sta.create_ibss;
1466                 break;
1467
1468         case PRISM2_PARAM_MIXED_CELL:
1469                 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1470                     sdata->type != IEEE80211_IF_TYPE_IBSS)
1471                         ret = -EINVAL;
1472                 else
1473                         *param = !!sdata->u.sta.mixed_cell;
1474                 break;
1475         case PRISM2_PARAM_WMM_ENABLED:
1476                 if (sdata->type != IEEE80211_IF_TYPE_STA &&
1477                     sdata->type != IEEE80211_IF_TYPE_IBSS)
1478                         ret = -EINVAL;
1479                 else
1480                         *param = !!sdata->u.sta.wmm_enabled;
1481                 break;
1482         default:
1483                 ret = -EOPNOTSUPP;
1484                 break;
1485         }
1486
1487         return ret;
1488 }
1489
1490 static int ieee80211_ioctl_siwmlme(struct net_device *dev,
1491                                    struct iw_request_info *info,
1492                                    struct iw_point *data, char *extra)
1493 {
1494         struct ieee80211_sub_if_data *sdata;
1495         struct iw_mlme *mlme = (struct iw_mlme *) extra;
1496
1497         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1498         if (sdata->type != IEEE80211_IF_TYPE_STA &&
1499             sdata->type != IEEE80211_IF_TYPE_IBSS)
1500                 return -EINVAL;
1501
1502         switch (mlme->cmd) {
1503         case IW_MLME_DEAUTH:
1504                 /* TODO: mlme->addr.sa_data */
1505                 return ieee80211_sta_deauthenticate(dev, mlme->reason_code);
1506         case IW_MLME_DISASSOC:
1507                 /* TODO: mlme->addr.sa_data */
1508                 return ieee80211_sta_disassociate(dev, mlme->reason_code);
1509         default:
1510                 return -EOPNOTSUPP;
1511         }
1512 }
1513
1514
1515 static int ieee80211_ioctl_siwencode(struct net_device *dev,
1516                                      struct iw_request_info *info,
1517                                      struct iw_point *erq, char *keybuf)
1518 {
1519         struct ieee80211_sub_if_data *sdata;
1520         int idx, i, alg = ALG_WEP;
1521         u8 bcaddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1522
1523         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1524
1525         idx = erq->flags & IW_ENCODE_INDEX;
1526         if (idx == 0) {
1527                 if (sdata->default_key)
1528                         for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1529                                 if (sdata->default_key == sdata->keys[i]) {
1530                                         idx = i;
1531                                         break;
1532                                 }
1533                         }
1534         } else if (idx < 1 || idx > 4)
1535                 return -EINVAL;
1536         else
1537                 idx--;
1538
1539         if (erq->flags & IW_ENCODE_DISABLED)
1540                 alg = ALG_NONE;
1541         else if (erq->length == 0) {
1542                 /* No key data - just set the default TX key index */
1543                 if (sdata->default_key != sdata->keys[idx]) {
1544                         ieee80211_debugfs_key_remove_default(sdata);
1545                         sdata->default_key = sdata->keys[idx];
1546                         if (sdata->default_key)
1547                                 ieee80211_debugfs_key_add_default(sdata);
1548                 }
1549                 return 0;
1550         }
1551
1552         return ieee80211_set_encryption(
1553                 dev, bcaddr,
1554                 idx, alg,
1555                 !sdata->default_key,
1556                 keybuf, erq->length);
1557 }
1558
1559
1560 static int ieee80211_ioctl_giwencode(struct net_device *dev,
1561                                      struct iw_request_info *info,
1562                                      struct iw_point *erq, char *key)
1563 {
1564         struct ieee80211_sub_if_data *sdata;
1565         int idx, i;
1566
1567         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1568
1569         idx = erq->flags & IW_ENCODE_INDEX;
1570         if (idx < 1 || idx > 4) {
1571                 idx = -1;
1572                 if (!sdata->default_key)
1573                         idx = 0;
1574                 else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1575                         if (sdata->default_key == sdata->keys[i]) {
1576                                 idx = i;
1577                                 break;
1578                         }
1579                 }
1580                 if (idx < 0)
1581                         return -EINVAL;
1582         } else
1583                 idx--;
1584
1585         erq->flags = idx + 1;
1586
1587         if (!sdata->keys[idx]) {
1588                 erq->length = 0;
1589                 erq->flags |= IW_ENCODE_DISABLED;
1590                 return 0;
1591         }
1592
1593         memcpy(key, sdata->keys[idx]->key,
1594                min((int)erq->length, sdata->keys[idx]->keylen));
1595         erq->length = sdata->keys[idx]->keylen;
1596         erq->flags |= IW_ENCODE_ENABLED;
1597
1598         return 0;
1599 }
1600
1601 static int ieee80211_ioctl_siwauth(struct net_device *dev,
1602                                    struct iw_request_info *info,
1603                                    struct iw_param *data, char *extra)
1604 {
1605         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1606         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1607         int ret = 0;
1608
1609         switch (data->flags & IW_AUTH_INDEX) {
1610         case IW_AUTH_WPA_VERSION:
1611         case IW_AUTH_CIPHER_PAIRWISE:
1612         case IW_AUTH_CIPHER_GROUP:
1613         case IW_AUTH_WPA_ENABLED:
1614         case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1615                 break;
1616         case IW_AUTH_KEY_MGMT:
1617                 if (sdata->type != IEEE80211_IF_TYPE_STA)
1618                         ret = -EINVAL;
1619                 else {
1620                         /*
1621                          * TODO: sdata->u.sta.key_mgmt does not match with WE18
1622                          * value completely; could consider modifying this to
1623                          * be closer to WE18. For now, this value is not really
1624                          * used for anything else than Privacy matching, so the
1625                          * current code here should be more or less OK.
1626                          */
1627                         if (data->value & IW_AUTH_KEY_MGMT_802_1X) {
1628                                 sdata->u.sta.key_mgmt =
1629                                         IEEE80211_KEY_MGMT_WPA_EAP;
1630                         } else if (data->value & IW_AUTH_KEY_MGMT_PSK) {
1631                                 sdata->u.sta.key_mgmt =
1632                                         IEEE80211_KEY_MGMT_WPA_PSK;
1633                         } else {
1634                                 sdata->u.sta.key_mgmt =
1635                                         IEEE80211_KEY_MGMT_NONE;
1636                         }
1637                 }
1638                 break;
1639         case IW_AUTH_80211_AUTH_ALG:
1640                 if (sdata->type == IEEE80211_IF_TYPE_STA ||
1641                     sdata->type == IEEE80211_IF_TYPE_IBSS)
1642                         sdata->u.sta.auth_algs = data->value;
1643                 else
1644                         ret = -EOPNOTSUPP;
1645                 break;
1646         case IW_AUTH_PRIVACY_INVOKED:
1647                 if (local->ops->set_privacy_invoked)
1648                         ret = local->ops->set_privacy_invoked(
1649                                         local_to_hw(local), data->value);
1650                 break;
1651         default:
1652                 ret = -EOPNOTSUPP;
1653                 break;
1654         }
1655         return ret;
1656 }
1657
1658 /* Get wireless statistics.  Called by /proc/net/wireless and by SIOCGIWSTATS */
1659 static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev)
1660 {
1661         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1662         struct iw_statistics *wstats = &local->wstats;
1663         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1664         struct sta_info *sta = NULL;
1665
1666         if (sdata->type == IEEE80211_IF_TYPE_STA ||
1667             sdata->type == IEEE80211_IF_TYPE_IBSS)
1668                 sta = sta_info_get(local, sdata->u.sta.bssid);
1669         if (!sta) {
1670                 wstats->discard.fragment = 0;
1671                 wstats->discard.misc = 0;
1672                 wstats->qual.qual = 0;
1673                 wstats->qual.level = 0;
1674                 wstats->qual.noise = 0;
1675                 wstats->qual.updated = IW_QUAL_ALL_INVALID;
1676         } else {
1677                 wstats->qual.level = sta->last_rssi;
1678                 wstats->qual.qual = sta->last_signal;
1679                 wstats->qual.noise = sta->last_noise;
1680                 wstats->qual.updated = local->wstats_flags;
1681                 sta_info_put(sta);
1682         }
1683         return wstats;
1684 }
1685
1686 static int ieee80211_ioctl_giwauth(struct net_device *dev,
1687                                    struct iw_request_info *info,
1688                                    struct iw_param *data, char *extra)
1689 {
1690         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1691         int ret = 0;
1692
1693         switch (data->flags & IW_AUTH_INDEX) {
1694         case IW_AUTH_80211_AUTH_ALG:
1695                 if (sdata->type == IEEE80211_IF_TYPE_STA ||
1696                     sdata->type == IEEE80211_IF_TYPE_IBSS)
1697                         data->value = sdata->u.sta.auth_algs;
1698                 else
1699                         ret = -EOPNOTSUPP;
1700                 break;
1701         default:
1702                 ret = -EOPNOTSUPP;
1703                 break;
1704         }
1705         return ret;
1706 }
1707
1708
1709 static int ieee80211_ioctl_siwencodeext(struct net_device *dev,
1710                                         struct iw_request_info *info,
1711                                         struct iw_point *erq, char *extra)
1712 {
1713         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1714         struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
1715         int alg, idx, i;
1716
1717         switch (ext->alg) {
1718         case IW_ENCODE_ALG_NONE:
1719                 alg = ALG_NONE;
1720                 break;
1721         case IW_ENCODE_ALG_WEP:
1722                 alg = ALG_WEP;
1723                 break;
1724         case IW_ENCODE_ALG_TKIP:
1725                 alg = ALG_TKIP;
1726                 break;
1727         case IW_ENCODE_ALG_CCMP:
1728                 alg = ALG_CCMP;
1729                 break;
1730         default:
1731                 return -EOPNOTSUPP;
1732         }
1733
1734         if (erq->flags & IW_ENCODE_DISABLED)
1735                 alg = ALG_NONE;
1736
1737         idx = erq->flags & IW_ENCODE_INDEX;
1738         if (idx < 1 || idx > 4) {
1739                 idx = -1;
1740                 if (!sdata->default_key)
1741                         idx = 0;
1742                 else for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1743                         if (sdata->default_key == sdata->keys[i]) {
1744                                 idx = i;
1745                                 break;
1746                         }
1747                 }
1748                 if (idx < 0)
1749                         return -EINVAL;
1750         } else
1751                 idx--;
1752
1753         return ieee80211_set_encryption(dev, ext->addr.sa_data, idx, alg,
1754                                         ext->ext_flags &
1755                                         IW_ENCODE_EXT_SET_TX_KEY,
1756                                         ext->key, ext->key_len);
1757 }
1758
1759
1760 static const struct iw_priv_args ieee80211_ioctl_priv[] = {
1761         { PRISM2_IOCTL_PRISM2_PARAM,
1762           IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "param" },
1763         { PRISM2_IOCTL_GET_PRISM2_PARAM,
1764           IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1765           IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_param" },
1766 };
1767
1768 /* Structures to export the Wireless Handlers */
1769
1770 static const iw_handler ieee80211_handler[] =
1771 {
1772         (iw_handler) NULL,                              /* SIOCSIWCOMMIT */
1773         (iw_handler) ieee80211_ioctl_giwname,           /* SIOCGIWNAME */
1774         (iw_handler) NULL,                              /* SIOCSIWNWID */
1775         (iw_handler) NULL,                              /* SIOCGIWNWID */
1776         (iw_handler) ieee80211_ioctl_siwfreq,           /* SIOCSIWFREQ */
1777         (iw_handler) ieee80211_ioctl_giwfreq,           /* SIOCGIWFREQ */
1778         (iw_handler) ieee80211_ioctl_siwmode,           /* SIOCSIWMODE */
1779         (iw_handler) ieee80211_ioctl_giwmode,           /* SIOCGIWMODE */
1780         (iw_handler) NULL,                              /* SIOCSIWSENS */
1781         (iw_handler) NULL,                              /* SIOCGIWSENS */
1782         (iw_handler) NULL /* not used */,               /* SIOCSIWRANGE */
1783         (iw_handler) ieee80211_ioctl_giwrange,          /* SIOCGIWRANGE */
1784         (iw_handler) NULL /* not used */,               /* SIOCSIWPRIV */
1785         (iw_handler) NULL /* kernel code */,            /* SIOCGIWPRIV */
1786         (iw_handler) NULL /* not used */,               /* SIOCSIWSTATS */
1787         (iw_handler) NULL /* kernel code */,            /* SIOCGIWSTATS */
1788         iw_handler_set_spy,                             /* SIOCSIWSPY */
1789         iw_handler_get_spy,                             /* SIOCGIWSPY */
1790         iw_handler_set_thrspy,                          /* SIOCSIWTHRSPY */
1791         iw_handler_get_thrspy,                          /* SIOCGIWTHRSPY */
1792         (iw_handler) ieee80211_ioctl_siwap,             /* SIOCSIWAP */
1793         (iw_handler) ieee80211_ioctl_giwap,             /* SIOCGIWAP */
1794         (iw_handler) ieee80211_ioctl_siwmlme,           /* SIOCSIWMLME */
1795         (iw_handler) NULL,                              /* SIOCGIWAPLIST */
1796         (iw_handler) ieee80211_ioctl_siwscan,           /* SIOCSIWSCAN */
1797         (iw_handler) ieee80211_ioctl_giwscan,           /* SIOCGIWSCAN */
1798         (iw_handler) ieee80211_ioctl_siwessid,          /* SIOCSIWESSID */
1799         (iw_handler) ieee80211_ioctl_giwessid,          /* SIOCGIWESSID */
1800         (iw_handler) NULL,                              /* SIOCSIWNICKN */
1801         (iw_handler) NULL,                              /* SIOCGIWNICKN */
1802         (iw_handler) NULL,                              /* -- hole -- */
1803         (iw_handler) NULL,                              /* -- hole -- */
1804         (iw_handler) NULL,                              /* SIOCSIWRATE */
1805         (iw_handler) ieee80211_ioctl_giwrate,           /* SIOCGIWRATE */
1806         (iw_handler) ieee80211_ioctl_siwrts,            /* SIOCSIWRTS */
1807         (iw_handler) ieee80211_ioctl_giwrts,            /* SIOCGIWRTS */
1808         (iw_handler) ieee80211_ioctl_siwfrag,           /* SIOCSIWFRAG */
1809         (iw_handler) ieee80211_ioctl_giwfrag,           /* SIOCGIWFRAG */
1810         (iw_handler) NULL,                              /* SIOCSIWTXPOW */
1811         (iw_handler) NULL,                              /* SIOCGIWTXPOW */
1812         (iw_handler) ieee80211_ioctl_siwretry,          /* SIOCSIWRETRY */
1813         (iw_handler) ieee80211_ioctl_giwretry,          /* SIOCGIWRETRY */
1814         (iw_handler) ieee80211_ioctl_siwencode,         /* SIOCSIWENCODE */
1815         (iw_handler) ieee80211_ioctl_giwencode,         /* SIOCGIWENCODE */
1816         (iw_handler) NULL,                              /* SIOCSIWPOWER */
1817         (iw_handler) NULL,                              /* SIOCGIWPOWER */
1818         (iw_handler) NULL,                              /* -- hole -- */
1819         (iw_handler) NULL,                              /* -- hole -- */
1820         (iw_handler) ieee80211_ioctl_siwgenie,          /* SIOCSIWGENIE */
1821         (iw_handler) NULL,                              /* SIOCGIWGENIE */
1822         (iw_handler) ieee80211_ioctl_siwauth,           /* SIOCSIWAUTH */
1823         (iw_handler) ieee80211_ioctl_giwauth,           /* SIOCGIWAUTH */
1824         (iw_handler) ieee80211_ioctl_siwencodeext,      /* SIOCSIWENCODEEXT */
1825         (iw_handler) NULL,                              /* SIOCGIWENCODEEXT */
1826         (iw_handler) NULL,                              /* SIOCSIWPMKSA */
1827         (iw_handler) NULL,                              /* -- hole -- */
1828 };
1829
1830 static const iw_handler ieee80211_private_handler[] =
1831 {                                                       /* SIOCIWFIRSTPRIV + */
1832         (iw_handler) ieee80211_ioctl_prism2_param,      /* 0 */
1833         (iw_handler) ieee80211_ioctl_get_prism2_param,  /* 1 */
1834 };
1835
1836 const struct iw_handler_def ieee80211_iw_handler_def =
1837 {
1838         .num_standard   = ARRAY_SIZE(ieee80211_handler),
1839         .num_private    = ARRAY_SIZE(ieee80211_private_handler),
1840         .num_private_args = ARRAY_SIZE(ieee80211_ioctl_priv),
1841         .standard       = (iw_handler *) ieee80211_handler,
1842         .private        = (iw_handler *) ieee80211_private_handler,
1843         .private_args   = (struct iw_priv_args *) ieee80211_ioctl_priv,
1844         .get_wireless_stats = ieee80211_get_wireless_stats,
1845 };