Re: Question about NDIS memory management
- From: atweir@xxxxxxxxx
- Date: 18 Nov 2006 13:12:11 -0800
Thanks for the reply Stephan - in my original message when I said "NDIS
frees ..." I was refering to the API's you listed. I was just checking
that there is no issue with indicating that the data size in the buffer
is X while the actual memory allocated is >X.
Stephan Wolf [MVP] wrote:
2) NDIS will *not* free anything for you when you call NdisSend(),
i.e., NDIS will not free neither the NDIS_PACKET, nor any
NDIS_BUFFER(s) associated with it, nor the memory that make up the
actual buffer area(s). Instead, you need to take "appropriate" action
in your ProtocolSendComplete() handler. For instance, you could call
NdisFreeMemory(), NdisFreeBuffer(), and NdisFreePacket(). This would be
"appropriate" for the code you presented.
1) But you could also choose to reuse the packet/buffer/memory without
freeing and reallocating them. This implies a more complicated design.
Not sure whether this would make sense for you.
Stephan
---
atweir@xxxxxxxxx wrote:
I am writing an IM driver based on the PT example. The driver will
inspect each packet received from the network and if it meets certain
criteria it will append its payload plus a locally generated header to
NDIS memory. When the memory is full a new packet and buffer are
created and the packet is sent back over the network. None of these
received packets are sent up the network stack. Here is my pseudo code
For each received network packet
{
If (packet meets criteria)
{
If (packet payload size > (MaxMTU + index))
{
NdisDprAllocatePacket(,&NewPacket,);
NdisAllocateBuffer(,&NewBuffer, pool, data, index);
NdisChainBufferAtFront(NewPacket, NewBuffer)
NdisSend(,,NewPacket);
}
If (data == NULL)
{
NdisAllocateMemoryWithTag(&data,MaxMTU,);
Build UDP header
Index = sizeof(UDPHeader);
}
Build a descriptor for this payload and copy it to &data[index]
Adjust index
Copy the payload from packet to &data[index]
Adjust index
}
}
My questions are:
1) is there a better way to manage the NDIS memory/buffers?
2) When I allocate the memory I specify a size of MaxMTU but when I
associate the memory with the buffer I specify the amount of data in
the buffer which will be less. When NDIS frees the memory after sending
the packet will this difference cause a memory leak?
TIA, Alan
.
- Follow-Ups:
- Re: Question about NDIS memory management
- From: Stephan Wolf [MVP]
- Re: Question about NDIS memory management
- References:
- Question about NDIS memory management
- From: atweir
- Re: Question about NDIS memory management
- From: Stephan Wolf [MVP]
- Question about NDIS memory management
- Prev by Date: Re: Multiple DMA transactions
- Next by Date: Re: What is the volume driver?
- Previous by thread: Re: Question about NDIS memory management
- Next by thread: Re: Question about NDIS memory management
- Index(es):
Relevant Pages
|
Loading