Debian Codegraph @

src/modules/avpops/README

raw
1 AVPops Module
2
3 Ramona-Elena Modroiu
4
5 <[email protected]>
6
7 Edited by
8
9 Ramona-Elena Modroiu
10
11 <[email protected]>
12
13 Copyright © 2004, 2005 Voice Sistem SRL
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22
23 2.1. Kamailio Modules
24 2.2. External Libraries or Applications
25
26 3. AVP naming format
27 4. Parameters
28
29 4.1. db_url (string)
30 4.2. avp_table (string)
31 4.3. use_domain (integer)
32 4.4. uuid_column (string)
33 4.5. username_column (string)
34 4.6. domain_column (string)
35 4.7. attribute_column (string)
36 4.8. value_column (string)
37 4.9. type_column (string)
38 4.10. db_scheme (string)
39
40 5. Functions
41
42 5.1. avp_db_load(source, name)
43 5.2. avp_db_store(source, name)
44 5.3. avp_db_delete(source, name)
45 5.4. avp_db_query(query[, dest])
46 5.5. avp_delete(name)
47 5.6. avp_pushto(destination, name)
48 5.7. avp_check(name, op_value)
49 5.8. avp_copy(old_name, new_name)
50 5.9. avp_printf(dest, format)
51 5.10. avp_subst(avps, subst)
52 5.11. avp_subst_pv(avps, subst)
53 5.12. avp_op(name, op_value)
54 5.13. is_avp_set(name)
55 5.14. avp_print()
56
57 List of Examples
58
59 1.1. AVP naming examples
60 1.2. Set db_url parameter
61 1.3. Set avp_table parameter
62 1.4. Set use_domain parameter
63 1.5. Set uuid_column parameter
64 1.6. Set username_column parameter
65 1.7. Set domain_column parameter
66 1.8. Set attribute_column parameter
67 1.9. Set value_column parameter
68 1.10. Set type_column parameter
69 1.11. Set db_scheme parameter
70 1.12. avp_db_load usage
71 1.13. avp_db_store usage
72 1.14. avp_db_delete usage
73 1.15. avp_db_query usage
74 1.16. avp_delete usage
75 1.17. avp_pushto usage
76 1.18. avp_check usage
77 1.19. avp_copy usage
78 1.20. avp_printf usage
79 1.21. avp_subst usage
80 1.22. avp_subst_pv usage
81 1.23. avp_op usage
82 1.24. is_avp_set usage
83 1.25. avp_print usage
84
85 Chapter 1. Admin Guide
86
87 Table of Contents
88
89 1. Overview
90 2. Dependencies
91
92 2.1. Kamailio Modules
93 2.2. External Libraries or Applications
94
95 3. AVP naming format
96 4. Parameters
97
98 4.1. db_url (string)
99 4.2. avp_table (string)
100 4.3. use_domain (integer)
101 4.4. uuid_column (string)
102 4.5. username_column (string)
103 4.6. domain_column (string)
104 4.7. attribute_column (string)
105 4.8. value_column (string)
106 4.9. type_column (string)
107 4.10. db_scheme (string)
108
109 5. Functions
110
111 5.1. avp_db_load(source, name)
112 5.2. avp_db_store(source, name)
113 5.3. avp_db_delete(source, name)
114 5.4. avp_db_query(query[, dest])
115 5.5. avp_delete(name)
116 5.6. avp_pushto(destination, name)
117 5.7. avp_check(name, op_value)
118 5.8. avp_copy(old_name, new_name)
119 5.9. avp_printf(dest, format)
120 5.10. avp_subst(avps, subst)
121 5.11. avp_subst_pv(avps, subst)
122 5.12. avp_op(name, op_value)
123 5.13. is_avp_set(name)
124 5.14. avp_print()
125
126 1. Overview
127
128 The AVPops (AVP-operations) module implements a set of script functions
129 which allow access and manipulation of user attribute-value pairs
130 (AVPs, preferences) and pseudo-variables. AVPs are a powerful tool for
131 implementing services/preferences per user/domain. With this module,
132 they are usable directly from configuration script.
133
134 The module implements functions for interfacing DB resources
135 (loading/storing/removing), functions for swapping information between
136 AVPs and SIP messages and a function for testing/checking the value of
137 an AVP.
138
139 If you just need a way to execute SQL statements in a Kamailio
140 configuration script, please consider use the sqlops module instead.
141
142 AVPs are persistent per SIP transaction, being available in "route",
143 "branch_route" and "failure_route". A tutorial providing more
144 information (detailed explanations and commented examples) can be found
145 on the SIP-router web site.
146
147 2. Dependencies
148
149 2.1. Kamailio Modules
150 2.2. External Libraries or Applications
151
152 2.1. Kamailio Modules
153
154 The following modules must be loaded before this module:
155 * Optionally a database module
156
157 2.2. External Libraries or Applications
158
159 The following libraries or applications must be installed before
160 running Kamailio with this module loaded:
161 * None
162
163 3. AVP naming format
164
165 The format of the parameters specifying an AVP in functions exported by
166 this module is: $avp(avp_flags:avp_name) or $avp(avp_alias).
167 * avp_flags = type_flags [script_flags]; type_flags = 'I' | 'i' | 'S'
168 | 's'; script_flags = 0..255
169 'I' or 'i' means that the type of avp name is an integer (ID)
170 'S' or 's' means that the type of avp name is string
171 The type flag is mandatory. Please note that the type flag only
172 indicates type of name, not type of variable. An avp with name type
173 "i" may very well contain text strings.
174 script_flags must be an 8 bit unsigned number, therefore can be set
175 up to 8 flags. If no script flag is provided, the name will match
176 all AVPs, regardless they have or not a script flag set (preserves
177 the compatibility with the old naming schema).
178 * avp_name = string | integer
179 string - might be any alphanumeric string, which contain following
180 characters: [a-z] [A-Z] [0-9] '_'
181 integer - might be an unsigned integer, greater than zero, up to
182 2^16-1
183 * avp_alias = string
184 string - might be any alphanumeric string, which contain following
185 characters: [a-z] [A-Z] [0-9] '_'
186
187 Example 1.1. AVP naming examples
188 ...
189 $avp(i:11) - the AVP identified by integer 11
190 $avp(s:foo) - the AVP identified by the string 'foo'
191 $avp(bar) - the AVP identified by the AVP alias 'bar'
192 $avp(i3:123) - the AVP identified by the integer 123 which has script flags 1
193 and 2 set
194 ...
195
196 4. Parameters
197
198 4.1. db_url (string)
199 4.2. avp_table (string)
200 4.3. use_domain (integer)
201 4.4. uuid_column (string)
202 4.5. username_column (string)
203 4.6. domain_column (string)
204 4.7. attribute_column (string)
205 4.8. value_column (string)
206 4.9. type_column (string)
207 4.10. db_scheme (string)
208
209 4.1. db_url (string)
210
211 DB URL for database connection.
212
213 The default value is NULL.
214
215 Example 1.2. Set db_url parameter
216 ...
217 modparam("avpops","db_url","mysql://user:passwd@host/database")
218 ...
219
220 4.2. avp_table (string)
221
222 DB table to be used.
223
224 The default value is NULL. But if you specify a db_url, you need also
225 to set up this parameter.
226
227 Example 1.3. Set avp_table parameter
228 ...
229 modparam("avpops","avp_table","avptable")
230 ...
231
232 4.3. use_domain (integer)
233
234 If the domain part of the URI should be used for identifying an AVP in
235 DB operations.
236
237 Default value is 0 (no).
238
239 Example 1.4. Set use_domain parameter
240 ...
241 modparam("avpops","use_domain",1)
242 ...
243
244 4.4. uuid_column (string)
245
246 Name of column containing the uuid (unique user id).
247
248 Default value is “uuid”.
249
250 Example 1.5. Set uuid_column parameter
251 ...
252 modparam("avpops","uuid_column","uuid")
253 ...
254
255 4.5. username_column (string)
256
257 Name of column containing the username.
258
259 Default value is “username”.
260
261 Example 1.6. Set username_column parameter
262 ...
263 modparam("avpops","username_column","username")
264 ...
265
266 4.6. domain_column (string)
267
268 Name of column containing the domain name.
269
270 Default value is “domain”.
271
272 Example 1.7. Set domain_column parameter
273 ...
274 modparam("avpops","domain_column","domain")
275 ...
276
277 4.7. attribute_column (string)
278
279 Name of column containing the attribute name (AVP name).
280
281 Default value is “attribute”.
282
283 Example 1.8. Set attribute_column parameter
284 ...
285 modparam("avpops","attribute_column","attribute")
286 ...
287
288 4.8. value_column (string)
289
290 Name of column containing the AVP value.
291
292 Default value is “value”.
293
294 Example 1.9. Set value_column parameter
295 ...
296 modparam("avpops","value_column","value")
297 ...
298
299 4.9. type_column (string)
300
301 Name of integer column containing the AVP type.
302
303 Default value is “type”.
304
305 Possible column values are
306 * 0 - AVP with string name and string value
307 * 1 - AVP with string name and integer value
308 * 2 - AVP with integer name and string value
309 * 3 - AVP with integer name and integer value
310
311 Example 1.10. Set type_column parameter
312 ...
313 modparam("avpops","type_column","type")
314 ...
315
316 4.10. db_scheme (string)
317
318 Definition of a DB scheme to be used for non-standard access to
319 Database information.
320
321 Definition of a DB scheme. Scheme syntax is:
322 * db_scheme = name':'element[';'element]*
323 * element =
324 + 'uuid_col='string
325 + 'username_col='string
326 + 'domain_col='string
327 + 'value_col='string
328 + 'value_type='('integer'|'string')
329 + 'table='string
330
331 Default value is “NULL”.
332
333 Example 1.11. Set db_scheme parameter
334 ...
335 modparam("avpops","db_scheme",
336 "scheme1:table=subscriber;uuid_col=uuid;value_col=first_name")
337 ...
338
339 5. Functions
340
341 5.1. avp_db_load(source, name)
342 5.2. avp_db_store(source, name)
343 5.3. avp_db_delete(source, name)
344 5.4. avp_db_query(query[, dest])
345 5.5. avp_delete(name)
346 5.6. avp_pushto(destination, name)
347 5.7. avp_check(name, op_value)
348 5.8. avp_copy(old_name, new_name)
349 5.9. avp_printf(dest, format)
350 5.10. avp_subst(avps, subst)
351 5.11. avp_subst_pv(avps, subst)
352 5.12. avp_op(name, op_value)
353 5.13. is_avp_set(name)
354 5.14. avp_print()
355
356 5.1. avp_db_load(source, name)
357
358 Loads from DB into memory the AVPs corresponding to the given source.
359 If given, it sets the script flags for loaded AVPs. It returns true if
360 it loaded some values in AVPs, false otherwise (db error, no avp loaded
361 ...).
362
363 Meaning of the parameters is as follows:
364 * source - what info is used for identifying the AVPs. Parameter
365 syntax:
366 + source = (pvar|str_value)
367 ['/'('username'|'domain'|'uri'|'uuid')])
368 + pvar = any pseudo variable defined in Kamailio. If the pvar is
369 $ru (request uri), $fu (from uri), $tu (to uri) or $ou
370 (original uri), then the implicit flag is 'uri'. Otherwise,
371 the implicit flag is 'uuid'.
372 * name - which AVPs will be loaded from DB into memory. Parameter
373 syntax is:
374 + name = avp_spec['/'(table_name|'$'db_scheme)]
375 + avp_spec = matching_flags|$avp(avp_name)|$avp(avp_alias)
376 + matching_flags = 'a' | 'A' | 'i' | 'I' | 's' | 'S'
377 [script_flags]
378 'a' or 'A' means matching any of AVP name types ('i' and 's')
379 (NOTE: matching_flags cannot be used with $db_scheme because
380 the name of AVP to save in cannot be specified), the rest have
381 the meaning described in 'AVP naming format' chapter.
382
383 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
384 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
385
386 Example 1.12. avp_db_load usage
387 ...
388 avp_db_load("$fu","$(i:678)");
389 avp_db_load("$ru/domain","i:/domain_preferences");
390 avp_db_load("$uuid","$avp(s:404fwd)/fwd_table");
391 avp_db_load("$ru","$avp(i1:123)/$some_scheme");
392 ...
393
394 5.2. avp_db_store(source, name)
395
396 Stores to DB the AVPs corresponding to the given source.
397
398 The meaning and usage of the parameters are identical as for
399 avp_db_load(source,name) function. Please refer to its description.
400
401 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
402 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
403
404 Example 1.13. avp_db_store usage
405 ...
406 avp_db_store("$tu","$avp(i:678)");
407 avp_db_store("$ru/username","$avp(email)");
408 ...
409
410 5.3. avp_db_delete(source, name)
411
412 Deletes from DB the AVPs corresponding to the given source.
413
414 The meaning and usage of the parameters are identical as for
415 avp_db_load(source,name) function. Please refer to its description.
416
417 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
418 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
419
420 Example 1.14. avp_db_delete usage
421 ...
422 avp_db_delete("$tu","$avp(i:678)");
423 avp_db_delete("$ru/username","$avp(email)");
424 avp_db_delete("$uuid","$avp(s:404fwd)/fwd_table");
425 ...
426
427 5.4. avp_db_query(query[, dest])
428
429 Make a database query and store the result in AVPs. This command is
430 deprecated, please use the more flexible and advanced sqlops module
431 instead.
432
433 The meaning and usage of the parameters:
434 * query - must be a valid SQL query. The parameter can contain
435 pseudo-variables.
436 You must escape any pseudo-variables manually to prevent SQL
437 injection attacks. You can use the existing transformations
438 escape.common and unescape.common to escape and unescape the
439 content of any pseudo-variable. Failing to escape the variables
440 used in the query makes you vulnerable to SQL injection, e.g. make
441 it possible for an outside attacker to alter your database content.
442 * dest - a list with AVP names where to store the result. The format
443 is “$avp(name1);$avp(name2);...”. If this parameter is ommited, the
444 result is stored in “$avp(i:1);$avp(i:2);...”. If the result gives
445 many rows, then multiple AVPs with corresponding name will be
446 added. The value type of the AVP (string or integer) will be
447 derived from the type of the columns. Please note that only this
448 two datatypes are supported, so it is not possible for example to
449 return floating point or big integer values this way.
450
451 The function delivers the following return-codes:
452 * -1 - An error occurred while querying the database (e.g. wrong SQL
453 or database error)
454 * 1 - Query was successful
455 * -2 - Query was successful, but no rows where returned.
456
457 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
458 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
459
460 Example 1.15. avp_db_query usage
461 ...
462 avp_db_query("select password, ha1 from subscriber where username='$tu'",
463 "$avp(i:678);$avp(i:679)");
464 avp_db_query("delete from subscriber");
465 ...
466
467 5.5. avp_delete(name)
468
469 Deletes from memory the AVPs with name or, if empty, all AVPs.
470
471 Meaning of the parameters is as follows:
472 * name - which AVPs will be deleted from memory. Parameter syntax is:
473 + name = (matching_flags|avp_name|avp_alias)['/'flag]
474 + matching_flags = please refer to avp_db_load() function
475 + flag = 'g'|'G' = deletes not only the last value but the
476 complete AVP.
477
478 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
479 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
480
481 Example 1.16. avp_delete usage
482 ...
483 avp_delete("$avp(i:678)/g");
484 avp_delete("$avp(email)");
485 avp_delete("i");
486 avp_delete("a3");
487 ...
488
489 5.6. avp_pushto(destination, name)
490
491 Pushes the value of AVP(s) into the SIP message.
492
493 Meaning of the parameters is as follows:
494 * destination - as what will be the AVP value pushed into SIP
495 message. Parameter syntax:
496 + destination = '$ru' ['/'('username'|'domain')] | '$du' | '$br'
497 + $ru '['/'('username'|'domain')] - write the AVP in the request
498 URI or in username/domain part of it
499 + $du - write the AVP in 'dst_uri' field
500 + $br - write the AVP directly as a new branch (does not affect
501 RURI)
502 * name - which AVP(s)/pseudo-variable should be pushed into the SIP
503 message. Parameter syntax is:
504 + name = ( avp_name | avp_alias | pvar_name )['/'flags]
505 + flags = 'g' - effective only with AVPs
506
507 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
508 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
509
510 Example 1.17. avp_pushto usage
511 ...
512 avp_pushto("$ru/domain","$fd");
513 avp_pushto("$ru","$avp(i:678)");
514 avp_pushto("$ru/domain","$avp(s:backup_domains)/g");
515 avp_pushto("$du","$avp(i:679)");
516 avp_pushto("$br","$avp(i:680)");
517 ...
518
519 5.7. avp_check(name, op_value)
520
521 Checks the value of the AVP(s) against an operator and value.
522
523 Meaning of the parameters is as follows:
524 * name - which AVP(s) should be checked. Parameter syntax is:
525 + name = ( pseudo-variable )
526 * op_value - define the operator, the value and flags for checking.
527 Parameter syntax is:
528 + op_value = operator '/' value ['/'flags]
529 + operator = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' | 're' |
530 'fm' | 'and' | 'or' | 'xor'
531 + value = pseudo-variable | fix_value
532 + fix_value = 'i:'integer | 's:'string | string
533 + flags = 'g' | 'G' | 'i' | 'I'
534 Operator meaning:
535 + eq - equal
536 + ne - not equal
537 + lt - less than
538 + le - less or equal
539 + gt - greater than
540 + ge - greater or equal
541 + re - regexp (regular expression match)
542 + fm - fast match (see: man fnmatch)
543 + and - bitwise 'and'
544 + or - bitwise 'or'
545 + xor - bitwise 'xor'
546 Integer values can be given in hexadecimal using notation:
547 'i:0xhex_number' (e.g.,: 'i:0xabcd');
548
549 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
550 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
551
552 Example 1.18. avp_check usage
553 ...
554 avp_check("$avp(i:678)", "lt/i:345/g");
555 avp_check("$fd","eq/$td/I");
556 avp_check("$avp(s:foo)","gt/$avp($var(bar))/g");
557 avp_check("$avp(s:foo)","re/sip:.*@bar.net/g");
558 avp_check("$avp(s:foo)","fm/$avp(fm_avp)/g");
559 ...
560
561 NOTE: you can use a xavp variable ($xavp(key1[indx1]=>key2[indx2])) as
562 first or second parameter. If you want to check all the values of the
563 key2 you should use [*] at indx2. The [*] index is not allowed at
564 indx1.
565 ...
566 avp_check("$xavp(op[0]=>lt[0])", "lt/i:345/g");
567 avp_check("$xavp(op=>fd","eq/$td/I");
568 avp_check("$xavp(op[1]=>foo[*])","gt/$avp($var(bar))/g");
569 avp_check("$avp(s:foo)","re/$xavp(op[0]=>re[*]/g");
570 $var(id)=2;
571 avp_check("$xavp(op=>foo[*])","fm/$xavp(op=>fm[$var(id)])/g");
572 ...
573
574 5.8. avp_copy(old_name, new_name)
575
576 Copy / move an avp under a new name.
577
578 Meaning of the parameters is as follows:
579 * name1 - which AVP(s) should be copied/moved. Parameter syntax is:
580 + name = ( avp_name | avp_alias )
581 * name2 - the new name of the copied/moved AVP(s). Parameter syntax
582 is:
583 + name = ( avp_name | avp_alias ) ['/'flags]
584 + flags = 'g' | 'G' | 'd' | 'D' | 'n' | 'N' | 's' | 'S'
585
586 NOTE: if a list of AVPs is copied/moved (flag g|G), then the order of
587 the values is reversed. Copy/move twice in order to get the same order
588 as in original list.
589
590 This function can be used from ANY_ROUTE.
591
592 Example 1.19. avp_copy usage
593 ...
594 avp_copy("$avp(i:678)", "$avp(s:345)/g");
595 avp_copy("$avp(old)","$avp(new)/gd");
596 ...
597
598 5.9. avp_printf(dest, format)
599
600 NOTE: since Kamailio 1.3.0 the function has been moved to core and it
601 is an alias to pv_printf().
602
603 Prints the formatted string 'format' in the AVP 'dest'. The 'format'
604 parameter can include any pseudo-variable defined in Kamailio. The list
605 with all pseudo-variables in Kamailio can be found at:
606 https://www.kamailio.org/wikidocs/
607
608 Meaning of the parameters is as follows:
609 * dest - in which AVP should be stored the result. Parameter syntax
610 is:
611 + name = ( avp_name | avp_alias )
612 * format - the formatted string to be printed in 'dest' AVP.
613
614 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
615 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
616
617 Example 1.20. avp_printf usage
618 ...
619 avp_printf("$avp(i:20)", "This is a $rm request with call-id $hdr(call-id)");
620 ...
621
622 5.10. avp_subst(avps, subst)
623
624 Perl/sed-like subst applied to AVPs having string value.
625
626 Meaning of the parameters is as follows:
627 * avps - source AVP, destination AVP and flags. Parameter syntax is:
628 + avps = src_avp [ '/' dst_avp [ '/' flags ] ]
629 + src_avp = ( avp_name | avp_alias )
630 + dst_avp = ( avp_name | avp_alias ) - if dst_avp is missing
631 then the value of src_avp will be replaced
632 + flags = ( d | D | g | G ) -- (d, D - delete source avp; g, G -
633 apply to all avps matching src_avp name)
634 * subst - perl/sed-like reqular expression. Parameter syntax is:
635 + subst = "/regexp/replacement/flags"
636 + regexp - regular expression
637 + replacement - replacement string, can include pseudo-variables
638 and \1, ..., \9 for matching tokens, \0 for whole matching
639 text
640 + flags = 'g' | 'G' | 'i' | 'i' (g, G - replace all matching
641 tokens; i, I - match ignore case)
642
643 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
644 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
645
646 Example 1.21. avp_subst usage
647 ...
648 # if avp i:678 has a string value in e-mail format, replace the
649 # domain part with the value of domain part from R-URI
650 avp_subst("$avp(i:678)", "/(.*)@(.*)/\1@$rd/");
651
652 # if any avp i:678 has a string value in e-mail format, replace the
653 # domain part with the value of domain part from R-URI
654 # and place the result in avp i:679
655 avp_subst("$avp(i:678)/$avp(i:679)/g", "/(.*)@(.*)/\1@$rd/");
656 ...
657
658 IMPORTANT NOTE: if the replacement string includes src_avp or dst_avp
659 you will get something that you may not expect. In case you have many
660 src_avp and you make the substitution to be applied to all of them,
661 after the first src_avp is processed, it will be added in avp list and
662 next processing will use it.
663
664 5.11. avp_subst_pv(avps, subst)
665
666 Same functionality than avp_subst() but seccond parameter will be
667 evaluated first.
668
669 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
670 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
671
672 Example 1.22. avp_subst_pv usage
673 ...
674 $(avp(src)[*]) = "testME";
675 $var(z) = "j";
676 $var(y) = "e";
677 $var(x) = "/" + $var(y) + "/" + $var(z) + "/gi";
678
679 ## all this calls will produce the same result "tjstMj"
680 avp_subst_pv("$avp(src)", "/e/j/gi");
681 avp_subst_pv("$avp(src)", "/" + $var(y) + "/" + $var(z) + "/gi");
682 avp_subst_pv("$avp(src)", "/$var(y)/$var(z)/gi");
683 avp_subst_pv("$avp(src)", "$var(x)");
684 ...
685
686 5.12. avp_op(name, op_value)
687
688 Different integer operations with avps.
689
690 Meaning of the parameters is as follows:
691 * name - 'source_avp/destination_avp' - which AVP(s) should be
692 processed and where to store the result. If 'destination_avp' is
693 missing, same name as 'source_avp' is used to store the result.
694 Parameter syntax is:
695 + name = ( source_avp[/destination_avp] )
696 source_avp = ( avp_name | avp_alias )
697 destination_avp = ( avp_name | avp_alias )
698 * op_value - define the operation, the value and flags. Parameter
699 syntax is:
700 + op_value = operator '/' value ['/'flags]
701 + operator = 'add' | 'sub' | 'mul' | 'div' | 'mod' | 'and' |
702 'or' | 'xor' | 'not'
703 + value = pseudo-variable | fix_value
704 + fix_value = 'i:'integer
705 + flags = 'g' | 'G' | 'd' | 'D'
706 Integer values can be given in hexadecimal using notation
707 'i:0xhex_number' (e.g.,: 'i:0xabcd');
708
709 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
710 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
711
712 Example 1.23. avp_op usage
713 ...
714 avp_op("$avp(i:678)", "add/i:345/g");
715 avp_op("$avp(number)","sub/$avp(number2)/d");
716 ...
717
718 5.13. is_avp_set(name)
719
720 Check if any AVP with name is set.
721
722 Meaning of the parameters is as follows:
723 * name - name of AVP to look for. Parameter syntax is:
724 + name = avp_name|avp_alias [ '/' flags ])
725 flags = ('e'|'s'|'n') - e = empty value; s = value string; n =
726 value number (int)
727
728 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
729 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
730
731 Example 1.24. is_avp_set usage
732 ...
733 if(is_avp_set("$avp(i:678)"))
734 log("AVP with integer id 678 exists\n");
735 ...
736
737 5.14. avp_print()
738
739 Prints the list with all the AVPs from memory. This is only a
740 helper/debug function.
741
742 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
743 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
744
745 Example 1.25. avp_print usage
746 ...
747 avp_print();
748 ...