From eeec778bb2702c417f3a7e865bc7c47d99e457d7 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sat, 5 Dec 2015 18:29:57 +0000 Subject: [PATCH] [TCPIP] DispTdiQueryIpHwAddress(): use the correct function to get the interface associated with an IP address. Also, because local links aren't in the ARP table (obviously), handle them without the mechanism described previously This fixes arpinging oneself. svn path=/trunk/; revision=70277 --- .../drivers/network/tcpip/tcpip/dispatch.c | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/network/tcpip/tcpip/dispatch.c b/reactos/drivers/network/tcpip/tcpip/dispatch.c index b57fbfada69..847b435201c 100644 --- a/reactos/drivers/network/tcpip/tcpip/dispatch.c +++ b/reactos/drivers/network/tcpip/tcpip/dispatch.c @@ -1681,6 +1681,27 @@ NTSTATUS DispTdiQueryIpHwAddress( PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STA AddrInitIPv4(&Remote, IPs[0]); AddrInitIPv4(&Local, IPs[1]); + if (AddrIsUnspecified(&Remote)) { + Status = STATUS_UNSUCCESSFUL; + goto Exit; + } + + Interface = AddrLocateInterface(&Remote); + if (Interface) { + PVOID OutputBuffer; + + if (Interface->AddressLength > IrpSp->Parameters.DeviceIoControl.OutputBufferLength) { + Status = STATUS_INVALID_BUFFER_SIZE; + goto Exit; + } + + OutputBuffer = Irp->AssociatedIrp.SystemBuffer; + RtlCopyMemory(OutputBuffer, Interface->Address, Interface->AddressLength); + Irp->IoStatus.Information = Interface->AddressLength; + Status = STATUS_SUCCESS; + goto Exit; + } + if (AddrIsUnspecified(&Local)) { NCE = RouteGetRouteToDestination(&Remote); if (NCE == NULL) { @@ -1691,7 +1712,7 @@ NTSTATUS DispTdiQueryIpHwAddress( PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STA Interface = NCE->Interface; } else { - Interface = FindOnLinkInterface(&Local); + Interface = AddrLocateInterface(&Local); if (Interface == NULL) { Status = STATUS_NETWORK_UNREACHABLE; goto Exit;