increase compat on NDLB-to-in-200-contact to handle NAT

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13759 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-06-11 17:17:52 +00:00
parent 9ea470710d
commit 2eac35df99

View File

@ -4758,7 +4758,8 @@ 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); url_set_chanvars(session, sip->sip_to->a_url, sip_to);
if (switch_channel_get_variable(channel, "sip_to_uri")) { if (switch_channel_get_variable(channel, "sip_to_uri")) {
const char *ipv6; const char *ipv6;
const char *url = NULL;
host = switch_channel_get_variable(channel, "sip_to_host"); host = switch_channel_get_variable(channel, "sip_to_host");
user = switch_channel_get_variable(channel, "sip_to_user"); user = switch_channel_get_variable(channel, "sip_to_user");
@ -4783,37 +4784,33 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
port, port,
sofia_glue_transport2str(transport)); sofia_glue_transport2str(transport));
if (profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) { if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
if (strchr(tech_pvt->to_uri, '>')) { url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_public_url : profile->public_url;
tech_pvt->reply_contact = tech_pvt->to_uri; } else {
} else { url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s>", tech_pvt->to_uri); }
}
} else { if ((profile->ndlb & PFLAG_NDLB_TO_IN_200_CONTACT) || sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) { char *at;
tech_pvt->reply_contact = switch_core_session_sprintf(session, "<sip:%s@%s>", user, host); char *tmp = sofia_overcome_sip_uri_weakness(session, url, transport, SWITCH_TRUE, NULL);
} else { if ((at = strchr(tmp, '@'))) {
const char *url = NULL; url = switch_core_session_sprintf(session, "sip:%s%s", user, at);
if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_public_url : profile->public_url;
} else {
url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
}
if (url) {
if (strchr(url, '>')) {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url,
sofia_glue_transport2str(transport));
} else {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url,
sofia_glue_transport2str(transport));
}
} else {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
} }
} }
if (url) {
if (strchr(url, '>')) {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s;transport=%s", url,
sofia_glue_transport2str(transport));
} else {
tech_pvt->reply_contact = switch_core_session_sprintf(session, "<%s;transport=%s>", url,
sofia_glue_transport2str(transport));
}
} else {
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
} else { } else {
const char *url = NULL; const char *url = NULL;
if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) { if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {