Skip to content

Commit

Permalink
Add adv_contact ONLY if it is a local contact
Browse files Browse the repository at this point in the history
Extract the outgoing contact and store it as adv_contact ONLY is a self-point contact resulted from Topo Hiding.
  • Loading branch information
bogdan-iancu committed May 14, 2019
1 parent 142957c commit bab898e
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions modules/dialog/dlg_handlers.c
Expand Up @@ -1027,19 +1027,23 @@ static void dlg_onreply_out(struct cell* t, int type, struct tmcb_params *ps)

dlg_update_sdp(dlg, callee_idx(dlg), DLG_CALLER_LEG, msg);

/* extract the contact address */
if (!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0||!msg->contact)){
LM_ERR("There is no contact header in the outgoing 200OK \n");
} else {
contact.s = msg->contact->name.s;
contact.len = msg->contact->len;

if (shm_str_sync(&dlg->legs[DLG_CALLER_LEG].adv_contact,
&contact) != 0) {
LM_ERR("No more shm mem for outgoing contact hdr\n");
free_sip_msg(msg);
pkg_free(msg);
return;
/* save the outgoing contact only if TH */
if (dlg->flags & TOPOH_ONGOING) {
/* extract the adv contact address */
if (!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0 ||
!msg->contact)){
LM_ERR("There is no contact header in the outgoing 200OK \n");
} else {
contact.s = msg->contact->name.s;
contact.len = msg->contact->len;

if (shm_str_sync(&dlg->legs[DLG_CALLER_LEG].adv_contact,
&contact) != 0) {
LM_ERR("No more shm mem for outgoing contact hdr\n");
free_sip_msg(msg);
pkg_free(msg);
return;
}
}
}

Expand Down Expand Up @@ -1193,16 +1197,20 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)

dlg_update_sdp(dlg, DLG_CALLER_LEG, dlg->legs_no[DLG_LEGS_USED], msg);

/* extract the contact address */
if (!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0||!msg->contact)){
LM_ERR("No outgoing contact in the initial INVITE \n");
} else {
contact.s = msg->contact->name.s;
contact.len = msg->contact->len;
/* save the outgoing contact only if TH */
if (dlg->flags & TOPOH_ONGOING) {
/* extract the contact address */
if (!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0 ||
!msg->contact)){
LM_ERR("No outgoing contact in the initial INVITE \n");
} else {
contact.s = msg->contact->name.s;
contact.len = msg->contact->len;

if (shm_str_dup(&leg->adv_contact, &contact) != 0) {
LM_ERR("No more shm for INVITE outgoing contact \n");
goto out_free;
if (shm_str_dup(&leg->adv_contact, &contact) != 0) {
LM_ERR("No more shm for INVITE outgoing contact \n");
goto out_free;
}
}
}

Expand Down

0 comments on commit bab898e

Please sign in to comment.