From 3cd62df96f78a0ea3255c4fced2e2f32f97c0a42 Mon Sep 17 00:00:00 2001 From: Matteo Brancaleoni Date: Wed, 28 Jan 2015 11:13:37 +0100 Subject: [PATCH] If ANI ton is not interpreted correctly by libpri, fallback to calling ton/type. --- libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c index c8259aa6a2..ea94ce0de0 100644 --- a/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c +++ b/libs/freetdm/src/ftmod/ftmod_libpri/ftmod_libpri.c @@ -1915,8 +1915,16 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event ftdm_set_string(caller_data->dnis.digits, (char *)pevent->ring.callednum); ftdm_set_string(caller_data->rdnis.digits, (char *)pevent->ring.redirectingnum); - caller_data->ani.type = pevent->ring.callingplanani >> 4; - caller_data->ani.plan = pevent->ring.callingplanani & 0x0F; + if (pevent->ring.callingplanani != -1) { + caller_data->ani.type = pevent->ring.callingplanani >> 4; + caller_data->ani.plan = pevent->ring.callingplanani & 0x0F; + } else { + /* the remote party did not sent a valid (according to libpri) ANI ton, + * so let's use the callingplan ton/type and hope is correct. + */ + caller_data->ani.type = pevent->ring.callingplan >> 4; + caller_data->ani.plan = pevent->ring.callingplan & 0x0F; + } caller_data->cid_num.type = pevent->ring.callingplan >> 4; caller_data->cid_num.plan = pevent->ring.callingplan & 0x0F;