diff --git a/conf/freeswitch.xml b/conf/freeswitch.xml index 65f6e1812d..42eede31ee 100644 --- a/conf/freeswitch.xml +++ b/conf/freeswitch.xml @@ -52,14 +52,12 @@ - -
- - - - - - - + +
+ + + + +
diff --git a/conf/lang/de/de.xml b/conf/lang/de/de.xml index 5239489f75..1b44c9a1dd 100644 --- a/conf/lang/de/de.xml +++ b/conf/lang/de/de.xml @@ -1,7 +1,11 @@ - - - - + + + + + + + + diff --git a/conf/lang/en/en.xml b/conf/lang/en/en.xml index 6bd5a7d5fb..1e23dc5d7b 100644 --- a/conf/lang/en/en.xml +++ b/conf/lang/en/en.xml @@ -1,8 +1,12 @@ - - - - - + + + + + + + + + diff --git a/conf/lang/fr/fr.xml b/conf/lang/fr/fr.xml index 12bec06f20..eaf00f247e 100644 --- a/conf/lang/fr/fr.xml +++ b/conf/lang/fr/fr.xml @@ -1,8 +1,12 @@ - - - - - + + + + + + + + + diff --git a/conf/lang/he/he.xml b/conf/lang/he/he.xml index 006195bf9a..fe7c5d8a01 100644 --- a/conf/lang/he/he.xml +++ b/conf/lang/he/he.xml @@ -1,7 +1,11 @@ - - - - + + + + + + + + diff --git a/conf/lang/ru/ru.xml b/conf/lang/ru/ru.xml index 25d63b6110..686e840860 100644 --- a/conf/lang/ru/ru.xml +++ b/conf/lang/ru/ru.xml @@ -1,9 +1,13 @@ - - - - + + + + + + + + diff --git a/docs/ChangeLog b/docs/ChangeLog index 9aae7053a2..b4e93ab05c 100644 --- a/docs/ChangeLog +++ b/docs/ChangeLog @@ -238,6 +238,13 @@ freeswitch (1.0.7) core: Fix argument parsing for tone_detect app (r:38c3a67a/FS-3229) core: add L16 def for 32ms and allow timer matrix to drop to 1ms to support nelly (r:82e3d49f) core: fix segfault in zrtp srtcp (r:2330b340) + core: add switch_clean_name_string util function to strip out caller id name chars that can cause issues (r:244048f8) + core: switch_core_sqldb - clear pointer on release (r:aaef33cc) + core: all [] {} and <> can be stacked and override the delim per set <><^^:>{}{^^:}{^^;}[][^^:] (r:4c4bf59e/FS-3246) + core: fix default tipping point it was too low (r:e4eade33) + core: enable optimal defaults on linux kernels that can support newer features. (r:0b51aca3) + core: Lower NAT port mapping disabled log msg from WARNING to INFO (r:973a850d) + core: Change the structure of the phrases/language system. Previously it was fxml->phrases->macros->language->macro. Changed it so fxml->languages->language->phrases->macros->macro You can have sub macros and allow you to call it login@voicemail. Change the sound-path to sound-prefix to make it constistant with the rest of freeswitch. Also allow to set a sound-prefix to a macros, so you can override it for a specific file set. You can set say-modules="en" or whatever in the rdnis.digits); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-TON", "%d", channel_caller_data->rdnis.type); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Plan", "%d", channel_caller_data->rdnis.plan); - + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Screen", "%d", channel_caller_data->screen); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Presentation", "%d", channel_caller_data->pres); } @@ -3615,7 +3635,7 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t * "--------------------------------------------------------------------------------\n" \ "ftdm list\n" \ "ftdm start|stop \n" \ -"ftdm restart \n" \ +"ftdm restart []\n" \ "ftdm dump []\n" \ "ftdm sigstatus get|set [] [] []\n" \ "ftdm trace []\n" \ @@ -4141,10 +4161,11 @@ SWITCH_STANDARD_API(ft_function) stream->write_function(stream, "+OK queue sizes set to Rx %d and Tx %d\n", rxsize, txsize); } else if (!strcasecmp(argv[0], "restart")) { uint32_t chan_id = 0; + uint32_t ccount = 0; ftdm_channel_t *chan; ftdm_span_t *span = NULL; - if (argc < 3) { - stream->write_function(stream, "-ERR Usage: ftdm restart \n"); + if (argc < 2) { + stream->write_function(stream, "-ERR Usage: ftdm restart []\n"); goto end; } ftdm_span_find_by_name(argv[1], &span); @@ -4152,15 +4173,32 @@ SWITCH_STANDARD_API(ft_function) stream->write_function(stream, "-ERR invalid span\n"); goto end; } - - chan_id = atoi(argv[2]); - chan = ftdm_span_get_channel(span, chan_id); - if (!chan) { - stream->write_function(stream, "-ERR Could not find chan\n"); - goto end; + + if (argc > 2) { + chan_id = atoi(argv[2]); + if (chan_id > ftdm_span_get_chan_count(span)) { + stream->write_function(stream, "-ERR invalid chan\n"); + goto end; + } } - stream->write_function(stream, "Resetting channel %s:%s\n", argv[2], argv[3]); - ftdm_channel_reset(chan); + if (chan_id) { + chan = ftdm_span_get_channel(span, chan_id); + if (!chan) { + stream->write_function(stream, "-ERR Could not find chan\n"); + goto end; + } + stream->write_function(stream, "Resetting channel %s:%s\n", argv[1], argv[2]); + ftdm_channel_reset(chan); + } else { + uint32_t i = 0; + ccount = ftdm_span_get_chan_count(span); + for (i = 1; i < ccount; i++) { + chan = ftdm_span_get_channel(span, i); + stream->write_function(stream, "Resetting channel %s:%d\n", argv[1], i); + ftdm_channel_reset(chan); + } + } + } else { char *rply = ftdm_api_execute(cmd); diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 96fd235ad2..1d7a0d1eb1 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -3563,6 +3563,16 @@ static FIO_WRITE_FUNCTION(ftdm_raw_write) static FIO_READ_FUNCTION(ftdm_raw_read) { ftdm_status_t status = ftdmchan->fio->read(ftdmchan, data, datalen); + + if (status == FTDM_SUCCESS && ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN) + && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) { + int i = 0; + unsigned char *rdata = data; + for (i = 0; i < *datalen; i++) { + rdata[i] = ftdmchan->rxgain_table[rdata[i]]; + } + } + if (status == FTDM_SUCCESS && ftdmchan->fds[FTDM_READ_TRACE_INDEX] > -1) { ftdm_size_t dlen = *datalen; if ((ftdm_size_t)write(ftdmchan->fds[FTDM_READ_TRACE_INDEX], data, (int)dlen) != dlen) { @@ -3730,7 +3740,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data ftdm_status_t status = FTDM_FAIL; fio_codec_t codec_func = NULL; ftdm_size_t max = *datalen; - unsigned i = 0; ftdm_assert_return(ftdmchan != NULL, FTDM_FAIL, "ftdmchan is null\n"); ftdm_assert_return(ftdmchan->fio != NULL, FTDM_FAIL, "No I/O module attached to ftdmchan\n"); @@ -3769,13 +3778,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data goto done; } - if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_USE_RX_GAIN) - && (ftdmchan->native_codec == FTDM_CODEC_ALAW || ftdmchan->native_codec == FTDM_CODEC_ULAW)) { - unsigned char *rdata = data; - for (i = 0; i < *datalen; i++) { - rdata[i] = ftdmchan->rxgain_table[rdata[i]]; - } - } handle_tone_generation(ftdmchan); if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) && ftdmchan->effective_codec != ftdmchan->native_codec) { diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index d119ff4fd2..75379eef64 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -996,11 +996,15 @@ static ftdm_status_t ftdm_sangoma_isdn_start(ftdm_span_t *span) ftdm_clear_flag(span, FTDM_SPAN_STOP_THREAD); ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD); - if (signal_data->raw_trace_q921 == SNGISDN_OPT_TRUE) { + if (signal_data->trace_q921 == SNGISDN_OPT_TRUE || + signal_data->raw_trace_q921 == SNGISDN_OPT_TRUE) { + sngisdn_activate_trace(span, SNGISDN_TRACE_Q921); } - if (signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) { + if (signal_data->trace_q931 == SNGISDN_OPT_TRUE || + signal_data->raw_trace_q931 == SNGISDN_OPT_TRUE) { + sngisdn_activate_trace(span, SNGISDN_TRACE_Q931); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index 43d6ad555e..112e7cf27d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -213,6 +213,8 @@ typedef struct sngisdn_span_data { int8_t facility_timeout; uint8_t num_local_numbers; uint8_t ignore_cause_value; + uint8_t trace_q931; /* TODO: combine with trace_flags */ + uint8_t trace_q921; /* TODO: combine with trace_flags */ uint8_t raw_trace_q931; /* TODO: combine with trace_flags */ uint8_t raw_trace_q921; /* TODO: combine with trace_flags */ uint8_t timer_t3; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index ee0cdbe1ef..49b07fff33 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -369,6 +369,10 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ parse_yesno(var, val, &signal_data->facility_ie_decode); } else if (!strcasecmp(var, "ignore-cause-value")) { parse_yesno(var, val, &signal_data->ignore_cause_value); + } else if (!strcasecmp(var, "q931-trace")) { + parse_yesno(var, val, &signal_data->trace_q931); + } else if (!strcasecmp(var, "q921-trace")) { + parse_yesno(var, val, &signal_data->trace_q921); } else if (!strcasecmp(var, "q931-raw-trace")) { parse_yesno(var, val, &signal_data->raw_trace_q931); } else if (!strcasecmp(var, "q921-raw-trace")) { 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..1dd9717c9f 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 @@ -724,6 +724,9 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream) stream->write_function(stream, "ftdm ss7 lpo link X\n"); stream->write_function(stream, "ftdm ss7 lpr link X\n"); stream->write_function(stream, "\n"); + stream->write_function(stream, "Ftmod_sangoma_ss7 Relay status:\n"); + stream->write_function(stream, "ftdm ss7 show status relay X\n"); + stream->write_function(stream, "\n"); return FTDM_SUCCESS; } @@ -1207,8 +1210,8 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span, stream->write_function(stream, "r_hw=N|"); } - if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) { - stream->write_function(stream, "relay=Y"); + if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) { + stream->write_function(stream, "relay=Y|"); }else { stream->write_function(stream, "relay=N"); } @@ -1366,7 +1369,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 +1395,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 +1411,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 +1439,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 +1455,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 +1490,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 +1507,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 +1522,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 +1539,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 +1894,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 +1910,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 +1925,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 +1941,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 +1956,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 +1972,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 +1987,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 +2003,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 +2018,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 +2049,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 +2081,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 +2097,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 +2112,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 +2128,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 +2147,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 +2171,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_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c index 3981cd6597..40a712f8e2 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c @@ -1565,6 +1565,9 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ /* throw the unblock flag */ sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX); + /* clear the block flag */ + sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX); + /* set the channel to suspended state */ ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); 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..4b5787c0cb 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; } @@ -149,24 +149,19 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) switch (sta->t.usta.alarm.cause) { - /******************************************************************/ - case (LCM_CAUSE_UNKNOWN): - ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event)); - break; - /******************************************************************/ - case (LCM_CAUSE_MGMT_INITIATED): - ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s[MGMT] %s\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event)); - break; - /******************************************************************/ - default: - ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s (***unknown cause***)\n", - buf, - DECODE_LSD_EVENT(sta->t.usta.alarm.event)); - break; + case (LCM_CAUSE_MGMT_INITIATED): + ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s[MGMT] cause:%s event:%s\n", + buf, + DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), + DECODE_LSD_EVENT(sta->t.usta.alarm.event)); + break; + case (LCM_CAUSE_UNKNOWN): + default: + ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s cause:%s event:%s\n", + buf, + DECODE_LCM_CAUSE(sta->t.usta.alarm.cause), + DECODE_LSD_EVENT(sta->t.usta.alarm.event)); + break; /******************************************************************/ } /* switch (sta->t.usta.alarm.cause) */ break; @@ -175,7 +170,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 +193,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; } @@ -211,7 +206,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta) sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name); } - ftdm_log(FTDM_LOG_ERROR,"[MTP2]%s %s : %s\n", + ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s %s : %s\n", buf, DECODE_LSD_EVENT(sta->t.usta.alarm.event), DECODE_DISC_REASON(sta->t.usta.evntParm[1])); @@ -222,7 +217,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 +243,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 +266,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 +361,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; } @@ -402,7 +397,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta) break; /**********************************************************************/ default: - ftdm_log(FTDM_LOG_ERROR,"[MTP3]%s %s(%d) : %s(%d)\n", + ftdm_log(FTDM_LOG_DEBUG,"[MTP3]%s %s(%d) : %s(%d)\n", buf, DECODE_LSN_EVENT(sta->t.usta.alarm.event), sta->t.usta.alarm.event, @@ -421,7 +416,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta) break; /**************************************************************************/ case (STLNKSET): - ftdm_log(FTDM_LOG_ERROR,"[MTP3][LNKSET:%d] %s : %s\n", + ftdm_log(FTDM_LOG_DEBUG,"[MTP3][LNKSET:%d] %s : %s\n", sta->hdr.elmId.elmntInst1, DECODE_LSN_EVENT(sta->t.usta.alarm.event), DECODE_LSN_CAUSE(sta->t.usta.alarm.cause)); 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 8e57473202..4f8c069b71 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 @@ -109,7 +109,15 @@ ftdm_state_map_t sangoma_ss7_state_map = { {FTDM_CHANNEL_STATE_RING, FTDM_END}, {FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART, FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, - FTDM_CHANNEL_STATE_PROGRESS, FTDM_END} + FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END} + }, + { + ZSD_INBOUND, + ZSM_UNACCEPTABLE, + {FTDM_CHANNEL_STATE_RINGING, FTDM_END}, + {FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP, + FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA, + FTDM_CHANNEL_STATE_UP, FTDM_END}, }, { ZSD_INBOUND, @@ -609,6 +617,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) break; /**************************************************************************/ + /* We handle RING indication the same way we would indicate PROGRESS */ + case FTDM_CHANNEL_STATE_RINGING: case FTDM_CHANNEL_STATE_PROGRESS: if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) { @@ -626,7 +636,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA); } else { /* inbound call so we need to send out ACM */ - ft_to_sngss7_acm(ftdmchan); + if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) { + sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM); + ft_to_sngss7_acm(ftdmchan); + } } break; @@ -877,6 +890,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan) /* clear any call related flags */ sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL); sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL); + sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM); if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) { @@ -1049,18 +1063,20 @@ 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 */ + sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN); + } } /* 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 */ @@ -1076,8 +1092,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 */ @@ -1100,6 +1115,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 */ @@ -1115,8 +1131,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 */ @@ -1139,6 +1155,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 */ @@ -1151,8 +1168,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 */ @@ -1172,6 +1189,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 */ @@ -1192,8 +1210,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 */ @@ -1210,7 +1227,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; @@ -1370,6 +1387,9 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span) ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD); ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD); + /* check the status of all isup interfaces */ + check_status_of_all_isup_intf(); + /* throw the channels in pause */ for (x = 1; x < (span->chan_count + 1); x++) { /* extract the channel structure and sngss7 channel data */ @@ -1632,7 +1652,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)) { @@ -1648,7 +1668,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_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h index df8b086c49..ea31a89c5b 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 @@ -316,8 +316,11 @@ typedef struct sng_isup_ckt { uint32_t typeCntrl; uint32_t ssf; uint32_t switchType; + uint32_t clg_nadi; uint32_t cld_nadi; + uint8_t rdnis_nadi; + uint32_t min_digits; void *obj; uint16_t t3; @@ -503,6 +506,7 @@ typedef enum { FLAG_GLARE = (1 << 13), FLAG_INFID_RESUME = (1 << 14), FLAG_INFID_PAUSED = (1 << 15), + FLAG_SENT_ACM = (1 << 16), FLAG_RELAY_DOWN = (1 << 30), FLAG_CKT_RECONFIG = (1 << 31) } sng_ckt_flag_t; @@ -524,6 +528,7 @@ typedef enum { "GLARE", \ "INF_RESUME", \ "INF_PAUSED", \ + "TX_ACM_SENT" \ "RELAY_DOWN", \ "CKT_RECONFIG" FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t) @@ -784,8 +789,12 @@ uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum); uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum); uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum); -uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); -uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); +ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum); + + +ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); +ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); +ftdm_status_t copy_tknStr_to_sngss7(char* str, TknStr *tknStr, TknU8 *oddEven); int check_for_state_change(ftdm_channel_t *ftdmchan); int check_cics_in_range(sngss7_chan_data_t *sngss7_info); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 96446b4215..9fe279d7c5 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -182,8 +182,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* copy down the called number information */ copy_cdPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cdPtyNum); - /* copy down the calling number information */ - + /* copy down the calling number information */ copy_cgPtyNum_to_sngss7 (&ftdmchan->caller_data, &iam.cgPtyNum); /* check if the user would like a custom NADI value for the calling Pty Num */ @@ -195,7 +194,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) iam.cgPtyNum.natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].clg_nadi; SS7_DEBUG_CHAN(ftdmchan,"No user supplied NADI value found for CLG, using \"%d\"\n", iam.cgPtyNum.natAddrInd.val); } - + cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi"); if ((cld_nadi != NULL) && (*cld_nadi)) { SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Called NADI value \"%s\"\n", cld_nadi); @@ -244,6 +243,8 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) } /* if (subAddrIE[0] != '0') */ } + copy_redirgNum_to_sngss7(ftdmchan, &iam.redirgNum); + /* check if the user would like us to send a cld_sub-address */ cld_subAddr = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_subaddr"); if ((cld_subAddr != NULL) && (*cld_subAddr)) { 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..22b522409f 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 @@ -43,13 +43,6 @@ uint32_t sngss7_id; /******************************************************************************/ /* PROTOTYPES *****************************************************************/ -uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); -uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven); -uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum); -uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum); -uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum); -uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum); - int check_for_state_change(ftdm_channel_t *ftdmchan); int check_cics_in_range(sngss7_chan_data_t *sngss7_info); int check_for_reset(sngss7_chan_data_t *sngss7_info); @@ -134,11 +127,12 @@ uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum) cgPtyNum->niInd.val = 0x00; /**************************************************************************/ cgPtyNum->addrSig.pres = PRSNT_NODEF; - + /* atoi will search through memory starting from the pointer it is given until * it finds the \0...since tmp is on the stack it will start going through the * possibly causing corruption. Hard code a \0 to prevent this */ + tmp[1] = '\0'; k = 0; j = 0; @@ -334,8 +328,68 @@ uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum) return 0; } -/******************************************************************************/ -uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) + +ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum) +{ + const char* val = NULL; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; + uint8_t len = strlen(caller_data->rdnis.digits); + if (!len) { + return FTDM_SUCCESS; + } + SS7_DEBUG_CHAN(ftdmchan, "Redirecting Number %s\n", caller_data->rdnis.digits); + + redirgNum->eh.pres = PRSNT_NODEF; + + /* Nature of address indicator */ + redirgNum->natAddr.pres = PRSNT_NODEF; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_nadi"); + if (!ftdm_strlen_zero(val)) { + redirgNum->natAddr.val = atoi(val); + } else { + redirgNum->natAddr.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].rdnis_nadi; + } + SS7_DEBUG_CHAN(ftdmchan, "Redirecting Number NADI:%d\n", redirgNum->natAddr.val); + + /* Screening indicator */ + redirgNum->scrInd.pres = PRSNT_NODEF; + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_screen_ind"); + if (!ftdm_strlen_zero(val)) { + redirgNum->scrInd.val = atoi(val); + } else { + redirgNum->scrInd.val = FTDM_SCREENING_VERIFIED_PASSED; + } + SS7_DEBUG_CHAN(ftdmchan, "Redirecting Number Screening Ind:%d\n", redirgNum->scrInd.val); + + /* Address presentation restricted ind */ + redirgNum->presRest.pres = PRSNT_NODEF; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_pres_ind"); + if (!ftdm_strlen_zero(val)) { + redirgNum->presRest.val = atoi(val); + } else { + redirgNum->presRest.val = FTDM_PRES_ALLOWED; + } + SS7_DEBUG_CHAN(ftdmchan, "Redirecting Number Address Presentation Restricted Ind:%d\n", redirgNum->presRest.val); + + /* Numbering plan */ + redirgNum->numPlan.pres = PRSNT_NODEF; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rdnis_plan"); + if (!ftdm_strlen_zero(val)) { + redirgNum->numPlan.val = atoi(val); + } else { + redirgNum->numPlan.val = caller_data->rdnis.plan; + } + + SS7_DEBUG_CHAN(ftdmchan, "Redirecting Number Numbering plan:%d\n", redirgNum->numPlan.val); + + return copy_tknStr_to_sngss7(caller_data->rdnis.digits, &redirgNum->addrSig, &redirgNum->oddEven); +} + +ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) { uint8_t i; uint8_t j; @@ -362,14 +416,14 @@ uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) } else { SS7_ERROR("Asked to copy tknStr that is not present!\n"); - return 1; + return FTDM_FAIL; } - return 0; + return FTDM_SUCCESS; } /******************************************************************************/ -uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) +ftdm_status_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) { int i = 0; int j = 0; @@ -382,7 +436,7 @@ uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) /* confirm that we found an acceptable length */ if ( j > 25 ) { SS7_ERROR("string length exceeds maxium value...aborting append!\n"); - return 1; + return FTDM_FAIL; } /* if ( j > 25 ) */ /* copy in digits */ @@ -405,12 +459,100 @@ uint8_t append_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven) } /* if ((oddEven.pres == 1) && (oddEven.val == 1)) */ } else { SS7_ERROR("Asked to copy tknStr that is not present!\n"); - return 1; + return FTDM_FAIL; } /* if (str.pres == 1) */ - return 0; + return FTDM_SUCCESS; } + +ftdm_status_t copy_tknStr_to_sngss7(char* val, TknStr *tknStr, TknU8 *oddEven) +{ + char tmp[2]; + int k = 0; + int j = 0; + uint8_t flag = 0; + uint8_t odd = 0; + + uint8_t lower = 0x0; + uint8_t upper = 0x0; + + tknStr->pres = PRSNT_NODEF; + + /* atoi will search through memory starting from the pointer it is given until + * it finds the \0...since tmp is on the stack it will start going through the + * possibly causing corruption. Hard code a \0 to prevent this + */ + tmp[1] = '\0'; + + while (1) { + /* grab a digit from the ftdm digits */ + tmp[0] = val[k]; + + /* check if the digit is a number and that is not null */ + while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) { + SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); + /* move on to the next value */ + k++; + tmp[0] = val[k]; + } /* while(!(isdigit(tmp))) */ + + /* check if tmp is null or a digit */ + if (tmp[0] != '\0') { + /* push it into the lower nibble */ + lower = strtol(&tmp[0], (char **)NULL, 16); + /* move to the next digit */ + k++; + /* grab a digit from the ftdm digits */ + tmp[0] = val[k]; + + /* check if the digit is a number and that is not null */ + while (!(isxdigit(tmp[0])) && (tmp[0] != '\0')) { + SS7_INFO("Dropping invalid digit: %c\n", tmp[0]); + k++; + tmp[0] = val[k]; + } /* while(!(isdigit(tmp))) */ + + /* check if tmp is null or a digit */ + if (tmp[0] != '\0') { + /* push the digit into the upper nibble */ + upper = (strtol(&tmp[0], (char **)NULL, 16)) << 4; + } else { + /* there is no upper ... fill in 0 */ + upper = 0x0; + /* throw the odd flag */ + odd = 1; + /* throw the end flag */ + flag = 1; + } /* if (tmp != '\0') */ + } else { + /* keep the odd flag down */ + odd = 0; + /* break right away since we don't need to write the digits */ + break; + } + + /* push the digits into the trillium structure */ + tknStr->val[j] = upper | lower; + + /* increment the trillium pointer */ + j++; + + /* if the flag is up we're through all the digits */ + if (flag) break; + + /* move to the next digit */ + k++; + } /* while(1) */ + + tknStr->len = j; + oddEven->pres = PRSNT_NODEF; + oddEven->val = odd; + return FTDM_SUCCESS; +} + + + /******************************************************************************/ int check_for_state_change(ftdm_channel_t *ftdmchan) { @@ -1319,7 +1461,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 +1518,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..815377b476 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 @@ -122,6 +122,7 @@ typedef struct sng_ccSpan uint32_t ssf; uint32_t clg_nadi; uint32_t cld_nadi; + uint32_t rdnis_nadi; uint32_t min_digits; uint32_t t3; uint32_t t12; @@ -1215,7 +1216,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 +1758,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 */ @@ -1841,6 +1842,7 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) int num_parms = cc_span->n_parameters; int flag_clg_nadi = 0; int flag_cld_nadi = 0; + int flag_rdnis_nadi = 0; int i; int ret; @@ -1891,28 +1893,6 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) SS7_DEBUG("Found an ccSpan typeCntrl = %s\n", sng_cic_cntrl_type_map[ret].sng_type); } /**********************************************************************/ - } else if (!strcasecmp(parm->var, "ssf")) { - /**********************************************************************/ - ret = find_ssf_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid ccSpan ssf = %s\n", parm->var); - return FTDM_FAIL; - } else { - sng_ccSpan.ssf = sng_ssf_type_map[ret].tril_type; - SS7_DEBUG("Found an ccSpan ssf = %s\n", sng_ssf_type_map[ret].sng_type); - } - /**********************************************************************/ - } else if (!strcasecmp(parm->var, "switchType")) { - /**********************************************************************/ - ret = find_switch_type_in_map(parm->val); - if (ret == -1) { - SS7_ERROR("Found an invalid ccSpan switchType = %s\n", parm->var); - return FTDM_FAIL; - } else { - sng_ccSpan.switchType = sng_switch_type_map[ret].tril_isup_type; - SS7_DEBUG("Found an ccSpan switchType = %s\n", sng_switch_type_map[ret].sng_type); - } - /**********************************************************************/ } else if (!strcasecmp(parm->var, "cicbase")) { /**********************************************************************/ sng_ccSpan.cicbase = atoi(parm->val); @@ -1934,16 +1914,17 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) flag_clg_nadi = 1; sng_ccSpan.clg_nadi = atoi(parm->val); SS7_DEBUG("Found default CLG_NADI parm->value = %d\n", sng_ccSpan.clg_nadi); - /**********************************************************************/ } else if (!strcasecmp(parm->var, "cld_nadi")) { - /**********************************************************************/ /* throw the flag so that we know we got this optional parameter */ flag_cld_nadi = 1; sng_ccSpan.cld_nadi = atoi(parm->val); SS7_DEBUG("Found default CLD_NADI parm->value = %d\n", sng_ccSpan.cld_nadi); - /**********************************************************************/ + } else if (!strcasecmp(parm->var, "rdnis_nadi")) { + /* throw the flag so that we know we got this optional parameter */ + flag_rdnis_nadi = 1; + sng_ccSpan.rdnis_nadi = atoi(parm->val); + SS7_DEBUG("Found default RDNIS_NADI parm->value = %d\n", sng_ccSpan.rdnis_nadi); } else if (!strcasecmp(parm->var, "obci_bita")) { - /**********************************************************************/ if (*parm->val == '1') { sngss7_set_options(&sng_ccSpan, SNGSS7_ACM_OBCI_BITA); SS7_DEBUG("Found Optional Backwards Indicator: Bit A (early media) enable option\n"); @@ -2034,6 +2015,15 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span) sng_ccSpan.clg_nadi = 0x03; } + if (!flag_rdnis_nadi) { + /* default the nadi value to national */ + sng_ccSpan.rdnis_nadi = 0x03; + } + + /* pull up the SSF and Switchtype from the isup interface */ + sng_ccSpan.ssf = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].ssf; + sng_ccSpan.switchType = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].switchType; + /* add this span to our global listing */ ftmod_ss7_fill_in_ccSpan(&sng_ccSpan); @@ -2461,7 +2451,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 +2461,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 { @@ -2909,6 +2909,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan) g_ftdm_sngss7_data.cfg.isupCkt[x].ssf = ccSpan->ssf; g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi = ccSpan->cld_nadi; g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi = ccSpan->clg_nadi; + g_ftdm_sngss7_data.cfg.isupCkt[x].rdnis_nadi = ccSpan->rdnis_nadi; g_ftdm_sngss7_data.cfg.isupCkt[x].options = ccSpan->options; g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType; g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits; diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index f1164cee2e..2d3f994878 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -417,6 +417,8 @@ SWITCH_DECLARE(switch_xml_section_t) switch_xml_parse_section_string(_In_opt_z_ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond); +SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language); + SWITCH_END_EXTERN_C ///\} #endif // _SWITCH_XML_H diff --git a/src/mod/applications/mod_protovm/protovm.conf.xml b/src/mod/applications/mod_protovm/protovm.conf.xml index 3c42ce1faa..e25b8760c8 100644 --- a/src/mod/applications/mod_protovm/protovm.conf.xml +++ b/src/mod/applications/mod_protovm/protovm.conf.xml @@ -17,7 +17,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -43,12 +43,12 @@ - - - - - - + + + + + + @@ -62,7 +62,7 @@ - + @@ -75,9 +75,9 @@ - - - + + + @@ -90,9 +90,9 @@ - - - + + + @@ -106,9 +106,9 @@ - - - + + + @@ -116,7 +116,7 @@ - + @@ -124,7 +124,7 @@ - + diff --git a/src/mod/applications/mod_protovm/sounds.xml b/src/mod/applications/mod_protovm/sounds.xml index 2fe42a40d2..1760e7cc07 100644 --- a/src/mod/applications/mod_protovm/sounds.xml +++ b/src/mod/applications/mod_protovm/sounds.xml @@ -1,375 +1,376 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index 33c18dab84..c0402e142d 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -12688,6 +12688,18 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_clean_string(char * jarg1) { } +SWIGEXPORT char * SWIGSTDCALL CSharp_switch_clean_name_string(char * jarg1) { + char * jresult ; + char *arg1 = (char *) 0 ; + char *result = 0 ; + + arg1 = (char *)jarg1; + result = (char *)switch_clean_name_string(arg1); + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_switch_safe_strdup(char * jarg1) { char * jresult ; char *arg1 = (char *) 0 ; @@ -25903,7 +25915,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_json(void * jarg1, char * } -SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_brackets(char * jarg1, char jarg2, char jarg3, char jarg4, void * jarg5, void * jarg6) { +SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_brackets(char * jarg1, char jarg2, char jarg3, char jarg4, void * jarg5, void * jarg6, int jarg7) { int jresult ; char *arg1 = (char *) 0 ; char arg2 ; @@ -25911,6 +25923,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_brackets(char * jarg1, cha char arg4 ; switch_event_t **arg5 = (switch_event_t **) 0 ; char **arg6 = (char **) 0 ; + switch_bool_t arg7 ; switch_status_t result; arg1 = (char *)jarg1; @@ -25919,7 +25932,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_create_brackets(char * jarg1, cha arg4 = (char)jarg4; arg5 = (switch_event_t **)jarg5; arg6 = (char **)jarg6; - result = (switch_status_t)switch_event_create_brackets(arg1,arg2,arg3,arg4,arg5,arg6); + arg7 = (switch_bool_t)jarg7; + result = (switch_status_t)switch_event_create_brackets(arg1,arg2,arg3,arg4,arg5,arg6,arg7); jresult = result; return jresult; } diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index 400acef378..497630fd26 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -2945,6 +2945,11 @@ public class freeswitch { return ret; } + public static string switch_clean_name_string(string s) { + string ret = freeswitchPINVOKE.switch_clean_name_string(s); + return ret; + } + public static string switch_safe_strdup(string it) { string ret = freeswitchPINVOKE.switch_safe_strdup(it); return ret; @@ -3970,8 +3975,8 @@ public class freeswitch { return ret; } - public static switch_status_t switch_event_create_brackets(string data, char a, char b, char c, SWIGTYPE_p_p_switch_event arg4, ref string new_data) { - switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_create_brackets(data, a, b, c, SWIGTYPE_p_p_switch_event.getCPtr(arg4), ref new_data); + public static switch_status_t switch_event_create_brackets(string data, char a, char b, char c, SWIGTYPE_p_p_switch_event arg4, ref string new_data, switch_bool_t dup) { + switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_create_brackets(data, a, b, c, SWIGTYPE_p_p_switch_event.getCPtr(arg4), ref new_data, (int)dup); return ret; } @@ -8827,6 +8832,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_clean_string")] public static extern string switch_clean_string(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_clean_name_string")] + public static extern string switch_clean_name_string(string jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_safe_strdup")] public static extern string switch_safe_strdup(string jarg1); @@ -12017,7 +12025,7 @@ class freeswitchPINVOKE { public static extern int switch_event_create_json(HandleRef jarg1, string jarg2); [DllImport("mod_managed", EntryPoint="CSharp_switch_event_create_brackets")] - public static extern int switch_event_create_brackets(string jarg1, char jarg2, char jarg3, char jarg4, HandleRef jarg5, ref string jarg6); + public static extern int switch_event_create_brackets(string jarg1, char jarg2, char jarg3, char jarg4, HandleRef jarg5, ref string jarg6, int jarg7); [DllImport("mod_managed", EntryPoint="CSharp_switch_event_running")] public static extern int switch_event_running(); diff --git a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c index e58377ef5a..1ac0d38889 100644 --- a/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c +++ b/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c @@ -50,7 +50,8 @@ typedef enum { XML_LDAP_CONFIG = 0, XML_LDAP_DIRECTORY, XML_LDAP_DIALPLAN, - XML_LDAP_PHRASE + XML_LDAP_PHRASE, + XML_LDAP_LANGUAGE } xml_ldap_query_type_t; SWITCH_MODULE_LOAD_FUNCTION(mod_xml_ldap_load); @@ -247,6 +248,8 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c query_type = XML_LDAP_DIALPLAN; } else if (!strcmp(section, "phrases")) { query_type = XML_LDAP_PHRASE; + } else if (!strcmp(section, "languages")) { + query_type = XML_LDAP_LANGUAGE; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid section\n"); return NULL; @@ -269,6 +272,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c case XML_LDAP_DIALPLAN: case XML_LDAP_PHRASE: + case XML_LDAP_LANGUAGE: break; } } @@ -326,6 +330,7 @@ static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, c break; case XML_LDAP_PHRASE: + case XML_LDAP_LANGUAGE: break; } } else { diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 07c341a580..825f2d30cd 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -29,6 +29,7 @@ * Matt Klein * Michael Jerris * Ken Rice + * Marc Olivier Chouinard * * switch_ivr.c -- IVR Library * @@ -2327,9 +2328,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, switch_say_interface_t *si; switch_channel_t *channel; switch_status_t status = SWITCH_STATUS_FALSE; - const char *save_path = NULL, *chan_lang = NULL, *lang = NULL, *lname = NULL, *sound_path = NULL; + const char *save_path = NULL, *chan_lang = NULL, *lang = NULL, *sound_path = NULL; switch_event_t *hint_data; - switch_xml_t cfg, xml = NULL, language, macros; + switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL; char *p; switch_assert(session); @@ -2341,6 +2342,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, } if (module_name) { + char *p; p = switch_core_session_strdup(session, module_name); module_name = p; @@ -2371,58 +2373,35 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, switch_event_add_header_string(hint_data, SWITCH_STACK_BOTTOM, "lang", chan_lang); switch_channel_event_set_data(channel, hint_data); - if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of phrases failed.\n"); + if (switch_xml_locate_language(&xml, &cfg, hint_data, &language, &phrases, ¯os, chan_lang) != SWITCH_STATUS_SUCCESS) { goto done; } - if (!(macros = switch_xml_child(cfg, "macros"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros tag.\n"); - goto done; - } - - if (!(language = switch_xml_child(macros, "language"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language tag.\n"); - goto done; - } - - while (language) { - if ((lname = (char *) switch_xml_attr(language, "name")) && !strcasecmp(lname, chan_lang)) { - const char *tmp; - - if ((tmp = switch_xml_attr(language, "module"))) { - module_name = tmp; - } - break; - } - language = language->next; - } - - if (!language) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language %s.\n", chan_lang); - goto done; - } - - if (!module_name) { + if ((p = (char *) switch_xml_attr(language, "say-module"))) { + module_name = switch_core_session_strdup(session, p); + } else if ((p = (char *) switch_xml_attr(language, "module"))) { + module_name = switch_core_session_strdup(session, p); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Deprecated usage of module attribute\n"); + } else { module_name = chan_lang; } - if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { - sound_path = (char *) switch_xml_attr(language, "sound_path"); + if (!(sound_path = (char *) switch_xml_attr(language, "sound-prefix"))) { + if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { + sound_path = (char *) switch_xml_attr(language, "sound_path"); + } } - save_path = switch_channel_get_variable(channel, "sound_prefix"); - - if (sound_path) { - switch_channel_set_variable(channel, "sound_prefix", sound_path); - p = switch_core_session_strdup(session, sound_path); - sound_path = p; + if (channel) { + const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced"); + if (!switch_true(p)) { + save_path = switch_channel_get_variable(channel, "sound_prefix"); + if (sound_path) { + switch_channel_set_variable(channel, "sound_prefix", sound_path); + } + } } - if (xml) { - switch_xml_free(xml); - } - if ((si = switch_loadable_module_get_say_interface(module_name))) { /* should go back and proto all the say mods to const.... */ switch_say_args_t say_args = {0}; @@ -2446,7 +2425,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, if (save_path) { switch_channel_set_variable(channel, "sound_prefix", save_path); } - + + if (xml) { + switch_xml_free(xml); + } + return status; } @@ -2463,9 +2446,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_string(switch_core_session_t *ses switch_say_interface_t *si; switch_channel_t *channel = NULL; switch_status_t status = SWITCH_STATUS_FALSE; - const char *save_path = NULL, *chan_lang = NULL, *lname = NULL, *sound_path = NULL; + const char *save_path = NULL, *chan_lang = NULL, *sound_path = NULL; switch_event_t *hint_data; - switch_xml_t cfg, xml = NULL, language, macros; + switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL; if (session) { channel = switch_core_session_get_channel(session); @@ -2498,52 +2481,31 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_string(switch_core_session_t *ses switch_channel_event_set_data(channel, hint_data); } - if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of phrases failed.\n"); + if (switch_xml_locate_language(&xml, &cfg, hint_data, &language, &phrases, ¯os, chan_lang) != SWITCH_STATUS_SUCCESS) { goto done; } - if (!(macros = switch_xml_child(cfg, "macros"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros tag.\n"); - goto done; - } - - if (!(language = switch_xml_child(macros, "language"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language tag.\n"); - goto done; - } - - while (language) { - if ((lname = (char *) switch_xml_attr(language, "name")) && !strcasecmp(lname, chan_lang)) { - const char *tmp; - - if ((tmp = switch_xml_attr(language, "module"))) { - module_name = tmp; - } - break; - } - language = language->next; - } - - if (!language) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language %s.\n", chan_lang); - goto done; - } - - if (!module_name) { + if ((module_name = switch_xml_attr(language, "say-module"))) { + } else if ((module_name = switch_xml_attr(language, "module"))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Deprecated usage of module attribute\n"); + } else { module_name = chan_lang; } - if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { - sound_path = (char *) switch_xml_attr(language, "sound_path"); + if (!(sound_path = (char *) switch_xml_attr(language, "sound-prefix"))) { + if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { + sound_path = (char *) switch_xml_attr(language, "sound_path"); + } } if (channel) { - save_path = switch_channel_get_variable(channel, "sound_prefix"); - } - - if (sound_path && channel) { - switch_channel_set_variable(channel, "sound_prefix", sound_path); + const char *p = switch_channel_get_variable(channel, "sound_prefix_enforced"); + if (!switch_true(p)) { + save_path = switch_channel_get_variable(channel, "sound_prefix"); + if (sound_path) { + switch_channel_set_variable(channel, "sound_prefix", sound_path); + } + } } if ((si = switch_loadable_module_get_say_interface(module_name))) { diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 6c769ecfd8..76cea5a666 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -28,6 +28,7 @@ * Neal Horman * Matt Klein * Michael Jerris + * Marc Olivier Chouinard * * switch_ivr_play_say.c -- IVR Library (functions to play or say audio) * @@ -39,8 +40,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio switch_input_args_t *args) { switch_event_t *hint_data; - switch_xml_t cfg, xml = NULL, language, macros, macro, input, action; - char *lname = NULL, *mname = NULL; + switch_xml_t cfg, xml = NULL, language = NULL, macros = NULL, phrases = NULL, macro, input, action; switch_status_t status = SWITCH_STATUS_GENERR; const char *old_sound_prefix = NULL, *sound_path = NULL, *tts_engine = NULL, *tts_voice = NULL; const char *module_name = NULL, *chan_lang = NULL; @@ -49,6 +49,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio int matches = 0; const char *pause_val; int pause = 100; + const char *group_macro_name = NULL; + const char *local_macro_name = macro_name; + switch_bool_t sound_prefix_enforced = switch_true(switch_channel_get_variable(channel, "sound_prefix_enforced")); + switch_bool_t local_sound_prefix_enforced = SWITCH_FALSE; if (!macro_name) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No phrase macro specified.\n"); @@ -65,8 +69,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio chan_lang = lang; } - module_name = chan_lang; - switch_event_create(&hint_data, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(hint_data); @@ -82,40 +84,21 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio } switch_channel_event_set_data(channel, hint_data); - if (switch_xml_locate("phrases", NULL, NULL, NULL, &xml, &cfg, hint_data, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Open of phrases failed.\n"); + if (switch_xml_locate_language(&xml, &cfg, hint_data, &language, &phrases, ¯os, chan_lang) != SWITCH_STATUS_SUCCESS) { goto done; } - if (!(macros = switch_xml_child(cfg, "macros"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros tag.\n"); - goto done; + if ((module_name = switch_xml_attr(language, "say-module"))) { + } else if ((module_name = switch_xml_attr(language, "module"))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Deprecated usage of module attribute. Use say-module instead\n"); + } else { + module_name = chan_lang; } - if (!(language = switch_xml_child(macros, "language"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language tag.\n"); - goto done; - } - - while (language) { - if ((lname = (char *) switch_xml_attr(language, "name")) && !strcasecmp(lname, chan_lang)) { - const char *tmp; - - if ((tmp = switch_xml_attr(language, "module"))) { - module_name = tmp; - } - break; + if (!(sound_path = (char *) switch_xml_attr(language, "sound-prefix"))) { + if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { + sound_path = (char *) switch_xml_attr(language, "sound_path"); } - language = language->next; - } - - if (!language) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find language %s.\n", chan_lang); - goto done; - } - - if (!(sound_path = (char *) switch_xml_attr(language, "sound-path"))) { - sound_path = (char *) switch_xml_attr(language, "sound_path"); } if (!(tts_engine = (char *) switch_xml_attr(language, "tts-engine"))) { @@ -126,7 +109,41 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio tts_voice = (char *) switch_xml_attr(language, "tts_voice"); } - if (sound_path) { + /* If we use the new structure, check for a group name */ + if (language != macros) { + char *p; + char *macro_name_dup = switch_core_session_strdup(session, macro_name); + const char *group_sound_path; + const char *sound_prefix_enforced_str; + + if ((p = strchr(macro_name_dup, '@'))) { + *p++ = '\0'; + local_macro_name = macro_name_dup; + group_macro_name = p; + + if (!(macros = switch_xml_find_child(phrases, "macros", "name", group_macro_name))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macros group %s.\n", group_macro_name); + goto done; + } + } + /* Support override of certain language attribute */ + if ((group_sound_path = (char *) switch_xml_attr(macros, "sound-prefix")) || (group_sound_path = (char *) switch_xml_attr(macros, "sound-path")) || (group_sound_path = (char *) switch_xml_attr(macros, "sound_path"))) { + sound_path = group_sound_path; + } + + if (sound_prefix_enforced == SWITCH_FALSE && (sound_prefix_enforced_str = switch_xml_attr(macros, "sound-prefix-enforced")) + && (local_sound_prefix_enforced = switch_true(sound_prefix_enforced_str)) == SWITCH_TRUE) { + switch_channel_set_variable(channel, "sound_prefix_enforced", sound_prefix_enforced_str); + } + + } + + if (!(macro = switch_xml_find_child(macros, "macro", "name", local_macro_name))) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macro %s.\n", macro_name); + goto done; + } + + if (sound_path && sound_prefix_enforced == SWITCH_FALSE) { char *p; old_sound_prefix = switch_str_nil(switch_channel_get_variable(channel, "sound_prefix")); p = switch_core_session_strdup(session, old_sound_prefix); @@ -134,23 +151,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio switch_channel_set_variable(channel, "sound_prefix", sound_path); } - if (!(macro = switch_xml_child(language, "macro"))) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find any macro tags.\n"); - goto done; - } - - while (macro) { - if ((mname = (char *) switch_xml_attr(macro, "name")) && !strcasecmp(mname, macro_name)) { - break; - } - macro = macro->next; - } - - if (!macro) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find macro %s.\n", macro_name); - goto done; - } - if ((pause_val = switch_xml_attr(macro, "pause"))) { int tmp = atoi(pause_val); if (tmp >= 0) { @@ -342,6 +342,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio if (old_sound_prefix) { switch_channel_set_variable(channel, "sound_prefix", old_sound_prefix); } + if (local_sound_prefix_enforced == SWITCH_TRUE) { + switch_channel_set_variable(channel, "sound_prefix_enforced", NULL); + } + if (xml) { switch_xml_free(xml); } diff --git a/src/switch_xml.c b/src/switch_xml.c index 00f6ddd48e..0ad8768cad 100644 --- a/src/switch_xml.c +++ b/src/switch_xml.c @@ -25,7 +25,7 @@ * * Anthony Minessale II * Simon Capper - * + * Marc Olivier Chouinard * * switch_xml.c -- XML PARSER * @@ -2785,6 +2785,62 @@ SWITCH_DECLARE(int) switch_xml_std_datetime_check(switch_xml_t xcond) { return time_match; } +SWITCH_DECLARE(switch_status_t) switch_xml_locate_language(switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_xml_t *language, switch_xml_t *phrases, switch_xml_t *macros, const char *str_language) { + switch_status_t status = SWITCH_STATUS_FALSE; + + if (switch_xml_locate("languages", NULL, NULL, NULL, root, node, params, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { + switch_xml_t sub_macros; + + if (switch_xml_locate("phrases", NULL, NULL, NULL, root, node, params, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of languages and phrases failed.\n"); + goto done; + } + if (!(sub_macros = switch_xml_child(*node, "macros"))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find macros tag.\n"); + switch_xml_free(*root); + *root = NULL; + *node = NULL; + goto done; + } + if (!(*language = switch_xml_find_child(sub_macros, "language", "name", str_language))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find language %s.\n", str_language); + switch_xml_free(*root); + *root = NULL; + *node = NULL; + goto done; + } + *macros = *language; + } else { + if (!(*language = switch_xml_find_child(*node, "language", "name", str_language))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find language %s.\n", str_language); + switch_xml_free(*root); + *root = NULL; + goto done; + } + if (!(*phrases = switch_xml_child(*language, "phrases"))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find phrases tag.\n"); + switch_xml_free(*root); + *root = NULL; + *node = NULL; + *language = NULL; + goto done; + } + + if (!(*macros = switch_xml_child(*phrases, "macros"))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find macros tag.\n"); + switch_xml_free(*root); + *root = NULL; + *node = NULL; + *language = NULL; + *phrases = NULL; + goto done; + } + } + status = SWITCH_STATUS_SUCCESS; + +done: + return status; +} #ifdef WIN32 /*