[Asterisk-code-review] res pjsip caller id: Anonymize 'From' when caller id present... (asterisk[master])

George Joseph asteriskteam at digium.com
Wed Feb 24 17:33:47 CST 2016


George Joseph has uploaded a new change for review.

  https://gerrit.asterisk.org/2294

Change subject: res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited
......................................................................

res_pjsip_caller_id: Anonymize 'From' when caller id presentation is prohibited

Per RFC3325, the 'From' header is now anonymized on outgoing calls when
caller id presentation is prohibited.

ASTERISK-25791 #close
Reported-by: Anthony Messina

Change-Id: I2c82a5ca1413c2c00fb62ea95b0ae8e97af54dc9
---
M CHANGES
M res/res_pjsip_caller_id.c
2 files changed, 29 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/94/2294/1

diff --git a/CHANGES b/CHANGES
index 3022b7e..cc34788 100644
--- a/CHANGES
+++ b/CHANGES
@@ -210,6 +210,11 @@
 --- Functionality changes from Asterisk 13.7.0 to Asterisk 13.8.0 ------------
 ------------------------------------------------------------------------------
 
+res_pjsip_caller_id
+------------------
+ * Per RFC3325, the 'From' header is now anonymized on outgoing calls when
+   caller id presentation is prohibited.
+
 res_pjsip_config_wizard
 ------------------
  * A new command (pjsip export config_wizard primitives) has been added that
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 8227cac..43142d9 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -693,6 +693,9 @@
 	ast_party_id_copy(&connected_id, &effective_id);
 	ast_channel_unlock(session->channel);
 
+	/* We need to add pai/rpid before anonymizing From */
+	add_id_headers(session, tdata, &connected_id);
+
 	if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
 		/* Only change the From header on the initial outbound INVITE. Switching it
 		 * mid-call might confuse some UAs.
@@ -703,17 +706,32 @@
 		from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, tdata->msg->hdr.next);
 		dlg = session->inv_session->dlg;
 
-		if (ast_strlen_zero(session->endpoint->fromuser)
-			&& (session->endpoint->id.trust_outbound
-				|| (ast_party_id_presentation(&connected_id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED)) {
-			modify_id_header(tdata->pool, from, &connected_id);
-			modify_id_header(dlg->pool, dlg->local.info, &connected_id);
+		if ((ast_party_id_presentation(&connected_id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED) {
+			if (ast_strlen_zero(session->endpoint->fromuser) && session->endpoint->id.trust_outbound) {
+				modify_id_header(tdata->pool, from, &connected_id);
+				modify_id_header(dlg->pool, dlg->local.info, &connected_id);
+			}
+		} else {
+			/* Regardless of whether fromuser was specified or we trust the peer, if presentation
+			 * is prohibited, we're going to anonymize From.
+			 */
+			pjsip_name_addr *id_name_addr = (pjsip_name_addr *) from->uri;
+			pjsip_sip_uri *id_uri = pjsip_uri_get_uri(id_name_addr);
+
+			pj_strdup2(tdata->pool, &id_name_addr->display, "Anonymous");
+			pj_strdup2(tdata->pool, &id_uri->user, "anonymous");
+			pj_strdup2(tdata->pool, &id_uri->host, "anonymous.invalid");
+
+			id_name_addr = (pjsip_name_addr *) dlg->local.info->uri;
+			id_uri = pjsip_uri_get_uri(id_name_addr);
+			pj_strdup2(dlg->pool, &id_name_addr->display, "Anonymous");
+			pj_strdup2(dlg->pool, &id_uri->user, "anonymous");
+			pj_strdup2(dlg->pool, &id_uri->host, "anonymous.invalid");
 		}
 
 		ast_sip_add_usereqphone(session->endpoint, tdata->pool, from->uri);
 		ast_sip_add_usereqphone(session->endpoint, dlg->pool, dlg->local.info->uri);
 	}
-	add_id_headers(session, tdata, &connected_id);
 	ast_party_id_free(&connected_id);
 }
 

-- 
To view, visit https://gerrit.asterisk.org/2294
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c82a5ca1413c2c00fb62ea95b0ae8e97af54dc9
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>



More information about the asterisk-code-review mailing list