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 15fdec8 commit fde0552
Showing 1 changed file with 21 additions and 1 deletion.
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 @@ -3904,7 +3904,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 @@ -3921,6 +3921,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 fde0552

Please sign in to comment.