diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c index b7eaa37639..34d79837f0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c @@ -207,9 +207,10 @@ int ft_to_sngss7_cfg_all(void) /* go through all the relays channels and configure it */ x = 1; - while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) { + while (x < (MAX_RELAY_CHANNELS)) { /* check if this relay channel has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) { + 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)) { @@ -223,13 +224,13 @@ int ft_to_sngss7_cfg_all(void) g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED; } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */ + } /* while (x < (MAX_RELAY_CHANNELS)) */ x = 1; - while (x < (MAX_MTP_LINKS + 1)) { + while (x < (MAX_MTP_LINKS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED) && - (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0)) { + if ((g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) && + (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED))) { /* configure mtp1 */ if (ftmod_ss7_mtp1_psap_config(x)) { @@ -243,13 +244,13 @@ int ft_to_sngss7_cfg_all(void) g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED; } x++; - } /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ x = 1; - while (x < (MAX_MTP_LINKS + 1)) { + while (x < (MAX_MTP_LINKS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED) && - (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0)) { + if ((g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) && + (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED))) { /* configure mtp2 */ if (ftmod_ss7_mtp2_dlsap_config(x)) { @@ -263,13 +264,13 @@ int ft_to_sngss7_cfg_all(void) g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED; } x++; - } /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ x = 1; - while (x < (MAX_MTP_LINKS + 1)) { + while (x < (MAX_MTP_LINKS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED) && - (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0)) { + 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)) { @@ -284,12 +285,13 @@ int ft_to_sngss7_cfg_all(void) } x++; - } /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ x = 1; - while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) { + while (x < (MAX_NSAPS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED)) { + 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) { @@ -312,12 +314,13 @@ int ft_to_sngss7_cfg_all(void) } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */ + } /* while (x < (MAX_NSAPS)) */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) { + while (x < (MAX_MTP_LINKSETS+1)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED)) { + 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); @@ -331,12 +334,13 @@ int ft_to_sngss7_cfg_all(void) } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */ + } /* while (x < (MAX_MTP_LINKSETS+1)) */ x = 1; - while ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0)) { + while (x < (MAX_MTP_ROUTES+1)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED)) { + 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); @@ -350,12 +354,13 @@ int ft_to_sngss7_cfg_all(void) } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */ + } /* while (x < (MAX_MTP_ROUTES+1)) */ x = 1; - while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) { + while (x < (MAX_ISAPS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED)) { + 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); @@ -369,13 +374,14 @@ int ft_to_sngss7_cfg_all(void) } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */ + } /* while (x < (MAX_ISAPS)) */ if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) { x = 1; - while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) { + while (x < (MAX_ISUP_INFS)) { /* check if this link has been configured already */ - if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED)) { + 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); @@ -391,21 +397,25 @@ int ft_to_sngss7_cfg_all(void) } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */ + } /* 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) { + /* 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))) { - if (ftmod_ss7_isup_ckt_config(x)) { - SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x); - return 1; - } else { - SS7_INFO("ISUP CKT %d configuration DONE!\n", x); - } + if (ftmod_ss7_isup_ckt_config(x)) { + SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x); + return 1; + } else { + SS7_INFO("ISUP CKT %d configuration DONE!\n", x); + } - /* set the SNGSS7_CONFIGURED flag */ - g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED; + /* set the SNGSS7_CONFIGURED flag */ + g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED; + } /* if !SNGSS7_CONFIGURED */ x++; } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */ diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c index 2cd3a13e30..887c742282 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c @@ -1366,7 +1366,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char * /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the status request */ @@ -1392,7 +1392,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char * /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Failed to find link=\"%s\"\n", name); @@ -1408,7 +1408,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char * /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) { /* send the status request */ @@ -1436,7 +1436,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char * /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Failed to find link=\"%s\"\n", name); @@ -1452,7 +1452,7 @@ static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *n /* find the linkset request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) { + while(x < (MAX_MTP_LINKSETS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { /* send the status request */ @@ -1487,7 +1487,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the inhibit request */ @@ -1504,7 +1504,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name /* move to the next linkset */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Failed to find link=\"%s\"\n", name); @@ -1519,7 +1519,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -1536,7 +1536,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na /* move to the next linkset */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Failed to find link=\"%s\"\n", name); @@ -1891,7 +1891,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name) /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -1907,7 +1907,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name) /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -1922,7 +1922,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -1938,7 +1938,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -1953,7 +1953,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -1969,7 +1969,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -1984,7 +1984,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char * /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the deactivate request */ @@ -2000,7 +2000,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char * /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -2015,7 +2015,7 @@ static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char /* find the linkset request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) { + while(x < (MAX_MTP_LINKSETS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { /* send the activate request */ @@ -2046,7 +2046,7 @@ static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, cha /* find the linkset request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) { + while(x < (MAX_MTP_LINKSETS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) { /* send the deactivate request */ @@ -2078,7 +2078,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name) /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -2094,7 +2094,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name) /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -2109,7 +2109,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name) /* find the link request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while(x < (MAX_MTP_LINKS+1)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) { /* send the uninhibit request */ @@ -2125,7 +2125,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name) /* move to the next link */ x++; - } /* while (id != 0) */ + } /* while (x < (MAX_MTP_LINKS+1)) */ stream->write_function(stream, "Could not find link=%s\n", name); @@ -2144,7 +2144,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam /* find the channel request by it's name */ x = 1; - while(g_ftdm_sngss7_data.cfg.relay[x].id != 0) { + while(x < (MAX_RELAY_CHANNELS)) { if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) { if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &sta)) { @@ -2168,7 +2168,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam /* move to the next link */ x++; - } /* g_ftdm_sngss7_data.cfg.relay[x].id */ + } /* x < (MAX_RELAY_CHANNELS) */ success: return FTDM_SUCCESS; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c index 8a7b095675..b0a2163fdd 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c @@ -85,9 +85,10 @@ int ft_to_sngss7_activate_all(void) int x; x = 1; - while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) { + while (x < (MAX_ISAPS)) { /* check if this link has already been actived */ - if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE)) { + if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) && + (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE))) { if (ftmod_ss7_enable_isap(x)) { SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x); @@ -101,12 +102,13 @@ int ft_to_sngss7_activate_all(void) } /* if !SNGSS7_ACTIVE */ x++; - } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */ + } /* while (x < (MAX_ISAPS)) */ x = 1; - while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) { + while (x < (MAX_NSAPS)) { /* check if this link has already been actived */ - if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE)) { + if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) && + (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE))) { if (ftmod_ss7_enable_nsap(x)) { SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x); @@ -120,13 +122,14 @@ int ft_to_sngss7_activate_all(void) } /* if !SNGSS7_ACTIVE */ x++; - } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */ + } /* while (x < (MAX_NSAPS)) */ if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) { x = 1; - while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) { + while (x < (MAX_MTP_LINKSETS+1)) { /* check if this link has already been actived */ - if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE)) { + if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) && + (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE))) { if (ftmod_ss7_enable_mtpLinkSet(x)) { SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name); @@ -140,7 +143,7 @@ int ft_to_sngss7_activate_all(void) } /* if !SNGSS7_ACTIVE */ x++; - } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */ + } /* while (x < (MAX_MTP_LINKSETS+1)) */ } return 0; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c index 2a395c9ad1..2e6fc7e8a0 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c @@ -134,7 +134,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -175,7 +175,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -198,7 +198,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -222,7 +222,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -248,7 +248,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -271,7 +271,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) { break; } @@ -366,7 +366,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta) /* find the name for the sap in question */ x = 1; - while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) { + while (x < (MAX_MTP_LINKS+1)) { if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) { 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 70a99ef901..374c8473d2 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 @@ -1062,18 +1062,22 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) } } /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */ - if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) && - (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) { + if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", ""); - /* bring the sig status down */ - sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) { + /* bring the sig status down */ + sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED; + sigev.ev_data.sigstatus.status = FTDM_SIG_STATE_DOWN; + ftdm_span_send_signal(ftdmchan->span, &sigev); + } } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */ /**********************************************************************/ - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX) && + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX))&& !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", ""); /* bring the sig status down */ @@ -1089,8 +1093,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) goto suspend_goto_last; } - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX) && - !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX_DN)){ + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){ SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", ""); /* clear the block flags */ @@ -1113,6 +1116,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /**********************************************************************/ if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) && !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", ""); /* bring the sig status down */ @@ -1128,8 +1132,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) goto suspend_goto_last; } - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX) && - !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX_DN)){ + 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", ""); /* clear the block flags */ @@ -1152,6 +1156,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /**********************************************************************/ if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX) && !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", ""); /* send a BLA */ @@ -1164,8 +1169,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) goto suspend_goto_last; } - if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX) && - !sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX_DN)) { + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", ""); /* clear the block flags */ @@ -1185,6 +1190,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /**********************************************************************/ if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK) && !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK_DN)) { + SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", ""); /* bring the channel signaling status to down */ @@ -1205,8 +1211,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) goto suspend_goto_last; } - if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK) && - !sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK_DN)) { + if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) { SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", ""); /* remove the UCIC block flag */ @@ -1223,7 +1228,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) goto suspend_goto_restart; } - SS7_ERROR_CHAN(ftdmchan,"No block flag processed!%s\n", ""); + SS7_DEBUG_CHAN(ftdmchan,"No block flag processed!%s\n", ""); suspend_goto_last: state_flag = 0; @@ -1645,7 +1650,7 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) { /* go through all the relays channels and configure it */ x = 1; - while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) { + while (x < (MAX_RELAY_CHANNELS)) { /* check if this relay channel has been configured already */ if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) { @@ -1661,7 +1666,7 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED; } /* if !SNGSS7_CONFIGURED */ x++; - } /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */ + } /* while (x < (MAX_RELAY_CHANNELS)) */ ftmod_ss7_shutdown_relay(); sng_isup_free_relay(); 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 2b915b1053..4513deebea 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 @@ -1319,7 +1319,7 @@ ftdm_status_t check_status_of_all_isup_intf(void) /* go through all the isupIntfs and ask the stack to give their current state */ x = 1; - for (x = 1; x < (MAX_ISUP_INFS + 1); x++) { + for (x = 1; x < (MAX_ISUP_INFS); x++) { /**************************************************************************/ if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue; @@ -1376,7 +1376,7 @@ ftdm_status_t check_status_of_all_isup_intf(void) } /* switch (status) */ /**************************************************************************/ - } /* for (x = 1; x < MAX_ISUP_INFS + 1); i++) */ + } /* for (x = 1; x < MAX_ISUP_INFS); i++) */ return FTDM_SUCCESS; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c index 49da10cdf1..dd4bb60dd1 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c @@ -1215,7 +1215,7 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset) /* go through all the mtp3 links and fill in the apc */ i = 1; - while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) { + while (i < (MAX_MTP_LINKS)) { if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) { g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc; } @@ -1757,7 +1757,7 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) /**************************************************************************/ /* go through all the links and check if they belong to this linkset*/ i = 1; - while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) { + while (i < (MAX_MTP_LINKS)) { /* check if this link is in the linkset */ if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == lnkSet->lsId) { /* fill in the spc */ @@ -2461,7 +2461,7 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i { int i = 1; - while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) { + while (i < (MAX_MTP_ROUTES)) { if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) { /* we have a match so break out of this loop */ break; @@ -2471,6 +2471,16 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i } if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { + /* this is a new route...find the first free spot */ + i = 1; + while (i < (MAX_MTP_ROUTES)) { + if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { + /* we have a match so break out of this loop */ + break; + } + /* move on to the next one */ + i++; + } g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i; SS7_DEBUG("found new mtp3 self route\n"); } else {