📄 request.c
字号:
case OID_GEN_TRANSMIT_BUFFER_SPACE:
GenericUlong = HTDSU_MAX_PACKET_SIZE;
break;
case OID_GEN_RECEIVE_BUFFER_SPACE:
GenericUlong = HTDSU_MAX_PACKET_SIZE;
break;
case OID_GEN_TRANSMIT_BLOCK_SIZE:
GenericUlong = HTDSU_MAX_PACKET_SIZE;
break;
case OID_GEN_RECEIVE_BLOCK_SIZE:
GenericUlong = HTDSU_MAX_PACKET_SIZE;
break;
case OID_GEN_VENDOR_ID:
SourceBuffer = HtDsuVendorID;
SourceBufferLength = sizeof(HtDsuVendorID);
break;
case OID_GEN_VENDOR_DESCRIPTION:
SourceBuffer = HtDsuVendorDescription;
SourceBufferLength = strlen(HtDsuVendorDescription) + 1;
break;
case OID_GEN_CURRENT_LOOKAHEAD:
GenericUlong = HTDSU_MAX_LOOKAHEAD;
break;
case OID_GEN_MAC_OPTIONS:
GenericUlong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
NDIS_MAC_OPTION_NO_LOOPBACK |
NDIS_MAC_OPTION_TRANSFERS_NOT_PEND;
break;
case OID_GEN_DRIVER_VERSION:
GenericUshort = (NDIS_MAJOR_VERSION << 8) + NDIS_MINOR_VERSION;
SourceBuffer = &GenericUshort;
SourceBufferLength = sizeof(USHORT);
break;
case OID_GEN_MAXIMUM_TOTAL_SIZE:
GenericUlong = HTDSU_MAX_PACKET_SIZE;
break;
case OID_WAN_MEDIUM_SUBTYPE:
GenericUlong = NdisWanMediumSW56K;
break;
case OID_WAN_GET_INFO:
SourceBuffer = &Adapter->WanInfo;
SourceBufferLength = sizeof(NDIS_WAN_INFO);
break;
case OID_WAN_PERMANENT_ADDRESS:
case OID_WAN_CURRENT_ADDRESS:
HtDsuWanAddress[5] = Adapter->InstanceNumber + '0';
SourceBuffer = HtDsuWanAddress;
SourceBufferLength = sizeof(HtDsuWanAddress);
break;
case OID_WAN_GET_LINK_INFO:
{
/*
// The first field in the info buffer is a MiniportLinkContext
// which is really a pointer to an entry in our link information.
// If this aint so, bail out...
*/
PHTDSU_LINK Link = (PHTDSU_LINK)
(((PNDIS_WAN_SET_LINK_INFO)InformationBuffer)->NdisLinkHandle);
if (!IS_VALID_LINK(Adapter, Link))
{
SourceBufferLength = 0;
Status = NDIS_STATUS_INVALID_DATA;
break;
}
DBG_NOTICE(Adapter,("Returning:\n"
"NdisLinkHandle = %08lX\n"
"MaxSendFrameSize = %08lX\n"
"MaxRecvFrameSize = %08lX\n"
"SendFramingBits = %08lX\n"
"RecvFramingBits = %08lX\n"
"SendACCM = %08lX\n"
"RecvACCM = %08lX\n",
Link->WanLinkInfo.NdisLinkHandle ,
Link->WanLinkInfo.MaxSendFrameSize ,
Link->WanLinkInfo.MaxRecvFrameSize ,
Link->WanLinkInfo.SendFramingBits ,
Link->WanLinkInfo.RecvFramingBits ,
Link->WanLinkInfo.SendACCM ,
Link->WanLinkInfo.RecvACCM ));
SourceBuffer = &(Link->WanLinkInfo);
SourceBufferLength = sizeof(NDIS_WAN_GET_LINK_INFO);
}
break;
default:
/*
// Unknown OID
*/
Status = NDIS_STATUS_INVALID_OID;
SourceBufferLength = 0;
break;
}
/*
// Now we copy the data into the caller's buffer if there's enough room,
// otherwise, we report the error and tell em how much we need.
*/
if (SourceBufferLength > InformationBufferLength)
{
*BytesNeeded = SourceBufferLength;
Status = NDIS_STATUS_INVALID_LENGTH;
}
else if (SourceBufferLength)
{
NdisMoveMemory(InformationBuffer,
SourceBuffer,
SourceBufferLength
);
*BytesNeeded = *BytesWritten = SourceBufferLength;
Status = NDIS_STATUS_SUCCESS;
}
else
{
*BytesNeeded = *BytesWritten = 0;
}
DBG_FILTER(Adapter,DBG_REQUEST_ON,
("RETURN: Status=%Xh Needed=%d Written=%d\n",
Status, *BytesNeeded, *BytesWritten));
DBG_LEAVE(Adapter);
return (Status);
}
NDIS_STATUS
HtDsuSetInformation(
IN PHTDSU_ADAPTER Adapter,
IN NDIS_OID Oid,
IN PVOID InformationBuffer,
IN ULONG InformationBufferLength,
OUT PULONG BytesRead,
OUT PULONG BytesNeeded
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
The MiniportSetInformation request allows for control of the Miniport
by changing information maintained by the Miniport driver.
Any of the settable NDIS Global Oids may be used. (see section 7.4 of
the NDIS 3.0 specification for a complete description of the NDIS Oids.)
If the Miniport does not complete the call immediately (by returning
NDIS_STATUS_PENDING), it must call NdisMSetInformationComplete to
complete the call. The Miniport controls the buffers pointed to by
InformationBuffer, BytesRead, and BytesNeeded until the request completes.
Interrupts are in any state during the call, and no other requests will
be submitted to the Miniport until this request is completed.
Parameters:
MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
during MiniportInitialize.
Oid _ The OID. (See section 7.4 of the NDIS 3.0 specification for
a complete description of OIDs.)
InformationBuffer _ The buffer that will receive the information.
(See section 7.4 of the NDIS 3.0 specification for
a description of the length required for each OID.)
InformationBufferLength _ The length in bytes of InformationBuffer.
BytesRead_ Returns the number of bytes read from InformationBuffer.
BytesNeeded _ This parameter returns the number of additional bytes
expected to satisfy the OID.
Return Values:
NDIS_STATUS_INVALID_DATA
NDIS_STATUS_INVALID_LENGTH
NDIS_STATUS_INVALID_OID
NDIS_STATUS_NOT_ACCEPTED
NDIS_STATUS_NOT_SUPPORTED
NDIS_STATUS_PENDING
NDIS_STATUS_RESOURCES
NDIS_STATUS_SUCCESS
---------------------------------------------------------------------------*/
{
DBG_FUNC("HtDsuSetInformation")
/*
// Holds the status result returned by this function.
*/
NDIS_STATUS Status;
/*
// If this is a TAPI OID, pass it on over.
*/
if ((Oid & 0xFFFFFF00L) == (OID_TAPI_ACCEPT & 0xFFFFFF00L))
{
Status = HtTapiSetInformation(Adapter,
Oid,
InformationBuffer,
InformationBufferLength,
BytesRead,
BytesNeeded
);
return (Status);
}
DBG_ENTER(Adapter);
DBG_FILTER(Adapter,DBG_REQUEST_ON,
("(OID=%s=%08x)\n\t\tInfoLength=%d InfoBuffer=%Xh\n",
HtGetOidString(Oid),Oid,
InformationBufferLength,
InformationBuffer
));
/*
// Assume no extra bytes are needed.
*/
ASSERT(BytesRead && BytesNeeded);
*BytesRead = 0;
*BytesNeeded = 0;
/*
// Determine which OID is being requested and do the right thing.
*/
switch (Oid)
{
case OID_GEN_CURRENT_LOOKAHEAD:
/*
// WAN drivers always indicate the entire packet regardless of the
// lookahead size. So this request should be politely ignored.
*/
DBG_NOTICE(Adapter,("OID_GEN_CURRENT_LOOKAHEAD: set=%d expected=%d\n",
*(PULONG) InformationBuffer, HTDSU_MAX_LOOKAHEAD));
ASSERT(InformationBufferLength == sizeof(ULONG));
*BytesNeeded = *BytesRead = sizeof(ULONG);
Status = NDIS_STATUS_SUCCESS;
break;
case OID_WAN_SET_LINK_INFO:
if (InformationBufferLength == sizeof(NDIS_WAN_SET_LINK_INFO))
{
/*
// The first field in the info buffer is a MiniportLinkContext
// which is really a pointer to an entry in our WanLinkArray.
// If this aint so, bail out...
*/
PHTDSU_LINK Link = (PHTDSU_LINK)
(((PNDIS_WAN_SET_LINK_INFO)InformationBuffer)->NdisLinkHandle);
if (Link == NULL)
{
Status = NDIS_STATUS_INVALID_DATA;
break;
}
ASSERT(Link->WanLinkInfo.NdisLinkHandle == Link);
ASSERT(Link->WanLinkInfo.MaxSendFrameSize <= Adapter->WanInfo.MaxFrameSize);
ASSERT(Link->WanLinkInfo.MaxRecvFrameSize <= Adapter->WanInfo.MaxFrameSize);
ASSERT(!(Link->WanLinkInfo.SendFramingBits & ~Adapter->WanInfo.FramingBits));
ASSERT(!(Link->WanLinkInfo.RecvFramingBits & ~Adapter->WanInfo.FramingBits));
/*
// Copy the data into our WanLinkInfo sturcture.
*/
NdisMoveMemory(&(Link->WanLinkInfo),
InformationBuffer,
InformationBufferLength
);
*BytesRead = sizeof(NDIS_WAN_SET_LINK_INFO);
Status = NDIS_STATUS_SUCCESS;
DBG_NOTICE(Adapter,("\n setting expected\n"
"NdisLinkHandle = %08lX=?=%08lX\n"
"MaxSendFrameSize = %08lX=?=%08lX\n"
"MaxRecvFrameSize = %08lX=?=%08lX\n"
"SendFramingBits = %08lX=?=%08lX\n"
"RecvFramingBits = %08lX=?=%08lX\n"
"SendACCM = %08lX=?=%08lX\n"
"RecvACCM = %08lX=?=%08lX\n",
Link->WanLinkInfo.NdisLinkHandle , Link,
Link->WanLinkInfo.MaxSendFrameSize , Adapter->WanInfo.MaxFrameSize,
Link->WanLinkInfo.MaxRecvFrameSize , Adapter->WanInfo.MaxFrameSize,
Link->WanLinkInfo.SendFramingBits , Adapter->WanInfo.FramingBits,
Link->WanLinkInfo.RecvFramingBits , Adapter->WanInfo.FramingBits,
Link->WanLinkInfo.SendACCM , Adapter->WanInfo.DesiredACCM,
Link->WanLinkInfo.RecvACCM , Adapter->WanInfo.DesiredACCM));
}
else
{
DBG_WARNING(Adapter, ("OID_WAN_SET_LINK_INFO: Invalid size:%d expected:%d\n",
InformationBufferLength, sizeof(NDIS_WAN_SET_LINK_INFO)));
Status = NDIS_STATUS_INVALID_LENGTH;
}
*BytesNeeded = sizeof(NDIS_WAN_SET_LINK_INFO);
break;
default:
/*
// Unknown OID
*/
Status = NDIS_STATUS_INVALID_OID;
break;
}
DBG_FILTER(Adapter,DBG_REQUEST_ON,
("RETURN: Status=%Xh Needed=%d Read=%d\n",
Status, *BytesNeeded, *BytesRead));
DBG_LEAVE(Adapter);
return (Status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -