Hello all,

     I finally got accounting on db to work. I added a few extra fields and its all fine. But i have some questions:

I added:

     modparam("acc", "db_extra", "from_uri=$fu ; to_uri=$tu ; from_user=$fU; source_ip=$si")

     to me config, and all the info gets loaded. BUT, source_ip is not always the ip from which the request was received, either that, or INVITES are not getting logged!
 well, that's really 2 questions in one... ;)

here's my config:

#
# sample config file to be used with nathelper/rtpproxy
#
# start RTPProxy with: rtpproxy -l your_public_ip -s udp:localhost:8899
#

# ----------- global configuration parameters ------------------------

debug=2            # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=yes # (cmd line: -E)

# Uncomment these lines to enter debugging mode
#fork=no
#log_stderror=yes


check_via=no    # (cmd. line: -v)
dns=no          # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
port=5060
children=20
disable_dns_blacklist=true


#

# --- module loading

mpath="/usr/lib/openser/modules/"

loadmodule "mysql.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule " registrar.so"
loadmodule "textops.so"
loadmodule "nathelper.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "mi_fifo.so"
loadmodule " dispatcher.so"
#loadmodule "domain.so"
loadmodule "xlog.so"
loadmodule "/usr/lib/openser/modules/acc.so"

modparam("acc", "early_media", 1)
modparam("acc", "report_cancels", 1)

modparam("acc", "db_flag", 2)
modparam("acc", "db_url", "mysql://openser:password@localhost/openser")
modparam("acc", "report_ack", 0)
modparam("acc", "db_missed_flag", 3)
modparam("acc", "failed_transaction_flag", 4)
modparam("acc", "db_extra", "from_uri=$fu ; to_uri=$tu ; from_user=$fU; source_ip=$si")


#
#       CONSTANTS
#

# --- setting module parameters
#modparam("domain","db_url","mysql://openser:password@localhost/openser")
#modparam("domain", "db_mode", 1)
#modparam("domain", "domain_table", "domain")
#modparam("domain", "domain_col", "domain")

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

# --- setting module parameters
modparam("dispatcher", "list_file", "/etc/openser/dispatcher.list")

# -- mi_fifo params --
modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")

modparam("usrloc|auth_db","db_url","mysql://openser:password@localhost/openser")

# -- usrloc params --
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "nat_bflag", 6)
#modparam("usrloc", "use_domain", 0)

# -- registrar params --
modparam("registrar|nathelper", "received_avp", "$avp(i:42)")

# -- auth params --
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
#modparam("auth_db", "use_domain", 0)

# -- rr params --
#modparam("rr", "enable_full_lr", 1)



# -- nathelper
modparam("nathelper", "rtpproxy_sock", "udp:1.2.3.4:8899")
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", " sip:pinger@sip.whatever.com")

#modparam("registrar", "max_contacts", 1)

# --- main routing logic
route{
        if (method=="INVITE") {
                xlog("L_NOTICE", "INVITE MESSAGE RECEIVED - START ACC\n");
                setflag(2);
                setflag(3);
                setflag(4);
        };

        if (method=="BYE") {
                xlog ("L_NOTICE", "BYE  - STOP ACCOUNTING\n");
                setflag(2);
                setflag(3);
                setflag(4);
        };

        if (method=="CANCEL") {
                xlog ("L_NOTICE", "CANCEL - STOP ACCOUNTING\n");
                setflag(2);
                setflag(3);
                setflag(4);
        };

        if (method=="REGISTER") {
                setflag(2);
                setflag(3);
                setflag(4);
        };


        if (!mf_process_maxfwd_header("100")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        };

        #if (msg:len >=  2048 ) {
        #       sl_send_reply("513", "Message too big");
        #       exit;
        #};

        # NAT detection
        route(2);

        if (!method=="REGISTER")
                record_route();

        if (loose_route()) {
                append_hf("P-hint: rr-enforced\r\n");
                route(1);
        };

        if (!uri==myself) {
#       if (!is_uri_host_local() ) {
                append_hf("P-hint: outbound\r\n");
                route(1);
        };

        if (uri==myself) {
                if (method=="REGISTER") {
                        xlog("L_NOTICE", "\nNew Registration\n");

                        if (!www_authorize(" sip.whatever.com", "subscriber")) {
                                xlog("L_NOTICE", "\nRegistration FAILED! CLIENT: $au\n");
                                www_challenge(" sip.whatever.com", "0");
                                exit;
                        };

                        if (isflagset(5)) {
                                xlog("L_NOTICE", "\nRegistration OK\n");
                                setbflag(6);
                                # if you want OPTIONS natpings uncomment next
                                # setbflag(7);
                        };
                        save("location");
                        exit;
                };

        };

        route(1);
}


route[1] {
        xlog("L_NOTICE", "\n**************IN ROUTE 1************\n");
        if (subst_uri('/(sip:.*);nat=yes/\1/')){
                setbflag(6);
        };

        if (isflagset(5)||isbflagset(6)) {
                route(3);
        }

        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}

route[2]{
        force_rport();
        if (nat_uac_test("19")) {
                if (method=="REGISTER") {
                        fix_nated_register();
                } else {
                        fix_nated_contact();
                };
                setflag(5);
        };
}

route[3] {
        if (is_method("BYE|CANCEL")) {
                unforce_rtp_proxy();
        } else if (is_method("INVITE")){
                force_rtp_proxy();
                t_on_failure("1");
        };
        if (isflagset(5))
                search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
        t_on_reply("1");
}

failure_route[1] {
        if (isbflagset(6) || isflagset(5)) {
                unforce_rtp_proxy();
        }
}

onreply_route[1] {
        if ((isflagset(5) || isbflagset(6)) && status=~"(183)|(2[0-9][0-9])") {
                force_rtp_proxy();
        }
        search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');

        if (isbflagset(6)) {
                fix_nated_contact();
        }
        exit;
}


#=======================================

Thanks in advance!

Any other comment to make this cfg better, i'm all ears!!

David