Hello everybody,

I'm trying to make mysql accounting work but it only records INVITE messages. In order to be able to use accounting records I need to have call duration except 'sip_from', 'sip_to'...etc. Is there any way to do this?

Here is my ser.cfg:

#debug=3

#fork=yes

#log_stderror=yes

listen=XX.XX.XX.XX

alias=XXXXXXXXXXXXXX.com

alias=XX.XX.XX.XX

alias=XXXXXXXXX.com

alias=www.XXXXXXXXX.com

port=5060

children=4

dns=no

rev_dns=no

fifo="/tmp/ser_fifo"

fifo_mode=0666

fifo_db_url="mysql://ser:XXXXXXXXXXXXXX@localhost/ser"

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/acc.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/mediaproxy.so"

loadmodule "/usr/local/lib/ser/modules/nathelper.so"

loadmodule "/usr/local/lib/ser/modules/textops.so"

loadmodule "/usr/local/lib/ser/modules/avpops.so"

loadmodule "/usr/local/lib/ser/modules/domain.so"

loadmodule "/usr/local/lib/ser/modules/permissions.so"

modparam("auth_db|permissions|uri_db|usrloc",

"db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")

modparam("auth_db", "calculate_ha1", 1)

modparam("auth_db", "password_column", "password")

# -------------- accounting params ----------------

#modparam("acc", "log_missed_flag", 2)

#modparam("acc", "log_level", 1)

#modparam("acc", "log_flag", 1)

modparam("acc", "db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")

modparam("acc", "db_flag", 1)

#modparam("acc", "failed_transactions", 1)

modparam("acc", "db_missed_flag", 2)

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("usrloc", "db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")

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

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

modparam("tm", "fr_inv_timer", 27)

modparam("tm", "fr_inv_timer_avp", "inv_timeout")

modparam("permissions", "db_mode", 1)

modparam("permissions", "trusted_table", "trusted")

 

# ------------- routing logic

route {

# ------------- routine checks

# initial sanity checks -- messages with

# max_forwards==0, or excessively long requests

if (!mf_process_maxfwd_header("XX")) {

sl_send_reply("483","Too Many Hops");

break;

};

if ( msg:len > max_len ) {

sl_send_reply("513", "Message too big");

break;

};

# separate the destination r-uri from the set of proxies that must be traversed

loose_route();

# we record-route all messages -- to make sure that

# subsequent messages will go through our proxy; that's

# particularly good if upstream and downstream entities

# use different transport protocol

record_route();

# loose-route processing

if (loose_route()) {

t_relay();

break;

};

# All REGISTER attempts are processed and must always be authenticated

if (method=="REGISTER") {

# make sure that users don't register infinite loops

if (search("^(Contact|m): .*@(XX\.XX\.XX\.XX|(XX\.)?XXXXXXXXX\.com)")) {

log(1, "LOG: alert: someone trying to set aor==contact\n");

sl_send_reply("476", "No Server Address in Contacts Allowed" );

break;

};

# challenge/response

if (!www_authorize("XXXXXXXXX.com", "subscriber")) {

www_challenge("XXXXXXXXX.com", "0");

break;

};

# only registered users are allowed

if (!is_user("replicator") & !check_to()) {

log(1, "LOG: unregistered user registration attempt\n");

sl_send_reply("403", "Only registered users are allowed");

break;

};

# it is an authenticated request, update Contact database now

if (!save("location")) {

sl_reply_error();

};

break;

};

# process traffic local to XXXXXXXXX and the PSTN

# Find the canonical username

lookup("aliases");

# check domain again, if it is not still local after the alias

# table lookup, just send it on its way. We do not authenticate

# traffic we forward

if (!(uri=~"^sip:(.+@)?(XX\.XX\.XX\.XX|(XX\.)?XXXXXXXXX\.com)([:;\?].*)?$")) {

route(5);

break;

};

# now check for destinations through the gateway. 911 and 9911

# are always sent to the gateway. The assumption is that other all

# numeric usernames between XX and 20 digits are really pstn numbers

# and so they are routed to the gateway

if ( (uri=~"^sip:1@.*") | (uri=~"^sip:8@.*") | (uri=~"sip:[0-9]{11,20}@.*") ) {

route(3);

break;

};

# does the user wish redirection on no availability? (i.e., is he

# in the voicemail (ser->grp) group?)

/*if (is_user_in("Request-URI", "voicemail")) {

t_on_failure("4");

setflag(4);

};*/

# handle local SIP destinations not found in usrloc db

# mostly offline or non-existent users

if (!lookup("location")) {

route(4);

break;

};

# check whether some inventive user has uploaded gateway

# contacts to usrloc to bypass authorization logic

if (uri=~"@XX\.XX\.XX\.XX([;:].*)*" ) {

log(1, "LOG: Gateway address in UsrLoc\n");

route(3);

break;

};

# this flag is used with the acc module to report missed calls

# to syslog.

setflag(2);

# do it (words to live by)

append_hf("P-hint: USRLOC\r\n");

if (!t_relay()) {

sl_reply_error();

break;

};

} /* end of initial routing logic */

 

