[asterisk-commits] moy: branch moy/dahdi-tap-trunk r229287 - /team/moy/dahdi-tap-trunk/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 10 14:17:28 CST 2009


Author: moy
Date: Tue Nov 10 14:17:24 2009
New Revision: 229287

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=229287
Log:
fixed crv calculation and ignored multiple progress messages

Modified:
    team/moy/dahdi-tap-trunk/channels/sig_pri.c
    team/moy/dahdi-tap-trunk/channels/sig_pri.h

Modified: team/moy/dahdi-tap-trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/moy/dahdi-tap-trunk/channels/sig_pri.c?view=diff&rev=229287&r1=229286&r2=229287
==============================================================================
--- team/moy/dahdi-tap-trunk/channels/sig_pri.c (original)
+++ team/moy/dahdi-tap-trunk/channels/sig_pri.c Tue Nov 10 14:17:24 2009
@@ -1227,8 +1227,18 @@
 	}
 }
 
+static int dahdi_pri_get_crv(struct pri *ctrl, q931_call *call);
+static int dahdi_pri_get_crv(struct pri *ctrl, q931_call *call)
+{
+	int callmode = 0;
+	int crv = pri_get_crv(ctrl, call, &callmode);
+	crv <<= 3;
+	crv |= (callmode & 0x7);
+	return crv;
+}
+
 /* Not thread-safe, we assume nobody else is looking for a tap call slot at the same time in this pri */
-static struct dahdi_tapcall *pri_get_tap_call(struct sig_pri_pri *pri, void *callref)
+static struct dahdi_tapcall *dahdi_pri_get_tap_call(struct sig_pri_pri *pri, void *callref)
 {
 	int i;
 	for (i = 0; i < ARRAY_LEN(pri->tapcalls); i++) {
@@ -1239,12 +1249,12 @@
 	return NULL;
 }
 
-static struct dahdi_tapcall *pri_get_tap_call_by_crv(struct sig_pri_pri *pri, int crv)
+static struct dahdi_tapcall *dahdi_pri_get_tap_call_by_crv(struct sig_pri_pri *pri, int crv)
 {
 	int i;
 	int tstcrv;
 	for (i = 0; i < ARRAY_LEN(pri->tapcalls); i++) {
-		tstcrv = pri->tapcalls[i].callref ? pri_get_crv(pri->pri, pri->tapcalls[i].callref, NULL) : 0;
+		tstcrv = pri->tapcalls[i].callref ? dahdi_pri_get_crv(pri->pri, pri->tapcalls[i].callref) : 0;
 		if (pri->tapcalls[i].callref && tstcrv == crv) {
 			return &pri->tapcalls[i];
 		}
@@ -1252,7 +1262,7 @@
 	return NULL;
 }
 
-static void pri_put_pcall(struct sig_pri_pri *pri, void *callref)
+static void dahdi_pri_put_tap_call(struct sig_pri_pri *pri, void *callref)
 {
 	int i;
 	for (i = 0; i < ARRAY_LEN(pri->tapcalls); i++) {
@@ -1264,7 +1274,7 @@
 
 static void handle_pri_tapping_event(struct sig_pri_pri *pri, pri_event *e)
 {
-	int chanpos, peerpos, law, layer1, transcap;
+	int chanpos, peerpos, law, layer1, transcap, crv;
 	struct dahdi_tapcall *tapcall = NULL;
 	struct sig_pri_chan *masterpvt = NULL;
 	struct sig_pri_chan *peerpvt = NULL;
@@ -1279,10 +1289,16 @@
 	switch (e->e) {
 
 	case PRI_EVENT_RING:
-		ast_log(LOG_DEBUG, "Ring on channel %d of span %d with callref %d\n", e->ring.channel, pri->span, e->ring.cref);
+		crv = dahdi_pri_get_crv(pri->pri, e->ring.call);
+		ast_log(LOG_DEBUG, "Ring on channel %d of span %d with callref %d\n", e->ring.channel, pri->span, crv);
+		tapcall = dahdi_pri_get_tap_call_by_crv(pri, crv);
+		if (tapcall) {
+			ast_log(LOG_WARNING, "There is a call with call reference %d already, ignoring duplicated RING msg\n", crv);
+			break;
+		}
 		/* we cannot use any pri->pvts data structure because we still dont know which channel will be used and therefore cant get
 		 * chanpos (ie, flexible channel was requested), thus, we need our own list of call references */
-		tapcall = pri_get_tap_call(pri, NULL);
+		tapcall = dahdi_pri_get_tap_call(pri, NULL);
 		if (!tapcall) {
 			ast_log(LOG_ERROR, "Failed to get a free PRI tap call slot, this is a bug!\n");
 			break;
@@ -1295,24 +1311,33 @@
 		break;
 
 	case PRI_EVENT_PROGRESS:
-		ast_log(LOG_DEBUG, "Progress on channel %d of span %d\n", e->proceeding.channel, pri->span);
+		crv = dahdi_pri_get_crv(pri->pri, e->proceeding.call);
+		ast_log(LOG_DEBUG, "Progress on channel %d of span %d with call reference %d\n", e->proceeding.channel, pri->span, crv);
 		break;
 
 	case PRI_EVENT_PROCEEDING:
-		ast_log(LOG_DEBUG, "Proceed on channel %d of span %d\n", e->proceeding.channel, pri->span);
+		crv = dahdi_pri_get_crv(pri->pri, e->proceeding.call);
+		ast_log(LOG_DEBUG, "Proceed on channel %d of span %d with call reference %d\n", e->proceeding.channel, pri->span, crv);
 		/* at this point we should know the real b chan that will be used and can therefore proceed to setup the ast channels, but
 		 * only if a couple of call tests are passed */
 
 		/* check that we already know about this call in the peer PRI (which was the one receiving the PRI_EVENT_RING event) */
-		if (!(tapcall = pri_get_tap_call_by_crv(peerpri, pri_get_crv(pri->pri, e->proceeding.call, NULL)))) {
+		if (!(tapcall = dahdi_pri_get_tap_call_by_crv(peerpri, crv))) {
 			ast_log(LOG_ERROR, 
 				"BUG, we got proceeding in channel number %d/%d on span %d for call reference %d "
 				"but we never got PRI_EVENT_RING for that call on peer span %d?\n", 
 				PRI_SPAN(e->proceeding.channel), 
 				PRI_CHANNEL(e->proceeding.channel),
-				pri->span, e->proceeding.cref, peerpri->span);
-			break;
-		}
+				pri->span, crv, peerpri->span);
+			break;
+		}
+
+		if (tapcall->proceeding) {
+			ast_log(LOG_DEBUG, "Ignoring duplicated proceeding with call reference value %d\n", crv);
+			break;
+		}
+		tapcall->proceeding = 1;
+
 		/* check that the layer 1 and trans capability are supported */
 		layer1 = pri_get_layer1(peerpri->pri, tapcall->callref);
 		transcap = pri_get_transcap(peerpri->pri, tapcall->callref);
@@ -1460,9 +1485,6 @@
 					PRI_CHANNEL(e->hangup.channel), pri->span);
 			break;
 		}
-		/* first put back the passive call slot, if any was used, since 
-		 * regardless of whether there is an owner or not, this resource must be freed */
-		pri_put_pcall(pri, e->hangup.call);
 
 		masterpvt = pri->pvts[chanpos];
 		sig_pri_lock_private(masterpvt);
@@ -1503,12 +1525,14 @@
 	case PRI_EVENT_HANGUP_ACK:
 
 		ast_log(LOG_DEBUG, "Hangup ack on channel %d of span %d\n", e->hangup.channel, pri->span);
+
 		/* put back the passive call slot, if any was used */
-		pri_put_pcall(pri, e->hangup.call);
+		dahdi_pri_put_tap_call(pri, e->hangup.call);
+		dahdi_pri_put_tap_call(peerpri, e->hangup.call);
 		break;
 
 	default:
-		ast_log(LOG_NOTICE, "Ignoring passive event %s on span %d\n", pri_event2str(e->gen.e), pri->span);
+		ast_log(LOG_DEBUG, "Ignoring passive event %s on span %d\n", pri_event2str(e->gen.e), pri->span);
 		break;
 	}
 }

Modified: team/moy/dahdi-tap-trunk/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/moy/dahdi-tap-trunk/channels/sig_pri.h?view=diff&rev=229287&r1=229286&r2=229287
==============================================================================
--- team/moy/dahdi-tap-trunk/channels/sig_pri.h (original)
+++ team/moy/dahdi-tap-trunk/channels/sig_pri.h Tue Nov 10 14:17:24 2009
@@ -124,6 +124,7 @@
 	char callingani[AST_MAX_EXTENSION];
 	char callingname[AST_MAX_EXTENSION];
 	char callednum[AST_MAX_EXTENSION];
+	int proceeding:1; /* the call already got proceeding msg */
 };
 
 struct sig_pri_chan {




More information about the asterisk-commits mailing list