<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16279">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_nat: Don't rewrite Contact on REGISTER responses.<br><br>When sending a SIP response to an incoming REGISTER request<br>we don't want to change the Contact header as it will<br>contain the Contacts registered to the AOR and not our own<br>Contact URI.<br><br>ASTERISK-29235<br><br>Change-Id: I35a0723545281dd01fcd5cae497baab58720478c<br>(cherry picked from commit d65041ebea0d54b5306419866a08e6e171fb444d)<br>---<br>M res/res_pjsip_nat.c<br>1 file changed, 18 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_nat.c b/res/res_pjsip_nat.c</span><br><span>index dc7d10b..9fc6a67 100644</span><br><span>--- a/res/res_pjsip_nat.c</span><br><span>+++ b/res/res_pjsip_nat.c</span><br><span>@@ -406,12 +406,24 @@</span><br><span>  }</span><br><span> </span><br><span>        if (!ast_sockaddr_isnull(&transport_state->external_signaling_address)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                /* Update the contact header with the external address */</span><br><span style="color: hsl(0, 100%, 40%);">-               if (uri || (uri = nat_get_contact_sip_uri(tdata))) {</span><br><span style="color: hsl(0, 100%, 40%);">-                    pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));</span><br><span style="color: hsl(0, 100%, 40%);">-                        if (transport->external_signaling_port) {</span><br><span style="color: hsl(0, 100%, 40%);">-                            uri->port = transport->external_signaling_port;</span><br><span style="color: hsl(0, 100%, 40%);">-                           ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port);</span><br><span style="color: hsl(120, 100%, 40%);">+            pjsip_cseq_hdr *cseq = PJSIP_MSG_CSEQ_HDR(tdata->msg);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           /* Update the Contact header with the external address. We only do this if</span><br><span style="color: hsl(120, 100%, 40%);">+             * a CSeq is not present (which should not happen - but we are extra safe),</span><br><span style="color: hsl(120, 100%, 40%);">+            * if a request is being sent, or if a response is sent that is not a response</span><br><span style="color: hsl(120, 100%, 40%);">+                 * to a REGISTER. We specifically don't do this for a response to a REGISTER</span><br><span style="color: hsl(120, 100%, 40%);">+               * as the Contact headers would contain the registered Contacts, and not our</span><br><span style="color: hsl(120, 100%, 40%);">+           * own Contact.</span><br><span style="color: hsl(120, 100%, 40%);">+                */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!cseq || tdata->msg->type == PJSIP_REQUEST_MSG ||</span><br><span style="color: hsl(120, 100%, 40%);">+                   pjsip_method_cmp(&cseq->method, &pjsip_register_method)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 /* We can only rewrite the URI when one is present */</span><br><span style="color: hsl(120, 100%, 40%);">+                 if (uri || (uri = nat_get_contact_sip_uri(tdata))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                          pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));</span><br><span style="color: hsl(120, 100%, 40%);">+                              if (transport->external_signaling_port) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                  uri->port = transport->external_signaling_port;</span><br><span style="color: hsl(120, 100%, 40%);">+                                 ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port);</span><br><span style="color: hsl(120, 100%, 40%);">+                            }</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/+/16279">change 16279</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/+/16279"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: certified/16.8 </div>
<div style="display:none"> Gerrit-Change-Id: I35a0723545281dd01fcd5cae497baab58720478c </div>
<div style="display:none"> Gerrit-Change-Number: 16279 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.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>