]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_caller_id: Add "party" parameter to RPID header.
authorJoshua Colp <jcolp@digium.com>
Tue, 14 Aug 2018 12:29:18 +0000 (09:29 -0300)
committerJoshua Colp <jcolp@digium.com>
Tue, 14 Aug 2018 13:55:37 +0000 (10:55 -0300)
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

res/res_pjsip_caller_id.c

index 0c1325c47292d00c9e6d0c50989481d108e88d14..d2404965c49f2c1af31b5346ec2fb1d9acf30292 100644 (file)
@@ -543,6 +543,33 @@ static void add_pai_header(const struct ast_sip_session *session, pjsip_tx_data
        pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)pai_hdr);
 }
 
+/*!
+ * \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.
@@ -632,6 +659,7 @@ static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data
                        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 @@ static void add_rpid_header(const struct ast_sip_session *session, pjsip_tx_data
        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);
 }