From b1a3a106ecf98db4953d8ce54ea93bd8f28273d8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 17 Oct 2013 12:18:01 -0400 Subject: [PATCH] FS-5852 --resolve --- src/include/switch_types.h | 8 +++--- src/switch_caller.c | 5 ++++ src/switch_core_session.c | 17 ++++++++++++- src/switch_ivr_originate.c | 52 +++++++++++++++++++++++++++++++++----- 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 055539e767..7c90161d3a 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -299,9 +299,11 @@ typedef enum { SOF_NONE = 0, SOF_NOBLOCK = (1 << 0), SOF_FORKED_DIAL = (1 << 1), - SOF_NO_EFFECTIVE_CID_NUM = (1 << 2), - SOF_NO_EFFECTIVE_CID_NAME = (1 << 3), - SOF_NO_LIMITS = (1 << 4) + SOF_NO_EFFECTIVE_ANI = (1 << 2), + SOF_NO_EFFECTIVE_ANIII = (1 << 3), + SOF_NO_EFFECTIVE_CID_NUM = (1 << 4), + SOF_NO_EFFECTIVE_CID_NAME = (1 << 5), + SOF_NO_LIMITS = (1 << 6) } switch_originate_flag_enum_t; typedef uint32_t switch_originate_flag_t; diff --git a/src/switch_caller.c b/src/switch_caller.c index 02de5575aa..fdd41a4dd7 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -66,6 +66,11 @@ SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memor caller_id_number = SWITCH_DEFAULT_CLID_NUMBER; } + /* ANI defaults to Caller ID Number when not specified */ + if (zstr(ani)) { + ani = caller_id_number; + } + profile_dup_clean(username, profile->username, pool); profile_dup_clean(dialplan, profile->dialplan, pool); profile_dup_clean(caller_id_name, profile->caller_id_name, pool); diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 52cb871aa9..a08b548fee 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -525,8 +525,17 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ } if (caller_profile) { + const char *eani = NULL, *eaniii = NULL; const char *ecaller_id_name = NULL, *ecaller_id_number = NULL; + if (!(flags & SOF_NO_EFFECTIVE_ANI)) { + eani = switch_channel_get_variable(channel, "effective_ani"); + } + + if (!(flags & SOF_NO_EFFECTIVE_ANIII)) { + eaniii = switch_channel_get_variable(channel, "effective_aniii"); + } + if (!(flags & SOF_NO_EFFECTIVE_CID_NAME)) { ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"); } @@ -535,9 +544,15 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_ ecaller_id_number = switch_channel_get_variable(channel, "effective_caller_id_number"); } - if (ecaller_id_name || ecaller_id_number) { + if (eani || eaniii || ecaller_id_name || ecaller_id_number) { outgoing_profile = switch_caller_profile_clone(session, caller_profile); + if (eani) { + outgoing_profile->ani = eani; + } + if (eaniii) { + outgoing_profile->aniii = eaniii; + } if (ecaller_id_name) { outgoing_profile->caller_id_name = ecaller_id_name; } diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 52ef822cad..b30df42a98 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1487,16 +1487,24 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess } if (channel) { - const char *cid; + const char *tmp_var = NULL; switch_channel_process_export(channel, NULL, var_event, SWITCH_EXPORT_VARS_VARIABLE); - if ((cid = switch_channel_get_variable(channel, "effective_caller_id_name"))) { - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_name", cid); + if ((tmp_var = switch_channel_get_variable(channel, "effective_ani"))) { + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_ani", tmp_var); } - if ((cid = switch_channel_get_variable(channel, "effective_caller_id_number"))) { - switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_number", cid); + if ((tmp_var = switch_channel_get_variable(channel, "effective_aniii"))) { + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_aniii", tmp_var); + } + + if ((tmp_var = switch_channel_get_variable(channel, "effective_caller_id_name"))) { + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_name", tmp_var); + } + + if ((tmp_var = switch_channel_get_variable(channel, "effective_caller_id_number"))) { + switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_number", tmp_var); } } @@ -1891,6 +1899,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess int read_packet = 0; int check_reject = 1; switch_codec_implementation_t read_impl = { 0 }; + const char *ani_override = NULL; + const char *aniii_override = NULL; if (session) { switch_channel_set_variable(switch_core_session_get_channel(session), "originated_legs", NULL); @@ -2342,6 +2352,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } } + /* variable to force ANI / ANIII */ + ani_override = switch_event_get_header(var_event, "origination_ani"); + aniii_override = switch_event_get_header(var_event, "origination_aniii"); + if ((cid_tmp = switch_event_get_header(var_event, "origination_caller_id_name"))) { cid_name_override = cid_tmp; } @@ -2370,6 +2384,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess dftflags |= SOF_NO_LIMITS; } + if (ani_override) { + dftflags |= SOF_NO_EFFECTIVE_ANI; + } + + if (aniii_override) { + dftflags |= SOF_NO_EFFECTIVE_ANIII; + } + if (cid_num_override) { dftflags |= SOF_NO_EFFECTIVE_CID_NUM; } @@ -2542,13 +2564,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess new_profile = switch_caller_profile_new(oglobals.pool, NULL, NULL, - cid_name_override, cid_num_override, NULL, NULL, NULL, NULL, __FILE__, NULL, chan_data); + cid_name_override, cid_num_override, NULL, ani_override, aniii_override, NULL, __FILE__, NULL, chan_data); } new_profile->uuid = SWITCH_BLANK_STRING; new_profile->chan_name = SWITCH_BLANK_STRING; new_profile->destination_number = switch_core_strdup(new_profile->pool, chan_data); + if (ani_override) { + new_profile->ani = switch_core_strdup(new_profile->pool, ani_override); + } + if (aniii_override) { + new_profile->aniii = switch_core_strdup(new_profile->pool, aniii_override); + } if (cid_name_override) { new_profile->caller_id_name = switch_core_strdup(new_profile->pool, cid_name_override); } @@ -2572,7 +2600,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess new_profile = switch_caller_profile_new(oglobals.pool, NULL, NULL, - cid_name_override, cid_num_override, NULL, NULL, NULL, NULL, __FILE__, NULL, chan_data); + cid_name_override, cid_num_override, NULL, ani_override, aniii_override, NULL, __FILE__, NULL, chan_data); } } @@ -2615,6 +2643,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_event_merge(originate_var_event, local_var_event); } + if ((current_variable = switch_event_get_header(originate_var_event, "origination_ani"))) { + new_profile->ani = switch_core_strdup(new_profile->pool, current_variable); + myflags |= SOF_NO_EFFECTIVE_ANI; + } + + if ((current_variable = switch_event_get_header(originate_var_event, "origination_aniii"))) { + new_profile->aniii = switch_core_strdup(new_profile->pool, current_variable); + myflags |= SOF_NO_EFFECTIVE_ANIII; + } + if ((current_variable = switch_event_get_header(originate_var_event, "origination_caller_id_number"))) { new_profile->caller_id_number = switch_core_strdup(new_profile->pool, current_variable); myflags |= SOF_NO_EFFECTIVE_CID_NUM;