📄 cmdsend.c
字号:
#elif defined(MRV_CHIP_8385H)
if ( (usDesiredPowerInDbm < 10) || (usDesiredPowerInDbm > 17) )
#else
if ( (usDesiredPowerInDbm < 5) || (usDesiredPowerInDbm > 17) )
#endif
{
return NDIS_STATUS_NOT_SUPPORTED;
}
pRTP->SupportTxPowerLevel=(USHORT)usDesiredPowerInDbm;
pRTP->CurrentTxPowerLevel=(USHORT)usDesiredPowerInDbm;
pRTP->PowerLevelList[0] = (USHORT)usDesiredPowerInDbm;
pRTP->Action=(USHORT)HostCmd_ACT_TX_POWER_OPT_SET;
DBGPRINT(DBG_OID,("****SendCommand -HostCmd_CMD_802_11_RF_TX_POWER- pRTP->SupportTxPowerLevel=%d\n",pRTP->SupportTxPowerLevel));
}
break;
case HostCmd_ACT_TX_POWER_OPT_GET:
{
DBGPRINT(DBG_OID,("****SendCommand -HostCmd_CMD_802_11_RF_TX_POWER- HostCmd_ACT_TX_POWER_OPT_GET\n"));
pRTP->Action = HostCmd_ACT_GEN_GET;
pRTP->SupportTxPowerLevel = MRVDRV_TX_POWER_LEVEL_TOTAL;
pRTP->CurrentTxPowerLevel = HostCmd_ACT_TX_POWER_INDEX_LOW;
pRTP->Action=(USHORT)HostCmd_ACT_TX_POWER_OPT_GET;
}
break;
case HostCmd_ACT_TX_POWER_OPT_SET_HIGH:
{
pRTP->Action = HostCmd_ACT_GEN_SET;
pRTP->SupportTxPowerLevel = MRVDRV_TX_POWER_LEVEL_HIGH;
}
break;
case HostCmd_ACT_TX_POWER_OPT_SET_MID:
{
pRTP->Action = HostCmd_ACT_GEN_SET;
pRTP->SupportTxPowerLevel = MRVDRV_TX_POWER_LEVEL_MID;
}
break;
case HostCmd_ACT_TX_POWER_OPT_SET_LOW:
{
pRTP->Action = HostCmd_ACT_GEN_SET;
pRTP->SupportTxPowerLevel = MRVDRV_TX_POWER_LEVEL_LOW;
}
break;
case HostCmd_ACT_TX_POWER_OPT_SET_TPC:
{
pRTP->Action = HostCmd_ACT_GEN_SET;
pRTP->SupportTxPowerLevel = HostCmd_ACT_TX_POWER_INDEX_TPC;
DBGPRINT(DBG_OID,("\n**** TPC %d****\n\n", *((ULONG *)InformationBuffer)));
}
break;
default:
return NDIS_STATUS_NOT_SUPPORTED;
}
}
break;
}
case HostCmd_CMD_802_11_RADIO_CONTROL:
{
Size = (USHORT)(sizeof(HostCmd_DS_802_11_RADIO_CONTROL));
pRadioControl = (PHostCmd_DS_802_11_RADIO_CONTROL)pCmdPtr;
pRadioControl->Action = CmdOption;
switch((UCHAR)(Adapter->Preamble))
{
case HostCmd_TYPE_SHORT_PREAMBLE:
pRadioControl->Control=SET_SHORT_PREAMBLE;
break;
case HostCmd_TYPE_LONG_PREAMBLE:
pRadioControl->Control=SET_LONG_PREAMBLE;
break;
default:
// case HostCmd_TYPE_AUTO_PREAMBLE: //dralee 20060613
pRadioControl->Control=SET_AUTO_PREAMBLE;
break;
}
#ifdef MRVL_SET_RF_RADIO
if ( CmdOption == HostCmd_ACT_SET )
{
if (Adapter->RadioOn)
{
pRadioControl->Control |= TURN_ON_RF;
}
else
{
pRadioControl->Control &= ~TURN_ON_RF;
}
DBGPRINT(DBG_OID, ("HostCmd_CMD_802_11_RADIO_CONTROL pRadioControl->Control=0x%x,Adapter->RadioOn=%d\n",pRadioControl->Control,Adapter->RadioOn));
}
#endif
break;
}
case HostCmd_CMD_802_11_RF_CHANNEL:
{
Size = (USHORT)(sizeof(HostCmd_DS_802_11_RF_CHANNEL));
pRFChannel = (PHostCmd_DS_802_11_RF_CHANNEL)pCmdPtr;
pRFChannel->Action = CmdOption;
if (Adapter->Channel == 0)
{
Adapter->Channel = DEFAULT_CHANNEL;
}
#ifdef MRVL_RFCHANNEL
if(CmdOption ==HostCmd_ACT_GEN_SET)
{
pRFChannel->CurentChannel = (UCHAR)Adapter->Channel;
DBGPRINT(DBG_OID,("SendCommand - HostCmd_CMD_802_11_RF_CHANNEL, Adapter->Channel=0x%x ****\n",Adapter->Channel));
}
#else
pRFChannel->CurentChannel = (UCHAR)Adapter->Channel;
#endif
}
break;
case HostCmd_CMD_802_11_AD_HOC_STOP:
{
// nothing to set for adhoc stop cmd
Size = (USHORT)(sizeof(HostCmd_DS_GEN));
break;
}
#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;
}
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;
//Plus++, 012706, 802.1x wep
USHORT wepKeyIndex;
//Plus--, 012706
// 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);
//Plus++, 012706, 802.1x wep
wepKeyIndex = pSetWEP->KeyIndex;
*((UCHAR *)(&pSetWEP->WEPTypeForKey1 + wepKeyIndex)) = ucWepType;
NdisMoveMemory((void *)(pSetWEP->WEP1 + wepKeyIndex * 16), pNewWEP->KeyMaterial, KeyLength);
// plus 802.1x
if (pNewWEP->KeyIndex & 0x80000000)
{
Adapter->txKeyIndex = pSetWEP->KeyIndex;
Adapter->txKeyLength = (USHORT)pNewWEP->KeyLength;
NdisMoveMemory(Adapter->txKeyMaterial, pNewWEP->KeyMaterial, pNewWEP->KeyLength);
}
else
{
if(Adapter->txKeyLength)
{
switch(Adapter->txKeyLength )
{
case 5:
ucWepType= HostCmd_TYPE_WEP_40_BIT;
break;
case 13:
ucWepType= HostCmd_TYPE_WEP_104_BIT;
break;
case 16:
ucWepType= HostCmd_TYPE_WEP_128_BIT;
break;
default:
ucWepType= HostCmd_TYPE_WEP_40_BIT;
break;
}
pSetWEP->KeyIndex = Adapter->txKeyIndex;
wepKeyIndex = pSetWEP->KeyIndex;
*((UCHAR *)(&pSetWEP->WEPTypeForKey1 + wepKeyIndex)) = ucWepType;
NdisMoveMemory((void *)(pSetWEP->WEP1 + wepKeyIndex * 16), Adapter->txKeyMaterial, Adapter->txKeyLength);
}
}
}
//Plus--, 012706
if (PendingOID == OID_802_11_REMOVE_WEP )
{
pSetWEP->Action = HostCmd_ACT_REMOVE;
KeyIndex = *((NDIS_802_11_KEY_INDEX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -