[prev in list] [next in list] [prev in thread] [next in thread] 

List:       serusers
Subject:    [SR-Users] =?utf-8?q?How_to_intercept_an_INVITE_after_waking_up_?= =?utf-8?q?=28TSILO_module=29_to_c
From:       Oleg Podguyko <podguiko () mail ! ru>
Date:       2019-10-31 15:01:20
Message-ID: 1572534080.717307610 () f481 ! i ! mail ! ru
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]


Hello everybody!
 
Kamailio works as a Registrar. Additionally, rtpengine is deployed next to it. Using \
the module rtpgngine I change SDP. Webrtc <-> SIP calls work fine. RTPengine proxies \
media. It is necessary to understand that when the call comes, I determine what \
Protocol the call came wss/tcp/udp, and then through the command "rtpengine_manage" \
change SDP accordingly. Now I have a new task. Wake up mobile customers through push \
notification. This client may be as WebRTC and also regular SIP. Trying to use TSILO \
module.   
# User location service
route[LOCATION] {
    lookup("location"); 
    $var(rc) = $rc;
    if (is_method("INVITE")) 
    {
        if (t_newtran()) 
        {
            route(SEND_PUSH);
            xlog("L_INFO", "tsilo store\n");
            ts_store();
        }
    }
    switch ($var(rc)) 
    {
    case  1:
            xlog("L_INFO", "LOCATION, Subscriber found, RC: $var(rc)\n");
            route(RELAY);
            break; 
        case -1:
            xlog("L_INFO", "LOCATION, Subscriber doesn't found, RC: $var(rc)\n");
            exit;
            break;
    case -3:
        xlog("L_INFO", "LOCATION, Subscriber doesn't found, RC: $var(rc)\n"); 
            send_reply("404", "Not Found");
            exit;
    case -2:
            xlog("L_INFO", "LOCATION, Method Not Allowed, RC: $var(rc)\n");
            send_reply("405", "Method Not Allowed");
            exit;
    }
}
If a call occurs when the called client is registered, then we go to the \
route(RELAY), which creates a branch in which I change the SDP. Everything works.

route[RELAY] {
    # enable additional event routes for forwarded requests
    # - serial forking, RTP relaying handling, a.s.o.
    if (is_method("INVITE|BYE")) {
        if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
    }
    if (!t_relay()) {
        sl_reply_error();
    }
    exit;
}

And already in MANAGE BRANCH the necessary SDP is put.

If the called party is not registered. In the beginning everything goes well.
I find this caller through a separate server. Send push notification. The client \
successfully registers on kamailio.

# Handle SIP registrations
route[REGISTRAR] {
    if (!is_method("REGISTER")) return;
    if(isflagset(FLT_NATS)) 
    {
    setbflag(FLB_NATB);
    setbflag(FLB_NATSIPPING);
    }
        
    if(isflagset(FLT_SRC_WSS))
    {
        setbflag(FLB_DST_WS); 
    }
    if (!save("location")) 
    {
       sl_reply_error();
    }
    ts_append("location", "$tu")
    exit;
}
Next I better show a piece of the log:
 
окт 31 14:55:08  /usr/sbin/kamailio[17488]: exec: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} *** cfgtrace:request_route=[REGISTRAR] \
c=[/etc/kamailio/kamailio.cfg] l=429 a=26 n=ts_append окт 31 14:55:08  \
/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tsilo \
[ts_append.c:72]: ts_append(): transaction 8800:338205132 found for 1234567890, going \
to append branches окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_lookup.c:1629]: t_lookup_ident_filter(): transaction \
found окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} registrar [lookup.c:255]: lookup_helper(): contact for \
[1234567890] found by address окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 \
REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} registrar [lookup.c:456]: lookup_helper(): \
instance is окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:77]: t_append_branches(): \
transaction 8800:338205132 in status 0 окт 31 14:55:08  /usr/sbin/kamailio[17488]: \
DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:99]: \
t_append_branches(): Call uefn7rvufi112jj5lt91: 0 (1) outgoing branches окт 31 \
14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
tm [t_append_branches.c:126]: t_append_branches(): Current uri \
sip:1234567890@10.10.10.1:58027;transport=TCP;rinstance=727a64a3a59c508f окт 31 \
14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
<core> [core/msg_translator.c:162]: check_via_address(): (50.7.93.27, \
uas7i396ceb5.invalid, 0) окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 \
REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:149]: t_append_branches(): \
added branch [sip:1234567890@10.10.10.1:58027;transport=TCP;rinstance=727a64a3a59c508f] \
with ruid [uloc-5dbacb09-4450-7] окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: \
{1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:163]: \
t_append_branches(): Call uefn7rvufi112jj5lt91: 0 (0) outgoing branches after \
clear_branches() окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} <core> [core/tcp_main.c:2238]: tcpconn_send_put(): send \
from reader (17488 (21)), reusing fd окт 31 14:55:08  /usr/sbin/kamailio[17488]: \
DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} <core> [core/tcp_main.c:2473]: \
tcpconn_do_send(): sending... окт 31 14:55:08  /usr/sbin/kamailio[17488]: DEBUG: {1 2 \
REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} <core> [core/tcp_main.c:2507]: tcpconn_do_send(): \
after real write: c= 0x7fb39dde4c68 n=3131 fd=12 окт 31 14:55:08  \
/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} <core> \
[core/tcp_main.c:2508]: tcpconn_do_send(): buf=  
Thus, the transaction wakes up and the initial INVITE is sent to the new registered \
client without any SDP change! Which eventually leads to  415 error.  Now the \
question itself. Tell me! As me at this moment intercept this INVITE, to it has \
passed through in advance prepared path for changing SDP.

