Author: cgutman Date: Wed Jul 1 01:14:21 2009 New Revision: 41720
URL: http://svn.reactos.org/svn/reactos?rev=41720&view=rev Log: - Put the correct source address in Raw IP and UDP packets - Remove (now unused) IPGetDefaultAddress which just broke things - Fixes responses from different IP addresses when trying to ping the loopback adapter - See issue #4573 for more details
Modified: trunk/reactos/drivers/network/tcpip/include/address.h trunk/reactos/lib/drivers/ip/network/interface.c trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/drivers/network/tcpip/include/address.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/inclu... ============================================================================== --- trunk/reactos/drivers/network/tcpip/include/address.h [iso-8859-1] (original) +++ trunk/reactos/drivers/network/tcpip/include/address.h [iso-8859-1] Wed Jul 1 01:14:21 2009 @@ -58,8 +58,6 @@ BOOLEAN AddrLocateADEv4( IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
-BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address ); - PADDRESS_FILE AddrSearchFirst( PIP_ADDRESS Address, USHORT Port,
Modified: trunk/reactos/lib/drivers/ip/network/interface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/inte... ============================================================================== --- trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/network/interface.c [iso-8859-1] Wed Jul 1 01:14:21 2009 @@ -112,34 +112,6 @@ return Matched; }
-BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address ) { - KIRQL OldIrql; - BOOLEAN Matched = FALSE; - IF_LIST_ITER(CurrentIF); - - TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql); - - /* Find the first 'real' interface */ - ForEachInterface(CurrentIF) { - if( CurrentIF->Context ) { - *Address = CurrentIF->Unicast; - Matched = TRUE; break; - } - } EndFor(CurrentIF); - - /* Not matched, use the first one */ - if( !Matched ) { - ForEachInterface(CurrentIF) { - *Address = CurrentIF->Unicast; - Matched = TRUE; break; - } EndFor(CurrentIF); - } - - TcpipReleaseSpinLock(&InterfaceListLock, OldIrql); - - return Matched; -} - BOOLEAN HasPrefix( PIP_ADDRESS Address, PIP_ADDRESS Prefix,
Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/ra... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Wed Jul 1 01:14:21 2009 @@ -210,11 +210,19 @@ return STATUS_UNSUCCESSFUL; }
+ TI_DbgPrint(MID_TRACE,("About to get route to destination\n")); + + if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) + return STATUS_NETWORK_UNREACHABLE; + LocalAddress = AddrFile->Address; if (AddrIsUnspecified(&LocalAddress)) { - if (!IPGetDefaultAddress(&LocalAddress)) - return STATUS_UNSUCCESSFUL; + /* If the local address is unspecified (0), + * then use the unicast address of the + * interface we're sending over + */ + LocalAddress = NCE->Interface->Unicast; }
Status = BuildRawIpPacket( &Packet, @@ -227,13 +235,6 @@
if( !NT_SUCCESS(Status) ) return Status; - - TI_DbgPrint(MID_TRACE,("About to get route to destination\n")); - - if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) { - FreeNdisPacket(Packet.NdisPacket); - return STATUS_NETWORK_UNREACHABLE; - }
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/ud... ============================================================================== --- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original) +++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Wed Jul 1 01:14:21 2009 @@ -161,7 +161,7 @@ IP_PACKET Packet; PTA_IP_ADDRESS RemoteAddressTa = (PTA_IP_ADDRESS)ConnInfo->RemoteAddress; IP_ADDRESS RemoteAddress; - IP_ADDRESS LocalAddress; + IP_ADDRESS LocalAddress; USHORT RemotePort; NTSTATUS Status; PNEIGHBOR_CACHE_ENTRY NCE; @@ -186,12 +186,15 @@ return STATUS_NETWORK_UNREACHABLE; }
- LocalAddress = AddrFile->Address; - if (AddrIsUnspecified(&LocalAddress)) - { - if (!IPGetDefaultAddress(&LocalAddress)) - return FALSE; - } + LocalAddress = AddrFile->Address; + if (AddrIsUnspecified(&LocalAddress)) + { + /* If the local address is unspecified (0), + * then use the unicast address of the + * interface we're sending over + */ + LocalAddress = NCE->Interface->Unicast; + }
Status = BuildUDPPacket( &Packet, &RemoteAddress,