2006-01-12 20:12:59 +00:00
|
|
|
/*
|
|
|
|
* This file contains the softmac's association logic.
|
|
|
|
*
|
2006-01-31 18:31:41 +00:00
|
|
|
* Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
|
|
|
|
* Joseph Jezak <josejx@gentoo.org>
|
|
|
|
* Larry Finger <Larry.Finger@lwfinger.net>
|
|
|
|
* Danny van Dyk <kugelfang@gentoo.org>
|
|
|
|
* Michael Buesch <mbuesch@freenet.de>
|
2006-01-12 20:12:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in the
|
|
|
|
* file called COPYING.
|
|
|
|
*/
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
#include "ieee80211softmac_priv.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Overview
|
|
|
|
*
|
|
|
|
* Before you can associate, you have to authenticate.
|
2007-02-09 14:24:46 +00:00
|
|
|
*
|
2006-01-04 15:32:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Sends out an association request to the desired AP */
|
|
|
|
static void
|
|
|
|
ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
2006-03-22 22:29:32 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* Switch to correct channel for this network */
|
|
|
|
mac->set_channel(mac->dev, net->channel);
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* Send association request */
|
|
|
|
ieee80211softmac_send_mgt_frame(mac, net, IEEE80211_STYPE_ASSOC_REQ, 0);
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
dprintk(KERN_INFO PFX "sent association request!\n");
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mac->lock, flags);
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 0; /* just to make sure */
|
2006-01-04 15:32:16 +00:00
|
|
|
|
|
|
|
/* Set a timer for timeout */
|
|
|
|
/* FIXME: make timeout configurable */
|
2006-04-30 21:09:07 +00:00
|
|
|
if (likely(mac->running))
|
|
|
|
schedule_delayed_work(&mac->associnfo.timeout, 5 * HZ);
|
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-22 14:57:56 +00:00
|
|
|
ieee80211softmac_assoc_timeout(struct work_struct *work)
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
2006-11-22 14:57:56 +00:00
|
|
|
struct ieee80211softmac_device *mac =
|
|
|
|
container_of(work, struct ieee80211softmac_device,
|
|
|
|
associnfo.timeout.work);
|
2006-06-11 16:01:03 +00:00
|
|
|
struct ieee80211softmac_network *n;
|
2006-01-04 15:32:16 +00:00
|
|
|
|
2006-09-27 12:26:33 +00:00
|
|
|
mutex_lock(&mac->associnfo.mutex);
|
2006-01-04 15:32:16 +00:00
|
|
|
/* we might race against ieee80211softmac_handle_assoc_response,
|
|
|
|
* so make sure only one of us does something */
|
2006-09-27 12:26:33 +00:00
|
|
|
if (!mac->associnfo.associating)
|
|
|
|
goto out;
|
2006-01-04 15:32:16 +00:00
|
|
|
mac->associnfo.associating = 0;
|
|
|
|
mac->associnfo.bssvalid = 0;
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 0;
|
2006-06-11 16:01:03 +00:00
|
|
|
|
|
|
|
n = ieee80211softmac_get_network_by_bssid_locked(mac, mac->associnfo.bssid);
|
2006-01-04 15:32:16 +00:00
|
|
|
|
|
|
|
dprintk(KERN_INFO PFX "assoc request timed out!\n");
|
2006-06-11 16:01:03 +00:00
|
|
|
ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, n);
|
2006-09-27 12:26:33 +00:00
|
|
|
out:
|
|
|
|
mutex_unlock(&mac->associnfo.mutex);
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
|
2006-04-20 18:02:02 +00:00
|
|
|
void
|
2006-05-01 21:23:27 +00:00
|
|
|
ieee80211softmac_disassoc(struct ieee80211softmac_device *mac)
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2006-05-01 21:23:27 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&mac->lock, flags);
|
|
|
|
if (mac->associnfo.associating)
|
|
|
|
cancel_delayed_work(&mac->associnfo.timeout);
|
|
|
|
|
|
|
|
netif_carrier_off(mac->dev);
|
|
|
|
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 0;
|
2006-05-01 21:23:27 +00:00
|
|
|
mac->associnfo.bssvalid = 0;
|
|
|
|
mac->associnfo.associating = 0;
|
2006-07-18 20:33:27 +00:00
|
|
|
ieee80211softmac_init_bss(mac);
|
2006-05-01 21:23:27 +00:00
|
|
|
ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_DISASSOCIATED, NULL);
|
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sends out a disassociation request to the desired AP */
|
|
|
|
void
|
|
|
|
ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason)
|
|
|
|
{
|
2006-01-04 15:32:16 +00:00
|
|
|
struct ieee80211softmac_network *found;
|
|
|
|
|
2006-09-27 12:26:33 +00:00
|
|
|
if (mac->associnfo.bssvalid && mac->associnfo.associated) {
|
2006-01-04 15:32:16 +00:00
|
|
|
found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
|
|
|
|
if (found)
|
|
|
|
ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason);
|
|
|
|
}
|
|
|
|
|
2006-05-01 21:23:27 +00:00
|
|
|
ieee80211softmac_disassoc(mac);
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
we_support_all_basic_rates(struct ieee80211softmac_device *mac, u8 *from, u8 from_len)
|
|
|
|
{
|
2006-05-01 21:45:50 +00:00
|
|
|
int idx;
|
|
|
|
u8 rate;
|
2006-01-04 15:32:16 +00:00
|
|
|
|
|
|
|
for (idx = 0; idx < (from_len); idx++) {
|
|
|
|
rate = (from)[idx];
|
|
|
|
if (!(rate & IEEE80211_BASIC_RATE_MASK))
|
|
|
|
continue;
|
|
|
|
rate &= ~IEEE80211_BASIC_RATE_MASK;
|
2006-05-01 21:45:50 +00:00
|
|
|
if (!ieee80211softmac_ratesinfo_rate_supported(&mac->ratesinfo, rate))
|
2006-01-04 15:32:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_network *net)
|
|
|
|
{
|
|
|
|
/* we cannot associate to networks whose name we don't know */
|
|
|
|
if (ieee80211_is_empty_essid(net->ssid, net->ssid_len))
|
|
|
|
return 0;
|
|
|
|
/* do not associate to a network whose BSSBasicRateSet we cannot support */
|
|
|
|
if (!we_support_all_basic_rates(mac, net->rates, net->rates_len))
|
|
|
|
return 0;
|
|
|
|
/* do we really need to check the ex rates? */
|
|
|
|
if (!we_support_all_basic_rates(mac, net->rates_ex, net->rates_ex_len))
|
|
|
|
return 0;
|
|
|
|
|
2006-04-20 18:02:03 +00:00
|
|
|
/* assume that users know what they're doing ...
|
|
|
|
* (note we don't let them select a net we're incompatible with) */
|
|
|
|
if (mac->associnfo.bssfixed) {
|
|
|
|
return !memcmp(mac->associnfo.bssid, net->bssid, ETH_ALEN);
|
|
|
|
}
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* if 'ANY' network requested, take any that doesn't have privacy enabled */
|
2007-02-09 14:24:46 +00:00
|
|
|
if (mac->associnfo.req_essid.len == 0
|
2006-01-04 15:32:16 +00:00
|
|
|
&& !(net->capability & WLAN_CAPABILITY_PRIVACY))
|
|
|
|
return 1;
|
|
|
|
if (net->ssid_len != mac->associnfo.req_essid.len)
|
|
|
|
return 0;
|
|
|
|
if (!memcmp(net->ssid, mac->associnfo.req_essid.data, mac->associnfo.req_essid.len))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-01 14:37:22 +00:00
|
|
|
ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
|
|
|
struct ieee80211softmac_device *mac = ieee80211_priv(dev);
|
2006-12-10 17:39:08 +00:00
|
|
|
ieee80211softmac_assoc_work(&mac->associnfo.work.work);
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
|
2006-06-01 14:37:22 +00:00
|
|
|
static void
|
|
|
|
ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
|
|
|
|
{
|
|
|
|
struct ieee80211softmac_device *mac = ieee80211_priv(dev);
|
|
|
|
|
|
|
|
switch (event_type) {
|
|
|
|
case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
|
2006-12-10 17:39:08 +00:00
|
|
|
ieee80211softmac_assoc_work(&mac->associnfo.work.work);
|
2006-06-01 14:37:22 +00:00
|
|
|
break;
|
|
|
|
case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
|
|
|
|
case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
|
|
|
|
ieee80211softmac_disassoc(mac);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* This function is called to handle userspace requests (asynchronously) */
|
|
|
|
void
|
2006-11-22 14:57:56 +00:00
|
|
|
ieee80211softmac_assoc_work(struct work_struct *work)
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
2006-11-22 14:57:56 +00:00
|
|
|
struct ieee80211softmac_device *mac =
|
|
|
|
container_of(work, struct ieee80211softmac_device,
|
|
|
|
associnfo.work.work);
|
2006-01-04 15:32:16 +00:00
|
|
|
struct ieee80211softmac_network *found = NULL;
|
|
|
|
struct ieee80211_network *net = NULL, *best = NULL;
|
2006-05-01 21:23:27 +00:00
|
|
|
int bssvalid;
|
2006-01-04 15:32:16 +00:00
|
|
|
unsigned long flags;
|
2006-05-01 21:23:27 +00:00
|
|
|
|
2006-09-27 12:26:33 +00:00
|
|
|
mutex_lock(&mac->associnfo.mutex);
|
|
|
|
|
|
|
|
if (!mac->associnfo.associating)
|
|
|
|
goto out;
|
|
|
|
|
2006-05-01 21:23:27 +00:00
|
|
|
/* ieee80211_disassoc might clear this */
|
|
|
|
bssvalid = mac->associnfo.bssvalid;
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* meh */
|
2006-09-27 12:26:33 +00:00
|
|
|
if (mac->associnfo.associated)
|
2006-05-01 21:23:27 +00:00
|
|
|
ieee80211softmac_send_disassoc_req(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT);
|
2006-01-04 15:32:16 +00:00
|
|
|
|
|
|
|
/* try to find the requested network in our list, if we found one already */
|
2006-05-01 21:23:27 +00:00
|
|
|
if (bssvalid || mac->associnfo.bssfixed)
|
2007-02-09 14:24:46 +00:00
|
|
|
found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
|
|
|
|
|
2006-01-11 09:46:16 +00:00
|
|
|
/* Search the ieee80211 networks for this network if we didn't find it by bssid,
|
|
|
|
* but only if we've scanned at least once (to get a better list of networks to
|
|
|
|
* select from). If we have not scanned before, the !found logic below will be
|
|
|
|
* invoked and will scan. */
|
|
|
|
if (!found && (mac->associnfo.scan_retry < IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT))
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
2006-01-10 17:56:32 +00:00
|
|
|
s8 rssi = -128; /* if I don't initialise, gcc emits an invalid warning
|
|
|
|
because it cannot follow the best pointer logic. */
|
2006-01-04 15:32:16 +00:00
|
|
|
spin_lock_irqsave(&mac->ieee->lock, flags);
|
|
|
|
list_for_each_entry(net, &mac->ieee->network_list, list) {
|
|
|
|
/* we're supposed to find the network with
|
|
|
|
* the best signal here, as we're asked to join
|
|
|
|
* any network with a specific ESSID, and many
|
|
|
|
* different ones could have that.
|
|
|
|
*
|
2006-01-10 17:56:32 +00:00
|
|
|
* I'll for now just go with the reported rssi.
|
2006-01-04 15:32:16 +00:00
|
|
|
*
|
|
|
|
* We also should take into account the rateset
|
|
|
|
* here to find the best BSSID to try.
|
|
|
|
*/
|
|
|
|
if (network_matches_request(mac, net)) {
|
|
|
|
if (!best) {
|
|
|
|
best = net;
|
2006-01-10 17:56:32 +00:00
|
|
|
rssi = best->stats.rssi;
|
2006-01-04 15:32:16 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* we already had a matching network, so
|
|
|
|
* compare their properties to get the
|
|
|
|
* better of the two ... (see above)
|
|
|
|
*/
|
2006-01-10 17:56:32 +00:00
|
|
|
if (rssi < net->stats.rssi) {
|
|
|
|
best = net;
|
|
|
|
rssi = best->stats.rssi;
|
|
|
|
}
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if we unlock here, we might get interrupted and the `best'
|
|
|
|
* pointer could go stale */
|
|
|
|
if (best) {
|
|
|
|
found = ieee80211softmac_create_network(mac, best);
|
|
|
|
/* if found is still NULL, then we got -ENOMEM somewhere */
|
|
|
|
if (found)
|
|
|
|
ieee80211softmac_add_network(mac, found);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&mac->ieee->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
if (mac->associnfo.scan_retry > 0) {
|
|
|
|
mac->associnfo.scan_retry--;
|
2006-09-27 12:26:33 +00:00
|
|
|
|
2007-02-09 14:24:46 +00:00
|
|
|
/* We know of no such network. Let's scan.
|
2006-01-04 15:32:16 +00:00
|
|
|
* NB: this also happens if we had no memory to copy the network info...
|
|
|
|
* Maybe we can hope to have more memory after scanning finishes ;)
|
|
|
|
*/
|
2006-01-11 09:46:16 +00:00
|
|
|
dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
|
2006-06-01 14:37:22 +00:00
|
|
|
ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
|
2007-07-10 01:37:36 +00:00
|
|
|
if (ieee80211softmac_start_scan(mac)) {
|
2006-01-11 09:46:16 +00:00
|
|
|
dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
|
2007-07-10 01:37:36 +00:00
|
|
|
mac->associnfo.associating = 0;
|
|
|
|
mac->associnfo.associated = 0;
|
|
|
|
}
|
2006-09-27 12:26:33 +00:00
|
|
|
goto out;
|
2006-04-20 18:02:03 +00:00
|
|
|
} else {
|
2006-01-04 15:32:16 +00:00
|
|
|
mac->associnfo.associating = 0;
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 0;
|
2006-01-04 15:32:16 +00:00
|
|
|
|
2006-01-11 09:46:16 +00:00
|
|
|
dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n");
|
2006-04-20 18:02:03 +00:00
|
|
|
/* reset the retry counter for the next user request since we
|
|
|
|
* break out and don't reschedule ourselves after this point. */
|
|
|
|
mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
|
2006-01-04 15:32:16 +00:00
|
|
|
ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL);
|
2006-09-27 12:26:33 +00:00
|
|
|
goto out;
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-20 18:02:03 +00:00
|
|
|
|
|
|
|
/* reset the retry counter for the next user request since we
|
|
|
|
* now found a net and will try to associate to it, but not
|
|
|
|
* schedule this function again. */
|
|
|
|
mac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
|
2006-01-04 15:32:16 +00:00
|
|
|
mac->associnfo.bssvalid = 1;
|
|
|
|
memcpy(mac->associnfo.bssid, found->bssid, ETH_ALEN);
|
|
|
|
/* copy the ESSID for displaying it */
|
|
|
|
mac->associnfo.associate_essid.len = found->essid.len;
|
|
|
|
memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1);
|
2006-09-27 12:26:33 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
/* we found a network! authenticate (if necessary) and associate to it. */
|
2006-06-11 16:00:37 +00:00
|
|
|
if (found->authenticating) {
|
|
|
|
dprintk(KERN_INFO PFX "Already requested authentication, waiting...\n");
|
|
|
|
if(!mac->associnfo.assoc_wait) {
|
|
|
|
mac->associnfo.assoc_wait = 1;
|
2006-06-26 20:34:29 +00:00
|
|
|
ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
|
2006-06-11 16:00:37 +00:00
|
|
|
}
|
2006-09-27 12:26:33 +00:00
|
|
|
goto out;
|
2006-06-11 16:00:37 +00:00
|
|
|
}
|
|
|
|
if (!found->authenticated && !found->authenticating) {
|
2006-01-04 15:32:16 +00:00
|
|
|
/* This relies on the fact that _auth_req only queues the work,
|
|
|
|
* otherwise adding the notification would be racy. */
|
|
|
|
if (!ieee80211softmac_auth_req(mac, found)) {
|
2006-06-11 16:00:37 +00:00
|
|
|
if(!mac->associnfo.assoc_wait) {
|
|
|
|
dprintk(KERN_INFO PFX "Cannot associate without being authenticated, requested authentication\n");
|
|
|
|
mac->associnfo.assoc_wait = 1;
|
2006-06-26 20:34:29 +00:00
|
|
|
ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
|
2006-06-11 16:00:37 +00:00
|
|
|
}
|
2006-01-04 15:32:16 +00:00
|
|
|
} else {
|
|
|
|
printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
|
2006-06-11 16:00:37 +00:00
|
|
|
mac->associnfo.assoc_wait = 0;
|
2006-01-04 15:32:16 +00:00
|
|
|
ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
|
|
|
|
}
|
2006-09-27 12:26:33 +00:00
|
|
|
goto out;
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
/* finally! now we can start associating */
|
2006-06-11 16:00:37 +00:00
|
|
|
mac->associnfo.assoc_wait = 0;
|
2006-01-04 15:32:16 +00:00
|
|
|
ieee80211softmac_assoc(mac, found);
|
2006-09-27 12:26:33 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&mac->associnfo.mutex);
|
2006-01-04 15:32:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* call this to do whatever is necessary when we're associated */
|
|
|
|
static void
|
|
|
|
ieee80211softmac_associated(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211_assoc_response * resp,
|
|
|
|
struct ieee80211softmac_network *net)
|
|
|
|
{
|
2006-07-18 20:33:27 +00:00
|
|
|
u16 cap = le16_to_cpu(resp->capability);
|
|
|
|
u8 erp_value = net->erp_value;
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
mac->associnfo.associating = 0;
|
2006-07-18 20:33:27 +00:00
|
|
|
mac->bssinfo.supported_rates = net->supported_rates;
|
2006-05-01 21:45:50 +00:00
|
|
|
ieee80211softmac_recalc_txrates(mac);
|
|
|
|
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 1;
|
2006-07-18 20:33:27 +00:00
|
|
|
|
|
|
|
mac->associnfo.short_preamble_available =
|
|
|
|
(cap & WLAN_CAPABILITY_SHORT_PREAMBLE) != 0;
|
|
|
|
ieee80211softmac_process_erp(mac, erp_value);
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
if (mac->set_bssid_filter)
|
|
|
|
mac->set_bssid_filter(mac->dev, net->bssid);
|
|
|
|
memcpy(mac->ieee->bssid, net->bssid, ETH_ALEN);
|
2006-01-06 17:11:23 +00:00
|
|
|
netif_carrier_on(mac->dev);
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
mac->association_id = le16_to_cpup(&resp->aid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* received frame handling functions */
|
|
|
|
int
|
|
|
|
ieee80211softmac_handle_assoc_response(struct net_device * dev,
|
|
|
|
struct ieee80211_assoc_response * resp,
|
2006-07-18 20:33:27 +00:00
|
|
|
struct ieee80211_network * _ieee80211_network)
|
2006-01-04 15:32:16 +00:00
|
|
|
{
|
2006-07-18 20:33:27 +00:00
|
|
|
/* NOTE: the network parameter has to be mostly ignored by
|
2006-01-04 15:32:16 +00:00
|
|
|
* this code because it is the ieee80211's pointer
|
|
|
|
* to the struct, not ours (we made a copy)
|
|
|
|
*/
|
|
|
|
struct ieee80211softmac_device *mac = ieee80211_priv(dev);
|
|
|
|
u16 status = le16_to_cpup(&resp->status);
|
|
|
|
struct ieee80211softmac_network *network = NULL;
|
|
|
|
unsigned long flags;
|
2006-04-30 21:09:07 +00:00
|
|
|
|
|
|
|
if (unlikely(!mac->running))
|
|
|
|
return -ENODEV;
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
spin_lock_irqsave(&mac->lock, flags);
|
|
|
|
|
|
|
|
if (!mac->associnfo.associating) {
|
|
|
|
/* we race against the timeout function, so make sure
|
|
|
|
* only one of us can do work */
|
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
network = ieee80211softmac_get_network_by_bssid_locked(mac, resp->header.addr3);
|
|
|
|
|
|
|
|
/* someone sending us things without us knowing him? Ignore. */
|
|
|
|
if (!network) {
|
|
|
|
dprintk(KERN_INFO PFX "Received unrequested assocation response from " MAC_FMT "\n", MAC_ARG(resp->header.addr3));
|
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now that we know it was for us, we can cancel the timeout */
|
|
|
|
cancel_delayed_work(&mac->associnfo.timeout);
|
|
|
|
|
2006-07-18 20:33:27 +00:00
|
|
|
/* if the association response included an ERP IE, update our saved
|
|
|
|
* copy */
|
|
|
|
if (_ieee80211_network->flags & NETWORK_HAS_ERP_VALUE)
|
|
|
|
network->erp_value = _ieee80211_network->erp_value;
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
switch (status) {
|
|
|
|
case 0:
|
|
|
|
dprintk(KERN_INFO PFX "associated!\n");
|
|
|
|
ieee80211softmac_associated(mac, resp, network);
|
|
|
|
ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATED, network);
|
|
|
|
break;
|
|
|
|
case WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH:
|
|
|
|
if (!network->auth_desynced_once) {
|
|
|
|
/* there seem to be a few rare cases where our view of
|
|
|
|
* the world is obscured, or buggy APs that don't DEAUTH
|
|
|
|
* us properly. So we handle that, but allow it only once.
|
|
|
|
*/
|
|
|
|
printkl(KERN_INFO PFX "We were not authenticated during association, retrying...\n");
|
|
|
|
network->authenticated = 0;
|
|
|
|
/* we don't want to do this more than once ... */
|
|
|
|
network->auth_desynced_once = 1;
|
2006-11-22 14:57:56 +00:00
|
|
|
schedule_delayed_work(&mac->associnfo.work, 0);
|
2006-01-04 15:32:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status);
|
|
|
|
mac->associnfo.associating = 0;
|
|
|
|
mac->associnfo.bssvalid = 0;
|
2006-09-27 12:26:33 +00:00
|
|
|
mac->associnfo.associated = 0;
|
2006-01-04 15:32:16 +00:00
|
|
|
ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network);
|
|
|
|
}
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-12-03 15:32:00 +00:00
|
|
|
void
|
|
|
|
ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&mac->lock, flags);
|
|
|
|
mac->associnfo.associating = 1;
|
2006-12-10 10:18:31 +00:00
|
|
|
schedule_delayed_work(&mac->associnfo.work, 0);
|
2006-12-03 15:32:00 +00:00
|
|
|
spin_unlock_irqrestore(&mac->lock, flags);
|
|
|
|
}
|
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
int
|
|
|
|
ieee80211softmac_handle_disassoc(struct net_device * dev,
|
|
|
|
struct ieee80211_disassoc *disassoc)
|
|
|
|
{
|
|
|
|
struct ieee80211softmac_device *mac = ieee80211_priv(dev);
|
2006-04-30 21:09:07 +00:00
|
|
|
|
|
|
|
if (unlikely(!mac->running))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2006-01-10 18:12:19 +00:00
|
|
|
if (memcmp(disassoc->header.addr2, mac->associnfo.bssid, ETH_ALEN))
|
|
|
|
return 0;
|
2006-04-30 21:09:07 +00:00
|
|
|
|
2006-01-10 18:12:19 +00:00
|
|
|
if (memcmp(disassoc->header.addr1, mac->dev->dev_addr, ETH_ALEN))
|
|
|
|
return 0;
|
2006-04-30 21:09:07 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
dprintk(KERN_INFO PFX "got disassoc frame\n");
|
2006-05-01 21:23:27 +00:00
|
|
|
ieee80211softmac_disassoc(mac);
|
|
|
|
|
2006-12-03 15:32:00 +00:00
|
|
|
ieee80211softmac_try_reassoc(mac);
|
2006-05-01 21:23:27 +00:00
|
|
|
|
2006-01-04 15:32:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-01-31 18:49:42 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
ieee80211softmac_handle_reassoc_req(struct net_device * dev,
|
|
|
|
struct ieee80211_reassoc_request * resp)
|
|
|
|
{
|
|
|
|
struct ieee80211softmac_device *mac = ieee80211_priv(dev);
|
|
|
|
struct ieee80211softmac_network *network;
|
|
|
|
|
2006-04-30 21:09:07 +00:00
|
|
|
if (unlikely(!mac->running))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2006-01-31 18:49:42 +00:00
|
|
|
network = ieee80211softmac_get_network_by_bssid(mac, resp->header.addr3);
|
|
|
|
if (!network) {
|
|
|
|
dprintkl(KERN_INFO PFX "reassoc request from unknown network\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2006-11-22 14:57:56 +00:00
|
|
|
schedule_delayed_work(&mac->associnfo.work, 0);
|
2006-04-06 23:42:55 +00:00
|
|
|
|
2006-01-31 18:49:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|