Table of Contents
List of Examples
Table of Contents
The prefix_route module does routing based on a set of prefixes from the database. The prefix rule-set is loaded from the database into a binary tree in memory, either on startup or when issuing the "prefix_route.reload" RPC command. When calling the "prefix_route()" function from the ser.cfg configuration script, it will try to match the user part of the request URI with the best matching route. If a route is found, it will be used for further processing. If not found normal processing will continue.
Development was sponsored by Telio Telecom.
This is URL of the database to be used.
Default value is "mysql://ser@localhost/ser"
Example 1.1. Setting db_url parameter
... modparam("prefix_route", "db_url", "mysql://ser:pass@db_host/ser") ...
This function tries to find a route from the user part of the request URI (if no parameter is provided), or from the value of the parameter. The parameter can contain config variables.
If a route is found, it will be used for further processing. Otherwise the function will return false.
Example 1.4. prefix_route() usage
... if (!prefix_route()) { xlog("L_ERR", "prefix_route(): no matching routes\n"); } ... if (!prefix_route("$fU")) { xlog("L_ERR", "prefix_route(): no matching routes\n"); } ...
Reload prefix route tree from the database. Validation is done and the prefix route tree will only be reloaded if there are no errors.
A prefix route set consists of three fields:
prefix - varchar(64) - Prefix rule
route - varchar(64) - Route name
comment - varchar(64) - Free-form comment
Example 1.5. Sample data
... +--------+-------+---------------+ | prefix | route | comment | +--------+-------+---------------+ | 46 | SE | Sweden | | 47 | NO | Norway | | 479 | NOMOB | Norway mobile | | 49 | DE | Deutschland | | 39 | IT | Italy | +--------+-------+---------------+ ...