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-2023 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 union iwreq_data
*wrqu
, char *extra
)
30 strcpy(wrqu
->name
, "IEEE 802.11");
34 int cfg80211_wext_siwmode(struct net_device
*dev
, struct iw_request_info
*info
,
35 union iwreq_data
*wrqu
, char *extra
)
37 __u32
*mode
= &wrqu
->mode
;
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
);
72 int cfg80211_wext_giwmode(struct net_device
*dev
, struct iw_request_info
*info
,
73 union iwreq_data
*wrqu
, char *extra
)
75 __u32
*mode
= &wrqu
->mode
;
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
;
108 int cfg80211_wext_giwrange(struct net_device
*dev
,
109 struct iw_request_info
*info
,
110 union iwreq_data
*wrqu
, char *extra
)
112 struct iw_point
*data
= &wrqu
->data
;
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
;
223 * cfg80211_wext_freq - get wext frequency for non-"auto"
224 * @freq: the wext freq encoding
226 * Returns: a frequency, or a negative error code, or 0 for auto.
228 int cfg80211_wext_freq(struct iw_freq
*freq
)
231 * Parse frequency - return 0 for auto and
232 * -EINVAL for impossible things.
235 enum nl80211_band band
= NL80211_BAND_2GHZ
;
239 band
= NL80211_BAND_5GHZ
;
240 return ieee80211_channel_to_frequency(freq
->m
, band
);
242 int i
, div
= 1000000;
243 for (i
= 0; i
< freq
->e
; i
++)
247 return freq
->m
/ div
;
251 int cfg80211_wext_siwrts(struct net_device
*dev
,
252 struct iw_request_info
*info
,
253 union iwreq_data
*wrqu
, char *extra
)
255 struct iw_param
*rts
= &wrqu
->rts
;
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
);
281 int cfg80211_wext_giwrts(struct net_device
*dev
,
282 struct iw_request_info
*info
,
283 union iwreq_data
*wrqu
, char *extra
)
285 struct iw_param
*rts
= &wrqu
->rts
;
286 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
288 rts
->value
= wdev
->wiphy
->rts_threshold
;
289 rts
->disabled
= rts
->value
== (u32
) -1;
295 int cfg80211_wext_siwfrag(struct net_device
*dev
,
296 struct iw_request_info
*info
,
297 union iwreq_data
*wrqu
, char *extra
)
299 struct iw_param
*frag
= &wrqu
->frag
;
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
);
325 int cfg80211_wext_giwfrag(struct net_device
*dev
,
326 struct iw_request_info
*info
,
327 union iwreq_data
*wrqu
, char *extra
)
329 struct iw_param
*frag
= &wrqu
->frag
;
330 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
332 frag
->value
= wdev
->wiphy
->frag_threshold
;
333 frag
->disabled
= frag
->value
== (u32
) -1;
339 static int cfg80211_wext_siwretry(struct net_device
*dev
,
340 struct iw_request_info
*info
,
341 union iwreq_data
*wrqu
, char *extra
)
343 struct iw_param
*retry
= &wrqu
->retry
;
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 union iwreq_data
*wrqu
, char *extra
)
383 struct iw_param
*retry
= &wrqu
->retry
;
384 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
388 if (retry
->flags
== 0 || (retry
->flags
& IW_RETRY_SHORT
)) {
390 * First return short value, iwconfig will ask long value
393 retry
->flags
|= IW_RETRY_LIMIT
| IW_RETRY_SHORT
;
394 retry
->value
= wdev
->wiphy
->retry_short
;
395 if (wdev
->wiphy
->retry_long
== wdev
->wiphy
->retry_short
)
396 retry
->flags
|= IW_RETRY_LONG
;
401 if (retry
->flags
& IW_RETRY_LONG
) {
402 retry
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
403 retry
->value
= wdev
->wiphy
->retry_long
;
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
< 4; 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
, -1, 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
, -1, 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
, -1, idx
, true,
553 wdev
->wext
.default_key
= idx
;
555 err
= cfg80211_ibss_wext_join(rdev
, wdev
);
560 if (params
->cipher
== WLAN_CIPHER_SUITE_AES_CMAC
&&
561 (tx_key
|| (!addr
&& wdev
->wext
.default_mgmt_key
== -1))) {
562 if (wdev
->connected
||
563 (wdev
->iftype
== NL80211_IFTYPE_ADHOC
&&
564 wdev
->u
.ibss
.current_bss
))
565 err
= rdev_set_default_mgmt_key(rdev
, dev
, -1, idx
);
567 wdev
->wext
.default_mgmt_key
= idx
;
574 static int cfg80211_wext_siwencode(struct net_device
*dev
,
575 struct iw_request_info
*info
,
576 union iwreq_data
*wrqu
, char *keybuf
)
578 struct iw_point
*erq
= &wrqu
->encoding
;
579 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
580 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
583 struct key_params params
;
585 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
&&
586 wdev
->iftype
!= NL80211_IFTYPE_ADHOC
)
589 /* no use -- only MFP (set_default_mgmt_key) is optional */
590 if (!rdev
->ops
->del_key
||
591 !rdev
->ops
->add_key
||
592 !rdev
->ops
->set_default_key
)
595 wiphy_lock(&rdev
->wiphy
);
596 if (wdev
->valid_links
) {
601 idx
= erq
->flags
& IW_ENCODE_INDEX
;
603 idx
= wdev
->wext
.default_key
;
606 } else if (idx
< 1 || idx
> 4) {
613 if (erq
->flags
& IW_ENCODE_DISABLED
)
615 else if (erq
->length
== 0) {
616 /* No key data - just set the default TX key index */
618 if (wdev
->connected
||
619 (wdev
->iftype
== NL80211_IFTYPE_ADHOC
&&
620 wdev
->u
.ibss
.current_bss
))
621 err
= rdev_set_default_key(rdev
, dev
, -1, idx
, true,
624 wdev
->wext
.default_key
= idx
;
628 memset(¶ms
, 0, sizeof(params
));
630 params
.key_len
= erq
->length
;
631 if (erq
->length
== 5) {
632 params
.cipher
= WLAN_CIPHER_SUITE_WEP40
;
633 } else if (erq
->length
== 13) {
634 params
.cipher
= WLAN_CIPHER_SUITE_WEP104
;
635 } else if (!remove
) {
640 err
= cfg80211_set_encryption(rdev
, dev
, false, NULL
, remove
,
641 wdev
->wext
.default_key
== -1,
644 wiphy_unlock(&rdev
->wiphy
);
649 static int cfg80211_wext_siwencodeext(struct net_device
*dev
,
650 struct iw_request_info
*info
,
651 union iwreq_data
*wrqu
, char *extra
)
653 struct iw_point
*erq
= &wrqu
->encoding
;
654 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
655 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
656 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
660 struct key_params params
;
664 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
&&
665 wdev
->iftype
!= NL80211_IFTYPE_ADHOC
)
668 /* no use -- only MFP (set_default_mgmt_key) is optional */
669 if (!rdev
->ops
->del_key
||
670 !rdev
->ops
->add_key
||
671 !rdev
->ops
->set_default_key
)
674 if (wdev
->valid_links
)
678 case IW_ENCODE_ALG_NONE
:
682 case IW_ENCODE_ALG_WEP
:
683 if (ext
->key_len
== 5)
684 cipher
= WLAN_CIPHER_SUITE_WEP40
;
685 else if (ext
->key_len
== 13)
686 cipher
= WLAN_CIPHER_SUITE_WEP104
;
690 case IW_ENCODE_ALG_TKIP
:
691 cipher
= WLAN_CIPHER_SUITE_TKIP
;
693 case IW_ENCODE_ALG_CCMP
:
694 cipher
= WLAN_CIPHER_SUITE_CCMP
;
696 case IW_ENCODE_ALG_AES_CMAC
:
697 cipher
= WLAN_CIPHER_SUITE_AES_CMAC
;
703 if (erq
->flags
& IW_ENCODE_DISABLED
)
706 idx
= erq
->flags
& IW_ENCODE_INDEX
;
707 if (cipher
== WLAN_CIPHER_SUITE_AES_CMAC
) {
708 if (idx
< 4 || idx
> 5) {
709 idx
= wdev
->wext
.default_mgmt_key
;
715 if (idx
< 1 || idx
> 4) {
716 idx
= wdev
->wext
.default_key
;
723 addr
= ext
->addr
.sa_data
;
724 if (is_broadcast_ether_addr(addr
))
727 memset(¶ms
, 0, sizeof(params
));
728 params
.key
= ext
->key
;
729 params
.key_len
= ext
->key_len
;
730 params
.cipher
= cipher
;
732 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
) {
733 params
.seq
= ext
->rx_seq
;
737 wiphy_lock(wdev
->wiphy
);
738 ret
= cfg80211_set_encryption(
740 !(ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
),
742 ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
,
744 wiphy_unlock(wdev
->wiphy
);
749 static int cfg80211_wext_giwencode(struct net_device
*dev
,
750 struct iw_request_info
*info
,
751 union iwreq_data
*wrqu
, char *keybuf
)
753 struct iw_point
*erq
= &wrqu
->encoding
;
754 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
757 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
&&
758 wdev
->iftype
!= NL80211_IFTYPE_ADHOC
)
761 idx
= erq
->flags
& IW_ENCODE_INDEX
;
763 idx
= wdev
->wext
.default_key
;
766 } else if (idx
< 1 || idx
> 4)
771 erq
->flags
= idx
+ 1;
773 if (!wdev
->wext
.keys
|| !wdev
->wext
.keys
->params
[idx
].cipher
) {
774 erq
->flags
|= IW_ENCODE_DISABLED
;
779 erq
->length
= min_t(size_t, erq
->length
,
780 wdev
->wext
.keys
->params
[idx
].key_len
);
781 memcpy(keybuf
, wdev
->wext
.keys
->params
[idx
].key
, erq
->length
);
782 erq
->flags
|= IW_ENCODE_ENABLED
;
787 static int cfg80211_wext_siwfreq(struct net_device
*dev
,
788 struct iw_request_info
*info
,
789 union iwreq_data
*wrqu
, char *extra
)
791 struct iw_freq
*wextfreq
= &wrqu
->freq
;
792 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
793 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
794 struct cfg80211_chan_def chandef
= {
795 .width
= NL80211_CHAN_WIDTH_20_NOHT
,
799 wiphy_lock(&rdev
->wiphy
);
801 switch (wdev
->iftype
) {
802 case NL80211_IFTYPE_STATION
:
803 ret
= cfg80211_mgd_wext_siwfreq(dev
, info
, wextfreq
, extra
);
805 case NL80211_IFTYPE_ADHOC
:
806 ret
= cfg80211_ibss_wext_siwfreq(dev
, info
, wextfreq
, extra
);
808 case NL80211_IFTYPE_MONITOR
:
809 freq
= cfg80211_wext_freq(wextfreq
);
818 chandef
.center_freq1
= freq
;
819 chandef
.chan
= ieee80211_get_channel(&rdev
->wiphy
, freq
);
824 ret
= cfg80211_set_monitor_channel(rdev
, dev
, &chandef
);
826 case NL80211_IFTYPE_MESH_POINT
:
827 freq
= cfg80211_wext_freq(wextfreq
);
836 chandef
.center_freq1
= freq
;
837 chandef
.chan
= ieee80211_get_channel(&rdev
->wiphy
, freq
);
842 ret
= cfg80211_set_mesh_channel(rdev
, wdev
, &chandef
);
849 wiphy_unlock(&rdev
->wiphy
);
854 static int cfg80211_wext_giwfreq(struct net_device
*dev
,
855 struct iw_request_info
*info
,
856 union iwreq_data
*wrqu
, char *extra
)
858 struct iw_freq
*freq
= &wrqu
->freq
;
859 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
860 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
861 struct cfg80211_chan_def chandef
= {};
864 wiphy_lock(&rdev
->wiphy
);
865 switch (wdev
->iftype
) {
866 case NL80211_IFTYPE_STATION
:
867 ret
= cfg80211_mgd_wext_giwfreq(dev
, info
, freq
, extra
);
869 case NL80211_IFTYPE_ADHOC
:
870 ret
= cfg80211_ibss_wext_giwfreq(dev
, info
, freq
, extra
);
872 case NL80211_IFTYPE_MONITOR
:
873 if (!rdev
->ops
->get_channel
) {
878 ret
= rdev_get_channel(rdev
, wdev
, 0, &chandef
);
881 freq
->m
= chandef
.chan
->center_freq
;
890 wiphy_unlock(&rdev
->wiphy
);
895 static int cfg80211_wext_siwtxpower(struct net_device
*dev
,
896 struct iw_request_info
*info
,
897 union iwreq_data
*data
, char *extra
)
899 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
900 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
901 enum nl80211_tx_power_setting type
;
905 if ((data
->txpower
.flags
& IW_TXPOW_TYPE
) != IW_TXPOW_DBM
)
907 if (data
->txpower
.flags
& IW_TXPOW_RANGE
)
910 if (!rdev
->ops
->set_tx_power
)
913 /* only change when not disabling */
914 if (!data
->txpower
.disabled
) {
915 rfkill_set_sw_state(rdev
->wiphy
.rfkill
, false);
917 if (data
->txpower
.fixed
) {
919 * wext doesn't support negative values, see
920 * below where it's for automatic
922 if (data
->txpower
.value
< 0)
924 dbm
= data
->txpower
.value
;
925 type
= NL80211_TX_POWER_FIXED
;
926 /* TODO: do regulatory check! */
929 * Automatic power level setting, max being the value
930 * passed in from userland.
932 if (data
->txpower
.value
< 0) {
933 type
= NL80211_TX_POWER_AUTOMATIC
;
935 dbm
= data
->txpower
.value
;
936 type
= NL80211_TX_POWER_LIMITED
;
940 if (rfkill_set_sw_state(rdev
->wiphy
.rfkill
, true))
941 schedule_work(&rdev
->rfkill_block
);
945 wiphy_lock(&rdev
->wiphy
);
946 ret
= rdev_set_tx_power(rdev
, wdev
, type
, DBM_TO_MBM(dbm
));
947 wiphy_unlock(&rdev
->wiphy
);
952 static int cfg80211_wext_giwtxpower(struct net_device
*dev
,
953 struct iw_request_info
*info
,
954 union iwreq_data
*data
, char *extra
)
956 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
957 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
960 if ((data
->txpower
.flags
& IW_TXPOW_TYPE
) != IW_TXPOW_DBM
)
962 if (data
->txpower
.flags
& IW_TXPOW_RANGE
)
965 if (!rdev
->ops
->get_tx_power
)
968 wiphy_lock(&rdev
->wiphy
);
969 err
= rdev_get_tx_power(rdev
, wdev
, &val
);
970 wiphy_unlock(&rdev
->wiphy
);
974 /* well... oh well */
975 data
->txpower
.fixed
= 1;
976 data
->txpower
.disabled
= rfkill_blocked(rdev
->wiphy
.rfkill
);
977 data
->txpower
.value
= val
;
978 data
->txpower
.flags
= IW_TXPOW_DBM
;
983 static int cfg80211_set_auth_alg(struct wireless_dev
*wdev
,
991 if (auth_alg
& ~(IW_AUTH_ALG_OPEN_SYSTEM
|
992 IW_AUTH_ALG_SHARED_KEY
|
996 if (auth_alg
& IW_AUTH_ALG_OPEN_SYSTEM
) {
998 wdev
->wext
.connect
.auth_type
= NL80211_AUTHTYPE_OPEN_SYSTEM
;
1001 if (auth_alg
& IW_AUTH_ALG_SHARED_KEY
) {
1003 wdev
->wext
.connect
.auth_type
= NL80211_AUTHTYPE_SHARED_KEY
;
1006 if (auth_alg
& IW_AUTH_ALG_LEAP
) {
1008 wdev
->wext
.connect
.auth_type
= NL80211_AUTHTYPE_NETWORK_EAP
;
1012 wdev
->wext
.connect
.auth_type
= NL80211_AUTHTYPE_AUTOMATIC
;
1017 static int cfg80211_set_wpa_version(struct wireless_dev
*wdev
, u32 wpa_versions
)
1019 if (wpa_versions
& ~(IW_AUTH_WPA_VERSION_WPA
|
1020 IW_AUTH_WPA_VERSION_WPA2
|
1021 IW_AUTH_WPA_VERSION_DISABLED
))
1024 if ((wpa_versions
& IW_AUTH_WPA_VERSION_DISABLED
) &&
1025 (wpa_versions
& (IW_AUTH_WPA_VERSION_WPA
|
1026 IW_AUTH_WPA_VERSION_WPA2
)))
1029 if (wpa_versions
& IW_AUTH_WPA_VERSION_DISABLED
)
1030 wdev
->wext
.connect
.crypto
.wpa_versions
&=
1031 ~(NL80211_WPA_VERSION_1
|NL80211_WPA_VERSION_2
);
1033 if (wpa_versions
& IW_AUTH_WPA_VERSION_WPA
)
1034 wdev
->wext
.connect
.crypto
.wpa_versions
|=
1035 NL80211_WPA_VERSION_1
;
1037 if (wpa_versions
& IW_AUTH_WPA_VERSION_WPA2
)
1038 wdev
->wext
.connect
.crypto
.wpa_versions
|=
1039 NL80211_WPA_VERSION_2
;
1044 static int cfg80211_set_cipher_group(struct wireless_dev
*wdev
, u32 cipher
)
1046 if (cipher
& IW_AUTH_CIPHER_WEP40
)
1047 wdev
->wext
.connect
.crypto
.cipher_group
=
1048 WLAN_CIPHER_SUITE_WEP40
;
1049 else if (cipher
& IW_AUTH_CIPHER_WEP104
)
1050 wdev
->wext
.connect
.crypto
.cipher_group
=
1051 WLAN_CIPHER_SUITE_WEP104
;
1052 else if (cipher
& IW_AUTH_CIPHER_TKIP
)
1053 wdev
->wext
.connect
.crypto
.cipher_group
=
1054 WLAN_CIPHER_SUITE_TKIP
;
1055 else if (cipher
& IW_AUTH_CIPHER_CCMP
)
1056 wdev
->wext
.connect
.crypto
.cipher_group
=
1057 WLAN_CIPHER_SUITE_CCMP
;
1058 else if (cipher
& IW_AUTH_CIPHER_AES_CMAC
)
1059 wdev
->wext
.connect
.crypto
.cipher_group
=
1060 WLAN_CIPHER_SUITE_AES_CMAC
;
1061 else if (cipher
& IW_AUTH_CIPHER_NONE
)
1062 wdev
->wext
.connect
.crypto
.cipher_group
= 0;
1069 static int cfg80211_set_cipher_pairwise(struct wireless_dev
*wdev
, u32 cipher
)
1072 u32
*ciphers_pairwise
= wdev
->wext
.connect
.crypto
.ciphers_pairwise
;
1074 if (cipher
& IW_AUTH_CIPHER_WEP40
) {
1075 ciphers_pairwise
[nr_ciphers
] = WLAN_CIPHER_SUITE_WEP40
;
1079 if (cipher
& IW_AUTH_CIPHER_WEP104
) {
1080 ciphers_pairwise
[nr_ciphers
] = WLAN_CIPHER_SUITE_WEP104
;
1084 if (cipher
& IW_AUTH_CIPHER_TKIP
) {
1085 ciphers_pairwise
[nr_ciphers
] = WLAN_CIPHER_SUITE_TKIP
;
1089 if (cipher
& IW_AUTH_CIPHER_CCMP
) {
1090 ciphers_pairwise
[nr_ciphers
] = WLAN_CIPHER_SUITE_CCMP
;
1094 if (cipher
& IW_AUTH_CIPHER_AES_CMAC
) {
1095 ciphers_pairwise
[nr_ciphers
] = WLAN_CIPHER_SUITE_AES_CMAC
;
1099 BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES
< 5);
1101 wdev
->wext
.connect
.crypto
.n_ciphers_pairwise
= nr_ciphers
;
1107 static int cfg80211_set_key_mgt(struct wireless_dev
*wdev
, u32 key_mgt
)
1109 int nr_akm_suites
= 0;
1111 if (key_mgt
& ~(IW_AUTH_KEY_MGMT_802_1X
|
1112 IW_AUTH_KEY_MGMT_PSK
))
1115 if (key_mgt
& IW_AUTH_KEY_MGMT_802_1X
) {
1116 wdev
->wext
.connect
.crypto
.akm_suites
[nr_akm_suites
] =
1117 WLAN_AKM_SUITE_8021X
;
1121 if (key_mgt
& IW_AUTH_KEY_MGMT_PSK
) {
1122 wdev
->wext
.connect
.crypto
.akm_suites
[nr_akm_suites
] =
1127 wdev
->wext
.connect
.crypto
.n_akm_suites
= nr_akm_suites
;
1132 static int cfg80211_wext_siwauth(struct net_device
*dev
,
1133 struct iw_request_info
*info
,
1134 union iwreq_data
*wrqu
, char *extra
)
1136 struct iw_param
*data
= &wrqu
->param
;
1137 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1139 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
)
1142 switch (data
->flags
& IW_AUTH_INDEX
) {
1143 case IW_AUTH_PRIVACY_INVOKED
:
1144 wdev
->wext
.connect
.privacy
= data
->value
;
1146 case IW_AUTH_WPA_VERSION
:
1147 return cfg80211_set_wpa_version(wdev
, data
->value
);
1148 case IW_AUTH_CIPHER_GROUP
:
1149 return cfg80211_set_cipher_group(wdev
, data
->value
);
1150 case IW_AUTH_KEY_MGMT
:
1151 return cfg80211_set_key_mgt(wdev
, data
->value
);
1152 case IW_AUTH_CIPHER_PAIRWISE
:
1153 return cfg80211_set_cipher_pairwise(wdev
, data
->value
);
1154 case IW_AUTH_80211_AUTH_ALG
:
1155 return cfg80211_set_auth_alg(wdev
, data
->value
);
1156 case IW_AUTH_WPA_ENABLED
:
1157 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1158 case IW_AUTH_DROP_UNENCRYPTED
:
1166 static int cfg80211_wext_giwauth(struct net_device
*dev
,
1167 struct iw_request_info
*info
,
1168 union iwreq_data
*wrqu
, char *extra
)
1170 /* XXX: what do we need? */
1175 static int cfg80211_wext_siwpower(struct net_device
*dev
,
1176 struct iw_request_info
*info
,
1177 union iwreq_data
*wrqu
, char *extra
)
1179 struct iw_param
*wrq
= &wrqu
->power
;
1180 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1181 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1183 int timeout
= wdev
->ps_timeout
;
1186 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
)
1189 if (!rdev
->ops
->set_power_mgmt
)
1192 if (wrq
->disabled
) {
1195 switch (wrq
->flags
& IW_POWER_MODE
) {
1196 case IW_POWER_ON
: /* If not specified */
1197 case IW_POWER_MODE
: /* If set all mask */
1198 case IW_POWER_ALL_R
: /* If explicitly state all */
1201 default: /* Otherwise we ignore */
1205 if (wrq
->flags
& ~(IW_POWER_MODE
| IW_POWER_TIMEOUT
))
1208 if (wrq
->flags
& IW_POWER_TIMEOUT
)
1209 timeout
= wrq
->value
/ 1000;
1212 wiphy_lock(&rdev
->wiphy
);
1213 err
= rdev_set_power_mgmt(rdev
, dev
, ps
, timeout
);
1214 wiphy_unlock(&rdev
->wiphy
);
1219 wdev
->ps_timeout
= timeout
;
1225 static int cfg80211_wext_giwpower(struct net_device
*dev
,
1226 struct iw_request_info
*info
,
1227 union iwreq_data
*wrqu
, char *extra
)
1229 struct iw_param
*wrq
= &wrqu
->power
;
1230 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1232 wrq
->disabled
= !wdev
->ps
;
1237 static int cfg80211_wext_siwrate(struct net_device
*dev
,
1238 struct iw_request_info
*info
,
1239 union iwreq_data
*wrqu
, char *extra
)
1241 struct iw_param
*rate
= &wrqu
->bitrate
;
1242 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1243 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1244 struct cfg80211_bitrate_mask mask
;
1246 struct ieee80211_supported_band
*sband
;
1247 int band
, ridx
, ret
;
1250 if (!rdev
->ops
->set_bitrate_mask
)
1253 memset(&mask
, 0, sizeof(mask
));
1257 if (rate
->value
< 0) {
1259 } else if (rate
->fixed
) {
1260 fixed
= rate
->value
/ 100000;
1262 maxrate
= rate
->value
/ 100000;
1265 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
1266 sband
= wdev
->wiphy
->bands
[band
];
1269 for (ridx
= 0; ridx
< sband
->n_bitrates
; ridx
++) {
1270 struct ieee80211_rate
*srate
= &sband
->bitrates
[ridx
];
1271 if (fixed
== srate
->bitrate
) {
1272 mask
.control
[band
].legacy
= 1 << ridx
;
1276 if (srate
->bitrate
<= maxrate
) {
1277 mask
.control
[band
].legacy
|= 1 << ridx
;
1286 wiphy_lock(&rdev
->wiphy
);
1287 if (dev
->ieee80211_ptr
->valid_links
)
1290 ret
= rdev_set_bitrate_mask(rdev
, dev
, 0, NULL
, &mask
);
1291 wiphy_unlock(&rdev
->wiphy
);
1296 static int cfg80211_wext_giwrate(struct net_device
*dev
,
1297 struct iw_request_info
*info
,
1298 union iwreq_data
*wrqu
, char *extra
)
1300 struct iw_param
*rate
= &wrqu
->bitrate
;
1301 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1302 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1303 struct station_info sinfo
= {};
1307 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
)
1310 if (!rdev
->ops
->get_station
)
1314 if (!wdev
->valid_links
&& wdev
->links
[0].client
.current_bss
)
1315 memcpy(addr
, wdev
->links
[0].client
.current_bss
->pub
.bssid
,
1322 wiphy_lock(&rdev
->wiphy
);
1323 err
= rdev_get_station(rdev
, dev
, addr
, &sinfo
);
1324 wiphy_unlock(&rdev
->wiphy
);
1328 if (!(sinfo
.filled
& BIT_ULL(NL80211_STA_INFO_TX_BITRATE
))) {
1333 rate
->value
= 100000 * cfg80211_calculate_bitrate(&sinfo
.txrate
);
1336 cfg80211_sinfo_release_content(&sinfo
);
1340 /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
1341 static struct iw_statistics
*cfg80211_wireless_stats(struct net_device
*dev
)
1343 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1344 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1345 /* we are under RTNL - globally locked - so can use static structs */
1346 static struct iw_statistics wstats
;
1347 static struct station_info sinfo
= {};
1351 if (dev
->ieee80211_ptr
->iftype
!= NL80211_IFTYPE_STATION
)
1354 if (!rdev
->ops
->get_station
)
1357 /* Grab BSSID of current BSS, if any */
1358 wiphy_lock(&rdev
->wiphy
);
1359 if (wdev
->valid_links
|| !wdev
->links
[0].client
.current_bss
) {
1360 wiphy_unlock(&rdev
->wiphy
);
1363 memcpy(bssid
, wdev
->links
[0].client
.current_bss
->pub
.bssid
, ETH_ALEN
);
1365 memset(&sinfo
, 0, sizeof(sinfo
));
1367 ret
= rdev_get_station(rdev
, dev
, bssid
, &sinfo
);
1368 wiphy_unlock(&rdev
->wiphy
);
1373 memset(&wstats
, 0, sizeof(wstats
));
1375 switch (rdev
->wiphy
.signal_type
) {
1376 case CFG80211_SIGNAL_TYPE_MBM
:
1377 if (sinfo
.filled
& BIT_ULL(NL80211_STA_INFO_SIGNAL
)) {
1378 int sig
= sinfo
.signal
;
1379 wstats
.qual
.updated
|= IW_QUAL_LEVEL_UPDATED
;
1380 wstats
.qual
.updated
|= IW_QUAL_QUAL_UPDATED
;
1381 wstats
.qual
.updated
|= IW_QUAL_DBM
;
1382 wstats
.qual
.level
= sig
;
1387 wstats
.qual
.qual
= sig
+ 110;
1391 case CFG80211_SIGNAL_TYPE_UNSPEC
:
1392 if (sinfo
.filled
& BIT_ULL(NL80211_STA_INFO_SIGNAL
)) {
1393 wstats
.qual
.updated
|= IW_QUAL_LEVEL_UPDATED
;
1394 wstats
.qual
.updated
|= IW_QUAL_QUAL_UPDATED
;
1395 wstats
.qual
.level
= sinfo
.signal
;
1396 wstats
.qual
.qual
= sinfo
.signal
;
1401 wstats
.qual
.updated
|= IW_QUAL_LEVEL_INVALID
;
1402 wstats
.qual
.updated
|= IW_QUAL_QUAL_INVALID
;
1405 wstats
.qual
.updated
|= IW_QUAL_NOISE_INVALID
;
1406 if (sinfo
.filled
& BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC
))
1407 wstats
.discard
.misc
= sinfo
.rx_dropped_misc
;
1408 if (sinfo
.filled
& BIT_ULL(NL80211_STA_INFO_TX_FAILED
))
1409 wstats
.discard
.retries
= sinfo
.tx_failed
;
1411 cfg80211_sinfo_release_content(&sinfo
);
1416 static int cfg80211_wext_siwap(struct net_device
*dev
,
1417 struct iw_request_info
*info
,
1418 union iwreq_data
*wrqu
, char *extra
)
1420 struct sockaddr
*ap_addr
= &wrqu
->ap_addr
;
1421 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1422 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1425 wiphy_lock(&rdev
->wiphy
);
1426 switch (wdev
->iftype
) {
1427 case NL80211_IFTYPE_ADHOC
:
1428 ret
= cfg80211_ibss_wext_siwap(dev
, info
, ap_addr
, extra
);
1430 case NL80211_IFTYPE_STATION
:
1431 ret
= cfg80211_mgd_wext_siwap(dev
, info
, ap_addr
, extra
);
1437 wiphy_unlock(&rdev
->wiphy
);
1442 static int cfg80211_wext_giwap(struct net_device
*dev
,
1443 struct iw_request_info
*info
,
1444 union iwreq_data
*wrqu
, char *extra
)
1446 struct sockaddr
*ap_addr
= &wrqu
->ap_addr
;
1447 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1448 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1451 wiphy_lock(&rdev
->wiphy
);
1452 switch (wdev
->iftype
) {
1453 case NL80211_IFTYPE_ADHOC
:
1454 ret
= cfg80211_ibss_wext_giwap(dev
, info
, ap_addr
, extra
);
1456 case NL80211_IFTYPE_STATION
:
1457 ret
= cfg80211_mgd_wext_giwap(dev
, info
, ap_addr
, extra
);
1463 wiphy_unlock(&rdev
->wiphy
);
1468 static int cfg80211_wext_siwessid(struct net_device
*dev
,
1469 struct iw_request_info
*info
,
1470 union iwreq_data
*wrqu
, char *ssid
)
1472 struct iw_point
*data
= &wrqu
->data
;
1473 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1474 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1477 wiphy_lock(&rdev
->wiphy
);
1478 switch (wdev
->iftype
) {
1479 case NL80211_IFTYPE_ADHOC
:
1480 ret
= cfg80211_ibss_wext_siwessid(dev
, info
, data
, ssid
);
1482 case NL80211_IFTYPE_STATION
:
1483 ret
= cfg80211_mgd_wext_siwessid(dev
, info
, data
, ssid
);
1489 wiphy_unlock(&rdev
->wiphy
);
1494 static int cfg80211_wext_giwessid(struct net_device
*dev
,
1495 struct iw_request_info
*info
,
1496 union iwreq_data
*wrqu
, char *ssid
)
1498 struct iw_point
*data
= &wrqu
->data
;
1499 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1500 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1506 wiphy_lock(&rdev
->wiphy
);
1507 switch (wdev
->iftype
) {
1508 case NL80211_IFTYPE_ADHOC
:
1509 ret
= cfg80211_ibss_wext_giwessid(dev
, info
, data
, ssid
);
1511 case NL80211_IFTYPE_STATION
:
1512 ret
= cfg80211_mgd_wext_giwessid(dev
, info
, data
, ssid
);
1518 wiphy_unlock(&rdev
->wiphy
);
1523 static int cfg80211_wext_siwpmksa(struct net_device
*dev
,
1524 struct iw_request_info
*info
,
1525 union iwreq_data
*wrqu
, char *extra
)
1527 struct wireless_dev
*wdev
= dev
->ieee80211_ptr
;
1528 struct cfg80211_registered_device
*rdev
= wiphy_to_rdev(wdev
->wiphy
);
1529 struct cfg80211_pmksa cfg_pmksa
;
1530 struct iw_pmksa
*pmksa
= (struct iw_pmksa
*)extra
;
1533 memset(&cfg_pmksa
, 0, sizeof(struct cfg80211_pmksa
));
1535 if (wdev
->iftype
!= NL80211_IFTYPE_STATION
)
1538 cfg_pmksa
.bssid
= pmksa
->bssid
.sa_data
;
1539 cfg_pmksa
.pmkid
= pmksa
->pmkid
;
1541 wiphy_lock(&rdev
->wiphy
);
1542 switch (pmksa
->cmd
) {
1544 if (!rdev
->ops
->set_pmksa
) {
1549 ret
= rdev_set_pmksa(rdev
, dev
, &cfg_pmksa
);
1551 case IW_PMKSA_REMOVE
:
1552 if (!rdev
->ops
->del_pmksa
) {
1557 ret
= rdev_del_pmksa(rdev
, dev
, &cfg_pmksa
);
1559 case IW_PMKSA_FLUSH
:
1560 if (!rdev
->ops
->flush_pmksa
) {
1565 ret
= rdev_flush_pmksa(rdev
, dev
);
1571 wiphy_unlock(&rdev
->wiphy
);
1576 static const iw_handler cfg80211_handlers
[] = {
1577 IW_HANDLER(SIOCGIWNAME
, cfg80211_wext_giwname
),
1578 IW_HANDLER(SIOCSIWFREQ
, cfg80211_wext_siwfreq
),
1579 IW_HANDLER(SIOCGIWFREQ
, cfg80211_wext_giwfreq
),
1580 IW_HANDLER(SIOCSIWMODE
, cfg80211_wext_siwmode
),
1581 IW_HANDLER(SIOCGIWMODE
, cfg80211_wext_giwmode
),
1582 IW_HANDLER(SIOCGIWRANGE
, cfg80211_wext_giwrange
),
1583 IW_HANDLER(SIOCSIWAP
, cfg80211_wext_siwap
),
1584 IW_HANDLER(SIOCGIWAP
, cfg80211_wext_giwap
),
1585 IW_HANDLER(SIOCSIWMLME
, cfg80211_wext_siwmlme
),
1586 IW_HANDLER(SIOCSIWSCAN
, cfg80211_wext_siwscan
),
1587 IW_HANDLER(SIOCGIWSCAN
, cfg80211_wext_giwscan
),
1588 IW_HANDLER(SIOCSIWESSID
, cfg80211_wext_siwessid
),
1589 IW_HANDLER(SIOCGIWESSID
, cfg80211_wext_giwessid
),
1590 IW_HANDLER(SIOCSIWRATE
, cfg80211_wext_siwrate
),
1591 IW_HANDLER(SIOCGIWRATE
, cfg80211_wext_giwrate
),
1592 IW_HANDLER(SIOCSIWRTS
, cfg80211_wext_siwrts
),
1593 IW_HANDLER(SIOCGIWRTS
, cfg80211_wext_giwrts
),
1594 IW_HANDLER(SIOCSIWFRAG
, cfg80211_wext_siwfrag
),
1595 IW_HANDLER(SIOCGIWFRAG
, cfg80211_wext_giwfrag
),
1596 IW_HANDLER(SIOCSIWTXPOW
, cfg80211_wext_siwtxpower
),
1597 IW_HANDLER(SIOCGIWTXPOW
, cfg80211_wext_giwtxpower
),
1598 IW_HANDLER(SIOCSIWRETRY
, cfg80211_wext_siwretry
),
1599 IW_HANDLER(SIOCGIWRETRY
, cfg80211_wext_giwretry
),
1600 IW_HANDLER(SIOCSIWENCODE
, cfg80211_wext_siwencode
),
1601 IW_HANDLER(SIOCGIWENCODE
, cfg80211_wext_giwencode
),
1602 IW_HANDLER(SIOCSIWPOWER
, cfg80211_wext_siwpower
),
1603 IW_HANDLER(SIOCGIWPOWER
, cfg80211_wext_giwpower
),
1604 IW_HANDLER(SIOCSIWGENIE
, cfg80211_wext_siwgenie
),
1605 IW_HANDLER(SIOCSIWAUTH
, cfg80211_wext_siwauth
),
1606 IW_HANDLER(SIOCGIWAUTH
, cfg80211_wext_giwauth
),
1607 IW_HANDLER(SIOCSIWENCODEEXT
, cfg80211_wext_siwencodeext
),
1608 IW_HANDLER(SIOCSIWPMKSA
, cfg80211_wext_siwpmksa
),
1611 const struct iw_handler_def cfg80211_wext_handler
= {
1612 .num_standard
= ARRAY_SIZE(cfg80211_handlers
),
1613 .standard
= cfg80211_handlers
,
1614 .get_wireless_stats
= cfg80211_wireless_stats
,