[libpri-commits] rmudgett: branch group/ccss r1346 - /team/group/ccss/

SVN commits to the libpri project libpri-commits at lists.digium.com
Fri Nov 20 17:47:05 CST 2009


Author: rmudgett
Date: Fri Nov 20 17:47:03 2009
New Revision: 1346

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1346
Log:
Merged revisions 1345 via svnmerge from 
https://origsvn.digium.com/svn/libpri/branches/1.4

........
  r1345 | rmudgett | 2009-11-20 17:42:40 -0600 (Fri, 20 Nov 2009) | 14 lines
  
  Delay processing of facility ie's after all other ie's are processed.
  
  *  Some ROSE message processing depends on the presence of other ies.  The
  DivertingLegInformation1, and 3 messages will be used as the default
  connected line number if the connected number ie is not present.  The
  redirecting number ie is used as a default to the redirecting number in
  the DivertingLegInformation2 message if the ROSE message does not contain
  it and the redirecting number ie is present.
  
  *  Some ROSE message processing depends upon other ie values.  The
  StatusRequest, CCBS-T-Call, and CcRingout messages collectively need the
  BC, HLC, LLC, called number, called subaddress, calling number, and
  calling subaddress ie information to be available.
........

Modified:
    team/group/ccss/   (props changed)
    team/group/ccss/pri_facility.c
    team/group/ccss/pri_internal.h
    team/group/ccss/q931.c

Propchange: team/group/ccss/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Nov 20 17:47:03 2009
@@ -1,1 +1,1 @@
-/branches/1.4:1-1331
+/branches/1.4:1-1345

Modified: team/group/ccss/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri_facility.c?view=diff&rev=1346&r1=1345&r2=1346
==============================================================================
--- team/group/ccss/pri_facility.c (original)
+++ team/group/ccss/pri_facility.c Fri Nov 20 17:47:03 2009
@@ -3536,27 +3536,31 @@
 		break;
 #endif	/* Not handled yet */
 	case ROSE_ETSI_DivertingLegInformation1:
-		/*
-		 * Unless otherwise indicated by CONNECT, the divertedToNumber will be
-		 * the remote_id.number.
-		 *
-		 * Fortunately, the connected number ie is supposed to come after the
-		 * facility ie in the same message so it will be processed later.
-		 */
 		if (invoke->args.etsi.DivertingLegInformation1.diverted_to_present) {
-			rose_copy_presented_number_unscreened_to_q931(ctrl, &call->remote_id.number,
+			rose_copy_presented_number_unscreened_to_q931(ctrl, &party_id.number,
 				&invoke->args.etsi.DivertingLegInformation1.diverted_to);
 			/*
 			 * We set the presentation value since the sender cannot know the
 			 * presentation value preference of the destination party.
 			 */
-			if (call->remote_id.number.str[0]) {
-				call->remote_id.number.presentation =
+			if (party_id.number.str[0]) {
+				party_id.number.presentation =
 					PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
+			} else {
+				party_id.number.presentation =
+					PRI_PRES_UNAVAILABLE | PRI_PRES_USER_NUMBER_UNSCREENED;
 			}
 		} else {
-			q931_party_number_init(&call->remote_id.number);
-			call->remote_id.number.valid = 1;
+			q931_party_number_init(&party_id.number);
+			party_id.number.valid = 1;
+		}
+
+		/*
+		 * Unless otherwise indicated by CONNECT, the divertedToNumber will be
+		 * the remote_id.number.
+		 */
+		if (!call->connected_number_in_message) {
+			call->remote_id.number = party_id.number;
 		}
 
 		/* divertedToNumber is put in redirecting.to.number */
@@ -3570,7 +3574,7 @@
 				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
 			break;
 		case 2:	/* notificationWithDivertedToNr */
-			call->redirecting.to.number = call->remote_id.number;
+			call->redirecting.to.number = party_id.number;
 			break;
 		}
 
@@ -3597,7 +3601,7 @@
 			rose_copy_presented_number_unscreened_to_q931(ctrl,
 				&call->redirecting.from.number,
 				&invoke->args.etsi.DivertingLegInformation2.diverting);
-		} else {
+		} else if (!call->redirecting_number_in_message) {
 			q931_party_number_init(&call->redirecting.from.number);
 			call->redirecting.from.number.valid = 1;
 		}
@@ -3617,15 +3621,14 @@
 		/*
 		 * Unless otherwise indicated by CONNECT, this will be the
 		 * remote_id.number.presentation.
-		 *
-		 * Fortunately, the connected number ie is supposed to come after the
-		 * facility ie in the same message so it will be processed later.
 		 */
 		if (!invoke->args.etsi.DivertingLegInformation3.presentation_allowed_indicator) {
-			call->remote_id.number.presentation =
-				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
 			call->redirecting.to.number.presentation =
 				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
+			if (!call->connected_number_in_message) {
+				call->remote_id.number.presentation =
+					PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
+			}
 		}
 
 		switch (call->redirecting.state) {
@@ -4101,19 +4104,20 @@
 			&deflection);
 		break;
 	case ROSE_QSIG_DivertingLegInformation1:
+		q931_party_number_init(&party_id.number);
+		rose_copy_number_to_q931(ctrl, &party_id.number,
+			&invoke->args.qsig.DivertingLegInformation1.nominated_number);
+		if (party_id.number.str[0]) {
+			party_id.number.presentation =
+				PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
+		}
+
 		/*
 		 * Unless otherwise indicated by CONNECT, the nominatedNr will be
 		 * the remote_id.number.
-		 *
-		 * Fortunately, the connected number ie is supposed to come after the
-		 * facility ie in the same message so it will be processed later.
 		 */
-		q931_party_number_init(&call->remote_id.number);
-		rose_copy_number_to_q931(ctrl, &call->remote_id.number,
-			&invoke->args.qsig.DivertingLegInformation1.nominated_number);
-		if (call->remote_id.number.str[0]) {
-			call->remote_id.number.presentation =
-				PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
+		if (!call->connected_number_in_message) {
+			call->remote_id.number = party_id.number;
 		}
 
 		/* nominatedNr is put in redirecting.to.number */
@@ -4127,7 +4131,7 @@
 				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
 			break;
 		case QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR:
-			call->redirecting.to.number = call->remote_id.number;
+			call->redirecting.to.number = party_id.number;
 			break;
 		}
 
@@ -4154,7 +4158,7 @@
 			rose_copy_presented_number_unscreened_to_q931(ctrl,
 				&call->redirecting.from.number,
 				&invoke->args.qsig.DivertingLegInformation2.diverting);
-		} else {
+		} else if (!call->redirecting_number_in_message) {
 			q931_party_number_init(&call->redirecting.from.number);
 			call->redirecting.from.number.valid = 1;
 		}
@@ -4194,15 +4198,14 @@
 		/*
 		 * Unless otherwise indicated by CONNECT, this will be the
 		 * remote_id.number.presentation.
-		 *
-		 * Fortunately, the connected number ie is supposed to come after the
-		 * facility ie in the same message so it will be processed later.
 		 */
 		if (!invoke->args.qsig.DivertingLegInformation3.presentation_allowed_indicator) {
-			call->remote_id.number.presentation =
-				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
 			call->redirecting.to.number.presentation =
 				PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
+			if (!call->connected_number_in_message) {
+				call->remote_id.number.presentation =
+					PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED;
+			}
 		}
 
 		/* redirectionName is put in redirecting.to.name */

Modified: team/group/ccss/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/pri_internal.h?view=diff&rev=1346&r1=1345&r2=1346
==============================================================================
--- team/group/ccss/pri_internal.h (original)
+++ team/group/ccss/pri_internal.h Fri Nov 20 17:47:03 2009
@@ -59,6 +59,9 @@
 
 /*! Maximum number of scheduled events active at the same time. */
 #define MAX_SCHED	(128 + 256) /* 256 CC supervision timer events */
+
+/*! Maximum number of facility ie's to handle per incoming message. */
+#define MAX_FACILITY_IES	8
 
 /*! \brief D channel controller structure */
 struct pri {
@@ -179,6 +182,16 @@
 #endif	/* defined(QSIG_PATH_RESERVATION_SUPPORT) */
 		} option;
 	} cc;
