File: README

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (441 lines) | stat: -rw-r--r-- 9,488 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
mtree Module

Daniel-Constantin Mierla

   asipto.com

Edited by

Daniel-Constantin Mierla

   <miconda@gmail.com>

Juha Heinanen

   tutpro.com

Edited by

Juha Heinanen

   <jh@tutpro.com>

   Copyright (c) 2010 Daniel-Constantin Mierla (asipto.com)

   Copyright (c) 2011 Juha Heinanen
     __________________________________________________________________

   Table of Contents

   1. Admin Guide

        1. Overview
        2. Dependencies

              2.1. Kamailio Modules
              2.2. External Libraries or Applications

        3. Parameters

              3.1. db_url (string)
              3.2. db_table (string)
              3.3. mtree (string)
              3.4. tname_column (string)
              3.5. tprefix_column (string)
              3.6. tvalue_column (string)
              3.7. fetch_rows (integer)
              3.8. char_list (string)
              3.9. pv_value (string)
              3.10. pv_values (string)
              3.11. mt_tree_type (integer)
              3.12. mt_ignore_duplicates (integer)
              3.13. mt_allow_duplicates (integer)

        4. Functions

              4.1. mt_match(mtree, pv, mode)

        5. MI Commands

              5.1. mt_list
              5.2. mt_reload
              5.3. mt_summary
              5.4. mt_match

        6. RPC Commands

              6.1. mtree.summary
              6.2. mtree.reload
              6.3. mtree.match

   List of Examples

   1.1. Set db_url parameter
   1.2. Set db_table parameter
   1.3. Set mtree parameter
   1.4. Set tname_column parameter
   1.5. Set tprefix_column parameter
   1.6. Set tvalue_column parameter
   1.7. Set fetch_rows parameter
   1.8. Set char_list parameter
   1.9. Set pv_value parameter
   1.10. Set pv_values parameter
   1.11. Set mt_tree_type parameter
   1.12. Set mt_ignore_duplicates parameter
   1.13. Set mt_allow_duplicates parameter
   1.14. mt_match usage

Chapter 1. Admin Guide

   Table of Contents

   1. Overview
   2. Dependencies

        2.1. Kamailio Modules
        2.2. External Libraries or Applications

   3. Parameters

        3.1. db_url (string)
        3.2. db_table (string)
        3.3. mtree (string)
        3.4. tname_column (string)
        3.5. tprefix_column (string)
        3.6. tvalue_column (string)
        3.7. fetch_rows (integer)
        3.8. char_list (string)
        3.9. pv_value (string)
        3.10. pv_values (string)
        3.11. mt_tree_type (integer)
        3.12. mt_ignore_duplicates (integer)
        3.13. mt_allow_duplicates (integer)

   4. Functions

        4.1. mt_match(mtree, pv, mode)

   5. MI Commands

        5.1. mt_list
        5.2. mt_reload
        5.3. mt_summary
        5.4. mt_match

   6. RPC Commands

        6.1. mtree.summary
        6.2. mtree.reload
        6.3. mtree.match

1. Overview

   This module loads data indexed by prefixes from database and returns
   associated string or precompiled value.

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:
     * A Kamailio database module (e.g., mysql).

2.2. External Libraries or Applications

   The following libraries or applications must be installed before
   running Kamailio with this module loaded:
     * None.

3. Parameters

   3.1. db_url (string)
   3.2. db_table (string)
   3.3. mtree (string)
   3.4. tname_column (string)
   3.5. tprefix_column (string)
   3.6. tvalue_column (string)
   3.7. fetch_rows (integer)
   3.8. char_list (string)
   3.9. pv_value (string)
   3.10. pv_values (string)
   3.11. mt_tree_type (integer)
   3.12. mt_ignore_duplicates (integer)
   3.13. mt_allow_duplicates (integer)

3.1. db_url (string)

   URL of the database server to be used.

   Default value is "mysql://kamailio:kamailiorw@localhost/kamailio".

   Example 1.1. Set db_url parameter
...
modparam("mtree", "db_url", "dbdriver://username:password@dbhost/dbname")
...

3.2. db_table (string)

   Name of database table where data for trees is stored. It is ignored if
   a 'mtree' parameter is defined.

   Default value is "mtrees".

   Example 1.2. Set db_table parameter
...
modparam("mtree", "db_table", "mymtrees")
...

3.3. mtree (string)

   Definition of memory tree with parameters name, dbtable, type, and
   multi. Name is name of the tree, dbtable is name of dbtable where tree
   is stored, type is type of tree elements (0 = string, 2 = integer), and
   multi tells if dbtable can contain more than one tree (0 = one tree, 1
   = more than one tree identified by tname column).

   This parameter can be set many times to add more trees in memory.

   Default value is "none".

   Example 1.3. Set mtree parameter
...
modparam("mtree", "mtree", "name=mytree1;dbtable=routes1;type=0")
modparam("mtree", "mtree", "name=mytree2;dbtable=routes2;type=0;multi=1")
...

3.4. tname_column (string)

   Name of 'tname' column.

   Default value is "tname".

   Example 1.4. Set tname_column parameter
...
modparam("mtree", "tname_column", "name")
...

3.5. tprefix_column (string)

   Name of 'tprefix' column.

   Default value is "tprefix".

   Example 1.5. Set tprefix_column parameter
...
modparam("mtree", "tprefix_column", "prefix")
...

3.6. tvalue_column (string)

   Name of 'tvalue' column.

   Default value is "tvalue".

   Example 1.6. Set tvalue_column parameter
...
modparam("mtree", "tvalue_column", "ipaddr")
...

3.7. fetch_rows (integer)

   Number of rows to be loaded in one step from database.

   Default value is 1000.

   Example 1.7. Set fetch_rows parameter
...
modparam("mtree", "fetch_rows", 4000)
...

3.8. char_list (string)

   The list with characters allowed in prefix.

   Default value is "0123456789".

   Example 1.8. Set char_list parameter
...
modparam("mtree", "char_list", "0123456789*+")
...

3.9. pv_value (string)

   The PV spec where to store the matched value. It can be any writable
   PV.

   Default value is "$avp(s:tvalue)".

   Example 1.9. Set pv_value parameter
...
modparam("mtree", "pv_value", "$var(mtval)")
...

3.10. pv_values (string)

   The AVP where to store the matched values when mtree is of type 0 or 2
   and mode of mt_match() call has value 2.

   Default value is "$avp(s:tvalues)".

   Example 1.10. Set pv_values parameter
...
modparam("mtree", "pv_values", "$avp(mtvals)")
...

3.11. mt_tree_type (integer)

   Default payload type for trees data stored in 'db_table'. Documented
   values are 0 for string payloads and 2 for integer payloads.

   Default value is 0.

   Example 1.11. Set mt_tree_type parameter
...
modparam("mtree", "mt_tree_type", 2)
...

3.12. mt_ignore_duplicates (integer)

   Ignore duplicated prefixes when loading data.

   Default value is 0.

   Example 1.12. Set mt_ignore_duplicates parameter
...
modparam("mtree", "mt_ignore_duplicates", 1)
...

3.13. mt_allow_duplicates (integer)

   Allow duplicate prefixes when loading data.

   Default value is 0.

   Example 1.13. Set mt_allow_duplicates parameter
...
modparam("mtree", "mt_allow_duplicates", 1)
...

4. Functions

   4.1. mt_match(mtree, pv, mode)

4.1.  mt_match(mtree, pv, mode)

   Match 'pv' value against 'mtree'. If 'mtree' type is 0 or 2 and value
   of 'mode' is NOT 2, sets a value of the longest matching prefix to
   pseudo variable specified by pv_value parameter. If 'mtree' type is 0
   or 2 and value of 'mode' is 2, sets values of all matching prefixes to
   avp specified by pv_values parameter so that a value of longest
   matching prefix is in avp index 0. Parameter 'mode' can be an integer
   constant or a pseudo variable with integer value.

   Returns 1 if match succeeded and -1 otherwise.

   Example 1.14. mt_match usage
...
mt_match("mytree", "$rU", "0");
...

5. MI Commands

   5.1. mt_list
   5.2. mt_reload
   5.3. mt_summary
   5.4. mt_match

5.1.  mt_list

   List content of a tree.

   Name: mt_list

   Parameters:
     * _mtree_ : name of tree to list.

   MI FIFO Command Format:
                :mt_list:_reply_fifo_file_
                _mtname_
                _empty_line_

5.2.  mt_reload

   Reload mtree from database.

   Name: mt_mtree

   Parameters:
     * _mtname_
       - name of mem tree

   MI FIFO Command Format:
                :mt_reload:_reply_fifo_file_
                _mtname_
                _empty_line_

5.3.  mt_summary

   List usage summary for all trees.

   Name: mt_summary

   Parameters: none.

   MI FIFO Command Format:
                :mt_summary:_reply_fifo_file_
                _empty_line_

5.4.  mt_match

   Match prefix value against mtree.

   Name: mt_match

   Parameters: 3
     * Name of mtree
     * Prefix to match
     * Mode of matching

   MI FIFO Command Format:
                :mt_match:_reply_fifo_file_
                _mtree_
                _prefix_
                _mode_
                _empty_line_

6. RPC Commands

   6.1. mtree.summary
   6.2. mtree.reload
   6.3. mtree.match

6.1.  mtree.summary

   List usage summary for all trees or for the tree whose name is given as
   parameter.

   Parameters:
     * _mtree_ - (optional) the name of the tree.

6.2.  mtree.reload

   Reload mtree from database to memory.

   Parameters:
     * _mtree_
       - name of mtree or empty string meaning all mtrees

6.3.  mtree.match

   Match prefix value against mtree

   Parameters:
     * _mtree_
       - name of mtree
     * _prefix_
       - match prefix
     * _mode_
       - matching mode