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 [2011/11/30 09:26]
85.178.74.216 [$shtcn(htable=>regexp)]
cookbooks:3.2.x:pseudovariables [2012/05/03 13:35] (current)
klaus3000 [AVPs]
Line 9: Line 9:
 There is a set of predefined pseudo-variables, which have the name composed from one or more characters, and special pseudo-variables that are references to dynamic fields (AVP and Headers). There is a set of predefined pseudo-variables, which have the name composed from one or more characters, and special pseudo-variables that are references to dynamic fields (AVP and Headers).
  
-Pseudo-Variables are implemented by various modules, most of them are provided by [b]pv[/b].+Pseudo-Variables are implemented by various modules, most of them are provided by **pv**.
  
 ===== Pseudo-variables usage ===== ===== Pseudo-variables usage =====
Line 112: Line 112:
 **$br** - reference to request's first branch **$br** - reference to request's first branch
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file (will add a new branch).</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file (will add a new branch).</fc>
  
 ==== Request's all branches ==== ==== Request's all branches ====
Line 190: Line 190:
 $du is also set if lookup() function of 'registrar' module finds contact(s) behind NAT. $du is also set if lookup() function of 'registrar' module finds contact(s) behind NAT.
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 To reset $du: To reset $du:
Line 244: Line 244:
 **$mf** - reference to message/transaction flags set for current SIP request **$mf** - reference to message/transaction flags set for current SIP request
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== Flags in hexadecimal ==== ==== Flags in hexadecimal ====
Line 250: Line 250:
 **$mF** -reference to message/transaction flags set for current SIP request in hexa-decimal **$mF** -reference to message/transaction flags set for current SIP request in hexa-decimal
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== SIP message id ==== ==== SIP message id ====
Line 259: Line 259:
  
 **$ml** - reference to SIP message length **$ml** - reference to SIP message length
 +
 +==== SIP Message Type ====
 +
 +**$mt** - returns 1 if the sip message is a request, returns 2 if the sip message is a reply
 +
  
 ==== Domain in SIP Request's original URI ==== ==== Domain in SIP Request's original URI ====
Line 310: Line 315:
 **$rd** - reference to domain in request's URI **$rd** - reference to domain in request's URI
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== Body of request/reply ==== ==== Body of request/reply ====
Line 331: Line 336:
  
 **$rm** - reference to request's method. Works also for replies (by using the CSeq header) **$rm** - reference to request's method. Works also for replies (by using the CSeq header)
 +
 +==== Request Method ID ====
 +
 +**$rmid** - returns internal integer representation of SIP method type
 +
  
 ==== SIP request's port ==== ==== SIP request's port ====
Line 336: Line 346:
 **$rp** - reference to port of R-URI **$rp** - reference to port of R-URI
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== Transport protocol of SIP request URI ==== ==== Transport protocol of SIP request URI ====
Line 358: Line 368:
 **$ru** - reference to request's URI **$ru** - reference to request's URI
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== Username in SIP Request's URI ==== ==== Username in SIP Request's URI ====
Line 364: Line 374:
 **$rU** - reference to username in request's URI **$rU** - reference to username in request's URI
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc> 
 + 
 +==== URI Scheme of Request URI ==== 
 + 
 +**$rz** - returns R-URI scheme, possible values: sip, sips, tel and tels, R-URI scheme parsing error should be reflected by value: none
  
 ==== Received IP address ==== ==== Received IP address ====
Line 399: Line 413:
 **$fs** - reference to the forced socket for message sending (if any) in the form proto:ip:port **$fs** - reference to the forced socket for message sending (if any) in the form proto:ip:port
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== To URI Domain ==== ==== To URI Domain ====
Line 462: Line 476:
 The 'id' can be: The 'id' can be:
  
