阅读:1693回复:2
在ptreceive中数据包的转发问题!
我在ptreceive中把得到的packet数据包,进行重新封包后,利用ndissend函数进行转发,但是在ptsendcomplete中的ndismsendcomplete函数会发生错误,softice中显示为“break due to page fault(0eh) fault=0000”。
我的理解是:ndismsendcomplete函数是通知协议层去释放数据包,而我自己构造的数据包不在协议层形成,应而发生错误,不知道这样理解对不对,请高手指出,能不能给我介绍个解决的办法,先谢谢了!! |
|
最新喜欢:chili |
沙发#
发布于:2003-11-18 08:56
看看前面的帖子吧。 关于这个问题, 讨论了好多了。 也讨论的很清楚了。
ndissend 返回 是 pendding 的时候, 会进入 sendcomplete 中。 你如果 没有 对 mpsend 中的数据包 进行 过 重装。 那在 complete 中 所 释放的包, 有可能是你 自己在 ptrecece 中调用了 ndissend 所 重组的包, 也有可能是 windows发下来调用了 mpsend 所 形成的包。 所以你要 加以 区分的释放。 不然就是内存出错。 好了。 别忘了, 给分。 |
|
板凳#
发布于:2003-11-19 10:28
我找到的资料是对mpsend中要发送的数据包进行重新封包以后,继续发送,而我现在是要在ptreceive中,对港接收到的数据包,直接转发,好像在处理上还有些差别,一下是我在passthru中加的代码:
我在ptreceive中加入了如下代码: Status=NdisAllocateMemory(&pPacketContent,2000,0,HighestAcceptableMax); if (Status!=NDIS_STATUS_SUCCESS) { DbgPrint(\"ptreceive: ndisallocatememory failed\\n\"); return NDIS_STATUS_NOT_ACCEPTED; } if (pPacketContent==NULL) { DbgPrint(\"ptreceive: pPacketContent==NULL\\n\"); return NDIS_STATUS_NOT_ACCEPTED; } RtlZeroMemory(pPacketContent,2000); RtlCopyMemory(pPacketContent,HeaderBuffer,HeaderBufferSize); RtlCopyMemory(pPacketContent+HeaderBufferSize,LookAheadBuffer,LookAheadBufferSize); PacketLen=HeaderBufferSize+LookAheadBufferSize; DbgPrint(\"UDP Packet is filtered successfully\\n\"); //pAdapt = pAdapt->pSecondaryAdapt; //重构MAC地址 ((CHAR *)pPacketContent)[6] = 0x08; ((CHAR *)pPacketContent)[7] = 0x00; ((CHAR *)pPacketContent)[8] = 0x39; ((CHAR *)pPacketContent)[9] = 0x02; ((CHAR *)pPacketContent)[10] = 0x1c; ((CHAR *)pPacketContent)[11] = 0x69; //交换发送端和接受端的IP地址 for (iExchange=26;iExchange<=29;iExchange++) { ExchangeContent = ((CHAR *)pPacketContent)[iExchange]; ((CHAR *)pPacketContent)[iExchange] = ((CHAR )pPacketContent)[iExchange+4]; ((CHAR *)pPacketContent)[iExchange+4] = ExchangeContent; } //交换发送端和接受端的端口号 for (iExchange=34;iExchange<=35;iExchange++) { ExchangeContent = ((CHAR *)pPacketContent)[iExchange]; ((CHAR *)pPacketContent)[iExchange] = ((CHAR *)pPacketContent)[iExchange+2]; ((CHAR *)pPacketContent)[iExchange+2] = ExchangeContent; } MyPacket1=(PNDIS_PACKET)pPacketContent; NdisAllocatePacket(&Status,&MyPacket,pAdapt->SendPacketPoolHandle); if (Status==NDIS_STATUS_SUCCESS) { NdisAllocateBuffer(&Status,&FirstBuffer,SendHandle,&MyPacket1,42); NdisChainBufferAtFront(MyPacket,FirstBuffer); Rsvd=(PRSVD)(MyPacket->ProtocolReserved); Rsvd->OriginalPkt=MyPacket1; MyPacket->Private.Head->Next=NULL; MyPacket->Private.Tail->Next=NULL; NdisSetPacketFlags(MyPacket,NDIS_FLAGS_DONT_LOOPBACK); Rsvd = (PRSVD)(MyPacket->ProtocolReserved); Rsvd->OriginalPkt = MyPacket1; MyPacket->Private.Flags = MyPacket1->Private.Flags; MyPacket->Private.Head = MyPacket1->Private.Head; MyPacket->Private.Tail = MyPacket1->Private.Tail; NdisSetPacketFlags(MyPacket,NDIS_FLAGS_DONT_LOOPBACK); NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket), NDIS_OOB_DATA_FROM_PACKET(MyPacket1), sizeof(NDIS_PACKET_OOB_DATA)); NdisIMCopySendPerPacketInfo(MyPacket,MyPacket1); NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket1, &MediaSpecificInfo, &MediaSpecificInfoSize); if (MediaSpecificInfo || MediaSpecificInfoSize) { NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, MediaSpecificInfo, MediaSpecificInfoSize); } if_need_free=1; NdisSend(&Status,pAdapt->BindingHandle,MyPacket); if (Status!=NDIS_STATUS_PENDING) { DbgPrint(\"Status!=NDIS_STATUS_PENDING\"); if (if_need_free==1) { NdisUnchainBufferAtFront(MyPacket,&FirstBuffer); NdisQueryBufferSafe(FirstBuffer,&virtualaddress,&virtuallength,32); NdisFreeBuffer(FirstBuffer); if_need_free=2; } NdisIMCopySendCompletePerPacketInfo(MyPacket1,MyPacket); NdisFreePacket(MyPacket); } 我在ptsendcomplete中加入了如下代码: if(if_need_free==1) { NdisUnchainBufferAtFront(Packet,&PacketBuffer); NdisQueryBufferSafe(PacketBuffer,&virtualaddress,&virtuallength,32); NdisFreeBuffer(PacketBuffer); NdisDprFreePacket(Packet); if_need_free=2; } |
|