]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 225033 via svnmerge from
authorDavid Vossel <dvossel@digium.com>
Wed, 21 Oct 2009 15:26:37 +0000 (15:26 +0000)
committerDavid Vossel <dvossel@digium.com>
Wed, 21 Oct 2009 15:26:37 +0000 (15:26 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r225033 | dvossel | 2009-10-21 09:39:10 -0500 (Wed, 21 Oct 2009) | 27 lines

  Merged revisions 225032 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r225032 | dvossel | 2009-10-21 09:37:04 -0500 (Wed, 21 Oct 2009) | 20 lines

    IAX/SIP shrinkcallerid option

    The shrinking of caller id removes '(', ' ', ')', non-trailing '.',
    and '-' from the string.  This means values such as 555.5555 and
    test-test result in 555555 and testtest.  There are instances,
    such as Skype integration, where a specific value is passed via
    caller id that must be preserved unmodified.  This patch makes
    the shrinking of caller id optional in chan_sip and chan_iax in
    order to support such cases.  By default this option is on to
    preserve previous expected behavior.

    (closes issue #15940)
    Reported by: dimas
    Patches:
          v2-15940.patch uploaded by dimas (license 88)
          15940_shrinkcallerid_trunk.c uploaded by dvossel (license 671)
    Tested by: dvossel

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

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

channels/chan_iax2.c
channels/chan_sip.c
configs/iax.conf.sample
configs/sip.conf.sample

index e749cce6ae7a599b173327e53dfc9a58dbc74d24..35bc581f9b26995bfc17aa183073e3f6481ec669 100644 (file)
@@ -296,6 +296,7 @@ enum iax2_flags {
                                                     response, so that we've achieved a three-way handshake with
                                                     them before sending voice or anything else*/
        IAX_ALLOWFWDOWNLOAD = (1 << 26),        /*!< Allow the FWDOWNL command? */
+       IAX_SHRINKCALLERID = (1 << 27),   /*!< Turn on and off caller id shrinking */
 };
 
 static int global_rtautoclear = 120;
@@ -6983,7 +6984,9 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
        if (ies->called_number)
                ast_string_field_set(iaxs[callno], exten, ies->called_number);
        if (ies->calling_number) {
-               ast_shrink_phone_number(ies->calling_number);
+               if (ast_test_flag(&globalflags, IAX_SHRINKCALLERID)) { 
+                       ast_shrink_phone_number(ies->calling_number);
+               }
                ast_string_field_set(iaxs[callno], cid_num, ies->calling_number);
        }
        if (ies->calling_name)
@@ -12290,11 +12293,12 @@ static int set_config(const char *config_file, int reload)
 
        /* Reset global codec prefs */  
        memset(&prefs, 0 , sizeof(struct ast_codec_pref));
-       
+
        /* Reset Global Flags */
        memset(&globalflags, 0, sizeof(globalflags));
        ast_set_flag(&globalflags, IAX_RTUPDATE);
-       
+       ast_set_flag(&globalflags, IAX_SHRINKCALLERID);
+
        /* Turns on support for key rotation during encryption. */
        iax2_encryption |= IAX_ENCRYPT_KEYROTATE;
 #ifdef SO_NO_CHECK
@@ -12536,10 +12540,18 @@ static int set_config(const char *config_file, int reload)
                        if (sscanf(v->value, "%10hu", &global_maxcallno_nonval) != 1) {
                                ast_log(LOG_WARNING, "maxcallnumbers_nonvalidated must be set to a valid number.  %s is not valid at line %d.\n", v->value, v->lineno);
                        }
-               } else if(!strcasecmp(v->name, "calltokenoptional")) {
+               } else if (!strcasecmp(v->name, "calltokenoptional")) {
                        if (add_calltoken_ignore(v->value)) {
                                ast_log(LOG_WARNING, "Invalid calltokenoptional address range - '%s' line %d\n", v->value, v->lineno);
                        }
+               } else if (!strcasecmp(v->name, "shrinkcallerid")) {
+                       if (ast_true(v->value)) {
+                               ast_set_flag((&globalflags), IAX_SHRINKCALLERID);
+                       } else if (ast_false(v->value)) {
+                               ast_clear_flag((&globalflags), IAX_SHRINKCALLERID);
+                       } else {
+                               ast_log(LOG_WARNING, "shrinkcallerid value %s is not valid at line %d.\n", v->value, v->lineno);
+                       }
                }/*else if (strcasecmp(v->name,"type")) */
                /*      ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
                v = v->next;
index 2ab5a6fd225d5c06da12ee510a93058b84835ae2..badd72c047eae4bc8ee53b230f073a1f355419ad 100644 (file)
@@ -769,6 +769,7 @@ static int global_rtpholdtimeout;   /*!< Time out call if no RTP during hold */
 static int global_rtpkeepalive;                /*!< Send RTP keepalives */
 static int global_reg_timeout; 
 static int global_regattempts_max;     /*!< Registration attempts before giving up */
+static int global_shrinkcallerid;      /*!< enable or disable shrinking of caller id  */
 static int global_allowguest;          /*!< allow unauthenticated peers to connect? */
 static int global_callcounter;         /*!< Enable call counters for all devices. This is currently enabled by setting the peer
                                                call-limit to 999. When we remove the call-limit from the code, we can make it
@@ -12651,7 +12652,7 @@ static void replace_cid(struct sip_pvt *p, const char *rpid_num, const char *cal
                char *tmp = ast_strdupa(rpid_num); /* XXX the copy can be done later */
                if (!ast_strlen_zero(calleridname))
                        ast_string_field_set(p, cid_name, calleridname);
-               if (ast_is_shrinkable_phonenumber(tmp))
+               if (global_shrinkcallerid && ast_is_shrinkable_phonenumber(tmp))
                        ast_shrink_phone_number(tmp);
                ast_string_field_set(p, cid_num, tmp);
        }
