diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2014-10-10 10:33:23 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2014-10-10 10:33:23 +0000 |
commit | c8df8abb353e06c805369f52e376b51632cd8077 (patch) | |
tree | a9ac24c6ced248cab34206c6ec68bbbf3290ac45 /pjsip/src/pjsua-lib | |
parent | 21e715c8632cd2e3b77d1c46ee574249b05560b2 (diff) |
Fixed #1796: Avoid infinite registration loop caused by contact rewrite.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4944 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_acc.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index 27aa72d2..0cb4801c 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -2092,7 +2092,12 @@ static void regc_tsx_cb(struct pjsip_regc_tsx_cb_param *param) pj_log_push_indent(); - if ((acc->cfg.contact_rewrite_method & + /* Check if we should do NAT bound address check for contact rewrite. + * Note that '!contact_rewritten' check here is to avoid overriding + * the current contact generated from last 2xx. + */ + if (!acc->contact_rewritten && + (acc->cfg.contact_rewrite_method & PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE) == PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE && param->cbparam.code >= 400 && @@ -2103,6 +2108,10 @@ static void regc_tsx_cb(struct pjsip_regc_tsx_cb_param *param) { param->contact_cnt = 1; param->contact[0] = acc->reg_contact; + + /* Don't set 'contact_rewritten' to PJ_TRUE here to allow + * further check of NAT bound address in 2xx response. + */ } } @@ -2177,12 +2186,16 @@ static void regc_cb(struct pjsip_regc_cbparam *param) */ update_rfc5626_status(acc, param->rdata); - /* Check NAT bound address */ - if (acc_check_nat_addr(acc, (acc->cfg.contact_rewrite_method & 3), + /* Check NAT bound address if it hasn't been done before */ + if (!acc->contact_rewritten && + acc_check_nat_addr(acc, (acc->cfg.contact_rewrite_method & 3), param)) { PJSUA_UNLOCK(); pj_log_pop_indent(); + + /* Avoid another check of NAT bound address */ + acc->contact_rewritten = PJ_TRUE; return; } @@ -2216,6 +2229,9 @@ static void regc_cb(struct pjsip_regc_cbparam *param) acc->reg_last_err = param->status; acc->reg_last_code = param->code; + /* Reaching this point means no contact rewrite, so reset the flag */ + acc->contact_rewritten = PJ_FALSE; + /* Check if we need to auto retry registration. Basically, registration * failure codes triggering auto-retry are those of temporal failures * considered to be recoverable in relatively short term. |