[asterisk-commits] dvossel: trunk r225033 - in /trunk: ./ channels/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 21 09:39:30 CDT 2009


Author: dvossel
Date: Wed Oct 21 09:39:10 2009
New Revision: 225033

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=225033
Log:
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/
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/configs/iax.conf.sample
    trunk/configs/sip.conf.sample

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=225033&r1=225032&r2=225033
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed Oct 21 09:39:10 2009
@@ -421,7 +421,7 @@
 #define IAX_SENDCONNECTEDLINE   (uint64_t)(1 << 28)   /*!< Allow sending of connected line updates */
 #define IAX_RECVCONNECTEDLINE   (uint64_t)(1 << 29)   /*!< Allow receiving of connected line updates */
 #define IAX_FORCE_ENCRYPT       (uint64_t)(1 << 30)   /*!< Forces call encryption, if encryption not possible hangup */
-
+#define IAX_SHRINKCALLERID      (uint64_t)(1 << 31)   /*!< Turn on and off caller id shrinking */
 static int global_rtautoclear = 120;
 
 static int reload_config(void);
@@ -7224,7 +7224,9 @@
 	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_flag64(&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)
@@ -12563,6 +12565,7 @@
 	/* Reset Global Flags */
 	memset(&globalflags, 0, sizeof(globalflags));
 	ast_set_flag64(&globalflags, IAX_RTUPDATE);
+	ast_set_flag64((&globalflags), IAX_SHRINKCALLERID);
 
 #ifdef SO_NO_CHECK
 	nochecksums = 0;
@@ -12829,9 +12832,17 @@
 			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_flag64((&globalflags), IAX_SHRINKCALLERID);
+			} else if (ast_false(v->value)) {
+				ast_clear_flag64((&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); */

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=225033&r1=225032&r2=225033
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Oct 21 09:39:10 2009
@@ -1227,6 +1227,7 @@
 static int global_rtpkeepalive;		/*!< Send RTP keepalives */
 static int global_reg_timeout;		/*!< Global time between attempts for outbound registrations */
 static int global_regattempts_max;	/*!< Registration attempts before giving up */
+static int global_shrinkcallerid;	/*!< enable or disable shrinking of caller id  */
 static int global_callcounter;		/*!< Enable call counters for all devices. This is currently enabled by setting the peer
 						call-limit to INT_MAX. When we remove the call-limit from the code, we can make it
 						with just a boolean flag in the device structure */
@@ -13420,7 +13421,7 @@
 		cid_num = (char *)p->cid_num;
 	} else if (!strncasecmp(start, "sip:", 4)) {
 		cid_num = start + 4;
-		if (ast_is_shrinkable_phonenumber(cid_num))
+		if (global_shrinkcallerid && ast_is_shrinkable_phonenumber(cid_num))
 			ast_shrink_phone_number(cid_num);
 		start = end;
 
@@ -13499,7 +13500,7 @@
 	if (strncasecmp(start, "sip:", 4))
 		return 0;
 	cid_num = start + 4;
-	if (ast_is_shrinkable_phonenumber(cid_num))
+	if (global_shrinkcallerid && ast_is_shrinkable_phonenumber(cid_num))
 		ast_shrink_phone_number(cid_num);
 	start = end;
 
@@ -14347,7 +14348,7 @@
 		if (!get_rpid(p, req)) {
 			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);
 			}
@@ -14456,7 +14457,7 @@
 			<sip:8164444422;phone-context=+1 at 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);
 	}
@@ -25058,6 +25059,7 @@
 	global_t1min = DEFAULT_T1MIN;
 	global_qualifyfreq = DEFAULT_QUALIFYFREQ;
 	global_t38_maxdatagram = -1;
+	global_shrinkcallerid = 1;
 
 	sip_cfg.matchexterniplocally = DEFAULT_MATCHEXTERNIPLOCALLY;
 
@@ -25513,6 +25515,14 @@
 			mark_parsed_methods(&sip_cfg.disallowed_methods, disallow);
 		} else if (!strcasecmp(v->name, "constantssrc")) {
 			ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_CONSTANT_SSRC);
+		} 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);
+			}
 		}
 	}
 

Modified: trunk/configs/iax.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/iax.conf.sample?view=diff&rev=225033&r1=225032&r2=225033
==============================================================================
--- trunk/configs/iax.conf.sample (original)
+++ trunk/configs/iax.conf.sample Wed Oct 21 09:39:10 2009
@@ -384,6 +384,15 @@
 ;10.1.1.0/255.255.255.0 = 24
 ;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.

Modified: trunk/configs/sip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/sip.conf.sample?view=diff&rev=225033&r1=225032&r2=225033
==============================================================================
--- trunk/configs/sip.conf.sample (original)
+++ trunk/configs/sip.conf.sample Wed Oct 21 09:39:10 2009
@@ -340,6 +340,16 @@
                                 ; If you have qualify on and the peer becomes unreachable
                                 ; this setting will enforce inactivation of the regexten
                                 ; extension for the peer
+
+; 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
+
 ;------------------------ TLS settings ------------------------------------------------------------
 ;tlscertfile=</path/to/certificate.pem> ; Certificate file (*.pem format only) to use for TLS connections
                                         ; default is to look for "asterisk.pem" in current directory




More information about the asterisk-commits mailing list