Commit 2ebd2f08 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix un-authentified SUBSCRIBE request

parent 58b733a4
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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){
......
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