[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> </div>
<div>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. </div>
<div> </div>
<div># 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>
route(SEND_PUSH);<br>
xlog("L_INFO", "tsilo store\n");<br>
ts_store();<br>
}<br>
}<br>
switch ($var(rc)) <br>
{<br>
case 1:<br>
xlog("L_INFO", "LOCATION, Subscriber found, \
RC: $var(rc)\n");<br> route(RELAY);<br>
break; <br>
case -1:<br>
xlog("L_INFO", "LOCATION, Subscriber \
doesn't found, RC: $var(rc)\n");<br> \
exit;<br> break;<br>
case -3:<br>
xlog("L_INFO", "LOCATION, Subscriber doesn't found, \
RC: $var(rc)\n"); <br> \
send_reply("404", "Not Found");<br> \
exit;<br> case -2:<br>
xlog("L_INFO", "LOCATION, Method Not \
Allowed, RC: $var(rc)\n");<br> \
send_reply("405", "Method Not Allowed");<br> \
exit;<br> }<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> # enable additional event routes for forwarded requests<br>
# - serial forking, RTP relaying handling, a.s.o.<br>
if (is_method("INVITE|BYE")) {<br>
if(!t_is_set("branch_route")) \
t_on_branch("MANAGE_BRANCH");<br> }<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
}<br>
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>
if (!is_method("REGISTER")) return;</div>
<div> if(isflagset(FLT_NATS)) <br>
{<br>
setbflag(FLB_NATB);<br>
setbflag(FLB_NATSIPPING);<br>
}<br>
<br>
if(isflagset(FLT_SRC_WSS))<br>
{<br>
setbflag(FLB_DST_WS); <br>
}</div>
<div> if (!save("location")) <br>
{<br>
sl_reply_error();<br>
}<br>
ts_append("location", "$tu")<br>
exit;<br>
}</div>
<div>Next I better show a piece of the log:</div>
<div> </div>
<div>Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 31 14:55:08 /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 /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 \
/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
registrar [lookup.c:456]: lookup_helper(): instance is<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ \
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)<br> Ð¾ÐºÑ 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]<br> Ð¾ÐºÑ 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()<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 31 14:55:08 \
/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
<core> [core/tcp_main.c:2473]: tcpconn_do_send(): sending...<br> Ð¾ÐºÑ 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<br> Ð¾ÐºÑ 31 14:55:08 \
/usr/sbin/kamailio[17488]: DEBUG: {1 2 REGISTER cY6rPubTvJ3ZbyxOrrvGHw..} \
<core> [core/tcp_main.c:2508]: tcpconn_do_send(): buf=</div>
<div> </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 415 \
error. </div>
<div>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.</div>
<div><br>
Thank you.</div>
</div>
<div> </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