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-2022 Intel Corporation
21 #include <net/cfg80211-wext.h>
22 #include "wext-compat.h"
24 #include "rdev-ops.h"
38 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwmode()
44 rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwmode()
57 return -EINVAL; in cfg80211_wext_siwmode()
60 if (type == wdev->iftype) in cfg80211_wext_siwmode()
65 wiphy_lock(wdev->wiphy); in cfg80211_wext_siwmode()
67 wiphy_unlock(wdev->wiphy); in cfg80211_wext_siwmode()
76 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwmode()
79 return -EOPNOTSUPP; in cfg80211_wext_giwmode()
81 switch (wdev->iftype) { in cfg80211_wext_giwmode()
113 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrange()
119 return -EOPNOTSUPP; in cfg80211_wext_giwrange()
121 data->length = sizeof(struct iw_range); in cfg80211_wext_giwrange()
124 range->we_version_compiled = WIRELESS_EXT; in cfg80211_wext_giwrange()
125 range->we_version_source = 21; in cfg80211_wext_giwrange()
126 range->retry_capa = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
127 range->retry_flags = IW_RETRY_LIMIT; in cfg80211_wext_giwrange()
128 range->min_retry = 0; in cfg80211_wext_giwrange()
129 range->max_retry = 255; in cfg80211_wext_giwrange()
130 range->min_rts = 0; in cfg80211_wext_giwrange()
131 range->max_rts = 2347; in cfg80211_wext_giwrange()
132 range->min_frag = 256; in cfg80211_wext_giwrange()
133 range->max_frag = 2346; in cfg80211_wext_giwrange()
135 range->max_encoding_tokens = 4; in cfg80211_wext_giwrange()
137 range->max_qual.updated = IW_QUAL_NOISE_INVALID; in cfg80211_wext_giwrange()
139 switch (wdev->wiphy->signal_type) { in cfg80211_wext_giwrange()
143 range->max_qual.level = (u8)-110; in cfg80211_wext_giwrange()
144 range->max_qual.qual = 70; in cfg80211_wext_giwrange()
145 range->avg_qual.qual = 35; in cfg80211_wext_giwrange()
146 range->max_qual.updated |= IW_QUAL_DBM; in cfg80211_wext_giwrange()
147 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
148 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
151 range->max_qual.level = 100; in cfg80211_wext_giwrange()
152 range->max_qual.qual = 100; in cfg80211_wext_giwrange()
153 range->avg_qual.qual = 50; in cfg80211_wext_giwrange()
154 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; in cfg80211_wext_giwrange()
155 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; in cfg80211_wext_giwrange()
159 range->avg_qual.level = range->max_qual.level / 2; in cfg80211_wext_giwrange()
160 range->avg_qual.noise = range->max_qual.noise / 2; in cfg80211_wext_giwrange()
161 range->avg_qual.updated = range->max_qual.updated; in cfg80211_wext_giwrange()
163 for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) { in cfg80211_wext_giwrange()
164 switch (wdev->wiphy->cipher_suites[i]) { in cfg80211_wext_giwrange()
166 range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP | in cfg80211_wext_giwrange()
171 range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP | in cfg80211_wext_giwrange()
176 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
181 range->encoding_size[range->num_encoding_sizes++] = in cfg80211_wext_giwrange()
190 sband = wdev->wiphy->bands[band]; in cfg80211_wext_giwrange()
195 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { in cfg80211_wext_giwrange()
196 struct ieee80211_channel *chan = &sband->channels[i]; in cfg80211_wext_giwrange()
198 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { in cfg80211_wext_giwrange()
199 range->freq[c].i = in cfg80211_wext_giwrange()
201 chan->center_freq); in cfg80211_wext_giwrange()
202 range->freq[c].m = chan->center_freq; in cfg80211_wext_giwrange()
203 range->freq[c].e = 6; in cfg80211_wext_giwrange()
208 range->num_channels = c; in cfg80211_wext_giwrange()
209 range->num_frequency = c; in cfg80211_wext_giwrange()
211 IW_EVENT_CAPA_SET_KERNEL(range->event_capa); in cfg80211_wext_giwrange()
212 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); in cfg80211_wext_giwrange()
213 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); in cfg80211_wext_giwrange()
215 if (wdev->wiphy->max_scan_ssids > 0) in cfg80211_wext_giwrange()
216 range->scan_capa |= IW_SCAN_CAPA_ESSID; in cfg80211_wext_giwrange()
224 * cfg80211_wext_freq - get wext frequency for non-"auto"
232 * Parse frequency - return 0 for auto and in cfg80211_wext_freq()
233 * -EINVAL for impossible things. in cfg80211_wext_freq()
235 if (freq->e == 0) { in cfg80211_wext_freq()
237 if (freq->m < 0) in cfg80211_wext_freq()
239 if (freq->m > 14) in cfg80211_wext_freq()
241 return ieee80211_channel_to_frequency(freq->m, band); in cfg80211_wext_freq()
244 for (i = 0; i < freq->e; i++) in cfg80211_wext_freq()
247 return -EINVAL; in cfg80211_wext_freq()
248 return freq->m / div; in cfg80211_wext_freq()
256 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrts()
257 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrts()
258 u32 orts = wdev->wiphy->rts_threshold; in cfg80211_wext_siwrts()
261 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwrts()
262 if (rts->disabled || !rts->fixed) { in cfg80211_wext_siwrts()
263 wdev->wiphy->rts_threshold = (u32) -1; in cfg80211_wext_siwrts()
264 } else if (rts->value < 0) { in cfg80211_wext_siwrts()
265 err = -EINVAL; in cfg80211_wext_siwrts()
268 wdev->wiphy->rts_threshold = rts->value; in cfg80211_wext_siwrts()
274 wdev->wiphy->rts_threshold = orts; in cfg80211_wext_siwrts()
277 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwrts()
286 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrts()
288 rts->value = wdev->wiphy->rts_threshold; in cfg80211_wext_giwrts()
289 rts->disabled = rts->value == (u32) -1; in cfg80211_wext_giwrts()
290 rts->fixed = 1; in cfg80211_wext_giwrts()
300 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfrag()
301 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfrag()
302 u32 ofrag = wdev->wiphy->frag_threshold; in cfg80211_wext_siwfrag()
305 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwfrag()
306 if (frag->disabled || !frag->fixed) { in cfg80211_wext_siwfrag()
307 wdev->wiphy->frag_threshold = (u32) -1; in cfg80211_wext_siwfrag()
308 } else if (frag->value < 256) { in cfg80211_wext_siwfrag()
309 err = -EINVAL; in cfg80211_wext_siwfrag()
313 wdev->wiphy->frag_threshold = frag->value & ~0x1; in cfg80211_wext_siwfrag()
318 wdev->wiphy->frag_threshold = ofrag; in cfg80211_wext_siwfrag()
320 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwfrag()
330 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfrag()
332 frag->value = wdev->wiphy->frag_threshold; in cfg80211_wext_giwfrag()
333 frag->disabled = frag->value == (u32) -1; in cfg80211_wext_giwfrag()
334 frag->fixed = 1; in cfg80211_wext_giwfrag()
344 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwretry()
345 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwretry()
347 u8 olong = wdev->wiphy->retry_long; in cfg80211_wext_siwretry()
348 u8 oshort = wdev->wiphy->retry_short; in cfg80211_wext_siwretry()
351 if (retry->disabled || retry->value < 1 || retry->value > 255 || in cfg80211_wext_siwretry()
352 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT) in cfg80211_wext_siwretry()
353 return -EINVAL; in cfg80211_wext_siwretry()
355 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwretry()
356 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_siwretry()
357 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
359 } else if (retry->flags & IW_RETRY_SHORT) { in cfg80211_wext_siwretry()
360 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
363 wdev->wiphy->retry_short = retry->value; in cfg80211_wext_siwretry()
364 wdev->wiphy->retry_long = retry->value; in cfg80211_wext_siwretry()
371 wdev->wiphy->retry_short = oshort; in cfg80211_wext_siwretry()
372 wdev->wiphy->retry_long = olong; in cfg80211_wext_siwretry()
374 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwretry()
383 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwretry()
385 retry->disabled = 0; in cfg80211_wext_giwretry()
387 if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) { in cfg80211_wext_giwretry()
392 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT; in cfg80211_wext_giwretry()
393 retry->value = wdev->wiphy->retry_short; in cfg80211_wext_giwretry()
394 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short) in cfg80211_wext_giwretry()
395 retry->flags |= IW_RETRY_LONG; in cfg80211_wext_giwretry()
400 if (retry->flags & IW_RETRY_LONG) { in cfg80211_wext_giwretry()
401 retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; in cfg80211_wext_giwretry()
402 retry->value = wdev->wiphy->retry_long; in cfg80211_wext_giwretry()
414 struct wireless_dev *wdev = dev->ieee80211_ptr; in __cfg80211_set_encryption()
418 if (wdev->valid_links) in __cfg80211_set_encryption()
419 return -EINVAL; in __cfg80211_set_encryption()
422 return -EINVAL; in __cfg80211_set_encryption()
428 if (!wdev->wext.keys) { in __cfg80211_set_encryption()
429 wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys), in __cfg80211_set_encryption()
431 if (!wdev->wext.keys) in __cfg80211_set_encryption()
432 return -ENOMEM; in __cfg80211_set_encryption()
434 wdev->wext.keys->params[i].key = in __cfg80211_set_encryption()
435 wdev->wext.keys->data[i]; in __cfg80211_set_encryption()
438 if (wdev->iftype != NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
439 wdev->iftype != NL80211_IFTYPE_STATION) in __cfg80211_set_encryption()
440 return -EOPNOTSUPP; in __cfg80211_set_encryption()
442 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { in __cfg80211_set_encryption()
443 if (!wdev->connected) in __cfg80211_set_encryption()
444 return -ENOLINK; in __cfg80211_set_encryption()
446 if (!rdev->ops->set_default_mgmt_key) in __cfg80211_set_encryption()
447 return -EOPNOTSUPP; in __cfg80211_set_encryption()
450 return -EINVAL; in __cfg80211_set_encryption()
452 return -EINVAL; in __cfg80211_set_encryption()
456 if (wdev->connected || in __cfg80211_set_encryption()
457 (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
458 wdev->u.ibss.current_bss)) { in __cfg80211_set_encryption()
463 if (idx == wdev->wext.default_key && in __cfg80211_set_encryption()
464 wdev->iftype == NL80211_IFTYPE_ADHOC) { in __cfg80211_set_encryption()
465 __cfg80211_leave_ibss(rdev, wdev->netdev, true); in __cfg80211_set_encryption()
470 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) in __cfg80211_set_encryption()
471 err = -ENOENT; in __cfg80211_set_encryption()
473 err = rdev_del_key(rdev, dev, -1, idx, pairwise, in __cfg80211_set_encryption()
476 wdev->wext.connect.privacy = false; in __cfg80211_set_encryption()
481 if (err == -ENOENT) in __cfg80211_set_encryption()
485 memset(wdev->wext.keys->data[idx], 0, in __cfg80211_set_encryption()
486 sizeof(wdev->wext.keys->data[idx])); in __cfg80211_set_encryption()
487 wdev->wext.keys->params[idx].key_len = 0; in __cfg80211_set_encryption()
488 wdev->wext.keys->params[idx].cipher = 0; in __cfg80211_set_encryption()
490 if (idx == wdev->wext.default_key) in __cfg80211_set_encryption()
491 wdev->wext.default_key = -1; in __cfg80211_set_encryption()
492 else if (idx == wdev->wext.default_mgmt_key) in __cfg80211_set_encryption()
493 wdev->wext.default_mgmt_key = -1; in __cfg80211_set_encryption()
506 return -EINVAL; in __cfg80211_set_encryption()
509 if (wdev->connected || in __cfg80211_set_encryption()
510 (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
511 wdev->u.ibss.current_bss)) in __cfg80211_set_encryption()
512 err = rdev_add_key(rdev, dev, -1, idx, pairwise, addr, params); in __cfg80211_set_encryption()
513 else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 && in __cfg80211_set_encryption()
514 params->cipher != WLAN_CIPHER_SUITE_WEP104) in __cfg80211_set_encryption()
515 return -EINVAL; in __cfg80211_set_encryption()
524 if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 || in __cfg80211_set_encryption()
525 params->cipher == WLAN_CIPHER_SUITE_WEP104)) { in __cfg80211_set_encryption()
526 wdev->wext.keys->params[idx] = *params; in __cfg80211_set_encryption()
527 memcpy(wdev->wext.keys->data[idx], in __cfg80211_set_encryption()
528 params->key, params->key_len); in __cfg80211_set_encryption()
529 wdev->wext.keys->params[idx].key = in __cfg80211_set_encryption()
530 wdev->wext.keys->data[idx]; in __cfg80211_set_encryption()
533 if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 || in __cfg80211_set_encryption()
534 params->cipher == WLAN_CIPHER_SUITE_WEP104) && in __cfg80211_set_encryption()
535 (tx_key || (!addr && wdev->wext.default_key == -1))) { in __cfg80211_set_encryption()
536 if (wdev->connected || in __cfg80211_set_encryption()
537 (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
538 wdev->u.ibss.current_bss)) { in __cfg80211_set_encryption()
544 if (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
545 wdev->wext.default_key == -1) { in __cfg80211_set_encryption()
546 __cfg80211_leave_ibss(rdev, wdev->netdev, true); in __cfg80211_set_encryption()
549 err = rdev_set_default_key(rdev, dev, -1, idx, true, in __cfg80211_set_encryption()
553 wdev->wext.default_key = idx; in __cfg80211_set_encryption()
560 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && in __cfg80211_set_encryption()
561 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { in __cfg80211_set_encryption()
562 if (wdev->connected || in __cfg80211_set_encryption()
563 (wdev->iftype == NL80211_IFTYPE_ADHOC && in __cfg80211_set_encryption()
564 wdev->u.ibss.current_bss)) in __cfg80211_set_encryption()
565 err = rdev_set_default_mgmt_key(rdev, dev, -1, idx); in __cfg80211_set_encryption()
567 wdev->wext.default_mgmt_key = idx; in __cfg80211_set_encryption()
581 wdev_lock(dev->ieee80211_ptr); in cfg80211_set_encryption()
584 wdev_unlock(dev->ieee80211_ptr); in cfg80211_set_encryption()
593 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencode()
594 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencode()
599 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencode()
600 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencode()
601 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
603 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencode()
604 if (!rdev->ops->del_key || in cfg80211_wext_siwencode()
605 !rdev->ops->add_key || in cfg80211_wext_siwencode()
606 !rdev->ops->set_default_key) in cfg80211_wext_siwencode()
607 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
609 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwencode()
610 if (wdev->valid_links) { in cfg80211_wext_siwencode()
611 err = -EOPNOTSUPP; in cfg80211_wext_siwencode()
615 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencode()
617 idx = wdev->wext.default_key; in cfg80211_wext_siwencode()
621 err = -EINVAL; in cfg80211_wext_siwencode()
624 idx--; in cfg80211_wext_siwencode()
627 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencode()
629 else if (erq->length == 0) { in cfg80211_wext_siwencode()
630 /* No key data - just set the default TX key index */ in cfg80211_wext_siwencode()
633 if (wdev->connected || in cfg80211_wext_siwencode()
634 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_wext_siwencode()
635 wdev->u.ibss.current_bss)) in cfg80211_wext_siwencode()
636 err = rdev_set_default_key(rdev, dev, -1, idx, true, in cfg80211_wext_siwencode()
639 wdev->wext.default_key = idx; in cfg80211_wext_siwencode()
646 params.key_len = erq->length; in cfg80211_wext_siwencode()
647 if (erq->length == 5) { in cfg80211_wext_siwencode()
649 } else if (erq->length == 13) { in cfg80211_wext_siwencode()
652 err = -EINVAL; in cfg80211_wext_siwencode()
657 wdev->wext.default_key == -1, in cfg80211_wext_siwencode()
660 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwencode()
669 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencodeext()
670 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencodeext()
679 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencodeext()
680 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencodeext()
681 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
683 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencodeext()
684 if (!rdev->ops->del_key || in cfg80211_wext_siwencodeext()
685 !rdev->ops->add_key || in cfg80211_wext_siwencodeext()
686 !rdev->ops->set_default_key) in cfg80211_wext_siwencodeext()
687 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
690 if (wdev->valid_links) { in cfg80211_wext_siwencodeext()
692 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
696 switch (ext->alg) { in cfg80211_wext_siwencodeext()
702 if (ext->key_len == 5) in cfg80211_wext_siwencodeext()
704 else if (ext->key_len == 13) in cfg80211_wext_siwencodeext()
707 return -EINVAL; in cfg80211_wext_siwencodeext()
719 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
722 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencodeext()
725 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencodeext()
728 idx = wdev->wext.default_mgmt_key; in cfg80211_wext_siwencodeext()
730 return -EINVAL; in cfg80211_wext_siwencodeext()
732 idx--; in cfg80211_wext_siwencodeext()
735 idx = wdev->wext.default_key; in cfg80211_wext_siwencodeext()
737 return -EINVAL; in cfg80211_wext_siwencodeext()
739 idx--; in cfg80211_wext_siwencodeext()
742 addr = ext->addr.sa_data; in cfg80211_wext_siwencodeext()
747 params.key = ext->key; in cfg80211_wext_siwencodeext()
748 params.key_len = ext->key_len; in cfg80211_wext_siwencodeext()
751 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { in cfg80211_wext_siwencodeext()
752 params.seq = ext->rx_seq; in cfg80211_wext_siwencodeext()
756 wiphy_lock(wdev->wiphy); in cfg80211_wext_siwencodeext()
759 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY), in cfg80211_wext_siwencodeext()
761 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, in cfg80211_wext_siwencodeext()
763 wiphy_unlock(wdev->wiphy); in cfg80211_wext_siwencodeext()
772 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwencode()
775 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_giwencode()
776 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_giwencode()
777 return -EOPNOTSUPP; in cfg80211_wext_giwencode()
779 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_giwencode()
781 idx = wdev->wext.default_key; in cfg80211_wext_giwencode()
785 return -EINVAL; in cfg80211_wext_giwencode()
787 idx--; in cfg80211_wext_giwencode()
789 erq->flags = idx + 1; in cfg80211_wext_giwencode()
791 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) { in cfg80211_wext_giwencode()
792 erq->flags |= IW_ENCODE_DISABLED; in cfg80211_wext_giwencode()
793 erq->length = 0; in cfg80211_wext_giwencode()
797 erq->length = min_t(size_t, erq->length, in cfg80211_wext_giwencode()
798 wdev->wext.keys->params[idx].key_len); in cfg80211_wext_giwencode()
799 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length); in cfg80211_wext_giwencode()
800 erq->flags |= IW_ENCODE_ENABLED; in cfg80211_wext_giwencode()
809 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfreq()
810 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfreq()
816 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwfreq()
818 switch (wdev->iftype) { in cfg80211_wext_siwfreq()
832 ret = -EINVAL; in cfg80211_wext_siwfreq()
836 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
838 ret = -EINVAL; in cfg80211_wext_siwfreq()
850 ret = -EINVAL; in cfg80211_wext_siwfreq()
854 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
856 ret = -EINVAL; in cfg80211_wext_siwfreq()
862 ret = -EOPNOTSUPP; in cfg80211_wext_siwfreq()
866 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwfreq()
875 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfreq()
876 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwfreq()
880 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwfreq()
881 switch (wdev->iftype) { in cfg80211_wext_giwfreq()
889 if (!rdev->ops->get_channel) { in cfg80211_wext_giwfreq()
890 ret = -EINVAL; in cfg80211_wext_giwfreq()
897 freq->m = chandef.chan->center_freq; in cfg80211_wext_giwfreq()
898 freq->e = 6; in cfg80211_wext_giwfreq()
902 ret = -EINVAL; in cfg80211_wext_giwfreq()
906 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwfreq()
915 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwtxpower()
916 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwtxpower()
921 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_siwtxpower()
922 return -EINVAL; in cfg80211_wext_siwtxpower()
923 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_siwtxpower()
924 return -EINVAL; in cfg80211_wext_siwtxpower()
926 if (!rdev->ops->set_tx_power) in cfg80211_wext_siwtxpower()
927 return -EOPNOTSUPP; in cfg80211_wext_siwtxpower()
930 if (!data->txpower.disabled) { in cfg80211_wext_siwtxpower()
931 rfkill_set_sw_state(rdev->wiphy.rfkill, false); in cfg80211_wext_siwtxpower()
933 if (data->txpower.fixed) { in cfg80211_wext_siwtxpower()
938 if (data->txpower.value < 0) in cfg80211_wext_siwtxpower()
939 return -EINVAL; in cfg80211_wext_siwtxpower()
940 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
948 if (data->txpower.value < 0) { in cfg80211_wext_siwtxpower()
951 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
956 if (rfkill_set_sw_state(rdev->wiphy.rfkill, true)) in cfg80211_wext_siwtxpower()
957 schedule_work(&rdev->rfkill_block); in cfg80211_wext_siwtxpower()
961 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
963 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
972 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwtxpower()
973 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwtxpower()
976 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_giwtxpower()
977 return -EINVAL; in cfg80211_wext_giwtxpower()
978 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_giwtxpower()
979 return -EINVAL; in cfg80211_wext_giwtxpower()
981 if (!rdev->ops->get_tx_power) in cfg80211_wext_giwtxpower()
982 return -EOPNOTSUPP; in cfg80211_wext_giwtxpower()
984 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
986 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
991 data->txpower.fixed = 1; in cfg80211_wext_giwtxpower()
992 data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill); in cfg80211_wext_giwtxpower()
993 data->txpower.value = val; in cfg80211_wext_giwtxpower()
994 data->txpower.flags = IW_TXPOW_DBM; in cfg80211_wext_giwtxpower()
1005 return -EINVAL; in cfg80211_set_auth_alg()
1010 return -EINVAL; in cfg80211_set_auth_alg()
1014 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; in cfg80211_set_auth_alg()
1019 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; in cfg80211_set_auth_alg()
1024 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; in cfg80211_set_auth_alg()
1028 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_set_auth_alg()
1038 return -EINVAL; in cfg80211_set_wpa_version()
1043 return -EINVAL; in cfg80211_set_wpa_version()
1046 wdev->wext.connect.crypto.wpa_versions &= in cfg80211_set_wpa_version()
1050 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1054 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1063 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1066 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1069 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1072 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1075 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1078 wdev->wext.connect.crypto.cipher_group = 0; in cfg80211_set_cipher_group()
1080 return -EINVAL; in cfg80211_set_cipher_group()
1088 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; in cfg80211_set_cipher_pairwise()
1117 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; in cfg80211_set_cipher_pairwise()
1129 return -EINVAL; in cfg80211_set_key_mgt()
1132 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1138 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1143 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; in cfg80211_set_key_mgt()
1152 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwauth()
1154 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwauth()
1155 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1157 switch (data->flags & IW_AUTH_INDEX) { in cfg80211_wext_siwauth()
1159 wdev->wext.connect.privacy = data->value; in cfg80211_wext_siwauth()
1162 return cfg80211_set_wpa_version(wdev, data->value); in cfg80211_wext_siwauth()
1164 return cfg80211_set_cipher_group(wdev, data->value); in cfg80211_wext_siwauth()
1166 return cfg80211_set_key_mgt(wdev, data->value); in cfg80211_wext_siwauth()
1168 return cfg80211_set_cipher_pairwise(wdev, data->value); in cfg80211_wext_siwauth()
1170 return cfg80211_set_auth_alg(wdev, data->value); in cfg80211_wext_siwauth()
1177 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1187 return -EOPNOTSUPP; in cfg80211_wext_giwauth()
1194 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpower()
1195 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpower()
1197 int timeout = wdev->ps_timeout; in cfg80211_wext_siwpower()
1200 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpower()
1201 return -EINVAL; in cfg80211_wext_siwpower()
1203 if (!rdev->ops->set_power_mgmt) in cfg80211_wext_siwpower()
1204 return -EOPNOTSUPP; in cfg80211_wext_siwpower()
1206 if (wrq->disabled) { in cfg80211_wext_siwpower()
1209 switch (wrq->flags & IW_POWER_MODE) { in cfg80211_wext_siwpower()
1216 return -EINVAL; in cfg80211_wext_siwpower()
1219 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) in cfg80211_wext_siwpower()
1220 return -EINVAL; in cfg80211_wext_siwpower()
1222 if (wrq->flags & IW_POWER_TIMEOUT) in cfg80211_wext_siwpower()
1223 timeout = wrq->value / 1000; in cfg80211_wext_siwpower()
1226 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpower()
1228 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpower()
1232 wdev->ps = ps; in cfg80211_wext_siwpower()
1233 wdev->ps_timeout = timeout; in cfg80211_wext_siwpower()
1243 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwpower()
1245 wrq->disabled = !wdev->ps; in cfg80211_wext_giwpower()
1254 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrate()
1255 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrate()
1257 u32 fixed, maxrate; in cfg80211_wext_siwrate() local
1262 if (!rdev->ops->set_bitrate_mask) in cfg80211_wext_siwrate()
1263 return -EOPNOTSUPP; in cfg80211_wext_siwrate()
1266 fixed = 0; in cfg80211_wext_siwrate()
1267 maxrate = (u32)-1; in cfg80211_wext_siwrate()
1269 if (rate->value < 0) { in cfg80211_wext_siwrate()
1271 } else if (rate->fixed) { in cfg80211_wext_siwrate()
1272 fixed = rate->value / 100000; in cfg80211_wext_siwrate()
1274 maxrate = rate->value / 100000; in cfg80211_wext_siwrate()
1278 sband = wdev->wiphy->bands[band]; in cfg80211_wext_siwrate()
1281 for (ridx = 0; ridx < sband->n_bitrates; ridx++) { in cfg80211_wext_siwrate()
1282 struct ieee80211_rate *srate = &sband->bitrates[ridx]; in cfg80211_wext_siwrate()
1283 if (fixed == srate->bitrate) { in cfg80211_wext_siwrate()
1288 if (srate->bitrate <= maxrate) { in cfg80211_wext_siwrate()
1296 return -EINVAL; in cfg80211_wext_siwrate()
1298 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwrate()
1299 if (dev->ieee80211_ptr->valid_links) in cfg80211_wext_siwrate()
1300 ret = -EOPNOTSUPP; in cfg80211_wext_siwrate()
1303 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwrate()
1312 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrate()
1313 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwrate()
1318 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_giwrate()
1319 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1321 if (!rdev->ops->get_station) in cfg80211_wext_giwrate()
1322 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1326 if (!wdev->valid_links && wdev->links[0].client.current_bss) in cfg80211_wext_giwrate()
1327 memcpy(addr, wdev->links[0].client.current_bss->pub.bssid, in cfg80211_wext_giwrate()
1330 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1335 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwrate()
1337 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwrate()
1342 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1346 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); in cfg80211_wext_giwrate()
1356 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wireless_stats()
1357 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wireless_stats()
1358 /* we are under RTNL - globally locked - so can use static structs */ in cfg80211_wireless_stats()
1364 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) in cfg80211_wireless_stats()
1367 if (!rdev->ops->get_station) in cfg80211_wireless_stats()
1372 if (wdev->valid_links || !wdev->links[0].client.current_bss) { in cfg80211_wireless_stats()
1376 memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN); in cfg80211_wireless_stats()
1381 wiphy_lock(&rdev->wiphy); in cfg80211_wireless_stats()
1383 wiphy_unlock(&rdev->wiphy); in cfg80211_wireless_stats()
1390 switch (rdev->wiphy.signal_type) { in cfg80211_wireless_stats()
1398 if (sig < -110) in cfg80211_wireless_stats()
1399 sig = -110; in cfg80211_wireless_stats()
1400 else if (sig > -40) in cfg80211_wireless_stats()
1401 sig = -40; in cfg80211_wireless_stats()
1435 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwap()
1436 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwap()
1439 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwap()
1440 switch (wdev->iftype) { in cfg80211_wext_siwap()
1448 ret = -EOPNOTSUPP; in cfg80211_wext_siwap()
1451 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwap()
1460 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwap()
1461 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwap()
1464 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwap()
1465 switch (wdev->iftype) { in cfg80211_wext_giwap()
1473 ret = -EOPNOTSUPP; in cfg80211_wext_giwap()
1476 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwap()
1485 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwessid()
1486 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwessid()
1489 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwessid()
1490 switch (wdev->iftype) { in cfg80211_wext_siwessid()
1498 ret = -EOPNOTSUPP; in cfg80211_wext_siwessid()
1501 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwessid()
1510 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwessid()
1511 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwessid()
1514 data->flags = 0; in cfg80211_wext_giwessid()
1515 data->length = 0; in cfg80211_wext_giwessid()
1517 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwessid()
1518 switch (wdev->iftype) { in cfg80211_wext_giwessid()
1526 ret = -EOPNOTSUPP; in cfg80211_wext_giwessid()
1529 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwessid()
1538 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpmksa()
1539 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpmksa()
1546 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpmksa()
1547 return -EINVAL; in cfg80211_wext_siwpmksa()
1549 cfg_pmksa.bssid = pmksa->bssid.sa_data; in cfg80211_wext_siwpmksa()
1550 cfg_pmksa.pmkid = pmksa->pmkid; in cfg80211_wext_siwpmksa()
1552 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpmksa()
1553 switch (pmksa->cmd) { in cfg80211_wext_siwpmksa()
1555 if (!rdev->ops->set_pmksa) { in cfg80211_wext_siwpmksa()
1556 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1563 if (!rdev->ops->del_pmksa) { in cfg80211_wext_siwpmksa()
1564 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1571 if (!rdev->ops->flush_pmksa) { in cfg80211_wext_siwpmksa()
1572 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1579 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1582 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpmksa()