2
0
Эх сурвалжийг харах

modules_k/acc: added 'failed_filter' module parameter

Added 'failed_filter' module parameter that can be used to control based
on SIP response code, which failed transactions are accounted, when
'failed_transaction_flag' is set.
Juha Heinanen 14 жил өмнө
parent
commit
959ab31990

+ 218 - 208
modules_k/acc/README

@@ -58,38 +58,39 @@ Bogdan-Andrei Iancu
 
               5.1. early_media (integer)
               5.2. failed_transaction_flag (integer)
-              5.3. report_ack (integer)
-              5.4. report_cancels (integer)
-              5.5. detect_direction (integer)
-              5.6. multi_leg_info (string)
-              5.7. log_flag (integer)
-              5.8. log_missed_flag (integer)
-              5.9. log_level (integer)
-              5.10. log_facility (string)
-              5.11. log_extra (string)
-              5.12. radius_config (string)
-              5.13. radius_flag (integer)
-              5.14. radius_missed_flag (integer)
-              5.15. service_type (integer)
-              5.16. radius_extra (string)
-              5.17. db_flag (integer)
-              5.18. db_missed_flag (integer)
-              5.19. db_table_acc (string)
-              5.20. db_table_missed_calls (string)
-              5.21. db_url (string)
-              5.22. acc_method_column (string)
-              5.23. acc_from_tag_column (string)
-              5.24. acc_to_tag_column (string)
-              5.25. acc_callid_column (string)
-              5.26. acc_sip_code_column (string)
-              5.27. acc_sip_reason_column (string)
-              5.28. acc_time_column (string)
-              5.29. db_extra (string)
-              5.30. diameter_flag (integer)
-              5.31. diameter_missed_flag (integer)
-              5.32. diameter_client_host (string)
-              5.33. diameter_client_port (int)
-              5.34. diameter_extra (string)
+              5.3. failed_filter (string)
+              5.4. report_ack (integer)
+              5.5. report_cancels (integer)
+              5.6. detect_direction (integer)
+              5.7. multi_leg_info (string)
+              5.8. log_flag (integer)
+              5.9. log_missed_flag (integer)
+              5.10. log_level (integer)
+              5.11. log_facility (string)
+              5.12. log_extra (string)
+              5.13. radius_config (string)
+              5.14. radius_flag (integer)
+              5.15. radius_missed_flag (integer)
+              5.16. service_type (integer)
+              5.17. radius_extra (string)
+              5.18. db_flag (integer)
+              5.19. db_missed_flag (integer)
+              5.20. db_table_acc (string)
+              5.21. db_table_missed_calls (string)
+              5.22. db_url (string)
+              5.23. acc_method_column (string)
+              5.24. acc_from_tag_column (string)
+              5.25. acc_to_tag_column (string)
+              5.26. acc_callid_column (string)
+              5.27. acc_sip_code_column (string)
+              5.28. acc_sip_reason_column (string)
+              5.29. acc_time_column (string)
+              5.30. db_extra (string)
+              5.31. diameter_flag (integer)
+              5.32. diameter_missed_flag (integer)
+              5.33. diameter_client_host (string)
+              5.34. diameter_client_port (int)
+              5.35. diameter_extra (string)
 
         6. Exported Functions
 
@@ -104,42 +105,43 @@ Bogdan-Andrei Iancu
 
    1.1. early_media example
    1.2. failed_transaction_flag example
-   1.3. report_ack example
-   1.4. report_cancels example
-   1.5. detect_direction example
-   1.6. multi_leg_info example
-   1.7. log_flag example
-   1.8. log_missed_flag example
-   1.9. log_level example
-   1.10. log_facility example
-   1.11. log_extra example
-   1.12. radius_config example
-   1.13. radius_flag example
-   1.14. radius_missed_flag example
-   1.15. service_type example
-   1.16. radius_extra example
-   1.17. db_flag example
-   1.18. db_missed_flag example
-   1.19. db_table_acc example
-   1.20. db_table_missed_calls example
-   1.21. db_url example
-   1.22. acc_method_column example
-   1.23. acc_from_tag_column example
-   1.24. acc_to_tag_column example
-   1.25. acc_callid_column example
-   1.26. acc_sip_code_column example
-   1.27. acc_sip_reason_column example
-   1.28. acc_time_column example
-   1.29. db_extra example
-   1.30. diameter_flag example
-   1.31. diameter_missed_flag example
-   1.32. diameter_client_host example
+   1.3. failed_filter example
+   1.4. report_ack example
+   1.5. report_cancels example
+   1.6. detect_direction example
+   1.7. multi_leg_info example
+   1.8. log_flag example
+   1.9. log_missed_flag example
+   1.10. log_level example
+   1.11. log_facility example
+   1.12. log_extra example
+   1.13. radius_config example
+   1.14. radius_flag example
+   1.15. radius_missed_flag example
+   1.16. service_type example
+   1.17. radius_extra example
+   1.18. db_flag example
+   1.19. db_missed_flag example
+   1.20. db_table_acc example
+   1.21. db_table_missed_calls example
+   1.22. db_url example
+   1.23. acc_method_column example
+   1.24. acc_from_tag_column example
+   1.25. acc_to_tag_column example
+   1.26. acc_callid_column example
+   1.27. acc_sip_code_column example
+   1.28. acc_sip_reason_column example
+   1.29. acc_time_column example
+   1.30. db_extra example
+   1.31. diameter_flag example
+   1.32. diameter_missed_flag example
    1.33. diameter_client_host example
-   1.34. diameter_extra example
-   1.35. acc_log_request usage
-   1.36. acc_db_request usage
-   1.37. acc_rad_request usage
-   1.38. acc_diam_request usage
+   1.34. diameter_client_host example
+   1.35. diameter_extra example
+   1.36. acc_log_request usage
+   1.37. acc_db_request usage
+   1.38. acc_rad_request usage
+   1.39. acc_diam_request usage
 
 Chapter 1. Admin Guide
 
@@ -170,38 +172,39 @@ Chapter 1. Admin Guide
 
         5.1. early_media (integer)
         5.2. failed_transaction_flag (integer)
-        5.3. report_ack (integer)
-        5.4. report_cancels (integer)
-        5.5. detect_direction (integer)
-        5.6. multi_leg_info (string)
-        5.7. log_flag (integer)
-        5.8. log_missed_flag (integer)
-        5.9. log_level (integer)
-        5.10. log_facility (string)
-        5.11. log_extra (string)
-        5.12. radius_config (string)
-        5.13. radius_flag (integer)
-        5.14. radius_missed_flag (integer)
-        5.15. service_type (integer)
-        5.16. radius_extra (string)
-        5.17. db_flag (integer)
-        5.18. db_missed_flag (integer)
-        5.19. db_table_acc (string)
-        5.20. db_table_missed_calls (string)
-        5.21. db_url (string)
-        5.22. acc_method_column (string)
-        5.23. acc_from_tag_column (string)
-        5.24. acc_to_tag_column (string)
-        5.25. acc_callid_column (string)
-        5.26. acc_sip_code_column (string)
-        5.27. acc_sip_reason_column (string)
-        5.28. acc_time_column (string)
-        5.29. db_extra (string)
-        5.30. diameter_flag (integer)
-        5.31. diameter_missed_flag (integer)
-        5.32. diameter_client_host (string)
-        5.33. diameter_client_port (int)
-        5.34. diameter_extra (string)
+        5.3. failed_filter (string)
+        5.4. report_ack (integer)
+        5.5. report_cancels (integer)
+        5.6. detect_direction (integer)
+        5.7. multi_leg_info (string)
+        5.8. log_flag (integer)
+        5.9. log_missed_flag (integer)
+        5.10. log_level (integer)
+        5.11. log_facility (string)
+        5.12. log_extra (string)
+        5.13. radius_config (string)
+        5.14. radius_flag (integer)
+        5.15. radius_missed_flag (integer)
+        5.16. service_type (integer)
+        5.17. radius_extra (string)
+        5.18. db_flag (integer)
+        5.19. db_missed_flag (integer)
+        5.20. db_table_acc (string)
+        5.21. db_table_missed_calls (string)
+        5.22. db_url (string)
+        5.23. acc_method_column (string)
+        5.24. acc_from_tag_column (string)
+        5.25. acc_to_tag_column (string)
+        5.26. acc_callid_column (string)
+        5.27. acc_sip_code_column (string)
+        5.28. acc_sip_reason_column (string)
+        5.29. acc_time_column (string)
+        5.30. db_extra (string)
+        5.31. diameter_flag (integer)
+        5.32. diameter_missed_flag (integer)
+        5.33. diameter_client_host (string)
+        5.34. diameter_client_port (int)
+        5.35. diameter_extra (string)
 
    6. Exported Functions
 
@@ -450,38 +453,39 @@ Note
 
    5.1. early_media (integer)
    5.2. failed_transaction_flag (integer)
-   5.3. report_ack (integer)
-   5.4. report_cancels (integer)
-   5.5. detect_direction (integer)
-   5.6. multi_leg_info (string)
-   5.7. log_flag (integer)
-   5.8. log_missed_flag (integer)
-   5.9. log_level (integer)
-   5.10. log_facility (string)
-   5.11. log_extra (string)
-   5.12. radius_config (string)
-   5.13. radius_flag (integer)
-   5.14. radius_missed_flag (integer)
-   5.15. service_type (integer)
-   5.16. radius_extra (string)
-   5.17. db_flag (integer)
-   5.18. db_missed_flag (integer)
-   5.19. db_table_acc (string)
-   5.20. db_table_missed_calls (string)
-   5.21. db_url (string)
-   5.22. acc_method_column (string)
-   5.23. acc_from_tag_column (string)
-   5.24. acc_to_tag_column (string)
-   5.25. acc_callid_column (string)
-   5.26. acc_sip_code_column (string)
-   5.27. acc_sip_reason_column (string)
-   5.28. acc_time_column (string)
-   5.29. db_extra (string)
-   5.30. diameter_flag (integer)
-   5.31. diameter_missed_flag (integer)
-   5.32. diameter_client_host (string)
-   5.33. diameter_client_port (int)
-   5.34. diameter_extra (string)
+   5.3. failed_filter (string)
+   5.4. report_ack (integer)
+   5.5. report_cancels (integer)
+   5.6. detect_direction (integer)
+   5.7. multi_leg_info (string)
+   5.8. log_flag (integer)
+   5.9. log_missed_flag (integer)
+   5.10. log_level (integer)
+   5.11. log_facility (string)
+   5.12. log_extra (string)
+   5.13. radius_config (string)
+   5.14. radius_flag (integer)
+   5.15. radius_missed_flag (integer)
+   5.16. service_type (integer)
+   5.17. radius_extra (string)
+   5.18. db_flag (integer)
+   5.19. db_missed_flag (integer)
+   5.20. db_table_acc (string)
+   5.21. db_table_missed_calls (string)
+   5.22. db_url (string)
+   5.23. acc_method_column (string)
+   5.24. acc_from_tag_column (string)
+   5.25. acc_to_tag_column (string)
+   5.26. acc_callid_column (string)
+   5.27. acc_sip_code_column (string)
+   5.28. acc_sip_reason_column (string)
+   5.29. acc_time_column (string)
+   5.30. db_extra (string)
+   5.31. diameter_flag (integer)
+   5.32. diameter_missed_flag (integer)
+   5.33. diameter_client_host (string)
+   5.34. diameter_client_port (int)
+   5.35. diameter_extra (string)
 
 5.1. early_media (integer)
 
@@ -502,7 +506,18 @@ modparam("acc", "early_media", 1)
    Example 1.2. failed_transaction_flag example
 modparam("acc", "failed_transaction_flag", 4)
 
-5.3. report_ack (integer)
+5.3. failed_filter (string)
+
+   A string of failure response codes from 300 to 999 separated by commas.
+   Failed transaction will not be accounted if its response code is in the
+   list even when failed_transaction_flag is set.
+
+   Default value is not-set (failure filtering is off).
+
+   Example 1.3. failed_filter example
+modparam("acc", "failed_filter", "404,407")
+
+5.4. report_ack (integer)
 
    Shall acc attempt to account e2e ACKs too ? Note that this is really
    only an attempt, as e2e ACKs may take a different path (unless RR
@@ -511,10 +526,10 @@ modparam("acc", "failed_transaction_flag", 4)
 
    Default value is 0 (no).
 
-   Example 1.3. report_ack example
+   Example 1.4. report_ack example
 modparam("acc", "report_ack", 1)
 
-5.4. report_cancels (integer)
+5.5. report_cancels (integer)
 
    By default, CANCEL reporting is disabled -- most accounting
    applications wants to see INVITE's cancellation status. Turn on if you
@@ -522,10 +537,10 @@ modparam("acc", "report_ack", 1)
 
    Default value is 0 (no).
 
-   Example 1.4. report_cancels example
+   Example 1.5. report_cancels example
 modparam("acc", "report_cancels", 1)
 
-5.5. detect_direction (integer)
+5.6. detect_direction (integer)
 
    Controlles the direction detection for sequential requests. If enabled
    (non zero value), for sequential requests with upstream direction (from
@@ -537,10 +552,10 @@ modparam("acc", "report_cancels", 1)
 
    Default value is 0 (disabled).
 
-   Example 1.5. detect_direction example
+   Example 1.6. detect_direction example
 modparam("acc", "detect_direction", 1)
 
-5.6. multi_leg_info (string)
+5.7. multi_leg_info (string)
 
    Defines the AVP set to be used in per-call-leg accounting. See
    Section 3, “Multi Call-Legs accounting” for a detailed description of
@@ -550,7 +565,7 @@ modparam("acc", "detect_direction", 1)
 
    Default value is 0 (disabled).
 
-   Example 1.6. multi_leg_info example
+   Example 1.7. 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)")
@@ -564,34 +579,34 @@ modparam("acc", "multi_leg_info",
 modparam("acc", "multi_leg_info",
     "2345=$avp(src);2346=$avp(dst)")
 
-5.7. log_flag (integer)
+5.8. log_flag (integer)
 
    Request flag which needs to be set to account a transaction via syslog.
 
    Default value is not-set (no flag).
 
-   Example 1.7. log_flag example
+   Example 1.8. log_flag example
 modparam("acc", "log_flag", 2)
 
-5.8. log_missed_flag (integer)
+5.9. log_missed_flag (integer)
 
    Request flag which needs to be set to account missed calls via syslog.
 
    Default value is not-set (no flag).
 
-   Example 1.8. log_missed_flag example
+   Example 1.9. log_missed_flag example
 modparam("acc", "log_missed_flag", 3)
 
-5.9. log_level (integer)
+5.10. log_level (integer)
 
    Log level at which accounting messages are issued to syslog.
 
    Default value is L_NOTICE.
 
-   Example 1.9. log_level example
+   Example 1.10. log_level example
 modparam("acc", "log_level", 2)   # Set log_level to 2
 
-5.10. log_facility (string)
+5.11. log_facility (string)
 
    Log facility to which accounting messages are issued to syslog. This
    allows to easily seperate the accounting specific logging from the
@@ -599,20 +614,20 @@ modparam("acc", "log_level", 2)   # Set log_level to 2
 
    Default value is LOG_DAEMON.
 
-   Example 1.10. log_facility example
+   Example 1.11. log_facility example
 modparam("acc", "log_facility", "LOG_DAEMON")
 
-5.11. log_extra (string)
+5.12. log_extra (string)
 
    Extra values to be logged. See section Section 2, “Extra accounting”
    for more details.
 
    Default value is NULL.
 
-   Example 1.11. log_extra example
+   Example 1.12. log_extra example
 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
 
-5.12. radius_config (string)
+5.13. radius_config (string)
 
    This parameter is radius specific. Path to radius client configuration
    file, set the referred config file correctly and specify there address
@@ -625,225 +640,221 @@ modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
 
    Default value is “NULL”.
 
-   Example 1.12. radius_config example
+   Example 1.13. radius_config example
 modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
 
-5.13. radius_flag (integer)
+5.14. radius_flag (integer)
 
    Request flag which needs to be set to account a transaction -- RADIUS
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.13. radius_flag example
+   Example 1.14. radius_flag example
 modparam("acc", "radius_flag", 2)
 
-5.14. radius_missed_flag (integer)
+5.15. radius_missed_flag (integer)
 
    Request flag which needs to be set to account missed calls -- RADIUS
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.14. radius_missed_flag example
+   Example 1.15. radius_missed_flag example
 modparam("acc", "radius_missed_flag", 3)
 
-5.15. service_type (integer)
+5.16. service_type (integer)
 
    Radius service type used for accounting.
 
    Default value is 15 (SIP).
 
-   Example 1.15. service_type example
+   Example 1.16. service_type example
 modparam("acc", "service_type", 16)
 
-5.16. radius_extra (string)
+5.17. radius_extra (string)
 
    Extra values to be logged via RADIUS - RADIUS specific. See section
    Section 2, “Extra accounting” for more details.
 
    Default value is NULL.
 
-   Example 1.16. radius_extra example
+   Example 1.17. radius_extra example
 modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
 
-5.17. db_flag (integer)
+5.18. db_flag (integer)
 
    Request flag which needs to be set to account a transaction -- database
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.17. db_flag example
+   Example 1.18. db_flag example
 modparam("acc", "db_flag", 2)
 
-5.18. db_missed_flag (integer)
+5.19. db_missed_flag (integer)
 
    Request flag which needs to be set to account missed calls -- database
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.18. db_missed_flag example
+   Example 1.19. db_missed_flag example
 modparam("acc", "db_missed_flag", 3)
 
-5.19. db_table_acc (string)
+5.20. db_table_acc (string)
 
-   Table name of accounting successfull calls -- database specific. It can
-   include config variables.
+   Table name of accounting successfull calls -- database specific.
 
    Default value is “acc”
 
-   Example 1.19. db_table_acc example
+   Example 1.20. db_table_acc example
 modparam("acc", "db_table_acc", "myacc_table")
-modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
 
-5.20. db_table_missed_calls (string)
+5.21. db_table_missed_calls (string)
 
-   Table name for accounting missed calls -- database specific. It can
-   include config variables.
+   Table name for accounting missed calls -- database specific.
 
    Default value is “missed_calls”
 
-   Example 1.20. db_table_missed_calls example
+   Example 1.21. db_table_missed_calls example
 modparam("acc", "db_table_missed_calls", "myMC_table")
-modparam("acc", "db_table_missed_calls", "mc_$time(year)_$time(mon)")
 
-5.21. db_url (string)
+5.22. db_url (string)
 
    SQL address -- database specific. If is set to NULL or emty string, the
    SQL support is disabled.
 
    Default value is “NULL” (SQL disabled).
 
-   Example 1.21. db_url example
+   Example 1.22. db_url example
 modparam("acc", "db_url", "mysql://user:password@localhost/openser")
 
-5.22. acc_method_column (string)
+5.23. acc_method_column (string)
 
    Column name in accounting table to store the request's method name as
    string.
 
    Default value is “method”.
 
-   Example 1.22. acc_method_column example
+   Example 1.23. acc_method_column example
 modparam("acc", "acc_method_column", "method")
 
-5.23. acc_from_tag_column (string)
+5.24. acc_from_tag_column (string)
 
    Column name in accounting table to store the From header TAG parameter.
 
    Default value is “from_tag”.
 
-   Example 1.23. acc_from_tag_column example
+   Example 1.24. acc_from_tag_column example
 modparam("acc", "acc_from_tag_column", "from_tag")
 
-5.24. acc_to_tag_column (string)
+5.25. acc_to_tag_column (string)
 
    Column name in accounting table to store the To header TAG parameter.
 
    Default value is “to_tag”.
 
-   Example 1.24. acc_to_tag_column example
+   Example 1.25. acc_to_tag_column example
 modparam("acc", "acc_to_tag_column", "to_tag")
 
-5.25. acc_callid_column (string)
+5.26. acc_callid_column (string)
 
    Column name in accounting table to store the request's Callid value.
 
    Default value is “callid”.
 
-   Example 1.25. acc_callid_column example
+   Example 1.26. acc_callid_column example
 modparam("acc", "acc_callid_column", "callid")
 
-5.26. acc_sip_code_column (string)
+5.27. acc_sip_code_column (string)
 
    Column name in accounting table to store the final reply's numric code
    value in string format.
 
    Default value is “sip_code”.
 
-   Example 1.26. acc_sip_code_column example
+   Example 1.27. acc_sip_code_column example
 modparam("acc", "acc_sip_code_column", "sip_code")
 
-5.27. acc_sip_reason_column (string)
+5.28. acc_sip_reason_column (string)
 
    Column name in accounting table to store the final reply's reason
    phrase value.
 
    Default value is “sip_reason”.
 
-   Example 1.27. acc_sip_reason_column example
+   Example 1.28. acc_sip_reason_column example
 modparam("acc", "acc_sip_reason_column", "sip_reason")
 
-5.28. acc_time_column (string)
+5.29. acc_time_column (string)
 
    Column name in accounting table to store the time stamp of the
    transaction completion in date-time format.
 
    Default value is “time”.
 
-   Example 1.28. acc_time_column example
+   Example 1.29. acc_time_column example
 modparam("acc", "acc_time_column", "time")
 
-5.29. db_extra (string)
+5.30. db_extra (string)
 
    Extra values to be logged into database - DB specific. See section
    Section 2, “Extra accounting” for more details.
 
    Default value is NULL.
 
-   Example 1.29. db_extra example
+   Example 1.30. db_extra example
 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
 
-5.30. diameter_flag (integer)
+5.31. diameter_flag (integer)
 
    Request flag which needs to be set to account a transaction -- DIAMETER
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.30. diameter_flag example
+   Example 1.31. diameter_flag example
 modparam("acc", "diameter_flag", 2)
 
-5.31. diameter_missed_flag (integer)
+5.32. diameter_missed_flag (integer)
 
    Request flag which needs to be set to account missed calls -- DIAMETER
    specific.
 
    Default value is not-set (no flag).
 
-   Example 1.31. diameter_missed_flag example
+   Example 1.32. diameter_missed_flag example
 modparam("acc", "diameter_missed_flag", 3)
 
-5.32. diameter_client_host (string)
+5.33. diameter_client_host (string)
 
    Hostname of the machine where the DIAMETER Client is running --
    DIAMETER specific.
 
    Default value is “localhost”.
 
-   Example 1.32. diameter_client_host example
+   Example 1.33. diameter_client_host example
 modparam("acc", "diameter_client_host", "3a_server.net")
 
-5.33. diameter_client_port (int)
+5.34. diameter_client_port (int)
 
    Port number where the Diameter Client is listening -- DIAMETER
    specific.
 
    Default value is 3000.
 
-   Example 1.33. diameter_client_host example
+   Example 1.34. diameter_client_host example
 modparam("acc", "diameter_client_port", 3000)
 
-5.34. diameter_extra (string)
+5.35. diameter_extra (string)
 
    Extra values to be logged via DIAMETER - DIAMETER specific. See section
    Section 2, “Extra accounting” for more details.
 
    Default value is NULL.
 
-   Example 1.34. diameter_extra example
+   Example 1.35. diameter_extra example
 modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
 
 6. Exported Functions
@@ -865,7 +876,7 @@ modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
 
    This function can be used from ANY_ROUTE.
 
-   Example 1.35. acc_log_request usage
+   Example 1.36. acc_log_request usage
 ...
 acc_log_request("Some comment");
 ...
@@ -878,14 +889,13 @@ acc_log_request("Some comment");
 
    Meaning of the parameters is as follows:
      * comment - Comment to be appended.
-     * table - Database table to be used. It can include config variables.
+     * table - Database table to be used.
 
    This function can be used from ANY_ROUTE.
 
-   Example 1.36. acc_db_request usage
+   Example 1.37. acc_db_request usage
 ...
-acc_db_request("Some comment", "some_table");
-acc_db_request("200 ok", "acc_cfg_$time(year)");
+acc_log_request("Some comment", "Some table");
 ...
 
 6.3.  acc_rad_request(comment)
@@ -898,7 +908,7 @@ acc_db_request("200 ok", "acc_cfg_$time(year)");
 
    This function can be used from ANY_ROUTE.
 
-   Example 1.37. acc_rad_request usage
+   Example 1.38. acc_rad_request usage
 ...
 acc_rad_request("Some comment");
 ...
@@ -913,7 +923,7 @@ acc_rad_request("Some comment");
 
    This function can be used from ANY_ROUTE.
 
-   Example 1.38. acc_diam_request usage
+   Example 1.39. acc_diam_request usage
 ...
 acc_diam_request("Some comment");
 ...

+ 2 - 0
modules_k/acc/acc.h

@@ -73,6 +73,8 @@
 
 #define MAX_SYSLOG_SIZE  65536
 
+#define MAX_FAILED_FILTER_COUNT 15
+
 /* WARNING: This is a flag stored in the sip_msg structure, the flag is
  * temporarily defined here to make the module work with the sip-router core,
  * I assume it won't be needed once we merge acc implementations from both

+ 30 - 58
modules_k/acc/acc_logic.c

@@ -39,7 +39,6 @@
 #include <string.h>
 
 #include "../../dprint.h"
-#include "../../sr_module.h"
 #include "../../parser/parse_from.h"
 #include "../../parser/parse_content.h"
 #include "../../modules/tm/tm_load.h"
@@ -102,6 +101,8 @@ struct acc_enviroment acc_env;
 	(((_rq)->REQ_METHOD==METHOD_CANCEL) && report_cancels==0)
 
 
+
+
 static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
 
 
@@ -179,35 +180,6 @@ int w_acc_log_request(struct sip_msg *rq, char *comment, char *foo)
 
 
 #ifdef SQL_ACC
-int acc_db_set_table_name(struct sip_msg *msg, void *param, str *table)
-{
-#define DB_TABLE_NAME_SIZE	64
-	static char db_table_name_buf[DB_TABLE_NAME_SIZE];
-	str dbtable;
-
-	if(param!=NULL) {
-		if(get_str_fparam(&dbtable, msg, (fparam_t*)param)<0) {
-			LM_ERR("cannot get acc db table name\n");
-			return -1;
-		}
-		if(dbtable.len>=DB_TABLE_NAME_SIZE) {
-			LM_ERR("acc db table name too big [%.*s] max %d\n",
-					dbtable.len, dbtable.s, DB_TABLE_NAME_SIZE);
-			return -1;
-		}
-		strncpy(db_table_name_buf, dbtable.s, dbtable.len);
-		env_set_text(db_table_name_buf, dbtable.len);
-	} else {
-		if(table==NULL) {
-			LM_ERR("no acc table name\n");
-			return -1;
-		}
-		env_set_text(table->s, table->len);
-	}
-	return 0;
-}
-
-
 int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
 {
 	if (!table) {
@@ -216,12 +188,9 @@ int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
 	}
 	if (acc_preparse_req(rq)<0)
 		return -1;
-	if(acc_db_set_table_name(rq, (void*)table, NULL)<0) {
-		LM_ERR("cannot set table name\n");
-		return -1;
-    }
 	env_set_to( rq->to );
 	env_set_comment((struct acc_param*)comment);
+	env_set_text(table, strlen(table));
 	return acc_db_request(rq);
 }
 #endif
@@ -289,21 +258,33 @@ void acc_onreq( struct cell* t, int type, struct tmcb_params *ps )
 
 
 /* is this reply of interest for accounting ? */
-static inline int should_acc_reply(struct sip_msg *req,struct sip_msg *rpl,
-																	int code)
+static inline int should_acc_reply(struct sip_msg *req, struct sip_msg *rpl,
+				   int code)
 {
+    unsigned int i;
+
 	/* negative transactions reported otherwise only if explicitly 
 	 * demanded */
-	if ( !is_failed_acc_on(req) && code >=300 )
-		return 0;
-	if ( !is_acc_on(req) )
-		return 0;
-	if ( code<200 && !(early_media &&
-	parse_headers(rpl,HDR_CONTENTLENGTH_F, 0)==0 && rpl->content_length &&
-	get_content_length(rpl)>0 ) )
-		return 0;
-
-	return 1; /* seed is through, we will account this reply */
+
+    if (code >= 300) {
+	if (!is_failed_acc_on(req)) return 0;
+	i = 0;
+	while (failed_filter[i] != 0) {
+	    if (failed_filter[i] == code) return 0;
+	    i++;
+	}
+	return 1;
+    }
+
+    if ( !is_acc_on(req) )
+	return 0;
+	
+    if ( code<200 && !(early_media &&
+		       parse_headers(rpl,HDR_CONTENTLENGTH_F, 0) == 0 &&
+		       rpl->content_length && get_content_length(rpl) > 0))
+	return 0;
+
+    return 1; /* seed is through, we will account this reply */
 }
 
 
@@ -355,10 +336,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
 	}
 #ifdef SQL_ACC
 	if (is_db_mc_on(req)) {
-		if(acc_db_set_table_name(req, db_table_mc_data, &db_table_mc)<0) {
-			LM_ERR("cannot set missed call db table name\n");
-			return;
-		}
+		env_set_text(db_table_mc.s, db_table_mc.len);
 		acc_db_request( req );
 		flags_to_reset |= db_missed_flag;
 	}
@@ -429,10 +407,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
 	}
 #ifdef SQL_ACC
 	if (is_db_acc_on(req)) {
-		if(acc_db_set_table_name(req, db_table_acc_data, &db_table_acc)<0) {
-			LM_ERR("cannot set acc db table name\n");
-			return;
-		}
+		env_set_text( db_table_acc.s, db_table_acc.len);
 		acc_db_request(req);
 	}
 #endif
