]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Implement the '!' negation element to negate codecs directly in the allow keyword.
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 7 Sep 2011 00:54:36 +0000 (00:54 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 7 Sep 2011 00:54:36 +0000 (00:54 +0000)
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/

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@334574 65c4cc65-6c06-0410-ace0-fbb531ad65f3

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

diff --git a/CHANGES b/CHANGES
index 986c132e30b24fa56f0105dc8488618c9ea8fb1d..4f44c1412a3a8b5f90015255dcf4c19d84038987 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,13 @@ Chan_local changes
  * 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 -------------------
 ------------------------------------------------------------------------------
index fb487dba66155c6307b5a6afc62adffcaf85dab5..7c04a4a0f5a6dc5e7e706a3ec37913c71b70de36 100644 (file)
@@ -1216,10 +1216,14 @@ srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
         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
 ;
index 3b3bbb3c79fc73328e6f14de890aa57c9705656d..f01fd73ffaf958a6c0b97d828095a6ab66c70f91 100644 (file)
@@ -37,8 +37,7 @@ CREATE TABLE `iaxfriends` (
   `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
index 12047d399b27cc2dc8eb581959c5c9c8459c66b6..07cd8788aaa5cf8da6b4f914830cd39c60d06d81 100644 (file)
@@ -28,8 +28,7 @@ CREATE TABLE IF NOT EXISTS `sipfriends` (
       `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,
index 74b895738f6d20a3c2e263891090b1bae60cb754..fb474ebbe2285f35722f4c1a4bee77cba25102fb 100644 (file)
@@ -61,8 +61,7 @@ rtpholdtimeout character varying(3),
 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,
index b664e2e849fc54c9f142eb5af75438e65a9e0984..4a9109694994e8403e6394b617b1866ead458c5c 100644 (file)
@@ -730,13 +730,18 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
 
 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 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap
                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 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap
 
                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));
                        }
                }