Skip to content

Commit

Permalink
Use public address for outgoing responses' contact header
Browse files Browse the repository at this point in the history
The public address haven't been used for responses.

Issue-Id: #4047
  • Loading branch information
wosrediinanatour committed Aug 20, 2024
1 parent 0c6b9fb commit 34b167b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion pjmedia/src/pjmedia/transport_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ pjmedia_transport_loop_create2(pjmedia_endpt *endpt,
if (status != PJ_SUCCESS)
return status;

tp->base.grp_lock = grp_lock;
pj_grp_lock_add_ref(grp_lock);
pj_grp_lock_add_handler(grp_lock, pool, tp, &tp_loop_on_destroy);

Expand Down
22 changes: 21 additions & 1 deletion pjsip/src/pjsua-lib/pjsua_acc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3923,7 +3923,7 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
pjsua_init_tpselector(acc_id, &tp_sel);
}

/* Get local address suitable to send request from */
/* Get local address suitable to send response from */
pjsip_tpmgr_fla2_param_default(&tfla2_prm);
tfla2_prm.tp_type = tp_type;
tfla2_prm.tp_sel = &tp_sel;
Expand All @@ -3940,6 +3940,26 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
local_addr = tfla2_prm.ret_addr;
local_port = tfla2_prm.ret_port;

/* For UDP transport, check if we need to overwrite the address
* with its configured bound/public address.
*/
if ((flag & PJSIP_TRANSPORT_DATAGRAM) && tfla2_prm.local_if &&
tfla2_prm.ret_tp)
{
int i;

for (i = 0; i < (int)PJ_ARRAY_SIZE(pjsua_var.tpdata); i++) {
if (tfla2_prm.ret_tp==(const void *)pjsua_var.tpdata[i].data.tp) {
if (pjsua_var.tpdata[i].has_cfg_addr) {
pj_strdup(pool, &local_addr,
&pjsua_var.tpdata[i].data.tp->local_name.host);
local_port = (pj_uint16_t)
pjsua_var.tpdata[i].data.tp->local_name.port;
}
break;
}
}
}

/* Enclose IPv6 address in square brackets */
if (tp_type & PJSIP_TRANSPORT_IPV6) {
Expand Down

0 comments on commit 34b167b

Please sign in to comment.