[asterisk-commits] tilghman: trunk r334574 - in /trunk: ./ configs/ contrib/realtime/mysql/ cont...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 6 19:54:42 CDT 2011


Author: tilghman
Date: Tue Sep  6 19:54:36 2011
New Revision: 334574

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334574
Log:
Implement the '!' negation element to negate codecs directly in the allow keyword.

This permits the list of codecs to be specified in one configuration line,
instead of two or more, generally with the aim of either allowing all codecs
with the exception of a few or disallowing most but permitting a few.

Review: https://reviewboard.asterisk.org/r/1411/

Modified:
    trunk/CHANGES
    trunk/configs/sip.conf.sample
    trunk/contrib/realtime/mysql/iaxfriends.sql
    trunk/contrib/realtime/mysql/sipfriends.sql
    trunk/contrib/realtime/postgresql/realtime.sql
    trunk/main/frame.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Tue Sep  6 19:54:36 2011
@@ -23,6 +23,13 @@
 ------------------
  * Added a manager event "LocalBridge" for local channel call bridges between
    the two pseudo-channels created.
+
+Codec changes
+-------------
+ * Codec lists may now be modified by the '!' character, to allow succinct
+   specification of a list of codecs allowed and disallowed, without the
+   requirement to use two different keywords.  For example, to specify all
+   codecs except g729 and g723, one need only specify allow=all,!g729,!g723.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Tue Sep  6 19:54:36 2011
@@ -1216,10 +1216,14 @@
         allow=gsm
         allow=g723
         allow=ulaw
+        ; Or, more simply:
+        ;allow=!all,ilbc,g729,gsm,g723,ulaw
 
 [ulaw-phone](!)                   ; and another one for ulaw-only
         disallow=all
         allow=ulaw
+        ; Again, more simply:
+        ;allow=!all,ulaw
 
 ; and finally instantiate a few phones
 ;

Modified: trunk/contrib/realtime/mysql/iaxfriends.sql
URL: http://svnview.digium.com/svn/asterisk/trunk/contrib/realtime/mysql/iaxfriends.sql?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/contrib/realtime/mysql/iaxfriends.sql (original)
+++ trunk/contrib/realtime/mysql/iaxfriends.sql Tue Sep  6 19:54:36 2011
@@ -37,8 +37,7 @@
   `transfer` varchar(10) NULL, -- mediaonly/yes/no
   `jitterbuffer` varchar(3) NULL, -- yes/no
   `forcejitterbuffer` varchar(3) NULL, -- yes/no
-  `disallow` varchar(40) NULL, -- all/{list-of-codecs}
-  `allow` varchar(40) NULL, -- all/{list-of-codecs}
+  `allow` varchar(200) NULL, -- all/{list-of-codecs}
   `codecpriority` varchar(40) NULL, 
   `qualify` varchar(10) NULL, -- yes/no/{number of milliseconds}
   `qualifysmoothing` varchar(10) NULL, -- yes/no

Modified: trunk/contrib/realtime/mysql/sipfriends.sql
URL: http://svnview.digium.com/svn/asterisk/trunk/contrib/realtime/mysql/sipfriends.sql?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/contrib/realtime/mysql/sipfriends.sql (original)
+++ trunk/contrib/realtime/mysql/sipfriends.sql Tue Sep  6 19:54:36 2011
@@ -28,8 +28,7 @@
       `callgroup` varchar(40) DEFAULT NULL,
       `pickupgroup` varchar(40) DEFAULT NULL,
       `language` varchar(40) DEFAULT NULL,
-      `allow` varchar(40) DEFAULT NULL,
-      `disallow` varchar(40) DEFAULT NULL,
+      `allow` varchar(200) DEFAULT NULL,
       `insecure` varchar(40) DEFAULT NULL,
       `trustrpid` enum('yes','no') DEFAULT NULL,
       `progressinband` enum('yes','no','never') DEFAULT NULL,

Modified: trunk/contrib/realtime/postgresql/realtime.sql
URL: http://svnview.digium.com/svn/asterisk/trunk/contrib/realtime/postgresql/realtime.sql?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/contrib/realtime/postgresql/realtime.sql (original)
+++ trunk/contrib/realtime/postgresql/realtime.sql Tue Sep  6 19:54:36 2011
@@ -61,8 +61,7 @@
 secret character varying(80),
 "type" character varying DEFAULT 'friend' NOT NULL,
 username character varying(80) DEFAULT '' NOT NULL,
-disallow character varying(100) DEFAULT 'all',
-allow character varying(100) DEFAULT 'g729;ilbc;gsm;ulaw;alaw',
+allow character varying(200) DEFAULT '!all,g729,ilbc,gsm,ulaw,alaw',
 musiconhold character varying(100),
 regseconds bigint DEFAULT 0::bigint NOT NULL,
 ipaddr character varying(40) DEFAULT '' NOT NULL,

Modified: trunk/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/frame.c?view=diff&rev=334574&r1=334573&r2=334574
==============================================================================
--- trunk/main/frame.c (original)
+++ trunk/main/frame.c Tue Sep  6 19:54:36 2011
@@ -730,13 +730,18 @@
 
 int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing) 
 {
-	int errors = 0, framems = 0, all = 0;
+	int errors = 0, framems = 0, all = 0, iter_allowing;
 	char *parse = NULL, *this = NULL, *psize = NULL;
 	struct ast_format format;
 
 	parse = ast_strdupa(list);
 	while ((this = strsep(&parse, ","))) {
+		iter_allowing = allowing;
 		framems = 0;
+		if (*this == '!') {
+			this++;
+			iter_allowing = !allowing;
+		}
 		if ((psize = strrchr(this, ':'))) {
 			*psize++ = '\0';
 			ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
@@ -750,13 +755,13 @@
 		all = strcasecmp(this, "all") ? 0 : 1;
 
 		if (!all && !ast_getformatbyname(this, &format)) {
-			ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
+			ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", iter_allowing ? "allow" : "disallow", this);
 			errors++;
 			continue;
 		}
 
 		if (cap) {
-			if (allowing) {
+			if (iter_allowing) {
 				if (all) {
 					ast_format_cap_add_all(cap);
 				} else {
@@ -773,13 +778,13 @@
 
 		if (pref) {
 			if (!all) {
-				if (allowing) {
+				if (iter_allowing) {
 					ast_codec_pref_append(pref, &format);
 					ast_codec_pref_setsize(pref, &format, framems);
 				} else {
 					ast_codec_pref_remove(pref, &format);
 				}
-			} else if (!allowing) {
+			} else if (!iter_allowing) {
 				memset(pref, 0, sizeof(*pref));
 			}
 		}




More information about the asterisk-commits mailing list