Re: Duplicating NDIS_PACKET
- From: "Thomas F. Divine [DDK MVP]" <tdivine@xxxxxxxxxxxxxxxx>
- Date: Wed, 26 Oct 2005 16:30:34 -0400
"Peter Schmitz" <PeterSchmitz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:49AEB8A7-E564-4AE8-A9FB-B35BA74BD730@xxxxxxxxxxxxxxxx
Thanks for replying!
So, I discarded the two bogus lines (containing the copying of the private parts), and recreated the PtSendcomplete handler like this:
VOID PtSendComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status ) { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PNDIS_PACKET Pkt; NDIS_HANDLE PoolHandle;
PSEND_RSVD SendRsvd; UINT nDataSize, nBufferCount; PNDIS_BUFFER pBuffer;
SendRsvd = (PSEND_RSVD)(Packet->ProtocolReserved); Pkt = SendRsvd->OriginalPkt;
if( Pkt ) { NdisIMCopySendCompletePerPacketInfo (Pkt, Packet); NdisMSendComplete(pAdapt->MiniportHandle,Pkt,Status); } else {
You must ALWAYS free your own packet! Not just in the case where OriginalPkt != NULL.
NdisQueryPacket(Packet,NULL,&nBufferCount,&pBuffer,&nDataSize); while(nBufferCount-- > 0L) { NdisUnchainBufferAtFront(Packet,&pBuffer); if(pBuffer)NdisFreeBuffer(pBuffer); } } NdisFreePacket(Packet);
}
Unfortunately, this source code results in an error when I try to send the packet DuplicatePacket created for me:
DRIVER_IRQL_NOT_LESS_OR_EQUAL (d1)
Arg1: 835eca10, memory referenced Arg2: 00000002, IRQL Arg3: 00000000, value 0 = read operation, 1 = write operation Arg4: f871ffc5, address which referenced memory
just at the lines:
NdisSend(&Status,padapt->BindingHandle,looppacket->packet); if(Status != NDIS_STATUS_PENDING) {
Just call PtSendComplete. It should know what to do in this case.
UINT nDataSize, nBufferCount; PNDIS_BUFFER pBuffer;
NdisQueryPacket(looppacket->packet,NULL,&nBufferCount,&pBuffer,&nDataSize); while( nBufferCount-- > 0L ) { NdisUnchainBufferAtFront(looppacket->packet,&pBuffer); NdisFreeBuffer(pBuffer); } NdisFreePacket(looppacket->packet); }
NdisSend is the cause for the error.
By the way, the passthru sample contains some lines in the MPSendPackets
function (only covered in NDIS 5.1 config) that don't seem to create a copy
of the NDIS_PACKET, but instead use the original packet directly... (I
commented them out for now).
For sure, the PassThru chaining code simply links the original packet's NDIS buffer's into the new "wrapper" packet for simple passthru. It does NOT duplicate the original packet's contents.
Thomas
Greetings, and thanks a lot,
Peter
.
- References:
- Duplicating NDIS_PACKET
- From: Peter Schmitz
- Re: Duplicating NDIS_PACKET
- From: Stephan Wolf [MVP]
- Re: Duplicating NDIS_PACKET
- From: Peter Schmitz
- Duplicating NDIS_PACKET
- Prev by Date: Re: Problems adding NDIS_BUFFERS to an NDIS_PACKET
- Next by Date: RtlCreateRegistryKey and STATUS_BUFFER_TOO_SMALL
- Previous by thread: Re: Duplicating NDIS_PACKET
- Next by thread: About the Connection of MPEG-1 Stream Splitter ...
- Index(es):
Relevant Pages
|