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/08/11 19:48] mslehto [$T(name)] add: reply_reason, reply_last |
cookbooks:devel:pseudovariables [2018/10/04 19:55] mslehto [sdpops variables] |
||
---|---|---|---|
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 170: | Line 170: | ||
**$conid** - The TCP connection ID of the connection the current message arrived on for TCP, TLS, WS, and WSS. Set to $null for SCTP and UDP. | **$conid** - The TCP connection ID of the connection the current message arrived on for TCP, TLS, WS, and WSS. Set to $null for SCTP and UDP. | ||
- | ==== $cs - CSeq ==== | + | ==== $cs - CSeq Number |
- | **$cs** - reference to the sequence number in the cseq header. The method in the CSeq header is identical to the request method, thus use $rm to get the method (works also for responses). | + | **$cs** - reference to the sequence number in the CSeq header. The method in the CSeq header is identical to the request method, thus use $rm to get the method (works also for responses). |
+ | ==== $csb - CSeq Header Body ==== | ||
+ | |||
+ | **$csb** - reference to the CSeq header body (number method). | ||
==== $ct - Contact header ==== | ==== $ct - Contact header ==== | ||
Line 333: | Line 336: | ||
**$pp** - reference to process id (pid) | **$pp** - reference to process id (pid) | ||
- | ==== $pr - Protocol of received message ==== | + | ==== $pr or $proto |
**$pr** or **$proto** - protocol of received message (udp, tcp, tls, sctp, ws, wss) | **$pr** or **$proto** - protocol of received message (udp, tcp, tls, sctp, ws, wss) | ||
+ | ==== $prid - protocol id ==== | ||
+ | |||
+ | **$prid** - internal protocol id | ||
+ | |||
+ | * 0 - NONE | ||
+ | * 1 - UDP | ||
+ | * 2 - TCP | ||
+ | * 3 - TLS | ||
+ | * 4 - SCTP | ||
+ | * 5 - WS | ||
+ | * 6 - WSS | ||
+ | * 7 - OTHER | ||
==== $pU - User in P-Preferred-Identity header URI ==== | ==== $pU - User in P-Preferred-Identity header URI ==== | ||
Line 475: | 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 504: | 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 733: | 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 1487: | Line 1510: | ||
* $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 1966: | Line 2041: | ||
* 0x000 - HEP attribute 0x000 | * 0x000 - HEP attribute 0x000 | ||
* 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) | ||
+ | |||
===== $C(xy) - Foreground and background colors ===== | ===== $C(xy) - Foreground and background colors ===== |