📄 request.c
字号:
// Initialize the result
*BytesWritten = 0;
*BytesNeeded = 0;
// Switch on request type
switch (Oid)
{
case OID_GEN_MAC_OPTIONS:
// NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA is set to indicate to the
// protocol that it can access the lookahead data by any means that
// it wishes. On some systems there are fast copy routines that
// may have trouble accessing shared memory. Netcard drivers that
// indicate data out of shared memory, should not have this flag
// set on these troublesome systems For the time being this driver
// will set this flag. This should be safe because the data area
// of the RFDs is contained in uncached memory.
// NOTE: Don't set NDIS_MAC_OPTION_RECEIVE_SERIALIZED if we
// are doing multipacket (ndis4) style receives.
GenericUlong = (ULONG)(NDIS_MAC_OPTION_TRANSFERS_NOT_PEND |
NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
NDIS_MAC_OPTION_NO_LOOPBACK
);
break;
case OID_GEN_SUPPORTED_LIST:
MoveSource = (PVOID) (D100GlobalSupportedOids);
MoveBytes = sizeof(D100GlobalSupportedOids);
break;
case OID_GEN_HARDWARE_STATUS:
MoveSource = (PVOID)(&HardwareStatus);
MoveBytes = sizeof(NDIS_HARDWARE_STATUS);
break;
case OID_GEN_MEDIA_SUPPORTED:
case OID_GEN_MEDIA_IN_USE:
MoveSource = (PVOID) (&Medium);
MoveBytes = sizeof(NDIS_MEDIUM);
break;
case OID_GEN_MAXIMUM_LOOKAHEAD:
case OID_GEN_CURRENT_LOOKAHEAD:
case OID_GEN_MAXIMUM_FRAME_SIZE:
GenericUlong = MAXIMUM_ETHERNET_PACKET_SIZE - ENET_HEADER_SIZE;
break;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
case OID_GEN_TRANSMIT_BLOCK_SIZE:
case OID_GEN_RECEIVE_BLOCK_SIZE:
GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE;
break;
case OID_GEN_LINK_SPEED:
// We won't always know what line speed we are actually running at, but
// report the value that the we detected when the driver loaded.
GenericUlong = (((ULONG) Adapter->AiLineSpeedCur) * 10000);
break;
case OID_GEN_TRANSMIT_BUFFER_SPACE:
GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE *
Adapter -> RegNumTcb;
break;
case OID_GEN_RECEIVE_BUFFER_SPACE:
GenericUlong = (ULONG) MAXIMUM_ETHERNET_PACKET_SIZE *
Adapter -> NumRfd;
break;
case OID_GEN_VENDOR_ID:
NdisMoveMemory(VendorId, Adapter->AiNodeAddress, 3);
VendorId[3] = 0x0;
MoveSource = (PVOID) VendorId;
MoveBytes = sizeof(VendorId);
break;
case OID_GEN_VENDOR_DESCRIPTION:
MoveSource = (PVOID) VendorDescriptor;
MoveBytes = sizeof(VendorDescriptor);
break;
case OID_GEN_DRIVER_VERSION:
GenericUShort = (USHORT) D100_DRIVER_VERSION;
MoveSource = (PVOID)(&GenericUShort);
MoveBytes = sizeof(GenericUShort);
break;
// WMI support
case OID_GEN_SUPPORTED_GUIDS:
MoveSource = (PUCHAR) &GuidList;
MoveBytes = sizeof(GuidList);
break;
/*
******************************************************************************
// Task Offload
case OID_GEN_TASK_OFFLOAD:
// here we set up the capabilities that we support
// later the protocol will come back with a set requesting
// some subset of the specific capabilities we support.
// this is all commented out because it is just a stub
//
// TaskOffload.Size = sizeof(NDIS_TASK_OFFLOAD);
// TaskOffload.Task = NDIS_TASK_TCP_IP_CHECKSUM;
// // offsetnext should be 0 if this is the last task supported.
// TaskOffload.OffsetNextTask = (ULONG) (&TaskOffload + sizeof(NDIS_TASK_OFFLOAD));
// TaskOffload.TaskBufferLength = sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
//
// //set up our TaskBuffer
// TaskBufferDescriptor.Receive.TcpChecksum = TRUE;
// TaskOffload.TaskBuffer = &TaskBufferDescriptor;
//
// MoveSource = (PVOID) &TaskOffload;
// MoveBytes = sizeof(NDIS_TASK_OFFLOAD) * NUM_TASKS_SUPPORTED;
Status = NDIS_STATUS_NOT_SUPPORTED; // stub
break;
******************************************************************************
*/
case OID_802_3_PERMANENT_ADDRESS:
ETH_COPY_NETWORK_ADDRESS(
(PCHAR) GenericArray,
Adapter->AiPermanentNodeAddress);
MoveSource = (PVOID) (GenericArray);
MoveBytes = ETH_LENGTH_OF_ADDRESS;
break;
case OID_802_3_CURRENT_ADDRESS:
ETH_COPY_NETWORK_ADDRESS(
GenericArray,
Adapter->AiNodeAddress);
MoveSource = (PVOID) (GenericArray);
MoveBytes = ETH_LENGTH_OF_ADDRESS;
break;
case OID_802_3_MAXIMUM_LIST_SIZE:
GenericUlong = (ULONG) MAX_MULTICAST_ADDRESSES;
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
GenericUlong = (ULONG) MAX_ARRAY_SEND_PACKETS;
break;
case OID_GEN_MEDIA_CONNECT_STATUS:
if (Adapter->LinkIsActive != GetConnectionStatus(Adapter))
// if status has changed
{
switch ( Adapter->LinkIsActive )
{
case NdisMediaStateConnected: // changing from connected
Adapter->LinkIsActive = NdisMediaStateDisconnected;
break;
case NdisMediaStateDisconnected: // changing from disconnected
Adapter->LinkIsActive = NdisMediaStateConnected;
break;
}
}
// now we simply return our status (NdisMediaState[Dis]Connected)
// this line also covers the case where our link status hasn't changed.
GenericUlong = (ULONG) Adapter->LinkIsActive;
break;
case OID_PNP_CAPABILITIES:
TRACEPOWER(("QUERY:Got a Query Capabilities Call\n"));
// since we are stubbing power management, return only the
// D0 power state indicating that the lowest power state we
// support is D0 (full power)
// Power_Management_Capabilities.WakeUpCapabilities.MinMagicPacketWakeUp = NdisDeviceStateD0;
// Power_Management_Capabilities.WakeUpCapabilities.MinPatternWakeUp = NdisDeviceStateD0;
// Power_Management_Capabilities.WakeUpCapabilities.MinLinkChangeWakeUp = NdisDeviceStateD0;
// MoveSource = (PVOID) &Power_Management_Capabilities;
// MoveBytes = sizeof(NDIS_PNP_CAPABILITIES);
Status = NDIS_STATUS_NOT_SUPPORTED; //stub
break;
case OID_PNP_QUERY_POWER:
TRACEPOWER(("QUERY:Got a Query Power Call of 0x%08X\n",InformationBuffer));
// Adapter->NextPowerState = (NDIS_DEVICE_POWER_STATE) InformationBuffer;
// return success indicating we will do nothing to jeapordize the
// transition...
// Status is pre-set in this routine to Success
// but since we aren't actually supporting power manangement
// return failure.
Status = NDIS_STATUS_NOT_SUPPORTED; //stub
break;
// WMI support
// this is the uint case
case OID_CUSTOM_DRIVER_QUERY:
REQUEST(Adapter,("CUSTOM_DRIVER_QUERY got a QUERY\n"));
GenericUlong = ++Adapter->CustomDriverSet;
break;
case OID_CUSTOM_DRIVER_SET:
REQUEST(Adapter,("CUSTOM_DRIVER_SET got a QUERY\n"));
GenericUlong = Adapter->CustomDriverSet;
break;
// this is the array case
case OID_CUSTOM_ARRAY:
REQUEST(Adapter,("CUSTOM_ARRAY got a QUERY\n"));
NdisMoveMemory(VendorId, Adapter->AiNodeAddress, 4);
MoveSource = (PVOID) VendorId;
MoveBytes = sizeof(VendorId);
break;
// this is the string case
case OID_CUSTOM_STRING:
REQUEST(Adapter,("CUSTOM_STRING got a QUERY\n"));
MoveSource = (PVOID) VendorDescriptor;
MoveBytes = sizeof(VendorDescriptor);
break;
default:
// The query is for a driver statistic, so we need to first
// update our statistics in software.
DumpStatsCounters(Adapter);
switch (Oid)
{
case OID_GEN_XMIT_OK:
GenericUlong = (ULONG) Adapter->GoodTransmits;
break;
case OID_GEN_RCV_OK:
GenericUlong = (ULONG) Adapter->GoodReceives;
break;
case OID_GEN_XMIT_ERROR:
GenericUlong = (ULONG) (Adapter->TxAbortExcessCollisions +
Adapter->TxDmaUnderrun +
Adapter->TxLostCRS +
Adapter->TxLateCollisions);
break;
case OID_GEN_RCV_ERROR:
// receive error counters are kept on chip.
GenericUlong = (ULONG) (Adapter->RcvCrcErrors +
Adapter->RcvAlignmentErrors +
Adapter->RcvResourceErrors +
Adapter->RcvDmaOverrunErrors +
Adapter->RcvRuntErrors);
break;
case OID_GEN_RCV_NO_BUFFER:
GenericUlong = (ULONG) Adapter->RcvResourceErrors;
break;
case OID_GEN_RCV_CRC_ERROR:
GenericUlong = (ULONG) Adapter->RcvCrcErrors;
break;
case OID_GEN_TRANSMIT_QUEUE_LENGTH:
GenericUlong = (ULONG) Adapter->RegNumTcb;
break;
case OID_802_3_RCV_ERROR_ALIGNMENT:
GenericUlong = (ULONG) Adapter->RcvAlignmentErrors;
break;
case OID_802_3_XMIT_ONE_COLLISION:
GenericUlong = (ULONG) Adapter->OneRetry;
break;
case OID_802_3_XMIT_MORE_COLLISIONS:
GenericUlong = (ULONG) Adapter->MoreThanOneRetry;
break;
case OID_802_3_XMIT_DEFERRED:
GenericUlong = (ULONG) Adapter->TxOKButDeferred;
break;
case OID_802_3_XMIT_MAX_COLLISIONS:
GenericUlong = (ULONG) Adapter->TxAbortExcessCollisions;
break;
case OID_802_3_RCV_OVERRUN:
GenericUlong = (ULONG) Adapter->RcvDmaOverrunErrors;
break;
case OID_802_3_XMIT_UNDERRUN:
GenericUlong = (ULONG) Adapter->TxDmaUnderrun;
break;
case OID_802_3_XMIT_HEARTBEAT_FAILURE:
GenericUlong = (ULONG) Adapter->TxLostCRS;
break;
case OID_802_3_XMIT_TIMES_CRS_LOST:
GenericUlong = (ULONG) Adapter->TxLostCRS;
break;
case OID_802_3_XMIT_LATE_COLLISIONS:
GenericUlong = (ULONG) Adapter->TxLateCollisions;
break;
default:
Status = NDIS_STATUS_NOT_SUPPORTED;
break;
}
}
if (Status == NDIS_STATUS_SUCCESS)
{
if (MoveBytes > InformationBufferLength)
{
// Not enough room in InformationBuffer. Punt
*BytesNeeded = MoveBytes;
Status = NDIS_STATUS_BUFFER_TOO_SHORT;
}
else
{
// Copy result into InformationBuffer
*BytesWritten = MoveBytes;
if (MoveBytes > 0)
NdisMoveMemory(InformationBuffer, MoveSource, MoveBytes);
}
}
return (Status);
} /* end of D100QueryInformation */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -