<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16632">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_callerid: Fix OLI parsing<br><br>Fix parsing of ANI2/OLI information, since it was previously<br>parsing the user, when it should have been parsing other_param.<br><br>Also improves the parsing by using pjproject native functions<br>rather than trying to parse the parameters ourselves like<br>chan_sip did. A previous attempt at this caused a crash, but<br>this works correctly now.<br><br>ASTERISK-29703 #close<br><br>Change-Id: I8f3c79032d9ea1a21d16f8e11f22bd8d887738a1<br>---<br>M res/res_pjsip_caller_id.c<br>1 file changed, 18 insertions(+), 29 deletions(-)<br><br></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 3b871cd..f1c89ee 100644</span><br><span>--- a/res/res_pjsip_caller_id.c</span><br><span>+++ b/res/res_pjsip_caller_id.c</span><br><span>@@ -133,43 +133,32 @@</span><br><span> */</span><br><span> static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- char fromhdr[AST_CHANNEL_NAME];</span><br><span style="color: hsl(0, 100%, 40%);">- const char *s = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_sip_uri *uri;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_name_addr *id_name_addr;</span><br><span style="color: hsl(120, 100%, 40%);">+ char oli[AST_CHANNEL_NAME];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_param *oli1, *oli2, *oli3;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str1 = { "isup-oli", 8 };</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str2 = { "ss7-oli", 7 };</span><br><span style="color: hsl(120, 100%, 40%);">+ static const pj_str_t oli_str3 = { "oli", 3 };</span><br><span> </span><br><span> pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,</span><br><span> PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);</span><br><span style="color: hsl(0, 100%, 40%);">- id_name_addr = (pjsip_name_addr *) from->uri;</span><br><span> </span><br><span> if (!from) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* This had better not happen */</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1; /* This had better not happen */</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%);">+ if ((oli1 = pjsip_param_find(&from->other_param, &oli_str1))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_pj_str(oli, &oli1->value, sizeof(oli));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if ((oli2 = pjsip_param_find(&from->other_param, &oli_str2))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_pj_str(oli, &oli2->value, sizeof(oli));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if ((oli3 = pjsip_param_find(&from->other_param, &oli_str3))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_pj_str(oli, &oli3->value, sizeof(oli));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- uri = pjsip_uri_get_uri(id_name_addr);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_pj_str(fromhdr, &uri->user, sizeof(fromhdr));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Look for the possible OLI tags. */</span><br><span style="color: hsl(0, 100%, 40%);">- if ((s = strcasestr(fromhdr, ";isup-oli="))) {</span><br><span style="color: hsl(0, 100%, 40%);">- s += 10;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if ((s = strcasestr(fromhdr, ";ss7-oli="))) {</span><br><span style="color: hsl(0, 100%, 40%);">- s += 9;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if ((s = strcasestr(fromhdr, ";oli="))) {</span><br><span style="color: hsl(0, 100%, 40%);">- s += 5;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(s)) {</span><br><span style="color: hsl(0, 100%, 40%);">- /* OLI tag is missing, or present with nothing following the '=' sign */</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* just in case OLI is quoted */</span><br><span style="color: hsl(0, 100%, 40%);">- if (*s == '\"') {</span><br><span style="color: hsl(0, 100%, 40%);">- s++;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_to_int(s, ani2);</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_to_int(oli, ani2);</span><br><span> }</span><br><span> </span><br><span> /*!</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16632">change 16632</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/+/16632"/><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: I8f3c79032d9ea1a21d16f8e11f22bd8d887738a1 </div>
<div style="display:none"> Gerrit-Change-Number: 16632 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>