<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8522">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_rfc3326.c: Account for more than one 'Reason' header<br><br>ASTERISK-27741<br><br>Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf<br>---<br>M res/res_pjsip_rfc3326.c<br>1 file changed, 26 insertions(+), 23 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c<br>index f467e22..b4438a0 100644<br>--- a/res/res_pjsip_rfc3326.c<br>+++ b/res/res_pjsip_rfc3326.c<br>@@ -36,32 +36,35 @@<br> <br> static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)<br> {<br>-     const pj_str_t str_reason = { "Reason", 6 };<br>-       pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);<br>-        char buf[20], *cause, *text;<br>+ static const pj_str_t str_reason = { "Reason", 6 };<br>+        pjsip_generic_string_hdr *header;<br>+    char buf[20];<br>+        char *cause;<br>+ char *text;<br>   int code;<br> <br>- if (!header) {<br>-               return;<br>+      header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);<br>+  for (; header;<br>+               header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, header->next)) {<br>+             ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));<br>+           cause = ast_skip_blanks(buf);<br>+<br>+             if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {<br>+                      continue;<br>+            }<br>+<br>+         /* If text is present get rid of it */<br>+               if ((text = strstr(cause, ";"))) {<br>+                 *text = '\0';<br>+                }<br>+<br>+         if (sscanf(cause, "cause=%30d", &code) != 1) {<br>+                 continue;<br>+            }<br>+<br>+         ast_channel_hangupcause_set(session->channel, code & 0x7f);<br>+           break;<br>        }<br>-<br>- ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));<br>-   cause = ast_skip_blanks(buf);<br>-<br>-     if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {<br>-              return;<br>-      }<br>-<br>- /* If text is present get rid of it */<br>-       if ((text = strstr(cause, ";"))) {<br>-         *text = '\0';<br>-        }<br>-<br>- if (sscanf(cause, "cause=%30d", &code) != 1) {<br>-         return;<br>-      }<br>-<br>- ast_channel_hangupcause_set(session->channel, code & 0x7f);<br> }<br> <br> static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8522">change 8522</a>. To unsubscribe, 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/8522"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I0aa59a54735c6d20b95c54db1bd095dbf93e7adf </div>
<div style="display:none"> Gerrit-Change-Number: 8522 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Ross Beer <ross.beer@voicehost.co.uk> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>