more nat stuff

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8488 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2008-05-20 16:41:57 +00:00
parent 83e6642391
commit 2848cfdd18
4 changed files with 135 additions and 51 deletions

View File

@@ -985,12 +985,22 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
if (code == 407 && !msg->numeric_arg) {
const char *to_uri = switch_channel_get_variable(channel, "sip_to_uri");
const char *to_host = reason;
const char *val;
const char *sticky = NULL;
if (switch_test_flag(tech_pvt, TFLAG_NAT) ||
(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
sticky = tech_pvt->record_route;
switch_channel_set_variable(channel, "sip_nat_detected", "true");
}
if (switch_strlen_zero(to_host)) {
to_host = switch_channel_get_variable(channel, "sip_to_host");
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Challenging call %s\n", to_uri);
sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0);
sofia_reg_auth_challange(NULL, tech_pvt->profile, tech_pvt->nh, REG_INVITE, to_host, 0, sticky);
switch_channel_hangup(channel, SWITCH_CAUSE_USER_CHALLENGE);
} else if (code == 484 && msg->numeric_arg) {
const char *to = switch_channel_get_variable(channel, "sip_to_uri");