1 <?xml version="1.0" encoding='ISO-8859-1'?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
5 <!-- Include general documentation entities -->
6 <!ENTITY % docentities SYSTEM "../../../../doc/docbook/entities.xml">
11 <!-- Module User's Guide -->
15 <title>&adminguide;</title>
19 <title>Overview</title>
21 The AVPops (AVP-operations) module implements a set of script
22 functions which allow access and manipulation of user attribute-value pairs (AVPs,
23 preferences) and pseudo-variables. AVPs are a powerful tool
24 for implementing services/preferences per user/domain. With this module, they
25 are usable directly from configuration script. </para>
26 <para>The module implement functions for
27 interfacing DB resources (loading/storing/removing), functions
28 for swapping information between AVPs and SIP messages and a function for
29 testing/checking the value of an AVP.
32 If you just need a way to execute SQL statements in a
33 &kamailio; configuration script, please consider use the
34 <emphasis>sqlops</emphasis> module instead.
37 AVPs are persistent per SIP transaction, being available in "route",
38 "branch_route" and "failure_route". A tutorial providing more information (detailed
39 explanations and commented examples) can be found on the SIP-router web site.
43 <title>Dependencies</title>
45 <title>&kamailio; Modules</title>
47 The following modules must be loaded before this module:
51 <emphasis>Optionally a database module</emphasis>
58 <title>External Libraries or Applications</title>
60 The following libraries or applications must be installed
61 before running &kamailio; with this module loaded:
65 <emphasis>None</emphasis>
74 <title>AVP naming format</title>
76 The format of the parameters specifying an AVP in functions exported
78 <emphasis role="bold">$avp(avp_flags:avp_name)</emphasis> or
79 <emphasis role="bold">$avp(avp_alias)</emphasis>.
84 <emphasis>avp_flags</emphasis> = type_flags [script_flags]; type_flags = 'I' | 'i' | 'S' | 's'; script_flags = 0..255
87 'I' or 'i' means that the type of avp name is an integer (ID)
90 'S' or 's' means that the type of avp name is string
93 The type flag is mandatory.
94 Please note that the type flag only indicates type of name, not type of variable. An avp with name type "i" may very well contain text strings.
97 script_flags must be an 8 bit unsigned number, therefore can be set
98 up to 8 flags. If no script flag is provided, the name will
99 match all AVPs, regardless they have or not a script flag set (preserves
100 the compatibility with the old naming schema).
105 <emphasis>avp_name</emphasis> = string | integer
108 string - might be any alphanumeric string, wich contain following
109 characters: [a-z] [A-Z] [0-9] '_'
112 integer - might be an unsigned integer, greater than zero, up to 2^16-1
117 <emphasis>avp_alias</emphasis> = string
120 string - might be any alphanumeric string, wich contain following
121 characters: [a-z] [A-Z] [0-9] '_'
126 <title>AVP naming examples</title>
127 <programlisting format="linespecific">
129 $avp(i:11) - the AVP identified by integer 11
130 $avp(s:foo) - the AVP identified by the string 'foo'
131 $avp(bar) - the AVP identified by the AVP alias 'bar'
132 $avp(i3:123) - the AVP identified by the integer 123 which has script flags 1
139 <title>Parameters</title>
140 <section id="avpops.p.db_url">
141 <title><varname>db_url</varname> (string)</title>
143 DB URL for database connection.
147 This parameter is optional, it's default value being NULL.
151 <title>Set <varname>db_url</varname> parameter</title>
152 <programlisting format="linespecific">
154 modparam("avpops","db_url","mysql://user:passwd@host/database")
159 <section id="avpops.p.avp_table">
160 <title><varname>avp_table</varname> (string)</title>
166 This parameter is optional, it's default value being NULL. But if
167 you specify a db_url, you need also setup this parameter.
171 <title>Set <varname>avp_table</varname> parameter</title>
172 <programlisting format="linespecific">
174 modparam("avpops","avp_table","avptable")
179 <section id="avpops.p.use_domain">
180 <title><varname>use_domain</varname> (integer)</title>
182 If the domain part of the URI should be used for
183 identifying an AVP in DB operations.
186 <emphasis>Default value is 0 (no).
190 <title>Set <varname>use_domain</varname> parameter
192 <programlisting format="linespecific">
194 modparam("avpops","use_domain",1)
199 <section id="avpops.p.uuid_column">
200 <title><varname>uuid_column</varname> (string)</title>
202 Name of column containing the uuid (unique user id).
205 <emphasis>Default value is <quote>uuid</quote>.
209 <title>Set <varname>uuid_column</varname> parameter</title>
210 <programlisting format="linespecific">
212 modparam("avpops","uuid_column","uuid")
217 <section id="avpops.p.username_column">
218 <title><varname>username_column</varname> (string)</title>
220 Name of column containing the username.
223 <emphasis>Default value is <quote>username</quote>.
227 <title>Set <varname>username_column</varname> parameter</title>
228 <programlisting format="linespecific">
230 modparam("avpops","username_column","username")
235 <section id="avpops.p.domain_column">
236 <title><varname>domain_column</varname> (string)</title>
238 Name of column containing the domain name.
241 <emphasis>Default value is <quote>domain</quote>.
245 <title>Set <varname>domain_column</varname> parameter</title>
246 <programlisting format="linespecific">
248 modparam("avpops","domain_column","domain")
253 <section id="avpops.p.attribute_column">
254 <title><varname>attribute_column</varname> (string)</title>
256 Name of column containing the attribute name (AVP name).
259 <emphasis>Default value is <quote>attribute</quote>.
263 <title>Set <varname>attribute_column</varname> parameter
265 <programlisting format="linespecific">
267 modparam("avpops","attribute_column","attribute")
272 <section id="avpops.p.value_column">
273 <title><varname>value_column</varname> (string)</title>
275 Name of column containing the AVP value.
278 <emphasis>Default value is <quote>value</quote>.
282 <title>Set <varname>value_column</varname> parameter
284 <programlisting format="linespecific">
286 modparam("avpops","value_column","value")
291 <section id="avpops.p.type_column">
292 <title><varname>type_column</varname> (string)</title>
294 Name of integer column containing the AVP type.
297 <emphasis>Default value is <quote>type</quote>.
301 Possible column values are
303 <listitem><para><emphasis>
304 0 - AVP with string name and string value
305 </emphasis></para></listitem>
306 <listitem><para><emphasis>
307 1 - AVP with string name and integer value
308 </emphasis></para></listitem>
309 <listitem><para><emphasis>
310 2 - AVP with integer name and string value
311 </emphasis></para></listitem>
312 <listitem><para><emphasis>
313 3 - AVP with integer name and integer value
314 </emphasis></para></listitem>
319 <title>Set <varname>type_column</varname> parameter
321 <programlisting format="linespecific">
323 modparam("avpops","type_column","type")
328 <section id="avpops.p.db_scheme">
329 <title><varname>db_scheme</varname> (string)</title>
331 Definition of a DB scheme to be used for non-standard
332 access to Database information.
335 Definition of a DB scheme. Scheme syntax is:
337 <listitem><para><emphasis>
338 db_scheme = name':'element[';'element]*
339 </emphasis></para></listitem>
340 <listitem><para><emphasis>element</emphasis> =
342 <listitem><para>'uuid_col='string
344 <listitem><para>'username_col='string
346 <listitem><para>'domain_col='string
348 <listitem><para>'value_col='string
350 <listitem><para>'value_type='('integer'|'string')
352 <listitem><para>'table='string
359 <emphasis>Default value is <quote>NULL</quote>.
363 <title>Set <varname>db_scheme</varname> parameter
365 <programlisting format="linespecific">
367 modparam("avpops","db_scheme",
368 "scheme1:table=subscriber;uuid_col=uuid;value_col=first_name")
377 <title>Functions</title>
378 <section id="avpops.f.avp_db_load">
380 <function moreinfo="none">avp_db_load(source,name)
384 Loads from DB into memory the AVPs corresponding to the given
385 <emphasis>source</emphasis>. If given, it sets the script flags
386 for loaded AVPs. It returns true if it loaded some values
387 in AVPs, false otherwise (db error, no avp loaded ...).
389 <para>Meaning of the parameters is as follows:</para>
392 <para><emphasis>source</emphasis> - what info is used for
393 identifying the AVPs. Parameter syntax:
395 <listitem><para><emphasis>
396 source = (pvar|str_value)
397 ['/'('username'|'domain'|'uri'|'uuid')])
398 </emphasis></para></listitem>
399 <listitem><para><emphasis>
400 pvar = any pseudo variable defined in &kamailio;. If
401 the pvar is $ru (request uri), $fu (from uri), $tu (to uri)
402 or $ou (original uri), then the implicit flag is 'uri'.
403 Otherwise, the implicit flag is 'uuid'.
404 </emphasis></para></listitem>
409 <para><emphasis>name</emphasis> - which AVPs will be loaded
410 from DB into memory. Parameter syntax is:
412 <listitem><para><emphasis>
413 name = avp_spec['/'(table_name|'$'db_scheme)]
414 </emphasis></para></listitem>
415 <listitem><para><emphasis>
416 avp_spec = matching_flags|$avp(avp_name)|$avp(avp_alias)
417 </emphasis></para></listitem>
418 <listitem><para><emphasis>
419 matching_flags = 'a' | 'A' | 'i' | 'I' | 's' | 'S'
421 </emphasis></para><para>'a' or 'A' means matching any of
422 AVP name types ('i' and 's') (NOTE: matching_flags cannot
423 be used with $db_scheme because the name of AVP to save in
424 cannot be specified), the rest have the
425 meaning descriped in 'AVP naming format' chapter.</para>
432 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
433 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
437 <title><function>avp_db_load</function> usage</title>
438 <programlisting format="linespecific">
440 avp_db_load("$fu","$(i:678)");
441 avp_db_load("$ru/domain","i:/domain_preferences");
442 avp_db_load("$uuid","$avp(s:404fwd)/fwd_table");
443 avp_db_load("$ru","$avp(i1:123)/$some_scheme");
448 <section id="avpops.f.avp_db_store">
450 <function moreinfo="none">avp_db_store(source,name)</function>
453 Stores to DB the AVPs corresponding to the given
454 <emphasis>source</emphasis>.
456 <para>The meaning and usage of the parameters are identical as for
457 <emphasis>avp_db_load(source,name)</emphasis>
458 function. Please refer to its description.
461 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
462 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
466 <title><function>avp_db_store</function> usage</title>
467 <programlisting format="linespecific">
469 avp_db_store("$tu","$avp(i:678)");
470 avp_db_store("$ru/username","$avp(email)");
475 <section id="avpops.f.avp_db_delete">
477 <function moreinfo="none">avp_db_delete(source,name)</function>
480 Deletes from DB the AVPs corresponding to the given
481 <emphasis>source</emphasis>.
483 <para>The meaning and usage of the parameters are identical as for
484 <emphasis>avp_db_load(source,name)</emphasis>
485 function. Please refer to its description.
488 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
489 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
492 <title><function>avp_db_delete</function> usage</title>
493 <programlisting format="linespecific">
495 avp_db_delete("$tu","$avp(i:678)");
496 avp_db_delete("$ru/username","$avp(email)");
497 avp_db_delete("$uuid","$avp(s:404fwd)/fwd_table");
502 <section id="avpops.f.avp_db_query">
504 <function moreinfo="none">avp_db_query(query[,dest])</function>
507 Make a database query and store the result in AVPs.
508 This command is deprecated, please use the more
509 flexible and advanced <emphasis>sqlops</emphasis> module instead.
512 The meaning and usage of the parameters:
516 <para><emphasis>query</emphasis> - must be a valid SQL
517 query. The parameter can contain pseudo-variables.</para>
518 <para>You must escape any pseudo-variables manually to prevent
519 SQL injection attacks. You can use the existing transformations
520 <emphasis>escape.common</emphasis> and
521 <emphasis>unescape.common</emphasis>
522 to escape and unescape the content of any pseudo-variable.
523 Failing to escape the variables used in the query makes you
524 vulnerable to SQL injection, e.g. make it possible for an
525 outside attacker to alter your database content.
529 <para><emphasis>dest</emphasis> - a list with AVP names where
530 to store the result. The format is
531 <quote>$avp(name1);$avp(name2);...</quote>. If this parameter
532 is ommited, the result is stored in
533 <quote>$avp(i:1);$avp(i:2);...</quote>. If the result gives
534 many rows, then multiple AVPs with corresponding name will
535 be added. The value type of the AVP (string or integer) will
536 be derived from the type of the columns. Please note that only
537 this two datatypes are supported, so its not possible for
538 example to return floating point or big integer values this way.
542 <para>The function delivers the following return-codes:</para>
545 <emphasis>-1</emphasis> - An error occurred while querying the database
546 (e.g. wrong SQL or database error)
549 <emphasis>1</emphasis> - Query was successful
552 <emphasis>-2</emphasis> - Query was successful, but no rows where returned.
556 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
557 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
560 <title><function>avp_db_query</function> usage</title>
561 <programlisting format="linespecific">
563 avp_db_query("select password, ha1 from subscriber where username='$tu'",
564 "$avp(i:678);$avp(i:679)");
565 avp_db_query("delete from subscriber");
570 <section id="avpops.f.avp_delete">
572 <function moreinfo="none">avp_delete(name)
576 Deletes from memory the AVPs with <emphasis>name</emphasis> or,
579 <para>Meaning of the parameters is as follows:</para>
582 <para><emphasis>name</emphasis> - which AVPs will be deleted
586 <listitem><para><emphasis>
587 name = (matching_flags|avp_name|avp_alias)['/'flag]
588 </emphasis></para></listitem>
589 <listitem><para><emphasis>
590 matching_flags = please refer to avp_db_load() function
591 </emphasis></para></listitem>
592 <listitem><para><emphasis>
593 flag = 'g'|'G' = deletes not only the last value but the complete AVP.
594 </emphasis></para></listitem>
600 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
601 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
604 <title><function>avp_delete</function> usage</title>
605 <programlisting format="linespecific">
607 avp_delete("$avp(i:678)/g");
608 avp_delete("$avp(email)");
615 <section id="avpops.f.avp_pushto">
617 <function moreinfo="none">avp_pushto(destination,name)
621 Pushes the value of AVP(s) into the SIP message.
623 <para>Meaning of the parameters is as follows:</para>
626 <para><emphasis>destination</emphasis> - as what will be the
627 AVP value pushed into SIP message.
630 <listitem><para><emphasis>
631 destination = '$ru' ['/'('username'|'domain')] | '$du' |
633 </emphasis></para></listitem>
634 <listitem><para><emphasis>
635 $ru '['/'('username'|'domain')] - write the AVP in the
636 request URI or in username/domain part of it
637 </emphasis></para></listitem>
638 <listitem><para><emphasis>
639 $du - write the AVP in 'dst_uri' field
640 </emphasis></para></listitem>
641 <listitem><para><emphasis>
642 $br - write the AVP directly as a new branch (does not
644 </emphasis></para></listitem>
649 <para><emphasis>name</emphasis> - which AVP(s)/pseudo-variable
651 into the SIP message.
654 <listitem><para><emphasis>
655 name = ( avp_name | avp_alias | pvar_name )['/'flags]
656 </emphasis></para></listitem>
657 <listitem><para><emphasis>
658 flags = 'g' - effective only with AVPs
659 </emphasis></para></listitem>
665 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
666 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
669 <title><function>avp_pushto</function> usage</title>
670 <programlisting format="linespecific">
672 avp_pushto("$ru/domain","$fd");
673 avp_pushto("$ru","$avp(i:678)");
674 avp_pushto("$ru/domain","$avp(s:backup_domains)/g");
675 avp_pushto("$du","$avp(i:679)");
676 avp_pushto("$br","$avp(i:680)");
681 <section id="avpops.f.avp_check">
683 <function moreinfo="none">avp_check(name,op_value)
687 Checks the value of the AVP(s) against an operator and value.
689 <para>Meaning of the parameters is as follows:</para>
692 <para><emphasis>name</emphasis> - which AVP(s) should be
696 <listitem><para><emphasis>
697 name = ( pseudo-variable )
698 </emphasis></para></listitem>
703 <para><emphasis>op_value</emphasis> - define the operator,
704 the value and flags for checking.
708 <listitem><para><emphasis>
709 op_value = operator '/' value ['/'flags]
710 </emphasis></para></listitem>
711 <listitem><para><emphasis>
712 operator = 'eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge'
713 | 're' | 'fm' | 'and' | 'or' | 'xor'
714 </emphasis></para></listitem>
715 <listitem><para><emphasis>
716 value = pseudo-variable | fix_value
717 </emphasis></para></listitem>
718 <listitem><para><emphasis>
719 fix_value = 'i:'integer | 's:'string | string
720 </emphasis></para></listitem>
721 <listitem><para><emphasis>
722 flags = 'g' | 'G' | 'i' | 'I'
723 </emphasis></para></listitem>
729 <listitem><para><emphasis>eq
730 </emphasis> - equal</para></listitem>
731 <listitem><para><emphasis>ne
732 </emphasis> - not equal</para></listitem>
733 <listitem><para><emphasis>lt
734 </emphasis> - less than</para></listitem>
735 <listitem><para><emphasis>le
736 </emphasis> - less or equal</para></listitem>
737 <listitem><para><emphasis>gt
738 </emphasis> - greater than</para></listitem>
739 <listitem><para><emphasis>ge
740 </emphasis> - greater or equal</para></listitem>
741 <listitem><para><emphasis>re
742 </emphasis> - regexp (regular exression match)</para>
744 <listitem><para><emphasis>fm
745 </emphasis> - fast match (see: man fnmatch)</para>
747 <listitem><para><emphasis>and
748 </emphasis> - bitwise 'and'</para></listitem>
749 <listitem><para><emphasis>or
750 </emphasis> - bitwise 'or'</para></listitem>
751 <listitem><para><emphasis>xor
752 </emphasis> - bitwise 'xor'</para></listitem>
755 Integer values can be given in hexadecimal using notation:
756 'i:0xhex_number' (e.g.,: 'i:0xabcd');
761 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
762 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
765 <title><function>avp_check</function> usage</title>
766 <programlisting format="linespecific">
768 avp_check("$avp(i:678)", "lt/i:345/g");
769 avp_check("$fd","eq/$td/I");
770 avp_check("$avp(s:foo)","gt/$avp($var(bar))/g");
771 avp_check("$avp(s:foo)","re/sip:.*@bar.net/g");
772 avp_check("$avp(s:foo)","fm/$avp(fm_avp)/g");
775 <para>NOTE: you can use a xavp variable ($xavp(key1[indx1]=>key2[indx2]))
776 as first or second parameter.
777 If you want to check all the values of the key2 you should
778 use [*] at indx2. The [*] index is not allowed at indx1.
780 <programlisting format="linespecific">
782 avp_check("$xavp(op[0]=>lt[0])", "lt/i:345/g");
783 avp_check("$xavp(op=>fd","eq/$td/I");
784 avp_check("$xavp(op[1]=>foo[*])","gt/$avp($var(bar))/g");
785 avp_check("$avp(s:foo)","re/$xavp(op[0]=>re[*]/g");
787 avp_check("$xavp(op=>foo[*])","fm/$xavp(op=>fm[$var(id)])/g");
792 <section id="avpops.f.avp_copy">
794 <function moreinfo="none">avp_copy(old_name,new_name)
798 Copy / move an avp under a new name.
800 <para>Meaning of the parameters is as follows:</para>
803 <para><emphasis>name1</emphasis> - which AVP(s) should be
807 <listitem><para><emphasis>
808 name = ( avp_name | avp_alias )
809 </emphasis></para></listitem>
814 <para><emphasis>name2</emphasis> - the new name of the
818 <listitem><para><emphasis>
819 name = ( avp_name | avp_alias ) ['/'flags]
820 </emphasis></para></listitem>
821 <listitem><para><emphasis>
822 flags = 'g' | 'G' | 'd' | 'D' | 'n' | 'N' | 's' | 'S'
823 </emphasis></para></listitem>
829 NOTE: if a list of AVPs is copied/moved (flag g|G), then the order
830 of the values is reversed. Copy/move twice in order to get the same
831 order as in original list.
834 This function can be used from ANY_ROUTE.
837 <title><function>avp_copy</function> usage</title>
838 <programlisting format="linespecific">
840 avp_copy("$avp(i:678)", "$avp(s:345)/g");
841 avp_copy("$avp(old)","$avp(new)/gd");
846 <section id="avpops.f.avp_printf">
848 <function moreinfo="none">avp_printf(dest, format)
852 NOTE: since &kamailio; 1.3.0 the function has been moved to core
853 and it is an alias to pv_printf().
856 Prints the formatted string 'format' in the AVP 'dest'. The
857 'format' parameter can include any pseudo-variable defined in
858 &kamailio;. The list with all pseudo-variables in &kamailio; can
860 <ulink url="http://kamailio.org/dokuwiki/">
861 http://kamailio.org/dokuwiki/</ulink>.
863 <para>Meaning of the parameters is as follows:</para>
866 <para><emphasis>dest</emphasis> - in which AVP should be
871 <listitem><para><emphasis>
872 name = ( avp_name | avp_alias )
873 </emphasis></para></listitem>
877 <para><emphasis>format</emphasis> - the formatted string
878 to be printed in 'dest' AVP.
883 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
884 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
887 <title><function>avp_printf</function> usage</title>
888 <programlisting format="linespecific">
890 avp_printf("$avp(i:20)", "This is a $rm request with call-id $hdr(call-id)");
895 <section id="avpops.f.avp_subst">
897 <function moreinfo="none">avp_subst(avps, subst)</function>
900 Perl/sed-like subst applied to AVPs having string value.
902 <para>Meaning of the parameters is as follows:</para>
905 <para><emphasis>avps</emphasis> - source AVP, destination AVP
906 and flags. Parameter syntax is:
908 <listitem><para><emphasis>
909 avps = src_avp [ '/' dst_avp [ '/' flags ] ]
910 </emphasis></para></listitem>
911 <listitem><para><emphasis>
912 src_avp = ( avp_name | avp_alias )
913 </emphasis></para></listitem>
914 <listitem><para><emphasis>
915 dst_avp = ( avp_name | avp_alias ) - if dst_avp is missing
916 then the value of src_avp will be replaced
917 </emphasis></para></listitem>
918 <listitem><para><emphasis>
919 flags = ( d | D | g | G ) -- (d, D - delete source avp;
920 g, G - apply to all avps matching src_avp name)
921 </emphasis></para></listitem>
926 <para><emphasis>subst</emphasis> - perl/sed-like reqular expression.
929 <listitem><para><emphasis>
930 subst = "/regexp/replacement/flags"
931 </emphasis></para></listitem>
932 <listitem><para><emphasis>
933 regexp - regular expression
934 </emphasis></para></listitem>
935 <listitem><para><emphasis>
936 replacement - replacement string, can include
937 pseudo-variables and \1, ..., \9 for matching tokens,
938 \0 for whole matching text
939 </emphasis></para></listitem>
940 <listitem><para><emphasis>
941 flags = 'g' | 'G' | 'i' | 'i' (g, G - replace all
942 matching tokens; i, I - match ignore case)
943 </emphasis></para></listitem>
949 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
950 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
953 <title><function>avp_subst</function> usage</title>
954 <programlisting format="linespecific">
956 # if avp i:678 has a string value in e-mail format, replace the
957 # domain part with the value of domain part from R-URI
958 avp_subst("$avp(i:678)", "/(.*)@(.*)/\1@$rd/");
960 # if any avp i:678 has a string value in e-mail format, replace the
961 # domain part with the value of domain part from R-URI
962 # and place the result in avp i:679
963 avp_subst("$avp(i:678)/$avp(i:679)/g", "/(.*)@(.*)/\1@$rd/");
968 IMPORTANT NOTE: if the replacement string includes src_avp
969 or dst_avp you will get something that you may not expect.
970 In case you have many src_avp and you make the substitution
971 to be applied to all of them, after the first src_avp is
972 processed, it will be added in avp list and next
973 processing will use it.
976 <section id="avpops.f.avp_op">
978 <function moreinfo="none">avp_op(name,op_value)
982 Different integer operations with avps.
984 <para>Meaning of the parameters is as follows:</para>
987 <para><emphasis>name</emphasis>
988 - 'source_avp/destination_avp' - which AVP(s) should be
989 processed and where to store the result. If 'destination_avp'
990 is missing, same name as 'source_avp' is used to store the
999 name = ( source_avp[/destination_avp] )
1002 source_avp = ( avp_name | avp_alias )
1005 destination_avp = ( avp_name | avp_alias )
1011 <para><emphasis>op_value</emphasis> - define the operation,
1012 the value and flags.
1013 Parameter syntax is:
1015 <listitem><para><emphasis>
1016 op_value = operator '/' value ['/'flags]
1017 </emphasis></para></listitem>
1018 <listitem><para><emphasis>
1019 operator = 'add' | 'sub' | 'mul' | 'div' | 'mod'
1020 | 'and' | 'or' | 'xor' | 'not'
1021 </emphasis></para></listitem>
1022 <listitem><para><emphasis>
1023 value = pseudo-variable | fix_value
1024 </emphasis></para></listitem>
1025 <listitem><para><emphasis>
1026 fix_value = 'i:'integer
1027 </emphasis></para></listitem>
1028 <listitem><para><emphasis>
1029 flags = 'g' | 'G' | 'd' | 'D'
1030 </emphasis></para></listitem>
1034 Integer values can be given in hexadecimal using notation
1035 'i:0xhex_number' (e.g.,: 'i:0xabcd');
1040 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
1041 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
1044 <title><function>avp_op</function> usage</title>
1045 <programlisting format="linespecific">
1047 avp_op("$avp(i:678)", "add/i:345/g");
1048 avp_op("$avp(number)","sub/$avp(number2)/d");
1053 <section id="avpops.f.is_avp_set">
1055 <function moreinfo="none">is_avp_set(name)
1059 Check if any AVP with <emphasis>name</emphasis> is set.
1061 <para>Meaning of the parameters is as follows:</para>
1064 <para><emphasis>name</emphasis> - name of AVP to look for.
1065 Parameter syntax is:
1067 <listitem><para><emphasis>
1068 name = avp_name|avp_alias [ '/' flags ])
1071 flags = ('e'|'s'|'n') - e = empty value; s = value string;
1072 n = value number (int)
1073 </emphasis></para></listitem>
1079 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
1080 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
1083 <title><function>is_avp_set</function> usage</title>
1084 <programlisting format="linespecific">
1086 if(is_avp_set("$avp(i:678)"))
1087 log("AVP with integer id 678 exists\n");
1092 <section id="avpops.f.avp_print">
1094 <function moreinfo="none">avp_print()
1098 Prints the list with all the AVPs from memory. This is only a
1099 helper/debug function.
1102 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
1103 BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
1106 <title><function>avp_print</function> usage</title>
1107 <programlisting format="linespecific">