在NDIS6中将标头添加到NetBuffer

时间:2014-12-27 01:45:44

标签: ndis

在NDIS6 LWF中,我们使用以下代码片段在发送之前将名为DaiHdr的结构预先添加到netbuffer:

// 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);
}

然而,我们的发送程序似乎有些不对劲。有人能说出这件作品是否正确吗?

0 个答案:

没有答案