From 2338c9467457ada5bf2ecd036e76d042cece9d57 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 29 Jan 2016 17:48:55 +0100 Subject: [PATCH] fix routing of quality reporting publishes --- coreapi/bellesip_sal/sal_address_impl.c | 5 +++++ coreapi/quality_reporting.c | 24 +++++++++++++++--------- include/sal/sal.h | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index b6ed5b77e..8b8b75417 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -208,6 +208,11 @@ void sal_address_set_uri_params(SalAddress *addr, const char *params){ belle_sip_parameters_set(parameters,params); } +bool_t sal_address_has_uri_param(SalAddress *addr, const char *name){ + belle_sip_parameters_t* parameters = BELLE_SIP_PARAMETERS(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr))); + belle_sip_parameters_has_parameter(parameters, name); +} + void sal_address_set_header(SalAddress *addr, const char *header_name, const char *header_value){ belle_sip_uri_set_header(belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(addr)),header_name, header_value); } diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index 5f01ab99b..ea4ba3f6e 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -271,8 +271,7 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, int ret = 0; LinphoneEvent *lev; LinphoneAddress *request_uri; - char * domain; - const char* route; + const char* collector_uri; /*if we are on a low bandwidth network, do not send reports to not overload it*/ if (linphone_call_params_low_bandwidth_enabled(linphone_call_get_current_params(call))){ @@ -353,14 +352,21 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report, } - route = linphone_proxy_config_get_quality_reporting_collector(call->dest_proxy); - domain = ms_strdup_printf("sip:%s", linphone_proxy_config_get_domain(call->dest_proxy)); - request_uri = linphone_address_new(route ? route : domain); - ms_free(domain); + collector_uri = linphone_proxy_config_get_quality_reporting_collector(call->dest_proxy); + if (!collector_uri){ + collector_uri = ms_strdup_printf("sip:%s", linphone_proxy_config_get_domain(call->dest_proxy)); + } + request_uri = linphone_address_new(collector_uri); lev=linphone_core_create_publish(call->core, request_uri, "vq-rtcpxr", expires); - if (route) { - ms_message("Publishing report with custom route %s", route); - sal_op_set_route(lev->op, route); + /* Special exception for quality report PUBLISH: if the collector_uri has any transport related parameters + * (port, transport, maddr), then it is sent directly. + * Otherwise it is routed as any LinphoneEvent publish, following proxy config policy. + **/ + if (sal_address_has_uri_param((SalAddress*)request_uri, "transport") || + sal_address_has_uri_param((SalAddress*)request_uri, "maddr") || + linphone_address_get_port(request_uri) != 0) { + ms_message("Publishing report with custom route %s", collector_uri); + sal_op_set_route(lev->op, collector_uri); } if (linphone_event_send_publish(lev, content) != 0){ diff --git a/include/sal/sal.h b/include/sal/sal.h index ca06b1d13..5a7e59138 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -126,6 +126,7 @@ void sal_address_set_transport_name(SalAddress* addr,const char* transport); void sal_address_set_method_param(SalAddress *addr, const char *method); void sal_address_set_params(SalAddress *addr, const char *params); void sal_address_set_uri_params(SalAddress *addr, const char *params); +bool_t sal_address_has_uri_param(SalAddress *addr, const char *name); bool_t sal_address_is_ipv6(const SalAddress *addr); bool_t sal_address_is_sip(const SalAddress *addr); void sal_address_set_password(SalAddress *addr, const char *passwd);