Hi Michele,

The acc_aaa_request() function will generate a RADIUS acc request on the
spot, so it will happen for all your INVITEs disregarding if the calls
will establish or not in the future.

If you want to account only established calls, do not use the
acc_aaa_request() function, but trigger the accounting via flags only.
Use the aaa_flag only (do not set aa_missed_flag) and it should do the
trick.

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com


On 05/16/2013 10:36 AM, Michele Pinassi wrote:
> Hi all,
>
> here's my acc module config, using radius backend and MySQL.
>
> modparam("acc", "early_media", 0)
> modparam("acc", "report_cancels", 0)
> modparam("acc", "detect_direction", 0)
> modparam("acc", "failed_transaction_flag", 3)
> modparam("acc", "log_level", 1)
> modparam("acc", "log_flag", 1)
> modparam("acc", "log_missed_flag", 2)
> modparam("acc", "aaa_url", "radius:/etc/radiusclient-ng/radiusclient.conf")
> modparam("acc", "aaa_flag", 1)
> modparam("acc", "aaa_missed_flag", 2)
> modparam("acc", "aaa_extra",          "via=$hdr(Via[*]); \
>                                        Digest-User-Name=$Au; \
>                                        Calling-Station-Id=$from; \
>                                        Called-Station-Id=$to; \
>                                        Sip-Translated-Request-URI=$ru; \
>                                        Sip-RPid=$avp(s:rpid); \
>                                        Source-IP=$avp(s:source_ip); \
>                                        Source-Port=$avp(s:source_port); \
>                                        SIP-Proxy-IP=$avp(s:sip_proxy_ip); \
>                                        Canonical-URI=$avp(s:can_uri); \
>
> Divert-Reason=$avp(s:divert_reason); \
>                                        User-Agent=$hdr(user-agent); \
>                                        Contact=$hdr(contact); \
>                                        Event=$hdr(event) ;\
>                                        ENUM-TLD=$avp(s:enum_tld)")
>
> my routing logic is:
>
> ####### Routing Logic ########
>
> route{
>       if (!mf_process_maxfwd_header("10")) {
>           sl_send_reply("483","Too Many Hops");
>           exit;
>       }
>       
>       if (msg:len >= 2048 ) {
>           sl_send_reply("513", "Message too big");
>           exit;
>       };
>       
>       if (has_totag()) {
>               # sequential request withing a dialog should
>               # take the path determined by record-routing
>               if (loose_route()) {
>                       if (is_method("BYE")) {
>                               setflag(1); # do accounting ...
>                               setflag(3); # ... even if the transaction fails
>                       } else if (is_method("INVITE")) {
>                               # even if in most of the cases is useless, do 
> RR for
>                               # re-INVITEs alos, as some buggy clients do 
> change route set
>                               # during the dialog.
>                               record_route();
>                       }
>                       # route it out to whatever destination was set by 
> loose_route()
>                       # in $du (destination URI).
>                       route(1);
>               } else {
>                       /* uncomment the following lines if you want to enable 
> presence */
>                       if (is_method("SUBSCRIBE") && $rd == "voip.unisi.it") {
>                               # in-dialog subscribe requests
>                               route(2);
>                               exit;
>                       }
>                       if ( is_method("ACK") ) {
>                               if ( t_check_trans() ) {
>                                       # non 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;
>       }
>
>       if (is_method("CANCEL"))
>       {
>               if (t_check_trans())
>                       t_relay();
>               exit;
>       }
>
>       t_check_trans();
>
>       if (!(method=="REGISTER") && is_from_local())
>       {
>               if(!check_source_address("0")){
>                   if (!proxy_authorize("", "subscriber")) {
>                       proxy_challenge("", "0");
>                       exit;
>                   }
>                   if (!db_check_from()) {
>                       sl_send_reply("403","Forbidden auth ID");
>                       exit;
>                   }
>       
>                   consume_credentials();
>                   # caller authenticated
>               }
>       }
>
>       # preloaded route checking
>       if (loose_route()) {
>               xlog("L_ERR", "Attempt to route with preloaded Route's
> [$fu/$tu/$ru/$ci]");
>               if (!is_method("ACK"))
>                       sl_send_reply("403","Preload Route denied");
>               exit;
>       }
>
>
>       # record routing
>       if (!is_method("REGISTER|MESSAGE"))
>               record_route();
>
>       # account only INVITEs
>       if (is_method("INVITE")) {
>               acc_aaa_request("VoIP");
>               setflag(1); # do accounting
>       }
>
>       if (!uri==myself) {
>               append_hf("P-hint: outbound\r\n");
>               route(1);
>       }
>
>       if( is_method("PUBLISH|SUBSCRIBE")) {
>           route(2);
>       }
>       
>       if (is_method("REGISTER"))
>       {
>               # authenticate the REGISTER requests (uncomment to enable auth)
>               if (!www_authorize("", "subscriber"))
>               {
>                       www_challenge("", "0");
>                       exit;
>               }
>               
>               if (!db_check_to())
>               {
>                       sl_send_reply("403","Forbidden auth ID");
>                       exit;
>               }
>
>               if (!save("location"))
>                       sl_reply_error();
>
>               exit;
>       }
>
>       if ($rU==NULL) {
>               # request with no Username in RURI
>               sl_send_reply("484","Address Incomplete");
>               exit;
>       }
>
>       # media service number? (digits starting with *)
>       if($rU=~"^\*") {
>           route(4);
>       }
>       
>
>       # apply DB based aliases (uncomment to enable)
>       alias_db_lookup("dbaliases");
>
>       # do lookup with method filtering
>       if (!lookup("location","m")) {
>               switch ($retcode) {
>                       case -1: # Note here: check for blacklist numbers
>                               if (!check_blacklist("globalblacklist")) {
>                                   sl_send_reply("403", "Forbidden");
>                                   exit;
>                               }
>                               # Then route it !
>                               cr_user_carrier("$fU", "$fd", "$avp(carrier)");
>                               if($avp(carrier)==0) {
>                                   xlog("L_INFO","Not here: default route 
> [$fd/$fu/$rd/$ru/$si]\n");
>                                   # Not here: default route
> [172.20.1.4/sip:2425@172.20.1.4:5060/voip.unisi.it/sip:5...@voip.unisi.it:5060/172.20.1.4]
>                                   if($(rU{s.len}) < 4) {
>                                       xlog("L_ERR", "Number 
> incomplete/failure for $rU\n");
>                                       prefix("FAIL_");
>                                       route(4);
>                                   }
>                               
>                                   if(!cr_route("default", "$fd", "$rU", 
> "$rU", "call_id",
> "$avp(host)")) {
>                                       xlog("L_ERR", "Number not found for 
> $rU\n");
>                                       prefix("FAIL_");
>                                       route(4);
>                                   }
>                               } else {
>                                   xlog("L_INFO","Not here: user route
> [$fd/$fu/$rd/$ru/$si/$avp(carrier)]\n");
>                                   $avp(domain)="voip.unisi.it";
>                                   if (!cr_route("$avp(carrier)", 
> "$avp(domain)", "$rU",
> "$rU","call_id", "$avp(host)")) {
>                                       sl_send_reply("404", "Not found");
>                                       xlog("L_ERR", "cr_route failed\n");
>                                       exit;
>                                   }
>                               }
>                               t_on_failure("1");
>                               if (!t_relay()) {
>                                   sl_reply_error();
>                               };
>                               exit;
>                       case -3: # internal error
>                               t_newtran();
>                               t_reply("404", "Not Found");
>                               exit;
>                       case -2: # method not supported
>                               sl_send_reply("405", "Method Not Allowed");
>                               exit;
>               }
>       }
>
>       # when routing via usrloc, log the missed calls also
>       setflag(2);
>
>       route(1);
> }
>
> route[1] {
>       xlog("L_INFO","Route1  [$fd/$fu/$rd/$ru/$si/]\n");
>
>       # for INVITEs enable some additional helper routes
>       if (is_method("INVITE")) {
>               t_on_branch("2");
>               t_on_reply("2");
>               t_on_failure("1");
>       }
>
>       if (!t_relay()) {
>               sl_reply_error();
>       };
>       exit;
> }
>
>
> # Presence route
> route[2] {
>     xlog("L_INFO","Route2  [$fd/$fu/$rd/$ru/$si/]\n");
>
>     if (!t_newtran()) {
>       sl_reply_error();
>       exit;
>     };
>
>     if(is_method("PUBLISH")) {
>       handle_publish();
>     } else if( is_method("SUBSCRIBE")) {
>       handle_subscribe();
>     }
>
>     exit;
> }
>
> route[4] {
>     xlog("L_INFO","Route4  [$fd/$fu/$rd/$ru/$si/]\n");
>
>     rewritehostport("172.20.1.5:5060");
>     route(1);
> }
>
> branch_route[2] {
>     xlog("L_INFO","Branch Route2  [$fd/$fu/$rd/$ru/$si/]\n");
> }
>
> onreply_route[1] {
>     xlog("L_INFO","OnReply Route1  [$fd/$fu/$rd/$ru/$si/]\n");
> }
>
> onreply_route[2] {
>     xlog("L_INFO","OnReply Route2  [$fd/$fu/$rd/$ru/$si/]\n");
> }
>
> failure_route[1] {
>     xlog("L_INFO","Failure Route1  [$fd/$fu/$rd/$ru/$si/]\n");
>
>     if (t_was_cancelled()) {
>       exit;
>     }
>
>     if (t_check_status("408|5[0-9][0-9]")) {
>         if(!cr_route("default", "$fd", "$rU", "$rU", "call_id",
> "$avp(host)")){
>           t_reply("403", "Not allowed");
>       } else {
>           t_on_failure("2");
>           t_relay();
>       }
>     }
> }
>
> failure_route[2] {
>     xlog("L_INFO","Failure Route2  [$fd/$fu/$rd/$ru/$si/]\n");
>
>     if (t_was_cancelled()) {
>       exit;
>     }
>
>     revert_uri();
>     prefix("FAILURE_");
>     rewritehostport("172.20.1.5:5060");
>     t_relay();
> }
>
> i insert acc_aaa_request inside INVITE but also missed calls were
> recorded. I want to count only effective calls: maybe i need to move
> acc_aaa_request in another place ?
>
> Thanks for your suggestions, Michele
>
>
>
> _______________________________________________
> Users mailing list
> Users@lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to