]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7463 #resolve
authorLuis Azedo <luis@2600hz.com>
Mon, 1 Jun 2015 19:11:40 +0000 (20:11 +0100)
committerLuis Azedo <luis@2600hz.com>
Mon, 1 Jun 2015 19:11:40 +0000 (20:11 +0100)
allow intercept of replaced call-id when processing the replaces header by providing a a-leg parameter in replaces header.
without this change one leg calls could not be picked because there is no bridge_uuid

src/mod/endpoints/mod_sofia/sofia.c

index 6b969ca3887a5d1bd98bcfff593e95275adce474..e2c0ffd5c4e037962f757512716a3e482c81a05e 100644 (file)
@@ -9895,21 +9895,28 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                                                                                                                                                                                   "%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
                                        }
                                } else {
-                                       if (!zstr(bridge_uuid)) {
+                                       char *a_leg = NULL;
+                                       if (sip->sip_replaces && sip->sip_replaces->rp_params && sip->sip_replaces->rp_call_id) {
+                                               a_leg = switch_find_parameter(*(sip->sip_replaces->rp_params), "a-leg", switch_core_session_get_pool(session));
+                                       }
+                                       if(a_leg) {
                                                switch_channel_mark_hold(b_channel, SWITCH_FALSE);
-                                               tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
+                                               tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", sip->sip_replaces->rp_call_id);
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "call %s picked up on a-leg\n", sip->sip_replaces->rp_call_id);
                                        } else {
-                                               const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
-                                               const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
-
-                                               if (b_data && b_app) {
-                                                       tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", b_app, b_data);
-                                               } else if (b_app) {
-                                                       tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", b_app);
+                                               if (!zstr(bridge_uuid)) {
+                                                       switch_channel_mark_hold(b_channel, SWITCH_FALSE);
+                                                       tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,intercept:%s", bridge_uuid);
+                                               } else {
+                                                       const char *b_app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
+                                                       const char *b_data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
+                                                       if (b_data && b_app) {
+                                                               tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s:%s", b_app, b_data);
+                                                       } else if (b_app) {
+                                                               tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, "answer,%s", b_app);
+                                                       }
+                                                       switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
                                                }
-
-
-                                               switch_channel_hangup(b_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
                                        }
                                }