<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Not sure if my previous email was posted due to me being not subscribed to the mailing list so just writing this now (after subscribing) to make sure it gets posted.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 9 May 2019, at 09:38, Ivan Ribakov <<a href="mailto:i.ribakov@zaleos.net" class="">i.ribakov@zaleos.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks for your feedback Henning.<div class=""><br class=""></div><div class="">Regarding dev mailing list, I’ve considered posting here but the description of the mailing list pretty clearly states it’s purpose (“the list is dedicated for discussions related to development version and next steps of Kamailio”) and I didn’t feel like my question belonged here. If that’s not the case, it would be nice if the list’s purpose description could be amended to include all code-related queries, including those coming from users, not just Kamailio developers.</div><div class=""><br class=""></div><div class="">Regarding my question - since my last email I have found the cause of the problem which was unrelated to the code I was using (incorrect SIPp scenario was generating response with a different Via header branch, hence it was discarded). But in the process of debugging, I realised that using tmb.t_request_outside() has some shared memory implications, in particular that it allocates memory for the dlg_t dialog struct. I can see that tm_load.h interface exposes free_dlg() function but what I’m not sure about is whether I have to call it myself, or does tm module takes care of that?</div><div class=""><br class=""></div><div class="">Regarding dlg_transfer.c - thanks for pointing it out, I’ll consider using it as a reference in the future. But I’m still feeling a bit at a loss as there seems to be no other code that uses tmb.t_request_outside() / tmb.t_request_within() specifically, hence my doubts about memory management etc. </div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Ivan</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 9 May 2019, at 07:58, Henning Westerholt <<a href="mailto:hw@skalatan.de" class="">hw@skalatan.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">

<div text="#000000" bgcolor="#FFFFFF" class=""><p class="">Hello Ivan,</p><p class="">this type of questions are better suited to our developer list, not the users list - adding it to CC.<br class="">
</p><p class="">I haven't looked yet that deep into your previous e-mail, but have you already looked e.g. to the dialog module? This does something similar, e.g. bridging an existing dialog. It uses uac_req_t and a TM callback. You find the implementation in dlg_transfer.c,
 e.g. function dlg_bridge(str *from, str *to, str *op, str *bd).</p><p class="">Cheers,</p><p class="">Henning<br class="">
</p>
<div class="moz-cite-prefix">Am 08.05.19 um 09:26 schrieb Ivan Ribakov:<br class="">
</div>
<blockquote type="cite" cite="mid:24FEDFA4-371B-42D2-B1A9-E45B2F8C57AA@zaleos.net" class="">
Anyone with module dev experience here who had to do something similar or used tm_load.h interface for other purposes?<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 7 May 2019, at 16:39, Ivan Ribakov <<a href="mailto:i.ribakov@zaleos.net" class="" moz-do-not-send="true">i.ribakov@zaleos.net</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space;
              line-break: after-white-space;" class="">
I’m working on a custom Kamailio module where I need to send new-dialog and in-dialog requests on timer (hence I’m being forced to generate new messages from C code).
<div class=""><br class="">
</div>
<div class="">So far I’ve been using modules/tm/tm_load.h defined interface to generate messages and handle callbacks. New dialog messages are sent and processed normally. To do that I’m:</div>
<div class=""><br class="">
</div>
<div class="">1. Calling set_uac_request() to define request parameters</div>
<div class="">2. Calling tmb.t_request_outside() to send it outside any existing dialog</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I was able to send in-dialog requests (or so I thought) in a similar fashion, but I soon realised that responses to those requests were dropped because they couldn’t be matched against any known existing transaction. I’m attaching log messages
 that I believe support this theory and I’ve also observed UDP retransmissions.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">tm [t_lookup.c:897]: t_reply_matching(): t_reply_matching: hash 50576 label 0 branch 0</div>
<div class="">tm [t_lookup.c:990]: t_reply_matching(): no matching transaction exists</div>
<div class="">tm [t_lookup.c:993]: t_reply_matching(): failure to match a transaction</div>
<div class="">tm [t_lookup.c:1088]: t_check_msg(): msg (0x5abcb50) id=1 global id=1 T end=(nil)</div>
<div class="">tm [t_reply.c:2195]: reply_received(): transaction not found - (branch -1)</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">The way I’m currently generating in-dialog requests is very similar to what tmb.t_request_outside() does, the main difference being that I do the dialog setup manually, based on the call-ID, cseq and from/to tags (I’m tracking transaction identifiers
 separately) and then pass resulting uac_req_t to tmb.t_request_within() - <a href="https://gist.github.com/IvanRibakov/3302cb286b1f4b786d109b406f2435a2" class="" moz-do-not-send="true">https://gist.github.com/IvanRibakov/3302cb286b1f4b786d109b406f2435a2</a></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Now, the question part - does anyone know what I’m doing wrong/missing? As I mentioned, when looking at the generated message bodies, they look ok to me (left - initial request that started the dialog, right - first in-dialog request), so I’m
 guessing I’m missing some Kamailio internal steps needed to register new transaction.</div>
<div class=""><span id="cid:3802445C-68C9-4423-9A78-305BDB9516EC@home" class=""><kamailio_indialog_req.png></span></div>
<div class=""><br class="">
</div>
<div class="">SIP flow (up to the point when first UDP retransmission happens)</div>
<div class=""><span id="cid:1D497085-3CBB-4FD4-AEBD-C2AE05810728@home" class=""><PastedGraphic-1.png></span></div>
<div class=""><br class="">
</div>
<div class="">I apologise in advance for the bulky question and will be extremely thankful for any guidance.</div>
<div class=""><br class="">
</div>
<div class="">Regards,</div>
<div class="">Ivan</div>
</div>
</div>
</blockquote>
</div>
<br class="">
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Henning Westerholt - <a class="moz-txt-link-freetext" href="https://skalatan.de/blog/">https://skalatan.de/blog/</a>
Kamailio services - <a class="moz-txt-link-freetext" href="https://skalatan.de/services">https://skalatan.de/services</a></pre>
</div>

</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>