From 6f2ccbae21199c8ef786903f1ef83f67d9efe4a0 Mon Sep 17 00:00:00 2001 From: Konrad Hammel Date: Thu, 28 Oct 2010 17:09:51 -0400 Subject: [PATCH] freetdm: ss7 - update to support CCR --- .../ftmod_sangoma_ss7_handle.c | 32 ++++++++++++------- .../ftmod_sangoma_ss7_main.c | 11 ++++++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c index 7519b2787d..af3b9edbae 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c @@ -598,7 +598,7 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* this is a remote hangup request */ sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL); - +ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); /* move the state of the channel to CANCEL to end the call */ ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); @@ -613,7 +613,7 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ 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"); + SS7_ERROR("REL does not have a cause ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);code!\n"); ftdmchan->caller_data.hangup_cause = 0; } @@ -625,6 +625,23 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ break; /**************************************************************************/ + case FTDM_CHANNEL_STATE_IN_LOOP: + + /* inform the core to unloop the channel*/ + ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); + + /* since we need to acknowledge the hang up set the flag for remote release */ + sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL); + + /* go to hangup complete to send the RLC */ + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE); + + /* save the call info for the RLC */ + sngss7_info->suInstId = get_unique_id(); + sngss7_info->spInstId = spInstId; + + break; + /**************************************************************************/ default: /* throw the reset flag */ @@ -1293,15 +1310,6 @@ ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t ci /* switch to the IN_LOOP state */ ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_IN_LOOP); - /* store the sngss7 ids */ - if (suInstId == 0) { - sngss7_info->suInstId = get_unique_id(); - } else { - sngss7_info->suInstId = suInstId; - } - sngss7_info->spInstId = spInstId; - sngss7_info->globalFlg = globalFlg; - /* unlock the channel again before we exit */ ftdm_mutex_unlock(ftdmchan->mutex); @@ -1662,7 +1670,7 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ sngss7_set_flag(sngss7_info, FLAG_RESET_TX_RSP); /* go to DOWN */ - ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + /*ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);*/ break; /**********************************************************************/ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index ebb4efa311..7612f3dd74 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -93,7 +93,8 @@ ftdm_state_map_t sangoma_ss7_state_map = { ZSM_UNACCEPTABLE, {FTDM_CHANNEL_STATE_IN_LOOP, FTDM_END}, {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, - FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_DOWN, FTDM_END} + FTDM_CHANNEL_STATE_COLLECT, FTDM_CHANNEL_STATE_DOWN, + FTDM_CHANNEL_STATE_HANGUP_COMPLETE, FTDM_END} }, { ZSD_INBOUND, @@ -970,6 +971,14 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) ftdm_set_state_locked (ftdmchan, ftdmchan->last_state); break; /******************************************************************/ + case (FTDM_CHANNEL_STATE_IN_LOOP): + /* we screwed up in a COT/CCR, remove the loop */ + ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL); + + /* go to down */ + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN); + break; + /******************************************************************/ default: /* KONRAD: find out what the cause code should be */ ftdmchan->caller_data.hangup_cause = 41;