[asterisk-commits] mmichelson: branch mmichelson/caller_id r384813 - in /team/mmichelson/caller_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 5 10:54:08 CDT 2013


Author: mmichelson
Date: Fri Apr  5 10:54:05 2013
New Revision: 384813

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384813
Log:
Implement privacy restrictions for sending outbound identification.


Modified:
    team/mmichelson/caller_id/include/asterisk/res_sip.h
    team/mmichelson/caller_id/res/res_sip/sip_configuration.c
    team/mmichelson/caller_id/res/res_sip_caller_id.c

Modified: team/mmichelson/caller_id/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/include/asterisk/res_sip.h?view=diff&rev=384813&r1=384812&r2=384813
==============================================================================
--- team/mmichelson/caller_id/include/asterisk/res_sip.h (original)
+++ team/mmichelson/caller_id/include/asterisk/res_sip.h Fri Apr  5 10:54:05 2013
@@ -316,8 +316,10 @@
 	enum ast_sip_direct_media_glare_mitigation direct_media_glare_mitigation;
 	/*! Do not attempt direct media session refreshes if a media NAT is detected */
 	unsigned int disable_direct_media_on_nat;
+	/*! Do we trust the endpoint with our outbound identity? */
+	unsigned int trust_id_outbound;
 	/*! Do we trust identity information that originates externally (e.g. P-Asserted-Identity header)? */
-	unsigned int trust_external_id;
+	unsigned int trust_id_inbound;
 	/*! Do we send P-Asserted-Identity headers to this endpoint? */
 	unsigned int send_pai;
 	/*! Do we send Remote-Party-ID headers to this endpoint? */

Modified: team/mmichelson/caller_id/res/res_sip/sip_configuration.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/res/res_sip/sip_configuration.c?view=diff&rev=384813&r1=384812&r2=384813
==============================================================================
--- team/mmichelson/caller_id/res/res_sip/sip_configuration.c (original)
+++ team/mmichelson/caller_id/res/res_sip/sip_configuration.c Fri Apr  5 10:54:05 2013
@@ -323,7 +323,8 @@
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid", "", caller_id_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_privacy", "", caller_id_privacy_handler, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "callerid_tag", "", caller_id_tag_handler, NULL, 0, 0);
-	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_external_id", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, trust_external_id));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_inbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, trust_id_inbound));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "trust_id_outbound", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, trust_id_outbound));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_pai", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, send_pai));
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "send_rpid", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, send_rpid));
 

Modified: team/mmichelson/caller_id/res/res_sip_caller_id.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/res/res_sip_caller_id.c?view=diff&rev=384813&r1=384812&r2=384813
==============================================================================
--- team/mmichelson/caller_id/res/res_sip_caller_id.c (original)
+++ team/mmichelson/caller_id/res/res_sip_caller_id.c Fri Apr  5 10:54:05 2013
@@ -219,7 +219,7 @@
 static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
 {
 	struct ast_party_id id;
-	if (!session->endpoint->trust_external_id) {
+	if (!session->endpoint->trust_id_inbound) {
 		return;
 	}
 
@@ -238,7 +238,7 @@
 {
 	if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
 		/* Initial inbound INVITE. Set the session ID directly */
-		if (session->endpoint->trust_external_id &&
+		if (session->endpoint->trust_id_inbound &&
 				(!get_id_from_pai(rdata, &session->id) || !get_id_from_rpid(rdata, &session->id))) {
 			return 0;
 		} 
@@ -361,6 +361,21 @@
 	pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
 }
 
+static void add_id_headers(struct ast_sip_session *session, pjsip_tx_data *tdata, struct ast_party_id *id)
+{
+	if (((id->name.presentation & AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED ||
+			(id->number.presentation & AST_PRES_RESTRICTION) == AST_PRES_RESTRICTED) &&
+			!session->endpoint->trust_id_outbound) {
+		return;
+	}
+	if (session->endpoint->send_pai) {
+		add_pai_header(tdata, id);
+	}
+	if (session->endpoint->send_rpid) {
+		add_rpid_header(tdata, id);
+	}
+}
+
 static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
 {
 	struct ast_party_id connected_id;
@@ -385,12 +400,7 @@
 			queue_connected_line_update(session, &session->endpoint->id);
 		}
 	}
-	if (session->endpoint->send_pai) {
-		add_pai_header(tdata, &connected_id);
-	}
-	if (session->endpoint->send_rpid) {
-		add_rpid_header(tdata, &connected_id);
-	}
+	add_id_headers(session, tdata, &connected_id);
 }
 
 static void caller_id_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
@@ -398,12 +408,7 @@
 	if (!session->channel) {
 		return;
 	}
-	if (session->endpoint->send_pai) {
-		add_pai_header(tdata, &ast_channel_connected(session->channel)->id);
-	}
-	if (session->endpoint->send_rpid) {
-		add_rpid_header(tdata, &ast_channel_connected(session->channel)->id);
-	}
+	add_id_headers(session, tdata, &ast_channel_connected(session->channel)->id);
 }
 
 static struct ast_sip_session_supplement caller_id_supplement = {




More information about the asterisk-commits mailing list