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/05/29 23:36] linuxmaniac [$xavu(id) - XAVUs] |
cookbooks:devel:pseudovariables [2021/05/27 15:31] miconda [$hdr(name) - Headers] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Pseudo-Variables ====== | ||
+ | |||
+ | Version: Kamailio SIP Server v5.6.x (devel) | ||
+ | |||
{{ : | {{ : | ||
- | ====== Kamailio SIP Server v5.4.x (devel): Pseudo-Variables ====== | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 193: | Line 196: | ||
**$dd** - reference to domain of destination uri (without port) | **$dd** - reference to domain of destination uri (without port) | ||
+ | ==== $def(name) - Defined Value ==== | ||
+ | **$def(name)** - return a defined value. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <code c> | ||
+ | #!define ABC xyz | ||
+ | |||
+ | xlog(" | ||
+ | </ | ||
+ | |||
+ | ==== $defn(name) - Defined Value As Number ==== | ||
+ | |||
+ | **$defn(name)** - return a defined value as a signed integer. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <code c> | ||
+ | #!define FLT_ACC 1 | ||
+ | |||
+ | xlog(" | ||
+ | </ | ||
==== $di - Diversion header URI ==== | ==== $di - Diversion header URI ==== | ||
Line 243: | 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 293: | Line 320: | ||
Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | ||
+ | |||
==== $fU - From URI username ==== | ==== $fU - From URI username ==== | ||
Line 300: | Line 328: | ||
Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | ||
+ | |||
+ | ==== $fUl - From URI Username Length ==== | ||
+ | |||
+ | **$fUl** - length of the username in the From URI | ||
+ | |||
==== $mb - SIP message buffer ==== | ==== $mb - SIP message buffer ==== | ||
Line 352: | Line 385: | ||
**$oU** - reference to username in request' | **$oU** - reference to username in request' | ||
+ | |||
+ | ==== $oUl - Original R-URI Username Length ==== | ||
+ | |||
+ | **$oUl** - the length of the username in the original R-URI | ||
==== $pd - Domain in P-Preferred-Identity header URI ==== | ==== $pd - Domain in P-Preferred-Identity header URI ==== | ||
Line 401: | 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 476: | Line 534: | ||
<fc # | <fc # | ||
+ | |||
+ | ==== $rUl - R-URI Username Length ==== | ||
+ | |||
+ | **$rU** - the length of the username in R-URI | ||
==== $rv - SIP message version ==== | ==== $rv - SIP message version ==== | ||
Line 615: | Line 677: | ||
**$tU** - reference to username in URI of ' | **$tU** - reference to username in URI of ' | ||
+ | |||
+ | ==== $tUl - To URI Username Length ==== | ||
+ | |||
+ | **$tU** - the length of the username in To URI | ||
==== $Tb - Startup timestamp ==== | ==== $Tb - Startup timestamp ==== | ||
Line 833: | 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 853: | 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 989: | 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 1030: | 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 1540: | 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 ==== |