[asterisk-commits] mmichelson: branch mmichelson/caller_id r384802 - /team/mmichelson/caller_id/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 4 15:53:19 CDT 2013


Author: mmichelson
Date: Thu Apr  4 15:53:16 2013
New Revision: 384802

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384802
Log:
Get privacy information from P-Asserted-Identity and Remote-Party-ID headers.


Modified:
    team/mmichelson/caller_id/res/res_sip_caller_id.c

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=384802&r1=384801&r2=384802
==============================================================================
--- team/mmichelson/caller_id/res/res_sip_caller_id.c (original)
+++ team/mmichelson/caller_id/res/res_sip_caller_id.c Thu Apr  4 15:53:16 2013
@@ -57,7 +57,7 @@
 {
 	static const pj_str_t from = { "From", 4 };
 	pjsip_generic_string_hdr *ident = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
-			header_name, rdata->msg_info.msg->hdr.next);
+			header_name, NULL);
 	pjsip_fromto_hdr *parsed_hdr;
 	int parsed_len;
 	pj_str_t header_content;
@@ -80,8 +80,10 @@
 
 static int get_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
 {
-	pj_str_t pai_str = { "P-Asserted-Identity", 19 };
+	static const pj_str_t pai_str = { "P-Asserted-Identity", 19 };
+	static const pj_str_t privacy_str = { "Privacy", 7 };
 	pjsip_fromto_hdr *pai_hdr = get_id_header(rdata, &pai_str);
+	pjsip_generic_string_hdr *privacy;
 	if (!pai_hdr) {
 		return -1;
 	}
@@ -92,13 +94,26 @@
 		return -1;
 	}
 
+	privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str, NULL);
+	if (!privacy) {
+		return 0;
+	}
+	if (!pj_stricmp2(&privacy->hvalue, "id")) {
+		id->number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
+		id->name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
+	}
+
 	return 0;
 }
 
 static int get_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id)
 {
-	pj_str_t rpid_str = { "Remote-Party-ID", 15 };
+	static const pj_str_t rpid_str = { "Remote-Party-ID", 15 };
+	static const pj_str_t privacy_str = { "privacy", 7 };
+	static const pj_str_t screen_str = { "screen", 6 };
 	pjsip_fromto_hdr *rpid_hdr = get_id_header(rdata, &rpid_str);
+	pjsip_param *screen;
+	pjsip_param *privacy;
 	if (!rpid_hdr) {
 		return -1;
 	}
@@ -107,6 +122,17 @@
 
 	if (!id->number.valid) {
 		return -1;
+	}
+
+	privacy = pjsip_param_find(&rpid_hdr->other_param, &privacy_str);
+	screen = pjsip_param_find(&rpid_hdr->other_param, &screen_str);
+	if (privacy && !pj_stricmp2(&privacy->value, "full")) {
+		id->number.presentation |= AST_PRES_RESTRICTED;
+		id->name.presentation |= AST_PRES_RESTRICTED;
+	}
+	if (screen && !pj_stricmp2(&screen->value, "yes")) {
+		id->number.presentation |= AST_PRES_USER_NUMBER_PASSED_SCREEN;
+		id->name.presentation |= AST_PRES_USER_NUMBER_PASSED_SCREEN;
 	}
 
 	return 0;
@@ -251,7 +277,7 @@
 	/* Since inv_session reuses responses, we have to make sure there's not already
 	 * a P-Asserted-Identity present. If there is, we just modify the old one.
 	 */
-	old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name, tdata->msg->hdr.next);
+	old_pai = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_pai_name, NULL);
 	if (old_pai) {
 		modify_id_header(tdata->pool, old_pai, id);
 		return;
@@ -278,7 +304,7 @@
 	/* Since inv_session reuses responses, we have to make sure there's not already
 	 * a P-Asserted-Identity present. If there is, we just modify the old one.
 	 */
-	old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name, tdata->msg->hdr.next);
+	old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name, NULL);
 	if (old_rpid) {
 		modify_id_header(tdata->pool, old_rpid, id);
 		return;




More information about the asterisk-commits mailing list