summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2012-06-28 14:16:05 +0000
committerLiong Sauw Ming <ming@teluu.com>2012-06-28 14:16:05 +0000
commitdc0be8ac4914a91e999d88d625b14e5ccfa9090d (patch)
treeb3a2c5b81b3999132fb3549f00e8188c2e3c821f /pjsip
parent9eb13e2a670fd4a2bbabca475b76576230e5aec7 (diff)
Re #1537: Modify NAT detection to no longer update the transport address.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4185 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index dd816eb1..28acf6ee 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -1341,16 +1341,33 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc,
tp = param->rdata->tp_info.transport;
- /* If allow_via_rewrite is enabled, we save the Via "sent-by" address
+ /* Get the received and rport info */
+ via = param->rdata->msg_info.via;
+ if (via->rport_param < 1) {
+ /* Remote doesn't support rport */
+ rport = via->sent_by.port;
+ if (rport==0) {
+ pjsip_transport_type_e tp_type;
+ tp_type = (pjsip_transport_type_e) tp->key.type;
+ rport = pjsip_transport_get_default_port_for_type(tp_type);
+ }
+ } else
+ rport = via->rport_param;
+
+ if (via->recvd_param.slen != 0)
+ via_addr = &via->recvd_param;
+ else
+ via_addr = &via->sent_by.host;
+
+ /* If allow_via_rewrite is enabled, we save the Via "received" address
* from the response.
*/
if (acc->cfg.allow_via_rewrite &&
(acc->via_addr.host.slen == 0 || acc->via_tp != tp))
{
- via = param->rdata->msg_info.via;
- if (pj_strcmp(&acc->via_addr.host, &via->sent_by.host))
- pj_strdup(acc->pool, &acc->via_addr.host, &via->sent_by.host);
- acc->via_addr.port = via->sent_by.port;
+ if (pj_strcmp(&acc->via_addr.host, via_addr))
+ pj_strdup(acc->pool, &acc->via_addr.host, via_addr);
+ acc->via_addr.port = rport;
acc->via_tp = tp;
pjsip_regc_set_via_sent_by(acc->regc, &acc->via_addr, acc->via_tp);
if (acc->publish_sess != NULL) {
@@ -1389,24 +1406,6 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc,
}
#endif
- /* Get the received and rport info */
- via = param->rdata->msg_info.via;
- if (via->rport_param < 1) {
- /* Remote doesn't support rport */
- rport = via->sent_by.port;
- if (rport==0) {
- pjsip_transport_type_e tp_type;
- tp_type = (pjsip_transport_type_e) tp->key.type;
- rport = pjsip_transport_get_default_port_for_type(tp_type);
- }
- } else
- rport = via->rport_param;
-
- if (via->recvd_param.slen != 0)
- via_addr = &via->recvd_param;
- else
- via_addr = &via->sent_by.host;
-
/* Compare received and rport with the URI in our registration */
pool = pjsua_pool_create("tmp", 512, 512);
contact_hdr = (pjsip_contact_hdr*)
@@ -1553,8 +1552,14 @@ static pj_bool_t acc_check_nat_addr(pjsua_acc *acc,
update_regc_contact(acc);
/* Always update, by http://trac.pjsip.org/repos/ticket/864. */
+ /* Since the Via address will now be overwritten to the correct
+ * address by https://trac.pjsip.org/repos/ticket/1537, we do
+ * not need to update the transport address.
+ */
+ /*
pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr);
tp->local_name.port = rport;
+ */
}