Commit bc5d63b8 authored by jehan's avatar jehan

use res_ninit to guess dns names

parent 3cf4815b
......@@ -78,6 +78,11 @@
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="include/belle-sip"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="tester"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
......@@ -114,6 +119,7 @@
</target>
</buildTargets>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
......@@ -199,7 +205,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.779699347;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1327025999;cdt.managedbuild.tool.gnu.c.compiler.input.1517483722">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290.;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.3940526;cdt.managedbuild.tool.gnu.c.compiler.input.2089521215">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
......@@ -242,7 +248,7 @@
</scannerInfoProvider>
</profile>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.959032290.;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.3940526;cdt.managedbuild.tool.gnu.c.compiler.input.2089521215">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.macosx.base.557244179;cdt.managedbuild.toolchain.gnu.macosx.base.557244179.779699347;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1327025999;cdt.managedbuild.tool.gnu.c.compiler.input.1517483722">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
......@@ -286,5 +292,4 @@
</profile>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
......@@ -71,6 +71,11 @@ CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $ANTLR_CFLAGS"
AC_CHECK_HEADERS([antlr3.h], [found_antlr3=yes])
AC_CHECK_DECL([antlr3StringStreamNew], [found_antlr3=yes], [found_antlr3=no],[#include <antlr3.h>])
AC_CHECK_DECL([res_ninit]
,[AC_DEFINE(HAVE_RESINIT,1,[Defined when res_ninit api is available]) LIBS="$LIBS -lresolv"]
,[foo=bar]
,[#include <resolv.h>])
CPPFLAGS=$CPPFLAGS_save
if test "$found_antlr3" != "yes" ; then
......
......@@ -25,7 +25,7 @@
static struct dns_resolv_conf *resconf(belle_sip_resolver_context_t *ctx) {
#ifndef _WIN32
#if !_WIN32 && !HAVE_RESINIT
const char *path;
#endif
int error;
......@@ -43,12 +43,16 @@ static struct dns_resolv_conf *resconf(belle_sip_resolver_context_t *ctx) {
if (error) {
belle_sip_error("%s dns_resconf_loadwin error", __FUNCTION__);
}
#else
#ifdef ANDROID
#elif ANDROID
error = dns_resconf_loadandroid(ctx->resconf);
if (error) {
belle_sip_error("%s dns_resconf_loadandroid error", __FUNCTION__);
}
#elif HAVE_RESINIT
error = dns_resconf_loadfromresolv(ctx->resconf);
if (error) {
belle_sip_error("%s dns_resconf_loadfromresolv error", __FUNCTION__);
}
#else
path = "/etc/resolv.conf";
error = dns_resconf_loadpath(ctx->resconf, path);
......@@ -63,7 +67,7 @@ static struct dns_resolv_conf *resconf(belle_sip_resolver_context_t *ctx) {
belle_sip_message("%s dns_nssconf_loadpath error [%s]: %s", __FUNCTION__, path, dns_strerror(error));
}
#endif
#endif
return ctx->resconf;
}
......
......@@ -104,6 +104,9 @@
#include "dns.h"
#ifdef HAVE_RESINIT
#include <resolv.h>
#endif
/*
* C O M P I L E R A N N O T A T I O N S
......@@ -4367,6 +4370,23 @@ int dns_resconf_loadandroid(struct dns_resolv_conf *resconf) {
} /* dns_resconf_loadandroid */
#endif
#ifdef HAVE_RESINIT
int dns_resconf_loadfromresolv(struct dns_resolv_conf *resconf) {
struct __res_state res;
union res_sockaddr_union addresses[3];
int i,error;
if ((error = res_ninit(&res))) {
return error;
}
for (i = 0; i < res_getservers(&res,addresses,res.nscount) && i<3 /*only 3 element*/; i++ ) {
memcpy(&resconf->nameserver[i],&addresses[i],sizeof(union res_sockaddr_union));
}
res_ndestroy(&res);
return i>0?0:-1;
}
#endif /*HAVE_RESINIT*/
struct dns_anyconf {
char *token[16];
......
......@@ -25,7 +25,9 @@
*/
#ifndef DNS_H
#define DNS_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stddef.h> /* size_t offsetof() */
#include <stdio.h> /* FILE */
......@@ -911,7 +913,9 @@ int dns_resconf_loadpath(struct dns_resolv_conf *, const char *);
#ifdef _WIN32
int dns_resconf_loadwin(struct dns_resolv_conf *);
#endif
#ifdef HAVE_RESINIT
int dns_resconf_loadfromresolv(struct dns_resolv_conf *resconf);
#endif /*HAVE_RESINIT*/
int dns_nssconf_loadfile(struct dns_resolv_conf *, FILE *);
int dns_nssconf_loadpath(struct dns_resolv_conf *, const char *);
......
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