📄 e100bexoids.cpp
字号:
return KNdisAdapterTraits<E100bexAdapter>::NdisVersion();
}
inline ULONG E100bexAdapter::getOID_GEN_CURRENT_LOOKAHEAD(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE - ENET_HEADER_SIZE;
}
inline ULONG E100bexAdapter::getOID_GEN_CURRENT_PACKET_FILTER(void)
{
if( m_pCard )
{
return m_pCard->GetPacketFilter();
}
else
{
ASSERT( m_pCard );
return 0;
}
}
NDIS_STATUS E100bexAdapter::getOID_GEN_VENDOR_DESCRIPTION
(char* pDesc, IN OUT PULONG ByteCount, OUT PULONG BytesNeeded)
{
static char Desc[] = "KNdis Miniport E100bex Driver";
if ((*BytesNeeded = sizeof(Desc)) > *ByteCount) {
*ByteCount = 0;
return NDIS_STATUS_BUFFER_TOO_SHORT;
}
NdisMoveMemory(pDesc, Desc, (*ByteCount = sizeof(Desc)));
return NDIS_STATUS_SUCCESS;
}
inline ULONG E100bexAdapter::getOID_GEN_VENDOR_ID(void)
{
// This OID specifies a three-byte IEEE-registered vendor code.
ETHERNET_ADDRESS addr = getOID_802_3_PERMANENT_ADDRESS();
ULONG id = addr; // get 1st 4 bytes
* (PUCHAR(&id)+3) = 0; // my "NIC" id
return id;
}
inline ULONG E100bexAdapter::getOID_GEN_VENDOR_DRIVER_VERSION()
{
return (E100BEX_VERSION_MAJOR<<8) | E100BEX_VERSION_MINOR;
}
inline ULONG E100bexAdapter::getOID_GEN_RECEIVE_BLOCK_SIZE(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE;
}
ULONG E100bexAdapter::getOID_GEN_TRANSMIT_BLOCK_SIZE(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE;
}
inline ULONG E100bexAdapter::getOID_GEN_RECEIVE_BUFFER_SPACE(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE * m_pRxArea->GetNumberDescriptors();
}
inline ULONG E100bexAdapter::getOID_GEN_TRANSMIT_BUFFER_SPACE(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE * m_RegNumTcb;
}
ULONG E100bexAdapter::getOID_GEN_LINK_SPEED(void)
{
// The driver does not always know what is current line speed, but
// reports the value that the we detected when the driver loaded.
return m_pCard ? (m_pCard->GetCurrentLineSpeed() * 10000) : 0;
}
ULONG E100bexAdapter::getOID_GEN_MAXIMUM_FRAME_SIZE(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE - ENET_HEADER_SIZE;
}
ULONG E100bexAdapter::getOID_GEN_MAXIMUM_LOOKAHEAD(void)
{
return MAXIMUM_ETHERNET_PACKET_SIZE - ENET_HEADER_SIZE;
}
NDIS_STATUS E100bexAdapter::getOID_GEN_MEDIA_SUPPORTED
(NDIS_MEDIUM* pMedium, PULONG ByteCount, OUT PULONG BytesNeeded)
{
// supporting Ethernet only
static NDIS_MEDIUM medium[] = { NdisMedium802_3 };
if ( (*BytesNeeded = sizeof(medium)) > *ByteCount) {
*ByteCount = 0;
return NDIS_STATUS_BUFFER_TOO_SHORT;
}
NdisMoveMemory(pMedium, medium, (*ByteCount = sizeof(medium)));
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS E100bexAdapter::getOID_GEN_MEDIA_IN_USE
(NDIS_MEDIUM* pMedium, PULONG ByteCount, OUT PULONG BytesNeeded)
{
if ( (*BytesNeeded = sizeof(NDIS_MEDIUM)) > *ByteCount) {
*ByteCount = 0;
return NDIS_STATUS_BUFFER_TOO_SHORT;
}
*pMedium = NdisMedium802_3;
*ByteCount = sizeof(NDIS_MEDIUM);
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS E100bexAdapter::getOID_GEN_SUPPORTED_GUIDS
(NDIS_GUID* pGUID, PULONG ByteCount, OUT PULONG BytesNeeded)
{
// registers the miniport's custom GUIDs with WMI
if ( (*BytesNeeded = sizeof(NDIS_GUID)) > *ByteCount) {
*ByteCount = 0;
return NDIS_STATUS_BUFFER_TOO_SHORT;
}
// TODO: Assign custom GUIDs
//*pGUID = ;
//*ByteCount = sizeof(NDIS_GUID);
*ByteCount = 0;
return NDIS_STATUS_SUCCESS;
}
/////////////////////////////////////////////////////////////////
// OID Set Handlers
NDIS_STATUS E100bexAdapter::setOID_802_3_MULTICAST_LIST
(ETHERNET_ADDRESS * pEA, PULONG ByteCount, OUT PULONG BytesNeeded)
{
// The data must be a multiple of the Ethernet address size.
if ( (NULL == ByteCount) || (NULL == BytesNeeded) )
{
return NDIS_STATUS_INVALID_DATA;
}
// The data must be a multiple of the Ethernet address size.
if ( (*ByteCount % ETH_LENGTH_OF_ADDRESS != 0) )
{
*BytesNeeded = ETH_LENGTH_OF_ADDRESS;
return NDIS_STATUS_BUFFER_TOO_SHORT;
}
if ( 0 != *ByteCount )
{
// Save these new MC addresses to our adapter object
NdisMoveMemory(
m_PrivateMulticastBuffer,
pEA,
*ByteCount
);
}
// Save the number of MC address in our adapter object
m_NumberOfMcAddresses = *ByteCount / ETH_LENGTH_OF_ADDRESS;
// have the hardware change its mulicast address filter
NDIS_STATUS Status = m_pCard->ChangeMCAddresses( &m_PrivateMulticastBuffer[0][0], m_NumberOfMcAddresses );
*BytesNeeded = *ByteCount;
return Status;
}
NDIS_STATUS E100bexAdapter::setOID_GEN_PROTOCOL_OPTIONS(PULONG Param)
{
return NDIS_STATUS_NOT_SUPPORTED;
}
NDIS_STATUS E100bexAdapter::setOID_GEN_CURRENT_PACKET_FILTER(PULONG Param)
{
if( Param && m_pCard )
{
return m_pCard->SetPacketFilter(*Param);
}
else
{
ASSERT( Param );
ASSERT( m_pCard );
return NDIS_STATUS_FAILURE;
}
}
NDIS_STATUS E100bexAdapter::setOID_GEN_CURRENT_LOOKAHEAD(PULONG)
{
return NDIS_STATUS_SUCCESS; // ignore for now
}
///////////////////////////////////////////////////////////////
// PnP Handlers
#if (KNDIS_PNP_AWARE && E100BEX_SUPPORT_PNP)
NDIS_STATUS E100bexAdapter::getOID_PNP_QUERY_POWER(PNDIS_DEVICE_POWER_STATE DesiredState)
{
// TODO: Check if it is safe to switch to the specified lower-power state.
// On successful return, NDIS will immediately call OID_PNP_SET_POWER
UNREFERENCED_PARAMETER(DesiredState);
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS E100bexAdapter::setOID_PNP_SET_POWER(PNDIS_DEVICE_POWER_STATE DesiredState)
{
// switch to the specified lower-power state. Can't fail.
if (m_Power == NdisDeviceStateD0 && *DesiredState != NdisDeviceStateD0)
{
DisableCard();
}
else if (m_Power != NdisDeviceStateD0 && *DesiredState == NdisDeviceStateD0)
{
m_pCard->SetPacketFilter( m_pCard->GetPacketFilter(), FALSE);
NDIS_STATUS Status = EnableCard();
ASSERT(Status == NDIS_STATUS_SUCCESS);
}
m_Power = *DesiredState;
return NDIS_STATUS_SUCCESS;
}
/*
// This NIC does not have Wake-up capabilities so Wake-up OID handlers are commented out.
NDIS_STATUS E100bexAdapter::setOID_PNP_ADD_WAKE_UP_PATTERN(PNDIS_PM_PACKET_PATTERN Pattern)
{
// TODO: Program the pattern into the NIC. NOTE that this handler can never be
// called unless we had specified the "wake-up" support in our
// KNdisPnpMode<E100bexAdapter> policies.
KNdisPmPacketPattern pattern(Pattern);
STRING mask, data;
pattern.GetMask(mask);
pattern.GetData(data);
// ...
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS E100bexAdapter::setOID_PNP_REMOVE_WAKE_UP_PATTERN(PNDIS_PM_PACKET_PATTERN Pattern)
{
// TODO: Remove the pattern from the NIC. NOTE that this handler can never be
// called unless we had specified the "wake-up" support in our
// KNdisPnpMode<E100bexAdapter> policies.
KNdisPmPacketPattern pattern(Pattern);
STRING mask, data;
pattern.GetMask(mask);
pattern.GetData(data);
// ...
return NDIS_STATUS_SUCCESS;
}
ULONG E100bexAdapter::getOID_PNP_ENABLE_WAKE_UP()
{
// TODO: Return those wake up methods (a mask) that are safe to turn on now.
// NDIS will select one of those in a following set request. Those
// should be a subset of flags retrieved from the m_Power member.
ULONG uMask = m_Power.GetCurrentWakeUpEnableMask();
return uMask;
}
NDIS_STATUS E100bexAdapter::setOID_PNP_ENABLE_WAKE_UP(PULONG uMask)
{
// TODO: Enable wake/disable methods specified in the uMask.
// Note that NDIS would never set all 3 simultaneously.
// "Magic Packet": a packet that contains 16 contiguous copies of the receiving
// NIC's Ethernet address
if (*uMask & NDIS_PNP_WAKE_UP_MAGIC_PACKET) { // enable
} else { // disable
}
// "Pattern Match": signal on receipt of a packet that contains a pattern
// specified by the protocol with setOID_PNP_ADD_WAKE_UP_PATTERN
if (*uMask & NDIS_PNP_WAKE_UP_PATTERN_MATCH) { // enable
} else { // disable
}
// "Link Change": signal in response to the connection or disconnection of
// the NIC's network cable.
if (*uMask & NDIS_PNP_WAKE_UP_LINK_CHANGE) { // enable
} else { // disable
}
return NDIS_STATUS_SUCCESS;
}
*/
#endif // KNDIS_PNP_AWARE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -