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 [2017/10/01 00:06] mslehto [$csb - CSeq Header Body] s/cs/csb/ |
cookbooks:devel:pseudovariables [2018/10/26 19:31] miconda [$TV(name)] |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{ : | {{ : | ||
- | ====== Kamailio SIP Server v5.1.x (devel): Pseudo-Variables ====== | + | ====== Kamailio SIP Server v5.2.x (devel): Pseudo-Variables ====== |
===== Introduction ===== | ===== Introduction ===== | ||
Line 490: | Line 490: | ||
**$Rut** - local socket where the SIP messages was received in URI format, always with transport parameter. | **$Rut** - local socket where the SIP messages was received in URI format, always with transport parameter. | ||
+ | ==== $sas - Source address in socket format ==== | ||
+ | |||
+ | **$sas** - get source address in socket format (proto: | ||
==== $sbranch(attr) - Static Branch ==== | ==== $sbranch(attr) - Static Branch ==== | ||
Line 519: | Line 522: | ||
**$si** - reference to IP source address of the message - see also $siz | **$si** - reference to IP source address of the message - see also $siz | ||
+ | ==== $sid - Server ID ==== | ||
+ | |||
+ | **$sid** - the value for server id (server_id parameter) | ||
==== $siz - Source IP address ==== | ==== $siz - Source IP address ==== | ||
Line 748: | Line 754: | ||
**$(hdr(name)[N])** - represents the body of the N-th header identified by ' | **$(hdr(name)[N])** - represents the body of the N-th header identified by ' | ||
- | 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=' | + | If [N] is omitted then the body of the first header is printed. The body of first header is returned |
+ | |||
+ | If name is *, then any header name is matched, e.g., $hdr(*) is body of first header, $(hdr(*)[-1]) is body of last header. | ||
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. | 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. | ||
Line 1482: | Line 1490: | ||
==== $TV(name) ==== | ==== $TV(name) ==== | ||
- | Seconds and microseconds taken from struct timeval. | + | Seconds and microseconds taken from struct timeval. The time at that moment is represented by **seconds.microseconds**. |
* $TV(s) - seconds (cached at first call per sip message) | * $TV(s) - seconds (cached at first call per sip message) | ||
* $TV(u) - microseconds (cached at first call per sip message) | * $TV(u) - microseconds (cached at first call per sip message) | ||
- | * $TV(sn) - seconds (not cached) | + | * $TV(sn) - seconds (not cached, taken at that moment) |
- | * $TV(un) - microseconds (not cached) | + | * $TV(un) - microseconds (corresponding to the moment $TV(sn) is retrieved) |
- | * $TV(Sn) - string representation seconds.microseconds (not cached) | + | * $TV(Sn) - string representation seconds.microseconds (not cached, taken at that moment) |
===== Next hop address ===== | ===== Next hop address ===== | ||
Line 1502: | Line 1509: | ||
* $nh(P) - transport protocol (upper case p) | * $nh(P) - transport protocol (upper case p) | ||
- | ===== GeoIP module Pseudo-Variables | + | ===== NDB_REDIS Module ===== |
+ | |||
+ | ==== $redis(res=> | ||
+ | |||
+ | Access the attributes of the Redis response. | ||
+ | |||
+ | The key can be: | ||
+ | |||
+ | * type - type of the reply (as in hiredis.h) | ||
+ | * value - the value returned by REDIS server; | ||
+ | * info - in case of error from REDIS, it will contain an info message. | ||
+ | |||
+ | If reply type is an array (as in hiredis.h), there are other keys available: | ||
+ | |||
+ | * size - returns number of elements in the array. | ||
+ | |||
+ | * type[n] - returns the type of the nth element in the array. type - returns array type. | ||
+ | |||
+ | * value[n] - returns value of the nth element. value - returns null for an array. You need to get each element by index. | ||
+ | |||
+ | In case one of the members of the array is also an array (for example calling SMEMBERS in a MULTI/EXEC transaction), | ||
+ | |||
+ | Example: | ||
+ | |||
+ | < | ||
+ | redis_cmd(" | ||
+ | xlog(" | ||
+ | </ | ||
+ | |||
+ | ==== $redisd(key) ==== | ||
+ | |||
+ | Return the corresponding value for various defines from hiredis library. | ||
+ | |||
+ | The key can be: | ||
+ | |||
+ | * rpl_str - return REDIS_REPLY_STRING | ||
+ | * rpl_arr - return REDIS_REPLY_ARRAY | ||
+ | * rpl_int - return REDIS_REPLY_INTEGER | ||
+ | * rpl_nil - return REDIS_REPLY_NIL | ||
+ | * rpl_sts - return REDIS_REPLY_STATUS | ||
+ | * rpl_err - return REDIS_REPLY_ERROR | ||
+ | |||
+ | $redisd(rpl_XYZ) can be compared with $redis(r=> | ||
+ | |||
+ | Example: | ||
+ | |||
+ | < | ||
+ | redis_cmd(" | ||
+ | if ($redis(r=> | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== GeoIP Module | ||
==== $gip(pvc=> | ==== $gip(pvc=> | ||
Line 1982: | Line 2041: | ||
* 0x999 - HEP attribute 0x999 | * 0x999 - HEP attribute 0x999 | ||
+ | ===== $phn(rid=> | ||
+ | |||
+ | $phn(rid=> | ||
+ | |||
+ | * number - phone number that is matched | ||
+ | * valid - 1 if the matched number has a valid result; 0 otherwise | ||
+ | * normalized - normalized phone number | ||
+ | * cctel - country code for phone number | ||
+ | * ltype - local network type | ||
+ | * ndesc - phone number description | ||
+ | * error - error string if phone number matching fails. | ||
+ | |||
+ | <code c> | ||
+ | if(phonenum_match(" | ||
+ | if($phn(src=> | ||
+ | xlog(" | ||
+ | } else { | ||
+ | xlog(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== sdpops module variables ===== | ||
+ | |||
+ | * $sdp(body) - full SDP body (read only) | ||
+ | * $sdp(sess_version) - sess-version -attribute from SDP o= -line. When set to special value -1, current value is incremented. (read + write) | ||
+ | |||
+ | ===== kex module variables ===== | ||
+ | |||
+ | * $sruid - return unique ID | ||
===== $C(xy) - Foreground and background colors ===== | ===== $C(xy) - Foreground and background colors ===== | ||