forked from Mirrors/freeswitch
openzap/0/a will pick the first available channel, on the first available span (same rules apply for a and A)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@676 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
c7c8742e15
commit
f5c913452a
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -1041,51 +1041,48 @@ 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 (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_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;
|
||||
}
|
||||
zap_set_flag(check, ZAP_CHANNEL_INUSE);
|
||||
*zchan = check;
|
||||
}
|
||||
zap_mutex_unlock(check->mutex);
|
||||
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 (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;
|
||||
}
|
||||
zap_set_flag(check, ZAP_CHANNEL_INUSE);
|
||||
*zchan = check;
|
||||
}
|
||||
zap_mutex_unlock(check->mutex);
|
||||
|
||||
done:
|
||||
zap_mutex_unlock(globals.mutex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user