📄 cmdsend.c
字号:
}
#ifdef ENABLE_802_11D
case HostCmd_CMD_802_11D_DOMAIN_INFO:
{
PHostCmd_DS_802_11D_DOMAIN_INFO pDomainInfo;
pDomainInfo = (PHostCmd_DS_802_11D_DOMAIN_INFO)pCmdPtr;
if (CmdOption == HostCmd_ACT_SET)
{
GenerateDomainInfoFromCountryIE(
&(pDomainInfo->Domain),
(IEEEtypes_CountryInfoFullSet_t *)InformationBuffer
);
pDomainInfo->Size = 8 + 2 + 4 + pDomainInfo->Domain.Header.Len;
}
else if (CmdOption == HostCmd_ACT_GET)
{
pDomainInfo->Size = 8 + 2;
}
Size = pDomainInfo->Size;
HexDump(DBG_ALLEN, "HostCmd_CMD_802_11D_DOMAIN_INFO dump", (UCHAR *)pCmdPtr,
pDomainInfo->Size);
}
break;
#endif
#ifdef WPA2
case HostCmd_CMD_802_11_KEY_MATERIAL:
pKeyMaterial = (PHostCmd_DS_802_11_KEY_MATERIAL)pCmdPtr;
SetupKeyMaterial(
Adapter,
pKeyMaterial,
CmdOption,
INTOption,
InformationBuffer);
Size = pKeyMaterial->Size;
break;
#endif
default:
DBGPRINT(DBG_ERROR, ("ERROR: Unrecognized command 0x%x!!\n", Cmd));
break;
}
// Set command size
pCmdPtr->Size = Size;
// If there is no pending command, download command, else, append command to Q
if (Size == 0)
{
DBGPRINT(DBG_CMDRESP,("HWAC - Detected command with size zero, cmd = 0x%x", Cmd));
ReturnCmdNode(Adapter, pTempCmd);
}
else
{
InsertCmdToQueue (Adapter, pTempCmd);
GetCmdFromQueueToExecute(Adapter);
}
return NDIS_STATUS_SUCCESS;
}
/******************************************************************************
*
* Name: SetupDataRate()
*
* Description: Prepare data rate command
*
* Arguments: PHostCmd_DS_802_11_DATA_RATE pDataRate
* PMRVDRV_ADAPTER Adapter
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
VOID
SetupDataRate(
USHORT CmdOption,
PHostCmd_DS_802_11_DATA_RATE pDataRate,
PMRVDRV_ADAPTER Adapter,
PVOID InformationBuffer
)
{
UCHAR *pDot11DataRate;
UCHAR FWIndex;
DBGPRINT(DBG_CMDRESP,("HostCmd_CMD_802_11_DATA_RATE\n"));
// HostCmd_ACT_SET
if (CmdOption == HostCmd_ACT_GET)
{
DBGPRINT(DBG_CMDRESP,("SetupDataRate(): GET Data Rate\n"));
pDataRate->Action = HostCmd_ACT_GET_TX_RATE;
}
else if(CmdOption == HostCmd_ACT_SET)
{
DBGPRINT(DBG_DATARATE,("SetupDataRate(): Setting FW for fixed rate\n"));
pDot11DataRate = (UCHAR *)InformationBuffer;
FWIndex = ConvertNDISRateToFWIndex(*(pDot11DataRate));
if (*pDot11DataRate==0)
{
DBGPRINT(DBG_CMDRESP | DBG_ERROR,
("SetupDataRate(): Error looking up FW Index, use auto rate!\n"));
pDataRate->Action = HostCmd_ACT_SET_TX_AUTO;
}
else
{
// Fixed rate setting
pDataRate->Action = HostCmd_ACT_SET_TX_FIX_RATE;
pDataRate->DataRate[0] = FWIndex;
DBGPRINT(DBG_CMDRESP, ("Data rate index set to %d\n", FWIndex));
}
}
}
/******************************************************************************
*
* Name: CleanupWepKeys()
*
* Description: Cleanup WEP keys
*
* Arguments: PHostCmd_DS_802_11_SET_WEP pSetWEP
*
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
VOID
CleanupWepKeys(
PHostCmd_DS_802_11_SET_WEP pSetWEP
)
{
pSetWEP->WEPTypeForKey1 = 0;
pSetWEP->WEPTypeForKey2 = 0;
pSetWEP->WEPTypeForKey3 = 0;
pSetWEP->WEPTypeForKey4 = 0;
NdisZeroMemory(pSetWEP->WEP1, MRVL_KEY_BUFFER_SIZE_IN_BYTE);
NdisZeroMemory(pSetWEP->WEP2, MRVL_KEY_BUFFER_SIZE_IN_BYTE);
NdisZeroMemory(pSetWEP->WEP3, MRVL_KEY_BUFFER_SIZE_IN_BYTE);
NdisZeroMemory(pSetWEP->WEP4, MRVL_KEY_BUFFER_SIZE_IN_BYTE);
}
/******************************************************************************
*
* Name: SetupWepKeys()
*
* Description: Setup WEP keys
*
* Arguments: NDIS_OID PendingOID
* PHostCmd_DS_802_11_SET_WEP pSetWEP
* PNDIS_802_11_WEP pNewWEP
*
* Return Value:
*
* Notes:
*
*****************************************************************************/
VOID
SetupWepKeys(
NDIS_OID PendingOID,
PHostCmd_DS_802_11_SET_WEP pSetWEP,
PNDIS_802_11_WEP pNewWEP,
PVOID InformationBuffer,
PMRVDRV_ADAPTER Adapter,
USHORT CmdOption
)
{
NDIS_802_11_KEY_INDEX KeyIndex;
UCHAR ucWepType;
ULONG KeyLength;
// May need to check pending OID and OID information buffer to get
// more information
if (PendingOID == OID_802_11_ADD_WEP )
{
pSetWEP->Action = HostCmd_ACT_ADD;
pSetWEP->KeyIndex = (USHORT) (pNewWEP->KeyIndex & (ULONG)HostCmd_WEP_KEY_INDEX_MASK);
KeyLength = pNewWEP->KeyLength;
if ( KeyLength == 5 )
ucWepType= HostCmd_TYPE_WEP_40_BIT;
if ( KeyLength == 13 )
ucWepType= HostCmd_TYPE_WEP_104_BIT;
if ( KeyLength == 16 )
ucWepType= HostCmd_TYPE_WEP_128_BIT;
// clean-up all the WEP key types and WEP keys
CleanupWepKeys(pSetWEP);
switch( pSetWEP->KeyIndex)
{
case 0:
pSetWEP->WEPTypeForKey1 = ucWepType;
NdisMoveMemory(pSetWEP->WEP1, pNewWEP->KeyMaterial, KeyLength);
break;
case 1:
pSetWEP->WEPTypeForKey2 = ucWepType;
NdisMoveMemory(pSetWEP->WEP2, pNewWEP->KeyMaterial, KeyLength);
break;
case 2:
pSetWEP->WEPTypeForKey3 = ucWepType;
NdisMoveMemory(pSetWEP->WEP3, pNewWEP->KeyMaterial, KeyLength);
break;
case 3:
pSetWEP->WEPTypeForKey4 = ucWepType;
NdisMoveMemory(pSetWEP->WEP4, pNewWEP->KeyMaterial, KeyLength);
break;
default:
break;
}
}
if (PendingOID == OID_802_11_REMOVE_WEP )
{
pSetWEP->Action = HostCmd_ACT_REMOVE;
KeyIndex = *((NDIS_802_11_KEY_INDEX *)(InformationBuffer));
KeyIndex = KeyIndex & HostCmd_WEP_KEY_INDEX_MASK;
CleanupWepKeys(pSetWEP);
switch( KeyIndex )
{
case 0:
pSetWEP->WEPTypeForKey1 =0;
pSetWEP->WEP1[0] = 0xff;
break;
case 1:
pSetWEP->WEPTypeForKey2 =0;
pSetWEP->WEP2[0] = 0xff;
break;
case 2:
pSetWEP->WEPTypeForKey3 =0;
pSetWEP->WEP3[0] = 0xff;
break;
case 3:
pSetWEP->WEPTypeForKey4 =0;
pSetWEP->WEP4[0] = 0xff;
break;
default:
break;
}
NdisZeroMemory(&(Adapter->CurrentWEPKey), sizeof(MRVL_WEP_KEY));
}
if(PendingOID == OID_802_11_RELOAD_DEFAULTS )
{
pSetWEP->Action = CmdOption;
// pSetWEP->WEPType = 0;
// pSetWEP->NumOfKeys = 0;
}
}
VOID
UpdateWEPTable(
PMRVDRV_ADAPTER Adapter,
PVOID InformationBuffer
)
{
#ifdef MRVL_WINXP_NDIS51
// update WEP Table
if (Adapter->LastAddedWEPKey.Length > 0)
{
NdisMoveMemory(&(Adapter->CurrentWEPKey), &(Adapter->LastAddedWEPKey), sizeof(MRVL_WEP_KEY));
///NdisZeroMemory(&(Adapter->LastAddedWEPKey),sizeof(MRVL_WEP_KEY));
}
#endif
}
#ifdef WPA2
int SetupKeyMaterial(
PMRVDRV_ADAPTER Adapter,
PHostCmd_DS_802_11_KEY_MATERIAL pKeyMaterial,
USHORT option,
USHORT enable,
void *InformationBuffer)
{
PNDIS_802_11_KEY pKey = (PNDIS_802_11_KEY)InformationBuffer;
USHORT KeyParamSet_len;
PMRVL_NDIS_WPA_KEY pKeyIn;
KeyMaterial_TKIP_t *pKeyTkipOut;
KeyMaterial_AES_t *pKeyAesOut;
pKeyMaterial->Action = option;
if( option == HostCmd_ACT_GET )
{
pKeyMaterial->Size = 2 + 8;
DBGPRINT(DBG_CMDRESP, ("SetupKeyMaterial Get\n"));
return 0;
}
DBGPRINT(DBG_CMDRESP, ("SetupKeyMaterial Set\n"));
NdisZeroMemory(&(pKeyMaterial->KeyParamSet), sizeof(MrvlIEtype_KeyParamSet_t));
pKeyIn = (PMRVL_NDIS_WPA_KEY)pKey->KeyMaterial;
if (pKey->KeyLength == WPA_AES_KEY_LEN)
{
DBGPRINT(DBG_CMDRESP, ("Set AES key\n"));
pKeyMaterial->KeyParamSet.KeyTypeId = KEY_TYPE_ID_AES;
if ( enable == KEY_INFO_ENABLED )
pKeyMaterial->KeyParamSet.KeyInfo = KEY_INFO_AES_ENABLED;
else
pKeyMaterial->KeyParamSet.KeyInfo = !(KEY_INFO_AES_ENABLED);
if (pKey->KeyIndex & 0x40000000) // AES pairwise key: unicast
pKeyMaterial->KeyParamSet.KeyInfo |= KEY_INFO_AES_UNICAST;
else // AES group key: multicast
pKeyMaterial->KeyParamSet.KeyInfo |= KEY_INFO_AES_MCAST;
pKeyAesOut = (KeyMaterial_AES_t *)pKeyMaterial->KeyParamSet.Key;
NdisMoveMemory(pKeyAesOut->AesKey, pKeyIn->EncryptionKey, 16);
}
else if (pKey->KeyLength == WPA_TKIP_KEY_LEN)
{
DBGPRINT(DBG_CMDRESP, ("Set TKIP key\n"));
pKeyMaterial->KeyParamSet.KeyTypeId = KEY_TYPE_ID_TKIP;
pKeyMaterial->KeyParamSet.KeyInfo = KEY_INFO_TKIP_ENABLED;
if (pKey->KeyIndex & 0x40000000) // TKIP pairwise key: unicast
pKeyMaterial->KeyParamSet.KeyInfo |= KEY_INFO_TKIP_UNICAST;
else // TKIP group key: multicast
pKeyMaterial->KeyParamSet.KeyInfo |= KEY_INFO_TKIP_MCAST;
pKeyTkipOut = (KeyMaterial_TKIP_t *)pKeyMaterial->KeyParamSet.Key;
NdisMoveMemory(pKeyTkipOut->TkipKey, pKeyIn->EncryptionKey, 16);
NdisMoveMemory(pKeyTkipOut->TkipRxMicKey, pKeyIn->MICKey1, 8);
NdisMoveMemory(pKeyTkipOut->TkipTxMicKey, pKeyIn->MICKey2, 8);
}
if (pKeyMaterial->KeyParamSet.KeyTypeId)
{
pKeyMaterial->KeyParamSet.Type = TLV_TYPE_KEY_MATERIAL;
pKeyMaterial->KeyParamSet.KeyLen = (USHORT)pKey->KeyLength;
pKeyMaterial->KeyParamSet.Length = (USHORT)(pKey->KeyLength + 6);
// 2 bytes for Type, 2 bytes for Length
KeyParamSet_len = pKeyMaterial->KeyParamSet.Length + 4;
// 2 bytes for Action
pKeyMaterial->Size = KeyParamSet_len + 2 + 8;
}
HexDump(DBG_ALLEN, "NdisKey context", (UCHAR *)pKey, sizeof(NDIS_802_11_KEY)+ pKey->KeyLength);
HexDump(DBG_ALLEN, "pKeyMaterial context", (UCHAR *)pKeyMaterial, pKeyMaterial->Size);
return 0;
}
#endif //WPA2
#ifdef TLV_ASSOCIATE
NDIS_STATUS
SetupAssociationExt (
PHostCmd_DS_802_11_ASSOCIATE_EXT pAsso,
USHORT PendingInfo,
PMRVDRV_ADAPTER Adapter,
CmdCtrlNode *pTempCmd,
PVOID InformationBuffer
)
{
ULONG i, ulAttemptSSIDIdx;
BOOLEAN bSsidFound = FALSE;
long lRSSI;
ULONG ulNumBSSID;
PNDIS_WLAN_BSSID_EX pBSSIDListSrc;
PNDIS_802_11_FIXED_IEs pF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -