<p></p>
<h3>Description</h3>
<p>I'm using dispatcher module like:</p>
<pre><code>loadmodule "dispatcher.so"
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_ping_interval", 60)
</code></pre>
<p>With records like:</p>
<pre><code>1 sip:sip.host.com;transport=tls  0 1 socket=tls:111.222.233.10:5061;ping_from=sip:my-domain-01.com
2 sip:sip.host.com;transport=tls  0 1 socket=tls:111.222.233.20:5061;ping_from=sip:my-domain-02.com
</code></pre>
<p>In event_route[tm:local-request] I'm modifying 'Contact' and would like to specify what client TLS profile to use via server name or server id.</p>
<pre><code>event_route[tm:local-request] {
        if(is_method("OPTIONS")) {
               append_hf("Contact: <sip:some-host.com;transport=tls>\r\n");
               $xavp(tls=>server_name)=$fd;
               $xavp(tls[0]=>server_id)=$fd;
        }
}
</code></pre>
<p>Setting 'tls' xavp doesn't make any difference and default client TLS profile is being used.</p>
<p>It happens because in src/modules/tm/uac.c there is a code:</p>
<pre><code>t_run_local_req()
...
        tm_xdata_swap(new_cell, &backup_xd, 0);
...
        /* restore original environment */
        tm_xdata_swap(new_cell, &backup_xd, 1);
</code></pre>
<p>which resets any xavp changes done in event_route[tm:local-request].</p>
<p>Expected behaviour: ability to use xavp in  tm:local-request route. That would allow to choose TLS client profile for dispatcher initiated requests.</p>
<h3>Possible Solutions</h3>
<p>As a hack, in tm_xdata_swap() for mode=1, don't restore xavp list if it was NULL.</p>
<pre><code>if (x->xavps_list != NULL && *x->xavps_list==NULL) {
//  .... don't restore empty list...
} else { 
        xavp_set_list(x->xavps_list);
}
</code></pre>
<p>This change allows to select required TLS profile for dispatcher requests.</p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.3.5 (x86_64/linux) ff2f8c-dirty
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: ff2f8c -dirty
compiled on 10:19:05 Jul 28 2020 with gcc 7.5.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>
<pre><code>Linux xx 4.15.0-111-generic #112-Ubuntu SMP Thu Jul 9 20:32:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2413">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZKB5DZWX7ICHFJW2B3R537HDANCNFSM4PKXAVVA">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZK5E3Z5MZKEGUBJAQLR537HDA5CNFSM4PKXAVVKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4J6FBX6A.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2413",
"url": "https://github.com/kamailio/kamailio/issues/2413",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>