]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: ftdm_running checks on handle, implemented no wait block
authorNenad Corbic <ncorbic@sangoma.com>
Tue, 25 Oct 2011 22:05:41 +0000 (18:05 -0400)
committerNenad Corbic <ncorbic@sangoma.com>
Tue, 25 Oct 2011 22:05:41 +0000 (18:05 -0400)
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c

index b0a2163fdd256eb90635831dffcd9dd3af9245f5..d57526b2671c306c38dc14d1ee6ba67bf9254d4e 100644 (file)
@@ -48,35 +48,7 @@ static int ftmod_ss7_enable_isap(int suId);
 static int ftmod_ss7_enable_nsap(int suId);
 static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId);
 
-int ftmod_ss7_inhibit_mtp3link(uint32_t id);
-int ftmod_ss7_uninhibit_mtp3link(uint32_t id);
 
-int ftmod_ss7_bind_mtp3link(uint32_t id);
-int ftmod_ss7_unbind_mtp3link(uint32_t id);
-int ftmod_ss7_activate_mtp3link(uint32_t id);
-int ftmod_ss7_deactivate_mtp3link(uint32_t id);
-int ftmod_ss7_deactivate2_mtp3link(uint32_t id);
-
-int ftmod_ss7_activate_mtplinkSet(uint32_t id);
-int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
-int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
-
-int ftmod_ss7_lpo_mtp3link(uint32_t id);
-int ftmod_ss7_lpr_mtp3link(uint32_t id);
-
-int ftmod_ss7_shutdown_isup(void);
-int ftmod_ss7_shutdown_mtp3(void);
-int ftmod_ss7_shutdown_mtp2(void);
-int ftmod_ss7_shutdown_relay(void);
-int ftmod_ss7_disable_relay_channel(uint32_t chanId);
-
-int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
-int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
-
-int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
-
-int ftmod_ss7_block_isup_ckt(uint32_t cktId);
-int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
@@ -848,7 +820,7 @@ int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId)
 }
 
 /******************************************************************************/
-int ftmod_ss7_block_isup_ckt(uint32_t cktId)
+int __ftmod_ss7_block_isup_ckt(uint32_t cktId, ftdm_bool_t wait)
 {
        SiMngmt cntrl;
        Pst pst;
@@ -876,7 +848,11 @@ int ftmod_ss7_block_isup_ckt(uint32_t cktId)
        cntrl.t.cntrl.action                                    = ADISIMM;              /* block via BLO */
        cntrl.t.cntrl.subAction                                 = SAELMNT;              /* specificed element */
 
-       return (sng_cntrl_isup(&pst, &cntrl));
+       if (wait == FTDM_TRUE) {
+               return (sng_cntrl_isup(&pst, &cntrl));
+       } else {
+               return (sng_cntrl_isup_nowait(&pst, &cntrl));
+       }
 }
 
 /******************************************************************************/
index 59a226d738301d124191b0f4a47b7a991b2f2ff9..8d01a6d97e7226e9daccc8d5408727b0eb7e73b5 100644 (file)
@@ -87,6 +87,8 @@ ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
 /* FUNCTIONS ******************************************************************/
 
