阅读:1163回复:1
中间层发送问题:
我在中间层发送,自己从一块buffer构建一个Packet,然后用NDISSend发送,但,每次在NDISSend执行时都会有0x000000d1的错误,
为什么? 请高手指教,代码如下: long TransferBuffer( IN NDIS_HANDLE ProtocolBindingContext, IN PVOID pBuffer, IN UINT PacketSize ) { int i ; PNDIS_PACKET Packet; NDIS_STATUS Status = NDIS_STATUS_SUCCESS; PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PNDIS_BUFFER pNdisBuffer; PETHHDR pEthHdr = (PETHHDR)pBuffer; PIPHDR pIPHdr = (PIPHDR)(&((char *)pBuffer)[sizeof(ETHHDR)]); PUDPHDR pUdpHdr = (PUDPHDR)(&((char*)pIPHdr)[sizeof(IPHDR)]); PTRANSHDR pTransHdr = (PTRANSHDR)(&((char*)pUdpHdr)[sizeof(UDPHDR)]); // pAdapt = pAdapt->pSecondaryAdapt; pIPHdr->sourceIP = pIPHdr->destIP; pUdpHdr->sourcePort = pUdpHdr->destPort; (PTRANSIPINFO)(&((char*)pTransHdr)[sizeof(TRANSHDR)+i*sizeof(TRANSIPINFO)]); pIPHdr->destIP = pIPHdr->sourceIP; pUdpHdr->destPort = pUdpHdr->sourcePort; NdisDprAllocatePacket(&Status,&Packet,pAdapt->SendPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { NdisAllocateBuffer( &Status, &pNdisBuffer, pAdapt->SendPacketPoolHandle, Packet->ProtocolReserved, PacketSize); NdisChainBufferAtFront( Packet, pNdisBuffer); NdisMoveMemory( pNdisBuffer, pBuffer, PacketSize); Packet->Private.TotalLength = PacketSize; Packet->Private.Flags = 0; Packet->Private.ValidCounts = 0; Packet->Private.NdisPacketOobOffset = 0; Packet->Private.NdisPacketFlags = NDIS_FLAGS_DIRECTED_PACKET; NdisSend(&Status,pAdapt->SendPacketPoolHandle,Packet); if(Status != NDIS_STATUS_PENDING) { NdisFreePacket(Packet); NdisFreeMemory(pNdisBuffer, PacketSize, 0); } } return 0; } |
|
沙发#
发布于:2003-11-22 00:29
CSDN的也是你问的吗?
丢了一天的帖子。 1、NdisSend(&Status,pAdapt->SendPacketPoolHandle,Packet); 是pAdapt->BindingHandle 2、NdisAllocateBuffer( &Status, &pNdisBuffer, pAdapt->SendPacketPoolHandle, Packet->ProtocolReserved, PacketSize); 如果你是要把pBuffer发送出去的话,改成 NdisAllocateBuffer( &Status, &pNdisBuffer, // pAdapt->SendPacketPoolHandle,改成一个Buffer Pool Handle,而不是Packet Pool Handle pBuffer, PacketSize); 3、NdisFreeMemory(pNdisBuffer, PacketSize, 0); pNdisBuffer是从allocate buffer而来,不是allocate memory!! 在ptsendcomplete还要有处理。 |
|