Commit 047809f6 authored by Simon Morlat's avatar Simon Morlat
Browse files

workaround bug in eXosip with unSUBSCRIBEs.

parent 180a835e
...@@ -302,7 +302,6 @@ static void linphone_friend_unsubscribe(LinphoneFriend *lf){ ...@@ -302,7 +302,6 @@ static void linphone_friend_unsubscribe(LinphoneFriend *lf){
} }
void linphone_friend_close_subscriptions(LinphoneFriend *lf){ void linphone_friend_close_subscriptions(LinphoneFriend *lf){
linphone_friend_notify(lf,LINPHONE_STATUS_OFFLINE);
linphone_friend_unsubscribe(lf); linphone_friend_unsubscribe(lf);
if (lf->insub){ if (lf->insub){
sal_notify_close(lf->insub); sal_notify_close(lf->insub);
......
...@@ -1401,7 +1401,7 @@ extern const char *eXosip_get_version(); ...@@ -1401,7 +1401,7 @@ extern const char *eXosip_get_version();
static void apply_user_agent(LinphoneCore *lc){ static void apply_user_agent(LinphoneCore *lc){
char ua_string[256]; char ua_string[256];
snprintf(ua_string,sizeof(ua_string),"%s/%s (eXosip2/%s)",_ua_name,_ua_version, snprintf(ua_string,sizeof(ua_string)-1,"%s/%s (eXosip2/%s)",_ua_name,_ua_version,
#ifdef HAVE_EXOSIP_GET_VERSION #ifdef HAVE_EXOSIP_GET_VERSION
eXosip_get_version() eXosip_get_version()
#else #else
......
...@@ -158,6 +158,9 @@ void sal_op_release(SalOp *op){ ...@@ -158,6 +158,9 @@ void sal_op_release(SalOp *op){
} }
if (op->nid!=-1){ if (op->nid!=-1){
sal_remove_in_subscribe(op->base.root,op); sal_remove_in_subscribe(op->base.root,op);
if (op->call_id)
osip_call_id_free(op->call_id);
op->call_id=NULL;
} }
if (op->pending_auth){ if (op->pending_auth){
sal_remove_pending_auth(op->base.root,op); sal_remove_pending_auth(op->base.root,op);
...@@ -1135,6 +1138,17 @@ static void other_request(Sal *sal, eXosip_event_t *ev){ ...@@ -1135,6 +1138,17 @@ static void other_request(Sal *sal, eXosip_event_t *ev){
} }
} }
static void masquerade_via(osip_message_t *msg, const char *ip, const char *port){
osip_via_t *via=NULL;
osip_message_get_via(msg,0,&via);
if (via){
osip_free(via->port);
via->port=osip_strdup(port);
osip_free(via->host);
via->host=osip_strdup(ip);
}
}
static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){
osip_message_t *msg; osip_message_t *msg;
const char *received; const char *received;
...@@ -1173,6 +1187,7 @@ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *ori ...@@ -1173,6 +1187,7 @@ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *ori
} }
snprintf(port,sizeof(port),"%i",rport); snprintf(port,sizeof(port),"%i",rport);
ctt->url->port=osip_strdup(port); ctt->url->port=osip_strdup(port);
masquerade_via(msg,received,port);
eXosip_register_send_register(op->rid,msg); eXosip_register_send_register(op->rid,msg);
eXosip_unlock(); eXosip_unlock();
osip_contact_to_str(ctt,&tmp); osip_contact_to_str(ctt,&tmp);
......
...@@ -49,7 +49,19 @@ static SalOp * sal_find_in_subscribe(Sal *sal, int nid){ ...@@ -49,7 +49,19 @@ static SalOp * sal_find_in_subscribe(Sal *sal, int nid){
return NULL; return NULL;
} }
static void sal_add_in_subscribe(Sal *sal, SalOp *op){ static SalOp * sal_find_in_subscribe_by_call_id(Sal *sal, osip_call_id_t *call_id){
const MSList *elem;
SalOp *op;
for(elem=sal->in_subscribes;elem!=NULL;elem=elem->next){
op=(SalOp*)elem->data;
if (op->call_id && osip_call_id_match(op->call_id,call_id)==0)
return op;
}
return NULL;
}
static void sal_add_in_subscribe(Sal *sal, SalOp *op, osip_message_t *subs){
osip_call_id_clone(subs->call_id,&op->call_id);
sal->in_subscribes=ms_list_append(sal->in_subscribes,op); sal->in_subscribes=ms_list_append(sal->in_subscribes,op);
} }
...@@ -423,6 +435,7 @@ int sal_notify_close(SalOp *op){ ...@@ -423,6 +435,7 @@ int sal_notify_close(SalOp *op){
const char *identity=sal_op_get_contact(op); const char *identity=sal_op_get_contact(op);
if (identity==NULL) identity=sal_op_get_to(op); if (identity==NULL) identity=sal_op_get_to(op);
osip_message_set_contact(msg,identity); osip_message_set_contact(msg,identity);
add_presence_body(msg,SalPresenceOffline);
eXosip_insubscription_send_request(op->did,msg); eXosip_insubscription_send_request(op->did,msg);
}else ms_error("sal_notify_close(): could not create notify for incoming subscription" }else ms_error("sal_notify_close(): could not create notify for incoming subscription"
" did=%i, nid=%i",op->did,op->nid); " did=%i, nid=%i",op->did,op->nid);
...@@ -582,7 +595,7 @@ int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus p ...@@ -582,7 +595,7 @@ int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus p
return 0; return 0;
} }
void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){ static void _sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){
SalOp *op=sal_op_new(sal); SalOp *op=sal_op_new(sal);
char *tmp; char *tmp;
op->did=ev->did; op->did=ev->did;
...@@ -594,10 +607,26 @@ void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){ ...@@ -594,10 +607,26 @@ void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){
osip_from_to_str(ev->request->to,&tmp); osip_from_to_str(ev->request->to,&tmp);
sal_op_set_to(op,tmp); sal_op_set_to(op,tmp);
ms_free(tmp); ms_free(tmp);
sal_add_in_subscribe(sal,op); sal_add_in_subscribe(sal,op,ev->request);
sal->callbacks.subscribe_received(op,sal_op_get_from(op)); sal->callbacks.subscribe_received(op,sal_op_get_from(op));
} }
void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){
/*workaround a bug in eXosip: incoming SUBSCRIBES within dialog with expires: 0 are
recognized as new incoming subscribes*/
SalOp *op=sal_find_in_subscribe_by_call_id(sal,ev->request->call_id);
if (op){
osip_header_t *h;
osip_message_header_get_byname(ev->request,"expires",0,&h);
if (h && h->hvalue && atoi(h->hvalue)==0){
ms_warning("This susbscribe is not a new one but terminates an old one.");
ev->did=op->did;
ev->nid=op->nid;
sal_exosip_subscription_closed(sal,ev);
}else ms_warning("Probably a refresh subscribe");
}else _sal_exosip_subscription_recv(sal,ev);
}
void sal_exosip_notify_recv(Sal *sal, eXosip_event_t *ev){ void sal_exosip_notify_recv(Sal *sal, eXosip_event_t *ev){
SalOp *op=sal_find_out_subscribe(sal,ev->sid); SalOp *op=sal_find_out_subscribe(sal,ev->sid);
char *tmp; char *tmp;
......
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