In a NDIS6 LWF, we are using the following code snippet to prepend a structure called DaiHdr to a netbuffer before sending down:
// retreat data start offset by sizeof(DAI_HDR)
NdisRetreatNetBufferDataStart(pNetBuffer, sizeof(DaiHdr), 0, NULL);
// copy data from DaiHdr to the retreated offset in pNetBuffer:
{
PMDL pMDL;
PNET_BUFFER pNB;
ULONG BytesCopied;
// allocate an MDL with data in DaiHdr
pMDL = NdisAllocateMdl(FilterDriverHandle, &DaiHdr, sizeof(DaiHdr));
// allocate a temporary NB
pNB = NdisAllocateNetBuffer(pFilter->OwnNBPool, pMDL, 0, sizeof(DaiHdr));
// copy data from DaiHdr to pNetBuffer
NdisCopyFromNetBufferToNetBuffer(pNetBuffer, 0, sizeof(DaiHdr), pNB, 0, &BytesCopied);
// free temporary resources
NdisFreeNetBuffer(pNB);
NdisFreeMdl(pMDL);
}
However, something seems wrong in our sending routine. Can someone tell if particularly this piece is correct?