- Fix an issue that broke ARP replies because we compared the source address with...
authorCameron Gutman <aicommander@gmail.com>
Wed, 21 Oct 2009 02:16:03 +0000 (02:16 +0000)
committerCameron Gutman <aicommander@gmail.com>
Wed, 21 Oct 2009 02:16:03 +0000 (02:16 +0000)
 - What ended up happening was the router saved our gratuitous ARP hw address which allowed communication until it sent an ARP request which we would discard instead of replying to it, so the network connection would drop unexpectedly. "ipconfig /renew" was a temporary fix because it caused another gratuitous ARP packet to be sent and readded our hw address to the router's cache
 - This should be the last major issue with running in bridged mode

svn path=/trunk/; revision=43663

reactos/lib/drivers/ip/network/arp.c

index 3a95612..08549c2 100644 (file)
@@ -183,9 +183,11 @@ VOID ARPReceive(
  */
 {
     PARP_HEADER Header;
-    IP_ADDRESS Address;
+    IP_ADDRESS SrcAddress;
+    IP_ADDRESS DstAddress;
     PVOID SenderHWAddress;
     PVOID SenderProtoAddress;
+    PVOID TargetProtoAddress;
     PNEIGHBOR_CACHE_ENTRY NCE;
     PNDIS_PACKET NdisPacket;
     PIP_INTERFACE Interface = (PIP_INTERFACE)Context;
@@ -208,12 +210,14 @@ VOID ARPReceive(
 
     SenderHWAddress    = (PVOID)((ULONG_PTR)Header + sizeof(ARP_HEADER));
     SenderProtoAddress = (PVOID)((ULONG_PTR)SenderHWAddress + Header->HWAddrLen);
+    TargetProtoAddress = (PVOID)((ULONG_PTR)SenderProtoAddress + Header->ProtoAddrLen + Header->HWAddrLen);
 
     /* Check if we know the sender */
 
-    AddrInitIPv4(&Address, *((PULONG)SenderProtoAddress));
+    AddrInitIPv4(&SrcAddress, *((PULONG)SenderProtoAddress));
+    AddrInitIPv4(&DstAddress, *((PULONG)TargetProtoAddress));
 
-    NCE = NBLocateNeighbor(&Address);
+    NCE = NBLocateNeighbor(&SrcAddress);
     if (NCE) {
         /* We know the sender. Update the hardware address
            and state in our neighbor address cache */
@@ -222,12 +226,12 @@ VOID ARPReceive(
         /* The packet had our protocol address as target. The sender
            may want to communicate with us soon, so add his address
            to our address cache */
-        NCE = NBAddNeighbor(Interface, &Address, SenderHWAddress,
+        NCE = NBAddNeighbor(Interface, &SrcAddress, SenderHWAddress,
             Header->HWAddrLen, 0, ARP_TIMEOUT);
     }
 
     if (Header->Opcode != ARP_OPCODE_REQUEST ||
-        !AddrIsEqual(&Address, &Interface->Unicast))
+        !AddrIsEqual(&DstAddress, &Interface->Unicast))
         return;
 
     /* This is a request for our address. Swap the addresses and