blob: a32065d600a1c584c67a711a43798f168f5aaeba [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Johannes Bergfee52672008-11-26 22:36:31 +01002/*
3 * cfg80211 - wext compat code
4 *
5 * This is temporary code until all wireless functionality is migrated
6 * into cfg80211, when that happens all the exports here go away and
7 * we directly assign the wireless handlers of wireless interfaces.
8 *
Johannes Berg08645122009-05-11 13:54:58 +02009 * Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
Johannes Berga05829a2021-01-22 16:19:43 +010010 * Copyright (C) 2019-2021 Intel Corporation
Johannes Bergfee52672008-11-26 22:36:31 +010011 */
12
Paul Gortmakerbc3b2d72011-07-15 11:47:34 -040013#include <linux/export.h>
Johannes Bergfee52672008-11-26 22:36:31 +010014#include <linux/wireless.h>
15#include <linux/nl80211.h>
Johannes Berg691597c2009-04-19 19:57:45 +020016#include <linux/if_arp.h>
Johannes Berg08645122009-05-11 13:54:58 +020017#include <linux/etherdevice.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090018#include <linux/slab.h>
Johannes Bergfee52672008-11-26 22:36:31 +010019#include <net/iw_handler.h>
Johannes Bergfee52672008-11-26 22:36:31 +010020#include <net/cfg80211.h>
Johannes Berg262eb9b22011-07-13 10:39:09 +020021#include <net/cfg80211-wext.h>
Johannes Berg0e82ffe2009-07-27 12:01:50 +020022#include "wext-compat.h"
Johannes Bergfee52672008-11-26 22:36:31 +010023#include "core.h"
Hila Gonene35e4d22012-06-27 17:19:42 +030024#include "rdev-ops.h"
Johannes Bergfee52672008-11-26 22:36:31 +010025
26int cfg80211_wext_giwname(struct net_device *dev,
27 struct iw_request_info *info,
28 char *name, char *extra)
29{
Johannes Bergfee52672008-11-26 22:36:31 +010030 strcpy(name, "IEEE 802.11");
Johannes Bergfee52672008-11-26 22:36:31 +010031 return 0;
32}
Johannes Berg2afe38d2015-01-06 14:00:53 +010033EXPORT_WEXT_HANDLER(cfg80211_wext_giwname);
Johannes Berge60c7742008-11-26 23:31:40 +010034
35int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
36 u32 *mode, char *extra)
37{
38 struct wireless_dev *wdev = dev->ieee80211_ptr;
39 struct cfg80211_registered_device *rdev;
40 struct vif_params vifparams;
41 enum nl80211_iftype type;
Johannes Bergbae17352021-01-28 18:35:26 +010042 int ret;
Johannes Berge60c7742008-11-26 23:31:40 +010043
Zhao, Gangf26cbf42014-04-21 12:53:03 +080044 rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berge60c7742008-11-26 23:31:40 +010045
Johannes Berge60c7742008-11-26 23:31:40 +010046 switch (*mode) {
47 case IW_MODE_INFRA:
48 type = NL80211_IFTYPE_STATION;
49 break;
50 case IW_MODE_ADHOC:
51 type = NL80211_IFTYPE_ADHOC;
52 break;
Johannes Berge60c7742008-11-26 23:31:40 +010053 case IW_MODE_MONITOR:
54 type = NL80211_IFTYPE_MONITOR;
55 break;
56 default:
57 return -EINVAL;
58 }
59
Johannes Bergac7f9cf2009-03-21 17:07:59 +010060 if (type == wdev->iftype)
61 return 0;
62
Johannes Berge60c7742008-11-26 23:31:40 +010063 memset(&vifparams, 0, sizeof(vifparams));
64
Johannes Bergbae17352021-01-28 18:35:26 +010065 wiphy_lock(wdev->wiphy);
66 ret = cfg80211_change_iface(rdev, dev, type, &vifparams);
67 wiphy_unlock(wdev->wiphy);
68
69 return ret;
Johannes Berge60c7742008-11-26 23:31:40 +010070}
Johannes Berg2afe38d2015-01-06 14:00:53 +010071EXPORT_WEXT_HANDLER(cfg80211_wext_siwmode);
Johannes Berge60c7742008-11-26 23:31:40 +010072
73int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
74 u32 *mode, char *extra)
75{
76 struct wireless_dev *wdev = dev->ieee80211_ptr;
77
78 if (!wdev)
79 return -EOPNOTSUPP;
80
81 switch (wdev->iftype) {
82 case NL80211_IFTYPE_AP:
83 *mode = IW_MODE_MASTER;
84 break;
85 case NL80211_IFTYPE_STATION:
86 *mode = IW_MODE_INFRA;
87 break;
88 case NL80211_IFTYPE_ADHOC:
89 *mode = IW_MODE_ADHOC;
90 break;
91 case NL80211_IFTYPE_MONITOR:
92 *mode = IW_MODE_MONITOR;
93 break;
94 case NL80211_IFTYPE_WDS:
95 *mode = IW_MODE_REPEAT;
96 break;
97 case NL80211_IFTYPE_AP_VLAN:
98 *mode = IW_MODE_SECOND; /* FIXME */
99 break;
100 default:
101 *mode = IW_MODE_AUTO;
102 break;
103 }
104 return 0;
105}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100106EXPORT_WEXT_HANDLER(cfg80211_wext_giwmode);
Johannes Berg4aa188e2009-02-18 19:32:08 +0100107
108
109int cfg80211_wext_giwrange(struct net_device *dev,
110 struct iw_request_info *info,
111 struct iw_point *data, char *extra)
112{
113 struct wireless_dev *wdev = dev->ieee80211_ptr;
114 struct iw_range *range = (struct iw_range *) extra;
Johannes Berg57fbcce2016-04-12 15:56:15 +0200115 enum nl80211_band band;
Johannes Berg9834c072009-07-06 19:40:51 +0200116 int i, c = 0;
Johannes Berg4aa188e2009-02-18 19:32:08 +0100117
118 if (!wdev)
119 return -EOPNOTSUPP;
120
121 data->length = sizeof(struct iw_range);
122 memset(range, 0, sizeof(struct iw_range));
123
124 range->we_version_compiled = WIRELESS_EXT;
125 range->we_version_source = 21;
126 range->retry_capa = IW_RETRY_LIMIT;
127 range->retry_flags = IW_RETRY_LIMIT;
128 range->min_retry = 0;
129 range->max_retry = 255;
130 range->min_rts = 0;
131 range->max_rts = 2347;
132 range->min_frag = 256;
133 range->max_frag = 2346;
134
Johannes Berg4aa188e2009-02-18 19:32:08 +0100135 range->max_encoding_tokens = 4;
136
137 range->max_qual.updated = IW_QUAL_NOISE_INVALID;
138
139 switch (wdev->wiphy->signal_type) {
140 case CFG80211_SIGNAL_TYPE_NONE:
141 break;
142 case CFG80211_SIGNAL_TYPE_MBM:
Johannes Berge7d83ed2012-12-07 11:58:26 +0100143 range->max_qual.level = (u8)-110;
Johannes Berg4aa188e2009-02-18 19:32:08 +0100144 range->max_qual.qual = 70;
145 range->avg_qual.qual = 35;
146 range->max_qual.updated |= IW_QUAL_DBM;
147 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
148 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
149 break;
150 case CFG80211_SIGNAL_TYPE_UNSPEC:
151 range->max_qual.level = 100;
152 range->max_qual.qual = 100;
153 range->avg_qual.qual = 50;
154 range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
155 range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
156 break;
157 }
158
159 range->avg_qual.level = range->max_qual.level / 2;
160 range->avg_qual.noise = range->max_qual.noise / 2;
161 range->avg_qual.updated = range->max_qual.updated;
162
Johannes Berg9834c072009-07-06 19:40:51 +0200163 for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) {
164 switch (wdev->wiphy->cipher_suites[i]) {
David Kilroy3daf0972009-06-18 23:21:14 +0100165 case WLAN_CIPHER_SUITE_TKIP:
David Kilroy27bea662009-06-18 23:21:17 +0100166 range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP |
167 IW_ENC_CAPA_WPA);
David Kilroy3daf0972009-06-18 23:21:14 +0100168 break;
169
170 case WLAN_CIPHER_SUITE_CCMP:
David Kilroy27bea662009-06-18 23:21:17 +0100171 range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP |
172 IW_ENC_CAPA_WPA2);
David Kilroy3daf0972009-06-18 23:21:14 +0100173 break;
David Kilroy2ab658f2009-06-18 23:21:16 +0100174
175 case WLAN_CIPHER_SUITE_WEP40:
176 range->encoding_size[range->num_encoding_sizes++] =
177 WLAN_KEY_LEN_WEP40;
178 break;
179
180 case WLAN_CIPHER_SUITE_WEP104:
181 range->encoding_size[range->num_encoding_sizes++] =
182 WLAN_KEY_LEN_WEP104;
183 break;
David Kilroy3daf0972009-06-18 23:21:14 +0100184 }
185 }
Johannes Berg4aa188e2009-02-18 19:32:08 +0100186
Johannes Berg57fbcce2016-04-12 15:56:15 +0200187 for (band = 0; band < NUM_NL80211_BANDS; band ++) {
Johannes Berg4aa188e2009-02-18 19:32:08 +0100188 struct ieee80211_supported_band *sband;
189
190 sband = wdev->wiphy->bands[band];
191
192 if (!sband)
193 continue;
194
195 for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
196 struct ieee80211_channel *chan = &sband->channels[i];
197
198 if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
199 range->freq[c].i =
200 ieee80211_frequency_to_channel(
201 chan->center_freq);
202 range->freq[c].m = chan->center_freq;
203 range->freq[c].e = 6;
204 c++;
205 }
206 }
207 }
208 range->num_channels = c;
209 range->num_frequency = c;
210
211 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
212 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
213 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
214
David Kilroy51cd4aa2009-06-18 23:21:15 +0100215 if (wdev->wiphy->max_scan_ssids > 0)
216 range->scan_capa |= IW_SCAN_CAPA_ESSID;
Johannes Berg4aa188e2009-02-18 19:32:08 +0100217
218 return 0;
219}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100220EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange);
Johannes Berg691597c2009-04-19 19:57:45 +0200221
Johannes Berg04a773a2009-04-19 21:24:32 +0200222
223/**
224 * cfg80211_wext_freq - get wext frequency for non-"auto"
Johannes Berg04a773a2009-04-19 21:24:32 +0200225 * @freq: the wext freq encoding
226 *
Johannes Berg59bbb6f2009-08-07 17:22:35 +0200227 * Returns a frequency, or a negative error code, or 0 for auto.
Johannes Berg04a773a2009-04-19 21:24:32 +0200228 */
Zhao, Gang96998e32014-04-09 09:28:06 +0800229int cfg80211_wext_freq(struct iw_freq *freq)
Johannes Berg04a773a2009-04-19 21:24:32 +0200230{
Johannes Berg0b258582009-05-08 09:42:33 +0200231 /*
Johannes Berg59bbb6f2009-08-07 17:22:35 +0200232 * Parse frequency - return 0 for auto and
Johannes Berg0b258582009-05-08 09:42:33 +0200233 * -EINVAL for impossible things.
234 */
Johannes Berg04a773a2009-04-19 21:24:32 +0200235 if (freq->e == 0) {
Johannes Berg57fbcce2016-04-12 15:56:15 +0200236 enum nl80211_band band = NL80211_BAND_2GHZ;
Johannes Berg04a773a2009-04-19 21:24:32 +0200237 if (freq->m < 0)
Johannes Berg59bbb6f2009-08-07 17:22:35 +0200238 return 0;
Bruno Randolf59eb21a2011-01-17 13:37:28 +0900239 if (freq->m > 14)
Johannes Berg57fbcce2016-04-12 15:56:15 +0200240 band = NL80211_BAND_5GHZ;
Bruno Randolf59eb21a2011-01-17 13:37:28 +0900241 return ieee80211_channel_to_frequency(freq->m, band);
Johannes Berg04a773a2009-04-19 21:24:32 +0200242 } else {
243 int i, div = 1000000;
244 for (i = 0; i < freq->e; i++)
245 div /= 10;
Johannes Berg0b258582009-05-08 09:42:33 +0200246 if (div <= 0)
Johannes Berg59bbb6f2009-08-07 17:22:35 +0200247 return -EINVAL;
248 return freq->m / div;
Johannes Berg04a773a2009-04-19 21:24:32 +0200249 }
Johannes Berg04a773a2009-04-19 21:24:32 +0200250}
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200251
252int cfg80211_wext_siwrts(struct net_device *dev,
253 struct iw_request_info *info,
254 struct iw_param *rts, char *extra)
255{
256 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800257 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200258 u32 orts = wdev->wiphy->rts_threshold;
259 int err;
260
Johannes Berga05829a2021-01-22 16:19:43 +0100261 wiphy_lock(&rdev->wiphy);
262 if (rts->disabled || !rts->fixed) {
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200263 wdev->wiphy->rts_threshold = (u32) -1;
Johannes Berga05829a2021-01-22 16:19:43 +0100264 } else if (rts->value < 0) {
265 err = -EINVAL;
266 goto out;
267 } else {
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200268 wdev->wiphy->rts_threshold = rts->value;
Johannes Berga05829a2021-01-22 16:19:43 +0100269 }
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200270
Hila Gonene35e4d22012-06-27 17:19:42 +0300271 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD);
Johannes Berga05829a2021-01-22 16:19:43 +0100272
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200273 if (err)
274 wdev->wiphy->rts_threshold = orts;
275
Johannes Berga05829a2021-01-22 16:19:43 +0100276out:
277 wiphy_unlock(&rdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200278 return err;
279}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100280EXPORT_WEXT_HANDLER(cfg80211_wext_siwrts);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200281
282int cfg80211_wext_giwrts(struct net_device *dev,
283 struct iw_request_info *info,
284 struct iw_param *rts, char *extra)
285{
286 struct wireless_dev *wdev = dev->ieee80211_ptr;
287
288 rts->value = wdev->wiphy->rts_threshold;
289 rts->disabled = rts->value == (u32) -1;
290 rts->fixed = 1;
291
292 return 0;
293}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100294EXPORT_WEXT_HANDLER(cfg80211_wext_giwrts);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200295
296int cfg80211_wext_siwfrag(struct net_device *dev,
297 struct iw_request_info *info,
298 struct iw_param *frag, char *extra)
299{
300 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800301 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200302 u32 ofrag = wdev->wiphy->frag_threshold;
303 int err;
304
Johannes Berga05829a2021-01-22 16:19:43 +0100305 wiphy_lock(&rdev->wiphy);
306 if (frag->disabled || !frag->fixed) {
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200307 wdev->wiphy->frag_threshold = (u32) -1;
Johannes Berga05829a2021-01-22 16:19:43 +0100308 } else if (frag->value < 256) {
309 err = -EINVAL;
310 goto out;
311 } else {
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200312 /* Fragment length must be even, so strip LSB. */
313 wdev->wiphy->frag_threshold = frag->value & ~0x1;
314 }
315
Hila Gonene35e4d22012-06-27 17:19:42 +0300316 err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200317 if (err)
318 wdev->wiphy->frag_threshold = ofrag;
Johannes Berga05829a2021-01-22 16:19:43 +0100319out:
320 wiphy_unlock(&rdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200321
322 return err;
323}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100324EXPORT_WEXT_HANDLER(cfg80211_wext_siwfrag);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200325
326int cfg80211_wext_giwfrag(struct net_device *dev,
327 struct iw_request_info *info,
328 struct iw_param *frag, char *extra)
329{
330 struct wireless_dev *wdev = dev->ieee80211_ptr;
331
332 frag->value = wdev->wiphy->frag_threshold;
333 frag->disabled = frag->value == (u32) -1;
334 frag->fixed = 1;
335
336 return 0;
337}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100338EXPORT_WEXT_HANDLER(cfg80211_wext_giwfrag);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200339
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200340static int cfg80211_wext_siwretry(struct net_device *dev,
341 struct iw_request_info *info,
342 struct iw_param *retry, char *extra)
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200343{
344 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800345 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200346 u32 changed = 0;
347 u8 olong = wdev->wiphy->retry_long;
348 u8 oshort = wdev->wiphy->retry_short;
349 int err;
350
Ujjal Royf5aa0d22014-01-09 21:16:14 +0530351 if (retry->disabled || retry->value < 1 || retry->value > 255 ||
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200352 (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
353 return -EINVAL;
354
Johannes Berga05829a2021-01-22 16:19:43 +0100355 wiphy_lock(&rdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200356 if (retry->flags & IW_RETRY_LONG) {
357 wdev->wiphy->retry_long = retry->value;
358 changed |= WIPHY_PARAM_RETRY_LONG;
359 } else if (retry->flags & IW_RETRY_SHORT) {
360 wdev->wiphy->retry_short = retry->value;
361 changed |= WIPHY_PARAM_RETRY_SHORT;
362 } else {
363 wdev->wiphy->retry_short = retry->value;
364 wdev->wiphy->retry_long = retry->value;
365 changed |= WIPHY_PARAM_RETRY_LONG;
366 changed |= WIPHY_PARAM_RETRY_SHORT;
367 }
368
Hila Gonene35e4d22012-06-27 17:19:42 +0300369 err = rdev_set_wiphy_params(rdev, changed);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200370 if (err) {
371 wdev->wiphy->retry_short = oshort;
372 wdev->wiphy->retry_long = olong;
373 }
Johannes Berga05829a2021-01-22 16:19:43 +0100374 wiphy_unlock(&rdev->wiphy);
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200375
376 return err;
377}
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200378
379int cfg80211_wext_giwretry(struct net_device *dev,
380 struct iw_request_info *info,
381 struct iw_param *retry, char *extra)
382{
383 struct wireless_dev *wdev = dev->ieee80211_ptr;
384
385 retry->disabled = 0;
386
387 if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) {
388 /*
389 * First return short value, iwconfig will ask long value
390 * later if needed
391 */
Ujjal Roy60a4fe02014-01-06 21:56:11 +0530392 retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT;
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200393 retry->value = wdev->wiphy->retry_short;
Ujjal Roy60a4fe02014-01-06 21:56:11 +0530394 if (wdev->wiphy->retry_long == wdev->wiphy->retry_short)
Jouni Malinenb9a5f8ca2009-04-20 18:39:05 +0200395 retry->flags |= IW_RETRY_LONG;
396
397 return 0;
398 }
399
400 if (retry->flags & IW_RETRY_LONG) {
401 retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
402 retry->value = wdev->wiphy->retry_long;
403 }
404
405 return 0;
406}
Johannes Berg2afe38d2015-01-06 14:00:53 +0100407EXPORT_WEXT_HANDLER(cfg80211_wext_giwretry);
Johannes Berg08645122009-05-11 13:54:58 +0200408
Johannes Bergfffd0932009-07-08 14:22:54 +0200409static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
Johannes Berge31b8212010-10-05 19:39:30 +0200410 struct net_device *dev, bool pairwise,
411 const u8 *addr, bool remove, bool tx_key,
412 int idx, struct key_params *params)
Johannes Berg08645122009-05-11 13:54:58 +0200413{
414 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Bergfffd0932009-07-08 14:22:54 +0200415 int err, i;
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100416 bool rejoin = false;
Johannes Bergfffd0932009-07-08 14:22:54 +0200417
Johannes Berge31b8212010-10-05 19:39:30 +0200418 if (pairwise && !addr)
419 return -EINVAL;
420
Johannes Berg8f7d99b2016-09-28 23:44:57 +0200421 /*
422 * In many cases we won't actually need this, but it's better
423 * to do it first in case the allocation fails. Don't use wext.
424 */
Johannes Bergfffd0932009-07-08 14:22:54 +0200425 if (!wdev->wext.keys) {
426 wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys),
Johannes Berg89b706f2016-09-13 16:39:38 +0200427 GFP_KERNEL);
Johannes Bergfffd0932009-07-08 14:22:54 +0200428 if (!wdev->wext.keys)
429 return -ENOMEM;
David Spinadelb8676222016-09-22 23:16:50 +0300430 for (i = 0; i < CFG80211_MAX_WEP_KEYS; i++)
Johannes Bergfffd0932009-07-08 14:22:54 +0200431 wdev->wext.keys->params[i].key =
432 wdev->wext.keys->data[i];
433 }
434
435 if (wdev->iftype != NL80211_IFTYPE_ADHOC &&
436 wdev->iftype != NL80211_IFTYPE_STATION)
437 return -EOPNOTSUPP;
Johannes Berg08645122009-05-11 13:54:58 +0200438
439 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
Johannes Bergfffd0932009-07-08 14:22:54 +0200440 if (!wdev->current_bss)
441 return -ENOLINK;
442
Johannes Berg08645122009-05-11 13:54:58 +0200443 if (!rdev->ops->set_default_mgmt_key)
444 return -EOPNOTSUPP;
445
446 if (idx < 4 || idx > 5)
447 return -EINVAL;
448 } else if (idx < 0 || idx > 3)
449 return -EINVAL;
450
451 if (remove) {
Johannes Bergfffd0932009-07-08 14:22:54 +0200452 err = 0;
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100453 if (wdev->current_bss) {
454 /*
455 * If removing the current TX key, we will need to
456 * join a new IBSS without the privacy bit clear.
457 */
458 if (idx == wdev->wext.default_key &&
459 wdev->iftype == NL80211_IFTYPE_ADHOC) {
460 __cfg80211_leave_ibss(rdev, wdev->netdev, true);
461 rejoin = true;
462 }
Johannes Berge31b8212010-10-05 19:39:30 +0200463
464 if (!pairwise && addr &&
465 !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
466 err = -ENOENT;
467 else
Hila Gonene35e4d22012-06-27 17:19:42 +0300468 err = rdev_del_key(rdev, dev, idx, pairwise,
469 addr);
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100470 }
Vivek Natarajand55fb892009-11-24 11:54:10 -0500471 wdev->wext.connect.privacy = false;
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100472 /*
473 * Applications using wireless extensions expect to be
474 * able to delete keys that don't exist, so allow that.
475 */
476 if (err == -ENOENT)
477 err = 0;
Johannes Berg08645122009-05-11 13:54:58 +0200478 if (!err) {
Johannes Berg89b706f2016-09-13 16:39:38 +0200479 if (!addr && idx < 4) {
Johannes Berg538c9eb2014-09-10 13:39:56 +0300480 memset(wdev->wext.keys->data[idx], 0,
481 sizeof(wdev->wext.keys->data[idx]));
Johannes Bergfffd0932009-07-08 14:22:54 +0200482 wdev->wext.keys->params[idx].key_len = 0;
483 wdev->wext.keys->params[idx].cipher = 0;
484 }
Johannes Berg08645122009-05-11 13:54:58 +0200485 if (idx == wdev->wext.default_key)
486 wdev->wext.default_key = -1;
487 else if (idx == wdev->wext.default_mgmt_key)
488 wdev->wext.default_mgmt_key = -1;
489 }
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100490
491 if (!err && rejoin)
492 err = cfg80211_ibss_wext_join(rdev, wdev);
Johannes Berge3da5742009-05-18 19:56:36 +0200493
Johannes Berg08645122009-05-11 13:54:58 +0200494 return err;
Johannes Bergfffd0932009-07-08 14:22:54 +0200495 }
Johannes Berg08645122009-05-11 13:54:58 +0200496
Johannes Bergfffd0932009-07-08 14:22:54 +0200497 if (addr)
498 tx_key = false;
Johannes Berg08645122009-05-11 13:54:58 +0200499
Johannes Berge31b8212010-10-05 19:39:30 +0200500 if (cfg80211_validate_key_settings(rdev, params, idx, pairwise, addr))
Johannes Bergfffd0932009-07-08 14:22:54 +0200501 return -EINVAL;
502
503 err = 0;
504 if (wdev->current_bss)
Hila Gonene35e4d22012-06-27 17:19:42 +0300505 err = rdev_add_key(rdev, dev, idx, pairwise, addr, params);
Johannes Berg9381e262016-09-13 16:11:32 +0200506 else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
507 params->cipher != WLAN_CIPHER_SUITE_WEP104)
508 return -EINVAL;
Johannes Bergfffd0932009-07-08 14:22:54 +0200509 if (err)
510 return err;
Johannes Berg08645122009-05-11 13:54:58 +0200511
Johannes Berg8f7d99b2016-09-28 23:44:57 +0200512 /*
513 * We only need to store WEP keys, since they're the only keys that
Randy Dunlapeee79f82020-08-22 16:19:53 -0700514 * can be set before a connection is established and persist after
Johannes Berg8f7d99b2016-09-28 23:44:57 +0200515 * disconnecting.
516 */
517 if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
518 params->cipher == WLAN_CIPHER_SUITE_WEP104)) {
Johannes Bergfffd0932009-07-08 14:22:54 +0200519 wdev->wext.keys->params[idx] = *params;
520 memcpy(wdev->wext.keys->data[idx],
521 params->key, params->key_len);
522 wdev->wext.keys->params[idx].key =
523 wdev->wext.keys->data[idx];
524 }
525
Zhu Yi1f00fca2009-07-20 11:47:43 +0800526 if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
527 params->cipher == WLAN_CIPHER_SUITE_WEP104) &&
Johannes Bergfffd0932009-07-08 14:22:54 +0200528 (tx_key || (!addr && wdev->wext.default_key == -1))) {
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100529 if (wdev->current_bss) {
530 /*
531 * If we are getting a new TX key from not having
532 * had one before we need to join a new IBSS with
533 * the privacy bit set.
534 */
535 if (wdev->iftype == NL80211_IFTYPE_ADHOC &&
536 wdev->wext.default_key == -1) {
537 __cfg80211_leave_ibss(rdev, wdev->netdev, true);
538 rejoin = true;
539 }
Hila Gonene35e4d22012-06-27 17:19:42 +0300540 err = rdev_set_default_key(rdev, dev, idx, true, true);
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100541 }
542 if (!err) {
Johannes Bergfffd0932009-07-08 14:22:54 +0200543 wdev->wext.default_key = idx;
Johannes Berg98d3a7c2009-11-18 13:03:43 +0100544 if (rejoin)
545 err = cfg80211_ibss_wext_join(rdev, wdev);
546 }
Johannes Bergfffd0932009-07-08 14:22:54 +0200547 return err;
548 }
Johannes Berg08645122009-05-11 13:54:58 +0200549
Johannes Bergfffd0932009-07-08 14:22:54 +0200550 if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
551 (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
552 if (wdev->current_bss)
Hila Gonene35e4d22012-06-27 17:19:42 +0300553 err = rdev_set_default_mgmt_key(rdev, dev, idx);
Johannes Bergfffd0932009-07-08 14:22:54 +0200554 if (!err)
555 wdev->wext.default_mgmt_key = idx;
556 return err;
Johannes Berg08645122009-05-11 13:54:58 +0200557 }
Johannes Bergfffd0932009-07-08 14:22:54 +0200558
559 return 0;
560}
561
562static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
Johannes Berge31b8212010-10-05 19:39:30 +0200563 struct net_device *dev, bool pairwise,
564 const u8 *addr, bool remove, bool tx_key,
565 int idx, struct key_params *params)
Johannes Bergfffd0932009-07-08 14:22:54 +0200566{
567 int err;
568
569 wdev_lock(dev->ieee80211_ptr);
Johannes Berge31b8212010-10-05 19:39:30 +0200570 err = __cfg80211_set_encryption(rdev, dev, pairwise, addr,
571 remove, tx_key, idx, params);
Johannes Bergfffd0932009-07-08 14:22:54 +0200572 wdev_unlock(dev->ieee80211_ptr);
573
574 return err;
Johannes Berg08645122009-05-11 13:54:58 +0200575}
576
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200577static int cfg80211_wext_siwencode(struct net_device *dev,
578 struct iw_request_info *info,
579 struct iw_point *erq, char *keybuf)
Johannes Berg08645122009-05-11 13:54:58 +0200580{
581 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800582 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg08645122009-05-11 13:54:58 +0200583 int idx, err;
584 bool remove = false;
585 struct key_params params;
586
Johannes Bergfffd0932009-07-08 14:22:54 +0200587 if (wdev->iftype != NL80211_IFTYPE_STATION &&
588 wdev->iftype != NL80211_IFTYPE_ADHOC)
589 return -EOPNOTSUPP;
590
Johannes Berg08645122009-05-11 13:54:58 +0200591 /* no use -- only MFP (set_default_mgmt_key) is optional */
592 if (!rdev->ops->del_key ||
593 !rdev->ops->add_key ||
594 !rdev->ops->set_default_key)
595 return -EOPNOTSUPP;
596
Johannes Berga05829a2021-01-22 16:19:43 +0100597 wiphy_lock(&rdev->wiphy);
Johannes Berg08645122009-05-11 13:54:58 +0200598 idx = erq->flags & IW_ENCODE_INDEX;
599 if (idx == 0) {
600 idx = wdev->wext.default_key;
601 if (idx < 0)
602 idx = 0;
Johannes Berga05829a2021-01-22 16:19:43 +0100603 } else if (idx < 1 || idx > 4) {
604 err = -EINVAL;
605 goto out;
606 } else {
Johannes Berg08645122009-05-11 13:54:58 +0200607 idx--;
Johannes Berga05829a2021-01-22 16:19:43 +0100608 }
Johannes Berg08645122009-05-11 13:54:58 +0200609
610 if (erq->flags & IW_ENCODE_DISABLED)
611 remove = true;
612 else if (erq->length == 0) {
613 /* No key data - just set the default TX key index */
Johannes Bergfffd0932009-07-08 14:22:54 +0200614 err = 0;
615 wdev_lock(wdev);
616 if (wdev->current_bss)
Hila Gonene35e4d22012-06-27 17:19:42 +0300617 err = rdev_set_default_key(rdev, dev, idx, true,
618 true);
Johannes Berg08645122009-05-11 13:54:58 +0200619 if (!err)
620 wdev->wext.default_key = idx;
Johannes Bergfffd0932009-07-08 14:22:54 +0200621 wdev_unlock(wdev);
Johannes Berga05829a2021-01-22 16:19:43 +0100622 goto out;
Johannes Berg08645122009-05-11 13:54:58 +0200623 }
624
625 memset(&params, 0, sizeof(params));
626 params.key = keybuf;
627 params.key_len = erq->length;
Johannes Berga05829a2021-01-22 16:19:43 +0100628 if (erq->length == 5) {
Johannes Berg08645122009-05-11 13:54:58 +0200629 params.cipher = WLAN_CIPHER_SUITE_WEP40;
Johannes Berga05829a2021-01-22 16:19:43 +0100630 } else if (erq->length == 13) {
Johannes Berg08645122009-05-11 13:54:58 +0200631 params.cipher = WLAN_CIPHER_SUITE_WEP104;
Johannes Berga05829a2021-01-22 16:19:43 +0100632 } else if (!remove) {
633 err = -EINVAL;
634 goto out;
635 }
Johannes Berg08645122009-05-11 13:54:58 +0200636
Johannes Berga05829a2021-01-22 16:19:43 +0100637 err = cfg80211_set_encryption(rdev, dev, false, NULL, remove,
638 wdev->wext.default_key == -1,
639 idx, &params);
640out:
641 wiphy_unlock(&rdev->wiphy);
642
643 return err;
Johannes Berg08645122009-05-11 13:54:58 +0200644}
Johannes Berg08645122009-05-11 13:54:58 +0200645
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200646static int cfg80211_wext_siwencodeext(struct net_device *dev,
647 struct iw_request_info *info,
648 struct iw_point *erq, char *extra)
Johannes Berg08645122009-05-11 13:54:58 +0200649{
650 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800651 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg08645122009-05-11 13:54:58 +0200652 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
653 const u8 *addr;
654 int idx;
655 bool remove = false;
656 struct key_params params;
657 u32 cipher;
Johannes Bergc88f9522021-01-28 18:35:27 +0100658 int ret;
Johannes Berg08645122009-05-11 13:54:58 +0200659
Johannes Bergfffd0932009-07-08 14:22:54 +0200660 if (wdev->iftype != NL80211_IFTYPE_STATION &&
661 wdev->iftype != NL80211_IFTYPE_ADHOC)
662 return -EOPNOTSUPP;
663
Johannes Berg08645122009-05-11 13:54:58 +0200664 /* no use -- only MFP (set_default_mgmt_key) is optional */
665 if (!rdev->ops->del_key ||
666 !rdev->ops->add_key ||
667 !rdev->ops->set_default_key)
668 return -EOPNOTSUPP;
669
670 switch (ext->alg) {
671 case IW_ENCODE_ALG_NONE:
672 remove = true;
673 cipher = 0;
674 break;
675 case IW_ENCODE_ALG_WEP:
676 if (ext->key_len == 5)
677 cipher = WLAN_CIPHER_SUITE_WEP40;
678 else if (ext->key_len == 13)
679 cipher = WLAN_CIPHER_SUITE_WEP104;
680 else
681 return -EINVAL;
682 break;
683 case IW_ENCODE_ALG_TKIP:
684 cipher = WLAN_CIPHER_SUITE_TKIP;
685 break;
686 case IW_ENCODE_ALG_CCMP:
687 cipher = WLAN_CIPHER_SUITE_CCMP;
688 break;
689 case IW_ENCODE_ALG_AES_CMAC:
690 cipher = WLAN_CIPHER_SUITE_AES_CMAC;
691 break;
692 default:
693 return -EOPNOTSUPP;
694 }
695
696 if (erq->flags & IW_ENCODE_DISABLED)
697 remove = true;
698
699 idx = erq->flags & IW_ENCODE_INDEX;
700 if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
701 if (idx < 4 || idx > 5) {
702 idx = wdev->wext.default_mgmt_key;
703 if (idx < 0)
704 return -EINVAL;
705 } else
706 idx--;
707 } else {
708 if (idx < 1 || idx > 4) {
709 idx = wdev->wext.default_key;
710 if (idx < 0)
711 return -EINVAL;
712 } else
713 idx--;
714 }
715
716 addr = ext->addr.sa_data;
717 if (is_broadcast_ether_addr(addr))
718 addr = NULL;
719
720 memset(&params, 0, sizeof(params));
721 params.key = ext->key;
722 params.key_len = ext->key_len;
723 params.cipher = cipher;
724
Jouni Malinenfaa8fdc2009-05-11 21:57:58 +0300725 if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
726 params.seq = ext->rx_seq;
727 params.seq_len = 6;
728 }
729
Johannes Bergc88f9522021-01-28 18:35:27 +0100730 wiphy_lock(wdev->wiphy);
731 ret = cfg80211_set_encryption(
Johannes Berge31b8212010-10-05 19:39:30 +0200732 rdev, dev,
733 !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY),
734 addr, remove,
Johannes Berg08645122009-05-11 13:54:58 +0200735 ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
736 idx, &params);
Johannes Bergc88f9522021-01-28 18:35:27 +0100737 wiphy_unlock(wdev->wiphy);
738
739 return ret;
Johannes Berg08645122009-05-11 13:54:58 +0200740}
Johannes Berg08645122009-05-11 13:54:58 +0200741
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200742static int cfg80211_wext_giwencode(struct net_device *dev,
743 struct iw_request_info *info,
744 struct iw_point *erq, char *keybuf)
Johannes Berg08645122009-05-11 13:54:58 +0200745{
746 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Bergfffd0932009-07-08 14:22:54 +0200747 int idx;
Johannes Berg08645122009-05-11 13:54:58 +0200748
Johannes Bergfffd0932009-07-08 14:22:54 +0200749 if (wdev->iftype != NL80211_IFTYPE_STATION &&
750 wdev->iftype != NL80211_IFTYPE_ADHOC)
Johannes Berg08645122009-05-11 13:54:58 +0200751 return -EOPNOTSUPP;
752
753 idx = erq->flags & IW_ENCODE_INDEX;
754 if (idx == 0) {
755 idx = wdev->wext.default_key;
756 if (idx < 0)
757 idx = 0;
758 } else if (idx < 1 || idx > 4)
759 return -EINVAL;
760 else
761 idx--;
762
763 erq->flags = idx + 1;
764
Johannes Bergfffd0932009-07-08 14:22:54 +0200765 if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) {
Johannes Berg08645122009-05-11 13:54:58 +0200766 erq->flags |= IW_ENCODE_DISABLED;
767 erq->length = 0;
768 return 0;
769 }
770
Johannes Bergfffd0932009-07-08 14:22:54 +0200771 erq->length = min_t(size_t, erq->length,
772 wdev->wext.keys->params[idx].key_len);
773 memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length);
774 erq->flags |= IW_ENCODE_ENABLED;
775
776 return 0;
Johannes Berg08645122009-05-11 13:54:58 +0200777}
Johannes Berg7643a2c2009-06-02 13:01:39 +0200778
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200779static int cfg80211_wext_siwfreq(struct net_device *dev,
780 struct iw_request_info *info,
781 struct iw_freq *wextfreq, char *extra)
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200782{
783 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800784 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg683b6d32012-11-08 21:25:48 +0100785 struct cfg80211_chan_def chandef = {
Johannes Berg3d9d1d62012-11-08 23:14:50 +0100786 .width = NL80211_CHAN_WIDTH_20_NOHT,
Johannes Berg683b6d32012-11-08 21:25:48 +0100787 };
Johannes Berga05829a2021-01-22 16:19:43 +0100788 int freq, ret;
789
790 wiphy_lock(&rdev->wiphy);
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200791
792 switch (wdev->iftype) {
793 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +0100794 ret = cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
795 break;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200796 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +0100797 ret = cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
798 break;
Johannes Bergf444de02010-05-05 15:25:02 +0200799 case NL80211_IFTYPE_MONITOR:
Zhao, Gang96998e32014-04-09 09:28:06 +0800800 freq = cfg80211_wext_freq(wextfreq);
Johannes Berga05829a2021-01-22 16:19:43 +0100801 if (freq < 0) {
802 ret = freq;
803 break;
804 }
805 if (freq == 0) {
806 ret = -EINVAL;
807 break;
808 }
Johannes Berg3d9d1d62012-11-08 23:14:50 +0100809 chandef.center_freq1 = freq;
Johannes Berg683b6d32012-11-08 21:25:48 +0100810 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
Johannes Berga05829a2021-01-22 16:19:43 +0100811 if (!chandef.chan) {
812 ret = -EINVAL;
813 break;
814 }
815 ret = cfg80211_set_monitor_channel(rdev, &chandef);
816 break;
Johannes Bergcc1d2802012-05-16 23:50:20 +0200817 case NL80211_IFTYPE_MESH_POINT:
Zhao, Gang96998e32014-04-09 09:28:06 +0800818 freq = cfg80211_wext_freq(wextfreq);
Johannes Berga05829a2021-01-22 16:19:43 +0100819 if (freq < 0) {
820 ret = freq;
821 break;
822 }
823 if (freq == 0) {
824 ret = -EINVAL;
825 break;
826 }
Johannes Berg3d9d1d62012-11-08 23:14:50 +0100827 chandef.center_freq1 = freq;
Johannes Berg683b6d32012-11-08 21:25:48 +0100828 chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
Johannes Berga05829a2021-01-22 16:19:43 +0100829 if (!chandef.chan) {
830 ret = -EINVAL;
831 break;
832 }
833 ret = cfg80211_set_mesh_channel(rdev, wdev, &chandef);
834 break;
Johannes Bergf444de02010-05-05 15:25:02 +0200835 default:
Johannes Berga05829a2021-01-22 16:19:43 +0100836 ret = -EOPNOTSUPP;
837 break;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200838 }
Johannes Berga05829a2021-01-22 16:19:43 +0100839
840 wiphy_unlock(&rdev->wiphy);
841
842 return ret;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200843}
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200844
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200845static int cfg80211_wext_giwfreq(struct net_device *dev,
846 struct iw_request_info *info,
847 struct iw_freq *freq, char *extra)
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200848{
849 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800850 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Bergf43e5212019-09-23 13:51:16 +0200851 struct cfg80211_chan_def chandef = {};
Johannes Berg683b6d32012-11-08 21:25:48 +0100852 int ret;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200853
Johannes Berga05829a2021-01-22 16:19:43 +0100854 wiphy_lock(&rdev->wiphy);
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200855 switch (wdev->iftype) {
856 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +0100857 ret = cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
858 break;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200859 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +0100860 ret = cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
861 break;
Johannes Berge9998822011-11-09 10:30:21 +0100862 case NL80211_IFTYPE_MONITOR:
Johannes Berga05829a2021-01-22 16:19:43 +0100863 if (!rdev->ops->get_channel) {
864 ret = -EINVAL;
865 break;
866 }
Johannes Berge9998822011-11-09 10:30:21 +0100867
Johannes Berg683b6d32012-11-08 21:25:48 +0100868 ret = rdev_get_channel(rdev, wdev, &chandef);
869 if (ret)
Johannes Berga05829a2021-01-22 16:19:43 +0100870 break;
Johannes Berg683b6d32012-11-08 21:25:48 +0100871 freq->m = chandef.chan->center_freq;
Johannes Berge9998822011-11-09 10:30:21 +0100872 freq->e = 6;
Johannes Berga05829a2021-01-22 16:19:43 +0100873 ret = 0;
874 break;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200875 default:
Johannes Berga05829a2021-01-22 16:19:43 +0100876 ret = -EINVAL;
877 break;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200878 }
Johannes Berga05829a2021-01-22 16:19:43 +0100879
880 wiphy_unlock(&rdev->wiphy);
881
882 return ret;
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200883}
Johannes Berg0e82ffe2009-07-27 12:01:50 +0200884
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200885static int cfg80211_wext_siwtxpower(struct net_device *dev,
886 struct iw_request_info *info,
887 union iwreq_data *data, char *extra)
Johannes Berg7643a2c2009-06-02 13:01:39 +0200888{
889 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800890 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +0300891 enum nl80211_tx_power_setting type;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200892 int dbm = 0;
Johannes Berga05829a2021-01-22 16:19:43 +0100893 int ret;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200894
895 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
896 return -EINVAL;
897 if (data->txpower.flags & IW_TXPOW_RANGE)
898 return -EINVAL;
899
900 if (!rdev->ops->set_tx_power)
901 return -EOPNOTSUPP;
902
903 /* only change when not disabling */
904 if (!data->txpower.disabled) {
Emmanuel Grumbach358ae882021-06-16 23:28:26 +0300905 rfkill_set_sw_state(rdev->wiphy.rfkill, false);
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200906
Johannes Berg7643a2c2009-06-02 13:01:39 +0200907 if (data->txpower.fixed) {
908 /*
909 * wext doesn't support negative values, see
910 * below where it's for automatic
911 */
912 if (data->txpower.value < 0)
913 return -EINVAL;
914 dbm = data->txpower.value;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +0300915 type = NL80211_TX_POWER_FIXED;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200916 /* TODO: do regulatory check! */
917 } else {
918 /*
919 * Automatic power level setting, max being the value
920 * passed in from userland.
921 */
922 if (data->txpower.value < 0) {
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +0300923 type = NL80211_TX_POWER_AUTOMATIC;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200924 } else {
925 dbm = data->txpower.value;
Juuso Oikarinenfa61cf72010-06-23 12:12:37 +0300926 type = NL80211_TX_POWER_LIMITED;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200927 }
928 }
929 } else {
Emmanuel Grumbach358ae882021-06-16 23:28:26 +0300930 if (rfkill_set_sw_state(rdev->wiphy.rfkill, true))
Johannes Berg3cfe91c2019-08-30 14:24:44 +0300931 schedule_work(&rdev->rfkill_block);
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200932 return 0;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200933 }
934
Johannes Berga05829a2021-01-22 16:19:43 +0100935 wiphy_lock(&rdev->wiphy);
936 ret = rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm));
937 wiphy_unlock(&rdev->wiphy);
938
939 return ret;
Johannes Berg7643a2c2009-06-02 13:01:39 +0200940}
Johannes Berg7643a2c2009-06-02 13:01:39 +0200941
Johannes Berg04b0c5c2011-07-15 13:01:38 +0200942static int cfg80211_wext_giwtxpower(struct net_device *dev,
943 struct iw_request_info *info,
944 union iwreq_data *data, char *extra)
Johannes Berg7643a2c2009-06-02 13:01:39 +0200945{
946 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +0800947 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg7643a2c2009-06-02 13:01:39 +0200948 int err, val;
949
950 if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
951 return -EINVAL;
952 if (data->txpower.flags & IW_TXPOW_RANGE)
953 return -EINVAL;
954
955 if (!rdev->ops->get_tx_power)
956 return -EOPNOTSUPP;
957
Johannes Berga05829a2021-01-22 16:19:43 +0100958 wiphy_lock(&rdev->wiphy);
Johannes Bergc8442112012-10-24 10:17:18 +0200959 err = rdev_get_tx_power(rdev, wdev, &val);
Johannes Berga05829a2021-01-22 16:19:43 +0100960 wiphy_unlock(&rdev->wiphy);
Johannes Berg1f87f7d2009-06-02 13:01:41 +0200961 if (err)
Johannes Berg7643a2c2009-06-02 13:01:39 +0200962 return err;
963
964 /* well... oh well */
965 data->txpower.fixed = 1;
Emmanuel Grumbach358ae882021-06-16 23:28:26 +0300966 data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill);
Johannes Berg7643a2c2009-06-02 13:01:39 +0200967 data->txpower.value = val;
968 data->txpower.flags = IW_TXPOW_DBM;
969
970 return 0;
971}
Johannes Bergf2129352009-07-01 21:26:56 +0200972
973static int cfg80211_set_auth_alg(struct wireless_dev *wdev,
974 s32 auth_alg)
975{
976 int nr_alg = 0;
977
978 if (!auth_alg)
979 return -EINVAL;
980
981 if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM |
982 IW_AUTH_ALG_SHARED_KEY |
983 IW_AUTH_ALG_LEAP))
984 return -EINVAL;
985
986 if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) {
987 nr_alg++;
988 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
989 }
990
991 if (auth_alg & IW_AUTH_ALG_SHARED_KEY) {
992 nr_alg++;
993 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY;
994 }
995
996 if (auth_alg & IW_AUTH_ALG_LEAP) {
997 nr_alg++;
998 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP;
999 }
1000
1001 if (nr_alg > 1)
1002 wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
1003
1004 return 0;
1005}
1006
1007static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions)
1008{
Johannes Bergf2129352009-07-01 21:26:56 +02001009 if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA |
Gábor Stefanik323d5662009-07-12 02:03:48 +02001010 IW_AUTH_WPA_VERSION_WPA2|
1011 IW_AUTH_WPA_VERSION_DISABLED))
Johannes Bergf2129352009-07-01 21:26:56 +02001012 return -EINVAL;
1013
Gábor Stefanik323d5662009-07-12 02:03:48 +02001014 if ((wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) &&
1015 (wpa_versions & (IW_AUTH_WPA_VERSION_WPA|
1016 IW_AUTH_WPA_VERSION_WPA2)))
1017 return -EINVAL;
1018
1019 if (wpa_versions & IW_AUTH_WPA_VERSION_DISABLED)
1020 wdev->wext.connect.crypto.wpa_versions &=
1021 ~(NL80211_WPA_VERSION_1|NL80211_WPA_VERSION_2);
1022
Johannes Bergf2129352009-07-01 21:26:56 +02001023 if (wpa_versions & IW_AUTH_WPA_VERSION_WPA)
1024 wdev->wext.connect.crypto.wpa_versions |=
1025 NL80211_WPA_VERSION_1;
1026
1027 if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2)
1028 wdev->wext.connect.crypto.wpa_versions |=
1029 NL80211_WPA_VERSION_2;
1030
1031 return 0;
1032}
1033
Johannes Berg4f5dadc2009-07-07 03:56:10 +02001034static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher)
Johannes Bergf2129352009-07-01 21:26:56 +02001035{
Johannes Bergf2129352009-07-01 21:26:56 +02001036 if (cipher & IW_AUTH_CIPHER_WEP40)
1037 wdev->wext.connect.crypto.cipher_group =
1038 WLAN_CIPHER_SUITE_WEP40;
1039 else if (cipher & IW_AUTH_CIPHER_WEP104)
1040 wdev->wext.connect.crypto.cipher_group =
1041 WLAN_CIPHER_SUITE_WEP104;
1042 else if (cipher & IW_AUTH_CIPHER_TKIP)
1043 wdev->wext.connect.crypto.cipher_group =
1044 WLAN_CIPHER_SUITE_TKIP;
1045 else if (cipher & IW_AUTH_CIPHER_CCMP)
1046 wdev->wext.connect.crypto.cipher_group =
1047 WLAN_CIPHER_SUITE_CCMP;
1048 else if (cipher & IW_AUTH_CIPHER_AES_CMAC)
1049 wdev->wext.connect.crypto.cipher_group =
1050 WLAN_CIPHER_SUITE_AES_CMAC;
Jouni Malinenc5f82892009-11-01 11:18:49 +02001051 else if (cipher & IW_AUTH_CIPHER_NONE)
1052 wdev->wext.connect.crypto.cipher_group = 0;
Johannes Bergf2129352009-07-01 21:26:56 +02001053 else
1054 return -EINVAL;
1055
1056 return 0;
1057}
1058
Johannes Berg4f5dadc2009-07-07 03:56:10 +02001059static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher)
Johannes Bergf2129352009-07-01 21:26:56 +02001060{
1061 int nr_ciphers = 0;
1062 u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
1063
1064 if (cipher & IW_AUTH_CIPHER_WEP40) {
1065 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40;
1066 nr_ciphers++;
1067 }
1068
1069 if (cipher & IW_AUTH_CIPHER_WEP104) {
1070 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104;
1071 nr_ciphers++;
1072 }
1073
1074 if (cipher & IW_AUTH_CIPHER_TKIP) {
1075 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP;
1076 nr_ciphers++;
1077 }
1078
1079 if (cipher & IW_AUTH_CIPHER_CCMP) {
1080 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP;
1081 nr_ciphers++;
1082 }
1083
1084 if (cipher & IW_AUTH_CIPHER_AES_CMAC) {
1085 ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC;
1086 nr_ciphers++;
1087 }
1088
1089 BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5);
1090
1091 wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers;
1092
1093 return 0;
1094}
1095
1096
Johannes Berg4f5dadc2009-07-07 03:56:10 +02001097static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt)
Johannes Bergf2129352009-07-01 21:26:56 +02001098{
1099 int nr_akm_suites = 0;
1100
1101 if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X |
1102 IW_AUTH_KEY_MGMT_PSK))
1103 return -EINVAL;
1104
1105 if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) {
1106 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
1107 WLAN_AKM_SUITE_8021X;
1108 nr_akm_suites++;
1109 }
1110
1111 if (key_mgt & IW_AUTH_KEY_MGMT_PSK) {
1112 wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
1113 WLAN_AKM_SUITE_PSK;
1114 nr_akm_suites++;
1115 }
1116
1117 wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites;
1118
1119 return 0;
1120}
1121
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001122static int cfg80211_wext_siwauth(struct net_device *dev,
1123 struct iw_request_info *info,
1124 struct iw_param *data, char *extra)
Johannes Bergf2129352009-07-01 21:26:56 +02001125{
1126 struct wireless_dev *wdev = dev->ieee80211_ptr;
1127
1128 if (wdev->iftype != NL80211_IFTYPE_STATION)
1129 return -EOPNOTSUPP;
1130
1131 switch (data->flags & IW_AUTH_INDEX) {
1132 case IW_AUTH_PRIVACY_INVOKED:
1133 wdev->wext.connect.privacy = data->value;
1134 return 0;
1135 case IW_AUTH_WPA_VERSION:
1136 return cfg80211_set_wpa_version(wdev, data->value);
1137 case IW_AUTH_CIPHER_GROUP:
1138 return cfg80211_set_cipher_group(wdev, data->value);
1139 case IW_AUTH_KEY_MGMT:
1140 return cfg80211_set_key_mgt(wdev, data->value);
1141 case IW_AUTH_CIPHER_PAIRWISE:
1142 return cfg80211_set_cipher_pairwise(wdev, data->value);
1143 case IW_AUTH_80211_AUTH_ALG:
1144 return cfg80211_set_auth_alg(wdev, data->value);
1145 case IW_AUTH_WPA_ENABLED:
1146 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1147 case IW_AUTH_DROP_UNENCRYPTED:
1148 case IW_AUTH_MFP:
1149 return 0;
1150 default:
1151 return -EOPNOTSUPP;
1152 }
1153}
Johannes Bergf2129352009-07-01 21:26:56 +02001154
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001155static int cfg80211_wext_giwauth(struct net_device *dev,
1156 struct iw_request_info *info,
1157 struct iw_param *data, char *extra)
Johannes Bergf2129352009-07-01 21:26:56 +02001158{
1159 /* XXX: what do we need? */
1160
1161 return -EOPNOTSUPP;
1162}
Johannes Bergbc92afd2009-07-01 21:26:57 +02001163
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001164static int cfg80211_wext_siwpower(struct net_device *dev,
1165 struct iw_request_info *info,
1166 struct iw_param *wrq, char *extra)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001167{
1168 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +08001169 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Yang Lic2a86372021-04-28 17:59:05 +08001170 bool ps;
Kalle Valoffb9eb32010-02-17 17:58:10 +02001171 int timeout = wdev->ps_timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001172 int err;
1173
1174 if (wdev->iftype != NL80211_IFTYPE_STATION)
1175 return -EINVAL;
1176
1177 if (!rdev->ops->set_power_mgmt)
1178 return -EOPNOTSUPP;
1179
1180 if (wrq->disabled) {
1181 ps = false;
1182 } else {
1183 switch (wrq->flags & IW_POWER_MODE) {
1184 case IW_POWER_ON: /* If not specified */
1185 case IW_POWER_MODE: /* If set all mask */
1186 case IW_POWER_ALL_R: /* If explicitely state all */
1187 ps = true;
1188 break;
1189 default: /* Otherwise we ignore */
1190 return -EINVAL;
1191 }
1192
1193 if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
1194 return -EINVAL;
1195
1196 if (wrq->flags & IW_POWER_TIMEOUT)
1197 timeout = wrq->value / 1000;
1198 }
1199
Johannes Berga05829a2021-01-22 16:19:43 +01001200 wiphy_lock(&rdev->wiphy);
Hila Gonene35e4d22012-06-27 17:19:42 +03001201 err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
Johannes Berga05829a2021-01-22 16:19:43 +01001202 wiphy_unlock(&rdev->wiphy);
Johannes Bergbc92afd2009-07-01 21:26:57 +02001203 if (err)
1204 return err;
1205
Kalle Valoffb9eb32010-02-17 17:58:10 +02001206 wdev->ps = ps;
1207 wdev->ps_timeout = timeout;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001208
1209 return 0;
1210
1211}
Johannes Bergbc92afd2009-07-01 21:26:57 +02001212
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001213static int cfg80211_wext_giwpower(struct net_device *dev,
1214 struct iw_request_info *info,
1215 struct iw_param *wrq, char *extra)
Johannes Bergbc92afd2009-07-01 21:26:57 +02001216{
1217 struct wireless_dev *wdev = dev->ieee80211_ptr;
1218
Kalle Valoffb9eb32010-02-17 17:58:10 +02001219 wrq->disabled = !wdev->ps;
Johannes Bergbc92afd2009-07-01 21:26:57 +02001220
1221 return 0;
1222}
Johannes Bergab737a42009-07-01 21:26:58 +02001223
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001224static int cfg80211_wext_siwrate(struct net_device *dev,
1225 struct iw_request_info *info,
1226 struct iw_param *rate, char *extra)
Johannes Berg99303802009-07-01 21:26:59 +02001227{
1228 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +08001229 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg99303802009-07-01 21:26:59 +02001230 struct cfg80211_bitrate_mask mask;
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001231 u32 fixed, maxrate;
1232 struct ieee80211_supported_band *sband;
Johannes Berga05829a2021-01-22 16:19:43 +01001233 int band, ridx, ret;
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001234 bool match = false;
Johannes Berg99303802009-07-01 21:26:59 +02001235
1236 if (!rdev->ops->set_bitrate_mask)
1237 return -EOPNOTSUPP;
1238
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001239 memset(&mask, 0, sizeof(mask));
1240 fixed = 0;
John W. Linville54233262010-01-27 09:44:48 -05001241 maxrate = (u32)-1;
Johannes Berg99303802009-07-01 21:26:59 +02001242
1243 if (rate->value < 0) {
1244 /* nothing */
1245 } else if (rate->fixed) {
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001246 fixed = rate->value / 100000;
Johannes Berg99303802009-07-01 21:26:59 +02001247 } else {
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001248 maxrate = rate->value / 100000;
Johannes Berg99303802009-07-01 21:26:59 +02001249 }
1250
Johannes Berg57fbcce2016-04-12 15:56:15 +02001251 for (band = 0; band < NUM_NL80211_BANDS; band++) {
Jouni Malinen37eb0b12010-01-06 13:09:08 +02001252 sband = wdev->wiphy->bands[band];
1253 if (sband == NULL)
1254 continue;
1255 for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
1256 struct ieee80211_rate *srate = &sband->bitrates[ridx];
1257 if (fixed == srate->bitrate) {
1258 mask.control[band].legacy = 1 << ridx;
1259 match = true;
1260 break;
1261 }
1262 if (srate->bitrate <= maxrate) {
1263 mask.control[band].legacy |= 1 << ridx;
1264 match = true;
1265 }
1266 }
1267 }
1268
1269 if (!match)
1270 return -EINVAL;
1271
Johannes Berga05829a2021-01-22 16:19:43 +01001272 wiphy_lock(&rdev->wiphy);
1273 ret = rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
1274 wiphy_unlock(&rdev->wiphy);
1275
1276 return ret;
Johannes Berg99303802009-07-01 21:26:59 +02001277}
Johannes Berg99303802009-07-01 21:26:59 +02001278
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001279static int cfg80211_wext_giwrate(struct net_device *dev,
1280 struct iw_request_info *info,
1281 struct iw_param *rate, char *extra)
Johannes Berg99303802009-07-01 21:26:59 +02001282{
1283 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +08001284 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg5762d7d2018-01-16 23:20:22 +01001285 struct station_info sinfo = {};
Johannes Berga71d62d2009-07-07 23:41:27 +02001286 u8 addr[ETH_ALEN];
Johannes Berg99303802009-07-01 21:26:59 +02001287 int err;
1288
1289 if (wdev->iftype != NL80211_IFTYPE_STATION)
1290 return -EOPNOTSUPP;
1291
1292 if (!rdev->ops->get_station)
1293 return -EOPNOTSUPP;
1294
Johannes Berga71d62d2009-07-07 23:41:27 +02001295 err = 0;
1296 wdev_lock(wdev);
Samuel Ortiz6c230c02009-07-03 02:00:48 +02001297 if (wdev->current_bss)
Johannes Berga71d62d2009-07-07 23:41:27 +02001298 memcpy(addr, wdev->current_bss->pub.bssid, ETH_ALEN);
Samuel Ortiz6c230c02009-07-03 02:00:48 +02001299 else
Johannes Berga71d62d2009-07-07 23:41:27 +02001300 err = -EOPNOTSUPP;
1301 wdev_unlock(wdev);
1302 if (err)
1303 return err;
Johannes Berg99303802009-07-01 21:26:59 +02001304
Johannes Berga05829a2021-01-22 16:19:43 +01001305 wiphy_lock(&rdev->wiphy);
Hila Gonene35e4d22012-06-27 17:19:42 +03001306 err = rdev_get_station(rdev, dev, addr, &sinfo);
Johannes Berga05829a2021-01-22 16:19:43 +01001307 wiphy_unlock(&rdev->wiphy);
Johannes Berg99303802009-07-01 21:26:59 +02001308 if (err)
1309 return err;
1310
Stefan Seyfried848e6162018-09-30 12:53:00 +02001311 if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
1312 err = -EOPNOTSUPP;
1313 goto free;
1314 }
Johannes Berg99303802009-07-01 21:26:59 +02001315
John W. Linville254416a2009-12-09 16:43:52 -05001316 rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
Johannes Berg99303802009-07-01 21:26:59 +02001317
Stefan Seyfried848e6162018-09-30 12:53:00 +02001318free:
1319 cfg80211_sinfo_release_content(&sinfo);
1320 return err;
Johannes Berg99303802009-07-01 21:26:59 +02001321}
Johannes Berg89906462009-07-01 21:27:00 +02001322
1323/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001324static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
Johannes Berg89906462009-07-01 21:27:00 +02001325{
1326 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +08001327 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Johannes Berg89906462009-07-01 21:27:00 +02001328 /* we are under RTNL - globally locked - so can use static structs */
1329 static struct iw_statistics wstats;
Stefan Seyfried848e6162018-09-30 12:53:00 +02001330 static struct station_info sinfo = {};
Johannes Bergc56c5712009-07-10 16:54:07 +02001331 u8 bssid[ETH_ALEN];
Johannes Berga05829a2021-01-22 16:19:43 +01001332 int ret;
Johannes Berg89906462009-07-01 21:27:00 +02001333
1334 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
1335 return NULL;
1336
1337 if (!rdev->ops->get_station)
1338 return NULL;
1339
Johannes Bergc56c5712009-07-10 16:54:07 +02001340 /* Grab BSSID of current BSS, if any */
1341 wdev_lock(wdev);
1342 if (!wdev->current_bss) {
1343 wdev_unlock(wdev);
Johannes Berg89906462009-07-01 21:27:00 +02001344 return NULL;
Johannes Bergc56c5712009-07-10 16:54:07 +02001345 }
1346 memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
1347 wdev_unlock(wdev);
Johannes Berg89906462009-07-01 21:27:00 +02001348
Johannes Berg9c5a18a2015-06-09 21:35:44 +02001349 memset(&sinfo, 0, sizeof(sinfo));
1350
Johannes Berga05829a2021-01-22 16:19:43 +01001351 wiphy_lock(&rdev->wiphy);
1352 ret = rdev_get_station(rdev, dev, bssid, &sinfo);
1353 wiphy_unlock(&rdev->wiphy);
1354
1355 if (ret)
Johannes Berg89906462009-07-01 21:27:00 +02001356 return NULL;
1357
1358 memset(&wstats, 0, sizeof(wstats));
1359
1360 switch (rdev->wiphy.signal_type) {
1361 case CFG80211_SIGNAL_TYPE_MBM:
Omer Efrat397c6572018-06-17 13:06:14 +03001362 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
Johannes Berg89906462009-07-01 21:27:00 +02001363 int sig = sinfo.signal;
1364 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1365 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
1366 wstats.qual.updated |= IW_QUAL_DBM;
1367 wstats.qual.level = sig;
1368 if (sig < -110)
1369 sig = -110;
1370 else if (sig > -40)
1371 sig = -40;
1372 wstats.qual.qual = sig + 110;
1373 break;
1374 }
Miaohe Lin7b506ff2020-08-22 04:23:23 -04001375 fallthrough;
Johannes Berg89906462009-07-01 21:27:00 +02001376 case CFG80211_SIGNAL_TYPE_UNSPEC:
Omer Efrat397c6572018-06-17 13:06:14 +03001377 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
Johannes Berg89906462009-07-01 21:27:00 +02001378 wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
1379 wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
1380 wstats.qual.level = sinfo.signal;
1381 wstats.qual.qual = sinfo.signal;
1382 break;
1383 }
Miaohe Lin7b506ff2020-08-22 04:23:23 -04001384 fallthrough;
Johannes Berg89906462009-07-01 21:27:00 +02001385 default:
1386 wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
1387 wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
1388 }
1389
1390 wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
Omer Efrat397c6572018-06-17 13:06:14 +03001391 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC))
Ben Greear5a5c7312010-10-07 16:39:20 -07001392 wstats.discard.misc = sinfo.rx_dropped_misc;
Omer Efrat397c6572018-06-17 13:06:14 +03001393 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))
Ben Greear5a5c7312010-10-07 16:39:20 -07001394 wstats.discard.retries = sinfo.tx_failed;
Johannes Berg89906462009-07-01 21:27:00 +02001395
Stefan Seyfried848e6162018-09-30 12:53:00 +02001396 cfg80211_sinfo_release_content(&sinfo);
1397
Johannes Berg89906462009-07-01 21:27:00 +02001398 return &wstats;
1399}
Johannes Berg562e4822009-07-27 12:01:51 +02001400
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001401static int cfg80211_wext_siwap(struct net_device *dev,
1402 struct iw_request_info *info,
1403 struct sockaddr *ap_addr, char *extra)
Johannes Berg562e4822009-07-27 12:01:51 +02001404{
1405 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berga05829a2021-01-22 16:19:43 +01001406 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1407 int ret;
Johannes Berg562e4822009-07-27 12:01:51 +02001408
Johannes Berga05829a2021-01-22 16:19:43 +01001409 wiphy_lock(&rdev->wiphy);
Johannes Berg562e4822009-07-27 12:01:51 +02001410 switch (wdev->iftype) {
1411 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +01001412 ret = cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
1413 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001414 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +01001415 ret = cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
1416 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001417 default:
Johannes Berga05829a2021-01-22 16:19:43 +01001418 ret = -EOPNOTSUPP;
1419 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001420 }
Johannes Berga05829a2021-01-22 16:19:43 +01001421 wiphy_unlock(&rdev->wiphy);
1422
1423 return ret;
Johannes Berg562e4822009-07-27 12:01:51 +02001424}
Johannes Berg562e4822009-07-27 12:01:51 +02001425
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001426static int cfg80211_wext_giwap(struct net_device *dev,
1427 struct iw_request_info *info,
1428 struct sockaddr *ap_addr, char *extra)
Johannes Berg562e4822009-07-27 12:01:51 +02001429{
1430 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berga05829a2021-01-22 16:19:43 +01001431 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1432 int ret;
Johannes Berg562e4822009-07-27 12:01:51 +02001433
Johannes Berga05829a2021-01-22 16:19:43 +01001434 wiphy_lock(&rdev->wiphy);
Johannes Berg562e4822009-07-27 12:01:51 +02001435 switch (wdev->iftype) {
1436 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +01001437 ret = cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
1438 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001439 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +01001440 ret = cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
1441 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001442 default:
Johannes Berga05829a2021-01-22 16:19:43 +01001443 ret = -EOPNOTSUPP;
1444 break;
Johannes Berg562e4822009-07-27 12:01:51 +02001445 }
Johannes Berga05829a2021-01-22 16:19:43 +01001446 wiphy_unlock(&rdev->wiphy);
1447
1448 return ret;
Johannes Berg562e4822009-07-27 12:01:51 +02001449}
Johannes Berg1f9298f2009-07-27 12:01:52 +02001450
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001451static int cfg80211_wext_siwessid(struct net_device *dev,
1452 struct iw_request_info *info,
1453 struct iw_point *data, char *ssid)
Johannes Berg1f9298f2009-07-27 12:01:52 +02001454{
1455 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berga05829a2021-01-22 16:19:43 +01001456 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1457 int ret;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001458
Johannes Berga05829a2021-01-22 16:19:43 +01001459 wiphy_lock(&rdev->wiphy);
Johannes Berg1f9298f2009-07-27 12:01:52 +02001460 switch (wdev->iftype) {
1461 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +01001462 ret = cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
1463 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001464 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +01001465 ret = cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
1466 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001467 default:
Johannes Berga05829a2021-01-22 16:19:43 +01001468 ret = -EOPNOTSUPP;
1469 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001470 }
Johannes Berga05829a2021-01-22 16:19:43 +01001471 wiphy_unlock(&rdev->wiphy);
1472
1473 return ret;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001474}
Johannes Berg1f9298f2009-07-27 12:01:52 +02001475
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001476static int cfg80211_wext_giwessid(struct net_device *dev,
1477 struct iw_request_info *info,
1478 struct iw_point *data, char *ssid)
Johannes Berg1f9298f2009-07-27 12:01:52 +02001479{
1480 struct wireless_dev *wdev = dev->ieee80211_ptr;
Johannes Berga05829a2021-01-22 16:19:43 +01001481 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1482 int ret;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001483
Johannes Berg42da2f92010-08-30 12:24:54 +02001484 data->flags = 0;
1485 data->length = 0;
1486
Johannes Berga05829a2021-01-22 16:19:43 +01001487 wiphy_lock(&rdev->wiphy);
Johannes Berg1f9298f2009-07-27 12:01:52 +02001488 switch (wdev->iftype) {
1489 case NL80211_IFTYPE_ADHOC:
Johannes Berga05829a2021-01-22 16:19:43 +01001490 ret = cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
1491 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001492 case NL80211_IFTYPE_STATION:
Johannes Berga05829a2021-01-22 16:19:43 +01001493 ret = cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
1494 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001495 default:
Johannes Berga05829a2021-01-22 16:19:43 +01001496 ret = -EOPNOTSUPP;
1497 break;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001498 }
Johannes Berga05829a2021-01-22 16:19:43 +01001499 wiphy_unlock(&rdev->wiphy);
1500
1501 return ret;
Johannes Berg1f9298f2009-07-27 12:01:52 +02001502}
Johannes Berga9a11622009-07-27 12:01:53 +02001503
Johannes Berg04b0c5c2011-07-15 13:01:38 +02001504static int cfg80211_wext_siwpmksa(struct net_device *dev,
1505 struct iw_request_info *info,
1506 struct iw_point *data, char *extra)
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001507{
1508 struct wireless_dev *wdev = dev->ieee80211_ptr;
Zhao, Gangf26cbf42014-04-21 12:53:03 +08001509 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001510 struct cfg80211_pmksa cfg_pmksa;
1511 struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
Johannes Berga05829a2021-01-22 16:19:43 +01001512 int ret;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001513
1514 memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa));
1515
1516 if (wdev->iftype != NL80211_IFTYPE_STATION)
1517 return -EINVAL;
1518
1519 cfg_pmksa.bssid = pmksa->bssid.sa_data;
1520 cfg_pmksa.pmkid = pmksa->pmkid;
1521
Johannes Berga05829a2021-01-22 16:19:43 +01001522 wiphy_lock(&rdev->wiphy);
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001523 switch (pmksa->cmd) {
1524 case IW_PMKSA_ADD:
Johannes Berga05829a2021-01-22 16:19:43 +01001525 if (!rdev->ops->set_pmksa) {
1526 ret = -EOPNOTSUPP;
1527 break;
1528 }
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001529
Johannes Berga05829a2021-01-22 16:19:43 +01001530 ret = rdev_set_pmksa(rdev, dev, &cfg_pmksa);
1531 break;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001532 case IW_PMKSA_REMOVE:
Johannes Berga05829a2021-01-22 16:19:43 +01001533 if (!rdev->ops->del_pmksa) {
1534 ret = -EOPNOTSUPP;
1535 break;
1536 }
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001537
Johannes Berga05829a2021-01-22 16:19:43 +01001538 ret = rdev_del_pmksa(rdev, dev, &cfg_pmksa);
1539 break;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001540 case IW_PMKSA_FLUSH:
Johannes Berga05829a2021-01-22 16:19:43 +01001541 if (!rdev->ops->flush_pmksa) {
1542 ret = -EOPNOTSUPP;
1543 break;
1544 }
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001545
Johannes Berga05829a2021-01-22 16:19:43 +01001546 ret = rdev_flush_pmksa(rdev, dev);
1547 break;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001548 default:
Johannes Berga05829a2021-01-22 16:19:43 +01001549 ret = -EOPNOTSUPP;
1550 break;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001551 }
Johannes Berga05829a2021-01-22 16:19:43 +01001552 wiphy_unlock(&rdev->wiphy);
1553
1554 return ret;
Samuel Ortiz2944b2c2009-11-25 00:01:01 +01001555}
1556
Sami Tolvanen32fc4a92020-11-17 12:59:02 -08001557#define DEFINE_WEXT_COMPAT_STUB(func, type) \
1558 static int __ ## func(struct net_device *dev, \
1559 struct iw_request_info *info, \
1560 union iwreq_data *wrqu, \
1561 char *extra) \
1562 { \
1563 return func(dev, info, (type *)wrqu, extra); \
1564 }
1565
1566DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwname, char)
1567DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwfreq, struct iw_freq)
1568DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwfreq, struct iw_freq)
1569DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwmode, u32)
1570DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwmode, u32)
1571DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrange, struct iw_point)
1572DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwap, struct sockaddr)
1573DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwap, struct sockaddr)
1574DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwmlme, struct iw_point)
1575DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwscan, struct iw_point)
1576DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwessid, struct iw_point)
1577DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwessid, struct iw_point)
1578DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwrate, struct iw_param)
1579DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrate, struct iw_param)
1580DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwrts, struct iw_param)
1581DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwrts, struct iw_param)
1582DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwfrag, struct iw_param)
1583DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwfrag, struct iw_param)
1584DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwretry, struct iw_param)
1585DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwretry, struct iw_param)
1586DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwencode, struct iw_point)
1587DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwencode, struct iw_point)
1588DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwpower, struct iw_param)
1589DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwpower, struct iw_param)
1590DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwgenie, struct iw_point)
1591DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_giwauth, struct iw_param)
1592DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwauth, struct iw_param)
1593DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwencodeext, struct iw_point)
1594DEFINE_WEXT_COMPAT_STUB(cfg80211_wext_siwpmksa, struct iw_point)
1595
Johannes Berga9a11622009-07-27 12:01:53 +02001596static const iw_handler cfg80211_handlers[] = {
Sami Tolvanen32fc4a92020-11-17 12:59:02 -08001597 [IW_IOCTL_IDX(SIOCGIWNAME)] = __cfg80211_wext_giwname,
1598 [IW_IOCTL_IDX(SIOCSIWFREQ)] = __cfg80211_wext_siwfreq,
1599 [IW_IOCTL_IDX(SIOCGIWFREQ)] = __cfg80211_wext_giwfreq,
1600 [IW_IOCTL_IDX(SIOCSIWMODE)] = __cfg80211_wext_siwmode,
1601 [IW_IOCTL_IDX(SIOCGIWMODE)] = __cfg80211_wext_giwmode,
1602 [IW_IOCTL_IDX(SIOCGIWRANGE)] = __cfg80211_wext_giwrange,
1603 [IW_IOCTL_IDX(SIOCSIWAP)] = __cfg80211_wext_siwap,
1604 [IW_IOCTL_IDX(SIOCGIWAP)] = __cfg80211_wext_giwap,
1605 [IW_IOCTL_IDX(SIOCSIWMLME)] = __cfg80211_wext_siwmlme,
1606 [IW_IOCTL_IDX(SIOCSIWSCAN)] = cfg80211_wext_siwscan,
1607 [IW_IOCTL_IDX(SIOCGIWSCAN)] = __cfg80211_wext_giwscan,
1608 [IW_IOCTL_IDX(SIOCSIWESSID)] = __cfg80211_wext_siwessid,
1609 [IW_IOCTL_IDX(SIOCGIWESSID)] = __cfg80211_wext_giwessid,
1610 [IW_IOCTL_IDX(SIOCSIWRATE)] = __cfg80211_wext_siwrate,
1611 [IW_IOCTL_IDX(SIOCGIWRATE)] = __cfg80211_wext_giwrate,
1612 [IW_IOCTL_IDX(SIOCSIWRTS)] = __cfg80211_wext_siwrts,
1613 [IW_IOCTL_IDX(SIOCGIWRTS)] = __cfg80211_wext_giwrts,
1614 [IW_IOCTL_IDX(SIOCSIWFRAG)] = __cfg80211_wext_siwfrag,
1615 [IW_IOCTL_IDX(SIOCGIWFRAG)] = __cfg80211_wext_giwfrag,
1616 [IW_IOCTL_IDX(SIOCSIWTXPOW)] = cfg80211_wext_siwtxpower,
1617 [IW_IOCTL_IDX(SIOCGIWTXPOW)] = cfg80211_wext_giwtxpower,
1618 [IW_IOCTL_IDX(SIOCSIWRETRY)] = __cfg80211_wext_siwretry,
1619 [IW_IOCTL_IDX(SIOCGIWRETRY)] = __cfg80211_wext_giwretry,
1620 [IW_IOCTL_IDX(SIOCSIWENCODE)] = __cfg80211_wext_siwencode,
1621 [IW_IOCTL_IDX(SIOCGIWENCODE)] = __cfg80211_wext_giwencode,
1622 [IW_IOCTL_IDX(SIOCSIWPOWER)] = __cfg80211_wext_siwpower,
1623 [IW_IOCTL_IDX(SIOCGIWPOWER)] = __cfg80211_wext_giwpower,
1624 [IW_IOCTL_IDX(SIOCSIWGENIE)] = __cfg80211_wext_siwgenie,
1625 [IW_IOCTL_IDX(SIOCSIWAUTH)] = __cfg80211_wext_siwauth,
1626 [IW_IOCTL_IDX(SIOCGIWAUTH)] = __cfg80211_wext_giwauth,
1627 [IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= __cfg80211_wext_siwencodeext,
1628 [IW_IOCTL_IDX(SIOCSIWPMKSA)] = __cfg80211_wext_siwpmksa,
Johannes Berga9a11622009-07-27 12:01:53 +02001629};
1630
1631const struct iw_handler_def cfg80211_wext_handler = {
1632 .num_standard = ARRAY_SIZE(cfg80211_handlers),
1633 .standard = cfg80211_handlers,
1634 .get_wireless_stats = cfg80211_wireless_stats,
1635};