2007-09-21 00:09:35 +07:00
|
|
|
/*
|
|
|
|
* This is the new netlink-based wireless configuration interface.
|
|
|
|
*
|
2010-02-15 17:53:10 +07:00
|
|
|
* Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
|
2007-09-21 00:09:35 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/err.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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2007-09-21 00:09:35 +07:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/ieee80211.h>
|
|
|
|
#include <linux/nl80211.h>
|
|
|
|
#include <linux/rtnetlink.h>
|
|
|
|
#include <linux/netlink.h>
|
2009-02-11 03:25:55 +07:00
|
|
|
#include <linux/etherdevice.h>
|
2009-07-14 05:33:35 +07:00
|
|
|
#include <net/net_namespace.h>
|
2007-09-21 00:09:35 +07:00
|
|
|
#include <net/genetlink.h>
|
|
|
|
#include <net/cfg80211.h>
|
2009-07-14 05:33:35 +07:00
|
|
|
#include <net/sock.h>
|
2007-09-21 00:09:35 +07:00
|
|
|
#include "core.h"
|
|
|
|
#include "nl80211.h"
|
2008-09-10 13:19:48 +07:00
|
|
|
#include "reg.h"
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2011-08-11 03:54:35 +07:00
|
|
|
static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
|
|
|
|
struct genl_info *info,
|
|
|
|
struct cfg80211_crypto_settings *settings,
|
|
|
|
int cipher_limit);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb,
|
|
|
|
struct genl_info *info);
|
|
|
|
static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb,
|
|
|
|
struct genl_info *info);
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
/* the netlink family */
|
|
|
|
static struct genl_family nl80211_fam = {
|
|
|
|
.id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
|
|
|
|
.name = "nl80211", /* have users key off the name instead */
|
|
|
|
.hdrsize = 0, /* no private header */
|
|
|
|
.version = 1, /* no particular meaning now */
|
|
|
|
.maxattr = NL80211_ATTR_MAX,
|
2009-07-14 05:33:35 +07:00
|
|
|
.netnsok = true,
|
2010-10-05 02:36:35 +07:00
|
|
|
.pre_doit = nl80211_pre_doit,
|
|
|
|
.post_doit = nl80211_post_doit,
|
2007-09-21 00:09:35 +07:00
|
|
|
};
|
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
/* returns ERR_PTR values */
|
|
|
|
static struct wireless_dev *
|
|
|
|
__cfg80211_wdev_from_attrs(struct net *netns, struct nlattr **attrs)
|
2007-09-21 00:09:35 +07:00
|
|
|
{
|
2012-06-15 19:33:17 +07:00
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
struct wireless_dev *result = NULL;
|
|
|
|
bool have_ifidx = attrs[NL80211_ATTR_IFINDEX];
|
|
|
|
bool have_wdev_id = attrs[NL80211_ATTR_WDEV];
|
|
|
|
u64 wdev_id;
|
|
|
|
int wiphy_idx = -1;
|
|
|
|
int ifidx = -1;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
assert_cfg80211_lock();
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
if (!have_ifidx && !have_wdev_id)
|
|
|
|
return ERR_PTR(-EINVAL);
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
if (have_ifidx)
|
|
|
|
ifidx = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
|
|
|
|
if (have_wdev_id) {
|
|
|
|
wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]);
|
|
|
|
wiphy_idx = wdev_id >> 32;
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
|
|
|
|
if (wiphy_net(&rdev->wiphy) != netns)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (have_wdev_id && rdev->wiphy_idx != wiphy_idx)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
list_for_each_entry(wdev, &rdev->wdev_list, list) {
|
|
|
|
if (have_ifidx && wdev->netdev &&
|
|
|
|
wdev->netdev->ifindex == ifidx) {
|
|
|
|
result = wdev;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (have_wdev_id && wdev->identifier == (u32)wdev_id) {
|
|
|
|
result = wdev;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
return ERR_PTR(-ENODEV);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2012-06-15 18:32:49 +07:00
|
|
|
static struct cfg80211_registered_device *
|
2012-06-15 19:18:32 +07:00
|
|
|
__cfg80211_rdev_from_attrs(struct net *netns, struct nlattr **attrs)
|
2012-06-15 18:32:49 +07:00
|
|
|
{
|
2012-06-15 19:09:58 +07:00
|
|
|
struct cfg80211_registered_device *rdev = NULL, *tmp;
|
|
|
|
struct net_device *netdev;
|
2012-06-15 18:32:49 +07:00
|
|
|
|
|
|
|
assert_cfg80211_lock();
|
|
|
|
|
2012-06-15 19:18:32 +07:00
|
|
|
if (!attrs[NL80211_ATTR_WIPHY] &&
|
2012-06-15 19:33:17 +07:00
|
|
|
!attrs[NL80211_ATTR_IFINDEX] &&
|
|
|
|
!attrs[NL80211_ATTR_WDEV])
|
2012-06-15 19:09:58 +07:00
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
2012-06-15 19:18:32 +07:00
|
|
|
if (attrs[NL80211_ATTR_WIPHY])
|
2012-06-15 19:09:58 +07:00
|
|
|
rdev = cfg80211_rdev_by_wiphy_idx(
|
2012-06-15 19:18:32 +07:00
|
|
|
nla_get_u32(attrs[NL80211_ATTR_WIPHY]));
|
2012-06-15 18:32:49 +07:00
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
if (attrs[NL80211_ATTR_WDEV]) {
|
|
|
|
u64 wdev_id = nla_get_u64(attrs[NL80211_ATTR_WDEV]);
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
tmp = cfg80211_rdev_by_wiphy_idx(wdev_id >> 32);
|
|
|
|
if (tmp) {
|
|
|
|
/* make sure wdev exists */
|
|
|
|
mutex_lock(&tmp->devlist_mtx);
|
|
|
|
list_for_each_entry(wdev, &tmp->wdev_list, list) {
|
|
|
|
if (wdev->identifier != (u32)wdev_id)
|
|
|
|
continue;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mutex_unlock(&tmp->devlist_mtx);
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
tmp = NULL;
|
|
|
|
|
|
|
|
if (rdev && tmp != rdev)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
rdev = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 19:18:32 +07:00
|
|
|
if (attrs[NL80211_ATTR_IFINDEX]) {
|
|
|
|
int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
|
2012-06-15 19:14:22 +07:00
|
|
|
netdev = dev_get_by_index(netns, ifindex);
|
2012-06-15 19:09:58 +07:00
|
|
|
if (netdev) {
|
|
|
|
if (netdev->ieee80211_ptr)
|
|
|
|
tmp = wiphy_to_dev(
|
|
|
|
netdev->ieee80211_ptr->wiphy);
|
|
|
|
else
|
|
|
|
tmp = NULL;
|
|
|
|
|
|
|
|
dev_put(netdev);
|
|
|
|
|
|
|
|
/* not wireless device -- return error */
|
|
|
|
if (!tmp)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
/* mismatch -- return error */
|
|
|
|
if (rdev && tmp != rdev)
|
|
|
|
return ERR_PTR(-EINVAL);
|
|
|
|
|
|
|
|
rdev = tmp;
|
2012-06-15 18:32:49 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 19:14:22 +07:00
|
|
|
if (!rdev)
|
|
|
|
return ERR_PTR(-ENODEV);
|
2012-06-15 18:32:49 +07:00
|
|
|
|
2012-06-15 19:14:22 +07:00
|
|
|
if (netns != wiphy_net(&rdev->wiphy))
|
|
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
|
|
|
|
return rdev;
|
2012-06-15 18:32:49 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This function returns a pointer to the driver
|
|
|
|
* that the genl_info item that is passed refers to.
|
|
|
|
* If successful, it returns non-NULL and also locks
|
|
|
|
* the driver's mutex!
|
|
|
|
*
|
|
|
|
* This means that you need to call cfg80211_unlock_rdev()
|
|
|
|
* before being allowed to acquire &cfg80211_mutex!
|
|
|
|
*
|
|
|
|
* This is necessary because we need to lock the global
|
|
|
|
* mutex to get an item off the list safely, and then
|
|
|
|
* we lock the rdev mutex so it doesn't go away under us.
|
|
|
|
*
|
|
|
|
* We don't want to keep cfg80211_mutex locked
|
|
|
|
* for all the time in order to allow requests on
|
|
|
|
* other interfaces to go through at the same time.
|
|
|
|
*
|
|
|
|
* The result of this can be a PTR_ERR and hence must
|
|
|
|
* be checked with IS_ERR() for errors.
|
|
|
|
*/
|
|
|
|
static struct cfg80211_registered_device *
|
2012-06-15 19:14:22 +07:00
|
|
|
cfg80211_get_dev_from_info(struct net *netns, struct genl_info *info)
|
2012-06-15 18:32:49 +07:00
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
|
|
|
|
mutex_lock(&cfg80211_mutex);
|
2012-06-15 19:18:32 +07:00
|
|
|
rdev = __cfg80211_rdev_from_attrs(netns, info->attrs);
|
2012-06-15 18:32:49 +07:00
|
|
|
|
|
|
|
/* if it is not an error we grab the lock on
|
|
|
|
* it to assure it won't be going away while
|
|
|
|
* we operate on it */
|
|
|
|
if (!IS_ERR(rdev))
|
|
|
|
mutex_lock(&rdev->mtx);
|
|
|
|
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
|
|
|
|
return rdev;
|
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
/* policy for the attributes */
|
2010-02-18 15:14:31 +07:00
|
|
|
static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
|
2007-09-21 00:09:35 +07:00
|
|
|
[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
|
2009-05-27 11:15:00 +07:00
|
|
|
.len = 20-1 },
|
2008-10-30 21:59:24 +07:00
|
|
|
[NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED },
|
2008-11-26 21:15:24 +07:00
|
|
|
[NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 },
|
2008-12-12 13:27:43 +07:00
|
|
|
[NL80211_ATTR_WIPHY_CHANNEL_TYPE] = { .type = NLA_U32 },
|
2009-04-20 23:39:05 +07:00
|
|
|
[NL80211_ATTR_WIPHY_RETRY_SHORT] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_WIPHY_RETRY_LONG] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_WIPHY_FRAG_THRESHOLD] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_WIPHY_RTS_THRESHOLD] = { .type = NLA_U32 },
|
2009-12-22 04:50:47 +07:00
|
|
|
[NL80211_ATTR_WIPHY_COVERAGE_CLASS] = { .type = NLA_U8 },
|
2007-09-21 00:09:35 +07:00
|
|
|
|
|
|
|
[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2011-11-24 23:13:56 +07:00
|
|
|
[NL80211_ATTR_MAC] = { .len = ETH_ALEN },
|
|
|
|
[NL80211_ATTR_PREV_BSSID] = { .len = ETH_ALEN },
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
[NL80211_ATTR_KEY] = { .type = NLA_NESTED, },
|
2007-12-19 08:03:29 +07:00
|
|
|
[NL80211_ATTR_KEY_DATA] = { .type = NLA_BINARY,
|
|
|
|
.len = WLAN_MAX_KEY_LEN },
|
|
|
|
[NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG },
|
2011-11-03 04:36:31 +07:00
|
|
|
[NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 },
|
2010-10-06 00:39:30 +07:00
|
|
|
[NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 },
|
2007-12-19 08:03:32 +07:00
|
|
|
|
|
|
|
[NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_DTIM_PERIOD] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_BEACON_HEAD] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
|
|
|
[NL80211_ATTR_BEACON_TAIL] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
2007-12-19 08:03:34 +07:00
|
|
|
[NL80211_ATTR_STA_AID] = { .type = NLA_U16 },
|
|
|
|
[NL80211_ATTR_STA_FLAGS] = { .type = NLA_NESTED },
|
|
|
|
[NL80211_ATTR_STA_LISTEN_INTERVAL] = { .type = NLA_U16 },
|
|
|
|
[NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY,
|
|
|
|
.len = NL80211_MAX_SUPP_RATES },
|
2008-02-23 21:17:06 +07:00
|
|
|
[NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 },
|
2007-12-19 08:03:34 +07:00
|
|
|
[NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 },
|
2008-10-15 16:54:04 +07:00
|
|
|
[NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ },
|
2008-02-23 21:17:06 +07:00
|
|
|
[NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
|
2012-06-11 10:59:36 +07:00
|
|
|
.len = IEEE80211_MAX_MESH_ID_LEN },
|
2008-02-23 21:17:06 +07:00
|
|
|
[NL80211_ATTR_MPATH_NEXT_HOP] = { .type = NLA_U32 },
|
2008-08-08 00:07:01 +07:00
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
[NL80211_ATTR_REG_ALPHA2] = { .type = NLA_STRING, .len = 2 },
|
|
|
|
[NL80211_ATTR_REG_RULES] = { .type = NLA_NESTED },
|
|
|
|
|
2008-08-08 00:07:01 +07:00
|
|
|
[NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 },
|
2008-10-30 21:59:22 +07:00
|
|
|
[NL80211_ATTR_BSS_BASIC_RATES] = { .type = NLA_BINARY,
|
|
|
|
.len = NL80211_MAX_SUPP_RATES },
|
2010-11-19 18:40:25 +07:00
|
|
|
[NL80211_ATTR_BSS_HT_OPMODE] = { .type = NLA_U16 },
|
2008-08-25 15:58:58 +07:00
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
[NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED },
|
2011-04-08 05:08:28 +07:00
|
|
|
[NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG },
|
2008-10-22 02:03:48 +07:00
|
|
|
|
2011-11-03 15:27:01 +07:00
|
|
|
[NL80211_ATTR_HT_CAPABILITY] = { .len = NL80211_HT_CAPABILITY_LEN },
|
2009-01-13 21:03:29 +07:00
|
|
|
|
|
|
|
[NL80211_ATTR_MGMT_SUBTYPE] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_IE] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
2009-02-11 03:25:55 +07:00
|
|
|
[NL80211_ATTR_SCAN_FREQUENCIES] = { .type = NLA_NESTED },
|
|
|
|
[NL80211_ATTR_SCAN_SSIDS] = { .type = NLA_NESTED },
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
[NL80211_ATTR_SSID] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_SSID_LEN },
|
|
|
|
[NL80211_ATTR_AUTH_TYPE] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_REASON_CODE] = { .type = NLA_U16 },
|
2009-04-20 02:24:32 +07:00
|
|
|
[NL80211_ATTR_FREQ_FIXED] = { .type = NLA_FLAG },
|
2009-04-23 01:38:25 +07:00
|
|
|
[NL80211_ATTR_TIMED_OUT] = { .type = NLA_FLAG },
|
2009-05-07 02:09:37 +07:00
|
|
|
[NL80211_ATTR_USE_MFP] = { .type = NLA_U32 },
|
2009-05-12 01:57:56 +07:00
|
|
|
[NL80211_ATTR_STA_FLAGS2] = {
|
|
|
|
.len = sizeof(struct nl80211_sta_flag_update),
|
|
|
|
},
|
2009-05-12 01:57:57 +07:00
|
|
|
[NL80211_ATTR_CONTROL_PORT] = { .type = NLA_FLAG },
|
2010-08-27 18:26:53 +07:00
|
|
|
[NL80211_ATTR_CONTROL_PORT_ETHERTYPE] = { .type = NLA_U16 },
|
|
|
|
[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT] = { .type = NLA_FLAG },
|
2009-07-02 02:26:54 +07:00
|
|
|
[NL80211_ATTR_PRIVACY] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_ATTR_CIPHER_SUITE_GROUP] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_WPA_VERSIONS] = { .type = NLA_U32 },
|
2009-07-14 05:33:35 +07:00
|
|
|
[NL80211_ATTR_PID] = { .type = NLA_U32 },
|
2009-11-11 00:53:10 +07:00
|
|
|
[NL80211_ATTR_4ADDR] = { .type = NLA_U8 },
|
2009-11-25 05:59:15 +07:00
|
|
|
[NL80211_ATTR_PMKID] = { .type = NLA_BINARY,
|
|
|
|
.len = WLAN_PMKID_LEN },
|
2009-12-23 19:15:41 +07:00
|
|
|
[NL80211_ATTR_DURATION] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_COOKIE] = { .type = NLA_U64 },
|
2009-12-29 17:59:45 +07:00
|
|
|
[NL80211_ATTR_TX_RATES] = { .type = NLA_NESTED },
|
2010-02-15 17:53:10 +07:00
|
|
|
[NL80211_ATTR_FRAME] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
|
|
|
[NL80211_ATTR_FRAME_MATCH] = { .type = NLA_BINARY, },
|
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 22:58:10 +07:00
|
|
|
[NL80211_ATTR_PS_STATE] = { .type = NLA_U32 },
|
2010-03-23 14:02:33 +07:00
|
|
|
[NL80211_ATTR_CQM] = { .type = NLA_NESTED, },
|
2010-04-04 13:37:19 +07:00
|
|
|
[NL80211_ATTR_LOCAL_STATE_CHANGE] = { .type = NLA_FLAG },
|
2010-04-27 06:23:35 +07:00
|
|
|
[NL80211_ATTR_AP_ISOLATE] = { .type = NLA_U8 },
|
2010-06-23 16:12:38 +07:00
|
|
|
[NL80211_ATTR_WIPHY_TX_POWER_SETTING] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_WIPHY_TX_POWER_LEVEL] = { .type = NLA_U32 },
|
2010-08-12 20:38:38 +07:00
|
|
|
[NL80211_ATTR_FRAME_TYPE] = { .type = NLA_U16 },
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
[NL80211_ATTR_WIPHY_ANTENNA_TX] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_WIPHY_ANTENNA_RX] = { .type = NLA_U32 },
|
2010-11-11 21:07:22 +07:00
|
|
|
[NL80211_ATTR_MCAST_RATE] = { .type = NLA_U32 },
|
2010-11-25 16:02:29 +07:00
|
|
|
[NL80211_ATTR_OFFCHANNEL_TX_OK] = { .type = NLA_FLAG },
|
2010-12-10 01:58:59 +07:00
|
|
|
[NL80211_ATTR_KEY_DEFAULT_TYPES] = { .type = NLA_NESTED },
|
2011-05-04 20:37:28 +07:00
|
|
|
[NL80211_ATTR_WOWLAN_TRIGGERS] = { .type = NLA_NESTED },
|
2011-05-04 06:57:11 +07:00
|
|
|
[NL80211_ATTR_STA_PLINK_STATE] = { .type = NLA_U8 },
|
2011-05-11 21:09:37 +07:00
|
|
|
[NL80211_ATTR_SCHED_SCAN_INTERVAL] = { .type = NLA_U32 },
|
2011-07-05 21:35:40 +07:00
|
|
|
[NL80211_ATTR_REKEY_DATA] = { .type = NLA_NESTED },
|
2011-07-18 23:08:35 +07:00
|
|
|
[NL80211_ATTR_SCAN_SUPP_RATES] = { .type = NLA_NESTED },
|
2011-08-11 03:53:31 +07:00
|
|
|
[NL80211_ATTR_HIDDEN_SSID] = { .type = NLA_U32 },
|
2011-08-11 03:55:56 +07:00
|
|
|
[NL80211_ATTR_IE_PROBE_RESP] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
|
|
|
[NL80211_ATTR_IE_ASSOC_RESP] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
2011-08-29 15:53:03 +07:00
|
|
|
[NL80211_ATTR_ROAM_SUPPORT] = { .type = NLA_FLAG },
|
2011-08-31 20:01:48 +07:00
|
|
|
[NL80211_ATTR_SCHED_SCAN_MATCH] = { .type = NLA_NESTED },
|
2011-09-25 16:23:30 +07:00
|
|
|
[NL80211_ATTR_TX_NO_CCK_RATE] = { .type = NLA_FLAG },
|
2011-09-28 18:12:50 +07:00
|
|
|
[NL80211_ATTR_TDLS_ACTION] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_TDLS_DIALOG_TOKEN] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_TDLS_OPERATION] = { .type = NLA_U8 },
|
|
|
|
[NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG },
|
2011-11-04 17:18:21 +07:00
|
|
|
[NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG },
|
2011-11-10 16:28:56 +07:00
|
|
|
[NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY,
|
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
2011-10-12 00:59:02 +07:00
|
|
|
[NL80211_ATTR_DFS_REGION] = { .type = NLA_U8 },
|
2011-11-19 02:31:59 +07:00
|
|
|
[NL80211_ATTR_DISABLE_HT] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_ATTR_HT_CAPABILITY_MASK] = {
|
|
|
|
.len = NL80211_HT_CAPABILITY_LEN
|
|
|
|
},
|
2011-11-18 20:20:43 +07:00
|
|
|
[NL80211_ATTR_NOACK_MAP] = { .type = NLA_U16 },
|
2012-03-02 17:20:02 +07:00
|
|
|
[NL80211_ATTR_INACTIVITY_TIMEOUT] = { .type = NLA_U16 },
|
2012-03-07 18:57:12 +07:00
|
|
|
[NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 },
|
2012-06-15 19:33:17 +07:00
|
|
|
[NL80211_ATTR_WDEV] = { .type = NLA_U64 },
|
2012-07-13 01:49:18 +07:00
|
|
|
[NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
|
2012-09-30 23:29:39 +07:00
|
|
|
[NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, },
|
2012-10-11 15:04:52 +07:00
|
|
|
[NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN },
|
2012-10-12 11:03:31 +07:00
|
|
|
[NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 },
|
2007-09-21 00:09:35 +07:00
|
|
|
};
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
/* policy for the key attributes */
|
2010-02-18 15:14:31 +07:00
|
|
|
static const struct nla_policy nl80211_key_policy[NL80211_KEY_MAX + 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 19:22:54 +07:00
|
|
|
[NL80211_KEY_DATA] = { .type = NLA_BINARY, .len = WLAN_MAX_KEY_LEN },
|
2009-07-08 18:29:08 +07:00
|
|
|
[NL80211_KEY_IDX] = { .type = NLA_U8 },
|
|
|
|
[NL80211_KEY_CIPHER] = { .type = NLA_U32 },
|
2011-11-03 04:36:31 +07:00
|
|
|
[NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 },
|
2009-07-08 18:29:08 +07:00
|
|
|
[NL80211_KEY_DEFAULT] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG },
|
2010-10-06 00:39:30 +07:00
|
|
|
[NL80211_KEY_TYPE] = { .type = NLA_U32 },
|
2010-12-10 01:58:59 +07:00
|
|
|
[NL80211_KEY_DEFAULT_TYPES] = { .type = NLA_NESTED },
|
|
|
|
};
|
|
|
|
|
|
|
|
/* policy for the key default flags */
|
|
|
|
static const struct nla_policy
|
|
|
|
nl80211_key_default_policy[NUM_NL80211_KEY_DEFAULT_TYPES] = {
|
|
|
|
[NL80211_KEY_DEFAULT_TYPE_UNICAST] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_KEY_DEFAULT_TYPE_MULTICAST] = { .type = NLA_FLAG },
|
2009-07-08 18:29:08 +07:00
|
|
|
};
|
|
|
|
|
2011-05-04 20:37:28 +07:00
|
|
|
/* policy for WoWLAN attributes */
|
|
|
|
static const struct nla_policy
|
|
|
|
nl80211_wowlan_policy[NUM_NL80211_WOWLAN_TRIG] = {
|
|
|
|
[NL80211_WOWLAN_TRIG_ANY] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_DISCONNECT] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_MAGIC_PKT] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_PKT_PATTERN] = { .type = NLA_NESTED },
|
2011-07-13 15:48:55 +07:00
|
|
|
[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_WOWLAN_TRIG_RFKILL_RELEASE] = { .type = NLA_FLAG },
|
2011-05-04 20:37:28 +07:00
|
|
|
};
|
|
|
|
|
2011-07-05 21:35:40 +07:00
|
|
|
/* policy for GTK rekey offload attributes */
|
|
|
|
static const struct nla_policy
|
|
|
|
nl80211_rekey_policy[NUM_NL80211_REKEY_DATA] = {
|
|
|
|
[NL80211_REKEY_DATA_KEK] = { .len = NL80211_KEK_LEN },
|
|
|
|
[NL80211_REKEY_DATA_KCK] = { .len = NL80211_KCK_LEN },
|
|
|
|
[NL80211_REKEY_DATA_REPLAY_CTR] = { .len = NL80211_REPLAY_CTR_LEN },
|
|
|
|
};
|
|
|
|
|
2011-08-31 20:01:48 +07:00
|
|
|
static const struct nla_policy
|
|
|
|
nl80211_match_policy[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1] = {
|
2012-06-13 16:17:11 +07:00
|
|
|
[NL80211_SCHED_SCAN_MATCH_ATTR_SSID] = { .type = NLA_BINARY,
|
2011-08-31 20:01:48 +07:00
|
|
|
.len = IEEE80211_MAX_SSID_LEN },
|
2012-06-22 01:09:54 +07:00
|
|
|
[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI] = { .type = NLA_U32 },
|
2011-08-31 20:01:48 +07:00
|
|
|
};
|
|
|
|
|
2009-11-11 17:30:02 +07:00
|
|
|
/* ifidx get helper */
|
|
|
|
static int nl80211_get_ifidx(struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
|
|
|
|
nl80211_fam.attrbuf, nl80211_fam.maxattr,
|
|
|
|
nl80211_policy);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
res = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
|
|
|
|
if (!res)
|
|
|
|
return -EINVAL;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
static int nl80211_prepare_netdev_dump(struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb,
|
|
|
|
struct cfg80211_registered_device **rdev,
|
|
|
|
struct net_device **dev)
|
|
|
|
{
|
|
|
|
int ifidx = cb->args[0];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!ifidx)
|
|
|
|
ifidx = nl80211_get_ifidx(cb);
|
|
|
|
if (ifidx < 0)
|
|
|
|
return ifidx;
|
|
|
|
|
|
|
|
cb->args[0] = ifidx;
|
|
|
|
|
|
|
|
rtnl_lock();
|
|
|
|
|
|
|
|
*dev = __dev_get_by_index(sock_net(skb->sk), ifidx);
|
|
|
|
if (!*dev) {
|
|
|
|
err = -ENODEV;
|
|
|
|
goto out_rtnl;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rdev = cfg80211_get_dev_from_ifindex(sock_net(skb->sk), ifidx);
|
2010-10-31 21:31:54 +07:00
|
|
|
if (IS_ERR(*rdev)) {
|
|
|
|
err = PTR_ERR(*rdev);
|
2010-10-05 02:14:06 +07:00
|
|
|
goto out_rtnl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
out_rtnl:
|
|
|
|
rtnl_unlock();
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nl80211_finish_netdev_dump(struct cfg80211_registered_device *rdev)
|
|
|
|
{
|
|
|
|
cfg80211_unlock_rdev(rdev);
|
|
|
|
rtnl_unlock();
|
|
|
|
}
|
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
/* IE validation */
|
|
|
|
static bool is_valid_ie_attr(const struct nlattr *attr)
|
|
|
|
{
|
|
|
|
const u8 *pos;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!attr)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
pos = nla_data(attr);
|
|
|
|
len = nla_len(attr);
|
|
|
|
|
|
|
|
while (len) {
|
|
|
|
u8 elemlen;
|
|
|
|
|
|
|
|
if (len < 2)
|
|
|
|
return false;
|
|
|
|
len -= 2;
|
|
|
|
|
|
|
|
elemlen = pos[1];
|
|
|
|
if (elemlen > len)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
len -= elemlen;
|
|
|
|
pos += 2 + elemlen;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
/* message building helper */
|
2012-09-08 03:12:54 +07:00
|
|
|
static inline void *nl80211hdr_put(struct sk_buff *skb, u32 portid, u32 seq,
|
2007-09-21 00:09:35 +07:00
|
|
|
int flags, u8 cmd)
|
|
|
|
{
|
|
|
|
/* since there is no private header just add the generic one */
|
2012-09-08 03:12:54 +07:00
|
|
|
return genlmsg_put(skb, portid, seq, &nl80211_fam, flags, cmd);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2009-04-03 01:08:08 +07:00
|
|
|
static int nl80211_msg_put_channel(struct sk_buff *msg,
|
|
|
|
struct ieee80211_channel *chan)
|
|
|
|
{
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ,
|
|
|
|
chan->center_freq))
|
|
|
|
goto nla_put_failure;
|
2009-04-03 01:08:08 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((chan->flags & IEEE80211_CHAN_DISABLED) &&
|
|
|
|
nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DISABLED))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
|
|
|
|
nla_put_flag(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
|
|
|
|
nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((chan->flags & IEEE80211_CHAN_RADAR) &&
|
|
|
|
nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
|
|
|
|
goto nla_put_failure;
|
2009-04-03 01:08:08 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
|
|
|
|
DBM_TO_MBM(chan->max_power)))
|
|
|
|
goto nla_put_failure;
|
2009-04-03 01:08:08 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
/* netlink command implementations */
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
struct key_parse {
|
|
|
|
struct key_params p;
|
|
|
|
int idx;
|
2010-10-06 00:39:30 +07:00
|
|
|
int type;
|
2009-07-08 18:29:08 +07:00
|
|
|
bool def, defmgmt;
|
2010-12-10 01:58:59 +07:00
|
|
|
bool def_uni, def_multi;
|
2009-07-08 18:29:08 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int nl80211_parse_key_new(struct nlattr *key, struct key_parse *k)
|
|
|
|
{
|
|
|
|
struct nlattr *tb[NL80211_KEY_MAX + 1];
|
|
|
|
int err = nla_parse_nested(tb, NL80211_KEY_MAX, key,
|
|
|
|
nl80211_key_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
k->def = !!tb[NL80211_KEY_DEFAULT];
|
|
|
|
k->defmgmt = !!tb[NL80211_KEY_DEFAULT_MGMT];
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (k->def) {
|
|
|
|
k->def_uni = true;
|
|
|
|
k->def_multi = true;
|
|
|
|
}
|
|
|
|
if (k->defmgmt)
|
|
|
|
k->def_multi = true;
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
if (tb[NL80211_KEY_IDX])
|
|
|
|
k->idx = nla_get_u8(tb[NL80211_KEY_IDX]);
|
|
|
|
|
|
|
|
if (tb[NL80211_KEY_DATA]) {
|
|
|
|
k->p.key = nla_data(tb[NL80211_KEY_DATA]);
|
|
|
|
k->p.key_len = nla_len(tb[NL80211_KEY_DATA]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_KEY_SEQ]) {
|
|
|
|
k->p.seq = nla_data(tb[NL80211_KEY_SEQ]);
|
|
|
|
k->p.seq_len = nla_len(tb[NL80211_KEY_SEQ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_KEY_CIPHER])
|
|
|
|
k->p.cipher = nla_get_u32(tb[NL80211_KEY_CIPHER]);
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (tb[NL80211_KEY_TYPE]) {
|
|
|
|
k->type = nla_get_u32(tb[NL80211_KEY_TYPE]);
|
|
|
|
if (k->type < 0 || k->type >= NUM_NL80211_KEYTYPES)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (tb[NL80211_KEY_DEFAULT_TYPES]) {
|
|
|
|
struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
|
2012-01-20 19:52:37 +07:00
|
|
|
err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
|
|
|
|
tb[NL80211_KEY_DEFAULT_TYPES],
|
|
|
|
nl80211_key_default_policy);
|
2010-12-10 01:58:59 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
k->def_uni = kdt[NL80211_KEY_DEFAULT_TYPE_UNICAST];
|
|
|
|
k->def_multi = kdt[NL80211_KEY_DEFAULT_TYPE_MULTICAST];
|
|
|
|
}
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_parse_key_old(struct genl_info *info, struct key_parse *k)
|
|
|
|
{
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_DATA]) {
|
|
|
|
k->p.key = nla_data(info->attrs[NL80211_ATTR_KEY_DATA]);
|
|
|
|
k->p.key_len = nla_len(info->attrs[NL80211_ATTR_KEY_DATA]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_SEQ]) {
|
|
|
|
k->p.seq = nla_data(info->attrs[NL80211_ATTR_KEY_SEQ]);
|
|
|
|
k->p.seq_len = nla_len(info->attrs[NL80211_ATTR_KEY_SEQ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_IDX])
|
|
|
|
k->idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_CIPHER])
|
|
|
|
k->p.cipher = nla_get_u32(info->attrs[NL80211_ATTR_KEY_CIPHER]);
|
|
|
|
|
|
|
|
k->def = !!info->attrs[NL80211_ATTR_KEY_DEFAULT];
|
|
|
|
k->defmgmt = !!info->attrs[NL80211_ATTR_KEY_DEFAULT_MGMT];
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (k->def) {
|
|
|
|
k->def_uni = true;
|
|
|
|
k->def_multi = true;
|
|
|
|
}
|
|
|
|
if (k->defmgmt)
|
|
|
|
k->def_multi = true;
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
|
|
|
|
k->type = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
|
|
|
|
if (k->type < 0 || k->type >= NUM_NL80211_KEYTYPES)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES]) {
|
|
|
|
struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
|
|
|
|
int err = nla_parse_nested(
|
|
|
|
kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
|
|
|
|
info->attrs[NL80211_ATTR_KEY_DEFAULT_TYPES],
|
|
|
|
nl80211_key_default_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
k->def_uni = kdt[NL80211_KEY_DEFAULT_TYPE_UNICAST];
|
|
|
|
k->def_multi = kdt[NL80211_KEY_DEFAULT_TYPE_MULTICAST];
|
|
|
|
}
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_parse_key(struct genl_info *info, struct key_parse *k)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
memset(k, 0, sizeof(*k));
|
|
|
|
k->idx = -1;
|
2010-10-06 00:39:30 +07:00
|
|
|
k->type = -1;
|
2009-07-08 18:29:08 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY])
|
|
|
|
err = nl80211_parse_key_new(info->attrs[NL80211_ATTR_KEY], k);
|
|
|
|
else
|
|
|
|
err = nl80211_parse_key_old(info, k);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (k->def && k->defmgmt)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (k->defmgmt) {
|
|
|
|
if (k->def_uni || !k->def_multi)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
if (k->idx != -1) {
|
|
|
|
if (k->defmgmt) {
|
|
|
|
if (k->idx < 4 || k->idx > 5)
|
|
|
|
return -EINVAL;
|
|
|
|
} else if (k->def) {
|
|
|
|
if (k->idx < 0 || k->idx > 3)
|
|
|
|
return -EINVAL;
|
|
|
|
} else {
|
|
|
|
if (k->idx < 0 || k->idx > 5)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 19:22:54 +07:00
|
|
|
static struct cfg80211_cached_keys *
|
|
|
|
nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
|
|
|
|
struct nlattr *keys)
|
|
|
|
{
|
|
|
|
struct key_parse parse;
|
|
|
|
struct nlattr *key;
|
|
|
|
struct cfg80211_cached_keys *result;
|
|
|
|
int rem, err, def = 0;
|
|
|
|
|
|
|
|
result = kzalloc(sizeof(*result), GFP_KERNEL);
|
|
|
|
if (!result)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
result->def = -1;
|
|
|
|
result->defmgmt = -1;
|
|
|
|
|
|
|
|
nla_for_each_nested(key, keys, rem) {
|
|
|
|
memset(&parse, 0, sizeof(parse));
|
|
|
|
parse.idx = -1;
|
|
|
|
|
|
|
|
err = nl80211_parse_key_new(key, &parse);
|
|
|
|
if (err)
|
|
|
|
goto error;
|
|
|
|
err = -EINVAL;
|
|
|
|
if (!parse.p.key)
|
|
|
|
goto error;
|
|
|
|
if (parse.idx < 0 || parse.idx > 4)
|
|
|
|
goto error;
|
|
|
|
if (parse.def) {
|
|
|
|
if (def)
|
|
|
|
goto error;
|
|
|
|
def = 1;
|
|
|
|
result->def = parse.idx;
|
2010-12-10 01:58:59 +07:00
|
|
|
if (!parse.def_uni || !parse.def_multi)
|
|
|
|
goto error;
|
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 19:22:54 +07:00
|
|
|
} else if (parse.defmgmt)
|
|
|
|
goto error;
|
|
|
|
err = cfg80211_validate_key_settings(rdev, &parse.p,
|
2010-10-06 00:39:30 +07:00
|
|
|
parse.idx, false, NULL);
|
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 19:22:54 +07:00
|
|
|
if (err)
|
|
|
|
goto error;
|
|
|
|
result->params[parse.idx].cipher = parse.p.cipher;
|
|
|
|
result->params[parse.idx].key_len = parse.p.key_len;
|
|
|
|
result->params[parse.idx].key = result->data[parse.idx];
|
|
|
|
memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
error:
|
|
|
|
kfree(result);
|
|
|
|
return ERR_PTR(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_key_allowed(struct wireless_dev *wdev)
|
|
|
|
{
|
|
|
|
ASSERT_WDEV_LOCK(wdev);
|
|
|
|
|
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
2010-09-16 19:58:22 +07:00
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
2011-05-04 06:57:12 +07:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
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 19:22:54 +07:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
if (!wdev->current_bss)
|
|
|
|
return -ENOLINK;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
2010-09-16 19:58:22 +07:00
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
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 19:22:54 +07:00
|
|
|
if (wdev->sme_state != CFG80211_SME_CONNECTED)
|
|
|
|
return -ENOLINK;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:58:57 +07:00
|
|
|
static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes)
|
|
|
|
{
|
|
|
|
struct nlattr *nl_modes = nla_nest_start(msg, attr);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!nl_modes)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (ifmodes) {
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((ifmodes & 1) && nla_put_flag(msg, i))
|
|
|
|
goto nla_put_failure;
|
2011-05-13 15:58:57 +07:00
|
|
|
ifmodes >>= 1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_modes);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_put_iface_combinations(struct wiphy *wiphy,
|
|
|
|
struct sk_buff *msg)
|
|
|
|
{
|
|
|
|
struct nlattr *nl_combis;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
nl_combis = nla_nest_start(msg,
|
|
|
|
NL80211_ATTR_INTERFACE_COMBINATIONS);
|
|
|
|
if (!nl_combis)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (i = 0; i < wiphy->n_iface_combinations; i++) {
|
|
|
|
const struct ieee80211_iface_combination *c;
|
|
|
|
struct nlattr *nl_combi, *nl_limits;
|
|
|
|
|
|
|
|
c = &wiphy->iface_combinations[i];
|
|
|
|
|
|
|
|
nl_combi = nla_nest_start(msg, i + 1);
|
|
|
|
if (!nl_combi)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
nl_limits = nla_nest_start(msg, NL80211_IFACE_COMB_LIMITS);
|
|
|
|
if (!nl_limits)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (j = 0; j < c->n_limits; j++) {
|
|
|
|
struct nlattr *nl_limit;
|
|
|
|
|
|
|
|
nl_limit = nla_nest_start(msg, j + 1);
|
|
|
|
if (!nl_limit)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX,
|
|
|
|
c->limits[j].max))
|
|
|
|
goto nla_put_failure;
|
2011-05-13 15:58:57 +07:00
|
|
|
if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES,
|
|
|
|
c->limits[j].types))
|
|
|
|
goto nla_put_failure;
|
|
|
|
nla_nest_end(msg, nl_limit);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_limits);
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (c->beacon_int_infra_match &&
|
|
|
|
nla_put_flag(msg, NL80211_IFACE_COMB_STA_AP_BI_MATCH))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (nla_put_u32(msg, NL80211_IFACE_COMB_NUM_CHANNELS,
|
|
|
|
c->num_different_channels) ||
|
|
|
|
nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
|
|
|
|
c->max_interfaces))
|
|
|
|
goto nla_put_failure;
|
2011-05-13 15:58:57 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, nl_combi);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_combis);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
nla_put_failure:
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flags,
|
2007-09-21 00:09:35 +07:00
|
|
|
struct cfg80211_registered_device *dev)
|
|
|
|
{
|
|
|
|
void *hdr;
|
2008-01-25 01:38:39 +07:00
|
|
|
struct nlattr *nl_bands, *nl_band;
|
|
|
|
struct nlattr *nl_freqs, *nl_freq;
|
|
|
|
struct nlattr *nl_rates, *nl_rate;
|
2009-03-14 15:34:01 +07:00
|
|
|
struct nlattr *nl_cmds;
|
2008-01-25 01:38:39 +07:00
|
|
|
enum ieee80211_band band;
|
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
struct ieee80211_rate *rate;
|
|
|
|
int i;
|
2010-08-12 20:38:38 +07:00
|
|
|
const struct ieee80211_txrx_stypes *mgmt_stypes =
|
|
|
|
dev->wiphy.mgmt_stypes;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_WIPHY);
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx) ||
|
|
|
|
nla_put_string(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_GENERATION,
|
|
|
|
cfg80211_rdev_list_generation) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_SHORT,
|
|
|
|
dev->wiphy.retry_short) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_WIPHY_RETRY_LONG,
|
|
|
|
dev->wiphy.retry_long) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_FRAG_THRESHOLD,
|
|
|
|
dev->wiphy.frag_threshold) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD,
|
|
|
|
dev->wiphy.rts_threshold) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_WIPHY_COVERAGE_CLASS,
|
|
|
|
dev->wiphy.coverage_class) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
|
|
|
|
dev->wiphy.max_scan_ssids) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS,
|
|
|
|
dev->wiphy.max_sched_scan_ssids) ||
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN,
|
|
|
|
dev->wiphy.max_scan_ie_len) ||
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN,
|
|
|
|
dev->wiphy.max_sched_scan_ie_len) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS,
|
|
|
|
dev->wiphy.max_match_sets))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_SUPPORT_IBSS_RSN))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_MESH_AUTH) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_SUPPORT_MESH_AUTH))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_SUPPORT_AP_UAPSD))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_ROAM_SUPPORT))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_TDLS_SUPPORT))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES,
|
|
|
|
sizeof(u32) * dev->wiphy.n_cipher_suites,
|
|
|
|
dev->wiphy.cipher_suites))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_MAX_NUM_PMKIDS,
|
|
|
|
dev->wiphy.max_num_pmkids))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_CONTROL_PORT_ETHERTYPE))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX,
|
|
|
|
dev->wiphy.available_antennas_tx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX,
|
|
|
|
dev->wiphy.available_antennas_rx))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD,
|
|
|
|
dev->wiphy.probe_resp_offload))
|
|
|
|
goto nla_put_failure;
|
2011-11-10 16:28:55 +07:00
|
|
|
|
2010-12-16 09:30:22 +07:00
|
|
|
if ((dev->wiphy.available_antennas_tx ||
|
|
|
|
dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) {
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
u32 tx_ant = 0, rx_ant = 0;
|
|
|
|
int res;
|
|
|
|
res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant);
|
|
|
|
if (!res) {
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX,
|
|
|
|
tx_ant) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_RX,
|
|
|
|
rx_ant))
|
|
|
|
goto nla_put_failure;
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-13 15:58:57 +07:00
|
|
|
if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
|
|
|
|
dev->wiphy.interface_modes))
|
2008-08-30 06:26:43 +07:00
|
|
|
goto nla_put_failure;
|
|
|
|
|
2008-01-25 01:38:39 +07:00
|
|
|
nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS);
|
|
|
|
if (!nl_bands)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
|
|
|
|
if (!dev->wiphy.bands[band])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nl_band = nla_nest_start(msg, band);
|
|
|
|
if (!nl_band)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2008-10-09 17:20:13 +07:00
|
|
|
/* add HT info */
|
2012-03-29 15:41:26 +07:00
|
|
|
if (dev->wiphy.bands[band]->ht_cap.ht_supported &&
|
|
|
|
(nla_put(msg, NL80211_BAND_ATTR_HT_MCS_SET,
|
|
|
|
sizeof(dev->wiphy.bands[band]->ht_cap.mcs),
|
|
|
|
&dev->wiphy.bands[band]->ht_cap.mcs) ||
|
|
|
|
nla_put_u16(msg, NL80211_BAND_ATTR_HT_CAPA,
|
|
|
|
dev->wiphy.bands[band]->ht_cap.cap) ||
|
|
|
|
nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_FACTOR,
|
|
|
|
dev->wiphy.bands[band]->ht_cap.ampdu_factor) ||
|
|
|
|
nla_put_u8(msg, NL80211_BAND_ATTR_HT_AMPDU_DENSITY,
|
|
|
|
dev->wiphy.bands[band]->ht_cap.ampdu_density)))
|
|
|
|
goto nla_put_failure;
|
2008-10-09 17:20:13 +07:00
|
|
|
|
2012-06-22 14:27:46 +07:00
|
|
|
/* add VHT info */
|
|
|
|
if (dev->wiphy.bands[band]->vht_cap.vht_supported &&
|
|
|
|
(nla_put(msg, NL80211_BAND_ATTR_VHT_MCS_SET,
|
|
|
|
sizeof(dev->wiphy.bands[band]->vht_cap.vht_mcs),
|
|
|
|
&dev->wiphy.bands[band]->vht_cap.vht_mcs) ||
|
|
|
|
nla_put_u32(msg, NL80211_BAND_ATTR_VHT_CAPA,
|
|
|
|
dev->wiphy.bands[band]->vht_cap.cap)))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2008-01-25 01:38:39 +07:00
|
|
|
/* add frequencies */
|
|
|
|
nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS);
|
|
|
|
if (!nl_freqs)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) {
|
|
|
|
nl_freq = nla_nest_start(msg, i);
|
|
|
|
if (!nl_freq)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
chan = &dev->wiphy.bands[band]->channels[i];
|
2009-04-03 01:08:08 +07:00
|
|
|
|
|
|
|
if (nl80211_msg_put_channel(msg, chan))
|
|
|
|
goto nla_put_failure;
|
2008-11-22 00:01:30 +07:00
|
|
|
|
2008-01-25 01:38:39 +07:00
|
|
|
nla_nest_end(msg, nl_freq);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_freqs);
|
|
|
|
|
|
|
|
/* add bitrates */
|
|
|
|
nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES);
|
|
|
|
if (!nl_rates)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (i = 0; i < dev->wiphy.bands[band]->n_bitrates; i++) {
|
|
|
|
nl_rate = nla_nest_start(msg, i);
|
|
|
|
if (!nl_rate)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
rate = &dev->wiphy.bands[band]->bitrates[i];
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_BITRATE_ATTR_RATE,
|
|
|
|
rate->bitrate))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((rate->flags & IEEE80211_RATE_SHORT_PREAMBLE) &&
|
|
|
|
nla_put_flag(msg,
|
|
|
|
NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE))
|
|
|
|
goto nla_put_failure;
|
2008-01-25 01:38:39 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, nl_rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_rates);
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_band);
|
|
|
|
}
|
|
|
|
nla_nest_end(msg, nl_bands);
|
|
|
|
|
2009-03-14 15:34:01 +07:00
|
|
|
nl_cmds = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_COMMANDS);
|
|
|
|
if (!nl_cmds)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
#define CMD(op, n) \
|
|
|
|
do { \
|
|
|
|
if (dev->ops->op) { \
|
|
|
|
i++; \
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \
|
|
|
|
goto nla_put_failure; \
|
2009-03-14 15:34:01 +07:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
CMD(add_virtual_intf, NEW_INTERFACE);
|
|
|
|
CMD(change_virtual_intf, SET_INTERFACE);
|
|
|
|
CMD(add_key, NEW_KEY);
|
2012-02-13 21:17:18 +07:00
|
|
|
CMD(start_ap, START_AP);
|
2009-03-14 15:34:01 +07:00
|
|
|
CMD(add_station, NEW_STATION);
|
|
|
|
CMD(add_mpath, NEW_MPATH);
|
2010-12-17 08:37:48 +07:00
|
|
|
CMD(update_mesh_config, SET_MESH_CONFIG);
|
2009-03-14 15:34:01 +07:00
|
|
|
CMD(change_bss, SET_BSS);
|
2009-03-19 18:39:22 +07:00
|
|
|
CMD(auth, AUTHENTICATE);
|
|
|
|
CMD(assoc, ASSOCIATE);
|
|
|
|
CMD(deauth, DEAUTHENTICATE);
|
|
|
|
CMD(disassoc, DISASSOCIATE);
|
2009-04-20 02:24:32 +07:00
|
|
|
CMD(join_ibss, JOIN_IBSS);
|
2010-12-03 15:20:44 +07:00
|
|
|
CMD(join_mesh, JOIN_MESH);
|
2009-11-25 05:59:15 +07:00
|
|
|
CMD(set_pmksa, SET_PMKSA);
|
|
|
|
CMD(del_pmksa, DEL_PMKSA);
|
|
|
|
CMD(flush_pmksa, FLUSH_PMKSA);
|
2011-11-18 21:33:48 +07:00
|
|
|
if (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)
|
|
|
|
CMD(remain_on_channel, REMAIN_ON_CHANNEL);
|
2009-12-29 17:59:45 +07:00
|
|
|
CMD(set_bitrate_mask, SET_TX_BITRATE_MASK);
|
2010-08-12 20:38:38 +07:00
|
|
|
CMD(mgmt_tx, FRAME);
|
2010-11-25 16:02:29 +07:00
|
|
|
CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL);
|
2009-11-19 06:56:28 +07:00
|
|
|
if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) {
|
2009-07-14 05:33:35 +07:00
|
|
|
i++;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_SET_WIPHY_NETNS))
|
|
|
|
goto nla_put_failure;
|
2009-07-14 05:33:35 +07:00
|
|
|
}
|
2012-06-06 13:18:22 +07:00
|
|
|
if (dev->ops->set_monitor_channel || dev->ops->start_ap ||
|
2012-05-17 04:50:20 +07:00
|
|
|
dev->ops->join_mesh) {
|
2012-05-17 04:50:18 +07:00
|
|
|
i++;
|
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_SET_CHANNEL))
|
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
2010-10-02 00:54:28 +07:00
|
|
|
CMD(set_wds_peer, SET_WDS_PEER);
|
2011-09-28 18:12:50 +07:00
|
|
|
if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) {
|
|
|
|
CMD(tdls_mgmt, TDLS_MGMT);
|
|
|
|
CMD(tdls_oper, TDLS_OPER);
|
|
|
|
}
|
2011-05-11 21:09:35 +07:00
|
|
|
if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN)
|
|
|
|
CMD(sched_scan_start, START_SCHED_SCAN);
|
2011-11-04 17:18:15 +07:00
|
|
|
CMD(probe_client, PROBE_CLIENT);
|
2011-11-18 20:20:43 +07:00
|
|
|
CMD(set_noack_map, SET_NOACK_MAP);
|
2011-11-04 17:18:17 +07:00
|
|
|
if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) {
|
|
|
|
i++;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_REGISTER_BEACONS))
|
|
|
|
goto nla_put_failure;
|
2011-11-04 17:18:17 +07:00
|
|
|
}
|
2012-06-16 05:19:54 +07:00
|
|
|
CMD(start_p2p_device, START_P2P_DEVICE);
|
2009-03-14 15:34:01 +07:00
|
|
|
|
2011-11-18 00:06:10 +07:00
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
CMD(testmode_cmd, TESTMODE);
|
|
|
|
#endif
|
|
|
|
|
2009-03-14 15:34:01 +07:00
|
|
|
#undef CMD
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2009-07-02 14:13:27 +07:00
|
|
|
if (dev->ops->connect || dev->ops->auth) {
|
2009-07-02 02:26:54 +07:00
|
|
|
i++;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_CONNECT))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:54 +07:00
|
|
|
}
|
|
|
|
|
2009-07-02 14:13:27 +07:00
|
|
|
if (dev->ops->disconnect || dev->ops->deauth) {
|
2009-07-02 02:26:54 +07:00
|
|
|
i++;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, i, NL80211_CMD_DISCONNECT))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:54 +07:00
|
|
|
}
|
|
|
|
|
2009-03-14 15:34:01 +07:00
|
|
|
nla_nest_end(msg, nl_cmds);
|
|
|
|
|
2011-11-18 21:33:48 +07:00
|
|
|
if (dev->ops->remain_on_channel &&
|
2012-03-29 15:41:26 +07:00
|
|
|
(dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION,
|
|
|
|
dev->wiphy.max_remain_on_channel_duration))
|
|
|
|
goto nla_put_failure;
|
2010-12-14 23:54:28 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK))
|
|
|
|
goto nla_put_failure;
|
2010-11-25 16:02:29 +07:00
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
if (mgmt_stypes) {
|
|
|
|
u16 stypes;
|
|
|
|
struct nlattr *nl_ftypes, *nl_ifs;
|
|
|
|
enum nl80211_iftype ift;
|
|
|
|
|
|
|
|
nl_ifs = nla_nest_start(msg, NL80211_ATTR_TX_FRAME_TYPES);
|
|
|
|
if (!nl_ifs)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) {
|
|
|
|
nl_ftypes = nla_nest_start(msg, ift);
|
|
|
|
if (!nl_ftypes)
|
|
|
|
goto nla_put_failure;
|
|
|
|
i = 0;
|
|
|
|
stypes = mgmt_stypes[ift].tx;
|
|
|
|
while (stypes) {
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((stypes & 1) &&
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE,
|
|
|
|
(i << 4) | IEEE80211_FTYPE_MGMT))
|
|
|
|
goto nla_put_failure;
|
2010-08-12 20:38:38 +07:00
|
|
|
stypes >>= 1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
nla_nest_end(msg, nl_ftypes);
|
|
|
|
}
|
|
|
|
|
2010-08-24 17:15:53 +07:00
|
|
|
nla_nest_end(msg, nl_ifs);
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
nl_ifs = nla_nest_start(msg, NL80211_ATTR_RX_FRAME_TYPES);
|
|
|
|
if (!nl_ifs)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (ift = 0; ift < NUM_NL80211_IFTYPES; ift++) {
|
|
|
|
nl_ftypes = nla_nest_start(msg, ift);
|
|
|
|
if (!nl_ftypes)
|
|
|
|
goto nla_put_failure;
|
|
|
|
i = 0;
|
|
|
|
stypes = mgmt_stypes[ift].rx;
|
|
|
|
while (stypes) {
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((stypes & 1) &&
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_FRAME_TYPE,
|
|
|
|
(i << 4) | IEEE80211_FTYPE_MGMT))
|
|
|
|
goto nla_put_failure;
|
2010-08-12 20:38:38 +07:00
|
|
|
stypes >>= 1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
nla_nest_end(msg, nl_ftypes);
|
|
|
|
}
|
|
|
|
nla_nest_end(msg, nl_ifs);
|
|
|
|
}
|
|
|
|
|
2012-06-27 14:23:48 +07:00
|
|
|
#ifdef CONFIG_PM
|
2011-05-04 20:37:28 +07:00
|
|
|
if (dev->wiphy.wowlan.flags || dev->wiphy.wowlan.n_patterns) {
|
|
|
|
struct nlattr *nl_wowlan;
|
|
|
|
|
|
|
|
nl_wowlan = nla_nest_start(msg,
|
|
|
|
NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED);
|
|
|
|
if (!nl_wowlan)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_ANY) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_DISCONNECT) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_MAGIC_PKT) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_4WAY_HANDSHAKE) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) ||
|
|
|
|
((dev->wiphy.wowlan.flags & WIPHY_WOWLAN_RFKILL_RELEASE) &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE)))
|
|
|
|
goto nla_put_failure;
|
2011-05-04 20:37:28 +07:00
|
|
|
if (dev->wiphy.wowlan.n_patterns) {
|
|
|
|
struct nl80211_wowlan_pattern_support pat = {
|
|
|
|
.max_patterns = dev->wiphy.wowlan.n_patterns,
|
|
|
|
.min_pattern_len =
|
|
|
|
dev->wiphy.wowlan.pattern_min_len,
|
|
|
|
.max_pattern_len =
|
|
|
|
dev->wiphy.wowlan.pattern_max_len,
|
|
|
|
};
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put(msg, NL80211_WOWLAN_TRIG_PKT_PATTERN,
|
|
|
|
sizeof(pat), &pat))
|
|
|
|
goto nla_put_failure;
|
2011-05-04 20:37:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_wowlan);
|
|
|
|
}
|
2012-06-27 14:23:48 +07:00
|
|
|
#endif
|
2011-05-04 20:37:28 +07:00
|
|
|
|
2011-05-13 15:58:57 +07:00
|
|
|
if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES,
|
|
|
|
dev->wiphy.software_iftypes))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nl80211_put_iface_combinations(&dev->wiphy, msg))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME,
|
|
|
|
dev->wiphy.ap_sme_capa))
|
|
|
|
goto nla_put_failure;
|
2011-11-07 18:39:33 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_FEATURE_FLAGS,
|
|
|
|
dev->wiphy.features))
|
|
|
|
goto nla_put_failure;
|
2011-11-06 20:13:33 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (dev->wiphy.ht_capa_mod_mask &&
|
|
|
|
nla_put(msg, NL80211_ATTR_HT_CAPABILITY_MASK,
|
|
|
|
sizeof(*dev->wiphy.ht_capa_mod_mask),
|
|
|
|
dev->wiphy.ht_capa_mod_mask))
|
|
|
|
goto nla_put_failure;
|
2011-11-19 02:31:59 +07:00
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
2008-06-04 06:36:54 +07:00
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
int start = cb->args[0];
|
|
|
|
struct cfg80211_registered_device *dev;
|
|
|
|
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
2009-07-07 08:56:12 +07:00
|
|
|
list_for_each_entry(dev, &cfg80211_rdev_list, list) {
|
2009-07-14 05:33:35 +07:00
|
|
|
if (!net_eq(wiphy_net(&dev->wiphy), sock_net(skb->sk)))
|
|
|
|
continue;
|
net/wireless/nl80211.c: fix endless Netlink callback loop.
Although I only tested similar code (I don't use any of this wireless
code), the state maintainance between Netlink dump callback invocations
seems wrong here and should lead to an endless loop. There are also other
examples in the same file which might have the same problem. Perhaps someone
can actually test this (or refute my logic).
Take the simple example with only one element in the list (which should fit
into the message):
1. invocation:
Start:
idx = 0, start = 0
Loop:
condition (++idx < start) => (1 < 0) => false
=> no continue, fill one entry, exit loop, return skb->len > 0
2. invocation:
Start:
idx = 0, start = 1
Loop:
condition (++idx < start) => (1 < 1) => false
=> no continue, fill the same entry again, exit loop, return skb->len > 0
3. invocation:
Same as 2. invocation, endless invocation of callback.
Also, iterations where the filling of an element fails should not be counted as
completed, so idx should not be incremented in this case.
Signed-off-by: Julius Volz <juliusv@google.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-08 19:02:19 +07:00
|
|
|
if (++idx <= start)
|
2007-09-21 00:09:35 +07:00
|
|
|
continue;
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).portid,
|
2007-09-21 00:09:35 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
net/wireless/nl80211.c: fix endless Netlink callback loop.
Although I only tested similar code (I don't use any of this wireless
code), the state maintainance between Netlink dump callback invocations
seems wrong here and should lead to an endless loop. There are also other
examples in the same file which might have the same problem. Perhaps someone
can actually test this (or refute my logic).
Take the simple example with only one element in the list (which should fit
into the message):
1. invocation:
Start:
idx = 0, start = 0
Loop:
condition (++idx < start) => (1 < 0) => false
=> no continue, fill one entry, exit loop, return skb->len > 0
2. invocation:
Start:
idx = 0, start = 1
Loop:
condition (++idx < start) => (1 < 1) => false
=> no continue, fill the same entry again, exit loop, return skb->len > 0
3. invocation:
Same as 2. invocation, endless invocation of callback.
Also, iterations where the filling of an element fails should not be counted as
completed, so idx should not be incremented in this case.
Signed-off-by: Julius Volz <juliusv@google.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-08 19:02:19 +07:00
|
|
|
dev) < 0) {
|
|
|
|
idx--;
|
2007-09-21 00:09:35 +07:00
|
|
|
break;
|
net/wireless/nl80211.c: fix endless Netlink callback loop.
Although I only tested similar code (I don't use any of this wireless
code), the state maintainance between Netlink dump callback invocations
seems wrong here and should lead to an endless loop. There are also other
examples in the same file which might have the same problem. Perhaps someone
can actually test this (or refute my logic).
Take the simple example with only one element in the list (which should fit
into the message):
1. invocation:
Start:
idx = 0, start = 0
Loop:
condition (++idx < start) => (1 < 0) => false
=> no continue, fill one entry, exit loop, return skb->len > 0
2. invocation:
Start:
idx = 0, start = 1
Loop:
condition (++idx < start) => (1 < 1) => false
=> no continue, fill the same entry again, exit loop, return skb->len > 0
3. invocation:
Same as 2. invocation, endless invocation of callback.
Also, iterations where the filling of an element fails should not be counted as
completed, so idx should not be incremented in this case.
Signed-off-by: Julius Volz <juliusv@google.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-08 19:02:19 +07:00
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2007-09-21 00:09:35 +07:00
|
|
|
|
|
|
|
cb->args[0] = idx;
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *dev = info->user_ptr[0];
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!msg)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -ENOMEM;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_wiphy(msg, info->snd_portid, info->snd_seq, 0, dev) < 0) {
|
2010-10-05 02:36:35 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-07-10 16:51:34 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2008-10-30 21:59:24 +07:00
|
|
|
static const struct nla_policy txq_params_policy[NL80211_TXQ_ATTR_MAX + 1] = {
|
|
|
|
[NL80211_TXQ_ATTR_QUEUE] = { .type = NLA_U8 },
|
|
|
|
[NL80211_TXQ_ATTR_TXOP] = { .type = NLA_U16 },
|
|
|
|
[NL80211_TXQ_ATTR_CWMIN] = { .type = NLA_U16 },
|
|
|
|
[NL80211_TXQ_ATTR_CWMAX] = { .type = NLA_U16 },
|
|
|
|
[NL80211_TXQ_ATTR_AIFS] = { .type = NLA_U8 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int parse_txq_params(struct nlattr *tb[],
|
|
|
|
struct ieee80211_txq_params *txq_params)
|
|
|
|
{
|
2012-03-28 16:04:24 +07:00
|
|
|
if (!tb[NL80211_TXQ_ATTR_AC] || !tb[NL80211_TXQ_ATTR_TXOP] ||
|
2008-10-30 21:59:24 +07:00
|
|
|
!tb[NL80211_TXQ_ATTR_CWMIN] || !tb[NL80211_TXQ_ATTR_CWMAX] ||
|
|
|
|
!tb[NL80211_TXQ_ATTR_AIFS])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-03-28 16:04:24 +07:00
|
|
|
txq_params->ac = nla_get_u8(tb[NL80211_TXQ_ATTR_AC]);
|
2008-10-30 21:59:24 +07:00
|
|
|
txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]);
|
|
|
|
txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]);
|
|
|
|
txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]);
|
|
|
|
txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]);
|
|
|
|
|
2012-03-28 16:04:24 +07:00
|
|
|
if (txq_params->ac >= NL80211_NUM_ACS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2008-10-30 21:59:24 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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 20:25:02 +07:00
|
|
|
static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
|
|
|
|
{
|
|
|
|
/*
|
2012-05-17 04:50:20 +07:00
|
|
|
* You can only set the channel explicitly for WDS interfaces,
|
|
|
|
* all others have their channel managed via their respective
|
|
|
|
* "establish a connection" command (connect, join, ...)
|
|
|
|
*
|
|
|
|
* For AP/GO and mesh mode, the channel can be set with the
|
|
|
|
* channel userspace API, but is only stored and passed to the
|
|
|
|
* low-level driver when the AP starts or the mesh is joined.
|
|
|
|
* This is for backward compatibility, userspace can also give
|
|
|
|
* the channel in the start-ap or join-mesh commands instead.
|
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 20:25:02 +07:00
|
|
|
*
|
|
|
|
* Monitors are special as they are normally slaved to
|
2012-06-06 13:18:22 +07:00
|
|
|
* whatever else is going on, so they have their own special
|
|
|
|
* operation to set the monitor channel if possible.
|
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 20:25:02 +07:00
|
|
|
*/
|
|
|
|
return !wdev ||
|
|
|
|
wdev->iftype == NL80211_IFTYPE_AP ||
|
|
|
|
wdev->iftype == NL80211_IFTYPE_MESH_POINT ||
|
2010-09-16 19:58:22 +07:00
|
|
|
wdev->iftype == NL80211_IFTYPE_MONITOR ||
|
|
|
|
wdev->iftype == NL80211_IFTYPE_P2P_GO;
|
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 20:25:02 +07:00
|
|
|
}
|
|
|
|
|
2012-05-11 02:27:18 +07:00
|
|
|
static bool nl80211_valid_channel_type(struct genl_info *info,
|
|
|
|
enum nl80211_channel_type *channel_type)
|
|
|
|
{
|
|
|
|
enum nl80211_channel_type tmp;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
tmp = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
|
|
|
|
if (tmp != NL80211_CHAN_NO_HT &&
|
|
|
|
tmp != NL80211_CHAN_HT20 &&
|
|
|
|
tmp != NL80211_CHAN_HT40PLUS &&
|
|
|
|
tmp != NL80211_CHAN_HT40MINUS)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (channel_type)
|
|
|
|
*channel_type = tmp;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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 20:25:02 +07:00
|
|
|
static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
|
|
|
|
struct wireless_dev *wdev,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
2012-05-17 04:50:18 +07:00
|
|
|
struct ieee80211_channel *channel;
|
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 20:25:02 +07:00
|
|
|
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
u32 freq;
|
|
|
|
int result;
|
2012-06-06 13:18:22 +07:00
|
|
|
enum nl80211_iftype iftype = NL80211_IFTYPE_MONITOR;
|
|
|
|
|
|
|
|
if (wdev)
|
|
|
|
iftype = wdev->iftype;
|
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 20:25:02 +07:00
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_FREQ])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!nl80211_can_set_dev_channel(wdev))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-05-11 02:27:18 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
|
|
|
|
!nl80211_valid_channel_type(info, &channel_type))
|
|
|
|
return -EINVAL;
|
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 20:25:02 +07:00
|
|
|
|
|
|
|
freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
2012-06-06 13:18:22 +07:00
|
|
|
switch (iftype) {
|
2012-05-17 04:50:18 +07:00
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
|
|
|
if (wdev->beacon_interval) {
|
|
|
|
result = -EBUSY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
channel = rdev_freq_to_chan(rdev, freq, channel_type);
|
|
|
|
if (!channel || !cfg80211_can_beacon_sec_chan(&rdev->wiphy,
|
|
|
|
channel,
|
|
|
|
channel_type)) {
|
|
|
|
result = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wdev->preset_chan = channel;
|
|
|
|
wdev->preset_chantype = channel_type;
|
|
|
|
result = 0;
|
|
|
|
break;
|
2012-05-17 04:50:20 +07:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
result = cfg80211_set_mesh_freq(rdev, wdev, freq, channel_type);
|
|
|
|
break;
|
2012-06-06 13:18:22 +07:00
|
|
|
case NL80211_IFTYPE_MONITOR:
|
|
|
|
result = cfg80211_set_monitor_channel(rdev, freq, channel_type);
|
|
|
|
break;
|
2012-05-17 04:50:18 +07:00
|
|
|
default:
|
2012-06-06 13:18:22 +07:00
|
|
|
result = -EINVAL;
|
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 20:25:02 +07:00
|
|
|
}
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_channel(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *netdev = info->user_ptr[1];
|
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 20:25:02 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return __nl80211_set_channel(rdev, netdev->ieee80211_ptr, info);
|
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 20:25:02 +07:00
|
|
|
}
|
|
|
|
|
2010-10-02 00:54:28 +07:00
|
|
|
static int nl80211_set_wds_peer(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-07 18:10:30 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2010-10-07 18:11:09 +07:00
|
|
|
const u8 *bssid;
|
2010-10-02 00:54:28 +07:00
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-07 18:10:30 +07:00
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
2010-10-02 00:54:28 +07:00
|
|
|
|
2010-10-07 18:10:30 +07:00
|
|
|
if (!rdev->ops->set_wds_peer)
|
|
|
|
return -EOPNOTSUPP;
|
2010-10-02 00:54:28 +07:00
|
|
|
|
2010-10-07 18:10:30 +07:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_WDS)
|
|
|
|
return -EOPNOTSUPP;
|
2010-10-02 00:54:28 +07:00
|
|
|
|
|
|
|
bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2010-10-07 18:10:30 +07:00
|
|
|
return rdev->ops->set_wds_peer(wdev->wiphy, dev, bssid);
|
2010-10-02 00:54:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev;
|
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 20:25:02 +07:00
|
|
|
struct net_device *netdev = NULL;
|
|
|
|
struct wireless_dev *wdev;
|
2010-09-10 22:22:32 +07:00
|
|
|
int result = 0, rem_txq_params = 0;
|
2008-10-30 21:59:24 +07:00
|
|
|
struct nlattr *nl_txq_params;
|
2009-04-20 23:39:05 +07:00
|
|
|
u32 changed;
|
|
|
|
u8 retry_short = 0, retry_long = 0;
|
|
|
|
u32 frag_threshold = 0, rts_threshold = 0;
|
2009-12-22 04:50:47 +07:00
|
|
|
u8 coverage_class = 0;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
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 20:25:02 +07:00
|
|
|
/*
|
|
|
|
* Try to find the wiphy and netdev. Normally this
|
|
|
|
* function shouldn't need the netdev, but this is
|
|
|
|
* done for backward compatibility -- previously
|
|
|
|
* setting the channel was done per wiphy, but now
|
|
|
|
* it is per netdev. Previous userland like hostapd
|
|
|
|
* also passed a netdev to set_wiphy, so that it is
|
|
|
|
* possible to let that go to the right netdev!
|
|
|
|
*/
|
2009-03-24 15:35:46 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
|
|
|
|
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 20:25:02 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IFINDEX]) {
|
|
|
|
int ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]);
|
|
|
|
|
|
|
|
netdev = dev_get_by_index(genl_info_net(info), ifindex);
|
|
|
|
if (netdev && netdev->ieee80211_ptr) {
|
|
|
|
rdev = wiphy_to_dev(netdev->ieee80211_ptr->wiphy);
|
|
|
|
mutex_lock(&rdev->mtx);
|
|
|
|
} else
|
|
|
|
netdev = NULL;
|
2009-03-24 15:35:46 +07:00
|
|
|
}
|
|
|
|
|
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 20:25:02 +07:00
|
|
|
if (!netdev) {
|
2012-06-15 19:18:32 +07:00
|
|
|
rdev = __cfg80211_rdev_from_attrs(genl_info_net(info),
|
|
|
|
info->attrs);
|
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 20:25:02 +07:00
|
|
|
if (IS_ERR(rdev)) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2010-10-05 02:36:35 +07:00
|
|
|
return PTR_ERR(rdev);
|
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 20:25:02 +07:00
|
|
|
}
|
|
|
|
wdev = NULL;
|
|
|
|
netdev = NULL;
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
mutex_lock(&rdev->mtx);
|
2012-05-17 04:50:20 +07:00
|
|
|
} else if (nl80211_can_set_dev_channel(netdev->ieee80211_ptr))
|
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 20:25:02 +07:00
|
|
|
wdev = netdev->ieee80211_ptr;
|
|
|
|
else
|
|
|
|
wdev = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* end workaround code, by now the rdev is available
|
|
|
|
* and locked, and wdev may or may not be NULL.
|
|
|
|
*/
|
2009-03-24 15:35:46 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_NAME])
|
2008-10-30 21:59:24 +07:00
|
|
|
result = cfg80211_dev_rename(
|
|
|
|
rdev, nla_data(info->attrs[NL80211_ATTR_WIPHY_NAME]));
|
2009-03-24 15:35:46 +07:00
|
|
|
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
2008-10-30 21:59:24 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS]) {
|
|
|
|
struct ieee80211_txq_params txq_params;
|
|
|
|
struct nlattr *tb[NL80211_TXQ_ATTR_MAX + 1];
|
|
|
|
|
|
|
|
if (!rdev->ops->set_txq_params) {
|
|
|
|
result = -EOPNOTSUPP;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2011-09-26 00:06:53 +07:00
|
|
|
if (!netdev) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2011-11-03 20:50:13 +07:00
|
|
|
if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2012-04-02 15:51:55 +07:00
|
|
|
if (!netif_running(netdev)) {
|
|
|
|
result = -ENETDOWN;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2008-10-30 21:59:24 +07:00
|
|
|
nla_for_each_nested(nl_txq_params,
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
|
|
|
|
rem_txq_params) {
|
|
|
|
nla_parse(tb, NL80211_TXQ_ATTR_MAX,
|
|
|
|
nla_data(nl_txq_params),
|
|
|
|
nla_len(nl_txq_params),
|
|
|
|
txq_params_policy);
|
|
|
|
result = parse_txq_params(tb, &txq_params);
|
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
|
|
|
|
|
|
|
result = rdev->ops->set_txq_params(&rdev->wiphy,
|
2011-09-26 00:06:53 +07:00
|
|
|
netdev,
|
2008-10-30 21:59:24 +07:00
|
|
|
&txq_params);
|
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2008-11-26 21:15:24 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
|
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 20:25:02 +07:00
|
|
|
result = __nl80211_set_channel(rdev, wdev, info);
|
2008-11-26 21:15:24 +07:00
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2010-06-23 16:12:38 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) {
|
|
|
|
enum nl80211_tx_power_setting type;
|
|
|
|
int idx, mbm = 0;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_tx_power) {
|
2010-07-07 20:02:46 +07:00
|
|
|
result = -EOPNOTSUPP;
|
2010-06-23 16:12:38 +07:00
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
idx = NL80211_ATTR_WIPHY_TX_POWER_SETTING;
|
|
|
|
type = nla_get_u32(info->attrs[idx]);
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_TX_POWER_LEVEL] &&
|
|
|
|
(type != NL80211_TX_POWER_AUTOMATIC)) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != NL80211_TX_POWER_AUTOMATIC) {
|
|
|
|
idx = NL80211_ATTR_WIPHY_TX_POWER_LEVEL;
|
|
|
|
mbm = nla_get_u32(info->attrs[idx]);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = rdev->ops->set_tx_power(&rdev->wiphy, type, mbm);
|
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
|
|
|
|
u32 tx_ant, rx_ant;
|
2010-12-16 09:30:22 +07:00
|
|
|
if ((!rdev->wiphy.available_antennas_tx &&
|
|
|
|
!rdev->wiphy.available_antennas_rx) ||
|
|
|
|
!rdev->ops->set_antenna) {
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
result = -EOPNOTSUPP;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
tx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX]);
|
|
|
|
rx_ant = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
|
|
|
|
|
2010-12-08 11:59:24 +07:00
|
|
|
/* reject antenna configurations which don't match the
|
2010-12-16 09:30:22 +07:00
|
|
|
* available antenna masks, except for the "all" mask */
|
|
|
|
if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) ||
|
|
|
|
(~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx))) {
|
2010-12-08 11:59:24 +07:00
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2010-12-16 09:30:22 +07:00
|
|
|
tx_ant = tx_ant & rdev->wiphy.available_antennas_tx;
|
|
|
|
rx_ant = rx_ant & rdev->wiphy.available_antennas_rx;
|
2010-12-08 11:59:24 +07:00
|
|
|
|
cfg80211: Add nl80211 antenna configuration
Allow setting of TX and RX antennas configuration via nl80211.
The antenna configuration is defined as a bitmap of allowed antennas to use.
This API can be used to mask out antennas which are not attached or should not
be used for other reasons like regulatory concerns or special setups.
Separate bitmaps are used for RX and TX to allow configuring different antennas
for receiving and transmitting. Each bitmap is 32 bit long, each bit
representing one antenna, starting with antenna 1 at the first bit. If an
antenna bit is set, this means the driver is allowed to use this antenna for RX
or TX respectively; if the bit is not set the hardware is not allowed to use
this antenna.
Using bitmaps has the benefit of allowing for a flexible configuration
interface which can support many different configurations and which can be used
for 802.11n as well as non-802.11n devices. Instead of relying on some hardware
specific assumptions, drivers can use this information to know which antennas
are actually attached to the system and derive their capabilities based on
that.
802.11n devices should enable or disable chains, based on which antennas are
present (If all antennas belonging to a particular chain are disabled, the
entire chain should be disabled). HT capabilities (like STBC, TX Beamforming,
Antenna selection) should be calculated based on the available chains after
applying the antenna masks. Should a 802.11n device have diversity antennas
attached to one of their chains, diversity can be enabled or disabled based on
the antenna information.
Non-802.11n drivers can use the antenna masks to select RX and TX antennas and
to enable or disable antenna diversity.
While covering chainmasks for 802.11n and the standard "legacy" modes "fixed
antenna 1", "fixed antenna 2" and "diversity" this API also allows more rare,
but useful configurations as follows:
1) Send on antenna 1, receive on antenna 2 (or vice versa). This can be used to
have a low gain antenna for TX in order to keep within the regulatory
constraints and a high gain antenna for RX in order to receive weaker signals
("speak softly, but listen harder"). This can be useful for building long-shot
outdoor links. Another usage of this setup is having a low-noise pre-amplifier
on antenna 1 and a power amplifier on the other antenna. This way transmit
noise is mostly kept out of the low noise receive channel.
(This would be bitmaps: tx 1 rx 2).
2) Another similar setup is: Use RX diversity on both antennas, but always send
on antenna 1. Again that would allow us to benefit from a higher gain RX
antenna, while staying within the legal limits.
(This would be: tx 0 rx 3).
3) And finally there can be special experimental setups in research and
development even with pre 802.11n hardware where more than 2 antennas are
available. It's good to keep the API simple, yet flexible.
Signed-off-by: Bruno Randolf <br1@einfach.org>
--
v7: Made bitmasks 32 bit wide and rebased to latest wireless-testing.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2010-11-10 10:50:50 +07:00
|
|
|
result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant);
|
|
|
|
if (result)
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
2009-04-20 23:39:05 +07:00
|
|
|
changed = 0;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]) {
|
|
|
|
retry_short = nla_get_u8(
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_RETRY_SHORT]);
|
|
|
|
if (retry_short == 0) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
changed |= WIPHY_PARAM_RETRY_SHORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]) {
|
|
|
|
retry_long = nla_get_u8(
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_RETRY_LONG]);
|
|
|
|
if (retry_long == 0) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
changed |= WIPHY_PARAM_RETRY_LONG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]) {
|
|
|
|
frag_threshold = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_FRAG_THRESHOLD]);
|
|
|
|
if (frag_threshold < 256) {
|
|
|
|
result = -EINVAL;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
if (frag_threshold != (u32) -1) {
|
|
|
|
/*
|
|
|
|
* Fragments (apart from the last one) are required to
|
|
|
|
* have even length. Make the fragmentation code
|
|
|
|
* simpler by stripping LSB should someone try to use
|
|
|
|
* odd threshold value.
|
|
|
|
*/
|
|
|
|
frag_threshold &= ~0x1;
|
|
|
|
}
|
|
|
|
changed |= WIPHY_PARAM_FRAG_THRESHOLD;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]) {
|
|
|
|
rts_threshold = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_RTS_THRESHOLD]);
|
|
|
|
changed |= WIPHY_PARAM_RTS_THRESHOLD;
|
|
|
|
}
|
|
|
|
|
2009-12-22 04:50:47 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
|
|
|
|
coverage_class = nla_get_u8(
|
|
|
|
info->attrs[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
|
|
|
|
changed |= WIPHY_PARAM_COVERAGE_CLASS;
|
|
|
|
}
|
|
|
|
|
2009-04-20 23:39:05 +07:00
|
|
|
if (changed) {
|
|
|
|
u8 old_retry_short, old_retry_long;
|
|
|
|
u32 old_frag_threshold, old_rts_threshold;
|
2009-12-22 04:50:47 +07:00
|
|
|
u8 old_coverage_class;
|
2009-04-20 23:39:05 +07:00
|
|
|
|
|
|
|
if (!rdev->ops->set_wiphy_params) {
|
|
|
|
result = -EOPNOTSUPP;
|
|
|
|
goto bad_res;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_retry_short = rdev->wiphy.retry_short;
|
|
|
|
old_retry_long = rdev->wiphy.retry_long;
|
|
|
|
old_frag_threshold = rdev->wiphy.frag_threshold;
|
|
|
|
old_rts_threshold = rdev->wiphy.rts_threshold;
|
2009-12-22 04:50:47 +07:00
|
|
|
old_coverage_class = rdev->wiphy.coverage_class;
|
2009-04-20 23:39:05 +07:00
|
|
|
|
|
|
|
if (changed & WIPHY_PARAM_RETRY_SHORT)
|
|
|
|
rdev->wiphy.retry_short = retry_short;
|
|
|
|
if (changed & WIPHY_PARAM_RETRY_LONG)
|
|
|
|
rdev->wiphy.retry_long = retry_long;
|
|
|
|
if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
|
|
|
|
rdev->wiphy.frag_threshold = frag_threshold;
|
|
|
|
if (changed & WIPHY_PARAM_RTS_THRESHOLD)
|
|
|
|
rdev->wiphy.rts_threshold = rts_threshold;
|
2009-12-22 04:50:47 +07:00
|
|
|
if (changed & WIPHY_PARAM_COVERAGE_CLASS)
|
|
|
|
rdev->wiphy.coverage_class = coverage_class;
|
2009-04-20 23:39:05 +07:00
|
|
|
|
|
|
|
result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed);
|
|
|
|
if (result) {
|
|
|
|
rdev->wiphy.retry_short = old_retry_short;
|
|
|
|
rdev->wiphy.retry_long = old_retry_long;
|
|
|
|
rdev->wiphy.frag_threshold = old_frag_threshold;
|
|
|
|
rdev->wiphy.rts_threshold = old_rts_threshold;
|
2009-12-22 04:50:47 +07:00
|
|
|
rdev->wiphy.coverage_class = old_coverage_class;
|
2009-04-20 23:39:05 +07:00
|
|
|
}
|
|
|
|
}
|
2008-11-26 21:15:24 +07:00
|
|
|
|
2008-12-08 18:39:04 +07:00
|
|
|
bad_res:
|
2009-03-24 15:35:46 +07:00
|
|
|
mutex_unlock(&rdev->mtx);
|
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 20:25:02 +07:00
|
|
|
if (netdev)
|
|
|
|
dev_put(netdev);
|
2007-09-21 00:09:35 +07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
static inline u64 wdev_id(struct wireless_dev *wdev)
|
|
|
|
{
|
|
|
|
return (u64)wdev->identifier |
|
|
|
|
((u64)wiphy_to_dev(wdev->wiphy)->wiphy_idx << 32);
|
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags,
|
2009-04-19 21:23:20 +07:00
|
|
|
struct cfg80211_registered_device *rdev,
|
2012-06-15 22:52:47 +07:00
|
|
|
struct wireless_dev *wdev)
|
2007-09-21 00:09:35 +07:00
|
|
|
{
|
2012-06-15 22:52:47 +07:00
|
|
|
struct net_device *dev = wdev->netdev;
|
2007-09-21 00:09:35 +07:00
|
|
|
void *hdr;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_INTERFACE);
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-06-15 22:52:47 +07:00
|
|
|
if (dev &&
|
|
|
|
(nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
2012-06-16 05:19:54 +07:00
|
|
|
nla_put_string(msg, NL80211_ATTR_IFNAME, dev->name)))
|
2012-06-15 22:52:47 +07:00
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFTYPE, wdev->iftype) ||
|
2012-06-15 20:30:18 +07:00
|
|
|
nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
|
2012-06-16 05:19:54 +07:00
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, wdev_address(wdev)) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
nla_put_u32(msg, NL80211_ATTR_GENERATION,
|
|
|
|
rdev->devlist_generation ^
|
|
|
|
(cfg80211_rdev_list_generation << 2)))
|
|
|
|
goto nla_put_failure;
|
2009-08-07 21:17:38 +07:00
|
|
|
|
2012-07-13 00:45:08 +07:00
|
|
|
if (rdev->ops->get_channel) {
|
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
enum nl80211_channel_type channel_type;
|
|
|
|
|
|
|
|
chan = rdev->ops->get_channel(&rdev->wiphy, wdev,
|
|
|
|
&channel_type);
|
|
|
|
if (chan &&
|
|
|
|
(nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ,
|
|
|
|
chan->center_freq) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE,
|
|
|
|
channel_type)))
|
2012-04-19 01:17:13 +07:00
|
|
|
goto nla_put_failure;
|
2012-04-03 21:39:58 +07:00
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
2008-06-04 06:36:54 +07:00
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
int wp_idx = 0;
|
|
|
|
int if_idx = 0;
|
|
|
|
int wp_start = cb->args[0];
|
|
|
|
int if_start = cb->args[1];
|
2009-08-07 21:17:38 +07:00
|
|
|
struct cfg80211_registered_device *rdev;
|
2007-09-21 00:09:35 +07:00
|
|
|
struct wireless_dev *wdev;
|
|
|
|
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
2009-08-07 21:17:38 +07:00
|
|
|
list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
|
|
|
|
if (!net_eq(wiphy_net(&rdev->wiphy), sock_net(skb->sk)))
|
2009-07-14 05:33:35 +07:00
|
|
|
continue;
|
2008-07-29 18:22:51 +07:00
|
|
|
if (wp_idx < wp_start) {
|
|
|
|
wp_idx++;
|
2007-09-21 00:09:35 +07:00
|
|
|
continue;
|
2008-07-29 18:22:51 +07:00
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
if_idx = 0;
|
|
|
|
|
2009-08-07 21:17:38 +07:00
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
2012-06-15 19:33:17 +07:00
|
|
|
list_for_each_entry(wdev, &rdev->wdev_list, list) {
|
2008-07-29 18:22:51 +07:00
|
|
|
if (if_idx < if_start) {
|
|
|
|
if_idx++;
|
2007-09-21 00:09:35 +07:00
|
|
|
continue;
|
2008-07-29 18:22:51 +07:00
|
|
|
}
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid,
|
2007-09-21 00:09:35 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
2012-06-15 22:52:47 +07:00
|
|
|
rdev, wdev) < 0) {
|
2009-08-07 21:17:38 +07:00
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
2008-07-29 18:22:51 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if_idx++;
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
2009-08-07 21:17:38 +07:00
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
2008-07-29 18:22:51 +07:00
|
|
|
|
|
|
|
wp_idx++;
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
2008-07-29 18:22:51 +07:00
|
|
|
out:
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2007-09-21 00:09:35 +07:00
|
|
|
|
|
|
|
cb->args[0] = wp_idx;
|
|
|
|
cb->args[1] = if_idx;
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *dev = info->user_ptr[0];
|
2012-06-15 22:52:47 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!msg)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -ENOMEM;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0,
|
2012-06-15 22:52:47 +07:00
|
|
|
dev, wdev) < 0) {
|
2010-10-05 02:36:35 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-07-10 16:51:34 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2008-02-01 01:48:22 +07:00
|
|
|
static const struct nla_policy mntr_flags_policy[NL80211_MNTR_FLAG_MAX + 1] = {
|
|
|
|
[NL80211_MNTR_FLAG_FCSFAIL] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_MNTR_FLAG_PLCPFAIL] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_MNTR_FLAG_CONTROL] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_MNTR_FLAG_OTHER_BSS] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_MNTR_FLAG_COOK_FRAMES] = { .type = NLA_FLAG },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int parse_monitor_flags(struct nlattr *nla, u32 *mntrflags)
|
|
|
|
{
|
|
|
|
struct nlattr *flags[NL80211_MNTR_FLAG_MAX + 1];
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
*mntrflags = 0;
|
|
|
|
|
|
|
|
if (!nla)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (nla_parse_nested(flags, NL80211_MNTR_FLAG_MAX,
|
|
|
|
nla, mntr_flags_policy))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
for (flag = 1; flag <= NL80211_MNTR_FLAG_MAX; flag++)
|
|
|
|
if (flags[flag])
|
|
|
|
*mntrflags |= (1<<flag);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-19 17:55:19 +07:00
|
|
|
static int nl80211_valid_4addr(struct cfg80211_registered_device *rdev,
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
struct net_device *netdev, u8 use_4addr,
|
|
|
|
enum nl80211_iftype iftype)
|
2009-11-19 17:55:19 +07:00
|
|
|
{
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
if (!use_4addr) {
|
2010-06-15 13:50:45 +07:00
|
|
|
if (netdev && (netdev->priv_flags & IFF_BRIDGE_PORT))
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
return -EBUSY;
|
2009-11-19 17:55:19 +07:00
|
|
|
return 0;
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
}
|
2009-11-19 17:55:19 +07:00
|
|
|
|
|
|
|
switch (iftype) {
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
if (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
if (rdev->wiphy.flags & WIPHY_FLAG_4ADDR_STATION)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2008-02-23 21:17:06 +07:00
|
|
|
struct vif_params params;
|
2009-06-10 02:04:43 +07:00
|
|
|
int err;
|
2009-04-20 02:24:32 +07:00
|
|
|
enum nl80211_iftype otype, ntype;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-09-17 01:39:36 +07:00
|
|
|
u32 _flags, *flags = NULL;
|
2009-03-21 23:07:59 +07:00
|
|
|
bool change = false;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
2009-04-20 02:24:32 +07:00
|
|
|
otype = ntype = dev->ieee80211_ptr->iftype;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2008-09-17 01:22:09 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IFTYPE]) {
|
2009-03-21 23:07:59 +07:00
|
|
|
ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
|
2009-04-20 02:24:32 +07:00
|
|
|
if (otype != ntype)
|
2009-03-21 23:07:59 +07:00
|
|
|
change = true;
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ntype > NL80211_IFTYPE_MAX)
|
|
|
|
return -EINVAL;
|
2008-09-17 01:22:09 +07:00
|
|
|
}
|
|
|
|
|
2008-09-17 01:39:36 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MESH_ID]) {
|
2010-12-03 15:20:44 +07:00
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ntype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EINVAL;
|
2010-12-03 15:20:44 +07:00
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
wdev_lock(wdev);
|
|
|
|
BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN !=
|
|
|
|
IEEE80211_MAX_MESH_ID_LEN);
|
|
|
|
wdev->mesh_id_up_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
|
|
|
|
memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]),
|
|
|
|
wdev->mesh_id_up_len);
|
|
|
|
wdev_unlock(wdev);
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
2009-11-11 00:53:10 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_4ADDR]) {
|
|
|
|
params.use_4addr = !!nla_get_u8(info->attrs[NL80211_ATTR_4ADDR]);
|
|
|
|
change = true;
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
err = nl80211_valid_4addr(rdev, dev, params.use_4addr, ntype);
|
2009-11-19 17:55:19 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2009-11-11 00:53:10 +07:00
|
|
|
} else {
|
|
|
|
params.use_4addr = -1;
|
|
|
|
}
|
|
|
|
|
2008-09-17 01:39:36 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MNTR_FLAGS]) {
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ntype != NL80211_IFTYPE_MONITOR)
|
|
|
|
return -EINVAL;
|
2008-09-17 01:39:36 +07:00
|
|
|
err = parse_monitor_flags(info->attrs[NL80211_ATTR_MNTR_FLAGS],
|
|
|
|
&_flags);
|
2009-03-21 23:07:59 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2009-03-21 23:07:59 +07:00
|
|
|
|
|
|
|
flags = &_flags;
|
|
|
|
change = true;
|
2008-09-17 01:39:36 +07:00
|
|
|
}
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2009-03-21 23:07:59 +07:00
|
|
|
if (change)
|
2009-08-21 19:51:05 +07:00
|
|
|
err = cfg80211_change_iface(rdev, dev, ntype, flags, ¶ms);
|
2009-03-21 23:07:59 +07:00
|
|
|
else
|
|
|
|
err = 0;
|
2008-09-16 19:55:09 +07:00
|
|
|
|
2009-11-19 17:55:19 +07:00
|
|
|
if (!err && params.use_4addr != -1)
|
|
|
|
dev->ieee80211_ptr->use_4addr = params.use_4addr;
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2008-02-23 21:17:06 +07:00
|
|
|
struct vif_params params;
|
2012-06-16 05:00:26 +07:00
|
|
|
struct wireless_dev *wdev;
|
2012-06-16 05:05:37 +07:00
|
|
|
struct sk_buff *msg;
|
2007-09-21 00:09:35 +07:00
|
|
|
int err;
|
|
|
|
enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED;
|
2008-02-01 01:48:22 +07:00
|
|
|
u32 flags;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_IFNAME])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IFTYPE]) {
|
|
|
|
type = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
|
|
|
|
if (type > NL80211_IFTYPE_MAX)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
if (!rdev->ops->add_virtual_intf ||
|
2010-10-05 02:36:35 +07:00
|
|
|
!(rdev->wiphy.interface_modes & (1 << type)))
|
|
|
|
return -EOPNOTSUPP;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-11-19 17:55:19 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_4ADDR]) {
|
2009-11-11 00:53:10 +07:00
|
|
|
params.use_4addr = !!nla_get_u8(info->attrs[NL80211_ATTR_4ADDR]);
|
cfg80211: disallow bridging managed/adhoc interfaces
A number of people have tried to add a wireless interface
(in managed mode) to a bridge and then complained that it
doesn't work. It cannot work, however, because in 802.11
networks all packets need to be acknowledged and as such
need to be sent to the right address. Promiscuous doesn't
help here. The wireless address format used for these
links has only space for three addresses, the
* transmitter, which must be equal to the sender (origin)
* receiver (on the wireless medium), which is the AP in
the case of managed mode
* the recipient (destination), which is on the APs local
network segment
In an IBSS, it is similar, but the receiver and recipient
must match and the third address is used as the BSSID.
To avoid such mistakes in the future, disallow adding a
wireless interface to a bridge.
Felix has recently added a four-address mode to the AP
and client side that can be used (after negotiating that
it is possible, which must happen out-of-band by setting
up both sides) for bridging, so allow that case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-11-19 06:56:30 +07:00
|
|
|
err = nl80211_valid_4addr(rdev, NULL, params.use_4addr, type);
|
2009-11-19 17:55:19 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2009-11-19 17:55:19 +07:00
|
|
|
}
|
2009-11-11 00:53:10 +07:00
|
|
|
|
2012-06-16 05:05:37 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2008-02-01 01:48:22 +07:00
|
|
|
err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ?
|
|
|
|
info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL,
|
|
|
|
&flags);
|
2012-06-16 05:00:26 +07:00
|
|
|
wdev = rdev->ops->add_virtual_intf(&rdev->wiphy,
|
2008-02-01 01:48:22 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_IFNAME]),
|
2008-02-23 21:17:06 +07:00
|
|
|
type, err ? NULL : &flags, ¶ms);
|
2012-06-16 05:05:37 +07:00
|
|
|
if (IS_ERR(wdev)) {
|
|
|
|
nlmsg_free(msg);
|
2012-06-16 05:00:26 +07:00
|
|
|
return PTR_ERR(wdev);
|
2012-06-16 05:05:37 +07:00
|
|
|
}
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2012-06-16 05:19:54 +07:00
|
|
|
switch (type) {
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
if (!info->attrs[NL80211_ATTR_MESH_ID])
|
|
|
|
break;
|
2010-12-03 15:20:44 +07:00
|
|
|
wdev_lock(wdev);
|
|
|
|
BUILD_BUG_ON(IEEE80211_MAX_SSID_LEN !=
|
|
|
|
IEEE80211_MAX_MESH_ID_LEN);
|
|
|
|
wdev->mesh_id_up_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
|
|
|
|
memcpy(wdev->ssid, nla_data(info->attrs[NL80211_ATTR_MESH_ID]),
|
|
|
|
wdev->mesh_id_up_len);
|
|
|
|
wdev_unlock(wdev);
|
2012-06-16 05:19:54 +07:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_P2P_DEVICE:
|
|
|
|
/*
|
|
|
|
* P2P Device doesn't have a netdev, so doesn't go
|
|
|
|
* through the netdev notifier and must be added here
|
|
|
|
*/
|
|
|
|
mutex_init(&wdev->mtx);
|
|
|
|
INIT_LIST_HEAD(&wdev->event_list);
|
|
|
|
spin_lock_init(&wdev->event_lock);
|
|
|
|
INIT_LIST_HEAD(&wdev->mgmt_registrations);
|
|
|
|
spin_lock_init(&wdev->mgmt_registrations_lock);
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
wdev->identifier = ++rdev->wdev_id;
|
|
|
|
list_add_rcu(&wdev->list, &rdev->wdev_list);
|
|
|
|
rdev->devlist_generation++;
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-12-03 15:20:44 +07:00
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0,
|
2012-06-16 05:05:37 +07:00
|
|
|
rdev, wdev) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return genlmsg_reply(msg, info);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-16 05:00:26 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->del_virtual_intf)
|
|
|
|
return -EOPNOTSUPP;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2012-06-16 05:00:26 +07:00
|
|
|
/*
|
|
|
|
* If we remove a wireless device without a netdev then clear
|
|
|
|
* user_ptr[1] so that nl80211_post_doit won't dereference it
|
|
|
|
* to check if it needs to do dev_put(). Otherwise it crashes
|
|
|
|
* since the wdev has been freed, unlike with a netdev where
|
|
|
|
* we need the dev_put() for the netdev to really be freed.
|
|
|
|
*/
|
|
|
|
if (!wdev->netdev)
|
|
|
|
info->user_ptr[1] = NULL;
|
|
|
|
|
|
|
|
return rdev->ops->del_virtual_intf(&rdev->wiphy, wdev);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2011-11-18 20:20:43 +07:00
|
|
|
static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
u16 noack_map;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_NOACK_MAP])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_noack_map)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]);
|
|
|
|
|
|
|
|
return rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map);
|
|
|
|
}
|
|
|
|
|
2007-12-19 08:03:29 +07:00
|
|
|
struct get_key_cookie {
|
|
|
|
struct sk_buff *msg;
|
|
|
|
int error;
|
2009-07-08 18:29:08 +07:00
|
|
|
int idx;
|
2007-12-19 08:03:29 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void get_key_callback(void *c, struct key_params *params)
|
|
|
|
{
|
2009-07-08 18:29:08 +07:00
|
|
|
struct nlattr *key;
|
2007-12-19 08:03:29 +07:00
|
|
|
struct get_key_cookie *cookie = c;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((params->key &&
|
|
|
|
nla_put(cookie->msg, NL80211_ATTR_KEY_DATA,
|
|
|
|
params->key_len, params->key)) ||
|
|
|
|
(params->seq &&
|
|
|
|
nla_put(cookie->msg, NL80211_ATTR_KEY_SEQ,
|
|
|
|
params->seq_len, params->seq)) ||
|
|
|
|
(params->cipher &&
|
|
|
|
nla_put_u32(cookie->msg, NL80211_ATTR_KEY_CIPHER,
|
|
|
|
params->cipher)))
|
|
|
|
goto nla_put_failure;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
key = nla_nest_start(cookie->msg, NL80211_ATTR_KEY);
|
|
|
|
if (!key)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((params->key &&
|
|
|
|
nla_put(cookie->msg, NL80211_KEY_DATA,
|
|
|
|
params->key_len, params->key)) ||
|
|
|
|
(params->seq &&
|
|
|
|
nla_put(cookie->msg, NL80211_KEY_SEQ,
|
|
|
|
params->seq_len, params->seq)) ||
|
|
|
|
(params->cipher &&
|
|
|
|
nla_put_u32(cookie->msg, NL80211_KEY_CIPHER,
|
|
|
|
params->cipher)))
|
|
|
|
goto nla_put_failure;
|
2009-07-08 18:29:08 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u8(cookie->msg, NL80211_ATTR_KEY_IDX, cookie->idx))
|
|
|
|
goto nla_put_failure;
|
2009-07-08 18:29:08 +07:00
|
|
|
|
|
|
|
nla_nest_end(cookie->msg, key);
|
|
|
|
|
2007-12-19 08:03:29 +07:00
|
|
|
return;
|
|
|
|
nla_put_failure:
|
|
|
|
cookie->error = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2007-12-19 08:03:29 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:29 +07:00
|
|
|
u8 key_idx = 0;
|
2010-10-06 00:39:30 +07:00
|
|
|
const u8 *mac_addr = NULL;
|
|
|
|
bool pairwise;
|
2007-12-19 08:03:29 +07:00
|
|
|
struct get_key_cookie cookie = {
|
|
|
|
.error = 0,
|
|
|
|
};
|
|
|
|
void *hdr;
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_IDX])
|
|
|
|
key_idx = nla_get_u8(info->attrs[NL80211_ATTR_KEY_IDX]);
|
|
|
|
|
2009-01-08 18:32:02 +07:00
|
|
|
if (key_idx > 5)
|
2007-12-19 08:03:29 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
pairwise = !!mac_addr;
|
|
|
|
if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
|
|
|
|
u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
|
|
|
|
if (kt >= NUM_NL80211_KEYTYPES)
|
|
|
|
return -EINVAL;
|
|
|
|
if (kt != NL80211_KEYTYPE_GROUP &&
|
|
|
|
kt != NL80211_KEYTYPE_PAIRWISE)
|
|
|
|
return -EINVAL;
|
|
|
|
pairwise = kt == NL80211_KEYTYPE_PAIRWISE;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->get_key)
|
|
|
|
return -EOPNOTSUPP;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2007-12-19 08:03:29 +07:00
|
|
|
NL80211_CMD_NEW_KEY);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (IS_ERR(hdr))
|
|
|
|
return PTR_ERR(hdr);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
cookie.msg = msg;
|
2009-07-08 18:29:08 +07:00
|
|
|
cookie.idx = key_idx;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_idx))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (mac_addr &&
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr))
|
|
|
|
goto nla_put_failure;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (pairwise && mac_addr &&
|
|
|
|
!(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
err = rdev->ops->get_key(&rdev->wiphy, dev, key_idx, pairwise,
|
|
|
|
mac_addr, &cookie, get_key_callback);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
if (err)
|
2009-07-15 15:00:53 +07:00
|
|
|
goto free_msg;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
if (cookie.error)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
2010-10-05 02:36:35 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
err = -ENOBUFS;
|
2009-07-15 15:00:53 +07:00
|
|
|
free_msg:
|
2007-12-19 08:03:29 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2009-07-08 18:29:08 +07:00
|
|
|
struct key_parse key;
|
2007-12-19 08:03:29 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
err = nl80211_parse_key(info, &key);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
if (key.idx < 0)
|
2007-12-19 08:03:29 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
/* only support setting default key */
|
|
|
|
if (!key.def && !key.defmgmt)
|
2007-12-19 08:03:29 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
wdev_lock(dev->ieee80211_ptr);
|
2009-01-08 18:32:02 +07:00
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
if (key.def) {
|
|
|
|
if (!rdev->ops->set_default_key) {
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2010-12-10 01:58:59 +07:00
|
|
|
err = nl80211_key_allowed(dev->ieee80211_ptr);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = rdev->ops->set_default_key(&rdev->wiphy, dev, key.idx,
|
|
|
|
key.def_uni, key.def_multi);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto out;
|
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 19:22:54 +07:00
|
|
|
|
2009-09-30 04:27:28 +07:00
|
|
|
#ifdef CONFIG_CFG80211_WEXT
|
2010-12-10 01:58:59 +07:00
|
|
|
dev->ieee80211_ptr->wext.default_key = key.idx;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
if (key.def_uni || !key.def_multi) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rdev->ops->set_default_mgmt_key) {
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = nl80211_key_allowed(dev->ieee80211_ptr);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = rdev->ops->set_default_mgmt_key(&rdev->wiphy,
|
|
|
|
dev, key.idx);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
#ifdef CONFIG_CFG80211_WEXT
|
|
|
|
dev->ieee80211_ptr->wext.default_mgmt_key = key.idx;
|
2009-05-11 18:54:58 +07:00
|
|
|
#endif
|
2010-12-10 01:58:59 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
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 19:22:54 +07:00
|
|
|
wdev_unlock(dev->ieee80211_ptr);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[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 19:22:54 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-08 18:29:08 +07:00
|
|
|
struct key_parse key;
|
2010-10-06 00:39:30 +07:00
|
|
|
const u8 *mac_addr = NULL;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
err = nl80211_parse_key(info, &key);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
if (!key.p.key)
|
2007-12-19 08:03:29 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (key.type == -1) {
|
|
|
|
if (mac_addr)
|
|
|
|
key.type = NL80211_KEYTYPE_PAIRWISE;
|
|
|
|
else
|
|
|
|
key.type = NL80211_KEYTYPE_GROUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for now */
|
|
|
|
if (key.type != NL80211_KEYTYPE_PAIRWISE &&
|
|
|
|
key.type != NL80211_KEYTYPE_GROUP)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->add_key)
|
|
|
|
return -EOPNOTSUPP;
|
2009-04-03 01:14:06 +07:00
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (cfg80211_validate_key_settings(rdev, &key.p, key.idx,
|
|
|
|
key.type == NL80211_KEYTYPE_PAIRWISE,
|
|
|
|
mac_addr))
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2007-12-19 08:03:29 +07: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 19:22:54 +07:00
|
|
|
wdev_lock(dev->ieee80211_ptr);
|
|
|
|
err = nl80211_key_allowed(dev->ieee80211_ptr);
|
|
|
|
if (!err)
|
|
|
|
err = rdev->ops->add_key(&rdev->wiphy, dev, key.idx,
|
2010-10-06 00:39:30 +07:00
|
|
|
key.type == NL80211_KEYTYPE_PAIRWISE,
|
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 19:22:54 +07:00
|
|
|
mac_addr, &key.p);
|
|
|
|
wdev_unlock(dev->ieee80211_ptr);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2007-12-19 08:03:29 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:29 +07:00
|
|
|
u8 *mac_addr = NULL;
|
2009-07-08 18:29:08 +07:00
|
|
|
struct key_parse key;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-07-08 18:29:08 +07:00
|
|
|
err = nl80211_parse_key(info, &key);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2007-12-19 08:03:29 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-06 00:39:30 +07:00
|
|
|
if (key.type == -1) {
|
|
|
|
if (mac_addr)
|
|
|
|
key.type = NL80211_KEYTYPE_PAIRWISE;
|
|
|
|
else
|
|
|
|
key.type = NL80211_KEYTYPE_GROUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for now */
|
|
|
|
if (key.type != NL80211_KEYTYPE_PAIRWISE &&
|
|
|
|
key.type != NL80211_KEYTYPE_GROUP)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->del_key)
|
|
|
|
return -EOPNOTSUPP;
|
2007-12-19 08:03:29 +07: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 19:22:54 +07:00
|
|
|
wdev_lock(dev->ieee80211_ptr);
|
|
|
|
err = nl80211_key_allowed(dev->ieee80211_ptr);
|
2010-10-06 00:39:30 +07:00
|
|
|
|
|
|
|
if (key.type == NL80211_KEYTYPE_PAIRWISE && mac_addr &&
|
|
|
|
!(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN))
|
|
|
|
err = -ENOENT;
|
|
|
|
|
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 19:22:54 +07:00
|
|
|
if (!err)
|
2010-10-06 00:39:30 +07:00
|
|
|
err = rdev->ops->del_key(&rdev->wiphy, dev, key.idx,
|
|
|
|
key.type == NL80211_KEYTYPE_PAIRWISE,
|
|
|
|
mac_addr);
|
2007-12-19 08:03:29 +07:00
|
|
|
|
2009-09-30 04:27:28 +07:00
|
|
|
#ifdef CONFIG_CFG80211_WEXT
|
2009-05-11 18:54:58 +07:00
|
|
|
if (!err) {
|
2009-07-08 18:29:08 +07:00
|
|
|
if (key.idx == dev->ieee80211_ptr->wext.default_key)
|
2009-05-11 18:54:58 +07:00
|
|
|
dev->ieee80211_ptr->wext.default_key = -1;
|
2009-07-08 18:29:08 +07:00
|
|
|
else if (key.idx == dev->ieee80211_ptr->wext.default_mgmt_key)
|
2009-05-11 18:54:58 +07:00
|
|
|
dev->ieee80211_ptr->wext.default_mgmt_key = -1;
|
|
|
|
}
|
|
|
|
#endif
|
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 19:22:54 +07:00
|
|
|
wdev_unlock(dev->ieee80211_ptr);
|
2009-05-11 18:54:58 +07:00
|
|
|
|
2007-12-19 08:03:29 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
static int nl80211_parse_beacon(struct genl_info *info,
|
|
|
|
struct cfg80211_beacon_data *bcn)
|
2007-12-19 08:03:32 +07:00
|
|
|
{
|
2012-02-13 21:17:18 +07:00
|
|
|
bool haveinfo = false;
|
2007-12-19 08:03:32 +07:00
|
|
|
|
2011-08-11 03:55:56 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_BEACON_TAIL]) ||
|
|
|
|
!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]) ||
|
|
|
|
!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_PROBE_RESP]) ||
|
|
|
|
!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]))
|
2009-03-27 18:40:28 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
memset(bcn, 0, sizeof(*bcn));
|
2007-12-19 08:03:32 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_BEACON_HEAD]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->head = nla_data(info->attrs[NL80211_ATTR_BEACON_HEAD]);
|
|
|
|
bcn->head_len = nla_len(info->attrs[NL80211_ATTR_BEACON_HEAD]);
|
|
|
|
if (!bcn->head_len)
|
|
|
|
return -EINVAL;
|
|
|
|
haveinfo = true;
|
2007-12-19 08:03:32 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_BEACON_TAIL]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->tail = nla_data(info->attrs[NL80211_ATTR_BEACON_TAIL]);
|
|
|
|
bcn->tail_len =
|
2007-12-19 08:03:32 +07:00
|
|
|
nla_len(info->attrs[NL80211_ATTR_BEACON_TAIL]);
|
2012-02-13 21:17:18 +07:00
|
|
|
haveinfo = true;
|
2007-12-19 08:03:32 +07:00
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!haveinfo)
|
|
|
|
return -EINVAL;
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2011-08-11 03:55:56 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->beacon_ies = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
bcn->beacon_ies_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2011-08-11 03:55:56 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE_PROBE_RESP]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->proberesp_ies =
|
2011-08-11 03:55:56 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_IE_PROBE_RESP]);
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->proberesp_ies_len =
|
2011-08-11 03:55:56 +07:00
|
|
|
nla_len(info->attrs[NL80211_ATTR_IE_PROBE_RESP]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE_ASSOC_RESP]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->assocresp_ies =
|
2011-08-11 03:55:56 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]);
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->assocresp_ies_len =
|
2011-08-11 03:55:56 +07:00
|
|
|
nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]);
|
|
|
|
}
|
|
|
|
|
2011-11-10 16:28:56 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_PROBE_RESP]) {
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->probe_resp =
|
2011-11-10 16:28:56 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]);
|
2012-02-13 21:17:18 +07:00
|
|
|
bcn->probe_resp_len =
|
2011-11-10 16:28:56 +07:00
|
|
|
nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]);
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-19 07:50:57 +07:00
|
|
|
static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev,
|
|
|
|
struct cfg80211_ap_settings *params)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
|
2012-06-15 19:33:17 +07:00
|
|
|
list_for_each_entry(wdev, &rdev->wdev_list, list) {
|
2012-06-19 07:50:57 +07:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!wdev->preset_chan)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
params->channel = wdev->preset_chan;
|
|
|
|
params->channel_type = wdev->preset_chantype;
|
|
|
|
ret = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-09-30 23:29:39 +07:00
|
|
|
static bool nl80211_valid_auth_type(struct cfg80211_registered_device *rdev,
|
|
|
|
enum nl80211_auth_type auth_type,
|
|
|
|
enum nl80211_commands cmd)
|
|
|
|
{
|
|
|
|
if (auth_type > NL80211_AUTHTYPE_MAX)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case NL80211_CMD_AUTHENTICATE:
|
|
|
|
if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) &&
|
|
|
|
auth_type == NL80211_AUTHTYPE_SAE)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
case NL80211_CMD_CONNECT:
|
|
|
|
case NL80211_CMD_START_AP:
|
|
|
|
/* SAE not supported yet */
|
|
|
|
if (auth_type == NL80211_AUTHTYPE_SAE)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_ap_settings params;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->start_ap)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wdev->beacon_interval)
|
|
|
|
return -EALREADY;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
/* these are required for START_AP */
|
|
|
|
if (!info->attrs[NL80211_ATTR_BEACON_INTERVAL] ||
|
|
|
|
!info->attrs[NL80211_ATTR_DTIM_PERIOD] ||
|
|
|
|
!info->attrs[NL80211_ATTR_BEACON_HEAD])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nl80211_parse_beacon(info, ¶ms.beacon);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
params.beacon_interval =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
|
|
|
|
params.dtim_period =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_DTIM_PERIOD]);
|
|
|
|
|
|
|
|
err = cfg80211_validate_beacon_int(rdev, params.beacon_interval);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In theory, some of these attributes should be required here
|
|
|
|
* but since they were not used when the command was originally
|
|
|
|
* added, keep them optional for old user space programs to let
|
|
|
|
* them continue to work with drivers that do not need the
|
|
|
|
* additional information -- drivers must check!
|
|
|
|
*/
|
|
|
|
if (info->attrs[NL80211_ATTR_SSID]) {
|
|
|
|
params.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
params.ssid_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
if (params.ssid_len == 0 ||
|
|
|
|
params.ssid_len > IEEE80211_MAX_SSID_LEN)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_HIDDEN_SSID]) {
|
|
|
|
params.hidden_ssid = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_HIDDEN_SSID]);
|
|
|
|
if (params.hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE &&
|
|
|
|
params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_LEN &&
|
|
|
|
params.hidden_ssid != NL80211_HIDDEN_SSID_ZERO_CONTENTS)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
params.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_AUTH_TYPE]) {
|
|
|
|
params.auth_type = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_AUTH_TYPE]);
|
2012-09-30 23:29:39 +07:00
|
|
|
if (!nl80211_valid_auth_type(rdev, params.auth_type,
|
|
|
|
NL80211_CMD_START_AP))
|
2012-02-13 21:17:18 +07:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
params.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
|
|
|
|
|
|
|
|
err = nl80211_crypto_settings(rdev, info, ¶ms.crypto,
|
|
|
|
NL80211_MAX_NR_CIPHER_SUITES);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2012-03-02 17:20:02 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]) {
|
|
|
|
if (!(rdev->wiphy.features & NL80211_FEATURE_INACTIVITY_TIMER))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
params.inactivity_timeout = nla_get_u16(
|
|
|
|
info->attrs[NL80211_ATTR_INACTIVITY_TIMEOUT]);
|
|
|
|
}
|
|
|
|
|
2012-05-17 04:50:18 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
|
|
|
|
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
|
|
|
|
!nl80211_valid_channel_type(info, &channel_type))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
params.channel = rdev_freq_to_chan(rdev,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
|
|
|
|
channel_type);
|
|
|
|
if (!params.channel)
|
|
|
|
return -EINVAL;
|
|
|
|
params.channel_type = channel_type;
|
|
|
|
} else if (wdev->preset_chan) {
|
|
|
|
params.channel = wdev->preset_chan;
|
|
|
|
params.channel_type = wdev->preset_chantype;
|
2012-06-19 07:50:57 +07:00
|
|
|
} else if (!nl80211_get_ap_channel(rdev, ¶ms))
|
2012-05-17 04:50:18 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!cfg80211_can_beacon_sec_chan(&rdev->wiphy, params.channel,
|
|
|
|
params.channel_type))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-06-29 17:47:08 +07:00
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
err = cfg80211_can_use_chan(rdev, wdev, params.channel,
|
|
|
|
CHAN_MODE_SHARED);
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
err = rdev->ops->start_ap(&rdev->wiphy, dev, ¶ms);
|
2012-06-19 07:50:57 +07:00
|
|
|
if (!err) {
|
|
|
|
wdev->preset_chan = params.channel;
|
|
|
|
wdev->preset_chantype = params.channel_type;
|
2012-02-13 21:17:18 +07:00
|
|
|
wdev->beacon_interval = params.beacon_interval;
|
2012-06-29 17:46:58 +07:00
|
|
|
wdev->channel = params.channel;
|
2012-06-19 07:50:57 +07:00
|
|
|
}
|
2011-05-09 23:41:15 +07:00
|
|
|
return err;
|
2007-12-19 08:03:32 +07:00
|
|
|
}
|
|
|
|
|
2012-02-13 21:17:18 +07:00
|
|
|
static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_beacon_data params;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->change_beacon)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!wdev->beacon_interval)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nl80211_parse_beacon(info, ¶ms);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
return rdev->ops->change_beacon(&rdev->wiphy, dev, ¶ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info)
|
2007-12-19 08:03:32 +07:00
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:32 +07:00
|
|
|
|
2012-06-29 17:46:56 +07:00
|
|
|
return cfg80211_stop_ap(rdev, dev);
|
2007-12-19 08:03:32 +07:00
|
|
|
}
|
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
|
|
|
|
[NL80211_STA_FLAG_AUTHORIZED] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_STA_FLAG_SHORT_PREAMBLE] = { .type = NLA_FLAG },
|
|
|
|
[NL80211_STA_FLAG_WME] = { .type = NLA_FLAG },
|
2009-05-12 01:57:55 +07:00
|
|
|
[NL80211_STA_FLAG_MFP] = { .type = NLA_FLAG },
|
2011-04-08 05:08:30 +07:00
|
|
|
[NL80211_STA_FLAG_AUTHENTICATED] = { .type = NLA_FLAG },
|
2011-12-14 15:29:15 +07:00
|
|
|
[NL80211_STA_FLAG_TDLS_PEER] = { .type = NLA_FLAG },
|
2007-12-19 08:03:34 +07:00
|
|
|
};
|
|
|
|
|
2009-05-12 01:57:56 +07:00
|
|
|
static int parse_station_flags(struct genl_info *info,
|
2012-01-02 19:30:03 +07:00
|
|
|
enum nl80211_iftype iftype,
|
2009-05-12 01:57:56 +07:00
|
|
|
struct station_parameters *params)
|
2007-12-19 08:03:34 +07:00
|
|
|
{
|
|
|
|
struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
|
2009-05-12 01:57:56 +07:00
|
|
|
struct nlattr *nla;
|
2007-12-19 08:03:34 +07:00
|
|
|
int flag;
|
|
|
|
|
2009-05-12 01:57:56 +07:00
|
|
|
/*
|
|
|
|
* Try parsing the new attribute first so userspace
|
|
|
|
* can specify both for older kernels.
|
|
|
|
*/
|
|
|
|
nla = info->attrs[NL80211_ATTR_STA_FLAGS2];
|
|
|
|
if (nla) {
|
|
|
|
struct nl80211_sta_flag_update *sta_flags;
|
|
|
|
|
|
|
|
sta_flags = nla_data(nla);
|
|
|
|
params->sta_flags_mask = sta_flags->mask;
|
|
|
|
params->sta_flags_set = sta_flags->set;
|
|
|
|
if ((params->sta_flags_mask |
|
|
|
|
params->sta_flags_set) & BIT(__NL80211_STA_FLAG_INVALID))
|
|
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if present, parse the old attribute */
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2009-05-12 01:57:56 +07:00
|
|
|
nla = info->attrs[NL80211_ATTR_STA_FLAGS];
|
2007-12-19 08:03:34 +07:00
|
|
|
if (!nla)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (nla_parse_nested(flags, NL80211_STA_FLAG_MAX,
|
|
|
|
nla, sta_flags_policy))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-01-02 19:30:03 +07:00
|
|
|
/*
|
|
|
|
* Only allow certain flags for interface types so that
|
|
|
|
* other attributes are silently ignored. Remember that
|
|
|
|
* this is backward compatibility code with old userspace
|
|
|
|
* and shouldn't be hit in other cases anyway.
|
|
|
|
*/
|
|
|
|
switch (iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
|
|
|
params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
|
|
|
|
BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
|
|
|
|
BIT(NL80211_STA_FLAG_WME) |
|
|
|
|
BIT(NL80211_STA_FLAG_MFP);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
|
|
|
|
BIT(NL80211_STA_FLAG_TDLS_PEER);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) |
|
|
|
|
BIT(NL80211_STA_FLAG_MFP) |
|
|
|
|
BIT(NL80211_STA_FLAG_AUTHORIZED);
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2012-05-11 01:14:43 +07:00
|
|
|
for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) {
|
|
|
|
if (flags[flag]) {
|
2009-05-12 01:57:56 +07:00
|
|
|
params->sta_flags_set |= (1<<flag);
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2012-05-11 01:14:43 +07:00
|
|
|
/* no longer support new API additions in old API */
|
|
|
|
if (flag > NL80211_STA_FLAG_MAX_OLD_API)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-02-28 04:08:00 +07:00
|
|
|
static bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info,
|
|
|
|
int attr)
|
|
|
|
{
|
|
|
|
struct nlattr *rate;
|
2012-07-05 18:25:49 +07:00
|
|
|
u32 bitrate;
|
|
|
|
u16 bitrate_compat;
|
2011-02-28 04:08:00 +07:00
|
|
|
|
|
|
|
rate = nla_nest_start(msg, attr);
|
|
|
|
if (!rate)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
/* cfg80211_calculate_bitrate will return 0 for mcs >= 32 */
|
|
|
|
bitrate = cfg80211_calculate_bitrate(info);
|
2012-07-05 18:25:49 +07:00
|
|
|
/* report 16-bit bitrate only if we can */
|
|
|
|
bitrate_compat = bitrate < (1UL << 16) ? bitrate : 0;
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((bitrate > 0 &&
|
2012-07-05 18:25:49 +07:00
|
|
|
nla_put_u32(msg, NL80211_RATE_INFO_BITRATE32, bitrate)) ||
|
|
|
|
(bitrate_compat > 0 &&
|
|
|
|
nla_put_u16(msg, NL80211_RATE_INFO_BITRATE, bitrate_compat)) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
((info->flags & RATE_INFO_FLAGS_MCS) &&
|
|
|
|
nla_put_u8(msg, NL80211_RATE_INFO_MCS, info->mcs)) ||
|
|
|
|
((info->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) &&
|
|
|
|
nla_put_flag(msg, NL80211_RATE_INFO_40_MHZ_WIDTH)) ||
|
|
|
|
((info->flags & RATE_INFO_FLAGS_SHORT_GI) &&
|
|
|
|
nla_put_flag(msg, NL80211_RATE_INFO_SHORT_GI)))
|
|
|
|
goto nla_put_failure;
|
2011-02-28 04:08:00 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, rate);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
static int nl80211_send_station(struct sk_buff *msg, u32 portid, u32 seq,
|
2012-03-16 00:25:41 +07:00
|
|
|
int flags,
|
|
|
|
struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev,
|
2009-12-23 19:15:44 +07:00
|
|
|
const u8 *mac_addr, struct station_info *sinfo)
|
2007-12-19 08:03:36 +07:00
|
|
|
{
|
|
|
|
void *hdr;
|
2011-03-31 23:25:41 +07:00
|
|
|
struct nlattr *sinfoattr, *bss_param;
|
2007-12-19 08:03:36 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_STATION);
|
2007-12-19 08:03:36 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_GENERATION, sinfo->generation))
|
|
|
|
goto nla_put_failure;
|
2009-08-07 21:17:38 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
sinfoattr = nla_nest_start(msg, NL80211_ATTR_STA_INFO);
|
|
|
|
if (!sinfoattr)
|
2007-12-19 08:03:36 +07:00
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_CONNECTED_TIME) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_CONNECTED_TIME,
|
|
|
|
sinfo->connected_time))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_INACTIVE_TIME) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_INACTIVE_TIME,
|
|
|
|
sinfo->inactive_time))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_RX_BYTES) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_RX_BYTES,
|
|
|
|
sinfo->rx_bytes))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_TX_BYTES) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_TX_BYTES,
|
|
|
|
sinfo->tx_bytes))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_LLID) &&
|
|
|
|
nla_put_u16(msg, NL80211_STA_INFO_LLID, sinfo->llid))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_PLID) &&
|
|
|
|
nla_put_u16(msg, NL80211_STA_INFO_PLID, sinfo->plid))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_PLINK_STATE) &&
|
|
|
|
nla_put_u8(msg, NL80211_STA_INFO_PLINK_STATE,
|
|
|
|
sinfo->plink_state))
|
|
|
|
goto nla_put_failure;
|
2012-03-16 00:25:41 +07:00
|
|
|
switch (rdev->wiphy.signal_type) {
|
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_SIGNAL) &&
|
|
|
|
nla_put_u8(msg, NL80211_STA_INFO_SIGNAL,
|
|
|
|
sinfo->signal))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_SIGNAL_AVG) &&
|
|
|
|
nla_put_u8(msg, NL80211_STA_INFO_SIGNAL_AVG,
|
|
|
|
sinfo->signal_avg))
|
|
|
|
goto nla_put_failure;
|
2012-03-16 00:25:41 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-12 04:04:19 +07:00
|
|
|
if (sinfo->filled & STATION_INFO_TX_BITRATE) {
|
2011-02-28 04:08:00 +07:00
|
|
|
if (!nl80211_put_sta_rate(msg, &sinfo->txrate,
|
|
|
|
NL80211_STA_INFO_TX_BITRATE))
|
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
|
|
|
if (sinfo->filled & STATION_INFO_RX_BITRATE) {
|
|
|
|
if (!nl80211_put_sta_rate(msg, &sinfo->rxrate,
|
|
|
|
NL80211_STA_INFO_RX_BITRATE))
|
2008-12-12 04:04:19 +07:00
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_RX_PACKETS) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_RX_PACKETS,
|
|
|
|
sinfo->rx_packets))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_TX_PACKETS) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_TX_PACKETS,
|
|
|
|
sinfo->tx_packets))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_TX_RETRIES) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_TX_RETRIES,
|
|
|
|
sinfo->tx_retries))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_TX_FAILED) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_TX_FAILED,
|
|
|
|
sinfo->tx_failed))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((sinfo->filled & STATION_INFO_BEACON_LOSS_COUNT) &&
|
|
|
|
nla_put_u32(msg, NL80211_STA_INFO_BEACON_LOSS,
|
|
|
|
sinfo->beacon_loss_count))
|
|
|
|
goto nla_put_failure;
|
2011-03-31 23:25:41 +07:00
|
|
|
if (sinfo->filled & STATION_INFO_BSS_PARAM) {
|
|
|
|
bss_param = nla_nest_start(msg, NL80211_STA_INFO_BSS_PARAM);
|
|
|
|
if (!bss_param)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (((sinfo->bss_param.flags & BSS_PARAM_FLAGS_CTS_PROT) &&
|
|
|
|
nla_put_flag(msg, NL80211_STA_BSS_PARAM_CTS_PROT)) ||
|
|
|
|
((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_PREAMBLE) &&
|
|
|
|
nla_put_flag(msg, NL80211_STA_BSS_PARAM_SHORT_PREAMBLE)) ||
|
|
|
|
((sinfo->bss_param.flags & BSS_PARAM_FLAGS_SHORT_SLOT_TIME) &&
|
|
|
|
nla_put_flag(msg, NL80211_STA_BSS_PARAM_SHORT_SLOT_TIME)) ||
|
|
|
|
nla_put_u8(msg, NL80211_STA_BSS_PARAM_DTIM_PERIOD,
|
|
|
|
sinfo->bss_param.dtim_period) ||
|
|
|
|
nla_put_u16(msg, NL80211_STA_BSS_PARAM_BEACON_INTERVAL,
|
|
|
|
sinfo->bss_param.beacon_interval))
|
|
|
|
goto nla_put_failure;
|
2011-03-31 23:25:41 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, bss_param);
|
|
|
|
}
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_STA_FLAGS) &&
|
|
|
|
nla_put(msg, NL80211_STA_INFO_STA_FLAGS,
|
|
|
|
sizeof(struct nl80211_sta_flag_update),
|
|
|
|
&sinfo->sta_flags))
|
|
|
|
goto nla_put_failure;
|
2012-04-13 01:25:14 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_T_OFFSET) &&
|
|
|
|
nla_put_u64(msg, NL80211_STA_INFO_T_OFFSET,
|
|
|
|
sinfo->t_offset))
|
|
|
|
goto nla_put_failure;
|
2008-02-23 21:17:06 +07:00
|
|
|
nla_nest_end(msg, sinfoattr);
|
2007-12-19 08:03:36 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((sinfo->filled & STATION_INFO_ASSOC_REQ_IES) &&
|
|
|
|
nla_put(msg, NL80211_ATTR_IE, sinfo->assoc_req_ies_len,
|
|
|
|
sinfo->assoc_req_ies))
|
|
|
|
goto nla_put_failure;
|
2011-08-08 16:11:52 +07:00
|
|
|
|
2007-12-19 08:03:36 +07:00
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
2008-06-04 06:36:54 +07:00
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
2007-12-19 08:03:36 +07:00
|
|
|
}
|
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
static int nl80211_dump_station(struct sk_buff *skb,
|
2008-07-29 18:22:51 +07:00
|
|
|
struct netlink_callback *cb)
|
2008-02-23 21:17:06 +07:00
|
|
|
{
|
|
|
|
struct station_info sinfo;
|
|
|
|
struct cfg80211_registered_device *dev;
|
2008-07-29 18:22:51 +07:00
|
|
|
struct net_device *netdev;
|
2008-02-23 21:17:06 +07:00
|
|
|
u8 mac_addr[ETH_ALEN];
|
2008-07-29 18:22:51 +07:00
|
|
|
int sta_idx = cb->args[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
int err;
|
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
err = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2008-07-29 18:22:51 +07:00
|
|
|
|
|
|
|
if (!dev->ops->dump_station) {
|
2009-03-21 02:21:19 +07:00
|
|
|
err = -EOPNOTSUPP;
|
2008-07-29 18:22:51 +07:00
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
2011-08-11 15:46:22 +07:00
|
|
|
memset(&sinfo, 0, sizeof(sinfo));
|
2008-07-29 18:22:51 +07:00
|
|
|
err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx,
|
|
|
|
mac_addr, &sinfo);
|
|
|
|
if (err == -ENOENT)
|
|
|
|
break;
|
|
|
|
if (err)
|
2009-03-12 15:55:09 +07:00
|
|
|
goto out_err;
|
2008-07-29 18:22:51 +07:00
|
|
|
|
|
|
|
if (nl80211_send_station(skb,
|
2012-09-08 03:12:54 +07:00
|
|
|
NETLINK_CB(cb->skb).portid,
|
2008-07-29 18:22:51 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
2012-03-16 00:25:41 +07:00
|
|
|
dev, netdev, mac_addr,
|
2008-07-29 18:22:51 +07:00
|
|
|
&sinfo) < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
sta_idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
cb->args[1] = sta_idx;
|
|
|
|
err = skb->len;
|
|
|
|
out_err:
|
2010-10-05 02:14:06 +07:00
|
|
|
nl80211_finish_netdev_dump(dev);
|
2008-07-29 18:22:51 +07:00
|
|
|
|
|
|
|
return err;
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
2007-12-19 08:03:36 +07:00
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
struct station_info sinfo;
|
2007-12-19 08:03:36 +07:00
|
|
|
struct sk_buff *msg;
|
|
|
|
u8 *mac_addr = NULL;
|
2010-10-05 02:36:35 +07:00
|
|
|
int err;
|
2007-12-19 08:03:36 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
memset(&sinfo, 0, sizeof(sinfo));
|
2007-12-19 08:03:36 +07:00
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->get_station)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
err = rdev->ops->get_station(&rdev->wiphy, dev, mac_addr, &sinfo);
|
2007-12-19 08:03:36 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2007-12-19 08:03:36 +07:00
|
|
|
if (!msg)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -ENOMEM;
|
2007-12-19 08:03:36 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_station(msg, info->snd_portid, info->snd_seq, 0,
|
2012-03-16 00:25:41 +07:00
|
|
|
rdev, dev, mac_addr, &sinfo) < 0) {
|
2010-10-05 02:36:35 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2007-12-19 08:03:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2009-11-11 23:23:31 +07:00
|
|
|
* Get vlan interface making sure it is running and on the right wiphy.
|
2007-12-19 08:03:34 +07:00
|
|
|
*/
|
2011-11-18 22:23:01 +07:00
|
|
|
static struct net_device *get_vlan(struct genl_info *info,
|
|
|
|
struct cfg80211_registered_device *rdev)
|
2007-12-19 08:03:34 +07:00
|
|
|
{
|
2009-07-14 05:33:35 +07:00
|
|
|
struct nlattr *vlanattr = info->attrs[NL80211_ATTR_STA_VLAN];
|
2011-11-18 22:23:01 +07:00
|
|
|
struct net_device *v;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!vlanattr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
v = dev_get_by_index(genl_info_net(info), nla_get_u32(vlanattr));
|
|
|
|
if (!v)
|
|
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
|
|
|
|
if (!v->ieee80211_ptr || v->ieee80211_ptr->wiphy != &rdev->wiphy) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
2007-12-19 08:03:34 +07:00
|
|
|
}
|
2011-11-18 22:23:01 +07:00
|
|
|
|
|
|
|
if (!netif_running(v)) {
|
|
|
|
ret = -ENETDOWN;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return v;
|
|
|
|
error:
|
|
|
|
dev_put(v);
|
|
|
|
return ERR_PTR(ret);
|
2007-12-19 08:03:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2007-12-19 08:03:34 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:34 +07:00
|
|
|
struct station_parameters params;
|
|
|
|
u8 *mac_addr = NULL;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
params.listen_interval = -1;
|
2011-05-14 00:45:43 +07:00
|
|
|
params.plink_state = -1;
|
2007-12-19 08:03:34 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_STA_AID])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]) {
|
|
|
|
params.supported_rates =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
|
|
|
|
params.supported_rates_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
|
|
|
|
params.listen_interval =
|
|
|
|
nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
|
|
|
|
|
2008-08-25 15:58:58 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
|
|
|
|
params.ht_capa =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
|
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
if (!rdev->ops->change_station)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-01-02 19:30:03 +07:00
|
|
|
if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms))
|
2007-12-19 08:03:34 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
|
|
|
|
params.plink_action =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
|
|
|
|
|
2011-05-04 06:57:11 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_STA_PLINK_STATE])
|
|
|
|
params.plink_state =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_STATE]);
|
|
|
|
|
2009-06-18 22:23:43 +07:00
|
|
|
switch (dev->ieee80211_ptr->iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
2010-09-16 19:58:22 +07:00
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
2009-06-18 22:23:43 +07:00
|
|
|
/* disallow mesh-specific things */
|
|
|
|
if (params.plink_action)
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* TDLS can't be set, ... */
|
|
|
|
if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
|
|
|
|
return -EINVAL;
|
|
|
|
/*
|
|
|
|
* ... but don't bother the driver with it. This works around
|
|
|
|
* a hostapd/wpa_supplicant issue -- it always includes the
|
|
|
|
* TLDS_PEER flag in the mask even for AP mode.
|
|
|
|
*/
|
|
|
|
params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER);
|
|
|
|
|
|
|
|
/* accept only the listed bits */
|
|
|
|
if (params.sta_flags_mask &
|
|
|
|
~(BIT(NL80211_STA_FLAG_AUTHORIZED) |
|
|
|
|
BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
|
|
|
|
BIT(NL80211_STA_FLAG_WME) |
|
|
|
|
BIT(NL80211_STA_FLAG_MFP)))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* must be last in here for error handling */
|
|
|
|
params.vlan = get_vlan(info, rdev);
|
|
|
|
if (IS_ERR(params.vlan))
|
|
|
|
return PTR_ERR(params.vlan);
|
2009-06-18 22:23:43 +07:00
|
|
|
break;
|
2010-09-16 19:58:22 +07:00
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
2009-06-18 22:23:43 +07:00
|
|
|
case NL80211_IFTYPE_STATION:
|
2011-12-14 18:20:27 +07:00
|
|
|
/*
|
|
|
|
* Don't allow userspace to change the TDLS_PEER flag,
|
|
|
|
* but silently ignore attempts to change it since we
|
|
|
|
* don't have state here to verify that it doesn't try
|
|
|
|
* to change the flag.
|
|
|
|
*/
|
|
|
|
params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER);
|
2012-02-01 02:25:47 +07:00
|
|
|
/* fall through */
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
/* disallow things sta doesn't support */
|
|
|
|
if (params.plink_action)
|
|
|
|
return -EINVAL;
|
|
|
|
if (params.ht_capa)
|
|
|
|
return -EINVAL;
|
|
|
|
if (params.listen_interval >= 0)
|
|
|
|
return -EINVAL;
|
2011-12-14 18:20:27 +07:00
|
|
|
/* reject any changes other than AUTHORIZED */
|
|
|
|
if (params.sta_flags_mask & ~BIT(NL80211_STA_FLAG_AUTHORIZED))
|
|
|
|
return -EINVAL;
|
2009-06-18 22:23:43 +07:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
/* disallow things mesh doesn't support */
|
|
|
|
if (params.vlan)
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EINVAL;
|
2009-06-18 22:23:43 +07:00
|
|
|
if (params.ht_capa)
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EINVAL;
|
2009-06-18 22:23:43 +07:00
|
|
|
if (params.listen_interval >= 0)
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EINVAL;
|
|
|
|
/*
|
|
|
|
* No special handling for TDLS here -- the userspace
|
|
|
|
* mesh code doesn't have this bug.
|
|
|
|
*/
|
2011-04-08 05:08:30 +07:00
|
|
|
if (params.sta_flags_mask &
|
|
|
|
~(BIT(NL80211_STA_FLAG_AUTHENTICATED) |
|
2011-05-04 06:57:13 +07:00
|
|
|
BIT(NL80211_STA_FLAG_MFP) |
|
2011-04-08 05:08:30 +07:00
|
|
|
BIT(NL80211_STA_FLAG_AUTHORIZED)))
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EINVAL;
|
2009-06-18 22:23:43 +07:00
|
|
|
break;
|
|
|
|
default:
|
2011-12-14 18:20:27 +07:00
|
|
|
return -EOPNOTSUPP;
|
2009-05-27 15:35:29 +07:00
|
|
|
}
|
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
/* be aware of params.vlan when changing code here */
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
err = rdev->ops->change_station(&rdev->wiphy, dev, mac_addr, ¶ms);
|
2007-12-19 08:03:34 +07:00
|
|
|
|
|
|
|
if (params.vlan)
|
|
|
|
dev_put(params.vlan);
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-08-23 18:37:46 +07:00
|
|
|
static struct nla_policy
|
|
|
|
nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] __read_mostly = {
|
|
|
|
[NL80211_STA_WME_UAPSD_QUEUES] = { .type = NLA_U8 },
|
|
|
|
[NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 },
|
|
|
|
};
|
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2007-12-19 08:03:34 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:34 +07:00
|
|
|
struct station_parameters params;
|
|
|
|
u8 *mac_addr = NULL;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-02-12 21:34:50 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_STA_AID])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-12-19 08:03:34 +07:00
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
params.supported_rates =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
|
|
|
|
params.supported_rates_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_STA_SUPPORTED_RATES]);
|
|
|
|
params.listen_interval =
|
|
|
|
nla_get_u16(info->attrs[NL80211_ATTR_STA_LISTEN_INTERVAL]);
|
2009-05-24 21:42:30 +07:00
|
|
|
|
2010-02-12 21:34:50 +07:00
|
|
|
params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
|
|
|
|
if (!params.aid || params.aid > IEEE80211_MAX_AID)
|
|
|
|
return -EINVAL;
|
2009-05-24 21:42:30 +07:00
|
|
|
|
2008-08-25 15:58:58 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
|
|
|
|
params.ht_capa =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2012-10-11 15:04:52 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY])
|
|
|
|
params.vht_capa =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
|
|
|
|
|
2011-04-08 05:08:33 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
|
|
|
|
params.plink_action =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]);
|
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
if (!rdev->ops->add_station)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-01-02 19:30:03 +07:00
|
|
|
if (parse_station_flags(info, dev->ieee80211_ptr->iftype, ¶ms))
|
2007-12-19 08:03:34 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
switch (dev->ieee80211_ptr->iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
|
|
|
/* parse WME attributes if sta is WME capable */
|
|
|
|
if ((rdev->wiphy.flags & WIPHY_FLAG_AP_UAPSD) &&
|
|
|
|
(params.sta_flags_set & BIT(NL80211_STA_FLAG_WME)) &&
|
|
|
|
info->attrs[NL80211_ATTR_STA_WME]) {
|
|
|
|
struct nlattr *tb[NL80211_STA_WME_MAX + 1];
|
|
|
|
struct nlattr *nla;
|
|
|
|
|
|
|
|
nla = info->attrs[NL80211_ATTR_STA_WME];
|
|
|
|
err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla,
|
|
|
|
nl80211_sta_wme_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (tb[NL80211_STA_WME_UAPSD_QUEUES])
|
|
|
|
params.uapsd_queues =
|
|
|
|
nla_get_u8(tb[NL80211_STA_WME_UAPSD_QUEUES]);
|
|
|
|
if (params.uapsd_queues &
|
|
|
|
~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
|
|
|
|
return -EINVAL;
|
2011-08-23 18:37:46 +07:00
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
if (tb[NL80211_STA_WME_MAX_SP])
|
|
|
|
params.max_sp =
|
|
|
|
nla_get_u8(tb[NL80211_STA_WME_MAX_SP]);
|
2011-08-23 18:37:46 +07:00
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
if (params.max_sp &
|
|
|
|
~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK)
|
|
|
|
return -EINVAL;
|
2011-09-07 16:50:48 +07:00
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
params.sta_modify_mask |= STATION_PARAM_APPLY_UAPSD;
|
|
|
|
}
|
|
|
|
/* TDLS peers cannot be added */
|
|
|
|
if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
|
2011-09-07 16:50:48 +07:00
|
|
|
return -EINVAL;
|
2011-12-14 18:20:27 +07:00
|
|
|
/* but don't bother the driver with it */
|
|
|
|
params.sta_flags_mask &= ~BIT(NL80211_STA_FLAG_TDLS_PEER);
|
2011-09-28 01:56:12 +07:00
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
/* must be last in here for error handling */
|
|
|
|
params.vlan = get_vlan(info, rdev);
|
|
|
|
if (IS_ERR(params.vlan))
|
|
|
|
return PTR_ERR(params.vlan);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
/* TDLS peers cannot be added */
|
|
|
|
if (params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER))
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
/* Only TDLS peers can be added */
|
|
|
|
if (!(params.sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)))
|
|
|
|
return -EINVAL;
|
|
|
|
/* Can only add if TDLS ... */
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
/* ... with external setup is supported */
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_TDLS_EXTERNAL_SETUP))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
2011-08-23 18:37:46 +07:00
|
|
|
}
|
|
|
|
|
2011-12-14 18:20:27 +07:00
|
|
|
/* be aware of params.vlan when changing code here */
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
err = rdev->ops->add_station(&rdev->wiphy, dev, mac_addr, ¶ms);
|
2007-12-19 08:03:34 +07:00
|
|
|
|
|
|
|
if (params.vlan)
|
|
|
|
dev_put(params.vlan);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2007-12-19 08:03:34 +07:00
|
|
|
u8 *mac_addr = NULL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2009-05-11 19:43:13 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
|
2010-03-30 15:00:16 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP_VLAN &&
|
2010-09-16 19:58:22 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EINVAL;
|
2007-12-19 08:03:34 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->del_station)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->del_station(&rdev->wiphy, dev, mac_addr);
|
2007-12-19 08:03:34 +07:00
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq,
|
2008-02-23 21:17:06 +07:00
|
|
|
int flags, struct net_device *dev,
|
|
|
|
u8 *dst, u8 *next_hop,
|
|
|
|
struct mpath_info *pinfo)
|
|
|
|
{
|
|
|
|
void *hdr;
|
|
|
|
struct nlattr *pinfoattr;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, NL80211_CMD_NEW_STATION);
|
2008-02-23 21:17:06 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, dst) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MPATH_NEXT_HOP, ETH_ALEN, next_hop) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_GENERATION, pinfo->generation))
|
|
|
|
goto nla_put_failure;
|
2009-08-07 21:17:38 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
pinfoattr = nla_nest_start(msg, NL80211_ATTR_MPATH_INFO);
|
|
|
|
if (!pinfoattr)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((pinfo->filled & MPATH_INFO_FRAME_QLEN) &&
|
|
|
|
nla_put_u32(msg, NL80211_MPATH_INFO_FRAME_QLEN,
|
|
|
|
pinfo->frame_qlen))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (((pinfo->filled & MPATH_INFO_SN) &&
|
|
|
|
nla_put_u32(msg, NL80211_MPATH_INFO_SN, pinfo->sn)) ||
|
|
|
|
((pinfo->filled & MPATH_INFO_METRIC) &&
|
|
|
|
nla_put_u32(msg, NL80211_MPATH_INFO_METRIC,
|
|
|
|
pinfo->metric)) ||
|
|
|
|
((pinfo->filled & MPATH_INFO_EXPTIME) &&
|
|
|
|
nla_put_u32(msg, NL80211_MPATH_INFO_EXPTIME,
|
|
|
|
pinfo->exptime)) ||
|
|
|
|
((pinfo->filled & MPATH_INFO_FLAGS) &&
|
|
|
|
nla_put_u8(msg, NL80211_MPATH_INFO_FLAGS,
|
|
|
|
pinfo->flags)) ||
|
|
|
|
((pinfo->filled & MPATH_INFO_DISCOVERY_TIMEOUT) &&
|
|
|
|
nla_put_u32(msg, NL80211_MPATH_INFO_DISCOVERY_TIMEOUT,
|
|
|
|
pinfo->discovery_timeout)) ||
|
|
|
|
((pinfo->filled & MPATH_INFO_DISCOVERY_RETRIES) &&
|
|
|
|
nla_put_u8(msg, NL80211_MPATH_INFO_DISCOVERY_RETRIES,
|
|
|
|
pinfo->discovery_retries)))
|
|
|
|
goto nla_put_failure;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, pinfoattr);
|
|
|
|
|
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
2008-06-04 06:36:54 +07:00
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_dump_mpath(struct sk_buff *skb,
|
2008-07-29 18:22:51 +07:00
|
|
|
struct netlink_callback *cb)
|
2008-02-23 21:17:06 +07:00
|
|
|
{
|
|
|
|
struct mpath_info pinfo;
|
|
|
|
struct cfg80211_registered_device *dev;
|
2008-07-29 18:22:51 +07:00
|
|
|
struct net_device *netdev;
|
2008-02-23 21:17:06 +07:00
|
|
|
u8 dst[ETH_ALEN];
|
|
|
|
u8 next_hop[ETH_ALEN];
|
2008-07-29 18:22:51 +07:00
|
|
|
int path_idx = cb->args[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
int err;
|
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
err = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2008-07-29 18:22:51 +07:00
|
|
|
|
|
|
|
if (!dev->ops->dump_mpath) {
|
2009-03-21 02:21:19 +07:00
|
|
|
err = -EOPNOTSUPP;
|
2008-07-29 18:22:51 +07:00
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
2009-03-21 02:21:19 +07:00
|
|
|
if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) {
|
|
|
|
err = -EOPNOTSUPP;
|
2009-08-23 02:15:49 +07:00
|
|
|
goto out_err;
|
2009-03-21 02:21:19 +07:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:22:51 +07:00
|
|
|
while (1) {
|
|
|
|
err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx,
|
|
|
|
dst, next_hop, &pinfo);
|
|
|
|
if (err == -ENOENT)
|
2008-02-23 21:17:06 +07:00
|
|
|
break;
|
2008-07-29 18:22:51 +07:00
|
|
|
if (err)
|
2009-03-12 15:55:09 +07:00
|
|
|
goto out_err;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid,
|
2008-07-29 18:22:51 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
|
|
|
netdev, dst, next_hop,
|
|
|
|
&pinfo) < 0)
|
|
|
|
goto out;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2008-07-29 18:22:51 +07:00
|
|
|
path_idx++;
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-29 18:22:51 +07:00
|
|
|
out:
|
|
|
|
cb->args[1] = path_idx;
|
|
|
|
err = skb->len;
|
|
|
|
out_err:
|
2010-10-05 02:14:06 +07:00
|
|
|
nl80211_finish_netdev_dump(dev);
|
2008-07-29 18:22:51 +07:00
|
|
|
return err;
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2008-02-23 21:17:06 +07:00
|
|
|
int err;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
struct mpath_info pinfo;
|
|
|
|
struct sk_buff *msg;
|
|
|
|
u8 *dst = NULL;
|
|
|
|
u8 next_hop[ETH_ALEN];
|
|
|
|
|
|
|
|
memset(&pinfo, 0, sizeof(pinfo));
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->get_mpath)
|
|
|
|
return -EOPNOTSUPP;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:19 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
err = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, &pinfo);
|
2008-02-23 21:17:06 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2008-02-23 21:17:06 +07:00
|
|
|
if (!msg)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -ENOMEM;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0,
|
2010-10-05 02:36:35 +07:00
|
|
|
dev, dst, next_hop, &pinfo) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
u8 *dst = NULL;
|
|
|
|
u8 *next_hop = NULL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->change_mpath)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:18 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EOPNOTSUPP;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop);
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
2010-10-05 02:36:35 +07:00
|
|
|
|
2008-02-23 21:17:06 +07:00
|
|
|
static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
u8 *dst = NULL;
|
|
|
|
u8 *next_hop = NULL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MPATH_NEXT_HOP])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->add_mpath)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:18 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EOPNOTSUPP;
|
2008-02-23 21:17:06 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop);
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-02-23 21:17:06 +07:00
|
|
|
u8 *dst = NULL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
dst = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->del_mpath)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->del_mpath(&rdev->wiphy, dev, dst);
|
2008-02-23 21:17:06 +07:00
|
|
|
}
|
|
|
|
|
2008-08-08 00:07:01 +07:00
|
|
|
static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2008-08-08 00:07:01 +07:00
|
|
|
struct bss_parameters params;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
/* default to not changing parameters */
|
|
|
|
params.use_cts_prot = -1;
|
|
|
|
params.use_short_preamble = -1;
|
|
|
|
params.use_short_slot_time = -1;
|
2010-04-27 06:23:35 +07:00
|
|
|
params.ap_isolate = -1;
|
2010-11-19 18:40:25 +07:00
|
|
|
params.ht_opmode = -1;
|
2008-08-08 00:07:01 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_BSS_CTS_PROT])
|
|
|
|
params.use_cts_prot =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_BSS_CTS_PROT]);
|
|
|
|
if (info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE])
|
|
|
|
params.use_short_preamble =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
|
|
|
|
if (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME])
|
|
|
|
params.use_short_slot_time =
|
|
|
|
nla_get_u8(info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME]);
|
2008-10-30 21:59:22 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
|
|
|
|
params.basic_rates =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
|
|
|
|
params.basic_rates_len =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
|
|
|
|
}
|
2010-04-27 06:23:35 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_AP_ISOLATE])
|
|
|
|
params.ap_isolate = !!nla_get_u8(info->attrs[NL80211_ATTR_AP_ISOLATE]);
|
2010-11-19 18:40:25 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_BSS_HT_OPMODE])
|
|
|
|
params.ht_opmode =
|
|
|
|
nla_get_u16(info->attrs[NL80211_ATTR_BSS_HT_OPMODE]);
|
2008-08-08 00:07:01 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->change_bss)
|
|
|
|
return -EOPNOTSUPP;
|
2008-08-08 00:07:01 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->change_bss(&rdev->wiphy, dev, ¶ms);
|
2008-08-08 00:07:01 +07:00
|
|
|
}
|
|
|
|
|
2010-02-18 15:14:31 +07:00
|
|
|
static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = {
|
2008-09-10 13:19:48 +07:00
|
|
|
[NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int parse_reg_rule(struct nlattr *tb[],
|
|
|
|
struct ieee80211_reg_rule *reg_rule)
|
|
|
|
{
|
|
|
|
struct ieee80211_freq_range *freq_range = ®_rule->freq_range;
|
|
|
|
struct ieee80211_power_rule *power_rule = ®_rule->power_rule;
|
|
|
|
|
|
|
|
if (!tb[NL80211_ATTR_REG_RULE_FLAGS])
|
|
|
|
return -EINVAL;
|
|
|
|
if (!tb[NL80211_ATTR_FREQ_RANGE_START])
|
|
|
|
return -EINVAL;
|
|
|
|
if (!tb[NL80211_ATTR_FREQ_RANGE_END])
|
|
|
|
return -EINVAL;
|
|
|
|
if (!tb[NL80211_ATTR_FREQ_RANGE_MAX_BW])
|
|
|
|
return -EINVAL;
|
|
|
|
if (!tb[NL80211_ATTR_POWER_RULE_MAX_EIRP])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
reg_rule->flags = nla_get_u32(tb[NL80211_ATTR_REG_RULE_FLAGS]);
|
|
|
|
|
|
|
|
freq_range->start_freq_khz =
|
|
|
|
nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]);
|
|
|
|
freq_range->end_freq_khz =
|
|
|
|
nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]);
|
|
|
|
freq_range->max_bandwidth_khz =
|
|
|
|
nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]);
|
|
|
|
|
|
|
|
power_rule->max_eirp =
|
|
|
|
nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_EIRP]);
|
|
|
|
|
|
|
|
if (tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN])
|
|
|
|
power_rule->max_antenna_gain =
|
|
|
|
nla_get_u32(tb[NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_req_set_reg(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
char *data = NULL;
|
2012-07-13 01:49:18 +07:00
|
|
|
enum nl80211_user_reg_hint_type user_reg_hint_type;
|
2008-09-10 13:19:48 +07:00
|
|
|
|
2009-02-21 12:04:22 +07:00
|
|
|
/*
|
|
|
|
* You should only get this when cfg80211 hasn't yet initialized
|
|
|
|
* completely when built-in to the kernel right between the time
|
|
|
|
* window between nl80211_init() and regulatory_init(), if that is
|
|
|
|
* even possible.
|
|
|
|
*/
|
|
|
|
mutex_lock(&cfg80211_mutex);
|
|
|
|
if (unlikely(!cfg80211_regdomain)) {
|
2009-02-21 12:04:30 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
return -EINPROGRESS;
|
2009-02-21 12:04:22 +07:00
|
|
|
}
|
2009-02-21 12:04:30 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2009-02-21 12:04:22 +07:00
|
|
|
|
2009-02-21 12:04:30 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
|
|
|
|
return -EINVAL;
|
2008-09-10 13:19:48 +07:00
|
|
|
|
|
|
|
data = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
|
|
|
|
|
2012-07-13 01:49:18 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE])
|
|
|
|
user_reg_hint_type =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_USER_REG_HINT_TYPE]);
|
|
|
|
else
|
|
|
|
user_reg_hint_type = NL80211_USER_REG_HINT_USER;
|
|
|
|
|
|
|
|
switch (user_reg_hint_type) {
|
|
|
|
case NL80211_USER_REG_HINT_USER:
|
|
|
|
case NL80211_USER_REG_HINT_CELL_BASE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = regulatory_hint_user(data, user_reg_hint_type);
|
2009-02-21 12:04:30 +07:00
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
static int nl80211_get_mesh_config(struct sk_buff *skb,
|
2010-12-03 15:20:44 +07:00
|
|
|
struct genl_info *info)
|
2008-10-22 02:03:48 +07:00
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2010-12-03 15:20:44 +07:00
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct mesh_config cur_params;
|
|
|
|
int err = 0;
|
2008-10-22 02:03:48 +07:00
|
|
|
void *hdr;
|
|
|
|
struct nlattr *pinfoattr;
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2010-12-03 15:20:44 +07:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
if (!rdev->ops->get_mesh_config)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EOPNOTSUPP;
|
2009-03-20 22:57:36 +07:00
|
|
|
|
2010-12-03 15:20:44 +07:00
|
|
|
wdev_lock(wdev);
|
|
|
|
/* If not connected, get default parameters */
|
|
|
|
if (!wdev->mesh_id_len)
|
|
|
|
memcpy(&cur_params, &default_mesh_config, sizeof(cur_params));
|
|
|
|
else
|
2010-12-17 08:37:48 +07:00
|
|
|
err = rdev->ops->get_mesh_config(&rdev->wiphy, dev,
|
2010-12-03 15:20:44 +07:00
|
|
|
&cur_params);
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
|
2008-10-22 02:03:48 +07:00
|
|
|
if (err)
|
2010-10-05 02:36:35 +07:00
|
|
|
return err;
|
2008-10-22 02:03:48 +07:00
|
|
|
|
|
|
|
/* Draw up a netlink message to send back */
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2010-12-17 08:37:48 +07:00
|
|
|
NL80211_CMD_GET_MESH_CONFIG);
|
2008-10-22 02:03:48 +07:00
|
|
|
if (!hdr)
|
2011-01-28 21:17:11 +07:00
|
|
|
goto out;
|
2010-12-17 08:37:48 +07:00
|
|
|
pinfoattr = nla_nest_start(msg, NL80211_ATTR_MESH_CONFIG);
|
2008-10-22 02:03:48 +07:00
|
|
|
if (!pinfoattr)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_RETRY_TIMEOUT,
|
|
|
|
cur_params.dot11MeshRetryTimeout) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_CONFIRM_TIMEOUT,
|
|
|
|
cur_params.dot11MeshConfirmTimeout) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HOLDING_TIMEOUT,
|
|
|
|
cur_params.dot11MeshHoldingTimeout) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
|
|
|
|
cur_params.dot11MeshMaxPeerLinks) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_MAX_RETRIES,
|
|
|
|
cur_params.dot11MeshMaxRetries) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_TTL,
|
|
|
|
cur_params.dot11MeshTTL) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_ELEMENT_TTL,
|
|
|
|
cur_params.element_ttl) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
|
|
|
|
cur_params.auto_open_plinks) ||
|
2012-04-13 01:25:14 +07:00
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
|
|
|
|
cur_params.dot11MeshNbrOffsetMaxNeighbor) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
|
|
|
|
cur_params.dot11MeshHWMPmaxPREQretries) ||
|
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_PATH_REFRESH_TIME,
|
|
|
|
cur_params.path_refresh_time) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
|
|
|
|
cur_params.min_discovery_timeout) ||
|
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
|
|
|
|
cur_params.dot11MeshHWMPactivePathTimeout) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
|
|
|
|
cur_params.dot11MeshHWMPpreqMinInterval) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
|
|
|
|
cur_params.dot11MeshHWMPperrMinInterval) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
|
|
|
|
cur_params.dot11MeshHWMPnetDiameterTraversalTime) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_HWMP_ROOTMODE,
|
|
|
|
cur_params.dot11MeshHWMPRootMode) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_RANN_INTERVAL,
|
|
|
|
cur_params.dot11MeshHWMPRannInterval) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
|
|
|
|
cur_params.dot11MeshGateAnnouncementProtocol) ||
|
|
|
|
nla_put_u8(msg, NL80211_MESHCONF_FORWARDING,
|
|
|
|
cur_params.dot11MeshForwarding) ||
|
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
|
2012-05-01 04:20:32 +07:00
|
|
|
cur_params.rssi_threshold) ||
|
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_HT_OPMODE,
|
2012-06-14 01:06:06 +07:00
|
|
|
cur_params.ht_opmode) ||
|
|
|
|
nla_put_u32(msg, NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
|
|
|
|
cur_params.dot11MeshHWMPactivePathToRootTimeout) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
|
2012-06-14 01:06:10 +07:00
|
|
|
cur_params.dot11MeshHWMProotInterval) ||
|
|
|
|
nla_put_u16(msg, NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
|
|
|
|
cur_params.dot11MeshHWMPconfirmationInterval))
|
2012-03-29 15:41:26 +07:00
|
|
|
goto nla_put_failure;
|
2008-10-22 02:03:48 +07:00
|
|
|
nla_nest_end(msg, pinfoattr);
|
|
|
|
genlmsg_end(msg, hdr);
|
2010-10-05 02:36:35 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
2008-10-22 02:03:48 +07:00
|
|
|
|
2009-03-12 15:55:09 +07:00
|
|
|
nla_put_failure:
|
2008-10-22 02:03:48 +07:00
|
|
|
genlmsg_cancel(msg, hdr);
|
2011-01-28 21:17:11 +07:00
|
|
|
out:
|
2010-06-29 18:08:07 +07:00
|
|
|
nlmsg_free(msg);
|
2010-10-05 02:36:35 +07:00
|
|
|
return -ENOBUFS;
|
2008-10-22 02:03:48 +07:00
|
|
|
}
|
|
|
|
|
2010-02-18 15:14:31 +07:00
|
|
|
static const struct nla_policy nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] = {
|
2008-10-22 02:03:48 +07:00
|
|
|
[NL80211_MESHCONF_RETRY_TIMEOUT] = { .type = NLA_U16 },
|
|
|
|
[NL80211_MESHCONF_CONFIRM_TIMEOUT] = { .type = NLA_U16 },
|
|
|
|
[NL80211_MESHCONF_HOLDING_TIMEOUT] = { .type = NLA_U16 },
|
|
|
|
[NL80211_MESHCONF_MAX_PEER_LINKS] = { .type = NLA_U16 },
|
|
|
|
[NL80211_MESHCONF_MAX_RETRIES] = { .type = NLA_U8 },
|
|
|
|
[NL80211_MESHCONF_TTL] = { .type = NLA_U8 },
|
2010-12-03 15:20:40 +07:00
|
|
|
[NL80211_MESHCONF_ELEMENT_TTL] = { .type = NLA_U8 },
|
2008-10-22 02:03:48 +07:00
|
|
|
[NL80211_MESHCONF_AUTO_OPEN_PLINKS] = { .type = NLA_U8 },
|
2012-04-01 01:31:33 +07:00
|
|
|
[NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR] = { .type = NLA_U32 },
|
2008-10-22 02:03:48 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES] = { .type = NLA_U8 },
|
|
|
|
[NL80211_MESHCONF_PATH_REFRESH_TIME] = { .type = NLA_U32 },
|
|
|
|
[NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT] = { .type = NLA_U16 },
|
|
|
|
[NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT] = { .type = NLA_U32 },
|
|
|
|
[NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL] = { .type = NLA_U16 },
|
2011-11-25 08:15:24 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL] = { .type = NLA_U16 },
|
2008-10-22 02:03:48 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME] = { .type = NLA_U16 },
|
2011-08-10 06:45:09 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_ROOTMODE] = { .type = NLA_U8 },
|
2011-08-10 06:45:10 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_RANN_INTERVAL] = { .type = NLA_U16 },
|
2011-08-10 06:45:11 +07:00
|
|
|
[NL80211_MESHCONF_GATE_ANNOUNCEMENTS] = { .type = NLA_U8 },
|
2012-01-21 00:02:16 +07:00
|
|
|
[NL80211_MESHCONF_FORWARDING] = { .type = NLA_U8 },
|
2012-06-11 10:59:36 +07:00
|
|
|
[NL80211_MESHCONF_RSSI_THRESHOLD] = { .type = NLA_U32 },
|
|
|
|
[NL80211_MESHCONF_HT_OPMODE] = { .type = NLA_U16 },
|
2012-06-14 01:06:06 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT] = { .type = NLA_U32 },
|
|
|
|
[NL80211_MESHCONF_HWMP_ROOT_INTERVAL] = { .type = NLA_U16 },
|
2012-06-14 01:06:10 +07:00
|
|
|
[NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL] = { .type = NLA_U16 },
|
2008-10-22 02:03:48 +07:00
|
|
|
};
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
static const struct nla_policy
|
|
|
|
nl80211_mesh_setup_params_policy[NL80211_MESH_SETUP_ATTR_MAX+1] = {
|
2012-04-01 01:31:33 +07:00
|
|
|
[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC] = { .type = NLA_U8 },
|
2010-12-17 08:37:49 +07:00
|
|
|
[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL] = { .type = NLA_U8 },
|
|
|
|
[NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC] = { .type = NLA_U8 },
|
2011-04-08 05:08:28 +07:00
|
|
|
[NL80211_MESH_SETUP_USERSPACE_AUTH] = { .type = NLA_FLAG },
|
2011-04-08 05:08:27 +07:00
|
|
|
[NL80211_MESH_SETUP_IE] = { .type = NLA_BINARY,
|
2012-06-11 10:59:36 +07:00
|
|
|
.len = IEEE80211_MAX_DATA_LEN },
|
2011-05-04 06:57:07 +07:00
|
|
|
[NL80211_MESH_SETUP_USERSPACE_AMPE] = { .type = NLA_FLAG },
|
2010-12-17 08:37:49 +07:00
|
|
|
};
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
static int nl80211_parse_mesh_config(struct genl_info *info,
|
2010-12-03 15:20:43 +07:00
|
|
|
struct mesh_config *cfg,
|
|
|
|
u32 *mask_out)
|
2008-10-22 02:03:48 +07:00
|
|
|
{
|
|
|
|
struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1];
|
2010-12-03 15:20:43 +07:00
|
|
|
u32 mask = 0;
|
2008-10-22 02:03:48 +07:00
|
|
|
|
2010-12-03 15:20:43 +07:00
|
|
|
#define FILL_IN_MESH_PARAM_IF_SET(table, cfg, param, mask, attr_num, nla_fn) \
|
|
|
|
do {\
|
|
|
|
if (table[attr_num]) {\
|
|
|
|
cfg->param = nla_fn(table[attr_num]); \
|
|
|
|
mask |= (1 << (attr_num - 1)); \
|
|
|
|
} \
|
|
|
|
} while (0);\
|
|
|
|
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
|
2008-10-22 02:03:48 +07:00
|
|
|
return -EINVAL;
|
|
|
|
if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
|
2010-12-17 08:37:48 +07:00
|
|
|
info->attrs[NL80211_ATTR_MESH_CONFIG],
|
2010-12-03 15:20:43 +07:00
|
|
|
nl80211_meshconf_params_policy))
|
2008-10-22 02:03:48 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* This makes sure that there aren't more than 32 mesh config
|
|
|
|
* parameters (otherwise our bitfield scheme would not work.) */
|
|
|
|
BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
|
|
|
|
|
|
|
|
/* Fill in the params struct */
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_RETRY_TIMEOUT,
|
|
|
|
nla_get_u16);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_CONFIRM_TIMEOUT,
|
|
|
|
nla_get_u16);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_HOLDING_TIMEOUT,
|
|
|
|
nla_get_u16);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_MAX_PEER_LINKS,
|
|
|
|
nla_get_u16);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_MAX_RETRIES,
|
|
|
|
nla_get_u8);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_TTL, nla_get_u8);
|
2010-12-03 15:20:40 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_ELEMENT_TTL,
|
|
|
|
nla_get_u8);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
|
|
|
|
nla_get_u8);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor, mask,
|
|
|
|
NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
|
|
|
|
nla_get_u32);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
|
|
|
|
nla_get_u8);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_PATH_REFRESH_TIME,
|
|
|
|
nla_get_u32);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
|
|
|
|
nla_get_u16);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout, mask,
|
|
|
|
NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
|
|
|
|
nla_get_u32);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
|
|
|
|
nla_get_u16);
|
2011-11-25 08:15:24 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
|
|
|
|
nla_get_u16);
|
2008-10-22 02:03:48 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
|
2012-06-11 10:59:36 +07:00
|
|
|
dot11MeshHWMPnetDiameterTraversalTime, mask,
|
|
|
|
NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
|
|
|
|
nla_get_u16);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask,
|
|
|
|
NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask,
|
|
|
|
NL80211_MESHCONF_HWMP_RANN_INTERVAL,
|
|
|
|
nla_get_u16);
|
2009-11-10 06:46:57 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
|
2012-06-11 10:59:36 +07:00
|
|
|
dot11MeshGateAnnouncementProtocol, mask,
|
|
|
|
NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
|
|
|
|
nla_get_u8);
|
2012-01-21 00:02:16 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_FORWARDING,
|
|
|
|
nla_get_u8);
|
2012-02-29 08:04:08 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_RSSI_THRESHOLD,
|
|
|
|
nla_get_u32);
|
2012-05-01 04:20:32 +07:00
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode,
|
2012-06-11 10:59:36 +07:00
|
|
|
mask, NL80211_MESHCONF_HT_OPMODE,
|
2012-06-14 01:06:06 +07:00
|
|
|
nla_get_u16);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout,
|
|
|
|
mask,
|
|
|
|
NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
|
|
|
|
nla_get_u32);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval,
|
|
|
|
mask, NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
|
2012-06-14 01:06:10 +07:00
|
|
|
nla_get_u16);
|
|
|
|
FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
|
|
|
|
dot11MeshHWMPconfirmationInterval, mask,
|
|
|
|
NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
|
2012-06-11 10:59:36 +07:00
|
|
|
nla_get_u16);
|
2010-12-03 15:20:43 +07:00
|
|
|
if (mask_out)
|
|
|
|
*mask_out = mask;
|
2010-12-17 08:37:49 +07:00
|
|
|
|
2010-12-03 15:20:43 +07:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
#undef FILL_IN_MESH_PARAM_IF_SET
|
|
|
|
}
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
static int nl80211_parse_mesh_setup(struct genl_info *info,
|
|
|
|
struct mesh_setup *setup)
|
|
|
|
{
|
|
|
|
struct nlattr *tb[NL80211_MESH_SETUP_ATTR_MAX + 1];
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MESH_SETUP])
|
|
|
|
return -EINVAL;
|
|
|
|
if (nla_parse_nested(tb, NL80211_MESH_SETUP_ATTR_MAX,
|
|
|
|
info->attrs[NL80211_ATTR_MESH_SETUP],
|
|
|
|
nl80211_mesh_setup_params_policy))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-04-01 01:31:33 +07:00
|
|
|
if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC])
|
|
|
|
setup->sync_method =
|
|
|
|
(nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_SYNC])) ?
|
|
|
|
IEEE80211_SYNC_METHOD_VENDOR :
|
|
|
|
IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET;
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL])
|
|
|
|
setup->path_sel_proto =
|
|
|
|
(nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_PATH_SEL])) ?
|
|
|
|
IEEE80211_PATH_PROTOCOL_VENDOR :
|
|
|
|
IEEE80211_PATH_PROTOCOL_HWMP;
|
|
|
|
|
|
|
|
if (tb[NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC])
|
|
|
|
setup->path_metric =
|
|
|
|
(nla_get_u8(tb[NL80211_MESH_SETUP_ENABLE_VENDOR_METRIC])) ?
|
|
|
|
IEEE80211_PATH_METRIC_VENDOR :
|
|
|
|
IEEE80211_PATH_METRIC_AIRTIME;
|
|
|
|
|
2011-04-08 05:08:27 +07:00
|
|
|
|
|
|
|
if (tb[NL80211_MESH_SETUP_IE]) {
|
2010-12-17 08:37:49 +07:00
|
|
|
struct nlattr *ieattr =
|
2011-04-08 05:08:27 +07:00
|
|
|
tb[NL80211_MESH_SETUP_IE];
|
2010-12-17 08:37:49 +07:00
|
|
|
if (!is_valid_ie_attr(ieattr))
|
|
|
|
return -EINVAL;
|
2011-04-08 05:08:27 +07:00
|
|
|
setup->ie = nla_data(ieattr);
|
|
|
|
setup->ie_len = nla_len(ieattr);
|
2010-12-17 08:37:49 +07:00
|
|
|
}
|
2011-05-04 06:57:07 +07:00
|
|
|
setup->is_authenticated = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AUTH]);
|
|
|
|
setup->is_secure = nla_get_flag(tb[NL80211_MESH_SETUP_USERSPACE_AMPE]);
|
2010-12-17 08:37:49 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
static int nl80211_update_mesh_config(struct sk_buff *skb,
|
2010-12-03 15:20:44 +07:00
|
|
|
struct genl_info *info)
|
2010-12-03 15:20:43 +07:00
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2010-12-03 15:20:44 +07:00
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
2010-12-03 15:20:43 +07:00
|
|
|
struct mesh_config cfg;
|
|
|
|
u32 mask;
|
|
|
|
int err;
|
|
|
|
|
2010-12-03 15:20:44 +07:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_MESH_POINT)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
if (!rdev->ops->update_mesh_config)
|
2010-12-03 15:20:43 +07:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
err = nl80211_parse_mesh_config(info, &cfg, &mask);
|
2010-12-03 15:20:43 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-12-03 15:20:44 +07:00
|
|
|
wdev_lock(wdev);
|
|
|
|
if (!wdev->mesh_id_len)
|
|
|
|
err = -ENOLINK;
|
|
|
|
|
|
|
|
if (!err)
|
2010-12-17 08:37:48 +07:00
|
|
|
err = rdev->ops->update_mesh_config(&rdev->wiphy, dev,
|
2010-12-03 15:20:44 +07:00
|
|
|
mask, &cfg);
|
|
|
|
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
|
|
|
|
return err;
|
2008-10-22 02:03:48 +07:00
|
|
|
}
|
|
|
|
|
2009-01-31 00:26:42 +07:00
|
|
|
static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr = NULL;
|
|
|
|
struct nlattr *nl_reg_rules;
|
|
|
|
unsigned int i;
|
|
|
|
int err = -EINVAL;
|
|
|
|
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
2009-01-31 00:26:42 +07:00
|
|
|
|
|
|
|
if (!cfg80211_regdomain)
|
|
|
|
goto out;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-01-31 00:26:42 +07:00
|
|
|
if (!msg) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2009-01-31 00:26:42 +07:00
|
|
|
NL80211_CMD_GET_REG);
|
|
|
|
if (!hdr)
|
2011-01-28 21:17:11 +07:00
|
|
|
goto put_failure;
|
2009-01-31 00:26:42 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_string(msg, NL80211_ATTR_REG_ALPHA2,
|
|
|
|
cfg80211_regdomain->alpha2) ||
|
|
|
|
(cfg80211_regdomain->dfs_region &&
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_DFS_REGION,
|
|
|
|
cfg80211_regdomain->dfs_region)))
|
|
|
|
goto nla_put_failure;
|
2009-01-31 00:26:42 +07:00
|
|
|
|
2012-07-13 01:49:18 +07:00
|
|
|
if (reg_last_request_cell_base() &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_USER_REG_HINT_TYPE,
|
|
|
|
NL80211_USER_REG_HINT_CELL_BASE))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2009-01-31 00:26:42 +07:00
|
|
|
nl_reg_rules = nla_nest_start(msg, NL80211_ATTR_REG_RULES);
|
|
|
|
if (!nl_reg_rules)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (i = 0; i < cfg80211_regdomain->n_reg_rules; i++) {
|
|
|
|
struct nlattr *nl_reg_rule;
|
|
|
|
const struct ieee80211_reg_rule *reg_rule;
|
|
|
|
const struct ieee80211_freq_range *freq_range;
|
|
|
|
const struct ieee80211_power_rule *power_rule;
|
|
|
|
|
|
|
|
reg_rule = &cfg80211_regdomain->reg_rules[i];
|
|
|
|
freq_range = ®_rule->freq_range;
|
|
|
|
power_rule = ®_rule->power_rule;
|
|
|
|
|
|
|
|
nl_reg_rule = nla_nest_start(msg, i);
|
|
|
|
if (!nl_reg_rule)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_REG_RULE_FLAGS,
|
|
|
|
reg_rule->flags) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_START,
|
|
|
|
freq_range->start_freq_khz) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_END,
|
|
|
|
freq_range->end_freq_khz) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_FREQ_RANGE_MAX_BW,
|
|
|
|
freq_range->max_bandwidth_khz) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN,
|
|
|
|
power_rule->max_antenna_gain) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_POWER_RULE_MAX_EIRP,
|
|
|
|
power_rule->max_eirp))
|
|
|
|
goto nla_put_failure;
|
2009-01-31 00:26:42 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, nl_reg_rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_reg_rules);
|
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
2009-07-10 16:51:34 +07:00
|
|
|
err = genlmsg_reply(msg, info);
|
2009-01-31 00:26:42 +07:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
2011-01-28 21:17:11 +07:00
|
|
|
put_failure:
|
2010-06-29 18:08:07 +07:00
|
|
|
nlmsg_free(msg);
|
2009-01-31 00:26:42 +07:00
|
|
|
err = -EMSGSIZE;
|
|
|
|
out:
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2009-01-31 00:26:42 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct nlattr *tb[NL80211_REG_RULE_ATTR_MAX + 1];
|
|
|
|
struct nlattr *nl_reg_rule;
|
|
|
|
char *alpha2 = NULL;
|
|
|
|
int rem_reg_rules = 0, r = 0;
|
|
|
|
u32 num_rules = 0, rule_idx = 0, size_of_regd;
|
2011-10-12 00:59:02 +07:00
|
|
|
u8 dfs_region = 0;
|
2008-09-10 13:19:48 +07:00
|
|
|
struct ieee80211_regdomain *rd = NULL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REG_ALPHA2])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REG_RULES])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
alpha2 = nla_data(info->attrs[NL80211_ATTR_REG_ALPHA2]);
|
|
|
|
|
2011-10-12 00:59:02 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_DFS_REGION])
|
|
|
|
dfs_region = nla_get_u8(info->attrs[NL80211_ATTR_DFS_REGION]);
|
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
|
|
|
|
rem_reg_rules) {
|
|
|
|
num_rules++;
|
|
|
|
if (num_rules > NL80211_MAX_SUPP_REG_RULES)
|
2009-05-14 04:04:39 +07:00
|
|
|
return -EINVAL;
|
2008-09-10 13:19:48 +07:00
|
|
|
}
|
|
|
|
|
2009-05-14 04:04:41 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
|
|
|
|
2009-05-14 04:04:40 +07:00
|
|
|
if (!reg_is_valid_request(alpha2)) {
|
|
|
|
r = -EINVAL;
|
|
|
|
goto bad_reg;
|
|
|
|
}
|
2008-09-10 13:19:48 +07:00
|
|
|
|
|
|
|
size_of_regd = sizeof(struct ieee80211_regdomain) +
|
|
|
|
(num_rules * sizeof(struct ieee80211_reg_rule));
|
|
|
|
|
|
|
|
rd = kzalloc(size_of_regd, GFP_KERNEL);
|
2009-05-14 04:04:40 +07:00
|
|
|
if (!rd) {
|
|
|
|
r = -ENOMEM;
|
|
|
|
goto bad_reg;
|
|
|
|
}
|
2008-09-10 13:19:48 +07:00
|
|
|
|
|
|
|
rd->n_reg_rules = num_rules;
|
|
|
|
rd->alpha2[0] = alpha2[0];
|
|
|
|
rd->alpha2[1] = alpha2[1];
|
|
|
|
|
2011-10-12 00:59:02 +07:00
|
|
|
/*
|
|
|
|
* Disable DFS master mode if the DFS region was
|
|
|
|
* not supported or known on this kernel.
|
|
|
|
*/
|
|
|
|
if (reg_supported_dfs_region(dfs_region))
|
|
|
|
rd->dfs_region = dfs_region;
|
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
|
|
|
|
rem_reg_rules) {
|
|
|
|
nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
|
|
|
|
nla_data(nl_reg_rule), nla_len(nl_reg_rule),
|
|
|
|
reg_rule_policy);
|
|
|
|
r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
|
|
|
|
if (r)
|
|
|
|
goto bad_reg;
|
|
|
|
|
|
|
|
rule_idx++;
|
|
|
|
|
2009-05-14 04:04:40 +07:00
|
|
|
if (rule_idx > NL80211_MAX_SUPP_REG_RULES) {
|
|
|
|
r = -EINVAL;
|
2008-09-10 13:19:48 +07:00
|
|
|
goto bad_reg;
|
2009-05-14 04:04:40 +07:00
|
|
|
}
|
2008-09-10 13:19:48 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(rule_idx != num_rules);
|
|
|
|
|
|
|
|
r = set_regdom(rd);
|
2009-05-14 04:04:41 +07:00
|
|
|
|
2009-02-21 12:04:21 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2009-05-14 04:04:40 +07:00
|
|
|
|
2008-09-10 13:19:48 +07:00
|
|
|
return r;
|
|
|
|
|
2008-10-25 01:32:20 +07:00
|
|
|
bad_reg:
|
2009-05-14 04:04:41 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2008-09-10 13:19:48 +07:00
|
|
|
kfree(rd);
|
2009-05-14 04:04:40 +07:00
|
|
|
return r;
|
2008-09-10 13:19:48 +07:00
|
|
|
}
|
|
|
|
|
2009-06-17 22:41:49 +07:00
|
|
|
static int validate_scan_freqs(struct nlattr *freqs)
|
|
|
|
{
|
|
|
|
struct nlattr *attr1, *attr2;
|
|
|
|
int n_channels = 0, tmp1, tmp2;
|
|
|
|
|
|
|
|
nla_for_each_nested(attr1, freqs, tmp1) {
|
|
|
|
n_channels++;
|
|
|
|
/*
|
|
|
|
* Some hardware has a limited channel list for
|
|
|
|
* scanning, and it is pretty much nonsensical
|
|
|
|
* to scan for a channel twice, so disallow that
|
|
|
|
* and don't require drivers to check that the
|
|
|
|
* channel list they get isn't longer than what
|
|
|
|
* they can scan, as long as they can scan all
|
|
|
|
* the channels they registered at once.
|
|
|
|
*/
|
|
|
|
nla_for_each_nested(attr2, freqs, tmp2)
|
|
|
|
if (attr1 != attr2 &&
|
|
|
|
nla_get_u32(attr1) == nla_get_u32(attr2))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n_channels;
|
|
|
|
}
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-19 00:17:03 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2009-02-11 03:25:55 +07:00
|
|
|
struct cfg80211_scan_request *request;
|
|
|
|
struct nlattr *attr;
|
|
|
|
struct wiphy *wiphy;
|
2009-06-17 22:41:49 +07:00
|
|
|
int err, tmp, n_ssids = 0, n_channels, i;
|
2009-02-17 00:39:13 +07:00
|
|
|
size_t ie_len;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
wiphy = &rdev->wiphy;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->scan)
|
|
|
|
return -EOPNOTSUPP;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (rdev->scan_req)
|
|
|
|
return -EBUSY;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
|
2009-06-17 22:41:49 +07:00
|
|
|
n_channels = validate_scan_freqs(
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!n_channels)
|
|
|
|
return -EINVAL;
|
2009-02-11 03:25:55 +07:00
|
|
|
} else {
|
2011-07-18 23:08:35 +07:00
|
|
|
enum ieee80211_band band;
|
2009-06-17 22:41:49 +07:00
|
|
|
n_channels = 0;
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++)
|
|
|
|
if (wiphy->bands[band])
|
|
|
|
n_channels += wiphy->bands[band]->n_channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
|
|
|
|
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp)
|
|
|
|
n_ssids++;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (n_ssids > wiphy->max_scan_ssids)
|
|
|
|
return -EINVAL;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-02-17 00:39:13 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IE])
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
else
|
|
|
|
ie_len = 0;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ie_len > wiphy->max_scan_ie_len)
|
|
|
|
return -EINVAL;
|
2009-03-31 17:12:05 +07:00
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
request = kzalloc(sizeof(*request)
|
2011-05-18 15:42:03 +07:00
|
|
|
+ sizeof(*request->ssids) * n_ssids
|
|
|
|
+ sizeof(*request->channels) * n_channels
|
2009-02-17 00:39:13 +07:00
|
|
|
+ ie_len, GFP_KERNEL);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!request)
|
|
|
|
return -ENOMEM;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
|
|
|
if (n_ssids)
|
2009-08-07 22:54:07 +07:00
|
|
|
request->ssids = (void *)&request->channels[n_channels];
|
2009-02-11 03:25:55 +07:00
|
|
|
request->n_ssids = n_ssids;
|
2009-02-17 00:39:13 +07:00
|
|
|
if (ie_len) {
|
|
|
|
if (request->ssids)
|
|
|
|
request->ie = (void *)(request->ssids + n_ssids);
|
|
|
|
else
|
|
|
|
request->ie = (void *)(request->channels + n_channels);
|
|
|
|
}
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-11-02 19:32:03 +07:00
|
|
|
i = 0;
|
2009-02-11 03:25:55 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
|
|
|
|
/* user specified, bail out if channel not found */
|
|
|
|
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_FREQUENCIES], tmp) {
|
2009-11-02 19:32:03 +07:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
|
|
|
|
chan = ieee80211_get_channel(wiphy, nla_get_u32(attr));
|
|
|
|
|
|
|
|
if (!chan) {
|
2009-02-11 03:25:55 +07:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
2009-11-02 19:32:03 +07:00
|
|
|
|
|
|
|
/* ignore disabled channels */
|
|
|
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
request->channels[i] = chan;
|
2009-02-11 03:25:55 +07:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else {
|
2011-07-18 23:08:35 +07:00
|
|
|
enum ieee80211_band band;
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
/* all channels */
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
|
|
|
|
int j;
|
|
|
|
if (!wiphy->bands[band])
|
|
|
|
continue;
|
|
|
|
for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
|
2009-11-02 19:32:03 +07:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
|
|
|
|
chan = &wiphy->bands[band]->channels[j];
|
|
|
|
|
|
|
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
request->channels[i] = chan;
|
2009-02-11 03:25:55 +07:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 19:32:03 +07:00
|
|
|
if (!i) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
request->n_channels = i;
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
i = 0;
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
|
|
|
|
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {
|
2011-06-08 00:42:26 +07:00
|
|
|
if (nla_len(attr) > IEEE80211_MAX_SSID_LEN) {
|
2009-02-11 03:25:55 +07:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
2011-06-08 00:42:26 +07:00
|
|
|
request->ssids[i].ssid_len = nla_len(attr);
|
2009-02-11 03:25:55 +07:00
|
|
|
memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-17 00:39:13 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
|
|
|
request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2009-04-01 16:58:36 +07:00
|
|
|
memcpy((void *)request->ie,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_IE]),
|
2009-02-17 00:39:13 +07:00
|
|
|
request->ie_len);
|
|
|
|
}
|
|
|
|
|
2011-07-18 23:08:35 +07:00
|
|
|
for (i = 0; i < IEEE80211_NUM_BANDS; i++)
|
2011-07-20 05:52:16 +07:00
|
|
|
if (wiphy->bands[i])
|
|
|
|
request->rates[i] =
|
|
|
|
(1 << wiphy->bands[i]->n_bitrates) - 1;
|
2011-07-18 23:08:35 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_SUPP_RATES]) {
|
|
|
|
nla_for_each_nested(attr,
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_SUPP_RATES],
|
|
|
|
tmp) {
|
|
|
|
enum ieee80211_band band = nla_type(attr);
|
|
|
|
|
2011-07-29 15:52:18 +07:00
|
|
|
if (band < 0 || band >= IEEE80211_NUM_BANDS) {
|
2011-07-18 23:08:35 +07:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
err = ieee80211_get_ratemask(wiphy->bands[band],
|
|
|
|
nla_data(attr),
|
|
|
|
nla_len(attr),
|
|
|
|
&request->rates[band]);
|
|
|
|
if (err)
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 11:03:32 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
|
2012-10-12 11:03:31 +07:00
|
|
|
request->flags = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_FLAGS]);
|
2012-10-12 11:03:34 +07:00
|
|
|
if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
|
|
|
|
!(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) ||
|
|
|
|
((request->flags & NL80211_SCAN_FLAG_FLUSH) &&
|
|
|
|
!(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) {
|
2012-10-12 11:03:32 +07:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
}
|
2012-10-12 11:03:31 +07:00
|
|
|
|
2011-09-25 16:23:30 +07:00
|
|
|
request->no_cck =
|
|
|
|
nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
|
|
|
|
|
2012-06-19 00:17:03 +07:00
|
|
|
request->wdev = wdev;
|
2009-07-07 08:56:12 +07:00
|
|
|
request->wiphy = &rdev->wiphy;
|
2012-10-12 11:03:34 +07:00
|
|
|
request->scan_start = jiffies;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
rdev->scan_req = request;
|
2012-06-19 00:17:03 +07:00
|
|
|
err = rdev->ops->scan(&rdev->wiphy, request);
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
if (!err) {
|
2012-06-19 00:17:03 +07:00
|
|
|
nl80211_send_scan_start(rdev, wdev);
|
|
|
|
if (wdev->netdev)
|
|
|
|
dev_hold(wdev->netdev);
|
2010-10-05 02:36:35 +07:00
|
|
|
} else {
|
2009-02-11 03:25:55 +07:00
|
|
|
out_free:
|
2009-07-07 08:56:12 +07:00
|
|
|
rdev->scan_req = NULL;
|
2009-02-11 03:25:55 +07:00
|
|
|
kfree(request);
|
|
|
|
}
|
2009-03-12 15:55:09 +07:00
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
static int nl80211_start_sched_scan(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_sched_scan_request *request;
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct nlattr *attr;
|
|
|
|
struct wiphy *wiphy;
|
2011-08-31 20:01:48 +07:00
|
|
|
int err, tmp, n_ssids = 0, n_match_sets = 0, n_channels, i;
|
2011-05-11 21:09:37 +07:00
|
|
|
u32 interval;
|
2011-05-11 21:09:35 +07:00
|
|
|
enum ieee80211_band band;
|
|
|
|
size_t ie_len;
|
2011-08-31 20:01:48 +07:00
|
|
|
struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
|
2011-05-11 21:09:35 +07:00
|
|
|
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
|
|
|
|
!rdev->ops->sched_scan_start)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-05-11 21:09:37 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_SCHED_SCAN_INTERVAL])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
interval = nla_get_u32(info->attrs[NL80211_ATTR_SCHED_SCAN_INTERVAL]);
|
|
|
|
if (interval == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
wiphy = &rdev->wiphy;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
|
|
|
|
n_channels = validate_scan_freqs(
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]);
|
|
|
|
if (!n_channels)
|
|
|
|
return -EINVAL;
|
|
|
|
} else {
|
|
|
|
n_channels = 0;
|
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++)
|
|
|
|
if (wiphy->bands[band])
|
|
|
|
n_channels += wiphy->bands[band]->n_channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
|
|
|
|
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS],
|
|
|
|
tmp)
|
|
|
|
n_ssids++;
|
|
|
|
|
2011-07-13 18:57:28 +07:00
|
|
|
if (n_ssids > wiphy->max_sched_scan_ssids)
|
2011-05-11 21:09:35 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2011-08-31 20:01:48 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
|
|
|
|
nla_for_each_nested(attr,
|
|
|
|
info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
|
|
|
|
tmp)
|
|
|
|
n_match_sets++;
|
|
|
|
|
|
|
|
if (n_match_sets > wiphy->max_match_sets)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IE])
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
else
|
|
|
|
ie_len = 0;
|
|
|
|
|
2011-07-13 18:57:29 +07:00
|
|
|
if (ie_len > wiphy->max_sched_scan_ie_len)
|
2011-05-11 21:09:35 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2011-06-30 12:32:41 +07:00
|
|
|
mutex_lock(&rdev->sched_scan_mtx);
|
|
|
|
|
|
|
|
if (rdev->sched_scan_req) {
|
|
|
|
err = -EINPROGRESS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
request = kzalloc(sizeof(*request)
|
2011-05-18 15:42:03 +07:00
|
|
|
+ sizeof(*request->ssids) * n_ssids
|
2011-08-31 20:01:48 +07:00
|
|
|
+ sizeof(*request->match_sets) * n_match_sets
|
2011-05-18 15:42:03 +07:00
|
|
|
+ sizeof(*request->channels) * n_channels
|
2011-05-11 21:09:35 +07:00
|
|
|
+ ie_len, GFP_KERNEL);
|
2011-06-30 12:32:41 +07:00
|
|
|
if (!request) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-05-11 21:09:35 +07:00
|
|
|
|
|
|
|
if (n_ssids)
|
|
|
|
request->ssids = (void *)&request->channels[n_channels];
|
|
|
|
request->n_ssids = n_ssids;
|
|
|
|
if (ie_len) {
|
|
|
|
if (request->ssids)
|
|
|
|
request->ie = (void *)(request->ssids + n_ssids);
|
|
|
|
else
|
|
|
|
request->ie = (void *)(request->channels + n_channels);
|
|
|
|
}
|
|
|
|
|
2011-08-31 20:01:48 +07:00
|
|
|
if (n_match_sets) {
|
|
|
|
if (request->ie)
|
|
|
|
request->match_sets = (void *)(request->ie + ie_len);
|
|
|
|
else if (request->ssids)
|
|
|
|
request->match_sets =
|
|
|
|
(void *)(request->ssids + n_ssids);
|
|
|
|
else
|
|
|
|
request->match_sets =
|
|
|
|
(void *)(request->channels + n_channels);
|
|
|
|
}
|
|
|
|
request->n_match_sets = n_match_sets;
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
i = 0;
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) {
|
|
|
|
/* user specified, bail out if channel not found */
|
|
|
|
nla_for_each_nested(attr,
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_FREQUENCIES],
|
|
|
|
tmp) {
|
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
|
|
|
|
chan = ieee80211_get_channel(wiphy, nla_get_u32(attr));
|
|
|
|
|
|
|
|
if (!chan) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ignore disabled channels */
|
|
|
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
request->channels[i] = chan;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* all channels */
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
|
|
|
|
int j;
|
|
|
|
if (!wiphy->bands[band])
|
|
|
|
continue;
|
|
|
|
for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
|
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
|
|
|
|
chan = &wiphy->bands[band]->channels[j];
|
|
|
|
|
|
|
|
if (chan->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
request->channels[i] = chan;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!i) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
request->n_channels = i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
|
|
|
|
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS],
|
|
|
|
tmp) {
|
2011-06-08 00:42:26 +07:00
|
|
|
if (nla_len(attr) > IEEE80211_MAX_SSID_LEN) {
|
2011-05-11 21:09:35 +07:00
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
2011-06-08 00:42:26 +07:00
|
|
|
request->ssids[i].ssid_len = nla_len(attr);
|
2011-05-11 21:09:35 +07:00
|
|
|
memcpy(request->ssids[i].ssid, nla_data(attr),
|
|
|
|
nla_len(attr));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-31 20:01:48 +07:00
|
|
|
i = 0;
|
|
|
|
if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
|
|
|
|
nla_for_each_nested(attr,
|
|
|
|
info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
|
|
|
|
tmp) {
|
2012-06-22 01:09:54 +07:00
|
|
|
struct nlattr *ssid, *rssi;
|
2011-08-31 20:01:48 +07:00
|
|
|
|
|
|
|
nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
|
|
|
|
nla_data(attr), nla_len(attr),
|
|
|
|
nl80211_match_policy);
|
2012-06-13 16:17:11 +07:00
|
|
|
ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
|
2011-08-31 20:01:48 +07:00
|
|
|
if (ssid) {
|
|
|
|
if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
memcpy(request->match_sets[i].ssid.ssid,
|
|
|
|
nla_data(ssid), nla_len(ssid));
|
|
|
|
request->match_sets[i].ssid.ssid_len =
|
|
|
|
nla_len(ssid);
|
|
|
|
}
|
2012-06-22 01:09:54 +07:00
|
|
|
rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
|
|
|
|
if (rssi)
|
|
|
|
request->rssi_thold = nla_get_u32(rssi);
|
|
|
|
else
|
|
|
|
request->rssi_thold =
|
|
|
|
NL80211_SCAN_RSSI_THOLD_OFF;
|
2011-08-31 20:01:48 +07:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
|
|
|
request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
memcpy((void *)request->ie,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_IE]),
|
|
|
|
request->ie_len);
|
|
|
|
}
|
|
|
|
|
2012-10-12 11:03:32 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
|
2012-10-12 11:03:31 +07:00
|
|
|
request->flags = nla_get_u32(
|
|
|
|
info->attrs[NL80211_ATTR_SCAN_FLAGS]);
|
2012-10-12 11:03:34 +07:00
|
|
|
if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) &&
|
|
|
|
!(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) ||
|
|
|
|
((request->flags & NL80211_SCAN_FLAG_FLUSH) &&
|
|
|
|
!(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) {
|
2012-10-12 11:03:32 +07:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
}
|
2012-10-12 11:03:31 +07:00
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
request->dev = dev;
|
|
|
|
request->wiphy = &rdev->wiphy;
|
2011-05-11 21:09:37 +07:00
|
|
|
request->interval = interval;
|
2012-10-12 11:03:34 +07:00
|
|
|
request->scan_start = jiffies;
|
2011-05-11 21:09:35 +07:00
|
|
|
|
|
|
|
err = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request);
|
|
|
|
if (!err) {
|
|
|
|
rdev->sched_scan_req = request;
|
|
|
|
nl80211_send_sched_scan(rdev, dev,
|
|
|
|
NL80211_CMD_START_SCHED_SCAN);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_free:
|
|
|
|
kfree(request);
|
|
|
|
out:
|
2011-06-30 12:32:41 +07:00
|
|
|
mutex_unlock(&rdev->sched_scan_mtx);
|
2011-05-11 21:09:35 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_stop_sched_scan(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2011-06-30 12:32:41 +07:00
|
|
|
int err;
|
2011-05-11 21:09:35 +07:00
|
|
|
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
|
|
|
|
!rdev->ops->sched_scan_stop)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2011-06-30 12:32:41 +07:00
|
|
|
mutex_lock(&rdev->sched_scan_mtx);
|
|
|
|
err = __cfg80211_stop_sched_scan(rdev, false);
|
|
|
|
mutex_unlock(&rdev->sched_scan_mtx);
|
|
|
|
|
|
|
|
return err;
|
2011-05-11 21:09:35 +07:00
|
|
|
}
|
|
|
|
|
2011-06-21 14:45:33 +07:00
|
|
|
static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
|
|
|
|
u32 seq, int flags,
|
2009-02-11 03:25:55 +07:00
|
|
|
struct cfg80211_registered_device *rdev,
|
2009-07-10 23:42:31 +07:00
|
|
|
struct wireless_dev *wdev,
|
|
|
|
struct cfg80211_internal_bss *intbss)
|
2009-02-11 03:25:55 +07:00
|
|
|
{
|
2009-07-10 23:42:31 +07:00
|
|
|
struct cfg80211_bss *res = &intbss->pub;
|
2009-02-11 03:25:55 +07:00
|
|
|
void *hdr;
|
|
|
|
struct nlattr *bss;
|
2009-07-10 23:42:31 +07:00
|
|
|
|
|
|
|
ASSERT_WDEV_LOCK(wdev);
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags,
|
2009-02-11 03:25:55 +07:00
|
|
|
NL80211_CMD_NEW_SCAN_RESULTS);
|
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2011-06-21 14:45:33 +07:00
|
|
|
genl_dump_check_consistent(cb, hdr, &nl80211_fam);
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_GENERATION, rdev->bss_generation) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex))
|
|
|
|
goto nla_put_failure;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
|
|
|
bss = nla_nest_start(msg, NL80211_ATTR_BSS);
|
|
|
|
if (!bss)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((!is_zero_ether_addr(res->bssid) &&
|
|
|
|
nla_put(msg, NL80211_BSS_BSSID, ETH_ALEN, res->bssid)) ||
|
|
|
|
(res->information_elements && res->len_information_elements &&
|
|
|
|
nla_put(msg, NL80211_BSS_INFORMATION_ELEMENTS,
|
|
|
|
res->len_information_elements,
|
|
|
|
res->information_elements)) ||
|
|
|
|
(res->beacon_ies && res->len_beacon_ies &&
|
|
|
|
res->beacon_ies != res->information_elements &&
|
|
|
|
nla_put(msg, NL80211_BSS_BEACON_IES,
|
|
|
|
res->len_beacon_ies, res->beacon_ies)))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (res->tsf &&
|
|
|
|
nla_put_u64(msg, NL80211_BSS_TSF, res->tsf))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (res->beacon_interval &&
|
|
|
|
nla_put_u16(msg, NL80211_BSS_BEACON_INTERVAL, res->beacon_interval))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (nla_put_u16(msg, NL80211_BSS_CAPABILITY, res->capability) ||
|
|
|
|
nla_put_u32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq) ||
|
|
|
|
nla_put_u32(msg, NL80211_BSS_SEEN_MS_AGO,
|
|
|
|
jiffies_to_msecs(jiffies - intbss->ts)))
|
|
|
|
goto nla_put_failure;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-02-19 00:45:06 +07:00
|
|
|
switch (rdev->wiphy.signal_type) {
|
2009-02-11 03:25:55 +07:00
|
|
|
case CFG80211_SIGNAL_TYPE_MBM:
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_BSS_SIGNAL_MBM, res->signal))
|
|
|
|
goto nla_put_failure;
|
2009-02-11 03:25:55 +07:00
|
|
|
break;
|
|
|
|
case CFG80211_SIGNAL_TYPE_UNSPEC:
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u8(msg, NL80211_BSS_SIGNAL_UNSPEC, res->signal))
|
|
|
|
goto nla_put_failure;
|
2009-02-11 03:25:55 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-07-10 23:42:31 +07:00
|
|
|
switch (wdev->iftype) {
|
2010-09-16 19:58:22 +07:00
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
2009-07-10 23:42:31 +07:00
|
|
|
case NL80211_IFTYPE_STATION:
|
2012-03-29 15:41:26 +07:00
|
|
|
if (intbss == wdev->current_bss &&
|
|
|
|
nla_put_u32(msg, NL80211_BSS_STATUS,
|
|
|
|
NL80211_BSS_STATUS_ASSOCIATED))
|
|
|
|
goto nla_put_failure;
|
2009-07-10 23:42:31 +07:00
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2012-03-29 15:41:26 +07:00
|
|
|
if (intbss == wdev->current_bss &&
|
|
|
|
nla_put_u32(msg, NL80211_BSS_STATUS,
|
|
|
|
NL80211_BSS_STATUS_IBSS_JOINED))
|
|
|
|
goto nla_put_failure;
|
2009-07-10 23:42:31 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
nla_nest_end(msg, bss);
|
|
|
|
|
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_dump_scan(struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb)
|
|
|
|
{
|
2009-07-10 23:42:31 +07:00
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
struct net_device *dev;
|
2009-02-11 03:25:55 +07:00
|
|
|
struct cfg80211_internal_bss *scan;
|
2009-07-10 23:42:31 +07:00
|
|
|
struct wireless_dev *wdev;
|
2009-02-11 03:25:55 +07:00
|
|
|
int start = cb->args[1], idx = 0;
|
|
|
|
int err;
|
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
err = nl80211_prepare_netdev_dump(skb, cb, &rdev, &dev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-07-10 23:42:31 +07:00
|
|
|
wdev = dev->ieee80211_ptr;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-07-10 23:42:31 +07:00
|
|
|
wdev_lock(wdev);
|
|
|
|
spin_lock_bh(&rdev->bss_lock);
|
|
|
|
cfg80211_bss_expire(rdev);
|
|
|
|
|
2011-06-21 14:45:33 +07:00
|
|
|
cb->seq = rdev->bss_generation;
|
|
|
|
|
2009-07-10 23:42:31 +07:00
|
|
|
list_for_each_entry(scan, &rdev->bss_list, list) {
|
2009-02-11 03:25:55 +07:00
|
|
|
if (++idx <= start)
|
|
|
|
continue;
|
2011-06-21 14:45:33 +07:00
|
|
|
if (nl80211_send_bss(skb, cb,
|
2009-02-11 03:25:55 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
2009-07-10 23:42:31 +07:00
|
|
|
rdev, wdev, scan) < 0) {
|
2009-02-11 03:25:55 +07:00
|
|
|
idx--;
|
2010-10-05 02:14:06 +07:00
|
|
|
break;
|
2009-02-11 03:25:55 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-10 23:42:31 +07:00
|
|
|
spin_unlock_bh(&rdev->bss_lock);
|
|
|
|
wdev_unlock(wdev);
|
2009-02-11 03:25:55 +07:00
|
|
|
|
|
|
|
cb->args[1] = idx;
|
2010-10-05 02:14:06 +07:00
|
|
|
nl80211_finish_netdev_dump(rdev);
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
return skb->len;
|
2009-02-11 03:25:55 +07:00
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
static int nl80211_send_survey(struct sk_buff *msg, u32 portid, u32 seq,
|
2009-11-11 18:25:40 +07:00
|
|
|
int flags, struct net_device *dev,
|
|
|
|
struct survey_info *survey)
|
|
|
|
{
|
|
|
|
void *hdr;
|
|
|
|
struct nlattr *infoattr;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags,
|
2009-11-11 18:25:40 +07:00
|
|
|
NL80211_CMD_NEW_SURVEY_RESULTS);
|
|
|
|
if (!hdr)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex))
|
|
|
|
goto nla_put_failure;
|
2009-11-11 18:25:40 +07:00
|
|
|
|
|
|
|
infoattr = nla_nest_start(msg, NL80211_ATTR_SURVEY_INFO);
|
|
|
|
if (!infoattr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_SURVEY_INFO_FREQUENCY,
|
|
|
|
survey->channel->center_freq))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if ((survey->filled & SURVEY_INFO_NOISE_DBM) &&
|
|
|
|
nla_put_u8(msg, NL80211_SURVEY_INFO_NOISE, survey->noise))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_IN_USE) &&
|
|
|
|
nla_put_flag(msg, NL80211_SURVEY_INFO_IN_USE))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_CHANNEL_TIME) &&
|
|
|
|
nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME,
|
|
|
|
survey->channel_time))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_BUSY) &&
|
|
|
|
nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY,
|
|
|
|
survey->channel_time_busy))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY) &&
|
|
|
|
nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_EXT_BUSY,
|
|
|
|
survey->channel_time_ext_busy))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_RX) &&
|
|
|
|
nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_RX,
|
|
|
|
survey->channel_time_rx))
|
|
|
|
goto nla_put_failure;
|
|
|
|
if ((survey->filled & SURVEY_INFO_CHANNEL_TIME_TX) &&
|
|
|
|
nla_put_u64(msg, NL80211_SURVEY_INFO_CHANNEL_TIME_TX,
|
|
|
|
survey->channel_time_tx))
|
|
|
|
goto nla_put_failure;
|
2009-11-11 18:25:40 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, infoattr);
|
|
|
|
|
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_dump_survey(struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
struct survey_info survey;
|
|
|
|
struct cfg80211_registered_device *dev;
|
|
|
|
struct net_device *netdev;
|
|
|
|
int survey_idx = cb->args[1];
|
|
|
|
int res;
|
|
|
|
|
2010-10-05 02:14:06 +07:00
|
|
|
res = nl80211_prepare_netdev_dump(skb, cb, &dev, &netdev);
|
|
|
|
if (res)
|
|
|
|
return res;
|
2009-11-11 18:25:40 +07:00
|
|
|
|
|
|
|
if (!dev->ops->dump_survey) {
|
|
|
|
res = -EOPNOTSUPP;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
2011-05-27 21:24:02 +07:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
|
2009-11-11 18:25:40 +07:00
|
|
|
res = dev->ops->dump_survey(&dev->wiphy, netdev, survey_idx,
|
|
|
|
&survey);
|
|
|
|
if (res == -ENOENT)
|
|
|
|
break;
|
|
|
|
if (res)
|
|
|
|
goto out_err;
|
|
|
|
|
2011-05-27 21:24:02 +07:00
|
|
|
/* Survey without a channel doesn't make sense */
|
|
|
|
if (!survey.channel) {
|
|
|
|
res = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
chan = ieee80211_get_channel(&dev->wiphy,
|
|
|
|
survey.channel->center_freq);
|
|
|
|
if (!chan || chan->flags & IEEE80211_CHAN_DISABLED) {
|
|
|
|
survey_idx++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-11 18:25:40 +07:00
|
|
|
if (nl80211_send_survey(skb,
|
2012-09-08 03:12:54 +07:00
|
|
|
NETLINK_CB(cb->skb).portid,
|
2009-11-11 18:25:40 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
|
|
|
netdev,
|
|
|
|
&survey) < 0)
|
|
|
|
goto out;
|
|
|
|
survey_idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
cb->args[1] = survey_idx;
|
|
|
|
res = skb->len;
|
|
|
|
out_err:
|
2010-10-05 02:14:06 +07:00
|
|
|
nl80211_finish_netdev_dump(dev);
|
2009-11-11 18:25:40 +07:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
static bool nl80211_valid_wpa_versions(u32 wpa_versions)
|
|
|
|
{
|
|
|
|
return !(wpa_versions & ~(NL80211_WPA_VERSION_1 |
|
|
|
|
NL80211_WPA_VERSION_2));
|
|
|
|
}
|
|
|
|
|
2009-03-19 18:39:22 +07:00
|
|
|
static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 22:20:43 +07:00
|
|
|
struct ieee80211_channel *chan;
|
2012-09-30 23:29:39 +07:00
|
|
|
const u8 *bssid, *ssid, *ie = NULL, *sae_data = NULL;
|
|
|
|
int err, ssid_len, ie_len = 0, sae_data_len = 0;
|
2009-07-02 22:20:43 +07:00
|
|
|
enum nl80211_auth_type auth_type;
|
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 19:22:54 +07:00
|
|
|
struct key_parse key;
|
2010-04-04 13:37:19 +07:00
|
|
|
bool local_state_change;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-03-28 01:52:47 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_AUTH_TYPE])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_SSID])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_FREQ])
|
|
|
|
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 19:22:54 +07:00
|
|
|
err = nl80211_parse_key(info, &key);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (key.idx >= 0) {
|
2010-10-06 00:39:30 +07:00
|
|
|
if (key.type != -1 && key.type != NL80211_KEYTYPE_GROUP)
|
|
|
|
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 19:22:54 +07:00
|
|
|
if (!key.p.key || !key.p.key_len)
|
|
|
|
return -EINVAL;
|
|
|
|
if ((key.p.cipher != WLAN_CIPHER_SUITE_WEP40 ||
|
|
|
|
key.p.key_len != WLAN_KEY_LEN_WEP40) &&
|
|
|
|
(key.p.cipher != WLAN_CIPHER_SUITE_WEP104 ||
|
|
|
|
key.p.key_len != WLAN_KEY_LEN_WEP104))
|
|
|
|
return -EINVAL;
|
|
|
|
if (key.idx > 4)
|
|
|
|
return -EINVAL;
|
|
|
|
} else {
|
|
|
|
key.p.key_len = 0;
|
|
|
|
key.p.key = NULL;
|
|
|
|
}
|
|
|
|
|
2010-08-10 14:46:42 +07:00
|
|
|
if (key.idx >= 0) {
|
|
|
|
int i;
|
|
|
|
bool ok = false;
|
|
|
|
for (i = 0; i < rdev->wiphy.n_cipher_suites; i++) {
|
|
|
|
if (key.p.cipher == rdev->wiphy.cipher_suites[i]) {
|
|
|
|
ok = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!ok)
|
|
|
|
return -EINVAL;
|
2010-08-10 14:46:42 +07:00
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->auth)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:19 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2009-07-07 08:56:12 +07:00
|
|
|
chan = ieee80211_get_channel(&rdev->wiphy,
|
2009-07-02 22:20:43 +07:00
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!chan || (chan->flags & IEEE80211_CHAN_DISABLED))
|
|
|
|
return -EINVAL;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
ssid = nla_data(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
2009-07-02 22:20:43 +07:00
|
|
|
ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]);
|
2012-09-30 23:29:39 +07:00
|
|
|
if (!nl80211_valid_auth_type(rdev, auth_type, NL80211_CMD_AUTHENTICATE))
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2012-09-30 23:29:39 +07:00
|
|
|
if (auth_type == NL80211_AUTHTYPE_SAE &&
|
|
|
|
!info->attrs[NL80211_ATTR_SAE_DATA])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_SAE_DATA]) {
|
|
|
|
if (auth_type != NL80211_AUTHTYPE_SAE)
|
|
|
|
return -EINVAL;
|
|
|
|
sae_data = nla_data(info->attrs[NL80211_ATTR_SAE_DATA]);
|
|
|
|
sae_data_len = nla_len(info->attrs[NL80211_ATTR_SAE_DATA]);
|
|
|
|
/* need to include at least Auth Transaction and Status Code */
|
|
|
|
if (sae_data_len < 4)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-04-04 13:37:19 +07:00
|
|
|
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
|
|
|
|
|
2012-01-20 19:55:25 +07:00
|
|
|
/*
|
|
|
|
* Since we no longer track auth state, ignore
|
|
|
|
* requests to only change local state.
|
|
|
|
*/
|
|
|
|
if (local_state_change)
|
|
|
|
return 0;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
|
|
|
|
ssid, ssid_len, ie, ie_len,
|
2012-09-30 23:29:39 +07:00
|
|
|
key.p.key, key.p.key_len, key.idx,
|
|
|
|
sae_data, sae_data_len);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2010-08-27 18:26:53 +07:00
|
|
|
static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev,
|
|
|
|
struct genl_info *info,
|
2009-07-03 02:36:37 +07:00
|
|
|
struct cfg80211_crypto_settings *settings,
|
|
|
|
int cipher_limit)
|
2009-07-02 02:26:54 +07:00
|
|
|
{
|
2009-07-25 21:54:36 +07:00
|
|
|
memset(settings, 0, sizeof(*settings));
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
settings->control_port = info->attrs[NL80211_ATTR_CONTROL_PORT];
|
|
|
|
|
2010-08-27 18:26:53 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]) {
|
|
|
|
u16 proto;
|
|
|
|
proto = nla_get_u16(
|
|
|
|
info->attrs[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]);
|
|
|
|
settings->control_port_ethertype = cpu_to_be16(proto);
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_CONTROL_PORT_PROTOCOL) &&
|
|
|
|
proto != ETH_P_PAE)
|
|
|
|
return -EINVAL;
|
|
|
|
if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT])
|
|
|
|
settings->control_port_no_encrypt = true;
|
|
|
|
} else
|
|
|
|
settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE);
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]) {
|
|
|
|
void *data;
|
|
|
|
int len, i;
|
|
|
|
|
|
|
|
data = nla_data(info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]);
|
|
|
|
len = nla_len(info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]);
|
|
|
|
settings->n_ciphers_pairwise = len / sizeof(u32);
|
|
|
|
|
|
|
|
if (len % sizeof(u32))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-03 02:36:37 +07:00
|
|
|
if (settings->n_ciphers_pairwise > cipher_limit)
|
2009-07-02 02:26:54 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memcpy(settings->ciphers_pairwise, data, len);
|
|
|
|
|
|
|
|
for (i = 0; i < settings->n_ciphers_pairwise; i++)
|
2011-09-21 22:14:56 +07:00
|
|
|
if (!cfg80211_supported_cipher_suite(
|
|
|
|
&rdev->wiphy,
|
2009-07-02 02:26:54 +07:00
|
|
|
settings->ciphers_pairwise[i]))
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]) {
|
|
|
|
settings->cipher_group =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_CIPHER_SUITE_GROUP]);
|
2011-09-21 22:14:56 +07:00
|
|
|
if (!cfg80211_supported_cipher_suite(&rdev->wiphy,
|
|
|
|
settings->cipher_group))
|
2009-07-02 02:26:54 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WPA_VERSIONS]) {
|
|
|
|
settings->wpa_versions =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WPA_VERSIONS]);
|
|
|
|
if (!nl80211_valid_wpa_versions(settings->wpa_versions))
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_AKM_SUITES]) {
|
|
|
|
void *data;
|
2011-09-21 22:11:33 +07:00
|
|
|
int len;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
|
|
|
data = nla_data(info->attrs[NL80211_ATTR_AKM_SUITES]);
|
|
|
|
len = nla_len(info->attrs[NL80211_ATTR_AKM_SUITES]);
|
|
|
|
settings->n_akm_suites = len / sizeof(u32);
|
|
|
|
|
|
|
|
if (len % sizeof(u32))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-09-21 20:13:07 +07:00
|
|
|
if (settings->n_akm_suites > NL80211_MAX_NR_AKM_SUITES)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
memcpy(settings->akm_suites, data, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-19 18:39:22 +07:00
|
|
|
static int nl80211_associate(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 22:20:43 +07:00
|
|
|
struct cfg80211_crypto_settings crypto;
|
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 20:25:02 +07:00
|
|
|
struct ieee80211_channel *chan;
|
2009-07-07 19:37:26 +07:00
|
|
|
const u8 *bssid, *ssid, *ie = NULL, *prev_bssid = NULL;
|
2009-07-02 22:20:43 +07:00
|
|
|
int err, ssid_len, ie_len = 0;
|
|
|
|
bool use_mfp = false;
|
2011-11-19 02:31:59 +07:00
|
|
|
u32 flags = 0;
|
|
|
|
struct ieee80211_ht_cap *ht_capa = NULL;
|
|
|
|
struct ieee80211_ht_cap *ht_capa_mask = NULL;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC] ||
|
2009-07-02 22:20:43 +07:00
|
|
|
!info->attrs[NL80211_ATTR_SSID] ||
|
|
|
|
!info->attrs[NL80211_ATTR_WIPHY_FREQ])
|
2009-03-27 18:40:28 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->assoc)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:19 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
chan = ieee80211_get_channel(&rdev->wiphy,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!chan || (chan->flags & IEEE80211_CHAN_DISABLED))
|
|
|
|
return -EINVAL;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
ssid = nla_data(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
2009-07-02 22:20:43 +07:00
|
|
|
ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2009-05-07 02:09:37 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_USE_MFP]) {
|
2009-07-07 08:56:10 +07:00
|
|
|
enum nl80211_mfp mfp =
|
2009-05-07 02:09:37 +07:00
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_USE_MFP]);
|
2009-07-07 08:56:10 +07:00
|
|
|
if (mfp == NL80211_MFP_REQUIRED)
|
2009-07-02 22:20:43 +07:00
|
|
|
use_mfp = true;
|
2010-10-05 02:36:35 +07:00
|
|
|
else if (mfp != NL80211_MFP_NO)
|
|
|
|
return -EINVAL;
|
2009-05-07 02:09:37 +07:00
|
|
|
}
|
|
|
|
|
2009-07-07 19:37:26 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_PREV_BSSID])
|
|
|
|
prev_bssid = nla_data(info->attrs[NL80211_ATTR_PREV_BSSID]);
|
|
|
|
|
2011-11-19 02:31:59 +07:00
|
|
|
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
|
|
|
|
flags |= ASSOC_REQ_DISABLE_HT;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
|
|
|
|
ht_capa_mask =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]);
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
|
|
|
|
if (!ht_capa_mask)
|
|
|
|
return -EINVAL;
|
|
|
|
ht_capa = nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
|
|
|
|
}
|
|
|
|
|
2010-08-27 18:26:53 +07:00
|
|
|
err = nl80211_crypto_settings(rdev, info, &crypto, 1);
|
2009-07-02 02:26:54 +07:00
|
|
|
if (!err)
|
2009-07-07 19:37:26 +07:00
|
|
|
err = cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
|
|
|
|
ssid, ssid_len, ie, ie_len, use_mfp,
|
2011-11-19 02:31:59 +07:00
|
|
|
&crypto, flags, ht_capa,
|
|
|
|
ht_capa_mask);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_deauthenticate(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 22:20:43 +07:00
|
|
|
const u8 *ie = NULL, *bssid;
|
2010-10-05 02:36:35 +07:00
|
|
|
int ie_len = 0;
|
2009-07-02 22:20:43 +07:00
|
|
|
u16 reason_code;
|
2010-04-04 13:37:19 +07:00
|
|
|
bool local_state_change;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REASON_CODE])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->deauth)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:19 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
reason_code = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
|
|
|
|
if (reason_code == 0) {
|
2009-03-27 18:40:28 +07:00
|
|
|
/* Reason Code 0 is reserved */
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2009-03-21 02:21:17 +07:00
|
|
|
}
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
2009-07-02 22:20:43 +07:00
|
|
|
ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2010-04-04 13:37:19 +07:00
|
|
|
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return cfg80211_mlme_deauth(rdev, dev, bssid, ie, ie_len, reason_code,
|
|
|
|
local_state_change);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 22:20:43 +07:00
|
|
|
const u8 *ie = NULL, *bssid;
|
2010-10-05 02:36:35 +07:00
|
|
|
int ie_len = 0;
|
2009-07-02 22:20:43 +07:00
|
|
|
u16 reason_code;
|
2010-04-04 13:37:19 +07:00
|
|
|
bool local_state_change;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-03-27 18:40:28 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REASON_CODE])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->disassoc)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-03-21 02:21:19 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2009-03-19 18:39:22 +07:00
|
|
|
|
2009-07-02 22:20:43 +07:00
|
|
|
reason_code = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
|
|
|
|
if (reason_code == 0) {
|
2009-03-27 18:40:28 +07:00
|
|
|
/* Reason Code 0 is reserved */
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2009-03-21 02:21:17 +07:00
|
|
|
}
|
2009-03-19 18:39:22 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
2009-07-02 22:20:43 +07:00
|
|
|
ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2010-04-04 13:37:19 +07:00
|
|
|
local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE];
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return cfg80211_mlme_disassoc(rdev, dev, bssid, ie, ie_len, reason_code,
|
|
|
|
local_state_change);
|
2009-03-19 18:39:22 +07:00
|
|
|
}
|
|
|
|
|
2010-11-23 02:58:24 +07:00
|
|
|
static bool
|
|
|
|
nl80211_parse_mcast_rate(struct cfg80211_registered_device *rdev,
|
|
|
|
int mcast_rate[IEEE80211_NUM_BANDS],
|
|
|
|
int rateval)
|
|
|
|
{
|
|
|
|
struct wiphy *wiphy = &rdev->wiphy;
|
|
|
|
bool found = false;
|
|
|
|
int band, i;
|
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
|
|
|
|
sband = wiphy->bands[band];
|
|
|
|
if (!sband)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (sband->bitrates[i].bitrate == rateval) {
|
|
|
|
mcast_rate[band] = i + 1;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2009-04-20 02:24:32 +07:00
|
|
|
static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-04-20 02:24:32 +07:00
|
|
|
struct cfg80211_ibss_params ibss;
|
|
|
|
struct wiphy *wiphy;
|
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 19:22:54 +07:00
|
|
|
struct cfg80211_cached_keys *connkeys = NULL;
|
2009-04-20 02:24:32 +07:00
|
|
|
int err;
|
|
|
|
|
2009-04-22 22:45:38 +07:00
|
|
|
memset(&ibss, 0, sizeof(ibss));
|
|
|
|
|
2009-04-20 02:24:32 +07:00
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
|
|
|
|
!info->attrs[NL80211_ATTR_SSID] ||
|
|
|
|
!nla_len(info->attrs[NL80211_ATTR_SSID]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-04-22 22:45:38 +07:00
|
|
|
ibss.beacon_interval = 100;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_BEACON_INTERVAL]) {
|
|
|
|
ibss.beacon_interval =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_BEACON_INTERVAL]);
|
|
|
|
if (ibss.beacon_interval < 1 || ibss.beacon_interval > 10000)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->join_ibss)
|
|
|
|
return -EOPNOTSUPP;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
wiphy = &rdev->wiphy;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2011-09-16 18:45:25 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MAC]) {
|
2009-04-20 02:24:32 +07:00
|
|
|
ibss.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
2011-09-16 18:45:25 +07:00
|
|
|
|
|
|
|
if (!is_valid_ether_addr(ibss.bssid))
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-04-20 02:24:32 +07:00
|
|
|
ibss.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
ibss.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
|
|
|
ibss.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
ibss.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
}
|
|
|
|
|
2011-11-30 22:56:32 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
|
|
|
|
enum nl80211_channel_type channel_type;
|
|
|
|
|
2012-05-11 02:27:18 +07:00
|
|
|
if (!nl80211_valid_channel_type(info, &channel_type))
|
2011-11-30 22:56:32 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (channel_type != NL80211_CHAN_NO_HT &&
|
|
|
|
!(wiphy->features & NL80211_FEATURE_HT_IBSS))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ibss.channel_type = channel_type;
|
|
|
|
} else {
|
|
|
|
ibss.channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
}
|
|
|
|
|
|
|
|
ibss.channel = rdev_freq_to_chan(rdev,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
|
|
|
|
ibss.channel_type);
|
2009-04-20 02:24:32 +07:00
|
|
|
if (!ibss.channel ||
|
|
|
|
ibss.channel->flags & IEEE80211_CHAN_NO_IBSS ||
|
2010-10-05 02:36:35 +07:00
|
|
|
ibss.channel->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
return -EINVAL;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2011-11-30 22:56:32 +07:00
|
|
|
/* Both channels should be able to initiate communication */
|
|
|
|
if ((ibss.channel_type == NL80211_CHAN_HT40PLUS ||
|
|
|
|
ibss.channel_type == NL80211_CHAN_HT40MINUS) &&
|
|
|
|
!cfg80211_can_beacon_sec_chan(&rdev->wiphy, ibss.channel,
|
|
|
|
ibss.channel_type))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-04-20 02:24:32 +07:00
|
|
|
ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED];
|
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 19:22:54 +07:00
|
|
|
ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY];
|
|
|
|
|
2010-06-14 16:55:31 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
|
|
|
|
u8 *rates =
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
|
|
|
|
int n_rates =
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
|
|
|
|
struct ieee80211_supported_band *sband =
|
|
|
|
wiphy->bands[ibss.channel->band];
|
|
|
|
|
2011-07-18 23:08:35 +07:00
|
|
|
err = ieee80211_get_ratemask(sband, rates, n_rates,
|
|
|
|
&ibss.basic_rates);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2010-06-14 16:55:31 +07:00
|
|
|
}
|
2010-11-23 02:58:24 +07:00
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_MCAST_RATE] &&
|
|
|
|
!nl80211_parse_mcast_rate(rdev, ibss.mcast_rate,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE])))
|
|
|
|
return -EINVAL;
|
2010-06-14 16:55:31 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) {
|
|
|
|
connkeys = nl80211_parse_connkeys(rdev,
|
|
|
|
info->attrs[NL80211_ATTR_KEYS]);
|
|
|
|
if (IS_ERR(connkeys))
|
|
|
|
return PTR_ERR(connkeys);
|
|
|
|
}
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2012-02-01 02:25:47 +07:00
|
|
|
ibss.control_port =
|
|
|
|
nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
|
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 19:22:54 +07:00
|
|
|
if (err)
|
|
|
|
kfree(connkeys);
|
2009-04-20 02:24:32 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->leave_ibss)
|
|
|
|
return -EOPNOTSUPP;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -EOPNOTSUPP;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return cfg80211_leave_ibss(rdev, dev, false);
|
2009-04-20 02:24:32 +07:00
|
|
|
}
|
|
|
|
|
2009-07-02 02:26:51 +07:00
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
static struct genl_multicast_group nl80211_testmode_mcgrp = {
|
|
|
|
.name = "testmode",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2009-07-02 02:26:51 +07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_TESTDATA])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
if (rdev->ops->testmode_cmd) {
|
|
|
|
rdev->testmode_info = info;
|
|
|
|
err = rdev->ops->testmode_cmd(&rdev->wiphy,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_TESTDATA]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_TESTDATA]));
|
|
|
|
rdev->testmode_info = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-05-20 23:05:54 +07:00
|
|
|
static int nl80211_testmode_dump(struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb)
|
|
|
|
{
|
2011-12-13 23:22:05 +07:00
|
|
|
struct cfg80211_registered_device *rdev;
|
2011-05-20 23:05:54 +07:00
|
|
|
int err;
|
|
|
|
long phy_idx;
|
|
|
|
void *data = NULL;
|
|
|
|
int data_len = 0;
|
|
|
|
|
|
|
|
if (cb->args[0]) {
|
|
|
|
/*
|
|
|
|
* 0 is a valid index, but not valid for args[0],
|
|
|
|
* so we need to offset by 1.
|
|
|
|
*/
|
|
|
|
phy_idx = cb->args[0] - 1;
|
|
|
|
} else {
|
|
|
|
err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
|
|
|
|
nl80211_fam.attrbuf, nl80211_fam.maxattr,
|
|
|
|
nl80211_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2011-12-13 23:22:05 +07:00
|
|
|
|
2012-06-15 19:23:16 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
|
|
|
rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
|
|
|
|
nl80211_fam.attrbuf);
|
|
|
|
if (IS_ERR(rdev)) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
return PTR_ERR(rdev);
|
2011-12-13 23:22:05 +07:00
|
|
|
}
|
2012-06-15 19:23:16 +07:00
|
|
|
phy_idx = rdev->wiphy_idx;
|
|
|
|
rdev = NULL;
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
|
2011-05-20 23:05:54 +07:00
|
|
|
if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA])
|
|
|
|
cb->args[1] =
|
|
|
|
(long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cb->args[1]) {
|
|
|
|
data = nla_data((void *)cb->args[1]);
|
|
|
|
data_len = nla_len((void *)cb->args[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&cfg80211_mutex);
|
2011-12-13 23:22:05 +07:00
|
|
|
rdev = cfg80211_rdev_by_wiphy_idx(phy_idx);
|
|
|
|
if (!rdev) {
|
2011-05-20 23:05:54 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2011-12-13 23:22:05 +07:00
|
|
|
cfg80211_lock_rdev(rdev);
|
2011-05-20 23:05:54 +07:00
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
|
2011-12-13 23:22:05 +07:00
|
|
|
if (!rdev->ops->testmode_dump) {
|
2011-05-20 23:05:54 +07:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
2012-09-08 03:12:54 +07:00
|
|
|
void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
|
2011-05-20 23:05:54 +07:00
|
|
|
cb->nlh->nlmsg_seq, NLM_F_MULTI,
|
|
|
|
NL80211_CMD_TESTMODE);
|
|
|
|
struct nlattr *tmdata;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
|
2011-05-20 23:05:54 +07:00
|
|
|
genlmsg_cancel(skb, hdr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmdata = nla_nest_start(skb, NL80211_ATTR_TESTDATA);
|
|
|
|
if (!tmdata) {
|
|
|
|
genlmsg_cancel(skb, hdr);
|
|
|
|
break;
|
|
|
|
}
|
2011-12-13 23:22:05 +07:00
|
|
|
err = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb,
|
|
|
|
data, data_len);
|
2011-05-20 23:05:54 +07:00
|
|
|
nla_nest_end(skb, tmdata);
|
|
|
|
|
|
|
|
if (err == -ENOBUFS || err == -ENOENT) {
|
|
|
|
genlmsg_cancel(skb, hdr);
|
|
|
|
break;
|
|
|
|
} else if (err) {
|
|
|
|
genlmsg_cancel(skb, hdr);
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_end(skb, hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
err = skb->len;
|
|
|
|
/* see above */
|
|
|
|
cb->args[0] = phy_idx + 1;
|
|
|
|
out_err:
|
2011-12-13 23:22:05 +07:00
|
|
|
cfg80211_unlock_rdev(rdev);
|
2011-05-20 23:05:54 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-07-02 02:26:51 +07:00
|
|
|
static struct sk_buff *
|
|
|
|
__cfg80211_testmode_alloc_skb(struct cfg80211_registered_device *rdev,
|
2012-09-08 03:12:54 +07:00
|
|
|
int approxlen, u32 portid, u32 seq, gfp_t gfp)
|
2009-07-02 02:26:51 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
void *hdr;
|
|
|
|
struct nlattr *data;
|
|
|
|
|
|
|
|
skb = nlmsg_new(approxlen + 100, gfp);
|
|
|
|
if (!skb)
|
|
|
|
return NULL;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(skb, portid, seq, 0, NL80211_CMD_TESTMODE);
|
2009-07-02 02:26:51 +07:00
|
|
|
if (!hdr) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(skb, NL80211_ATTR_WIPHY, rdev->wiphy_idx))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:51 +07:00
|
|
|
data = nla_nest_start(skb, NL80211_ATTR_TESTDATA);
|
|
|
|
|
|
|
|
((void **)skb->cb)[0] = rdev;
|
|
|
|
((void **)skb->cb)[1] = hdr;
|
|
|
|
((void **)skb->cb)[2] = data;
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
kfree_skb(skb);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy,
|
|
|
|
int approxlen)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
|
|
|
|
|
|
|
|
if (WARN_ON(!rdev->testmode_info))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return __cfg80211_testmode_alloc_skb(rdev, approxlen,
|
2012-09-08 03:12:54 +07:00
|
|
|
rdev->testmode_info->snd_portid,
|
2009-07-02 02:26:51 +07:00
|
|
|
rdev->testmode_info->snd_seq,
|
|
|
|
GFP_KERNEL);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_testmode_alloc_reply_skb);
|
|
|
|
|
|
|
|
int cfg80211_testmode_reply(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = ((void **)skb->cb)[0];
|
|
|
|
void *hdr = ((void **)skb->cb)[1];
|
|
|
|
struct nlattr *data = ((void **)skb->cb)[2];
|
|
|
|
|
|
|
|
if (WARN_ON(!rdev->testmode_info)) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(skb, data);
|
|
|
|
genlmsg_end(skb, hdr);
|
|
|
|
return genlmsg_reply(skb, rdev->testmode_info);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_testmode_reply);
|
|
|
|
|
|
|
|
struct sk_buff *cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy,
|
|
|
|
int approxlen, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
|
|
|
|
|
|
|
|
return __cfg80211_testmode_alloc_skb(rdev, approxlen, 0, 0, gfp);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_testmode_alloc_event_skb);
|
|
|
|
|
|
|
|
void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp)
|
|
|
|
{
|
|
|
|
void *hdr = ((void **)skb->cb)[1];
|
|
|
|
struct nlattr *data = ((void **)skb->cb)[2];
|
|
|
|
|
|
|
|
nla_nest_end(skb, data);
|
|
|
|
genlmsg_end(skb, hdr);
|
|
|
|
genlmsg_multicast(skb, 0, nl80211_testmode_mcgrp.id, gfp);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_testmode_event);
|
|
|
|
#endif
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 02:26:54 +07:00
|
|
|
struct cfg80211_connect_params connect;
|
|
|
|
struct wiphy *wiphy;
|
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 19:22:54 +07:00
|
|
|
struct cfg80211_cached_keys *connkeys = NULL;
|
2009-07-02 02:26:54 +07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
memset(&connect, 0, sizeof(connect));
|
|
|
|
|
|
|
|
if (!is_valid_ie_attr(info->attrs[NL80211_ATTR_IE]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_SSID] ||
|
|
|
|
!nla_len(info->attrs[NL80211_ATTR_SSID]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_AUTH_TYPE]) {
|
|
|
|
connect.auth_type =
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]);
|
2012-09-30 23:29:39 +07:00
|
|
|
if (!nl80211_valid_auth_type(rdev, connect.auth_type,
|
|
|
|
NL80211_CMD_CONNECT))
|
2009-07-02 02:26:54 +07:00
|
|
|
return -EINVAL;
|
|
|
|
} else
|
|
|
|
connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
|
|
|
|
|
|
|
|
connect.privacy = info->attrs[NL80211_ATTR_PRIVACY];
|
|
|
|
|
2010-08-27 18:26:53 +07:00
|
|
|
err = nl80211_crypto_settings(rdev, info, &connect.crypto,
|
2009-07-03 02:36:37 +07:00
|
|
|
NL80211_MAX_NR_CIPHER_SUITES);
|
2009-07-02 02:26:54 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2009-07-07 08:56:12 +07:00
|
|
|
wiphy = &rdev->wiphy;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2012-03-07 18:57:12 +07:00
|
|
|
connect.bg_scan_period = -1;
|
|
|
|
if (info->attrs[NL80211_ATTR_BG_SCAN_PERIOD] &&
|
|
|
|
(wiphy->flags & WIPHY_FLAG_SUPPORTS_FW_ROAM)) {
|
|
|
|
connect.bg_scan_period =
|
|
|
|
nla_get_u16(info->attrs[NL80211_ATTR_BG_SCAN_PERIOD]);
|
|
|
|
}
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MAC])
|
|
|
|
connect.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
connect.ssid = nla_data(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
connect.ssid_len = nla_len(info->attrs[NL80211_ATTR_SSID]);
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_IE]) {
|
|
|
|
connect.ie = nla_data(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
connect.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
|
|
|
|
connect.channel =
|
|
|
|
ieee80211_get_channel(wiphy,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]));
|
|
|
|
if (!connect.channel ||
|
2010-10-05 02:36:35 +07:00
|
|
|
connect.channel->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
return -EINVAL;
|
2009-07-02 02:26:54 +07: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 19:22:54 +07:00
|
|
|
if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) {
|
|
|
|
connkeys = nl80211_parse_connkeys(rdev,
|
|
|
|
info->attrs[NL80211_ATTR_KEYS]);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (IS_ERR(connkeys))
|
|
|
|
return PTR_ERR(connkeys);
|
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 19:22:54 +07:00
|
|
|
}
|
|
|
|
|
2011-11-19 02:31:59 +07:00
|
|
|
if (nla_get_flag(info->attrs[NL80211_ATTR_DISABLE_HT]))
|
|
|
|
connect.flags |= ASSOC_REQ_DISABLE_HT;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK])
|
|
|
|
memcpy(&connect.ht_capa_mask,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]),
|
|
|
|
sizeof(connect.ht_capa_mask));
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
|
2012-09-02 20:41:04 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) {
|
|
|
|
kfree(connkeys);
|
2011-11-19 02:31:59 +07:00
|
|
|
return -EINVAL;
|
2012-09-02 20:41:04 +07:00
|
|
|
}
|
2011-11-19 02:31:59 +07:00
|
|
|
memcpy(&connect.ht_capa,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]),
|
|
|
|
sizeof(connect.ht_capa));
|
|
|
|
}
|
|
|
|
|
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 19:22:54 +07:00
|
|
|
err = cfg80211_connect(rdev, dev, &connect, connkeys);
|
|
|
|
if (err)
|
|
|
|
kfree(connkeys);
|
2009-07-02 02:26:54 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_disconnect(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-07-02 02:26:54 +07:00
|
|
|
u16 reason;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REASON_CODE])
|
|
|
|
reason = WLAN_REASON_DEAUTH_LEAVING;
|
|
|
|
else
|
|
|
|
reason = nla_get_u16(info->attrs[NL80211_ATTR_REASON_CODE]);
|
|
|
|
|
|
|
|
if (reason == 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return cfg80211_disconnect(rdev, dev, reason, true);
|
2009-07-02 02:26:54 +07:00
|
|
|
}
|
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
static int nl80211_wiphy_netns(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2009-07-14 05:33:35 +07:00
|
|
|
struct net *net;
|
|
|
|
int err;
|
|
|
|
u32 pid;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_PID])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pid = nla_get_u32(info->attrs[NL80211_ATTR_PID]);
|
|
|
|
|
|
|
|
net = get_net_ns_by_pid(pid);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (IS_ERR(net))
|
|
|
|
return PTR_ERR(net);
|
2009-07-14 05:33:35 +07:00
|
|
|
|
|
|
|
err = 0;
|
|
|
|
|
|
|
|
/* check if anything to do */
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!net_eq(wiphy_net(&rdev->wiphy), net))
|
|
|
|
err = cfg80211_switch_netns(rdev, net);
|
2009-07-14 05:33:35 +07:00
|
|
|
|
|
|
|
put_net(net);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-11-25 05:59:15 +07:00
|
|
|
static int nl80211_setdel_pmksa(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2009-11-25 05:59:15 +07:00
|
|
|
int (*rdev_ops)(struct wiphy *wiphy, struct net_device *dev,
|
|
|
|
struct cfg80211_pmksa *pmksa) = NULL;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-11-25 05:59:15 +07:00
|
|
|
struct cfg80211_pmksa pmksa;
|
|
|
|
|
|
|
|
memset(&pmksa, 0, sizeof(struct cfg80211_pmksa));
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_PMKID])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pmksa.pmkid = nla_data(info->attrs[NL80211_ATTR_PMKID]);
|
|
|
|
pmksa.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-11-25 05:59:15 +07:00
|
|
|
|
|
|
|
switch (info->genlhdr->cmd) {
|
|
|
|
case NL80211_CMD_SET_PMKSA:
|
|
|
|
rdev_ops = rdev->ops->set_pmksa;
|
|
|
|
break;
|
|
|
|
case NL80211_CMD_DEL_PMKSA:
|
|
|
|
rdev_ops = rdev->ops->del_pmksa;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ON(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev_ops)
|
|
|
|
return -EOPNOTSUPP;
|
2009-11-25 05:59:15 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev_ops(&rdev->wiphy, dev, &pmksa);
|
2009-11-25 05:59:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_flush_pmksa(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-11-25 05:59:15 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2009-11-25 05:59:15 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->flush_pmksa)
|
|
|
|
return -EOPNOTSUPP;
|
2009-11-25 05:59:15 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->flush_pmksa(&rdev->wiphy, dev);
|
2009-11-25 05:59:15 +07:00
|
|
|
}
|
|
|
|
|
2011-09-28 18:12:50 +07:00
|
|
|
static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
u8 action_code, dialog_token;
|
|
|
|
u16 status_code;
|
|
|
|
u8 *peer;
|
|
|
|
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) ||
|
|
|
|
!rdev->ops->tdls_mgmt)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_TDLS_ACTION] ||
|
|
|
|
!info->attrs[NL80211_ATTR_STATUS_CODE] ||
|
|
|
|
!info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN] ||
|
|
|
|
!info->attrs[NL80211_ATTR_IE] ||
|
|
|
|
!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
peer = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
action_code = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_ACTION]);
|
|
|
|
status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]);
|
|
|
|
dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]);
|
|
|
|
|
|
|
|
return rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code,
|
|
|
|
dialog_token, status_code,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_IE]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_IE]));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
enum nl80211_tdls_operation operation;
|
|
|
|
u8 *peer;
|
|
|
|
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_TDLS) ||
|
|
|
|
!rdev->ops->tdls_oper)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_TDLS_OPERATION] ||
|
|
|
|
!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]);
|
|
|
|
peer = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
|
|
|
return rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, operation);
|
|
|
|
}
|
|
|
|
|
2009-12-23 19:15:41 +07:00
|
|
|
static int nl80211_remain_on_channel(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2009-12-23 19:15:41 +07:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
u64 cookie;
|
|
|
|
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
u32 freq, duration;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
|
|
|
|
!info->attrs[NL80211_ATTR_DURATION])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
duration = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]);
|
|
|
|
|
2012-06-01 17:50:54 +07:00
|
|
|
if (!rdev->ops->remain_on_channel ||
|
|
|
|
!(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2009-12-23 19:15:41 +07:00
|
|
|
/*
|
2012-06-01 17:50:54 +07:00
|
|
|
* We should be on that channel for at least a minimum amount of
|
|
|
|
* time (10ms) but no longer than the driver supports.
|
2009-12-23 19:15:41 +07:00
|
|
|
*/
|
2012-06-01 17:50:54 +07:00
|
|
|
if (duration < NL80211_MIN_REMAIN_ON_CHANNEL_TIME ||
|
2010-12-14 23:54:28 +07:00
|
|
|
duration > rdev->wiphy.max_remain_on_channel_duration)
|
2009-12-23 19:15:41 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2012-05-11 02:27:18 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
|
|
|
|
!nl80211_valid_channel_type(info, &channel_type))
|
|
|
|
return -EINVAL;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
|
|
|
|
chan = rdev_freq_to_chan(rdev, freq, channel_type);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (chan == NULL)
|
|
|
|
return -EINVAL;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2009-12-23 19:15:41 +07:00
|
|
|
NL80211_CMD_REMAIN_ON_CHANNEL);
|
|
|
|
|
|
|
|
if (IS_ERR(hdr)) {
|
|
|
|
err = PTR_ERR(hdr);
|
|
|
|
goto free_msg;
|
|
|
|
}
|
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
err = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan,
|
2009-12-23 19:15:41 +07:00
|
|
|
channel_type, duration, &cookie);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto free_msg;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
|
|
|
|
goto nla_put_failure;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
2010-10-05 02:36:35 +07:00
|
|
|
|
|
|
|
return genlmsg_reply(msg, info);
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
err = -ENOBUFS;
|
|
|
|
free_msg:
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_cancel_remain_on_channel(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2009-12-23 19:15:41 +07:00
|
|
|
u64 cookie;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_COOKIE])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->cancel_remain_on_channel)
|
|
|
|
return -EOPNOTSUPP;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
|
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie);
|
2009-12-23 19:15:41 +07:00
|
|
|
}
|
|
|
|
|
2009-12-29 17:59:45 +07:00
|
|
|
static u32 rateset_to_mask(struct ieee80211_supported_band *sband,
|
|
|
|
u8 *rates, u8 rates_len)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u32 mask = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < rates_len; i++) {
|
|
|
|
int rate = (rates[i] & 0x7f) * 5;
|
|
|
|
int ridx;
|
|
|
|
for (ridx = 0; ridx < sband->n_bitrates; ridx++) {
|
|
|
|
struct ieee80211_rate *srate =
|
|
|
|
&sband->bitrates[ridx];
|
|
|
|
if (rate == srate->bitrate) {
|
|
|
|
mask |= 1 << ridx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ridx == sband->n_bitrates)
|
|
|
|
return 0; /* rate not found */
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2012-01-28 23:25:32 +07:00
|
|
|
static bool ht_rateset_to_mask(struct ieee80211_supported_band *sband,
|
|
|
|
u8 *rates, u8 rates_len,
|
|
|
|
u8 mcs[IEEE80211_HT_MCS_MASK_LEN])
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
memset(mcs, 0, IEEE80211_HT_MCS_MASK_LEN);
|
|
|
|
|
|
|
|
for (i = 0; i < rates_len; i++) {
|
|
|
|
int ridx, rbit;
|
|
|
|
|
|
|
|
ridx = rates[i] / 8;
|
|
|
|
rbit = BIT(rates[i] % 8);
|
|
|
|
|
|
|
|
/* check validity */
|
2012-02-01 14:42:11 +07:00
|
|
|
if ((ridx < 0) || (ridx >= IEEE80211_HT_MCS_MASK_LEN))
|
2012-01-28 23:25:32 +07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* check availability */
|
|
|
|
if (sband->ht_cap.mcs.rx_mask[ridx] & rbit)
|
|
|
|
mcs[ridx] |= rbit;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-18 15:14:31 +07:00
|
|
|
static const struct nla_policy nl80211_txattr_policy[NL80211_TXRATE_MAX + 1] = {
|
2009-12-29 17:59:45 +07:00
|
|
|
[NL80211_TXRATE_LEGACY] = { .type = NLA_BINARY,
|
|
|
|
.len = NL80211_MAX_SUPP_RATES },
|
2012-01-28 23:25:32 +07:00
|
|
|
[NL80211_TXRATE_MCS] = { .type = NLA_BINARY,
|
|
|
|
.len = NL80211_MAX_SUPP_HT_RATES },
|
2009-12-29 17:59:45 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct nlattr *tb[NL80211_TXRATE_MAX + 1];
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2009-12-29 17:59:45 +07:00
|
|
|
struct cfg80211_bitrate_mask mask;
|
2010-10-05 02:36:35 +07:00
|
|
|
int rem, i;
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2009-12-29 17:59:45 +07:00
|
|
|
struct nlattr *tx_rates;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_TX_RATES] == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->set_bitrate_mask)
|
|
|
|
return -EOPNOTSUPP;
|
2009-12-29 17:59:45 +07:00
|
|
|
|
|
|
|
memset(&mask, 0, sizeof(mask));
|
|
|
|
/* Default to all rates enabled */
|
|
|
|
for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
|
|
|
|
sband = rdev->wiphy.bands[i];
|
|
|
|
mask.control[i].legacy =
|
|
|
|
sband ? (1 << sband->n_bitrates) - 1 : 0;
|
2012-01-28 23:25:32 +07:00
|
|
|
if (sband)
|
|
|
|
memcpy(mask.control[i].mcs,
|
|
|
|
sband->ht_cap.mcs.rx_mask,
|
|
|
|
sizeof(mask.control[i].mcs));
|
|
|
|
else
|
|
|
|
memset(mask.control[i].mcs, 0,
|
|
|
|
sizeof(mask.control[i].mcs));
|
2009-12-29 17:59:45 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The nested attribute uses enum nl80211_band as the index. This maps
|
|
|
|
* directly to the enum ieee80211_band values used in cfg80211.
|
|
|
|
*/
|
2012-01-28 23:25:32 +07:00
|
|
|
BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
|
2009-12-29 17:59:45 +07:00
|
|
|
nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
|
|
|
|
{
|
|
|
|
enum ieee80211_band band = nla_type(tx_rates);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (band < 0 || band >= IEEE80211_NUM_BANDS)
|
|
|
|
return -EINVAL;
|
2009-12-29 17:59:45 +07:00
|
|
|
sband = rdev->wiphy.bands[band];
|
2010-10-05 02:36:35 +07:00
|
|
|
if (sband == NULL)
|
|
|
|
return -EINVAL;
|
2009-12-29 17:59:45 +07:00
|
|
|
nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
|
|
|
|
nla_len(tx_rates), nl80211_txattr_policy);
|
|
|
|
if (tb[NL80211_TXRATE_LEGACY]) {
|
|
|
|
mask.control[band].legacy = rateset_to_mask(
|
|
|
|
sband,
|
|
|
|
nla_data(tb[NL80211_TXRATE_LEGACY]),
|
|
|
|
nla_len(tb[NL80211_TXRATE_LEGACY]));
|
2012-04-20 20:42:58 +07:00
|
|
|
if ((mask.control[band].legacy == 0) &&
|
|
|
|
nla_len(tb[NL80211_TXRATE_LEGACY]))
|
|
|
|
return -EINVAL;
|
2012-01-28 23:25:32 +07:00
|
|
|
}
|
|
|
|
if (tb[NL80211_TXRATE_MCS]) {
|
|
|
|
if (!ht_rateset_to_mask(
|
|
|
|
sband,
|
|
|
|
nla_data(tb[NL80211_TXRATE_MCS]),
|
|
|
|
nla_len(tb[NL80211_TXRATE_MCS]),
|
|
|
|
mask.control[band].mcs))
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mask.control[band].legacy == 0) {
|
|
|
|
/* don't allow empty legacy rates if HT
|
|
|
|
* is not even supported. */
|
|
|
|
if (!rdev->wiphy.bands[band]->ht_cap.ht_supported)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++)
|
|
|
|
if (mask.control[band].mcs[i])
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* legacy and mcs rates may not be both empty */
|
|
|
|
if (i == IEEE80211_HT_MCS_MASK_LEN)
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2009-12-29 17:59:45 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, NULL, &mask);
|
2009-12-29 17:59:45 +07:00
|
|
|
}
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)
|
2010-02-15 17:53:10 +07:00
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2010-08-12 20:38:38 +07:00
|
|
|
u16 frame_type = IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_FRAME_MATCH])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_FRAME_TYPE])
|
|
|
|
frame_type = nla_get_u16(info->attrs[NL80211_ATTR_FRAME_TYPE]);
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
2012-06-16 05:19:54 +07:00
|
|
|
case NL80211_IFTYPE_P2P_DEVICE:
|
2012-06-15 20:30:18 +07:00
|
|
|
break;
|
|
|
|
default:
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EOPNOTSUPP;
|
2012-06-15 20:30:18 +07:00
|
|
|
}
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
/* not much point in registering if we can't reply */
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->mgmt_tx)
|
|
|
|
return -EOPNOTSUPP;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
return cfg80211_mlme_register_mgmt(wdev, info->snd_portid, frame_type,
|
2010-02-15 17:53:10 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH]));
|
|
|
|
}
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
|
2010-02-15 17:53:10 +07:00
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2010-02-15 17:53:10 +07:00
|
|
|
struct ieee80211_channel *chan;
|
|
|
|
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
|
2010-05-19 17:17:12 +07:00
|
|
|
bool channel_type_valid = false;
|
2010-02-15 17:53:10 +07:00
|
|
|
u32 freq;
|
|
|
|
int err;
|
2011-11-10 15:44:46 +07:00
|
|
|
void *hdr = NULL;
|
2010-02-15 17:53:10 +07:00
|
|
|
u64 cookie;
|
2011-11-04 17:18:21 +07:00
|
|
|
struct sk_buff *msg = NULL;
|
2010-11-25 16:02:29 +07:00
|
|
|
unsigned int wait = 0;
|
2011-11-04 17:18:21 +07:00
|
|
|
bool offchan, no_cck, dont_wait_for_ack;
|
|
|
|
|
|
|
|
dont_wait_for_ack = info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK];
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_FRAME] ||
|
|
|
|
!info->attrs[NL80211_ATTR_WIPHY_FREQ])
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->mgmt_tx)
|
|
|
|
return -EOPNOTSUPP;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
2012-06-16 05:19:54 +07:00
|
|
|
case NL80211_IFTYPE_P2P_DEVICE:
|
2012-06-15 20:30:18 +07:00
|
|
|
break;
|
|
|
|
default:
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EOPNOTSUPP;
|
2012-06-15 20:30:18 +07:00
|
|
|
}
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2010-11-25 16:02:29 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_DURATION]) {
|
2011-11-18 21:33:48 +07:00
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX))
|
2010-11-25 16:02:29 +07:00
|
|
|
return -EINVAL;
|
|
|
|
wait = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]);
|
2012-06-01 17:50:54 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We should wait on the channel for at least a minimum amount
|
|
|
|
* of time (10ms) but no longer than the driver supports.
|
|
|
|
*/
|
|
|
|
if (wait < NL80211_MIN_REMAIN_ON_CHANNEL_TIME ||
|
|
|
|
wait > rdev->wiphy.max_remain_on_channel_duration)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-11-25 16:02:29 +07:00
|
|
|
}
|
|
|
|
|
2010-02-15 17:53:10 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
|
2012-05-11 02:27:18 +07:00
|
|
|
if (!nl80211_valid_channel_type(info, &channel_type))
|
2010-10-05 02:36:35 +07:00
|
|
|
return -EINVAL;
|
2010-05-19 17:17:12 +07:00
|
|
|
channel_type_valid = true;
|
2010-02-15 17:53:10 +07:00
|
|
|
}
|
|
|
|
|
2010-11-25 16:02:29 +07:00
|
|
|
offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK];
|
|
|
|
|
2011-11-18 21:33:48 +07:00
|
|
|
if (offchan && !(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-09-25 16:23:30 +07:00
|
|
|
no_cck = nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
|
|
|
|
|
2010-02-15 17:53:10 +07:00
|
|
|
freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
|
|
|
|
chan = rdev_freq_to_chan(rdev, freq, channel_type);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (chan == NULL)
|
|
|
|
return -EINVAL;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2011-11-04 17:18:21 +07:00
|
|
|
if (!dont_wait_for_ack) {
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2011-11-04 17:18:21 +07:00
|
|
|
NL80211_CMD_FRAME);
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2011-11-04 17:18:21 +07:00
|
|
|
if (IS_ERR(hdr)) {
|
|
|
|
err = PTR_ERR(hdr);
|
|
|
|
goto free_msg;
|
|
|
|
}
|
2010-02-15 17:53:10 +07:00
|
|
|
}
|
2011-11-04 17:18:21 +07:00
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
err = cfg80211_mlme_mgmt_tx(rdev, wdev, chan, offchan, channel_type,
|
2010-11-25 16:02:29 +07:00
|
|
|
channel_type_valid, wait,
|
2010-08-12 20:38:38 +07:00
|
|
|
nla_data(info->attrs[NL80211_ATTR_FRAME]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_FRAME]),
|
2011-11-04 17:18:21 +07:00
|
|
|
no_cck, dont_wait_for_ack, &cookie);
|
2010-02-15 17:53:10 +07:00
|
|
|
if (err)
|
|
|
|
goto free_msg;
|
|
|
|
|
2011-11-04 17:18:21 +07:00
|
|
|
if (msg) {
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
|
|
|
|
goto nla_put_failure;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2011-11-04 17:18:21 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
return genlmsg_reply(msg, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
err = -ENOBUFS;
|
|
|
|
free_msg:
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-11-25 16:02:29 +07:00
|
|
|
static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
2010-11-25 16:02:29 +07:00
|
|
|
u64 cookie;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_COOKIE])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->mgmt_tx_cancel_wait)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
switch (wdev->iftype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
case NL80211_IFTYPE_P2P_CLIENT:
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_P2P_GO:
|
2012-06-16 05:19:54 +07:00
|
|
|
case NL80211_IFTYPE_P2P_DEVICE:
|
2012-06-15 20:30:18 +07:00
|
|
|
break;
|
|
|
|
default:
|
2010-11-25 16:02:29 +07:00
|
|
|
return -EOPNOTSUPP;
|
2012-06-15 20:30:18 +07:00
|
|
|
}
|
2010-11-25 16:02:29 +07:00
|
|
|
|
|
|
|
cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
|
|
|
|
|
2012-06-15 20:30:18 +07:00
|
|
|
return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie);
|
2010-11-25 16:02:29 +07:00
|
|
|
}
|
|
|
|
|
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 22:58:10 +07:00
|
|
|
static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
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 22:58:10 +07:00
|
|
|
struct wireless_dev *wdev;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
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 22:58:10 +07:00
|
|
|
u8 ps_state;
|
|
|
|
bool state;
|
|
|
|
int err;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_PS_STATE])
|
|
|
|
return -EINVAL;
|
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 22:58:10 +07:00
|
|
|
|
|
|
|
ps_state = nla_get_u32(info->attrs[NL80211_ATTR_PS_STATE]);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ps_state != NL80211_PS_DISABLED && ps_state != NL80211_PS_ENABLED)
|
|
|
|
return -EINVAL;
|
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 22:58:10 +07:00
|
|
|
|
|
|
|
wdev = dev->ieee80211_ptr;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->set_power_mgmt)
|
|
|
|
return -EOPNOTSUPP;
|
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 22:58:10 +07:00
|
|
|
|
|
|
|
state = (ps_state == NL80211_PS_ENABLED) ? true : false;
|
|
|
|
|
|
|
|
if (state == wdev->ps)
|
2010-10-05 02:36:35 +07:00
|
|
|
return 0;
|
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 22:58:10 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, state,
|
|
|
|
wdev->ps_timeout);
|
|
|
|
if (!err)
|
|
|
|
wdev->ps = state;
|
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 22:58:10 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
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 22:58:10 +07:00
|
|
|
enum nl80211_ps_state ps_state;
|
|
|
|
struct wireless_dev *wdev;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
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 22:58:10 +07:00
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
wdev = dev->ieee80211_ptr;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->set_power_mgmt)
|
|
|
|
return -EOPNOTSUPP;
|
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 22:58:10 +07:00
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
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 22:58:10 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
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 22:58:10 +07:00
|
|
|
NL80211_CMD_GET_POWER_SAVE);
|
|
|
|
if (!hdr) {
|
2010-10-05 02:36:35 +07:00
|
|
|
err = -ENOBUFS;
|
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 22:58:10 +07:00
|
|
|
goto free_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wdev->ps)
|
|
|
|
ps_state = NL80211_PS_ENABLED;
|
|
|
|
else
|
|
|
|
ps_state = NL80211_PS_DISABLED;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_PS_STATE, ps_state))
|
|
|
|
goto nla_put_failure;
|
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 22:58:10 +07:00
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
2010-10-05 02:36:35 +07:00
|
|
|
return genlmsg_reply(msg, info);
|
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 22:58:10 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
nla_put_failure:
|
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 22:58:10 +07:00
|
|
|
err = -ENOBUFS;
|
2010-10-05 02:36:35 +07:00
|
|
|
free_msg:
|
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 22:58:10 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-03-23 14:02:33 +07:00
|
|
|
static struct nla_policy
|
|
|
|
nl80211_attr_cqm_policy[NL80211_ATTR_CQM_MAX + 1] __read_mostly = {
|
|
|
|
[NL80211_ATTR_CQM_RSSI_THOLD] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_CQM_RSSI_HYST] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT] = { .type = NLA_U32 },
|
2012-07-13 06:17:33 +07:00
|
|
|
[NL80211_ATTR_CQM_TXE_RATE] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_CQM_TXE_PKTS] = { .type = NLA_U32 },
|
|
|
|
[NL80211_ATTR_CQM_TXE_INTVL] = { .type = NLA_U32 },
|
2010-03-23 14:02:33 +07:00
|
|
|
};
|
|
|
|
|
2012-07-13 06:17:33 +07:00
|
|
|
static int nl80211_set_cqm_txe(struct genl_info *info,
|
|
|
|
u32 rate, u32 pkts, u32 intvl)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
|
|
|
|
if ((rate < 0 || rate > 100) ||
|
|
|
|
(intvl < 0 || intvl > NL80211_CQM_TXE_MAX_INTVL))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (!rdev->ops->set_cqm_txe_config)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return rdev->ops->set_cqm_txe_config(wdev->wiphy, dev,
|
|
|
|
rate, pkts, intvl);
|
|
|
|
}
|
|
|
|
|
2010-03-23 14:02:33 +07:00
|
|
|
static int nl80211_set_cqm_rssi(struct genl_info *info,
|
|
|
|
s32 threshold, u32 hysteresis)
|
|
|
|
{
|
2010-10-05 02:36:35 +07:00
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
2010-03-23 14:02:33 +07:00
|
|
|
struct wireless_dev *wdev;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev = info->user_ptr[1];
|
2010-03-23 14:02:33 +07:00
|
|
|
|
|
|
|
if (threshold > 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
wdev = dev->ieee80211_ptr;
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
if (!rdev->ops->set_cqm_rssi_config)
|
|
|
|
return -EOPNOTSUPP;
|
2010-03-23 14:02:33 +07:00
|
|
|
|
2010-09-16 19:58:22 +07:00
|
|
|
if (wdev->iftype != NL80211_IFTYPE_STATION &&
|
2010-10-05 02:36:35 +07:00
|
|
|
wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
|
|
|
|
return -EOPNOTSUPP;
|
2010-03-23 14:02:33 +07:00
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
return rdev->ops->set_cqm_rssi_config(wdev->wiphy, dev,
|
|
|
|
threshold, hysteresis);
|
2010-03-23 14:02:33 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct nlattr *attrs[NL80211_ATTR_CQM_MAX + 1];
|
|
|
|
struct nlattr *cqm;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
cqm = info->attrs[NL80211_ATTR_CQM];
|
|
|
|
if (!cqm) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = nla_parse_nested(attrs, NL80211_ATTR_CQM_MAX, cqm,
|
|
|
|
nl80211_attr_cqm_policy);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (attrs[NL80211_ATTR_CQM_RSSI_THOLD] &&
|
|
|
|
attrs[NL80211_ATTR_CQM_RSSI_HYST]) {
|
|
|
|
s32 threshold;
|
|
|
|
u32 hysteresis;
|
|
|
|
threshold = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_THOLD]);
|
|
|
|
hysteresis = nla_get_u32(attrs[NL80211_ATTR_CQM_RSSI_HYST]);
|
|
|
|
err = nl80211_set_cqm_rssi(info, threshold, hysteresis);
|
2012-07-13 06:17:33 +07:00
|
|
|
} else if (attrs[NL80211_ATTR_CQM_TXE_RATE] &&
|
|
|
|
attrs[NL80211_ATTR_CQM_TXE_PKTS] &&
|
|
|
|
attrs[NL80211_ATTR_CQM_TXE_INTVL]) {
|
|
|
|
u32 rate, pkts, intvl;
|
|
|
|
rate = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_RATE]);
|
|
|
|
pkts = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_PKTS]);
|
|
|
|
intvl = nla_get_u32(attrs[NL80211_ATTR_CQM_TXE_INTVL]);
|
|
|
|
err = nl80211_set_cqm_txe(info, rate, pkts, intvl);
|
2010-03-23 14:02:33 +07:00
|
|
|
} else
|
|
|
|
err = -EINVAL;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2010-12-03 15:20:44 +07:00
|
|
|
static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct mesh_config cfg;
|
2010-12-17 08:37:49 +07:00
|
|
|
struct mesh_setup setup;
|
2010-12-03 15:20:44 +07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
/* start with default */
|
|
|
|
memcpy(&cfg, &default_mesh_config, sizeof(cfg));
|
2010-12-17 08:37:49 +07:00
|
|
|
memcpy(&setup, &default_mesh_setup, sizeof(setup));
|
2010-12-03 15:20:44 +07:00
|
|
|
|
2010-12-17 08:37:48 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MESH_CONFIG]) {
|
2010-12-03 15:20:44 +07:00
|
|
|
/* and parse parameters if given */
|
2010-12-17 08:37:48 +07:00
|
|
|
err = nl80211_parse_mesh_config(info, &cfg, NULL);
|
2010-12-03 15:20:44 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MESH_ID] ||
|
|
|
|
!nla_len(info->attrs[NL80211_ATTR_MESH_ID]))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
setup.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
|
|
|
|
setup.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);
|
|
|
|
|
2011-11-25 08:15:20 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MCAST_RATE] &&
|
|
|
|
!nl80211_parse_mcast_rate(rdev, setup.mcast_rate,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE])))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_MESH_SETUP]) {
|
|
|
|
/* parse additional setup parameters if given */
|
|
|
|
err = nl80211_parse_mesh_setup(info, &setup);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-05-17 04:50:20 +07:00
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
|
|
|
|
enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
|
|
|
|
|
|
|
|
if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
|
|
|
|
!nl80211_valid_channel_type(info, &channel_type))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
setup.channel = rdev_freq_to_chan(rdev,
|
|
|
|
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]),
|
|
|
|
channel_type);
|
|
|
|
if (!setup.channel)
|
|
|
|
return -EINVAL;
|
|
|
|
setup.channel_type = channel_type;
|
|
|
|
} else {
|
|
|
|
/* cfg80211_join_mesh() will sort it out */
|
|
|
|
setup.channel = NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-17 08:37:49 +07:00
|
|
|
return cfg80211_join_mesh(rdev, dev, &setup, &cfg);
|
2010-12-03 15:20:44 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_leave_mesh(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
|
|
|
|
return cfg80211_leave_mesh(rdev, dev);
|
|
|
|
}
|
|
|
|
|
2012-06-27 14:23:48 +07:00
|
|
|
#ifdef CONFIG_PM
|
2011-05-04 20:37:28 +07:00
|
|
|
static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2011-05-04 20:37:28 +07:00
|
|
|
NL80211_CMD_GET_WOWLAN);
|
|
|
|
if (!hdr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (rdev->wowlan) {
|
|
|
|
struct nlattr *nl_wowlan;
|
|
|
|
|
|
|
|
nl_wowlan = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS);
|
|
|
|
if (!nl_wowlan)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if ((rdev->wowlan->any &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_ANY)) ||
|
|
|
|
(rdev->wowlan->disconnect &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) ||
|
|
|
|
(rdev->wowlan->magic_pkt &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_MAGIC_PKT)) ||
|
|
|
|
(rdev->wowlan->gtk_rekey_failure &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE)) ||
|
|
|
|
(rdev->wowlan->eap_identity_req &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST)) ||
|
|
|
|
(rdev->wowlan->four_way_handshake &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE)) ||
|
|
|
|
(rdev->wowlan->rfkill_release &&
|
|
|
|
nla_put_flag(msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE)))
|
|
|
|
goto nla_put_failure;
|
2011-05-04 20:37:28 +07:00
|
|
|
if (rdev->wowlan->n_patterns) {
|
|
|
|
struct nlattr *nl_pats, *nl_pat;
|
|
|
|
int i, pat_len;
|
|
|
|
|
|
|
|
nl_pats = nla_nest_start(msg,
|
|
|
|
NL80211_WOWLAN_TRIG_PKT_PATTERN);
|
|
|
|
if (!nl_pats)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
for (i = 0; i < rdev->wowlan->n_patterns; i++) {
|
|
|
|
nl_pat = nla_nest_start(msg, i + 1);
|
|
|
|
if (!nl_pat)
|
|
|
|
goto nla_put_failure;
|
|
|
|
pat_len = rdev->wowlan->patterns[i].pattern_len;
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put(msg, NL80211_WOWLAN_PKTPAT_MASK,
|
|
|
|
DIV_ROUND_UP(pat_len, 8),
|
|
|
|
rdev->wowlan->patterns[i].mask) ||
|
|
|
|
nla_put(msg, NL80211_WOWLAN_PKTPAT_PATTERN,
|
|
|
|
pat_len,
|
|
|
|
rdev->wowlan->patterns[i].pattern))
|
|
|
|
goto nla_put_failure;
|
2011-05-04 20:37:28 +07:00
|
|
|
nla_nest_end(msg, nl_pat);
|
|
|
|
}
|
|
|
|
nla_nest_end(msg, nl_pats);
|
|
|
|
}
|
|
|
|
|
|
|
|
nla_nest_end(msg, nl_wowlan);
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
return genlmsg_reply(msg, info);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct nlattr *tb[NUM_NL80211_WOWLAN_TRIG];
|
|
|
|
struct cfg80211_wowlan new_triggers = {};
|
2012-07-12 21:25:02 +07:00
|
|
|
struct cfg80211_wowlan *ntrig;
|
2011-05-04 20:37:28 +07:00
|
|
|
struct wiphy_wowlan_support *wowlan = &rdev->wiphy.wowlan;
|
|
|
|
int err, i;
|
2012-04-04 20:05:25 +07:00
|
|
|
bool prev_enabled = rdev->wowlan;
|
2011-05-04 20:37:28 +07:00
|
|
|
|
|
|
|
if (!rdev->wiphy.wowlan.flags && !rdev->wiphy.wowlan.n_patterns)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-07-12 21:25:02 +07:00
|
|
|
if (!info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]) {
|
|
|
|
cfg80211_rdev_free_wowlan(rdev);
|
|
|
|
rdev->wowlan = NULL;
|
|
|
|
goto set_wakeup;
|
|
|
|
}
|
2011-05-04 20:37:28 +07:00
|
|
|
|
|
|
|
err = nla_parse(tb, MAX_NL80211_WOWLAN_TRIG,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
|
|
|
|
nl80211_wowlan_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_ANY]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_ANY))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.any = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_DISCONNECT]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_DISCONNECT))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.disconnect = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_MAGIC_PKT]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_MAGIC_PKT))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.magic_pkt = true;
|
|
|
|
}
|
|
|
|
|
2011-07-13 15:48:55 +07:00
|
|
|
if (tb[NL80211_WOWLAN_TRIG_GTK_REKEY_SUPPORTED])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.gtk_rekey_failure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_EAP_IDENTITY_REQ))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.eap_identity_req = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_4WAY_HANDSHAKE))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.four_way_handshake = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) {
|
|
|
|
if (!(wowlan->flags & WIPHY_WOWLAN_RFKILL_RELEASE))
|
|
|
|
return -EINVAL;
|
|
|
|
new_triggers.rfkill_release = true;
|
|
|
|
}
|
|
|
|
|
2011-05-04 20:37:28 +07:00
|
|
|
if (tb[NL80211_WOWLAN_TRIG_PKT_PATTERN]) {
|
|
|
|
struct nlattr *pat;
|
|
|
|
int n_patterns = 0;
|
|
|
|
int rem, pat_len, mask_len;
|
|
|
|
struct nlattr *pat_tb[NUM_NL80211_WOWLAN_PKTPAT];
|
|
|
|
|
|
|
|
nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
|
|
|
|
rem)
|
|
|
|
n_patterns++;
|
|
|
|
if (n_patterns > wowlan->n_patterns)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
new_triggers.patterns = kcalloc(n_patterns,
|
|
|
|
sizeof(new_triggers.patterns[0]),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!new_triggers.patterns)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
new_triggers.n_patterns = n_patterns;
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
nla_for_each_nested(pat, tb[NL80211_WOWLAN_TRIG_PKT_PATTERN],
|
|
|
|
rem) {
|
|
|
|
nla_parse(pat_tb, MAX_NL80211_WOWLAN_PKTPAT,
|
|
|
|
nla_data(pat), nla_len(pat), NULL);
|
|
|
|
err = -EINVAL;
|
|
|
|
if (!pat_tb[NL80211_WOWLAN_PKTPAT_MASK] ||
|
|
|
|
!pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN])
|
|
|
|
goto error;
|
|
|
|
pat_len = nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]);
|
|
|
|
mask_len = DIV_ROUND_UP(pat_len, 8);
|
|
|
|
if (nla_len(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]) !=
|
|
|
|
mask_len)
|
|
|
|
goto error;
|
|
|
|
if (pat_len > wowlan->pattern_max_len ||
|
|
|
|
pat_len < wowlan->pattern_min_len)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
new_triggers.patterns[i].mask =
|
|
|
|
kmalloc(mask_len + pat_len, GFP_KERNEL);
|
|
|
|
if (!new_triggers.patterns[i].mask) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
new_triggers.patterns[i].pattern =
|
|
|
|
new_triggers.patterns[i].mask + mask_len;
|
|
|
|
memcpy(new_triggers.patterns[i].mask,
|
|
|
|
nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_MASK]),
|
|
|
|
mask_len);
|
|
|
|
new_triggers.patterns[i].pattern_len = pat_len;
|
|
|
|
memcpy(new_triggers.patterns[i].pattern,
|
|
|
|
nla_data(pat_tb[NL80211_WOWLAN_PKTPAT_PATTERN]),
|
|
|
|
pat_len);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-12 21:25:02 +07:00
|
|
|
ntrig = kmemdup(&new_triggers, sizeof(new_triggers), GFP_KERNEL);
|
|
|
|
if (!ntrig) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto error;
|
2011-05-04 20:37:28 +07:00
|
|
|
}
|
2012-07-12 21:25:02 +07:00
|
|
|
cfg80211_rdev_free_wowlan(rdev);
|
|
|
|
rdev->wowlan = ntrig;
|
2011-05-04 20:37:28 +07:00
|
|
|
|
2012-07-12 21:25:02 +07:00
|
|
|
set_wakeup:
|
2012-04-04 20:05:25 +07:00
|
|
|
if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan)
|
|
|
|
rdev->ops->set_wakeup(&rdev->wiphy, rdev->wowlan);
|
|
|
|
|
2011-05-04 20:37:28 +07:00
|
|
|
return 0;
|
|
|
|
error:
|
|
|
|
for (i = 0; i < new_triggers.n_patterns; i++)
|
|
|
|
kfree(new_triggers.patterns[i].mask);
|
|
|
|
kfree(new_triggers.patterns);
|
|
|
|
return err;
|
|
|
|
}
|
2012-06-27 14:23:48 +07:00
|
|
|
#endif
|
2011-05-04 20:37:28 +07:00
|
|
|
|
2011-07-05 21:35:40 +07:00
|
|
|
static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct nlattr *tb[NUM_NL80211_REKEY_DATA];
|
|
|
|
struct cfg80211_gtk_rekey_data rekey_data;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_REKEY_DATA])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nla_parse(tb, MAX_NL80211_REKEY_DATA,
|
|
|
|
nla_data(info->attrs[NL80211_ATTR_REKEY_DATA]),
|
|
|
|
nla_len(info->attrs[NL80211_ATTR_REKEY_DATA]),
|
|
|
|
nl80211_rekey_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (nla_len(tb[NL80211_REKEY_DATA_REPLAY_CTR]) != NL80211_REPLAY_CTR_LEN)
|
|
|
|
return -ERANGE;
|
|
|
|
if (nla_len(tb[NL80211_REKEY_DATA_KEK]) != NL80211_KEK_LEN)
|
|
|
|
return -ERANGE;
|
|
|
|
if (nla_len(tb[NL80211_REKEY_DATA_KCK]) != NL80211_KCK_LEN)
|
|
|
|
return -ERANGE;
|
|
|
|
|
|
|
|
memcpy(rekey_data.kek, nla_data(tb[NL80211_REKEY_DATA_KEK]),
|
|
|
|
NL80211_KEK_LEN);
|
|
|
|
memcpy(rekey_data.kck, nla_data(tb[NL80211_REKEY_DATA_KCK]),
|
|
|
|
NL80211_KCK_LEN);
|
|
|
|
memcpy(rekey_data.replay_ctr,
|
|
|
|
nla_data(tb[NL80211_REKEY_DATA_REPLAY_CTR]),
|
|
|
|
NL80211_REPLAY_CTR_LEN);
|
|
|
|
|
|
|
|
wdev_lock(wdev);
|
|
|
|
if (!wdev->current_bss) {
|
|
|
|
err = -ENOTCONN;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rdev->ops->set_rekey_data) {
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rdev->ops->set_rekey_data(&rdev->wiphy, dev, &rekey_data);
|
|
|
|
out:
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:12 +07:00
|
|
|
static int nl80211_register_unexpected_frame(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (wdev->ap_unexpected_nlportid)
|
2011-11-04 17:18:12 +07:00
|
|
|
return -EBUSY;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
wdev->ap_unexpected_nlportid = info->snd_portid;
|
2011-11-04 17:18:12 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:15 +07:00
|
|
|
static int nl80211_probe_client(struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct net_device *dev = info->user_ptr[1];
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
const u8 *addr;
|
|
|
|
u64 cookie;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_AP &&
|
|
|
|
wdev->iftype != NL80211_IFTYPE_P2P_GO)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!info->attrs[NL80211_ATTR_MAC])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (!rdev->ops->probe_client)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
|
2011-11-04 17:18:15 +07:00
|
|
|
NL80211_CMD_PROBE_CLIENT);
|
|
|
|
|
|
|
|
if (IS_ERR(hdr)) {
|
|
|
|
err = PTR_ERR(hdr);
|
|
|
|
goto free_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
|
|
|
|
|
|
|
|
err = rdev->ops->probe_client(&rdev->wiphy, dev, addr, &cookie);
|
|
|
|
if (err)
|
|
|
|
goto free_msg;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
|
|
|
|
goto nla_put_failure;
|
2011-11-04 17:18:15 +07:00
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
return genlmsg_reply(msg, info);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
err = -ENOBUFS;
|
|
|
|
free_msg:
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:17 +07:00
|
|
|
static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
|
|
|
|
if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (rdev->ap_beacons_nlportid)
|
2011-11-04 17:18:17 +07:00
|
|
|
return -EBUSY;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
rdev->ap_beacons_nlportid = info->snd_portid;
|
2011-11-04 17:18:17 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-16 05:19:54 +07:00
|
|
|
static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!rdev->ops->start_p2p_device)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (wdev->p2p_started)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
err = cfg80211_can_add_interface(rdev, wdev->iftype);
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = rdev->ops->start_p2p_device(&rdev->wiphy, wdev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
wdev->p2p_started = true;
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
rdev->opencount++;
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = info->user_ptr[0];
|
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
|
|
|
|
|
|
|
if (wdev->iftype != NL80211_IFTYPE_P2P_DEVICE)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->stop_p2p_device)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!wdev->p2p_started)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rdev->ops->stop_p2p_device(&rdev->wiphy, wdev);
|
|
|
|
wdev->p2p_started = false;
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
rdev->opencount--;
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
if (WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev)) {
|
|
|
|
rdev->scan_req->aborted = true;
|
|
|
|
___cfg80211_scan_done(rdev, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
#define NL80211_FLAG_NEED_WIPHY 0x01
|
|
|
|
#define NL80211_FLAG_NEED_NETDEV 0x02
|
|
|
|
#define NL80211_FLAG_NEED_RTNL 0x04
|
2010-10-05 02:14:05 +07:00
|
|
|
#define NL80211_FLAG_CHECK_NETDEV_UP 0x08
|
|
|
|
#define NL80211_FLAG_NEED_NETDEV_UP (NL80211_FLAG_NEED_NETDEV |\
|
|
|
|
NL80211_FLAG_CHECK_NETDEV_UP)
|
2012-06-15 20:23:36 +07:00
|
|
|
#define NL80211_FLAG_NEED_WDEV 0x10
|
2012-06-16 05:19:54 +07:00
|
|
|
/* If a netdev is associated, it must be UP, P2P must be started */
|
2012-06-15 20:23:36 +07:00
|
|
|
#define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\
|
|
|
|
NL80211_FLAG_CHECK_NETDEV_UP)
|
2010-10-05 02:36:35 +07:00
|
|
|
|
|
|
|
static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev;
|
2012-06-15 19:33:17 +07:00
|
|
|
struct wireless_dev *wdev;
|
2010-10-05 02:36:35 +07:00
|
|
|
struct net_device *dev;
|
|
|
|
bool rtnl = ops->internal_flags & NL80211_FLAG_NEED_RTNL;
|
|
|
|
|
|
|
|
if (rtnl)
|
|
|
|
rtnl_lock();
|
|
|
|
|
|
|
|
if (ops->internal_flags & NL80211_FLAG_NEED_WIPHY) {
|
2012-06-15 19:14:22 +07:00
|
|
|
rdev = cfg80211_get_dev_from_info(genl_info_net(info), info);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (IS_ERR(rdev)) {
|
|
|
|
if (rtnl)
|
|
|
|
rtnl_unlock();
|
|
|
|
return PTR_ERR(rdev);
|
|
|
|
}
|
|
|
|
info->user_ptr[0] = rdev;
|
2012-06-15 20:23:36 +07:00
|
|
|
} else if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV ||
|
|
|
|
ops->internal_flags & NL80211_FLAG_NEED_WDEV) {
|
2012-06-15 19:33:17 +07:00
|
|
|
mutex_lock(&cfg80211_mutex);
|
|
|
|
wdev = __cfg80211_wdev_from_attrs(genl_info_net(info),
|
|
|
|
info->attrs);
|
|
|
|
if (IS_ERR(wdev)) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
2010-10-05 02:36:35 +07:00
|
|
|
if (rtnl)
|
|
|
|
rtnl_unlock();
|
2012-06-15 19:33:17 +07:00
|
|
|
return PTR_ERR(wdev);
|
2010-10-05 02:36:35 +07:00
|
|
|
}
|
2012-06-15 19:33:17 +07:00
|
|
|
|
|
|
|
dev = wdev->netdev;
|
|
|
|
rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
|
2012-06-15 20:23:36 +07:00
|
|
|
if (ops->internal_flags & NL80211_FLAG_NEED_NETDEV) {
|
|
|
|
if (!dev) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
if (rtnl)
|
|
|
|
rtnl_unlock();
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->user_ptr[1] = dev;
|
|
|
|
} else {
|
|
|
|
info->user_ptr[1] = wdev;
|
2010-10-05 02:14:05 +07:00
|
|
|
}
|
2012-06-15 20:23:36 +07:00
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP &&
|
|
|
|
!netif_running(dev)) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
if (rtnl)
|
|
|
|
rtnl_unlock();
|
|
|
|
return -ENETDOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_hold(dev);
|
2012-06-16 05:19:54 +07:00
|
|
|
} else if (ops->internal_flags & NL80211_FLAG_CHECK_NETDEV_UP) {
|
|
|
|
if (!wdev->p2p_started) {
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
if (rtnl)
|
|
|
|
rtnl_unlock();
|
|
|
|
return -ENETDOWN;
|
|
|
|
}
|
2010-10-05 02:14:05 +07:00
|
|
|
}
|
2012-06-15 19:33:17 +07:00
|
|
|
|
|
|
|
cfg80211_lock_rdev(rdev);
|
|
|
|
|
|
|
|
mutex_unlock(&cfg80211_mutex);
|
|
|
|
|
2010-10-05 02:36:35 +07:00
|
|
|
info->user_ptr[0] = rdev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb,
|
|
|
|
struct genl_info *info)
|
|
|
|
{
|
|
|
|
if (info->user_ptr[0])
|
|
|
|
cfg80211_unlock_rdev(info->user_ptr[0]);
|
2012-06-15 20:23:36 +07:00
|
|
|
if (info->user_ptr[1]) {
|
|
|
|
if (ops->internal_flags & NL80211_FLAG_NEED_WDEV) {
|
|
|
|
struct wireless_dev *wdev = info->user_ptr[1];
|
|
|
|
|
|
|
|
if (wdev->netdev)
|
|
|
|
dev_put(wdev->netdev);
|
|
|
|
} else {
|
|
|
|
dev_put(info->user_ptr[1]);
|
|
|
|
}
|
|
|
|
}
|
2010-10-05 02:36:35 +07:00
|
|
|
if (ops->internal_flags & NL80211_FLAG_NEED_RTNL)
|
|
|
|
rtnl_unlock();
|
|
|
|
}
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
static struct genl_ops nl80211_ops[] = {
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_WIPHY,
|
|
|
|
.doit = nl80211_get_wiphy,
|
|
|
|
.dumpit = nl80211_dump_wiphy,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_WIPHY,
|
|
|
|
.doit = nl80211_set_wiphy,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_RTNL,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_INTERFACE,
|
|
|
|
.doit = nl80211_get_interface,
|
|
|
|
.dumpit = nl80211_dump_interface,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
2012-06-15 22:52:47 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_INTERFACE,
|
|
|
|
.doit = nl80211_set_interface,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_NEW_INTERFACE,
|
|
|
|
.doit = nl80211_new_interface,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEL_INTERFACE,
|
|
|
|
.doit = nl80211_del_interface,
|
|
|
|
.policy = nl80211_policy,
|
2007-12-19 08:03:29 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-16 05:00:26 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:29 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_KEY,
|
|
|
|
.doit = nl80211_get_key,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:29 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_KEY,
|
|
|
|
.doit = nl80211_set_key,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:29 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_NEW_KEY,
|
|
|
|
.doit = nl80211_new_key,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:29 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEL_KEY,
|
|
|
|
.doit = nl80211_del_key,
|
|
|
|
.policy = nl80211_policy,
|
2007-09-21 00:09:35 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-09-21 00:09:35 +07:00
|
|
|
},
|
2007-12-19 08:03:32 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_BEACON,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-02-13 21:17:18 +07:00
|
|
|
.doit = nl80211_set_beacon,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:32 +07:00
|
|
|
},
|
|
|
|
{
|
2012-02-13 21:17:18 +07:00
|
|
|
.cmd = NL80211_CMD_START_AP,
|
2007-12-19 08:03:32 +07:00
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-02-13 21:17:18 +07:00
|
|
|
.doit = nl80211_start_ap,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:32 +07:00
|
|
|
},
|
|
|
|
{
|
2012-02-13 21:17:18 +07:00
|
|
|
.cmd = NL80211_CMD_STOP_AP,
|
2007-12-19 08:03:32 +07:00
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-02-13 21:17:18 +07:00
|
|
|
.doit = nl80211_stop_ap,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:32 +07:00
|
|
|
},
|
2007-12-19 08:03:34 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_STATION,
|
|
|
|
.doit = nl80211_get_station,
|
2008-02-23 21:17:06 +07:00
|
|
|
.dumpit = nl80211_dump_station,
|
2007-12-19 08:03:34 +07:00
|
|
|
.policy = nl80211_policy,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:34 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_STATION,
|
|
|
|
.doit = nl80211_set_station,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:34 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_NEW_STATION,
|
|
|
|
.doit = nl80211_new_station,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2007-12-19 08:03:34 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEL_STATION,
|
|
|
|
.doit = nl80211_del_station,
|
|
|
|
.policy = nl80211_policy,
|
2008-02-23 21:17:06 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-02-23 21:17:06 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_MPATH,
|
|
|
|
.doit = nl80211_get_mpath,
|
|
|
|
.dumpit = nl80211_dump_mpath,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-02-23 21:17:06 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_MPATH,
|
|
|
|
.doit = nl80211_set_mpath,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-02-23 21:17:06 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_NEW_MPATH,
|
|
|
|
.doit = nl80211_new_mpath,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-02-23 21:17:06 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEL_MPATH,
|
|
|
|
.doit = nl80211_del_mpath,
|
|
|
|
.policy = nl80211_policy,
|
2008-08-08 00:07:01 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-08-08 00:07:01 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_BSS,
|
|
|
|
.doit = nl80211_set_bss,
|
|
|
|
.policy = nl80211_policy,
|
2008-09-10 13:19:48 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-09-10 13:19:48 +07:00
|
|
|
},
|
2009-01-31 00:26:42 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_REG,
|
|
|
|
.doit = nl80211_get_reg,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
|
|
|
},
|
2008-09-10 13:19:48 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_REG,
|
|
|
|
.doit = nl80211_set_reg,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_REQ_SET_REG,
|
|
|
|
.doit = nl80211_req_set_reg,
|
|
|
|
.policy = nl80211_policy,
|
2008-10-22 02:03:48 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
},
|
|
|
|
{
|
2010-12-17 08:37:48 +07:00
|
|
|
.cmd = NL80211_CMD_GET_MESH_CONFIG,
|
|
|
|
.doit = nl80211_get_mesh_config,
|
2008-10-22 02:03:48 +07:00
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2008-10-22 02:03:48 +07:00
|
|
|
},
|
|
|
|
{
|
2010-12-17 08:37:48 +07:00
|
|
|
.cmd = NL80211_CMD_SET_MESH_CONFIG,
|
|
|
|
.doit = nl80211_update_mesh_config,
|
2008-10-22 02:03:48 +07:00
|
|
|
.policy = nl80211_policy,
|
2009-01-13 21:03:29 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-12-03 15:20:44 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-01-13 21:03:29 +07:00
|
|
|
},
|
2009-02-11 03:25:55 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_TRIGGER_SCAN,
|
|
|
|
.doit = nl80211_trigger_scan,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-19 00:17:03 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-02-11 03:25:55 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_SCAN,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.dumpit = nl80211_dump_scan,
|
|
|
|
},
|
2011-05-11 21:09:35 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_START_SCHED_SCAN,
|
|
|
|
.doit = nl80211_start_sched_scan,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_STOP_SCHED_SCAN,
|
|
|
|
.doit = nl80211_stop_sched_scan,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2009-03-19 18:39:22 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_AUTHENTICATE,
|
|
|
|
.doit = nl80211_authenticate,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-03-19 18:39:22 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_ASSOCIATE,
|
|
|
|
.doit = nl80211_associate,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-03-19 18:39:22 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEAUTHENTICATE,
|
|
|
|
.doit = nl80211_deauthenticate,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-03-19 18:39:22 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DISASSOCIATE,
|
|
|
|
.doit = nl80211_disassociate,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-03-19 18:39:22 +07:00
|
|
|
},
|
2009-04-20 02:24:32 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_JOIN_IBSS,
|
|
|
|
.doit = nl80211_join_ibss,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-04-20 02:24:32 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_LEAVE_IBSS,
|
|
|
|
.doit = nl80211_leave_ibss,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-04-20 02:24:32 +07:00
|
|
|
},
|
2009-07-02 02:26:51 +07:00
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_TESTMODE,
|
|
|
|
.doit = nl80211_testmode_do,
|
2011-05-20 23:05:54 +07:00
|
|
|
.dumpit = nl80211_testmode_dump,
|
2009-07-02 02:26:51 +07:00
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-07-02 02:26:51 +07:00
|
|
|
},
|
|
|
|
#endif
|
2009-07-02 02:26:54 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_CONNECT,
|
|
|
|
.doit = nl80211_connect,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-07-02 02:26:54 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DISCONNECT,
|
|
|
|
.doit = nl80211_disconnect,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:14:05 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-07-02 02:26:54 +07:00
|
|
|
},
|
2009-07-14 05:33:35 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_WIPHY_NETNS,
|
|
|
|
.doit = nl80211_wiphy_netns,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-07-14 05:33:35 +07:00
|
|
|
},
|
2009-11-11 18:25:40 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_SURVEY,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.dumpit = nl80211_dump_survey,
|
|
|
|
},
|
2009-11-25 05:59:15 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_PMKSA,
|
|
|
|
.doit = nl80211_setdel_pmksa,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-11-25 05:59:15 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_DEL_PMKSA,
|
|
|
|
.doit = nl80211_setdel_pmksa,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-11-25 05:59:15 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_FLUSH_PMKSA,
|
|
|
|
.doit = nl80211_flush_pmksa,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-11-25 05:59:15 +07:00
|
|
|
},
|
2009-12-23 19:15:41 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_REMAIN_ON_CHANNEL,
|
|
|
|
.doit = nl80211_remain_on_channel,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-15 20:30:18 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-12-23 19:15:41 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
|
|
|
|
.doit = nl80211_cancel_remain_on_channel,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-15 20:30:18 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-12-23 19:15:41 +07:00
|
|
|
},
|
2009-12-29 17:59:45 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_TX_BITRATE_MASK,
|
|
|
|
.doit = nl80211_set_tx_bitrate_mask,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2009-12-29 17:59:45 +07:00
|
|
|
},
|
2010-02-15 17:53:10 +07:00
|
|
|
{
|
2010-08-12 20:38:38 +07:00
|
|
|
.cmd = NL80211_CMD_REGISTER_FRAME,
|
|
|
|
.doit = nl80211_register_mgmt,
|
2010-02-15 17:53:10 +07:00
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-15 20:30:18 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2010-02-15 17:53:10 +07:00
|
|
|
},
|
|
|
|
{
|
2010-08-12 20:38:38 +07:00
|
|
|
.cmd = NL80211_CMD_FRAME,
|
|
|
|
.doit = nl80211_tx_mgmt,
|
2010-02-15 17:53:10 +07:00
|
|
|
.policy = nl80211_policy,
|
2010-11-25 16:02:29 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-15 20:30:18 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
2010-11-25 16:02:29 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_FRAME_WAIT_CANCEL,
|
|
|
|
.doit = nl80211_tx_mgmt_cancel_wait,
|
|
|
|
.policy = nl80211_policy,
|
2010-02-15 17:53:10 +07:00
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-06-15 20:30:18 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
2010-10-05 02:36:35 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2010-02-15 17:53:10 +07:00
|
|
|
},
|
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 22:58:10 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_POWER_SAVE,
|
|
|
|
.doit = nl80211_set_power_save,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
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 22:58:10 +07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_POWER_SAVE,
|
|
|
|
.doit = nl80211_get_power_save,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
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 22:58:10 +07:00
|
|
|
},
|
2010-03-23 14:02:33 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_CQM,
|
|
|
|
.doit = nl80211_set_cqm,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2010-03-23 14:02:33 +07:00
|
|
|
},
|
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 20:25:02 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_CHANNEL,
|
|
|
|
.doit = nl80211_set_channel,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-05 02:36:35 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
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 20:25:02 +07:00
|
|
|
},
|
2010-10-02 00:54:28 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_WDS_PEER,
|
|
|
|
.doit = nl80211_set_wds_peer,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2010-10-07 18:10:30 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
2010-10-02 00:54:28 +07:00
|
|
|
},
|
2010-12-03 15:20:44 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_JOIN_MESH,
|
|
|
|
.doit = nl80211_join_mesh,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_LEAVE_MESH,
|
|
|
|
.doit = nl80211_leave_mesh,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2012-06-27 14:23:48 +07:00
|
|
|
#ifdef CONFIG_PM
|
2011-05-04 20:37:28 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_GET_WOWLAN,
|
|
|
|
.doit = nl80211_get_wowlan,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
/* can be retrieved by unprivileged users */
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_WOWLAN,
|
|
|
|
.doit = nl80211_set_wowlan,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2012-06-27 14:23:48 +07:00
|
|
|
#endif
|
2011-07-05 21:35:40 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_REKEY_OFFLOAD,
|
|
|
|
.doit = nl80211_set_rekey_data,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2011-09-28 18:12:50 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_TDLS_MGMT,
|
|
|
|
.doit = nl80211_tdls_mgmt,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_TDLS_OPER,
|
|
|
|
.doit = nl80211_tdls_oper,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2011-11-04 17:18:12 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_UNEXPECTED_FRAME,
|
|
|
|
.doit = nl80211_register_unexpected_frame,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2011-11-04 17:18:15 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_PROBE_CLIENT,
|
|
|
|
.doit = nl80211_probe_client,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
2012-04-02 15:51:55 +07:00
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV_UP |
|
2011-11-04 17:18:15 +07:00
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2011-11-04 17:18:17 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_REGISTER_BEACONS,
|
|
|
|
.doit = nl80211_register_beacons,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_WIPHY |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2011-11-18 20:20:43 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_SET_NOACK_MAP,
|
|
|
|
.doit = nl80211_set_noack_map,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_NETDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2012-06-16 05:19:54 +07:00
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_START_P2P_DEVICE,
|
|
|
|
.doit = nl80211_start_p2p_device,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = NL80211_CMD_STOP_P2P_DEVICE,
|
|
|
|
.doit = nl80211_stop_p2p_device,
|
|
|
|
.policy = nl80211_policy,
|
|
|
|
.flags = GENL_ADMIN_PERM,
|
|
|
|
.internal_flags = NL80211_FLAG_NEED_WDEV_UP |
|
|
|
|
NL80211_FLAG_NEED_RTNL,
|
|
|
|
},
|
2007-09-21 00:09:35 +07:00
|
|
|
};
|
2009-12-23 19:15:41 +07:00
|
|
|
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
static struct genl_multicast_group nl80211_mlme_mcgrp = {
|
|
|
|
.name = "mlme",
|
|
|
|
};
|
2007-09-21 00:09:35 +07:00
|
|
|
|
|
|
|
/* multicast groups */
|
|
|
|
static struct genl_multicast_group nl80211_config_mcgrp = {
|
|
|
|
.name = "config",
|
|
|
|
};
|
2009-02-11 03:25:55 +07:00
|
|
|
static struct genl_multicast_group nl80211_scan_mcgrp = {
|
|
|
|
.name = "scan",
|
|
|
|
};
|
2009-03-10 09:07:42 +07:00
|
|
|
static struct genl_multicast_group nl80211_regulatory_mcgrp = {
|
|
|
|
.name = "regulatory",
|
|
|
|
};
|
2007-09-21 00:09:35 +07:00
|
|
|
|
|
|
|
/* notification functions */
|
|
|
|
|
|
|
|
void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2007-09-21 00:09:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (nl80211_send_wiphy(msg, 0, 0, 0, rdev) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_config_mcgrp.id, GFP_KERNEL);
|
2007-09-21 00:09:35 +07:00
|
|
|
}
|
|
|
|
|
2009-05-24 21:43:15 +07:00
|
|
|
static int nl80211_add_scan_req(struct sk_buff *msg,
|
|
|
|
struct cfg80211_registered_device *rdev)
|
|
|
|
{
|
|
|
|
struct cfg80211_scan_request *req = rdev->scan_req;
|
|
|
|
struct nlattr *nest;
|
|
|
|
int i;
|
|
|
|
|
2009-07-07 08:56:11 +07:00
|
|
|
ASSERT_RDEV_LOCK(rdev);
|
|
|
|
|
2009-05-24 21:43:15 +07:00
|
|
|
if (WARN_ON(!req))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nest = nla_nest_start(msg, NL80211_ATTR_SCAN_SSIDS);
|
|
|
|
if (!nest)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
for (i = 0; i < req->n_ssids; i++) {
|
|
|
|
if (nla_put(msg, i, req->ssids[i].ssid_len, req->ssids[i].ssid))
|
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
2009-05-24 21:43:15 +07:00
|
|
|
nla_nest_end(msg, nest);
|
|
|
|
|
|
|
|
nest = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES);
|
|
|
|
if (!nest)
|
|
|
|
goto nla_put_failure;
|
2012-03-29 15:41:26 +07:00
|
|
|
for (i = 0; i < req->n_channels; i++) {
|
|
|
|
if (nla_put_u32(msg, i, req->channels[i]->center_freq))
|
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
2009-05-24 21:43:15 +07:00
|
|
|
nla_nest_end(msg, nest);
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (req->ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie))
|
|
|
|
goto nla_put_failure;
|
2009-05-24 21:43:15 +07:00
|
|
|
|
2012-10-12 11:03:31 +07:00
|
|
|
if (req->flags)
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags);
|
|
|
|
|
2009-05-24 21:43:15 +07:00
|
|
|
return 0;
|
|
|
|
nla_put_failure:
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
2009-06-17 00:56:42 +07:00
|
|
|
static int nl80211_send_scan_msg(struct sk_buff *msg,
|
|
|
|
struct cfg80211_registered_device *rdev,
|
2012-06-19 00:17:03 +07:00
|
|
|
struct wireless_dev *wdev,
|
2012-09-08 03:12:54 +07:00
|
|
|
u32 portid, u32 seq, int flags,
|
2009-06-17 00:56:42 +07:00
|
|
|
u32 cmd)
|
2009-02-11 03:25:55 +07:00
|
|
|
{
|
|
|
|
void *hdr;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
|
2009-02-11 03:25:55 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
2012-06-19 00:17:03 +07:00
|
|
|
(wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
|
|
|
|
wdev->netdev->ifindex)) ||
|
|
|
|
nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
|
2012-03-29 15:41:26 +07:00
|
|
|
goto nla_put_failure;
|
2009-02-11 03:25:55 +07:00
|
|
|
|
2009-05-24 21:43:15 +07:00
|
|
|
/* ignore errors and send incomplete event anyway */
|
|
|
|
nl80211_add_scan_req(msg, rdev);
|
2009-02-11 03:25:55 +07:00
|
|
|
|
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
static int
|
|
|
|
nl80211_send_sched_scan_msg(struct sk_buff *msg,
|
|
|
|
struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev,
|
2012-09-08 03:12:54 +07:00
|
|
|
u32 portid, u32 seq, int flags, u32 cmd)
|
2011-05-11 21:09:35 +07:00
|
|
|
{
|
|
|
|
void *hdr;
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
|
2011-05-11 21:09:35 +07:00
|
|
|
if (!hdr)
|
|
|
|
return -1;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex))
|
|
|
|
goto nla_put_failure;
|
2011-05-11 21:09:35 +07:00
|
|
|
|
|
|
|
return genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
2009-06-17 00:56:42 +07:00
|
|
|
void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
|
2012-06-19 00:17:03 +07:00
|
|
|
struct wireless_dev *wdev)
|
2009-06-17 00:56:42 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-06-17 00:56:42 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2012-06-19 00:17:03 +07:00
|
|
|
if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
|
2009-06-17 00:56:42 +07:00
|
|
|
NL80211_CMD_TRIGGER_SCAN) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_scan_mcgrp.id, GFP_KERNEL);
|
2009-06-17 00:56:42 +07:00
|
|
|
}
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
|
2012-06-19 00:17:03 +07:00
|
|
|
struct wireless_dev *wdev)
|
2009-02-11 03:25:55 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-02-11 03:25:55 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2012-06-19 00:17:03 +07:00
|
|
|
if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
|
2009-06-17 00:56:42 +07:00
|
|
|
NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
|
2009-02-11 03:25:55 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_scan_mcgrp.id, GFP_KERNEL);
|
2009-02-11 03:25:55 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
|
2012-06-19 00:17:03 +07:00
|
|
|
struct wireless_dev *wdev)
|
2009-02-11 03:25:55 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-02-11 03:25:55 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2012-06-19 00:17:03 +07:00
|
|
|
if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
|
2009-06-17 00:56:42 +07:00
|
|
|
NL80211_CMD_SCAN_ABORTED) < 0) {
|
2009-02-11 03:25:55 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_scan_mcgrp.id, GFP_KERNEL);
|
2009-02-11 03:25:55 +07:00
|
|
|
}
|
|
|
|
|
2011-05-11 21:09:35 +07:00
|
|
|
void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (nl80211_send_sched_scan_msg(msg, rdev, netdev, 0, 0, 0,
|
|
|
|
NL80211_CMD_SCHED_SCAN_RESULTS) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_scan_mcgrp.id, GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, u32 cmd)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2011-05-11 21:09:35 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (nl80211_send_sched_scan_msg(msg, rdev, netdev, 0, 0, 0, cmd) < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_scan_mcgrp.id, GFP_KERNEL);
|
|
|
|
}
|
|
|
|
|
2009-03-10 09:07:42 +07:00
|
|
|
/*
|
|
|
|
* This can happen on global regulatory changes or device specific settings
|
|
|
|
* based on custom world regulatory domains.
|
|
|
|
*/
|
|
|
|
void nl80211_send_reg_change_event(struct regulatory_request *request)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-03-10 09:07:42 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_CHANGE);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Userspace can always count this one always being set */
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_REG_INITIATOR, request->initiator))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (request->alpha2[0] == '0' && request->alpha2[1] == '0') {
|
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE,
|
|
|
|
NL80211_REGDOM_TYPE_WORLD))
|
|
|
|
goto nla_put_failure;
|
|
|
|
} else if (request->alpha2[0] == '9' && request->alpha2[1] == '9') {
|
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE,
|
|
|
|
NL80211_REGDOM_TYPE_CUSTOM_WORLD))
|
|
|
|
goto nla_put_failure;
|
|
|
|
} else if ((request->alpha2[0] == '9' && request->alpha2[1] == '8') ||
|
|
|
|
request->intersect) {
|
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE,
|
|
|
|
NL80211_REGDOM_TYPE_INTERSECTION))
|
|
|
|
goto nla_put_failure;
|
|
|
|
} else {
|
|
|
|
if (nla_put_u8(msg, NL80211_ATTR_REG_TYPE,
|
|
|
|
NL80211_REGDOM_TYPE_COUNTRY) ||
|
|
|
|
nla_put_string(msg, NL80211_ATTR_REG_ALPHA2,
|
|
|
|
request->alpha2))
|
|
|
|
goto nla_put_failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wiphy_idx_valid(request->wiphy_idx) &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx))
|
|
|
|
goto nla_put_failure;
|
2009-03-10 09:07:42 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-03-10 09:07:42 +07:00
|
|
|
|
2009-07-25 15:54:13 +07:00
|
|
|
rcu_read_lock();
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id,
|
2009-07-25 15:54:13 +07:00
|
|
|
GFP_ATOMIC);
|
|
|
|
rcu_read_unlock();
|
2009-03-10 09:07:42 +07:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
static void nl80211_send_mlme_event(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev,
|
|
|
|
const u8 *buf, size_t len,
|
2009-07-02 02:26:47 +07:00
|
|
|
enum nl80211_commands cmd, gfp_t gfp)
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2009-07-02 02:26:47 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, cmd);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_FRAME, len, buf))
|
|
|
|
goto nla_put_failure;
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_rx_auth(struct cfg80211_registered_device *rdev,
|
2009-07-02 02:26:47 +07:00
|
|
|
struct net_device *netdev, const u8 *buf,
|
|
|
|
size_t len, gfp_t gfp)
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
{
|
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
2009-07-02 02:26:47 +07:00
|
|
|
NL80211_CMD_AUTHENTICATE, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_rx_assoc(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *buf,
|
2009-07-02 02:26:47 +07:00
|
|
|
size_t len, gfp_t gfp)
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
{
|
2009-07-02 02:26:47 +07:00
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
|
|
|
NL80211_CMD_ASSOCIATE, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
}
|
|
|
|
|
2009-03-28 01:53:56 +07:00
|
|
|
void nl80211_send_deauth(struct cfg80211_registered_device *rdev,
|
2009-07-02 02:26:47 +07:00
|
|
|
struct net_device *netdev, const u8 *buf,
|
|
|
|
size_t len, gfp_t gfp)
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
{
|
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
2009-07-02 02:26:47 +07:00
|
|
|
NL80211_CMD_DEAUTHENTICATE, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
}
|
|
|
|
|
2009-03-28 01:53:56 +07:00
|
|
|
void nl80211_send_disassoc(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *buf,
|
2009-07-02 02:26:47 +07:00
|
|
|
size_t len, gfp_t gfp)
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
{
|
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
2009-07-02 02:26:47 +07:00
|
|
|
NL80211_CMD_DISASSOCIATE, gfp);
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
}
|
|
|
|
|
2010-12-16 05:52:40 +07:00
|
|
|
void nl80211_send_unprot_deauth(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *buf,
|
|
|
|
size_t len, gfp_t gfp)
|
|
|
|
{
|
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
|
|
|
NL80211_CMD_UNPROT_DEAUTHENTICATE, gfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_unprot_disassoc(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *buf,
|
|
|
|
size_t len, gfp_t gfp)
|
|
|
|
{
|
|
|
|
nl80211_send_mlme_event(rdev, netdev, buf, len,
|
|
|
|
NL80211_CMD_UNPROT_DISASSOCIATE, gfp);
|
|
|
|
}
|
|
|
|
|
2009-05-02 11:34:48 +07:00
|
|
|
static void nl80211_send_mlme_timeout(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, int cmd,
|
2009-07-02 02:26:47 +07:00
|
|
|
const u8 *addr, gfp_t gfp)
|
2009-04-23 01:38:25 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2009-07-02 02:26:47 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-04-23 01:38:25 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, cmd);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_TIMED_OUT) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr))
|
|
|
|
goto nla_put_failure;
|
2009-04-23 01:38:25 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-04-23 01:38:25 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
2009-04-23 01:38:25 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_auth_timeout(struct cfg80211_registered_device *rdev,
|
2009-07-02 02:26:47 +07:00
|
|
|
struct net_device *netdev, const u8 *addr,
|
|
|
|
gfp_t gfp)
|
2009-04-23 01:38:25 +07:00
|
|
|
{
|
|
|
|
nl80211_send_mlme_timeout(rdev, netdev, NL80211_CMD_AUTHENTICATE,
|
2009-07-02 02:26:47 +07:00
|
|
|
addr, gfp);
|
2009-04-23 01:38:25 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_assoc_timeout(struct cfg80211_registered_device *rdev,
|
2009-07-02 02:26:47 +07:00
|
|
|
struct net_device *netdev, const u8 *addr,
|
|
|
|
gfp_t gfp)
|
2009-04-23 01:38:25 +07:00
|
|
|
{
|
2009-07-02 02:26:47 +07:00
|
|
|
nl80211_send_mlme_timeout(rdev, netdev, NL80211_CMD_ASSOCIATE,
|
|
|
|
addr, gfp);
|
2009-04-23 01:38:25 +07:00
|
|
|
}
|
|
|
|
|
2009-07-02 02:26:54 +07:00
|
|
|
void nl80211_send_connect_result(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *bssid,
|
|
|
|
const u8 *req_ie, size_t req_ie_len,
|
|
|
|
const u8 *resp_ie, size_t resp_ie_len,
|
|
|
|
u16 status, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-07-02 02:26:54 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CONNECT);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
(bssid && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid)) ||
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_STATUS_CODE, status) ||
|
|
|
|
(req_ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) ||
|
|
|
|
(resp_ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie)))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
2009-07-02 02:26:54 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_roamed(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *bssid,
|
|
|
|
const u8 *req_ie, size_t req_ie_len,
|
|
|
|
const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-07-02 02:26:54 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_ROAM);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid) ||
|
|
|
|
(req_ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_REQ_IE, req_ie_len, req_ie)) ||
|
|
|
|
(resp_ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie)))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
2009-07-02 02:26:54 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_disconnected(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, u16 reason,
|
2009-07-07 08:56:11 +07:00
|
|
|
const u8 *ie, size_t ie_len, bool from_ap)
|
2009-07-02 02:26:54 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
2009-07-02 02:26:54 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_DISCONNECT);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
(from_ap && reason &&
|
|
|
|
nla_put_u16(msg, NL80211_ATTR_REASON_CODE, reason)) ||
|
|
|
|
(from_ap &&
|
|
|
|
nla_put_flag(msg, NL80211_ATTR_DISCONNECTED_BY_AP)) ||
|
|
|
|
(ie && nla_put(msg, NL80211_ATTR_IE, ie_len, ie)))
|
|
|
|
goto nla_put_failure;
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-07-02 02:26:54 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, GFP_KERNEL);
|
2009-07-02 02:26:54 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-04-20 02:24:32 +07:00
|
|
|
void nl80211_send_ibss_bssid(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *bssid,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-04-20 02:24:32 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_JOIN_IBSS);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid))
|
|
|
|
goto nla_put_failure;
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-04-20 02:24:32 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
2009-04-20 02:24:32 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2011-04-08 05:08:34 +07:00
|
|
|
void nl80211_send_new_peer_candidate(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev,
|
|
|
|
const u8 *macaddr, const u8* ie, u8 ie_len,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NEW_PEER_CANDIDATE);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, macaddr) ||
|
|
|
|
(ie_len && ie &&
|
|
|
|
nla_put(msg, NL80211_ATTR_IE, ie_len , ie)))
|
|
|
|
goto nla_put_failure;
|
2011-04-08 05:08:34 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2011-04-08 05:08:34 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2009-03-28 02:59:49 +07:00
|
|
|
void nl80211_michael_mic_failure(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *addr,
|
|
|
|
enum nl80211_key_type key_type, int key_id,
|
2009-07-02 02:26:47 +07:00
|
|
|
const u8 *tsc, gfp_t gfp)
|
2009-03-28 02:59:49 +07:00
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2009-07-02 02:26:47 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-03-28 02:59:49 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_MICHAEL_MIC_FAILURE);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
(addr && nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr)) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_KEY_TYPE, key_type) ||
|
|
|
|
(key_id != -1 &&
|
|
|
|
nla_put_u8(msg, NL80211_ATTR_KEY_IDX, key_id)) ||
|
|
|
|
(tsc && nla_put(msg, NL80211_ATTR_KEY_SEQ, 6, tsc)))
|
|
|
|
goto nla_put_failure;
|
2009-03-28 02:59:49 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-03-28 02:59:49 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
2009-03-28 02:59:49 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2009-04-03 01:08:09 +07:00
|
|
|
void nl80211_send_beacon_hint_event(struct wiphy *wiphy,
|
|
|
|
struct ieee80211_channel *channel_before,
|
|
|
|
struct ieee80211_channel *channel_after)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
struct nlattr *nl_freq;
|
|
|
|
|
2009-05-20 05:27:55 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC);
|
2009-04-03 01:08:09 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_BEACON_HINT);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we are applying the beacon hint to a wiphy we know its
|
|
|
|
* wiphy_idx is valid
|
|
|
|
*/
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)))
|
|
|
|
goto nla_put_failure;
|
2009-04-03 01:08:09 +07:00
|
|
|
|
|
|
|
/* Before */
|
|
|
|
nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_BEFORE);
|
|
|
|
if (!nl_freq)
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (nl80211_msg_put_channel(msg, channel_before))
|
|
|
|
goto nla_put_failure;
|
|
|
|
nla_nest_end(msg, nl_freq);
|
|
|
|
|
|
|
|
/* After */
|
|
|
|
nl_freq = nla_nest_start(msg, NL80211_ATTR_FREQ_AFTER);
|
|
|
|
if (!nl_freq)
|
|
|
|
goto nla_put_failure;
|
|
|
|
if (nl80211_msg_put_channel(msg, channel_after))
|
|
|
|
goto nla_put_failure;
|
|
|
|
nla_nest_end(msg, nl_freq);
|
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-04-03 01:08:09 +07:00
|
|
|
|
2009-07-14 05:33:35 +07:00
|
|
|
rcu_read_lock();
|
|
|
|
genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
rcu_read_unlock();
|
2009-04-03 01:08:09 +07:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2009-12-23 19:15:41 +07:00
|
|
|
static void nl80211_send_remain_on_chan_event(
|
|
|
|
int cmd, struct cfg80211_registered_device *rdev,
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev, u64 cookie,
|
2009-12-23 19:15:41 +07:00
|
|
|
struct ieee80211_channel *chan,
|
|
|
|
enum nl80211_channel_type channel_type,
|
|
|
|
unsigned int duration, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, cmd);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
2012-06-15 20:30:18 +07:00
|
|
|
(wdev->netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
|
|
|
|
wdev->netdev->ifindex)) ||
|
2012-07-17 16:53:12 +07:00
|
|
|
nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, channel_type) ||
|
|
|
|
nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie))
|
|
|
|
goto nla_put_failure;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_DURATION, duration))
|
|
|
|
goto nla_put_failure;
|
2009-12-23 19:15:41 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2009-12-23 19:15:41 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_remain_on_channel(struct cfg80211_registered_device *rdev,
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev, u64 cookie,
|
2009-12-23 19:15:41 +07:00
|
|
|
struct ieee80211_channel *chan,
|
|
|
|
enum nl80211_channel_type channel_type,
|
|
|
|
unsigned int duration, gfp_t gfp)
|
|
|
|
{
|
|
|
|
nl80211_send_remain_on_chan_event(NL80211_CMD_REMAIN_ON_CHANNEL,
|
2012-06-15 20:30:18 +07:00
|
|
|
rdev, wdev, cookie, chan,
|
2009-12-23 19:15:41 +07:00
|
|
|
channel_type, duration, gfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_send_remain_on_channel_cancel(
|
2012-06-15 20:30:18 +07:00
|
|
|
struct cfg80211_registered_device *rdev,
|
|
|
|
struct wireless_dev *wdev,
|
2009-12-23 19:15:41 +07:00
|
|
|
u64 cookie, struct ieee80211_channel *chan,
|
|
|
|
enum nl80211_channel_type channel_type, gfp_t gfp)
|
|
|
|
{
|
|
|
|
nl80211_send_remain_on_chan_event(NL80211_CMD_CANCEL_REMAIN_ON_CHANNEL,
|
2012-06-15 20:30:18 +07:00
|
|
|
rdev, wdev, cookie, chan,
|
2009-12-23 19:15:41 +07:00
|
|
|
channel_type, 0, gfp);
|
|
|
|
}
|
|
|
|
|
2009-12-23 19:15:44 +07:00
|
|
|
void nl80211_send_sta_event(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, const u8 *mac_addr,
|
|
|
|
struct station_info *sinfo, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2009-12-23 19:15:44 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2012-03-16 00:25:41 +07:00
|
|
|
if (nl80211_send_station(msg, 0, 0, 0,
|
|
|
|
rdev, dev, mac_addr, sinfo) < 0) {
|
2009-12-23 19:15:44 +07:00
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
}
|
|
|
|
|
2011-03-23 20:29:52 +07:00
|
|
|
void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, const u8 *mac_addr,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2011-03-23 20:29:52 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_DEL_STATION);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr))
|
|
|
|
goto nla_put_failure;
|
2011-03-23 20:29:52 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2011-03-23 20:29:52 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2012-09-18 18:20:49 +07:00
|
|
|
void nl80211_send_conn_failed_event(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, const u8 *mac_addr,
|
|
|
|
enum nl80211_connect_failed_reason reason,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CONN_FAILED);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_CONN_FAILED_REASON, reason))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:19 +07:00
|
|
|
static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd,
|
|
|
|
const u8 *addr, gfp_t gfp)
|
2011-11-04 17:18:12 +07:00
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
int err;
|
2012-09-08 03:12:54 +07:00
|
|
|
u32 nlportid = ACCESS_ONCE(wdev->ap_unexpected_nlportid);
|
2011-11-04 17:18:12 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (!nlportid)
|
2011-11-04 17:18:12 +07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
msg = nlmsg_new(100, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return true;
|
|
|
|
|
2011-11-04 17:18:19 +07:00
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, cmd);
|
2011-11-04 17:18:12 +07:00
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr))
|
|
|
|
goto nla_put_failure;
|
2011-11-04 17:18:12 +07:00
|
|
|
|
|
|
|
err = genlmsg_end(msg, hdr);
|
|
|
|
if (err < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
|
2011-11-04 17:18:12 +07:00
|
|
|
return true;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:19 +07:00
|
|
|
bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp)
|
|
|
|
{
|
|
|
|
return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME,
|
|
|
|
addr, gfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nl80211_unexpected_4addr_frame(struct net_device *dev,
|
|
|
|
const u8 *addr, gfp_t gfp)
|
|
|
|
{
|
|
|
|
return __nl80211_unexpected_frame(dev,
|
|
|
|
NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
|
|
|
|
addr, gfp);
|
|
|
|
}
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
|
2012-09-08 03:12:54 +07:00
|
|
|
struct wireless_dev *wdev, u32 nlportid,
|
2012-03-06 04:18:41 +07:00
|
|
|
int freq, int sig_dbm,
|
|
|
|
const u8 *buf, size_t len, gfp_t gfp)
|
2010-02-15 17:53:10 +07:00
|
|
|
{
|
2012-06-15 20:30:18 +07:00
|
|
|
struct net_device *netdev = wdev->netdev;
|
2010-02-15 17:53:10 +07:00
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME);
|
2010-02-15 17:53:10 +07:00
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
2012-06-15 20:30:18 +07:00
|
|
|
(netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
|
|
|
|
netdev->ifindex)) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) ||
|
|
|
|
(sig_dbm &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_FRAME, len, buf))
|
|
|
|
goto nla_put_failure;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return -ENOBUFS;
|
|
|
|
}
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
void nl80211_send_mgmt_tx_status(struct cfg80211_registered_device *rdev,
|
2012-06-15 20:30:18 +07:00
|
|
|
struct wireless_dev *wdev, u64 cookie,
|
2010-08-12 20:38:38 +07:00
|
|
|
const u8 *buf, size_t len, bool ack,
|
|
|
|
gfp_t gfp)
|
2010-02-15 17:53:10 +07:00
|
|
|
{
|
2012-06-15 20:30:18 +07:00
|
|
|
struct net_device *netdev = wdev->netdev;
|
2010-02-15 17:53:10 +07:00
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
2010-08-12 20:38:38 +07:00
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME_TX_STATUS);
|
2010-02-15 17:53:10 +07:00
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
2012-06-15 20:30:18 +07:00
|
|
|
(netdev && nla_put_u32(msg, NL80211_ATTR_IFINDEX,
|
|
|
|
netdev->ifindex)) ||
|
2012-03-29 15:41:26 +07:00
|
|
|
nla_put(msg, NL80211_ATTR_FRAME, len, buf) ||
|
|
|
|
nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) ||
|
|
|
|
(ack && nla_put_flag(msg, NL80211_ATTR_ACK)))
|
|
|
|
goto nla_put_failure;
|
2010-02-15 17:53:10 +07:00
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2010-03-23 14:02:33 +07:00
|
|
|
void
|
|
|
|
nl80211_send_cqm_rssi_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev,
|
|
|
|
enum nl80211_cqm_rssi_threshold_event rssi_event,
|
|
|
|
gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
struct nlattr *pinfoattr;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2010-03-23 14:02:33 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_CQM);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex))
|
|
|
|
goto nla_put_failure;
|
2010-03-23 14:02:33 +07:00
|
|
|
|
|
|
|
pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM);
|
|
|
|
if (!pinfoattr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_CQM_RSSI_THRESHOLD_EVENT,
|
|
|
|
rssi_event))
|
|
|
|
goto nla_put_failure;
|
2010-03-23 14:02:33 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, pinfoattr);
|
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2010-03-23 14:02:33 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2011-07-05 21:35:40 +07:00
|
|
|
void nl80211_gtk_rekey_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *bssid,
|
|
|
|
const u8 *replay_ctr, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
struct nlattr *rekey_attr;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2011-07-05 21:35:40 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_SET_REKEY_OFFLOAD);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid))
|
|
|
|
goto nla_put_failure;
|
2011-07-05 21:35:40 +07:00
|
|
|
|
|
|
|
rekey_attr = nla_nest_start(msg, NL80211_ATTR_REKEY_DATA);
|
|
|
|
if (!rekey_attr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put(msg, NL80211_REKEY_DATA_REPLAY_CTR,
|
|
|
|
NL80211_REPLAY_CTR_LEN, replay_ctr))
|
|
|
|
goto nla_put_failure;
|
2011-07-05 21:35:40 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, rekey_attr);
|
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2011-07-05 21:35:40 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2011-09-16 22:56:23 +07:00
|
|
|
void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, int index,
|
|
|
|
const u8 *bssid, bool preauth, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
struct nlattr *attr;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2011-09-16 22:56:23 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PMKSA_CANDIDATE);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex))
|
|
|
|
goto nla_put_failure;
|
2011-09-16 22:56:23 +07:00
|
|
|
|
|
|
|
attr = nla_nest_start(msg, NL80211_ATTR_PMKSA_CANDIDATE);
|
|
|
|
if (!attr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_PMKSA_CANDIDATE_INDEX, index) ||
|
|
|
|
nla_put(msg, NL80211_PMKSA_CANDIDATE_BSSID, ETH_ALEN, bssid) ||
|
|
|
|
(preauth &&
|
|
|
|
nla_put_flag(msg, NL80211_PMKSA_CANDIDATE_PREAUTH)))
|
|
|
|
goto nla_put_failure;
|
2011-09-16 22:56:23 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, attr);
|
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2011-09-16 22:56:23 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2012-04-07 03:35:47 +07:00
|
|
|
void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, int freq,
|
|
|
|
enum nl80211_channel_type type, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2012-04-07 03:35:47 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_CH_SWITCH_NOTIFY);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-13 01:25:14 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, type))
|
|
|
|
goto nla_put_failure;
|
2012-04-07 03:35:47 +07:00
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2012-07-13 06:17:33 +07:00
|
|
|
void
|
|
|
|
nl80211_send_cqm_txe_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *peer,
|
|
|
|
u32 num_packets, u32 rate, u32 intvl, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
struct nlattr *pinfoattr;
|
|
|
|
void *hdr;
|
|
|
|
|
|
|
|
msg = nlmsg_new(NLMSG_GOODSIZE, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_CQM);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM);
|
|
|
|
if (!pinfoattr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_PKTS, num_packets))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_RATE, rate))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_CQM_TXE_INTVL, intvl))
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
|
|
|
nla_nest_end(msg, pinfoattr);
|
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2010-11-24 14:10:05 +07:00
|
|
|
void
|
|
|
|
nl80211_send_cqm_pktloss_notify(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *netdev, const u8 *peer,
|
|
|
|
u32 num_packets, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct sk_buff *msg;
|
|
|
|
struct nlattr *pinfoattr;
|
|
|
|
void *hdr;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2010-11-24 14:10:05 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NOTIFY_CQM);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, peer))
|
|
|
|
goto nla_put_failure;
|
2010-11-24 14:10:05 +07:00
|
|
|
|
|
|
|
pinfoattr = nla_nest_start(msg, NL80211_ATTR_CQM);
|
|
|
|
if (!pinfoattr)
|
|
|
|
goto nla_put_failure;
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_CQM_PKT_LOSS_EVENT, num_packets))
|
|
|
|
goto nla_put_failure;
|
2010-11-24 14:10:05 +07:00
|
|
|
|
|
|
|
nla_nest_end(msg, pinfoattr);
|
|
|
|
|
2011-10-23 00:05:51 +07:00
|
|
|
genlmsg_end(msg, hdr);
|
2010-11-24 14:10:05 +07:00
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
|
2011-11-04 17:18:15 +07:00
|
|
|
void cfg80211_probe_status(struct net_device *dev, const u8 *addr,
|
|
|
|
u64 cookie, bool acked, gfp_t gfp)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev = dev->ieee80211_ptr;
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
|
|
|
int err;
|
|
|
|
|
2012-06-28 10:57:45 +07:00
|
|
|
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
|
2011-11-04 17:18:15 +07:00
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PROBE_CLIENT);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, addr) ||
|
|
|
|
nla_put_u64(msg, NL80211_ATTR_COOKIE, cookie) ||
|
|
|
|
(acked && nla_put_flag(msg, NL80211_ATTR_ACK)))
|
|
|
|
goto nla_put_failure;
|
2011-11-04 17:18:15 +07:00
|
|
|
|
|
|
|
err = genlmsg_end(msg, hdr);
|
|
|
|
if (err < 0) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0,
|
|
|
|
nl80211_mlme_mcgrp.id, gfp);
|
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_probe_status);
|
|
|
|
|
2011-11-04 17:18:17 +07:00
|
|
|
void cfg80211_report_obss_beacon(struct wiphy *wiphy,
|
|
|
|
const u8 *frame, size_t len,
|
2012-03-06 04:18:41 +07:00
|
|
|
int freq, int sig_dbm, gfp_t gfp)
|
2011-11-04 17:18:17 +07:00
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
|
|
|
|
struct sk_buff *msg;
|
|
|
|
void *hdr;
|
2012-09-08 03:12:54 +07:00
|
|
|
u32 nlportid = ACCESS_ONCE(rdev->ap_beacons_nlportid);
|
2011-11-04 17:18:17 +07:00
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
if (!nlportid)
|
2011-11-04 17:18:17 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
msg = nlmsg_new(len + 100, gfp);
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME);
|
|
|
|
if (!hdr) {
|
|
|
|
nlmsg_free(msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-29 15:41:26 +07:00
|
|
|
if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
|
|
|
|
(freq &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) ||
|
|
|
|
(sig_dbm &&
|
|
|
|
nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) ||
|
|
|
|
nla_put(msg, NL80211_ATTR_FRAME, len, frame))
|
|
|
|
goto nla_put_failure;
|
2011-11-04 17:18:17 +07:00
|
|
|
|
|
|
|
genlmsg_end(msg, hdr);
|
|
|
|
|
2012-09-08 03:12:54 +07:00
|
|
|
genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid);
|
2011-11-04 17:18:17 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
nla_put_failure:
|
|
|
|
genlmsg_cancel(msg, hdr);
|
|
|
|
nlmsg_free(msg);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_report_obss_beacon);
|
|
|
|
|
2010-02-15 17:53:10 +07:00
|
|
|
static int nl80211_netlink_notify(struct notifier_block * nb,
|
|
|
|
unsigned long state,
|
|
|
|
void *_notify)
|
|
|
|
{
|
|
|
|
struct netlink_notify *notify = _notify;
|
|
|
|
struct cfg80211_registered_device *rdev;
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
|
|
|
|
if (state != NETLINK_URELEASE)
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
2011-11-04 17:18:17 +07:00
|
|
|
list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) {
|
2012-06-15 19:33:17 +07:00
|
|
|
list_for_each_entry_rcu(wdev, &rdev->wdev_list, list)
|
2012-09-08 03:12:54 +07:00
|
|
|
cfg80211_mlme_unregister_socket(wdev, notify->portid);
|
|
|
|
if (rdev->ap_beacons_nlportid == notify->portid)
|
|
|
|
rdev->ap_beacons_nlportid = 0;
|
2011-11-04 17:18:17 +07:00
|
|
|
}
|
2010-02-15 17:53:10 +07:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block nl80211_netlink_notifier = {
|
|
|
|
.notifier_call = nl80211_netlink_notify,
|
|
|
|
};
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
/* initialisation/exit functions */
|
|
|
|
|
|
|
|
int nl80211_init(void)
|
|
|
|
{
|
2009-05-21 17:34:06 +07:00
|
|
|
int err;
|
2007-09-21 00:09:35 +07:00
|
|
|
|
2009-05-21 17:34:06 +07:00
|
|
|
err = genl_register_family_with_ops(&nl80211_fam,
|
|
|
|
nl80211_ops, ARRAY_SIZE(nl80211_ops));
|
2007-09-21 00:09:35 +07:00
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = genl_register_mc_group(&nl80211_fam, &nl80211_config_mcgrp);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
2009-02-11 03:25:55 +07:00
|
|
|
err = genl_register_mc_group(&nl80211_fam, &nl80211_scan_mcgrp);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
2009-03-10 09:07:42 +07:00
|
|
|
err = genl_register_mc_group(&nl80211_fam, &nl80211_regulatory_mcgrp);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
nl80211: Event notifications for MLME events
Add new nl80211 event notifications (and a new multicast group, "mlme")
for informing user space about received and processed Authentication,
(Re)Association Response, Deauthentication, and Disassociation frames in
station and IBSS modes (i.e., MLME SAP interface primitives
MLME-AUTHENTICATE.confirm, MLME-ASSOCIATE.confirm,
MLME-REASSOCIATE.confirm, MLME-DEAUTHENTICATE.indicate, and
MLME-DISASSOCIATE.indication). The event data is encapsulated as the 802.11
management frame since we already have the frame in that format and it
includes all the needed information.
This is the initial step in providing MLME SAP interface for
authentication and association with nl80211. In other words, kernel code
will act as the MLME and a user space application can control it as the
SME.
Signed-off-by: Jouni Malinen <j@w1.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-03-19 18:39:21 +07:00
|
|
|
err = genl_register_mc_group(&nl80211_fam, &nl80211_mlme_mcgrp);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
2009-07-02 02:26:51 +07:00
|
|
|
#ifdef CONFIG_NL80211_TESTMODE
|
|
|
|
err = genl_register_mc_group(&nl80211_fam, &nl80211_testmode_mcgrp);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
#endif
|
|
|
|
|
2010-02-15 17:53:10 +07:00
|
|
|
err = netlink_register_notifier(&nl80211_netlink_notifier);
|
|
|
|
if (err)
|
|
|
|
goto err_out;
|
|
|
|
|
2007-09-21 00:09:35 +07:00
|
|
|
return 0;
|
|
|
|
err_out:
|
|
|
|
genl_unregister_family(&nl80211_fam);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nl80211_exit(void)
|
|
|
|
{
|
2010-02-15 17:53:10 +07:00
|
|
|
netlink_unregister_notifier(&nl80211_netlink_notifier);
|
2007-09-21 00:09:35 +07:00
|
|
|
genl_unregister_family(&nl80211_fam);
|
|
|
|
}
|