From 0f312991392a3111d52831613014c574e5901fe2 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Thu, 13 Feb 2014 16:08:09 +0100 Subject: [PATCH] Prefer default, then registering proxy in linphone_core_lookup_known_proxy Simple backward compatible evolution of the algorithm. Not registering proxy does not mean disabled: they are the fallback in case no other proxy matches. A better description of the proxy config modes would be: - enabled; - noregister; - disabled. However, it is a bit invasive as many places enable/disable registrations. --- coreapi/linphonecore.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ea94da3fa..b589c17b0 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2490,9 +2490,10 @@ static MSList *make_routes_for_proxy(LinphoneProxyConfig *proxy, const LinphoneA LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri){ const MSList *elem; LinphoneProxyConfig *found_cfg=NULL; + LinphoneProxyConfig *found_noreg_cfg=NULL; LinphoneProxyConfig *default_cfg=lc->default_proxy; - /*always prefer the default proxy if it is matching the destination uri*/ + /*return default proxy if it is matching the destination uri*/ if (default_cfg){ const char *domain=linphone_proxy_config_get_domain(default_cfg); if (strcmp(domain,linphone_address_get_domain(uri))==0){ @@ -2501,16 +2502,21 @@ LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const L } } - /*otherwise iterate through the other proxy config and return the first matching*/ + /*otherwise return first registering matching, otherwise first matching */ for (elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=elem->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; const char *domain=linphone_proxy_config_get_domain(cfg); if (domain!=NULL && strcmp(domain,linphone_address_get_domain(uri))==0){ - found_cfg=cfg; - goto end; + if (linphone_proxy_config_register_enabled(cfg)) { + found_cfg=cfg; + goto end; + } else if (!found_noreg_cfg){ + found_noreg_cfg=cfg; + } } } end: + if (found_noreg_cfg) found_cfg = found_noreg_cfg; if (found_cfg!=NULL && found_cfg!=default_cfg){ ms_debug("Overriding default proxy setting for this call/message/subscribe operation."); }else found_cfg=default_cfg;