Browse code

Merge pull request #13 from alezzandro/master

dispatcher: fixing some misspelled words and adding support for custom number of successful probing requests

Daniel-Constantin Mierla authored on 09/01/2015 19:11:26
Showing 8 changed files
... ...
@@ -22,13 +22,21 @@ Olle E. Johansson
22 22
 
23 23
    Edvina AB
24 24
 
25
-   Copyright � 2004 FhG FOKUS
25
+Edited by
26
+
27
+Alessandro Arrichiello
28
+
29
+   Hewlett Packard
26 30
 
27
-   Copyright � 2005 Voice Sistem
31
+   Copyright © 2004 FhG FOKUS
28 32
 
29
-   Copyright � 2010 Daniel-Constantin Mierla (asipto.com)
33
+   Copyright © 2005 Voice Sistem
30 34
 
31
-   Copyright � 2014 Olle E. Johansson, Edvina AB
35
+   Copyright © 2010 Daniel-Constantin Mierla (asipto.com)
36
+
37
+   Copyright © 2014 Olle E. Johansson, Edvina AB
38
+
39
+   Copyright © 2015 Alessandro Arrichiello, Hewlett Packard
32 40
      __________________________________________________________________
33 41
 
34 42
    Table of Contents
... ...
@@ -66,14 +74,15 @@ Olle E. Johansson
66 74
               3.21. ds_ping_from (string)
67 75
               3.22. ds_ping_interval (int)
68 76
               3.23. ds_probing_threshold (int)
69
-              3.24. ds_ping_reply_codes (string)
70
-              3.25. ds_probing_mode (int)
71
-              3.26. ds_hash_size (int)
72
-              3.27. ds_hash_expire (int)
73
-              3.28. ds_hash_initexpire (int)
74
-              3.29. ds_hash_check_interval (int)
75
-              3.30. outbound_proxy (str)
76
-              3.31. ds_default_socket (str)
77
+              3.24. ds_inactive_threshold (int)
78
+              3.25. ds_ping_reply_codes (string)
79
+              3.26. ds_probing_mode (int)
80
+              3.27. ds_hash_size (int)
81
+              3.28. ds_hash_expire (int)
82
+              3.29. ds_hash_initexpire (int)
83
+              3.30. ds_hash_check_interval (int)
84
+              3.31. outbound_proxy (str)
85
+              3.32. ds_default_socket (str)
77 86
 
78 87
         4. Functions
79 88
 
... ...
@@ -117,45 +126,46 @@ Olle E. Johansson
117 126
 
118 127
    List of Examples
119 128
 
120
-   1.1. Set the "list_file" parameter
121
-   1.2. Set "db_url" parameter
122
-   1.3. Set "table_name" parameter
123
-   1.4. Set "setid_col" parameter
124
-   1.5. Set "destination_col" parameter
125
-   1.6. Set "flags_col" parameter
126
-   1.7. Set "priority_col" parameter
127
-   1.8. Set the "force_dst" parameter
128
-   1.9. Set the "flags" parameter
129
-   1.10. Set the "use_default" parameter
130
-   1.11. Set the "dst_avp" parameter
131
-   1.12. Set the "grp_avp" parameter
132
-   1.13. Set the "cnt_avp" parameter
133
-   1.14. Set the "dstid_avp" parameter
134
-   1.15. Set the "attrs_avp" parameter
135
-   1.16. Set the "sock_avp" parameter
129
+   1.1. Set the “list_file” parameter
130
+   1.2. Set “db_url” parameter
131
+   1.3. Set “table_name” parameter
132
+   1.4. Set “setid_col” parameter
133
+   1.5. Set “destination_col” parameter
134
+   1.6. Set “flags_col” parameter
135
+   1.7. Set “priority_col” parameter
136
+   1.8. Set the “force_dst” parameter
137
+   1.9. Set the “flags” parameter
138
+   1.10. Set the “use_default” parameter
139
+   1.11. Set the “dst_avp” parameter
140
+   1.12. Set the “grp_avp” parameter
141
+   1.13. Set the “cnt_avp” parameter
142
+   1.14. Set the “dstid_avp” parameter
143
+   1.15. Set the “attrs_avp” parameter
144
+   1.16. Set the “sock_avp” parameter
136 145
    1.17. Use $avp(i:273) for hashing:
137 146
    1.18. Use combination of PVs for hashing:
138
-   1.19. Set the "setid_pvname" parameter
139
-   1.20. Set the "attrs_pvname" parameter
140
-   1.21. Set the "ds_ping_method" parameter
141
-   1.22. Set the "ds_ping_from" parameter
142
-   1.23. Set the "ds_ping_interval" parameter
143
-   1.24. Set the "ds_probing_threshhold" parameter
144
-   1.25. Set the "ds_ping_reply_codes" parameter
145
-   1.26. Set the "ds_probing_mode" parameter
146
-   1.27. Set the "ds_hash_size" parameter
147
-   1.28. Set the "ds_hash_expire" parameter
148
-   1.29. Set the "ds_hash_initexpire" parameter
149
-   1.30. Set the "ds_hash_check_interval" parameter
150
-   1.31. Set the "outbound_proxy" parameter
151
-   1.32. Set the "ds_default_socket" parameter
152
-   1.33. ds_select_dst usage
153
-   1.34. ds_mark_dst usage
154
-   1.35. ds_list_exist usage
155
-   1.36. ds_mark_dst usage
156
-   1.37. ds_load_unset usage
157
-   1.38. dispatcher list file
158
-   1.39. Kamailio config script - sample dispatcher usage
147
+   1.19. Set the “setid_pvname” parameter
148
+   1.20. Set the “attrs_pvname” parameter
149
+   1.21. Set the “ds_ping_method” parameter
150
+   1.22. Set the “ds_ping_from” parameter
151
+   1.23. Set the “ds_ping_interval” parameter
152
+   1.24. Set the “ds_probing_threshold” parameter
153
+   1.25. Set the “ds_inactive_threshold” parameter
154
+   1.26. Set the “ds_ping_reply_codes” parameter
155
+   1.27. Set the “ds_probing_mode” parameter
156
+   1.28. Set the “ds_hash_size” parameter
157
+   1.29. Set the “ds_hash_expire” parameter
158
+   1.30. Set the “ds_hash_initexpire” parameter
159
+   1.31. Set the “ds_hash_check_interval” parameter
160
+   1.32. Set the “outbound_proxy” parameter
161
+   1.33. Set the “ds_default_socket” parameter
162
+   1.34. ds_select_dst usage
163
+   1.35. ds_mark_dst usage
164
+   1.36. ds_list_exist usage
165
+   1.37. ds_mark_dst usage
166
+   1.38. ds_load_unset usage
167
+   1.39. dispatcher list file
168
+   1.40. Kamailio config script - sample dispatcher usage
159 169
 
160 170
 Chapter 1. Admin Guide
161 171
 
... ...
@@ -192,14 +202,15 @@ Chapter 1. Admin Guide
192 202
         3.21. ds_ping_from (string)
193 203
         3.22. ds_ping_interval (int)
194 204
         3.23. ds_probing_threshold (int)
195
-        3.24. ds_ping_reply_codes (string)
196
-        3.25. ds_probing_mode (int)
197
-        3.26. ds_hash_size (int)
198
-        3.27. ds_hash_expire (int)
199
-        3.28. ds_hash_initexpire (int)
200
-        3.29. ds_hash_check_interval (int)
201
-        3.30. outbound_proxy (str)
202
-        3.31. ds_default_socket (str)
205
+        3.24. ds_inactive_threshold (int)
206
+        3.25. ds_ping_reply_codes (string)
207
+        3.26. ds_probing_mode (int)
208
+        3.27. ds_hash_size (int)
209
+        3.28. ds_hash_expire (int)
210
+        3.29. ds_hash_initexpire (int)
211
+        3.30. ds_hash_check_interval (int)
212
+        3.31. outbound_proxy (str)
213
+        3.32. ds_default_socket (str)
203 214
 
204 215
    4. Functions
205 216
 
... ...
@@ -298,23 +309,24 @@ Chapter 1. Admin Guide
298 309
    3.21. ds_ping_from (string)
299 310
    3.22. ds_ping_interval (int)
300 311
    3.23. ds_probing_threshold (int)
301
-   3.24. ds_ping_reply_codes (string)
302
-   3.25. ds_probing_mode (int)
303
-   3.26. ds_hash_size (int)
304
-   3.27. ds_hash_expire (int)
305
-   3.28. ds_hash_initexpire (int)
306
-   3.29. ds_hash_check_interval (int)
307
-   3.30. outbound_proxy (str)
308
-   3.31. ds_default_socket (str)
312
+   3.24. ds_inactive_threshold (int)
313
+   3.25. ds_ping_reply_codes (string)
314
+   3.26. ds_probing_mode (int)
315
+   3.27. ds_hash_size (int)
316
+   3.28. ds_hash_expire (int)
317
+   3.29. ds_hash_initexpire (int)
318
+   3.30. ds_hash_check_interval (int)
319
+   3.31. outbound_proxy (str)
320
+   3.32. ds_default_socket (str)
309 321
 
310 322
 3.1. list_file (string)
311 323
 
312 324
    Path to the file with destination sets.
313 325
 
314
-   Default value is "/etc/kamailio/dispatcher.list" or
315
-   "/usr/local/etc/kamailio/dispatcher.list".
326
+   Default value is “/etc/kamailio/dispatcher.list” or
327
+   “/usr/local/etc/kamailio/dispatcher.list”.
316 328
 
317
-   Example 1.1. Set the "list_file" parameter
329
+   Example 1.1. Set the “list_file” parameter
318 330
 ...
319 331
 modparam("dispatcher", "list_file", "/var/run/kamailio/dispatcher.list")
320 332
 ...
... ...
@@ -324,9 +336,9 @@ modparam("dispatcher", "list_file", "/var/run/kamailio/dispatcher.list")
324 336
    If you want to load the sets of gateways from the database you must set
325 337
    this parameter.
326 338
 
327
-   Default value is "NULL" (disable DB support).
339
+   Default value is “NULL” (disable DB support).
328 340
 
329
-   Example 1.2. Set "db_url" parameter
341
+   Example 1.2. Set “db_url” parameter
330 342
 ...
331 343
 modparam("dispatcher", "db_url", "mysql://user:passwb@localhost/database")
332 344
 ...
... ...
@@ -336,9 +348,9 @@ modparam("dispatcher", "db_url", "mysql://user:passwb@localhost/database")
336 348
    If you want to load the sets of gateways from the database you must set
337 349
    this parameter as the database name.
338 350
 
339
-   Default value is "dispatcher".
351
+   Default value is “dispatcher”.
340 352
 
341
-   Example 1.3. Set "table_name" parameter
353
+   Example 1.3. Set “table_name” parameter
342 354
 ...
343 355
 modparam("dispatcher", "table_name", "my_dispatcher")
344 356
 ...
... ...
@@ -347,9 +359,9 @@ modparam("dispatcher", "table_name", "my_dispatcher")
347 359
 
348 360
    The column's name in the database storing the gateway's group id.
349 361
 
350
-   Default value is "setid".
362
+   Default value is “setid”.
351 363
 
352
-   Example 1.4. Set "setid_col" parameter
364
+   Example 1.4. Set “setid_col” parameter
353 365
 ...
354 366
 modparam("dispatcher", "setid_col", "groupid")
355 367
 ...
... ...
@@ -358,9 +370,9 @@ modparam("dispatcher", "setid_col", "groupid")
358 370
 
359 371
    The column's name in the database storing the destination sip URI.
360 372
 
361
-   Default value is "destination".
373
+   Default value is “destination”.
362 374
 
363
-   Example 1.5. Set "destination_col" parameter
375
+   Example 1.5. Set “destination_col” parameter
364 376
 ...
365 377
 modparam("dispatcher", "destination_col", "uri")
366 378
 ...
... ...
@@ -370,9 +382,9 @@ modparam("dispatcher", "destination_col", "uri")
370 382
    The column's name in the database storing the flags for the destination
371 383
    URI.
372 384
 
373
-   Default value is "flags".
385
+   Default value is “flags”.
374 386
 
375
-   Example 1.6. Set "flags_col" parameter
387
+   Example 1.6. Set “flags_col” parameter
376 388
 ...
377 389
 modparam("dispatcher", "flags_col", "dstflags")
378 390
 ...
... ...
@@ -382,9 +394,9 @@ modparam("dispatcher", "flags_col", "dstflags")
382 394
    The column's name in the database storing the priority for destination
383 395
    URI.
384 396
 
385
-   Default value is "priority".
397
+   Default value is “priority”.
386 398
 
387
-   Example 1.7. Set "priority_col" parameter
399
+   Example 1.7. Set “priority_col” parameter
388 400
 ...
389 401
 modparam("dispatcher", "priority_col", "dstpriority")
390 402
 ...
... ...
@@ -395,9 +407,9 @@ modparam("dispatcher", "priority_col", "dstpriority")
395 407
    when that is already set. If set to 0, will return error when the
396 408
    destination address is already set.
397 409
 
398
-   Default value is "1".
410
+   Default value is “1”.
399 411
 
400
-   Example 1.8. Set the "force_dst" parameter
412
+   Example 1.8. Set the “force_dst” parameter
401 413
 ...
402 414
 modparam("dispatcher", "force_dst", 1)
403 415
 ...
... ...
@@ -416,9 +428,9 @@ modparam("dispatcher", "force_dst", 1)
416 428
    destination set in the AVP, and use these AVPs to contact next address
417 429
    if the current-tried destination fails.
418 430
 
419
-   Default value is "0".
431
+   Default value is “0”.
420 432
 
421
-   Example 1.9. Set the "flags" parameter
433
+   Example 1.9. Set the “flags” parameter
422 434
  ...
423 435
  modparam("dispatcher", "flags", 3)
424 436
  ...
... ...
@@ -430,9 +442,9 @@ modparam("dispatcher", "force_dst", 1)
430 442
    useful when wanting to send the call to an anouncement server saying:
431 443
    "the gateways are full, try later".
432 444
 
433
-   Default value is "0".
445
+   Default value is “0”.
434 446
 
435
-   Example 1.10. Set the "use_default" parameter
447
+   Example 1.10. Set the “use_default” parameter
436 448
  ...
