From fcf4cf44b20102597314c35cdcc28508ba93f641 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 2 Feb 2011 12:33:46 +0100 Subject: [PATCH] prevent double registration by config --- coreapi/linphonecore.c | 1 + coreapi/sal.h | 1 + coreapi/sal_eXosip2.c | 8 ++++++++ coreapi/sal_eXosip2.h | 1 + 4 files changed, 11 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index db2548a84..4490bf451 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -575,6 +575,7 @@ static void sip_config_read(LinphoneCore *lc) lc->sip_conf.keepalive_period=lp_config_get_int(lc->config,"sip","keepalive_period",10000); sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period); sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0)); + sal_use_double_registrations(lc->sal,lp_config_get_int(lc->config,"sip","use_double_registrations",1)); } static void rtp_config_read(LinphoneCore *lc) diff --git a/coreapi/sal.h b/coreapi/sal.h index f20555b0a..2f39c697c 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -257,6 +257,7 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value); * */ unsigned int sal_get_keepalive_period(Sal *ctx); void sal_use_session_timers(Sal *ctx, int expires); +void sal_use_double_registrations(Sal *ctx, bool_t enabled); void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec); int sal_iterate(Sal *sal); MSList * sal_get_pending_auths(Sal *sal); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index b993d88bd..6c10d4c89 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -264,6 +264,7 @@ Sal * sal_init(){ eXosip_init(); sal=ms_new0(Sal,1); sal->keepalive_period=30; + sal->double_reg=TRUE; return sal; } @@ -393,6 +394,10 @@ MSList *sal_get_pending_auths(Sal *sal){ return ms_list_copy(sal->pending_auths); } +void sal_use_double_registrations(Sal *ctx, bool_t enabled){ + ctx->double_reg=enabled; +} + static int extract_received_rport(osip_message_t *msg, const char **received, int *rportval){ osip_via_t *via=NULL; osip_generic_param_t *param=NULL; @@ -1552,6 +1557,9 @@ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *ori char *tmp; char port[20]; SalAddress *addr; + Sal *sal=op->base.root; + + if (sal->double_reg==FALSE) return FALSE; if (extract_received_rport(last_answer,&received,&rport)==-1) return FALSE; osip_message_get_contact(orig_request,0,&ctt); diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 7d50ae823..c60a81281 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -41,6 +41,7 @@ struct Sal{ int keepalive_period; void *up; bool_t one_matching_codec; + bool_t double_reg; }; struct SalOp{