Module: wine Branch: master Commit: 112f878975659c2d3700efd377c5bbc00beb66d8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=112f878975659c2d3700efd377...
Author: Juan Lang juan.lang@gmail.com Date: Tue Mar 23 14:56:34 2010 -0700
iphlpapi: Set DNS servers in the IP_PER_ADAPTER_INFO returned for non-loopback addresses.
---
dlls/iphlpapi/ifenum.c | 15 +++++++++++++++ dlls/iphlpapi/ifenum.h | 1 + dlls/iphlpapi/iphlpapi_main.c | 20 +++++++++++++++----- 3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c index 4628b21..c998b93 100644 --- a/dlls/iphlpapi/ifenum.c +++ b/dlls/iphlpapi/ifenum.c @@ -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; diff --git a/dlls/iphlpapi/ifenum.h b/dlls/iphlpapi/ifenum.h index 79e484b..be5c9c1 100644 --- a/dlls/iphlpapi/ifenum.h +++ b/dlls/iphlpapi/ifenum.h @@ -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 { diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 2869ce3..5cefd4a 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -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; }