<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16041">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_caller_id: Add ANI2/OLI parsing<br><br>Adds parsing of ANI II digits (Originating<br>Line Information) to PJSIP, on par with<br>what currently exists in chan_sip.<br><br>ASTERISK-29472<br><br>Change-Id: Ifc938a7a7d45ce33999ebf3656a542226f6d3847<br>---<br>M res/res_pjsip_caller_id.c<br>1 file changed, 40 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/16041/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c</span><br><span>index 0b16665..620c0f4 100644</span><br><span>--- a/res/res_pjsip_caller_id.c</span><br><span>+++ b/res/res_pjsip_caller_id.c</span><br><span>@@ -33,6 +33,7 @@</span><br><span> #include "asterisk/channel.h"</span><br><span> #include "asterisk/module.h"</span><br><span> #include "asterisk/callerid.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/conversions.h"</span><br><span> </span><br><span> /*!</span><br><span> * \internal</span><br><span>@@ -121,6 +122,38 @@</span><br><span> </span><br><span> /*!</span><br><span> * \internal</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Set an ANI2 integer based on OLI data in a From header</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This uses the contents of a From header in order to set Originating Line information.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param rdata The incoming message</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param ani2 The ANI2 field to set</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval 0 Successfully parsed From header</span><br><span style="color: hsl(120, 100%, 40%);">+ * \retval non-zero Could not parse From header</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t from = { "From", 4 };</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str1 = { "oli", 3 };</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str2 = { "isup-oli", 8 };</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str3 = { "ss7-oli", 7 };</span><br><span style="color: hsl(120, 100%, 40%);">+ const pjsip_param *oli1, *oli2, *oli3;</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_fromto_hdr *from_hdr = get_id_header(rdata, &from);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!from_hdr) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((oli1 = pjsip_param_find(&from_hdr->other_param, &oli_str1))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_to_int(oli1->value.ptr, ani2);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if ((oli2 = pjsip_param_find(&from_hdr->other_param, &oli_str2))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_to_int(oli2->value.ptr, ani2);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if ((oli3 = pjsip_param_find(&from_hdr->other_param, &oli_str3))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_to_int(oli3->value.ptr, ani2);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</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%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \internal</span><br><span> * \brief Set an ast_party_id structure based on data in a P-Asserted-Identity header</span><br><span> *</span><br><span> * This makes use of \ref set_id_from_hdr for setting name and number. It uses</span><br><span>@@ -371,11 +404,18 @@</span><br><span> static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)</span><br><span> {</span><br><span> if (!session->channel) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_party_caller caller;</span><br><span style="color: hsl(120, 100%, 40%);">+ int ani2;</span><br><span> /*</span><br><span> * Since we have no channel this must be the initial inbound</span><br><span> * INVITE. Set the session ID directly because the channel</span><br><span> * has not been created yet.</span><br><span> */</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (!set_id_from_oli(rdata, &ani2)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_party_caller_init(&caller);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_caller(session->channel)->ani2 = ani2;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> if (session->endpoint->id.trust_inbound</span><br><span> && (!set_id_from_pai(rdata, &session->id)</span><br><span> || !set_id_from_rpid(rdata, &session->id))) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16041">change 16041</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/+/16041"/><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: Ifc938a7a7d45ce33999ebf3656a542226f6d3847 </div>
<div style="display:none"> Gerrit-Change-Number: 16041 </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>