Author: cgutman Date: Wed Dec 30 13:46:14 2009 New Revision: 44810
URL: http://svn.reactos.org/svn/reactos?rev=44810&view=rev Log: [IP] - Bind to the address specified in AddressFile instead of always binding to the outgoing interface's unicast address - Get the NCE using the local address (if specified) so we don't end up sending from one interface using another interface's address as the source
Modified: branches/aicom-network-branch/lib/drivers/ip/network/icmp.c branches/aicom-network-branch/lib/drivers/ip/transport/rawip/rawip.c branches/aicom-network-branch/lib/drivers/ip/transport/tcp/tcp.c branches/aicom-network-branch/lib/drivers/ip/transport/udp/udp.c
Modified: branches/aicom-network-branch/lib/drivers/ip/network/icmp.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/drivers... ============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/network/icmp.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/network/icmp.c [iso-8859-1] Wed Dec 30 13:46:14 2009 @@ -178,9 +178,6 @@
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)) { @@ -188,7 +185,15 @@ * then use the unicast address of the * interface we're sending over */ + if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) + return STATUS_NETWORK_UNREACHABLE; + LocalAddress = NCE->Interface->Unicast; + } + else + { + if(!(NCE = NBLocateNeighbor( &LocalAddress ))) + return STATUS_INVALID_PARAMETER; }
Status = PrepareICMPPacket( NCE->Interface,
Modified: branches/aicom-network-branch/lib/drivers/ip/transport/rawip/rawip.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/drivers... ============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Wed Dec 30 13:46:14 2009 @@ -218,12 +218,6 @@
TI_DbgPrint(MID_TRACE,("About to get route to destination\n"));
- if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) - { - KeReleaseSpinLock(&AddrFile->Lock, OldIrql); - return STATUS_NETWORK_UNREACHABLE; - } - LocalAddress = AddrFile->Address; if (AddrIsUnspecified(&LocalAddress)) { @@ -231,7 +225,19 @@ * then use the unicast address of the * interface we're sending over */ + if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) { + KeReleaseSpinLock(&AddrFile->Lock, OldIrql); + return STATUS_NETWORK_UNREACHABLE; + } + LocalAddress = NCE->Interface->Unicast; + } + else + { + if(!(NCE = NBLocateNeighbor( &LocalAddress ))) { + KeReleaseSpinLock(&AddrFile->Lock, OldIrql); + return STATUS_INVALID_PARAMETER; + } }
Status = BuildRawIpPacket( AddrFile,
Modified: branches/aicom-network-branch/lib/drivers/ip/transport/tcp/tcp.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/drivers... ============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Wed Dec 30 13:46:14 2009 @@ -631,11 +631,6 @@ return Status; }
- if (!(NCE = RouteGetRouteToDestination(&RemoteAddress))) - { - return STATUS_NETWORK_UNREACHABLE; - } - /* Freed in TCPSocketState */ TI_DbgPrint(DEBUG_TCP, ("Connecting to address %x:%x\n", @@ -644,9 +639,29 @@
AddressToConnect.sin_family = AF_INET; AddressToBind = AddressToConnect; - AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address;
KeAcquireSpinLock(&Connection->Lock, &OldIrql); + + if (!Connection->AddressFile) + { + KeReleaseSpinLock(&Connection->Lock, OldIrql); + return STATUS_INVALID_PARAMETER; + } + + if (AddrIsUnspecified(&Connection->AddressFile->Address)) + { + if (!(NCE = RouteGetRouteToDestination(&RemoteAddress))) + { + KeReleaseSpinLock(&Connection->Lock, OldIrql); + return STATUS_NETWORK_UNREACHABLE; + } + + AddressToBind.sin_addr.s_addr = NCE->Interface->Unicast.Address.IPv4Address; + } + else + { + AddressToBind.sin_addr.s_addr = Connection->AddressFile->Address.Address.IPv4Address; + }
Status = TCPTranslateError ( OskitTCPBind( Connection->SocketContext,
Modified: branches/aicom-network-branch/lib/drivers/ip/transport/udp/udp.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/drivers... ============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Wed Dec 30 13:46:14 2009 @@ -193,11 +193,6 @@ return STATUS_UNSUCCESSFUL; }
- if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) { - KeReleaseSpinLock(&AddrFile->Lock, OldIrql); - return STATUS_NETWORK_UNREACHABLE; - } - LocalAddress = AddrFile->Address; if (AddrIsUnspecified(&LocalAddress)) { @@ -205,7 +200,19 @@ * then use the unicast address of the * interface we're sending over */ + if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) { + KeReleaseSpinLock(&AddrFile->Lock, OldIrql); + return STATUS_NETWORK_UNREACHABLE; + } + LocalAddress = NCE->Interface->Unicast; + } + else + { + if(!(NCE = NBLocateNeighbor( &LocalAddress ))) { + KeReleaseSpinLock(&AddrFile->Lock, OldIrql); + return STATUS_INVALID_PARAMETER; + } }
Status = BuildUDPPacket( AddrFile,