Thank you.
 
--
Oleg Podguyko


[Attachment #5 (text/html)]


<HTML><BODY><div>
<div>
<div>Hello everybody!</div>

<div>&nbsp;</div>

<div>Kamailio works as a Registrar. Additionally, rtpengine is deployed next to it. \
Using the module rtpgngine I change SDP. Webrtc &lt;-&gt; SIP calls work fine. \
RTPengine proxies media. It is necessary to understand that when the call comes, I \
determine what Protocol the call came wss/tcp/udp, and then through the command \
"rtpengine_manage" change SDP accordingly. Now I have a new task. Wake up mobile \
customers through push notification. This client may be as WebRTC and also regular \
SIP. Trying to use&nbsp;TSILO module.&nbsp;</div>

<div>&nbsp;</div>

<div># User location service<br>
route[LOCATION] {<br>
&nbsp; &nbsp; lookup("location");&nbsp;<br>
&nbsp; &nbsp; $var(rc) = $rc;<br>
&nbsp; &nbsp; if (is_method("INVITE"))&nbsp;<br>
&nbsp; &nbsp; {<br>
&nbsp; &nbsp; &nbsp; &nbsp; if (t_newtran())&nbsp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; {<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route(SEND_PUSH);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "tsilo store\n");<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ts_store();<br>
&nbsp; &nbsp; &nbsp; &nbsp; }<br>
&nbsp; &nbsp; }<br>
&nbsp; &nbsp; switch ($var(rc))&nbsp;<br>
&nbsp; &nbsp; {<br>
&nbsp;&nbsp; &nbsp;case &nbsp;1:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "LOCATION, Subscriber found, \
RC: $var(rc)\n");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; route(RELAY);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;&nbsp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; case -1:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "LOCATION, Subscriber \
doesn't found, RC: $var(rc)\n");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
exit;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>
&nbsp;&nbsp; &nbsp;case -3:<br>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xlog("L_INFO", "LOCATION, Subscriber doesn't found, \
RC: $var(rc)\n");&nbsp;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
send_reply("404", "Not Found");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
exit;<br> &nbsp;&nbsp; &nbsp;case -2:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xlog("L_INFO", "LOCATION, Method Not \
Allowed, RC: $var(rc)\n");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
send_reply("405", "Method Not Allowed");<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; exit;<br> &nbsp; &nbsp; }<br>
}</div>

<div>If a call occurs when the called client is registered, then we go to the \
route(RELAY), which creates a branch in which I change the SDP. Everything \
works.</div>

