- Copy correct data to our lookahead buffer. It was previously missing the media...
authorCameron Gutman <aicommander@gmail.com>
Tue, 20 Oct 2009 02:30:05 +0000 (02:30 +0000)
committerCameron Gutman <aicommander@gmail.com>
Tue, 20 Oct 2009 02:30:05 +0000 (02:30 +0000)
 - Fix the check for loopback indication. It was previously checking whether the source and destination packets were the same which makes no sense at all
 - Correct the offset and length passed to NdisCopyFromPacketToPacket. The caller's values of these don't include the header size but the packet does
 - Fixes a crash when running "ping 10.0.2.15 -l 1800" on vbox with NAT

svn path=/trunk/; revision=43635

reactos/drivers/network/ndis/ndis/protocol.c

index 4703e5e..dd56c40 100644 (file)
@@ -279,7 +279,8 @@ ProIndicatePacket(
   NDIS_DbgPrint(MAX_TRACE, ("acquiring miniport block lock\n"));
   KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
     {
-      BufferedLength = CopyPacketToBuffer(LookaheadBuffer, Packet, 0, Adapter->NdisMiniportBlock.CurrentLookahead);
+      BufferedLength = CopyPacketToBuffer(LookaheadBuffer, Packet, 0, Adapter->NdisMiniportBlock.CurrentLookahead +
+                                                                      Adapter->MediumHeaderSize);
       Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] = Packet;
     }
   KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
@@ -298,6 +299,12 @@ ProIndicatePacket(
 
   ExFreePool(LookaheadBuffer);
 
+  KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+    {
+      Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()] = NULL;
+    }
+  KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+
   return NDIS_STATUS_SUCCESS;
 }
 
@@ -649,12 +656,12 @@ ProTransferData(
     /* FIXME: Interrupts must be disabled for adapter */
     /* XXX sd - why is that true? */
 
-    if (Packet == Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()]) {
+    if (Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()]) {
        NDIS_DbgPrint(MAX_TRACE, ("LoopPacket\n"));
         /* NDIS is responsible for looping this packet */
         NdisCopyFromPacketToPacket(Packet,
-                                   ByteOffset,
-                                   BytesToTransfer,
+                                   ByteOffset + Adapter->MediumHeaderSize,
+                                   BytesToTransfer + Adapter->MediumHeaderSize,
                                    Adapter->NdisMiniportBlock.IndicatedPacket[KeGetCurrentProcessorNumber()],
                                    0,
                                    BytesTransferred);