📄 request.c
字号:
/*
Copyright(c) 1998,1999 SIC/Hitachi,Ltd.
Module Name:
request.c
Revision History:
26th May 1999 Released
*/
#include "nsc.h"
#include "settings.h"
#include "firregs.h"
DWORD
ReleaseAdapterResources(
PVOID pvContext_pIrDevice
);
/*
*************************************************************************
* MiniportQueryInformation
*************************************************************************
*
*
* MiniportQueryInformation queries the capabilities and status of the miniport driver.
*
*
*/
NDIS_STATUS MiniportQueryInformation (
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesWritten,
OUT PULONG BytesNeeded
)
{
NDIS_STATUS result = NDIS_STATUS_SUCCESS;
IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);
UINT i, speeds;
UINT *infoPtr;
DEBUGMSG(ZONE_FIRMODE, (TEXT("MiniportQueryInformation -->\r\n")));
if (InformationBufferLength >= sizeof(int)){
switch (Oid){
case OID_IRDA_RECEIVING:
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_RECEIVING)")));
*(UINT *)InformationBuffer = (UINT)thisDev->nowReceiving;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_SUPPORTED_SPEEDS:
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_SUPPORTED_SPEEDS)")));
speeds = thisDev->portInfo.hwCaps.supportedSpeedsMask & ALL_IRDA_SPEEDS;
*BytesWritten = 0;
for (i = 0, infoPtr = (PUINT)InformationBuffer;
(i < NUM_BAUDRATES) &&
speeds &&
(InformationBufferLength >= sizeof(UINT));
i++){
if (supportedBaudRateTable[i].ndisCode & speeds){
*infoPtr++ = supportedBaudRateTable[i].bitsPerSec;
InformationBufferLength -= sizeof(UINT);
*BytesWritten += sizeof(UINT);
speeds &= ~supportedBaudRateTable[i].ndisCode;
DBGOUT((TEXT(" - supporting speed %d bps"),
supportedBaudRateTable[i].bitsPerSec));
}
}
if (speeds){
/*
* We ran out of room in InformationBuffer.
* Count the remaining number of bits set in speeds
* to figure out the number of remaining bytes needed.
*/
for (*BytesNeeded = 0; speeds; *BytesNeeded += sizeof(UINT)){
/*
* This instruction clears the lowest set bit in speeds.
* Trust me.
*/
speeds &= (speeds - 1);
}
result = NDIS_STATUS_INVALID_LENGTH;
}
else {
result = NDIS_STATUS_SUCCESS;
*BytesNeeded = 0;
}
break;
case OID_IRDA_LINK_SPEED:
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_LINK_SPEED)")));
if (thisDev->linkSpeedInfo){
*(UINT *)InformationBuffer = thisDev->linkSpeedInfo->bitsPerSec;
}
else {
*(UINT *)InformationBuffer = DEFAULT_BAUD_RATE;
}
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_MEDIA_BUSY:
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_MEDIA_BUSY)")));
*(UINT *)InformationBuffer = (UINT)thisDev->mediaBusy;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
#ifdef UNDER_CE
case OID_IRDA_RELEASE_HW_RESOURCES:
DBGWARN((TEXT("NSCIRDA: Query(OID_IRDA_RELEASE_HW_RESOURCES)")));
if (thisDev->resourcesReleased == TRUE)
{
*BytesWritten = 0;
result = NDIS_STATUS_FAILURE;
DEBUGMSG(ZONE_ERROR,
(TEXT("NSCIRDA: resources already released!!!\r\n")));
}
else
{
HANDLE hRelThread;
DWORD dwRelThreadId;
*BytesWritten = sizeof(UINT);
hRelThread = CreateThread(NULL,
0, ReleaseAdapterResources, thisDev,
0, &dwRelThreadId);
if (hRelThread == NULL)
{
result = NDIS_STATUS_RESOURCES;
}
else
{
CloseHandle(hRelThread);
result = NDIS_STATUS_PENDING;
}
}
break;
#endif // UNDER_CE
case OID_GEN_MAXIMUM_LOOKAHEAD:
DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAXIMUM_LOOKAHEAD)")));
*(UINT *)InformationBuffer = 256;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_GEN_MAC_OPTIONS:
DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAC_OPTIONS)")));
*(UINT *)InformationBuffer =
NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
NDIS_MAC_OPTION_TRANSFERS_NOT_PEND;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_GEN_MAXIMUM_SEND_PACKETS:
DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAXIMUM_SEND_PACKETS)")));
*(UINT *)InformationBuffer = 16;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_TURNAROUND_TIME:
/*
* Indicate the amount of time that the transceiver needs
* to recuperate after a send.
*/
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_TURNAROUND_TIME)")));
*(UINT *)InformationBuffer = thisDev->portInfo.hwCaps.turnAroundTime_usec;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_EXTRA_RCV_BOFS:
/*
* Pass back the number of _extra_ BOFs to be prepended
* to packets sent to this unit at 115.2 baud, the
* maximum Slow IR speed. This will be scaled for other
* speed according to the table in the
* 'Infrared Extensions to NDIS' spec.
*/
DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_EXTRA_RCV_BOFS)")));
*(UINT *)InformationBuffer = thisDev->portInfo.hwCaps.extraBOFsRequired;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_GEN_CURRENT_PACKET_FILTER:
DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_CURRENT_PACKET_FILTER)")));
*(UINT *)InformationBuffer = NDIS_PACKET_TYPE_PROMISCUOUS;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_GEN_MAXIMUM_FRAME_SIZE:
DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAXIMUM_FRAME_SIZE)")));
*(UINT *)InformationBuffer = MAX_I_DATA_SIZE;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_MAX_RECEIVE_WINDOW_SIZE:
*(UINT *)InformationBuffer = (UINT)1;
*BytesWritten = sizeof(UINT);
*BytesNeeded = 0;
break;
case OID_IRDA_UNICAST_LIST:
case OID_IRDA_MAX_UNICAST_LIST_SIZE:
case OID_IRDA_RATE_SNIFF:
/*
* We don't support these
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -