<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
<blockquote
cite="mid:CAK1NKFsG2L6DkiKqPJoOKfUio7FCO-YN37FhuReUesXDVtEWCg@mail.gmail.com"
type="cite">Hi Daniel, <br>
<br>
thanks for the quick fix and reply.<br>
<br>
What is the easiest way to try this new patch? I'm running
kamailio 3.1.4 and there is no t_flush_flags() in tmx module in
that version. I suppose I need to install Kamailio Devel from git
(<a moz-do-not-send="true"
href="http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git">http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git</a>)
to get t_flush flags() and your patch or is there a workaround to
apply them to my 3.1.4 branch?<br>
</blockquote>
<br>
did you install 3.1.4 from tarball/packages or is it from git branch
3.1? If later, then you can do:<br>
<br>
git pull origin<br>
git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f<br>
git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05<br>
<br>
then recompile/install. First cherry-pick brings the t_flush_flags,
the second auto-update of the flags after branch/failure route.<br>
<br>
If you installed from packages, then you would need to repackage
yourself after patching. The patches are available at commit url,
for example:<br>
<br>
<a class="moz-txt-link-freetext" href="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05</a><br>
<br>
There you find at top of the page a link named 'patch' that you can
use with git tools to apply or extract the diff-patch part and apply
with patch.<br>
<br>
Cheers,<br>
Daniel<br>
<blockquote
cite="mid:CAK1NKFsG2L6DkiKqPJoOKfUio7FCO-YN37FhuReUesXDVtEWCg@mail.gmail.com"
type="cite">
<br>
Cheers<br>
Ozren<br>
<br>
<br>
<div class="gmail_quote">On Tue, Sep 6, 2011 at 2:18 PM,
Daniel-Constantin Mierla <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:miconda@gmail.com">miconda@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
<br>
can you use t_flush_flags() after setting the accounting
flag in falure_route? Automatic update was missing so far,
reported by Alex Hermann as well. I just did a patch, so if
you want to try it, see the commit:<br>
<br>
<a moz-do-not-send="true"
href="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05"
target="_blank">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05</a><br>
<br>
Actually, reporting if all goes fine with this patch, will
help in backporting it to 3.1 branch.<br>
<br>
Thanks,<br>
Daniel
<div>
<div class="h5"><br>
<br>
On 9/5/11 2:41 PM, Ozren Lapcevic wrote: </div>
</div>
<blockquote type="cite">
<div>
<div class="h5">Hi,<br>
<br>
I'm having some problems accounting missed serial
forked calls to mysql database. <br>
<br>
I have following setup. Each user can have up to two
contacts: telephone number (routed to asterisk) and
SIP URI. Users can specify which contact has higher
priority - which one should ring first. There is also
SEMS voicemail which is forked as 3rd serial call leg
if there is no answer at first two contacts.<br>
<br>
For example, I have two users: <a
moz-do-not-send="true" href="mailto:oz@abc.hr"
target="_blank">oz@abc.hr</a> and <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a>. <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a> also has set
telephone number as alternative number if he is not
reachable at <a moz-do-not-send="true"
href="mailto:sip%3Apero@abc.hr" target="_blank">sip:pero@abc.hr</a>.
Moreover, <a moz-do-not-send="true"
href="mailto:pero@abc.hr" target="_blank">pero@abc.hr</a>
has voicemail turned on. When <a
moz-do-not-send="true" href="mailto:oz@abc.hr"
target="_blank">oz@abc.hr</a> calls <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a>, first <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a>'s SIP client rings,
then if there is no answer and after the timeout
telephone number rings and finally, if there is no
answer at telephone and after the timeout INVITE is
forked to SEMS.<br>
<br>
There are two interesting scenarios accounting-wise
which can happened:<br>
1. <a moz-do-not-send="true" href="mailto:oz@abc.hr"
target="_blank">oz@abc.hr</a> calls <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a>, there are no
answers and call is forked to voicemail.<br>
2. <a moz-do-not-send="true" href="mailto:oz@abc.hr"
target="_blank">oz@abc.hr</a> calls <a
moz-do-not-send="true" href="mailto:pero@abc.hr"
target="_blank">pero@abc.hr</a>, there is no answer
at SIP client, but pero answers call at telephone.<br>
<br>
When scenario 1 happens, I want to have only one log
(row) in missed_calls table.<br>
<br>
When scenario 2 happens, I don't want to have a log in
missed_calls table.<br>
<br>
To accomplish this,<b> I want to log only the 2nd
branch of the forked call. However, there is either
a bug in acc module or I'm doing something wrong,
and I can't get Kamailio to log only the 2nd branch</b>.
I think that I am setting the FLT_ACCMISSED flag
correctly - after the 2nd branch is handled and prior
to calling the RELAY route. Logs show that
FLT_ACCMISSED flag is set prior to calling t_relay(),
and there are no errors in debug log. I am using $ru =
"something" to rewrite URI prior to forking request. <br>
<br>
I can easily set up logging of every call (two missed
calls for serially forked call to two locations) by
setting FLT_ACCMISSED flag for each INVITE. I can set
up logging of every call's 1st branch, by reseting
FLT_ACCMISSED flag when handling 2nd branch of the
call. Interestingly, logging of only the 2nd branch of
the serial forked call works when there is no forking
to voicemail! <br>
<br>
Any ideas how to solve this problem? <br>
<br>
Bellow are important parts of my config file. I'm
running kamailio 3.1.4.<br>
<br>
Cheers<br>
Ozren<br>
<br>
<br>
# ----- acc params -----<br>
/* what special events should be accounted ? */<br>
modparam("acc", "early_media", 0)<br>
modparam("acc", "report_ack", 1)<br>
modparam("acc", "report_cancels", 0)<br>
modparam("acc", "detect_direction", 0)<br>
/* account triggers (flags) */<br>
modparam("acc", "log_flag", FLT_ACC)<br>
modparam("acc", "log_missed_flag", FLT_ACCMISSED)<br>
modparam("acc", "failed_transaction_flag",
FLT_ACCFAILED)<br>
modparam("acc",
"log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")<br>
/* enhanced DB accounting */<br>
#!ifdef WITH_ACCDB<br>
modparam("acc", "db_flag", FLT_ACC)<br>
modparam("acc", "db_missed_flag", FLT_ACCMISSED)<br>
modparam("acc", "db_url", DBURL)<br>
modparam("acc", "db_extra",
"src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si")<br>
#!endif<br>
<br>
...<br>
<br>
<br>
# Main SIP request routing logic<br>
# - processing of any incoming SIP request starts with
this route<br>
route {<br>
<br>
# per request initial checks<br>
route(REQINIT);<br>
<br>
if (src_ip != ****) {<br>
# NAT detection<br>
route(NAT);<br>
}<br>
<br>
# handle requests within SIP dialogs<br>
route(WITHINDLG);<br>
<br>
### only initial requests (no To tag)<br>
<br>
# CANCEL processing<br>
if (is_method("CANCEL"))<br>
{<br>
if (t_check_trans())<br>
t_relay();<br>
exit;<br>
}<br>
<br>
t_check_trans();<br>
<br>
# authentication<br>
route(AUTH);<br>
<br>
# record routing for dialog forming requests
(in case they are routed)<br>
# - remove preloaded route headers<br>
remove_hf("Route");<br>
if (is_method("INVITE|SUBSCRIBE"))<br>
record_route();<br>
<br>
# account only INVITEs<br>
if (is_method("INVITE"))<br>
{<br>
setflag(FLT_ACC); # do accounting<br>
}<br>
<br>
# dispatch requests to foreign domains<br>
route(SIPOUT);<br>
<br>
### requests for my local domains<br>
<br>
# handle presence related requests<br>
route(PRESENCE);<br>
<br>
# handle registrations<br>
route(REGISTRAR);<br>
<br>
if ($rU==$null)<br>
{<br>
# request with no Username in RURI<br>
sl_send_reply("484","Address
Incomplete");<br>
exit;<br>
}<br>
<br>
# dispatch destinations to PSTN<br>
route(PSTN);<br>
<br>
if ( is_method("INVITE") ) {<br>
route(DBALIASES);<br>
#check for user defined forking
priorities and timers<br>
route(FORK);<br>
}<br>
<br>
# user location service<br>
route(LOCATION);<br>
<br>
route(RELAY);<br>
}<br>
<br>
<br>
<br>
#check for user defined forking priorities and timers<br>
route[FORK]{<br>
sql_query("con", "select * from
usr_pref_custom where uuid='$tu'", "pref");<br>
<br>
$avp(uuid)=$dbr(pref=>[0,0]);<br>
$avp(email)=$dbr(pref=>[0,1]);<br>
$avp(prio1)=$dbr(pref=>[0,2]);<br>
$avp(prio2)=$dbr(pref=>[0,3]);<br>
$avp(timer1)=$dbr(pref=>[0,5]);<br>
$avp(timer2)=$dbr(pref=>[0,6]);<br>
<br>
if (strlen($avp(prio1))>5) {<br>
<br>
# user has multiple contacts, do
serial forking<br>
setflag(FLT_USRPREF);<br>
<br>
# set counter<br>
if (!$avp(prio)) {<br>
$avp(prio) = 1;<br>
}<br>
<br>
# overwrite request URI with highest
priority contact<br>
if ($avp(prio1) =~ "^<a
moz-do-not-send="true">sip:00</a>") {<br>
$ru = $avp(prio1) + "@host";<br>
xlog("L_INFO","PRIO 1 is tel
number, RURI set: $ru");<br>
}<br>
else {<br>
$ru = $avp(prio1);<br>
xlog("L_INFO","PRIO 1 is SIP
URI, RURI set: $ru");<br>
}<br>
}<br>
}<br>
<br>
<br>
route[RELAY] {<br>
#!ifdef WITH_NAT<br>
if (check_route_param("nat=yes")) {<br>
setbflag(FLB_NATB);<br>
}<br>
if (isflagset(FLT_NATS) ||
isbflagset(FLB_NATB)) {<br>
route(RTPPROXY);<br>
}<br>
#!endif<br>
<br>
/* example how to enable some additional event
routes */<br>
if (is_method("INVITE")) {<br>
<br>
t_on_reply("REPLY_ONE");<br>
t_on_failure("FAIL_ONE");<br>
<br>
#if users have priorities set, use
FAIL_FORK failure route<br>
if ( isflagset(FLT_USRPREF) ) {<br>
t_on_failure("FAIL_FORK");<br>
}<br>
}<br>
<br>
if (isflagset(FLT_ACCMISSED))
xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS
SET");<br>
else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED
FLAG IS NOT SET");<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
}<br>
exit;<br>
}<br>
<br>
<br>
# Handle requests within SIP dialogs<br>
route[WITHINDLG] {<br>
if (has_totag()) {<br>
# sequential request withing a dialog
should<br>
# take the path determined by
record-routing<br>
if (loose_route()) {<br>
xlog("L_INFO","WITHINDLG,
loose_route()");<br>
if (is_method("BYE")) {<br>
xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING");<br>
setflag(FLT_ACC); # do
accounting ...<br>
setflag(FLT_ACCFAILED); # ... even if the transaction
fails<br>
}<br>
route(RELAY);<br>
} else {<br>
if (is_method("SUBSCRIBE")
&& uri == myself) {<br>
# in-dialog subscribe
requests<br>
route(PRESENCE);<br>
exit;<br>
}<br>
if ( is_method("ACK") ) {<br>
if ( t_check_trans() )
{<br>
# no
loose-route, but stateful ACK;<br>
# must be an
ACK after a 487<br>
# or e.g. 404
from upstream server<br>
t_relay();<br>
exit;<br>
} else {<br>
# ACK without
matching transaction ... ignore and discard<br>
exit;<br>
}<br>
}<br>
sl_send_reply("404","Not
here");<br>
}<br>
exit;<br>
}<br>
}<br>
<br>
<br>
# USER location service<br>
route[LOCATION] {<br>
<br>
#skip if $ru is telephone number<br>
if ($ru =~ "^<a moz-do-not-send="true">sip:00</a>")
{<br>
xlog("L_INFO","SKIP lookup...");<br>
}<br>
else {<br>
if (!lookup("location")) {<br>
switch ($rc) {<br>
case -1:<br>
case -3:<br>
t_newtran();<br>
t_reply("404",
"Not Found");<br>
exit;<br>
case -2:<br>
sl_send_reply("405", "Method Not Allowed");<br>
exit;<br>
}<br>
}<br>
}<br>
<br>
# when routing via usrloc, log the missed
calls also, but only if user doesn't have prios set<br>
if ( is_method("INVITE") &&
!(isflagset(FLT_USRPREF))) {<br>
setflag(FLT_ACCMISSED);<br>
}<br>
}<br>
<br>
<br>
# Failure route for forked calls<br>
failure_route[FAIL_FORK] {<br>
#!ifdef WITH_NAT<br>
if (is_method("INVITE") &&
(isbflagset(FLB_NATB) || isflagset(FLT_NATS))) {<br>
unforce_rtp_proxy();<br>
}<br>
#!endif<br>
<br>
if ($avp(prio) >= 1) {<br>
$avp(prio) = $avp(prio) + 1;<br>
<br>
# handle 2nd branch<br>
if ( ($avp(prio) == 2) && (
isflagset(FLT_USRPREF) )) {<br>
t_on_failure("FAIL_FORK");<br>
<br>
if ($avp(prio2) =~ "^<a
moz-do-not-send="true">sip:00</a>") {<br>
xlog("L_INFO","FAIL
FORK, PRIO 2 is tel number");<br>
$ru = $avp(prio2) +
"@host";<br>
}<br>
else {<br>
xlog("L_INFO","FAIL
FORK, PRIO 2 is SIP URI");<br>
$ru = $avp(prio2);<br>
route(LOCATION);<br>
}<br>
setflag(FLT_ACCMISSED);<br>
}<br>
<br>
else {<br>
$avp(prio) = 0;<br>
$ru = $(avp(uuid));<br>
rewritehostport("host:port");<br>
xlog("L_INFO","FAIL FORK,
VOICEMAIL email:$avp(email), ru:$ru, br: $br");<br>
append_hf("P-App-Name:
voicemail\r\n");<br>
append_hf("P-App-Param:
Email-Address=$avp(email)\r\n");<br>
}<br>
route(RELAY);<br>
}<br>
<br>
if (t_is_canceled()) {<br>
exit;<br>
}<br>
} <br>
<fieldset></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<font color="#888888"> <br>
<pre cols="72">--
Daniel-Constantin Mierla -- <a moz-do-not-send="true" href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Kamailio Advanced Training, Oct 10-13, Berlin: <a moz-do-not-send="true" href="http://asipto.com/u/kat" target="_blank">http://asipto.com/u/kat</a>
<a moz-do-not-send="true" href="http://linkedin.com/in/miconda" target="_blank">http://linkedin.com/in/miconda</a> -- <a moz-do-not-send="true" href="http://twitter.com/miconda" target="_blank">http://twitter.com/miconda</a></pre>
</font></div>
</blockquote>
</div>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Kamailio Advanced Training, Oct 10-13, Berlin: <a class="moz-txt-link-freetext" href="http://asipto.com/u/kat">http://asipto.com/u/kat</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a></pre>
</body>
</html>