当前位置: 首页 > news >正文

天津网站制作工具网站数据库备份怎么做

天津网站制作工具,网站数据库备份怎么做,东方网络律师团队,雄安优秀网站建设哪家好Core 说明书 版本#xff1a;Kamailio SIP Server v6.0.x#xff08;稳定版#xff09; 概述 本教程收集了 Kamailio 导出的函数和参数 core 添加到配置文件中。 注意#xff1a;此页面上的参数不按字母顺序排列。 结构 kamailio.cfg 的结构可以看作是三个部分#xff…Core 说明书 版本Kamailio SIP Server v6.0.x稳定版 概述 本教程收集了 Kamailio 导出的函数和参数 core 添加到配置文件中。 注意此页面上的参数不按字母顺序排列。 结构 kamailio.cfg 的结构可以看作是三个部分 全局参数 模块 设置 路由块 为了清晰且易于维护建议保留 它们按此顺序排列尽管其中一些可以混合。 全局参数部分 这是配置文件的第一部分包含 参数用于 Kamailio 的核心和自定义全局参数。 通常这是由以下形式的指令形成的 namevalue 该名称对应于以下 部分。如果名称与核心参数不匹配则 则 Kamailio 将无法启动并在启动过程中出现错误。 该值通常为整数、布尔值或字符串。 多个参数可以获得由组组成的复数值 的整数、字符串或标识符。例如这样的参数是 listen可以为其分配一个类似于 protoipaddressport 的值。 内容示例 log_facilityLOG_LOCAL0 children4 disable_tcpyes alias“sip.mydomain.com” listenudp:10.0.0.10:5060 通常设置参数以行尾结束但也可以是 以 ;分号结尾。当 parameter 允许多行的值如 listen 或 alias 而下一行则通过作为 value 的一部分被吞噬而产生冲突 对于上一个参数。 alias“sip.mydomain.com”; 如果要将保留的 config 关键字用作参数的一部分请使用 需要将其括在引号中。请参阅下面的关键字示例 “dns” 的 DNS 文件。 listentcp:127.0.0.1:5060 advertise “sip.dns.example.com”:5060 Modules Settings 部分 这是配置文件的第二部分包含 指令来加载模块并设置它们的参数。 它包含指令 loadmodule 和 modparam。在 default configuration file 以将 path 设置为 modules 的 intent 中 分配给 mpath 核心参数。 内容示例 loadmodule “debugger.so” … modparam(“debugger”, “cfgtrace”, 1) Routing Blocks 部分 这是配置文件的最后一部分通常是 largest 的包含具有 由 Kamailio 处理的 SIP 流量。 唯一的强制路由块是 request_route其中包含 用于决定 SIP 请求路由的作。 有关详细信息请参阅本文档中的 路由块 一章 关于配置文件中可以使用哪些类型的路由块 以及它们在路由 SIP 流量和 Kamailio 行为中的作用。 内容示例 request_route { # per request initial checks route(REQINIT);...} branch_route[MANAGE_BRANCH] { xdbg(“new branch [$T_branch_idx] to $ru\n”); route(NATMANAGE); } Generic Elements Comments Line comments start with (hash/pound character - like in shell) or (double forward slash - like in C/Java).#// Block comments start with (forward slash and asterisk) and are ended by (asterisk and forward slash) (like in C, C, Java)./**/ Example: this is a line comment // this is another line comment /* this is a block comment */ Important: be aware of preprocessor directives that start with (hash/pound and exclamation) - those are no longer line comments.#! Values There are three types of values used for parameters, assignments, arithmetic or string expressions: integer - numbers of 32bit size boolean - aliases to (, , ) or (, , 1trueonyes0falseoffno) string - 括在双引号或单引号之间的标记 例 // next two are strings “this is a string value” ‘this is another string value’ // next is a boolean yes // next is an integer 64 注意请注意表达式逻辑计算的特定规则并且 返回代码请参阅 和 的文档。IFreturn 标识符 标识符是不括在单引号或双引号中的标记 并匹配整数或布尔值的规则。 例如标识符是核心参数和函数 module 函数、核心关键字和语句。 例 return 变量 变量以 $美元字符开头。 您可以在 Pseudo-Variables 伪变量 中看到包含可用变量的列表 食谱。 例 $var(x) $rU “” $fd; 行动 作是在路由块内用到的元素以 ;分号结尾。它可以是从核心或模块执行函数 条件或循环语句赋值表达式。 例 sl_send_reply(“404”, “Not found”); exit; 表达 式 表达式是语句、变量、 函数和运算符。 例 if(!t_relay()) if($var(x)10) “sip:” $var(prefix) $rU “” $rd Config 预处理器指令 在构建执行之前评估预处理器指令 tree 的 在 ‘understand’ 配置文件内容之前。它们需要一个 End of-line 以便正确识别 例如 。\n#!else\n#!endif\n include_file include_file “path_to_file” 在解析之前将文件的内容包含在 config 中。path_to_file 必须是 static 字符串。包含文件作在启动时完成。如果 更改包含文件的内容必须重新启动 SIP 服务器生效。 path_to_file可以是相对的也可以是绝对的。如果不是绝对的 path 的 PATH 中首先尝试的是相对于当前目录进行定位而 如果失败则相对于包含它的文件的目录。有 没有限制可以使用 include 或可以包含 - 任何部分 的配置文件是 OK 的。深度最多包含 10 个 否则您可以根据需要使用任意数量的 include。报告 cfg File Syntax Errors 现在打印文件名以便于故障排除。 如果未找到包含的文件则配置文件解析器会引发错误。 您可以在日志记录目标中找到此错误消息通常在 系统日志记录 文件。 You can use also the syntax #!include_file or !!include_file. Example of usage: request_route { … include_file “/etc/kamailio/checks.cfg” … } /etc/kamailio/checks.cfg: if (!mf_process_maxfwd_header(“10”)) { sl_send_reply(“483”,“Too Many Hops”); exit; } import_file import_file “path_to_file” Similar to , but does not throw error if the included file is not found.include_file define 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. Available directives: NAME - define a keyword NAME VALUE - define a keyword with value NAME - check if a keyword is defined #!ifndef - check if a keyword is not defined #!ifexp - check if an expression is true (see corresponding section for more) #!else - switch to false branch of region (needs after it to be detected)ifdef/ifndef/#!ifexpEoL #!endif - end region (needs after it to be detected)ifdef/ifndef/#!ifexpEoL #!trydef - add a define if not already defined #!redefine - force redefinition even if already defined Predefined keywords: KAMAILIO_X[_Y[_Z]] - Kamailio versions MOD_X - when module has been loadedX KAMAILIO_VERSION - associated with a number representation of Kamailio version (e.g., for version , the value is , representing X.Y.ZX00Y00ZX1000000 Y1000 Z) OS_NAME - associated with a string representing the Operating System name Examples: KAMAILIO_5 KAMAILIO_5_6 KAMAILIO_5_6_2 MOD_acc MOD_corex See for full list.kamctl rpc core.ppdefines_full Among benefits: easy way to enable/disable features (e.g., see default cfg – controlling support of nat traversal, presence, etc…) switch control for parts where conditional statements were not possible (e.g., global parameters, module settings) 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, say testbed and production, controlled just by one define to switch between the two modes: … #!define TESTBED_MODE #!ifdef TESTBED_MODE debug5 log_stderroryes listen192.168.1.1 #!else debug2 log_stderrorno listen10.0.0.1 #!endif … #!ifdef TESTBED_MODE modparam(“acc|auth_db|usrloc”, “db_url”, “mysql://kamailio:kamailiorwlocalhost/kamailio_testbed”) #!else modparam(“acc|auth_db|usrloc”, “db_url”, “mysql://kamailio:kamailiorw10.0.0.2/kamailio_production”) #!endif … #!ifdef TESTBED_MODE route[DEBUG] { xlog(“SCRIPT: SIP $rm from: $fu to: $ru - srcip: $si”\n); } #!endif … request_route { #!ifdef TESTBED_MODE route(DEBUG); #!endif … } … you can define values for IDs #!define MYINT 123 #!define MYSTR “xyz” defined IDs are replaced at startup, during config parsing, e.g.,: $var(x) 100 MYINT; is interpreted as: $var(x) 100 123; you can have multi-line defined IDs #!define IDLOOP v a r ( i ) 0 ; w h i l e ( var(i) 0; \ while( var(i)0; while(var(i)5) { xlog(“ $var(i)\n”); $var(i) $var(i) 1; } then in routing block request_route { … IDLOOP … } number of allowed defines is now set to 256 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 and for the accurate inside-define position\CR 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. ifexp Evaluate an expression and if true, then enable first region, otherwise enable the region (if it exists).#!else The expression has to be till the end of the line (no support for multi-line yet). The evaluation is done using (which is embedded inside Kamailio code):snexpr https://github.com/miconda/snexpr Defined IDs can be used inside expressions with the following characteristics: if there is an associated value, then the value is used as a string, with the enclosing quotes being removed if there is no associated value, but the ID is defined, then the value (integer) is used (equivalent of 1true) if the ID is not defined, then the value is used (equivalent of 0false) The result of an expression is evaluated to: true if it is a number different than 0 false if it is number 0 true if it is a string with length greater than 0 false if it is an empty string (length is 0) Comparison operations between two strings are done using and it is considered:strcmp(s1, s2) s1 s2 - if the result of is negativestrcmp(s1, s2) s1 s2 - if the result of is strcmp(s1, s2)0 s1 s2 - if the result of is positivestrcmp(s1, s2) Operations between two values with different types are done by converting the second value (right operand) to the type of the first value (left operand). Examples: 1 “20” - converted to: 1 20 (result: 21) “1” 20 - converted to: “1” “20” (result: “120”) 4 “20” - converted to: 4 20 (result: false) “4” 20 - converted to: “4” “20” (result: true) Available Operators Arithmetic operations: addition subtraction multiplication / - division % - modulus (remainder) ** - power Bitwise operations - shift left shift right - and | - or ^ - xor (unary bitwise negation) Logical operations: - equal ! - not equal (different) - less than greater than - less than or equal to - greater than or equal to - and || - or ! - unary not String operations: concatenation Other operations: - assignment ( … ) - parenthesis to group parts of the expression , - comma (separates expressions or function parameters) ifexp examples #!ifexp KAMAILIO_VERSION 5006000 … #!else … #!endif #!ifexp MOD_xlog (OS_NAME “darwin”) … #!endif #!define WITH_NAT #!define WITH_RTPENGINE #!ifexp WITH_NAT WITH_RTPENGINE … #!endif #!ifexp WITH_RTPENGINE || WITH_RTPPROXY … #!endif defexp Preprocessor directive to define an ID to the value of an expression. #!defenv ID STM The evaluation of is done using , see the section for for more details about how the expression can be built, what data types and operators are supported.STMsnexpr#!ifexp Examples: #!define IPADDR 127.0.0.1 #!defexp SIPURI “sip:” IPADDR “:5060” #!defexp QSIPURI ‘sip:’ IPADDR ‘:5060’ #!defexp V16 14 defexps Preprocessor directive similar to , but the the result being enclosed in double quotes, suitable to be used for string values.#!defexp defenv Preprocessor directive to define an ID to the value of an environment variable with the name ENVVAR. #!defenv IDENVVAR It can also be just $!defenv ENVVAR and the defined ID is the ENVVAR name. Example: #!defenv SHELL If environment variable $SHELL is ‘/bin/bash’, then it is like: #!define SHELL /bin/bash Full expression variant: #!defenv ENVSHELLSHELL Then it is like: #!define ENVSHELL /bin/bash It is a simplified alternative of using #!substdef with $env(NAME) in the replacement part. defenvs Similar to #!defenv, but the value is defined in between double quotes to make it convenient to be used as a string token. #!defenvs ENVVAR #!defenvs IDENVVAR trydefenv #!trydefenv IDENVVAR Similar to defenv, but will not error if the environmental variable is not set. This allows for boolean defines via system ENVVARs. For example, using an environmental variable to toggle loading of db_mysql: #!trydefenv WITH_MYSQL #!ifdef WITH_MYSQL loadmodule “db_mysql.so” #!ifdef trydefenvs Similar to #!trydefenv, but the value is defined in between double quotes to make it convenient to be used as a string token. #!trydefenvs ENVVAR #!trydefenvs IDENVVAR subst 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.,: #!subst “/regexp/subst/flags” flags is optional and can be: ‘i’ - ignore case; ‘g’ - global replacement Example: #!subst “/DBPASSWD/xyz/” modparam(“acc”, “db_url”, “mysql://user:DBPASSWDlocalhost/db”) will do the substitution of db password in db_url parameter value substdef #!substdef “/ID/subst/” Similar to , but in addition it adds a .#!substID subst substdefs #!substdefs “/ID/subst/” Similar to , but in addition it adds a (note the difference from that the value for define is enclosed in double quotes, useful when the define is used in a place for a string value).#!substID “subst”#!substdef Core Keywords Keywords specific to SIP messages which can be used mainly in expressions.if af The address family of the received SIP message. It is INET if the message was received over IPv4 or INET6 if the message was received over IPv6. Exampe of usage: if (afINET6) {log(Message received over IPv6 link\n); }dst_ip 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. Example of usage: if(dst_ip127.0.0.1) { log(“message received on loopback interface\n”); }; dst_port 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. Example of usage: if(dst_port5061) { log(“message was received on port 5061\n”); }; from_uri This script variable is a reference to the URI of ‘From’ header. It can be used to test ‘From’- header URI value. Example of usage: if(is_method(INVITE) from_uri~.*kamailio.org) {log(the caller is from kamailio.org\n); };method The variable is a reference to the SIP method of the message. Example of usage: if(methodREGISTER) {log(this SIP request is a REGISTER message\n); };msg:len The variable is a reference to the size of the message. It can be used in ‘if’ constructs to test message’s size. Example of usage: if(msg:len2048) {sl_send_reply(413, message too large);exit; };. proto This variable can be used to test the transport protocol of the SIP message. Example of usage: if(protoUDP) {log(SIP message received over UDP\n); };status If used in onreply_route, this variable is a referece to the status code of the reply. If it used in a standard route block, the variable is a reference to the status of the last reply sent out for the current request. Example of usage: if(status200) {log(this is a 200 OK reply\n); };snd_af snd_ip snd_port snd_proto src_ip Reference to source IP address of the SIP message. Example of usage: if(src_ip127.0.0.1) {log(the message was sent from localhost!\n); };src_port Reference to source port of the SIP message (from which port the message was sent by previous hop). Example of usage: if(src_port5061) {log(message sent from port 5061\n); }to_ip to_port to_uri This variable can be used to test the value of URI from To header. Example of usage: if(to_uri~“sip:.kamailio.org”) { log(“this is a request for kamailio.org users\n”); }; uri This variable can be used to test the value of the request URI. Example of usage: if(uri~sip:.kamailio.org) {log(this is a request for kamailio.org users\n); };Core Values Values that can be used in ’ expressions to check against Core Keywords’if INET Variant: IPv4 This keyword can be used to test whether the SIP packet was received over an IPv4 connection. Example of usage: if (afINET) {log(the SIP message was received over IPv4\n); }INET6 Variant: IPv6 This keyword can be used to test whether the SIP packet was received over an IPv6 connection. Example of usage: if(afINET6) { log(“the SIP message was received over IPv6\n”); }; SCTP This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over SCTP or not. Example of usage: if(protoSCTP) { log(“the SIP message was received over SCTP\n”); }; TCP This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over TCP or not. Example of usage: if(protoTCP) { log(“the SIP message was received over TCP\n”); }; TLS This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over TLS or not. Example of usage: if(protoTLS) { log(“the SIP message was received over TLS\n”); }; UDP This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over UDP or not. Example of usage: if(protoUDP) { log(“the SIP message was received over UDP\n”); }; WS This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over WS or not. Example of usage: if(protoWS) { log(“the SIP message was received over WS\n”); }; WSS This keyword can be used to test the value of ‘proto’ and check whether the SIP packet was received over WSS or not. Example of usage: if(protoWSS) { log(“the SIP message was received over WSS\n”); }; max_len Note: This command was removed. myself 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. 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. See “alias” to add hostnames, IP addresses and aliases to the list. Example of usage: if(urimyself) {log(the request is for local processing\n); };Note: You can also use the is_myself() function. Core parameters advertised_address 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. WARNING: don’t set it unless you know what you are doing (e.g. nat traversal)you can set anything here, no check is made (e.g. foo.bar will be accepted even if foo.bar doesn’t exist) Example of usage: advertised_address​1.2.3.4​ advertised_address“kamailio.org” Note: this option may be deprecated and removed in the near future, it is recommended to set advertise option for listen parameter. advertised_port The port advertised in Via header. If empty or not set (default value) the port from where the message will be sent is used. Same warnings as for ‘advertised_address’. Example of usage: advertised_port5080 Note: this option may be deprecated and removed in the near future, it is recommended to set advertise option for listen parameter. alias Alias name: domain 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 ‘myself’ is checked. It is necessary to include the port (the port value used in the “port” or “listen” defintions) in the alias definition otherwise the loose_route() function will not work as expected for local forwards. Even if you do not use ‘myself’ explicitly (for example if you use the domain module), it is often necessary to set the alias as these aliases are used by the loose_routing function and might be needed to handle requests with pre-loaded route set correctly. Example of usage: aliasother.domain.com:5060 aliasanother.domain.com:5060 domainnew.domain.com:5060 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 Specify how many child processes (workers) to create for asynchronous execution in the group “default”. These are processes that can receive tasks from various components (e.g, modules such as async, acc, sqlops) and execute them locally, which is different process than the task sender. Default: 0 (asynchronous framework is disabled). Example: async_workers4 async_nonblock Set the non-block mode for the internal sockets used by default group of async workers. Default: 0 Example: async_nonblock1 async_usleep Set the number of microseconds to sleep before trying to receive next task (can be useful when async_nonblock1). Default: 0 Example: async_usleep100 async_workers_group Define groups of asynchronous worker processes. Prototype: async_workers_group“nameX;workersN;nonblock[0|1];usleepM” The attributes are: name - the group name (used by functions such as sworker_task(name)) workers - the number of processes to create for this group nonblock - set or not set the non-block flag for internal communication socket usleep - the number of microseconds to sleep before trying to receive next task (can be useful if nonblock1) Default: “”. Example: async_workers_group“namereg;workers4;nonblock0;usleep0” If the name is default, then it overwrites the value set by async_workers. See also and module.event_route[core:pre-routing]sworker async_tkv_evcb Set the name of the event route or KEMI callback for processing tkv. 默认值‘’ 空字符串 例 async_tkv_evcb “core:tkv” … async_tkv_evcb “ksr_core_tkv” async_tkv_gname 设置用于处理 TKV 事件的异步组的名称。这 async group 必须定义。 默认值‘’ 空字符串 例 async_workers_group“nametkv;workers1;nonblock0;usleep0” async_tkv_gname “tkv” auto_aliases 别名auto_domains 默认情况下Kamailio 会发现所有接口上的所有 IPv4 地址并且 对这些地址执行反向 DNS 查找以查找主机名。 发现的主机名将添加到 aliases 列表中与 myself 条件匹配。要禁用主机名自动发现请关闭 auto_aliases。 例 auto_aliasesno auto_domainsno auto_bind_ipv6 开启后Kamailio 会自动绑定所有 IPv6 地址 很像 IPv4 的默认行为。 默认值为 。0 例 auto_bind_ipv61 bind_ipv6_link_local 如果设置为 则尝试通过发现 IPv6 链接本地地址 接口的范围。如果设置为 则跳过绑定链接本地地址。12 注意对于 UDP 套接字首先实现要为其他协议添加。 默认值为 。0 例 bind_ipv6_link_local1 check_via 检查回复最顶部的地址是否为本地地址。默认值 为 0选中已禁用。 用法示例 check_via1 孩子 UDP 接口要分叉的子项数每个接口一组 interface - ipport 的 IP 端口。默认值为 8。例如如果您配置 代理监听 3 个 UDP 端口它将创建 3xchildren 进程 处理传入的 UDP 消息。 有关 TCP/TLS 工作线程的配置请参阅选项 “tcp_children”。 用法示例 children16 chroot 该值必须是系统中的有效路径。如果设置Kamailio 将 chroot 更改根目录 设置为其值。 用法示例 chroot/other/fakeroot corelog 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. Default value is ().-1L_ERR Example of usage: corelog1 debug 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 #log_stderror parameter). The following log levels are defined: L_ALERT -5 L_BUG -4 L_CRIT2 -3 L_CRIT -2 L_ERR -1 L_WARN 0 L_NOTICE 1 L_INFO 2 L_DBG 3 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 (debug0) Examples of usage: debug3: 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) debug0: This will only log warning, errors and more critical messages. debug-6: This will disable all log messages. Value of ‘debug’ parameter can also be obtained and set dynamically using the ‘debug’ Core MI function or the RPC function, e.g.: kamcmd cfg.get core debug kamcmd cfg.set_now_int core debug 2 kamcmd cfg.set_now_int core debug – -1 Note: There is a difference in log-levels between Kamailio 3.x and Kamailio1.5: Up to Kamailio 1.5 the log level started with 4, whereas in Kamailio3 the log level starts with 3. Thus, if you were using debug3 in older Kamailio, now use debug2. For configuration of logging of the memory manager see the parameters #memlog and #memdbg. Further information can also be found at: https://www.kamailio.org/wiki/tutorials/3.2.x/syslog description Alias name: descr desc This is a keyword that can be used when declaring custom global parameters to specify their text description. See the section .Custom Global Parameters disable_core_dump Can be ‘yes’ or ‘no’. By default core dump limits are set to unlimited or a high enough value. Set this config variable to ‘yes’ to disable core dump-ing (will set core limits to 0). Default value is .no Example of usage: disable_core_dumpyes disable_tls Alias name: tls_disable Global parameter to disable TLS support in the SIP server. Default value is ‘yes’. Note: Make sure to load the “tls” module to get tls functionality. Example of usage: disable_tlsyes 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://kamailio.org/docs/modules/devel/modules/tls.html enable_tls Alias name: tls_enable Reverse Meaning of the disable_tls parameter. See disable_tls parameter. enable_tlsyes # 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. exit_timeout seconds flags SIP message (transaction) flags can have string names. The name for flags cannot be used for branch or script flags(*) … flags FLAG_ONE : 1, FLAG_TWO : 2; … NOTE: 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 #!define (which is also valid for branch/script flags): #!define FLAG_NAME FLAG_BIT force_rport Value: / (default yesnono) Similar to the force_rport() function, but activates symmetric response routing globally. fork If set to ‘yes’ the proxy will fork and run in daemon mode - one process will be created for each network interface the proxy listens to and for each protocol (TCP/UDP), multiplied with the value of ‘children’ parameter. When set to ‘no’, the proxy will stay bound to the terminal and runs as single process. First interface is used for listening to. This is equivalent to setting the server option “-F”. Default value is ‘yes’. Example of usage: forkno fork_delay Number of usecs to wait before forking a process. Default is 0 (don’t wait). Example of usage: fork_delay5000 group Alias name: gid The group id to run Kamailio. Example of usage: group“kamailio” http_reply_parse Alias: http_reply_hack When enabled, Kamailio can parse HTTP replies, but does so by treating them as SIP replies. When not enabled HTTP replies cannot be parsed. This was previously a compile-time option, now it is run-time. Default value is ‘no’. Example of usage: http_reply_parseyes ip_free_bind Alias: ipfreebind, ip_nonlocal_bind Control if Kamailio should attempt to bind to non local ip. This option is the per-socket equivalent of the system ip_nonlocal_bind. Default is 0 (do not bind to non local ip). Example of usage: ip_free_bind 1 ipv6_hex_style Can be set to , or to specify if locally computed string representation of IPv6 addresses should be expanded lowercase, expanded uppercase or compacted lowercase hexa digits.aAc Default is (compacted lower hexa digits, conforming better with RFC 5952).c A is preserving the behaviour before this global parameter was introduced, while enables the ability to follow some of the recommendations of RFC 5952, section 4.3.a Example of usage: ipv6_hex_style “a” kemi.onsend_route_callback Set the name of callback function in the KEMI script to be executed as the equivalent of block (from the native configuration file).onsend_route Default value: ksr_onsend_route Set it to empty string or to skip execution of this callback function.none Example: kemi.onsend_route_callback“ksr_my_onsend_route” kemi.received_route_callback Set the name of callback function in the KEMI script to be executed as the equivalent of block (from the native configuration file). For execution, it also require to have the received_route_mode global parameter set to 1.event_route[core:msg-received] Default value: none Set it to empty string or to skip execution of this callback function.none Example: kemi.received_route_callback“ksr_my_receieved_route” kemi.reply_route_callback Set the name of callback function in the KEMI script to be executed as the equivalent of block (from the native configuration file).reply_route Default value: ksr_reply_route Set it to empty string or to skip execution of this callback function.none Example: kemi.reply_route_callback“ksr_my_reply_route” kemi.pre_routing_callback Set the name of callback function in the KEMI script to be executed as the equivalent of block (from the native configuration file).event_route[core:pre-routing] Default value: none Set it to empty string or to skip execution of this callback function.none Example: kemi.pre_routing_callback“ksr_pre_routing” 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 ().3L_DBG Example: latency_cfg_log2 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 name when it is a module function, as well as internal action id. Default value is (disabled).0 latency_limit_action500 latency_limit_db Limit of latency in us (micro-seconds) for db operations. If a db operation executed via DB API v1 takes longer that its value, a message is printed in the logs, showing the first 50 characters of the db query. Default value is (disabled).0 latency_limit_db500 latency_log Log level to print the messages related to latency. Default value is ().-1L_ERR latency_log3 listen Set the network addresses the SIP server should listen to. It can be an , or or combination of (e.g., ). This parameter can be set multiple times in same configuration file, the server is listening on all addresses specified.IP addresshostnamenetwork interface idprotocol:address:portudp:10.10.10.10:5060 Example of usage: listen10.10.10.10 listeneth1:5062 listenudp:10.10.10.10:5064If you omit this directive then the SIP server will listen on all network 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 If you specify IPv6 addresses, you should put them into square brackets, e.g.: listenudp:[2a02:1850:1:1::18]:5060You can specify an advertise address (like ) per listening socket, it will be used to build the SIP headers such as Via and Record-Route:ip:port listenudp:10.10.10.10:5060 advertise 11.11.11.11:5060The advertise address must be in the format , the protocol is taken from the bind socket. The advertise address is a convenient alternative to / config parameters or / config functions.address:portadvertised_addressadvertised_portset_advertised_address()set_advertised_port() A typical use case for advertise address is when running SIP server behind a NAT/Firewall, when the local IP address (to be used for bind) is different than the public IP address (to be used for advertising). 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 keyword.name listenudp:10.0.0.10:5060 name s1 listenudp:10.10.10.10:5060 advertise 11.11.11.11:5060 name s2 listenudp:10.10.10.20:5060 advertise mysipdomain.com name s3 listenudp:10.10.10.30:5060 advertise mysipdomain.com name s4 ... $fsn s4; t_relay();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. As of 5.6, there is now a keyword which can be added to the end of each listen directive. This can be used in combination with any other keyword, but must be added at the end of the line.virtual listenudp:10.1.1.1:5060 virtual listenudp:10.0.0.10:5060 name s1 virtual listenudp:10.10.10.10:5060 advertise 11.11.11.11:5060 virtual listenudp:10.10.10.20:5060 advertise mysipdomain.com name s3 virtualThe keyword is meant for use in situations where you have a floating/virtual IP address on your system that may not always be active on the system. It is particularly useful for active/active virtual IP situations, where otherwise things like usrloc PATH support can break due to incorrect results.virtualcheck_self This identifier will change the behaviour of how , or matches against traffic destined to this IP address. By default, Kamailio always considers traffic destined to a listen IP as regardless of if the IP is currently locally active. With this flag set, Kamailio will do an extra check to make sure the IP is currently a local IP address before considering the traffic as local.myselfis_myself()check_selflocal This means that if Kamailio is listening on an IP that is not currently local, it will recognise that, and can relay the traffic to another Kamailio node as needed, instead of thinking it always needs to handle the traffic. loadmodule Loads a module for later usage in the configuration script. The module is searched in the path specified by (or ).loadpathmpath Prototypes: loadmodule “modulepath” loadmodule(“modulepath”) loadmodule(“modulepath”, “opts”) If is only or , then Kamailio will try to search also for , very useful when using directly the version compiled in the source tree.modulepathmodulenamemodulename.somodulename/modulename.so The parameter is a list of characters that can specify loading options. They can be:opts g (or ) - open the module shared object file with set, which can be used for modules related to external scripting languages to avoid reloading.GRTLD_GLOBAL Example of usage: loadpath /usr/local/lib/kamailio/:usr/local/lib/kamailio/modules/loadmodule /usr/local/lib/kamailio/modules/db_mysql.so loadmodule modules/usrloc.so loadmodule tm loadmodule dialplan.so loadmodule(app_lua.so, g)loadmodulex Similar to with the ability to evaluate variables in its parameter.loadmodule loadpath Alias name: mpath Set the module search path. takes a list of directories separated by . The list is searched in-order. For each directory , and are tried.loadpath:d d / d/ d/{module_name}.so d / d/ d/{module_name}/${module_name}.so This can be used to simplify the loadmodule parameter and can include many paths separated by colon. First module found is used. Example of usage: loadpath /usr/local/lib/kamailio/modules:/usr/local/lib/kamailio/mymodulesloadmodule mysql loadmodule uri loadmodule uri_db loadmodule sl loadmodule tmThe proxy tries to find the modules in a smart way, e.g: tries to find in the loadpath, but also .loadmodule uriuri.souri/uri.so local_rport Similar to add_local_rport() function, but done in a global scope, so the function does not have to be executed for each request. Default: off Example: local_rport on log_engine_data Set specific data required by the log engine. See also the log_engine_type. 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. log_engine_type“udp” log_engine_data“127.0.0.1:9” log_facility If Kamailio logs to syslog, you can control the facility for logging. Very useful when you want to divert all Kamailio logs to a different log file. See the man page syslog(3) for more details. For more see: https://www.kamailio.org/dokuwiki/doku.php/tutorials:debug-syslog-messages Default value is LOG_DAEMON. Example of usage: log_facilityLOG_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. log_name“kamailio-proxy-5080” log_prefix Specify the text to be prefixed to the log messages printed by Kamailio while processing a SIP message (that is, when executing route blocks). It can contain script variables that are evaluated at runtime. See #log_prefix_mode about when/how evaluation is done. 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. Example - prefix with message type (1 - request, 2 - response), CSeq and Call-ID: log_prefix{$mt $hdr(CSeq) $ci} log_prefix_mode Control if log prefix is re-evaluated. 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. If set to 1, then the log prefix is evaluated before/after each config action (needs to be set when the log_prefix has variables that are different based on the context of config execution, e.g., $cfg(line)). Example: log_prefix_mode1 log_stderror With this parameter you can make Kamailio to write log and debug messages to standard error. Possible values are: yes - write the messages to standard error no - write the messages to syslog Default value is .no For more see: https://www.kamailio.org/dokuwiki/doku.php/tutorials:debug-syslog-messages Example of usage: log_stderroryes cfgengine Set the config interpreter engine for execution of the routing logic inside the configuration file. Default is the native interpreter. Example of usage: cfgengine“name” cfgengine “name” If name is or , it expects to have in native config interpreter for routing logic.nativedefault The name can be the identifier of an embedded language interpreter, such as which is registered by the module:luaapp_lua cfgengine “lua” maxbuffer The size in bytes multiplied by 2 not to be exceeded during the auto-probing procedure of discovering and increasing the maximum OS buffer size for receiving UDP messages (socket option SO_RCVBUF). Default value is 262144. Example of usage: maxbuffer65536 Note: it is not the size of the internal SIP message receive buffer. maxsndbuffer The size in bytes multiplied by 2 not to be exceeded during the auto-probing procedure of discovering and increasing the maximum OS buffer size for sending UDP messages (socket option SO_SNDBUF). Default value is 262144. Example of usage: maxsndbuffer65536 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 30. Default value: 12 Example of usage: max_branches16 max_recursive_level The parameters set the value of maximum recursive calls to blocks of actions, such as sub-routes or chained IF-ELSE (for the ELSE branches). Default is 256. Example of usage: max_recursive_level500 max_while_loops The parameters set the value of maximum loops that can be done within a “while”. Comes as a protection to avoid infinite loops in config file execution. Default is 100. Setting to 0 disables the protection (you will still get a warning when you start Kamailio if you do something like while(1) {…}). Example of usage: max_while_loops200 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“eth1” listenudp:224.0.1.75:5060 mcast_loopback It can be ‘yes’ or ‘no’. If set to ‘yes’, multicast datagram are sent over loopback. Default value is ‘no’. Example of usage: mcast_loopbackyes mcast_ttl Set the value for multicast ttl. Default value is OS specific (usually 1). Example of usage: mcast_ttl32 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 (memdbg3) For example, memdbg2 means that memory debugging is activated if the debug level is 2 or higher. debug3 # no memory debugging as debug level memdbg4 # is lower than memdbg debug3 # memory debugging is active as the debug level memdbg2 # is higher or equal memdbg 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 (memlog3) For example, memlog2 means that memory statistics dumping is activated if the debug level is 2 or higher. debug3 # no memory statistics as debug level memlog4 # is lower than memlog debug3 # dumping of memory statistics is active as the memlog2 # debug level is higher or equal memlog Please see also #memdbg and #debug. mem_add_size Size in bytes to be added for each chunk allocated by the internal (quick malloc) memory manager. It could be useful in cases when external libraries initialized to use expose issues of buffer overflow.qmqm It can be set via config reload framework. Default is 0. mem_add_size4 mem_join If set to 1, memory manager (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). mem_join1 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: kamctl rpc cfg.set_now_int core mem_join 1 To disable, set its value to 0. mem_safety If set to , memory free operation does not call 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 to generate a core file.1abort()abort() It can be set via config reload framework. Default is (enabled).1 mem_safety0 mem_status_mode If set to , memory status dump for allocator will print details about used fragments. If set to , the dump contains only free fragments. It can be set at runtime via cfg param framework (e.g., via ).1qm0kamcmd Default is .0 mem_status_mode1 mem_summary Parameter to control printing of memory debugging information displayed on or . The value can be composed by following flags:exitSIGUSR1 1 - dump all the pkg used blocks (status) 2 - dump all the shm used blocks (status) 4 - summary of pkg used blocks 8 - summary of shm used blocks 16 - short status If set to , nothing is printed.0 Default value: 12 Example: mem_summary15 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, the incoming socket will be used or the first one for a different protocol, disregarding the destination location. When activated, Kamailio will select a socket that can reach the destination (to be able to connect to the remote address). (Kamailio opens a UDP socket to the destination, then it retrieves the local IP which was assigned by the operating system to the new UDP socket. Then this socket will be closed and the retrieved IP address will be used as IP address in the Via/Record-Route headers) Example of usage: mhomed1 mlock_pages Locks all Kamailio pages into memory making it unswappable (in general one doesn’t want his SIP proxy swapped out ) mlock_pages yes |no (default no) 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_delay100000 modparam The modparam command will be used to set the options (parameters) for the loaded modules. Prototypes: modparam(“modname”, “paramname”, intval) modparam(“modname”, “paramname”, “strval”) The first pameter is the name of the module or a list of module names separated by (pipe). Actually, the is enclosed in beteen and and matched with the names of the loaded modules using POSIX regexp operation. For example, when is given, then the module name is matched with ; when is given, then the module name is matched with . While using only between the names of the modules is recommended for clarity, any value that can construct a valid regular expression can be used. Note also that throws error only when no module name is matched and no parameter is set. If the list of modules in includes a wrong name, Kamailio starts. For example setting to does not result in a startup error if module is loaded. Be also careful with expressions than can match more module names than wanted, for example setting to can result in matching all module names that include either or .|modname()$auth^(auth)$acc|auth(acc|auth)$|modparammodnamemodnamemsilo|notamodulemsilomodnamea|bab The second parameter of is the name of the module parameter.modparam The third parameter of has to be either an interger or a string value, a matter of what the module parameter expects, as documented in the README of the module.modparam Example: modparam(“usrloc”, “db_mode”, 2) modparam(“usrloc”, “nat_bflag”, 6) modparam(“auth_db|msilo|usrloc”, “db_url”, “mysql://kamailio:kamailiorwlocalhost/kamailio”) See the documenation of the respective module to find out the available options. modparamx Similar to modparam, with ability to evaluate the variables in its parameters. msg_recv_max_size Set the maximum size in bytes of a SIP message to be accepted by Kamailio. Default: 32767 (2^15 - 1) Example: msg_recv_max_size 10000 onsend_route_reply If set to 1 (yes, on), onsend_route block is executed for received replies that are sent out. Default is 0. onsend_route_replyyes 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, is on most systems). “Files” include network sockets, so you need one for every concurrent session (especially if you use connection-oriented transports, like TCP/TLS).1024 Example of usage: open_files_limit2048 phone2tel By enabling this feature, Kamailio internally treats SIP URIs with userphone parameter as TEL URIs. If you do not want this behavior, you have to turn it off. Default value: (enabled)1 phone2tel 0 pmtu_discovery If set to 1, the don’t-fragment (DF) bit will be set in outbound IP packets, but no fragmentation from the kernel will be done for IPv4 and IPv6. This means that packets might be dropped and it is up to the user to reduce the packet size and try again. If set to 2, the kernel will will fragment a packet if needed according to the path MTU, or will set the don’t-fragment flag otherwise. For IPv6 the kernel will fragment a packet if needed according to the path MTU. The kernel keeps track of the path MTU per destination host. The default is 0, do not set the don’t-fragment bit or fragment packets for IPv4 and IPv6. pmtu_discovery 0 | 1 | 2 (default 0) port The port the SIP server listens to. The default value for it is 5060. Example of usage: port5080 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_size2048 pv_buffer_slots The number of internal buffer slots to print dynamic strings with pseudo-variables inside. The default value is 10. Example of usage: pv_buffer_slots12 pv_cache_limit The limit how many pv declarations in the cache after which an action is taken. Default value is 2048. pv_cache_limit1024 pv_cache_action Specify what action to be done when the size of pv cache is exceeded. If , print a warning log message when the limit is exceeded. If , warning log messages is printed and the cache systems tries to drop a declaration. Default is .01$sht(…)0 pv_cache_action1 rpc_exec_delta Specify the time interval (in seconds) required to wait before executing again an RPC command exported with the flag . Practically it enables an execution rate limit for such command. The rate limiting is per RPC command.RPC_EXEC_DELTA Such RPC commands can be those related to reload of data records or config options from backends such as database or hard drive. For them, executing the RPC command too ofter can result in compromizing the internal structures (e.g., previous reload of data was not finished when next reload is triggered). Default value: (no rate limiting)0 Example: rpc_exec_delta5 rundir Alias: run_dir Set the folder for creating runtime files such as MI fifo or CTL unixsocket. Default: /var/run/kamailio Example of usage: rundir“/tmp” received_route_mode Enable or disable the execution of routing block or its corresponding Kemi callback.event_route[core:msg-received] Default value: (disabled)0 Example of usage: received_route_mode1 reply_to_via If it is set to 1, any local reply is sent to the IP address advertised in top most Via of the request instead of the IP address from which the request was received. Default value is 0 (off). Example of usage: reply_to_via0 route_locks_size Set the number of mutex locks to be used for synchronizing the execution of config script for messages sharing the same . In other words, enables Kamailio to execute the config script sequentially for the requests and replies received within the same dialog – a new message received within the same dialog waits until the previous one is routed out.Call-Id For smaller impact on parallel processing, its value it should be at least twice the number of Kamailio processes (all children processes). Example: route_locks_size 256 Note that ordering of the SIP messages can still be changed by network transmission (quite likely for UDP, especially on long distance paths) or CPU allocation for processes when executing pre-config and post-config tasks (very low chance, but not to be ruled out completely). server_id A configurable unique server id that can be used to discriminate server instances within a cluster of servers when all other information, such as IP addresses are the same. 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 of usage: server_header“Server: My Super SIP Server” server_signature This parameter controls the “Server” header in any locally generated message. Example of usage: server_signatureno If it is enabled (defaultyes) a header is generated as in the following example: Server: Kamailio ( (/)) shm_force_alloc Tries to pre-fault all the shared memory, before starting. When “on”, start time will increase, but combined with mlock_pages will guarantee Kamailio will get all its memory from the beginning (no more kswapd slow downs) shm_force_alloc yes | no (default no) shm_mem_size Set shared memory size (in Mb). shm_mem_size 64 (default 64) sip_parser_log Log level for printing debug messages for some of the SIP parsing errors. Default: 0 (L_WARN) sip_parser_log 1 sip_parser_mode Control sip parser behaviour. If set to , the parser is more strict in accepting messages that have invalid headers (e.g., duplicate To or From). It can make the system safer, but loses the flexibility to be able to fix invalid messages with config operations.1 If set to , the parser is less strict on checking validity of headers.0 Default: 1 sip_parser_mode 0 sip_warning (noisy feedback) Can be or . If set to (default value is ) a ‘Warning’ header is added to each reply generated by Kamailio. 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.0110 Example of usage: sip_warning0 socket Specify an address to listen (bind) to, a simplified alternative to paramter that allows specifying the attributes using a structure style.listen Prototype: socket { attr1 value1; … attrN valueN; } The attributes are: bind - the address to listen on in format or [proto:]address[:port][proto:]address[:port1-port2] advertise - the address to advertise in SIP headers in format address[:port] name - name of the socket to be referenced in configuration file agname - async (action) group name where to push SIP messages received using multi-threaded mode virtual - set to to indicate if the IP has to be considered virtual or notyes/no The attribute is mandatory and has to provide at list the address to listen on.bind Example: socket { bind udp:10.10.10.10:5060; advertise 11.11.11.11:5060; name “s0”; virtual yes; } The above is the equivalent of: listenudp:10.10.10.10:5060 advertise 11.11.11.11:5060 name “s0” virtual When attribute is set to , then Kamailio binds to a range of ports from to (the start and end ports are inclusive). If socket is provided in this case, then the port is appended, becoming for each of the sockets created in the port range. If is also provided, then a corresponding range of ports is used for advertised addresses, although only the start port for advertise has to be provided.bind[proto:]address[:port1-port2]port1port2name[name][port]advertise If the following definition is provided:socket socket { bind udp:10.10.10.10:5060-5068; advertise 11.11.11.11:5060; name “s0p”; virtual yes; } The first bind socket in rage is the equivalent of: socket { bind udp:10.10.10.10:5060; advertise 11.11.11.11:5060; name “s0p5060”; virtual yes; } And the last one is: socket { bind udp:10.10.10.10:5068; advertise 11.11.11.11:5068; name “s0p5068”; virtual yes; } 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, tcp_children and sctp_children are used as usually. Example for udp sockets: children4 socket_workers2 listenudp:127.0.0.1:5080 listenudp:127.0.0.1:5070 listenudp:127.0.0.1:5060 it will start 2 workers to handle traffic on udp:127.0.0.1:5080 and 4 for each of udp:127.0.0.1:5070 and udp:127.0.0.1:5060. In total there are 10 worker processes Example for tcp sockets: children4 socket_workers2 listentcp:127.0.0.1:5080 listentcp:127.0.0.1:5070 listentcp:127.0.0.1:5060 it will start 2 workers to handle traffic on tcp:127.0.0.1:5080 and 4 to handle traffic on both tcp:127.0.0.1:5070 and tcp:127.0.0.1:5060. In total there are 6 worker processes 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_size131070 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 “statistics” module. The statistics counters are read/updated either automatically by Kamailio internally (e.g. tcp counters), by the script writer via the module functions of the “statistics” module, by the script writer using the pseudo variable (read-only), or via MI commands.$stat() Following are some examples how to access statistics variables: script: modparam(“statistics”, “variable”, “NOTIFY”) (if method “NOTIFY”) { update_stat(“NOTIFY”, “1”); } xlog(“Number of received NOTIFYs: $stat(NOTIFY)”); RPC: get counter value kamctl rpc stats.get_statistics NOTIFY set counter to zero kamctl rpc stats.reset_statistics NOTIFY get counter value and then set it to zero kamctl rpc stats.clear_statistics NOTIFY or use the kamcmd tool kamcmd stats.get_statistics 1xx_replies stats_name_separator Specify the character used as a separator for the internal statistics’ names. Default value is ._ 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: tosIPTOS_LOWDELAY tos0x10 tosIPTOS_RELIABILITY udp_mtu Fallback to another protocol ( must be set also either globally or per packet) if the constructed request size is greater than udp_mtu.udp_mtu_try_proto RFC 3261 specified size: . Default: (off).13000 udp_mtu number udp_mtu_try_proto If and udp forwarded request size (after adding all the “local” headers) , use this protocol instead of udp. Only the Via header will be updated (e.g. The Record-Route will be the one built for udp).udp_mtu ! 0 udp_mtu Warning: Although RFC3261 mandates automatic transport protocol changing, enabling this feature can lead to problems with clients which do not support other protocols or are behind a firewall or NAT. Use this only when you know what you do! See also function.udp_mtu_try_proto(proto) Default: (). Recommended: .UDPoffTCP udp_mtu_try_proto TCP|TLS|SCTP|UDP udp_receiver_mode Specify how UDP traffic is received, either via a pool of processes per UDP socket or a single multi-threaded process with a thread per socket. Default value is (pool of processes defined by , old-style behaviour).0children Value switches to multi-threaded process receiver for all UDP sockets. SIP messages are pushed to async tasks group, sending is still done by any of processes.1udp async_workers_group“nameudp;workers8” udp_receiver_mode 1 Value allows to define sockets that can be groupped to a specific async tasks group by providing the to definition. These sockets use the multi-threaded receiver style. The sockets without set use the old-style multi-process receivers.2agnamesocketagname async_workers_group“nameudp507x;workers8” async_workers_group“nameudp5080;workers8” udp_receiver_mode 2 // multi-process UDP receiving socket { bind udp:10.10.10.10:5060; advertise 11.11.11.11:5060; name “s5060”; } // multi-threaded UDP receiving socket { bind udp:10.10.10.10:5070; name “s5070”; agname “udp507x”; } // multi-threaded UDP receiving socket { bind udp:10.10.10.10:5072; name “s5072”; agname “udp507x”; } // multi-threaded UDP receiving socket { bind udp:10.10.10.10:5080; advertise 11.11.11.11:5080; name “s5080”; agname “udp5080”; } uri_host_extra_chars Specify additional chars that should be allowed in the host part of URI. uri_host_extra_chars “_” user Alias name: uid The user id to run Kamailio (Kamailio will suid to it). Example of usage: userkamailiouser_agent_header Set the value of User-Agent header for requests generated by Kamailio. It must contain header name as well, but not the ending CRLF. user_agent_header“User-Agent: My Super SIP Server” verbose_startup Control if printing routing tree and udp probing buffer debug messages should be printed at startup. Default is 0 (don’t print); set to 1 to get those debug messages. Example of usage: verbose_startup1 version_table 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 “version”. Example of usage: version_table“version44” wait_worker1_mode Enable waiting for child SIP worker one to complete initialization, then create the other child worker processes. Default: 0 (do not wait for child worker one to complete initialization). Example: wait_worker1_mode 1 wait_worker1_time How long to wait for child worker one to complete the initialization. In micro-seconds. Default: 4000000 (micro-seconds 4 seconds). Example: wait_worker1_time 1000000 wait_worker1_usleep Waiting for child worker one to complete the initialization is done in a loop, which loop waits until wait_worker1_time passes. This parameter specifies how long after each iteration of that loop to wait in micro-seconds. Default: 100000 (micro-seconds 0.1 seconds). Example: wait_worker1_usleep 50000 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: wdir“/usr/local/kamailio” or wdir/usr/kamwd xavp_via_params Set the name of the XAVP of which subfields will be added as local -header parameters.Via If not set, to header parameter manipulation is not applied (default behaviour).XAVPVia If set, local header gets additional parameters from defined . Core flag needs to be set¹.ViaXAVPFL_ADD_XAVP_VIA_PARAMS Example: xavp_via_params“via” [1] See function from “corex” module.via_add_xavp_params() xavp_via_fields Set the name of xavp from where to take Via header field: address and port. Use them to build local Via header. Example: xavp_via_fields“customvia” request_route { … $xavp(customviaaddress) “1.2.3.4”; $xavp(customvia[0]port) “5080”; # must be string via_use_xavp_fields(“1”); t_relay(); } See function from “corex” module.via_use_xavp_fields() xavp_via_reply_params Set the name of the XAVP of which subfields will be added as header parameters to the top of the replies sent out.Via If not set, to header parameter manipulation is not applied (default behaviour).XAVPVia If set, top header of the to-be-sent reply gets additional parameters from defined . Core flag needs to be set¹.ViaXAVPFL_ADD_XAVP_VIA_REPLY PARAMS Example: xavp_via_reply_params“viarpl” [1] See function from “corex” module.via_reply_vadd_xavp_params() DNS Parameters Note: See also file for details about Kamailio’s DNS client.doc/tutorials/dns.txt Kamailio has an internal DNS resolver with caching capabilities. If this caching resolver is activated (default setting) then the system’s stub resolver won’t be used. Thus, also local name resolution configuration like entries will not be used. If the DNS cache is deactivated (), then system’s resolver will be used. The DNS failover functionality in the tm module references directly records in the DNS cache (which saves a lot of memory) and hence DNS based failover only works if the internal DNS cache is enabled./etc/hostsuse_dns_cacheno DNS resolver comparison internal resolver system resolver Caching of resolved records yes no* NAPTR/SRV lookups with correct weighting yes yes DNS based failover yes no Of course you can use the resolving name servers configured in as caching nameservers./etc/resolv.conf If the internal resolver/cache is enabled you can add/remove records by hand (using kamcmd or xmlrpc) using the DNS RPCs, e.g. dns.add_a, dns.add_srv, dns.delete_a a.s.o. For more info on DNS RPCs see: https://www.kamailio.org/docs/docbooks/devel/rpc_list/rpc_list.html#dns.add_a Note: During startup of Kamailio, before the internal resolver is loaded, the system resolver will be used (it will be used for queries done from module register functions or modparams fixups, but not for queries done from or normal fixups).mod_init() Note: The dns cache uses the DNS servers configured on your server (), therefore even if you use the internal resolver you should have a working DNS resolving configuration on your server./etc/resolv.conf Kamailio also allows you to finetune the DNS resolver settings. The maximum time a dns request can take (before failing) is (if is yes, multiply it again by ; if and lookups are enabled, it can take even longer!):dns_try_ipv62SRVNAPTR (dns_retr_time*(dns_retr_no1)dns_servers_no)(search_list_domains) Note: During DNS lookups, the process which performs the DNS lookup blocks. To minimize the blocked time the following parameters can be used (max 2s): dns_try_ipv6no dns_retr_time1 dns_retr_no1 dns_use_search_listno dns 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 parameter to the Via is necessary. Note that Vias containing DNS names (instead of IPs) should have added, so turning dns to yes is not recommended.receivedsrc_ipreceived Default is .no rev_dns Alias name: dns_rev_via 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 parameter to the Via is necessary (if the Via contains a DNS name instead of an IP address, the result of the reverse dns on the source IP will be compared with the DNS name in the Via). 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 added, so turning rev_dns to yes is not recommended.receivedsrc_ipreceived Default is .no dns_cache_del_nonexp Alias name: dns_cache_delete_nonexpired dns_cache_del_nonexp yes | no (default: no) 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. dns_cache_rec_pref dns_cache_rec_pref number (default 0) dns cache record preference, determines how new DNS records are stored internally in relation to existing entries. Possible values: 0 - do not check duplicates 1 - prefer old records 2 - prefer new records 3 - prefer records with longer lifetime 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’t listen on any ipv6 address. 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. dns_cache_gc_interval Interval in seconds after which the dns cache is garbage collected (default: 120 s) dns_cache_gc_interval number dns_cache_init If off, the dns cache is not initialized at startup and cannot be enabled at runtime, this saves some memory. dns_cache_init on | off (default on) dns_cache_max_ttl dns_cache_max_ttl time in seconds (default MAXINT) dns_cache_mem Maximum memory used for the dns cache in KB (default 500 K) dns_cache_mem number dns_cache_min_ttl dns_cache_min_ttl time in seconds (default 0) dns_cache_negative_ttl Tells how long to keep negative DNS responses in cache. If set to 0, disables caching of negative responses. Default is 60 (seconds). dns_naptr_ignore_rfc If the DNS lookup should ignore the remote side’s protocol preferences, as indicated by the Order field in the NAPTR records and mandated by RFC 2915. dns_naptr_ignore_rfc yes | no (default yes) dns_retr_no Number of dns retransmissions before giving up. Default value is system specific, depends also on the ‘/etc/resolv.conf’ content (usually 4). Example of usage: dns_retr_no3 dns_retr_time Time in seconds before retrying a dns request. Default value is system specific, depends also on the ‘/etc/resolv.conf’ content (usually 5s). Example of usage: dns_retr_time3 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) dns_search_full_match yes | no (default yes) dns_servers_no How many dns servers from the ones defined in ‘/etc/resolv.conf’ will be used. Default value is to use all of them. Example of usage: dns_servers_no2 dns_srv_lb Alias name: dns_srv_loadbalancing Enable dns srv weight based load balancing (see doc/tutorials/dns.txt) dns_srv_lb yes | no (default no) dns_try_ipv6 Can be ‘yes’ or ‘no’. If it is set to ‘yes’ and a DNS lookup fails, it will retry it for ipv6 (AAAA record). Default value is ‘no’. Note: If dns_try_ipv6 is off, no hostname resolving that would result in an ipv6 address would succeed - it doesn’t matter if an actual DNS lookup is to be performed or the host is already an ip address. Thus, if the proxy should forward requests to IPv6 targets, this option must be turned on! Example of usage: dns_try_ipv6yes dns_try_naptr Enable NAPTR support according to RFC 3263 (see doc/tutorials/dns.txt for more info) dns_try_naptr yes | no (default no) dns_sctp_pref, dns_tcp_pref, dns_tls_pref, dns_udp_pref Alias name: dns_sctp_preference, dns_tcp_preference, dns_tls_preference, dns_udp_preference Set preference for each protocol when doing naptr lookups. By default dns_udp_pref30, dns_tcp_pref20, dns_tls_pref10 and dns_sctp_pref20. To use the remote site preferences set all dns_*_pref to the same positive value (e.g. dns_udp_pref1, dns_tcp_pref1, dns_tls_pref1, dns_sctp_pref1). To completely ignore NAPTR records for a specific protocol, set the corresponding protocol preference to -1 (or any other negative number). (see doc/tutorials/dns.txt for more info) dns_{udp,tcp,tls,sctp}_pref number dns_use_search_list Can be ‘yes’ or ‘no’. If set to ‘no’, the search list in ‘/etc/resolv.conf’ will be ignored ( fewer lookups gives up faster). Default value is ‘yes’. HINT: even if you don’t have a search list defined, setting this option to ‘no’ will still be “faster”, because an empty search list is in fact search “” (so even if the search list is empty/missing there will still be 2 dns queries, eg. foo‘.’ and foo“”‘.’) Example of usage: dns_use_search_listno use_dns_cache Alias name: dns_use_cache 告知 DNS 响应是否已缓存 - 这意味着内部 DNS resolver 而不是系统的存根解析器。如果设置为 “off”禁用 DNS 响应的缓存作为副作用禁用 DNS 故障转移。默认值为 “on”。也可以在运行时更改设置 从 internal 切换到 System Resolver然后再切换回来。 use_dns_failover 别名dns_use_failover use_dns_failover on | off (default off) 如果 和 发送请求失败由于不允许从 发送失败、已列入阻止列表的目标或者在使用 TM 时邀请超时和 destination 解析为多个 IP 地址和/或多条记录则发送 将使用下一个 IP/记录重试。如果新分支将是 为每次新的发送尝试创建。ononsend_routeSRVtm TCP 参数 以下参数允许调整 TCP 行为。 disable_tcp 用于在 SIP 服务器中禁用 TCP 支持的全局参数。默认值 是。no 用法示例 disable_tcpyes tcp_accept_aliases 如果通过 tcp 连接接收的邮件在通过新的 将为邮件来源的连接创建 TCP 别名端口 别名端口将设置为 Via 端口。 基于 但仅使用端口 主机别名很危险涉及额外的 DNS 查找并且需要 他们是值得怀疑的draft-ietf-sip-connect-reuse-00.txt 有关更多详细信息请参阅。force_tcp_alias 注意对于 TCP 客户端的 NAT 遍历最好不要使用 tcp_accept_aliases但只需使用 nathelper 模块和函数。fix_nated_contact|register 默认值为no (off) tcp_accept_aliases yes|no tcp_accept_haproxy 启用内部 TCP 堆栈以期望 PROXY-protocol-format header 作为 Connection 的第一条消息。既是人类可读的 支持协议的 v1 和二进制编码 v2 变体。 如果您在 TCP 负载均衡器后面此选项通常很有用。 例如 HAProxy 或 AWS 的 ELB并允许负载均衡器提供 有关上游客户端的连接信息。这将启用 使用基于 IP 的 ACL即使在负载均衡器后面也是如此。 请注意启用此选项将拒绝任何入站 TCP 不符合 PROXY-protocol 规范的连接。 供参考 - PROXY 协议 https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt 默认值为 no。 tcp_accept_haproxyyes tcp_accept_hep3 启用内部 TCP 接收堆栈以接受 HEP3 数据包。此选项 必须在充当 Homer 的 Kamailio 实例上设置为 yes SIPCapture 服务器该服务器应该通过 TCP/TLS 接收 HEP3 数据包。 默认值为 no。 tcp_accept_hep3yes tcp_accept_iplimit 为来自同一 IP 地址的接受连接设置限制。 违约。1024 tcp_accept_iplimit32 可以将其设置为 或负值 以禁用此限制。0 tcp_accept_no_cl 控制在没有 Content-Length 时是否抛出错误 通过 TCP 接收的请求的标头。对于通过 HTTP/1.1 发送的 XCAP 流量需要将其设置为 yes该流量不使用 Content-Length 标头但将大型 body 拆分为多个块。这 然后可以使用 module sanity 将此权限限制为 HTTP 仅流量在 Route Block 中进行测试以保持 RFC3261 合规性 关于通过 TCP 的 SIP 请求的此强制标头。 默认值为 no。 tcp_accept_no_clyes tcp_accept_unique 如果设置为 则拒绝来自同一源 IP 的重复连接并且 港口。1 默认设置为 .0 tcp_accept_unique 1 tcp_async Alias name: tcp_buf_write If enabled, all the tcp writes that would block / wait for connect to finish, will be queued and attempted latter (see also and ).tcp_conn_wq_maxtcp_wq_max Note: It also applies for TLS. tcp_async yes | no (default yes) tcp_check_timer Set the check interval (in seconds) for tcp connections. It is used to check if there was any data received on new connections or if the receiving of SIP messages takes too long. See also and .tcp_msg_data_timeouttcp_msg_read_timeout Default half of or value depending on which one is smaller and not zero or 0 if both are zerotcp_msg_data_timeouttcp_msg_read_timeout tcp_check_timer5 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 “children” parameter) will be used. Example of usage: tcp_children4 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 (don’t clone), set it to for cloning.01 Example of usage: tcp_clone_rcvbuf1 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 . Setting this value to 0 will close the TCP connection pretty quick.120 Note: As many SIP clients are behind NAT/Firewalls, the SIP proxy should not close the TCP connection as it is not capable of opening a new one. Example of usage: tcp_connection_lifetime3605 tcp_connection_match If set to , try to be more strict in matching outbound TCP connections, attempting to lookup first the connection using also local port, not only the local IP and remote IPport.1 Default is .0 tcp_connection_match1 tcp_connect_timeout 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. Example of usage: tcp_connect_timeout5 tcp_conn_wq_max 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. tcp_conn_wq_max bytes (default 32 K) tcp_crlf_ping Enable SIP outbound TCP keep-alive using PING-PONG (CRLFCRLF - CRLF). tcp_crlf_ping yes | no default: yes tcp_defer_accept Tcp accepts will be delayed until some data is received (improves performance on proxies with lots of opened tcp connections). See linux or freebsd . For now linux and freebsd only.tcp(7)TCP_DEFER_ACCEPTACCF_DATA(0) WARNING: the linux is buggy () and doesn’t work exactly as expected (if no data is received it will retransmit syn acks for , irrespective of the set timeout and then it will silently drop the connection without sending a RST or FIN). Try to use it together with tcp_syncnt (this way the number of retrans. SYNACKs can be limited the timeout can be controlled in some way).TCP_DEFER_ACCEPT2.6.23~ 190 s On FreeBSD: tcp_defer_accept yes | no (default no) On Linux: tcp_defer_accept number of seconds before timeout (default disabled) 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. tcp_delayed_ack yes | no (default yes when supported) tcp_fd_cache 如果启用用于发送的 FD 将缓存在进程内 调用 tcp_send通过 TCP 发送的性能提升但代价是 连接关闭速度稍慢额外的 FD 保持打开状态 tcp_fd_cache yes | no (default yes) tcp_keepalive 为 tcp 启用 keepalive设置SO_KEEPALIVE套接字选项 tcp_keepalive yes | no (default yes) tcp_keepcnt 断开连接之前发送的 keepalive 数 TCP_KEEPCNT socket 选项。仅限 Linux。 tcp_keepcnt number (not set by default) tcp_keepidle 如果连接处于空闲状态则开始发送 keepalive 之前的时间 TCP_KEEPIDLE 插槽选项。仅限 Linux。 tcp_keepidle seconds (not set by default) tcp_keepintvl keepalive 探测之间的时间间隔当上一个探测失败时 TCP_KEEPINTVL 插槽选项。仅限 Linux。 tcp_keepintvl seconds (not set by default) tcp_linger2 处于 FIN_WAIT2 状态的孤立套接字的生存期覆盖 tcp_fin_timeout请参阅 Linux TCP7 TCP_LINGER2。仅限 Linux。 tcp_linger2 seconds (not set by default) tcp_max_connections 最大 tcp 连接数如果超过该数量则无新 tcp 将接受连接。默认值在 tcp_init.h 中定义 #define DEFAULT_TCP_MAX_CONNECTIONS 2048 用法示例 tcp_max_connections4096 tcp_msg_data_timeout 在新 tcp 上接收到数据之前等待多长时间的持续时间以秒为单位 连接。默认 20。 tcp_msg_data_timeout10 tcp_msg_read_timeout 在新 tcp 上接收到数据之前等待多长时间的持续时间以秒为单位 连接。默认 20。 tcp_msg_read_timeout10 tcp_no_connect 通过将 tcp_no_connect 设置为 是的。 您可以随时执行此作即使 Kamailio 已经启动在 本例使用命令 “kamcmd cfg.set_now_int TCP no_connect 1”。 tcp_poll_method 使用的轮询方法默认情况下当前作系统的最佳方法是 selected 。有关可用类型请参阅 io_wait.c 和 poll_types.h none 轮询、epoll_lt、epoll_et、sigio_rt、select、kqueue、/dev/poll 用法示例 tcp_poll_methodselect tcp_rd_buf_size 用于 tcp 读取的缓冲区大小。高缓冲区大小可提高性能 在连接很少且流量很大的服务器上而且 增加内存消耗因此对于大量连接最好使用 低值。另请注意此值限制了最大消息大小 SIP HTTP 的 TCP 请求。 该值在内部限制为 16MByte对于更高的值请重新编译 在 tcp_options.c 中具有更高限制的 Kamailio 搜索 “rd_buf_size” 和 16777216。此外您可能需要增加私有内存并且 如果您处理消息 Stateful则可能还必须增加 共享内存。 默认值4096可以在运行时更改。 tcp_rd_buf_size65536 tcp_reuse_port 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 as an UAC. Kamailio must have been compiled in a system implementing SO_REUSEPORT (Linux 3.9.0, FreeBSD, OpenBSD, NetBSD, MacOSX). This parameter takes effect only if also the system on which Kamailio is running on supports SO_REUSEPORT. tcp_reuse_port yes (default no) tcp_script_mode Specify if connection should be closed (set to CONN_ERROR) if processing the received message results in error (that can also be due to negative return code from a configuration script main route block). If set to 1, the processing continues with the connection open. Default (close connection)0 tcp_script_mode 1 tcp_send_timeout 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. Example of usage: tcp_send_timeout3 tcp_source_ipv4, tcp_source_ipv6 Set the source IP for all outbound TCP connections. If setting of the IP fails, the TCP connection will use the default IP address. tcp_source_ipv4 IPv4 address tcp_source_ipv6 IPv6 address tcp_syncnt Number of SYN retransmissions before aborting a connect attempt (see linux tcp(7) TCP_SYNCNT). Linux only. tcp_syncnt number of syn retr. (default not set) tcp_wait_data Specify how long to wait (in milliseconds) to wait for data on tcp connections in certain cases. Now applies when reading on tcp connection for haproxy protocol. Default: 5000ms (5secs) tcp_wait_data 10000 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 than 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). Default: (), can be changed at runtime.2100~ 2 INVITEs tcp_wq_max Maximum bytes queued for write allowed globally. It has no effect if tcp_buf_write is not enabled. tcp_wq_max bytes (default 10 Mb) TLS Parameters Most of TLS layer attributes can be configured via TLS module parameters. tls_port_no The port the SIP server listens to for TLS connections. Default value is .5061 Example of usage: tls_port_no6061 tls_max_connections Maximum number of TLS connections (if the number is exceeded no new TLS connections will be accepted). It cannot exceed tcp_max_connections. Default value is .2048 Example of usage: tls_max_connections4096 tls_threads_mode Control how to initialize the internal multi-threading system that impacts libssl 3.x. Values: 0 - no thread-specific initialization/execution (default) 1 - for each function that might initialize OpenSSL, run it in a temporary thread; this leaves the thread-local variables in rank 0, main thread at their default value of 0x0 2 - use at-fork handler to set thread-local variables to 0x0; the implementation will set thread-local keys from 0-15 to have value 0x0. tls_threads_mode 2 With libssl v3.x, the recommended value for production is . For development/troubleshooting, value can be used.21 SCTP Parameters disable_sctp Global parameter to disable SCTP support in the SIP server. See also .enable_sctp Default value is .auto Example of usage: disable_sctpyes enable_sctp enable_sctp 0/1/2 - SCTP disabled (0)/ SCTP enabled (1)/auto (2), default 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: s). Can be changed at runtime, but it will affect only new associations. E.g.:180 kamcmd cfg.seti sctp autoclose 120 sctp_autoclose seconds sctp_send_ttl Number of milliseconds before an unsent message/chunk is dropped (default: ms or s). Can be changed at runtime, e.g.:3200032 kamcmd cfg.seti 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, if the sctp stack did give up sending it (it’s not related to sctp protocol level retransmission). Useful to improve reliability with peers that reboot/restart or fail over to another machine. WARNING: use with care and low values (e.g. 1-3) to avoid “multiplying” traffic to unresponding hosts (default: 0). Can be changed at runtime. sctp_send_retries 1 sctp_assoc_tracking Controls whether or not sctp associations are tracked inside Kamailio. Turning it off would result in less memory being used and slightly better performance, but it will also disable some other features that depend on it (e.g. ). Default: yes.sctp_assoc_reuse Can be changed at runtime (“kamcmd sctp assoc_tracking 0”), but changes will be allowed only if all the other features that depend on it are turned off (for example it can be turned off only if first was turned off).sctp_assoc_reuse Note: turning 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.sctp_assoc_tracking Config options depending on being on: .sctp_assoc_trackingsctp_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: . Depends on being on.yessctp_assoc_tracking Note that even if turned off, if the port in via corresponds to the source port of the association the request was sent on or if rport is turned on ( or via containing a rport option), the association will be automatically reused by the sctp stack. Can be changed at runtime (sctp assoc_reuse), but it can be turned on only if is on.force_rport()sctp_assoc_tracking 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 the maximum associations number is exceeded and a new associations is opened by a remote host, the association will be immediately closed. However it is possible that some SIP packets get through (especially if they are sent early, as part of the 4-way handshake).kamcmd cfg.seti sctp max_assocs 10 When Kamailio tries to open a new association and the max_assocs is exceeded the exact behaviour depends on whether or not 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 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_assoc_trackingsctp_assoc_tracking 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 ) but it will affect only new associations.srto_initial sctp_srto_initial milliseconds sctp_srto_max Maximum value of the retransmission timeout (RTO) (default: OS specific). WARNING: values lower than the sctp will cause lots of retransmissions and connection instability (see sctp_srto_min for more details).sack_delay Can be changed at runtime (sctp ) but it will affect only new associations.srto_max sctp_srto_max milliseconds sctp_srto_min Minimum value of the retransmission timeout (RTO) (default: OS specific). WARNING: values lower than the sctp of any peer might cause retransmissions and possible interoperability problems. According to the standard the should be between 200 and 500 ms, so avoid trying values lower than 500 ms unless you control all the possible sctp peers and you do make sure their is higher or their sack_freq is 1.sack_delaysack_delaysack_delay Can be changed at runtime (sctp ) but it will affect only new associations.srto_min sctp_srto_min milliseconds sctp_asocmaxrxt Maximum retransmissions attempts per association (default: OS specific). It should be set to no. of expected paths.sctp_pathmaxrxt* Can be changed at runtime (sctp asocmaxrxt) but it will affect only new associations. sctp_asocmaxrxt number 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 a packet. Default: OS specific. WARNING: a value higher than srto_min can cause a lot of retransmissions (and strange problems). A value higher than srto_max will result in very high connections instability. According to the standard the value should be between 200 and 500 ms.sack_delay Can be changed at runtime (sctp ) but it will affect only new associations.sack_delay sctp_sack_delay milliseconds sctp_sack_freq Number of packets received before an ACK is sent (without waiting for the to expire). Default: OS specific.sack_delay Note: on linux with 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).lksctp Can be changed at runtime (sctp ) but it will affect only new associations.sack_freq 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 ) but it will affect only new associations.max_burst 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: - disabled (default), - enabled, auto.01-1 In “auto” mode it will be enabled if possible (sr started as root or with ). can be used on Linux and FreeBSD. For other BSDs and Darwin one must compile with . On Linux one should also set if the MTU on any network interface that could be used for sending is smaller than .CAP_NET_RAWudp4_raw-DUSE_RAW_SOCKSudp4_raw_mtu1500 The parameter can be set at runtime as long as sr was started with enough privileges ().core.udp4_raw udp4_raw on udp4_raw_mtu MTU value used for UDP IPv4 packets when udp4_raw is enabled. It should be set to the minimum MTU of all the network interfaces that could be used for sending. The default value is 1500. Note that on BSDs it does not need to be set (if set it will be ignored, the proper MTU will be used automatically by the kernel). On Linux it should be set. The parameter can be set at runtime ().core.udp4_raw_mtu udp4_raw_ttl TTL value used for UDP IPv4 packets when udp4_raw is enabled. By default it is set to auto mode (), meaning that the same TTL will be used as for normal UDP sockets.-1 The parameter can be set at runtime ().core.udp4_raw_ttl Blocklist Parameters dst_blocklist_expire Alias name: dst_blocklist_ttl How much time a blocklisted destination will be kept in the blocklist (w/o any update). dst_blocklist_expire time in s (default 60 s) dst_blocklist_gc_interval How often the garbage collection will run (eliminating old, expired entries). dst_blocklist_gc_interval time in s (default 60 s) dst_blocklist_init If off, the blocklist is not initialized at startup and cannot be enabled at runtime, this saves some memory. dst_blocklist_init on | off (default on) dst_blocklist_mem Maximum shared memory amount used for keeping the blocklisted destinations. dst_blocklist_mem size in Kb (default 250 Kb) use_dst_blocklist Enable the destination blocklist: Each failed send attempt will cause the destination to be added to the blocklist. Before any send, this blocklist will be checked and if a match is found, the send is no longer attempted (an error is returned immediately). Note: using the blocklist incurs a small performance penalty. See also .doc/dst_blocklist.txt use_dst_blocklist on | off (default off) Real-Time Parameters real_time Sets real time priority for all the Kamailio processes, or the timers (bitmask). Possible values: 0 - off 1 - the “fast” timer 2 - the “slow” timer 4 - all processes, except the timers Example: everything switched to real time priority.real_time 7 real_time (flags) (default off) rt_policy Real time scheduling policy, , and 0 SCHED_OTHER1 SCHED_RR2SCHED_FIFO rt_policy 0…3 (default 0) rt_prio Real time priority used for everything except the timers, if is enabled.real_time rt_prio (default 0) rt_timer1_policy Alias name: rt_ftimer_policy Like but for the “fast” timer.rt_policy rt_timer1_policy0…3 (default 0) rt_timer1_prio Alias name: rt_fast_timer_prio, rt_ftimer_prio Like but for the “fast” timer process (if ).rt_prioreal_time 1 rt_timer1_prio (default 0) rt_timer2_policy Alias name: rt_stimer_policy Like but for the “slow” timer.rt_policy rt_timer2_policy0…3 (default 0) rt_timer2_prio Alias name: rt_stimer_prio Like but for the “slow” timer.rt_prio rt_timer2_prio (default 0) 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 of usage: add_local_rport(); avpflags break ‘break’ statement can be used to end a ‘case’ block in a ‘switch’ statement or exit from a ‘while’ statement. drop Stop the execution of the configuration script and alter the implicit action which is done afterwards. If the function is called in a ‘branch_route’ then the branch is discarded (implicit action for ‘branch_route’ is to forward the request). If the function is called in the default ‘onreply_route’ then you can drop any response. If the function is called in a named ‘onreply_route’ (transaction stateful) then any provisional reply is discarded. (Implicit action for ‘onreply_route’ is to send the reply upstream according to Via header.) Example of usage: onreply_route { if(status“200”) { drop(); # this works } } onreply_route[FOOBAR] { if(status“200”) { drop(); # this is ignored } } exit 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. request_route { if (route(ABC)) { xlog(“L_NOTICE”,“method $rm is INVITE\n”); } else { xlog(“L_NOTICE”,“method is $rm\n”); } } route[ABC] { if (is_method(“INVITE”)) { return(1); } else if (is_method(“REGISTER”)) { return(-1); } else if (is_method(“MESSAGE”)) { sl_send_reply(“403”,“IM not allowed”); exit; } } error error(“p1”, “p2”); Not properly implemented yet - prints a log messages with the two string parameters. exec Basic implementation of executing an external application with C function. Look also at the functions exported by module.system()exec exec(“/path/to/app”); force_rport() The adds the rport parameter to the first Via header of the received message. Thus, Kamailio will add the received port to the top most Via header in the SIP message, even if the client does not indicate support for rport. This enables subsequent SIP messages to return to the proper port later on in a SIP transaction.force_rport() This is useful for NAT traversal, to enforce symmetric response signaling. The rport parameter is defined in RFC 3581. Note: there is also a parameter which changes the global behavior of the SIP proxy.force_rport Example of usage: 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 directive). If the protocol doesn’t match (e.g. UDP message “forced” to a TCP socket) the closest socket of the same protocol is used.listen This function does not support pseudo-variables, use the function from the corex module instead.set_send_socket() Example of usage: force_send_socket(10.10.10.10:5060); force_send_socket(udp:10.10.10.10:5060); force_tcp_alias Alias name: add_tcp_alias force_tcp_alias(port) adds a tcp port alias for the current connection (if tcp). Useful if you want to send all the traffic 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 “aliased” connection is closed (e.g. it’s idle for too much time), all the port aliases are removed. forward Forward in stateless mode the SIP request to destination address set in or . d u du duru Example of usage: $du “sip:10.0.0.10:5060;transporttcp”; forward(); isavpflagset isflagset Test if a flag is set for current processed message (if the flag value is 1). The value of the parameter can be in range of 0…31. For more see: Kamailio - Flag Operations Example of usage: if(isflagset(3)) { log(“flag 3 is set\n”); }; Kamailio also supports named flags. They have to be declared at the beginning of the config file with: flags flag1_name[:position], flag2_name ...Example: flags test, a:1, b:2 ; request_route { setflag(test); if (isflagset(a)){ # equiv. to isflagset(1) … } resetflag(b); # equiv. to resetflag(2) is_int Checks if a pseudo variable argument contains integer value. if(is_int(“$avp(foobar)”)) { log(“foobar contains an integer\n”); } log Write text message to standard error terminal or syslog. You can specify the log level (the integer id) as first parameter. The parameters are static values. If you want dynamic parameters with variables, look at module.xlog For more see: https://www.kamailio.org/dokuwiki/doku.php/tutorials:debug-syslog-messages Example of usage: log(“just some text message\n”); log(1, “another text message\n”); prefix Add the string parameter in front of username in R-URI. Example of usage: prefix(“00”); 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 variable (which is same as or ). r e t c o d e retcode retcoderc$? return(0) is same as exit(); In logical evaluation expressions: Negative is FALSE Positive is TRUE If no value is specified, it returns 1. If return is used in the top level route is equivalent with exit . If no is at the end of the routing block, the return code is the value of the last executed action, therefore it is highly recommended to return an explicit value (e.g., ) to avoid unexpected config execution.[val]returnreturn(1) Example usage: request_route { if (route(RET)) { xlog(“L_NOTICE”,“method $rm is INVITE\n”); } else { xlog(“L_NOTICE”,“method $rm is REGISTER\n”); }; } route[RET] { if (is_method(“INVITE”)) { return(1); } else if (is_method(“REGISTER”)) { return(-1); } else { return(0); }; } IMPORTANT: do not compare route block or module function execution in a condition with the value of the return code. Next example is showing a wrong use: request_route { if (route(RET) -2) { xinfo(“return is -2\n”); } else { xinfo(“return is not -2\n”); ### THIS IS GOING TO BE EXECUTED } } route[RET] { return -2; } See also the FAQ for how the function return code is evaluated: Frequently Asked Questions Note: starting with version , this behaviour can be changed with global parameter.5.7.0-devreturn_mode return_mode Control the return code evaluation mode: 0 (default) - evaluation is like so far (negative is false, positive is true) 1 - propagate return value and evaluation has to be done with or , otherwise is evaluated to true no matter is negative or positive00value!0 revert_uri Set the R-URI to the value of the R-URI as it was when the request was received by server (undo all changes of R-URI). Example of usage: revert_uri();rewritehostport Alias name: sethostport, sethp Rewrite the domain part and port of the R-URI with the value of function’s parameter. Other parts of the R-URI like username and URI parameters remain unchanged. Example of usage: rewritehostport(1.2.3.4:5080);rewritehostporttrans Alias name: sethostporttrans, sethpt Rewrite the domain part and port of the R-URI with the value of function’s parameter. Also allows to specify the transport parameter. Other parts of the R-URI like username and URI parameters remain unchanged. Example of usage: rewritehostporttrans(“1.2.3.4:5080”); rewritehost Alias name: sethost, seth Rewrite the domain part of the R-URI with the value of function’s parameter. Other parts of the R-URI like username, port and URI parameters remain unchanged. Example of usage: rewritehost(“1.2.3.4”); rewriteport Alias name: setport, setp Rewrites/sets the port part of the R-URI with the value of function’s parameter. Example of usage: rewriteport(“5070”); rewriteuri Alias name: seturi Rewrite the request URI. Example of usage: rewriteuri(“sip:testkamailio.org”); rewriteuserpass Alias name: setuserpass, setup Rewrite the password part of the R-URI with the value of function’s parameter. Example of usage: rewriteuserpass(“my_secret_passwd”); rewriteuser Alias name: setuser, setu Rewrite the user part of the R-URI with the value of function’s parameter. Example of usage: rewriteuser(“newuser”); route() Execute route block given in parameter. Parameter may be name of the block or a string valued expression. Examples of usage: route(REGISTER_REQUEST); route(received.proto “proto” $var(route_set)); selval Select a value based on conditional expression. Prototype: selval(evalexpr, valexp1, valexpr2) This is a core statement that return the 2nd parameter if the 1st parameter is evaluated to true, or 3rd parameter if the 1st parameter is evaluated to false. It can be considered a core function that is equivalent of ternary condition/operator Example: v a r ( x ) s e l v a l ( var(x) selval( var(x)selval(Ts mod 2, “true/” $ru, “false/” $rd); The first parameter is a conditional expression, like those used for IF, the 2nd and 3rd parameters can be expressions like those used in the right side of assignments. set_advertised_address Same as but it affects only the current message. It has priority if is also set.advertised_addressadvertised_address Example of usage: set_advertised_address(“kamailio.org”); set_advertised_port Same as but it affects only the current message. It has priority over .advertised_portadvertised_port Example of usage: set_advertised_port(5080); set_forward_no_connect 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: 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). onreply_route[0] (stateless): equivalent to (it’s better to use though)set_reply_()set_reply_ onreply_route[!0] ™: ignored branch_route: affects the current branch only (all messages sent on this branch, like possible retransmissions and CANCELs). onsend_route: like branch 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 , but for replies to the current message (local generated replies and replies forwarded by tm). The behavior depends in which route block the function is called: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: affects the current reply (so the send_flags set in the will be used if the reply for which they were set is the winning final reply or it’s a provisional reply that is forwarded)onreply_route branch_route: ignored. onsend_route: ignored 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 repliesset_reply_no_connect();// do authentication and call routing...}set_reply_close Like , but closes the TCP connection after sending. Can be used in same route blocks as .set_reply_no_connectset_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(403,REGISTER first);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: Kamailio - Flag Operations 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 - - like global parameter but works on a per packet basis and not globally.TCP|TLS|SCTP|UDPudp_mtu_try_proto Example: if($rd“10.10.10.10”) udp_mtu_try_proto(SCTP); userphone Add parameter to R-URI.userphone Custom Global Parameters These are parameters that can be defined by the writer of kamailio.cfg in order to be used inside routing blocks. One of the important properties for custom global parameters is that their value can be changed at runtime via RPC commands, without restarting Kamailio. The definition of a custom global parameter must follow the pattern: group.variable value desc “description” The value can be a quoted string or integer number. Example: pstn.gw_ip “1.2.3.4” desc “PSTN GW Address” The custom global parameter can be accessed inside a routing block via: $sel(cfg_get.group.variable) Example: $ru “sip:” $rU “” $sel(cfg_get.pstn.gw_ip); Note: Some words cannot be used as (part of) names for custom variables or groups, and if they are used a syntax error is logged by kamailio. Among these keywords: “yes”, “true”, “on”, “enable”, “no”, “false”, “off”, “disable”, “udp”, “UDP”, “tcp”, “TCP”, “tls”, “TLS”, “sctp”, “SCTP”, “ws”, “WS”, “wss”, “WSS”, “inet”, “INET”, “inet6”, “INET6”, “sslv23”, “SSLv23”, “SSLV23”, “sslv2”, “SSLv2”, “SSLV2”, “sslv3”, “SSLv3”, “SSLV3”, “tlsv1”, “TLSv1”, “TLSV1” Routing Blocks 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 (or procedures) from common programming languages. A routing block is identified by a specific token, followed by a name in between square brackets and actions in between curly braces. route_block_id[NAME] { ACTIONS } The name can be any alphanumeric string, with specific routing blocks enforcing a particular format. IMPORTANT: Note: is equivalent to .route(number)route(“number”) Route blocks can be executed on network events (e.g., receiving a SIP message), timer events (e.g., retransmission timeout) or particular events specific to modules. There can be so called sub-route blocks, which can be invoked from another route blocks, like a function. Invocation is done with followed by the name of sub-route to execute, enclosed in between parentheses.route Example: request_route{ … route(“test”); … } route[“test”]{ … } request_route Request routing block - is executed for each SIP request. It contains a set of actions to be executed for SIP requests received from the network. It is the equivalent of function for handling the SIP requests.main() IMPORTANT: For backward compatibility reasons, the main request block can be identified by or .routeroute{…}route[0]{…} 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(), forward(), t_relay()) must be called inside the route block. Example of usage: request_route {if(is_method(OPTIONS)) {# send reply for each options requestsl_send_reply(200, ok);exit();}route(FWD); } route[FWD] {# forward according to uriforward(); }route block This block is used to define ‘sub-routes’ - group of actions that can be executed from another routing block. Originally targeted as being executed from ‘request_route’, it can be executed now from all the other blocks. Be sure you put there the actions valid for the root routing block executing the sub-route. The definition of the sub-route block follows the general rules, with a name in between square brackets and actions between curly braces. A sub-route can return an integer value back to the routing block that executed it. The return code can be retrieved via $rc variables. Evaluation of the return of a subroute is done with following rules: negative value is evaluated as false 0 - is interpreted as exit positive value is evaluated as true request_route { if(route(POSITIVE)) { xlog(“return number is positive\n”); } if( ! route(NEGATIVE)) { xlog(“return number is negative\n”); } if( route(ZERO)) { xlog(“this log message does not appear\n”); } } route[POSITIVE] { return 10; } route[NEGATIVE] { return -8; } route[ZERO] { return 0; } 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. The sub-route blocks allow to make the configuration file modular, simplifying the logic and helping to avoid duplication of actions. If no is at the end of the routing block, the return code is the value of the last executed action, therefore it is highly recommended to return an explicit value (e.g., ) to avoid unexpected config execution.returnreturn(1) branch_route Request’s branch routing block. It contains a set of actions to be taken for each branch of a SIP request. It is executed only by TM module after it was armed via .t_on_branch(“branch_route_index”) Example of usage: request_route {lookup(location);t_on_branch(OUT);if(!t_relay()) {sl_send_reply(500, relaying failed);} } branch_route[OUT] {if(uri~10\.10\.10\.10) {# discard branches that go to 10.10.10.10drop();} }failure_route Failed transaction routing block. It contains a set of actions to be taken each transaction that received only negative replies () for all branches. The is executed only by TM module after it was armed via .300failure_routet_on_failure(“failure_route_index”) Note that in is processed the request that initiated the transaction, not the reply .failure_route Example of usage: request_route {lookup(location);t_on_failure(TOVOICEMAIL);if(!t_relay()) {sl_send_reply(500, relaying failed);} } failure_route[TOVOICEMAIL] {if(is_method(INVITE)) {# call failed - relay to voice mailt_relay_to_udp(voicemail.server.com,5060);} }reply_route Main SIP response (reply) handling block - it contains a set of actions to be executed for SIP replies. It is executed for all replies received from the network. It does not have a name and it is executed by the core, before any other module handling the SIP reply. It is triggered only by SIP replies received on the network. 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: reply_route { if(status“128”) { drop; } } IMPORTANT: Note: In reply_route, if the last executed function fails, the SIP response processing is considered unsuccessful, and kamailio will not relay the reply. To ensure proper relay of the SIP response, make sure the last command in reply_route is either a successful function or a return statement. IMPORTANT: Note: for backward compatibility reasons, the main routing block can be also identified by or .replyonreply_route {…}onreply_route[0] {…} onreply_route SIP reply routing block executed by tm module. It contains a set of actions to be taken for SIP replies in the context of an active transaction. The must be armed for the SIP requests whose replies should be processed within it, via (“”).onreply_routet_on_replyonreply_route_index Core ‘reply_route’ block is executed before a possible tm ‘onreply_route’ block. request_route { lookup(“location”); t_on_reply(“LOGRPL”); if(!t_relay()) { sl_send_reply(“500”, “relaying failed”); } } reply_route { if(!t_check_trans()) { drop; } } onreply_route[LOGRPL] { if(status~“1[0-9][0-9]”) { log(“provisional response\n”); } } onsend_route The route is executed in when a SIP request is sent out. Only a limited number of commands are allowed (, all the checks, msg flag manipulations, , , ).dropifsend()log()textops::search() In this route the final destination of the message is available and can be checked (with , , , , , ).snd_ipsnd_portto_ipto_portsnd_protosnd_af This route is executed only when forwarding requests - it is not executed for replies, retransmissions, or locally generated messages (e.g. via fifo uac). Example: onsend_route { if(to_ip1.2.3.4 !isflagset(12)){ log(1, “message blocked\n”); drop; } } snd_ip, snd_port - behave like src_ip/src_port, but contain the ip/port Kamailio will use to send the message to_ip, to_port - like above, but contain the ip/port the message will be sent to (not to be confused with dst_ip/dst_port, which are the destination of the original received request: Kamailio’s ip and port on which the message was received) snd_proto, snd_af - behave like proto/af but contain the protocol/address family that Kamailio will use to send the message msg:len - when used in an onsend_route, msg:len will contain the length of the message on the wire (after all the changes in the script are applied, Vias are added a.s.o) and not the lentgh of the original message. event_route Generic type of route executed when specific events happen. Prototype: event_route[groupid:eventid] groupid - should be the name of the module that triggers the event eventid - some meaningful short text describing the event Core Event Routes Implementations: event_route[core:worker-one-init] - executed by core after the first udp sip worker process executed the child_init() for all modules, before starting to process sip traffic note that due to forking, other sip workers can get faster to listening for sip traffic event_route[core:worker-one-init] { xlog(“L_INFO”,“Hello world\n”); } event_route[core:msg-received] - executed when a message is received from the network. It runs with a faked request and makes available the $rcv(key) variables to access what was received and related attribtues. 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 event_route[core:msg-received] { xlog(“rcv on r c v ( a f ) / rcv(af)/ rcv(af)/rcv(proto): ( r c v ( l e n ) ) [ rcv(len)) [ rcv(len))[rcv(buf)] from [ r c v ( s r c i p ) : rcv(srcip): rcv(srcip):rcv(srcport)] to [ r c v ( r c v i p ) : rcv(rcvip): rcv(rcvip):rcv(rcvport)]\n”); if($rcv(srcip) “1.2.3.4”) { drop; } } event_route[core:pre-routing] - executed by core on receiving SIP traffic before running request_route or reply_route. if drop is used, then the message is not processed further with request_route or reply_route in the same process. This can be useful together with sworker module which can delegate the processing to another worker. async_workers_group“namereg;workers4” … event_route[core:pre-routing] { xinfo(“pre-routing rules\n”); if(is_method(“REGISTER”)) { # delegate processing of REGISTERs to a special group of workers if(sworker_task(“reg”)) { drop; } } } event_route[core:receive-parse-error] - executed by core on receiving a broken SIP message that can not be parsed. note that the SIP message is broken in this case, but it gets access to source and local socket addresses (ip, port, proto, af) as well as the whole message buffer and its size event_route[core:receive-parse-error] { xlog(“got a parsing error from s i : si: si:sp, message $mb\n”); } event_route[core:modinit-before] - executed by core before the module-init callbacks are run: event_route[core:modinit-before] { $shv(x) 0; } event_route[core:tkv] - executed by core for events emitted with a type-key-value (mostly for catching error cases): async_workers_group“nametkv;workers1;nonblock0;usleep0” async_tkv_gname “tkv” async_tkv_evcb “core:tkv” event_route[core:tkv] { xlog(“$atkv(type) / $atkv(key) / $atkv(val)\n”); } The event route is executed in an async worker process. 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:mod-init] - executed by htable module after all modules have been initialised. Good for initialising values in hash tables. modparam(“htable”, “htable”, “asize4;”) event_route[htable:mod-init] { $sht(acalls-to::10.10.10.10) 0; $sht(amax-calls-to::10.10.10.10) 100; } request_route { if(is_method(“INVITE”) !has_totag()) { switch($rd) { case “10.10.10.10”: lock(“calls-to::10.10.10.10”); $sht(acalls-to::10.10.10.10) s h t ( a c a l l s − t o : : 10.10.10.10 ) 1 ; u n l o c k ( c a l l s − t o : : 10.10.10.10 ) ; i f ( sht(acalls-to::10.10.10.10) 1; unlock(calls-to::10.10.10.10); if( sht(acalls−to::10.10.10.10)1;unlock(calls−to::10.10.10.10);if(sht(acalls-to::10.10.10.10)$sht(amax-calls-to::10.10.10.10)) { sl_send_reply(“500”, “To many calls to .10”); exit; } break; … } } } event_route[tm:local-request] - executed on locally generated requests. event_route [tm:local-request] { # Handle locally generated requests xlog(“L_INFO”, “Routing locally generated r m t o rm to rmtoru\n”); t_set_fr(10000, 10000); } event_route[tm:branch-failure] - executed on all failure responses. request_route { … t_on_branch_failure(“myroute”); t_relay(); } event_route[tm:branch-failure:myroute] { xlog(“L_INFO”, “Handling $T_reply_code response to r m t o rm to rmtoru\n”); if (t_check_status(“430”)) { # Outbound flow failed unregister(“location”, “ t u , tu, tu,T_reply_ruid”); if (t_next_contact_flow()) { t_relay(); } } } Compatibility Modes With the merge of source trees from and in 2008, there were some different behaviours in various module parameters and functions. To control the behaviour, the compatibility mode can be specified with or at the beginning (first line) of the configuration file.KamailioSER#!KAMAILIO#!SER The default mode is .#!KAMAILIO The parameters and functions that behave differently should have a note in their documentation. Note: the first line having is also used to set the file type by extenssions in editors like , , , or .#!KAMAILIOvimvscodeatommceditemacs Script Statements if IF-ELSE statement Prototype: if(expr) {actions; } else {actions; }The should be a valid logical expression.expr The logical operators that can be used in :expr : equal !: not equal ~: case-insensitive regular expression matching: Note: Posix regular expressions will be used, e.g. use instead of [[:digit:]]{3}\d\d\d !~: regular expression not-matching (NOT PORTED from Kamailio 1.x, use !(x ~ y)) : greater : greater or equal : less : less or equal : logical AND ||: logical OR !: logical NOT Example of usage: if(is_method(INVITE)){log(this sip message is an invite\n);} else {log(this sip message is not an invite\n);}See also the FAQ for how the function return code is evaluated: How is the function code evaluated switch SWITCH statement - it can be used to test the value of a pseudo-variable. NOTE: can be used only to mark the end of a branch (as it is in shell scripts).breakcase Example of usage: request_route {route(1);switch($retcode){case -1:log(process INVITE requests here\n);break;case 1:log(process REGISTER requests here\n);break;case 2:case 3:log(process SUBSCRIBE and NOTIFY requests here\n);break;default:log(process other requests here\n);}# switch of R-URI usernameswitch($rU){case 101:log(destination number is 101\n);break;case 102:log(destination number is 102\n);break;case 103:case 104:log(destination number is 103 or 104\n);break;# cases with starting slash are regular expressionscase /\49.*:log(destination number is germany\n);break;case /\33.*:log(destination number is france\n);break;default:log(unknown destination number\n);} }route[1] {if(is_method(INVITE)){return(-1);};if(is_method(REGISTER))return(1);}if(is_method(SUBSCRIBE))return(2);}if(is_method(NOTIFY))return(3);}return(-2); }NOTE: take care while using - stops the execution of the script.returnreturn(0) while while statement - conditional loop Example of usage: $var(i) 0; while($var(i) 10) {xlog(counter: $var(i)\n);$var(i) $var(i) 1; }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 (equal). Among the pseudo-variables that can be used in left side of an assignment: Unordered List Item AVPs - to set the value of an AVP script variables - to set the value of a script variable( v a r ( . . . ) ) s h a r e d v a r i a b l e s ( var(...)) shared variables ( var(...))sharedvariables(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; For avp’s there a way to remove all values and assign a single value in one statement (in other words, delete existing AVPs with same name, add a new one with the right side value). This replaces the assignment operator from kamailio .: 3.0 $(avp(i:3)[*]) 123; $(avp(i:3)[*]) $null;String Operations For strings, is available to concatenate. $var(a) test; $var(b) sip: $var(a) $fd;Arithmetic Operations For numbers, one can use: : plus : minus / : divide : multiply mod : modulo (SER uses instead of %mod) | : bitwise OR : bitwise AND ^ : bitwise XOR ~ : bitwise NOT : bitwise left shift : bitwise right shift Example: $var(a) 4 ( 7 ( ~2 ) ); 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(“var a has third bit set\n”); Operators type casts operators: , .(int)(str) string comparison: , eqne integer comparison: , ieqine Note: The names are not yet final (use them at your own risk). Future version might use / only for ints () and for strings (under debate). They are almost equivalent to or , but they force the conversion of their operands ( to string and to int), allowing among other things better type checking on startup and more optimizations.!ieq/ineeq/ne!eqieq Non equivalent examples: 0 “” (true) is not equivalent to (false: it evaluates to ).0 eq “”“0” eq “” “a” ieq “b” (true: and ) is not equivalent to (false).(int)“a” is 0(int)“b” is 0a “b” Note: internally and are converted on startup to whenever possible (both operand types can be safely determined at start time and they are the same).!eq/ne/ieq/ine 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 .! Special case: undef as left operand: For : - is converted to string “” expr. For and : - is converted to type_of expr. If is , then is (internally is converted to string).undef exprundef!undef exprundefexprundefundef undeftrue expression evaluation changes: Kamailio will auto-convert to integer or string in function of the operators: int(undef)0, int()0, int(123)123, int(abc)0 str(undef), str(123)123defined expr - returns true if expr is defined, and false if not. Note: only a standalone avp or pvar can be undefined, everything else is defined. strlen(expr) - returns the lenght of expr evaluated as string. strempty(expr) - returns true if expr evaluates to the empty string (equivalent to expr“”). Example: if (defined KaTeX parse error: Expected EOF, got at position 3: v ̲ !strempty(v)) l e n s t r l e n ( lenstrlen( lenstrlen(v); 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: ~# kamailio -h version: kamailio 5.8.3 (aarch64/linux) be1fe9 Usage: kamailio [options] Options: -a mode Auto aliases mode: enable with yes or on, disable with no or off –aliasval Add an alias, the value has to be ‘[proto:]hostname[:port]’ (like for ‘alias’ global parameter) –atexitval Control atexit callbacks execution from external libraries which may access destroyed shm memory causing crash on shutdown. Can be y[es] or 1 to enable atexit callbacks, n[o] or 0 to disable, default is no. -A define Add config pre-processor define (e.g., -A WITH_AUTH, -A ‘FLT_ACC1’, -A ‘DEFVAL“str-val”’) -b nr Maximum OS UDP receive buffer size which will not be exceeded by auto-probing-and-increase procedure even if OS allows -B nr Maximum OS UDP send buffer size which will not be exceeded by auto-probing-and-increase procedure even if OS allows -c Check configuration file for syntax errors –cfg-print Print configuration file evaluating includes and ifdefs -d Debugging level control (multiple -d to increase the level from 0) –debugval Debugging level value -D Control how daemonize is done: -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: /usr/local/etc/kamailio/kamailio.cfg) -g gid Change gid (group id) -G file Create a pgid file -h This help message –help Long option for -h -I Print more internal compile flags and options -K Turn on “via:” host checking when forwarding replies -l address Listen on the specified address/interface (multiple -l mean listening on more addresses). The address format is [proto:]addr_lst[:port][/advaddr], where protoudp|tcp|tls|sctp, addr_lst addr|(addr, addr_lst), addrhost|ip_address|interface_name and advaddraddr[:port] (advertised address). E.g: -l localhost, -l udp:127.0.0.1:5080, -l eth0:5062, -l udp:127.0.0.1:5080/1.2.3.4:5060, -l “sctp:(eth0)”, -l “(eth0, eth1, 127.0.0.1):5065”. The default behaviour is to listen on all the interfaces. –loadmodulename load the module specified by name –log-enginelog engine name and data -L path Modules search path (default: /usr/local/lib64/kamailio/modules) -m nr Size of shared memory allocated in Megabytes –modparammodname:paramname:type:value set the module parameter type has to be ‘s’ for string value and ‘i’ for int value, example: --modparamcorex:alias_subdomains:s:kamailio.org –all-errors Print details about all config errors that can be detected -M nr Size of private memory allocated, in Megabytes -n processes Number of child processes to fork per interface (default: 8) -N Number of tcp child processes (default: equal to -n) -O nr Script optimization level (debugging option) -P file Create a pid file -Q Number of sctp child processes (default: equal to -n’) -r Use dns to check if is necessary to add a “received” field to a via -R Same as -r but use reverse dns; (to use both use -rR) –server-idnum set the value for server_id –substexp set a subst preprocessor directive –substdefexp set a substdef preprocessor directive –substdefsexp set a substdefs preprocessor directive -S disable sctp -t dir Chroot to “dir” -T Disable tcp -u uid Change uid (user id) -v Version number –version Long option for -v -V Alternative for -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 Runtime dir path -w dir Change the working directory to “dir” (default: “/”) -W type poll method (depending on support in OS, it can be: poll, epoll_lt, epoll_et, sigio_rt, select, kqueue, /dev/poll) Log Engine CLI 参数 –log-engine 参数允许指定要 这实际上是关于日志消息的格式。如果 根本没有设置那么 Kamailio 做了基于线的经典风格 plain 文本日志消息。 该参数的取值可以是 --log-enginename 或 --log-enginenamedata。 日志引擎的名称可以是 json - 以结构化 JSON 格式写入日志 JSON 日志引擎的数据可以是一组字符 标志 a - 将日志前缀添加为特殊字段 A - 不添加日志前缀 c - 将呼叫 ID如果可用添加为专用 JSON 属性 j - 日志前缀和消息字段以 JSON 结构格式检测它们是否包含在 介于 { } 之间或将它们添加为文本字段 M - 从日志消息字段的值中删除 EOL \n N - 不在 JSON 文档末尾添加 EOL p - 日志前缀按根 JSON 中的原样打印 document它必须以逗号 开头并且是有效的 JSON 字段集 U - CEE通用事件表达式架构格式 - https://cee.mitre.org/language/1.0-beta1/core-profile.html 使用以下命令运行 Kamailio 时的 JSON 日志示例–log-enginejson:M { idx: 1, pid: 18239, level: DEBUG, module: maxfwd, file: mf_funcs.c, line: 74, function: is_maxfwd_present, logprefix: {1 1 OPTIONS 715678756192.168.188.20} , message: value 70 }{ idx: 1, pid: 18239, level: DEBUG, module: core, file: core/socket_info.c, line: 644, function: grep_sock_info, logprefix: {1 1 OPTIONS 715678756192.168.188.20} , message: checking if hostus: 99 [127.0.0.1] [127.0.0.1] }打印带有 flag 的日志消息的示例配置j xinfo(“{ “src_ip”: “KaTeX parse error: Expected group as argument to \ at end of input: … \method\: \rm”, “text”: “request received” }”); 使用 flag 打印日志消息的示例配置p log_prefix“, “src_ip”: “$si”, “tv”: $TV(Sn), “mt”: KaTeX parse error: Expected group as argument to \ at end of input: mt, \ua\: \(ua{s.escape.common})”, “cseq”: “$hdr(CSeq)”
http://www.pierceye.com/news/12323/

相关文章:

  • 黑彩网站充值就给你做单子工厂网站建设公司
  • 怎么选择做网站的公司网页制作与设计的总结
  • 网站被k原因wordpress发表意见
  • 网站建设用户调查问卷北京企业响应式网站建设
  • wordpress 2.0 下载北京seo的排名优化
  • 建设一个网站用什么软件张家界城乡建设网站
  • 做网站好的广东专业移动网站服务商
  • 不错的网站开发公司怎么上网站
  • 设计商城网站 优帮云工装效果图网站
  • 网站如何做微信支付链接郑州网站建设模板制作
  • 国内产品网站1688ui界面设计案例ppt
  • 做网站需要做需求分析吗网站的规划与建设
  • 福州市建设厅网站购物网站推广怎么做
  • 永久免费的自助建站wordpress改变字体
  • 站长工具seo客户端装修大全
  • 高校网站建设管理办法网站内容页怎么设计
  • 有多个网页的大网站如何做北京建站管理系统价格
  • 怎么做可以直播的网站WordPress多用户商城插件
  • 闸北企业网站建设德州网站制作
  • 柳州制作网站寻找在山西运城专业做网站推广的
  • 嘉兴手机模板建站郑州seo多少钱
  • 建站公司外贸wordpress赚钱
  • 毛衣品 东莞网站建设wordpress添加qq交谈
  • 做网站的都改行做什么了17173网游排行榜
  • 微信网站开发需要什么知识医药网站前置审批
  • 全国建设项目竣工验收公示网站棋牌软件制作开发app公司
  • 网站建设简介怎么样wordpress 调用文章
  • 焦作网站设计济南建设厅官方网站
  • 专做农产品的网站四川成都有什么好玩的
  • 深圳产品网站建设网站开发如何让图片加载的更快