2007-02-10 09:25:27 -05:00
|
|
|
/**
|
|
|
|
* Functions implementing wlan infrastructure and adhoc join routines,
|
|
|
|
* IOCTL handlers as well as command preperation and response routines
|
|
|
|
* for sending adhoc start, adhoc join, and association commands
|
|
|
|
* to the firmware.
|
|
|
|
*/
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/wireless.h>
|
2007-05-25 17:09:41 -04:00
|
|
|
#include <linux/etherdevice.h>
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
#include <net/iw_handler.h>
|
|
|
|
|
|
|
|
#include "host.h"
|
|
|
|
#include "decl.h"
|
|
|
|
#include "join.h"
|
|
|
|
#include "dev.h"
|
2007-05-25 17:09:41 -04:00
|
|
|
#include "assoc.h"
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function finds out the common rates between rate1 and rate2.
|
|
|
|
*
|
|
|
|
* It will fill common rates in rate1 as output if found.
|
|
|
|
*
|
|
|
|
* NOTE: Setting the MSB of the basic rates need to be taken
|
|
|
|
* care, either before or after calling this function
|
|
|
|
*
|
|
|
|
* @param adapter A pointer to wlan_adapter structure
|
|
|
|
* @param rate1 the buffer which keeps input and output
|
|
|
|
* @param rate1_size the size of rate1 buffer
|
|
|
|
* @param rate2 the buffer which keeps rate2
|
|
|
|
* @param rate2_size the size of rate2 buffer.
|
|
|
|
*
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
|
|
|
static int get_common_rates(wlan_adapter * adapter, u8 * rate1,
|
|
|
|
int rate1_size, u8 * rate2, int rate2_size)
|
|
|
|
{
|
|
|
|
u8 *ptr = rate1;
|
|
|
|
int ret = 0;
|
|
|
|
u8 tmp[30];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
memcpy(&tmp, rate1, min_t(size_t, rate1_size, sizeof(tmp)));
|
|
|
|
memset(rate1, 0, rate1_size);
|
|
|
|
|
|
|
|
/* Mask the top bit of the original values */
|
|
|
|
for (i = 0; tmp[i] && i < sizeof(tmp); i++)
|
|
|
|
tmp[i] &= 0x7F;
|
|
|
|
|
|
|
|
for (i = 0; rate2[i] && i < rate2_size; i++) {
|
|
|
|
/* Check for Card Rate in tmp, excluding the top bit */
|
|
|
|
if (strchr(tmp, rate2[i] & 0x7F)) {
|
|
|
|
/* values match, so copy the Card Rate to rate1 */
|
|
|
|
*rate1++ = rate2[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lbs_dbg_hex("rate1 (AP) rates:", tmp, sizeof(tmp));
|
|
|
|
lbs_dbg_hex("rate2 (Card) rates:", rate2, rate2_size);
|
|
|
|
lbs_dbg_hex("Common rates:", ptr, rate1_size);
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("Tx datarate is set to 0x%X\n", adapter->datarate);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
if (!adapter->is_datarate_auto) {
|
|
|
|
while (*ptr) {
|
|
|
|
if ((*ptr & 0x7f) == adapter->datarate) {
|
|
|
|
ret = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
lbs_pr_alert( "Previously set fixed data rate %#x isn't "
|
|
|
|
"compatible with the network.\n", adapter->datarate);
|
|
|
|
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
done:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_send_deauth(wlan_private * priv)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-10 22:58:02 -04:00
|
|
|
if (adapter->mode == IW_MODE_INFRA &&
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->connect_status == libertas_connected)
|
|
|
|
ret = libertas_send_deauthentication(priv);
|
|
|
|
else
|
|
|
|
ret = -ENOTSUPP;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Associate to a specific BSS discovered in a scan
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @param pbssdesc Pointer to the BSS descriptor to associate with.
|
|
|
|
*
|
|
|
|
* @return 0-success, otherwise fail
|
|
|
|
*/
|
2007-05-25 17:09:41 -04:00
|
|
|
int wlan_associate(wlan_private * priv, struct assoc_request * assoc_req)
|
2007-02-10 09:25:27 -05:00
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret;
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
ret = libertas_prepare_and_send_command(priv, cmd_802_11_authenticate,
|
|
|
|
0, cmd_option_waitforrsp,
|
2007-05-25 17:09:41 -04:00
|
|
|
0, assoc_req->bss.bssid);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
if (ret)
|
|
|
|
goto done;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* set preamble to firmware */
|
2007-08-02 10:43:44 -04:00
|
|
|
if ( (adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
|
|
|
|
&& (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->preamble = cmd_type_short_preamble;
|
|
|
|
else
|
|
|
|
adapter->preamble = cmd_type_long_preamble;
|
|
|
|
|
|
|
|
libertas_set_radio_control(priv);
|
|
|
|
|
|
|
|
ret = libertas_prepare_and_send_command(priv, cmd_802_11_associate,
|
2007-05-25 17:09:41 -04:00
|
|
|
0, cmd_option_waitforrsp, 0, assoc_req);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Start an Adhoc Network
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @param adhocssid The ssid of the Adhoc Network
|
|
|
|
* @return 0--success, -1--fail
|
|
|
|
*/
|
2007-05-25 17:09:41 -04:00
|
|
|
int libertas_start_adhoc_network(wlan_private * priv, struct assoc_request * assoc_req)
|
2007-02-10 09:25:27 -05:00
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
adapter->adhoccreate = 1;
|
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
if (adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("AdhocStart: Short preamble\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->preamble = cmd_type_short_preamble;
|
2007-08-02 10:43:44 -04:00
|
|
|
} else {
|
|
|
|
lbs_deb_join("AdhocStart: Long preamble\n");
|
|
|
|
adapter->preamble = cmd_type_long_preamble;
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
libertas_set_radio_control(priv);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel);
|
|
|
|
lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
ret = libertas_prepare_and_send_command(priv, cmd_802_11_ad_hoc_start,
|
2007-05-25 17:09:41 -04:00
|
|
|
0, cmd_option_waitforrsp, 0, assoc_req);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Join an adhoc network found in a previous scan
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @param pbssdesc Pointer to a BSS descriptor found in a previous scan
|
|
|
|
* to attempt to join
|
|
|
|
*
|
|
|
|
* @return 0--success, -1--fail
|
|
|
|
*/
|
2007-05-25 17:09:41 -04:00
|
|
|
int libertas_join_adhoc_network(wlan_private * priv, struct assoc_request * assoc_req)
|
2007-02-10 09:25:27 -05:00
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct bss_descriptor * bss = &assoc_req->bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
int ret = 0;
|
|
|
|
|
2007-05-28 23:54:55 -04:00
|
|
|
lbs_deb_join("%s: Current SSID '%s', ssid length %u\n",
|
|
|
|
__func__,
|
|
|
|
escape_essid(adapter->curbssparams.ssid,
|
|
|
|
adapter->curbssparams.ssid_len),
|
|
|
|
adapter->curbssparams.ssid_len);
|
|
|
|
lbs_deb_join("%s: requested ssid '%s', ssid length %u\n",
|
|
|
|
__func__, escape_essid(bss->ssid, bss->ssid_len),
|
|
|
|
bss->ssid_len);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* check if the requested SSID is already joined */
|
2007-05-28 23:54:55 -04:00
|
|
|
if (adapter->curbssparams.ssid_len
|
2007-05-29 00:03:31 -04:00
|
|
|
&& !libertas_ssid_cmp(adapter->curbssparams.ssid,
|
2007-05-28 23:54:55 -04:00
|
|
|
adapter->curbssparams.ssid_len,
|
|
|
|
bss->ssid, bss->ssid_len)
|
2007-05-10 22:58:02 -04:00
|
|
|
&& (adapter->mode == IW_MODE_ADHOC)) {
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join(
|
2007-02-10 09:25:27 -05:00
|
|
|
"ADHOC_J_CMD: New ad-hoc SSID is the same as current, "
|
|
|
|
"not attempting to re-join");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
/* Use shortpreamble only when both creator and card supports
|
2007-02-10 09:25:27 -05:00
|
|
|
short preamble */
|
2007-08-02 10:43:44 -04:00
|
|
|
if ( !(bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
|
|
|
|
|| !(adapter->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("AdhocJoin: Long preamble\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->preamble = cmd_type_long_preamble;
|
|
|
|
} else {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("AdhocJoin: Short preamble\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->preamble = cmd_type_short_preamble;
|
|
|
|
}
|
|
|
|
|
|
|
|
libertas_set_radio_control(priv);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel);
|
|
|
|
lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
adapter->adhoccreate = 0;
|
|
|
|
|
|
|
|
ret = libertas_prepare_and_send_command(priv, cmd_802_11_ad_hoc_join,
|
|
|
|
0, cmd_option_waitforrsp,
|
2007-05-25 17:09:41 -04:00
|
|
|
OID_802_11_SSID, assoc_req);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_stop_adhoc_network(wlan_private * priv)
|
|
|
|
{
|
|
|
|
return libertas_prepare_and_send_command(priv, cmd_802_11_ad_hoc_stop,
|
|
|
|
0, cmd_option_waitforrsp, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Send Deauthentication Request
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @return 0--success, -1--fail
|
|
|
|
*/
|
|
|
|
int libertas_send_deauthentication(wlan_private * priv)
|
|
|
|
{
|
|
|
|
return libertas_prepare_and_send_command(priv, cmd_802_11_deauthenticate,
|
|
|
|
0, cmd_option_waitforrsp, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function prepares command of authenticate.
|
|
|
|
*
|
|
|
|
* @param priv A pointer to wlan_private structure
|
|
|
|
* @param cmd A pointer to cmd_ds_command structure
|
|
|
|
* @param pdata_buf Void cast of pointer to a BSSID to authenticate with
|
|
|
|
*
|
|
|
|
* @return 0 or -1
|
|
|
|
*/
|
|
|
|
int libertas_cmd_80211_authenticate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *cmd,
|
|
|
|
void *pdata_buf)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
2007-05-10 22:56:42 -04:00
|
|
|
struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth;
|
|
|
|
int ret = -1;
|
2007-02-10 09:25:27 -05:00
|
|
|
u8 *bssid = pdata_buf;
|
|
|
|
|
2007-05-25 22:58:55 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
|
|
|
|
2007-02-10 09:25:27 -05:00
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_authenticate);
|
2007-05-10 22:56:42 -04:00
|
|
|
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate)
|
|
|
|
+ S_DS_GEN);
|
|
|
|
|
|
|
|
/* translate auth mode to 802.11 defined wire value */
|
|
|
|
switch (adapter->secinfo.auth_mode) {
|
|
|
|
case IW_AUTH_ALG_OPEN_SYSTEM:
|
|
|
|
pauthenticate->authtype = 0x00;
|
|
|
|
break;
|
|
|
|
case IW_AUTH_ALG_SHARED_KEY:
|
|
|
|
pauthenticate->authtype = 0x01;
|
|
|
|
break;
|
|
|
|
case IW_AUTH_ALG_LEAP:
|
|
|
|
pauthenticate->authtype = 0x80;
|
|
|
|
break;
|
|
|
|
default:
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("AUTH_CMD: invalid auth alg 0x%X\n",
|
2007-05-10 22:56:42 -04:00
|
|
|
adapter->secinfo.auth_mode);
|
|
|
|
goto out;
|
|
|
|
}
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
memcpy(pauthenticate->macaddr, bssid, ETH_ALEN);
|
|
|
|
|
2007-05-25 22:58:55 -04:00
|
|
|
lbs_deb_join("AUTH_CMD: BSSID is : " MAC_FMT " auth=0x%X\n",
|
|
|
|
MAC_ARG(bssid), pauthenticate->authtype);
|
2007-05-10 22:56:42 -04:00
|
|
|
ret = 0;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-10 22:56:42 -04:00
|
|
|
out:
|
2007-05-25 22:58:55 -04:00
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-05-10 22:56:42 -04:00
|
|
|
return ret;
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_cmd_80211_deauthenticate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *cmd)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
struct cmd_ds_802_11_deauthenticate *dauth = &cmd->params.deauth;
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_deauthenticate);
|
2007-05-25 23:36:54 -04:00
|
|
|
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_deauthenticate) +
|
2007-02-10 09:25:27 -05:00
|
|
|
S_DS_GEN);
|
|
|
|
|
|
|
|
/* set AP MAC address */
|
2007-05-25 23:36:54 -04:00
|
|
|
memmove(dauth->macaddr, adapter->curbssparams.bssid, ETH_ALEN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* Reason code 3 = Station is leaving */
|
|
|
|
#define REASON_CODE_STA_LEAVING 3
|
|
|
|
dauth->reasoncode = cpu_to_le16(REASON_CODE_STA_LEAVING);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_leave(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_cmd_80211_associate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *cmd, void *pdata_buf)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
struct cmd_ds_802_11_associate *passo = &cmd->params.associate;
|
|
|
|
int ret = 0;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct assoc_request * assoc_req = pdata_buf;
|
|
|
|
struct bss_descriptor * bss = &assoc_req->bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
u8 *card_rates;
|
|
|
|
u8 *pos;
|
|
|
|
int card_rates_size;
|
2007-05-25 23:36:54 -04:00
|
|
|
u16 tmpcap, tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
struct mrvlietypes_ssidparamset *ssid;
|
|
|
|
struct mrvlietypes_phyparamset *phy;
|
|
|
|
struct mrvlietypes_ssparamset *ss;
|
|
|
|
struct mrvlietypes_ratesparamset *rates;
|
|
|
|
struct mrvlietypes_rsnparamset *rsn;
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
pos = (u8 *) passo;
|
|
|
|
|
|
|
|
if (!adapter) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_associate);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
memcpy(passo->peerstaaddr, bss->bssid, sizeof(passo->peerstaaddr));
|
2007-02-10 09:25:27 -05:00
|
|
|
pos += sizeof(passo->peerstaaddr);
|
|
|
|
|
|
|
|
/* set the listen interval */
|
2007-05-25 23:36:54 -04:00
|
|
|
passo->listeninterval = cpu_to_le16(adapter->listeninterval);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
pos += sizeof(passo->capability);
|
2007-02-10 09:25:27 -05:00
|
|
|
pos += sizeof(passo->listeninterval);
|
|
|
|
pos += sizeof(passo->bcnperiod);
|
|
|
|
pos += sizeof(passo->dtimperiod);
|
|
|
|
|
|
|
|
ssid = (struct mrvlietypes_ssidparamset *) pos;
|
|
|
|
ssid->header.type = cpu_to_le16(TLV_TYPE_SSID);
|
2007-05-28 23:54:55 -04:00
|
|
|
tmplen = bss->ssid_len;
|
2007-05-25 23:41:16 -04:00
|
|
|
ssid->header.len = cpu_to_le16(tmplen);
|
2007-05-28 23:54:55 -04:00
|
|
|
memcpy(ssid->ssid, bss->ssid, tmplen);
|
2007-05-25 23:41:16 -04:00
|
|
|
pos += sizeof(ssid->header) + tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
phy = (struct mrvlietypes_phyparamset *) pos;
|
|
|
|
phy->header.type = cpu_to_le16(TLV_TYPE_PHY_DS);
|
2007-05-25 23:41:16 -04:00
|
|
|
tmplen = sizeof(phy->fh_ds.dsparamset);
|
|
|
|
phy->header.len = cpu_to_le16(tmplen);
|
2007-02-10 09:25:27 -05:00
|
|
|
memcpy(&phy->fh_ds.dsparamset,
|
2007-05-25 17:09:41 -04:00
|
|
|
&bss->phyparamset.dsparamset.currentchan,
|
2007-05-25 23:41:16 -04:00
|
|
|
tmplen);
|
|
|
|
pos += sizeof(phy->header) + tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
ss = (struct mrvlietypes_ssparamset *) pos;
|
|
|
|
ss->header.type = cpu_to_le16(TLV_TYPE_CF);
|
2007-05-25 23:41:16 -04:00
|
|
|
tmplen = sizeof(ss->cf_ibss.cfparamset);
|
|
|
|
ss->header.len = cpu_to_le16(tmplen);
|
|
|
|
pos += sizeof(ss->header) + tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
rates = (struct mrvlietypes_ratesparamset *) pos;
|
|
|
|
rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
memcpy(&rates->rates, &bss->libertas_supported_rates, WLAN_SUPPORTED_RATES);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
card_rates = libertas_supported_rates;
|
|
|
|
card_rates_size = sizeof(libertas_supported_rates);
|
|
|
|
|
|
|
|
if (get_common_rates(adapter, rates->rates, WLAN_SUPPORTED_RATES,
|
|
|
|
card_rates, card_rates_size)) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
tmplen = min_t(size_t, strlen(rates->rates), WLAN_SUPPORTED_RATES);
|
|
|
|
adapter->curbssparams.numofrates = tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
pos += sizeof(rates->header) + tmplen;
|
|
|
|
rates->header.len = cpu_to_le16(tmplen);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (assoc_req->secinfo.WPAenabled || assoc_req->secinfo.WPA2enabled) {
|
2007-02-10 09:25:27 -05:00
|
|
|
rsn = (struct mrvlietypes_rsnparamset *) pos;
|
2007-05-25 23:36:54 -04:00
|
|
|
/* WPA_IE or WPA2_IE */
|
|
|
|
rsn->header.type = cpu_to_le16((u16) assoc_req->wpa_ie[0]);
|
|
|
|
tmplen = (u16) assoc_req->wpa_ie[1];
|
|
|
|
rsn->header.len = cpu_to_le16(tmplen);
|
|
|
|
memcpy(rsn->rsnie, &assoc_req->wpa_ie[2], tmplen);
|
2007-02-10 09:25:27 -05:00
|
|
|
lbs_dbg_hex("ASSOC_CMD: RSN IE", (u8 *) rsn,
|
2007-05-25 23:36:54 -04:00
|
|
|
sizeof(rsn->header) + tmplen);
|
|
|
|
pos += sizeof(rsn->header) + tmplen;
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update curbssparams */
|
2007-05-25 23:36:54 -04:00
|
|
|
adapter->curbssparams.channel = bss->phyparamset.dsparamset.currentchan;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* Copy the infra. association rates into Current BSS state structure */
|
|
|
|
memcpy(&adapter->curbssparams.datarates, &rates->rates,
|
2007-05-25 23:36:54 -04:00
|
|
|
min_t(size_t, sizeof(adapter->curbssparams.datarates),
|
|
|
|
cpu_to_le16(rates->header.len)));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
lbs_deb_join("ASSOC_CMD: rates->header.len = %d\n",
|
|
|
|
cpu_to_le16(rates->header.len));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (libertas_parse_dnld_countryinfo_11d(priv, bss)) {
|
2007-02-10 09:25:27 -05:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->size = cpu_to_le16((u16) (pos - (u8 *) passo) + S_DS_GEN);
|
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
/* set the capability info */
|
|
|
|
tmpcap = (bss->capability & CAPINFO_MASK);
|
|
|
|
if (bss->mode == IW_MODE_INFRA)
|
|
|
|
tmpcap |= WLAN_CAPABILITY_ESS;
|
|
|
|
passo->capability = cpu_to_le16(tmpcap);
|
|
|
|
lbs_deb_join("ASSOC_CMD: capability=%4X CAPINFO_MASK=%4X\n",
|
2007-05-25 23:36:54 -04:00
|
|
|
tmpcap, CAPINFO_MASK);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_cmd_80211_ad_hoc_start(wlan_private * priv,
|
2007-05-25 17:09:41 -04:00
|
|
|
struct cmd_ds_command *cmd, void *pdata_buf)
|
2007-02-10 09:25:27 -05:00
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
struct cmd_ds_802_11_ad_hoc_start *adhs = &cmd->params.ads;
|
|
|
|
int ret = 0;
|
|
|
|
int cmdappendsize = 0;
|
|
|
|
int i;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct assoc_request * assoc_req = pdata_buf;
|
2007-08-02 10:43:44 -04:00
|
|
|
u16 tmpcap = 0;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
if (!adapter) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_ad_hoc_start);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the parameters for 2 data structures:
|
|
|
|
* 1. cmd_ds_802_11_ad_hoc_start command
|
|
|
|
* 2. adapter->scantable[i]
|
|
|
|
*
|
|
|
|
* Driver will fill up SSID, bsstype,IBSS param, Physical Param,
|
|
|
|
* probe delay, and cap info.
|
|
|
|
*
|
|
|
|
* Firmware will fill up beacon period, DTIM, Basic rates
|
|
|
|
* and operational rates.
|
|
|
|
*/
|
|
|
|
|
|
|
|
memset(adhs->SSID, 0, IW_ESSID_MAX_SIZE);
|
2007-05-28 23:54:55 -04:00
|
|
|
memcpy(adhs->SSID, assoc_req->ssid, assoc_req->ssid_len);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-28 23:54:55 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: SSID '%s', ssid length %u\n",
|
|
|
|
escape_essid(assoc_req->ssid, assoc_req->ssid_len),
|
|
|
|
assoc_req->ssid_len);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* set the BSS type */
|
|
|
|
adhs->bsstype = cmd_bss_type_ibss;
|
2007-05-25 17:09:41 -04:00
|
|
|
adapter->mode = IW_MODE_ADHOC;
|
2007-05-25 23:36:54 -04:00
|
|
|
adhs->beaconperiod = cpu_to_le16(adapter->beaconperiod);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* set Physical param set */
|
|
|
|
#define DS_PARA_IE_ID 3
|
|
|
|
#define DS_PARA_IE_LEN 1
|
|
|
|
|
|
|
|
adhs->phyparamset.dsparamset.elementid = DS_PARA_IE_ID;
|
|
|
|
adhs->phyparamset.dsparamset.len = DS_PARA_IE_LEN;
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
WARN_ON(!assoc_req->channel);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: Creating ADHOC on channel %d\n",
|
2007-05-25 23:36:54 -04:00
|
|
|
assoc_req->channel);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
adhs->phyparamset.dsparamset.currentchan = assoc_req->channel;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* set IBSS param set */
|
|
|
|
#define IBSS_PARA_IE_ID 6
|
|
|
|
#define IBSS_PARA_IE_LEN 2
|
|
|
|
|
|
|
|
adhs->ssparamset.ibssparamset.elementid = IBSS_PARA_IE_ID;
|
|
|
|
adhs->ssparamset.ibssparamset.len = IBSS_PARA_IE_LEN;
|
2007-05-25 23:36:54 -04:00
|
|
|
adhs->ssparamset.ibssparamset.atimwindow = cpu_to_le16(adapter->atimwindow);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* set capability info */
|
2007-08-02 10:43:44 -04:00
|
|
|
tmpcap = WLAN_CAPABILITY_IBSS;
|
2007-05-25 17:09:41 -04:00
|
|
|
if (assoc_req->secinfo.wep_enabled) {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: WEP enabled, setting privacy on\n");
|
2007-08-02 10:43:44 -04:00
|
|
|
tmpcap |= WLAN_CAPABILITY_PRIVACY;
|
2007-02-10 09:25:27 -05:00
|
|
|
} else {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: WEP disabled, setting privacy off\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
2007-08-02 10:43:44 -04:00
|
|
|
adhs->capability = cpu_to_le16(tmpcap);
|
|
|
|
|
|
|
|
/* probedelay */
|
|
|
|
adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
memset(adhs->datarate, 0, sizeof(adhs->datarate));
|
|
|
|
|
|
|
|
if (adapter->adhoc_grate_enabled) {
|
|
|
|
memcpy(adhs->datarate, libertas_adhoc_rates_g,
|
|
|
|
min(sizeof(adhs->datarate), sizeof(libertas_adhoc_rates_g)));
|
|
|
|
} else {
|
|
|
|
memcpy(adhs->datarate, libertas_adhoc_rates_b,
|
|
|
|
min(sizeof(adhs->datarate), sizeof(libertas_adhoc_rates_b)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the last non zero */
|
|
|
|
for (i = 0; i < sizeof(adhs->datarate) && adhs->datarate[i]; i++) ;
|
|
|
|
|
|
|
|
adapter->curbssparams.numofrates = i;
|
|
|
|
|
|
|
|
/* Copy the ad-hoc creating rates into Current BSS state structure */
|
|
|
|
memcpy(&adapter->curbssparams.datarates,
|
|
|
|
&adhs->datarate, adapter->curbssparams.numofrates);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: rates=%02x %02x %02x %02x \n",
|
2007-02-10 09:25:27 -05:00
|
|
|
adhs->datarate[0], adhs->datarate[1],
|
|
|
|
adhs->datarate[2], adhs->datarate[3]);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: AD HOC Start command is ready\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
if (libertas_create_dnld_countryinfo_11d(priv)) {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_S_CMD: dnld_countryinfo_11d failed\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_start) +
|
|
|
|
S_DS_GEN + cmdappendsize);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
done:
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_cmd_80211_ad_hoc_stop(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *cmd)
|
|
|
|
{
|
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_ad_hoc_stop);
|
|
|
|
cmd->size = cpu_to_le16(S_DS_GEN);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_cmd_80211_ad_hoc_join(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *cmd, void *pdata_buf)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
2007-08-02 10:43:44 -04:00
|
|
|
struct cmd_ds_802_11_ad_hoc_join *join_cmd = &cmd->params.adj;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct assoc_request * assoc_req = pdata_buf;
|
|
|
|
struct bss_descriptor *bss = &assoc_req->bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
int cmdappendsize = 0;
|
|
|
|
int ret = 0;
|
|
|
|
u8 *card_rates;
|
|
|
|
int card_rates_size;
|
|
|
|
int i;
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
cmd->command = cpu_to_le16(cmd_802_11_ad_hoc_join);
|
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->bss.type = cmd_bss_type_ibss;
|
|
|
|
join_cmd->bss.beaconperiod = cpu_to_le16(bss->beaconperiod);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
memcpy(&join_cmd->bss.bssid, &bss->bssid, ETH_ALEN);
|
|
|
|
memcpy(&join_cmd->bss.ssid, &bss->ssid, bss->ssid_len);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
memcpy(&join_cmd->bss.phyparamset, &bss->phyparamset,
|
|
|
|
sizeof(union ieeetypes_phyparamset));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
memcpy(&join_cmd->bss.ssparamset, &bss->ssparamset,
|
|
|
|
sizeof(union IEEEtypes_ssparamset));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->bss.capability = cpu_to_le16(bss->capability & CAPINFO_MASK);
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_J_CMD: tmpcap=%4X CAPINFO_MASK=%4X\n",
|
2007-08-02 10:43:44 -04:00
|
|
|
bss->capability, CAPINFO_MASK);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* information on BSSID descriptor passed to FW */
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join(
|
|
|
|
"ADHOC_J_CMD: BSSID = " MAC_FMT ", SSID = '%s'\n",
|
2007-08-02 10:43:44 -04:00
|
|
|
MAC_ARG(join_cmd->bss.bssid), join_cmd->bss.ssid);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* failtimeout */
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* probedelay */
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->probedelay = cpu_to_le16(cmd_scan_probe_delay_time);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* Copy Data rates from the rates recorded in scan response */
|
2007-08-02 10:43:44 -04:00
|
|
|
memset(join_cmd->bss.datarates, 0, sizeof(join_cmd->bss.datarates));
|
|
|
|
memcpy(join_cmd->bss.datarates, bss->datarates,
|
|
|
|
min(sizeof(join_cmd->bss.datarates), sizeof(bss->datarates)));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
card_rates = libertas_supported_rates;
|
|
|
|
card_rates_size = sizeof(libertas_supported_rates);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
adapter->curbssparams.channel = bss->channel;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
if (get_common_rates(adapter, join_cmd->bss.datarates,
|
|
|
|
sizeof(join_cmd->bss.datarates),
|
2007-02-10 09:25:27 -05:00
|
|
|
card_rates, card_rates_size)) {
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_J_CMD: get_common_rates returns error.\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the last non zero */
|
2007-08-02 10:43:44 -04:00
|
|
|
for (i = 0; i < sizeof(join_cmd->bss.datarates)
|
|
|
|
&& join_cmd->bss.datarates[i]; i++) ;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
adapter->curbssparams.numofrates = i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy the adhoc joining rates to Current BSS State structure
|
|
|
|
*/
|
|
|
|
memcpy(adapter->curbssparams.datarates,
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->bss.datarates,
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->curbssparams.numofrates);
|
|
|
|
|
2007-08-02 10:43:44 -04:00
|
|
|
join_cmd->bss.ssparamset.ibssparamset.atimwindow =
|
2007-05-25 17:09:41 -04:00
|
|
|
cpu_to_le16(bss->atimwindow);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (assoc_req->secinfo.wep_enabled) {
|
2007-08-02 10:43:44 -04:00
|
|
|
u16 tmp = le16_to_cpu(join_cmd->bss.capability);
|
|
|
|
tmp |= WLAN_CAPABILITY_PRIVACY;
|
|
|
|
join_cmd->bss.capability = cpu_to_le16(tmp);
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (adapter->psmode == wlan802_11powermodemax_psp) {
|
|
|
|
/* wake up first */
|
2007-05-25 23:36:54 -04:00
|
|
|
__le32 Localpsmode;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
Localpsmode = cpu_to_le32(wlan802_11powermodecam);
|
2007-02-10 09:25:27 -05:00
|
|
|
ret = libertas_prepare_and_send_command(priv,
|
|
|
|
cmd_802_11_ps_mode,
|
|
|
|
cmd_act_set,
|
|
|
|
0, 0, &Localpsmode);
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (libertas_parse_dnld_countryinfo_11d(priv, bss)) {
|
2007-02-10 09:25:27 -05:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ad_hoc_join) +
|
|
|
|
S_DS_GEN + cmdappendsize);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_ret_80211_associate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
union iwreq_data wrqu;
|
|
|
|
struct ieeetypes_assocrsp *passocrsp;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct bss_descriptor * bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (!adapter->in_progress_assoc_req) {
|
|
|
|
lbs_deb_join("ASSOC_RESP: no in-progress association request\n");
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
bss = &adapter->in_progress_assoc_req->bss;
|
|
|
|
|
2007-02-10 09:25:27 -05:00
|
|
|
passocrsp = (struct ieeetypes_assocrsp *) & resp->params;
|
|
|
|
|
2007-05-25 23:36:54 -04:00
|
|
|
if (le16_to_cpu(passocrsp->statuscode)) {
|
2007-02-10 09:25:27 -05:00
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join("ASSOC_RESP: Association failed, status code = %d\n",
|
2007-05-25 23:36:54 -04:00
|
|
|
le16_to_cpu(passocrsp->statuscode));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
lbs_dbg_hex("ASSOC_RESP:", (void *)&resp->params,
|
|
|
|
le16_to_cpu(resp->size) - S_DS_GEN);
|
|
|
|
|
|
|
|
/* Send a Media Connected event, according to the Spec */
|
|
|
|
adapter->connect_status = libertas_connected;
|
|
|
|
|
2007-05-28 23:54:55 -04:00
|
|
|
lbs_deb_join("ASSOC_RESP: assocated to '%s'\n",
|
|
|
|
escape_essid(bss->ssid, bss->ssid_len));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
/* Update current SSID and BSSID */
|
2007-05-28 23:54:55 -04:00
|
|
|
memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE);
|
|
|
|
adapter->curbssparams.ssid_len = bss->ssid_len;
|
2007-05-25 17:09:41 -04:00
|
|
|
memcpy(adapter->curbssparams.bssid, bss->bssid, ETH_ALEN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ASSOC_RESP: currentpacketfilter is %x\n",
|
2007-02-10 09:25:27 -05:00
|
|
|
adapter->currentpacketfilter);
|
|
|
|
|
|
|
|
adapter->SNR[TYPE_RXPD][TYPE_AVG] = 0;
|
|
|
|
adapter->NF[TYPE_RXPD][TYPE_AVG] = 0;
|
|
|
|
|
|
|
|
memset(adapter->rawSNR, 0x00, sizeof(adapter->rawSNR));
|
|
|
|
memset(adapter->rawNF, 0x00, sizeof(adapter->rawNF));
|
|
|
|
adapter->nextSNRNF = 0;
|
|
|
|
adapter->numSNRNF = 0;
|
|
|
|
|
2007-05-25 13:05:16 -04:00
|
|
|
netif_carrier_on(priv->dev);
|
|
|
|
netif_wake_queue(priv->dev);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 12:06:56 -04:00
|
|
|
netif_carrier_on(priv->mesh_dev);
|
|
|
|
netif_wake_queue(priv->mesh_dev);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ASSOC_RESP: Associated \n");
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN);
|
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
2007-05-25 13:05:16 -04:00
|
|
|
wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_ret_80211_disassociate(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_leave(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_ret_80211_ad_hoc_start(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
|
|
|
wlan_adapter *adapter = priv->adapter;
|
|
|
|
int ret = 0;
|
|
|
|
u16 command = le16_to_cpu(resp->command);
|
|
|
|
u16 result = le16_to_cpu(resp->result);
|
|
|
|
struct cmd_ds_802_11_ad_hoc_result *padhocresult;
|
|
|
|
union iwreq_data wrqu;
|
2007-05-25 17:09:41 -04:00
|
|
|
struct bss_descriptor *bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
padhocresult = &resp->params.result;
|
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: size = %d\n", le16_to_cpu(resp->size));
|
|
|
|
lbs_deb_join("ADHOC_RESP: command = %x\n", command);
|
|
|
|
lbs_deb_join("ADHOC_RESP: result = %x\n", result);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 17:09:41 -04:00
|
|
|
if (!adapter->in_progress_assoc_req) {
|
|
|
|
lbs_deb_join("ADHOC_RESP: no in-progress association request\n");
|
|
|
|
ret = -1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
bss = &adapter->in_progress_assoc_req->bss;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Join result code 0 --> SUCCESS
|
|
|
|
*/
|
|
|
|
if (result) {
|
2007-05-25 17:09:41 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: failed\n");
|
2007-02-10 09:25:27 -05:00
|
|
|
if (adapter->connect_status == libertas_connected) {
|
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
}
|
2007-05-25 11:27:16 -04:00
|
|
|
ret = -1;
|
|
|
|
goto done;
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now the join cmd should be successful
|
|
|
|
* If BSSID has changed use SSID to compare instead of BSSID
|
|
|
|
*/
|
2007-05-28 23:54:55 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: associated to '%s'\n",
|
|
|
|
escape_essid(bss->ssid, bss->ssid_len));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* Send a Media Connected event, according to the Spec */
|
|
|
|
adapter->connect_status = libertas_connected;
|
|
|
|
|
|
|
|
if (command == cmd_ret_802_11_ad_hoc_start) {
|
|
|
|
/* Update the created network descriptor with the new BSSID */
|
2007-08-02 11:18:23 -04:00
|
|
|
memcpy(bss->bssid, padhocresult->bssid, ETH_ALEN);
|
2007-02-10 09:25:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the BSSID from the joined/started descriptor */
|
2007-05-25 17:09:41 -04:00
|
|
|
memcpy(&adapter->curbssparams.bssid, bss->bssid, ETH_ALEN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
/* Set the new SSID to current SSID */
|
2007-05-28 23:54:55 -04:00
|
|
|
memcpy(&adapter->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE);
|
|
|
|
adapter->curbssparams.ssid_len = bss->ssid_len;
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 13:05:16 -04:00
|
|
|
netif_carrier_on(priv->dev);
|
|
|
|
netif_wake_queue(priv->dev);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 12:06:56 -04:00
|
|
|
netif_carrier_on(priv->mesh_dev);
|
|
|
|
netif_wake_queue(priv->mesh_dev);
|
|
|
|
|
2007-02-10 09:25:27 -05:00
|
|
|
memset(&wrqu, 0, sizeof(wrqu));
|
|
|
|
memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN);
|
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
2007-05-25 13:05:16 -04:00
|
|
|
wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: - Joined/Started Ad Hoc\n");
|
2007-05-25 16:46:33 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: channel = %d\n", adapter->curbssparams.channel);
|
2007-05-25 17:27:31 -04:00
|
|
|
lbs_deb_join("ADHOC_RESP: BSSID = " MAC_FMT "\n",
|
|
|
|
MAC_ARG(padhocresult->BSSID));
|
2007-02-10 09:25:27 -05:00
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
done:
|
|
|
|
lbs_deb_leave_args(LBS_DEB_JOIN, "ret %d", ret);
|
2007-02-10 09:25:27 -05:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int libertas_ret_80211_ad_hoc_stop(wlan_private * priv,
|
|
|
|
struct cmd_ds_command *resp)
|
|
|
|
{
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_enter(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
|
|
|
|
libertas_mac_event_disconnected(priv);
|
|
|
|
|
2007-05-25 11:27:16 -04:00
|
|
|
lbs_deb_leave(LBS_DEB_JOIN);
|
2007-02-10 09:25:27 -05:00
|
|
|
return 0;
|
|
|
|
}
|