Commit b382cb6e authored by Simon Morlat's avatar Simon Morlat
Browse files

improve NAT friendlyness (use received/rport from 4xx answers to OPTIONS), and...

improve NAT friendlyness (use received/rport from 4xx answers to OPTIONS), and in last resort, default proxy fixed contact address.
parent b289e74d
......@@ -1851,14 +1851,7 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr
if (call->op && sal_op_get_contact(call->op)!=NULL){
return NULL;
}
/*if using a proxy, use the contact address as guessed with the REGISTERs*/
if (dest_proxy && dest_proxy->op){
const char *fixed_contact=sal_op_get_contact(dest_proxy->op);
if (fixed_contact) {
ms_message("Contact has been fixed using proxy to %s",fixed_contact);
return ms_strdup(fixed_contact);
}
}
/* if the ping OPTIONS request succeeded use the contact guessed from the
received, rport*/
if (call->ping_op){
......@@ -1868,6 +1861,15 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr
return ms_strdup(guessed);
}
}
/*if using a proxy, use the contact address as guessed with the REGISTERs*/
if (dest_proxy && dest_proxy->op){
const char *fixed_contact=sal_op_get_contact(dest_proxy->op);
if (fixed_contact) {
ms_message("Contact has been fixed using proxy to %s",fixed_contact);
return ms_strdup(fixed_contact);
}
}
ctt=linphone_core_get_primary_contact_parsed(lc);
......@@ -2342,6 +2344,7 @@ void linphone_core_stop_media_streams(LinphoneCore *lc, LinphoneCall *call){
int linphone_core_accept_call(LinphoneCore *lc, const char *url)
{
LinphoneCall *call=lc->call;
LinphoneProxyConfig *cfg=NULL;
const char *contact=NULL;
if (call==NULL){
......@@ -2360,9 +2363,10 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url)
ms_message("ring stopped");
lc->ringstream=NULL;
}
linphone_core_get_default_proxy(lc,&cfg);
/*try to be best-effort in giving real local or routable contact address*/
contact=get_fixed_contact(lc,call,NULL);
contact=get_fixed_contact(lc,call,cfg);
if (contact)
sal_op_set_contact(call->op,contact);
......
......@@ -872,17 +872,19 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
}
static void call_terminated(Sal *sal, eXosip_event_t *ev){
char *from;
char *from=NULL;
SalOp *op=find_op(sal,ev);
if (op==NULL){
ms_warning("Call terminated for already closed call ?");
return;
}
osip_from_to_str(ev->request->from,&from);
if (ev->request){
osip_from_to_str(ev->request->from,&from);
}
sal_remove_call(sal,op);
op->cid=-1;
sal->callbacks.call_terminated(op,from);
osip_free(from);
sal->callbacks.call_terminated(op,from!=NULL ? from : sal_op_get_from(op));
if (from) osip_free(from);
}
static void call_released(Sal *sal, eXosip_event_t *ev){
......@@ -1399,7 +1401,8 @@ static void other_request_reply(Sal *sal,eXosip_event_t *ev){
}
if (ev->response){
update_contact_from_response(op,ev->response);
sal->callbacks.ping_reply(op);
if (ev->request && strcmp(osip_message_get_method(ev->request),"OPTIONS")==0)
sal->callbacks.ping_reply(op);
}
}
......@@ -1517,6 +1520,7 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){
if (ev->response && (ev->response->status_code == 407 || ev->response->status_code == 401)){
return process_authentication(sal,ev);
}
other_request_reply(sal,ev);
break;
default:
ms_message("Unhandled exosip event ! %i",ev->type);
......
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