?? car6koid.cpp
字號:
if (result != ERROR_SUCCESS) {
return NDIS_STATUS_FAILURE;
}
// Coming out of standby and the resume state is off, keep
// the WLAN module in off state by failing the OID.
if ((!(m_LastSysState & POWER_STATE_ON)) &&
(m_ResumeWlanState == 0) &&
(*pDevPowerState == NdisDeviceStateD0))
{
m_LastSysState = sysPwrState;
return NDIS_STATUS_FAILURE;
}
m_LastSysState = sysPwrState;
if (*pDevPowerState == NdisDeviceStateD3) {
if (!m_WMIReady) {
Status = NDIS_STATUS_ADAPTER_NOT_READY;
} else {
if (m_Connected) {
NdisMIndicateStatus(m_MiniportAdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, 0, 0);
NdisMIndicateStatusComplete(m_MiniportAdapterHandle);
m_Connected = FALSE;
}
StopEndpoints();
plat_suspend();
}
} else if (*pDevPowerState == NdisDeviceStateD0) {
plat_resume();
Init();
BMIInit();
if (StartEndpoints() != A_OK) {
Status = NDIS_STATUS_FAILURE;
}
}
if (Status == NDIS_STATUS_SUCCESS) {
m_PowerState = *pDevPowerState;
}
// Set the event and notify the apps abt the status change
SetEvent(m_PowerChangeEvent);
return Status;
}
// AR6K 802.11 OID Query Handlers
NDIS_STATUS
CAR6KMini::Get802_11AssociatedAPBSSID(
OUT NDIS_802_11_MAC_ADDRESS *BSSID)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// If the adapter is not associated, return NDIS_STATUS_ADAPTER_NOT_READY
if (!m_Connected)
Status = NDIS_STATUS_ADAPTER_NOT_READY;
else
memcpy(BSSID, m_PeerBSSID, ETHERNET_MAC_ADDRESS_LENGTH);
return Status;
}
void
CAR6KMini::Get802_11SSID(
OUT NDIS_802_11_SSID *pSSID)
{
// If the adapter is not associated, return 0 for SsidLength.
if (!m_Connected)
pSSID->SsidLength = 0;
else
*pSSID = m_SSID;
}
static NDIS_802_11_NETWORK_TYPE g_AR6KNetworkTypesSupported[] =
{
Ndis802_11DS,
Ndis802_11OFDM24,
};
void
CAR6KMini::Get802_11NetworkTypesSupported(
OUT NDIS_802_11_NETWORK_TYPE **ppTypes,
OUT PULONG pNumTypes)
{
*ppTypes = &g_AR6KNetworkTypesSupported[0];
*pNumTypes = sizeof(g_AR6KNetworkTypesSupported) / sizeof(g_AR6KNetworkTypesSupported[0]);
}
void
CAR6KMini::Get802_11NetworkTypeInUse(
OUT NDIS_802_11_NETWORK_TYPE *pType)
{
*pType = m_NetworkTypeInUse;
}
NDIS_STATUS
CAR6KMini::Get802_11TxPowerLevel(
OUT NDIS_802_11_TX_POWER_LEVEL *pLevel)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS
CAR6KMini::Get802_11RSSI(
OUT NDIS_802_11_RSSI *pRSSI)
{
//Return if WMI is not ready yet
if (!m_WMIReady)
return NDIS_STATUS_ADAPTER_NOT_READY;
//get stats from target
if (ar6000_get_target_stats() != A_OK)
return NDIS_STATUS_FAILURE;
//Post the RSSI value relative to the Standard Noise floor value.
*pRSSI = RSSI_TO_NDIS(m_RSSI);
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Get802_11RSSITrigger(
OUT NDIS_802_11_RSSI *pTrigger)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
void
CAR6KMini::Get802_11InfrastructureMode(
OUT NDIS_802_11_NETWORK_INFRASTRUCTURE *pMode)
{
*pMode = m_InfrastructureMode;
}
NDIS_STATUS
CAR6KMini::Get802_11FragmentationThreshold(
OUT NDIS_802_11_FRAGMENTATION_THRESHOLD *pThreshold)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS
CAR6KMini::Get802_11RTSThreshold(
OUT NDIS_802_11_RTS_THRESHOLD *pThreshold)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS
CAR6KMini::Get802_11NumberOfAntennas(
OUT ULONG *pNumberOfAntennas)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS
CAR6KMini::Get802_11RxAntennaSelected(
OUT NDIS_802_11_ANTENNA *pAntenna)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS
CAR6KMini::Get802_11TxAntennaSelected(
OUT NDIS_802_11_ANTENNA *pAntenna)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
void
CAR6KMini::Get802_11SupportedRates(
OUT BYTE *pRates)
//
// When queried, the OID_802_11_SUPPORTED_RATES OID requests that
// the miniport driver return the underlying NIC's data rate set,
// which includes the data rates that the NIC's radio supports.
//
// Data rate sets are encoded as eight bytes. Each byte describes
// a single rate in units of 0.5 Mbps. Rates from the IEEE 802.11
// BSSBasicRateSet that are included in the supported rates are used,
// for example, for control and broadcast frames.
//
// Each supported rate from the BSSBasicRateSet is encoded as a byte
// with the most significant bit (bit 7) set to 1. For example, a 1Mbps
// rate in the BSSBasicRateSet is encoded as 0x82.
//
// Rates that are not included in the BSSBasicRateSet are encoded with
// the most significant bit set to zero. For example, a 2Mbps rate
// that does not belong to the BSSBasicRateSet is encoded as 0x04.
//
// If the device supports less than eight rates, the driver must set
// the unused entries at the end of the array to zero.
//
// If the device supports more than eight rates, the miniport driver returns
// the highest eight rates.
//
{
memset(pRates, 0, sizeof(NDIS_802_11_RATES));
pRates[0] = 0x80 | 22; // 11 Mbps
pRates[1] = 0x80 | 108; // 54 Mbps
}
NDIS_STATUS
CAR6KMini::Get802_11DesiredRates(
OUT NDIS_802_11_RATES *pRates)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
void
CAR6KMini::Get802_11Configuration(
OUT NDIS_802_11_CONFIGURATION *pConfiguration)
{
pConfiguration->Length = sizeof(NDIS_802_11_CONFIGURATION);
// returns a value for BeaconPeriod based on the following:
// o If the device is in infrastructure mode and is associated, the driver returns the current beacon period of the associated access point.
// o If the device is in ad hoc mode, the driver returns the IBSS beacon period.
// o If the device is not associated, the driver returns 0.
if (m_Connected)
pConfiguration->BeaconPeriod = m_beaconInterval;
else
pConfiguration->BeaconPeriod = 0;
// The announcement traffic information message (ATIM) window in Kmicroseconds (1024 microseconds). The ATIM window is a short time period immediately after the transmission of each beacon in an ad hoc network. During the ATIM window, any station within the ad hoc network can indicate the need to transfer data to another station during the following data-transmission window.
// If the driver's network mode is set for infrastructure networks, the driver returns 0 for ATIMWindow.
pConfiguration->ATIMWindow = 0;
// DSConfig contains the current radio frequency in kHz.
pConfiguration->DSConfig = m_ConnectedChannel * 1000;
pConfiguration->FHConfig.Length = sizeof(NDIS_802_11_CONFIGURATION_FH);
pConfiguration->FHConfig.HopPattern = 0;
pConfiguration->FHConfig.HopSet = 0;
pConfiguration->FHConfig.DwellTime = 0;
}
NDIS_STATUS
CAR6KMini::Get802_11Statistics(
OUT NDIS_802_11_STATISTICS *pStatistics)
{
if (!m_WMIReady) {
return NDIS_STATUS_ADAPTER_NOT_READY;
}
//get stats from target
if (ar6000_get_target_stats() != A_OK)
return NDIS_STATUS_FAILURE;
*pStatistics = m_tgtStats;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CAR6KMini::Get802_11PowerMode(
OUT NDIS_802_11_POWER_MODE *pMode)
{
*pMode = m_80211_PowerMode;
return NDIS_STATUS_SUCCESS;
}
void
CAR6KMini::WMIBSSIDInfoAdd(
IN bss_t *pWmiBss)
//
// This function is called after Get802_11BSSIDList is called,
// to add this node to the BSSID list being returned.
//
{
NDIS_WLAN_BSSID_EX *pBSSID = m_pBSSIDList;
PBYTE pIE;
ULONG spaceNeeded;
NDIS_802_11_FIXED_IEs *pFixed;
NDIS_802_11_VARIABLE_IEs *pVar;
// Check to see that there is space available to add the node
spaceNeeded = offsetof(NDIS_WLAN_BSSID_EX, IEs);
spaceNeeded = spaceNeeded + sizeof(NDIS_802_11_FIXED_IEs);
#ifdef SUPPORT_WPA2
if (pWmiBss->ni_cie.ie_wpa2) {
pIE = pWmiBss->ni_cie.ie_wpa2;
spaceNeeded = spaceNeeded + pIE[1] + 2;
}
#endif
if (pWmiBss->ni_cie.ie_wpa) {
pIE = pWmiBss->ni_cie.ie_wpa;
spaceNeeded = spaceNeeded + pIE[1] + 2;
}
// spaceNeeded must be a multiple of 4 to maintain alignment.
spaceNeeded = (spaceNeeded + 3) & ~3;
if (*m_pcbBSSIDListNeeded + spaceNeeded < m_cbBSSIDList)
{
memset(pBSSID, 0, spaceNeeded);
pBSSID->Length = spaceNeeded; // must be multiple of 4
memcpy(pBSSID->MacAddress, pWmiBss->ni_macaddr, ETHERNET_MAC_ADDRESS_LENGTH);
pBSSID->Ssid.SsidLength = 0;
pIE = pWmiBss->ni_cie.ie_ssid;
if (pIE)
{
// Format of SSID IE is:
// Type (1 octet)
// Length (1 octet)
// SSID (Length octets)
//
// Validation of the IE should have occurred within WMI.
//
ASSERT(pIE[0] == IEEE80211_ELEMID_SSID);
ASSERT(pIE[1] <= 32);
if (pIE[1] <= 32)
{
pBSSID->Ssid.SsidLength = pIE[1];
memcpy(pBSSID->Ssid.Ssid, &pIE[2], pBSSID->Ssid.SsidLength);
}
}
pBSSID->Privacy = (pWmiBss->ni_cie.ie_capInfo & 0x10) ? 1 : 0;
//Post the RSSI value relative to the Standard Noise floor value.
pBSSID->Rssi = RSSI_TO_NDIS(pWmiBss->ni_rssi);
pBSSID->NetworkTypeInUse = Ndis802_11DS;
pBSSID->Configuration.Length = sizeof(pBSSID->Configuration);
pBSSID->Configuration.BeaconPeriod = pWmiBss->ni_cie.ie_beaconInt; // Units are Kmicroseconds (1024 us)
pBSSID->Configuration.ATIMWindow = 0;
pBSSID->Configuration.DSConfig = pWmiBss->ni_cie.ie_chan * 1000;
pBSSID->InfrastructureMode = ((pWmiBss->ni_cie.ie_capInfo & 0x03) == 0x01 ) ? Ndis802_11Infrastructure : Ndis802_11IBSS;
#if 0
pIE = pWmiBss->ie_rates;
if (pIE)
{
USHORT length;
ASSERT(pIE[0] == IEEE80211_ELEMID_RATES);
pBSSID->SupportedRates = ;
}
#endif
// Copy the fixed IEs
pBSSID->IELength = sizeof(NDIS_802_11_FIXED_IEs);
pFixed = (NDIS_802_11_FIXED_IEs *)pBSSID->IEs;
memcpy(pFixed->Timestamp, pWmiBss->ni_cie.ie_tstamp, sizeof(pFixed->Timestamp));
pFixed->BeaconInterval = pWmiBss->ni_cie.ie_beaconInt;
pFixed->Capabilities = pWmiBss->ni_cie.ie_capInfo;
// Copy selected variable IEs
pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pFixed + sizeof(NDIS_802_11_FIXED_IEs));
#ifdef SUPPORT_WPA2
// Copy the WPAv2 IE
if (pWmiBss->ni_cie.ie_wpa2) {
pIE = pWmiBss->ni_cie.ie_wpa2;
pBSSID->IELength += pIE[1] + 2;
memcpy(pVar, pIE, pIE[1] + 2);
pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pVar + pIE[1] + 2);
}
#endif
// Copy the WPAv1 IE
if (pWmiBss->ni_cie.ie_wpa) {
pIE = pWmiBss->ni_cie.ie_wpa;
pBSSID->IELength += pIE[1] + 2;
memcpy(pVar, pIE, pIE[1] + 2);
pVar = (NDIS_802_11_VARIABLE_IEs *)((PBYTE)pVar + pIE[1] + 2);
}
// Advance buffer pointer to next space beyond what we just added
m_pBSSIDList = (NDIS_WLAN_BSSID_EX *)((PBYTE)pBSSID + pBSSID->Length);
m_BSSIDListNumberOfItems++;
}
*m_pcbBSSIDListNeeded += spaceNeeded;
}
void
AR6KWMIIterateNodeCallback(
IN PVOID Context,
IN bss_t *pBssNode)
//
// This function is called by WMI after we call wmi_iterate_nodes
//
{
CAR6KMini *Adapter = (CAR6KMini *)Context;
Adapter->WMIBSSIDInfoAdd(pBssNode);
}
void
CAR6KMini::Get802_11BSSIDList(
OUT NDIS_802_11_BSSID_LIST_EX *pList,
IN ULONG cbBuffer,
OUT ULONG *pcbNeeded)
//
// Return a list containing all of the detected BSSIDs and their attributes
//
{
pList->NumberOfItems = 0;
//Return if WMI is not ready yet
if (!m_WMIReady)
return;
*pcbNeeded = offsetof(NDIS_802_11_BSSID_LIST_EX, Bssid);
m_pBSSIDList = &pList->Bssid[0];
m_cbBSSIDList = cbBuffer;
m_pcbBSSIDListNeeded = pcbNeeded;
m_BSSIDListNumberOfItems = 0;
Lock();
wmi_iterate_nodes((wmi_t *)m_pWMI, AR6KWMIIterateNodeCallback, this);
Unlock();
m_pBSSIDList = NULL;
m_cbBSSIDList = 0;
m_pcbBSSIDListNeeded = NULL;
pList->NumberOfItems = m_BSSIDListNumberOfItems;
}
void
CAR6KMini::Get802_11AuthenticationMode(
OUT NDIS_802_11_AUTHENTICATION_MODE *pMode)
{
*pMode = m_AuthenticationMode;
}
NDIS_STATUS
CAR6KMini::Get802_11PrivacyFilter(
OUT NDIS_802_11_PRIVACY_FILTER *pFilter)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
void
CAR6KMini::Get802_11EncryptionStatus(
OUT NDIS_802_11_ENCRYPTION_STATUS *pStatus)
{
*pStatus = m_EncryptionStatus;
switch (m_EncryptionStatus) {
case Ndis802_11WEPEnabled:
if (m_cbKey == 0) {
*pStatus = Ndis802_11WEPKeyAbsent;
}
break;
case Ndis802_11Encryption2Enabled:
if (m_cbKey == 0) {
*pStatus = Ndis802_11Encryption2KeyAbsent;
}
break;
case Ndis802_11Encryption3Enabled:
if (m_cbKey == 0) {
*pStatus = Ndis802_11Encryption3KeyAbsent;
}
break;
} //switch
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -