Browse code

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 authored on 18/03/2011 05:51:55
Showing 6 changed files
... ...
@@ -58,38 +58,39 @@ Bogdan-Andrei Iancu
58 58
 
59 59
               5.1. early_media (integer)
60 60
               5.2. failed_transaction_flag (integer)
61
-              5.3. report_ack (integer)
62
-              5.4. report_cancels (integer)
63
-              5.5. detect_direction (integer)
64
-              5.6. multi_leg_info (string)
65
-              5.7. log_flag (integer)
66
-              5.8. log_missed_flag (integer)
67
-              5.9. log_level (integer)
68
-              5.10. log_facility (string)
69
-              5.11. log_extra (string)
70
-              5.12. radius_config (string)
71
-              5.13. radius_flag (integer)
72
-              5.14. radius_missed_flag (integer)
73
-              5.15. service_type (integer)
74
-              5.16. radius_extra (string)
75
-              5.17. db_flag (integer)
76
-              5.18. db_missed_flag (integer)
77
-              5.19. db_table_acc (string)
78
-              5.20. db_table_missed_calls (string)
79
-              5.21. db_url (string)
80
-              5.22. acc_method_column (string)
81
-              5.23. acc_from_tag_column (string)
82
-              5.24. acc_to_tag_column (string)
83
-              5.25. acc_callid_column (string)
84
-              5.26. acc_sip_code_column (string)
85
-              5.27. acc_sip_reason_column (string)
86
-              5.28. acc_time_column (string)
87
-              5.29. db_extra (string)
88
-              5.30. diameter_flag (integer)
89
-              5.31. diameter_missed_flag (integer)
90
-              5.32. diameter_client_host (string)
91
-              5.33. diameter_client_port (int)
92
-              5.34. diameter_extra (string)
61
+              5.3. failed_filter (string)
62
+              5.4. report_ack (integer)
63
+              5.5. report_cancels (integer)
64
+              5.6. detect_direction (integer)
65
+              5.7. multi_leg_info (string)
66
+              5.8. log_flag (integer)
67
+              5.9. log_missed_flag (integer)
68
+              5.10. log_level (integer)
69
+              5.11. log_facility (string)
70
+              5.12. log_extra (string)
71
+              5.13. radius_config (string)
72
+              5.14. radius_flag (integer)
73
+              5.15. radius_missed_flag (integer)
74
+              5.16. service_type (integer)
75
+              5.17. radius_extra (string)
76
+              5.18. db_flag (integer)
77
+              5.19. db_missed_flag (integer)
78
+              5.20. db_table_acc (string)
79
+              5.21. db_table_missed_calls (string)
80
+              5.22. db_url (string)
81
+              5.23. acc_method_column (string)
82
+              5.24. acc_from_tag_column (string)
83
+              5.25. acc_to_tag_column (string)
84
+              5.26. acc_callid_column (string)
85
+              5.27. acc_sip_code_column (string)
86
+              5.28. acc_sip_reason_column (string)
87
+              5.29. acc_time_column (string)
88
+              5.30. db_extra (string)
89
+              5.31. diameter_flag (integer)
90
+              5.32. diameter_missed_flag (integer)
91
+              5.33. diameter_client_host (string)
92
+              5.34. diameter_client_port (int)
93
+              5.35. diameter_extra (string)
93 94
 
94 95
         6. Exported Functions
95 96
 
... ...
@@ -104,42 +105,43 @@ Bogdan-Andrei Iancu
104 105
 
105 106
    1.1. early_media example
106 107
    1.2. failed_transaction_flag example
107
-   1.3. report_ack example
108
-   1.4. report_cancels example
109
-   1.5. detect_direction example
110
-   1.6. multi_leg_info example
111
-   1.7. log_flag example
112
-   1.8. log_missed_flag example
113
-   1.9. log_level example
114
-   1.10. log_facility example
115
-   1.11. log_extra example
116
-   1.12. radius_config example
117
-   1.13. radius_flag example
118
-   1.14. radius_missed_flag example
119
-   1.15. service_type example
120
-   1.16. radius_extra example
121
-   1.17. db_flag example
122
-   1.18. db_missed_flag example
123
-   1.19. db_table_acc example
124
-   1.20. db_table_missed_calls example
125
-   1.21. db_url example
126
-   1.22. acc_method_column example
127
-   1.23. acc_from_tag_column example
128
-   1.24. acc_to_tag_column example
129
-   1.25. acc_callid_column example
130
-   1.26. acc_sip_code_column example
131
-   1.27. acc_sip_reason_column example
132
-   1.28. acc_time_column example
133
-   1.29. db_extra example
134
-   1.30. diameter_flag example
135
-   1.31. diameter_missed_flag example
136
-   1.32. diameter_client_host example
108
+   1.3. failed_filter example
109
+   1.4. report_ack example
110
+   1.5. report_cancels example
111
+   1.6. detect_direction example
112
+   1.7. multi_leg_info example
113
+   1.8. log_flag example
114
+   1.9. log_missed_flag example
115
+   1.10. log_level example
116
+   1.11. log_facility example
117
+   1.12. log_extra example
118
+   1.13. radius_config example
119
+   1.14. radius_flag example
120
+   1.15. radius_missed_flag example
121
+   1.16. service_type example
122
+   1.17. radius_extra example
123
+   1.18. db_flag example
124
+   1.19. db_missed_flag example
125
+   1.20. db_table_acc example
126
+   1.21. db_table_missed_calls example
127
+   1.22. db_url example
128
+   1.23. acc_method_column example
129
+   1.24. acc_from_tag_column example
130
+   1.25. acc_to_tag_column example
131
+   1.26. acc_callid_column example
132
+   1.27. acc_sip_code_column example
133
+   1.28. acc_sip_reason_column example
134
+   1.29. acc_time_column example
135
+   1.30. db_extra example
136
+   1.31. diameter_flag example
137
+   1.32. diameter_missed_flag example
137 138
    1.33. diameter_client_host example
138
-   1.34. diameter_extra example
139
-   1.35. acc_log_request usage
140
-   1.36. acc_db_request usage
141
-   1.37. acc_rad_request usage
142
-   1.38. acc_diam_request usage
139
+   1.34. diameter_client_host example
140
+   1.35. diameter_extra example
141
+   1.36. acc_log_request usage
142
+   1.37. acc_db_request usage
143
+   1.38. acc_rad_request usage
144
+   1.39. acc_diam_request usage
143 145
 
144 146
 Chapter 1. Admin Guide
145 147
 
... ...
@@ -170,38 +172,39 @@ Chapter 1. Admin Guide
170 172
 
171 173
         5.1. early_media (integer)
172 174
         5.2. failed_transaction_flag (integer)
173
-        5.3. report_ack (integer)
174
-        5.4. report_cancels (integer)
175
-        5.5. detect_direction (integer)
176
-        5.6. multi_leg_info (string)
177
-        5.7. log_flag (integer)
178
-        5.8. log_missed_flag (integer)
179
-        5.9. log_level (integer)
180
-        5.10. log_facility (string)
181
-        5.11. log_extra (string)
182
-        5.12. radius_config (string)
183
-        5.13. radius_flag (integer)
184
-        5.14. radius_missed_flag (integer)
185
-        5.15. service_type (integer)
186
-        5.16. radius_extra (string)
187
-        5.17. db_flag (integer)
188
-        5.18. db_missed_flag (integer)
189
-        5.19. db_table_acc (string)
190
-        5.20. db_table_missed_calls (string)
191
-        5.21. db_url (string)
192
-        5.22. acc_method_column (string)
193
-        5.23. acc_from_tag_column (string)
194
-        5.24. acc_to_tag_column (string)
195
-        5.25. acc_callid_column (string)
196
-        5.26. acc_sip_code_column (string)
197
-        5.27. acc_sip_reason_column (string)
198
-        5.28. acc_time_column (string)
199
-        5.29. db_extra (string)
200
-        5.30. diameter_flag (integer)
201
-        5.31. diameter_missed_flag (integer)
202
-        5.32. diameter_client_host (string)
203
-        5.33. diameter_client_port (int)
204
-        5.34. diameter_extra (string)
175
+        5.3. failed_filter (string)
176
+        5.4. report_ack (integer)
177
+        5.5. report_cancels (integer)
178
+        5.6. detect_direction (integer)
179
+        5.7. multi_leg_info (string)
180
+        5.8. log_flag (integer)
181
+        5.9. log_missed_flag (integer)
182
+        5.10. log_level (integer)
183
+        5.11. log_facility (string)
184
+        5.12. log_extra (string)
185
+        5.13. radius_config (string)
186
+        5.14. radius_flag (integer)
187
+        5.15. radius_missed_flag (integer)
188
+        5.16. service_type (integer)
189
+        5.17. radius_extra (string)
190
+        5.18. db_flag (integer)
191
+        5.19. db_missed_flag (integer)
192
+        5.20. db_table_acc (string)
193
+        5.21. db_table_missed_calls (string)
194
+        5.22. db_url (string)
195
+        5.23. acc_method_column (string)
196
+        5.24. acc_from_tag_column (string)
197
+        5.25. acc_to_tag_column (string)
198
+        5.26. acc_callid_column (string)
199
+        5.27. acc_sip_code_column (string)
200
+        5.28. acc_sip_reason_column (string)
201
+        5.29. acc_time_column (string)
202
+        5.30. db_extra (string)
203
+        5.31. diameter_flag (integer)
204
+        5.32. diameter_missed_flag (integer)
205
+        5.33. diameter_client_host (string)
206
+        5.34. diameter_client_port (int)
207
+        5.35. diameter_extra (string)
205 208
 
206 209
    6. Exported Functions
207 210
 
... ...
@@ -450,38 +453,39 @@ Note
450 453
 
451 454
    5.1. early_media (integer)
452 455
    5.2. failed_transaction_flag (integer)
453
-   5.3. report_ack (integer)
454
-   5.4. report_cancels (integer)
455
-   5.5. detect_direction (integer)
456
-   5.6. multi_leg_info (string)
457
-   5.7. log_flag (integer)
458
-   5.8. log_missed_flag (integer)
459
-   5.9. log_level (integer)
460
-   5.10. log_facility (string)
461
-   5.11. log_extra (string)
462
-   5.12. radius_config (string)
463
-   5.13. radius_flag (integer)
464
-   5.14. radius_missed_flag (integer)
465
-   5.15. service_type (integer)
466
-   5.16. radius_extra (string)
467
-   5.17. db_flag (integer)
468
-   5.18. db_missed_flag (integer)
469
-   5.19. db_table_acc (string)
470
-   5.20. db_table_missed_calls (string)
471
-   5.21. db_url (string)
472
-   5.22. acc_method_column (string)
473
-   5.23. acc_from_tag_column (string)
474
-   5.24. acc_to_tag_column (string)
475
-   5.25. acc_callid_column (string)
476
-   5.26. acc_sip_code_column (string)
477
-   5.27. acc_sip_reason_column (string)
478
-   5.28. acc_time_column (string)
479
-   5.29. db_extra (string)
480
-   5.30. diameter_flag (integer)
481
-   5.31. diameter_missed_flag (integer)
482
-   5.32. diameter_client_host (string)
483
-   5.33. diameter_client_port (int)
484
-   5.34. diameter_extra (string)
456
+   5.3. failed_filter (string)
457
+   5.4. report_ack (integer)
458
+   5.5. report_cancels (integer)
459
+   5.6. detect_direction (integer)
460
+   5.7. multi_leg_info (string)
461
+   5.8. log_flag (integer)
462
+   5.9. log_missed_flag (integer)
463
+   5.10. log_level (integer)
464
+   5.11. log_facility (string)
465
+   5.12. log_extra (string)
466
+   5.13. radius_config (string)
467
+   5.14. radius_flag (integer)
468
+   5.15. radius_missed_flag (integer)
469
+   5.16. service_type (integer)
470
+   5.17. radius_extra (string)
471
+   5.18. db_flag (integer)
472
+   5.19. db_missed_flag (integer)
473
+   5.20. db_table_acc (string)
474
+   5.21. db_table_missed_calls (string)
475
+   5.22. db_url (string)
476
+   5.23. acc_method_column (string)
477
+   5.24. acc_from_tag_column (string)
478
+   5.25. acc_to_tag_column (string)
479
+   5.26. acc_callid_column (string)
480
+   5.27. acc_sip_code_column (string)
481
+   5.28. acc_sip_reason_column (string)
482
+   5.29. acc_time_column (string)
483
+   5.30. db_extra (string)
484
+   5.31. diameter_flag (integer)
485
+   5.32. diameter_missed_flag (integer)
486
+   5.33. diameter_client_host (string)
487
+   5.34. diameter_client_port (int)
488
+   5.35. diameter_extra (string)
485 489
 
486 490
 5.1. early_media (integer)
487 491
 
... ...
@@ -502,7 +506,18 @@ modparam("acc", "early_media", 1)
502 506
    Example 1.2. failed_transaction_flag example
503 507
 modparam("acc", "failed_transaction_flag", 4)
504 508
 
505
-5.3. report_ack (integer)
509
+5.3. failed_filter (string)
510
+
511
+   A string of failure response codes from 300 to 999 separated by commas.
512
+   Failed transaction will not be accounted if its response code is in the
513
+   list even when failed_transaction_flag is set.
514
+
515
+   Default value is not-set (failure filtering is off).
516
+
517
+   Example 1.3. failed_filter example
518
+modparam("acc", "failed_filter", "404,407")
519
+
520
+5.4. report_ack (integer)
506 521
 
507 522
    Shall acc attempt to account e2e ACKs too ? Note that this is really
508 523
    only an attempt, as e2e ACKs may take a different path (unless RR
... ...
@@ -511,10 +526,10 @@ modparam("acc", "failed_transaction_flag", 4)
511 526
 
512 527
    Default value is 0 (no).
513 528
 
514
-   Example 1.3. report_ack example
529
+   Example 1.4. report_ack example
515 530
 modparam("acc", "report_ack", 1)
516 531
 
517
-5.4. report_cancels (integer)
532
+5.5. report_cancels (integer)
518 533
 
519 534
    By default, CANCEL reporting is disabled -- most accounting
520 535
    applications wants to see INVITE's cancellation status. Turn on if you
... ...
@@ -522,10 +537,10 @@ modparam("acc", "report_ack", 1)
522 537
 
523 538
    Default value is 0 (no).
524 539
 
525
-   Example 1.4. report_cancels example
540
+   Example 1.5. report_cancels example
526 541
 modparam("acc", "report_cancels", 1)
527 542
 
528
-5.5. detect_direction (integer)
543
+5.6. detect_direction (integer)
529 544
 
530 545
    Controlles the direction detection for sequential requests. If enabled
531 546
    (non zero value), for sequential requests with upstream direction (from
... ...
@@ -537,10 +552,10 @@ modparam("acc", "report_cancels", 1)
537 552
 
538 553
    Default value is 0 (disabled).
539 554
 
540
-   Example 1.5. detect_direction example
555
+   Example 1.6. detect_direction example
541 556
 modparam("acc", "detect_direction", 1)
542 557
 
543
-5.6. multi_leg_info (string)
558
+5.7. multi_leg_info (string)
544 559
 
545 560
    Defines the AVP set to be used in per-call-leg accounting. See
546 561
    Section 3, “Multi Call-Legs accounting” for a detailed description of
... ...
@@ -550,7 +565,7 @@ modparam("acc", "detect_direction", 1)
550 565
 
551 566
    Default value is 0 (disabled).
552 567
 
553
-   Example 1.6. multi_leg_info example
568
+   Example 1.7. multi_leg_info example
554 569
 # for syslog-based accounting, use any text you want to be printed
555 570
 modparam("acc", "multi_leg_info",
556 571
     "text1=$avp(src);text2=$avp(dst)")
... ...
@@ -564,34 +579,34 @@ modparam("acc", "multi_leg_info",
564 579
 modparam("acc", "multi_leg_info",
565 580
     "2345=$avp(src);2346=$avp(dst)")
566 581
 
567
-5.7. log_flag (integer)
582
+5.8. log_flag (integer)
568 583
 
569 584
    Request flag which needs to be set to account a transaction via syslog.
570 585
 
571 586
    Default value is not-set (no flag).
572 587
 
573
-   Example 1.7. log_flag example
588
+   Example 1.8. log_flag example
574 589
 modparam("acc", "log_flag", 2)
575 590
 
576
-5.8. log_missed_flag (integer)
591
+5.9. log_missed_flag (integer)
577 592
 
578 593
    Request flag which needs to be set to account missed calls via syslog.
579 594
 
580 595
    Default value is not-set (no flag).
581 596
 
582
-   Example 1.8. log_missed_flag example
597
+   Example 1.9. log_missed_flag example
583 598
 modparam("acc", "log_missed_flag", 3)
584 599
 
585
-5.9. log_level (integer)
600
+5.10. log_level (integer)
586 601
 
587 602
    Log level at which accounting messages are issued to syslog.
588 603
 
589 604
    Default value is L_NOTICE.
590 605
 
591
-   Example 1.9. log_level example
606
+   Example 1.10. log_level example
592 607
 modparam("acc", "log_level", 2)   # Set log_level to 2
593 608
 
594
-5.10. log_facility (string)
609
+5.11. log_facility (string)
595 610
 
596 611
    Log facility to which accounting messages are issued to syslog. This
597 612
    allows to easily seperate the accounting specific logging from the
... ...
@@ -599,20 +614,20 @@ modparam("acc", "log_level", 2)   # Set log_level to 2
599 614
 
600 615
    Default value is LOG_DAEMON.
601 616
 
602
-   Example 1.10. log_facility example
617
+   Example 1.11. log_facility example
603 618
 modparam("acc", "log_facility", "LOG_DAEMON")
604 619
 
605
-5.11. log_extra (string)
620
+5.12. log_extra (string)
606 621
 
607 622
    Extra values to be logged. See section Section 2, “Extra accounting”
608 623
    for more details.
609 624
 
610 625
    Default value is NULL.
611 626
 
612
-   Example 1.11. log_extra example
627
+   Example 1.12. log_extra example
613 628
 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
614 629
 
615
-5.12. radius_config (string)
630
+5.13. radius_config (string)
616 631
 
617 632
    This parameter is radius specific. Path to radius client configuration
618 633
    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)")
625 640
 
626 641
    Default value is “NULL”.
627 642
 
628
-   Example 1.12. radius_config example
643
+   Example 1.13. radius_config example
629 644
 modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
630 645
 
631
-5.13. radius_flag (integer)
646
+5.14. radius_flag (integer)
632 647
 
633 648
    Request flag which needs to be set to account a transaction -- RADIUS
634 649
    specific.
635 650
 
636 651
    Default value is not-set (no flag).
637 652
 
638
-   Example 1.13. radius_flag example
653
+   Example 1.14. radius_flag example
639 654
 modparam("acc", "radius_flag", 2)
640 655
 
641
-5.14. radius_missed_flag (integer)
656
+5.15. radius_missed_flag (integer)
642 657
 
643 658
    Request flag which needs to be set to account missed calls -- RADIUS
644 659
    specific.
645 660
 
646 661
    Default value is not-set (no flag).
647 662
 
648
-   Example 1.14. radius_missed_flag example
663
+   Example 1.15. radius_missed_flag example
649 664
 modparam("acc", "radius_missed_flag", 3)
650 665
 
651
-5.15. service_type (integer)
666
+5.16. service_type (integer)
652 667
 
653 668
    Radius service type used for accounting.
654 669
 
655 670
    Default value is 15 (SIP).
656 671
 
657
-   Example 1.15. service_type example
672
+   Example 1.16. service_type example
658 673
 modparam("acc", "service_type", 16)
659 674
 
660
-5.16. radius_extra (string)
675
+5.17. radius_extra (string)
661 676
 
662 677
    Extra values to be logged via RADIUS - RADIUS specific. See section
663 678
    Section 2, “Extra accounting” for more details.
664 679
 
665 680
    Default value is NULL.
666 681
 
667
-   Example 1.16. radius_extra example
682
+   Example 1.17. radius_extra example
668 683
 modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
669 684
 
670
-5.17. db_flag (integer)
685
+5.18. db_flag (integer)
671 686
 
672 687
    Request flag which needs to be set to account a transaction -- database
673 688
    specific.
674 689
 
675 690
    Default value is not-set (no flag).
676 691
 
677
-   Example 1.17. db_flag example
692
+   Example 1.18. db_flag example
678 693
 modparam("acc", "db_flag", 2)
679 694
 
680
-5.18. db_missed_flag (integer)
695
+5.19. db_missed_flag (integer)
681 696
 
682 697
    Request flag which needs to be set to account missed calls -- database
683 698
    specific.
684 699
 
685 700
    Default value is not-set (no flag).
686 701
 
687
-   Example 1.18. db_missed_flag example
702
+   Example 1.19. db_missed_flag example
688 703
 modparam("acc", "db_missed_flag", 3)
689 704
 
690
-5.19. db_table_acc (string)
705
+5.20. db_table_acc (string)
691 706
 
692
-   Table name of accounting successfull calls -- database specific. It can
693
-   include config variables.
707
+   Table name of accounting successfull calls -- database specific.
694 708
 
695 709
    Default value is “acc”
696 710
 
697
-   Example 1.19. db_table_acc example
711
+   Example 1.20. db_table_acc example
698 712
 modparam("acc", "db_table_acc", "myacc_table")
699
-modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
700 713
 
701
-5.20. db_table_missed_calls (string)
714
+5.21. db_table_missed_calls (string)
702 715
 
703
-   Table name for accounting missed calls -- database specific. It can
704
-   include config variables.
716
+   Table name for accounting missed calls -- database specific.
705 717
 
706 718
    Default value is “missed_calls”
707 719
 
708
-   Example 1.20. db_table_missed_calls example
720
+   Example 1.21. db_table_missed_calls example
709 721
 modparam("acc", "db_table_missed_calls", "myMC_table")
710
-modparam("acc", "db_table_missed_calls", "mc_$time(year)_$time(mon)")
711 722
 
712
-5.21. db_url (string)
723
+5.22. db_url (string)
713 724
 
714 725
    SQL address -- database specific. If is set to NULL or emty string, the
715 726
    SQL support is disabled.
716 727
 
717 728
    Default value is “NULL” (SQL disabled).
718 729
 
719
-   Example 1.21. db_url example
730
+   Example 1.22. db_url example
720 731
 modparam("acc", "db_url", "mysql://user:password@localhost/openser")
721 732
 
722
-5.22. acc_method_column (string)
733
+5.23. acc_method_column (string)
723 734
 
724 735
    Column name in accounting table to store the request's method name as
725 736
    string.
726 737
 
727 738
    Default value is “method”.
728 739
 
729
-   Example 1.22. acc_method_column example
740
+   Example 1.23. acc_method_column example
730 741
 modparam("acc", "acc_method_column", "method")
731 742
 
732
-5.23. acc_from_tag_column (string)
743
+5.24. acc_from_tag_column (string)
733 744
 
734 745
    Column name in accounting table to store the From header TAG parameter.
735 746
 
736 747
    Default value is “from_tag”.
737 748
 
738
-   Example 1.23. acc_from_tag_column example
749
+   Example 1.24. acc_from_tag_column example
739 750
 modparam("acc", "acc_from_tag_column", "from_tag")
740 751
 
741
-5.24. acc_to_tag_column (string)
752
+5.25. acc_to_tag_column (string)
742 753
 
743 754
    Column name in accounting table to store the To header TAG parameter.
744 755
 
745 756
    Default value is “to_tag”.
746 757
 
747
-   Example 1.24. acc_to_tag_column example
758
+   Example 1.25. acc_to_tag_column example
748 759
 modparam("acc", "acc_to_tag_column", "to_tag")
749 760
 
750
-5.25. acc_callid_column (string)
761
+5.26. acc_callid_column (string)
751 762
 
752 763
    Column name in accounting table to store the request's Callid value.
753 764
 
754 765
    Default value is “callid”.
755 766
 
756
-   Example 1.25. acc_callid_column example
767
+   Example 1.26. acc_callid_column example
757 768
 modparam("acc", "acc_callid_column", "callid")
758 769
 
759
-5.26. acc_sip_code_column (string)
770
+5.27. acc_sip_code_column (string)
760 771
 
761 772
    Column name in accounting table to store the final reply's numric code
762 773
    value in string format.
763 774
 
764 775
    Default value is “sip_code”.
765 776
 
766
-   Example 1.26. acc_sip_code_column example
777
+   Example 1.27. acc_sip_code_column example
767 778
 modparam("acc", "acc_sip_code_column", "sip_code")
768 779
 
769
-5.27. acc_sip_reason_column (string)
780
+5.28. acc_sip_reason_column (string)
770 781
 
771 782
    Column name in accounting table to store the final reply's reason
772 783
    phrase value.
773 784
 
774 785
    Default value is “sip_reason”.
775 786
 
776
-   Example 1.27. acc_sip_reason_column example
787
+   Example 1.28. acc_sip_reason_column example
777 788
 modparam("acc", "acc_sip_reason_column", "sip_reason")
778 789
 
779
-5.28. acc_time_column (string)
790
+5.29. acc_time_column (string)
780 791
 
781 792
    Column name in accounting table to store the time stamp of the
782 793
    transaction completion in date-time format.
783 794
 
784 795
    Default value is “time”.
785 796
 
786
-   Example 1.28. acc_time_column example
797
+   Example 1.29. acc_time_column example
787 798
 modparam("acc", "acc_time_column", "time")
788 799
 
789
-5.29. db_extra (string)
800
+5.30. db_extra (string)
790 801
 
791 802
    Extra values to be logged into database - DB specific. See section
792 803
    Section 2, “Extra accounting” for more details.
793 804
 
794 805
    Default value is NULL.
795 806
 
796
-   Example 1.29. db_extra example
807
+   Example 1.30. db_extra example
797 808
 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
798 809
 
799
-5.30. diameter_flag (integer)
810
+5.31. diameter_flag (integer)
800 811
 
801 812
    Request flag which needs to be set to account a transaction -- DIAMETER
802 813
    specific.
803 814
 
804 815
    Default value is not-set (no flag).
805 816
 
806
-   Example 1.30. diameter_flag example
817
+   Example 1.31. diameter_flag example
807 818
 modparam("acc", "diameter_flag", 2)
808 819
 
809
-5.31. diameter_missed_flag (integer)
820
+5.32. diameter_missed_flag (integer)
810 821
 
811 822
    Request flag which needs to be set to account missed calls -- DIAMETER
812 823
    specific.
813 824
 
814 825
    Default value is not-set (no flag).
815 826
 
816
-   Example 1.31. diameter_missed_flag example
827
+   Example 1.32. diameter_missed_flag example
817 828
 modparam("acc", "diameter_missed_flag", 3)
818 829
 
819
-5.32. diameter_client_host (string)
830
+5.33. diameter_client_host (string)
820 831
 
821 832
    Hostname of the machine where the DIAMETER Client is running --
822 833
    DIAMETER specific.
823 834
 
824 835
    Default value is “localhost”.
825 836
 
826
-   Example 1.32. diameter_client_host example
837
+   Example 1.33. diameter_client_host example
827 838
 modparam("acc", "diameter_client_host", "3a_server.net")
828 839
 
829
-5.33. diameter_client_port (int)
840
+5.34. diameter_client_port (int)
830 841
 
831 842
    Port number where the Diameter Client is listening -- DIAMETER
832 843
    specific.
833 844
 
834 845
    Default value is 3000.
835 846
 
836
-   Example 1.33. diameter_client_host example
847
+   Example 1.34. diameter_client_host example
837 848
 modparam("acc", "diameter_client_port", 3000)
838 849
 
839
-5.34. diameter_extra (string)
850
+5.35. diameter_extra (string)
840 851
 
841 852
    Extra values to be logged via DIAMETER - DIAMETER specific. See section
842 853
    Section 2, “Extra accounting” for more details.
843 854
 
844 855
    Default value is NULL.
845 856
 
846
-   Example 1.34. diameter_extra example
857
+   Example 1.35. diameter_extra example
847 858
 modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
848 859
 
849 860
 6. Exported Functions
... ...
@@ -865,7 +876,7 @@ modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
865 876
 
866 877
    This function can be used from ANY_ROUTE.
867 878
 
868
-   Example 1.35. acc_log_request usage
879
+   Example 1.36. acc_log_request usage
869 880
 ...
870 881
 acc_log_request("Some comment");
871 882
 ...
... ...
@@ -878,14 +889,13 @@ acc_log_request("Some comment");
878 889
 
879 890
    Meaning of the parameters is as follows:
880 891
      * comment - Comment to be appended.
881
-     * table - Database table to be used. It can include config variables.
892
+     * table - Database table to be used.
882 893
 
883 894
    This function can be used from ANY_ROUTE.
884 895
 
885
-   Example 1.36. acc_db_request usage
896
+   Example 1.37. acc_db_request usage
886 897
 ...
887
-acc_db_request("Some comment", "some_table");
888
-acc_db_request("200 ok", "acc_cfg_$time(year)");
898
+acc_log_request("Some comment", "Some table");
889 899
 ...
890 900
 
891 901
 6.3.  acc_rad_request(comment)
... ...
@@ -898,7 +908,7 @@ acc_db_request("200 ok", "acc_cfg_$time(year)");
898 908
 
899 909
    This function can be used from ANY_ROUTE.
900 910
 
901
-   Example 1.37. acc_rad_request usage
911
+   Example 1.38. acc_rad_request usage
902 912
 ...
903 913
 acc_rad_request("Some comment");
904 914
 ...
... ...
@@ -913,7 +923,7 @@ acc_rad_request("Some comment");
913 923
 
914 924
    This function can be used from ANY_ROUTE.
915 925
 
916
-   Example 1.38. acc_diam_request usage
926
+   Example 1.39. acc_diam_request usage
917 927
 ...
918 928
 acc_diam_request("Some comment");
919 929
 ...
... ...
@@ -73,6 +73,8 @@
73 73
 
74 74
 #define MAX_SYSLOG_SIZE  65536
75 75
 
76
+#define MAX_FAILED_FILTER_COUNT 15
77
+
76 78
 /* WARNING: This is a flag stored in the sip_msg structure, the flag is
77 79
  * temporarily defined here to make the module work with the sip-router core,
78 80
  * I assume it won't be needed once we merge acc implementations from both
... ...
@@ -39,7 +39,6 @@
39 39
 #include <string.h>
40 40
 
41 41
 #include "../../dprint.h"
42
-#include "../../sr_module.h"
43 42
 #include "../../parser/parse_from.h"
44 43
 #include "../../parser/parse_content.h"
45 44
 #include "../../modules/tm/tm_load.h"
... ...
@@ -102,6 +101,8 @@ struct acc_enviroment acc_env;
102 101
 	(((_rq)->REQ_METHOD==METHOD_CANCEL) && report_cancels==0)
103 102
 
104 103
 
104
+
105
+
105 106
 static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
106 107
 
107 108
 
... ...
@@ -179,35 +180,6 @@ int w_acc_log_request(struct sip_msg *rq, char *comment, char *foo)
179 180
 
180 181
 
181 182
 #ifdef SQL_ACC
182
-int acc_db_set_table_name(struct sip_msg *msg, void *param, str *table)
183
-{
184
-#define DB_TABLE_NAME_SIZE	64
185
-	static char db_table_name_buf[DB_TABLE_NAME_SIZE];
186
-	str dbtable;
187
-
188
-	if(param!=NULL) {
189
-		if(get_str_fparam(&dbtable, msg, (fparam_t*)param)<0) {
190
-			LM_ERR("cannot get acc db table name\n");
191
-			return -1;
192
-		}
193
-		if(dbtable.len>=DB_TABLE_NAME_SIZE) {
194
-			LM_ERR("acc db table name too big [%.*s] max %d\n",
195
-					dbtable.len, dbtable.s, DB_TABLE_NAME_SIZE);
196
-			return -1;
197
-		}
198
-		strncpy(db_table_name_buf, dbtable.s, dbtable.len);
199
-		env_set_text(db_table_name_buf, dbtable.len);
200
-	} else {
201
-		if(table==NULL) {
202
-			LM_ERR("no acc table name\n");
203
-			return -1;
204
-		}
205
-		env_set_text(table->s, table->len);
206
-	}
207
-	return 0;
208
-}
209
-
210
-
211 183
 int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
212 184
 {
213 185
 	if (!table) {
... ...
@@ -216,12 +188,9 @@ int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
216 188
 	}
217 189
 	if (acc_preparse_req(rq)<0)
218 190
 		return -1;
219
-	if(acc_db_set_table_name(rq, (void*)table, NULL)<0) {
220
-		LM_ERR("cannot set table name\n");
221
-		return -1;
222
-    }
223 191
 	env_set_to( rq->to );
224 192
 	env_set_comment((struct acc_param*)comment);
193
+	env_set_text(table, strlen(table));
225 194
 	return acc_db_request(rq);
226 195
 }
227 196
 #endif
... ...
@@ -289,21 +258,33 @@ void acc_onreq( struct cell* t, int type, struct tmcb_params *ps )
289 258
 
290 259
 
291 260
 /* is this reply of interest for accounting ? */
292
-static inline int should_acc_reply(struct sip_msg *req,struct sip_msg *rpl,
293
-																	int code)
261
+static inline int should_acc_reply(struct sip_msg *req, struct sip_msg *rpl,
262
+				   int code)
294 263
 {
264
+    unsigned int i;
265
+
295 266
 	/* negative transactions reported otherwise only if explicitly 
296 267
 	 * demanded */
297
-	if ( !is_failed_acc_on(req) && code >=300 )
298
-		return 0;
299
-	if ( !is_acc_on(req) )
300
-		return 0;
301
-	if ( code<200 && !(early_media &&
302
-	parse_headers(rpl,HDR_CONTENTLENGTH_F, 0)==0 && rpl->content_length &&
303
-	get_content_length(rpl)>0 ) )
304
-		return 0;
305
-
306
-	return 1; /* seed is through, we will account this reply */
268
+
269
+    if (code >= 300) {
270
+	if (!is_failed_acc_on(req)) return 0;
271
+	i = 0;
272
+	while (failed_filter[i] != 0) {
273
+	    if (failed_filter[i] == code) return 0;
274
+	    i++;
275
+	}
276
+	return 1;
277
+    }
278
+
279
+    if ( !is_acc_on(req) )
280
+	return 0;
281
+	
282
+    if ( code<200 && !(early_media &&
283
+		       parse_headers(rpl,HDR_CONTENTLENGTH_F, 0) == 0 &&
284
+		       rpl->content_length && get_content_length(rpl) > 0))
285
+	return 0;
286
+
287
+    return 1; /* seed is through, we will account this reply */
307 288
 }
308 289
 
309 290
 
... ...
@@ -355,10 +336,7 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
355 336
 	}
356 337
 #ifdef SQL_ACC
357 338
 	if (is_db_mc_on(req)) {
358
-		if(acc_db_set_table_name(req, db_table_mc_data, &db_table_mc)<0) {
359
-			LM_ERR("cannot set missed call db table name\n");
360
-			return;
361
-		}
339
+		env_set_text(db_table_mc.s, db_table_mc.len);
362 340
 		acc_db_request( req );
363 341
 		flags_to_reset |= db_missed_flag;
364 342
 	}
... ...
@@ -429,10 +407,7 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
429 407
 	}
430 408
 #ifdef SQL_ACC
431 409
 	if (is_db_acc_on(req)) {
432
-		if(acc_db_set_table_name(req, db_table_acc_data, &db_table_acc)<0) {
433
-			LM_ERR("cannot set acc db table name\n");
434
-			return;
435
-		}
410
+		env_set_text( db_table_acc.s, db_table_acc.len);
436 411
 		acc_db_request(req);
437 412
 	}
438 413
 #endif
... ...
@@ -473,10 +448,7 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req,
473 448
 	}
474 449
 #ifdef SQL_ACC
475 450
 	if (is_db_acc_on(req)) {
476
-		if(acc_db_set_table_name(ack, db_table_acc_data, &db_table_acc)<0) {
477
-			LM_ERR("cannot set acc db table name\n");
478
-			return;
479
-		}
451
+		env_set_text( db_table_acc.s, db_table_acc.len);
480 452
 		acc_db_request( ack );
481 453
 	}
482 454
 #endif
... ...
@@ -102,6 +102,9 @@ int report_cancels = 0;		/*!< would you like us to report CANCELs from upstream
102 102
 int report_ack = 0;		/*!< report e2e ACKs too */
103 103
 int detect_direction = 0;	/*!< detect and correct direction in the sequential requests */
104 104
 int failed_transaction_flag = -1; /*!< should failed replies (>=3xx) be logged ? default==no */
105
+static char *failed_filter_str = 0;  /* by default, do not filter logging of
106
+					failed transactions */
107
+unsigned short failed_filter[MAX_FAILED_FILTER_COUNT + 1];
105 108
 static char* leg_info_str = 0;	/*!< multi call-leg support */
106 109
 struct acc_extra *leg_info = 0;
107 110
 
... ...
@@ -164,9 +167,7 @@ static char *db_extra_str = 0;		/*!< db extra variables */
164 167
 struct acc_extra *db_extra = 0;
165 168
 static str db_url = {NULL, 0};		/*!< Database url */
166 169
 str db_table_acc = str_init("acc");	/*!< name of database tables */
167
-void *db_table_acc_data = NULL;
168 170
 str db_table_mc = str_init("missed_calls");
169
-void *db_table_mc_data = NULL;
170 171
 /* names of columns in tables acc/missed calls*/
171 172
 str acc_method_col     = str_init("method");
172 173
 str acc_fromtag_col    = str_init("from_tag");
... ...
@@ -218,6 +219,7 @@ static cmd_export_t cmds[] = {
218 219
 static param_export_t params[] = {
219 220
 	{"early_media",             INT_PARAM, &early_media             },
220 221
 	{"failed_transaction_flag", INT_PARAM, &failed_transaction_flag },
222
+	{"failed_filter",           STR_PARAM, &failed_filter_str       },
221 223
 	{"report_ack",              INT_PARAM, &report_ack              },
222 224
 	{"report_cancels",          INT_PARAM, &report_cancels          },
223 225
 	{"multi_leg_info",          STR_PARAM, &leg_info_str            },
... ...
@@ -320,8 +322,6 @@ static int acc_fixup(void** param, int param_no)
320 322
 		if (db_url.s==0) {
321 323
 			pkg_free(p);
322 324
 			*param = 0;
323
-		} else {
324
-			return fixup_var_pve_str_12(param, 2);
325 325
 		}
326 326
 #endif
327 327
 	}
... ...
@@ -355,6 +355,45 @@ static int mod_lrt_init( void )
355 355
 	return 0;
356 356
 }
357 357
 
358
+static int parse_failed_filter(char *s, unsigned short *failed_filter)
359
+{
360
+    unsigned int n;
361
+    char *at;
362
+
363
+    n = 0;
364
+
365
+    while (1) {
366
+	if (n >= MAX_FAILED_FILTER_COUNT) {
367
+	    LM_ERR("too many elements in failed_filter\n");
368
+	    return 0;
369
+	}
370
+	at = s;
371
+	while ((*at >= '0') && (*at <= '9')) at++;
372
+	if (at - s != 3) {
373
+	    LM_ERR("respose code in failed_filter must have 3 digits\n");
374
+	    return 0;
375
+	}
376
+	failed_filter[n] = (*s - '0') * 100 + (*(s + 1) - '0') * 10 +
377
+	    (*(s + 2) - '0');
378
+	if (failed_filter[n] < 300) {
379
+	    LM_ERR("invalid respose code %u in failed_filter\n",
380
+		   failed_filter[n]);
381
+	    return 0;
382
+	}
383
+	LM_DBG("failed_filter %u = %u\n", n, failed_filter[n]);
384
+	n++;
385
+	failed_filter[n] = 0;
386
+	s = at;
387
+	if (*s == 0)
388
+	    return 1;
389
+	if (*s != ',') {
390
+	    LM_ERR("response code is not followed by comma or end of string\n");
391
+	    return 0;
392
+	}
393
+	s++;
394
+    }
395
+}
396
+
358 397
 static int mod_init( void )
359 398
 {
360 399
 	lrt_info_t li;
... ...
@@ -367,27 +406,7 @@ static int mod_init( void )
367 406
 	if (db_url.s)
368 407
 		db_url.len = strlen(db_url.s);
369 408
 	db_table_acc.len = strlen(db_table_acc.s);
370
-	if(db_table_acc.len!=3 || strncmp(db_table_acc.s, "acc", 3)!=0)
371
-	{
372
-		db_table_acc_data = db_table_acc.s;
373
-		if(fixup_var_pve_str_12(&db_table_acc_data, 1)<0)
374
-		{
375
-			LM_ERR("unable to parse acc table name [%.*s]\n",
376
-					db_table_acc.len, db_table_acc.s);
377
-			return -1;
378
-		}
379
-	}
380 409
 	db_table_mc.len = strlen(db_table_mc.s);
381
-	if(db_table_mc.len!=12 || strncmp(db_table_mc.s, "missed_calls", 12)!=0)
382
-	{
383
-		db_table_mc_data = db_table_mc.s;
384
-		if(fixup_var_pve_str_12(&db_table_mc_data, 1)<0)
385
-		{
386
-			LM_ERR("unable to parse mc table name [%.*s]\n",
387
-					db_table_mc.len, db_table_mc.s);
388
-			return -1;
389
-		}
390
-	}
391 410
 	acc_method_col.len = strlen(acc_method_col.s);
392 411
 	acc_fromtag_col.len = strlen(acc_fromtag_col.s);
393 412
 	acc_totag_col.len = strlen(acc_totag_col.s);
... ...
@@ -409,11 +428,20 @@ static int mod_init( void )
409 428
 
410 429
 	/* ----------- GENERIC INIT SECTION  ----------- */
411 430
 
431
+	/* failed transaction handling */
412 432
 	if ((failed_transaction_flag != -1) && 
413 433
 		!flag_in_range(failed_transaction_flag)) {
414 434
 		LM_ERR("failed_transaction_flag set to invalid value\n");
415 435
 		return -1;
416 436
 	}
437
+	if (failed_filter_str) {
438
+	    if (parse_failed_filter(failed_filter_str, failed_filter) == 0) {
439
+		LM_ERR("failed to parse failed_filter param\n");
440
+		return -1;
441
+	    }
442
+	} else {
443
+	    failed_filter[0] = 0;
444
+	}
417 445
 
418 446
 	/* load the TM API */
419 447
 	if (load_tm_api(&tmb)!=0) {
... ...
@@ -47,6 +47,7 @@ extern int report_cancels;
47 47
 extern int report_ack;
48 48
 extern int early_media;
49 49
 extern int failed_transaction_flag;
50
+extern unsigned short failed_filter[];
50 51
 extern int detect_direction;
51 52
 
52 53
 extern int log_facility;
... ...
@@ -73,9 +74,7 @@ extern int db_flag;
73 74
 extern int db_missed_flag;
74 75
 
75 76
 extern str db_table_acc;
76
-extern void *db_table_acc_data;
77 77
 extern str db_table_mc;
78
-extern void *db_table_mc_data;
79 78
 
80 79
 extern str acc_method_col;
81 80
 extern str acc_fromuri_col;
... ...
@@ -400,6 +400,24 @@ modparam("acc", "early_media", 1)
400 400
 		<title>failed_transaction_flag example</title>
401 401
 		<programlisting format="linespecific">
402 402
 modparam("acc", "failed_transaction_flag", 4)
403
+</programlisting>
404
+		</example>
405
+	</section>
406
+	<section>
407
+		<title><varname>failed_filter</varname> (string)</title>
408
+		<para>
409
+		A string of failure response codes from 300 to 999
410
+		separated by commas. Failed transaction will not be accounted
411
+		if its response code is in the list even when
412
+		failed_transaction_flag is set. 
413
+		</para>
414
+		<para>
415
+		Default value is not-set (failure filtering is off).
416
+		</para>
417
+		<example>
418
+		<title>failed_filter example</title>
419
+		<programlisting format="linespecific">
420
+modparam("acc", "failed_filter", "404,407")
403 421
 </programlisting>
404 422
 		</example>
405 423
 	</section>
... ...
@@ -695,8 +713,7 @@ modparam("acc", "db_missed_flag", 3)
695 713
 	<section>
696 714
 		<title><varname>db_table_acc</varname> (string)</title>
697 715
 		<para>
698
-			Table name of accounting successfull calls -- database specific. It
699
-			can include config variables.
716
+		Table name of accounting successfull calls -- database specific.
700 717
 		</para>
701 718
 		<para>
702 719
 		Default value is <quote>acc</quote>
... ...
@@ -705,15 +722,13 @@ modparam("acc", "db_missed_flag", 3)
705 722
 		<title>db_table_acc example</title>
706 723
 		<programlisting format="linespecific">
707 724
 modparam("acc", "db_table_acc", "myacc_table")
708
-modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
709 725
 </programlisting>
710 726
 		</example>
711 727
 	</section>
712 728
 	<section>
713 729
 		<title><varname>db_table_missed_calls</varname> (string)</title>
714 730
 		<para>
715
-			Table name for accounting missed calls -- database specific. It
716
-			can include config variables.
731
+		Table name for accounting missed calls -- database specific.
717 732
 		</para>
718 733
 		<para>
719 734
 		Default value is <quote>missed_calls</quote>
... ...
@@ -722,7 +737,6 @@ modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
722 737
 		<title>db_table_missed_calls example</title>
723 738
 		<programlisting format="linespecific">
724 739
 modparam("acc", "db_table_missed_calls", "myMC_table")
725
-modparam("acc", "db_table_missed_calls", "mc_$time(year)_$time(mon)")
726 740
 </programlisting>
727 741
 		</example>
728 742
 	</section>
... ...
@@ -1001,8 +1015,7 @@ acc_log_request("Some comment");
1001 1015
 			<para><emphasis>comment</emphasis> - Comment to be appended.</para>
1002 1016
 		</listitem>
1003 1017
 		<listitem>
1004
-			<para><emphasis>table</emphasis> - Database table to be used. It
1005
-			can include config variables.</para>
1018
+			<para><emphasis>table</emphasis> - Database table to be used.</para>
1006 1019
 		</listitem>
1007 1020
 		</itemizedlist>
1008 1021
 		<para>
... ...
@@ -1012,8 +1025,7 @@ acc_log_request("Some comment");
1012 1025
 		<title>acc_db_request usage</title>
1013 1026
 		<programlisting format="linespecific">
1014 1027
 ...
1015
-acc_db_request("Some comment", "some_table");
1016
-acc_db_request("200 ok", "acc_cfg_$time(year)");
1028
+acc_log_request("Some comment", "Some table");
1017 1029
 ...
1018 1030
 </programlisting>
1019 1031
 		</example>