ast_websocket_unref(session);
}
+static void save_orig_contact_host(pjsip_rx_data *rdata, pjsip_sip_uri *uri)
+{
+ pjsip_param *x_orig_host;
+ pj_str_t p_value;
+#define COLON_LEN 1
+#define MAX_PORT_LEN 5
+
+ if (rdata->msg_info.msg->type != PJSIP_REQUEST_MSG ||
+ rdata->msg_info.msg->line.req.method.id != PJSIP_REGISTER_METHOD) {
+ return;
+ }
+
+ ast_debug(1, "Saving contact '%.*s:%d'\n",
+ (int)uri->host.slen, uri->host.ptr, uri->port);
+
+ x_orig_host = PJ_POOL_ALLOC_T(rdata->tp_info.pool, pjsip_param);
+ x_orig_host->name = pj_strdup3(rdata->tp_info.pool, "x-ast-orig-host");
+ p_value.slen = pj_strlen(&uri->host) + COLON_LEN + MAX_PORT_LEN;
+ p_value.ptr = (char*)pj_pool_alloc(rdata->tp_info.pool, p_value.slen + 1);
+ p_value.slen = snprintf(p_value.ptr, p_value.slen + 1, "%.*s:%d", (int)uri->host.slen, uri->host.ptr, uri->port);
+ pj_strassign(&x_orig_host->value, &p_value);
+ pj_list_insert_before(&uri->other_param, x_orig_host);
+
+ return;
+}
+
/*!
* \brief Store the transport a message came in on, so it can be used for outbound messages to that contact.
*/
pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);
const pj_str_t *txp_str = &STR_WS;
+ /* Saving the contact on REGISTER so it can be restored on outbound response
+ * This will actually be done by restore_orig_contact_host in res_pjsip_nat, via nat_on_tx_message */
+ save_orig_contact_host(rdata, uri);
+
if (DEBUG_ATLEAST(4)) {
char src_addr_buffer[AST_SOCKADDR_BUFLEN];
const char *ipv6_s = "", *ipv6_e = "";