User Tools

Site Tools


cookbooks:devel: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
Next revision Both sides next revision
cookbooks:devel:pseudovariables [2020/12/12 18:45]
miconda [$dd - Domain of destination URI]
cookbooks:devel:pseudovariables [2021/05/15 09:26]
miconda [$sel(name) - Selects]
Line 1: Line 1:
-{{ :cookbooks:devel:pseudovariables.png?200|}} 
 ====== Pseudo-Variables ====== ====== Pseudo-Variables ======
  
-Version: Kamailio SIP Server v5.5.x (devel)+Version: Kamailio SIP Server v5.6.x (devel) 
 + 
 +{{ :cookbooks:devel:pseudovariables.png?200|}}
  
 ===== Introduction ===== ===== Introduction =====
Line 207: Line 208:
 </code> </code>
  
-==== $def(name) - Defined Value As Number ====+==== $defn(name) - Defined Value As Number ====
  
-**$def(name)** - return a defined value as a signed integer.+**$defn(name)** - return a defined value as a signed integer.
  
 Example: Example:
Line 216: Line 217:
 #!define FLT_ACC 1 #!define FLT_ACC 1
  
-xlog("FLT_ACC: $def(FLT_ACC)\n");+xlog("FLT_ACC: $defn(FLT_ACC)\n");
 </code> </code>
 ==== $di - Diversion header URI ==== ==== $di - Diversion header URI ====
Line 267: Line 268:
  
 **$fd** - reference to domain in URI of 'From' header **$fd** - reference to domain in URI of 'From' header
 +
 +<fc #0000ff>It is R/W variable (you can assign values to it directly in configuration file)</fc>
  
 ==== $fn - From display name ==== ==== $fn - From display name ====
Line 435: Line 438:
 **$retcode** - same as **$rc** **$retcode** - same as **$rc**
  
 +Note that the value of $rc is overwritten by each new function call.
 +
 +Example of use:
 +
 +<code c>
 + lookup("location");
 + $var(rc) = $rc;
 + if ($var(rc) < 0) {
 + t_newtran();
 + switch ($var(rc)) {
 + case -1:
 + case -3:
 + send_reply("404", "Not Found");
 + exit;
 + case -2:
 + send_reply("405", "Method Not Allowed");
 + exit;
 + }
 + }
 +
 +</code>
 ==== $rd - Domain in R-URI ==== ==== $rd - Domain in R-URI ====
  
Line 1031: Line 1055:
 <code c> <code c>
 xlog("The time is $utimef(%m/%d/%y %H:%M:%S)\n"); xlog("The time is $utimef(%m/%d/%y %H:%M:%S)\n");
 +</code>
 +
 +===== $ccp(key) - Config Custom Parameters =====
 +
 +Get the value for global custom parameters:
 +
 +  * https://www.kamailio.org/wiki/cookbooks/devel/core#custom_global_parameters
 +
 +
 +Example:
 +
 +<code c>
 +gv.sval = "hello" desc "hello var"
 +gv.ival = 10 desc "ten var"
 +
 +request_route {
 +    xinfo("global vars: $ccp(gv.sval) :: $ccp(gv.ival)\n");
 +}
 </code> </code>
  
Line 1072: Line 1114:
 event_route[core:msg-received] { event_route[core:msg-received] {
   xlog("rcv on $rcv(af)/$rcv(proto): ($rcv(len)) [$rcv(buf)] from [$rcv(srcip):$rcv(srcport)] to [$rcv(rcvip):$rcv(rcvport)]\n");   xlog("rcv on $rcv(af)/$rcv(proto): ($rcv(len)) [$rcv(buf)] from [$rcv(srcip):$rcv(srcport)] to [$rcv(rcvip):$rcv(rcvport)]\n");
 +}
 +</code>
 +
 +==== $rpl(key) ====
 +
 +Attributes of the SIP reply processed at that moment. The variables must be used during SIP reply processing, otherwise it returns $null.
 +
 +The key can be:
 +
 +  * duri - SIP URI corresponding to the address where the SIP reply is going to be sent based on 2nd via
 +  * dhost - host part of duri
 +  * dport - port part of duri
 +  * dproto - proto part of duri
 +  * dprotoid - proto id of duri
 +  * cntvia - the number of Via header bodies
 +
 +Example of usage:
 +
 +<code c>
 +reply_route{
 +  xinfo("reply to be sent to: $rpl(duri)\n");
 } }
 </code> </code>
Line 1582: Line 1645:
 ==== $T_branch_idx ==== ==== $T_branch_idx ====
  
-  * the index (starting with for the first branch) of the branch for which is executed the branch_route[]. If used outside of branch_route[] block, the value is '0'.+  * the index (starting with for the first branch) of the branch for which is executed the branch_route[]. 
 +  * in failure_route[] block, the value is the number of completed branches added to the number of new new branches 
 +  * in request_route block, the value is number of created branches 
 +  * in onreply_route[], the value is the index of the branch receiving the reply 
 +  * if used outside of transaction processing, the value is '-1'
  
 ==== $T_reply_ruid ==== ==== $T_reply_ruid ====
cookbooks/devel/pseudovariables.txt · Last modified: 2022/04/11 15:24 by henningw