Commit 90a5aa9b authored by Ghislain MARY's avatar Ghislain MARY

Add option to use the struct res_state to get nameservers.

parent 45422ac0
......@@ -168,7 +168,12 @@ static struct dns_resolv_conf *resconf(belle_sip_simple_resolver_context_t *ctx)
#if defined(USE_FIXED_NAMESERVERS)
error = dns_resconf_load_fixed_nameservers(ctx->resconf);
if (error) {
belle_sip_error("%s dns_resconf_load_fixed_name_servers error", __FUNCTION__);
belle_sip_error("%s dns_resconf_load_fixed_nameservers error", __FUNCTION__);
}
#elif defined(USE_STRUCT_RES_STATE_NAMESERVERS)
error = dns_resconf_load_struct_res_state_nameservers(ctx->resconf);
if (error) {
belle_sip_error("%s dns_resconf_load_struct_res_state_nameservers error", __FUNCTION__);
}
#elif defined(_WIN32)
error = dns_resconf_loadwin(ctx->resconf);
......
......@@ -111,7 +111,7 @@
#include "dns.h"
#ifdef HAVE_RESINIT
#if defined(HAVE_RESINIT) || defined(USE_STRUCT_RES_STATE_NAMESERVERS)
#include <resolv.h>
#endif
......@@ -4210,6 +4210,19 @@ int dns_resconf_load_fixed_nameservers(struct dns_resolv_conf *resconf) {
}
#endif /* USE_FIXED_NAMESERVERS */
#ifdef USE_STRUCT_RES_STATE_NAMESERVERS
int dns_resconf_load_struct_res_state_nameservers(struct dns_resolv_conf *resconf) {
int i;
struct __res_state *rs = __res_get_state();
for (i = 0; i < rs->nscount; i++) {
memcpy(&resconf->nameserver[i], (struct sockaddr_storage *)&rs->nsaddr_list[i], sizeof(struct sockaddr_in));
}
return 0;
}
#endif /* USE_STRUCT_RES_STATE_NAMESERVERS */
#ifdef _WIN32
int dns_resconf_loadwin(struct dns_resolv_conf *resconf) {
FIXED_INFO *pFixedInfo;
......
......@@ -913,6 +913,9 @@ int dns_resconf_loadpath(struct dns_resolv_conf *, const char *);
#ifdef USE_FIXED_NAMESERVERS
int dns_resconf_load_fixed_nameservers(struct dns_resolv_conf *resconf);
#endif /* USE_FIXED_NAMESERVERS */
#ifdef USE_STRUCT_RES_STATE_NAMESERVERS
int dns_resconf_load_struct_res_state_nameservers(struct dns_resolv_conf *resconf);
#endif /* USE_STRUCT_RES_STATE_NAMESERVERS */
#ifdef _WIN32
int dns_resconf_loadwin(struct dns_resolv_conf *);
#endif
......
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