From 9eeae0e8264937c033f2e701eab9b28d72ab5918 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 21 Oct 2009 02:16:03 +0000 Subject: [PATCH] - Fix an issue that broke ARP replies because we compared the source address with our address instead of the destination address with our address - 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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/reactos/lib/drivers/ip/network/arp.c b/reactos/lib/drivers/ip/network/arp.c index 3a956120bbf..08549c2fc07 100644 --- a/reactos/lib/drivers/ip/network/arp.c +++ b/reactos/lib/drivers/ip/network/arp.c @@ -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