Commit 112f8789 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

iphlpapi: Set DNS servers in the IP_PER_ADAPTER_INFO returned for non-loopback addresses.

parent 189cd590
......@@ -158,6 +158,21 @@ DWORD getInterfaceIndexByName(const char *name, PDWORD index)
return ret;
}
BOOL isIfIndexLoopback(ULONG idx)
{
BOOL ret = FALSE;
char name[IFNAMSIZ];
int fd;
getInterfaceNameByIndex(idx, name);
fd = socket(PF_INET, SOCK_DGRAM, 0);
if (fd != -1) {
ret = isLoopbackInterface(fd, name);
close(fd);
}
return ret;
}
DWORD getNumNonLoopbackInterfaces(void)
{
DWORD numInterfaces;
......
......@@ -46,6 +46,7 @@
DWORD getNumInterfaces(void);
DWORD getNumNonLoopbackInterfaces(void);
BOOL isIfIndexLoopback(ULONG idx);
/* A table of interface indexes, see get*InterfaceTable(). */
typedef struct _InterfaceIndexTable {
......
......@@ -1688,18 +1688,21 @@ DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
* RETURNS
* Success: NO_ERROR
* Failure: error code from winerror.h
*
* FIXME
* Stub, returns empty IP_PER_ADAPTER_INFO in every case.
*/
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
{
ULONG bytesNeeded = sizeof(IP_PER_ADAPTER_INFO);
ULONG bytesNeeded = sizeof(IP_PER_ADAPTER_INFO), serverListSize = 0;
DWORD ret = NO_ERROR;
TRACE("(IfIndex %d, pPerAdapterInfo %p, pOutBufLen %p)\n", IfIndex, pPerAdapterInfo, pOutBufLen);
if (!pOutBufLen) return ERROR_INVALID_PARAMETER;
if (!isIfIndexLoopback(IfIndex)) {
get_dns_server_list(NULL, NULL, &serverListSize);
if (serverListSize > sizeof(IP_ADDR_STRING))
bytesNeeded += serverListSize - sizeof(IP_ADDR_STRING);
}
if (!pPerAdapterInfo || *pOutBufLen < bytesNeeded)
{
*pOutBufLen = bytesNeeded;
......@@ -1707,7 +1710,14 @@ DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterIn
}
memset(pPerAdapterInfo, 0, bytesNeeded);
return NO_ERROR;
if (!isIfIndexLoopback(IfIndex)) {
ret = get_dns_server_list(&pPerAdapterInfo->DnsServerList,
(PIP_ADDR_STRING)((PBYTE)pPerAdapterInfo + sizeof(IP_PER_ADAPTER_INFO)),
&serverListSize);
/* Assume the first DNS server in the list is the "current" DNS server: */
pPerAdapterInfo->CurrentDnsServer = &pPerAdapterInfo->DnsServerList;
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment