From c019e89de8322549b99856e0c7c243780d44d6e9 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 10 Nov 2009 03:45:42 +0000 Subject: Ticket #864: Revise on account registration Contact update rule - don't switch if only port number is different and the Via received address is private - always update the transport (i.e. Via) address as well git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3001 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_acc.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 26ff39a7..4321d752 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -687,6 +687,19 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc, return PJ_FALSE; } + /* Also don't switch if only the port number part is different, and + * the Via received address is private. + * See http://trac.pjsip.org/repos/ticket/864 + */ + if (acc->cfg.allow_contact_rewrite != 2 && + pj_sockaddr_cmp(&contact_addr, &recv_addr)==0 && + is_private_ip(via_addr)) + { + /* Don't switch */ + pj_pool_release(pool); + return PJ_FALSE; + } + PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d " "(%.*s:%d --> %.*s:%d). Updating registration..", acc->index, @@ -743,16 +756,9 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc, pj_strdup2_with_null(acc->pool, &acc->contact, tmp); } - /* For UDP transport, if STUN is enabled then update the transport's - * published name as well. - */ - if (tp->key.type==PJSIP_TRANSPORT_UDP && - (pjsua_var.ua_cfg.stun_domain.slen != 0 || - pjsua_var.ua_cfg.stun_host.slen != 0)) - { - pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr); - tp->local_name.port = rport; - } + /* Always update, by http://trac.pjsip.org/repos/ticket/864. */ + pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr); + tp->local_name.port = rport; /* Perform new registration */ pjsua_acc_set_registration(acc->index, PJ_TRUE); -- cgit v1.2.3