阅读:1320回复:2
请指点一下,在 MPSend 中为什么发不了长数据包呢
请指点一下,在 MPSend 中为什么发不了长数据包呢
我修改了MPSend 和PtSendComplete 函数,如果TCP包的数据长度小于等于703个字节的话可以发出去,再长就发不出去了, 请帮忙看一下为什么,下面是源码,红色代码和黑体代码的是我在DDK自带的代码的基础上添加的,因为有一部分显示不出来红色,所以改成了黑体。 NDIS_STATUS MPSend( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags ) { PADAPT pAdapt = (PADAPT)MiniportAdapterContext; NDIS_STATUS Status; PNDIS_PACKET MyPacket; PRSVD Rsvd; PVOID MediaSpecificInfo = NULL; ULONG MediaSpecificInfoSize = 0; //---added by white young start---------------------------------------------------- // define variables NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1,-1); PUCHAR pPacketContent; PNDIS_BUFFER pBakBuffer; PUCHAR pBuf; UINT BufLength; MDL * pNext; UINT i; int PacketSize = 0, ipTotalLength=0, ipHeaderLength=0, tcpHeaderLen=0, tcpLen=0; //---added by white young end------------------------------------------------------- // // According to our LBFO design, all sends will be performed on the secondary miniport // However, the must be completed on the primary's miniport handle // ASSERT (pAdapt->pSecondaryAdapt); pAdapt = pAdapt->pSecondaryAdapt; if (IsIMDeviceStateOn (pAdapt) == FALSE) { return NDIS_STATUS_FAILURE; } NdisAllocatePacket(&Status, &MyPacket, pAdapt->SendPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { PNDIS_PACKET_EXTENSION Old, New; //---added by white young start---------------------------------------------------- NdisQueryPacket(Packet,NULL,NULL,NULL,&PacketSize); Status = NdisAllocateMemory((PVOID*)&pPacketContent,2000, 0,HighestAcceptableMax); if (Status!=NDIS_STATUS_SUCCESS ) { NdisFreePacket(MyPacket); DBGPRINT((" NdisAllocateMemory pPacketContent failed n")); return Status; } NdisZeroMemory (pPacketContent, 2000); NdisQueryBufferSafe(Packet->Private.Head, &pBuf, &BufLength, 32 ); NdisMoveMemory(pPacketContent, pBuf, BufLength); i = BufLength; pNext = Packet->Private.Head; for(;;) { if(pNext == Packet->Private.Tail) break; pNext = pNext->Next; //指针后移 if(pNext == NULL) break; NdisQueryBufferSafe(pNext,&pBuf,&BufLength,32); NdisMoveMemory(pPacketContent+i,pBuf,BufLength); i+=BufLength; } if(pPacketContent[12] == 8 && pPacketContent[13] == 0 && pPacketContent[23] == 6) // Deal TCP packet { ipTotalLength = (*(pPacketContent+16*sizeof(UCHAR))<<8) + *(pPacketContent+17*sizeof(UCHAR)); ipHeaderLength = ((USHORT)pPacketContent[14] - 64) * 32 / 8 ; tcpHeaderLen = ((USHORT)pPacketContent[ipHeaderLength + 26]>>4) * 32 / 8 ; tcpLen = ipTotalLength - ipHeaderLength; if((tcpLen - tcpHeaderLen) > 0) { DBGPRINT((" Here should be deal send packet data n")); //DEAL_OUT_PACKET(pPacketContent); } } NdisAllocateBuffer(&Status,&pBakBuffer,pAdapt->SendBufferPoolHandle,pPacketContent,PacketSize); if (Status != NDIS_STATUS_SUCCESS) { NdisFreePacket(MyPacket); NdisFreeMemory(pPacketContent, 2000, 0); DBGPRINT((" NdisAllocateBuffer pBakBuffer failed n")); return (Status); } //---added by white young end------------------------------------------------------- Rsvd = (PRSVD)(MyPacket->ProtocolReserved); Rsvd->OriginalPkt = Packet; MyPacket->Private.Flags = Flags; MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; NdisSetPacketFlags(MyPacket, NDIS_FLAGS_DONT_LOOPBACK); // // Copy the OOB Offset from the original packet to the new // packet. // NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket), NDIS_OOB_DATA_FROM_PACKET(Packet), sizeof(NDIS_PACKET_OOB_DATA)); // // Copy the per packet info into the new packet // This includes ClassificationHandle, etc. // Make sure other stuff is not copied !!! // NdisIMCopySendPerPacketInfo(MyPacket, Packet); // // Copy the Media specific information // NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet, &MediaSpecificInfo, &MediaSpecificInfoSize); if (MediaSpecificInfo || MediaSpecificInfoSize) { NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, MediaSpecificInfo, MediaSpecificInfoSize); } //---added by white young start---------------------------------------------------- NdisChainBufferAtFront(MyPacket,pBakBuffer); //---added by white young end------------------------------------------------------- NdisSend(&Status,pAdapt->BindingHandle,MyPacket); DbgPrint("MPSend : NdisSend n"); if (Status != NDIS_STATUS_PENDING) { NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket); DbgPrint("MPSend : NdisIMCopySendCompletePerPacketInfo n"); //---added by white young start---------------------------------------------------- NdisUnchainBufferAtFront(Packet,&pBakBuffer); NdisQueryBufferSafe(pBakBuffer,&pPacketContent,&BufLength,32); NdisFreeBuffer(pBakBuffer); NdisFreeMemory(pPacketContent,BufLength,0); //---added by white young end------------------------------------------------------- NdisFreePacket(MyPacket); } } else { // // We are out of packets. Silently drop it. Alternatively we can deal with it: // - By keeping separate send and receive pools // - Dynamically allocate more pools as needed and free them when not needed // } return(Status); } VOID PtSendComplete( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status ) /*++ Routine Description: Interesting case: We wish to send all sends down the secondary NIC. But when we indicate to the protocol above, we need to revert back to the original miniport that Protocol wished to use for the Send Arguments: Return Value: --*/ { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PNDIS_PACKET Pkt; PRSVD Rsvd; //---added by white young start---------------------------------------------------- // define variables PNDIS_BUFFER pBakBuffer; PUCHAR pPacketContent; UINT BufLength; //---added by white young end------------------------------------------------------- DBGPRINT(("==> PtSendComplete : NdisMSendCompleten")); // // Returning the Send on the Primary, will point to itself if there is no bundle // pAdapt = pAdapt->pPrimaryAdapt; Rsvd =(PRSVD)(Packet->ProtocolReserved); Pkt = Rsvd->OriginalPkt; NdisIMCopySendCompletePerPacketInfo (Pkt, Packet); //* //---added by white young start---------------------------------------------------- NdisUnchainBufferAtFront(Packet,&pBakBuffer); NdisQueryBufferSafe(pBakBuffer,&pPacketContent,&BufLength,32); NdisFreeBuffer(pBakBuffer); NdisFreeMemory(pPacketContent,BufLength,0); //---added by white young end------------------------------------------------------- //*/ NdisDprFreePacket(Packet); NdisMSendComplete(pAdapt->MiniportHandle, Pkt, Status); DBGPRINT(("<== PtSendComplete : NdisMSendCompleten")); } [编辑 - 6/16/04 by whiteyoung] [编辑 - 6/17/04 by whiteyoung] |
|
最新喜欢:![]() |
沙发#
发布于:2004-06-18 21:35
该贴已经没用了,请版主随手删掉吧
|
|
板凳#
发布于:2004-09-01 14:55
这段代码的问题找到了?
我正在我的机器上调试。 |
|