From 5cf9ad5986898d7925ca95d578521165b153acd0 Mon Sep 17 00:00:00 2001 From: "Ahron Greenberg (agree)" <37550360+greenbea@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:58:13 -0400 Subject: [PATCH 1/3] Add missing timing variables in profile var lookup --- src/switch_caller.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/switch_caller.c b/src/switch_caller.c index 37a3683039c..16250411efc 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -306,6 +306,15 @@ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profi if (!strcasecmp(name, "transferred_time")) { return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred); } + if (!strcasecmp(name, "bridged_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->bridged); + } + if (!strcasecmp(name, "last_hold_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->last_hold); + } + if (!strcasecmp(name, "hold_accum_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hold_accum); + } if (caller_profile->soft && switch_test_flag(caller_profile, SWITCH_CPF_SOFT_LOOKUP)) { profile_node_t *pn; From 98b2720940ce7dd3c6a67f340b4a81520f6e924a Mon Sep 17 00:00:00 2001 From: agree Date: Thu, 7 Aug 2025 01:34:35 -0400 Subject: [PATCH 2/3] Fix segfault on switch_channel_get_variable bleg_* vars originatee profile doesn't have times set when it gets set in switch_ivr_originate --- src/switch_caller.c | 52 ++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/switch_caller.c b/src/switch_caller.c index 16250411efc..cf8bbfac3b0 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -285,26 +285,38 @@ SWITCH_DECLARE(const char *) switch_caller_get_field_by_name(switch_caller_profi if (!strcasecmp(name, "privacy_hide_number")) { return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false"; } - if (!strcasecmp(name, "profile_created_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created); - } - if (!strcasecmp(name, "created_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created); - } - if (!strcasecmp(name, "answered_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered); - } - if (!strcasecmp(name, "progress_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress); - } - if (!strcasecmp(name, "progress_media_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media); - } - if (!strcasecmp(name, "hungup_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup); - } - if (!strcasecmp(name, "transferred_time")) { - return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred); + + if (caller_profile->times) { + if (!strcasecmp(name, "profile_created_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created); + } + if (!strcasecmp(name, "created_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created); + } + if (!strcasecmp(name, "answered_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered); + } + if (!strcasecmp(name, "progress_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress); + } + if (!strcasecmp(name, "progress_media_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media); + } + if (!strcasecmp(name, "hungup_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup); + } + if (!strcasecmp(name, "transferred_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred); + } + if (!strcasecmp(name, "bridged_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->bridged); + } + if (!strcasecmp(name, "last_hold_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->last_hold); + } + if (!strcasecmp(name, "hold_accum_time")) { + return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hold_accum); + } } if (!strcasecmp(name, "bridged_time")) { return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->bridged); From 51feccbd75b503d384a2d8a1be1b4b98af64624d Mon Sep 17 00:00:00 2001 From: agree Date: Thu, 7 Aug 2025 01:38:56 -0400 Subject: [PATCH 3/3] Add ability to get variables from other leg --- src/switch_channel.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index d360c8a9517..44ac040e9e1 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -990,23 +990,32 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *c } if (!v && (!channel->variables || !(v = switch_event_get_header_idx(channel->variables, varname, idx)))) { - switch_caller_profile_t *cp = switch_channel_get_caller_profile(channel); - - if (cp) { - if (!strncmp(varname, "aleg_", 5)) { - cp = cp->originator_caller_profile; - varname += 5; - } else if (!strncmp(varname, "bleg_", 5)) { - cp = cp->originatee_caller_profile; - varname += 5; - } - } + if (!strncmp(varname, "other_", 6)) { + varname += 6; - if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) { - if ((vdup = switch_core_get_variable_pdup(varname, switch_core_session_get_pool(channel->session)))) { + if ((vdup = switch_channel_get_variable_partner(channel, varname))) { v = vdup; } + } else { + switch_caller_profile_t *cp = switch_channel_get_caller_profile(channel); + + if (cp) { + if (!strncmp(varname, "aleg_", 5)) { + cp = cp->originator_caller_profile; + varname += 5; + } else if (!strncmp(varname, "bleg_", 5)) { + cp = cp->originatee_caller_profile; + varname += 5; + } + } + + if (!cp || !(v = switch_caller_get_field_by_name(cp, varname))) { + if ((vdup = switch_core_get_variable_pdup(varname, switch_core_session_get_pool(channel->session)))) { + v = vdup; + } + } } + } }