437 449
  modparam("dispatcher", "use_default", 1)
438 450
  ...
... ...
@@ -450,9 +462,9 @@ Note
450 462
 
451 463
    You must set this parameter if you want to do load balancing fail over.
452 464
 
453
-   Default value is "null" - don't add AVPs.
465
+   Default value is “null” - don't add AVPs.
454 466
 
455
-   Example 1.11. Set the "dst_avp" parameter
467
+   Example 1.11. Set the “dst_avp” parameter
456 468
  ...
457 469
  modparam("dispatcher", "dst_avp", "$avp(dsdst)")
458 470
  ...
... ...
@@ -466,9 +478,9 @@ Note
466 478
 
467 479
    You must set this parameter if you want to do load balancing fail over.
468 480
 
469
-   Default value is "null" - don't add AVP.
481
+   Default value is “null” - don't add AVP.
470 482
 
471
-   Example 1.12. Set the "grp_avp" parameter
483
+   Example 1.12. Set the “grp_avp” parameter
472 484
  ...
473 485
  modparam("dispatcher", "grp_avp", "$avp(dsgrp)")
474 486
  ...
... ...
@@ -482,9 +494,9 @@ Note
482 494
 
483 495
    You must set this parameter if you want to do load balancing fail over.
484 496
 
485
-   Default value is "null" - don't add AVP.
497
+   Default value is “null” - don't add AVP.
486 498
 
487
-   Example 1.13. Set the "cnt_avp" parameter
499
+   Example 1.13. Set the “cnt_avp” parameter
488 500
  ...
489 501
  modparam("dispatcher", "cnt_avp", "$avp(dscnt)")
490 502
  ...
... ...
@@ -499,9 +511,9 @@ Note
499 511
    You must set this parameter if you want to do load balancing on call
500 512
    load (alg 10).
501 513
 
502
-   Default value is "null" - don't add AVP.
514
+   Default value is “null” - don't add AVP.
503 515
 
504
-   Example 1.14. Set the "dstid_avp" parameter
516
+   Example 1.14. Set the “dstid_avp” parameter
505 517
  ...
506 518
  modparam("dispatcher", "dstid_avp", "$avp(dsdstid)")
507 519
  ...
... ...
@@ -512,9 +524,9 @@ Note
512 524
 
513 525
 Note
514 526
 
515
-   Default value is "null" - don't add AVP.
527
+   Default value is “null” - don't add AVP.
516 528
 
517
-   Example 1.15. Set the "attrs_avp" parameter
529
+   Example 1.15. Set the “attrs_avp” parameter
518 530
  ...
519 531
  modparam("dispatcher", "attrs_avp", "$avp(dsattrs)")
520 532
  ...
... ...
@@ -529,9 +541,9 @@ Note
529 541
    If you want to do load balancing fail over, you have to set this
530 542
    parameter to use the correct socket for each gateway.
531 543
 
532
-   Default value is "null" - don't add AVPs.
544
+   Default value is “null” - don't add AVPs.
533 545
 
534
-   Example 1.16. Set the "sock_avp" parameter
546
+   Example 1.16. Set the “sock_avp” parameter
535 547
  ...
536 548
  modparam("dispatcher", "sock_avp", "$avp(dssocket)")
537 549
  ...
... ...
@@ -545,7 +557,7 @@ Note
545 557
    You must set this parameter if you want do hashing over custom message
546 558
    parts.
547 559
 
548
-   Default value is "null" - disabled.
560
+   Default value is “null” - disabled.
549 561
 
550 562
    Example 1.17. Use $avp(i:273) for hashing:
551 563
  ...
... ...
@@ -562,9 +574,9 @@ Note
562 574
    The name of the PV where to store the set ID (group ID) when calling
563 575
    ds_is_from_list() with no parameter.
564 576
 
565
-   Default value is "null" - don't set PV.
577
+   Default value is “null” - don't set PV.
566 578
 
567
-   Example 1.19. Set the "setid_pvname" parameter
579
+   Example 1.19. Set the “setid_pvname” parameter
568 580
  ...
569 581
  modparam("dispatcher", "setid_pvname", "$var(setid)")
570 582
  ...
... ...
@@ -574,9 +586,9 @@ Note
574 586
    The name of the PV where to store the attributes of matching address
575 587
    when calling ds_is_from_list().
576 588
 
577
-   Default value is "null" - don't set PV.
589
+   Default value is “null” - don't set PV.
578 590
 
579
-   Example 1.20. Set the "attrs_pvname" parameter
591
+   Example 1.20. Set the “attrs_pvname” parameter
580 592
  ...
581 593
  modparam("dispatcher", "attrs_pvname", "$var(attrs)")
582 594
  ...
... ...
@@ -587,9 +599,9 @@ Note
587 599
    the gateways. Pinging gateways feature depends on ds_ping_interval
588 600
    parameter.
589 601
 
590
-   Default value is "OPTIONS".
602
+   Default value is “OPTIONS”.
591 603
 
592
-   Example 1.21. Set the "ds_ping_method" parameter
604
+   Example 1.21. Set the “ds_ping_method” parameter
593 605
  ...
594 606
  modparam("dispatcher", "ds_ping_method", "INFO")
595 607
  ...
... ...
@@ -600,9 +612,9 @@ Note
600 612
    to the failed gateways. This method is only available, if compiled with
601 613
    the probing of failed gateways enabled.
602 614
 
603
-   Default value is "sip:dispatcher@localhost".
615
+   Default value is “sip:dispatcher@localhost”.
604 616
 
605
-   Example 1.22. Set the "ds_ping_from" parameter
617
+   Example 1.22. Set the “ds_ping_from” parameter
606 618
  ...
607 619
  modparam("dispatcher", "ds_ping_from", "sip:proxy@sip.somehost.com")
608 620
  ...
... ...
@@ -612,11 +624,11 @@ Note
612 624
    With this parameter you can define the interval for sending a request
613 625
    to a gateway marked as inactive upon a failed request routing to it.
614 626
    This parameter is only used, when the TM-Module is loaded. If set to
615
-   "0", the pinging of inactive gateway is disabled.
627
+   “0”, the pinging of inactive gateway is disabled.
616 628
 
617
-   Default value is "0".
629
+   Default value is “0”.
618 630
 
619
-   Example 1.23. Set the "ds_ping_interval" parameter
631
+   Example 1.23. Set the “ds_ping_interval” parameter
620 632
  ...
621 633
  modparam("dispatcher", "ds_ping_interval", 30)
622 634
  ...
... ...
@@ -630,14 +642,29 @@ Note
630 642
    The number of attempts can be set with this parameter. This parameter
631 643
    can be modified via ser config framework.
632 644
 
633
-   Default value is "1" (set inactive with first failure).
645
+   Default value is “1” (set inactive with first failure).
646
+
647
+   Example 1.24. Set the “ds_probing_threshold” parameter
648
+ ...
649
+ modparam("dispatcher", "ds_probing_threshold", 10)
650
+ ...
651
+
652
+3.24. ds_inactive_threshold (int)
653
+
654
+   If you want to set a gateway into active mode (after being inactive),
655
+   there can be a specific number of successful requests until it will
656
+   change from "inactive" to "active". The number of attempts can be set
657
+   with this parameter. This parameter can be modified via ser config
658
+   framework.
659
+
660
+   Default value is “1” (set active with first success).
634 661
 
