freetdm: CDR - location number implementation (for incoming and outgoing calls)

This commit is contained in:
James Zhang 2011-10-12 17:44:52 -04:00
parent 711091751b
commit 4aa0285a22
8 changed files with 125 additions and 12 deletions

View File

@ -1337,6 +1337,11 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
ftdm_set_string(caller_data.dnis.digits, sipvar);
}
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-LOC");
if (sipvar) {
ftdm_set_string(caller_data.loc.digits, sipvar);
}
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-DNIS-TON");
if (sipvar) {
caller_data.dnis.type = (uint8_t)atoi(sipvar);
@ -1703,6 +1708,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-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_rdnis_screen_ind");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-RDNIS-Screen", "%d", var_value);
@ -1766,6 +1772,26 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-OPC", "%s", var_value);
}
var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_digits");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC", "%s", var_value);
}
var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_screen_ind");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-Screen", "%s", var_value);
}
var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_pres_ind");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-Presentation", "%s", var_value);
}
var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_loc_pres_nadi");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-LOC-NADI", "%s", var_value);
}
}
/* Add any call variable to the dial plan */

View File

@ -78,6 +78,8 @@ int ft_to_sngss7_cfg_all(void)
/* check if we have done gen_config already */
if (!(g_ftdm_sngss7_data.gen_config)) {
/* update the global gen_config so we don't do it again */
g_ftdm_sngss7_data.gen_config = 1;
/* start of by checking if the license and sig file are valid */
if (sng_validate_license(g_ftdm_sngss7_data.cfg.license,
@ -207,10 +209,17 @@ int ft_to_sngss7_cfg_all(void)
}
} /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */
/* update the global gen_config so we don't do it again */
g_ftdm_sngss7_data.gen_config = 1;
g_ftdm_sngss7_data.gen_config = 2;
} /* if (!(g_ftdm_sngss7_data.gen_config)) */
/* FIXME: Please change number 2 to an ENUM that is more explanatory */
if (g_ftdm_sngss7_data.gen_config != 2) {
SS7_CRITICAL("General configuration FAILED!\n");
return 1;
}
/* go through all the relays channels and configure it */
x = 1;
while (x < (MAX_RELAY_CHANNELS)) {

View File

@ -213,9 +213,6 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
sprintf(var, "%d", siConEvnt->cgPtyNum.natAddrInd.val);
sngss7_add_var(sngss7_info, "ss7_clg_nadi", var);
sprintf(var, "%d", siConEvnt->cdPtyNum.natAddrInd.val);
sngss7_add_var(sngss7_info, "ss7_cld_nadi", var);
/* Retrieve the Location Number if present (see ITU Q.763, 3.30) */
if (siConEvnt->cgPtyNum1.eh.pres) {
if (siConEvnt->cgPtyNum1.addrSig.pres) {

View File

@ -328,6 +328,7 @@ typedef struct sng_isup_ckt {
uint32_t clg_nadi;
uint32_t cld_nadi;
uint8_t rdnis_nadi;
uint32_t loc_nadi;
/* Generic Number defaults */
uint8_t gn_nmbqual; /* Number Qualifier */
@ -835,6 +836,8 @@ 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);
ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum);
ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum);
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);
ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb);
ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat);

View File

