]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10617: [mod_sofia] Nightmare transfer: expose remote server's channel UUIDs as...
authorHristo Trendev <htrendev@gmail.com>
Tue, 22 Aug 2017 13:41:05 +0000 (15:41 +0200)
committerHristo Trendev <htrendev@gmail.com>
Mon, 28 Aug 2017 11:38:45 +0000 (13:38 +0200)
Currently there is no easy way for ESL and dial plan users to easily correlate
the channel UUID of the call legs involved in a nightmare transfer. This patch
adds two new channel variables, which are set to the remote server call leg
UUIDs (transfer_refer_from, transfer_refer_for).

The UUIDs are passed from the remote server in custom headers (X-FS-Refer-From
and X-FS-Refer-For).

src/mod/endpoints/mod_sofia/sofia.c

index b9f52d8fadf21a57ed0f243c0d4c08a38912e338..758435d15d71046b9546007d50a529334bd99ede 100644 (file)
@@ -9288,6 +9288,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
                                                        }
                                                }
 
+                                               switch_event_add_header_string(nightmare_xfer_helper->vars, SWITCH_STACK_BOTTOM, "sip_h_X-FS-Refer-From", switch_core_session_get_uuid(session));
+                                               switch_event_add_header_string(nightmare_xfer_helper->vars, SWITCH_STACK_BOTTOM, "sip_h_X-FS-Refer-For", br_a);
+
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Good Luck, you'll need it......\n");
                                                launch_nightmare_xfer(nightmare_xfer_helper);
 
@@ -11104,6 +11107,8 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                        }
                                } else {
                                        char const *a_leg = NULL;
+                                       char const *nightmare_xfer_uuid = NULL;
+
                                    switch_event_t *event = NULL;
                                        if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id) {
                                                a_leg = msg_header_find_param(sip->sip_replaces->rp_common, "a-leg");
@@ -11119,6 +11124,13 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                                        switch_event_fire(&event);
                                                }
                                        } else {
+                                               if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-For"))) {
+                                                       switch_channel_set_variable(b_channel, "transfer_refer_for", nightmare_xfer_uuid);
+                                               }
+                                               if ((nightmare_xfer_uuid = sofia_glue_get_unknown_header(sip, "X-FS-Refer-From"))) {
+                                                       switch_channel_set_variable(b_channel, "transfer_refer_from", nightmare_xfer_uuid);
+                                               }
+
                                                if (!zstr(bridge_uuid)) {
                                                        if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id && switch_channel_test_flag(b_channel, CF_BRIDGED) &&
                                                                switch_true(switch_find_parameter(*(sip->sip_replaces->rp_params), "early-only", switch_core_session_get_pool(session)))) {