[libpri-commits] rmudgett: branch 1.4 r1823 - in /branches/1.4: pri_internal.h q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Jun 29 11:15:08 CDT 2010


Author: rmudgett
Date: Tue Jun 29 11:15:03 2010
New Revision: 1823

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1823
Log:
[regression] Calling Number assignment logic change in libpri 1.4.11.

Restored the old behaviour if there is more than one calling number in the
incoming SETUP message.  A network provided number is reported as ANI.

(closes issue #17495)
Reported by: ibercom
Patches:
      issue_17495_v1.4.11.2.patch uploaded by rmudgett (license 664)
      issue_17495_v1.4.patch uploaded by rmudgett (license 664)
Tested by: ibercom

Modified:
    branches/1.4/pri_internal.h
    branches/1.4/q931.c

Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=1823&r1=1822&r2=1823
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Tue Jun 29 11:15:03 2010
@@ -534,6 +534,8 @@
 	 *    (Caller-ID for answered or connected-line for originated calls.)
 	 */
 	struct q931_party_id remote_id;
+	/*! \brief Automatic Number Identification (ANI) */
+	struct q931_party_number ani;
 
 	/*!
 	 * \brief Staging place for the Q.931 redirection number ie.

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=1823&r1=1822&r2=1823
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Tue Jun 29 11:15:03 2010
@@ -2130,26 +2130,41 @@
 static int receive_calling_party_number(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
 {
 	int i = 0;
-
-	call->remote_id.number.valid = 1;
-	call->remote_id.number.presentation =
-		PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
+	struct q931_party_number number;
+
+	q931_party_number_init(&number);
+	number.valid = 1;
+	number.presentation = PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
+
 	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
 	   walking through all bytes until one with ext bit (8) set to 1 */
 	do {
 		switch (i) {
 		case 0:
-			call->remote_id.number.plan = ie->data[i] & 0x7f;
+			number.plan = ie->data[i] & 0x7f;
 			break;
 		case 1:
 			/* Keep only the presentation and screening fields */
-			call->remote_id.number.presentation =
+			number.presentation =
 				ie->data[i] & (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
 			break;
 		}
 	} while (!(ie->data[i++] & 0x80));
-	q931_get_number((unsigned char *) call->remote_id.number.str,
-		sizeof(call->remote_id.number.str), ie->data + i, ie->len - i);
+	q931_get_number((unsigned char *) number.str, sizeof(number.str), ie->data + i,
+		ie->len - i);
+
+	/* There can be more than one calling party number ie in the SETUP message. */
+	if (number.presentation == (PRI_PRES_ALLOWED | PRI_PRES_NETWORK_NUMBER)
+		|| number.presentation == (PRI_PRES_RESTRICTED | PRI_PRES_NETWORK_NUMBER)) {
+		/* The number is network provided so it is an ANI number. */
+		call->ani = number;
+		if (!call->remote_id.number.valid) {
+			/* Copy ANI to CallerID if CallerID is not already set. */
+			call->remote_id.number = number;
+		}
+	} else {
+		call->remote_id.number = number;
+	}
 
 	return 0;
 }
@@ -3707,6 +3722,7 @@
 	q931_party_address_init(&call->called);
 	q931_party_id_init(&call->local_id);
 	q931_party_id_init(&call->remote_id);
+	q931_party_number_init(&call->ani);
 	q931_party_redirecting_init(&call->redirecting);
 
 	/* PRI is set to whoever called us */
@@ -6075,6 +6091,7 @@
 		q931_party_address_init(&c->called);
 		q931_party_id_init(&c->local_id);
 		q931_party_id_init(&c->remote_id);
+		q931_party_number_init(&c->ani);
 		q931_party_redirecting_init(&c->redirecting);
 
 		/*
@@ -6891,11 +6908,9 @@
 	/* Calling party information */
 	ctrl->ev.ring.callingpres = q931_party_id_presentation(&call->remote_id);
 	ctrl->ev.ring.callingplan = call->remote_id.number.plan;
-	if (call->remote_id.number.valid
-		&& (call->remote_id.number.presentation == PRES_ALLOWED_NETWORK_NUMBER
-			|| call->remote_id.number.presentation == PRES_PROHIB_NETWORK_NUMBER)) {
-		ctrl->ev.ring.callingplanani = call->remote_id.number.plan;
-		libpri_copy_string(ctrl->ev.ring.callingani, call->remote_id.number.str,
+	if (call->ani.valid) {
+		ctrl->ev.ring.callingplanani = call->ani.plan;
+		libpri_copy_string(ctrl->ev.ring.callingani, call->ani.str,
 			sizeof(ctrl->ev.ring.callingani));
 	} else {
 		ctrl->ev.ring.callingplanani = -1;




More information about the libpri-commits mailing list