From 65bac44b327afd9ad0bdad7d9959b519c5a3e84a Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Wed, 3 Aug 2011 10:52:18 -0400 Subject: [PATCH] freetdm: ISDN - Added function to transmission of NOTIFY msg --- .../ftmod_sangoma_isdn/ftmod_sangoma_isdn.h | 3 +- .../ftmod_sangoma_isdn_stack_out.c | 30 ++++++++++++++++--- .../ftmod_sangoma_isdn_support.c | 8 +++++ 3 files changed, 36 insertions(+), 5 deletions(-) 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 6acbe3047a..2f1c5904ef 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 @@ -380,6 +380,7 @@ void sngisdn_snd_setup_ack(ftdm_channel_t *ftdmchan); void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); void sngisdn_snd_progress(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); void sngisdn_snd_alert(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_ind); +void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan); void sngisdn_snd_connect(ftdm_channel_t *ftdmchan); void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan); void sngisdn_snd_release(ftdm_channel_t *ftdmchan, uint8_t glare); @@ -480,7 +481,7 @@ ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr ftdm_status_t set_facility_ie_str(ftdm_channel_t *ftdmchan, uint8_t *data, uint8_t *data_len); ftdm_status_t set_user_to_user_ie(ftdm_channel_t *ftdmchan, UsrUsr *usrUsr); ftdm_status_t set_cause_ie(ftdm_channel_t *ftdmchan, CauseDgn *causeDgn); - +ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd); ftdm_status_t sngisdn_add_var(sngisdn_chan_data_t *sngisdn_info, const char* var, const char* val); ftdm_status_t sngisdn_add_raw_data(sngisdn_chan_data_t *sngisdn_info, uint8_t* data, ftdm_size_t data_len); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c index 94c4f03e7e..c2305e445f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_out.c @@ -317,11 +317,7 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan) } memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - //ftdm_log_chan_msg(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ\n"); - - - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending INFO REQ (suId:%d dchan:%d ces:%d)\n", signal_data->cc_id, signal_data->dchan_id, sngisdn_info->ces); if (sng_isdn_con_status(signal_data->cc_id, 0, 0, &cnStEvnt, MI_INFO, signal_data->dchan_id, sngisdn_info->ces)) { @@ -330,6 +326,32 @@ void sngisdn_snd_info_req(ftdm_channel_t *ftdmchan) return; } +void sngisdn_snd_notify_req(ftdm_channel_t *ftdmchan) +{ + CnStEvnt cnStEvnt; + + sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*) ftdmchan->call_data; + sngisdn_span_data_t *signal_data = (sngisdn_span_data_t*) ftdmchan->span->signal_data; + + if (!sngisdn_info->suInstId || !sngisdn_info->spInstId) { + ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, "Sending NOTIFY, but no call data, aborting (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); + sngisdn_set_flag(sngisdn_info, FLAG_LOCAL_ABORT); + ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); + return; + } + + memset(&cnStEvnt, 0, sizeof(cnStEvnt)); + + set_not_ind_ie(ftdmchan, &cnStEvnt.notInd); + + ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending NOTIFY (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces); + + if(sng_isdn_con_status(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId,&cnStEvnt, MI_NOTIFY, signal_data->dchan_id, sngisdn_info->ces)) { + ftdm_log_chan_msg(ftdmchan, FTDM_LOG_CRIT, "stack refused NOTIFY request\n"); + } + return; +} + void sngisdn_snd_status_enq(ftdm_channel_t *ftdmchan) { 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 39c756a2c2..9a633b902a 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 @@ -1021,6 +1021,14 @@ ftdm_status_t set_restart_ind_ie(ftdm_channel_t *ftdmchan, RstInd *rstInd) return FTDM_SUCCESS; } +ftdm_status_t set_not_ind_ie(ftdm_channel_t *ftdmchan, NotInd *notInd) +{ + notInd->eh.pres = PRSNT_NODEF; + notInd->notDesc.pres = PRSNT_NODEF; + notInd->notDesc.val = 0x71; /* Call information event */ + return FTDM_SUCCESS; +} + void sngisdn_t3_timeout(void *p_sngisdn_info) { sngisdn_chan_data_t *sngisdn_info = (sngisdn_chan_data_t*)p_sngisdn_info;