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 15fc1ef5db..01d101300e 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 @@ -74,6 +74,7 @@ int ftmod_ss7_relay_chan_config(int id); int ft_to_sngss7_cfg_all(void) { int x = 0; + int ret = 0; /* check if we have done gen_config already */ if (!(g_ftdm_sngss7_data.gen_config)) { @@ -289,15 +290,17 @@ int ft_to_sngss7_cfg_all(void) /* check if this link has been configured already */ if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED)) { - if (ftmod_ss7_mtp3_nsap_config(x)) { - SS7_CRITICAL("MTP3 NSAP %d configuration FAILED!\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); } - if (ftmod_ss7_isup_nsap_config(x)) { - SS7_CRITICAL("ISUP NSAP %d configuration FAILED!\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); @@ -580,7 +583,7 @@ int ftmod_ss7_mtp3_gen_config(void) cfg.t.cfg.s.snGen.ssfValid = TRUE; /* ssf validation required */ cfg.t.cfg.s.snGen.nmbDLSap = MAX_SN_LINKS; /* number of MTP Data Link SAPs */ - cfg.t.cfg.s.snGen.nmbNSap = MAX_SN_VARIANTS; /* number of Upper Layer Saps */ + cfg.t.cfg.s.snGen.nmbNSap = MAX_SN_ROUTES; /* number of Upper Layer Saps */ cfg.t.cfg.s.snGen.nmbRouts = MAX_SN_ROUTES; /* maximum number of routing entries */ cfg.t.cfg.s.snGen.nmbLnkSets = MAX_SN_LINKSETS; /* number of link sets */ cfg.t.cfg.s.snGen.nmbRteInst = MAX_SN_ROUTES*16; /* number of simultaneous Rte instances */ 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 4ab4359c93..0298429109 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 @@ -1131,46 +1131,57 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj; ftdmchan = ss7_info->ftdmchan; - /* grab the signaling_status */ - ftdm_channel_get_sig_status(ftdmchan, &sigstatus); + if (ftdmchan == NULL) { + /* this should never happen!!! */ + stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|FTDMCHAN DOES NOT EXISTS", + ckt->span, + ckt->chan, + ckt->cic); + + } else { + /* grab the signaling_status */ + ftdm_channel_get_sig_status(ftdmchan, &sigstatus); + + stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|", + ckt->span, + ckt->chan, + ckt->cic, + ftdm_signaling_status2str(sigstatus), + ftdm_channel_state2str(ftdmchan->state)); + + if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || + (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) { + stream->write_function(stream, "l_mn=Y|"); + }else { + stream->write_function(stream, "l_mn=N|"); + } + + if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || + (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) { + stream->write_function(stream, "r_mn=Y|"); + }else { + stream->write_function(stream, "r_mn=N|"); + } + + if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) { + stream->write_function(stream, "l_hw=Y|"); + }else { + stream->write_function(stream, "l_hw=N|"); + } + + if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) { + stream->write_function(stream, "r_hw=Y|"); + }else { + stream->write_function(stream, "r_hw=N|"); + } - stream->write_function(stream, "span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|", - ckt->span, - ckt->chan, - ckt->cic, - ftdm_signaling_status2str(sigstatus), - ftdm_channel_state2str(ftdmchan->state)); - - if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) { - stream->write_function(stream, "l_mn=Y|"); - }else { - stream->write_function(stream, "l_mn=N|"); + if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) { + stream->write_function(stream, "relay=Y|"); + }else { + stream->write_function(stream, "relay=N|"); + } } - if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) { - stream->write_function(stream, "r_mn=Y|"); - }else { - stream->write_function(stream, "r_mn=N|"); - } - - if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) { - stream->write_function(stream, "l_hw=Y|"); - }else { - stream->write_function(stream, "l_hw=N|"); - } - - if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) { - stream->write_function(stream, "r_hw=Y|"); - }else { - stream->write_function(stream, "r_hw=N|"); - } - - if(sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) { - stream->write_function(stream, "relay=Y|"); - }else { - stream->write_function(stream, "relay=N|"); - } - stream->write_function(stream, "flags=0x%X",ss7_info->ckt_flags); stream->write_function(stream, "\n"); 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 adee000abb..ad528272c4 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 @@ -1570,26 +1570,33 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) { sng_isup_free_cc(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC); } if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) { ftmod_ss7_shutdown_isup(); sng_isup_free_isup(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP); } if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) { ftmod_ss7_shutdown_mtp3(); sng_isup_free_mtp3(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP3); } if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) { ftmod_ss7_shutdown_mtp2(); sng_isup_free_mtp2(); sng_isup_free_mtp1(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2); } - ftmod_ss7_shutdown_relay(); - sng_isup_free_relay(); + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) { + ftmod_ss7_shutdown_relay(); + sng_isup_free_relay(); + sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY); + } sng_isup_free_sm(); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index 5272aa8bac..fe291fb305 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h @@ -219,13 +219,18 @@ typedef struct sng_link_set { uint32_t links[16]; } sng_link_set_t; +typedef struct sng_link_set_list { + uint32_t lsId; + struct sng_link_set_list *next; +} sng_link_set_list_t; + typedef struct sng_route { char name[MAX_NAME_LEN]; uint32_t flags; uint32_t id; uint32_t dpc; uint32_t cmbLinkSetId; - uint32_t linkSetId; + struct sng_link_set_list lnkSets; uint32_t linkType; uint32_t switchType; uint32_t ssf; 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 d2fa973393..dc6428d0bb 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 @@ -1268,9 +1268,9 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) ftdm_conf_parameter_t *parm = mtp_route->parameters; int num_parms = mtp_route->n_parameters; int i; + sng_link_set_list_t *lnkSet; ftdm_conf_node_t *linkset; - int ls_id; int numLinks; /* initalize the mtpRoute structure */ @@ -1383,42 +1383,50 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) } /* fill in the rest of the values in the mtpRoute struct */ - mtpRoute.nwId = mtpRoute.id; + mtpRoute.nwId = 0; mtpRoute.cmbLinkSetId = mtpRoute.id; /* parse in the list of linksets this route is reachable by */ linkset = mtp_route->child->child; + /* initalize the link-list of linkSet Ids */ + lnkSet = &mtpRoute.lnkSets; + while (linkset != NULL) { /**************************************************************************/ /* extract the linkset Id */ - ls_id = atoi(linkset->parameters->val); + lnkSet->lsId = atoi(linkset->parameters->val); - if (g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].id != 0) { - SS7_DEBUG("Found mtpRoute linkset id = %d that is valid\n",ls_id); + if (g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].id != 0) { + SS7_DEBUG("Found mtpRoute linkset id = %d that is valid\n",lnkSet->lsId); } else { - SS7_ERROR("Found mtpRoute linkset id = %d that is invalid\n",ls_id); + SS7_ERROR("Found mtpRoute linkset id = %d that is invalid\n",lnkSet->lsId); goto move_along; } /* pull up the linktype, switchtype, and SSF from the linkset */ - mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].linkType; - mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].switchType; - mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].ssf; + mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].linkType; + mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].switchType; + mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].ssf; /* extract the number of cmbLinkSetId aleady on this linkset */ - numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks; + numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; /* add this routes cmbLinkSetId to the list */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].links[numLinks] = mtpRoute.cmbLinkSetId; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[numLinks] = mtpRoute.cmbLinkSetId; /* increment the number of cmbLinkSets on this linkset */ - g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks++; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; + + /* update the linked list */ + lnkSet->next = ftdm_malloc(sizeof(sng_link_set_list_t)); + lnkSet = lnkSet->next; + lnkSet->lsId = 0; + lnkSet->next = NULL; move_along: /* move to the next linkset element */ linkset = linkset->next; - /**************************************************************************/ } /* while (linkset != null) */ @@ -1465,6 +1473,7 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) { sng_isup_inf_t sng_isup; sng_isap_t sng_isap; + sng_link_set_list_t *lnkSet; ftdm_conf_parameter_t *parm = isup_interface->parameters; int num_parms = isup_interface->n_parameters; int i; @@ -1500,7 +1509,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) } else if (!strcasecmp(parm->var, "spc")) { /**********************************************************************/ sng_isup.spc = atoi(parm->val); - g_ftdm_sngss7_data.cfg.spc = sng_isup.spc; SS7_DEBUG("Found an isup SPC = %d\n", sng_isup.spc); /**********************************************************************/ } else if (!strcasecmp(parm->var, "mtprouteId")) { @@ -1747,17 +1755,14 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface) sngss7_set_flag(&sng_isup, SNGSS7_PAUSED); /* trickle down the SPC to all sub entities */ - int linkSetId; + lnkSet = &g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].lnkSets; - linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].linkSetId; + g_ftdm_sngss7_data.cfg.mtp3Link[lnkSet->lsId].spc = sng_isup.spc; + lnkSet = lnkSet->next; - i = 1; - while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) { - if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == linkSetId) { - g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = g_ftdm_sngss7_data.cfg.spc; - } - - i++; + while (lnkSet->next != NULL) { + g_ftdm_sngss7_data.cfg.mtp3Link[lnkSet->lsId].spc = sng_isup.spc; + lnkSet = lnkSet->next; } /* pull values from the lower levels */ @@ -2342,7 +2347,10 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet) /******************************************************************************/ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route) { - int i = mtp3_route->id; + sng_link_set_list_t *lnkSet = NULL; + int i = mtp3_route->id; + int tmp = 0; + /* check if this id value has been used already */ if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) { @@ -2355,10 +2363,19 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route) } /* fill in the cmbLinkSet in the linkset structure */ - int tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route->linkSetId].numLinks; + lnkSet = &mtp3_route->lnkSets; - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route->linkSetId].links[tmp] = mtp3_route->cmbLinkSetId; - g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route->linkSetId].numLinks++; + tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; + + while (lnkSet->next != NULL) { + tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].links[tmp] = mtp3_route->cmbLinkSetId; + g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet->lsId].numLinks++; + + lnkSet = lnkSet->next; + } strcpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route->name); @@ -2369,7 +2386,7 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route) g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId = mtp3_route->cmbLinkSetId; g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP = mtp3_route->isSTP; g_ftdm_sngss7_data.cfg.mtpRoute[i].nwId = mtp3_route->nwId; - g_ftdm_sngss7_data.cfg.mtpRoute[i].linkSetId = mtp3_route->linkSetId; + g_ftdm_sngss7_data.cfg.mtpRoute[i].lnkSets = mtp3_route->lnkSets; g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf = mtp3_route->ssf; if (mtp3_route->t6 != 0) { g_ftdm_sngss7_data.cfg.mtpRoute[i].t6 = mtp3_route->t6; @@ -2439,8 +2456,7 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route) i = 1; while (g_ftdm_sngss7_data.cfg.nsap[i].id != 0) { if ((g_ftdm_sngss7_data.cfg.nsap[i].linkType == mtp3_route->linkType) && - (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route->switchType) && - (g_ftdm_sngss7_data.cfg.nsap[i].ssf == mtp3_route->ssf)) { + (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route->switchType)) { /* we have a match so break out of this loop */ break; @@ -2789,6 +2805,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) sngss7_chan_data_t *ss7_info = NULL; int x; int count = 1; + int flag; while (ccSpan->ch_map[0] != '\0') { /**************************************************************************/ @@ -2799,13 +2816,45 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) return FTDM_FAIL; } - /* find the spot in master array for this circuit */ - x = (ccSpan->procId * 1000) + count; + /* find a spot for this circuit in the global structure */ + x = (ccSpan->procId * 1000); + flag = 0; + while (flag == 0) { + /**********************************************************************/ + /* check the id value ( 0 = new, 0 > circuit can be existing) */ + if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) { + /* we're at the end of the list of circuitsl aka this is new */ + SS7_DEBUG("Found a new circuit %d, ccSpanId=%d, chan=%d\n", + x, + ccSpan->id, + count); - /* check if this circuit has already been filled in */ - if (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) { - SS7_DEVEL_DEBUG("Filling in circuit that already exists...%d\n", x); - } + /* throw the flag to end the loop */ + flag = 1; + } else { + /* check the ccspan.id and chan to see if the circuit already exists */ + if ((g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId == ccSpan->id) && + (g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count)) { + + /* we are processing a circuit that already exists */ + SS7_DEBUG("Found an existing circuit %d, ccSpanId=%d, chan%d\n", + x, + ccSpan->id, + count); + + /* throw the flag to end the loop */ + flag = 1; + + /* not supporting reconfig at this time */ + SS7_DEBUG("Not supporting ckt reconfig at this time!\n"); + goto move_along; + } else { + /* this is not the droid you are looking for */ + x++; + } + } + /**********************************************************************/ + } /* while (flag == 0) */ /* prepare the global info sturcture */ ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t)); @@ -2901,6 +2950,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) g_ftdm_sngss7_data.cfg.isupCkt[x].cic, g_ftdm_sngss7_data.cfg.isupCkt[x].id); +move_along: /* increment the span channel count */ count++;