📄 c802_11mini.cpp
字号:
if (false == m_bRSSITriggerSet)
Status = NDIS_STATUS_ADAPTER_NOT_READY;
else
Status = Get802_11RSSITrigger((NDIS_802_11_RSSI *)Buffer);
break;
case OID_802_11_INFRASTRUCTURE_MODE:
#if 0 // Disabling this because WZC does not obey this convention that a prior set must occur
// When queried, this OID requests that the miniport driver return its current
// network mode setting. If queried without a prior setting of this OID, the
// driver must return NDIS_STATUS_ADAPTER_NOT_READY.
if (false == m_bInfrastructureModeSet)
Status = NDIS_STATUS_ADAPTER_NOT_READY;
else
#endif
Get802_11InfrastructureMode((PNDIS_802_11_NETWORK_INFRASTRUCTURE)Buffer);
break;
case OID_802_11_FRAGMENTATION_THRESHOLD:
// Return the fragmentation threshold setting.
Status = Get802_11FragmentationThreshold((NDIS_802_11_FRAGMENTATION_THRESHOLD *)Buffer);
break;
case OID_802_11_RTS_THRESHOLD:
// When queried, this OID requests that the miniport driver return the
// request to send (RTS) threshold setting.
Status = Get802_11RTSThreshold((NDIS_802_11_RTS_THRESHOLD *)Buffer);
break;
case OID_802_11_NUMBER_OF_ANTENNAS:
// When queried, the OID_802_11_NUMBER_OF_ANTENNAS OID requests that
// the miniport driver return the number of antennas on the underlying
// NIC's radio. The number of antennas is returned in a value of type ULONG.
Status = Get802_11NumberOfAntennas((ULONG *)Buffer);
break;
case OID_802_11_RX_ANTENNA_SELECTED:
// When queried, this OID requests that the miniport driver return the
// antenna number that identifies the currently selected receive antenna.
Status = Get802_11RxAntennaSelected((NDIS_802_11_ANTENNA *)Buffer);
break;
case OID_802_11_TX_ANTENNA_SELECTED:
// When queried, this OID requests that the miniport driver return the
// antenna number that identifies the currently selected transmit antenna.
Status = Get802_11TxAntennaSelected((NDIS_802_11_ANTENNA *)Buffer);
break;
case OID_802_11_SUPPORTED_RATES:
// 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.
Get802_11SupportedRates((BYTE *)Buffer);
break;
case OID_802_11_DESIRED_RATES:
// Return the NIC's set of data transmission rates
Status = Get802_11DesiredRates((NDIS_802_11_RATES *)Buffer);
break;
case OID_802_11_CONFIGURATION:
// Return the NIC's current radio configuration
Get802_11Configuration((PNDIS_802_11_CONFIGURATION)Buffer);
break;
case OID_802_11_STATISTICS:
// Return the current statistics for the IEEE 802.11 interface
Status = Get802_11Statistics((PNDIS_802_11_STATISTICS)Buffer);
break;
case OID_802_11_POWER_MODE:
// Return the current power mode of the NIC
Status = Get802_11PowerMode((PNDIS_802_11_POWER_MODE)Buffer);
break;
case OID_802_11_BSSID_LIST:
// Return a list containing all of the detected BSSIDs and their attributes.
// This list contains all the BSSIDs that the device detected during its most
// recent scan of potential BSSs. The miniport driver must respond to this OID
// as quickly as possible.
//
// If this OID is queried without a preceding OID_802_11_BSSID_LIST_SCAN
// set request, and the device is active, the miniport driver must return
// a list of BSSIDs that are valid to join based on the device's current
// configuration.
//
// If this OID is queried 6 seconds or longer after OID_802_11_BSSID_LIST_SCAN
// is set, the list of BSSIDs must also contain all of the BSSIDs found during
// the most recent network scan.
Get802_11BSSIDList((PNDIS_802_11_BSSID_LIST_EX)Buffer, cbBuffer, pcbNeeded);
break;
case OID_802_11_AUTHENTICATION_MODE:
// Return the IEEE 802.11 Authentication Mode
Get802_11AuthenticationMode((NDIS_802_11_AUTHENTICATION_MODE *)Buffer);
break;
case OID_802_11_PRIVACY_FILTER:
// Return the IEEE 802.1X privacy filter mode
Status = Get802_11PrivacyFilter((PNDIS_802_11_PRIVACY_FILTER)Buffer);
break;
case OID_802_11_ENCRYPTION_STATUS:
// Return the current encryption mode.
// In response, the miniport driver can indicate which encryption mode is
// enabled or disabled, that the transmit key is absent, or that encryption
// is not supported.
Get802_11EncryptionStatus((PNDIS_802_11_ENCRYPTION_STATUS)Buffer);
break;
case OID_802_11_ASSOCIATION_INFORMATION:
// return the IEs that were used in the last association or reassociation
// request to an access point. The driver also returns the IEs in the last
// association or reassociation response from the access point.
Status = Get802_11AssociationInformation((PNDIS_802_11_ASSOCIATION_INFORMATION)Buffer, cbBuffer, pcbNeeded);
break;
#ifdef SUPPORT_WPA2
case OID_802_11_PMKID:
Status = Get802_11PMKID((NDIS_802_11_PMKID *)Buffer, cbBuffer, pcbNeeded);
break;
case OID_802_11_CAPABILITY:
Status = Get802_11Capability((NDIS_802_11_CAPABILITY *)Buffer, cbBuffer, pcbNeeded);
break;
#endif
default:
Status = NDIS_STATUS_INVALID_OID;
break;
}
#ifdef DEBUG
char szBuffer[256];
Get80211OidTypeAndData(szBuffer, Oid, (PBYTE)Buffer);
NDIS_DEBUG_PRINTF(ATH_LOG_INF,"AR6K: Query Status=%x for %hs\n", Status, szBuffer);
#endif
if (NDIS_STATUS_SUCCESS == Status)
{
if (*pcbNeeded > cbBuffer)
Status = NDIS_STATUS_INVALID_LENGTH;
else
*pcbWritten = *pcbNeeded;
}
done:
return Status;
}
static MPOidInfo g_802_11SupportedSetOids[] =
{
{ OID_802_11_BSSID, sizeof(NDIS_802_11_MAC_ADDRESS) },
{ OID_802_11_SSID, sizeof(NDIS_802_11_SSID) },
{ OID_802_11_NETWORK_TYPE_IN_USE, sizeof(NDIS_802_11_NETWORK_TYPE) },
{ OID_802_11_TX_POWER_LEVEL, sizeof(NDIS_802_11_TX_POWER_LEVEL) },
{ OID_802_11_RSSI_TRIGGER, sizeof(NDIS_802_11_RSSI) },
{ OID_802_11_INFRASTRUCTURE_MODE, sizeof(NDIS_802_11_NETWORK_INFRASTRUCTURE) },
{ OID_802_11_FRAGMENTATION_THRESHOLD, sizeof(NDIS_802_11_FRAGMENTATION_THRESHOLD) },
{ OID_802_11_RTS_THRESHOLD, sizeof(NDIS_802_11_RTS_THRESHOLD) },
{ OID_802_11_RX_ANTENNA_SELECTED, sizeof(NDIS_802_11_ANTENNA) },
{ OID_802_11_TX_ANTENNA_SELECTED, sizeof(NDIS_802_11_ANTENNA) },
{ OID_802_11_DESIRED_RATES, sizeof(NDIS_802_11_RATES) },
{ OID_802_11_CONFIGURATION, sizeof(NDIS_802_11_CONFIGURATION) },
{ OID_802_11_DISASSOCIATE, 0 },
{ OID_802_11_POWER_MODE, sizeof(NDIS_802_11_POWER_MODE) },
{ OID_802_11_BSSID_LIST_SCAN, 0 },
{ OID_802_11_PRIVACY_FILTER, sizeof(NDIS_802_11_PRIVACY_FILTER) },
{ OID_802_11_RELOAD_DEFAULTS, sizeof(NDIS_802_11_RELOAD_DEFAULTS) },
{ OID_802_11_AUTHENTICATION_MODE, sizeof(NDIS_802_11_AUTHENTICATION_MODE) },
{ OID_802_11_ENCRYPTION_STATUS, sizeof(NDIS_802_11_ENCRYPTION_STATUS) },
{ OID_802_11_ADD_WEP, offsetof(NDIS_802_11_WEP, KeyMaterial[0]) },
{ OID_802_11_REMOVE_WEP, sizeof(NDIS_802_11_KEY_INDEX) },
{ OID_802_11_ADD_KEY, offsetof(NDIS_802_11_KEY, KeyMaterial[0]) },
{ OID_802_11_REMOVE_KEY, sizeof(NDIS_802_11_REMOVE_KEY) },
{ OID_802_11_ASSOCIATION_INFORMATION, sizeof(NDIS_802_11_ASSOCIATION_INFORMATION) },
{ OID_802_11_TEST, sizeof(NDIS_802_11_TEST) },
#ifdef SUPPORT_WPA2
{ OID_802_11_PMKID, offsetof(NDIS_802_11_PMKID, BSSIDInfo) },
// { OID_802_11_MEDIA_STREAM_MODE, sizeof(ULONG) },
#endif
{ 0, 0 }
};
NDIS_STATUS
C802_11Miniport::SetInformation(
IN NDIS_OID Oid,
OUT PVOID Buffer,
IN ULONG cbBuffer,
OUT PULONG pcbWritten,
OUT PULONG pcbNeeded)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// Check that OID is supported and buffer size is reasonable.
Status = CheckOidRequest(&g_802_11SupportedSetOids[0], Oid, cbBuffer, pcbNeeded);
if (NDIS_STATUS_INVALID_OID == Status)
{
// OID is not a supported 802_11 OID. Check to see if it is an 802_3 OID.
Status = C802_3Miniport::SetInformation(Oid, Buffer, cbBuffer, pcbWritten, pcbNeeded);
goto done;
}
if (NDIS_STATUS_SUCCESS != Status)
goto done;
switch (Oid)
{
//
// 802_11 OIDS
//
case OID_802_11_BSSID:
Status = Set802_11AssociatedAPBSSID((NDIS_802_11_MAC_ADDRESS *)Buffer);
break;
case OID_802_11_SSID:
Status = Set802_11SSID((NDIS_802_11_SSID *)Buffer);
break;
case OID_802_11_NETWORK_TYPE_IN_USE:
Status = Set802_11NetworkTypeInUse(*(NDIS_802_11_NETWORK_TYPE *)Buffer);
break;
case OID_802_11_TX_POWER_LEVEL:
Status = Set802_11TxPowerLevel(*(NDIS_802_11_TX_POWER_LEVEL *)Buffer);
break;
case OID_802_11_RSSI_TRIGGER:
Status = Set802_11RSSITrigger(*(NDIS_802_11_RSSI *)Buffer);
break;
case OID_802_11_INFRASTRUCTURE_MODE:
Status = Set802_11InfrastructureMode(*(NDIS_802_11_NETWORK_INFRASTRUCTURE *)Buffer);
break;
case OID_802_11_FRAGMENTATION_THRESHOLD:
Status = Set802_11FragmentationThreshold(*(NDIS_802_11_FRAGMENTATION_THRESHOLD *)Buffer);
break;
case OID_802_11_RTS_THRESHOLD:
Status = Set802_11RTSThreshold(*(NDIS_802_11_RTS_THRESHOLD *)Buffer);
break;
case OID_802_11_RX_ANTENNA_SELECTED:
Status = Set802_11RxAntennaSelected(*(ULONG *)Buffer);
break;
case OID_802_11_TX_ANTENNA_SELECTED:
Status = Set802_11TxAntennaSelected(*(ULONG *)Buffer);
break;
case OID_802_11_DESIRED_RATES:
Status = Set802_11DesiredRates((NDIS_802_11_RATES *)Buffer);
break;
case OID_802_11_CONFIGURATION:
Status = Set802_11Configuration((NDIS_802_11_CONFIGURATION *)Buffer);
break;
case OID_802_11_DISASSOCIATE:
Status = Set802_11Disassociate();
break;
case OID_802_11_POWER_MODE:
Status = Set802_11PowerMode(*(NDIS_802_11_POWER_MODE *)Buffer);
break;
case OID_802_11_BSSID_LIST_SCAN:
Status = Set802_11BSSIDListScan();
break;
case OID_802_11_PRIVACY_FILTER:
Status = Set802_11PrivacyFilter(*(NDIS_802_11_PRIVACY_FILTER *)Buffer);
break;
case OID_802_11_RELOAD_DEFAULTS:
Status = Set802_11ReloadDefaults(*(NDIS_802_11_RELOAD_DEFAULTS *)Buffer);
break;
case OID_802_11_AUTHENTICATION_MODE:
Status = Set802_11AuthenticationMode(*(NDIS_802_11_AUTHENTICATION_MODE *)Buffer);
break;
case OID_802_11_ENCRYPTION_STATUS:
Status = Set802_11EncryptionStatus(*(NDIS_802_11_ENCRYPTION_STATUS *)Buffer);
break;
case OID_802_11_ADD_WEP:
Status = Set802_11AddWEP((NDIS_802_11_WEP *)Buffer);
break;
case OID_802_11_REMOVE_WEP:
Status = Set802_11RemoveWEP(*(NDIS_802_11_KEY_INDEX *)Buffer);
break;
case OID_802_11_ADD_KEY:
Status = Set802_11AddKey((NDIS_802_11_KEY *)Buffer);
break;
case OID_802_11_REMOVE_KEY:
Status = Set802_11RemoveKey((NDIS_802_11_REMOVE_KEY *)Buffer);
break;
case OID_802_11_ASSOCIATION_INFORMATION:
Status = Set802_11AssociationInformation((NDIS_802_11_ASSOCIATION_INFORMATION *)Buffer, cbBuffer);
break;
#ifdef SUPPORT_WPA2
case OID_802_11_PMKID:
Status = Set802_11PMKID((NDIS_802_11_PMKID*)Buffer, cbBuffer);
break;
#endif
case OID_802_11_TEST:
Status = Set802_11Test((NDIS_802_11_TEST *)Buffer,cbBuffer);
break;
default:
ASSERT(FALSE);
Status = NDIS_STATUS_INVALID_OID;
break;
}
#ifdef DEBUG
char szBuffer[256];
Get80211OidTypeAndData(szBuffer, Oid, (PBYTE)Buffer);
NDIS_DEBUG_PRINTF(ATH_LOG_INF, "AR6K: Set Status=%x for %hs\n", Status, szBuffer);
#endif
done:
return Status;
}
PNDIS_OID
C802_11Miniport::GetSupportedOidList(
OUT PNDIS_OID pOidBuffer,
IN OUT PULONG pMaxOidsToAddToBuffer,
IN OUT PULONG pTotalNumberOfSupportedOids)
//
// Add the OIDs supported by the driver to pOidBuffer, but
// do not add more than MaxOidsToAddToBuffer.
//
// TotalNumberOfSupportedOids is set to the number of Oids
// that the driver supports.
//
// Returns a pointer to the next unused slot in pOidBuffer
// after the oids have been added.
//
{
PNDIS_OID p802_11OidListStart;
ULONG OidListCount = 0;
// First fill in base class supported OIDs
p802_11OidListStart = C802_3Miniport::GetSupportedOidList(pOidBuffer, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
// Now append 802.11 OIDs
AddOidsToList(&g_802_11SupportedQueryOids[0], p802_11OidListStart, &OidListCount, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
AddOidsToList(&g_802_11SupportedSetOids[0], p802_11OidListStart, &OidListCount, pMaxOidsToAddToBuffer, pTotalNumberOfSupportedOids);
return p802_11OidListStart + OidListCount;
}
void
C802_11Miniport::Get802_3MulticastList(
OUT PBYTE *pMulticastAddresses,
OUT PULONG pNumMulticastAddresses)
// The multicast address list on the NIC enabled for packet reception.
{
*pMulticastAddresses = &m_MulticastAddresses[0][0];
*pNumMulticastAddresses = m_numMulticastAddresses;
}
ULONG
C802_11Miniport::Get802_3MaxMulticastListSize()
// The maximum number of multicast addresses the NIC driver can manage.
{
return DEFAULT_802_11_MAX_MULTICAST_ADDRESSES;
}
NDIS_PHYSICAL_MEDIUM
C802_11Miniport::GetGenPhysicalMedium()
// The maximum number of multicast addresses the NIC driver can manage.
{
return NdisPhysicalMediumWirelessLan;
}
NDIS_STATUS
C802_11Miniport::Set802_3MulticastList(
IN PBYTE pMulticastAddreses,
IN ULONG NumMulticastAddresses)
//
// Set the multicast address list. This function just saves the settings
// for use in software filtering. If hardware filtering is supported then
// the device specific subclass method should handle hardware configuration.
//
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
if (NumMulticastAddresses > DEFAULT_802_11_MAX_MULTICAST_ADDRESSES)
{
Status = NDIS_STATUS_INVALID_LENGTH;
}
else
{
memcpy(&m_MulticastAddresses[0][0], pMulticastAddreses, NumMulticastAddresses * ETHERNET_MAC_ADDRESS_LENGTH);
m_numMulticastAddresses = NumMulticastAddresses;
}
return Status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -