Hi,
I'm having some problems accounting missed serial forked calls to mysql database.
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.
For example, I have two users: oz@abc.hr and pero@abc.hr. pero@abc.hr also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr. Moreover, pero@abc.hr has voicemail turned on. When oz@abc.hr calls pero@abc.hr, first pero@abc.hr'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.
There are two interesting scenarios accounting-wise which can happened: 1. oz@abc.hr calls pero@abc.hr, there are no answers and call is forked to voicemail. 2. oz@abc.hr calls pero@abc.hr, there is no answer at SIP client, but pero answers call at telephone.
When scenario 1 happens, I want to have only one log (row) in missed_calls table.
When scenario 2 happens, I don't want to have a log in missed_calls table.
To accomplish this,* 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*. 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.
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!
Any ideas how to solve this problem?
Bellow are important parts of my config file. I'm running kamailio 3.1.4.
Cheers Ozren
# ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif
...
# Main SIP request routing logic # - processing of any incoming SIP request starts with this route route {
# per request initial checks route(REQINIT);
if (src_ip != ****) { # NAT detection route(NAT); }
# handle requests within SIP dialogs route(WITHINDLG);
### only initial requests (no To tag)
# CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; }
t_check_trans();
# authentication route(AUTH);
# record routing for dialog forming requests (in case they are routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route();
# account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting }
# dispatch requests to foreign domains route(SIPOUT);
### requests for my local domains
# handle presence related requests route(PRESENCE);
# handle registrations route(REGISTRAR);
if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; }
# dispatch destinations to PSTN route(PSTN);
if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); }
# user location service route(LOCATION);
route(RELAY); }
#check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref");
$avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]);
if (strlen($avp(prio1))>5) {
# user has multiple contacts, do serial forking setflag(FLT_USRPREF);
# set counter if (!$avp(prio)) { $avp(prio) = 1; }
# overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set: $ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } }
route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif
/* example how to enable some additional event routes */ if (is_method("INVITE")) {
t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE");
#if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } }
if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; }
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } }
# USER location service route[LOCATION] {
#skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } }
# when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } }
# Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif
if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1;
# handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK");
if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); }
else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); }
if (t_is_canceled()) { exit; } }
Hello,
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:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch.
Thanks, Daniel
On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi,
I'm having some problems accounting missed serial forked calls to mysql database.
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.
For example, I have two users: oz@abc.hr mailto:oz@abc.hr and pero@abc.hr mailto:pero@abc.hr. pero@abc.hr mailto:pero@abc.hr also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr mailto:sip%3Apero@abc.hr. Moreover, pero@abc.hr mailto:pero@abc.hr has voicemail turned on. When oz@abc.hr mailto:oz@abc.hr calls pero@abc.hr mailto:pero@abc.hr, first pero@abc.hr mailto:pero@abc.hr'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.
There are two interesting scenarios accounting-wise which can happened:
- oz@abc.hr mailto:oz@abc.hr calls pero@abc.hr
mailto:pero@abc.hr, there are no answers and call is forked to voicemail. 2. oz@abc.hr mailto:oz@abc.hr calls pero@abc.hr mailto:pero@abc.hr, there is no answer at SIP client, but pero answers call at telephone.
When scenario 1 happens, I want to have only one log (row) in missed_calls table.
When scenario 2 happens, I don't want to have a log in missed_calls table.
To accomplish this,*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*. 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.
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!
Any ideas how to solve this problem?
Bellow are important parts of my config file. I'm running kamailio 3.1.4.
Cheers Ozren
# ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif
...
# Main SIP request routing logic # - processing of any incoming SIP request starts with this route route {
# per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are
routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route();
# account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY);
}
#check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref");
$avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set:
$ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } }
route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif
/* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru,
ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; }
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } }
# USER location service route[LOCATION] {
#skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } }
# when routing via usrloc, log the missed calls also, but only
if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } }
# Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif
if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is
tel number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); }
else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL
email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); }
if (t_is_canceled()) { exit; }
}
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hi Daniel,
thanks for the quick fix and reply.
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 ( http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
Cheers Ozren
On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla miconda@gmail.comwrote:
Hello,
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:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch.
Thanks, Daniel
On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi,
I'm having some problems accounting missed serial forked calls to mysql database.
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.
For example, I have two users: oz@abc.hr and pero@abc.hr. pero@abc.hr also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr. Moreover, pero@abc.hr has voicemail turned on. When oz@abc.hr calls pero@abc.hr, first pero@abc.hr'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.
There are two interesting scenarios accounting-wise which can happened:
- oz@abc.hr calls pero@abc.hr, there are no answers and call is forked to
voicemail. 2. oz@abc.hr calls pero@abc.hr, there is no answer at SIP client, but pero answers call at telephone.
When scenario 1 happens, I want to have only one log (row) in missed_calls table.
When scenario 2 happens, I don't want to have a log in missed_calls table.
To accomplish this,* 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*. 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.
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!
Any ideas how to solve this problem?
Bellow are important parts of my config file. I'm running kamailio 3.1.4.
Cheers Ozren
# ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif
...
# Main SIP request routing logic # - processing of any incoming SIP request starts with this route route {
# per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are
routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route();
# account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY);
}
#check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref");
$avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set:
$ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } }
route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif
/* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru,
ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; }
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } }
# USER location service route[LOCATION] {
#skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } }
# when routing via usrloc, log the missed calls also, but only if
user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } }
# Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif
if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel
number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); }
else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL
email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); }
if (t_is_canceled()) { exit; }
}
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel,
thanks for the quick fix and reply.
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 (http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do:
git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05
then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route.
If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
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.
Cheers, Daniel
Cheers Ozren
On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, 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: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch. Thanks, Daniel On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi, I'm having some problems accounting missed serial forked calls to mysql database. 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. For example, I have two users: oz@abc.hr <mailto:oz@abc.hr> and pero@abc.hr <mailto:pero@abc.hr>. pero@abc.hr <mailto:pero@abc.hr> also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr <mailto:sip%3Apero@abc.hr>. Moreover, pero@abc.hr <mailto:pero@abc.hr> has voicemail turned on. When oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, first pero@abc.hr <mailto:pero@abc.hr>'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. There are two interesting scenarios accounting-wise which can happened: 1. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there are no answers and call is forked to voicemail. 2. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there is no answer at SIP client, but pero answers call at telephone. When scenario 1 happens, I want to have only one log (row) in missed_calls table. When scenario 2 happens, I don't want to have a log in missed_calls table. To accomplish this,*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*. 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. 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! Any ideas how to solve this problem? Bellow are important parts of my config file. I'm running kamailio 3.1.4. Cheers Ozren # ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif ... # Main SIP request routing logic # - processing of any incoming SIP request starts with this route route { # per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route(); # account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY); } #check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref"); $avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set: $ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } } route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif /* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; } # Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } } # USER location service route[LOCATION] { #skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } } # Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); } else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); } if (t_is_canceled()) { exit; } } _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hi,
I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb.... I don't know why I can't cherry-pick it.
Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch.
Cheers Ozren
On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla miconda@gmail.comwrote:
Hello,
On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel,
thanks for the quick fix and reply.
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 ( http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do:
git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05
then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route.
If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
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.
Cheers, Daniel
Cheers Ozren
On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
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:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch.
Thanks, Daniel
On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi,
I'm having some problems accounting missed serial forked calls to mysql database.
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.
For example, I have two users: oz@abc.hr and pero@abc.hr. pero@abc.hralso has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr. Moreover, pero@abc.hr has voicemail turned on. When oz@abc.hr calls pero@abc.hr, first pero@abc.hr'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.
There are two interesting scenarios accounting-wise which can happened:
- oz@abc.hr calls pero@abc.hr, there are no answers and call is forked
to voicemail. 2. oz@abc.hr calls pero@abc.hr, there is no answer at SIP client, but pero answers call at telephone.
When scenario 1 happens, I want to have only one log (row) in missed_calls table.
When scenario 2 happens, I don't want to have a log in missed_calls table.
To accomplish this,* 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*. 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.
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!
Any ideas how to solve this problem?
Bellow are important parts of my config file. I'm running kamailio 3.1.4.
Cheers Ozren
# ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif
...
# Main SIP request routing logic # - processing of any incoming SIP request starts with this route route {
# per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are
routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route();
# account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY);
}
#check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref");
$avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set:
$ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } }
route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif
/* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru,
ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; }
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } }
# USER location service route[LOCATION] {
#skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } }
# when routing via usrloc, log the missed calls also, but only if
user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } }
# Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif
if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel
number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); }
else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL
email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); }
if (t_is_canceled()) { exit; }
}
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
when you pulled the GIT branch 3.1, did you use --depth 1, like next?
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
The you just got the snapshot at that time without the history of the commit and probably you did the git clone after I did the commit, a new git pull taking newer commit. So try cloning again the latest branch 3.1, without --depth 1 parameter.
Cheers, Daniel
On 9/7/11 2:20 PM, Ozren Lapcevic wrote:
Hi,
I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb.... I don't know why I can't cherry-pick it.
Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch.
Cheers Ozren
On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel, thanks for the quick fix and reply. 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 (http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do: git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05 then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route. If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 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. Cheers, Daniel
Cheers Ozren On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, 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: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch. Thanks, Daniel On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi, I'm having some problems accounting missed serial forked calls to mysql database. 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. For example, I have two users: oz@abc.hr <mailto:oz@abc.hr> and pero@abc.hr <mailto:pero@abc.hr>. pero@abc.hr <mailto:pero@abc.hr> also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr <mailto:sip%3Apero@abc.hr>. Moreover, pero@abc.hr <mailto:pero@abc.hr> has voicemail turned on. When oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, first pero@abc.hr <mailto:pero@abc.hr>'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. There are two interesting scenarios accounting-wise which can happened: 1. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there are no answers and call is forked to voicemail. 2. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there is no answer at SIP client, but pero answers call at telephone. When scenario 1 happens, I want to have only one log (row) in missed_calls table. When scenario 2 happens, I don't want to have a log in missed_calls table. To accomplish this,*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*. 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. 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! Any ideas how to solve this problem? Bellow are important parts of my config file. I'm running kamailio 3.1.4. Cheers Ozren # ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif ... # Main SIP request routing logic # - processing of any incoming SIP request starts with this route route { # per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route(); # account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY); } #check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref"); $avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set: $ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } } route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif /* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; } # Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } } # USER location service route[LOCATION] { #skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } } # Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); } else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); } if (t_is_canceled()) { exit; } } _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello,
over the weekend I backported the implementation of t_flush_flags() as well as auto-update of transaction flags after branch/failure route. Just pull the latest branch 3.1 and you are ready to compile/install.
Let us know if it solves the case.
Cheers, Daniel
On 9/9/11 2:40 PM, Daniel-Constantin Mierla wrote:
Hello,
when you pulled the GIT branch 3.1, did you use --depth 1, like next?
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
The you just got the snapshot at that time without the history of the commit and probably you did the git clone after I did the commit, a new git pull taking newer commit. So try cloning again the latest branch 3.1, without --depth 1 parameter.
Cheers, Daniel
On 9/7/11 2:20 PM, Ozren Lapcevic wrote:
Hi,
I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb.... I don't know why I can't cherry-pick it.
Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch.
Cheers Ozren
On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel, thanks for the quick fix and reply. 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 (http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do: git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05 then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route. If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 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. Cheers, Daniel
Cheers Ozren On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, 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: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch. Thanks, Daniel On 9/5/11 2:41 PM, Ozren Lapcevic wrote:
Hi, I'm having some problems accounting missed serial forked calls to mysql database. 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. For example, I have two users: oz@abc.hr <mailto:oz@abc.hr> and pero@abc.hr <mailto:pero@abc.hr>. pero@abc.hr <mailto:pero@abc.hr> also has set telephone number as alternative number if he is not reachable at sip:pero@abc.hr <mailto:sip%3Apero@abc.hr>. Moreover, pero@abc.hr <mailto:pero@abc.hr> has voicemail turned on. When oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, first pero@abc.hr <mailto:pero@abc.hr>'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. There are two interesting scenarios accounting-wise which can happened: 1. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there are no answers and call is forked to voicemail. 2. oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>, there is no answer at SIP client, but pero answers call at telephone. When scenario 1 happens, I want to have only one log (row) in missed_calls table. When scenario 2 happens, I don't want to have a log in missed_calls table. To accomplish this,*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*. 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. 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! Any ideas how to solve this problem? Bellow are important parts of my config file. I'm running kamailio 3.1.4. Cheers Ozren # ----- acc params ----- /* what special events should be accounted ? */ modparam("acc", "early_media", 0) modparam("acc", "report_ack", 1) modparam("acc", "report_cancels", 0) modparam("acc", "detect_direction", 0) /* account triggers (flags) */ modparam("acc", "log_flag", FLT_ACC) modparam("acc", "log_missed_flag", FLT_ACCMISSED) modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") /* enhanced DB accounting */ #!ifdef WITH_ACCDB modparam("acc", "db_flag", FLT_ACC) modparam("acc", "db_missed_flag", FLT_ACCMISSED) modparam("acc", "db_url", DBURL) modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_user=$tU;dst_domain=$td;src_ip=$si") #!endif ... # Main SIP request routing logic # - processing of any incoming SIP request starts with this route route { # per request initial checks route(REQINIT); if (src_ip != ****) { # NAT detection route(NAT); } # handle requests within SIP dialogs route(WITHINDLG); ### only initial requests (no To tag) # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); # authentication route(AUTH); # record routing for dialog forming requests (in case they are routed) # - remove preloaded route headers remove_hf("Route"); if (is_method("INVITE|SUBSCRIBE")) record_route(); # account only INVITEs if (is_method("INVITE")) { setflag(FLT_ACC); # do accounting } # dispatch requests to foreign domains route(SIPOUT); ### requests for my local domains # handle presence related requests route(PRESENCE); # handle registrations route(REGISTRAR); if ($rU==$null) { # request with no Username in RURI sl_send_reply("484","Address Incomplete"); exit; } # dispatch destinations to PSTN route(PSTN); if ( is_method("INVITE") ) { route(DBALIASES); #check for user defined forking priorities and timers route(FORK); } # user location service route(LOCATION); route(RELAY); } #check for user defined forking priorities and timers route[FORK]{ sql_query("con", "select * from usr_pref_custom where uuid='$tu'", "pref"); $avp(uuid)=$dbr(pref=>[0,0]); $avp(email)=$dbr(pref=>[0,1]); $avp(prio1)=$dbr(pref=>[0,2]); $avp(prio2)=$dbr(pref=>[0,3]); $avp(timer1)=$dbr(pref=>[0,5]); $avp(timer2)=$dbr(pref=>[0,6]); if (strlen($avp(prio1))>5) { # user has multiple contacts, do serial forking setflag(FLT_USRPREF); # set counter if (!$avp(prio)) { $avp(prio) = 1; } # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") { $ru = $avp(prio1) + "@host"; xlog("L_INFO","PRIO 1 is tel number, RURI set: $ru"); } else { $ru = $avp(prio1); xlog("L_INFO","PRIO 1 is SIP URI, RURI set: $ru"); } } } route[RELAY] { #!ifdef WITH_NAT if (check_route_param("nat=yes")) { setbflag(FLB_NATB); } if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { route(RTPPROXY); } #!endif /* example how to enable some additional event routes */ if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) { t_on_failure("FAIL_FORK"); } } if (isflagset(FLT_ACCMISSED)) xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS SET"); else xlog("L_INFO","RELAY, $rm $ru, ACCMISSED FLAG IS NOT SET"); if (!t_relay()) { sl_reply_error(); } exit; } # Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { # sequential request withing a dialog should # take the path determined by record-routing if (loose_route()) { xlog("L_INFO","WITHINDLG, loose_route()"); if (is_method("BYE")) { xlog("L_INFO","WITHINDLG, BYE, DO ACCOUNTING"); setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } route(RELAY); } else { if (is_method("SUBSCRIBE") && uri == myself) { # in-dialog subscribe requests route(PRESENCE); exit; } if ( is_method("ACK") ) { if ( t_check_trans() ) { # no loose-route, but stateful ACK; # must be an ACK after a 487 # or e.g. 404 from upstream server t_relay(); exit; } else { # ACK without matching transaction ... ignore and discard exit; } } sl_send_reply("404","Not here"); } exit; } } # USER location service route[LOCATION] { #skip if $ru is telephone number if ($ru =~ "^sip:00") { xlog("L_INFO","SKIP lookup..."); } else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { setflag(FLT_ACCMISSED); } } # Failure route for forked calls failure_route[FAIL_FORK] { #!ifdef WITH_NAT if (is_method("INVITE") && (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { unforce_rtp_proxy(); } #!endif if ($avp(prio) >= 1) { $avp(prio) = $avp(prio) + 1; # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") { xlog("L_INFO","FAIL FORK, PRIO 2 is tel number"); $ru = $avp(prio2) + "@host"; } else { xlog("L_INFO","FAIL FORK, PRIO 2 is SIP URI"); $ru = $avp(prio2); route(LOCATION); } setflag(FLT_ACCMISSED); } else { $avp(prio) = 0; $ru = $(avp(uuid)); rewritehostport("host:port"); xlog("L_INFO","FAIL FORK, VOICEMAIL email:$avp(email), ru:$ru, br: $br"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); } if (t_is_canceled()) { exit; } } _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hi,
now I'm using t_flush_flags() after setting the accounting flag in falure_route and latest updates (I have a new 3.1 clone without depth parameter and I've made sure your changes are in sources), but it doesn't solve the case, accounting behavior is still exactly the same as described in the first mail.
If it is of any help, previously I've tested the same scenario where I was setting the accounting flag in RELAY and LOCATION routes which were called from failure route.
Cheers Ozren
On Mon, Sep 12, 2011 at 9:19 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
Hello,
over the weekend I backported the implementation of t_flush_flags() as well as auto-update of transaction flags after branch/failure route. Just pull the latest branch 3.1 and you are ready to compile/install.
Let us know if it solves the case.
Cheers, Daniel
On 9/9/11 2:40 PM, Daniel-Constantin Mierla wrote:
Hello,
when you pulled the GIT branch 3.1, did you use --depth 1, like next?
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
The you just got the snapshot at that time without the history of the commit and probably you did the git clone after I did the commit, a new git pull taking newer commit. So try cloning again the latest branch 3.1, without --depth 1 parameter.
Cheers, Daniel
On 9/7/11 2:20 PM, Ozren Lapcevic wrote:
Hi,
I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb.... I don't know why I can't cherry-pick it.
Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch.
Cheers Ozren
On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel,
thanks for the quick fix and reply.
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 ( http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do:
git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05
then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route.
If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
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.
Cheers, Daniel
Cheers Ozren
On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
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:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch.
Thanks, Daniel
Hello,
On 9/12/11 12:04 PM, Ozren Lapcevic wrote:
Hi,
now I'm using t_flush_flags() after setting the accounting flag in falure_route and latest updates (I have a new 3.1 clone without depth parameter and I've made sure your changes are in sources), but it doesn't solve the case, accounting behavior is still exactly the same as described in the first mail.
If it is of any help, previously I've tested the same scenario where I was setting the accounting flag in RELAY and LOCATION routes which were called from failure route.
can you send the debug messages for such a call (use debug=4 in your config)? Also, set a tm onreply_route[x] for such invite where to print with xlog the value of the flags ($mF).
Cheers, Daniel
Cheers Ozren
On Mon, Sep 12, 2011 at 9:19 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, over the weekend I backported the implementation of t_flush_flags() as well as auto-update of transaction flags after branch/failure route. Just pull the latest branch 3.1 and you are ready to compile/install. Let us know if it solves the case. Cheers, Daniel On 9/9/11 2:40 PM, Daniel-Constantin Mierla wrote:
Hello, when you pulled the GIT branch 3.1, did you use --depth 1, like next? git clone --depth 1 git://git.sip-router.org/sip-router <http://git.sip-router.org/sip-router> kamailio The you just got the snapshot at that time without the history of the commit and probably you did the git clone after I did the commit, a new git pull taking newer commit. So try cloning again the latest branch 3.1, without --depth 1 parameter. Cheers, Daniel On 9/7/11 2:20 PM, Ozren Lapcevic wrote:
Hi, I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb7cd14ee3b509eef72d99337567f53967f. I don't know why I can't cherry-pick it. Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch. Cheers Ozren On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel, thanks for the quick fix and reply. 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 (http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do: git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05 then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route. If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 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. Cheers, Daniel
Cheers Ozren On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, 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: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35b2aa3097a3c9e2a5a050514337300c05 Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch. Thanks, Daniel
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
I have attached log file. I have single onreply_route[REPLY_ONE] used for all replies. Grep "REPLY_ONE, FLAGS" to find where the flags are printed. Grep "FAIL FORK" for logs from failure route.
Let me know if you need anything else.
Cheers Ozren
On Mon, Sep 12, 2011 at 12:35 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
can you send the debug messages for such a call (use debug=4 in your config)? Also, set a tm onreply_route[x] for such invite where to print with xlog the value of the flags ($mF).
Cheers, Daniel
Cheers Ozren
On Mon, Sep 12, 2011 at 9:19 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
over the weekend I backported the implementation of t_flush_flags() as well as auto-update of transaction flags after branch/failure route. Just pull the latest branch 3.1 and you are ready to compile/install.
Let us know if it solves the case.
Cheers, Daniel
On 9/9/11 2:40 PM, Daniel-Constantin Mierla wrote:
Hello,
when you pulled the GIT branch 3.1, did you use --depth 1, like next?
git clone --depth 1 git://git.sip-router.org/sip-router kamailio
The you just got the snapshot at that time without the history of the commit and probably you did the git clone after I did the commit, a new git pull taking newer commit. So try cloning again the latest branch 3.1, without --depth 1 parameter.
Cheers, Daniel
On 9/7/11 2:20 PM, Ozren Lapcevic wrote:
Hi,
I've previously installed kamailio from git branch 3.1. Now, I've manged to git cherry-pick your patch, but got "fatal: Could not find 83620cb7cd14ee3b509eef72d99337567f53967f" when tried to get t_flush_flags(). I've double-checked commit and found it here: http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=commit;h=83620cb.... I don't know why I can't cherry-pick it.
Your patch alone, without t_flush_flags(), doesn't change anything in my scenario, there is still no logging of 2nd branch.
Cheers Ozren
On Wed, Sep 7, 2011 at 1:05 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 9/7/11 11:25 AM, Ozren Lapcevic wrote:
Hi Daniel,
thanks for the quick fix and reply.
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 ( http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git) to get t_flush flags() and your patch or is there a workaround to apply them to my 3.1.4 branch?
did you install 3.1.4 from tarball/packages or is it from git branch 3.1? If later, then you can do:
git pull origin git cherry-pick -x 83620cb7cd14ee3b509eef72d99337567f53967f git cherry-pick -x c589ca35b2aa3097a3c9e2a5a050514337300c05
then recompile/install. First cherry-pick brings the t_flush_flags, the second auto-update of the flags after branch/failure route.
If you installed from packages, then you would need to repackage yourself after patching. The patches are available at commit url, for example:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
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.
Cheers, Daniel
Cheers Ozren
On Tue, Sep 6, 2011 at 2:18 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
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:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c589ca35...
Actually, reporting if all goes fine with this patch, will help in backporting it to 3.1 branch.
Thanks, Daniel
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
just to be sure, you used flag 2 for missed calls, right? I can see it set in onreply_route.
That means the flags are ok now, the issue seems to be in other place. You don't set any of the accounting flags in request route block, isn't it? I mean, the first accounting flag (like accounting answered calls or missed calls) is set in failure route. If so, the acc does not register itself for a tm callback that is used for handling accounting events.
Try to set acc flag for writing to syslog in route {...}, you can reset it in failure route or onreply_route. Of course, this as an workaround for now, I will look for a proper solution in case this is the problem.
Cheers, Daniel
On 9/12/11 3:29 PM, Ozren Lapcevic wrote:
I have attached log file. I have single onreply_route[REPLY_ONE] used for all replies. Grep "REPLY_ONE, FLAGS" to find where the flags are printed. Grep "FAIL FORK" for logs from failure route.
Let me know if you need anything else.
Cheers Ozren
Hi,
On Tue, Sep 13, 2011 at 8:46 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
Hello,
just to be sure, you used flag 2 for missed calls, right? I can see it set in onreply_route.
Yes, I've used #!define FLT_ACCMISSED 2 and setflag(FLT_ACCMISSED) for missed calls. I checked the flag in onreply_route and failure route and they are properly set.
That means the flags are ok now, the issue seems to be in other place. You don't set any of the accounting flags in request route block, isn't it? I mean, the first accounting flag (like accounting answered calls or missed calls) is set in failure route. If so, the acc does not register itself for a tm callback that is used for handling accounting events.
Actually, I do set other accounting flags in following routes:
#!define FLT_ACC 1 #!define FLT_ACCMISSED 2 #!define FLT_ACCFAILED 3
#MAIN ROUTE
if (is_method("INVITE")) setflag(FLT_ACC);
route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if the transaction fails } .....
route[LOCATION] { # only for people who don't have multiple contacts (no serial forking, not used in reported scenario)
if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) setflag(FLT_ACCMISSED); }
#called only for serial forked calls failure_route[FAIL_FORK] { ..... # if second branch set flag setflag(FLT_ACCMISSED); t_flush_flags(); .... # if 3rd branch (voicemail) reset flag resetflag(FLT_ACCMISSED); t_flush_flags(); .... }
Now that you've mentioned it, I've removed all other setflag() functions and kept only the ones in FAIL_FORK failure route. There is still no logging of the second branch.
Try to set acc flag for writing to syslog in route {...}, you can reset it in failure route or onreply_route. Of course, this as an workaround for now, I will look for a proper solution in case this is the problem.
I'm not sure I can implement needed logic this way. I don't want to account 1st branch. If I set FLT_ACCMISSED flag in route {...} and reset it in on_reply and failure route, it will be too late, the missed call will already be accounted. Or, I'm missing something?
Cheers Ozren
On 9/12/11 3:29 PM, Ozren Lapcevic wrote:
I have attached log file. I have single onreply_route[REPLY_ONE] used for all replies. Grep "REPLY_ONE, FLAGS" to find where the flags are printed. Grep "FAIL FORK" for logs from failure route.
Let me know if you need anything else.
Cheers Ozren
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
On 9/13/11 11:21 AM, Ozren Lapcevic wrote:
Hi,
On Tue, Sep 13, 2011 at 8:46 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, just to be sure, you used flag 2 for missed calls, right? I can see it set in onreply_route.
Yes, I've used #!define FLT_ACCMISSED 2 and setflag(FLT_ACCMISSED) for missed calls. I checked the flag in onreply_route and failure route and they are properly set.
That means the flags are ok now, the issue seems to be in other place. You don't set any of the accounting flags in request route block, isn't it? I mean, the first accounting flag (like accounting answered calls or missed calls) is set in failure route. If so, the acc does not register itself for a tm callback that is used for handling accounting events.
Actually, I do set other accounting flags in following routes:
#!define FLT_ACC 1 #!define FLT_ACCMISSED 2 #!define FLT_ACCFAILED 3
#MAIN ROUTE
if (is_method("INVITE")) setflag(FLT_ACC);
route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if
the transaction fails } .....
route[LOCATION] { # only for people who don't have multiple contacts (no serial forking, not used in reported scenario)
if ( is_method("INVITE") && !(isflagset(FLT_USRPREF)))
setflag(FLT_ACCMISSED); }
#called only for serial forked calls failure_route[FAIL_FORK] { ..... # if second branch set flag setflag(FLT_ACCMISSED); t_flush_flags(); .... # if 3rd branch (voicemail) reset flag resetflag(FLT_ACCMISSED); t_flush_flags(); .... }
Now that you've mentioned it, I've removed all other setflag() functions and kept only the ones in FAIL_FORK failure route. There is still no logging of the second branch.
Try to set acc flag for writing to syslog in route {...}, you can reset it in failure route or onreply_route. Of course, this as an workaround for now, I will look for a proper solution in case this is the problem.
I'm not sure I can implement needed logic this way. I don't want to account 1st branch. If I set FLT_ACCMISSED flag in route {...} and reset it in on_reply and failure route, it will be too late, the missed call will already be accounted. Or, I'm missing something?
It meant setting FLT_ACC (not FLT_ACCMISSED) in main route and reset it on onreply_route in case you didn't want to account successful transactions at all. But I see you actually set the acc flag in route block ... probably I have to dig further in the logs for more details. So far it looked like an issue if no acc module flags were set in request route block.
Cheers, Daniel
Hello,
can you add a debug message to acc module, compile, reinstall and test again? Send again the debug messages with parameter debug=4
I am attaching the patch for master branch, should be easy to apply to 3.1 as well.
Cheers, Daniel
On 9/13/11 11:33 AM, Daniel-Constantin Mierla wrote:
Hello,
On 9/13/11 11:21 AM, Ozren Lapcevic wrote:
Hi,
On Tue, Sep 13, 2011 at 8:46 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, just to be sure, you used flag 2 for missed calls, right? I can see it set in onreply_route.
Yes, I've used #!define FLT_ACCMISSED 2 and setflag(FLT_ACCMISSED) for missed calls. I checked the flag in onreply_route and failure route and they are properly set.
That means the flags are ok now, the issue seems to be in other place. You don't set any of the accounting flags in request route block, isn't it? I mean, the first accounting flag (like accounting answered calls or missed calls) is set in failure route. If so, the acc does not register itself for a tm callback that is used for handling accounting events.
Actually, I do set other accounting flags in following routes:
#!define FLT_ACC 1 #!define FLT_ACCMISSED 2 #!define FLT_ACCFAILED 3
#MAIN ROUTE
if (is_method("INVITE")) setflag(FLT_ACC);
route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ... setflag(FLT_ACCFAILED); # ... even if
the transaction fails } .....
route[LOCATION] { # only for people who don't have multiple contacts (no serial forking, not used in reported scenario)
if ( is_method("INVITE") && !(isflagset(FLT_USRPREF)))
setflag(FLT_ACCMISSED); }
#called only for serial forked calls failure_route[FAIL_FORK] { ..... # if second branch set flag setflag(FLT_ACCMISSED); t_flush_flags(); .... # if 3rd branch (voicemail) reset flag resetflag(FLT_ACCMISSED); t_flush_flags(); .... }
Now that you've mentioned it, I've removed all other setflag() functions and kept only the ones in FAIL_FORK failure route. There is still no logging of the second branch.
Try to set acc flag for writing to syslog in route {...}, you can reset it in failure route or onreply_route. Of course, this as an workaround for now, I will look for a proper solution in case this is the problem.
I'm not sure I can implement needed logic this way. I don't want to account 1st branch. If I set FLT_ACCMISSED flag in route {...} and reset it in on_reply and failure route, it will be too late, the missed call will already be accounted. Or, I'm missing something?
It meant setting FLT_ACC (not FLT_ACCMISSED) in main route and reset it on onreply_route in case you didn't want to account successful transactions at all. But I see you actually set the acc flag in route block ... probably I have to dig further in the logs for more details. So far it looked like an issue if no acc module flags were set in request route block.
Hi Daniel,
sure, debug log is in attach.
Cheers Ozren
On Fri, Sep 23, 2011 at 1:41 PM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
Hello,
can you add a debug message to acc module, compile, reinstall and test again? Send again the debug messages with parameter debug=4
I am attaching the patch for master branch, should be easy to apply to 3.1 as well.
Cheers, Daniel
Hello,
just to refresh in case you mentioned already, do you set acc missed call flag in request route block?
I found another issue that if this flag is no set in request route, the callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites?
Thanks, Daniel
On 9/23/11 4:23 PM, Ozren Lapcevic wrote:
Hi Daniel,
sure, debug log is in attach.
Cheers Ozren
On Fri, Sep 23, 2011 at 1:41 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, can you add a debug message to acc module, compile, reinstall and test again? Send again the debug messages with parameter debug=4 I am attaching the patch for master branch, should be easy to apply to 3.1 as well. Cheers, Daniel
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
Hello,
just to refresh in case you mentioned already, do you set acc missed call flag in request route block?
No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
I found another issue that if this flag is no set in request route, the
callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites?
I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Cheers Ozren
Thanks, Daniel
On 9/23/11 4:23 PM, Ozren Lapcevic wrote:
Hi Daniel,
sure, debug log is in attach.
Cheers Ozren
On Fri, Sep 23, 2011 at 1:41 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
can you add a debug message to acc module, compile, reinstall and test again? Send again the debug messages with parameter debug=4
I am attaching the patch for master branch, should be easy to apply to 3.1 as well.
Cheers, Daniel
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, just to refresh in case you mentioned already, do you set acc missed call flag in request route block?
No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
ok, so that caused not to register to TM for a callback on failure events when the transaction for respective INVITE was created.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
This is different that what we looked after.
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
Because it caused the first branch also to be recorded to missed calls.
I found another issue that if this flag is no set in request route, the callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites?
I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
Do:
/usr/local/sbin/kamailio -V
The config file kamailio.cfg is not overwritten if already exists, to prevent mistakenly loss (no backup).
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Yes, it has to be set in request route {...} block.
Cheers, Daniel
Hi,
sorry if I haven't been clear in the last mail(s). I'll try to recap.
I have a call with 3 branches that are serially forked. branch 1 and 2 can be PSTN number or SIP URI. branch 3 is voicemail. I do not want to account 1st branch if call is missed, only the 2nd one.
Here are the snippets from the configuration file that I'm using since I've started this thread. I've bolded parts where acc related flags are set.
route { .... route(WITHINDLG); ....
if ( is_method("INVITE") ) { ... *setflag(FLT_ACC); # [1]* #check for user defined forking priorities and timers route(FORK); } route(LOCATION); route(RELAY); }
#check for user defined forking priorities and timers route[FORK]{ ... # user has multiple contacts, do serial forking setflag(FLT_USRPREF); .... # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") $ru = $avp(prio1) + "@host"; else $ru = $avp(prio1); .... }
route[RELAY] { if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE");
#if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) t_on_failure("FAIL_FORK"); } if (!t_relay()) sl_reply_error(); exit; }
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) { *setflag(FLT_ACC);* *# [2]* *setflag(FLT_ACCFAILED);* *# [3]* } route(RELAY); } ....} }
# USER location service route[LOCATION] { if ($ru =~ "^sip:00") xlog("L_INFO","SKIP lookup..."); else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { *setflag(FLT_ACCMISSED);* *# [4] - not used in serial forking scenario * } }
# Failure route for forked calls failure_route[FAIL_FORK] { ... # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK");
if ($avp(prio2) =~ "^sip:00") $ru = $avp(prio2) + "@host"; # tel number else { $ru = $avp(prio2); # sip uri route(LOCATION); } *setflag(FLT_ACCMISSED); # [5]* } # 3rd branch is voicemail else { $ru = $(avp(uuid)); rewritehostport("host:port"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY);
if (t_is_canceled()) { exit; } }
With code above I'm testing following scenarios, where oz@abc.hr calls pero@abc.hr. Due to pero@abc.hr settings and priorities set, 1st branch is PSTN number, 2nd branch is sip:pero@abc.hr and 3rd branch is voicemail: 1. pero doesn't answer 1st branch and 2nd branch, voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy), voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call, voicemail doesn't activate. There is a single log in missed_calls (487). This is ok, as expected. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487). This is also ok. Logs in acc table exist and are good for all 4 cases - all of them are related to established call to voicemail server.
Previously, I've tested several variations of config file above:
Variation 1: remove [1], [2] and [3]. (look for bolded lines above). In this variation, only [5] is related to acc flags and is set in failure route. When testing 4 scenarios above, there are no logs in acc and acc_missed table. This is probably related to your comment that acc does not register itself for a tm callback that is used for handling accounting events if there are no flags defined in request route block.
Variation 2: [1], [2], [3] are used again, but 3rd branch is removed, there is no voicemail. Lets go through 4 scenarios again: 1. pero doesn't answer 1st branch and 2nd branch. There is a single log in missed_calls (408) - OK. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy). There is a single log in missed_calls (486) - OK. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. There are no logs in acc table. This is OK because no calls have been established. Everything works as expected here! However, I need the voicemail, I can't replace it for accounting.
Variation 3: [1], [2], [3] are used, as well as voicemail. [5] is removed from failure route. Instead, in failure route setflag(FL_2NDBRANCH) is set when 2nd branch is processed. In RELAY route following line is added: if ( isflagset(FL_2NDBRANCH) ) setflag(FLT_ACCMISSED). Results are the same as for original configuration.
On Mon, Sep 26, 2011 at 12:06 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
just to refresh in case you mentioned already, do you set acc missed call flag in request route block?
No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
ok, so that caused not to register to TM for a callback on failure events when the transaction for respective INVITE was created.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
This is different that what we looked after.
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
Because it caused the first branch also to be recorded to missed calls.
By that, I meant Variation 3.
I found another issue that if this flag is no set in request route, the
callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites?
I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
Do:
/usr/local/sbin/kamailio -V
The config file kamailio.cfg is not overwritten if already exists, to prevent mistakenly loss (no backup).
Ok, I have good version installed. I'll test it and report results.
Cheers Ozren
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Yes, it has to be set in request route {...} block.
Cheers, Daniel
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
the mail is quite long and has lot of inner references that makes it not that easy to follow, better focus only on what is wrong.
I see lot of OKs, but I don't get it if you tried with v3.2.0. If still does not work, send the debug messages.
You can always use acc_db_request(...) just to record a missed call whenever you want, but the other way with flags should work as well, after latest enhancement, maybe it needs some tuning if not there yet. Previously there was no callback to tm registered for failure event if the missed call flag was not set in main route block.
Cheers, Daniel
On 9/26/11 3:17 PM, Ozren Lapcevic wrote:
Hi,
sorry if I haven't been clear in the last mail(s). I'll try to recap.
I have a call with 3 branches that are serially forked. branch 1 and 2 can be PSTN number or SIP URI. branch 3 is voicemail. I do not want to account 1st branch if call is missed, only the 2nd one.
Here are the snippets from the configuration file that I'm using since I've started this thread. I've bolded parts where acc related flags are set.
route { .... route(WITHINDLG); ....
if ( is_method("INVITE") ) { ...
*setflag(FLT_ACC); # [1]* #check for user defined forking priorities and timers route(FORK); } route(LOCATION); route(RELAY); }
#check for user defined forking priorities and timers route[FORK]{ ... # user has multiple contacts, do serial forking setflag(FLT_USRPREF); .... # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") $ru = $avp(prio1) + "@host"; else $ru = $avp(prio1); .... }
route[RELAY] { if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE");
#if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) t_on_failure("FAIL_FORK"); } if (!t_relay()) sl_reply_error(); exit;
}
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) { *setflag(FLT_ACC);* *# [2]* *setflag(FLT_ACCFAILED);* *# [3]* } route(RELAY); } ....} }
# USER location service route[LOCATION] { if ($ru =~ "^sip:00") xlog("L_INFO","SKIP lookup..."); else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { *setflag(FLT_ACCMISSED);* *# [4] - not used in serial forking scenario
}
}
# Failure route for forked calls failure_route[FAIL_FORK] { ... # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK");
if ($avp(prio2) =~ "^sip:00") $ru =
$avp(prio2) + "@host"; # tel number else { $ru = $avp(prio2); # sip uri route(LOCATION); } *setflag(FLT_ACCMISSED); # [5]* } # 3rd branch is voicemail else { $ru = $(avp(uuid)); rewritehostport("host:port"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY);
if (t_is_canceled()) { exit; }
}
With code above I'm testing following scenarios, where oz@abc.hr mailto:oz@abc.hr calls pero@abc.hr mailto:pero@abc.hr. Due to pero@abc.hr mailto:pero@abc.hr settings and priorities set, 1st branch is PSTN number, 2nd branch is sip:pero@abc.hr mailto:sip%3Apero@abc.hr and 3rd branch is voicemail:
- pero doesn't answer 1st branch and 2nd branch, voicemail activates.
There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy), voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call, voicemail doesn't activate. There is a single log in missed_calls (487). This is ok, as expected. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487). This is also ok. Logs in acc table exist and are good for all 4 cases - all of them are related to established call to voicemail server.
Previously, I've tested several variations of config file above:
Variation 1: remove [1], [2] and [3]. (look for bolded lines above). In this variation, only [5] is related to acc flags and is set in failure route. When testing 4 scenarios above, there are no logs in acc and acc_missed table. This is probably related to your comment that acc does not register itself for a tm callback that is used for handling accounting events if there are no flags defined in request route block.
Variation 2: [1], [2], [3] are used again, but 3rd branch is removed, there is no voicemail. Lets go through 4 scenarios again:
- pero doesn't answer 1st branch and 2nd branch. There is a single
log in missed_calls (408) - OK. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy). There is a single log in missed_calls (486) - OK. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. There are no logs in acc table. This is OK because no calls have been established. Everything works as expected here! However, I need the voicemail, I can't replace it for accounting.
Variation 3: [1], [2], [3] are used, as well as voicemail. [5] is removed from failure route. Instead, in failure route setflag(FL_2NDBRANCH) is set when 2nd branch is processed. In RELAY route following line is added: if ( isflagset(FL_2NDBRANCH) ) setflag(FLT_ACCMISSED). Results are the same as for original configuration.
On Mon, Sep 26, 2011 at 12:06 PM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, just to refresh in case you mentioned already, do you set acc missed call flag in request route block? No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
ok, so that caused not to register to TM for a callback on failure events when the transaction for respective INVITE was created.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
This is different that what we looked after.
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
Because it caused the first branch also to be recorded to missed calls.
By that, I meant Variation 3.
I found another issue that if this flag is no set in request route, the callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites? I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
Do: /usr/local/sbin/kamailio -V The config file kamailio.cfg is not overwritten if already exists, to prevent mistakenly loss (no backup).
Ok, I have good version installed. I'll test it and report results.
Cheers Ozren
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Yes, it has to be set in request route {...} block. Cheers, Daniel -- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Just tested with v3.2 and acc_prepare_flag and accounting works fine now!
Thanks, Ozren
On Tue, Sep 27, 2011 at 8:21 AM, Daniel-Constantin Mierla <miconda@gmail.com
wrote:
Hello,
the mail is quite long and has lot of inner references that makes it not that easy to follow, better focus only on what is wrong.
I see lot of OKs, but I don't get it if you tried with v3.2.0. If still does not work, send the debug messages.
You can always use acc_db_request(...) just to record a missed call whenever you want, but the other way with flags should work as well, after latest enhancement, maybe it needs some tuning if not there yet. Previously there was no callback to tm registered for failure event if the missed call flag was not set in main route block.
Cheers, Daniel
On 9/26/11 3:17 PM, Ozren Lapcevic wrote:
Hi,
sorry if I haven't been clear in the last mail(s). I'll try to recap.
I have a call with 3 branches that are serially forked. branch 1 and 2 can be PSTN number or SIP URI. branch 3 is voicemail. I do not want to account 1st branch if call is missed, only the 2nd one.
Here are the snippets from the configuration file that I'm using since I've started this thread. I've bolded parts where acc related flags are set.
route { .... route(WITHINDLG); ....
if ( is_method("INVITE") ) { ... *setflag(FLT_ACC); # [1]* #check for user defined forking priorities and timers route(FORK); } route(LOCATION); route(RELAY);
}
#check for user defined forking priorities and timers route[FORK]{ ... # user has multiple contacts, do serial forking setflag(FLT_USRPREF); .... # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") $ru = $avp(prio1) + "@host"; else $ru = $avp(prio1); .... }
route[RELAY] { if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE");
#if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) t_on_failure("FAIL_FORK"); } if (!t_relay()) sl_reply_error(); exit;
}
# Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) { *setflag(FLT_ACC);* *# [2]* *setflag(FLT_ACCFAILED);* *# [3]* } route(RELAY); } ....} }
# USER location service route[LOCATION] { if ($ru =~ "^sip:00") xlog("L_INFO","SKIP lookup..."); else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { *setflag(FLT_ACCMISSED);* *# [4] - not used in serial forking scenario
}
}
# Failure route for forked calls failure_route[FAIL_FORK] { ... # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK");
if ($avp(prio2) =~ "^sip:00") $ru = $avp(prio2) +
"@host"; # tel number else { $ru = $avp(prio2); # sip uri route(LOCATION); } *setflag(FLT_ACCMISSED); # [5]* } # 3rd branch is voicemail else { $ru = $(avp(uuid)); rewritehostport("host:port"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY);
if (t_is_canceled()) { exit; }
}
With code above I'm testing following scenarios, where oz@abc.hr calls pero@abc.hr. Due to pero@abc.hr settings and priorities set, 1st branch is PSTN number, 2nd branch is sip:pero@abc.hr and 3rd branch is voicemail:
- pero doesn't answer 1st branch and 2nd branch, voicemail activates.
There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy), voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call, voicemail doesn't activate. There is a single log in missed_calls (487). This is ok, as expected. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487). This is also ok. Logs in acc table exist and are good for all 4 cases - all of them are related to established call to voicemail server.
Previously, I've tested several variations of config file above:
Variation 1: remove [1], [2] and [3]. (look for bolded lines above). In this variation, only [5] is related to acc flags and is set in failure route. When testing 4 scenarios above, there are no logs in acc and acc_missed table. This is probably related to your comment that acc does not register itself for a tm callback that is used for handling accounting events if there are no flags defined in request route block.
Variation 2: [1], [2], [3] are used again, but 3rd branch is removed, there is no voicemail. Lets go through 4 scenarios again:
- pero doesn't answer 1st branch and 2nd branch. There is a single log in
missed_calls (408) - OK. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy). There is a single log in missed_calls (486) - OK. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. There are no logs in acc table. This is OK because no calls have been established. Everything works as expected here! However, I need the voicemail, I can't replace it for accounting.
Variation 3: [1], [2], [3] are used, as well as voicemail. [5] is removed from failure route. Instead, in failure route setflag(FL_2NDBRANCH) is set when 2nd branch is processed. In RELAY route following line is added: if ( isflagset(FL_2NDBRANCH) ) setflag(FLT_ACCMISSED). Results are the same as for original configuration.
On Mon, Sep 26, 2011 at 12:06 PM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla < miconda@gmail.com> wrote:
Hello,
just to refresh in case you mentioned already, do you set acc missed call flag in request route block?
No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
ok, so that caused not to register to TM for a callback on failure events when the transaction for respective INVITE was created.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
This is different that what we looked after.
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
Because it caused the first branch also to be recorded to missed calls.
By that, I meant Variation 3.
I found another issue that if this flag is no set in request route, the
callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites?
I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
Do:
/usr/local/sbin/kamailio -V
The config file kamailio.cfg is not overwritten if already exists, to prevent mistakenly loss (no backup).
Ok, I have good version installed. I'll test it and report results.
Cheers Ozren
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Yes, it has to be set in request route {...} block.
Cheers, Daniel
-- Daniel-Constantin Mierla -- http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kathttp://linkedin.com/in/miconda -- http://twitter.com/miconda
Hello,
On 9/27/11 12:32 PM, Ozren Lapcevic wrote:
Just tested with v3.2 and acc_prepare_flag and accounting works fine now!
great, thanks for reporting back.
Not sure if this should be backported to 3.1 branch, thinking of how it was so far designed the acc -- I am actually not that much convinced for backporting since more or less similar functionality can be done using acc_db_request(...) in failure_route and version 3.2 is on the corner, but also this backport would introduce a new parameter to acc module ... I will give more thought until the next minor release to 3.1 branch.
Cheers, Daniel
Thanks, Ozren
On Tue, Sep 27, 2011 at 8:21 AM, Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com> wrote:
Hello, the mail is quite long and has lot of inner references that makes it not that easy to follow, better focus only on what is wrong. I see lot of OKs, but I don't get it if you tried with v3.2.0. If still does not work, send the debug messages. You can always use acc_db_request(...) just to record a missed call whenever you want, but the other way with flags should work as well, after latest enhancement, maybe it needs some tuning if not there yet. Previously there was no callback to tm registered for failure event if the missed call flag was not set in main route block. Cheers, Daniel On 9/26/11 3:17 PM, Ozren Lapcevic wrote:
Hi, sorry if I haven't been clear in the last mail(s). I'll try to recap. I have a call with 3 branches that are serially forked. branch 1 and 2 can be PSTN number or SIP URI. branch 3 is voicemail. I do not want to account 1st branch if call is missed, only the 2nd one. Here are the snippets from the configuration file that I'm using since I've started this thread. I've bolded parts where acc related flags are set. route { .... route(WITHINDLG); .... if ( is_method("INVITE") ) { ... *setflag(FLT_ACC); # [1]* #check for user defined forking priorities and timers route(FORK); } route(LOCATION); route(RELAY); } #check for user defined forking priorities and timers route[FORK]{ ... # user has multiple contacts, do serial forking setflag(FLT_USRPREF); .... # overwrite request URI with highest priority contact if ($avp(prio1) =~ "^sip:00") $ru = $avp(prio1) + "@host"; else $ru = $avp(prio1); .... } route[RELAY] { if (is_method("INVITE")) { t_on_reply("REPLY_ONE"); t_on_failure("FAIL_ONE"); #if users have priorities set, use FAIL_FORK failure route if ( isflagset(FLT_USRPREF) ) t_on_failure("FAIL_FORK"); } if (!t_relay()) sl_reply_error(); exit; } # Handle requests within SIP dialogs route[WITHINDLG] { if (has_totag()) { if (loose_route()) { if (is_method("BYE")) { *setflag(FLT_ACC);* *# [2]* *setflag(FLT_ACCFAILED);* *# [3]* } route(RELAY); } ....} } # USER location service route[LOCATION] { if ($ru =~ "^sip:00") xlog("L_INFO","SKIP lookup..."); else { if (!lookup("location")) { switch ($rc) { case -1: case -3: t_newtran(); t_reply("404", "Not Found"); exit; case -2: sl_send_reply("405", "Method Not Allowed"); exit; } } } # when routing via usrloc, log the missed calls also, but only if user doesn't have prios set if ( is_method("INVITE") && !(isflagset(FLT_USRPREF))) { *setflag(FLT_ACCMISSED);* *# [4] - not used in serial forking scenario * } } # Failure route for forked calls failure_route[FAIL_FORK] { ... # handle 2nd branch if ( ($avp(prio) == 2) && ( isflagset(FLT_USRPREF) )) { t_on_failure("FAIL_FORK"); if ($avp(prio2) =~ "^sip:00") $ru = $avp(prio2) + "@host"; # tel number else { $ru = $avp(prio2); # sip uri route(LOCATION); } *setflag(FLT_ACCMISSED); # [5]* } # 3rd branch is voicemail else { $ru = $(avp(uuid)); rewritehostport("host:port"); append_hf("P-App-Name: voicemail\r\n"); append_hf("P-App-Param: Email-Address=$avp(email)\r\n"); } route(RELAY); if (t_is_canceled()) { exit; } } With code above I'm testing following scenarios, where oz@abc.hr <mailto:oz@abc.hr> calls pero@abc.hr <mailto:pero@abc.hr>. Due to pero@abc.hr <mailto:pero@abc.hr> settings and priorities set, 1st branch is PSTN number, 2nd branch is sip:pero@abc.hr <mailto:sip%3Apero@abc.hr> and 3rd branch is voicemail: 1. pero doesn't answer 1st branch and 2nd branch, voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy), voicemail activates. There are no logs in missed_calls. I want to have a single log in missed_calls for this case. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call, voicemail doesn't activate. There is a single log in missed_calls (487). This is ok, as expected. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487). This is also ok. Logs in acc table exist and are good for all 4 cases - all of them are related to established call to voicemail server. Previously, I've tested several variations of config file above: Variation 1: remove [1], [2] and [3]. (look for bolded lines above). In this variation, only [5] is related to acc flags and is set in failure route. When testing 4 scenarios above, there are no logs in acc and acc_missed table. This is probably related to your comment that acc does not register itself for a tm callback that is used for handling accounting events if there are no flags defined in request route block. Variation 2: [1], [2], [3] are used again, but 3rd branch is removed, there is no voicemail. Lets go through 4 scenarios again: 1. pero doesn't answer 1st branch and 2nd branch. There is a single log in missed_calls (408) - OK. 2. pero doesn't answer 1st branch, declines call at 2nd branch (486 Busy). There is a single log in missed_calls (486) - OK. 3. pero doesn't answer 1st branch, 2nd branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. 4. 1st branch rings, oz cancels call. There is a single log in missed_calls (487) - OK. There are no logs in acc table. This is OK because no calls have been established. Everything works as expected here! However, I need the voicemail, I can't replace it for accounting. Variation 3: [1], [2], [3] are used, as well as voicemail. [5] is removed from failure route. Instead, in failure route setflag(FL_2NDBRANCH) is set when 2nd branch is processed. In RELAY route following line is added: if ( isflagset(FL_2NDBRANCH) ) setflag(FLT_ACCMISSED). Results are the same as for original configuration. On Mon, Sep 26, 2011 at 12:06 PM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, On 9/26/11 11:44 AM, Ozren Lapcevic wrote:
On Sat, Sep 24, 2011 at 9:11 AM, Daniel-Constantin Mierla <miconda@gmail.com <mailto:miconda@gmail.com>> wrote: Hello, just to refresh in case you mentioned already, do you set acc missed call flag in request route block? No. I'm setting setflag(FLT_ACCMISSED) in failure route for serially forked calls.
ok, so that caused not to register to TM for a callback on failure events when the transaction for respective INVITE was created.
(Also, I'm setting setflag(FLT_ACC); in main route for INVITES. I'm setting setflag(FLT_ACC) and setflag(FLT_ACCFAILED) in WITHINDLG route for loose routed BYEs.)
This is different that what we looked after.
Previously, before starting this thread, and before any of your patches, I've tried setting FLT_ACCMISSED in LOCATION route and in RELAY route, but didn't help with properly accounting only the 2nd branch.
Because it caused the first branch also to be recorded to missed calls. By that, I meant Variation 3.
I found another issue that if this flag is no set in request route, the callback to tm that is used for accounting missed calls is not registered. Can you try with 3.2.0 (git master branch at this moment) and set the acc_prepare_flag parameter, plus the flag itself for invites? I've installed new Kamailio with instructions from: http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-devel-from-git. However, default kamailio config file and kamctl file both show 3.1 version. How can I check whether I have 3.2 version installed?
Do: /usr/local/sbin/kamailio -V The config file kamailio.cfg is not overwritten if already exists, to prevent mistakenly loss (no backup). Ok, I have good version installed. I'll test it and report results. Cheers Ozren
acc_prepare_flag should be set in main route, e.g. in the same place as FLT_ACC for INVITES?
Yes, it has to be set in request route {...} block. Cheers, Daniel -- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin:http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla --http://www.asipto.com Kamailio Advanced Training, Oct 10-13, Berlin: http://asipto.com/u/kat http://linkedin.com/in/miconda -- http://twitter.com/miconda