[OpenSIPS-Users] Custom RADIUS Accounting with "AAA RADIUS MODULE"

Bogdan-Andrei Iancu bogdan at opensips.org
Fri Apr 5 15:55:53 CEST 2013


Hello Ewgwny,

The module docs offers some good basic examples : 
http://www.opensips.org/html/docs/modules/1.9.x/aaa_radius.html .

Before spending too much time in doing your own manual accounting with 
Radius, have you evaluated the possibility to use the ACC module (auto 
accounting) with RADIUS backend and extra accouting option 
(http://www.opensips.org/html/docs/modules/1.9.x/acc.html#id293362).

Regards,

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


On 03/29/2013 02:36 PM, Ewgeny wrote:
> Hi,
>
>
> I use custom radius accounting with "AAA RADIUS MODULE", because I have to adapt the RADIUS accounting with complex system, and i have to send many many specific attributes to the RADIUS server.
> I'm using functions "radius_send_auth", "radius_send_acct".
> I didn't find good examples in google or in mailing list - about using of "AAA RADIUS MODULE".
>
> Due to the manual RADIUS accounting there are many nuances, which does not happening when using standart RADIUS accounting module "Acc Module" with "setflag(ACC_DO)".
>
>
> As you can see in my code examples - I should call Radius Acct-Stop and Radius Acct-Start in many places of opensips.cfg.
> What do you think about stability and reliability about my method of RADIUS accounting ?
>
> I have problem with Acct-STOP on loose_route(), because not always i should do it.
> For example when routing in local call - i don't start accounting, and i didn't setflag(DOACCT) - but in loose_route flags are not working.
> How to do STOP package sending not every time when receive SIP BYE, but only in those cases when a START packet was sent ?
>
>
>
> I'm sorry for my poor English....
>
>
>
> ************************************************************************************************************************************
> loadmodule "aaa_radius.so"
> modparam("aaa_radius", "radius_config", "/etc/radiusclient-ng/radiusclient.conf")
>
>
> modparam("aaa_radius","sets","acct-start = (................many attributes
>      ...............................
>      ...............................
>      ...............................)")
>
>
> modparam("aaa_radius","sets","acct-stop =  (................many attributes
>       ...............................
>       ...............................
>       ...............................)")
>
>
>
>
> route{
>
>
>      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
>
>                  /*Send custom RADIUS Accounting STOP when recive BYE message*/
>                                  xog("L_NOTICE", "******************Accounting STOP $ci");
>                  route(acctstop);
>
> ............................................................
> ............................................................
> ............................................................
>
>
>          # I should send ACCT STOP when CANCEL processing
>
>          if (is_method("CANCEL")) {
>          /*call custom RADIUS Accounting STOP*/
>              xlog("L_NOTICE", "****************** CANCEL Accounting STOP ci=$ci");
>                  route(acctstop);
>              if (t_check_trans())
>                  t_relay();
>                  exit;
>          }
>
> ............................................................
> ............................................................
> ............................................................
>
>
>      /*when local call - we don't start the custom Radius accounting */
>          if ($rU=~"^490[0-9]{10}") {
>                  # do lookup with method filtering
>                  xlog("L_NOTICE", "******************* Local Call 490 - do looookup lookation");
>                          if (!lookup("location","m")) {
>                                  switch ($retcode) {
>                                  case -1:
>                                           xlog("L_NOTICE", "-1");.
>                                           /*route forward when user is not regitered*/
> route(forwarding);
>                                  exit;
>                                 case -3:
>                                      xlog("L_NOTICE", "-3");
>                                 exit;
>                                 case -2:
>                                        xlog("L_NOTICE", "-2");
>                                 exit;
>               };
> ............................................................
> ............................................................
> ............................................................
>
>
>
>         /*Call to PSTN*/
>          if ($rU=~"^[0-9]{8,15}$") {
>                  xlog("L_INFO", "PSTN REQUEST : M=$rm rU=$rU F=$fu T=$tu IP=$si\n");
>         /*Set attributes for custom radius accounting*/
>                   route(acctonsip);
>                   $rd="xxx.xxx.xxx.xxx";
>                   $rp=5060;
>         /*If that flag is set - then we do custom accounting onreply route*/
>                   setflag(DOACCT);
>         /*route relay*/
>                   route(1);
>                   exit;
>          }.
>
>
>
> ............................................................
> ............................................................
> ............................................................
>
>
>
>    onreply_route[2] {
>          if (nat_uac_test("1"))
>                  fix_nated_contact();
>
>                  setflag(TRACE);
>                  sip_trace();
>
>          if ( isflagset(10) )
>                  rtpproxy_answer("ro");
>
>          xlog("incoming reply $rs, $rr \n");
>
>
>          /*if flag DOACCT is SET - and we get 200 OK - then Accounting start*/
>
>           if (isflagset(DOACCT)) {
>                  if($rs=~"200") {
>
>                        setflag(ACCTstarted);
>
>                        xlog("L_NOTICE", "*****************Accounting Start ci=$ci");
>                        /*отправляем RADIUS Acct-START*/
>                        radius_send_acct("acct-start");
>                        xlog("L_INFO", "radius_acct-start $ci \n");
>                  }
>              }
>
>
> }
>
>
> ............................................................
> ............................................................
> ............................................................
>
>
>
> failure_route[1] {
>
>                  xlog("L_NOTICE", "****************** Failure $rs Accounting STOP $ci");
>                  /*RADIUS Accounting STOP*/
>                  route(acctstop);
> }
>
>
> ............................................................
> ............................................................
> ............................................................
>
> /*Call custom Accounting STOP when module dialog ends the sip session*/
>
> local_route {
>                  /*setflag(TRACE);
>                    sip_trace();*/
>
>                  if (is_method("BYE")&&  $DLG_dir=="UPSTREAM"){
>                      /*RADIUS Accounting STOP*/
>                      xlog("L_NOTICE", "*************Accounting STOP on DIALOG local route");
>                      route(acctstop);
>                    }
> }
>
>
> ***************************************************************************************************
>
>
>
>
> thanks in advance
>
> Regards
> Ewgeny
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users



More information about the Users mailing list