From a382990d9f23096d04812cea6d66f6c3f3994e89 Mon Sep 17 00:00:00 2001 From: Konrad Hammel Date: Fri, 21 Jan 2011 12:04:33 -0500 Subject: [PATCH] chlog: freetdm: ss7 - bug fix: a route now supports multiple linksets --- libs/freetdm/mod_freetdm/mod_freetdm.c | 2 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 51 +++++++++++++++---- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index d972cd7406..92cf9e54b9 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -2462,7 +2462,7 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn } /* add mtp routes */ - if (add_config_list_nodes(isup, rootnode, "mtp_routes", "mtp_route", NULL, NULL)) { + if (add_config_list_nodes(isup, rootnode, "mtp_routes", "mtp_route", "linksets", "linkset")) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed to process mtp_routes for sng_isup config %s\n", confname); ftdm_conf_node_destroy(rootnode); return NULL; 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 277951c5d1..93f2678d08 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 @@ -1269,6 +1269,10 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) int num_parms = mtp_route->n_parameters; int i; + ftdm_conf_node_t *linkset; + int ls_id; + int numLinks; + /* initalize the mtpRoute structure */ memset(&mtpRoute, 0x0, sizeof(mtpRoute)); @@ -1299,11 +1303,6 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) mtpRoute.dpc = atoi(parm->val); SS7_DEBUG("Found an mtpRoute dpc = %d\n", mtpRoute.dpc); /**********************************************************************/ - } else if (!strcasecmp(parm->var, "linksetId")) { - /**********************************************************************/ - mtpRoute.linkSetId = atoi(parm->val); - SS7_DEBUG("Found an mtpRoute linkset = %s\n", parm->val); - /**********************************************************************/ } else if (!strcasecmp(parm->var, "isSTP")) { /**********************************************************************/ if (!strcasecmp(parm->val, "no")) { @@ -1383,15 +1382,47 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route) parm = parm + 1; } - /* pull up the linktype, switchtype, and SSF from the linkset */ - mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].linkType; - mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].switchType; - mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].ssf; - /* fill in the rest of the values in the mtpRoute struct */ mtpRoute.nwId = mtpRoute.id; mtpRoute.cmbLinkSetId = mtpRoute.id; + /* parse in the list of linksets this route is reachable by */ + linkset = mtp_route->child->child; + + while (linkset != NULL) { + /**************************************************************************/ + /* extract the linkset Id */ + ls_id = 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); + } else { + SS7_ERROR("Found mtpRoute linkset id = %d that is invalid\n",ls_id); + 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; + + /* extract the number of cmbLinkSetId aleady on this linkset */ + numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks; + + /* add this routes cmbLinkSetId to the list */ + g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].links[numLinks] = mtpRoute.cmbLinkSetId; + + /* increment the number of cmbLinkSets on this linkset */ + g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks++; + +move_along: + /* move to the next linkset element */ + linkset = linkset->next; + + /**************************************************************************/ + } /* while (linkset != null) */ + + ftmod_ss7_fill_in_mtp3_route(&mtpRoute); ftmod_ss7_fill_in_nsap(&mtpRoute);