Commit 0f65bec1 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Greg Kroah-Hartman

Staging: rt28x0: run sta/*.c files through Lindent

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 96b3c83d
......@@ -36,31 +36,31 @@
*/
#include "../rt_config.h"
UCHAR CipherWpaTemplate[] = {
0xdd, // WPA IE
0x16, // Length
0x00, 0x50, 0xf2, 0x01, // oui
0x01, 0x00, // Version
0x00, 0x50, 0xf2, 0x02, // Multicast
0x01, 0x00, // Number of unicast
0x00, 0x50, 0xf2, 0x02, // unicast
0x01, 0x00, // number of authentication method
0x00, 0x50, 0xf2, 0x01 // authentication
};
UCHAR CipherWpa2Template[] = {
0x30, // RSN IE
0x14, // Length
0x01, 0x00, // Version
0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
0x01, 0x00, // number of pairwise
0x00, 0x0f, 0xac, 0x02, // unicast
0x01, 0x00, // number of authentication method
0x00, 0x0f, 0xac, 0x02, // authentication
0x00, 0x00, // RSN capability
};
UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
UCHAR CipherWpaTemplate[] = {
0xdd, // WPA IE
0x16, // Length
0x00, 0x50, 0xf2, 0x01, // oui
0x01, 0x00, // Version
0x00, 0x50, 0xf2, 0x02, // Multicast
0x01, 0x00, // Number of unicast
0x00, 0x50, 0xf2, 0x02, // unicast
0x01, 0x00, // number of authentication method
0x00, 0x50, 0xf2, 0x01 // authentication
};
UCHAR CipherWpa2Template[] = {
0x30, // RSN IE
0x14, // Length
0x01, 0x00, // Version
0x00, 0x0f, 0xac, 0x02, // group cipher, TKIP
0x01, 0x00, // number of pairwise
0x00, 0x0f, 0xac, 0x02, // unicast
0x01, 0x00, // number of authentication method
0x00, 0x0f, 0xac, 0x02, // authentication
0x00, 0x00, // RSN capability
};
UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02 };
/*
==========================================================================
......@@ -73,55 +73,84 @@ UCHAR Ccx2IeInfo[] = { 0x00, 0x40, 0x96, 0x03, 0x02};
==========================================================================
*/
VOID AssocStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *S,
OUT STATE_MACHINE_FUNC Trans[])
VOID AssocStateMachineInit(IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE * S, OUT STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG, (STATE_MACHINE_FUNC)Drop, ASSOC_IDLE, ASSOC_MACHINE_BASE);
StateMachineInit(S, Trans, MAX_ASSOC_STATE, MAX_ASSOC_MSG,
(STATE_MACHINE_FUNC) Drop, ASSOC_IDLE,
ASSOC_MACHINE_BASE);
// first column
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)MlmeAssocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)MlmeReassocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)MlmeDisassocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_ASSOC_REQ,
(STATE_MACHINE_FUNC) MlmeAssocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_REASSOC_REQ,
(STATE_MACHINE_FUNC) MlmeReassocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_MLME_DISASSOC_REQ,
(STATE_MACHINE_FUNC) MlmeDisassocReqAction);
StateMachineSetAction(S, ASSOC_IDLE, MT2_PEER_DISASSOC_REQ,
(STATE_MACHINE_FUNC) PeerDisassocAction);
// second column
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
(STATE_MACHINE_FUNC)
InvalidStateWhenDisassociate);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
(STATE_MACHINE_FUNC) PeerDisassocAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP,
(STATE_MACHINE_FUNC) PeerAssocRspAction);
//
// Patch 3Com AP MOde:3CRWE454G72
// We send Assoc request frame to this AP, it always send Reassoc Rsp not Associate Rsp.
//
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerAssocRspAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT, (STATE_MACHINE_FUNC)AssocTimeoutAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP,
(STATE_MACHINE_FUNC) PeerAssocRspAction);
StateMachineSetAction(S, ASSOC_WAIT_RSP, MT2_ASSOC_TIMEOUT,
(STATE_MACHINE_FUNC) AssocTimeoutAction);
// third column
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
(STATE_MACHINE_FUNC)
InvalidStateWhenDisassociate);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
(STATE_MACHINE_FUNC) PeerDisassocAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_REASSOC_RSP,
(STATE_MACHINE_FUNC) PeerReassocRspAction);
//
// Patch, AP doesn't send Reassociate Rsp frame to Station.
//
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP, (STATE_MACHINE_FUNC)PeerReassocRspAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT, (STATE_MACHINE_FUNC)ReassocTimeoutAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_PEER_ASSOC_RSP,
(STATE_MACHINE_FUNC) PeerReassocRspAction);
StateMachineSetAction(S, REASSOC_WAIT_RSP, MT2_REASSOC_TIMEOUT,
(STATE_MACHINE_FUNC) ReassocTimeoutAction);
// fourth column
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAssoc);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenReassoc);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenDisassociate);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ, (STATE_MACHINE_FUNC)PeerDisassocAction);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT, (STATE_MACHINE_FUNC)DisassocTimeoutAction);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_ASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAssoc);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_REASSOC_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenReassoc);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_MLME_DISASSOC_REQ,
(STATE_MACHINE_FUNC)
InvalidStateWhenDisassociate);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_PEER_DISASSOC_REQ,
(STATE_MACHINE_FUNC) PeerDisassocAction);
StateMachineSetAction(S, DISASSOC_WAIT_RSP, MT2_DISASSOC_TIMEOUT,
(STATE_MACHINE_FUNC) DisassocTimeoutAction);
// initialize the timer
RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer, GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer, GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer, GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.AssocTimer,
GET_TIMER_FUNCTION(AssocTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.ReassocTimer,
GET_TIMER_FUNCTION(ReassocTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.DisassocTimer,
GET_TIMER_FUNCTION(DisassocTimeout), pAd, FALSE);
}
/*
......@@ -137,15 +166,15 @@ VOID AssocStateMachineInit(
==========================================================================
*/
VOID AssocTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_ASSOC_TIMEOUT, 0, NULL);
......@@ -165,15 +194,15 @@ VOID AssocTimeout(IN PVOID SystemSpecific1,
==========================================================================
*/
VOID ReassocTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_REASSOC_TIMEOUT, 0, NULL);
......@@ -193,15 +222,15 @@ VOID ReassocTimeout(IN PVOID SystemSpecific1,
==========================================================================
*/
VOID DisassocTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_DISASSOC_TIMEOUT, 0, NULL);
......@@ -230,136 +259,145 @@ VOID DisassocTimeout(IN PVOID SystemSpecific1,
==========================================================================
*/
VOID MlmeAssocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeAssocReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR ApAddr[6];
HEADER_802_11 AssocHdr;
UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
USHORT ListenIntv;
ULONG Timeout;
USHORT CapabilityInfo;
BOOLEAN TimerCancelled;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
ULONG tmp;
USHORT VarIesOffset;
USHORT Status;
UCHAR ApAddr[6];
HEADER_802_11 AssocHdr;
UCHAR WmeIe[9] =
{ IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
0x00 };
USHORT ListenIntv;
ULONG Timeout;
USHORT CapabilityInfo;
BOOLEAN TimerCancelled;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
ULONG tmp;
USHORT VarIesOffset;
USHORT Status;
// Block all authentication request durning WPA block period
if (pAd->StaCfg.bBlockAssoc == TRUE)
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block Assoc request durning WPA block period!\n"));
if (pAd->StaCfg.bBlockAssoc == TRUE) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - Block Assoc request durning WPA block period!\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
&Status);
}
// check sanity first
else if (MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
{
else if (MlmeAssocReqSanity
(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
&Timeout, &ListenIntv)) {
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
// Get an unused nonpaged memory
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - MlmeAssocReqAction() allocate memory failed \n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_ASSOC_CONF, 2, &Status);
return;
}
// Add by James 03/06/27
pAd->StaCfg.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
pAd->StaCfg.AssocInfo.Length =
sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
// Association don't need to report MAC address
pAd->StaCfg.AssocInfo.AvailableRequestFixedIEs =
NDIS_802_11_AI_REQFI_CAPABILITIES | NDIS_802_11_AI_REQFI_LISTENINTERVAL;
pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities = CapabilityInfo;
pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval = ListenIntv;
NDIS_802_11_AI_REQFI_CAPABILITIES |
NDIS_802_11_AI_REQFI_LISTENINTERVAL;
pAd->StaCfg.AssocInfo.RequestFixedIEs.Capabilities =
CapabilityInfo;
pAd->StaCfg.AssocInfo.RequestFixedIEs.ListenInterval =
ListenIntv;
// Only reassociate need this
//COPY_MAC_ADDR(pAd->StaCfg.AssocInfo.RequestFixedIEs.CurrentAPAddress, ApAddr);
pAd->StaCfg.AssocInfo.OffsetRequestIEs = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
pAd->StaCfg.AssocInfo.OffsetRequestIEs =
sizeof(NDIS_802_11_ASSOCIATION_INFORMATION);
NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
NdisZeroMemory(pAd->StaCfg.ReqVarIEs, MAX_VIE_LEN);
// First add SSID
VarIesOffset = 0;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe, 1);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SsidIe,
1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SsidLen, 1);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
&pAd->MlmeAux.SsidLen, 1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen);
VarIesOffset += pAd->MlmeAux.SsidLen;
// Second add Supported rates
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe, 1);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &SupRateIe,
1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->MlmeAux.SupRateLen, 1);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
&pAd->MlmeAux.SupRateLen, 1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
pAd->MlmeAux.SupRate, pAd->MlmeAux.SupRateLen);
VarIesOffset += pAd->MlmeAux.SupRateLen;
// End Add by James
if ((pAd->CommonCfg.Channel > 14) &&
(pAd->CommonCfg.bIEEE80211H == TRUE))
CapabilityInfo |= 0x0100;
if ((pAd->CommonCfg.Channel > 14) &&
(pAd->CommonCfg.bIEEE80211H == TRUE))
CapabilityInfo |= 0x0100;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send ASSOC request...\n"));
MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr, ApAddr);
MgtMacHeaderInit(pAd, &AssocHdr, SUBTYPE_ASSOC_REQ, 0, ApAddr,
ApAddr);
// Build basic frame first
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &AssocHdr,
2, &CapabilityInfo,
2, &ListenIntv,
1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
1, &SupRateIe,
1, &pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
END_OF_ARGS);
if (pAd->MlmeAux.ExtRateLen != 0)
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &ExtRateIe,
1, &pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &AssocHdr,
2, &CapabilityInfo,
2, &ListenIntv,
1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
1, &SupRateIe,
1, &pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
END_OF_ARGS);
if (pAd->MlmeAux.ExtRateLen != 0) {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &ExtRateIe,
1, &pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRate, END_OF_ARGS);
FrameLen += tmp;
}
// HT
if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
if ((pAd->MlmeAux.HtCapabilityLen > 0)
&& (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
ULONG TmpLen;
UCHAR HtLen;
UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
{
UCHAR BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
HtLen = SIZE_HT_CAP_IE + 4;
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &WpaIe,
1, &HtLen,
4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
}
else
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &HtCapIe,
1, &pAd->MlmeAux.HtCapabilityLen,
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &WpaIe, 1, &HtLen,
4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen,
&pAd->MlmeAux.HtCapability,
END_OF_ARGS);
} else {
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &HtCapIe, 1,
&pAd->MlmeAux.HtCapabilityLen,
pAd->MlmeAux.HtCapabilityLen,
&pAd->MlmeAux.HtCapability,
END_OF_ARGS);
}
FrameLen += TmpLen;
}
// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
// Case I: (Aggregation + Piggy-Back)
// 1. user enable aggregation, AND
......@@ -368,63 +406,60 @@ VOID MlmeAssocReqAction(
// Case II: (Aggregation)
// 1. user enable aggregation, AND
// 2. AP annouces it's AGGREGATION-capable in BEACON
if (pAd->CommonCfg.bAggregationCapable)
{
if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
{
if (pAd->CommonCfg.bAggregationCapable) {
if ((pAd->CommonCfg.bPiggyBackCapable)
&& ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
0x03, 0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 9, RalinkIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
{
} else if (pAd->MlmeAux.APRalinkIe & 0x00000001) {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
0x01, 0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 9, RalinkIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
}
else
{
} else {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x06,
0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9,
RalinkIe, END_OF_ARGS);
FrameLen += TmpLen;
}
if (pAd->MlmeAux.APEdcaParm.bValid)
{
if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
{
if (pAd->MlmeAux.APEdcaParm.bValid) {
if (pAd->CommonCfg.bAPSDCapable
&& pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
QBSS_STA_INFO_PARM QosInfo;
NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
NdisZeroMemory(&QosInfo,
sizeof(QBSS_STA_INFO_PARM));
QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
WmeIe[8] |= *(PUCHAR)&QosInfo;
}
else
{
// The Parameter Set Count is set to 0 in the association request frames
// WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
QosInfo.MaxSPLength =
pAd->CommonCfg.MaxSPLength;
WmeIe[8] |= *(PUCHAR) & QosInfo;
} else {
// The Parameter Set Count is set to 0 in the association request frames
// WmeIe[8] |= (pAd->MlmeAux.APEdcaParm.EdcaUpdateCount & 0x0f);
}
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
9, &WmeIe[0],
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
9, &WmeIe[0], END_OF_ARGS);
FrameLen += tmp;
}
//
// Let WPA(#221) Element ID on the end of this association frame.
// Otherwise some AP will fail on parsing Element ID and set status fail on Assoc Rsp.
......@@ -432,94 +467,107 @@ VOID MlmeAssocReqAction(
// This happens on AP (Model No:Linksys WRK54G)
//
if (((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
)
)
{
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
)
) {
UCHAR RSNIe = IE_WPA;
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK) ||
(pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2))
{
if ((pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)
|| (pAd->StaCfg.AuthMode ==
Ndis802_11AuthModeWPA2)) {
RSNIe = IE_WPA2;
}
if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE) &&
(pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, BSS0);
if ((pAd->StaCfg.WpaSupplicantUP !=
WPA_SUPPLICANT_ENABLE)
&& (pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode,
pAd->StaCfg.WepStatus, BSS0);
// Check for WPA PMK cache list
if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2)
{
INT idx;
BOOLEAN FoundPMK = FALSE;
// Check for WPA PMK cache list
if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2) {
INT idx;
BOOLEAN FoundPMK = FALSE;
// Search chched PMKID, append it if existed
for (idx = 0; idx < PMKID_NO; idx++)
{
if (NdisEqualMemory(ApAddr, &pAd->StaCfg.SavedPMK[idx].BSSID, 6))
{
for (idx = 0; idx < PMKID_NO; idx++) {
if (NdisEqualMemory
(ApAddr,
&pAd->StaCfg.SavedPMK[idx].BSSID,
6)) {
FoundPMK = TRUE;
break;
}
}
if (FoundPMK)
{
if (FoundPMK) {
// Set PMK number
*(PUSHORT) &pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len] = 1;
NdisMoveMemory(&pAd->StaCfg.RSN_IE[pAd->StaCfg.RSNIE_Len + 2], &pAd->StaCfg.SavedPMK[idx].PMKID, 16);
pAd->StaCfg.RSNIE_Len += 18;
*(PUSHORT) & pAd->StaCfg.RSN_IE[pAd->
StaCfg.
RSNIE_Len]
= 1;
NdisMoveMemory(&pAd->StaCfg.
RSN_IE[pAd->StaCfg.
RSNIE_Len + 2],
&pAd->StaCfg.
SavedPMK[idx].PMKID, 16);
pAd->StaCfg.RSNIE_Len += 18;
}
}
if ((pAd->StaCfg.WpaSupplicantUP == WPA_SUPPLICANT_ENABLE) &&
(pAd->StaCfg.bRSN_IE_FromWpaSupplicant == TRUE))
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
END_OF_ARGS);
}
else
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &RSNIe,
1, &pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
END_OF_ARGS);
if ((pAd->StaCfg.WpaSupplicantUP ==
WPA_SUPPLICANT_ENABLE)
&& (pAd->StaCfg.bRSN_IE_FromWpaSupplicant ==
TRUE)) {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSN_IE,
END_OF_ARGS);
} else {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &RSNIe,
1, &pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSN_IE,
END_OF_ARGS);
}
FrameLen += tmp;
if ((pAd->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_ENABLE) ||
(pAd->StaCfg.bRSN_IE_FromWpaSupplicant == FALSE))
{
// Append Variable IE
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &RSNIe, 1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, &pAd->StaCfg.RSNIE_Len, 1);
VarIesOffset += 1;
if ((pAd->StaCfg.WpaSupplicantUP !=
WPA_SUPPLICANT_ENABLE)
|| (pAd->StaCfg.bRSN_IE_FromWpaSupplicant ==
FALSE)) {
// Append Variable IE
NdisMoveMemory(pAd->StaCfg.ReqVarIEs +
VarIesOffset, &RSNIe, 1);
VarIesOffset += 1;
NdisMoveMemory(pAd->StaCfg.ReqVarIEs +
VarIesOffset,
&pAd->StaCfg.RSNIE_Len, 1);
VarIesOffset += 1;
}
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset, pAd->StaCfg.RSN_IE, pAd->StaCfg.RSNIE_Len);
NdisMoveMemory(pAd->StaCfg.ReqVarIEs + VarIesOffset,
pAd->StaCfg.RSN_IE,
pAd->StaCfg.RSNIE_Len);
VarIesOffset += pAd->StaCfg.RSNIE_Len;
// Set Variable IEs Length
pAd->StaCfg.ReqVarIELen = VarIesOffset;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(&pAd->MlmeAux.AssocTimer, Timeout);
pAd->Mlme.AssocMachine.CurrState = ASSOC_WAIT_RSP;
}
else
{
DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
} else {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - MlmeAssocReqAction() sanity check failed. BUG!!!!!! \n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2,
&Status);
}
}
......@@ -541,121 +589,117 @@ VOID MlmeAssocReqAction(
==========================================================================
*/
VOID MlmeReassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeReassocReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR ApAddr[6];
HEADER_802_11 ReassocHdr;
UCHAR WmeIe[9] = {IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
USHORT CapabilityInfo, ListenIntv;
ULONG Timeout;
ULONG FrameLen = 0;
BOOLEAN TimerCancelled;
NDIS_STATUS NStatus;
ULONG tmp;
PUCHAR pOutBuffer = NULL;
USHORT Status;
UCHAR ApAddr[6];
HEADER_802_11 ReassocHdr;
UCHAR WmeIe[9] =
{ IE_VENDOR_SPECIFIC, 0x07, 0x00, 0x50, 0xf2, 0x02, 0x00, 0x01,
0x00 };
USHORT CapabilityInfo, ListenIntv;
ULONG Timeout;
ULONG FrameLen = 0;
BOOLEAN TimerCancelled;
NDIS_STATUS NStatus;
ULONG tmp;
PUCHAR pOutBuffer = NULL;
USHORT Status;
// Block all authentication request durning WPA block period
if (pAd->StaCfg.bBlockAssoc == TRUE)
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Block ReAssoc request durning WPA block period!\n"));
if (pAd->StaCfg.bBlockAssoc == TRUE) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - Block ReAssoc request durning WPA block period!\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
&Status);
}
// the parameters are the same as the association
else if(MlmeAssocReqSanity(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo, &Timeout, &ListenIntv))
{
else if (MlmeAssocReqSanity
(pAd, Elem->Msg, Elem->MsgLen, ApAddr, &CapabilityInfo,
&Timeout, &ListenIntv)) {
RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if(NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - MlmeReassocReqAction() allocate memory failed \n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_REASSOC_CONF, 2, &Status);
return;
}
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, ApAddr);
// make frame, use bssid as the AP address??
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send RE-ASSOC request...\n"));
MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0, ApAddr, ApAddr);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ReassocHdr,
2, &CapabilityInfo,
2, &ListenIntv,
MAC_ADDR_LEN, ApAddr,
1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
1, &SupRateIe,
1, &pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
END_OF_ARGS);
if (pAd->MlmeAux.ExtRateLen != 0)
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &ExtRateIe,
1, &pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRateLen, pAd->MlmeAux.ExtRate,
END_OF_ARGS);
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - Send RE-ASSOC request...\n"));
MgtMacHeaderInit(pAd, &ReassocHdr, SUBTYPE_REASSOC_REQ, 0,
ApAddr, ApAddr);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),
&ReassocHdr, 2, &CapabilityInfo, 2,
&ListenIntv, MAC_ADDR_LEN, ApAddr, 1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid, 1,
&SupRateIe, 1, &pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.SupRate,
END_OF_ARGS);
if (pAd->MlmeAux.ExtRateLen != 0) {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &ExtRateIe,
1, &pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRateLen,
pAd->MlmeAux.ExtRate, END_OF_ARGS);
FrameLen += tmp;
}
if (pAd->MlmeAux.APEdcaParm.bValid)
{
if (pAd->CommonCfg.bAPSDCapable && pAd->MlmeAux.APEdcaParm.bAPSDCapable)
{
if (pAd->MlmeAux.APEdcaParm.bValid) {
if (pAd->CommonCfg.bAPSDCapable
&& pAd->MlmeAux.APEdcaParm.bAPSDCapable) {
QBSS_STA_INFO_PARM QosInfo;
NdisZeroMemory(&QosInfo, sizeof(QBSS_STA_INFO_PARM));
NdisZeroMemory(&QosInfo,
sizeof(QBSS_STA_INFO_PARM));
QosInfo.UAPSD_AC_BE = pAd->CommonCfg.bAPSDAC_BE;
QosInfo.UAPSD_AC_BK = pAd->CommonCfg.bAPSDAC_BK;
QosInfo.UAPSD_AC_VI = pAd->CommonCfg.bAPSDAC_VI;
QosInfo.UAPSD_AC_VO = pAd->CommonCfg.bAPSDAC_VO;
QosInfo.MaxSPLength = pAd->CommonCfg.MaxSPLength;
WmeIe[8] |= *(PUCHAR)&QosInfo;
QosInfo.MaxSPLength =
pAd->CommonCfg.MaxSPLength;
WmeIe[8] |= *(PUCHAR) & QosInfo;
}
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
9, &WmeIe[0],
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
9, &WmeIe[0], END_OF_ARGS);
FrameLen += tmp;
}
// HT
if ((pAd->MlmeAux.HtCapabilityLen > 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
if ((pAd->MlmeAux.HtCapabilityLen > 0)
&& (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
ULONG TmpLen;
UCHAR HtLen;
UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE)
{
UCHAR BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
if (pAd->StaActive.SupportedPhyInfo.bPreNHt == TRUE) {
HtLen = SIZE_HT_CAP_IE + 4;
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &WpaIe,
1, &HtLen,
4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
}
else
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &HtCapIe,
1, &pAd->MlmeAux.HtCapabilityLen,
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &WpaIe, 1, &HtLen,
4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen,
&pAd->MlmeAux.HtCapability,
END_OF_ARGS);
} else {
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &HtCapIe, 1,
&pAd->MlmeAux.HtCapabilityLen,
pAd->MlmeAux.HtCapabilityLen,
&pAd->MlmeAux.HtCapability,
END_OF_ARGS);
}
FrameLen += TmpLen;
}
// add Ralink proprietary IE to inform AP this STA is going to use AGGREGATION or PIGGY-BACK+AGGREGATION
// Case I: (Aggregation + Piggy-Back)
// 1. user enable aggregation, AND
......@@ -664,49 +708,49 @@ VOID MlmeReassocReqAction(
// Case II: (Aggregation)
// 1. user enable aggregation, AND
// 2. AP annouces it's AGGREGATION-capable in BEACON
if (pAd->CommonCfg.bAggregationCapable)
{
if ((pAd->CommonCfg.bPiggyBackCapable) && ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3))
{
if (pAd->CommonCfg.bAggregationCapable) {
if ((pAd->CommonCfg.bPiggyBackCapable)
&& ((pAd->MlmeAux.APRalinkIe & 0x00000003) == 3)) {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x03, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
0x03, 0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 9, RalinkIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
else if (pAd->MlmeAux.APRalinkIe & 0x00000001)
{
} else if (pAd->MlmeAux.APRalinkIe & 0x00000001) {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43,
0x01, 0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 9, RalinkIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
}
else
{
} else {
ULONG TmpLen;
UCHAR RalinkIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkIe,
END_OF_ARGS);
UCHAR RalinkIe[9] =
{ IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x04,
0x00, 0x00, 0x00 };
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen, 9,
RalinkIe, END_OF_ARGS);
FrameLen += TmpLen;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
RTMPSetTimer(&pAd->MlmeAux.ReassocTimer, Timeout); /* in mSec */
pAd->Mlme.AssocMachine.CurrState = REASSOC_WAIT_RSP;
}
else
{
DBGPRINT(RT_DEBUG_TRACE,("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
} else {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - MlmeReassocReqAction() sanity check failed. BUG!!!! \n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2,
&Status);
}
}
......@@ -721,52 +765,50 @@ VOID MlmeReassocReqAction(
==========================================================================
*/
VOID MlmeDisassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeDisassocReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
PMLME_DISASSOC_REQ_STRUCT pDisassocReq;
HEADER_802_11 DisassocHdr;
PHEADER_802_11 pDisassocHdr;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
NDIS_STATUS NStatus;
BOOLEAN TimerCancelled;
ULONG Timeout = 500;
USHORT Status;
HEADER_802_11 DisassocHdr;
PHEADER_802_11 pDisassocHdr;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
NDIS_STATUS NStatus;
BOOLEAN TimerCancelled;
ULONG Timeout = 500;
USHORT Status;
// skip sanity check
pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg);
pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT) (Elem->Msg);
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - MlmeDisassocReqAction() allocate memory failed\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
&Status);
return;
}
RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer, &TimerCancelled);
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
pDisassocReq->Addr[0], pDisassocReq->Addr[1], pDisassocReq->Addr[2],
pDisassocReq->Addr[3], pDisassocReq->Addr[4], pDisassocReq->Addr[5], pDisassocReq->Reason));
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - Send DISASSOC request[BSSID::%02x:%02x:%02x:%02x:%02x:%02x (Reason=%d)\n",
pDisassocReq->Addr[0], pDisassocReq->Addr[1],
pDisassocReq->Addr[2], pDisassocReq->Addr[3],
pDisassocReq->Addr[4], pDisassocReq->Addr[5],
pDisassocReq->Reason));
MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); // patch peap ttls switching issue
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),&DisassocHdr,
2, &pDisassocReq->Reason,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &DisassocHdr,
2, &pDisassocReq->Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
// To patch Instance and Buffalo(N) AP
// Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
// Therefore, we send both of them.
pDisassocHdr = (PHEADER_802_11)pOutBuffer;
pDisassocHdr = (PHEADER_802_11) pOutBuffer;
pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
......@@ -775,10 +817,9 @@ VOID MlmeDisassocReqAction(
pAd->StaCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING;
COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pDisassocReq->Addr);
RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); /* in mSec */
pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP;
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
}
......@@ -794,71 +835,81 @@ VOID MlmeDisassocReqAction(
==========================================================================
*/
VOID PeerAssocRspAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerAssocRspAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT CapabilityInfo, Status, Aid;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
UCHAR Addr2[MAC_ADDR_LEN];
BOOLEAN TimerCancelled;
UCHAR CkipFlag;
EDCA_PARM EdcaParm;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
&HtCapability,&AddHtInfo, &HtCapabilityLen,&AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
{
USHORT CapabilityInfo, Status, Aid;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
UCHAR Addr2[MAC_ADDR_LEN];
BOOLEAN TimerCancelled;
UCHAR CkipFlag;
EDCA_PARM EdcaParm;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
if (PeerAssocRspSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status,
&Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability,
&AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset,
&EdcaParm, &CkipFlag)) {
// The frame is for me ?
if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid))
{
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status));
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",Elem->Wcid, pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer, &TimerCancelled);
if(Status == MLME_SUCCESS)
{
UCHAR MaxSupportedRateIn500Kbps = 0;
UCHAR idx;
if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspAction():ASSOC - receive ASSOC_RSP to me (status=%d)\n",
Status));
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspAction():MacTable [%d].AMsduSize = %d. ClientStatusFlags = 0x%lx \n",
Elem->Wcid,
pAd->MacTab.Content[BSSID_WCID].AMsduSize,
pAd->MacTab.Content[BSSID_WCID].
ClientStatusFlags));
RTMPCancelTimer(&pAd->MlmeAux.AssocTimer,
&TimerCancelled);
if (Status == MLME_SUCCESS) {
UCHAR MaxSupportedRateIn500Kbps = 0;
UCHAR idx;
// supported rates array may not be sorted. sort it and find the maximum rate
for (idx=0; idx<SupRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
}
for (idx=0; idx<ExtRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
}
for (idx = 0; idx < SupRateLen; idx++) {
if (MaxSupportedRateIn500Kbps <
(SupRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps =
SupRate[idx] & 0x7f;
}
for (idx = 0; idx < ExtRateLen; idx++) {
if (MaxSupportedRateIn500Kbps <
(ExtRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps =
ExtRate[idx] & 0x7f;
}
// go to procedure listed on page 376
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
&EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
SupRate, SupRateLen, ExtRate,
ExtRateLen, &EdcaParm,
&HtCapability, HtCapabilityLen,
&AddHtInfo);
StaAddMacTableEntry(pAd,
&pAd->MacTab.Content[BSSID_WCID],
MaxSupportedRateIn500Kbps,
&HtCapability,
HtCapabilityLen,
&AddHtInfo,
AddHtInfoLen,
CapabilityInfo);
&pAd->MacTab.
Content[BSSID_WCID],
MaxSupportedRateIn500Kbps,
&HtCapability,
HtCapabilityLen, &AddHtInfo,
AddHtInfoLen,
CapabilityInfo);
}
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_ASSOC_CONF, 2, &Status);
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerAssocRspAction() sanity check fail\n"));
} else {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - PeerAssocRspAction() sanity check fail\n"));
}
}
......@@ -873,55 +924,62 @@ VOID PeerAssocRspAction(
==========================================================================
*/
VOID PeerReassocRspAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerReassocRspAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT CapabilityInfo;
USHORT Status;
USHORT Aid;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR CkipFlag;
BOOLEAN TimerCancelled;
EDCA_PARM EdcaParm;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen,
&HtCapability, &AddHtInfo, &HtCapabilityLen, &AddHtInfoLen,&NewExtChannelOffset, &EdcaParm, &CkipFlag))
{
if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
USHORT CapabilityInfo;
USHORT Status;
USHORT Aid;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen;
UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen;
UCHAR Addr2[MAC_ADDR_LEN];
UCHAR CkipFlag;
BOOLEAN TimerCancelled;
EDCA_PARM EdcaParm;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
if (PeerAssocRspSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status,
&Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &HtCapability,
&AddHtInfo, &HtCapabilityLen, &AddHtInfoLen, &NewExtChannelOffset,
&EdcaParm, &CkipFlag)) {
if (MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ?
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status));
RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer, &TimerCancelled);
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - receive REASSOC_RSP to me (status=%d)\n",
Status));
RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer,
&TimerCancelled);
if(Status == MLME_SUCCESS)
{
if (Status == MLME_SUCCESS) {
// go to procedure listed on page 376
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen,
&EdcaParm, &HtCapability, HtCapabilityLen, &AddHtInfo);
AssocPostProc(pAd, Addr2, CapabilityInfo, Aid,
SupRate, SupRateLen, ExtRate,
ExtRateLen, &EdcaParm,
&HtCapability, HtCapabilityLen,
&AddHtInfo);
{
wext_notify_event_assoc(pAd);
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, &pAd->MlmeAux.Bssid[0], NULL, 0);
}
}
{
wext_notify_event_assoc(pAd);
RtmpOSWrielessEventSend(pAd, SIOCGIWAP,
-1,
&pAd->MlmeAux.
Bssid[0], NULL,
0);
}
// CkipFlag is no use for reassociate
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
}
// CkipFlag is no use for reassociate
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_REASSOC_CONF, 2, &Status);
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerReassocRspAction() sanity check fail\n"));
} else {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - PeerReassocRspAction() sanity check fail\n"));
}
}
......@@ -936,30 +994,18 @@ VOID PeerReassocRspAction(
==========================================================================
*/
VOID AssocPostProc(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr2,
IN USHORT CapabilityInfo,
IN USHORT Aid,
IN UCHAR SupRate[],
IN UCHAR SupRateLen,
IN UCHAR ExtRate[],
IN UCHAR ExtRateLen,
IN PEDCA_PARM pEdcaParm,
IN HT_CAPABILITY_IE *pHtCapability,
IN UCHAR HtCapabilityLen,
IN ADD_HT_INFO_IE *pAddHtInfo) // AP might use this additional ht info IE
VOID AssocPostProc(IN PRTMP_ADAPTER pAd, IN PUCHAR pAddr2, IN USHORT CapabilityInfo, IN USHORT Aid, IN UCHAR SupRate[], IN UCHAR SupRateLen, IN UCHAR ExtRate[], IN UCHAR ExtRateLen, IN PEDCA_PARM pEdcaParm, IN HT_CAPABILITY_IE * pHtCapability, IN UCHAR HtCapabilityLen, IN ADD_HT_INFO_IE * pAddHtInfo) // AP might use this additional ht info IE
{
ULONG Idx;
pAd->MlmeAux.BssType = BSS_INFRA;
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pAddr2);
pAd->MlmeAux.Aid = Aid;
pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
pAd->MlmeAux.CapabilityInfo =
CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
// Some HT AP might lost WMM IE. We add WMM ourselves. beacuase HT requires QoS on.
if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE))
{
if ((HtCapabilityLen > 0) && (pEdcaParm->bValid == FALSE)) {
pEdcaParm->bValid = TRUE;
pEdcaParm->Aifsn[0] = 3;
pEdcaParm->Aifsn[1] = 7;
......@@ -976,10 +1022,10 @@ VOID AssocPostProc(
pEdcaParm->Cwmax[2] = 4;
pEdcaParm->Cwmax[3] = 3;
pEdcaParm->Txop[0] = 0;
pEdcaParm->Txop[1] = 0;
pEdcaParm->Txop[2] = 96;
pEdcaParm->Txop[3] = 48;
pEdcaParm->Txop[0] = 0;
pEdcaParm->Txop[1] = 0;
pEdcaParm->Txop[2] = 96;
pEdcaParm->Txop[3] = 48;
}
......@@ -995,75 +1041,94 @@ VOID AssocPostProc(
NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
if (HtCapabilityLen > 0)
{
if (HtCapabilityLen > 0) {
RTMPCheckHt(pAd, BSSID_WCID, pHtCapability, pAddHtInfo);
}
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n", pAd->MacTab.Content[BSSID_WCID].AMsduSize, pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
DBGPRINT(RT_DEBUG_TRACE,
("AssocPostProc===> AP.AMsduSize = %d. ClientStatusFlags = 0x%lx \n",
pAd->MacTab.Content[BSSID_WCID].AMsduSize,
pAd->MacTab.Content[BSSID_WCID].ClientStatusFlags));
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
pAd->MacTab.Content[BSSID_WCID].MmpsMode, pAd->MacTab.Content[BSSID_WCID].AMsduSize));
DBGPRINT(RT_DEBUG_TRACE,
("AssocPostProc===> (Mmps=%d, AmsduSize=%d, )\n",
pAd->MacTab.Content[BSSID_WCID].MmpsMode,
pAd->MacTab.Content[BSSID_WCID].AMsduSize));
// Set New WPA information
Idx = BssTableSearch(&pAd->ScanTab, pAddr2, pAd->MlmeAux.Channel);
if (Idx == BSS_NOT_FOUND)
{
if (Idx == BSS_NOT_FOUND) {
DBGPRINT_ERR(("ASSOC - Can't find BSS after receiving Assoc response\n"));
}
else
{
} else {
// Init variable
pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = 0;
NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, MAX_LEN_OF_RSNIE);
NdisZeroMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE,
MAX_LEN_OF_RSNIE);
// Store appropriate RSN_IE for WPA SM negotiation later
if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA) && (pAd->ScanTab.BssEntry[Idx].VarIELen != 0))
{
PUCHAR pVIE;
USHORT len;
PEID_STRUCT pEid;
if ((pAd->StaCfg.AuthMode >= Ndis802_11AuthModeWPA)
&& (pAd->ScanTab.BssEntry[Idx].VarIELen != 0)) {
PUCHAR pVIE;
USHORT len;
PEID_STRUCT pEid;
pVIE = pAd->ScanTab.BssEntry[Idx].VarIEs;
len = pAd->ScanTab.BssEntry[Idx].VarIELen;
len = pAd->ScanTab.BssEntry[Idx].VarIELen;
//KH need to check again
// Don't allow to go to sleep mode if authmode is WPA-related.
//This can make Authentication process more smoothly.
RTMP_CLEAR_PSFLAG(pAd, fRTMP_PS_CAN_GO_SLEEP);
while (len > 0)
{
while (len > 0) {
pEid = (PEID_STRUCT) pVIE;
// For WPA/WPAPSK
if ((pEid->Eid == IE_WPA) && (NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
&& (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPAPSK))
{
NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
if ((pEid->Eid == IE_WPA)
&&
(NdisEqualMemory(pEid->Octet, WPA_OUI, 4))
&& (pAd->StaCfg.AuthMode ==
Ndis802_11AuthModeWPA
|| pAd->StaCfg.AuthMode ==
Ndis802_11AuthModeWPAPSK)) {
NdisMoveMemory(pAd->MacTab.
Content[BSSID_WCID].
RSN_IE, pVIE,
(pEid->Len + 2));
pAd->MacTab.Content[BSSID_WCID].
RSNIE_Len = (pEid->Len + 2);
DBGPRINT(RT_DEBUG_TRACE,
("AssocPostProc===> Store RSN_IE for WPA SM negotiation \n"));
}
// For WPA2/WPA2PSK
else if ((pEid->Eid == IE_RSN) && (NdisEqualMemory(pEid->Octet + 2, RSN_OUI, 3))
&& (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2 || pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
{
NdisMoveMemory(pAd->MacTab.Content[BSSID_WCID].RSN_IE, pVIE, (pEid->Len + 2));
pAd->MacTab.Content[BSSID_WCID].RSNIE_Len = (pEid->Len + 2);
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
else if ((pEid->Eid == IE_RSN)
&&
(NdisEqualMemory
(pEid->Octet + 2, RSN_OUI, 3))
&& (pAd->StaCfg.AuthMode ==
Ndis802_11AuthModeWPA2
|| pAd->StaCfg.AuthMode ==
Ndis802_11AuthModeWPA2PSK)) {
NdisMoveMemory(pAd->MacTab.
Content[BSSID_WCID].
RSN_IE, pVIE,
(pEid->Len + 2));
pAd->MacTab.Content[BSSID_WCID].
RSNIE_Len = (pEid->Len + 2);
DBGPRINT(RT_DEBUG_TRACE,
("AssocPostProc===> Store RSN_IE for WPA2 SM negotiation \n"));
}
pVIE += (pEid->Len + 2);
len -= (pEid->Len + 2);
len -= (pEid->Len + 2);
}
}
if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0)
{
DBGPRINT(RT_DEBUG_TRACE, ("AssocPostProc===> no RSN_IE \n"));
}
else
{
hex_dump("RSN_IE", pAd->MacTab.Content[BSSID_WCID].RSN_IE, pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
if (pAd->MacTab.Content[BSSID_WCID].RSNIE_Len == 0) {
DBGPRINT(RT_DEBUG_TRACE,
("AssocPostProc===> no RSN_IE \n"));
} else {
hex_dump("RSN_IE",
pAd->MacTab.Content[BSSID_WCID].RSN_IE,
pAd->MacTab.Content[BSSID_WCID].RSNIE_Len);
}
}
}
......@@ -1079,36 +1144,36 @@ VOID AssocPostProc(
==========================================================================
*/
VOID PeerDisassocAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerDisassocAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Reason;
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Reason;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction()\n"));
if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() Reason = %d\n", Reason));
if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2))
{
if (pAd->CommonCfg.bWirelessEvent)
{
RTMPSendWirelessEvent(pAd, IW_DISASSOC_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
if (PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - PeerDisassocAction() Reason = %d\n",
Reason));
if (INFRA_ON(pAd)
&& MAC_ADDR_EQUAL(pAd->CommonCfg.Bssid, Addr2)) {
if (pAd->CommonCfg.bWirelessEvent) {
RTMPSendWirelessEvent(pAd,
IW_DISASSOC_EVENT_FLAG,
pAd->MacTab.
Content[BSSID_WCID].Addr,
BSS0, 0);
}
LinkDown(pAd, TRUE);
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
0);
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - PeerDisassocAction() sanity check fail\n"));
} else {
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - PeerDisassocAction() sanity check fail\n"));
}
}
......@@ -1124,11 +1189,9 @@ VOID PeerDisassocAction(
==========================================================================
*/
VOID AssocTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID AssocTimeoutAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - AssocTimeoutAction\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_REJ_TIMEOUT;
......@@ -1144,11 +1207,9 @@ VOID AssocTimeoutAction(
==========================================================================
*/
VOID ReassocTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID ReassocTimeoutAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - ReassocTimeoutAction\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_REJ_TIMEOUT;
......@@ -1164,51 +1225,49 @@ VOID ReassocTimeoutAction(
==========================================================================
*/
VOID DisassocTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID DisassocTimeoutAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - DisassocTimeoutAction\n"));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
&Status);
}
VOID InvalidStateWhenAssoc(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenAssoc(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - InvalidStateWhenAssoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status);
}
VOID InvalidStateWhenReassoc(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenReassoc(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - InvalidStateWhenReassoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status);
}
VOID InvalidStateWhenDisassociate(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenDisassociate(IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - InvalidStateWhenDisassoc(state=%ld), reset ASSOC state machine\n",
pAd->Mlme.AssocMachine.CurrState));
pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2,
&Status);
}
/*
......@@ -1224,33 +1283,31 @@ VOID InvalidStateWhenDisassociate(
==========================================================================
*/
VOID Cls3errAction(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr)
VOID Cls3errAction(IN PRTMP_ADAPTER pAd, IN PUCHAR pAddr)
{
HEADER_802_11 DisassocHdr;
PHEADER_802_11 pDisassocHdr;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
NDIS_STATUS NStatus;
USHORT Reason = REASON_CLS3ERR;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
HEADER_802_11 DisassocHdr;
PHEADER_802_11 pDisassocHdr;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
NDIS_STATUS NStatus;
USHORT Reason = REASON_CLS3ERR;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE, ("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
DBGPRINT(RT_DEBUG_TRACE,
("ASSOC - Class 3 Error, Send DISASSOC frame\n"));
MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr, pAd->CommonCfg.Bssid); // patch peap ttls switching issue
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),&DisassocHdr,
2, &Reason,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &DisassocHdr,
2, &Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
// To patch Instance and Buffalo(N) AP
// Driver has to send deauth to Instance AP, but Buffalo(N) needs to send disassoc to reset Authenticator's state machine
// Therefore, we send both of them.
pDisassocHdr = (PHEADER_802_11)pOutBuffer;
pDisassocHdr = (PHEADER_802_11) pOutBuffer;
pDisassocHdr->FC.SubType = SUBTYPE_DEAUTH;
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
......@@ -1260,206 +1317,248 @@ VOID Cls3errAction(
COPY_MAC_ADDR(pAd->StaCfg.DisassocSta, pAddr);
}
int wext_notify_event_assoc(
IN RTMP_ADAPTER *pAd)
int wext_notify_event_assoc(IN RTMP_ADAPTER * pAd)
{
char custom[IW_CUSTOM_MAX] = {0};
char custom[IW_CUSTOM_MAX] = { 0 };
if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX)
{
NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs, pAd->StaCfg.ReqVarIELen);
RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom, pAd->StaCfg.ReqVarIELen);
}
else
DBGPRINT(RT_DEBUG_TRACE, ("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
if (pAd->StaCfg.ReqVarIELen <= IW_CUSTOM_MAX) {
NdisMoveMemory(custom, pAd->StaCfg.ReqVarIEs,
pAd->StaCfg.ReqVarIELen);
RtmpOSWrielessEventSend(pAd, IWEVASSOCREQIE, -1, NULL, custom,
pAd->StaCfg.ReqVarIELen);
} else
DBGPRINT(RT_DEBUG_TRACE,
("pAd->StaCfg.ReqVarIELen > MAX_CUSTOM_LEN\n"));
return 0;
}
BOOLEAN StaAddMacTableEntry(
IN PRTMP_ADAPTER pAd,
IN PMAC_TABLE_ENTRY pEntry,
IN UCHAR MaxSupportedRateIn500Kbps,
IN HT_CAPABILITY_IE *pHtCapability,
IN UCHAR HtCapabilityLen,
IN ADD_HT_INFO_IE *pAddHtInfo,
IN UCHAR AddHtInfoLen,
IN USHORT CapabilityInfo)
BOOLEAN StaAddMacTableEntry(IN PRTMP_ADAPTER pAd,
IN PMAC_TABLE_ENTRY pEntry,
IN UCHAR MaxSupportedRateIn500Kbps,
IN HT_CAPABILITY_IE * pHtCapability,
IN UCHAR HtCapabilityLen,
IN ADD_HT_INFO_IE * pAddHtInfo,
IN UCHAR AddHtInfoLen, IN USHORT CapabilityInfo)
{
UCHAR MaxSupportedRate = RATE_11;
UCHAR MaxSupportedRate = RATE_11;
if (ADHOC_ON(pAd))
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
switch (MaxSupportedRateIn500Kbps)
{
case 108: MaxSupportedRate = RATE_54; break;
case 96: MaxSupportedRate = RATE_48; break;
case 72: MaxSupportedRate = RATE_36; break;
case 48: MaxSupportedRate = RATE_24; break;
case 36: MaxSupportedRate = RATE_18; break;
case 24: MaxSupportedRate = RATE_12; break;
case 18: MaxSupportedRate = RATE_9; break;
case 12: MaxSupportedRate = RATE_6; break;
case 22: MaxSupportedRate = RATE_11; break;
case 11: MaxSupportedRate = RATE_5_5; break;
case 4: MaxSupportedRate = RATE_2; break;
case 2: MaxSupportedRate = RATE_1; break;
default: MaxSupportedRate = RATE_11; break;
}
if ((pAd->CommonCfg.PhyMode == PHY_11G) && (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
return FALSE;
switch (MaxSupportedRateIn500Kbps) {
case 108:
MaxSupportedRate = RATE_54;
break;
case 96:
MaxSupportedRate = RATE_48;
break;
case 72:
MaxSupportedRate = RATE_36;
break;
case 48:
MaxSupportedRate = RATE_24;
break;
case 36:
MaxSupportedRate = RATE_18;
break;
case 24:
MaxSupportedRate = RATE_12;
break;
case 18:
MaxSupportedRate = RATE_9;
break;
case 12:
MaxSupportedRate = RATE_6;
break;
case 22:
MaxSupportedRate = RATE_11;
break;
case 11:
MaxSupportedRate = RATE_5_5;
break;
case 4:
MaxSupportedRate = RATE_2;
break;
case 2:
MaxSupportedRate = RATE_1;
break;
default:
MaxSupportedRate = RATE_11;
break;
}
if ((pAd->CommonCfg.PhyMode == PHY_11G)
&& (MaxSupportedRate < RATE_FIRST_OFDM_RATE))
return FALSE;
// 11n only
if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G) || (pAd->CommonCfg.PhyMode == PHY_11N_5G))&& (HtCapabilityLen == 0))
if (((pAd->CommonCfg.PhyMode == PHY_11N_2_4G)
|| (pAd->CommonCfg.PhyMode == PHY_11N_5G))
&& (HtCapabilityLen == 0))
return FALSE;
if (!pEntry)
return FALSE;
return FALSE;
NdisAcquireSpinLock(&pAd->MacTabLock);
if (pEntry)
{
if (pEntry) {
pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
if ((MaxSupportedRate < RATE_FIRST_OFDM_RATE) ||
(pAd->CommonCfg.PhyMode == PHY_11B))
{
(pAd->CommonCfg.PhyMode == PHY_11B)) {
pEntry->RateLen = 4;
if (MaxSupportedRate >= RATE_FIRST_OFDM_RATE)
MaxSupportedRate = RATE_11;
}
else
} else
pEntry->RateLen = 12;
pEntry->MaxHTPhyMode.word = 0;
pEntry->MinHTPhyMode.word = 0;
pEntry->HTPhyMode.word = 0;
pEntry->MaxSupportedRate = MaxSupportedRate;
if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE)
{
if (pEntry->MaxSupportedRate < RATE_FIRST_OFDM_RATE) {
pEntry->MaxHTPhyMode.field.MODE = MODE_CCK;
pEntry->MaxHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
pEntry->MaxHTPhyMode.field.MCS =
pEntry->MaxSupportedRate;
pEntry->MinHTPhyMode.field.MODE = MODE_CCK;
pEntry->MinHTPhyMode.field.MCS = pEntry->MaxSupportedRate;
pEntry->MinHTPhyMode.field.MCS =
pEntry->MaxSupportedRate;
pEntry->HTPhyMode.field.MODE = MODE_CCK;
pEntry->HTPhyMode.field.MCS = pEntry->MaxSupportedRate;
}
else
{
} else {
pEntry->MaxHTPhyMode.field.MODE = MODE_OFDM;
pEntry->MaxHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
pEntry->MaxHTPhyMode.field.MCS =
OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
pEntry->MinHTPhyMode.field.MODE = MODE_OFDM;
pEntry->MinHTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
pEntry->MinHTPhyMode.field.MCS =
OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
pEntry->HTPhyMode.field.MODE = MODE_OFDM;
pEntry->HTPhyMode.field.MCS = OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
pEntry->HTPhyMode.field.MCS =
OfdmRateToRxwiMCS[pEntry->MaxSupportedRate];
}
pEntry->CapabilityInfo = CapabilityInfo;
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_PIGGYBACK_CAPABLE);
CLIENT_STATUS_CLEAR_FLAG(pEntry,
fCLIENT_STATUS_AGGREGATION_CAPABLE);
CLIENT_STATUS_CLEAR_FLAG(pEntry,
fCLIENT_STATUS_PIGGYBACK_CAPABLE);
}
NdisZeroMemory(&pEntry->HTCapability, sizeof(pEntry->HTCapability));
// If this Entry supports 802.11n, upgrade to HT rate.
if ((HtCapabilityLen != 0) && (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED))
{
UCHAR j, bitmask; //k,bitmask;
CHAR i;
if ((HtCapabilityLen != 0)
&& (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)) {
UCHAR j, bitmask; //k,bitmask;
CHAR i;
if (ADHOC_ON(pAd))
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
if ((pHtCapability->HtCapInfo.GF) && (pAd->CommonCfg.DesiredHtPhy.GF))
{
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_WMM_CAPABLE);
if ((pHtCapability->HtCapInfo.GF)
&& (pAd->CommonCfg.DesiredHtPhy.GF)) {
pEntry->MaxHTPhyMode.field.MODE = MODE_HTGREENFIELD;
}
else
{
} else {
pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
pAd->MacTab.fAnyStationNonGF = TRUE;
pAd->CommonCfg.AddHTInfo.AddHtInfo2.NonGfPresent = 1;
}
if ((pHtCapability->HtCapInfo.ChannelWidth) &&
(pAd->CommonCfg.DesiredHtPhy.ChannelWidth) &&
((pAd->StaCfg.BssType == BSS_INFRA) || ((pAd->StaCfg.BssType == BSS_ADHOC) && (pAddHtInfo->AddHtInfo.ExtChanOffset == pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset))))
{
pEntry->MaxHTPhyMode.field.BW= BW_40;
pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor40)&(pHtCapability->HtCapInfo.ShortGIfor40));
}
else
{
(pAd->CommonCfg.DesiredHtPhy.ChannelWidth) &&
((pAd->StaCfg.BssType == BSS_INFRA)
|| ((pAd->StaCfg.BssType == BSS_ADHOC)
&& (pAddHtInfo->AddHtInfo.ExtChanOffset ==
pAd->CommonCfg.AddHTInfo.AddHtInfo.
ExtChanOffset)))) {
pEntry->MaxHTPhyMode.field.BW = BW_40;
pEntry->MaxHTPhyMode.field.ShortGI =
((pAd->CommonCfg.DesiredHtPhy.
ShortGIfor40) & (pHtCapability->HtCapInfo.
ShortGIfor40));
} else {
pEntry->MaxHTPhyMode.field.BW = BW_20;
pEntry->MaxHTPhyMode.field.ShortGI = ((pAd->CommonCfg.DesiredHtPhy.ShortGIfor20)&(pHtCapability->HtCapInfo.ShortGIfor20));
pEntry->MaxHTPhyMode.field.ShortGI =
((pAd->CommonCfg.DesiredHtPhy.
ShortGIfor20) & (pHtCapability->HtCapInfo.
ShortGIfor20));
pAd->MacTab.fAnyStation20Only = TRUE;
}
// 3*3
if (pAd->MACVersion >= RALINK_2883_VERSION && pAd->MACVersion < RALINK_3070_VERSION)
pEntry->MaxHTPhyMode.field.TxBF = pAd->CommonCfg.RegTransmitSetting.field.TxBF;
if (pAd->MACVersion >= RALINK_2883_VERSION
&& pAd->MACVersion < RALINK_3070_VERSION)
pEntry->MaxHTPhyMode.field.TxBF =
pAd->CommonCfg.RegTransmitSetting.field.TxBF;
// find max fixed rate
for (i=23; i>=0; i--) // 3*3
for (i = 23; i >= 0; i--) // 3*3
{
j = i/8;
bitmask = (1<<(i-(j*8)));
if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask) && (pHtCapability->MCSSet[j] & bitmask))
{
j = i / 8;
bitmask = (1 << (i - (j * 8)));
if ((pAd->StaCfg.DesiredHtPhyInfo.MCSSet[j] & bitmask)
&& (pHtCapability->MCSSet[j] & bitmask)) {
pEntry->MaxHTPhyMode.field.MCS = i;
break;
}
if (i==0)
if (i == 0)
break;
}
if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO)
{
if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32)
{
if (pAd->StaCfg.DesiredTransmitSetting.field.MCS != MCS_AUTO) {
if (pAd->StaCfg.DesiredTransmitSetting.field.MCS == 32) {
// Fix MCS as HT Duplicated Mode
pEntry->MaxHTPhyMode.field.BW = 1;
pEntry->MaxHTPhyMode.field.MODE = MODE_HTMIX;
pEntry->MaxHTPhyMode.field.STBC = 0;
pEntry->MaxHTPhyMode.field.ShortGI = 0;
pEntry->MaxHTPhyMode.field.MCS = 32;
}
else if (pEntry->MaxHTPhyMode.field.MCS > pAd->StaCfg.HTPhyMode.field.MCS)
{
} else if (pEntry->MaxHTPhyMode.field.MCS >
pAd->StaCfg.HTPhyMode.field.MCS) {
// STA supports fixed MCS
pEntry->MaxHTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
pEntry->MaxHTPhyMode.field.MCS =
pAd->StaCfg.HTPhyMode.field.MCS;
}
}
pEntry->MaxHTPhyMode.field.STBC = (pHtCapability->HtCapInfo.RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
pEntry->MaxHTPhyMode.field.STBC =
(pHtCapability->HtCapInfo.
RxSTBC & (pAd->CommonCfg.DesiredHtPhy.TxSTBC));
pEntry->MpduDensity = pHtCapability->HtCapParm.MpduDensity;
pEntry->MaxRAmpduFactor = pHtCapability->HtCapParm.MaxRAmpduFactor;
pEntry->MmpsMode = (UCHAR)pHtCapability->HtCapInfo.MimoPs;
pEntry->AMsduSize = (UCHAR)pHtCapability->HtCapInfo.AMsduSize;
pEntry->MaxRAmpduFactor =
pHtCapability->HtCapParm.MaxRAmpduFactor;
pEntry->MmpsMode = (UCHAR) pHtCapability->HtCapInfo.MimoPs;
pEntry->AMsduSize = (UCHAR) pHtCapability->HtCapInfo.AMsduSize;
pEntry->HTPhyMode.word = pEntry->MaxHTPhyMode.word;
if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable && (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AMSDU_INUSED);
if (pAd->CommonCfg.DesiredHtPhy.AmsduEnable
&& (pAd->CommonCfg.REGBACapability.field.AutoBA == FALSE))
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_AMSDU_INUSED);
if (pHtCapability->HtCapInfo.ShortGIfor20)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI20_CAPABLE);
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_SGI20_CAPABLE);
if (pHtCapability->HtCapInfo.ShortGIfor40)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_SGI40_CAPABLE);
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_SGI40_CAPABLE);
if (pHtCapability->HtCapInfo.TxSTBC)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_TxSTBC_CAPABLE);
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_TxSTBC_CAPABLE);
if (pHtCapability->HtCapInfo.RxSTBC)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RxSTBC_CAPABLE);
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_RxSTBC_CAPABLE);
if (pHtCapability->ExtHtCapInfo.PlusHTC)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_HTC_CAPABLE);
if (pAd->CommonCfg.bRdg && pHtCapability->ExtHtCapInfo.RDGSupport)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_RDG_CAPABLE);
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_HTC_CAPABLE);
if (pAd->CommonCfg.bRdg
&& pHtCapability->ExtHtCapInfo.RDGSupport)
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_RDG_CAPABLE);
if (pHtCapability->ExtHtCapInfo.MCSFeedback == 0x03)
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
NdisMoveMemory(&pEntry->HTCapability, pHtCapability, HtCapabilityLen);
}
else
{
CLIENT_STATUS_SET_FLAG(pEntry,
fCLIENT_STATUS_MCSFEEDBACK_CAPABLE);
NdisMoveMemory(&pEntry->HTCapability, pHtCapability,
HtCapabilityLen);
} else {
pAd->MacTab.fAnyStationIsLegacy = TRUE;
}
......@@ -1467,22 +1566,22 @@ BOOLEAN StaAddMacTableEntry(
pEntry->CurrTxRate = pEntry->MaxSupportedRate;
// Set asic auto fall back
if (pAd->StaCfg.bAutoTxRateSwitch == TRUE)
{
PUCHAR pTable;
UCHAR TableSize = 0;
if (pAd->StaCfg.bAutoTxRateSwitch == TRUE) {
PUCHAR pTable;
UCHAR TableSize = 0;
MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize, &pEntry->CurrTxRateIndex);
MlmeSelectTxRateTable(pAd, pEntry, &pTable, &TableSize,
&pEntry->CurrTxRateIndex);
pEntry->bAutoTxRateSwitch = TRUE;
}
else
{
pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
} else {
pEntry->HTPhyMode.field.MODE = pAd->StaCfg.HTPhyMode.field.MODE;
pEntry->HTPhyMode.field.MCS = pAd->StaCfg.HTPhyMode.field.MCS;
pEntry->bAutoTxRateSwitch = FALSE;
// If the legacy mode is set, overwrite the transmit setting of this entry.
RTMPUpdateLegacyTxSetting((UCHAR)pAd->StaCfg.DesiredTransmitSetting.field.FixedTxMode, pEntry);
RTMPUpdateLegacyTxSetting((UCHAR) pAd->StaCfg.
DesiredTransmitSetting.field.
FixedTxMode, pEntry);
}
pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
......@@ -1493,14 +1592,14 @@ BOOLEAN StaAddMacTableEntry(
NdisReleaseSpinLock(&pAd->MacTabLock);
{
union iwreq_data wrqu;
wext_notify_event_assoc(pAd);
{
union iwreq_data wrqu;
wext_notify_event_assoc(pAd);
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN);
memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN);
wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL);
}
}
return TRUE;
}
......@@ -55,27 +55,35 @@
==========================================================================
*/
void AuthStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[])
void AuthStateMachineInit(IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE * Sm, OUT STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_REQ_IDLE, AUTH_MACHINE_BASE);
// the first column
StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)MlmeAuthReqAction);
// the second column
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq2Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
// the third column
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN, (STATE_MACHINE_FUNC)PeerAuthRspAtSeq4Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT, (STATE_MACHINE_FUNC)AuthTimeoutAction);
RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer, GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
StateMachineInit(Sm, Trans, MAX_AUTH_STATE, MAX_AUTH_MSG,
(STATE_MACHINE_FUNC) Drop, AUTH_REQ_IDLE,
AUTH_MACHINE_BASE);
// the first column
StateMachineSetAction(Sm, AUTH_REQ_IDLE, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) MlmeAuthReqAction);
// the second column
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_PEER_AUTH_EVEN,
(STATE_MACHINE_FUNC) PeerAuthRspAtSeq2Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ2, MT2_AUTH_TIMEOUT,
(STATE_MACHINE_FUNC) AuthTimeoutAction);
// the third column
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_MLME_AUTH_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenAuth);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_PEER_AUTH_EVEN,
(STATE_MACHINE_FUNC) PeerAuthRspAtSeq4Action);
StateMachineSetAction(Sm, AUTH_WAIT_SEQ4, MT2_AUTH_TIMEOUT,
(STATE_MACHINE_FUNC) AuthTimeoutAction);
RTMPInitTimer(pAd, &pAd->MlmeAux.AuthTimer,
GET_TIMER_FUNCTION(AuthTimeout), pAd, FALSE);
}
/*
......@@ -87,31 +95,28 @@ void AuthStateMachineInit(
==========================================================================
*/
VOID AuthTimeout(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
VOID AuthTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
DBGPRINT(RT_DEBUG_TRACE,("AUTH - AuthTimeout\n"));
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeout\n"));
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
if (RTMP_TEST_FLAG
(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST))
return;
// send a de-auth to reset AP's state machine (Patch AP-Dir635)
if (pAd->Mlme.AuthMachine.CurrState == AUTH_WAIT_SEQ2)
Cls2errAction(pAd, pAd->MlmeAux.Bssid);
MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
RTMP_MLME_HANDLER(pAd);
MlmeEnqueue(pAd, AUTH_STATE_MACHINE, MT2_AUTH_TIMEOUT, 0, NULL);
RTMP_MLME_HANDLER(pAd);
}
/*
==========================================================================
Description:
......@@ -120,20 +125,19 @@ VOID AuthTimeout(
==========================================================================
*/
VOID MlmeAuthReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeAuthReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
if (AUTH_ReqSend(pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
else
{
if (AUTH_ReqSend
(pAd, Elem, &pAd->MlmeAux.AuthTimer, "AUTH", 1, NULL, 0))
pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ2;
else {
USHORT Status;
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
&Status);
}
}
/*
......@@ -144,101 +148,130 @@ VOID MlmeAuthReqAction(
==========================================================================
*/
VOID PeerAuthRspAtSeq2Action(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerAuthRspAtSeq2Action(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Seq, Status, RemoteStatus, Alg;
UCHAR ChlgText[CIPHER_TEXT_LEN];
UCHAR CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
UCHAR Element[2];
HEADER_802_11 AuthHdr;
BOOLEAN TimerCancelled;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Status2;
if (PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, (PCHAR)ChlgText))
{
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2)
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n", Alg, Status));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
if (Status == MLME_SUCCESS)
{
// Authentication Mode "LEAP" has allow for CCX 1.X
if (pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen)
{
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
else
{
// 2. shared key, need to be challenged
Seq++;
RemoteStatus = MLME_SUCCESS;
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Seq, Status, RemoteStatus, Alg;
UCHAR ChlgText[CIPHER_TEXT_LEN];
UCHAR CyperChlgText[CIPHER_TEXT_LEN + 8 + 8];
UCHAR Element[2];
HEADER_802_11 AuthHdr;
BOOLEAN TimerCancelled;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Status2;
if (PeerAuthSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
(PCHAR) ChlgText)) {
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 2) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Receive AUTH_RSP seq#2 to me (Alg=%d, Status=%d)\n",
Alg, Status));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
&TimerCancelled);
if (Status == MLME_SUCCESS) {
// Authentication Mode "LEAP" has allow for CCX 1.X
if (pAd->MlmeAux.Alg == Ndis802_11AuthModeOpen) {
pAd->Mlme.AuthMachine.CurrState =
AUTH_REQ_IDLE;
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2, &Status);
} else {
// 2. shared key, need to be challenged
Seq++;
RemoteStatus = MLME_SUCCESS;
// Get an unused nonpaged memory
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if(NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status2 = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status2);
return;
}
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send AUTH request seq#3...\n"));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr2, pAd->MlmeAux.Bssid);
AuthHdr.FC.Wep = 1;
// Encrypt challenge text & auth information
RTMPInitWepEngine(
pAd,
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].Key,
pAd->StaCfg.DefaultKeyId,
pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId].KeyLen,
CyperChlgText);
Alg = cpu2le16(*(USHORT *)&Alg);
Seq = cpu2le16(*(USHORT *)&Seq);
RemoteStatus= cpu2le16(*(USHORT *)&RemoteStatus);
RTMPEncryptData(pAd, (PUCHAR) &Alg, CyperChlgText + 4, 2);
RTMPEncryptData(pAd, (PUCHAR) &Seq, CyperChlgText + 6, 2);
RTMPEncryptData(pAd, (PUCHAR) &RemoteStatus, CyperChlgText + 8, 2);
NStatus =
MlmeAllocateMemory(pAd,
&pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthRspAtSeq2Action() allocate memory fail\n"));
pAd->Mlme.AuthMachine.
CurrState = AUTH_REQ_IDLE;
Status2 = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2,
&Status2);
return;
}
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Send AUTH request seq#3...\n"));
MgtMacHeaderInit(pAd, &AuthHdr,
SUBTYPE_AUTH, 0, Addr2,
pAd->MlmeAux.Bssid);
AuthHdr.FC.Wep = 1;
// Encrypt challenge text & auth information
RTMPInitWepEngine(pAd,
pAd->
SharedKey[BSS0][pAd->
StaCfg.
DefaultKeyId].
Key,
pAd->StaCfg.
DefaultKeyId,
pAd->
SharedKey[BSS0][pAd->
StaCfg.
DefaultKeyId].
KeyLen,
CyperChlgText);
Alg = cpu2le16(*(USHORT *) & Alg);
Seq = cpu2le16(*(USHORT *) & Seq);
RemoteStatus =
cpu2le16(*(USHORT *) &
RemoteStatus);
RTMPEncryptData(pAd, (PUCHAR) & Alg,
CyperChlgText + 4, 2);
RTMPEncryptData(pAd, (PUCHAR) & Seq,
CyperChlgText + 6, 2);
RTMPEncryptData(pAd,
(PUCHAR) & RemoteStatus,
CyperChlgText + 8, 2);
Element[0] = 16;
Element[1] = 128;
RTMPEncryptData(pAd, Element, CyperChlgText + 10, 2);
RTMPEncryptData(pAd, ChlgText, CyperChlgText + 12, 128);
RTMPEncryptData(pAd, Element,
CyperChlgText + 10, 2);
RTMPEncryptData(pAd, ChlgText,
CyperChlgText + 12,
128);
RTMPSetICV(pAd, CyperChlgText + 140);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &AuthHdr,
CIPHER_TEXT_LEN + 16, CyperChlgText,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(&pAd->MlmeAux.AuthTimer, AUTH_TIMEOUT);
pAd->Mlme.AuthMachine.CurrState = AUTH_WAIT_SEQ4;
}
}
else
{
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthSanity() sanity check fail\n"));
}
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),
&AuthHdr,
CIPHER_TEXT_LEN + 16,
CyperChlgText,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer,
FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(&pAd->MlmeAux.AuthTimer,
AUTH_TIMEOUT);
pAd->Mlme.AuthMachine.CurrState =
AUTH_WAIT_SEQ4;
}
} else {
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE,
MT2_AUTH_CONF, 2, &Status);
}
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthSanity() sanity check fail\n"));
}
}
/*
......@@ -249,36 +282,35 @@ VOID PeerAuthRspAtSeq2Action(
==========================================================================
*/
VOID PeerAuthRspAtSeq4Action(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerAuthRspAtSeq4Action(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Alg, Seq, Status;
CHAR ChlgText[CIPHER_TEXT_LEN];
BOOLEAN TimerCancelled;
if(PeerAuthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status, ChlgText))
{
if(MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4)
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Receive AUTH_RSP seq#4 to me\n"));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer, &TimerCancelled);
if (Status != MLME_SUCCESS)
{
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
}
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
}
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Alg, Seq, Status;
CHAR ChlgText[CIPHER_TEXT_LEN];
BOOLEAN TimerCancelled;
if (PeerAuthSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Alg, &Seq, &Status,
ChlgText)) {
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Addr2) && Seq == 4) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Receive AUTH_RSP seq#4 to me\n"));
RTMPCancelTimer(&pAd->MlmeAux.AuthTimer,
&TimerCancelled);
if (Status != MLME_SUCCESS) {
pAd->StaCfg.AuthFailReason = Status;
COPY_MAC_ADDR(pAd->StaCfg.AuthFailSta, Addr2);
}
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
2, &Status);
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - PeerAuthRspAtSeq4Action() sanity check fail\n"));
}
}
/*
......@@ -289,47 +321,49 @@ VOID PeerAuthRspAtSeq4Action(
==========================================================================
*/
VOID MlmeDeauthReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeDeauthReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
MLME_DEAUTH_REQ_STRUCT *pInfo;
HEADER_802_11 DeauthHdr;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Status;
pInfo = (MLME_DEAUTH_REQ_STRUCT *)Elem->Msg;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
return;
}
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Send DE-AUTH request (Reason=%d)...\n", pInfo->Reason));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr, pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),&DeauthHdr,
2, &pInfo->Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MLME_DEAUTH_REQ_STRUCT *pInfo;
HEADER_802_11 DeauthHdr;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Status;
pInfo = (MLME_DEAUTH_REQ_STRUCT *) Elem->Msg;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - MlmeDeauthReqAction() allocate memory fail\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2,
&Status);
return;
}
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Send DE-AUTH request (Reason=%d)...\n",
pInfo->Reason));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pInfo->Addr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),
&DeauthHdr, 2, &pInfo->Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
pAd->StaCfg.DeauthReason = pInfo->Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
pAd->StaCfg.DeauthReason = pInfo->Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pInfo->Addr);
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DEAUTH_CONF, 2, &Status);
// send wireless event - for deauthentication
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
pAd->MacTab.Content[BSSID_WCID].Addr,
BSS0, 0);
}
/*
......@@ -340,15 +374,13 @@ VOID MlmeDeauthReqAction(
==========================================================================
*/
VOID AuthTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID AuthTimeoutAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_REJ_TIMEOUT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - AuthTimeoutAction\n"));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_REJ_TIMEOUT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
/*
......@@ -359,15 +391,15 @@ VOID AuthTimeoutAction(
==========================================================================
*/
VOID InvalidStateWhenAuth(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenAuth(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n", pAd->Mlme.AuthMachine.CurrState));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - InvalidStateWhenAuth (state=%ld), reset AUTH state machine\n",
pAd->Mlme.AuthMachine.CurrState));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
/*
......@@ -382,109 +414,104 @@ VOID InvalidStateWhenAuth(
==========================================================================
*/
VOID Cls2errAction(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr)
VOID Cls2errAction(IN PRTMP_ADAPTER pAd, IN PUCHAR pAddr)
{
HEADER_802_11 DeauthHdr;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Reason = REASON_CLS2ERR;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE, ("AUTH - Class 2 error, Send DEAUTH frame...\n"));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr, pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),&DeauthHdr,
2, &Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
HEADER_802_11 DeauthHdr;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
USHORT Reason = REASON_CLS2ERR;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE,
("AUTH - Class 2 error, Send DEAUTH frame...\n"));
MgtMacHeaderInit(pAd, &DeauthHdr, SUBTYPE_DEAUTH, 0, pAddr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),
&DeauthHdr, 2, &Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
pAd->StaCfg.DeauthReason = Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
pAd->StaCfg.DeauthReason = Reason;
COPY_MAC_ADDR(pAd->StaCfg.DeauthSta, pAddr);
}
BOOLEAN AUTH_ReqSend(
IN PRTMP_ADAPTER pAd,
IN PMLME_QUEUE_ELEM pElem,
IN PRALINK_TIMER_STRUCT pAuthTimer,
IN PSTRING pSMName,
IN USHORT SeqNo,
IN PUCHAR pNewElement,
IN ULONG ElementLen)
BOOLEAN AUTH_ReqSend(IN PRTMP_ADAPTER pAd,
IN PMLME_QUEUE_ELEM pElem,
IN PRALINK_TIMER_STRUCT pAuthTimer,
IN PSTRING pSMName,
IN USHORT SeqNo,
IN PUCHAR pNewElement, IN ULONG ElementLen)
{
USHORT Alg, Seq, Status;
UCHAR Addr[6];
ULONG Timeout;
HEADER_802_11 AuthHdr;
BOOLEAN TimerCancelled;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0, tmp = 0;
USHORT Alg, Seq, Status;
UCHAR Addr[6];
ULONG Timeout;
HEADER_802_11 AuthHdr;
BOOLEAN TimerCancelled;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0, tmp = 0;
// Block all authentication request durning WPA block period
if (pAd->StaCfg.bBlockAssoc == TRUE)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s - Block Auth request durning WPA block period!\n", pSMName));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
}
else if(MlmeAuthReqSanity(pAd, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg))
{
/* reset timer */
if (pAd->StaCfg.bBlockAssoc == TRUE) {
DBGPRINT(RT_DEBUG_TRACE,
("%s - Block Auth request durning WPA block period!\n",
pSMName));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2,
&Status);
} else
if (MlmeAuthReqSanity
(pAd, pElem->Msg, pElem->MsgLen, Addr, &Timeout, &Alg)) {
/* reset timer */
RTMPCancelTimer(pAuthTimer, &TimerCancelled);
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
pAd->MlmeAux.Alg = Alg;
Seq = SeqNo;
Status = MLME_SUCCESS;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if(NStatus != NDIS_STATUS_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n", pSMName, Alg));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF, 2, &Status);
return FALSE;
}
DBGPRINT(RT_DEBUG_TRACE, ("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName, Alg));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr, pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11),&AuthHdr,
2, &Alg,
2, &Seq,
2, &Status,
END_OF_ARGS);
if (pNewElement && ElementLen)
{
MakeOutgoingFrame(pOutBuffer+FrameLen, &tmp,
ElementLen, pNewElement,
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, Addr);
pAd->MlmeAux.Alg = Alg;
Seq = SeqNo;
Status = MLME_SUCCESS;
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE,
("%s - MlmeAuthReqAction(Alg:%d) allocate memory failed\n",
pSMName, Alg));
pAd->Mlme.AuthMachine.CurrState = AUTH_REQ_IDLE;
Status = MLME_FAIL_NO_RESOURCE;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_AUTH_CONF,
2, &Status);
return FALSE;
}
DBGPRINT(RT_DEBUG_TRACE,
("%s - Send AUTH request seq#1 (Alg=%d)...\n", pSMName,
Alg));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, Addr,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),
&AuthHdr, 2, &Alg, 2, &Seq, 2, &Status,
END_OF_ARGS);
if (pNewElement && ElementLen) {
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
ElementLen, pNewElement, END_OF_ARGS);
FrameLen += tmp;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
RTMPSetTimer(pAuthTimer, Timeout);
return TRUE;
}
else
{
DBGPRINT_ERR(("%s - MlmeAuthReqAction() sanity check failed\n", pSMName));
} else {
DBGPRINT_ERR(("%s - MlmeAuthReqAction() sanity check failed\n",
pSMName));
return FALSE;
}
}
return TRUE;
}
......@@ -47,18 +47,21 @@
==========================================================================
*/
VOID AuthRspStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN PSTATE_MACHINE Sm,
IN STATE_MACHINE_FUNC Trans[])
VOID AuthRspStateMachineInit(IN PRTMP_ADAPTER pAd,
IN PSTATE_MACHINE Sm,
IN STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG, (STATE_MACHINE_FUNC)Drop, AUTH_RSP_IDLE, AUTH_RSP_MACHINE_BASE);
StateMachineInit(Sm, Trans, MAX_AUTH_RSP_STATE, MAX_AUTH_RSP_MSG,
(STATE_MACHINE_FUNC) Drop, AUTH_RSP_IDLE,
AUTH_RSP_MACHINE_BASE);
// column 1
StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
// column 1
StateMachineSetAction(Sm, AUTH_RSP_IDLE, MT2_PEER_DEAUTH,
(STATE_MACHINE_FUNC) PeerDeauthAction);
// column 2
StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH, (STATE_MACHINE_FUNC)PeerDeauthAction);
// column 2
StateMachineSetAction(Sm, AUTH_RSP_WAIT_CHAL, MT2_PEER_DEAUTH,
(STATE_MACHINE_FUNC) PeerDeauthAction);
}
......@@ -70,39 +73,32 @@ VOID AuthRspStateMachineInit(
==========================================================================
*/
VOID PeerAuthSimpleRspGenAndSend(
IN PRTMP_ADAPTER pAd,
IN PHEADER_802_11 pHdr80211,
IN USHORT Alg,
IN USHORT Seq,
IN USHORT Reason,
IN USHORT Status)
VOID PeerAuthSimpleRspGenAndSend(IN PRTMP_ADAPTER pAd,
IN PHEADER_802_11 pHdr80211,
IN USHORT Alg,
IN USHORT Seq,
IN USHORT Reason, IN USHORT Status)
{
HEADER_802_11 AuthHdr;
ULONG FrameLen = 0;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
if (Reason != MLME_SUCCESS)
{
DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
return;
}
HEADER_802_11 AuthHdr;
ULONG FrameLen = 0;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
if (Reason != MLME_SUCCESS) {
DBGPRINT(RT_DEBUG_TRACE, ("Peer AUTH fail...\n"));
return;
}
//Get an unused nonpaged memory
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2, pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &AuthHdr,
2, &Alg,
2, &Seq,
2, &Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if (NStatus != NDIS_STATUS_SUCCESS)
return;
DBGPRINT(RT_DEBUG_TRACE, ("Send AUTH response (seq#2)...\n"));
MgtMacHeaderInit(pAd, &AuthHdr, SUBTYPE_AUTH, 0, pHdr80211->Addr2,
pAd->MlmeAux.Bssid);
MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),
&AuthHdr, 2, &Alg, 2, &Seq, 2, &Reason, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
......@@ -114,35 +110,33 @@ VOID PeerAuthSimpleRspGenAndSend(
==========================================================================
*/
VOID PeerDeauthAction(
IN PRTMP_ADAPTER pAd,
IN PMLME_QUEUE_ELEM Elem)
VOID PeerDeauthAction(IN PRTMP_ADAPTER pAd, IN PMLME_QUEUE_ELEM Elem)
{
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Reason;
if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason))
{
if (INFRA_ON(pAd)
&& MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
)
{
DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n", Reason));
UCHAR Addr2[MAC_ADDR_LEN];
USHORT Reason;
if (PeerDeauthSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) {
if (INFRA_ON(pAd)
&& MAC_ADDR_EQUAL(Addr2, pAd->CommonCfg.Bssid)
) {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH_RSP - receive DE-AUTH from our AP (Reason=%d)\n",
Reason));
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL, 0);
RtmpOSWrielessEventSend(pAd, SIOCGIWAP, -1, NULL, NULL,
0);
// send wireless event - for deauthentication
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
LinkDown(pAd, TRUE);
}
}
else
{
DBGPRINT(RT_DEBUG_TRACE,("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
}
RTMPSendWirelessEvent(pAd, IW_DEAUTH_EVENT_FLAG,
pAd->MacTab.
Content[BSSID_WCID].Addr,
BSS0, 0);
LinkDown(pAd, TRUE);
}
} else {
DBGPRINT(RT_DEBUG_TRACE,
("AUTH_RSP - PeerDeauthAction() sanity check fail\n"));
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,15 +36,15 @@
*/
#include "../rt_config.h"
extern UCHAR CISCO_OUI[];
extern UCHAR CISCO_OUI[];
extern UCHAR WPA_OUI[];
extern UCHAR RSN_OUI[];
extern UCHAR WME_INFO_ELEM[];
extern UCHAR WME_PARM_ELEM[];
extern UCHAR Ccx2QosInfo[];
extern UCHAR RALINK_OUI[];
extern UCHAR BROADCOM_OUI[];
extern UCHAR WPA_OUI[];
extern UCHAR RSN_OUI[];
extern UCHAR WME_INFO_ELEM[];
extern UCHAR WME_PARM_ELEM[];
extern UCHAR Ccx2QosInfo[];
extern UCHAR RALINK_OUI[];
extern UCHAR BROADCOM_OUI[];
/*
==========================================================================
......@@ -54,27 +54,25 @@ extern UCHAR BROADCOM_OUI[];
TRUE if all parameters are OK, FALSE otherwise
==========================================================================
*/
BOOLEAN MlmeStartReqSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT CHAR Ssid[],
OUT UCHAR *pSsidLen)
BOOLEAN MlmeStartReqSanity(IN PRTMP_ADAPTER pAd,
IN VOID * Msg,
IN ULONG MsgLen,
OUT CHAR Ssid[], OUT UCHAR * pSsidLen)
{
MLME_START_REQ_STRUCT *Info;
MLME_START_REQ_STRUCT *Info;
Info = (MLME_START_REQ_STRUCT *)(Msg);
Info = (MLME_START_REQ_STRUCT *) (Msg);
if (Info->SsidLen > MAX_LEN_OF_SSID)
{
DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqSanity fail - wrong SSID length\n"));
return FALSE;
}
if (Info->SsidLen > MAX_LEN_OF_SSID) {
DBGPRINT(RT_DEBUG_TRACE,
("MlmeStartReqSanity fail - wrong SSID length\n"));
return FALSE;
}
*pSsidLen = Info->SsidLen;
NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
*pSsidLen = Info->SsidLen;
NdisMoveMemory(Ssid, Info->Ssid, *pSsidLen);
return TRUE;
return TRUE;
}
/*
......@@ -88,171 +86,161 @@ BOOLEAN MlmeStartReqSanity(
==========================================================================
*/
BOOLEAN PeerAssocRspSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *pMsg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT USHORT *pCapabilityInfo,
OUT USHORT *pStatus,
OUT USHORT *pAid,
OUT UCHAR SupRate[],
OUT UCHAR *pSupRateLen,
OUT UCHAR ExtRate[],
OUT UCHAR *pExtRateLen,
OUT HT_CAPABILITY_IE *pHtCapability,
OUT ADD_HT_INFO_IE *pAddHtInfo, // AP might use this additional ht info IE
OUT UCHAR *pHtCapabilityLen,
OUT UCHAR *pAddHtInfoLen,
OUT UCHAR *pNewExtChannelOffset,
OUT PEDCA_PARM pEdcaParm,
OUT UCHAR *pCkipFlag)
BOOLEAN PeerAssocRspSanity(IN PRTMP_ADAPTER pAd, IN VOID * pMsg, IN ULONG MsgLen, OUT PUCHAR pAddr2, OUT USHORT * pCapabilityInfo, OUT USHORT * pStatus, OUT USHORT * pAid, OUT UCHAR SupRate[], OUT UCHAR * pSupRateLen, OUT UCHAR ExtRate[], OUT UCHAR * pExtRateLen, OUT HT_CAPABILITY_IE * pHtCapability, OUT ADD_HT_INFO_IE * pAddHtInfo, // AP might use this additional ht info IE
OUT UCHAR * pHtCapabilityLen,
OUT UCHAR * pAddHtInfoLen,
OUT UCHAR * pNewExtChannelOffset,
OUT PEDCA_PARM pEdcaParm, OUT UCHAR * pCkipFlag)
{
CHAR IeType, *Ptr;
PFRAME_802_11 pFrame = (PFRAME_802_11)pMsg;
PEID_STRUCT pEid;
ULONG Length = 0;
CHAR IeType, *Ptr;
PFRAME_802_11 pFrame = (PFRAME_802_11) pMsg;
PEID_STRUCT pEid;
ULONG Length = 0;
*pNewExtChannelOffset = 0xff;
*pHtCapabilityLen = 0;
*pAddHtInfoLen = 0;
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
Ptr = (PCHAR)pFrame->Octet;
Length += LENGTH_802_11;
NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
Length += 2;
NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
Length += 2;
*pCkipFlag = 0;
*pExtRateLen = 0;
pEdcaParm->bValid = FALSE;
if (*pStatus != MLME_SUCCESS)
return TRUE;
NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
Length += 2;
// Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
*pAid = (*pAid) & 0x3fff; // AID is low 14-bit
// -- get supported rates from payload and advance the pointer
IeType = pFrame->Octet[6];
*pSupRateLen = pFrame->Octet[7];
if ((IeType != IE_SUPP_RATES) || (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES))
{
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
return FALSE;
}
else
NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
Length = Length + 2 + *pSupRateLen;
// many AP implement proprietary IEs in non-standard order, we'd better
// tolerate mis-ordered IEs to get best compatibility
pEid = (PEID_STRUCT) &pFrame->Octet[8 + (*pSupRateLen)];
// get variable fields from payload and advance the pointer
while ((Length + 2 + pEid->Len) <= MsgLen)
{
switch (pEid->Eid)
{
case IE_EXT_SUPP_RATES:
if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES)
{
NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
*pExtRateLen = pEid->Len;
}
break;
case IE_HT_CAP:
case IE_HT_CAP2:
if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
Ptr = (PCHAR) pFrame->Octet;
Length += LENGTH_802_11;
NdisMoveMemory(pCapabilityInfo, &pFrame->Octet[0], 2);
Length += 2;
NdisMoveMemory(pStatus, &pFrame->Octet[2], 2);
Length += 2;
*pCkipFlag = 0;
*pExtRateLen = 0;
pEdcaParm->bValid = FALSE;
if (*pStatus != MLME_SUCCESS)
return TRUE;
NdisMoveMemory(pAid, &pFrame->Octet[4], 2);
Length += 2;
// Aid already swaped byte order in RTMPFrameEndianChange() for big endian platform
*pAid = (*pAid) & 0x3fff; // AID is low 14-bit
// -- get supported rates from payload and advance the pointer
IeType = pFrame->Octet[6];
*pSupRateLen = pFrame->Octet[7];
if ((IeType != IE_SUPP_RATES)
|| (*pSupRateLen > MAX_LEN_OF_SUPPORTED_RATES)) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspSanity fail - wrong SupportedRates IE\n"));
return FALSE;
} else
NdisMoveMemory(SupRate, &pFrame->Octet[8], *pSupRateLen);
Length = Length + 2 + *pSupRateLen;
// many AP implement proprietary IEs in non-standard order, we'd better
// tolerate mis-ordered IEs to get best compatibility
pEid = (PEID_STRUCT) & pFrame->Octet[8 + (*pSupRateLen)];
// get variable fields from payload and advance the pointer
while ((Length + 2 + pEid->Len) <= MsgLen) {
switch (pEid->Eid) {
case IE_EXT_SUPP_RATES:
if (pEid->Len <= MAX_LEN_OF_SUPPORTED_RATES) {
NdisMoveMemory(ExtRate, pEid->Octet, pEid->Len);
*pExtRateLen = pEid->Len;
}
break;
case IE_HT_CAP:
case IE_HT_CAP2:
if (pEid->Len >= SIZE_HT_CAP_IE) //Note: allow extension.!!
{
NdisMoveMemory(pHtCapability, pEid->Octet, SIZE_HT_CAP_IE);
NdisMoveMemory(pHtCapability, pEid->Octet,
SIZE_HT_CAP_IE);
*(USHORT *)(&pHtCapability->HtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->HtCapInfo));
*(USHORT *)(&pHtCapability->ExtHtCapInfo) = cpu2le16(*(USHORT *)(&pHtCapability->ExtHtCapInfo));
*(USHORT *) (&pHtCapability->HtCapInfo) =
cpu2le16(*(USHORT *)
(&pHtCapability->HtCapInfo));
*(USHORT *) (&pHtCapability->ExtHtCapInfo) =
cpu2le16(*(USHORT *)
(&pHtCapability->ExtHtCapInfo));
*pHtCapabilityLen = SIZE_HT_CAP_IE;
}
else
{
DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_HT_CAP. \n"));
}
break;
case IE_ADD_HT:
case IE_ADD_HT2:
if (pEid->Len >= sizeof(ADD_HT_INFO_IE))
{
break;
case IE_ADD_HT:
case IE_ADD_HT2:
if (pEid->Len >= sizeof(ADD_HT_INFO_IE)) {
// This IE allows extension, but we can ignore extra bytes beyond our knowledge , so only
// copy first sizeof(ADD_HT_INFO_IE)
NdisMoveMemory(pAddHtInfo, pEid->Octet, sizeof(ADD_HT_INFO_IE));
NdisMoveMemory(pAddHtInfo, pEid->Octet,
sizeof(ADD_HT_INFO_IE));
*(USHORT *)(&pAddHtInfo->AddHtInfo2) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo2));
*(USHORT *)(&pAddHtInfo->AddHtInfo3) = cpu2le16(*(USHORT *)(&pAddHtInfo->AddHtInfo3));
*(USHORT *) (&pAddHtInfo->AddHtInfo2) =
cpu2le16(*(USHORT *)
(&pAddHtInfo->AddHtInfo2));
*(USHORT *) (&pAddHtInfo->AddHtInfo3) =
cpu2le16(*(USHORT *)
(&pAddHtInfo->AddHtInfo3));
*pAddHtInfoLen = SIZE_ADD_HT_INFO_IE;
}
else
{
DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_ADD_HT. \n"));
}
break;
case IE_SECONDARY_CH_OFFSET:
if (pEid->Len == 1)
{
break;
case IE_SECONDARY_CH_OFFSET:
if (pEid->Len == 1) {
*pNewExtChannelOffset = pEid->Octet[0];
} else {
DBGPRINT(RT_DEBUG_WARN,
("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
}
else
{
DBGPRINT(RT_DEBUG_WARN, ("PeerAssocRspSanity - wrong IE_SECONDARY_CH_OFFSET. \n"));
break;
case IE_VENDOR_SPECIFIC:
// handle WME PARAMTER ELEMENT
if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6)
&& (pEid->Len == 24)) {
PUCHAR ptr;
int i;
// parsing EDCA parameters
pEdcaParm->bValid = TRUE;
pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
//pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80;
pEdcaParm->EdcaUpdateCount =
pEid->Octet[6] & 0x0f;
pEdcaParm->bAPSDCapable =
(pEid->Octet[6] & 0x80) ? 1 : 0;
ptr = (PUCHAR) & pEid->Octet[8];
for (i = 0; i < 4; i++) {
UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
pEdcaParm->Cwmin[aci] = *(ptr + 1) & 0x0f; // b0~4 is Cwmin
pEdcaParm->Cwmax[aci] = *(ptr + 1) >> 4; // b5~8 is Cwmax
pEdcaParm->Txop[aci] = *(ptr + 2) + 256 * (*(ptr + 3)); // in unit of 32-us
ptr += 4; // point to next AC
}
}
break;
case IE_VENDOR_SPECIFIC:
// handle WME PARAMTER ELEMENT
if (NdisEqualMemory(pEid->Octet, WME_PARM_ELEM, 6) && (pEid->Len == 24))
{
PUCHAR ptr;
int i;
// parsing EDCA parameters
pEdcaParm->bValid = TRUE;
pEdcaParm->bQAck = FALSE; // pEid->Octet[0] & 0x10;
pEdcaParm->bQueueRequest = FALSE; // pEid->Octet[0] & 0x20;
pEdcaParm->bTxopRequest = FALSE; // pEid->Octet[0] & 0x40;
//pEdcaParm->bMoreDataAck = FALSE; // pEid->Octet[0] & 0x80;
pEdcaParm->EdcaUpdateCount = pEid->Octet[6] & 0x0f;
pEdcaParm->bAPSDCapable = (pEid->Octet[6] & 0x80) ? 1 : 0;
ptr = (PUCHAR)&pEid->Octet[8];
for (i=0; i<4; i++)
{
UCHAR aci = (*ptr & 0x60) >> 5; // b5~6 is AC INDEX
pEdcaParm->bACM[aci] = (((*ptr) & 0x10) == 0x10); // b5 is ACM
pEdcaParm->Aifsn[aci] = (*ptr) & 0x0f; // b0~3 is AIFSN
pEdcaParm->Cwmin[aci] = *(ptr+1) & 0x0f; // b0~4 is Cwmin
pEdcaParm->Cwmax[aci] = *(ptr+1) >> 4; // b5~8 is Cwmax
pEdcaParm->Txop[aci] = *(ptr+2) + 256 * (*(ptr+3)); // in unit of 32-us
ptr += 4; // point to next AC
}
}
break;
default:
DBGPRINT(RT_DEBUG_TRACE, ("PeerAssocRspSanity - ignore unrecognized EID = %d\n", pEid->Eid));
break;
}
Length = Length + 2 + pEid->Len;
pEid = (PEID_STRUCT)((UCHAR*)pEid + 2 + pEid->Len);
}
return TRUE;
break;
default:
DBGPRINT(RT_DEBUG_TRACE,
("PeerAssocRspSanity - ignore unrecognized EID = %d\n",
pEid->Eid));
break;
}
Length = Length + 2 + pEid->Len;
pEid = (PEID_STRUCT) ((UCHAR *) pEid + 2 + pEid->Len);
}
return TRUE;
}
/*
......@@ -266,47 +254,46 @@ BOOLEAN PeerAssocRspSanity(
==========================================================================
*/
BOOLEAN PeerProbeReqSanity(
IN PRTMP_ADAPTER pAd,
IN VOID *Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT CHAR Ssid[],
OUT UCHAR *pSsidLen)
BOOLEAN PeerProbeReqSanity(IN PRTMP_ADAPTER pAd,
IN VOID * Msg,
IN ULONG MsgLen,
OUT PUCHAR pAddr2,
OUT CHAR Ssid[], OUT UCHAR * pSsidLen)
{
UCHAR Idx;
UCHAR RateLen;
CHAR IeType;
PFRAME_802_11 pFrame = (PFRAME_802_11)Msg;
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
if ((pFrame->Octet[0] != IE_SSID) || (pFrame->Octet[1] > MAX_LEN_OF_SSID))
{
DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",pFrame->Octet[0],pFrame->Octet[1]));
return FALSE;
}
*pSsidLen = pFrame->Octet[1];
NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
Idx = *pSsidLen + 2;
// -- get supported rates from payload and advance the pointer
IeType = pFrame->Octet[Idx];
RateLen = pFrame->Octet[Idx + 1];
if (IeType != IE_SUPP_RATES)
{
DBGPRINT(RT_DEBUG_TRACE, ("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",pFrame->Octet[Idx],pFrame->Octet[Idx+1]));
return FALSE;
}
else
{
if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
return (FALSE);
}
return TRUE;
UCHAR Idx;
UCHAR RateLen;
CHAR IeType;
PFRAME_802_11 pFrame = (PFRAME_802_11) Msg;
COPY_MAC_ADDR(pAddr2, pFrame->Hdr.Addr2);
if ((pFrame->Octet[0] != IE_SSID)
|| (pFrame->Octet[1] > MAX_LEN_OF_SSID)) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerProbeReqSanity fail - wrong SSID IE(Type=%d,Len=%d)\n",
pFrame->Octet[0], pFrame->Octet[1]));
return FALSE;
}
*pSsidLen = pFrame->Octet[1];
NdisMoveMemory(Ssid, &pFrame->Octet[2], *pSsidLen);
Idx = *pSsidLen + 2;
// -- get supported rates from payload and advance the pointer
IeType = pFrame->Octet[Idx];
RateLen = pFrame->Octet[Idx + 1];
if (IeType != IE_SUPP_RATES) {
DBGPRINT(RT_DEBUG_TRACE,
("PeerProbeReqSanity fail - wrong SupportRates IE(Type=%d,Len=%d)\n",
pFrame->Octet[Idx], pFrame->Octet[Idx + 1]));
return FALSE;
} else {
if ((pAd->CommonCfg.PhyMode == PHY_11G) && (RateLen < 8))
return (FALSE);
}
return TRUE;
}
/*
......@@ -317,62 +304,58 @@ BOOLEAN PeerProbeReqSanity(
==========================================================================
*/
BOOLEAN GetTimBit(
IN CHAR *Ptr,
IN USHORT Aid,
OUT UCHAR *TimLen,
OUT UCHAR *BcastFlag,
OUT UCHAR *DtimCount,
OUT UCHAR *DtimPeriod,
OUT UCHAR *MessageToMe)
BOOLEAN GetTimBit(IN CHAR * Ptr,
IN USHORT Aid,
OUT UCHAR * TimLen,
OUT UCHAR * BcastFlag,
OUT UCHAR * DtimCount,
OUT UCHAR * DtimPeriod, OUT UCHAR * MessageToMe)
{
UCHAR BitCntl, N1, N2, MyByte, MyBit;
CHAR *IdxPtr;
UCHAR BitCntl, N1, N2, MyByte, MyBit;
CHAR *IdxPtr;
IdxPtr = Ptr;
IdxPtr = Ptr;
IdxPtr ++;
*TimLen = *IdxPtr;
IdxPtr++;
*TimLen = *IdxPtr;
// get DTIM Count from TIM element
IdxPtr ++;
*DtimCount = *IdxPtr;
// get DTIM Count from TIM element
IdxPtr++;
*DtimCount = *IdxPtr;
// get DTIM Period from TIM element
IdxPtr++;
*DtimPeriod = *IdxPtr;
// get DTIM Period from TIM element
IdxPtr++;
*DtimPeriod = *IdxPtr;
// get Bitmap Control from TIM element
IdxPtr++;
BitCntl = *IdxPtr;
// get Bitmap Control from TIM element
IdxPtr++;
BitCntl = *IdxPtr;
if ((*DtimCount == 0) && (BitCntl & 0x01))
*BcastFlag = TRUE;
else
*BcastFlag = FALSE;
if ((*DtimCount == 0) && (BitCntl & 0x01))
*BcastFlag = TRUE;
else
*BcastFlag = FALSE;
// Parse Partial Virtual Bitmap from TIM element
N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
// Parse Partial Virtual Bitmap from TIM element
N1 = BitCntl & 0xfe; // N1 is the first bitmap byte#
N2 = *TimLen - 4 + N1; // N2 is the last bitmap byte#
if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
*MessageToMe = FALSE;
else
{
MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
MyBit = Aid % 16 - ((MyByte & 0x01)? 8:0);
if ((Aid < (N1 << 3)) || (Aid >= ((N2 + 1) << 3)))
*MessageToMe = FALSE;
else {
MyByte = (Aid >> 3) - N1; // my byte position in the bitmap byte-stream
MyBit = Aid % 16 - ((MyByte & 0x01) ? 8 : 0);
IdxPtr += (MyByte + 1);
IdxPtr += (MyByte + 1);
//if (*IdxPtr)
// DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
//if (*IdxPtr)
// DBGPRINT(RT_DEBUG_WARN, ("TIM bitmap = 0x%02x\n", *IdxPtr));
if (*IdxPtr & (0x01 << MyBit))
*MessageToMe = TRUE;
else
*MessageToMe = FALSE;
}
if (*IdxPtr & (0x01 << MyBit))
*MessageToMe = TRUE;
else
*MessageToMe = FALSE;
}
return TRUE;
return TRUE;
}
......@@ -37,7 +37,6 @@
*/
#include "../rt_config.h"
#define ADHOC_ENTRY_BEACON_LOST_TIME (2*OS_HZ) // 2 sec
/*
......@@ -51,38 +50,56 @@
==========================================================================
*/
VOID SyncStateMachineInit(
IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE *Sm,
OUT STATE_MACHINE_FUNC Trans[])
VOID SyncStateMachineInit(IN PRTMP_ADAPTER pAd,
IN STATE_MACHINE * Sm, OUT STATE_MACHINE_FUNC Trans[])
{
StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG, (STATE_MACHINE_FUNC)Drop, SYNC_IDLE, SYNC_MACHINE_BASE);
StateMachineInit(Sm, Trans, MAX_SYNC_STATE, MAX_SYNC_MSG,
(STATE_MACHINE_FUNC) Drop, SYNC_IDLE,
SYNC_MACHINE_BASE);
// column 1
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)MlmeScanReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)MlmeJoinReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)MlmeStartReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeacon);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ, (STATE_MACHINE_FUNC)PeerProbeReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_SCAN_REQ,
(STATE_MACHINE_FUNC) MlmeScanReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_JOIN_REQ,
(STATE_MACHINE_FUNC) MlmeJoinReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_MLME_START_REQ,
(STATE_MACHINE_FUNC) MlmeStartReqAction);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_BEACON,
(STATE_MACHINE_FUNC) PeerBeacon);
StateMachineSetAction(Sm, SYNC_IDLE, MT2_PEER_PROBE_REQ,
(STATE_MACHINE_FUNC) PeerProbeReqAction);
//column 2
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtJoinAction);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT, (STATE_MACHINE_FUNC)BeaconTimeoutAtJoinAction);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_SCAN_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenScan);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_JOIN_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenJoin);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_MLME_START_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenStart);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_PEER_BEACON,
(STATE_MACHINE_FUNC) PeerBeaconAtJoinAction);
StateMachineSetAction(Sm, JOIN_WAIT_BEACON, MT2_BEACON_TIMEOUT,
(STATE_MACHINE_FUNC) BeaconTimeoutAtJoinAction);
// column 3
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenScan);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenJoin);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ, (STATE_MACHINE_FUNC)InvalidStateWhenStart);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP, (STATE_MACHINE_FUNC)PeerBeaconAtScanAction);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT, (STATE_MACHINE_FUNC)ScanTimeoutAction);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_SCAN_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenScan);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_JOIN_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenJoin);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_MLME_START_REQ,
(STATE_MACHINE_FUNC) InvalidStateWhenStart);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_BEACON,
(STATE_MACHINE_FUNC) PeerBeaconAtScanAction);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_PEER_PROBE_RSP,
(STATE_MACHINE_FUNC) PeerBeaconAtScanAction);
StateMachineSetAction(Sm, SCAN_LISTEN, MT2_SCAN_TIMEOUT,
(STATE_MACHINE_FUNC) ScanTimeoutAction);
// timer init
RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer, GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer, GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.BeaconTimer,
GET_TIMER_FUNCTION(BeaconTimeout), pAd, FALSE);
RTMPInitTimer(pAd, &pAd->MlmeAux.ScanTimer,
GET_TIMER_FUNCTION(ScanTimeout), pAd, FALSE);
}
/*
......@@ -94,15 +111,13 @@ VOID SyncStateMachineInit(
==========================================================================
*/
VOID BeaconTimeout(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
VOID BeaconTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
DBGPRINT(RT_DEBUG_TRACE,("SYNC - BeaconTimeout\n"));
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeout\n"));
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
......@@ -110,16 +125,17 @@ VOID BeaconTimeout(
return;
if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
)
{
UCHAR BBPValue = 0;
) {
UCHAR BBPValue = 0;
AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
BBPValue |= 0x10;
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",
pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
}
MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_BEACON_TIMEOUT, 0, NULL);
......@@ -135,32 +151,28 @@ VOID BeaconTimeout(
==========================================================================
*/
VOID ScanTimeout(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
VOID ScanTimeout(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *)FunctionContext;
RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) FunctionContext;
// Do nothing if the driver is starting halt state.
// This might happen when timer already been fired before cancel timer with mlmehalt
if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS))
return;
if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL))
{
RTMP_MLME_HANDLER(pAd);
}
else
{
if (MlmeEnqueue(pAd, SYNC_STATE_MACHINE, MT2_SCAN_TIMEOUT, 0, NULL)) {
RTMP_MLME_HANDLER(pAd);
} else {
// To prevent SyncMachine.CurrState is SCAN_LISTEN forever.
pAd->MlmeAux.Channel = 0;
ScanNextChannel(pAd);
if (pAd->CommonCfg.bWirelessEvent)
{
RTMPSendWirelessEvent(pAd, IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
if (pAd->CommonCfg.bWirelessEvent) {
RTMPSendWirelessEvent(pAd,
IW_SCAN_ENQUEUE_FAIL_EVENT_FLAG,
pAd->MacTab.Content[BSSID_WCID].
Addr, BSS0, 0);
}
}
}
......@@ -171,83 +183,78 @@ VOID ScanTimeout(
MLME SCAN req state machine procedure
==========================================================================
*/
VOID MlmeScanReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeScanReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
BOOLEAN TimerCancelled;
ULONG Now;
USHORT Status;
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, ScanType, BssType, BBPValue = 0;
BOOLEAN TimerCancelled;
ULONG Now;
USHORT Status;
PHEADER_802_11 pHdr80211;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
NDIS_STATUS NStatus;
// Check the total scan tries for one single OID command
// If this is the CCX 2.0 Case, skip that!
if ( !RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP))
{
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeScanReqAction before Startup\n"));
if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_START_UP)) {
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - MlmeScanReqAction before Startup\n"));
return;
}
// Increase the scan retry counters.
pAd->StaCfg.ScanCnt++;
#ifdef RTMP_MAC_PCI
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
{
if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE)
{
AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00, 0x02);
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))) {
if (pAd->StaCfg.PSControl.field.EnableNewPS == FALSE) {
AsicSendCommandToMcu(pAd, 0x31, PowerWakeCID, 0x00,
0x02);
AsicCheckCommanOk(pAd, PowerWakeCID);
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF);
DBGPRINT(RT_DEBUG_TRACE, ("PSM - Issue Wake up command \n"));
DBGPRINT(RT_DEBUG_TRACE,
("PSM - Issue Wake up command \n"));
} else {
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
else
{
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
}
#endif // RTMP_MAC_PCI //
// first check the parameter sanity
if (MlmeScanReqSanity(pAd,
Elem->Msg,
Elem->MsgLen,
&BssType,
(PCHAR)Ssid,
&SsidLen,
&ScanType))
{
Elem->Msg,
Elem->MsgLen,
&BssType, (PCHAR) Ssid, &SsidLen, &ScanType)) {
// Check for channel load and noise hist request
// Suspend MSDU only at scan request, not the last two mentioned
// Suspend MSDU transmission here
RTMPSuspendMsduTransmission(pAd);
// Suspend MSDU transmission here
RTMPSuspendMsduTransmission(pAd);
//
// To prevent data lost.
// Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
// And should send an NULL data with turned PSM bit off to AP, when scan progress done
//
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
{
NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
if (NStatus == NDIS_STATUS_SUCCESS)
{
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
&& (INFRA_ON(pAd))) {
NStatus = MlmeAllocateMemory(pAd, (PVOID) & pOutBuffer);
if (NStatus == NDIS_STATUS_SUCCESS) {
pHdr80211 = (PHEADER_802_11) pOutBuffer;
MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
MgtMacHeaderInit(pAd, pHdr80211,
SUBTYPE_NULL_FUNC, 1,
pAd->CommonCfg.Bssid,
pAd->CommonCfg.Bssid);
pHdr80211->Duration = 0;
pHdr80211->FC.Type = BTYPE_DATA;
pHdr80211->FC.PwrMgmt = PWR_SAVE;
// Send using priority queue
MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
MiniportMMRequest(pAd, 0, pOutBuffer,
sizeof(HEADER_802_11));
DBGPRINT(RT_DEBUG_TRACE,
("MlmeScanReqAction -- Send PSM Data frame for off channel RM\n"));
MlmeFreeMemory(pAd, pOutBuffer);
RTMPusecDelay(5000);
}
......@@ -263,7 +270,7 @@ VOID MlmeScanReqAction(
pAd->MlmeAux.BssType = BssType;
pAd->MlmeAux.ScanType = ScanType;
pAd->MlmeAux.SsidLen = SsidLen;
NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
// start from the first channel
......@@ -275,13 +282,12 @@ VOID MlmeScanReqAction(
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BBP R4 to 20MHz.l\n"));
ScanNextChannel(pAd);
}
else
{
} else {
DBGPRINT_ERR(("SYNC - MlmeScanReqAction() sanity check fail\n"));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2,
&Status);
}
}
......@@ -291,33 +297,31 @@ VOID MlmeScanReqAction(
MLME JOIN req state machine procedure
==========================================================================
*/
VOID MlmeJoinReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeJoinReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR BBPValue = 0;
BSS_ENTRY *pBss;
BOOLEAN TimerCancelled;
UCHAR BBPValue = 0;
BSS_ENTRY *pBss;
BOOLEAN TimerCancelled;
HEADER_802_11 Hdr80211;
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
PUCHAR pOutBuffer = NULL;
PUCHAR pSupRate = NULL;
UCHAR SupRateLen;
PUCHAR pExtRate = NULL;
UCHAR ExtRateLen;
UCHAR ASupRate[] = {0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C};
UCHAR ASupRateLen = sizeof(ASupRate)/sizeof(UCHAR);
MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *)(Elem->Msg);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
NDIS_STATUS NStatus;
ULONG FrameLen = 0;
PUCHAR pOutBuffer = NULL;
PUCHAR pSupRate = NULL;
UCHAR SupRateLen;
PUCHAR pExtRate = NULL;
UCHAR ExtRateLen;
UCHAR ASupRate[] = { 0x8C, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6C };
UCHAR ASupRateLen = sizeof(ASupRate) / sizeof(UCHAR);
MLME_JOIN_REQ_STRUCT *pInfo = (MLME_JOIN_REQ_STRUCT *) (Elem->Msg);
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - MlmeJoinReqAction(BSS #%ld)\n", pInfo->BssIdx));
#ifdef RTMP_MAC_PCI
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF)))
{
if ((OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE)) &&
(IDLE_ON(pAd)) &&
(pAd->StaCfg.bRadio == TRUE) &&
(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_IDLE_RADIO_OFF))) {
RT28xxPciAsicRadioOn(pAd, GUI_IDLE_POWER_SAVE);
}
#endif // RTMP_MAC_PCI //
......@@ -332,8 +336,7 @@ VOID MlmeJoinReqAction(
COPY_MAC_ADDR(pAd->MlmeAux.Bssid, pBss->Bssid);
// If AP's SSID is not hidden, it is OK for updating ssid to MlmeAux again.
if (pBss->Hidden == 0)
{
if (pBss->Hidden == 0) {
RTMPZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID);
NdisMoveMemory(pAd->MlmeAux.Ssid, pBss->Ssid, pBss->SsidLen);
pAd->MlmeAux.SsidLen = pBss->SsidLen;
......@@ -343,7 +346,6 @@ VOID MlmeJoinReqAction(
pAd->MlmeAux.Channel = pBss->Channel;
pAd->MlmeAux.CentralChannel = pBss->CentralChannel;
// Let BBP register at 20MHz to do scan
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
BBPValue &= (~0x18);
......@@ -356,35 +358,28 @@ VOID MlmeJoinReqAction(
AsicLockChannel(pAd, pAd->MlmeAux.Channel);
RTMPSetTimer(&pAd->MlmeAux.BeaconTimer, JOIN_TIMEOUT);
do
{
do {
if (((pAd->CommonCfg.bIEEE80211H == 1) &&
(pAd->MlmeAux.Channel > 14) &&
RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
)
{
(pAd->MlmeAux.Channel > 14) &&
RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
) {
//
// We can't send any Probe request frame to meet 802.11h.
//
if (pBss->Hidden == 0)
break;
}
//
// send probe request
//
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer);
if (NStatus == NDIS_STATUS_SUCCESS)
{
if (pAd->MlmeAux.Channel <= 14)
{
if (NStatus == NDIS_STATUS_SUCCESS) {
if (pAd->MlmeAux.Channel <= 14) {
pSupRate = pAd->CommonCfg.SupRate;
SupRateLen = pAd->CommonCfg.SupRateLen;
pExtRate = pAd->CommonCfg.ExtRate;
ExtRateLen = pAd->CommonCfg.ExtRateLen;
}
else
{
} else {
//
// Overwrite Support Rate, CCK rate are not allowed
//
......@@ -394,39 +389,44 @@ VOID MlmeJoinReqAction(
}
if (pAd->MlmeAux.BssType == BSS_INFRA)
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, pAd->MlmeAux.Bssid, pAd->MlmeAux.Bssid);
MgtMacHeaderInit(pAd, &Hdr80211,
SUBTYPE_PROBE_REQ, 0,
pAd->MlmeAux.Bssid,
pAd->MlmeAux.Bssid);
else
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &Hdr80211,
1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen, pAd->MlmeAux.Ssid,
1, &SupRateIe,
1, &SupRateLen,
SupRateLen, pSupRate,
END_OF_ARGS);
if (ExtRateLen)
{
MgtMacHeaderInit(pAd, &Hdr80211,
SUBTYPE_PROBE_REQ, 0,
BROADCAST_ADDR,
BROADCAST_ADDR);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &Hdr80211,
1, &SsidIe,
1, &pAd->MlmeAux.SsidLen,
pAd->MlmeAux.SsidLen,
pAd->MlmeAux.Ssid, 1, &SupRateIe, 1,
&SupRateLen, SupRateLen, pSupRate,
END_OF_ARGS);
if (ExtRateLen) {
ULONG Tmp;
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
1, &ExtRateIe,
1, &ExtRateLen,
ExtRateLen, pExtRate,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
1, &ExtRateIe,
1, &ExtRateLen,
ExtRateLen, pExtRate,
END_OF_ARGS);
FrameLen += Tmp;
}
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
} while (FALSE);
} while (FALSE);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2], pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - Switch to ch %d, Wait BEACON from %02x:%02x:%02x:%02x:%02x:%02x\n",
pBss->Channel, pBss->Bssid[0], pBss->Bssid[1], pBss->Bssid[2],
pBss->Bssid[3], pBss->Bssid[4], pBss->Bssid[5]));
pAd->Mlme.SyncMachine.CurrState = JOIN_WAIT_BEACON;
}
......@@ -437,28 +437,26 @@ VOID MlmeJoinReqAction(
MLME START Request state machine procedure, starting an IBSS
==========================================================================
*/
VOID MlmeStartReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID MlmeStartReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
BOOLEAN TimerCancelled;
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen;
BOOLEAN TimerCancelled;
// New for WPA security suites
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
LARGE_INTEGER TimeStamp;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
LARGE_INTEGER TimeStamp;
BOOLEAN Privacy;
USHORT Status;
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
TimeStamp.u.LowPart = 0;
TimeStamp.u.LowPart = 0;
TimeStamp.u.HighPart = 0;
if (MlmeStartReqSanity(pAd, Elem->Msg, Elem->MsgLen, (PCHAR)Ssid, &SsidLen))
{
if (MlmeStartReqSanity
(pAd, Elem->Msg, Elem->MsgLen, (PCHAR) Ssid, &SsidLen)) {
// reset all the timers
RTMPCancelTimer(&pAd->MlmeAux.ScanTimer, &TimerCancelled);
RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
......@@ -466,67 +464,83 @@ VOID MlmeStartReqAction(
//
// Start a new IBSS. All IBSS parameters are decided now....
//
DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
pAd->MlmeAux.BssType = BSS_ADHOC;
DBGPRINT(RT_DEBUG_TRACE,
("MlmeStartReqAction - Start a new IBSS. All IBSS parameters are decided now.... \n"));
pAd->MlmeAux.BssType = BSS_ADHOC;
NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
pAd->MlmeAux.SsidLen = SsidLen;
pAd->MlmeAux.SsidLen = SsidLen;
// generate a radom number as BSSID
MacAddrRandomBssid(pAd, pAd->MlmeAux.Bssid);
DBGPRINT(RT_DEBUG_TRACE, ("MlmeStartReqAction - generate a radom number as BSSID \n"));
Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
pAd->MlmeAux.CapabilityInfo = CAP_GENERATE(0,1,Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 1, 0);
pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
pAd->MlmeAux.SupRateLen= pAd->CommonCfg.SupRateLen;
NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate, MAX_LEN_OF_SUPPORTED_RATES);
RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
DBGPRINT(RT_DEBUG_TRACE,
("MlmeStartReqAction - generate a radom number as BSSID \n"));
Privacy =
(pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled)
|| (pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled)
|| (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
pAd->MlmeAux.CapabilityInfo =
CAP_GENERATE(0, 1, Privacy,
(pAd->CommonCfg.TxPreamble ==
Rt802_11PreambleShort), 1, 0);
pAd->MlmeAux.BeaconPeriod = pAd->CommonCfg.BeaconPeriod;
pAd->MlmeAux.AtimWin = pAd->StaCfg.AtimWin;
pAd->MlmeAux.Channel = pAd->CommonCfg.Channel;
pAd->CommonCfg.CentralChannel = pAd->CommonCfg.Channel;
pAd->MlmeAux.CentralChannel = pAd->CommonCfg.CentralChannel;
pAd->MlmeAux.SupRateLen = pAd->CommonCfg.SupRateLen;
NdisMoveMemory(pAd->MlmeAux.SupRate, pAd->CommonCfg.SupRate,
MAX_LEN_OF_SUPPORTED_RATES);
RTMPCheckRates(pAd, pAd->MlmeAux.SupRate,
&pAd->MlmeAux.SupRateLen);
pAd->MlmeAux.ExtRateLen = pAd->CommonCfg.ExtRateLen;
NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate, MAX_LEN_OF_SUPPORTED_RATES);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy, &pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0], &pAd->MlmeAux.HtCapability, &pAd->MlmeAux.AddHtInfo);
NdisMoveMemory(pAd->MlmeAux.ExtRate, pAd->CommonCfg.ExtRate,
MAX_LEN_OF_SUPPORTED_RATES);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate,
&pAd->MlmeAux.ExtRateLen);
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
RTMPUpdateHTIE(&pAd->CommonCfg.DesiredHtPhy,
&pAd->StaCfg.DesiredHtPhyInfo.MCSSet[0],
&pAd->MlmeAux.HtCapability,
&pAd->MlmeAux.AddHtInfo);
pAd->MlmeAux.HtCapabilityLen = sizeof(HT_CAPABILITY_IE);
// Not turn pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE here.
DBGPRINT(RT_DEBUG_TRACE, ("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
}
else
{
DBGPRINT(RT_DEBUG_TRACE,
("SYNC -pAd->StaActive.SupportedHtPhy.bHtEnable = TRUE\n"));
} else {
pAd->MlmeAux.HtCapabilityLen = 0;
pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.MCSSet[0], 16);
NdisZeroMemory(&pAd->StaActive.SupportedPhyInfo.
MCSSet[0], 16);
}
// temporarily not support QOS in IBSS
NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQbssLoad,
sizeof(QBSS_LOAD_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQosCapability,
sizeof(QOS_CAPABILITY_PARM));
AsicSwitchChannel(pAd, pAd->MlmeAux.Channel, FALSE);
AsicLockChannel(pAd, pAd->MlmeAux.Channel);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - MlmeStartReqAction(ch= %d,sup rates= %d, ext rates=%d)\n",
pAd->MlmeAux.Channel, pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.ExtRateLen));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
}
else
{
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2,
&Status);
} else {
DBGPRINT_ERR(("SYNC - MlmeStartReqAction() sanity check fail.\n"));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_INVALID_FORMAT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2,
&Status);
}
}
......@@ -536,35 +550,33 @@ VOID MlmeStartReqAction(
peer sends beacon back when scanning
==========================================================================
*/
VOID PeerBeaconAtScanAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerBeaconAtScanAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
CF_PARM CfParm;
USHORT BeaconPeriod, AtimWin, CapabilityInfo;
PFRAME_802_11 pFrame;
LARGE_INTEGER TimeStamp;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
USHORT LenVIE;
UCHAR CkipFlag;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
UCHAR Ssid[MAX_LEN_OF_SSID], BssType, Channel, NewChannel,
SsidLen, DtimCount, DtimPeriod, BcastFlag, MessageToMe;
CF_PARM CfParm;
USHORT BeaconPeriod, AtimWin, CapabilityInfo;
PFRAME_802_11 pFrame;
LARGE_INTEGER TimeStamp;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES],
ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
USHORT LenVIE;
UCHAR CkipFlag;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
QOS_CAPABILITY_PARM QosCapability;
ULONG RalinkIe;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
ULONG RalinkIe;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
// NdisFillMemory(Ssid, MAX_LEN_OF_SSID, 0x00);
pFrame = (PFRAME_802_11) Elem->Msg;
......@@ -572,49 +584,46 @@ VOID PeerBeaconAtScanAction(
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
if (PeerBeaconAndProbeRspSanity(pAd,
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
(PCHAR)Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&CfParm,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset,
&LenVIE,
pVIE))
{
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
(PCHAR) Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&CfParm,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset, &LenVIE, pVIE)) {
ULONG Idx;
CHAR Rssi = 0;
......@@ -622,22 +631,32 @@ VOID PeerBeaconAtScanAction(
if (Idx != BSS_NOT_FOUND)
Rssi = pAd->ScanTab.BssEntry[Idx].Rssi;
Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
Rssi =
RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
if ((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
HtCapabilityLen = SIZE_HT_CAP_IE;
Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (PCHAR)Ssid, SsidLen, BssType, BeaconPeriod,
&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
if (Idx != BSS_NOT_FOUND)
{
NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
}
Idx =
BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (PCHAR) Ssid,
SsidLen, BssType, BeaconPeriod, &CfParm,
AtimWin, CapabilityInfo, SupRate,
SupRateLen, ExtRate, ExtRateLen,
&HtCapability, &AddHtInfo, HtCapabilityLen,
AddHtInfoLen, NewExtChannelOffset, Channel,
Rssi, TimeStamp, CkipFlag, &EdcaParm,
&QosCapability, &QbssLoad, LenVIE, pVIE);
if (Idx != BSS_NOT_FOUND) {
NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF,
&Elem->Msg[24], 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0],
&Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4],
&Elem->TimeStamp.u.LowPart, 4);
}
}
// sanity check fail, ignored
......@@ -649,88 +668,85 @@ VOID PeerBeaconAtScanAction(
When waiting joining the (I)BSS, beacon received from external
==========================================================================
*/
VOID PeerBeaconAtJoinAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerBeaconAtJoinAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
DtimCount, DtimPeriod, BcastFlag, NewChannel;
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
UCHAR Ssid[MAX_LEN_OF_SSID], SsidLen, BssType, Channel, MessageToMe,
DtimCount, DtimPeriod, BcastFlag, NewChannel;
LARGE_INTEGER TimeStamp;
USHORT BeaconPeriod, AtimWin, CapabilityInfo;
CF_PARM Cf;
BOOLEAN TimerCancelled;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
UCHAR CkipFlag;
USHORT LenVIE;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
USHORT BeaconPeriod, AtimWin, CapabilityInfo;
CF_PARM Cf;
BOOLEAN TimerCancelled;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES],
ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
UCHAR CkipFlag;
USHORT LenVIE;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
QOS_CAPABILITY_PARM QosCapability;
USHORT Status;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
ULONG RalinkIe;
ULONG Idx;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
UCHAR CentralChannel;
BOOLEAN bAllowNrate = FALSE;
USHORT Status;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
ULONG RalinkIe;
ULONG Idx;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen = 0, PreNHtCapabilityLen = 0;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
UCHAR CentralChannel;
BOOLEAN bAllowNrate = FALSE;
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
if (PeerBeaconAndProbeRspSanity(pAd,
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
(PCHAR)Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&Cf,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset,
&LenVIE,
pVIE))
{
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
(PCHAR) Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&Cf,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset, &LenVIE, pVIE)) {
// Disqualify 11b only adhoc when we are in 11g only adhoc mode
if ((BssType == BSS_ADHOC) && (pAd->CommonCfg.PhyMode == PHY_11G) && ((SupRateLen+ExtRateLen)< 12))
if ((BssType == BSS_ADHOC)
&& (pAd->CommonCfg.PhyMode == PHY_11G)
&& ((SupRateLen + ExtRateLen) < 12))
return;
// BEACON from desired BSS/IBSS found. We should be able to decide most
......@@ -739,61 +755,120 @@ VOID PeerBeaconAtJoinAction(
// Do we need to receover back all parameters belonging to previous BSS?
// A. Should be not. There's no back-door recover to previous AP. It still need
// a new JOIN-AUTH-ASSOC sequence.
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid))
{
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n", Channel));
RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer, &TimerCancelled);
if (MAC_ADDR_EQUAL(pAd->MlmeAux.Bssid, Bssid)) {
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - receive desired BEACON at JoinWaitBeacon... Channel = %d\n",
Channel));
RTMPCancelTimer(&pAd->MlmeAux.BeaconTimer,
&TimerCancelled);
// Update RSSI to prevent No signal display when cards first initialized
pAd->StaCfg.RssiSample.LastRssi0 = ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
pAd->StaCfg.RssiSample.LastRssi1 = ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
pAd->StaCfg.RssiSample.LastRssi2 = ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
pAd->StaCfg.RssiSample.AvgRssi0 = pAd->StaCfg.RssiSample.LastRssi0;
pAd->StaCfg.RssiSample.AvgRssi0X8 = pAd->StaCfg.RssiSample.AvgRssi0 << 3;
pAd->StaCfg.RssiSample.AvgRssi1 = pAd->StaCfg.RssiSample.LastRssi1;
pAd->StaCfg.RssiSample.AvgRssi1X8 = pAd->StaCfg.RssiSample.AvgRssi1 << 3;
pAd->StaCfg.RssiSample.AvgRssi2 = pAd->StaCfg.RssiSample.LastRssi2;
pAd->StaCfg.RssiSample.AvgRssi2X8 = pAd->StaCfg.RssiSample.AvgRssi2 << 3;
pAd->StaCfg.RssiSample.LastRssi0 =
ConvertToRssi(pAd, Elem->Rssi0, RSSI_0);
pAd->StaCfg.RssiSample.LastRssi1 =
ConvertToRssi(pAd, Elem->Rssi1, RSSI_1);
pAd->StaCfg.RssiSample.LastRssi2 =
ConvertToRssi(pAd, Elem->Rssi2, RSSI_2);
pAd->StaCfg.RssiSample.AvgRssi0 =
pAd->StaCfg.RssiSample.LastRssi0;
pAd->StaCfg.RssiSample.AvgRssi0X8 =
pAd->StaCfg.RssiSample.AvgRssi0 << 3;
pAd->StaCfg.RssiSample.AvgRssi1 =
pAd->StaCfg.RssiSample.LastRssi1;
pAd->StaCfg.RssiSample.AvgRssi1X8 =
pAd->StaCfg.RssiSample.AvgRssi1 << 3;
pAd->StaCfg.RssiSample.AvgRssi2 =
pAd->StaCfg.RssiSample.LastRssi2;
pAd->StaCfg.RssiSample.AvgRssi2X8 =
pAd->StaCfg.RssiSample.AvgRssi2 << 3;
//
// We need to check if SSID only set to any, then we can record the current SSID.
// Otherwise will cause hidden SSID association failed.
//
if (pAd->MlmeAux.SsidLen == 0)
{
NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid, SsidLen);
if (pAd->MlmeAux.SsidLen == 0) {
NdisMoveMemory(pAd->MlmeAux.Ssid, Ssid,
SsidLen);
pAd->MlmeAux.SsidLen = SsidLen;
}
else
{
Idx = BssSsidTableSearch(&pAd->ScanTab, Bssid, pAd->MlmeAux.Ssid, pAd->MlmeAux.SsidLen, Channel);
if (Idx == BSS_NOT_FOUND)
{
} else {
Idx =
BssSsidTableSearch(&pAd->ScanTab, Bssid,
pAd->MlmeAux.Ssid,
pAd->MlmeAux.SsidLen,
Channel);
if (Idx == BSS_NOT_FOUND) {
CHAR Rssi = 0;
Rssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
Idx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, (CHAR *) Ssid, SsidLen, BssType, BeaconPeriod,
&Cf, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, Rssi, TimeStamp, CkipFlag,
&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
if (Idx != BSS_NOT_FOUND)
{
NdisMoveMemory(pAd->ScanTab.BssEntry[Idx].PTSF, &Elem->Msg[24], 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Idx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
Rssi =
RTMPMaxRssi(pAd,
ConvertToRssi(pAd,
Elem->
Rssi0,
RSSI_0),
ConvertToRssi(pAd,
Elem->
Rssi1,
RSSI_1),
ConvertToRssi(pAd,
Elem->
Rssi2,
RSSI_2));
Idx =
BssTableSetEntry(pAd, &pAd->ScanTab,
Bssid,
(CHAR *) Ssid,
SsidLen, BssType,
BeaconPeriod, &Cf,
AtimWin,
CapabilityInfo,
SupRate,
SupRateLen,
ExtRate,
ExtRateLen,
&HtCapability,
&AddHtInfo,
HtCapabilityLen,
AddHtInfoLen,
NewExtChannelOffset,
Channel, Rssi,
TimeStamp,
CkipFlag,
&EdcaParm,
&QosCapability,
&QbssLoad, LenVIE,
pVIE);
if (Idx != BSS_NOT_FOUND) {
NdisMoveMemory(pAd->ScanTab.
BssEntry[Idx].
PTSF,
&Elem->Msg[24],
4);
NdisMoveMemory(&pAd->ScanTab.
BssEntry[Idx].
TTSF[0],
&Elem->TimeStamp.
u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.
BssEntry[Idx].
TTSF[4],
&Elem->TimeStamp.
u.LowPart, 4);
CapabilityInfo =
pAd->ScanTab.BssEntry[Idx].
CapabilityInfo;
}
}
else
{
} else {
//
// Multiple SSID case, used correct CapabilityInfo
//
CapabilityInfo = pAd->ScanTab.BssEntry[Idx].CapabilityInfo;
CapabilityInfo =
pAd->ScanTab.BssEntry[Idx].
CapabilityInfo;
}
}
NdisMoveMemory(pAd->MlmeAux.Bssid, Bssid, MAC_ADDR_LEN);
pAd->MlmeAux.CapabilityInfo = CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
pAd->MlmeAux.CapabilityInfo =
CapabilityInfo & SUPPORTED_CAPABILITY_INFO;
pAd->MlmeAux.BssType = BssType;
pAd->MlmeAux.BeaconPeriod = BeaconPeriod;
pAd->MlmeAux.Channel = Channel;
......@@ -805,110 +880,152 @@ VOID PeerBeaconAtJoinAction(
// Copy AP's supported rate to MlmeAux for creating assoication request
// Also filter out not supported rate
pAd->MlmeAux.SupRateLen = SupRateLen;
NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate, SupRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.SupRate, &pAd->MlmeAux.SupRateLen);
NdisMoveMemory(pAd->MlmeAux.SupRate, SupRate,
SupRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.SupRate,
&pAd->MlmeAux.SupRateLen);
pAd->MlmeAux.ExtRateLen = ExtRateLen;
NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate, ExtRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate, &pAd->MlmeAux.ExtRateLen);
NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, 16);
if (((pAd->StaCfg.WepStatus != Ndis802_11WEPEnabled) && (pAd->StaCfg.WepStatus != Ndis802_11Encryption2Enabled))
|| (pAd->CommonCfg.HT_DisallowTKIP == FALSE))
{
NdisMoveMemory(pAd->MlmeAux.ExtRate, ExtRate,
ExtRateLen);
RTMPCheckRates(pAd, pAd->MlmeAux.ExtRate,
&pAd->MlmeAux.ExtRateLen);
NdisZeroMemory(pAd->StaActive.SupportedPhyInfo.MCSSet,
16);
if (((pAd->StaCfg.WepStatus != Ndis802_11WEPEnabled)
&& (pAd->StaCfg.WepStatus !=
Ndis802_11Encryption2Enabled))
|| (pAd->CommonCfg.HT_DisallowTKIP == FALSE)) {
bAllowNrate = TRUE;
}
pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
pAd->MlmeAux.HtCapabilityLen = HtCapabilityLen;
RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
RTMPZeroMemory(&pAd->MlmeAux.HtCapability,
SIZE_HT_CAP_IE);
// filter out un-supported ht rates
if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0)) &&
((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) && (bAllowNrate)))
{
RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo, &AddHtInfo, SIZE_ADD_HT_INFO_IE);
if (((HtCapabilityLen > 0) || (PreNHtCapabilityLen > 0))
&& ((pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
&& (bAllowNrate))) {
RTMPMoveMemory(&pAd->MlmeAux.AddHtInfo,
&AddHtInfo, SIZE_ADD_HT_INFO_IE);
// StaActive.SupportedHtPhy.MCSSet stores Peer AP's 11n Rx capability
NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.MCSSet, HtCapability.MCSSet, 16);
pAd->MlmeAux.NewExtChannelOffset = NewExtChannelOffset;
NdisMoveMemory(pAd->StaActive.SupportedPhyInfo.
MCSSet, HtCapability.MCSSet, 16);
pAd->MlmeAux.NewExtChannelOffset =
NewExtChannelOffset;
pAd->MlmeAux.HtCapabilityLen = SIZE_HT_CAP_IE;
pAd->StaActive.SupportedPhyInfo.bHtEnable = TRUE;
pAd->StaActive.SupportedPhyInfo.bHtEnable =
TRUE;
if (PreNHtCapabilityLen > 0)
pAd->StaActive.SupportedPhyInfo.bPreNHt = TRUE;
RTMPCheckHt(pAd, BSSID_WCID, &HtCapability, &AddHtInfo);
pAd->StaActive.SupportedPhyInfo.
bPreNHt = TRUE;
RTMPCheckHt(pAd, BSSID_WCID, &HtCapability,
&AddHtInfo);
// Copy AP Parameter to StaActive. This is also in LinkUp.
DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
pAd->StaActive.SupportedHtPhy.MpduDensity, pAd->StaActive.SupportedHtPhy.MaxRAmpduFactor, HtCapability.HtCapInfo.ChannelWidth));
if (AddHtInfoLen > 0)
{
DBGPRINT(RT_DEBUG_TRACE,
("PeerBeaconAtJoinAction! (MpduDensity=%d, MaxRAmpduFactor=%d, BW=%d)\n",
pAd->StaActive.SupportedHtPhy.
MpduDensity,
pAd->StaActive.SupportedHtPhy.
MaxRAmpduFactor,
HtCapability.HtCapInfo.ChannelWidth));
if (AddHtInfoLen > 0) {
CentralChannel = AddHtInfo.ControlChan;
// Check again the Bandwidth capability of this AP.
if ((AddHtInfo.ControlChan > 2)&& (AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_BELOW) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
{
CentralChannel = AddHtInfo.ControlChan - 2;
}
else if ((AddHtInfo.AddHtInfo.ExtChanOffset == EXTCHA_ABOVE) && (HtCapability.HtCapInfo.ChannelWidth == BW_40))
{
CentralChannel = AddHtInfo.ControlChan + 2;
}
// Check again the Bandwidth capability of this AP.
if ((AddHtInfo.ControlChan > 2)
&& (AddHtInfo.AddHtInfo.
ExtChanOffset == EXTCHA_BELOW)
&& (HtCapability.HtCapInfo.
ChannelWidth == BW_40)) {
CentralChannel =
AddHtInfo.ControlChan - 2;
} else
if ((AddHtInfo.AddHtInfo.
ExtChanOffset == EXTCHA_ABOVE)
&& (HtCapability.HtCapInfo.
ChannelWidth == BW_40)) {
CentralChannel =
AddHtInfo.ControlChan + 2;
}
// Check Error .
if (pAd->MlmeAux.CentralChannel != CentralChannel)
DBGPRINT(RT_DEBUG_ERROR, ("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n", CentralChannel, AddHtInfo.ControlChan, pAd->MlmeAux.CentralChannel));
DBGPRINT(RT_DEBUG_TRACE, ("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d, .\n", CentralChannel, AddHtInfo.ControlChan));
if (pAd->MlmeAux.CentralChannel !=
CentralChannel)
DBGPRINT(RT_DEBUG_ERROR,
("PeerBeaconAtJoinAction HT===>Beacon Central Channel = %d, Control Channel = %d. Mlmeaux CentralChannel = %d\n",
CentralChannel,
AddHtInfo.ControlChan,
pAd->MlmeAux.
CentralChannel));
DBGPRINT(RT_DEBUG_TRACE,
("PeerBeaconAtJoinAction HT===>Central Channel = %d, Control Channel = %d, .\n",
CentralChannel,
AddHtInfo.ControlChan));
}
}
else
{
// To prevent error, let legacy AP must have same CentralChannel and Channel.
if ((HtCapabilityLen == 0) && (PreNHtCapabilityLen == 0))
pAd->MlmeAux.CentralChannel = pAd->MlmeAux.Channel;
} else {
// To prevent error, let legacy AP must have same CentralChannel and Channel.
if ((HtCapabilityLen == 0)
&& (PreNHtCapabilityLen == 0))
pAd->MlmeAux.CentralChannel =
pAd->MlmeAux.Channel;
pAd->StaActive.SupportedPhyInfo.bHtEnable = FALSE;
pAd->StaActive.SupportedPhyInfo.bHtEnable =
FALSE;
pAd->MlmeAux.NewExtChannelOffset = 0xff;
RTMPZeroMemory(&pAd->MlmeAux.HtCapability, SIZE_HT_CAP_IE);
RTMPZeroMemory(&pAd->MlmeAux.HtCapability,
SIZE_HT_CAP_IE);
pAd->MlmeAux.HtCapabilityLen = 0;
RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo, SIZE_ADD_HT_INFO_IE);
RTMPZeroMemory(&pAd->MlmeAux.AddHtInfo,
SIZE_ADD_HT_INFO_IE);
}
RTMPUpdateMlmeRate(pAd);
// copy QOS related information
if ((pAd->CommonCfg.bWmmCapable)
|| (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
)
{
NdisMoveMemory(&pAd->MlmeAux.APEdcaParm, &EdcaParm, sizeof(EDCA_PARM));
NdisMoveMemory(&pAd->MlmeAux.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
NdisMoveMemory(&pAd->MlmeAux.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
}
else
{
NdisZeroMemory(&pAd->MlmeAux.APEdcaParm, sizeof(EDCA_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQbssLoad, sizeof(QBSS_LOAD_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQosCapability, sizeof(QOS_CAPABILITY_PARM));
|| (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
) {
NdisMoveMemory(&pAd->MlmeAux.APEdcaParm,
&EdcaParm, sizeof(EDCA_PARM));
NdisMoveMemory(&pAd->MlmeAux.APQbssLoad,
&QbssLoad,
sizeof(QBSS_LOAD_PARM));
NdisMoveMemory(&pAd->MlmeAux.APQosCapability,
&QosCapability,
sizeof(QOS_CAPABILITY_PARM));
} else {
NdisZeroMemory(&pAd->MlmeAux.APEdcaParm,
sizeof(EDCA_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQbssLoad,
sizeof(QBSS_LOAD_PARM));
NdisZeroMemory(&pAd->MlmeAux.APQosCapability,
sizeof(QOS_CAPABILITY_PARM));
}
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
pAd->MlmeAux.SupRateLen, pAd->MlmeAux.ExtRateLen));
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - after JOIN, SupRateLen=%d, ExtRateLen=%d\n",
pAd->MlmeAux.SupRateLen,
pAd->MlmeAux.ExtRateLen));
if (AironetCellPowerLimit != 0xFF)
{
if (AironetCellPowerLimit != 0xFF) {
//We need to change our TxPower for CCX 2.0 AP Control of Client Transmit Power
ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
}
else //Used the default TX Power Percentage.
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
ChangeToCellPowerLimit(pAd,
AironetCellPowerLimit);
} else //Used the default TX Power Percentage.
pAd->CommonCfg.TxPowerPercentage =
pAd->CommonCfg.TxPowerDefault;
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_SUCCESS;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF,
2, &Status);
}
// not to me BEACON, ignored
}
......@@ -924,98 +1041,99 @@ VOID PeerBeaconAtJoinAction(
==========================================================================
*/
VOID PeerBeacon(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerBeacon(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
CF_PARM CfParm;
UCHAR SsidLen, MessageToMe=0, BssType, Channel, NewChannel, index=0;
UCHAR DtimCount=0, DtimPeriod=0, BcastFlag=0;
USHORT CapabilityInfo, AtimWin, BeaconPeriod;
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
CF_PARM CfParm;
UCHAR SsidLen, MessageToMe = 0, BssType, Channel, NewChannel, index = 0;
UCHAR DtimCount = 0, DtimPeriod = 0, BcastFlag = 0;
USHORT CapabilityInfo, AtimWin, BeaconPeriod;
LARGE_INTEGER TimeStamp;
USHORT TbttNumToNextWakeUp;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
UCHAR CkipFlag;
USHORT LenVIE;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
USHORT TbttNumToNextWakeUp;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES],
ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
UCHAR CkipFlag;
USHORT LenVIE;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
QOS_CAPABILITY_PARM QosCapability;
ULONG RalinkIe;
ULONG RalinkIe;
// New for WPA security suites
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen, PreNHtCapabilityLen;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
HT_CAPABILITY_IE HtCapability;
ADD_HT_INFO_IE AddHtInfo; // AP might use this additional ht info IE
UCHAR HtCapabilityLen, PreNHtCapabilityLen;
UCHAR AddHtInfoLen;
UCHAR NewExtChannelOffset = 0xff;
if (!(INFRA_ON(pAd) || ADHOC_ON(pAd)
))
))
return;
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&HtCapability, sizeof(HtCapability));
RTMPZeroMemory(&AddHtInfo, sizeof(ADD_HT_INFO_IE));
if (PeerBeaconAndProbeRspSanity(pAd,
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&CfParm,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset,
&LenVIE,
pVIE))
{
Elem->Msg,
Elem->MsgLen,
Elem->Channel,
Addr2,
Bssid,
Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&NewChannel,
&TimeStamp,
&CfParm,
&AtimWin,
&CapabilityInfo,
&Erp,
&DtimCount,
&DtimPeriod,
&BcastFlag,
&MessageToMe,
SupRate,
&SupRateLen,
ExtRate,
&ExtRateLen,
&CkipFlag,
&AironetCellPowerLimit,
&EdcaParm,
&QbssLoad,
&QosCapability,
&RalinkIe,
&HtCapabilityLen,
&PreNHtCapabilityLen,
&HtCapability,
&AddHtInfoLen,
&AddHtInfo,
&NewExtChannelOffset, &LenVIE, pVIE)) {
BOOLEAN is_my_bssid, is_my_ssid;
ULONG Bssidx, Now;
ULONG Bssidx, Now;
BSS_ENTRY *pBss;
CHAR RealRssi = RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0), ConvertToRssi(pAd, Elem->Rssi1, RSSI_1), ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
is_my_bssid = MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid)? TRUE : FALSE;
is_my_ssid = SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen)? TRUE:FALSE;
CHAR RealRssi =
RTMPMaxRssi(pAd, ConvertToRssi(pAd, Elem->Rssi0, RSSI_0),
ConvertToRssi(pAd, Elem->Rssi1, RSSI_1),
ConvertToRssi(pAd, Elem->Rssi2, RSSI_2));
is_my_bssid =
MAC_ADDR_EQUAL(Bssid, pAd->CommonCfg.Bssid) ? TRUE : FALSE;
is_my_ssid =
SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid,
pAd->CommonCfg.SsidLen) ? TRUE : FALSE;
// ignore BEACON not for my SSID
if ((! is_my_ssid) && (! is_my_bssid))
if ((!is_my_ssid) && (!is_my_bssid))
return;
// It means STA waits disassoc completely from this AP, ignores this beacon.
......@@ -1033,177 +1151,194 @@ VOID PeerBeacon(
// Housekeeping "SsidBssTab" table for later-on ROAMing usage.
//
Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
if (Bssidx == BSS_NOT_FOUND)
{
if (Bssidx == BSS_NOT_FOUND) {
// discover new AP of this network, create BSS entry
Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen,
&HtCapability, &AddHtInfo,HtCapabilityLen,AddHtInfoLen,NewExtChannelOffset, Channel,
RealRssi, TimeStamp, CkipFlag, &EdcaParm, &QosCapability,
&QbssLoad, LenVIE, pVIE);
if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
Bssidx =
BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid,
SsidLen, BssType, BeaconPeriod,
&CfParm, AtimWin, CapabilityInfo,
SupRate, SupRateLen, ExtRate,
ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen,
AddHtInfoLen, NewExtChannelOffset,
Channel, RealRssi, TimeStamp,
CkipFlag, &EdcaParm,
&QosCapability, &QbssLoad, LenVIE,
pVIE);
if (Bssidx == BSS_NOT_FOUND) // return if BSS table full
return;
NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF, &Elem->Msg[24], 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0], &Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4], &Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(pAd->ScanTab.BssEntry[Bssidx].PTSF,
&Elem->Msg[24], 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[0],
&Elem->TimeStamp.u.LowPart, 4);
NdisMoveMemory(&pAd->ScanTab.BssEntry[Bssidx].TTSF[4],
&Elem->TimeStamp.u.LowPart, 4);
}
if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0) && (Channel != NewChannel))
{
if ((pAd->CommonCfg.bIEEE80211H == 1) && (NewChannel != 0)
&& (Channel != NewChannel)) {
// Switching to channel 1 can prevent from rescanning the current channel immediately (by auto reconnection).
// In addition, clear the MLME queue and the scan table to discard the RX packets and previous scanning results.
AsicSwitchChannel(pAd, 1, FALSE);
AsicLockChannel(pAd, 1);
LinkDown(pAd, FALSE);
LinkDown(pAd, FALSE);
MlmeQueueInit(&pAd->Mlme.Queue);
BssTableInit(&pAd->ScanTab);
RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
RTMPusecDelay(1000000); // use delay to prevent STA do reassoc
// channel sanity check
for (index = 0 ; index < pAd->ChannelListNum; index++)
{
if (pAd->ChannelList[index].Channel == NewChannel)
{
pAd->ScanTab.BssEntry[Bssidx].Channel = NewChannel;
for (index = 0; index < pAd->ChannelListNum; index++) {
if (pAd->ChannelList[index].Channel ==
NewChannel) {
pAd->ScanTab.BssEntry[Bssidx].Channel =
NewChannel;
pAd->CommonCfg.Channel = NewChannel;
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
DBGPRINT(RT_DEBUG_TRACE, ("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n", NewChannel));
AsicSwitchChannel(pAd,
pAd->CommonCfg.
Channel, FALSE);
AsicLockChannel(pAd,
pAd->CommonCfg.Channel);
DBGPRINT(RT_DEBUG_TRACE,
("PeerBeacon - STA receive channel switch announcement IE (New Channel =%d)\n",
NewChannel));
break;
}
}
if (index >= pAd->ChannelListNum)
{
if (index >= pAd->ChannelListNum) {
DBGPRINT_ERR(("PeerBeacon(can not find New Channel=%d in ChannelList[%d]\n", pAd->CommonCfg.Channel, pAd->ChannelListNum));
}
}
// if the ssid matched & bssid unmatched, we should select the bssid with large value.
// This might happened when two STA start at the same time
if ((! is_my_bssid) && ADHOC_ON(pAd))
{
INT i;
if ((!is_my_bssid) && ADHOC_ON(pAd)) {
INT i;
// Add the safeguard against the mismatch of adhoc wep status
if (pAd->StaCfg.WepStatus != pAd->ScanTab.BssEntry[Bssidx].WepStatus)
{
if (pAd->StaCfg.WepStatus !=
pAd->ScanTab.BssEntry[Bssidx].WepStatus) {
return;
}
// collapse into the ADHOC network which has bigger BSSID value.
for (i = 0; i < 6; i++)
{
if (Bssid[i] > pAd->CommonCfg.Bssid[i])
{
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
Bssid[0], Bssid[1], Bssid[2], Bssid[3], Bssid[4], Bssid[5]));
for (i = 0; i < 6; i++) {
if (Bssid[i] > pAd->CommonCfg.Bssid[i]) {
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - merge to the IBSS with bigger BSSID=%02x:%02x:%02x:%02x:%02x:%02x\n",
Bssid[0], Bssid[1], Bssid[2],
Bssid[3], Bssid[4],
Bssid[5]));
AsicDisableSync(pAd);
COPY_MAC_ADDR(pAd->CommonCfg.Bssid, Bssid);
COPY_MAC_ADDR(pAd->CommonCfg.Bssid,
Bssid);
AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
MakeIbssBeacon(pAd); // re-build BEACON frame
AsicEnableIbssSync(pAd); // copy BEACON frame to on-chip memory
MakeIbssBeacon(pAd); // re-build BEACON frame
AsicEnableIbssSync(pAd); // copy BEACON frame to on-chip memory
is_my_bssid = TRUE;
break;
}
else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
} else if (Bssid[i] < pAd->CommonCfg.Bssid[i])
break;
}
}
NdisGetSystemUpTime(&Now);
pBss = &pAd->ScanTab.BssEntry[Bssidx];
pBss->Rssi = RealRssi; // lastest RSSI
pBss->LastBeaconRxTime = Now; // last RX timestamp
pBss->Rssi = RealRssi; // lastest RSSI
pBss->LastBeaconRxTime = Now; // last RX timestamp
//
// BEACON from my BSSID - either IBSS or INFRA network
//
if (is_my_bssid)
{
RXWI_STRUC RxWI;
if (is_my_bssid) {
RXWI_STRUC RxWI;
pAd->StaCfg.DtimCount = DtimCount;
pAd->StaCfg.DtimPeriod = DtimPeriod;
pAd->StaCfg.LastBeaconRxTime = Now;
RxWI.RSSI0 = Elem->Rssi0;
RxWI.RSSI1 = Elem->Rssi1;
RxWI.RSSI2 = Elem->Rssi2;
Update_Rssi_Sample(pAd, &pAd->StaCfg.RssiSample, &RxWI);
if (AironetCellPowerLimit != 0xFF)
{
if (AironetCellPowerLimit != 0xFF) {
//
// We get the Cisco (ccx) "TxPower Limit" required
// Changed to appropriate TxPower Limit for Ciso Compatible Extensions
//
ChangeToCellPowerLimit(pAd, AironetCellPowerLimit);
}
else
{
ChangeToCellPowerLimit(pAd,
AironetCellPowerLimit);
} else {
//
// AironetCellPowerLimit equal to 0xFF means the Cisco (ccx) "TxPower Limit" not exist.
// Used the default TX Power Percentage, that set from UI.
//
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
pAd->CommonCfg.TxPowerPercentage =
pAd->CommonCfg.TxPowerDefault;
}
if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo)))
{
UCHAR MaxSupportedRateIn500Kbps = 0;
UCHAR idx;
if (ADHOC_ON(pAd) && (CAP_IS_IBSS_ON(CapabilityInfo))) {
UCHAR MaxSupportedRateIn500Kbps = 0;
UCHAR idx;
MAC_TABLE_ENTRY *pEntry;
// supported rates array may not be sorted. sort it and find the maximum rate
for (idx=0; idx<SupRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (SupRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = SupRate[idx] & 0x7f;
}
for (idx=0; idx<ExtRateLen; idx++)
{
if (MaxSupportedRateIn500Kbps < (ExtRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps = ExtRate[idx] & 0x7f;
}
for (idx = 0; idx < SupRateLen; idx++) {
if (MaxSupportedRateIn500Kbps <
(SupRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps =
SupRate[idx] & 0x7f;
}
for (idx = 0; idx < ExtRateLen; idx++) {
if (MaxSupportedRateIn500Kbps <
(ExtRate[idx] & 0x7f))
MaxSupportedRateIn500Kbps =
ExtRate[idx] & 0x7f;
}
// look up the existing table
pEntry = MacTableLookup(pAd, Addr2);
// Ad-hoc mode is using MAC address as BA session. So we need to continuously find newly joined adhoc station by receiving beacon.
// To prevent always check this, we use wcid == RESERVED_WCID to recognize it as newly joined adhoc station.
if ((ADHOC_ON(pAd) && (Elem->Wcid == RESERVED_WCID)) ||
(pEntry && ((pEntry->LastBeaconRxTime + ADHOC_ENTRY_BEACON_LOST_TIME) < Now)))
{
if ((ADHOC_ON(pAd)
&& (Elem->Wcid == RESERVED_WCID))
|| (pEntry
&&
((pEntry->LastBeaconRxTime +
ADHOC_ENTRY_BEACON_LOST_TIME) <
Now))) {
if (pEntry == NULL)
// Another adhoc joining, add to our MAC table.
pEntry = MacTableInsertEntry(pAd, Addr2, BSS0, FALSE);
pEntry =
MacTableInsertEntry(pAd,
Addr2,
BSS0,
FALSE);
if (StaAddMacTableEntry(pAd,
pEntry,
MaxSupportedRateIn500Kbps,
&HtCapability,
HtCapabilityLen,
&AddHtInfo,
AddHtInfoLen,
CapabilityInfo) == FALSE)
{
DBGPRINT(RT_DEBUG_TRACE, ("ADHOC - Add Entry failed.\n"));
pEntry,
MaxSupportedRateIn500Kbps,
&HtCapability,
HtCapabilityLen,
&AddHtInfo,
AddHtInfoLen,
CapabilityInfo)
== FALSE) {
DBGPRINT(RT_DEBUG_TRACE,
("ADHOC - Add Entry failed.\n"));
return;
}
if (pEntry &&
(Elem->Wcid == RESERVED_WCID))
{
(Elem->Wcid == RESERVED_WCID)) {
idx = pAd->StaCfg.DefaultKeyId;
RTMP_STA_SECURITY_INFO_ADD(pAd, BSS0, idx, pEntry);
RTMP_STA_SECURITY_INFO_ADD(pAd,
BSS0,
idx,
pEntry);
}
}
......@@ -1211,33 +1346,62 @@ VOID PeerBeacon(
pEntry->LastBeaconRxTime = Now;
// At least another peer in this IBSS, declare MediaState as CONNECTED
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED))
{
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED);
if (!OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)) {
OPSTATUS_SET_FLAG(pAd,
fOP_STATUS_MEDIA_STATE_CONNECTED);
pAd->IndicateMediaState = NdisMediaStateConnected;
pAd->IndicateMediaState =
NdisMediaStateConnected;
RTMP_IndicateMediaState(pAd);
pAd->ExtraInfo = GENERAL_LINK_UP;
pAd->ExtraInfo = GENERAL_LINK_UP;
AsicSetBssid(pAd, pAd->CommonCfg.Bssid);
// 2003/03/12 - john
// Make sure this entry in "ScanTab" table, thus complies to Microsoft's policy that
// "site survey" result should always include the current connected network.
//
Bssidx = BssTableSearch(&pAd->ScanTab, Bssid, Channel);
if (Bssidx == BSS_NOT_FOUND)
{
Bssidx = BssTableSetEntry(pAd, &pAd->ScanTab, Bssid, Ssid, SsidLen, BssType, BeaconPeriod,
&CfParm, AtimWin, CapabilityInfo, SupRate, SupRateLen, ExtRate, ExtRateLen, &HtCapability,
&AddHtInfo, HtCapabilityLen, AddHtInfoLen, NewExtChannelOffset, Channel, RealRssi, TimeStamp, 0,
&EdcaParm, &QosCapability, &QbssLoad, LenVIE, pVIE);
Bssidx =
BssTableSearch(&pAd->ScanTab, Bssid,
Channel);
if (Bssidx == BSS_NOT_FOUND) {
Bssidx =
BssTableSetEntry(pAd,
&pAd->
ScanTab,
Bssid,
Ssid,
SsidLen,
BssType,
BeaconPeriod,
&CfParm,
AtimWin,
CapabilityInfo,
SupRate,
SupRateLen,
ExtRate,
ExtRateLen,
&HtCapability,
&AddHtInfo,
HtCapabilityLen,
AddHtInfoLen,
NewExtChannelOffset,
Channel,
RealRssi,
TimeStamp,
0,
&EdcaParm,
&QosCapability,
&QbssLoad,
LenVIE,
pVIE);
}
DBGPRINT(RT_DEBUG_TRACE, ("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
DBGPRINT(RT_DEBUG_TRACE,
("ADHOC fOP_STATUS_MEDIA_STATE_CONNECTED.\n"));
}
}
if (INFRA_ON(pAd))
{
if (INFRA_ON(pAd)) {
BOOLEAN bUseShortSlot, bUseBGProtection;
// decide to use/change to -
......@@ -1246,174 +1410,283 @@ VOID PeerBeacon(
// 3. short preamble
//bUseShortSlot = pAd->CommonCfg.bUseShortSlotTime && CAP_IS_SHORT_SLOT(CapabilityInfo);
bUseShortSlot = CAP_IS_SHORT_SLOT(CapabilityInfo);
if (bUseShortSlot != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_SLOT_INUSED))
bUseShortSlot =
CAP_IS_SHORT_SLOT(CapabilityInfo);
if (bUseShortSlot !=
OPSTATUS_TEST_FLAG(pAd,
fOP_STATUS_SHORT_SLOT_INUSED))
AsicSetSlotTime(pAd, bUseShortSlot);
bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) || // always use
((pAd->CommonCfg.UseBGProtection == 0) && ERP_IS_USE_PROTECTION(Erp));
bUseBGProtection = (pAd->CommonCfg.UseBGProtection == 1) || // always use
((pAd->CommonCfg.UseBGProtection == 0)
&& ERP_IS_USE_PROTECTION(Erp));
if (pAd->CommonCfg.Channel > 14) // always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP
if (pAd->CommonCfg.Channel > 14) // always no BG protection in A-band. falsely happened when switching A/G band to a dual-band AP
bUseBGProtection = FALSE;
if (bUseBGProtection != OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED))
if (bUseBGProtection !=
OPSTATUS_TEST_FLAG(pAd,
fOP_STATUS_BG_PROTECTION_INUSED))
{
if (bUseBGProtection)
{
OPSTATUS_SET_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),FALSE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
}
else
{
OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_BG_PROTECTION_INUSED);
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, (OFDMSETPROTECT|CCKSETPROTECT|ALLN_SETPROTECT),TRUE,(pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1));
if (bUseBGProtection) {
OPSTATUS_SET_FLAG(pAd,
fOP_STATUS_BG_PROTECTION_INUSED);
AsicUpdateProtect(pAd,
pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
OperaionMode,
(OFDMSETPROTECT
|
CCKSETPROTECT
|
ALLN_SETPROTECT),
FALSE,
(pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
NonGfPresent
== 1));
} else {
OPSTATUS_CLEAR_FLAG(pAd,
fOP_STATUS_BG_PROTECTION_INUSED);
AsicUpdateProtect(pAd,
pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
OperaionMode,
(OFDMSETPROTECT
|
CCKSETPROTECT
|
ALLN_SETPROTECT),
TRUE,
(pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
NonGfPresent
== 1));
}
DBGPRINT(RT_DEBUG_WARN, ("SYNC - AP changed B/G protection to %d\n", bUseBGProtection));
DBGPRINT(RT_DEBUG_WARN,
("SYNC - AP changed B/G protection to %d\n",
bUseBGProtection));
}
// check Ht protection mode. and adhere to the Non-GF device indication by AP.
if ((AddHtInfoLen != 0) &&
((AddHtInfo.AddHtInfo2.OperaionMode != pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode) ||
(AddHtInfo.AddHtInfo2.NonGfPresent != pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent)))
{
pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent = AddHtInfo.AddHtInfo2.NonGfPresent;
pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode = AddHtInfo.AddHtInfo2.OperaionMode;
if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent == 1)
{
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, TRUE);
}
else
AsicUpdateProtect(pAd, pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode, ALLN_SETPROTECT, FALSE, FALSE);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP changed N OperaionMode to %d\n", pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode));
((AddHtInfo.AddHtInfo2.OperaionMode !=
pAd->MlmeAux.AddHtInfo.AddHtInfo2.
OperaionMode)
|| (AddHtInfo.AddHtInfo2.NonGfPresent !=
pAd->MlmeAux.AddHtInfo.AddHtInfo2.
NonGfPresent))) {
pAd->MlmeAux.AddHtInfo.AddHtInfo2.
NonGfPresent =
AddHtInfo.AddHtInfo2.NonGfPresent;
pAd->MlmeAux.AddHtInfo.AddHtInfo2.
OperaionMode =
AddHtInfo.AddHtInfo2.OperaionMode;
if (pAd->MlmeAux.AddHtInfo.AddHtInfo2.
NonGfPresent == 1) {
AsicUpdateProtect(pAd,
pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
OperaionMode,
ALLN_SETPROTECT,
FALSE, TRUE);
} else
AsicUpdateProtect(pAd,
pAd->MlmeAux.
AddHtInfo.
AddHtInfo2.
OperaionMode,
ALLN_SETPROTECT,
FALSE, FALSE);
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - AP changed N OperaionMode to %d\n",
pAd->MlmeAux.AddHtInfo.
AddHtInfo2.OperaionMode));
}
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED) &&
ERP_IS_USE_BARKER_PREAMBLE(Erp))
{
MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP forced to use LONG preamble\n"));
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED)
&& ERP_IS_USE_BARKER_PREAMBLE(Erp)) {
MlmeSetTxPreamble(pAd,
Rt802_11PreambleLong);
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - AP forced to use LONG preamble\n"));
}
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_WMM_INUSED) &&
(EdcaParm.bValid == TRUE) &&
(EdcaParm.EdcaUpdateCount != pAd->CommonCfg.APEdcaParm.EdcaUpdateCount))
{
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - AP change EDCA parameters(from %d to %d)\n",
pAd->CommonCfg.APEdcaParm.EdcaUpdateCount,
EdcaParm.EdcaUpdateCount));
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_WMM_INUSED)
&& (EdcaParm.bValid == TRUE)
&& (EdcaParm.EdcaUpdateCount !=
pAd->CommonCfg.APEdcaParm.
EdcaUpdateCount)) {
DBGPRINT(RT_DEBUG_TRACE,
("SYNC - AP change EDCA parameters(from %d to %d)\n",
pAd->CommonCfg.APEdcaParm.
EdcaUpdateCount,
EdcaParm.EdcaUpdateCount));
AsicSetEdcaParm(pAd, &EdcaParm);
}
// copy QOS related information
NdisMoveMemory(&pAd->CommonCfg.APQbssLoad, &QbssLoad, sizeof(QBSS_LOAD_PARM));
NdisMoveMemory(&pAd->CommonCfg.APQosCapability, &QosCapability, sizeof(QOS_CAPABILITY_PARM));
NdisMoveMemory(&pAd->CommonCfg.APQbssLoad,
&QbssLoad,
sizeof(QBSS_LOAD_PARM));
NdisMoveMemory(&pAd->CommonCfg.APQosCapability,
&QosCapability,
sizeof(QOS_CAPABILITY_PARM));
}
// only INFRASTRUCTURE mode support power-saving feature
if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE)) || (pAd->CommonCfg.bAPSDForcePowerSave))
{
if ((INFRA_ON(pAd) && (pAd->StaCfg.Psm == PWR_SAVE))
|| (pAd->CommonCfg.bAPSDForcePowerSave)) {
UCHAR FreeNumber;
// 1. AP has backlogged unicast-to-me frame, stay AWAKE, send PSPOLL
// 2. AP has backlogged broadcast/multicast frame and we want those frames, stay AWAKE
// 3. we have outgoing frames in TxRing or MgmtRing, better stay AWAKE
// 4. Psm change to PWR_SAVE, but AP not been informed yet, we better stay AWAKE
// 5. otherwise, put PHY back to sleep to save battery.
if (MessageToMe)
{
if (MessageToMe) {
#ifdef RTMP_MAC_PCI
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
{
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_PCIE_DEVICE)) {
// Restore to correct BBP R3 value
if (pAd->Antenna.field.RxPath > 1)
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
if (pAd->Antenna.field.RxPath >
1)
RTMP_BBP_IO_WRITE8_BY_REG_ID
(pAd, BBP_R3,
pAd->StaCfg.BBPR3);
// Turn clk to 80Mhz.
}
#endif // RTMP_MAC_PCI //
if (pAd->CommonCfg.bAPSDCapable && pAd->CommonCfg.APEdcaParm.bAPSDCapable &&
pAd->CommonCfg.bAPSDAC_BE && pAd->CommonCfg.bAPSDAC_BK && pAd->CommonCfg.bAPSDAC_VI && pAd->CommonCfg.bAPSDAC_VO)
{
pAd->CommonCfg.bNeedSendTriggerFrame = TRUE;
}
else
if (pAd->CommonCfg.bAPSDCapable
&& pAd->CommonCfg.APEdcaParm.
bAPSDCapable
&& pAd->CommonCfg.bAPSDAC_BE
&& pAd->CommonCfg.bAPSDAC_BK
&& pAd->CommonCfg.bAPSDAC_VI
&& pAd->CommonCfg.bAPSDAC_VO) {
pAd->CommonCfg.
bNeedSendTriggerFrame =
TRUE;
} else
RTMP_PS_POLL_ENQUEUE(pAd);
}
else if (BcastFlag && (DtimCount == 0) && OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM))
} else if (BcastFlag && (DtimCount == 0)
&& OPSTATUS_TEST_FLAG(pAd,
fOP_STATUS_RECEIVE_DTIM))
{
#ifdef RTMP_MAC_PCI
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
{
if (pAd->Antenna.field.RxPath > 1)
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_PCIE_DEVICE)) {
if (pAd->Antenna.field.RxPath >
1)
RTMP_BBP_IO_WRITE8_BY_REG_ID
(pAd, BBP_R3,
pAd->StaCfg.BBPR3);
}
#endif // RTMP_MAC_PCI //
}
else if ((pAd->TxSwQueue[QID_AC_BK].Number != 0) ||
(pAd->TxSwQueue[QID_AC_BE].Number != 0) ||
(pAd->TxSwQueue[QID_AC_VI].Number != 0) ||
(pAd->TxSwQueue[QID_AC_VO].Number != 0) ||
(RTMPFreeTXDRequest(pAd, QID_AC_BK, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
(RTMPFreeTXDRequest(pAd, QID_AC_BE, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
(RTMPFreeTXDRequest(pAd, QID_AC_VI, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
(RTMPFreeTXDRequest(pAd, QID_AC_VO, TX_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS) ||
(RTMPFreeTXDRequest(pAd, QID_MGMT, MGMT_RING_SIZE - 1, &FreeNumber) != NDIS_STATUS_SUCCESS))
{
} else
if ((pAd->TxSwQueue[QID_AC_BK].Number != 0)
|| (pAd->TxSwQueue[QID_AC_BE].Number !=
0)
|| (pAd->TxSwQueue[QID_AC_VI].Number !=
0)
|| (pAd->TxSwQueue[QID_AC_VO].Number !=
0)
||
(RTMPFreeTXDRequest
(pAd, QID_AC_BK, TX_RING_SIZE - 1,
&FreeNumber) != NDIS_STATUS_SUCCESS)
||
(RTMPFreeTXDRequest
(pAd, QID_AC_BE, TX_RING_SIZE - 1,
&FreeNumber) != NDIS_STATUS_SUCCESS)
||
(RTMPFreeTXDRequest
(pAd, QID_AC_VI, TX_RING_SIZE - 1,
&FreeNumber) != NDIS_STATUS_SUCCESS)
||
(RTMPFreeTXDRequest
(pAd, QID_AC_VO, TX_RING_SIZE - 1,
&FreeNumber) != NDIS_STATUS_SUCCESS)
||
(RTMPFreeTXDRequest
(pAd, QID_MGMT, MGMT_RING_SIZE - 1,
&FreeNumber) !=
NDIS_STATUS_SUCCESS)) {
// TODO: consider scheduled HCCA. might not be proper to use traditional DTIM-based power-saving scheme
// can we cheat here (i.e. just check MGMT & AC_BE) for better performance?
#ifdef RTMP_MAC_PCI
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_PCIE_DEVICE))
{
if (pAd->Antenna.field.RxPath > 1)
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, pAd->StaCfg.BBPR3);
if (OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_PCIE_DEVICE)) {
if (pAd->Antenna.field.RxPath >
1)
RTMP_BBP_IO_WRITE8_BY_REG_ID
(pAd, BBP_R3,
pAd->StaCfg.BBPR3);
}
#endif // RTMP_MAC_PCI //
}
else
{
if ((pAd->CommonCfg.bACMAPSDTr[QID_AC_VO]) ||
(pAd->CommonCfg.bACMAPSDTr[QID_AC_VI]) ||
(pAd->CommonCfg.bACMAPSDTr[QID_AC_BK]) ||
(pAd->CommonCfg.bACMAPSDTr[QID_AC_BE]))
{
} else {
if ((pAd->CommonCfg.
bACMAPSDTr[QID_AC_VO])
|| (pAd->CommonCfg.
bACMAPSDTr[QID_AC_VI])
|| (pAd->CommonCfg.
bACMAPSDTr[QID_AC_BK])
|| (pAd->CommonCfg.
bACMAPSDTr[QID_AC_BE])) {
/*
WMM Spec v1.0 3.6.2.4,
The WMM STA shall remain awake until it receives a
QoS Data or Null frame addressed to it, with the
EOSP subfield in QoS Control field set to 1.
So we can not sleep here or we will suffer a case:
PS Management Frame -->
Trigger frame -->
Beacon (TIM=0) (Beacon is closer to Trig frame) -->
Station goes to sleep -->
AP delivery queued UAPSD packets -->
Station can NOT receive the reply
Maybe we need a timeout timer to avoid that we do
NOT receive the EOSP frame.
We can not use More Data to check if SP is ended
due to MaxSPLength.
*/
}
else
{
USHORT NextDtim = DtimCount;
if (NextDtim == 0)
NextDtim = DtimPeriod;
TbttNumToNextWakeUp = pAd->StaCfg.DefaultListenCount;
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM) && (TbttNumToNextWakeUp > NextDtim))
TbttNumToNextWakeUp = NextDtim;
if (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
{
// Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
pAd->ThisTbttNumToNextWakeUp = TbttNumToNextWakeUp;
AsicSleepThenAutoWakeup(pAd, pAd->ThisTbttNumToNextWakeUp);
WMM Spec v1.0 3.6.2.4,
The WMM STA shall remain awake until it receives a
QoS Data or Null frame addressed to it, with the
EOSP subfield in QoS Control field set to 1.
So we can not sleep here or we will suffer a case:
PS Management Frame -->
Trigger frame -->
Beacon (TIM=0) (Beacon is closer to Trig frame) -->
Station goes to sleep -->
AP delivery queued UAPSD packets -->
Station can NOT receive the reply
Maybe we need a timeout timer to avoid that we do
NOT receive the EOSP frame.
We can not use More Data to check if SP is ended
due to MaxSPLength.
*/
} else {
USHORT NextDtim = DtimCount;
if (NextDtim == 0)
NextDtim = DtimPeriod;
TbttNumToNextWakeUp =
pAd->StaCfg.
DefaultListenCount;
if (OPSTATUS_TEST_FLAG
(pAd,
fOP_STATUS_RECEIVE_DTIM)
&& (TbttNumToNextWakeUp >
NextDtim))
TbttNumToNextWakeUp =
NextDtim;
if (!OPSTATUS_TEST_FLAG
(pAd, fOP_STATUS_DOZE)) {
// Set a flag to go to sleep . Then after parse this RxDoneInterrupt, will go to sleep mode.
pAd->
ThisTbttNumToNextWakeUp
=
TbttNumToNextWakeUp;
AsicSleepThenAutoWakeup
(pAd,
pAd->
ThisTbttNumToNextWakeUp);
}
}
}
......@@ -1430,116 +1703,126 @@ VOID PeerBeacon(
Receive PROBE REQ from remote peer when operating in IBSS mode
==========================================================================
*/
VOID PeerProbeReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID PeerProbeReqAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
UCHAR Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
UCHAR SsidLen;
UCHAR HtLen, AddHtLen, NewExtLen;
UCHAR Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
UCHAR SsidLen;
UCHAR HtLen, AddHtLen, NewExtLen;
HEADER_802_11 ProbeRspHdr;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
NDIS_STATUS NStatus;
PUCHAR pOutBuffer = NULL;
ULONG FrameLen = 0;
LARGE_INTEGER FakeTimestamp;
UCHAR DsLen = 1, IbssLen = 2;
UCHAR LocalErpIe[3] = {IE_ERP, 1, 0};
BOOLEAN Privacy;
USHORT CapabilityInfo;
UCHAR RSNIe = IE_WPA;
UCHAR DsLen = 1, IbssLen = 2;
UCHAR LocalErpIe[3] = { IE_ERP, 1, 0 };
BOOLEAN Privacy;
USHORT CapabilityInfo;
UCHAR RSNIe = IE_WPA;
if (! ADHOC_ON(pAd))
if (!ADHOC_ON(pAd))
return;
if (PeerProbeReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen))
{
if ((SsidLen == 0) || SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid, pAd->CommonCfg.SsidLen))
{
if (PeerProbeReqSanity
(pAd, Elem->Msg, Elem->MsgLen, Addr2, Ssid, &SsidLen)) {
if ((SsidLen == 0)
|| SSID_EQUAL(Ssid, SsidLen, pAd->CommonCfg.Ssid,
pAd->CommonCfg.SsidLen)) {
// allocate and send out ProbeRsp frame
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NStatus != NDIS_STATUS_SUCCESS)
return;
//pAd->StaCfg.AtimWin = 0; // ??????
Privacy = (pAd->StaCfg.WepStatus == Ndis802_11Encryption1Enabled) ||
(pAd->StaCfg.WepStatus == Ndis802_11Encryption2Enabled) ||
(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled);
CapabilityInfo = CAP_GENERATE(0, 1, Privacy, (pAd->CommonCfg.TxPreamble == Rt802_11PreambleShort), 0, 0);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ProbeRspHdr,
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->CommonCfg.BeaconPeriod,
2, &CapabilityInfo,
1, &SsidIe,
1, &pAd->CommonCfg.SsidLen,
pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
1, &SupRateIe,
1, &pAd->StaActive.SupRateLen,
pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
1, &DsIe,
1, &DsLen,
1, &pAd->CommonCfg.Channel,
1, &IbssIe,
1, &IbssLen,
2, &pAd->StaActive.AtimWin,
END_OF_ARGS);
if (pAd->StaActive.ExtRateLen)
{
Privacy =
(pAd->StaCfg.WepStatus ==
Ndis802_11Encryption1Enabled)
|| (pAd->StaCfg.WepStatus ==
Ndis802_11Encryption2Enabled)
|| (pAd->StaCfg.WepStatus ==
Ndis802_11Encryption3Enabled);
CapabilityInfo =
CAP_GENERATE(0, 1, Privacy,
(pAd->CommonCfg.TxPreamble ==
Rt802_11PreambleShort), 0, 0);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ProbeRspHdr,
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->CommonCfg.BeaconPeriod,
2, &CapabilityInfo,
1, &SsidIe,
1, &pAd->CommonCfg.SsidLen,
pAd->CommonCfg.SsidLen,
pAd->CommonCfg.Ssid, 1, &SupRateIe, 1,
&pAd->StaActive.SupRateLen,
pAd->StaActive.SupRateLen,
pAd->StaActive.SupRate, 1, &DsIe, 1,
&DsLen, 1, &pAd->CommonCfg.Channel, 1,
&IbssIe, 1, &IbssLen, 2,
&pAd->StaActive.AtimWin, END_OF_ARGS);
if (pAd->StaActive.ExtRateLen) {
ULONG tmp;
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
3, LocalErpIe,
1, &ExtRateIe,
1, &pAd->StaActive.ExtRateLen,
pAd->StaActive.ExtRateLen, &pAd->StaActive.ExtRate,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
3, LocalErpIe,
1, &ExtRateIe,
1, &pAd->StaActive.ExtRateLen,
pAd->StaActive.ExtRateLen,
&pAd->StaActive.ExtRate,
END_OF_ARGS);
FrameLen += tmp;
}
// If adhoc secruity is set for WPA-None, append the cipher suite IE
if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone)
{
if (pAd->StaCfg.AuthMode == Ndis802_11AuthModeWPANone) {
ULONG tmp;
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &RSNIe,
1, &pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSNIE_Len, pAd->StaCfg.RSN_IE,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer + FrameLen, &tmp,
1, &RSNIe,
1, &pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSNIE_Len,
pAd->StaCfg.RSN_IE,
END_OF_ARGS);
FrameLen += tmp;
}
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
{
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
ULONG TmpLen;
UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
UCHAR BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
HtLen = sizeof(pAd->CommonCfg.HtCapability);
AddHtLen = sizeof(pAd->CommonCfg.AddHTInfo);
NewExtLen = 1;
//New extension channel offset IE is included in Beacon, Probe Rsp or channel Switch Announcement Frame
if (pAd->bBroadComHT == TRUE)
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &WpaIe,
4, &BROADCOM[0],
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
END_OF_ARGS);
}
else
{
MakeOutgoingFrame(pOutBuffer + FrameLen, &TmpLen,
1, &HtCapIe,
1, &HtLen,
sizeof(HT_CAPABILITY_IE), &pAd->CommonCfg.HtCapability,
1, &AddHtInfoIe,
1, &AddHtLen,
sizeof(ADD_HT_INFO_IE), &pAd->CommonCfg.AddHTInfo,
1, &NewExtChanIe,
1, &NewExtLen,
sizeof(NEW_EXT_CHAN_IE), &pAd->CommonCfg.NewExtChanOffset,
END_OF_ARGS);
if (pAd->bBroadComHT == TRUE) {
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &WpaIe, 4,
&BROADCOM[0],
pAd->MlmeAux.
HtCapabilityLen,
&pAd->MlmeAux.
HtCapability,
END_OF_ARGS);
} else {
MakeOutgoingFrame(pOutBuffer + FrameLen,
&TmpLen, 1, &HtCapIe,
1, &HtLen,
sizeof
(HT_CAPABILITY_IE),
&pAd->CommonCfg.
HtCapability, 1,
&AddHtInfoIe, 1,
&AddHtLen,
sizeof
(ADD_HT_INFO_IE),
&pAd->CommonCfg.
AddHTInfo, 1,
&NewExtChanIe, 1,
&NewExtLen,
sizeof
(NEW_EXT_CHAN_IE),
&pAd->CommonCfg.
NewExtChanOffset,
END_OF_ARGS);
}
FrameLen += TmpLen;
}
......@@ -1550,9 +1833,7 @@ VOID PeerProbeReqAction(
}
}
VOID BeaconTimeoutAtJoinAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID BeaconTimeoutAtJoinAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - BeaconTimeoutAtJoinAction\n"));
......@@ -1567,17 +1848,15 @@ VOID BeaconTimeoutAtJoinAction(
Scan timeout procedure. basically add channel index by 1 and rescan
==========================================================================
*/
VOID ScanTimeoutAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID ScanTimeoutAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
pAd->MlmeAux.Channel = NextChannel(pAd, pAd->MlmeAux.Channel);
// Only one channel scanned for CISCO beacon request
if ((pAd->MlmeAux.ScanType == SCAN_CISCO_ACTIVE) ||
(pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
(pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
(pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
(pAd->MlmeAux.ScanType == SCAN_CISCO_PASSIVE) ||
(pAd->MlmeAux.ScanType == SCAN_CISCO_NOISE) ||
(pAd->MlmeAux.ScanType == SCAN_CISCO_CHANNEL_LOAD))
pAd->MlmeAux.Channel = 0;
// this routine will stop if pAd->MlmeAux.Channel == 0
......@@ -1589,12 +1868,12 @@ VOID ScanTimeoutAction(
Description:
==========================================================================
*/
VOID InvalidStateWhenScan(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenScan(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
DBGPRINT(RT_DEBUG_TRACE,
("AYNC - InvalidStateWhenScan(state=%ld). Reset SYNC machine\n",
pAd->Mlme.SyncMachine.CurrState));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
......@@ -1605,12 +1884,12 @@ VOID InvalidStateWhenScan(
Description:
==========================================================================
*/
VOID InvalidStateWhenJoin(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenJoin(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
DBGPRINT(RT_DEBUG_TRACE,
("InvalidStateWhenJoin(state=%ld). Reset SYNC machine\n",
pAd->Mlme.SyncMachine.CurrState));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_JOIN_CONF, 2, &Status);
......@@ -1621,12 +1900,12 @@ VOID InvalidStateWhenJoin(
Description:
==========================================================================
*/
VOID InvalidStateWhenStart(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID InvalidStateWhenStart(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
USHORT Status;
DBGPRINT(RT_DEBUG_TRACE, ("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n", pAd->Mlme.SyncMachine.CurrState));
DBGPRINT(RT_DEBUG_TRACE,
("InvalidStateWhenStart(state=%ld). Reset SYNC machine\n",
pAd->Mlme.SyncMachine.CurrState));
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
Status = MLME_STATE_MACHINE_REJECT;
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_START_CONF, 2, &Status);
......@@ -1640,56 +1919,51 @@ VOID InvalidStateWhenStart(
==========================================================================
*/
VOID EnqueuePsPoll(
IN PRTMP_ADAPTER pAd)
VOID EnqueuePsPoll(IN PRTMP_ADAPTER pAd)
{
if (pAd->StaCfg.WindowsPowerMode == Ndis802_11PowerModeLegacy_PSP)
pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
MiniportMMRequest(pAd, 0, (PUCHAR)&pAd->PsPollFrame, sizeof(PSPOLL_FRAME));
pAd->PsPollFrame.FC.PwrMgmt = PWR_SAVE;
MiniportMMRequest(pAd, 0, (PUCHAR) & pAd->PsPollFrame,
sizeof(PSPOLL_FRAME));
}
/*
==========================================================================
Description:
==========================================================================
*/
VOID EnqueueProbeRequest(
IN PRTMP_ADAPTER pAd)
VOID EnqueueProbeRequest(IN PRTMP_ADAPTER pAd)
{
NDIS_STATUS NState;
PUCHAR pOutBuffer;
ULONG FrameLen = 0;
HEADER_802_11 Hdr80211;
NDIS_STATUS NState;
PUCHAR pOutBuffer;
ULONG FrameLen = 0;
HEADER_802_11 Hdr80211;
DBGPRINT(RT_DEBUG_TRACE, ("force out a ProbeRequest ...\n"));
NState = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NState == NDIS_STATUS_SUCCESS)
{
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
NState = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
if (NState == NDIS_STATUS_SUCCESS) {
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0,
BROADCAST_ADDR, BROADCAST_ADDR);
// this ProbeRequest explicitly specify SSID to reduce unwanted ProbeResponse
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &Hdr80211,
1, &SsidIe,
1, &pAd->CommonCfg.SsidLen,
pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
1, &SupRateIe,
1, &pAd->StaActive.SupRateLen,
pAd->StaActive.SupRateLen, pAd->StaActive.SupRate,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &Hdr80211,
1, &SsidIe,
1, &pAd->CommonCfg.SsidLen,
pAd->CommonCfg.SsidLen, pAd->CommonCfg.Ssid,
1, &SupRateIe,
1, &pAd->StaActive.SupRateLen,
pAd->StaActive.SupRateLen,
pAd->StaActive.SupRate, END_OF_ARGS);
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
MlmeFreeMemory(pAd, pOutBuffer);
}
}
BOOLEAN ScanRunning(
IN PRTMP_ADAPTER pAd)
BOOLEAN ScanRunning(IN PRTMP_ADAPTER pAd)
{
return (pAd->Mlme.SyncMachine.CurrState == SCAN_LISTEN) ? TRUE : FALSE;
}
......@@ -37,7 +37,7 @@
*/
#include "../rt_config.h"
void inc_byte_array(UCHAR *counter, int len);
void inc_byte_array(UCHAR * counter, int len);
/*
========================================================================
......@@ -58,33 +58,29 @@ void inc_byte_array(UCHAR *counter, int len);
========================================================================
*/
VOID RTMPReportMicError(
IN PRTMP_ADAPTER pAd,
IN PCIPHER_KEY pWpaKey)
VOID RTMPReportMicError(IN PRTMP_ADAPTER pAd, IN PCIPHER_KEY pWpaKey)
{
ULONG Now;
UCHAR unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1:0);
ULONG Now;
UCHAR unicastKey = (pWpaKey->Type == PAIRWISE_KEY ? 1 : 0);
// Record Last MIC error time and count
NdisGetSystemUpTime(&Now);
if (pAd->StaCfg.MicErrCnt == 0)
{
if (pAd->StaCfg.MicErrCnt == 0) {
pAd->StaCfg.MicErrCnt++;
pAd->StaCfg.LastMicErrorTime = Now;
NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
}
else if (pAd->StaCfg.MicErrCnt == 1)
{
if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now)
{
NdisZeroMemory(pAd->StaCfg.ReplayCounter, 8);
} else if (pAd->StaCfg.MicErrCnt == 1) {
if ((pAd->StaCfg.LastMicErrorTime + (60 * OS_HZ)) < Now) {
// Update Last MIC error time, this did not violate two MIC errors within 60 seconds
pAd->StaCfg.LastMicErrorTime = Now;
}
else
{
} else {
if (pAd->CommonCfg.bWirelessEvent)
RTMPSendWirelessEvent(pAd, IW_COUNTER_MEASURES_EVENT_FLAG, pAd->MacTab.Content[BSSID_WCID].Addr, BSS0, 0);
RTMPSendWirelessEvent(pAd,
IW_COUNTER_MEASURES_EVENT_FLAG,
pAd->MacTab.
Content[BSSID_WCID].Addr,
BSS0, 0);
pAd->StaCfg.LastMicErrorTime = Now;
// Violate MIC error counts, MIC countermeasures kicks in
......@@ -101,154 +97,139 @@ VOID RTMPReportMicError(
// RTMPRingCleanUp(pAd, QID_AC_VO);
// RTMPRingCleanUp(pAd, QID_HCCA);
}
}
else
{
} else {
// MIC error count >= 2
// This should not happen
;
}
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
OID_802_11_MIC_FAILURE_REPORT_FRAME,
1,
&unicastKey);
if (pAd->StaCfg.MicErrCnt == 2)
{
RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
}
MlmeEnqueue(pAd,
MLME_CNTL_STATE_MACHINE,
OID_802_11_MIC_FAILURE_REPORT_FRAME, 1, &unicastKey);
if (pAd->StaCfg.MicErrCnt == 2) {
RTMPSetTimer(&pAd->StaCfg.WpaDisassocAndBlockAssocTimer, 100);
}
}
#define LENGTH_EAP_H 4
// If the received frame is EAP-Packet ,find out its EAP-Code (Request(0x01), Response(0x02), Success(0x03), Failure(0x04)).
INT WpaCheckEapCode(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pFrame,
IN USHORT FrameLen,
IN USHORT OffSet)
INT WpaCheckEapCode(IN PRTMP_ADAPTER pAd,
IN PUCHAR pFrame, IN USHORT FrameLen, IN USHORT OffSet)
{
PUCHAR pData;
INT result = 0;
PUCHAR pData;
INT result = 0;
if( FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H )
if (FrameLen < OffSet + LENGTH_EAPOL_H + LENGTH_EAP_H)
return result;
pData = pFrame + OffSet; // skip offset bytes
pData = pFrame + OffSet; // skip offset bytes
if(*(pData+1) == EAPPacket) // 802.1x header - Packet Type
if (*(pData + 1) == EAPPacket) // 802.1x header - Packet Type
{
result = *(pData+4); // EAP header - Code
result = *(pData + 4); // EAP header - Code
}
return result;
}
VOID WpaSendMicFailureToWpaSupplicant(
IN PRTMP_ADAPTER pAd,
IN BOOLEAN bUnicast)
VOID WpaSendMicFailureToWpaSupplicant(IN PRTMP_ADAPTER pAd, IN BOOLEAN bUnicast)
{
char custom[IW_CUSTOM_MAX] = {0};
char custom[IW_CUSTOM_MAX] = { 0 };
sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
if(bUnicast)
sprintf(custom, "%s unicast", custom);
sprintf(custom, "MLME-MICHAELMICFAILURE.indication");
if (bUnicast)
sprintf(custom, "%s unicast", custom);
RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (PUCHAR)custom, strlen(custom));
RtmpOSWrielessEventSend(pAd, IWEVCUSTOM, -1, NULL, (PUCHAR) custom,
strlen(custom));
return;
return;
}
VOID WpaMicFailureReportFrame(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
VOID WpaMicFailureReportFrame(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
{
PUCHAR pOutBuffer = NULL;
UCHAR Header802_3[14];
ULONG FrameLen = 0;
EAPOL_PACKET Packet;
UCHAR Mic[16];
BOOLEAN bUnicast;
PUCHAR pOutBuffer = NULL;
UCHAR Header802_3[14];
ULONG FrameLen = 0;
EAPOL_PACKET Packet;
UCHAR Mic[16];
BOOLEAN bUnicast;
DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame ----->\n"));
bUnicast = (Elem->Msg[0] == 1 ? TRUE:FALSE);
bUnicast = (Elem->Msg[0] == 1 ? TRUE : FALSE);
pAd->Sequence = ((pAd->Sequence) + 1) & (MAX_SEQ_NUMBER);
// init 802.3 header and Fill Packet
MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid, pAd->CurrentAddress, EAPOL);
MAKE_802_3_HEADER(Header802_3, pAd->CommonCfg.Bssid,
pAd->CurrentAddress, EAPOL);
NdisZeroMemory(&Packet, sizeof(Packet));
Packet.ProVer = EAPOL_VER;
Packet.ProType = EAPOLKey;
Packet.ProVer = EAPOL_VER;
Packet.ProType = EAPOLKey;
Packet.KeyDesc.Type = WPA1_KEY_DESC;
// Request field presented
Packet.KeyDesc.KeyInfo.Request = 1;
// Request field presented
Packet.KeyDesc.KeyInfo.Request = 1;
if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
{
if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) {
Packet.KeyDesc.KeyInfo.KeyDescVer = 2;
}
else // TKIP
} else // TKIP
{
Packet.KeyDesc.KeyInfo.KeyDescVer = 1;
}
Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
Packet.KeyDesc.KeyInfo.KeyType = (bUnicast ? PAIRWISEKEY : GROUPKEY);
// KeyMic field presented
Packet.KeyDesc.KeyInfo.KeyMic = 1;
Packet.KeyDesc.KeyInfo.KeyMic = 1;
// Error field presented
Packet.KeyDesc.KeyInfo.Error = 1;
// Error field presented
Packet.KeyDesc.KeyInfo.Error = 1;
// Update packet length after decide Key data payload
SET_UINT16_TO_ARRARY(Packet.Body_Len, LEN_EAPOL_KEY_MSG)
// Key Replay Count
NdisMoveMemory(Packet.KeyDesc.ReplayCounter, pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
// Key Replay Count
NdisMoveMemory(Packet.KeyDesc.ReplayCounter,
pAd->StaCfg.ReplayCounter, LEN_KEY_DESC_REPLAY);
inc_byte_array(pAd->StaCfg.ReplayCounter, 8);
// Convert to little-endian format.
*((USHORT *)&Packet.KeyDesc.KeyInfo) = cpu2le16(*((USHORT *)&Packet.KeyDesc.KeyInfo));
*((USHORT *) & Packet.KeyDesc.KeyInfo) =
cpu2le16(*((USHORT *) & Packet.KeyDesc.KeyInfo));
MlmeAllocateMemory(pAd, (PUCHAR *)&pOutBuffer); // allocate memory
if(pOutBuffer == NULL)
{
MlmeAllocateMemory(pAd, (PUCHAR *) & pOutBuffer); // allocate memory
if (pOutBuffer == NULL) {
return;
}
// Prepare EAPOL frame for MIC calculation
// Be careful, only EAPOL frame is counted for MIC calculation
MakeOutgoingFrame(pOutBuffer, &FrameLen,
CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, &Packet,
END_OF_ARGS);
MakeOutgoingFrame(pOutBuffer, &FrameLen,
CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, &Packet,
END_OF_ARGS);
// Prepare and Fill MIC value
NdisZeroMemory(Mic, sizeof(Mic));
if(pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled)
{ // AES
UCHAR digest[20] = {0};
HMAC_SHA1(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, digest, SHA1_DIGEST_SIZE);
if (pAd->StaCfg.WepStatus == Ndis802_11Encryption3Enabled) { // AES
UCHAR digest[20] = { 0 };
HMAC_SHA1(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
digest, SHA1_DIGEST_SIZE);
NdisMoveMemory(Mic, digest, LEN_KEY_DESC_MIC);
}
else
{ // TKIP
HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen, Mic, MD5_DIGEST_SIZE);
} else { // TKIP
HMAC_MD5(pAd->StaCfg.PTK, LEN_EAP_MICK, pOutBuffer, FrameLen,
Mic, MD5_DIGEST_SIZE);
}
NdisMoveMemory(Packet.KeyDesc.KeyMic, Mic, LEN_KEY_DESC_MIC);
// copy frame to Tx ring and send MIC failure report frame to authenticator
RTMPToWirelessSta(pAd, &pAd->MacTab.Content[BSSID_WCID],
Header802_3, LENGTH_802_3,
(PUCHAR)&Packet,
CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, FALSE);
Header802_3, LENGTH_802_3,
(PUCHAR) & Packet,
CONV_ARRARY_TO_UINT16(Packet.Body_Len) + 4, FALSE);
MlmeFreeMemory(pAd, (PUCHAR)pOutBuffer);
MlmeFreeMemory(pAd, (PUCHAR) pOutBuffer);
DBGPRINT(RT_DEBUG_TRACE, ("WpaMicFailureReportFrame <-----\n"));
}
......@@ -262,7 +243,7 @@ VOID WpaMicFailureReportFrame(
* rolling over to more significant bytes if the byte was incremented from
* 0xff to 0x00.
*/
void inc_byte_array(UCHAR *counter, int len)
void inc_byte_array(UCHAR * counter, int len)
{
int pos = len - 1;
while (pos >= 0) {
......@@ -273,26 +254,27 @@ void inc_byte_array(UCHAR *counter, int len)
}
}
VOID WpaDisassocApAndBlockAssoc(
IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
VOID WpaDisassocApAndBlockAssoc(IN PVOID SystemSpecific1,
IN PVOID FunctionContext,
IN PVOID SystemSpecific2,
IN PVOID SystemSpecific3)
{
RTMP_ADAPTER *pAd = (PRTMP_ADAPTER)FunctionContext;
MLME_DISASSOC_REQ_STRUCT DisassocReq;
RTMP_ADAPTER *pAd = (PRTMP_ADAPTER) FunctionContext;
MLME_DISASSOC_REQ_STRUCT DisassocReq;
// disassoc from current AP first
DBGPRINT(RT_DEBUG_TRACE, ("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid, REASON_MIC_FAILURE);
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ, sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
DBGPRINT(RT_DEBUG_TRACE,
("RTMPReportMicError - disassociate with current AP after sending second continuous EAPOL frame\n"));
DisassocParmFill(pAd, &DisassocReq, pAd->CommonCfg.Bssid,
REASON_MIC_FAILURE);
MlmeEnqueue(pAd, ASSOC_STATE_MACHINE, MT2_MLME_DISASSOC_REQ,
sizeof(MLME_DISASSOC_REQ_STRUCT), &DisassocReq);
pAd->Mlme.CntlMachine.CurrState = CNTL_WAIT_DISASSOC;
pAd->StaCfg.bBlockAssoc = TRUE;
}
VOID WpaStaPairwiseKeySetting(
IN PRTMP_ADAPTER pAd)
VOID WpaStaPairwiseKeySetting(IN PRTMP_ADAPTER pAd)
{
PCIPHER_KEY pSharedKey;
PMAC_TABLE_ENTRY pEntry;
......@@ -307,9 +289,11 @@ VOID WpaStaPairwiseKeySetting(
// Prepare pair-wise key information into shared key table
NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
pSharedKey->KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
NdisMoveMemory(pSharedKey->Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.PTK[48],
LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic,
&pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
// Decide its ChiperAlg
if (pAd->StaCfg.PairCipher == Ndis802_11Encryption2Enabled)
......@@ -320,37 +304,35 @@ VOID WpaStaPairwiseKeySetting(
pSharedKey->CipherAlg = CIPHER_NONE;
// Update these related information to MAC_TABLE_ENTRY
NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32], LEN_TKIP_EK);
NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48], LEN_TKIP_RXMICK);
NdisMoveMemory(pEntry->PairwiseKey.TxMic, &pAd->StaCfg.PTK[48+LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
NdisMoveMemory(pEntry->PairwiseKey.Key, &pAd->StaCfg.PTK[32],
LEN_TKIP_EK);
NdisMoveMemory(pEntry->PairwiseKey.RxMic, &pAd->StaCfg.PTK[48],
LEN_TKIP_RXMICK);
NdisMoveMemory(pEntry->PairwiseKey.TxMic,
&pAd->StaCfg.PTK[48 + LEN_TKIP_RXMICK], LEN_TKIP_TXMICK);
pEntry->PairwiseKey.CipherAlg = pSharedKey->CipherAlg;
// Update pairwise key information to ASIC Shared Key Table
AsicAddSharedKeyEntry(pAd,
BSS0,
0,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic,
pSharedKey->RxMic);
BSS0,
0,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic, pSharedKey->RxMic);
// Update ASIC WCID attribute table and IVEIV table
RTMPAddWcidAttributeEntry(pAd,
BSS0,
0,
pSharedKey->CipherAlg,
pEntry);
RTMPAddWcidAttributeEntry(pAd, BSS0, 0, pSharedKey->CipherAlg, pEntry);
STA_PORT_SECURED(pAd);
pAd->IndicateMediaState = NdisMediaStateConnected;
DBGPRINT(RT_DEBUG_TRACE, ("%s : AID(%d) port secured\n", __func__, pEntry->Aid));
DBGPRINT(RT_DEBUG_TRACE,
("%s : AID(%d) port secured\n", __func__, pEntry->Aid));
}
VOID WpaStaGroupKeySetting(
IN PRTMP_ADAPTER pAd)
VOID WpaStaGroupKeySetting(IN PRTMP_ADAPTER pAd)
{
PCIPHER_KEY pSharedKey;
PCIPHER_KEY pSharedKey;
pSharedKey = &pAd->SharedKey[BSS0][pAd->StaCfg.DefaultKeyId];
......@@ -358,8 +340,10 @@ VOID WpaStaGroupKeySetting(
NdisZeroMemory(pSharedKey, sizeof(CIPHER_KEY));
pSharedKey->KeyLen = LEN_TKIP_EK;
NdisMoveMemory(pSharedKey->Key, pAd->StaCfg.GTK, LEN_TKIP_EK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16], LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24], LEN_TKIP_TXMICK);
NdisMoveMemory(pSharedKey->RxMic, &pAd->StaCfg.GTK[16],
LEN_TKIP_RXMICK);
NdisMoveMemory(pSharedKey->TxMic, &pAd->StaCfg.GTK[24],
LEN_TKIP_TXMICK);
// Update Shared Key CipherAlg
pSharedKey->CipherAlg = CIPHER_NONE;
......@@ -374,18 +358,16 @@ VOID WpaStaGroupKeySetting(
// Update group key information to ASIC Shared Key Table
AsicAddSharedKeyEntry(pAd,
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic,
pSharedKey->RxMic);
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg,
pSharedKey->Key,
pSharedKey->TxMic, pSharedKey->RxMic);
// Update ASIC WCID attribute table and IVEIV table
RTMPAddWcidAttributeEntry(pAd,
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg,
NULL);
BSS0,
pAd->StaCfg.DefaultKeyId,
pSharedKey->CipherAlg, NULL);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment