]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: fixing relay must start after master.
authorJames Zhang <jzhang@sangoma.com>
Tue, 15 Nov 2011 19:46:57 +0000 (14:46 -0500)
committerJames Zhang <jzhang@sangoma.com>
Tue, 15 Nov 2011 19:46:57 +0000 (14:46 -0500)
         relay - configuring circuits only when resume is recieved.
 master - configuring relay after all the others are configured.

libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c

index e51428acaa2d1eda48bcc345bda3fd8f7c243671..25510e8c7a8344415d47fb440dbaff6b174015c4 100644 (file)
@@ -220,27 +220,6 @@ int  ft_to_sngss7_cfg_all(void)
                        return 1;
        }
 
-       /* go through all the relays channels and configure it */
-       x = 1;
-       while (x < (MAX_RELAY_CHANNELS)) {
-               /* check if this relay channel has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.relay[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED))) {
-
-                       /* send the specific configuration */
-                       if (ftmod_ss7_relay_chan_config(x)) {
-                               SS7_CRITICAL("Relay Channel %d configuration FAILED!\n", x);
-                               return 1;
-                       } else {
-                               SS7_INFO("Relay Channel %d configuration DONE!\n", x);
-                       }
-
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED;
-               } /* if !SNGSS7_CONFIGURED */
-               x++;
-       } /* while (x < (MAX_RELAY_CHANNELS)) */
-
        x = 1;
        while (x < (MAX_MTP_LINKS)) {
                /* check if this link has been configured already */
@@ -281,160 +260,189 @@ int  ft_to_sngss7_cfg_all(void)
                x++;
        } /* while (x < (MAX_MTP_LINKS+1)) */
 
-       x = 1;
-       while (x < (MAX_MTP_LINKS)) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED))) {
+       /* no configs above mtp2 for relay */
+       if (g_ftdm_sngss7_data.cfg.procId == 1) {
+               x = 1;
+               while (x < (MAX_MTP_LINKS)) {
+                       /* check if this link has been configured already */
+                       if ((g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED))) {
 
-                       /* configure mtp3 */
-                       if (ftmod_ss7_mtp3_dlsap_config(x)) {
-                               SS7_CRITICAL("MTP3 DLSAP %d configuration FAILED!\n", x);
-                               return 1;;
-                       } else {
-                               SS7_INFO("MTP3 DLSAP %d configuration DONE!\n", x);
+                               /* configure mtp3 */
+                               if (ftmod_ss7_mtp3_dlsap_config(x)) {
+                                       SS7_CRITICAL("MTP3 DLSAP %d configuration FAILED!\n", x);
+                                       return 1;;
+                               } else {
+                                       SS7_INFO("MTP3 DLSAP %d configuration DONE!\n", x);
+                               }
+
+                               /* set the SNGSS7_CONFIGURED flag */
+                               g_ftdm_sngss7_data.cfg.mtp3Link[x].flags |= SNGSS7_CONFIGURED;
                        }
+                       
+                       x++;
+               } /* while (x < (MAX_MTP_LINKS+1)) */
 
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.mtp3Link[x].flags |= SNGSS7_CONFIGURED;
-               }
-               
-               x++;
-       } /* while (x < (MAX_MTP_LINKS+1)) */
+               x = 1;
+               while (x < (MAX_NSAPS)) {
+                       /* check if this link has been configured already */
+                       if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED))) {
 
-       x = 1;
-       while (x < (MAX_NSAPS)) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED))) {
+                               ret = ftmod_ss7_mtp3_nsap_config(x);
+                               if (ret) {
+                                       SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
+                                       return 1;
+                               } else {
+                                       SS7_INFO("MTP3 NSAP %d configuration DONE!\n", x);
+                               }
 
-                       ret = ftmod_ss7_mtp3_nsap_config(x);
-                       if (ret) {
-                               SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
-                               return 1;
-                       } else {
-                               SS7_INFO("MTP3 NSAP %d configuration DONE!\n", x);
-                       }
+                               ret = ftmod_ss7_isup_nsap_config(x);
+                               if (ret) {
+                                       SS7_CRITICAL("ISUP NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
+                                       return 1;
+                               } else {
+                                       SS7_INFO("ISUP NSAP %d configuration DONE!\n", x);
+                               }
 
-                       ret = ftmod_ss7_isup_nsap_config(x);
-                       if (ret) {
-                               SS7_CRITICAL("ISUP NSAP %d configuration FAILED!(%s)\n", x, DECODE_LCM_REASON(ret));
-                               return 1;
-                       } else {
-                               SS7_INFO("ISUP NSAP %d configuration DONE!\n", x);
-                       }
+                               /* set the SNGSS7_CONFIGURED flag */
+                               g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_CONFIGURED;
+                       } /* if !SNGSS7_CONFIGURED */
+                       
+                       x++;
+               } /* while (x < (MAX_NSAPS)) */
 
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_CONFIGURED;
-               } /* if !SNGSS7_CONFIGURED */
-               
-               x++;
-       } /* while (x < (MAX_NSAPS)) */
+               x = 1;
+               while (x < (MAX_MTP_LINKSETS+1)) {
+                       /* check if this link has been configured already */
+                       if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED))) {
 
-       x = 1;
-       while (x < (MAX_MTP_LINKSETS+1)) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED))) {
+                               if (ftmod_ss7_mtp3_linkset_config(x)) {
+                                       SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
+                                       return 1;
+                               } else {
+                                       SS7_INFO("MTP3 LINKSET %d configuration DONE!\n", x);
+                               }
 
-                       if (ftmod_ss7_mtp3_linkset_config(x)) {
-                               SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
-                               return 1;
-                       } else {
-                               SS7_INFO("MTP3 LINKSET %d configuration DONE!\n", x);
-                       }
+                               /* set the SNGSS7_CONFIGURED flag */
+                               g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_CONFIGURED;
+                       } /* if !SNGSS7_CONFIGURED */
+                       
+                       x++;
+               } /* while (x < (MAX_MTP_LINKSETS+1)) */
 
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_CONFIGURED;
-               } /* if !SNGSS7_CONFIGURED */
-               
-               x++;
-       } /* while (x < (MAX_MTP_LINKSETS+1)) */
+               x = 1;
+               while (x < (MAX_MTP_ROUTES+1)) {
+                       /* check if this link has been configured already */
+                       if ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED))) {
 
-       x = 1;
-       while (x < (MAX_MTP_ROUTES+1)) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED))) {
+                               if (ftmod_ss7_mtp3_route_config(x)) {
+                                       SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
+                                       return 1;
+                               } else {
+                                       SS7_INFO("MTP3 ROUTE %d configuration DONE!\n",x);
+                               }
 
-                       if (ftmod_ss7_mtp3_route_config(x)) {
-                               SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
-                               return 1;
-                       } else {
-                               SS7_INFO("MTP3 ROUTE %d configuration DONE!\n",x);
-                       }
+                               /* set the SNGSS7_CONFIGURED flag */
+                               g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= SNGSS7_CONFIGURED;
+                       } /* if !SNGSS7_CONFIGURED */
+                       
+                       x++;
+               } /* while (x < (MAX_MTP_ROUTES+1)) */
 
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= SNGSS7_CONFIGURED;
-               } /* if !SNGSS7_CONFIGURED */
-               
-               x++;
-       } /* while (x < (MAX_MTP_ROUTES+1)) */
+               x = 1;
+               while (x < (MAX_ISAPS)) {
+                       /* check if this link has been configured already */
+                       if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED))) {
+                               
+                               if (ftmod_ss7_isup_isap_config(x)) {
+                                       SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
+                                       return 1;
+                               } else {
+                                       SS7_INFO("ISUP ISAP %d configuration DONE!\n", x);
+                               }
 
-       x = 1;
-       while (x < (MAX_ISAPS)) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED))) {
+                               /* set the SNGSS7_CONFIGURED flag */
+                               g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_CONFIGURED;
+                       } /* if !SNGSS7_CONFIGURED */
                        
-                       if (ftmod_ss7_isup_isap_config(x)) {
-                               SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
-                               return 1;
-                       } else {
-                               SS7_INFO("ISUP ISAP %d configuration DONE!\n", x);
-                       }
-
-                       /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_CONFIGURED;
-               } /* if !SNGSS7_CONFIGURED */
+                       x++;
+               } /* while (x < (MAX_ISAPS)) */
+
+               if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) {
+                       x = 1;
+                       while (x < (MAX_ISUP_INFS)) {
+                               /* check if this link has been configured already */
+                               if ((g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) &&
+                                       (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED))) {
                
-               x++;
-       } /* while (x < (MAX_ISAPS)) */
+                                       if (ftmod_ss7_isup_intf_config(x)) {
+                                               SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
+                                               return 1;
+                                       } else {
+                                               SS7_INFO("ISUP INTF %d configuration DONE!\n", x);
+                                               /* set the interface to paused */
+                                               sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);
+                                       }
+               
+                                       /* set the SNGSS7_CONFIGURED flag */
+                                       g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= SNGSS7_CONFIGURED;
+                               } /* if !SNGSS7_CONFIGURED */
+                               
+                               x++;
+                       } /* while (x < (MAX_ISUP_INFS)) */
+               } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
+
+               x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
+               while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+
+                       if (g_ftdm_sngss7_data.cfg.procId > 1) {
+                               break;
+                       }
 
