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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 3 09:55:15 CDT 2013


Author: mmichelson
Date: Wed Apr  3 09:55:12 2013
New Revision: 384612

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384612
Log:
Add code for retrieving ID from a Remote-Party-ID header.

This is mostly identical to P-Asserted-Identity at the moment, so expect
to see some common code factored out.


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=384612&r1=384611&r2=384612
==============================================================================
--- team/mmichelson/caller_id/res/res_sip_caller_id.c (original)
+++ team/mmichelson/caller_id/res/res_sip_caller_id.c Wed Apr  3 09:55:12 2013
@@ -82,6 +82,36 @@
 	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 };
+	pjsip_generic_string_hdr *rpid = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
+			&rpid_str, rdata->msg_info.msg->hdr.next);
+	pj_str_t header_content;
+	pjsip_name_addr *id_name_addr;
+
+	if (!rpid) {
+		return -1;
+	}
+
+	pj_strdup_with_null(rdata->tp_info.pool, &header_content, &rpid->hvalue);
+
+	id_name_addr = (pjsip_name_addr *)pjsip_parse_uri(rdata->tp_info.pool,
+			header_content.ptr, header_content.slen, PJSIP_PARSE_URI_AS_NAMEADDR);
+
+	if (!id_name_addr) {
+		return -1;
+	}
+
+	set_id_from_nameaddr(id_name_addr, id);
+
+	if (!id->number.valid) {
+		return -1;
+	}
+
+	return 0;
+}
+
 static int get_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
 {
 	pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
@@ -113,7 +143,7 @@
 
 	ast_party_connected_line_init(&connected);
 
-	if (get_id_from_pai(rdata, &connected.id)) {
+	if (get_id_from_pai(rdata, &connected.id) && get_id_from_rpid(rdata, &connected.id)) {
 		return;
 	}
 	if ((connected.id.number.valid &&
@@ -141,7 +171,7 @@
 	if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
 		/* Initial inbound INVITE. Set the session ID directly */
 		if (session->endpoint->trust_external_id &&
-				!get_id_from_pai(rdata, &session->id)) {
+				(!get_id_from_pai(rdata, &session->id) || !get_id_from_rpid(rdata, &session->id))) {
 			return 0;
 		} 
 		if (session->endpoint->id.number.valid) {




More information about the asterisk-commits mailing list