[svn-commits] rmudgett: branch rmudgett/subaddr_xfer r2162 - /team/rmudgett/subaddr_xfer/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 9 20:53:25 CST 2010


Author: rmudgett
Date: Thu Dec  9 20:53:18 2010
New Revision: 2162

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2162
Log:
Check if the subaddress is presentable before sending it.

Modified:
    team/rmudgett/subaddr_xfer/pri.c
    team/rmudgett/subaddr_xfer/pri_facility.c
    team/rmudgett/subaddr_xfer/pri_internal.h
    team/rmudgett/subaddr_xfer/q931.c

Modified: team/rmudgett/subaddr_xfer/pri.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/pri.c?view=diff&rev=2162&r1=2161&r2=2162
==============================================================================
--- team/rmudgett/subaddr_xfer/pri.c (original)
+++ team/rmudgett/subaddr_xfer/pri.c Thu Dec  9 20:53:18 2010
@@ -963,8 +963,8 @@
 
 	new_name = q931_party_name_cmp(&party_id.name, &call->local_id.name);
 	new_number = q931_party_number_cmp(&party_id.number, &call->local_id.number);
-	new_subaddress = party_id.subaddress.valid
-		&& q931_party_subaddress_cmp(&party_id.subaddress, &call->local_id.subaddress);
+	new_subaddress =
+		q931_party_subaddress_cmp(&party_id.subaddress, &call->local_id.subaddress);
 
 	/* Update the call and all subcalls with new local_id. */
 	call->local_id = party_id;
@@ -1002,7 +1002,8 @@
 					q931_notify_redirection(ctrl, call, PRI_NOTIFY_TRANSFER_ACTIVE,
 						&party_id.number);
 				}
-				if (new_subaddress || (party_id.subaddress.valid && new_number)) {
+				if ((new_number || new_subaddress)
+					&& q931_party_id_is_subaddress_presentable(&party_id)) {
 					q931_subaddress_transfer(ctrl, call);
 				}
 			} else if (PTP_MODE(ctrl)) {
@@ -1011,7 +1012,8 @@
 					/* Immediately send EctInform APDU, callStatus=answered(0) */
 					send_call_transfer_complete(ctrl, call, 0);
 				}
-				if (new_subaddress || (party_id.subaddress.valid && new_number)) {
+				if ((new_number || new_subaddress)
+					&& q931_party_id_is_subaddress_presentable(&party_id)) {
 					q931_subaddress_transfer(ctrl, call);
 				}
 			}
@@ -1021,8 +1023,8 @@
 				/* Immediately send CallTransferComplete APDU, callStatus=answered(0) */
 				send_call_transfer_complete(ctrl, call, 0);
 			}
-			if (new_subaddress
-				|| (party_id.subaddress.valid && (new_name || new_number))) {
+			if ((new_name || new_number || new_subaddress)
+				&& q931_party_id_is_subaddress_presentable(&party_id)) {
 				q931_subaddress_transfer(ctrl, call);
 			}
 			break;
@@ -1047,7 +1049,8 @@
 					q931_request_subaddress(ctrl, call, PRI_NOTIFY_TRANSFER_ACTIVE,
 						&party_id.number);
 				}
-				if (new_subaddress || (party_id.subaddress.valid && new_number)) {
+				if ((new_number || new_subaddress)
+					&& q931_party_id_is_subaddress_presentable(&party_id)) {
 					q931_subaddress_transfer(ctrl, call);
 				}
 			} else if (PTP_MODE(ctrl)) {
@@ -1056,7 +1059,8 @@
 					/* Immediately send EctInform APDU, callStatus=answered(0) */
 					send_call_transfer_complete(ctrl, call, 0);
 				}
-				if (new_subaddress || (party_id.subaddress.valid && new_number)) {
+				if ((new_number || new_subaddress)
+					&& q931_party_id_is_subaddress_presentable(&party_id)) {
 					q931_subaddress_transfer(ctrl, call);
 				}
 			}
@@ -1066,8 +1070,8 @@
 				/* Immediately send CallTransferComplete APDU, callStatus=answered(0) */
 				send_call_transfer_complete(ctrl, call, 0);
 			}
-			if (new_subaddress
-				|| (party_id.subaddress.valid && (new_name || new_number))) {
+			if ((new_name || new_number || new_subaddress)
+				&& q931_party_id_is_subaddress_presentable(&party_id)) {
 				q931_subaddress_transfer(ctrl, call);
 			}
 			break;

Modified: team/rmudgett/subaddr_xfer/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/pri_facility.c?view=diff&rev=2162&r1=2161&r2=2162
==============================================================================
--- team/rmudgett/subaddr_xfer/pri_facility.c (original)
+++ team/rmudgett/subaddr_xfer/pri_facility.c Thu Dec  9 20:53:18 2010
@@ -3607,8 +3607,8 @@
 		break;
 	}
 
-	/* Send our subaddress back if we have one. */
-	if (call->local_id.subaddress.valid) {
+	/* Send our subaddress back if we can. */
+	if (q931_party_id_is_subaddress_presentable(&call->local_id)) {
 		send_subaddress_transfer(ctrl, call);
 	}
 }
@@ -4703,8 +4703,8 @@
 			call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
 		}
 
-		/* Send our subaddress back if we have one. */
-		if (call->local_id.subaddress.valid) {
+		/* Send our subaddress back if we can. */
+		if (q931_party_id_is_subaddress_presentable(&call->local_id)) {
 			send_subaddress_transfer(ctrl, call);
 		}
 		break;
@@ -5131,8 +5131,8 @@
 			call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
 		}
 
-		/* Send our subaddress back if we have one. */
-		if (call->local_id.subaddress.valid) {
+		/* Send our subaddress back if we can. */
+		if (q931_party_id_is_subaddress_presentable(&call->local_id)) {
 			send_subaddress_transfer(ctrl, call);
 		}
 		break;

Modified: team/rmudgett/subaddr_xfer/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/pri_internal.h?view=diff&rev=2162&r1=2161&r2=2162
==============================================================================
--- team/rmudgett/subaddr_xfer/pri_internal.h (original)
+++ team/rmudgett/subaddr_xfer/pri_internal.h Thu Dec  9 20:53:18 2010
@@ -938,6 +938,7 @@
 void pri_copy_party_id_to_q931(struct q931_party_id *q931_id, const struct pri_party_id *pri_id);
 
 void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id);
+int q931_party_id_is_subaddress_presentable(const struct q931_party_id *id);
 int q931_party_id_presentation(const struct q931_party_id *id);
 
 const char *q931_call_state_str(enum Q931_CALL_STATE callstate);

Modified: team/rmudgett/subaddr_xfer/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/q931.c?view=diff&rev=2162&r1=2161&r2=2162
==============================================================================
--- team/rmudgett/subaddr_xfer/q931.c (original)
+++ team/rmudgett/subaddr_xfer/q931.c Thu Dec  9 20:53:18 2010
@@ -861,6 +861,34 @@
 	default:
 		break;
 	}
+}
+
+/*!
+ * \brief Determine if the subaddress in the party id is presentable.
+ *
+ * \param id Party ID to check.
+ *
+ * \retval TRUE if the subaddress is presentable.
+ * \retval FALSE if the subaddress is not presentable.
+ */
+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;
 }
 
 /*!




More information about the svn-commits mailing list