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

George Joseph asteriskteam at digium.com
Wed Aug 15 09:44:31 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/9863 )

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(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 64191a7..0ac0fec 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/9863
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I1eec3e377ffff8633b5c1dd59a05e9533122cfca
Gerrit-Change-Number: 9863
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180815/229e5ae0/attachment.html>


More information about the asterisk-code-review mailing list