| 1 | |
| 2 | |
| 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 | *
|
| 9 | * Copyright 2008-2009 Johannes Berg <[email protected]>
|
| 10 | * Copyright (C) 2019-2023, 2026 Intel Corporation
|
| 11 |
|
| 12 |
|
| 13 | #include <linux/export.h>
|
| 14 | #include <linux/wireless.h>
|
| 15 | #include <linux/nl80211.h>
|
| 16 | #include <linux/if_arp.h>
|
| 17 | #include <linux/etherdevice.h>
|
| 18 | #include <linux/slab.h>
|
| 19 | #include <linux/string.h>
|
| 20 | #include <net/iw_handler.h>
|
| 21 | #include <net/cfg80211.h>
|
| 22 | #include <net/cfg80211-wext.h>
|
| 23 | #include "wext-compat.h"
|
| 24 | #include "core.h"
|
| 25 | #include "rdev-ops.h"
|
| 26 |
|
| 27 | int cfg80211_wext_giwname(struct net_device *dev,
|
| 28 | struct iw_request_info *info,
|
| 29 | union iwreq_data *wrqu, char *extra)
|
| 30 | {
|
| 31 | strscpy(wrqu->name, "IEEE 802.11");
|
| 32 | return 0;
|
| 33 | }
|
| 34 |
|
| 35 | int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
|
| 36 | union iwreq_data *wrqu, char *extra)
|
| 37 | {
|
| 38 | __u32 *mode = &wrqu->mode;
|
| 39 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 40 | struct cfg80211_registered_device *rdev;
|
| 41 | struct vif_params vifparams;
|
| 42 | enum nl80211_iftype type;
|
| 43 |
|
| 44 | rdev = wiphy_to_rdev(wdev->wiphy);
|
| 45 |
|
| 46 | 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;
|
| 53 | case IW_MODE_MONITOR:
|
| 54 | type = NL80211_IFTYPE_MONITOR;
|
| 55 | break;
|
| 56 | default:
|
| 57 | return -EINVAL;
|
| 58 | }
|
| 59 |
|
| 60 | if (type == wdev->iftype)
|
| 61 | return 0;
|
| 62 |
|
| 63 | memset(&vifparams, 0, sizeof(vifparams));
|
| 64 |
|
| 65 | guard(wiphy)(wdev->wiphy);
|
| 66 |
|
| 67 | return cfg80211_change_iface(rdev, dev, type, &vifparams);
|
| 68 | }
|
| 69 |
|
| 70 | int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
|
| 71 | union iwreq_data *wrqu, char *extra)
|
| 72 | {
|
| 73 | __u32 *mode = &wrqu->mode;
|
| 74 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 75 |
|
| 76 | if (!wdev)
|
| 77 | return -EOPNOTSUPP;
|
| 78 |
|
| 79 | switch (wdev->iftype) {
|
| 80 | case NL80211_IFTYPE_AP:
|
| 81 | *mode = IW_MODE_MASTER;
|
| 82 | break;
|
| 83 | case NL80211_IFTYPE_STATION:
|
| 84 | *mode = IW_MODE_INFRA;
|
| 85 | break;
|
| 86 | case NL80211_IFTYPE_ADHOC:
|
| 87 | *mode = IW_MODE_ADHOC;
|
| 88 | break;
|
| 89 | case NL80211_IFTYPE_MONITOR:
|
| 90 | *mode = IW_MODE_MONITOR;
|
| 91 | break;
|
| 92 | case NL80211_IFTYPE_WDS:
|
| 93 | *mode = IW_MODE_REPEAT;
|
| 94 | break;
|
| 95 | case NL80211_IFTYPE_AP_VLAN:
|
| 96 | *mode = IW_MODE_SECOND;
|
| 97 | break;
|
| 98 | default:
|
| 99 | *mode = IW_MODE_AUTO;
|
| 100 | break;
|
| 101 | }
|
| 102 | return 0;
|
| 103 | }
|
| 104 |
|
| 105 |
|
| 106 | int cfg80211_wext_giwrange(struct net_device *dev,
|
| 107 | struct iw_request_info *info,
|
| 108 | union iwreq_data *wrqu, char *extra)
|
| 109 | {
|
| 110 | struct iw_point *data = &wrqu->data;
|
| 111 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 112 | struct iw_range *range = (struct iw_range *) extra;
|
| 113 | enum nl80211_band band;
|
| 114 | int i, c = 0;
|
| 115 |
|
| 116 | if (!wdev)
|
| 117 | return -EOPNOTSUPP;
|
| 118 |
|
| 119 | data->length = sizeof(struct iw_range);
|
| 120 | memset(range, 0, sizeof(struct iw_range));
|
| 121 |
|
| 122 | range->we_version_compiled = WIRELESS_EXT;
|
| 123 | range->we_version_source = 21;
|
| 124 | range->retry_capa = IW_RETRY_LIMIT;
|
| 125 | range->retry_flags = IW_RETRY_LIMIT;
|
| 126 | range->min_retry = 0;
|
| 127 | range->max_retry = 255;
|
| 128 | range->min_rts = 0;
|
| 129 | range->max_rts = 2347;
|
| 130 | range->min_frag = 256;
|
| 131 | range->max_frag = 2346;
|
| 132 |
|
| 133 | range->max_encoding_tokens = 4;
|
| 134 |
|
| 135 | range->max_qual.updated = IW_QUAL_NOISE_INVALID;
|
| 136 |
|
| 137 | switch (wdev->wiphy->signal_type) {
|
| 138 | case CFG80211_SIGNAL_TYPE_NONE:
|
| 139 | break;
|
| 140 | case CFG80211_SIGNAL_TYPE_MBM:
|
| 141 | range->max_qual.level = (u8)-110;
|
| 142 | range->max_qual.qual = 70;
|
| 143 | range->avg_qual.qual = 35;
|
| 144 | range->max_qual.updated |= IW_QUAL_DBM;
|
| 145 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
| 146 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
| 147 | break;
|
| 148 | case CFG80211_SIGNAL_TYPE_UNSPEC:
|
| 149 | range->max_qual.level = 100;
|
| 150 | range->max_qual.qual = 100;
|
| 151 | range->avg_qual.qual = 50;
|
| 152 | range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
| 153 | range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
| 154 | break;
|
| 155 | }
|
| 156 |
|
| 157 | range->avg_qual.level = range->max_qual.level / 2;
|
| 158 | range->avg_qual.noise = range->max_qual.noise / 2;
|
| 159 | range->avg_qual.updated = range->max_qual.updated;
|
| 160 |
|
| 161 | for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) {
|
| 162 | switch (wdev->wiphy->cipher_suites[i]) {
|
| 163 | case WLAN_CIPHER_SUITE_TKIP:
|
| 164 | range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP |
|
| 165 | IW_ENC_CAPA_WPA);
|
| 166 | break;
|
| 167 |
|
| 168 | case WLAN_CIPHER_SUITE_CCMP:
|
| 169 | range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP |
|
| 170 | IW_ENC_CAPA_WPA2);
|
| 171 | break;
|
| 172 |
|
| 173 | case WLAN_CIPHER_SUITE_WEP40:
|
| 174 | range->encoding_size[range->num_encoding_sizes++] =
|
| 175 | WLAN_KEY_LEN_WEP40;
|
| 176 | break;
|
| 177 |
|
| 178 | case WLAN_CIPHER_SUITE_WEP104:
|
| 179 | range->encoding_size[range->num_encoding_sizes++] =
|
| 180 | WLAN_KEY_LEN_WEP104;
|
| 181 | break;
|
| 182 | }
|
| 183 | }
|
| 184 |
|
| 185 | for (band = 0; band < NUM_NL80211_BANDS; band ++) {
|
| 186 | struct ieee80211_supported_band *sband;
|
| 187 |
|
| 188 | sband = wdev->wiphy->bands[band];
|
| 189 |
|
| 190 | if (!sband)
|
| 191 | continue;
|
| 192 |
|
| 193 | for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
|
| 194 | struct ieee80211_channel *chan = &sband->channels[i];
|
| 195 |
|
| 196 | if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
|
| 197 | range->freq[c].i =
|
| 198 | ieee80211_frequency_to_channel(
|
| 199 | chan->center_freq);
|
| 200 | range->freq[c].m = chan->center_freq;
|
| 201 | range->freq[c].e = 6;
|
| 202 | c++;
|
| 203 | }
|
| 204 | }
|
| 205 | }
|
| 206 | range->num_channels = c;
|
| 207 | range->num_frequency = c;
|
| 208 |
|
| 209 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
|
| 210 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
|
| 211 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
|
| 212 |
|
| 213 | if (wdev->wiphy->max_scan_ssids > 0)
|
| 214 | range->scan_capa |= IW_SCAN_CAPA_ESSID;
|
| 215 |
|
| 216 | return 0;
|
| 217 | }
|
| 218 |
|
| 219 |
|
| 220 | |
| 221 | * cfg80211_wext_freq - get wext frequency for non-"auto"
|
| 222 | * @freq: the wext freq encoding
|
| 223 | *
|
| 224 | * Returns: a frequency, or a negative error code, or 0 for auto.
|
| 225 |
|
| 226 | int cfg80211_wext_freq(struct iw_freq *freq)
|
| 227 | {
|
| 228 | |
| 229 | * Parse frequency - return 0 for auto and
|
| 230 | * -EINVAL for impossible things.
|
| 231 |
|
| 232 | if (freq->e == 0) {
|
| 233 | enum nl80211_band band = NL80211_BAND_2GHZ;
|
| 234 | if (freq->m < 0)
|
| 235 | return 0;
|
| 236 | if (freq->m > 14)
|
| 237 | band = NL80211_BAND_5GHZ;
|
| 238 | return ieee80211_channel_to_frequency(freq->m, band);
|
| 239 | } else {
|
| 240 | int i, div = 1000000;
|
| 241 | for (i = 0; i < freq->e; i++)
|
| 242 | div /= 10;
|
| 243 | if (div <= 0)
|
| 244 | return -EINVAL;
|
| 245 | return freq->m / div;
|
| 246 | }
|
| 247 | }
|
| 248 |
|
| 249 | int cfg80211_wext_siwrts(struct net_device *dev,
|
| 250 | struct iw_request_info *info,
|
| 251 | union iwreq_data *wrqu, char *extra)
|
| 252 | {
|
| 253 | struct iw_param *rts = &wrqu->rts;
|
| 254 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 255 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 256 | u32 orts = wdev->wiphy->rts_threshold;
|
| 257 | int err;
|
| 258 |
|
| 259 | guard(wiphy)(&rdev->wiphy);
|
| 260 | if (rts->disabled || !rts->fixed)
|
| 261 | wdev->wiphy->rts_threshold = (u32) -1;
|
| 262 | else if (rts->value < 0)
|
| 263 | return -EINVAL;
|
| 264 | else
|
| 265 | wdev->wiphy->rts_threshold = rts->value;
|
| 266 |
|
| 267 | err = rdev_set_wiphy_params(rdev, -1, WIPHY_PARAM_RTS_THRESHOLD);
|
| 268 | if (err)
|
| 269 | wdev->wiphy->rts_threshold = orts;
|
| 270 | return err;
|
| 271 | }
|
| 272 |
|
| 273 | int cfg80211_wext_giwrts(struct net_device *dev,
|
| 274 | struct iw_request_info *info,
|
| 275 | union iwreq_data *wrqu, char *extra)
|
| 276 | {
|
| 277 | struct iw_param *rts = &wrqu->rts;
|
| 278 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 279 |
|
| 280 | rts->value = wdev->wiphy->rts_threshold;
|
| 281 | rts->disabled = rts->value == (u32) -1;
|
| 282 | rts->fixed = 1;
|
| 283 |
|
| 284 | return 0;
|
| 285 | }
|
| 286 |
|
| 287 | int cfg80211_wext_siwfrag(struct net_device *dev,
|
| 288 | struct iw_request_info *info,
|
| 289 | union iwreq_data *wrqu, char *extra)
|
| 290 | {
|
| 291 | struct iw_param *frag = &wrqu->frag;
|
| 292 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 293 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 294 | u32 ofrag = wdev->wiphy->frag_threshold;
|
| 295 | int err;
|
| 296 |
|
| 297 | guard(wiphy)(&rdev->wiphy);
|
| 298 |
|
| 299 | if (frag->disabled || !frag->fixed) {
|
| 300 | wdev->wiphy->frag_threshold = (u32) -1;
|
| 301 | } else if (frag->value < 256) {
|
| 302 | return -EINVAL;
|
| 303 | } else {
|
| 304 |
|
| 305 | wdev->wiphy->frag_threshold = frag->value & ~0x1;
|
| 306 | }
|
| 307 |
|
| 308 | err = rdev_set_wiphy_params(rdev, -1, WIPHY_PARAM_FRAG_THRESHOLD);
|
| 309 | if (err)
|
| 310 | wdev->wiphy->frag_threshold = ofrag;
|
| 311 | return err;
|
| 312 | }
|
| 313 |
|
| 314 | int cfg80211_wext_giwfrag(struct net_device *dev,
|
| 315 | struct iw_request_info *info,
|
| 316 | union iwreq_data *wrqu, char *extra)
|
| 317 | {
|
| 318 | struct iw_param *frag = &wrqu->frag;
|
| 319 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 320 |
|
| 321 | frag->value = wdev->wiphy->frag_threshold;
|
| 322 | frag->disabled = frag->value == (u32) -1;
|
| 323 | frag->fixed = 1;
|
| 324 |
|
| 325 | return 0;
|
| 326 | }
|
| 327 |
|
| 328 | static int cfg80211_wext_siwretry(struct net_device *dev,
|
| 329 | struct iw_request_info *info,
|
| 330 | union iwreq_data *wrqu, char *extra)
|
| 331 | {
|
| 332 | struct iw_param *retry = &wrqu->retry;
|
| 333 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 334 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 335 | u32 changed = 0;
|
| 336 | u8 olong = wdev->wiphy->retry_long;
|
| 337 | u8 oshort = wdev->wiphy->retry_short;
|
| 338 | int err;
|
| 339 |
|
| 340 | if (retry->disabled || retry->value < 1 || retry->value > 255 ||
|
| 341 | (retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
|
| 342 | return -EINVAL;
|
| 343 |
|
| 344 | guard(wiphy)(&rdev->wiphy);
|
| 345 |
|
| 346 | if (retry->flags & IW_RETRY_LONG) {
|
| 347 | wdev->wiphy->retry_long = retry->value;
|
| 348 | changed |= WIPHY_PARAM_RETRY_LONG;
|
| 349 | } else if (retry->flags & IW_RETRY_SHORT) {
|
| 350 | wdev->wiphy->retry_short = retry->value;
|
| 351 | changed |= WIPHY_PARAM_RETRY_SHORT;
|
| 352 | } else {
|
| 353 | wdev->wiphy->retry_short = retry->value;
|
| 354 | wdev->wiphy->retry_long = retry->value;
|
| 355 | changed |= WIPHY_PARAM_RETRY_LONG;
|
| 356 | changed |= WIPHY_PARAM_RETRY_SHORT;
|
| 357 | }
|
| 358 |
|
| 359 | err = rdev_set_wiphy_params(rdev, -1, changed);
|
| 360 | if (err) {
|
| 361 | wdev->wiphy->retry_short = oshort;
|
| 362 | wdev->wiphy->retry_long = olong;
|
| 363 | }
|
| 364 |
|
| 365 | return err;
|
| 366 | }
|
| 367 |
|
| 368 | int cfg80211_wext_giwretry(struct net_device *dev,
|
| 369 | struct iw_request_info *info,
|
| 370 | union iwreq_data *wrqu, char *extra)
|
| 371 | {
|
| 372 | struct iw_param *retry = &wrqu->retry;
|
| 373 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 374 |
|
| 375 | retry->disabled = 0;
|
| 376 |
|
| 377 | if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) {
|
| 378 | |
| 379 | * First return short value, iwconfig will ask long value
|
| 380 | * later if needed
|
| 381 |
|
| 382 | retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT;
|
| 383 | retry->value = wdev->wiphy->retry_short;
|
| 384 | if (wdev->wiphy->retry_long == wdev->wiphy->retry_short)
|
| 385 | retry->flags |= IW_RETRY_LONG;
|
| 386 |
|
| 387 | return 0;
|
| 388 | }
|
| 389 |
|
| 390 | if (retry->flags & IW_RETRY_LONG) {
|
| 391 | retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
|
| 392 | retry->value = wdev->wiphy->retry_long;
|
| 393 | }
|
| 394 |
|
| 395 | return 0;
|
| 396 | }
|
| 397 |
|
| 398 | static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
|
| 399 | struct net_device *dev, bool pairwise,
|
| 400 | const u8 *addr, bool remove, bool tx_key,
|
| 401 | int idx, struct key_params *params)
|
| 402 | {
|
| 403 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 404 | int err, i;
|
| 405 | bool rejoin = false;
|
| 406 |
|
| 407 | if (wdev->valid_links)
|
| 408 | return -EINVAL;
|
| 409 |
|
| 410 | if (pairwise && !addr)
|
| 411 | return -EINVAL;
|
| 412 |
|
| 413 | |
| 414 | * In many cases we won't actually need this, but it's better
|
| 415 | * to do it first in case the allocation fails. Don't use wext.
|
| 416 |
|
| 417 | if (!wdev->wext.keys) {
|
| 418 | wdev->wext.keys = kzalloc_obj(*wdev->wext.keys);
|
| 419 | if (!wdev->wext.keys)
|
| 420 | return -ENOMEM;
|
| 421 | for (i = 0; i < 4; i++)
|
| 422 | wdev->wext.keys->params[i].key =
|
| 423 | wdev->wext.keys->data[i];
|
| 424 | }
|
| 425 |
|
| 426 | if (wdev->iftype != NL80211_IFTYPE_ADHOC &&
|
| 427 | wdev->iftype != NL80211_IFTYPE_STATION)
|
| 428 | return -EOPNOTSUPP;
|
| 429 |
|
| 430 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
| 431 | if (!wdev->connected)
|
| 432 | return -ENOLINK;
|
| 433 |
|
| 434 | if (!rdev->ops->set_default_mgmt_key)
|
| 435 | return -EOPNOTSUPP;
|
| 436 |
|
| 437 | if (idx < 4 || idx > 5)
|
| 438 | return -EINVAL;
|
| 439 | } else if (idx < 0 || idx > 3)
|
| 440 | return -EINVAL;
|
| 441 |
|
| 442 | if (remove) {
|
| 443 | err = 0;
|
| 444 | if (wdev->connected ||
|
| 445 | (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 446 | wdev->u.ibss.current_bss)) {
|
| 447 | |
| 448 | * If removing the current TX key, we will need to
|
| 449 | * join a new IBSS without the privacy bit clear.
|
| 450 |
|
| 451 | if (idx == wdev->wext.default_key &&
|
| 452 | wdev->iftype == NL80211_IFTYPE_ADHOC) {
|
| 453 | cfg80211_leave_ibss(rdev, wdev->netdev, true);
|
| 454 | rejoin = true;
|
| 455 | }
|
| 456 |
|
| 457 | if (!cfg80211_valid_key_idx(wdev, idx, pairwise, addr))
|
| 458 | err = -ENOENT;
|
| 459 | else
|
| 460 | err = rdev_del_key(rdev, wdev, -1, idx, pairwise,
|
| 461 | addr);
|
| 462 | }
|
| 463 | wdev->wext.connect.privacy = false;
|
| 464 | |
| 465 | * Applications using wireless extensions expect to be
|
| 466 | * able to delete keys that don't exist, so allow that.
|
| 467 |
|
| 468 | if (err == -ENOENT)
|
| 469 | err = 0;
|
| 470 | if (!err) {
|
| 471 | if (!addr && idx < 4) {
|
| 472 | memset(wdev->wext.keys->data[idx], 0,
|
| 473 | sizeof(wdev->wext.keys->data[idx]));
|
| 474 | wdev->wext.keys->params[idx].key_len = 0;
|
| 475 | wdev->wext.keys->params[idx].cipher = 0;
|
| 476 | }
|
| 477 | if (idx == wdev->wext.default_key)
|
| 478 | wdev->wext.default_key = -1;
|
| 479 | else if (idx == wdev->wext.default_mgmt_key)
|
| 480 | wdev->wext.default_mgmt_key = -1;
|
| 481 | }
|
| 482 |
|
| 483 | if (!err && rejoin)
|
| 484 | err = cfg80211_ibss_wext_join(rdev, wdev);
|
| 485 |
|
| 486 | return err;
|
| 487 | }
|
| 488 |
|
| 489 | if (addr)
|
| 490 | tx_key = false;
|
| 491 |
|
| 492 | if (cfg80211_validate_key_settings(rdev, wdev, params, idx,
|
| 493 | pairwise, addr))
|
| 494 | return -EINVAL;
|
| 495 |
|
| 496 | err = 0;
|
| 497 | if (wdev->connected ||
|
| 498 | (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 499 | wdev->u.ibss.current_bss))
|
| 500 | err = rdev_add_key(rdev, wdev, -1, idx, pairwise, addr, params);
|
| 501 | else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
|
| 502 | params->cipher != WLAN_CIPHER_SUITE_WEP104)
|
| 503 | return -EINVAL;
|
| 504 | if (err)
|
| 505 | return err;
|
| 506 |
|
| 507 | |
| 508 | * We only need to store WEP keys, since they're the only keys that
|
| 509 | * can be set before a connection is established and persist after
|
| 510 | * disconnecting.
|
| 511 |
|
| 512 | if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
|
| 513 | params->cipher == WLAN_CIPHER_SUITE_WEP104)) {
|
| 514 | wdev->wext.keys->params[idx] = *params;
|
| 515 | memcpy(wdev->wext.keys->data[idx],
|
| 516 | params->key, params->key_len);
|
| 517 | wdev->wext.keys->params[idx].key =
|
| 518 | wdev->wext.keys->data[idx];
|
| 519 | }
|
| 520 |
|
| 521 | if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
|
| 522 | params->cipher == WLAN_CIPHER_SUITE_WEP104) &&
|
| 523 | (tx_key || (!addr && wdev->wext.default_key == -1))) {
|
| 524 | if (wdev->connected ||
|
| 525 | (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 526 | wdev->u.ibss.current_bss)) {
|
| 527 | |
| 528 | * If we are getting a new TX key from not having
|
| 529 | * had one before we need to join a new IBSS with
|
| 530 | * the privacy bit set.
|
| 531 |
|
| 532 | if (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 533 | wdev->wext.default_key == -1) {
|
| 534 | cfg80211_leave_ibss(rdev, wdev->netdev, true);
|
| 535 | rejoin = true;
|
| 536 | }
|
| 537 | err = rdev_set_default_key(rdev, dev, -1, idx, true,
|
| 538 | true);
|
| 539 | }
|
| 540 | if (!err) {
|
| 541 | wdev->wext.default_key = idx;
|
| 542 | if (rejoin)
|
| 543 | err = cfg80211_ibss_wext_join(rdev, wdev);
|
| 544 | }
|
| 545 | return err;
|
| 546 | }
|
| 547 |
|
| 548 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
|
| 549 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
|
| 550 | if (wdev->connected ||
|
| 551 | (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 552 | wdev->u.ibss.current_bss))
|
| 553 | err = rdev_set_default_mgmt_key(rdev, wdev, -1, idx);
|
| 554 | if (!err)
|
| 555 | wdev->wext.default_mgmt_key = idx;
|
| 556 | return err;
|
| 557 | }
|
| 558 |
|
| 559 | return 0;
|
| 560 | }
|
| 561 |
|
| 562 | static int cfg80211_wext_siwencode(struct net_device *dev,
|
| 563 | struct iw_request_info *info,
|
| 564 | union iwreq_data *wrqu, char *keybuf)
|
| 565 | {
|
| 566 | struct iw_point *erq = &wrqu->encoding;
|
| 567 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 568 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 569 | struct key_params params;
|
| 570 | bool remove = false;
|
| 571 | int idx;
|
| 572 |
|
| 573 | if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
| 574 | wdev->iftype != NL80211_IFTYPE_ADHOC)
|
| 575 | return -EOPNOTSUPP;
|
| 576 |
|
| 577 |
|
| 578 | if (!rdev->ops->del_key ||
|
| 579 | !rdev->ops->add_key ||
|
| 580 | !rdev->ops->set_default_key)
|
| 581 | return -EOPNOTSUPP;
|
| 582 |
|
| 583 | guard(wiphy)(&rdev->wiphy);
|
| 584 | if (wdev->valid_links)
|
| 585 | return -EOPNOTSUPP;
|
| 586 |
|
| 587 | idx = erq->flags & IW_ENCODE_INDEX;
|
| 588 | if (idx == 0) {
|
| 589 | idx = wdev->wext.default_key;
|
| 590 | if (idx < 0)
|
| 591 | idx = 0;
|
| 592 | } else if (idx < 1 || idx > 4) {
|
| 593 | return -EINVAL;
|
| 594 | } else {
|
| 595 | idx--;
|
| 596 | }
|
| 597 |
|
| 598 | if (erq->flags & IW_ENCODE_DISABLED)
|
| 599 | remove = true;
|
| 600 | else if (erq->length == 0) {
|
| 601 |
|
| 602 | int err = 0;
|
| 603 |
|
| 604 | if (wdev->connected ||
|
| 605 | (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
| 606 | wdev->u.ibss.current_bss))
|
| 607 | err = rdev_set_default_key(rdev, dev, -1, idx, true,
|
| 608 | true);
|
| 609 | if (!err)
|
| 610 | wdev->wext.default_key = idx;
|
| 611 | return err;
|
| 612 | }
|
| 613 |
|
| 614 | memset(¶ms, 0, sizeof(params));
|
| 615 | params.key = keybuf;
|
| 616 | params.key_len = erq->length;
|
| 617 | if (erq->length == 5)
|
| 618 | params.cipher = WLAN_CIPHER_SUITE_WEP40;
|
| 619 | else if (erq->length == 13)
|
| 620 | params.cipher = WLAN_CIPHER_SUITE_WEP104;
|
| 621 | else if (!remove)
|
| 622 | return -EINVAL;
|
| 623 |
|
| 624 | return cfg80211_set_encryption(rdev, dev, false, NULL, remove,
|
| 625 | wdev->wext.default_key == -1,
|
| 626 | idx, ¶ms);
|
| 627 | }
|
| 628 |
|
| 629 | static int cfg80211_wext_siwencodeext(struct net_device *dev,
|
| 630 | struct iw_request_info *info,
|
| 631 | union iwreq_data *wrqu, char *extra)
|
| 632 | {
|
| 633 | struct iw_point *erq = &wrqu->encoding;
|
| 634 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 635 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 636 | struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
|
| 637 | const u8 *addr;
|
| 638 | int idx;
|
| 639 | bool remove = false;
|
| 640 | struct key_params params;
|
| 641 | u32 cipher;
|
| 642 |
|
| 643 | if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
| 644 | wdev->iftype != NL80211_IFTYPE_ADHOC)
|
| 645 | return -EOPNOTSUPP;
|
| 646 |
|
| 647 |
|
| 648 | if (!rdev->ops->del_key ||
|
| 649 | !rdev->ops->add_key ||
|
| 650 | !rdev->ops->set_default_key)
|
| 651 | return -EOPNOTSUPP;
|
| 652 |
|
| 653 | if (wdev->valid_links)
|
| 654 | return -EOPNOTSUPP;
|
| 655 |
|
| 656 | switch (ext->alg) {
|
| 657 | case IW_ENCODE_ALG_NONE:
|
| 658 | remove = true;
|
| 659 | cipher = 0;
|
| 660 | break;
|
| 661 | case IW_ENCODE_ALG_WEP:
|
| 662 | if (ext->key_len == 5)
|
| 663 | cipher = WLAN_CIPHER_SUITE_WEP40;
|
| 664 | else if (ext->key_len == 13)
|
| 665 | cipher = WLAN_CIPHER_SUITE_WEP104;
|
| 666 | else
|
| 667 | return -EINVAL;
|
| 668 | break;
|
| 669 | case IW_ENCODE_ALG_TKIP:
|
| 670 | cipher = WLAN_CIPHER_SUITE_TKIP;
|
| 671 | break;
|
| 672 | case IW_ENCODE_ALG_CCMP:
|
| 673 | cipher = WLAN_CIPHER_SUITE_CCMP;
|
| 674 | break;
|
| 675 | case IW_ENCODE_ALG_AES_CMAC:
|
| 676 | cipher = WLAN_CIPHER_SUITE_AES_CMAC;
|
| 677 | break;
|
| 678 | default:
|
| 679 | return -EOPNOTSUPP;
|
| 680 | }
|
| 681 |
|
| 682 | if (erq->flags & IW_ENCODE_DISABLED)
|
| 683 | remove = true;
|
| 684 |
|
| 685 | idx = erq->flags & IW_ENCODE_INDEX;
|
| 686 | if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
| 687 | if (idx < 5 || idx > 6) {
|
| 688 | idx = wdev->wext.default_mgmt_key;
|
| 689 | if (idx < 0)
|
| 690 | return -EINVAL;
|
| 691 | } else
|
| 692 | idx--;
|
| 693 | } else {
|
| 694 | if (idx < 1 || idx > 4) {
|
| 695 | idx = wdev->wext.default_key;
|
| 696 | if (idx < 0)
|
| 697 | return -EINVAL;
|
| 698 | } else
|
| 699 | idx--;
|
| 700 | }
|
| 701 |
|
| 702 | addr = ext->addr.sa_data;
|
| 703 | if (is_broadcast_ether_addr(addr))
|
| 704 | addr = NULL;
|
| 705 |
|
| 706 | memset(¶ms, 0, sizeof(params));
|
| 707 | params.key = ext->key;
|
| 708 | params.key_len = ext->key_len;
|
| 709 | params.cipher = cipher;
|
| 710 |
|
| 711 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
|
| 712 | params.seq = ext->rx_seq;
|
| 713 | params.seq_len = 6;
|
| 714 | }
|
| 715 |
|
| 716 | guard(wiphy)(wdev->wiphy);
|
| 717 |
|
| 718 | return cfg80211_set_encryption(rdev, dev,
|
| 719 | !(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY),
|
| 720 | addr, remove,
|
| 721 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
|
| 722 | idx, ¶ms);
|
| 723 | }
|
| 724 |
|
| 725 | static int cfg80211_wext_giwencode(struct net_device *dev,
|
| 726 | struct iw_request_info *info,
|
| 727 | union iwreq_data *wrqu, char *keybuf)
|
| 728 | {
|
| 729 | struct iw_point *erq = &wrqu->encoding;
|
| 730 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 731 | int idx;
|
| 732 |
|
| 733 | if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
| 734 | wdev->iftype != NL80211_IFTYPE_ADHOC)
|
| 735 | return -EOPNOTSUPP;
|
| 736 |
|
| 737 | idx = erq->flags & IW_ENCODE_INDEX;
|
| 738 | if (idx == 0) {
|
| 739 | idx = wdev->wext.default_key;
|
| 740 | if (idx < 0)
|
| 741 | idx = 0;
|
| 742 | } else if (idx < 1 || idx > 4)
|
| 743 | return -EINVAL;
|
| 744 | else
|
| 745 | idx--;
|
| 746 |
|
| 747 | erq->flags = idx + 1;
|
| 748 |
|
| 749 | if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) {
|
| 750 | erq->flags |= IW_ENCODE_DISABLED;
|
| 751 | erq->length = 0;
|
| 752 | return 0;
|
| 753 | }
|
| 754 |
|
| 755 | erq->length = min_t(size_t, erq->length,
|
| 756 | wdev->wext.keys->params[idx].key_len);
|
| 757 | memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length);
|
| 758 | erq->flags |= IW_ENCODE_ENABLED;
|
| 759 |
|
| 760 | return 0;
|
| 761 | }
|
| 762 |
|
| 763 | static int cfg80211_wext_siwfreq(struct net_device *dev,
|
| 764 | struct iw_request_info *info,
|
| 765 | union iwreq_data *wrqu, char *extra)
|
| 766 | {
|
| 767 | struct iw_freq *wextfreq = &wrqu->freq;
|
| 768 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 769 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 770 | struct cfg80211_chan_def chandef = {
|
| 771 | .width = NL80211_CHAN_WIDTH_20_NOHT,
|
| 772 | };
|
| 773 | int freq;
|
| 774 |
|
| 775 | guard(wiphy)(&rdev->wiphy);
|
| 776 |
|
| 777 | switch (wdev->iftype) {
|
| 778 | case NL80211_IFTYPE_STATION:
|
| 779 | return cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
|
| 780 | case NL80211_IFTYPE_ADHOC:
|
| 781 | return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
|
| 782 | case NL80211_IFTYPE_MONITOR:
|
| 783 | freq = cfg80211_wext_freq(wextfreq);
|
| 784 | if (freq < 0)
|
| 785 | return freq;
|
| 786 | if (freq == 0)
|
| 787 | return -EINVAL;
|
| 788 |
|
| 789 | chandef.center_freq1 = freq;
|
| 790 | chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
| 791 | if (!chandef.chan)
|
| 792 | return -EINVAL;
|
| 793 | if (!cfg80211_chandef_valid(&chandef))
|
| 794 | return -EINVAL;
|
| 795 | return cfg80211_set_monitor_channel(rdev, dev, &chandef);
|
| 796 | case NL80211_IFTYPE_MESH_POINT:
|
| 797 | freq = cfg80211_wext_freq(wextfreq);
|
| 798 | if (freq < 0)
|
| 799 | return freq;
|
| 800 | if (freq == 0)
|
| 801 | return -EINVAL;
|
| 802 | chandef.center_freq1 = freq;
|
| 803 | chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
| 804 | if (!chandef.chan)
|
| 805 | return -EINVAL;
|
| 806 | return cfg80211_set_mesh_channel(rdev, wdev, &chandef);
|
| 807 | default:
|
| 808 | return -EOPNOTSUPP;
|
| 809 | }
|
| 810 | }
|
| 811 |
|
| 812 | static int cfg80211_wext_giwfreq(struct net_device *dev,
|
| 813 | struct iw_request_info *info,
|
| 814 | union iwreq_data *wrqu, char *extra)
|
| 815 | {
|
| 816 | struct iw_freq *freq = &wrqu->freq;
|
| 817 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 818 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 819 | struct cfg80211_chan_def chandef = {};
|
| 820 | int ret;
|
| 821 |
|
| 822 | guard(wiphy)(&rdev->wiphy);
|
| 823 |
|
| 824 | switch (wdev->iftype) {
|
| 825 | case NL80211_IFTYPE_STATION:
|
| 826 | return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
|
| 827 | case NL80211_IFTYPE_ADHOC:
|
| 828 | return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
|
| 829 | case NL80211_IFTYPE_MONITOR:
|
| 830 | if (!rdev->ops->get_channel)
|
| 831 | return -EINVAL;
|
| 832 |
|
| 833 | ret = rdev_get_channel(rdev, wdev, 0, &chandef);
|
| 834 | if (ret)
|
| 835 | return ret;
|
| 836 | freq->m = chandef.chan->center_freq;
|
| 837 | freq->e = 6;
|
| 838 | return ret;
|
| 839 | default:
|
| 840 | return -EINVAL;
|
| 841 | }
|
| 842 | }
|
| 843 |
|
| 844 | static int cfg80211_wext_siwtxpower(struct net_device *dev,
|
| 845 | struct iw_request_info *info,
|
| 846 | union iwreq_data *data, char *extra)
|
| 847 | {
|
| 848 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 849 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 850 | enum nl80211_tx_power_setting type;
|
| 851 | int dbm = 0;
|
| 852 |
|
| 853 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
| 854 | return -EINVAL;
|
| 855 | if (data->txpower.flags & IW_TXPOW_RANGE)
|
| 856 | return -EINVAL;
|
| 857 |
|
| 858 | if (!rdev->ops->set_tx_power)
|
| 859 | return -EOPNOTSUPP;
|
| 860 |
|
| 861 |
|
| 862 | if (!data->txpower.disabled) {
|
| 863 | rfkill_set_sw_state(rdev->wiphy.rfkill, false);
|
| 864 |
|
| 865 | if (data->txpower.fixed) {
|
| 866 | |
| 867 | * wext doesn't support negative values, see
|
| 868 | * below where it's for automatic
|
| 869 |
|
| 870 | if (data->txpower.value < 0)
|
| 871 | return -EINVAL;
|
| 872 | dbm = data->txpower.value;
|
| 873 | type = NL80211_TX_POWER_FIXED;
|
| 874 |
|
| 875 | } else {
|
| 876 | |
| 877 | * Automatic power level setting, max being the value
|
| 878 | * passed in from userland.
|
| 879 |
|
| 880 | if (data->txpower.value < 0) {
|
| 881 | type = NL80211_TX_POWER_AUTOMATIC;
|
| 882 | } else {
|
| 883 | dbm = data->txpower.value;
|
| 884 | type = NL80211_TX_POWER_LIMITED;
|
| 885 | }
|
| 886 | }
|
| 887 | } else {
|
| 888 | if (rfkill_set_sw_state(rdev->wiphy.rfkill, true))
|
| 889 | schedule_work(&rdev->rfkill_block);
|
| 890 | return 0;
|
| 891 | }
|
| 892 |
|
| 893 | guard(wiphy)(&rdev->wiphy);
|
| 894 |
|
| 895 | return rdev_set_tx_power(rdev, wdev, -1, type, DBM_TO_MBM(dbm));
|
| 896 | }
|
| 897 |
|
| 898 | static int cfg80211_wext_giwtxpower(struct net_device *dev,
|
| 899 | struct iw_request_info *info,
|
| 900 | union iwreq_data *data, char *extra)
|
| 901 | {
|
| 902 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 903 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 904 | int err, val;
|
| 905 |
|
| 906 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
| 907 | return -EINVAL;
|
| 908 | if (data->txpower.flags & IW_TXPOW_RANGE)
|
| 909 | return -EINVAL;
|
| 910 |
|
| 911 | if (!rdev->ops->get_tx_power)
|
| 912 | return -EOPNOTSUPP;
|
| 913 |
|
| 914 | scoped_guard(wiphy, &rdev->wiphy) {
|
| 915 | err = rdev_get_tx_power(rdev, wdev, -1, 0, &val);
|
| 916 | }
|
| 917 | if (err)
|
| 918 | return err;
|
| 919 |
|
| 920 |
|
| 921 | data->txpower.fixed = 1;
|
| 922 | data->txpower.disabled = rfkill_blocked(rdev->wiphy.rfkill);
|
| 923 | data->txpower.value = val;
|
| 924 | data->txpower.flags = IW_TXPOW_DBM;
|
| 925 |
|
| 926 | return 0;
|
| 927 | }
|
| 928 |
|
| 929 | static int cfg80211_set_auth_alg(struct wireless_dev *wdev,
|
| 930 | s32 auth_alg)
|
| 931 | {
|
| 932 | int nr_alg = 0;
|
| 933 |
|
| 934 | if (!auth_alg)
|
| 935 | return -EINVAL;
|
| 936 |
|
| 937 | if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM |
|
| 938 | IW_AUTH_ALG_SHARED_KEY |
|
| 939 | IW_AUTH_ALG_LEAP))
|
| 940 | return -EINVAL;
|
| 941 |
|
| 942 | if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) {
|
| 943 | nr_alg++;
|
| 944 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
|
| 945 | }
|
| 946 |
|
| 947 | if (auth_alg & IW_AUTH_ALG_SHARED_KEY) {
|
| 948 | nr_alg++;
|
| 949 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY;
|
| 950 | }
|
| 951 |
|
| 952 | if (auth_alg & IW_AUTH_ALG_LEAP) {
|
| 953 | nr_alg++;
|
| 954 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP;
|
| 955 | }
|
| 956 |
|
| 957 | if (nr_alg > 1)
|
| 958 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
|
| 959 |
|
| 960 | return 0;
|
| 961 | }
|
| 962 |
|
| 963 | static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions)
|
| 964 | {
|
| 965 | if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA |
|
| 966 | IW_AUTH_WPA_VERSION_WPA2|
|
| 967 | IW_AUTH_WPA_VERSION_DISABLED))
|
| 968 | return -EINVAL;
|
| 969 |
|
| 970 | if ((wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) &&
|
| 971 | (wpa_versions & (IW_AUTH_WPA_VERSION_WPA|
|
| 972 | IW_AUTH_WPA_VERSION_WPA2)))
|
| 973 | return -EINVAL;
|
| 974 |
|
| 975 | if (wpa_versions & IW_AUTH_WPA_VERSION_DISABLED)
|
| 976 | wdev->wext.connect.crypto.wpa_versions &=
|
| 977 | ~(NL80211_WPA_VERSION_1|NL80211_WPA_VERSION_2);
|
| 978 |
|
| 979 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA)
|
| 980 | wdev->wext.connect.crypto.wpa_versions |=
|
| 981 | NL80211_WPA_VERSION_1;
|
| 982 |
|
| 983 | if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2)
|
| 984 | wdev->wext.connect.crypto.wpa_versions |=
|
| 985 | NL80211_WPA_VERSION_2;
|
| 986 |
|
| 987 | return 0;
|
| 988 | }
|
| 989 |
|
| 990 | static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher)
|
| 991 | {
|
| 992 | if (cipher & IW_AUTH_CIPHER_WEP40)
|
| 993 | wdev->wext.connect.crypto.cipher_group =
|
| 994 | WLAN_CIPHER_SUITE_WEP40;
|
| 995 | else if (cipher & IW_AUTH_CIPHER_WEP104)
|
| 996 | wdev->wext.connect.crypto.cipher_group =
|
| 997 | WLAN_CIPHER_SUITE_WEP104;
|
| 998 | else if (cipher & IW_AUTH_CIPHER_TKIP)
|
| 999 | wdev->wext.connect.crypto.cipher_group =
|
| 1000 | WLAN_CIPHER_SUITE_TKIP;
|
| 1001 | else if (cipher & IW_AUTH_CIPHER_CCMP)
|
| 1002 | wdev->wext.connect.crypto.cipher_group =
|
| 1003 | WLAN_CIPHER_SUITE_CCMP;
|
| 1004 | else if (cipher & IW_AUTH_CIPHER_AES_CMAC)
|
| 1005 | wdev->wext.connect.crypto.cipher_group =
|
| 1006 | WLAN_CIPHER_SUITE_AES_CMAC;
|
| 1007 | else if (cipher & IW_AUTH_CIPHER_NONE)
|
| 1008 | wdev->wext.connect.crypto.cipher_group = 0;
|
| 1009 | else
|
| 1010 | return -EINVAL;
|
| 1011 |
|
| 1012 | return 0;
|
| 1013 | }
|
| 1014 |
|
| 1015 | static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher)
|
| 1016 | {
|
| 1017 | int nr_ciphers = 0;
|
| 1018 | u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
|
| 1019 |
|
| 1020 | if (cipher & IW_AUTH_CIPHER_WEP40) {
|
| 1021 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40;
|
| 1022 | nr_ciphers++;
|
| 1023 | }
|
| 1024 |
|
| 1025 | if (cipher & IW_AUTH_CIPHER_WEP104) {
|
| 1026 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104;
|
| 1027 | nr_ciphers++;
|
| 1028 | }
|
| 1029 |
|
| 1030 | if (cipher & IW_AUTH_CIPHER_TKIP) {
|
| 1031 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP;
|
| 1032 | nr_ciphers++;
|
| 1033 | }
|
| 1034 |
|
| 1035 | if (cipher & IW_AUTH_CIPHER_CCMP) {
|
| 1036 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP;
|
| 1037 | nr_ciphers++;
|
| 1038 | }
|
| 1039 |
|
| 1040 | if (cipher & IW_AUTH_CIPHER_AES_CMAC) {
|
| 1041 | ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC;
|
| 1042 | nr_ciphers++;
|
| 1043 | }
|
| 1044 |
|
| 1045 | BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5);
|
| 1046 |
|
| 1047 | wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers;
|
| 1048 |
|
| 1049 | return 0;
|
| 1050 | }
|
| 1051 |
|
| 1052 |
|
| 1053 | static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt)
|
| 1054 | {
|
| 1055 | int nr_akm_suites = 0;
|
| 1056 |
|
| 1057 | if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X |
|
| 1058 | IW_AUTH_KEY_MGMT_PSK))
|
| 1059 | return -EINVAL;
|
| 1060 |
|
| 1061 | if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) {
|
| 1062 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
| 1063 | WLAN_AKM_SUITE_8021X;
|
| 1064 | nr_akm_suites++;
|
| 1065 | }
|
| 1066 |
|
| 1067 | if (key_mgt & IW_AUTH_KEY_MGMT_PSK) {
|
| 1068 | wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
| 1069 | WLAN_AKM_SUITE_PSK;
|
| 1070 | nr_akm_suites++;
|
| 1071 | }
|
| 1072 |
|
| 1073 | wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites;
|
| 1074 |
|
| 1075 | return 0;
|
| 1076 | }
|
| 1077 |
|
| 1078 | static int cfg80211_wext_siwauth(struct net_device *dev,
|
| 1079 | struct iw_request_info *info,
|
| 1080 | union iwreq_data *wrqu, char *extra)
|
| 1081 | {
|
| 1082 | struct iw_param *data = &wrqu->param;
|
| 1083 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1084 |
|
| 1085 | if (wdev->iftype != NL80211_IFTYPE_STATION)
|
| 1086 | return -EOPNOTSUPP;
|
| 1087 |
|
| 1088 | switch (data->flags & IW_AUTH_INDEX) {
|
| 1089 | case IW_AUTH_PRIVACY_INVOKED:
|
| 1090 | wdev->wext.connect.privacy = data->value;
|
| 1091 | return 0;
|
| 1092 | case IW_AUTH_WPA_VERSION:
|
| 1093 | return cfg80211_set_wpa_version(wdev, data->value);
|
| 1094 | case IW_AUTH_CIPHER_GROUP:
|
| 1095 | return cfg80211_set_cipher_group(wdev, data->value);
|
| 1096 | case IW_AUTH_KEY_MGMT:
|
| 1097 | return cfg80211_set_key_mgt(wdev, data->value);
|
| 1098 | case IW_AUTH_CIPHER_PAIRWISE:
|
| 1099 | return cfg80211_set_cipher_pairwise(wdev, data->value);
|
| 1100 | case IW_AUTH_80211_AUTH_ALG:
|
| 1101 | return cfg80211_set_auth_alg(wdev, data->value);
|
| 1102 | case IW_AUTH_WPA_ENABLED:
|
| 1103 | case IW_AUTH_RX_UNENCRYPTED_EAPOL:
|
| 1104 | case IW_AUTH_DROP_UNENCRYPTED:
|
| 1105 | case IW_AUTH_MFP:
|
| 1106 | return 0;
|
| 1107 | default:
|
| 1108 | return -EOPNOTSUPP;
|
| 1109 | }
|
| 1110 | }
|
| 1111 |
|
| 1112 | static int cfg80211_wext_giwauth(struct net_device *dev,
|
| 1113 | struct iw_request_info *info,
|
| 1114 | union iwreq_data *wrqu, char *extra)
|
| 1115 | {
|
| 1116 |
|
| 1117 |
|
| 1118 | return -EOPNOTSUPP;
|
| 1119 | }
|
| 1120 |
|
| 1121 | static int cfg80211_wext_siwpower(struct net_device *dev,
|
| 1122 | struct iw_request_info *info,
|
| 1123 | union iwreq_data *wrqu, char *extra)
|
| 1124 | {
|
| 1125 | struct iw_param *wrq = &wrqu->power;
|
| 1126 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1127 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1128 | bool ps;
|
| 1129 | int timeout = wdev->ps_timeout;
|
| 1130 | int err;
|
| 1131 |
|
| 1132 | if (wdev->iftype != NL80211_IFTYPE_STATION)
|
| 1133 | return -EINVAL;
|
| 1134 |
|
| 1135 | if (!rdev->ops->set_power_mgmt)
|
| 1136 | return -EOPNOTSUPP;
|
| 1137 |
|
| 1138 | if (wrq->disabled) {
|
| 1139 | ps = false;
|
| 1140 | } else {
|
| 1141 | switch (wrq->flags & IW_POWER_MODE) {
|
| 1142 | case IW_POWER_ON:
|
| 1143 | case IW_POWER_MODE:
|
| 1144 | case IW_POWER_ALL_R:
|
| 1145 | ps = true;
|
| 1146 | break;
|
| 1147 | default:
|
| 1148 | return -EINVAL;
|
| 1149 | }
|
| 1150 |
|
| 1151 | if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
|
| 1152 | return -EINVAL;
|
| 1153 |
|
| 1154 | if (wrq->flags & IW_POWER_TIMEOUT)
|
| 1155 | timeout = wrq->value / 1000;
|
| 1156 | }
|
| 1157 |
|
| 1158 | guard(wiphy)(&rdev->wiphy);
|
| 1159 |
|
| 1160 | err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
|
| 1161 | if (err)
|
| 1162 | return err;
|
| 1163 |
|
| 1164 | wdev->ps = ps;
|
| 1165 | wdev->ps_timeout = timeout;
|
| 1166 |
|
| 1167 | return 0;
|
| 1168 |
|
| 1169 | }
|
| 1170 |
|
| 1171 | static int cfg80211_wext_giwpower(struct net_device *dev,
|
| 1172 | struct iw_request_info *info,
|
| 1173 | union iwreq_data *wrqu, char *extra)
|
| 1174 | {
|
| 1175 | struct iw_param *wrq = &wrqu->power;
|
| 1176 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1177 |
|
| 1178 | wrq->disabled = !wdev->ps;
|
| 1179 |
|
| 1180 | return 0;
|
| 1181 | }
|
| 1182 |
|
| 1183 | static int cfg80211_wext_siwrate(struct net_device *dev,
|
| 1184 | struct iw_request_info *info,
|
| 1185 | union iwreq_data *wrqu, char *extra)
|
| 1186 | {
|
| 1187 | struct iw_param *rate = &wrqu->bitrate;
|
| 1188 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1189 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1190 | struct cfg80211_bitrate_mask mask;
|
| 1191 | u32 fixed, maxrate;
|
| 1192 | struct ieee80211_supported_band *sband;
|
| 1193 | bool match = false;
|
| 1194 | int band, ridx;
|
| 1195 |
|
| 1196 | if (!rdev->ops->set_bitrate_mask)
|
| 1197 | return -EOPNOTSUPP;
|
| 1198 |
|
| 1199 | memset(&mask, 0, sizeof(mask));
|
| 1200 | fixed = 0;
|
| 1201 | maxrate = (u32)-1;
|
| 1202 |
|
| 1203 | if (rate->value < 0) {
|
| 1204 |
|
| 1205 | } else if (rate->fixed) {
|
| 1206 | fixed = rate->value / 100000;
|
| 1207 | } else {
|
| 1208 | maxrate = rate->value / 100000;
|
| 1209 | }
|
| 1210 |
|
| 1211 | for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
| 1212 | sband = wdev->wiphy->bands[band];
|
| 1213 | if (sband == NULL)
|
| 1214 | continue;
|
| 1215 | for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
|
| 1216 | struct ieee80211_rate *srate = &sband->bitrates[ridx];
|
| 1217 | if (fixed == srate->bitrate) {
|
| 1218 | mask.control[band].legacy = 1 << ridx;
|
| 1219 | match = true;
|
| 1220 | break;
|
| 1221 | }
|
| 1222 | if (srate->bitrate <= maxrate) {
|
| 1223 | mask.control[band].legacy |= 1 << ridx;
|
| 1224 | match = true;
|
| 1225 | }
|
| 1226 | }
|
| 1227 | }
|
| 1228 |
|
| 1229 | if (!match)
|
| 1230 | return -EINVAL;
|
| 1231 |
|
| 1232 | guard(wiphy)(&rdev->wiphy);
|
| 1233 |
|
| 1234 | if (dev->ieee80211_ptr->valid_links)
|
| 1235 | return -EOPNOTSUPP;
|
| 1236 |
|
| 1237 | return rdev_set_bitrate_mask(rdev, dev, 0, NULL, &mask);
|
| 1238 | }
|
| 1239 |
|
| 1240 | static int cfg80211_wext_giwrate(struct net_device *dev,
|
| 1241 | struct iw_request_info *info,
|
| 1242 | union iwreq_data *wrqu, char *extra)
|
| 1243 | {
|
| 1244 | struct iw_param *rate = &wrqu->bitrate;
|
| 1245 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1246 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1247 | struct station_info sinfo = {};
|
| 1248 | u8 addr[ETH_ALEN];
|
| 1249 | int err;
|
| 1250 |
|
| 1251 | if (wdev->iftype != NL80211_IFTYPE_STATION)
|
| 1252 | return -EOPNOTSUPP;
|
| 1253 |
|
| 1254 | if (!rdev->ops->get_station)
|
| 1255 | return -EOPNOTSUPP;
|
| 1256 |
|
| 1257 | err = 0;
|
| 1258 | if (!wdev->valid_links && wdev->links[0].client.current_bss)
|
| 1259 | memcpy(addr, wdev->links[0].client.current_bss->pub.bssid,
|
| 1260 | ETH_ALEN);
|
| 1261 | else
|
| 1262 | err = -EOPNOTSUPP;
|
| 1263 | if (err)
|
| 1264 | return err;
|
| 1265 |
|
| 1266 | scoped_guard(wiphy, &rdev->wiphy) {
|
| 1267 | err = rdev_get_station(rdev, wdev, addr, &sinfo);
|
| 1268 | }
|
| 1269 | if (err)
|
| 1270 | return err;
|
| 1271 |
|
| 1272 | if (!(sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
|
| 1273 | err = -EOPNOTSUPP;
|
| 1274 | goto free;
|
| 1275 | }
|
| 1276 |
|
| 1277 | rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
|
| 1278 |
|
| 1279 | free:
|
| 1280 | cfg80211_sinfo_release_content(&sinfo);
|
| 1281 | return err;
|
| 1282 | }
|
| 1283 |
|
| 1284 |
|
| 1285 | static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
|
| 1286 | {
|
| 1287 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1288 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1289 |
|
| 1290 | static struct iw_statistics wstats;
|
| 1291 | static struct station_info sinfo = {};
|
| 1292 | u8 bssid[ETH_ALEN];
|
| 1293 | int ret;
|
| 1294 |
|
| 1295 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
|
| 1296 | return NULL;
|
| 1297 |
|
| 1298 | if (!rdev->ops->get_station)
|
| 1299 | return NULL;
|
| 1300 |
|
| 1301 |
|
| 1302 | wiphy_lock(&rdev->wiphy);
|
| 1303 | if (wdev->valid_links || !wdev->links[0].client.current_bss) {
|
| 1304 | wiphy_unlock(&rdev->wiphy);
|
| 1305 | return NULL;
|
| 1306 | }
|
| 1307 | memcpy(bssid, wdev->links[0].client.current_bss->pub.bssid, ETH_ALEN);
|
| 1308 |
|
| 1309 | memset(&sinfo, 0, sizeof(sinfo));
|
| 1310 |
|
| 1311 | ret = rdev_get_station(rdev, wdev, bssid, &sinfo);
|
| 1312 | wiphy_unlock(&rdev->wiphy);
|
| 1313 |
|
| 1314 | if (ret)
|
| 1315 | return NULL;
|
| 1316 |
|
| 1317 | memset(&wstats, 0, sizeof(wstats));
|
| 1318 |
|
| 1319 | switch (rdev->wiphy.signal_type) {
|
| 1320 | case CFG80211_SIGNAL_TYPE_MBM:
|
| 1321 | if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
|
| 1322 | int sig = sinfo.signal;
|
| 1323 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
| 1324 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
| 1325 | wstats.qual.updated |= IW_QUAL_DBM;
|
| 1326 | wstats.qual.level = sig;
|
| 1327 | if (sig < -110)
|
| 1328 | sig = -110;
|
| 1329 | else if (sig > -40)
|
| 1330 | sig = -40;
|
| 1331 | wstats.qual.qual = sig + 110;
|
| 1332 | break;
|
| 1333 | }
|
| 1334 | fallthrough;
|
| 1335 | case CFG80211_SIGNAL_TYPE_UNSPEC:
|
| 1336 | if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
|
| 1337 | wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
| 1338 | wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
| 1339 | wstats.qual.level = sinfo.signal;
|
| 1340 | wstats.qual.qual = sinfo.signal;
|
| 1341 | break;
|
| 1342 | }
|
| 1343 | fallthrough;
|
| 1344 | default:
|
| 1345 | wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
|
| 1346 | wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
|
| 1347 | }
|
| 1348 |
|
| 1349 | wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
|
| 1350 | if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC))
|
| 1351 | wstats.discard.misc = sinfo.rx_dropped_misc;
|
| 1352 | if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))
|
| 1353 | wstats.discard.retries = sinfo.tx_failed;
|
| 1354 |
|
| 1355 | cfg80211_sinfo_release_content(&sinfo);
|
| 1356 |
|
| 1357 | return &wstats;
|
| 1358 | }
|
| 1359 |
|
| 1360 | static int cfg80211_wext_siwap(struct net_device *dev,
|
| 1361 | struct iw_request_info *info,
|
| 1362 | union iwreq_data *wrqu, char *extra)
|
| 1363 | {
|
| 1364 | struct sockaddr *ap_addr = &wrqu->ap_addr;
|
| 1365 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1366 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1367 |
|
| 1368 | guard(wiphy)(&rdev->wiphy);
|
| 1369 |
|
| 1370 | switch (wdev->iftype) {
|
| 1371 | case NL80211_IFTYPE_ADHOC:
|
| 1372 | return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
|
| 1373 | case NL80211_IFTYPE_STATION:
|
| 1374 | return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
|
| 1375 | default:
|
| 1376 | return -EOPNOTSUPP;
|
| 1377 | }
|
| 1378 | }
|
| 1379 |
|
| 1380 | static int cfg80211_wext_giwap(struct net_device *dev,
|
| 1381 | struct iw_request_info *info,
|
| 1382 | union iwreq_data *wrqu, char *extra)
|
| 1383 | {
|
| 1384 | struct sockaddr *ap_addr = &wrqu->ap_addr;
|
| 1385 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1386 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1387 |
|
| 1388 | guard(wiphy)(&rdev->wiphy);
|
| 1389 |
|
| 1390 | switch (wdev->iftype) {
|
| 1391 | case NL80211_IFTYPE_ADHOC:
|
| 1392 | return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
|
| 1393 | case NL80211_IFTYPE_STATION:
|
| 1394 | return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
|
| 1395 | default:
|
| 1396 | return -EOPNOTSUPP;
|
| 1397 | }
|
| 1398 | }
|
| 1399 |
|
| 1400 | static int cfg80211_wext_siwessid(struct net_device *dev,
|
| 1401 | struct iw_request_info *info,
|
| 1402 | union iwreq_data *wrqu, char *ssid)
|
| 1403 | {
|
| 1404 | struct iw_point *data = &wrqu->data;
|
| 1405 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1406 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1407 |
|
| 1408 | guard(wiphy)(&rdev->wiphy);
|
| 1409 |
|
| 1410 | switch (wdev->iftype) {
|
| 1411 | case NL80211_IFTYPE_ADHOC:
|
| 1412 | return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
| 1413 | case NL80211_IFTYPE_STATION:
|
| 1414 | return cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
|
| 1415 | default:
|
| 1416 | return -EOPNOTSUPP;
|
| 1417 | }
|
| 1418 | }
|
| 1419 |
|
| 1420 | static int cfg80211_wext_giwessid(struct net_device *dev,
|
| 1421 | struct iw_request_info *info,
|
| 1422 | union iwreq_data *wrqu, char *ssid)
|
| 1423 | {
|
| 1424 | struct iw_point *data = &wrqu->data;
|
| 1425 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1426 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1427 |
|
| 1428 | data->flags = 0;
|
| 1429 | data->length = 0;
|
| 1430 |
|
| 1431 | guard(wiphy)(&rdev->wiphy);
|
| 1432 |
|
| 1433 | switch (wdev->iftype) {
|
| 1434 | case NL80211_IFTYPE_ADHOC:
|
| 1435 | return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
| 1436 | case NL80211_IFTYPE_STATION:
|
| 1437 | return cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
|
| 1438 | default:
|
| 1439 | return -EOPNOTSUPP;
|
| 1440 | }
|
| 1441 | }
|
| 1442 |
|
| 1443 | static int cfg80211_wext_siwpmksa(struct net_device *dev,
|
| 1444 | struct iw_request_info *info,
|
| 1445 | union iwreq_data *wrqu, char *extra)
|
| 1446 | {
|
| 1447 | struct wireless_dev *wdev = dev->ieee80211_ptr;
|
| 1448 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
| 1449 | struct cfg80211_pmksa cfg_pmksa;
|
| 1450 | struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
|
| 1451 |
|
| 1452 | memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa));
|
| 1453 |
|
| 1454 | if (wdev->iftype != NL80211_IFTYPE_STATION)
|
| 1455 | return -EINVAL;
|
| 1456 |
|
| 1457 | cfg_pmksa.bssid = pmksa->bssid.sa_data;
|
| 1458 | cfg_pmksa.pmkid = pmksa->pmkid;
|
| 1459 |
|
| 1460 | guard(wiphy)(&rdev->wiphy);
|
| 1461 |
|
| 1462 | switch (pmksa->cmd) {
|
| 1463 | case IW_PMKSA_ADD:
|
| 1464 | if (!rdev->ops->set_pmksa)
|
| 1465 | return -EOPNOTSUPP;
|
| 1466 |
|
| 1467 | return rdev_set_pmksa(rdev, dev, &cfg_pmksa);
|
| 1468 | case IW_PMKSA_REMOVE:
|
| 1469 | if (!rdev->ops->del_pmksa)
|
| 1470 | return -EOPNOTSUPP;
|
| 1471 |
|
| 1472 | return rdev_del_pmksa(rdev, dev, &cfg_pmksa);
|
| 1473 | case IW_PMKSA_FLUSH:
|
| 1474 | if (!rdev->ops->flush_pmksa)
|
| 1475 | return -EOPNOTSUPP;
|
| 1476 |
|
| 1477 | return rdev_flush_pmksa(rdev, dev);
|
| 1478 | default:
|
| 1479 | return -EOPNOTSUPP;
|
| 1480 | }
|
| 1481 | }
|
| 1482 |
|
| 1483 | static const iw_handler cfg80211_handlers[] = {
|
| 1484 | IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname),
|
| 1485 | IW_HANDLER(SIOCSIWFREQ, cfg80211_wext_siwfreq),
|
| 1486 | IW_HANDLER(SIOCGIWFREQ, cfg80211_wext_giwfreq),
|
| 1487 | IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode),
|
| 1488 | IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode),
|
| 1489 | IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange),
|
| 1490 | IW_HANDLER(SIOCSIWAP, cfg80211_wext_siwap),
|
| 1491 | IW_HANDLER(SIOCGIWAP, cfg80211_wext_giwap),
|
| 1492 | IW_HANDLER(SIOCSIWMLME, cfg80211_wext_siwmlme),
|
| 1493 | IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan),
|
| 1494 | IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan),
|
| 1495 | IW_HANDLER(SIOCSIWESSID, cfg80211_wext_siwessid),
|
| 1496 | IW_HANDLER(SIOCGIWESSID, cfg80211_wext_giwessid),
|
| 1497 | IW_HANDLER(SIOCSIWRATE, cfg80211_wext_siwrate),
|
| 1498 | IW_HANDLER(SIOCGIWRATE, cfg80211_wext_giwrate),
|
| 1499 | IW_HANDLER(SIOCSIWRTS, cfg80211_wext_siwrts),
|
| 1500 | IW_HANDLER(SIOCGIWRTS, cfg80211_wext_giwrts),
|
| 1501 | IW_HANDLER(SIOCSIWFRAG, cfg80211_wext_siwfrag),
|
| 1502 | IW_HANDLER(SIOCGIWFRAG, cfg80211_wext_giwfrag),
|
| 1503 | IW_HANDLER(SIOCSIWTXPOW, cfg80211_wext_siwtxpower),
|
| 1504 | IW_HANDLER(SIOCGIWTXPOW, cfg80211_wext_giwtxpower),
|
| 1505 | IW_HANDLER(SIOCSIWRETRY, cfg80211_wext_siwretry),
|
| 1506 | IW_HANDLER(SIOCGIWRETRY, cfg80211_wext_giwretry),
|
| 1507 | IW_HANDLER(SIOCSIWENCODE, cfg80211_wext_siwencode),
|
| 1508 | IW_HANDLER(SIOCGIWENCODE, cfg80211_wext_giwencode),
|
| 1509 | IW_HANDLER(SIOCSIWPOWER, cfg80211_wext_siwpower),
|
| 1510 | IW_HANDLER(SIOCGIWPOWER, cfg80211_wext_giwpower),
|
| 1511 | IW_HANDLER(SIOCSIWGENIE, cfg80211_wext_siwgenie),
|
| 1512 | IW_HANDLER(SIOCSIWAUTH, cfg80211_wext_siwauth),
|
| 1513 | IW_HANDLER(SIOCGIWAUTH, cfg80211_wext_giwauth),
|
| 1514 | IW_HANDLER(SIOCSIWENCODEEXT, cfg80211_wext_siwencodeext),
|
| 1515 | IW_HANDLER(SIOCSIWPMKSA, cfg80211_wext_siwpmksa),
|
| 1516 | };
|
| 1517 |
|
| 1518 | const struct iw_handler_def cfg80211_wext_handler = {
|
| 1519 | .num_standard = ARRAY_SIZE(cfg80211_handlers),
|
| 1520 | .standard = cfg80211_handlers,
|
| 1521 | .get_wireless_stats = cfg80211_wireless_stats,
|
| 1522 | };
|