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
Next revision Both sides next revision
cookbooks:pseudo-variables:devel [2011/07/03 20:17]
85.178.64.4
cookbooks:pseudo-variables:devel [2011/11/08 14:00]
182.3.198.58 [AVPs]
Line 453: Line 453:
  
 **$ua** - reference to user agent header field **$ua** - reference to user agent header field
-==== AVPs ====+ 
 +===== AVPs ====
 + 
 +**$avp(id)** - the value of the AVP identified by 'id'.
  
 **$(avp(id)[N])** - represents the value of N-th AVP identified by 'id'. **$(avp(id)[N])** - represents the value of N-th AVP identified by 'id'.
Line 460: Line 463:
  
 * "[si]:name" - name is the id of an AVP; 's' and 'i' specifies if the id is string or integer. If missing, it is considered to be string. * "[si]:name" - name is the id of an AVP; 's' and 'i' specifies if the id is string or integer. If missing, it is considered to be string.
-* "name" - the name is an AVP alias 
  
-$(avp(id)[0]) can be written in shorter form as $avp(id) and $avp(s:name) as $name.+* "name" - the name is an AVP alias, or if the alias is not found, it is a string name 
 + 
 +* pseudo variable - if value of pv is integer, id is integer, if string, id is string 
 + 
 +$(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. 
 + 
 +To delete the first AVP with name 'id' you have to assign to it '$null': 
 +<code c> 
 +$avp(id) = $null; 
 +</code> 
 + 
 +To delete all the AVP with name 'id' you have to assign $null to the index '*': 
 +<code c> 
 +$(avp(id)[*]) = $null; 
 +</code> 
 + 
 +To overwrite the value f the AVP with name 'id' you have to assign the new value to the index '*': 
 +<code c> 
 +$(avp(id)[*]) = newvalue; 
 +</code> 
 + 
 +The value of an AVP can be integer or string. To assign a value as string, it has to be enclosed in double quotes. To assign the value as integer, it has to be a valid number given without quotes. 
 + 
 +Example of usage: 
 + 
 +<code c> 
 +$avp(x) = 1;  # assign of integer value 
 +$avp(x) = 2; 
 +$avp(y) = "abc"; # assign of string value 
 +if($(avp(x)[1])==1) { 
 +  ... 
 +
 +$(avp(x)[1]) = $null; 
 +</code>
  
  
Line 468: Line 505:
  
  
-==== Headers ====+===== Headers =====
  
  
-**$(hdr(name)[N])** - represents the body of the N-th header identified by 'name'. If [N] is omitted then the body of the first header is printed. The first header is got when N=0, for the second N=1, a.s.o. In case of a comma-separated multi-body headers, it returns all the bodies, comma-separated. To print the last header of that type, use -1, no other negative values are supported now. No white spaces are allowed inside the specifier (before }, before or after {, [, ] symbols). When N='*', all headers of that type are printed.+**$hdr(name)** - represents the body of first header identified by 'name'
  
-The module should identify most of compact header names (the ones recognised by SIP-Router which should be all at this moment), if not, the compact form has to be specified explicitly. It is recommended to use dedicated specifiers for headers (e.g., %ua for user agent header), if they are available -- they are faster.+**$(hdr(name)[N])** represents the body of the N-th header identified by 'name'.
  
-==== Script variables ====+If [N] is omitted then the body of the first header is printed. The first header is got when N=0, for the second N=1, a.s.o. In case of a comma-separated multi-body headers, it returns all the bodies, comma-separated. To print the last header of that type, use -1, or other negative values to count from the end. No white spaces are allowed inside the specifier (before }, before or after {, [, ] symbols). When N='*', all headers of that type are printed. 
 + 
 +The module should identify compact header names. It is recommended to use dedicated specifiers for headers (e.g., $ua for user agent header), if they are available -- they are faster. 
 + 
 +Example of usage: 
 + 
 +<code c> 
 +if($hdr(From)=~"sip-router\.org") { 
 +... 
 +
 +</code> 
 + 
 +<hi #d0d0d0>It is read-only variable. You can remove or add headers using functions from textops module.</hi> 
 + 
 +===== Script private variables =====
  
 **$var(name)** - refers to variables that can be used in configuration script, having integer or string value. This kind of variables are faster the AVPs, being referenced directly to memory location. The value of script variables persists over the processing of SIP messages, being specific per each SIP-Router process. **$var(name)** - refers to variables that can be used in configuration script, having integer or string value. This kind of variables are faster the AVPs, being referenced directly to memory location. The value of script variables persists over the processing of SIP messages, being specific per each SIP-Router process.
Line 500: Line 551:
 [b]pv[/b] module can be used to initialise the script variables. [b]pv[/b] module can be used to initialise the script variables.
  
-==== Shared variables ====+===== Script shared variables =====
  
 **$shv(name)**  - it is a class of pseudo-variables stored in shared memory. The value of $shv(name) is visible across all openser processes. Each “shv” has single value and it is initialised to integer 0. You can use “shvset” parameter of **pv module** to initialize the shared variable. The module exports a set of MI functions to get/set the value of shared variables. **$shv(name)**  - it is a class of pseudo-variables stored in shared memory. The value of $shv(name) is visible across all openser processes. Each “shv” has single value and it is initialised to integer 0. You can use “shvset” parameter of **pv module** to initialize the shared variable. The module exports a set of MI functions to get/set the value of shared variables.
Line 517: Line 568:
  
 <hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi> <hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>
-==== Broken-down time ====+ 
 +===== Broken-down time =====
  
 **$time(name)** - the PV provides access to broken-down time attributes. **$time(name)** - the PV provides access to broken-down time attributes.
Line 542: Line 594:
 </code> </code>
  
-==== Selects ====+===== Selects =====
  
 **$sel(name)** - return the value of **select** specified by name. **select** refers a class of config variables introduced by SER 2.0, allowing to select and return parts of sip messages and not only. **$sel(name)** - return the value of **select** specified by name. **select** refers a class of config variables introduced by SER 2.0, allowing to select and return parts of sip messages and not only.
Line 558: Line 610:
 } }
 </code> </code>
-==== Send Addr Attributes ==== 
  
-**$snd(name)** - return attributes of the address where the request is going to be sent. They are available in **onsend_route**. The name can be:+===== Send Address Attributes ===== 
 + 
 +**$snd(name)** - return attributes of the address from where the request is going to be sent (local socket). 
 + 
 +**$sndfrom(name)** - return attributes of the address from where the request is going to be sent (local socket, same as $snd(name)). 
 + 
 +**$sndto(name)** - return attributes of the address to where the request is going to be sent (remote socket). 
 + 
 +They are available in **onsend_route**. The name can be:
  
   * ip - IP address of destination   * ip - IP address of destination
Line 969: Line 1028:
  
 </code> </code>
 +
 +===== XHTTP module Pseudo-Variables =====
 +
 +==== $hu ====
 +
 +  * URL of http request.
 +
  
 ===== Special pseudo-variables - Escape Sequences ===== ===== Special pseudo-variables - Escape Sequences =====

Navigation

Wiki

Other

QR Code
QR Code cookbooks:pseudo-variables:devel (generated for current page)