diff --git a/kamailio/accounting-role.cfg b/kamailio/accounting-role.cfg new file mode 100644 index 0000000..99fded7 --- /dev/null +++ b/kamailio/accounting-role.cfg @@ -0,0 +1,22 @@ +####### Flags ####### +flags + FLAG_ACC: 7, + FLAG_ACCMISSED: 8, + FLAG_ACCFAILED: 9; + +######## Accounting module ######## +loadmodule "acc.so" + +######## Accounting params ######## +modparam("acc", "early_media", 0) +modparam("acc", "report_ack", 0) +modparam("acc", "report_cancels", 1) +modparam("acc", "detect_direction", 0) +modparam("acc", "log_flag", 7) +modparam("acc", "log_level", 2) +modparam("acc", "log_missed_flag", 8) +modparam("acc", "failed_transaction_flag", 9) +modparam("acc", "log_extra", + "src_user=$fU;src_domain=$fd;src_ip=$si;" + "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") +modparam("acc", "log_facility", "LOG_LOCAL6") diff --git a/kamailio/default.cfg b/kamailio/default.cfg index ad5d5db..b59c0ac 100644 --- a/kamailio/default.cfg +++ b/kamailio/default.cfg @@ -185,6 +185,9 @@ include_file "websockets-role.cfg" #!ifdef TLS-ROLE include_file "tls-role.cfg" #!endif +#!ifdef ACCOUNTING-ROLE +include_file "accounting-role.cfg" +#!endif ####### Permissions module ########## loadmodule "permissions.so" @@ -338,6 +341,13 @@ route[HANDLE_IN_DIALOG_REQUESTS] record_route(); } if (loose_route()) { + #!ifdef ACCOUNTING-ROLE + if (is_method("BYE")) { + setflag(FLAG_ACC); + setflag(FLAG_ACCFAILED); + } + #!endif + #!ifdef WEBSOCKETS-ROLE if ($du == $null) { handle_ruri_alias(); @@ -421,6 +431,13 @@ route[RELAY] route[INTERNAL_TO_EXTERNAL_RELAY] { + #!ifdef ACCOUNTING-ROLE + if (is_method("INVITE")) { + setflag(FLAG_ACC); + setflag(FLAG_ACCFAILED); + } + #!endif + remove_hf_re("X-.*"); t_on_reply("EXTERNAL_REPLY"); @@ -432,6 +449,13 @@ route[INTERNAL_TO_EXTERNAL_RELAY] route[EXTERNAL_TO_INTERNAL_RELAY] { + #!ifdef ACCOUNTING-ROLE + if (is_method("INVITE") && is_present_hf("Proxy-Authorization")) { + setflag(FLAG_ACC); + setflag(FLAG_ACCFAILED); + } + #!endif + #!ifdef NAT-TRAVERSAL-ROLE if (!isflagset(FLAG_INTERNALLY_SOURCED)) { route(NAT_TEST_AND_CORRECT);