[libpri-commits] rmudgett: branch rmudgett/subaddr_xfer r2163 - /team/rmudgett/subaddr_xfer/

SVN commits to the libpri project libpri-commits at lists.digium.com
Thu Dec 9 21:20:18 CST 2010


Author: rmudgett
Date: Thu Dec  9 21:20:14 2010
New Revision: 2163

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2163
Log:
Suppress subaddress ies if the subaddress is not presentable.

Modified:
    team/rmudgett/subaddr_xfer/q931.c

Modified: team/rmudgett/subaddr_xfer/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/q931.c?view=diff&rev=2163&r1=2162&r2=2163
==============================================================================
--- team/rmudgett/subaddr_xfer/q931.c (original)
+++ team/rmudgett/subaddr_xfer/q931.c Thu Dec  9 21:20:14 2010
@@ -864,6 +864,50 @@
 }
 
 /*!
+ * \internal
+ * \brief Determine if the subaddress is presentable.
+ *
+ * \param number Party number associated with subaddress.
+ * \param subaddr Subaddress to determine if presentable.
+ *
+ * \retval TRUE if the subaddress is presentable.
+ * \retval FALSE if the subaddress is not presentable.
+ */
+static int is_number_subaddress_presentable(const struct q931_party_number *number, const struct q931_party_subaddress *subaddr)
+{
+	/* If unsure about the presentation, we will restrict it. */
+	if (!subaddr->valid) {
+		return 0;
+	}
+	if (!number->valid) {
+		return 0;
+	}
+	switch (number->presentation & PRI_PRES_RESTRICTION) {
+	case PRI_PRES_ALLOWED:
+	case PRI_PRES_UNAVAILABLE:
+		break;
+	default:
+	case PRI_PRES_RESTRICTED:
+		return 0;
+	}
+	return 1;
+}
+
+/*!
+ * \internal
+ * \brief Determine if the subaddress in the party address is presentable.
+ *
+ * \param addr Party address to check.
+ *
+ * \retval TRUE if the subaddress is presentable.
+ * \retval FALSE if the subaddress is not presentable.
+ */
+static int q931_party_address_is_subaddress_presentable(const struct q931_party_address *addr)
+{
+	return is_number_subaddress_presentable(&addr->number, &addr->subaddress);
+}
+
+/*!
  * \brief Determine if the subaddress in the party id is presentable.
  *
  * \param id Party ID to check.
@@ -873,22 +917,7 @@
  */
 int q931_party_id_is_subaddress_presentable(const struct q931_party_id *id)
 {
-	/* If unsure about the presentation, we will restrict it. */
-	if (!id->subaddress.valid) {
-		return 0;
-	}
-	if (!id->number.valid) {
-		return 0;
-	}
-	switch (id->number.presentation & PRI_PRES_RESTRICTION) {
-	case PRI_PRES_ALLOWED:
-	case PRI_PRES_UNAVAILABLE:
-		break;
-	default:
-	case PRI_PRES_RESTRICTED:
-		return 0;
-	}
-	return 1;
+	return is_number_subaddress_presentable(&id->number, &id->subaddress);
 }
 
 /*!
@@ -2081,6 +2110,9 @@
 
 static int transmit_connected_subaddr(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
 {
+	if (!q931_party_id_is_subaddress_presentable(&call->local_id)) {
+		return 0;
+	}
 	return transmit_subaddr_helper(full_ie, ctrl, &call->local_id.subaddress, msgtype, ie,
 		1, len, order);
 }
@@ -2204,6 +2236,9 @@
 
 static int transmit_calling_party_subaddr(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
 {
+	if (!q931_party_id_is_subaddress_presentable(&call->local_id)) {
+		return 0;
+	}
 	return transmit_subaddr_helper(full_ie, ctrl, &call->local_id.subaddress, msgtype, ie,
 		1, len, order);
 }
@@ -2219,6 +2254,9 @@
 
 static int transmit_called_party_subaddr(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
 {
+	if (!q931_party_address_is_subaddress_presentable(&call->called)) {
+		return 0;
+	}
 	return transmit_subaddr_helper(full_ie, ctrl, &call->called.subaddress, msgtype, ie,
 		1, len, order);
 }




More information about the libpri-commits mailing list