<html><div style='background-color:'><DIV class=RTE><FONT size=2>
<P>Hello everybody,</P>
<P>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?</P>
<P>Here is my ser.cfg:</P>
<P>#debug=3</P>
<P>#fork=yes</P>
<P>#log_stderror=yes</P>
<P>listen=XX.XX.XX.XX </P>
<P>alias=XXXXXXXXXXXXXX.com</P>
<P>alias=XX.XX.XX.XX</P>
<P>alias=XXXXXXXXX.com</P>
<P>alias=www.XXXXXXXXX.com</P>
<P>port=5060</P>
<P>children=4</P>
<P>dns=no</P>
<P>rev_dns=no</P>
<P>fifo="/tmp/ser_fifo"</P>
<P>fifo_mode=0666</P>
<P>fifo_db_url="mysql://ser:XXXXXXXXXXXXXX@localhost/ser"</P>
<P>loadmodule "/usr/local/lib/ser/modules/mysql.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/sl.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/tm.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/acc.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/rr.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/maxfwd.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/usrloc.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/registrar.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/auth.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/auth_db.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/uri.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/uri_db.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/mediaproxy.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/nathelper.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/textops.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/avpops.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/domain.so"</P>
<P>loadmodule "/usr/local/lib/ser/modules/permissions.so"</P>
<P>modparam("auth_db|permissions|uri_db|usrloc", </P>
<P>"db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")</P>
<P>modparam("auth_db", "calculate_ha1", 1)</P>
<P>modparam("auth_db", "password_column", "password")</P>
<P># -------------- accounting params ----------------</P>
<P>#modparam("acc", "log_missed_flag", 2)</P>
<P>#modparam("acc", "log_level", 1)</P>
<P>#modparam("acc", "log_flag", 1)</P>
<P>modparam("acc", "db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")</P>
<P>modparam("acc", "db_flag", 1)</P>
<P>#modparam("acc", "failed_transactions", 1)</P>
<P>modparam("acc", "db_missed_flag", 2)</P>
<P>modparam("nathelper", "rtpproxy_disable", 1)</P>
<P>modparam("nathelper", "natping_interval", 0)</P>
<P>modparam("mediaproxy","natping_interval", 30)</P>
<P>modparam("mediaproxy","mediaproxy_socket", "/var/run/mediaproxy.sock")</P>
<P>modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-clients")</P>
<P>modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-clients")</P>
<P>modparam("usrloc", "db_mode", 2)</P>
<P>modparam("usrloc", "db_url", "mysql://ser:XXXXXXXXXXXXXX@localhost/ser")</P>
<P>modparam("registrar", "nat_flag", 6)</P>
<P>modparam("rr", "enable_full_lr", 1)</P>
<P>modparam("tm", "fr_inv_timer", 27)</P>
<P>modparam("tm", "fr_inv_timer_avp", "inv_timeout")</P>
<P>modparam("permissions", "db_mode", 1)</P>
<P>modparam("permissions", "trusted_table", "trusted")</P>
<P>&nbsp;</P>
<P># ------------- routing logic</P>
<P>route {</P>
<P># ------------- routine checks</P>
<P># initial sanity checks -- messages with</P>
<P># max_forwards==0, or excessively long requests</P>
<P>if (!mf_process_maxfwd_header("XX")) {</P>
<P>sl_send_reply("483","Too Many Hops");</P>
<P>break;</P>
<P>};</P>
<P>if ( msg:len &gt; max_len ) {</P>
<P>sl_send_reply("513", "Message too big");</P>
<P>break;</P>
<P>};</P>
<P></P>
<P># separate the destination r-uri from the set of proxies that must be traversed</P>
<P>loose_route();</P>
<P># we record-route all messages -- to make sure that</P>
<P># subsequent messages will go through our proxy; that's</P>
<P># particularly good if upstream and downstream entities</P>
<P># use different transport protocol</P>
<P>record_route(); </P>
<P># loose-route processing</P>
<P>if (loose_route()) {</P>
<P>t_relay();</P>
<P>break;</P>
<P>};</P>
<P># All REGISTER attempts are processed and must always be authenticated</P>
<P>if (method=="REGISTER") {</P>
<P># make sure that users don't register infinite loops</P>
<P>if (search("^(Contact|m): .*@(XX\.XX\.XX\.XX|(XX\.)?XXXXXXXXX\.com)")) {</P>
<P>log(1, "LOG: alert: someone trying to set aor==contact\n");</P>
<P>sl_send_reply("476", "No Server Address in Contacts Allowed" );</P>
<P>break;</P>
<P>};</P>
<P># challenge/response</P>
<P>if (!www_authorize("XXXXXXXXX.com", "subscriber")) {</P>
<P>www_challenge("XXXXXXXXX.com", "0");</P>
<P>break;</P>
<P>};</P>
<P># only registered users are allowed</P>
<P>if (!is_user("replicator") &amp; !check_to()) {</P>
<P>log(1, "LOG: unregistered user registration attempt\n");</P>
<P>sl_send_reply("403", "Only registered users are allowed");</P>
<P>break;</P>
<P>};</P>
<P># it is an authenticated request, update Contact database now</P>
<P>if (!save("location")) {</P>
<P>sl_reply_error();</P>
<P>};</P>
<P>break;</P>
<P>};</P>
<P># process traffic local to XXXXXXXXX and the PSTN</P>
<P># Find the canonical username</P>
<P>lookup("aliases");</P>
<P># check domain again, if it is not still local after the alias</P>
<P># table lookup, just send it on its way. We do not authenticate</P>
<P># traffic we forward</P>
<P>if (!(uri=~"^sip:(.+@)?(XX\.XX\.XX\.XX|(XX\.)?XXXXXXXXX\.com)([:;\?].*)?$")) {</P>
<P>route(5);</P>
<P>break;</P>
<P>};</P>
<P># now check for destinations through the gateway. 911 and 9911</P>
<P># are always sent to the gateway. The assumption is that other all</P>
<P># numeric usernames between XX and 20 digits are really pstn numbers</P>
<P># and so they are routed to the gateway</P>
<P>if ( (uri=~"^sip:1@.*") | (uri=~"^sip:8@.*") | (uri=~"sip:[0-9]{11,20}@.*") ) {</P>
<P>route(3);</P>
<P>break;</P>
<P>};</P>
<P># does the user wish redirection on no availability? (i.e., is he</P>
<P># in the voicemail (ser-&gt;grp) group?)</P>
<P>/*if (is_user_in("Request-URI", "voicemail")) {</P>
<P>t_on_failure("4");</P>
<P>setflag(4);</P>
<P>};*/</P>
<P># handle local SIP destinations not found in usrloc db</P>
<P># mostly offline or non-existent users</P>
<P>if (!lookup("location")) {</P>
<P>route(4);</P>
<P>break;</P>
<P>};</P>
<P># check whether some inventive user has uploaded gateway</P>
<P># contacts to usrloc to bypass authorization logic</P>
<P>if (uri=~"@XX\.XX\.XX\.XX([;:].*)*" ) {</P>
<P>log(1, "LOG: Gateway address in UsrLoc\n");</P>
<P>route(3);</P>
<P>break;</P>
<P>};</P>
<P># this flag is used with the acc module to report missed calls</P>
<P># to syslog.</P>
<P>setflag(2);</P>
<P># do it (words to live by)</P>
<P>append_hf("P-hint: USRLOC\r\n");</P>
<P>if (!t_relay()) {</P>
<P>sl_reply_error();</P>
<P>break;</P>
<P>};</P>
<P>} /* end of initial routing logic */</P>
<P>&nbsp;</P>
<P># ------------- process traffic leaving XXXXXXXXX.com for Internet</P>
<P>route[2] {</P>
<P># outbound requests are allowed only for registered XXXXXXXXX.com users</P>
<P>if (!(src_ip==XX.XX.XX.XX) &amp;</P>
<P>!(proxy_authorize("XXXXXXXXX.com", "subscriber"))) {</P>
<P># ACK and CANCEL have no security mechanisms so they are just</P>
<P># noted</P>
<P>if (method=="ACK" | method=="BYE") {</P>
<P>log(1, "LOG: failed outbound authentication for ACK granted\n");</P>
<P>} else if (method=="CANCEL") {</P>
<P>log(1, "LOG: failed outbound authentication for CANCEL granted\n");</P>
<P>} else {</P>
<P>proxy_challenge("XXXXXXXXX.com", "0");</P>
<P>break;</P>
<P>};</P>
<P>};</P>
<P># to maintain credibility of our proxy, we check From in INVITEs</P>
<P>if (!src_ip==XX.XX.XX.XX &amp; method=="INVITE" &amp; !check_from()) {</P>
<P>log(1, "LOG: Spoofed from attempt\n");</P>
<P>sl_send_reply("403", "Use From=id next time");</P>
<P>break;</P>
<P>};</P>
<P>append_hf("P-hint: OUTBOUND ON INTERNET\r\n");</P>
<P>if (!t_relay()) {</P>
<P>sl_reply_error();</P>
<P>break;</P>
<P>};</P>
<P>}</P>
<P>&nbsp;</P>
<P># ------------- process traffic leaving Internet for PSTN</P>
<P>route[3] {</P>
<P># all calls through the gateway must be record routed to assure</P>
<P># acl acceptance on the gateway</P>
<P>record_route();</P>
<P># all numeric addresses beginning with 9 go to the pbx on the way</P>
<P># to the PSTN</P>
<P>if (uri=~"^sip:2[0-9]*@(XX.XX.XX.XX|(XX\.)?XXXXXXXXX\.com)") {</P>
<P>if (!(src_ip==XX.XX.XX.XX | method==ACK | method=="CANCEL" | method=="BYE")) {</P>
<P>if (!proxy_authorize("XXXXXXXXX.com", "subscriber")) {</P>
<P>proxy_challenge( "XXXXXXXXX.com","0");</P>
<P>break;</P>
<P>} else if (method=="INVITE" &amp; !check_from()) {</P>
<P>log(1, "LOG: Spoofed from attempt\n");</P>
<P>sl_send_reply("403", "Use From=id next time");</P>
<P>break;</P>
<P>};</P>
<P>};</P>
<P># if the r-uri begins 9, does the authenticated user have</P>
<P># permission for long distance</P>
<P>#if (uri=~"sip:2[0-9]*@.*") {</P>
<P>#if (!is_user_in("credentials", "ld")) {</P>
<P>#sl_send_reply("403", "Local calls only");</P>
<P>#break;</P>
<P>#};</P>
<P>#forward(XX.XX.XX.XX, 5060);</P>
<P>#};</P>
<P>#};</P>
<P># authenticated and authorized, now accounting is set</P>
<P>#setflag(1);</P>
<P>};</P>
<P></P>
<P>rewritehostport("XX.XX.XX.XX:5060");</P>
<P>append_hf("P-hint: GATEWAY\r\n");</P>
<P>if ( (method=="INVITE") || (method=="ACK") || (method=="BYE") ) {</P>
<P>record_route();</P>
<P>setflag(1);</P>
<P>};</P>
<P>if (!t_relay()) {</P>
<P>sl_reply_error();</P>
<P>break;</P>
<P>};</P>
<P>}</P>
<P>&nbsp;</P>
<P># ------------- process calls for users offline</P>
<P>route[4] {</P>
<P>if (!t_newtran()) {</P>
<P>sl_reply_error();</P>
<P>};</P>
<P>if (!t_reply("404", "Not Found")) {</P>
<P>sl_reply_error();</P>
<P>};</P>
<P>break;</P>
<P>}</P>
<P>&nbsp;</P>
<P># ------------- process aliased outbound traffic</P>
<P># inbound requests that have been aliased to an XXXXXXXXX.com domain</P>
<P># are not authenticated by XXXXXXXXX.com</P>
<P>route[5] {</P>
<P>append_hf("P-hint: ALIASED-OUTBOUND\r\n");</P>
<P>if (!t_relay()) {</P>
<P>sl_reply_error();</P>
<P>break;</P>
<P>};</P>
<P>}</P>
<P>&nbsp;</P>
<P># ------------- CC-Diversion to voicemail</P>
<P>failure_route[4] {</P>
<P>append_branch("sip:80000@XX.XX.XX.XX");</P>
<P>append_urihf("CC-Diversion: ", "\r\n");</P>
<P>append_hf("P-hint: OFFLINE-VOICEMAIL\r\n");</P>
<P>t_relay();</P>
<P>}</P></FONT></DIV></div><br clear=all><hr>FREE pop-up blocking with the new MSN Toolbar <a href="http://g.msn.com/8HMAEN/2755??PS=47575" target="_top">MSN Toolbar</a> Get it now!</html>