]> sjero.net Git - linphone/commitdiff
fix un-authentified SUBSCRIBE request
authorSimon Morlat <simon.morlat@linphone.org>
Thu, 14 Oct 2010 07:54:49 +0000 (09:54 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Thu, 14 Oct 2010 07:54:49 +0000 (09:54 +0200)
coreapi/sal.h
coreapi/sal_eXosip2.c
coreapi/sal_eXosip2.h
coreapi/sal_eXosip2_presence.c

index 9f97c52391a7e92a0af6b6e4bd7e120f60ce13b2..0fcd6e5a875c90e469f769914fb84b2bc4ca1f9e 100644 (file)
@@ -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);
index a7fa26b16ebec372e8f14eb86bd116ab9e15b2a3..0db619d0b4b1afaa728958d2f2b947791e112492 100644 (file)
@@ -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;
index 5f2c681d1e72847f384e03fcb7e0ef361d1d1846..88afb1c21773aac2c3457107a4f20facde8a7ac0 100644 (file)
@@ -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);
 
 
index a38fdf91b8b51f028ba4ec34e50336fbd6c58cb5..bf94edcb3f562ecdd9755239ae2b02b494f7b96e 100644 (file)
@@ -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){