Commit 2f80cd6e authored by jehan's avatar jehan

ad linphone_proxy_config_get_transport

parent fa8135be
......@@ -52,4 +52,4 @@ coreapi/help/registration
coreapi/test_ecc
coreapi/test_lsd
gtk/version_date.h
specs.c
......@@ -230,6 +230,6 @@ bundle: $(LIBICONV_HACK)
clean-local:
rm -rf $(BUNDLEDIR)
discovery:
touch specs.cpp
touch specs.c
$(CC) --include $(top_builddir)/config.h \
$(TUNNEL_CFLAGS) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) $(SIPSTACK_CFLAGS) $(CUNIT_CFLAGS) -E -P -v -dD specs.cpp
$(TUNNEL_CFLAGS) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) $(SIPSTACK_CFLAGS) $(CUNIT_CFLAGS) -E -P -v -dD specs.c
......@@ -85,7 +85,7 @@ int sal_address_get_port_int(const SalAddress *addr){
SalTransport sal_address_get_transport(const SalAddress* addr){
belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr);
belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr);
if (uri) {
if (uri && belle_sip_uri_get_transport_param(uri)) {
return sal_transport_parse(belle_sip_uri_get_transport_param(uri));
} else
return SalTransportUDP;
......
......@@ -539,6 +539,13 @@ bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg
const char * linphone_proxy_config_get_dial_prefix(const LinphoneProxyConfig *cfg);
LinphoneReason linphone_proxy_config_get_error(const LinphoneProxyConfig *cfg);
/*
* return the transport from either : service route, route, or addr
* @returns cfg object
* @return transport as string (I.E udp, tcp, tls, dtls)*/
LINPHONE_PUBLIC const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg);
/* destruction is called automatically when removing the proxy config */
void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
......
......@@ -1322,3 +1322,25 @@ void linphone_proxy_config_set_error(LinphoneProxyConfig *cfg,LinphoneReason err
const LinphoneAddress* linphone_proxy_config_get_service_route(const LinphoneProxyConfig* cfg) {
return cfg->op?(const LinphoneAddress*) sal_op_get_service_route(cfg->op):NULL;
}
const char* linphone_proxy_config_get_transport(const LinphoneProxyConfig *cfg) {
const char* addr=NULL;
const char* ret="udp"; /*default value*/
SalAddress* route_addr=NULL;
if (linphone_proxy_config_get_service_route(cfg)) {
route_addr=(SalAddress*)linphone_proxy_config_get_service_route(cfg);
} else if (linphone_proxy_config_get_route(cfg)) {
addr=linphone_proxy_config_get_route(cfg);
} else if(linphone_proxy_config_get_addr(cfg)) {
addr=linphone_proxy_config_get_addr(cfg);
} else {
ms_error("Cannot guess transport for proxy with identity [%s]",linphone_proxy_config_get_identity(cfg));
return NULL;
}
if ((route_addr || (route_addr=sal_address_new(addr))) && sal_address_get_transport(route_addr)) {
ret=sal_transport_to_string(sal_address_get_transport(route_addr));
if (!linphone_proxy_config_get_service_route(cfg)) sal_address_destroy(route_addr); /*destroy except for service route*/
}
return ret;
}
......@@ -263,7 +263,17 @@ static void network_state_change(){
wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,2*register_ok);
linphone_core_destroy(lc);
}
static int get_number_of_udp_proxy(const LinphoneCore* lc) {
int number_of_udp_proxy=0;
LinphoneProxyConfig* proxy_cfg;
MSList* proxys;
for (proxys=(MSList*)linphone_core_get_proxy_config_list(lc);proxys!=NULL;proxys=proxys->next) {
proxy_cfg=(LinphoneProxyConfig*)proxys->data;
if (strcmp("udp",linphone_proxy_config_get_transport(proxy_cfg))==0)
number_of_udp_proxy++;
}
return number_of_udp_proxy;
}
static void transport_change(){
LinphoneCoreVTable v_table;
LinphoneCore* lc;
......@@ -271,21 +281,25 @@ static void transport_change(){
stats* counters ;
LCSipTransports sip_tr;
LCSipTransports sip_tr_orig;
memset(&sip_tr,0,sizeof(sip_tr));
int number_of_udp_proxy=0;
memset(&sip_tr,0,sizeof(sip_tr));
memset (&v_table,0,sizeof(LinphoneCoreVTable));
v_table.registration_state_changed=registration_state_changed;
lc=configure_lc(&v_table);
counters = (stats*)linphone_core_get_user_data(lc);
register_ok=counters->number_of_LinphoneRegistrationOk;
number_of_udp_proxy=get_number_of_udp_proxy(lc);
linphone_core_get_sip_transports(lc,&sip_tr_orig);
sip_tr.udp_port=sip_tr_orig.udp_port;
/*keep only udp*/
linphone_core_set_sip_transports(lc,&sip_tr);
CU_ASSERT_TRUE_FATAL(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok+1));
CU_ASSERT_TRUE_FATAL(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok+number_of_udp_proxy));
CU_ASSERT_TRUE_FATAL(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok+2));
CU_ASSERT_TRUE_FATAL(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok+(ms_list_size(proxys)-number_of_udp_proxy)));
linphone_core_destroy(lc);
}
......@@ -295,15 +309,17 @@ static void io_recv_error(){
LinphoneCore* lc;
int register_ok;
stats* counters ;
int number_of_udp_proxy=0;
memset (&v_table,0,sizeof(LinphoneCoreVTable));
v_table.registration_state_changed=registration_state_changed;
lc=configure_lc(&v_table);
counters = (stats*)linphone_core_get_user_data(lc);
register_ok=counters->number_of_LinphoneRegistrationOk;
number_of_udp_proxy=get_number_of_udp_proxy(lc);
sal_set_recv_error(lc->sal, 0);
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok-1 /*because 1 udp*/));
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok-number_of_udp_proxy /*because 1 udp*/));
sal_set_recv_error(lc->sal, 1); /*reset*/
linphone_core_destroy(lc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment