Commit e30413a1 authored by Ghislain MARY's avatar Ghislain MARY Committed by Sandrine Avakian
Browse files

Fix DNS resolution on Windows that was broken with the update of dns.c.

parent 8a27c66e
......@@ -74,8 +74,23 @@
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#ifndef USE_FIXED_NAMESERVERS
#include <IPHlpApi.h>
#pragma comment(lib, "IPHLPAPI.lib")
#endif
#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
#define BELLE_SIP_WINDOWS_DESKTOP 1
#elif defined(WINAPI_FAMILY_PARTITION)
#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define BELLE_SIP_WINDOWS_DESKTOP 1
#elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
#define BELLE_SIP_WINDOWS_PHONE 1
#elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define BELLE_SIP_WINDOWS_UNIVERSAL 1
#endif
#endif
#else
#include <sys/types.h> /* FD_SETSIZE socklen_t */
#include <sys/select.h> /* FD_ZERO FD_SET fd_set select(2) */
......@@ -4141,7 +4156,8 @@ struct dns_hosts *dns_hosts_mortal(struct dns_hosts *hosts) {
return hosts;
} /* dns_hosts_mortal() */
int dns_hosts_add_localhost(struct dns_hosts *hosts) {
#if defined(BELLE_SIP_WINDOWS_PHONE) || defined(BELLE_SIP_WINDOWS_UNIVERSAL)
static int dns_hosts_add_localhost(struct dns_hosts *hosts) {
struct dns_hosts_entry ent;
memset(&ent, '\0', sizeof(ent));
ent.af = AF_INET;
......@@ -4155,6 +4171,7 @@ int dns_hosts_add_localhost(struct dns_hosts *hosts) {
dns_hosts_insert(hosts, ent.af, &ent.addr, ent.host, 1);
return 0;
}
#endif
struct dns_hosts *dns_hosts_local(int *error_) {
struct dns_hosts *hosts;
......@@ -4164,7 +4181,7 @@ struct dns_hosts *dns_hosts_local(int *error_) {
goto error;
#ifdef _WIN32
#ifdef WINAPI_FAMILY_PHONE_APP
#if defined(BELLE_SIP_WINDOWS_PHONE) || defined(BELLE_SIP_WINDOWS_UNIVERSAL)
if ((error = dns_hosts_add_localhost(hosts)))
#else
if ((error = dns_hosts_loadpath(hosts, "C:/Windows/System32/drivers/etc/hosts")))
......@@ -4905,20 +4922,8 @@ int dns_resconf_load_struct_res_state_nameservers(struct dns_resolv_conf *rescon
}
#endif /* USE_STRUCT_RES_STATE_NAMESERVERS */
#ifdef _WIN32
#if defined(_WIN32) && !defined(USE_FIXED_NAMESERVERS)
int dns_resconf_loadwin(struct dns_resolv_conf *resconf) {
#if WINAPI_FAMILY_APP
const char * const nameservers[] = {
"8.8.8.8",
"8.8.4.4"
};
int i;
int error = 0;
for (i = 0; !error && (i < lengthof(nameservers)); i++) {
error = dns_resconf_pton(&resconf->nameserver[i], nameservers[i]);
}
return error;
#else
FIXED_INFO *pFixedInfo;
ULONG ulOutBufLen;
DWORD dwRetVal;
......@@ -4951,7 +4956,6 @@ int dns_resconf_loadwin(struct dns_resolv_conf *resconf) {
}
free(pFixedInfo);
return 0;
#endif
}
#endif /* dns_resconf_loadwin() */
......
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