]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10407: [mod_sofia] Set redirect variables when outbound_redirect_fatal is true
authorHristo Trendev <htrendev@gmail.com>
Tue, 20 Jun 2017 13:30:32 +0000 (15:30 +0200)
committerHristo Trendev <htrendev@gmail.com>
Wed, 21 Jun 2017 07:25:23 +0000 (09:25 +0200)
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

index 2919a129df6fae580f18fad95ebb54a965f9be47..647ccf35d7d4b6c6833e37bb05d9b362b43d5297 100644 (file)
@@ -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;
                        }