From 0ce3fa1c22cc67610c52cc828f7d7dd6253b61ac Mon Sep 17 00:00:00 2001 From: David Vossel <dvossel@digium.com> Date: Fri, 17 Jul 2009 16:13:22 +0000 Subject: [PATCH] Merged revisions 206938 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r206938 | dvossel | 2009-07-17 11:05:06 -0500 (Fri, 17 Jul 2009) | 14 lines SIP incorrect From: header information when callpres is prohib Some ITSP make use of the "Anonymous" display name to detect a requirement to withhold caller id across the PSTN. This does not work if the display name is "Unknown". (closes issue #14465) Reported by: Nick_Lewis Patches: chan_sip.c-callerpres.patch uploaded by Nick (license 657) chan_sip.c-callerpres_trunk.patch uploaded by dvossel (license 671) Tested by: Nick_Lewis, dvossel ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@206939 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 34e13a0f58..0b2b26c15b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -603,8 +603,9 @@ static int mwi_expiry = DEFAULT_MWI_EXPIRY; #define DEFAULT_QUALIFY_PEERS 1 -#define CALLERID_UNKNOWN "Unknown" - +#define CALLERID_UNKNOWN "Anonymous" +#define FROMDOMAIN_INVALID "anonymous.invalid" + #define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */ #define DEFAULT_QUALIFYFREQ 60 * 1000 /*!< Qualification: How often to check for the host to be up */ #define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */ @@ -10495,6 +10496,7 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho char tmp_l[SIPBUFSIZE/2]; /* build a local copy of 'l' if needed */ const char *l = NULL; /* XXX what is this, exactly ? */ const char *n = NULL; /* XXX what is this, exactly ? */ + const char *d = NULL; /* domain in from header */ const char *urioptions = ""; int ourport; @@ -10520,9 +10522,15 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho snprintf(p->lastmsg, sizeof(p->lastmsg), "Init: %s", sip_methods[sipmethod].text); + d = S_OR(p->fromdomain, ast_inet_ntoa(p->ourip.sin_addr)); if (p->owner && (p->owner->connected.id.number_presentation & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) { l = p->owner->connected.id.number; n = p->owner->connected.id.name; + } else if (p->owner && (p->owner->connected.id.number_presentation & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED && (!ast_test_flag(&p->flags[0], SIP_SENDRPID))) { + /* if we are not sending RPID and user wants his callerid restricted */ + l = CALLERID_UNKNOWN; + n = l; + d = FROMDOMAIN_INVALID; } /* Hey, it's a NOTIFY! See if they've configured a mwi_from. @@ -10560,9 +10568,9 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho ourport = ntohs(p->ourip.sin_port); if (!sip_standard_port(p->socket.type, ourport) && ast_strlen_zero(p->fromdomain)) - snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=%s", n, l, ast_inet_ntoa(p->ourip.sin_addr), ourport, p->tag); + snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=%s", n, l, d, ourport, p->tag); else - snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%s", n, l, S_OR(p->fromdomain, ast_inet_ntoa(p->ourip.sin_addr)), p->tag); + snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%s", n, l, d, p->tag); /* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */ if (!ast_strlen_zero(p->fullcontact)) { -- GitLab