<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18531">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, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_transport_websocket: save the original contact host<br><br>This is needed to be able to restore it in REGISTER responses,<br>otherwise the client won't be able to find the contact it created.<br><br>ASTERISK-30042<br><br>Change-Id: I0c5823918199acf09246b3b206fbde66773688f6<br>---<br>M res/res_pjsip_transport_websocket.c<br>1 file changed, 30 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_transport_websocket.c b/res/res_pjsip_transport_websocket.c</span><br><span>index 1b882da..9894a8c 100644</span><br><span>--- a/res/res_pjsip_transport_websocket.c</span><br><span>+++ b/res/res_pjsip_transport_websocket.c</span><br><span>@@ -415,6 +415,32 @@</span><br><span> ast_websocket_unref(session);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void save_orig_contact_host(pjsip_rx_data *rdata, pjsip_sip_uri *uri)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_param *x_orig_host;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_str_t p_value;</span><br><span style="color: hsl(120, 100%, 40%);">+#define COLON_LEN 1</span><br><span style="color: hsl(120, 100%, 40%);">+#define MAX_PORT_LEN 5</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rdata->msg_info.msg->type != PJSIP_REQUEST_MSG ||</span><br><span style="color: hsl(120, 100%, 40%);">+ rdata->msg_info.msg->line.req.method.id != PJSIP_REGISTER_METHOD) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</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%);">+ ast_debug(1, "Saving contact '%.*s:%d'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ (int)uri->host.slen, uri->host.ptr, uri->port);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ x_orig_host = PJ_POOL_ALLOC_T(rdata->tp_info.pool, pjsip_param);</span><br><span style="color: hsl(120, 100%, 40%);">+ x_orig_host->name = pj_strdup3(rdata->tp_info.pool, "x-ast-orig-host");</span><br><span style="color: hsl(120, 100%, 40%);">+ p_value.slen = pj_strlen(&uri->host) + COLON_LEN + MAX_PORT_LEN;</span><br><span style="color: hsl(120, 100%, 40%);">+ p_value.ptr = (char*)pj_pool_alloc(rdata->tp_info.pool, p_value.slen + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ p_value.slen = snprintf(p_value.ptr, p_value.slen + 1, "%.*s:%d", (int)uri->host.slen, uri->host.ptr, uri->port);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_strassign(&x_orig_host->value, &p_value);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_list_insert_before(&uri->other_param, x_orig_host);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*!</span><br><span> * \brief Store the transport a message came in on, so it can be used for outbound messages to that contact.</span><br><span> */</span><br><span>@@ -436,6 +462,10 @@</span><br><span> pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);</span><br><span> const pj_str_t *txp_str = &STR_WS;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Saving the contact on REGISTER so it can be restored on outbound response</span><br><span style="color: hsl(120, 100%, 40%);">+ * This will actually be done by restore_orig_contact_host in res_pjsip_nat, via nat_on_tx_message */</span><br><span style="color: hsl(120, 100%, 40%);">+ save_orig_contact_host(rdata, uri);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (DEBUG_ATLEAST(4)) {</span><br><span> char src_addr_buffer[AST_SOCKADDR_BUFLEN];</span><br><span> const char *ipv6_s = "", *ipv6_e = "";</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/+/18531">change 18531</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/+/18531"/><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: I0c5823918199acf09246b3b206fbde66773688f6 </div>
<div style="display:none"> Gerrit-Change-Number: 18531 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Thomas Guebels <tgu@escaux.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </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>