diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 0fe6bdda9e..1ace3893b3 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -334,6 +334,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc */ SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension); +SWITCH_DECLARE(void) switch_channel_invert_cid(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel); SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel); @@ -603,7 +604,9 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(_In_ switch_channel_ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *channel, const char *in, switch_event_t *var_list, switch_event_t *api_list, uint32_t recur); #define switch_channel_expand_variables(_channel, _in) switch_channel_expand_variables_check(_channel, _in, NULL, NULL, 0) -#define switch_channel_inbound_display(_channel) (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND || switch_channel_test_flag(_channel, CF_DIALPLAN)) +#define switch_channel_inbound_display(_channel) ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && !switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && switch_channel_test_flag(_channel, CF_DIALPLAN))) + +#define switch_channel_outbound_display(_channel) ((switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_INBOUND && switch_channel_test_flag(_channel, CF_BLEG)) || (switch_channel_direction(_channel) == SWITCH_CALL_DIRECTION_OUTBOUND && !switch_channel_test_flag(_channel, CF_DIALPLAN))) SWITCH_DECLARE(char *) switch_channel_build_param_string(_In_ switch_channel_t *channel, _In_opt_ switch_caller_profile_t *caller_profile, _In_opt_ const char *prefix); diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 975a90eb90..87b928825d 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -2985,18 +2985,7 @@ SWITCH_STANDARD_APP(fifo_function) originatee_cp = switch_channel_get_caller_profile(other_channel); if (switch_channel_inbound_display(other_channel)) { - const char *tname = originatee_cp->caller_id_name; - const char *tnum = originatee_cp->caller_id_number; - -#ifdef DEEP_DEBUG_CID - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originatee_cp->caller_id_name, originatee_cp->caller_id_number, originatee_cp->callee_id_name, originatee_cp->callee_id_number); -#endif - - originatee_cp->caller_id_name = originatee_cp->callee_id_name; - originatee_cp->caller_id_number = originatee_cp->callee_id_number; - - originatee_cp->callee_id_name = tname; - originatee_cp->callee_id_number = tnum; + switch_channel_invert_cid(other_channel); if (switch_channel_direction(other_channel) == SWITCH_CALL_DIRECTION_INBOUND) { switch_channel_set_flag(other_channel, CF_BLEG); diff --git a/src/switch_channel.c b/src/switch_channel.c index 79dc40e620..06d5e22389 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -2850,6 +2850,36 @@ SWITCH_DECLARE(switch_status_t) switch_channel_caller_extension_masquerade(switc return status; } +SWITCH_DECLARE(void) switch_channel_invert_cid(switch_channel_t *channel) +{ + const char *tname, *tnum; + switch_caller_profile_t *cp; + + cp = switch_channel_get_caller_profile(channel); + + tname = cp->caller_id_name; + tnum = cp->caller_id_number; + +#ifdef DEEP_DEBUG_CID + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originate_cp->caller_id_name, cp->caller_id_number, cp->callee_id_name, cp->callee_id_number); +#endif + + cp->caller_id_name = cp->callee_id_name; + cp->caller_id_number = cp->callee_id_number; + + cp->callee_id_name = tname; + cp->callee_id_number = tnum; + + if (zstr(cp->caller_id_name)) { + cp->caller_id_name = "Unknown"; + } + + if (zstr(cp->caller_id_number)) { + cp->caller_id_number = "Unknown"; + } +} + + SWITCH_DECLARE(void) switch_channel_flip_cid(switch_channel_t *channel) { switch_event_t *event; diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c index 97364b14c0..0df636cac5 100644 --- a/src/switch_ivr_bridge.c +++ b/src/switch_ivr_bridge.c @@ -1652,20 +1652,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(const char *originator_uu originator_cp = switch_channel_get_caller_profile(originator_channel); originatee_cp = switch_channel_get_caller_profile(originatee_channel); + + + if (switch_channel_outbound_display(originator_channel)) { + switch_channel_invert_cid(originator_channel); + + if (switch_channel_direction(originator_channel) == SWITCH_CALL_DIRECTION_INBOUND) { + switch_channel_clear_flag(originatee_channel, CF_BLEG); + } + } + if (switch_channel_inbound_display(originatee_channel)) { - const char *tname = originatee_cp->caller_id_name; - const char *tnum = originatee_cp->caller_id_number; - -#ifdef DEEP_DEBUG_CID - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SWAP [%s][%s] [%s][%s]\n", originatee_cp->caller_id_name, originatee_cp->caller_id_number, originatee_cp->callee_id_name, originatee_cp->callee_id_number); -#endif - - originatee_cp->caller_id_name = originatee_cp->callee_id_name; - originatee_cp->caller_id_number = originatee_cp->callee_id_number; - - originatee_cp->callee_id_name = tname; - originatee_cp->callee_id_number = tnum; - + switch_channel_invert_cid(originatee_channel); + if (switch_channel_direction(originatee_channel) == SWITCH_CALL_DIRECTION_INBOUND) { switch_channel_set_flag(originatee_channel, CF_BLEG); }