[Asterisk-code-review] res pjsip caller id: Add "party" parameter to RPID header. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Tue Aug 14 08:55:02 CDT 2018


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/9862


Change subject: res_pjsip_caller_id: Add "party" parameter to RPID header.
......................................................................

res_pjsip_caller_id: Add "party" parameter to RPID header.

This change adds the "party" parameter to the Remote-Party-ID header
which indicates which party the header information is applicable
to. In Asterisk this is determined on whether we are the calling
or called party. This is added to improve interoperability with some
implementations.

ASTERISK-28006

Change-Id: I1eec3e377ffff8633b5c1dd59a05e9533122cfca
---
M res/res_pjsip_caller_id.c
1 file changed, 29 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/9862/1

diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 0c1325c..d240496 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -545,6 +545,33 @@
 
 /*!
  * \internal
+ * \brief Add party parameter to a Remote-Party-ID header.
+ *
+ * \param tdata The message where the Remote-Party-ID header is
+ * \param hdr The header on which the parameters are being added
+ * \param session The session involved
+ */
+static void add_party_param(pjsip_tx_data *tdata, pjsip_fromto_hdr *hdr, const struct ast_sip_session *session)
+{
+	static const pj_str_t party_str = { "party", 5 };
+	static const pj_str_t calling_str = { "calling", 7 };
+	static const pj_str_t called_str = { "called", 6 };
+	pjsip_param *party;
+
+	/* The party value can't change throughout the lifetime, so it is set only once */
+	party = pjsip_param_find(&hdr->other_param, &party_str);
+	if (party) {
+		return;
+	}
+
+	party = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
+	party->name = party_str;
+	party->value = (session->inv_session->role == PJSIP_ROLE_UAC) ? calling_str : called_str;
+	pj_list_insert_before(&hdr->other_param, party);
+}
+
+/*!
+ * \internal
  * \brief Add privacy and screen parameters to a Remote-Party-ID header.
  *
  * If privacy is requested, then the privacy and screen parameters need to
@@ -632,6 +659,7 @@
 			pj_list_erase(old_rpid);
 		} else {
 			ast_sip_modify_id_header(tdata->pool, old_rpid, id);
+			add_party_param(tdata, old_rpid, session);
 			add_privacy_params(tdata, old_rpid, id);
 			return;
 		}
@@ -647,6 +675,7 @@
 	if (!rpid_hdr) {
 		return;
 	}
+	add_party_param(tdata, rpid_hdr, session);
 	add_privacy_params(tdata, rpid_hdr, id);
 	pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
 }

-- 
To view, visit https://gerrit.asterisk.org/9862
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1eec3e377ffff8633b5c1dd59a05e9533122cfca
Gerrit-Change-Number: 9862
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180814/3ea29b5b/attachment.html>


More information about the asterisk-code-review mailing list