<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18830">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Add custom parameter support.<br><br>Adds support for custom URI parameters in the From<br>header in PJSIP. This is often imperative when doing<br>SS7 over SIP, and this helps bring us closer to<br>feature parity with chan_sip.<br><br>ASTERISK-30150 #close<br><br>Change-Id: Ifb1bc3c512ad5f6faeaebd7817f004a2ecbd6428<br>---<br>A doc/CHANGES-staging/res_pjsip_session_params.txt<br>M res/res_pjsip_session.c<br>2 files changed, 42 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/30/18830/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_pjsip_session_params.txt b/doc/CHANGES-staging/res_pjsip_session_params.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..06a061c</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_session_params.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_pjsip_session</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+It is now possible to set custom URI parameters</span><br><span style="color: hsl(120, 100%, 40%);">+in the From header in an outgoing call through</span><br><span style="color: hsl(120, 100%, 40%);">+the SIPURIPARAMETERS variable on a channel.</span><br><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index d4a857f..824501b 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -1645,7 +1645,7 @@</span><br><span> pjsip_sip_uri *dlg_info_uri;</span><br><span> pjsip_sip_uri *dlg_contact_uri;</span><br><span> int restricted;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *pjsip_from_domain;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *pjsip_from_domain, *pjsip_uri_params;</span><br><span> </span><br><span> if (!session->channel || session->saved_from_hdr) {</span><br><span> return;</span><br><span>@@ -1699,6 +1699,42 @@</span><br><span> ast_sip_session_get_name(session), pjsip_from_domain);</span><br><span> pj_strdup2(dlg_pool, &dlg_info_uri->host, pjsip_from_domain);</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set URI (inside the <>, as opposed to header (outside the <>)) parameters, if requested.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This is often necessary for SS7 trunking over SIP. Most carriers require</span><br><span style="color: hsl(120, 100%, 40%);">+ * that added parameters be URI parameters (as opposed to header parameters).</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * other_param is how to add custom URI parameters to the header</span><br><span style="color: hsl(120, 100%, 40%);">+ * XXX: header_param is for header parameters, but doesn't seem to work at the moment.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Especially when dealing with SS7 or TDM elements over SIP,</span><br><span style="color: hsl(120, 100%, 40%);">+ * injecting parameters into the user and/or method parameters</span><br><span style="color: hsl(120, 100%, 40%);">+ * is required.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * For example, if wanted to set the isup-oli parameter to the channel's ANI2 value:</span><br><span style="color: hsl(120, 100%, 40%);">+ * e.g. pjsip_param_add(dlg_pool, &dlg_info_uri->other_param, "isup-oli", ani2);</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define pjsip_param_add(pool, list, pname, pvalue) { \</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_param *param; \</span><br><span style="color: hsl(120, 100%, 40%);">+ param = PJ_POOL_ALLOC_T(pool, pjsip_param); \</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_strdup2(pool, ¶m->name, pname); \</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_strdup2(pool, ¶m->value, pvalue); \</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_list_insert_before(list, param); \</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Add any URI parameters that we find on the channel */</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_uri_params = pbx_builtin_getvar_helper(session->channel, "SIPURIPARAMETERS");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pjsip_uri_params)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *params, *param_name, *param_value;</span><br><span style="color: hsl(120, 100%, 40%);">+ params = ast_strdupa(pjsip_uri_params);</span><br><span style="color: hsl(120, 100%, 40%);">+ while ((param_value = strsep(¶ms, ","))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ param_name = strsep(¶m_value, "=");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Adding URI parameter to From header: %s=%s\n", param_name, S_OR(param_value, ""));</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_param_add(dlg_pool, &dlg_info_uri->other_param, param_name, S_OR(param_value, ""));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+#undef pjsip_param_add</span><br><span> ast_channel_unlock(session->channel);</span><br><span> </span><br><span> /* We need to save off the non-anonymized From for RPID/PAI generation (for domain) */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18830">change 18830</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/18830"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ifb1bc3c512ad5f6faeaebd7817f004a2ecbd6428 </div>
<div style="display:none"> Gerrit-Change-Number: 18830 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>