mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
use transport from proxyconfig if not set in request uri
This commit is contained in:
parent
08281caa49
commit
eb26ab5c1c
6 changed files with 69 additions and 10 deletions
|
|
@ -216,6 +216,10 @@ static void process_request_event(void *sal, const belle_sip_request_event_t *ev
|
|||
|
||||
static void process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
|
||||
belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
|
||||
if (!client_transaction) {
|
||||
ms_error("Unexpected stateless response, trashing");
|
||||
return;
|
||||
}
|
||||
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction));
|
||||
belle_sip_response_t* response = belle_sip_response_event_get_response(event);
|
||||
belle_sip_request_t* request=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction));
|
||||
|
|
@ -355,12 +359,14 @@ static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *eve
|
|||
}
|
||||
}
|
||||
static void process_transaction_terminated(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) {
|
||||
/* belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event);
|
||||
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(client_transaction);
|
||||
belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event);
|
||||
belle_sip_server_transaction_t* server_transaction = belle_sip_transaction_terminated_event_get_server_transaction(event);
|
||||
|
||||
/* SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(client_transaction);
|
||||
if (op->calbacks.process_transaction_terminated) {
|
||||
op->calbacks.process_transaction_terminated(op,event);
|
||||
} else */{
|
||||
ms_error("Unhandled transaction terminated [%p]",event);
|
||||
ms_error("Unhandled transaction terminated [%p]",client_transaction!=NULL?(void*)client_transaction:(void*)server_transaction);
|
||||
}
|
||||
}
|
||||
static void process_auth_requested(void *sal, belle_sip_auth_event_t *auth_event) {
|
||||
|
|
|
|||
|
|
@ -106,14 +106,14 @@ static void register_process_transaction_terminated(void *user_ctx, const belle_
|
|||
|
||||
|
||||
/*if expire = -1, does not change expires*/
|
||||
static void send_register_request_with_expires(SalOp* op, belle_sip_request_t* request,int expires) {
|
||||
static int send_register_request_with_expires(SalOp* op, belle_sip_request_t* request,int expires) {
|
||||
belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_EXPIRES);
|
||||
|
||||
if (!expires_header && expires>=0) {
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(request),BELLE_SIP_HEADER(expires_header=belle_sip_header_expires_new()));
|
||||
}
|
||||
if (expires_header) belle_sip_header_expires_set_expires(expires_header,expires);
|
||||
sal_op_send_request(op,request);
|
||||
return sal_op_send_request(op,request);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -131,8 +131,7 @@ int sal_register(SalOp *op, const char *proxy, const char *from, int expires){
|
|||
belle_sip_uri_t* req_uri = belle_sip_request_get_uri(req);
|
||||
belle_sip_uri_set_user(req_uri,NULL); /*remove userinfo if any*/
|
||||
|
||||
send_register_request_with_expires(op,req,expires);
|
||||
return 0;
|
||||
return send_register_request_with_expires(op,req,expires);
|
||||
}
|
||||
|
||||
int sal_register_refresh(SalOp *op, int expires){
|
||||
|
|
|
|||
|
|
@ -2427,6 +2427,8 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
|
|||
const char *from=NULL;
|
||||
LinphoneProxyConfig *proxy=NULL,*dest_proxy=NULL;
|
||||
LinphoneAddress *parsed_url2=NULL;
|
||||
SalAddress *route=NULL;
|
||||
SalAddress *proxy_addr=NULL;
|
||||
char *real_url=NULL;
|
||||
LinphoneCall *call;
|
||||
bool_t use_ice = FALSE;
|
||||
|
|
@ -2465,6 +2467,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
|
|||
if (linphone_core_get_route(lc)) {
|
||||
sal_op_set_route(call->op,linphone_core_get_route(lc));
|
||||
}
|
||||
|
||||
/*
|
||||
* rfc3608
|
||||
6.1. Procedures at the UA
|
||||
|
|
@ -2485,7 +2488,27 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
|
|||
sal_op_add_route_address(call->op,linphone_proxy_config_get_service_route(proxy));
|
||||
} /*else, no route*/
|
||||
|
||||
if (!sal_op_get_route(call->op)) {
|
||||
/*still no route, so try to build a route from proxy transport + identity host*/
|
||||
route=sal_address_new(NULL);
|
||||
/*first, get domain and port from requerst uri*/
|
||||
sal_address_set_domain(route,sal_address_get_domain((SalAddress*)addr));
|
||||
sal_address_set_port_int(route,sal_address_get_port_int((SalAddress*)addr));
|
||||
/*next get transport either from request uri or from proxy if any*/
|
||||
if (sal_address_get_transport((SalAddress*)addr)) {
|
||||
sal_address_set_transport(route,sal_address_get_transport((SalAddress*)addr));
|
||||
} else {
|
||||
if (dest_proxy)
|
||||
proxy_addr=sal_address_new(linphone_proxy_config_get_addr(dest_proxy));
|
||||
else if (proxy)
|
||||
proxy_addr=sal_address_new(linphone_proxy_config_get_addr(proxy));
|
||||
if (proxy_addr && sal_address_get_transport(proxy_addr))
|
||||
sal_address_set_transport(route,sal_address_get_transport(proxy_addr));
|
||||
}
|
||||
|
||||
sal_op_add_route_address(call->op,route);
|
||||
|
||||
}
|
||||
|
||||
if(linphone_core_add_call(lc,call)!= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript
|
|||
void linphone_call_update_remote_session_id_and_ver(LinphoneCall *call);
|
||||
|
||||
const char * linphone_core_get_identity(LinphoneCore *lc);
|
||||
const char * linphone_core_get_route(LinphoneCore *lc);
|
||||
|
||||
void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
|
||||
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
|
||||
void linphone_core_stop_waiting(LinphoneCore *lc);
|
||||
|
|
|
|||
|
|
@ -300,6 +300,8 @@ void sal_op_add_route_address(SalOp *op, const SalAddress *address){
|
|||
SalOpBase* op_base = (SalOpBase*)op;
|
||||
if (op_base->route_addresses) {
|
||||
op_base->route_addresses=ms_list_append(op_base->route_addresses,(void*)address);
|
||||
} else {
|
||||
sal_op_set_route_address(op,address);
|
||||
}
|
||||
}
|
||||
void sal_op_set_from(SalOp *op, const char *from){
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@ static void authenticated_register_with_late_credentials(){
|
|||
stats* counters = (stats*)linphone_core_get_user_data(lc);
|
||||
register_with_refresh_base_2(lc,FALSE,auth_domain,NULL,TRUE);
|
||||
CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1);
|
||||
linphone_core_destroy(lc);
|
||||
}
|
||||
|
||||
static LinphoneCore* configure_lc(LinphoneCoreVTable* v_table) {
|
||||
|
|
@ -235,6 +236,32 @@ static void network_state_change(){
|
|||
linphone_core_destroy(lc);
|
||||
}
|
||||
|
||||
static void transport_change(){
|
||||
LinphoneCoreVTable v_table;
|
||||
LinphoneCore* lc;
|
||||
int register_ok;
|
||||
stats* counters ;
|
||||
LCSipTransports sip_tr;
|
||||
LCSipTransports sip_tr_orig;
|
||||
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;
|
||||
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_LinphoneRegistrationFailed,register_ok+2));
|
||||
|
||||
linphone_core_destroy(lc);
|
||||
}
|
||||
|
||||
static void io_recv_error(){
|
||||
LinphoneCoreVTable v_table;
|
||||
LinphoneCore* lc;
|
||||
|
|
@ -248,7 +275,7 @@ static void io_recv_error(){
|
|||
register_ok=counters->number_of_LinphoneRegistrationOk;
|
||||
sal_set_recv_error(lc->sal, 0);
|
||||
|
||||
CU_ASSERT_TRUE_FATAL(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-1 /*because 1 udp*/));
|
||||
sal_set_recv_error(lc->sal, 1); /*reset*/
|
||||
|
||||
linphone_core_destroy(lc);
|
||||
|
|
@ -287,7 +314,9 @@ int register_test_suite () {
|
|||
if (NULL == CU_add_test(pSuite, "multi account", multiple_proxy)) {
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
if (NULL == CU_add_test(pSuite, "transport_change", transport_change)) {
|
||||
return CU_get_error();
|
||||
}
|
||||
if (NULL == CU_add_test(pSuite, "network_state_change", network_state_change)) {
|
||||
return CU_get_error();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue