User Tools

Site Tools


cookbooks:3.2.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
cookbooks:3.2.x:pseudovariables [2012/02/02 10:38]
klaus3000 [Username in SIP Request's URI]
cookbooks:3.2.x:pseudovariables [2012/05/03 13:35] (current)
klaus3000 [AVPs]
Line 482: Line 482:
 $(avp(id)[0]) can be written in shorter form as $avp(id) and $avp(s:name) as $avp(name). $(avp(id)[0]) can be written in shorter form as $avp(id) and $avp(s:name) as $avp(name).
  
-AVPs are special variables that are attached to SIP transactions. It is a list of pairs (name,value). Before the transaction is created, the AVP list is attached to SIP request. Note that the AVP list works like a stack, last added value is retrieved first, and there can be many values for same AVP name, an assignment to the same AVP name does not overwrite old value, it will add the new value in the list.+AVPs are special variables that are attached to SIP transactions. It is a list of pairs (name,value). Before the transaction is created, the AVP list is attached to SIP request. Note that the AVP list works like a stack, last added value is retrieved first, and there can be many values for same AVP name. An assignment to the same AVP name does not overwrite the existing AVPbut it will add an additional AVP to the list. When writing an AVP, the [N] index is ignored, except for [*].
  
 To delete the first AVP with name 'id' you have to assign to it '$null': To delete the first AVP with name 'id' you have to assign to it '$null':
Line 496: Line 496:
 To overwrite the value of the AVP with name 'id' you have to assign the new value to the index '*': To overwrite the value of the AVP with name 'id' you have to assign the new value to the index '*':
 <code c> <code c>
-$(avp(id)[*]) = newvalue;+$(avp(id)[*]) = newvalue; # delete all existing AVPs with name 'id' and create a single AVP with newvalue
 </code> </code>
  
Line 506: Line 506:
 $avp(x) = 1;  # assign of integer value $avp(x) = 1;  # assign of integer value
 $avp(x) = 2; $avp(x) = 2;
 +$avp(x) = 3;
 +# now: $avp(x) = $(avp(x)[0]) = 3, $(avp(x)[1]) = 2, $(avp(x)[2]) = 1
 $avp(y) = "abc"; # assign of string value $avp(y) = "abc"; # assign of string value
-if($(avp(x)[1])==1) {+if($(avp(x)[2])==1) { # TRUE
   ...   ...
 } }
-$(avp(x)[1]) = $null;+$(avp(x)[1]) = $null; # index will be ignored and top element removed from list 
 +# now: $avp(x) = $(avp(x)[0]) = 2, $(avp(x)[1]) = 1 
 +$(avp(x)[*]) = $null; # all AVPs 'x' are deleted
 </code> </code>
  
cookbooks/3.2.x/pseudovariables.1328175518.txt.gz · Last modified: 2012/02/02 10:38 by klaus3000