|
@@ -12,62 +12,67 @@ Juha Heinanen
|
|
|
|
|
|
Copyright © 2005-2008 Juha Heinanen
|
|
|
Revision History
|
|
|
- Revision $Revision$ $Date: 2008-10-16 19:58:34 +0300
|
|
|
- (Thu, 16 Oct 2008) $
|
|
|
- __________________________________________________________
|
|
|
+ Revision $Revision$ $Date$
|
|
|
+ __________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
|
|
|
|
1. Admin Guide
|
|
|
|
|
|
- 1.1. Overview
|
|
|
- 1.2. Dependencies
|
|
|
-
|
|
|
- 1.2.1. Kamailio modules
|
|
|
- 1.2.2. External libraries or applications
|
|
|
-
|
|
|
- 1.3. Exported Parameters
|
|
|
-
|
|
|
- 1.3.1. db_url (string)
|
|
|
- 1.3.2. gw_table (string)
|
|
|
- 1.3.3. gw_name_column (string)
|
|
|
- 1.3.4. grp_id_column (string)
|
|
|
- 1.3.5. ip_addr_column (string)
|
|
|
- 1.3.6. hostname_column (string)
|
|
|
- 1.3.7. port_column (string)
|
|
|
- 1.3.8. uri_scheme_column (string)
|
|
|
- 1.3.9. transport_column (string)
|
|
|
- 1.3.10. strip_column (string)
|
|
|
- 1.3.11. tag_column (string)
|
|
|
- 1.3.12. weight_column (string)
|
|
|
- 1.3.13. flags_column (string)
|
|
|
- 1.3.14. lcr_table (string)
|
|
|
- 1.3.15. prefix_column (string)
|
|
|
- 1.3.16. from_uri_column (string)
|
|
|
- 1.3.17. priority_column (string)
|
|
|
- 1.3.18. gw_uri_avp (AVP string)
|
|
|
- 1.3.19. rpid_avp (AVP string)
|
|
|
- 1.3.20. ruri_user_avp (AVP string)
|
|
|
- 1.3.21. flags_avp (AVP string)
|
|
|
- 1.3.22. lcr_hash_size (integer)
|
|
|
- 1.3.23. fetch_rows (integer)
|
|
|
-
|
|
|
- 1.4. Exported Functions
|
|
|
-
|
|
|
- 1.4.1. load_gws([pvar])
|
|
|
- 1.4.2. load_gws_from_grp(group-id)
|
|
|
- 1.4.3. next_gw()
|
|
|
- 1.4.4. from_gw([pvar])
|
|
|
- 1.4.5. from_gw_grp(group-id)
|
|
|
- 1.4.6. to_gw([group-id])
|
|
|
-
|
|
|
- 1.5. Exported MI Commands
|
|
|
-
|
|
|
- 1.5.1. lcr_reload
|
|
|
- 1.5.2. lcr_gw_dump
|
|
|
- 1.5.3. lcr_lcr_dump
|
|
|
-
|
|
|
- 1.6. Known Limitations
|
|
|
+ 1. Overview
|
|
|
+ 2. Dependencies
|
|
|
+
|
|
|
+ 2.1. Kamailio modules
|
|
|
+ 2.2. External libraries or applications
|
|
|
+
|
|
|
+ 3. Exported Parameters
|
|
|
+
|
|
|
+ 3.1. db_url (string)
|
|
|
+ 3.2. gw_table (string)
|
|
|
+ 3.3. gw_name_column (string)
|
|
|
+ 3.4. grp_id_column (string)
|
|
|
+ 3.5. ip_addr_column (string)
|
|
|
+ 3.6. hostname_column (string)
|
|
|
+ 3.7. port_column (string)
|
|
|
+ 3.8. uri_scheme_column (string)
|
|
|
+ 3.9. transport_column (string)
|
|
|
+ 3.10. strip_column (string)
|
|
|
+ 3.11. tag_column (string)
|
|
|
+ 3.12. weight_column (string)
|
|
|
+ 3.13. flags_column (string)
|
|
|
+ 3.14. lcr_table (string)
|
|
|
+ 3.15. prefix_column (string)
|
|
|
+ 3.16. from_uri_column (string)
|
|
|
+ 3.17. priority_column (string)
|
|
|
+ 3.18. gw_uri_avp (AVP string)
|
|
|
+ 3.19. rpid_avp (AVP string)
|
|
|
+ 3.20. ruri_user_avp (AVP string)
|
|
|
+ 3.21. flags_avp (AVP string)
|
|
|
+ 3.22. lcr_hash_size (integer)
|
|
|
+ 3.23. fetch_rows (integer)
|
|
|
+
|
|
|
+ 4. Exported Functions
|
|
|
+
|
|
|
+ 4.1. load_gws([pvar])
|
|
|
+ 4.2. load_gws_from_grp(group-id)
|
|
|
+ 4.3. next_gw()
|
|
|
+ 4.4. from_gw([pvar])
|
|
|
+ 4.5. from_gw_grp(group-id)
|
|
|
+ 4.6. to_gw([group-id])
|
|
|
+
|
|
|
+ 5. Exported MI Commands
|
|
|
+
|
|
|
+ 5.1. lcr_reload
|
|
|
+ 5.2. lcr_gw_dump
|
|
|
+ 5.3. lcr_lcr_dump
|
|
|
+
|
|
|
+ 6. Exported RPC Commands
|
|
|
+
|
|
|
+ 6.1. lcr.reload
|
|
|
+ 6.2. lcr.dump_gws
|
|
|
+ 6.3. lcr.dump_lcr
|
|
|
+
|
|
|
+ 7. Known Limitations
|
|
|
|
|
|
List of Examples
|
|
|
|
|
@@ -103,83 +108,165 @@ Juha Heinanen
|
|
|
1.30. from_gw_grp usage
|
|
|
1.31. to_gw usage
|
|
|
1.32. to_gw usage with group-id
|
|
|
+ 1.33. lcr.reload RPC example
|
|
|
+ 1.34. lcr.dump_gws RPC example
|
|
|
+ 1.35. lcr.dump_lcr RPC example
|
|
|
|
|
|
Chapter 1. Admin Guide
|
|
|
|
|
|
-1.1. Overview
|
|
|
-
|
|
|
- Least cost routing (LCR) module implements capability to
|
|
|
- serially forward a request to one or more gateways so that the
|
|
|
- order in which the gateways is tried is based on admin defined
|
|
|
- "least cost".
|
|
|
-
|
|
|
- For the purpose of facilitating least cost routing of requests,
|
|
|
- each gateway belongs to a gateway group and each gateway group
|
|
|
- is associated with one or more <prefix, from pattern, priority>
|
|
|
- tuples. A gateway matches a request if user part of Request URI
|
|
|
- matches a prefix and caller's URI matches a from pattern in a
|
|
|
- tuple that belongs to the group of the gateway.
|
|
|
-
|
|
|
- When function load_gws() is called, matching gateways are
|
|
|
- ordered for forwarding purpose (1) according to longest user
|
|
|
- part match, (2) according to tuple's priority, and (3)
|
|
|
- gateway's randomized weight within its group. Prefix is a
|
|
|
- string of characters or NULL. From pattern is a regular
|
|
|
- expression (see 'man pcresyntax' for syntax), an empty string,
|
|
|
- or NULL. Empty or NULL from pattern or prefix matches anything.
|
|
|
- Smaller priority value means higher priority (highest priority
|
|
|
- value being 0). Weight is an integer value from 1 to 254.
|
|
|
-
|
|
|
- Function next_gw() can then be used to select one gateway at a
|
|
|
- time for forwarding. Upon each call, user part of original
|
|
|
- Request URI is first stripped by the number of characters as
|
|
|
- specified by the gateway's strip count and then prefixed by
|
|
|
- gateway's tag. Upon first call, if gateway's hostname is NULL,
|
|
|
- Request URI is rewritten based on gateway's URI scheme, IP
|
|
|
- address, port, and transport protocol. If hostname is not NULL,
|
|
|
- Request-URI is rewritten based on gateway's URI scheme and
|
|
|
- hostname, and destination URI is set based on gateway's URI
|
|
|
- scheme, IP address, port, and transport protocol. Upon
|
|
|
- subsequent calls, the same is done, but instead of rewriting
|
|
|
- Request URI, a new branch is added.
|
|
|
-
|
|
|
- Valid URI scheme values are NULL = sip, 1 = sip and 2 = sips.
|
|
|
- Currently valid transport protocol values are NULL = none, 1 =
|
|
|
- udp, 2 = tcp, 3 = tls, and 4 = sctp.
|
|
|
-
|
|
|
- As a side effect of gateway selection, gateway's flags (that
|
|
|
- may contain information about capabilities of the gateway) are
|
|
|
- stored into an AVP.
|
|
|
-
|
|
|
-1.2. Dependencies
|
|
|
-
|
|
|
-1.2.1. Kamailio modules
|
|
|
+ Table of Contents
|
|
|
+
|
|
|
+ 1. Overview
|
|
|
+ 2. Dependencies
|
|
|
+
|
|
|
+ 2.1. Kamailio modules
|
|
|
+ 2.2. External libraries or applications
|
|
|
+
|
|
|
+ 3. Exported Parameters
|
|
|
+
|
|
|
+ 3.1. db_url (string)
|
|
|
+ 3.2. gw_table (string)
|
|
|
+ 3.3. gw_name_column (string)
|
|
|
+ 3.4. grp_id_column (string)
|
|
|
+ 3.5. ip_addr_column (string)
|
|
|
+ 3.6. hostname_column (string)
|
|
|
+ 3.7. port_column (string)
|
|
|
+ 3.8. uri_scheme_column (string)
|
|
|
+ 3.9. transport_column (string)
|
|
|
+ 3.10. strip_column (string)
|
|
|
+ 3.11. tag_column (string)
|
|
|
+ 3.12. weight_column (string)
|
|
|
+ 3.13. flags_column (string)
|
|
|
+ 3.14. lcr_table (string)
|
|
|
+ 3.15. prefix_column (string)
|
|
|
+ 3.16. from_uri_column (string)
|
|
|
+ 3.17. priority_column (string)
|
|
|
+ 3.18. gw_uri_avp (AVP string)
|
|
|
+ 3.19. rpid_avp (AVP string)
|
|
|
+ 3.20. ruri_user_avp (AVP string)
|
|
|
+ 3.21. flags_avp (AVP string)
|
|
|
+ 3.22. lcr_hash_size (integer)
|
|
|
+ 3.23. fetch_rows (integer)
|
|
|
+
|
|
|
+ 4. Exported Functions
|
|
|
+
|
|
|
+ 4.1. load_gws([pvar])
|
|
|
+ 4.2. load_gws_from_grp(group-id)
|
|
|
+ 4.3. next_gw()
|
|
|
+ 4.4. from_gw([pvar])
|
|
|
+ 4.5. from_gw_grp(group-id)
|
|
|
+ 4.6. to_gw([group-id])
|
|
|
+
|
|
|
+ 5. Exported MI Commands
|
|
|
+
|
|
|
+ 5.1. lcr_reload
|
|
|
+ 5.2. lcr_gw_dump
|
|
|
+ 5.3. lcr_lcr_dump
|
|
|
+
|
|
|
+ 6. Exported RPC Commands
|
|
|
+
|
|
|
+ 6.1. lcr.reload
|
|
|
+ 6.2. lcr.dump_gws
|
|
|
+ 6.3. lcr.dump_lcr
|
|
|
+
|
|
|
+ 7. Known Limitations
|
|
|
+
|
|
|
+1. Overview
|
|
|
+
|
|
|
+ Least cost routing (LCR) module implements capability to serially
|
|
|
+ forward a request to one or more gateways so that the order in which
|
|
|
+ the gateways is tried is based on admin defined "least cost".
|
|
|
+
|
|
|
+ For the purpose of facilitating least cost routing of requests, each
|
|
|
+ gateway belongs to a gateway group and each gateway group is associated
|
|
|
+ with one or more <prefix, from pattern, priority> tuples. A gateway
|
|
|
+ matches a request if user part of Request URI matches a prefix and
|
|
|
+ caller's URI matches a from pattern in a tuple that belongs to the
|
|
|
+ group of the gateway.
|
|
|
+
|
|
|
+ When function load_gws() is called, matching gateways are ordered for
|
|
|
+ forwarding purpose (1) according to longest user part match, (2)
|
|
|
+ according to tuple's priority, and (3) gateway's randomized weight
|
|
|
+ within its group. Prefix is a string of characters or NULL. From
|
|
|
+ pattern is a regular expression (see 'man pcresyntax' for syntax), an
|
|
|
+ empty string, or NULL. Empty or NULL from pattern or prefix matches
|
|
|
+ anything. Smaller priority value means higher priority (highest
|
|
|
+ priority value being 0). Weight is an integer value from 1 to 254.
|
|
|
+
|
|
|
+ Function next_gw() can then be used to select one gateway at a time for
|
|
|
+ forwarding. Upon each call, user part of original Request URI is first
|
|
|
+ stripped by the number of characters as specified by the gateway's
|
|
|
+ strip count and then prefixed by gateway's tag. Upon first call, if
|
|
|
+ gateway's hostname is NULL, Request URI is rewritten based on gateway's
|
|
|
+ URI scheme, IP address, port, and transport protocol. If hostname is
|
|
|
+ not NULL, Request-URI is rewritten based on gateway's URI scheme and
|
|
|
+ hostname, and destination URI is set based on gateway's URI scheme, IP
|
|
|
+ address, port, and transport protocol. Upon subsequent calls, the same
|
|
|
+ is done, but instead of rewriting Request URI, a new branch is added.
|
|
|
+
|
|
|
+ Valid URI scheme values are NULL = sip, 1 = sip and 2 = sips. Currently
|
|
|
+ valid transport protocol values are NULL = none, 1 = udp, 2 = tcp, 3 =
|
|
|
+ tls, and 4 = sctp.
|
|
|
+
|
|
|
+ As a side effect of gateway selection, gateway's flags (that may
|
|
|
+ contain information about capabilities of the gateway) are stored into
|
|
|
+ an AVP.
|
|
|
+
|
|
|
+2. Dependencies
|
|
|
+
|
|
|
+ 2.1. Kamailio modules
|
|
|
+ 2.2. External libraries or applications
|
|
|
+
|
|
|
+2.1. Kamailio modules
|
|
|
|
|
|
The following modules must be loaded before this module:
|
|
|
* TM module
|
|
|
* A database module like mysql, postgres or dbtext.
|
|
|
|
|
|
-1.2.2. External libraries or applications
|
|
|
+2.2. External libraries or applications
|
|
|
|
|
|
- The following libraries or applications must be installed
|
|
|
- before running Kamailio with this module:
|
|
|
+ The following libraries or applications must be installed before
|
|
|
+ running Kamailio with this module:
|
|
|
* none.
|
|
|
|
|
|
-1.3. Exported Parameters
|
|
|
-
|
|
|
-1.3.1. db_url (string)
|
|
|
+3. Exported Parameters
|
|
|
+
|
|
|
+ 3.1. db_url (string)
|
|
|
+ 3.2. gw_table (string)
|
|
|
+ 3.3. gw_name_column (string)
|
|
|
+ 3.4. grp_id_column (string)
|
|
|
+ 3.5. ip_addr_column (string)
|
|
|
+ 3.6. hostname_column (string)
|
|
|
+ 3.7. port_column (string)
|
|
|
+ 3.8. uri_scheme_column (string)
|
|
|
+ 3.9. transport_column (string)
|
|
|
+ 3.10. strip_column (string)
|
|
|
+ 3.11. tag_column (string)
|
|
|
+ 3.12. weight_column (string)
|
|
|
+ 3.13. flags_column (string)
|
|
|
+ 3.14. lcr_table (string)
|
|
|
+ 3.15. prefix_column (string)
|
|
|
+ 3.16. from_uri_column (string)
|
|
|
+ 3.17. priority_column (string)
|
|
|
+ 3.18. gw_uri_avp (AVP string)
|
|
|
+ 3.19. rpid_avp (AVP string)
|
|
|
+ 3.20. ruri_user_avp (AVP string)
|
|
|
+ 3.21. flags_avp (AVP string)
|
|
|
+ 3.22. lcr_hash_size (integer)
|
|
|
+ 3.23. fetch_rows (integer)
|
|
|
+
|
|
|
+3.1. db_url (string)
|
|
|
|
|
|
URL of the database table to be used.
|
|
|
|
|
|
- Default value is
|
|
|
- "mysql://openserro:openserro@localhost/openser".
|
|
|
+ Default value is "mysql://openserro:openserro@localhost/openser".
|
|
|
|
|
|
Example 1.1. Setting db_url module parameter
|
|
|
...
|
|
|
modparam("lcr","db_url","dbdriver://username:password@dbhost/dbname")
|
|
|
...
|
|
|
|
|
|
-1.3.2. gw_table (string)
|
|
|
+3.2. gw_table (string)
|
|
|
|
|
|
Name of the table holding the gateways definitions.
|
|
|
|
|
@@ -190,7 +277,7 @@ modparam("lcr","db_url","dbdriver://username:password@dbhost/dbname")
|
|
|
modparam("lcr","gw_table","gw")
|
|
|
...
|
|
|
|
|
|
-1.3.3. gw_name_column (string)
|
|
|
+3.3. gw_name_column (string)
|
|
|
|
|
|
Name of the column holding the gateway name.
|
|
|
|
|
@@ -201,10 +288,10 @@ modparam("lcr","gw_table","gw")
|
|
|
modparam("lcr","gw_name_column","gw_name")
|
|
|
...
|
|
|
|
|
|
-1.3.4. grp_id_column (string)
|
|
|
+3.4. grp_id_column (string)
|
|
|
|
|
|
- Name of the column holding the group ID of gateway both in gw
|
|
|
- and lcr tables.
|
|
|
+ Name of the column holding the group ID of gateway both in gw and lcr
|
|
|
+ tables.
|
|
|
|
|
|
Default value is "grp_id".
|
|
|
|
|
@@ -213,7 +300,7 @@ modparam("lcr","gw_name_column","gw_name")
|
|
|
modparam("lcr","grp_id_column","grp_id")
|
|
|
...
|
|
|
|
|
|
-1.3.5. ip_addr_column (string)
|
|
|
+3.5. ip_addr_column (string)
|
|
|
|
|
|
Name of the column holding the IP address of the gateway.
|
|
|
|
|
@@ -224,12 +311,12 @@ modparam("lcr","grp_id_column","grp_id")
|
|
|
modparam("lcr","ip_addr_column","ip_addr")
|
|
|
...
|
|
|
|
|
|
-1.3.6. hostname_column (string)
|
|
|
+3.6. hostname_column (string)
|
|
|
|
|
|
Name of the column holding gateway's hostname that is used in
|
|
|
- Request-URI, when request is sent to the gateway. Note that
|
|
|
- request is not forwarded based on hostname, but based on
|
|
|
- gateway's IP address in destination uri.
|
|
|
+ Request-URI, when request is sent to the gateway. Note that request is
|
|
|
+ not forwarded based on hostname, but based on gateway's IP address in
|
|
|
+ destination uri.
|
|
|
|
|
|
Default value is "hostname".
|
|
|
|
|
@@ -238,7 +325,7 @@ modparam("lcr","ip_addr_column","ip_addr")
|
|
|
modparam("lcr", "hostname_column","host")
|
|
|
...
|
|
|
|
|
|
-1.3.7. port_column (string)
|
|
|
+3.7. port_column (string)
|
|
|
|
|
|
Name of the column holding the port number of the gateway.
|
|
|
|
|
@@ -249,7 +336,7 @@ modparam("lcr", "hostname_column","host")
|
|
|
modparam("lcr","port_column","port")
|
|
|
...
|
|
|
|
|
|
-1.3.8. uri_scheme_column (string)
|
|
|
+3.8. uri_scheme_column (string)
|
|
|
|
|
|
Name of the column holding the uri scheme of the gateway.
|
|
|
|
|
@@ -260,10 +347,10 @@ modparam("lcr","port_column","port")
|
|
|
modparam("lcr","uri_scheme_column","scheme")
|
|
|
...
|
|
|
|
|
|
-1.3.9. transport_column (string)
|
|
|
+3.9. transport_column (string)
|
|
|
|
|
|
- Name of the column holding the transport type to be used for
|
|
|
- the gateway.
|
|
|
+ Name of the column holding the transport type to be used for the
|
|
|
+ gateway.
|
|
|
|
|
|
Default value is "transport".
|
|
|
|
|
@@ -272,11 +359,10 @@ modparam("lcr","uri_scheme_column","scheme")
|
|
|
modparam("lcr","transport_column","transport")
|
|
|
...
|
|
|
|
|
|
-1.3.10. strip_column (string)
|
|
|
+3.10. strip_column (string)
|
|
|
|
|
|
- Name of the column holding the number of characters to be
|
|
|
- stripped from the front of Request URI user part before
|
|
|
- inserting tag.
|
|
|
+ Name of the column holding the number of characters to be stripped from
|
|
|
+ the front of Request URI user part before inserting tag.
|
|
|
|
|
|
Default value is "strip".
|
|
|
|
|
@@ -285,7 +371,7 @@ modparam("lcr","transport_column","transport")
|
|
|
modparam("lcr","strip_column","strip_count")
|
|
|
...
|
|
|
|
|
|
-1.3.11. tag_column (string)
|
|
|
+3.11. tag_column (string)
|
|
|
|
|
|
Name of the column holding gateway specific tag string.
|
|
|
|
|
@@ -296,7 +382,7 @@ modparam("lcr","strip_column","strip_count")
|
|
|
modparam("lcr","tag_column","gw_tag")
|
|
|
...
|
|
|
|
|
|
-1.3.12. weight_column (string)
|
|
|
+3.12. weight_column (string)
|
|
|
|
|
|
Name of the column holding gateway's weight within its group.
|
|
|
|
|
@@ -307,7 +393,7 @@ modparam("lcr","tag_column","gw_tag")
|
|
|
modparam("lcr","weight_column","gw_weight")
|
|
|
...
|
|
|
|
|
|
-1.3.13. flags_column (string)
|
|
|
+3.13. flags_column (string)
|
|
|
|
|
|
Name of the column holding gateway specific flag values.
|
|
|
|
|
@@ -318,7 +404,7 @@ modparam("lcr","weight_column","gw_weight")
|
|
|
modparam("lcr","flags_column","gw_flags")
|
|
|
...
|
|
|
|
|
|
-1.3.14. lcr_table (string)
|
|
|
+3.14. lcr_table (string)
|
|
|
|
|
|
Name of the table holding the LCR rules.
|
|
|
|
|
@@ -329,7 +415,7 @@ modparam("lcr","flags_column","gw_flags")
|
|
|
modparam("lcr","lcr_table","lcr")
|
|
|
...
|
|
|
|
|
|
-1.3.15. prefix_column (string)
|
|
|
+3.15. prefix_column (string)
|
|
|
|
|
|
Name of the column holding prefix of Request URI user part.
|
|
|
|
|
@@ -340,7 +426,7 @@ modparam("lcr","lcr_table","lcr")
|
|
|
modparam("lcr","prefix_column","prefix")
|
|
|
...
|
|
|
|
|
|
-1.3.16. from_uri_column (string)
|
|
|
+3.16. from_uri_column (string)
|
|
|
|
|
|
Name of the column holding the FROM (source) URI.
|
|
|
|
|
@@ -351,7 +437,7 @@ modparam("lcr","prefix_column","prefix")
|
|
|
modparam("lcr","from_uri_column","from_uri")
|
|
|
...
|
|
|
|
|
|
-1.3.17. priority_column (string)
|
|
|
+3.17. priority_column (string)
|
|
|
|
|
|
Name of the column holding the priority of the rule.
|
|
|
|
|
@@ -362,63 +448,63 @@ modparam("lcr","from_uri_column","from_uri")
|
|
|
modparam("lcr","priority_column","priority")
|
|
|
...
|
|
|
|
|
|
-1.3.18. gw_uri_avp (AVP string)
|
|
|
+3.18. gw_uri_avp (AVP string)
|
|
|
|
|
|
- Internal AVP that load_gws function uses to store information
|
|
|
- of matching gateways.
|
|
|
+ Internal AVP that load_gws function uses to store information of
|
|
|
+ matching gateways.
|
|
|
|
|
|
- There is NO default value, thus this variable must be defined
|
|
|
- in kamailio.cfg.
|
|
|
+ There is NO default value, thus this variable must be defined in
|
|
|
+ kamailio.cfg.
|
|
|
|
|
|
Example 1.18. Setting gw_uri_avp module parameter
|
|
|
...
|
|
|
modparam("lcr", "gw_uri_avp", "$avp(i:709)")
|
|
|
...
|
|
|
|
|
|
-1.3.19. rpid_avp (AVP string)
|
|
|
+3.19. rpid_avp (AVP string)
|
|
|
|
|
|
An AVP that contains caller's RPID (if any).
|
|
|
|
|
|
- There is NO default value, thus this variable must be defined
|
|
|
- in kamailio.cfg.
|
|
|
+ There is NO default value, thus this variable must be defined in
|
|
|
+ kamailio.cfg.
|
|
|
|
|
|
Example 1.19. Setting rpid_avp module parameter
|
|
|
...
|
|
|
modparam("^auth$|lcr", "rpid_avp", "$avp(i:302)")
|
|
|
...
|
|
|
|
|
|
-1.3.20. ruri_user_avp (AVP string)
|
|
|
+3.20. ruri_user_avp (AVP string)
|
|
|
|
|
|
- Internal AVP that next_gw function uses to store Request-URI
|
|
|
- user for subsequent next_gw calls.
|
|
|
+ Internal AVP that next_gw function uses to store Request-URI user for
|
|
|
+ subsequent next_gw calls.
|
|
|
|
|
|
- There is NO default value, thus this variable must be defined
|
|
|
- in kamailio.cfg.
|
|
|
+ There is NO default value, thus this variable must be defined in
|
|
|
+ kamailio.cfg.
|
|
|
|
|
|
Example 1.20. Setting ruri_user_avp module parameter
|
|
|
...
|
|
|
modparam("lcr", "ruri_user_avp", "$avp(i:500)")
|
|
|
...
|
|
|
|
|
|
-1.3.21. flags_avp (AVP string)
|
|
|
+3.21. flags_avp (AVP string)
|
|
|
|
|
|
- An AVP where successful next_gw and from_gw functions store
|
|
|
- gateway's flags.
|
|
|
+ An AVP where successful next_gw and from_gw functions store gateway's
|
|
|
+ flags.
|
|
|
|
|
|
- There is NO default value, thus this variable must be defined
|
|
|
- in kamailio.cfg.
|
|
|
+ There is NO default value, thus this variable must be defined in
|
|
|
+ kamailio.cfg.
|
|
|
|
|
|
Example 1.21. Setting flags_avp module parameter
|
|
|
...
|
|
|
modparam("lcr", "flags_avp", "$avp(i:712)")
|
|
|
...
|
|
|
|
|
|
-1.3.22. lcr_hash_size (integer)
|
|
|
+3.22. lcr_hash_size (integer)
|
|
|
|
|
|
- Defines the size of hash table used to store <prefix,
|
|
|
- from_pattern, priority> tuples. Hashing is done based on
|
|
|
- prefix. Larger value means less collisions with other prefixes.
|
|
|
- Hash size value should be a power of 2.
|
|
|
+ Defines the size of hash table used to store <prefix, from_pattern,
|
|
|
+ priority> tuples. Hashing is done based on prefix. Larger value means
|
|
|
+ less collisions with other prefixes. Hash size value should be a power
|
|
|
+ of 2.
|
|
|
|
|
|
Default value is 128.
|
|
|
|
|
@@ -427,13 +513,13 @@ modparam("lcr", "flags_avp", "$avp(i:712)")
|
|
|
modparam("lcr", "lcr_hash_size", 1024)
|
|
|
...
|
|
|
|
|
|
-1.3.23. fetch_rows (integer)
|
|
|
+3.23. fetch_rows (integer)
|
|
|
|
|
|
- The number of the rows to be fetched at once from database when
|
|
|
- loading data from lcr table. This value can be used to tune the
|
|
|
- load time at startup. For 1MB of private memory (default) it
|
|
|
- should be below 3750. In order for this parameter to have
|
|
|
- effect, database driver must support fetch_result() capability.
|
|
|
+ The number of the rows to be fetched at once from database when loading
|
|
|
+ data from lcr table. This value can be used to tune the load time at
|
|
|
+ startup. For 1MB of private memory (default) it should be below 3750.
|
|
|
+ In order for this parameter to have effect, database driver must
|
|
|
+ support fetch_result() capability.
|
|
|
|
|
|
Default value is "2000".
|
|
|
|
|
@@ -442,80 +528,82 @@ modparam("lcr", "lcr_hash_size", 1024)
|
|
|
modparam("lcr", "fetch_rows", 3000)
|
|
|
...
|
|
|
|
|
|
-1.4. Exported Functions
|
|
|
+4. Exported Functions
|
|
|
+
|
|
|
+ 4.1. load_gws([pvar])
|
|
|
+ 4.2. load_gws_from_grp(group-id)
|
|
|
+ 4.3. next_gw()
|
|
|
+ 4.4. from_gw([pvar])
|
|
|
+ 4.5. from_gw_grp(group-id)
|
|
|
+ 4.6. to_gw([group-id])
|
|
|
|
|
|
-1.4.1. load_gws([pvar])
|
|
|
+4.1. load_gws([pvar])
|
|
|
|
|
|
- Loads URI schemes, IP addresses, hostnames, ports, and
|
|
|
- transports of matching gateways to gw_uri_avp (see Overview
|
|
|
- section). If optional pseudo variable argument is included,
|
|
|
- caller's URI is taken from it. If pseudo variable argument is
|
|
|
- not included, caller's URI is taken from rpid_avp or, if
|
|
|
- rpid_avp value is empty, from From URI. Returns 1 or -1
|
|
|
+ Loads URI schemes, IP addresses, hostnames, ports, and transports of
|
|
|
+ matching gateways to gw_uri_avp (see Overview section). If optional
|
|
|
+ pseudo variable argument is included, caller's URI is taken from it. If
|
|
|
+ pseudo variable argument is not included, caller's URI is taken from
|
|
|
+ rpid_avp or, if rpid_avp value is empty, from From URI. Returns 1 or -1
|
|
|
depending on success.
|
|
|
|
|
|
- Execution time of load_gws() function is O(N) * O(M), where N
|
|
|
- is number of different prefix lengths and M is number of
|
|
|
- collisions for matching prefix(es) in lcr hash table.
|
|
|
+ Execution time of load_gws() function is O(N) * O(M), where N is number
|
|
|
+ of different prefix lengths and M is number of collisions for matching
|
|
|
+ prefix(es) in lcr hash table.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE.
|
|
|
|
|
|
Example 1.24. load_gws usage
|
|
|
...
|
|
|
if (!load_gws("$var(caller_uri)")) {
|
|
|
- sl_send_reply("500", "Server Internal Error - Cannot load gatewa
|
|
|
-ys");
|
|
|
+ sl_send_reply("500", "Server Internal Error - Cannot load gateways");
|
|
|
exit;
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.4.2. load_gws_from_grp(group-id)
|
|
|
+4.2. load_gws_from_grp(group-id)
|
|
|
|
|
|
- Loads URI schemes, IP addresses, hostnames, ports, and
|
|
|
- transports of gateways that belong to a given group to
|
|
|
- gw_uri_avp. group-id argument is a string that may contain
|
|
|
- pseudo-variables. Its value must be a a string of digits that
|
|
|
- are converted to an integer group id. Returns 1 or -1 depending
|
|
|
- on success.
|
|
|
+ Loads URI schemes, IP addresses, hostnames, ports, and transports of
|
|
|
+ gateways that belong to a given group to gw_uri_avp. group-id argument
|
|
|
+ is a string that may contain pseudo-variables. Its value must be a a
|
|
|
+ string of digits that are converted to an integer group id. Returns 1
|
|
|
+ or -1 depending on success.
|
|
|
|
|
|
- Execution time of load_gws_from_grp() function is O(N), where N
|
|
|
- is number of gateways.
|
|
|
+ Execution time of load_gws_from_grp() function is O(N), where N is
|
|
|
+ number of gateways.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE.
|
|
|
|
|
|
Example 1.25. load_gws_from_grp usage
|
|
|
...
|
|
|
if (!load_gws_from_grp("1")) {
|
|
|
- sl_send_reply("500", "Server Internal Error - Cannot load gatewa
|
|
|
-ys from group 1");
|
|
|
+ sl_send_reply("500", "Server Internal Error - Cannot load gateways from
|
|
|
+group 1");
|
|
|
exit;
|
|
|
};
|
|
|
...
|
|
|
|
|
|
if (!load_gws_from_grp("$avp(s:gateway_group)")) {
|
|
|
- sl_send_reply("500", "Server Internal Error - Cannot load gatewa
|
|
|
-ys");
|
|
|
+ sl_send_reply("500", "Server Internal Error - Cannot load gateways");
|
|
|
exit;
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.4.3. next_gw()
|
|
|
+4.3. next_gw()
|
|
|
|
|
|
- Upon first call, replaces URI scheme, host, port, and transport
|
|
|
- of Request-URI by the values stored in first gw_uri_avp and
|
|
|
- destroys that AVP (see Overview section). Saves user part of
|
|
|
- Request-URI into ruri_user_avp for use in subsequent next_gw()
|
|
|
- calls.
|
|
|
+ Upon first call, replaces URI scheme, host, port, and transport of
|
|
|
+ Request-URI by the values stored in first gw_uri_avp and destroys that
|
|
|
+ AVP (see Overview section). Saves user part of Request-URI into
|
|
|
+ ruri_user_avp for use in subsequent next_gw() calls.
|
|
|
|
|
|
- Upon subsequent calls, appends a new branch URI to the request,
|
|
|
- where URI scheme, host, port, and transport of are taken from
|
|
|
- values stored in the first gw_uri_avp and destroys that AVP.
|
|
|
- URI user is taken from ruri_user_avp.
|
|
|
+ Upon subsequent calls, appends a new branch URI to the request, where
|
|
|
+ URI scheme, host, port, and transport of are taken from values stored
|
|
|
+ in the first gw_uri_avp and destroys that AVP. URI user is taken from
|
|
|
+ ruri_user_avp.
|
|
|
|
|
|
As a side effect, stores gateway's flags to flags_avp.
|
|
|
|
|
|
- Returns 1 on success and -1 if there were no gateways left or
|
|
|
- if an error occurred (see syslog).
|
|
|
+ Returns 1 on success and -1 if there were no gateways left or if an
|
|
|
+ error occurred (see syslog).
|
|
|
|
|
|
Must be preceded by successful load_gws() call.
|
|
|
|
|
@@ -537,15 +625,15 @@ if (!next_gw()) {
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.4.4. from_gw([pvar])
|
|
|
+4.4. from_gw([pvar])
|
|
|
|
|
|
- Checks if request came from IP address of a gateway. IP address
|
|
|
- to be checked is either taken from source IP address of the
|
|
|
- request or (if present) from pseudo variable argument. As a
|
|
|
- side effect, stores gateway's flags to flags_avp.
|
|
|
+ Checks if request came from IP address of a gateway. IP address to be
|
|
|
+ checked is either taken from source IP address of the request or (if
|
|
|
+ present) from pseudo variable argument. As a side effect, stores
|
|
|
+ gateway's flags to flags_avp.
|
|
|
|
|
|
- Execution time of from_gw() function is O(log N), where N is
|
|
|
- number of gateways.
|
|
|
+ Execution time of from_gw() function is O(log N), where N is number of
|
|
|
+ gateways.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
|
ONREPLY_ROUTE.
|
|
@@ -564,15 +652,14 @@ if (from_gw("$si")) {
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.4.5. from_gw_grp(group-id)
|
|
|
+4.5. from_gw_grp(group-id)
|
|
|
|
|
|
- Checks if request came from IP address of a gateway that
|
|
|
- belongs to the given group (integer string). Sets or resets a
|
|
|
- message flag depending on whether the gateway supports directed
|
|
|
- media.
|
|
|
+ Checks if request came from IP address of a gateway that belongs to the
|
|
|
+ given group (integer string). Sets or resets a message flag depending
|
|
|
+ on whether the gateway supports directed media.
|
|
|
|
|
|
- Execution time of from_gw_grp() function is O(log N), where N
|
|
|
- is number of gateways.
|
|
|
+ Execution time of from_gw_grp() function is O(log N), where N is number
|
|
|
+ of gateways.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
|
ONREPLY_ROUTE.
|
|
@@ -584,14 +671,14 @@ if (from_gw_grp("1")) {
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.4.6. to_gw([group-id])
|
|
|
+4.6. to_gw([group-id])
|
|
|
|
|
|
- Checks if in-dialog request goes to a gateway. If an optional
|
|
|
- group-id (integer string) is given, only gateways belonging to
|
|
|
- this group are checked.
|
|
|
+ Checks if in-dialog request goes to a gateway. If an optional group-id
|
|
|
+ (integer string) is given, only gateways belonging to this group are
|
|
|
+ checked.
|
|
|
|
|
|
- Execution time of to_gw() function is O(log N), where N is
|
|
|
- number of gateways.
|
|
|
+ Execution time of to_gw() function is O(log N), where N is number of
|
|
|
+ gateways.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
|
|
|
|
|
@@ -611,12 +698,15 @@ if (to_gw("1")) {
|
|
|
};
|
|
|
...
|
|
|
|
|
|
-1.5. Exported MI Commands
|
|
|
+5. Exported MI Commands
|
|
|
|
|
|
-1.5.1. lcr_reload
|
|
|
+ 5.1. lcr_reload
|
|
|
+ 5.2. lcr_gw_dump
|
|
|
+ 5.3. lcr_lcr_dump
|
|
|
|
|
|
- Causes lcr module to re-read the contents of gateway table into
|
|
|
- memory.
|
|
|
+5.1. lcr_reload
|
|
|
+
|
|
|
+ Causes lcr module to re-read the contents of gateway table into memory.
|
|
|
|
|
|
Name: lcr_reload
|
|
|
|
|
@@ -626,10 +716,9 @@ if (to_gw("1")) {
|
|
|
:lcr_reload:_reply_fifo_file_
|
|
|
_empty_line_
|
|
|
|
|
|
-1.5.2. lcr_gw_dump
|
|
|
+5.2. lcr_gw_dump
|
|
|
|
|
|
- Causes lcr module to dump the contents of its in-memory gw
|
|
|
- table.
|
|
|
+ Causes lcr module to dump the contents of its in-memory gw table.
|
|
|
|
|
|
Name: lcr_gw_dump
|
|
|
|
|
@@ -639,10 +728,9 @@ if (to_gw("1")) {
|
|
|
:lcr_gw_dump:_reply_fifo_file_
|
|
|
_empty_line_
|
|
|
|
|
|
-1.5.3. lcr_lcr_dump
|
|
|
+5.3. lcr_lcr_dump
|
|
|
|
|
|
- Causes lcr module to dump the contents of its in-memory lcr
|
|
|
- table.
|
|
|
+ Causes lcr module to dump the contents of its in-memory lcr table.
|
|
|
|
|
|
Name: lcr_lcr_dump
|
|
|
|
|
@@ -652,10 +740,44 @@ if (to_gw("1")) {
|
|
|
:lcr_gw_dump:_reply_fifo_file_
|
|
|
_empty_line_
|
|
|
|
|
|
-1.6. Known Limitations
|
|
|
+6. Exported RPC Commands
|
|
|
+
|
|
|
+ 6.1. lcr.reload
|
|
|
+ 6.2. lcr.dump_gws
|
|
|
+ 6.3. lcr.dump_lcr
|
|
|
+
|
|
|
+6.1. lcr.reload
|
|
|
+
|
|
|
+ Causes lcr module to re-read the contents of gateway table into memory.
|
|
|
+
|
|
|
+ Name: lcr.reload
|
|
|
+
|
|
|
+ Parameters: none
|
|
|
+
|
|
|
+ Example 1.33. lcr.reload RPC example
|
|
|
+ $ sercmd lcr.reload
|
|
|
+
|
|
|
+6.2. lcr.dump_gws
|
|
|
+
|
|
|
+ Causes lcr module to dump the contents of its in-memory gw table.
|
|
|
+
|
|
|
+ Parameters: none
|
|
|
+
|
|
|
+ Example 1.34. lcr.dump_gws RPC example
|
|
|
+ $ sercmd lcr.dump_gws
|
|
|
+
|
|
|
+6.3. lcr.dump_lcr
|
|
|
+
|
|
|
+ Causes lcr module to dump the contents of its in-memory lcr table.
|
|
|
+
|
|
|
+ Parameters: none
|
|
|
+
|
|
|
+ Example 1.35. lcr.dump_lcr RPC example
|
|
|
+ $ sercmd lcr.dump_lcr
|
|
|
+
|
|
|
+7. Known Limitations
|
|
|
|
|
|
In-memory gateway and in-memory lcr table are switched by two
|
|
|
- consecutive machine instructions. If lcr reload process is
|
|
|
- interrupted after the first one, in-memory gateway table does
|
|
|
- not match in-memory lcr table until execution of lcr reload
|
|
|
- process is resumed.
|
|
|
+ consecutive machine instructions. If lcr reload process is interrupted
|
|
|
+ after the first one, in-memory gateway table does not match in-memory
|
|
|
+ lcr table until execution of lcr reload process is resumed.
|