Lines Matching +full:fixed +full:- +full:links
1 // SPDX-License-Identifier: GPL-2.0
3 * cfg80211 - wext compat code
9 * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
10 * Copyright (C) 2019-2023 Intel Corporation
21 #include <net/cfg80211-wext.h>
22 #include "wext-compat.h"
24 #include "rdev-ops.h"
30 strcpy(wrqu->name, "IEEE 802.11"); in cfg80211_wext_giwname()
38 __u32 *mode = &wrqu->mode; in cfg80211_wext_siwmode()
39 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwmode()
45 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwmode()
58 return -EINVAL; in cfg80211_wext_siwmode()
61 if (type == wdev->iftype) in cfg80211_wext_siwmode()
66 wiphy_lock(wdev->wiphy); in cfg80211_wext_siwmode()
68 wiphy_unlock(wdev->wiphy); in cfg80211_wext_siwmode()
77 __u32 *mode = &wrqu->mode; in cfg80211_wext_giwmode()
78 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwmode()
81 return -EOPNOTSUPP; in cfg80211_wext_giwmode()
83 switch (wdev->iftype) { in cfg80211_wext_giwmode()
115 struct iw_point *data = &wrqu->data; in cfg80211_wext_giwrange()
116 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrange()
122 return -EOPNOTSUPP; in cfg80211_wext_giwrange()
124 data->length = sizeof(struct iw_range); in cfg80211_wext_giwrange()
127 range->we_version_compiled = WIRELESS_EXT; in cfg80211_wext_giwrange()
128 range->we_version_source = 21; in cfg80211_wext_giwrange()
129 range->retry_capa = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
130 range->retry_flags = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
131 range->min_retry = 0; in cfg80211_wext_giwrange()
132 range->max_retry = 255; in cfg80211_wext_giwrange()
133 range->min_rts = 0; in cfg80211_wext_giwrange()
134 range->max_rts = 2347; in cfg80211_wext_giwrange()
135 range->min_frag = 256; in cfg80211_wext_giwrange()
136 range->max_frag = 2346; in cfg80211_wext_giwrange()
138 range->max_encoding_tokens = 4; in cfg80211_wext_giwrange()
140 range->max_qual.updated = IW_QUAL_NOISE_INVALID; in cfg80211_wext_giwrange()
142 switch (wdev->wiphy->signal_type) { in cfg80211_wext_giwrange()
146 range->max_qual.level = (u8)-110; in cfg80211_wext_giwrange()
147 range->max_qual.qual = 70; in cfg80211_wext_giwrange()
148 range->avg_qual.qual = 35; in cfg80211_wext_giwrange()
149 range->max_qual.updated |= IW_QUAL_DBM; in cfg80211_wext_giwrange()
150 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
151 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
154 range->max_qual.level = 100; in cfg80211_wext_giwrange()
155 range->max_qual.qual = 100; in cfg80211_wext_giwrange()
156 range->avg_qual.qual = 50; in cfg80211_wext_giwrange()
157 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
158 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
162 range->avg_qual.level = range->max_qual.level / 2; in cfg80211_wext_giwrange()
163 range->avg_qual.noise = range->max_qual.noise / 2; in cfg80211_wext_giwrange()
164 range->avg_qual.updated = range->max_qual.updated; in cfg80211_wext_giwrange()
166 for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) { in cfg80211_wext_giwrange()
167 switch (wdev->wiphy->cipher_suites[i]) { in cfg80211_wext_giwrange()
169 range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP | in cfg80211_wext_giwrange()
174 range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP | in cfg80211_wext_giwrange()
179 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
184 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
193 sband = wdev->wiphy->bands[band]; in cfg80211_wext_giwrange()
198 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { in cfg80211_wext_giwrange()
199 struct ieee80211_channel *chan = &sband->channels[i]; in cfg80211_wext_giwrange()
201 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { in cfg80211_wext_giwrange()
202 range->freq[c].i = in cfg80211_wext_giwrange()
204 chan->center_freq); in cfg80211_wext_giwrange()
205 range->freq[c].m = chan->center_freq; in cfg80211_wext_giwrange()
206 range->freq[c].e = 6; in cfg80211_wext_giwrange()
211 range->num_channels = c; in cfg80211_wext_giwrange()
212 range->num_frequency = c; in cfg80211_wext_giwrange()
214 IW_EVENT_CAPA_SET_KERNEL(range->event_capa); in cfg80211_wext_giwrange()
215 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); in cfg80211_wext_giwrange()
216 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); in cfg80211_wext_giwrange()
218 if (wdev->wiphy->max_scan_ssids > 0) in cfg80211_wext_giwrange()
219 range->scan_capa |= IW_SCAN_CAPA_ESSID; in cfg80211_wext_giwrange()
227 * cfg80211_wext_freq - get wext frequency for non-"auto"
235 * Parse frequency - return 0 for auto and in cfg80211_wext_freq()
236 * -EINVAL for impossible things. in cfg80211_wext_freq()
238 if (freq->e == 0) { in cfg80211_wext_freq()
240 if (freq->m < 0) in cfg80211_wext_freq()
242 if (freq->m > 14) in cfg80211_wext_freq()
244 return ieee80211_channel_to_frequency(freq->m, band); in cfg80211_wext_freq()
247 for (i = 0; i < freq->e; i++) in cfg80211_wext_freq()
250 return -EINVAL; in cfg80211_wext_freq()
251 return freq->m / div; in cfg80211_wext_freq()
259 struct iw_param *rts = &wrqu->rts; in cfg80211_wext_siwrts()
260 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrts()
261 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrts()
262 u32 orts = wdev->wiphy->rts_threshold; in cfg80211_wext_siwrts()
265 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwrts()
266 if (rts->disabled || !rts->fixed) { in cfg80211_wext_siwrts()
267 wdev->wiphy->rts_threshold = (u32) -1; in cfg80211_wext_siwrts()
268 } else if (rts->value < 0) { in cfg80211_wext_siwrts()
269 err = -EINVAL; in cfg80211_wext_siwrts()
272 wdev->wiphy->rts_threshold = rts->value; in cfg80211_wext_siwrts()
278 wdev->wiphy->rts_threshold = orts; in cfg80211_wext_siwrts()
281 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwrts()
290 struct iw_param *rts = &wrqu->rts; in cfg80211_wext_giwrts()
291 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrts()
293 rts->value = wdev->wiphy->rts_threshold; in cfg80211_wext_giwrts()
294 rts->disabled = rts->value == (u32) -1; in cfg80211_wext_giwrts()
295 rts->fixed = 1; in cfg80211_wext_giwrts()
305 struct iw_param *frag = &wrqu->frag; in cfg80211_wext_siwfrag()
306 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfrag()
307 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfrag()
308 u32 ofrag = wdev->wiphy->frag_threshold; in cfg80211_wext_siwfrag()
311 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwfrag()
312 if (frag->disabled || !frag->fixed) { in cfg80211_wext_siwfrag()
313 wdev->wiphy->frag_threshold = (u32) -1; in cfg80211_wext_siwfrag()
314 } else if (frag->value < 256) { in cfg80211_wext_siwfrag()
315 err = -EINVAL; in cfg80211_wext_siwfrag()
319 wdev->wiphy->frag_threshold = frag->value & ~0x1; in cfg80211_wext_siwfrag()
324 wdev->wiphy->frag_threshold = ofrag; in cfg80211_wext_siwfrag()
326 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwfrag()
336 struct iw_param *frag = &wrqu->frag; in cfg80211_wext_giwfrag()
337 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfrag()
339 frag->value = wdev->wiphy->frag_threshold; in cfg80211_wext_giwfrag()
340 frag->disabled = frag->value == (u32) -1; in cfg80211_wext_giwfrag()
341 frag->fixed = 1; in cfg80211_wext_giwfrag()
351 struct iw_param *retry = &wrqu->retry; in cfg80211_wext_siwretry()
352 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwretry()
353 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwretry()
355 u8 olong = wdev->wiphy->retry_long; in cfg80211_wext_siwretry()
356 u8 oshort = wdev->wiphy->retry_short; in cfg80211_wext_siwretry()
359 if (retry->disabled || retry->value < 1 || retry->value > 255 || in cfg80211_wext_siwretry()
360 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) in cfg80211_wext_siwretry()
361 return -EINVAL; in cfg80211_wext_siwretry()
363 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwretry()
364 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_siwretry()
365 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
367 } else if (retry->flags & IW_RETRY_SHORT) { in cfg80211_wext_siwretry()
368 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
371 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
372 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
379 wdev->wiphy->retry_short = oshort; in cfg80211_wext_siwretry()
380 wdev->wiphy->retry_long = olong; in cfg80211_wext_siwretry()
382 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwretry()
391 struct iw_param *retry = &wrqu->retry; in cfg80211_wext_giwretry()
392 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwretry()
394 retry->disabled = 0; in cfg80211_wext_giwretry()
396 if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) { in cfg80211_wext_giwretry()
401 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT; in cfg80211_wext_giwretry()
402 retry->value = wdev->wiphy->retry_short; in cfg80211_wext_giwretry()
403 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short) in cfg80211_wext_giwretry()
404 retry->flags |= IW_RETRY_LONG; in cfg80211_wext_giwretry()
409 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_giwretry()
410 retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in cfg80211_wext_giwretry()
411 retry->value = wdev->wiphy->retry_long; in cfg80211_wext_giwretry()
423 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_set_encryption()
427 if (wdev->valid_links) in cfg80211_set_encryption()
428 return -EINVAL; in cfg80211_set_encryption()
431 return -EINVAL; in cfg80211_set_encryption()
437 if (!wdev->wext.keys) { in cfg80211_set_encryption()
438 wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys), in cfg80211_set_encryption()
440 if (!wdev->wext.keys) in cfg80211_set_encryption()
441 return -ENOMEM; in cfg80211_set_encryption()
443 wdev->wext.keys->params[i].key = in cfg80211_set_encryption()
444 wdev->wext.keys->data[i]; in cfg80211_set_encryption()
447 if (wdev->iftype != NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
448 wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_set_encryption()
449 return -EOPNOTSUPP; in cfg80211_set_encryption()
451 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in cfg80211_set_encryption()
452 if (!wdev->connected) in cfg80211_set_encryption()
453 return -ENOLINK; in cfg80211_set_encryption()
455 if (!rdev->ops->set_default_mgmt_key) in cfg80211_set_encryption()
456 return -EOPNOTSUPP; in cfg80211_set_encryption()
459 return -EINVAL; in cfg80211_set_encryption()
461 return -EINVAL; in cfg80211_set_encryption()
465 if (wdev->connected || in cfg80211_set_encryption()
466 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
467 wdev->u.ibss.current_bss)) { in cfg80211_set_encryption()
472 if (idx == wdev->wext.default_key && in cfg80211_set_encryption()
473 wdev->iftype == NL80211_IFTYPE_ADHOC) { in cfg80211_set_encryption()
474 cfg80211_leave_ibss(rdev, wdev->netdev, true); in cfg80211_set_encryption()
479 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) in cfg80211_set_encryption()
480 err = -ENOENT; in cfg80211_set_encryption()
482 err = rdev_del_key(rdev, dev, -1, idx, pairwise, in cfg80211_set_encryption()
485 wdev->wext.connect.privacy = false; in cfg80211_set_encryption()
490 if (err == -ENOENT) in cfg80211_set_encryption()
494 memset(wdev->wext.keys->data[idx], 0, in cfg80211_set_encryption()
495 sizeof(wdev->wext.keys->data[idx])); in cfg80211_set_encryption()
496 wdev->wext.keys->params[idx].key_len = 0; in cfg80211_set_encryption()
497 wdev->wext.keys->params[idx].cipher = 0; in cfg80211_set_encryption()
499 if (idx == wdev->wext.default_key) in cfg80211_set_encryption()
500 wdev->wext.default_key = -1; in cfg80211_set_encryption()
501 else if (idx == wdev->wext.default_mgmt_key) in cfg80211_set_encryption()
502 wdev->wext.default_mgmt_key = -1; in cfg80211_set_encryption()
515 return -EINVAL; in cfg80211_set_encryption()
518 if (wdev->connected || in cfg80211_set_encryption()
519 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
520 wdev->u.ibss.current_bss)) in cfg80211_set_encryption()
521 err = rdev_add_key(rdev, dev, -1, idx, pairwise, addr, params); in cfg80211_set_encryption()
522 else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 && in cfg80211_set_encryption()
523 params->cipher != WLAN_CIPHER_SUITE_WEP104) in cfg80211_set_encryption()
524 return -EINVAL; in cfg80211_set_encryption()
533 if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 || in cfg80211_set_encryption()
534 params->cipher == WLAN_CIPHER_SUITE_WEP104)) { in cfg80211_set_encryption()
535 wdev->wext.keys->params[idx] = *params; in cfg80211_set_encryption()
536 memcpy(wdev->wext.keys->data[idx], in cfg80211_set_encryption()
537 params->key, params->key_len); in cfg80211_set_encryption()
538 wdev->wext.keys->params[idx].key = in cfg80211_set_encryption()
539 wdev->wext.keys->data[idx]; in cfg80211_set_encryption()
542 if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 || in cfg80211_set_encryption()
543 params->cipher == WLAN_CIPHER_SUITE_WEP104) && in cfg80211_set_encryption()
544 (tx_key || (!addr && wdev->wext.default_key == -1))) { in cfg80211_set_encryption()
545 if (wdev->connected || in cfg80211_set_encryption()
546 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
547 wdev->u.ibss.current_bss)) { in cfg80211_set_encryption()
553 if (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
554 wdev->wext.default_key == -1) { in cfg80211_set_encryption()
555 cfg80211_leave_ibss(rdev, wdev->netdev, true); in cfg80211_set_encryption()
558 err = rdev_set_default_key(rdev, dev, -1, idx, true, in cfg80211_set_encryption()
562 wdev->wext.default_key = idx; in cfg80211_set_encryption()
569 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && in cfg80211_set_encryption()
570 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { in cfg80211_set_encryption()
571 if (wdev->connected || in cfg80211_set_encryption()
572 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_set_encryption()
573 wdev->u.ibss.current_bss)) in cfg80211_set_encryption()
574 err = rdev_set_default_mgmt_key(rdev, dev, -1, idx); in cfg80211_set_encryption()
576 wdev->wext.default_mgmt_key = idx; in cfg80211_set_encryption()
587 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_siwencode()
588 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencode()
589 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencode()
594 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencode()
595 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencode()
596 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
598 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencode()
599 if (!rdev->ops->del_key || in cfg80211_wext_siwencode()
600 !rdev->ops->add_key || in cfg80211_wext_siwencode()
601 !rdev->ops->set_default_key) in cfg80211_wext_siwencode()
602 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
604 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwencode()
605 if (wdev->valid_links) { in cfg80211_wext_siwencode()
606 err = -EOPNOTSUPP; in cfg80211_wext_siwencode()
610 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencode()
612 idx = wdev->wext.default_key; in cfg80211_wext_siwencode()
616 err = -EINVAL; in cfg80211_wext_siwencode()
619 idx--; in cfg80211_wext_siwencode()
622 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencode()
624 else if (erq->length == 0) { in cfg80211_wext_siwencode()
625 /* No key data - just set the default TX key index */ in cfg80211_wext_siwencode()
627 if (wdev->connected || in cfg80211_wext_siwencode()
628 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_wext_siwencode()
629 wdev->u.ibss.current_bss)) in cfg80211_wext_siwencode()
630 err = rdev_set_default_key(rdev, dev, -1, idx, true, in cfg80211_wext_siwencode()
633 wdev->wext.default_key = idx; in cfg80211_wext_siwencode()
639 params.key_len = erq->length; in cfg80211_wext_siwencode()
640 if (erq->length == 5) { in cfg80211_wext_siwencode()
642 } else if (erq->length == 13) { in cfg80211_wext_siwencode()
645 err = -EINVAL; in cfg80211_wext_siwencode()
650 wdev->wext.default_key == -1, in cfg80211_wext_siwencode()
653 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwencode()
662 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_siwencodeext()
663 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencodeext()
664 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencodeext()
673 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencodeext()
674 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencodeext()
675 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
677 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencodeext()
678 if (!rdev->ops->del_key || in cfg80211_wext_siwencodeext()
679 !rdev->ops->add_key || in cfg80211_wext_siwencodeext()
680 !rdev->ops->set_default_key) in cfg80211_wext_siwencodeext()
681 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
683 if (wdev->valid_links) in cfg80211_wext_siwencodeext()
684 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
686 switch (ext->alg) { in cfg80211_wext_siwencodeext()
692 if (ext->key_len == 5) in cfg80211_wext_siwencodeext()
694 else if (ext->key_len == 13) in cfg80211_wext_siwencodeext()
697 return -EINVAL; in cfg80211_wext_siwencodeext()
709 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
712 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencodeext()
715 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencodeext()
718 idx = wdev->wext.default_mgmt_key; in cfg80211_wext_siwencodeext()
720 return -EINVAL; in cfg80211_wext_siwencodeext()
722 idx--; in cfg80211_wext_siwencodeext()
725 idx = wdev->wext.default_key; in cfg80211_wext_siwencodeext()
727 return -EINVAL; in cfg80211_wext_siwencodeext()
729 idx--; in cfg80211_wext_siwencodeext()
732 addr = ext->addr.sa_data; in cfg80211_wext_siwencodeext()
737 params.key = ext->key; in cfg80211_wext_siwencodeext()
738 params.key_len = ext->key_len; in cfg80211_wext_siwencodeext()
741 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { in cfg80211_wext_siwencodeext()
742 params.seq = ext->rx_seq; in cfg80211_wext_siwencodeext()
746 wiphy_lock(wdev->wiphy); in cfg80211_wext_siwencodeext()
749 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY), in cfg80211_wext_siwencodeext()
751 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, in cfg80211_wext_siwencodeext()
753 wiphy_unlock(wdev->wiphy); in cfg80211_wext_siwencodeext()
762 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_giwencode()
763 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwencode()
766 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_giwencode()
767 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_giwencode()
768 return -EOPNOTSUPP; in cfg80211_wext_giwencode()
770 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_giwencode()
772 idx = wdev->wext.default_key; in cfg80211_wext_giwencode()
776 return -EINVAL; in cfg80211_wext_giwencode()
778 idx--; in cfg80211_wext_giwencode()
780 erq->flags = idx + 1; in cfg80211_wext_giwencode()
782 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) { in cfg80211_wext_giwencode()
783 erq->flags |= IW_ENCODE_DISABLED; in cfg80211_wext_giwencode()
784 erq->length = 0; in cfg80211_wext_giwencode()
788 erq->length = min_t(size_t, erq->length, in cfg80211_wext_giwencode()
789 wdev->wext.keys->params[idx].key_len); in cfg80211_wext_giwencode()
790 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length); in cfg80211_wext_giwencode()
791 erq->flags |= IW_ENCODE_ENABLED; in cfg80211_wext_giwencode()
800 struct iw_freq *wextfreq = &wrqu->freq; in cfg80211_wext_siwfreq()
801 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfreq()
802 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfreq()
808 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwfreq()
810 switch (wdev->iftype) { in cfg80211_wext_siwfreq()
824 ret = -EINVAL; in cfg80211_wext_siwfreq()
828 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
830 ret = -EINVAL; in cfg80211_wext_siwfreq()
842 ret = -EINVAL; in cfg80211_wext_siwfreq()
846 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
848 ret = -EINVAL; in cfg80211_wext_siwfreq()
854 ret = -EOPNOTSUPP; in cfg80211_wext_siwfreq()
858 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwfreq()
867 struct iw_freq *freq = &wrqu->freq; in cfg80211_wext_giwfreq()
868 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfreq()
869 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwfreq()
873 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwfreq()
874 switch (wdev->iftype) { in cfg80211_wext_giwfreq()
882 if (!rdev->ops->get_channel) { in cfg80211_wext_giwfreq()
883 ret = -EINVAL; in cfg80211_wext_giwfreq()
890 freq->m = chandef.chan->center_freq; in cfg80211_wext_giwfreq()
891 freq->e = 6; in cfg80211_wext_giwfreq()
895 ret = -EINVAL; in cfg80211_wext_giwfreq()
899 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwfreq()
908 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwtxpower()
909 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwtxpower()
914 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_siwtxpower()
915 return -EINVAL; in cfg80211_wext_siwtxpower()
916 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_siwtxpower()
917 return -EINVAL; in cfg80211_wext_siwtxpower()
919 if (!rdev->ops->set_tx_power) in cfg80211_wext_siwtxpower()
920 return -EOPNOTSUPP; in cfg80211_wext_siwtxpower()
923 if (!data->txpower.disabled) { in cfg80211_wext_siwtxpower()
924 rfkill_set_sw_state(rdev->wiphy.rfkill, false); in cfg80211_wext_siwtxpower()
926 if (data->txpower.fixed) { in cfg80211_wext_siwtxpower()
931 if (data->txpower.value < 0) in cfg80211_wext_siwtxpower()
932 return -EINVAL; in cfg80211_wext_siwtxpower()
933 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
941 if (data->txpower.value < 0) { in cfg80211_wext_siwtxpower()
944 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
949 if (rfkill_set_sw_state(rdev->wiphy.rfkill, true)) in cfg80211_wext_siwtxpower()
950 schedule_work(&rdev->rfkill_block); in cfg80211_wext_siwtxpower()
954 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
956 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
965 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwtxpower()
966 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwtxpower()
969 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_giwtxpower()
970 return -EINVAL; in cfg80211_wext_giwtxpower()
971 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_giwtxpower()
972 return -EINVAL; in cfg80211_wext_giwtxpower()
974 if (!rdev->ops->get_tx_power) in cfg80211_wext_giwtxpower()
975 return -EOPNOTSUPP; in cfg80211_wext_giwtxpower()
977 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
979 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
984 data->txpower.fixed = 1; in cfg80211_wext_giwtxpower()
985 data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill); in cfg80211_wext_giwtxpower()
986 data->txpower.value = val; in cfg80211_wext_giwtxpower()
987 data->txpower.flags = IW_TXPOW_DBM; in cfg80211_wext_giwtxpower()
998 return -EINVAL; in cfg80211_set_auth_alg()
1003 return -EINVAL; in cfg80211_set_auth_alg()
1007 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; in cfg80211_set_auth_alg()
1012 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; in cfg80211_set_auth_alg()
1017 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; in cfg80211_set_auth_alg()
1021 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_set_auth_alg()
1031 return -EINVAL; in cfg80211_set_wpa_version()
1036 return -EINVAL; in cfg80211_set_wpa_version()
1039 wdev->wext.connect.crypto.wpa_versions &= in cfg80211_set_wpa_version()
1043 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1047 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1056 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1059 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1062 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1065 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1068 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1071 wdev->wext.connect.crypto.cipher_group = 0; in cfg80211_set_cipher_group()
1073 return -EINVAL; in cfg80211_set_cipher_group()
1081 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; in cfg80211_set_cipher_pairwise()
1110 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; in cfg80211_set_cipher_pairwise()
1122 return -EINVAL; in cfg80211_set_key_mgt()
1125 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1131 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1136 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; in cfg80211_set_key_mgt()
1145 struct iw_param *data = &wrqu->param; in cfg80211_wext_siwauth()
1146 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwauth()
1148 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwauth()
1149 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1151 switch (data->flags & IW_AUTH_INDEX) { in cfg80211_wext_siwauth()
1153 wdev->wext.connect.privacy = data->value; in cfg80211_wext_siwauth()
1156 return cfg80211_set_wpa_version(wdev, data->value); in cfg80211_wext_siwauth()
1158 return cfg80211_set_cipher_group(wdev, data->value); in cfg80211_wext_siwauth()
1160 return cfg80211_set_key_mgt(wdev, data->value); in cfg80211_wext_siwauth()
1162 return cfg80211_set_cipher_pairwise(wdev, data->value); in cfg80211_wext_siwauth()
1164 return cfg80211_set_auth_alg(wdev, data->value); in cfg80211_wext_siwauth()
1171 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1181 return -EOPNOTSUPP; in cfg80211_wext_giwauth()
1188 struct iw_param *wrq = &wrqu->power; in cfg80211_wext_siwpower()
1189 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpower()
1190 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpower()
1192 int timeout = wdev->ps_timeout; in cfg80211_wext_siwpower()
1195 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpower()
1196 return -EINVAL; in cfg80211_wext_siwpower()
1198 if (!rdev->ops->set_power_mgmt) in cfg80211_wext_siwpower()
1199 return -EOPNOTSUPP; in cfg80211_wext_siwpower()
1201 if (wrq->disabled) { in cfg80211_wext_siwpower()
1204 switch (wrq->flags & IW_POWER_MODE) { in cfg80211_wext_siwpower()
1211 return -EINVAL; in cfg80211_wext_siwpower()
1214 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) in cfg80211_wext_siwpower()
1215 return -EINVAL; in cfg80211_wext_siwpower()
1217 if (wrq->flags & IW_POWER_TIMEOUT) in cfg80211_wext_siwpower()
1218 timeout = wrq->value / 1000; in cfg80211_wext_siwpower()
1221 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpower()
1223 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpower()
1227 wdev->ps = ps; in cfg80211_wext_siwpower()
1228 wdev->ps_timeout = timeout; in cfg80211_wext_siwpower()
1238 struct iw_param *wrq = &wrqu->power; in cfg80211_wext_giwpower()
1239 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwpower()
1241 wrq->disabled = !wdev->ps; in cfg80211_wext_giwpower()
1250 struct iw_param *rate = &wrqu->bitrate; in cfg80211_wext_siwrate()
1251 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrate()
1252 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrate()
1254 u32 fixed, maxrate; in cfg80211_wext_siwrate() local
1259 if (!rdev->ops->set_bitrate_mask) in cfg80211_wext_siwrate()
1260 return -EOPNOTSUPP; in cfg80211_wext_siwrate()
1263 fixed = 0; in cfg80211_wext_siwrate()
1264 maxrate = (u32)-1; in cfg80211_wext_siwrate()
1266 if (rate->value < 0) { in cfg80211_wext_siwrate()
1268 } else if (rate->fixed) { in cfg80211_wext_siwrate()
1269 fixed = rate->value / 100000; in cfg80211_wext_siwrate()
1271 maxrate = rate->value / 100000; in cfg80211_wext_siwrate()
1275 sband = wdev->wiphy->bands[band]; in cfg80211_wext_siwrate()
1278 for (ridx = 0; ridx < sband->n_bitrates; ridx++) { in cfg80211_wext_siwrate()
1279 struct ieee80211_rate *srate = &sband->bitrates[ridx]; in cfg80211_wext_siwrate()
1280 if (fixed == srate->bitrate) { in cfg80211_wext_siwrate()
1285 if (srate->bitrate <= maxrate) { in cfg80211_wext_siwrate()
1293 return -EINVAL; in cfg80211_wext_siwrate()
1295 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwrate()
1296 if (dev->ieee80211_ptr->valid_links) in cfg80211_wext_siwrate()
1297 ret = -EOPNOTSUPP; in cfg80211_wext_siwrate()
1300 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwrate()
1309 struct iw_param *rate = &wrqu->bitrate; in cfg80211_wext_giwrate()
1310 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrate()
1311 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwrate()
1316 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_giwrate()
1317 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1319 if (!rdev->ops->get_station) in cfg80211_wext_giwrate()
1320 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1323 if (!wdev->valid_links && wdev->links[0].client.current_bss) in cfg80211_wext_giwrate()
1324 memcpy(addr, wdev->links[0].client.current_bss->pub.bssid, in cfg80211_wext_giwrate()
1327 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1331 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwrate()
1333 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwrate()
1338 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1342 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); in cfg80211_wext_giwrate()
1352 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wireless_stats()
1353 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wireless_stats()
1354 /* we are under RTNL - globally locked - so can use static structs */ in cfg80211_wireless_stats()
1360 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) in cfg80211_wireless_stats()
1363 if (!rdev->ops->get_station) in cfg80211_wireless_stats()
1367 wiphy_lock(&rdev->wiphy); in cfg80211_wireless_stats()
1368 if (wdev->valid_links || !wdev->links[0].client.current_bss) { in cfg80211_wireless_stats()
1369 wiphy_unlock(&rdev->wiphy); in cfg80211_wireless_stats()
1372 memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN); in cfg80211_wireless_stats()
1377 wiphy_unlock(&rdev->wiphy); in cfg80211_wireless_stats()
1384 switch (rdev->wiphy.signal_type) { in cfg80211_wireless_stats()
1392 if (sig < -110) in cfg80211_wireless_stats()
1393 sig = -110; in cfg80211_wireless_stats()
1394 else if (sig > -40) in cfg80211_wireless_stats()
1395 sig = -40; in cfg80211_wireless_stats()
1429 struct sockaddr *ap_addr = &wrqu->ap_addr; in cfg80211_wext_siwap()
1430 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwap()
1431 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwap()
1434 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwap()
1435 switch (wdev->iftype) { in cfg80211_wext_siwap()
1443 ret = -EOPNOTSUPP; in cfg80211_wext_siwap()
1446 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwap()
1455 struct sockaddr *ap_addr = &wrqu->ap_addr; in cfg80211_wext_giwap()
1456 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwap()
1457 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwap()
1460 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwap()
1461 switch (wdev->iftype) { in cfg80211_wext_giwap()
1469 ret = -EOPNOTSUPP; in cfg80211_wext_giwap()
1472 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwap()
1481 struct iw_point *data = &wrqu->data; in cfg80211_wext_siwessid()
1482 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwessid()
1483 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwessid()
1486 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwessid()
1487 switch (wdev->iftype) { in cfg80211_wext_siwessid()
1495 ret = -EOPNOTSUPP; in cfg80211_wext_siwessid()
1498 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwessid()
1507 struct iw_point *data = &wrqu->data; in cfg80211_wext_giwessid()
1508 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwessid()
1509 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwessid()
1512 data->flags = 0; in cfg80211_wext_giwessid()
1513 data->length = 0; in cfg80211_wext_giwessid()
1515 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwessid()
1516 switch (wdev->iftype) { in cfg80211_wext_giwessid()
1524 ret = -EOPNOTSUPP; in cfg80211_wext_giwessid()
1527 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwessid()
1536 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpmksa()
1537 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpmksa()
1544 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpmksa()
1545 return -EINVAL; in cfg80211_wext_siwpmksa()
1547 cfg_pmksa.bssid = pmksa->bssid.sa_data; in cfg80211_wext_siwpmksa()
1548 cfg_pmksa.pmkid = pmksa->pmkid; in cfg80211_wext_siwpmksa()
1550 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpmksa()
1551 switch (pmksa->cmd) { in cfg80211_wext_siwpmksa()
1553 if (!rdev->ops->set_pmksa) { in cfg80211_wext_siwpmksa()
1554 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1561 if (!rdev->ops->del_pmksa) { in cfg80211_wext_siwpmksa()
1562 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1569 if (!rdev->ops->flush_pmksa) { in cfg80211_wext_siwpmksa()
1570 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1577 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1580 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpmksa()