阅读:1777回复:5
困惑,得不到数据包协议类型
Packet = PacketArray;
NdisQueryPacket(Packet,NULL,&BufLength,&pBuffer,&PacketSize); if(!BufLength) DBGPRINT(("==Packet Query Failed")); // 分配缓冲区pPacketContent Status = NdisAllocateMemoryWithTag((PVOID *)&pPacketContent, PacketSize, 'maDN'); if (Status!=NDIS_STATUS_SUCCESS ) DBGPRINT(("==Memory Allocate Failed")); // 读取所有数据到pPacketContent NdisZeroMemory (pPacketContent, PacketSize); NdisAllocateBuffer(&Status, &pBuffer, pAdapt->SendPacketPoolHandle, pPacketContent, BufLength ); NdisQueryBuffer(pBuffer, &CurrentBufferVA, &CurrentBufferLength); while(pBuffer != NULL) { NdisMoveMemory(pPacketContent+tempBuL, CurrentBufferVA, CurrentBufferLength); tempBuL += CurrentBufferLength; NdisGetNextBuffer(pBuffer, &pBuffer); if(pBuffer == NULL) break; NdisQueryBuffer(pBuffer, &CurrentBufferVA, &CurrentBufferLength); } DBGPRINT(("==>pPacketContent:%x\n",pPacketContent[23])); 这段代码在MPSendPackets函数里,pPacketContent[23]用来得到协议类型,为什么值总为0? |
|
|
沙发#
发布于:2008-06-20 10:18
收到的并不是只有IP包,也可能是ARP包,正确的做法应该是定义好各种协议头结构,然后去解析包。
|
|
板凳#
发布于:2008-06-20 19:08
假设我要求得到的只有ip包,那为什么没有得到正确的值,我在上网,肯定会发送ip包
|
|
|
地板#
发布于:2008-06-22 00:33
打印出所有数据,检查
|
|
|
地下室#
发布于:2008-06-22 14:33
打印了,原来是NdisGetNextBuffer(pBuffer, &pBuffer);这句有问题,pBuffer变成空的了,如何解决
|
|
|
5楼#
发布于:2008-06-22 21:02
搞定了,谢谢版主提醒
|
|
|