阅读:3461回复:8
我修改了DDk的passthru中 PtReceivePacket Packet包,好象没有什么用呀
测试环境:
服务端:XP ,NC监听80 另一端:XP,telnet IP 80 我修改了DDk的passthru中 PtReceivePacket Packet包,好象还是能够互连 问题有二: 一、我调试DDK的passthru例子,会进PtReceivePacket Packet函数,而且会进#ifdef NDIS51这段代码(我的环境是XP),似乎网上所有能找的例子在这一块都没有修改呀 二、于是我就硬着头皮进行修改,代码如下: #ifdef NDIS51 // // Check if we can reuse the same packet for indicating up. // See also: PtReceive(). // (VOID)NdisIMGetCurrentPacketStack(Packet, &Remaining); if (Remaining) { //分配pPacketContentrcv,接收 Status=NdisAllocateMemory(&pPacketContentrcv,BUFFER_SIZE,0,HighestAcceptableMax); if(Status!=NDIS_STATUS_SUCCESS) { DBGPRINT(("PtReceivePacket:NdisAllocateMemory pPacketContentrcv Failed\n")); return(NDIS_STATUS_NOT_ACCEPTED); } if(pPacketContentrcv==NULL) { DBGPRINT(("PtReceivePacket:pPacketContentrcv==NULL\n")); return(NDIS_STATUS_NOT_ACCEPTED); } NdisZeroMemory(pPacketContentrcv,BUFFER_SIZE); //packet to buffer (pPacketContentrcv) NdisQueryPacket(Packet, NULL, NULL, NULL, &PacketLen); CopyPacketToBuffer( pPacketContentrcv,Packet,0,PacketLen,1); DBGPRINT(("PtReceivePacket ptDealCapsulate 1111\n")); Status = ptDealCapsulate(ProtocolBindingContext,pPacketContentrcv,PacketLen); if(Status!=NDIS_STATUS_SUCCESS) { NdisFreeMemory(pPacketContentrcv,BUFFER_SIZE,0); return(NDIS_STATUS_NOT_ACCEPTED); } // // Get a packet off the pool and indicate that up // NdisDprAllocatePacket(&Status, &MyPacket, pAdapt->RecvPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { PRECV_RSVD RecvRsvd; NdisAllocateBuffer(&Status,&pPacketBuffer,pAdapt->RcvBufferPoolHandle,pPacketContentrcv,PacketLen); if (Status!=NDIS_STATUS_SUCCESS) { NdisFreeMemory(pPacketContentrcv,BUFFER_SIZE,0); NdisDprFreePacket(MyPacket); return(NDIS_STATUS_NOT_ACCEPTED); } NdisChainBufferAtFront(MyPacket,pPacketBuffer); RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved); RecvRsvd->OriginalPkt = Packet; MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; // // Get the original packet (it could be the same packet as the one // received or a different one based on the number of layered miniports // below) and set it on the indicated packet so the OOB data is visible // correctly to protocols above us. // NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); // // Set Packet Flags // NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); Status = NDIS_GET_PACKET_STATUS(Packet); NDIS_SET_PACKET_STATUS(MyPacket, Status); NDIS_SET_PACKET_HEADER_SIZE(MyPacket, NDIS_GET_PACKET_HEADER_SIZE(Packet)); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); if(NDIS_GET_PACKET_STATUS(MyPacket)!=NDIS_STATUS_PENDING)//如状态为PENDING,则调用MPReturnPacket { DBGPRINT(("In PtReceive And Free Memory\n")); NdisFreeBuffer(pPacketBuffer); NdisFreeMemory(pPacketContentrcv,BUFFER_SIZE,0); if (MyPacket!=NULL) { DBGPRINT(("1MyPacket MyPacket MyPacketMyPacketMyPacketMyPacketMyPacketMyPacketMyPacket\n")); //NdisDprFreePacket(MyPacket); //MyPacket=NULL; } } // // Check if we had indicated up the packet with NDIS_STATUS_RESOURCES // NOTE -- do not use NDIS_GET_PACKET_STATUS(MyPacket) for this since // it might have changed! Use the value saved in the local variable. // if (Status == NDIS_STATUS_RESOURCES) { // // Our ReturnPackets handler will not be called for this packet. // We should reclaim it right here. // if (MyPacket!=NULL) { DBGPRINT(("2MyPacket MyPacket MyPacketMyPacketMyPacketMyPacketMyPacketMyPacketMyPacket\n")); NdisDprFreePacket(MyPacket); //MyPacket=NULL; } } return((Status != NDIS_STATUS_RESOURCES) ? 1 : 0); } else { // // We are out of packets. Silently drop it. // NdisFreeBuffer(pPacketBuffer); return(0); } } #endif // NDIS51 我在函数ptDealCapsulate中对收到的BUFFER进行修改,比如将TCP的端口换掉,甚至将IP地址全部换掉,好象还是能够通信,怪哉,各位走过路过看过,留下意见呀,本人第一次学passthru,请指教 |
|
沙发#
发布于:2008-07-01 15:33
路过
|
|
板凳#
发布于:2008-07-02 10:06
一般程序走得比较多的应该是ptReceive吧,所以你怎么改上面的函数,其实都没有影响
|
|
地板#
发布于:2008-07-02 10:48
Re:我修改了DDk的passthru中 PtReceivePacket Packet包,
期待答案! |
|
地下室#
发布于:2008-07-02 12:08
不要好像。。。,要确定.。。。,所以:
1 打印修改前的数据 , 打印修改后的数据 对比 2 抓发送出去的数据,和修改前与修改后数据对比 3 在接收端抓报,和修改前与修改后数据对比 然后。。。,应该能够找出问题了 |
|
|
5楼#
发布于:2008-07-02 16:51
问题已经解决:
|
|
6楼#
发布于:2008-07-02 17:02
答案:
修改代码 RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved); RecvRsvd->OriginalPkt = Packet; MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; 为: RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved); RecvRsvd->OriginalPkt = Packet; MyPacket->Private.Head = NULL; MyPacket->Private.Tail = NULL; 就可以实现我所需要的功能。 |
|
7楼#
发布于:2008-07-08 15:52
最近很上驱动网,今天才看到你发的消息,
|
|
|
8楼#
发布于:2010-02-04 00:25
回 6楼(billwangyj) 的帖子
内存泄露 |
|