?? car6koid.cpp
字號:
//TODO: New SSID is the same as the old. No need to indicate MEDIA_DISCONNECT
// to NDIS immediately. If the subsequent connection attempt fails then we can
// indicate MEDIA_DISCONNECT to NDIS.
}
m_SSID = *lSSID;
// Initialize the GrpwiseCrypto index to 0 to start afresh.
m_GrpwiseCryptoIndex = 0;
if (m_ConnectInProgress || m_Connected)
{
Status = SendWMIDisconnectCommand();
}
else
{
// No current connection,
Status = SendWMIConnectCommand(SSID);
}
}
done:
return Status;
}
NDIS_STATUS
CAR6KMini::Set802_11NetworkTypeInUse(
IN NDIS_802_11_NETWORK_TYPE Type)
{
if (Type == Ndis802_11DS || Type == Ndis802_11OFDM24) {
m_NetworkTypeInUse = Type;
return NDIS_STATUS_SUCCESS;
}
else
return NDIS_STATUS_INVALID_DATA;
}
NDIS_STATUS
CAR6KMini::Set802_11TxPowerLevel(
IN NDIS_802_11_TX_POWER_LEVEL Level)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11RSSITrigger(
IN NDIS_802_11_RSSI Trigger)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11InfrastructureMode(
IN NDIS_802_11_NETWORK_INFRASTRUCTURE Mode)
{
int i;
A_STATUS wmiStatus;
BYTE KeyIndex;
if (!m_WMIReady) {
return NDIS_STATUS_ADAPTER_NOT_READY;
}
m_InfrastructureMode = Mode;
// Clear all the Keys as per OID Recommendation
for (i=0;i<4;i++) {
if (m_Key[i]) {
KeyIndex=(BYTE)(m_KeyIndex[i]);
memset(m_Key[i],0,sizeof(m_Key[i]));
m_cbKey[i] = 0;
m_KeyIndex[i] = 0;
m_KeyRSC[i] = 0;
wmiStatus = wmi_deleteKey_cmd((wmi_t *)m_pWMI, KeyIndex);
if (wmiStatus != A_OK) {
return NDIS_STATUS_FAILURE;
}
}
}
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11FragmentationThreshold(
IN NDIS_802_11_FRAGMENTATION_THRESHOLD Threshold)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11RTSThreshold(
IN NDIS_802_11_RTS_THRESHOLD Threshold)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11RxAntennaSelected(
IN ULONG Antenna)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11TxAntennaSelected(
IN ULONG Antenna)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11DesiredRates(
IN NDIS_802_11_RATES *Rates)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11Configuration(
IN NDIS_802_11_CONFIGURATION *pConfiguration)
//
// Set the underlying NIC's radio configuration parameters to the specified values
//
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// This OID can only be set when the device is not associated
// within the desired SSID. The miniport driver must return
// NDIS_STATUS_NOT_ACCEPTED if it is currently associated.
if (m_Connected)
Status = NDIS_STATUS_NOT_ACCEPTED;
else
{
if ( m_InfrastructureMode == Ndis802_11IBSS ) {
m_Config.ibssChannel = pConfiguration->DSConfig;
}
// BeaconPeriod specifies the beacon interval for ad hoc mode.
// BeaconPeriod is ignored in infrastructure mode
// wmi_set_adhoc_beacon_interval(BeaconPeriod);
}
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11Disassociate()
//
// Disassociate from the current service set and turn off the radio.
//
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
A_STATUS wmiStatus;
m_WantToBeConnected = false;
m_SSID.SsidLength = 0;
// Only need to do something if we are connected
if (m_Connected)
{
if (!m_WMIReady) {
// Hardware is not in a state where we can send it commands
Status = NDIS_STATUS_ADAPTER_NOT_READY;
}
else {
Status = SendWMIDisconnectCommand();
}
}
wmiStatus = wmi_scanparams_cmd((wmi_t *)m_pWMI,65535,0,0,0,0,0);
if ( wmiStatus != A_OK ) {
NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - wmi_scanparams_cmd failed = %u\n", wmiStatus);
}
wmi_free_allnodes((wmi_t *)m_pWMI);
if (m_Connected && Status==NDIS_STATUS_SUCCESS) {
m_Connected = false;
NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
}
m_RadioDisabled = TRUE;
return Status;
}
NDIS_STATUS
CAR6KMini::Set802_11PowerMode(
IN NDIS_802_11_POWER_MODE PowerMode)
{
A_STATUS Status = A_OK;
A_UINT8 powerMode = 0;
A_UINT16 listenInterval = MIN_LISTEN_INTERVAL;
// return if PowerMode @ target is already the same as what we get here.
if (PowerMode == m_80211_PowerMode)
return NDIS_STATUS_SUCCESS;
switch( PowerMode ) {
case Ndis802_11PowerModeCAM:
powerMode = MAX_PERF_POWER;
break;
case Ndis802_11PowerModeMAX_PSP:
//Increase the listen interval to 1000 TUs ensure MAX_PSP.
listenInterval = MAX_LISTEN_INTERVAL;
powerMode = REC_POWER;
break;
case Ndis802_11PowerModeFast_PSP:
//Set to default listen interval of 100 TUs.
listenInterval = MIN_LISTEN_INTERVAL;
powerMode = REC_POWER;
break;
default:
return NDIS_STATUS_INVALID_DATA;
}
//Set the Listen interval if Power mode is other than MAX_PERF_POWER
if ( powerMode != MAX_PERF_POWER ) {
Status = wmi_listeninterval_cmd((struct wmi_t *)m_pWMI, listenInterval, 0);
if (Status != A_OK)
return NDIS_STATUS_FAILURE;
}
Status = wmi_powermode_cmd((struct wmi_t *)m_pWMI, powerMode);
if ( Status != A_OK ) {
//if the Listen interval was updated, roll back to original.
if ( powerMode != MAX_PERF_POWER )
wmi_listeninterval_cmd((struct wmi_t *)m_pWMI, m_ListenInterval, 0);
return NDIS_STATUS_FAILURE;
}
//Update the global power mode & listen Interval vars with the set value;
m_80211_PowerMode = PowerMode;
if ( powerMode != MAX_PERF_POWER )
m_ListenInterval = listenInterval;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11BSSIDListScan()
//
// Perform a network scan of BSSIDs and SSIDs.
//
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
A_STATUS wmiStatus;
if (!m_WMIReady)
{
Status = NDIS_STATUS_ADAPTER_NOT_READY;
goto done;
}
if (m_ConnectInProgress || m_Connected)
{
goto done;
}
if (m_WMIBssFilter != ALL_BSS_FILTER) {
wmiStatus = wmi_bssfilter_cmd((struct wmi_t *)m_pWMI, ALL_BSS_FILTER);
if (wmiStatus == A_OK) {
m_WMIBssFilter = ALL_BSS_FILTER;
} else {
Status = NDIS_STATUS_FAILURE;
goto done;
}
}
wmiStatus = wmi_startscan_cmd((struct wmi_t *)m_pWMI, WMI_LONG_SCAN);
if (A_OK != wmiStatus)
Status = NDIS_STATUS_FAILURE;
done:
return Status;
}
NDIS_STATUS
CAR6KMini::Set802_11PrivacyFilter(
IN NDIS_802_11_PRIVACY_FILTER Filter)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11ReloadDefaults(
IN NDIS_802_11_RELOAD_DEFAULTS Filter)
{
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::SetCAr6k802_11AuthAlg(
IN ULONG AuthAlg)
{
m_AuthAlg = AuthAlg;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::SetResumeWlanState(ULONG state)
{
m_ResumeWlanState = state;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11AuthenticationMode(
IN NDIS_802_11_AUTHENTICATION_MODE Mode)
{
if ( m_AuthenticationMode == Ndis802_11AuthModeAutoSwitch ) {
return NDIS_STATUS_NOT_SUPPORTED;
}
if ((Mode == Ndis802_11AuthModeOpen) || (Mode == Ndis802_11AuthModeShared) ||
(Mode == Ndis802_11AuthModeWPA) || (Mode == Ndis802_11AuthModeWPAPSK) ||
(Mode == Ndis802_11AuthModeWPA2PSK) || (Mode == Ndis802_11AuthModeWPA2)) {
m_AuthenticationMode = Mode;
return NDIS_STATUS_SUCCESS;
} else {
return NDIS_STATUS_INVALID_DATA;
}
}
NDIS_STATUS
CAR6KMini::Set802_11EncryptionStatus(
IN NDIS_802_11_ENCRYPTION_STATUS EncryptionStatus)
{
m_EncryptionStatus = EncryptionStatus;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11AddWEP(
IN NDIS_802_11_WEP *pWEP)
{
BYTE KeyIndex;
A_UINT8 KeyUsage = 0;
A_STATUS wmiStatus;
NDIS_DEBUG_PRINTF(ATH_LOG_INF, "AR6K: AddWEP from Supplicant\n");
if (pWEP->KeyIndex & 0x80000000) {
KeyUsage |= TX_USAGE;
}
if (!(pWEP->KeyIndex & 0x40000000)) {
KeyUsage |= GROUP_USAGE;
}
KeyIndex = (BYTE)(pWEP->KeyIndex & 0xff);
if (KeyUsage & TX_USAGE && !(KeyUsage & GROUP_USAGE)) {
//pairwise key and index is not 0
if (KeyIndex != 0) {
return NDIS_STATUS_INVALID_DATA;
}
}
if (KeyIndex < WMI_MIN_KEY_INDEX ||
KeyIndex > WMI_MAX_KEY_INDEX) {
return NDIS_STATUS_INVALID_DATA;
}
if (pWEP->KeyLength <= sizeof(m_Key[KeyIndex])) {
m_cbKey[KeyIndex] = pWEP->KeyLength;
memcpy(m_Key[KeyIndex], pWEP->KeyMaterial, pWEP->KeyLength);
m_KeyIndex[KeyIndex] = KeyIndex;
m_KeyRSC[KeyIndex] = 0;
m_KeyUsage[KeyIndex] = KeyUsage;
}
// Add the key to the target
if (m_EncryptionStatus == Ndis802_11WEPEnabled) {
wmiStatus = wmi_addKey_cmd((wmi_t *)m_pWMI,
(A_UINT8)KeyIndex,
WEP_CRYPT,
m_KeyUsage[KeyIndex],
(A_UINT8)m_cbKey[KeyIndex],
(A_UINT8*)&m_KeyRSC[KeyIndex],
m_Key[KeyIndex]);
if (wmiStatus != A_OK) {
NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - wmi_addKey_cmd failed = %u\n", wmiStatus);
return NDIS_STATUS_FAILURE;
}
}
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11RemoveWEP(
IN NDIS_802_11_KEY_INDEX KeyIndex)
{
A_STATUS wmiStatus;
NDIS_DEBUG_PRINTF(ATH_LOG_INF, "AR6K: RemoveWEP from Supplicant\n");
if (KeyIndex >= 4) {
return NDIS_STATUS_FAILURE;
}
memset(m_Key[KeyIndex], 0, sizeof(m_Key[KeyIndex]));
m_cbKey[KeyIndex] = 0;
wmiStatus = wmi_deleteKey_cmd((wmi_t *)m_pWMI, (BYTE)KeyIndex);
if (wmiStatus != A_OK) {
NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - wmi_deleteKey_cmd failed = %u\n", wmiStatus);
return NDIS_STATUS_FAILURE;
}
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Set802_11AddKey(
IN NDIS_802_11_KEY *pKey)
{
BYTE KeyIndex, tempKeyVal, tempKeyMaterial[32];
A_UINT8 KeyUsage = 0;
A_STATUS wmiStatus;
int i = 0;
CRYPTO_TYPE keyType = NONE_CRYPT;
if (pKey->KeyIndex & 0x80000000) {
KeyUsage |= TX_USAGE;
}
if (!(pKey->KeyIndex & 0x40000000)) {
KeyUsage |= GROUP_USAGE;
}
KeyIndex = (BYTE)(pKey->KeyIndex & 0xff);
if (KeyUsage & TX_USAGE && !(KeyUsage & GROUP_USAGE)) {
//pairwise key and index is not 0
if (KeyIndex != 0) {
return NDIS_STATUS_INVALID_DATA;
}
}
if (KeyIndex < WMI_MIN_KEY_INDEX ||
KeyIndex > WMI_MAX_KEY_INDEX) {
return NDIS_STATUS_INVALID_DATA;
}
if( (KeyUsage & GROUP_USAGE) == GROUP_USAGE )
{
keyType = m_GrpwiseCryptoType;
} else {
keyType = m_PairwiseCryptoType;
}
/* Set the keyType to WEP_CRYPT for the case of this OID being called because of a profile
* switch to 802.1x/SharedAuth/AutoSwitch from a connected profile. This is because the encryption status
* OID is got only after the AddKey OID.
*/
if ((m_AuthenticationMode == Ndis802_11AuthModeShared ||
m_AuthenticationMode == Ndis802_11AuthModeAutoSwitch || m_AuthenticationMode == Ndis802_11AuthModeOpen)) {
keyType = WEP_CRYPT;
}
// TODO - to check BSSID in pKey and the AP address for pairwis
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -