From 9cb68a7d8d55561bd3df6e69ba0523c45ef2f3e4 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 19 Feb 2013 15:07:10 +0100 Subject: [PATCH] Disable ping options when uPnP is working --- coreapi/linphonecall.c | 23 +++++++++++++++-------- coreapi/linphonecore.c | 24 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 6a39783e..a7cad386 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -508,14 +508,21 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro call->core=lc; if (lc->sip_conf.ping_with_options){ - /*the following sends an option request back to the caller so that - we get a chance to discover our nat'd address before answering.*/ - call->ping_op=sal_op_new(lc->sal); - from_str=linphone_address_as_string_uri_only(from); - sal_op_set_route(call->ping_op,sal_op_get_network_origin(op)); - sal_op_set_user_pointer(call->ping_op,call); - sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str); - ms_free(from_str); +#ifdef BUILD_UPNP + if (lc->upnp != NULL && linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp && + linphone_upnp_context_get_state(lc->upnp) == LinphoneUpnpStateOk) { +#else //BUILD_UPNP + { +#endif //BUILD_UPNP + /*the following sends an option request back to the caller so that + we get a chance to discover our nat'd address before answering.*/ + call->ping_op=sal_op_new(lc->sal); + from_str=linphone_address_as_string_uri_only(from); + sal_op_set_route(call->ping_op,sal_op_get_network_origin(op)); + sal_op_set_user_pointer(call->ping_op,call); + sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str); + ms_free(from_str); + } } linphone_address_clean(from); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ea439dc2..bc421e51 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2605,15 +2605,23 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const } if (call->dest_proxy==NULL && lc->sip_conf.ping_with_options==TRUE){ - /*defer the start of the call after the OPTIONS ping*/ - call->ping_replied=FALSE; - call->ping_op=sal_op_new(lc->sal); - sal_ping(call->ping_op,from,real_url); - sal_op_set_user_pointer(call->ping_op,call); - call->start_time=time(NULL); - }else{ - if (defer==FALSE) linphone_core_start_invite(lc,call); +#ifdef BUILD_UPNP + if (lc->upnp != NULL && linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp && + linphone_upnp_context_get_state(lc->upnp) == LinphoneUpnpStateOk) { +#else //BUILD_UPNP + { +#endif //BUILD_UPNP + /*defer the start of the call after the OPTIONS ping*/ + call->ping_replied=FALSE; + call->ping_op=sal_op_new(lc->sal); + sal_ping(call->ping_op,from,real_url); + sal_op_set_user_pointer(call->ping_op,call); + call->start_time=time(NULL); + defer = TRUE; + } } + + if (defer==FALSE) linphone_core_start_invite(lc,call); if (real_url!=NULL) ms_free(real_url); return call; -- 2.39.2