]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
openzap/0/a will pick the first available channel, on the first available span (same...
authorMathieu Rene <mrene@avgs.ca>
Sun, 1 Mar 2009 23:38:33 +0000 (23:38 +0000)
committerMathieu Rene <mrene@avgs.ca>
Sun, 1 Mar 2009 23:38:33 +0000 (23:38 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@676 a93c3328-9c30-0410-af19-c9cd2b2d52af

libs/openzap/mod_openzap/mod_openzap.c
libs/openzap/src/ozmod/ozmod_libpri/ozmod_libpri.c
libs/openzap/src/zap_io.c

index c9b200fa2fc3d5f2f75fe4a7503349d633c660c2..5c9aa41963eecdf59d3fa9d14198ea5f17c0457d 100644 (file)
@@ -891,7 +891,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
 
        const char *dest = NULL;
        char *data = NULL;
-       int span_id = 0, chan_id = 0;
+       int span_id = -1, chan_id = 0;
        zap_channel_t *zchan = NULL;
        switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
        char name[128];
@@ -941,7 +941,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                dest = "";
        }
 
-       if (!span_id && !switch_strlen_zero(span_name)) {
+       if (span_id == 0 && chan_id != 0) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Span 0 is used to pick the first available span, selecting a channel is not supported (and doesn't make sense)\n");
+        return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+       }
+
+       if (span_id == -1 && !switch_strlen_zero(span_name)) {
                zap_span_t *span;
                zap_status_t zstatus = zap_span_find_by_name(span_name, &span);
                if (zstatus == ZAP_SUCCESS && span) {
@@ -949,7 +954,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
                }
        }
 
-       if (!span_id) {
+       if (span_id == -1) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing span\n");
                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
        }
index 169cae6146fb133690a5ffd83994972ad828ab56..dc6555d1ba054584b5b426fc8a3f33bfee10b63c 100644 (file)
@@ -832,7 +832,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_libpri_configure_span)
                        }
                        node = str2node(val);
                        if (-1 == node) {
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unknown node type %s, defaulting to CPE mode\n", val);
+                               zap_log(ZAP_LOG_ERROR, "Unknown node type %s, defaulting to CPE mode\n", val);
                                node = PRI_CPE;
                        }
                        isdn_data->node = node;
index e71f0cda9caf583882e6c98aee5d7fa53baeba89..ad00ce9f030cb80350d749799f4a7add38c37d97 100644 (file)
@@ -1041,50 +1041,47 @@ zap_status_t zap_channel_open_chan(zap_channel_t *zchan)
 
 zap_status_t zap_channel_open(uint32_t span_id, uint32_t chan_id, zap_channel_t **zchan)
 {
+       zap_channel_t *check;
        zap_status_t status = ZAP_FAIL;
 
        zap_mutex_lock(globals.mutex);
 
-       if (span_id < ZAP_MAX_SPANS_INTERFACE && chan_id < ZAP_MAX_CHANNELS_SPAN) {
-               zap_channel_t *check;
-               
-               if (span_id > globals.span_index || !globals.spans[span_id]) {
-                       zap_log(ZAP_LOG_ERROR, "SPAN NOT DEFINED!\n");
-                       *zchan = NULL;
-                       goto done;
-               }
+       if (span_id > globals.span_index  || chan_id >= ZAP_MAX_CHANNELS_SPAN || !globals.spans[span_id]) {
+               zap_log(ZAP_LOG_ERROR, "SPAN NOT DEFINED!\n");
+               *zchan = NULL;
+               goto done;              
+       }
 
-               if (globals.spans[span_id]->channel_request) {
-                       zap_log(ZAP_LOG_ERROR, "Individual channel selection not implemented on this span.\n");
-                       *zchan = NULL;
-                       goto done;
-               }
-               
-               check = globals.spans[span_id]->channels[chan_id];
+       if (globals.spans[span_id]->channel_request) {
+               zap_log(ZAP_LOG_ERROR, "Individual channel selection not implemented on this span.\n");
+               *zchan = NULL;
+               goto done;
+       }
+       
+       check = globals.spans[span_id]->channels[chan_id];
 
-               if (zap_test_flag(check, ZAP_CHANNEL_SUSPENDED) || 
-                       !zap_test_flag(check, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(check->mutex)) != ZAP_SUCCESS) {
-                       *zchan = NULL;
-                       goto done;
-               }
-               
-               status = ZAP_FAIL;
+       if (zap_test_flag(check, ZAP_CHANNEL_SUSPENDED) || 
+               !zap_test_flag(check, ZAP_CHANNEL_READY) || (status = zap_mutex_trylock(check->mutex)) != ZAP_SUCCESS) {
+               *zchan = NULL;
+               goto done;
+       }
+       
+       status = ZAP_FAIL;
 
-               if (zap_test_flag(check, ZAP_CHANNEL_READY) && (!zap_test_flag(check, ZAP_CHANNEL_INUSE) || 
-                                                                                                               (check->type == ZAP_CHAN_TYPE_FXS && check->token_count == 1))) {
-                       if (!zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
-                               status = check->zio->open(check);
-                               if (status == ZAP_SUCCESS) {
-                                       zap_set_flag(check, ZAP_CHANNEL_OPEN);
-                               }
-                       } else {
-                               status = ZAP_SUCCESS;
+       if (zap_test_flag(check, ZAP_CHANNEL_READY) && (!zap_test_flag(check, ZAP_CHANNEL_INUSE) || 
+                                                                                                       (check->type == ZAP_CHAN_TYPE_FXS && check->token_count == 1))) {
+               if (!zap_test_flag(check, ZAP_CHANNEL_OPEN)) {
+                       status = check->zio->open(check);
+                       if (status == ZAP_SUCCESS) {
+                               zap_set_flag(check, ZAP_CHANNEL_OPEN);
                        }
-                       zap_set_flag(check, ZAP_CHANNEL_INUSE);
-                       *zchan = check;
+               } else {
+                       status = ZAP_SUCCESS;
                }
-               zap_mutex_unlock(check->mutex);
+               zap_set_flag(check, ZAP_CHANNEL_INUSE);
+               *zchan = check;
        }
+       zap_mutex_unlock(check->mutex);
 
        done:
        zap_mutex_unlock(globals.mutex);