0

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?

Vitalie
  • 3
  • 3
  • It's usually helpful to say what went wrong - is the wrong data being sent? Does it crash? Also, I don't understand why the code needs a temporary NB. – Jeffrey Tippet Dec 29 '14 at 23:18
  • Doesnt crash. Seems that wrong data is sent, and the DHCP on the other end (a stable prior release of the same project) doesnt see requests. As of the temporary NB, how else could we inject data into the packet? We would be glad to know how to do that without a temp NB! – Vitalie Dec 31 '14 at 00:42

0 Answers0