From 98d566b29c5ebc43834c27c8859d042b69ef94ba Mon Sep 17 00:00:00 2001 From: James Zhang Date: Thu, 26 Jan 2012 16:39:43 -0500 Subject: [PATCH] FreeTDM: adding variable ss7_rel_loc for REL location indicator (to support SPIROU) --- libs/freetdm/mod_freetdm/mod_freetdm.c | 11 +++++++++++ .../ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index e694a0f8fa..1ecf1fe7ef 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -506,6 +506,9 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) int chan_id = 0; const char *name = NULL; + ftdm_usrmsg_t usrmsg; + memset(&usrmsg, 0, sizeof(ftdm_usrmsg_t)); + channel = switch_core_session_get_channel(session); assert(channel != NULL); @@ -574,11 +577,19 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session) case FTDM_CHAN_TYPE_CAS: case FTDM_CHAN_TYPE_B: { + const char *sipvar; ftdm_call_cause_t hcause = switch_channel_get_cause_q850(channel); if (hcause < 1 || hcause > 127) { hcause = FTDM_CAUSE_DESTINATION_OUT_OF_ORDER; } + sipvar = switch_channel_get_variable(channel, "ss7_rel_loc"); + if (sipvar) { + ftdm_usrmsg_add_var(&usrmsg, "ss7_rel_loc", sipvar); + } + /* ftdm_channel_call_hangup_with_cause(tech_pvt->ftdmchan, hcause); + */ + ftdm_channel_call_hangup_with_cause_ex(tech_pvt->ftdmchan, hcause, &usrmsg); } break; default: diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 0c8cf3832a..f73fd871b4 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -259,6 +259,7 @@ void ft_to_sngss7_anm (ftdm_channel_t * ftdmchan) /******************************************************************************/ void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan) { + const char *loc_ind = NULL; SS7_FUNC_TRACE_ENTER (__FUNCTION__); sngss7_chan_data_t *sngss7_info = ftdmchan->call_data; @@ -268,7 +269,15 @@ void ft_to_sngss7_rel (ftdm_channel_t * ftdmchan) rel.causeDgn.eh.pres = PRSNT_NODEF; rel.causeDgn.location.pres = PRSNT_NODEF; - rel.causeDgn.location.val = 0x01; + + loc_ind = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "ss7_rel_loc"); + if (!ftdm_strlen_zero(loc_ind)) { + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "Found user supplied location indicator in REL, value \"%s\"\n", loc_ind); + rel.causeDgn.location.val = atoi(loc_ind); + } else { + rel.causeDgn.location.val = 0x01; + ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, "No user supplied location indicator in REL, using 0x01\"%s\"\n", ""); + } rel.causeDgn.cdeStand.pres = PRSNT_NODEF; rel.causeDgn.cdeStand.val = 0x00; rel.causeDgn.recommend.pres = NOTPRSNT;