[libpri-commits] rmudgett: branch rmudgett/ntptmp r1131 - in /team/rmudgett/ntptmp: pri.c q931.c

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Sep 22 18:18:51 CDT 2009


Author: rmudgett
Date: Tue Sep 22 18:18:47 2009
New Revision: 1131

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1131
Log:
Send NOTIFY on all subcalls that have a positive response.

*  Send NOTIFY on all subcalls that have a positive response.
*  Update subcalls for connected line and redirecting update.
*  Add an error message if attempt to send a message using the BRI PTMP NT
master call record.  The only broadcast message allowed is a SETUP.

Modified:
    team/rmudgett/ntptmp/pri.c
    team/rmudgett/ntptmp/q931.c

Modified: team/rmudgett/ntptmp/pri.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/ntptmp/pri.c?view=diff&rev=1131&r1=1130&r2=1131
==============================================================================
--- team/rmudgett/ntptmp/pri.c (original)
+++ team/rmudgett/ntptmp/pri.c Tue Sep 22 18:18:47 2009
@@ -646,6 +646,8 @@
 int pri_connected_line_update(struct pri *ctrl, q931_call *call, const struct pri_party_connected_line *connected)
 {
 	struct q931_party_id party_id;
+	unsigned idx;
+	struct q931_call *subcall;
 
 	if (!ctrl || !call) {
 		return -1;
@@ -658,6 +660,16 @@
 		return 0;
 	}
 	call->local_id = party_id;
+
+	/* Update all subcalls with new local_id. */
+	if (call->outboundbroadcast && call->master_call == call) {
+		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+			subcall = call->subcalls[idx];
+			if (subcall) {
+				subcall->local_id = party_id;
+			}
+		}
+	}
 
 	switch (call->ourcallstate) {
 	case Q931_CALL_STATE_CALL_INITIATED:
@@ -700,6 +712,9 @@
 
 int pri_redirecting_update(struct pri *ctrl, q931_call *call, const struct pri_party_redirecting *redirecting)
 {
+	unsigned idx;
+	struct q931_call *subcall;
+
 	if (!ctrl || !call) {
 		return -1;
 	}
@@ -708,6 +723,21 @@
 	pri_copy_party_id_to_q931(&call->redirecting.to, &redirecting->to);
 	q931_party_id_fixup(ctrl, &call->redirecting.to);
 	call->redirecting.reason = redirecting->reason;
+
+	/*
+	 * Update all subcalls with new redirecting.to information and reason.
+	 * I do not think we will ever have any subcalls when this data is relevant,
+	 * but update it just in case.
+	 */
+	if (call->outboundbroadcast && call->master_call == call) {
+		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+			subcall = call->subcalls[idx];
+			if (subcall) {
+				subcall->redirecting.to = call->redirecting.to;
+				subcall->redirecting.reason = redirecting->reason;
+			}
+		}
+	}
 
 	switch (call->ourcallstate) {
 	case Q931_CALL_STATE_NULL:

Modified: team/rmudgett/ntptmp/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/ntptmp/q931.c?view=diff&rev=1131&r1=1130&r2=1131
==============================================================================
--- team/rmudgett/ntptmp/q931.c (original)
+++ team/rmudgett/ntptmp/q931.c Tue Sep 22 18:18:47 2009
@@ -3574,6 +3574,13 @@
 	int x;
 	int codeset;
 
+	if (call->outboundbroadcast && call->master_call == call && msgtype != Q931_SETUP) {
+		pri_error(ctrl,
+			"Attempting to use master call record to send %s on BRI PTMP NT %p\n",
+			msg2str(msgtype), ctrl);
+		return -1;
+	}
+
 	memset(buf, 0, sizeof(buf));
 	len = sizeof(buf);
 	init_header(ctrl, call, buf, &h, &mh, &len, (msgtype >> 8));
@@ -3728,7 +3735,8 @@
 static int notify_ies[] = { Q931_IE_NOTIFY_IND, Q931_IE_REDIRECTION_NUMBER, -1 };
 
 /*!
- * \brief Send a NOTIFY message with optional redirection number.
+ * \internal
+ * \brief Actually send a NOTIFY message with optional redirection number.
  *
  * \param ctrl D channel controller.
  * \param call Q.931 call leg
@@ -3738,7 +3746,7 @@
  * \retval 0 on success.
  * \retval -1 on error.
  */
-int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number)
+static int q931_notify_redirection_helper(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number)
 {
 	if (number) {
 		call->redirection_number = *number;
@@ -3749,13 +3757,50 @@
 	return send_message(ctrl, call, Q931_NOTIFY, notify_ies);
 }
 
+/*!
+ * \brief Send a NOTIFY message with optional redirection number.
+ *
+ * \param ctrl D channel controller.
+ * \param call Q.931 call leg
+ * \param notify Notification indicator
+ * \param number Redirection number to send if not NULL.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number)
+{
+	int status;
+	unsigned idx;
+	struct q931_call *subcall;
+
+	if (call->outboundbroadcast && call->master_call == call) {
+		status = 0;
+		for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
+			subcall = call->subcalls[idx];
+			if (subcall) {
+				/* Send to all subcalls that have given a positive response. */
+				switch (subcall->ourcallstate) {
+				case Q931_CALL_STATE_OUTGOING_CALL_PROCEEDING:
+				case Q931_CALL_STATE_CALL_DELIVERED:
+				case Q931_CALL_STATE_ACTIVE:
+					if (q931_notify_redirection_helper(ctrl, subcall, notify, number)) {
+						status = -1;
+					}
+					break;
+				default:
+					break;
+				}
+			}
+		}
+	} else {
+		status = q931_notify_redirection_helper(ctrl, call, notify, number);
+	}
+	return status;
+}
+
 int q931_notify(struct pri *ctrl, q931_call *c, int channel, int info)
 {
-/*
- * BUGBUG Need to send the remote hold/retrieval NOTIFY to all NT PTMP subcalls
- * that have given a positive response.
- * States Outgoing-call-proceeding(U3/N3), Call-delivered(U4/N4), and Active(U10/N10).
- */
 	if ((ctrl->switchtype == PRI_SWITCH_EUROISDN_T1) || (ctrl->switchtype != PRI_SWITCH_EUROISDN_E1)) {
 		if ((info > 0x2) || (info < 0x00)) {
 			return 0;




More information about the libpri-commits mailing list