From c34e5320d3a93fb85986236958569f86c092eb18 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 26 Feb 2010 22:54:59 +0000 Subject: [PATCH] Changed zap_channel_set_caller_data Set default NPI to e164 and default TON to national git-svn-id: http://svn.openzap.org/svn/openzap/trunk@1042 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/mod_openzap/mod_openzap.c | 15 ++++++------ libs/openzap/src/include/openzap.h | 3 +-- libs/openzap/src/zap_io.c | 34 ++++++++++++++++---------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/libs/openzap/mod_openzap/mod_openzap.c b/libs/openzap/mod_openzap/mod_openzap.c index 2961cd0804..f98d571702 100644 --- a/libs/openzap/mod_openzap/mod_openzap.c +++ b/libs/openzap/mod_openzap/mod_openzap.c @@ -1254,7 +1254,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (chan_id) { status = zap_channel_open(span_id, chan_id, &zchan); - zap_set_caller_data(span_id, &caller_data); } else { status = zap_channel_open_any(span_id, direction, &caller_data, &zchan); } @@ -1304,7 +1303,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi switch_channel_set_variable(channel, "openzap_span_name", zchan->span->name); switch_channel_set_variable_printf(channel, "openzap_span_number", "%d", zchan->span_id); switch_channel_set_variable_printf(channel, "openzap_chan_number", "%d", zchan->chan_id); - zchan->caller_data = caller_data; + zap_channel_set_caller_data(zchan, &caller_data); caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); switch_channel_set_caller_profile(channel, caller_profile); tech_pvt->caller_profile = caller_profile; @@ -2434,12 +2433,12 @@ static switch_status_t load_config(void) zap_status_t zstatus = ZAP_FAIL; const char *context = "default"; const char *dialplan = "XML"; - const char *outbound_called_ton = "unknown"; - const char *outbound_called_npi = "unknown"; - const char *outbound_calling_ton = "unknown"; - const char *outbound_calling_npi = "unknown"; - const char *outbound_rdnis_ton = "unknown"; - const char *outbound_rdnis_npi = "unknown"; + const char *outbound_called_ton = "national"; + const char *outbound_called_npi = "isdn"; + const char *outbound_calling_ton = "national"; + const char *outbound_calling_npi = "isdn"; + const char *outbound_rdnis_ton = "national"; + const char *outbound_rdnis_npi = "isdn"; uint32_t span_id = 0; zap_span_t *span = NULL; const char *tonegroup = NULL; diff --git a/libs/openzap/src/include/openzap.h b/libs/openzap/src/include/openzap.h index b7e75575c8..3f88772cd8 100644 --- a/libs/openzap/src/include/openzap.h +++ b/libs/openzap/src/include/openzap.h @@ -715,8 +715,7 @@ OZ_DECLARE(int) zap_load_module_assume(const char *name); OZ_DECLARE(zap_status_t) zap_span_find_by_name(const char *name, zap_span_t **span); OZ_DECLARE(char *) zap_api_execute(const char *type, const char *cmd); OZ_DECLARE(int) zap_vasprintf(char **ret, const char *fmt, va_list ap); - -OZ_DECLARE(void) zap_set_caller_data(uint32_t span_id, zap_caller_data_t *caller_data); +OZ_DECLARE(zap_status_t) zap_channel_set_caller_data(zap_channel_t *zchan, zap_caller_data_t *caller_data); ZIO_CODEC_FUNCTION(zio_slin2ulaw); ZIO_CODEC_FUNCTION(zio_ulaw2slin); diff --git a/libs/openzap/src/zap_io.c b/libs/openzap/src/zap_io.c index e0768e145e..8c11bae87e 100644 --- a/libs/openzap/src/zap_io.c +++ b/libs/openzap/src/zap_io.c @@ -176,18 +176,11 @@ static void default_logger(const char *file, const char *func, int line, int lev } -OZ_DECLARE(void) zap_set_caller_data(uint32_t span_id, zap_caller_data_t *caller_data) +static zap_status_t zap_set_caller_data(zap_span_t *span, zap_caller_data_t *caller_data) { - zap_span_t *span = NULL; - if (!span_id) { - zap_log(ZAP_LOG_CRIT, "Error: trying to set caller data, but no span id?\n"); - return; - } - - zap_span_find(span_id, &span); - if (!span) { - zap_log(ZAP_LOG_CRIT, "Error: trying to set caller data, but could not find span\n"); - return; + if (!caller_data) { + zap_log(ZAP_LOG_CRIT, "Error: trying to set caller data, but no caller_data!\n"); + return ZAP_FAIL; } if (caller_data->cid_num.plan == ZAP_NPI_INVALID) { @@ -213,6 +206,21 @@ OZ_DECLARE(void) zap_set_caller_data(uint32_t span_id, zap_caller_data_t *caller if (caller_data->rdnis.type == ZAP_NPI_INVALID) { caller_data->rdnis.type = span->default_caller_data.rdnis.type; } + return ZAP_SUCCESS; +} + +OZ_DECLARE(zap_status_t) zap_channel_set_caller_data(zap_channel_t *zchan, zap_caller_data_t *caller_data) +{ + zap_status_t err = ZAP_SUCCESS; + if (!zchan) { + zap_log(ZAP_LOG_CRIT, "Error: trying to set caller data, but no zchan!\n"); + return ZAP_FAIL; + } + if ((err = zap_set_caller_data(zchan->span, caller_data)) != ZAP_SUCCESS) { + return err; + } + zchan->caller_data = *caller_data; + return ZAP_SUCCESS; } OZ_DECLARE_DATA zap_logger_t zap_log = null_logger; @@ -1007,9 +1015,8 @@ OZ_DECLARE(zap_status_t) zap_channel_open_any(uint32_t span_id, zap_direction_t return ZAP_FAIL; } - zap_set_caller_data(span_id, caller_data); - if (span->channel_request && !span->suggest_chan_id) { + zap_set_caller_data(span, caller_data); return span->channel_request(span, 0, direction, caller_data, zchan); } @@ -1056,6 +1063,7 @@ OZ_DECLARE(zap_status_t) zap_channel_open_any(uint32_t span_id, zap_direction_t ) { if (span && span->channel_request) { + zap_set_caller_data(span, caller_data); status = span->channel_request(span, i, direction, caller_data, zchan); break; }