[libpri-commits] rmudgett: branch rmudgett/call_waiting r1522 - /team/rmudgett/call_waiting/

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Mar 9 14:00:21 CST 2010


Author: rmudgett
Date: Tue Mar  9 14:00:17 2010
New Revision: 1522

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1522
Log:
Send CONNECT ACKNOWLEDGE to the winning call.

Modified:
    team/rmudgett/call_waiting/q931.c

Modified: team/rmudgett/call_waiting/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/call_waiting/q931.c?view=diff&rev=1522&r1=1521&r2=1522
==============================================================================
--- team/rmudgett/call_waiting/q931.c (original)
+++ team/rmudgett/call_waiting/q931.c Tue Mar  9 14:00:17 2010
@@ -5100,39 +5100,6 @@
 	return res;
 }
 
-static int connect_ack_ies[] = { -1 };
-static int connect_ack_w_chan_id_ies[] = { Q931_CHANNEL_IDENT, -1 };
-static int gr303_connect_ack_ies[] = { Q931_CHANNEL_IDENT, -1 };
-
-int q931_connect_acknowledge(struct pri *ctrl, q931_call *call, int channel)
-{
-	int *use_ies;
-
-	UPDATE_OURCALLSTATE(ctrl, call, Q931_CALL_STATE_ACTIVE);
-	call->peercallstate = Q931_CALL_STATE_ACTIVE;
-	if (channel) {
-		call->ds1no = (channel & 0xff00) >> 8;
-		call->ds1explicit = (channel & 0x10000) >> 16;
-		call->channelno = channel & 0xff;
-		call->chanflags &= ~FLAG_PREFERRED;
-		call->chanflags |= FLAG_EXCLUSIVE;
-	}
-	use_ies = NULL;
-	if (ctrl->subchannel && !ctrl->bri) {
-		if (ctrl->localtype == PRI_CPE) {
-			use_ies = gr303_connect_ack_ies;
-		}
-	} else if (channel) {
-		use_ies = connect_ack_w_chan_id_ies;
-	} else {
-		use_ies = connect_ack_ies;
-	}
-	if (use_ies) {
-		return send_message(ctrl, call, Q931_CONNECT_ACKNOWLEDGE, use_ies);
-	}
-	return 0;
-}
-
 /*!
  * \internal
  * \brief Find the winning subcall if it exists or current call if not outboundbroadcast.
@@ -5157,6 +5124,49 @@
 		}
 	}
 	return call;
+}
+
+static int connect_ack_ies[] = { -1 };
+static int connect_ack_w_chan_id_ies[] = { Q931_CHANNEL_IDENT, -1 };
+static int gr303_connect_ack_ies[] = { Q931_CHANNEL_IDENT, -1 };
+
+int q931_connect_acknowledge(struct pri *ctrl, q931_call *call, int channel)
+{
+	int *use_ies;
+	struct q931_call *winner;
+
+	winner = q931_find_winning_call(call);
+	if (!winner) {
+		return -1;
+	}
+
+	if (winner != call) {
+		UPDATE_OURCALLSTATE(ctrl, call, Q931_CALL_STATE_ACTIVE);
+		call->peercallstate = Q931_CALL_STATE_ACTIVE;
+	}
+	UPDATE_OURCALLSTATE(ctrl, winner, Q931_CALL_STATE_ACTIVE);
+	winner->peercallstate = Q931_CALL_STATE_ACTIVE;
+	if (channel) {
+		winner->ds1no = (channel & 0xff00) >> 8;
+		winner->ds1explicit = (channel & 0x10000) >> 16;
+		winner->channelno = channel & 0xff;
+		winner->chanflags &= ~FLAG_PREFERRED;
+		winner->chanflags |= FLAG_EXCLUSIVE;
+	}
+	use_ies = NULL;
+	if (ctrl->subchannel && !ctrl->bri) {
+		if (ctrl->localtype == PRI_CPE) {
+			use_ies = gr303_connect_ack_ies;
+		}
+	} else if (channel) {
+		use_ies = connect_ack_w_chan_id_ies;
+	} else {
+		use_ies = connect_ack_ies;
+	}
+	if (use_ies) {
+		return send_message(ctrl, winner, Q931_CONNECT_ACKNOWLEDGE, use_ies);
+	}
+	return 0;
 }
 
 /*!




More information about the libpri-commits mailing list