mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:02:59 +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(
|
BOOLEAN AddrLocateADEv4(
|
||||||
IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
|
IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
|
||||||
|
|
||||||
BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address );
|
|
||||||
|
|
||||||
PADDRESS_FILE AddrSearchFirst(
|
PADDRESS_FILE AddrSearchFirst(
|
||||||
PIP_ADDRESS Address,
|
PIP_ADDRESS Address,
|
||||||
USHORT Port,
|
USHORT Port,
|
||||||
|
|
|
@ -112,34 +112,6 @@ BOOLEAN AddrLocateADEv4(
|
||||||
return Matched;
|
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(
|
BOOLEAN HasPrefix(
|
||||||
PIP_ADDRESS Address,
|
PIP_ADDRESS Address,
|
||||||
PIP_ADDRESS Prefix,
|
PIP_ADDRESS Prefix,
|
||||||
|
|
|
@ -210,11 +210,19 @@ NTSTATUS RawIPSendDatagram(
|
||||||
return STATUS_UNSUCCESSFUL;
|
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;
|
LocalAddress = AddrFile->Address;
|
||||||
if (AddrIsUnspecified(&LocalAddress))
|
if (AddrIsUnspecified(&LocalAddress))
|
||||||
{
|
{
|
||||||
if (!IPGetDefaultAddress(&LocalAddress))
|
/* If the local address is unspecified (0),
|
||||||
return STATUS_UNSUCCESSFUL;
|
* then use the unicast address of the
|
||||||
|
* interface we're sending over
|
||||||
|
*/
|
||||||
|
LocalAddress = NCE->Interface->Unicast;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = BuildRawIpPacket( &Packet,
|
Status = BuildRawIpPacket( &Packet,
|
||||||
|
@ -228,13 +236,6 @@ NTSTATUS RawIPSendDatagram(
|
||||||
if( !NT_SUCCESS(Status) )
|
if( !NT_SUCCESS(Status) )
|
||||||
return 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"));
|
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete, NULL )))
|
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete, NULL )))
|
||||||
|
|
|
@ -189,8 +189,11 @@ NTSTATUS UDPSendDatagram(
|
||||||
LocalAddress = AddrFile->Address;
|
LocalAddress = AddrFile->Address;
|
||||||
if (AddrIsUnspecified(&LocalAddress))
|
if (AddrIsUnspecified(&LocalAddress))
|
||||||
{
|
{
|
||||||
if (!IPGetDefaultAddress(&LocalAddress))
|
/* If the local address is unspecified (0),
|
||||||
return FALSE;
|
* then use the unicast address of the
|
||||||
|
* interface we're sending over
|
||||||
|
*/
|
||||||
|
LocalAddress = NCE->Interface->Unicast;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = BuildUDPPacket( &Packet,
|
Status = BuildUDPPacket( &Packet,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue