[svn-commits] qwell: branch 1.2 r2422 - /branches/1.2/zaptel-base.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Apr 13 16:12:23 MST 2007


Author: qwell
Date: Fri Apr 13 18:12:23 2007
New Revision: 2422

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2422
Log:
Fix several places where we treat confmode as a bitmask.
It is a bitmask...sort of..  I'll explain..

confmode is used for 2 different things.
It defines both the "mode" and the "flags" of the conference.

The "mode" part is in 0x00FF and is NOT bitwise.
The "flag" part is in 0xFF00 and *IS* bitwise.
Confused yet?  Good.

So, when we want to check the "mode" of the conference, we need to check only within 0xFF.
There were several places where this was not happening - but due to luck, it worked (...sort of).
That's what this patch fixes.

Modified:
    branches/1.2/zaptel-base.c

Modified: branches/1.2/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel-base.c?view=diff&rev=2422&r1=2421&r2=2422
==============================================================================
--- branches/1.2/zaptel-base.c (original)
+++ branches/1.2/zaptel-base.c Fri Apr 13 18:12:23 2007
@@ -694,7 +694,12 @@
 	if (!confalias[x])
 		return;
 	for (y=0;y<maxchans;y++) {
-		if (chans[y] && (chans[y]->confna == x) && (chans[y]->confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO)))
+		if (chans[y] && (chans[y]->confna == x) &&
+			((chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONF ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANN ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFMON ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANNMON ||
+			(chans[y]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_REALANDPSEUDO))
 			return;
 	}
 	/* If we get here, nobody is in the conference anymore.  Clear it out
@@ -1645,9 +1650,10 @@
 				chans[x]->master = chans[x];
 			}
 			if ((chans[x]->confna == chan->channo) &&
-				(((chans[x]->confmode >= ZT_CONF_MONITOR) &&
-				(chans[x]->confmode <= ZT_CONF_MONITORBOTH)) ||
-				(chans[x]->confmode == ZT_CONF_DIGITALMON))) {
+				((chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR ||
+				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX ||
+				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH ||
+				(chans[x]->confmode & ZT_CONF_MODE_MASK) == ZT_CONF_DIGITALMON)) {
 				/* Take them out of conference with us */
 				/* release conference resource if any */
 				if (chans[x]->confna) {
@@ -3795,7 +3801,9 @@
 		  /* make sure channel number makes sense */
 		if ((i < 1) || (i > ZT_MAX_CHANNELS) || (!chans[i])) return(-EINVAL);
 		if (!(chans[i]->flags & ZT_FLAG_AUDIO)) return (-EINVAL); 
-		if (stack.conf.confmode && ((stack.conf.confmode & ZT_CONF_MODE_MASK) < 4)) {
+		if ((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITOR ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORTX ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_MONITORBOTH) {
 			/* Monitor mode -- it's a channel */
 			if ((stack.conf.confno < 0) || (stack.conf.confno >= ZT_MAX_CHANNELS) || !chans[stack.conf.confno]) return(-EINVAL);
 		} else {
@@ -3831,17 +3839,20 @@
 		zt_check_conf(j);
 		zt_check_conf(stack.conf.confno);
 		if (chans[i]->span && chans[i]->span->dacs) {
-			if ((stack.conf.confmode == ZT_CONF_DIGITALMON) && chans[stack.conf.confno]->span &&
+			if (((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_DIGITALMON) && chans[stack.conf.confno]->span &&
 					(chans[stack.conf.confno]->span->dacs == chans[i]->span->dacs)) {
 				chans[i]->span->dacs(chans[i], chans[stack.conf.confno]);
 			} else {
 				chans[i]->span->dacs(chans[i], NULL);
 			}
 		}
-		/* k will be non-zero if in a real conf */
-		k = stack.conf.confmode & (ZT_CONF_CONF | ZT_CONF_CONFANN | ZT_CONF_CONFMON | ZT_CONF_CONFANNMON | ZT_CONF_REALANDPSEUDO);
 		/* if we are going onto a conf */
-		if (stack.conf.confno && k) {
+		if (stack.conf.confno &&
+			((stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONF ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANN ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFMON ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_CONFANNMON ||
+			(stack.conf.confmode & ZT_CONF_MODE_MASK) == ZT_CONF_REALANDPSEUDO)) {
 			/* Get alias */
 			chans[i]->_confn = zt_get_conf_alias(stack.conf.confno);
 		}



More information about the svn-commits mailing list