From 1d15e411f9f5b6c8883cda47534cc1e9c3a77f95 Mon Sep 17 00:00:00 2001 From: Hristo Trendev <htrendev@gmail.com> Date: Tue, 20 Jun 2017 15:30:32 +0200 Subject: [PATCH] FS-10407: [mod_sofia] Set redirect variables when outbound_redirect_fatal is true In case of outbound_redirect_fatal=true none of the redirect variables are set. This makes it impossible for ESL applications to extract any information related to the "302 Moved Temporarily" reply. --- src/mod/endpoints/mod_sofia/sofia.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 2919a129df..647ccf35d7 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -6607,6 +6607,42 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status const char *v; if ((v = switch_channel_get_variable(channel, "outbound_redirect_fatal")) && switch_true(v)) { + su_home_t *home = su_home_new(sizeof(*home)); + switch_assert(home != NULL); + + for (p_contact = sip->sip_contact; p_contact; p_contact = p_contact->m_next) { + full_contact = sip_header_as_string(home, (void *) p_contact); + invite_contact = sofia_glue_strip_uri(full_contact); + + switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_%d", i); + switch_channel_set_variable(channel, var_name, full_contact); + + if (i == 0) { + switch_channel_set_variable(channel, "sip_redirected_to", full_contact); + } + + if (p_contact->m_url->url_user) { + switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_user_%d", i); + switch_channel_set_variable(channel, var_name, p_contact->m_url->url_user); + } + if (p_contact->m_url->url_host) { + switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_host_%d", i); + switch_channel_set_variable(channel, var_name, p_contact->m_url->url_host); + } + if (p_contact->m_url->url_params) { + switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_params_%d", i); + switch_channel_set_variable(channel, var_name, p_contact->m_url->url_params); + } + + free(invite_contact); + i++; + } + if (home) { + su_home_unref(home); + home = NULL; + } + switch_snprintf(var_name, sizeof(var_name), "sip:%d", status); + switch_channel_set_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, var_name); switch_channel_hangup(channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL); goto end; }