Re: Duplicating NDIS_PACKET



"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

.



Relevant Pages

  • Duplicating NDIS_PACKET
    ... short period) sends/receives the duplicate instead. ... as it seems to me that I don't really copy any packet data... ... NULL pointer at OriginalPkt, MPReturnPackets crashes, if I enter a pointer ... PNDIS_PACKET Pkt; ...
    (microsoft.public.development.device.drivers)
  • BPF patch for addition of good feature linux packet (7) (see attachment)
    ... * Packet types. ... diff -ruN sys.orig/net/bpf.c sys/net/bpf.c ... * pkt is really an mbuf. ...
    (freebsd-net)
  • BPF patch
    ... * Packet types. ... diff -ruN sys.orig/net/bpf.c sys/net/bpf.c ... * pkt is really an mbuf. ...
    (freebsd-hackers)
  • Re: Duplicating NDIS_PACKET
    ... the NULL pointer to OriginalPkt in my ProtocolReserved area is ... > - Your local packet uses the same NDIS_BUFFER chain as the original ... the lifetime of your local packet cannot be any longer ... >> short period) sends/receives the duplicate instead. ...
    (microsoft.public.development.device.drivers)
  • Re: Duplicating NDIS_PACKET
    ... - Your local packet uses the same NDIS_BUFFER chain as the original ... the lifetime of your local packet cannot be any longer ... > short period) sends/receives the duplicate instead. ... > NULL pointer at OriginalPkt, MPReturnPackets crashes, if I enter a pointer ...
    (microsoft.public.development.device.drivers)