@@ -473,10 +448,7 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req,
 	}
 #ifdef SQL_ACC
 	if (is_db_acc_on(req)) {
-		if(acc_db_set_table_name(ack, db_table_acc_data, &db_table_acc)<0) {
-			LM_ERR("cannot set acc db table name\n");
-			return;
-		}
+		env_set_text( db_table_acc.s, db_table_acc.len);
 		acc_db_request( ack );
 	}
 #endif

+ 52 - 24
modules_k/acc/acc_mod.c

@@ -102,6 +102,9 @@ int report_cancels = 0;		/*!< would you like us to report CANCELs from upstream
 int report_ack = 0;		/*!< report e2e ACKs too */
 int detect_direction = 0;	/*!< detect and correct direction in the sequential requests */
 int failed_transaction_flag = -1; /*!< should failed replies (>=3xx) be logged ? default==no */
+static char *failed_filter_str = 0;  /* by default, do not filter logging of
+					failed transactions */
+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;
 
@@ -164,9 +167,7 @@ static char *db_extra_str = 0;		/*!< db extra variables */
 struct acc_extra *db_extra = 0;
 static str db_url = {NULL, 0};		/*!< Database url */
 str db_table_acc = str_init("acc");	/*!< name of database tables */
-void *db_table_acc_data = NULL;
 str db_table_mc = str_init("missed_calls");
