Filter Driver Buffer Management
Filter drivers create buffers to copy network data obtained from other drivers, or to initiate send or receive operations.
If a filter driver does not create buffers, the driver does not manage buffer pools. Such a driver simply passes on the buffers that it receives from other drivers.
A filter driver that creates buffers to support send or receive operations must manage NET_BUFFER_LIST structure pools and NET_BUFFER structure pools.
To create these pools, drivers call the following functions:
Filter drivers can use the following functions to allocate structures from the pools:
NdisAllocateNetBufferAndNetBufferList
Calling NdisAllocateNetBufferAndNetBufferList is more efficient than calling NdisAllocateNetBufferList followed by NdisAllocateNetBuffer. However, NdisAllocateNetBufferAndNetBufferList only creates one NET_BUFFER structure on the NET_BUFFER_LIST structure. To use NdisAllocateNetBufferAndNetBufferList, the driver must set the AllocateNetBuffer parameter to TRUE when it calls NdisAllocateNetBufferListPool.
Filter drivers that originate send requests should determine the context and backfill space requirements of the underlying drivers. Filter drivers use restart attributes to determine the backfill requirements of underlying drivers. A filter driver should determine the backfill and context requirements in the Restarting state. The driver should allocate sufficient backfill and context space for the entire stack. If necessary, a filter driver can free the pools and reallocate them in the Restarting state.
Filter drivers use the following functions to free the pools:
Filter drivers use the following functions to free the structures allocated from the pools:
Drivers should free NET_BUFFER structures allocated with NdisAllocateNetBuffer before freeing the associated NET_BUFFER_LIST structure. NET_BUFFER structures allocated with NdisAllocateNetBufferAndNetBufferList are freed when the driver calls NdisFreeNetBufferList for the associated NET_BUFFER_LIST structure.