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"
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()
590 wdev_lock(dev->ieee80211_ptr); in cfg80211_set_encryption()
593 wdev_unlock(dev->ieee80211_ptr); in cfg80211_set_encryption()
602 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_siwencode()
603 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencode()
604 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencode()
609 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencode()
610 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencode()
611 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
613 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencode()
614 if (!rdev->ops->del_key || in cfg80211_wext_siwencode()
615 !rdev->ops->add_key || in cfg80211_wext_siwencode()
616 !rdev->ops->set_default_key) in cfg80211_wext_siwencode()
617 return -EOPNOTSUPP; in cfg80211_wext_siwencode()
619 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwencode()
620 if (wdev->valid_links) { in cfg80211_wext_siwencode()
621 err = -EOPNOTSUPP; in cfg80211_wext_siwencode()
625 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencode()
627 idx = wdev->wext.default_key; in cfg80211_wext_siwencode()
631 err = -EINVAL; in cfg80211_wext_siwencode()
634 idx--; in cfg80211_wext_siwencode()
637 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencode()
639 else if (erq->length == 0) { in cfg80211_wext_siwencode()
640 /* No key data - just set the default TX key index */ in cfg80211_wext_siwencode()
643 if (wdev->connected || in cfg80211_wext_siwencode()
644 (wdev->iftype == NL80211_IFTYPE_ADHOC && in cfg80211_wext_siwencode()
645 wdev->u.ibss.current_bss)) in cfg80211_wext_siwencode()
646 err = rdev_set_default_key(rdev, dev, -1, idx, true, in cfg80211_wext_siwencode()
649 wdev->wext.default_key = idx; in cfg80211_wext_siwencode()
656 params.key_len = erq->length; in cfg80211_wext_siwencode()
657 if (erq->length == 5) { in cfg80211_wext_siwencode()
659 } else if (erq->length == 13) { in cfg80211_wext_siwencode()
662 err = -EINVAL; in cfg80211_wext_siwencode()
667 wdev->wext.default_key == -1, in cfg80211_wext_siwencode()
670 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwencode()
679 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_siwencodeext()
680 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwencodeext()
681 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwencodeext()
690 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_siwencodeext()
691 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_siwencodeext()
692 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
694 /* no use -- only MFP (set_default_mgmt_key) is optional */ in cfg80211_wext_siwencodeext()
695 if (!rdev->ops->del_key || in cfg80211_wext_siwencodeext()
696 !rdev->ops->add_key || in cfg80211_wext_siwencodeext()
697 !rdev->ops->set_default_key) in cfg80211_wext_siwencodeext()
698 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
701 if (wdev->valid_links) { in cfg80211_wext_siwencodeext()
703 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
707 switch (ext->alg) { in cfg80211_wext_siwencodeext()
713 if (ext->key_len == 5) in cfg80211_wext_siwencodeext()
715 else if (ext->key_len == 13) in cfg80211_wext_siwencodeext()
718 return -EINVAL; in cfg80211_wext_siwencodeext()
730 return -EOPNOTSUPP; in cfg80211_wext_siwencodeext()
733 if (erq->flags & IW_ENCODE_DISABLED) in cfg80211_wext_siwencodeext()
736 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_siwencodeext()
739 idx = wdev->wext.default_mgmt_key; in cfg80211_wext_siwencodeext()
741 return -EINVAL; in cfg80211_wext_siwencodeext()
743 idx--; in cfg80211_wext_siwencodeext()
746 idx = wdev->wext.default_key; in cfg80211_wext_siwencodeext()
748 return -EINVAL; in cfg80211_wext_siwencodeext()
750 idx--; in cfg80211_wext_siwencodeext()
753 addr = ext->addr.sa_data; in cfg80211_wext_siwencodeext()
758 params.key = ext->key; in cfg80211_wext_siwencodeext()
759 params.key_len = ext->key_len; in cfg80211_wext_siwencodeext()
762 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { in cfg80211_wext_siwencodeext()
763 params.seq = ext->rx_seq; in cfg80211_wext_siwencodeext()
767 wiphy_lock(wdev->wiphy); in cfg80211_wext_siwencodeext()
770 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY), in cfg80211_wext_siwencodeext()
772 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, in cfg80211_wext_siwencodeext()
774 wiphy_unlock(wdev->wiphy); in cfg80211_wext_siwencodeext()
783 struct iw_point *erq = &wrqu->encoding; in cfg80211_wext_giwencode()
784 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwencode()
787 if (wdev->iftype != NL80211_IFTYPE_STATION && in cfg80211_wext_giwencode()
788 wdev->iftype != NL80211_IFTYPE_ADHOC) in cfg80211_wext_giwencode()
789 return -EOPNOTSUPP; in cfg80211_wext_giwencode()
791 idx = erq->flags & IW_ENCODE_INDEX; in cfg80211_wext_giwencode()
793 idx = wdev->wext.default_key; in cfg80211_wext_giwencode()
797 return -EINVAL; in cfg80211_wext_giwencode()
799 idx--; in cfg80211_wext_giwencode()
801 erq->flags = idx + 1; in cfg80211_wext_giwencode()
803 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) { in cfg80211_wext_giwencode()
804 erq->flags |= IW_ENCODE_DISABLED; in cfg80211_wext_giwencode()
805 erq->length = 0; in cfg80211_wext_giwencode()
809 erq->length = min_t(size_t, erq->length, in cfg80211_wext_giwencode()
810 wdev->wext.keys->params[idx].key_len); in cfg80211_wext_giwencode()
811 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length); in cfg80211_wext_giwencode()
812 erq->flags |= IW_ENCODE_ENABLED; in cfg80211_wext_giwencode()
821 struct iw_freq *wextfreq = &wrqu->freq; in cfg80211_wext_siwfreq()
822 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwfreq()
823 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwfreq()
829 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwfreq()
831 switch (wdev->iftype) { in cfg80211_wext_siwfreq()
845 ret = -EINVAL; in cfg80211_wext_siwfreq()
849 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
851 ret = -EINVAL; in cfg80211_wext_siwfreq()
863 ret = -EINVAL; in cfg80211_wext_siwfreq()
867 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq); in cfg80211_wext_siwfreq()
869 ret = -EINVAL; in cfg80211_wext_siwfreq()
875 ret = -EOPNOTSUPP; in cfg80211_wext_siwfreq()
879 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwfreq()
888 struct iw_freq *freq = &wrqu->freq; in cfg80211_wext_giwfreq()
889 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwfreq()
890 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwfreq()
894 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwfreq()
895 switch (wdev->iftype) { in cfg80211_wext_giwfreq()
903 if (!rdev->ops->get_channel) { in cfg80211_wext_giwfreq()
904 ret = -EINVAL; in cfg80211_wext_giwfreq()
911 freq->m = chandef.chan->center_freq; in cfg80211_wext_giwfreq()
912 freq->e = 6; in cfg80211_wext_giwfreq()
916 ret = -EINVAL; in cfg80211_wext_giwfreq()
920 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwfreq()
929 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwtxpower()
930 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwtxpower()
935 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_siwtxpower()
936 return -EINVAL; in cfg80211_wext_siwtxpower()
937 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_siwtxpower()
938 return -EINVAL; in cfg80211_wext_siwtxpower()
940 if (!rdev->ops->set_tx_power) in cfg80211_wext_siwtxpower()
941 return -EOPNOTSUPP; in cfg80211_wext_siwtxpower()
944 if (!data->txpower.disabled) { in cfg80211_wext_siwtxpower()
945 rfkill_set_sw_state(rdev->wiphy.rfkill, false); in cfg80211_wext_siwtxpower()
947 if (data->txpower.fixed) { in cfg80211_wext_siwtxpower()
952 if (data->txpower.value < 0) in cfg80211_wext_siwtxpower()
953 return -EINVAL; in cfg80211_wext_siwtxpower()
954 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
962 if (data->txpower.value < 0) { in cfg80211_wext_siwtxpower()
965 dbm = data->txpower.value; in cfg80211_wext_siwtxpower()
970 if (rfkill_set_sw_state(rdev->wiphy.rfkill, true)) in cfg80211_wext_siwtxpower()
971 schedule_work(&rdev->rfkill_block); in cfg80211_wext_siwtxpower()
975 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
977 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwtxpower()
986 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwtxpower()
987 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwtxpower()
990 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) in cfg80211_wext_giwtxpower()
991 return -EINVAL; in cfg80211_wext_giwtxpower()
992 if (data->txpower.flags & IW_TXPOW_RANGE) in cfg80211_wext_giwtxpower()
993 return -EINVAL; in cfg80211_wext_giwtxpower()
995 if (!rdev->ops->get_tx_power) in cfg80211_wext_giwtxpower()
996 return -EOPNOTSUPP; in cfg80211_wext_giwtxpower()
998 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
1000 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwtxpower()
1005 data->txpower.fixed = 1; in cfg80211_wext_giwtxpower()
1006 data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill); in cfg80211_wext_giwtxpower()
1007 data->txpower.value = val; in cfg80211_wext_giwtxpower()
1008 data->txpower.flags = IW_TXPOW_DBM; in cfg80211_wext_giwtxpower()
1019 return -EINVAL; in cfg80211_set_auth_alg()
1024 return -EINVAL; in cfg80211_set_auth_alg()
1028 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; in cfg80211_set_auth_alg()
1033 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY; in cfg80211_set_auth_alg()
1038 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP; in cfg80211_set_auth_alg()
1042 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; in cfg80211_set_auth_alg()
1052 return -EINVAL; in cfg80211_set_wpa_version()
1057 return -EINVAL; in cfg80211_set_wpa_version()
1060 wdev->wext.connect.crypto.wpa_versions &= in cfg80211_set_wpa_version()
1064 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1068 wdev->wext.connect.crypto.wpa_versions |= in cfg80211_set_wpa_version()
1077 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1080 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1083 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1086 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1089 wdev->wext.connect.crypto.cipher_group = in cfg80211_set_cipher_group()
1092 wdev->wext.connect.crypto.cipher_group = 0; in cfg80211_set_cipher_group()
1094 return -EINVAL; in cfg80211_set_cipher_group()
1102 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise; in cfg80211_set_cipher_pairwise()
1131 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers; in cfg80211_set_cipher_pairwise()
1143 return -EINVAL; in cfg80211_set_key_mgt()
1146 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1152 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] = in cfg80211_set_key_mgt()
1157 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites; in cfg80211_set_key_mgt()
1166 struct iw_param *data = &wrqu->param; in cfg80211_wext_siwauth()
1167 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwauth()
1169 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwauth()
1170 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1172 switch (data->flags & IW_AUTH_INDEX) { in cfg80211_wext_siwauth()
1174 wdev->wext.connect.privacy = data->value; in cfg80211_wext_siwauth()
1177 return cfg80211_set_wpa_version(wdev, data->value); in cfg80211_wext_siwauth()
1179 return cfg80211_set_cipher_group(wdev, data->value); in cfg80211_wext_siwauth()
1181 return cfg80211_set_key_mgt(wdev, data->value); in cfg80211_wext_siwauth()
1183 return cfg80211_set_cipher_pairwise(wdev, data->value); in cfg80211_wext_siwauth()
1185 return cfg80211_set_auth_alg(wdev, data->value); in cfg80211_wext_siwauth()
1192 return -EOPNOTSUPP; in cfg80211_wext_siwauth()
1202 return -EOPNOTSUPP; in cfg80211_wext_giwauth()
1209 struct iw_param *wrq = &wrqu->power; in cfg80211_wext_siwpower()
1210 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpower()
1211 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpower()
1213 int timeout = wdev->ps_timeout; in cfg80211_wext_siwpower()
1216 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpower()
1217 return -EINVAL; in cfg80211_wext_siwpower()
1219 if (!rdev->ops->set_power_mgmt) in cfg80211_wext_siwpower()
1220 return -EOPNOTSUPP; in cfg80211_wext_siwpower()
1222 if (wrq->disabled) { in cfg80211_wext_siwpower()
1225 switch (wrq->flags & IW_POWER_MODE) { in cfg80211_wext_siwpower()
1232 return -EINVAL; in cfg80211_wext_siwpower()
1235 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) in cfg80211_wext_siwpower()
1236 return -EINVAL; in cfg80211_wext_siwpower()
1238 if (wrq->flags & IW_POWER_TIMEOUT) in cfg80211_wext_siwpower()
1239 timeout = wrq->value / 1000; in cfg80211_wext_siwpower()
1242 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpower()
1244 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpower()
1248 wdev->ps = ps; in cfg80211_wext_siwpower()
1249 wdev->ps_timeout = timeout; in cfg80211_wext_siwpower()
1259 struct iw_param *wrq = &wrqu->power; in cfg80211_wext_giwpower()
1260 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwpower()
1262 wrq->disabled = !wdev->ps; in cfg80211_wext_giwpower()
1271 struct iw_param *rate = &wrqu->bitrate; in cfg80211_wext_siwrate()
1272 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwrate()
1273 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwrate()
1275 u32 fixed, maxrate; in cfg80211_wext_siwrate() local
1280 if (!rdev->ops->set_bitrate_mask) in cfg80211_wext_siwrate()
1281 return -EOPNOTSUPP; in cfg80211_wext_siwrate()
1284 fixed = 0; in cfg80211_wext_siwrate()
1285 maxrate = (u32)-1; in cfg80211_wext_siwrate()
1287 if (rate->value < 0) { in cfg80211_wext_siwrate()
1289 } else if (rate->fixed) { in cfg80211_wext_siwrate()
1290 fixed = rate->value / 100000; in cfg80211_wext_siwrate()
1292 maxrate = rate->value / 100000; in cfg80211_wext_siwrate()
1296 sband = wdev->wiphy->bands[band]; in cfg80211_wext_siwrate()
1299 for (ridx = 0; ridx < sband->n_bitrates; ridx++) { in cfg80211_wext_siwrate()
1300 struct ieee80211_rate *srate = &sband->bitrates[ridx]; in cfg80211_wext_siwrate()
1301 if (fixed == srate->bitrate) { in cfg80211_wext_siwrate()
1306 if (srate->bitrate <= maxrate) { in cfg80211_wext_siwrate()
1314 return -EINVAL; in cfg80211_wext_siwrate()
1316 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwrate()
1317 if (dev->ieee80211_ptr->valid_links) in cfg80211_wext_siwrate()
1318 ret = -EOPNOTSUPP; in cfg80211_wext_siwrate()
1321 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwrate()
1330 struct iw_param *rate = &wrqu->bitrate; in cfg80211_wext_giwrate()
1331 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwrate()
1332 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwrate()
1337 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_giwrate()
1338 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1340 if (!rdev->ops->get_station) in cfg80211_wext_giwrate()
1341 return -EOPNOTSUPP; in cfg80211_wext_giwrate()
1345 if (!wdev->valid_links && wdev->links[0].client.current_bss) in cfg80211_wext_giwrate()
1346 memcpy(addr, wdev->links[0].client.current_bss->pub.bssid, in cfg80211_wext_giwrate()
1349 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1354 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwrate()
1356 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwrate()
1361 err = -EOPNOTSUPP; in cfg80211_wext_giwrate()
1365 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate); in cfg80211_wext_giwrate()
1375 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wireless_stats()
1376 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wireless_stats()
1377 /* we are under RTNL - globally locked - so can use static structs */ in cfg80211_wireless_stats()
1383 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION) in cfg80211_wireless_stats()
1386 if (!rdev->ops->get_station) in cfg80211_wireless_stats()
1391 if (wdev->valid_links || !wdev->links[0].client.current_bss) { in cfg80211_wireless_stats()
1395 memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN); in cfg80211_wireless_stats()
1400 wiphy_lock(&rdev->wiphy); in cfg80211_wireless_stats()
1402 wiphy_unlock(&rdev->wiphy); in cfg80211_wireless_stats()
1409 switch (rdev->wiphy.signal_type) { in cfg80211_wireless_stats()
1417 if (sig < -110) in cfg80211_wireless_stats()
1418 sig = -110; in cfg80211_wireless_stats()
1419 else if (sig > -40) in cfg80211_wireless_stats()
1420 sig = -40; in cfg80211_wireless_stats()
1454 struct sockaddr *ap_addr = &wrqu->ap_addr; in cfg80211_wext_siwap()
1455 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwap()
1456 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwap()
1459 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwap()
1460 switch (wdev->iftype) { in cfg80211_wext_siwap()
1468 ret = -EOPNOTSUPP; in cfg80211_wext_siwap()
1471 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwap()
1480 struct sockaddr *ap_addr = &wrqu->ap_addr; in cfg80211_wext_giwap()
1481 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwap()
1482 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwap()
1485 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwap()
1486 switch (wdev->iftype) { in cfg80211_wext_giwap()
1494 ret = -EOPNOTSUPP; in cfg80211_wext_giwap()
1497 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwap()
1506 struct iw_point *data = &wrqu->data; in cfg80211_wext_siwessid()
1507 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwessid()
1508 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwessid()
1511 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwessid()
1512 switch (wdev->iftype) { in cfg80211_wext_siwessid()
1520 ret = -EOPNOTSUPP; in cfg80211_wext_siwessid()
1523 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwessid()
1532 struct iw_point *data = &wrqu->data; in cfg80211_wext_giwessid()
1533 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_giwessid()
1534 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_giwessid()
1537 data->flags = 0; in cfg80211_wext_giwessid()
1538 data->length = 0; in cfg80211_wext_giwessid()
1540 wiphy_lock(&rdev->wiphy); in cfg80211_wext_giwessid()
1541 switch (wdev->iftype) { in cfg80211_wext_giwessid()
1549 ret = -EOPNOTSUPP; in cfg80211_wext_giwessid()
1552 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_giwessid()
1561 struct wireless_dev *wdev = dev->ieee80211_ptr; in cfg80211_wext_siwpmksa()
1562 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); in cfg80211_wext_siwpmksa()
1569 if (wdev->iftype != NL80211_IFTYPE_STATION) in cfg80211_wext_siwpmksa()
1570 return -EINVAL; in cfg80211_wext_siwpmksa()
1572 cfg_pmksa.bssid = pmksa->bssid.sa_data; in cfg80211_wext_siwpmksa()
1573 cfg_pmksa.pmkid = pmksa->pmkid; in cfg80211_wext_siwpmksa()
1575 wiphy_lock(&rdev->wiphy); in cfg80211_wext_siwpmksa()
1576 switch (pmksa->cmd) { in cfg80211_wext_siwpmksa()
1578 if (!rdev->ops->set_pmksa) { in cfg80211_wext_siwpmksa()
1579 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1586 if (!rdev->ops->del_pmksa) { in cfg80211_wext_siwpmksa()
1587 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1594 if (!rdev->ops->flush_pmksa) { in cfg80211_wext_siwpmksa()
1595 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1602 ret = -EOPNOTSUPP; in cfg80211_wext_siwpmksa()
1605 wiphy_unlock(&rdev->wiphy); in cfg80211_wext_siwpmksa()