diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 98271d3d95..cd9259fccb 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -317,7 +317,7 @@ static switch_status_t sofia_answer_channel(switch_core_session_t *session) } nua_respond(tech_pvt->nh, SIP_200_OK, - SIPTAG_CONTACT_STR(tech_pvt->to_uri), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); } @@ -680,7 +680,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi sofia_glue_set_local_sdp(tech_pvt, ip, atoi(port), msg->string_arg, 1); } nua_respond(tech_pvt->nh, SIP_200_OK, - SIPTAG_CONTACT_STR(tech_pvt->to_uri), + SIPTAG_CONTACT_STR(tech_pvt->reply_contact), SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END()); switch_channel_mark_answered(channel); } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 25b473c525..3d0a5d1d27 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -114,6 +114,11 @@ typedef enum { PFLAG_RESPAWN = (1 << 9) } PFLAGS; + +typedef enum { + PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 1) +} sofia_NDLB_t; + typedef enum { TFLAG_IO = (1 << 0), TFLAG_CHANGE_MEDIA = (1 << 1), @@ -223,6 +228,7 @@ struct sofia_profile { int dtmf_duration; unsigned int flags; unsigned int pflags; + unsigned int ndlb; uint32_t max_calls; uint32_t nonce_ttl; nua_t *nua; @@ -287,6 +293,7 @@ struct private_object { switch_port_t adv_sdp_audio_port; char *proxy_sdp_audio_ip; switch_port_t proxy_sdp_audio_port; + char *reply_contact; char *from_uri; char *to_uri; char *from_address; diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 40027da779..511dbcc97d 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -789,6 +789,10 @@ switch_status_t config_sofia(int reload, char *profile_name) if (switch_true(val)) { profile->pflags |= PFLAG_PRESENCE; } + } else if (!strcasecmp(var, "NDLB-to-in-200-contact")) { + if (switch_true(val)) { + profile->ndlb |= PFLAG_NDLB_TO_IN_200_CONTACT; + } } else if (!strcasecmp(var, "pass-rfc2833")) { if (switch_true(val)) { profile->pflags |= PFLAG_PASS_RFC2833; @@ -1837,8 +1841,14 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ url_set_chanvars(session, sip->sip_to->a_url, sip_to); if ((val = switch_channel_get_variable(channel, "sip_to_uri"))) { tech_pvt->to_uri = switch_core_session_sprintf(session, "sip:%s", val); + if (profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) { + tech_pvt->reply_contact = tech_pvt->to_uri; + } else { + tech_pvt->reply_contact = tech_pvt->profile->url; + } } else { tech_pvt->to_uri = tech_pvt->profile->url; + tech_pvt->reply_contact = tech_pvt->profile->url; } } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 5a60aae4d9..7fdd67088f 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -365,7 +365,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han } if (v_event && *v_event && (v_contact_str = switch_event_get_header(*v_event, "force-contact"))) { - if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction")) { + if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-connectile-dysfunction")) { if (contact->m_url->url_params) { snprintf(contact_str, sizeof(contact_str), "%s ", display, contact->m_url->url_user, network_ip, network_port, contact->m_url->url_params);