# ------------- process traffic leaving XXXXXXXXX.com for Internet

route[2] {

# outbound requests are allowed only for registered XXXXXXXXX.com users

if (!(src_ip==XX.XX.XX.XX) &

!(proxy_authorize("XXXXXXXXX.com", "subscriber"))) {

# ACK and CANCEL have no security mechanisms so they are just

# noted

if (method=="ACK" | method=="BYE") {

log(1, "LOG: failed outbound authentication for ACK granted\n");

} else if (method=="CANCEL") {

log(1, "LOG: failed outbound authentication for CANCEL granted\n");

} else {

proxy_challenge("XXXXXXXXX.com", "0");

break;

};

};

# to maintain credibility of our proxy, we check From in INVITEs

if (!src_ip==XX.XX.XX.XX & method=="INVITE" & !check_from()) {

log(1, "LOG: Spoofed from attempt\n");

sl_send_reply("403", "Use From=id next time");

break;

};

append_hf("P-hint: OUTBOUND ON INTERNET\r\n");

if (!t_relay()) {

sl_reply_error();

break;

};

}

 

# ------------- process traffic leaving Internet for PSTN

route[3] {

# all calls through the gateway must be record routed to assure

# acl acceptance on the gateway

record_route();

# all numeric addresses beginning with 9 go to the pbx on the way

# to the PSTN

if (uri=~"^sip:2[0-9]*@(XX.XX.XX.XX|(XX\.)?XXXXXXXXX\.com)") {

if (!(src_ip==XX.XX.XX.XX | method==ACK | method=="CANCEL" | method=="BYE")) {

if (!proxy_authorize("XXXXXXXXX.com", "subscriber")) {

proxy_challenge( "XXXXXXXXX.com","0");

break;

} else if (method=="INVITE" & !check_from()) {

log(1, "LOG: Spoofed from attempt\n");

sl_send_reply("403", "Use From=id next time");

break;

};

};

# if the r-uri begins 9, does the authenticated user have

# permission for long distance

#if (uri=~"sip:2[0-9]*@.*") {

#if (!is_user_in("credentials", "ld")) {

#sl_send_reply("403", "Local calls only");

#break;

#};

#forward(XX.XX.XX.XX, 5060);

#};

#};

# authenticated and authorized, now accounting is set

#setflag(1);

};

rewritehostport("XX.XX.XX.XX:5060");

append_hf("P-hint: GATEWAY\r\n");

if ( (method=="INVITE") || (method=="ACK") || (method=="BYE") ) {

record_route();

setflag(1);

};

if (!t_relay()) {

sl_reply_error();

break;

};

}

 

# ------------- process calls for users offline

route[4] {

if (!t_newtran()) {

sl_reply_error();

};

if (!t_reply("404", "Not Found")) {

sl_reply_error();

};

break;

}

 

# ------------- process aliased outbound traffic

# inbound requests that have been aliased to an XXXXXXXXX.com domain

# are not authenticated by XXXXXXXXX.com

route[5] {

append_hf("P-hint: ALIASED-OUTBOUND\r\n");

if (!t_relay()) {

sl_reply_error();

break;

};

}

 

# ------------- CC-Diversion to voicemail

failure_route[4] {

append_branch("sip:80000@XX.XX.XX.XX");

append_urihf("CC-Diversion: ", "\r\n");

append_hf("P-hint: OFFLINE-VOICEMAIL\r\n");

t_relay();

}



FREE pop-up blocking with the new MSN Toolbar MSN Toolbar Get it now!