From ce46a57b857c3648ec5518fcd23a7ad66fd16cd9 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 17 May 2012 17:56:50 -0400 Subject: [PATCH 01/15] ss7: Adding support of Access Transport IE in IAM message Adding sip x-header and channel variable to set the value of Access Transport IE --- libs/freetdm/mod_freetdm/mod_freetdm.c | 10 +++++ .../ftmod_sangoma_ss7_handle.c | 1 + .../ftmod_sangoma_ss7_main.h | 2 + .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 10 ++++- .../ftmod_sangoma_ss7_support.c | 43 +++++++++++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 6a32098b44..51fbeca6cc 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1400,6 +1400,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (sipvar) { ftdm_set_string(caller_data.loc.digits, sipvar); } + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Access-Transport"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_access_transport_urlenc", sipvar); + } sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC-Screen"); if (sipvar) { @@ -1865,6 +1870,11 @@ 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-Plan", "%d", channel_caller_data->rdnis.plan); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc)); + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_access_transport_urlenc"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Access-Transport", "%s", var_value); + } + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_indicator"); if (!ftdm_strlen_zero(var_value)) { switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDINF-Indicator", "%s", var_value); 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 d0d6c32867..48e4bc4735 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 @@ -221,6 +221,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ } else { SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); } + copy_access_transport_from_sngss7(ftdmchan, &siConEvnt->accTrnspt); copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum); copy_redirgInfo_from_sngss7(ftdmchan, &siConEvnt->redirInfo); 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 4ccf4efe0e..a6dde4d704 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 @@ -916,6 +916,8 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum); +ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); +ftdm_status_t copy_access_transport_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum); ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb); 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 9ba11ada58..bf693c0999 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 @@ -138,6 +138,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Original Called Number */ copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); } + copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); } } else if (sngss7_info->circuit->transparent_iam && sngss7_retrieve_iam(ftdmchan, &iam) == FTDM_SUCCESS) { @@ -160,6 +161,8 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Original Called Number */ copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); + + copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); } else { /* Nature of Connection Indicators */ copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd); @@ -199,8 +202,13 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) /* Original Called Number */ copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); - /* Access Transport */ + /* Access Transport - old implementation, taking from channel variable of ss7_clg_subaddr */ copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt); + + /* Access Transport - taking from channel variable of ss7_access_transport_urlenc. + This will overwirte the IE value set be above old implementation. + */ + copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d), loc = %s (NADI=%d)\n", sngss7_info->circuit->cic, 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 96359ba595..fd70f13290 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 @@ -637,6 +637,49 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r return FTDM_SUCCESS; } +ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) +{ + char *val=NULL; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + if (accTrnspt->eh.pres != PRSNT_NODEF || accTrnspt->infoElmts.pres !=PRSNT_NODEF) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No Access Transport IE available\n"); + return FTDM_SUCCESS; + } + + val = ftdm_malloc(3*accTrnspt->infoElmts.len); + ftdm_url_encode((const char*)accTrnspt->infoElmts.val, val, accTrnspt->infoElmts.len); + sngss7_add_var (sngss7_info, "ss7_access_transport_urlenc", val); + ftdm_safe_free(val); + + return FTDM_SUCCESS; +} +ftdm_status_t copy_access_transport_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) +{ + const char *val = NULL; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_access_transport_urlenc"); + if (ftdm_strlen_zero(val)) { + accTrnspt->eh.pres = NOTPRSNT; + accTrnspt->infoElmts.pres = NOTPRSNT; + } + else { + char *val_dec = NULL; + int val_len = strlen (val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found Access Transport IE encoded : %s\n", val); + + accTrnspt->eh.pres = PRSNT_NODEF; + accTrnspt->infoElmts.pres = PRSNT_NODEF; + + val_dec = ftdm_strdup(val); + ftdm_url_decode(val_dec, (ftdm_size_t*)&val_len); + memcpy (accTrnspt->infoElmts.val, val_dec, val_len); + accTrnspt->infoElmts.len = val_len; + ftdm_safe_free(val_dec); + } + return FTDM_SUCCESS; +} + ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum) { char val[20]; From e91e4d68163368371461e9db451790667c90947b Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 18 May 2012 09:57:51 -0400 Subject: [PATCH 02/15] renamed sip_h_X-FreeTDM-Access-Transport to sip_h_X-FreeTDM-Access-Transport-URLENC --- libs/freetdm/mod_freetdm/mod_freetdm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 51fbeca6cc..90de796b43 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1401,7 +1401,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ftdm_set_string(caller_data.loc.digits, sipvar); } - sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Access-Transport"); + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-Access-Transport-URLENC"); if (sipvar) { ftdm_usrmsg_add_var(&usrmsg, "ss7_access_transport_urlenc", sipvar); } @@ -1872,7 +1872,7 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_access_transport_urlenc"); if (!ftdm_strlen_zero(var_value)) { - switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Access-Transport", "%s", var_value); + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Access-Transport-URLENC", "%s", var_value); } var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_rdinfo_indicator"); From 91dfa062bf41ce8005696987a20f3c4648c0e888 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 28 May 2012 16:53:45 -0400 Subject: [PATCH 03/15] ss7: adding iam_fwd_ind_HEX channel variable to set forward indicator IE's heximal value. - add to dialplan with expected hex value. If the outgoing ftdm channel's forward indicator needs to be changed, "export" needs to be put in the incoming channel's dialplan to set this variable value accordingly. - this implementation takes bits of A, CB, D, E, F, HG, I from the hex value. Bits of KJ, L, P-M are not taken from the hex. - How to calculate hex value with wanted bits: . the hex value is H-A-P-I, H is the highest bit to A, and next is P-I. I is the lowest bit in the whole field, and H is the highest bit in the whole field. Refer to Q.763 chapter 3.23. . use a text pad to fill in the bits with 0 and 1. eventually fill all the 16 bits . copy the binary value into a calculator and convert it to hex --- libs/freetdm/mod_freetdm/mod_freetdm.c | 5 + .../ftmod_sangoma_ss7_support.c | 136 ++++++++++++++++-- 2 files changed, 128 insertions(+), 13 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 90de796b43..430ace829f 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1593,6 +1593,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if ((var = channel_get_variable(session, var_event, "freetdm_calling_party_category"))) { ftdm_set_calling_party_category(var, (uint8_t *)&caller_data.cpc); } + + if ((var = channel_get_variable(session, var_event, "iam_fwd_ind_HEX"))) { + ftdm_usrmsg_add_var(&usrmsg, "iam_fwd_ind_HEX", var); + } + if (!zstr(dest)) { ftdm_set_string(caller_data.dnis.digits, dest); 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 fd70f13290..39134f9925 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 @@ -87,7 +87,7 @@ FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_fl /* FUNCTIONS ******************************************************************/ static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val); static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val); - +ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) ; /* Maps generic FreeTDM CPC codes to SS7 CPC codes */ @@ -248,9 +248,9 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - if (!strcasecmp(caller_data->loc.digits, "NULL")) { - pres_val = NOTPRSNT; - } + if (!strcasecmp(caller_data->loc.digits, "NULL")) { + pres_val = NOTPRSNT; + } locPtyNum->eh.pres = pres_val; locPtyNum->natAddrInd.pres = pres_val; @@ -896,6 +896,86 @@ ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *na return FTDM_SUCCESS; } +ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) +{ + int i= 4; + char a, b, c, d; + if (!in || 4>strlen(in)) { + return FTDM_FAIL; + } + while(i) + { + switch((char)*(in+(4-i))) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (i==4) { + d = *(in+(4-i)) - 48; + } else if (i==3) { + c = *(in+(4-i)) - 48; + } else if (i==2) { + b = *(in+(4-i)) - 48; + } else { + a = *(in+(4-i)) - 48; + } + break; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + if (i==4) { + d = *(in+(4-i)) - 55; + } else if (i==3) { + c = *(in+(4-i)) - 55; + } else if (i==2) { + b = *(in+(4-i)) - 55; + } else { + a = *(in+(4-i)) - 55; + } + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + if (i==4) { + d = *(in+(4-i)) - 87; + } else if (i==3) { + c = *(in+(4-i)) - 87; + } else if (i==2) { + b = *(in+(4-i)) - 87; + } else { + a = *(in+(4-i)) - 87; + } + break; + default: + SS7_ERROR("Invalid character found when decoding hex string, %c!\n", *(in+(4-i)) ); + break; + } + i--; + }; + + *out |= d; + *out = *out<<4; + *out |= c; + *out = *out<<4; + *out |= b; + *out = *out<<4; + *out |= a; + + return FTDM_SUCCESS; +} + ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) { const char *val = NULL; @@ -904,27 +984,56 @@ ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd * fwdCallInd->eh.pres = PRSNT_NODEF; fwdCallInd->natIntCallInd.pres = PRSNT_NODEF; - fwdCallInd->natIntCallInd.val = 0x00; fwdCallInd->end2EndMethInd.pres = PRSNT_NODEF; - fwdCallInd->end2EndMethInd.val = E2EMTH_NOMETH; fwdCallInd->intInd.pres = PRSNT_NODEF; - fwdCallInd->intInd.val = INTIND_NOINTW; fwdCallInd->end2EndInfoInd.pres = PRSNT_NODEF; - fwdCallInd->end2EndInfoInd.val = E2EINF_NOINFO; fwdCallInd->isdnUsrPrtInd.pres = PRSNT_NODEF; - fwdCallInd->isdnUsrPrtInd.val = ISUP_USED; fwdCallInd->isdnUsrPrtPrfInd.pres = PRSNT_NODEF; - fwdCallInd->isdnUsrPrtPrfInd.val = PREF_PREFAW; fwdCallInd->isdnAccInd.pres = PRSNT_NODEF; + fwdCallInd->sccpMethInd.pres = PRSNT_NODEF; + fwdCallInd->sccpMethInd.val = SCCPMTH_NOIND; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_HEX"); + if (!ftdm_strlen_zero(val)) { + uint16_t val_hex = 0; + if (four_char_to_hex (val, &val_hex) == FTDM_FAIL) { + SS7_ERROR ("Wrong value set in iam_fwd_ind_HEX variable. Please correct the error. Setting to default values.\n" ); + } else { + fwdCallInd->natIntCallInd.val = (val_hex & 0x100)>>8; + fwdCallInd->end2EndMethInd.val = (val_hex & 0x600)>>9; + fwdCallInd->intInd.val = (val_hex & 0x800)>>11; + fwdCallInd->end2EndInfoInd.val = (val_hex & 0x1000)>>12; + fwdCallInd->isdnUsrPrtInd.val = (val_hex & 0x2000)>>13; + fwdCallInd->isdnUsrPrtPrfInd.val = (val_hex & 0xC000)>>14; + fwdCallInd->isdnUsrPrtPrfInd.val = (fwdCallInd->isdnUsrPrtPrfInd.val==0x03)?0x0:fwdCallInd->isdnUsrPrtPrfInd.val; + fwdCallInd->isdnAccInd.val = val_hex & 0x1; + + if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) || + (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) || + (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS95)) { + + /* include only if we're running ANSI */ + fwdCallInd->transCallNInd.pres = PRSNT_NODEF; + fwdCallInd->transCallNInd.val = 0x0; + } + + return FTDM_SUCCESS; + } + } + + fwdCallInd->natIntCallInd.val = 0x00; + fwdCallInd->end2EndMethInd.val = E2EMTH_NOMETH; + fwdCallInd->intInd.val = INTIND_NOINTW; + fwdCallInd->end2EndInfoInd.val = E2EINF_NOINFO; + fwdCallInd->isdnUsrPrtInd.val = ISUP_USED; + fwdCallInd->isdnUsrPrtPrfInd.val = PREF_PREFAW; val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_isdn_access_ind"); if (!ftdm_strlen_zero(val)) { acc_val = (int)atoi(val); } - fwdCallInd->isdnAccInd.val = acc_val; - fwdCallInd->sccpMethInd.pres = PRSNT_NODEF; - fwdCallInd->sccpMethInd.val = SCCPMTH_NOIND; + fwdCallInd->isdnAccInd.val = acc_val; if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS88) || (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].switchType == LSI_SW_ANS92) || @@ -934,6 +1043,7 @@ ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd * fwdCallInd->transCallNInd.pres = PRSNT_NODEF; fwdCallInd->transCallNInd.val = 0x0; } + return FTDM_SUCCESS; } From e05bd3fae8ed8edaddee6271b3d246a16a0b4234 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 30 May 2012 13:10:04 -0400 Subject: [PATCH 04/15] Some changes to ss7 variables to be more consistent --- libs/freetdm/mod_freetdm/mod_freetdm.c | 9 ++++----- .../ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 430ace829f..e889d1ebba 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1554,6 +1554,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (sipvar) { ftdm_usrmsg_add_var(&usrmsg, "ss7_ocn_pres", sipvar); } + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM-FWD-IND-HEX"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_iam_fwd_ind_hex", sipvar); + } } if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { @@ -1594,11 +1598,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ftdm_set_calling_party_category(var, (uint8_t *)&caller_data.cpc); } - if ((var = channel_get_variable(session, var_event, "iam_fwd_ind_HEX"))) { - ftdm_usrmsg_add_var(&usrmsg, "iam_fwd_ind_HEX", var); - } - - if (!zstr(dest)) { ftdm_set_string(caller_data.dnis.digits, dest); } 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 39134f9925..b2edc2b497 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 @@ -993,7 +993,7 @@ ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd * fwdCallInd->sccpMethInd.pres = PRSNT_NODEF; fwdCallInd->sccpMethInd.val = SCCPMTH_NOIND; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_HEX"); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_fwd_ind_hex"); if (!ftdm_strlen_zero(val)) { uint16_t val_hex = 0; if (four_char_to_hex (val, &val_hex) == FTDM_FAIL) { @@ -1028,7 +1028,12 @@ ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd * fwdCallInd->isdnUsrPrtInd.val = ISUP_USED; fwdCallInd->isdnUsrPrtPrfInd.val = PREF_PREFAW; - val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_isdn_access_ind"); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_fwd_ind_isdn_access_ind"); + if (ftdm_strlen_zero(val)) { + /* Kept for backward compatibility */ + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "iam_fwd_ind_isdn_access_ind"); + } + if (!ftdm_strlen_zero(val)) { acc_val = (int)atoi(val); } From 2f5ac6243332fb75add1e13159966b2a8d49ffc8 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 15 Jun 2012 15:46:53 -0400 Subject: [PATCH 05/15] added mod_distributor --- build/modules.conf.in | 1 + 1 file changed, 1 insertion(+) diff --git a/build/modules.conf.in b/build/modules.conf.in index 1d27aaad1b..1284bb8bc1 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -5,6 +5,7 @@ applications/mod_dptools applications/mod_commands applications/mod_hash applications/mod_spandsp +applications/mod_distributor dialplans/mod_dialplan_xml endpoints/mod_sofia ../../libs/freetdm/mod_freetdm From 607da0f56c1b7a1c9227d39b53a53ab9a4b9ceca Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 22 Jun 2012 17:05:15 -0400 Subject: [PATCH 06/15] ss7: adding ss7_iam_fwd_ind_hex as x-header and channel variables in hex format. Read the forward call indicator IE and print it into channel variable ss7_iam_fwd_ind_hex. If this variable exists, put it in the x-header. This implementation takes bits of A, CB, D, E, F, HG, I from the hex value. Bits of KJ, L, P-M are not taken and set to 0. The hex value is H-A-P-I, H is the highest bit to A, and next is P-I. I is the lowest bit in the whole field, and H is the highest bit in the whole field. Refer to Q.763 chapter 3.23. --- libs/freetdm/mod_freetdm/mod_freetdm.c | 5 ++ .../ftmod_sangoma_ss7_handle.c | 1 + .../ftmod_sangoma_ss7_main.h | 1 + .../ftmod_sangoma_ss7_support.c | 54 +++++++++++++++++-- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index e889d1ebba..ed57b8c0c3 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1874,6 +1874,11 @@ 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-Plan", "%d", channel_caller_data->rdnis.plan); switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc)); + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam_fwd_ind_hex"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM-FWD-IND-HEX", "%s", var_value); + } + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_access_transport_urlenc"); if (!ftdm_strlen_zero(var_value)) { switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-Access-Transport-URLENC", "%s", var_value); 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 48e4bc4735..beacecc180 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 @@ -221,6 +221,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ } else { SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); } + copy_fwdCallInd_hex_from_sngss7(ftdmchan, &siConEvnt->fwdCallInd); copy_access_transport_from_sngss7(ftdmchan, &siConEvnt->accTrnspt); copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum); 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 a6dde4d704..3b62f67850 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 @@ -926,6 +926,7 @@ ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPt ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat); ftdm_status_t copy_accTrnspt_to_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt); ftdm_status_t copy_natConInd_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd); +ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd); ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd); ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq); ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA); 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 b2edc2b497..bafd2d3f8d 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 @@ -88,7 +88,7 @@ FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_fl static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val); static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val); ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) ; - +ftdm_status_t hex_to_four_char(uint16_t in, char* out); /* Maps generic FreeTDM CPC codes to SS7 CPC codes */ ftdm2trillium_t cpc_codes[] = { @@ -976,6 +976,54 @@ ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) return FTDM_SUCCESS; } + +ftdm_status_t hex_to_four_char(uint16_t in, char* out) +{ + char val=0; + int mask = 0xf; + int i=0; + if (!out) { + return FTDM_SUCCESS; + } + + for (i=3; i>=0; i--) { + val = (in & (mask<<(4*i))) >> (4*i); + sprintf (out+(3-i), "%x", val); + } + + return FTDM_SUCCESS; +} + +ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) +{ + char val[5]; + uint16_t val_hex = 0; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + memset (val, 0, 5*sizeof(char)); + if (fwdCallInd->eh.pres != PRSNT_NODEF ) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No forward call indicator IE available\n"); + return FTDM_SUCCESS; + } + + val_hex |= fwdCallInd->natIntCallInd.val << 8; + val_hex |= (fwdCallInd->end2EndMethInd.val & 0x1) << 9; + val_hex |= ((fwdCallInd->end2EndMethInd.val & 0x2)>>1) << 10; + val_hex |= fwdCallInd->intInd.val << 11; + val_hex |= fwdCallInd->end2EndInfoInd.val << 12; + val_hex |= fwdCallInd->isdnUsrPrtInd.val << 13; + val_hex |= (fwdCallInd->isdnUsrPrtPrfInd.val & 0x1) << 14; + val_hex |= ((fwdCallInd->isdnUsrPrtPrfInd.val & 0x2)>>1) << 15; + + val_hex |= fwdCallInd->isdnAccInd.val; + hex_to_four_char(val_hex, val) ; + + sngss7_add_var(sngss7_info, "ss7_iam_fwd_ind_hex", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Forwad Call Indicator Hex: 0x%s\n", val); + + return FTDM_SUCCESS; +} + ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) { const char *val = NULL; @@ -1000,9 +1048,9 @@ ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd * SS7_ERROR ("Wrong value set in iam_fwd_ind_HEX variable. Please correct the error. Setting to default values.\n" ); } else { fwdCallInd->natIntCallInd.val = (val_hex & 0x100)>>8; - fwdCallInd->end2EndMethInd.val = (val_hex & 0x600)>>9; + fwdCallInd->end2EndMethInd.val = (val_hex & 0x600)>>9; fwdCallInd->intInd.val = (val_hex & 0x800)>>11; - fwdCallInd->end2EndInfoInd.val = (val_hex & 0x1000)>>12; + fwdCallInd->end2EndInfoInd.val = (val_hex & 0x1000)>>12; fwdCallInd->isdnUsrPrtInd.val = (val_hex & 0x2000)>>13; fwdCallInd->isdnUsrPrtPrfInd.val = (val_hex & 0xC000)>>14; fwdCallInd->isdnUsrPrtPrfInd.val = (fwdCallInd->isdnUsrPrtPrfInd.val==0x03)?0x0:fwdCallInd->isdnUsrPrtPrfInd.val; From 80f72823b3a0427b6b24851e146984976e0e799a Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 27 Jun 2012 12:31:35 -0400 Subject: [PATCH 07/15] ss7: add ss7_iam_nature_connection_hex to support Nature of Connection Indicator in IAM message. - ss7_iam_nature_connection_hex is the channel variable to carry HEX value from/to IAM message - X-FreeTDM-IAM-NATURE-CONN-HEX is the x-header string to carry HEX value from/to sip invite message - This IE is 8 bit hex, which turns into 2 chars - Only Satellite indicator, Continuity check indicator, and Echo control device indicator are supported. Spare value are not taken. Spare value is always set to all zero. - example: To set 00010101 (bit H-A), set X-FreeTDM-IAM-NATURE-CONN-HEX string value to 15 in the sip invite message to NSG. When NSG send out sip invite, if the incoming IAM message comes with Nature of Connection IE, NSG will put X-FreeTDM-IAM-NATURE-CONN-HEX in the invite x-header. For example, if the IE value is 00001010 in the IAM, NSG will send X-FreeTDM-IAM-NATURE-CONN-HEX with value string of "0A". - Two characters are madatory. "0A" must be specified rather than "A". If invalid format or characters are found, this x-header will be ommited. - Valid characters include 0-9, A-F, and a-f --- libs/freetdm/mod_freetdm/mod_freetdm.c | 11 ++ .../ftmod_sangoma_ss7_handle.c | 1 + .../ftmod_sangoma_ss7_main.h | 2 + .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 4 + .../ftmod_sangoma_ss7_support.c | 130 ++++++++++++++++++ 5 files changed, 148 insertions(+) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index ed57b8c0c3..a3e9fd4568 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -1558,6 +1558,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi if (sipvar) { ftdm_usrmsg_add_var(&usrmsg, "ss7_iam_fwd_ind_hex", sipvar); } + + sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-IAM-NATURE-CONN-HEX"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_iam_nature_connection_hex", sipvar); + } } if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) { @@ -1873,7 +1878,13 @@ 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-NADI", "%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-CPC", "%s", ftdm_calling_party_category2str(channel_caller_data->cpc)); + + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam_nature_connection_hex"); + if (!ftdm_strlen_zero(var_value)) { + switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM-NATURE-CONN-HEX", "%s", var_value); + } + var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_iam_fwd_ind_hex"); if (!ftdm_strlen_zero(var_value)) { switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-IAM-FWD-IND-HEX", "%s", var_value); 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 beacecc180..a4802b1853 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 @@ -221,6 +221,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ } else { SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " "); } + copy_NatureOfConnection_from_sngss7(ftdmchan, &siConEvnt->natConInd); copy_fwdCallInd_hex_from_sngss7(ftdmchan, &siConEvnt->fwdCallInd); copy_access_transport_from_sngss7(ftdmchan, &siConEvnt->accTrnspt); copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum); 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 3b62f67850..1e064f2522 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 @@ -930,6 +930,8 @@ ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCal ftdm_status_t copy_fwdCallInd_to_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd); ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMedReq); ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA); +ftdm_status_t copy_NatureOfConnection_from_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd ); +ftdm_status_t copy_NatureOfConnection_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd); 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); 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 bf693c0999..4f177a3957 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 @@ -163,6 +163,8 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) copy_ocn_to_sngss7(ftdmchan, &iam.origCdNum); copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); + + copy_NatureOfConnection_to_sngss7(ftdmchan, &iam.natConInd); } else { /* Nature of Connection Indicators */ copy_natConInd_to_sngss7(ftdmchan, &iam.natConInd); @@ -209,6 +211,8 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) This will overwirte the IE value set be above old implementation. */ copy_access_transport_to_sngss7(ftdmchan, &iam.accTrnspt); + + copy_NatureOfConnection_to_sngss7(ftdmchan, &iam.natConInd); SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d), loc = %s (NADI=%d)\n", sngss7_info->circuit->cic, 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 bafd2d3f8d..2f4c18d4c3 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 @@ -90,6 +90,10 @@ static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) ; ftdm_status_t hex_to_four_char(uint16_t in, char* out); + +ftdm_status_t hex_to_char(uint16_t in, char* out, int len); +ftdm_status_t char_to_hex(const char* in, uint16_t* out, int len); + /* Maps generic FreeTDM CPC codes to SS7 CPC codes */ ftdm2trillium_t cpc_codes[] = { {FTDM_CPC_UNKNOWN, CAT_UNKNOWN}, @@ -976,7 +980,79 @@ ftdm_status_t four_char_to_hex(const char* in, uint16_t* out) return FTDM_SUCCESS; } +ftdm_status_t char_to_hex(const char* in, uint16_t* out, int len) +{ + int i= len; + char *val = ftdm_malloc(len*sizeof(char)); + + if (!val ||!in || len>strlen(in)) { + return FTDM_FAIL; + } + + while(i) + { + switch((char)*(in+(len-i))) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + *(val+(len-i)) = *(in+(len-i)) - 48; + break; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + *(val+(len-i)) = *(in+(len-i)) - 55; + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + *(val+(len-i)) = *(in+(len-i)) - 87; + break; + default: + SS7_ERROR("Invalid character found when decoding hex string, %c!\n", *(in+(len-i)) ); + break; + } + i--; + }; + for (i=0; i<=len-1; i++) { + *out = *out << 4; + *out |= *(val+i); + } + + return FTDM_SUCCESS; +} + + + +ftdm_status_t hex_to_char(uint16_t in, char* out, int len) +{ + char val=0; + int mask = 0xf; + int i=0; + if (!out) { + return FTDM_SUCCESS; + } + + for (i=len-1; i>=0; i--) { + val = (in & (mask<<(4*i))) >> (4*i); + sprintf (out+(len-1-i), "%x", val); + } + + return FTDM_SUCCESS; +} ftdm_status_t hex_to_four_char(uint16_t in, char* out) { char val=0; @@ -994,6 +1070,60 @@ ftdm_status_t hex_to_four_char(uint16_t in, char* out) return FTDM_SUCCESS; } +ftdm_status_t copy_NatureOfConnection_to_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd) +{ + const char *val = NULL; + + natConInd->eh.pres = PRSNT_NODEF; + natConInd->satInd.pres = PRSNT_NODEF; + natConInd->contChkInd.pres = PRSNT_NODEF;; + natConInd->echoCntrlDevInd.pres = PRSNT_NODEF; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_nature_connection_hex"); + if (!ftdm_strlen_zero(val)) { + uint16_t val_hex = 0; + if (char_to_hex (val, &val_hex, 2) == FTDM_FAIL) { + SS7_ERROR ("Wrong value set in ss7_iam_nature_connection_hex variable. Please correct the error. Setting to default values.\n" ); + } else { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "hex = 0x%x\n", val_hex); + natConInd->satInd.val = (val_hex & 0x3); + natConInd->contChkInd.val = (val_hex & 0xc)>>2; + natConInd->echoCntrlDevInd.val = (val_hex & 0x10) >> 4; + + return FTDM_SUCCESS; + } + } + + natConInd->satInd.val = 0; + natConInd->contChkInd.val = 0; + natConInd->echoCntrlDevInd.val = 0; + + return FTDM_SUCCESS; +} + +ftdm_status_t copy_NatureOfConnection_from_sngss7(ftdm_channel_t *ftdmchan, SiNatConInd *natConInd ) +{ + char val[3]; + uint16_t val_hex = 0; + sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; + + memset (val, 0, 3*sizeof(char)); + if (natConInd->eh.pres != PRSNT_NODEF ) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No nature of connection indicator IE available\n"); + return FTDM_SUCCESS; + } + + val_hex |= natConInd->satInd.val; + val_hex |= natConInd->contChkInd.val << 2; + val_hex |= natConInd->echoCntrlDevInd.val <<4; + hex_to_char(val_hex, val, 2) ; + + sngss7_add_var(sngss7_info, "ss7_iam_nature_connection_hex", val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Nature of connection indicator Hex: 0x%s\n", val); + + return FTDM_SUCCESS; +} + ftdm_status_t copy_fwdCallInd_hex_from_sngss7(ftdm_channel_t *ftdmchan, SiFwdCallInd *fwdCallInd) { char val[5]; From 24a458683a3e6a0f9390e5ab7318f4cd0b14788e Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 29 Jun 2012 12:54:09 -0400 Subject: [PATCH 08/15] Skip filling locPtyNum if caller_data->loc.digits is NULL --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 2f4c18d4c3..867a8f7c07 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 @@ -247,13 +247,14 @@ ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *loc { const char *val = NULL; const char *loc_nadi = NULL; - int pres_val = PRSNT_NODEF; + int pres_val = PRSNT_NODEF; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; if (!strcasecmp(caller_data->loc.digits, "NULL")) { pres_val = NOTPRSNT; + return FTDM_SUCCESS; } locPtyNum->eh.pres = pres_val; From edd718d258306d16e2142f9cf0b9955871f137e2 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 4 Jul 2012 10:00:23 -0400 Subject: [PATCH 09/15] ss7: fix a wired crash on remind ticket 4972 - change dynamic memory allocation/deallocation to char array --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 2f4c18d4c3..8c5c221e0e 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 @@ -643,7 +643,7 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) { - char *val=NULL; + char val[(MF_SIZE_TKNSTRE + 7) & 0xff8]; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; if (accTrnspt->eh.pres != PRSNT_NODEF || accTrnspt->infoElmts.pres !=PRSNT_NODEF) { @@ -651,10 +651,8 @@ ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccT return FTDM_SUCCESS; } - val = ftdm_malloc(3*accTrnspt->infoElmts.len); ftdm_url_encode((const char*)accTrnspt->infoElmts.val, val, accTrnspt->infoElmts.len); sngss7_add_var (sngss7_info, "ss7_access_transport_urlenc", val); - ftdm_safe_free(val); return FTDM_SUCCESS; } From 64f33c25da177ce225ff3b24c23fffad97e126fd Mon Sep 17 00:00:00 2001 From: James Zhang Date: Wed, 4 Jul 2012 10:09:19 -0400 Subject: [PATCH 10/15] ss7: fix on last fix, make enough memory for bad encode cases --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8c5c221e0e..c47b580ef6 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 @@ -643,7 +643,7 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r ftdm_status_t copy_access_transport_from_sngss7(ftdm_channel_t *ftdmchan, SiAccTrnspt *accTrnspt) { - char val[(MF_SIZE_TKNSTRE + 7) & 0xff8]; + char val[3*((MF_SIZE_TKNSTRE + 7) & 0xff8)]; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; if (accTrnspt->eh.pres != PRSNT_NODEF || accTrnspt->infoElmts.pres !=PRSNT_NODEF) { From 03be3a3a74e57568df134bc54cc95fecc30211c1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 2 Sep 2011 16:59:59 -0500 Subject: [PATCH 11/15] don't parse signals in the set_running_state function to avoid livelock situation --- src/include/switch_channel.h | 4 ++++ src/switch_channel.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 176b841147..a4e44083df 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -87,6 +87,10 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_ #define switch_channel_up(_channel) (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) < CS_HANGUP) #define switch_channel_down(_channel) (switch_channel_check_signal(_channel, SWITCH_TRUE) || switch_channel_get_state(_channel) >= CS_HANGUP) + +#define switch_channel_up_nosig(_channel) switch_channel_get_state(_channel) < CS_HANGUP +#define switch_channel_down_nosig(_channel) switch_channel_get_state(_channel) >= CS_HANGUP + #define switch_channel_media_ack(_channel) (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK)) SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state); diff --git a/src/switch_channel.c b/src/switch_channel.c index 3f96616794..c11754d48a 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1839,8 +1839,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state( channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Call-Direction", channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound"); - - if (switch_channel_down(channel)) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-HIT-Dialplan", + switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_INBOUND || + switch_channel_test_flag(channel, CF_DIALPLAN) ? "true" : "false"); + + if (switch_channel_down_nosig(channel)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Answer-State", "hangup"); } else if (switch_channel_test_flag(channel, CF_ANSWERED)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered"); @@ -2123,7 +2126,7 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *chann switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", v); } - if (switch_channel_down(channel)) { + if (switch_channel_down_nosig(channel)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Answer-State", "hangup"); } else if (switch_channel_test_flag(channel, CF_ANSWERED)) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Answer-State", "answered"); From a4255e140b3b5de77b62213b6987a85b6dce7b1b Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 27 Jul 2012 11:53:00 -0400 Subject: [PATCH 12/15] freetdm: adding variables for ansi outgoing IAMs . added called party number INN variable ie. . added multiple variables to set User Service Information IE variables are : ss7_iam_usi_trans_cap ss7_iam_usi_code_standard ss7_iam_usi_trans_mode ss7_iam_usi_trans_rate_0 ss7_iam_usi_trans_rate_1 ss7_iam_usi_layer1_ident ss7_iam_usi_layer1_prot ss7_iam_usi_layer2_ident ss7_iam_usi_layer2_prot ss7_iam_usi_layer3_ident ss7_iam_usi_layer3_prot ss7_iam_usi_chan_struct ss7_iam_usi_config ss7_iam_usi_establish ss7_iam_usi_symmetry ss7_iam_usi_rate_multiplier . ss7_iam_usi_trans_cap is a string variable, the others are all integers . ss7_iam_usi_trans_cap has options of : - SPEECH - UNRESTRICTED - RESTRICTED - 31KHZ - 7KHZ - 15KHZ - VIDEO default value is SPEECH, if the parameter is wrong, set to SPEECH. If not set, this field is not present --- .../ftmod_sangoma_ss7_support.c | 229 +++++++++++++++--- 1 file changed, 199 insertions(+), 30 deletions(-) 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 032ea8efd7..2e51ba8674 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 @@ -213,17 +213,17 @@ ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cd ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum) { - const char *cld_nadi = NULL; + char *val = NULL; ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; cdPtyNum->eh.pres = PRSNT_NODEF; cdPtyNum->natAddrInd.pres = PRSNT_NODEF; - cld_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi"); - if (!ftdm_strlen_zero(cld_nadi)) { - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called NADI value \"%s\"\n", cld_nadi); - cdPtyNum->natAddrInd.val = atoi(cld_nadi); + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_nadi"); + if (!ftdm_strlen_zero(val)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called NADI value \"%s\"\n", val); + cdPtyNum->natAddrInd.val = atoi(val); } else { cdPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].cld_nadi; ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for CLD, using \"%d\"\n", cdPtyNum->natAddrInd.val); @@ -233,7 +233,14 @@ ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPt cdPtyNum->numPlan.val = 0x01; cdPtyNum->innInd.pres = PRSNT_NODEF; - cdPtyNum->innInd.val = 0x01; + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cld_inn"); + if (!ftdm_strlen_zero(val)) { + cdPtyNum->innInd.val = atoi(val); + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called INN value \"%s\"\n", val); + } else { + cdPtyNum->innInd.val = 0x01; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Called INN value, set to default value 0x01\n"); + } return copy_tknStr_to_sngss7(caller_data->dnis.digits, &cdPtyNum->addrSig, &cdPtyNum->oddEven); } @@ -1240,32 +1247,194 @@ ftdm_status_t copy_txMedReq_to_sngss7(ftdm_channel_t *ftdmchan, SiTxMedReq *txMe ftdm_status_t copy_usrServInfoA_to_sngss7(ftdm_channel_t *ftdmchan, SiUsrServInfo *usrServInfoA) { - usrServInfoA->eh.pres = PRSNT_NODEF; + int bProceed = 0; + const char *val = NULL; + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_cap"); + if (!ftdm_strlen_zero(val)) { + int itc_type = 0; + if (!strcasecmp(val, "SPEECH")) { + itc_type = ITC_SPEECH; + } else if (!strcasecmp(val, "UNRESTRICTED")) { + itc_type = ITC_UNRDIG; + } else if (!strcasecmp(val, "RESTRICTED")) { + itc_type = ITC_RESDIG; + } else if (!strcasecmp(val, "31KHZ")) { + itc_type = ITC_A31KHZ; + } else if (!strcasecmp(val, "7KHZ")) { + itc_type = ITC_A7KHZ; + } else if (!strcasecmp(val, "15KHZ")) { + itc_type = ITC_A15KHZ; + } else if (!strcasecmp(val, "VIDEO")) { + itc_type = ITC_VIDEO; + } else { + itc_type = ITC_SPEECH; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI transmission capability parameter is wrong : %s. Setting to default SPEECH. \n", val ); + } + + usrServInfoA->infoTranCap.pres = PRSNT_NODEF; + usrServInfoA->infoTranCap.val = get_trillium_val(bc_cap_codes, ftdmchan->caller_data.bearer_capability, itc_type); + bProceed = 1; + } else { + usrServInfoA->infoTranCap.pres = NOTPRSNT; + } - usrServInfoA->infoTranCap.pres = PRSNT_NODEF; + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_code_standard"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->cdeStand.pres = PRSNT_NODEF; + usrServInfoA->cdeStand.val = (int)atoi(val); /* default is 0x0 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI coding standard = %d\n", usrServInfoA->cdeStand.val ); + bProceed = 1; + } else { + usrServInfoA->cdeStand.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_mode"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->tranMode.pres = PRSNT_NODEF; + usrServInfoA->tranMode.val = (int)atoi(val); /* transfer mode, default is 0x0*/ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI transfer mode = %d\n", usrServInfoA->tranMode.val ); + bProceed = 1; + } else { + usrServInfoA->tranMode.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_rate_0"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->infoTranRate0.pres = PRSNT_NODEF; + usrServInfoA->infoTranRate0.val = (int)atoi(val); /* default is 0x10, 64kbps origination to destination*/ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI trans rate 0 = %d\n", usrServInfoA->infoTranRate0.val ); + bProceed = 1; + } else { + usrServInfoA->infoTranRate0.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_trans_rate_1"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->infoTranRate1.pres = PRSNT_NODEF; + usrServInfoA->infoTranRate1.val = (int)atoi(val); /* 64kbps destination to origination, default is 0x10 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI trans rate 1 = %d\n", usrServInfoA->infoTranRate1.val ); + bProceed = 1; + } else { + usrServInfoA->infoTranRate1.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer1_ident"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->lyr1Ident.pres = PRSNT_NODEF; + usrServInfoA->lyr1Ident.val = (int)atoi(val); /*default value is 0x01 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 1 indentification = %d\n", usrServInfoA->lyr1Ident.val ); + bProceed = 1; + } else { + usrServInfoA->lyr1Ident.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer1_prot"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->usrInfLyr1Prot.pres = PRSNT_NODEF; + usrServInfoA->usrInfLyr1Prot.val = (int)atoi(val); /*default value is 0x02 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 1 protocol = %d\n", usrServInfoA->usrInfLyr1Prot.val ); + bProceed = 1; + } else { + usrServInfoA->usrInfLyr1Prot.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer2_ident"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->lyr2Ident.pres = PRSNT_NODEF; + usrServInfoA->lyr2Ident.val = (int)atoi(val); /*default value is 0x01 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 2 indentification = %d\n", usrServInfoA->lyr2Ident.val ); + bProceed = 1; + } else { + usrServInfoA->lyr2Ident.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer2_prot"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->usrInfLyr2Prot.pres = PRSNT_NODEF; + usrServInfoA->usrInfLyr2Prot.val = (int)atoi(val); /*default value is 0x02 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 2 protocol = %d\n", usrServInfoA->usrInfLyr2Prot.val ); + bProceed = 1; + } else { + usrServInfoA->usrInfLyr2Prot.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer3_ident"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->lyr3Ident.pres = PRSNT_NODEF; + usrServInfoA->lyr3Ident.val = (int)atoi(val); /*default value is 0x01 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 3 indentification = %d\n", usrServInfoA->lyr3Ident.val ); + bProceed = 1; + } else { + usrServInfoA->lyr3Ident.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_layer3_prot"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->usrInfLyr3Prot.pres = PRSNT_NODEF; + usrServInfoA->usrInfLyr3Prot.val = (int)atoi(val); /*default value is 0x02 */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI layer 3 protocol = %d\n", usrServInfoA->usrInfLyr3Prot.val ); + bProceed = 1; + } else { + usrServInfoA->usrInfLyr3Prot.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_chan_struct"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->chanStruct.pres = PRSNT_NODEF; + usrServInfoA->chanStruct.val = (int)atoi(val); /* default value is 0x1, 8kHz integrity */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI channel structure = %d\n", usrServInfoA->chanStruct.val ); + bProceed = 1; + } else { + usrServInfoA->chanStruct.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_config"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->config.pres = PRSNT_NODEF; + usrServInfoA->config.val = (int)atoi(val); /* default value is 0x0, point to point configuration */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI configuration = %d\n", usrServInfoA->config.val ); + bProceed = 1; + } else { + usrServInfoA->config.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_establish"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->establish.pres = PRSNT_NODEF; + usrServInfoA->establish.val = (int)atoi(val); /* default value is 0x0, on demand */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI establishment = %d\n", usrServInfoA->establish.val ); + bProceed = 1; + } else { + usrServInfoA->establish.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_symmetry"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->symmetry.pres = PRSNT_NODEF; + usrServInfoA->symmetry.val = (int)atoi(val); /* default value is 0x0, bi-directional symmetric */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI symmetry = %d\n", usrServInfoA->symmetry.val ); + bProceed = 1; + } else { + usrServInfoA->symmetry.pres = NOTPRSNT; + } + + val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_iam_usi_rate_multiplier"); + if (!ftdm_strlen_zero(val)) { + usrServInfoA->rateMultiplier.pres = PRSNT_NODEF; + usrServInfoA->rateMultiplier.val = (int)atoi(val); /* default value is 0x1, 1x rate multipler */ + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "USI rate multipier = %d\n", usrServInfoA->rateMultiplier.val ); + bProceed = 1; + } else { + usrServInfoA->rateMultiplier.pres = NOTPRSNT; + } + + if (bProceed) { + usrServInfoA->eh.pres = PRSNT_NODEF; + } else { + usrServInfoA->eh.pres = NOTPRSNT; + } - usrServInfoA->infoTranCap.val = get_trillium_val(bc_cap_codes, ftdmchan->caller_data.bearer_capability, ITC_SPEECH); - - usrServInfoA->cdeStand.pres = PRSNT_NODEF; - usrServInfoA->cdeStand.val = 0x0; /* ITU-T standardized coding */ - usrServInfoA->tranMode.pres = PRSNT_NODEF; - usrServInfoA->tranMode.val = 0x0; /* circuit mode */ - usrServInfoA->infoTranRate0.pres = PRSNT_NODEF; - usrServInfoA->infoTranRate0.val = 0x10; /* 64kbps origination to destination */ - usrServInfoA->infoTranRate1.pres = PRSNT_NODEF; - usrServInfoA->infoTranRate1.val = 0x10; /* 64kbps destination to origination */ - usrServInfoA->chanStruct.pres = PRSNT_NODEF; - usrServInfoA->chanStruct.val = 0x1; /* 8kHz integrity */ - usrServInfoA->config.pres = PRSNT_NODEF; - usrServInfoA->config.val = 0x0; /* point to point configuration */ - usrServInfoA->establish.pres = PRSNT_NODEF; - usrServInfoA->establish.val = 0x0; /* on demand */ - usrServInfoA->symmetry.pres = PRSNT_NODEF; - usrServInfoA->symmetry.val = 0x0; /* bi-directional symmetric */ - usrServInfoA->usrInfLyr1Prot.pres = PRSNT_NODEF; - usrServInfoA->usrInfLyr1Prot.val = 0x2; /* G.711 ulaw */ - usrServInfoA->rateMultiplier.pres = PRSNT_NODEF; - usrServInfoA->rateMultiplier.val = 0x1; /* 1x rate multipler */ return FTDM_SUCCESS; } From 6895e46983e625817d6f939f5c19c0719fbc5c55 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 27 Jul 2012 15:02:45 -0400 Subject: [PATCH 13/15] Fix compile warning --- libs/freetdm/src/ftdm_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 1c05797102..18e39a3da9 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -36,7 +36,6 @@ * David Yat Sin * */ - #define _GNU_SOURCE #include "private/ftdm_core.h" #include From a6503b49524e0cce8d20e5b4c31955eea24b4521 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Sat, 28 Jul 2012 09:59:47 -0400 Subject: [PATCH 14/15] Fixed compile warning --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2e51ba8674..4e59b6ae33 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 @@ -213,7 +213,7 @@ ftdm_status_t copy_cdPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cd ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPtyNum) { - char *val = NULL; + const char *val = NULL; ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; From 4bbb8c014a8dccab24439bf43905559927169f53 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Sat, 28 Jul 2012 10:41:55 -0400 Subject: [PATCH 15/15] Fixed compile error --- .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2e51ba8674..105dda1f6b 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 @@ -239,7 +239,7 @@ ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPt ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Called INN value \"%s\"\n", val); } else { cdPtyNum->innInd.val = 0x01; - ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Called INN value, set to default value 0x01\n"); + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Called INN value, set to default value 0x01\n"); } return copy_tknStr_to_sngss7(caller_data->dnis.digits, &cdPtyNum->addrSig, &cdPtyNum->oddEven);