<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello Oleg,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">quick question – do you already tried to setup a branch_route to interact with the branch?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">t_on_branch(“MANAGE_BRANCH”);<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">branch_route[MANAGE_BRANCH] { …}<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">-- <o:p>
</o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning Westerholt –
</span><span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/blog/"><span lang="EN-GB" style="color:#0563C1">https://skalatan.de/blog/</span></a></span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Kamailio services –
</span><span style="mso-fareast-language:EN-US"><a href="https://gilawa.com/"><span lang="EN-GB" style="color:#0563C1">https://gilawa.com</span></a></span><span style="mso-fareast-language:EN-US">
<span lang="EN-GB"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kamailio Merchandising – </span><a href="https://skalatan.de/merchandising"><span lang="EN-GB" style="color:#0563C1">https://skalatan.de/merchandising</span></a>
<span lang="EN-GB"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org>
<b>On Behalf Of </b>Oleg Podguyko<br>
<b>Sent:</b> Monday, November 18, 2019 10:21 PM<br>
<b>To:</b> sr-users@lists.kamailio.org<br>
<b>Subject:</b> [SR-Users] How to intercept an INVITE after (ts_append)<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Hello everybody!<br>
 <br>
Kamailio works as a Registrar. Additionally, rtpengine is deployed next to it. Using rtpgngine module I proxy media stream via rtpengine(rtpengine_manage()). I change SDP.  SiP2SIP calls work fine. Now I would like to have possibility to "wake up" sip-clients(at
 the android and ios phones) which are usually not on-line via push notification. Trying to use TSILO module. <br>
 <br>
# User location service<br>
route[LOCATION] {<br>
    lookup("location"); <br>
    $var(rc) = $rc;<br>
    if (is_method("INVITE")) <br>
    {<br>
        if (t_newtran()) <br>
        {<br>
            ts_store(); # if it a new transuction ,it will be store for some time.<br>
        }<br>
    }<br>
    switch ($var(rc)) <br>
    {<br>
    case  1:<br>
         route(RELAY);<br>
         break; <br>
    case -1:<br>
         break;<br>
    case -3:<br>
         send_reply("404", "Not Found");<br>
         exit;<br>
    case -2:<br>
         send_reply("405", "Method Not Allowed");<br>
         exit;<br>
    }<br>
}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
# Handle SIP registrations<br>
route[REGISTRAR] {<br>
    if (!is_method("REGISTER")) return;<br>
    if (!save("location")) <br>
    {<br>
        sl_reply_error();<br>
    }<br>
    ts_append("location", "$tu"); # if transuction for this sip-client is exist. The invite will be send. <br>
    exit;<br>
}<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
If the client is not registered at the kamailio during the call. Then such calls are stored through the "ts_store" function for some time. And if during this time the client send register, kamailio  will be sent INVITE to it. But I have the problem. Such calls
 after "wake up"go through a special branch route that I don't know how to intercept. As a result, I can't change SDP(using rtpengite_manage commands) and rtp stream do not proxy via rtpengine… and call failed.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">/usr/sbin/kamailio[9957]: exec: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} *** cfgtrace:request_route=[REGISTRAR] c=[/etc/kamailio/kamailio.cfg] l=428 a=26 n=ts_append<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tsilo [ts_append.c:72]: ts_append(): transaction 36343:92182831 found for 777777777, going to append branches<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_lookup.c:1629]: t_lookup_ident_filter(): transaction found<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} registrar [lookup.c:255]: lookup_helper(): contact for [777777777] found by address<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} registrar [lookup.c:456]: lookup_helper(): instance is<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_append_branches.c:77]: t_append_branches(): transaction 36343:92182831 in status 0<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_append_branches.c:99]: t_append_branches(): Call uvAzTGsEV9N2ReDjmWoo8A..: 0 (1) outgoing branches<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_append_branches.c:126]: t_append_branches(): Current uri
<a href="sip:77777777@95.165.146.181:63618;transport=TCP;rinstance=8b1865b95767b7ba">
sip:77777777@95.165.146.181:63618;transport=TCP;rinstance=8b1865b95767b7ba</a><br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} <core> [core/msg_translator.c:2933]: create_via_hf(): id added: <;i=1>, rcv proto=2<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_append_branches.c:149]: t_append_branches(): added branch [<a href="sip:777777777@95.165.146.181:63618;transport=TCP;rinstance=8b1865b95767b7ba">sip:777777777@95.165.146.181:63618;transport=TCP;rinstance=8b1865b95767b7ba</a>]
 with ruid [uloc-5dd2faa0-26e5-1]<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} tm [t_append_branches.c:163]: t_append_branches(): Call uvAzTGsEV9N2ReDjmWoo8A..: 0 (0) outgoing branches after clear_branches()<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} <core> [core/tcp_main.c:2238]: tcpconn_send_put(): send from reader (9957 (22)), reusing fd<br>
/usr/sbin/kamailio[9957]: DEBUG: {1 2 REGISTER JxPcA9D1hIJ8PmkcnOvI7g..} <core> [core/tcp_main.c:2473]: tcpconn_do_send(): sending...<br>
 <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"> <o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Oleg Podguyko<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>