2007-05-06 02:45:53 +08:00
|
|
|
/*
|
|
|
|
* BSS client mode implementation
|
2009-01-08 19:31:59 +08:00
|
|
|
* Copyright 2003-2008, Jouni Malinen <j@w1.fi>
|
2007-05-06 02:45:53 +08:00
|
|
|
* Copyright 2004, Instant802 Networks, Inc.
|
|
|
|
* Copyright 2005, Devicescape Software, Inc.
|
|
|
|
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
|
|
|
|
* Copyright 2007, Michael Wu <flamingice@sourmilk.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2007-05-09 09:40:27 +08:00
|
|
|
#include <linux/delay.h>
|
2007-05-06 02:45:53 +08:00
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/etherdevice.h>
|
2008-02-25 23:27:46 +08:00
|
|
|
#include <linux/rtnetlink.h>
|
2007-05-06 02:45:53 +08:00
|
|
|
#include <net/mac80211.h>
|
2008-09-11 06:01:49 +08:00
|
|
|
#include <asm/unaligned.h>
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2007-05-06 02:45:53 +08:00
|
|
|
#include "ieee80211_i.h"
|
2008-04-09 03:14:40 +08:00
|
|
|
#include "rate.h"
|
|
|
|
#include "led.h"
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-08-08 06:50:46 +08:00
|
|
|
#define IEEE80211_ASSOC_SCANS_MAX_TRIES 2
|
2007-05-06 02:45:53 +08:00
|
|
|
#define IEEE80211_AUTH_TIMEOUT (HZ / 5)
|
|
|
|
#define IEEE80211_AUTH_MAX_TRIES 3
|
|
|
|
#define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
|
|
|
|
#define IEEE80211_ASSOC_MAX_TRIES 3
|
|
|
|
#define IEEE80211_MONITORING_INTERVAL (2 * HZ)
|
2009-03-23 03:57:14 +08:00
|
|
|
#define IEEE80211_PROBE_IDLE_TIME (60 * HZ)
|
2007-05-06 02:45:53 +08:00
|
|
|
#define IEEE80211_RETRY_AUTH_INTERVAL (1 * HZ)
|
|
|
|
|
2008-09-08 23:44:27 +08:00
|
|
|
/* utils */
|
|
|
|
static int ecw2cw(int ecw)
|
2008-09-08 23:44:22 +08:00
|
|
|
{
|
2008-09-08 23:44:27 +08:00
|
|
|
return (1 << ecw) - 1;
|
2008-09-08 23:44:22 +08:00
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:55 +08:00
|
|
|
static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie)
|
2008-08-16 03:21:27 +08:00
|
|
|
{
|
|
|
|
u8 *end, *pos;
|
|
|
|
|
2009-02-11 04:26:00 +08:00
|
|
|
pos = bss->cbss.information_elements;
|
2008-08-16 03:21:27 +08:00
|
|
|
if (pos == NULL)
|
|
|
|
return NULL;
|
2009-02-11 04:26:00 +08:00
|
|
|
end = pos + bss->cbss.len_information_elements;
|
2008-08-16 03:21:27 +08:00
|
|
|
|
|
|
|
while (pos + 1 < end) {
|
|
|
|
if (pos + 2 + pos[1] > end)
|
|
|
|
break;
|
|
|
|
if (pos[0] == ie)
|
|
|
|
return pos;
|
|
|
|
pos += 2 + pos[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:55 +08:00
|
|
|
static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
|
2008-09-09 16:57:09 +08:00
|
|
|
struct ieee80211_supported_band *sband,
|
2009-01-21 22:13:48 +08:00
|
|
|
u32 *rates)
|
2008-09-09 16:57:09 +08:00
|
|
|
{
|
|
|
|
int i, j, count;
|
|
|
|
*rates = 0;
|
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < bss->supp_rates_len; i++) {
|
|
|
|
int rate = (bss->supp_rates[i] & 0x7F) * 5;
|
|
|
|
|
|
|
|
for (j = 0; j < sband->n_bitrates; j++)
|
|
|
|
if (sband->bitrates[j].bitrate == rate) {
|
|
|
|
*rates |= BIT(j);
|
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
/* frame sending functions */
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
|
2008-09-09 16:57:09 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-09 16:57:09 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_mgmt *mgmt;
|
2009-03-21 03:21:16 +08:00
|
|
|
u8 *pos, *ies, *ht_ie;
|
2008-09-09 16:57:09 +08:00
|
|
|
int i, len, count, rates_len, supp_rates_len;
|
|
|
|
u16 capab;
|
2008-09-11 06:01:55 +08:00
|
|
|
struct ieee80211_bss *bss;
|
2008-09-09 16:57:09 +08:00
|
|
|
int wmm = 0;
|
|
|
|
struct ieee80211_supported_band *sband;
|
2009-01-21 22:13:48 +08:00
|
|
|
u32 rates = 0;
|
2008-09-09 16:57:09 +08:00
|
|
|
|
|
|
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom +
|
2009-02-15 19:44:28 +08:00
|
|
|
sizeof(*mgmt) + 200 + ifmgd->extra_ie_len +
|
2009-03-21 03:21:16 +08:00
|
|
|
ifmgd->ssid_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
if (!skb) {
|
|
|
|
printk(KERN_DEBUG "%s: failed to allocate buffer for assoc "
|
|
|
|
"frame\n", sdata->dev->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
|
|
|
|
|
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
capab = ifmgd->capab;
|
2008-09-09 16:57:09 +08:00
|
|
|
|
|
|
|
if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) {
|
|
|
|
if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
|
|
|
|
capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
|
|
|
|
if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
|
|
|
|
capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
|
2008-09-09 16:57:09 +08:00
|
|
|
local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
if (bss) {
|
2009-02-11 04:26:00 +08:00
|
|
|
if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY)
|
2008-09-09 16:57:09 +08:00
|
|
|
capab |= WLAN_CAPABILITY_PRIVACY;
|
|
|
|
if (bss->wmm_used)
|
|
|
|
wmm = 1;
|
|
|
|
|
|
|
|
/* get all rates supported by the device and the AP as
|
|
|
|
* some APs don't like getting a superset of their rates
|
|
|
|
* in the association request (e.g. D-Link DAP 1353 in
|
|
|
|
* b-only mode) */
|
|
|
|
rates_len = ieee80211_compatible_rates(bss, sband, &rates);
|
|
|
|
|
2009-02-11 04:26:00 +08:00
|
|
|
if ((bss->cbss.capability & WLAN_CAPABILITY_SPECTRUM_MGMT) &&
|
2008-09-09 16:57:09 +08:00
|
|
|
(local->hw.flags & IEEE80211_HW_SPECTRUM_MGMT))
|
|
|
|
capab |= WLAN_CAPABILITY_SPECTRUM_MGMT;
|
|
|
|
|
|
|
|
ieee80211_rx_bss_put(local, bss);
|
|
|
|
} else {
|
|
|
|
rates = ~0;
|
|
|
|
rates_len = sband->n_bitrates;
|
|
|
|
}
|
|
|
|
|
|
|
|
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
|
|
|
memset(mgmt, 0, 24);
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN);
|
2008-09-09 16:57:09 +08:00
|
|
|
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_PREV_BSSID_SET) {
|
2008-09-09 16:57:09 +08:00
|
|
|
skb_put(skb, 10);
|
|
|
|
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
|
|
|
IEEE80211_STYPE_REASSOC_REQ);
|
|
|
|
mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab);
|
|
|
|
mgmt->u.reassoc_req.listen_interval =
|
|
|
|
cpu_to_le16(local->hw.conf.listen_interval);
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(mgmt->u.reassoc_req.current_ap, ifmgd->prev_bssid,
|
2008-09-09 16:57:09 +08:00
|
|
|
ETH_ALEN);
|
|
|
|
} else {
|
|
|
|
skb_put(skb, 4);
|
|
|
|
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
|
|
|
IEEE80211_STYPE_ASSOC_REQ);
|
|
|
|
mgmt->u.assoc_req.capab_info = cpu_to_le16(capab);
|
2008-12-17 04:38:29 +08:00
|
|
|
mgmt->u.assoc_req.listen_interval =
|
2008-09-09 16:57:09 +08:00
|
|
|
cpu_to_le16(local->hw.conf.listen_interval);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SSID */
|
2009-02-15 19:44:28 +08:00
|
|
|
ies = pos = skb_put(skb, 2 + ifmgd->ssid_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
*pos++ = WLAN_EID_SSID;
|
2009-02-15 19:44:28 +08:00
|
|
|
*pos++ = ifmgd->ssid_len;
|
|
|
|
memcpy(pos, ifmgd->ssid, ifmgd->ssid_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
|
|
|
/* add all rates which were marked to be used above */
|
|
|
|
supp_rates_len = rates_len;
|
|
|
|
if (supp_rates_len > 8)
|
|
|
|
supp_rates_len = 8;
|
|
|
|
|
|
|
|
len = sband->n_bitrates;
|
|
|
|
pos = skb_put(skb, supp_rates_len + 2);
|
|
|
|
*pos++ = WLAN_EID_SUPP_RATES;
|
|
|
|
*pos++ = supp_rates_len;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < sband->n_bitrates; i++) {
|
|
|
|
if (BIT(i) & rates) {
|
|
|
|
int rate = sband->bitrates[i].bitrate;
|
|
|
|
*pos++ = (u8) (rate / 5);
|
|
|
|
if (++count == 8)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rates_len > count) {
|
|
|
|
pos = skb_put(skb, rates_len - count + 2);
|
|
|
|
*pos++ = WLAN_EID_EXT_SUPP_RATES;
|
|
|
|
*pos++ = rates_len - count;
|
|
|
|
|
|
|
|
for (i++; i < sband->n_bitrates; i++) {
|
|
|
|
if (BIT(i) & rates) {
|
|
|
|
int rate = sband->bitrates[i].bitrate;
|
|
|
|
*pos++ = (u8) (rate / 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) {
|
|
|
|
/* 1. power capabilities */
|
|
|
|
pos = skb_put(skb, 4);
|
|
|
|
*pos++ = WLAN_EID_PWR_CAPABILITY;
|
|
|
|
*pos++ = 2;
|
|
|
|
*pos++ = 0; /* min tx power */
|
|
|
|
*pos++ = local->hw.conf.channel->max_power; /* max tx power */
|
|
|
|
|
|
|
|
/* 2. supported channels */
|
|
|
|
/* TODO: get this in reg domain format */
|
|
|
|
pos = skb_put(skb, 2 * sband->n_channels + 2);
|
|
|
|
*pos++ = WLAN_EID_SUPPORTED_CHANNELS;
|
|
|
|
*pos++ = 2 * sband->n_channels;
|
|
|
|
for (i = 0; i < sband->n_channels; i++) {
|
|
|
|
*pos++ = ieee80211_frequency_to_channel(
|
|
|
|
sband->channels[i].center_freq);
|
|
|
|
*pos++ = 1; /* one channel in the subband*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->extra_ie) {
|
|
|
|
pos = skb_put(skb, ifmgd->extra_ie_len);
|
|
|
|
memcpy(pos, ifmgd->extra_ie, ifmgd->extra_ie_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) {
|
2008-09-09 16:57:09 +08:00
|
|
|
pos = skb_put(skb, 9);
|
|
|
|
*pos++ = WLAN_EID_VENDOR_SPECIFIC;
|
|
|
|
*pos++ = 7; /* len */
|
|
|
|
*pos++ = 0x00; /* Microsoft OUI 00:50:F2 */
|
|
|
|
*pos++ = 0x50;
|
|
|
|
*pos++ = 0xf2;
|
|
|
|
*pos++ = 2; /* WME */
|
|
|
|
*pos++ = 0; /* WME info */
|
|
|
|
*pos++ = 1; /* WME ver */
|
|
|
|
*pos++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wmm support is a must to HT */
|
2008-12-24 00:00:50 +08:00
|
|
|
/*
|
|
|
|
* IEEE802.11n does not allow TKIP/WEP as pairwise
|
|
|
|
* ciphers in HT mode. We still associate in non-ht
|
|
|
|
* mode (11a/b/g) if any one of these ciphers is
|
|
|
|
* configured as pairwise.
|
|
|
|
*/
|
2009-02-15 19:44:28 +08:00
|
|
|
if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
|
2008-10-09 18:13:49 +08:00
|
|
|
sband->ht_cap.ht_supported &&
|
|
|
|
(ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) &&
|
2008-12-24 00:00:50 +08:00
|
|
|
ht_ie[1] >= sizeof(struct ieee80211_ht_info) &&
|
2009-02-15 19:44:28 +08:00
|
|
|
(!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))) {
|
2008-10-09 18:13:49 +08:00
|
|
|
struct ieee80211_ht_info *ht_info =
|
|
|
|
(struct ieee80211_ht_info *)(ht_ie + 2);
|
|
|
|
u16 cap = sband->ht_cap.cap;
|
2008-09-09 16:57:09 +08:00
|
|
|
__le16 tmp;
|
|
|
|
u32 flags = local->hw.conf.channel->flags;
|
|
|
|
|
2008-10-09 18:13:49 +08:00
|
|
|
switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
|
|
|
|
case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
|
2008-09-09 16:57:09 +08:00
|
|
|
if (flags & IEEE80211_CHAN_NO_FAT_ABOVE) {
|
2008-10-09 18:13:49 +08:00
|
|
|
cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
|
2008-09-09 16:57:09 +08:00
|
|
|
cap &= ~IEEE80211_HT_CAP_SGI_40;
|
|
|
|
}
|
|
|
|
break;
|
2008-10-09 18:13:49 +08:00
|
|
|
case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
|
2008-09-09 16:57:09 +08:00
|
|
|
if (flags & IEEE80211_CHAN_NO_FAT_BELOW) {
|
2008-10-09 18:13:49 +08:00
|
|
|
cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
|
2008-09-09 16:57:09 +08:00
|
|
|
cap &= ~IEEE80211_HT_CAP_SGI_40;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = cpu_to_le16(cap);
|
|
|
|
pos = skb_put(skb, sizeof(struct ieee80211_ht_cap)+2);
|
|
|
|
*pos++ = WLAN_EID_HT_CAPABILITY;
|
|
|
|
*pos++ = sizeof(struct ieee80211_ht_cap);
|
|
|
|
memset(pos, 0, sizeof(struct ieee80211_ht_cap));
|
|
|
|
memcpy(pos, &tmp, sizeof(u16));
|
|
|
|
pos += sizeof(u16);
|
|
|
|
/* TODO: needs a define here for << 2 */
|
2008-10-09 18:13:49 +08:00
|
|
|
*pos++ = sband->ht_cap.ampdu_factor |
|
|
|
|
(sband->ht_cap.ampdu_density << 2);
|
|
|
|
memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs));
|
2008-09-09 16:57:09 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
kfree(ifmgd->assocreq_ies);
|
|
|
|
ifmgd->assocreq_ies_len = (skb->data + skb->len) - ies;
|
|
|
|
ifmgd->assocreq_ies = kmalloc(ifmgd->assocreq_ies_len, GFP_KERNEL);
|
|
|
|
if (ifmgd->assocreq_ies)
|
|
|
|
memcpy(ifmgd->assocreq_ies, ies, ifmgd->assocreq_ies_len);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
2008-09-09 21:07:09 +08:00
|
|
|
ieee80211_tx_skb(sdata, skb, 0);
|
2008-09-09 16:57:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-09 16:58:25 +08:00
|
|
|
static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
|
|
|
|
u16 stype, u16 reason)
|
2008-09-09 16:57:09 +08:00
|
|
|
{
|
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-09 16:57:09 +08:00
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_mgmt *mgmt;
|
2009-01-13 22:03:29 +08:00
|
|
|
|
2009-03-21 03:21:16 +08:00
|
|
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt));
|
2008-09-09 16:57:09 +08:00
|
|
|
if (!skb) {
|
2008-09-09 16:58:25 +08:00
|
|
|
printk(KERN_DEBUG "%s: failed to allocate buffer for "
|
|
|
|
"deauth/disassoc frame\n", sdata->dev->name);
|
2008-09-09 16:57:09 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
|
|
|
|
|
|
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
|
|
|
memset(mgmt, 0, 24);
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN);
|
2008-09-09 16:57:09 +08:00
|
|
|
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN);
|
2008-09-09 16:58:25 +08:00
|
|
|
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype);
|
2008-09-09 16:57:09 +08:00
|
|
|
skb_put(skb, 2);
|
2008-09-09 16:58:25 +08:00
|
|
|
/* u.deauth.reason_code == u.disassoc.reason_code */
|
2008-09-09 16:57:09 +08:00
|
|
|
mgmt->u.deauth.reason_code = cpu_to_le16(reason);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED);
|
2008-09-09 16:57:09 +08:00
|
|
|
}
|
|
|
|
|
2009-02-10 23:09:31 +08:00
|
|
|
void ieee80211_send_pspoll(struct ieee80211_local *local,
|
|
|
|
struct ieee80211_sub_if_data *sdata)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2009-02-10 23:09:31 +08:00
|
|
|
struct ieee80211_pspoll *pspoll;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
u16 fc;
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*pspoll));
|
|
|
|
if (!skb) {
|
|
|
|
printk(KERN_DEBUG "%s: failed to allocate buffer for "
|
|
|
|
"pspoll frame\n", sdata->dev->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
|
|
|
|
|
|
pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll));
|
|
|
|
memset(pspoll, 0, sizeof(*pspoll));
|
|
|
|
fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM;
|
|
|
|
pspoll->frame_control = cpu_to_le16(fc);
|
2009-02-15 19:44:28 +08:00
|
|
|
pspoll->aid = cpu_to_le16(ifmgd->aid);
|
2009-02-10 23:09:31 +08:00
|
|
|
|
|
|
|
/* aid in PS-Poll has its two MSBs each set to 1 */
|
|
|
|
pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN);
|
2009-02-10 23:09:31 +08:00
|
|
|
memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN);
|
|
|
|
|
|
|
|
ieee80211_tx_skb(sdata, skb, 0);
|
|
|
|
}
|
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
/* MLME */
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_sta_wmm_params(struct ieee80211_local *local,
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd,
|
2007-05-06 02:45:53 +08:00
|
|
|
u8 *wmm_param, size_t wmm_param_len)
|
|
|
|
{
|
|
|
|
struct ieee80211_tx_queue_params params;
|
|
|
|
size_t left;
|
|
|
|
int count;
|
|
|
|
u8 *pos;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_WMM_ENABLED))
|
2008-05-03 06:59:37 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!wmm_param)
|
|
|
|
return;
|
|
|
|
|
2007-05-06 02:45:53 +08:00
|
|
|
if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1)
|
|
|
|
return;
|
|
|
|
count = wmm_param[6] & 0x0f;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (count == ifmgd->wmm_last_param_set)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->wmm_last_param_set = count;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
pos = wmm_param + 8;
|
|
|
|
left = wmm_param_len - 8;
|
|
|
|
|
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
|
|
|
local->wmm_acm = 0;
|
|
|
|
for (; left >= 4; left -= 4, pos += 4) {
|
|
|
|
int aci = (pos[0] >> 5) & 0x03;
|
|
|
|
int acm = (pos[0] >> 4) & 0x01;
|
|
|
|
int queue;
|
|
|
|
|
|
|
|
switch (aci) {
|
2009-03-05 23:23:46 +08:00
|
|
|
case 1: /* AC_BK */
|
2008-05-01 00:51:21 +08:00
|
|
|
queue = 3;
|
2008-04-18 01:21:22 +08:00
|
|
|
if (acm)
|
2009-03-05 23:23:46 +08:00
|
|
|
local->wmm_acm |= BIT(1) | BIT(2); /* BK/- */
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
2009-03-05 23:23:46 +08:00
|
|
|
case 2: /* AC_VI */
|
2008-05-01 00:51:21 +08:00
|
|
|
queue = 1;
|
2008-04-18 01:21:22 +08:00
|
|
|
if (acm)
|
2009-03-05 23:23:46 +08:00
|
|
|
local->wmm_acm |= BIT(4) | BIT(5); /* CL/VI */
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
2009-03-05 23:23:46 +08:00
|
|
|
case 3: /* AC_VO */
|
2008-05-01 00:51:21 +08:00
|
|
|
queue = 0;
|
2008-04-18 01:21:22 +08:00
|
|
|
if (acm)
|
2009-03-05 23:23:46 +08:00
|
|
|
local->wmm_acm |= BIT(6) | BIT(7); /* VO/NC */
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
2009-03-05 23:23:46 +08:00
|
|
|
case 0: /* AC_BE */
|
2007-05-06 02:45:53 +08:00
|
|
|
default:
|
2008-05-01 00:51:21 +08:00
|
|
|
queue = 2;
|
2008-04-18 01:21:22 +08:00
|
|
|
if (acm)
|
2009-03-05 23:23:46 +08:00
|
|
|
local->wmm_acm |= BIT(0) | BIT(3); /* BE/EE */
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
params.aifs = pos[0] & 0x0f;
|
|
|
|
params.cw_max = ecw2cw((pos[1] & 0xf0) >> 4);
|
|
|
|
params.cw_min = ecw2cw(pos[1] & 0x0f);
|
2008-07-10 17:22:31 +08:00
|
|
|
params.txop = get_unaligned_le16(pos + 2);
|
2008-06-30 21:10:46 +08:00
|
|
|
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
2007-05-06 02:45:53 +08:00
|
|
|
printk(KERN_DEBUG "%s: WMM queue=%d aci=%d acm=%d aifs=%d "
|
2008-02-10 23:49:38 +08:00
|
|
|
"cWmin=%d cWmax=%d txop=%d\n",
|
2008-08-03 08:04:37 +08:00
|
|
|
local->mdev->name, queue, aci, acm, params.aifs, params.cw_min,
|
2008-02-10 23:49:38 +08:00
|
|
|
params.cw_max, params.txop);
|
|
|
|
#endif
|
2009-03-05 23:23:46 +08:00
|
|
|
if (local->ops->conf_tx &&
|
|
|
|
local->ops->conf_tx(local_to_hw(local), queue, ¶ms)) {
|
2007-05-06 02:45:53 +08:00
|
|
|
printk(KERN_DEBUG "%s: failed to set TX queue "
|
2008-08-03 08:04:37 +08:00
|
|
|
"parameters for queue %d\n", local->mdev->name, queue);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-10 23:09:24 +08:00
|
|
|
static bool ieee80211_check_tim(struct ieee802_11_elems *elems, u16 aid)
|
2008-12-24 10:39:02 +08:00
|
|
|
{
|
|
|
|
u8 mask;
|
|
|
|
u8 index, indexn1, indexn2;
|
|
|
|
struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *) elems->tim;
|
|
|
|
|
|
|
|
aid &= 0x3fff;
|
|
|
|
index = aid / 8;
|
|
|
|
mask = 1 << (aid & 7);
|
|
|
|
|
|
|
|
indexn1 = tim->bitmap_ctrl & 0xfe;
|
|
|
|
indexn2 = elems->tim_len + indexn1 - 4;
|
|
|
|
|
|
|
|
if (index < indexn1 || index > indexn2)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
index -= indexn1;
|
|
|
|
|
|
|
|
return !!(tim->virtual_map[index] & mask);
|
|
|
|
}
|
|
|
|
|
2008-10-08 16:59:33 +08:00
|
|
|
static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata,
|
|
|
|
u16 capab, bool erp_valid, u8 erp)
|
2007-07-11 01:32:10 +08:00
|
|
|
{
|
2008-10-11 07:51:51 +08:00
|
|
|
struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
|
2008-07-01 15:44:50 +08:00
|
|
|
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-07-01 15:44:50 +08:00
|
|
|
#endif
|
2007-12-28 21:32:58 +08:00
|
|
|
u32 changed = 0;
|
2008-10-08 16:59:33 +08:00
|
|
|
bool use_protection;
|
|
|
|
bool use_short_preamble;
|
|
|
|
bool use_short_slot;
|
|
|
|
|
|
|
|
if (erp_valid) {
|
|
|
|
use_protection = (erp & WLAN_ERP_USE_PROTECTION) != 0;
|
|
|
|
use_short_preamble = (erp & WLAN_ERP_BARKER_PREAMBLE) == 0;
|
|
|
|
} else {
|
|
|
|
use_protection = false;
|
|
|
|
use_short_preamble = !!(capab & WLAN_CAPABILITY_SHORT_PREAMBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME);
|
2007-07-11 01:32:10 +08:00
|
|
|
|
2007-12-28 21:32:58 +08:00
|
|
|
if (use_protection != bss_conf->use_cts_prot) {
|
2008-06-30 21:10:46 +08:00
|
|
|
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
2007-07-11 01:32:10 +08:00
|
|
|
if (net_ratelimit()) {
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: CTS protection %s (BSSID=%pM)\n",
|
2007-12-28 21:32:58 +08:00
|
|
|
sdata->dev->name,
|
2007-07-11 01:32:10 +08:00
|
|
|
use_protection ? "enabled" : "disabled",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->bssid);
|
2007-07-11 01:32:10 +08:00
|
|
|
}
|
2008-06-30 21:10:46 +08:00
|
|
|
#endif
|
2007-12-28 21:32:58 +08:00
|
|
|
bss_conf->use_cts_prot = use_protection;
|
|
|
|
changed |= BSS_CHANGED_ERP_CTS_PROT;
|
2007-07-11 01:32:10 +08:00
|
|
|
}
|
2007-07-27 21:43:24 +08:00
|
|
|
|
2008-03-31 23:05:03 +08:00
|
|
|
if (use_short_preamble != bss_conf->use_short_preamble) {
|
2008-06-30 21:10:46 +08:00
|
|
|
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
2007-07-27 21:43:24 +08:00
|
|
|
if (net_ratelimit()) {
|
|
|
|
printk(KERN_DEBUG "%s: switched to %s barker preamble"
|
2008-10-28 06:56:10 +08:00
|
|
|
" (BSSID=%pM)\n",
|
2007-12-28 21:32:58 +08:00
|
|
|
sdata->dev->name,
|
2008-03-31 23:05:03 +08:00
|
|
|
use_short_preamble ? "short" : "long",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->bssid);
|
2007-07-27 21:43:24 +08:00
|
|
|
}
|
2008-06-30 21:10:46 +08:00
|
|
|
#endif
|
2008-03-31 23:05:03 +08:00
|
|
|
bss_conf->use_short_preamble = use_short_preamble;
|
2007-12-28 21:32:58 +08:00
|
|
|
changed |= BSS_CHANGED_ERP_PREAMBLE;
|
2007-07-27 21:43:24 +08:00
|
|
|
}
|
2007-07-27 21:43:24 +08:00
|
|
|
|
2008-10-08 16:59:33 +08:00
|
|
|
if (use_short_slot != bss_conf->use_short_slot) {
|
|
|
|
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
|
|
|
if (net_ratelimit()) {
|
2009-01-18 09:24:15 +08:00
|
|
|
printk(KERN_DEBUG "%s: switched to %s slot time"
|
|
|
|
" (BSSID=%pM)\n",
|
2008-10-08 16:59:33 +08:00
|
|
|
sdata->dev->name,
|
|
|
|
use_short_slot ? "short" : "long",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->bssid);
|
2008-10-08 16:59:33 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bss_conf->use_short_slot = use_short_slot;
|
|
|
|
changed |= BSS_CHANGED_ERP_SLOT;
|
2008-04-16 02:09:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_sta_send_apinfo(struct ieee80211_sub_if_data *sdata)
|
2008-09-08 23:33:39 +08:00
|
|
|
{
|
|
|
|
union iwreq_data wrqu;
|
2009-02-15 19:44:28 +08:00
|
|
|
|
2008-09-08 23:33:39 +08:00
|
|
|
memset(&wrqu, 0, sizeof(wrqu));
|
2009-02-15 19:44:28 +08:00
|
|
|
if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED)
|
|
|
|
memcpy(wrqu.ap_addr.sa_data, sdata->u.mgd.bssid, ETH_ALEN);
|
2008-09-08 23:33:39 +08:00
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL);
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-06 03:38:09 +08:00
|
|
|
char *buf;
|
|
|
|
size_t len;
|
|
|
|
int i;
|
2007-05-06 02:45:53 +08:00
|
|
|
union iwreq_data wrqu;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (!ifmgd->assocreq_ies && !ifmgd->assocresp_ies)
|
2008-09-06 03:38:09 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
buf = kmalloc(50 + 2 * (ifmgd->assocreq_ies_len +
|
|
|
|
ifmgd->assocresp_ies_len), GFP_KERNEL);
|
2008-09-06 03:38:09 +08:00
|
|
|
if (!buf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
len = sprintf(buf, "ASSOCINFO(");
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->assocreq_ies) {
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, "ReqIEs=");
|
2009-02-15 19:44:28 +08:00
|
|
|
for (i = 0; i < ifmgd->assocreq_ies_len; i++) {
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, "%02x",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->assocreq_ies[i]);
|
2008-09-06 03:38:09 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->assocresp_ies) {
|
|
|
|
if (ifmgd->assocreq_ies)
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, " ");
|
|
|
|
len += sprintf(buf + len, "RespIEs=");
|
2009-02-15 19:44:28 +08:00
|
|
|
for (i = 0; i < ifmgd->assocresp_ies_len; i++) {
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, "%02x",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->assocresp_ies[i]);
|
2008-09-06 03:38:09 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, ")");
|
|
|
|
|
|
|
|
if (len > IW_CUSTOM_MAX) {
|
|
|
|
len = sprintf(buf, "ASSOCRESPIE=");
|
2009-02-15 19:44:28 +08:00
|
|
|
for (i = 0; i < ifmgd->assocresp_ies_len; i++) {
|
2008-09-06 03:38:09 +08:00
|
|
|
len += sprintf(buf + len, "%02x",
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->assocresp_ies[i]);
|
2008-09-06 03:38:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-02 03:45:02 +08:00
|
|
|
if (len <= IW_CUSTOM_MAX) {
|
|
|
|
memset(&wrqu, 0, sizeof(wrqu));
|
|
|
|
wrqu.data.length = len;
|
|
|
|
wireless_send_event(sdata->dev, IWEVCUSTOM, &wrqu, buf);
|
|
|
|
}
|
2008-09-06 03:38:09 +08:00
|
|
|
|
|
|
|
kfree(buf);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
|
2008-10-14 22:58:37 +08:00
|
|
|
u32 bss_info_changed)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-12-28 21:32:58 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2008-03-29 07:33:32 +08:00
|
|
|
struct ieee80211_conf *conf = &local_to_hw(local)->conf;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 06:01:55 +08:00
|
|
|
struct ieee80211_bss *bss;
|
2007-08-29 05:01:54 +08:00
|
|
|
|
2008-10-14 22:58:37 +08:00
|
|
|
bss_info_changed |= BSS_CHANGED_ASSOC;
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags |= IEEE80211_STA_ASSOCIATED;
|
2007-07-11 01:32:10 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
|
2008-09-08 23:33:39 +08:00
|
|
|
conf->channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2008-09-08 23:33:39 +08:00
|
|
|
if (bss) {
|
|
|
|
/* set timing information */
|
2009-02-11 04:26:00 +08:00
|
|
|
sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval;
|
|
|
|
sdata->vif.bss_conf.timestamp = bss->cbss.tsf;
|
2008-10-11 07:51:51 +08:00
|
|
|
sdata->vif.bss_conf.dtim_period = bss->dtim_period;
|
2008-03-29 07:33:34 +08:00
|
|
|
|
2008-10-14 22:58:37 +08:00
|
|
|
bss_info_changed |= ieee80211_handle_bss_capability(sdata,
|
2009-02-11 04:26:00 +08:00
|
|
|
bss->cbss.capability, bss->has_erp_value, bss->erp_value);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
|
|
|
ieee80211_rx_bss_put(local, bss);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags |= IEEE80211_STA_PREV_BSSID_SET;
|
|
|
|
memcpy(ifmgd->prev_bssid, sdata->u.mgd.bssid, ETH_ALEN);
|
|
|
|
ieee80211_sta_send_associnfo(sdata);
|
2008-05-29 16:35:23 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->last_probe = jiffies;
|
2008-09-09 16:57:09 +08:00
|
|
|
ieee80211_led_assoc(local, 1);
|
2008-05-29 16:35:23 +08:00
|
|
|
|
2008-10-11 07:51:51 +08:00
|
|
|
sdata->vif.bss_conf.assoc = 1;
|
2008-09-11 06:01:57 +08:00
|
|
|
/*
|
|
|
|
* For now just always ask the driver to update the basic rateset
|
|
|
|
* when we have associated, we aren't checking whether it actually
|
|
|
|
* changed or not.
|
|
|
|
*/
|
2008-10-14 22:58:37 +08:00
|
|
|
bss_info_changed |= BSS_CHANGED_BASIC_RATES;
|
|
|
|
ieee80211_bss_info_change_notify(sdata, bss_info_changed);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-01-08 01:28:20 +08:00
|
|
|
if (local->powersave) {
|
|
|
|
if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS) &&
|
|
|
|
local->hw.conf.dynamic_ps_timeout > 0) {
|
2008-12-19 05:35:27 +08:00
|
|
|
mod_timer(&local->dynamic_ps_timer, jiffies +
|
2009-01-07 01:13:18 +08:00
|
|
|
msecs_to_jiffies(
|
|
|
|
local->hw.conf.dynamic_ps_timeout));
|
2009-01-08 01:28:20 +08:00
|
|
|
} else {
|
|
|
|
if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
|
|
|
|
ieee80211_send_nullfunc(local, sdata, 1);
|
2008-12-19 05:35:27 +08:00
|
|
|
conf->flags |= IEEE80211_CONF_PS;
|
2009-01-08 01:28:20 +08:00
|
|
|
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
|
2008-12-19 05:35:27 +08:00
|
|
|
}
|
2008-12-19 05:35:13 +08:00
|
|
|
}
|
|
|
|
|
2008-09-09 16:57:09 +08:00
|
|
|
netif_tx_start_all_queues(sdata->dev);
|
|
|
|
netif_carrier_on(sdata->dev);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_sta_send_apinfo(sdata);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2009-03-12 21:04:34 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-02-15 19:44:28 +08:00
|
|
|
|
|
|
|
ifmgd->direct_probe_tries++;
|
|
|
|
if (ifmgd->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) {
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
|
|
|
ieee80211_sta_send_apinfo(sdata);
|
2009-02-04 20:58:48 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Most likely AP is not in the range so remove the
|
|
|
|
* bss information associated to the AP
|
|
|
|
*/
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_rx_bss_remove(sdata, ifmgd->bssid,
|
2009-02-04 20:58:48 +08:00
|
|
|
sdata->local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2009-03-12 21:04:34 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We might have a pending scan which had no chance to run yet
|
|
|
|
* due to state == IEEE80211_STA_MLME_DIRECT_PROBE.
|
|
|
|
* Hence, queue the STAs work again
|
|
|
|
*/
|
|
|
|
queue_work(local->hw.workqueue, &ifmgd->work);
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: direct probe to AP %pM try %d\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid,
|
|
|
|
ifmgd->direct_probe_tries);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
set_bit(IEEE80211_STA_REQ_DIRECT_PROBE, &ifmgd->request);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
|
|
|
/* Direct probe is sent to broadcast address as some APs
|
|
|
|
* will not answer to direct packet in unassociated state.
|
|
|
|
*/
|
|
|
|
ieee80211_send_probe_req(sdata, NULL,
|
2009-02-17 01:39:13 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len, NULL, 0);
|
2008-09-09 16:57:09 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
|
2008-09-08 23:44:22 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-09 16:57:09 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2009-03-12 21:04:34 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-03-19 19:39:22 +08:00
|
|
|
u8 *ies;
|
|
|
|
size_t ies_len;
|
2009-02-15 19:44:28 +08:00
|
|
|
|
|
|
|
ifmgd->auth_tries++;
|
|
|
|
if (ifmgd->auth_tries > IEEE80211_AUTH_MAX_TRIES) {
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: authentication with AP %pM"
|
2008-09-09 16:57:09 +08:00
|
|
|
" timed out\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
|
|
|
ieee80211_sta_send_apinfo(sdata);
|
|
|
|
ieee80211_rx_bss_remove(sdata, ifmgd->bssid,
|
2009-02-04 20:58:48 +08:00
|
|
|
sdata->local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2009-03-12 21:04:34 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We might have a pending scan which had no chance to run yet
|
|
|
|
* due to state == IEEE80211_STA_MLME_AUTHENTICATE.
|
|
|
|
* Hence, queue the STAs work again
|
|
|
|
*/
|
|
|
|
queue_work(local->hw.workqueue, &ifmgd->work);
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: authenticate with AP %pM\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_EXT_SME) {
|
|
|
|
ies = ifmgd->sme_auth_ie;
|
|
|
|
ies_len = ifmgd->sme_auth_ie_len;
|
|
|
|
} else {
|
|
|
|
ies = NULL;
|
|
|
|
ies_len = 0;
|
|
|
|
}
|
|
|
|
ieee80211_send_auth(sdata, 1, ifmgd->auth_alg, ies, ies_len,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->bssid, 0);
|
|
|
|
ifmgd->auth_transaction = 2;
|
2008-09-09 16:57:09 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-11-22 14:19:50 +08:00
|
|
|
/*
|
|
|
|
* The disassoc 'reason' argument can be either our own reason
|
|
|
|
* if self disconnected or a reason code from the AP.
|
|
|
|
*/
|
2008-09-09 05:32:12 +08:00
|
|
|
static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
|
2009-02-15 19:44:28 +08:00
|
|
|
bool deauth, bool self_disconnected,
|
|
|
|
u16 reason)
|
2008-09-09 05:32:12 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-09 05:32:12 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
struct sta_info *sta;
|
2008-12-19 05:35:13 +08:00
|
|
|
u32 changed = 0, config_changed = 0;
|
2008-09-09 05:32:12 +08:00
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_get(local, ifmgd->bssid);
|
2008-09-09 05:32:12 +08:00
|
|
|
if (!sta) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deauth) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->direct_probe_tries = 0;
|
|
|
|
ifmgd->auth_tries = 0;
|
2008-09-09 05:32:12 +08:00
|
|
|
}
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->assoc_scan_tries = 0;
|
|
|
|
ifmgd->assoc_tries = 0;
|
2008-09-09 05:32:12 +08:00
|
|
|
|
2008-09-08 23:33:40 +08:00
|
|
|
netif_tx_stop_all_queues(sdata->dev);
|
2008-09-09 05:32:12 +08:00
|
|
|
netif_carrier_off(sdata->dev);
|
|
|
|
|
2009-02-11 04:25:52 +08:00
|
|
|
ieee80211_sta_tear_down_BA_sessions(sta);
|
2008-09-09 05:32:12 +08:00
|
|
|
|
|
|
|
if (self_disconnected) {
|
|
|
|
if (deauth)
|
2008-09-09 16:58:25 +08:00
|
|
|
ieee80211_send_deauth_disassoc(sdata,
|
|
|
|
IEEE80211_STYPE_DEAUTH, reason);
|
2008-09-09 05:32:12 +08:00
|
|
|
else
|
2008-09-09 16:58:25 +08:00
|
|
|
ieee80211_send_deauth_disassoc(sdata,
|
|
|
|
IEEE80211_STYPE_DISASSOC, reason);
|
2008-09-09 05:32:12 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED;
|
2008-09-08 23:33:39 +08:00
|
|
|
changed |= ieee80211_reset_erp_info(sdata);
|
|
|
|
|
|
|
|
ieee80211_led_assoc(local, 0);
|
2008-10-14 22:58:37 +08:00
|
|
|
changed |= BSS_CHANGED_ASSOC;
|
|
|
|
sdata->vif.bss_conf.assoc = false;
|
2008-09-08 23:33:39 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_sta_send_apinfo(sdata);
|
2008-09-09 05:32:12 +08:00
|
|
|
|
2009-02-04 20:58:48 +08:00
|
|
|
if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
|
|
|
ieee80211_rx_bss_remove(sdata, ifmgd->bssid,
|
2009-02-04 20:58:48 +08:00
|
|
|
sdata->local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2009-02-04 20:58:48 +08:00
|
|
|
}
|
2008-09-09 05:32:12 +08:00
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
2009-01-07 17:13:27 +08:00
|
|
|
/* channel(_type) changes are handled by ieee80211_hw_config */
|
2008-12-12 14:27:43 +08:00
|
|
|
local->oper_channel_type = NL80211_CHAN_NO_HT;
|
2008-12-19 05:35:13 +08:00
|
|
|
|
2009-01-09 20:44:15 +08:00
|
|
|
local->power_constr_level = 0;
|
|
|
|
|
2008-12-19 05:35:27 +08:00
|
|
|
del_timer_sync(&local->dynamic_ps_timer);
|
|
|
|
cancel_work_sync(&local->dynamic_ps_enable_work);
|
|
|
|
|
2008-12-19 05:35:13 +08:00
|
|
|
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
|
|
|
|
local->hw.conf.flags &= ~IEEE80211_CONF_PS;
|
|
|
|
config_changed |= IEEE80211_CONF_CHANGE_PS;
|
|
|
|
}
|
2008-10-14 22:58:37 +08:00
|
|
|
|
2008-12-19 05:35:13 +08:00
|
|
|
ieee80211_hw_config(local, config_changed);
|
2008-10-14 22:58:37 +08:00
|
|
|
ieee80211_bss_info_change_notify(sdata, changed);
|
2008-11-25 19:05:44 +08:00
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_get(local, ifmgd->bssid);
|
2008-11-25 19:05:44 +08:00
|
|
|
if (!sta) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta_info_unlink(&sta);
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
sta_info_destroy(sta);
|
2008-09-09 05:32:12 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-09 16:57:09 +08:00
|
|
|
static int ieee80211_sta_wep_configured(struct ieee80211_sub_if_data *sdata)
|
|
|
|
{
|
|
|
|
if (!sdata || !sdata->default_key ||
|
|
|
|
sdata->default_key->conf.alg != ALG_WEP)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2008-09-11 06:01:55 +08:00
|
|
|
struct ieee80211_bss *bss;
|
2007-11-03 21:11:10 +08:00
|
|
|
int bss_privacy;
|
|
|
|
int wep_privacy;
|
|
|
|
int privacy_invoked;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-22 00:08:43 +08:00
|
|
|
if (!ifmgd || (ifmgd->flags & IEEE80211_STA_EXT_SME))
|
2007-05-06 02:45:53 +08:00
|
|
|
return 0;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
bss = ieee80211_rx_bss_get(local, ifmgd->bssid,
|
2008-01-25 02:38:38 +08:00
|
|
|
local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2007-05-06 02:45:53 +08:00
|
|
|
if (!bss)
|
|
|
|
return 0;
|
|
|
|
|
2009-02-11 04:26:00 +08:00
|
|
|
bss_privacy = !!(bss->cbss.capability & WLAN_CAPABILITY_PRIVACY);
|
2008-08-03 08:04:37 +08:00
|
|
|
wep_privacy = !!ieee80211_sta_wep_configured(sdata);
|
2009-02-15 19:44:28 +08:00
|
|
|
privacy_invoked = !!(ifmgd->flags & IEEE80211_STA_PRIVACY_INVOKED);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
mac80211: make master netdev handling sane
Currently, almost every interface type has a 'bss' pointer
pointing to BSS information. This BSS information, however,
is for a _local_ BSS, not for the BSS we joined, so having
it on a STA mode interface makes little sense, but now they
have it pointing to the master device, which is an AP mode
virtual interface. However, except for some bitrate control
data, this pointer is only used in AP/VLAN modes (for power
saving stations.)
Overall, it is not necessary to even have the master netdev
be a valid virtual interface, and it doesn't have to be on
the list of interfaces either.
This patch changes the master netdev to be special, it now
- no longer is on the list of virtual interfaces, which
lets me remove a lot of tests for that
- no longer has sub_if_data attached, since that isn't used
Additionally, this patch changes some vlan/ap mode handling
that is related to these 'bss' pointers described above (but
in the VLAN case they actually make sense because there they
point to the AP they belong to); it also adds some debugging
code to IEEE80211_DEV_TO_SUB_IF to validate it is not called
on the master netdev any more.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-09 20:40:34 +08:00
|
|
|
ieee80211_rx_bss_put(local, bss);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2007-11-03 21:11:10 +08:00
|
|
|
if ((bss_privacy == wep_privacy) || (bss_privacy == privacy_invoked))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_associate(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2009-03-12 21:04:34 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-02-15 19:44:28 +08:00
|
|
|
|
|
|
|
ifmgd->assoc_tries++;
|
|
|
|
if (ifmgd->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) {
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: association with AP %pM"
|
2007-05-06 02:45:53 +08:00
|
|
|
" timed out\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
|
|
|
ieee80211_sta_send_apinfo(sdata);
|
|
|
|
ieee80211_rx_bss_remove(sdata, ifmgd->bssid,
|
2009-02-04 20:58:48 +08:00
|
|
|
sdata->local->hw.conf.channel->center_freq,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, ifmgd->ssid_len);
|
2009-03-12 21:04:34 +08:00
|
|
|
/*
|
|
|
|
* We might have a pending scan which had no chance to run yet
|
|
|
|
* due to state == IEEE80211_STA_MLME_ASSOCIATE.
|
|
|
|
* Hence, queue the STAs work again
|
|
|
|
*/
|
|
|
|
queue_work(local->hw.workqueue, &ifmgd->work);
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE;
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: associate with AP %pM\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
if (ieee80211_privacy_mismatch(sdata)) {
|
2007-05-06 02:45:53 +08:00
|
|
|
printk(KERN_DEBUG "%s: mismatch in privacy configuration and "
|
2008-08-03 08:04:37 +08:00
|
|
|
"mixed-cell disabled - abort association\n", sdata->dev->name);
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_send_assoc(sdata);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
mod_timer(&ifmgd->timer, jiffies + IEEE80211_ASSOC_TIMEOUT);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-03-23 03:57:06 +08:00
|
|
|
void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
|
|
|
|
struct ieee80211_hdr *hdr)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* We can postpone the mgd.timer whenever receiving unicast frames
|
|
|
|
* from AP because we know that the connection is working both ways
|
|
|
|
* at that time. But multicast frames (and hence also beacons) must
|
|
|
|
* be ignored here, because we need to trigger the timer during
|
|
|
|
* data idle periods for sending the periodical probe request to
|
|
|
|
* the AP.
|
|
|
|
*/
|
|
|
|
if (!is_multicast_ether_addr(hdr->addr1))
|
|
|
|
mod_timer(&sdata->u.mgd.timer,
|
|
|
|
jiffies + IEEE80211_MONITORING_INTERVAL);
|
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_associated(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2007-05-06 02:45:53 +08:00
|
|
|
struct sta_info *sta;
|
2009-03-23 03:57:14 +08:00
|
|
|
bool disassoc = false;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
/* TODO: start monitoring current AP signal quality and number of
|
|
|
|
* missed beacons. Scan other channels every now and then and search
|
|
|
|
* for better APs. */
|
|
|
|
/* TODO: remove expired BSSes */
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_ASSOCIATED;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-02-25 23:27:46 +08:00
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_get(local, ifmgd->bssid);
|
2007-05-06 02:45:53 +08:00
|
|
|
if (!sta) {
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: No STA entry for own AP %pM\n",
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->dev->name, ifmgd->bssid);
|
2009-03-23 03:57:14 +08:00
|
|
|
disassoc = true;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) &&
|
|
|
|
time_after(jiffies, sta->last_rx + IEEE80211_MONITORING_INTERVAL)) {
|
|
|
|
printk(KERN_DEBUG "%s: no probe response from AP %pM "
|
|
|
|
"- disassociating\n",
|
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
disassoc = true;
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time_after(jiffies,
|
|
|
|
ifmgd->last_beacon + IEEE80211_MONITORING_INTERVAL)) {
|
|
|
|
printk(KERN_DEBUG "%s: beacon loss from AP %pM "
|
|
|
|
"- sending probe request\n",
|
|
|
|
sdata->dev->name, ifmgd->bssid);
|
|
|
|
ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL;
|
|
|
|
ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid,
|
|
|
|
ifmgd->ssid_len, NULL, 0);
|
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time_after(jiffies, sta->last_rx + IEEE80211_PROBE_IDLE_TIME)) {
|
|
|
|
ifmgd->flags |= IEEE80211_STA_PROBEREQ_POLL;
|
|
|
|
ieee80211_send_probe_req(sdata, ifmgd->bssid, ifmgd->ssid,
|
|
|
|
ifmgd->ssid_len, NULL, 0);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
2008-02-25 23:27:46 +08:00
|
|
|
|
2009-03-23 03:57:14 +08:00
|
|
|
unlock:
|
2008-02-25 23:27:46 +08:00
|
|
|
rcu_read_unlock();
|
|
|
|
|
2009-02-04 20:58:48 +08:00
|
|
|
if (disassoc)
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, true, true,
|
2008-09-08 23:44:22 +08:00
|
|
|
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
2009-02-04 20:58:48 +08:00
|
|
|
else
|
2009-02-15 19:44:28 +08:00
|
|
|
mod_timer(&ifmgd->timer, jiffies +
|
2008-09-08 23:44:22 +08:00
|
|
|
IEEE80211_MONITORING_INTERVAL);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name);
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags |= IEEE80211_STA_AUTHENTICATED;
|
2009-03-19 19:39:22 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_EXT_SME) {
|
|
|
|
/* Wait for SME to request association */
|
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
|
|
|
} else
|
|
|
|
ieee80211_associate(sdata);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len)
|
|
|
|
{
|
|
|
|
u8 *pos;
|
|
|
|
struct ieee802_11_elems elems;
|
|
|
|
|
|
|
|
pos = mgmt->u.auth.variable;
|
2007-10-13 04:40:37 +08:00
|
|
|
ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
|
2008-06-30 21:10:46 +08:00
|
|
|
if (!elems.challenge)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_send_auth(sdata, 3, sdata->u.mgd.auth_alg,
|
|
|
|
elems.challenge - 2, elems.challenge_len + 2,
|
|
|
|
sdata->u.mgd.bssid, 1);
|
|
|
|
sdata->u.mgd.auth_transaction = 4;
|
2009-02-11 04:26:03 +08:00
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
u16 auth_alg, auth_transaction, status_code;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2008-06-30 21:10:46 +08:00
|
|
|
if (len < 24 + 6)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg);
|
|
|
|
auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction);
|
|
|
|
status_code = le16_to_cpu(mgmt->u.auth.status_code);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (auth_alg != ifmgd->auth_alg ||
|
|
|
|
auth_transaction != ifmgd->auth_transaction)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (status_code != WLAN_STATUS_SUCCESS) {
|
|
|
|
if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) {
|
|
|
|
u8 algs[3];
|
|
|
|
const int num_algs = ARRAY_SIZE(algs);
|
|
|
|
int i, pos;
|
|
|
|
algs[0] = algs[1] = algs[2] = 0xff;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN)
|
2007-05-06 02:45:53 +08:00
|
|
|
algs[0] = WLAN_AUTH_OPEN;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
|
2007-05-06 02:45:53 +08:00
|
|
|
algs[1] = WLAN_AUTH_SHARED_KEY;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP)
|
2007-05-06 02:45:53 +08:00
|
|
|
algs[2] = WLAN_AUTH_LEAP;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->auth_alg == WLAN_AUTH_OPEN)
|
2007-05-06 02:45:53 +08:00
|
|
|
pos = 0;
|
2009-02-15 19:44:28 +08:00
|
|
|
else if (ifmgd->auth_alg == WLAN_AUTH_SHARED_KEY)
|
2007-05-06 02:45:53 +08:00
|
|
|
pos = 1;
|
|
|
|
else
|
|
|
|
pos = 2;
|
|
|
|
for (i = 0; i < num_algs; i++) {
|
|
|
|
pos++;
|
|
|
|
if (pos >= num_algs)
|
|
|
|
pos = 0;
|
2009-02-15 19:44:28 +08:00
|
|
|
if (algs[pos] == ifmgd->auth_alg ||
|
2007-05-06 02:45:53 +08:00
|
|
|
algs[pos] == 0xff)
|
|
|
|
continue;
|
|
|
|
if (algs[pos] == WLAN_AUTH_SHARED_KEY &&
|
2008-08-03 08:04:37 +08:00
|
|
|
!ieee80211_sta_wep_configured(sdata))
|
2007-05-06 02:45:53 +08:00
|
|
|
continue;
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->auth_alg = algs[pos];
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
switch (ifmgd->auth_alg) {
|
2007-05-06 02:45:53 +08:00
|
|
|
case WLAN_AUTH_OPEN:
|
|
|
|
case WLAN_AUTH_LEAP:
|
2009-03-19 19:39:22 +08:00
|
|
|
case WLAN_AUTH_FT:
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_auth_completed(sdata);
|
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 19:39:21 +08:00
|
|
|
cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len);
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
|
|
|
case WLAN_AUTH_SHARED_KEY:
|
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 19:39:21 +08:00
|
|
|
if (ifmgd->auth_transaction == 4) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_auth_completed(sdata);
|
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 19:39:21 +08:00
|
|
|
cfg80211_send_rx_auth(sdata->dev, (u8 *) mgmt, len);
|
|
|
|
} else
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_auth_challenge(sdata, mgmt, len);
|
2007-05-06 02:45:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
u16 reason_code;
|
|
|
|
|
2008-06-30 21:10:46 +08:00
|
|
|
if (len < 24 + 2)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN))
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
reason_code = le16_to_cpu(mgmt->u.deauth.reason_code);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_AUTHENTICATED)
|
2008-10-28 15:58:31 +08:00
|
|
|
printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n",
|
|
|
|
sdata->dev->name, reason_code);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) &&
|
|
|
|
(ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE ||
|
|
|
|
ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE ||
|
|
|
|
ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE;
|
|
|
|
mod_timer(&ifmgd->timer, jiffies +
|
2007-05-06 02:45:53 +08:00
|
|
|
IEEE80211_RETRY_AUTH_INTERVAL);
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, true, false, 0);
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED;
|
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 19:39:21 +08:00
|
|
|
cfg80211_send_rx_deauth(sdata->dev, (u8 *) mgmt, len);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
u16 reason_code;
|
|
|
|
|
2008-06-30 21:10:46 +08:00
|
|
|
if (len < 24 + 2)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN))
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_ASSOCIATED)
|
2008-10-28 15:58:31 +08:00
|
|
|
printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n",
|
|
|
|
sdata->dev->name, reason_code);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) &&
|
|
|
|
ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE;
|
|
|
|
mod_timer(&ifmgd->timer, jiffies +
|
2007-05-06 02:45:53 +08:00
|
|
|
IEEE80211_RETRY_AUTH_INTERVAL);
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, false, false, reason_code);
|
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 19:39:21 +08:00
|
|
|
cfg80211_send_rx_disassoc(sdata->dev, (u8 *) mgmt, len);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-28 21:32:58 +08:00
|
|
|
static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len,
|
|
|
|
int reassoc)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-12-28 21:32:58 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2008-01-25 02:38:38 +08:00
|
|
|
struct ieee80211_supported_band *sband;
|
2007-05-06 02:45:53 +08:00
|
|
|
struct sta_info *sta;
|
2009-01-21 22:13:48 +08:00
|
|
|
u32 rates, basic_rates;
|
2007-05-06 02:45:53 +08:00
|
|
|
u16 capab_info, status_code, aid;
|
|
|
|
struct ieee802_11_elems elems;
|
2008-10-11 07:51:51 +08:00
|
|
|
struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
|
2007-05-06 02:45:53 +08:00
|
|
|
u8 *pos;
|
2008-10-14 22:58:37 +08:00
|
|
|
u32 changed = 0;
|
2007-05-06 02:45:53 +08:00
|
|
|
int i, j;
|
2008-10-22 17:41:38 +08:00
|
|
|
bool have_higher_than_11mbit = false, newsta = false;
|
2008-10-14 22:58:37 +08:00
|
|
|
u16 ap_ht_cap_flags;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
/* AssocResp and ReassocResp have identical structure, so process both
|
|
|
|
* of them in this function. */
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2008-06-30 21:10:46 +08:00
|
|
|
if (len < 24 + 6)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info);
|
|
|
|
status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code);
|
|
|
|
aid = le16_to_cpu(mgmt->u.assoc_resp.aid);
|
|
|
|
|
2008-10-28 06:56:10 +08:00
|
|
|
printk(KERN_DEBUG "%s: RX %sssocResp from %pM (capab=0x%x "
|
2007-05-06 02:45:53 +08:00
|
|
|
"status=%d aid=%d)\n",
|
2008-10-28 06:56:10 +08:00
|
|
|
sdata->dev->name, reassoc ? "Rea" : "A", mgmt->sa,
|
2007-10-22 20:51:37 +08:00
|
|
|
capab_info, status_code, (u16)(aid & ~(BIT(15) | BIT(14))));
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-01-08 19:32:09 +08:00
|
|
|
pos = mgmt->u.assoc_resp.variable;
|
|
|
|
ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
|
|
|
|
|
|
|
|
if (status_code == WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY &&
|
2009-01-20 00:48:46 +08:00
|
|
|
elems.timeout_int && elems.timeout_int_len == 5 &&
|
|
|
|
elems.timeout_int[0] == WLAN_TIMEOUT_ASSOC_COMEBACK) {
|
2009-01-08 19:32:09 +08:00
|
|
|
u32 tu, ms;
|
2009-01-20 00:48:46 +08:00
|
|
|
tu = get_unaligned_le32(elems.timeout_int + 1);
|
2009-01-08 19:32:09 +08:00
|
|
|
ms = tu * 1024 / 1000;
|
|
|
|
printk(KERN_DEBUG "%s: AP rejected association temporarily; "
|
|
|
|
"comeback duration %u TU (%u ms)\n",
|
|
|
|
sdata->dev->name, tu, ms);
|
|
|
|
if (ms > IEEE80211_ASSOC_TIMEOUT)
|
2009-02-15 19:44:28 +08:00
|
|
|
mod_timer(&ifmgd->timer,
|
2009-01-08 19:32:09 +08:00
|
|
|
jiffies + msecs_to_jiffies(ms));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-06 02:45:53 +08:00
|
|
|
if (status_code != WLAN_STATUS_SUCCESS) {
|
|
|
|
printk(KERN_DEBUG "%s: AP denied association (code=%d)\n",
|
2008-08-03 08:04:37 +08:00
|
|
|
sdata->dev->name, status_code);
|
2007-07-27 21:43:23 +08:00
|
|
|
/* if this was a reassociation, ensure we try a "full"
|
|
|
|
* association next time. This works around some broken APs
|
|
|
|
* which do not correctly reject reassociation requests. */
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-10-10 18:03:41 +08:00
|
|
|
if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14)))
|
|
|
|
printk(KERN_DEBUG "%s: invalid aid value %d; bits 15:14 not "
|
2008-08-03 08:04:37 +08:00
|
|
|
"set\n", sdata->dev->name, aid);
|
2007-10-10 18:03:41 +08:00
|
|
|
aid &= ~(BIT(15) | BIT(14));
|
|
|
|
|
2007-05-06 02:45:53 +08:00
|
|
|
if (!elems.supp_rates) {
|
|
|
|
printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
|
2008-08-03 08:04:37 +08:00
|
|
|
sdata->dev->name);
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
printk(KERN_DEBUG "%s: associated\n", sdata->dev->name);
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->aid = aid;
|
|
|
|
ifmgd->ap_capab = capab_info;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
kfree(ifmgd->assocresp_ies);
|
|
|
|
ifmgd->assocresp_ies_len = len - (pos - (u8 *) mgmt);
|
|
|
|
ifmgd->assocresp_ies = kmalloc(ifmgd->assocresp_ies_len, GFP_KERNEL);
|
|
|
|
if (ifmgd->assocresp_ies)
|
|
|
|
memcpy(ifmgd->assocresp_ies, pos, ifmgd->assocresp_ies_len);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-02-25 23:27:46 +08:00
|
|
|
rcu_read_lock();
|
|
|
|
|
2007-05-06 02:45:53 +08:00
|
|
|
/* Add STA entry for the AP */
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_get(local, ifmgd->bssid);
|
2007-05-06 02:45:53 +08:00
|
|
|
if (!sta) {
|
2008-10-22 17:41:38 +08:00
|
|
|
newsta = true;
|
2008-02-25 23:27:46 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_alloc(sdata, ifmgd->bssid, GFP_ATOMIC);
|
2008-02-25 23:27:47 +08:00
|
|
|
if (!sta) {
|
|
|
|
printk(KERN_DEBUG "%s: failed to alloc STA entry for"
|
2008-08-03 08:04:37 +08:00
|
|
|
" the AP\n", sdata->dev->name);
|
2008-02-25 23:27:46 +08:00
|
|
|
rcu_read_unlock();
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
}
|
2008-02-23 22:17:12 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
/* update new sta with its last rx activity */
|
|
|
|
sta->last_rx = jiffies;
|
2008-02-23 22:17:12 +08:00
|
|
|
}
|
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
/*
|
|
|
|
* FIXME: Do we really need to update the sta_info's information here?
|
|
|
|
* We already know about the AP (we found it in our list) so it
|
|
|
|
* should already be filled with the right info, no?
|
|
|
|
* As is stands, all this is racy because typically we assume
|
|
|
|
* the information that is filled in here (except flags) doesn't
|
|
|
|
* change while a STA structure is alive. As such, it should move
|
|
|
|
* to between the sta_info_alloc() and sta_info_insert() above.
|
|
|
|
*/
|
2008-02-23 22:17:12 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
set_sta_flags(sta, WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_AP |
|
|
|
|
WLAN_STA_AUTHORIZED);
|
2008-04-01 07:00:13 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
rates = 0;
|
|
|
|
basic_rates = 0;
|
|
|
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
2008-02-23 22:17:12 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
for (i = 0; i < elems.supp_rates_len; i++) {
|
|
|
|
int rate = (elems.supp_rates[i] & 0x7f) * 5;
|
2008-10-30 23:08:08 +08:00
|
|
|
bool is_basic = !!(elems.supp_rates[i] & 0x80);
|
2008-02-23 22:17:12 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
if (rate > 110)
|
|
|
|
have_higher_than_11mbit = true;
|
|
|
|
|
|
|
|
for (j = 0; j < sband->n_bitrates; j++) {
|
2008-10-30 23:08:08 +08:00
|
|
|
if (sband->bitrates[j].bitrate == rate) {
|
2008-09-08 23:44:22 +08:00
|
|
|
rates |= BIT(j);
|
2008-10-30 23:08:08 +08:00
|
|
|
if (is_basic)
|
|
|
|
basic_rates |= BIT(j);
|
|
|
|
break;
|
|
|
|
}
|
2008-02-23 22:17:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
for (i = 0; i < elems.ext_supp_rates_len; i++) {
|
|
|
|
int rate = (elems.ext_supp_rates[i] & 0x7f) * 5;
|
2008-10-30 23:08:08 +08:00
|
|
|
bool is_basic = !!(elems.supp_rates[i] & 0x80);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
if (rate > 110)
|
|
|
|
have_higher_than_11mbit = true;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
for (j = 0; j < sband->n_bitrates; j++) {
|
2008-10-30 23:08:08 +08:00
|
|
|
if (sband->bitrates[j].bitrate == rate) {
|
2008-09-08 23:44:22 +08:00
|
|
|
rates |= BIT(j);
|
2008-10-30 23:08:08 +08:00
|
|
|
if (is_basic)
|
|
|
|
basic_rates |= BIT(j);
|
|
|
|
break;
|
|
|
|
}
|
2008-09-08 23:44:22 +08:00
|
|
|
}
|
2008-04-23 15:47:15 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 08:45:11 +08:00
|
|
|
sta->sta.supp_rates[local->hw.conf.channel->band] = rates;
|
2008-10-11 07:51:51 +08:00
|
|
|
sdata->vif.bss_conf.basic_rates = basic_rates;
|
2008-09-08 23:44:22 +08:00
|
|
|
|
|
|
|
/* cf. IEEE 802.11 9.2.12 */
|
|
|
|
if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
|
|
|
|
have_higher_than_11mbit)
|
|
|
|
sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
|
|
|
|
else
|
|
|
|
sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-02 15:58:31 +08:00
|
|
|
/* If TKIP/WEP is used, no need to parse AP's HT capabilities */
|
|
|
|
if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))
|
2008-10-14 22:58:37 +08:00
|
|
|
ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
|
2008-10-09 18:13:49 +08:00
|
|
|
elems.ht_cap_elem, &sta->sta.ht_cap);
|
2008-10-14 22:58:37 +08:00
|
|
|
|
|
|
|
ap_ht_cap_flags = sta->sta.ht_cap.cap;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-19 00:14:18 +08:00
|
|
|
rate_control_rate_init(sta);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED)
|
2009-01-08 19:31:59 +08:00
|
|
|
set_sta_flags(sta, WLAN_STA_MFP);
|
|
|
|
|
2008-10-22 17:41:38 +08:00
|
|
|
if (elems.wmm_param)
|
2008-09-08 23:44:22 +08:00
|
|
|
set_sta_flags(sta, WLAN_STA_WME);
|
2008-10-22 17:41:38 +08:00
|
|
|
|
|
|
|
if (newsta) {
|
|
|
|
int err = sta_info_insert(sta);
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_DEBUG "%s: failed to insert STA entry for"
|
|
|
|
" the AP (error %d)\n", sdata->dev->name, err);
|
|
|
|
rcu_read_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
if (elems.wmm_param)
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param,
|
2008-09-08 23:44:22 +08:00
|
|
|
elems.wmm_param_len);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-10-14 22:58:37 +08:00
|
|
|
if (elems.ht_info_elem && elems.wmm_param &&
|
2009-02-15 19:44:28 +08:00
|
|
|
(ifmgd->flags & IEEE80211_STA_WMM_ENABLED) &&
|
|
|
|
!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))
|
2008-10-14 22:58:37 +08:00
|
|
|
changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
|
|
|
|
ap_ht_cap_flags);
|
|
|
|
|
2008-09-08 23:44:22 +08:00
|
|
|
/* set AID and assoc capability,
|
|
|
|
* ieee80211_set_associated() will tell the driver */
|
|
|
|
bss_conf->aid = aid;
|
|
|
|
bss_conf->assoc_capability = capab_info;
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_associated(sdata, changed);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-03-23 03:57:14 +08:00
|
|
|
/*
|
|
|
|
* initialise the time of last beacon to be the association time,
|
|
|
|
* otherwise beacon loss check will trigger immediately
|
|
|
|
*/
|
|
|
|
ifmgd->last_beacon = jiffies;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_associated(sdata);
|
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 19:39:21 +08:00
|
|
|
cfg80211_send_rx_assoc(sdata->dev, (u8 *) mgmt, len);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-08 23:44:26 +08:00
|
|
|
static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
|
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len,
|
|
|
|
struct ieee80211_rx_status *rx_status,
|
|
|
|
struct ieee802_11_elems *elems,
|
|
|
|
bool beacon)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
int freq;
|
2008-09-11 06:01:55 +08:00
|
|
|
struct ieee80211_bss *bss;
|
2008-09-08 23:44:26 +08:00
|
|
|
struct ieee80211_channel *channel;
|
|
|
|
|
|
|
|
if (elems->ds_params && elems->ds_params_len == 1)
|
|
|
|
freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
|
|
|
|
else
|
|
|
|
freq = rx_status->freq;
|
|
|
|
|
|
|
|
channel = ieee80211_get_channel(local->hw.wiphy, freq);
|
|
|
|
|
|
|
|
if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
|
2009-02-11 04:25:55 +08:00
|
|
|
channel, beacon);
|
2008-09-08 23:44:26 +08:00
|
|
|
if (!bss)
|
|
|
|
return;
|
|
|
|
|
2009-01-06 11:58:37 +08:00
|
|
|
if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) &&
|
2009-02-15 19:44:28 +08:00
|
|
|
(memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN) == 0)) {
|
2009-01-06 11:58:37 +08:00
|
|
|
struct ieee80211_channel_sw_ie *sw_elem =
|
|
|
|
(struct ieee80211_channel_sw_ie *)elems->ch_switch_elem;
|
|
|
|
ieee80211_process_chanswitch(sdata, sw_elem, bss);
|
|
|
|
}
|
|
|
|
|
mac80211: make master netdev handling sane
Currently, almost every interface type has a 'bss' pointer
pointing to BSS information. This BSS information, however,
is for a _local_ BSS, not for the BSS we joined, so having
it on a STA mode interface makes little sense, but now they
have it pointing to the master device, which is an AP mode
virtual interface. However, except for some bitrate control
data, this pointer is only used in AP/VLAN modes (for power
saving stations.)
Overall, it is not necessary to even have the master netdev
be a valid virtual interface, and it doesn't have to be on
the list of interfaces either.
This patch changes the master netdev to be special, it now
- no longer is on the list of virtual interfaces, which
lets me remove a lot of tests for that
- no longer has sub_if_data attached, since that isn't used
Additionally, this patch changes some vlan/ap mode handling
that is related to these 'bss' pointers described above (but
in the VLAN case they actually make sense because there they
point to the AP they belong to); it also adds some debugging
code to IEEE80211_DEV_TO_SUB_IF to validate it is not called
on the master netdev any more.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-07-09 20:40:34 +08:00
|
|
|
ieee80211_rx_bss_put(local, bss);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len,
|
|
|
|
struct ieee80211_rx_status *rx_status)
|
|
|
|
{
|
2009-03-23 03:57:14 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd;
|
2008-06-27 23:54:48 +08:00
|
|
|
size_t baselen;
|
|
|
|
struct ieee802_11_elems elems;
|
|
|
|
|
2009-03-23 03:57:14 +08:00
|
|
|
ifmgd = &sdata->u.mgd;
|
|
|
|
|
2008-08-03 19:32:01 +08:00
|
|
|
if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN))
|
|
|
|
return; /* ignore ProbeResp to foreign address */
|
|
|
|
|
2008-06-27 23:54:48 +08:00
|
|
|
baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
|
|
|
|
if (baselen > len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
|
|
|
|
&elems);
|
|
|
|
|
2008-09-08 23:44:26 +08:00
|
|
|
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false);
|
2008-08-09 08:02:19 +08:00
|
|
|
|
|
|
|
/* direct probe may be part of the association flow */
|
|
|
|
if (test_and_clear_bit(IEEE80211_STA_REQ_DIRECT_PROBE,
|
2009-03-23 03:57:14 +08:00
|
|
|
&ifmgd->request)) {
|
2008-08-09 08:02:19 +08:00
|
|
|
printk(KERN_DEBUG "%s direct probe responded\n",
|
|
|
|
sdata->dev->name);
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_authenticate(sdata);
|
2008-08-09 08:02:19 +08:00
|
|
|
}
|
2009-03-23 03:57:14 +08:00
|
|
|
|
|
|
|
if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL)
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt,
|
|
|
|
size_t len,
|
|
|
|
struct ieee80211_rx_status *rx_status)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
size_t baselen;
|
|
|
|
struct ieee802_11_elems elems;
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2007-12-28 21:32:58 +08:00
|
|
|
u32 changed = 0;
|
2009-02-10 23:09:24 +08:00
|
|
|
bool erp_valid, directed_tim;
|
2008-10-08 16:59:33 +08:00
|
|
|
u8 erp_value = 0;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-06-27 23:54:48 +08:00
|
|
|
/* Process beacon from the current BSS */
|
|
|
|
baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
|
|
|
|
if (baselen > len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
|
|
|
|
|
2008-09-08 23:44:26 +08:00
|
|
|
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, true);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 06:01:58 +08:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd = &sdata->u.mgd;
|
|
|
|
|
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED) ||
|
|
|
|
memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0)
|
2007-05-06 02:45:53 +08:00
|
|
|
return;
|
|
|
|
|
2009-01-06 11:58:37 +08:00
|
|
|
if (rx_status->freq != local->hw.conf.channel->center_freq)
|
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param,
|
2008-09-08 17:05:09 +08:00
|
|
|
elems.wmm_param_len);
|
|
|
|
|
2009-03-02 22:50:30 +08:00
|
|
|
if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) {
|
2009-02-15 19:44:28 +08:00
|
|
|
directed_tim = ieee80211_check_tim(&elems, ifmgd->aid);
|
2008-12-24 10:39:02 +08:00
|
|
|
|
2009-02-10 23:09:24 +08:00
|
|
|
if (directed_tim) {
|
2009-02-10 23:09:31 +08:00
|
|
|
if (local->hw.conf.dynamic_ps_timeout > 0) {
|
|
|
|
local->hw.conf.flags &= ~IEEE80211_CONF_PS;
|
|
|
|
ieee80211_hw_config(local,
|
|
|
|
IEEE80211_CONF_CHANGE_PS);
|
|
|
|
ieee80211_send_nullfunc(local, sdata, 0);
|
|
|
|
} else {
|
|
|
|
local->pspolling = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here is assumed that the driver will be
|
|
|
|
* able to send ps-poll frame and receive a
|
|
|
|
* response even though power save mode is
|
|
|
|
* enabled, but some drivers might require
|
|
|
|
* to disable power save here. This needs
|
|
|
|
* to be investigated.
|
|
|
|
*/
|
|
|
|
ieee80211_send_pspoll(local, sdata);
|
|
|
|
}
|
2008-12-24 10:39:02 +08:00
|
|
|
}
|
|
|
|
}
|
2008-10-08 16:59:33 +08:00
|
|
|
|
|
|
|
if (elems.erp_info && elems.erp_info_len >= 1) {
|
|
|
|
erp_valid = true;
|
|
|
|
erp_value = elems.erp_info[0];
|
|
|
|
} else {
|
|
|
|
erp_valid = false;
|
2008-04-16 02:09:27 +08:00
|
|
|
}
|
2008-10-08 16:59:33 +08:00
|
|
|
changed |= ieee80211_handle_bss_capability(sdata,
|
|
|
|
le16_to_cpu(mgmt->u.beacon.capab_info),
|
|
|
|
erp_valid, erp_value);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2007-11-26 22:14:34 +08:00
|
|
|
|
2009-02-12 00:48:49 +08:00
|
|
|
if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param &&
|
2009-02-15 19:44:28 +08:00
|
|
|
!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) {
|
2008-10-14 22:58:37 +08:00
|
|
|
struct sta_info *sta;
|
|
|
|
struct ieee80211_supported_band *sband;
|
|
|
|
u16 ap_ht_cap_flags;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
sta = sta_info_get(local, ifmgd->bssid);
|
2008-10-14 22:58:37 +08:00
|
|
|
if (!sta) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
|
|
|
|
|
|
|
ieee80211_ht_cap_ie_to_sta_ht_cap(sband,
|
|
|
|
elems.ht_cap_elem, &sta->sta.ht_cap);
|
|
|
|
|
|
|
|
ap_ht_cap_flags = sta->sta.ht_cap.cap;
|
|
|
|
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem,
|
|
|
|
ap_ht_cap_flags);
|
2007-11-26 22:14:34 +08:00
|
|
|
}
|
|
|
|
|
2008-11-13 06:22:02 +08:00
|
|
|
if (elems.country_elem) {
|
|
|
|
/* Note we are only reviewing this on beacons
|
|
|
|
* for the BSSID we are associated to */
|
|
|
|
regulatory_hint_11d(local->hw.wiphy,
|
|
|
|
elems.country_elem, elems.country_elem_len);
|
2009-01-09 20:44:15 +08:00
|
|
|
|
|
|
|
/* TODO: IBSS also needs this */
|
|
|
|
if (elems.pwr_constr_elem)
|
|
|
|
ieee80211_handle_pwr_constr(sdata,
|
|
|
|
le16_to_cpu(mgmt->u.probe_resp.capab_info),
|
|
|
|
elems.pwr_constr_elem,
|
|
|
|
elems.pwr_constr_elem_len);
|
2008-11-13 06:22:02 +08:00
|
|
|
}
|
|
|
|
|
2007-12-28 21:32:58 +08:00
|
|
|
ieee80211_bss_info_change_notify(sdata, changed);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata,
|
|
|
|
struct sk_buff *skb,
|
|
|
|
struct ieee80211_rx_status *rx_status)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2007-05-06 02:45:53 +08:00
|
|
|
struct ieee80211_mgmt *mgmt;
|
|
|
|
u16 fc;
|
|
|
|
|
|
|
|
if (skb->len < 24)
|
2009-02-15 19:44:28 +08:00
|
|
|
return RX_DROP_MONITOR;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
mgmt = (struct ieee80211_mgmt *) skb->data;
|
|
|
|
fc = le16_to_cpu(mgmt->frame_control);
|
|
|
|
|
|
|
|
switch (fc & IEEE80211_FCTL_STYPE) {
|
|
|
|
case IEEE80211_STYPE_PROBE_REQ:
|
|
|
|
case IEEE80211_STYPE_PROBE_RESP:
|
|
|
|
case IEEE80211_STYPE_BEACON:
|
|
|
|
memcpy(skb->cb, rx_status, sizeof(*rx_status));
|
|
|
|
case IEEE80211_STYPE_AUTH:
|
|
|
|
case IEEE80211_STYPE_ASSOC_RESP:
|
|
|
|
case IEEE80211_STYPE_REASSOC_RESP:
|
|
|
|
case IEEE80211_STYPE_DEAUTH:
|
|
|
|
case IEEE80211_STYPE_DISASSOC:
|
2009-02-15 19:44:28 +08:00
|
|
|
skb_queue_tail(&sdata->u.mgd.skb_queue, skb);
|
|
|
|
queue_work(local->hw.workqueue, &sdata->u.mgd.work);
|
|
|
|
return RX_QUEUED;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
return RX_DROP_MONITOR;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
|
2007-05-06 02:45:53 +08:00
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct ieee80211_rx_status *rx_status;
|
|
|
|
struct ieee80211_mgmt *mgmt;
|
|
|
|
u16 fc;
|
|
|
|
|
|
|
|
rx_status = (struct ieee80211_rx_status *) skb->cb;
|
|
|
|
mgmt = (struct ieee80211_mgmt *) skb->data;
|
|
|
|
fc = le16_to_cpu(mgmt->frame_control);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
switch (fc & IEEE80211_FCTL_STYPE) {
|
|
|
|
case IEEE80211_STYPE_PROBE_RESP:
|
|
|
|
ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
|
|
|
|
rx_status);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_BEACON:
|
|
|
|
ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
|
|
|
|
rx_status);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_AUTH:
|
|
|
|
ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_ASSOC_RESP:
|
|
|
|
ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 0);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_REASSOC_RESP:
|
|
|
|
ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 1);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_DEAUTH:
|
|
|
|
ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len);
|
|
|
|
break;
|
|
|
|
case IEEE80211_STYPE_DISASSOC:
|
|
|
|
ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len);
|
|
|
|
break;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
static void ieee80211_sta_timer(unsigned long data)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2008-09-08 23:44:22 +08:00
|
|
|
struct ieee80211_sub_if_data *sdata =
|
|
|
|
(struct ieee80211_sub_if_data *) data;
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-08 23:44:22 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request);
|
|
|
|
queue_work(local->hw.workqueue, &ifmgd->work);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
if (local->ops->reset_tsf) {
|
|
|
|
/* Reset own TSF to allow time synchronization work. */
|
|
|
|
local->ops->reset_tsf(local_to_hw(local));
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->wmm_last_param_set = -1; /* allow any WMM update */
|
2007-05-06 02:45:53 +08:00
|
|
|
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN)
|
|
|
|
ifmgd->auth_alg = WLAN_AUTH_OPEN;
|
|
|
|
else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY)
|
|
|
|
ifmgd->auth_alg = WLAN_AUTH_SHARED_KEY;
|
|
|
|
else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP)
|
|
|
|
ifmgd->auth_alg = WLAN_AUTH_LEAP;
|
2009-03-19 19:39:22 +08:00
|
|
|
else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_FT)
|
|
|
|
ifmgd->auth_alg = WLAN_AUTH_FT;
|
2007-05-06 02:45:53 +08:00
|
|
|
else
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->auth_alg = WLAN_AUTH_OPEN;
|
|
|
|
ifmgd->auth_transaction = -1;
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED;
|
|
|
|
ifmgd->assoc_scan_tries = 0;
|
|
|
|
ifmgd->direct_probe_tries = 0;
|
|
|
|
ifmgd->auth_tries = 0;
|
|
|
|
ifmgd->assoc_tries = 0;
|
2008-09-08 23:33:40 +08:00
|
|
|
netif_tx_stop_all_queues(sdata->dev);
|
2008-08-03 08:04:37 +08:00
|
|
|
netif_carrier_off(sdata->dev);
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-08-03 08:04:37 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2008-09-11 06:01:55 +08:00
|
|
|
struct ieee80211_bss *bss;
|
2009-02-15 19:44:28 +08:00
|
|
|
u8 *bssid = ifmgd->bssid, *ssid = ifmgd->ssid;
|
|
|
|
u8 ssid_len = ifmgd->ssid_len;
|
2009-02-11 04:26:00 +08:00
|
|
|
u16 capa_mask = WLAN_CAPABILITY_ESS;
|
|
|
|
u16 capa_val = WLAN_CAPABILITY_ESS;
|
|
|
|
struct ieee80211_channel *chan = local->oper_channel;
|
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) &&
|
|
|
|
ifmgd->flags & (IEEE80211_STA_AUTO_SSID_SEL |
|
2009-02-11 04:26:00 +08:00
|
|
|
IEEE80211_STA_AUTO_BSSID_SEL |
|
|
|
|
IEEE80211_STA_AUTO_CHANNEL_SEL)) {
|
|
|
|
capa_mask |= WLAN_CAPABILITY_PRIVACY;
|
|
|
|
if (sdata->default_key)
|
|
|
|
capa_val |= WLAN_CAPABILITY_PRIVACY;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
2008-07-09 20:40:37 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_AUTO_CHANNEL_SEL)
|
2009-02-11 04:26:00 +08:00
|
|
|
chan = NULL;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_AUTO_BSSID_SEL)
|
2009-02-11 04:26:00 +08:00
|
|
|
bssid = NULL;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL) {
|
2009-02-11 04:26:00 +08:00
|
|
|
ssid = NULL;
|
|
|
|
ssid_len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan,
|
|
|
|
bssid, ssid, ssid_len,
|
|
|
|
capa_mask, capa_val);
|
|
|
|
|
|
|
|
if (bss) {
|
|
|
|
ieee80211_set_freq(sdata, bss->cbss.channel->center_freq);
|
2009-02-15 19:44:28 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_SSID_SET))
|
2009-02-11 04:26:00 +08:00
|
|
|
ieee80211_sta_set_ssid(sdata, bss->ssid,
|
|
|
|
bss->ssid_len);
|
|
|
|
ieee80211_sta_set_bssid(sdata, bss->cbss.bssid);
|
|
|
|
ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len,
|
|
|
|
bss->supp_rates);
|
2009-02-15 19:44:28 +08:00
|
|
|
if (sdata->u.mgd.mfp == IEEE80211_MFP_REQUIRED)
|
|
|
|
sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED;
|
2009-01-08 19:32:05 +08:00
|
|
|
else
|
2009-02-15 19:44:28 +08:00
|
|
|
sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
/* Send out direct probe if no probe resp was received or
|
|
|
|
* the one we have is outdated
|
|
|
|
*/
|
2009-02-11 04:26:00 +08:00
|
|
|
if (!bss->last_probe_resp ||
|
|
|
|
time_after(jiffies, bss->last_probe_resp
|
2008-09-11 06:01:52 +08:00
|
|
|
+ IEEE80211_SCAN_RESULT_EXPIRE))
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE;
|
2008-09-11 06:01:52 +08:00
|
|
|
else
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-11 04:26:00 +08:00
|
|
|
ieee80211_rx_bss_put(local, bss);
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_sta_reset_auth(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
return 0;
|
|
|
|
} else {
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) {
|
|
|
|
ifmgd->assoc_scan_tries++;
|
2009-02-11 04:25:55 +08:00
|
|
|
/* XXX maybe racy? */
|
|
|
|
if (local->scan_req)
|
|
|
|
return -1;
|
|
|
|
memcpy(local->int_scan_req.ssids[0].ssid,
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->ssid, IEEE80211_MAX_SSID_LEN);
|
|
|
|
if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL)
|
2009-02-11 04:25:55 +08:00
|
|
|
local->int_scan_req.ssids[0].ssid_len = 0;
|
2008-09-11 06:01:52 +08:00
|
|
|
else
|
2009-02-15 19:44:28 +08:00
|
|
|
local->int_scan_req.ssids[0].ssid_len = ifmgd->ssid_len;
|
2009-03-09 22:47:08 +08:00
|
|
|
|
|
|
|
if (ieee80211_start_scan(sdata, &local->int_scan_req))
|
|
|
|
ieee80211_scan_failed(local);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE;
|
|
|
|
set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request);
|
2009-01-29 12:04:22 +08:00
|
|
|
} else {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->assoc_scan_tries = 0;
|
|
|
|
ifmgd->state = IEEE80211_STA_MLME_DISABLED;
|
2009-01-29 12:04:22 +08:00
|
|
|
}
|
2008-09-11 06:01:52 +08:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ieee80211_sta_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata =
|
2009-02-15 19:44:28 +08:00
|
|
|
container_of(work, struct ieee80211_sub_if_data, u.mgd.work);
|
2008-09-11 06:01:52 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd;
|
2008-09-11 06:01:52 +08:00
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
if (!netif_running(sdata->dev))
|
|
|
|
return;
|
|
|
|
|
2008-09-11 06:01:55 +08:00
|
|
|
if (local->sw_scanning || local->hw_scanning)
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd = &sdata->u.mgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
while ((skb = skb_dequeue(&ifmgd->skb_queue)))
|
2008-09-11 06:01:52 +08:00
|
|
|
ieee80211_sta_rx_queued_mgmt(sdata, skb);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->state != IEEE80211_STA_MLME_DIRECT_PROBE &&
|
|
|
|
ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE &&
|
|
|
|
ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE &&
|
|
|
|
test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) {
|
2009-03-09 22:47:08 +08:00
|
|
|
/*
|
|
|
|
* The call to ieee80211_start_scan can fail but ieee80211_request_scan
|
|
|
|
* (which queued ieee80211_sta_work) did not return an error. Thus, call
|
|
|
|
* ieee80211_scan_failed here if ieee80211_start_scan fails in order to
|
|
|
|
* notify the scan requester.
|
|
|
|
*/
|
|
|
|
if (ieee80211_start_scan(sdata, local->scan_req))
|
|
|
|
ieee80211_scan_failed(local);
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request)) {
|
|
|
|
if (ieee80211_sta_config_auth(sdata))
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
2009-02-15 19:44:28 +08:00
|
|
|
clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request);
|
|
|
|
} else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request))
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
2007-08-29 05:01:54 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
switch (ifmgd->state) {
|
2008-09-11 06:01:52 +08:00
|
|
|
case IEEE80211_STA_MLME_DISABLED:
|
|
|
|
break;
|
|
|
|
case IEEE80211_STA_MLME_DIRECT_PROBE:
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_direct_probe(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
break;
|
|
|
|
case IEEE80211_STA_MLME_AUTHENTICATE:
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_authenticate(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
break;
|
|
|
|
case IEEE80211_STA_MLME_ASSOCIATE:
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_associate(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
break;
|
|
|
|
case IEEE80211_STA_MLME_ASSOCIATED:
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_associated(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN_ON(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ieee80211_privacy_mismatch(sdata)) {
|
2008-09-11 06:01:52 +08:00
|
|
|
printk(KERN_DEBUG "%s: privacy configuration mismatch and "
|
|
|
|
"mixed-cell disabled - disassociate\n", sdata->dev->name);
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, false, true,
|
2008-09-11 06:01:52 +08:00
|
|
|
WLAN_REASON_UNSPECIFIED);
|
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
static void ieee80211_restart_sta_timer(struct ieee80211_sub_if_data *sdata)
|
|
|
|
{
|
2008-09-11 06:01:58 +08:00
|
|
|
if (sdata->vif.type == NL80211_IFTYPE_STATION)
|
2008-09-11 06:01:52 +08:00
|
|
|
queue_work(sdata->local->hw.workqueue,
|
2009-02-15 19:44:28 +08:00
|
|
|
&sdata->u.mgd.work);
|
2008-09-11 06:01:52 +08:00
|
|
|
}
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
/* interface setup */
|
|
|
|
void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd;
|
2008-04-18 01:21:22 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd = &sdata->u.mgd;
|
|
|
|
INIT_WORK(&ifmgd->work, ieee80211_sta_work);
|
|
|
|
INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work);
|
|
|
|
setup_timer(&ifmgd->timer, ieee80211_sta_timer,
|
2009-01-06 11:58:37 +08:00
|
|
|
(unsigned long) sdata);
|
2009-02-15 19:44:28 +08:00
|
|
|
setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer,
|
2008-09-11 06:01:52 +08:00
|
|
|
(unsigned long) sdata);
|
2009-02-15 19:44:28 +08:00
|
|
|
skb_queue_head_init(&ifmgd->skb_queue);
|
2008-09-11 06:01:52 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->capab = WLAN_CAPABILITY_ESS;
|
|
|
|
ifmgd->auth_algs = IEEE80211_AUTH_ALG_OPEN |
|
2008-09-11 06:01:52 +08:00
|
|
|
IEEE80211_AUTH_ALG_SHARED_KEY;
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags |= IEEE80211_STA_CREATE_IBSS |
|
2008-09-11 06:01:52 +08:00
|
|
|
IEEE80211_STA_AUTO_BSSID_SEL |
|
|
|
|
IEEE80211_STA_AUTO_CHANNEL_SEL;
|
2009-03-13 06:49:28 +08:00
|
|
|
if (sdata->local->hw.queues >= 4)
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->flags |= IEEE80211_STA_WMM_ENABLED;
|
2007-05-06 02:45:53 +08:00
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
/* configuration hooks */
|
2009-02-15 19:44:28 +08:00
|
|
|
void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata)
|
2008-09-08 23:44:22 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-08 23:44:22 +08:00
|
|
|
struct ieee80211_local *local = sdata->local;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
|
2008-09-11 06:01:52 +08:00
|
|
|
return;
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if ((ifmgd->flags & (IEEE80211_STA_BSSID_SET |
|
2008-09-11 06:01:52 +08:00
|
|
|
IEEE80211_STA_AUTO_BSSID_SEL)) &&
|
2009-02-15 19:44:28 +08:00
|
|
|
(ifmgd->flags & (IEEE80211_STA_SSID_SET |
|
2008-09-11 06:01:52 +08:00
|
|
|
IEEE80211_STA_AUTO_SSID_SEL))) {
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED)
|
|
|
|
ieee80211_set_disassoc(sdata, true, true,
|
2008-09-11 06:01:52 +08:00
|
|
|
WLAN_REASON_DEAUTH_LEAVING);
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) ||
|
|
|
|
ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE)
|
|
|
|
set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request);
|
|
|
|
else if (ifmgd->flags & IEEE80211_STA_EXT_SME)
|
|
|
|
set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request);
|
2009-02-15 19:44:28 +08:00
|
|
|
queue_work(local->hw.workqueue, &ifmgd->work);
|
2008-09-11 06:01:52 +08:00
|
|
|
}
|
|
|
|
}
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2009-02-21 08:27:29 +08:00
|
|
|
int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata)
|
|
|
|
{
|
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
|
|
|
|
|
|
|
if (ifmgd->ssid_len)
|
|
|
|
ifmgd->flags |= IEEE80211_STA_SSID_SET;
|
|
|
|
else
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_SSID_SET;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd;
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
if (len > IEEE80211_MAX_SSID_LEN)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd = &sdata->u.mgd;
|
2008-09-11 06:01:52 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) {
|
2009-03-19 19:39:20 +08:00
|
|
|
/*
|
|
|
|
* Do not use reassociation if SSID is changed (different ESS).
|
|
|
|
*/
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET;
|
2009-02-15 19:44:28 +08:00
|
|
|
memset(ifmgd->ssid, 0, sizeof(ifmgd->ssid));
|
|
|
|
memcpy(ifmgd->ssid, ssid, len);
|
|
|
|
ifmgd->ssid_len = len;
|
2008-09-08 23:44:22 +08:00
|
|
|
}
|
|
|
|
|
2009-02-21 08:27:29 +08:00
|
|
|
return ieee80211_sta_commit(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
|
|
|
memcpy(ssid, ifmgd->ssid, ifmgd->ssid_len);
|
|
|
|
*len = ifmgd->ssid_len;
|
2008-09-11 06:01:52 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid)
|
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-11 06:01:52 +08:00
|
|
|
|
2009-01-24 08:19:04 +08:00
|
|
|
if (is_valid_ether_addr(bssid)) {
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(ifmgd->bssid, bssid, ETH_ALEN);
|
|
|
|
ifmgd->flags |= IEEE80211_STA_BSSID_SET;
|
2009-01-24 08:19:04 +08:00
|
|
|
} else {
|
2009-02-15 19:44:28 +08:00
|
|
|
memset(ifmgd->bssid, 0, ETH_ALEN);
|
|
|
|
ifmgd->flags &= ~IEEE80211_STA_BSSID_SET;
|
2009-01-24 08:19:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (netif_running(sdata->dev)) {
|
|
|
|
if (ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID)) {
|
2008-09-11 06:01:52 +08:00
|
|
|
printk(KERN_DEBUG "%s: Failed to config new BSSID to "
|
|
|
|
"the low-level driver\n", sdata->dev->name);
|
|
|
|
}
|
|
|
|
}
|
2008-09-08 23:44:22 +08:00
|
|
|
|
2009-02-21 08:27:29 +08:00
|
|
|
return ieee80211_sta_commit(sdata);
|
2008-09-11 06:01:52 +08:00
|
|
|
}
|
|
|
|
|
2009-03-19 19:39:22 +08:00
|
|
|
int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata,
|
|
|
|
const char *ie, size_t len)
|
2008-09-11 06:01:52 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2008-09-11 06:01:52 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
kfree(ifmgd->extra_ie);
|
2008-09-11 06:01:52 +08:00
|
|
|
if (len == 0) {
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->extra_ie = NULL;
|
|
|
|
ifmgd->extra_ie_len = 0;
|
2008-09-08 23:44:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2009-02-15 19:44:28 +08:00
|
|
|
ifmgd->extra_ie = kmalloc(len, GFP_KERNEL);
|
|
|
|
if (!ifmgd->extra_ie) {
|
|
|
|
ifmgd->extra_ie_len = 0;
|
2008-09-11 06:01:52 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2009-02-15 19:44:28 +08:00
|
|
|
memcpy(ifmgd->extra_ie, ie, len);
|
|
|
|
ifmgd->extra_ie_len = len;
|
2008-09-11 06:01:52 +08:00
|
|
|
return 0;
|
2008-09-08 23:44:22 +08:00
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2008-06-30 21:10:46 +08:00
|
|
|
printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n",
|
2008-08-03 08:04:37 +08:00
|
|
|
sdata->dev->name, reason);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
2007-05-06 02:45:53 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, true, true, reason);
|
2007-05-06 02:45:53 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-03 08:04:37 +08:00
|
|
|
int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason)
|
2007-05-06 02:45:53 +08:00
|
|
|
{
|
2009-02-15 19:44:28 +08:00
|
|
|
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-06-30 21:10:46 +08:00
|
|
|
printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n",
|
2008-08-03 08:04:37 +08:00
|
|
|
sdata->dev->name, reason);
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2008-09-11 06:01:58 +08:00
|
|
|
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
2007-05-06 02:45:53 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED))
|
|
|
|
return -ENOLINK;
|
2007-05-06 02:45:53 +08:00
|
|
|
|
2009-02-15 19:44:28 +08:00
|
|
|
ieee80211_set_disassoc(sdata, false, true, reason);
|
2007-05-06 02:45:53 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2008-04-05 07:59:58 +08:00
|
|
|
|
2008-09-11 06:01:52 +08:00
|
|
|
/* scan finished notification */
|
|
|
|
void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local)
|
|
|
|
{
|
|
|
|
struct ieee80211_sub_if_data *sdata = local->scan_sdata;
|
|
|
|
|
|
|
|
/* Restart STA timers */
|
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(sdata, &local->interfaces, list)
|
|
|
|
ieee80211_restart_sta_timer(sdata);
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
2008-12-19 05:35:27 +08:00
|
|
|
|
|
|
|
void ieee80211_dynamic_ps_disable_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local =
|
|
|
|
container_of(work, struct ieee80211_local,
|
|
|
|
dynamic_ps_disable_work);
|
|
|
|
|
|
|
|
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
|
|
|
|
local->hw.conf.flags &= ~IEEE80211_CONF_PS;
|
|
|
|
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ieee80211_wake_queues_by_reason(&local->hw,
|
|
|
|
IEEE80211_QUEUE_STOP_REASON_PS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_dynamic_ps_enable_work(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local =
|
|
|
|
container_of(work, struct ieee80211_local,
|
|
|
|
dynamic_ps_enable_work);
|
2008-12-24 10:39:02 +08:00
|
|
|
struct ieee80211_sub_if_data *sdata = local->scan_sdata;
|
2008-12-19 05:35:27 +08:00
|
|
|
|
|
|
|
if (local->hw.conf.flags & IEEE80211_CONF_PS)
|
|
|
|
return;
|
|
|
|
|
2009-01-08 01:28:20 +08:00
|
|
|
if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK)
|
|
|
|
ieee80211_send_nullfunc(local, sdata, 1);
|
2008-12-19 05:35:27 +08:00
|
|
|
|
2009-01-08 01:28:20 +08:00
|
|
|
local->hw.conf.flags |= IEEE80211_CONF_PS;
|
2008-12-19 05:35:27 +08:00
|
|
|
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ieee80211_dynamic_ps_timer(unsigned long data)
|
|
|
|
{
|
|
|
|
struct ieee80211_local *local = (void *) data;
|
|
|
|
|
|
|
|
queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work);
|
|
|
|
}
|
2009-02-15 19:44:28 +08:00
|
|
|
|
|
|
|
void ieee80211_send_nullfunc(struct ieee80211_local *local,
|
|
|
|
struct ieee80211_sub_if_data *sdata,
|
|
|
|
int powersave)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct ieee80211_hdr *nullfunc;
|
|
|
|
__le16 fc;
|
|
|
|
|
|
|
|
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION))
|
|
|
|
return;
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24);
|
|
|
|
if (!skb) {
|
|
|
|
printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc "
|
|
|
|
"frame\n", sdata->dev->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
|
|
|
|
|
|
nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24);
|
|
|
|
memset(nullfunc, 0, 24);
|
|
|
|
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
|
|
|
|
IEEE80211_FCTL_TODS);
|
|
|
|
if (powersave)
|
|
|
|
fc |= cpu_to_le16(IEEE80211_FCTL_PM);
|
|
|
|
nullfunc->frame_control = fc;
|
|
|
|
memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN);
|
|
|
|
memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN);
|
|
|
|
memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN);
|
|
|
|
|
|
|
|
ieee80211_tx_skb(sdata, skb, 0);
|
|
|
|
}
|