-* "[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. +  * "[(s|i):]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, or if the alias is not found, it is a string 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). $(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 481: 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 491: 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>
  
Line 520: Line 539:
 </code> </code>
  
-<hi #d0d0d0>It is read-only variable. You can remove or add headers using functions from textops module.</hi>+<fc #0000ff>It is read-only variable. You can remove or add headers using functions from textops module.</fc>
  
 ===== Script private variables ===== ===== Script private variables =====
Line 543: Line 562:
 **Note:** A script variable persists over the SIP-Router process in which it was initialized, so be sure of giving it a new value before reading it or you'll get the value asigned in any other previous message processed by the same SIP-Router process (pid). **Note:** A script variable persists over the SIP-Router process in which it was initialized, so be sure of giving it a new value before reading it or you'll get the value asigned in any other previous message processed by the same SIP-Router process (pid).
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000FF>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
-[b]pv[/b] module can be used to initialise the script variables.+**pv** module can be used to initialize the script variables.
  
 ===== Script shared variables ===== ===== Script shared variables =====
Line 563: Line 582:
 </code> </code>
  
-<hi #d0d0d0>It is R/W variable (you can assign values to it directly in configuration file)</hi>+<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ===== Broken-down time ===== ===== Broken-down time =====
Line 590: Line 609:
 </code> </code>
  
 +===== Strftime Formatted Time =====
 +
 +**$timef(format)** - return current time as formatted by strftime 'format'. See 'man strftime' to see the available time attribute specifiers.
 +
 +Example:
 +
 +<code c>
 +xlog("Today is $timef(%m/%d/%y)\n");
 +</code>
 ===== Selects ===== ===== Selects =====
  
Line 642: Line 670:
 Return the attribute of the current processed dialog. Return the attribute of the current processed dialog.
  
-<hi #d0d0d0>It is R/O variable.</hi>+<fc #0000ff>It is R/O variable.</fc>
  
 The 'attr' can be: The 'attr' can be:
Line 672: Line 700:
 Return the attribute of the context for current processed dialog. Return the attribute of the context for current processed dialog.
  
-<hi #d0d0d0>It is R/W variable.</hi>+<fc #0000ff>It is R/W variable.</fc>
  
 The 'attr' can be: The 'attr' can be:
Line 687: Line 715:
 Access hash table entries. Access hash table entries.
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file.</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file.</fc>
  
 The “htname” must be a hash table name defined via “htable” parameter. The “htname” must be a hash table name defined via “htable” parameter.
Line 709: Line 737:
 Access hash table entry expire value. Value represents the seconds until the htable entry will expire and be deleted from htable. Access hash table entry expire value. Value represents the seconds until the htable entry will expire and be deleted from htable.
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file.</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file.</fc>
  
 The “htname” must be a hash table name defined via “htable” parameter and have auto-expire greater than 0. The “htname” must be a hash table name defined via “htable” parameter and have auto-expire greater than 0.
Line 756: Line 784:
 </code> </code>
  
-==== $shtcv(htable=>regexp) ====+==== $shtcv(htable=>exp) ====
  
 Count items matching the value by regexp. Count items matching the value by regexp.
Line 762: Line 790:
 The “htname” must be a hash table name defined via “htable” parameter. The “htname” must be a hash table name defined via “htable” parameter.
  
-The “regexp” must be a regular expression.+The **exp** must follow same rules as for **$shtcn(...)**.
  
 <code> <code>
Line 780: Line 808:
 Access hash table entries stored in the memcached server. Access hash table entries stored in the memcached server.
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file.</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file.</fc>
  
 The “key” can be: The “key” can be:
Line 802: Line 830:
 Do a atomic increment operation on the value stored in memcached. You need to add a value previously. Do a atomic increment operation on the value stored in memcached. You need to add a value previously.
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file.</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file.</fc>
  
 The “key” can be: The “key” can be:
Line 821: Line 849:
 Do a atomic decrement operation on the value stored in memcached. You need to add a value previously. Do a atomic decrement operation on the value stored in memcached. You need to add a value previously.
  
-<hi #d0d0d0>It is R/W variable, you can assign values to it directly in configuration file.</hi>+<fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file.</fc>
  
 The “key” can be: The “key” can be:
Line 918: Line 946:
   * reply_code - alias to $T_reply_code   * reply_code - alias to $T_reply_code
   * branch_index - alias to $T_branch_idx   * branch_index - alias to $T_branch_idx
 +  * reply_type - 1 if it is a local generated reply, 0 - if no reply for transaction or it is a received reply
  
 Note: the pair (id_index,id_label) uniquely identifies a transaction. Note: the pair (id_index,id_label) uniquely identifies a transaction.
cookbooks/3.2.x/pseudovariables.1322641596.txt.gz · Last modified: 2011/11/30 09:26 by 85.178.74.216