diff options
author | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-21 14:37:04 +0000 |
---|---|---|
committer | dvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-21 14:37:04 +0000 |
commit | 6ba5e74e4b40db25812f0f8fc1814aff3059e874 (patch) | |
tree | 69fe2215bfe875fbf3b718a98c79a9e0e836454c /channels/chan_sip.c | |
parent | fb85d4632c8233e0f171346a4fa5e41c1e1fdcff (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.4@225032 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index bb49cd72e..f5a45b2a5 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -554,6 +554,7 @@ static int global_rtpholdtimeout; 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 users/peers to connect? */ static int global_allowsubscribe; /*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE the global setting is in globals_flags[1] */ @@ -10014,7 +10015,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); } @@ -10047,7 +10048,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ if (*calleridname) ast_string_field_set(p, cid_name, calleridname); tmp = ast_strdupa(rpid_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); } @@ -10070,7 +10071,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ ast_string_field_set(p, context, user->context); if (!ast_strlen_zero(user->cid_num)) { char *tmp = ast_strdupa(user->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); } @@ -10157,7 +10158,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ char *tmp = ast_strdupa(rpid_num); if (*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); } @@ -10207,7 +10208,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ } 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); } @@ -10257,10 +10258,10 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ char *tmp = ast_strdupa(rpid_num); if (*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); - } + } } } @@ -18212,7 +18213,8 @@ static int reload_config(enum channelreloadreason reason) /* Misc settings for the channel */ global_relaxdtmf = FALSE; global_callevents = FALSE; - global_t1min = DEFAULT_T1MIN; + global_t1min = DEFAULT_T1MIN; + global_shrinkcallerid = 1; global_matchexterniplocally = FALSE; @@ -18467,6 +18469,14 @@ static int reload_config(enum channelreloadreason reason) global_matchexterniplocally = ast_true(v->value); } 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); + } } } |