From: Paul Gofman pgofman@codeweavers.com
--- dlls/iphlpapi/iphlpapi_main.c | 30 ++++++++++++------------------ include/iphlpapi.h | 6 +++--- 2 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 31c6c03eb8c..e3202e3a2bd 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -1389,27 +1389,21 @@ DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex) * Success: NO_ERROR * Failure: error code from winerror.h */ -DWORD WINAPI GetBestInterfaceEx(struct sockaddr *pDestAddr, PDWORD pdwBestIfIndex) +DWORD WINAPI GetBestInterfaceEx( struct sockaddr *dst, DWORD *best_index ) { - DWORD ret; + SOCKADDR_INET best_address; + MIB_IPFORWARD_ROW2 row; + DWORD ret;
- TRACE("pDestAddr %p, pdwBestIfIndex %p\n", pDestAddr, pdwBestIfIndex); - if (!pDestAddr || !pdwBestIfIndex) - ret = ERROR_INVALID_PARAMETER; - else { - MIB_IPFORWARDROW ipRow; + TRACE( "dst %p, best_index %p\n", dst, best_index );
- if (pDestAddr->sa_family == AF_INET) { - ret = GetBestRoute(((struct sockaddr_in *)pDestAddr)->sin_addr.S_un.S_addr, 0, &ipRow); - if (ret == ERROR_SUCCESS) - *pdwBestIfIndex = ipRow.dwForwardIfIndex; - } else { - FIXME("address family %d not supported\n", pDestAddr->sa_family); - ret = ERROR_NOT_SUPPORTED; - } - } - TRACE("returning %ld\n", ret); - return ret; + if (!dst || !best_index) return ERROR_INVALID_PARAMETER; + + ret = GetBestRoute2( NULL, 0, NULL, (const SOCKADDR_INET *)dst, 0, &row, &best_address ); + if (!ret) *best_index = row.InterfaceIndex; + + TRACE( "returning %ld\n", ret ); + return ret; }
diff --git a/include/iphlpapi.h b/include/iphlpapi.h index 9daf864a92b..d8fc36a5f72 100644 --- a/include/iphlpapi.h +++ b/include/iphlpapi.h @@ -100,11 +100,11 @@ IPHLPAPI_DLL_LINKAGE DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdw #ifdef __WINE_WINSOCKAPI_STDLIB_H IPHLPAPI_DLL_LINKAGE DWORD WINAPI GetBestInterfaceEx( #ifdef USE_WS_PREFIX - struct WS_sockaddr *pDestAddr, + struct WS_sockaddr *dst, #else - struct sockaddr *pDestAddr, + struct sockaddr *dst, #endif - PDWORD pdwBestIfIndex); + DWORD *best_index); #endif
IPHLPAPI_DLL_LINKAGE DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute);