📄 request.c
字号:
default:
DBGERR((TEXT("MiniportQueryInformation(%d=0x%x), unsupported OID"),
Oid, Oid));
result = NDIS_STATUS_NOT_SUPPORTED;
break;
}
}
else {
*BytesNeeded = sizeof(UINT) - InformationBufferLength;
*BytesWritten = 0;
result = NDIS_STATUS_INVALID_LENGTH;
}
DBGOUT((TEXT("MiniportQueryInformation succeeded (info <- %d)"),
*(UINT *)InformationBuffer));
DEBUGMSG(ZONE_FIRMODE, (TEXT("MiniportQueryInformation <--\r\n")));
return result;
}
/*
*************************************************************************
* MiniportSetInformation
*************************************************************************
*
*
* MiniportSetInformation allows other layers of the network software
* (e.g., a transport driver) to control the miniport driver by changing
* information that the miniport driver maintains in its OIDs,
* such as the packet filters or multicast addresses.
*
*
*/
NDIS_STATUS MiniportSetInformation (
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesRead,
OUT PULONG BytesNeeded
)
{
NDIS_STATUS result = NDIS_STATUS_SUCCESS;
IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);
int i;
DEBUGMSG(ZONE_FIRMODE, (TEXT("MiniportSetInformation -->\r\n")));
if (InformationBufferLength >= sizeof(UINT)){
UINT info;
*BytesRead = sizeof(UINT);
*BytesNeeded = 0;
switch (Oid){
case OID_IRDA_LINK_SPEED:
info = *(UINT *)InformationBuffer;
DBGOUT((TEXT("MiniportSetInformation(OID_IRDA_LINK_SPEED, %xh)"),
info));
result = NDIS_STATUS_INVALID_DATA;
for (i = 0; i < NUM_BAUDRATES; i++){
if (supportedBaudRateTable[i].bitsPerSec == info){
thisDev->linkSpeedInfo = &supportedBaudRateTable[i];
result = NDIS_STATUS_SUCCESS;
break;
}
}
if (result == NDIS_STATUS_SUCCESS){
if (!SetSpeed(thisDev)){
result = NDIS_STATUS_FAILURE;
}
}
else {
*BytesRead = 0;
*BytesNeeded = 0;
}
break;
case OID_IRDA_MEDIA_BUSY:
info = *(UINT *)InformationBuffer;
DBGOUT((TEXT("MiniportSetInformation(OID_IRDA_MEDIA_BUSY, %xh)"),
info));
/*
* The protocol can use this OID to reset the busy field
* in order to check it later for intervening activity.
*/
thisDev->mediaBusy = (BOOLEAN)info;
result = NDIS_STATUS_SUCCESS;
break;
#ifdef UNDER_CE
case OID_IRDA_REACQUIRE_HW_RESOURCES:
DBGWARN((TEXT("NSCIRDA: Set(OID_IRDA_REACQUIRE_HW_RESOURCES)")));
*BytesNeeded = 0;
if (thisDev->resourcesReleased == FALSE)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("NSCIRDA: resources already acquired!!\r\n")));
result = NDIS_STATUS_FAILURE;
}
else
{
if (OpenCOM(thisDev) == FALSE)
{
DEBUGMSG(ZONE_ERROR, (TEXT("NSCIRDA: DoOpen failure.\r\n")));
result = NDIS_STATUS_FAILURE;
}
else
{
// Reset state.
thisDev->portInfo.rcvState = STATE_INIT;
thisDev->portInfo.writePending = FALSE;
DBGOUT((TEXT("writePending = FALSE")));
thisDev->resourcesReleased = FALSE;
}
}
break;
#endif // UNDER_CE
case OID_GEN_CURRENT_PACKET_FILTER:
DBGOUT((TEXT("MiniportSetInformation(OID_GEN_CURRENT_PACKET_FILTER)")));
result = NDIS_STATUS_SUCCESS;
break;
/*
* We don't support these
*/
case OID_IRDA_RATE_SNIFF:
case OID_IRDA_UNICAST_LIST:
/*
* These are query-only parameters.
*/
case OID_IRDA_SUPPORTED_SPEEDS:
case OID_IRDA_MAX_UNICAST_LIST_SIZE:
case OID_IRDA_TURNAROUND_TIME:
default:
DBGERR((TEXT("MiniportSetInformation(OID=%d=0x%x) - unsupported OID"),
Oid, Oid));
*BytesRead = 0;
*BytesNeeded = 0;
result = NDIS_STATUS_NOT_SUPPORTED;
break;
}
}
else {
*BytesRead = 0;
*BytesNeeded = sizeof(UINT);
result = NDIS_STATUS_INVALID_LENGTH;
}
DBGOUT((TEXT("MiniportSetInformation succeeded")));
DEBUGMSG(ZONE_FIRMODE, (TEXT("MiniportSetInformation <--\r\n")));
return result;
}
DWORD
ReleaseAdapterResources(
PVOID pvContext_pIrDevice
)
{
IrDevice *pIrDevice = (IrDevice *)pvContext_pIrDevice;
BOOL fSwitchSuccessful;
NDIS_HANDLE hSwitchToMiniport;
DBGOUT((TEXT("+ReleaseAdapterResources(%#x)\r\n"), pIrDevice));
DEBUGMSG(ZONE_FIRMODE, (TEXT("ReleaseAdapterResources -->\r\n")));
// Wait for all packets to be sent and returned.
while (1)
{
NdisAcquireSpinLock(&pIrDevice->QueueLock);
if (IsListEmpty(&pIrDevice->SendQueue) == TRUE &&
pIrDevice->portInfo.writePending == FALSE)
{
NdisReleaseSpinLock(&pIrDevice->QueueLock);
break;
}
NdisReleaseSpinLock(&pIrDevice->QueueLock);
Sleep(100);
}
// Need to indicate that we are releasing resources now so the ISR
// does not try to perform any real operations.
pIrDevice->resourcesReleased = TRUE;
CloseCOM(pIrDevice);
// Indicate success back to protocol.
fSwitchSuccessful = NdisIMSwitchToMiniport(
pIrDevice->ndisAdapterHandle,
&hSwitchToMiniport
);
if (hSwitchToMiniport == FALSE)
{
// WinCE's NdisIMSwitchToMiniport should not fail.
ASSERT(FALSE);
}
NdisMQueryInformationComplete(
pIrDevice->ndisAdapterHandle,
NDIS_STATUS_SUCCESS
);
NdisIMRevertBack(
pIrDevice->ndisAdapterHandle,
hSwitchToMiniport
);
DBGOUT((TEXT("-ReleaseAdapterResources\r\n")));
DEBUGMSG(ZONE_FIRMODE, (TEXT("ReleaseAdapterResources <--\r\n")));
return (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -