]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Changed zap_channel_set_caller_data
authorDavid Yat Sin <dyatsin@sangoma.com>
Fri, 26 Feb 2010 22:54:59 +0000 (22:54 +0000)
committerDavid Yat Sin <dyatsin@sangoma.com>
Fri, 26 Feb 2010 22:54:59 +0000 (22:54 +0000)
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
libs/openzap/src/include/openzap.h
libs/openzap/src/zap_io.c

index 2961cd0804239d745d95492214a2e93d134b2ea6..f98d571702224a5929cac9d6ac204c76bc12ca35 100644 (file)
@@ -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;
index b7e75575c8ac48abeeb424728d89697fe5efb8f4..3f88772cd828b50c60d0f763c689925ca39e0772 100644 (file)
@@ -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);
index e0768e145ea05d9f09ab7842201a777b1f3ba0e1..8c11bae87e202cbe5a1061f7467af521f4973a0a 100644 (file)
@@ -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;
                        }