Hi, all!
I know If I indicate all the data to the protocol by
NdisMEthIndicateReceive,the MiniportTransferData will never be called.
But the WHQL test will force to test MiniportTransferData, so I
add the handle of MiniportTransferData.
But there are some errors when HCT 11 tests this handle.Could
any one point out what’s wrong with this codes?
Usually Ndistest of HCT give MyTransferData 50 bytes to copy
(BytesToTransfer=50 , and ByteOffset = 0).And I really copied 50 bytes
to the packet,I have compared the content of buffer and packet, all the
bytes are the same.But Ndistest always report immediately :"Ndistest
ndtReceivePacketCommon: Bad Checksum of Packetinfor at 8141****".
Why, could any one give me any hint?
BTW:The call stack at the time of Ndistest reporting error is in my
driver
just after my NdisMEthIndicateReceive() call.
Thanks a lot!
Samuel
///////////////////////////////////////////////////////////////////////
///////////
NDIS_STATUS MyTransferData(
OUT PNDIS_PACKET Packet, // Received packet
OUT PUINT BytesTransferred,
IN NDIS_HANDLE MiniportAdapterContext,
IN NDIS_HANDLE MiniportRxContext, // Received data buffer
IN UINT ByteOffset, // frame data offset
IN UINT BytesToTransfer
)
{
*BytesTransferred = CopyFromBufferToPacket(
(PCHAR)((ULONG)MiniportRxContext + ByteOffset),
Packet,
0, //offset
BytesToTransfer
);
return NDIS_STATUS_SUCCESS;
}
UINT CopyFromBufferToPacket (
IN PCHAR Buffer,
IN PNDIS_PACKET Packet,
IN UINT Offset,
IN UINT BytesToCopy
)
{
UINT NdisBufferCount;
PNDIS_BUFFER CurrentBuffer;
PVOID VirtualAddress;
UINT CurrentLength;
UINT LocalBytesCopied;
UINT AmountToMove;
NdisQueryPacket(
Packet,
NULL,
&NdisBufferCount,
&CurrentBuffer,
NULL
);
if (!BytesToCopy || !NdisBufferCount) return 0;
NdisQueryBufferSafe(
CurrentBuffer,
&VirtualAddress,
&CurrentLength,NormalPagePriority
);
LocalBytesCopied = 0;
if (Offset) {
while (Offset > CurrentLength) {
Offset -= CurrentLength;
NdisGetNextBuffer(
CurrentBuffer,
&CurrentBuffer
);
if (!CurrentBuffer) return LocalBytesCopied;
NdisQueryBufferSafe(
CurrentBuffer,
&VirtualAddress,
&CurrentLength,NormalPagePriority
);
}
VirtualAddress = (PCHAR)VirtualAddress + Offset;
CurrentLength -= Offset;
}
while (LocalBytesCopied < BytesToCopy)
{
if (!CurrentLength)
{
NdisGetNextBuffer(
CurrentBuffer,
&CurrentBuffer
);
if (!CurrentBuffer) {
// There is no more buffer.
break;
}
NdisQueryBufferSafe(
CurrentBuffer,
&VirtualAddress,
&CurrentLength,NormalPagePriority
);
}
AmountToMove = min (CurrentLength , BytesToCopy -
LocalBytesCopied);
NdisMoveMemory(VirtualAddress,Buffer,AmountToMove);
LocalBytesCopied += AmountToMove;
CurrentLength -= AmountToMove;
Buffer = (PCHAR)Buffer + AmountToMove;
VirtualAddress = (PCHAR)VirtualAddress + AmountToMove;
}
return LocalBytesCopied;
}