From 5b8af78a897ea2716da18e5be913eca71e72f7f1 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 25 Nov 2011 21:05:39 -0500 Subject: [PATCH] Fixed 5 relay conditions M UP -> S UP M Down -> S UP -> M UP M UP -> S UP -> relay down -> relay up M UP -> S UP -> Kill M -> M UP M Up -> S UP -> relay down -> M link down -> relay up -> M link up --- .../ftmod_sangoma_ss7_main.c | 15 ++++++++------ .../ftmod_sangoma_ss7_relay.c | 8 +++----- .../ftmod_sangoma_ss7_support.c | 20 ++++++++++++++++--- 3 files changed, 29 insertions(+), 14 deletions(-) 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 93d76fc8e7..468c8b0a83 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 @@ -1171,16 +1171,19 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) sngss7_info->circuit->flags ); if (!(sngss7_info->circuit->flags & SNGSS7_CONFIGURED)) { - if ( !sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED) - ||(sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME))) { + /* Configure the circuit if RESUME and PAUSED are not set. + And also in a case when RESUME is set */ + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED) || + sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) { if (ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id)) { SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", sngss7_info->circuit->id); - *(int*)0=0; - return 1; + sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED); + sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME); } else { SS7_INFO("ISUP CKT %d configuration DONE!\n", sngss7_info->circuit->id); + sngss7_info->circuit->flags |= SNGSS7_CONFIGURED; + sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX); } - sngss7_info->circuit->flags |= SNGSS7_CONFIGURED; } } @@ -1391,7 +1394,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* check the last state and return to it to allow the call to finish */ goto suspend_goto_last; } - + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)) { SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", ""); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c index a96dae5cdd..0fb496843f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c @@ -64,11 +64,9 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta) SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id); if (sng_relay->type == LRY_CT_TCP_CLIENT) { - if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) { - if (reconfig_all_ckts_for_relay()) { - SS7_ERROR("Failed to reconfigure ISUP Ckts!\n"); - /* we're done....this is very bad! */ - } + if (reconfig_all_ckts_for_relay()) { + SS7_ERROR("Failed to reconfigure ISUP Ckts!\n"); + /* we're done....this is very bad! */ } return FTDM_SUCCESS; } else if (sng_relay->type == LRY_CT_TCP_SERVER) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c index 4f18459018..6d5880073d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c @@ -2110,6 +2110,7 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) uint8_t bits_ef = 0; int x; int ret; + ret=0; for (x = 1; x < (ftdmspan->chan_count + 1); x++) { /**************************************************************************/ @@ -2147,6 +2148,10 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) /* query for the status of the ckt */ if (ftmod_ss7_isup_ckt_sta(sngss7_info->circuit->id, &state)) { + /* NC: Circuit statistic failed: does not exist. Must re-configure circuit + Reset the circuit CONFIGURED flag so that RESUME will reconfigure + this circuit. */ + sngss7_info->circuit->flags &= ~SNGSS7_CONFIGURED; SS7_ERROR("Failed to read isup ckt = %d status\n", sngss7_info->circuit->id); continue; } @@ -2159,6 +2164,14 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) if (bits_cd == 0x0) { /* check if circuit is UCIC or transient */ if (bits_ab == 0x3) { + SS7_INFO("ISUP CKT %d re-configuration pending!\n", x); + sngss7_info->circuit->flags &= ~SNGSS7_CONFIGURED; + SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); + + /* NC: The code below should be deleted. Its here for hitorical + reason. The RESUME code will reconfigure the channel since + the CONFIGURED flag has been reset */ +#if 0 /* bit a and bit b are set, unequipped */ ret = ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id); if (ret) { @@ -2181,6 +2194,7 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) /* unlock the channel */ ftdm_mutex_unlock(ftdmchan->mutex); +#endif } /* if (bits_ab == 0x3) */ } else { @@ -2192,8 +2206,8 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) break; /**************************************************************************/ case (1): - /* locally blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); + /* locally blocked: Therefore we need to state machine to send an unblock */ + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); /* set the channel to suspended state */ SS7_STATE_CHANGE(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); @@ -2209,7 +2223,7 @@ ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan) /**************************************************************************/ case (3): /* both locally and remotely blocked */ - sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX); + sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_TX); sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); /* set the channel to suspended state */