From 95072fee6659cccdf0afa61c678f01c11ae3b969 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 5 Apr 2011 17:12:33 -0400 Subject: [PATCH 1/5] freetdm: SS7 decreased some unsollicited status messages from Trillium to debug level --- .../ftmod_sangoma_ss7_logger.c | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) 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 2e6fc7e8a0..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 @@ -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; @@ -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])); @@ -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)); From 358e9aab2211769d6e6dd190c47b13a0d909ad02 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 6 Apr 2011 17:25:29 -0400 Subject: [PATCH 2/5] chlog:FreeTDM - SS7 Support for transmitting Redirecting Number --- libs/freetdm/mod_freetdm/mod_freetdm.c | 22 ++- .../ftmod_sangoma_ss7_main.h | 11 +- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 14 +- .../ftmod_sangoma_ss7_support.c | 174 ++++++++++++++++-- .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c | 17 +- 5 files changed, 204 insertions(+), 34 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index b8bd67fc1b..8739c4c0bf 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1264,6 +1264,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi caller_data.ani.plan = (uint8_t)atoi(sipvar); } + /* Used by ftmod_sangoma_ss7 only */ + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI-NADI"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_clg_nadi", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-ANI2"); if (sipvar) { ftdm_set_string(caller_data.aniII, sipvar); @@ -1284,6 +1290,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi caller_data.dnis.plan = (uint8_t)atoi(sipvar); } + /* Used by ftmod_sangoma_ss7 only */ + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-NADI"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_clg_nadi", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS"); if (sipvar) { ftdm_set_string(caller_data.rdnis.digits, sipvar); @@ -1299,6 +1311,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi caller_data.rdnis.plan = (uint8_t)atoi(sipvar); } + /* Used by ftmod_sangoma_ss7 only */ + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-RDNIS-NADI"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_rdnis_nadi", sipvar); + } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Screen"); if (sipvar) { caller_data.screen = (uint8_t)atoi(sipvar); @@ -1308,6 +1326,8 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (sipvar) { caller_data.pres = (uint8_t)atoi(sipvar); } + + } if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { @@ -1568,7 +1588,7 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS", "%s", channel_caller_data->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); } 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 e7372ecd28..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; @@ -786,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..0e73c05c07 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,19 +182,9 @@ 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 */ - clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi"); - if ((clg_nadi != NULL) && (*clg_nadi)) { - SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi); - iam.cgPtyNum.natAddrInd.val = atoi(clg_nadi); - } else { - 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)) { @@ -244,6 +234,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 4513deebea..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) { 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 bf347f0019..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; @@ -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; @@ -1912,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"); @@ -2012,6 +2015,11 @@ 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; @@ -2901,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; From 8e54baf4bdecc865a590ade5485001181cfa3866 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 6 Apr 2011 17:58:30 -0400 Subject: [PATCH 3/5] freetdm:fixed errors introduced when Redirection Number was implemented --- .../ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 0e73c05c07..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 @@ -185,7 +185,16 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* 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 */ + clg_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_clg_nadi"); + if ((clg_nadi != NULL) && (*clg_nadi)) { + SS7_DEBUG_CHAN(ftdmchan,"Found user supplied Calling NADI value \"%s\"\n", clg_nadi); + iam.cgPtyNum.natAddrInd.val = atoi(clg_nadi); + } else { + 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); From b33015327ee7dc1fa536f45750e5331e46ce7173 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 6 Apr 2011 18:42:01 -0400 Subject: [PATCH 4/5] freetdm: apply gain before dumping to file --- libs/freetdm/src/ftdm_io.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 96fd235ad2..1ecd816658 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -3565,6 +3565,14 @@ static FIO_READ_FUNCTION(ftdm_raw_read) ftdm_status_t status = ftdmchan->fio->read(ftdmchan, data, datalen); if (status == FTDM_SUCCESS && ftdmchan->fds[FTDM_READ_TRACE_INDEX] > -1) { ftdm_size_t dlen = *datalen; + if (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 ((ftdm_size_t)write(ftdmchan->fds[FTDM_READ_TRACE_INDEX], data, (int)dlen) != dlen) { ftdm_log(FTDM_LOG_WARNING, "Raw input trace failed to write all of the %"FTDM_SIZE_FMT" bytes\n", dlen); } @@ -3730,7 +3738,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 +3776,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) { From 8270ccb1ad856bf3e9aa0f21f899a1eff4a0c2b3 Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Thu, 7 Apr 2011 11:21:50 -0400 Subject: [PATCH 5/5] freetdm: fix rx gain --- libs/freetdm/src/ftdm_io.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 1ecd816658..1d7a0d1eb1 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -3563,16 +3563,18 @@ 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_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 ((ftdm_size_t)write(ftdmchan->fds[FTDM_READ_TRACE_INDEX], data, (int)dlen) != dlen) { ftdm_log(FTDM_LOG_WARNING, "Raw input trace failed to write all of the %"FTDM_SIZE_FMT" bytes\n", dlen); }