+#define ftdm_running_return(var) if (!ftdm_running()) { SS7_ERROR("Error: ftdm_running is not set! Ignoring\n"); return var; } 
+
 ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt)
 {
        SS7_FUNC_TRACE_ENTER(__FUNCTION__);
@@ -97,6 +99,8 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        memset(var, '\0', sizeof(var));
 
+       ftdm_running_return(FTDM_FAIL);
+
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
                SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
@@ -341,6 +345,8 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -596,6 +602,8 @@ ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -671,6 +679,8 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -793,6 +803,8 @@ ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -844,6 +856,8 @@ ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -871,6 +885,8 @@ ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -898,6 +914,8 @@ ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -925,6 +943,8 @@ ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t cir
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -952,6 +972,8 @@ ftdm_status_t handle_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t cir
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -979,6 +1001,8 @@ ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t cir
        
        sngss7_chan_data_t  *sngss7_info ;
        ftdm_channel_t    *ftdmchan;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -1003,6 +1027,8 @@ ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t cir
 ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt)
 {
        SS7_FUNC_TRACE_ENTER(__FUNCTION__);
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is active on our side otherwise move to the next circuit */
        if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
@@ -1203,6 +1229,8 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1266,6 +1294,8 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui
        int                              infId;
        int                              i;
        
+       ftdm_running_return(FTDM_FAIL);
+       
        /* extract the affected infId from the circuit structure */
        infId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;
 
@@ -1330,6 +1360,8 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu
        ftdm_channel_t    *ftdmchan = NULL;
        int                              infId;
        int                              i;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* extract the affect infId from the circuit structure */
        infId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;
@@ -1394,6 +1426,8 @@ ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t ci
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1449,6 +1483,8 @@ ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t cir
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1494,6 +1530,8 @@ ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit,
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1562,6 +1600,8 @@ ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1612,6 +1652,8 @@ ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1653,6 +1695,8 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1741,6 +1785,8 @@ ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1800,6 +1846,8 @@ ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1858,6 +1906,8 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -1948,6 +1998,8 @@ ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        ftdm_channel_t *ftdmchan = NULL;
        sngss7_span_data_t *sngss7_span = NULL;
        int range = 0;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -2005,6 +2057,8 @@ ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        ftdm_channel_t *ftdmchan = NULL;
        sngss7_span_data_t *sngss7_span = NULL; 
        int range = 0;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -2069,6 +2123,8 @@ ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t ci
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -2119,6 +2175,8 @@ ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t ci
 
        sngss7_chan_data_t  *sngss7_info = NULL;
        ftdm_channel_t    *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -2174,6 +2232,7 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
        sngss7_span_data_t *sngss7_span = NULL;
        ftdm_channel_t *ftdmchan = NULL;
 
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
@@ -2255,6 +2314,8 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        int                                     bit = 0;
        int                             x;
 
+       ftdm_running_return(FTDM_FAIL);
+
        memset(&status[0], '\0', sizeof(status));
 
        /* confirm that the circuit is voice channel */
@@ -2401,6 +2462,8 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        int                                     bit = 0;
        int                             x;
        ftdm_sigmsg_t           sigev;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        memset(&sigev, 0, sizeof (sigev));
        memset(&status[0], '\0', sizeof(status));
@@ -2538,6 +2601,8 @@ ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circ
 
        sngss7_chan_data_t      *sngss7_info = NULL;
        ftdm_channel_t          *ftdmchan = NULL;
+       
+       ftdm_running_return(FTDM_FAIL);
 
        /* confirm that the circuit is voice channel */
        if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].type != SNG_CKT_VOICE) {
index 3fd5c6e46835dc3f1a97606ccefb6d4bb484c86b..cdef8942320773757e53f8f65c1fb3dc64a2d6d1 100644 (file)
@@ -732,7 +732,9 @@ int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
 
 int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
 
-int ftmod_ss7_block_isup_ckt(uint32_t cktId);
+#define ftmod_ss7_block_isup_ckt(x)            __ftmod_ss7_block_isup_ckt(x,FTDM_TRUE)
+#define ftmod_ss7_block_isup_ckt_nowait(x)     __ftmod_ss7_block_isup_ckt(x,FTDM_FALSE)
+int __ftmod_ss7_block_isup_ckt(uint32_t cktId, ftdm_bool_t wait);
 int ftmod_ss7_unblock_isup_ckt(uint32_t cktId);
 
 
index 1d85dfffbb2b66d52c28b4cc24f2c95b98b47227..f58aad4ca7d0161aad72428ba824405bb5be437f 100644 (file)
@@ -248,7 +248,7 @@ ftdm_status_t block_all_ckts_for_relay(uint32_t procId)
                if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == SNG_CKT_VOICE) {
 
                        /* send a block request via stack manager */
-                       ret = ftmod_ss7_block_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+                       ret = ftmod_ss7_block_isup_ckt_nowait(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
                        if (ret) {
                                SS7_INFO("Successfully BLOcked CIC:%d(ckt:%d) due to Relay failure\n", 
                                                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic,