From 5c747b699cfe3b2e19a3dc66a815cf7bfc9574a0 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 25 Nov 2010 18:54:15 -0500 Subject: [PATCH] Fix for receiving/transmitting facility IE --- .../ftmod_sangoma_isdn_stack_hndl.c | 23 ++++++++++--------- .../ftmod_sangoma_isdn_stack_out.c | 2 -- .../ftmod_sangoma_isdn_support.c | 4 +++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c index f10fa766e3..f3fc23e317 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c @@ -142,21 +142,22 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdmchan->caller_data.bearer_capability = sngisdn_get_infoTranCap_from_stack(conEvnt->bearCap[0].infoTranCap.val); } - if (signal_data->switchtype == SNGISDN_SWITCH_NI2) { - if (conEvnt->shift11.eh.pres && conEvnt->ni2OctStr.eh.pres) { - if (conEvnt->ni2OctStr.str.len == 4 && conEvnt->ni2OctStr.str.val[0] == 0x37) { - snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); - } + + if (conEvnt->shift11.eh.pres && conEvnt->ni2OctStr.eh.pres) { + if (conEvnt->ni2OctStr.str.len == 4 && conEvnt->ni2OctStr.str.val[0] == 0x37) { + snprintf(ftdmchan->caller_data.aniII, 5, "%.2d", conEvnt->ni2OctStr.str.val[3]); } + } - if (conEvnt->facilityStr.eh.pres) { - if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { - get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); - } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + if (conEvnt->facilityStr.eh.pres) { + if (signal_data->facility_ie_decode == SNGISDN_OPT_FALSE) { + get_facility_ie(&ftdmchan->caller_data, conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len); + } else if (signal_data->facility == SNGISDN_OPT_TRUE) { + if (signal_data->switchtype == SNGISDN_SWITCH_NI2) { /* Verify whether the Caller Name will come in a subsequent FACILITY message */ uint16_t ret_val; char retrieved_str[255]; - + ret_val = sng_isdn_retrieve_facility_caller_name(conEvnt->facilityStr.facilityStr.val, conEvnt->facilityStr.facilityStr.len, retrieved_str); /* return values for "sng_isdn_retrieve_facility_information_following": @@ -170,7 +171,7 @@ void sngisdn_process_con_ind (sngisdn_event_data_t *sngisdn_event) ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_GET_CALLERID); /* Launch timer in case we never get a FACILITY msg */ if (signal_data->facility_timeout) { - ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, + ftdm_sched_timer(signal_data->sched, "facility_timeout", signal_data->facility_timeout, sngisdn_facility_timeout, (void*) sngisdn_info, &sngisdn_info->timers[SNGISDN_TIMER_FACILITY]); } break; 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 36c6782a97..1b906a2004 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 @@ -412,7 +412,6 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan) memset(&cnStEvnt, 0, sizeof(cnStEvnt)); - cnStEvnt.chanId.eh.pres = PRSNT_NODEF; cnStEvnt.chanId.prefExc.pres = PRSNT_NODEF; cnStEvnt.chanId.prefExc.val = IN_PE_EXCLSVE; @@ -557,7 +556,6 @@ void sngisdn_snd_disconnect(ftdm_channel_t *ftdmchan) discEvnt.causeDgn[0].dgnVal.pres = NOTPRSNT; set_facility_ie(ftdmchan, &discEvnt.facilityStr); - ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending DISCONNECT (suId:%d suInstId:%u spInstId:%u)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId); if (sng_isdn_disc_request(signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, &discEvnt)) { 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 c9aa3f035c..241bb43a90 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 @@ -412,14 +412,16 @@ ftdm_status_t set_calling_name(ConEvnt *conEvnt, ftdm_channel_t *ftdmchan) } ftdm_status_t set_facility_ie(ftdm_channel_t *ftdmchan, FacilityStr *facilityStr) -{ +{ if (ftdmchan->caller_data.raw_data_len && ftdmchan->caller_data.raw_data[0] == 0x1C) { facilityStr->eh.pres = PRSNT_NODEF; + facilityStr->facilityStr.pres = PRSNT_NODEF; facilityStr->facilityStr.len = ftdmchan->caller_data.raw_data_len-2; memcpy(facilityStr->facilityStr.val, &ftdmchan->caller_data.raw_data[2], facilityStr->facilityStr.len); return FTDM_SUCCESS; } + return FTDM_FAIL; }