cookbooks:5.4.x:core
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
cookbooks:5.4.x:core [2020/06/19 08:34] – created linuxmaniac | cookbooks:5.4.x:core [2021/05/12 11:35] (current) – [kemi.received_route_callback] giavac | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | ===== Introduction ===== | + | Version: Kamailio SIP Server v5.4.x (stable) |
- | The term “pseudo-variable” is used for special tokens that can be given as parameters to different script functions and they will be replaced with a value before the execution of the function. | + | ===== Overview ===== |
- | The beginning of a “pseudo-variable” is marked | + | This tutorial collects the functions and parameters exported |
- | There is a set of predefined pseudo-variables, | + | **Note:** The parameters on this page are **NOT** in alphabetical order. |
- | Pseudo-Variables are implemented by various modules, most of them are provided by **pv** (if there is no special reference to a module, expect that the pseudo-variable is provided by **pv** module). | + | ===== Structure ===== |
- | ===== Pseudo-variables usage ===== | + | The structure of the kamailio.cfg can be seen as three parts: |
+ | * global parameters | ||
+ | * modules settings | ||
+ | * routing blocks | ||
- | Pseudo-variables can be used with many modules, among them: | + | For clarity and making it easy to maintain, it is recommended to keep them in this order, although some of them can be mixed. |
- | * acc | + | ==== Global Parameters Section ==== |
- | * avpops | + | |
- | * htable | + | |
- | * http_async_client | + | |
- | * textops | + | |
- | * uac | + | |
- | * xlog | + | |
- | ===== The list of pseudo-variables ===== | + | This is the first part of the configuration file, containing the parameters for the core of kamailio and custom global parameters. |
+ | Typically this is formed by directives of the form: | ||
- | Predefined pseudo-variables are listed in alphabetical order. | + | < |
+ | name=value | ||
+ | </ | ||
- | ==== $$ - Pseudo-variable marker ==== | + | The name corresponds to a core parameter as listed in one of the next sections of this document. If a name is not matching a core parameter, then Kamailio will not start, rising an error during startup. |
- | **$$** - represents the character ' | + | The value is typically an integer, boolean or a string. |
- | ==== $_s(format) - Evaluate dynamic format ==== | + | Several parameters can get a complex value which is formed from a group of integer, strings or identifiers. For example, such parameter is **listen**, which can be assigned a value like **proto: |
- | **$_s(format)** - returns the string after evaluating all pseudo-variables in format | + | Example of content: |
- | < | + | < |
- | | + | log_facility=LOG_LOCAL0 |
- | # is equivalent of: | + | children=4 |
- | $var(x) | + | disable_tcp=yes |
+ | |||
+ | alias=" | ||
+ | |||
+ | listen=udp: | ||
</ | </ | ||
- | ==== $ai - URI inP-Asserted-Identity header ==== | + | Usually setting a parameter is ended by end of line, but it can be also ended with **;** (semicolon). This should be used when the grammar of a parameter allows values on multiple lines (like **listen** or **alias**) and the next line creates a conflict by being swallowed as part of value for previous parameter. |
- | **$ai** - reference to URI in request' | + | <code c> |
+ | alias=" | ||
+ | </ | ||
- | ==== $adu - Auth Digest URI ==== | + | If you want to use a reserved config keyword as part of a parameter, you need to enclose it in quotes. See the example below for the keyword " |
- | **$adu** - URI from Authorization or Proxy-Authorization header. This URI is used when calculating the HTTP Digest Response. | + | <code c> |
+ | listen=tcp: | ||
+ | </ | ||
+ | ==== Modules Settings Section ==== | ||
- | ==== $aa - Auth algorithm ==== | + | This is the second section of the configuration file, containing the directives to load modules and set their parameters. |
- | **$aa** - algorithm from Authorization or Proxy-Authorization header. | + | It contains the directives |
- | ==== $ar - Auth realm ==== | + | Example of content: |
- | **$ar** - realm from Authorization or Proxy-Authorization header | + | <code c> |
+ | loadmodule " | ||
+ | ... | ||
+ | modparam(" | ||
+ | </ | ||
+ | ==== Routing Blocks Section ==== | ||
- | ==== $au - Auth username user ==== | + | This is the last section of the configuration file, typically the biggest one, containing the routing blocks with the routing logic for SIP traffic handled by Kamailio. |
- | **$au** - user part of username from Authorization or Proxy-Authorization header | + | The only mandatory routing block is **request_route**, which contains the actions for deciding the routing for SIP requests. |
+ | See the chapter **Routing Blocks** in this document for more details about what types of routing blocks can be used in the configuration file and their role in routing SIP traffic and Kamailio behaviour. | ||
- | ==== $ad - Auth username domain ==== | + | Example of content: |
- | **$ad** - domain part of username from Authorization or Proxy-Authorization header | + | <code c> |
+ | request_route { | ||
+ | # per request initial checks | ||
+ | route(REQINIT); | ||
- | ==== $aU - Auth whole username ==== | + | ... |
+ | } | ||
- | **$aU** - whole username from Authorization or Proxy-Authorization header | + | branch_route[MANAGE_BRANCH] { |
+ | xdbg(" | ||
+ | route(NATMANAGE); | ||
+ | } | ||
+ | </ | ||
- | ==== $Au - Acc username and realm/ | + | ===== Generic Elements ===== |
- | **$Au** - username for accounting purposes. It's a selective pseudo variable (inherited from acc module). It returns the auth username and realm ($au@$ar) if exists or From URI ($fu) otherwise. | + | ==== Comments ==== |
- | ==== $AU - Acc username ==== | + | Line comments start with **#** (hash/pound character |
- | **$AU** - username for accounting purposes. It's a selective pseudo variable | + | Block comments start with /* (forward slash and asterisk) and are ended by */ (sterisk and forward slash) (like in C, C++, Java). |
- | ==== $branch(name) - Branch attributes ==== | + | |
- | **$branch(name)** - reference to attribute ' | + | Example: |
- | This pseudo variable gives you access to the " | + | < |
+ | # this is a line comment | ||
+ | |||
+ | // this is another line comment | ||
+ | |||
+ | /* this | ||
+ | is | ||
+ | a | ||
+ | | ||
+ | | ||
+ | </ | ||
- | The ' | + | Important: be aware of preprocessor directives that start with **#!** (hash/pound and exclamation) - those are no longer line comments. |
- | * uri - return uri of the branch | + | ==== Values ==== |
- | * dst_uri - return destination uri (next hop address) | + | |
- | * path - return the path vector for the branch | + | There are three types of values: |
- | * q - return the q value of the branch | + | |
- | * send_socket - return the socket to be used to send the branch | + | * integer |
- | * count - return the number | + | * boolean |
- | * flags - return the branch flags value | + | * string |
- | * ruid - return the ruid of the branch (Record internal Unique ID from usrloc) | + | |
- | The PV can take an index to access a specif branch: $(branch(name)[index]) | ||
Example: | Example: | ||
<code c> | <code c> | ||
- | $var(i)=0; | + | // next two are strings |
- | while($var(i)< | + | |
- | { | + | "this is a string value" |
- | xlog("$(branch(uri)[$var(i)])\n"); | + | ' |
- | $var(i) = $var(i) + 1; | + | |
- | } | + | // next is a boolean |
+ | |||
+ | yes | ||
+ | |||
+ | // next is an integer | ||
+ | |||
+ | 64 | ||
</ | </ | ||
- | Starting with 3.1.0, you can assign value per attribute. Index can be used to update a specific branch: | + | ==== Identifiers ==== |
+ | |||
+ | Identifiers are tokens which are not enclosed in single or double quotes and don't match the rules for integer or boolean values. | ||
+ | |||
+ | For example, the identifiers are the core parameters and functions, module functions, core keywords and statements. | ||
+ | |||
+ | Example: | ||
<code c> | <code c> | ||
- | $(branch(attr)[index]) = value; | + | return |
</ | </ | ||
- | If index is missing, first branch is used. If index is -1 the last branch is used. | + | ==== Variables ==== |
- | Assigning | + | The variables start with **$** (dollar character). |
+ | |||
+ | You can see the list with available variables in the Pseudo-Variables Cookbook. | ||
+ | |||
+ | Example: | ||
<code c> | <code c> | ||
- | $(branch(uri)[2]) = "sip:test@kamailio.org; | + | $var(x) = $rU + " |
</ | </ | ||
+ | ==== Actions ==== | ||
- | ==== $br - Request' | + | An action is an element used inside routing blocks ended by **;** (semicolon). It can be an execution of a function from core or a module, a conditional or loop statement, an assignment expression. |
- | **$br** - reference to request' | + | Example: |
- | <fc #0000ff>It is R/W variable, you can assign values to it directly in configuration file (will add a new branch).</fc> | + | <code c> |
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | </code> | ||
- | ==== $bR - Request' | + | ==== Expressions |
- | **$bR** - reference to request' | + | An expression is an association group of statements, variables, functions and operators. |
- | ==== $bf - Branch flags ==== | + | Example: |
- | **$bf** - reference to branch flags of branch 0 (RURI) - decimal output | + | <code c> |
+ | if(!t_relay()) | ||
- | <fc # | + | if($var(x)>10) |
- | ==== $bF - Branch flags ==== | + | |
- | **$bF** - reference to branch flags of branch 0 (RURI) - hexa output | + | " |
+ | </ | ||
- | <fc # | + | ===== Config Pre-Processor Directives ===== |
- | ==== $bs - Body size ==== | + | ==== include_file |
- | **$bs** - body size | + | < |
+ | | ||
+ | </ | ||
- | ==== $ci - Call-Id ==== | + | Include the content of the file in config before parsing. path_to_file must be a static string. Including file operation is done at startup. If you change the content of included file, you have to restart the SIP server to become effective. |
- | **$ci** - reference | + | The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory |
- | ==== $cl - Content-Length ==== | + | If the included file is not found, the config file parser throws error. You can find this error message at the logging destination, |
- | **$cl** - reference to body of content-length header | + | You can use also the syntax |
- | ==== $cnt(pv) - Count number | + | Example |
- | + | ||
- | **$cnt(avp)** - return the number of avps | + | |
<code c> | <code c> | ||
- | xlog("$$avp(x) fount $cnt($avp(x)) times\n"); | + | route { |
- | </ | + | ... |
- | ==== $conid - TCP Connection ID ==== | + | include_file |
+ | ... | ||
+ | } | ||
- | **$conid** | + | --- /sr/checks.cfg --- |
- | ==== $cs - CSeq Number ==== | + | if (!mf_process_maxfwd_header(" |
+ | | ||
+ | | ||
+ | } | ||
- | **$cs** | + | --- |
+ | </ | ||
- | ==== $csb - CSeq Header Body ==== | + | ==== import_file |
- | **$csb** - reference to the CSeq header body (number method). | + | < |
- | ==== $ct - Contact header ==== | + | import_file " |
+ | </ | ||
- | **$ct** - reference to body of contact header | + | Similar to **include_file**, but does not throw error if the included file is not found. |
+ | ==== define ==== | ||
- | ==== $cT - Content-Type ==== | + | Control in C-style what parts of the config file are executed. The parts in non-defined zones are not loaded, ensuring lower memory usage and faster execution. |
- | **$cT** - reference | + | Available directives: |
+ | | ||
+ | * **#!define NAME VALUE** - define a keyword with value | ||
+ | * **#!ifdef NAME** - check if a keyword is defined | ||
+ | * **# | ||
+ | * **#!else** - switch | ||
+ | * **#!endif** - end ifdef/ | ||
+ | * **# | ||
+ | * **# | ||
- | ==== $dd - Domain of destination URI ==== | + | Predefined keywords: |
+ | * **KAMAILIO_X[_Y[_Z]]** | ||
+ | * **MOD_X** - when module X has been loaded | ||
+ | See ' | ||
- | **$dd** - reference | + | Among benefits: |
+ | | ||
+ | * switch control for parts where conditional statements were not possible | ||
+ | * faster by not using conditional statements inside routing blocks when switching between running environments | ||
+ | Example: how to make config to be used in two environments, | ||
- | ==== $di - Diversion header URI ==== | + | <code c> |
+ | ... | ||
- | **$di** - reference to Diversion header URI | + | #!define TESTBED_MODE |
- | ==== $dip - Diversion " | + | #!ifdef TESTBED_MODE |
+ | debug=5 | ||
+ | log_stderror=yes | ||
+ | listen=192.168.1.1 | ||
+ | #!else | ||
+ | debug=2 | ||
+ | log_stderror=no | ||
+ | listen=10.0.0.1 | ||
+ | #!endif | ||
- | **$dip** - reference to Diversion header " | + | ... |
- | ==== $dir - Diversion | + | #!ifdef TESTBED_MODE |
+ | modparam("acc|auth_db|usrloc", " | ||
+ | " | ||
+ | #!else | ||
+ | modparam(" | ||
+ | " | ||
+ | #!endif | ||
- | **$dir** - reference to Diversion header " | + | ... |
- | ==== $dic - Diversion " | + | #!ifdef TESTBED_MODE |
+ | route[DEBUG] { | ||
+ | xlog(" | ||
+ | } | ||
+ | #!endif | ||
- | **$dic** - reference to Diversion header " | + | ... |
- | ==== $dp - Port of destination URI ==== | + | route { |
+ | #!ifdef TESTBED_MODE | ||
+ | route(DEBUG); | ||
+ | #!endif | ||
- | **$dp** - reference to port of destination uri | + | ... |
+ | } | ||
- | ==== $dP - Transport protocol of destination URI ==== | + | ... |
+ | </ | ||
- | **$dP** - reference to transport protocol of destination uri | + | |
- | ==== $ds - Destination set ==== | + | <code c> |
+ | #!define MYINT 123 | ||
+ | #!define MYSTR " | ||
+ | </ | ||
- | **$ds** - reference to destination set | + | |
+ | <code c> | ||
+ | $var(x) = 100 + MYINT; | ||
+ | </ | ||
- | ==== $du - Destination URI ==== | + | * is interpreted as: |
- | **$du** - reference to destination uri | + | <code c> |
+ | $var(x) = 100 + 123; | ||
+ | </ | ||
- | If loose_route() returns TRUE a destination uri is set according to the first Route header. | + | * you can have multi-line defined IDs |
- | $du is also set if lookup() function of ' | + | |
- | if you use the path functionality. The function handle_ruri_alias() from the nathelper | + | |
- | module will also set it. You can set $du to any SIP URI. | + | |
- | | + | |
- | | + | |
- | | + | |
- | <fc #0000ff>It is R/W variable | + | <code c> |
+ | #!define IDLOOP $var(i) = 0; \ | ||
+ | while($var(i)< | ||
+ | xlog(" | ||
+ | $var(i) = $var(i) + 1; \ | ||
+ | } | ||
+ | </code> | ||
- | To reset $du: | + | * then in routing block |
- | $du = $null; | + | |
- | ==== $fd - From URI domain ==== | + | <code c> |
+ | route { | ||
+ | ... | ||
+ | IDLOOP | ||
+ | ... | ||
+ | } | ||
+ | </ | ||
- | **$fd** - reference | + | |
- | ==== $fn - From display name ==== | + | * notes: |
+ | * multilines defines are reduced to single line, so line counter should be fine | ||
+ | * column counter goes inside the define value, but you have to omit the ' | ||
+ | * text on the same line as the directive will cause problems. Keep the directive lines clean and only comment on a line before or after. | ||
- | **$fn** - reference to display name of ' | + | ==== subst ==== |
- | ==== $fs - Forced Send Socket ==== | + | * perform substitutions inside the strings of config (note that define is replacing only IDs - alphanumeric tokens not enclosed in quotes) |
+ | * #!subst offers an easy way to search and replace inside strings before cfg parsing. E.g.,: | ||
- | **$fs** - reference to the forced send socket for the SIP message (if any) in the form "proto: | + | <code c> |
+ | # | ||
+ | </ | ||
- | <fc # | + | * flags is optional and can be: ' |
Example: | Example: | ||
<code c> | <code c> | ||
- | listen=udp: | + | #!subst "/ |
- | ... | + | modparam(" |
- | $fs = "udp:1.2.3.4:5060"; | + | |
</ | </ | ||
- | ==== $fsn - Forced Send Socket Name ==== | + | * will do the substitution of db password in db_url parameter value |
- | **$fsn** - reference to the name of the forced send socket for the SIP message. The name can be assigned to this variable to select a send socket via its name. | + | ==== substdef ==== |
<code c> | <code c> | ||
- | listen=udp: | + | # |
- | ... | + | |
- | $fsn = " | + | |
- | ... | + | |
- | $fs = " | + | |
- | xdbg(" | + | |
</ | </ | ||
- | ==== $ft - From tag ==== | + | Similar to **subst**, but in addition it adds a **#!define ID subst**. |
- | **$ft** - reference to tag parameter of ' | + | ==== substdefs ==== |
- | ==== $fti - Initial From tag ==== | + | <code c> |
+ | #!substdefs "/ | ||
+ | </ | ||
- | **$fti** - reference to tag parameter of ' | + | Similar to **subst**, but in addition it adds a **#!define ID " |
+ | ===== Core Keywords ===== | ||
- | The value From tag in the initial request | + | Keywords specific to SIP messages which can be used mainly |
- | It is exported by **rr** module and has to be used after loose_route(). The append_fromtag parameter is required to be set to 1 in order to have this variable returning the right value. | + | ==== af ==== |
- | ==== $fu - From URI ==== | + | |
- | **$fu** - reference to URI of ' | + | The address family |
- | <fc # | + | Exampe of usage: |
- | Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | + | <code c> |
+ | if (af==INET6) { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
- | ==== $fU - From URI username | + | ==== dst_ip |
- | **$fU** - reference to username in URI of ' | + | The IP of the local interface where the SIP message was received. When the proxy listens on many network interfaces, makes possible to detect which was the one that received the packet. |
- | <fc # | + | Example of usage: |
- | Note that changing the From: header may break backwards compatibility with SIP 1.0 devices. | + | <code c> |
+ | | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | ==== $fUl - From URI Username Length | + | ==== dst_port |
- | **$fUl** - length of the username in the From URI | + | The local port where the SIP packet was received. When Kamailio is listening on many ports, it is useful to learn which was the one that received the SIP packet. |
- | ==== $mb - SIP message | + | Example of usage: |
+ | <code c> | ||
+ | | ||
+ | { | ||
+ | | ||
+ | }; | ||
+ | </ | ||
- | **$mb** - reference to SIP message buffer | ||
- | ==== $mbu - updated SIP message buffer | + | ==== from_uri |
- | **$mbu** - reference to updated SIP message buffer, after applying changes | + | This script variable is a reference to the URI of ' |
- | ==== $mf - Flags ==== | + | Example of usage: |
- | **$mf** - reference to message/transaction flags set for current SIP request | + | <code c> |
+ | if(is_method(" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </code> | ||
- | <fc # | + | ==== method ==== |
- | ==== $mF - Flags in hexadecimal ==== | + | The variable is a reference to the SIP method of the message. |
- | **$mF** -reference to message/ | + | Example of usage: |
- | <fc #0000ff>It is R/W variable | + | <code c> |
+ | if(method==" | ||
+ | { | ||
+ | | ||
+ | }; | ||
+ | </code> | ||
- | ==== $mi - SIP message id ==== | + | ==== msg: |
- | **$mi** - reference to SIP message | + | The variable is a reference to the size of the message. It can be used in ' |
- | ==== $ml - SIP message length ==== | ||
- | **$ml** - reference to SIP message | + | Example of usage: |
+ | <code c> | ||
+ | if(msg: | ||
+ | { | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | </ | ||
- | ==== $mt - SIP Message Type ==== | ||
- | **$mt** - returns 1 if the sip message is a request, returns 2 if the sip message is a reply | + | . |
+ | ==== proto ==== | ||
- | ==== $od - Domain original R-URI ==== | + | This variable can be used to test the transport protocol of the SIP message. |
- | **$od** - reference to domain in request' | + | Example of usage: |
+ | <code c> | ||
+ | if(proto==UDP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | ==== $op - Port in original R-URI ==== | + | ==== status |
- | **$op** - reference to port of original R-URI | + | If used in **onreply_route**, this variable is a reference to the status code of the reply. If used in a standard route block, the variable is a reference to the status of the last reply sent out for the current request. |
- | ==== $oP - Protocol | + | Example |
+ | <code c> | ||
+ | if(status==" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | **$oP** - reference to transport protocol of original R-URI | ||
- | ==== $ou - Original R-URI ==== | + | ==== snd_af |
- | **$ou** - reference | + | In **onsend_route** it identifies the address family (see **af**) used to send the message out. |
+ | ==== snd_ip ==== | ||
- | ==== $oU - Username in original R-URI ==== | + | In **onsend_route** it contains the IP address used by Kamailio to send the message out. |
+ | ==== snd_port | ||
- | **$oU** - reference | + | In **onsend_route** it contains the port used by Kamailio |
+ | ==== snd_proto ==== | ||
- | ==== $oUl - Original R-URI Username Length | + | In **onsend_route** it identifies the protocol (see **proto**) used to send the message out. |
+ | ==== src_ip | ||
- | **$oUl** - the length | + | Reference to source IP address |
- | ==== $pd - Domain in P-Preferred-Identity header URI ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(src_ip==127.0.0.1) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | **$pd** - reference to domain in request' | + | ==== src_port ==== |
- | ==== $pn - Display Name in P-Preferred-Identity header ==== | + | Reference to source port of the SIP message (from which port the message was sent by previous hop). |
- | **$pn** - reference to Display Name in request' | + | Example of usage: |
+ | <code c> | ||
+ | if(src_port==5061) | ||
+ | { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
- | ==== $pp - Process id ==== | + | ==== to_ip ==== |
- | **$pp** - reference | + | In **onsend_route** it contains the destination IP address where the message will be sent to. |
+ | ==== to_port ==== | ||
- | ==== $pr or $proto - Protocol of received message | + | In **onsend_route** it contains the destination port where the message will be sent to. |
+ | ==== to_uri | ||
- | **$pr** or **$proto** - protocol | + | This variable can be used to test the value of URI from To header. |
- | ==== $prid - protocol id ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(to_uri=~" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | **$prid** - internal protocol id | + | ==== uri ==== |
- | * 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** - reference | + | This variable can be used to test the value of the request URI. |
- | ==== $pu - URI in P-Preferred-Identity header ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(uri=~" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | **$pu** - reference to URI in request' | ||
+ | ===== Core Values ===== | ||
- | ==== $rb - Body of request/ | + | Values that can be used in ''' |
- | **$rb** - reference to message body | + | ==== INET ==== |
- | ==== $rc - Returned code ==== | + | This keyword can be used to test whether the SIP packet was received over an IPv4 connection. |
- | **$rc** - reference to returned code by last invoked function | + | Example of usage: |
- | **$retcode** - same as **$rc** | + | <code c> |
+ | if (af==INET) { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
- | ==== $rd - Domain in R-URI ==== | + | ==== INET6 ==== |
- | **$rd** - reference to domain in request' | + | This keyword can be used to test whether |
- | <fc #0000ff>It is R/W variable | + | Example of usage: |
+ | <code c> | ||
+ | if(af==INET6) | ||
+ | { | ||
+ | log("the SIP message was received over IPv6\n" | ||
+ | }; | ||
+ | </code> | ||
- | ==== $rdir(key) - Request Direction | + | ==== SCTP ==== |
- | **$rdir(key)** - get the direction | + | This keyword can be used to test the value of ' |
- | The direction is ' | + | Example of usage: |
+ | <code c> | ||
+ | | ||
+ | { | ||
+ | log("the SIP message was received over SCTP\n" | ||
+ | }; | ||
+ | </ | ||
- | The key can be: | + | ==== TCP ==== |
- | * id - the returned | + | This keyword can be used to test the value of 'proto' |
- | * name - the returned value is a string: | + | |
- | Example: | + | Example |
+ | <code c> | ||
+ | if(proto==TCP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | ==== TLS ==== | ||
+ | |||
+ | This keyword can be used to test the value of ' | ||
+ | |||
+ | Example of usage: | ||
<code c> | <code c> | ||
- | if($rdir(name)==" | + | |
- | xlog("request | + | |
- | } | + | log("the SIP message |
+ | }; | ||
</ | </ | ||
+ | ==== UDP ==== | ||
- | The variable is exported by **rr** module and append_fromtag parameter must be enabled. The variable has to be used after loose_route() function. | + | This keyword can be used to test the value of ' |
- | ==== $re - Remote-Party-ID header URI ==== | + | |
- | **$re** - reference to Remote-Party-ID header URI | + | Example of usage: |
+ | <code c> | ||
+ | if(proto==UDP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | ==== $rm - SIP method | + | ==== WS ==== |
- | **$rm** - reference | + | This keyword can be used to test the value of 'proto' and check whether |
- | ==== $rmid - SIP Method ID ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(proto==WS) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
- | **$rmid** - returns internal integer representation of SIP method type | ||
- | ==== $route_uri - URI in first Route header | + | ==== WSS ==== |
- | **$route_uri** - returns | + | This keyword can be used to test the value of ' |
- | ==== $rp - Port in R-URI ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(proto==WSS) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | ==== max_len | ||
- | **$rp** - reference to port of R-URI | + | Note: This command was removed. |
- | <fc # | ||
- | ==== $rP - Protocol of R-URI ==== | + | ==== myself |
- | **$rP** - reference to transport protocol | + | This is a reference to the list of local IP addresses, hostnames and aliases that has been set in the Kamailio configuration file. This lists contain the domains served by Kamailio. |
- | ==== $rr - SIP reply reason phrase ==== | + | The variable can be used to test if the host part of an URI is in the list. The usefulness of this test is to select the messages that has to be processed locally or has to be forwarded to another server. |
- | **$rr** - reference | + | See **alias** to add hostnames, IP addresses and aliases to the list. |
- | ==== $rs - SIP reply code ==== | + | Example of usage: |
+ | <code c> | ||
+ | if(uri==myself) { | ||
+ | log(" | ||
+ | }; | ||
+ | </code> | ||
- | **$rs** - reference to reply' | + | Note: You can also use the is_myself() function. |
+ | ===== Core parameters ===== | ||
- | ==== $rt - Refer-to URI ==== | + | ==== advertised_address |
- | **$rt** - reference to URI of refer-to | + | It can be an IP address or string and represents the address advertised in Via header. If empty or not set (default value) the socket |
+ | address from where the request will be sent is used. | ||
- | ==== $ru - Request URI ==== | + | WARNING: |
+ | | ||
+ | - you can set anything here, no check is made (e.g. foo.bar will be accepted even if foo.bar doesn' | ||
- | **$ru** - reference to request' | + | Example |
- | <fc # | + | advertised_address=" |
+ | advertised_address=" | ||
- | ==== $rU - Username in R-URI ==== | + | Note: this option may be deprecated and removed in the near future, it is recommended to set **advertise** option for **listen** parameter. |
+ | ==== advertised_port | ||
- | **$rU** - reference to username | + | The port advertised |
- | <fc # | + | Example of usage: |
- | ==== $rUl - R-URI Username Length ==== | + | advertised_port=5080 |
- | **$rU** - the length of the username in R-URI | + | Note: this option may be deprecated and removed in the near future, it is recommended to set **advertise** option for **listen** parameter. |
+ | ==== alias ==== | ||
- | ==== $rv - SIP message version ==== | + | Parameter to set alias hostnames for the server. It can be set many times, each value being added in a list to match the hostname when ' |
- | **$rv** - reference | + | It is necessary |
- | ==== $ruid - Record internal Unique ID ==== | + | |
- | **$ruid** - the Record internal Unique ID for the location record selected by calling registrar:lookup() | + | Example of usage: |
- | ==== $rz - URI Scheme of R-URI ==== | + | < |
+ | alias=other.domain.com: | ||
+ | alias=another.domain.com: | ||
+ | </ | ||
- | **$rz** - returns R-URI scheme, possible values: sip, sips, tel, tels and urn, R-URI scheme parsing error should be reflected by value: none | + | Note: the hostname has to be enclosed in between quotes if it has reserved tokens such as **forward**, **drop** ... or operators such as **-** (minus) ... |
+ | ==== async_workers ==== | ||
- | ==== $RAi - Received advertised IP address ==== | + | Specify how many child processes to create for asynchronous execution. These are processes that can receive tasks from various components and execute them locally, which is different process than the task sender. |
- | **$RAi** - reference to advertised IP address of the interface where the request has been received, or $Ri if no advertised address. | + | Default: 0 (asynchronous framework is disabled). |
- | ==== $RAp - Received advertised port ==== | + | Example: |
- | **$RAp** - reference to advertised port where the request has been received, or $Rp if no advertised port. | + | < |
+ | async_workers=4 | ||
+ | </ | ||
- | ==== $Ri - Received IP address | + | ==== auto_aliases |
- | **$Ri** - reference to IP address of the interface where the request has been received | + | Kamailio by default discovers all IPv4 addresses on all interfaces and does a reverse DNS lookup on these addresses to find host names. Discovered host names are added to aliases list, matching the **myself** condition. To disable host names auto-discovery, turn off auto_aliases. |
- | ==== $Rp - Received port ==== | + | |
- | **$Rp** - reference to the port where the message was received | + | Example: |
- | ==== $RAu - Advertised socket URI ==== | + | < |
+ | auto_aliases=no | ||
+ | </ | ||
+ | ==== auto_bind_ipv6 | ||
- | **$RAu** - local socket where the SIP messages was received in URI format, without transport parameter | + | When turned on, Kamailio will automatically bind to all IPv6 addresses (much like the default behaviour |
- | ==== $RAut - Advertised socket URI ==== | + | Example: |
- | **$RAut** - local socket where the SIP messages was received in URI format, always with transport parameter, using advertised address when available. | + | < |
+ | auto_bind_ipv6=1 | ||
+ | </ | ||
- | ==== $Ru - Received socket URI ==== | + | ==== bind_ipv6_link_local |
- | **$Ru** - local socket where the SIP messages was received in URI format, without transport parameter | + | If set to 1, try to bind also IPv6 link local addresses by discovering |
- | ==== $Rut - Received socket URI ==== | + | Example: |
- | **$Rut** - local socket where the SIP messages was received in URI format, always with transport parameter. | + | < |
+ | bind_ipv6_link_local=1 | ||
+ | </ | ||
+ | ==== check_via ==== | ||
- | ==== $sas - Source | + | Check if the address in top most via of replies is local. Default value is 0 (check disabled). |
- | **$sas** - get source address in socket format (proto:address: | + | Example of usage: |
- | ==== $sbranch(attr) - Static Branch ==== | + | |
- | **$sbranch(attr)** - class of variables allowing to manage the values of attributes for static branch. The static branch is internal structure that is used by the functions sbranch_push_ruri() and sbranch_append() from **pv** module, enabling more flexibility in updating the R-URI (first) branch attributes as well as extra branches (e.g., for parallel forking). | + | check_via=1 |
- | The **attr** can be any of the supported values | + | ==== children ==== |
+ | |||
+ | Number | ||
+ | |||
+ | For configuration | ||
Example of usage: | Example of usage: | ||
- | <code c> | + | children=16 |
- | sbranch_reset(); | + | |
- | $sbranch(uri) | + | |
- | $sbranch(dst_uri) = " | + | |
- | $sbranch(path) = " | + | |
- | $sbranch(send_socket) = " | + | |
- | sbranch_set_ruri(); | + | |
- | </ | + | |
- | ==== $sf - Script flags ==== | + | ==== chroot |
- | **$sf** - reference | + | The value must be a valid path in the system. If set, Kamailio will chroot (change root directory) |
- | ==== $sF - Script flags ==== | + | Example of usage: |
- | **$sF** - reference to script flags - hexa output | + | chroot=/ |
- | ==== $si - Source IP address ==== | ||
- | **$si** - reference to IP source address of the message - see also $siz | + | ==== corelog ==== |
- | ==== $sid - Server ID ==== | + | Set the debug level used to print some log messages from core, which might become annoying and don't represent critical errors. For example, such case is failure to parse incoming traffic from the network as SIP message, due to someone sending invalid content. |
- | **$sid** | + | Default value is -1 (L_ERR). |
- | ==== $siz - Source IP address ==== | + | |
- | **$siz** - reference to IP source address | + | Example |
- | ==== $sp - Source port ==== | + | < |
+ | corelog=1 | ||
+ | </ | ||
+ | ==== debug ==== | ||
- | **$sp** - reference to the source port of the message | + | Set the debug level. Higher values make Kamailio to print more debug messages. Log messages are usually sent to syslog, except if logging to stderr was activated (see [[# |
- | ==== $stat(name) - Statistics ==== | + | The following log levels are defined: |
- | **$stat(name)** | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | ==== $su - Source address as URI ==== | + | A log message will be logged if its log-level is lower than the defined debug level. Log messages are either produced by the the code, or manually in the configuration script using log() or xlog() functions. For a production server you usually use a log value between -1 and 2. |
+ | Default value: L_WARN (debug=0) | ||
- | **$su** - returns the representation | + | Examples |
- | Its value looks like: | + | * debug=3: print all log messages. This is only useful for debugging of problems. Note: this produces a lot of data and therefore should not be used on production servers (on a busy server this can easily fill up your hard disk with log messages) |
+ | * debug=0: This will only log warning, errors and more critical messages. | ||
+ | * debug=-6: This will disable all log messages. | ||
- | < | + | Value of ' |
- | "sip:ip: | + | |
- | " | + | kamcmd cfg.set_now_int core debug 2 |
- | </ | + | kamcmd cfg.set_now_int core debug -- -1 |
- | Note that WS and WSS are both represented by transport=ws, conforming | + | Note: There is a difference in log-levels between Kamailio 3.x and Kamailio< |
- | ==== $sut - Source address as full URI ==== | + | For configuration of logging of the memory manager see the parameters [[#memlog]] and [[# |
- | **$sut** - returns the representation of source address (ip, port, proto) as full SIP URI. The proto UDP is added also as transport parameter. | + | Further information can also be found at: https:// |
- | Its value looks like: | + | ==== description ==== |
- | < | + | **Alias name: descr desc** |
- | "sip:ip:port;transport=proto" | + | |
+ | ==== disable_core_dump ==== | ||
+ | |||
+ | Can be ' | ||
+ | |||
+ | Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_core_dump=yes | ||
+ | |||
+ | ==== disable_tls ==== | ||
+ | |||
+ | **Alias name: tls_disable** | ||
+ | |||
+ | Global parameter to disable TLS support in the SIP server. Default value is ' | ||
+ | |||
+ | Note: Make sure to load the " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_tls=yes | ||
+ | |||
+ | In Kamailio TLS is implemented as a module. Thus, the TLS configuration is done as module configuration. For more details see the README of the TLS module: | ||
+ | http:// | ||
+ | ==== enable_tls ==== | ||
+ | |||
+ | **Alias name: tls_enable** | ||
+ | |||
+ | Reverse Meaning of the disable_tls parameter. See disable_tls parameter. | ||
+ | |||
+ | enable_tls=yes # enable tls support in core | ||
+ | |||
+ | ==== exit_timeout ==== | ||
+ | |||
+ | **Alias name: ser_kill_timeout** | ||
+ | |||
+ | How much time Kamailio will wait for all the shutdown procedures to complete. If this time is exceeded, all the remaining processes are immediately killed and Kamailio exits immediately (it might also generate a core dump if the cleanup part takes too long). | ||
+ | |||
+ | Default: 60 s. Use 0 to disable. | ||
+ | |||
+ | | ||
+ | |||
+ | ==== flags ==== | ||
+ | |||
+ | SIP message (transaction) flags can have string names. | ||
+ | The //name// for flags cannot be used for **branch** or **script flags**(*) | ||
+ | |||
+ | |||
+ | < | ||
+ | ... | ||
+ | flags | ||
+ | FLAG_ONE | ||
+ | FLAG_TWO | ||
+ | ... | ||
</ | </ | ||
- | ==== $td - To URI Domain ==== | ||
- | **$td** - reference to domain | + | (*) The named flags feature was propagated from the source code merge back in 2008 and is not extensively tested. The recommended way of defining flags is using [[cookbooks: |
+ | <code c> | ||
+ | #!define FLAG_NAME FLAG_BIT | ||
+ | </ | ||
- | ==== $tn - To display name ==== | ||
- | **$tn** - reference to display name of ' | ||
- | ==== $tt - To tag ==== | + | ==== force_rport |
- | **$tt** - reference | + | yes/no: Similar |
- | ==== $tti - Initial To tag ==== | + | ==== fork ==== |
- | **$tti** - reference | + | If set to 'yes' |
- | The value To tag in the initial transaction can be in the From tag, if the request within | + | When set to ' |
- | It is exported by **rr** module and has to be used after loose_route(). The append_fromtag parameter is required to be set to 1 in order to have this variable returning the right value. | + | Default value is ' |
- | ==== $tu - To URI ==== | + | |
- | **$tu** - reference to URI of ' | + | Example |
- | ==== $tU - To URI Username ==== | + | fork=no |
- | **$tU** - reference to username in URI of ' | + | ==== fork_delay ==== |
- | ==== $tUl - To URI Username Length ==== | + | Number of usecs to wait before forking a process. |
- | **$tU** - the length of the username in To URI | + | Default is 0 (don't wait). |
- | ==== $Tb - Startup timestamp ==== | + | Example of usage: |
- | **$Tb** - reference to unix timestamp of the time at which kamailio was started (boot time) | + | <code c> |
+ | fork_delay=5000 | ||
+ | </ | ||
+ | ==== group ==== | ||
- | ==== $Tf - String formatted time - cached ==== | + | **Alias name: gid** |
- | **$Tf** - reference string formatted time | + | The group id to run Kamailio. |
- | Note: the system time is retrieved only once for each processed SIP message. Subsequent calls of $Tf for same SIP message will return same value. | + | Example |
- | ==== $TF - String formatted time - current ==== | + | group=" |
- | **$TF** - reference string formatted time | + | ==== http_reply_parse ==== |
- | Note: the system time is computed for each call of $TF. Subsequent calls of $TF for same SIP message may return different values. | + | Alias: http_reply_hack |
- | ==== $Ts - Unix time stamp - cached ==== | + | When enabled, Kamailio can parse HTTP replies, but does so by treating them as SIP replies. |
- | **$Ts** - reference to unix time stamp | + | Default value is ' |
- | Note: the system time is retrieved only once for each processed SIP message. Subsequent calls of $Ts for same SIP message will return same value. | + | Example |
- | ==== $TS - Unix time stamp - current ==== | + | http_reply_parse=yes |
- | **$TS** - reference to unix time stamp | + | ==== ip_free_bind ==== |
- | Note: the system time is computed for each call of $TS. Subsequent calls of $TS for same SIP message may return different values. | + | Alias: ipfreebind, ip_nonlocal_bind |
- | ==== $ua - User agent header ==== | + | Control if Kamailio should attempt to bind to non local ip. This option is the per-socket equivalent of the system **ip_nonlocal_bind**. |
- | **$ua** - reference | + | Default is 0 (do not bind to non local ip). |
- | ==== $version() - version ==== | + | Example of usage: |
- | **$version(num)** - version as number | + | <code c> |
+ | ip_free_bind = 1 | ||
+ | </ | ||
- | **$version(full)** - full version string "name version architecture/ | + | ==== kemi.onsend_route_callback ==== |
- | **$version(hash)** - TBA | + | Set the name of callback function in the KEMI script to be executed as the equivalent of `onsend_route` block (from the native configuration file). |
- | ===== $env(NAME) - environment variables ===== | + | Default value: ksr_onsend_route |
- | **$env(NAME)** - value of the environment variable named NAME | + | Set it to empty string or " |
Example: | Example: | ||
<code c> | <code c> | ||
- | xdbg("PATH environment variable: | + | kemi.onsend_route_callback="ksr_my_onsend_route" |
</ | </ | ||
- | ===== $avp(id) - AVPs ===== | ||
- | **$avp(id)** - the value of the AVP identified by ' | + | ==== kemi.received_route_callback ==== |
- | **$(avp(id)[N])** - represents the value of N-th AVP identified by ' | + | Set the name of callback function in the KEMI script to be executed as the equivalent of `event_route[core: |
- | The ' | + | Default value: none |
- | * " | + | Set it to empty string |
- | * "name" | + | |
- | * pseudo variable - if value of pv is integer, id is integer, if string, id is string | + | |
- | $(avp(id)[0]) can be written in shorter form as $avp(id) and $avp(s:name) as $avp(name). | + | Example: |
- | AVPs are special variables that are attached to SIP transactions. It is a list of pairs (name, | + | <code c> |
+ | kemi.received_route_callback=" | ||
+ | </ | ||
+ | |||
+ | ==== kemi.reply_route_callback ==== | ||
+ | |||
+ | Set the name of callback function in the KEMI script | ||
+ | |||
+ | Default | ||
+ | |||
+ | Set it to empty string or " | ||
+ | |||
+ | Example: | ||
- | To delete the first AVP with name ' | ||
<code c> | <code c> | ||
- | $avp(id) | + | kemi.onsend_route_callback=" |
</ | </ | ||
+ | ==== latency_cfg_log ==== | ||
+ | |||
+ | If set to a log level less or equal than debug parameter, a log message with the duration in microseconds of executing request route or reply route is printed to syslog. | ||
+ | |||
+ | Default value is 3 (L_DBG). | ||
+ | |||
+ | Example: | ||
- | To delete all the AVP with name ' | ||
<code c> | <code c> | ||
- | $(avp(id)[*]) | + | latency_cfg_log=2 |
</ | </ | ||
- | To overwrite the value of the AVP with name 'id' you have to assign the new value to the index ' | + | ==== latency_limit_action ==== |
+ | |||
+ | Limit of latency in us (micro-seconds) for config actions. If a config action executed by cfg interpreter takes longer than its value, a message is printed in the logs, showing config path, line and action | ||
+ | |||
+ | Default | ||
<code c> | <code c> | ||
- | $(avp(id)[*]) | + | latency_limit_action=500 |
</ | </ | ||
+ | |||
+ | ==== latency_limit_db ==== | ||
- | The value of an AVP can be integer or string. To assign | + | Limit of latency in us (micro-seconds) for db operations. If a db operation executed via DB API v1 takes longer that its value, |
- | Example of usage: | + | |
+ | Default value is 0 (disabled). | ||
<code c> | <code c> | ||
- | $avp(x) | + | latency_limit_db=500 |
- | $avp(x) = 2; | + | |
- | $avp(y) = " | + | |
- | if($(avp(x)[1])==1) { | + | |
- | ... | + | |
- | } | + | |
- | $(avp(x)[1]) = $null; | + | |
</ | </ | ||
- | It is R/W variable (you can assign values to it directly in configuration file). | ||
- | ===== $expires(key) - Expires Values ===== | + | ==== latency_log |
- | Return | + | Log level to print the messages related to latency. |
- | If none is found, $null is returned. | ||
- | Possible ' | + | Default value is -1 (L_ERR). |
+ | |||
+ | <code c> | ||
+ | latency_log=3 | ||
+ | </ | ||
- | * $expires(min) - the minimum value for expires | + | ==== listen ==== |
- | * $expires(max) - the maximum value for expires | + | |
- | When there is only one expires value, then min and max return | + | Set the network addresses the SIP server should listen to. It can be an IP address, hostname or network interface id or combination of protocol: |
Example of usage: | Example of usage: | ||
<code c> | <code c> | ||
- | if($expires(max)!=$null) { | + | listen=10.10.10.10 |
- | | + | |
- | } | + | |
</ | </ | ||
- | ===== $xavp(id) - XAVPs ===== | + | If you omit this directive then the SIP server will listen on all interfaces. On start the SIP server reports all the interfaces that it is listening on. Even if you specify only UDP interfaces here, the server will start the TCP engine too. If you don't want this, you need to disable the TCP support completely with the core parameter disable_tcp. |
- | **xavp** - eXtended AVPs - are variables that can store multiple values, which can also be grouped in a structure-like fashion. Their value can be a string, an integer number or a list of named values (child values). | + | If you specify IPv6 addresses, you should put them into square brackets, e.g.: |
- | They work like a stack, similar to AVPs, and are attached to SIP transactions and automatically destroyed when the transaction is finished. | + | <code c> |
+ | listen=udp: | ||
+ | </ | ||
- | Each xavp has a string name and can contain a string, and integer or a list of named values. The structure name (or root list name) and the value name (or field name, or child value name) are separated by < | + | You can specify an advertise address |
- | + | ||
- | To assign a single value use: | + | |
<code c> | <code c> | ||
- | $xavp(root)=" | + | listen=udp: |
- | $xavp(root)=intnumber; | + | |
</ | </ | ||
- | To assign | + | The advertise address must be the format ' |
+ | |||
+ | A typical | ||
+ | |||
+ | A unique name can be set for sockets to simplify the selection of the socket for sending out. For example, the rr and path modules can use the socket name to advertise it in header URI parameter and use it as a shortcut to select the corresponding socket for routing subsequent requests. | ||
+ | |||
+ | The name has to be provided as a string enclosed in between quotes after the **name** identifier. | ||
<code c> | <code c> | ||
- | $xavp(root=>field)="string value"; | + | listen=udp: |
- | $xavp(root=>field)=intnumber; | + | listen=udp: |
+ | | ||
+ | listen=udp: | ||
+ | ... | ||
+ | | ||
+ | t_relay(); | ||
</ | </ | ||
- | Like avps, xavp act like a stack. To refer to an existing value, use an index. The newest xavp has index zero [0]. | + | Note that there is no internal check for uniqueness of the socket names, the admin has to ensure it in order to be sure the desired socket is selected, otherwise the first socket with a matching name is used. |
+ | ==== loadmodule ==== | ||
+ | Loads a module for later usage in the configuration script. The modules is searched in the path specified by **loadpath**. | ||
+ | |||
+ | Prototype: **loadmodule " | ||
+ | |||
+ | If modulepath is only modulename or modulename.so, | ||
+ | |||
+ | Example of usage: | ||
<code c> | <code c> | ||
- | $xavp(root[0]=> | + | loadpath "/ |
+ | |||
+ | loadmodule "/ | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
</ | </ | ||
- | If you assign | + | ==== loadpath ==== |
+ | |||
+ | **Alias name: mpath** | ||
+ | |||
+ | Set the module search path. loadpath takes a list of directories separated by ':' | ||
+ | |||
+ | This can be used to simplify | ||
+ | |||
+ | Example of usage: | ||
<code c> | <code c> | ||
- | # new item (person => [(lastname = "Smith")]) | + | loadpath |
- | $xavp(person=> | + | |
- | # add new item (person => [(lastname = "Doe")]) | + | loadmodule |
- | $xavp(person=> | + | |
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | </ | ||
- | # add another named value to the last example item | + | The proxy tries to find the modules in a smart way, e.g: loadmodule |
- | # | + | |
- | $xavp(person[0]=> | + | |
- | # add another named value to first example item | + | |
- | # | + | ==== log_engine_data ==== |
- | xavp(person[1]=> | + | |
+ | Set specific data required by the log engine. See also the **log_engine_type**. | ||
+ | |||
+ | <code c> | ||
+ | log_engine_type="udp" | ||
+ | log_engine_data="127.0.0.1:9" | ||
</ | </ | ||
+ | ==== log_engine_type ==== | ||
+ | |||
+ | Specify what logging engine to be used and its initialization data. A logging engine is implemented as a module. Supported values are a matter of the module. | ||
+ | |||
+ | For example, see the readme of **log_custom** module for more details. | ||
- | Another example: | ||
<code c> | <code c> | ||
- | # create new (the first) root xavp with a named value of string type | + | log_engine_type=" |
- | $xavp(sf=> | + | log_engine_data="127.0.0.1:9" |
+ | </ | ||
- | # add named values (child values) | ||
- | $xavp(sf[0]=> | ||
- | $xavp(sf[0]=> | ||
- | $xavp(sf[0]=> | ||
- | # create new (the second) root xavp with a named value of string type, moving previous one to sf[1] | + | ==== log_facility ==== |
- | $xavp(sf=>uri)=" | + | |
- | # add named values (child values) | + | |
- | $xavp(sf[0]=> | + | |
- | $xavp(sf[0]=> | + | |
- | # create new (the third) xavp with a named value of string type, moving previous one to sf[1] and the other one to sf[2] | + | If Kamailio logs to syslog, you can control |
- | $xavp(sf=>uri)="sip:10.10.10.12"; | + | |
- | # add named values (child values) | + | For more see: http://www.kamailio.org/ |
- | $xavp(sf[0]=> | + | |
- | $xavp(sf[0]=> | + | Default value is LOG_DAEMON. |
- | $xavp(sf[0]=>headers)="X-CustomerID: pw45\r\n"; | + | |
+ | Example of usage: | ||
+ | |||
+ | log_facility=LOG_LOCAL0 | ||
+ | |||
+ | ==== log_name ==== | ||
+ | |||
+ | Allows to configure a log_name prefix which will be used when printing to syslog -- it is also known as syslog tag, and the default value is the application name or full path that printed the log message. This is useful to filter log messages when running many instances of Kamailio on same server. | ||
+ | |||
+ | <code> | ||
+ | log_name="kamailio-proxy-5080" | ||
</ | </ | ||
- | xavps are read and write variables. | + | ==== log_prefix ==== |
- | ===== $xavu(id) - XAVUs ===== | + | Specify the text to be prefixed to the log messages printed by Kamailio while processing a SIP message |
+ | See [[# | ||
- | Similar to XAVPs, but with single value items, therefore there are no indexes in the naming format. XAVUs are also stored in transaction context and destroyed when the transaction is terminated. | ||
- | Examples: | + | If a log message is printed from a part of the code executed out of routing blocks actions (e.g., can be timer, evapi worker process, ...), there is no log prefix set, because this one requires a valid SIP message structure to work with. |
- | <code c> | + | Example - prefix with message type (1 - request, 2 - response), CSeq and Call-ID: |
- | $xavu(x) = 123; # <- set the value | + | |
- | $xavu(x) = 234; # <- update to the value, not adding to a list like for xavps | + | <code> |
- | $xavu(x) | + | log_prefix="{$mt $hdr(CSeq) $ci} " |
- | $xavu(a=>b) = "xyz"; # <- two level naming supported | + | |
</ | </ | ||
- | ===== $xavi(id) - XAVIs ===== | + | ==== log_prefix_mode |
- | Similar to XAVPs, but with key names are case insensitive. XAVIs are also stored in transaction context and destroyed when the transaction | + | Control if [[# |
+ | If set to 0 (default), then log prefix is evaluated when the sip message is received and then reused (recommended if the **log_prefix** has only variables that have same value for same message). This is the current behaviour of **log_prefix** evaluation. | ||
- | Examples: | + | If set to 1, then the log prefix is evaluated before/ |
- | < | + | Example: |
- | $xavi(WhatEver=> | + | |
- | # $xavi(whatever[0]=> | + | < |
+ | log_prefix_mode=1 | ||
</ | </ | ||
- | ===== $hdr(name) - Headers ===== | + | ==== log_stderror |
+ | With this parameter you can make Kamailio to write log and debug messages to standard error. Possible values are: | ||
- | **$hdr(name)** | + | - " |
- | **$(hdr(name)[N])** | + | - " |
+ | |||
+ | Default value is " | ||
+ | |||
+ | For more see: http:// | ||
+ | |||
+ | Example of usage: | ||
- | 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=' | + | log_stderror=yes |
- | If name is *, then any header name is matched, e.g., $hdr(*) is body of first header, $(hdr(*)[-1]) is body of last header. | + | ==== cfgengine ==== |
- | 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. | + | Set the config interpreter engine for execution of the routing logic inside the configuration file. Default |
Example of usage: | Example of usage: | ||
- | <code c> | + | cfgengine="name" |
- | if($hdr(From)=~"kamailio\.org") { | + | cfgengine " |
- | ... | + | |
- | } | + | If name is " |
+ | |||
+ | The name can be the identifier of an embedded language interpreter, | ||
+ | |||
+ | cfgengine " | ||
+ | |||
+ | ==== maxbuffer ==== | ||
+ | |||
+ | The size in bytes not to be exceeded during the auto-probing procedure of descovering the maximum buffer size for receiving UDP messages. Default value is 262144. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | maxbuffer=65536 | ||
+ | |||
+ | ==== max_branches ==== | ||
+ | |||
+ | The maximum number of outgoing branches for each SIP request. It has impact on the size of destination set created in core (e.g., via append_branch()) as well as the serial and parallel forking done via tm module. It replaces the old defined constant MAX_BRANCHES. | ||
+ | |||
+ | The value has to be at least 1 and the upper limit is 31. | ||
+ | |||
+ | Default value: 12 | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | < | ||
+ | max_branches=16 | ||
</ | </ | ||
- | <fc # | + | ==== max_recursive_level ==== |
- | ===== $hdrc(name) - Number of Headers ===== | + | The parameters set the value of maximum recursive calls to blocks of actions, such as sub-routes or chained IF-ELSE |
- | **$hdrc(name)** - get the number | + | Example of usage: |
+ | |||
+ | max_recursive_level=500 | ||
+ | |||
+ | |||
+ | ==== max_while_loops ==== | ||
+ | |||
+ | The parameters set the value of maximum loops that can be done within a " | ||
Example of usage: | Example of usage: | ||
+ | |||
+ | max_while_loops=200 | ||
+ | |||
+ | ==== mcast ==== | ||
+ | |||
+ | This parameter can be used to set the interface that should join the multicast group. This is useful if you want to **listen** on a multicast address and don't want to depend on the kernel routing table for choosing an interface. | ||
+ | |||
+ | The parameter is reset after each **listen** parameter, so you can join the right multicast group on each interface without having to modify kernel routing beforehand. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mcast=" | ||
+ | listen=udp: | ||
+ | |||
+ | ==== mcast_loopback ==== | ||
+ | |||
+ | It can be ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mcast_loopback=yes | ||
+ | |||
+ | ==== mcast_ttl ==== | ||
+ | |||
+ | Set the value for multicast ttl. Default value is OS specific (usually 1). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mcast_ttl=32 | ||
+ | |||
+ | ==== memdbg ==== | ||
+ | |||
+ | **Alias name: mem_dbg** | ||
+ | |||
+ | This parameter specifies on which log level the memory debugger messages will be logged. If memdbg is active, every request (alloc, free) to the memory manager will be logged. (Note: if compile option NO_DEBUG is specified, there will never be logging from the memory manager). | ||
+ | |||
+ | Default value: L_DBG (memdbg=3) | ||
+ | |||
+ | For example, memdbg=2 means that memory debugging is activated if the debug level is 2 or higher. | ||
+ | |||
+ | debug=3 | ||
+ | memdbg=4 | ||
+ | |||
+ | debug=3 | ||
+ | memdbg=2 | ||
+ | |||
+ | Please see also [[#memlog]] and [[#debug]]. | ||
+ | |||
+ | ==== memlog ==== | ||
+ | |||
+ | **Alias name: mem_log** | ||
+ | |||
+ | This parameter specifies on which log level the memory statistics will be logged. If memlog is active, Kamailio will log memory statistics on shutdown (or if requested via signal SIGUSR1). This can be useful for debugging of memory leaks. | ||
+ | |||
+ | Default value: L_DBG (memlog=3) | ||
+ | |||
+ | For example, memlog=2 means that memory statistics dumping is activated if the debug level is 2 or higher. | ||
+ | |||
+ | debug=3 | ||
+ | memlog=4 | ||
+ | |||
+ | debug=3 | ||
+ | memlog=2 | ||
+ | |||
+ | Please see also [[#memdbg]] and [[#debug]]. | ||
+ | |||
+ | ==== mem_join ==== | ||
+ | |||
+ | If set to 1, memory manger (e.g., q_malloc) does join of free fragments. It is effective if MEM_JOIN_FREE compile option is defined. | ||
+ | |||
+ | It can be set via config reload framework. | ||
+ | |||
+ | Default is 1 (enabled). | ||
<code c> | <code c> | ||
- | if($hdrc(Via) | + | mem_join=1 |
- | ... | + | |
- | } | + | |
</ | </ | ||
- | ===== $var(name) - Private memory variables (zero) ===== | + | To change its value at runtime, **kamcmd** needs to be used and the modules **ctl** and **cfg_rpc** loaded. Enabling it can be done with: |
- | **$var(name)** - refers to variables that can be used in configuration script, having integer or string value. This kind of variables are faster than AVPs, being referenced directly to memory location. | + | < |
+ | kamcmd cfg.set_now_int core mem_join 1 | ||
+ | </ | ||
- | Example of usage: | + | To disable, set its value to 0. |
+ | ==== mem_safety ==== | ||
+ | |||
+ | If set to 1, memory free operation does not call abort() for double freeing a pointer or freeing an invalid address. The server still prints the alerting log messages. If set to 0, the SIP server stops by calling abort() to generate a core file. | ||
+ | |||
+ | It can be set via config reload framework. | ||
+ | |||
+ | Default is 1 (enabled). | ||
<code c> | <code c> | ||
- | $var(a) | + | mem_safety=0 |
- | $var(a) = " | + | </ |
- | $var(a) = " | + | |
- | $var(a) = 3 + (7& | + | |
- | if( $var(a) & 4 ) { | + | ==== mem_status_mode ==== |
- | | + | |
- | } | + | If set to 1, memory status dump for qm allocator will print details about used fragments. If set to 0, the dump contains only free fragments. It can be set at runtime via cfg param framework (e.g., via kamcmd). |
+ | |||
+ | Default is 0. | ||
+ | |||
+ | <code c> | ||
+ | mem_status_mode=1 | ||
</ | </ | ||
- | **Note:** Setting a variable | + | ==== mem_summary ==== |
+ | |||
+ | Parameter to control printing of mmemory debugging information displayed on exit or SIGUSR1. The value can be composed by following flags: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | If set to 0, nothing is printed. | ||
+ | |||
+ | Default | ||
+ | |||
+ | Example: | ||
<code c> | <code c> | ||
- | $var(x) | + | mem_summary=15 |
+ | </ | ||
- | if($var(x)==0) { # this is true | + | ==== mhomed ==== |
- | ... | + | |
- | } | + | Set the server to try to locate outbound interface on multihomed host. This parameter affects the selection of the outgoing socket for forwarding requests. By default is off (0) - it is rather time consuming. When deactivated, |
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mhomed=1 | ||
+ | |||
+ | ==== mlock_pages ==== | ||
+ | Locks all Kamailio pages into memory making it unswappable (in general one doesn' | ||
+ | |||
+ | | ||
+ | |||
+ | ==== modinit_delay ==== | ||
+ | |||
+ | Number of microseconds to wait after initializing a module - useful to cope with systems where are rate limits on new connections to database or other systems. | ||
+ | |||
+ | Default value is 0 (no wait). | ||
+ | |||
+ | < | ||
+ | modinit_delay=100000 | ||
</ | </ | ||
- | **Note:** A script variable persists over the Kamailio process in which it was initialized, | ||
- | <fc # | + | ==== modparam ==== |
+ | The modparam command will be used to set the options of the modules. | ||
- | **pv** module can be used to initialize the script variables. | + | Example: |
- | ===== $vz(name) - Private memory variables | + | modparam(" |
+ | modparam(" | ||
- | Same as $var(name) -- added to pair with $vn(name). | + | See the documenation of the respective module |
- | ===== $vn(name) - Private memory variables (null) ===== | + | ==== onsend_route_reply |
- | Similar | + | If set to 1 (yes, on), onsend_route block is executed for received replies that are sent out. Default is 0. |
+ | |||
+ | onsend_route_reply=yes | ||
+ | |||
+ | ==== open_files_limit ==== | ||
+ | |||
+ | If set and bigger than the current open file limit, Kamailio will try to increase its open file limit to this number. Note: Kamailio must be started as root to be able to increase a limit past the hard limit (which, for open files, | ||
Example of usage: | Example of usage: | ||
- | <code c> | + | open_files_limit=2048 |
- | $vn(x) | + | |
- | $vn(x) = " | + | |
- | $vn(x) = $null; | + | |
- | if($vn(x) == $null) { ... } | + | ==== phone2tel ==== |
+ | By enabling this feature, Kamailio internally treats SIP URIs with user=phone parameter as TEL URIs. If you do not want this behavior, you have to turn it off. | ||
+ | |||
+ | Default value: 1 (enabled) | ||
+ | |||
+ | phone2tel | ||
+ | |||
+ | |||
+ | ==== pmtu_discovery ==== | ||
+ | If enabled, the Don't Fragment (DF) bit will be set in outbound IP packets. | ||
+ | |||
+ | pmtu_discovery = 0 | 1 (default 0) | ||
+ | |||
+ | ==== port ==== | ||
+ | |||
+ | The port the SIP server listens to. The default value for it is 5060. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | port=5080 | ||
+ | |||
+ | ==== pv_buffer_size ==== | ||
+ | |||
+ | The size in bytes of internal buffer to print dynamic strings with pseudo-variables inside. The default value is 8192 (8kB). Please keep in mind that for xlog messages, there is a dedicated module parameter to set the internal buffer size. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | < | ||
+ | pv_buffer_size=2048 | ||
</ | </ | ||
- | ===== $shv(name) - Shared memory variables ===== | ||
- | **$shv(name)** | + | ==== pv_buffer_slots ==== |
- | Example - shv(name) | + | The number of internal buffer slots to print dynamic strings with pseudo-variables inside. The default value is 10. |
+ | |||
+ | Example of usage: | ||
< | < | ||
- | ... | + | pv_buffer_slots=12 |
- | modparam(" | + | |
- | ... | + | |
- | if ($shv(debug) == 1) { | + | |
- | xlog(" | + | |
- | } | + | |
- | ... | + | |
</ | </ | ||
- | <fc # | + | ==== pv_cache_limit ==== |
- | ===== $dsv(key) - Dispatcher variables ===== | + | The limit how many pv declarations in the cache after which an action is taken. Default value is 2048. |
- | Return attributes related to dispatcher module. | + | < |
+ | pv_cache_limit=1024 | ||
+ | </ | ||
- | The key can be: | + | ==== pv_cache_action ==== |
- | * code - the SIP response code that caused the execution | + | Specify what action to be done when the size of pv cache is exceeded. If 0, print an warning log message when the limit is exceeded. If 1, warning log messages is printed and the cache systems tries to drop a $sht(...) declaration. Default is 0. |
- | * reason - the SIP response reason that caused | + | |
- | * flags - flags set internally when executing event_route ' | + | |
- | ===== $time(name) - Broken-down time ===== | + | |
- | **$time(name)** - the PV provides access to broken-down time attributes in the local timezone. | + | < |
+ | pv_cache_action=1 | ||
+ | </ | ||
- | The ' | + | ==== rundir ==== |
- | * sec - return seconds (int 0-59) | + | |
- | * min - return minutes (int 0-59) | + | |
- | * hour - return hours (int 0-23) | + | |
- | * mday - return the day of month (int 0-59) | + | |
- | * mon - return the month (int 1-12) | + | |
- | * year - return the year (int, e.g., 2008) | + | |
- | * wday - return the day of week (int, 1=Sunday - 7=Saturday) | + | |
- | * yday - return the day of year (int, 1-366) | + | |
- | * isdst - return daylight saving time status (int, 0 - DST off, >0 DST on) | + | |
- | Example - time(name) pseudo-variable | + | Alias: run_dir |
+ | |||
+ | Set the folder for creating runtime files such as MI fifo or CTL unixsocket. | ||
+ | |||
+ | Default: / | ||
+ | |||
+ | Example | ||
+ | |||
+ | < | ||
+ | rundir="/ | ||
+ | </ | ||
+ | |||
+ | ==== received_route_mode ==== | ||
+ | |||
+ | Enable or disable the execution of event_route[core: | ||
+ | |||
+ | Default value: 0 (disabled) | ||
+ | |||
+ | Example of usage: | ||
<code c> | <code c> | ||
- | ... | + | received_route_mode=1 |
- | if ($time(year) | + | |
- | xlog(" | + | |
- | } | + | |
- | ... | + | |
</ | </ | ||
- | ===== $utime(name) - Broken-down time ===== | + | ==== reply_to_via |
- | **$utime(name)** - the PV provides access | + | If it is set to 1, any local reply is sent to the IP address advertised |
- | See **$time(name)** above for the possible attributes | + | Example of usage: |
- | ===== $timef(format) - Strftime Formatted Time ===== | + | |
- | **$timef(format)** | + | reply_to_via=0 |
+ | |||
+ | |||
+ | ==== route_locks_size ==== | ||
+ | |||
+ | Set the number of mutex locks to be used for synchronizing the execution of config script for messages sharing the same Call-Id. In other words, enables Kamailio | ||
+ | |||
+ | For smaller impact on parallel processing, its value it should be at least twice the number of Kamailio processes (all children processes). | ||
Example: | Example: | ||
<code c> | <code c> | ||
- | xlog(" | + | route_locks_size = 256 |
</ | </ | ||
- | ===== $utimef(format) - Strftime Formatted UTC Time ===== | + | Note that ordering of the SIP messages can still be changed by network transmission |
+ | ==== server_id | ||
- | **$utimef(format)** - return current time in UTC as formatted by strftime ' | + | A configurable unique server id that can be used to discriminate server instances within a cluster of servers when all other information, |
- | Example: | + | <code c> |
+ | server_id = number | ||
+ | </ | ||
+ | |||
+ | ==== server_header ==== | ||
+ | |||
+ | Set the value of Server header for replies generated by Kamailio. It must contain the header name, but not the ending CRLF. | ||
+ | |||
+ | Example | ||
<code c> | <code c> | ||
- | xlog("The time is $utimef(%m/ | + | server_header="Server: My Super SIP Server" |
</ | </ | ||
- | ===== $sel(name) - Selects ===== | + | ==== server_signature |
- | **$sel(name)** - return | + | This parameter controls |
- | List of available selects: | + | Example |
- | * http:// | + | |
- | Example: | + | |
+ | |||
+ | If it is enabled (default=yes) a header is generated as in the following example: | ||
+ | |||
+ | | ||
+ | |||
+ | ==== shm_force_alloc ==== | ||
+ | Tries to pre-fault all the shared memory, before starting. When " | ||
+ | |||
+ | shm_force_alloc = yes | no (default no) | ||
+ | |||
+ | ==== shm_mem_size ==== | ||
+ | |||
+ | Set shared memory size (in Mb). | ||
+ | |||
+ | shm_mem_size = 64 (default 64) | ||
+ | |||
+ | ==== sip_warning (noisy feedback) ==== | ||
+ | |||
+ | Can be 0 or 1. If set to 1 (default value is 0) a ' | ||
+ | The header contains several details that help troubleshooting using the network traffic dumps, but might reveal details of your network infrastructure and internal SIP routing. | ||
+ | |||
+ | Example | ||
+ | |||
+ | sip_warning=0 | ||
+ | |||
+ | ==== socket_workers ==== | ||
+ | |||
+ | Number of workers to process SIP traffic per listen socket - typical use is before a **listen** global parameter. | ||
+ | |||
+ | * when used before **listen** on UDP or SCTP socket, it overwrites **children** or **sctp_children** value for that socket. | ||
+ | * when used before **listen** on TCP or TLS socket, it adds extra tcp workers, these handling traffic only on that socket. | ||
+ | |||
+ | The value of **socket_workers** is reset with next **listen** socket definition that is added, thus use it for each **listen** socket where you want custom number of workers. | ||
+ | |||
+ | If this parameter is not used at all, the values for **children**, | ||
+ | |||
+ | Example for udp sockets: | ||
<code c> | <code c> | ||
+ | children=4 | ||
+ | socket_workers=2 | ||
+ | listen=udp: | ||
+ | listen=udp: | ||
+ | listen=udp: | ||
+ | </ | ||
- | if($sel(via[1].host)=="10.10.10.10") | + | * it will start 2 workers to handle traffic on udp: |
- | { | + | |
- | ... | + | Example for tcp sockets: |
+ | |||
+ | <code c> | ||
+ | children=4 | ||
+ | socket_workers=2 | ||
+ | listen=tcp: | ||
+ | listen=tcp: | ||
+ | listen=tcp: | ||
+ | </ | ||
+ | |||
+ | * it will start 2 workers to handle traffic on tcp: | ||
+ | |||
+ | ==== sql_buffer_size ==== | ||
+ | |||
+ | The size in bytes of the SQL buffer created for data base queries. For database drivers that use the core db_query library, this will be maximum size object that can be written or read from a database. Default value is 65535. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | sql_buffer_size=131070 | ||
+ | |||
+ | |||
+ | ==== statistics ==== | ||
+ | |||
+ | Kamailio has built-in support for statistics counter. This means, these counters can be increased, decreased, read and cleared. The statistics counter are defined either by the core (e.g. tcp counters), by modules (e.g. 2xx_transactions by "tmx" module) or by the script writer using the " | ||
+ | |||
+ | The statistics counters are read/ | ||
+ | |||
+ | Following are some examples how to access statistics variables: | ||
+ | |||
+ | **script** | ||
+ | < | ||
+ | modparam(" | ||
+ | |||
+ | (if method == " | ||
+ | update_stat(" | ||
} | } | ||
+ | |||
+ | xlog(" | ||
</ | </ | ||
- | ===== Received Data Attributes ===== | + | **MI** |
+ | < | ||
+ | # get counter value | ||
+ | kamctl fifo get_statistics NOTIFY | ||
+ | # set counter to zero | ||
+ | kamctl fifo reset_statistics NOTIFY | ||
+ | # get counter value and then set it to zero | ||
+ | kamctl fifo clear_statistics NOTIFY | ||
- | ==== $rcv(key) ==== | + | # or use the kamcmd tool |
+ | kamcmd mi get_statistics 1xx_replies | ||
+ | </ | ||
- | Attributes of received data. The variables must be used inside **event_route[core: | ||
- | The key can be: | + | ==== stats_name_separator ==== |
- | * buf - received message | + | Specify the character used as a separator for the internal statistics' |
- | * len - lenght of received message | + | Default value is " |
- | * srcip - source ip | + | |
- | * rcvip - local ip where it was received | + | |
- | * scrport - source port | + | |
- | * rcvport - local port where it was received | + | |
- | * proto - protocol as int id | + | |
- | * sproto - protocol | + | |
- | * af - address family | + | |
Example of usage: | Example of usage: | ||
+ | |||
+ | stats_name_separator = " | ||
+ | |||
+ | ==== tos ==== | ||
+ | |||
+ | The TOS (Type Of Service) to be used for the sent IP packages (both TCP and UDP). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tos=IPTOS_LOWDELAY | ||
+ | tos=0x10 | ||
+ | tos=IPTOS_RELIABILITY | ||
+ | |||
+ | ==== udp_mtu ==== | ||
+ | Fallback to another protocol (udp_mtu_try_proto must be set also either globally or per packet) if the constructed request size is greater then udp_mtu. | ||
+ | |||
+ | RFC 3261 specified size: 1300. Default: 0 (off). | ||
+ | |||
+ | udp_mtu = number | ||
+ | |||
+ | ==== udp_mtu_try_proto ==== | ||
+ | |||
+ | If udp_mtu !=0 and udp forwarded request size (after adding all the " | ||
+ | |||
+ | **Warning: | ||
+ | |||
+ | See also udp_mtu_try_proto(proto) function. | ||
+ | |||
+ | Default: UDP (off). Recommended: | ||
+ | |||
+ | udp_mtu_try_proto = TCP|TLS|SCTP|UDP | ||
+ | |||
+ | |||
+ | ==== uri_host_extra_chars ==== | ||
+ | |||
+ | Specify additional chars that should be allowed in the host part of URI. | ||
<code c> | <code c> | ||
- | event_route[core: | + | uri_host_extra_chars = "_" |
- | xlog("rcv on $rcv(af)/ | + | |
- | } | + | |
</ | </ | ||
+ | ==== user ==== | ||
- | ===== Send Data Attributes ===== | + | **Alias name: uid** |
- | ==== $sndfrom(name) ==== | + | The user id to run Kamailio |
- | **$snd(name)** - return attributes | + | Example |
- | **$sndfrom(name)** - return attributes of the address from where the request is going to be sent (local socket, same as $snd(name)). | + | <code c> |
+ | user=" | ||
+ | </ | ||
- | The name can have same values as for $sndto(...). | + | ==== user_agent_header ==== |
- | ==== $sndto(name) ==== | + | Set the value of User-Agent header for requests generated by Kamailio. It must contain header |
- | **$sndto(name)** | + | <code c> |
+ | user_agent_header=" | ||
+ | </ | ||
- | They are available in **onsend_route**. The name can be: | + | ==== verbose_startup ==== |
- | * ip - IP address of destination | + | Control if printing routing tree and udp probing buffer debug messages should |
- | * af - address family to be used to send (numeric) | + | |
- | * port - port of destination address | + | |
- | * proto - transport protocol to be used to send (numeric - UDP=1, TCP=2, TLS=3, SCTP=4, WS=5, WSS=6) | + | |
- | * sproto - transport protocol to be used to send (string) | + | |
- | * buf - entire send buffer as string | + | |
- | * len - length of outgoing packet (length of above buf) | + | |
- | Example: | + | Default is 0 (don't print); set to 1 to get those debug messages. |
+ | |||
+ | Example | ||
<code c> | <code c> | ||
+ | | ||
+ | </ | ||
- | onsend_route { | + | ==== version_table ==== |
- | if($snd(ip)==" | + | |
- | { | + | Set the name of the table holding the table version. Useful if the proxy is sharing a database within a project and during upgrades. Default value is " |
- | ... | + | |
- | } | + | Example of usage: |
- | } | + | |
+ | <code c> | ||
+ | | ||
</ | </ | ||
+ | ==== workdir ==== | ||
+ | |||
+ | **Alias name: wdir** | ||
+ | |||
+ | The working directory used by Kamailio at runtime. You might find it useful when it comes to generating core files :) | ||
+ | |||
+ | Example of usage: | ||
- | ===== SIPDUMP Module ===== | + | wdir="/ |
+ | or | ||
+ | wdir=/usr/kam_wd | ||
- | ==== $sipdump(name) | + | ==== xavp_via_params |
- | **$sipdump(name)** - return attributes | + | Set the name of the XAVP of which subfields will be added as local //Via// -header parameters. |
- | The name can be: | + | If not set, XAVP to Via header parameter manipulation is not applied (default behaviour). |
- | * tag - the tag of processing (rcv or snd) | + | If set, local Via header gets additional parameters from defined XAVP. Core flag FL_ADD_XAVP_VIA_PARAMS needs to be set¹. |
- | * buf - entire message buffer as string | + | |
- | * len - length of the message | + | Example: |
- | * af - address family | + | |
- | * src_ip - source IP address | + | [1] See function // |
- | * dst_ip - destination IP address | + | |
- | * src_port - port of source | + | ==== xavp_via_fields ==== |
- | * dst_port - port of source address | + | |
- | * proto - transport protocol | + | Set the name of xavp from where to take Via header field: |
+ | Use them to build local Via header. | ||
Example: | Example: | ||
<code c> | <code c> | ||
+ | xavp_via_fields=" | ||
- | event_route[sipdump: | + | request_route |
- | | + | |
- | | + | |
- | | + | |
+ | via_use_xavp_fields(" | ||
+ | t_relay(); | ||
} | } | ||
</ | </ | ||
+ | |||
+ | See function // | ||
+ | ===== DNS Parameters ===== | ||
- | ===== Benchmark Module ===== | + | Note: See also file doc/dns.txt for details about Kamailio' |
- | ==== $BM_time_diff ==== | + | Kamailio has an internal DNS resolver with caching capabilities. If this caching resolver is activated |
- | $BM_time_diff - the time difference elapsed between calls of bm_start_timer(name) and bm_log_timer(name). The value is 0 if no bm_log_timer() was called. | + | |
- | ===== Dialog Module ===== | + | ^ DNS resolver comparison |
+ | | Caching of resolved records | yes | no* | | ||
+ | | NAPTR/SRV lookups with correct weighting | yes | yes | | ||
+ | | DNS based failover | yes | no | | ||
- | ==== $dlg(attr) ==== | + | * Of course you can use the resolving name servers configured in / |
- | Return | + | If the internal resolver/ |
+ | dns.add_srv, | ||
- | <fc # | + | Note: During startup of Kamailio, before the internal resolver |
- | The ' | + | Note: The dns cache uses the DNS servers configured on your server (/ |
- | * h_id - hash id | + | |
- | * h_entry - hash entry | + | |
- | * ref - reference count | + | |
- | * state - state of dialog | + | |
- | * to_rs - To route set | + | |
- | * from_rs - From route set | + | |
- | * dflags - dialog | + | |
- | * sflags - dialog script flags | + | |
- | * callid - sip call id | + | |
- | * to_uri - To uri | + | |
- | * to_tag - To tag | + | |
- | * from_uri - From uri | + | |
- | * from_tag - From tag | + | |
- | * toroute - timeout route | + | |
- | * lifetime - timeout inteval | + | |
- | * start_ts - start timestamp | + | |
- | * to_cseq - To CSeq | + | |
- | * from_cseq - From CSeq | + | |
- | * to_contact - To contact address | + | |
- | * from_contact - From contact address | + | |
- | * to_bindaddr - To bind address | + | |
- | * from_bindaddr - From bind address | + | |
- | ==== $dlg_ctx(attr) ==== | + | Kamailio also allows you to finetune the DNS resolver settings. |
- | Return the attribute of the context for current processed dialog. | + | The maximum time a dns request can take (before failing) is (if dns_try_ipv6 is yes, multiply it again by 2; if SRV and NAPTR lookups are enabled, it can take even longer!): |
- | <fc # | + | (dns_retr_time*(dns_retr_no+1)*dns_servers_no)*(search_list_domains) |
- | The ' | + | Note: During DNS lookups, the process which performs |
- | * set - returns 1 if the dialog for current context is set, 0 otherwise | + | |
- | * flags - get/set dialog flags | + | |
- | * timeout_route - get/set route name to be executed on timeout | + | |
- | * timeout_route_id - get internal id for the route to be executed on timeout | + | |
- | * timeout_bye - set to 1 if BYE has to be sent when dialog lifetime elapses | + | |
- | * timeout - set the dialog lifetime (in seconds) | + | |
- | * on - get/set an integer value associated with the context (cfg usage) | + | |
- | * dir - get direction of the request for the dialog of the current context | + | |
- | ==== $dlg_var(key) ==== | + | dns_try_ipv6=no |
+ | dns_retr_time=1 | ||
+ | dns_retr_no=1 | ||
+ | dns_use_search_list=no | ||
- | Store and retrieve custom variable for current processed dialog. | + | ==== dns ==== |
- | <fc #0000ff>It is R/W variable.</fc> | + | This parameter controls if the SIP server will try doing a DNS lookup on the address in the Via header of a received sip request to decide if adding a received=<src_ip> parameter to the Via is necessary. Note that Vias containing |
+ | DNS names (instead of IPs) should have received= added, so turning dns to yes is not recommended. | ||
- | The ' | + | Default is no. |
- | ===== Erlang Module ===== | + | ==== rev_dns |
- | ==== Attributes === | + | This parameter controls if the SIP server will try doing a reverse DNS lookup on the source IP of a sip request |
+ | to decide if adding a received=< | ||
+ | See also dns (the effect is cumulative, both can be turned on and in that case if the DNS lookup test fails the reverse | ||
+ | DNS test will be tried). | ||
+ | Note that Vias containing DNS names (instead of IPs) should have received= added, so turning rev_dns to yes is not recommended. | ||
+ | |||
- | * type - get variable type. Possible types are: atom, integer, list, string, tuple, pid and ref. | + | Default is no. |
- | * length - get length of list or tuple. | + | ==== dns_cache_del_nonexp ==== |
- | * format - prints a term, in clear text. It tries to resemble the term printing in the Erlang shell. | + | **Alias name: dns_cache_delete_nonexpired** |
- | ==== $erl_atom(name) ==== | + | dns_cache_del_nonexp |
+ | allow deletion of non-expired records from the cache when there is no more space | ||
+ | left for new ones. The last-recently used entries are deleted first. | ||
- | //$erl_atom(name)// pseudo variable allows create analog to Erlang atom data type. | + | ==== dns_cache_rec_pref ==== |
- | Erlang atom is a literal, a constant with name. Formatted output pseudo variable | + | dns_cache_rec_pref = number |
- | atom could be enclosed in single quotes (') if it does not begin with a | + | dns cache record preference, determines how new DNS records are stored internally in relation to existing entries. |
- | lower-case letter or if it contains other characters than alphanumeric characters, | + | |
- | underscore (_), or @. | + | 0 - do not check duplicates |
+ | | ||
+ | 2 - prefer new records | ||
+ | 3 - prefer records with longer lifetime | ||
- | Example: | + | ==== dns_cache_flags ==== |
+ | dns_cache_flags = number (default 0) - | ||
+ | dns cache specific resolver flags, used for overriding the default behaviour (low level). | ||
+ | Possible values: | ||
+ | 1 - ipv4 only: only DNS A requests are performed, even if Kamailio also listens on ipv6 addresses. | ||
+ | 2 - ipv6 only: only DNS AAAA requests are performed. Ignored if dns_try_ipv6 is off or Kamailio | ||
+ | doesn' | ||
+ | 4 - prefer ipv6: try first to resolve a host name to an ipv6 address (DNS AAAA request) and only | ||
+ | if this fails try an ipv4 address (DNS A request). By default the ipv4 addresses are preferred. | ||
- | <code c> | + | ==== dns_cache_gc_interval ==== |
- | $erl_atom(A) = " | + | Interval in seconds after which the dns cache is garbage collected |
- | xlogl(" | + | dns_cache_gc_interval |
- | </ | + | |
- | ==== $erl_list(name) ==== | ||
- | Compound data type with a variable number of terms. Formally, a list is either | ||
- | the empty list [] or consists of one or more elements. | ||
- | Example: | + | ==== dns_cache_init ==== |
- | <code c> | + | If off, the dns cache is not initialized at startup and cannot be enabled runtime, that saves some memory. |
- | $erl_atom(E) = " | + | |
- | $erl_list(L) = " | + | |
- | $erl_list(L) = " | + | |
- | $erl_list(L) = $erl_atom(E); | + | |
- | xlogl(" | + | dns_cache_init |
- | # empty list | + | ==== dns_cache_max_ttl ==== |
- | $erl_tuple(E[*]) = $null; | + | |
- | </ | + | |
- | ==== $erl_tuple(name) | + | ==== dns_cache_mem |
- | From the Erlang point of view the tuple compound data type with a fixed number | + | Maximum memory used for the dns cache in KB (default 500 K) |
- | of terms. The module implementation of tuple has the same behavior as the list. | + | |
- | Example: | + | dns_cache_mem = number |
- | <code c> | ||
- | $erl_atom(e) = " | ||
- | $erl_tuple(T) | + | ==== dns_cache_min_ttl ==== |
- | $erl_tuple(T) | + | |
- | xlogl(" | + | ==== dns_cache_negative_ttl ==== |
- | </ | + | |
- | ==== $erl_pid(name) ==== | + | Tells how long to keep negative DNS responses |
- | Holds Eralng process identifier. Provides access | + | |
- | be used in send message. | + | |
- | ==== $erl_ref(name) | + | ==== dns_naptr_ignore_rfc |
- | Holds Erlang reference. Provides access to reference value and could be used in | + | |
- | send message. | + | |
- | ==== $erl_xbuff(name) ==== | + | If the DNS lookup should ignore the remote side's protocol preferences, |
- | Generic pseudo variable to acts as other pseudo variables exported from Erlang | + | |
- | module. | + | |
- | ===== HTable Module ===== | + | dns_naptr_ignore_rfc |
- | ==== $sht(htable=> | + | ==== dns_retr_no |
- | Access hash table entries. | + | Number of dns retransmissions before giving up. Default value is system specific, depends also on the '/ |
- | <fc # | + | Example |
- | The “htname” must be a hash table name defined via “htable” parameter. | + | dns_retr_no=3 |
- | The “key” can be: | + | ==== dns_retr_time ==== |
- | * static string - set of characters without pseudo-variables | + | Time in seconds before retrying a dns request. Default value is system specific, depends also on the '/ |
- | * dynamic string - set of characters that include pseudo-variables. The pseudo-variables will be evaluated at runtime. | + | |
- | < | + | Example of usage: |
- | ... | + | |
- | modparam(" | + | |
- | ... | + | |
- | $sht(a=> | + | |
- | $sht(a=> | + | |
- | ... | + | |
- | </ | + | |
- | ==== $shtex(htable=> | + | dns_retr_time=3 |
- | Access hash table entry expire value. Value represents | + | ==== dns_search_full_match ==== |
+ | When name was resolved using dns search list, check the domain added in the answer matches with one from the search list (small performance hit, but more safe) | ||
- | <fc # | + | dns_search_full_match = yes | no (default yes) |
- | The “htname” must be a hash table name defined via “htable” parameter and have auto-expire greater than 0. | + | ==== dns_servers_no ==== |
- | The “key” can be: | + | How many dns servers from the ones defined in '/ |
- | * static string - set of characters without pseudo-variables | + | Example |
- | * dynamic string - set of characters that include pseudo-variables. The pseudo-variables will be evaluated at runtime. | + | |
- | < | + | dns_servers_no=2 |
- | ... | + | |
- | modparam(" | + | |
- | ... | + | |
- | $sht(a=> | + | |
- | $shtex(a=> | + | |
- | ... | + | |
- | </ | + | |
+ | ==== dns_srv_lb ==== | ||
- | ==== $shtcn(htable=> | + | **Alias name: dns_srv_loadbalancing** |
- | Count items matching the name by regexp. | + | Enable dns srv weight based load balancing (see doc/dns.txt) |
- | The “htname” must be a hash table name defined via “htable” parameter. | + | dns_srv_lb = yes | no (default no) |
- | The **exp** can be: | + | ==== dns_try_ipv6 ==== |
- | * reqexp - match by regular expression | + | Can be 'yes' |
- | * ~~regexp - match by regular expression | + | for ipv6 (AAAA record). Default value is ' |
- | * ~%prefix - match by right prefix | + | |
- | * %~prefix - match by left prefix | + | |
- | * ==value - match by string value | + | |
- | * eqvalue - match by integer value | + | |
- | * * * - (two asterisks next to each other) - count all items | + | |
- | The **exp** can contain pseudo-variables. | + | Note: If dns_try_ipv6 is off, no hostname resolving that would result in an ipv6 address would succeed |
- | < | + | Example of usage: |
- | ... | + | |
- | modparam(" | + | |
- | ... | + | |
- | $sht(a=> | + | |
- | $shtex(a=> | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ==== $shtcv(htable=> | + | dns_try_ipv6=yes |
- | Count items matching the value by regexp. | + | ==== dns_try_naptr ==== |
+ | Enable NAPTR support according to RFC 3263 (see doc/dns.txt for more info) | ||
+ | |||
+ | dns_try_naptr = yes | no (default no) | ||
- | The “htname” must be a hash table name defined via “htable” parameter. | + | ==== dns_sctp_pref, |
- | The **exp** must follow same rules as for **$shtcn(...)**. | + | **Alias name: dns_sctp_preference, |
- | < | + | Set preference for each protocol when doing naptr lookups. By default dns_udp_pref=30, dns_tcp_pref=20, |
- | ... | + | dns_tls_pref=10 and dns_sctp_pref=20. To use the remote site preferences set all dns_*_pref to the same positive value (e.g. dns_udp_pref=1, |
- | modparam(" | + | dns_tcp_pref=1, dns_tls_pref=1, dns_sctp_pref=1). To completely ignore NAPTR records for a specific protocol, set the corresponding protocol |
- | ... | + | preference to -1 (or any other negative number). |
- | $sht(a=> | + | |
- | $shtex(a=>ade) = " | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ==== $shtinc(htable=> | + | dns_{udp, |
- | Atomic increment of the value for the hash table item. | + | ==== dns_use_search_list ==== |
- | < | + | Can be ' |
- | ... | + | |
- | modparam("htable", "htable", "a=>size=4;") | + | HINT: even if you don't have a search list defined, setting this option to ' |
- | ... | + | |
- | $sht(a=> | + | Example of usage: |
- | xlog(" | + | |
- | ... | + | dns_use_search_list=no |
+ | |||
+ | ==== use_dns_cache ==== | ||
+ | |||
+ | Tells if DNS responses are cached - this means that the internal DNS resolver (instead of the system' | ||
+ | |||
+ | ==== use_dns_failover ==== | ||
+ | use_dns_failover = on | off (default off) | ||
+ | |||
+ | ===== TCP Parameters ===== | ||
+ | |||
+ | The following parameters allows to tweak the TCP behaviour. | ||
+ | |||
+ | ==== disable_tcp ==== | ||
+ | |||
+ | Global parameter to disable TCP support in the SIP server. Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_tcp=yes | ||
+ | |||
+ | ==== tcp_accept_aliases ==== | ||
+ | |||
+ | If a message received over a tcp connection has " | ||
+ | |||
+ | Based on draft-ietf-sip-connect-reuse-00.txt, | ||
+ | |||
+ | See force_tcp_alias for more details. | ||
+ | |||
+ | Note: For NAT traversal of TCP clients it is better to not use tcp_accept_aliases but just use nathelper module and fix_nated_[contact|register] functions. | ||
+ | |||
+ | Default is "no" (off) | ||
+ | |||
+ | | ||
+ | |||
+ | ==== tcp_accept_haproxy ==== | ||
+ | |||
+ | Enable the internal TCP stack to expect a PROXY-protocol-formatted header as the first message of the connection. Both the human-readable (v1) and binary-encoded (v2) variants of the protocol are supported. This option is typically useful if you are behind a TCP load-balancer, | ||
+ | |||
+ | Please note that enabling this option will reject any inbound TCP connection that does not conform to the PROXY-protocol spec. | ||
+ | |||
+ | For reference: A PROXY protocol - https://www.haproxy.org/ | ||
+ | |||
+ | Default value is **no**. | ||
+ | |||
+ | <code c> | ||
+ | tcp_accept_haproxy=yes | ||
</ | </ | ||
- | ==== $shtdec(htable=> | + | ==== tcp_accept_hep3 |
- | Atomic decrement of the value for the hash table item. | + | Enable internal TCP receiving stack to accept HEP3 packets. This option has to be set to **yes** on a Kamailio instance acting as Homer SIPCapture server that is supposed to receive HEP3 packets over TCP/TLS. |
- | < | + | Default value is **no**. |
- | ... | + | |
- | modparam(" | + | <code c> |
- | ... | + | tcp_accept_hep3=yes |
- | $sht(a=>$au) = 1; | + | |
- | xlog("==== $shtdec(a=> | + | |
- | ... | + | |
</ | </ | ||
- | ==== $shtitkey(iname) | + | ==== tcp_accept_no_cl |
- | The key at the current position | + | Control whether to throw or not error when there is no Content-Length header for requests received over TCP. It is required to be set to **yes** for XCAP traffic sent over HTTP/1.1 which does not use Content-Length header, but splits large bodies in many chunks. |
- | ==== $shtitval(iname) ==== | + | Default value is **no**. |
- | The value at the current position in the iterator. | + | <code c> |
+ | tcp_accept_no_cl=yes | ||
+ | </ | ||
- | Example: | + | ==== tcp_accept_unique ==== |
+ | |||
+ | If set to 1, reject duplicate connections coming from same source IP and port. | ||
+ | |||
+ | Default set to 0. | ||
<code c> | <code c> | ||
- | sht_iterator_start(" | + | tcp_accept_unique = 1 |
- | while(sht_iterator_next(" | + | |
- | xlog(" | + | |
- | } | + | |
- | sht_iterator_end(" | + | |
</ | </ | ||
+ | ==== tcp_async ==== | ||
- | ==== $shtrecord(id) ==== | + | **Alias name: tcp_buf_write** |
- | Get the key or the value of expired item inside the event_route[htable: | + | If enabled, all the tcp writes that would block / wait for connect to finish, will be queued and attempted latter (see also tcp_conn_wq_max and tcp_wq_max). |
- | The id can be: | + | **Note:** It also applies for TLS. |
- | | + | |
- | | + | |
- | Example: | + | ==== tcp_children ==== |
+ | |||
+ | Number of children processes to be created for reading from TCP connections. If no value is explicitly set, the same number of TCP children as UDP children (see " | ||
+ | |||
+ | Example | ||
+ | |||
+ | tcp_children=4 | ||
+ | |||
+ | ==== tcp_clone_rcvbuf ==== | ||
+ | |||
+ | Control if the received buffer should be cloned from the TCP stream, needed by functions working inside the SIP message buffer (such as msg_apply_changes()). | ||
+ | |||
+ | Default is 0 (don't clone), set it to 1 for cloning. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_clone_rcvbuf=1 | ||
+ | ==== tcp_connection_lifetime ==== | ||
+ | |||
+ | Lifetime in seconds for TCP sessions. TCP sessions which are inactive for longer than **tcp_connection_lifetime** will be closed by Kamailio. Default value is defined is 120. Setting this value to 0 will close the TCP connection pretty quick ;-). | ||
+ | |||
+ | Note: As many SIP clients are behind NAT/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_connection_lifetime=3605 | ||
+ | |||
+ | ==== tcp_connection_match ==== | ||
+ | |||
+ | If set to 1, try to be more strict in matching outbound TCP connections, | ||
+ | |||
+ | Default is 0. | ||
<code c> | <code c> | ||
- | event_route[htable: | + | tcp_connection_match=1 |
- | xlog(" | + | |
- | } | + | |
</ | </ | ||
- | ===== Memcached Module ===== | + | ==== tcp_connect_timeout |
- | ==== $mct(key) ==== | + | Time in seconds before an ongoing attempt to establish a new TCP connection will be aborted. Lower this value for faster detection of TCP connection problems. The default value is 10s. |
- | Access hash table entries stored in the memcached server. | + | Example of usage: |
- | <fc # | + | tcp_connect_timeout=5 |
- | The “key” can be: | + | ==== tcp_conn_wq_max ==== |
- | * static string - set of characters without pseudo-variables | + | Maximum bytes queued for write allowed per connection. Attempting to queue more bytes would result in an error and in the connection being closed (too slow). If tcp_buf_write is not enabled, it has no effect. |
- | * dynamic string - set of characters that include pseudo-variables. The pseudo-variables will be evaluated at runtime. | + | |
- | When assigning values, the default | + | tcp_conn_wq_max = bytes (default |
+ | |||
+ | ==== tcp_crlf_ping ==== | ||
+ | Enable SIP outbound TCP keep-alive using PING-PONG (CRLFCRLF - CRLF). | ||
- | < | + | tcp_crlf_ping |
- | ... | + | |
- | $mct($au) | + | |
- | $mct($ru) = $fu; | + | |
- | $mct(test) = 1; | + | |
- | xlog(" | + | |
- | $mct(test) = null; # delete it | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ==== $mct(key=> | ||
- | Using this alternative format, the default expiry may be overidden by including a custom value at time of assignment. | + | ==== tcp_defer_accept ==== |
- | < | + | Tcp accepts will be delayed until some data is received |
- | ... | + | |
- | $mct(test=>30) = 1; # set expire time to 30 seconds | + | |
- | xlog(" | + | |
- | # sleep 30 seconds | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ==== $mcinc(key) ==== | + | WARNING: the linux TCP_DEFER_ACCEPT is buggy (<=2.6.23) and doesn' |
- | Do a atomic increment operation on the value stored in memcached. You need to add a value previously. | + | On FreeBSD: |
+ | tcp_defer_accept = yes | no (default no) | ||
+ | |||
+ | On Linux: | ||
+ | tcp_defer_accept = number of seconds before timeout (default disabled) | ||
- | <fc # | + | ==== tcp_delayed_ack ==== |
+ | Initial ACK for opened connections will be delayed and sent with the first data segment (see linux tcp(7) TCP_QUICKACK). For now linux only. | ||
- | The “key” can be: | + | tcp_delayed_ack |
- | * static string - set of characters without pseudo-variables | + | ==== tcp_fd_cache ==== |
- | * dynamic string - set of characters that include pseudo-variables. The pseudo-variables will be evaluated at runtime. | + | |
- | < | + | If enabled FDs used for sending will be cached inside the process calling tcp_send |
- | ... | + | |
- | $mct(cnt) = 1; | + | |
- | $mcinc(cnt) = 2; # increment by 2 | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ==== $mcdec(key) ==== | + | tcp_fd_cache |
- | Do a atomic decrement operation on the value stored in memcached. You need to add a value previously. | + | ==== tcp_keepalive ==== |
+ | Enables keepalive for tcp (sets SO_KEEPALIVE socket option) | ||
- | <fc # | + | tcp_keepalive = yes | no (default yes) |
- | The “key” can be: | + | ==== tcp_keepcnt ==== |
+ | Number of keepalives sent before dropping the connection (TCP_KEEPCNT socket option). Linux only. | ||
- | | + | |
- | * dynamic string - set of characters that include pseudo-variables. The pseudo-variables will be evaluated at runtime. | + | |
- | < | + | ==== tcp_keepidle ==== |
- | ... | + | |
- | $mct(cnt) | + | |
- | $mcdec(cnt) | + | |
- | xlog(" | + | |
- | ... | + | |
- | </ | + | |
- | ===== http_async_client Module ===== | + | Time before starting to send keepalives, if the connection is idle (TCP_KEEPIDLE socket option). Linux only. |
- | ==== $http_req_id ==== | + | tcp_keepidle |
- | The $http_req_id read-only variable can be used in REQUEST_ROUTE to retrive | + | ==== tcp_keepintvl ==== |
+ | Time interval between keepalive probes, when the previous probe failed (TCP_KEEPINTVL socket option). Linux only. | ||
- | ==== $http_req(key) ==== | + | tcp_keepintvl |
- | The $http_req(key) write-only variable can be used to set custom parameters before sending a HTTP query. | + | ==== tcp_linger2 ==== |
+ | Lifetime of orphaned sockets in FIN_WAIT2 state (overrides tcp_fin_timeout on, see linux tcp(7) TCP_LINGER2). Linux only. | ||
- | **key** can be one of: | + | tcp_linger2 = seconds |
- | * all: if set to $null, resets all the parameters to their default value (the ones defined in modparam) | + | |
- | * hdr: sets/ | + | |
- | * body: sets/ | + | |
- | * method: sets the HTTP method: either " | + | |
- | * timeout: sets the HTTP timeout. (Note, this timeout should be normally less than tm.fr_timer timeout, because transaction timeout has a higher priority over HTTP timeout) | + | |
- | * tls_client_cert: | + | |
- | * tls_client_key: | + | |
- | * tls_ca_path: | + | |
- | * authmethod: Sets the preferred authentication mode for HTTP/HTTPS requests. The value is a bitmap and multiple methods can be used. Note that in this case, the CURL library will make an extra request to discover server-supported authentication methods. You may want to use a specific value. Valid values are: | + | |
- | * 1 - BASIC authentication | + | |
- | * 2 - HTTP Digest authentication | + | |
- | * 4 - GSS-Negotiate authentication | + | |
- | * 8 - NTLM authentication | + | |
- | * 16 - HTTP Digest with IE flavour. | + | |
- | * (Default value is 3 - BASIC and Digest authentication.) | + | |
- | * username: sets the username to use for authenticated requests | + | |
- | * password: sets the password to use for authenticated requests | + | |
- | * suspend: if set to 0 it doesn' | + | |
- | * tcp_keepalive: | + | |
- | * tcp_ka_idle: | + | |
- | * tcp_ka_interval: | + | |
- | ==== Other read-only variables | + | ==== tcp_max_connections |
- | The following read-only pseudo variables can only be used in the callback routes executed by http_async_query() | + | Maximum number of tcp connections |
- | === $http_ok === | + | Example of usage: |
- | 1 if cURL executed the request successfully, | + | |
- | === $http_err === | + | tcp_max_connections=4096 |
- | cURL error string if an error occurred, $null otherwise. | + | |
- | === $http_rs | + | ==== tcp_no_connect ==== |
- | HTTP status. | + | |
- | === $http_rr === | + | Stop outgoing TCP connects (also stops TLS) by setting tcp_no_connect to yes. |
- | HTTP reason phrase. | + | |
- | === $http_hdr(Name) === | + | You can do this any time, even even if Kamailio is already started (in this case using the command " |
- | Value of the Name header (the $(http_hdr(Name)[N]) syntax | + | |
- | === $http_mb and $http_ml | + | ==== tcp_poll_method ==== |
- | HTTP response buffer (including headers) and length. | + | |
- | === $http_rb | + | Poll method used (by default the best one for the current OS is selected). For available types see io_wait.c |
- | HTTP response body and body length, | + | |
- | ===== XMLOPS Pseudo-Variables ===== | + | Example of usage: |
- | ==== $xml(name=> | + | tcp_poll_method=select |
- | * name - id to refer the documet | + | ==== tcp_rd_buf_size ==== |
- | * spec - specifier: | + | |
- | * doc - set/get the document as text | + | |
- | * xpath: | + | |
- | Example: | + | Buffer size used for tcp reads. A high buffer size increases performance on server with few connections and lot of traffic on them, but also increases memory consumption (so for lots of connection is better to use a low value). Note also that this value limits the maximum message size (SIP, HTTP) that can be received over tcp. |
- | < | + | The value is internally limited to 16MByte, for higher values recompile Kamailio with higher limit in tcp_options.c |
- | $xml(x=>doc) = '<? | + | |
- | xlog(" | + | Default: 4096, can be changed at runtime. |
- | $xml(x=> | + | |
+ | <code c> | ||
+ | tcp_rd_buf_size=65536 | ||
</ | </ | ||
+ | ==== tcp_send_timeout ==== | ||
- | ===== TMX Module ===== | + | Time in seconds after a TCP connection will be closed if it is not available for writing in this interval (and Kamailio wants to send something on it). Lower this value for faster detection of broken TCP connections. The default value is 10s. |
- | ==== $T_branch_idx ==== | + | Example of usage: |
- | * the index (starting with 1 for the first branch) of the branch for which is executed the branch_route[]. If used outside of branch_route[] block, the value is ' | + | tcp_send_timeout=3 |
- | ==== $T_reply_ruid | + | ==== tcp_source_ipv4, |
- | * the ruid stored in the current branch of the transaction. The ruid is stored in a branch from the details in a contact binding. In a event_route[tm: | + | Set the source IP for all outbound TCP connections. If setting |
+ | tcp_source_ipv4 = IPv4 address | ||
+ | tcp_source_ipv6 = IPv6 address | ||
- | ==== $T_reply_code | + | ==== tcp_syncnt |
+ | Number of SYN retransmissions before aborting a connect attempt (see linux tcp(7) TCP_SYNCNT). Linux only. | ||
- | | + | |
- | ==== $T_req(pv) | + | ==== tcp_wq_blk_size |
+ | Block size used for tcp async writes. It should be big enough to hold a few datagrams. If it's smaller then a datagram (in fact a tcp write()) size, it will be rounded up. It has no influenced on the number of datagrams queued (for that see tcp_conn_wq_max or tcp_wq_max). It has mostly debugging and testing value (can be ignored). | ||
- | * can be used in reply routes or inside the modules to get access to attributes of the request belonging to same transaction as the reply | + | Default: 2100 (~ 2 INVITEs), |
- | < | + | ==== tcp_wq_max ==== |
- | route { | + | |
- | t_on_reply(" | + | |
- | t_relay(); | + | |
- | } | + | |
- | onreply_route[1] { | + | Maximum bytes queued for write allowed globally. It has no effect if tcp_buf_write is not enabled. |
- | xlog(" | + | |
- | } | + | |
- | </ | + | |
- | ==== $T_rpl(pv) | + | tcp_wq_max |
+ | |||
+ | ==== tcp_reuse_port | ||
- | * can be used in failure routes or inside the modules to get access to attributes | + | Allows reuse of TCP ports. This means,for example, that the same TCP ports on which Kamailio is listening on, can be used as source ports of new TCP connections when acting |
- | <code> | + | |
- | route { | + | |
- | t_on_failure(" | + | |
- | t_relay(); | + | |
- | } | + | |
- | failure_route[1] { | + | tcp_reuse_port |
- | xlog(" | + | |
- | } | + | |
- | </ | + | |
- | ==== $T_inv(pv) | + | ===== TLS Parameters ===== |
- | * can be used in request routes | + | Most of TLS layer attributes |
+ | |||
+ | ==== tls_port_no ==== | ||
+ | |||
+ | The port the SIP server listens to for TLS connections. | ||
+ | |||
+ | Default value is 5061. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tls_port_no=6061 | ||
+ | |||
+ | ==== tls_max_connections ==== | ||
+ | |||
+ | Maximum number of ls connections (if the number is exceeded no new ls connections will be accepted). It cannot exceed tcp_max_connections. | ||
+ | |||
+ | Default value is 2048. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tls_max_connections=4096 | ||
+ | ===== SCTP Parameters ===== | ||
+ | |||
+ | ==== disable_sctp ==== | ||
+ | |||
+ | Global parameter to disable SCTP support | ||
+ | |||
+ | Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_sctp=yes | ||
+ | |||
+ | ==== enable_sctp ==== | ||
+ | |||
+ | enable_sctp = 0/1/2 - SCTP disabled (0)/ SCTP enabled (1)/auto (2), | ||
+ | | ||
+ | |||
+ | ==== sctp_children ==== | ||
+ | sctp children no (similar to udp children) | ||
+ | sctp_children = number | ||
+ | |||
+ | ==== sctp_socket_rcvbuf ==== | ||
+ | Size for the sctp socket receive buffer | ||
+ | |||
+ | **Alias name: sctp_socket_receive_buffer** | ||
+ | |||
+ | sctp_socket_rcvbuf = number | ||
+ | |||
+ | ==== sctp_socket_sndbuf ==== | ||
+ | Size for the sctp socket send buffer | ||
+ | |||
+ | **Alias name: sctp_socket_send_buffer** | ||
+ | |||
+ | sctp_socket_sndbuf = number | ||
+ | |||
+ | ==== sctp_autoclose ==== | ||
+ | Number of seconds before autoclosing an idle association (default: 180 s). Can be changed at runtime, but it will affect only new associations. E.g.: | ||
+ | $ kamcmd cfg.set_now_int sctp autoclose 120 | ||
+ | |||
+ | sctp_autoclose = seconds | ||
+ | |||
+ | ==== sctp_send_ttl ==== | ||
+ | Number of milliseconds before an unsent message/ | ||
+ | $ kamcmd cfg.set_now_int sctp send_ttl 180000 | ||
+ | |||
+ | sctp_send_ttl = milliseconds - n | ||
+ | |||
+ | ==== sctp_send_retries ==== | ||
+ | How many times to attempt re-sending a message on a re-opened association, | ||
+ | |||
+ | WARNING: use with care and low values (e.g. 1-3) to avoid " | ||
+ | |||
+ | sctp_send_retries = 1 | ||
+ | |||
+ | ==== sctp_assoc_tracking ==== | ||
+ | Controls whether or not sctp associations are tracked | ||
+ | |||
+ | Can be changed at runtime (" | ||
+ | |||
+ | Note: turning sctp_assoc_tracking on/off will delete all the tracking information for all the currently tracked associations and might introduce a small temporary delay in the sctp processing if lots of associations were tracked. | ||
+ | |||
+ | Config options depending on sctp_assoc_tracking being on: sctp_assoc_reuse. | ||
+ | |||
+ | sctp_assoc_tracking = yes/no | ||
+ | |||
+ | ==== sctp_assoc_reuse ==== | ||
+ | Controls sctp association reuse. For now only association reuse for replies is affected by it. Default: yes. | ||
+ | Depends on sctp_assoc_tracking being on. | ||
+ | |||
+ | Note that even if turned off, if the port in via corresponds | ||
+ | Can be changed at runtime (sctp assoc_reuse), | ||
+ | |||
+ | sctp_assoc_reuse = yes/no | ||
+ | |||
+ | ==== sctp_max_assocs ==== | ||
+ | Maximum number of allowed open sctp associations. -1 means maximum allowed by the OS. Default: -1. | ||
+ | Can be changed at runtime (e.g.: | ||
+ | |||
+ | When Kamailio tries to open a new association and the max_assocs is exceeded the exact behaviour depends on whether or not | ||
+ | sctp_assoc_tracking is on. If on, the send triggering the active open will gracefully fail, before actually opening the new association and no packet will be sent. However if sctp_assoc_tracking is off, the association will first be opened and then immediately closed. In general this means that the initial sip packet will be sent (as part of the 4-way handshake). | ||
+ | |||
+ | |||
+ | |||
+ | sctp_max_assocs = number | ||
+ | |||
+ | ==== sctp_srto_initial ==== | ||
+ | Initial value of the retr. timeout, used in RTO calculations (default: OS specific). | ||
+ | |||
+ | Can be changed at runtime (sctp srto_initial) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_initial = milliseconds | ||
+ | |||
+ | ==== sctp_srto_max ==== | ||
+ | Maximum value of the retransmission timeout (RTO) (default: OS specific). | ||
+ | |||
+ | WARNING: values lower then the sctp sack_delay will cause lots of retransmissions and connection instability (see sctp_srto_min for more details). | ||
+ | |||
+ | Can be changed at runtime (sctp srto_max) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_max = milliseconds | ||
+ | |||
+ | ==== sctp_srto_min ==== | ||
+ | Minimum value of the retransmission timeout (RTO) (default: OS specific). | ||
+ | |||
+ | WARNING: values lower then the sctp sack_delay of any peer might cause retransmissions and possible interoperability problems. According to the standard the sack_delay should be between 200 and 500 ms, so avoid trying values lower then 500 ms unless you control all the possible sctp peers and you do make sure their sack_delay is higher or their sack_freq is 1. | ||
+ | |||
+ | Can be changed at runtime (sctp srto_min) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_min = milliseconds | ||
+ | |||
+ | ==== sctp_asocmaxrxt ==== | ||
+ | Maximum retransmissions attempts per association (default: OS specific). It should be set to sctp_pathmaxrxt * no. of expected paths. | ||
+ | |||
+ | Can be changed at runtime (sctp asocmaxrxt) but it will affect only new associations. | ||
+ | |||
+ | sctp_asocmaxrxt | ||
+ | |||
+ | ==== sctp_init_max_attempts ==== | ||
+ | Maximum INIT retransmission attempts (default: OS specific). | ||
+ | |||
+ | Can be changed at runtime (sctp init_max_attempts). | ||
+ | |||
+ | sctp_init_max_attempts = number | ||
+ | |||
+ | ==== sctp_init_max_timeo ==== | ||
+ | Maximum INIT retransmission timeout (RTO max for INIT). Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp init_max_timeo). | ||
+ | |||
+ | sctp_init_max_timeo = milliseconds | ||
+ | |||
+ | |||
+ | ==== sctp_hbinterval ==== | ||
+ | sctp heartbeat interval. Setting it to -1 will disable the heartbeats. Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp hbinterval) but it will affect only new associations. | ||
+ | |||
+ | sctp_hbinterval = milliseconds | ||
+ | |||
+ | ==== sctp_pathmaxrxt ==== | ||
+ | Maximum retransmission attempts per path (see also sctp_asocmaxrxt). Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp pathmaxrxt) but it will affect only new associations. | ||
+ | |||
+ | sctp_pathmaxrxt = number | ||
+ | |||
+ | ==== sctp_sack_delay ==== | ||
+ | Delay until an ACK is generated after receiving | ||
+ | |||
+ | WARNING: a value higher then srto_min can cause a lot of retransmissions (and strange problems). A value higher then srto_max will result in very high connections instability. According to the standard the sack_delay value should be between 200 and 500 ms. | ||
+ | |||
+ | Can be changed at runtime (sctp sack_delay) but it will affect only new associations. | ||
+ | |||
+ | sctp_sack_delay = milliseconds | ||
+ | |||
+ | ==== sctp_sack_freq ==== | ||
+ | Number of packets received before an ACK is sent (without waiting for the sack_delay to expire). | ||
+ | |||
+ | Note: on linux with lksctp up to and including 1.0.9 is not possible to set this value (having it in the config will produce a warning on startup). | ||
+ | |||
+ | Can be changed at runtime (sctp sack_freq) but it will affect only new associations. | ||
+ | |||
+ | sctp_sack_freq = number | ||
+ | |||
+ | ==== sctp_max_burst ==== | ||
+ | Maximum burst of packets that can be emitted by an association. Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp max_burst) but it will affect only new associations. | ||
+ | |||
+ | sctp_max_burst = number | ||
+ | |||
+ | |||
+ | ===== UDP Parameters ===== | ||
+ | |||
+ | ==== udp4_raw ==== | ||
+ | |||
+ | Enables raw socket support for sending UDP IPv4 datagrams (40-50% performance increase on linux multi-cpu). | ||
+ | |||
+ | Possible values: 0 - disabled (default), 1 - enabled, -1 auto. | ||
+ | |||
+ | In " | ||
+ | |||
+ | The parameter can be set at runtime as long as sr was started with enough privileges (core.udp4_raw). | ||
< | < | ||
- | route { | + | udp4_raw = on |
- | if(is_method(" | + | |
- | { | + | |
- | | + | |
- | { | + | |
- | # first flag is set in the INVITE transaction | + | |
- | } | + | |
- | } | + | |
- | } | + | |
</ | </ | ||
- | ==== $T(name) | + | ==== udp4_raw_mtu |
- | * pseudo-variable class to access TM attributes | + | MTU value used for UDP IPv4 packets when udp4_raw is enabled. |
- | The **name** | + | The parameter |
- | * id_index - return the internal index of current transaction or $null if not transaction is found | + | ==== udp4_raw_ttl ==== |
- | * id_label - return the internal label of current transaction or $null if not transaction is found | + | |
- | * id_index_n - return the internal index of current transaction, | + | |
- | * id_label_n - return the internal label of current transaction, | + | |
- | * reply_code - reply code (alias to $T_reply_code) | + | |
- | * reply_reason - reply reason | + | |
- | * reply_last - last received reply code | + | |
- | * branch_index - branch index (alias to $T_branch_idx) | + | |
- | * ruid - return the internal location ruid field for current branch | + | |
- | * reply_type - 1 if it is a local generated reply, 0 - if no reply for transaction or it is a received reply | + | |
- | Note: the pair (id_index, | + | TTL value used for UDP IPv4 packets when udp4_raw is enabled. By default it is set to auto mode (-1), meaning that the same TTL will be used as for normal UDP sockets. |
- | ==== $T_branch(name) ==== | + | The parameter can be set at runtime |
- | * pseudo-variable class to access TM branch attributes | ||
- | The **name** can be: | + | ===== Blacklist Parameters ===== |
- | * flags - Flags of the branch. In a event_route[tm: | + | ==== dst_blacklist_expire ==== |
- | * uri - the R-URI of the branch. Can be used in onreply_route[id] - reply route blocks executed by tm module. For other routing blocks handling requests, the R-URI is returned by $ru | + | |
+ | **Alias name: dst_blacklist_ttl** | ||
- | ===== UAC Module ===== | + | How much time a blacklisted destination will be kept in the blacklist (w/o any update). |
- | ==== $uac_req(key) ==== | + | dst_blacklist_expire |
- | * used to build the input for uac_send_req() function of UAC module | + | ==== dst_blacklist_gc_interval ==== |
+ | How often the garbage collection will run (eliminating old, expired entries). | ||
- | The key can be: | + | dst_blacklist_gc_interval |
- | * method - SIP method | + | |
- | * ruri - request URI | + | |
- | * furi - From URI | + | |
- | * turi - To URI | + | |
- | * ouri - Outbound proxy URI | + | |
- | * hdrs - SIP Headers | + | |
- | * body - Body | + | |
- | * auser - authentication username | + | |
- | * apasswd - authentication password | + | |
- | * sock - local socket to be used for sending (proto: | + | |
- | * callid - SIP-Call-ID of the generated request (by default, a call-id is generated) | + | |
- | * all - alias useful to reset all fields - $uac_req(all) | + | |
- | * evroute - it has to be set to 1 in order to execute event_route[uac: | + | |
- | * evcode - reply code for the request sent with uac_req_send(), available inside event_route[uac: | + | |
- | * evtype - is 1 if the reply was received via network, 2 if the reply was locally generated (e.g., retransmission timeout), available inside event_route[uac: | + | |
- | * evparam - generic data buffer associated with the request that can be set before sending it and retrieved when executing the event route. It has a size of 128 characters. | + | |
- | <code c> | + | ==== dst_blacklist_init |
- | $uac_req(method)=" | + | If off, the blacklist is not initialized at startup and cannot be enabled runtime, that saves some memory. |
- | $uac_req(ruri)=" | + | |
- | $uac_req(furi)=" | + | |
- | $uac_req(turi)=" | + | |
- | $uac_req(evroute) = 1; | + | |
- | uac_req_send(); | + | |
- | ... | + | |
- | event_route[uac: | + | |
- | xlog(" | + | |
- | } | + | |
- | </ | + | |
- | ===== Nathelper Module | + | |
- | ==== $rr_count ==== | + | dst_blacklist_init |
- | * Number of Record Routes in received SIP request or reply. | + | ==== dst_blacklist_mem ==== |
+ | Maximum shared memory amount used for keeping the blacklisted destinations. | ||
- | ==== $rr_top_count ==== | + | dst_blacklist_mem |
- | * If topmost Record Route in received SIP request or reply is a double Record Route, value of $rr_top_count | + | ==== use_dst_blacklist ==== |
+ | Enable the destination blacklist: Each failed send attempt will cause the destination to be added to the blacklist. Before any send, this blacklist will be checked and if a match is found, the send is no longer attempted | ||
- | ===== MQueue Module ===== | + | Note: using the blacklist incurs a small performance penalty. |
- | ==== $mqk(q) ==== | + | See also doc/ |
- | | + | |
- | ==== $mqv(q) | + | ===== Real-Time Parameters ===== |
+ | ==== real_time | ||
+ | Sets real time priority for all the Kamailio processes, or the timers (bitmask). | ||
+ | | ||
+ | 1 - the " | ||
+ | 2 - the " | ||
+ | 4 - all processes, except the timers | ||
+ | | ||
- | * return | + | |
+ | |||
+ | ==== rt_policy ==== | ||
+ | Real time scheduling policy, 0 = SCHED_OTHER, | ||
+ | |||
+ | rt_policy= < | ||
+ | |||
+ | ==== rt_prio ==== | ||
+ | Real time priority used for everything except the timers, if real_time is enabled. | ||
+ | |||
+ | rt_prio = <int> (default 0) | ||
+ | |||
+ | ==== rt_timer1_policy ==== | ||
+ | |||
+ | **Alias name: rt_ftimer_policy** | ||
+ | |||
+ | Like rt_policy but for the " | ||
+ | |||
+ | rt_timer1_policy=< | ||
+ | |||
+ | ==== rt_timer1_prio ==== | ||
+ | |||
+ | **Alias name: rt_fast_timer_prio, | ||
+ | |||
+ | Like rt_prio but for the " | ||
+ | |||
+ | rt_timer1_prio=< | ||
+ | |||
+ | ==== rt_timer2_policy ==== | ||
+ | |||
+ | **Alias name: rt_stimer_policy** | ||
+ | |||
+ | Like rt_policy but for the " | ||
+ | |||
+ | rt_timer2_policy=< | ||
+ | |||
+ | ==== rt_timer2_prio ==== | ||
+ | |||
+ | **Alias name: rt_stimer_prio** | ||
+ | |||
+ | Like rt_prio but for the " | ||
+ | |||
+ | rt_timer2_prio=< | ||
+ | ===== Core Functions ===== | ||
+ | |||
+ | Functions exported by core that can be used in route blocks. | ||
+ | |||
+ | ==== add_local_rport ==== | ||
+ | |||
+ | Add **rport** parameter to local generated Via header -- see RFC3581. In effect for forwarded SIP requests. | ||
+ | |||
+ | Example | ||
<code c> | <code c> | ||
- | ... | + | add_local_rport(); |
- | mq_add(" | + | |
- | ... | + | |
- | while(mq_fetch(" | + | |
- | { | + | |
- | | + | |
- | } | + | |
- | ... | + | |
</ | </ | ||
- | ===== TimeVal | + | ==== avpflags |
+ | ==== break ==== | ||
- | ==== $TV(name) ==== | + | ' |
- | Seconds and microseconds taken from struct timeval. The time at that moment is represented by **seconds.microseconds**. | + | ==== drop ==== |
- | * $TV(s) - seconds (cached at first call per sip message) | + | Stop the execution of the configuration script and alter the implicit action which is done afterwards. |
- | * $TV(u) - microseconds (cached at first call per sip message) | + | |
- | * $TV(sn) - seconds (not cached, taken at that moment) | + | |
- | * $TV(un) - microseconds (corresponding to the moment $TV(sn) | + | |
- | * $TV(Sn) - string representation seconds.microseconds (not cached, taken at that moment) | + | |
- | ===== Next hop address ===== | + | |
- | ==== $nh(key) ==== | + | If the function is called in a ' |
- | Return attributes of next hop for the SIP request. Address | + | If the function is called in the default ' |
- | * $nh(u) - uri (lower case u) | + | Example of usage: |
- | * $nh(U) - username (upper case u) | + | |
- | * $nh(d) - domain | + | |
- | * $nh(p) - port (lower case p) | + | |
- | * $nh(P) - transport protocol (upper case p) | + | |
- | ===== NDB_REDIS Module ===== | + | onreply_route { |
+ | if(status==" | ||
+ | drop(); # this works | ||
+ | } | ||
+ | } | ||
- | ==== $redis(res=>key) ==== | + | onreply_route[FOOBAR] { |
+ | if(status==" | ||
+ | drop(); # this is ignored | ||
+ | } | ||
+ | } | ||
- | Access the attributes of the Redis response. | + | ==== exit ==== |
- | The key can be: | + | Stop the execution of the configuration script -- it has the same behaviour as return(0). It does not affect the implicit action to be taken after script execution. |
- | | + | |
- | * value - the value returned by REDIS server; | + | if (route(2)) { |
- | * info - in case of error from REDIS, it will contain an info message. | + | |
+ | } else { | ||
+ | xlog(" | ||
+ | }; | ||
+ | } | ||
- | If reply type is an array (as in hiredis.h), there are other keys available: | + | route[2] { |
+ | if (is_method(" | ||
+ | return(1); | ||
+ | } else if (is_method(" | ||
+ | return(-1); | ||
+ | } else if (is_method(" | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | } | ||
- | * size - returns number of elements in the array. | + | ==== error ==== |
- | * type[n] - returns the type of the nth element in the array. type - returns array type. | + | ==== exec ==== |
- | * value[n] - returns value of the nth element. value - returns null for an array. You need to get each element by index. | + | ==== force_rport ==== |
- | In case one of the members of the array is also an array (for example calling SMEMBERS in a MULTI/EXEC transaction), the members of the array can be accessed by adding any of the above keys, after a value[n] key. The first value[n] references | + | Force_rport() adds the rport parameter to the first Via header |
- | Example: | + | This is useful for NAT traversal, to enforce symmetric response signaling. |
+ | |||
+ | The rport parameter is defined in RFC 3581. | ||
+ | |||
+ | Note: there is also a force_rport parameter which changes the gobal behavior of the SIP proxy. | ||
+ | |||
+ | Example | ||
+ | |||
+ | force_rport(); | ||
+ | |||
+ | ==== add_rport ==== | ||
+ | Alias for force_rport(); | ||
+ | |||
+ | ==== force_send_socket ==== | ||
+ | |||
+ | |||
+ | Force to send the message from the specified socket (it _must_ be one of the sockets specified with the " | ||
+ | |||
+ | This function does not support pseudo-variables, | ||
+ | |||
+ | Example of usage: | ||
< | < | ||
- | redis_cmd(" | + | force_send_socket(10.10.10.10: |
- | xlog("===== result type: $redis(r=> | + | |
</ | </ | ||
+ | ==== force_tcp_alias ==== | ||
- | ==== $redisd(key) ==== | + | **Alias name: add_tcp_alias** |
- | Return the corresponding value for various defines from hiredis library. | + | force_tcp_alias(port) |
- | The key can be: | + | adds a tcp port alias for the current connection (if tcp). |
+ | Useful if you want to send all the trafic to port_alias through | ||
+ | the same connection this request came from [it could help | ||
+ | for firewall or nat traversal]. | ||
+ | With no parameters adds the port from the message via as the alias. | ||
+ | When the " | ||
+ | much time), all the port aliases are removed. | ||
- | * rpl_str - return REDIS_REPLY_STRING | + | ==== forward ==== |
- | * 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=>type). | + | Forward the SIP request to destination stored in $du in stateless mode. |
+ | |||
+ | Example of usage: | ||
+ | |||
+ | $du = " | ||
+ | forward(); | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== isavpflagset ==== | ||
+ | |||
+ | ==== isflagset ==== | ||
+ | |||
+ | Test if a flag is set for current processed message (if the flag value is 1). The value of the parameter | ||
+ | |||
+ | For more see: https:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | if(isflagset(3)) { | ||
+ | log(" | ||
+ | }; | ||
+ | |||
+ | |||
+ | Kamailio also supports named flags. They have to be declared at the beginning of the config file with: | ||
+ | |||
+ | | ||
Example: | Example: | ||
+ | flags test, a:1, b:2 ; | ||
+ | | ||
+ | setflag(test); | ||
+ | if (isflagset(a)){ # equiv. to isflagset(1) | ||
+ | .... | ||
+ | } | ||
+ | resetflag(b); | ||
+ | |||
+ | ==== is_int ==== | ||
+ | Checks if a pseudo variable argument contains integer value. | ||
+ | |||
+ | if(is_int(" | ||
+ | log(" | ||
+ | } | ||
+ | |||
+ | ==== log ==== | ||
+ | |||
+ | Write text message to standard error terminal or syslog. You can specify the log level as first parameter. | ||
+ | |||
+ | For more see: http:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | log(" | ||
+ | |||
+ | |||
+ | ==== prefix ==== | ||
+ | |||
+ | Add the string parameter in front of username in R-URI. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | prefix(" | ||
+ | |||
+ | ==== resetavpflag ==== | ||
+ | |||
+ | ==== resetflag ==== | ||
+ | |||
+ | ==== return ==== | ||
+ | |||
+ | The return() function allows you to return any integer value from a called route() block. | ||
+ | You can test the value returned by a route using [[devel# | ||
+ | |||
+ | return(0) is same as [[devel# | ||
+ | |||
+ | In bool expressions: | ||
+ | |||
+ | * Negative is FALSE | ||
+ | * Positive is TRUE | ||
+ | |||
+ | If no value is specified, or a route reaches its end without executing a return statement, it returns 1. If return is used in the top level route is equivalent with exit [val]. | ||
+ | |||
+ | Example usage: | ||
< | < | ||
- | redis_cmd("srvN", "GET foo", "r"); | + | route { |
- | if ($redis(r=>type) == $redisd(rpl_int)) { | + | if (route(2)) { |
+ | xlog("L_NOTICE"," | ||
+ | } else { | ||
+ | xlog(" | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | < | ||
+ | route[2] { | ||
+ | | ||
+ | return(1); | ||
+ | } else if (is_method(" | ||
+ | return(-1); | ||
+ | } else { | ||
+ | return(0); | ||
+ | }; | ||
} | } | ||
</ | </ | ||
- | ===== GeoIP Module ===== | + | ==== revert_uri |
- | ==== $gip(pvc=>key) ==== | + | Set the R-URI to the value of the R-URI as it was when the request was received by server |
- | Variables exported by GeoIP module, returning geo-location attributes. The attributes are populated upon calling function **geoip_match(ipaddr, | + | Example of usage: |
- | **pvc** | + | revert_uri(); |
- | * cc - country code | + | ==== rewritehostport ==== |
- | * tz - time zone | + | |
- | * zip - postal code | + | |
- | * lat - latitude | + | |
- | * lon - longitude | + | |
- | * dma - dma code | + | |
- | * ips - ip start | + | |
- | * ipe - ip end | + | |
- | * city - city | + | |
- | * area - area code | + | |
- | * regc - region | + | |
- | * regn - region name | + | |
- | * metro - metro code | + | |
- | * contc - continent code | + | |
- | You can call several time **geoip_match(ipaddr, pvc)** with different ip address and containers in your config, to compare, for example, attributes of source and destination of a call. | + | **Alias name: sethostport, sethp** |
- | <code c> | + | Rewrite the domain part and port of the R-URI with the value of function' |
- | geoip_match(" | + | |
- | geoip_match(" | + | |
- | if($gip(src=> | + | Example of usage: |
- | { | + | |
- | # source and destination from same country | + | |
- | } | + | |
- | </ | + | rewritehostport(" |
- | ===== TLS Module ===== | + | ==== rewritehostporttrans |
- | ==== $tls_version ==== | + | **Alias name: sethostporttrans, |
- | The TLS/SSL version which is used on the TLS connection from which the message was received. String type. | + | |
- | ==== $tls_description ==== | + | |
- | The TLS/SSL description of the TLS connection from which the message was received. String type. | + | |
- | ==== $tls_cipher_info ==== | + | |
- | The TLS/SSL cipher which is used on the TLS connection from which the message was received. String type. | + | |
- | ==== $tls_cipher_bits ==== | + | |
- | The number of cipher bits which are used on the TLS connection from which the message was received. String and Integer type. | + | |
- | ==== $tls_peer_version ==== | + | |
- | The version of the certificate. String type. | + | |
- | ==== $tls_my_version ==== | + | |
- | The version of the certificate. String type. | + | |
- | ==== $tls_peer_serial ==== | + | |
- | The serial number of the certificate. String and Integer type. | + | |
- | ==== $tls_my_serial ==== | + | |
- | The serial number of the certificate. String and Integer type. | + | |
- | ==== $tls_peer_subject ==== | + | |
- | ASCII dump of the fields in the subject section of the certificate. String type. Example: | + | |
- | / | + | |
- | ==== $tls_peer_issuer ==== | + | |
- | ASCII dump of the fields in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject ==== | + | |
- | ASCII dump of the fields in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer ==== | + | |
- | ASCII dump of the fields in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_cn ==== | + | |
- | commonName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_cn ==== | + | |
- | commonName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_cn ==== | + | |
- | commonName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_cn ==== | + | |
- | commonName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_locality ==== | + | |
- | localityName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_locality ==== | + | |
- | localityName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_locality ==== | + | |
- | localityName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_locality ==== | + | |
- | localityName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_country ==== | + | |
- | countryName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_country ==== | + | |
- | countryName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_country ==== | + | |
- | countryName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_country ==== | + | |
- | countryName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_state ==== | + | |
- | stateOrProvinceName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_state ==== | + | |
- | stateOrProvinceName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_state ==== | + | |
- | stateOrProvinceName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_state ==== | + | |
- | stateOrProvinceName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_organization ==== | + | |
- | organizationName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_organization ==== | + | |
- | organizationName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_organization ==== | + | |
- | organizationName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_organization ==== | + | |
- | organizationName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_unit ==== | + | |
- | organizationalUnitName in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_subject_uid ==== | + | |
- | UID in the subject section of the certificate. String type. | + | |
- | ==== $tls_peer_issuer_unit ==== | + | |
- | organizationalUnitName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_my_subject_unit ==== | + | |
- | organizationalUnitName in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_subject_uid ==== | + | |
- | UID in the subject section of the certificate. String type. | + | |
- | ==== $tls_my_issuer_unit ==== | + | |
- | organizationalUnitName in the issuer section of the certificate. String type. | + | |
- | ==== $tls_peer_san_email ==== | + | |
- | email address in the " | + | |
- | ==== $tls_my_san_email ==== | + | |
- | email address in the " | + | |
- | ==== $tls_peer_san_hostname ==== | + | |
- | hostname (DNS) in the " | + | |
- | ==== $tls_my_san_hostname ==== | + | |
- | hostname (DNS) in the " | + | |
- | ==== $tls_peer_san_uri ==== | + | |
- | URI in the " | + | |
- | ==== $tls_my_san_uri ==== | + | |
- | URI in the " | + | |
- | ==== $tls_peer_san_ip ==== | + | |
- | ip address in the " | + | |
- | ==== $tls_my_san_ip ==== | + | |
- | ip address in the " | + | |
- | ==== $tls_peer_verified ==== | + | Rewrite |
- | Returns 1 if the peer' | + | |
- | ==== $tls_peer_revoked ==== | + | Example of usage: |
- | Returns 1 if the peer's certificate was revoked. Otherwise it returns 0. String and Integer type. | + | |
- | ==== $tls_peer_expired ==== | + | rewritehostporttrans(" |
- | Returns | + | |
- | ==== $tls_peer_selfsigned | + | ==== rewritehost |
- | Returns 1 if the peer's certificate is selfsigned. Otherwise it returns 0. String and Integer type. | + | |
- | ==== $tls_peer_notBefore ==== | + | **Alias name: sethost, seth** |
- | Returns the notBefore validity date of the peer's certificate. String type. | + | |
- | ==== $tls_peer_notAfter ==== | + | Rewrite |
- | Returns | + | |
- | ==== $tls_peer_server_name ==== | + | Example |
- | The SNI server name of the peer | + | |
- | ==== $tls_peer_raw_cert ==== | + | rewritehost(" |
- | The raw PEM-encoded client certificate. String type. | + | |
- | ==== $tls_my_raw_cert | + | ==== rewriteport |
- | The raw PEM-encoded client certificate. String type. | + | |
- | ==== $tls_peer_urlencoded_cert ==== | + | **Alias name: setport, setp** |
- | The PEM-encoded client certificate, urlencoded. String type. | + | |
- | ==== $tls_my_urlencoded_cert ==== | + | Rewrites/ |
- | The PEM-encoded client certificate, | + | |
- | ===== SIP Message Attributes ===== | + | |
- | ==== $msg(attr) ==== | + | Example of usage: |
- | Return attributes of SIP message: | + | rewriteport(" |
- | * $msg(len) - sip message length | + | ==== rewriteuri ==== |
- | * $msg(buf) - sip message buffer | + | |
- | * $msg(body) - sip message body | + | |
- | * $msg(body_len) - sip message body length | + | |
- | * $msg(hdrs) - sip message headers | + | |
- | * $msg(fline) - sip message first line | + | |
- | ===== XHTTP Module ===== | + | **Alias name: seturi** |
- | ==== $hu ==== | + | Rewrite the request URI. |
- | * URL of http request. | + | Example |
- | ===== MSRP Module ===== | + | rewriteuri(" |
- | This class of pseudo-variables is exported by MSRP module and give access to attributes of MSRP frames. | + | ==== rewriteuserpass |
- | ==== $msrp(buf) | + | |
- | The entire content of MSRP frame - first line, headers, body and end-line. | + | **Alias name: setuserpass, setup** |
- | ==== $msrp(body) ==== | + | |
- | The body of MSRP frame. | + | Rewrite the password part of the R-URI with the value of function' |
- | ==== $msrp(code) ==== | + | |
- | The code of MSRP replies. | + | Example |
- | ==== $msrp(hdrs) ==== | + | |
- | The headers in a MSRP frame. | + | rewriteuserpass(" |
- | ==== $msrp(msgid) | + | ==== rewriteuser |
- | The body of Message-Id header. | + | **Alias name: setuser, setu** |
- | ==== $msrp(method) ==== | + | |
- | The method | + | Rewrite the user part of the R-URI with the value of function' |
- | ==== $msrp(buflen) ==== | + | |
- | The length | + | Example |
- | ==== $msrp(sessid) ==== | + | |
- | The session id for MSRP frame. It is taken from the first MSRP URI in To-Path header. | + | rewriteuser(" |
- | ==== $msrp(reason) ==== | + | |
- | The reason text in a MSRP reply. | + | ==== route ==== |
- | ==== $msrp(crthop) | + | |
- | The URI for current hop - it is the first URI in To-Path header. | + | Execute route block given in parameter. |
- | ==== $msrp(bodylen) ==== | + | |
- | The length | + | Examples |
- | ==== $msrp(transid) ==== | + | route(REGISTER_REQUEST); |
+ | route(@received.proto + " | ||
- | The transaction ID from the first line of MSRP frame. | ||
- | ==== $msrp(prevhop) ==== | ||
- | The MSRP URI of the previous hop - the first address in From-Path header. | ||
- | ==== $msrp(nexthop) ==== | ||
- | The URI of the next hop - the second address in To-Path header. | + | ==== set_advertised_address |
- | ==== $msrp(lasthop) | + | |
- | The last hop URI - the last address in To-Path header. | + | Same as ' |
- | ==== $msrp(srcaddr) ==== | + | |
- | The address | + | Example |
- | ==== $msrp(srcsock) ==== | + | |
- | The local socket where the MSRP frame was received, set as **proto: | + | set_advertised_address("kamailio.org"); |
- | ==== $msrp(firsthop) ==== | + | |
- | The URI of the first hop - the last address in From-Path header. | + | ==== set_advertised_port |
- | ==== $msrp(prevhops) | + | |
- | The number of previous hops - it is the number of addresses in From-Path header. | + | Same as ' |
- | ==== $msrp(nexthops) ==== | + | |
- | The number | + | Example |
- | ==== $msrp(conid) ==== | + | set_advertised_port(5080); |
- | The internal integer id for TCP/TLS connection. | + | ==== set_forward_no_connect ==== |
- | ===== SIPT Module ===== | + | The message will be forwarded only if there is already an existing connection to the destination. It applies only to connection oriented protocols like TCP and TLS (TODO: SCTP), for UDP it will be ignored. The behavior depends in which route block the function is called: |
- | ==== $sipt(calling_party_number.presentation) / $sipt_presentation ==== | + | * normal request route: affects stateless forwards and tm. For tm it affects all the branches and the possible retransmissions (in fact there are no retransmission for TCP/TLS). |
- | Returns | + | |
- | The following values can be returned: | + | * onreply_route[0] (stateless): equivalent to set_reply_*() (it's better to use set_reply_* though) |
- | * 0 presentation allowed | + | |
- | * 1 resentation restricted | + | * onreply_route[!=0] < |
- | * 2 address | + | |
- | * 3 spare | + | * branch_route: |
+ | |||
+ | * onsend_route: | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route { | ||
+ | ... | ||
+ | if (lookup()) { | ||
+ | //requests to local users. They are usually behind NAT so it does not make sense to try | ||
+ | //to establish a new TCP connection | ||
+ | set_forward_no_connect(); | ||
+ | t_relay(); | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ==== set_forward_close ==== | ||
+ | |||
+ | Try to close the connection (the one on which the message is sent out) after forwarding the current message. Can be used in same route blocks as set_forward_no_connect(). | ||
+ | |||
+ | Note: Use with care as you might not receive the replies anymore as the connection is closed. | ||
+ | |||
+ | |||
+ | ==== set_reply_no_connect ==== | ||
+ | |||
+ | Like set_forward_no_connect(), | ||
+ | |||
+ | * normal request route: affects all replies sent back on the transaction (either local or forwarded) and all local stateless replies (sl_reply()). | ||
+ | |||
+ | * onreply_route: | ||
+ | |||
+ | * branch_route: | ||
+ | |||
+ | * onsend_route: | ||
+ | |||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route[4] { | ||
+ | //requests from local users. There are usually behind NAT so it does not make sense to try | ||
+ | //to establish a new TCP connection for the replies | ||
+ | set_reply_no_connect(); | ||
+ | // do authentication and call routing | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ==== set_reply_close ==== | ||
+ | |||
+ | Like set_reply_no_connect, | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route { | ||
+ | ... | ||
+ | if (...caller-is-not-registered...) { | ||
+ | // reject unregistered client | ||
+ | // if request was received via TCP/TLS close the connection, as | ||
+ | // this may trigger re-registration of the client. | ||
+ | set_reply_close(); | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | |||
+ | ==== setavpflag ==== | ||
+ | |||
+ | ==== setflag ==== | ||
+ | |||
+ | Set a flag for current processed message. The value of the parameter can be in range of 0..31. The flags are used to mark the message for special processing (e.g., accounting) or to keep some state (e.g., message authenticated). | ||
+ | |||
+ | For more see: https:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | setflag(3); | ||
+ | |||
+ | ==== strip ==== | ||
+ | |||
+ | Strip the first N-th characters from username of R-URI (N is the value of the parameter). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | strip(3); | ||
+ | |||
+ | ==== strip_tail ==== | ||
+ | |||
+ | Strip the last N-th characters from username of R-URI (N is the value of the parameter). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | strip_tail(3); | ||
+ | |||
+ | ==== udp_mtu_try_proto(proto) ==== | ||
+ | |||
+ | * proto - TCP|TLS|SCTP|UDP - like udp_mtu_try_proto global parameter but works on a per packet basis and not globally. | ||
Example: | Example: | ||
- | < | + | < |
- | if($sipt(calling_party_number.presentation) | + | if($rd==" |
- | { | + | |
- | append_hf(" | + | |
- | $fn = " | + | |
- | } | + | |
</ | </ | ||
+ | ==== userphone ==== | ||
- | ==== $sipt(calling_party_number.screening) / $sipt_screening | + | Add "user=phone" parameter to R-URI. |
- | Returns | + | |
+ | ===== Custom Global Parameters | ||
+ | |||
+ | These are parameters that can be defined by the writer | ||
+ | |||
+ | The definition of a custom global parameter must follow the pattern: | ||
+ | |||
+ | < | ||
+ | group.variable = value desc " | ||
+ | |||
+ | </ | ||
- | Can return the following values: | + | The value can be a quoted string or integer number. |
- | * 0 Reserved (user provided, not verified) | + | |
- | * 1 User Provided, Verified and Passed | + | |
- | * 2 Reserved (user provided, verified and failed) | + | |
- | * 3 Network provided | + | |
Example: | Example: | ||
+ | |||
<code c> | <code c> | ||
- | # remove P-Asserted-Identity header if the screening isn't verified | + | pstn.gw_ip = "1.2.3.4" desc "PSTN GW Address" |
- | # or network provided | + | |
- | $avp(s: | + | |
- | if($avp(s: | + | |
- | { | + | |
- | remove_hf("P-Asserted-Id"); | + | |
- | } | + | |
</ | </ | ||
+ | The custom global parameter can be accessed inside a routing block via: | ||
- | ==== | + | < |
- | Returns the value of the Hop Counter for the IAM message if it exists. Returns -1 if there isn't a hop counter. | + | $sel(cfg_get.group.variable) |
+ | </ | ||
Example: | Example: | ||
+ | |||
<code c> | <code c> | ||
- | # get the hop counter and update the Max-Forwards header if it exists | + | $ru = "sip:" |
- | $avp(s: | + | |
- | if($avp(s:hop) > 0) | + | |
- | { | + | |
- | remove_hf("Max-Forwards"); | + | |
- | append_hf("Max-Forwards: | + | |
- | } | + | |
</ | </ | ||
- | ==== $sipt(calling_party_category) / $sipt(cpc) / $sipt_cpc ==== | + | **Note:** Some words cannot be used as (part of) names for custom variables or groups, and if they are used a syntax |
- | Returns the value of the Calling Party Category | + | |
- | ==== $sipt(calling_party_number.nature_of_address) / $sipt.(calling_party_number.nai) / $sipt_calling_party_nai | + | ===== Routing Blocks ===== |
- | Returns the value of the Nature of Address Indicator of the Calling Party for the IAM message. Returns -1 if there is a parsing error or if the Calling Party Number is not present. | + | |
- | Can return | + | The routing blocks are the parts of the configuration file executed by kamailio at runtime. They can be seen as blocks of actions similar to functions |
- | * 0 Spare | + | |
- | * 1 Subscriber Number | + | A routing block is identified by a specific token, followed by a name in between square brackets and actions in between curly braces. |
- | * 2 Unknown (national use) | + | |
- | * 3 National (significant) number (national use) | + | |
- | * 4 International use | + | |
- | Example: | ||
<code c> | <code c> | ||
- | # get the Calling Nai and add country code if national | + | route_block_id[NAME] |
- | if($sipt(calling_party_number.nai) == 3) | + | |
- | { | + | |
- | $fU = " | + | |
} | } | ||
</ | </ | ||
- | ==== $sipt(called_party_number.nature_of_address) / $sipt(called_party_number.nai) / $sipt_called_party_nai ==== | + | The name can be any alphanumeric string, with specific routing blocks enforcing |
- | Returns the value of the Nature of Address Indicator of the Called Party for the IAM message. Returns -1 if there is a parsing error. | + | |
- | Can return the following values: | + | <fc # |
- | * 0 Spare | + | Route blocks can be executed on network events |
- | * 1 Subscriber Number | + | |
- | * 2 Unknown | + | There can be so called sub-route blocks, which can be invoked from another route blocks, like a function. Invocation is done with ' |
- | * 3 National (significant) number | + | |
- | * 4 International use | + | |
- | * 5 Network-specific number (national use) | + | |
Example: | Example: | ||
+ | |||
<code c> | <code c> | ||
- | # get the Called Nai and add country code if national | + | request_route{ |
- | if($sipt(called_party_number.nai) == 3) | + | ... |
- | { | + | route(" |
- | $rU = "32" | + | ... |
- | } | + | } |
+ | |||
+ | route["test"]{ | ||
+ | ... | ||
+ | } | ||
</ | </ | ||
- | ==== $sipt(event_info) | + | ==== request_route ==== |
- | Returns the value of the Event Info header of the CPG message. Returns -1 if there is a parsing error. | + | |
- | Can return the following values: | + | Request routing block - |
- | * 0 Spare | + | |
- | * 1 ALERTING | + | |
- | * 2 PROGRESS | + | |
- | * 3 In-band information or an appropriate pattern | + | |
- | * 4 Call forward on busy | + | |
- | * 5 Call forward on no reply | + | |
- | * 6 Call forward unconditional | + | |
+ | It contains a set of actions to be executed for SIP requests received from the network. It is the equivalent of *main()* function for handling the SIP requests. | ||
- | ==== $sipt(backward_call_indicator.charge_indicator) === | + | <fc # |
- | Returns the value of the charge indication of the backward | + | |
- | indicator header in the ACM or COT message. Returns -1 if there is a | + | |
- | parsing error | + | |
- | Can return | + | The implicit action after execution of the main route block is to drop the SIP request. To send a reply or forward the request, explicit actions (e.g., sl_send_reply(), |
- | * 0 no indication | + | |
- | * 1 no charge | + | |
- | * 2 charge | + | |
- | * 3 spare | + | |
+ | Example of usage: | ||
- | ===== $cfg(key) - Config File Attributes ===== | + | <code c> |
+ | request_route { | ||
+ | | ||
+ | # send reply for each options request | ||
+ | sl_send_reply(" | ||
+ | exit(); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | route[FWD] { | ||
+ | # forward according to uri | ||
+ | | ||
+ | } | ||
+ | </ | ||
- | Attributes related to configuration file. | + | ==== route ==== |
- | The key can be: | + | This block is used to define ' |
- | * line - return | + | The definition of the sub-route block follows |
- | * name - return the name of current config file | + | |
- | * file - return the name of current config file | + | Evaluation of the return |
- | * route - return the name of routing block | + | * negative value is evaluated as false |
+ | * 0 - is interpreted as **exit** | ||
+ | * positive value is evaluated as true | ||
- | Example: | ||
<code c> | <code c> | ||
- | send_reply("404", "Not found at line $cfg(line)"); | + | request_route { |
+ | if(route(POSITIVE)) { | ||
+ | xlog("return number is positive\n"); | ||
+ | } | ||
+ | if( ! route(NEGATIVE)) { | ||
+ | xlog("return number is negative\n" | ||
+ | } | ||
+ | if( route(ZERO)) { | ||
+ | xlog(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | route[POSITIVE] { | ||
+ | return 10; | ||
+ | } | ||
+ | |||
+ | route[NEGATIVE] { | ||
+ | return -8; | ||
+ | } | ||
+ | |||
+ | route[ZERO] { | ||
+ | return 0; | ||
+ | } | ||
</ | </ | ||
- | ===== $dns(pvid=> | + | A sub-route can execute another sub-route. There is a limit to the number of recursive levels, avoiding ending up in infinite loops -- see **max_recursive_level** global parameter. |
- | This variable stores | + | The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. |
+ | ==== branch_route ==== | ||
- | * pvid can be any string | + | Request' |
- | * key can be: | + | |
- | * count - number | + | |
- | * ipv4 - set to 1 if at least one ipv4 address (otherwise 0) | + | |
- | * ipv6 - set to 1 if at least one ipv6 address (otherwise 0) | + | |
- | * addr[index] - the address as string from position index in the list (0 based indexing) | + | |
- | * type[index] - the type of address from position index in the list (0 based indexing), the value is 4 for ipv4 and 6 for ipv6 | + | |
- | The index can be an integer or a variable with integer value. First address has the index 0. If negative value, the returned address is counted from the end of the list, -1 being the last address. If no index is provided, then the first address is returned. | + | Example |
<code c> | <code c> | ||
- | if(dns_query("test.com", | + | request_route { |
- | { | + | lookup("location"); |
- | xlog(" | + | |
- | xlog(" ipv4 address found: $dns(xyz=> | + | if(!t_relay()) { |
- | xlog(" | + | |
- | | + | } |
- | | + | |
- | | + | |
- | " | + | |
- | $var(i) = $var(i) + 1; | + | # discard branches that go to 10.10.10.10 |
+ | drop(); | ||
+ | } | ||
} | } | ||
- | } | ||
</ | </ | ||
- | ===== $HN(key) - Hostname details ===== | + | ==== failure_route |
- | Give local hostname details | + | Failed transaction routing block. It contains a set of actions to be taken each transaction that received only negative replies |
- | The key can be: | + | Note that in ' |
- | * n - the hostname | + | |
- | * f - the fullname | + | |
- | * d - the domain | + | Example of usage: |
- | * i - the ip address | + | |
<code c> | <code c> | ||
- | xlog("local hostanme is $HN(n)\n"); | + | request_route { |
+ | lookup("location" | ||
+ | t_on_failure(" | ||
+ | if(!t_relay()) { | ||
+ | sl_send_reply(" | ||
+ | } | ||
+ | } | ||
+ | failure_route[TOVOICEMAIL] { | ||
+ | if(is_method(" | ||
+ | # call failed - relay to voice mail | ||
+ | | ||
+ | } | ||
+ | } | ||
</ | </ | ||
- | ===== $RANDOM - Random number ===== | + | ==== reply_route |
- | Returns | + | Main SIP response (reply) handling block - it contains |
- | (Part of the cfgutils | + | It does not have a name and it is executed by the core, before any other module |
+ | |||
+ | There is no network route that can be enforced for a SIP reply - it is sent based on Via header, according to SIP RFC3261 - therefore no dedicated actions for forwarding the reply must be used in this block. | ||
+ | |||
+ | This routing block is optional, if missing, the SIP reply is sent to the address in 2nd Via header. | ||
+ | |||
+ | One can decide to drop a SIP reply by using **drop** action. | ||
+ | |||
+ | Example: | ||
<code c> | <code c> | ||
- | if (rand_event()) | + | reply_route |
- | | + | |
- | if ($avp(i:10) < 10) { | + | drop; |
- | $avp(i:10) = 10; | + | |
} | } | ||
- | append_to_reply(" | + | } |
- | sl_send_reply(" | + | |
- | exit; | + | |
- | }; | + | |
- | # normal message processing follows | + | |
</ | </ | ||
- | ===== JSONRPCS Variables ===== | + | <fc # |
- | ==== $jsonrpl(key) - JSONRPC Reply ==== | + | ==== onreply_route |
- | This variable gives access to JSONRPC reply after executing jsonrpc_exec(...) in kamailio.cfg. | ||
- | The key can be: | + | SIP reply routing block executed by **tm** module. It contains a set of actions to be taken for SIP replies in the contect |
- | | + | |
- | | + | |
- | * body - the body of the JSONRPC response | + | |
- | ===== Presence Module ===== | + | The ' |
- | ==== $subs(key) - Subscription Attributes ==== | + | Core ' |
- | This variable gives access to attributes of the current subscription. The variable has to be used after executing // | + | <code c> |
+ | request_route { | ||
+ | lookup(" | ||
+ | t_on_reply(" | ||
+ | if(!t_relay()) { | ||
+ | sl_send_reply(" | ||
+ | } | ||
+ | } | ||
- | The key can be: | + | reply_route { |
- | | + | if(!t_check_trans()) { |
+ | drop; | ||
+ | } | ||
+ | | ||
- | ===== Registrar Module ===== | + | onreply_route[LOGRPL] { |
+ | if(status=~" | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | ==== onsend_route | ||
- | ==== $ulc(profile=> | + | The route is executed in when a SIP request is sent out. Only a limited number of commands are allowed |
- | Access | + | In this route the final destination |
- | It must be used after a call of “reg_fetch_contacts()”. | + | This route is executed only when forwarding requests - it is not executed for replies, retransmissions, |
- | ===== Sipcapture Module ===== | + | Example: |
- | ==== $hep(key) - HEP Packet Attributes ==== | + | <code c> |
+ | onsend_route { | ||
+ | if(to_ip==1.2.3.4 && !isflagset(12)){ | ||
+ | log(1, " | ||
+ | drop; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | The key refers | + | * snd_ip, snd_port - behave like src_ip/ |
+ | * to_ip, to_port - like above, but contain the ip/port the message will be sent to (not to be confused with dst_ip/ | ||
+ | * snd_proto, snd_af - behave like proto/af but contain the protocol/ | ||
+ | * msg:len - when used in an onsend_route, | ||
- | * version - HEP version | + | ==== event_route ==== |
- | * src_ip - source IP address | + | |
- | * dst_ip - destination IP address | + | |
- | * 0x000 - HEP attribute 0x000 | + | |
- | * 0x999 - HEP attribute 0x999 | + | |
- | ===== $phn(rid=> | + | Generic type of route executed when specific events happen. |
- | $phn(rid=> | + | Prototype: event_route[groupid: |
+ | * groupid | ||
+ | * eventid - some meaningful short text describing the event | ||
- | * number - phone number that is matched | + | === Core Event Routes === |
- | * valid - 1 if the matched number has a valid result; 0 otherwise | + | |
- | * normalized - normalized phone number | + | Implementations: |
- | * cctel - country code for phone number | + | |
- | * ltype - local network type | + | * **event_route[core: |
- | | + | * note that due to forking, other sip workers can get faster to listening for sip traffic |
- | * error - error string if phone number matching fails. | + | |
<code c> | <code c> | ||
- | if(phonenum_match("1-484-555-8888", "src")) { | + | event_route[core: |
- | if($phn(src=>valid)==1) { | + | xlog("L_INFO"," |
- | | + | } |
- | } else { | + | </ |
- | | + | |
+ | * **event_route[core: | ||
+ | * it has to be enabled with received_route_mode global parameter. For usage via Kemi, set kemi.received_route_callback global parameter. | ||
+ | * if drop is executed, the received message is no longer processed | ||
+ | |||
+ | <code c> | ||
+ | event_route[core: | ||
+ | xlog("rcv on $rcv(af)/ | ||
+ | if($rcv(srcip) == " | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | === Module Event Routes === | ||
+ | |||
+ | Here are only a few examples, to see if a module exports event_route blocks and when they are executed, check the readme of the module. | ||
+ | |||
+ | |||
+ | * **event_route[htable: | ||
+ | <code c> | ||
+ | modparam(" | ||
+ | |||
+ | event_route[htable: | ||
+ | | ||
+ | $sht(a=> | ||
+ | } | ||
+ | |||
+ | request_route | ||
+ | if(is_method(" | ||
+ | { | ||
+ | switch($rd) { | ||
+ | case " | ||
+ | | ||
+ | | ||
+ | $sht(a=> | ||
+ | | ||
+ | if($sht(a=>calls-to:: | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | break; | ||
+ | ... | ||
} | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * **event_route [tm: | ||
+ | <code c> | ||
+ | event_route [tm: | ||
+ | xlog(" | ||
+ | t_set_fr(10000, | ||
} | } | ||
</ | </ | ||
+ | * **event_route [tm: | ||
+ | <code c> | ||
+ | request_route { | ||
+ | ... | ||
+ | t_on_branch_failure(" | ||
+ | t_relay(); | ||
+ | } | ||
- | ===== sdpops module variables ===== | + | event_route[tm: |
+ | xlog(" | ||
+ | if (t_check_status(" | ||
+ | unregister(" | ||
+ | if (t_next_contact_flow()) { | ||
+ | t_relay(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
- | * $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) | + | |
- | ===== $sruid - Unique ID ===== | + | ===== Script Statements |
- | * $sruid | + | ==== if ==== |
+ | IF-ELSE statement | ||
- | ===== $ltt(key) - Local To-Tag ===== | + | Prototype: |
- | $ltt(key) - return local generated To-tag when Kamailio sends a reply | + | < |
+ | if(expr) { | ||
+ | | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | </ | ||
- | * $ltt(s) - the to-tag used in stateless replies | + | The ' |
- | * $ltt(t) - the to-tag used in transaction stateful replies (transaction has to be created at that time, eg., by t_newtran() or in a branch/ | + | |
- | * $ltt(x) - $ltt(t) if the transaction was created already, otherwise $ltt(s) | + | |
- | ===== tcpops module variable ===== | + | The logical operators that can be used in ' |
- | $tcp(key) - return TCP connection attributes. | + | < |
+ | == equal | ||
+ | != not equal | ||
+ | =~ regular expression matching: Note: Posix regular expressions will be used, e.g. use [[: | ||
+ | !~ regular expression not-matching | ||
+ | > | ||
+ | >= greater or equal | ||
+ | < | ||
+ | <= less or equal | ||
+ | && | ||
+ | || logical OR | ||
+ | ! | ||
+ | [ ... ] test operator - inside can be any arithmetic expression | ||
+ | </ | ||
- | The key can be: | + | Example of usage: |
- | * c_si - connection source ip (useful with HAProxy connections) | + | |
- | * c_sp - connection source port (useful with HAProxy connections) | + | |
- | * conid - connection id | + | |
+ | if(is_method(" | ||
+ | { | ||
+ | log(" | ||
+ | } else { | ||
+ | log(" | ||
+ | } | ||
- | ===== pv_headers module variables ===== | ||
- | * $x_hdr(// | + | ==== switch ==== |
- | * $x_fu: Full From header | + | |
- | * $x_fU: From header user part | + | |
- | * $x_fd: From header domain part | + | |
- | * $x_fn: From header Display Name part | + | |
- | * $x_ft: From header Tag | + | |
- | * $x_tu: Full To header | + | |
- | * $x_tU: To header user part | + | |
- | * $x_td: To header domain part | + | |
- | * $x_tn: To header Display Name part | + | |
- | * $x_tt: To header Tag | + | |
- | * $x_rs: | + | |
- | * $x_rr: | + | |
- | ===== $C(xy) | + | SWITCH statement |
- | $C(xy) - reference to an escape sequence. “x” represents | + | IMPORTANT NOTE: ' |
- | Colors could be: | ||
- | * x : default color of the terminal | + | Example |
- | * s : Black | + | < |
- | * r : Red | + | route { |
- | * g : Green | + | |
- | * y : Yellow | + | switch($retcode) |
- | * b : Blue | + | { |
- | * p : Purple | + | case -1: |
- | * c : Cyan | + | |
- | * w : White | + | break; |
+ | case 1: | ||
+ | | ||
+ | break; | ||
+ | case 2: | ||
+ | case 3: | ||
+ | | ||
+ | break; | ||
+ | default: | ||
+ | log(" | ||
+ | } | ||
+ | # switch of R-URI username | ||
+ | switch($rU) | ||
+ | { | ||
+ | case " | ||
+ | log(" | ||
+ | break; | ||
+ | case " | ||
+ | log(" | ||
+ | break; | ||
+ | case " | ||
+ | case " | ||
+ | log(" | ||
+ | break; | ||
+ | default: | ||
+ | log(" | ||
+ | } | ||
+ | } | ||
+ | route[1]{ | ||
+ | if(is_method(" | ||
+ | { | ||
+ | return(-1); | ||
+ | }; | ||
+ | if(is_method(" | ||
+ | return(1); | ||
+ | } | ||
+ | if(is_method(" | ||
+ | return(2); | ||
+ | } | ||
+ | if(is_method(" | ||
+ | return(3); | ||
+ | } | ||
+ | return(-2); | ||
+ | } | ||
+ | </ | ||
+ | NOTE: take care while using ' | ||
- | ===== Examples ===== | ||
+ | ==== while ==== | ||
- | A few examples of usage. | + | while statement |
- | Example | + | Example |
- | <code c> | + | |
- | ... | + | $var(i) = 0; |
- | avp_aliases=" | + | |
- | ... | + | |
- | route { | + | xlog("counter: |
- | ... | + | |
- | $avp(uuid)=" | + | } |
- | $avp(i:20)= $avp(uuid) + ": " + $fu; | + | |
- | | + | ===== Script Operations ===== |
- | ... | + | |
- | } | + | Assignments together with string and arithmetic operations can be done directly in configuration file. |
- | ... | + | ==== Assignment ==== |
+ | |||
+ | Assignments can be done like in C, via ' | ||
+ | * Unordered List Item AVPs - to set the value of an AVP | ||
+ | * script variables ($var(...)) - to set the value of a script variable | ||
+ | * shared variables ($shv(...)) | ||
+ | * $ru - to set R-URI | ||
+ | * $rd - to set domain part of R-URI | ||
+ | * $rU - to set user part of R-URI | ||
+ | * $rp - to set the port of R-URI | ||
+ | * $du - to set dst URI | ||
+ | * $fs - to set send socket | ||
+ | * $br - to set branch | ||
+ | * $mf - to set message flags value | ||
+ | * $sf - to set script flags value | ||
+ | * $bf - to set branch flags value | ||
+ | |||
+ | < | ||
+ | $var(a) = 123; | ||
</ | </ | ||
- | ==== Request-URI | + | For avp's there a way to remove all values |
+ | < | ||
+ | $(avp(i: | ||
+ | $(avp(i: | ||
+ | </ | ||
- | Following are some examples how RURI and DURI are parsed, for SIP-URIs, tel-URIs and Service-URNs: | + | ==== String Operations ==== |
+ | For strings, ' | ||
< | < | ||
- | === Request URI contains SIP URI === | + | $var(a) |
- | $ru = "sip:example.com" | + | $var(b) |
- | $rz = "sip" | + | </code> |
- | $rU = "<null>" | + | ==== Arithmetic Operations ==== |
- | $rd = " | + | |
- | $rp = " | + | |
- | $rP = " | + | |
- | === Request URI contains SIP URI === | + | For numbers, one can use: |
- | $ru = "sips:john.q.public:hispw@example.com:6061; | + | * + : plus |
- | | + | * - : minus |
- | | + | * / : divide |
- | | + | |
- | | + | |
- | | + | |
+ | | ||
+ | | ||
+ | * ~ : bitwise NOT | ||
+ | * < | ||
+ | * < | ||
- | === Request URI contains service URN === | ||
- | $ru = " | ||
- | $rz = " | ||
- | $rU = " | ||
- | $rd = " | ||
- | $rp = " | ||
- | $rP = " | ||
- | === Request URI contains tel: URI === | + | Example: |
- | $ru = "tel:+1-201-555-0123" | + | |
- | | + | < |
- | | + | $var(a) |
- | $rd = "<null>" | + | </ |
- | | + | |
- | | + | NOTE: to ensure the priority of operands in expression evaluations do use __parenthesis__. |
+ | |||
+ | Arithmetic expressions can be used in condition expressions. | ||
+ | |||
+ | < | ||
+ | if( $var(a) & 4 ) | ||
+ | log(" | ||
+ | </ | ||
+ | |||
+ | ===== Operators ===== | ||
+ | |||
+ | - type casts operators: (int), (str). | ||
+ | - string comparison: eq, ne | ||
+ | - integer comparison: ieq, ine | ||
+ | |||
+ | Note: The names are not yet final (use them at your own risk). Future version might use ==/!= only for ints (ieq/ine) and eq/ne for strings (under debate). They are almost equivalent to == or !=, but they force the conversion of their operands (eq to string and ieq to int), allowing among other things better type checking on startup and more optimizations. | ||
+ | |||
+ | Non equiv. examples: | ||
+ | |||
+ | 0 == "" (true) is not equivalent to 0 eq "" | ||
+ | |||
+ | " | ||
+ | |||
+ | Note: internally == and != are converted on startup to eq/ | ||
+ | |||
+ | - Kamailio tries to guess what the user wanted when operators that support multiple types are used on different typed operands. In general convert the right operand to the type of the left operand and then perform the operation. Exception: the left operand is undef. This applies to the following operators: +, == and !=. | ||
+ | | ||
+ | For +: undef + expr -> undef is converted to string => "" | ||
+ | For == and !=: undef == expr -> undef is converted to type_of expr. | ||
+ | If expr is undef, then undef == undef is true (internally is converted | ||
+ | to string). | ||
+ | |||
+ | | ||
+ | int(undef)==0, | ||
+ | str(undef)=="", str(123)==" | ||
+ | |||
+ | | ||
+ | defined expr - returns true if expr is defined, and false if not. | ||
+ | Note: only a standalone avp or pvar can be | ||
+ | | ||
+ | strlen(expr) | ||
+ | strempty(expr) - returns true if expr evaluates to the empty | ||
+ | | ||
+ | | ||
+ | |||
+ | ===== Command Line Parameters ===== | ||
+ | |||
+ | Kamailio can be started with a set of command line parameters, providing more flexibility to control what is doing at runtime. Some of them can be quite useful when running on containerised environments. | ||
+ | |||
+ | To see the the available command line parameters, run **kamailio -h**: | ||
+ | |||
+ | <code> | ||
+ | # kamailio -h | ||
+ | |||
+ | version: kamailio 5.4.0-dev4 (x86_64/ | ||
+ | Usage: kamailio [options] | ||
+ | Options: | ||
+ | -a mode Auto aliases mode: enable with yes or on, | ||
+ | disable with no or off | ||
+ | --alias=val | ||
+ | (like for ' | ||
+ | -A define | ||
+ | -A ' | ||
+ | -b nr Maximum receive buffer size which will not be exceeded by | ||
+ | auto-probing procedure even if OS allows | ||
+ | -c Check configuration file for syntax errors | ||
+ | -d | ||
+ | -D | ||
+ | -D..do not fork (almost) anyway; | ||
+ | -DD..do not daemonize creator; | ||
+ | -DDD..daemonize (default) | ||
+ | -e Log messages printed in terminal colors (requires -E) | ||
+ | -E Log to stderr | ||
+ | -f file Configuration file (default: / | ||
+ | -g gid | ||
+ | -G file Create a pgid file | ||
+ | -h This help message | ||
+ | --help | ||
+ | -I Print more internal compile flags and options | ||
+ | -K Turn on " | ||
+ | -l address | ||
+ | mean listening on more addresses). The address format is | ||
+ | [proto: | ||
+ | where proto=udp|tcp|tls|sctp, | ||
+ | addr_lst= addr|(addr, addr_lst), | ||
+ | addr=host|ip_address|interface_name and | ||
+ | advaddr=addr[: | ||
+ | E.g: -l localhost, -l udp: | ||
+ | -l udp: | ||
+ | -l "sctp: | ||
+ | The default behaviour is to listen on all the interfaces. | ||
+ | --loadmodule=name load the module specified by name | ||
+ | --log-engine=log engine name and data | ||
+ | -L path Modules search path (default: / | ||
+ | -m nr Size of shared memory allocated in Megabytes | ||
+ | --modparam=modname: | ||
+ | type has to be ' | ||
+ | example: --modparam=corex: | ||
+ | -M nr Size of private memory allocated, in Megabytes | ||
+ | -n processes Number of child processes to fork per interface | ||
+ | (default: 8) | ||
+ | -N | ||
+ | -O nr Script optimization level (debugging option) | ||
+ | -P file Create a pid file | ||
+ | -Q | ||
+ | -r Use dns to check if is necessary to add a " | ||
+ | field to a via | ||
+ | -R Same as `-r` but use reverse dns; | ||
+ | (to use both use `-rR`) | ||
+ | --server-id=num set the value for server_id | ||
+ | --subst=exp set a subst preprocessor directive | ||
+ | --substdef=exp set a substdef preprocessor directive | ||
+ | --substdefs=exp set a substdefs preprocessor directive | ||
+ | -S | ||
+ | -t dir | ||
+ | -T | ||
+ | -u uid | ||
+ | -v | ||
+ | --version | ||
+ | -V | ||
+ | -x name Specify internal manager for shared memory (shm) | ||
+ | - can be: fm, qm or tlsf | ||
+ | -X name Specify internal manager for private memory (pkg) | ||
+ | - if omitted, the one for shm is used | ||
+ | -Y dir | ||
+ | -w dir | ||
+ | -W type poll method (depending on support in OS, it can be: poll, | ||
+ | epoll_lt, epoll_et, sigio_rt, select, kqueue, / | ||
+ | </ | ||
+ | |||
+ | ==== Log Engine CLI Parameter ==== | ||
+ | |||
+ | The **--log-engine** parameter allows to specify what logging engine to be used, which is practically about the format of the log messages. If not set at all, then Kamailio does the classic style of line-based plain text log messages. | ||
+ | |||
+ | The value of this parameter can be **--log-engine=name** or **--log-engine=name: | ||
+ | |||
+ | The name of the log engine can be: | ||
+ | |||
+ | | ||
+ | * the **data** for **json** log engine can be a set of character flags: | ||
+ | * **a** - add log prefix as a special field | ||
+ | * **A** - do not add log prefix | ||
+ | * **c** - add Call-ID (when available) as a dedicated JSON attribute | ||
+ | * **M** - strip EOL (' | ||
+ | * **N** - do not add EOL at the end of JSON document | ||
+ | |||
+ | Example of JSON logs when running Kamailio with " | ||
+ | |||
+ | < | ||
+ | { " | ||
- | === Request URI contains tel: URI with phone-context === | + | { " |
- | $ru = "tel:7042; | + | |
- | $rz = "tel" | + | |
- | $rU = "7042" | + | |
- | $rd = "< | + | |
- | $rp = "5060" | + | |
- | $rP = "UDP" | + | |
- | === Destination URI (must be a SIP(S) URI) === | ||
- | $du = " | ||
- | $dd = " | ||
- | $dp = " | ||
- | $dP = " | ||
</ | </ |
cookbooks/5.4.x/core.1592555651.txt.gz · Last modified: 2020/06/19 08:34 by linuxmaniac