License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2008-11-27 00:36:31 +03:00
|
|
|
/*
|
|
|
|
* cfg80211 - wext compat code
|
|
|
|
*
|
|
|
|
* This is temporary code until all wireless functionality is migrated
|
|
|
|
* into cfg80211, when that happens all the exports here go away and
|
|
|
|
* we directly assign the wireless handlers of wireless interfaces.
|
|
|
|
*
|
2009-05-11 15:54:58 +04:00
|
|
|
* Copyright 2008-2009 Johannes Berg <johannes@sipsolutions.net>
|
2008-11-27 00:36:31 +03:00
|
|
|
*/
|
|
|
|
|
2011-07-15 19:47:34 +04:00
|
|
|
#include <linux/export.h>
|
2008-11-27 00:36:31 +03:00
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <linux/nl80211.h>
|
2009-04-19 21:57:45 +04:00
|
|
|
#include <linux/if_arp.h>
|
2009-05-11 15:54:58 +04:00
|
|
|
#include <linux/etherdevice.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2008-11-27 00:36:31 +03:00
|
|
|
#include <net/iw_handler.h>
|
|
|
|
#include <net/cfg80211.h>
|
2011-07-13 12:39:09 +04:00
|
|
|
#include <net/cfg80211-wext.h>
|
2009-07-27 14:01:50 +04:00
|
|
|
#include "wext-compat.h"
|
2008-11-27 00:36:31 +03:00
|
|
|
#include "core.h"
|
2012-06-27 18:19:42 +04:00
|
|
|
#include "rdev-ops.h"
|
2008-11-27 00:36:31 +03:00
|
|
|
|
|
|
|
int cfg80211_wext_giwname(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
char *name, char *extra)
|
|
|
|
{
|
|
|
|
strcpy(name, "IEEE 802.11");
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwname);
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
u32 *mode, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
struct vif_params vifparams;
|
|
|
|
enum nl80211_iftype type;
|
|
|
|
|
2014-04-21 08:53:03 +04:00
|
|
|
rdev = wiphy_to_rdev(wdev->wiphy);
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
switch (*mode) {
|
|
|
|
case IW_MODE_INFRA:
|
|
|
|
type = NL80211_IFTYPE_STATION;
|
|
|
|
break;
|
|
|
|
case IW_MODE_ADHOC:
|
|
|
|
type = NL80211_IFTYPE_ADHOC;
|
|
|
|
break;
|
|
|
|
case IW_MODE_REPEAT:
|
|
|
|
type = NL80211_IFTYPE_WDS;
|
|
|
|
break;
|
|
|
|
case IW_MODE_MONITOR:
|
|
|
|
type = NL80211_IFTYPE_MONITOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-03-21 19:07:59 +03:00
|
|
|
if (type == wdev->iftype)
|
|
|
|
return 0;
|
|
|
|
|
2008-11-27 01:31:40 +03:00
|
|
|
memset(&vifparams, 0, sizeof(vifparams));
|
|
|
|
|
2017-04-12 12:23:28 +03:00
|
|
|
return cfg80211_change_iface(rdev, dev, type, &vifparams);
|
2008-11-27 01:31:40 +03:00
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_siwmode);
|
2008-11-27 01:31:40 +03:00
|
|
|
|
|
|
|
int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
u32 *mode, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
*mode = IW_MODE_MASTER;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
*mode = IW_MODE_INFRA;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
*mode = IW_MODE_ADHOC;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MONITOR:
|
|
|
|
*mode = IW_MODE_MONITOR;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_WDS:
|
|
|
|
*mode = IW_MODE_REPEAT;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
*mode = IW_MODE_SECOND; /* FIXME */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*mode = IW_MODE_AUTO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwmode);
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
int cfg80211_wext_giwrange(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct iw_range *range = (struct iw_range *) extra;
|
2016-04-12 16:56:15 +03:00
|
|
|
enum nl80211_band band;
|
2009-07-06 21:40:51 +04:00
|
|
|
int i, c = 0;
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
if (!wdev)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
data->length = sizeof(struct iw_range);
|
|
|
|
memset(range, 0, sizeof(struct iw_range));
|
|
|
|
|
|
|
|
range->we_version_compiled = WIRELESS_EXT;
|
|
|
|
range->we_version_source = 21;
|
|
|
|
range->retry_capa = IW_RETRY_LIMIT;
|
|
|
|
range->retry_flags = IW_RETRY_LIMIT;
|
|
|
|
range->min_retry = 0;
|
|
|
|
range->max_retry = 255;
|
|
|
|
range->min_rts = 0;
|
|
|
|
range->max_rts = 2347;
|
|
|
|
range->min_frag = 256;
|
|
|
|
range->max_frag = 2346;
|
|
|
|
|
|
|
|
range->max_encoding_tokens = 4;
|
|
|
|
|
|
|
|
range->max_qual.updated = IW_QUAL_NOISE_INVALID;
|
|
|
|
|
|
|
|
switch (wdev->wiphy->signal_type) {
|
|
|
|
case CFG80211_SIGNAL_TYPE_NONE:
|
|
|
|
break;
|
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
2012-12-07 14:58:26 +04:00
|
|
|
range->max_qual.level = (u8)-110;
|
2009-02-18 21:32:08 +03:00
|
|
|
range->max_qual.qual = 70;
|
|
|
|
range->avg_qual.qual = 35;
|
|
|
|
range->max_qual.updated |= IW_QUAL_DBM;
|
|
|
|
range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
break;
|
|
|
|
case CFG80211_SIGNAL_TYPE_UNSPEC:
|
|
|
|
range->max_qual.level = 100;
|
|
|
|
range->max_qual.qual = 100;
|
|
|
|
range->avg_qual.qual = 50;
|
|
|
|
range->max_qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
range->avg_qual.level = range->max_qual.level / 2;
|
|
|
|
range->avg_qual.noise = range->max_qual.noise / 2;
|
|
|
|
range->avg_qual.updated = range->max_qual.updated;
|
|
|
|
|
2009-07-06 21:40:51 +04:00
|
|
|
for (i = 0; i < wdev->wiphy->n_cipher_suites; i++) {
|
|
|
|
switch (wdev->wiphy->cipher_suites[i]) {
|
2009-06-19 02:21:14 +04:00
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
2009-06-19 02:21:17 +04:00
|
|
|
range->enc_capa |= (IW_ENC_CAPA_CIPHER_TKIP |
|
|
|
|
IW_ENC_CAPA_WPA);
|
2009-06-19 02:21:14 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
2009-06-19 02:21:17 +04:00
|
|
|
range->enc_capa |= (IW_ENC_CAPA_CIPHER_CCMP |
|
|
|
|
IW_ENC_CAPA_WPA2);
|
2009-06-19 02:21:14 +04:00
|
|
|
break;
|
2009-06-19 02:21:16 +04:00
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
range->encoding_size[range->num_encoding_sizes++] =
|
|
|
|
WLAN_KEY_LEN_WEP40;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
|
|
|
range->encoding_size[range->num_encoding_sizes++] =
|
|
|
|
WLAN_KEY_LEN_WEP104;
|
|
|
|
break;
|
2009-06-19 02:21:14 +04:00
|
|
|
}
|
|
|
|
}
|
2009-02-18 21:32:08 +03:00
|
|
|
|
2016-04-12 16:56:15 +03:00
|
|
|
for (band = 0; band < NUM_NL80211_BANDS; band ++) {
|
2009-02-18 21:32:08 +03:00
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
|
|
|
|
sband = wdev->wiphy->bands[band];
|
|
|
|
|
|
|
|
if (!sband)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) {
|
|
|
|
struct ieee80211_channel *chan = &sband->channels[i];
|
|
|
|
|
|
|
|
if (!(chan->flags & IEEE80211_CHAN_DISABLED)) {
|
|
|
|
range->freq[c].i =
|
|
|
|
ieee80211_frequency_to_channel(
|
|
|
|
chan->center_freq);
|
|
|
|
range->freq[c].m = chan->center_freq;
|
|
|
|
range->freq[c].e = 6;
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
range->num_channels = c;
|
|
|
|
range->num_frequency = c;
|
|
|
|
|
|
|
|
IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
|
|
|
|
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
|
|
|
|
IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
|
|
|
|
|
2009-06-19 02:21:15 +04:00
|
|
|
if (wdev->wiphy->max_scan_ssids > 0)
|
|
|
|
range->scan_capa |= IW_SCAN_CAPA_ESSID;
|
2009-02-18 21:32:08 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwrange);
|
2009-04-19 21:57:45 +04:00
|
|
|
|
2009-04-19 23:24:32 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cfg80211_wext_freq - get wext frequency for non-"auto"
|
2014-04-09 05:28:06 +04:00
|
|
|
* @dev: the net device
|
2009-04-19 23:24:32 +04:00
|
|
|
* @freq: the wext freq encoding
|
|
|
|
*
|
2009-08-07 19:22:35 +04:00
|
|
|
* Returns a frequency, or a negative error code, or 0 for auto.
|
2009-04-19 23:24:32 +04:00
|
|
|
*/
|
2014-04-09 05:28:06 +04:00
|
|
|
int cfg80211_wext_freq(struct iw_freq *freq)
|
2009-04-19 23:24:32 +04:00
|
|
|
{
|
2009-05-08 11:42:33 +04:00
|
|
|
/*
|
2009-08-07 19:22:35 +04:00
|
|
|
* Parse frequency - return 0 for auto and
|
2009-05-08 11:42:33 +04:00
|
|
|
* -EINVAL for impossible things.
|
|
|
|
*/
|
2009-04-19 23:24:32 +04:00
|
|
|
if (freq->e == 0) {
|
2016-04-12 16:56:15 +03:00
|
|
|
enum nl80211_band band = NL80211_BAND_2GHZ;
|
2009-04-19 23:24:32 +04:00
|
|
|
if (freq->m < 0)
|
2009-08-07 19:22:35 +04:00
|
|
|
return 0;
|
2011-01-17 07:37:28 +03:00
|
|
|
if (freq->m > 14)
|
2016-04-12 16:56:15 +03:00
|
|
|
band = NL80211_BAND_5GHZ;
|
2011-01-17 07:37:28 +03:00
|
|
|
return ieee80211_channel_to_frequency(freq->m, band);
|
2009-04-19 23:24:32 +04:00
|
|
|
} else {
|
|
|
|
int i, div = 1000000;
|
|
|
|
for (i = 0; i < freq->e; i++)
|
|
|
|
div /= 10;
|
2009-05-08 11:42:33 +04:00
|
|
|
if (div <= 0)
|
2009-08-07 19:22:35 +04:00
|
|
|
return -EINVAL;
|
|
|
|
return freq->m / div;
|
2009-04-19 23:24:32 +04:00
|
|
|
}
|
|
|
|
}
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwrts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rts, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-04-20 20:39:05 +04:00
|
|
|
u32 orts = wdev->wiphy->rts_threshold;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (rts->disabled || !rts->fixed)
|
|
|
|
wdev->wiphy->rts_threshold = (u32) -1;
|
|
|
|
else if (rts->value < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
wdev->wiphy->rts_threshold = rts->value;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD);
|
2009-04-20 20:39:05 +04:00
|
|
|
if (err)
|
|
|
|
wdev->wiphy->rts_threshold = orts;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_siwrts);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_giwrts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rts, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
rts->value = wdev->wiphy->rts_threshold;
|
|
|
|
rts->disabled = rts->value == (u32) -1;
|
|
|
|
rts->fixed = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwrts);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_siwfrag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *frag, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-04-20 20:39:05 +04:00
|
|
|
u32 ofrag = wdev->wiphy->frag_threshold;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (frag->disabled || !frag->fixed)
|
|
|
|
wdev->wiphy->frag_threshold = (u32) -1;
|
|
|
|
else if (frag->value < 256)
|
|
|
|
return -EINVAL;
|
|
|
|
else {
|
|
|
|
/* Fragment length must be even, so strip LSB. */
|
|
|
|
wdev->wiphy->frag_threshold = frag->value & ~0x1;
|
|
|
|
}
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD);
|
2009-04-20 20:39:05 +04:00
|
|
|
if (err)
|
|
|
|
wdev->wiphy->frag_threshold = ofrag;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_siwfrag);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
|
|
|
int cfg80211_wext_giwfrag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *frag, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
frag->value = wdev->wiphy->frag_threshold;
|
|
|
|
frag->disabled = frag->value == (u32) -1;
|
|
|
|
frag->fixed = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwfrag);
|
2009-04-20 20:39:05 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwretry(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *retry, char *extra)
|
2009-04-20 20:39:05 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-04-20 20:39:05 +04:00
|
|
|
u32 changed = 0;
|
|
|
|
u8 olong = wdev->wiphy->retry_long;
|
|
|
|
u8 oshort = wdev->wiphy->retry_short;
|
|
|
|
int err;
|
|
|
|
|
2014-01-09 19:46:14 +04:00
|
|
|
if (retry->disabled || retry->value < 1 || retry->value > 255 ||
|
2009-04-20 20:39:05 +04:00
|
|
|
(retry->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (retry->flags & IW_RETRY_LONG) {
|
|
|
|
wdev->wiphy->retry_long = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_LONG;
|
|
|
|
} else if (retry->flags & IW_RETRY_SHORT) {
|
|
|
|
wdev->wiphy->retry_short = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_SHORT;
|
|
|
|
} else {
|
|
|
|
wdev->wiphy->retry_short = retry->value;
|
|
|
|
wdev->wiphy->retry_long = retry->value;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_LONG;
|
|
|
|
changed |= WIPHY_PARAM_RETRY_SHORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!changed)
|
|
|
|
return 0;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_wiphy_params(rdev, changed);
|
2009-04-20 20:39:05 +04:00
|
|
|
if (err) {
|
|
|
|
wdev->wiphy->retry_short = oshort;
|
|
|
|
wdev->wiphy->retry_long = olong;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cfg80211_wext_giwretry(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *retry, char *extra)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
retry->disabled = 0;
|
|
|
|
|
|
|
|
if (retry->flags == 0 || (retry->flags & IW_RETRY_SHORT)) {
|
|
|
|
/*
|
|
|
|
* First return short value, iwconfig will ask long value
|
|
|
|
* later if needed
|
|
|
|
*/
|
2014-01-06 20:26:11 +04:00
|
|
|
retry->flags |= IW_RETRY_LIMIT | IW_RETRY_SHORT;
|
2009-04-20 20:39:05 +04:00
|
|
|
retry->value = wdev->wiphy->retry_short;
|
2014-01-06 20:26:11 +04:00
|
|
|
if (wdev->wiphy->retry_long == wdev->wiphy->retry_short)
|
2009-04-20 20:39:05 +04:00
|
|
|
retry->flags |= IW_RETRY_LONG;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retry->flags & IW_RETRY_LONG) {
|
|
|
|
retry->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
|
|
|
|
retry->value = wdev->wiphy->retry_long;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-01-06 16:00:53 +03:00
|
|
|
EXPORT_WEXT_HANDLER(cfg80211_wext_giwretry);
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
|
2010-10-05 21:39:30 +04:00
|
|
|
struct net_device *dev, bool pairwise,
|
|
|
|
const u8 *addr, bool remove, bool tx_key,
|
|
|
|
int idx, struct key_params *params)
|
2009-05-11 15:54:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
int err, i;
|
2009-11-18 15:03:43 +03:00
|
|
|
bool rejoin = false;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
|
2010-10-05 21:39:30 +04:00
|
|
|
if (pairwise && !addr)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-09-29 00:44:57 +03:00
|
|
|
/*
|
|
|
|
* In many cases we won't actually need this, but it's better
|
|
|
|
* to do it first in case the allocation fails. Don't use wext.
|
|
|
|
*/
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->wext.keys) {
|
|
|
|
wdev->wext.keys = kzalloc(sizeof(*wdev->wext.keys),
|
2016-09-13 17:39:38 +03:00
|
|
|
GFP_KERNEL);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->wext.keys)
|
|
|
|
return -ENOMEM;
|
2016-09-22 23:16:50 +03:00
|
|
|
for (i = 0; i < CFG80211_MAX_WEP_KEYS; i++)
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev->wext.keys->params[i].key =
|
|
|
|
wdev->wext.keys->data[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_ADHOC &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->current_bss)
|
|
|
|
return -ENOLINK;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!rdev->ops->set_default_mgmt_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (idx < 4 || idx > 5)
|
|
|
|
return -EINVAL;
|
|
|
|
} else if (idx < 0 || idx > 3)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (remove) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
2009-11-18 15:03:43 +03:00
|
|
|
if (wdev->current_bss) {
|
|
|
|
/*
|
|
|
|
* If removing the current TX key, we will need to
|
|
|
|
* join a new IBSS without the privacy bit clear.
|
|
|
|
*/
|
|
|
|
if (idx == wdev->wext.default_key &&
|
|
|
|
wdev->iftype == NL80211_IFTYPE_ADHOC) {
|
|
|
|
__cfg80211_leave_ibss(rdev, wdev->netdev, true);
|
|
|
|
rejoin = true;
|
|
|
|
}
|
2010-10-05 21:39:30 +04:00
|
|
|
|
|
|
|
if (!pairwise && addr &&
|
|
|
|
!(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
|
|
|
|
err = -ENOENT;
|
|
|
|
else
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_del_key(rdev, dev, idx, pairwise,
|
|
|
|
addr);
|
2009-11-18 15:03:43 +03:00
|
|
|
}
|
2009-11-24 19:54:10 +03:00
|
|
|
wdev->wext.connect.privacy = false;
|
2009-11-18 15:03:43 +03:00
|
|
|
/*
|
|
|
|
* Applications using wireless extensions expect to be
|
|
|
|
* able to delete keys that don't exist, so allow that.
|
|
|
|
*/
|
|
|
|
if (err == -ENOENT)
|
|
|
|
err = 0;
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!err) {
|
2016-09-13 17:39:38 +03:00
|
|
|
if (!addr && idx < 4) {
|
2014-09-10 14:39:56 +04:00
|
|
|
memset(wdev->wext.keys->data[idx], 0,
|
|
|
|
sizeof(wdev->wext.keys->data[idx]));
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev->wext.keys->params[idx].key_len = 0;
|
|
|
|
wdev->wext.keys->params[idx].cipher = 0;
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
if (idx == wdev->wext.default_key)
|
|
|
|
wdev->wext.default_key = -1;
|
|
|
|
else if (idx == wdev->wext.default_mgmt_key)
|
|
|
|
wdev->wext.default_mgmt_key = -1;
|
|
|
|
}
|
2009-11-18 15:03:43 +03:00
|
|
|
|
|
|
|
if (!err && rejoin)
|
|
|
|
err = cfg80211_ibss_wext_join(rdev, wdev);
|
2009-05-18 21:56:36 +04:00
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
return err;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (addr)
|
|
|
|
tx_key = false;
|
|
|
|
|
2010-10-05 21:39:30 +04:00
|
|
|
if (cfg80211_validate_key_settings(rdev, params, idx, pairwise, addr))
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
return -EINVAL;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
|
|
|
if (wdev->current_bss)
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_add_key(rdev, dev, idx, pairwise, addr, params);
|
2016-09-13 17:11:32 +03:00
|
|
|
else if (params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
|
|
|
|
params->cipher != WLAN_CIPHER_SUITE_WEP104)
|
|
|
|
return -EINVAL;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2016-09-29 00:44:57 +03:00
|
|
|
/*
|
|
|
|
* We only need to store WEP keys, since they're the only keys that
|
|
|
|
* can be be set before a connection is established and persist after
|
|
|
|
* disconnecting.
|
|
|
|
*/
|
|
|
|
if (!addr && (params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
|
|
|
|
params->cipher == WLAN_CIPHER_SUITE_WEP104)) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev->wext.keys->params[idx] = *params;
|
|
|
|
memcpy(wdev->wext.keys->data[idx],
|
|
|
|
params->key, params->key_len);
|
|
|
|
wdev->wext.keys->params[idx].key =
|
|
|
|
wdev->wext.keys->data[idx];
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
2009-07-20 07:47:43 +04:00
|
|
|
if ((params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
|
|
|
|
params->cipher == WLAN_CIPHER_SUITE_WEP104) &&
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
(tx_key || (!addr && wdev->wext.default_key == -1))) {
|
2009-11-18 15:03:43 +03:00
|
|
|
if (wdev->current_bss) {
|
|
|
|
/*
|
|
|
|
* If we are getting a new TX key from not having
|
|
|
|
* had one before we need to join a new IBSS with
|
|
|
|
* the privacy bit set.
|
|
|
|
*/
|
|
|
|
if (wdev->iftype == NL80211_IFTYPE_ADHOC &&
|
|
|
|
wdev->wext.default_key == -1) {
|
|
|
|
__cfg80211_leave_ibss(rdev, wdev->netdev, true);
|
|
|
|
rejoin = true;
|
|
|
|
}
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_default_key(rdev, dev, idx, true, true);
|
2009-11-18 15:03:43 +03:00
|
|
|
}
|
|
|
|
if (!err) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev->wext.default_key = idx;
|
2009-11-18 15:03:43 +03:00
|
|
|
if (rejoin)
|
|
|
|
err = cfg80211_ibss_wext_join(rdev, wdev);
|
|
|
|
}
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
return err;
|
|
|
|
}
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC &&
|
|
|
|
(tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) {
|
|
|
|
if (wdev->current_bss)
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_default_mgmt_key(rdev, dev, idx);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!err)
|
|
|
|
wdev->wext.default_mgmt_key = idx;
|
|
|
|
return err;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
|
2010-10-05 21:39:30 +04:00
|
|
|
struct net_device *dev, bool pairwise,
|
|
|
|
const u8 *addr, bool remove, bool tx_key,
|
|
|
|
int idx, struct key_params *params)
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
wdev_lock(dev->ieee80211_ptr);
|
2010-10-05 21:39:30 +04:00
|
|
|
err = __cfg80211_set_encryption(rdev, dev, pairwise, addr,
|
|
|
|
remove, tx_key, idx, params);
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev_unlock(dev->ieee80211_ptr);
|
|
|
|
|
|
|
|
return err;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwencode(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *keybuf)
|
2009-05-11 15:54:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-05-11 15:54:58 +04:00
|
|
|
int idx, err;
|
|
|
|
bool remove = false;
|
|
|
|
struct key_params params;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
/* no use -- only MFP (set_default_mgmt_key) is optional */
|
|
|
|
if (!rdev->ops->del_key ||
|
|
|
|
!rdev->ops->add_key ||
|
|
|
|
!rdev->ops->set_default_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (idx == 0) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
} else if (idx < 1 || idx > 4)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
idx--;
|
|
|
|
|
|
|
|
if (erq->flags & IW_ENCODE_DISABLED)
|
|
|
|
remove = true;
|
|
|
|
else if (erq->length == 0) {
|
|
|
|
/* No key data - just set the default TX key index */
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
err = 0;
|
|
|
|
wdev_lock(wdev);
|
|
|
|
if (wdev->current_bss)
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_default_key(rdev, dev, idx, true,
|
|
|
|
true);
|
2009-05-11 15:54:58 +04:00
|
|
|
if (!err)
|
|
|
|
wdev->wext.default_key = idx;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
wdev_unlock(wdev);
|
2009-05-11 15:54:58 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.key = keybuf;
|
|
|
|
params.key_len = erq->length;
|
|
|
|
if (erq->length == 5)
|
|
|
|
params.cipher = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (erq->length == 13)
|
|
|
|
params.cipher = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else if (!remove)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 21:39:30 +04:00
|
|
|
return cfg80211_set_encryption(rdev, dev, false, NULL, remove,
|
2009-05-11 15:54:58 +04:00
|
|
|
wdev->wext.default_key == -1,
|
|
|
|
idx, ¶ms);
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwencodeext(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *extra)
|
2009-05-11 15:54:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-05-11 15:54:58 +04:00
|
|
|
struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
|
|
|
|
const u8 *addr;
|
|
|
|
int idx;
|
|
|
|
bool remove = false;
|
|
|
|
struct key_params params;
|
|
|
|
u32 cipher;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
/* no use -- only MFP (set_default_mgmt_key) is optional */
|
|
|
|
if (!rdev->ops->del_key ||
|
|
|
|
!rdev->ops->add_key ||
|
|
|
|
!rdev->ops->set_default_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (ext->alg) {
|
|
|
|
case IW_ENCODE_ALG_NONE:
|
|
|
|
remove = true;
|
|
|
|
cipher = 0;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_WEP:
|
|
|
|
if (ext->key_len == 5)
|
|
|
|
cipher = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (ext->key_len == 13)
|
|
|
|
cipher = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_TKIP:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_CCMP:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_AES_CMAC:
|
|
|
|
cipher = WLAN_CIPHER_SUITE_AES_CMAC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (erq->flags & IW_ENCODE_DISABLED)
|
|
|
|
remove = true;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
|
|
|
|
if (idx < 4 || idx > 5) {
|
|
|
|
idx = wdev->wext.default_mgmt_key;
|
|
|
|
if (idx < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
idx--;
|
|
|
|
} else {
|
|
|
|
if (idx < 1 || idx > 4) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
idx--;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = ext->addr.sa_data;
|
|
|
|
if (is_broadcast_ether_addr(addr))
|
|
|
|
addr = NULL;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
params.key = ext->key;
|
|
|
|
params.key_len = ext->key_len;
|
|
|
|
params.cipher = cipher;
|
|
|
|
|
2009-05-11 22:57:58 +04:00
|
|
|
if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
|
|
|
|
params.seq = ext->rx_seq;
|
|
|
|
params.seq_len = 6;
|
|
|
|
}
|
|
|
|
|
2009-05-11 15:54:58 +04:00
|
|
|
return cfg80211_set_encryption(
|
2010-10-05 21:39:30 +04:00
|
|
|
rdev, dev,
|
|
|
|
!(ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY),
|
|
|
|
addr, remove,
|
2009-05-11 15:54:58 +04:00
|
|
|
ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY,
|
|
|
|
idx, ¶ms);
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwencode(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *erq, char *keybuf)
|
2009-05-11 15:54:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
int idx;
|
2009-05-11 15:54:58 +04:00
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_ADHOC)
|
2009-05-11 15:54:58 +04:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
idx = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
if (idx == 0) {
|
|
|
|
idx = wdev->wext.default_key;
|
|
|
|
if (idx < 0)
|
|
|
|
idx = 0;
|
|
|
|
} else if (idx < 1 || idx > 4)
|
|
|
|
return -EINVAL;
|
|
|
|
else
|
|
|
|
idx--;
|
|
|
|
|
|
|
|
erq->flags = idx + 1;
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
if (!wdev->wext.keys || !wdev->wext.keys->params[idx].cipher) {
|
2009-05-11 15:54:58 +04:00
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
erq->length = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 16:22:54 +04:00
|
|
|
erq->length = min_t(size_t, erq->length,
|
|
|
|
wdev->wext.keys->params[idx].key_len);
|
|
|
|
memcpy(keybuf, wdev->wext.keys->params[idx].key, erq->length);
|
|
|
|
erq->flags |= IW_ENCODE_ENABLED;
|
|
|
|
|
|
|
|
return 0;
|
2009-05-11 15:54:58 +04:00
|
|
|
}
|
2009-06-02 15:01:39 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwfreq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_freq *wextfreq, char *extra)
|
2009-07-27 14:01:50 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2012-11-09 00:25:48 +04:00
|
|
|
struct cfg80211_chan_def chandef = {
|
2012-11-09 02:14:50 +04:00
|
|
|
.width = NL80211_CHAN_WIDTH_20_NOHT,
|
2012-11-09 00:25:48 +04:00
|
|
|
};
|
2013-05-08 23:45:15 +04:00
|
|
|
int freq;
|
2009-07-27 14:01:50 +04:00
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2009-08-07 19:22:35 +04:00
|
|
|
return cfg80211_mgd_wext_siwfreq(dev, info, wextfreq, extra);
|
2009-07-27 14:01:50 +04:00
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2009-08-07 19:22:35 +04:00
|
|
|
return cfg80211_ibss_wext_siwfreq(dev, info, wextfreq, extra);
|
cfg80211/mac80211: better channel handling
Currently (all tested with hwsim) you can do stupid
things like setting up an AP on a certain channel,
then adding another virtual interface and making
that associate on another channel -- this will make
the beaconing to move channel but obviously without
the necessary IEs data update.
In order to improve this situation, first make the
configuration APIs (cfg80211 and nl80211) aware of
multi-channel operation -- we'll eventually need
that in the future anyway. There's one userland API
change and one API addition. The API change is that
now SET_WIPHY must be called with virtual interface
index rather than only wiphy index in order to take
effect for that interface -- luckily all current
users (hostapd) do that. For monitor interfaces, the
old setting is preserved, but monitors are always
slaved to other devices anyway so no guarantees.
The second userland API change is the introduction
of a per virtual interface SET_CHANNEL command, that
hostapd should use going forward to make it easier
to understand what's going on (it can automatically
detect a kernel with this command).
Other than mac80211, no existing cfg80211 drivers
are affected by this change because they only allow
a single virtual interface.
mac80211, however, now needs to be aware that the
channel settings are per interface now, and needs
to disallow (for now) real multi-channel operation,
which is another important part of this patch.
One of the immediate benefits is that you can now
start hostapd to operate on a hardware that already
has a connection on another virtual interface, as
long as you specify the same channel.
Note that two things are left unhandled (this is an
improvement -- not a complete fix):
* different HT/no-HT modes
currently you could start an HT AP and then
connect to a non-HT network on the same channel
which would configure the hardware for no HT;
that can be fixed fairly easily
* CSA
An AP we're connected to on a virtual interface
might indicate switching channels, and in that
case we would follow it, regardless of how many
other interfaces are operating; this requires
more effort to fix but is pretty rare after all
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-05-05 17:25:02 +04:00
|
|
|
case NL80211_IFTYPE_MONITOR:
|
2014-04-09 05:28:06 +04:00
|
|
|
freq = cfg80211_wext_freq(wextfreq);
|
2009-08-07 19:22:35 +04:00
|
|
|
if (freq < 0)
|
|
|
|
return freq;
|
|
|
|
if (freq == 0)
|
2009-07-27 14:01:50 +04:00
|
|
|
return -EINVAL;
|
2012-11-09 02:14:50 +04:00
|
|
|
chandef.center_freq1 = freq;
|
2012-11-09 00:25:48 +04:00
|
|
|
chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
|
|
|
if (!chandef.chan)
|
|
|
|
return -EINVAL;
|
2013-05-08 23:45:15 +04:00
|
|
|
return cfg80211_set_monitor_channel(rdev, &chandef);
|
2012-05-17 01:50:20 +04:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
2014-04-09 05:28:06 +04:00
|
|
|
freq = cfg80211_wext_freq(wextfreq);
|
2012-05-17 01:50:20 +04:00
|
|
|
if (freq < 0)
|
|
|
|
return freq;
|
|
|
|
if (freq == 0)
|
|
|
|
return -EINVAL;
|
2012-11-09 02:14:50 +04:00
|
|
|
chandef.center_freq1 = freq;
|
2012-11-09 00:25:48 +04:00
|
|
|
chandef.chan = ieee80211_get_channel(&rdev->wiphy, freq);
|
|
|
|
if (!chandef.chan)
|
|
|
|
return -EINVAL;
|
2013-05-08 23:45:15 +04:00
|
|
|
return cfg80211_set_mesh_channel(rdev, wdev, &chandef);
|
cfg80211/mac80211: better channel handling
Currently (all tested with hwsim) you can do stupid
things like setting up an AP on a certain channel,
then adding another virtual interface and making
that associate on another channel -- this will make
the beaconing to move channel but obviously without
the necessary IEs data update.
In order to improve this situation, first make the
configuration APIs (cfg80211 and nl80211) aware of
multi-channel operation -- we'll eventually need
that in the future anyway. There's one userland API
change and one API addition. The API change is that
now SET_WIPHY must be called with virtual interface
index rather than only wiphy index in order to take
effect for that interface -- luckily all current
users (hostapd) do that. For monitor interfaces, the
old setting is preserved, but monitors are always
slaved to other devices anyway so no guarantees.
The second userland API change is the introduction
of a per virtual interface SET_CHANNEL command, that
hostapd should use going forward to make it easier
to understand what's going on (it can automatically
detect a kernel with this command).
Other than mac80211, no existing cfg80211 drivers
are affected by this change because they only allow
a single virtual interface.
mac80211, however, now needs to be aware that the
channel settings are per interface now, and needs
to disallow (for now) real multi-channel operation,
which is another important part of this patch.
One of the immediate benefits is that you can now
start hostapd to operate on a hardware that already
has a connection on another virtual interface, as
long as you specify the same channel.
Note that two things are left unhandled (this is an
improvement -- not a complete fix):
* different HT/no-HT modes
currently you could start an HT AP and then
connect to a non-HT network on the same channel
which would configure the hardware for no HT;
that can be fixed fairly easily
* CSA
An AP we're connected to on a virtual interface
might indicate switching channels, and in that
case we would follow it, regardless of how many
other interfaces are operating; this requires
more effort to fix but is pretty rare after all
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-05-05 17:25:02 +04:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
2009-07-27 14:01:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwfreq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_freq *freq, char *extra)
|
2009-07-27 14:01:50 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2012-11-09 00:25:48 +04:00
|
|
|
struct cfg80211_chan_def chandef;
|
|
|
|
int ret;
|
2009-07-27 14:01:50 +04:00
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra);
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra);
|
2011-11-09 13:30:21 +04:00
|
|
|
case NL80211_IFTYPE_MONITOR:
|
2012-07-12 21:45:08 +04:00
|
|
|
if (!rdev->ops->get_channel)
|
2011-11-09 13:30:21 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-11-09 00:25:48 +04:00
|
|
|
ret = rdev_get_channel(rdev, wdev, &chandef);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
freq->m = chandef.chan->center_freq;
|
2011-11-09 13:30:21 +04:00
|
|
|
freq->e = 6;
|
|
|
|
return 0;
|
2009-07-27 14:01:50 +04:00
|
|
|
default:
|
2012-06-06 10:18:22 +04:00
|
|
|
return -EINVAL;
|
2009-07-27 14:01:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwtxpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *data, char *extra)
|
2009-06-02 15:01:39 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2010-06-23 13:12:37 +04:00
|
|
|
enum nl80211_tx_power_setting type;
|
2009-06-02 15:01:39 +04:00
|
|
|
int dbm = 0;
|
|
|
|
|
|
|
|
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
|
|
|
return -EINVAL;
|
|
|
|
if (data->txpower.flags & IW_TXPOW_RANGE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_tx_power)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
/* only change when not disabling */
|
|
|
|
if (!data->txpower.disabled) {
|
2009-06-02 15:01:41 +04:00
|
|
|
rfkill_set_sw_state(rdev->rfkill, false);
|
|
|
|
|
2009-06-02 15:01:39 +04:00
|
|
|
if (data->txpower.fixed) {
|
|
|
|
/*
|
|
|
|
* wext doesn't support negative values, see
|
|
|
|
* below where it's for automatic
|
|
|
|
*/
|
|
|
|
if (data->txpower.value < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
dbm = data->txpower.value;
|
2010-06-23 13:12:37 +04:00
|
|
|
type = NL80211_TX_POWER_FIXED;
|
2009-06-02 15:01:39 +04:00
|
|
|
/* TODO: do regulatory check! */
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Automatic power level setting, max being the value
|
|
|
|
* passed in from userland.
|
|
|
|
*/
|
|
|
|
if (data->txpower.value < 0) {
|
2010-06-23 13:12:37 +04:00
|
|
|
type = NL80211_TX_POWER_AUTOMATIC;
|
2009-06-02 15:01:39 +04:00
|
|
|
} else {
|
|
|
|
dbm = data->txpower.value;
|
2010-06-23 13:12:37 +04:00
|
|
|
type = NL80211_TX_POWER_LIMITED;
|
2009-06-02 15:01:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-06-02 15:01:41 +04:00
|
|
|
rfkill_set_sw_state(rdev->rfkill, true);
|
|
|
|
schedule_work(&rdev->rfkill_sync);
|
|
|
|
return 0;
|
2009-06-02 15:01:39 +04:00
|
|
|
}
|
|
|
|
|
2012-10-24 12:17:18 +04:00
|
|
|
return rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm));
|
2009-06-02 15:01:39 +04:00
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwtxpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *data, char *extra)
|
2009-06-02 15:01:39 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-06-02 15:01:39 +04:00
|
|
|
int err, val;
|
|
|
|
|
|
|
|
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
|
|
|
return -EINVAL;
|
|
|
|
if (data->txpower.flags & IW_TXPOW_RANGE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_tx_power)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-10-24 12:17:18 +04:00
|
|
|
err = rdev_get_tx_power(rdev, wdev, &val);
|
2009-06-02 15:01:41 +04:00
|
|
|
if (err)
|
2009-06-02 15:01:39 +04:00
|
|
|
return err;
|
|
|
|
|
|
|
|
/* well... oh well */
|
|
|
|
data->txpower.fixed = 1;
|
2009-06-02 15:01:41 +04:00
|
|
|
data->txpower.disabled = rfkill_blocked(rdev->rfkill);
|
2009-06-02 15:01:39 +04:00
|
|
|
data->txpower.value = val;
|
|
|
|
data->txpower.flags = IW_TXPOW_DBM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-01 23:26:56 +04:00
|
|
|
|
|
|
|
static int cfg80211_set_auth_alg(struct wireless_dev *wdev,
|
|
|
|
s32 auth_alg)
|
|
|
|
{
|
|
|
|
int nr_alg = 0;
|
|
|
|
|
|
|
|
if (!auth_alg)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (auth_alg & ~(IW_AUTH_ALG_OPEN_SYSTEM |
|
|
|
|
IW_AUTH_ALG_SHARED_KEY |
|
|
|
|
IW_AUTH_ALG_LEAP))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_OPEN_SYSTEM) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_SHARED_KEY) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_SHARED_KEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auth_alg & IW_AUTH_ALG_LEAP) {
|
|
|
|
nr_alg++;
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_NETWORK_EAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nr_alg > 1)
|
|
|
|
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg80211_set_wpa_version(struct wireless_dev *wdev, u32 wpa_versions)
|
|
|
|
{
|
|
|
|
if (wpa_versions & ~(IW_AUTH_WPA_VERSION_WPA |
|
2009-07-12 04:03:48 +04:00
|
|
|
IW_AUTH_WPA_VERSION_WPA2|
|
|
|
|
IW_AUTH_WPA_VERSION_DISABLED))
|
2009-07-01 23:26:56 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-12 04:03:48 +04:00
|
|
|
if ((wpa_versions & IW_AUTH_WPA_VERSION_DISABLED) &&
|
|
|
|
(wpa_versions & (IW_AUTH_WPA_VERSION_WPA|
|
|
|
|
IW_AUTH_WPA_VERSION_WPA2)))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (wpa_versions & IW_AUTH_WPA_VERSION_DISABLED)
|
|
|
|
wdev->wext.connect.crypto.wpa_versions &=
|
|
|
|
~(NL80211_WPA_VERSION_1|NL80211_WPA_VERSION_2);
|
|
|
|
|
2009-07-01 23:26:56 +04:00
|
|
|
if (wpa_versions & IW_AUTH_WPA_VERSION_WPA)
|
|
|
|
wdev->wext.connect.crypto.wpa_versions |=
|
|
|
|
NL80211_WPA_VERSION_1;
|
|
|
|
|
|
|
|
if (wpa_versions & IW_AUTH_WPA_VERSION_WPA2)
|
|
|
|
wdev->wext.connect.crypto.wpa_versions |=
|
|
|
|
NL80211_WPA_VERSION_2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_cipher_group(struct wireless_dev *wdev, u32 cipher)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP40)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_WEP104)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_TKIP)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_CCMP)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
else if (cipher & IW_AUTH_CIPHER_AES_CMAC)
|
|
|
|
wdev->wext.connect.crypto.cipher_group =
|
|
|
|
WLAN_CIPHER_SUITE_AES_CMAC;
|
2009-11-01 12:18:49 +03:00
|
|
|
else if (cipher & IW_AUTH_CIPHER_NONE)
|
|
|
|
wdev->wext.connect.crypto.cipher_group = 0;
|
2009-07-01 23:26:56 +04:00
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_cipher_pairwise(struct wireless_dev *wdev, u32 cipher)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
int nr_ciphers = 0;
|
|
|
|
u32 *ciphers_pairwise = wdev->wext.connect.crypto.ciphers_pairwise;
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP40) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP40;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_WEP104) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_WEP104;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_TKIP) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_TKIP;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_CCMP) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_CCMP;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher & IW_AUTH_CIPHER_AES_CMAC) {
|
|
|
|
ciphers_pairwise[nr_ciphers] = WLAN_CIPHER_SUITE_AES_CMAC;
|
|
|
|
nr_ciphers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUILD_BUG_ON(NL80211_MAX_NR_CIPHER_SUITES < 5);
|
|
|
|
|
|
|
|
wdev->wext.connect.crypto.n_ciphers_pairwise = nr_ciphers;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-07 05:56:10 +04:00
|
|
|
static int cfg80211_set_key_mgt(struct wireless_dev *wdev, u32 key_mgt)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
int nr_akm_suites = 0;
|
|
|
|
|
|
|
|
if (key_mgt & ~(IW_AUTH_KEY_MGMT_802_1X |
|
|
|
|
IW_AUTH_KEY_MGMT_PSK))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (key_mgt & IW_AUTH_KEY_MGMT_802_1X) {
|
|
|
|
wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
|
|
|
WLAN_AKM_SUITE_8021X;
|
|
|
|
nr_akm_suites++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_mgt & IW_AUTH_KEY_MGMT_PSK) {
|
|
|
|
wdev->wext.connect.crypto.akm_suites[nr_akm_suites] =
|
|
|
|
WLAN_AKM_SUITE_PSK;
|
|
|
|
nr_akm_suites++;
|
|
|
|
}
|
|
|
|
|
|
|
|
wdev->wext.connect.crypto.n_akm_suites = nr_akm_suites;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (data->flags & IW_AUTH_INDEX) {
|
|
|
|
case IW_AUTH_PRIVACY_INVOKED:
|
|
|
|
wdev->wext.connect.privacy = data->value;
|
|
|
|
return 0;
|
|
|
|
case IW_AUTH_WPA_VERSION:
|
|
|
|
return cfg80211_set_wpa_version(wdev, data->value);
|
|
|
|
case IW_AUTH_CIPHER_GROUP:
|
|
|
|
return cfg80211_set_cipher_group(wdev, data->value);
|
|
|
|
case IW_AUTH_KEY_MGMT:
|
|
|
|
return cfg80211_set_key_mgt(wdev, data->value);
|
|
|
|
case IW_AUTH_CIPHER_PAIRWISE:
|
|
|
|
return cfg80211_set_cipher_pairwise(wdev, data->value);
|
|
|
|
case IW_AUTH_80211_AUTH_ALG:
|
|
|
|
return cfg80211_set_auth_alg(wdev, data->value);
|
|
|
|
case IW_AUTH_WPA_ENABLED:
|
|
|
|
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
|
|
|
|
case IW_AUTH_DROP_UNENCRYPTED:
|
|
|
|
case IW_AUTH_MFP:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwauth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *data, char *extra)
|
2009-07-01 23:26:56 +04:00
|
|
|
{
|
|
|
|
/* XXX: what do we need? */
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2009-07-01 23:26:57 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *wrq, char *extra)
|
2009-07-01 23:26:57 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
nl80211: add power save commands
The most needed command from nl80211, which Wireless Extensions had,
is support for power save mode. Add a simple command to make it possible
to enable and disable power save via nl80211.
I was also planning about extending the interface, for example adding the
timeout value, but after thinking more about this I decided not to do it.
Basically there were three reasons:
Firstly, the parameters for power save are very much hardware dependent.
Trying to find a unified interface which would work with all hardware, and
still make sense to users, will be very difficult.
Secondly, IEEE 802.11 power save implementation in Linux is still in state
of flux. We have a long way to still to go and there is no way to predict
what kind of implementation we will have after few years. And because we
need to support nl80211 interface a long time, practically forever, adding
now parameters to nl80211 might create maintenance problems later on.
Third issue are the users. Power save parameters are mostly used for
debugging, so debugfs is better, more flexible, interface for this.
For example, wpa_supplicant currently doesn't configure anything related
to power save mode. It's better to strive that kernel can automatically
optimise the power save parameters, like with help of pm qos network
and other traffic parameters.
Later on, when we have better understanding of power save, we can extend
this command with more features, if there's a need for that.
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-02-17 18:58:10 +03:00
|
|
|
bool ps = wdev->ps;
|
|
|
|
int timeout = wdev->ps_timeout;
|
2009-07-01 23:26:57 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_power_mgmt)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wrq->disabled) {
|
|
|
|
ps = false;
|
|
|
|
} else {
|
|
|
|
switch (wrq->flags & IW_POWER_MODE) {
|
|
|
|
case IW_POWER_ON: /* If not specified */
|
|
|
|
case IW_POWER_MODE: /* If set all mask */
|
|
|
|
case IW_POWER_ALL_R: /* If explicitely state all */
|
|
|
|
ps = true;
|
|
|
|
break;
|
|
|
|
default: /* Otherwise we ignore */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (wrq->flags & IW_POWER_TIMEOUT)
|
|
|
|
timeout = wrq->value / 1000;
|
|
|
|
}
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_power_mgmt(rdev, dev, ps, timeout);
|
2009-07-01 23:26:57 +04:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
nl80211: add power save commands
The most needed command from nl80211, which Wireless Extensions had,
is support for power save mode. Add a simple command to make it possible
to enable and disable power save via nl80211.
I was also planning about extending the interface, for example adding the
timeout value, but after thinking more about this I decided not to do it.
Basically there were three reasons:
Firstly, the parameters for power save are very much hardware dependent.
Trying to find a unified interface which would work with all hardware, and
still make sense to users, will be very difficult.
Secondly, IEEE 802.11 power save implementation in Linux is still in state
of flux. We have a long way to still to go and there is no way to predict
what kind of implementation we will have after few years. And because we
need to support nl80211 interface a long time, practically forever, adding
now parameters to nl80211 might create maintenance problems later on.
Third issue are the users. Power save parameters are mostly used for
debugging, so debugfs is better, more flexible, interface for this.
For example, wpa_supplicant currently doesn't configure anything related
to power save mode. It's better to strive that kernel can automatically
optimise the power save parameters, like with help of pm qos network
and other traffic parameters.
Later on, when we have better understanding of power save, we can extend
this command with more features, if there's a need for that.
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-02-17 18:58:10 +03:00
|
|
|
wdev->ps = ps;
|
|
|
|
wdev->ps_timeout = timeout;
|
2009-07-01 23:26:57 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwpower(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *wrq, char *extra)
|
2009-07-01 23:26:57 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
nl80211: add power save commands
The most needed command from nl80211, which Wireless Extensions had,
is support for power save mode. Add a simple command to make it possible
to enable and disable power save via nl80211.
I was also planning about extending the interface, for example adding the
timeout value, but after thinking more about this I decided not to do it.
Basically there were three reasons:
Firstly, the parameters for power save are very much hardware dependent.
Trying to find a unified interface which would work with all hardware, and
still make sense to users, will be very difficult.
Secondly, IEEE 802.11 power save implementation in Linux is still in state
of flux. We have a long way to still to go and there is no way to predict
what kind of implementation we will have after few years. And because we
need to support nl80211 interface a long time, practically forever, adding
now parameters to nl80211 might create maintenance problems later on.
Third issue are the users. Power save parameters are mostly used for
debugging, so debugfs is better, more flexible, interface for this.
For example, wpa_supplicant currently doesn't configure anything related
to power save mode. It's better to strive that kernel can automatically
optimise the power save parameters, like with help of pm qos network
and other traffic parameters.
Later on, when we have better understanding of power save, we can extend
this command with more features, if there's a need for that.
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-02-17 18:58:10 +03:00
|
|
|
wrq->disabled = !wdev->ps;
|
2009-07-01 23:26:57 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-01 23:26:58 +04:00
|
|
|
|
2009-07-27 14:01:51 +04:00
|
|
|
static int cfg80211_wds_wext_siwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *addr, char *extra)
|
2009-07-01 23:26:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-07-01 23:26:58 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (addr->sa_family != ARPHRD_ETHER)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_wds_peer)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_set_wds_peer(rdev, dev, (u8 *)&addr->sa_data);
|
2009-07-01 23:26:58 +04:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
memcpy(&wdev->wext.bssid, (u8 *) &addr->sa_data, ETH_ALEN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:01:51 +04:00
|
|
|
static int cfg80211_wds_wext_giwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *addr, char *extra)
|
2009-07-01 23:26:58 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (WARN_ON(wdev->iftype != NL80211_IFTYPE_WDS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
addr->sa_family = ARPHRD_ETHER;
|
|
|
|
memcpy(&addr->sa_data, wdev->wext.bssid, ETH_ALEN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-01 23:26:59 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
2009-07-01 23:26:59 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-07-01 23:26:59 +04:00
|
|
|
struct cfg80211_bitrate_mask mask;
|
2010-01-06 14:09:08 +03:00
|
|
|
u32 fixed, maxrate;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
int band, ridx;
|
|
|
|
bool match = false;
|
2009-07-01 23:26:59 +04:00
|
|
|
|
|
|
|
if (!rdev->ops->set_bitrate_mask)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-01-06 14:09:08 +03:00
|
|
|
memset(&mask, 0, sizeof(mask));
|
|
|
|
fixed = 0;
|
2010-01-27 17:44:48 +03:00
|
|
|
maxrate = (u32)-1;
|
2009-07-01 23:26:59 +04:00
|
|
|
|
|
|
|
if (rate->value < 0) {
|
|
|
|
/* nothing */
|
|
|
|
} else if (rate->fixed) {
|
2010-01-06 14:09:08 +03:00
|
|
|
fixed = rate->value / 100000;
|
2009-07-01 23:26:59 +04:00
|
|
|
} else {
|
2010-01-06 14:09:08 +03:00
|
|
|
maxrate = rate->value / 100000;
|
|
|
|
}
|
|
|
|
|
2016-04-12 16:56:15 +03:00
|
|
|
for (band = 0; band < NUM_NL80211_BANDS; band++) {
|
2010-01-06 14:09:08 +03:00
|
|
|
sband = wdev->wiphy->bands[band];
|
|
|
|
if (sband == NULL)
|
|
|
|
continue;
|
|
|
|
for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
|
|
|
|
struct ieee80211_rate *srate = &sband->bitrates[ridx];
|
|
|
|
if (fixed == srate->bitrate) {
|
|
|
|
mask.control[band].legacy = 1 << ridx;
|
|
|
|
match = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (srate->bitrate <= maxrate) {
|
|
|
|
mask.control[band].legacy |= 1 << ridx;
|
|
|
|
match = true;
|
|
|
|
}
|
|
|
|
}
|
2009-07-01 23:26:59 +04:00
|
|
|
}
|
|
|
|
|
2010-01-06 14:09:08 +03:00
|
|
|
if (!match)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
return rdev_set_bitrate_mask(rdev, dev, NULL, &mask);
|
2009-07-01 23:26:59 +04:00
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwrate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_param *rate, char *extra)
|
2009-07-01 23:26:59 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-07-01 23:26:59 +04:00
|
|
|
/* we are under RTNL - globally locked - so can use a static struct */
|
|
|
|
static struct station_info sinfo;
|
2009-07-08 01:41:27 +04:00
|
|
|
u8 addr[ETH_ALEN];
|
2009-07-01 23:26:59 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_station)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-07-08 01:41:27 +04:00
|
|
|
err = 0;
|
|
|
|
wdev_lock(wdev);
|
2009-07-03 04:00:48 +04:00
|
|
|
if (wdev->current_bss)
|
2009-07-08 01:41:27 +04:00
|
|
|
memcpy(addr, wdev->current_bss->pub.bssid, ETH_ALEN);
|
2009-07-03 04:00:48 +04:00
|
|
|
else
|
2009-07-08 01:41:27 +04:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-07-01 23:26:59 +04:00
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
err = rdev_get_station(rdev, dev, addr, &sinfo);
|
2009-07-01 23:26:59 +04:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2014-11-17 16:08:11 +03:00
|
|
|
if (!(sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)))
|
2009-07-01 23:26:59 +04:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-12-10 00:43:52 +03:00
|
|
|
rate->value = 100000 * cfg80211_calculate_bitrate(&sinfo.txrate);
|
2009-07-01 23:26:59 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-01 23:27:00 +04:00
|
|
|
|
|
|
|
/* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */
|
2011-07-15 15:01:38 +04:00
|
|
|
static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
|
2009-07-01 23:27:00 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-07-01 23:27:00 +04:00
|
|
|
/* we are under RTNL - globally locked - so can use static structs */
|
|
|
|
static struct iw_statistics wstats;
|
|
|
|
static struct station_info sinfo;
|
2009-07-10 18:54:07 +04:00
|
|
|
u8 bssid[ETH_ALEN];
|
2009-07-01 23:27:00 +04:00
|
|
|
|
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!rdev->ops->get_station)
|
|
|
|
return NULL;
|
|
|
|
|
2009-07-10 18:54:07 +04:00
|
|
|
/* Grab BSSID of current BSS, if any */
|
|
|
|
wdev_lock(wdev);
|
|
|
|
if (!wdev->current_bss) {
|
|
|
|
wdev_unlock(wdev);
|
2009-07-01 23:27:00 +04:00
|
|
|
return NULL;
|
2009-07-10 18:54:07 +04:00
|
|
|
}
|
|
|
|
memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN);
|
|
|
|
wdev_unlock(wdev);
|
2009-07-01 23:27:00 +04:00
|
|
|
|
2015-06-09 22:35:44 +03:00
|
|
|
memset(&sinfo, 0, sizeof(sinfo));
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
if (rdev_get_station(rdev, dev, bssid, &sinfo))
|
2009-07-01 23:27:00 +04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memset(&wstats, 0, sizeof(wstats));
|
|
|
|
|
|
|
|
switch (rdev->wiphy.signal_type) {
|
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
2014-11-17 16:08:11 +03:00
|
|
|
if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL)) {
|
2009-07-01 23:27:00 +04:00
|
|
|
int sig = sinfo.signal;
|
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_DBM;
|
|
|
|
wstats.qual.level = sig;
|
|
|
|
if (sig < -110)
|
|
|
|
sig = -110;
|
|
|
|
else if (sig > -40)
|
|
|
|
sig = -40;
|
|
|
|
wstats.qual.qual = sig + 110;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CFG80211_SIGNAL_TYPE_UNSPEC:
|
2014-11-17 16:08:11 +03:00
|
|
|
if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL)) {
|
2009-07-01 23:27:00 +04:00
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
wstats.qual.level = sinfo.signal;
|
|
|
|
wstats.qual.qual = sinfo.signal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
|
|
|
|
wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
wstats.qual.updated |= IW_QUAL_NOISE_INVALID;
|
2014-11-17 16:08:11 +03:00
|
|
|
if (sinfo.filled & BIT(NL80211_STA_INFO_RX_DROP_MISC))
|
2010-10-08 03:39:20 +04:00
|
|
|
wstats.discard.misc = sinfo.rx_dropped_misc;
|
2014-11-17 16:08:11 +03:00
|
|
|
if (sinfo.filled & BIT(NL80211_STA_INFO_TX_FAILED))
|
2010-10-08 03:39:20 +04:00
|
|
|
wstats.discard.retries = sinfo.tx_failed;
|
2009-07-01 23:27:00 +04:00
|
|
|
|
|
|
|
return &wstats;
|
|
|
|
}
|
2009-07-27 14:01:51 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *ap_addr, char *extra)
|
2009-07-27 14:01:51 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra);
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
return cfg80211_mgd_wext_siwap(dev, info, ap_addr, extra);
|
|
|
|
case NL80211_IFTYPE_WDS:
|
|
|
|
return cfg80211_wds_wext_siwap(dev, info, ap_addr, extra);
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct sockaddr *ap_addr, char *extra)
|
2009-07-27 14:01:51 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
return cfg80211_ibss_wext_giwap(dev, info, ap_addr, extra);
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
return cfg80211_mgd_wext_giwap(dev, info, ap_addr, extra);
|
|
|
|
case NL80211_IFTYPE_WDS:
|
|
|
|
return cfg80211_wds_wext_giwap(dev, info, ap_addr, extra);
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 14:01:52 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwessid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *ssid)
|
2009-07-27 14:01:52 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
return cfg80211_ibss_wext_siwessid(dev, info, data, ssid);
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
return cfg80211_mgd_wext_siwessid(dev, info, data, ssid);
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_giwessid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *ssid)
|
2009-07-27 14:01:52 +04:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
wireless extensions: fix kernel heap content leak
Wireless extensions have an unfortunate, undocumented
requirement which requires drivers to always fill
iwp->length when returning a successful status. When
a driver doesn't do this, it leads to a kernel heap
content leak when userspace offers a larger buffer
than would have been necessary.
Arguably, this is a driver bug, as it should, if it
returns 0, fill iwp->length, even if it separately
indicated that the buffer contents was not valid.
However, we can also at least avoid the memory content
leak if the driver doesn't do this by setting the iwp
length to max_tokens, which then reflects how big the
buffer is that the driver may fill, regardless of how
big the userspace buffer is.
To illustrate the point, this patch also fixes a
corresponding cfg80211 bug (since this requirement
isn't documented nor was ever pointed out by anyone
during code review, I don't trust all drivers nor
all cfg80211 handlers to implement it correctly).
Cc: stable@kernel.org [all the way back]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-08-30 14:24:54 +04:00
|
|
|
data->flags = 0;
|
|
|
|
data->length = 0;
|
|
|
|
|
2009-07-27 14:01:52 +04:00
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
return cfg80211_ibss_wext_giwessid(dev, info, data, ssid);
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
return cfg80211_mgd_wext_giwessid(dev, info, data, ssid);
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 14:01:53 +04:00
|
|
|
|
2011-07-15 15:01:38 +04:00
|
|
|
static int cfg80211_wext_siwpmksa(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
struct iw_point *data, char *extra)
|
2009-11-25 02:01:01 +03:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2014-04-21 08:53:03 +04:00
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
|
2009-11-25 02:01:01 +03:00
|
|
|
struct cfg80211_pmksa cfg_pmksa;
|
|
|
|
struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
|
|
|
|
|
|
|
|
memset(&cfg_pmksa, 0, sizeof(struct cfg80211_pmksa));
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
cfg_pmksa.bssid = pmksa->bssid.sa_data;
|
|
|
|
cfg_pmksa.pmkid = pmksa->pmkid;
|
|
|
|
|
|
|
|
switch (pmksa->cmd) {
|
|
|
|
case IW_PMKSA_ADD:
|
|
|
|
if (!rdev->ops->set_pmksa)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
return rdev_set_pmksa(rdev, dev, &cfg_pmksa);
|
2009-11-25 02:01:01 +03:00
|
|
|
|
|
|
|
case IW_PMKSA_REMOVE:
|
|
|
|
if (!rdev->ops->del_pmksa)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
return rdev_del_pmksa(rdev, dev, &cfg_pmksa);
|
2009-11-25 02:01:01 +03:00
|
|
|
|
|
|
|
case IW_PMKSA_FLUSH:
|
|
|
|
if (!rdev->ops->flush_pmksa)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-27 18:19:42 +04:00
|
|
|
return rdev_flush_pmksa(rdev, dev);
|
2009-11-25 02:01:01 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-27 14:01:53 +04:00
|
|
|
static const iw_handler cfg80211_handlers[] = {
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWNAME)] = (iw_handler) cfg80211_wext_giwname,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWFREQ)] = (iw_handler) cfg80211_wext_siwfreq,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWFREQ)] = (iw_handler) cfg80211_wext_giwfreq,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWMODE)] = (iw_handler) cfg80211_wext_siwmode,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWMODE)] = (iw_handler) cfg80211_wext_giwmode,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWRANGE)] = (iw_handler) cfg80211_wext_giwrange,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWAP)] = (iw_handler) cfg80211_wext_siwap,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWAP)] = (iw_handler) cfg80211_wext_giwap,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWMLME)] = (iw_handler) cfg80211_wext_siwmlme,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWSCAN)] = (iw_handler) cfg80211_wext_siwscan,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWSCAN)] = (iw_handler) cfg80211_wext_giwscan,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWESSID)] = (iw_handler) cfg80211_wext_siwessid,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWESSID)] = (iw_handler) cfg80211_wext_giwessid,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWRATE)] = (iw_handler) cfg80211_wext_siwrate,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWRATE)] = (iw_handler) cfg80211_wext_giwrate,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWRTS)] = (iw_handler) cfg80211_wext_siwrts,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWRTS)] = (iw_handler) cfg80211_wext_giwrts,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWFRAG)] = (iw_handler) cfg80211_wext_siwfrag,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWFRAG)] = (iw_handler) cfg80211_wext_giwfrag,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWTXPOW)] = (iw_handler) cfg80211_wext_siwtxpower,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWTXPOW)] = (iw_handler) cfg80211_wext_giwtxpower,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWRETRY)] = (iw_handler) cfg80211_wext_siwretry,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWRETRY)] = (iw_handler) cfg80211_wext_giwretry,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWENCODE)] = (iw_handler) cfg80211_wext_siwencode,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWENCODE)] = (iw_handler) cfg80211_wext_giwencode,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWPOWER)] = (iw_handler) cfg80211_wext_siwpower,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWPOWER)] = (iw_handler) cfg80211_wext_giwpower,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWGENIE)] = (iw_handler) cfg80211_wext_siwgenie,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWAUTH)] = (iw_handler) cfg80211_wext_siwauth,
|
|
|
|
[IW_IOCTL_IDX(SIOCGIWAUTH)] = (iw_handler) cfg80211_wext_giwauth,
|
|
|
|
[IW_IOCTL_IDX(SIOCSIWENCODEEXT)]= (iw_handler) cfg80211_wext_siwencodeext,
|
2009-11-25 02:01:01 +03:00
|
|
|
[IW_IOCTL_IDX(SIOCSIWPMKSA)] = (iw_handler) cfg80211_wext_siwpmksa,
|
2009-07-27 14:01:53 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct iw_handler_def cfg80211_wext_handler = {
|
|
|
|
.num_standard = ARRAY_SIZE(cfg80211_handlers),
|
|
|
|
.standard = cfg80211_handlers,
|
|
|
|
.get_wireless_stats = cfg80211_wireless_stats,
|
|
|
|
};
|