chlog: freetdm: ss7 - Support for Calling Party's Category

This commit is contained in:
David Yat Sin 2011-05-10 11:38:23 -04:00
parent e9f8fb4942
commit 05fa93f831
7 changed files with 105 additions and 20 deletions

View File

@ -1367,7 +1367,10 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
ftdm_usrmsg_add_var(&usrmsg, "ss7_pres_ind", sipvar);
}
sipvar = switch_channel_get_variable(channel, "sip_h_X-FreeTDM-CPC");
if (sipvar) {
ftdm_usrmsg_add_var(&usrmsg, "ss7_cpc", sipvar);
}
}
if (switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN)) {
@ -1673,7 +1676,12 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-GN-NumInComp", "%d", var_value);
}
} /* End - var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_gn_digits"); */
var_value = ftdm_sigmsg_get_var(sigmsg, "ss7_cpc");
if (!ftdm_strlen_zero(var_value)) {
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-CPC", "%d", var_value);
}
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);
}

View File

@ -743,7 +743,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
int loc = prog_ind.loc;
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.descr");
if (str && *str) {
if (!ftdm_strlen_zero(str)) {
/* User wants to override progress indicator */
descr = ftdm_str2ftdm_sngisdn_progind_descr(str);
}
@ -754,7 +754,7 @@ ftdm_status_t set_prog_ind_ie(ftdm_channel_t *ftdmchan, ProgInd *progInd, ftdm_s
}
str = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "isdn.prog_ind.loc");
if (str && *str) {
if (!ftdm_strlen_zero(str)) {
loc = ftdm_str2ftdm_sngisdn_progind_loc(str);
}
if (loc == SNGISDN_PROGIND_LOC_INVALID) {

View File

@ -189,6 +189,8 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
copy_genNmb_from_sngss7(ftdmchan, &siConEvnt->genNmb);
copy_cgPtyCat_from_sngss7(ftdmchan, &siConEvnt->cgPtyCat);
/* fill in the TMR/bearer capability */
if (siConEvnt->txMedReq.eh.pres) {
if (siConEvnt->txMedReq.trMedReq.pres) {

View File

@ -60,6 +60,13 @@
#define MAX_SIZEOF_SUBADDR_IE 24 /* as per Q931 4.5.9 */
typedef struct ftdm2trillium
{
uint8_t ftdm_val;
uint8_t trillium_val;
}ftdm2trillium_t;
typedef enum {
SNGSS7_CON_IND_EVENT = 0,
SNGSS7_CON_CFM_EVENT,
@ -806,6 +813,8 @@ ftdm_status_t copy_redirgNum_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *red
ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *redirgNum);
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);
ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat);
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);

View File

@ -112,12 +112,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
iam.fwdCallInd.isdnAccInd.val = ISDNACC_ISDN;
iam.fwdCallInd.sccpMethInd.pres = PRSNT_NODEF;
iam.fwdCallInd.sccpMethInd.val = SCCPMTH_NOIND;
/* copy down the calling number information */
iam.cgPtyCat.eh.pres = PRSNT_NODEF;
iam.cgPtyCat.cgPtyCat.pres = PRSNT_NODEF;
iam.cgPtyCat.cgPtyCat.val = CAT_ORD; /* ordinary suscriber */
/* copy down the transmission medium requirements */
iam.txMedReq.eh.pres = PRSNT_NODEF;
iam.txMedReq.trMedReq.pres = PRSNT_NODEF;
@ -185,6 +180,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
/* copy down the generic number information */
copy_genNmb_to_sngss7(ftdmchan, &iam.genNmb);
/* copy down the calling party category */
copy_cgPtyCat_to_sngss7(ftdmchan, &iam.cgPtyCat);
/* TODO - move this to copy_clg_subAddr_to_sngss7 function */
/* check if the user would like us to send a clg_sub-address */

View File

@ -91,9 +91,50 @@ FTDM_ENUM_NAMES(BLK_FLAGS_NAMES, BLK_FLAGS_STRING)
FTDM_STR2ENUM(ftmod_ss7_blk_state2flag, ftmod_ss7_blk_flag2str, sng_ckt_block_flag_t, BLK_FLAGS_NAMES, 31)
/* 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);
/* Maps generic FreeTDM CPC codes to SS7 CPC codes */
ftdm2trillium_t cpc_codes[] = {
{FTDM_CPC_UNKNOWN, CAT_UNKNOWN},
{FTDM_CPC_OPERATOR_FRENCH, CAT_OPLANGFR},
{FTDM_CPC_OPERATOR_ENGLISH, CAT_OPLANGENG},
{FTDM_CPC_OPERATOR_GERMAN, CAT_OPLANGGER},
{FTDM_CPC_OPERATOR_RUSSIAN, CAT_OPLANGRUS},
{FTDM_CPC_OPERATOR_SPANISH, CAT_OPLANGSP},
{FTDM_CPC_ORDINARY, CAT_ORD},
{FTDM_CPC_PRIORITY, CAT_PRIOR},
{FTDM_CPC_DATA, CAT_DATA},
{FTDM_CPC_TEST, CAT_TEST},
{FTDM_CPC_PAYPHONE, CAT_PAYPHONE},
};
static uint8_t get_trillium_val(ftdm2trillium_t *vals, uint8_t ftdm_val, uint8_t default_val)
{
ftdm2trillium_t *val = vals;
while(val++) {
if (val->ftdm_val == ftdm_val) {
return val->trillium_val;
}
}
return default_val;
}
static uint8_t get_ftdm_val(ftdm2trillium_t *vals, uint8_t trillium_val, uint8_t default_val)
{
ftdm2trillium_t *val = vals;
while(val++) {
if (val->trillium_val == trillium_val) {
return val->ftdm_val;
}
}
return default_val;
}
ftdm_status_t copy_cgPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *cgPtyNum)
{
return FTDM_SUCCESS;
}
@ -174,7 +215,6 @@ ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
{
const char *val = NULL;
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_gn_digits");
if (!ftdm_strlen_zero(val)) {
@ -183,9 +223,9 @@ ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
return FTDM_FAIL;
}
} else {
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number qualifier \"%s\"\n", val);
return FTDM_SUCCESS;
}
genNmb->eh.pres = PRSNT_NODEF;
genNmb->addrSig.pres = PRSNT_NODEF;
@ -243,7 +283,6 @@ ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb)
genNmb->niInd.val = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info->circuit->id].gn_num_inc_ind;
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied Generic Number \"number incomplete indicator\" \"%d\"\n", genNmb->niInd.val);
}
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_SUCCESS;
}
@ -251,7 +290,6 @@ ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb
{
char val[64];
sngss7_chan_data_t *sngss7_info = ftdmchan->call_data;
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
memset(val, 0, sizeof(val));
@ -301,7 +339,6 @@ ftdm_status_t copy_genNmb_from_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb
sngss7_add_var(sngss7_info, "ss7_gn_num_inc_ind", val);
}
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_SUCCESS;
}
@ -423,6 +460,35 @@ ftdm_status_t copy_redirgNum_from_sngss7(ftdm_channel_t *ftdmchan, SiRedirNum *r
return FTDM_SUCCESS;
}
ftdm_status_t copy_cgPtyCat_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat)
{
const char* val = NULL;
cgPtyCat->eh.pres = PRSNT_NODEF;
cgPtyCat->cgPtyCat.pres = PRSNT_NODEF;
val = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_cpc");
if (!ftdm_strlen_zero(val)) {
cgPtyCat->cgPtyCat.val = get_trillium_val(cpc_codes, ftdm_str2ftdm_calling_party_category(val), CAT_ORD);
} else {
cgPtyCat->cgPtyCat.val = CAT_ORD; /* ordinary suscriber */
}
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n", cgPtyCat->cgPtyCat.val);
return FTDM_SUCCESS;
}
ftdm_status_t copy_cgPtyCat_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyCat *cgPtyCat)
{
if (cgPtyCat->eh.pres == PRSNT_NODEF &&
cgPtyCat->cgPtyCat.pres == PRSNT_NODEF) {
sngss7_add_var((sngss7_chan_data_t*)ftdmchan->call_data, "ss7_cpc",
ftdm_calling_party_category2str(get_ftdm_val(cpc_codes, cgPtyCat->cgPtyCat.val, FTDM_CPC_UNKNOWN)));
ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Calling Party Category:0x%x\n", cgPtyCat->cgPtyCat.val);
}
return FTDM_SUCCESS;
}
ftdm_status_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven)
{
uint8_t i;
@ -648,8 +714,6 @@ int check_cics_in_range(sngss7_chan_data_t *sngss7_info)
/******************************************************************************/
ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan)
{
/*SS7_FUNC_TRACE_ENTER(__FUNCTION__);*/
if (g_ftdm_sngss7_data.cfg.isupCkt[circuit].obj == NULL) {
SS7_ERROR("sngss7_info is Null for circuit #%d\n", circuit);
return FTDM_FAIL;
@ -662,7 +726,6 @@ ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_in
ftdm_assert_return((*sngss7_info)->ftdmchan, FTDM_FAIL, "received message on signalling link or non-configured cic\n");
*ftdmchan = (*sngss7_info)->ftdmchan;
/*SS7_FUNC_TRACE_EXIT(__FUNCTION__);*/
return FTDM_SUCCESS;
}

View File

@ -298,6 +298,11 @@ FTDM_STR2ENUM_P(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_u
typedef enum {
FTDM_CPC_UNKNOWN,
FTDM_CPC_OPERATOR,
FTDM_CPC_OPERATOR_FRENCH,
FTDM_CPC_OPERATOR_ENGLISH,
FTDM_CPC_OPERATOR_GERMAN,
FTDM_CPC_OPERATOR_RUSSIAN,
FTDM_CPC_OPERATOR_SPANISH,
FTDM_CPC_ORDINARY,
FTDM_CPC_PRIORITY,
FTDM_CPC_DATA,
@ -305,7 +310,7 @@ typedef enum {
FTDM_CPC_PAYPHONE,
FTDM_CPC_INVALID
} ftdm_calling_party_category_t;
#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid"
#define CALLING_PARTY_CATEGORY_STRINGS "unknown", "operator", "operator-french", "operator-english", "operator-german", "operator-russian", "operator-spanish", "ordinary", "priority", "data-call", "test-call", "payphone", "invalid"
FTDM_STR2ENUM_P(ftdm_str2ftdm_calling_party_category, ftdm_calling_party_category2str, ftdm_calling_party_category_t)
/*! \brief Digit limit used in DNIS/ANI */