<div><br>
route[RELAY] {</div>

<div>&nbsp;&nbsp; &nbsp;# enable additional event routes for forwarded requests<br>
&nbsp;&nbsp; &nbsp;# - serial forking, RTP relaying handling, a.s.o.<br>
&nbsp;&nbsp; &nbsp;if (is_method("INVITE|BYE")) {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!t_is_set("branch_route")) \
t_on_branch("MANAGE_BRANCH");<br> &nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;if (!t_relay()) {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sl_reply_error();<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;exit;<br>
}</div>

<div><br>
And already in MANAGE BRANCH the necessary SDP is put.</div>

<div><br>
If the called party is not registered. In the beginning everything goes well.<br>
I find this caller through a separate server. Send push notification. The client \
successfully registers on kamailio.</div>

<div><br>
# Handle SIP registrations<br>
route[REGISTRAR] {<br>
&nbsp; &nbsp; if (!is_method("REGISTER")) return;</div>

<div>&nbsp; &nbsp; if(isflagset(FLT_NATS))&nbsp;<br>
&nbsp; &nbsp; {<br>
&nbsp;&nbsp; &nbsp;setbflag(FLB_NATB);<br>
&nbsp;&nbsp; &nbsp;setbflag(FLB_NATSIPPING);<br>
&nbsp; &nbsp; }<br>
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>
&nbsp; &nbsp; if(isflagset(FLT_SRC_WSS))<br>
&nbsp; &nbsp; {<br>
&nbsp; &nbsp; &nbsp; &nbsp; setbflag(FLB_DST_WS);&nbsp;<br>
&nbsp; &nbsp; }</div>

<div>&nbsp; &nbsp; if (!save("location"))&nbsp;<br>
&nbsp; &nbsp; {<br>
&nbsp; &nbsp; &nbsp; &nbsp;sl_reply_error();<br>
&nbsp; &nbsp; }<br>
&nbsp; &nbsp; ts_append("location", "$tu")<br>
&nbsp; &nbsp; exit;<br>
}</div>

<div>Next I better show a piece of the log:</div>

<div>&nbsp;</div>

<div>окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: exec: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} *** cfgtrace:request_route=[REGISTRAR] \
c=[/etc/kamailio/kamailio.cfg] l=429 a=26 n=ts_append<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tsilo \
[ts_append.c:72]: ts_append(): transaction 8800:338205132 found for 1234567890, going \
to append branches<br> окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 \
2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_lookup.c:1629]: t_lookup_ident_filter(): \
transaction found<br> окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 \
REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} registrar [lookup.c:255]: lookup_helper(): contact \
for [1234567890] found by address<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
registrar [lookup.c:456]: lookup_helper(): instance is<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm \
[t_append_branches.c:77]: t_append_branches(): transaction 8800:338205132 in status \
0<br> окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:99]: t_append_branches(): Call \
uefn7rvufi112jj5lt91: 0 (1) outgoing branches<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm \
[t_append_branches.c:126]: t_append_branches(): Current uri \
sip:1234567890@10.10.10.1:58027;transport=TCP;rinstance=727a64a3a59c508f<br> окт \
31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} &lt;core&gt; [core/msg_translator.c:162]: \
check_via_address(): (50.7.93.27, uas7i396ceb5.invalid, 0)<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm \
[t_append_branches.c:149]: t_append_branches(): added branch \
[sip:1234567890@10.10.10.1:58027;transport=TCP;rinstance=727a64a3a59c508f] with ruid \
[uloc-5dbacb09-4450-7]<br> окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: \
{1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} tm [t_append_branches.c:163]: \
t_append_branches(): Call uefn7rvufi112jj5lt91: 0 (0) outgoing branches after \
clear_branches()<br> окт 31 14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 \
REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} &lt;core&gt; [core/tcp_main.c:2238]: \
tcpconn_send_put(): send from reader (17488 (21)), reusing fd<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
&lt;core&gt; [core/tcp_main.c:2473]: tcpconn_do_send(): sending...<br> окт 31 \
14:55:08 &nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER \
cY6rPubTvJ3ZbyxOrrvGHw..} &lt;core&gt; [core/tcp_main.c:2507]: tcpconn_do_send(): \
after real write: c= 0x7fb39dde4c68 n=3131 fd=12<br> окт 31 14:55:08 \
&nbsp;/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
&lt;core&gt; [core/tcp_main.c:2508]: tcpconn_do_send(): buf=</div>

<div>&nbsp;</div>

<div>Thus, the transaction wakes up and the initial INVITE is sent to the new \
registered client without any SDP change! Which eventually leads to &nbsp;415 \
error.&nbsp;</div>

<div>Now the question itself. Tell me! As me at&nbsp;this moment intercept this \
INVITE, to it&nbsp;has passed through in advance prepared path for changing \
SDP.</div>

<div><br>
Thank you.</div>
</div>

<div>&nbsp;</div>

<div data-signature-widget="container">
<div data-signature-widget="content">
<div>--<br>
Oleg Podguyko</div>
</div>
</div>
</div>
</BODY></HTML>


[Attachment #6 (text/plain)]

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic