阅读:1449回复:2
请教一个发送包处理的问题
我在2000DDK的PassThru基础上做一个处理收发包的驱动,在发送的时
候我用Dbgview看了一下我的网卡走的 Miniport MPSendPackets, 调用Miniport MPSendOnePacket最后NdisSend实现发送。我在 NdisSend之前加入了如下代码实现对发送包的解析(目前只是打印包内容): MPSendOnePacket ( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags ) { ......//定义变量,拷贝数据到MyPacket中(这些代码没有问题,因 为驱动Build之后网络通畅) NdisQueryPacket(MyPacket , &PhysicalBufferCount , &BufferCount , &CurrentBuffer , &TotalPacketLength );//query packet DbgPrint(\" PhysicalBufferCount: %u.\\n\", PhysicalBufferCount); DbgPrint(\" BufferCount: %u.\\n\", BufferCount); DbgPrint(\" TotalPacketLenth: %u.\\n\", TotalPacketLength); HeaderSize = NDIS_GET_PACKET_HEADER_SIZE(MyPacket);//head DbgPrint(\" HeaderSize: %u.\\n\", HeaderSize); dProtocolType= NDIS_GET_PACKET_PROTOCOL_TYPE(MyPacket); switch(dProtocolType) { case NDIS_PROTOCOL_ID_DEFAULT: NdisInitUnicodeString(&sProtocol, L\"DEFAULT\"); break; case NDIS_PROTOCOL_ID_TCP_IP : NdisInitUnicodeString(&sProtocol, L\"TCP/IP\"); break; case NDIS_PROTOCOL_ID_IPX : NdisInitUnicodeString(&sProtocol, L\"IPX\"); break; case NDIS_PROTOCOL_ID_NBF : NdisInitUnicodeString(&sProtocol, L\"NBF\"); break; default: NdisInitUnicodeString(&sProtocol, L\"UNKNOWN\"); break; } DbgPrint(\" Protocol: %ws.\\n\", sProtocol.Buffer); //protocol type if(!BufferCount) { // Output debug information DbgPrint(\" Debug Report @ MPSend: BufferCount of Packet is 0,\\n\"); DbgPrint(\"and MPSend will return NDIS_STATUS_FAILURE\\n\"); return (NDIS_STATUS_FAILURE); } while( CurrentBuffer != NULL) { NdisQueryBuffer(CurrentBuffer, &CurrentBufferVA, &CurrentBufferLength); if(!CurrentBufferVA) { // // System is running low on memory resources. // So fail the read. // //status = STATUS_INSUFFICIENT_RESOURCES; //Exit; break; } else { for(k=0;k<CurrentBufferLength/2;k++) DbgPrint(\" %02x\",((PUSHORT)CurrentBuffer)[k]); if(((k+1)%10)==0) DbgPrint(\"\\n\");//print CURRENTBUFFER... } DbgPrint(\"\\n\"); NdisGetNextBuffer(CurrentBuffer, &NextBuffer); CurrentBuffer = NextBuffer; } DbgPrint(\"\\n\"); NdisSend(&Status, pAdapt->BindingHandle, MyPacket);//发送 ......//返回 } 程序编译通过,但是输出的包信息却是一堆乱码。 00000000 0.00000000 *** XPASSHTRU.SYS ***==>Passthru Miniport MPSendPackets 00000001 0.00002095 *** XPASSHTRU.SYS ***==>Passthru Miniport MPSendOnePacke t. 00000002 0.00004023 PhysicalBufferCount: 4. 00000003 0.00004945 BufferCount: 4. 00000004 0.00005867 TotalPacketLenth: 74. 00000005 0.00006761 HeaderSize: 0. 00000006 0.00008185 Protocol: TCP/IP. 00000007 0.00013186 ea08 fcf1 20 0c 00 00 08 00000008 0.00020030 2ca8 fcef 20 0c 00 00 268 fcf1 00 fcf1 00000009 0.00022964 d508 fcf3 20 0c 00000010 0.00033663 00 00 20 0c 00 00 b48 fcef 0 0 fcef 20 00 b48 00 12a1 00 00000012 0.00038441 *** XPASSHTRU.SYS ***==> Passthru Protocol PtSendComplet e 不能分析出有用信息。 并且输出Head长度为0,完全不能理解。 我甚至将这段代码对没有拷贝前的Packet进行分析, 同样出现不能理解的结果。怀疑代码有问题。 恳请各位大虾能帮忙看看哪里有毛病。谢谢! -- |
|
最新喜欢:TickKi... |
沙发#
发布于:2003-04-08 20:15
DbgPrint(\" %02x\",((PUSHORT)CurrentBuffer)[k]);
是否应该改为 DbgPrint(\" %02x\",((PUSHORT)CurrentBufferVA)[k]); 看一下文档,我有点忘了。 |
|
板凳#
发布于:2003-04-09 09:08
多谢!问题已经解决,还是自己太粗心了。。希望以后还能得到您的帮助!
|
|