635
-   Example 1.24. Set the "ds_probing_threshhold" parameter
662
+   Example 1.25. Set the “ds_inactive_threshold” parameter
636 663
  ...
637
- modparam("dispatcher", "ds_probing_threshhold", 10)
664
+ modparam("dispatcher", "ds_inactive_threshold", 10)
638 665
  ...
639 666
 
640
-3.24. ds_ping_reply_codes (string)
667
+3.25. ds_ping_reply_codes (string)
641 668
 
642 669
    This parameter defines the valid response codes, which are accepted as
643 670
    a valid reply to the PING-Method. It is a list separated by colons,
... ...
@@ -647,15 +674,15 @@ Note
647 674
    valid response). This parameter can be modified via ser config
648 675
    framework.
649 676
 
650
-   Default value is "" (only 200 OK is accepted).
677
+   Default value is “” (only 200 OK is accepted).
651 678
 
652
-   Example 1.25. Set the "ds_ping_reply_codes" parameter
679
+   Example 1.26. Set the “ds_ping_reply_codes” parameter
653 680
  ...
654
- modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=403;code=488;class=
655
-3")
681
+ modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=403;code=488;class
682
+=3")
656 683
  ...
657 684
 
658
-3.25. ds_probing_mode (int)
685
+3.26. ds_probing_mode (int)
659 686
 
660 687
    Controls what gateways are tested to see if they are reachable. If set
661 688
    to 0, only the gateways with state PROBING are tested; if set to 1, all
... ...
@@ -663,76 +690,76 @@ Note
663 690
    probing mode set are tested. If set to 1 and there is a failure of
664 691
    keepalive to an active gateway, then it is set to TRYING state.
665 692
 
666
-   Default value is "0".
693
+   Default value is “0”.
667 694
 
668
-   Example 1.26. Set the "ds_probing_mode" parameter
695
+   Example 1.27. Set the “ds_probing_mode” parameter
669 696
  ...
670 697
  modparam("dispatcher", "ds_probing_mode", 1)
671 698
  ...
672 699
 
673
-3.26. ds_hash_size (int)
700
+3.27. ds_hash_size (int)
674 701
 
675 702
    The value to be used as power of two to set the number of slots to hash
676 703
    table storing data for call load dispatching (e.g., value 8 will create
677 704
    a hash table with 256 slots). It must be greater than 0 to enable call
678 705
    load dispatching feature (alg 10).
679 706
 
680
-   Default value is "0".
707
+   Default value is “0”.
681 708
 
682
-   Example 1.27. Set the "ds_hash_size" parameter
709
+   Example 1.28. Set the “ds_hash_size” parameter
683 710
  ...
684 711
  modparam("dispatcher", "ds_hash_size", 9)
685 712
  ...
686 713
 
687
-3.27. ds_hash_expire (int)
714
+3.28. ds_hash_expire (int)
688 715
 
689 716
    Expiration time in seconds to remove the load on a destination if no
690 717
    BYE was received meanwhile.
691 718
 
692
-   Default value is "7200".
719
+   Default value is “7200”.
693 720
 
694
-   Example 1.28. Set the "ds_hash_expire" parameter
721
+   Example 1.29. Set the “ds_hash_expire” parameter
695 722
  ...
696 723
  modparam("dispatcher", "ds_hash_expire", 3600)
697 724
  ...
698 725
 
699
-3.28. ds_hash_initexpire (int)
726
+3.29. ds_hash_initexpire (int)
700 727
 
701 728
    Expiration time in seconds to remove the load on a destination if no
702 729
    200 for INVITE was received meanwhile and state updated with
703 730
    ds_load_update().
704 731
 
705
-   Default value is "7200".
732
+   Default value is “7200”.
706 733
 
707
-   Example 1.29. Set the "ds_hash_initexpire" parameter
734
+   Example 1.30. Set the “ds_hash_initexpire” parameter
708 735
  ...
709 736
  modparam("dispatcher", "ds_hash_initexpire", 60)
710 737
  ...
711 738
 
712
-3.29. ds_hash_check_interval (int)
739
+3.30. ds_hash_check_interval (int)
713 740
 
714 741
    Time interval in seconds to scan internal hash table with call load
715 742
    dispatching data for expired items.
716 743
 
717
-   Default value is "30".
744
+   Default value is “30”.
718 745
 
719
-   Example 1.30. Set the "ds_hash_check_interval" parameter
746
+   Example 1.31. Set the “ds_hash_check_interval” parameter
720 747
  ...
721 748
  modparam("dispatcher", "ds_hash_check_interval", 60)
722 749
  ...
723 750
 
724
-3.30. outbound_proxy (str)
751
+3.31. outbound_proxy (str)
725 752
 
726 753
    SIP URI of outbound proxy to be used when sending pings.
727 754
 
728 755
    By default no outbound proxy is defined.
729 756
 
730
-   Example 1.31. Set the "outbound_proxy" parameter
757
+   Example 1.32. Set the “outbound_proxy” parameter
731 758
  ...
732 759
  modparam("dispatcher", "outbound_proxy", "sip:outbound.example.com")
733 760
  ...
734 761
 
735
-3.31. ds_default_socket (str)
762
+3.32. ds_default_socket (str)
736 763
 
737 764
    Default socket to be used for sending pings and dispatching requests
738 765
    when a gateway has no send socket configured.
... ...
@@ -740,7 +767,7 @@ Note
740 767
    By default no default socket is defined, the first configuration script
741 768
    listen directive is used.
742 769
 
743
-   Example 1.32. Set the "ds_default_socket" parameter
770
+   Example 1.33. Set the “ds_default_socket” parameter
744 771
  ...
745 772
  modparam("dispatcher", "ds_default_socket", "udp:192.168.0.125:5060")
746 773
  ...
... ...
@@ -757,7 +784,7 @@ Note
757 784
    4.8. ds_load_update()
758 785
    4.9. ds_load_unset()
759 786
 
760
-4.1. ds_select_dst(set, alg[, limit])
787
+4.1.  ds_select_dst(set, alg[, limit])
761 788
 
762 789
    The method selects a destination from addresses set. It returns true if
763 790
    a new destination is set. The selected address is set to dst_uri field
... ...
@@ -776,21 +803,21 @@ Note
776 803
        be an integer or a variable holding an integer.
777 804
      * alg - the algorithm used to select the destination address. The
778 805
        parameter can be an integer or a variable holding an interger.
779
-          + "0" - hash over callid
780
-          + "1" - hash over from URI.
781
-          + "2" - hash over to URI.
782
-          + "3" - hash over request-URI.
783
-          + "4" - round-robin (next destination).
784
-          + "5" - hash over authorization-username (Proxy-Authorization or
806
+          + “0” - hash over callid
807
+          + “1” - hash over from URI.
808
+          + “2” - hash over to URI.
809
+          + “3” - hash over request-URI.
810
+          + “4” - round-robin (next destination).
811
+          + “5” - hash over authorization-username (Proxy-Authorization or
785 812
             "normal" authorization). If no username is found, round robin
786 813
             is used.
787
-          + "6" - random (using rand()).
788
-          + "7" - hash over the content of PVs string. Note: This works
814
+          + “6” - random (using rand()).
815
+          + “7” - hash over the content of PVs string. Note: This works
789 816
             only when the parameter hash_pvar is set.
790
-          + "8" - use first destination (good for failover).
791
-          + "9" - use weight based load distribution. You have to set the
817
+          + “8” - use first destination (good for failover).
818
+          + “9” - use weight based load distribution. You have to set the
792 819
             attribute 'weight' per each address in destination set.
793
-          + "10" - use call load distribution. You have to set the
820
+          + “10” - use call load distribution. You have to set the
794 821
             attribute 'duid' (as an unique string id) per each address in
795 822
             destination set. Also, you must set parameters 'dstid_avp' and
796 823
             'ds_hash_size'.
... ...
@@ -805,7 +832,7 @@ Note
805 832
             on each address can change.
806 833
             This algorithm can be used only for dispatching INVITE
807 834
             requests as it is the only SIP method creating a SIP call.
808
-          + "X" - if the algorithm is not implemented, the first entry in
835
+          + “X” - if the algorithm is not implemented, the first entry in
809 836
             set is chosen.
810 837
      * limit - the maximum number of items to be stored in AVP list for
811 838
        further failovers (the first selected destination and default
... ...
@@ -818,7 +845,7 @@ Note
818 845
 
819 846
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
820 847
 
821
-   Example 1.33. ds_select_dst usage
848
+   Example 1.34. ds_select_dst usage
822 849
 ...
823 850
 ds_select_dst("1", "0");
824 851
 ...
... ...
@@ -828,7 +855,7 @@ ds_select_dst("1", "$var(a)");
828 855
 ds_select_dst("1", "4", "3");
829 856
 ...
830 857
 
831
-4.2. ds_select_domain(set, alg[, limit])
858
+4.2.  ds_select_domain(set, alg[, limit])
832 859
 
833 860
    The method selects a destination from addresses set and rewrites the
834 861
    host and port from R-URI. The parameters have same meaning as for
... ...
@@ -841,21 +868,21 @@ ds_select_dst("1", "4", "3");
841 868
 
842 869
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
843 870
 
844
-4.3. ds_next_dst()
871
+4.3.  ds_next_dst()
845 872
 
846 873
    Takes the next destination address from the AVPs with id 'dst_avp_id'
847 874
    and sets the dst_uri (outbound proxy address).
848 875
 
849 876
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
850 877
 
851
-4.4. ds_next_domain()
878
+4.4.  ds_next_domain()
852 879
 
853 880
    Takes the next destination address from the AVPs with id 'dst_avp_id'
854 881
    and sets the domain part of the request URI.
855 882
 
856 883
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
857 884
 
858
-4.5. ds_mark_dst([state])
885
+4.5.  ds_mark_dst([state])
859 886
 
860 887
    Mark the last used address from destination set as inactive ("i"/"I"),
861 888
    active ("a"/"A"), disabled ("d"/"D") or trying ("t"/"T"). Apart of
... ...
@@ -882,7 +909,7 @@ ds_select_dst("1", "4", "3");
882 909
 
883 910
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
884 911
 
885
-   Example 1.34. ds_mark_dst usage
912
+   Example 1.35. ds_mark_dst usage
886 913
 ...
887 914
 failure_route[tryagain] {
888 915
 ...
... ...
@@ -892,21 +919,21 @@ failure_route[tryagain] {
892 919
 }
893 920
 ...
894 921
 
895
-4.6. ds_list_exist(groupid)
922
+4.6.  ds_list_exist(groupid)
896 923
 
897 924
    Check if a specific group is defined in dispatcher list or database.
898 925
      * groupid - A group ID to check.
899 926
 
900 927
    This function can be used from ANY_ROUTE.
901 928
 
902
-   Example 1.35. ds_list_exist usage
929
+   Example 1.36. ds_list_exist usage
903 930
 ...
904 931
 if(ds_list_exist("10")) {
905 932
     ...
906 933
 }
907 934
 ...
908 935
 
909
-4.7. ds_is_from_list([groupid [, mode [, uri] ] ])
936
+4.7.  ds_is_from_list([groupid [, mode [, uri] ] ])
910 937
 
911 938
    This function returns true, if there is a match of source address or
912 939
    uri with an address in the given group of the dispatcher-list;
... ...
@@ -942,7 +969,7 @@ if(ds_list_exist("10")) {
942 969
 
943 970
    This function can be used from ANY_ROUTE.
944 971
 
945
-   Example 1.36. ds_mark_dst usage
972
+   Example 1.37. ds_mark_dst usage
946 973
 ...
947 974
 if(ds_is_from_list()) {
948 975
     ...
... ...
@@ -955,7 +982,7 @@ if(ds_is_from_list("10", "sip:127.0.0.1:5080", "3")) {
955 982
 }
956 983
 ...
957 984
 
958
-4.8. ds_load_update()
985
+4.8.  ds_load_update()
959 986
 
960 987
    Updates the load state:
961 988
      * if it is a BYE or CANCEL - remove the load from destination address
... ...
@@ -966,14 +993,14 @@ if(ds_is_from_list("10", "sip:127.0.0.1:5080", "3")) {
966 993
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
967 994
    BRANCH_ROUTE and ONREPLY_ROUTE.
968 995
 
969
-4.9. ds_load_unset()
996
+4.9.  ds_load_unset()
970 997
 
971 998
    Remove the call load for the destination that routed the call.
972 999
 
973 1000
    This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
974 1001
    BRANCH_ROUTE and ONREPLY_ROUTE.
975 1002
 
976
-   Example 1.37. ds_load_unset usage
1003
+   Example 1.38. ds_load_unset usage
977 1004
 ...
978 1005
 route {
979 1006
     ...
... ...
@@ -1003,7 +1030,7 @@ onreply_route {
1003 1030
    5.2. ds_list
1004 1031
    5.3. ds_reload
1005 1032
 
1006
-5.1. ds_set_state
1033
+5.1.  ds_set_state
1007 1034
 
1008 1035
    Sets the status for a destination address (can be use to mark the
1009 1036
    destination as active or inactive).
... ...
@@ -1012,11 +1039,11 @@ onreply_route {
1012 1039
 
1013 1040
    Parameters:
1014 1041
      * _state_ : state of the destination address
1015
-          + "a": active
1016
-          + "i": inactive
1017
-          + "t": trying
1018
-          + "d": disabled
1019
-       The states "a", "i" or "t" can be followed by "p" to set probing
1042
+          + “a”: active
1043
+          + “i”: inactive
1044
+          + “t”: trying
1045
+          + “d”: disabled
1046
+       The states “a”, “i” or “t” can be followed by “p” to set probing
1020 1047
        mode (e.g. 'ap', 'ip' or 'tp').
1021 1048
      * _group_: destination group id
1022 1049
      * _address_: address of the destination in the _group_
... ...
@@ -1028,7 +1055,7 @@ onreply_route {
1028 1055
                 _address_
1029 1056
                 _empty_line_
1030 1057
 
1031
-5.2. ds_list
1058
+5.2.  ds_list
1032 1059
 
1033 1060
    It lists the groups and included destinations.
1034 1061
 
... ...
@@ -1040,7 +1067,7 @@ onreply_route {
1040 1067
                 :ds_list:_reply_fifo_file_
1041 1068
                 _empty_line_
1042 1069
 
1043
-5.3. ds_reload
1070
+5.3.  ds_reload
1044 1071
 
1045 1072
    It reloads the groups and included destinations. For algorithm 10 (call
1046 1073
    load distribution), old internal list of active calls is destroyed
... ...
@@ -1060,7 +1087,7 @@ onreply_route {
1060 1087
    6.2. dispatcher.list
1061 1088
    6.3. dispatcher.reload
1062 1089
 
1063
-6.1. dispatcher.set_state
1090
+6.1.  dispatcher.set_state
1064 1091
 
1065 1092
    Sets the state for a destination address (can be use to mark the
1066 1093
    destination as active or inactive).
... ...
@@ -1069,11 +1096,11 @@ onreply_route {
1069 1096
 
1070 1097
    Parameters:
1071 1098
      * _state_ : state of the destination address
1072
-          + "a": active
1073
-          + "i": inactive
1074
-          + "t": trying
1075
-          + "d": disabled
1076
-       The states "a", "i" or "t" can be followed by "p" to set probing
1099
+          + “a”: active
1100
+          + “i”: inactive
1101
+          + “t”: trying
1102
+          + “d”: disabled
1103
+       The states “a”, “i” or “t” can be followed by “p” to set probing
1077 1104
        mode (e.g. 'ap', 'ip' or 'tp').
1078 1105
      * _group_: destination group id
1079 1106
      * _address_: address of the destination in the _group_
... ...
@@ -1084,7 +1111,7 @@ onreply_route {
1084 1111
 kamcmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
1085 1112
 ...
1086 1113
 
1087
-6.2. dispatcher.list
1114
+6.2.  dispatcher.list
1088 1115
 
1089 1116
    Lists the groups and included destinations.
1090 1117
 
... ...
@@ -1095,7 +1122,7 @@ kamcmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
1095 1122
    Example:
1096 1123
                 kamcmd dispatcher.list
1097 1124
 
1098
-6.3. dispatcher.reload
1125
+6.3.  dispatcher.reload
1099 1126
 
1100 1127
    Reloads the groups and included destinations. The command is disabled
1101 1128
    for call load based dispatching (algorithm 10) since removal of
... ...
@@ -1166,15 +1193,15 @@ setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attrs(str,opt)
1166 1193
    For database, each element of a line resides in a different column.
1167 1194
    Next is a dispatcher.list file example:
1168 1195
 
1169
-   Example 1.38. dispatcher list file
1196
+   Example 1.39. dispatcher list file
1170 1197
 ...
1171 1198
 # $Id$
1172 1199
 # dispatcher destination sets
1173 1200
 #
1174 1201
 
1175 1202
 # line format
1176
-# setit(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(st
1177
-r,opt)
1203
+# setit(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(s
1204
+tr,opt)
1178 1205
 
1179 1206
 # proxies
1180 1207
 2 sip:127.0.0.1:5080
... ...
@@ -1191,7 +1218,7 @@ r,opt)
1191 1218
 
1192 1219
    Next picture shows a sample usage of the dispatcher module.
1193 1220
 
1194
-   Example 1.39. Kamailio config script - sample dispatcher usage
1221
+   Example 1.40. Kamailio config script - sample dispatcher usage
1195 1222
 ...
1196 1223
 #!KAMAILIO
1197 1224
 #
... ...
@@ -1297,8 +1324,8 @@ modparam("rr", "append_fromtag", 0)
1297 1324
 modparam("acc", "log_flag", 1)
1298 1325
 modparam("acc", "failed_transaction_flag", 3)
1299 1326
 modparam("acc", "log_extra",
1300
-        "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;s
1301
-rc_ip=$si")
1327
+        "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;
1328
+src_ip=$si")
1302 1329
 
1303 1330
 # ----- tm params -----
1304 1331
 modparam("tm", "fr_timer", 2000)
... ...
@@ -1408,13 +1435,13 @@ route[WITHINDLG] {
1408 1435
                         if ( is_method("ACK") ) {
1409 1436
                                 if ( t_check_trans() ) {
1410 1437
                                         # non loose-route, but stateful ACK;
1411
-                                        # must be ACK after a 487 or e.g. 404 fr
1412
-om upstream server
1438
+                                        # must be ACK after a 487 or e.g. 404 f
1439
+rom upstream server
1413 1440
                                         t_relay();
1414 1441
                                         exit;
1415 1442
                                 } else {
1416
-                                        # ACK without matching transaction ... i
1417
-gnore and discard.
1443
+                                        # ACK without matching transaction ...
1444
+ignore and discard.
1418 1445
                                         exit;
1419 1446
                                 }
1420 1447
                         }
... ...
@@ -1482,7 +1509,7 @@ failure_route[RTF_DISPATCH] {
1482 1509
    8.1. dispatcher:dst-down
1483 1510
    8.2. dispatcher:dst-up
1484 1511
 
1485
-8.1. dispatcher:dst-down
1512
+8.1.  dispatcher:dst-down
1486 1513
 
1487 1514
    When defined, the module calls event_route[dispatcher:ds-down] when a
1488 1515
    destination goes down (becomes probing). A typical use case is to
... ...
@@ -1493,7 +1520,7 @@ event_route[dispatcher:dst-down] {
1493 1520
 }
1494 1521
 ...
1495 1522
 
1496
-8.2. dispatcher:dst-up
1523
+8.2.  dispatcher:dst-up
1497 1524
 
1498 1525
    When defined, the module calls event_route[dispatcher:ds-up] when a
1499 1526
    destination that was previously down (probing) comes up. A typical use
... ...
@@ -31,15 +31,18 @@
31 31
 #include "config.h"
32 32
 
33 33
 struct cfg_group_dispatcher	default_dispatcher_cfg = {
34
-		3,	/* Probing threshhold */	
34
+		1,	/* Probing threshold */	
35
+		1,      /* Inactive threshold */
35 36
 		{0,0}	/* reply codes */
36 37
 	    };
37 38
 
38 39
 void	*dispatcher_cfg = &default_dispatcher_cfg;
39 40
 
40 41
 cfg_def_t	dispatcher_cfg_def[] = {
41
-	{"probing_threshhold",		CFG_VAR_INT | CFG_ATOMIC, 	0, 0, 0, 0,
42
+	{"probing_threshold",		CFG_VAR_INT | CFG_ATOMIC, 	0, 0, 0, 0,
42 43
 		"Number of failed requests, before a destination is set to probing."},
44
+	{"inactive_threshold",           CFG_VAR_INT | CFG_ATOMIC,       0, 0, 0, 0,
45
+                "Number of successful requests, before a destination is set to active."},
43 46
 	{"ping_reply_codes",		CFG_VAR_STR | CFG_CB_ONLY_ONCE ,			0, 0, 0, ds_ping_reply_codes_update,
44 47
 		"Additional, valid reply codes for the OPTIONS Pinger. Default is \"\""},
45 48
 	{0, 0, 0, 0, 0, 0}
... ...
@@ -27,7 +27,8 @@
27 27
 #include "../../str.h"
28 28
 
29 29
 struct cfg_group_dispatcher {
30
-	int probing_threshhold;
30
+	int probing_threshold;
31
+	int inactive_threshold;
31 32
 	str ds_ping_reply_codes_str;
32 33
 };
33 34
 
... ...
@@ -38,6 +38,8 @@
38 38
  * 2007-07-18  removed index stuff
39 39
  * 			   added DB support to load/reload data(ancuta)
40 40
  * 2007-09-17  added list-file support for reload data (carstenbock)
41
+ * 2014-12-23  Corrected misspelled words in some variables' name (alezzandro)
42
+ * 2014-12-23  Added support for custom number of successful probing requests before moving a destination from 'inactive' to 'active' state (alezzandro)
41 43
  */
42 44
 
43 45
 /*! \file
... ...
@@ -2187,12 +2189,49 @@ int ds_mark_dst(struct sip_msg *msg, int state)
2187 2189
 }
2188 2190
 
2189 2191
 /**
2190
- *
2192
+ * Get state for given destination
2193
+ */
2194
+int ds_get_state(int group, str *address)
2195
+{
2196
+	int i=0;
2197
+	int state = 0;
2198
+	ds_set_t *idx = NULL;
2199
+
2200
+	if(_ds_list==NULL || _ds_list_nr<=0)
2201
+	{
2202
+		LM_ERR("the list is null\n");
2203
+		return -1;
2204
+	}
2205
+
2206
+	/* get the index of the set */
2207
+	if(ds_get_index(group, &idx)!=0)
2208
+	{
2209
+		LM_ERR("destination set [%d] not found\n", group);
2210
+		return -1;
2211
+	}
2212
+
2213
+	while(i<idx->nr)
2214
+	{
2215
+		if(idx->dlist[i].uri.len==address->len
2216
+				&& strncasecmp(idx->dlist[i].uri.s, address->s,
2217
+					address->len)==0)
2218
+		{
2219
+			/* destination address found */
2220
+			state = idx->dlist[i].flags;
2221
+		}
2222
+		i++;
2223
+	}
2224
+	return state;
2225
+}
2226
+
2227
+/**
2228
+ * Update destionation's state
2191 2229
  */
2192 2230
 int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2193 2231
 {
2194 2232
 	int i=0;
2195 2233
 	int old_state = 0;
2234
+	int init_state = 0;
2196 2235
 	ds_set_t *idx = NULL;
2197 2236
 
2198 2237
 	if(_ds_list==NULL || _ds_list_nr<=0)
... ...
@@ -2219,7 +2258,10 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2219 2258
 
2220 2259
 			/* reset the bits used for states */
2221 2260
 			idx->dlist[i].flags &= ~(DS_STATES_ALL);
2222
-
2261
+			
2262
+			/* we need the initial state for inactive counter */
2263
+			init_state = state;
2264
+			
2223 2265
 			if((state & DS_TRYING_DST) && (old_state & DS_INACTIVE_DST))
2224 2266
 			{
2225 2267
 				/* old state is inactive, new state is trying => keep it inactive
... ...
@@ -2235,18 +2277,33 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state)
2235 2277
 			} else {
2236 2278
 				idx->dlist[i].flags |= state;
2237 2279
 			}
2238
-
2280
+			
2239 2281
 			if(state & DS_TRYING_DST)
2240 2282
 			{
2241
-				idx->dlist[i].failure_count++;
2242
-				if (idx->dlist[i].failure_count >= probing_threshhold)
2283
+				idx->dlist[i].message_count++;
2284
+				/* Destination is not replying.. Increasing failure counter */
2285
+				if (idx->dlist[i].message_count >= probing_threshold)
2243 2286
 				{
2287
+					/* Destionation has too much lost messages.. Bringing it to inactive state */
2244 2288
 					idx->dlist[i].flags &= ~DS_TRYING_DST;
2245 2289
 					idx->dlist[i].flags |= DS_INACTIVE_DST;
2246
-					idx->dlist[i].failure_count = 0;
2290
+					idx->dlist[i].message_count = 0;
2247 2291
 				}
2248 2292
 			} else {
2249
-				idx->dlist[i].failure_count = 0;
2293
+				if(!(init_state & DS_TRYING_DST) && (old_state & DS_INACTIVE_DST)){
2294
+					idx->dlist[i].message_count++;
2295
+					/* Destination was inactive but it is just replying.. Increasing successful counter */
2296
+					if (idx->dlist[i].message_count < inactive_threshold)
2297
+					{
2298
+						/* Destination has not enough successful replies.. Leaving it into inactive state */
2299
+						idx->dlist[i].flags |= DS_INACTIVE_DST;
2300
+					}else{
2301
+						/* Destination has enough replied messages.. Bringing it to active state */
2302
+						idx->dlist[i].message_count = 0;
2303
+					}
2304
+				}else{ 
2305
+					idx->dlist[i].message_count = 0;
2306
+				}
2250 2307
 			}
2251 2308
 
2252 2309
 			if (!ds_skip_dst(old_state) && ds_skip_dst(idx->dlist[i].flags))
... ...
@@ -2375,10 +2432,10 @@ int ds_print_list(FILE *fout)
2375 2432
 			else if (list->dlist[j].flags&DS_TRYING_DST) {
2376 2433
 				fprintf(fout, "    Trying");
2377 2434
 				/* print the tries for this host. */
2378
-				if (list->dlist[j].failure_count > 0) {
2435
+				if (list->dlist[j].message_count > 0) {
2379 2436
 					fprintf(fout, " (Fail %d/%d)",
2380
-							list->dlist[j].failure_count,
2381
-							probing_threshhold);
2437
+							list->dlist[j].message_count,
2438
+							probing_threshold);
2382 2439
 				} else {
2383 2440
 					fprintf(fout, "           ");
2384 2441
 				}
... ...
@@ -2607,7 +2664,8 @@ static void ds_options_callback( struct cell *t, int type,
2607 2664
 		state = 0;
2608 2665
 		if (ds_probing_mode==DS_PROBE_ALL)
2609 2666
 			state |= DS_PROBING_DST;
2610
-		if (ds_update_state(fmsg, group, &uri, state) != 0)
2667
+		/* Check if in the meantime someone disabled the target through RPC or MI */
2668
+		if (!(ds_get_state(group, &uri) & DS_DISABLED_DST) && ds_update_state(fmsg, group, &uri, state) != 0)
2611 2669
 		{
2612 2670
 			LM_ERR("Setting the state failed (%.*s, group %d)\n", uri.len,
2613 2671
 					uri.s, group);
... ...
@@ -2616,8 +2674,8 @@ static void ds_options_callback( struct cell *t, int type,
2616 2674
 		state = DS_TRYING_DST;
2617 2675
 		if (ds_probing_mode!=DS_PROBE_NONE)
2618 2676
 			state |= DS_PROBING_DST;
2619
-
2620
-		if (ds_update_state(fmsg, group, &uri, state) != 0)
2677
+		/* Check if in the meantime someone disabled the target through RPC or MI */
2678
+		if (!(ds_get_state(group, &uri) & DS_DISABLED_DST) && ds_update_state(fmsg, group, &uri, state) != 0)
2621 2679
 		{
2622 2680
 			LM_ERR("Setting the probing state failed (%.*s, group %d)\n",
2623 2681
 					uri.len, uri.s, group);
... ...
@@ -30,6 +30,8 @@
30 30
  *		re-enabling of destinations
31 31
  * 2007-05-08  Ported the changes to SVN-Trunk and renamed ds_is_domain
32 32
  *		to ds_is_from_list.
33
+ * 2014-12-23  Corrected misspelled words in some variables' name (alezzandro) 
34
+ * 2014-12-23  Added support for custom number of successful probing requests before moving a destination from 'inactive' to 'active' state (alezzandro)
33 35
  */
34 36
 
35 37
 /*! \file
... ...
@@ -100,8 +102,10 @@ extern pv_spec_t ds_attrs_pv;
100 102
 extern struct tm_binds tmb;
101 103
 extern str ds_ping_method;
102 104
 extern str ds_ping_from;
103
-extern int probing_threshhold; /*!< number of failed requests,
104
-								 before a destination is taken into probing */ 
105
+extern int probing_threshold; /*!< number of failed requests,
106
+								before a destination is taken into probing */
107
+extern int inactive_threshold; /*!< number of successful requests, 
108
+								before a destination is taken into active */
105 109
 extern int ds_probing_mode;
106 110
 extern str ds_outbound_proxy;
107 111
 extern str ds_default_socket;
... ...
@@ -172,7 +176,7 @@ typedef struct _ds_dest
172 176
 	struct ip_addr ip_address; 	/*!< IP-Address of the entry */
173 177
 	unsigned short int port; 	/*!< Port of the URI */
174 178
 	unsigned short int proto; 	/*!< Protocol of the URI */
175
-	int failure_count;
179
+	int message_count;
176 180
 	struct _ds_dest *next;
177 181
 } ds_dest_t;
178 182
 
... ...
@@ -34,6 +34,8 @@
34 34
  * 2007-07-18  Added support for load/reload groups from DB 
35 35
  * 			   reload triggered from ds_reload MI_Command (ancuta)
36 36
  * 2014-12-12  Added "ds_list_exist" function
37
+ * 2014-12-23  Corrected misspelled words in some variables' name (alezzandro)
38
+ * 2014-12-23  Added support for custom number of successful probing requests before moving a destination from 'inactive' to 'active' state (alezzandro)
37 39
  */
38 40
 
39 41
 /*! \file
... ...
@@ -108,7 +110,7 @@ unsigned short sock_avp_type;
108 110
 
109 111
 pv_elem_t * hash_param_model = NULL;
110 112
 
111
-int probing_threshhold = 1; /* number of failed requests, before a destination
113
+int probing_threshold = 1; /* number of failed requests, before a destination
112 114
 							   is taken into probing */
113 115
 str ds_ping_method = str_init("OPTIONS");
114 116
 str ds_ping_from   = str_init("sip:dispatcher@localhost");
... ...
@@ -240,7 +242,7 @@ static param_export_t params[]={
240 242
 	{"hash_pvar",       PARAM_STR, &hash_pvar_param},
241 243
 	{"setid_pvname",    PARAM_STR, &ds_setid_pvname},
242 244
 	{"attrs_pvname",    PARAM_STR, &ds_attrs_pvname},
243
-	{"ds_probing_threshhold", INT_PARAM, &probing_threshhold},
245
+	{"ds_probing_threshold", INT_PARAM, &probing_threshold},
244 246
 	{"ds_ping_method",     PARAM_STR, &ds_ping_method},
245 247
 	{"ds_ping_from",       PARAM_STR, &ds_ping_from},
246 248
 	{"ds_ping_interval",   INT_PARAM, &ds_ping_interval},
... ...
@@ -321,8 +323,8 @@ static int mod_init(void)
321 323
 		}
322 324
 	}	
323 325
 	/* Copy Threshhold to Config */
324
-	cfg_get(dispatcher, dispatcher_cfg, probing_threshhold)
325
-		= probing_threshhold;
326
+	cfg_get(dispatcher, dispatcher_cfg, probing_threshold)
327
+		= probing_threshold;
326 328
 
327 329
 
328 330
 	if(init_data()!= 0)
... ...
@@ -549,7 +551,7 @@ static int mod_init(void)
549 551
 }
550 552
 
551 553
 /*! \brief
552
- * Initialize childreng
554
+ * Initialize children
553 555
  */
554 556
 static int child_init(int rank)
555 557
 {
... ...
@@ -39,6 +39,14 @@
39 39
                 <email>oej@edvina.net</email>
40 40
                 </address>
41 41
             </editor>
42
+            <editor>
43
+                <firstname>Alessandro</firstname>
44
+                <surname>Arrichiello</surname>
45
+                <affiliation><orgname>Hewlett Packard</orgname></affiliation>
46
+                <address>
47
+                <email>alezzandro@gmail.com</email>
48
+                </address>
49
+            </editor>
42 50
 	</authorgroup>
43 51
 	<copyright>
44 52
 	    <year>2004</year>
... ...
@@ -56,6 +64,10 @@
56 64
 	    <year>2014</year>
57 65
 	    <holder>Olle E. Johansson, Edvina AB</holder>
58 66
 	</copyright>
67
+	<copyright>
68
+            <year>2015</year>
69
+            <holder>Alessandro Arrichiello, Hewlett Packard</holder>
70
+        </copyright>
59 71
    </bookinfo>
60 72
     <toc></toc>
61 73
     
... ...
@@ -598,14 +598,36 @@ modparam("dispatcher", "force_dst", 1)
598 598
  		</emphasis>
599 599
  		</para>
600 600
  		<example>
601
- 		<title>Set the <quote>ds_probing_threshhold</quote> parameter</title>
601
+ 		<title>Set the <quote>ds_probing_threshold</quote> parameter</title>
602 602
  <programlisting format="linespecific">
603 603
  ...
604
- modparam("dispatcher", "ds_probing_threshhold", 10)
604
+ modparam("dispatcher", "ds_probing_threshold", 10)
605 605
  ...
606 606
  </programlisting>
607 607
  		</example>
608 608
 	</section>
609
+	<section id="dispatcher.p.ds_inactive_threshold">
610
+                <title><varname>ds_inactive_threshold</varname> (int)</title>
611
+                <para>
612
+                If you want to set a gateway into active mode (after being inactive), there can be
613
+                a specific number of successful requests until it will change from "inactive"
614
+                to "active". The number of attempts can be set with this parameter.
615
+                This parameter can be modified via ser config framework.
616
+                </para>
617
+                <para>
618
+                <emphasis>
619
+                Default value is <quote>1</quote> (set active with first success).
620
+                </emphasis>
621
+                </para>
622
+                <example>
623
+                <title>Set the <quote>ds_inactive_threshold</quote> parameter</title>
624
+ <programlisting format="linespecific">
625
+ ...
626
+ modparam("dispatcher", "ds_inactive_threshold", 10)
627
+ ...
628
+ </programlisting>
629
+                </example>
630
+        </section>
609 631
  	<section id="dispatcher.p.ds_ping_reply_codes">
610 632
  		<title><varname>ds_ping_reply_codes</varname> (string)</title>
611 633
  		<para>