阅读:2692回复:3
在PtReceive中解迷出错, 请大侠们帮忙!啊!
我在MPSend中把数据加密后发送出去,在接受端的PtReceive中已经成功接受到加密了的数据.
PtReceive的过程是 1->拷贝Packet 数据到MyBuffer中 2->解迷MyBuffer中的数据(可以确认的 是我已经正确的收到应该收到的加密数据AAA,也解迷成功,数据变成了BBB) 3->重新计算校验和 4->NdisDprAllocatePacket 5->NdisAllocateBuffer 6->NdisChainBufferAtBack 7->拷贝原始Packet信息到MyPacket中 8->NdisMIndicateReceivePacket 9->释放申请空间 最后的结果是,应用程序收到了未解迷的数据,即是收到了AAA,按理说应该收到的是BBB,请问哪儿没有处理好啊? 奉献一段代码,以表感谢!! void ICMPCheckSum(UC *IPBuf) { ULONG sum=0; UC *ICMPBuf,*ICMPBuf2; UI ICMPLen,IPLen; IPLen=(IPBuf[0]&0X0F)*4; ICMPBuf=IPBuf+IPLen; ICMPBuf2=ICMPBuf; ICMPLen=IPBuf[2]; ICMPLen=((ICMPLen<<8)&0xFF00)+IPBuf[3]-IPLen; ICMPBuf[2]=0;ICMPBuf[3]=0; //Clear CheckSum while(ICMPLen>1) { sum+=*((UI *)ICMPBuf); ICMPBuf+=2;ICMPLen-=2; } if(ICMPLen) sum+=*ICMPBuf; sum=(sum&0xffff)+((sum>>16)&0xFFFF); sum=(sum&0xffff)+((sum>>16)&0xFFFF); sum=~sum; ICMPBuf2[2]=(UCHAR)sum&0xFF; ICMPBuf2[3]=(UCHAR)(sum>>8)&0xFF; } |
|
沙发#
发布于:2007-08-16 13:02
第7部的时候,你复制了哪些信息?不要使用
MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; 这会把原来的数据包内容也传给上面。 |
|
板凳#
发布于:2007-08-16 20:23
我的程序如下,问题就是还是 不能够把我解密了的数据发到上层应用程序啊..请问哪儿有问题呢?
ASSERT(Packet); if (Packet==0) return NDIS_STATUS_SUCCESS; NdisQueryPacket(Packet, NULL, NULL,NULL, &PacketLen); Status=NdisAllocateMemoryWithTag(&PacketMemory,PacketLen,TAG); if(NDIS_STATUS_SUCCESS!=Status) return Status; CopyPacketToBuffer(PacketMemory,Packet,0,PacketLen); ret = (UCHAR)DecrptBuffer((char*)(((char*)PacketMemory)+54), (PacketLen-54)) ; CalculateIPChecksum( (PVOID)((char*)PacketMemory+MAC_HEADER_LEN),ret); CalculateTcpChecksum((PVOID)((char*)PacketMemory+MAC_HEADER_LEN), ret); /*ASSERT(FillLen<=16);*/ //当调用者运行在IRQL DISPATCH_LEVEL下,分配和初始化一个包描述符 NdisDprAllocatePacket(&Status,&MyPacket,pAdapt->RecvPacketPoolHandle); if(Status != NDIS_STATUS_SUCCESS) { NdisFreeMemory(PacketMemory,PacketLen,0); return NDIS_STATUS_RESOURCES; } NdisAllocateBuffer(&Status,&PacketBuffer,pAdapt->RecvPacketPoolHandle, PacketMemory,PacketLen); if (Status!=NDIS_STATUS_SUCCESS) { NdisDprFreePacket(MyPacket); NdisFreeMemory(PacketMemory,PacketLen,0); return Status; } RecvRsvd = (PRECV_RSVD)(MyPacket->MiniportReserved); RecvRsvd->OriginalPkt = MyPacket; NdisChainBufferAtFront(MyPacket,PacketBuffer); NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket),NDIS_OOB_DATA_FROM_PACKET(Packet), sizeof(NDIS_PACKET_OOB_DATA)); NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); // Set Packet Flags NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES); NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize); ASSERT(pAdapt->MiniportHandle && MyPacket); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); ASSERT(NDIS_GET_PACKET_STATUS(MyPacket) == NDIS_STATUS_RESOURCES); |
|
地板#
发布于:2011-05-29 04:18
我现在也出现这个问题,不知道楼主有没有解决,能不能讲明解决的方法!万分感激!
|
|