mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 22:49:12 +00:00
- 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 svn path=/trunk/; revision=41720
This commit is contained in:
parent
5ad493ce71
commit
fd848cadad
4 changed files with 20 additions and 46 deletions
|
@ -58,8 +58,6 @@ BOOLEAN AddrIsEqualIPv4(
|
|||
BOOLEAN AddrLocateADEv4(
|
||||
IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
|
||||
|
||||
BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address );
|
||||
|
||||
PADDRESS_FILE AddrSearchFirst(
|
||||
PIP_ADDRESS Address,
|
||||
USHORT Port,
|
||||
|
|
|
@ -112,34 +112,6 @@ BOOLEAN AddrLocateADEv4(
|
|||
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,
|
||||
|
|
|
@ -210,11 +210,19 @@ NTSTATUS RawIPSendDatagram(
|
|||
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,
|
||||
|
@ -228,13 +236,6 @@ NTSTATUS RawIPSendDatagram(
|
|||
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"));
|
||||
|
||||
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete, NULL )))
|
||||
|
|
|
@ -161,7 +161,7 @@ NTSTATUS UDPSendDatagram(
|
|||
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 @@ NTSTATUS UDPSendDatagram(
|
|||
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,
|
||||
|
|
Loading…
Reference in a new issue