@@ -12769,7 +12770,7 @@ static enum check_auth_result check_peer_ok(struct sip_pvt *p, char *of,
                }
                if (!ast_strlen_zero(peer->cid_num)) {
                        char *tmp = ast_strdupa(peer->cid_num);
-                       if (ast_is_shrinkable_phonenumber(tmp))
+                       if (global_shrinkcallerid && ast_is_shrinkable_phonenumber(tmp))
                                ast_shrink_phone_number(tmp);
                        ast_string_field_set(p, cid_num, tmp);
                }
@@ -12886,7 +12887,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
                        <sip:8164444422;phone-context=+1@1.2.3.4:5060;user=phone;tag=SDadkoa01-gK0c3bdb43>
                */
                tmp = strsep(&tmp, ";");
-               if (ast_is_shrinkable_phonenumber(tmp))
+               if (global_shrinkcallerid && ast_is_shrinkable_phonenumber(tmp))
                        ast_shrink_phone_number(tmp);
                ast_string_field_set(p, cid_num, tmp);
        }
@@ -22903,6 +22904,7 @@ static int reload_config(enum channelreloadreason reason)
        global_t1min = DEFAULT_T1MIN;
        global_qualifyfreq = DEFAULT_QUALIFYFREQ;
        global_t38_maxdatagram = -1;
+       global_shrinkcallerid = 1;
 
        global_matchexterniplocally = FALSE;
 
@@ -23311,6 +23313,14 @@ static int reload_config(enum channelreloadreason reason)
                        } else {
                                global_st_refresher = i;
                        }
+               } else if (!strcasecmp(v->name, "shrinkcallerid")) {
+                       if (ast_true(v->value)) {
+                               global_shrinkcallerid = 1;
+                       } else if (ast_false(v->value)) {
+                               global_shrinkcallerid = 0;
+                       } else {
+                               ast_log(LOG_WARNING, "shrinkcallerid value %s is not valid at line %d.\n", v->value, v->lineno);
+                       }
                }
        }
 
index 773fb40657b1f504722f2ae038650ed41a211dda..805e5213cb7a5547e1b481a174ff97333df0ddd4 100644 (file)
@@ -377,6 +377,15 @@ autokill=yes
 ;10.1.2.0/255.255.255.0 = 32
 ;
 
+; The shrinkcallerid function removes '(', ' ', ')', non-trailing '.', and '-' not
+; in square brackets.  For example, the caller id value 555.5555 becomes 5555555
+; when this option is enabled.  Disabling this option results in no modification
+; of the caller id value, which is necessary when the caller id represents something
+; that must be preserved.  This option can only be used in the [general] section.
+; By default this option is on.
+;
+;shrinkcallerid=yes     ; on by default
+
 ; Guest sections for unauthenticated connection attempts.  Just specify an
 ; empty secret, or provide no secret section.
 ;
index 9e590042a2f2a9439558ac02e78ba46b0f34af81..0b7a2fa23dfc317e5dfb2854c69e4b172c9861b8 100644 (file)
@@ -296,6 +296,15 @@ srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
 ;contactpermit=172.16.0.0/255.255.0.0  ; restrict at what IPs your users may
                                        ; register their phones.
 
+; The shrinkcallerid function removes '(', ' ', ')', non-trailing '.', and '-' not
+; in square brackets.  For example, the caller id value 555.5555 becomes 5555555
+; when this option is enabled.  Disabling this option results in no modification
+; of the caller id value, which is necessary when the caller id represents something
+; that must be preserved.  This option can only be used in the [general] section.
+; By default this option is on.
+;
+;shrinkcallerid=yes     ; on by default
+
 ;
 ; If regcontext is specified, Asterisk will dynamically create and destroy a
 ; NoOp priority 1 extension for a given peer who registers or unregisters with