This shows you the differences between two versions of the page.
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/27 15:31] miconda [$hdr(name) - Headers] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{ : | ||
====== Pseudo-Variables ====== | ====== Pseudo-Variables ====== | ||
- | Version: Kamailio SIP Server v5.5.x (devel) | + | Version: Kamailio SIP Server v5.6.x (devel) |
+ | |||
+ | {{ : | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 207: | Line 208: | ||
</ | </ | ||
- | ==== $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(" | + | xlog(" |
</ | </ | ||
==== $di - Diversion header URI ==== | ==== $di - Diversion header URI ==== | ||
Line 267: | Line 268: | ||
**$fd** - reference to domain in URI of ' | **$fd** - reference to domain in URI of ' | ||
+ | |||
+ | <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(" | ||
+ | $var(rc) = $rc; | ||
+ | if ($var(rc) < 0) { | ||
+ | t_newtran(); | ||
+ | switch ($var(rc)) { | ||
+ | case -1: | ||
+ | case -3: | ||
+ | send_reply(" | ||
+ | exit; | ||
+ | case -2: | ||
+ | send_reply(" | ||
+ | exit; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
==== $rd - Domain in R-URI ==== | ==== $rd - Domain in R-URI ==== | ||
Line 875: | Line 899: | ||
- | **$hdr(name)** - represents the body of first header identified by ' | + | **$hdr(name)** - represents the body of first header |
- | **$(hdr(name)[N])** - represents the body of the N-th header identified by ' | + | **$(hdr(name)[N])** - represents the body of the N-th header |
If [N] is omitted then the body of the first header is printed. The body of first header is returned 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=' | If [N] is omitted then the body of the first header is printed. The body of first header is returned 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=' | ||
Line 895: | Line 919: | ||
<fc # | <fc # | ||
+ | ===== $hfl(name) - Header Field With List Of Bodies ===== | ||
+ | |||
+ | Similar to **$hdr(name)**, | ||
+ | |||
+ | Implemented for: | ||
+ | |||
+ | * Via | ||
+ | |||
+ | For the rest of the headers works like **$hdr(name)**. | ||
+ | |||
+ | **$hfl(name)** - represents the first body of first header field identified by ' | ||
+ | |||
+ | **$(hfl(name)[N])** - represents the body of the N-th header field identified by ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | if($(hdr(Via)[1])=~" | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
===== $hdrc(name) - Number of Headers ===== | ===== $hdrc(name) - Number of Headers ===== | ||
Line 1031: | Line 1076: | ||
<code c> | <code c> | ||
xlog(" | xlog(" | ||
+ | </ | ||
+ | |||
+ | ===== $ccp(key) - Config Custom Parameters ===== | ||
+ | |||
+ | Get the value for global custom parameters: | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | |||
+ | Example: | ||
+ | |||
+ | <code c> | ||
+ | gv.sval = " | ||
+ | gv.ival = 10 desc "ten var" | ||
+ | |||
+ | request_route { | ||
+ | xinfo(" | ||
+ | } | ||
</ | </ | ||
Line 1072: | Line 1135: | ||
event_route[core: | event_route[core: | ||
xlog(" | xlog(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== $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(" | ||
} | } | ||
</ | </ | ||
Line 1582: | Line 1666: | ||
==== $T_branch_idx ==== | ==== $T_branch_idx ==== | ||
- | * the index (starting with 1 for the first branch) of the branch for which is executed the branch_route[]. | + | * the index (starting with 0 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[], | ||
+ | * if used outside of transaction processing, the value is '-1' | ||
==== $T_reply_ruid ==== | ==== $T_reply_ruid ==== |