📄 hwacproc.c
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/** @file hwacproc.c
* @This module has implmentation of station command
* processing functions
*
* Copyright (c) Marvell Semiconductor, Inc.
*/
#include "precomp.h"
extern ULONG DSFeqList[];
extern USHORT RegionCodeToIndex[MRVDRV_MAX_REGION_CODE];
extern UCHAR IEEERegionChannel[MRVDRV_MAX_REGION_CODE][MRVDRV_MAX_CHANNEL_NUMBER];
UCHAR EAPOLStartPacket[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // dest
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // src
0x88, 0x8e, 0x01, 0x01, 0x0, 0x0, 0x0 };
#ifdef ADHOCAES
VOID
HandleAdhocAES( IN PMRVDRV_ADAPTER Adapter,
IN PHostCmd_DS_802_11_PWK_KEY pKeyReturn,
IN PVOID info,
IN PULONG BytesWritten
)
{
PMRVL_ADHOC_AES_KEY pKey;
pKey = (PMRVL_ADHOC_AES_KEY)info;
pKey->Length = 16;
NdisMoveMemory(pKey->KeyBody, pKeyReturn->TkipEncryptKey, 16);
*BytesWritten = 16 + 4;
return ;
}
#endif
#ifdef HOST_WAKEUP
NDIS_STATUS Deactivate_Host_Wakeup_Cfg(PMRVDRV_ADAPTER Adapter)
{
OID_MRVL_DS_HOST_WAKEUP HW;
NDIS_STATUS Status;
DBGPRINT(DBG_HOSTWAKEUP,("++Deactivate_Host_Wakeup_Cfg\n"));
HW.ulCriteria = -1;
HW.ucGPIO = 0xff;
HW.ucGap = 0x10;
Status = PrepareAndSendCommand(
Adapter,
HostCmd_CMD_802_11_HOST_SLEEP_CFG,
HostCmd_ACT_GEN_SET,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
0,
(PVOID)&HW);
if (Status == NDIS_STATUS_FAILURE || Status == NDIS_STATUS_RESOURCES)
{
DBGPRINT(DBG_HOSTWAKEUP,("Send HostCmd_CMD_802_11_HOST_SLEEP_CFG FAIL !\n"));
return Status;
}
DBGPRINT(DBG_HOSTWAKEUP,("--Deactivate_Host_Wakeup_Cfg\n"));
return NDIS_STATUS_SUCCESS;
}
#endif
#ifdef BG_SCAN
/******************************************************************************
*
* Name: HandleBgScanResponse()
*
* Description: Handle background scan results
*
* Notes:
* The background scan results are added to PSBssidList.
*
*****************************************************************************/
VOID
HandleBgScanResponse(
PHostCmd_DS_802_11_BG_SCAN_QUERY_RSP pBgScanResponse,
PMRVDRV_ADAPTER Adapter
)
{
ULONG i,j;
USHORT Flag = 0;
ULONG TempV = 0,k;
NDIS_STATUS ndStat;
DBGPRINT(DBG_SCAN | DBG_CRLF ,("----------------------- Got background scan results ------------------------\n" ));
DBGPRINT(DBG_SCAN,("Command %x\n",(ULONG)pBgScanResponse -> Command));
DBGPRINT(DBG_SCAN,("Size %d SeqNum %d Result %d \n",
(ULONG)pBgScanResponse -> Size,
(ULONG)pBgScanResponse -> SeqNum,
(ULONG)pBgScanResponse -> Result
));
DBGPRINT(DBG_SCAN,("BSSDescriptSize %d\n",(ULONG)pBgScanResponse ->BSSDescriptSize));
DBGPRINT(DBG_SCAN,("NumberOfSets %d\n",(ULONG)pBgScanResponse ->NumberOfSets));
DBGPRINT(DBG_CMDRESP,("*** Scan returned %d AP before parsing ***\n", pBgScanResponse->NumberOfSets));
// Get number of BSS Descriptors
Adapter->ulNumOfBSSIDs = pBgScanResponse->NumberOfSets;
// Parse the return SCAN result
ndStat = InterpretBSSDescription(
Adapter,
(PVOID)(Adapter->CurCmd->BufVirtualAddr),
pBgScanResponse->BSSDescriptSize,
HostCmd_RET_802_11_BG_SCAN_QUERY );
if ( ndStat != NDIS_STATUS_SUCCESS )
{
DBGPRINT(DBG_SCAN | DBG_ERROR,("ERROR: InterpretBSSDescription returned ERROR\n"));
}
#ifdef DBG
DBGPRINT(DBG_SCAN,("*** Background scan Results: number of BSSID: %d\n", Adapter->ulNumOfBSSIDs));
for ( i=0; i < Adapter->ulNumOfBSSIDs; i++ )
{
DBGPRINT(DBG_SCAN,("\t\t%2d:\t%32s - %2x-%2x-%2x-%2x-%2x-%2x RSSI=%d\n",
i, Adapter->BSSIDList[i].Ssid.Ssid,
Adapter->BSSIDList[i].MacAddress[0],
Adapter->BSSIDList[i].MacAddress[1],
Adapter->BSSIDList[i].MacAddress[2],
Adapter->BSSIDList[i].MacAddress[3],
Adapter->BSSIDList[i].MacAddress[4],
Adapter->BSSIDList[i].MacAddress[5],
Adapter->BSSIDList[i].Rssi));
}
#endif
#ifdef MRVL_DBG_BG_SCAN
#ifdef MRVL_PRINT_DBG_MSG
for ( i=0; i < Adapter->ulNumOfBSSIDs; i++ )
{
MrvPrintFile("\t\t[Marvell]HandleBgScanResponse==>%2d:\t%32s - %2x-%2x-%2x-%2x-%2x-%2x RSSI=%d\n",
i, Adapter->BSSIDList[i].Ssid.Ssid,
Adapter->BSSIDList[i].MacAddress[0],
Adapter->BSSIDList[i].MacAddress[1],
Adapter->BSSIDList[i].MacAddress[2],
Adapter->BSSIDList[i].MacAddress[3],
Adapter->BSSIDList[i].MacAddress[4],
Adapter->BSSIDList[i].MacAddress[5],
Adapter->BSSIDList[i].Rssi);
}
#endif
#endif
//Check the whole BSSID list string if there's invalid character.
for ( Flag = 0, i=0; (i < Adapter->ulNumOfBSSIDs)||(Flag!=0); i++ )
{
// We'll re-check the first one when the previous first one has been discard.
if (Flag == 1)
{
Flag = 0;
i--;
}
do
{ //Check if there's invalid data rate.
for ( k=0,TempV=0; k < NDIS_SUPPORTED_RATES; k++)
TempV |= Adapter->BSSIDList[i].SupportedRates[k];
if (( TempV == 0 ) || (Adapter->BSSIDList[i].SupportedRates[0] == 0))
{
Flag = 1;
DBGPRINT(DBG_SCAN, ("Invalid support rate\n"));
break;
}
// check for DS config
#ifndef MRV_CHIP_8385H
if ((Adapter->BSSIDList[i].Configuration.DSConfig<2412000)||
(Adapter->BSSIDList[i].Configuration.DSConfig>2484000) )
{
Flag = 1;
DBGPRINT(DBG_SCAN, ("Invalid DSConfig: %d\n",
Adapter->BSSIDList[i].Configuration.DSConfig))
break;
}
#endif
// marked for support associate to Hide SSID
if ( Adapter->BSSIDList[i].Ssid.SsidLength == 0 )
{
Flag = 1;
break;
DBGPRINT(DBG_SCAN, ("0 length SSID, discard (%d)\n", i));
}
// Check the invalid SSID.
for (j=0; j < Adapter->BSSIDList[i].Ssid.SsidLength; j++)
{
if ( Adapter->BSSIDList[i].Ssid.Ssid[j] < 0x20 )
{
DBGPRINT(DBG_SCAN,("INVALID BSSID Setting flag to discard (%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
DBGPRINT(DBG_SCAN,("i = %d, j = %d, TempV = %x, Ssid[j] = %x, dsconfig = %d\n", i,j, TempV, Adapter->BSSIDList[i].Ssid.Ssid[j],Adapter->BSSIDList[i].Configuration.DSConfig));
// Replace the current BSSID struct with last one
Flag = 1;
break;
}
}
if ( Adapter->BSSIDList[i].Ssid.Ssid[0] == 0x20 )
{
Flag = 1;
break;
}
} while (0);
if (Flag == 1)
{
if ((i+1) == Adapter->ulNumOfBSSIDs)
{
DBGPRINT(DBG_SCAN,("INVALID BSSID DISCARDING LAST(%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
NdisZeroMemory( &(Adapter->BSSIDList[i]),
sizeof(NDIS_WLAN_BSSID_EX));
NdisZeroMemory( &(Adapter->IEBuffer[i]),
sizeof(MRV_BSSID_IE_LIST));
Adapter->ulNumOfBSSIDs -= 1;
Flag = 0;
break;
}
else
{
//We start replace the current invalid SSID with last SSID in array.
DBGPRINT(DBG_SCAN,("INVALID BSSID DISCARDING CURRENT(%d) %s\n",i, Adapter->BSSIDList[i].Ssid.Ssid));
NdisMoveMemory( &(Adapter->BSSIDList[i]),
&(Adapter->BSSIDList[Adapter->ulNumOfBSSIDs-1]),
sizeof(NDIS_WLAN_BSSID_EX));
NdisZeroMemory( &(Adapter->BSSIDList[Adapter->ulNumOfBSSIDs-1]),
sizeof(NDIS_WLAN_BSSID_EX));
NdisMoveMemory( &(Adapter->IEBuffer[i]),
&(Adapter->IEBuffer[Adapter->ulNumOfBSSIDs-1]),
sizeof(MRV_BSSID_IE_LIST));
NdisZeroMemory( &(Adapter->IEBuffer[Adapter->ulNumOfBSSIDs-1]),
sizeof(MRV_BSSID_IE_LIST));
Adapter->ulNumOfBSSIDs -= 1;
}
} // if (Flag == 1)
}
DBGPRINT(DBG_CMDRESP| DBG_ALLEN,("HWAC - Background scanned %2d APs\n", Adapter->ulNumOfBSSIDs));
{
// active scan, append AP only if it does not already exist
ULONG i,j;
BOOLEAN bFound;
for ( i=0; i < Adapter->ulNumOfBSSIDs; i++ )
{
bFound = FALSE;
for ( j=0; j < Adapter->ulPSNumOfBSSIDs; j++ )
{
// compare SSID, BSSID, and Mode
if ( Adapter->BSSIDList[i].Ssid.SsidLength !=
Adapter->PSBSSIDList[j].Ssid.SsidLength )
{
continue;
}
if ( NdisEqualMemory(Adapter->BSSIDList[i].Ssid.Ssid,
Adapter->PSBSSIDList[j].Ssid.Ssid,
Adapter->PSBSSIDList[j].Ssid.SsidLength) == 0 )
{
continue;
}
if ( NdisEqualMemory(Adapter->BSSIDList[i].MacAddress,
Adapter->PSBSSIDList[j].MacAddress,
ETH_ADDR_LENGTH) == 0 )
{
continue;
}
if ( Adapter->BSSIDList[i].InfrastructureMode !=
Adapter->PSBSSIDList[j].InfrastructureMode )
{
continue;
}
bFound = TRUE;
// replace the current entry
NdisMoveMemory(&Adapter->PSBSSIDList[j],
&Adapter->BSSIDList[i],
sizeof(NDIS_WLAN_BSSID_EX));
NdisMoveMemory(&Adapter->PSIEBuffer[j],
&Adapter->IEBuffer[i],
sizeof(MRV_BSSID_IE_LIST));
NdisMoveMemory(&Adapter->PSBssDescList[j],
&Adapter->BssDescList[i],
sizeof(BSS_DESCRIPTION_SET_ALL_FIELDS));
DBGPRINT(DBG_SCAN, ("PScan: Replace Specific Scan Entry %d "
"To Scan List\n", j));
}
if (! bFound)
{
if (Adapter->ulPSNumOfBSSIDs < MRVDRV_MAX_BSSID_LIST)
{
// append at the end
NdisMoveMemory( &Adapter->PSBSSIDList[Adapter->ulPSNumOfBSSIDs],
&Adapter->BSSIDList[i],
sizeof(NDIS_WLAN_BSSID_EX));
NdisMoveMemory( &Adapter->PSIEBuffer[Adapter->ulPSNumOfBSSIDs],
&Adapter->IEBuffer[i],
sizeof(MRV_BSSID_IE_LIST));
NdisMoveMemory( &Adapter->PSBssDescList[Adapter->ulPSNumOfBSSIDs],
&Adapter->BssDescList[i],
sizeof(BSS_DESCRIPTION_SET_ALL_FIELDS));
Adapter->ulPSNumOfBSSIDs++;
DBGPRINT(DBG_SCAN, ("PScan: Append Specific Scan Entry %d "
"To Scan List\n", i));
}
}
}
}
}
NDIS_STATUS
HandleBgScanResultEvent (
PMRVDRV_ADAPTER pAdapter
)
{
NDIS_STATUS Status;
OID_MRVL_DS_BG_SCAN_QUERY BgQuery;
#ifdef MRVL_DBG_BG_SCAN
#ifdef MRVL_PRINT_DBG_MSG
MrvPrintFile("\n[Marvell]HandleBgScanResultEvent : begin!!\n");
#endif
#endif
BgQuery.Oid = OID_MRVL_BG_SCAN_QUERY;
BgQuery.Flush = 1; // flush current results in firmware.
Status = PrepareAndSendCommand(
pAdapter,
HostCmd_CMD_802_11_BG_SCAN_QUERY,
HostCmd_ACT_GET,
HostCmd_OPTION_USE_INT,
(NDIS_OID)0,
HostCmd_PENDING_ON_NONE,
0,
FALSE,
NULL,
NULL,
NULL,
&BgQuery);
DBGPRINT( DBG_SCAN, ("Send out BG_SCAN_QUERY for getting background scan results [return: 0x%x]\n", Status) );
return Status;
}
#endif /* BG_SCAN */
/******************************************************************************
*
* Name: HandleMicError()
*
* Description: handle MIC error
*
* Arguments: PMRVDRV_ADAPTER Adapter
* UINT ErrorType
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
VOID
HandleMicError(
IN PMRVDRV_ADAPTER Adapter,
IN UINT ErrorType)
{
WPA_NOTIFY_OS message;
ULONG ulCurrTime;
ULONG ulTimeDiff;
NdisZeroMemory(&message, sizeof(WPA_NOTIFY_OS));
NdisMoveMemory(message.request.Bssid, Adapter->CurrentBSSID,
sizeof(Adapter->CurrentBSSID));
message.request.Length = sizeof(NDIS_802_11_AUTHENTICATION_REQUEST);
message.status.StatusType= Ndis802_11StatusType_Authentication;
switch (ErrorType)
{
case MACREG_INT_CODE_WPA_MIC_ERR_UNICAST:
message.request.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
DBGPRINT(DBG_WARNING | DBG_ALLEN, ("Pairwise MIC Error!\n"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -