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