From: Joshua Colp Date: Tue, 14 Aug 2018 12:29:18 +0000 (-0300) Subject: res_pjsip_caller_id: Add "party" parameter to RPID header. X-Git-Tag: 13.23.0-rc1~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=555516233d0d82be22785da6db31109acb196961;p=thirdparty%2Fasterisk.git 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 --- diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c index 0c1325c472..d2404965c4 100644 --- a/res/res_pjsip_caller_id.c +++ b/res/res_pjsip_caller_id.c @@ -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); }