Debian Codegraph @

src/modules/prefix_route/README

raw
1 prefix_route Module
2
3 Alfred E. Heggestad
4
5 Telio Telecom
6
7 Copyright © 2007 Alfred E. Heggestad
8
9 Copyright © 2008 Telio Telecom AS
10 __________________________________________________________________
11
12 Table of Contents
13
14 1. Admin Guide
15
16 1. Overview
17 2. Parameters
18
19 2.1. db_url (string)
20 2.2. db_table (string)
21 2.3. exit (int)
22
23 3. Functions
24
25 3.1. prefix_route([user])
26
27 4. RPC Commands
28
29 4.1. prefix_route.reload
30 4.2. prefix_route.dump
31
32 5. Database Structure
33
34 List of Examples
35
36 1.1. Setting db_url parameter
37 1.2. Setting db_table parameter
38 1.3. Setting exit parameter
39 1.4. prefix_route() usage
40 1.5. Sample data
41
42 Chapter 1. Admin Guide
43
44 Table of Contents
45
46 1. Overview
47 2. Parameters
48
49 2.1. db_url (string)
50 2.2. db_table (string)
51 2.3. exit (int)
52
53 3. Functions
54
55 3.1. prefix_route([user])
56
57 4. RPC Commands
58
59 4.1. prefix_route.reload
60 4.2. prefix_route.dump
61
62 5. Database Structure
63
64 1. Overview
65
66 The prefix_route module does routing based on a set of prefixes from
67 the database. The prefix rule-set is loaded from the database into a
68 binary tree in memory, either on startup or when issuing the
69 "prefix_route.reload" RPC command. When calling the "prefix_route()"
70 function from the ser.cfg configuration script, it will try to match
71 the user part of the request URI with the best matching route. If a
72 route is found, it will be used for further processing. If not found
73 normal processing will continue.
74
75 Development was sponsored by Telio Telecom.
76
77 2. Parameters
78
79 2.1. db_url (string)
80 2.2. db_table (string)
81 2.3. exit (int)
82
83 2.1. db_url (string)
84
85 This is URL of the database to be used.
86
87 Default value is "mysql://ser@localhost/ser"
88
89 Example 1.1. Setting db_url parameter
90 ...
91 modparam("prefix_route", "db_url", "mysql://ser:pass@db_host/ser")
92 ...
93
94 2.2. db_table (string)
95
96 The name of table where to read prefix route set.
97
98 Default value is "prefix_route".
99
100 Example 1.2. Setting db_table parameter
101 ...
102 modparam("prefix_route", "db_table", "new_prefix_route")
103 ...
104
105 2.3. exit (int)
106
107 If set, exit the execution of the configuration file when a route block
108 is executed upon matching a prefix. Otherwise return 1 (true).
109
110 Default value is 1 (on).
111
112 Example 1.3. Setting exit parameter
113 ...
114 modparam("prefix_route", "exit", 0)
115 ...
116
117 3. Functions
118
119 3.1. prefix_route([user])
120
121 3.1. prefix_route([user])
122
123 This function tries to find a route from the user part of the request
124 URI (if no parameter is provided), or from the value of the parameter.
125 The parameter can contain config variables.
126
127 If a route is found, it will be used for further processing. Otherwise
128 the function will return false.
129
130 Example 1.4. prefix_route() usage
131 ...
132 if (!prefix_route()) {
133 xlog("L_ERR", "prefix_route(): no matching routes\n");
134 }
135 ...
136 if (!prefix_route("$fU")) {
137 xlog("L_ERR", "prefix_route(): no matching routes\n");
138 }
139
140 ...
141
142 4. RPC Commands
143
144 4.1. prefix_route.reload
145 4.2. prefix_route.dump
146
147 4.1. prefix_route.reload
148
149 Reload prefix route tree from the database. Validation is done and the
150 prefix route tree will only be reloaded if there are no errors.
151
152 4.2. prefix_route.dump
153
154 Dump the current prefix route tree.
155
156 5. Database Structure
157
158 A prefix route set consists of three fields:
159 * prefix - varchar(64) - Prefix rule
160 * route - varchar(64) - Route name
161 * comment - varchar(64) - Free-form comment
162
163 Example 1.5. Sample data
164 ...
165 +--------+-------+---------------+
166 | prefix | route | comment |
167 +--------+-------+---------------+
168 | 46 | SE | Sweden |
169 | 47 | NO | Norway |
170 | 479 | NOMOB | Norway mobile |
171 | 49 | DE | Deutschland |
172 | 39 | IT | Italy |
173 +--------+-------+---------------+
174 ...