-void *db_table_mc_data = NULL;
 /* names of columns in tables acc/missed calls*/
 str acc_method_col     = str_init("method");
 str acc_fromtag_col    = str_init("from_tag");
@@ -218,6 +219,7 @@ static cmd_export_t cmds[] = {
 static param_export_t params[] = {
 	{"early_media",             INT_PARAM, &early_media             },
 	{"failed_transaction_flag", INT_PARAM, &failed_transaction_flag },
+	{"failed_filter",           STR_PARAM, &failed_filter_str       },
 	{"report_ack",              INT_PARAM, &report_ack              },
 	{"report_cancels",          INT_PARAM, &report_cancels          },
 	{"multi_leg_info",          STR_PARAM, &leg_info_str            },
@@ -320,8 +322,6 @@ static int acc_fixup(void** param, int param_no)
 		if (db_url.s==0) {
 			pkg_free(p);
 			*param = 0;
-		} else {
-			return fixup_var_pve_str_12(param, 2);
 		}
 #endif
 	}
@@ -355,6 +355,45 @@ static int mod_lrt_init( void )
 	return 0;
 }
 
+static int parse_failed_filter(char *s, unsigned short *failed_filter)
+{
+    unsigned int n;
+    char *at;
+
+    n = 0;
+
+    while (1) {
+	if (n >= MAX_FAILED_FILTER_COUNT) {
+	    LM_ERR("too many elements in failed_filter\n");
+	    return 0;
+	}
+	at = s;
+	while ((*at >= '0') && (*at <= '9')) at++;
+	if (at - s != 3) {
+	    LM_ERR("respose code in failed_filter must have 3 digits\n");
+	    return 0;
+	}
+	failed_filter[n] = (*s - '0') * 100 + (*(s + 1) - '0') * 10 +
+	    (*(s + 2) - '0');
+	if (failed_filter[n] < 300) {
+	    LM_ERR("invalid respose code %u in failed_filter\n",
+		   failed_filter[n]);
+	    return 0;
+	}
+	LM_DBG("failed_filter %u = %u\n", n, failed_filter[n]);
+	n++;
+	failed_filter[n] = 0;
+	s = at;
+	if (*s == 0)
+	    return 1;
+	if (*s != ',') {
+	    LM_ERR("response code is not followed by comma or end of string\n");
+	    return 0;
+	}
+	s++;
+    }
+}
+
 static int mod_init( void )
 {
 	lrt_info_t li;
@@ -367,27 +406,7 @@ static int mod_init( void )
 	if (db_url.s)
 		db_url.len = strlen(db_url.s);
 	db_table_acc.len = strlen(db_table_acc.s);
-	if(db_table_acc.len!=3 || strncmp(db_table_acc.s, "acc", 3)!=0)
-	{
-		db_table_acc_data = db_table_acc.s;
-		if(fixup_var_pve_str_12(&db_table_acc_data, 1)<0)
-		{
-			LM_ERR("unable to parse acc table name [%.*s]\n",
-					db_table_acc.len, db_table_acc.s);
-			return -1;
-		}
-	}
 	db_table_mc.len = strlen(db_table_mc.s);
-	if(db_table_mc.len!=12 || strncmp(db_table_mc.s, "missed_calls", 12)!=0)
-	{
-		db_table_mc_data = db_table_mc.s;
-		if(fixup_var_pve_str_12(&db_table_mc_data, 1)<0)
-		{
-			LM_ERR("unable to parse mc table name [%.*s]\n",
-					db_table_mc.len, db_table_mc.s);
-			return -1;
-		}
-	}
 	acc_method_col.len = strlen(acc_method_col.s);
 	acc_fromtag_col.len = strlen(acc_fromtag_col.s);
 	acc_totag_col.len = strlen(acc_totag_col.s);
@@ -409,11 +428,20 @@ static int mod_init( void )
 
 	/* ----------- GENERIC INIT SECTION  ----------- */
 
+	/* failed transaction handling */
 	if ((failed_transaction_flag != -1) && 
 		!flag_in_range(failed_transaction_flag)) {
 		LM_ERR("failed_transaction_flag set to invalid value\n");
 		return -1;
 	}
+	if (failed_filter_str) {
+	    if (parse_failed_filter(failed_filter_str, failed_filter) == 0) {
+		LM_ERR("failed to parse failed_filter param\n");
+		return -1;
+	    }
+	} else {
+	    failed_filter[0] = 0;
+	}
 
 	/* load the TM API */
 	if (load_tm_api(&tmb)!=0) {

+ 1 - 2
modules_k/acc/acc_mod.h

@@ -47,6 +47,7 @@ extern int report_cancels;
 extern int report_ack;
 extern int early_media;
 extern int failed_transaction_flag;
+extern unsigned short failed_filter[];
 extern int detect_direction;
 
 extern int log_facility;
@@ -73,9 +74,7 @@ extern int db_flag;
 extern int db_missed_flag;
 
 extern str db_table_acc;
-extern void *db_table_acc_data;
 extern str db_table_mc;
-extern void *db_table_mc_data;
 
 extern str acc_method_col;
 extern str acc_fromuri_col;

+ 22 - 10
modules_k/acc/doc/acc_admin.xml

@@ -400,6 +400,24 @@ modparam("acc", "early_media", 1)
 		<title>failed_transaction_flag example</title>
 		<programlisting format="linespecific">
 modparam("acc", "failed_transaction_flag", 4)
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>failed_filter</varname> (string)</title>
+		<para>
+		A string of failure response codes from 300 to 999
+		separated by commas. Failed transaction will not be accounted
+		if its response code is in the list even when
+		failed_transaction_flag is set. 
+		</para>
+		<para>
+		Default value is not-set (failure filtering is off).
+		</para>
+		<example>
+		<title>failed_filter example</title>
+		<programlisting format="linespecific">
+modparam("acc", "failed_filter", "404,407")
 </programlisting>
 		</example>
 	</section>
@@ -695,8 +713,7 @@ modparam("acc", "db_missed_flag", 3)
 	<section>
 		<title><varname>db_table_acc</varname> (string)</title>
 		<para>
-			Table name of accounting successfull calls -- database specific. It
-			can include config variables.
+		Table name of accounting successfull calls -- database specific.
 		</para>
 		<para>
 		Default value is <quote>acc</quote>
@@ -705,15 +722,13 @@ modparam("acc", "db_missed_flag", 3)
 		<title>db_table_acc example</title>
 		<programlisting format="linespecific">
 modparam("acc", "db_table_acc", "myacc_table")
-modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
 </programlisting>
 		</example>
 	</section>
 	<section>
 		<title><varname>db_table_missed_calls</varname> (string)</title>
 		<para>
-			Table name for accounting missed calls -- database specific. It
-			can include config variables.
+		Table name for accounting missed calls -- database specific.
 		</para>
 		<para>
 		Default value is <quote>missed_calls</quote>
@@ -722,7 +737,6 @@ modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
 		<title>db_table_missed_calls example</title>
 		<programlisting format="linespecific">
 modparam("acc", "db_table_missed_calls", "myMC_table")
-modparam("acc", "db_table_missed_calls", "mc_$time(year)_$time(mon)")
 </programlisting>
 		</example>
 	</section>
@@ -1001,8 +1015,7 @@ acc_log_request("Some comment");
 			<para><emphasis>comment</emphasis> - Comment to be appended.</para>
 		</listitem>
 		<listitem>
-			<para><emphasis>table</emphasis> - Database table to be used. It
-			can include config variables.</para>
+			<para><emphasis>table</emphasis> - Database table to be used.</para>
 		</listitem>
 		</itemizedlist>
 		<para>
@@ -1012,8 +1025,7 @@ acc_log_request("Some comment");
 		<title>acc_db_request usage</title>
 		<programlisting format="linespecific">
 ...
-acc_db_request("Some comment", "some_table");
-acc_db_request("200 ok", "acc_cfg_$time(year)");
+acc_log_request("Some comment", "Some table");
 ...
 </programlisting>
 		</example>