Skip to content

Commit

Permalink
more xp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh352 committed Jan 8, 2025
1 parent f296540 commit 57edcfb
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/lib/ares_sysconfig_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ static int compareAddresses(const void *arg1, const void *arg2)
return 0;
}

#if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
/* There can be multiple routes to "the Internet". And there can be different
* DNS servers associated with each of the interfaces that offer those routes.
* We have to assume that any DNS server can serve any request. But, some DNS
Expand Down Expand Up @@ -213,21 +214,6 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
const SOCKADDR_INET * const dest,
const ULONG interfaceMetric)
{
/* On this interface, get the best route to that destination. */
# if !defined(HAVE_GETBESTROUTE2) || defined(__WATCOMC__)
(void)luid;
(void)dest;
(void)interfaceMetric;
/* OpenWatcom's builtin Windows SDK does not have a definition for
* MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
* as a variable. Let's work around this by returning the worst possible
* metric, but only when using the OpenWatcom compiler.
* It may be worth investigating using a different version of the Windows
* SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
* 2.0.
*/
return (ULONG)-1;
# else
MIB_IPFORWARD_ROW2 row;
SOCKADDR_INET ignored;
if (GetBestRoute2(/* The interface to use. The index is ignored since we are
Expand Down Expand Up @@ -260,8 +246,8 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
* which describes the combination as a "sum".
*/
return row.Metric + interfaceMetric;
# endif
}
#endif

/*
* get_DNS_Windows()
Expand Down Expand Up @@ -382,9 +368,21 @@ static ares_bool_t get_DNS_Windows(char **outptr)
addressesSize = newSize;
}

# if !defined(HAVE_GETBESTROUTE2) || defined(__WATCOMC__)
/* OpenWatcom's builtin Windows SDK does not have a definition for
* MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
* as a variable. Let's work around this by returning the worst possible
* metric, but only when using the OpenWatcom compiler.
* It may be worth investigating using a different version of the Windows
* SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
* 2.0.
*/
addresses[addressesIndex].metric = getBestRouteMetric(
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
ipaaEntry->Ipv4Metric);
# else
addresses[addressesIndex].metric = (ULONG)-1;
# endif

/* Record insertion index to make qsort stable */
addresses[addressesIndex].orig_idx = addressesIndex;
Expand Down Expand Up @@ -426,9 +424,13 @@ static ares_bool_t get_DNS_Windows(char **outptr)
ll_scope = ipaaEntry->Ipv6IfIndex;
}

# if !defined(HAVE_GETBESTROUTE2) || defined(__WATCOMC__)
addresses[addressesIndex].metric = getBestRouteMetric(
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
ipaaEntry->Ipv6Metric);
# else
addresses[addressesIndex].metric = (ULONG)-1;
# endif

/* Record insertion index to make qsort stable */
addresses[addressesIndex].orig_idx = addressesIndex;
Expand Down

0 comments on commit 57edcfb

Please sign in to comment.