Cloning a entire Netbufferlist

Hi all,

I have to pass modified NBL to Upper layer.here i am using filter driver in
between. In filter driver ReceiveNetBufferList method, I am trying to clone
the NBL. How can i achieve this?

I used following code…
PNET_BUFFER_LIST NetBufferListClone;
NET_BUFFER_LIST_POOL_PARAMETERS Parameters;
PNET_BUFFER_LIST_POOL_PARAMETERS parameters;
NET_BUFFER_POOL_PARAMETERS NBParameters;
PNET_BUFFER_POOL_PARAMETERS pNBParameters;
NDIS_HANDLE NBLPoolHandle;
NDIS_HANDLE NBPoolHandle;

NdisZeroMemory( &Parameters,
sizeof(NET_BUFFER_LIST_POOL_PARAMETERS));
parameters= &Parameters;
parameters->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
parameters->Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
parameters->Header.Size =
NDIS_SIZEOF_NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
parameters->ProtocolId = NDIS_PROTOCOL_ID_DEFAULT ;
parameters->fAllocateNetBuffer = TRUE;
parameters->ContextSize = 1000*MEMORY_ALLOCATION_ALIGNMENT;
parameters->PoolTag = ‘TEig’;
parameters->DataSize = 2500;
NdisZeroMemory( &NBParameters, sizeof(NET_BUFFER_POOL_PARAMETERS));
pNBParameters= & NBParameters;
pNBParameters->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
pNBParameters->Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
pNBParameters->Header.Size =
NDIS_SIZEOF_NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
pNBParameters->PoolTag = ‘ETig’;
pNBParameters->DataSize = 2500;
NBLPoolHandle = NdisAllocateNetBufferListPool(FilterDriverHandle,
parameters);
if(NBLPoolHandle == NULL)
{
DbgPrint(“Failed to allocate NetbufferLIST”);
return;
}
else
{
DbgPrint(“Allocation is success For NBL pool”);
}
NBPoolHandle = NdisAllocateNetBufferPool(FilterDriverHandle, pNBParameters
);
if(NBPoolHandle == NULL)
{
DbgPrint(“Failed to allocate NB Pool”);
}
else{
DbgPrint(“Allocation is success for NB Pool”);
}
NetBufferListClone = NdisAllocateCloneNetBufferList(NetBufferLists,
NBLPoolHandle, NBPoolHandle, NDIS_CLONE_FLAGS_USE_ORIGINAL_MDLS );
if(NetBufferListClone == NULL)
{
DbgPrint(“Clone Failed”);
}
else
{
DbgPrint(“Clone Success”);
}