LCR working with mysql and accounting

Keywords: 0.9.x

0.9.0

example tables:

mysql> select * from gw;

gw_namegrp_idip_addrporturi_schemetransportprefix

sip1326156235450601119005552222
sip22238917652350601119005553333

2 rows in set (0.01 sec)

mysql> select * from lcr;

prefixfrom_urigrp_idpriority

19005552222%11
19005553333%21

2 rows in set (0.00 sec)

mysql> select * from gw_grp;

grp_idgrp_name

1sip1
2sip2

Ok this should set you up to route calls from an incoming pstn and proxy them to feature servers based on prefix (phone number)

the ip address of desitnation server needs to be this: reverse ip address, convert to binary, then convert to a decimal number

so 19005552222 will be send to sip1 and 19005553333 will be sent to sip2

make sure you are using a stable version of SER!!!!


Sample of ser.cfg

 # rogerles LCR ser.cfg
 #
 # ----------- global configuration parameters ------------------------
 # debug=9 # debug level (cmd line: -dddddddddd)
 #
 fork=yes
 log_stderror=yes# (cmd line: -E)
 check_via=no # (cmd. line: -v)
 dns=no # (cmd. line: -r)
 rev_dns=no # (cmd. line: -R)
 listen=64.201.13.52
 port=5060
 children=4
 # fifo="/tmp/ser_fifo"
 #
 #
 # ------------------ module loading ----------------------------------
 #
 loadmodule "/usr/local/lib/ser/modules/mysql.so"
 loadmodule "/usr/local/lib/ser/modules/nathelper.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/lcr.so"
 loadmodule "/usr/local/lib/ser/modules/acc.so" 
 # ----------------- setting module-specific parameters ---------------
 modparam("lcr","db_url", "mysql://root:password@localhost/openser")
 modparam("lcr","gw_table","gw")
 modparam("lcr","gw_name_column","gw_name")
 modparam("lcr","ip_addr_column","ip_addr")
 modparam("lcr","port_column","port")
 #modparam("lcr","uri_scheme_column","uri_scheme")
 #modparam("lcr","transport_column","transport")
 modparam("lcr","grp_id_column","grp_id")
 modparam("lcr","lcr_table","lcr")
 modparam("lcr","prefix_column","prefix")
 modparam("lcr","from_uri_column","from_uri")
 modparam("lcr","priority_column","priority")
 #modparam("lcr","gw_uri_avp","1400")
 modparam("lcr","contact_avp","1401")
 modparam("lcr","fr_inv_timer_avp","fr_inv_timer_avp")
 #modparam("lcr","rpid_avp","rpid")
 modparam("lcr","fr_inv_timer",90)
 modparam("lcr","fr_inv_timer_next",30)
 ###
 ### RR shit
 modparam("rr","enable_full_lr",1)
 ###
 ### ACC
 modparam("acc","db_url", "mysql://root:password@localhost/openser")
 modparam("acc", "db_flag", 2) 
 route{
 # initial sanity checks -- messages with
 # max_forwards==0, or excessively long requests
 if (!mf_process_maxfwd_header("10")) {
    sl_send_reply("483","Too Many Hops");
 break;
 };
 if (msg:len >= max_len ) {
   sl_send_reply("513", "Message too big");
 break;
 };
 # 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
 if(!method=="REGISTER"){record_route();};
   if(loose_route()){
      route(1); 
   break;
  };
 if(!load_gws()){
   sl_send_reply("500", "Internal server error, unable to load gateways");
 break;
 }
 if(!next_gw()){
   sl_send_reply("503", "Service not available, no gateways found");
 break;
 };
 route(1);
 }
 route[1]
 {
 # send it out now; use stateful forwarding as it works reliably
 # even for UDP2TCP 
 setflag(2);
 if(method=="INVITE"){
   force_rtp_proxy();
   t_on_reply("1");
 };
 if (!t_relay()) {
   sl_reply_error();
  };
 }
 onreply_route[1] {
 setflag(2);
 if (status=~"[12]0-90-9"){
   force_rtp_proxy();
 };
 }
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login