mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
Staging: rt28x0: run common/*.c files through Lindent
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
66cd8d6ec9
commit
96b3c83dc2
30 changed files with 16033 additions and 16469 deletions
|
@ -39,10 +39,7 @@
|
|||
#include "../rt_config.h"
|
||||
#include "action.h"
|
||||
|
||||
|
||||
static VOID ReservedAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem);
|
||||
static VOID ReservedAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem);
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
|
@ -61,75 +58,89 @@ static VOID ReservedAction(
|
|||
MT2_CLS3ERR cls3err_action
|
||||
==========================================================================
|
||||
*/
|
||||
VOID ActionStateMachineInit(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN STATE_MACHINE *S,
|
||||
OUT STATE_MACHINE_FUNC Trans[])
|
||||
VOID ActionStateMachineInit(IN PRTMP_ADAPTER pAd,
|
||||
IN STATE_MACHINE * S,
|
||||
OUT STATE_MACHINE_FUNC Trans[])
|
||||
{
|
||||
StateMachineInit(S, (STATE_MACHINE_FUNC *)Trans, MAX_ACT_STATE, MAX_ACT_MSG, (STATE_MACHINE_FUNC)Drop, ACT_IDLE, ACT_MACHINE_BASE);
|
||||
StateMachineInit(S, (STATE_MACHINE_FUNC *) Trans, MAX_ACT_STATE,
|
||||
MAX_ACT_MSG, (STATE_MACHINE_FUNC) Drop, ACT_IDLE,
|
||||
ACT_MACHINE_BASE);
|
||||
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE, (STATE_MACHINE_FUNC)PeerSpectrumAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE, (STATE_MACHINE_FUNC)PeerQOSAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_SPECTRUM_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerSpectrumAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_QOS_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerQOSAction);
|
||||
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE, (STATE_MACHINE_FUNC)ReservedAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_DLS_CATE,
|
||||
(STATE_MACHINE_FUNC) ReservedAction);
|
||||
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE, (STATE_MACHINE_FUNC)PeerBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE, (STATE_MACHINE_FUNC)PeerHTAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE, (STATE_MACHINE_FUNC)MlmeADDBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE, (STATE_MACHINE_FUNC)MlmeDELBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_BA_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_HT_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerHTAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ADD_BA_CATE,
|
||||
(STATE_MACHINE_FUNC) MlmeADDBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_ORI_DELBA_CATE,
|
||||
(STATE_MACHINE_FUNC) MlmeDELBAAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_REC_DELBA_CATE,
|
||||
(STATE_MACHINE_FUNC) MlmeDELBAAction);
|
||||
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE, (STATE_MACHINE_FUNC)PeerPublicAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE, (STATE_MACHINE_FUNC)PeerRMAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_PUBLIC_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerPublicAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_PEER_RM_CATE,
|
||||
(STATE_MACHINE_FUNC) PeerRMAction);
|
||||
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE, (STATE_MACHINE_FUNC)MlmeQOSAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE, (STATE_MACHINE_FUNC)MlmeDLSAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID, (STATE_MACHINE_FUNC)MlmeInvalidAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_QOS_CATE,
|
||||
(STATE_MACHINE_FUNC) MlmeQOSAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_MLME_DLS_CATE,
|
||||
(STATE_MACHINE_FUNC) MlmeDLSAction);
|
||||
StateMachineSetAction(S, ACT_IDLE, MT2_ACT_INVALID,
|
||||
(STATE_MACHINE_FUNC) MlmeInvalidAction);
|
||||
}
|
||||
|
||||
VOID MlmeADDBAAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
|
||||
VOID MlmeADDBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
MLME_ADDBA_REQ_STRUCT *pInfo;
|
||||
UCHAR Addr[6];
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG Idx;
|
||||
FRAME_ADDBA_REQ Frame;
|
||||
ULONG FrameLen;
|
||||
BA_ORI_ENTRY *pBAEntry = NULL;
|
||||
UCHAR Addr[6];
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG Idx;
|
||||
FRAME_ADDBA_REQ Frame;
|
||||
ULONG FrameLen;
|
||||
BA_ORI_ENTRY *pBAEntry = NULL;
|
||||
|
||||
pInfo = (MLME_ADDBA_REQ_STRUCT *)Elem->Msg;
|
||||
pInfo = (MLME_ADDBA_REQ_STRUCT *) Elem->Msg;
|
||||
NdisZeroMemory(&Frame, sizeof(FRAME_ADDBA_REQ));
|
||||
|
||||
if(MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr))
|
||||
{
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if(NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeADDBAAction() allocate memory failed \n"));
|
||||
if (MlmeAddBAReqSanity(pAd, Elem->Msg, Elem->MsgLen, Addr)) {
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("BA - MlmeADDBAAction() allocate memory failed \n"));
|
||||
return;
|
||||
}
|
||||
// 1. find entry
|
||||
Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
|
||||
if (Idx == 0)
|
||||
{
|
||||
Idx =
|
||||
pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
|
||||
if (Idx == 0) {
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("BA - MlmeADDBAAction() can't find BAOriEntry \n"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
pBAEntry =&pAd->BATable.BAOriEntry[Idx];
|
||||
} else {
|
||||
pBAEntry = &pAd->BATable.BAOriEntry[Idx];
|
||||
}
|
||||
|
||||
{
|
||||
if (ADHOC_ON(pAd))
|
||||
ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
|
||||
ActHeaderInit(pAd, &Frame.Hdr, pInfo->pAddr,
|
||||
pAd->CurrentAddress,
|
||||
pAd->CommonCfg.Bssid);
|
||||
else
|
||||
ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pInfo->pAddr);
|
||||
ActHeaderInit(pAd, &Frame.Hdr,
|
||||
pAd->CommonCfg.Bssid,
|
||||
pAd->CurrentAddress,
|
||||
pInfo->pAddr);
|
||||
}
|
||||
|
||||
Frame.Category = CATEGORY_BA;
|
||||
|
@ -141,22 +152,29 @@ VOID MlmeADDBAAction(
|
|||
Frame.Token = pInfo->Token;
|
||||
Frame.TimeOutValue = pInfo->TimeOutValue;
|
||||
Frame.BaStartSeq.field.FragNum = 0;
|
||||
Frame.BaStartSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
|
||||
Frame.BaStartSeq.field.StartSeq =
|
||||
pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID];
|
||||
|
||||
*(USHORT *)(&Frame.BaParm) = cpu2le16(*(USHORT *)(&Frame.BaParm));
|
||||
*(USHORT *) (&Frame.BaParm) =
|
||||
cpu2le16(*(USHORT *) (&Frame.BaParm));
|
||||
Frame.TimeOutValue = cpu2le16(Frame.TimeOutValue);
|
||||
Frame.BaStartSeq.word = cpu2le16(Frame.BaStartSeq.word);
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_ADDBA_REQ), &Frame,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_ADDBA_REQ), &Frame, END_OF_ARGS);
|
||||
|
||||
MiniportMMRequest(pAd, (MGMT_USE_QUEUE_FLAG | MapUserPriorityToAccessCategory[pInfo->TID]), pOutBuffer, FrameLen);
|
||||
MiniportMMRequest(pAd,
|
||||
(MGMT_USE_QUEUE_FLAG |
|
||||
MapUserPriorityToAccessCategory[pInfo->TID]),
|
||||
pOutBuffer, FrameLen);
|
||||
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n", Frame.BaStartSeq.field.StartSeq, FrameLen, Frame.BaParm.BufSize));
|
||||
}
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("BA - Send ADDBA request. StartSeq = %x, FrameLen = %ld. BufSize = %d\n",
|
||||
Frame.BaStartSeq.field.StartSeq, FrameLen,
|
||||
Frame.BaParm.BufSize));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -170,282 +188,271 @@ VOID MlmeADDBAAction(
|
|||
|
||||
==========================================================================
|
||||
*/
|
||||
VOID MlmeDELBAAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
VOID MlmeDELBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
MLME_DELBA_REQ_STRUCT *pInfo;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
PUCHAR pOutBuffer2 = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG Idx;
|
||||
FRAME_DELBA_REQ Frame;
|
||||
ULONG FrameLen;
|
||||
FRAME_BAR FrameBar;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
PUCHAR pOutBuffer2 = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG Idx;
|
||||
FRAME_DELBA_REQ Frame;
|
||||
ULONG FrameLen;
|
||||
FRAME_BAR FrameBar;
|
||||
|
||||
pInfo = (MLME_DELBA_REQ_STRUCT *)Elem->Msg;
|
||||
pInfo = (MLME_DELBA_REQ_STRUCT *) Elem->Msg;
|
||||
// must send back DELBA
|
||||
NdisZeroMemory(&Frame, sizeof(FRAME_DELBA_REQ));
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("==> MlmeDELBAAction(), Initiator(%d) \n", pInfo->Initiator));
|
||||
|
||||
if(MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen))
|
||||
{
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if(NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
|
||||
if (MlmeDelBAReqSanity(pAd, Elem->Msg, Elem->MsgLen)) {
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("BA - MlmeDELBAAction() allocate memory failed 1. \n"));
|
||||
return;
|
||||
}
|
||||
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
|
||||
if(NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer2); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("BA - MlmeDELBAAction() allocate memory failed 2. \n"));
|
||||
return;
|
||||
}
|
||||
|
||||
// SEND BAR (Send BAR to refresh peer reordering buffer.)
|
||||
Idx = pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
|
||||
Idx =
|
||||
pAd->MacTab.Content[pInfo->Wcid].BAOriWcidArray[pInfo->TID];
|
||||
|
||||
BarHeaderInit(pAd, &FrameBar, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress);
|
||||
BarHeaderInit(pAd, &FrameBar,
|
||||
pAd->MacTab.Content[pInfo->Wcid].Addr,
|
||||
pAd->CurrentAddress);
|
||||
|
||||
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.TID = pInfo->TID; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.ACKPolicy = IMMED_BA; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.Compressed = 1; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.MTID = 0; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.StartingSeq.field.StartSeq = pAd->MacTab.Content[pInfo->Wcid].TxSeq[pInfo->TID]; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.TID = pInfo->TID; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.ACKPolicy = IMMED_BA; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.Compressed = 1; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.MTID = 0; // make sure sequence not clear in DEL funciton.
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer2, &FrameLen,
|
||||
sizeof(FRAME_BAR), &FrameBar,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer2, &FrameLen,
|
||||
sizeof(FRAME_BAR), &FrameBar, END_OF_ARGS);
|
||||
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer2, FrameLen);
|
||||
MlmeFreeMemory(pAd, pOutBuffer2);
|
||||
DBGPRINT(RT_DEBUG_TRACE,("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("BA - MlmeDELBAAction() . Send BAR to refresh peer reordering buffer \n"));
|
||||
|
||||
// SEND DELBA FRAME
|
||||
FrameLen = 0;
|
||||
|
||||
{
|
||||
if (ADHOC_ON(pAd))
|
||||
ActHeaderInit(pAd, &Frame.Hdr, pAd->MacTab.Content[pInfo->Wcid].Addr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
|
||||
ActHeaderInit(pAd, &Frame.Hdr,
|
||||
pAd->MacTab.Content[pInfo->Wcid].
|
||||
Addr, pAd->CurrentAddress,
|
||||
pAd->CommonCfg.Bssid);
|
||||
else
|
||||
ActHeaderInit(pAd, &Frame.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAd->MacTab.Content[pInfo->Wcid].Addr);
|
||||
ActHeaderInit(pAd, &Frame.Hdr,
|
||||
pAd->CommonCfg.Bssid,
|
||||
pAd->CurrentAddress,
|
||||
pAd->MacTab.Content[pInfo->Wcid].
|
||||
Addr);
|
||||
}
|
||||
|
||||
Frame.Category = CATEGORY_BA;
|
||||
Frame.Action = DELBA;
|
||||
Frame.DelbaParm.Initiator = pInfo->Initiator;
|
||||
Frame.DelbaParm.TID = pInfo->TID;
|
||||
Frame.ReasonCode = 39; // Time Out
|
||||
*(USHORT *)(&Frame.DelbaParm) = cpu2le16(*(USHORT *)(&Frame.DelbaParm));
|
||||
Frame.ReasonCode = 39; // Time Out
|
||||
*(USHORT *) (&Frame.DelbaParm) =
|
||||
cpu2le16(*(USHORT *) (&Frame.DelbaParm));
|
||||
Frame.ReasonCode = cpu2le16(Frame.ReasonCode);
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_DELBA_REQ), &Frame,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_DELBA_REQ), &Frame, END_OF_ARGS);
|
||||
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n", pInfo->Initiator));
|
||||
}
|
||||
}
|
||||
|
||||
VOID MlmeQOSAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MlmeDLSAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MlmeInvalidAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
{
|
||||
//PUCHAR pOutBuffer = NULL;
|
||||
//Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11
|
||||
}
|
||||
|
||||
VOID PeerQOSAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID PeerBAAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
{
|
||||
UCHAR Action = Elem->Msg[LENGTH_802_11+1];
|
||||
|
||||
switch(Action)
|
||||
{
|
||||
case ADDBA_REQ:
|
||||
PeerAddBAReqAction(pAd,Elem);
|
||||
break;
|
||||
case ADDBA_RESP:
|
||||
PeerAddBARspAction(pAd,Elem);
|
||||
break;
|
||||
case DELBA:
|
||||
PeerDelBAAction(pAd,Elem);
|
||||
break;
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("BA - MlmeDELBAAction() . 3 DELBA sent. Initiator(%d)\n",
|
||||
pInfo->Initiator));
|
||||
}
|
||||
}
|
||||
|
||||
VOID PeerPublicAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
VOID MlmeQOSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MlmeDLSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MlmeInvalidAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
//PUCHAR pOutBuffer = NULL;
|
||||
//Return the receiving frame except the MSB of category filed set to 1. 7.3.1.11
|
||||
}
|
||||
|
||||
VOID PeerQOSAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
}
|
||||
|
||||
VOID PeerBAAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
UCHAR Action = Elem->Msg[LENGTH_802_11 + 1];
|
||||
|
||||
switch (Action) {
|
||||
case ADDBA_REQ:
|
||||
PeerAddBAReqAction(pAd, Elem);
|
||||
break;
|
||||
case ADDBA_RESP:
|
||||
PeerAddBARspAction(pAd, Elem);
|
||||
break;
|
||||
case DELBA:
|
||||
PeerDelBAAction(pAd, Elem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
VOID PeerPublicAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static VOID ReservedAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
static VOID ReservedAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
UCHAR Category;
|
||||
|
||||
if (Elem->MsgLen <= LENGTH_802_11)
|
||||
{
|
||||
if (Elem->MsgLen <= LENGTH_802_11) {
|
||||
return;
|
||||
}
|
||||
|
||||
Category = Elem->Msg[LENGTH_802_11];
|
||||
DBGPRINT(RT_DEBUG_TRACE,("Rcv reserved category(%d) Action Frame\n", Category));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("Rcv reserved category(%d) Action Frame\n", Category));
|
||||
hex_dump("Reserved Action Frame", &Elem->Msg[0], Elem->MsgLen);
|
||||
}
|
||||
|
||||
VOID PeerRMAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
|
||||
VOID PeerRMAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID respond_ht_information_exchange_action(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
static VOID respond_ht_information_exchange_action(IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG FrameLen;
|
||||
FRAME_HT_INFO HTINFOframe, *pFrame;
|
||||
UCHAR *pAddr;
|
||||
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG FrameLen;
|
||||
FRAME_HT_INFO HTINFOframe, *pFrame;
|
||||
UCHAR *pAddr;
|
||||
|
||||
// 2. Always send back ADDBA Response
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
|
||||
if (NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE,("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("ACTION - respond_ht_information_exchange_action() allocate memory failed \n"));
|
||||
return;
|
||||
}
|
||||
|
||||
// get RA
|
||||
pFrame = (FRAME_HT_INFO *) &Elem->Msg[0];
|
||||
pFrame = (FRAME_HT_INFO *) & Elem->Msg[0];
|
||||
pAddr = pFrame->Hdr.Addr2;
|
||||
|
||||
NdisZeroMemory(&HTINFOframe, sizeof(FRAME_HT_INFO));
|
||||
// 2-1. Prepare ADDBA Response frame.
|
||||
{
|
||||
if (ADHOC_ON(pAd))
|
||||
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr, pAd->CurrentAddress, pAd->CommonCfg.Bssid);
|
||||
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAddr,
|
||||
pAd->CurrentAddress,
|
||||
pAd->CommonCfg.Bssid);
|
||||
else
|
||||
ActHeaderInit(pAd, &HTINFOframe.Hdr, pAd->CommonCfg.Bssid, pAd->CurrentAddress, pAddr);
|
||||
ActHeaderInit(pAd, &HTINFOframe.Hdr,
|
||||
pAd->CommonCfg.Bssid, pAd->CurrentAddress,
|
||||
pAddr);
|
||||
}
|
||||
|
||||
HTINFOframe.Category = CATEGORY_HT;
|
||||
HTINFOframe.Action = HT_INFO_EXCHANGE;
|
||||
HTINFOframe.HT_Info.Request = 0;
|
||||
HTINFOframe.HT_Info.Forty_MHz_Intolerant = pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
|
||||
HTINFOframe.HT_Info.STA_Channel_Width = pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
|
||||
HTINFOframe.HT_Info.Forty_MHz_Intolerant =
|
||||
pAd->CommonCfg.HtCapability.HtCapInfo.Forty_Mhz_Intolerant;
|
||||
HTINFOframe.HT_Info.STA_Channel_Width =
|
||||
pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth;
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_HT_INFO), &HTINFOframe,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_HT_INFO), &HTINFOframe, END_OF_ARGS);
|
||||
|
||||
MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
}
|
||||
|
||||
VOID PeerHTAction(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MLME_QUEUE_ELEM *Elem)
|
||||
VOID PeerHTAction(IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM * Elem)
|
||||
{
|
||||
UCHAR Action = Elem->Msg[LENGTH_802_11+1];
|
||||
UCHAR Action = Elem->Msg[LENGTH_802_11 + 1];
|
||||
|
||||
if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
|
||||
return;
|
||||
|
||||
switch(Action)
|
||||
{
|
||||
case NOTIFY_BW_ACTION:
|
||||
DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Notify Channel bandwidth action----> \n"));
|
||||
|
||||
if(pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE)
|
||||
{
|
||||
// Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
|
||||
// sending BW_Notify Action frame, and cause us to linkup and linkdown.
|
||||
// In legacy mode, don't need to parse HT action frame.
|
||||
DBGPRINT(RT_DEBUG_TRACE,("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
|
||||
Elem->Msg[LENGTH_802_11+2] ));
|
||||
break;
|
||||
}
|
||||
|
||||
if (Elem->Msg[LENGTH_802_11+2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
|
||||
pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
|
||||
switch (Action) {
|
||||
case NOTIFY_BW_ACTION:
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("ACTION - HT Notify Channel bandwidth action----> \n"));
|
||||
|
||||
if (pAd->StaActive.SupportedPhyInfo.bHtEnable == FALSE) {
|
||||
// Note, this is to patch DIR-1353 AP. When the AP set to Wep, it will use legacy mode. But AP still keeps
|
||||
// sending BW_Notify Action frame, and cause us to linkup and linkdown.
|
||||
// In legacy mode, don't need to parse HT action frame.
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("ACTION -Ignore HT Notify Channel BW when link as legacy mode. BW = %d---> \n",
|
||||
Elem->Msg[LENGTH_802_11 + 2]));
|
||||
break;
|
||||
case SMPS_ACTION:
|
||||
// 7.3.1.25
|
||||
DBGPRINT(RT_DEBUG_TRACE,("ACTION - SMPS action----> \n"));
|
||||
if (((Elem->Msg[LENGTH_802_11+2]&0x1) == 0))
|
||||
{
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
|
||||
}
|
||||
else if (((Elem->Msg[LENGTH_802_11+2]&0x2) == 0))
|
||||
{
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
|
||||
}
|
||||
}
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE,("Aid(%d) MIMO PS = %d\n", Elem->Wcid, pAd->MacTab.Content[Elem->Wcid].MmpsMode));
|
||||
// rt2860c : add something for smps change.
|
||||
break;
|
||||
if (Elem->Msg[LENGTH_802_11 + 2] == 0) // 7.4.8.2. if value is 1, keep the same as supported channel bandwidth.
|
||||
pAd->MacTab.Content[Elem->Wcid].HTPhyMode.field.BW = 0;
|
||||
|
||||
case SETPCO_ACTION:
|
||||
break;
|
||||
case MIMO_CHA_MEASURE_ACTION:
|
||||
break;
|
||||
case HT_INFO_EXCHANGE:
|
||||
{
|
||||
HT_INFORMATION_OCTET *pHT_info;
|
||||
break;
|
||||
case SMPS_ACTION:
|
||||
// 7.3.1.25
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("ACTION - SMPS action----> \n"));
|
||||
if (((Elem->Msg[LENGTH_802_11 + 2] & 0x1) == 0)) {
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_ENABLE;
|
||||
} else if (((Elem->Msg[LENGTH_802_11 + 2] & 0x2) == 0)) {
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_STATIC;
|
||||
} else {
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode = MMPS_DYNAMIC;
|
||||
}
|
||||
|
||||
pHT_info = (HT_INFORMATION_OCTET *) &Elem->Msg[LENGTH_802_11+2];
|
||||
// 7.4.8.10
|
||||
DBGPRINT(RT_DEBUG_TRACE,("ACTION - HT Information Exchange action----> \n"));
|
||||
if (pHT_info->Request)
|
||||
{
|
||||
respond_ht_information_exchange_action(pAd, Elem);
|
||||
}
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("Aid(%d) MIMO PS = %d\n", Elem->Wcid,
|
||||
pAd->MacTab.Content[Elem->Wcid].MmpsMode));
|
||||
// rt2860c : add something for smps change.
|
||||
break;
|
||||
|
||||
case SETPCO_ACTION:
|
||||
break;
|
||||
case MIMO_CHA_MEASURE_ACTION:
|
||||
break;
|
||||
case HT_INFO_EXCHANGE:
|
||||
{
|
||||
HT_INFORMATION_OCTET *pHT_info;
|
||||
|
||||
pHT_info =
|
||||
(HT_INFORMATION_OCTET *) & Elem->Msg[LENGTH_802_11 +
|
||||
2];
|
||||
// 7.4.8.10
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("ACTION - HT Information Exchange action----> \n"));
|
||||
if (pHT_info->Request) {
|
||||
respond_ht_information_exchange_action(pAd,
|
||||
Elem);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -460,80 +467,79 @@ VOID PeerHTAction(
|
|||
FALSE , then continue indicaterx at this moment.
|
||||
==========================================================================
|
||||
*/
|
||||
VOID ORIBATimerTimeout(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
VOID ORIBATimerTimeout(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
MAC_TABLE_ENTRY *pEntry;
|
||||
INT i, total;
|
||||
UCHAR TID;
|
||||
MAC_TABLE_ENTRY *pEntry;
|
||||
INT i, total;
|
||||
UCHAR TID;
|
||||
|
||||
total = pAd->MacTab.Size * NUM_OF_TID;
|
||||
|
||||
for (i = 1; ((i <MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)) ; i++)
|
||||
{
|
||||
if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done)
|
||||
{
|
||||
pEntry = &pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].Wcid];
|
||||
for (i = 1; ((i < MAX_LEN_OF_BA_ORI_TABLE) && (total > 0)); i++) {
|
||||
if (pAd->BATable.BAOriEntry[i].ORI_BA_Status == Originator_Done) {
|
||||
pEntry =
|
||||
&pAd->MacTab.Content[pAd->BATable.BAOriEntry[i].
|
||||
Wcid];
|
||||
TID = pAd->BATable.BAOriEntry[i].TID;
|
||||
|
||||
ASSERT(pAd->BATable.BAOriEntry[i].Wcid < MAX_LEN_OF_MAC_TABLE);
|
||||
ASSERT(pAd->BATable.BAOriEntry[i].Wcid <
|
||||
MAX_LEN_OF_MAC_TABLE);
|
||||
}
|
||||
total --;
|
||||
total--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID SendRefreshBAR(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN MAC_TABLE_ENTRY *pEntry)
|
||||
VOID SendRefreshBAR(IN PRTMP_ADAPTER pAd, IN MAC_TABLE_ENTRY * pEntry)
|
||||
{
|
||||
FRAME_BAR FrameBar;
|
||||
ULONG FrameLen;
|
||||
NDIS_STATUS NStatus;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
USHORT Sequence;
|
||||
UCHAR i, TID;
|
||||
USHORT idx;
|
||||
BA_ORI_ENTRY *pBAEntry;
|
||||
FRAME_BAR FrameBar;
|
||||
ULONG FrameLen;
|
||||
NDIS_STATUS NStatus;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
USHORT Sequence;
|
||||
UCHAR i, TID;
|
||||
USHORT idx;
|
||||
BA_ORI_ENTRY *pBAEntry;
|
||||
|
||||
for (i = 0; i <NUM_OF_TID; i++)
|
||||
{
|
||||
for (i = 0; i < NUM_OF_TID; i++) {
|
||||
idx = pEntry->BAOriWcidArray[i];
|
||||
if (idx == 0)
|
||||
{
|
||||
if (idx == 0) {
|
||||
continue;
|
||||
}
|
||||
pBAEntry = &pAd->BATable.BAOriEntry[idx];
|
||||
|
||||
if (pBAEntry->ORI_BA_Status == Originator_Done)
|
||||
{
|
||||
if (pBAEntry->ORI_BA_Status == Originator_Done) {
|
||||
TID = pBAEntry->TID;
|
||||
|
||||
ASSERT(pBAEntry->Wcid < MAX_LEN_OF_MAC_TABLE);
|
||||
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if(NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR,("BA - MlmeADDBAAction() allocate memory failed \n"));
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("BA - MlmeADDBAAction() allocate memory failed \n"));
|
||||
return;
|
||||
}
|
||||
|
||||
Sequence = pEntry->TxSeq[TID];
|
||||
|
||||
BarHeaderInit(pAd, &FrameBar, pEntry->Addr, pAd->CurrentAddress);
|
||||
BarHeaderInit(pAd, &FrameBar, pEntry->Addr,
|
||||
pAd->CurrentAddress);
|
||||
|
||||
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
|
||||
FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.TID = TID; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.StartingSeq.field.FragNum = 0; // make sure sequence not clear in DEL function.
|
||||
FrameBar.StartingSeq.field.StartSeq = Sequence; // make sure sequence not clear in DEL funciton.
|
||||
FrameBar.BarControl.TID = TID; // make sure sequence not clear in DEL funciton.
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_BAR), &FrameBar,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(FRAME_BAR), &FrameBar,
|
||||
END_OF_ARGS);
|
||||
//if (!(CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_RALINK_CHIPSET)))
|
||||
if (1) // Now we always send BAR.
|
||||
{
|
||||
//MiniportMMRequestUnlock(pAd, 0, pOutBuffer, FrameLen);
|
||||
MiniportMMRequest(pAd, (MGMT_USE_QUEUE_FLAG | MapUserPriorityToAccessCategory[TID]), pOutBuffer, FrameLen);
|
||||
MiniportMMRequest(pAd,
|
||||
(MGMT_USE_QUEUE_FLAG |
|
||||
MapUserPriorityToAccessCategory
|
||||
[TID]), pOutBuffer,
|
||||
FrameLen);
|
||||
|
||||
}
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
|
@ -541,43 +547,36 @@ VOID SendRefreshBAR(
|
|||
}
|
||||
}
|
||||
|
||||
VOID ActHeaderInit(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PHEADER_802_11 pHdr80211,
|
||||
IN PUCHAR Addr1,
|
||||
IN PUCHAR Addr2,
|
||||
IN PUCHAR Addr3)
|
||||
VOID ActHeaderInit(IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PHEADER_802_11 pHdr80211,
|
||||
IN PUCHAR Addr1, IN PUCHAR Addr2, IN PUCHAR Addr3)
|
||||
{
|
||||
NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
|
||||
pHdr80211->FC.Type = BTYPE_MGMT;
|
||||
pHdr80211->FC.SubType = SUBTYPE_ACTION;
|
||||
NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
|
||||
pHdr80211->FC.Type = BTYPE_MGMT;
|
||||
pHdr80211->FC.SubType = SUBTYPE_ACTION;
|
||||
|
||||
COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
|
||||
COPY_MAC_ADDR(pHdr80211->Addr1, Addr1);
|
||||
COPY_MAC_ADDR(pHdr80211->Addr2, Addr2);
|
||||
COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
|
||||
COPY_MAC_ADDR(pHdr80211->Addr3, Addr3);
|
||||
}
|
||||
|
||||
VOID BarHeaderInit(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PFRAME_BAR pCntlBar,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pSA)
|
||||
VOID BarHeaderInit(IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PFRAME_BAR pCntlBar, IN PUCHAR pDA, IN PUCHAR pSA)
|
||||
{
|
||||
NdisZeroMemory(pCntlBar, sizeof(FRAME_BAR));
|
||||
pCntlBar->FC.Type = BTYPE_CNTL;
|
||||
pCntlBar->FC.SubType = SUBTYPE_BLOCK_ACK_REQ;
|
||||
pCntlBar->BarControl.MTID = 0;
|
||||
pCntlBar->BarControl.MTID = 0;
|
||||
pCntlBar->BarControl.Compressed = 1;
|
||||
pCntlBar->BarControl.ACKPolicy = 0;
|
||||
|
||||
|
||||
pCntlBar->Duration = 16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
|
||||
pCntlBar->Duration =
|
||||
16 + RTMPCalcDuration(pAd, RATE_1, sizeof(FRAME_BA));
|
||||
|
||||
COPY_MAC_ADDR(pCntlBar->Addr1, pDA);
|
||||
COPY_MAC_ADDR(pCntlBar->Addr2, pSA);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -592,19 +591,14 @@ VOID BarHeaderInit(
|
|||
Return : None.
|
||||
==========================================================================
|
||||
*/
|
||||
VOID InsertActField(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
OUT PUCHAR pFrameBuf,
|
||||
OUT PULONG pFrameLen,
|
||||
IN UINT8 Category,
|
||||
IN UINT8 ActCode)
|
||||
VOID InsertActField(IN PRTMP_ADAPTER pAd,
|
||||
OUT PUCHAR pFrameBuf,
|
||||
OUT PULONG pFrameLen, IN UINT8 Category, IN UINT8 ActCode)
|
||||
{
|
||||
ULONG TempLen;
|
||||
|
||||
MakeOutgoingFrame( pFrameBuf, &TempLen,
|
||||
1, &Category,
|
||||
1, &ActCode,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pFrameBuf, &TempLen,
|
||||
1, &Category, 1, &ActCode, END_OF_ARGS);
|
||||
|
||||
*pFrameLen = *pFrameLen + TempLen;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -35,50 +35,41 @@
|
|||
--------- ---------- ----------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
char* GetPhyMode(
|
||||
int Mode)
|
||||
char *GetPhyMode(int Mode)
|
||||
{
|
||||
switch(Mode)
|
||||
{
|
||||
case MODE_CCK:
|
||||
return "CCK";
|
||||
switch (Mode) {
|
||||
case MODE_CCK:
|
||||
return "CCK";
|
||||
|
||||
case MODE_OFDM:
|
||||
return "OFDM";
|
||||
case MODE_HTMIX:
|
||||
return "HTMIX";
|
||||
case MODE_OFDM:
|
||||
return "OFDM";
|
||||
case MODE_HTMIX:
|
||||
return "HTMIX";
|
||||
|
||||
case MODE_HTGREENFIELD:
|
||||
return "GREEN";
|
||||
default:
|
||||
return "N/A";
|
||||
case MODE_HTGREENFIELD:
|
||||
return "GREEN";
|
||||
default:
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char* GetBW(
|
||||
int BW)
|
||||
char *GetBW(int BW)
|
||||
{
|
||||
switch(BW)
|
||||
{
|
||||
case BW_10:
|
||||
return "10M";
|
||||
switch (BW) {
|
||||
case BW_10:
|
||||
return "10M";
|
||||
|
||||
case BW_20:
|
||||
return "20M";
|
||||
case BW_40:
|
||||
return "40M";
|
||||
default:
|
||||
return "N/A";
|
||||
case BW_20:
|
||||
return "20M";
|
||||
case BW_40:
|
||||
return "40M";
|
||||
default:
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -89,46 +80,37 @@ char* GetBW(
|
|||
TRUE if all parameters are OK, FALSE otherwise
|
||||
==========================================================================
|
||||
*/
|
||||
INT RT_CfgSetCountryRegion(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING arg,
|
||||
IN INT band)
|
||||
INT RT_CfgSetCountryRegion(IN PRTMP_ADAPTER pAd, IN PSTRING arg, IN INT band)
|
||||
{
|
||||
LONG region, regionMax;
|
||||
UCHAR *pCountryRegion;
|
||||
|
||||
region = simple_strtol(arg, 0, 10);
|
||||
|
||||
if (band == BAND_24G)
|
||||
{
|
||||
if (band == BAND_24G) {
|
||||
pCountryRegion = &pAd->CommonCfg.CountryRegion;
|
||||
regionMax = REGION_MAXIMUM_BG_BAND;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
pCountryRegion = &pAd->CommonCfg.CountryRegionForABand;
|
||||
regionMax = REGION_MAXIMUM_A_BAND;
|
||||
}
|
||||
|
||||
// TODO: Is it neccesay for following check???
|
||||
// Country can be set only when EEPROM not programmed
|
||||
if (*pCountryRegion & 0x80)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
|
||||
if (*pCountryRegion & 0x80) {
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("CfgSetCountryRegion():CountryRegion in eeprom was programmed\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND))
|
||||
{
|
||||
*pCountryRegion= (UCHAR) region;
|
||||
}
|
||||
else if ((region == REGION_31_BG_BAND) && (band == BAND_24G))
|
||||
{
|
||||
if ((region >= 0) && (region <= REGION_MAXIMUM_BG_BAND)) {
|
||||
*pCountryRegion = (UCHAR) region;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("CfgSetCountryRegion():region(%ld) out of range!\n", region));
|
||||
} else if ((region == REGION_31_BG_BAND) && (band == BAND_24G)) {
|
||||
*pCountryRegion = (UCHAR) region;
|
||||
} else {
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("CfgSetCountryRegion():region(%ld) out of range!\n",
|
||||
region));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -136,7 +118,6 @@ INT RT_CfgSetCountryRegion(
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -145,18 +126,15 @@ INT RT_CfgSetCountryRegion(
|
|||
TRUE if all parameters are OK, FALSE otherwise
|
||||
==========================================================================
|
||||
*/
|
||||
INT RT_CfgSetWirelessMode(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING arg)
|
||||
INT RT_CfgSetWirelessMode(IN PRTMP_ADAPTER pAd, IN PSTRING arg)
|
||||
{
|
||||
INT MaxPhyMode = PHY_11G;
|
||||
LONG WirelessMode;
|
||||
INT MaxPhyMode = PHY_11G;
|
||||
LONG WirelessMode;
|
||||
|
||||
MaxPhyMode = PHY_11N_5G;
|
||||
|
||||
WirelessMode = simple_strtol(arg, 0, 10);
|
||||
if (WirelessMode <= MaxPhyMode)
|
||||
{
|
||||
if (WirelessMode <= MaxPhyMode) {
|
||||
pAd->CommonCfg.PhyMode = WirelessMode;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -165,10 +143,7 @@ INT RT_CfgSetWirelessMode(
|
|||
|
||||
}
|
||||
|
||||
|
||||
INT RT_CfgSetShortSlot(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING arg)
|
||||
INT RT_CfgSetShortSlot(IN PRTMP_ADAPTER pAd, IN PSTRING arg)
|
||||
{
|
||||
LONG ShortSlot;
|
||||
|
||||
|
@ -179,12 +154,11 @@ INT RT_CfgSetShortSlot(
|
|||
else if (ShortSlot == 0)
|
||||
pAd->CommonCfg.bUseShortSlotTime = FALSE;
|
||||
else
|
||||
return FALSE; //Invalid argument
|
||||
return FALSE; //Invalid argument
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -193,54 +167,53 @@ INT RT_CfgSetShortSlot(
|
|||
TRUE if all parameters are OK, FALSE otherwise
|
||||
==========================================================================
|
||||
*/
|
||||
INT RT_CfgSetWepKey(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING keyString,
|
||||
IN CIPHER_KEY *pSharedKey,
|
||||
IN INT keyIdx)
|
||||
INT RT_CfgSetWepKey(IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING keyString,
|
||||
IN CIPHER_KEY * pSharedKey, IN INT keyIdx)
|
||||
{
|
||||
INT KeyLen;
|
||||
INT i;
|
||||
UCHAR CipherAlg = CIPHER_NONE;
|
||||
BOOLEAN bKeyIsHex = FALSE;
|
||||
INT KeyLen;
|
||||
INT i;
|
||||
UCHAR CipherAlg = CIPHER_NONE;
|
||||
BOOLEAN bKeyIsHex = FALSE;
|
||||
|
||||
// TODO: Shall we do memset for the original key info??
|
||||
memset(pSharedKey, 0, sizeof(CIPHER_KEY));
|
||||
KeyLen = strlen(keyString);
|
||||
switch (KeyLen)
|
||||
{
|
||||
case 5: //wep 40 Ascii type
|
||||
case 13: //wep 104 Ascii type
|
||||
bKeyIsHex = FALSE;
|
||||
pSharedKey->KeyLen = KeyLen;
|
||||
NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
|
||||
break;
|
||||
switch (KeyLen) {
|
||||
case 5: //wep 40 Ascii type
|
||||
case 13: //wep 104 Ascii type
|
||||
bKeyIsHex = FALSE;
|
||||
pSharedKey->KeyLen = KeyLen;
|
||||
NdisMoveMemory(pSharedKey->Key, keyString, KeyLen);
|
||||
break;
|
||||
|
||||
case 10: //wep 40 Hex type
|
||||
case 26: //wep 104 Hex type
|
||||
for(i=0; i < KeyLen; i++)
|
||||
{
|
||||
if( !isxdigit(*(keyString+i)) )
|
||||
return FALSE; //Not Hex value;
|
||||
}
|
||||
bKeyIsHex = TRUE;
|
||||
pSharedKey->KeyLen = KeyLen/2 ;
|
||||
AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
|
||||
break;
|
||||
case 10: //wep 40 Hex type
|
||||
case 26: //wep 104 Hex type
|
||||
for (i = 0; i < KeyLen; i++) {
|
||||
if (!isxdigit(*(keyString + i)))
|
||||
return FALSE; //Not Hex value;
|
||||
}
|
||||
bKeyIsHex = TRUE;
|
||||
pSharedKey->KeyLen = KeyLen / 2;
|
||||
AtoH(keyString, pSharedKey->Key, pSharedKey->KeyLen);
|
||||
break;
|
||||
|
||||
default: //Invalid argument
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n", keyIdx, keyString));
|
||||
return FALSE;
|
||||
default: //Invalid argument
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("RT_CfgSetWepKey(keyIdx=%d):Invalid argument (arg=%s)\n",
|
||||
keyIdx, keyString));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pSharedKey->CipherAlg = ((KeyLen % 5) ? CIPHER_WEP128 : CIPHER_WEP64);
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n",
|
||||
keyIdx, (bKeyIsHex == FALSE ? "Ascii" : "Hex"), CipherName[CipherAlg]));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("RT_CfgSetWepKey:(KeyIdx=%d,type=%s, Alg=%s)\n", keyIdx,
|
||||
(bKeyIsHex == FALSE ? "Ascii" : "Hex"),
|
||||
CipherName[CipherAlg]));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
Description:
|
||||
|
@ -257,33 +230,28 @@ INT RT_CfgSetWepKey(
|
|||
TRUE if all parameters are OK, FALSE otherwise
|
||||
==========================================================================
|
||||
*/
|
||||
INT RT_CfgSetWPAPSKKey(
|
||||
IN RTMP_ADAPTER *pAd,
|
||||
IN PSTRING keyString,
|
||||
IN UCHAR *pHashStr,
|
||||
IN INT hashStrLen,
|
||||
OUT PUCHAR pPMKBuf)
|
||||
INT RT_CfgSetWPAPSKKey(IN RTMP_ADAPTER * pAd,
|
||||
IN PSTRING keyString,
|
||||
IN UCHAR * pHashStr,
|
||||
IN INT hashStrLen, OUT PUCHAR pPMKBuf)
|
||||
{
|
||||
int keyLen;
|
||||
UCHAR keyMaterial[40];
|
||||
|
||||
keyLen = strlen(keyString);
|
||||
if ((keyLen < 8) || (keyLen > 64))
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
|
||||
keyLen, keyString));
|
||||
if ((keyLen < 8) || (keyLen > 64)) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("WPAPSK Key length(%d) error, required 8 ~ 64 characters!(keyStr=%s)\n",
|
||||
keyLen, keyString));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset(pPMKBuf, 0, 32);
|
||||
if (keyLen == 64)
|
||||
{
|
||||
AtoH(keyString, pPMKBuf, 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
|
||||
NdisMoveMemory(pPMKBuf, keyMaterial, 32);
|
||||
if (keyLen == 64) {
|
||||
AtoH(keyString, pPMKBuf, 32);
|
||||
} else {
|
||||
PasswordHash(keyString, pHashStr, hashStrLen, keyMaterial);
|
||||
NdisMoveMemory(pPMKBuf, keyMaterial, 32);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -37,46 +37,61 @@
|
|||
#include "../rt_config.h"
|
||||
|
||||
// 2.4 Ghz channel plan index in the TxPower arrays.
|
||||
#define BG_BAND_REGION_0_START 0 // 1,2,3,4,5,6,7,8,9,10,11
|
||||
#define BG_BAND_REGION_0_START 0 // 1,2,3,4,5,6,7,8,9,10,11
|
||||
#define BG_BAND_REGION_0_SIZE 11
|
||||
#define BG_BAND_REGION_1_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13
|
||||
#define BG_BAND_REGION_1_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13
|
||||
#define BG_BAND_REGION_1_SIZE 13
|
||||
#define BG_BAND_REGION_2_START 9 // 10,11
|
||||
#define BG_BAND_REGION_2_START 9 // 10,11
|
||||
#define BG_BAND_REGION_2_SIZE 2
|
||||
#define BG_BAND_REGION_3_START 9 // 10,11,12,13
|
||||
#define BG_BAND_REGION_3_START 9 // 10,11,12,13
|
||||
#define BG_BAND_REGION_3_SIZE 4
|
||||
#define BG_BAND_REGION_4_START 13 // 14
|
||||
#define BG_BAND_REGION_4_START 13 // 14
|
||||
#define BG_BAND_REGION_4_SIZE 1
|
||||
#define BG_BAND_REGION_5_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
#define BG_BAND_REGION_5_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
#define BG_BAND_REGION_5_SIZE 14
|
||||
#define BG_BAND_REGION_6_START 2 // 3,4,5,6,7,8,9
|
||||
#define BG_BAND_REGION_6_START 2 // 3,4,5,6,7,8,9
|
||||
#define BG_BAND_REGION_6_SIZE 7
|
||||
#define BG_BAND_REGION_7_START 4 // 5,6,7,8,9,10,11,12,13
|
||||
#define BG_BAND_REGION_7_START 4 // 5,6,7,8,9,10,11,12,13
|
||||
#define BG_BAND_REGION_7_SIZE 9
|
||||
#define BG_BAND_REGION_31_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
#define BG_BAND_REGION_31_START 0 // 1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
#define BG_BAND_REGION_31_SIZE 14
|
||||
|
||||
// 5 Ghz channel plan index in the TxPower arrays.
|
||||
UCHAR A_BAND_REGION_0_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165};
|
||||
UCHAR A_BAND_REGION_1_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
|
||||
UCHAR A_BAND_REGION_2_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64};
|
||||
UCHAR A_BAND_REGION_3_CHANNEL_LIST[]={52, 56, 60, 64, 149, 153, 157, 161};
|
||||
UCHAR A_BAND_REGION_4_CHANNEL_LIST[]={149, 153, 157, 161, 165};
|
||||
UCHAR A_BAND_REGION_5_CHANNEL_LIST[]={149, 153, 157, 161};
|
||||
UCHAR A_BAND_REGION_6_CHANNEL_LIST[]={36, 40, 44, 48};
|
||||
UCHAR A_BAND_REGION_7_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165, 169, 173};
|
||||
UCHAR A_BAND_REGION_8_CHANNEL_LIST[]={52, 56, 60, 64};
|
||||
UCHAR A_BAND_REGION_9_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165};
|
||||
UCHAR A_BAND_REGION_10_CHANNEL_LIST[]={36, 40, 44, 48, 149, 153, 157, 161, 165};
|
||||
UCHAR A_BAND_REGION_11_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153, 157, 161};
|
||||
UCHAR A_BAND_REGION_12_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
|
||||
UCHAR A_BAND_REGION_13_CHANNEL_LIST[]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161};
|
||||
UCHAR A_BAND_REGION_14_CHANNEL_LIST[]={36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165};
|
||||
UCHAR A_BAND_REGION_15_CHANNEL_LIST[]={149, 153, 157, 161, 165, 169, 173};
|
||||
|
||||
UCHAR A_BAND_REGION_0_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 };
|
||||
UCHAR A_BAND_REGION_1_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
|
||||
132, 136, 140 };
|
||||
UCHAR A_BAND_REGION_2_CHANNEL_LIST[] = { 36, 40, 44, 48, 52, 56, 60, 64 };
|
||||
UCHAR A_BAND_REGION_3_CHANNEL_LIST[] = { 52, 56, 60, 64, 149, 153, 157, 161 };
|
||||
UCHAR A_BAND_REGION_4_CHANNEL_LIST[] = { 149, 153, 157, 161, 165 };
|
||||
UCHAR A_BAND_REGION_5_CHANNEL_LIST[] = { 149, 153, 157, 161 };
|
||||
UCHAR A_BAND_REGION_6_CHANNEL_LIST[] = { 36, 40, 44, 48 };
|
||||
UCHAR A_BAND_REGION_7_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
|
||||
132, 136, 140, 149, 153, 157, 161, 165, 169, 173 };
|
||||
UCHAR A_BAND_REGION_8_CHANNEL_LIST[] = { 52, 56, 60, 64 };
|
||||
UCHAR A_BAND_REGION_9_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140,
|
||||
149, 153, 157, 161, 165 };
|
||||
UCHAR A_BAND_REGION_10_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 149, 153, 157, 161, 165 };
|
||||
UCHAR A_BAND_REGION_11_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 149, 153,
|
||||
157, 161 };
|
||||
UCHAR A_BAND_REGION_12_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
|
||||
132, 136, 140 };
|
||||
UCHAR A_BAND_REGION_13_CHANNEL_LIST[] =
|
||||
{ 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
|
||||
149, 153, 157, 161 };
|
||||
UCHAR A_BAND_REGION_14_CHANNEL_LIST[] =
|
||||
{ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149,
|
||||
153, 157, 161, 165 };
|
||||
UCHAR A_BAND_REGION_15_CHANNEL_LIST[] = { 149, 153, 157, 161, 165, 169, 173 };
|
||||
|
||||
//BaSizeArray follows the 802.11n definition as MaxRxFactor. 2^(13+factor) bytes. When factor =0, it's about Ba buffer size =8.
|
||||
UCHAR BaSizeArray[4] = {8,16,32,64};
|
||||
UCHAR BaSizeArray[4] = { 8, 16, 32, 64 };
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
|
@ -90,170 +105,243 @@ UCHAR BaSizeArray[4] = {8,16,32,64};
|
|||
|
||||
==========================================================================
|
||||
*/
|
||||
VOID BuildChannelList(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
VOID BuildChannelList(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UCHAR i, j, index=0, num=0;
|
||||
PUCHAR pChannelList = NULL;
|
||||
UCHAR i, j, index = 0, num = 0;
|
||||
PUCHAR pChannelList = NULL;
|
||||
|
||||
NdisZeroMemory(pAd->ChannelList, MAX_NUM_OF_CHANNELS * sizeof(CHANNEL_TX_POWER));
|
||||
NdisZeroMemory(pAd->ChannelList,
|
||||
MAX_NUM_OF_CHANNELS * sizeof(CHANNEL_TX_POWER));
|
||||
|
||||
// if not 11a-only mode, channel list starts from 2.4Ghz band
|
||||
if ((pAd->CommonCfg.PhyMode != PHY_11A)
|
||||
&& (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED) && (pAd->CommonCfg.PhyMode != PHY_11N_5G)
|
||||
)
|
||||
{
|
||||
switch (pAd->CommonCfg.CountryRegion & 0x7f)
|
||||
{
|
||||
case REGION_0_BG_BAND: // 1 -11
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_0_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_0_SIZE);
|
||||
index += BG_BAND_REGION_0_SIZE;
|
||||
break;
|
||||
case REGION_1_BG_BAND: // 1 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_1_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_1_SIZE);
|
||||
index += BG_BAND_REGION_1_SIZE;
|
||||
break;
|
||||
case REGION_2_BG_BAND: // 10 - 11
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_2_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_2_SIZE);
|
||||
index += BG_BAND_REGION_2_SIZE;
|
||||
break;
|
||||
case REGION_3_BG_BAND: // 10 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_3_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_3_SIZE);
|
||||
index += BG_BAND_REGION_3_SIZE;
|
||||
break;
|
||||
case REGION_4_BG_BAND: // 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_4_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_4_SIZE);
|
||||
index += BG_BAND_REGION_4_SIZE;
|
||||
break;
|
||||
case REGION_5_BG_BAND: // 1 - 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_5_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_5_SIZE);
|
||||
index += BG_BAND_REGION_5_SIZE;
|
||||
break;
|
||||
case REGION_6_BG_BAND: // 3 - 9
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_6_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_6_SIZE);
|
||||
index += BG_BAND_REGION_6_SIZE;
|
||||
break;
|
||||
case REGION_7_BG_BAND: // 5 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_7_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_7_SIZE);
|
||||
index += BG_BAND_REGION_7_SIZE;
|
||||
break;
|
||||
case REGION_31_BG_BAND: // 1 - 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index], &pAd->TxPower[BG_BAND_REGION_31_START], sizeof(CHANNEL_TX_POWER) * BG_BAND_REGION_31_SIZE);
|
||||
index += BG_BAND_REGION_31_SIZE;
|
||||
break;
|
||||
default: // Error. should never happen
|
||||
break;
|
||||
&& (pAd->CommonCfg.PhyMode != PHY_11AN_MIXED)
|
||||
&& (pAd->CommonCfg.PhyMode != PHY_11N_5G)
|
||||
) {
|
||||
switch (pAd->CommonCfg.CountryRegion & 0x7f) {
|
||||
case REGION_0_BG_BAND: // 1 -11
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_0_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_0_SIZE);
|
||||
index += BG_BAND_REGION_0_SIZE;
|
||||
break;
|
||||
case REGION_1_BG_BAND: // 1 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_1_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_1_SIZE);
|
||||
index += BG_BAND_REGION_1_SIZE;
|
||||
break;
|
||||
case REGION_2_BG_BAND: // 10 - 11
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_2_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_2_SIZE);
|
||||
index += BG_BAND_REGION_2_SIZE;
|
||||
break;
|
||||
case REGION_3_BG_BAND: // 10 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_3_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_3_SIZE);
|
||||
index += BG_BAND_REGION_3_SIZE;
|
||||
break;
|
||||
case REGION_4_BG_BAND: // 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_4_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_4_SIZE);
|
||||
index += BG_BAND_REGION_4_SIZE;
|
||||
break;
|
||||
case REGION_5_BG_BAND: // 1 - 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_5_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_5_SIZE);
|
||||
index += BG_BAND_REGION_5_SIZE;
|
||||
break;
|
||||
case REGION_6_BG_BAND: // 3 - 9
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_6_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_6_SIZE);
|
||||
index += BG_BAND_REGION_6_SIZE;
|
||||
break;
|
||||
case REGION_7_BG_BAND: // 5 - 13
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_7_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_7_SIZE);
|
||||
index += BG_BAND_REGION_7_SIZE;
|
||||
break;
|
||||
case REGION_31_BG_BAND: // 1 - 14
|
||||
NdisMoveMemory(&pAd->ChannelList[index],
|
||||
&pAd->TxPower[BG_BAND_REGION_31_START],
|
||||
sizeof(CHANNEL_TX_POWER) *
|
||||
BG_BAND_REGION_31_SIZE);
|
||||
index += BG_BAND_REGION_31_SIZE;
|
||||
break;
|
||||
default: // Error. should never happen
|
||||
break;
|
||||
}
|
||||
for (i=0; i<index; i++)
|
||||
for (i = 0; i < index; i++)
|
||||
pAd->ChannelList[i].MaxTxPwr = 20;
|
||||
}
|
||||
|
||||
if ((pAd->CommonCfg.PhyMode == PHY_11A) || (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)
|
||||
)
|
||||
{
|
||||
switch (pAd->CommonCfg.CountryRegionForABand & 0x7f)
|
||||
{
|
||||
case REGION_0_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_0_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_1_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_1_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_2_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_2_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_3_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_3_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_4_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_4_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_5_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_5_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_6_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_6_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_7_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_7_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_8_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_8_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_9_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_9_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
|
||||
break;
|
||||
if ((pAd->CommonCfg.PhyMode == PHY_11A)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11N_5G)
|
||||
) {
|
||||
switch (pAd->CommonCfg.CountryRegionForABand & 0x7f) {
|
||||
case REGION_0_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_0_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_0_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_1_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_1_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_1_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_2_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_2_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_2_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_3_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_3_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_3_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_4_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_4_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_4_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_5_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_5_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_5_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_6_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_6_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_6_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_7_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_7_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_7_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_8_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_8_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_8_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_9_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_9_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_9_CHANNEL_LIST;
|
||||
break;
|
||||
|
||||
case REGION_10_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_10_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_10_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_10_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_10_CHANNEL_LIST;
|
||||
break;
|
||||
|
||||
case REGION_11_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_11_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_12_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_12_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_13_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_13_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_14_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_14_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_15_A_BAND:
|
||||
num = sizeof(A_BAND_REGION_15_CHANNEL_LIST)/sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_15_CHANNEL_LIST;
|
||||
break;
|
||||
default: // Error. should never happen
|
||||
DBGPRINT(RT_DEBUG_WARN,("countryregion=%d not support", pAd->CommonCfg.CountryRegionForABand));
|
||||
break;
|
||||
case REGION_11_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_11_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_11_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_12_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_12_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_12_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_13_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_13_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_13_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_14_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_14_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_14_CHANNEL_LIST;
|
||||
break;
|
||||
case REGION_15_A_BAND:
|
||||
num =
|
||||
sizeof(A_BAND_REGION_15_CHANNEL_LIST) /
|
||||
sizeof(UCHAR);
|
||||
pChannelList = A_BAND_REGION_15_CHANNEL_LIST;
|
||||
break;
|
||||
default: // Error. should never happen
|
||||
DBGPRINT(RT_DEBUG_WARN,
|
||||
("countryregion=%d not support",
|
||||
pAd->CommonCfg.CountryRegionForABand));
|
||||
break;
|
||||
}
|
||||
|
||||
if (num != 0)
|
||||
{
|
||||
UCHAR RadarCh[15]={52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140};
|
||||
for (i=0; i<num; i++)
|
||||
{
|
||||
for (j=0; j<MAX_NUM_OF_CHANNELS; j++)
|
||||
{
|
||||
if (pChannelList[i] == pAd->TxPower[j].Channel)
|
||||
NdisMoveMemory(&pAd->ChannelList[index+i], &pAd->TxPower[j], sizeof(CHANNEL_TX_POWER));
|
||||
}
|
||||
for (j=0; j<15; j++)
|
||||
{
|
||||
if (pChannelList[i] == RadarCh[j])
|
||||
pAd->ChannelList[index+i].DfsReq = TRUE;
|
||||
if (num != 0) {
|
||||
UCHAR RadarCh[15] =
|
||||
{ 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124,
|
||||
128, 132, 136, 140 };
|
||||
for (i = 0; i < num; i++) {
|
||||
for (j = 0; j < MAX_NUM_OF_CHANNELS; j++) {
|
||||
if (pChannelList[i] ==
|
||||
pAd->TxPower[j].Channel)
|
||||
NdisMoveMemory(&pAd->
|
||||
ChannelList[index
|
||||
+ i],
|
||||
&pAd->TxPower[j],
|
||||
sizeof
|
||||
(CHANNEL_TX_POWER));
|
||||
}
|
||||
pAd->ChannelList[index+i].MaxTxPwr = 20;
|
||||
for (j = 0; j < 15; j++) {
|
||||
if (pChannelList[i] == RadarCh[j])
|
||||
pAd->ChannelList[index +
|
||||
i].DfsReq =
|
||||
TRUE;
|
||||
}
|
||||
pAd->ChannelList[index + i].MaxTxPwr = 20;
|
||||
}
|
||||
index += num;
|
||||
}
|
||||
}
|
||||
|
||||
pAd->ChannelListNum = index;
|
||||
DBGPRINT(RT_DEBUG_TRACE,("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
|
||||
pAd->CommonCfg.CountryRegion, pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType, pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("country code=%d/%d, RFIC=%d, PHY mode=%d, support %d channels\n",
|
||||
pAd->CommonCfg.CountryRegion,
|
||||
pAd->CommonCfg.CountryRegionForABand, pAd->RfIcType,
|
||||
pAd->CommonCfg.PhyMode, pAd->ChannelListNum));
|
||||
#ifdef DBG
|
||||
for (i=0;i<pAd->ChannelListNum;i++)
|
||||
{
|
||||
DBGPRINT_RAW(RT_DEBUG_TRACE,("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ", pAd->ChannelList[i].Channel, pAd->ChannelList[i].Power, pAd->ChannelList[i].Power2));
|
||||
for (i = 0; i < pAd->ChannelListNum; i++) {
|
||||
DBGPRINT_RAW(RT_DEBUG_TRACE,
|
||||
("BuildChannel # %d :: Pwr0 = %d, Pwr1 =%d, \n ",
|
||||
pAd->ChannelList[i].Channel,
|
||||
pAd->ChannelList[i].Power,
|
||||
pAd->ChannelList[i].Power2));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -271,8 +359,7 @@ VOID BuildChannelList(
|
|||
|
||||
==========================================================================
|
||||
*/
|
||||
UCHAR FirstChannel(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
UCHAR FirstChannel(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
return pAd->ChannelList[0].Channel;
|
||||
}
|
||||
|
@ -288,19 +375,16 @@ UCHAR FirstChannel(
|
|||
return 0 if no more next channel
|
||||
==========================================================================
|
||||
*/
|
||||
UCHAR NextChannel(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR channel)
|
||||
UCHAR NextChannel(IN PRTMP_ADAPTER pAd, IN UCHAR channel)
|
||||
{
|
||||
int i;
|
||||
UCHAR next_channel = 0;
|
||||
|
||||
for (i = 0; i < (pAd->ChannelListNum - 1); i++)
|
||||
if (channel == pAd->ChannelList[i].Channel)
|
||||
{
|
||||
next_channel = pAd->ChannelList[i+1].Channel;
|
||||
if (channel == pAd->ChannelList[i].Channel) {
|
||||
next_channel = pAd->ChannelList[i + 1].Channel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return next_channel;
|
||||
}
|
||||
|
||||
|
@ -324,16 +408,15 @@ UCHAR NextChannel(
|
|||
the minimum value or next lower value.
|
||||
==========================================================================
|
||||
*/
|
||||
VOID ChangeToCellPowerLimit(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR AironetCellPowerLimit)
|
||||
VOID ChangeToCellPowerLimit(IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR AironetCellPowerLimit)
|
||||
{
|
||||
//valud 0xFF means that hasn't found power limit information
|
||||
//from the AP's Beacon/Probe response.
|
||||
if (AironetCellPowerLimit == 0xFF)
|
||||
return;
|
||||
|
||||
if (AironetCellPowerLimit < 6) //Used Lowest Power Percentage.
|
||||
if (AironetCellPowerLimit < 6) //Used Lowest Power Percentage.
|
||||
pAd->CommonCfg.TxPowerPercentage = 6;
|
||||
else if (AironetCellPowerLimit < 9)
|
||||
pAd->CommonCfg.TxPowerPercentage = 10;
|
||||
|
@ -344,45 +427,40 @@ VOID ChangeToCellPowerLimit(
|
|||
else if (AironetCellPowerLimit < 15)
|
||||
pAd->CommonCfg.TxPowerPercentage = 75;
|
||||
else
|
||||
pAd->CommonCfg.TxPowerPercentage = 100; //else used maximum
|
||||
pAd->CommonCfg.TxPowerPercentage = 100; //else used maximum
|
||||
|
||||
if (pAd->CommonCfg.TxPowerPercentage > pAd->CommonCfg.TxPowerDefault)
|
||||
pAd->CommonCfg.TxPowerPercentage = pAd->CommonCfg.TxPowerDefault;
|
||||
pAd->CommonCfg.TxPowerPercentage =
|
||||
pAd->CommonCfg.TxPowerDefault;
|
||||
|
||||
}
|
||||
|
||||
CHAR ConvertToRssi(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN CHAR Rssi,
|
||||
IN UCHAR RssiNumber)
|
||||
CHAR ConvertToRssi(IN PRTMP_ADAPTER pAd, IN CHAR Rssi, IN UCHAR RssiNumber)
|
||||
{
|
||||
UCHAR RssiOffset, LNAGain;
|
||||
UCHAR RssiOffset, LNAGain;
|
||||
|
||||
// Rssi equals to zero should be an invalid value
|
||||
if (Rssi == 0)
|
||||
return -99;
|
||||
|
||||
LNAGain = GET_LNA_GAIN(pAd);
|
||||
if (pAd->LatchRfRegs.Channel > 14)
|
||||
{
|
||||
if (RssiNumber == 0)
|
||||
if (pAd->LatchRfRegs.Channel > 14) {
|
||||
if (RssiNumber == 0)
|
||||
RssiOffset = pAd->ARssiOffset0;
|
||||
else if (RssiNumber == 1)
|
||||
RssiOffset = pAd->ARssiOffset1;
|
||||
else
|
||||
RssiOffset = pAd->ARssiOffset2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RssiNumber == 0)
|
||||
} else {
|
||||
if (RssiNumber == 0)
|
||||
RssiOffset = pAd->BGRssiOffset0;
|
||||
else if (RssiNumber == 1)
|
||||
RssiOffset = pAd->BGRssiOffset1;
|
||||
else
|
||||
RssiOffset = pAd->BGRssiOffset2;
|
||||
}
|
||||
}
|
||||
|
||||
return (-12 - RssiOffset - LNAGain - Rssi);
|
||||
return (-12 - RssiOffset - LNAGain - Rssi);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -391,44 +469,44 @@ CHAR ConvertToRssi(
|
|||
Scan next channel
|
||||
==========================================================================
|
||||
*/
|
||||
VOID ScanNextChannel(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
VOID ScanNextChannel(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
HEADER_802_11 Hdr80211;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG FrameLen = 0;
|
||||
UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
|
||||
USHORT Status;
|
||||
PHEADER_802_11 pHdr80211;
|
||||
UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
|
||||
HEADER_802_11 Hdr80211;
|
||||
PUCHAR pOutBuffer = NULL;
|
||||
NDIS_STATUS NStatus;
|
||||
ULONG FrameLen = 0;
|
||||
UCHAR SsidLen = 0, ScanType = pAd->MlmeAux.ScanType, BBPValue = 0;
|
||||
USHORT Status;
|
||||
PHEADER_802_11 pHdr80211;
|
||||
UINT ScanTimeIn5gChannel = SHORT_CHANNEL_TIME;
|
||||
|
||||
{
|
||||
if (MONITOR_ON(pAd))
|
||||
return;
|
||||
if (MONITOR_ON(pAd))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (pAd->MlmeAux.Channel == 0)
|
||||
{
|
||||
if (pAd->MlmeAux.Channel == 0) {
|
||||
if ((pAd->CommonCfg.BBPCurrentBW == BW_40)
|
||||
&& (INFRA_ON(pAd)
|
||||
|| (pAd->OpMode == OPMODE_AP))
|
||||
)
|
||||
{
|
||||
AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel, FALSE);
|
||||
&& (INFRA_ON(pAd)
|
||||
|| (pAd->OpMode == OPMODE_AP))
|
||||
) {
|
||||
AsicSwitchChannel(pAd, pAd->CommonCfg.CentralChannel,
|
||||
FALSE);
|
||||
AsicLockChannel(pAd, pAd->CommonCfg.CentralChannel);
|
||||
RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R4, &BBPValue);
|
||||
BBPValue &= (~0x18);
|
||||
BBPValue |= 0x10;
|
||||
RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R4, BBPValue);
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",pAd->CommonCfg.CentralChannel, pAd->ScanTab.BssNr));
|
||||
}
|
||||
else
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("SYNC - End of SCAN, restore to 40MHz channel %d, Total BSS[%02d]\n",
|
||||
pAd->CommonCfg.CentralChannel,
|
||||
pAd->ScanTab.BssNr));
|
||||
} else {
|
||||
AsicSwitchChannel(pAd, pAd->CommonCfg.Channel, FALSE);
|
||||
AsicLockChannel(pAd, pAd->CommonCfg.Channel);
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("SYNC - End of SCAN, restore to channel %d, Total BSS[%02d]\n",
|
||||
pAd->CommonCfg.Channel, pAd->ScanTab.BssNr));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -437,20 +515,29 @@ VOID ScanNextChannel(
|
|||
// Send an NULL data with turned PSM bit on to current associated AP before SCAN progress.
|
||||
// Now, we need to send an NULL data with turned PSM bit off to AP, when scan progress done
|
||||
//
|
||||
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED) && (INFRA_ON(pAd)))
|
||||
{
|
||||
NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer);
|
||||
if (NStatus == NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
if (OPSTATUS_TEST_FLAG
|
||||
(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED)
|
||||
&& (INFRA_ON(pAd))) {
|
||||
NStatus =
|
||||
MlmeAllocateMemory(pAd,
|
||||
(PVOID) & pOutBuffer);
|
||||
if (NStatus == NDIS_STATUS_SUCCESS) {
|
||||
pHdr80211 = (PHEADER_802_11) pOutBuffer;
|
||||
MgtMacHeaderInit(pAd, pHdr80211, SUBTYPE_NULL_FUNC, 1, pAd->CommonCfg.Bssid, pAd->CommonCfg.Bssid);
|
||||
MgtMacHeaderInit(pAd, pHdr80211,
|
||||
SUBTYPE_NULL_FUNC, 1,
|
||||
pAd->CommonCfg.Bssid,
|
||||
pAd->CommonCfg.Bssid);
|
||||
pHdr80211->Duration = 0;
|
||||
pHdr80211->FC.Type = BTYPE_DATA;
|
||||
pHdr80211->FC.PwrMgmt = (pAd->StaCfg.Psm == PWR_SAVE);
|
||||
pHdr80211->FC.PwrMgmt =
|
||||
(pAd->StaCfg.Psm == PWR_SAVE);
|
||||
|
||||
// Send using priority queue
|
||||
MiniportMMRequest(pAd, 0, pOutBuffer, sizeof(HEADER_802_11));
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("MlmeScanReqAction -- Send PSM Data frame\n"));
|
||||
MiniportMMRequest(pAd, 0, pOutBuffer,
|
||||
sizeof
|
||||
(HEADER_802_11));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("MlmeScanReqAction -- Send PSM Data frame\n"));
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
RTMPusecDelay(5000);
|
||||
}
|
||||
|
@ -458,25 +545,24 @@ VOID ScanNextChannel(
|
|||
|
||||
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
|
||||
Status = MLME_SUCCESS;
|
||||
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
|
||||
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF,
|
||||
2, &Status);
|
||||
}
|
||||
|
||||
|
||||
RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS);
|
||||
}
|
||||
#ifdef RTMP_MAC_USB
|
||||
else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) && (pAd->OpMode == OPMODE_STA))
|
||||
{
|
||||
else if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)
|
||||
&& (pAd->OpMode == OPMODE_STA)) {
|
||||
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
|
||||
MlmeCntlConfirm(pAd, MT2_SCAN_CONF, MLME_FAIL_NO_RESOURCE);
|
||||
}
|
||||
#endif // RTMP_MAC_USB //
|
||||
else
|
||||
{
|
||||
else {
|
||||
{
|
||||
// BBP and RF are not accessible in PS mode, we has to wake them up first
|
||||
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
|
||||
AsicForceWakeup(pAd, TRUE);
|
||||
// BBP and RF are not accessible in PS mode, we has to wake them up first
|
||||
if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE))
|
||||
AsicForceWakeup(pAd, TRUE);
|
||||
|
||||
// leave PSM during scanning. otherwise we may lost ProbeRsp & BEACON
|
||||
if (pAd->StaCfg.Psm == PWR_SAVE)
|
||||
|
@ -487,10 +573,11 @@ VOID ScanNextChannel(
|
|||
AsicLockChannel(pAd, pAd->MlmeAux.Channel);
|
||||
|
||||
{
|
||||
if (pAd->MlmeAux.Channel > 14)
|
||||
{
|
||||
if ((pAd->CommonCfg.bIEEE80211H == 1) && RadarChannelCheck(pAd, pAd->MlmeAux.Channel))
|
||||
{
|
||||
if (pAd->MlmeAux.Channel > 14) {
|
||||
if ((pAd->CommonCfg.bIEEE80211H == 1)
|
||||
&& RadarChannelCheck(pAd,
|
||||
pAd->MlmeAux.
|
||||
Channel)) {
|
||||
ScanType = SCAN_PASSIVE;
|
||||
ScanTimeIn5gChannel = MIN_CHANNEL_TIME;
|
||||
}
|
||||
|
@ -498,103 +585,108 @@ VOID ScanNextChannel(
|
|||
}
|
||||
|
||||
//Global country domain(ch1-11:active scan, ch12-14 passive scan)
|
||||
if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12) && ((pAd->CommonCfg.CountryRegion & 0x7f) == REGION_31_BG_BAND))
|
||||
{
|
||||
if ((pAd->MlmeAux.Channel <= 14) && (pAd->MlmeAux.Channel >= 12)
|
||||
&& ((pAd->CommonCfg.CountryRegion & 0x7f) ==
|
||||
REGION_31_BG_BAND)) {
|
||||
ScanType = SCAN_PASSIVE;
|
||||
}
|
||||
|
||||
// We need to shorten active scan time in order for WZC connect issue
|
||||
// Chnage the channel scan time for CISCO stuff based on its IAPP announcement
|
||||
if (ScanType == FAST_SCAN_ACTIVE)
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, FAST_ACTIVE_SCAN_TIME);
|
||||
else // must be SCAN_PASSIVE or SCAN_ACTIVE
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
|
||||
FAST_ACTIVE_SCAN_TIME);
|
||||
else // must be SCAN_PASSIVE or SCAN_ACTIVE
|
||||
{
|
||||
if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
|
||||
)
|
||||
{
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED)
|
||||
|| (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED)
|
||||
) {
|
||||
if (pAd->MlmeAux.Channel > 14)
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, ScanTimeIn5gChannel);
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
|
||||
ScanTimeIn5gChannel);
|
||||
else
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MIN_CHANNEL_TIME);
|
||||
}
|
||||
else
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer, MAX_CHANNEL_TIME);
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
|
||||
MIN_CHANNEL_TIME);
|
||||
} else
|
||||
RTMPSetTimer(&pAd->MlmeAux.ScanTimer,
|
||||
MAX_CHANNEL_TIME);
|
||||
}
|
||||
|
||||
if ((ScanType == SCAN_ACTIVE)
|
||||
|| (ScanType == FAST_SCAN_ACTIVE)
|
||||
)
|
||||
{
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("SYNC - ScanNextChannel() allocate memory fail\n"));
|
||||
|| (ScanType == FAST_SCAN_ACTIVE)
|
||||
) {
|
||||
NStatus = MlmeAllocateMemory(pAd, &pOutBuffer); //Get an unused nonpaged memory
|
||||
if (NStatus != NDIS_STATUS_SUCCESS) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("SYNC - ScanNextChannel() allocate memory fail\n"));
|
||||
|
||||
{
|
||||
pAd->Mlme.SyncMachine.CurrState = SYNC_IDLE;
|
||||
pAd->Mlme.SyncMachine.CurrState =
|
||||
SYNC_IDLE;
|
||||
Status = MLME_FAIL_NO_RESOURCE;
|
||||
MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_SCAN_CONF, 2, &Status);
|
||||
MlmeEnqueue(pAd,
|
||||
MLME_CNTL_STATE_MACHINE,
|
||||
MT2_SCAN_CONF, 2, &Status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// There is no need to send broadcast probe request if active scan is in effect.
|
||||
if ((ScanType == SCAN_ACTIVE) || (ScanType == FAST_SCAN_ACTIVE)
|
||||
)
|
||||
if ((ScanType == SCAN_ACTIVE)
|
||||
|| (ScanType == FAST_SCAN_ACTIVE)
|
||||
)
|
||||
SsidLen = pAd->MlmeAux.SsidLen;
|
||||
else
|
||||
SsidLen = 0;
|
||||
|
||||
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0, BROADCAST_ADDR, BROADCAST_ADDR);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(HEADER_802_11), &Hdr80211,
|
||||
1, &SsidIe,
|
||||
1, &SsidLen,
|
||||
SsidLen, pAd->MlmeAux.Ssid,
|
||||
1, &SupRateIe,
|
||||
1, &pAd->CommonCfg.SupRateLen,
|
||||
pAd->CommonCfg.SupRateLen, pAd->CommonCfg.SupRate,
|
||||
END_OF_ARGS);
|
||||
MgtMacHeaderInit(pAd, &Hdr80211, SUBTYPE_PROBE_REQ, 0,
|
||||
BROADCAST_ADDR, BROADCAST_ADDR);
|
||||
MakeOutgoingFrame(pOutBuffer, &FrameLen,
|
||||
sizeof(HEADER_802_11), &Hdr80211, 1,
|
||||
&SsidIe, 1, &SsidLen, SsidLen,
|
||||
pAd->MlmeAux.Ssid, 1, &SupRateIe, 1,
|
||||
&pAd->CommonCfg.SupRateLen,
|
||||
pAd->CommonCfg.SupRateLen,
|
||||
pAd->CommonCfg.SupRate, END_OF_ARGS);
|
||||
|
||||
if (pAd->CommonCfg.ExtRateLen)
|
||||
{
|
||||
if (pAd->CommonCfg.ExtRateLen) {
|
||||
ULONG Tmp;
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
|
||||
1, &ExtRateIe,
|
||||
1, &pAd->CommonCfg.ExtRateLen,
|
||||
pAd->CommonCfg.ExtRateLen, pAd->CommonCfg.ExtRate,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
|
||||
1, &ExtRateIe,
|
||||
1, &pAd->CommonCfg.ExtRateLen,
|
||||
pAd->CommonCfg.ExtRateLen,
|
||||
pAd->CommonCfg.ExtRate,
|
||||
END_OF_ARGS);
|
||||
FrameLen += Tmp;
|
||||
}
|
||||
|
||||
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED)
|
||||
{
|
||||
ULONG Tmp;
|
||||
UCHAR HtLen;
|
||||
UCHAR BROADCOM[4] = {0x0, 0x90, 0x4c, 0x33};
|
||||
if (pAd->CommonCfg.PhyMode >= PHY_11ABGN_MIXED) {
|
||||
ULONG Tmp;
|
||||
UCHAR HtLen;
|
||||
UCHAR BROADCOM[4] = { 0x0, 0x90, 0x4c, 0x33 };
|
||||
|
||||
if (pAd->bBroadComHT == TRUE)
|
||||
{
|
||||
HtLen = pAd->MlmeAux.HtCapabilityLen + 4;
|
||||
if (pAd->bBroadComHT == TRUE) {
|
||||
HtLen =
|
||||
pAd->MlmeAux.HtCapabilityLen + 4;
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
|
||||
1, &WpaIe,
|
||||
1, &HtLen,
|
||||
4, &BROADCOM[0],
|
||||
pAd->MlmeAux.HtCapabilityLen, &pAd->MlmeAux.HtCapability,
|
||||
END_OF_ARGS);
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen,
|
||||
&Tmp, 1, &WpaIe, 1,
|
||||
&HtLen, 4,
|
||||
&BROADCOM[0],
|
||||
pAd->MlmeAux.
|
||||
HtCapabilityLen,
|
||||
&pAd->MlmeAux.
|
||||
HtCapability,
|
||||
END_OF_ARGS);
|
||||
} else {
|
||||
HtLen = pAd->MlmeAux.HtCapabilityLen;
|
||||
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen, &Tmp,
|
||||
1, &HtCapIe,
|
||||
1, &HtLen,
|
||||
HtLen, &pAd->CommonCfg.HtCapability,
|
||||
END_OF_ARGS);
|
||||
MakeOutgoingFrame(pOutBuffer + FrameLen,
|
||||
&Tmp, 1, &HtCapIe, 1,
|
||||
&HtLen, HtLen,
|
||||
&pAd->CommonCfg.
|
||||
HtCapability,
|
||||
END_OF_ARGS);
|
||||
}
|
||||
FrameLen += Tmp;
|
||||
}
|
||||
|
@ -602,20 +694,16 @@ VOID ScanNextChannel(
|
|||
MiniportMMRequest(pAd, 0, pOutBuffer, FrameLen);
|
||||
MlmeFreeMemory(pAd, pOutBuffer);
|
||||
}
|
||||
|
||||
// For SCAN_CISCO_PASSIVE, do nothing and silently wait for beacon or other probe reponse
|
||||
|
||||
pAd->Mlme.SyncMachine.CurrState = SCAN_LISTEN;
|
||||
}
|
||||
}
|
||||
|
||||
VOID MgtProbReqMacHeaderInit(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PHEADER_802_11 pHdr80211,
|
||||
IN UCHAR SubType,
|
||||
IN UCHAR ToDs,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pBssid)
|
||||
VOID MgtProbReqMacHeaderInit(IN PRTMP_ADAPTER pAd,
|
||||
IN OUT PHEADER_802_11 pHdr80211,
|
||||
IN UCHAR SubType,
|
||||
IN UCHAR ToDs, IN PUCHAR pDA, IN PUCHAR pBssid)
|
||||
{
|
||||
NdisZeroMemory(pHdr80211, sizeof(HEADER_802_11));
|
||||
|
||||
|
@ -628,5 +716,3 @@ VOID MgtProbReqMacHeaderInit(
|
|||
COPY_MAC_ADDR(pHdr80211->Addr2, pAd->CurrentAddress);
|
||||
COPY_MAC_ADDR(pHdr80211->Addr3, pBssid);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,109 +42,101 @@
|
|||
( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) )
|
||||
#define ROR32( A, n ) ROL32( (A), 32-(n) )
|
||||
|
||||
UINT Tkip_Sbox_Lower[256] =
|
||||
{
|
||||
0xA5,0x84,0x99,0x8D,0x0D,0xBD,0xB1,0x54,
|
||||
0x50,0x03,0xA9,0x7D,0x19,0x62,0xE6,0x9A,
|
||||
0x45,0x9D,0x40,0x87,0x15,0xEB,0xC9,0x0B,
|
||||
0xEC,0x67,0xFD,0xEA,0xBF,0xF7,0x96,0x5B,
|
||||
0xC2,0x1C,0xAE,0x6A,0x5A,0x41,0x02,0x4F,
|
||||
0x5C,0xF4,0x34,0x08,0x93,0x73,0x53,0x3F,
|
||||
0x0C,0x52,0x65,0x5E,0x28,0xA1,0x0F,0xB5,
|
||||
0x09,0x36,0x9B,0x3D,0x26,0x69,0xCD,0x9F,
|
||||
0x1B,0x9E,0x74,0x2E,0x2D,0xB2,0xEE,0xFB,
|
||||
0xF6,0x4D,0x61,0xCE,0x7B,0x3E,0x71,0x97,
|
||||
0xF5,0x68,0x00,0x2C,0x60,0x1F,0xC8,0xED,
|
||||
0xBE,0x46,0xD9,0x4B,0xDE,0xD4,0xE8,0x4A,
|
||||
0x6B,0x2A,0xE5,0x16,0xC5,0xD7,0x55,0x94,
|
||||
0xCF,0x10,0x06,0x81,0xF0,0x44,0xBA,0xE3,
|
||||
0xF3,0xFE,0xC0,0x8A,0xAD,0xBC,0x48,0x04,
|
||||
0xDF,0xC1,0x75,0x63,0x30,0x1A,0x0E,0x6D,
|
||||
0x4C,0x14,0x35,0x2F,0xE1,0xA2,0xCC,0x39,
|
||||
0x57,0xF2,0x82,0x47,0xAC,0xE7,0x2B,0x95,
|
||||
0xA0,0x98,0xD1,0x7F,0x66,0x7E,0xAB,0x83,
|
||||
0xCA,0x29,0xD3,0x3C,0x79,0xE2,0x1D,0x76,
|
||||
0x3B,0x56,0x4E,0x1E,0xDB,0x0A,0x6C,0xE4,
|
||||
0x5D,0x6E,0xEF,0xA6,0xA8,0xA4,0x37,0x8B,
|
||||
0x32,0x43,0x59,0xB7,0x8C,0x64,0xD2,0xE0,
|
||||
0xB4,0xFA,0x07,0x25,0xAF,0x8E,0xE9,0x18,
|
||||
0xD5,0x88,0x6F,0x72,0x24,0xF1,0xC7,0x51,
|
||||
0x23,0x7C,0x9C,0x21,0xDD,0xDC,0x86,0x85,
|
||||
0x90,0x42,0xC4,0xAA,0xD8,0x05,0x01,0x12,
|
||||
0xA3,0x5F,0xF9,0xD0,0x91,0x58,0x27,0xB9,
|
||||
0x38,0x13,0xB3,0x33,0xBB,0x70,0x89,0xA7,
|
||||
0xB6,0x22,0x92,0x20,0x49,0xFF,0x78,0x7A,
|
||||
0x8F,0xF8,0x80,0x17,0xDA,0x31,0xC6,0xB8,
|
||||
0xC3,0xB0,0x77,0x11,0xCB,0xFC,0xD6,0x3A
|
||||
UINT Tkip_Sbox_Lower[256] = {
|
||||
0xA5, 0x84, 0x99, 0x8D, 0x0D, 0xBD, 0xB1, 0x54,
|
||||
0x50, 0x03, 0xA9, 0x7D, 0x19, 0x62, 0xE6, 0x9A,
|
||||
0x45, 0x9D, 0x40, 0x87, 0x15, 0xEB, 0xC9, 0x0B,
|
||||
0xEC, 0x67, 0xFD, 0xEA, 0xBF, 0xF7, 0x96, 0x5B,
|
||||
0xC2, 0x1C, 0xAE, 0x6A, 0x5A, 0x41, 0x02, 0x4F,
|
||||
0x5C, 0xF4, 0x34, 0x08, 0x93, 0x73, 0x53, 0x3F,
|
||||
0x0C, 0x52, 0x65, 0x5E, 0x28, 0xA1, 0x0F, 0xB5,
|
||||
0x09, 0x36, 0x9B, 0x3D, 0x26, 0x69, 0xCD, 0x9F,
|
||||
0x1B, 0x9E, 0x74, 0x2E, 0x2D, 0xB2, 0xEE, 0xFB,
|
||||
0xF6, 0x4D, 0x61, 0xCE, 0x7B, 0x3E, 0x71, 0x97,
|
||||
0xF5, 0x68, 0x00, 0x2C, 0x60, 0x1F, 0xC8, 0xED,
|
||||
0xBE, 0x46, 0xD9, 0x4B, 0xDE, 0xD4, 0xE8, 0x4A,
|
||||
0x6B, 0x2A, 0xE5, 0x16, 0xC5, 0xD7, 0x55, 0x94,
|
||||
0xCF, 0x10, 0x06, 0x81, 0xF0, 0x44, 0xBA, 0xE3,
|
||||
0xF3, 0xFE, 0xC0, 0x8A, 0xAD, 0xBC, 0x48, 0x04,
|
||||
0xDF, 0xC1, 0x75, 0x63, 0x30, 0x1A, 0x0E, 0x6D,
|
||||
0x4C, 0x14, 0x35, 0x2F, 0xE1, 0xA2, 0xCC, 0x39,
|
||||
0x57, 0xF2, 0x82, 0x47, 0xAC, 0xE7, 0x2B, 0x95,
|
||||
0xA0, 0x98, 0xD1, 0x7F, 0x66, 0x7E, 0xAB, 0x83,
|
||||
0xCA, 0x29, 0xD3, 0x3C, 0x79, 0xE2, 0x1D, 0x76,
|
||||
0x3B, 0x56, 0x4E, 0x1E, 0xDB, 0x0A, 0x6C, 0xE4,
|
||||
0x5D, 0x6E, 0xEF, 0xA6, 0xA8, 0xA4, 0x37, 0x8B,
|
||||
0x32, 0x43, 0x59, 0xB7, 0x8C, 0x64, 0xD2, 0xE0,
|
||||
0xB4, 0xFA, 0x07, 0x25, 0xAF, 0x8E, 0xE9, 0x18,
|
||||
0xD5, 0x88, 0x6F, 0x72, 0x24, 0xF1, 0xC7, 0x51,
|
||||
0x23, 0x7C, 0x9C, 0x21, 0xDD, 0xDC, 0x86, 0x85,
|
||||
0x90, 0x42, 0xC4, 0xAA, 0xD8, 0x05, 0x01, 0x12,
|
||||
0xA3, 0x5F, 0xF9, 0xD0, 0x91, 0x58, 0x27, 0xB9,
|
||||
0x38, 0x13, 0xB3, 0x33, 0xBB, 0x70, 0x89, 0xA7,
|
||||
0xB6, 0x22, 0x92, 0x20, 0x49, 0xFF, 0x78, 0x7A,
|
||||
0x8F, 0xF8, 0x80, 0x17, 0xDA, 0x31, 0xC6, 0xB8,
|
||||
0xC3, 0xB0, 0x77, 0x11, 0xCB, 0xFC, 0xD6, 0x3A
|
||||
};
|
||||
|
||||
UINT Tkip_Sbox_Upper[256] =
|
||||
{
|
||||
0xC6,0xF8,0xEE,0xF6,0xFF,0xD6,0xDE,0x91,
|
||||
0x60,0x02,0xCE,0x56,0xE7,0xB5,0x4D,0xEC,
|
||||
0x8F,0x1F,0x89,0xFA,0xEF,0xB2,0x8E,0xFB,
|
||||
0x41,0xB3,0x5F,0x45,0x23,0x53,0xE4,0x9B,
|
||||
0x75,0xE1,0x3D,0x4C,0x6C,0x7E,0xF5,0x83,
|
||||
0x68,0x51,0xD1,0xF9,0xE2,0xAB,0x62,0x2A,
|
||||
0x08,0x95,0x46,0x9D,0x30,0x37,0x0A,0x2F,
|
||||
0x0E,0x24,0x1B,0xDF,0xCD,0x4E,0x7F,0xEA,
|
||||
0x12,0x1D,0x58,0x34,0x36,0xDC,0xB4,0x5B,
|
||||
0xA4,0x76,0xB7,0x7D,0x52,0xDD,0x5E,0x13,
|
||||
0xA6,0xB9,0x00,0xC1,0x40,0xE3,0x79,0xB6,
|
||||
0xD4,0x8D,0x67,0x72,0x94,0x98,0xB0,0x85,
|
||||
0xBB,0xC5,0x4F,0xED,0x86,0x9A,0x66,0x11,
|
||||
0x8A,0xE9,0x04,0xFE,0xA0,0x78,0x25,0x4B,
|
||||
0xA2,0x5D,0x80,0x05,0x3F,0x21,0x70,0xF1,
|
||||
0x63,0x77,0xAF,0x42,0x20,0xE5,0xFD,0xBF,
|
||||
0x81,0x18,0x26,0xC3,0xBE,0x35,0x88,0x2E,
|
||||
0x93,0x55,0xFC,0x7A,0xC8,0xBA,0x32,0xE6,
|
||||
0xC0,0x19,0x9E,0xA3,0x44,0x54,0x3B,0x0B,
|
||||
0x8C,0xC7,0x6B,0x28,0xA7,0xBC,0x16,0xAD,
|
||||
0xDB,0x64,0x74,0x14,0x92,0x0C,0x48,0xB8,
|
||||
0x9F,0xBD,0x43,0xC4,0x39,0x31,0xD3,0xF2,
|
||||
0xD5,0x8B,0x6E,0xDA,0x01,0xB1,0x9C,0x49,
|
||||
0xD8,0xAC,0xF3,0xCF,0xCA,0xF4,0x47,0x10,
|
||||
0x6F,0xF0,0x4A,0x5C,0x38,0x57,0x73,0x97,
|
||||
0xCB,0xA1,0xE8,0x3E,0x96,0x61,0x0D,0x0F,
|
||||
0xE0,0x7C,0x71,0xCC,0x90,0x06,0xF7,0x1C,
|
||||
0xC2,0x6A,0xAE,0x69,0x17,0x99,0x3A,0x27,
|
||||
0xD9,0xEB,0x2B,0x22,0xD2,0xA9,0x07,0x33,
|
||||
0x2D,0x3C,0x15,0xC9,0x87,0xAA,0x50,0xA5,
|
||||
0x03,0x59,0x09,0x1A,0x65,0xD7,0x84,0xD0,
|
||||
0x82,0x29,0x5A,0x1E,0x7B,0xA8,0x6D,0x2C
|
||||
UINT Tkip_Sbox_Upper[256] = {
|
||||
0xC6, 0xF8, 0xEE, 0xF6, 0xFF, 0xD6, 0xDE, 0x91,
|
||||
0x60, 0x02, 0xCE, 0x56, 0xE7, 0xB5, 0x4D, 0xEC,
|
||||
0x8F, 0x1F, 0x89, 0xFA, 0xEF, 0xB2, 0x8E, 0xFB,
|
||||
0x41, 0xB3, 0x5F, 0x45, 0x23, 0x53, 0xE4, 0x9B,
|
||||
0x75, 0xE1, 0x3D, 0x4C, 0x6C, 0x7E, 0xF5, 0x83,
|
||||
0x68, 0x51, 0xD1, 0xF9, 0xE2, 0xAB, 0x62, 0x2A,
|
||||
0x08, 0x95, 0x46, 0x9D, 0x30, 0x37, 0x0A, 0x2F,
|
||||
0x0E, 0x24, 0x1B, 0xDF, 0xCD, 0x4E, 0x7F, 0xEA,
|
||||
0x12, 0x1D, 0x58, 0x34, 0x36, 0xDC, 0xB4, 0x5B,
|
||||
0xA4, 0x76, 0xB7, 0x7D, 0x52, 0xDD, 0x5E, 0x13,
|
||||
0xA6, 0xB9, 0x00, 0xC1, 0x40, 0xE3, 0x79, 0xB6,
|
||||
0xD4, 0x8D, 0x67, 0x72, 0x94, 0x98, 0xB0, 0x85,
|
||||
0xBB, 0xC5, 0x4F, 0xED, 0x86, 0x9A, 0x66, 0x11,
|
||||
0x8A, 0xE9, 0x04, 0xFE, 0xA0, 0x78, 0x25, 0x4B,
|
||||
0xA2, 0x5D, 0x80, 0x05, 0x3F, 0x21, 0x70, 0xF1,
|
||||
0x63, 0x77, 0xAF, 0x42, 0x20, 0xE5, 0xFD, 0xBF,
|
||||
0x81, 0x18, 0x26, 0xC3, 0xBE, 0x35, 0x88, 0x2E,
|
||||
0x93, 0x55, 0xFC, 0x7A, 0xC8, 0xBA, 0x32, 0xE6,
|
||||
0xC0, 0x19, 0x9E, 0xA3, 0x44, 0x54, 0x3B, 0x0B,
|
||||
0x8C, 0xC7, 0x6B, 0x28, 0xA7, 0xBC, 0x16, 0xAD,
|
||||
0xDB, 0x64, 0x74, 0x14, 0x92, 0x0C, 0x48, 0xB8,
|
||||
0x9F, 0xBD, 0x43, 0xC4, 0x39, 0x31, 0xD3, 0xF2,
|
||||
0xD5, 0x8B, 0x6E, 0xDA, 0x01, 0xB1, 0x9C, 0x49,
|
||||
0xD8, 0xAC, 0xF3, 0xCF, 0xCA, 0xF4, 0x47, 0x10,
|
||||
0x6F, 0xF0, 0x4A, 0x5C, 0x38, 0x57, 0x73, 0x97,
|
||||
0xCB, 0xA1, 0xE8, 0x3E, 0x96, 0x61, 0x0D, 0x0F,
|
||||
0xE0, 0x7C, 0x71, 0xCC, 0x90, 0x06, 0xF7, 0x1C,
|
||||
0xC2, 0x6A, 0xAE, 0x69, 0x17, 0x99, 0x3A, 0x27,
|
||||
0xD9, 0xEB, 0x2B, 0x22, 0xD2, 0xA9, 0x07, 0x33,
|
||||
0x2D, 0x3C, 0x15, 0xC9, 0x87, 0xAA, 0x50, 0xA5,
|
||||
0x03, 0x59, 0x09, 0x1A, 0x65, 0xD7, 0x84, 0xD0,
|
||||
0x82, 0x29, 0x5A, 0x1E, 0x7B, 0xA8, 0x6D, 0x2C
|
||||
};
|
||||
|
||||
//
|
||||
// Expanded IV for TKIP function.
|
||||
//
|
||||
typedef struct PACKED _IV_CONTROL_
|
||||
{
|
||||
union PACKED
|
||||
{
|
||||
struct PACKED
|
||||
{
|
||||
UCHAR rc0;
|
||||
UCHAR rc1;
|
||||
UCHAR rc2;
|
||||
typedef struct PACKED _IV_CONTROL_ {
|
||||
union PACKED {
|
||||
struct PACKED {
|
||||
UCHAR rc0;
|
||||
UCHAR rc1;
|
||||
UCHAR rc2;
|
||||
|
||||
union PACKED
|
||||
{
|
||||
struct PACKED
|
||||
{
|
||||
UCHAR Rsvd:5;
|
||||
UCHAR ExtIV:1;
|
||||
UCHAR KeyID:2;
|
||||
} field;
|
||||
UCHAR Byte;
|
||||
} CONTROL;
|
||||
} field;
|
||||
union PACKED {
|
||||
struct PACKED {
|
||||
UCHAR Rsvd:5;
|
||||
UCHAR ExtIV:1;
|
||||
UCHAR KeyID:2;
|
||||
} field;
|
||||
UCHAR Byte;
|
||||
} CONTROL;
|
||||
} field;
|
||||
|
||||
ULONG word;
|
||||
} IV16;
|
||||
|
||||
ULONG IV32;
|
||||
} TKIP_IV, *PTKIP_IV;
|
||||
ULONG word;
|
||||
} IV16;
|
||||
|
||||
ULONG IV32;
|
||||
} TKIP_IV, *PTKIP_IV;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -162,14 +154,12 @@ typedef struct PACKED _IV_CONTROL_
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
ULONG RTMPTkipGetUInt32(
|
||||
IN PUCHAR pMICKey)
|
||||
ULONG RTMPTkipGetUInt32(IN PUCHAR pMICKey)
|
||||
{
|
||||
ULONG res = 0;
|
||||
INT i;
|
||||
ULONG res = 0;
|
||||
INT i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
res |= (*pMICKey++) << (8 * i);
|
||||
}
|
||||
|
||||
|
@ -195,14 +185,11 @@ ULONG RTMPTkipGetUInt32(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPTkipPutUInt32(
|
||||
IN OUT PUCHAR pDst,
|
||||
IN ULONG val)
|
||||
VOID RTMPTkipPutUInt32(IN OUT PUCHAR pDst, IN ULONG val)
|
||||
{
|
||||
INT i;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
*pDst++ = (UCHAR) (val & 0xff);
|
||||
val >>= 8;
|
||||
}
|
||||
|
@ -227,9 +214,7 @@ VOID RTMPTkipPutUInt32(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPTkipSetMICKey(
|
||||
IN PTKIP_KEY_INFO pTkip,
|
||||
IN PUCHAR pMICKey)
|
||||
VOID RTMPTkipSetMICKey(IN PTKIP_KEY_INFO pTkip, IN PUCHAR pMICKey)
|
||||
{
|
||||
// Set the key
|
||||
pTkip->K0 = RTMPTkipGetUInt32(pMICKey);
|
||||
|
@ -260,24 +245,23 @@ VOID RTMPTkipSetMICKey(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPTkipAppendByte(
|
||||
IN PTKIP_KEY_INFO pTkip,
|
||||
IN UCHAR uChar)
|
||||
VOID RTMPTkipAppendByte(IN PTKIP_KEY_INFO pTkip, IN UCHAR uChar)
|
||||
{
|
||||
// Append the byte to our word-sized buffer
|
||||
pTkip->M |= (uChar << (8* pTkip->nBytesInM));
|
||||
pTkip->M |= (uChar << (8 * pTkip->nBytesInM));
|
||||
pTkip->nBytesInM++;
|
||||
// Process the word if it is full.
|
||||
if( pTkip->nBytesInM >= 4 )
|
||||
{
|
||||
if (pTkip->nBytesInM >= 4) {
|
||||
pTkip->L ^= pTkip->M;
|
||||
pTkip->R ^= ROL32( pTkip->L, 17 );
|
||||
pTkip->R ^= ROL32(pTkip->L, 17);
|
||||
pTkip->L += pTkip->R;
|
||||
pTkip->R ^= ((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->L & 0x00ff00ff) << 8);
|
||||
pTkip->R ^=
|
||||
((pTkip->L & 0xff00ff00) >> 8) | ((pTkip->
|
||||
L & 0x00ff00ff) << 8);
|
||||
pTkip->L += pTkip->R;
|
||||
pTkip->R ^= ROL32( pTkip->L, 3 );
|
||||
pTkip->R ^= ROL32(pTkip->L, 3);
|
||||
pTkip->L += pTkip->R;
|
||||
pTkip->R ^= ROR32( pTkip->L, 2 );
|
||||
pTkip->R ^= ROR32(pTkip->L, 2);
|
||||
pTkip->L += pTkip->R;
|
||||
// Clear the buffer
|
||||
pTkip->M = 0;
|
||||
|
@ -305,14 +289,10 @@ VOID RTMPTkipAppendByte(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPTkipAppend(
|
||||
IN PTKIP_KEY_INFO pTkip,
|
||||
IN PUCHAR pSrc,
|
||||
IN UINT nBytes)
|
||||
VOID RTMPTkipAppend(IN PTKIP_KEY_INFO pTkip, IN PUCHAR pSrc, IN UINT nBytes)
|
||||
{
|
||||
// This is simple
|
||||
while(nBytes > 0)
|
||||
{
|
||||
while (nBytes > 0) {
|
||||
RTMPTkipAppendByte(pTkip, *pSrc++);
|
||||
nBytes--;
|
||||
}
|
||||
|
@ -336,19 +316,17 @@ VOID RTMPTkipAppend(
|
|||
the MIC Value is store in pAd->PrivateInfo.MIC
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPTkipGetMIC(
|
||||
IN PTKIP_KEY_INFO pTkip)
|
||||
VOID RTMPTkipGetMIC(IN PTKIP_KEY_INFO pTkip)
|
||||
{
|
||||
// Append the minimum padding
|
||||
RTMPTkipAppendByte(pTkip, 0x5a );
|
||||
RTMPTkipAppendByte(pTkip, 0 );
|
||||
RTMPTkipAppendByte(pTkip, 0 );
|
||||
RTMPTkipAppendByte(pTkip, 0 );
|
||||
RTMPTkipAppendByte(pTkip, 0 );
|
||||
RTMPTkipAppendByte(pTkip, 0x5a);
|
||||
RTMPTkipAppendByte(pTkip, 0);
|
||||
RTMPTkipAppendByte(pTkip, 0);
|
||||
RTMPTkipAppendByte(pTkip, 0);
|
||||
RTMPTkipAppendByte(pTkip, 0);
|
||||
// and then zeroes until the length is a multiple of 4
|
||||
while( pTkip->nBytesInM != 0 )
|
||||
{
|
||||
RTMPTkipAppendByte(pTkip, 0 );
|
||||
while (pTkip->nBytesInM != 0) {
|
||||
RTMPTkipAppendByte(pTkip, 0);
|
||||
}
|
||||
// The appendByte function has already computed the result.
|
||||
RTMPTkipPutUInt32(pTkip->MIC, pTkip->L);
|
||||
|
@ -377,27 +355,24 @@ VOID RTMPTkipGetMIC(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPInitTkipEngine(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN UCHAR KeyId,
|
||||
IN PUCHAR pTA,
|
||||
IN PUCHAR pMICKey,
|
||||
IN PUCHAR pTSC,
|
||||
OUT PULONG pIV16,
|
||||
OUT PULONG pIV32)
|
||||
VOID RTMPInitTkipEngine(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN UCHAR KeyId,
|
||||
IN PUCHAR pTA,
|
||||
IN PUCHAR pMICKey,
|
||||
IN PUCHAR pTSC, OUT PULONG pIV16, OUT PULONG pIV32)
|
||||
{
|
||||
TKIP_IV tkipIv;
|
||||
TKIP_IV tkipIv;
|
||||
|
||||
// Prepare 8 bytes TKIP encapsulation for MPDU
|
||||
NdisZeroMemory(&tkipIv, sizeof(TKIP_IV));
|
||||
tkipIv.IV16.field.rc0 = *(pTSC + 1);
|
||||
tkipIv.IV16.field.rc1 = (tkipIv.IV16.field.rc0 | 0x20) & 0x7f;
|
||||
tkipIv.IV16.field.rc2 = *pTSC;
|
||||
tkipIv.IV16.field.CONTROL.field.ExtIV = 1; // 0: non-extended IV, 1: an extended IV
|
||||
tkipIv.IV16.field.CONTROL.field.ExtIV = 1; // 0: non-extended IV, 1: an extended IV
|
||||
tkipIv.IV16.field.CONTROL.field.KeyID = KeyId;
|
||||
// tkipIv.IV32 = *(PULONG)(pTSC + 2);
|
||||
NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4); // Copy IV
|
||||
// tkipIv.IV32 = *(PULONG)(pTSC + 2);
|
||||
NdisMoveMemory(&tkipIv.IV32, (pTSC + 2), 4); // Copy IV
|
||||
|
||||
*pIV16 = tkipIv.IV16.word;
|
||||
*pIV32 = tkipIv.IV32;
|
||||
|
@ -424,13 +399,10 @@ VOID RTMPInitTkipEngine(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPInitMICEngine(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pSA,
|
||||
IN UCHAR UserPriority,
|
||||
IN PUCHAR pMICKey)
|
||||
VOID RTMPInitMICEngine(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pSA, IN UCHAR UserPriority, IN PUCHAR pMICKey)
|
||||
{
|
||||
ULONG Priority = UserPriority;
|
||||
|
||||
|
@ -441,7 +413,7 @@ VOID RTMPInitMICEngine(
|
|||
// SA
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSA, MAC_ADDR_LEN);
|
||||
// Priority + 3 bytes of 0
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, (PUCHAR)&Priority, 4);
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, (PUCHAR) & Priority, 4);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -468,17 +440,15 @@ VOID RTMPInitMICEngine(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
BOOLEAN RTMPTkipCompareMICValue(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pSrc,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pSA,
|
||||
IN PUCHAR pMICKey,
|
||||
IN UCHAR UserPriority,
|
||||
IN UINT Len)
|
||||
BOOLEAN RTMPTkipCompareMICValue(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pSrc,
|
||||
IN PUCHAR pDA,
|
||||
IN PUCHAR pSA,
|
||||
IN PUCHAR pMICKey,
|
||||
IN UCHAR UserPriority, IN UINT Len)
|
||||
{
|
||||
UCHAR OldMic[8];
|
||||
ULONG Priority = UserPriority;
|
||||
UCHAR OldMic[8];
|
||||
ULONG Priority = UserPriority;
|
||||
|
||||
// Init MIC value calculation
|
||||
RTMPTkipSetMICKey(&pAd->PrivateInfo.Rx, pMICKey);
|
||||
|
@ -487,7 +457,7 @@ BOOLEAN RTMPTkipCompareMICValue(
|
|||
// SA
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSA, MAC_ADDR_LEN);
|
||||
// Priority + 3 bytes of 0
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR)&Priority, 4);
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Rx, (PUCHAR) & Priority, 4);
|
||||
|
||||
// Calculate MIC value from plain text data
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Rx, pSrc, Len);
|
||||
|
@ -500,10 +470,8 @@ BOOLEAN RTMPTkipCompareMICValue(
|
|||
|
||||
// Move MIC value from MSDU, this steps should move to data path.
|
||||
// Since the MIC value might cross MPDUs.
|
||||
if(!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8))
|
||||
{
|
||||
DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n")); //MIC error.
|
||||
|
||||
if (!NdisEqualMemory(pAd->PrivateInfo.Rx.MIC, OldMic, 8)) {
|
||||
DBGPRINT_RAW(RT_DEBUG_ERROR, ("RTMPTkipCompareMICValue(): TKIP MIC Error !\n")); //MIC error.
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
@ -532,19 +500,17 @@ BOOLEAN RTMPTkipCompareMICValue(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPCalculateMICValue(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PNDIS_PACKET pPacket,
|
||||
IN PUCHAR pEncap,
|
||||
IN PCIPHER_KEY pKey,
|
||||
IN UCHAR apidx)
|
||||
VOID RTMPCalculateMICValue(IN PRTMP_ADAPTER pAd,
|
||||
IN PNDIS_PACKET pPacket,
|
||||
IN PUCHAR pEncap,
|
||||
IN PCIPHER_KEY pKey, IN UCHAR apidx)
|
||||
{
|
||||
PACKET_INFO PacketInfo;
|
||||
PUCHAR pSrcBufVA;
|
||||
UINT SrcBufLen;
|
||||
PUCHAR pSrc;
|
||||
UCHAR UserPriority;
|
||||
UCHAR vlan_offset = 0;
|
||||
PACKET_INFO PacketInfo;
|
||||
PUCHAR pSrcBufVA;
|
||||
UINT SrcBufLen;
|
||||
PUCHAR pSrc;
|
||||
UCHAR UserPriority;
|
||||
UCHAR vlan_offset = 0;
|
||||
|
||||
RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen);
|
||||
|
||||
|
@ -556,41 +522,33 @@ VOID RTMPCalculateMICValue(
|
|||
vlan_offset = 4;
|
||||
|
||||
{
|
||||
RTMPInitMICEngine(
|
||||
pAd,
|
||||
pKey->Key,
|
||||
pSrc,
|
||||
pSrc + 6,
|
||||
UserPriority,
|
||||
pKey->TxMic);
|
||||
RTMPInitMICEngine(pAd,
|
||||
pKey->Key,
|
||||
pSrc, pSrc + 6, UserPriority, pKey->TxMic);
|
||||
}
|
||||
|
||||
|
||||
if (pEncap != NULL)
|
||||
{
|
||||
if (pEncap != NULL) {
|
||||
// LLC encapsulation
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pEncap, 6);
|
||||
// Protocol Type
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset, 2);
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc + 12 + vlan_offset,
|
||||
2);
|
||||
}
|
||||
SrcBufLen -= (14 + vlan_offset);
|
||||
pSrc += (14 + vlan_offset);
|
||||
do
|
||||
{
|
||||
if (SrcBufLen > 0)
|
||||
{
|
||||
do {
|
||||
if (SrcBufLen > 0) {
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pSrc, SrcBufLen);
|
||||
}
|
||||
|
||||
break; // No need handle next packet
|
||||
break; // No need handle next packet
|
||||
|
||||
} while (TRUE); // End of copying payload
|
||||
} while (TRUE); // End of copying payload
|
||||
|
||||
// Compute the final MIC Value
|
||||
RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************/
|
||||
/* tkip_sbox() */
|
||||
/* Returns a 16 bit value from a 64K entry table. The Table */
|
||||
|
@ -607,7 +565,8 @@ UINT tkip_sbox(UINT index)
|
|||
index_high = ((index >> 8) % 256);
|
||||
|
||||
left = Tkip_Sbox_Lower[index_low] + (Tkip_Sbox_Upper[index_low] * 256);
|
||||
right = Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
|
||||
right =
|
||||
Tkip_Sbox_Upper[index_high] + (Tkip_Sbox_Lower[index_high] * 256);
|
||||
|
||||
return (left ^ right);
|
||||
}
|
||||
|
@ -616,25 +575,18 @@ UINT rotr1(UINT a)
|
|||
{
|
||||
unsigned int b;
|
||||
|
||||
if ((a & 0x01) == 0x01)
|
||||
{
|
||||
if ((a & 0x01) == 0x01) {
|
||||
b = (a >> 1) | 0x8000;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b = (a >> 1) & 0x7fff;
|
||||
}
|
||||
b = b % 65536;
|
||||
return b;
|
||||
}
|
||||
|
||||
VOID RTMPTkipMixKey(
|
||||
UCHAR *key,
|
||||
UCHAR *ta,
|
||||
ULONG pnl, /* Least significant 16 bits of PN */
|
||||
ULONG pnh, /* Most significant 32 bits of PN */
|
||||
UCHAR *rc4key,
|
||||
UINT *p1k)
|
||||
VOID RTMPTkipMixKey(UCHAR * key, UCHAR * ta, ULONG pnl, /* Least significant 16 bits of PN */
|
||||
ULONG pnh, /* Most significant 32 bits of PN */
|
||||
UCHAR * rc4key, UINT * p1k)
|
||||
{
|
||||
|
||||
UINT tsc0;
|
||||
|
@ -651,26 +603,40 @@ VOID RTMPTkipMixKey(
|
|||
INT i;
|
||||
INT j;
|
||||
|
||||
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
|
||||
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
|
||||
tsc1 = (unsigned int)(pnh % 65536);
|
||||
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
|
||||
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
|
||||
|
||||
/* Phase 1, step 1 */
|
||||
p1k[0] = tsc1;
|
||||
p1k[1] = tsc0;
|
||||
p1k[2] = (UINT)(ta[0] + (ta[1]*256));
|
||||
p1k[3] = (UINT)(ta[2] + (ta[3]*256));
|
||||
p1k[4] = (UINT)(ta[4] + (ta[5]*256));
|
||||
p1k[2] = (UINT) (ta[0] + (ta[1] * 256));
|
||||
p1k[3] = (UINT) (ta[2] + (ta[3] * 256));
|
||||
p1k[4] = (UINT) (ta[4] + (ta[5] * 256));
|
||||
|
||||
/* Phase 1, step 2 */
|
||||
for (i=0; i<8; i++)
|
||||
{
|
||||
j = 2*(i & 1);
|
||||
p1k[0] = (p1k[0] + tkip_sbox( (p1k[4] ^ ((256*key[1+j]) + key[j])) % 65536 )) % 65536;
|
||||
p1k[1] = (p1k[1] + tkip_sbox( (p1k[0] ^ ((256*key[5+j]) + key[4+j])) % 65536 )) % 65536;
|
||||
p1k[2] = (p1k[2] + tkip_sbox( (p1k[1] ^ ((256*key[9+j]) + key[8+j])) % 65536 )) % 65536;
|
||||
p1k[3] = (p1k[3] + tkip_sbox( (p1k[2] ^ ((256*key[13+j]) + key[12+j])) % 65536 )) % 65536;
|
||||
p1k[4] = (p1k[4] + tkip_sbox( (p1k[3] ^ (((256*key[1+j]) + key[j]))) % 65536 )) % 65536;
|
||||
for (i = 0; i < 8; i++) {
|
||||
j = 2 * (i & 1);
|
||||
p1k[0] =
|
||||
(p1k[0] +
|
||||
tkip_sbox((p1k[4] ^ ((256 * key[1 + j]) + key[j])) %
|
||||
65536)) % 65536;
|
||||
p1k[1] =
|
||||
(p1k[1] +
|
||||
tkip_sbox((p1k[0] ^ ((256 * key[5 + j]) + key[4 + j])) %
|
||||
65536)) % 65536;
|
||||
p1k[2] =
|
||||
(p1k[2] +
|
||||
tkip_sbox((p1k[1] ^ ((256 * key[9 + j]) + key[8 + j])) %
|
||||
65536)) % 65536;
|
||||
p1k[3] =
|
||||
(p1k[3] +
|
||||
tkip_sbox((p1k[2] ^ ((256 * key[13 + j]) + key[12 + j])) %
|
||||
65536)) % 65536;
|
||||
p1k[4] =
|
||||
(p1k[4] +
|
||||
tkip_sbox((p1k[3] ^ (((256 * key[1 + j]) + key[j]))) %
|
||||
65536)) % 65536;
|
||||
p1k[4] = (p1k[4] + i) % 65536;
|
||||
}
|
||||
|
||||
|
@ -683,31 +649,31 @@ VOID RTMPTkipMixKey(
|
|||
ppk5 = (p1k[4] + tsc2) % 65536;
|
||||
|
||||
/* Phase2, Step 2 */
|
||||
ppk0 = ppk0 + tkip_sbox( (ppk5 ^ ((256*key[1]) + key[0])) % 65536);
|
||||
ppk1 = ppk1 + tkip_sbox( (ppk0 ^ ((256*key[3]) + key[2])) % 65536);
|
||||
ppk2 = ppk2 + tkip_sbox( (ppk1 ^ ((256*key[5]) + key[4])) % 65536);
|
||||
ppk3 = ppk3 + tkip_sbox( (ppk2 ^ ((256*key[7]) + key[6])) % 65536);
|
||||
ppk4 = ppk4 + tkip_sbox( (ppk3 ^ ((256*key[9]) + key[8])) % 65536);
|
||||
ppk5 = ppk5 + tkip_sbox( (ppk4 ^ ((256*key[11]) + key[10])) % 65536);
|
||||
ppk0 = ppk0 + tkip_sbox((ppk5 ^ ((256 * key[1]) + key[0])) % 65536);
|
||||
ppk1 = ppk1 + tkip_sbox((ppk0 ^ ((256 * key[3]) + key[2])) % 65536);
|
||||
ppk2 = ppk2 + tkip_sbox((ppk1 ^ ((256 * key[5]) + key[4])) % 65536);
|
||||
ppk3 = ppk3 + tkip_sbox((ppk2 ^ ((256 * key[7]) + key[6])) % 65536);
|
||||
ppk4 = ppk4 + tkip_sbox((ppk3 ^ ((256 * key[9]) + key[8])) % 65536);
|
||||
ppk5 = ppk5 + tkip_sbox((ppk4 ^ ((256 * key[11]) + key[10])) % 65536);
|
||||
|
||||
ppk0 = ppk0 + rotr1(ppk5 ^ ((256*key[13]) + key[12]));
|
||||
ppk1 = ppk1 + rotr1(ppk0 ^ ((256*key[15]) + key[14]));
|
||||
ppk0 = ppk0 + rotr1(ppk5 ^ ((256 * key[13]) + key[12]));
|
||||
ppk1 = ppk1 + rotr1(ppk0 ^ ((256 * key[15]) + key[14]));
|
||||
ppk2 = ppk2 + rotr1(ppk1);
|
||||
ppk3 = ppk3 + rotr1(ppk2);
|
||||
ppk4 = ppk4 + rotr1(ppk3);
|
||||
ppk5 = ppk5 + rotr1(ppk4);
|
||||
|
||||
/* Phase 2, Step 3 */
|
||||
/* Phase 2, Step 3 */
|
||||
/* Phase 2, Step 3 */
|
||||
|
||||
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
|
||||
tsc0 = (unsigned int)((pnh >> 16) % 65536); /* msb */
|
||||
tsc1 = (unsigned int)(pnh % 65536);
|
||||
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
|
||||
tsc2 = (unsigned int)(pnl % 65536); /* lsb */
|
||||
|
||||
rc4key[0] = (tsc2 >> 8) % 256;
|
||||
rc4key[1] = (((tsc2 >> 8) % 256) | 0x20) & 0x7f;
|
||||
rc4key[2] = tsc2 % 256;
|
||||
rc4key[3] = ((ppk5 ^ ((256*key[1]) + key[0])) >> 1) % 256;
|
||||
rc4key[3] = ((ppk5 ^ ((256 * key[1]) + key[0])) >> 1) % 256;
|
||||
|
||||
rc4key[4] = ppk0 % 256;
|
||||
rc4key[5] = (ppk0 >> 8) % 256;
|
||||
|
@ -728,155 +694,140 @@ VOID RTMPTkipMixKey(
|
|||
rc4key[15] = (ppk5 >> 8) % 256;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TRUE: Success!
|
||||
// FALSE: Decrypt Error!
|
||||
//
|
||||
BOOLEAN RTMPSoftDecryptTKIP(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pData,
|
||||
IN ULONG DataByteCnt,
|
||||
IN UCHAR UserPriority,
|
||||
IN PCIPHER_KEY pWpaKey)
|
||||
BOOLEAN RTMPSoftDecryptTKIP(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pData,
|
||||
IN ULONG DataByteCnt,
|
||||
IN UCHAR UserPriority, IN PCIPHER_KEY pWpaKey)
|
||||
{
|
||||
UCHAR KeyID;
|
||||
UINT HeaderLen;
|
||||
UCHAR fc0;
|
||||
UCHAR fc1;
|
||||
USHORT fc;
|
||||
UINT frame_type;
|
||||
UINT frame_subtype;
|
||||
UINT from_ds;
|
||||
UINT to_ds;
|
||||
INT a4_exists;
|
||||
INT qc_exists;
|
||||
USHORT duration;
|
||||
USHORT seq_control;
|
||||
USHORT qos_control;
|
||||
UCHAR TA[MAC_ADDR_LEN];
|
||||
UCHAR DA[MAC_ADDR_LEN];
|
||||
UCHAR SA[MAC_ADDR_LEN];
|
||||
UCHAR RC4Key[16];
|
||||
UINT p1k[5]; //for mix_key;
|
||||
ULONG pnl;/* Least significant 16 bits of PN */
|
||||
ULONG pnh;/* Most significant 32 bits of PN */
|
||||
UINT num_blocks;
|
||||
UINT payload_remainder;
|
||||
ARCFOURCONTEXT ArcFourContext;
|
||||
UINT crc32 = 0;
|
||||
UINT trailfcs = 0;
|
||||
UCHAR MIC[8];
|
||||
UCHAR TrailMIC[8];
|
||||
|
||||
UCHAR KeyID;
|
||||
UINT HeaderLen;
|
||||
UCHAR fc0;
|
||||
UCHAR fc1;
|
||||
USHORT fc;
|
||||
UINT frame_type;
|
||||
UINT frame_subtype;
|
||||
UINT from_ds;
|
||||
UINT to_ds;
|
||||
INT a4_exists;
|
||||
INT qc_exists;
|
||||
USHORT duration;
|
||||
USHORT seq_control;
|
||||
USHORT qos_control;
|
||||
UCHAR TA[MAC_ADDR_LEN];
|
||||
UCHAR DA[MAC_ADDR_LEN];
|
||||
UCHAR SA[MAC_ADDR_LEN];
|
||||
UCHAR RC4Key[16];
|
||||
UINT p1k[5]; //for mix_key;
|
||||
ULONG pnl; /* Least significant 16 bits of PN */
|
||||
ULONG pnh; /* Most significant 32 bits of PN */
|
||||
UINT num_blocks;
|
||||
UINT payload_remainder;
|
||||
ARCFOURCONTEXT ArcFourContext;
|
||||
UINT crc32 = 0;
|
||||
UINT trailfcs = 0;
|
||||
UCHAR MIC[8];
|
||||
UCHAR TrailMIC[8];
|
||||
|
||||
fc0 = *pData;
|
||||
fc1 = *(pData + 1);
|
||||
|
||||
fc = *((PUSHORT)pData);
|
||||
fc = *((PUSHORT) pData);
|
||||
|
||||
frame_type = ((fc0 >> 2) & 0x03);
|
||||
frame_subtype = ((fc0 >> 4) & 0x0f);
|
||||
|
||||
from_ds = (fc1 & 0x2) >> 1;
|
||||
to_ds = (fc1 & 0x1);
|
||||
from_ds = (fc1 & 0x2) >> 1;
|
||||
to_ds = (fc1 & 0x1);
|
||||
|
||||
a4_exists = (from_ds & to_ds);
|
||||
qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
|
||||
(frame_subtype == 0x09) || /* Likely to change. */
|
||||
(frame_subtype == 0x0a) ||
|
||||
(frame_subtype == 0x0b)
|
||||
);
|
||||
a4_exists = (from_ds & to_ds);
|
||||
qc_exists = ((frame_subtype == 0x08) || /* Assumed QoS subtypes */
|
||||
(frame_subtype == 0x09) || /* Likely to change. */
|
||||
(frame_subtype == 0x0a) || (frame_subtype == 0x0b)
|
||||
);
|
||||
|
||||
HeaderLen = 24;
|
||||
if (a4_exists)
|
||||
HeaderLen += 6;
|
||||
|
||||
KeyID = *((PUCHAR)(pData+ HeaderLen + 3));
|
||||
KeyID = *((PUCHAR) (pData + HeaderLen + 3));
|
||||
KeyID = KeyID >> 6;
|
||||
|
||||
if (pWpaKey[KeyID].KeyLen == 0)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n", KeyID));
|
||||
if (pWpaKey[KeyID].KeyLen == 0) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("RTMPSoftDecryptTKIP failed!(KeyID[%d] Length can not be 0)\n",
|
||||
KeyID));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
duration = *((PUSHORT)(pData+2));
|
||||
duration = *((PUSHORT) (pData + 2));
|
||||
|
||||
seq_control = *((PUSHORT)(pData+22));
|
||||
seq_control = *((PUSHORT) (pData + 22));
|
||||
|
||||
if (qc_exists)
|
||||
{
|
||||
if (a4_exists)
|
||||
{
|
||||
qos_control = *((PUSHORT)(pData+30));
|
||||
}
|
||||
else
|
||||
{
|
||||
qos_control = *((PUSHORT)(pData+24));
|
||||
if (qc_exists) {
|
||||
if (a4_exists) {
|
||||
qos_control = *((PUSHORT) (pData + 30));
|
||||
} else {
|
||||
qos_control = *((PUSHORT) (pData + 24));
|
||||
}
|
||||
}
|
||||
|
||||
if (to_ds == 0 && from_ds == 1)
|
||||
{
|
||||
NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData+16, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN); //BSSID
|
||||
}
|
||||
else if (to_ds == 0 && from_ds == 0 )
|
||||
{
|
||||
NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData+4, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
|
||||
}
|
||||
else if (to_ds == 1 && from_ds == 0)
|
||||
{
|
||||
NdisMoveMemory(SA, pData+10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
|
||||
}
|
||||
else if (to_ds == 1 && from_ds == 1)
|
||||
{
|
||||
NdisMoveMemory(TA, pData+10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData+16, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData+22, MAC_ADDR_LEN);
|
||||
if (to_ds == 0 && from_ds == 1) {
|
||||
NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData + 16, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN); //BSSID
|
||||
} else if (to_ds == 0 && from_ds == 0) {
|
||||
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData + 4, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
|
||||
} else if (to_ds == 1 && from_ds == 0) {
|
||||
NdisMoveMemory(SA, pData + 10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
|
||||
} else if (to_ds == 1 && from_ds == 1) {
|
||||
NdisMoveMemory(TA, pData + 10, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(DA, pData + 16, MAC_ADDR_LEN);
|
||||
NdisMoveMemory(SA, pData + 22, MAC_ADDR_LEN);
|
||||
}
|
||||
|
||||
num_blocks = (DataByteCnt - 16) / 16;
|
||||
payload_remainder = (DataByteCnt - 16) % 16;
|
||||
|
||||
pnl = (*(pData + HeaderLen)) * 256 + *(pData + HeaderLen + 2);
|
||||
pnh = *((PULONG)(pData + HeaderLen + 4));
|
||||
pnh = *((PULONG) (pData + HeaderLen + 4));
|
||||
pnh = cpu2le32(pnh);
|
||||
RTMPTkipMixKey(pWpaKey[KeyID].Key, TA, pnl, pnh, RC4Key, p1k);
|
||||
|
||||
ARCFOUR_INIT(&ArcFourContext, RC4Key, 16);
|
||||
|
||||
ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen, pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
|
||||
ARCFOUR_DECRYPT(&ArcFourContext, pData + HeaderLen,
|
||||
pData + HeaderLen + 8, DataByteCnt - HeaderLen - 8);
|
||||
NdisMoveMemory(&trailfcs, pData + DataByteCnt - 8 - 4, 4);
|
||||
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4); //Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS).
|
||||
crc32 ^= 0xffffffff; /* complement */
|
||||
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 4); //Skip IV+EIV 8 bytes & Skip last 4 bytes(FCS).
|
||||
crc32 ^= 0xffffffff; /* complement */
|
||||
|
||||
if(crc32 != cpu2le32(trailfcs))
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n")); //ICV error.
|
||||
if (crc32 != cpu2le32(trailfcs)) {
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("RTMPSoftDecryptTKIP, WEP Data ICV Error !\n")); //ICV error.
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
NdisMoveMemory(TrailMIC, pData + DataByteCnt - 8 - 8 - 4, 8);
|
||||
RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority, pWpaKey[KeyID].RxMic);
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen, DataByteCnt - HeaderLen - 8 - 12);
|
||||
RTMPInitMICEngine(pAd, pWpaKey[KeyID].Key, DA, SA, UserPriority,
|
||||
pWpaKey[KeyID].RxMic);
|
||||
RTMPTkipAppend(&pAd->PrivateInfo.Tx, pData + HeaderLen,
|
||||
DataByteCnt - HeaderLen - 8 - 12);
|
||||
RTMPTkipGetMIC(&pAd->PrivateInfo.Tx);
|
||||
NdisMoveMemory(MIC, pAd->PrivateInfo.Tx.MIC, 8);
|
||||
|
||||
if (!NdisEqualMemory(MIC, TrailMIC, 8))
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n")); //MIC error.
|
||||
//RTMPReportMicError(pAd, &pWpaKey[KeyID]); // marked by AlbertY @ 20060630
|
||||
if (!NdisEqualMemory(MIC, TrailMIC, 8)) {
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("RTMPSoftDecryptTKIP, WEP Data MIC Error !\n")); //MIC error.
|
||||
//RTMPReportMicError(pAd, &pWpaKey[KeyID]); // marked by AlbertY @ 20060630
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
//DBGPRINT(RT_DEBUG_TRACE, "RTMPSoftDecryptTKIP Decript done!!\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
|
||||
#include "../rt_config.h"
|
||||
|
||||
UINT FCSTAB_32[256] =
|
||||
{
|
||||
UINT FCSTAB_32[256] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
|
||||
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
|
||||
|
@ -136,33 +135,31 @@ UCHAR WEPKEY[] = {
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPInitWepEngine(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN UCHAR KeyId,
|
||||
IN UCHAR KeyLen,
|
||||
IN OUT PUCHAR pDest)
|
||||
VOID RTMPInitWepEngine(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pKey,
|
||||
IN UCHAR KeyId, IN UCHAR KeyLen, IN OUT PUCHAR pDest)
|
||||
{
|
||||
UINT i;
|
||||
UCHAR WEPKEY[] = {
|
||||
UCHAR WEPKEY[] = {
|
||||
//IV
|
||||
0x00, 0x11, 0x22,
|
||||
//WEP KEY
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
|
||||
0xAA, 0xBB, 0xCC
|
||||
};
|
||||
|
||||
pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
|
||||
pAd->PrivateInfo.FCSCRC32 = PPPINITFCS32; //Init crc32.
|
||||
|
||||
{
|
||||
{
|
||||
NdisMoveMemory(WEPKEY + 3, pKey, KeyLen);
|
||||
|
||||
for(i = 0; i < 3; i++)
|
||||
WEPKEY[i] = RandomByte(pAd); //Call mlme RandomByte() function.
|
||||
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); //INIT SBOX, KEYLEN+3(IV)
|
||||
for (i = 0; i < 3; i++)
|
||||
WEPKEY[i] = RandomByte(pAd); //Call mlme RandomByte() function.
|
||||
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, KeyLen + 3); //INIT SBOX, KEYLEN+3(IV)
|
||||
|
||||
NdisMoveMemory(pDest, WEPKEY, 3); //Append Init Vector
|
||||
}
|
||||
*(pDest+3) = (KeyId << 6); //Append KEYID
|
||||
NdisMoveMemory(pDest, WEPKEY, 3); //Append Init Vector
|
||||
}
|
||||
*(pDest + 3) = (KeyId << 6); //Append KEYID
|
||||
|
||||
}
|
||||
|
||||
|
@ -187,17 +184,14 @@ VOID RTMPInitWepEngine(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPEncryptData(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pSrc,
|
||||
IN PUCHAR pDest,
|
||||
IN UINT Len)
|
||||
VOID RTMPEncryptData(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pSrc, IN PUCHAR pDest, IN UINT Len)
|
||||
{
|
||||
pAd->PrivateInfo.FCSCRC32 = RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
|
||||
pAd->PrivateInfo.FCSCRC32 =
|
||||
RTMP_CALC_FCS32(pAd->PrivateInfo.FCSCRC32, pSrc, Len);
|
||||
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, pSrc, Len);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
|
@ -217,40 +211,41 @@ VOID RTMPEncryptData(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
BOOLEAN RTMPSoftDecryptWEP(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pData,
|
||||
IN ULONG DataByteCnt,
|
||||
IN PCIPHER_KEY pGroupKey)
|
||||
BOOLEAN RTMPSoftDecryptWEP(IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pData,
|
||||
IN ULONG DataByteCnt, IN PCIPHER_KEY pGroupKey)
|
||||
{
|
||||
UINT trailfcs;
|
||||
UINT crc32;
|
||||
UCHAR KeyIdx;
|
||||
UCHAR WEPKEY[] = {
|
||||
UINT trailfcs;
|
||||
UINT crc32;
|
||||
UCHAR KeyIdx;
|
||||
UCHAR WEPKEY[] = {
|
||||
//IV
|
||||
0x00, 0x11, 0x22,
|
||||
//WEP KEY
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
|
||||
0xAA, 0xBB, 0xCC
|
||||
};
|
||||
UCHAR *pPayload = (UCHAR *)pData + LENGTH_802_11;
|
||||
ULONG payload_len = DataByteCnt - LENGTH_802_11;
|
||||
UCHAR *pPayload = (UCHAR *) pData + LENGTH_802_11;
|
||||
ULONG payload_len = DataByteCnt - LENGTH_802_11;
|
||||
|
||||
NdisMoveMemory(WEPKEY, pPayload, 3); //Get WEP IV
|
||||
NdisMoveMemory(WEPKEY, pPayload, 3); //Get WEP IV
|
||||
|
||||
KeyIdx = (*(pPayload + 3) & 0xc0) >> 6;
|
||||
if (pGroupKey[KeyIdx].KeyLen == 0)
|
||||
return (FALSE);
|
||||
|
||||
NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key, pGroupKey[KeyIdx].KeyLen);
|
||||
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY, pGroupKey[KeyIdx].KeyLen + 3);
|
||||
ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4, payload_len - 4);
|
||||
NdisMoveMemory(WEPKEY + 3, pGroupKey[KeyIdx].Key,
|
||||
pGroupKey[KeyIdx].KeyLen);
|
||||
ARCFOUR_INIT(&pAd->PrivateInfo.WEPCONTEXT, WEPKEY,
|
||||
pGroupKey[KeyIdx].KeyLen + 3);
|
||||
ARCFOUR_DECRYPT(&pAd->PrivateInfo.WEPCONTEXT, pPayload, pPayload + 4,
|
||||
payload_len - 4);
|
||||
NdisMoveMemory(&trailfcs, pPayload + payload_len - 8, 4);
|
||||
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8); //Skip last 4 bytes(FCS).
|
||||
crc32 ^= 0xffffffff; /* complement */
|
||||
crc32 = RTMP_CALC_FCS32(PPPINITFCS32, pPayload, payload_len - 8); //Skip last 4 bytes(FCS).
|
||||
crc32 ^= 0xffffffff; /* complement */
|
||||
|
||||
if(crc32 != cpu2le32(trailfcs))
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("! WEP Data CRC Error !\n")); //CRC error.
|
||||
if (crc32 != cpu2le32(trailfcs)) {
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("! WEP Data CRC Error !\n")); //CRC error.
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
|
@ -276,26 +271,22 @@ BOOLEAN RTMPSoftDecryptWEP(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID ARCFOUR_INIT(
|
||||
IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pKey,
|
||||
IN UINT KeyLen)
|
||||
VOID ARCFOUR_INIT(IN PARCFOURCONTEXT Ctx, IN PUCHAR pKey, IN UINT KeyLen)
|
||||
{
|
||||
UCHAR t, u;
|
||||
UINT keyindex;
|
||||
UINT stateindex;
|
||||
PUCHAR state;
|
||||
UINT counter;
|
||||
UCHAR t, u;
|
||||
UINT keyindex;
|
||||
UINT stateindex;
|
||||
PUCHAR state;
|
||||
UINT counter;
|
||||
|
||||
state = Ctx->STATE;
|
||||
Ctx->X = 0;
|
||||
Ctx->Y = 0;
|
||||
for (counter = 0; counter < 256; counter++)
|
||||
state[counter] = (UCHAR)counter;
|
||||
state[counter] = (UCHAR) counter;
|
||||
keyindex = 0;
|
||||
stateindex = 0;
|
||||
for (counter = 0; counter < 256; counter++)
|
||||
{
|
||||
for (counter = 0; counter < 256; counter++) {
|
||||
t = state[counter];
|
||||
stateindex = (stateindex + pKey[keyindex] + t) & 0xff;
|
||||
u = state[stateindex];
|
||||
|
@ -322,25 +313,24 @@ VOID ARCFOUR_INIT(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
UCHAR ARCFOUR_BYTE(
|
||||
IN PARCFOURCONTEXT Ctx)
|
||||
UCHAR ARCFOUR_BYTE(IN PARCFOURCONTEXT Ctx)
|
||||
{
|
||||
UINT x;
|
||||
UINT y;
|
||||
UCHAR sx, sy;
|
||||
PUCHAR state;
|
||||
UINT x;
|
||||
UINT y;
|
||||
UCHAR sx, sy;
|
||||
PUCHAR state;
|
||||
|
||||
state = Ctx->STATE;
|
||||
x = (Ctx->X + 1) & 0xff;
|
||||
sx = state[x];
|
||||
y = (sx + Ctx->Y) & 0xff;
|
||||
sy = state[y];
|
||||
Ctx->X = x;
|
||||
Ctx->Y = y;
|
||||
state[y] = sx;
|
||||
state[x] = sy;
|
||||
state = Ctx->STATE;
|
||||
x = (Ctx->X + 1) & 0xff;
|
||||
sx = state[x];
|
||||
y = (sx + Ctx->Y) & 0xff;
|
||||
sy = state[y];
|
||||
Ctx->X = x;
|
||||
Ctx->Y = y;
|
||||
state[y] = sx;
|
||||
state[x] = sy;
|
||||
|
||||
return(state[(sx + sy) & 0xff]);
|
||||
return (state[(sx + sy) & 0xff]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -363,11 +353,8 @@ UCHAR ARCFOUR_BYTE(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID ARCFOUR_DECRYPT(
|
||||
IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest,
|
||||
IN PUCHAR pSrc,
|
||||
IN UINT Len)
|
||||
VOID ARCFOUR_DECRYPT(IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest, IN PUCHAR pSrc, IN UINT Len)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
|
@ -396,11 +383,8 @@ VOID ARCFOUR_DECRYPT(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID ARCFOUR_ENCRYPT(
|
||||
IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest,
|
||||
IN PUCHAR pSrc,
|
||||
IN UINT Len)
|
||||
VOID ARCFOUR_ENCRYPT(IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest, IN PUCHAR pSrc, IN UINT Len)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
|
@ -420,26 +404,21 @@ VOID ARCFOUR_ENCRYPT(
|
|||
pSrc Pointer to the Source data
|
||||
Len Indicate the length of the Source dta
|
||||
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
|
||||
VOID WPAARCFOUR_ENCRYPT(
|
||||
IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest,
|
||||
IN PUCHAR pSrc,
|
||||
IN UINT Len)
|
||||
VOID WPAARCFOUR_ENCRYPT(IN PARCFOURCONTEXT Ctx,
|
||||
IN PUCHAR pDest, IN PUCHAR pSrc, IN UINT Len)
|
||||
{
|
||||
UINT i;
|
||||
//discard first 256 bytes
|
||||
//discard first 256 bytes
|
||||
for (i = 0; i < 256; i++)
|
||||
ARCFOUR_BYTE(Ctx);
|
||||
ARCFOUR_BYTE(Ctx);
|
||||
|
||||
for (i = 0; i < Len; i++)
|
||||
pDest[i] = pSrc[i] ^ ARCFOUR_BYTE(Ctx);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
|
@ -460,18 +439,14 @@ VOID WPAARCFOUR_ENCRYPT(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
UINT RTMP_CALC_FCS32(
|
||||
IN UINT Fcs,
|
||||
IN PUCHAR Cp,
|
||||
IN INT Len)
|
||||
UINT RTMP_CALC_FCS32(IN UINT Fcs, IN PUCHAR Cp, IN INT Len)
|
||||
{
|
||||
while (Len--)
|
||||
Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
|
||||
Fcs = (((Fcs) >> 8) ^ FCSTAB_32[((Fcs) ^ (*Cp++)) & 0xff]);
|
||||
|
||||
return (Fcs);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
|
@ -488,12 +463,11 @@ UINT RTMP_CALC_FCS32(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID RTMPSetICV(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUCHAR pDest)
|
||||
VOID RTMPSetICV(IN PRTMP_ADAPTER pAd, IN PUCHAR pDest)
|
||||
{
|
||||
pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
|
||||
pAd->PrivateInfo.FCSCRC32 ^= 0xffffffff; /* complement */
|
||||
pAd->PrivateInfo.FCSCRC32 = cpu2le32(pAd->PrivateInfo.FCSCRC32);
|
||||
|
||||
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest, (PUCHAR) &pAd->PrivateInfo.FCSCRC32, 4);
|
||||
ARCFOUR_ENCRYPT(&pAd->PrivateInfo.WEPCONTEXT, pDest,
|
||||
(PUCHAR) & pAd->PrivateInfo.FCSCRC32, 4);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "../crypt_hmac.h"
|
||||
|
||||
|
||||
#ifdef HMAC_SHA1_SUPPORT
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -47,66 +46,63 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID HMAC_SHA1 (
|
||||
IN const UINT8 Key[],
|
||||
IN UINT KeyLen,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen,
|
||||
OUT UINT8 MAC[],
|
||||
IN UINT MACLen)
|
||||
VOID HMAC_SHA1(IN const UINT8 Key[],
|
||||
IN UINT KeyLen,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen, OUT UINT8 MAC[], IN UINT MACLen)
|
||||
{
|
||||
SHA1_CTX_STRUC sha_ctx1;
|
||||
SHA1_CTX_STRUC sha_ctx2;
|
||||
UINT8 K0[SHA1_BLOCK_SIZE];
|
||||
UINT8 Digest[SHA1_DIGEST_SIZE];
|
||||
UINT index;
|
||||
SHA1_CTX_STRUC sha_ctx1;
|
||||
SHA1_CTX_STRUC sha_ctx2;
|
||||
UINT8 K0[SHA1_BLOCK_SIZE];
|
||||
UINT8 Digest[SHA1_DIGEST_SIZE];
|
||||
UINT index;
|
||||
|
||||
NdisZeroMemory(&sha_ctx1, sizeof(SHA1_CTX_STRUC));
|
||||
NdisZeroMemory(&sha_ctx2, sizeof(SHA1_CTX_STRUC));
|
||||
/*
|
||||
* If the length of K = B(Block size): K0 = K.
|
||||
* If the length of K > B: hash K to obtain an L byte string,
|
||||
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
|
||||
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
|
||||
*/
|
||||
NdisZeroMemory(K0, SHA1_BLOCK_SIZE);
|
||||
if (KeyLen <= SHA1_BLOCK_SIZE)
|
||||
NdisMoveMemory(K0, Key, KeyLen);
|
||||
else
|
||||
RT_SHA1(Key, KeyLen, K0);
|
||||
/* End of if */
|
||||
NdisZeroMemory(&sha_ctx1, sizeof(SHA1_CTX_STRUC));
|
||||
NdisZeroMemory(&sha_ctx2, sizeof(SHA1_CTX_STRUC));
|
||||
/*
|
||||
* If the length of K = B(Block size): K0 = K.
|
||||
* If the length of K > B: hash K to obtain an L byte string,
|
||||
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
|
||||
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
|
||||
*/
|
||||
NdisZeroMemory(K0, SHA1_BLOCK_SIZE);
|
||||
if (KeyLen <= SHA1_BLOCK_SIZE)
|
||||
NdisMoveMemory(K0, Key, KeyLen);
|
||||
else
|
||||
RT_SHA1(Key, KeyLen, K0);
|
||||
/* End of if */
|
||||
|
||||
/* Exclusive-Or K0 with ipad */
|
||||
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
|
||||
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36;
|
||||
/* End of for */
|
||||
/* Exclusive-Or K0 with ipad */
|
||||
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
|
||||
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36;
|
||||
/* End of for */
|
||||
|
||||
RT_SHA1_Init(&sha_ctx1);
|
||||
/* H(K0^ipad) */
|
||||
SHA1_Append(&sha_ctx1, K0, sizeof(K0));
|
||||
/* H((K0^ipad)||text) */
|
||||
SHA1_Append(&sha_ctx1, Message, MessageLen);
|
||||
SHA1_End(&sha_ctx1, Digest);
|
||||
RT_SHA1_Init(&sha_ctx1);
|
||||
/* H(K0^ipad) */
|
||||
SHA1_Append(&sha_ctx1, K0, sizeof(K0));
|
||||
/* H((K0^ipad)||text) */
|
||||
SHA1_Append(&sha_ctx1, Message, MessageLen);
|
||||
SHA1_End(&sha_ctx1, Digest);
|
||||
|
||||
/* Exclusive-Or K0 with opad and remove ipad */
|
||||
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
|
||||
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36^0x5c;
|
||||
/* End of for */
|
||||
/* Exclusive-Or K0 with opad and remove ipad */
|
||||
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
|
||||
for (index = 0; index < SHA1_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36 ^ 0x5c;
|
||||
/* End of for */
|
||||
|
||||
RT_SHA1_Init(&sha_ctx2);
|
||||
/* H(K0^opad) */
|
||||
SHA1_Append(&sha_ctx2, K0, sizeof(K0));
|
||||
/* H( (K0^opad) || H((K0^ipad)||text) ) */
|
||||
SHA1_Append(&sha_ctx2, Digest, SHA1_DIGEST_SIZE);
|
||||
SHA1_End(&sha_ctx2, Digest);
|
||||
RT_SHA1_Init(&sha_ctx2);
|
||||
/* H(K0^opad) */
|
||||
SHA1_Append(&sha_ctx2, K0, sizeof(K0));
|
||||
/* H( (K0^opad) || H((K0^ipad)||text) ) */
|
||||
SHA1_Append(&sha_ctx2, Digest, SHA1_DIGEST_SIZE);
|
||||
SHA1_End(&sha_ctx2, Digest);
|
||||
|
||||
if (MACLen > SHA1_DIGEST_SIZE)
|
||||
NdisMoveMemory(MAC, Digest, SHA1_DIGEST_SIZE);
|
||||
else
|
||||
NdisMoveMemory(MAC, Digest, MACLen);
|
||||
} /* End of HMAC_SHA1 */
|
||||
if (MACLen > SHA1_DIGEST_SIZE)
|
||||
NdisMoveMemory(MAC, Digest, SHA1_DIGEST_SIZE);
|
||||
else
|
||||
NdisMoveMemory(MAC, Digest, MACLen);
|
||||
} /* End of HMAC_SHA1 */
|
||||
#endif /* HMAC_SHA1_SUPPORT */
|
||||
|
||||
#ifdef HMAC_MD5_SUPPORT
|
||||
|
@ -129,66 +125,63 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID HMAC_MD5(
|
||||
IN const UINT8 Key[],
|
||||
IN UINT KeyLen,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen,
|
||||
OUT UINT8 MAC[],
|
||||
IN UINT MACLen)
|
||||
VOID HMAC_MD5(IN const UINT8 Key[],
|
||||
IN UINT KeyLen,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen, OUT UINT8 MAC[], IN UINT MACLen)
|
||||
{
|
||||
MD5_CTX_STRUC md5_ctx1;
|
||||
MD5_CTX_STRUC md5_ctx2;
|
||||
UINT8 K0[MD5_BLOCK_SIZE];
|
||||
UINT8 Digest[MD5_DIGEST_SIZE];
|
||||
UINT index;
|
||||
MD5_CTX_STRUC md5_ctx1;
|
||||
MD5_CTX_STRUC md5_ctx2;
|
||||
UINT8 K0[MD5_BLOCK_SIZE];
|
||||
UINT8 Digest[MD5_DIGEST_SIZE];
|
||||
UINT index;
|
||||
|
||||
NdisZeroMemory(&md5_ctx1, sizeof(MD5_CTX_STRUC));
|
||||
NdisZeroMemory(&md5_ctx2, sizeof(MD5_CTX_STRUC));
|
||||
/*
|
||||
* If the length of K = B(Block size): K0 = K.
|
||||
* If the length of K > B: hash K to obtain an L byte string,
|
||||
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
|
||||
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
|
||||
*/
|
||||
NdisZeroMemory(K0, MD5_BLOCK_SIZE);
|
||||
if (KeyLen <= MD5_BLOCK_SIZE) {
|
||||
NdisMoveMemory(K0, Key, KeyLen);
|
||||
} else {
|
||||
RT_MD5(Key, KeyLen, K0);
|
||||
}
|
||||
NdisZeroMemory(&md5_ctx1, sizeof(MD5_CTX_STRUC));
|
||||
NdisZeroMemory(&md5_ctx2, sizeof(MD5_CTX_STRUC));
|
||||
/*
|
||||
* If the length of K = B(Block size): K0 = K.
|
||||
* If the length of K > B: hash K to obtain an L byte string,
|
||||
* then append (B-L) zeros to create a B-byte string K0 (i.e., K0 = H(K) || 00...00).
|
||||
* If the length of K < B: append zeros to the end of K to create a B-byte string K0
|
||||
*/
|
||||
NdisZeroMemory(K0, MD5_BLOCK_SIZE);
|
||||
if (KeyLen <= MD5_BLOCK_SIZE) {
|
||||
NdisMoveMemory(K0, Key, KeyLen);
|
||||
} else {
|
||||
RT_MD5(Key, KeyLen, K0);
|
||||
}
|
||||
|
||||
/* Exclusive-Or K0 with ipad */
|
||||
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
|
||||
for (index = 0; index < MD5_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36;
|
||||
/* End of for */
|
||||
/* Exclusive-Or K0 with ipad */
|
||||
/* ipad: Inner pad; the byte x¡¦36¡¦ repeated B times. */
|
||||
for (index = 0; index < MD5_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36;
|
||||
/* End of for */
|
||||
|
||||
MD5_Init(&md5_ctx1);
|
||||
/* H(K0^ipad) */
|
||||
MD5_Append(&md5_ctx1, K0, sizeof(K0));
|
||||
/* H((K0^ipad)||text) */
|
||||
MD5_Append(&md5_ctx1, Message, MessageLen);
|
||||
MD5_End(&md5_ctx1, Digest);
|
||||
MD5_Init(&md5_ctx1);
|
||||
/* H(K0^ipad) */
|
||||
MD5_Append(&md5_ctx1, K0, sizeof(K0));
|
||||
/* H((K0^ipad)||text) */
|
||||
MD5_Append(&md5_ctx1, Message, MessageLen);
|
||||
MD5_End(&md5_ctx1, Digest);
|
||||
|
||||
/* Exclusive-Or K0 with opad and remove ipad */
|
||||
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
|
||||
for (index = 0; index < MD5_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36^0x5c;
|
||||
/* End of for */
|
||||
/* Exclusive-Or K0 with opad and remove ipad */
|
||||
/* opad: Outer pad; the byte x¡¦5c¡¦ repeated B times. */
|
||||
for (index = 0; index < MD5_BLOCK_SIZE; index++)
|
||||
K0[index] ^= 0x36 ^ 0x5c;
|
||||
/* End of for */
|
||||
|
||||
MD5_Init(&md5_ctx2);
|
||||
/* H(K0^opad) */
|
||||
MD5_Append(&md5_ctx2, K0, sizeof(K0));
|
||||
/* H( (K0^opad) || H((K0^ipad)||text) ) */
|
||||
MD5_Append(&md5_ctx2, Digest, MD5_DIGEST_SIZE);
|
||||
MD5_End(&md5_ctx2, Digest);
|
||||
MD5_Init(&md5_ctx2);
|
||||
/* H(K0^opad) */
|
||||
MD5_Append(&md5_ctx2, K0, sizeof(K0));
|
||||
/* H( (K0^opad) || H((K0^ipad)||text) ) */
|
||||
MD5_Append(&md5_ctx2, Digest, MD5_DIGEST_SIZE);
|
||||
MD5_End(&md5_ctx2, Digest);
|
||||
|
||||
if (MACLen > MD5_DIGEST_SIZE)
|
||||
NdisMoveMemory(MAC, Digest, MD5_DIGEST_SIZE);
|
||||
else
|
||||
NdisMoveMemory(MAC, Digest, MACLen);
|
||||
} /* End of HMAC_SHA256 */
|
||||
if (MACLen > MD5_DIGEST_SIZE)
|
||||
NdisMoveMemory(MAC, Digest, MD5_DIGEST_SIZE);
|
||||
else
|
||||
NdisMoveMemory(MAC, Digest, MACLen);
|
||||
} /* End of HMAC_SHA256 */
|
||||
#endif /* HMAC_MD5_SUPPORT */
|
||||
|
||||
/* End of crypt_hmac.c */
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
#define ROTL(x,n,w) ((x << n) | (x >> (w - n)))
|
||||
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
|
||||
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
|
||||
|
||||
#define ROUND1(a, b, c, d, x, s, ac) { \
|
||||
(a) += F((b),(c),(d)) + (x) + (UINT32)(ac); \
|
||||
|
@ -59,11 +59,10 @@
|
|||
(a) += (b); \
|
||||
}
|
||||
static const UINT32 MD5_DefaultHashValue[4] = {
|
||||
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL
|
||||
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL
|
||||
};
|
||||
#endif /* MD5_SUPPORT */
|
||||
|
||||
|
||||
#ifdef MD5_SUPPORT
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -80,16 +79,14 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID MD5_Init (
|
||||
IN MD5_CTX_STRUC *pMD5_CTX)
|
||||
VOID MD5_Init(IN MD5_CTX_STRUC * pMD5_CTX)
|
||||
{
|
||||
NdisMoveMemory(pMD5_CTX->HashValue, MD5_DefaultHashValue,
|
||||
sizeof(MD5_DefaultHashValue));
|
||||
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
pMD5_CTX->BlockLen = 0;
|
||||
pMD5_CTX->MessageLen = 0;
|
||||
} /* End of MD5_Init */
|
||||
|
||||
NdisMoveMemory(pMD5_CTX->HashValue, MD5_DefaultHashValue,
|
||||
sizeof(MD5_DefaultHashValue));
|
||||
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
pMD5_CTX->BlockLen = 0;
|
||||
pMD5_CTX->MessageLen = 0;
|
||||
} /* End of MD5_Init */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -106,124 +103,122 @@ Note:
|
|||
T[i] := floor(abs(sin(i + 1)) * (2 pow 32)), i is number of round
|
||||
========================================================================
|
||||
*/
|
||||
VOID MD5_Hash (
|
||||
IN MD5_CTX_STRUC *pMD5_CTX)
|
||||
VOID MD5_Hash(IN MD5_CTX_STRUC * pMD5_CTX)
|
||||
{
|
||||
UINT32 X_i;
|
||||
UINT32 X[16];
|
||||
UINT32 a,b,c,d;
|
||||
UINT32 X_i;
|
||||
UINT32 X[16];
|
||||
UINT32 a, b, c, d;
|
||||
|
||||
/* Prepare the message schedule, {X_i} */
|
||||
NdisMoveMemory(X, pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
for (X_i = 0; X_i < 16; X_i++)
|
||||
X[X_i] = cpu2le32(X[X_i]); /* Endian Swap */
|
||||
/* End of for */
|
||||
/* Prepare the message schedule, {X_i} */
|
||||
NdisMoveMemory(X, pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
for (X_i = 0; X_i < 16; X_i++)
|
||||
X[X_i] = cpu2le32(X[X_i]); /* Endian Swap */
|
||||
/* End of for */
|
||||
|
||||
/* MD5 hash computation */
|
||||
/* Initialize the working variables */
|
||||
a = pMD5_CTX->HashValue[0];
|
||||
b = pMD5_CTX->HashValue[1];
|
||||
c = pMD5_CTX->HashValue[2];
|
||||
d = pMD5_CTX->HashValue[3];
|
||||
/* MD5 hash computation */
|
||||
/* Initialize the working variables */
|
||||
a = pMD5_CTX->HashValue[0];
|
||||
b = pMD5_CTX->HashValue[1];
|
||||
c = pMD5_CTX->HashValue[2];
|
||||
d = pMD5_CTX->HashValue[3];
|
||||
|
||||
/*
|
||||
* Round 1
|
||||
* Let [abcd k s i] denote the operation
|
||||
* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND1(a, b, c, d, X[ 0], 7, 0xd76aa478); /* 1 */
|
||||
ROUND1(d, a, b, c, X[ 1], 12, 0xe8c7b756); /* 2 */
|
||||
ROUND1(c, d, a, b, X[ 2], 17, 0x242070db); /* 3 */
|
||||
ROUND1(b, c, d, a, X[ 3], 22, 0xc1bdceee); /* 4 */
|
||||
ROUND1(a, b, c, d, X[ 4], 7, 0xf57c0faf); /* 5 */
|
||||
ROUND1(d, a, b, c, X[ 5], 12, 0x4787c62a); /* 6 */
|
||||
ROUND1(c, d, a, b, X[ 6], 17, 0xa8304613); /* 7 */
|
||||
ROUND1(b, c, d, a, X[ 7], 22, 0xfd469501); /* 8 */
|
||||
ROUND1(a, b, c, d, X[ 8], 7, 0x698098d8); /* 9 */
|
||||
ROUND1(d, a, b, c, X[ 9], 12, 0x8b44f7af); /* 10 */
|
||||
ROUND1(c, d, a, b, X[10], 17, 0xffff5bb1); /* 11 */
|
||||
ROUND1(b, c, d, a, X[11], 22, 0x895cd7be); /* 12 */
|
||||
ROUND1(a, b, c, d, X[12], 7, 0x6b901122); /* 13 */
|
||||
ROUND1(d, a, b, c, X[13], 12, 0xfd987193); /* 14 */
|
||||
ROUND1(c, d, a, b, X[14], 17, 0xa679438e); /* 15 */
|
||||
ROUND1(b, c, d, a, X[15], 22, 0x49b40821); /* 16 */
|
||||
/*
|
||||
* Round 1
|
||||
* Let [abcd k s i] denote the operation
|
||||
* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND1(a, b, c, d, X[0], 7, 0xd76aa478); /* 1 */
|
||||
ROUND1(d, a, b, c, X[1], 12, 0xe8c7b756); /* 2 */
|
||||
ROUND1(c, d, a, b, X[2], 17, 0x242070db); /* 3 */
|
||||
ROUND1(b, c, d, a, X[3], 22, 0xc1bdceee); /* 4 */
|
||||
ROUND1(a, b, c, d, X[4], 7, 0xf57c0faf); /* 5 */
|
||||
ROUND1(d, a, b, c, X[5], 12, 0x4787c62a); /* 6 */
|
||||
ROUND1(c, d, a, b, X[6], 17, 0xa8304613); /* 7 */
|
||||
ROUND1(b, c, d, a, X[7], 22, 0xfd469501); /* 8 */
|
||||
ROUND1(a, b, c, d, X[8], 7, 0x698098d8); /* 9 */
|
||||
ROUND1(d, a, b, c, X[9], 12, 0x8b44f7af); /* 10 */
|
||||
ROUND1(c, d, a, b, X[10], 17, 0xffff5bb1); /* 11 */
|
||||
ROUND1(b, c, d, a, X[11], 22, 0x895cd7be); /* 12 */
|
||||
ROUND1(a, b, c, d, X[12], 7, 0x6b901122); /* 13 */
|
||||
ROUND1(d, a, b, c, X[13], 12, 0xfd987193); /* 14 */
|
||||
ROUND1(c, d, a, b, X[14], 17, 0xa679438e); /* 15 */
|
||||
ROUND1(b, c, d, a, X[15], 22, 0x49b40821); /* 16 */
|
||||
|
||||
/*
|
||||
* Round 2
|
||||
* Let [abcd k s i] denote the operation
|
||||
* a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND2(a, b, c, d, X[ 1], 5, 0xf61e2562); /* 17 */
|
||||
ROUND2(d, a, b, c, X[ 6], 9, 0xc040b340); /* 18 */
|
||||
ROUND2(c, d, a, b, X[11], 14, 0x265e5a51); /* 19 */
|
||||
ROUND2(b, c, d, a, X[ 0], 20, 0xe9b6c7aa); /* 20 */
|
||||
ROUND2(a, b, c, d, X[ 5], 5, 0xd62f105d); /* 21 */
|
||||
ROUND2(d, a, b, c, X[10], 9, 0x2441453); /* 22 */
|
||||
ROUND2(c, d, a, b, X[15], 14, 0xd8a1e681); /* 23 */
|
||||
ROUND2(b, c, d, a, X[ 4], 20, 0xe7d3fbc8); /* 24 */
|
||||
ROUND2(a, b, c, d, X[ 9], 5, 0x21e1cde6); /* 25 */
|
||||
ROUND2(d, a, b, c, X[14], 9, 0xc33707d6); /* 26 */
|
||||
ROUND2(c, d, a, b, X[ 3], 14, 0xf4d50d87); /* 27 */
|
||||
ROUND2(b, c, d, a, X[ 8], 20, 0x455a14ed); /* 28 */
|
||||
ROUND2(a, b, c, d, X[13], 5, 0xa9e3e905); /* 29 */
|
||||
ROUND2(d, a, b, c, X[ 2], 9, 0xfcefa3f8); /* 30 */
|
||||
ROUND2(c, d, a, b, X[ 7], 14, 0x676f02d9); /* 31 */
|
||||
ROUND2(b, c, d, a, X[12], 20, 0x8d2a4c8a); /* 32 */
|
||||
/*
|
||||
* Round 2
|
||||
* Let [abcd k s i] denote the operation
|
||||
* a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND2(a, b, c, d, X[1], 5, 0xf61e2562); /* 17 */
|
||||
ROUND2(d, a, b, c, X[6], 9, 0xc040b340); /* 18 */
|
||||
ROUND2(c, d, a, b, X[11], 14, 0x265e5a51); /* 19 */
|
||||
ROUND2(b, c, d, a, X[0], 20, 0xe9b6c7aa); /* 20 */
|
||||
ROUND2(a, b, c, d, X[5], 5, 0xd62f105d); /* 21 */
|
||||
ROUND2(d, a, b, c, X[10], 9, 0x2441453); /* 22 */
|
||||
ROUND2(c, d, a, b, X[15], 14, 0xd8a1e681); /* 23 */
|
||||
ROUND2(b, c, d, a, X[4], 20, 0xe7d3fbc8); /* 24 */
|
||||
ROUND2(a, b, c, d, X[9], 5, 0x21e1cde6); /* 25 */
|
||||
ROUND2(d, a, b, c, X[14], 9, 0xc33707d6); /* 26 */
|
||||
ROUND2(c, d, a, b, X[3], 14, 0xf4d50d87); /* 27 */
|
||||
ROUND2(b, c, d, a, X[8], 20, 0x455a14ed); /* 28 */
|
||||
ROUND2(a, b, c, d, X[13], 5, 0xa9e3e905); /* 29 */
|
||||
ROUND2(d, a, b, c, X[2], 9, 0xfcefa3f8); /* 30 */
|
||||
ROUND2(c, d, a, b, X[7], 14, 0x676f02d9); /* 31 */
|
||||
ROUND2(b, c, d, a, X[12], 20, 0x8d2a4c8a); /* 32 */
|
||||
|
||||
/*
|
||||
* Round 3
|
||||
* Let [abcd k s t] denote the operation
|
||||
* a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND3(a, b, c, d, X[ 5], 4, 0xfffa3942); /* 33 */
|
||||
ROUND3(d, a, b, c, X[ 8], 11, 0x8771f681); /* 34 */
|
||||
ROUND3(c, d, a, b, X[11], 16, 0x6d9d6122); /* 35 */
|
||||
ROUND3(b, c, d, a, X[14], 23, 0xfde5380c); /* 36 */
|
||||
ROUND3(a, b, c, d, X[ 1], 4, 0xa4beea44); /* 37 */
|
||||
ROUND3(d, a, b, c, X[ 4], 11, 0x4bdecfa9); /* 38 */
|
||||
ROUND3(c, d, a, b, X[ 7], 16, 0xf6bb4b60); /* 39 */
|
||||
ROUND3(b, c, d, a, X[10], 23, 0xbebfbc70); /* 40 */
|
||||
ROUND3(a, b, c, d, X[13], 4, 0x289b7ec6); /* 41 */
|
||||
ROUND3(d, a, b, c, X[ 0], 11, 0xeaa127fa); /* 42 */
|
||||
ROUND3(c, d, a, b, X[ 3], 16, 0xd4ef3085); /* 43 */
|
||||
ROUND3(b, c, d, a, X[ 6], 23, 0x4881d05); /* 44 */
|
||||
ROUND3(a, b, c, d, X[ 9], 4, 0xd9d4d039); /* 45 */
|
||||
ROUND3(d, a, b, c, X[12], 11, 0xe6db99e5); /* 46 */
|
||||
ROUND3(c, d, a, b, X[15], 16, 0x1fa27cf8); /* 47 */
|
||||
ROUND3(b, c, d, a, X[ 2], 23, 0xc4ac5665); /* 48 */
|
||||
/*
|
||||
* Round 3
|
||||
* Let [abcd k s t] denote the operation
|
||||
* a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND3(a, b, c, d, X[5], 4, 0xfffa3942); /* 33 */
|
||||
ROUND3(d, a, b, c, X[8], 11, 0x8771f681); /* 34 */
|
||||
ROUND3(c, d, a, b, X[11], 16, 0x6d9d6122); /* 35 */
|
||||
ROUND3(b, c, d, a, X[14], 23, 0xfde5380c); /* 36 */
|
||||
ROUND3(a, b, c, d, X[1], 4, 0xa4beea44); /* 37 */
|
||||
ROUND3(d, a, b, c, X[4], 11, 0x4bdecfa9); /* 38 */
|
||||
ROUND3(c, d, a, b, X[7], 16, 0xf6bb4b60); /* 39 */
|
||||
ROUND3(b, c, d, a, X[10], 23, 0xbebfbc70); /* 40 */
|
||||
ROUND3(a, b, c, d, X[13], 4, 0x289b7ec6); /* 41 */
|
||||
ROUND3(d, a, b, c, X[0], 11, 0xeaa127fa); /* 42 */
|
||||
ROUND3(c, d, a, b, X[3], 16, 0xd4ef3085); /* 43 */
|
||||
ROUND3(b, c, d, a, X[6], 23, 0x4881d05); /* 44 */
|
||||
ROUND3(a, b, c, d, X[9], 4, 0xd9d4d039); /* 45 */
|
||||
ROUND3(d, a, b, c, X[12], 11, 0xe6db99e5); /* 46 */
|
||||
ROUND3(c, d, a, b, X[15], 16, 0x1fa27cf8); /* 47 */
|
||||
ROUND3(b, c, d, a, X[2], 23, 0xc4ac5665); /* 48 */
|
||||
|
||||
/*
|
||||
* Round 4
|
||||
* Let [abcd k s t] denote the operation
|
||||
* a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND4(a, b, c, d, X[ 0], 6, 0xf4292244); /* 49 */
|
||||
ROUND4(d, a, b, c, X[ 7], 10, 0x432aff97); /* 50 */
|
||||
ROUND4(c, d, a, b, X[14], 15, 0xab9423a7); /* 51 */
|
||||
ROUND4(b, c, d, a, X[ 5], 21, 0xfc93a039); /* 52 */
|
||||
ROUND4(a, b, c, d, X[12], 6, 0x655b59c3); /* 53 */
|
||||
ROUND4(d, a, b, c, X[ 3], 10, 0x8f0ccc92); /* 54 */
|
||||
ROUND4(c, d, a, b, X[10], 15, 0xffeff47d); /* 55 */
|
||||
ROUND4(b, c, d, a, X[ 1], 21, 0x85845dd1); /* 56 */
|
||||
ROUND4(a, b, c, d, X[ 8], 6, 0x6fa87e4f); /* 57 */
|
||||
ROUND4(d, a, b, c, X[15], 10, 0xfe2ce6e0); /* 58 */
|
||||
ROUND4(c, d, a, b, X[ 6], 15, 0xa3014314); /* 59 */
|
||||
ROUND4(b, c, d, a, X[13], 21, 0x4e0811a1); /* 60 */
|
||||
ROUND4(a, b, c, d, X[ 4], 6, 0xf7537e82); /* 61 */
|
||||
ROUND4(d, a, b, c, X[11], 10, 0xbd3af235); /* 62 */
|
||||
ROUND4(c, d, a, b, X[ 2], 15, 0x2ad7d2bb); /* 63 */
|
||||
ROUND4(b, c, d, a, X[ 9], 21, 0xeb86d391); /* 64 */
|
||||
/*
|
||||
* Round 4
|
||||
* Let [abcd k s t] denote the operation
|
||||
* a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s)
|
||||
*/
|
||||
ROUND4(a, b, c, d, X[0], 6, 0xf4292244); /* 49 */
|
||||
ROUND4(d, a, b, c, X[7], 10, 0x432aff97); /* 50 */
|
||||
ROUND4(c, d, a, b, X[14], 15, 0xab9423a7); /* 51 */
|
||||
ROUND4(b, c, d, a, X[5], 21, 0xfc93a039); /* 52 */
|
||||
ROUND4(a, b, c, d, X[12], 6, 0x655b59c3); /* 53 */
|
||||
ROUND4(d, a, b, c, X[3], 10, 0x8f0ccc92); /* 54 */
|
||||
ROUND4(c, d, a, b, X[10], 15, 0xffeff47d); /* 55 */
|
||||
ROUND4(b, c, d, a, X[1], 21, 0x85845dd1); /* 56 */
|
||||
ROUND4(a, b, c, d, X[8], 6, 0x6fa87e4f); /* 57 */
|
||||
ROUND4(d, a, b, c, X[15], 10, 0xfe2ce6e0); /* 58 */
|
||||
ROUND4(c, d, a, b, X[6], 15, 0xa3014314); /* 59 */
|
||||
ROUND4(b, c, d, a, X[13], 21, 0x4e0811a1); /* 60 */
|
||||
ROUND4(a, b, c, d, X[4], 6, 0xf7537e82); /* 61 */
|
||||
ROUND4(d, a, b, c, X[11], 10, 0xbd3af235); /* 62 */
|
||||
ROUND4(c, d, a, b, X[2], 15, 0x2ad7d2bb); /* 63 */
|
||||
ROUND4(b, c, d, a, X[9], 21, 0xeb86d391); /* 64 */
|
||||
|
||||
/* Compute the i^th intermediate hash value H^(i) */
|
||||
pMD5_CTX->HashValue[0] += a;
|
||||
pMD5_CTX->HashValue[1] += b;
|
||||
pMD5_CTX->HashValue[2] += c;
|
||||
pMD5_CTX->HashValue[3] += d;
|
||||
|
||||
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
pMD5_CTX->BlockLen = 0;
|
||||
} /* End of MD5_Hash */
|
||||
/* Compute the i^th intermediate hash value H^(i) */
|
||||
pMD5_CTX->HashValue[0] += a;
|
||||
pMD5_CTX->HashValue[1] += b;
|
||||
pMD5_CTX->HashValue[2] += c;
|
||||
pMD5_CTX->HashValue[3] += d;
|
||||
|
||||
NdisZeroMemory(pMD5_CTX->Block, MD5_BLOCK_SIZE);
|
||||
pMD5_CTX->BlockLen = 0;
|
||||
} /* End of MD5_Hash */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -243,34 +238,30 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID MD5_Append (
|
||||
IN MD5_CTX_STRUC *pMD5_CTX,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen)
|
||||
VOID MD5_Append(IN MD5_CTX_STRUC * pMD5_CTX,
|
||||
IN const UINT8 Message[], IN UINT MessageLen)
|
||||
{
|
||||
UINT appendLen = 0;
|
||||
UINT diffLen = 0;
|
||||
|
||||
while (appendLen != MessageLen) {
|
||||
diffLen = MessageLen - appendLen;
|
||||
if ((pMD5_CTX->BlockLen + diffLen) < MD5_BLOCK_SIZE) {
|
||||
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
|
||||
Message + appendLen, diffLen);
|
||||
pMD5_CTX->BlockLen += diffLen;
|
||||
appendLen += diffLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
|
||||
Message + appendLen, MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
|
||||
appendLen += (MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
|
||||
pMD5_CTX->BlockLen = MD5_BLOCK_SIZE;
|
||||
MD5_Hash(pMD5_CTX);
|
||||
} /* End of if */
|
||||
} /* End of while */
|
||||
pMD5_CTX->MessageLen += MessageLen;
|
||||
} /* End of MD5_Append */
|
||||
UINT appendLen = 0;
|
||||
UINT diffLen = 0;
|
||||
|
||||
while (appendLen != MessageLen) {
|
||||
diffLen = MessageLen - appendLen;
|
||||
if ((pMD5_CTX->BlockLen + diffLen) < MD5_BLOCK_SIZE) {
|
||||
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
|
||||
Message + appendLen, diffLen);
|
||||
pMD5_CTX->BlockLen += diffLen;
|
||||
appendLen += diffLen;
|
||||
} else {
|
||||
NdisMoveMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen,
|
||||
Message + appendLen,
|
||||
MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
|
||||
appendLen += (MD5_BLOCK_SIZE - pMD5_CTX->BlockLen);
|
||||
pMD5_CTX->BlockLen = MD5_BLOCK_SIZE;
|
||||
MD5_Hash(pMD5_CTX);
|
||||
} /* End of if */
|
||||
} /* End of while */
|
||||
pMD5_CTX->MessageLen += MessageLen;
|
||||
} /* End of MD5_Append */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -289,34 +280,32 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID MD5_End (
|
||||
IN MD5_CTX_STRUC *pMD5_CTX,
|
||||
OUT UINT8 DigestMessage[])
|
||||
VOID MD5_End(IN MD5_CTX_STRUC * pMD5_CTX, OUT UINT8 DigestMessage[])
|
||||
{
|
||||
UINT index;
|
||||
UINT64 message_length_bits;
|
||||
UINT index;
|
||||
UINT64 message_length_bits;
|
||||
|
||||
/* append 1 bits to end of the message */
|
||||
NdisFillMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen, 1, 0x80);
|
||||
/* append 1 bits to end of the message */
|
||||
NdisFillMemory(pMD5_CTX->Block + pMD5_CTX->BlockLen, 1, 0x80);
|
||||
|
||||
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
|
||||
if (pMD5_CTX->BlockLen > 55)
|
||||
MD5_Hash(pMD5_CTX);
|
||||
/* End of if */
|
||||
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
|
||||
if (pMD5_CTX->BlockLen > 55)
|
||||
MD5_Hash(pMD5_CTX);
|
||||
/* End of if */
|
||||
|
||||
/* Append the length of message in rightmost 64 bits */
|
||||
message_length_bits = pMD5_CTX->MessageLen*8;
|
||||
message_length_bits = cpu2le64(message_length_bits);
|
||||
NdisMoveMemory(&pMD5_CTX->Block[56], &message_length_bits, 8);
|
||||
MD5_Hash(pMD5_CTX);
|
||||
|
||||
/* Return message digest, transform the UINT32 hash value to bytes */
|
||||
for (index = 0; index < 4;index++)
|
||||
pMD5_CTX->HashValue[index] = cpu2le32(pMD5_CTX->HashValue[index]);
|
||||
/* End of for */
|
||||
NdisMoveMemory(DigestMessage, pMD5_CTX->HashValue, MD5_DIGEST_SIZE);
|
||||
} /* End of MD5_End */
|
||||
/* Append the length of message in rightmost 64 bits */
|
||||
message_length_bits = pMD5_CTX->MessageLen * 8;
|
||||
message_length_bits = cpu2le64(message_length_bits);
|
||||
NdisMoveMemory(&pMD5_CTX->Block[56], &message_length_bits, 8);
|
||||
MD5_Hash(pMD5_CTX);
|
||||
|
||||
/* Return message digest, transform the UINT32 hash value to bytes */
|
||||
for (index = 0; index < 4; index++)
|
||||
pMD5_CTX->HashValue[index] =
|
||||
cpu2le32(pMD5_CTX->HashValue[index]);
|
||||
/* End of for */
|
||||
NdisMoveMemory(DigestMessage, pMD5_CTX->HashValue, MD5_DIGEST_SIZE);
|
||||
} /* End of MD5_End */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -334,18 +323,16 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID RT_MD5 (
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen,
|
||||
OUT UINT8 DigestMessage[])
|
||||
VOID RT_MD5(IN const UINT8 Message[],
|
||||
IN UINT MessageLen, OUT UINT8 DigestMessage[])
|
||||
{
|
||||
MD5_CTX_STRUC md5_ctx;
|
||||
MD5_CTX_STRUC md5_ctx;
|
||||
|
||||
NdisZeroMemory(&md5_ctx, sizeof(MD5_CTX_STRUC));
|
||||
MD5_Init(&md5_ctx);
|
||||
MD5_Append(&md5_ctx, Message, MessageLen);
|
||||
MD5_End(&md5_ctx, DigestMessage);
|
||||
} /* End of RT_MD5 */
|
||||
NdisZeroMemory(&md5_ctx, sizeof(MD5_CTX_STRUC));
|
||||
MD5_Init(&md5_ctx);
|
||||
MD5_Append(&md5_ctx, Message, MessageLen);
|
||||
MD5_End(&md5_ctx, DigestMessage);
|
||||
} /* End of RT_MD5 */
|
||||
|
||||
#endif /* MD5_SUPPORT */
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
#include "../crypt_sha2.h"
|
||||
|
||||
/* Basic operations */
|
||||
#define SHR(x,n) (x >> n) /* SHR(x)^n, right shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTR(x,n,w) ((x >> n) | (x << (w - n))) /* ROTR(x)^n, circular right shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTL(x,n,w) ((x << n) | (x >> (w - n))) /* ROTL(x)^n, circular left shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTR32(x,n) ROTR(x,n,32) /* 32 bits word */
|
||||
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
|
||||
#define SHR(x,n) (x >> n) /* SHR(x)^n, right shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTR(x,n,w) ((x >> n) | (x << (w - n))) /* ROTR(x)^n, circular right shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTL(x,n,w) ((x << n) | (x >> (w - n))) /* ROTL(x)^n, circular left shift n bits , x is w-bit word, 0 <= n <= w */
|
||||
#define ROTR32(x,n) ROTR(x,n,32) /* 32 bits word */
|
||||
#define ROTL32(x,n) ROTL(x,n,32) /* 32 bits word */
|
||||
|
||||
/* Basic functions */
|
||||
#define Ch(x,y,z) ((x & y) ^ ((~x) & z))
|
||||
|
@ -42,10 +42,11 @@
|
|||
/* SHA1 constants */
|
||||
#define SHA1_MASK 0x0000000f
|
||||
static const UINT32 SHA1_K[4] = {
|
||||
0x5a827999UL, 0x6ed9eba1UL, 0x8f1bbcdcUL, 0xca62c1d6UL
|
||||
0x5a827999UL, 0x6ed9eba1UL, 0x8f1bbcdcUL, 0xca62c1d6UL
|
||||
};
|
||||
|
||||
static const UINT32 SHA1_DefaultHashValue[5] = {
|
||||
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL
|
||||
0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -63,16 +64,14 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID RT_SHA1_Init (
|
||||
IN SHA1_CTX_STRUC *pSHA_CTX)
|
||||
VOID RT_SHA1_Init(IN SHA1_CTX_STRUC * pSHA_CTX)
|
||||
{
|
||||
NdisMoveMemory(pSHA_CTX->HashValue, SHA1_DefaultHashValue,
|
||||
sizeof(SHA1_DefaultHashValue));
|
||||
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
pSHA_CTX->MessageLen = 0;
|
||||
pSHA_CTX->BlockLen = 0;
|
||||
} /* End of RT_SHA1_Init */
|
||||
|
||||
NdisMoveMemory(pSHA_CTX->HashValue, SHA1_DefaultHashValue,
|
||||
sizeof(SHA1_DefaultHashValue));
|
||||
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
pSHA_CTX->MessageLen = 0;
|
||||
pSHA_CTX->BlockLen = 0;
|
||||
} /* End of RT_SHA1_Init */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -89,67 +88,67 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID SHA1_Hash (
|
||||
IN SHA1_CTX_STRUC *pSHA_CTX)
|
||||
VOID SHA1_Hash(IN SHA1_CTX_STRUC * pSHA_CTX)
|
||||
{
|
||||
UINT32 W_i,t,s;
|
||||
UINT32 W[16];
|
||||
UINT32 a,b,c,d,e,T,f_t = 0;
|
||||
UINT32 W_i, t, s;
|
||||
UINT32 W[16];
|
||||
UINT32 a, b, c, d, e, T, f_t = 0;
|
||||
|
||||
/* Prepare the message schedule, {W_i}, 0 < t < 15 */
|
||||
NdisMoveMemory(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
for (W_i = 0; W_i < 16; W_i++)
|
||||
W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
|
||||
/* End of for */
|
||||
/* Prepare the message schedule, {W_i}, 0 < t < 15 */
|
||||
NdisMoveMemory(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
for (W_i = 0; W_i < 16; W_i++)
|
||||
W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
|
||||
/* End of for */
|
||||
|
||||
/* SHA256 hash computation */
|
||||
/* Initialize the working variables */
|
||||
a = pSHA_CTX->HashValue[0];
|
||||
b = pSHA_CTX->HashValue[1];
|
||||
c = pSHA_CTX->HashValue[2];
|
||||
d = pSHA_CTX->HashValue[3];
|
||||
e = pSHA_CTX->HashValue[4];
|
||||
/* SHA256 hash computation */
|
||||
/* Initialize the working variables */
|
||||
a = pSHA_CTX->HashValue[0];
|
||||
b = pSHA_CTX->HashValue[1];
|
||||
c = pSHA_CTX->HashValue[2];
|
||||
d = pSHA_CTX->HashValue[3];
|
||||
e = pSHA_CTX->HashValue[4];
|
||||
|
||||
/* 80 rounds */
|
||||
for (t = 0;t < 80;t++) {
|
||||
s = t & SHA1_MASK;
|
||||
if (t > 15) { /* Prepare the message schedule, {W_i}, 16 < t < 79 */
|
||||
W[s] = (W[(s+13) & SHA1_MASK]) ^ (W[(s+8) & SHA1_MASK]) ^ (W[(s+2) & SHA1_MASK]) ^ W[s];
|
||||
W[s] = ROTL32(W[s],1);
|
||||
} /* End of if */
|
||||
switch (t / 20) {
|
||||
case 0:
|
||||
f_t = Ch(b,c,d);
|
||||
break;
|
||||
case 1:
|
||||
f_t = Parity(b,c,d);
|
||||
break;
|
||||
case 2:
|
||||
f_t = Maj(b,c,d);
|
||||
break;
|
||||
case 3:
|
||||
f_t = Parity(b,c,d);
|
||||
break;
|
||||
} /* End of switch */
|
||||
T = ROTL32(a,5) + f_t + e + SHA1_K[t / 20] + W[s];
|
||||
e = d;
|
||||
d = c;
|
||||
c = ROTL32(b,30);
|
||||
b = a;
|
||||
a = T;
|
||||
} /* End of for */
|
||||
/* 80 rounds */
|
||||
for (t = 0; t < 80; t++) {
|
||||
s = t & SHA1_MASK;
|
||||
if (t > 15) { /* Prepare the message schedule, {W_i}, 16 < t < 79 */
|
||||
W[s] =
|
||||
(W[(s + 13) & SHA1_MASK]) ^ (W[(s + 8) & SHA1_MASK])
|
||||
^ (W[(s + 2) & SHA1_MASK]) ^ W[s];
|
||||
W[s] = ROTL32(W[s], 1);
|
||||
} /* End of if */
|
||||
switch (t / 20) {
|
||||
case 0:
|
||||
f_t = Ch(b, c, d);
|
||||
break;
|
||||
case 1:
|
||||
f_t = Parity(b, c, d);
|
||||
break;
|
||||
case 2:
|
||||
f_t = Maj(b, c, d);
|
||||
break;
|
||||
case 3:
|
||||
f_t = Parity(b, c, d);
|
||||
break;
|
||||
} /* End of switch */
|
||||
T = ROTL32(a, 5) + f_t + e + SHA1_K[t / 20] + W[s];
|
||||
e = d;
|
||||
d = c;
|
||||
c = ROTL32(b, 30);
|
||||
b = a;
|
||||
a = T;
|
||||
} /* End of for */
|
||||
|
||||
/* Compute the i^th intermediate hash value H^(i) */
|
||||
pSHA_CTX->HashValue[0] += a;
|
||||
pSHA_CTX->HashValue[1] += b;
|
||||
pSHA_CTX->HashValue[2] += c;
|
||||
pSHA_CTX->HashValue[3] += d;
|
||||
pSHA_CTX->HashValue[4] += e;
|
||||
|
||||
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
pSHA_CTX->BlockLen = 0;
|
||||
} /* End of SHA1_Hash */
|
||||
/* Compute the i^th intermediate hash value H^(i) */
|
||||
pSHA_CTX->HashValue[0] += a;
|
||||
pSHA_CTX->HashValue[1] += b;
|
||||
pSHA_CTX->HashValue[2] += c;
|
||||
pSHA_CTX->HashValue[3] += d;
|
||||
pSHA_CTX->HashValue[4] += e;
|
||||
|
||||
NdisZeroMemory(pSHA_CTX->Block, SHA1_BLOCK_SIZE);
|
||||
pSHA_CTX->BlockLen = 0;
|
||||
} /* End of SHA1_Hash */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -169,34 +168,30 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID SHA1_Append (
|
||||
IN SHA1_CTX_STRUC *pSHA_CTX,
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen)
|
||||
VOID SHA1_Append(IN SHA1_CTX_STRUC * pSHA_CTX,
|
||||
IN const UINT8 Message[], IN UINT MessageLen)
|
||||
{
|
||||
UINT appendLen = 0;
|
||||
UINT diffLen = 0;
|
||||
|
||||
while (appendLen != MessageLen) {
|
||||
diffLen = MessageLen - appendLen;
|
||||
if ((pSHA_CTX->BlockLen + diffLen) < SHA1_BLOCK_SIZE) {
|
||||
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
|
||||
Message + appendLen, diffLen);
|
||||
pSHA_CTX->BlockLen += diffLen;
|
||||
appendLen += diffLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
|
||||
Message + appendLen, SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
|
||||
appendLen += (SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
|
||||
pSHA_CTX->BlockLen = SHA1_BLOCK_SIZE;
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
} /* End of if */
|
||||
} /* End of while */
|
||||
pSHA_CTX->MessageLen += MessageLen;
|
||||
} /* End of SHA1_Append */
|
||||
UINT appendLen = 0;
|
||||
UINT diffLen = 0;
|
||||
|
||||
while (appendLen != MessageLen) {
|
||||
diffLen = MessageLen - appendLen;
|
||||
if ((pSHA_CTX->BlockLen + diffLen) < SHA1_BLOCK_SIZE) {
|
||||
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
|
||||
Message + appendLen, diffLen);
|
||||
pSHA_CTX->BlockLen += diffLen;
|
||||
appendLen += diffLen;
|
||||
} else {
|
||||
NdisMoveMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen,
|
||||
Message + appendLen,
|
||||
SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
|
||||
appendLen += (SHA1_BLOCK_SIZE - pSHA_CTX->BlockLen);
|
||||
pSHA_CTX->BlockLen = SHA1_BLOCK_SIZE;
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
} /* End of if */
|
||||
} /* End of while */
|
||||
pSHA_CTX->MessageLen += MessageLen;
|
||||
} /* End of SHA1_Append */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -215,34 +210,32 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID SHA1_End (
|
||||
IN SHA1_CTX_STRUC *pSHA_CTX,
|
||||
OUT UINT8 DigestMessage[])
|
||||
VOID SHA1_End(IN SHA1_CTX_STRUC * pSHA_CTX, OUT UINT8 DigestMessage[])
|
||||
{
|
||||
UINT index;
|
||||
UINT64 message_length_bits;
|
||||
UINT index;
|
||||
UINT64 message_length_bits;
|
||||
|
||||
/* Append bit 1 to end of the message */
|
||||
NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
|
||||
/* Append bit 1 to end of the message */
|
||||
NdisFillMemory(pSHA_CTX->Block + pSHA_CTX->BlockLen, 1, 0x80);
|
||||
|
||||
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
|
||||
if (pSHA_CTX->BlockLen > 55)
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
/* End of if */
|
||||
/* 55 = 64 - 8 - 1: append 1 bit(1 byte) and message length (8 bytes) */
|
||||
if (pSHA_CTX->BlockLen > 55)
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
/* End of if */
|
||||
|
||||
/* Append the length of message in rightmost 64 bits */
|
||||
message_length_bits = pSHA_CTX->MessageLen*8;
|
||||
message_length_bits = cpu2be64(message_length_bits);
|
||||
NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
|
||||
/* Return message digest, transform the UINT32 hash value to bytes */
|
||||
for (index = 0; index < 5;index++)
|
||||
pSHA_CTX->HashValue[index] = cpu2be32(pSHA_CTX->HashValue[index]);
|
||||
/* End of for */
|
||||
NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA1_DIGEST_SIZE);
|
||||
} /* End of SHA1_End */
|
||||
/* Append the length of message in rightmost 64 bits */
|
||||
message_length_bits = pSHA_CTX->MessageLen * 8;
|
||||
message_length_bits = cpu2be64(message_length_bits);
|
||||
NdisMoveMemory(&pSHA_CTX->Block[56], &message_length_bits, 8);
|
||||
SHA1_Hash(pSHA_CTX);
|
||||
|
||||
/* Return message digest, transform the UINT32 hash value to bytes */
|
||||
for (index = 0; index < 5; index++)
|
||||
pSHA_CTX->HashValue[index] =
|
||||
cpu2be32(pSHA_CTX->HashValue[index]);
|
||||
/* End of for */
|
||||
NdisMoveMemory(DigestMessage, pSHA_CTX->HashValue, SHA1_DIGEST_SIZE);
|
||||
} /* End of SHA1_End */
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -260,19 +253,17 @@ Note:
|
|||
None
|
||||
========================================================================
|
||||
*/
|
||||
VOID RT_SHA1 (
|
||||
IN const UINT8 Message[],
|
||||
IN UINT MessageLen,
|
||||
OUT UINT8 DigestMessage[])
|
||||
VOID RT_SHA1(IN const UINT8 Message[],
|
||||
IN UINT MessageLen, OUT UINT8 DigestMessage[])
|
||||
{
|
||||
|
||||
SHA1_CTX_STRUC sha_ctx;
|
||||
SHA1_CTX_STRUC sha_ctx;
|
||||
|
||||
NdisZeroMemory(&sha_ctx, sizeof(SHA1_CTX_STRUC));
|
||||
RT_SHA1_Init(&sha_ctx);
|
||||
SHA1_Append(&sha_ctx, Message, MessageLen);
|
||||
SHA1_End(&sha_ctx, DigestMessage);
|
||||
} /* End of RT_SHA1 */
|
||||
NdisZeroMemory(&sha_ctx, sizeof(SHA1_CTX_STRUC));
|
||||
RT_SHA1_Init(&sha_ctx);
|
||||
SHA1_Append(&sha_ctx, Message, MessageLen);
|
||||
SHA1_End(&sha_ctx, DigestMessage);
|
||||
} /* End of RT_SHA1 */
|
||||
#endif /* SHA1_SUPPORT */
|
||||
|
||||
/* End of crypt_sha2.c */
|
||||
|
|
|
@ -52,17 +52,13 @@
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
BOOLEAN RadarChannelCheck(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR Ch)
|
||||
BOOLEAN RadarChannelCheck(IN PRTMP_ADAPTER pAd, IN UCHAR Ch)
|
||||
{
|
||||
INT i;
|
||||
INT i;
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
for (i=0; i<pAd->ChannelListNum; i++)
|
||||
{
|
||||
if (Ch == pAd->ChannelList[i].Channel)
|
||||
{
|
||||
for (i = 0; i < pAd->ChannelListNum; i++) {
|
||||
if (Ch == pAd->ChannelList[i].Channel) {
|
||||
result = pAd->ChannelList[i].DfsReq;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,37 +35,30 @@
|
|||
-------- ---------- ----------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
|
||||
#define EFUSE_USAGE_MAP_START 0x2d0
|
||||
#define EFUSE_USAGE_MAP_END 0x2fc
|
||||
#define EFUSE_USAGE_MAP_SIZE 45
|
||||
|
||||
|
||||
|
||||
#define EFUSE_EEPROM_DEFULT_FILE "RT30xxEEPROM.bin"
|
||||
#define MAX_EEPROM_BIN_FILE_SIZE 1024
|
||||
|
||||
|
||||
|
||||
#define EFUSE_TAG 0x2fe
|
||||
|
||||
typedef union _EFUSE_CTRL_STRUC {
|
||||
struct {
|
||||
UINT32 EFSROM_AOUT:6;
|
||||
UINT32 EFSROM_MODE:2;
|
||||
UINT32 EFSROM_LDO_OFF_TIME:6;
|
||||
UINT32 EFSROM_LDO_ON_TIME:2;
|
||||
UINT32 EFSROM_AIN:10;
|
||||
UINT32 RESERVED:4;
|
||||
UINT32 EFSROM_KICK:1;
|
||||
UINT32 SEL_EFUSE:1;
|
||||
} field;
|
||||
UINT32 word;
|
||||
} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
|
||||
typedef union _EFUSE_CTRL_STRUC {
|
||||
struct {
|
||||
UINT32 EFSROM_AOUT:6;
|
||||
UINT32 EFSROM_MODE:2;
|
||||
UINT32 EFSROM_LDO_OFF_TIME:6;
|
||||
UINT32 EFSROM_LDO_ON_TIME:2;
|
||||
UINT32 EFSROM_AIN:10;
|
||||
UINT32 RESERVED:4;
|
||||
UINT32 EFSROM_KICK:1;
|
||||
UINT32 SEL_EFUSE:1;
|
||||
} field;
|
||||
UINT32 word;
|
||||
} EFUSE_CTRL_STRUC, *PEFUSE_CTRL_STRUC;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -80,16 +73,13 @@ typedef union _EFUSE_CTRL_STRUC {
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
UCHAR eFuseReadRegisters(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset,
|
||||
IN USHORT Length,
|
||||
OUT USHORT* pData)
|
||||
UCHAR eFuseReadRegisters(IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset, IN USHORT Length, OUT USHORT * pData)
|
||||
{
|
||||
EFUSE_CTRL_STRUC eFuseCtrlStruc;
|
||||
int i;
|
||||
USHORT efuseDataOffset;
|
||||
UINT32 data;
|
||||
EFUSE_CTRL_STRUC eFuseCtrlStruc;
|
||||
int i;
|
||||
USHORT efuseDataOffset;
|
||||
UINT32 data;
|
||||
|
||||
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
|
||||
|
||||
|
@ -108,12 +98,10 @@ UCHAR eFuseReadRegisters(
|
|||
|
||||
//Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
|
||||
i = 0;
|
||||
while(i < 500)
|
||||
{
|
||||
while (i < 500) {
|
||||
//rtmp.HwMemoryReadDword(EFUSE_CTRL, (DWORD *) &eFuseCtrlStruc, 4);
|
||||
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
|
||||
if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
|
||||
{
|
||||
if (eFuseCtrlStruc.field.EFSROM_KICK == 0) {
|
||||
break;
|
||||
}
|
||||
RTMPusecDelay(2);
|
||||
|
@ -121,28 +109,25 @@ UCHAR eFuseReadRegisters(
|
|||
}
|
||||
|
||||
//if EFSROM_AOUT is not found in physical address, write 0xffff
|
||||
if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f)
|
||||
{
|
||||
for(i=0; i<Length/2; i++)
|
||||
*(pData+2*i) = 0xffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eFuseCtrlStruc.field.EFSROM_AOUT == 0x3f) {
|
||||
for (i = 0; i < Length / 2; i++)
|
||||
*(pData + 2 * i) = 0xffff;
|
||||
} else {
|
||||
//Step4. Read 16-byte of data from EFUSE_DATA0-3 (0x590-0x59C)
|
||||
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
|
||||
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
|
||||
//data hold 4 bytes data.
|
||||
//In RTMP_IO_READ32 will automatically execute 32-bytes swapping
|
||||
RTMP_IO_READ32(pAd, efuseDataOffset, &data);
|
||||
//Decide the upper 2 bytes or the bottom 2 bytes.
|
||||
// Little-endian S | S Big-endian
|
||||
// addr 3 2 1 0 | 0 1 2 3
|
||||
// Ori-V D C B A | A B C D
|
||||
// Little-endian S | S Big-endian
|
||||
// addr 3 2 1 0 | 0 1 2 3
|
||||
// Ori-V D C B A | A B C D
|
||||
//After swapping
|
||||
// D C B A | D C B A
|
||||
// D C B A | D C B A
|
||||
//Return 2-bytes
|
||||
//The return byte statrs from S. Therefore, the little-endian will return BA, the Big-endian will return DC.
|
||||
//For returning the bottom 2 bytes, the Big-endian should shift right 2-bytes.
|
||||
data = data >> (8*(Offset & 0x3));
|
||||
data = data >> (8 * (Offset & 0x3));
|
||||
|
||||
NdisMoveMemory(pData, &data, Length);
|
||||
}
|
||||
|
@ -164,16 +149,14 @@ UCHAR eFuseReadRegisters(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
VOID eFusePhysicalReadRegisters(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset,
|
||||
IN USHORT Length,
|
||||
OUT USHORT* pData)
|
||||
VOID eFusePhysicalReadRegisters(IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset,
|
||||
IN USHORT Length, OUT USHORT * pData)
|
||||
{
|
||||
EFUSE_CTRL_STRUC eFuseCtrlStruc;
|
||||
int i;
|
||||
USHORT efuseDataOffset;
|
||||
UINT32 data;
|
||||
EFUSE_CTRL_STRUC eFuseCtrlStruc;
|
||||
int i;
|
||||
USHORT efuseDataOffset;
|
||||
UINT32 data;
|
||||
|
||||
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
|
||||
|
||||
|
@ -192,10 +175,9 @@ VOID eFusePhysicalReadRegisters(
|
|||
|
||||
//Step3. Polling EFSROM_KICK(0x580, bit30) until it become 0 again.
|
||||
i = 0;
|
||||
while(i < 500)
|
||||
{
|
||||
while (i < 500) {
|
||||
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrlStruc.word);
|
||||
if(eFuseCtrlStruc.field.EFSROM_KICK == 0)
|
||||
if (eFuseCtrlStruc.field.EFSROM_KICK == 0)
|
||||
break;
|
||||
RTMPusecDelay(2);
|
||||
i++;
|
||||
|
@ -209,11 +191,11 @@ VOID eFusePhysicalReadRegisters(
|
|||
//594:B A 9 8
|
||||
//598:7 6 5 4
|
||||
//59C:3 2 1 0
|
||||
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC) ;
|
||||
efuseDataOffset = EFUSE_DATA3 - (Offset & 0xC);
|
||||
|
||||
RTMP_IO_READ32(pAd, efuseDataOffset, &data);
|
||||
|
||||
data = data >> (8*(Offset & 0x3));
|
||||
data = data >> (8 * (Offset & 0x3));
|
||||
|
||||
NdisMoveMemory(pData, &data, Length);
|
||||
|
||||
|
@ -232,24 +214,20 @@ VOID eFusePhysicalReadRegisters(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
static VOID eFuseReadPhysical(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PUSHORT lpInBuffer,
|
||||
IN ULONG nInBufferSize,
|
||||
OUT PUSHORT lpOutBuffer,
|
||||
IN ULONG nOutBufferSize
|
||||
)
|
||||
static VOID eFuseReadPhysical(IN PRTMP_ADAPTER pAd,
|
||||
IN PUSHORT lpInBuffer,
|
||||
IN ULONG nInBufferSize,
|
||||
OUT PUSHORT lpOutBuffer, IN ULONG nOutBufferSize)
|
||||
{
|
||||
USHORT* pInBuf = (USHORT*)lpInBuffer;
|
||||
USHORT* pOutBuf = (USHORT*)lpOutBuffer;
|
||||
USHORT *pInBuf = (USHORT *) lpInBuffer;
|
||||
USHORT *pOutBuf = (USHORT *) lpOutBuffer;
|
||||
|
||||
USHORT Offset = pInBuf[0]; //addr
|
||||
USHORT Length = pInBuf[1]; //length
|
||||
int i;
|
||||
USHORT Offset = pInBuf[0]; //addr
|
||||
USHORT Length = pInBuf[1]; //length
|
||||
int i;
|
||||
|
||||
for(i=0; i<Length; i+=2)
|
||||
{
|
||||
eFusePhysicalReadRegisters(pAd,Offset+i, 2, &pOutBuf[i/2]);
|
||||
for (i = 0; i < Length; i += 2) {
|
||||
eFusePhysicalReadRegisters(pAd, Offset + i, 2, &pOutBuf[i / 2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,116 +244,100 @@ static VOID eFuseReadPhysical(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
INT set_eFuseGetFreeBlockCount_Proc(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING arg)
|
||||
INT set_eFuseGetFreeBlockCount_Proc(IN PRTMP_ADAPTER pAd, IN PSTRING arg)
|
||||
{
|
||||
USHORT i;
|
||||
USHORT LogicalAddress;
|
||||
USHORT efusefreenum=0;
|
||||
if(!pAd->bUseEfuse)
|
||||
USHORT LogicalAddress;
|
||||
USHORT efusefreenum = 0;
|
||||
if (!pAd->bUseEfuse)
|
||||
return FALSE;
|
||||
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2)
|
||||
{
|
||||
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
|
||||
eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
|
||||
if( (LogicalAddress & 0xff) == 0)
|
||||
{
|
||||
efusefreenum= (UCHAR) (EFUSE_USAGE_MAP_END-i+1);
|
||||
if ((LogicalAddress & 0xff) == 0) {
|
||||
efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END - i + 1);
|
||||
break;
|
||||
}
|
||||
else if(( (LogicalAddress >> 8) & 0xff) == 0)
|
||||
{
|
||||
efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END-i);
|
||||
} else if (((LogicalAddress >> 8) & 0xff) == 0) {
|
||||
efusefreenum = (UCHAR) (EFUSE_USAGE_MAP_END - i);
|
||||
break;
|
||||
}
|
||||
|
||||
if(i == EFUSE_USAGE_MAP_END)
|
||||
if (i == EFUSE_USAGE_MAP_END)
|
||||
efusefreenum = 0;
|
||||
}
|
||||
printk("efuseFreeNumber is %d\n",efusefreenum);
|
||||
printk("efuseFreeNumber is %d\n", efusefreenum);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
INT set_eFusedump_Proc(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN PSTRING arg)
|
||||
INT set_eFusedump_Proc(IN PRTMP_ADAPTER pAd, IN PSTRING arg)
|
||||
{
|
||||
USHORT InBuf[3];
|
||||
INT i=0;
|
||||
if(!pAd->bUseEfuse)
|
||||
USHORT InBuf[3];
|
||||
INT i = 0;
|
||||
if (!pAd->bUseEfuse)
|
||||
return FALSE;
|
||||
for(i =0; i<EFUSE_USAGE_MAP_END/2; i++)
|
||||
{
|
||||
InBuf[0] = 2*i;
|
||||
for (i = 0; i < EFUSE_USAGE_MAP_END / 2; i++) {
|
||||
InBuf[0] = 2 * i;
|
||||
InBuf[1] = 2;
|
||||
InBuf[2] = 0x0;
|
||||
|
||||
eFuseReadPhysical(pAd, &InBuf[0], 4, &InBuf[2], 2);
|
||||
if(i%4==0)
|
||||
printk("\nBlock %x:",i/8);
|
||||
printk("%04x ",InBuf[2]);
|
||||
if (i % 4 == 0)
|
||||
printk("\nBlock %x:", i / 8);
|
||||
printk("%04x ", InBuf[2]);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int rtmp_ee_efuse_read16(
|
||||
IN RTMP_ADAPTER *pAd,
|
||||
IN USHORT Offset,
|
||||
OUT USHORT *pValue)
|
||||
int rtmp_ee_efuse_read16(IN RTMP_ADAPTER * pAd,
|
||||
IN USHORT Offset, OUT USHORT * pValue)
|
||||
{
|
||||
eFuseReadRegisters(pAd, Offset, 2, pValue);
|
||||
return (*pValue);
|
||||
}
|
||||
|
||||
int RtmpEfuseSupportCheck(
|
||||
IN RTMP_ADAPTER *pAd)
|
||||
int RtmpEfuseSupportCheck(IN RTMP_ADAPTER * pAd)
|
||||
{
|
||||
USHORT value;
|
||||
|
||||
if (IS_RT30xx(pAd))
|
||||
{
|
||||
if (IS_RT30xx(pAd)) {
|
||||
eFusePhysicalReadRegisters(pAd, EFUSE_TAG, 2, &value);
|
||||
pAd->EFuseTag = (value & 0xff);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID eFuseGetFreeBlockCount(IN PRTMP_ADAPTER pAd,
|
||||
PUINT EfuseFreeBlock)
|
||||
VOID eFuseGetFreeBlockCount(IN PRTMP_ADAPTER pAd, PUINT EfuseFreeBlock)
|
||||
{
|
||||
USHORT i;
|
||||
USHORT LogicalAddress;
|
||||
if(!pAd->bUseEfuse)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_TRACE,("eFuseGetFreeBlockCount Only supports efuse Mode\n"));
|
||||
return ;
|
||||
}
|
||||
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i+=2)
|
||||
{
|
||||
USHORT LogicalAddress;
|
||||
if (!pAd->bUseEfuse) {
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("eFuseGetFreeBlockCount Only supports efuse Mode\n"));
|
||||
return;
|
||||
}
|
||||
for (i = EFUSE_USAGE_MAP_START; i <= EFUSE_USAGE_MAP_END; i += 2) {
|
||||
eFusePhysicalReadRegisters(pAd, i, 2, &LogicalAddress);
|
||||
if( (LogicalAddress & 0xff) == 0)
|
||||
{
|
||||
*EfuseFreeBlock= (UCHAR) (EFUSE_USAGE_MAP_END-i+1);
|
||||
if ((LogicalAddress & 0xff) == 0) {
|
||||
*EfuseFreeBlock = (UCHAR) (EFUSE_USAGE_MAP_END - i + 1);
|
||||
break;
|
||||
}
|
||||
else if(( (LogicalAddress >> 8) & 0xff) == 0)
|
||||
{
|
||||
*EfuseFreeBlock = (UCHAR) (EFUSE_USAGE_MAP_END-i);
|
||||
} else if (((LogicalAddress >> 8) & 0xff) == 0) {
|
||||
*EfuseFreeBlock = (UCHAR) (EFUSE_USAGE_MAP_END - i);
|
||||
break;
|
||||
}
|
||||
|
||||
if(i == EFUSE_USAGE_MAP_END)
|
||||
if (i == EFUSE_USAGE_MAP_END)
|
||||
*EfuseFreeBlock = 0;
|
||||
}
|
||||
DBGPRINT(RT_DEBUG_TRACE,("eFuseGetFreeBlockCount is 0x%x\n",*EfuseFreeBlock));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
("eFuseGetFreeBlockCount is 0x%x\n", *EfuseFreeBlock));
|
||||
}
|
||||
|
||||
INT eFuse_init(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
INT eFuse_init(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UINT EfuseFreeBlock=0;
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("NVM is Efuse and its size =%x[%x-%x] \n",EFUSE_USAGE_MAP_SIZE,EFUSE_USAGE_MAP_START,EFUSE_USAGE_MAP_END));
|
||||
UINT EfuseFreeBlock = 0;
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("NVM is Efuse and its size =%x[%x-%x] \n",
|
||||
EFUSE_USAGE_MAP_SIZE, EFUSE_USAGE_MAP_START,
|
||||
EFUSE_USAGE_MAP_END));
|
||||
eFuseGetFreeBlockCount(pAd, &EfuseFreeBlock);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -35,25 +35,18 @@
|
|||
-------- ---------- ----------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
static inline VOID RaiseClock(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UINT32 *x)
|
||||
static inline VOID RaiseClock(IN PRTMP_ADAPTER pAd, IN UINT32 * x)
|
||||
{
|
||||
*x = *x | EESK;
|
||||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
|
||||
RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
|
||||
RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
|
||||
}
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
static inline VOID LowerClock(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UINT32 *x)
|
||||
static inline VOID LowerClock(IN PRTMP_ADAPTER pAd, IN UINT32 * x)
|
||||
{
|
||||
*x = *x & ~EESK;
|
||||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
|
||||
|
@ -61,67 +54,60 @@ static inline VOID LowerClock(
|
|||
}
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
static inline USHORT ShiftInBits(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
static inline USHORT ShiftInBits(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UINT32 x,i;
|
||||
USHORT data=0;
|
||||
UINT32 x, i;
|
||||
USHORT data = 0;
|
||||
|
||||
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
|
||||
|
||||
x &= ~( EEDO | EEDI);
|
||||
x &= ~(EEDO | EEDI);
|
||||
|
||||
for(i=0; i<16; i++)
|
||||
{
|
||||
for (i = 0; i < 16; i++) {
|
||||
data = data << 1;
|
||||
RaiseClock(pAd, &x);
|
||||
|
||||
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
|
||||
LowerClock(pAd, &x); //prevent read failed
|
||||
LowerClock(pAd, &x); //prevent read failed
|
||||
|
||||
x &= ~(EEDI);
|
||||
if(x & EEDO)
|
||||
data |= 1;
|
||||
if (x & EEDO)
|
||||
data |= 1;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
static inline VOID ShiftOutBits(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT data,
|
||||
IN USHORT count)
|
||||
static inline VOID ShiftOutBits(IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT data, IN USHORT count)
|
||||
{
|
||||
UINT32 x,mask;
|
||||
UINT32 x, mask;
|
||||
|
||||
mask = 0x01 << (count - 1);
|
||||
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
|
||||
|
||||
x &= ~(EEDO | EEDI);
|
||||
|
||||
do
|
||||
{
|
||||
x &= ~EEDI;
|
||||
if(data & mask) x |= EEDI;
|
||||
do {
|
||||
x &= ~EEDI;
|
||||
if (data & mask)
|
||||
x |= EEDI;
|
||||
|
||||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
|
||||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
|
||||
|
||||
RaiseClock(pAd, &x);
|
||||
LowerClock(pAd, &x);
|
||||
RaiseClock(pAd, &x);
|
||||
LowerClock(pAd, &x);
|
||||
|
||||
mask = mask >> 1;
|
||||
} while(mask);
|
||||
mask = mask >> 1;
|
||||
} while (mask);
|
||||
|
||||
x &= ~EEDI;
|
||||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
|
||||
}
|
||||
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
static inline VOID EEpromCleanup(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
static inline VOID EEpromCleanup(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UINT32 x;
|
||||
|
||||
|
@ -134,11 +120,9 @@ static inline VOID EEpromCleanup(
|
|||
LowerClock(pAd, &x);
|
||||
}
|
||||
|
||||
|
||||
static inline VOID EWEN(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
static inline VOID EWEN(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UINT32 x;
|
||||
UINT32 x;
|
||||
|
||||
// reset bits and set EECS
|
||||
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
|
||||
|
@ -157,11 +141,9 @@ static inline VOID EWEN(
|
|||
EEpromCleanup(pAd);
|
||||
}
|
||||
|
||||
|
||||
static inline VOID EWDS(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
static inline VOID EWDS(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
UINT32 x;
|
||||
UINT32 x;
|
||||
|
||||
// reset bits and set EECS
|
||||
RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
|
||||
|
@ -180,16 +162,12 @@ static inline VOID EWDS(
|
|||
EEpromCleanup(pAd);
|
||||
}
|
||||
|
||||
|
||||
// IRQL = PASSIVE_LEVEL
|
||||
int rtmp_ee_prom_read16(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset,
|
||||
OUT USHORT *pValue)
|
||||
int rtmp_ee_prom_read16(IN PRTMP_ADAPTER pAd,
|
||||
IN USHORT Offset, OUT USHORT * pValue)
|
||||
{
|
||||
UINT32 x;
|
||||
USHORT data;
|
||||
|
||||
UINT32 x;
|
||||
USHORT data;
|
||||
|
||||
Offset /= 2;
|
||||
// reset bits and set EECS
|
||||
|
@ -199,13 +177,11 @@ int rtmp_ee_prom_read16(
|
|||
RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
|
||||
|
||||
// patch can not access e-Fuse issue
|
||||
if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
|
||||
{
|
||||
if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))) {
|
||||
// kick a pulse
|
||||
RaiseClock(pAd, &x);
|
||||
LowerClock(pAd, &x);
|
||||
}
|
||||
|
||||
// output the read_opcode and register number in that order
|
||||
ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
|
||||
ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
|
||||
|
@ -215,7 +191,6 @@ int rtmp_ee_prom_read16(
|
|||
|
||||
EEpromCleanup(pAd);
|
||||
|
||||
|
||||
*pValue = data;
|
||||
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
|
|
|
@ -36,62 +36,56 @@
|
|||
*/
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
INT RtmpChipOpsEepromHook(
|
||||
IN RTMP_ADAPTER *pAd,
|
||||
IN INT infType)
|
||||
INT RtmpChipOpsEepromHook(IN RTMP_ADAPTER * pAd, IN INT infType)
|
||||
{
|
||||
RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
|
||||
RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
|
||||
#ifdef RT30xx
|
||||
#ifdef RTMP_EFUSE_SUPPORT
|
||||
UINT32 eFuseCtrl, MacCsr0;
|
||||
UINT32 eFuseCtrl, MacCsr0;
|
||||
int index;
|
||||
|
||||
index = 0;
|
||||
do
|
||||
{
|
||||
do {
|
||||
RTMP_IO_READ32(pAd, MAC_CSR0, &MacCsr0);
|
||||
pAd->MACVersion = MacCsr0;
|
||||
|
||||
if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))
|
||||
break;
|
||||
if ((pAd->MACVersion != 0x00)
|
||||
&& (pAd->MACVersion != 0xFFFFFFFF))
|
||||
break;
|
||||
|
||||
RTMPusecDelay(10);
|
||||
} while (index++ < 100);
|
||||
|
||||
pAd->bUseEfuse=FALSE;
|
||||
pAd->bUseEfuse = FALSE;
|
||||
RTMP_IO_READ32(pAd, EFUSE_CTRL, &eFuseCtrl);
|
||||
pAd->bUseEfuse = ( (eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
|
||||
if(pAd->bUseEfuse)
|
||||
{
|
||||
pAd->bUseEfuse = ((eFuseCtrl & 0x80000000) == 0x80000000) ? 1 : 0;
|
||||
if (pAd->bUseEfuse) {
|
||||
pChipOps->eeinit = eFuse_init;
|
||||
pChipOps->eeread = rtmp_ee_efuse_read16;
|
||||
return 0 ;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("NVM is EEPROM\n"));
|
||||
#endif // RTMP_EFUSE_SUPPORT //
|
||||
#endif // RT30xx //
|
||||
|
||||
switch(infType)
|
||||
{
|
||||
switch (infType) {
|
||||
#ifdef RTMP_PCI_SUPPORT
|
||||
case RTMP_DEV_INF_PCI:
|
||||
pChipOps->eeinit = NULL;
|
||||
pChipOps->eeread = rtmp_ee_prom_read16;
|
||||
break;
|
||||
case RTMP_DEV_INF_PCI:
|
||||
pChipOps->eeinit = NULL;
|
||||
pChipOps->eeread = rtmp_ee_prom_read16;
|
||||
break;
|
||||
#endif // RTMP_PCI_SUPPORT //
|
||||
#ifdef RTMP_USB_SUPPORT
|
||||
case RTMP_DEV_INF_USB:
|
||||
pChipOps->eeinit = NULL;
|
||||
pChipOps->eeread = RTUSBReadEEPROM16;
|
||||
break;
|
||||
case RTMP_DEV_INF_USB:
|
||||
pChipOps->eeinit = NULL;
|
||||
pChipOps->eeread = RTUSBReadEEPROM16;
|
||||
break;
|
||||
#endif // RTMP_USB_SUPPORT //
|
||||
|
||||
default:
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("RtmpChipOpsEepromHook() failed!\n"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("RtmpChipOpsEepromHook() failed!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -35,10 +35,8 @@
|
|||
-------- ---------- ----------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
#ifdef RTMP_RF_RW_SUPPORT
|
||||
/*
|
||||
========================================================================
|
||||
|
@ -55,27 +53,26 @@
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
NDIS_STATUS RT30xxWriteRFRegister(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR regID,
|
||||
IN UCHAR value)
|
||||
NDIS_STATUS RT30xxWriteRFRegister(IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR regID, IN UCHAR value)
|
||||
{
|
||||
RF_CSR_CFG_STRUC rfcsr;
|
||||
UINT i = 0;
|
||||
RF_CSR_CFG_STRUC rfcsr;
|
||||
UINT i = 0;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
|
||||
|
||||
if (!rfcsr.field.RF_CSR_KICK)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
|
||||
while ((i < RETRY_LIMIT)
|
||||
&& (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)));
|
||||
|
||||
if ((i == RETRY_LIMIT) || (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)))
|
||||
{
|
||||
DBGPRINT_RAW(RT_DEBUG_ERROR, ("Retry count exhausted or device removed!!!\n"));
|
||||
if ((i == RETRY_LIMIT)
|
||||
|| (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) {
|
||||
DBGPRINT_RAW(RT_DEBUG_ERROR,
|
||||
("Retry count exhausted or device removed!!!\n"));
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
@ -89,7 +86,6 @@ NDIS_STATUS RT30xxWriteRFRegister(
|
|||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
|
@ -105,20 +101,16 @@ NDIS_STATUS RT30xxWriteRFRegister(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
NDIS_STATUS RT30xxReadRFRegister(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR regID,
|
||||
IN PUCHAR pValue)
|
||||
NDIS_STATUS RT30xxReadRFRegister(IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR regID, IN PUCHAR pValue)
|
||||
{
|
||||
RF_CSR_CFG_STRUC rfcsr;
|
||||
UINT i=0, k=0;
|
||||
RF_CSR_CFG_STRUC rfcsr;
|
||||
UINT i = 0, k = 0;
|
||||
|
||||
for (i=0; i<MAX_BUSY_COUNT; i++)
|
||||
{
|
||||
for (i = 0; i < MAX_BUSY_COUNT; i++) {
|
||||
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
|
||||
|
||||
if (rfcsr.field.RF_CSR_KICK == BUSY)
|
||||
{
|
||||
if (rfcsr.field.RF_CSR_KICK == BUSY) {
|
||||
continue;
|
||||
}
|
||||
rfcsr.word = 0;
|
||||
|
@ -126,40 +118,34 @@ NDIS_STATUS RT30xxReadRFRegister(
|
|||
rfcsr.field.RF_CSR_KICK = 1;
|
||||
rfcsr.field.TESTCSR_RFACC_REGNUM = regID;
|
||||
RTMP_IO_WRITE32(pAd, RF_CSR_CFG, rfcsr.word);
|
||||
for (k=0; k<MAX_BUSY_COUNT; k++)
|
||||
{
|
||||
for (k = 0; k < MAX_BUSY_COUNT; k++) {
|
||||
RTMP_IO_READ32(pAd, RF_CSR_CFG, &rfcsr.word);
|
||||
|
||||
if (rfcsr.field.RF_CSR_KICK == IDLE)
|
||||
break;
|
||||
}
|
||||
if ((rfcsr.field.RF_CSR_KICK == IDLE) &&
|
||||
(rfcsr.field.TESTCSR_RFACC_REGNUM == regID))
|
||||
{
|
||||
*pValue = (UCHAR)rfcsr.field.RF_CSR_DATA;
|
||||
(rfcsr.field.TESTCSR_RFACC_REGNUM == regID)) {
|
||||
*pValue = (UCHAR) rfcsr.field.RF_CSR_DATA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rfcsr.field.RF_CSR_KICK == BUSY)
|
||||
{
|
||||
DBGPRINT_ERR(("RF read R%d=0x%x fail, i[%d], k[%d]\n", regID, rfcsr.word,i,k));
|
||||
if (rfcsr.field.RF_CSR_KICK == BUSY) {
|
||||
DBGPRINT_ERR(("RF read R%d=0x%x fail, i[%d], k[%d]\n", regID,
|
||||
rfcsr.word, i, k));
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
VOID NICInitRFRegisters(
|
||||
IN RTMP_ADAPTER *pAd)
|
||||
VOID NICInitRFRegisters(IN RTMP_ADAPTER * pAd)
|
||||
{
|
||||
if (pAd->chipOps.AsicRfInit)
|
||||
pAd->chipOps.AsicRfInit(pAd);
|
||||
}
|
||||
|
||||
|
||||
VOID RtmpChipOpsRFHook(
|
||||
IN RTMP_ADAPTER *pAd)
|
||||
VOID RtmpChipOpsRFHook(IN RTMP_ADAPTER * pAd)
|
||||
{
|
||||
RTMP_CHIP_OP *pChipOps = &pAd->chipOps;
|
||||
|
||||
|
@ -172,27 +158,27 @@ VOID RtmpChipOpsRFHook(
|
|||
/* We depends on RfICType and MACVersion to assign the corresponding operation callbacks. */
|
||||
|
||||
#ifdef RT30xx
|
||||
if (IS_RT30xx(pAd))
|
||||
{
|
||||
if (IS_RT30xx(pAd)) {
|
||||
pChipOps->pRFRegTable = RT30xx_RFRegTable;
|
||||
pChipOps->AsicHaltAction = RT30xxHaltAction;
|
||||
#ifdef RT3070
|
||||
if((IS_RT3070(pAd) || IS_RT3071(pAd)) && (pAd->infType == RTMP_DEV_INF_USB))
|
||||
{
|
||||
if ((IS_RT3070(pAd) || IS_RT3071(pAd))
|
||||
&& (pAd->infType == RTMP_DEV_INF_USB)) {
|
||||
pChipOps->AsicRfInit = NICInitRT3070RFRegisters;
|
||||
if (IS_RT3071(pAd))
|
||||
{
|
||||
pChipOps->AsicRfTurnOff = RT30xxLoadRFSleepModeSetup;
|
||||
pChipOps->AsicReverseRfFromSleepMode = RT30xxReverseRFSleepModeSetup;
|
||||
if (IS_RT3071(pAd)) {
|
||||
pChipOps->AsicRfTurnOff =
|
||||
RT30xxLoadRFSleepModeSetup;
|
||||
pChipOps->AsicReverseRfFromSleepMode =
|
||||
RT30xxReverseRFSleepModeSetup;
|
||||
}
|
||||
}
|
||||
#endif // RT3070 //
|
||||
#ifdef RT3090
|
||||
if (IS_RT3090(pAd) && (pAd->infType == RTMP_DEV_INF_PCI))
|
||||
{
|
||||
if (IS_RT3090(pAd) && (pAd->infType == RTMP_DEV_INF_PCI)) {
|
||||
pChipOps->AsicRfTurnOff = RT30xxLoadRFSleepModeSetup;
|
||||
pChipOps->AsicRfInit = NICInitRT3090RFRegisters;
|
||||
pChipOps->AsicReverseRfFromSleepMode = RT30xxReverseRFSleepModeSetup;
|
||||
pChipOps->AsicReverseRfFromSleepMode =
|
||||
RT30xxReverseRFSleepModeSetup;
|
||||
}
|
||||
#endif // RT3090 //
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -35,7 +35,6 @@
|
|||
-------- ---------- ----------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "../rt_config.h"
|
||||
|
||||
#if defined(RT2860) || defined(RT3090)
|
||||
|
@ -83,12 +82,11 @@
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
INT RtmpAsicEraseFirmware(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
INT RtmpAsicEraseFirmware(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for(i=0; i<MAX_FIRMWARE_IMAGE_SIZE; i+=4)
|
||||
for (i = 0; i < MAX_FIRMWARE_IMAGE_SIZE; i += 4)
|
||||
RTMP_IO_WRITE32(pAd, FIRMWARE_IMAGE_BASE + i, 0);
|
||||
|
||||
return 0;
|
||||
|
@ -111,16 +109,15 @@ INT RtmpAsicEraseFirmware(
|
|||
|
||||
========================================================================
|
||||
*/
|
||||
NDIS_STATUS RtmpAsicLoadFirmware(
|
||||
IN PRTMP_ADAPTER pAd)
|
||||
NDIS_STATUS RtmpAsicLoadFirmware(IN PRTMP_ADAPTER pAd)
|
||||
{
|
||||
|
||||
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
|
||||
PUCHAR pFirmwareImage = NULL;
|
||||
ULONG FileLength, Index;
|
||||
UINT32 MacReg = 0;
|
||||
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
|
||||
PUCHAR pFirmwareImage = NULL;
|
||||
ULONG FileLength, Index;
|
||||
UINT32 MacReg = 0;
|
||||
#ifdef RTMP_MAC_USB
|
||||
UINT32 Version = (pAd->MACVersion >> 16);
|
||||
UINT32 Version = (pAd->MACVersion >> 16);
|
||||
#endif
|
||||
|
||||
// New 8k byte firmware size for RT3071/RT3072
|
||||
|
@ -136,14 +133,13 @@ NDIS_STATUS RtmpAsicLoadFirmware(
|
|||
#endif // RTMP_MAC_PCI //
|
||||
#ifdef RTMP_MAC_USB
|
||||
/* the firmware image consists of two parts */
|
||||
if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070))
|
||||
{ /* use the second part */
|
||||
if ((Version != 0x2860) && (Version != 0x2872) && (Version != 0x3070)) { /* use the second part */
|
||||
//printk("KH:Use New Version,part2\n");
|
||||
pFirmwareImage = (PUCHAR)&FirmwareImage_3070[FIRMWAREIMAGEV1_LENGTH];
|
||||
pFirmwareImage =
|
||||
(PUCHAR) &
|
||||
FirmwareImage_3070[FIRMWAREIMAGEV1_LENGTH];
|
||||
FileLength = FIRMWAREIMAGEV2_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//printk("KH:Use New Version,part1\n");
|
||||
if (Version == 0x3070)
|
||||
pFirmwareImage = FirmwareImage_3070;
|
||||
|
@ -156,11 +152,9 @@ NDIS_STATUS RtmpAsicLoadFirmware(
|
|||
|
||||
RTMP_WRITE_FIRMWARE(pAd, pFirmwareImage, FileLength);
|
||||
|
||||
|
||||
/* check if MCU is ready */
|
||||
Index = 0;
|
||||
do
|
||||
{
|
||||
do {
|
||||
RTMP_IO_READ32(pAd, PBF_SYS_CTRL, &MacReg);
|
||||
|
||||
if (MacReg & 0x80)
|
||||
|
@ -169,138 +163,124 @@ NDIS_STATUS RtmpAsicLoadFirmware(
|
|||
RTMPusecDelay(1000);
|
||||
} while (Index++ < 1000);
|
||||
|
||||
if (Index > 1000)
|
||||
{
|
||||
DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
|
||||
if (Index > 1000) {
|
||||
DBGPRINT(RT_DEBUG_ERROR,
|
||||
("NICLoadFirmware: MCU is not ready\n\n\n"));
|
||||
Status = NDIS_STATUS_FAILURE;
|
||||
}
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("<=== %s (status=%d)\n", __func__, Status));
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("<=== %s (status=%d)\n", __func__, Status));
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
INT RtmpAsicSendCommandToMcu(
|
||||
IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR Command,
|
||||
IN UCHAR Token,
|
||||
IN UCHAR Arg0,
|
||||
IN UCHAR Arg1)
|
||||
INT RtmpAsicSendCommandToMcu(IN PRTMP_ADAPTER pAd,
|
||||
IN UCHAR Command,
|
||||
IN UCHAR Token, IN UCHAR Arg0, IN UCHAR Arg1)
|
||||
{
|
||||
HOST_CMD_CSR_STRUC H2MCmd;
|
||||
H2M_MAILBOX_STRUC H2MMailbox;
|
||||
ULONG i = 0;
|
||||
HOST_CMD_CSR_STRUC H2MCmd;
|
||||
H2M_MAILBOX_STRUC H2MMailbox;
|
||||
ULONG i = 0;
|
||||
|
||||
#ifdef PCIE_PS_SUPPORT
|
||||
// 3090F power solution 3 has hw limitation that needs to ban all mcu command
|
||||
// when firmware is in radio state. For other chip doesn't have this limitation.
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE))
|
||||
{
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
|
||||
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)) {
|
||||
RTMP_SEM_LOCK(&pAd->McuCmdLock);
|
||||
if ((pAd->brt30xxBanMcuCmd == TRUE)
|
||||
&& (Command != WAKE_MCU_CMD) && (Command != RFOFF_MCU_CMD))
|
||||
{
|
||||
&& (Command != WAKE_MCU_CMD) && (Command != RFOFF_MCU_CMD)) {
|
||||
RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
|
||||
DBGPRINT(RT_DEBUG_TRACE, (" Ban Mcu Cmd %x in sleep mode\n", Command));
|
||||
DBGPRINT(RT_DEBUG_TRACE,
|
||||
(" Ban Mcu Cmd %x in sleep mode\n", Command));
|
||||
return FALSE;
|
||||
}
|
||||
else if ((Command == SLEEP_MCU_CMD)
|
||||
||(Command == RFOFF_MCU_CMD))
|
||||
{
|
||||
} else if ((Command == SLEEP_MCU_CMD)
|
||||
|| (Command == RFOFF_MCU_CMD)) {
|
||||
pAd->brt30xxBanMcuCmd = TRUE;
|
||||
}
|
||||
else if (Command != WAKE_MCU_CMD)
|
||||
{
|
||||
} else if (Command != WAKE_MCU_CMD) {
|
||||
pAd->brt30xxBanMcuCmd = FALSE;
|
||||
}
|
||||
|
||||
RTMP_SEM_UNLOCK(&pAd->McuCmdLock);
|
||||
|
||||
}
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
|
||||
&& (Command == WAKE_MCU_CMD))
|
||||
{
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
|
||||
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
|
||||
&& (Command == WAKE_MCU_CMD)) {
|
||||
|
||||
do
|
||||
{
|
||||
RTMP_IO_FORCE_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
|
||||
do {
|
||||
RTMP_IO_FORCE_READ32(pAd, H2M_MAILBOX_CSR,
|
||||
&H2MMailbox.word);
|
||||
if (H2MMailbox.field.Owner == 0)
|
||||
break;
|
||||
|
||||
RTMPusecDelay(2);
|
||||
DBGPRINT(RT_DEBUG_INFO, ("AsicSendCommanToMcu::Mail box is busy\n"));
|
||||
} while(i++ < 100);
|
||||
DBGPRINT(RT_DEBUG_INFO,
|
||||
("AsicSendCommanToMcu::Mail box is busy\n"));
|
||||
} while (i++ < 100);
|
||||
|
||||
if (i >= 100)
|
||||
{
|
||||
if (i >= 100) {
|
||||
DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
H2MMailbox.field.Owner = 1; // pass ownership to MCU
|
||||
H2MMailbox.field.Owner = 1; // pass ownership to MCU
|
||||
H2MMailbox.field.CmdToken = Token;
|
||||
H2MMailbox.field.HighByte = Arg1;
|
||||
H2MMailbox.field.LowByte = Arg0;
|
||||
H2MMailbox.field.LowByte = Arg0;
|
||||
RTMP_IO_FORCE_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
|
||||
|
||||
H2MCmd.word = 0;
|
||||
H2MCmd.field.HostCommand = Command;
|
||||
H2MCmd.word = 0;
|
||||
H2MCmd.field.HostCommand = Command;
|
||||
RTMP_IO_FORCE_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif // PCIE_PS_SUPPORT //
|
||||
{
|
||||
do
|
||||
{
|
||||
RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
|
||||
if (H2MMailbox.field.Owner == 0)
|
||||
break;
|
||||
do {
|
||||
RTMP_IO_READ32(pAd, H2M_MAILBOX_CSR, &H2MMailbox.word);
|
||||
if (H2MMailbox.field.Owner == 0)
|
||||
break;
|
||||
|
||||
RTMPusecDelay(2);
|
||||
} while(i++ < 100);
|
||||
RTMPusecDelay(2);
|
||||
} while (i++ < 100);
|
||||
|
||||
if (i > 100)
|
||||
{
|
||||
if (i > 100) {
|
||||
#ifdef RTMP_MAC_PCI
|
||||
#endif // RTMP_MAC_PCI //
|
||||
{
|
||||
DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
|
||||
{
|
||||
DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef RTMP_MAC_PCI
|
||||
#endif // RTMP_MAC_PCI //
|
||||
|
||||
H2MMailbox.field.Owner = 1; // pass ownership to MCU
|
||||
H2MMailbox.field.CmdToken = Token;
|
||||
H2MMailbox.field.HighByte = Arg1;
|
||||
H2MMailbox.field.LowByte = Arg0;
|
||||
RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
|
||||
H2MMailbox.field.Owner = 1; // pass ownership to MCU
|
||||
H2MMailbox.field.CmdToken = Token;
|
||||
H2MMailbox.field.HighByte = Arg1;
|
||||
H2MMailbox.field.LowByte = Arg0;
|
||||
RTMP_IO_WRITE32(pAd, H2M_MAILBOX_CSR, H2MMailbox.word);
|
||||
|
||||
H2MCmd.word = 0;
|
||||
H2MCmd.field.HostCommand = Command;
|
||||
RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
|
||||
H2MCmd.word = 0;
|
||||
H2MCmd.field.HostCommand = Command;
|
||||
RTMP_IO_WRITE32(pAd, HOST_CMD_CSR, H2MCmd.word);
|
||||
|
||||
if (Command != 0x80)
|
||||
{
|
||||
if (Command != 0x80) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef PCIE_PS_SUPPORT
|
||||
// 3090 MCU Wakeup command needs more time to be stable.
|
||||
// Before stable, don't issue other MCU command to prevent from firmware error.
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)) && IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
|
||||
&& (Command == WAKE_MCU_CMD))
|
||||
{
|
||||
if (((IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd))
|
||||
&& IS_VERSION_AFTER_F(pAd)) && IS_VERSION_AFTER_F(pAd)
|
||||
&& (pAd->StaCfg.PSControl.field.rt30xxPowerMode == 3)
|
||||
&& (pAd->StaCfg.PSControl.field.EnableNewPS == TRUE)
|
||||
&& (Command == WAKE_MCU_CMD)) {
|
||||
RTMPusecDelay(2000);
|
||||
//Put this is after RF programming.
|
||||
//NdisAcquireSpinLock(&pAd->McuCmdLock);
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
#include "../rt_config.h"
|
||||
|
||||
|
||||
BUILD_TIMER_FUNCTION(MlmePeriodicExec);
|
||||
//BUILD_TIMER_FUNCTION(MlmeRssiReportExec);
|
||||
BUILD_TIMER_FUNCTION(AsicRxAntEvalTimeout);
|
||||
|
@ -68,30 +67,25 @@ BUILD_TIMER_FUNCTION(RtmpUsbStaAsicForceWakeupTimeout);
|
|||
#endif // RTMP_MAC_USB //
|
||||
|
||||
#if defined(AP_LED) || defined(STA_LED)
|
||||
extern void LedCtrlMain(
|
||||
IN PVOID SystemSpecific1,
|
||||
IN PVOID FunctionContext,
|
||||
IN PVOID SystemSpecific2,
|
||||
IN PVOID SystemSpecific3);
|
||||
extern void LedCtrlMain(IN PVOID SystemSpecific1,
|
||||
IN PVOID FunctionContext,
|
||||
IN PVOID SystemSpecific2, IN PVOID SystemSpecific3);
|
||||
BUILD_TIMER_FUNCTION(LedCtrlMain);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RTMP_TIMER_TASK_SUPPORT
|
||||
static void RtmpTimerQHandle(RTMP_ADAPTER *pAd)
|
||||
static void RtmpTimerQHandle(RTMP_ADAPTER * pAd)
|
||||
{
|
||||
#ifndef KTHREAD_SUPPORT
|
||||
int status;
|
||||
#endif
|
||||
RALINK_TIMER_STRUCT *pTimer;
|
||||
RTMP_TIMER_TASK_ENTRY *pEntry;
|
||||
unsigned long irqFlag;
|
||||
RALINK_TIMER_STRUCT *pTimer;
|
||||
RTMP_TIMER_TASK_ENTRY *pEntry;
|
||||
unsigned long irqFlag;
|
||||
RTMP_OS_TASK *pTask;
|
||||
|
||||
|
||||
pTask = &pAd->timerTask;
|
||||
while(!pTask->task_killed)
|
||||
{
|
||||
while (!pTask->task_killed) {
|
||||
pTimer = NULL;
|
||||
|
||||
#ifdef KTHREAD_SUPPORT
|
||||
|
@ -104,12 +98,10 @@ static void RtmpTimerQHandle(RTMP_ADAPTER *pAd)
|
|||
break;
|
||||
|
||||
// event happened.
|
||||
while(pAd->TimerQ.pQHead)
|
||||
{
|
||||
while (pAd->TimerQ.pQHead) {
|
||||
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlag);
|
||||
pEntry = pAd->TimerQ.pQHead;
|
||||
if (pEntry)
|
||||
{
|
||||
if (pEntry) {
|
||||
pTimer = pEntry->pRaTimer;
|
||||
|
||||
// update pQHead
|
||||
|
@ -123,18 +115,21 @@ static void RtmpTimerQHandle(RTMP_ADAPTER *pAd)
|
|||
}
|
||||
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlag);
|
||||
|
||||
if (pTimer)
|
||||
{
|
||||
if ((pTimer->handle != NULL) && (!pAd->PM_FlgSuspend))
|
||||
pTimer->handle(NULL, (PVOID) pTimer->cookie, NULL, pTimer);
|
||||
if ((pTimer->Repeat) && (pTimer->State == FALSE))
|
||||
RTMP_OS_Add_Timer(&pTimer->TimerObj, pTimer->TimerValue);
|
||||
if (pTimer) {
|
||||
if ((pTimer->handle != NULL)
|
||||
&& (!pAd->PM_FlgSuspend))
|
||||
pTimer->handle(NULL,
|
||||
(PVOID) pTimer->cookie,
|
||||
NULL, pTimer);
|
||||
if ((pTimer->Repeat)
|
||||
&& (pTimer->State == FALSE))
|
||||
RTMP_OS_Add_Timer(&pTimer->TimerObj,
|
||||
pTimer->TimerValue);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef KTHREAD_SUPPORT
|
||||
if (status != 0)
|
||||
{
|
||||
if (status != 0) {
|
||||
pAd->TimerQ.status = RTMP_TASK_STAT_STOPED;
|
||||
RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS);
|
||||
break;
|
||||
|
@ -143,22 +138,19 @@ static void RtmpTimerQHandle(RTMP_ADAPTER *pAd)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
INT RtmpTimerQThread(
|
||||
IN OUT PVOID Context)
|
||||
INT RtmpTimerQThread(IN OUT PVOID Context)
|
||||
{
|
||||
RTMP_OS_TASK *pTask;
|
||||
PRTMP_ADAPTER pAd;
|
||||
RTMP_OS_TASK *pTask;
|
||||
PRTMP_ADAPTER pAd;
|
||||
|
||||
|
||||
pTask = (RTMP_OS_TASK *)Context;
|
||||
pAd = (PRTMP_ADAPTER)pTask->priv;
|
||||
pTask = (RTMP_OS_TASK *) Context;
|
||||
pAd = (PRTMP_ADAPTER) pTask->priv;
|
||||
|
||||
RtmpOSTaskCustomize(pTask);
|
||||
|
||||
RtmpTimerQHandle(pAd);
|
||||
|
||||
DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
|
||||
DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __func__));
|
||||
#ifndef KTHREAD_SUPPORT
|
||||
pTask->taskPID = THREAD_PID_INIT_VALUE;
|
||||
#endif
|
||||
|
@ -182,20 +174,16 @@ INT RtmpTimerQThread(
|
|||
|
||||
}
|
||||
|
||||
|
||||
RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(
|
||||
IN RTMP_ADAPTER *pAd,
|
||||
IN RALINK_TIMER_STRUCT *pTimer)
|
||||
RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(IN RTMP_ADAPTER * pAd,
|
||||
IN RALINK_TIMER_STRUCT * pTimer)
|
||||
{
|
||||
RTMP_TIMER_TASK_ENTRY *pQNode = NULL, *pQTail;
|
||||
unsigned long irqFlags;
|
||||
RTMP_OS_TASK *pTask = &pAd->timerTask;
|
||||
RTMP_OS_TASK *pTask = &pAd->timerTask;
|
||||
|
||||
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
|
||||
if (pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT)
|
||||
{
|
||||
if(pAd->TimerQ.pQPollFreeList)
|
||||
{
|
||||
if (pAd->TimerQ.status & RTMP_TASK_CAN_DO_INSERT) {
|
||||
if (pAd->TimerQ.pQPollFreeList) {
|
||||
pQNode = pAd->TimerQ.pQPollFreeList;
|
||||
pAd->TimerQ.pQPollFreeList = pQNode->pNext;
|
||||
|
||||
|
@ -212,8 +200,7 @@ RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(
|
|||
}
|
||||
RTMP_INT_UNLOCK(&pAd->TimerQLock, irqFlags);
|
||||
|
||||
if (pQNode)
|
||||
{
|
||||
if (pQNode) {
|
||||
#ifdef KTHREAD_SUPPORT
|
||||
WAKE_UP(pTask);
|
||||
#else
|
||||
|
@ -224,20 +211,15 @@ RTMP_TIMER_TASK_ENTRY *RtmpTimerQInsert(
|
|||
return pQNode;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN RtmpTimerQRemove(
|
||||
IN RTMP_ADAPTER *pAd,
|
||||
IN RALINK_TIMER_STRUCT *pTimer)
|
||||
BOOLEAN RtmpTimerQRemove(IN RTMP_ADAPTER * pAd, IN RALINK_TIMER_STRUCT * pTimer)
|
||||
{
|
||||
RTMP_TIMER_TASK_ENTRY *pNode, *pPrev = NULL;
|
||||
unsigned long irqFlags;
|
||||
|
||||
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
|
||||
if (pAd->TimerQ.status >= RTMP_TASK_STAT_INITED)
|
||||
{
|
||||
if (pAd->TimerQ.status >= RTMP_TASK_STAT_INITED) {
|
||||
pNode = pAd->TimerQ.pQHead;
|
||||
while (pNode)
|
||||
{
|
||||
while (pNode) {
|
||||
if (pNode->pRaTimer == pTimer)
|
||||
break;
|
||||
pPrev = pNode;
|
||||
|
@ -245,8 +227,7 @@ BOOLEAN RtmpTimerQRemove(
|
|||
}
|
||||
|
||||
// Now move it to freeList queue.
|
||||
if (pNode)
|
||||
{
|
||||
if (pNode) {
|
||||
if (pNode == pAd->TimerQ.pQHead)
|
||||
pAd->TimerQ.pQHead = pNode->pNext;
|
||||
if (pNode == pAd->TimerQ.pQTail)
|
||||
|
@ -264,15 +245,13 @@ BOOLEAN RtmpTimerQRemove(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void RtmpTimerQExit(RTMP_ADAPTER *pAd)
|
||||
void RtmpTimerQExit(RTMP_ADAPTER * pAd)
|
||||
{
|
||||
RTMP_TIMER_TASK_ENTRY *pTimerQ;
|
||||
unsigned long irqFlags;
|
||||
|
||||
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
|
||||
while (pAd->TimerQ.pQHead)
|
||||
{
|
||||
while (pAd->TimerQ.pQHead) {
|
||||
pTimerQ = pAd->TimerQ.pQHead;
|
||||
pAd->TimerQ.pQHead = pTimerQ->pNext;
|
||||
// remove the timeQ
|
||||
|
@ -288,10 +267,9 @@ void RtmpTimerQExit(RTMP_ADAPTER *pAd)
|
|||
|
||||
}
|
||||
|
||||
|
||||
void RtmpTimerQInit(RTMP_ADAPTER *pAd)
|
||||
void RtmpTimerQInit(RTMP_ADAPTER * pAd)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
RTMP_TIMER_TASK_ENTRY *pQNode, *pEntry;
|
||||
unsigned long irqFlags;
|
||||
|
||||
|
@ -299,16 +277,17 @@ void RtmpTimerQInit(RTMP_ADAPTER *pAd)
|
|||
|
||||
NdisZeroMemory(&pAd->TimerQ, sizeof(pAd->TimerQ));
|
||||
|
||||
os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll, sizeof(RTMP_TIMER_TASK_ENTRY) * TIMER_QUEUE_SIZE_MAX);
|
||||
if (pAd->TimerQ.pTimerQPoll)
|
||||
{
|
||||
os_alloc_mem(pAd, &pAd->TimerQ.pTimerQPoll,
|
||||
sizeof(RTMP_TIMER_TASK_ENTRY) * TIMER_QUEUE_SIZE_MAX);
|
||||
if (pAd->TimerQ.pTimerQPoll) {
|
||||
pEntry = NULL;
|
||||
pQNode = (RTMP_TIMER_TASK_ENTRY *)pAd->TimerQ.pTimerQPoll;
|
||||
NdisZeroMemory(pAd->TimerQ.pTimerQPoll, sizeof(RTMP_TIMER_TASK_ENTRY) * TIMER_QUEUE_SIZE_MAX);
|
||||
pQNode = (RTMP_TIMER_TASK_ENTRY *) pAd->TimerQ.pTimerQPoll;
|
||||
NdisZeroMemory(pAd->TimerQ.pTimerQPoll,
|
||||
sizeof(RTMP_TIMER_TASK_ENTRY) *
|
||||
TIMER_QUEUE_SIZE_MAX);
|
||||
|
||||
RTMP_INT_LOCK(&pAd->TimerQLock, irqFlags);
|
||||
for (i = 0 ;i <TIMER_QUEUE_SIZE_MAX; i++)
|
||||
{
|
||||
for (i = 0; i < TIMER_QUEUE_SIZE_MAX; i++) {
|
||||
pQNode->pNext = pEntry;
|
||||
pEntry = pQNode;
|
||||
pQNode++;
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue