📄 request.c
字号:
case OID_GEN_VENDOR_DRIVER_VERSION:
//
// Specify the vendor-assigned version number of the NIC driver.
// The low-order half of the return value specifies the minor
// version; the high-order half specifies the major version.
//
ulInfo = NIC_VENDOR_DRIVER_VERSION;
break;
case OID_GEN_DRIVER_VERSION:
//
// Specify 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.
//
usInfo = (USHORT) (MP_NDIS_MAJOR_VERSION<<8) + MP_NDIS_MINOR_VERSION;
pInfo = (PVOID) &usInfo;
ulInfoLen = sizeof(USHORT);
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
//
// If a miniport driver registers a MiniportSendPackets function,
// MiniportQueryInformation will be called with the
// OID_GEN_MAXIMUM_SEND_PACKETS request. The miniport driver must
// respond with the maximum number of packets it is prepared to
// handle on a single send request. The miniport driver should
// pick a maximum that minimizes the number of packets that it
// has to queue internally because it has no resources
// (its device is full). A miniport driver for a bus-master DMA
// NIC should attempt to pick a value that keeps its NIC filled
// under anticipated loads.
//
ulInfo = NIC_MAX_SEND_PKTS;
break;
case OID_GEN_MEDIA_CONNECT_STATUS:
//
// Return the connection status of the NIC on the network as one
// of the following system-defined values: NdisMediaStateConnected
// or NdisMediaStateDisconnected.
//
ulInfo = NICGetMediaConnectStatus(Adapter);
break;
case OID_GEN_CURRENT_PACKET_FILTER:
//
// Specifiy the types of net packets such as directed, broadcast
// multicast, for which a protocol receives indications from a
// NIC driver. After NIC is initialized, a protocol driver
// can send a set OID_GEN_CURRENT_PACKET_FILTER to a non-zero value,
// thereby enabling the miniport driver to indicate receive packets
// to that protocol.
//
ulInfo = Adapter->PacketFilter;
break;
case OID_PNP_CAPABILITIES:
//
// Return the wake-up capabilities of its NIC. If you return
// NDIS_STATUS_NOT_SUPPORTED, NDIS considers the miniport driver
// to be not Power management aware and doesn't send any power
// or wake-up related queries such as
// OID_PNP_SET_POWER, OID_PNP_QUERY_POWER,
// OID_PNP_ADD_WAKE_UP_PATTERN, OID_PNP_REMOVE_WAKE_UP_PATTERN,
// OID_PNP_ENABLE_WAKE_UP.
//
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
//
// Following 4 OIDs are for querying Ethernet Operational
// Characteristics.
//
case OID_802_3_PERMANENT_ADDRESS:
//
// Return the MAC address of the NIC burnt in the hardware.
//
pInfo = Adapter->PermanentAddress;
ulInfoLen = ETH_LENGTH_OF_ADDRESS;
break;
case OID_802_3_CURRENT_ADDRESS:
//
// Return the MAC address the NIC is currently programmed to
// use. Note that this address could be different from the
// permananent address as the user can override using
// registry. Read NdisReadNetworkAddress doc for more info.
//
pInfo = Adapter->CurrentAddress;
ulInfoLen = ETH_LENGTH_OF_ADDRESS;
break;
case OID_802_3_MAXIMUM_LIST_SIZE:
//
// The maximum number of multicast addresses the NIC driver
// can manage. This list is global for all protocols bound
// to (or above) the NIC. Consequently, a protocol can receive
// NDIS_STATUS_MULTICAST_FULL from the NIC driver when
// attempting to set the multicast address list, even if
// the number of elements in the given list is less than
// the number originally returned for this query.
//
ulInfo = NIC_MAX_MCAST_LIST;
break;
case OID_802_3_MAC_OPTIONS:
//
// A protocol can use this OID to determine features supported
// by the underlying driver such as NDIS_802_3_MAC_OPTION_PRIORITY.
// Return zero indicating that it supports no options.
//
ulInfo = 0;
break;
//
// Following list consists of both general and Ethernet
// specific statistical OIDs.
//
case OID_GEN_XMIT_OK:
ulInfo64 = Adapter->GoodTransmits;
pInfo = &ulInfo64;
if (InformationBufferLength >= sizeof(ULONG64) ||
InformationBufferLength == 0)
{
ulInfoLen = sizeof(ULONG64);
}
else
{
ulInfoLen = sizeof(ULONG);
}
// We should always report that only 8 bytes are required to keep ndistest happy
*BytesNeeded = sizeof(ULONG64);
break;
case OID_GEN_RCV_OK:
ulInfo64 = Adapter->GoodReceives;
pInfo = &ulInfo64;
if (InformationBufferLength >= sizeof(ULONG64) ||
InformationBufferLength == 0)
{
ulInfoLen = sizeof(ULONG64);
}
else
{
ulInfoLen = sizeof(ULONG);
}
// We should always report that only 8 bytes are required to keep ndistest happy
*BytesNeeded = sizeof(ULONG64);
break;
case OID_GEN_XMIT_ERROR:
ulInfo = Adapter->TxAbortExcessCollisions +
Adapter->TxDmaUnderrun +
Adapter->TxLostCRS +
Adapter->TxLateCollisions+
Adapter->TransmitFailuresOther;
break;
case OID_GEN_RCV_ERROR:
ulInfo = Adapter->RcvCrcErrors +
Adapter->RcvAlignmentErrors +
Adapter->RcvResourceErrors +
Adapter->RcvDmaOverrunErrors +
Adapter->RcvRuntErrors;
break;
case OID_GEN_RCV_NO_BUFFER:
ulInfo = Adapter->RcvResourceErrors;
break;
case OID_GEN_RCV_CRC_ERROR:
ulInfo = Adapter->RcvCrcErrors;
break;
case OID_GEN_TRANSMIT_QUEUE_LENGTH:
ulInfo = Adapter->RegNumTcb;
break;
case OID_802_3_RCV_ERROR_ALIGNMENT:
ulInfo = Adapter->RcvAlignmentErrors;
break;
case OID_802_3_XMIT_ONE_COLLISION:
ulInfo = Adapter->OneRetry;
break;
case OID_802_3_XMIT_MORE_COLLISIONS:
ulInfo = Adapter->MoreThanOneRetry;
break;
case OID_802_3_XMIT_DEFERRED:
ulInfo = Adapter->TxOKButDeferred;
break;
case OID_802_3_XMIT_MAX_COLLISIONS:
ulInfo = Adapter->TxAbortExcessCollisions;
break;
case OID_802_3_RCV_OVERRUN:
ulInfo = Adapter->RcvDmaOverrunErrors;
break;
case OID_802_3_XMIT_UNDERRUN:
ulInfo = Adapter->TxDmaUnderrun;
break;
case OID_802_3_XMIT_HEARTBEAT_FAILURE:
ulInfo = Adapter->TxLostCRS;
break;
case OID_802_3_XMIT_TIMES_CRS_LOST:
ulInfo = Adapter->TxLostCRS;
break;
case OID_802_3_XMIT_LATE_COLLISIONS:
ulInfo = Adapter->TxLateCollisions;
break;
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
if(Status == NDIS_STATUS_SUCCESS)
{
if(ulInfoLen <= InformationBufferLength)
{
// Copy result into InformationBuffer
*BytesWritten = ulInfoLen;
if(ulInfoLen)
{
NdisMoveMemory(InformationBuffer, pInfo, ulInfoLen);
}
}
else
{
// too short
*BytesNeeded = ulInfoLen;
Status = NDIS_STATUS_BUFFER_TOO_SHORT;
}
}
DEBUGP(MP_LOUD, ("<--- MPQueryInformation Status = 0x%08x\n", Status));
return(Status);
}
NDIS_STATUS MPSetInformation(
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesRead,
OUT PULONG BytesNeeded)
/*++
Routine Description:
This is the handler for an OID set operation.
Arguments:
MiniportAdapterContext Pointer to the adapter structure
Oid Oid for this query
InformationBuffer Buffer for information
InformationBufferLength Size of this buffer
BytesRead Specifies how much info is read
BytesNeeded In case the buffer is smaller than what
we need, tell them how much is needed
Return Value:
Return code from the NdisRequest below.
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PMP_ADAPTER Adapter = (PMP_ADAPTER) MiniportAdapterContext;
DEBUGP(MP_LOUD, ("---> MPSetInformation %s\n", DbgGetOidName(Oid)));
*BytesRead = 0;
*BytesNeeded = 0;
switch(Oid)
{
case OID_802_3_MULTICAST_LIST:
//
// Set the multicast address list on the NIC for packet reception.
// The NIC driver can set a limit on the number of multicast
// addresses bound protocol drivers can enable simultaneously.
// NDIS returns NDIS_STATUS_MULTICAST_FULL if a protocol driver
// exceeds this limit or if it specifies an invalid multicast
// address.
//
Status = NICSetMulticastList(
Adapter,
InformationBuffer,
InformationBufferLength,
BytesRead,
BytesNeeded);
break;
case OID_GEN_CURRENT_PACKET_FILTER:
//
// Program the hardware to indicate the packets
// of certain filter types.
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -