阅读:1437回复:1
当PASSTHRU的Packet返回NULL时,应该怎么取得该Packet?
Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext);
以前的帖子讨论过,好象是因为网卡类型不同 有可能导致Packet 返回NULL 胡大侠曾说过,可以使用NdisTransferData 取得Packet 请看下面的代码 在win2k ddk 下编译可以通过,但是安装是则蓝屏 if(Packet == NULL){ DebugPrint((\"ReceiveIndicate\\n\")); open= (POPEN_INSTANCE)ProtocolBindingContext; if (HeaderBufferSize > ETHERNET_HEADER_LENGTH) { return NDIS_STATUS_SUCCESS; } packetListEntry=ExInterlockedRemoveHeadList( &open->RcvList, &open->RcvQSpinLock ); if (packetListEntry == NULL) { DebugPrint((\"No pending read, dropping packets\\n\")); return NDIS_STATUS_NOT_ACCEPTED; } reserved=CONTAINING_RECORD(packetListEntry,PACKET_RESERVED,ListElement); Packet=CONTAINING_RECORD(reserved,NDIS_PACKET,ProtocolReserved); irp=RESERVED(Packet)->Irp; irpSp = IoGetCurrentIrpStackLocation(irp); IoSetCancelRoutine(irp, NULL); bufferLength=irpSp->Parameters.Read.Length-ETHERNET_HEADER_LENGTH; sizeToTransfer = (PacketSize < bufferLength) ? PacketSize : bufferLength; NdisMoveMappedMemory( MmGetSystemAddressForMdlSafe(irp->MdlAddress, NormalPagePriority), HeaderBuffer, HeaderBufferSize ); pMdl=IoAllocateMdl( MmGetMdlVirtualAddress(irp->MdlAddress), MmGetMdlByteCount(irp->MdlAddress), FALSE, FALSE, NULL ); if (pMdl == NULL) { DebugPrint((\"Packet: Read-Failed to allocate Mdl\\n\")); Status = NDIS_STATUS_RESOURCES; return NDIS_STATUS_SUCCESS; } IoBuildPartialMdl( irp->MdlAddress, pMdl, ((PUCHAR)MmGetMdlVirtualAddress(irp->MdlAddress))+ETHERNET_HEADER_LENGTH, 0 ); pMdl->Next=NULL; RESERVED(Packet)->pMdl=pMdl; NdisChainBufferAtFront(Packet,pMdl); NdisTransferData( &Status, open->AdapterHandle, MacReceiveContext, 0, sizeToTransfer, Packet, &bytesTransfered); } 该代码放在 Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext); 后面 请高手指点,问题出在哪里? 谢谢! |
|
沙发#
发布于:2002-01-19 08:35
没有人理我呀。。。
。。。。 |
|