阅读:1488回复:0
高手请进!..................................
在PtReceivePacket中需要对数据包源IP进行操作,代码如下:
ReceivePacket(IN PADAPT pAdapt,IN PNDIS_PACKET Packet,OUT PNDIS_PACKET MyPacket) { status = NdisAllocateMemoryWithTag(&pPacketContent,2048,TAG); if(status != NDIS_STATUS_SUCCESS) { __leave; return FALSE; } NdisZeroMemory(pPacketContent,2048); NdisQueryPacket(Packet,&PhysicalBufferCount,&BufferCount,&NdisBuffer,&TotalPacketLength); while (TRUE) { NdisQueryBufferSafe(NdisBuffer,&tembuffer,©size,NormalPagePriority); if(tembuffer != NULL) { NdisMoveMemory(pPacketContent + DataOffset,tembuffer,copysize); DataOffset += copysize; } NdisGetNextBuffer(NdisBuffer,&NdisBuffer); if(NdisBuffer == NULL) break; } if(pPacketContent[12] ==8 && pPacketContent[13] ==0) { PIP_HEADER pIPHeader = NULL; NdisAcquireSpinLock(&ListSpinLock); pIPHeader = (PIP_HEADER)(pPacketContent + 0x0E); //检查pIPHeader的IP等等操作然后采用如下形式形成新的PACKET NdisAllocateBuffer(&status,&MyBuffer,pAdapt->RecvPacketPoolHandle,pPacketContent,DataOffset); NdisChainBufferAtFront(MyPacket,MyBuffer); ReceRsvd = (PRECV_RSVD)MyPacket->MiniportReserved; ReceRsvd->OriginalPkt = MyPacket; 但是这样后,在MPReturnPacket中的NdisReturnPackets(&MyPacket, 1); 出现错误! } } 请问PtReceivePacket中对数据包的操作该如何进行,是否可以象 上面类似一样对数据包进行操作? |
|