2007-02-10 15:25:27 +01:00
|
|
|
/* Copyright (C) 2006, Red Hat, Inc. */
|
|
|
|
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <net/ieee80211.h>
|
2007-05-25 23:28:30 +02:00
|
|
|
#include <linux/etherdevice.h>
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
#include "assoc.h"
|
|
|
|
#include "join.h"
|
|
|
|
#include "decl.h"
|
|
|
|
#include "hostcmd.h"
|
|
|
|
#include "host.h"
|
2007-12-11 22:54:15 +01:00
|
|
|
#include "cmd.h"
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
|
2008-01-25 14:15:00 +01:00
|
|
|
static const u8 bssid_any[ETH_ALEN] __attribute__ ((aligned (2))) =
|
|
|
|
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
|
|
|
static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) =
|
|
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 23:09:41 +02:00
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_essid(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2007-05-25 22:15:56 +02:00
|
|
|
struct bss_descriptor * bss;
|
2007-05-26 04:30:48 +02:00
|
|
|
int channel = -1;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 22:46:33 +02:00
|
|
|
/* FIXME: take channel into account when picking SSIDs if a channel
|
|
|
|
* is set.
|
|
|
|
*/
|
|
|
|
|
2007-05-26 04:30:48 +02:00
|
|
|
if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
|
|
|
|
channel = assoc_req->channel;
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc("SSID '%s' requested\n",
|
2007-05-29 05:54:55 +02:00
|
|
|
escape_essid(assoc_req->ssid, assoc_req->ssid_len));
|
2007-05-11 04:58:02 +02:00
|
|
|
if (assoc_req->mode == IW_MODE_INFRA) {
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
|
2007-08-02 19:05:32 +02:00
|
|
|
assoc_req->ssid_len, 0);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
assoc_req->ssid_len, NULL, IW_MODE_INFRA, channel);
|
2007-05-25 22:15:56 +02:00
|
|
|
if (bss != NULL) {
|
2007-05-25 23:09:41 +02:00
|
|
|
memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_associate(priv, assoc_req);
|
2007-02-10 15:25:27 +01:00
|
|
|
} else {
|
2007-05-29 05:54:55 +02:00
|
|
|
lbs_deb_assoc("SSID not found; cannot associate\n");
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
2007-05-11 04:58:02 +02:00
|
|
|
} else if (assoc_req->mode == IW_MODE_ADHOC) {
|
2007-02-10 15:25:27 +01:00
|
|
|
/* Scan for the network, do not save previous results. Stale
|
|
|
|
* scan data will cause us to join a non-existant adhoc network
|
|
|
|
*/
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_send_specific_ssid_scan(priv, assoc_req->ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
assoc_req->ssid_len, 1);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
/* Search for the requested SSID in the scan table */
|
2007-12-08 21:04:36 +01:00
|
|
|
bss = lbs_find_ssid_in_list(priv, assoc_req->ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
assoc_req->ssid_len, NULL, IW_MODE_ADHOC, channel);
|
2007-05-25 22:15:56 +02:00
|
|
|
if (bss != NULL) {
|
2007-05-29 05:54:55 +02:00
|
|
|
lbs_deb_assoc("SSID found, will join\n");
|
2007-05-25 23:09:41 +02:00
|
|
|
memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_join_adhoc_network(priv, assoc_req);
|
2007-02-10 15:25:27 +01:00
|
|
|
} else {
|
|
|
|
/* else send START command */
|
2007-05-29 05:54:55 +02:00
|
|
|
lbs_deb_assoc("SSID not found, creating adhoc network\n");
|
2007-05-25 23:09:41 +02:00
|
|
|
memcpy(&assoc_req->bss.ssid, &assoc_req->ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
IW_ESSID_MAX_SIZE);
|
|
|
|
assoc_req->bss.ssid_len = assoc_req->ssid_len;
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_start_adhoc_network(priv, assoc_req);
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_bssid(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
2007-05-25 22:15:56 +02:00
|
|
|
int ret = 0;
|
|
|
|
struct bss_descriptor * bss;
|
2007-10-04 02:59:30 +02:00
|
|
|
DECLARE_MAC_BUF(mac);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-10-04 02:59:30 +02:00
|
|
|
lbs_deb_enter_args(LBS_DEB_ASSOC, "BSSID %s",
|
|
|
|
print_mac(mac, assoc_req->bssid));
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
/* Search for index position in list for requested MAC */
|
2007-12-08 21:04:36 +01:00
|
|
|
bss = lbs_find_bssid_in_list(priv, assoc_req->bssid,
|
2007-02-10 15:25:27 +01:00
|
|
|
assoc_req->mode);
|
2007-05-25 22:15:56 +02:00
|
|
|
if (bss == NULL) {
|
2007-10-04 02:59:30 +02:00
|
|
|
lbs_deb_assoc("ASSOC: WAP: BSSID %s not found, "
|
|
|
|
"cannot associate.\n", print_mac(mac, assoc_req->bssid));
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:09:41 +02:00
|
|
|
memcpy(&assoc_req->bss, bss, sizeof(struct bss_descriptor));
|
2007-05-11 04:58:02 +02:00
|
|
|
if (assoc_req->mode == IW_MODE_INFRA) {
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_associate(priv, assoc_req);
|
|
|
|
lbs_deb_assoc("ASSOC: lbs_associate(bssid) returned %d\n", ret);
|
2007-05-11 04:58:02 +02:00
|
|
|
} else if (assoc_req->mode == IW_MODE_ADHOC) {
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_join_adhoc_network(priv, assoc_req);
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_associate(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0, done = 0;
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
|
|
|
|
2007-02-10 15:25:27 +01:00
|
|
|
/* If we're given and 'any' BSSID, try associating based on SSID */
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
|
2007-05-25 23:28:30 +02:00
|
|
|
if (compare_ether_addr(bssid_any, assoc_req->bssid)
|
|
|
|
&& compare_ether_addr(bssid_off, assoc_req->bssid)) {
|
2007-02-10 15:25:27 +01:00
|
|
|
ret = assoc_helper_bssid(priv, assoc_req);
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!done && test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_essid(priv, assoc_req);
|
|
|
|
}
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_mode(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (assoc_req->mode == priv->mode)
|
2007-05-25 17:27:16 +02:00
|
|
|
goto done;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-11 04:58:02 +02:00
|
|
|
if (assoc_req->mode == IW_MODE_INFRA) {
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->psstate != PS_STATE_FULL_POWER)
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_ps_wakeup(priv, CMD_OPTION_WAITFORRSP);
|
2007-12-08 21:04:36 +01:00
|
|
|
priv->psmode = LBS802_11POWERMODECAM;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
priv->mode = assoc_req->mode;
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_prepare_and_send_command(priv,
|
2007-08-02 17:31:18 +02:00
|
|
|
CMD_802_11_SNMP_MIB,
|
|
|
|
0, CMD_OPTION_WAITFORRSP,
|
2007-02-10 15:25:27 +01:00
|
|
|
OID_802_11_INFRASTRUCTURE_MODE,
|
2007-05-26 05:36:54 +02:00
|
|
|
/* Shoot me now */ (void *) (size_t) assoc_req->mode);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-13 04:50:21 +01:00
|
|
|
int lbs_update_channel(struct lbs_private *priv)
|
2007-05-25 22:46:33 +02:00
|
|
|
{
|
2007-10-15 12:55:56 +02:00
|
|
|
int ret;
|
2007-12-11 22:54:15 +01:00
|
|
|
|
2007-12-16 23:21:00 +01:00
|
|
|
/* the channel in f/w could be out of sync; get the current channel */
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-12-11 22:54:15 +01:00
|
|
|
|
|
|
|
ret = lbs_get_channel(priv);
|
2007-12-16 23:21:00 +01:00
|
|
|
if (ret > 0) {
|
|
|
|
priv->curbssparams.channel = ret;
|
|
|
|
ret = 0;
|
|
|
|
}
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
|
|
|
return ret;
|
2007-05-25 22:46:33 +02:00
|
|
|
}
|
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
void lbs_sync_channel(struct work_struct *work)
|
2007-05-30 18:14:34 +02:00
|
|
|
{
|
2007-11-23 15:43:44 +01:00
|
|
|
struct lbs_private *priv = container_of(work, struct lbs_private,
|
|
|
|
sync_channel);
|
2007-05-30 18:14:34 +02:00
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-12-13 04:50:21 +01:00
|
|
|
if (lbs_update_channel(priv))
|
2007-05-30 18:14:34 +02:00
|
|
|
lbs_pr_info("Channel synchronization failed.");
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_leave(LBS_DEB_ASSOC);
|
2007-05-30 18:14:34 +02:00
|
|
|
}
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_channel(struct lbs_private *priv,
|
2007-05-25 22:46:33 +02:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
|
|
|
|
2007-12-13 04:50:21 +01:00
|
|
|
ret = lbs_update_channel(priv);
|
2007-12-16 23:21:00 +01:00
|
|
|
if (ret) {
|
2007-12-12 06:14:21 +01:00
|
|
|
lbs_deb_assoc("ASSOC: channel: error getting channel.\n");
|
2007-12-16 23:21:00 +01:00
|
|
|
goto done;
|
2007-05-25 22:46:33 +02:00
|
|
|
}
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (assoc_req->channel == priv->curbssparams.channel)
|
2007-05-25 22:46:33 +02:00
|
|
|
goto done;
|
|
|
|
|
2007-12-12 02:03:01 +01:00
|
|
|
if (priv->mesh_dev) {
|
2007-12-13 06:32:36 +01:00
|
|
|
/* Change mesh channel first; 21.p21 firmware won't let
|
|
|
|
you change channel otherwise (even though it'll return
|
|
|
|
an error to this */
|
|
|
|
lbs_mesh_config(priv, 0, assoc_req->channel);
|
2007-12-12 02:03:01 +01:00
|
|
|
}
|
|
|
|
|
2007-05-25 22:46:33 +02:00
|
|
|
lbs_deb_assoc("ASSOC: channel: %d -> %d\n",
|
2007-12-13 06:32:36 +01:00
|
|
|
priv->curbssparams.channel, assoc_req->channel);
|
2007-05-25 22:46:33 +02:00
|
|
|
|
2007-12-11 22:54:15 +01:00
|
|
|
ret = lbs_set_channel(priv, assoc_req->channel);
|
|
|
|
if (ret < 0)
|
2007-12-12 06:14:21 +01:00
|
|
|
lbs_deb_assoc("ASSOC: channel: error setting channel.\n");
|
2007-05-25 22:46:33 +02:00
|
|
|
|
2007-12-11 22:54:15 +01:00
|
|
|
/* FIXME: shouldn't need to grab the channel _again_ after setting
|
|
|
|
* it since the firmware is supposed to return the new channel, but
|
|
|
|
* whatever... */
|
2007-12-13 04:50:21 +01:00
|
|
|
ret = lbs_update_channel(priv);
|
2007-12-16 23:21:00 +01:00
|
|
|
if (ret) {
|
2007-12-12 06:14:21 +01:00
|
|
|
lbs_deb_assoc("ASSOC: channel: error getting channel.\n");
|
2007-12-16 23:21:00 +01:00
|
|
|
goto done;
|
|
|
|
}
|
2007-05-25 22:46:33 +02:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (assoc_req->channel != priv->curbssparams.channel) {
|
2007-12-12 01:57:05 +01:00
|
|
|
lbs_deb_assoc("ASSOC: channel: failed to update channel to %d\n",
|
2007-05-25 22:46:33 +02:00
|
|
|
assoc_req->channel);
|
2007-12-12 02:03:01 +01:00
|
|
|
goto restore_mesh;
|
2007-05-25 22:46:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( assoc_req->secinfo.wep_enabled
|
|
|
|
&& (assoc_req->wep_keys[0].len
|
|
|
|
|| assoc_req->wep_keys[1].len
|
|
|
|
|| assoc_req->wep_keys[2].len
|
|
|
|
|| assoc_req->wep_keys[3].len)) {
|
|
|
|
/* Make sure WEP keys are re-sent to firmware */
|
|
|
|
set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must restart/rejoin adhoc networks after channel change */
|
2007-12-12 06:14:21 +01:00
|
|
|
set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
|
2007-05-25 22:46:33 +02:00
|
|
|
|
2007-12-12 02:03:01 +01:00
|
|
|
restore_mesh:
|
|
|
|
if (priv->mesh_dev)
|
2007-12-13 06:32:36 +01:00
|
|
|
lbs_mesh_config(priv, 1, priv->curbssparams.channel);
|
2007-12-12 02:03:01 +01:00
|
|
|
|
|
|
|
done:
|
2007-05-25 22:46:33 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_wep_keys(struct lbs_private *priv,
|
2007-12-18 06:18:05 +01:00
|
|
|
struct assoc_request *assoc_req)
|
2007-02-10 15:25:27 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
/* Set or remove WEP keys */
|
2007-12-18 06:18:05 +01:00
|
|
|
if (assoc_req->wep_keys[0].len || assoc_req->wep_keys[1].len ||
|
|
|
|
assoc_req->wep_keys[2].len || assoc_req->wep_keys[3].len)
|
|
|
|
ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_ADD, assoc_req);
|
|
|
|
else
|
|
|
|
ret = lbs_cmd_802_11_set_wep(priv, CMD_ACT_REMOVE, assoc_req);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* enable/disable the MAC's WEP packet filter */
|
2007-05-11 04:57:23 +02:00
|
|
|
if (assoc_req->secinfo.wep_enabled)
|
2007-12-08 21:04:36 +01:00
|
|
|
priv->currentpacketfilter |= CMD_ACT_MAC_WEP_ENABLE;
|
2007-02-10 15:25:27 +01:00
|
|
|
else
|
2007-12-08 21:04:36 +01:00
|
|
|
priv->currentpacketfilter &= ~CMD_ACT_MAC_WEP_ENABLE;
|
2007-12-18 06:18:05 +01:00
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_set_mac_packet_filter(priv);
|
2007-02-10 15:25:27 +01:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
mutex_lock(&priv->lock);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
/* Copy WEP keys into priv wep key fields */
|
2007-02-10 15:25:27 +01:00
|
|
|
for (i = 0; i < 4; i++) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&priv->wep_keys[i], &assoc_req->wep_keys[i],
|
2007-12-18 06:18:05 +01:00
|
|
|
sizeof(struct enc_key));
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
2007-12-08 21:04:36 +01:00
|
|
|
priv->wep_tx_keyidx = assoc_req->wep_tx_keyidx;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
mutex_unlock(&priv->lock);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
out:
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_secinfo(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2007-12-18 06:47:17 +01:00
|
|
|
uint16_t do_wpa;
|
|
|
|
uint16_t rsn = 0;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&priv->secinfo, &assoc_req->secinfo,
|
2007-11-16 00:05:47 +01:00
|
|
|
sizeof(struct lbs_802_11_security));
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_set_mac_packet_filter(priv);
|
2007-05-26 05:01:24 +02:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-06-18 18:01:12 +02:00
|
|
|
/* If RSN is already enabled, don't try to enable it again, since
|
|
|
|
* ENABLE_RSN resets internal state machines and will clobber the
|
|
|
|
* 4-way WPA handshake.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get RSN enabled/disabled */
|
2007-12-18 06:47:17 +01:00
|
|
|
ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_GET, &rsn);
|
2007-06-18 18:01:12 +02:00
|
|
|
if (ret) {
|
2007-12-12 06:14:21 +01:00
|
|
|
lbs_deb_assoc("Failed to get RSN status: %d\n", ret);
|
2007-06-18 18:01:12 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't re-enable RSN if it's already enabled */
|
2007-12-18 06:47:17 +01:00
|
|
|
do_wpa = assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled;
|
2007-06-18 18:01:12 +02:00
|
|
|
if (do_wpa == rsn)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Set RSN enabled/disabled */
|
2007-12-18 06:47:17 +01:00
|
|
|
ret = lbs_cmd_802_11_enable_rsn(priv, CMD_ACT_SET, &do_wpa);
|
2007-05-26 05:01:24 +02:00
|
|
|
|
|
|
|
out:
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_wpa_keys(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2007-10-03 16:37:45 +02:00
|
|
|
unsigned int flags = assoc_req->flags;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-10-03 16:37:45 +02:00
|
|
|
/* Work around older firmware bug where WPA unicast and multicast
|
|
|
|
* keys must be set independently. Seen in SDIO parts with firmware
|
|
|
|
* version 5.0.11p0.
|
|
|
|
*/
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-10-03 16:37:45 +02:00
|
|
|
if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
|
|
|
|
clear_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_prepare_and_send_command(priv,
|
2007-10-03 16:37:45 +02:00
|
|
|
CMD_802_11_KEY_MATERIAL,
|
|
|
|
CMD_ACT_SET,
|
|
|
|
CMD_OPTION_WAITFORRSP,
|
|
|
|
0, assoc_req);
|
|
|
|
assoc_req->flags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
|
|
|
|
clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
|
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_prepare_and_send_command(priv,
|
2007-10-03 16:37:45 +02:00
|
|
|
CMD_802_11_KEY_MATERIAL,
|
|
|
|
CMD_ACT_SET,
|
|
|
|
CMD_OPTION_WAITFORRSP,
|
|
|
|
0, assoc_req);
|
|
|
|
assoc_req->flags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 15:43:44 +01:00
|
|
|
static int assoc_helper_wpa_ie(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&priv->wpa_ie, &assoc_req->wpa_ie, assoc_req->wpa_ie_len);
|
|
|
|
priv->wpa_ie_len = assoc_req->wpa_ie_len;
|
2007-02-10 15:25:27 +01:00
|
|
|
} else {
|
2007-12-08 21:04:36 +01:00
|
|
|
memset(&priv->wpa_ie, 0, MAX_WPA_IE_LEN);
|
|
|
|
priv->wpa_ie_len = 0;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
static int should_deauth_infrastructure(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
2007-10-15 12:55:56 +02:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->connect_status != LBS_CONNECTED)
|
2007-02-10 15:25:27 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc("Deauthenticating due to new SSID\n");
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->secinfo.auth_mode != assoc_req->secinfo.auth_mode) {
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc("Deauthenticating due to new security\n");
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc("Deauthenticating due to new BSSID\n");
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
2007-05-30 18:16:13 +02:00
|
|
|
if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc("Deauthenticating due to channel switch\n");
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2007-05-30 18:16:13 +02:00
|
|
|
}
|
|
|
|
|
2007-02-10 15:25:27 +01:00
|
|
|
/* FIXME: deal with 'auto' mode somehow */
|
|
|
|
if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
|
2007-10-15 12:55:56 +02:00
|
|
|
if (assoc_req->mode != IW_MODE_INFRA) {
|
|
|
|
lbs_deb_assoc("Deauthenticating due to leaving "
|
|
|
|
"infra mode\n");
|
|
|
|
ret = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
out:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
|
2007-02-10 15:25:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
static int should_stop_adhoc(struct lbs_private *priv,
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req)
|
|
|
|
{
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->connect_status != LBS_CONNECTED)
|
2007-02-10 15:25:27 +01:00
|
|
|
return 0;
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (lbs_ssid_cmp(priv->curbssparams.ssid,
|
|
|
|
priv->curbssparams.ssid_len,
|
2007-05-29 05:54:55 +02:00
|
|
|
assoc_req->ssid, assoc_req->ssid_len) != 0)
|
2007-02-10 15:25:27 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* FIXME: deal with 'auto' mode somehow */
|
|
|
|
if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
|
2007-05-11 04:58:02 +02:00
|
|
|
if (assoc_req->mode != IW_MODE_ADHOC)
|
2007-02-10 15:25:27 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-05-25 22:46:33 +02:00
|
|
|
if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
if (assoc_req->channel != priv->curbssparams.channel)
|
2007-05-25 22:46:33 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_leave(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
void lbs_association_worker(struct work_struct *work)
|
2007-02-10 15:25:27 +01:00
|
|
|
{
|
2007-11-23 15:43:44 +01:00
|
|
|
struct lbs_private *priv = container_of(work, struct lbs_private,
|
|
|
|
assoc_work.work);
|
2007-02-10 15:25:27 +01:00
|
|
|
struct assoc_request * assoc_req = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
int find_any_ssid = 0;
|
2007-10-04 02:59:30 +02:00
|
|
|
DECLARE_MAC_BUF(mac);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
assoc_req = priv->pending_assoc_req;
|
|
|
|
priv->pending_assoc_req = NULL;
|
|
|
|
priv->in_progress_assoc_req = assoc_req;
|
|
|
|
mutex_unlock(&priv->lock);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 17:27:16 +02:00
|
|
|
if (!assoc_req)
|
|
|
|
goto done;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_assoc(
|
|
|
|
"Association Request:\n"
|
|
|
|
" flags: 0x%08lx\n"
|
|
|
|
" SSID: '%s'\n"
|
|
|
|
" chann: %d\n"
|
|
|
|
" band: %d\n"
|
|
|
|
" mode: %d\n"
|
|
|
|
" BSSID: %s\n"
|
|
|
|
" secinfo: %s%s%s\n"
|
|
|
|
" auth_mode: %d\n",
|
|
|
|
assoc_req->flags,
|
|
|
|
escape_essid(assoc_req->ssid, assoc_req->ssid_len),
|
|
|
|
assoc_req->channel, assoc_req->band, assoc_req->mode,
|
|
|
|
print_mac(mac, assoc_req->bssid),
|
|
|
|
assoc_req->secinfo.WPAenabled ? " WPA" : "",
|
|
|
|
assoc_req->secinfo.WPA2enabled ? " WPA2" : "",
|
|
|
|
assoc_req->secinfo.wep_enabled ? " WEP" : "",
|
|
|
|
assoc_req->secinfo.auth_mode);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
/* If 'any' SSID was specified, find an SSID to associate with */
|
|
|
|
if (test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)
|
2007-05-29 05:54:55 +02:00
|
|
|
&& !assoc_req->ssid_len)
|
2007-02-10 15:25:27 +01:00
|
|
|
find_any_ssid = 1;
|
|
|
|
|
|
|
|
/* But don't use 'any' SSID if there's a valid locked BSSID to use */
|
|
|
|
if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
|
2007-05-25 23:28:30 +02:00
|
|
|
if (compare_ether_addr(assoc_req->bssid, bssid_any)
|
|
|
|
&& compare_ether_addr(assoc_req->bssid, bssid_off))
|
2007-02-10 15:25:27 +01:00
|
|
|
find_any_ssid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (find_any_ssid) {
|
2007-05-11 04:58:02 +02:00
|
|
|
u8 new_mode;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_find_best_network_ssid(priv, assoc_req->ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
&assoc_req->ssid_len, assoc_req->mode, &new_mode);
|
2007-02-10 15:25:27 +01:00
|
|
|
if (ret) {
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_assoc("Could not find best network\n");
|
2007-02-10 15:25:27 +01:00
|
|
|
ret = -ENETUNREACH;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we switch to the mode of the AP */
|
2007-05-11 04:58:02 +02:00
|
|
|
if (assoc_req->mode == IW_MODE_AUTO) {
|
2007-02-10 15:25:27 +01:00
|
|
|
set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
|
|
|
|
assoc_req->mode = new_mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if the attributes being changing require deauthentication
|
|
|
|
* from the currently associated infrastructure access point.
|
|
|
|
*/
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->mode == IW_MODE_INFRA) {
|
|
|
|
if (should_deauth_infrastructure(priv, assoc_req)) {
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_send_deauthentication(priv);
|
2007-02-10 15:25:27 +01:00
|
|
|
if (ret) {
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_assoc("Deauthentication due to new "
|
2007-02-10 15:25:27 +01:00
|
|
|
"configuration request failed: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
}
|
2007-12-08 21:04:36 +01:00
|
|
|
} else if (priv->mode == IW_MODE_ADHOC) {
|
|
|
|
if (should_stop_adhoc(priv, assoc_req)) {
|
2007-11-16 00:05:47 +01:00
|
|
|
ret = lbs_stop_adhoc_network(priv);
|
2007-02-10 15:25:27 +01:00
|
|
|
if (ret) {
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_assoc("Teardown of AdHoc network due to "
|
2007-02-10 15:25:27 +01:00
|
|
|
"new configuration request failed: %d\n",
|
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send the various configuration bits to the firmware */
|
|
|
|
if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_mode(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-05-25 22:46:33 +02:00
|
|
|
if (test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_channel(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-05-25 22:46:33 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-02-10 15:25:27 +01:00
|
|
|
if ( test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)
|
|
|
|
|| test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_wep_keys(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_secinfo(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_wpa_ie(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)
|
|
|
|
|| test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
|
|
|
|
ret = assoc_helper_wpa_keys(priv, assoc_req);
|
2007-10-15 12:55:56 +02:00
|
|
|
if (ret)
|
2007-02-10 15:25:27 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SSID/BSSID should be the _last_ config option set, because they
|
|
|
|
* trigger the association attempt.
|
|
|
|
*/
|
|
|
|
if (test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)
|
|
|
|
|| test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
|
|
|
|
int success = 1;
|
|
|
|
|
|
|
|
ret = assoc_helper_associate(priv, assoc_req);
|
|
|
|
if (ret) {
|
2007-11-28 14:05:02 +01:00
|
|
|
lbs_deb_assoc("ASSOC: association unsuccessful: %d\n",
|
2007-02-10 15:25:27 +01:00
|
|
|
ret);
|
|
|
|
success = 0;
|
|
|
|
}
|
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
if (priv->connect_status != LBS_CONNECTED) {
|
2007-11-28 14:05:02 +01:00
|
|
|
lbs_deb_assoc("ASSOC: association unsuccessful, "
|
|
|
|
"not connected\n");
|
2007-02-10 15:25:27 +01:00
|
|
|
success = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
2007-11-28 14:05:02 +01:00
|
|
|
lbs_deb_assoc("ASSOC: associated to '%s', %s\n",
|
2007-12-08 21:04:36 +01:00
|
|
|
escape_essid(priv->curbssparams.ssid,
|
|
|
|
priv->curbssparams.ssid_len),
|
|
|
|
print_mac(mac, priv->curbssparams.bssid));
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_prepare_and_send_command(priv,
|
2007-08-02 17:31:18 +02:00
|
|
|
CMD_802_11_RSSI,
|
|
|
|
0, CMD_OPTION_WAITFORRSP, 0, NULL);
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-11-16 00:05:47 +01:00
|
|
|
lbs_prepare_and_send_command(priv,
|
2007-08-02 17:31:18 +02:00
|
|
|
CMD_802_11_GET_LOG,
|
|
|
|
0, CMD_OPTION_WAITFORRSP, 0, NULL);
|
2007-02-10 15:25:27 +01:00
|
|
|
} else {
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (ret) {
|
2007-05-25 17:27:16 +02:00
|
|
|
lbs_deb_assoc("ASSOC: reconfiguration attempt unsuccessful: %d\n",
|
2007-02-10 15:25:27 +01:00
|
|
|
ret);
|
|
|
|
}
|
2007-05-25 23:09:41 +02:00
|
|
|
|
2007-12-08 21:04:36 +01:00
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
priv->in_progress_assoc_req = NULL;
|
|
|
|
mutex_unlock(&priv->lock);
|
2007-02-10 15:25:27 +01:00
|
|
|
kfree(assoc_req);
|
2007-05-25 17:27:16 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
lbs_deb_leave(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Caller MUST hold any necessary locks
|
|
|
|
*/
|
2007-12-08 21:04:36 +01:00
|
|
|
struct assoc_request *lbs_get_association_request(struct lbs_private *priv)
|
2007-02-10 15:25:27 +01:00
|
|
|
{
|
|
|
|
struct assoc_request * assoc_req;
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_enter(LBS_DEB_ASSOC);
|
2007-12-08 21:04:36 +01:00
|
|
|
if (!priv->pending_assoc_req) {
|
|
|
|
priv->pending_assoc_req = kzalloc(sizeof(struct assoc_request),
|
2007-05-25 23:09:41 +02:00
|
|
|
GFP_KERNEL);
|
2007-12-08 21:04:36 +01:00
|
|
|
if (!priv->pending_assoc_req) {
|
2007-02-10 15:25:27 +01:00
|
|
|
lbs_pr_info("Not enough memory to allocate association"
|
|
|
|
" request!\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy current configuration attributes to the association request,
|
|
|
|
* but don't overwrite any that are already set.
|
|
|
|
*/
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req = priv->pending_assoc_req;
|
2007-02-10 15:25:27 +01:00
|
|
|
if (!test_bit(ASSOC_FLAG_SSID, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->ssid, &priv->curbssparams.ssid,
|
2007-05-29 05:54:55 +02:00
|
|
|
IW_ESSID_MAX_SIZE);
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->ssid_len = priv->curbssparams.ssid_len;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags))
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->channel = priv->curbssparams.channel;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
2007-05-25 23:09:41 +02:00
|
|
|
if (!test_bit(ASSOC_FLAG_BAND, &assoc_req->flags))
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->band = priv->curbssparams.band;
|
2007-05-25 23:09:41 +02:00
|
|
|
|
2007-02-10 15:25:27 +01:00
|
|
|
if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->mode = priv->mode;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->bssid, priv->curbssparams.bssid,
|
2007-02-10 15:25:27 +01:00
|
|
|
ETH_ALEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags)) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 4; i++) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->wep_keys[i], &priv->wep_keys[i],
|
2007-08-02 16:45:55 +02:00
|
|
|
sizeof(struct enc_key));
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags))
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->wep_tx_keyidx = priv->wep_tx_keyidx;
|
2007-02-10 15:25:27 +01:00
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->wpa_mcast_key, &priv->wpa_mcast_key,
|
2007-08-02 16:45:55 +02:00
|
|
|
sizeof(struct enc_key));
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->wpa_unicast_key, &priv->wpa_unicast_key,
|
2007-08-02 16:45:55 +02:00
|
|
|
sizeof(struct enc_key));
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->secinfo, &priv->secinfo,
|
2007-11-16 00:05:47 +01:00
|
|
|
sizeof(struct lbs_802_11_security));
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags)) {
|
2007-12-08 21:04:36 +01:00
|
|
|
memcpy(&assoc_req->wpa_ie, &priv->wpa_ie,
|
2007-02-10 15:25:27 +01:00
|
|
|
MAX_WPA_IE_LEN);
|
2007-12-08 21:04:36 +01:00
|
|
|
assoc_req->wpa_ie_len = priv->wpa_ie_len;
|
2007-02-10 15:25:27 +01:00
|
|
|
}
|
|
|
|
|
2007-10-15 12:55:56 +02:00
|
|
|
lbs_deb_leave(LBS_DEB_ASSOC);
|
2007-02-10 15:25:27 +01:00
|
|
|
return assoc_req;
|
|
|
|
}
|