?? cmini.cpp
字號:
for (j=0;j<(TotalNumberOfSupportedOids-i-1);j++) {
if (pOids[j] > pOids[j+1]) {
temp = pOids[j];
pOids[j] = pOids[j+1];
pOids[j+1] = temp;
}
}
}
*pcbWritten = TotalNumberOfSupportedOids * sizeof(NDIS_OID);
} else {
Status = NDIS_STATUS_BUFFER_TOO_SHORT;
}
}
break;
case OID_GEN_HARDWARE_STATUS:
// The current hardware status of the underlying NIC
HardwareStatus = GetGenHardwareStatus();
MoveSource = (PVOID)(&HardwareStatus);
MoveBytes = sizeof(HardwareStatus);
break;
case OID_GEN_MEDIA_SUPPORTED:
// The media types that the NIC can support but not necessarily
// the media types that the NIC currently uses.
Medium = GetGenMediaSupported();
MoveSource = (PVOID) (&Medium);
MoveBytes = sizeof(Medium);
break;
case OID_GEN_MEDIA_IN_USE:
// A complete list of the media types that the NIC currently uses.
Medium = GetGenMediaInUse();
MoveSource = (PVOID) (&Medium);
MoveBytes = sizeof(Medium);
break;
case OID_GEN_PHYSICAL_MEDIUM:
// A complete list of the media types that the NIC currently uses.
PhysicalMedium = GetGenPhysicalMedium();
MoveSource = (PVOID) (&PhysicalMedium);
MoveBytes = sizeof(PhysicalMedium);
break;
case OID_GEN_MEDIA_CONNECT_STATUS:
// Whether the media is currently connected and able to Tx/Rx packets.
// This is set by the plugin via VEMSetMediaState.
GenericULong = GetGenMediaConnectStatus();
break;
case OID_GEN_MAXIMUM_LOOKAHEAD:
// The maximum number of bytes that the NIC can provide as lookahead data.
// This specification does not include a header.
GenericULong = GetGenMaximumLookahead();
break;
case OID_GEN_CURRENT_LOOKAHEAD:
// The number of bytes of received packet data that will be indicated to the protocol driver.
GenericULong = GetGenCurrentLookahead();
break;
case OID_GEN_MAXIMUM_FRAME_SIZE:
// The maximum network packet size, in bytes, that the NIC supports.
// This specification does not include a header.
GenericULong = GetGenMaximumFrameSize();
break;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
// The maximum total packet length, in bytes, the NIC supports.
// This specification includes the header.
GenericULong = GetGenMaximumTotalSize();
break;
case OID_GEN_LINK_SPEED:
// Link speed in units of 100 bps.
GenericULong = GetGenLinkSpeed();
break;
case OID_GEN_TRANSMIT_BUFFER_SPACE:
// The amount of memory, in bytes, on the NIC that is available for buffering Tx/Rx data.
GetGenTransmitBufferSpace();
break;
case OID_GEN_RECEIVE_BUFFER_SPACE:
// The amount of memory, in bytes, on the NIC that is available for buffering Tx/Rx data.
GenericULong = GetGenReceiveBufferSpace();
break;
case OID_GEN_TRANSMIT_BLOCK_SIZE:
// Minimum amount of storage, in bytes, that a single packet
// occupies in the Tx/Rx buffer space of the NIC.
GenericULong = GetGenTransmitBlockSize();
break;
case OID_GEN_RECEIVE_BLOCK_SIZE:
// Minimum amount of storage, in bytes, that a single packet
// occupies in the Tx/Rx buffer space of the NIC.
GenericULong = GetGenReceiveBlockSize();
break;
case OID_GEN_VENDOR_ID:
// The OID_GEN_VENDOR_ID OID specifies a three-byte IEEE-registered vendor code,
// followed by a single byte that the vendor assigns to identify a particular NIC.
// Vendors without an IEEE registered code should use 0xFFFFFF for the vendor code.
GenericULong = GetGenVendorId();
break;
case OID_GEN_VENDOR_DESCRIPTION:
// The OID_GEN_VENDOR_DESCRIPTION OID points to a zero-terminated string describing the NIC.
MoveSource = (PVOID)GetGenVendorDescription();
MoveBytes = strlen((char *)MoveSource) + 1;
break;
case OID_GEN_DRIVER_VERSION:
// The NDIS version in use by the NIC driver.
// The high byte is the major version number; the low byte is the minor version number.
GenericUShort = GetGenDriverVersion();
MoveSource = (PVOID)(&GenericUShort);
MoveBytes = sizeof(GenericUShort);
break;
case OID_GEN_CURRENT_PACKET_FILTER:
// The types of net packets for which a protocol receives indications from a NIC driver.
// Queries for this should be intercepted and handled by the NDIS layer, they shouldn't
// make it down to the miniport...
GenericULong = GetGenCurrentPacketFilter();
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
// For serialized miniports:
// The maximum number of send packet descriptors that a miniport driver's
// MiniportSendPackets function can accept in the array at its PacketArray parameter.
//
// For deserialized miniports:
// NDIS ignores any value returned by a deserialized driver in response to a
// query of OID_GEN_MAXIMUM_SEND_PACKETS.
GenericULong = 1;
break;
//
// Statistics OIDs...
//
case OID_GEN_XMIT_OK:
GenericULong = GetGenXmitOk();
break;
case OID_GEN_RCV_OK:
GenericULong = GetGenRcvOk();
break;
case OID_GEN_XMIT_ERROR:
GenericULong = GetGenXmitError();
break;
case OID_GEN_RCV_ERROR:
GenericULong = GetGenRcvError();
break;
case OID_GEN_RCV_NO_BUFFER:
GenericULong = GetGenRcvNoBuffer();
break;
case OID_GEN_MEDIA_CAPABILITIES:
GenericULong = GetGenMediaCapabilities();
break;
case OID_PNP_CAPABILITIES:
MoveBytes = sizeof(NDIS_PNP_CAPABILITIES);
MoveSource = &PnpCaps;
GetPnpCapabilities(&PnpCaps);
break;
case OID_PNP_QUERY_POWER:
Status = QueryPnpPower((NDIS_DEVICE_POWER_STATE *)Buffer);
MoveBytes = 0;
MoveSource = NULL;
break;
default:
// Should never get here, CheckOidRequest should have caught unsupported Oids
ASSERT(FALSE);
Status = NDIS_STATUS_INVALID_OID;
break;
}
if (Status == NDIS_STATUS_SUCCESS)
{
if (MoveBytes > cbBuffer)
{
// Not enough room in Buffer.
*pcbNeeded = MoveBytes;
Status = NDIS_STATUS_INVALID_LENGTH;
}
else
{
// Store result.
if (MoveBytes)
{
memcpy(Buffer, MoveSource, MoveBytes);
*pcbWritten = MoveBytes;
}
}
}
done:
return Status;
}
NDIS_STATUS
CMiniport::SetInformation(
IN NDIS_OID Oid,
OUT PVOID Buffer,
IN ULONG cbBuffer,
OUT PULONG pcbRead,
OUT PULONG pcbNeeded)
{
NDIS_STATUS Status;
// Check that OID is supported and buffer size is reasonable.
Status = CheckOidRequest(&g_GenSupportedSetOids[0], Oid, cbBuffer, pcbNeeded);
if (NDIS_STATUS_SUCCESS != Status)
goto done;
*pcbRead = *pcbNeeded;
switch (Oid)
{
case OID_GEN_CURRENT_PACKET_FILTER:
// A bitmask specifying the type(s) of received packets that should
// be indicated to protocol drivers, e.g.:
// NDIS_PACKET_TYPE_DIRECTED
// NDIS_PACKET_TYPE_BROADCAST
// NDIS_PACKET_TYPE_MULTICAST
// NDIS_PACKET_TYPE_ALL_LOCAL
Status = SetGenCurrentPacketFilter(*(PULONG)Buffer);
break;
case OID_GEN_CURRENT_LOOKAHEAD:
// The number of bytes of received packet data, excluding the header,
// that will be indicated to protocol drivers.
Status = SetGenCurrentLookahead(*(PULONG)Buffer);
break;
case OID_GEN_PROTOCOL_OPTIONS:
// A bitmask that defines optional properties of the protocol driver, e.g.:
// NDIS_PROT_OPTION_ESTIMATED_LENGTH
// NDIS_PROT_OPTION_NO_LOOPBACK
Status = SetGenProtocolOptions(*(PULONG)Buffer);
break;
case OID_PNP_SET_POWER:
Status = SetPnpPower((NDIS_DEVICE_POWER_STATE *)Buffer);
break;
default:
// Should never get here, CheckOidRequest should have caught unsupported Oids
ASSERT(FALSE);
Status = NDIS_STATUS_INVALID_OID;
break;
}
done:
return Status;
}
ULONG
CMiniport::GetGenVendorId()
//
// The OID_GEN_VENDOR_ID OID specifies a three-byte IEEE-registered vendor code,
// followed by a single byte that the vendor assigns to identify a particular NIC.
// Vendors without an IEEE registered code should use 0xFFFFFF for the vendor code.
//
{
// Default to unknown
return 0xFFFFFFFF;
}
const char *
CMiniport::GetGenVendorDescription()
// The OID_GEN_VENDOR_DESCRIPTION OID returns a zero-terminated string describing the NIC.
{
return "Vendor Description Not Specified";
}
ULONG
CMiniport::GetGenMediaCapabilities()
// The OID_GEN_MEDIA_CAPABILITIES OID indicates whether transmits and receives are supported.
{
// Default implementation indicates that this miniport can both send and receive.
return NDIS_MEDIA_CAP_TRANSMIT | NDIS_MEDIA_CAP_RECEIVE;
}
ULONG
CMiniport::GetGenCurrentPacketFilter()
{
return m_CurrentPacketFilter;
}
NDIS_STATUS
CMiniport::SetGenCurrentPacketFilter(
ULONG PacketFilter)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
// Check to see that no unsupported types have been requested
if (PacketFilter & ~GetSupportedPacketTypes())
{
Status = NDIS_STATUS_INVALID_DATA;
}
else
{
m_CurrentPacketFilter = PacketFilter;
}
return Status;
}
NDIS_STATUS
CMiniport::SetGenCurrentLookahead(
ULONG Lookahead)
{
m_CurrentLookahead = Lookahead;
return NDIS_STATUS_SUCCESS;
}
NDIS_STATUS
CMiniport::SetGenProtocolOptions(
ULONG ProtocolOptions)
{
m_ProtocolOptions = ProtocolOptions;
return NDIS_STATUS_SUCCESS;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -