Debian Codegraph @

src/modules/domain/README

raw
1 Domain Module
2
3 Juha Heinanen
4
5 <[email protected]>
6
7 Edited by
8
9 Juha Heinanen
10
11 <[email protected]>
12
13 Copyright © 2002-2012 Juha Heinanen
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22 3. Parameters
23
24 3.1. db_url (string)
25 3.2. domain_table (string)
26 3.3. domain_attrs_table (string)
27 3.4. did_col (string)
28 3.5. domain_col (string)
29 3.6. name_col (string)
30 3.7. type_col (string)
31 3.8. value_col (string)
32 3.9. register_myself (integer)
33
34 4. Functions
35
36 4.1. is_from_local()
37 4.2. is_uri_host_local()
38 4.3. is_domain_local(domain)
39 4.4. lookup_domain(domain [, prefix])
40
41 5. RPC Commands
42
43 5.1. domain.reload
44 5.2. domain.dump
45
46 6. Known Limitations
47
48 2. Developer Guide
49
50 1. Available Functions
51
52 1.1. is_domain_local(domain)
53
54 List of Examples
55
56 1.1. Setting db_url parameter
57 1.2. Setting domain_table parameter
58 1.3. Setting domain_attrs_table parameter
59 1.4. Setting did_col parameter
60 1.5. Setting domain_col parameter
61 1.6. Setting name_col parameter
62 1.7. Setting name_col parameter
63 1.8. Setting value_col parameter
64 1.9. register_myself example
65 1.10. is_from_local usage
66 1.11. is_uri_host_local usage
67 1.12. is_domain_local usage
68 1.13. lookup_domain
69
70 Chapter 1. Admin Guide
71
72 Table of Contents
73
74 1. Overview
75 2. Dependencies
76 3. Parameters
77
78 3.1. db_url (string)
79 3.2. domain_table (string)
80 3.3. domain_attrs_table (string)
81 3.4. did_col (string)
82 3.5. domain_col (string)
83 3.6. name_col (string)
84 3.7. type_col (string)
85 3.8. value_col (string)
86 3.9. register_myself (integer)
87
88 4. Functions
89
90 4.1. is_from_local()
91 4.2. is_uri_host_local()
92 4.3. is_domain_local(domain)
93 4.4. lookup_domain(domain [, prefix])
94
95 5. RPC Commands
96
97 5.1. domain.reload
98 5.2. domain.dump
99
100 6. Known Limitations
101
102 1. Overview
103
104 Domain module implements checks that based on domain table determine if
105 a domain is “local”. A “local” domain is one that the proxy is
106 responsible for. SIP URIs of local users must have hostpart that is
107 equal to one of these domains.
108
109 Domain module reads the contents of domain and domain_attrs tables into
110 cache memory when the module is loaded. Any changes in domain or
111 domain_attrs tables must thus be followed by “domain.reload” rpc
112 command in order to reflect them in module behavior.
113
114 Caching is implemented using a hash table. The size of the hash table
115 is given by HASH_SIZE constant defined in domain_mod.h. Its “factory
116 default” value is 128.
117
118 2. Dependencies
119
120 The module depends on the following modules (in other words the listed
121 modules must be loaded before this module):
122 * database -- Any database module
123
124 3. Parameters
125
126 3.1. db_url (string)
127 3.2. domain_table (string)
128 3.3. domain_attrs_table (string)
129 3.4. did_col (string)
130 3.5. domain_col (string)
131 3.6. name_col (string)
132 3.7. type_col (string)
133 3.8. value_col (string)
134 3.9. register_myself (integer)
135
136 3.1. db_url (string)
137
138 This is URL of the database to be used.
139
140 Default value is “mysql://kamailioro:kamailioro@localhost/kamailio”
141
142 Example 1.1. Setting db_url parameter
143 modparam("domain", "db_url", "mysql://ser:pass@db_host/ser")
144
145 3.2. domain_table (string)
146
147 Name of table containing names of local domains that the proxy is
148 responsible for.
149
150 Default value is “domain”.
151
152 Example 1.2. Setting domain_table parameter
153 modparam("domain", "domain_table", "new_name")
154
155 3.3. domain_attrs_table (string)
156
157 Name of table containing attributes of local domains.
158
159 Default value is “domain_attrs”.
160
161 Example 1.3. Setting domain_attrs_table parameter
162 modparam("domain", "domain_attrs_table", "local_domain_attributes")
163
164 3.4. did_col (string)
165
166 Name of column containing domain id (did) of domain in domain and
167 domain_attrs tables. In domain table, a did column value may be NULL,
168 which means that it has same value as domain column.
169
170 Default value is “did”.
171
172 Example 1.4. Setting did_col parameter
173 modparam("domain", "did_col", "domain_did")
174
175 3.5. domain_col (string)
176
177 Name of column containing domain name in domain table.
178
179 Default value is “domain”.
180
181 Example 1.5. Setting domain_col parameter
182 modparam("domain", "domain_col", "domain_name")
183
184 3.6. name_col (string)
185
186 Name of column containing attribute name in domain_attrs table.
187
188 Default value is “name”.
189
190 Example 1.6. Setting name_col parameter
191 modparam("domain", "name_col", "attr_name")
192
193 3.7. type_col (string)
194
195 Name of column containing attribute type in domain_attrs table. Type
196 value 0 is integer and type value 2 is string.
197
198 Default value is “type”.
199
200 Example 1.7. Setting name_col parameter
201 modparam("domain", "type_col", "attr_type")
202
203 3.8. value_col (string)
204
205 Name of column containing attribute value in domain_attrs table.
206
207 Default value is “value”.
208
209 Example 1.8. Setting value_col parameter
210 modparam("domain", "value_col", "attr_value")
211
212 3.9. register_myself (integer)
213
214 Register the list of domains to match 'myself' check: 0 means no myself
215 registration, 1 means enable myself registration.
216
217 Default value is 0 (disable).
218
219 Example 1.9. register_myself example
220 modparam("domain", "register_myself", 1)
221
222 4. Functions
223
224 4.1. is_from_local()
225 4.2. is_uri_host_local()
226 4.3. is_domain_local(domain)
227 4.4. lookup_domain(domain [, prefix])
228
229 4.1. is_from_local()
230
231 Checks based on domain table if host part of From header uri is one of
232 the local domains that the proxy is responsible for
233
234 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
235 BRANCH_ROUTE, and LOCAL_ROUTE.
236
237 Example 1.10. is_from_local usage
238 ...
239 if (is_from_local()) {
240 ...
241 };
242 ...
243
244 4.2. is_uri_host_local()
245
246 If called from route or failure route block, checks based on domain
247 table if host part of Request-URI is one of the local domains that the
248 proxy is responsible for. If called from branch route, the test is made
249 on host part of URI of first branch, which thus must have been appended
250 to the transaction before is_uri_host_local() is called.
251
252 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
253 BRANCH_ROUTE, and LOCAL_ROUTE.
254
255 Example 1.11. is_uri_host_local usage
256 ...
257 if (is_uri_host_local()) {
258 ...
259 };
260 ...
261
262 4.3. is_domain_local(domain)
263
264 This function checks if the domain contained in the parameter is local.
265 The parameter can be a static string or contain pseudo-variables.
266
267 This function is a generalized form of the is_from_local() and
268 is_uri_host_local() functions, being able to completely replace them
269 and also extends them by allowing the domain to be taken from any of
270 the above mentioned sources. The following equivalences exist:
271 * is_domain_local("$rd") is same as is_uri_host_local()
272 * is_domain_local("$fd") is same as is_from_local()
273
274 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
275 BRANCH_ROUTE, and LOCAL_ROUTE.
276
277 Example 1.12. is_domain_local usage
278 ...
279 if (is_domain_local("$rd")) {
280 ...
281 }
282 if (is_domain_local("my.domain.com")) {
283 ...
284 }
285 if (is_domain_local("$fd")) {
286 ...
287 }
288 if (is_domain_local("$avp(some_avp_alias)")) {
289 ...
290 }
291 if (is_domain_local("$avp(i:850)")) {
292 ...
293 }
294 if (is_domain_local("$avp(s:some_avp)")) {
295 ...
296 }
297 ...
298
299 4.4. lookup_domain(domain [, prefix])
300
301 This function checks if domain given in domain argument is local and,
302 if so, adds attributes associated with domain's id (did) to AVPs. If
303 prefix argument (string) is given, names of attributes are prefixes by
304 it. In addition to attributes given in domain_attrs table, AVP named
305 did containing the did of domain is added.
306
307 Both parameters can contain pseudo-variables.
308
309 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
310 BRANCH_ROUTE, and LOCAL_ROUTE.
311
312 Example 1.13. lookup_domain
313 ...
314 if (lookup_domain("$fd", "from_")) {
315 xlog("L_INFO", "did of domain $fd is $avp(from_did)\n");
316 }
317 ...
318
319 5. RPC Commands
320
321 5.1. domain.reload
322 5.2. domain.dump
323
324 5.1. domain.reload
325
326 Causes domain module to re-read the contents of domain table into cache
327 memory.
328
329 Name: domain.reload
330
331 Parameters: none
332
333 Example:
334 kamcmd domain.reload
335
336 5.2. domain.dump
337
338 Causes domain module to dump domain names in its cache memory.
339
340 Name: domain.dump
341
342 Parameters: none
343
344 Example:
345 kamcmd domain.dump
346
347 6. Known Limitations
348
349 There is an unlikely race condition on domain reload. If a process uses
350 a table, which is reloaded at the same time twice through RPC, the
351 second reload will delete the original table still in use by the
352 process.
353
354 Chapter 2. Developer Guide
355
356 Table of Contents
357
358 1. Available Functions
359
360 1.1. is_domain_local(domain)
361
362 The module provides is_domain_local API function for use by other
363 Kamailio modules.
364
365 1. Available Functions
366
367 1.1. is_domain_local(domain)
368
369 1.1. is_domain_local(domain)
370
371 Checks if domain given in str* parameter is local.
372
373 The function returns 1 if domain is local and -1 if domain is not local
374 or if an error occurred.