db_url
(string)gw_table
(string)gw_name_column
(string)ip_addr_column
(string)port_column
(string)uri_scheme_column
(string)transport_column
(string)grp_id_column
(string)lcr_table
(string)strip_column
(string)prefix_column
(string)from_uri_column
(string)priority_column
(string)gw_uri_avp
(string)ruri_user_avp
(string)contact_avp
(string)fr_inv_timer_avp
(string)fr_inv_timer
(integer)fr_inv_timer_next
(integer)rpid_avp
(string)db_mode
(integer)load_gws(), load_gws(group-id)
next_gw()
from_gw(), from_gw(group-id)
to_gw(), to_gw(group-id)
load_contacts()
next_contacts()
lcr_reload
lcr_dump
db_url
module parametergw_table
module parametergw_name_column
module parameterip_addr_column
module parameterport_column
module parameteruri_scheme_column
module
parametertransport_column
module
parametergrp_id_column
module parameterlcr_table
module parameterstrip_column
module parameterprefix_column
module parameterfrom_uri_column
module parameterpriority_column
module parametergw_uri_avp
module parameterruri_user_avp
module parametercontact_avp
module parameterfr_inv_timer_avp
module parameterfr_inv_timer
module parameterfr_inv_timer_next
module parameterrpid_avp
module parameterdb_mode
module parameterload_gws
usageload_gws
usage with group-idnext_gw
usage from a route blocknext_gw
usage from a failure route blockfrom_gw
usagefrom_gw
usage with group-idto_gw
usageto_gw
usage with group-idload_contacts
usagenext_contacts
usage from route blocknext_contacts
usage from
failure route blockLeast cost routing (LCR) module implements two related capabilities:
sequential forwarding of a request to one or more gateways (functions load_gws and next_gw)
sequential forwarding to contacts if they don't share the the same qvalue (functions load_contacts and next_contacts).
Gateway selection is based on caller's RPID URI (if available in caller's RPID AVP after authentication) or From URI and user part of Request-URI (telephone number). A gateway matches a request if user part of Request-URI and "From" URI match the prefix and From pattern of the gateway. Matching gateways are then ordered for forwarding purpose (1) according to longest user part match, (2) according to gateway's priority, and (3) randomly.
Each gateway belongs to a gateway group either alone or among other gateways. All gateways in a group share the same priority.
Gateway and routing information is kept in two tables: gw and lcr.
When a gateway is selected, the Request-URI user part is stripped by the number of digits specified in the strip parameter. Subsequently, the Request-URI is rewritten with information from gw table: URI scheme, prefix, IP address, port, and transport protocol. Valid URI scheme values are NULL = sip, 1 = sip and 2 = sips. Prefix is appended in front of Request-URI user part. Currently valid transport protocol values are NULL = none, 1 = udp, 2 = tcp, and 3 = tls.
Table lcr contains prefix of user part of Request-URI, From URI, gateway group id, and priority. From URI can contain special characters % and _ matching any number of any characters and any one character, respectively, if db_mod parameter is set to 0. If db_mod parameter is set to 1, then From URI is a regular expression.
In addition to gw and lcr tables there is third table gw_grp that is used to associate names with gateway group ids.
The following modules must be loaded before this module:
TM module
A database module like mysql, postgres or dbtext.
The following libraries or applications must be installed before running OpenSER with this module:
none.
db_url
(string)URL of the database table to be used.
Default value is "mysql://openserro:openserro@localhost/openser".
gw_name_column
(string)Name of the column holding the gateway name.
Default value is "gw_name".
ip_addr_column
(string)Name of the column holding the IP address of the gateway.
Default value is "ip_addr".
port_column
(string)Name of the column holding the port number of the gateway.
Default value is "port".
uri_scheme_column
(string)Name of the column holding the uri scheme of the gateway.
Default value is "uri_scheme".
transport_column
(string)Name of the column holding the transport type to be used for the gateway.
Default value is "transport".
strip_column
(string)Name of the column holding the number of digits to strip from the RURI before applying the prefix.
Default value is "strip".
prefix_column
(string)Name of the column holding the RURI(destination) prefix.
Default value is "prefix".
from_uri_column
(string)Name of the column holding the FROM (source) URI.
Default value is "from_uri".
priority_column
(string)Name of the column holding the priority of the rule.
Default value is "priority".
gw_uri_avp
(string)Overrides the name of the AVP containing URI scheme, host, port, and transport of a gateway. If the string name of the AVP contains only digits, the name of the AVP is integer value of the string.
Default value is "1400".
ruri_user_avp
(string)Overrides the name of the AVP containing user part of Request-URI after the first next_gw() call. If the string name of the AVP contains only digits, the name of the AVP is integer value of the string.
Default value is "1402".
contact_avp
(string)Overrides the name of the AVP containing the contact. If the string name of the AVP contains only digits, the name of the AVP is integer value of the string.
Default value is "1401".
fr_inv_timer_avp
(string)Overrides the name of the AVP carrying the Final Response timeout for INVITEs.
Default value is "fr_inv_timer_avp".
fr_inv_timer
(integer)Sets the value of the fist INVITE's Final Response timeout to be used during sequential forwarding:
Default value is 90.
fr_inv_timer_next
(integer)Sets the value of the next INVITE's Final Response timeouts to be used during sequential forwarding:
Function next_contacts() sets tm fr_inv_timer to fr_inv_timer_next value if, after next contacts, there are still lower qvalue contacts available, and to fr_inv_timer value if next contacts are the last ones left.
Default value is 30.
rpid_avp
(string)Sets the string name of the AVP containing the RPID.
Default value is "rpid".
db_mode
(integer)Sets the database mode of operating:
0 : no-caching - a db lookup is performed during each load_gws()
1 : regexp are used for from_uri; no db lookup is performed during load_gws(), the DB content is cached into memory;
Default value is "1".
load_gws(), load_gws(group-id)
Loads URI schemes, addresses, ports, and transports of gateways that match user part of Request-URI to gw_uri_avp AVPs (see Overview section). If an optional group-id is specified, only gateways belonging to this group are loaded. Returns 1 or -1 depending on success.
This function can be used from REQUEST_ROUTE.
next_gw()
If called from a route block, replaces URI scheme, host, port, and transport of Request-URI by the values stored in first gw_uri_avp AVP and destroys that AVP. Saves user part of Request-URI into ruri_user_avp AVP for use in subsequent next_gw() calls.
If called from a failure route block, appends a new branch to request, where URI scheme, host, port, and transport of Request-URI is replaced by the values stored in the first gw_uri_avp AVP and destroys that AVP. Request-URI user is taken from ruri_user_avp AVP.
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.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
from_gw(), from_gw(group-id)
Checks if request came from IP address of a gateway. If an optional group-id is given, only gateways belonging to this group are checked.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, ONREPLY_ROUTE.
to_gw(), to_gw(group-id)
Checks if in-dialog request goes to a gateway. If an optional group-id is given, only gateways belonging to this group are checked.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
load_contacts()
Loads contacts in destination set in increasing qvalue order as values of lcr_contact AVP. If all contacts in the destination set have the same qvalue, load_contacts() does not do anything thus minimizing performance impact of sequential forking capability when it is not needed. Returns 1 if loading of contacts succeeded or there was nothing to do. Returns -1 on error (see syslog).
This function can be used from REQUEST_ROUTE.
next_contacts()
If called from a route block, replaces Request-URI with the first lcr_contact AVP value, adds the remaining lcr_contact AVP values with the same qvalue as branches, and destroys those AVPs. It does nothing if there are no lcr_contact AVPs. Returns 1 if there were no errors and -1 if an error occurred (see syslog).
If called from a failure route block, adds the first lcr_contact AVP value and all following lcr_contact AVP values with the same qvalue as new branches to request and destroys those AVPs. Returns 1 if new branches were successfully added and -1 on error (see syslog) or if there were no more lcr_contact AVPs.
Must be preceded by successful load_contacts() call.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
lcr_reload
Causes lcr module to re-read the contents of gateway table into memory.
There is an unlikely race condition on lcr reload. If a process uses in memory gw table, which is reloaded at the same time twice through FIFO, the second reload will delete the original table still in use by the process.
Function load_gws() currently makes an SQL query for the matching gateways. In order to avoid the query, also lcr table should be read into memory and the corresponding query should be rewritten in C.
Take a look at http://openser.org/.
First at all check if your question was already answered on one of our mailing lists:
User Mailing List - http://openser.org/cgi-bin/mailman/listinfo/users
Developer Mailing List - http://openser.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@openser.org>
and e-mails regarding development versions
should be sent to <devel@openser.org>
.
If you want to keep the mail private, send it to
<team@openser.org>
.
Please follow the guidelines provided at: http://sourceforge.net/tracker/?group_id=139143.