📄 wlan_cmd.c
字号:
if (get_common_rates(Adapter, Adapter->CurBssParams.DataRates,
sizeof(Adapter->CurBssParams.DataRates),
card_rates, card_rates_size)) {
return -EINVAL;
}
for (i=0; i < MIN(sizeof(Adapter->CurBssParams.DataRates),IW_MAX_BITRATES)
&& Adapter->CurBssParams.DataRates[i]; i++) {
}
Adapter->CurBssParams.NumOfRates = i;
#ifdef WPA
if ((FW_IS_WPA_ENABLED(Adapter)) && (Adapter->SecInfo.WPAEnabled) ) {
PWLAN_802_11_ASSOCIATION_INFORMATION pAdapterAssoInfo;
PRINTK1("Inside the WPA associate command\n");
/*
* reset the cap and interval info according
* to OID_802_11_ASSOCIATION_INFO
*/
pAdapterAssoInfo = (PWLAN_802_11_ASSOCIATION_INFORMATION)
Adapter->AssocInfoBuffer;
if (pAdapterAssoInfo->AvailableRequestFixedIEs &
WLAN_802_11_AI_REQFI_LISTENINTERVAL) {
asst->ListenInterval = pAdapterAssoInfo->
RequestFixedIEs.ListenInterval;
} else {
pAdapterAssoInfo->AvailableRequestFixedIEs |=
WLAN_802_11_AI_REQFI_LISTENINTERVAL;
pAdapterAssoInfo->RequestFixedIEs.ListenInterval
= asst->ListenInterval;
}
/* ToDo :not sure what to do with CurrentApAddress field */
pAdapterAssoInfo->AvailableRequestFixedIEs |=
WLAN_802_11_AI_REQFI_CURRENTAPADDRESS;
memmove(pAdapterAssoInfo->RequestFixedIEs.CurrentAPAddress,
asst->DestMacAddr, ETH_ALEN);
/*
* add SSID, supported rates,
* and wpa IE info associate request
*/
{
u8 tmpBuf[500];
u32 ulReqIELen = 0;
u32 ulCurOffset = 0;
u8 ucElemID;
u8 ucElemLen;
unsigned char *pIEBuf,
*pRequestIEBuf;
memmove(tmpBuf, Adapter->AssocInfoBuffer +
pAdapterAssoInfo->
OffsetResponseIEs,
pAdapterAssoInfo->
ResponseIELength);
pIEBuf = Adapter->IEBuffer[Adapter->
ulAttemptedBSSIDIndex].VariableIE;
pRequestIEBuf = Adapter->AssocInfoBuffer +
pAdapterAssoInfo->OffsetRequestIEs;
PRINTK1("Variable IE Length is %d\n",
(u32) (Adapter->BSSIDList
[Adapter->ulAttemptedBSSIDIndex].
IELength - MRVL_FIXED_IE_SIZE));
while (ulCurOffset < (Adapter->
BSSIDList[Adapter->
ulAttemptedBSSIDIndex].
IELength - MRVL_FIXED_IE_SIZE)
&& (Adapter->BSSIDList[Adapter->
ulAttemptedBSSIDIndex].IELength
> 12)) {
ucElemID = *(pIEBuf + ulCurOffset);
ucElemLen = *(pIEBuf + ulCurOffset + 1);
// PRINTK1("uc ElemID : %x\n", ucElemID);
/* wpa, supported rate, or wpa */
if ((ucElemID == SSID) ||
(ucElemID == SUPPORTED_RATES)
|| (ucElemID == WPA_IE)) {
/*
* copy the IE to association
* information buffer
*/
memmove(pRequestIEBuf +
ulReqIELen,
pIEBuf +
ulCurOffset,
ucElemLen + 2);
ulReqIELen += (ucElemLen + 2);
PRINTK1("Copied elemID = "
"0x%x, %d bytes into "
"request ID \n",
ucElemID, (u32) ulReqIELen);
HEXDUMP("RequestIE: ",
pRequestIEBuf, 32);
}
ulCurOffset = ulCurOffset + 2 + ucElemLen;
}
pAdapterAssoInfo->RequestIELength = ulReqIELen;
pAdapterAssoInfo->OffsetResponseIEs =
pAdapterAssoInfo->OffsetRequestIEs +
pAdapterAssoInfo->RequestIELength;
memmove(Adapter->AssocInfoBuffer +
pAdapterAssoInfo->OffsetResponseIEs, tmpBuf,
pAdapterAssoInfo->ResponseIELength);
}
/* Removed sending RSN_AUTH_SUITES command as
* it is already sent before coming here */
}
#endif /* WPA */
/* set failure-time-out */
asst->TimeOut = wlan_cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); // 2 sec in TU
/* set the Capability info */
memcpy(&TmpCap, &Adapter->capInfo, sizeof(asst->CapInfo));
TmpCap &= CAPINFO_MASK;
PRINTK("TmpCap=%4X CAPINFO_MASK=%4X\n", TmpCap, CAPINFO_MASK);
memcpy(&asst->CapInfo, &TmpCap, sizeof(asst->CapInfo));
// set preamble to firmware
if (Adapter->capInfo.ShortPreamble
&& Adapter->BSSIDList[i].Cap.ShortPreamble) {
Adapter->Preamble = HostCmd_TYPE_SHORT_PREAMBLE;
} else {
Adapter->Preamble = HostCmd_TYPE_LONG_PREAMBLE;
}
SetRadioControl(priv);
/*
* association was done after scanning,
* possibly trying to connect to
* AP that sends out beacon with blank SSID
*/
asst->BlankSsid = wlan_cpu_to_le32(1);
/* set IBSS field */
if (Adapter->BSSIDList[i].InfrastructureMode ==
Wlan802_11Infrastructure)
asst->CapInfo.Ess = 1; /* HostCmd_CAPINFO_ESS */
else
asst->CapInfo.Ibss = 1; /* HostCmd_CAPINFO_IBSS */
/* set Privacy field */
if (Adapter->SecInfo.WEPStatus == Wlan802_11WEPEnabled) {
PRINTK1("WEPStatus set, setting HostCmd_CAPINFO_PRIVACY bit\n");
asst->CapInfo.Privacy = 1; /* HostCmd_CAPINFO_PRIVACY */
}
/* set the listen interval */
asst->ListenInterval = wlan_cpu_to_le16(Adapter->ListenInterval);
Adapter->bIsAssociationInProgress = TRUE;
/* need to report disconnect event if currently associated */
if (Adapter->CurBssParams.ssid.SsidLength != 0) {
MacEventDisconnected(priv);
}
PRINTK1("Peer Mac Address = %x:%x:%x:%x:%x:%x\n",
asst->DestMacAddr[0], asst->DestMacAddr[1],
asst->DestMacAddr[2], asst->DestMacAddr[3],
asst->DestMacAddr[4], asst->DestMacAddr[5]);
PRINTK1("CapInfo: Ess=%d Ibss=%d CfPollable=%d CfPollRqst=%d "
"Privacy=%d ShortPreamble=%d Pbcc=%d ChanAgility=%d\n",
asst->CapInfo.Ess, asst->CapInfo.Ibss,
asst->CapInfo.CfPollable, asst->CapInfo.CfPollRqst,
asst->CapInfo.Privacy, asst->CapInfo.ShortPreamble,
asst->CapInfo.Pbcc, asst->CapInfo.ChanAgility);
PRINTK1("Listen Interval SSID = %d\n", asst->ListenInterval);
PRINTK1("Blank Sssid = 0x%08x\n", asst->BlankSsid);
PRINTK1("HWAC - ASSOCIATION command is ready\n");
LEAVE();
return ret;
}
#endif /* OLD ASSOCIATION */
/*
* New commands - for ioctl's
*/
static inline int wlan_cmd_802_11_deauthenticate(wlan_private * priv,
HostCmd_DS_COMMAND * cmd)
{
wlan_adapter *Adapter = priv->adapter;
ENTER();
if (cmd->Command == HostCmd_CMD_802_11_DEAUTHENTICATE) {
HostCmd_DS_802_11_DEAUTHENTICATE *dauth = &cmd->params.deauth;
cmd->Command = wlan_cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE);
cmd->Size =
wlan_cpu_to_le16(sizeof(HostCmd_DS_802_11_DEAUTHENTICATE) + S_DS_GEN);
/* set AP MAC address */
memmove(dauth->MacAddr, Adapter->CurrentBSSID,
MRVDRV_ETH_ADDR_LEN);
/* Reason code 3 = Station is leaving */
dauth->ReasonCode = wlan_cpu_to_le16(3);
}
else if (cmd->Command == HostCmd_CMD_802_11_DISASSOCIATE) {
HostCmd_DS_802_11_DISASSOCIATE *dassociate =
&cmd->params.dassociate;
cmd->Command = wlan_cpu_to_le16(HostCmd_CMD_802_11_DISASSOCIATE);
cmd->Size = wlan_cpu_to_le16(sizeof(HostCmd_DS_802_11_DISASSOCIATE) + S_DS_GEN);
/* set AP MAC address */
memmove(dassociate->DestMacAddr, Adapter->CurrentBSSID,
MRVDRV_ETH_ADDR_LEN);
/* Reason code 0 = Station is leaving */
dassociate->ReasonCode = wlan_cpu_to_le16(0);
}
// ResetRxPDQ(Adapter);
// TODO:Figure out we need to take care of anything
LEAVE();
return 0;
}
/* Needs OID,Info buffer and action to be paased */
#define WEP_40_BIT_LEN 5
#define WEP_104_BIT_LEN 13
static inline int wlan_cmd_802_11_set_wep(wlan_private * priv,
HostCmd_DS_COMMAND * cmd, u32 PendingOID,
void *InformationBuffer, u16 CmdOption)
{
HostCmd_DS_802_11_SET_WEP *wep = &cmd->params.wep;
wlan_adapter *Adapter = priv->adapter;
ENTER();
if (PendingOID == OID_802_11_ADD_WEP) {
cmd->Command = wlan_cpu_to_le16(HostCmd_CMD_802_11_SET_WEP);
cmd->Size = wlan_cpu_to_le16((sizeof(HostCmd_DS_802_11_SET_WEP)) + S_DS_GEN);
wep->Action = wlan_cpu_to_le16(HostCmd_ACT_ADD);
//default tx key index
wep->KeyIndex = wlan_cpu_to_le16(Adapter->CurrentWepKeyIndex &
HostCmd_WEP_KEY_INDEX_MASK);
PRINTK1("Tx Key Index: %u\n", wep->KeyIndex);
switch (Adapter->WepKey[0].KeyLength) {
case WEP_40_BIT_LEN:
wep->WEPTypeForKey1 = HostCmd_TYPE_WEP_40_BIT;
memmove(wep->WEP1, Adapter->WepKey[0].KeyMaterial, Adapter->WepKey[0].KeyLength);
break;
case WEP_104_BIT_LEN:
wep->WEPTypeForKey1 = HostCmd_TYPE_WEP_104_BIT;
memmove(wep->WEP1, Adapter->WepKey[0].KeyMaterial, Adapter->WepKey[0].KeyLength);
break;
case 0:
break;
default:
PRINTK("Key1 Length = %d is incorrect\n", Adapter->WepKey[0].KeyLength);
LEAVE();
return -1;
}
switch (Adapter->WepKey[1].KeyLength) {
case WEP_40_BIT_LEN:
wep->WEPTypeForKey2 = HostCmd_TYPE_WEP_40_BIT;
memmove(wep->WEP2, Adapter->WepKey[1].KeyMaterial, Adapter->WepKey[1].KeyLength);
break;
case WEP_104_BIT_LEN:
wep->WEPTypeForKey2 = HostCmd_TYPE_WEP_104_BIT;
memmove(wep->WEP2, Adapter->WepKey[1].KeyMaterial, Adapter->WepKey[1].KeyLength);
break;
case 0:
break;
default:
PRINTK("Key2 Length = %d is incorrect\n", Adapter->WepKey[1].KeyLength);
LEAVE();
return -1;
}
switch (Adapter->WepKey[2].KeyLength) {
case WEP_40_BIT_LEN:
wep->WEPTypeForKey3 = HostCmd_TYPE_WEP_40_BIT;
memmove(wep->WEP3, Adapter->WepKey[2].KeyMaterial, Adapter->WepKey[2].KeyLength);
break;
case WEP_104_BIT_LEN:
wep->WEPTypeForKey3 = HostCmd_TYPE_WEP_104_BIT;
memmove(wep->WEP3, Adapter->WepKey[2].KeyMaterial, Adapter->WepKey[2].KeyLength);
break;
case 0:
break;
default:
PRINTK("Key3 Length = %d is incorrect\n", Adapter->WepKey[2].KeyLength);
LEAVE();
return -1;
}
switch (Adapter->WepKey[3].KeyLength) {
case WEP_40_BIT_LEN:
wep->WEPTypeForKey4 = HostCmd_TYPE_WEP_40_BIT;
memmove(wep->WEP4, Adapter->WepKey[3].KeyMaterial, Adapter->WepKey[3].KeyLength);
break;
case WEP_104_BIT_LEN:
wep->WEPTypeForKey4 = HostCmd_TYPE_WEP_104_BIT;
memmove(wep->WEP4, Adapter->WepKey[3].KeyMaterial, Adapter->WepKey[3].KeyLength);
break;
case 0:
break;
default:
PRINTK("Key4 Length = %d is incorrect\n", Adapter->WepKey[3].KeyLength);
LEAVE();
return -1;
}
}
else if (PendingOID == OID_802_11_REMOVE_WEP) {
cmd->Command = wlan_cpu_to_le16(HostCmd_CMD_802_11_SET_WEP);
cmd->Size = wlan_cpu_to_le16((sizeof(HostCmd_DS_802_11_SET_WEP)) + S_DS_GEN);
wep->Action = wlan_cpu_to_le16(HostCmd_ACT_REMOVE);
//default tx key index
wep->KeyIndex = wlan_cpu_to_le16((u16) (Adapter->CurrentWepKeyIndex &
(u32) HostCmd_WEP_KEY_INDEX_MASK));
}
LEAVE();
return 0;
}
/*
* Needs a infoBuf to be transferred
*/
static inline int wlan_cmd_802_11_ad_hoc_start(wlan_private * priv,
CmdCtrlNode * cmdnode,
void *InformationBuffer)
{
int ret = 0;
wlan_adapter *Adapter = priv->adapter;
HostCmd_DS_COMMAND *cmd =
(HostCmd_DS_COMMAND *) cmdnode->BufVirtualAddr;
HostCmd_DS_802_11_AD_HOC_START *adhs = &cmd->params.ads;
int i, j;
#ifdef MULTI_BANDS
HostCmd_DS_802_11_BAND_CONFIG bc;
#endif /* MULTI BANDS */
u16 TmpCap;
ENTER();
cmd->Size = wlan_cpu_to_le16(sizeof(HostCmd_DS_802_11_AD_HOC_START) + S_DS_GEN);
cmd->Command = wlan_cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_START);
if (Adapter->AdHocCreated && Adapter->ulNumOfBSSIDs)
Adapter->ulNumOfBSSIDs--;
i = Adapter->ulNumOfBSSIDs;
/* add a new entry in the BSSID list */
if (Adapter->ulNumOfBSSIDs < MRVDRV_MAX_BSSID_LIST) {
Adapter->ulAttemptedBSSIDIndex = i;
Adapter->ulNumOfBSSIDs++;
}
/*
* Fill in the parameters for 2 data structures:
* 1. HostCmd_DS_802_11_AD_HOC_START Command
* 2. Adapter->BSSIDList[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.
*/
for (j = 0; j < MRVDRV_MAX_SSID_LENGTH; j++) {
if (((PWLAN_802_11_SSID) InformationBuffer)->Ssid[j] == '\0')
break;
}
memset(adhs->SSID, 0, MRVDRV_MAX_SSID_LENGTH); // with 2.0.23
// reference
memcpy(adhs->SSID,((PWLAN_802_11_SSID) InformationBuffer)->Ssid,
((PWLAN_802_11_SSID) InformationBuffer)->SsidLength);
PRINTK1("Inside the adhoc_start command %s\n", adhs->SSID);
memset(Adapter->BSSIDList[i].Ssid.Ssid, 0, MRVDRV_MAX_SSID_LENGTH);
memcpy(Adapter->BSSIDList[i].Ssid.Ssid,
((PWLAN_802_11_SSID) InformationBuffer)->Ssid,
((PWLAN_802_11_SSID) InformationBuffer)->SsidLength);
Adapter->BSSIDList[i].Ssid.SsidLength =
((PWLAN_802_11_SSID) InformationBuffer)->SsidLength;
/* Set the length of Adapter->BSSIDList[i] */
Adapter->BSSIDList[i].Length = sizeof(WLAN_802_11_BSSID);
/* set the length of configuration in Adapter->BSSIDList[i] */
Adapter->BSSIDList[i].Configuration.Length =
sizeof(WLAN_802_11_CONFIGURATION);
/* set the BSS type */
adhs->BSSType = HostCmd_BSS_TYPE_IBSS;
Adapter->BSSIDList[i].InfrastructureMode = Wlan802_11IBSS;
/* set Physical param set */
adhs->PhyParamSet.DsParamSet.ElementId = 3;
adhs->PhyParamSet.DsParamSet.Len = 1;
if (Adapter->AdhocChannel == 0) {
#ifdef MULTI_BANDS
if (Adapter->adhoc_start_band == BAND_A)
Adapter->AdhocChannel = DEFAULT_AD_HOC_CHANNEL_A;
else
#endif
Adapter->AdhocChannel = DEFAULT_AD_HOC_CHANNEL;
}
PRINTK1("Creating ADHOC on Channel %d\n", Adapter->AdhocChannel);
Adapter->CurBssParams.channel = Adapter->AdhocChannel;
#ifdef MULTI_BANDS
Adapter->CurBssParams.band = Adapter->adhoc_start_band;
#endif
Adapter->BSSIDList[i].Channel = Adapter->AdhocChannel;
adhs->PhyParamSet.DsParamSet.CurrentChan = Adapter->AdhocChannel;
memcpy(&Adapter->BSSIDList[i].PhyParamSet,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -