1 // SPDX-License-Identifier: GPL-2.0
3 * cfg80211 - wext compat code
5 * This is temporary code until all wireless functionality is migrated
6 * into cfg80211, when that happens all the exports here go away and
7 * we directly assign the wireless handlers of wireless interfaces.
9 * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
10 * Copyright (C) 2019-2022 Intel Corporation
13 #include <linux/export.h>
14 #include <linux/wireless.h>
15 #include <linux/nl80211.h>
16 #include <linux/if_arp.h>
17 #include <linux/etherdevice.h>
18 #include <linux/slab.h>
19 #include <net/iw_handler.h>
20 #include <net/cfg80211.h>
21 #include <net/cfg80211-wext.h>
22 #include "wext-compat.h"
26 int cfg80211_wext_giwname(struct net_device *dev,
27 struct iw_request_info *info,
28 char *name, char *extra)
30 strcpy(name, "IEEE 802.11");
33 EXPORT_WEXT_HANDLER(cfg80211_wext_giwname);
35 int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
36 u32 *mode, char *extra)
38 struct wireless_dev *wdev = dev->ieee80211_ptr;
39 struct cfg80211_registered_device *rdev;
40 struct vif_params vifparams;
41 enum nl80211_iftype type;
44 rdev = wiphy_to_rdev(wdev->wiphy);
48 type = NL80211_IFTYPE_STATION;
51 type = NL80211_IFTYPE_ADHOC;
54 type = NL80211_IFTYPE_MONITOR;
60 if (type == wdev->iftype)
63 memset(&vifparams, 0, sizeof(vifparams));
65 wiphy_lock(wdev->wiphy);
66 ret = cfg80211_change_iface(rdev, dev, type, &vifparams);
67 wiphy_unlock(wdev->wiphy);
71 EXPORT_WEXT_HANDLER(cfg80211_wext_siwmode);
73 int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
74 u32 *mode, char *extra)
76 struct wireless_dev *wdev = dev->ieee80211_ptr;
81 switch (wdev->iftype) {
82 case NL80211_IFTYPE_AP:
83 *mode = IW_MODE_MASTER;
85 case NL80211_IFTYPE_STATION:
86 *mode = IW_MODE_INFRA;
88 case NL80211_IFTYPE_ADHOC:
89 *mode = IW_MODE_ADHOC;
91 case NL80211_IFTYPE_MONITOR:
92 *mode = IW_MODE_MONITOR;
94 case NL80211_IFTYPE_WDS:
95 *mode = IW_MODE_REPEAT;
97 case NL80211_IFTYPE_AP_VLAN:
98 *mode = IW_MODE_SECOND; /* FIXME */
101 *mode = IW_MODE_AUTO;
106 EXPORT_WEXT_HANDLER(cfg80211_wext_giwmode);
109 int cfg80211_wext_giwrange(struct net_device *dev,
110 struct iw_request_info *info,
111 struct iw_point *data, char *extra)
113 struct wireless_dev *wdev = dev->ieee80211_ptr;
114 struct iw_range *range = (struct iw_range *) extra;
115 enum nl80211_band band;
121 data->length = sizeof(struct iw_range);
122 memset(range, 0, sizeof(struct iw_range));
124 range->we_version_compiled = WIRELESS_EXT;
125 range->we_version_source = 21;
126 range->retry_capa = IW_RETRY_LIMIT;
127 range->retry_flags = IW_RETRY_LIMIT;
128 range->min_retry = 0;
129 range->max_retry = 255;
131 range->max_rts = 2347;
132 range->min_frag = 256;
133 range->max_frag = 2346;
135 range->max_encoding_tokens = 4;
137 range->max_qual.updated = IW_QUAL_NOISE_INVALID;
139 switch (wdev->wiphy->signal_type) {
140 case CFG80211_SIGNAL_TYPE_NONE:
142 case CFG80211_SIGNAL_TYPE_MBM:
143 range->max_qual.level = (u8)-110;
144 range->max_qual.qual = 70;
145 range->avg_qual.qual = 35;
146 range->max_qual.updated |= IW_QUAL_DBM;
147 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
148 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
150 case CFG80211_SIGNAL_TYPE_UNSPEC:
151 range->max_qual.level = 100;
152 range->max_qual.qual = 100;
153 range->avg_qual.qual = 50;
154 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
155 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
159 range->avg_qual.level = range->max_qual.level / 2;
160 range->avg_qual.noise = range->max_qual.noise / 2;
161 range->avg_qual.updated = range->max_qual.updated;
163 for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) {
164 switch (wdev->wiphy->cipher_suites[i]) {
165 case WLAN_CIPHER_SUITE_TKIP:
166 range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP |
170 case WLAN_CIPHER_SUITE_CCMP:
171 range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP |
175 case WLAN_CIPHER_SUITE_WEP40:
176 range->encoding_size[range->num_encoding_sizes++] =
180 case WLAN_CIPHER_SUITE_WEP104:
181 range->encoding_size[range->num_encoding_sizes++] =
187 for (band = 0; band < NUM_NL80211_BANDS; band ++) {
188 struct ieee80211_supported_band *sband;
190 sband = wdev->wiphy->bands[band];
195 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
196 struct ieee80211_channel *chan = &sband->channels[i];
198 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
200 ieee80211_frequency_to_channel(
202 range->freq[c].m = chan->center_freq;
203 range->freq[c].e = 6;
208 range->num_channels = c;
209 range->num_frequency = c;
211 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
212 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
213 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
215 if (wdev->wiphy->max_scan_ssids > 0)
216 range->scan_capa |= IW_SCAN_CAPA_ESSID;
220 EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange);
224 * cfg80211_wext_freq - get wext frequency for non-"auto"
225 * @freq: the wext freq encoding
227 * Returns a frequency, or a negative error code, or 0 for auto.
229 int cfg80211_wext_freq(struct iw_freq *freq)
232 * Parse frequency - return 0 for auto and
233 * -EINVAL for impossible things.
236 enum nl80211_band band = NL80211_BAND_2GHZ;
240 band = NL80211_BAND_5GHZ;
241 return ieee80211_channel_to_frequency(freq->m, band);
243 int i, div = 1000000;
244 for (i = 0; i < freq->e; i++)
248 return freq->m / div;
252 int cfg80211_wext_siwrts(struct net_device *dev,
253 struct iw_request_info *info,
254 struct iw_param *rts, char *extra)
256 struct wireless_dev *wdev = dev->ieee80211_ptr;
257 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
258 u32 orts = wdev->wiphy->rts_threshold;
261 wiphy_lock(&rdev->wiphy);
262 if (rts->disabled || !rts->fixed) {
263 wdev->wiphy->rts_threshold = (u32) -1;
264 } else if (rts->value < 0) {
268 wdev->wiphy->rts_threshold = rts->value;
271 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD);
274 wdev->wiphy->rts_threshold = orts;
277 wiphy_unlock(&rdev->wiphy);
280 EXPORT_WEXT_HANDLER(cfg80211_wext_siwrts);
282 int cfg80211_wext_giwrts(struct net_device *dev,
283 struct iw_request_info *info,
284 struct iw_param *rts, char *extra)
286 struct wireless_dev *wdev = dev->ieee80211_ptr;
288 rts->value = wdev->wiphy->rts_threshold;
289 rts->disabled = rts->value == (u32) -1;
294 EXPORT_WEXT_HANDLER(cfg80211_wext_giwrts);
296 int cfg80211_wext_siwfrag(struct net_device *dev,
297 struct iw_request_info *info,
298 struct iw_param *frag, char *extra)
300 struct wireless_dev *wdev = dev->ieee80211_ptr;
301 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
302 u32 ofrag = wdev->wiphy->frag_threshold;
305 wiphy_lock(&rdev->wiphy);
306 if (frag->disabled || !frag->fixed) {
307 wdev->wiphy->frag_threshold = (u32) -1;
308 } else if (frag->value < 256) {
312 /* Fragment length must be even, so strip LSB. */
313 wdev->wiphy->frag_threshold = frag->value & ~0x1;
316 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD);
318 wdev->wiphy->frag_threshold = ofrag;
320 wiphy_unlock(&rdev->wiphy);
324 EXPORT_WEXT_HANDLER(cfg80211_wext_siwfrag);
326 int cfg80211_wext_giwfrag(struct net_device *dev,
327 struct iw_request_info *info,
328 struct iw_param *frag, char *extra)
330 struct wireless_dev *wdev = dev->ieee80211_ptr;
332 frag->value = wdev->wiphy->frag_threshold;
333 frag->disabled = frag->value == (u32) -1;
338 EXPORT_WEXT_HANDLER(cfg80211_wext_giwfrag);
340 static int cfg80211_wext_siwretry(struct net_device *dev,
341 struct iw_request_info *info,
342 struct iw_param *retry, char *extra)
344 struct wireless_dev *wdev = dev->ieee80211_ptr;
345 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
347 u8 olong = wdev->wiphy->retry_long;
348 u8 oshort = wdev->wiphy->retry_short;
351 if (retry->disabled || retry->value < 1 || retry->value > 255 ||
352 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
355 wiphy_lock(&rdev->wiphy);
356 if (retry->flags & IW_RETRY_LONG) {
357 wdev->wiphy->retry_long = retry->value;
358 changed |= WIPHY_PARAM_RETRY_LONG;
359 } else if (retry->flags & IW_RETRY_SHORT) {
360 wdev->wiphy->retry_short = retry->value;
361 changed |= WIPHY_PARAM_RETRY_SHORT;
363 wdev->wiphy->retry_short = retry->value;
364 wdev->wiphy->retry_long = retry->value;
365 changed |= WIPHY_PARAM_RETRY_LONG;
366 changed |= WIPHY_PARAM_RETRY_SHORT;
369 err = rdev_set_wiphy_params(rdev, changed);
371 wdev->wiphy->retry_short = oshort;
372 wdev->wiphy->retry_long = olong;
374 wiphy_unlock(&rdev->wiphy);
379 int cfg80211_wext_giwretry(struct net_device *dev,
380 struct iw_request_info *info,
381 struct iw_param *retry, char *extra)
383 struct wireless_dev *wdev = dev->ieee80211_ptr;
387 if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) {
389 * First return short value, iwconfig will ask long value
392 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT;
393 retry->value = wdev->wiphy->retry_short;
394 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short)
395 retry->flags |= IW_RETRY_LONG;
400 if (retry->flags & IW_RETRY_LONG) {
401 retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
402 retry->value = wdev->wiphy->retry_long;
407 EXPORT_WEXT_HANDLER(cfg80211_wext_giwretry);
409 static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
410 struct net_device *dev, bool pairwise,
411 const u8 *addr, bool remove, bool tx_key,
412 int idx, struct key_params *params)
414 struct wireless_dev *wdev = dev->ieee80211_ptr;
418 if (wdev->valid_links)
421 if (pairwise && !addr)
425 * In many cases we won't actually need this, but it's better
426 * to do it first in case the allocation fails. Don't use wext.
428 if (!wdev->wext.keys) {
429 wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys),
431 if (!wdev->wext.keys)
433 for (i = 0; i < CFG80211_MAX_WEP_KEYS; i++)
434 wdev->wext.keys->params[i].key =
435 wdev->wext.keys->data[i];
438 if (wdev->iftype != NL80211_IFTYPE_ADHOC &&
439 wdev->iftype != NL80211_IFTYPE_STATION)
442 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
443 if (!wdev->connected)
446 if (!rdev->ops->set_default_mgmt_key)
449 if (idx < 4 || idx > 5)
451 } else if (idx < 0 || idx > 3)
456 if (wdev->connected ||
457 (wdev->iftype == NL80211_IFTYPE_ADHOC &&
458 wdev->u.ibss.current_bss)) {
460 * If removing the current TX key, we will need to
461 * join a new IBSS without the privacy bit clear.
463 if (idx == wdev->wext.default_key &&
464 wdev->iftype == NL80211_IFTYPE_ADHOC) {
465 __cfg80211_leave_ibss(rdev, wdev->netdev, true);
469 if (!pairwise && addr &&
470 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
473 err = rdev_del_key(rdev, dev, idx, pairwise,
476 wdev->wext.connect.privacy = false;
478 * Applications using wireless extensions expect to be
479 * able to delete keys that don't exist, so allow that.
484 if (!addr && idx < 4) {
485 memset(wdev->wext.keys->data[idx], 0,
486 sizeof(wdev->wext.keys->data[idx]));
487 wdev->wext.keys->params[idx].key_len = 0;
488 wdev->wext.keys->params[idx].cipher = 0;
490 if (idx == wdev->wext.default_key)
491 wdev->wext.default_key = -1;
492 else if (idx == wdev->wext.default_mgmt_key)
493 wdev->wext.default_mgmt_key = -1;
497 err = cfg80211_ibss_wext_join(rdev, wdev);
505 if (cfg80211_validate_key_settings(rdev, params, idx, pairwise, addr))
509 if (wdev->connected ||
510 (wdev->iftype == NL80211_IFTYPE_ADHOC &&
511 wdev->u.ibss.current_bss))
512 err = rdev_add_key(rdev, dev, idx, pairwise, addr, params);
513 else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
514 params->cipher != WLAN_CIPHER_SUITE_WEP104)
520 * We only need to store WEP keys, since they're the only keys that
521 * can be set before a connection is established and persist after
524 if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
525 params->cipher == WLAN_CIPHER_SUITE_WEP104)) {
526 wdev->wext.keys->params[idx] = *params;
527 memcpy(wdev->wext.keys->data[idx],
528 params->key, params->key_len);
529 wdev->wext.keys->params[idx].key =
530 wdev->wext.keys->data[idx];
533 if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
534 params->cipher == WLAN_CIPHER_SUITE_WEP104) &&
535 (tx_key || (!addr && wdev->wext.default_key == -1))) {
536 if (wdev->connected ||
537 (wdev->iftype == NL80211_IFTYPE_ADHOC &&
538 wdev->u.ibss.current_bss)) {
540 * If we are getting a new TX key from not having
541 * had one before we need to join a new IBSS with
542 * the privacy bit set.
544 if (wdev->iftype == NL80211_IFTYPE_ADHOC &&
545 wdev->wext.default_key == -1) {
546 __cfg80211_leave_ibss(rdev, wdev->netdev, true);
549 err = rdev_set_default_key(rdev, dev, idx, true, true);
552 wdev->wext.default_key = idx;
554 err = cfg80211_ibss_wext_join(rdev, wdev);
559 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
560 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
561 if (wdev->connected ||
562 (wdev->iftype == NL80211_IFTYPE_ADHOC &&
563 wdev->u.ibss.current_bss))
564 err = rdev_set_default_mgmt_key(rdev, dev, idx);
566 wdev->wext.default_mgmt_key = idx;
573 static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
574 struct net_device *dev, bool pairwise,
575 const u8 *addr, bool remove, bool tx_key,
576 int idx, struct key_params *params)
580 wdev_lock(dev->ieee80211_ptr);
581 err = __cfg80211_set_encryption(rdev, dev, pairwise, addr,
582 remove, tx_key, idx, params);
583 wdev_unlock(dev->ieee80211_ptr);
588 static int cfg80211_wext_siwencode(struct net_device *dev,
589 struct iw_request_info *info,
590 struct iw_point *erq, char *keybuf)
592 struct wireless_dev *wdev = dev->ieee80211_ptr;
593 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
596 struct key_params params;
598 if (wdev->iftype != NL80211_IFTYPE_STATION &&
599 wdev->iftype != NL80211_IFTYPE_ADHOC)
602 /* no use -- only MFP (set_default_mgmt_key) is optional */
603 if (!rdev->ops->del_key ||
604 !rdev->ops->add_key ||
605 !rdev->ops->set_default_key)
608 wiphy_lock(&rdev->wiphy);
609 if (wdev->valid_links) {
614 idx = erq->flags & IW_ENCODE_INDEX;
616 idx = wdev->wext.default_key;
619 } else if (idx < 1 || idx > 4) {
626 if (erq->flags & IW_ENCODE_DISABLED)
628 else if (erq->length == 0) {
629 /* No key data - just set the default TX key index */
632 if (wdev->connected ||
633 (wdev->iftype == NL80211_IFTYPE_ADHOC &&
634 wdev->u.ibss.current_bss))
635 err = rdev_set_default_key(rdev, dev, idx, true,
638 wdev->wext.default_key = idx;
643 memset(¶ms, 0, sizeof(params));
645 params.key_len = erq->length;
646 if (erq->length == 5) {
647 params.cipher = WLAN_CIPHER_SUITE_WEP40;
648 } else if (erq->length == 13) {
649 params.cipher = WLAN_CIPHER_SUITE_WEP104;
650 } else if (!remove) {
655 err = cfg80211_set_encryption(rdev, dev, false, NULL, remove,
656 wdev->wext.default_key == -1,
659 wiphy_unlock(&rdev->wiphy);
664 static int cfg80211_wext_siwencodeext(struct net_device *dev,
665 struct iw_request_info *info,
666 struct iw_point *erq, char *extra)
668 struct wireless_dev *wdev = dev->ieee80211_ptr;
669 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
670 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
674 struct key_params params;
678 if (wdev->iftype != NL80211_IFTYPE_STATION &&
679 wdev->iftype != NL80211_IFTYPE_ADHOC)
682 /* no use -- only MFP (set_default_mgmt_key) is optional */
683 if (!rdev->ops->del_key ||
684 !rdev->ops->add_key ||
685 !rdev->ops->set_default_key)
689 case IW_ENCODE_ALG_NONE:
693 case IW_ENCODE_ALG_WEP:
694 if (ext->key_len == 5)
695 cipher = WLAN_CIPHER_SUITE_WEP40;
696 else if (ext->key_len == 13)
697 cipher = WLAN_CIPHER_SUITE_WEP104;
701 case IW_ENCODE_ALG_TKIP:
702 cipher = WLAN_CIPHER_SUITE_TKIP;
704 case IW_ENCODE_ALG_CCMP:
705 cipher = WLAN_CIPHER_SUITE_CCMP;
707 case IW_ENCODE_ALG_AES_CMAC:
708 cipher = WLAN_CIPHER_SUITE_AES_CMAC;
714 if (erq->flags & IW_ENCODE_DISABLED)
717 idx = erq->flags & IW_ENCODE_INDEX;
718 if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
719 if (idx < 4 || idx > 5) {
720 idx = wdev->wext.default_mgmt_key;
726 if (idx < 1 || idx > 4) {
727 idx = wdev->wext.default_key;
734 addr = ext->addr.sa_data;
735 if (is_broadcast_ether_addr(addr))
738 memset(¶ms, 0, sizeof(params));
739 params.key = ext->key;
740 params.key_len = ext->key_len;
741 params.cipher = cipher;
743 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
744 params.seq = ext->rx_seq;
748 wiphy_lock(wdev->wiphy);
749 ret = cfg80211_set_encryption(
751 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY),
753 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
755 wiphy_unlock(wdev->wiphy);
760 static int cfg80211_wext_giwencode(struct net_device *dev,
761 struct iw_request_info *info,
762 struct iw_point *erq, char *keybuf)
764 struct wireless_dev *wdev = dev->ieee80211_ptr;
767 if (wdev->iftype != NL80211_IFTYPE_STATION &&
768 wdev->iftype != NL80211_IFTYPE_ADHOC)
771 idx = erq->flags & IW_ENCODE_INDEX;
773 idx = wdev->wext.default_key;
776 } else if (idx < 1 || idx > 4)
781 erq->flags = idx + 1;
783 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) {
784 erq->flags |= IW_ENCODE_DISABLED;
789 erq->length = min_t(size_t, erq->length,
790 wdev->wext.keys->params[idx].key_len);
791 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length);
792 erq->flags |= IW_ENCODE_ENABLED;
797 static int cfg80211_wext_siwfreq(struct net_device *dev,
798 struct iw_request_info *info,
799 struct iw_freq *wextfreq, char *extra)
801 struct wireless_dev *wdev = dev->ieee80211_ptr;
802 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
803 struct cfg80211_chan_def chandef = {
804 .width = NL80211_CHAN_WIDTH_20_NOHT,
808 wiphy_lock(&rdev->wiphy);
810 switch (wdev->iftype) {
811 case NL80211_IFTYPE_STATION:
812 ret = cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
814 case NL80211_IFTYPE_ADHOC:
815 ret = cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
817 case NL80211_IFTYPE_MONITOR:
818 freq = cfg80211_wext_freq(wextfreq);
827 chandef.center_freq1 = freq;
828 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
833 ret = cfg80211_set_monitor_channel(rdev, &chandef);
835 case NL80211_IFTYPE_MESH_POINT:
836 freq = cfg80211_wext_freq(wextfreq);
845 chandef.center_freq1 = freq;
846 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
851 ret = cfg80211_set_mesh_channel(rdev, wdev, &chandef);
858 wiphy_unlock(&rdev->wiphy);
863 static int cfg80211_wext_giwfreq(struct net_device *dev,
864 struct iw_request_info *info,
865 struct iw_freq *freq, char *extra)
867 struct wireless_dev *wdev = dev->ieee80211_ptr;
868 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
869 struct cfg80211_chan_def chandef = {};
872 wiphy_lock(&rdev->wiphy);
873 switch (wdev->iftype) {
874 case NL80211_IFTYPE_STATION:
875 ret = cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
877 case NL80211_IFTYPE_ADHOC:
878 ret = cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
880 case NL80211_IFTYPE_MONITOR:
881 if (!rdev->ops->get_channel) {
886 ret = rdev_get_channel(rdev, wdev, 0, &chandef);
889 freq->m = chandef.chan->center_freq;
898 wiphy_unlock(&rdev->wiphy);
903 static int cfg80211_wext_siwtxpower(struct net_device *dev,
904 struct iw_request_info *info,
905 union iwreq_data *data, char *extra)
907 struct wireless_dev *wdev = dev->ieee80211_ptr;
908 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
909 enum nl80211_tx_power_setting type;
913 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
915 if (data->txpower.flags & IW_TXPOW_RANGE)
918 if (!rdev->ops->set_tx_power)
921 /* only change when not disabling */
922 if (!data->txpower.disabled) {
923 rfkill_set_sw_state(rdev->wiphy.rfkill, false);
925 if (data->txpower.fixed) {
927 * wext doesn't support negative values, see
928 * below where it's for automatic
930 if (data->txpower.value < 0)
932 dbm = data->txpower.value;
933 type = NL80211_TX_POWER_FIXED;
934 /* TODO: do regulatory check! */
937 * Automatic power level setting, max being the value
938 * passed in from userland.
940 if (data->txpower.value < 0) {
941 type = NL80211_TX_POWER_AUTOMATIC;
943 dbm = data->txpower.value;
944 type = NL80211_TX_POWER_LIMITED;
948 if (rfkill_set_sw_state(rdev->wiphy.rfkill, true))
949 schedule_work(&rdev->rfkill_block);
953 wiphy_lock(&rdev->wiphy);
954 ret = rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm));
955 wiphy_unlock(&rdev->wiphy);
960 static int cfg80211_wext_giwtxpower(struct net_device *dev,
961 struct iw_request_info *info,
962 union iwreq_data *data, char *extra)
964 struct wireless_dev *wdev = dev->ieee80211_ptr;
965 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
968 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
970 if (data->txpower.flags & IW_TXPOW_RANGE)
973 if (!rdev->ops->get_tx_power)
976 wiphy_lock(&rdev->wiphy);
977 err = rdev_get_tx_power(rdev, wdev, &val);
978 wiphy_unlock(&rdev->wiphy);
982 /* well... oh well */
983 data->txpower.fixed = 1;
984 data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill);
985 data->txpower.value = val;
986 data->txpower.flags = IW_TXPOW_DBM;
991 static int cfg80211_set_auth_alg(struct wireless_dev *wdev,
999 if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM |
1000 IW_AUTH_ALG_SHARED_KEY |
1004 if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) {
1006 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
1009 if (auth_alg & IW_AUTH_ALG_SHARED_KEY) {
1011 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY;
1014 if (auth_alg & IW_AUTH_ALG_LEAP) {
1016 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP;
1020 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
1025 static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions)
1027 if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA |
1028 IW_AUTH_WPA_VERSION_WPA2|
1029 IW_AUTH_WPA_VERSION_DISABLED))
1032 if ((wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) &&
1033 (wpa_versions & (IW_AUTH_WPA_VERSION_WPA|
1034 IW_AUTH_WPA_VERSION_WPA2)))
1037 if (wpa_versions & IW_AUTH_WPA_VERSION_DISABLED)
1038 wdev->wext.connect.crypto.wpa_versions &=
1039 ~(NL80211_WPA_VERSION_1|NL80211_WPA_VERSION_2);
1041 if (wpa_versions & IW_AUTH_WPA_VERSION_WPA)
1042 wdev->wext.connect.crypto.wpa_versions |=
1043 NL80211_WPA_VERSION_1;
1045 if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2)
1046 wdev->wext.connect.crypto.wpa_versions |=
1047 NL80211_WPA_VERSION_2;
1052 static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher)
1054 if (cipher & IW_AUTH_CIPHER_WEP40)
1055 wdev->wext.connect.crypto.cipher_group =
1056 WLAN_CIPHER_SUITE_WEP40;
1057 else if (cipher & IW_AUTH_CIPHER_WEP104)
1058 wdev->wext.connect.crypto.cipher_group =
1059 WLAN_CIPHER_SUITE_WEP104;
1060 else if (cipher & IW_AUTH_CIPHER_TKIP)
1061 wdev->wext.connect.crypto.cipher_group =
1062 WLAN_CIPHER_SUITE_TKIP;
1063 else if (cipher & IW_AUTH_CIPHER_CCMP)
1064 wdev->wext.connect.crypto.cipher_group =
1065 WLAN_CIPHER_SUITE_CCMP;
1066 else if (cipher & IW_AUTH_CIPHER_AES_CMAC)
1067 wdev->wext.connect.crypto.cipher_group =
1068 WLAN_CIPHER_SUITE_AES_CMAC;
1069 else if (cipher & IW_AUTH_CIPHER_NONE)
1070 wdev->wext.connect.crypto.cipher_group = 0;
1077 static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher)
1080 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
1082 if (cipher & IW_AUTH_CIPHER_WEP40) {
1083 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40;
1087 if (cipher & IW_AUTH_CIPHER_WEP104) {
1088 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104;
1092 if (cipher & IW_AUTH_CIPHER_TKIP) {
1093 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP;
1097 if (cipher & IW_AUTH_CIPHER_CCMP) {
1098 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP;
1102 if (cipher & IW_AUTH_CIPHER_AES_CMAC) {
1103 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC;
1107 BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5);
1109 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers;
1115 static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt)
1117 int nr_akm_suites = 0;
1119 if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X |
1120 IW_AUTH_KEY_MGMT_PSK))
1123 if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) {
1124 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
1125 WLAN_AKM_SUITE_8021X;
1129 if (key_mgt & IW_AUTH_KEY_MGMT_PSK) {
1130 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
1135 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites;
1140 static int cfg80211_wext_siwauth(struct net_device *dev,
1141 struct iw_request_info *info,
1142 struct iw_param *data, char *extra)
1144 struct wireless_dev *wdev = dev->ieee80211_ptr;
1146 if (wdev->iftype != NL80211_IFTYPE_STATION)
1149 switch (data->flags & IW_AUTH_INDEX) {
1150 case IW_AUTH_PRIVACY_INVOKED:
1151 wdev->wext.connect.privacy = data->value;
1153 case IW_AUTH_WPA_VERSION:
1154 return cfg80211_set_wpa_version(wdev, data->value);
1155 case IW_AUTH_CIPHER_GROUP:
1156 return cfg80211_set_cipher_group(wdev, data->value);
1157 case IW_AUTH_KEY_MGMT:
1158 return cfg80211_set_key_mgt(wdev, data->value);
1159 case IW_AUTH_CIPHER_PAIRWISE:
1160 return cfg80211_set_cipher_pairwise(wdev, data->value);
1161 case IW_AUTH_80211_AUTH_ALG:
1162 return cfg80211_set_auth_alg(wdev, data->value);
1163 case IW_AUTH_WPA_ENABLED:
1164 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1165 case IW_AUTH_DROP_UNENCRYPTED:
1173 static int cfg80211_wext_giwauth(struct net_device *dev,
1174 struct iw_request_info *info,
1175 struct iw_param *data, char *extra)
1177 /* XXX: what do we need? */
1182 static int cfg80211_wext_siwpower(struct net_device *dev,
1183 struct iw_request_info *info,
1184 struct iw_param *wrq, char *extra)
1186 struct wireless_dev *wdev = dev->ieee80211_ptr;
1187 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1189 int timeout = wdev->ps_timeout;
1192 if (wdev->iftype != NL80211_IFTYPE_STATION)
1195 if (!rdev->ops->set_power_mgmt)
1198 if (wrq->disabled) {
1201 switch (wrq->flags & IW_POWER_MODE) {
1202 case IW_POWER_ON: /* If not specified */
1203 case IW_POWER_MODE: /* If set all mask */
1204 case IW_POWER_ALL_R: /* If explicitely state all */
1207 default: /* Otherwise we ignore */
1211 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
1214 if (wrq->flags & IW_POWER_TIMEOUT)
1215 timeout = wrq->value / 1000;
1218 wiphy_lock(&rdev->wiphy);
1219 err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
1220 wiphy_unlock(&rdev->wiphy);
1225 wdev->ps_timeout = timeout;
1231 static int cfg80211_wext_giwpower(struct net_device *dev,
1232 struct iw_request_info *info,
1233 struct iw_param *wrq, char *extra)
1235 struct wireless_dev *wdev = dev->ieee80211_ptr;
1237 wrq->disabled = !wdev->ps;
1242 static int cfg80211_wext_siwrate(struct net_device *dev,
1243 struct iw_request_info *info,
1244 struct iw_param *rate, char *extra)
1246 struct wireless_dev *wdev = dev->ieee80211_ptr;
1247 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1248 struct cfg80211_bitrate_mask mask;
1250 struct ieee80211_supported_band *sband;
1251 int band, ridx, ret;
1254 if (!rdev->ops->set_bitrate_mask)
1257 memset(&mask, 0, sizeof(mask));
1261 if (rate->value < 0) {
1263 } else if (rate->fixed) {
1264 fixed = rate->value / 100000;
1266 maxrate = rate->value / 100000;
1269 for (band = 0; band < NUM_NL80211_BANDS; band++) {
1270 sband = wdev->wiphy->bands[band];
1273 for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
1274 struct ieee80211_rate *srate = &sband->bitrates[ridx];
1275 if (fixed == srate->bitrate) {
1276 mask.control[band].legacy = 1 << ridx;
1280 if (srate->bitrate <= maxrate) {
1281 mask.control[band].legacy |= 1 << ridx;
1290 wiphy_lock(&rdev->wiphy);
1291 if (dev->ieee80211_ptr->valid_links)
1294 ret = rdev_set_bitrate_mask(rdev, dev, 0, NULL, &mask);
1295 wiphy_unlock(&rdev->wiphy);
1300 static int cfg80211_wext_giwrate(struct net_device *dev,
1301 struct iw_request_info *info,
1302 struct iw_param *rate, char *extra)
1304 struct wireless_dev *wdev = dev->ieee80211_ptr;
1305 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1306 struct station_info sinfo = {};
1310 if (wdev->iftype != NL80211_IFTYPE_STATION)
1313 if (!rdev->ops->get_station)
1318 if (!wdev->valid_links && wdev->links[0].client.current_bss)
1319 memcpy(addr, wdev->links[0].client.current_bss->pub.bssid,
1327 wiphy_lock(&rdev->wiphy);
1328 err = rdev_get_station(rdev, dev, addr, &sinfo);
1329 wiphy_unlock(&rdev->wiphy);
1333 if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
1338 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
1341 cfg80211_sinfo_release_content(&sinfo);
1345 /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
1346 static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
1348 struct wireless_dev *wdev = dev->ieee80211_ptr;
1349 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1350 /* we are under RTNL - globally locked - so can use static structs */
1351 static struct iw_statistics wstats;
1352 static struct station_info sinfo = {};
1356 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
1359 if (!rdev->ops->get_station)
1362 /* Grab BSSID of current BSS, if any */
1364 if (wdev->valid_links || !wdev->links[0].client.current_bss) {
1368 memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN);
1371 memset(&sinfo, 0, sizeof(sinfo));
1373 wiphy_lock(&rdev->wiphy);
1374 ret = rdev_get_station(rdev, dev, bssid, &sinfo);
1375 wiphy_unlock(&rdev->wiphy);
1380 memset(&wstats, 0, sizeof(wstats));
1382 switch (rdev->wiphy.signal_type) {
1383 case CFG80211_SIGNAL_TYPE_MBM:
1384 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
1385 int sig = sinfo.signal;
1386 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1387 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
1388 wstats.qual.updated |= IW_QUAL_DBM;
1389 wstats.qual.level = sig;
1394 wstats.qual.qual = sig + 110;
1398 case CFG80211_SIGNAL_TYPE_UNSPEC:
1399 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
1400 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1401 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
1402 wstats.qual.level = sinfo.signal;
1403 wstats.qual.qual = sinfo.signal;
1408 wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
1409 wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
1412 wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
1413 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC))
1414 wstats.discard.misc = sinfo.rx_dropped_misc;
1415 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))
1416 wstats.discard.retries = sinfo.tx_failed;
1418 cfg80211_sinfo_release_content(&sinfo);
1423 static int cfg80211_wext_siwap(struct net_device *dev,
1424 struct iw_request_info *info,
1425 struct sockaddr *ap_addr, char *extra)
1427 struct wireless_dev *wdev = dev->ieee80211_ptr;
1428 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1431 wiphy_lock(&rdev->wiphy);
1432 switch (wdev->iftype) {
1433 case NL80211_IFTYPE_ADHOC:
1434 ret = cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
1436 case NL80211_IFTYPE_STATION:
1437 ret = cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
1443 wiphy_unlock(&rdev->wiphy);
1448 static int cfg80211_wext_giwap(struct net_device *dev,
1449 struct iw_request_info *info,
1450 struct sockaddr *ap_addr, char *extra)
1452 struct wireless_dev *wdev = dev->ieee80211_ptr;
1453 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1456 wiphy_lock(&rdev->wiphy);
1457 switch (wdev->iftype) {
1458 case NL80211_IFTYPE_ADHOC:
1459 ret = cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
1461 case NL80211_IFTYPE_STATION:
1462 ret = cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
1468 wiphy_unlock(&rdev->wiphy);
1473 static int cfg80211_wext_siwessid(struct net_device *dev,
1474 struct iw_request_info *info,
1475 struct iw_point *data, char *ssid)
1477 struct wireless_dev *wdev = dev->ieee80211_ptr;
1478 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1481 wiphy_lock(&rdev->wiphy);
1482 switch (wdev->iftype) {
1483 case NL80211_IFTYPE_ADHOC:
1484 ret = cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
1486 case NL80211_IFTYPE_STATION:
1487 ret = cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
1493 wiphy_unlock(&rdev->wiphy);
1498 static int cfg80211_wext_giwessid(struct net_device *dev,
1499 struct iw_request_info *info,
1500 struct iw_point *data, char *ssid)
1502 struct wireless_dev *wdev = dev->ieee80211_ptr;
1503 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1509 wiphy_lock(&rdev->wiphy);
1510 switch (wdev->iftype) {
1511 case NL80211_IFTYPE_ADHOC:
1512 ret = cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
1514 case NL80211_IFTYPE_STATION:
1515 ret = cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
1521 wiphy_unlock(&rdev->wiphy);
1526 static int cfg80211_wext_siwpmksa(struct net_device *dev,
1527 struct iw_request_info *info,
1528 struct iw_point *data, char *extra)
1530 struct wireless_dev *wdev = dev->ieee80211_ptr;
1531 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1532 struct cfg80211_pmksa cfg_pmksa;
1533 struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
1536 memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa));
1538 if (wdev->iftype != NL80211_IFTYPE_STATION)
1541 cfg_pmksa.bssid = pmksa->bssid.sa_data;
1542 cfg_pmksa.pmkid = pmksa->pmkid;
1544 wiphy_lock(&rdev->wiphy);
1545 switch (pmksa->cmd) {
1547 if (!rdev->ops->set_pmksa) {
1552 ret = rdev_set_pmksa(rdev, dev, &cfg_pmksa);
1554 case IW_PMKSA_REMOVE:
1555 if (!rdev->ops->del_pmksa) {
1560 ret = rdev_del_pmksa(rdev, dev, &cfg_pmksa);
1562 case IW_PMKSA_FLUSH:
1563 if (!rdev->ops->flush_pmksa) {
1568 ret = rdev_flush_pmksa(rdev, dev);
1574 wiphy_unlock(&rdev->wiphy);
1579 #define DEFINE_WEXT_COMPAT_STUB(func, type) \
1580 static int __ ## func(struct net_device *dev, \
1581 struct iw_request_info *info, \
1582 union iwreq_data *wrqu, \
1585 return func(dev, info, (type *)wrqu, extra); \
1588 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwname, char)
1589 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwfreq, struct iw_freq)
1590 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwfreq, struct iw_freq)
1591 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwmode, u32)
1592 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwmode, u32)
1593 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrange, struct iw_point)
1594 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwap, struct sockaddr)
1595 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwap, struct sockaddr)
1596 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwmlme, struct iw_point)
1597 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwscan, struct iw_point)
1598 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwessid, struct iw_point)
1599 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwessid, struct iw_point)
1600 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwrate, struct iw_param)
1601 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrate, struct iw_param)
1602 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwrts, struct iw_param)
1603 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrts, struct iw_param)
1604 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwfrag, struct iw_param)
1605 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwfrag, struct iw_param)
1606 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwretry, struct iw_param)
1607 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwretry, struct iw_param)
1608 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwencode, struct iw_point)
1609 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwencode, struct iw_point)
1610 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwpower, struct iw_param)
1611 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwpower, struct iw_param)
1612 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwgenie, struct iw_point)
1613 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwauth, struct iw_param)
1614 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwauth, struct iw_param)
1615 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwencodeext, struct iw_point)
1616 DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwpmksa, struct iw_point)
1618 static const iw_handler cfg80211_handlers[] = {
1619 [IW_IOCTL_IDX(SIOCGIWNAME)] = __cfg80211_wext_giwname,
1620 [IW_IOCTL_IDX(SIOCSIWFREQ)] = __cfg80211_wext_siwfreq,
1621 [IW_IOCTL_IDX(SIOCGIWFREQ)] = __cfg80211_wext_giwfreq,
1622 [IW_IOCTL_IDX(SIOCSIWMODE)] = __cfg80211_wext_siwmode,
1623 [IW_IOCTL_IDX(SIOCGIWMODE)] = __cfg80211_wext_giwmode,
1624 [IW_IOCTL_IDX(SIOCGIWRANGE)] = __cfg80211_wext_giwrange,
1625 [IW_IOCTL_IDX(SIOCSIWAP)] = __cfg80211_wext_siwap,
1626 [IW_IOCTL_IDX(SIOCGIWAP)] = __cfg80211_wext_giwap,
1627 [IW_IOCTL_IDX(SIOCSIWMLME)] = __cfg80211_wext_siwmlme,
1628 [IW_IOCTL_IDX(SIOCSIWSCAN)] = cfg80211_wext_siwscan,
1629 [IW_IOCTL_IDX(SIOCGIWSCAN)] = __cfg80211_wext_giwscan,
1630 [IW_IOCTL_IDX(SIOCSIWESSID)] = __cfg80211_wext_siwessid,
1631 [IW_IOCTL_IDX(SIOCGIWESSID)] = __cfg80211_wext_giwessid,
1632 [IW_IOCTL_IDX(SIOCSIWRATE)] = __cfg80211_wext_siwrate,
1633 [IW_IOCTL_IDX(SIOCGIWRATE)] = __cfg80211_wext_giwrate,
1634 [IW_IOCTL_IDX(SIOCSIWRTS)] = __cfg80211_wext_siwrts,
1635 [IW_IOCTL_IDX(SIOCGIWRTS)] = __cfg80211_wext_giwrts,
1636 [IW_IOCTL_IDX(SIOCSIWFRAG)] = __cfg80211_wext_siwfrag,
1637 [IW_IOCTL_IDX(SIOCGIWFRAG)] = __cfg80211_wext_giwfrag,
1638 [IW_IOCTL_IDX(SIOCSIWTXPOW)] = cfg80211_wext_siwtxpower,
1639 [IW_IOCTL_IDX(SIOCGIWTXPOW)] = cfg80211_wext_giwtxpower,
1640 [IW_IOCTL_IDX(SIOCSIWRETRY)] = __cfg80211_wext_siwretry,
1641 [IW_IOCTL_IDX(SIOCGIWRETRY)] = __cfg80211_wext_giwretry,
1642 [IW_IOCTL_IDX(SIOCSIWENCODE)] = __cfg80211_wext_siwencode,
1643 [IW_IOCTL_IDX(SIOCGIWENCODE)] = __cfg80211_wext_giwencode,
1644 [IW_IOCTL_IDX(SIOCSIWPOWER)] = __cfg80211_wext_siwpower,
1645 [IW_IOCTL_IDX(SIOCGIWPOWER)] = __cfg80211_wext_giwpower,
1646 [IW_IOCTL_IDX(SIOCSIWGENIE)] = __cfg80211_wext_siwgenie,
1647 [IW_IOCTL_IDX(SIOCSIWAUTH)] = __cfg80211_wext_siwauth,
1648 [IW_IOCTL_IDX(SIOCGIWAUTH)] = __cfg80211_wext_giwauth,
1649 [IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= __cfg80211_wext_siwencodeext,
1650 [IW_IOCTL_IDX(SIOCSIWPMKSA)] = __cfg80211_wext_siwpmksa,
1653 const struct iw_handler_def cfg80211_wext_handler = {
1654 .num_standard = ARRAY_SIZE(cfg80211_handlers),
1655 .standard = cfg80211_handlers,
1656 .get_wireless_stats = cfg80211_wireless_stats,