Merge branch 'master' into davidy_test

This commit is contained in:
David Yat Sin
2010-09-03 17:38:35 -04:00
10 changed files with 74 additions and 140 deletions
+29 -2
View File
@@ -1950,7 +1950,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char
ftdm_channel_lock(ftdmchan);
if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call is already terminating\n");
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call is already TERMINATING\n");
goto done;
}
@@ -1962,14 +1962,27 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_answer(const char *file, const char
goto done;
}
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) {
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1);
}
/* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */
if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to PROGRESS\n");
goto done;
}
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS_MEDIA) {
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1);
}
/* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */
if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to UP\n");
goto done;
}
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_UP, 1);
done:
@@ -2011,6 +2024,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup_with_cause(const char *file,
FT_DECLARE(ftdm_status_t) _ftdm_channel_call_hangup(const char *file, const char *func, int line, ftdm_channel_t *ftdmchan)
{
ftdm_channel_lock(ftdmchan);
ftdmchan->caller_data.hangup_cause = FTDM_CAUSE_NORMAL_CLEARING;
call_hangup(ftdmchan, file, func, line);
ftdm_channel_unlock(ftdmchan);
return FTDM_SUCCESS;
@@ -2084,8 +2098,13 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
{
ftdm_status_t status = FTDM_SUCCESS;
ftdm_channel_lock(ftdmchan);
switch (indication) {
if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to PROGRESS\n");
goto done;
}
switch (indication) {
/* FIXME: ring and busy cannot be used with all signaling stacks
* (particularly isdn stacks I think, we should emulate or just move to hangup with busy cause) */
case FTDM_CHANNEL_INDICATE_RING:
@@ -2112,6 +2131,13 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
if (ftdmchan->state < FTDM_CHANNEL_STATE_PROGRESS) {
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS, 1);
}
/* set state unlocks the channel so we need to re-confirm that the channel hasn't gone to hell */
if (ftdmchan->state == FTDM_CHANNEL_STATE_TERMINATING) {
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Ignoring answer because the call has moved to TERMINATING while we're moving to PROGRESS\n");
goto done;
}
ftdm_channel_set_state(file, func, line, ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, 1);
}
break;
@@ -2122,6 +2148,7 @@ FT_DECLARE(ftdm_status_t) _ftdm_channel_call_indicate(const char *file, const ch
break;
}
done:
ftdm_channel_unlock(ftdmchan);
return FTDM_SUCCESS;
@@ -78,8 +78,8 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info ;
ftdm_channel_t *ftdmchan;
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -121,14 +121,14 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/* check whether the ftdm channel is in a state to accept a call */
switch (ftdmchan->state) {
/**************************************************************************/
case (FTDM_CHANNEL_STATE_DOWN): /* only state it is fully valid to get IAM */
case (FTDM_CHANNEL_STATE_DOWN): /* only state it is valid to get IAM (except if there is glare */
/* fill in the channels SS7 Stack information */
sngss7_info->suInstId = get_unique_id();
sngss7_info->spInstId = spInstId;
/* try to open the ftdm channel */
if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) {
/* check if there is any reason why we can't use this channel */
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE)) {
/* channel is already requested for use by the ftdm core */
goto handle_glare;
} else if(ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) {
/* channel is not inuse but we can't open it...fail the call */
SS7_ERROR("Failed to open span: %d, chan: %d\n",
ftdmchan->physical_span_id,
ftdmchan->physical_chan_id);
@@ -143,6 +143,10 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
} else {
/* fill in the channels SS7 Stack information */
sngss7_info->suInstId = get_unique_id();
sngss7_info->spInstId = spInstId;
/* fill in calling party information */
if (siConEvnt->cgPtyNum.eh.pres) {
if (siConEvnt->cgPtyNum.addrSig.pres) {
@@ -211,7 +215,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/* set the state of the channel to collecting...the rest is done by the chan monitor */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_COLLECT);
} /* if (ftdm_channel_open_chan(ftdmchan) != FTDM_SUCCESS) */
} /* if (channel is usable */
break;
/**************************************************************************/
@@ -219,8 +223,11 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
case (FTDM_CHANNEL_STATE_TERMINATING):
case (FTDM_CHANNEL_STATE_HANGUP):
case (FTDM_CHANNEL_STATE_HANGUP_COMPLETE):
SS7_INFO_CHAN(ftdmchan, "Got IAM on channel in %s state...glare!\n", ftdm_channel_state2str (ftdmchan->state));
handle_glare:
/* the core already has plans for this channel...glare */
SS7_INFO_CHAN(ftdmchan, "Got IAM on channel that is already inuse (state=%s|inuse=%d)...glare!\n",
ftdm_channel_state2str (ftdmchan->state),
ftdm_test_flag(ftdmchan, FTDM_CHANNEL_INUSE));
/* save the info so that we can use it later on */
sngss7_info->glare.spInstId = spInstId;
@@ -239,8 +246,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/* move the state of the channel to Terminating to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
}
} /* if (!(sngss7_test_flag(sngss7_info, FLAG_GLARE))) */
break;
/**************************************************************************/
default: /* should not have gotten an IAM while in this state */