+
+	/*! For delayed processing of facility ie's. */
+	struct {
+		/*! Array of facility ie locations in the current received message. */
+		q931_ie *ie[MAX_FACILITY_IES];
+		/*! Codeset facility ie found within. */
+		unsigned char codeset[MAX_FACILITY_IES];
+		/*! Number of facility ie's in the array from the current received message. */
+		unsigned char count;
+	} facility;
 };
 
 /*! \brief Maximum name length plus null terminator (From ECMA-164) */
@@ -505,6 +518,10 @@
 	int hold_timer;
 
 	int deflection_in_progress;	/*!< CallDeflection for NT PTMP in progress. */
+	/*! TRUE if the connected number ie was in the current received message. */
+	int connected_number_in_message;
+	/*! TRUE if the redirecting number ie was in the current received message. */
+	int redirecting_number_in_message;
 
 	int useruserprotocoldisc;
 	char useruserinfo[256];

Modified: team/group/ccss/q931.c
URL: http://svnview.digium.com/svn/libpri/team/group/ccss/q931.c?view=diff&rev=1346&r1=1345&r2=1346
==============================================================================
--- team/group/ccss/q931.c (original)
+++ team/group/ccss/q931.c Fri Nov 20 17:47:03 2009
@@ -1834,6 +1834,7 @@
 {
 	int i = 0;
 
+	call->connected_number_in_message = 1;
 	call->remote_id.number.valid = 1;
 	call->remote_id.number.presentation =
 		PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
@@ -1918,6 +1919,7 @@
 {
 	int i = 0;
 
+	call->redirecting_number_in_message = 1;
 	call->redirecting.from.number.valid = 1;
 	call->redirecting.from.number.presentation =
 		PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
@@ -2438,6 +2440,25 @@
 
 static int receive_facility(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len)
 {
+	/* Delay processing facility ie's till after all other ie's are processed. */
+	if (MAX_FACILITY_IES <= ctrl->facility.count) {
+		pri_message(ctrl, "!! Too many facility ie's to delay.\n");
+		return -1;
+	}
+	/* Make sure we have enough room for the protocol profile ie octet(s) */
+	if (ie->data + ie->len < ie->data + 2) {
+		return -1;
+	}
+
+	/* Save the facility ie location for delayed decode. */
+	ctrl->facility.ie[ctrl->facility.count] = ie;
+	ctrl->facility.codeset[ctrl->facility.count] = Q931_IE_CODESET((unsigned) full_ie);
+	++ctrl->facility.count;
+	return 0;
+}
+
+static int process_facility(struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie)
+{
 	struct fac_extension_header header;
 	struct rose_message rose;
 	const unsigned char *pos;
@@ -2508,6 +2529,24 @@
 		return -1;
 	}
 	return 0;
+}
+
+static void q931_handle_facilities(struct pri *ctrl, q931_call *call, int msgtype)
+{
+	unsigned idx;
+	unsigned codeset;
+	unsigned full_ie;
+	q931_ie *ie;
+
+	for (idx = 0; idx < ctrl->facility.count; ++idx) {
+		ie = ctrl->facility.ie[idx];
+		if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
+			codeset = ctrl->facility.codeset[idx];
+			full_ie = Q931_FULL_IE(codeset, ie->ie);
+			pri_message(ctrl, "-- Delayed processing IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
+		}
+		process_facility(ctrl, call, msgtype, ie);
+	}
 }
 
 static int transmit_progress_indicator(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
@@ -5981,6 +6020,9 @@
 	}
 
 	/* Preliminary handling */
+	ctrl->facility.count = 0;
+	c->connected_number_in_message = 0;
+	c->redirecting_number_in_message = 0;
 	if ((h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_1) || (h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_2)) {
 		prepare_to_handle_maintenance_message(ctrl, mh, c);
 	} else {
@@ -6074,6 +6116,9 @@
 			}
 		}
 	}
+
+	/* Now handle the facility ie's after all the other ie's were processed. */
+	q931_handle_facilities(ctrl, c, mh->msg);
 
 	/* Post handling */
 	if ((h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_1) || (h->pd == MAINTENANCE_PROTOCOL_DISCRIMINATOR_2)) {




More information about the libpri-commits mailing list