– Kamailio SIP Server –

Below is an example of setting up Accounting using the acc module.

#---------------------------------------------------------------------------
# M4 defines
#---------------------------------------------------------------------------
define(`OPENSER_USER',          `user')
define(`OPENSER_PW',            `password')
define(`OPENSER_DATABASE',      `openser')
define(`OPENSER_DATABASE_HOST', `localhost')
define(`FLAG_ACC',           6)
define(`FLAG_ACC_DB',        7)
define(`FLAG_MISSED_CALL',   8)
#---------------------------------------------------------------------------
# load modules
#---------------------------------------------------------------------------
mpath="/usr/local/lib/openser/modules"
loadmodule "acc.so"
#---------------------------------------------------------------------------
# acc params
#---------------------------------------------------------------------------
modparam("acc", "db_url", "mysql://OPENSER_USER:OPENSER_PW@OPENSER_DATABASE_HOST/OPENSER_DATABASE")
modparam("acc", "db_flag", FLAG_ACC_DB)
modparam("acc", "db_missed_flag", FLAG_MISSED_CALL)
modparam("acc", "log_level", 3)
modparam("acc", "log_flag", FLAG_ACC)
modparam("acc", "log_missed_flag", FLAG_MISSED_CALL)
modparam("acc", "log_fmt", "cdfimorstup")
#modparam("acc", "multi_leg_enabled", YES)
#modparam("acc", "src_leg_avp_id", 110)
#modparam("acc", "dst_leg_avp_id", 111)
modparam("acc", "report_ack", YES)
modparam("acc", "report_cancels", YES)
modparam("acc", "failed_transaction_flag", YES)
modparam("acc", "early_media", YES)
route {
...
#---------------------------------------------------------------------------
# Setup Accounting
#---------------------------------------------------------------------------
if (is_method("BYE|CANCEL")) {
  setflag(FLAG_ACC);
  setflag(FLAG_ACC_DB);
} else if (is_method("INVITE")) {
  setflag(FLAG_ACC);
  setflag(FLAG_ACC_DB);
  setflag(FLAG_MISSED_CALL);
};
...
}