diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c index c3aa964d4d..262cd9d03d 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c @@ -1155,6 +1155,77 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_isdn_span_config) return FTDM_FAIL; } + if (span_data->cid_name_method == SNGISDN_CID_NAME_AUTO) { + switch (span_data->switchtype) { + case SNGISDN_SWITCH_EUROISDN: + if (FTDM_SPAN_IS_BRI(span)) { + span_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; + } else { + span_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; + } + break; + case SNGISDN_SWITCH_DMS100: + span_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; + break; + case SNGISDN_SWITCH_NI2: + case SNGISDN_SWITCH_5ESS: + case SNGISDN_SWITCH_4ESS: + span_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; + break; + default: + break; + } + } + + if (span_data->send_cid_name == SNGISDN_OPT_DEFAULT) { + switch (span_data->switchtype) { + case SNGISDN_SWITCH_EUROISDN: +#ifdef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY + case SNGISDN_SWITCH_NI2: + case SNGISDN_SWITCH_5ESS: + case SNGISDN_SWITCH_4ESS: +#endif + if (span_data->signalling == SNGISDN_SIGNALING_NET) { + span_data->send_cid_name = SNGISDN_OPT_TRUE; + } else { + span_data->send_cid_name = SNGISDN_OPT_FALSE; + } + break; + case SNGISDN_SWITCH_DMS100: + span_data->send_cid_name = SNGISDN_OPT_TRUE; + break; +#ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY + case SNGISDN_SWITCH_NI2: + case SNGISDN_SWITCH_5ESS: + case SNGISDN_SWITCH_4ESS: + span_data->send_cid_name = SNGISDN_OPT_FALSE; + break; +#endif + default: + span_data->send_cid_name = SNGISDN_OPT_FALSE; + break; + } + } else if (span_data->send_cid_name == SNGISDN_OPT_TRUE) { + switch (span_data->switchtype) { + case SNGISDN_SWITCH_NI2: + case SNGISDN_SWITCH_5ESS: + case SNGISDN_SWITCH_4ESS: +#ifndef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY + ftdm_log(FTDM_LOG_WARNING, "Sending Calling Name in Facility IE not supported, please update your libsng_isdn library\n"); + span_data->send_cid_name = SNGISDN_OPT_FALSE; +#endif + break; + case SNGISDN_SWITCH_INSNET: /* Don't know how to transmit caller ID name on INSNET */ + case SNGISDN_SWITCH_QSIG: /* It seems like QSIG does not support Caller ID */ + span_data->send_cid_name = SNGISDN_OPT_FALSE; + break; + case SNGISDN_SWITCH_EUROISDN: + break; + default: + span_data->send_cid_name = SNGISDN_OPT_FALSE; + break; + } + } span->start = ftdm_sangoma_isdn_start; span->stop = ftdm_sangoma_isdn_stop; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h index fee68ec41a..a095b0d57e 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.h @@ -132,6 +132,13 @@ typedef enum { SNGISDN_AVAIL_UP = 10, } sngisdn_avail_t; +typedef enum { + SNGISDN_CID_NAME_AUTO, + SNGISDN_CID_NAME_DISPLAY_IE, + SNGISDN_CID_NAME_USR_USR_IE, + SNGISDN_CID_NAME_FACILITY_IE, +} sngisdn_cid_name_t; + typedef enum { SNGISDN_EVENT_CON_IND = 1, SNGISDN_EVENT_CON_CFM, @@ -262,10 +269,10 @@ typedef struct sngisdn_span_data { uint8_t raw_trace_q921; /* TODO: combine with trace_flags */ uint8_t timer_t3; uint8_t restart_opt; - uint8_t dynamic_tei; uint8_t restart_timeout; uint8_t force_sending_complete; - uint8_t cid_name_in_display_ie; /* In BRI, send the CID-name inside Display IE instead of Usr-usr */ + uint8_t cid_name_method; + uint8_t send_cid_name; char* local_numbers[SNGISDN_NUM_LOCAL_NUMBERS]; ftdm_timer_id_t timers[SNGISDN_NUM_SPAN_TIMERS]; ftdm_sched_t *sched; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c index e5928720a0..ba9226b9bc 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c @@ -284,12 +284,14 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ signal_data->ignore_cause_value = SNGISDN_OPT_DEFAULT; signal_data->timer_t3 = 8; signal_data->restart_opt = SNGISDN_OPT_DEFAULT; - signal_data->dynamic_tei = SNGISDN_OPT_DEFAULT; signal_data->link_id = span->span_id; signal_data->transfer_timeout = 20000; signal_data->att_remove_dtmf = SNGISDN_OPT_DEFAULT; signal_data->force_sending_complete = SNGISDN_OPT_DEFAULT; + signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; + signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; + span->default_caller_data.dnis.plan = FTDM_NPI_INVALID; span->default_caller_data.dnis.type = FTDM_TON_INVALID; span->default_caller_data.cid_num.plan = FTDM_NPI_INVALID; @@ -362,8 +364,6 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ parse_yesno(var, val, &signal_data->restart_opt); } else if (!strcasecmp(var, "channel-restart-timeout")) { signal_data->restart_timeout = atoi(val); - } else if (!strcasecmp(var, "dynamic-tei")) { - parse_yesno(var, val, &signal_data->dynamic_tei); } else if (!strcasecmp(var, "local-number")) { if (add_local_number(val, span) != FTDM_SUCCESS) { return FTDM_FAIL; @@ -404,8 +404,30 @@ ftdm_status_t ftmod_isdn_parse_cfg(ftdm_conf_parameter_t *ftdm_parameters, ftdm_ #else ftdm_log(FTDM_LOG_WARNING, "chan-id-invert-extend-bit is not supported in your version of libsng_isdn\n"); #endif - } else if (!strcasecmp(var, "cid-name-in-display-ie")) { - parse_yesno(var, val, &signal_data->cid_name_in_display_ie); + } else if (!strcasecmp(var, "cid-name-transmit-method")) { + if (!strcasecmp(val, "display-ie")) { + signal_data->cid_name_method = SNGISDN_CID_NAME_DISPLAY_IE; + } else if (!strcasecmp(val, "user-user-ie")) { + signal_data->cid_name_method = SNGISDN_CID_NAME_USR_USR_IE; + } else if (!strcasecmp(val, "facility-ie")) { + signal_data->cid_name_method = SNGISDN_CID_NAME_FACILITY_IE; + } else if (!strcasecmp(val, "auto") || !strcasecmp(val, "automatic") || !strcasecmp(val, "default")) { + signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; + } else { + ftdm_log(FTDM_LOG_WARNING, "Invalid option %s for parameter %s\n", val, var); + signal_data->cid_name_method = SNGISDN_CID_NAME_AUTO; + } + } else if (!strcasecmp(var, "send-cid-name")) { + if (!strcasecmp(val, "yes")) { + signal_data->send_cid_name = SNGISDN_OPT_TRUE; + } else if (!strcasecmp(val, "no")) { + signal_data->send_cid_name = SNGISDN_OPT_FALSE; + } else if (!strcasecmp(val, "auto") || !strcasecmp(val, "automatic") || !strcasecmp(val, "default")) { + signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; + } else { + ftdm_log(FTDM_LOG_WARNING, "Invalid option %s for parameter %s\n", val, var); + signal_data->send_cid_name = SNGISDN_OPT_DEFAULT; + } } else { ftdm_log(FTDM_LOG_WARNING, "Ignoring unknown parameter %s\n", ftdm_parameters[paramindex].var); } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index 2b9bceea25..b121fee6cf 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -865,12 +865,6 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span) return FTDM_FAIL; } - /* Override TEI teiAlloc Option if user specified it */ - if (signal_data->dynamic_tei != SNGISDN_OPT_DEFAULT ) { - ftdm_log(FTDM_LOG_DEBUG, "%s: TEI allocation set to %s\n", span->name, (signal_data->dynamic_tei == SNGISDN_OPT_TRUE)? "dynamic": "static"); - cfg.t.cfg.s.inDLSAP.teiAlloc = (signal_data->dynamic_tei==SNGISDN_OPT_TRUE)?IN_DYNAMIC:IN_STATIC; - } - if (sng_isdn_q931_config(&pst, &cfg)) { return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c index af2c2e95d1..095221dcfa 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_support.c @@ -696,70 +696,61 @@ ftdm_status_t set_redir_num(ftdm_channel_t *ftdmchan, RedirNmb *redirNmb) ftdm_status_t set_calling_name(ftdm_channel_t *ftdmchan, ConEvnt *conEvnt) { uint8_t len; - ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; - /* sngisdn_chan_data_t *sngisdn_info = ftdmchan->call_data; */ + ftdm_caller_data_t *caller_data = &ftdmchan->caller_data; sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + len = strlen(caller_data->cid_name); if (!len) { return FTDM_SUCCESS; } - if (FTDM_SPAN_IS_BRI(ftdmchan->span) && - signal_data->cid_name_in_display_ie != SNGISDN_OPT_TRUE) { + if (signal_data->send_cid_name == SNGISDN_OPT_FALSE) { + return FTDM_SUCCESS; + } - conEvnt->usrUsr.eh.pres = PRSNT_NODEF; - conEvnt->usrUsr.protocolDisc.pres = PRSNT_NODEF; - conEvnt->usrUsr.protocolDisc.val = PD_IA5; /* IA5 chars */ - conEvnt->usrUsr.usrInfo.pres = PRSNT_NODEF; - conEvnt->usrUsr.usrInfo.len = len; - /* in sangoma_brid we used to send usr-usr info as !, - change to previous style if current one does not work */ - memcpy(conEvnt->usrUsr.usrInfo.val, caller_data->cid_name, len); - } else { - switch (signal_data->switchtype) { - case SNGISDN_SWITCH_NI2: + switch(signal_data->cid_name_method) { + case SNGISDN_CID_NAME_FACILITY_IE: #ifdef SNGISDN_SUPPORT_CALLING_NAME_IN_FACILITY - { - if (signal_data->signalling == SNGISDN_SIGNALING_NET) { - sng_isdn_encode_facility_caller_name(caller_data->cid_name, conEvnt->facilityStr.facilityStr.val, &conEvnt->facilityStr.facilityStr.len); - conEvnt->facilityStr.eh.pres = PRSNT_NODEF; - conEvnt->facilityStr.facilityStr.pres = PRSNT_NODEF; - } - } + /* Note: The Facility IE will be overwritten if user chose to transmit a Raw Facility IE */ + sng_isdn_encode_facility_caller_name(caller_data->cid_name, conEvnt->facilityStr.facilityStr.val, &conEvnt->facilityStr.facilityStr.len); + conEvnt->facilityStr.eh.pres = PRSNT_NODEF; + conEvnt->facilityStr.facilityStr.pres = PRSNT_NODEF; #endif break; - case SNGISDN_SWITCH_EUROISDN: - if (signal_data->signalling != SNGISDN_SIGNALING_NET) { - break; + case SNGISDN_CID_NAME_USR_USR_IE: + conEvnt->usrUsr.eh.pres = PRSNT_NODEF; + conEvnt->usrUsr.protocolDisc.pres = PRSNT_NODEF; + conEvnt->usrUsr.protocolDisc.val = PD_IA5; /* IA5 chars */ + conEvnt->usrUsr.usrInfo.pres = PRSNT_NODEF; + conEvnt->usrUsr.usrInfo.len = len; + /* in sangoma_brid we used to send usr-usr info as !, + change to previous style if current one does not work */ + memcpy(conEvnt->usrUsr.usrInfo.val, caller_data->cid_name, len); + break; + case SNGISDN_CID_NAME_DISPLAY_IE: + if (signal_data->switchtype == SNGISDN_SWITCH_DMS100) { + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispTypeNt.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispTypeNt.val = 0x01; /* Calling Party Name */ + conEvnt->ntDisplay[0].assocInfo.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].assocInfo.val = 0x03; /* Included */ + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispInfo.pres = PRSNT_NODEF; + conEvnt->ntDisplay[0].dispInfo.len = len; + memcpy(conEvnt->ntDisplay[0].dispInfo.val, caller_data->cid_name, len); + } else { + conEvnt->display.eh.pres = PRSNT_NODEF; + conEvnt->display.dispInfo.pres = PRSNT_NODEF; + conEvnt->display.dispInfo.len = len; + memcpy(conEvnt->display.dispInfo.val, caller_data->cid_name, len); } - /* follow through */ - case SNGISDN_SWITCH_5ESS: - case SNGISDN_SWITCH_4ESS: - conEvnt->display.dispInfo.pres = PRSNT_NODEF; - conEvnt->display.dispInfo.len = len; - memcpy(conEvnt->display.dispInfo.val, caller_data->cid_name, len); break; - case SNGISDN_SWITCH_DMS100: - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispTypeNt.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispTypeNt.val = 0x01; /* Calling Party Name */ - conEvnt->ntDisplay[0].assocInfo.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].assocInfo.val = 0x03; /* Included */ - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].eh.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispInfo.pres = PRSNT_NODEF; - conEvnt->ntDisplay[0].dispInfo.len = len; - memcpy(conEvnt->ntDisplay[0].dispInfo.val, caller_data->cid_name, len); + default: break; - case SNGISDN_SWITCH_QSIG: - /* It seems like QSIG does not support Caller ID Name */ - break; - case SNGISDN_SWITCH_INSNET: - /* Don't know how to transmit caller ID name on INSNET */ - break; - } } + return FTDM_SUCCESS; }