@ -79,6 +79,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
/* Calling Number information */
copy_cgPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum);
/* Location Number information */
copy_locPtyNum_to_sngss7(ftdmchan, &iam.cgPtyNum1);
/* Generic Number information */
copy_genNmb_to_sngss7(ftdmchan, &iam.genNmb);
@ -91,12 +94,14 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
/* Access Transport */
copy_accTrnspt_to_sngss7(ftdmchan, &iam.accTrnspt);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Tx IAM clg = \"%s\" (NADI=%d), cld = \"%s\" (NADI=%d)\n",
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,
ftdmchan->caller_data.cid_num.digits,
iam.cgPtyNum.natAddrInd.val,
ftdmchan->caller_data.dnis.digits,
iam.cdPtyNum.natAddrInd.val);
iam.cdPtyNum.natAddrInd.val,
ftdmchan->caller_data.loc.digits,
iam.cgPtyNum1.natAddrInd.val);
}
sng_cc_con_request (sngss7_info->spId,

View File

@ -225,6 +225,62 @@ ftdm_status_t copy_cdPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCdPtyNum *cdPt
return copy_tknStr_to_sngss7(caller_data->dnis.digits, &cdPtyNum->addrSig, &cdPtyNum->oddEven);
}
ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum)
{
return FTDM_SUCCESS;
}
ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum)
{
const char *val = NULL;
const char *loc_nadi = NULL;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
ftdm_caller_data_t *caller_data = &ftdmchan->caller_data;
locPtyNum->eh.pres = PRSNT_NODEF;
locPtyNum->natAddrInd.pres = PRSNT_NODEF;
locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi;
locPtyNum->scrnInd.pres = PRSNT_NODEF;
val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_screen_ind");
if (!ftdm_strlen_zero(val)) {
locPtyNum->scrnInd.val = atoi(val);
} else {
locPtyNum->scrnInd.val = caller_data->screen;
}
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Location Reference Code Screening Ind %d\n", locPtyNum->scrnInd.val);
locPtyNum->presRest.pres = PRSNT_NODEF;
val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_pres_ind");
if (!ftdm_strlen_zero(val)) {
locPtyNum->presRest.val = atoi(val);
} else {
locPtyNum->presRest.val = caller_data->pres;
}
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Number Presentation Ind %d\n", locPtyNum->presRest.val);
locPtyNum->numPlan.pres = PRSNT_NODEF;
locPtyNum->numPlan.val = 0x01;
locPtyNum->niInd.pres = PRSNT_NODEF;
locPtyNum->niInd.val = 0x00;
/* check if the user would like a custom NADI value for the Location Reference */
loc_nadi = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_loc_nadi");
if (!ftdm_strlen_zero(loc_nadi)) {
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied Location Reference NADI value \"%s\"\n", loc_nadi);
locPtyNum->natAddrInd.val = atoi(loc_nadi);
} else {
locPtyNum->natAddrInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].loc_nadi;
locPtyNum->natAddrInd.val = 0x03;
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied NADI value found for LOC, using \"%d\"\n", locPtyNum->natAddrInd.val);
}
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Location Reference Presentation Ind %d\n", locPtyNum->presRest.val);
return copy_tknStr_to_sngss7(caller_data->loc.digits, &locPtyNum->addrSig, &locPtyNum->oddEven);
}
ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
{
const char *val = NULL;

View File

@ -123,6 +123,7 @@ typedef struct sng_ccSpan
uint32_t clg_nadi;
uint32_t cld_nadi;
uint32_t rdnis_nadi;
uint32_t loc_nadi;
uint32_t min_digits;
uint8_t itx_auto_reply;
uint8_t transparent_iam;
@ -1844,6 +1845,7 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
int flag_clg_nadi = 0;
int flag_cld_nadi = 0;
int flag_rdnis_nadi = 0;
int flag_loc_nadi = 0;
int i;
int ret;
@ -1945,6 +1947,14 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
SS7_DEBUG("Invalid parm->value for obci_bita option\n");
}
/**********************************************************************/
} else if (!strcasecmp(parm->var, "loc_nadi")) {
/* add location reference number */
flag_loc_nadi = 1;
sng_ccSpan.loc_nadi = atoi(parm->val);
SS7_DEBUG("Found default LOC_NADI parm->value = %d\n", sng_ccSpan.loc_nadi);
printf( " --- jz: we got loc nadi from XML, val = %d \n" , sng_ccSpan.loc_nadi);
/**********************************************************************/
} else if (!strcasecmp(parm->var, "lpa_on_cot")) {
/**********************************************************************/
if (*parm->val == '1') {
@ -2034,6 +2044,11 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
sng_ccSpan.rdnis_nadi = 0x03;
}
if (!flag_loc_nadi) {
/* default the nadi value to national */
sng_ccSpan.loc_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;
@ -2918,12 +2933,13 @@ 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].rdnis_nadi = ccSpan->rdnis_nadi;
g_ftdm_sngss7_data.cfg.isupCkt[x].loc_nadi = ccSpan->loc_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;
g_ftdm_sngss7_data.cfg.isupCkt[x].itx_auto_reply = ccSpan->itx_auto_reply;
g_ftdm_sngss7_data.cfg.isupCkt[x].transparent_iam = ccSpan->transparent_iam;
g_ftdm_sngss7_data.cfg.isupCkt[x].switchType = ccSpan->switchType;
g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits = ccSpan->min_digits;
g_ftdm_sngss7_data.cfg.isupCkt[x].itx_auto_reply = ccSpan->itx_auto_reply;
g_ftdm_sngss7_data.cfg.isupCkt[x].transparent_iam = ccSpan->transparent_iam;
if (ccSpan->t3 == 0) {
g_ftdm_sngss7_data.cfg.isupCkt[x].t3 = 1200;

View File

@ -351,6 +351,7 @@ typedef struct ftdm_caller_data {
ftdm_number_t ani; /*!< ANI (Automatic Number Identification) */
ftdm_number_t dnis; /*!< DNIS (Dialed Number Identification Service) */
ftdm_number_t rdnis; /*!< RDNIS (Redirected Dialed Number Identification Service) */
ftdm_number_t loc; /*!< LOC (Location Reference Code) */
char aniII[FTDM_DIGITS_LIMIT]; /*! ANI II */
uint8_t screen; /*!< Screening */
uint8_t pres; /*!< Presentation*/