📄 request.c
字号:
// Force a disconnect whenever BSSID is set (even when new BSSID value is same as the old BSSID value)
// as we need to handle the case where the Host OS has changed other OID values (e.g.,
// OID_802_11_ENCRYPTION_STATUS, OID_802_11_AUTHENTICATION_MODE, etc.). These other OID values
// are sent to the device as part of the device connection process (i.e., via MIB Sets prior to
// sending the Activation Request).
DBG_LEV3(("Set of OID_802_11_BSSID: boNeedDisconnect = TRUE \n"));
psWlan->sChangeNetwork.boNeedDisconnect = TRUE;
// Try to connect to network with the BSSID.
vENDconnectNetwork( psAdapter, FALSE, FALSE );
}
break;
case OID_802_11_SSID:
{
PNDIS_802_11_SSID psSsid = (PNDIS_802_11_SSID)pvInformationBuffer;
*pulBytesRead = sizeof(ULONG) + psSsid->SsidLength;
psWlan->sChangeNetwork.ulOid = ulOid;
psWlan->sChangeNetwork.sSSID.SsidLength = psSsid->SsidLength;
OS_MEMCPY( psWlan->sChangeNetwork.sSSID.Ssid, psSsid->Ssid, psSsid->SsidLength );
psWlan->sChangeNetwork.sSSID.Ssid[psWlan->sChangeNetwork.sSSID.SsidLength] = '\0';
// Force a disconnect whenever SSID is set (even when new SSID value is same as the old SSID value)
// as we need to handle the case where the Host OS has changed other OID values (e.g.,
// OID_802_11_ENCRYPTION_STATUS, OID_802_11_AUTHENTICATION_MODE, etc.). These other OID values
// are sent to the device as part of the device connection process (i.e., via MIB Sets prior to
// sending the Activation Request).
DBG_LEV3(("Set of OID_802_11_SSID: boNeedDisconnect = TRUE \n"));
psWlan->sChangeNetwork.boNeedDisconnect = TRUE;
// Try to connect to network with the SSID.
vENDconnectNetwork( psAdapter, TRUE, FALSE );
}
break;
case OID_802_11_NETWORK_TYPE_IN_USE:
{
ULONG ulNetworkType = *(PULONG)pvInformationBuffer;
if ( ulNetworkType == Ndis802_11DS || ulNetworkType == Ndis802_11OFDM24 ||
(ulNetworkType == Ndis802_11OFDM5 && (psWlan->ulCardCapabilities & MIB_CA_DEVICE_CAPS_MASK_A_MODE)) )
{
if ( ulNetworkType != psWlan->ulNetworkTypeInUse )
{
if ( ulNetworkType == Ndis802_11OFDM5 || psWlan->ulNetworkTypeInUse == Ndis802_11OFDM5 )
{
// Reset device if going in or out of 802.11a mode.
psAdapter->boNeedReset = TRUE;
// Backup current domain and channel settings, restore the other set.
if ( ulNetworkType == Ndis802_11OFDM5 )
{
psWlan->ulBGRestrChannel = psWlan->ulRestrChannel;
psWlan->ulBGIbssChannel = psWlan->ulIbssChannel;
psWlan->ulBGRegDomain = psWlan->ulRegDomain;
psWlan->ulRestrChannel = psWlan->ulARestrChannel;
psWlan->ulIbssChannel = psWlan->ulAIbssChannel;
psWlan->ulRegDomain = psWlan->ulARegDomain;
}
else
{
psWlan->ulARestrChannel = psWlan->ulRestrChannel;
psWlan->ulAIbssChannel = psWlan->ulIbssChannel;
psWlan->ulARegDomain = psWlan->ulRegDomain;
psWlan->ulRestrChannel = psWlan->ulBGRestrChannel;
psWlan->ulIbssChannel = psWlan->ulBGIbssChannel;
psWlan->ulRegDomain = psWlan->ulBGRegDomain;
}
// Check domain and channel settings.
vENDcheckDomainChannel( ulNetworkType, &psWlan->ulRegDomain,
&psWlan->ulRestrChannel, &psWlan->ulIbssChannel );
}
else
{
if (( psWlan->ulInfraMode == Ndis802_11IBSS ) &&
( psWlan->boBGIbss54g == FALSE ))
{
// For ad-hoc mode, just save the setting, don't need to set MIB.
DBG_LEV1(("Ad-hoc mode, keep the original STA Protocol 802.11b.\n"));
}
else if ( psAdapter->eNetState != NET_DISCONNECTED )
{
psWlan->boSetProtocolType = TRUE;
// Send Disconnect request first.
vHALsendDisconnectReq( psHAL, FRAME_REASON_DEAUTH_SENDER_LEAVING );
}
else
{
uValue.u8Uint8 = (ulNetworkType == Ndis802_11DS) ? MIB_PROTOCOL_802_11B : MIB_PROTOCOL_802_11G;
// Send Set MIB request (MIB_PROTOCOL_TYPE) to Target.
vHALsendSetMibReq( psHAL, MIB_PROTOCOL_TYPE, &uValue );
}
}
psWlan->ulNetworkTypeInUse = ulNetworkType;
vENDsetDefaultRateSet( psWlan->ulNetworkTypeInUse, psWlan->ucSupportedRates, psWlan->ucDesiredRates );
}
}
else
{
iStatus = NDIS_STATUS_NOT_SUPPORTED;
}
}
break;
case OID_802_11_RSSI_TRIGGER:
psWlan->lRssiTrigger = *(NDIS_802_11_RSSI *)pvInformationBuffer;
*pulBytesRead = sizeof( NDIS_802_11_RSSI );
break;
case OID_802_11_INFRASTRUCTURE_MODE:
// When infrastructure mode changes, send Disconnect request to Target
// if current media state is Connected or current network mode is ad-hoc.
if ( (psWlan->ulInfraMode != *(PULONG)pvInformationBuffer) &&
((psWlan->ulInfraMode == Ndis802_11IBSS) || (psAdapter->eNetState == NET_CONNECTED)) )
{
DBG_LEV2(("Send Disconnect Req after set of OID_802_11_INFRASTRUCTURE_MODE\n"));
vHALsendDisconnectReq( psHAL, FRAME_REASON_DEAUTH_SENDER_LEAVING );
// FIXME: No support for handling Sets of Pending Oids...
iStatus = NDIS_STATUS_PENDING;
psAdapter->sPendingOID.ulOid = ulOid;
}
psWlan->ulInfraMode = *(PULONG)pvInformationBuffer;
DBG_LEV3(("Set infrastructure mode %d.\n", psWlan->ulInfraMode));
break;
case OID_802_11_FRAGMENTATION_THRESHOLD:
psWlan->ulFragmentThreshold = *(PULONG)pvInformationBuffer;
uValue.u16Uint16 = (USHORT)psWlan->ulFragmentThreshold;
// Send Set MIB request (MIB_FRAGMENT_THRESHOLD) to Target.
vHALsendSetMibReq( psHAL, MIB_FRAGMENT_THRESHOLD, &uValue );
break;
case OID_802_11_RTS_THRESHOLD:
psWlan->ulRTSThreshold = *(PULONG)pvInformationBuffer;
uValue.u16Uint16 = (USHORT)psWlan->ulRTSThreshold;
// Send Set MIB request (MIB_RTS_THRESHOLD) to Target.
vHALsendSetMibReq( psHAL, MIB_RTS_THRESHOLD, &uValue );
break;
case OID_802_11_RX_ANTENNA_SELECTED:
if ( *(PULONG)pvInformationBuffer + 1 > psWlan->ulNumOfRxAntennas )
iStatus = NDIS_STATUS_INVALID_DATA;
else
{
psWlan->ulRxAntennaSelected = *(PULONG)pvInformationBuffer;
uValue.u32Uint32 = psWlan->ulRxAntennaSelected + 1;
// Send Set MIB request (MIB_DIVERSITY_SELECTION_RX) to Target.
vHALsendSetMibReq( psHAL, MIB_DIVERSITY_SELECTION_RX, &uValue );
}
break;
case OID_802_11_TX_ANTENNA_SELECTED:
if ( *(PULONG)pvInformationBuffer + 1 > psWlan->ulNumOfTxAntennas )
iStatus = NDIS_STATUS_INVALID_DATA;
else
{
psWlan->ulTxAntennaSelected = *(PULONG)pvInformationBuffer;
uValue.u32Uint32 = psWlan->ulTxAntennaSelected + 1;
// Send Set MIB request (MIB_CURRENT_TX_ANTENNA) to Target.
vHALsendSetMibReq( psHAL, MIB_CURRENT_TX_ANTENNA, &uValue );
}
break;
case OID_802_11_DESIRED_RATES:
iStatus = NDIS_STATUS_NOT_SUPPORTED;
break;
case OID_802_11_CONFIGURATION:
if ( ulInformationBufferLength > sizeof( NDIS_802_11_CONFIGURATION ) ||
ulInformationBufferLength < sizeof( ULONG ) * 4 )
iStatus = NDIS_STATUS_INVALID_DATA;
else if ( psAdapter->eNetState == NET_DISCONNECTED ) //FIXME: or NET_SETUP?
{
PNDIS_802_11_CONFIGURATION psRadioCfg = (PNDIS_802_11_CONFIGURATION)pvInformationBuffer;
psWlan->sRadioConfig.ATIMWindow = psRadioCfg->ATIMWindow;
*pulBytesRead = ulInformationBufferLength;
uValue.u16Uint16 = (USHORT)psWlan->sRadioConfig.ATIMWindow;
// Send Set MIB request (MIB_ATIM_WINDOW) to Target.
vHALsendSetMibReq( psHAL, MIB_ATIM_WINDOW, &uValue );
// Some parameters are only for IBSS mode.
if ( psWlan->ulInfraMode == Ndis802_11IBSS )
{
psWlan->sRadioConfig.DSConfig = psRadioCfg->DSConfig;
uValue.u32Uint32 = 0;
vENDgetChannelFrequency( psWlan->sRadioConfig.DSConfig, &uValue.u32Uint32 );
psWlan->ulIbssChannel = uValue.u32Uint32;
// Send Set MIB request (MIB_IBSS_CHANNEL_NUMBER) to Target.
vHALsendSetMibReq( psHAL, MIB_IBSS_CHANNEL_NUMBER, &uValue );
}
}
else
iStatus = NDIS_STATUS_NOT_ACCEPTED;
break;
case OID_802_11_ADD_WEP:
{
PNDIS_802_11_WEP psWEPKey = (PNDIS_802_11_WEP) pvInformationBuffer;
ULONG ulLength, ulIndex;
ulLength = sizeof(ULONG) * 3 + psWEPKey->KeyLength;
if ( psWEPKey->Length < ulLength )
{
*pulBytesNeeded = ulLength;
iStatus = NDIS_STATUS_INVALID_LENGTH;
}
else
{
ulIndex = psWEPKey->KeyIndex & 0x03;
if ( psWEPKey->KeyIndex & 0x80000000 )
{
psWlan->boTransmitKeyAvail = TRUE;
psWlan->ulDefaultWEPKeyId = ulIndex;
uValue.u32Uint32 = psWlan->ulDefaultWEPKeyId;
// Send Set MIB request (MIB_WEP_DEFAULT_KEYID) to Target.
vHALsendSetMibReq( psHAL, MIB_WEP_DEFAULT_KEYID, &uValue );
}
// Backup the WEP key.
psWlan->sWEPKeys.sKey[ulIndex].u8KeyLength = (UCHAR)psWEPKey->KeyLength;
OS_MEMZERO( psWlan->sWEPKeys.sKey[ulIndex].au8KeyData, MIB_WEP_KEY_MAX_LENGTH );
OS_MEMCPY( psWlan->sWEPKeys.sKey[ulIndex].au8KeyData,
psWEPKey->KeyMaterial, psWEPKey->KeyLength );
*pulBytesRead = ulLength;
OS_MEMCPY( &uValue.sDefaultWEPKeys, &psWlan->sWEPKeys, sizeof(MIB_WEP_DEF_KEYS) );
// Send Set MIB request (MIB_WEP_DEFAULT_KEYS) to Target.
vHALsendSetMibReq( psHAL, MIB_WEP_DEFAULT_KEYS, &uValue );
DBG_LEV1(("Add WEP, key index 0x%x, key length %d.\n", psWEPKey->KeyIndex, psWEPKey->KeyLength));
}
}
break;
case OID_802_11_REMOVE_WEP:
{
ULONG ulKeyIndex = *(PULONG)pvInformationBuffer;
ULONG ulIndex;
if ( ulKeyIndex & 0x80000000 )
iStatus = NDIS_STATUS_INVALID_DATA;
else
{
ulIndex = ulKeyIndex & 0x03;
if ( ulIndex == psWlan->ulDefaultWEPKeyId )
psWlan->boTransmitKeyAvail = FALSE;
// Clear out the WEP key.
OS_MEMZERO( psWlan->sWEPKeys.sKey[ulIndex].au8KeyData, MIB_WEP_KEY_MAX_LENGTH );
psWlan->sWEPKeys.sKey[ulIndex].u8KeyLength = 0;
OS_MEMCPY( &uValue.sDefaultWEPKeys, &psWlan->sWEPKeys, sizeof(MIB_WEP_DEF_KEYS) );
// Send Set MIB request (MIB_WEP_DEFAULT_KEYS) to Target.
vHALsendSetMibReq( psHAL, MIB_WEP_DEFAULT_KEYS, &uValue );
DBG_LEV1(("Clear WEP, key index 0x%x.\n", ulIndex));
}
}
break;
case OID_802_11_DISASSOCIATE:
if (( psAdapter->eNetState == NET_CONNECTED ) ||
( psAdapter->eNetState == NET_DISCONNECTING )) // need to re-send disconnect if device is stuck in this state
{
// Send Disconnect request to Target.
DBG_LEV2(("Send Disconnect Req after set of OID_802_11_DISASSOCIATE\n"));
vHALsendDisconnectReq( psHAL, FRAME_REASON_DEAUTH_SENDER_LEAVING );
}
DBG_LEV2(("Set disassociate.\n"));
break;
case OID_802_11_POWER_MODE:
{
ULONG ulPowerMode = *(PULONG)pvInformationBuffer;
BOOLEAN boEnablePS;
DBG_LEV2(("Set Power Mode OID, %d, was %d before.\n", ulPowerMode,
psWlan->ulPowerMode));
if ( (ulPowerMode == Ndis802_11PowerModeCAM && psWlan->ulPowerMode == Ndis802_11PowerModeMAX_PSP) ||
(ulPowerMode == Ndis802_11PowerModeMAX_PSP && psWlan->ulPowerMode == Ndis802_11PowerModeCAM) )
{
boEnablePS = (ulPowerMode == Ndis802_11PowerModeCAM) ? FALSE : TRUE;
// Send Power Mode request to Target.
vHALsendPowerModeReq( psHAL, boEnablePS );
}
// if not a valid power mode return error code
else if ((ulPowerMode != Ndis802_11PowerModeCAM) && (ulPowerMode != Ndis802_11PowerModeMAX_PSP))
{
iStatus = NDIS_STATUS_NOT_SUPPORTED;
}
}
break;
case OID_802_11_AUTHENTICATION_MODE:
if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeWPAPSK)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_WPA;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = IW_AUTH_KEY_MGMT_PSK;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_OPEN_SYSTEM;
}
else if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeWPA)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_WPA;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = 0;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_OPEN_SYSTEM;
}
else if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeWPA2PSK)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_WPA2;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = IW_AUTH_KEY_MGMT_PSK;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_OPEN_SYSTEM;
}
else if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeWPA2)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_WPA2;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = 0;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_OPEN_SYSTEM;
}
else if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeShared)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_DISABLED;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = 0;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_SHARED_KEY;
}
else if (*(PULONG)pvInformationBuffer == Ndis802_11AuthModeOpen)
{
psWlan->auth_params[IW_AUTH_WPA_VERSION] = IW_AUTH_WPA_VERSION_DISABLED;
psWlan->auth_params[IW_AUTH_KEY_MGMT] = 0;
psWlan->auth_params[IW_AUTH_80211_AUTH_ALG] = IW_AUTH_ALG_OPEN_SYSTEM;
}
else // e.g. Ndis802_11AuthModeWPANone
{
iStatus = NDIS_STATUS_NOT_SUPPORTED;
break;
}
psWlan->sChangeNetwork.boAuthModeChanged = TRUE;
DBG_LEV1(("Save the authentication mode %d.\n", *(PULONG)pvInformationBuffer));
// Setting the authentication mode implicitly invalidates any currently set WEP keys.
NdisZeroMemory(&psWlan->sWEPKeys, sizeof(MIB_WEP_DEF_KEYS) );
break;
case OID_802_11_BSSID_LIST_SCAN:
// if ( psAdapter->eNetState > NET_SETUP && psWlan->boScanInProgress == FALSE )
if ( ((psAdapter->eNetState == NET_CONNECTED) ||
(psAdapter->eNetState == NET_DISCONNECTED)) &&
(psWlan->boScanInProgress == FALSE) )
{
// remove expired Bssids from List
vENDCleanBssidList(psHAL);
// Send Scan request to Target.
vHALsendScanReq( psHAL );
//DBG_LEV2(("BSSID list scan.\n"));
DBG_LEV2(("BSSID list scan.\n"));
}
else
{
iStatus = NDIS_STATUS_NOT_ACCEPTED;
}
break;
case OID_802_11_ENCRYPTION_STATUS:
if ( *(PULONG)pvInformationBuffer == Ndis802_11EncryptionDisabled )
{
psWlan->auth_params[IW_AUTH_CIPHER_GROUP] = IW_AUTH_CIPHER_NONE;
}
else if ( *(PULONG)pvInformationBuffer == Ndis802_11Encryption1Enabled )
{
psWlan->auth_params[IW_AUTH_CIPHER_GROUP] = IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40;
}
else if ( *(PULONG)pvInformationBuffer == Ndis802_11Encryption2Enabled )
{
psWlan->auth_params[IW_AUTH_CIPHER_GROUP] =
IW_AUTH_CIPHER_TKIP | IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40;
}
else if ( *(PULONG)pvInformationBuffer == Ndis802_11Encryption3Enabled )
{
psWlan->auth_params[IW_AUTH_CIPHER_GROUP] = IW_AUTH_CIPHER_CCMP |
IW_AUTH_CIPHER_TKIP | IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40;
}
else
{
iStatus = NDIS_STATUS_NOT_SUPPORTED;
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -