-> more work on glare...no crashes, and no stuck channels yet

This commit is contained in:
Konrad Hammel 2010-06-16 12:04:08 -04:00 committed by Moises Silva
parent 59764dd350
commit 055e242a2c
2 changed files with 80 additions and 26 deletions

View File

@ -174,7 +174,7 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
break; break;
/**************************************************************************/ /**************************************************************************/
case (FTDM_CHANNEL_STATE_DIALING): /* glare */ case (FTDM_CHANNEL_STATE_DIALING): /* glare */
SS7_ERROR("Got IAM in DIALING state...glare...queueing incoming call\n"); SS7_ERROR("Got IAM in DIALING state...glare!\n");
/* the flag the channel as having a collision */ /* the flag the channel as having a collision */
sngss7_set_flag(sngss7_info, FLAG_GLARE); sngss7_set_flag(sngss7_info, FLAG_GLARE);
@ -184,6 +184,9 @@ void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCo
sngss7_info->glare.suInstId = suInstId; sngss7_info->glare.suInstId = suInstId;
sngss7_info->glare.spInstId = spInstId; sngss7_info->glare.spInstId = spInstId;
sngss7_info->glare.circuit = circuit; sngss7_info->glare.circuit = circuit;
SS7_DEBUG("Queuing incoming cal request on Circuit = %d (CIC # %d\n",
sngss7_info->glare.circuit,
sngss7_info->circuit->cic);
break; break;
/**************************************************************************/ /**************************************************************************/
@ -464,7 +467,6 @@ void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
switch (ftdmchan->state) { switch (ftdmchan->state) {
/**************************************************************************/ /**************************************************************************/
case FTDM_CHANNEL_STATE_RING: case FTDM_CHANNEL_STATE_RING:
case FTDM_CHANNEL_STATE_DIALING:
case FTDM_CHANNEL_STATE_PROGRESS: case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA: case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
case FTDM_CHANNEL_STATE_UP: case FTDM_CHANNEL_STATE_UP:
@ -482,6 +484,21 @@ void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRe
break; break;
/**************************************************************************/ /**************************************************************************/
case FTDM_CHANNEL_STATE_DIALING:
/* pass the release code up to FTDM */
if (siRelEvnt->causeDgn.causeVal.pres) {
ftdmchan->caller_data.hangup_cause = siRelEvnt->causeDgn.causeVal.val;
} else {
SS7_ERROR("REL does not have a cause code!\n");
ftdmchan->caller_data.hangup_cause = 0;
}
/* move the state of the channel to TERMINATING to end the call */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
break;
/**************************************************************************/
default: default:
/* fill in the channels SS7 Stack information */ /* fill in the channels SS7 Stack information */

View File

@ -66,7 +66,7 @@ ftdm_state_map_t sangoma_ss7_state_map = {
ZSD_INBOUND, ZSD_INBOUND,
ZSM_UNACCEPTABLE, ZSM_UNACCEPTABLE,
{FTDM_CHANNEL_STATE_RESTART, FTDM_END}, {FTDM_CHANNEL_STATE_RESTART, FTDM_END},
{FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_END} {FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_END}
}, },
{ {
ZSD_INBOUND, ZSD_INBOUND,
@ -179,7 +179,7 @@ ftdm_state_map_t sangoma_ss7_state_map = {
ZSD_OUTBOUND, ZSD_OUTBOUND,
ZSM_UNACCEPTABLE, ZSM_UNACCEPTABLE,
{FTDM_CHANNEL_STATE_DIALING, FTDM_END}, {FTDM_CHANNEL_STATE_DIALING, FTDM_END},
{FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_DOWN, FTDM_END} {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_DOWN, FTDM_CHANNEL_STATE_CANCEL, FTDM_END}
}, },
{ {
ZSD_OUTBOUND, ZSD_OUTBOUND,
@ -393,6 +393,13 @@ static void ftdm_sangoma_ss7_process_state_change(ftdm_channel_t *ftdmchan)
break; break;
} }
/* kill t35 if active */
if (sngss7_info->t35.heartbeat_timer) {
ftdm_sched_cancel_timer(sngss7_info->t35.sched, &sngss7_info->t35.heartbeat_timer);
}
SS7_DEBUG("Sending incoming call from %s to %s to FTDM core\n", SS7_DEBUG("Sending incoming call from %s to %s to FTDM core\n",
ftdmchan->caller_data.ani.digits, ftdmchan->caller_data.ani.digits,
ftdmchan->caller_data.dnis.digits); ftdmchan->caller_data.dnis.digits);
@ -414,6 +421,9 @@ static void ftdm_sangoma_ss7_process_state_change(ftdm_channel_t *ftdmchan)
break; break;
} }
/* clear the glare flag if it is on from a preivous call */
sngss7_clear_flag(sngss7_info, FLAG_GLARE);
/*call sangoma_ss7_dial to make outgoing call*/ /*call sangoma_ss7_dial to make outgoing call*/
ft_to_sngss7_iam(ftdmchan); ft_to_sngss7_iam(ftdmchan);
@ -430,6 +440,7 @@ static void ftdm_sangoma_ss7_process_state_change(ftdm_channel_t *ftdmchan)
/*check if the channel is inbound or outbound*/ /*check if the channel is inbound or outbound*/
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) { if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {
/*OUTBOUND...so we were told by the line of this so noifiy the user*/ /*OUTBOUND...so we were told by the line of this so noifiy the user*/
sigev.event_id = FTDM_SIGEVENT_PROGRESS; sigev.event_id = FTDM_SIGEVENT_PROGRESS;
ftdm_span_send_signal(ftdmchan->span, &sigev); ftdm_span_send_signal(ftdmchan->span, &sigev);
@ -576,6 +587,11 @@ static void ftdm_sangoma_ss7_process_state_change(ftdm_channel_t *ftdmchan)
break; break;
} }
/* check if t35 is active */
if (sngss7_info->t35.heartbeat_timer) {
ftdm_sched_cancel_timer(sngss7_info->t35.sched, &sngss7_info->t35.heartbeat_timer);
}
/* check if there is a reset response that needs to be sent */ /* check if there is a reset response that needs to be sent */
if (sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) { if (sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) {
/* send a RLC */ /* send a RLC */
@ -621,27 +637,34 @@ static void ftdm_sangoma_ss7_process_state_change(ftdm_channel_t *ftdmchan)
/* check if the circuit has the glare flag up */ /* check if the circuit has the glare flag up */
if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) { if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {
SS7_DEBUG("Glare flag is up....spoofing incoming call on span=%d, chan=%d\n", sngss7_info->suInstId = 0;
ftdmchan->physical_span_id,ftdmchan->physical_chan_id); sngss7_info->spInstId = 0;
/* clear all the call specific data */ sngss7_info->globalFlg = 0;
sngss7_info->suInstId = 0; sngss7_info->spId = 0;
sngss7_info->spInstId = 0; sngss7_info->flags = 0;
sngss7_info->globalFlg = 0; sngss7_set_flag(sngss7_info, FLAG_GLARE);
sngss7_info->spId = 0;
sngss7_info->flags = 0;
/* close the channel */ /* close the channel */
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) { if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OPEN)) {
ftdm_channel_t *close_chan = ftdmchan; ftdm_channel_t *close_chan = ftdmchan;
/* close the channel */ /* close the channel */
ftdm_channel_close(&close_chan); ftdm_channel_close(&close_chan);
} }
/* spoof an incoming call */ /* check if the glare was caused by in incoming call aka glare structure is valid */
sngss7_con_ind(sngss7_info->glare.suInstId, if (sngss7_info->glare.circuit != 0) {
sngss7_info->glare.spInstId, SS7_DEBUG("Glare flag is up....spoofing incoming call on span=%d, chan=%d (Cir=%d)\n",
sngss7_info->glare.circuit, ftdmchan->physical_span_id,
&sngss7_info->glare.iam); ftdmchan->physical_chan_id,
sngss7_info->glare.circuit);
/* clear all the call specific data */
/* spoof an incoming call */
sngss7_con_ind(sngss7_info->glare.suInstId,
sngss7_info->glare.spInstId,
sngss7_info->glare.circuit,
&sngss7_info->glare.iam);
}
} else { } else {
/* clear all of the call specific data store in the channel structure */ /* clear all of the call specific data store in the channel structure */
sngss7_info->suInstId = 0; sngss7_info->suInstId = 0;
@ -873,13 +896,26 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
/* lock the channel while we check whether it is availble */ /* lock the channel while we check whether it is availble */
ftdm_mutex_lock(ftdmchan->mutex); ftdm_mutex_lock(ftdmchan->mutex);
/* check if there is a pending state change, give it a bit to clear */
if (check_for_state_change(ftdmchan)) {
SS7_ERROR("Failed to wait for pending state change on CIC = %d\n", sngss7_info->circuit->cic);
ftdm_mutex_unlock(ftdmchan->mutex);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
};
/* extract the sngss7_chan_data structure */ /* extract the sngss7_chan_data structure */
sngss7_info = (sngss7_chan_data_t *)ftdmchan->call_data; sngss7_info = (sngss7_chan_data_t *)ftdmchan->call_data;
if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) { if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {
SS7_ERROR("Glare flag on span=%d,chan=%d\n", SS7_ERROR("Glare flag on span=%d,chan=%d\n",
ftdmchan->physical_span_id,ftdmchan->physical_chan_id); ftdmchan->physical_span_id,ftdmchan->physical_chan_id);
/* kill the timer */
if (sngss7_info->t35.heartbeat_timer) {
ftdm_sched_cancel_timer(sngss7_info->t35.sched, &sngss7_info->t35.heartbeat_timer);
}
goto outgoing_glare; goto outgoing_glare;
} }
@ -895,11 +931,11 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
break; break;
/******************************************************************/ /******************************************************************/
default: default:
SS7_ERROR("Channel in invalid state (%s) on span=%d,chan=%d...glare\n", SS7_ERROR("Channel in invalid state (%s) on span=%d,chan=%d...fail\n",
ftdm_channel_state2str(ftdmchan->state), ftdm_channel_state2str(ftdmchan->state),
ftdmchan->physical_span_id, ftdmchan->physical_span_id,
ftdmchan->physical_chan_id); ftdmchan->physical_chan_id);
goto outgoing_glare; goto outgoing_fail;
break; break;
/******************************************************************/ /******************************************************************/
} }
@ -933,6 +969,7 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)
/**************************************************************************/ /**************************************************************************/
} }
outgoing_fail:
SS7_DEBUG("Call Request on span=%d, chan=%d failed\n"); SS7_DEBUG("Call Request on span=%d, chan=%d failed\n");
/* unlock the channel */ /* unlock the channel */
ftdm_mutex_unlock(ftdmchan->mutex); ftdm_mutex_unlock(ftdmchan->mutex);