-       if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP_STARTED)) {
-               x = 1;
-               while (x < (MAX_ISUP_INFS)) {
                        /* check if this link has been configured already */
-                       if ((g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) &&
-                               (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED))) {
-       
-                               if (ftmod_ss7_isup_intf_config(x)) {
-                                       SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
+                       if ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
+                               (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & SNGSS7_CONFIGURED))) {
+
+                               if (ftmod_ss7_isup_ckt_config(x)) {
+                                       SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
                                        return 1;
                                } else {
-                                       SS7_INFO("ISUP INTF %d configuration DONE!\n", x);
-                                       /* set the interface to paused */
-                                       sngss7_set_flag(&g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);
+                                       SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
                                }
-       
+
                                /* set the SNGSS7_CONFIGURED flag */
-                               g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= SNGSS7_CONFIGURED;
+                               g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
                        } /* if !SNGSS7_CONFIGURED */
                        
                        x++;
-               } /* while (x < (MAX_ISUP_INFS)) */
-       } /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
+               } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
+       }
 
-       x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
-       while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
-               /* check if this link has been configured already */
-               if ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
-                       (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & SNGSS7_CONFIGURED))) {
+       /* go through all the relays channels and configure it */
+       x = 1;
+       while (x < (MAX_RELAY_CHANNELS)) {
+               /* check if this relay channel has been configured already */
+               if ((g_ftdm_sngss7_data.cfg.relay[x].id != 0) &&
+                       (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED))) {
 
-                       if (ftmod_ss7_isup_ckt_config(x)) {
-                               SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
+                       /* send the specific configuration */
+                       if (ftmod_ss7_relay_chan_config(x)) {
+                               SS7_CRITICAL("Relay Channel %d configuration FAILED!\n", x);
                                return 1;
                        } else {
-                               SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
+                               SS7_INFO("Relay Channel %d configuration DONE!\n", x);
                        }
 
                        /* set the SNGSS7_CONFIGURED flag */
-                       g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
+                       g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED;
                } /* if !SNGSS7_CONFIGURED */
-               
                x++;
-       } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
-
+       } /* while (x < (MAX_RELAY_CHANNELS)) */
+       
        return 0;
 }
 
index 790b893a8db36e91c695b48af135972b9adcfca4..176de9e62703cbfe3e6d259b890a1035109c25db 100644 (file)
@@ -810,6 +810,11 @@ void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
 
                break;
        /**************************************************************************/
+       case (LRY_USTA_TCP_CONN_FAILED):
+               ftdm_log(FTDM_LOG_ERROR,"[RELAY] TCP connection failed \n" );
+
+               break;
+       /**************************************************************************/
        default:
                ftdm_log(FTDM_LOG_ERROR,"Unknown Relay Alram\n");
                break;
index cd7f3ad58ef2d0527ba57bc886db9a0b22045f02..93d76fc8e7d41434c5d7220237914491ddb0ac94 100644 (file)
@@ -1166,10 +1166,24 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
        /**************************************************************************/
        case FTDM_CHANNEL_STATE_SUSPENDED:      /* circuit has been blocked */
 
-                 SS7_DEBUG_CHAN(ftdmchan,"SUSPEND: Current flags: ckt=0x%X, blk=0x%X\n", 
-                                                                       sngss7_info->ckt_flags,
-                                                                       sngss7_info->blk_flags);
-
+               SS7_DEBUG_CHAN(ftdmchan,"SUSPEND: Current flags: ckt=0x%X, blk=0x%X, circuit->flag=0x%X\n", 
+                                       sngss7_info->ckt_flags, sngss7_info->blk_flags,
+                                       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))) {
+                               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;
+                               } else {
+                                       SS7_INFO("ISUP CKT %d configuration DONE!\n", sngss7_info->circuit->id);
+                               }
+                               sngss7_info->circuit->flags |= SNGSS7_CONFIGURED;
+                       }
+               }
+                
                /**********************************************************************/
                if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {
 
index aa50ce2264b92a872152701b770adf755631f06d..4f184590188ad30bf369d8e99310f552cbeaa1d5 100644 (file)
@@ -1943,6 +1943,7 @@ ftdm_status_t check_status_of_all_isup_intf(void)
 
                if (ftmod_ss7_isup_intf_sta(sngss7_intf->id, &status)) {
                        SS7_ERROR("Failed to get status of ISUP intf %d\n", sngss7_intf->id);
+                       sngss7_set_flag(sngss7_intf, SNGSS7_PAUSED);
                        continue;
                }