From b03a9b25f8125fa40bbc44dc76bb73299dd3bb36 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 13 Jul 2016 13:45:05 +0200 Subject: [PATCH] Add API and config parameter to enable/disable DNS search. --- coreapi/bellesip_sal/sal_impl.c | 8 ++++++++ coreapi/linphonecore.c | 12 ++++++++++++ coreapi/linphonecore.h | 16 ++++++++++++++++ include/sal/sal.h | 2 ++ 4 files changed, 38 insertions(+) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index aabee27f7..e9f0a7b23 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -877,6 +877,14 @@ bool_t sal_dns_srv_enabled(const Sal *sal) { return (bool_t)belle_sip_stack_dns_srv_enabled(sal->stack); } +void sal_enable_dns_search(Sal *sal, bool_t enable) { + belle_sip_stack_enable_dns_search(sal->stack, (unsigned char)enable); +} + +bool_t sal_dns_search_enabled(const Sal *sal) { + return (bool_t)belle_sip_stack_dns_search_enabled(sal->stack); +} + void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file) { belle_sip_stack_set_dns_user_hosts_file(sal->stack, hosts_file); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 317a87a16..bea0fff1b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -790,6 +790,8 @@ static void net_config_read (LinphoneCore *lc) } tmp = lp_config_get_int(lc->config, "net", "dns_srv_enabled", 1); linphone_core_enable_dns_srv(lc, tmp); + tmp = lp_config_get_int(lc->config, "net", "dns_search_enabled", 1); + linphone_core_enable_dns_search(lc, tmp); /* This is to filter out unsupported firewall policies */ if (nat_policy_ref == NULL) @@ -1523,6 +1525,16 @@ bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc) { return sal_dns_srv_enabled(lc->sal); } +void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable) { + sal_enable_dns_search(lc->sal, enable); + if (linphone_core_ready(lc)) + lp_config_set_int(lc->config, "net", "dns_search_enabled", enable ? 1 : 0); +} + +bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc) { + return sal_dns_search_enabled(lc->sal); +} + int linphone_core_get_download_bandwidth(const LinphoneCore *lc){ return lc->net_conf.download_bw; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index eafc3512d..8adc07c7e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -2754,6 +2754,22 @@ LINPHONE_PUBLIC void linphone_core_enable_dns_srv(LinphoneCore *lc, bool_t enabl */ LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc); +/** + * Enable or disable DNS search (use of local domain if the fully qualified name did return results). + * @param[in] lc #LinphoneCore object. + * @param[in] enable TRUE to enable DNS search, FALSE to disable it. + * @ingroup media_parameters + */ +LINPHONE_PUBLIC void linphone_core_enable_dns_search(LinphoneCore *lc, bool_t enable); + +/** + * Tells whether DNS search (use of local domain if the fully qualified name did return results) is enabled. + * @param[in] lc #LinphoneCore object. + * @return TRUE if DNS search is enabled, FALSE if disabled. + * @ingroup media_parameters + */ +LINPHONE_PUBLIC bool_t linphone_core_dns_search_enabled(const LinphoneCore *lc); + /** * Forces liblinphone to use the supplied list of dns servers, instead of system's ones. * @param[in] lc #LinphoneCore object. diff --git a/include/sal/sal.h b/include/sal/sal.h index a815bf64b..629569744 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -870,6 +870,8 @@ LINPHONE_PUBLIC int sal_get_transport_timeout(const Sal* sal); void sal_set_dns_servers(Sal *sal, const MSList *servers); LINPHONE_PUBLIC void sal_enable_dns_srv(Sal *sal, bool_t enable); LINPHONE_PUBLIC bool_t sal_dns_srv_enabled(const Sal *sal); +LINPHONE_PUBLIC void sal_enable_dns_search(Sal *sal, bool_t enable); +LINPHONE_PUBLIC bool_t sal_dns_search_enabled(const Sal *sal); LINPHONE_PUBLIC void sal_set_dns_user_hosts_file(Sal *sal, const char *hosts_file); LINPHONE_PUBLIC const char *sal_get_dns_user_hosts_file(const Sal *sal); unsigned int sal_get_random(void);