From 836c1343df4cb86ee508aa4a4d3328a1837e1394 Mon Sep 17 00:00:00 2001 From: Andrew Pogrebennyk Date: Thu, 17 Oct 2013 18:00:04 +0200 Subject: [PATCH] MT#4483 Adopt upstream patch for milliseconds precision in acc --- debian/patches/series | 2 +- .../sipwise/accounting_time_precision.patch | 154 -- .../acc-new-parameter-time_mode.patch | 2060 +++++++++++++++++ 3 files changed, 2061 insertions(+), 155 deletions(-) delete mode 100644 debian/patches/sipwise/accounting_time_precision.patch create mode 100644 debian/patches/upstream/acc-new-parameter-time_mode.patch diff --git a/debian/patches/series b/debian/patches/series index 2c0b65288..0066b0e27 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -26,11 +26,11 @@ upstream/avpops-allow-use-of-avps-as-second-parameter-on-re-o.patch upstream/avops-use-pv_cache_get-instead-of-pv_parse_spec.patch upstream/pv-Move-pv_xavp_name_t-declaration-to-core-pvar.h.patch upstream/avpops-allow-xavp-semantics-on-second-parameter.patch +upstream/acc-new-parameter-time_mode.patch no_lib64_on_64_bits.patch no_INSTALL_file.patch fix_export.patch sipwise/do-not-install-default-config.patch -sipwise/accounting_time_precision.patch sipwise/dialplan_regexp_subst.patch sipwise/unforce_rtp_proxy_one_param.patch sipwise/add_pcem_module.patch diff --git a/debian/patches/sipwise/accounting_time_precision.patch b/debian/patches/sipwise/accounting_time_precision.patch deleted file mode 100644 index 45409d7fe..000000000 --- a/debian/patches/sipwise/accounting_time_precision.patch +++ /dev/null @@ -1,154 +0,0 @@ --diff --git a/modules/acc/acc_api.h b/modules/acc/acc_api.h --index bc52eee..61bbb51 100644 ----- a/modules/acc/acc_api.h --+++ b/modules/acc/acc_api.h --@@ -57,6 +57,7 @@ typedef struct acc_enviroment { -- struct hdr_field *to; -- str text; -- time_t ts; --+ uint64_t time_hires; -- } acc_enviroment_t; -- -- /* acc extra parameter */ --diff --git a/modules/acc/acc_mod.c b/modules/acc/acc_mod.c --index 9f40e14..f8124d5 100644 ----- a/modules/acc/acc_mod.c --+++ b/modules/acc/acc_mod.c --@@ -195,6 +195,7 @@ str acc_callid_col = str_init("callid"); -- str acc_sipcode_col = str_init("sip_code"); -- str acc_sipreason_col = str_init("sip_reason"); -- str acc_time_col = str_init("time"); --+str acc_time_hires_col = str_init("time_hires"); -- int acc_db_insert_mode = 0; -- #endif -- --@@ -289,6 +290,7 @@ static param_export_t params[] = { -- {"acc_sip_code_column", STR_PARAM, &acc_sipcode_col.s }, -- {"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s }, -- {"acc_time_column", STR_PARAM, &acc_time_col.s }, --+ {"acc_time_hires_column", STR_PARAM, &acc_time_hires_col.s }, -- {"db_insert_mode", INT_PARAM, &acc_db_insert_mode }, -- #endif -- {0,0,0} --@@ -453,6 +455,7 @@ static int mod_init( void ) -- acc_sipcode_col.len = strlen(acc_sipcode_col.s); -- acc_sipreason_col.len = strlen(acc_sipreason_col.s); -- acc_time_col.len = strlen(acc_time_col.s); --+ acc_time_hires_col.len = strlen(acc_time_hires_col.s); -- #endif -- -- if (log_facility_str) { --diff --git a/modules/acc/acc_mod.h b/modules/acc/acc_mod.h --index 5e7792a..6494a30 100644 ----- a/modules/acc/acc_mod.h --+++ b/modules/acc/acc_mod.h --@@ -92,6 +92,7 @@ extern str acc_cseqno_col; -- extern str acc_sipcode_col; -- extern str acc_sipreason_col; -- extern str acc_time_col; --+extern str acc_time_hires_col; -- #endif /* SQL_ACC */ -- -- ---- a/modules/acc/acc.c -+++ b/modules/acc/acc.c -@@ -125,6 +125,14 @@ - struct hdr_field *from; - struct hdr_field *to; - -+ struct timeval tv; -+ struct timezone tz; -+ struct tm *tm; -+ uint64_t time_hires; -+ -+ gettimeofday(&tv, &tz); -+ tm = localtime(&tv.tv_sec); -+ - /* method : request/reply - cseq parsed in acc_preparse_req() */ - c_vals[0] = get_cseq(req)->method; - t_vals[0] = TYPE_STR; -@@ -174,6 +182,10 @@ - t_vals[5] = TYPE_STR; - - acc_env.ts = time(NULL); -+ -+ time_hires = (tv.tv_sec * 1000) + tv.tv_usec / 1000; -+ acc_env.time_hires = time_hires; -+ - return ACC_CORE_LEN; - } - -@@ -310,7 +322,8 @@ - db_keys[n++] = &acc_sipcode_col; - db_keys[n++] = &acc_sipreason_col; - db_keys[n++] = &acc_time_col; -- time_idx = n-1; -+ db_keys[n++] = &acc_time_hires_col; -+ time_idx = n-2; - - /* init the extra db keys */ - for(extra=db_extra; extra ; extra=extra->next) -@@ -326,6 +339,7 @@ - VAL_NULL(db_vals+i)=0; - } - VAL_TYPE(db_vals+time_idx)=DB1_DATETIME; -+ VAL_TYPE(db_vals+time_idx+1)=DB1_DOUBLE; - } - - -@@ -384,7 +398,8 @@ - VAL_STR(db_vals+i) = val_arr[i]; - /* time value */ - VAL_TIME(db_vals+(m++)) = acc_env.ts; -- -+ VAL_DOUBLE(db_vals+(m++)) = ((double) acc_env.time_hires) / 1000; -+ i = m; - /* extra columns */ - m += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m); - ---- a/modules/acc/acc_api.h -+++ b/modules/acc/acc_api.h -@@ -57,6 +57,7 @@ - struct hdr_field *to; - str text; - time_t ts; -+ uint64_t time_hires; - } acc_enviroment_t; - - /* acc extra parameter */ ---- a/modules/acc/acc_mod.c -+++ b/modules/acc/acc_mod.c -@@ -195,6 +195,7 @@ - str acc_sipcode_col = str_init("sip_code"); - str acc_sipreason_col = str_init("sip_reason"); - str acc_time_col = str_init("time"); -+str acc_time_hires_col = str_init("time_hires"); - int acc_db_insert_mode = 0; - #endif - -@@ -289,6 +290,7 @@ - {"acc_sip_code_column", STR_PARAM, &acc_sipcode_col.s }, - {"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s }, - {"acc_time_column", STR_PARAM, &acc_time_col.s }, -+ {"acc_time_hires_column", STR_PARAM, &acc_time_hires_col.s }, - {"db_insert_mode", INT_PARAM, &acc_db_insert_mode }, - #endif - {0,0,0} -@@ -453,6 +455,7 @@ - acc_sipcode_col.len = strlen(acc_sipcode_col.s); - acc_sipreason_col.len = strlen(acc_sipreason_col.s); - acc_time_col.len = strlen(acc_time_col.s); -+ acc_time_hires_col.len = strlen(acc_time_hires_col.s); - #endif - - if (log_facility_str) { ---- a/modules/acc/acc_mod.h -+++ b/modules/acc/acc_mod.h -@@ -92,6 +92,7 @@ - extern str acc_sipcode_col; - extern str acc_sipreason_col; - extern str acc_time_col; -+extern str acc_time_hires_col; - #endif /* SQL_ACC */ - - diff --git a/debian/patches/upstream/acc-new-parameter-time_mode.patch b/debian/patches/upstream/acc-new-parameter-time_mode.patch new file mode 100644 index 000000000..6bf29d99b --- /dev/null +++ b/debian/patches/upstream/acc-new-parameter-time_mode.patch @@ -0,0 +1,2060 @@ +diff --git a/modules/acc/README b/modules/acc/README +index 55bde38..f6b1c5c 100644 +--- a/modules/acc/README ++++ b/modules/acc/README +@@ -125,6 +125,12 @@ Sven Knoblich + 6.42. cdr_start_id (string) + 6.43. cdr_end_id (string) + 6.44. cdr_duration_id (string) ++ 6.45. cdr_log_enable (int) ++ 6.46. cdrs_table (str) ++ 6.47. time_mode (int) ++ 6.48. time_attr (str) ++ 6.49. time_exten (str) ++ 6.50. time_format (str) + + 7. Functions + +@@ -181,10 +187,16 @@ Sven Knoblich + 1.42. cdr_start_id example + 1.43. cdr_end_id example + 1.44. cdr_duration_id example +- 1.45. acc_log_request usage +- 1.46. acc_db_request usage +- 1.47. acc_rad_request usage +- 1.48. acc_diam_request usage ++ 1.45. cdr_log_enable example ++ 1.46. cdrs_table example ++ 1.47. time_mode example ++ 1.48. time_attr example ++ 1.49. time_exten example ++ 1.50. time_format example ++ 1.51. acc_log_request usage ++ 1.52. acc_db_request usage ++ 1.53. acc_rad_request usage ++ 1.54. acc_diam_request usage + + Chapter 1. Admin Guide + +@@ -273,6 +285,12 @@ Chapter 1. Admin Guide + 6.42. cdr_start_id (string) + 6.43. cdr_end_id (string) + 6.44. cdr_duration_id (string) ++ 6.45. cdr_log_enable (int) ++ 6.46. cdrs_table (str) ++ 6.47. time_mode (int) ++ 6.48. time_attr (str) ++ 6.49. time_exten (str) ++ 6.50. time_format (str) + + 7. Functions + +@@ -586,6 +604,7 @@ Note + + 4.3.2.1. Example for a spiraled Proxy + ++... + # A calls B (transaction 1) + $avp(caller)='A' + $avp(callee)='B'; +@@ -604,6 +623,7 @@ $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D"; + # C confirms call (200 reply of transaction 2) + $dlg_var(caller) = $avp(caller); #caller='B' + $dlg_var(callee) = $avp(callee); #callee='C' ++... + + 4.3.3. Logged data + +@@ -679,6 +699,12 @@ $dlg_var(callee) = $avp(callee); #callee='C' + 6.42. cdr_start_id (string) + 6.43. cdr_end_id (string) + 6.44. cdr_duration_id (string) ++ 6.45. cdr_log_enable (int) ++ 6.46. cdrs_table (str) ++ 6.47. time_mode (int) ++ 6.48. time_attr (str) ++ 6.49. time_exten (str) ++ 6.50. time_format (str) + + 6.1. early_media (integer) + +@@ -687,7 +713,9 @@ $dlg_var(callee) = $avp(callee); #callee='C' + Default value is 0 (no). + + Example 1.1. early_media example ++... + modparam("acc", "early_media", 1) ++... + + 6.2. failed_transaction_flag (integer) + +@@ -697,7 +725,9 @@ modparam("acc", "early_media", 1) + Default value is not-set (no flag). + + Example 1.2. failed_transaction_flag example ++... + modparam("acc", "failed_transaction_flag", 4) ++... + + 6.3. failed_filter (string) + +@@ -708,7 +738,9 @@ modparam("acc", "failed_transaction_flag", 4) + Default value is not-set (failure filtering is off). + + Example 1.3. failed_filter example ++... + modparam("acc", "failed_filter", "404,407") ++... + + 6.4. report_ack (integer) + +@@ -720,7 +752,9 @@ modparam("acc", "failed_filter", "404,407") + Default value is 0 (no). + + Example 1.4. report_ack example ++... + modparam("acc", "report_ack", 1) ++... + + 6.5. report_cancels (integer) + +@@ -731,7 +765,9 @@ modparam("acc", "report_ack", 1) + Default value is 0 (no). + + Example 1.5. report_cancels example ++... + modparam("acc", "report_cancels", 1) ++... + + 6.6. detect_direction (integer) + +@@ -746,7 +782,9 @@ modparam("acc", "report_cancels", 1) + Default value is 0 (disabled). + + Example 1.6. detect_direction example ++... + modparam("acc", "detect_direction", 1) ++... + + 6.7. acc_prepare_flag (integer) + +@@ -755,12 +793,14 @@ modparam("acc", "detect_direction", 1) + failure_route). If this flag is not set and acc or missed_call flag are + not set either in request route block, there is no way to mark the + request for transaction later. If either acc or missed_call flags are +- set in request route block, it is no need to set this flag. ++ set in request route block, there is no need to set this flag. + + Default value is not-set (no flag). + + Example 1.7. acc_prepare_flag example ++... + modparam("acc", "acc_prepare_flag", 5) ++... + + 6.8. multi_leg_info (string) + +@@ -773,6 +813,7 @@ modparam("acc", "acc_prepare_flag", 5) + Default value is 0 (disabled). + + Example 1.8. multi_leg_info example ++... + # for syslog-based accounting, use any text you want to be printed + modparam("acc", "multi_leg_info", + "text1=$avp(src);text2=$avp(dst)") +@@ -785,6 +826,7 @@ modparam("acc", "multi_leg_info", + # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer) + modparam("acc", "multi_leg_info", + "2345=$avp(src);2346=$avp(dst)") ++... + + 6.9. log_flag (integer) + +@@ -793,7 +835,9 @@ modparam("acc", "multi_leg_info", + Default value is not-set (no flag). + + Example 1.9. log_flag example ++... + modparam("acc", "log_flag", 2) ++... + + 6.10. log_missed_flag (integer) + +@@ -802,7 +846,9 @@ modparam("acc", "log_flag", 2) + Default value is not-set (no flag). + + Example 1.10. log_missed_flag example ++... + modparam("acc", "log_missed_flag", 3) ++... + + 6.11. log_level (integer) + +@@ -811,7 +857,9 @@ modparam("acc", "log_missed_flag", 3) + Default value is L_NOTICE. + + Example 1.11. log_level example ++... + modparam("acc", "log_level", 2) # Set log_level to 2 ++... + + 6.12. log_facility (string) + +@@ -822,7 +870,9 @@ modparam("acc", "log_level", 2) # Set log_level to 2 + Default value is LOG_DAEMON. + + Example 1.12. log_facility example ++... + modparam("acc", "log_facility", "LOG_DAEMON") ++... + + 6.13. log_extra (string) + +@@ -832,7 +882,9 @@ modparam("acc", "log_facility", "LOG_DAEMON") + Default value is NULL. + + Example 1.13. log_extra example ++... + modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)") ++... + + 6.14. radius_config (string) + +@@ -848,7 +900,9 @@ modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)") + Default value is "NULL". + + Example 1.14. radius_config example ++... + modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf") ++... + + 6.15. radius_flag (integer) + +@@ -858,7 +912,9 @@ modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf") + Default value is not-set (no flag). + + Example 1.15. radius_flag example ++... + modparam("acc", "radius_flag", 2) ++... + + 6.16. radius_missed_flag (integer) + +@@ -868,7 +924,9 @@ modparam("acc", "radius_flag", 2) + Default value is not-set (no flag). + + Example 1.16. radius_missed_flag example ++... + modparam("acc", "radius_missed_flag", 3) ++... + + 6.17. service_type (integer) + +@@ -877,7 +935,9 @@ modparam("acc", "radius_missed_flag", 3) + Default value is 15 (SIP). + + Example 1.17. service_type example ++... + modparam("acc", "service_type", 16) ++... + + 6.18. radius_extra (string) + +@@ -887,7 +947,9 @@ modparam("acc", "service_type", 16) + Default value is NULL. + + Example 1.18. radius_extra example ++... + modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)") ++... + + 6.19. db_flag (integer) + +@@ -897,7 +959,9 @@ modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)") + Default value is not-set (no flag). + + Example 1.19. db_flag example ++... + modparam("acc", "db_flag", 2) ++... + + 6.20. db_missed_flag (integer) + +@@ -907,7 +971,9 @@ modparam("acc", "db_flag", 2) + Default value is not-set (no flag). + + Example 1.20. db_missed_flag example ++... + modparam("acc", "db_missed_flag", 3) ++... + + 6.21. db_table_acc (string) + +@@ -917,8 +983,10 @@ modparam("acc", "db_missed_flag", 3) + Default value is "acc" + + Example 1.21. db_table_acc example ++... + modparam("acc", "db_table_acc", "myacc_table") + modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)") ++... + + 6.22. db_table_missed_calls (string) + +@@ -928,7 +996,9 @@ modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)") + Default value is "missed_calls" + + Example 1.22. db_table_missed_calls example ++... + modparam("acc", "db_table_missed_calls", "myMC_table") ++... + + 6.23. db_url (string) + +@@ -938,7 +1008,9 @@ modparam("acc", "db_table_missed_calls", "myMC_table") + Default value is "NULL" (SQL disabled). + + Example 1.23. db_url example +-modparam("acc", "db_url", "mysql://user:password@localhost/openser") ++... ++modparam("acc", "db_url", "mysql://user:password@localhost/kamailio") ++... + + 6.24. acc_method_column (string) + +@@ -948,7 +1020,9 @@ modparam("acc", "db_url", "mysql://user:password@localhost/openser") + Default value is "method". + + Example 1.24. acc_method_column example ++... + modparam("acc", "acc_method_column", "method") ++... + + 6.25. acc_from_tag_column (string) + +@@ -957,7 +1031,9 @@ modparam("acc", "acc_method_column", "method") + Default value is "from_tag". + + Example 1.25. acc_from_tag_column example ++... + modparam("acc", "acc_from_tag_column", "from_tag") ++... + + 6.26. acc_to_tag_column (string) + +@@ -966,7 +1042,9 @@ modparam("acc", "acc_from_tag_column", "from_tag") + Default value is "to_tag". + + Example 1.26. acc_to_tag_column example ++... + modparam("acc", "acc_to_tag_column", "to_tag") ++... + + 6.27. acc_callid_column (string) + +@@ -975,7 +1053,9 @@ modparam("acc", "acc_to_tag_column", "to_tag") + Default value is "callid". + + Example 1.27. acc_callid_column example ++... + modparam("acc", "acc_callid_column", "callid") ++... + + 6.28. acc_sip_code_column (string) + +@@ -985,7 +1065,9 @@ modparam("acc", "acc_callid_column", "callid") + Default value is "sip_code". + + Example 1.28. acc_sip_code_column example ++... + modparam("acc", "acc_sip_code_column", "sip_code") ++... + + 6.29. acc_sip_reason_column (string) + +@@ -995,7 +1077,9 @@ modparam("acc", "acc_sip_code_column", "sip_code") + Default value is "sip_reason". + + Example 1.29. acc_sip_reason_column example ++... + modparam("acc", "acc_sip_reason_column", "sip_reason") ++... + + 6.30. acc_time_column (string) + +@@ -1005,7 +1089,9 @@ modparam("acc", "acc_sip_reason_column", "sip_reason") + Default value is "time". + + Example 1.30. acc_time_column example ++... + modparam("acc", "acc_time_column", "time") ++... + + 6.31. db_extra (string) + +@@ -1015,7 +1101,9 @@ modparam("acc", "acc_time_column", "time") + Default value is NULL. + + Example 1.31. db_extra example ++... + modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)") ++... + + 6.32. db_insert_mode (integer) + +@@ -1026,7 +1114,9 @@ modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)") + Default value is 0 (no INSERT DELAYED). + + Example 1.32. db_insert_mode example ++... + modparam("acc", "db_insert_mode", 1) ++... + + 6.33. diameter_flag (integer) + +@@ -1036,7 +1126,9 @@ modparam("acc", "db_insert_mode", 1) + Default value is not-set (no flag). + + Example 1.33. diameter_flag example ++... + modparam("acc", "diameter_flag", 2) ++... + + 6.34. diameter_missed_flag (integer) + +@@ -1046,7 +1138,9 @@ modparam("acc", "diameter_flag", 2) + Default value is not-set (no flag). + + Example 1.34. diameter_missed_flag example ++... + modparam("acc", "diameter_missed_flag", 3) ++... + + 6.35. diameter_client_host (string) + +@@ -1056,7 +1150,9 @@ modparam("acc", "diameter_missed_flag", 3) + Default value is "localhost". + + Example 1.35. diameter_client_host example ++... + modparam("acc", "diameter_client_host", "3a_server.net") ++... + + 6.36. diameter_client_port (int) + +@@ -1066,7 +1162,9 @@ modparam("acc", "diameter_client_host", "3a_server.net") + Default value is 3000. + + Example 1.36. diameter_client_host example ++... + modparam("acc", "diameter_client_port", 3000) ++... + + 6.37. diameter_extra (string) + +@@ -1076,16 +1174,20 @@ modparam("acc", "diameter_client_port", 3000) + Default value is NULL. + + Example 1.37. diameter_extra example ++... + modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)") ++... + + 6.38. cdr_enable (integer) + + Should CDR-based logging be enabled? + +- 0 - off (default) 1 - on ++ 0 - off (default). 1 - on. + + Example 1.38. cdr_enable example ++... + modparam("acc", "cdr_enable", 1) ++... + + 6.39. cdr_start_on_confirmed (integer) + +@@ -1096,7 +1198,9 @@ modparam("acc", "cdr_enable", 1) + confirmation. + + Example 1.39. cdr_start_on_confirmed example ++... + modparam("acc", "cdr_start_on_confirmed", 1) ++... + + 6.40. cdr_facility (integer) + +@@ -1106,7 +1210,9 @@ modparam("acc", "cdr_start_on_confirmed", 1) + Default value is LOG_DAEMON. + + Example 1.40. cdr_facility example ++... + modparam("acc", "cdr_facility", "LOG_DAEMON") ++... + + 6.41. cdr_extra (string) + +@@ -1116,34 +1222,127 @@ modparam("acc", "cdr_facility", "LOG_DAEMON") + Default value is NULL. + + Example 1.41. cdr_extra example ++... + modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)" ++... + + 6.42. cdr_start_id (string) + +- Modifying the start id which is used to store the start time. ++ Modifying the id which is used to store the start time. + +- Default value is 'st' ++ Default value is 'start_time' + + Example 1.42. cdr_start_id example ++... + modparam("acc", "cdr_start_id", "start") ++... + + 6.43. cdr_end_id (string) + +- Modifying the end id which is used to store the end time. ++ Modifying the id which is used to store the end time. + +- Default value is 'et' ++ Default value is 'end_time' + + Example 1.43. cdr_end_id example ++... + modparam("acc", "cdr_end_id", "end") ++... + + 6.44. cdr_duration_id (string) + +- Modifying the duration id which is used to store the duration. ++ Modify the id which is used to store the duration. + +- Default value is 'd' ++ Default value is 'duration' + + Example 1.44. cdr_duration_id example +-modparam("acc", "cdr_duration_id", "start") ++... ++modparam("acc", "cdr_duration_id", "d") ++... ++ ++6.45. cdr_log_enable (int) ++ ++ Control if CDR-based accounting should be written to syslog. ++ ++ 0 - off. 1 - on (default). ++ ++ Example 1.45. cdr_log_enable example ++... ++modparam("acc", "cdr_log_enable", 0) ++... ++ ++6.46. cdrs_table (str) ++ ++ Name of db table to store dialog-based CDRs. ++ ++ Default value is "" (no db storage for dialog-based CDRs). ++ ++ Example 1.46. cdrs_table example ++... ++modparam("acc", "cdrs_table", "acc_cdrs") ++... ++ ++6.47. time_mode (int) ++ ++ Store additional value related to the time of event. ++ ++ Values can be: ++ * 0 - (default), save only unix timestamp for syslog and datetime for ++ database. ++ * 1 - save seconds in time_attr and microseconds in time_exten. ++ * 2 - save seconds.miliseconds in time_attr. ++ * 3 - save formatted time according to time_format parameter, using ++ the output of localtime(). ++ * 4 - save formatted time according to time_format parameter, using ++ the output of gmtime(). ++ ++ Example 1.47. time_mode example ++... ++modparam("acc", "time_mode", 1) ++... ++ ++6.48. time_attr (str) ++ ++ Name of the syslog attribute or database column where to store ++ additional value related to the time of event. ++ ++ For db accounting, the column has to be of different types, depending ++ on time_mode value. When time_mode is: ++ * 1 - time_attr column has to be int. ++ * 2 - time_attr column has to be double. ++ * 3 - time_attr column has to be varchar(128). ++ * 4 - time_attr column has to be varchar(128). ++ ++ For time_mode=1, this attribute is not written in syslog, because time ++ value is already unix timestamp, but in db accounting time value is ++ datetime and requires a function to get the timestamp. ++ ++ Example 1.48. time_attr example ++... ++modparam("acc", "time_attr", "seconds") ++... ++ ++6.49. time_exten (str) ++ ++ Name of the syslog attribute or database column where to store extended ++ value related to the time of event. ++ ++ It is used now only for time_mode=1 and database column has to be int: ++ ++ Example 1.49. time_exten example ++... ++modparam("acc", "time_exten", "micorsecs") ++... ++ ++6.50. time_format (str) ++ ++ Specify the format to print the time for time_mode 3 or 4. ++ ++ Default value is %Y-%m-%d %H:%M:%S". ++ ++ Example 1.50. time_format example ++... ++modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S") ++... + + 7. Functions + +@@ -1164,7 +1363,7 @@ modparam("acc", "cdr_duration_id", "start") + + This function can be used from ANY_ROUTE. + +- Example 1.45. acc_log_request usage ++ Example 1.51. acc_log_request usage + ... + acc_log_request("Some comment"); + ... +@@ -1182,7 +1381,7 @@ acc_log_request("Some comment"); + + This function can be used from ANY_ROUTE. + +- Example 1.46. acc_db_request usage ++ Example 1.52. acc_db_request usage + ... + acc_db_request("Some comment", "SomeTable"); + acc_db_request("Some comment", "acc_$time(year)_$time(mon)"); +@@ -1198,7 +1397,7 @@ acc_db_request("Some comment", "acc_$time(year)_$time(mon)"); + + This function can be used from ANY_ROUTE. + +- Example 1.47. acc_rad_request usage ++ Example 1.53. acc_rad_request usage + ... + acc_rad_request("Some comment"); + ... +@@ -1213,7 +1412,7 @@ acc_rad_request("Some comment"); + + This function can be used from ANY_ROUTE. + +- Example 1.48. acc_diam_request usage ++ Example 1.54. acc_diam_request usage + ... + acc_diam_request("Some comment"); + ... +diff --git a/modules/acc/acc.c b/modules/acc/acc.c +index 0a563d6..efaebc0 100644 +--- a/modules/acc/acc.c ++++ b/modules/acc/acc.c +@@ -75,6 +75,7 @@ + extern struct acc_extra *log_extra; + extern struct acc_extra *leg_info; + extern struct acc_enviroment acc_env; ++extern char *acc_time_format; + + #ifdef RAD_ACC + extern struct acc_extra *rad_extra; +@@ -90,14 +91,17 @@ extern struct acc_extra *dia_extra; + static db_func_t acc_dbf; + static db1_con_t* db_handle=0; + extern struct acc_extra *db_extra; +-extern int acc_db_insert_mode; + #endif + + /* arrays used to collect the values before being +- * pushed to the storage backend (whatever used) */ +-static str val_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG]; +-static int int_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG]; +-static char type_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG]; ++ * pushed to the storage backend (whatever used) ++ * (3 = datetime + max 2 from time_mode) */ ++static str val_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG+3]; ++static int int_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG+3]; ++static char type_arr[ACC_CORE_LEN+MAX_ACC_EXTRA+MAX_ACC_LEG+3]; ++ ++#define ACC_TIME_FORMAT_SIZE 128 ++static char acc_time_format_buf[ACC_TIME_FORMAT_SIZE]; + + /******************************************** + * acc CORE function +@@ -173,7 +177,9 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals) + c_vals[5] = acc_env.reason; + t_vals[5] = TYPE_STR; + +- acc_env.ts = time(NULL); ++ gettimeofday(&acc_env.tv, NULL); ++ acc_env.ts = acc_env.tv.tv_sec; ++ + return ACC_CORE_LEN; + } + +@@ -224,6 +230,7 @@ int acc_log_request( struct sip_msg *rq) + int n; + int m; + int i; ++ struct tm *t; + + /* get default values */ + m = core2strar( rq, val_arr, int_arr, type_arr); +@@ -275,8 +282,38 @@ int acc_log_request( struct sip_msg *rq) + *(p++) = '\n'; + *(p++) = 0; + +- LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu%s", +- acc_env.text.len, acc_env.text.s,(unsigned long) acc_env.ts, log_msg); ++ if(acc_time_mode==1) { ++ LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu;%s=%u%s", ++ acc_env.text.len, acc_env.text.s,(unsigned long)acc_env.ts, ++ acc_time_exten.s, (unsigned int)acc_env.tv.tv_usec, ++ log_msg); ++ } else if(acc_time_mode==2) { ++ LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu;%s=%.3f%s", ++ acc_env.text.len, acc_env.text.s,(unsigned long)acc_env.ts, ++ acc_time_attr.s, ++ (((double)(acc_env.tv.tv_sec * 1000) ++ + (acc_env.tv.tv_usec / 1000)) / 1000), ++ log_msg); ++ } else if(acc_time_mode==3 || acc_time_mode==4) { ++ if(acc_time_mode==3) { ++ t = localtime(&acc_env.ts); ++ } else { ++ t = gmtime(&acc_env.ts); ++ } ++ if(strftime(acc_time_format_buf, ACC_TIME_FORMAT_SIZE, ++ acc_time_format, t)<0) { ++ acc_time_format_buf[0] = '\0'; ++ } ++ LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu;%s=%s%s", ++ acc_env.text.len, acc_env.text.s,(unsigned long)acc_env.ts, ++ acc_time_attr.s, ++ acc_time_format_buf, ++ log_msg); ++ } else { ++ LM_GEN2(log_facility, log_level, "%.*stimestamp=%lu%s", ++ acc_env.text.len, acc_env.text.s,(unsigned long)acc_env.ts, ++ log_msg); ++ } + + return 1; + } +@@ -288,11 +325,20 @@ int acc_log_request( struct sip_msg *rq) + + #ifdef SQL_ACC + +-/* caution: keys need to be aligned to core format */ +-static db_key_t db_keys[ACC_CORE_LEN+1+MAX_ACC_EXTRA+MAX_ACC_LEG]; +-static db_val_t db_vals[ACC_CORE_LEN+1+MAX_ACC_EXTRA+MAX_ACC_LEG]; ++/* caution: keys need to be aligned to core format ++ * (3 = datetime + max 2 from time_mode) */ ++static db_key_t db_keys[ACC_CORE_LEN+3+MAX_ACC_EXTRA+MAX_ACC_LEG]; ++static db_val_t db_vals[ACC_CORE_LEN+3+MAX_ACC_EXTRA+MAX_ACC_LEG]; + + ++int acc_get_db_handlers(void **vf, void **vh) { ++ if(db_handle==0) ++ return -1; ++ *vf = (void*)&acc_dbf; ++ *vh = (void*)db_handle; ++ return 0; ++} ++ + static void acc_db_init_keys(void) + { + struct acc_extra *extra; +@@ -311,6 +357,13 @@ static void acc_db_init_keys(void) + db_keys[n++] = &acc_sipreason_col; + db_keys[n++] = &acc_time_col; + time_idx = n-1; ++ if(acc_time_mode==1 || acc_time_mode==2 ++ || acc_time_mode==3 || acc_time_mode==4) { ++ db_keys[n++] = &acc_time_attr; ++ if(acc_time_mode==1) { ++ db_keys[n++] = &acc_time_exten; ++ } ++ } + + /* init the extra db keys */ + for(extra=db_extra; extra ; extra=extra->next) +@@ -326,6 +379,14 @@ static void acc_db_init_keys(void) + VAL_NULL(db_vals+i)=0; + } + VAL_TYPE(db_vals+time_idx)=DB1_DATETIME; ++ if(acc_time_mode==1) { ++ VAL_TYPE(db_vals+time_idx+1)=DB1_INT; ++ VAL_TYPE(db_vals+time_idx+2)=DB1_INT; ++ } else if(acc_time_mode==2) { ++ VAL_TYPE(db_vals+time_idx+1)=DB1_DOUBLE; ++ } else if(acc_time_mode==3 || acc_time_mode==4) { ++ VAL_TYPE(db_vals+time_idx+1)=DB1_STRING; ++ } + } + + +@@ -376,6 +437,7 @@ int acc_db_request( struct sip_msg *rq) + int m; + int n; + int i; ++ struct tm *t; + + /* formated database columns */ + m = core2strar( rq, val_arr, int_arr, type_arr ); +@@ -384,6 +446,29 @@ int acc_db_request( struct sip_msg *rq) + VAL_STR(db_vals+i) = val_arr[i]; + /* time value */ + VAL_TIME(db_vals+(m++)) = acc_env.ts; ++ /* extra time value */ ++ if(acc_time_mode==1) { ++ VAL_INT(db_vals+(m++)) = (int)acc_env.tv.tv_sec; ++ i++; ++ VAL_INT(db_vals+(m++)) = (int)acc_env.tv.tv_usec; ++ i++; ++ } else if(acc_time_mode==2) { ++ VAL_DOUBLE(db_vals+(m++)) = ((double)(acc_env.tv.tv_sec * 1000) ++ + (acc_env.tv.tv_usec / 1000)) / 1000; ++ i++; ++ } else if(acc_time_mode==3 || acc_time_mode==4) { ++ if(acc_time_mode==3) { ++ t = localtime(&acc_env.ts); ++ } else { ++ t = gmtime(&acc_env.ts); ++ } ++ if(strftime(acc_time_format_buf, ACC_TIME_FORMAT_SIZE, ++ acc_time_format, t)<0) { ++ acc_time_format_buf[0] = '\0'; ++ } ++ VAL_STRING(db_vals+(m++)) = acc_time_format_buf; ++ i++; ++ } + + /* extra columns */ + m += extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m); +diff --git a/modules/acc/acc.h b/modules/acc/acc.h +index ef9a922..12acf98 100644 +--- a/modules/acc/acc.h ++++ b/modules/acc/acc.h +@@ -92,6 +92,7 @@ int acc_db_init(const str* db_url); + int acc_db_init_child(const str* db_url); + void acc_db_close(void); + int acc_db_request( struct sip_msg *req); ++int acc_get_db_handlers(void **vf, void **vh); + #endif + + #ifdef RAD_ACC +diff --git a/modules/acc/acc_api.h b/modules/acc/acc_api.h +index bc52eee..aa51380 100644 +--- a/modules/acc/acc_api.h ++++ b/modules/acc/acc_api.h +@@ -36,6 +36,7 @@ + + #include + #include ++#include + + #include "../../str.h" + #include "../../dprint.h" +@@ -57,6 +58,7 @@ typedef struct acc_enviroment { + struct hdr_field *to; + str text; + time_t ts; ++ struct timeval tv; + } acc_enviroment_t; + + /* acc extra parameter */ +@@ -104,7 +106,7 @@ typedef struct acc_engine { + + #define MAX_ACC_EXTRA 64 + #define MAX_ACC_LEG 16 +-#define ACC_CORE_LEN 6 ++#define ACC_CORE_LEN 6 + + + enum {TYPE_NULL = 0, TYPE_INT, TYPE_STR}; +diff --git a/modules/acc/acc_cdr.c b/modules/acc/acc_cdr.c +index 996ebf4..68792e9 100644 +--- a/modules/acc/acc_cdr.c ++++ b/modules/acc/acc_cdr.c +@@ -45,6 +45,10 @@ + #include "acc_extra.h" + #include "acc.h" + ++#ifdef SQL_ACC ++#include "../../lib/srdb1/db.h" ++#endif ++ + #include + + /* Solaris does not provide timersub macro in */ +@@ -75,13 +79,15 @@ static const str empty_string = { "", 0}; + // buffers which are used to collect the crd data for writing + static str cdr_attrs[ MAX_CDR_CORE + MAX_CDR_EXTRA]; + static str cdr_value_array[ MAX_CDR_CORE + MAX_CDR_EXTRA]; +-static int cdr_int_arr[ MAX_CDR_CORE + MAX_CDR_EXTRA]; ++static int cdr_int_array[ MAX_CDR_CORE + MAX_CDR_EXTRA]; + static char cdr_type_array[ MAX_CDR_CORE + MAX_CDR_EXTRA]; + + extern struct tm_binds tmb; + extern str cdr_start_str; + extern str cdr_end_str; + extern str cdr_duration_str; ++extern str acc_cdrs_table; ++extern int cdr_log_enable; + + /* write all basic information to buffers(e.g. start-time ...) */ + static int cdr_core2strar( struct dlg_cell* dlg, +@@ -115,8 +121,81 @@ static int cdr_core2strar( struct dlg_cell* dlg, + return MAX_CDR_CORE; + } + ++#ifdef SQL_ACC ++/* caution: keys need to be aligned to core format */ ++static db_key_t db_cdr_keys[ MAX_CDR_CORE + MAX_CDR_EXTRA]; ++static db_val_t db_cdr_vals[ MAX_CDR_CORE + MAX_CDR_EXTRA]; ++ + /* collect all crd data and write it to a syslog */ +-static int write_cdr( struct dlg_cell* dialog, ++static int db_write_cdr( struct dlg_cell* dialog, ++ struct sip_msg* message) ++{ ++ int m = 0; ++ int i; ++ db_func_t *df=NULL; ++ db1_con_t *dh=NULL; ++ void *vf=NULL; ++ void *vh=NULL; ++ ++ if(acc_cdrs_table.len<=0) ++ return 0; ++ ++ if(acc_get_db_handlers(&vf, &vh)<0) { ++ LM_ERR("cannot get db handlers\n"); ++ return -1; ++ } ++ df = (db_func_t*)vf; ++ dh = (db1_con_t*)vh; ++ ++ /* get default values */ ++ m = cdr_core2strar( dialog, ++ cdr_value_array, ++ cdr_int_array, ++ cdr_type_array); ++ ++ for(i=0; iuse_table(dh, &acc_cdrs_table /*table*/) < 0) { ++ LM_ERR("error in use_table\n"); ++ return -1; ++ } ++ ++ if(acc_db_insert_mode==1 && df->insert_delayed!=NULL) { ++ if (df->insert_delayed(dh, db_cdr_keys, db_cdr_vals, m) < 0) { ++ LM_ERR("failed to insert delayed into database\n"); ++ return -1; ++ } ++ } else { ++ if (df->insert(dh, db_cdr_keys, db_cdr_vals, m) < 0) { ++ LM_ERR("failed to insert into database\n"); ++ return -1; ++ } ++ } ++ ++ return 0; ++} ++#endif ++ ++/* collect all crd data and write it to a syslog */ ++static int log_write_cdr( struct dlg_cell* dialog, + struct sip_msg* message) + { + static char cdr_message[ MAX_SYSLOG_SIZE]; +@@ -127,23 +206,20 @@ static int write_cdr( struct dlg_cell* dialog, + int message_index = 0; + int counter = 0; + +- if( !dialog || !message) +- { +- LM_ERR( "dialog and/or message is/are empty!"); +- return -1; +- } ++ if(cdr_log_enable==0) ++ return 0; + + /* get default values */ + message_index = cdr_core2strar( dialog, + cdr_value_array, +- cdr_int_arr, ++ cdr_int_array, + cdr_type_array); + + /* get extra values */ + message_index += extra2strar( cdr_extra, + message, + cdr_value_array + message_index, +- cdr_int_arr + message_index, ++ cdr_int_array + message_index, + cdr_type_array + message_index); + + for( counter = 0, message_position = cdr_message; +@@ -194,6 +270,23 @@ static int write_cdr( struct dlg_cell* dialog, + return 0; + } + ++/* collect all crd data and write it to a syslog */ ++static int write_cdr( struct dlg_cell* dialog, ++ struct sip_msg* message) ++{ ++ int ret = 0; ++ if( !dialog || !message) ++ { ++ LM_ERR( "dialog or message is empty!"); ++ return -1; ++ } ++ ret = log_write_cdr(dialog, message); ++#ifdef SQL_ACC ++ ret |= db_write_cdr(dialog, message); ++#endif ++ return ret; ++} ++ + /* convert a string into a timeval struct */ + static int string2time( str* time_str, struct timeval* time_value) + { +@@ -495,7 +588,7 @@ static void cdr_on_end( struct dlg_cell* dialog, + } + } + +-/* callback for a expired dialog. */ ++/* callback for an expired dialog. */ + static void cdr_on_expired( struct dlg_cell* dialog, + int type, + struct dlg_cb_params* params) +diff --git a/modules/acc/acc_logic.c b/modules/acc/acc_logic.c +index c9bdd20..50278fb 100644 +--- a/modules/acc/acc_logic.c ++++ b/modules/acc/acc_logic.c +@@ -197,8 +197,7 @@ int acc_db_set_table_name(struct sip_msg *msg, void *param, str *table) + return -1; + } + strncpy(db_table_name_buf, dbtable.s, dbtable.len); +- /* FS#327: since the buffer is static terminate the table name */ +- db_table_name_buf[dbtable.len] = '\0'; ++ db_table_name_buf[dbtable.len] = '\0'; + env_set_text(db_table_name_buf, dbtable.len); + } else { + if(table==NULL) { +diff --git a/modules/acc/acc_mod.c b/modules/acc/acc_mod.c +index 9f40e14..2fb9258 100644 +--- a/modules/acc/acc_mod.c ++++ b/modules/acc/acc_mod.c +@@ -109,7 +109,17 @@ unsigned short failed_filter[MAX_FAILED_FILTER_COUNT + 1]; + static char* leg_info_str = 0; /*!< multi call-leg support */ + struct acc_extra *leg_info = 0; + int acc_prepare_flag = -1; /*!< should the request be prepared for later acc */ ++char *acc_time_format = "%Y-%m-%d %H:%M:%S"; + ++/* ----- time mode variables ------- */ ++/*! \name AccTimeModeVariables Time Mode Variables */ ++/*@{*/ ++ ++int acc_time_mode = 0; ++str acc_time_attr = str_init("time_attr"); ++str acc_time_exten = str_init("time_exten"); ++ ++/*@}*/ + + /* ----- SYSLOG acc variables ----------- */ + /*! \name AccSyslogVariables Syslog Variables */ +@@ -130,15 +140,18 @@ struct acc_extra *log_extra = 0; /*!< Log extra attributes */ + /*@{*/ + + int cdr_enable = 0; ++int cdr_log_enable = 1; + int cdr_start_on_confirmed = 0; + static char* cdr_facility_str = 0; + static char* cdr_log_extra_str = 0; + +-str cdr_start_str = str_init("st"); +-str cdr_end_str = str_init("et"); +-str cdr_duration_str = str_init("d"); ++str cdr_start_str = str_init("start_time"); ++str cdr_end_str = str_init("end_time"); ++str cdr_duration_str = str_init("duration"); ++/* name for db table to store dialog-based cdrs */ ++str acc_cdrs_table = str_init(""); + +-/*@{*/ ++/*@}*/ + + /* ----- RADIUS acc variables ----------- */ + /*! \name AccRadiusVariables Radius Variables */ +@@ -253,6 +266,7 @@ static param_export_t params[] = { + {"log_extra", STR_PARAM, &log_extra_str }, + /* cdr specific */ + {"cdr_enable", INT_PARAM, &cdr_enable }, ++ {"cdr_log_enable", INT_PARAM, &cdr_log_enable }, + {"cdr_start_on_confirmed", INT_PARAM, &cdr_start_on_confirmed }, + {"cdr_facility", STR_PARAM, &cdr_facility_str }, + {"cdr_extra", STR_PARAM, &cdr_log_extra_str }, +@@ -291,6 +305,12 @@ static param_export_t params[] = { + {"acc_time_column", STR_PARAM, &acc_time_col.s }, + {"db_insert_mode", INT_PARAM, &acc_db_insert_mode }, + #endif ++ /* time-mode-specific */ ++ {"time_mode", INT_PARAM, &acc_time_mode }, ++ {"time_attr", PARAM_STR, &acc_time_attr }, ++ {"time_exten", PARAM_STR, &acc_time_exten }, ++ {"cdrs_table", PARAM_STR, &acc_cdrs_table }, ++ {"time_format", STR_PARAM, &acc_time_format }, + {0,0,0} + }; + +diff --git a/modules/acc/acc_mod.h b/modules/acc/acc_mod.h +index 5e7792a..98cef33 100644 +--- a/modules/acc/acc_mod.h ++++ b/modules/acc/acc_mod.h +@@ -92,7 +92,14 @@ extern str acc_cseqno_col; + extern str acc_sipcode_col; + extern str acc_sipreason_col; + extern str acc_time_col; ++ ++extern int acc_db_insert_mode; + #endif /* SQL_ACC */ + ++/* time mode */ ++extern int acc_time_mode; ++extern str acc_time_attr; ++extern str acc_time_exten; ++ + + #endif +diff --git a/modules/acc/doc/acc_admin.xml b/modules/acc/doc/acc_admin.xml +index a60ba34..97858be 100644 +--- a/modules/acc/doc/acc_admin.xml ++++ b/modules/acc/doc/acc_admin.xml +@@ -373,7 +373,7 @@ if (uri=~"sip:+40") /* calls to Romania */ { + cdr_extra_definition = cdr_log_name '=' pseudo_variable + + +- See also . ++ See also . + + The full list of supported pseudo-variables in Sip-Router is + available at: +@@ -415,6 +415,7 @@ if (uri=~"sip:+40") /* calls to Romania */ { +
+ Example for a spiraled Proxy + ++... + # A calls B (transaction 1) + $avp(caller)='A' + $avp(callee)='B'; +@@ -433,6 +434,7 @@ $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D"; + # C confirms call (200 reply of transaction 2) + $dlg_var(caller) = $avp(caller); #caller='B' + $dlg_var(callee) = $avp(callee); #callee='C' ++... + +
+ +@@ -493,7 +495,7 @@ $dlg_var(callee) = $avp(callee); #callee='C' +
+ Parameters + +-
++
+ <varname>early_media</varname> (integer) + + Should be early media (any provisional reply with body) accounted too ? +@@ -504,11 +506,13 @@ $dlg_var(callee) = $avp(callee); #callee='C' + + early_media example + ++... + modparam("acc", "early_media", 1) ++... + + +
+-
++
+ <varname>failed_transaction_flag</varname> (integer) + + Per transaction flag which says if the transaction should be +@@ -520,11 +524,13 @@ modparam("acc", "early_media", 1) + + failed_transaction_flag example + ++... + modparam("acc", "failed_transaction_flag", 4) ++... + + +
+-
++
+ <varname>failed_filter</varname> (string) + + A string of failure response codes from 300 to 999 +@@ -538,11 +544,13 @@ modparam("acc", "failed_transaction_flag", 4) + + failed_filter example + ++... + modparam("acc", "failed_filter", "404,407") ++... + + +
+-
++
+ <varname>report_ack</varname> (integer) + + Shall acc attempt to account e2e ACKs too ? Note that this is really +@@ -556,11 +564,13 @@ modparam("acc", "failed_filter", "404,407") + + report_ack example + ++... + modparam("acc", "report_ack", 1) ++... + + +
+-
++
+ <varname>report_cancels</varname> (integer) + + By default, CANCEL reporting is disabled -- most accounting +@@ -573,11 +583,13 @@ modparam("acc", "report_ack", 1) + + report_cancels example + ++... + modparam("acc", "report_cancels", 1) ++... + + +
+-
++
+ <varname>detect_direction</varname> (integer) + + Controlles the direction detection for sequential requests. If +@@ -595,11 +607,13 @@ modparam("acc", "report_cancels", 1) + + detect_direction example + ++... + modparam("acc", "detect_direction", 1) ++... + + +
+-
++
+ <varname>acc_prepare_flag</varname> (integer) + + Per transaction flag which says if the transaction may be accounted +@@ -607,7 +621,7 @@ modparam("acc", "detect_direction", 1) + failure_route). If this flag is not set and acc or missed_call flag + are not set either in request route block, there is no way to mark the + request for transaction later. If either acc or missed_call flags are +- set in request route block, it is no need to set this flag. ++ set in request route block, there is no need to set this flag. + + + Default value is not-set (no flag). +@@ -615,11 +629,13 @@ modparam("acc", "detect_direction", 1) + + acc_prepare_flag example + ++... + modparam("acc", "acc_prepare_flag", 5) ++... + + +
+-
++
+ <varname>multi_leg_info</varname> (string) + + Defines the AVP set to be used in per-call-leg accounting. +@@ -635,6 +651,7 @@ modparam("acc", "acc_prepare_flag", 5) + + multi_leg_info example + ++... + # for syslog-based accounting, use any text you want to be printed + modparam("acc", "multi_leg_info", + "text1=$avp(src);text2=$avp(dst)") +@@ -647,11 +664,12 @@ modparam("acc", "multi_leg_info", + # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer) + modparam("acc", "multi_leg_info", + "2345=$avp(src);2346=$avp(dst)") ++... + + +
+ +-
++
+ <varname>log_flag</varname> (integer) + + Request flag which needs to be set to account a transaction via syslog. +@@ -662,11 +680,13 @@ modparam("acc", "multi_leg_info", + + log_flag example + ++... + modparam("acc", "log_flag", 2) ++... + + +
+-
++
+ <varname>log_missed_flag</varname> (integer) + + Request flag which needs to be set to account missed calls via syslog. +@@ -677,11 +697,13 @@ modparam("acc", "log_flag", 2) + + log_missed_flag example + ++... + modparam("acc", "log_missed_flag", 3) ++... + + +
+-
++
+ <varname>log_level</varname> (integer) + + Log level at which accounting messages are issued to syslog. +@@ -692,11 +714,13 @@ modparam("acc", "log_missed_flag", 3) + + log_level example + ++... + modparam("acc", "log_level", 2) # Set log_level to 2 ++... + + +
+-
++
+ <varname>log_facility</varname> (string) + + Log facility to which accounting messages are issued to syslog. +@@ -709,11 +733,13 @@ modparam("acc", "log_level", 2) # Set log_level to 2 + + log_facility example + ++... + modparam("acc", "log_facility", "LOG_DAEMON") ++... + + +
+-
++
+ <varname>log_extra</varname> (string) + + Extra values to be logged. +@@ -725,12 +751,14 @@ modparam("acc", "log_facility", "LOG_DAEMON") + + log_extra example + ++... + modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)") ++... + + +
+ +-
++
+ <varname>radius_config</varname> (string) + + This parameter is radius specific. Path to +@@ -750,11 +778,13 @@ modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)") + + radius_config example + ++... + modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf") ++... + + +
+-
++
+ <varname>radius_flag</varname> (integer) + + Request flag which needs to be set to account a +@@ -766,11 +796,13 @@ modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf") + + radius_flag example + ++... + modparam("acc", "radius_flag", 2) ++... + + +
+-
++
+ <varname>radius_missed_flag</varname> (integer) + + Request flag which needs to be set to account missed +@@ -782,11 +814,13 @@ modparam("acc", "radius_flag", 2) + + radius_missed_flag example + ++... + modparam("acc", "radius_missed_flag", 3) ++... + + +
+-
++
+ <varname>service_type</varname> (integer) + + Radius service type used for accounting. +@@ -797,11 +831,13 @@ modparam("acc", "radius_missed_flag", 3) + + service_type example + ++... + modparam("acc", "service_type", 16) ++... + + +
+-
++
+ <varname>radius_extra</varname> (string) + + Extra values to be logged via RADIUS - RADIUS specific. +@@ -813,12 +849,14 @@ modparam("acc", "service_type", 16) + + radius_extra example + ++... + modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)") ++... + + +
+ +-
++
+ <varname>db_flag</varname> (integer) + + Request flag which needs to be set to account a +@@ -830,11 +868,13 @@ modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)") + + db_flag example + ++... + modparam("acc", "db_flag", 2) ++... + + +
+-
++
+ <varname>db_missed_flag</varname> (integer) + + Request flag which needs to be set to account missed +@@ -846,11 +886,13 @@ modparam("acc", "db_flag", 2) + + db_missed_flag example + ++... + modparam("acc", "db_missed_flag", 3) ++... + + +
+-
++
+ <varname>db_table_acc</varname> (string) + + Table name of accounting successfull calls -- database specific. It +@@ -862,12 +904,14 @@ modparam("acc", "db_missed_flag", 3) + + db_table_acc example + ++... + modparam("acc", "db_table_acc", "myacc_table") + modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)") ++... + + +
+-
++
+ <varname>db_table_missed_calls</varname> (string) + + Table name for accounting missed calls -- database specific. It +@@ -879,11 +923,13 @@ modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)") + + db_table_missed_calls example + ++... + modparam("acc", "db_table_missed_calls", "myMC_table") ++... + + +
+-
++
+ <varname>db_url</varname> (string) + + SQL address -- database specific. If is set to NULL or emty string, +@@ -895,11 +941,13 @@ modparam("acc", "db_table_missed_calls", "myMC_table") + + db_url example + +-modparam("acc", "db_url", "mysql://user:password@localhost/openser") ++... ++modparam("acc", "db_url", "mysql://user:password@localhost/kamailio") ++... + + +
+-
++
+ <varname>acc_method_column</varname> (string) + + Column name in accounting table to store the request's method name as +@@ -911,11 +959,13 @@ modparam("acc", "db_url", "mysql://user:password@localhost/openser") + + acc_method_column example + ++... + modparam("acc", "acc_method_column", "method") ++... + + +
+-
++
+ <varname>acc_from_tag_column</varname> (string) + + Column name in accounting table to store the From header TAG parameter. +@@ -926,11 +976,13 @@ modparam("acc", "acc_method_column", "method") + + acc_from_tag_column example + ++... + modparam("acc", "acc_from_tag_column", "from_tag") ++... + + +
+-
++
+ <varname>acc_to_tag_column</varname> (string) + + Column name in accounting table to store the To header TAG parameter. +@@ -941,11 +993,13 @@ modparam("acc", "acc_from_tag_column", "from_tag") + + acc_to_tag_column example + ++... + modparam("acc", "acc_to_tag_column", "to_tag") ++... + + +
+-
++
+ <varname>acc_callid_column</varname> (string) + + Column name in accounting table to store the request's Callid value. +@@ -956,11 +1010,13 @@ modparam("acc", "acc_to_tag_column", "to_tag") + + acc_callid_column example + ++... + modparam("acc", "acc_callid_column", "callid") ++... + + +
+-
++
+ <varname>acc_sip_code_column</varname> (string) + + Column name in accounting table to store the final reply's numric code +@@ -972,11 +1028,13 @@ modparam("acc", "acc_callid_column", "callid") + + acc_sip_code_column example + ++... + modparam("acc", "acc_sip_code_column", "sip_code") ++... + + +
+-
++
+ <varname>acc_sip_reason_column</varname> (string) + + Column name in accounting table to store the final reply's reason +@@ -988,11 +1046,13 @@ modparam("acc", "acc_sip_code_column", "sip_code") + + acc_sip_reason_column example + ++... + modparam("acc", "acc_sip_reason_column", "sip_reason") ++... + + +
+-
++
+ <varname>acc_time_column</varname> (string) + + Column name in accounting table to store the time stamp of the +@@ -1004,11 +1064,13 @@ modparam("acc", "acc_sip_reason_column", "sip_reason") + + acc_time_column example + ++... + modparam("acc", "acc_time_column", "time") ++... + + +
+-
++
+ <varname>db_extra</varname> (string) + + Extra values to be logged into database - DB specific. +@@ -1020,11 +1082,13 @@ modparam("acc", "acc_time_column", "time") + + db_extra example + ++... + modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)") ++... + + +
+-
++
+ <varname>db_insert_mode</varname> (integer) + + If set to 1, use INSERT DELAYED to add records to accounting tables +@@ -1037,12 +1101,14 @@ modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)") + + db_insert_mode example + ++... + modparam("acc", "db_insert_mode", 1) ++... + + +
+ +-
++
+ <varname>diameter_flag</varname> (integer) + + Request flag which needs to be set to account a +@@ -1054,11 +1120,13 @@ modparam("acc", "db_insert_mode", 1) + + diameter_flag example + ++... + modparam("acc", "diameter_flag", 2) ++... + + +
+-
++
+ <varname>diameter_missed_flag</varname> (integer) + + Request flag which needs to be set to account missed +@@ -1070,11 +1138,13 @@ modparam("acc", "diameter_flag", 2) + + diameter_missed_flag example + ++... + modparam("acc", "diameter_missed_flag", 3) ++... + + +
+-
++
+ <varname>diameter_client_host</varname> (string) + + Hostname of the machine where the DIAMETER Client is +@@ -1086,11 +1156,13 @@ modparam("acc", "diameter_missed_flag", 3) + + diameter_client_host example + ++... + modparam("acc", "diameter_client_host", "3a_server.net") ++... + + +
+-
++
+ <varname>diameter_client_port</varname> (int) + + Port number where the Diameter Client is +@@ -1102,11 +1174,13 @@ modparam("acc", "diameter_client_host", "3a_server.net") + + diameter_client_host example + ++... + modparam("acc", "diameter_client_port", 3000) ++... + + +
+-
++
+ <varname>diameter_extra</varname> (string) + + Extra values to be logged via DIAMETER - DIAMETER specific. +@@ -1118,31 +1192,35 @@ modparam("acc", "diameter_client_port", 3000) + + diameter_extra example + ++... + modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)") ++... + + +
+-
++
+ <varname>cdr_enable</varname> (integer) + + Should CDR-based logging be enabled? + + +- 0 - off (default) +- 1 - on ++ 0 - off (default). ++ 1 - on. + + + cdr_enable example + ++... + modparam("acc", "cdr_enable", 1) ++... + + +
+-
++
+ <varname>cdr_start_on_confirmed</varname> (integer) + + Should the start time be taken from the time when the dialog is created, +- or when the dialog is confirmed? ++ or when the dialog is confirmed? + + + 0 - use time of dialog creation (default). +@@ -1151,11 +1229,13 @@ modparam("acc", "cdr_enable", 1) + + cdr_start_on_confirmed example + ++... + modparam("acc", "cdr_start_on_confirmed", 1) ++... + + +
+-
++
+ <varname>cdr_facility</varname> (integer) + + Log facility to which CDR messages are issued to syslog. +@@ -1168,11 +1248,13 @@ modparam("acc", "cdr_start_on_confirmed", 1) + + cdr_facility example + ++... + modparam("acc", "cdr_facility", "LOG_DAEMON") ++... + + +
+-
++
+ <varname>cdr_extra</varname> (string) + + Set of pseudo-variables defining custom CDR fields. See +@@ -1184,52 +1266,210 @@ modparam("acc", "cdr_facility", "LOG_DAEMON") + + cdr_extra example + ++... + modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)" ++... + + +
+-
++
+ <varname>cdr_start_id</varname> (string) + +- Modifying the start id which is used to store the start time. ++ Modifying the id which is used to store the start time. + + +- Default value is 'st' ++ Default value is 'start_time' + + + cdr_start_id example + ++... + modparam("acc", "cdr_start_id", "start") ++... + + +
+-
++
+ <varname>cdr_end_id</varname> (string) + +- Modifying the end id which is used to store the end time. ++ Modifying the id which is used to store the end time. + + +- Default value is 'et' ++ Default value is 'end_time' + + + cdr_end_id example + ++... + modparam("acc", "cdr_end_id", "end") ++... + + +
+-
++
+ <varname>cdr_duration_id</varname> (string) + +- Modifying the duration id which is used to store the duration. ++ Modify the id which is used to store the duration. + + +- Default value is 'd' ++ Default value is 'duration' + + + cdr_duration_id example + +-modparam("acc", "cdr_duration_id", "start") ++... ++modparam("acc", "cdr_duration_id", "d") ++... ++ ++ ++
++
++ <varname>cdr_log_enable</varname> (int) ++ ++ Control if CDR-based accounting should be written to syslog. ++ ++ ++ 0 - off. ++ 1 - on (default). ++ ++ ++ cdr_log_enable example ++ ++... ++modparam("acc", "cdr_log_enable", 0) ++... ++ ++ ++
++
++ <varname>cdrs_table</varname> (str) ++ ++ Name of db table to store dialog-based CDRs. ++ ++ ++ Default value is "" (no db storage for dialog-based CDRs). ++ ++ ++ cdrs_table example ++ ++... ++modparam("acc", "cdrs_table", "acc_cdrs") ++... ++ ++ ++
++
++ <varname>time_mode</varname> (int) ++ ++ Store additional value related to the time of event. ++ ++ ++ Values can be: ++ ++ ++ ++ 0 - (default), save only unix ++ timestamp for syslog and datetime for database. ++ ++ ++ 1 - save seconds in time_attr and ++ microseconds in time_exten. ++ ++ ++ 2 - save seconds.miliseconds ++ in time_attr. ++ ++ ++ 3 - save formatted time according ++ to time_format parameter, using the output of localtime(). ++ ++ ++ ++ 4 - save formatted time according ++ to time_format parameter, using the output of gmtime(). ++ ++ ++ ++ ++ ++ time_mode example ++ ++... ++modparam("acc", "time_mode", 1) ++... ++ ++ ++
++
++ <varname>time_attr</varname> (str) ++ ++ Name of the syslog attribute or database column where to store additional ++ value related to the time of event. ++ ++ ++ For db accounting, the column has to be of different types, depending on ++ time_mode value. When time_mode is: ++ ++ ++ ++ 1 - time_attr column has to be int. ++ ++ ++ 2 - time_attr column has to be double. ++ ++ ++ 3 - time_attr column has to be varchar(128). ++ ++ ++ 4 - time_attr column has to be varchar(128). ++ ++ ++ ++ For time_mode=1, this attribute is not written in syslog, because time ++ value is already unix timestamp, but in db accounting time value is ++ datetime and requires a function to get the timestamp. ++ ++ ++ time_attr example ++ ++... ++modparam("acc", "time_attr", "seconds") ++... ++ ++ ++
++
++ <varname>time_exten</varname> (str) ++ ++ Name of the syslog attribute or database column where to store extended ++ value related to the time of event. ++ ++ ++ It is used now only for time_mode=1 and database column has to be int: ++ ++ ++ time_exten example ++ ++... ++modparam("acc", "time_exten", "micorsecs") ++... ++ ++ ++
++
++ <varname>time_format</varname> (str) ++ ++ Specify the format to print the time for time_mode 3 or 4. ++ ++ ++ Default value is %Y-%m-%d %H:%M:%S". ++ ++ ++ time_format example ++ ++... ++modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S") ++... + + +