From: Simon Morlat Date: Thu, 14 Oct 2010 07:54:49 +0000 (+0200) Subject: fix un-authentified SUBSCRIBE request X-Git-Url: http://sjero.net/git/?p=linphone;a=commitdiff_plain;h=2ebd2f08d31f132ce1cd585a8aef50e64e9bce67 fix un-authentified SUBSCRIBE request --- diff --git a/coreapi/sal.h b/coreapi/sal.h index 9f97c523..0fcd6e5a 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -284,6 +284,8 @@ int sal_call_update(SalOp *h); SalMediaDescription * sal_call_get_final_media_description(SalOp *h); int sal_refer(SalOp *h, const char *refer_to); int sal_refer_accept(SalOp *h); +/* returns the SalOp of a call that should be replaced by h, if any */ +SalOp *sal_call_get_replaces(SalOp *h); int sal_call_send_dtmf(SalOp *h, char dtmf); int sal_call_terminate(SalOp *h); bool_t sal_call_autoanswer_asked(SalOp *op); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index a7fa26b1..0db619d0 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -161,6 +161,7 @@ SalOp * sal_op_new(Sal *sal){ op->sdp_answer=NULL; op->reinvite=FALSE; op->call_id=NULL; + op->replaces=NULL; op->masquerade_via=FALSE; op->auto_answer_asked=FALSE; return op; @@ -201,6 +202,9 @@ void sal_op_release(SalOp *op){ sal_remove_other(op->base.root,op); osip_call_id_free(op->call_id); } + if (op->replaces){ + ms_free(op->replaces); + } __sal_op_free(op); } @@ -655,6 +659,20 @@ int sal_refer(SalOp *h, const char *refer_to){ return err; } +SalOp *sal_call_get_replaces(SalOp *h){ + if (h->replaces!=NULL){ + int cid; + eXosip_lock(); + cid=eXosip_call_find_by_replaces(h->replaces); + eXosip_unlock(); + if (cid>0){ + SalOp *ret=sal_find_call(h->base.root,cid); + return ret; + } + } + return NULL; +} + int sal_call_send_dtmf(SalOp *h, char dtmf){ osip_message_t *msg=NULL; char dtmf_body[128]; @@ -732,6 +750,21 @@ static void set_remote_ua(SalOp* op, osip_message_t *req){ } } +static void set_replaces(SalOp *op, osip_message_t *req){ + osip_header_t *h=NULL; + + if (op->replaces){ + ms_free(op->replaces); + op->replaces=NULL; + } + osip_message_header_get_byname(req,"replaces",0,&h); + if (h){ + if (h->hvalue && h->hvalue[0]!='\0'){ + op->replaces=ms_strdup(h->hvalue); + } + } +} + static SalOp *find_op(Sal *sal, eXosip_event_t *ev){ if (ev->cid>0){ return sal_find_call(sal,ev->cid); @@ -739,6 +772,9 @@ static SalOp *find_op(Sal *sal, eXosip_event_t *ev){ if (ev->rid>0){ return sal_find_register(sal,ev->rid); } + if (ev->sid>0){ + return sal_find_out_subscribe(sal,ev->sid); + } if (ev->response) return sal_find_other(sal,ev->response); return NULL; } @@ -752,6 +788,7 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){ set_network_origin(op,ev->request); set_remote_ua(op,ev->request); + set_replaces(op,ev->request); if (sdp){ op->sdp_offering=FALSE; diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 5f2c681d..88afb1c2 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -56,6 +56,7 @@ struct SalOp{ eXosip_event_t *pending_auth; osip_call_id_t *call_id; /*used for out of calls transaction in order to retrieve the operation when receiving a response*/ + char *replaces; bool_t supports_session_timers; bool_t sdp_offering; bool_t reinvite; @@ -72,7 +73,7 @@ void sal_exosip_notify_recv(Sal *sal,eXosip_event_t *ev); void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev); void sal_exosip_in_subscription_closed(Sal *sal, eXosip_event_t *ev); - +SalOp * sal_find_out_subscribe(Sal *sal, int sid); void sal_exosip_fix_route(SalOp *op); diff --git a/coreapi/sal_eXosip2_presence.c b/coreapi/sal_eXosip2_presence.c index a38fdf91..bf94edcb 100644 --- a/coreapi/sal_eXosip2_presence.c +++ b/coreapi/sal_eXosip2_presence.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sal_eXosip2.h" -static SalOp * sal_find_out_subscribe(Sal *sal, int sid){ +SalOp * sal_find_out_subscribe(Sal *sal, int sid){ const MSList *elem; SalOp *op; for(elem=sal->out_subscribes;elem!=NULL;elem=elem->next){