[asterisk-commits] jpeeler: branch dhubbard/pinecowbell r186501 - /team/dhubbard/pinecowbell/cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 3 15:31:13 CDT 2009


Author: jpeeler
Date: Fri Apr  3 15:30:54 2009
New Revision: 186501

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=186501
Log:
This I believe fixes the channel mappings for NFAS.

The problem was that the channel number being sent to libpri was incorrectly 
calculated based on the physical span instead of its mapping. The channel
number must be offset by the number of b-chans already present in the same
trunkgroup. For clarity, the channel listing in astdb now contains the physical
span in addition to the channel number.

Modified:
    team/dhubbard/pinecowbell/channels/chan_dahdi.c

Modified: team/dhubbard/pinecowbell/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/dhubbard/pinecowbell/channels/chan_dahdi.c?view=diff&rev=186501&r1=186500&r2=186501
==============================================================================
--- team/dhubbard/pinecowbell/channels/chan_dahdi.c (original)
+++ team/dhubbard/pinecowbell/channels/chan_dahdi.c Fri Apr  3 15:30:54 2009
@@ -2988,7 +2988,7 @@
 			char db_chan_name[20], db_answer[5], state;
 			int why = -1;
 
-			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, x);
+			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, pl->span, x);
 			if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
 				sscanf(db_answer, "%c:%d", &state, &why);
 			}
@@ -8783,7 +8783,6 @@
 							}
 						}
 					}
-					offset = p.chanpos;
 					if (!matchesdchan) {
 						if (pris[span].nodetype && (pris[span].nodetype != conf->pri.nodetype)) {
 							ast_log(LOG_ERROR, "Span %d is already a %s node\n", span + 1, pri_node2str(pris[span].nodetype));
@@ -8856,7 +8855,11 @@
 						pris[span].resetinterval = conf->pri.resetinterval;
 						
 						tmp->pri = &pris[span];
-						tmp->prioffset = offset;
+						if (si.spanno != span + 1) { /* in another trunkgroup */
+							tmp->prioffset = pris[span].numchans;
+						} else {
+							tmp->prioffset = p.chanpos;
+						}
 						tmp->call = NULL;
 					} else {
 						ast_log(LOG_ERROR, "Channel %d is reserved for D-channel.\n", offset);
@@ -9121,7 +9124,7 @@
 				if (chan_sig == SIG_PRI) {
 					char db_chan_name[20], db_answer[5];
 
-					snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, tmp->channel);
+					snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, tmp->span, tmp->channel);
 					if (ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
 						snprintf(db_answer, sizeof(db_answer), "%s:%d", SRVST_TYPE_OOS, SRVST_INITIALIZED);
 						ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
@@ -9222,7 +9225,7 @@
 			char db_chan_name[20], db_answer[5], state;
 			int why = 0;
 						
-			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, p->channel);
+			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, p->span, p->channel);
 			if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
 				sscanf(db_answer, "%c:%d", &state, &why);
 			}
@@ -10704,7 +10707,7 @@
 
 		/* check if the channel is out of service */
 		ast_mutex_lock(&pri->pvts[pri->resetpos]->lock);
-		snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, pri->pvts[pri->resetpos]->channel);
+		snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, pri->pvts[pri->resetpos]->span, pri->pvts[pri->resetpos]->channel);
 		ast_mutex_unlock(&pri->pvts[pri->resetpos]->lock);
 
 		/* if so, try next channel */
@@ -11089,7 +11092,7 @@
 						int why, skipit = 0;
 						
 						ast_mutex_lock(&pri->pvts[chanpos]->lock);
-						snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, pri->pvts[chanpos]->channel);
+						snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, pri->pvts[chanpos]->span, pri->pvts[chanpos]->channel);
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 
 						if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
@@ -11207,7 +11210,7 @@
 					ch = pri->pvts[chanpos]->channel;
 					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					
-					snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, ch);
+					snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, pri->pvts[chanpos]->span, ch);
 					if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
 						sscanf(db_answer, "%c:%d", &state, &why);
 						ast_db_del(db_chan_name, SRVST_DBKEY);
@@ -12261,7 +12264,7 @@
 				return CLI_SUCCESS;
 			}
 			why = -1;
-			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d", dahdi_db, channel);
+			snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, tmp->span, channel);
 			if (!ast_db_get(db_chan_name, SRVST_DBKEY, db_answer, sizeof(db_answer))) {
 				sscanf(db_answer, "%c:%d", &state, &why);
 				ast_db_del(db_chan_name, SRVST_DBKEY);




More information about the asterisk-commits mailing list