User Tools

Site Tools


cookbooks:5.3.x:pseudovariables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
cookbooks:5.3.x:pseudovariables [2020/04/02 21:35]
miconda [$xavp(id) - XAVPs]
cookbooks:5.3.x:pseudovariables [2020/04/02 21:45]
miconda [$xavp(id) - XAVPs]
Line 722: Line 722:
 ===== $xavp(id) - XAVPs ===== ===== $xavp(id) - XAVPs =====
  
-**xavp** - eXtended AVPs - are variables that can store multiple values, which can also be grouped in a structure-like fashion. Their value can be a string, an integer number or a list of named values.+**xavp** - eXtended AVPs - are variables that can store multiple values, which can also be grouped in a structure-like fashion. Their value can be a string, an integer number or a list of named values (child values).
  
 They work like a stack, similar to AVPs, and are attached to SIP transactions and automatically destroyed when the transaction is finished. They work like a stack, similar to AVPs, and are attached to SIP transactions and automatically destroyed when the transaction is finished.
  
-Each xavp has a string name and can contain a string, and integer or a list of named value. The structure name (or root list name) and the value name (or field name) are separated by <nowiki>=></nowiki> like <nowiki>$xavp(root=>field)</nowiki> where "root" is the name of the structure and "field" is the name of the value.+Each xavp has a string name and can contain a string, and integer or a list of named values. The structure name (or root list name) and the value name (or field name, or child value name) are separated by <nowiki>=></nowiki> like <nowiki>$xavp(root=>field)</nowiki> where "root" is the name of the structure and "field" is the name of the (child) value.
  
 To assign a single value use: To assign a single value use:
Line 751: Line 751:
  
 <code c> <code c>
-# new item (example => [(name = "one")]) +# new item (person => [(lastname = "Smith")]) 
-$xavp(example=>name)="one";+$xavp(person=>lastname)="Smith";
  
-# add new item (example => [(name = "two")]) +# add new item (person => [(lastname = "Doe")]) 
-$xavp(example=>name)="two";+$xavp(person=>name)="Doe";
  
 # add another named value to the last example item # add another named value to the last example item
-#   (example => [(value="John"), (name = "one")]) +#   (person => [(firstname="John"), (lastname = "Doe")]) 
-$xavp(example[0]=>value)="John";+$xavp(person[0]=>firstname)="John";
  
 # add another named value to first example item # add another named value to first example item
-#   (example => [(value="Ana"), (name = "one")]) +#   (person => [(firstname="Alice"), (lastname = "Smith")]) 
-xavp(example[1]=>value)="Anna";+xavp(person[1]=>firstname)="Alice";
 </code> </code>
  
Line 769: Line 769:
 Another example: Another example:
 <code c> <code c>
-Create new xavp+create new (the first) root xavp with a named value of string type
 $xavp(sf=>uri)="sip:10.10.10.10"; $xavp(sf=>uri)="sip:10.10.10.10";
  
-#assign values+add named values (child values)
 $xavp(sf[0]=>fr_timer)=10; $xavp(sf[0]=>fr_timer)=10;
 $xavp(sf[0]=>fr_inv_timer)=15; $xavp(sf[0]=>fr_inv_timer)=15;
 $xavp(sf[0]=>headers)="X-CustomerID: 1234\r\n"; $xavp(sf[0]=>headers)="X-CustomerID: 1234\r\n";
  
-#create new xavp, moving previous one to sf[1]+# create new (the second) root xavp with a named value of string type, moving previous one to sf[1]
 $xavp(sf=>uri)="sip:10.10.10.11"; $xavp(sf=>uri)="sip:10.10.10.11";
 +# add named values (child values)
 $xavp(sf[0]=>fr_timer)=20; $xavp(sf[0]=>fr_timer)=20;
 $xavp(sf[0]=>fr_inv_timer)=35; $xavp(sf[0]=>fr_inv_timer)=35;
  
-#Create a third xavp+create new (the thirdxavp with a named value of string type, moving previous one to sf[1] and the other one to sf[2]
 $xavp(sf=>uri)="sip:10.10.10.12"; $xavp(sf=>uri)="sip:10.10.10.12";
 +# add named values (child values)
 $xavp(sf[0]=>fr_timer)=10; $xavp(sf[0]=>fr_timer)=10;
 $xavp(sf[0]=>fr_inv_timer)=15; $xavp(sf[0]=>fr_inv_timer)=15;
Line 789: Line 791:
 </code> </code>
  
-xavps are read and write variables. You can create multilevel xavps, as xavps may contain xavps.+xavps are read and write variables.
  
 ===== $hdr(name) - Headers ===== ===== $hdr(name) - Headers =====
cookbooks/5.3.x/pseudovariables.txt · Last modified: 2020/04/06 18:09 by pojogas