[Serusers] Setting Accounting Flags:-(

ravi reddy mravikreddy at gmail.com
Mon Sep 4 09:33:59 CEST 2006


Hi users ,

              I am using ser.cfg from onsip.org and because i am not a
programmer (means i dont understand the language)I am using the config file
as i downloaded , before i gave a lot messages regarding this getting of
multiple records in radius database as well as in SER mysql(ac) database
also ;  i am attaching the ser.cfg below please let me know where to set
flag so that i can get single record per call ;-) thank you.



debug=4
fork=yes
log_stderror=yes

listen=My Ip address         # INSERT YOUR IP ADDRESS HERE
port=5060
children=5



dns=no
rev_dns=no
fifo="/tmp/ser_fifo"
fifo_mode=766
fifo_db_url="mysql://ser:heslo@localhost/ser"

sip_warning=yes
server_signature=no


loadmodule "/usr/local/lib/ser/modules/mysql.so"
loadmodule "/usr/local/lib/ser/modules/sl.so"
loadmodule "/usr/local/lib/ser/modules/tm.so"
loadmodule "/usr/local/lib/ser/modules/rr.so"
loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
loadmodule "/usr/local/lib/ser/modules/usrloc.so"
loadmodule "/usr/local/lib/ser/modules/registrar.so"
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"
loadmodule "/usr/local/lib/ser/modules/uri.so"
loadmodule "/usr/local/lib/ser/modules/uri_db.so"
loadmodule "/usr/local/lib/ser/modules/domain.so"
loadmodule "/usr/local/lib/ser/modules/mediaproxy.so"
loadmodule "/usr/local/lib/ser/modules/nathelper.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"
loadmodule "/usr/local/lib/ser/modules/xlog.so"
loadmodule "/usr/local/lib/ser/modules/avpops.so"
loadmodule "/usr/local/lib/ser/modules/permissions.so"
loadmodule "/usr/local/lib/ser/modules/acc.so"

modparam("auth_db|permissions|domain|uri_db|usrloc", "db_url", "
mysql://ser:heslo@localhost/ser")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")

modparam("nathelper", "rtpproxy_disable", 1)
modparam("nathelper", "natping_interval", 0)

modparam("mediaproxy","natping_interval", 30)
modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy.sock")
modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-clients")
modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-clients")

modparam("usrloc", "db_mode", 2)

modparam("registrar", "nat_flag", 6)

modparam("rr", "enable_full_lr", 1)

modparam("xlog", "buf_size", 8192)

modparam("tm", "fr_inv_timer", 27)
modparam("tm", "fr_inv_timer_avp", "inv_timeout")
modparam("permissions", "db_mode", 1)
modparam("permissions", "trusted_table", "trusted")
modparam("avpops", "avp_url", "mysql://ser:heslo@localhost/ser")
modparam("avpops", "avp_table", "usr_preferences")

# -- acc params --
# set the reporting log level
modparam("acc", "log_level", 1)
# number of flag, which will be used for accounting; if a message is
# labeled with this flag, its completion status will be reported
modparam("acc", "radius_flag", 11 )
modparam("acc", "radius_missed_flag",12)
modparam("acc", "radius_config",
"/usr/local/etc/radiusclient-ng/radiusclient.conf")
modparam("acc", "service_type", 15)
modparam("acc", "db_flag",13)
modparam("acc", "db_table_acc", "acc")


route {

    # -----------------------------------------------------------------
    # Sanity Check Section
    # -----------------------------------------------------------------
    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483", "Too Many Hops");
        break;
    };

    if (msg:len > max_len) {
        sl_send_reply("513", "Message Overflow");
        break;
    };

        # -----------------------------------------------------------------
        # Record Route Section
        # -----------------------------------------------------------------
             if (method=="INVITE" && client_nat_test("3")) {
                 # INSERT YOUR IP ADDRESS HERE
                 record_route_preset("81.21.33.35:5060;nat=yes");
                 } else if (method!="REGISTER") {
                  record_route();
                 };
        # -----------------------------------------------------------------
        # Call Tear Down Section
        # -----------------------------------------------------------------
               if (method=="BYE" || method=="CANCEL") {
                      end_media_session();
        };
        # -----------------------------------------------------------------
        # Loose Route Section
        # -----------------------------------------------------------------
  setflag(11);         if (loose_route() ){
------------------------------------------------------>>>>>>>>>>here i set
flag for radius accounting ;

             # mark routing logic in request
            #append_hf("P-hint: rr-enforced\r\n");

              t_relay();
               route(1);
        break;

    };




    # -----------------------------------------------------------------
    # Call Type Processing Section
    # -----------------------------------------------------------------
    if (!is_uri_host_local()) {
        if (is_from_local() || allow_trusted()) {
                route(4);
                route(1);
        } else {
                sl_send_reply("403", "Forbidden");
        };
        break;
       };


    if (method=="CANCEL") {
        route(1);
        break;
    } else if (method=="INVITE") {
        route(3);
        break;
    } else if (method=="REGISTER") {
        route(2);
        break;
    };

    lookup("aliases");
    if (uri!=myself) {
        route(4);
        route(1);
        break;
    };

    if (!lookup("location")) {
        sl_send_reply("404", "User Not Found");
        break;
    };

    route(1);
}

route[1] {

    # -----------------------------------------------------------------
    # Default Message Handler
    # -----------------------------------------------------------------
       # send it out now; use stateful forwarding as it works reliably
       # even for UDP2TCP

    t_on_reply("1");

    if (!t_relay()) {

        if (method=="INVITE" || method=="ACK") {
            end_media_session();
        };

        sl_reply_error();
    };
}


route[2] {

    # -----------------------------------------------------------------
    # REGISTER Message Handler
    # ----------------------------------------------------------------

    sl_send_reply("100", "Trying");

    if (!search("^Contact:[ ]*\*") && client_nat_test("7")) {
        setflag(6);
        fix_nated_register();
        force_rport();
    };

    if (!www_authorize("","subscriber")) {
        www_challenge("","0");
        break;
    };

       if (!check_to()) {
         xlog("L_WARN", "[%Tf]: possible uri spoofing attempt!; method=%rm;
IP=%is; from=%fu;
         to=%tu\n");

        sl_send_reply("403", "Forbidden");
        break;
    };

    consume_credentials();

    if (!save("location")) {
        sl_reply_error();
    };
}

route[3] {

           # ----------------------------------------------------------
                 # INVITE Message Handler
              # ----------------------------------------------------------
                    if (!allow_trusted()) {
                     if (!proxy_authorize("","subscriber")) {
                          proxy_challenge("","0");
                        break;
                   } else if (!check_from()) {
                      sl_send_reply("403", "Use From=ID");
                   break;
        };
                    consume_credentials();
                                             };
                   if (client_nat_test("3")) {
                      setflag(7);
                      force_rport();
                     fix_nated_contact();
                                            };
               if (uri=~"^sip:1[0-9]{8}@") {
                        strip(1);
                                               };
                    lookup("aliases");
                  if (uri!=myself) {
                   route(4);
                    route(1);
                   break;
           };
                 if (uri=~"^sip:00[0-9]*@") {
                      route(4);
                      route(5);
                       break;
                       };
          if (avp_db_load("$ruri/username", "s:callfwd")) {
                   setflag(22);
                avp_pushto("$ruri", "s:callfwd");
                      route(6);
                      break;
             };
                  if (!lookup("location")) {
                  if (uri=~"^sip:[0-9]{8}@") {
                  route(4);
                  route(5);
                  break;
          };
                   sl_send_reply("404", "User Not Found");
                    break;
          };
                 if (avp_db_load("$ruri/username", "s:fwdbusy")) {
                  if (!avp_check("s:fwdbusy", "eq/$ruri/i")) {
                  setflag(26);
          };
       };
                if (avp_db_load("$ruri/username", "s:fwdnoanswer")) {
                if (!avp_check("s:fwdnoanswer", "eq/$ruri/i")) {
                  setflag(27);
          };
      };
                t_on_failure("1");
                  route(4);
                    route(1);
           }



route[4] {

    # -----------------------------------------------------------------
    # NAT Traversal Section
    # -----------------------------------------------------------------

    if (isflagset(6) || isflagset(7)) {
              if (!isflagset(8)) {
                setflag(8);
        use_media_proxy();
             };
    };
}

      route[5] {
        # -----------------------------------------------------------------
        # PSTN Handler
        # -----------------------------------------------------------------
        rewritehost("pstn gateway ip");
        avp_write("i:30", "inv_timeout");
        t_on_failure("1");
        route(4);
        route(1);
}
route[6] {
        #  ----------------------------------------------------------
        #  Call Forwarding Handler
        #
        #  This must be done as a route block because sl_send_reply() cannot
be
        #  called from the failure_route block
        #  ----------------------------------------------------------
        if (uri=~"^sip:1[0-9]{8}@") {
                 strip(1);
        };
        lookup("aliases");
        if (uri!=myself) {
                 if (!isflagset(22)) {
                         append_branch();
                 };
                 route(4);
                 route(1);
                 break;
        };
        if (uri=~"^sip:00[0-9]*@") {
                 route(4);
                 route(5);
                 break;
         }
        if (uri=~"^sip:+[0-9]{3}[0-9]*@") {
               route(4);
               route(5);
               break;
        };
        if (!lookup("location")) {
                 if (uri=~"^sip:[0-9]{8}@") { #local pstn
                         route(4);
                         route(1);
                         break;
          };

       sl_send_reply("404", "User Not Found");
          };
            route(4);
            route(1);
          }



onreply_route[1] {


    if ((isflagset(6) || isflagset(7)) &&
(status=~"(180)|(183)|2[0-9][0-9]")) {

        if (!search("^Content-Length:[ ]*0")) {
            use_media_proxy();
        };
    };



    if (client_nat_test("1")) {
        fix_nated_contact();
    };
}

.........................)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20060904/f20a8466/attachment.htm>


More information about the sr-users mailing list