2008-01-25 01:38:38 +07:00
|
|
|
/*
|
|
|
|
* Wireless utility functions
|
|
|
|
*
|
2009-04-20 19:31:42 +07:00
|
|
|
* Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net>
|
2008-01-25 01:38:38 +07:00
|
|
|
*/
|
2009-04-20 19:31:42 +07:00
|
|
|
#include <linux/bitops.h>
|
2009-05-21 20:47:03 +07:00
|
|
|
#include <linux/etherdevice.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2009-04-20 19:31:42 +07:00
|
|
|
#include <net/cfg80211.h>
|
2009-05-21 20:47:03 +07:00
|
|
|
#include <net/ip.h>
|
2008-01-25 01:38:38 +07:00
|
|
|
#include "core.h"
|
|
|
|
|
2008-10-30 02:00:45 +07:00
|
|
|
struct ieee80211_rate *
|
|
|
|
ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
|
2009-01-21 21:13:48 +07:00
|
|
|
u32 basic_rates, int bitrate)
|
2008-10-30 02:00:45 +07:00
|
|
|
{
|
|
|
|
struct ieee80211_rate *result = &sband->bitrates[0];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (!(basic_rates & BIT(i)))
|
|
|
|
continue;
|
|
|
|
if (sband->bitrates[i].bitrate > bitrate)
|
|
|
|
continue;
|
|
|
|
result = &sband->bitrates[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_get_response_rate);
|
|
|
|
|
2008-01-25 01:38:38 +07:00
|
|
|
int ieee80211_channel_to_frequency(int chan)
|
|
|
|
{
|
|
|
|
if (chan < 14)
|
|
|
|
return 2407 + chan * 5;
|
|
|
|
|
|
|
|
if (chan == 14)
|
|
|
|
return 2484;
|
|
|
|
|
|
|
|
/* FIXME: 802.11j 17.3.8.3.2 */
|
|
|
|
return (chan + 1000) * 5;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_channel_to_frequency);
|
|
|
|
|
|
|
|
int ieee80211_frequency_to_channel(int freq)
|
|
|
|
{
|
|
|
|
if (freq == 2484)
|
|
|
|
return 14;
|
|
|
|
|
|
|
|
if (freq < 2484)
|
|
|
|
return (freq - 2407) / 5;
|
|
|
|
|
|
|
|
/* FIXME: 802.11j 17.3.8.3.2 */
|
|
|
|
return freq/5 - 1000;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_frequency_to_channel);
|
|
|
|
|
2008-03-26 20:14:55 +07:00
|
|
|
struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
|
|
|
|
int freq)
|
2008-03-17 00:34:33 +07:00
|
|
|
{
|
|
|
|
enum ieee80211_band band;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
|
|
|
|
sband = wiphy->bands[band];
|
|
|
|
|
|
|
|
if (!sband)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = 0; i < sband->n_channels; i++) {
|
|
|
|
if (sband->channels[i].center_freq == freq)
|
|
|
|
return &sband->channels[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-26 20:14:55 +07:00
|
|
|
EXPORT_SYMBOL(__ieee80211_get_channel);
|
2008-03-17 00:34:33 +07:00
|
|
|
|
2008-01-25 01:38:38 +07:00
|
|
|
static void set_mandatory_flags_band(struct ieee80211_supported_band *sband,
|
|
|
|
enum ieee80211_band band)
|
|
|
|
{
|
|
|
|
int i, want;
|
|
|
|
|
|
|
|
switch (band) {
|
|
|
|
case IEEE80211_BAND_5GHZ:
|
|
|
|
want = 3;
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (sband->bitrates[i].bitrate == 60 ||
|
|
|
|
sband->bitrates[i].bitrate == 120 ||
|
|
|
|
sband->bitrates[i].bitrate == 240) {
|
|
|
|
sband->bitrates[i].flags |=
|
|
|
|
IEEE80211_RATE_MANDATORY_A;
|
|
|
|
want--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WARN_ON(want);
|
|
|
|
break;
|
|
|
|
case IEEE80211_BAND_2GHZ:
|
|
|
|
want = 7;
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (sband->bitrates[i].bitrate == 10) {
|
|
|
|
sband->bitrates[i].flags |=
|
|
|
|
IEEE80211_RATE_MANDATORY_B |
|
|
|
|
IEEE80211_RATE_MANDATORY_G;
|
|
|
|
want--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sband->bitrates[i].bitrate == 20 ||
|
|
|
|
sband->bitrates[i].bitrate == 55 ||
|
|
|
|
sband->bitrates[i].bitrate == 110 ||
|
|
|
|
sband->bitrates[i].bitrate == 60 ||
|
|
|
|
sband->bitrates[i].bitrate == 120 ||
|
|
|
|
sband->bitrates[i].bitrate == 240) {
|
|
|
|
sband->bitrates[i].flags |=
|
|
|
|
IEEE80211_RATE_MANDATORY_G;
|
|
|
|
want--;
|
|
|
|
}
|
|
|
|
|
2008-01-30 23:36:10 +07:00
|
|
|
if (sband->bitrates[i].bitrate != 10 &&
|
|
|
|
sband->bitrates[i].bitrate != 20 &&
|
|
|
|
sband->bitrates[i].bitrate != 55 &&
|
|
|
|
sband->bitrates[i].bitrate != 110)
|
2008-01-25 01:38:38 +07:00
|
|
|
sband->bitrates[i].flags |=
|
|
|
|
IEEE80211_RATE_ERP_G;
|
|
|
|
}
|
2008-02-03 05:53:10 +07:00
|
|
|
WARN_ON(want != 0 && want != 3 && want != 6);
|
2008-01-25 01:38:38 +07:00
|
|
|
break;
|
|
|
|
case IEEE80211_NUM_BANDS:
|
|
|
|
WARN_ON(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_set_bitrate_flags(struct wiphy *wiphy)
|
|
|
|
{
|
|
|
|
enum ieee80211_band band;
|
|
|
|
|
|
|
|
for (band = 0; band < IEEE80211_NUM_BANDS; band++)
|
|
|
|
if (wiphy->bands[band])
|
|
|
|
set_mandatory_flags_band(wiphy->bands[band], band);
|
|
|
|
}
|
2009-05-11 18:54:58 +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
|
|
|
int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
|
|
|
|
struct key_params *params, int key_idx,
|
2009-05-11 18:54:58 +07:00
|
|
|
const u8 *mac_addr)
|
|
|
|
{
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 19:22:54 +07:00
|
|
|
int i;
|
|
|
|
|
2009-05-11 18:54:58 +07:00
|
|
|
if (key_idx > 5)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disallow pairwise keys with non-zero index unless it's WEP
|
|
|
|
* (because current deployments use pairwise WEP keys with
|
|
|
|
* non-zero indizes but 802.11i clearly specifies to use zero)
|
|
|
|
*/
|
|
|
|
if (mac_addr && key_idx &&
|
|
|
|
params->cipher != WLAN_CIPHER_SUITE_WEP40 &&
|
|
|
|
params->cipher != WLAN_CIPHER_SUITE_WEP104)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (params->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
2009-05-24 21:57:19 +07:00
|
|
|
if (params->key_len != WLAN_KEY_LEN_WEP40)
|
2009-05-11 18:54:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
2009-05-24 21:57:19 +07:00
|
|
|
if (params->key_len != WLAN_KEY_LEN_TKIP)
|
2009-05-11 18:54:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
2009-05-24 21:57:19 +07:00
|
|
|
if (params->key_len != WLAN_KEY_LEN_CCMP)
|
2009-05-11 18:54:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
2009-05-24 21:57:19 +07:00
|
|
|
if (params->key_len != WLAN_KEY_LEN_WEP104)
|
2009-05-11 18:54:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case WLAN_CIPHER_SUITE_AES_CMAC:
|
2009-05-24 21:57:19 +07:00
|
|
|
if (params->key_len != WLAN_KEY_LEN_AES_CMAC)
|
2009-05-11 18:54:58 +07:00
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
default:
|
2010-08-27 18:26:51 +07:00
|
|
|
/*
|
|
|
|
* We don't know anything about this algorithm,
|
|
|
|
* allow using it -- but the driver must check
|
|
|
|
* all parameters! We still check below whether
|
|
|
|
* or not the driver supports this algorithm,
|
|
|
|
* of course.
|
|
|
|
*/
|
|
|
|
break;
|
2009-05-11 18:54:58 +07:00
|
|
|
}
|
|
|
|
|
2009-05-15 16:38:32 +07:00
|
|
|
if (params->seq) {
|
|
|
|
switch (params->cipher) {
|
|
|
|
case WLAN_CIPHER_SUITE_WEP40:
|
|
|
|
case WLAN_CIPHER_SUITE_WEP104:
|
|
|
|
/* These ciphers do not use key sequence */
|
|
|
|
return -EINVAL;
|
|
|
|
case WLAN_CIPHER_SUITE_TKIP:
|
|
|
|
case WLAN_CIPHER_SUITE_CCMP:
|
|
|
|
case WLAN_CIPHER_SUITE_AES_CMAC:
|
|
|
|
if (params->seq_len != 6)
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
for (i = 0; i < rdev->wiphy.n_cipher_suites; i++)
|
|
|
|
if (params->cipher == rdev->wiphy.cipher_suites[i])
|
|
|
|
break;
|
|
|
|
if (i == rdev->wiphy.n_cipher_suites)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-05-11 18:54:58 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2009-05-21 20:47:03 +07:00
|
|
|
|
|
|
|
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
|
|
|
|
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
|
|
|
|
const unsigned char rfc1042_header[] __aligned(2) =
|
|
|
|
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
|
|
|
|
EXPORT_SYMBOL(rfc1042_header);
|
|
|
|
|
|
|
|
/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
|
|
|
|
const unsigned char bridge_tunnel_header[] __aligned(2) =
|
|
|
|
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
|
|
|
|
EXPORT_SYMBOL(bridge_tunnel_header);
|
|
|
|
|
2010-08-12 19:49:58 +07:00
|
|
|
unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc)
|
2009-05-21 20:47:03 +07:00
|
|
|
{
|
|
|
|
unsigned int hdrlen = 24;
|
|
|
|
|
|
|
|
if (ieee80211_is_data(fc)) {
|
|
|
|
if (ieee80211_has_a4(fc))
|
|
|
|
hdrlen = 30;
|
2010-01-20 18:55:06 +07:00
|
|
|
if (ieee80211_is_data_qos(fc)) {
|
2009-05-21 20:47:03 +07:00
|
|
|
hdrlen += IEEE80211_QOS_CTL_LEN;
|
2010-01-20 18:55:06 +07:00
|
|
|
if (ieee80211_has_order(fc))
|
|
|
|
hdrlen += IEEE80211_HT_CTL_LEN;
|
|
|
|
}
|
2009-05-21 20:47:03 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee80211_is_ctl(fc)) {
|
|
|
|
/*
|
|
|
|
* ACK and CTS are 10 bytes, all others 16. To see how
|
|
|
|
* to get this condition consider
|
|
|
|
* subtype mask: 0b0000000011110000 (0x00F0)
|
|
|
|
* ACK subtype: 0b0000000011010000 (0x00D0)
|
|
|
|
* CTS subtype: 0b0000000011000000 (0x00C0)
|
|
|
|
* bits that matter: ^^^ (0x00E0)
|
|
|
|
* value of those: 0b0000000011000000 (0x00C0)
|
|
|
|
*/
|
|
|
|
if ((fc & cpu_to_le16(0x00E0)) == cpu_to_le16(0x00C0))
|
|
|
|
hdrlen = 10;
|
|
|
|
else
|
|
|
|
hdrlen = 16;
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return hdrlen;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_hdrlen);
|
|
|
|
|
|
|
|
unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
const struct ieee80211_hdr *hdr =
|
|
|
|
(const struct ieee80211_hdr *)skb->data;
|
|
|
|
unsigned int hdrlen;
|
|
|
|
|
|
|
|
if (unlikely(skb->len < 10))
|
|
|
|
return 0;
|
|
|
|
hdrlen = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
if (unlikely(hdrlen > skb->len))
|
|
|
|
return 0;
|
|
|
|
return hdrlen;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb);
|
|
|
|
|
2009-06-03 03:31:10 +07:00
|
|
|
static int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
|
2009-05-21 20:47:03 +07:00
|
|
|
{
|
|
|
|
int ae = meshhdr->flags & MESH_FLAGS_AE;
|
|
|
|
/* 7.1.3.5a.2 */
|
|
|
|
switch (ae) {
|
|
|
|
case 0:
|
|
|
|
return 6;
|
2009-08-11 02:15:48 +07:00
|
|
|
case MESH_FLAGS_AE_A4:
|
2009-05-21 20:47:03 +07:00
|
|
|
return 12;
|
2009-08-11 02:15:48 +07:00
|
|
|
case MESH_FLAGS_AE_A5_A6:
|
2009-05-21 20:47:03 +07:00
|
|
|
return 18;
|
2009-08-11 02:15:48 +07:00
|
|
|
case (MESH_FLAGS_AE_A4 | MESH_FLAGS_AE_A5_A6):
|
2009-05-21 20:47:03 +07:00
|
|
|
return 24;
|
|
|
|
default:
|
|
|
|
return 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 09:18:37 +07:00
|
|
|
int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
|
2009-05-21 20:47:03 +07:00
|
|
|
enum nl80211_iftype iftype)
|
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
|
|
|
u16 hdrlen, ethertype;
|
|
|
|
u8 *payload;
|
|
|
|
u8 dst[ETH_ALEN];
|
|
|
|
u8 src[ETH_ALEN] __aligned(2);
|
|
|
|
|
|
|
|
if (unlikely(!ieee80211_is_data_present(hdr->frame_control)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
hdrlen = ieee80211_hdrlen(hdr->frame_control);
|
|
|
|
|
|
|
|
/* convert IEEE 802.11 header + possible LLC headers into Ethernet
|
|
|
|
* header
|
|
|
|
* IEEE 802.11 address fields:
|
|
|
|
* ToDS FromDS Addr1 Addr2 Addr3 Addr4
|
|
|
|
* 0 0 DA SA BSSID n/a
|
|
|
|
* 0 1 DA BSSID SA n/a
|
|
|
|
* 1 0 BSSID SA DA n/a
|
|
|
|
* 1 1 RA TA DA SA
|
|
|
|
*/
|
|
|
|
memcpy(dst, ieee80211_get_DA(hdr), ETH_ALEN);
|
|
|
|
memcpy(src, ieee80211_get_SA(hdr), ETH_ALEN);
|
|
|
|
|
|
|
|
switch (hdr->frame_control &
|
|
|
|
cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
|
|
|
|
case cpu_to_le16(IEEE80211_FCTL_TODS):
|
|
|
|
if (unlikely(iftype != NL80211_IFTYPE_AP &&
|
|
|
|
iftype != NL80211_IFTYPE_AP_VLAN))
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
case cpu_to_le16(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
|
|
|
|
if (unlikely(iftype != NL80211_IFTYPE_WDS &&
|
2009-11-11 02:10:05 +07:00
|
|
|
iftype != NL80211_IFTYPE_MESH_POINT &&
|
|
|
|
iftype != NL80211_IFTYPE_AP_VLAN &&
|
|
|
|
iftype != NL80211_IFTYPE_STATION))
|
2009-05-21 20:47:03 +07:00
|
|
|
return -1;
|
|
|
|
if (iftype == NL80211_IFTYPE_MESH_POINT) {
|
|
|
|
struct ieee80211s_hdr *meshdr =
|
|
|
|
(struct ieee80211s_hdr *) (skb->data + hdrlen);
|
2010-03-29 16:35:07 +07:00
|
|
|
/* make sure meshdr->flags is on the linear part */
|
|
|
|
if (!pskb_may_pull(skb, hdrlen + 1))
|
|
|
|
return -1;
|
2009-05-21 20:47:03 +07:00
|
|
|
if (meshdr->flags & MESH_FLAGS_AE_A5_A6) {
|
2010-03-29 16:35:07 +07:00
|
|
|
skb_copy_bits(skb, hdrlen +
|
|
|
|
offsetof(struct ieee80211s_hdr, eaddr1),
|
|
|
|
dst, ETH_ALEN);
|
|
|
|
skb_copy_bits(skb, hdrlen +
|
|
|
|
offsetof(struct ieee80211s_hdr, eaddr2),
|
|
|
|
src, ETH_ALEN);
|
2009-05-21 20:47:03 +07:00
|
|
|
}
|
2010-03-29 16:35:07 +07:00
|
|
|
hdrlen += ieee80211_get_mesh_hdrlen(meshdr);
|
2009-05-21 20:47:03 +07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cpu_to_le16(IEEE80211_FCTL_FROMDS):
|
2009-08-11 02:15:48 +07:00
|
|
|
if ((iftype != NL80211_IFTYPE_STATION &&
|
|
|
|
iftype != NL80211_IFTYPE_MESH_POINT) ||
|
2009-05-21 20:47:03 +07:00
|
|
|
(is_multicast_ether_addr(dst) &&
|
|
|
|
!compare_ether_addr(src, addr)))
|
|
|
|
return -1;
|
2009-08-11 02:15:48 +07:00
|
|
|
if (iftype == NL80211_IFTYPE_MESH_POINT) {
|
|
|
|
struct ieee80211s_hdr *meshdr =
|
|
|
|
(struct ieee80211s_hdr *) (skb->data + hdrlen);
|
2010-03-29 16:35:07 +07:00
|
|
|
/* make sure meshdr->flags is on the linear part */
|
|
|
|
if (!pskb_may_pull(skb, hdrlen + 1))
|
|
|
|
return -1;
|
2009-08-11 02:15:48 +07:00
|
|
|
if (meshdr->flags & MESH_FLAGS_AE_A4)
|
2010-03-29 16:35:07 +07:00
|
|
|
skb_copy_bits(skb, hdrlen +
|
|
|
|
offsetof(struct ieee80211s_hdr, eaddr1),
|
|
|
|
src, ETH_ALEN);
|
|
|
|
hdrlen += ieee80211_get_mesh_hdrlen(meshdr);
|
2009-08-11 02:15:48 +07:00
|
|
|
}
|
2009-05-21 20:47:03 +07:00
|
|
|
break;
|
|
|
|
case cpu_to_le16(0):
|
|
|
|
if (iftype != NL80211_IFTYPE_ADHOC)
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-03-29 16:35:07 +07:00
|
|
|
if (!pskb_may_pull(skb, hdrlen + 8))
|
2009-05-21 20:47:03 +07:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
payload = skb->data + hdrlen;
|
|
|
|
ethertype = (payload[6] << 8) | payload[7];
|
|
|
|
|
|
|
|
if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
|
|
|
|
ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
|
|
|
|
compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
|
|
|
|
/* remove RFC1042 or Bridge-Tunnel encapsulation and
|
|
|
|
* replace EtherType */
|
|
|
|
skb_pull(skb, hdrlen + 6);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
|
|
|
|
} else {
|
|
|
|
struct ethhdr *ehdr;
|
|
|
|
__be16 len;
|
|
|
|
|
|
|
|
skb_pull(skb, hdrlen);
|
|
|
|
len = htons(skb->len);
|
|
|
|
ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
|
|
|
|
memcpy(ehdr->h_dest, dst, ETH_ALEN);
|
|
|
|
memcpy(ehdr->h_source, src, ETH_ALEN);
|
|
|
|
ehdr->h_proto = len;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_data_to_8023);
|
|
|
|
|
2009-12-01 09:18:37 +07:00
|
|
|
int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr,
|
2009-05-21 20:47:03 +07:00
|
|
|
enum nl80211_iftype iftype, u8 *bssid, bool qos)
|
|
|
|
{
|
|
|
|
struct ieee80211_hdr hdr;
|
|
|
|
u16 hdrlen, ethertype;
|
|
|
|
__le16 fc;
|
|
|
|
const u8 *encaps_data;
|
|
|
|
int encaps_len, skip_header_bytes;
|
|
|
|
int nh_pos, h_pos;
|
|
|
|
int head_need;
|
|
|
|
|
|
|
|
if (unlikely(skb->len < ETH_HLEN))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
nh_pos = skb_network_header(skb) - skb->data;
|
|
|
|
h_pos = skb_transport_header(skb) - skb->data;
|
|
|
|
|
|
|
|
/* convert Ethernet header to proper 802.11 header (based on
|
|
|
|
* operation mode) */
|
|
|
|
ethertype = (skb->data[12] << 8) | skb->data[13];
|
|
|
|
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
|
|
|
|
|
|
|
|
switch (iftype) {
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
|
|
|
|
/* DA BSSID SA */
|
|
|
|
memcpy(hdr.addr1, skb->data, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr2, addr, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
|
|
|
|
hdrlen = 24;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
|
|
|
|
/* BSSID SA DA */
|
|
|
|
memcpy(hdr.addr1, bssid, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr3, skb->data, ETH_ALEN);
|
|
|
|
hdrlen = 24;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
/* DA SA BSSID */
|
|
|
|
memcpy(hdr.addr1, skb->data, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
|
|
|
|
memcpy(hdr.addr3, bssid, ETH_ALEN);
|
|
|
|
hdrlen = 24;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qos) {
|
|
|
|
fc |= cpu_to_le16(IEEE80211_STYPE_QOS_DATA);
|
|
|
|
hdrlen += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdr.frame_control = fc;
|
|
|
|
hdr.duration_id = 0;
|
|
|
|
hdr.seq_ctrl = 0;
|
|
|
|
|
|
|
|
skip_header_bytes = ETH_HLEN;
|
|
|
|
if (ethertype == ETH_P_AARP || ethertype == ETH_P_IPX) {
|
|
|
|
encaps_data = bridge_tunnel_header;
|
|
|
|
encaps_len = sizeof(bridge_tunnel_header);
|
|
|
|
skip_header_bytes -= 2;
|
|
|
|
} else if (ethertype > 0x600) {
|
|
|
|
encaps_data = rfc1042_header;
|
|
|
|
encaps_len = sizeof(rfc1042_header);
|
|
|
|
skip_header_bytes -= 2;
|
|
|
|
} else {
|
|
|
|
encaps_data = NULL;
|
|
|
|
encaps_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_pull(skb, skip_header_bytes);
|
|
|
|
nh_pos -= skip_header_bytes;
|
|
|
|
h_pos -= skip_header_bytes;
|
|
|
|
|
|
|
|
head_need = hdrlen + encaps_len - skb_headroom(skb);
|
|
|
|
|
|
|
|
if (head_need > 0 || skb_cloned(skb)) {
|
|
|
|
head_need = max(head_need, 0);
|
|
|
|
if (head_need)
|
|
|
|
skb_orphan(skb);
|
|
|
|
|
|
|
|
if (pskb_expand_head(skb, head_need, 0, GFP_ATOMIC)) {
|
|
|
|
printk(KERN_ERR "failed to reallocate Tx buffer\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
skb->truesize += head_need;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encaps_data) {
|
|
|
|
memcpy(skb_push(skb, encaps_len), encaps_data, encaps_len);
|
|
|
|
nh_pos += encaps_len;
|
|
|
|
h_pos += encaps_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(skb_push(skb, hdrlen), &hdr, hdrlen);
|
|
|
|
|
|
|
|
nh_pos += hdrlen;
|
|
|
|
h_pos += hdrlen;
|
|
|
|
|
|
|
|
/* Update skb pointers to various headers since this modified frame
|
|
|
|
* is going to go through Linux networking code that may potentially
|
|
|
|
* need things like pointer to IP header. */
|
|
|
|
skb_set_mac_header(skb, 0);
|
|
|
|
skb_set_network_header(skb, nh_pos);
|
|
|
|
skb_set_transport_header(skb, h_pos);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_data_from_8023);
|
|
|
|
|
2009-12-01 09:18:37 +07:00
|
|
|
|
|
|
|
void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
|
|
|
|
const u8 *addr, enum nl80211_iftype iftype,
|
|
|
|
const unsigned int extra_headroom)
|
|
|
|
{
|
|
|
|
struct sk_buff *frame = NULL;
|
|
|
|
u16 ethertype;
|
|
|
|
u8 *payload;
|
|
|
|
const struct ethhdr *eth;
|
|
|
|
int remaining, err;
|
|
|
|
u8 dst[ETH_ALEN], src[ETH_ALEN];
|
|
|
|
|
|
|
|
err = ieee80211_data_to_8023(skb, addr, iftype);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* skip the wrapping header */
|
|
|
|
eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr));
|
|
|
|
if (!eth)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
while (skb != frame) {
|
|
|
|
u8 padding;
|
|
|
|
__be16 len = eth->h_proto;
|
|
|
|
unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len);
|
|
|
|
|
|
|
|
remaining = skb->len;
|
|
|
|
memcpy(dst, eth->h_dest, ETH_ALEN);
|
|
|
|
memcpy(src, eth->h_source, ETH_ALEN);
|
|
|
|
|
|
|
|
padding = (4 - subframe_len) & 0x3;
|
|
|
|
/* the last MSDU has no padding */
|
|
|
|
if (subframe_len > remaining)
|
|
|
|
goto purge;
|
|
|
|
|
|
|
|
skb_pull(skb, sizeof(struct ethhdr));
|
|
|
|
/* reuse skb for the last subframe */
|
|
|
|
if (remaining <= subframe_len + padding)
|
|
|
|
frame = skb;
|
|
|
|
else {
|
|
|
|
unsigned int hlen = ALIGN(extra_headroom, 4);
|
|
|
|
/*
|
|
|
|
* Allocate and reserve two bytes more for payload
|
|
|
|
* alignment since sizeof(struct ethhdr) is 14.
|
|
|
|
*/
|
|
|
|
frame = dev_alloc_skb(hlen + subframe_len + 2);
|
|
|
|
if (!frame)
|
|
|
|
goto purge;
|
|
|
|
|
|
|
|
skb_reserve(frame, hlen + sizeof(struct ethhdr) + 2);
|
|
|
|
memcpy(skb_put(frame, ntohs(len)), skb->data,
|
|
|
|
ntohs(len));
|
|
|
|
|
|
|
|
eth = (struct ethhdr *)skb_pull(skb, ntohs(len) +
|
|
|
|
padding);
|
|
|
|
if (!eth) {
|
|
|
|
dev_kfree_skb(frame);
|
|
|
|
goto purge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_reset_network_header(frame);
|
|
|
|
frame->dev = skb->dev;
|
|
|
|
frame->priority = skb->priority;
|
|
|
|
|
|
|
|
payload = frame->data;
|
|
|
|
ethertype = (payload[6] << 8) | payload[7];
|
|
|
|
|
|
|
|
if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
|
|
|
|
ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
|
|
|
|
compare_ether_addr(payload,
|
|
|
|
bridge_tunnel_header) == 0)) {
|
|
|
|
/* remove RFC1042 or Bridge-Tunnel
|
|
|
|
* encapsulation and replace EtherType */
|
|
|
|
skb_pull(frame, 6);
|
|
|
|
memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
|
|
|
|
memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
|
|
|
|
} else {
|
|
|
|
memcpy(skb_push(frame, sizeof(__be16)), &len,
|
|
|
|
sizeof(__be16));
|
|
|
|
memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
|
|
|
|
memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
|
|
|
|
}
|
|
|
|
__skb_queue_tail(list, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
purge:
|
|
|
|
__skb_queue_purge(list);
|
|
|
|
out:
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_amsdu_to_8023s);
|
|
|
|
|
2009-05-21 20:47:03 +07:00
|
|
|
/* Given a data frame determine the 802.1p/1d tag to use. */
|
|
|
|
unsigned int cfg80211_classify8021d(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
unsigned int dscp;
|
|
|
|
|
|
|
|
/* skb->priority values from 256->263 are magic values to
|
|
|
|
* directly indicate a specific 802.1d priority. This is used
|
|
|
|
* to allow 802.1d priority to be passed directly in from VLAN
|
|
|
|
* tags, etc.
|
|
|
|
*/
|
|
|
|
if (skb->priority >= 256 && skb->priority <= 263)
|
|
|
|
return skb->priority - 256;
|
|
|
|
|
|
|
|
switch (skb->protocol) {
|
|
|
|
case htons(ETH_P_IP):
|
|
|
|
dscp = ip_hdr(skb)->tos & 0xfc;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dscp >> 5;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cfg80211_classify8021d);
|
2009-07-02 22:18:40 +07:00
|
|
|
|
|
|
|
const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie)
|
|
|
|
{
|
|
|
|
u8 *end, *pos;
|
|
|
|
|
|
|
|
pos = bss->information_elements;
|
|
|
|
if (pos == NULL)
|
|
|
|
return NULL;
|
|
|
|
end = pos + bss->len_information_elements;
|
|
|
|
|
|
|
|
while (pos + 1 < end) {
|
|
|
|
if (pos + 2 + pos[1] > end)
|
|
|
|
break;
|
|
|
|
if (pos[0] == ie)
|
|
|
|
return pos;
|
|
|
|
pos += 2 + pos[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(ieee80211_bss_get_ie);
|
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
|
|
|
|
|
|
|
void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
|
|
|
|
{
|
|
|
|
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
|
|
|
|
struct net_device *dev = wdev->netdev;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!wdev->connect_keys)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
if (!wdev->connect_keys->params[i].cipher)
|
|
|
|
continue;
|
|
|
|
if (rdev->ops->add_key(wdev->wiphy, dev, i, NULL,
|
2009-07-20 15:12:57 +07:00
|
|
|
&wdev->connect_keys->params[i])) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 19:22:54 +07:00
|
|
|
printk(KERN_ERR "%s: failed to set key %d\n",
|
|
|
|
dev->name, i);
|
2009-07-20 15:12:57 +07:00
|
|
|
continue;
|
|
|
|
}
|
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->connect_keys->def == i)
|
2009-07-20 15:12:57 +07:00
|
|
|
if (rdev->ops->set_default_key(wdev->wiphy, dev, i)) {
|
cfg80211: rework key operation
This reworks the key operation in cfg80211, and now only
allows, from userspace, configuring keys (via nl80211)
after the connection has been established (in managed
mode), the IBSS been joined (in IBSS mode), at any time
(in AP[_VLAN] modes) or never for all the other modes.
In order to do shared key authentication correctly, it
is now possible to give a WEP key to the AUTH command.
To configure static WEP keys, these are given to the
CONNECT or IBSS_JOIN command directly, for a userspace
SME it is assumed it will configure it properly after
the connection has been established.
Since mac80211 used to check the default key in IBSS
mode to see whether or not the network is protected,
it needs an update in that area, as well as an update
to make use of the WEP key passed to auth() for shared
key authentication.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-08 19:22:54 +07:00
|
|
|
printk(KERN_ERR "%s: failed to set defkey %d\n",
|
|
|
|
dev->name, i);
|
2009-07-20 15:12:57 +07:00
|
|
|
continue;
|
|
|
|
}
|
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->connect_keys->defmgmt == i)
|
|
|
|
if (rdev->ops->set_default_mgmt_key(wdev->wiphy, dev, i))
|
|
|
|
printk(KERN_ERR "%s: failed to set mgtdef %d\n",
|
|
|
|
dev->name, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(wdev->connect_keys);
|
|
|
|
wdev->connect_keys = NULL;
|
|
|
|
}
|
2009-08-21 19:51:05 +07:00
|
|
|
|
|
|
|
static void cfg80211_process_wdev_events(struct wireless_dev *wdev)
|
|
|
|
{
|
|
|
|
struct cfg80211_event *ev;
|
|
|
|
unsigned long flags;
|
|
|
|
const u8 *bssid = NULL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&wdev->event_lock, flags);
|
|
|
|
while (!list_empty(&wdev->event_list)) {
|
|
|
|
ev = list_first_entry(&wdev->event_list,
|
|
|
|
struct cfg80211_event, list);
|
|
|
|
list_del(&ev->list);
|
|
|
|
spin_unlock_irqrestore(&wdev->event_lock, flags);
|
|
|
|
|
|
|
|
wdev_lock(wdev);
|
|
|
|
switch (ev->type) {
|
|
|
|
case EVENT_CONNECT_RESULT:
|
|
|
|
if (!is_zero_ether_addr(ev->cr.bssid))
|
|
|
|
bssid = ev->cr.bssid;
|
|
|
|
__cfg80211_connect_result(
|
|
|
|
wdev->netdev, bssid,
|
|
|
|
ev->cr.req_ie, ev->cr.req_ie_len,
|
|
|
|
ev->cr.resp_ie, ev->cr.resp_ie_len,
|
|
|
|
ev->cr.status,
|
|
|
|
ev->cr.status == WLAN_STATUS_SUCCESS,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case EVENT_ROAMED:
|
|
|
|
__cfg80211_roamed(wdev, ev->rm.bssid,
|
|
|
|
ev->rm.req_ie, ev->rm.req_ie_len,
|
|
|
|
ev->rm.resp_ie, ev->rm.resp_ie_len);
|
|
|
|
break;
|
|
|
|
case EVENT_DISCONNECTED:
|
|
|
|
__cfg80211_disconnected(wdev->netdev,
|
|
|
|
ev->dc.ie, ev->dc.ie_len,
|
|
|
|
ev->dc.reason, true);
|
|
|
|
break;
|
|
|
|
case EVENT_IBSS_JOINED:
|
|
|
|
__cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wdev_unlock(wdev);
|
|
|
|
|
|
|
|
kfree(ev);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&wdev->event_lock, flags);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&wdev->event_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev)
|
|
|
|
{
|
|
|
|
struct wireless_dev *wdev;
|
|
|
|
|
|
|
|
ASSERT_RTNL();
|
|
|
|
ASSERT_RDEV_LOCK(rdev);
|
|
|
|
|
|
|
|
mutex_lock(&rdev->devlist_mtx);
|
|
|
|
|
|
|
|
list_for_each_entry(wdev, &rdev->netdev_list, list)
|
|
|
|
cfg80211_process_wdev_events(wdev);
|
|
|
|
|
|
|
|
mutex_unlock(&rdev->devlist_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
|
|
|
|
struct net_device *dev, enum nl80211_iftype ntype,
|
|
|
|
u32 *flags, struct vif_params *params)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
enum nl80211_iftype otype = dev->ieee80211_ptr->iftype;
|
|
|
|
|
|
|
|
ASSERT_RDEV_LOCK(rdev);
|
|
|
|
|
|
|
|
/* don't support changing VLANs, you just re-create them */
|
|
|
|
if (otype == NL80211_IFTYPE_AP_VLAN)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!rdev->ops->change_virtual_intf ||
|
|
|
|
!(rdev->wiphy.interface_modes & (1 << ntype)))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
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 it's part of a bridge, reject changing type to station/ibss */
|
2010-06-15 13:50:45 +07:00
|
|
|
if ((dev->priv_flags & IFF_BRIDGE_PORT) &&
|
|
|
|
(ntype == NL80211_IFTYPE_ADHOC || ntype == NL80211_IFTYPE_STATION))
|
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-08-21 19:51:05 +07:00
|
|
|
if (ntype != otype) {
|
2009-11-19 17:55:19 +07:00
|
|
|
dev->ieee80211_ptr->use_4addr = false;
|
|
|
|
|
2009-08-21 19:51:05 +07:00
|
|
|
switch (otype) {
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
cfg80211_leave_ibss(rdev, dev, false);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
cfg80211_disconnect(rdev, dev,
|
|
|
|
WLAN_REASON_DEAUTH_LEAVING, true);
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
/* mesh should be handled? */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg80211_process_rdev_events(rdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev,
|
|
|
|
ntype, flags, params);
|
|
|
|
|
|
|
|
WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
|
|
|
|
|
2009-11-19 17:55:19 +07:00
|
|
|
if (!err && params && params->use_4addr != -1)
|
|
|
|
dev->ieee80211_ptr->use_4addr = params->use_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
|
|
|
if (!err) {
|
|
|
|
dev->priv_flags &= ~IFF_DONT_BRIDGE;
|
|
|
|
switch (ntype) {
|
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
if (dev->ieee80211_ptr->use_4addr)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
|
|
|
dev->priv_flags |= IFF_DONT_BRIDGE;
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_AP:
|
|
|
|
case NL80211_IFTYPE_AP_VLAN:
|
|
|
|
case NL80211_IFTYPE_WDS:
|
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
|
|
|
/* bridging OK */
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_MONITOR:
|
|
|
|
/* monitor can't bridge anyway */
|
|
|
|
break;
|
|
|
|
case NL80211_IFTYPE_UNSPECIFIED:
|
2010-08-12 20:38:38 +07:00
|
|
|
case NUM_NL80211_IFTYPES:
|
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
|
|
|
/* not happening */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-21 19:51:05 +07:00
|
|
|
return err;
|
|
|
|
}
|
2009-12-10 04:43:52 +07:00
|
|
|
|
|
|
|
u16 cfg80211_calculate_bitrate(struct rate_info *rate)
|
|
|
|
{
|
|
|
|
int modulation, streams, bitrate;
|
|
|
|
|
|
|
|
if (!(rate->flags & RATE_INFO_FLAGS_MCS))
|
|
|
|
return rate->legacy;
|
|
|
|
|
|
|
|
/* the formula below does only work for MCS values smaller than 32 */
|
|
|
|
if (rate->mcs >= 32)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
modulation = rate->mcs & 7;
|
|
|
|
streams = (rate->mcs >> 3) + 1;
|
|
|
|
|
|
|
|
bitrate = (rate->flags & RATE_INFO_FLAGS_40_MHZ_WIDTH) ?
|
|
|
|
13500000 : 6500000;
|
|
|
|
|
|
|
|
if (modulation < 4)
|
|
|
|
bitrate *= (modulation + 1);
|
|
|
|
else if (modulation == 4)
|
|
|
|
bitrate *= (modulation + 2);
|
|
|
|
else
|
|
|
|
bitrate *= (modulation + 3);
|
|
|
|
|
|
|
|
bitrate *= streams;
|
|
|
|
|
|
|
|
if (rate->flags & RATE_INFO_FLAGS_SHORT_GI)
|
|
|
|
bitrate = (bitrate / 9) * 10;
|
|
|
|
|
|
|
|
/* do NOT round down here */
|
|
|
|
return (bitrate + 50000) / 100000;
|
|
|
|
}
|