diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 876d572e2..b3877004d 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -362,17 +362,14 @@ static void process_auth_requested(void *sal, belle_sip_auth_event_t *auth_event } Sal * sal_init(){ - char stack_string[64]; belle_sip_listener_callbacks_t listener_callbacks; Sal * sal=ms_new0(Sal,1); sal->nat_helper_enabled=TRUE; - snprintf(stack_string,sizeof(stack_string)-1,"(belle-sip/%s)",belle_sip_version_to_string()); sal->user_agent=belle_sip_header_user_agent_new(); #if defined(PACKAGE_NAME) && defined(LINPHONE_VERSION) belle_sip_header_user_agent_add_product(sal->user_agent, PACKAGE_NAME "/" LINPHONE_VERSION); #endif - - belle_sip_header_user_agent_add_product(sal->user_agent,stack_string); + sal_append_stack_string_to_user_agent(sal); belle_sip_object_ref(sal->user_agent); belle_sip_set_log_handler(_belle_sip_log); sal->stack = belle_sip_stack_new(NULL); @@ -502,6 +499,13 @@ void sal_set_user_agent(Sal *ctx, const char *user_agent){ belle_sip_header_user_agent_add_product(ctx->user_agent,user_agent); return ; } + +void sal_append_stack_string_to_user_agent(Sal *ctx) { + char stack_string[64]; + snprintf(stack_string, sizeof(stack_string) - 1, "(belle-sip/%s)", belle_sip_version_to_string()); + belle_sip_header_user_agent_add_product(ctx->user_agent, stack_string); +} + /*keepalive period in ms*/ void sal_set_keepalive_period(Sal *ctx,unsigned int value){ const belle_sip_list_t* iterator; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 043943dbe..3a866a364 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1782,8 +1782,10 @@ int linphone_core_get_sip_port(LinphoneCore *lc) return tr->udp_port>0 ? tr->udp_port : (tr->tcp_port > 0 ? tr->tcp_port : tr->tls_port); } +#if !USE_BELLE_SIP static char _ua_name[64]="Linphone"; static char _ua_version[64]=LINPHONE_VERSION; +#endif #if HAVE_EXOSIP_GET_VERSION && !USE_BELLESIP extern const char *eXosip_get_version(); @@ -1809,9 +1811,18 @@ static void apply_user_agent(LinphoneCore *lc){ * @ingroup misc **/ void linphone_core_set_user_agent(LinphoneCore *lc, const char *name, const char *ver){ +#if USE_BELLESIP + char ua_string[256]; + snprintf(ua_string, sizeof(ua_string) - 1, "%s/%s", name, ver); + if (lc->sal) { + sal_set_user_agent(lc->sal, ua_string); + sal_append_stack_string_to_user_agent(lc->sal); + } +#else strncpy(_ua_name,name,sizeof(_ua_name)-1); strncpy(_ua_version,ver,sizeof(_ua_version)); apply_user_agent(lc); +#endif } const char *linphone_core_get_user_agent_name(void){ diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 222e7c329..591e39d99 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -447,6 +447,10 @@ void sal_set_user_agent(Sal *ctx, const char *user_agent){ eXosip_set_user_agent(user_agent); } +void sal_append_stack_string_to_user_agent(Sal *ctx) { + /* Not implemented for eXosip */ +} + void sal_use_session_timers(Sal *ctx, int expires){ ctx->session_expires=expires; } diff --git a/include/sal/sal.h b/include/sal/sal.h index 4bf2f415d..9b715eb63 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -383,6 +383,7 @@ void sal_set_dscp(Sal *ctx, int dscp); int sal_reset_transports(Sal *ctx); ortp_socket_t sal_get_socket(Sal *ctx); void sal_set_user_agent(Sal *ctx, const char *user_agent); +void sal_append_stack_string_to_user_agent(Sal *ctx); /*keepalive period in ms*/ void sal_set_keepalive_period(Sal *ctx,unsigned int value); void sal_use_tcp_tls_keepalive(Sal *ctx, bool_t enabled);