📄 request.cpp
字号:
break;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_MAXIMUM_TOTAL_SIZE)\n"));
/*
The maximum total packet length, in bytes,
the device supports, including the header.
This value is medium-dependent. The returned
length specifies the largest packet a protocol
driver can pass to NdisSend or NdisSendPackets.
For a binding emulating another media type,
the device driver must define the maximum total
packet length in such a way that it will not
transform a protocol-supplied net packet of
this size to a net packet too large for the true network medium.
*/
*(UINT *)InformationBuffer =MAX_PACKET_SIZE+2;
break;
case OID_GEN_VENDOR_ID:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_VENDOR_ID)\n"));
// we get this from our config descriptor
*(UINT *)InformationBuffer = Adapter->IdVendor;
break;
case OID_GEN_VENDOR_DESCRIPTION:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_VENDOR_DESCRIPTION)\n"));
// BUGBUG? should we ask for class-specific string?
NdisMoveMemory(
InformationBuffer,
(PVOID)vendorDesc,
sizeof(vendorDesc)
);
break;
case OID_GEN_LINK_SPEED:
DEBUGONCE(DBG_FUNC, ("MiniportQueryInformation(OID_GEN_LINK_SPEED)\n"));
//
// Return MAXIMUM POSSIBLE speed for this device in units
// of 100 bits/sec.
//
*(UINT *)InformationBuffer = 1000000;
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_LINK_SPEED) %d\n",*(UINT *)InformationBuffer));
break;
case OID_GEN_CURRENT_PACKET_FILTER:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_CURRENT_PACKET_FILTER)\n"));
*(UINT *)InformationBuffer = NDIS_PACKET_TYPE_PROMISCUOUS;
break;
case OID_GEN_DRIVER_VERSION:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_DRIVER_VERSION)\n"));
*(USHORT *)InformationBuffer = ((NDIS_MAJOR_VERSION << 8) |
NDIS_MINOR_VERSION);
break;
case OID_GEN_PROTOCOL_OPTIONS:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_PROTOCOL_OPTIONS)\n"));
DEBUGMSG(DBG_ERR, ("This is a set-only OID\n"));
*BytesWritten = 0;
status = NDIS_STATUS_NOT_SUPPORTED;
break;
case OID_GEN_MAC_OPTIONS:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_MAC_OPTIONS)\n"));
*(UINT *)InformationBuffer =
NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
NDIS_MAC_OPTION_TRANSFERS_NOT_PEND;
break;
case OID_GEN_MEDIA_CONNECT_STATUS:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_MEDIA_CONNECT_STATUS)\n"));
//
// Since we are not physically connected to a LAN, we
// cannot determine whether or not we are connected;
// so always indicate that we are.
//
*(UINT *)InformationBuffer = NdisMediaStateConnected;
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_MAXIMUM_SEND_PACKETS)\n"));
//The maximum number of send packets the
//MiniportSendPackets function can accept.
//If a larger packet array is given to MiniportSendPackets,
//it will return some packets in the array to NDIS for resubmission later.
//If the underlying driver has only a MiniportSend function, it should return one
//for this query. This is our case
*(UINT *)InformationBuffer = 1;
break;
case OID_GEN_VENDOR_DRIVER_VERSION:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_VENDOR_DRIVER_VERSION)\n"));
*(UINT *)InformationBuffer =
((NDIS_MAJOR_VERSION << 16) |
NDIS_MINOR_VERSION);
break;
//
// Required statistical OIDs.
//
case OID_GEN_XMIT_OK:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_XMIT_OK)\n"));
*(UINT *)InformationBuffer =
(UINT)Adapter->packetsSent;
break;
case OID_GEN_RCV_OK:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_RCV_OK)\n"));
*(UINT *)InformationBuffer =
(UINT)Adapter->packetsReceived;
break;
case OID_GEN_XMIT_ERROR:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_XMIT_ERROR)\n"));
*(UINT *)InformationBuffer =
(UINT)Adapter->packetsSentDropped;
break;
case OID_GEN_RCV_ERROR:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_RCV_ERROR)\n"));
*(UINT *)InformationBuffer =
(UINT)Adapter->packetsReceivedDropped;
break;
case OID_GEN_RCV_NO_BUFFER:
DEBUGONCE(DBG_FUNC, (" MiniportQueryInformation(OID_GEN_RCV_NO_BUFFER)\n"));
*(UINT *)InformationBuffer =
(UINT)Adapter->packetsReceivedOverflow;
break;
// PNP OIDs
case OID_PNP_CAPABILITIES:
DEBUGONCE(DBG_WARN, ("USB: OID_PNP_CAPABILITIES OID %x BufLen:%d\n", Oid, InformationBufferLength));
NdisZeroMemory( // say all pnp caps are unspecified
InformationBuffer,
sizeof(NDIS_PNP_CAPABILITIES)
);
break;
default:
DEBUGMSG(DBG_FUNC, (" MiniportQueryInformation(%d=0x%x), invalid OID\n", Oid, Oid));
status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
}
else
{
*BytesNeeded = infoSizeNeeded - InformationBufferLength;
*BytesWritten = 0;
status = NDIS_STATUS_INVALID_LENGTH;
}
release:
if ( NDIS_STATUS_PENDING != status ) {
// zero-out the time so check for hang handler knows nothing pending
Adapter->LastQueryTime.QuadPart = 0;
Adapter->fQuerypending = FALSE;
}
DEBUGMSG(DBG_FUNC, ("-MiniportQueryInformation\n"));
return status;
}
/*****************************************************************************
// MiniPortSetInformation
//
// 更改(设置)关于微端口驱动程序或其NIC的信息
//
*****************************************************************************/
NDIS_STATUS
MiniportSetInformation(
IN NDIS_HANDLE MiniportAdapterContext, // 指向适配器环境区的句柄
IN NDIS_OID Oid, // 系统定义的OID'
IN PVOID InformationBuffer, // 指向存放OID'信息的缓冲区的指针
IN ULONG InformationBufferLength, // 缓冲区的大小
OUT PULONG BytesRead, // 指向缓冲区内信息变量的指针
OUT PULONG BytesNeeded // 缓冲区的大小小于该OID'信息时,所需的额外缓冲区的大小
)
{
NDIS_STATUS status;
PUSB_DEVICE Adapter;
NTSTATUS ntStatus;
int i;
DEBUGMSG(DBG_FUNC, ("+MiniportSetInformation\n"));
status = NDIS_STATUS_SUCCESS;
Adapter = CONTEXT_TO_DEV(MiniportAdapterContext);
ASSERT( NULL != Adapter );
ASSERT( NULL != BytesRead );
ASSERT( NULL != BytesNeeded );
NdisGetCurrentSystemTime( &Adapter->LastSetTime ); //used by check for hang handler
Adapter->fSetpending = TRUE;
if ( NULL == InformationBuffer ) { // Should be impossible but it happened on an MP system!
DEBUGMSG(DBG_ERR, (" MiniportSetInformation() NULL info buffer passed!,InformationBufferLength = dec %d\n",InformationBufferLength));
status = NDIS_STATUS_NOT_ACCEPTED;
*BytesNeeded =0;
*BytesRead = 0;
goto release;
}
if (InformationBufferLength >= sizeof(UINT))
{
//
// Set default results.
//
UINT info = 0;
if ( NULL != InformationBuffer ) {
info = *(UINT *)InformationBuffer;
}
*BytesRead = sizeof(UINT);
*BytesNeeded = 0;
switch (Oid)
{
//
// 系统通用的OIDs.
//
case OID_GEN_CURRENT_PACKET_FILTER:
DEBUGONCE(DBG_FUNC, (" MiniportSetInformation(OID_GEN_CURRENT_PACKET_FILTER, %xh)\n", info));
//
// We ignore the packet filter itself.
//
// Note: The protocol may use a NULL filter, in which case
// we will not get this OID; so don't wait on
// OID_GEN_CURRENT_PACKET_FILTER to start receiving
// frames.
//
Adapter->fGotFilterIndication = TRUE;
break;
case OID_GEN_CURRENT_LOOKAHEAD:
DEBUGONCE(DBG_FUNC, (" MiniportSetInformation(OID_GEN_CURRENT_LOOKAHEAD, %xh)\n", info));
//
// We always indicate entire receive frames all at once,
// so just ignore this.
//
break;
case OID_GEN_PROTOCOL_OPTIONS:
DEBUGONCE(DBG_FUNC, (" MiniportSetInformation(OID_GEN_PROTOCOL_OPTIONS, %xh)\n", info));
//
// Ignore.
//
break;
default:
DEBUGMSG(DBG_ERR, (" MiniportSetInformation(OID=%d=0x%x, value=%xh) - invalid OID\n", Oid, Oid, info));
*BytesRead = 0;
*BytesNeeded = 0;
status = NDIS_STATUS_INVALID_OID;
break;
}
}
else
{
//
// The given data buffer is not large enough for the information
// to set.
//
*BytesRead = 0;
*BytesNeeded = sizeof(UINT);
status = NDIS_STATUS_INVALID_LENGTH;
}
release:
if ( NDIS_STATUS_PENDING != status ) {
// zero-out the time so check for hang handler knows nothing pending
Adapter->LastSetTime.QuadPart = 0;
Adapter->fSetpending = FALSE;
}
DEBUGMSG(DBG_FUNC, ("-MiniportSetInformation\n"));
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -