Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
core-cookbook:3.1.x [2010/10/06 13:44] – created miconda | core-cookbook:3.1.x [2020/10/28 05:33] (current) – [Config Pre-Processor Directives] lucasmiller7005 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Kamailio 3.1.x: Core Cookbook ====== | ||
+ | |||
+ | This tutorial collects the functions and parameters exported by SIP Router core to configuration file. | ||
+ | |||
+ | **Note:** The parameters on this page are **NOT** in alphabetical order. | ||
+ | |||
+ | ====== ECONOMICS HOMEWORK HELPER ====== | ||
+ | |||
+ | Contact us for the finest economics assignment help | ||
+ | |||
+ | Economics is the science that analyzes how goods and services are produced, distributed, | ||
+ | |||
+ | Enjoy round-the-clock economics assignment help for the consumption of goods | ||
+ | |||
+ | With so many sites promising to provide economics assignment help for the consumption of goods today, many students are having a hard time deciding which website to trust. This is not one of the topics on which you just entrust anyone with your assignment. You need to make sure that the person who is going to do the assignment for you actually has what it takes to deliver a quality assignment solution. You also want to make sure that the person is available at all times. | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | ==== include_file ==== | ||
+ | |||
+ | | ||
+ | |||
+ | Include the content of the file in config before parsing. path_to_file must be a static string. Including file operation is done at startup. If you change the content of included file, you have to restart the SIP server to become effective. | ||
+ | |||
+ | The path_to_file can be relative or absolute. If it is not absolute path, first attempt is to locate it relative to current directory, and if fails, relative to directory of the file that includes it. There is no restriction where include can be used or what can contain - any part of config file is ok. There is a limit of maximum 10 includes in depth, otherwise you can use as many includes as you want. Reporting of the cfg file syntax errors prints now the file name for easier troubleshooting. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | route { | ||
+ | ... | ||
+ | include_file "/ | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | --- / | ||
+ | |||
+ | if (!mf_process_maxfwd_header(" | ||
+ | | ||
+ | exit; | ||
+ | } | ||
+ | |||
+ | --- | ||
+ | </ | ||
+ | |||
+ | ==== 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: | ||
+ | * #!define NAME - define a keyword | ||
+ | * #!define NAME VALUE - define a keyword with value | ||
+ | * #!ifdef NAME - check if a keyword is defined | ||
+ | * #!ifndef - check if a keyword is not defined | ||
+ | * #!else - swtich to false branch of ifdef/ | ||
+ | * #!endif - end ifdef/ | ||
+ | |||
+ | Among benefits: | ||
+ | * easy way to enable/ | ||
+ | * 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, | ||
+ | |||
+ | <code c> | ||
+ | ... | ||
+ | |||
+ | #!define TESTBED_MODE | ||
+ | |||
+ | #!ifdef TESTBED_MODE | ||
+ | debug=5 | ||
+ | log_stderror=yes | ||
+ | listen=192.168.1.1 | ||
+ | #!else | ||
+ | debug=2 | ||
+ | log_stderror=no | ||
+ | listen=10.0.0.1 | ||
+ | #!endif | ||
+ | |||
+ | ... | ||
+ | |||
+ | #!ifdef TESTBED_MODE | ||
+ | modparam(" | ||
+ | " | ||
+ | #!else | ||
+ | modparam(" | ||
+ | " | ||
+ | #!endif | ||
+ | |||
+ | ... | ||
+ | |||
+ | #!ifdef TESTBED_MODE | ||
+ | route[DEBUG] { | ||
+ | xlog(" | ||
+ | } | ||
+ | #!endif | ||
+ | |||
+ | ... | ||
+ | |||
+ | route { | ||
+ | #!ifdef TESTBED_MODE | ||
+ | route(DEBUG); | ||
+ | #!endif | ||
+ | |||
+ | ... | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | * you can define values for IDs | ||
+ | |||
+ | <code c> | ||
+ | #!define MYINT 123 | ||
+ | #!define MYSTR " | ||
+ | </ | ||
+ | |||
+ | * defined IDs are replaced at startup, during config parsing, e.g.,: | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = 100 + MYINT; | ||
+ | </ | ||
+ | |||
+ | * is interpreted as: | ||
+ | |||
+ | <code c> | ||
+ | $var(x) = 100 + 123; | ||
+ | </ | ||
+ | |||
+ | * you can have multi-line defined IDs | ||
+ | |||
+ | <code c> | ||
+ | #!define IDLOOP $var(i) = 0; \ | ||
+ | while($var(i)< | ||
+ | xlog(" | ||
+ | $var(i) = $var(i) + 1; \ | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | * then in routing block | ||
+ | |||
+ | <code c> | ||
+ | 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 ' | ||
+ | * 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. | ||
+ | |||
+ | ==== 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.,: | ||
+ | |||
+ | <code c> | ||
+ | #!subst "/ | ||
+ | </ | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <code c> | ||
+ | #!subst "/ | ||
+ | modparam(" | ||
+ | </ | ||
+ | |||
+ | * will do the substitution of db password in db_url parameter value | ||
+ | |||
+ | ===== Core Keywords ===== | ||
+ | |||
+ | Keywords specific to SIP messages which can be used mainly in ''' | ||
+ | |||
+ | ==== 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: | ||
+ | |||
+ | <code c> | ||
+ | if (af==INET6) { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== 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: | ||
+ | |||
+ | <code c> | ||
+ | | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== dst_port ==== | ||
+ | |||
+ | The local port where the SIP packet was received. When SIP-Router is listening on many ports, it is useful to learn which was the one that received the SIP packet. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | | ||
+ | { | ||
+ | | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== from_uri ==== | ||
+ | |||
+ | This script variable is a reference to the URI of ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | if(is_method(" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== method ==== | ||
+ | |||
+ | The variable is a reference to the SIP method of the message. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | if(method==" | ||
+ | { | ||
+ | | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== msg:len ==== | ||
+ | |||
+ | The variable is a reference to the size of the message. It can be used in ' | ||
+ | |||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(msg: | ||
+ | { | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | . | ||
+ | |||
+ | ==== proto ==== | ||
+ | |||
+ | This variable can be used to test the transport protocol of the SIP message. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(proto==UDP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== status ==== | ||
+ | |||
+ | If used in onreply_route, | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(status==" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== snd_af ==== | ||
+ | |||
+ | ==== snd_ip ==== | ||
+ | |||
+ | ==== snd_port ==== | ||
+ | |||
+ | ==== snd_proto ==== | ||
+ | |||
+ | ==== src_ip ==== | ||
+ | |||
+ | Reference to source IP address of the SIP message. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(src_ip==127.0.0.1) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== src_port ==== | ||
+ | |||
+ | Reference to source port of the SIP message (from which port the message was sent by previous hop). | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(src_port==5061) | ||
+ | { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== to_ip ==== | ||
+ | |||
+ | ==== to_port ==== | ||
+ | |||
+ | ==== to_uri ==== | ||
+ | |||
+ | This variable can be used to test the value of URI from To header. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(to_uri=~" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== uri ==== | ||
+ | |||
+ | |||
+ | This variable can be used to test the value of the request URI. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(uri=~" | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Core Values ===== | ||
+ | |||
+ | Values that can be used in ''' | ||
+ | |||
+ | ==== INET ==== | ||
+ | |||
+ | This keyword can be used to test whether the SIP packet was received over an IPv4 connection. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | if (af==INET) { | ||
+ | log(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== INET6 ==== | ||
+ | |||
+ | This keyword can be used to test whether the SIP packet was received over an IPv6 connection. | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(af==INET6) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== TCP ==== | ||
+ | |||
+ | This keyword can be used to test the value of ' | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(proto==TCP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== UDP ==== | ||
+ | |||
+ | This keyword can be used to test the value of ' | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(proto==UDP) | ||
+ | { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | ==== max_len ==== | ||
+ | |||
+ | Note: This command was removed. | ||
+ | |||
+ | |||
+ | ==== myself ==== | ||
+ | |||
+ | It is a reference to the list of local IP addresses, hostnames and aliases that has been set in SIP-Router configuration file. This lists contain the domains served by SIP-Router. | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | if(uri==myself) { | ||
+ | log(" | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Core parameters ===== | ||
+ | |||
+ | ==== advertised_address ==== | ||
+ | |||
+ | It can be an IP address or string and represents the address advertised in Via header and | ||
+ | other destination lumps (e.g RR 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' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | advertised_address=" | ||
+ | |||
+ | ==== advertised_port ==== | ||
+ | |||
+ | The port advertised in Via header and other destination lumps (e.g. RR). If empty or not set (default value) the port from where the message will be sent is used. Same warnings as for ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | advertised_port=5080 | ||
+ | |||
+ | ==== alias ==== | ||
+ | |||
+ | 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 ' | ||
+ | |||
+ | It is necessary to include the port (the port value used in the " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | < | ||
+ | alias=other.domain.com: | ||
+ | alias=another.domain.com: | ||
+ | </ | ||
+ | |||
+ | ==== check_via ==== | ||
+ | |||
+ | Check if the address in top most via of replies is local. Default value is 0 (check disabled). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | check_via=1 | ||
+ | |||
+ | ==== children ==== | ||
+ | |||
+ | Number of children to fork for the UDP interfaces (one set for each interface - ip:port). Default value is 8. For example if you configure the proxy to listen on 3 UDP ports, it will create 3xchildren processes which handle the incoming UDP messages. | ||
+ | |||
+ | For configuration of the TCP/TLS worker threads see the option " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | children=16 | ||
+ | |||
+ | ==== chroot ==== | ||
+ | |||
+ | The value must be a valid path in the system. If set, sip-router will chroot (change root directory) to its value. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | chroot=/ | ||
+ | |||
+ | |||
+ | ==== debug ==== | ||
+ | |||
+ | Set the debug level. Higher values make sip-router to print more debug messages. Log messages are usually sent to syslog, except logging to stderr was activated (see [[# | ||
+ | |||
+ | The following log levels are defined: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | 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 configuration script using log() or xlog() functions. For a production server you usually use a log value between -1 and 2. | ||
+ | |||
+ | Default value: L_WARN (debug=0) | ||
+ | |||
+ | Examples of usage: | ||
+ | |||
+ | * debug=3: print all log messages. This is only usefull for debugging of problems. Note: this produces a lot of data and therefore should not be used on production servers (on a busy server this can easily fill up your hard disk with log messages) | ||
+ | * debug=0: This will only log warning, errors and more critical messages. | ||
+ | * debug=-6: This will disable all log messages. | ||
+ | |||
+ | Value of ' | ||
+ | sercmd cfg.get core debug | ||
+ | sercmd cfg.set_now_int core debug 2 | ||
+ | sercmd cfg.set_now_int core debug -- -1 | ||
+ | |||
+ | Note: There is a difference in log-levels between sip-router and Kamailio< | ||
+ | |||
+ | For configuration of logging of the memory manager see the parameters [[#memlog]] and [[# | ||
+ | |||
+ | Further information can also be bound at: http:// | ||
+ | |||
+ | ==== description ==== | ||
+ | |||
+ | **Alias name: descr desc** | ||
+ | |||
+ | ==== disable_core_dump ==== | ||
+ | |||
+ | Can be ' | ||
+ | |||
+ | Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_core_dump=yes | ||
+ | |||
+ | ==== disable_tls ==== | ||
+ | |||
+ | **Alias name: tls_disable** | ||
+ | |||
+ | Global parameter to disable TLS support in the SIP server. Default value is ' | ||
+ | |||
+ | Note: Make sure to load the " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_tls=yes | ||
+ | |||
+ | In sip-router TLS is implemented as a module. Thus, the TLS configuration is done as module configuration. For more details see the README of the TLS module: | ||
+ | http:// | ||
+ | |||
+ | ==== enable_tls ==== | ||
+ | |||
+ | **Alias name: tls_enable** | ||
+ | |||
+ | Reverse Meaning of the disable_tls parameter. See disable_tls parameter. | ||
+ | |||
+ | enable_tls=yes # enable tls support in core | ||
+ | |||
+ | ==== exit_timeout ==== | ||
+ | |||
+ | **Alias name: ser_kill_timeout** | ||
+ | |||
+ | How much time ser will wait for all the shutdown procedures to complete. If this time is exceeded, all the remaining processes are immediately killed and ser exits immediately (it might also generate a core dump if the cleanup part takes too long). | ||
+ | |||
+ | Default: 60 s. Use 0 to disable. | ||
+ | |||
+ | | ||
+ | |||
+ | ==== flags ==== | ||
+ | |||
+ | **Alias name: bool** | ||
+ | |||
+ | ==== force_rport ==== | ||
+ | |||
+ | yes/no: Similar to the force_rport() function, but activates symmetric response routing globally. | ||
+ | |||
+ | ==== fork ==== | ||
+ | If set to ' | ||
+ | |||
+ | When set to ' | ||
+ | |||
+ | Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | fork=no | ||
+ | |||
+ | ==== group ==== | ||
+ | |||
+ | **Alias name: gid** | ||
+ | |||
+ | The group id to run sip-router. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | group=" | ||
+ | |||
+ | |||
+ | |||
+ | ==== listen ==== | ||
+ | |||
+ | Set the network addresses the SIP server should listen to. It can be an IP address, hostname or network interface id or combination of protocol: | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | listen=10.10.10.10 | ||
+ | listen=eth1: | ||
+ | listen=udp: | ||
+ | |||
+ | If you omit this directive then the SIP server will listen on all interfaces. On start the SIP server reports all the interfaces that it is listening on. Even if you specify only UDP interfaces here, the server will start the TCP engine too. If you don't want this, you need to disable the TCP support completly with the core parameter disable_tcp. | ||
+ | |||
+ | If you specify IPv6 addresses, you should put them into square brackets, e.g.: | ||
+ | |||
+ | listen=udp: | ||
+ | |||
+ | ==== loadmodule ==== | ||
+ | |||
+ | Loads a module for later usage in the configuration script. The modules is searched in the path specified by **loadpath**. | ||
+ | |||
+ | Prototype: **loadmodule " | ||
+ | |||
+ | If modulepath is only modulename or modulename.so, | ||
+ | |||
+ | Example of usage: | ||
+ | <code c> | ||
+ | loadpath "/ | ||
+ | |||
+ | loadmodule "/ | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | </ | ||
+ | |||
+ | ==== loadpath ==== | ||
+ | |||
+ | **Alias name: mpath** | ||
+ | |||
+ | Set the module search path. loadpath takes a list of directories separated by ':' | ||
+ | |||
+ | 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: | ||
+ | |||
+ | <code c> | ||
+ | loadpath "/ | ||
+ | |||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | loadmodule " | ||
+ | </ | ||
+ | |||
+ | The proxy tries to find the modules in a smart way, e.g: loadmodule " | ||
+ | |||
+ | If you have installed Kamailio and ser modules, and want to load them in a certain order, you can for example use the following technique: | ||
+ | |||
+ | < | ||
+ | # common modules | ||
+ | loadpath "/ | ||
+ | loadmodule " | ||
+ | ... | ||
+ | |||
+ | # Kamailio modules | ||
+ | loadpath "/ | ||
+ | loadmodule " | ||
+ | ... | ||
+ | |||
+ | # ser modules | ||
+ | loadpath "/ | ||
+ | loadmodule " | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== log_facility ==== | ||
+ | |||
+ | If sip-router logs to syslog, you can control the facility for logging. Very useful when you want to divert all sip-router logs to a different log file. See the man page syslog(3) for more details. | ||
+ | |||
+ | For more see: http:// | ||
+ | |||
+ | Default value is LOG_DAEMON. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | log_facility=LOG_LOCAL0 | ||
+ | |||
+ | ==== log_name ==== | ||
+ | |||
+ | Allows to configure a log_name prefix which will be used when printing to syslog. This is useful to filter log messages when running many instance of sip-router on same server | ||
+ | |||
+ | |||
+ | ==== log_stderror ==== | ||
+ | |||
+ | With this parameter you can make sip-router to write log and debug messages to standard error. Possible values are: | ||
+ | |||
+ | - " | ||
+ | |||
+ | - " | ||
+ | |||
+ | Default value is " | ||
+ | |||
+ | For more see: http:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | log_stderror=yes | ||
+ | |||
+ | ==== maxbuffer ==== | ||
+ | |||
+ | The size in bytes not to be exceeded during the auto-probing procedure of descovering the maximum buffer size for receiving UDP messages. Default value is 262144. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | maxbuffer=65536 | ||
+ | |||
+ | ==== max_while_loops ==== | ||
+ | |||
+ | The parameters set the value of maximum loops that can be done within a " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | max_while_loops=200 | ||
+ | |||
+ | ==== mcast_loopback ==== | ||
+ | |||
+ | It can be ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mcast_loopback=yes | ||
+ | |||
+ | ==== mcast_ttl ==== | ||
+ | |||
+ | Set the value for multicast ttl. Default value is OS specific (usually 1). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mcast_ttl=32 | ||
+ | |||
+ | ==== memdbg ==== | ||
+ | |||
+ | **Alias name: mem_dbg** | ||
+ | |||
+ | This parameter specifies on which log level the memory debugger messages will be logged. If memdbg is active, every request (alloc, free) to the memory manager will be logged. (Note: if compile option NO_DEBUG is specified, there will never be logging from the memory manager). | ||
+ | |||
+ | Default value: L_DBG (memdbg=3) | ||
+ | |||
+ | For example, memdbg=2 means that memory debugging is activated if the debug level is 2 or higher. | ||
+ | |||
+ | debug=3 | ||
+ | memdbg=4 | ||
+ | |||
+ | debug=3 | ||
+ | memdbg=2 | ||
+ | |||
+ | Please see also [[#memlog]] and [[#debug]]. | ||
+ | |||
+ | ==== memlog ==== | ||
+ | |||
+ | **Alias name: mem_log** | ||
+ | |||
+ | This parameter specifies on which log level the memory statistics will be logged. If memlog is active, sip-router will log memory statistics on shutdown (or if requested via signal SIGUSR1). This can be useful for debugging of memory leaks. | ||
+ | |||
+ | Default value: L_DBG (memlog=3) | ||
+ | |||
+ | For example, memlog=2 means that memory statistics dumping is activated if the debug level is 2 or higher. | ||
+ | |||
+ | debug=3 | ||
+ | memlog=4 | ||
+ | |||
+ | debug=3 | ||
+ | memlog=2 | ||
+ | |||
+ | Please see also [[#memdbg]] and [[#debug]]. | ||
+ | |||
+ | ==== mem_summary ==== | ||
+ | |||
+ | Parameter to control printing of mmemory debugging information displayed on exit or SIGUSR1. The value can be composed by following flags: | ||
+ | * 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 | ||
+ | |||
+ | If set to 0, nothing is printed. | ||
+ | |||
+ | Default value: 3 | ||
+ | |||
+ | Example: | ||
+ | |||
+ | < | ||
+ | mem_summary=15 | ||
+ | </ | ||
+ | |||
+ | ==== 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 decativated, | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | mhomed=1 | ||
+ | |||
+ | ==== mlock_pages ==== | ||
+ | Locks all ser pages into memory making it unswappable (in general one doesn' | ||
+ | |||
+ | mlock_pages = yes |no (default no) | ||
+ | |||
+ | ==== modparam ==== | ||
+ | The modparam command will be used to set the options of the modules. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | modparam(" | ||
+ | modparam(" | ||
+ | |||
+ | See the documenation of the respective module to find out the available options. | ||
+ | |||
+ | ==== open_files_limit ==== | ||
+ | |||
+ | If set and bigger than the current open file limit, sip-router will try to increase its open file limit to this number. Note: sip-router must be started as root to be able to increase a limit past the hard limit (which, for open files, is 1024 on most systems). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | open_files_limit=2048 | ||
+ | |||
+ | ==== phone2tel ==== | ||
+ | By enabling this feature, SIP-Router internally treats SIP URIs with user=phone parameter as TEL URIs. If you do not want thi behavior, you have to turn it off. | ||
+ | |||
+ | Default value: 1 (enabled) | ||
+ | |||
+ | phone2tel = 0 | ||
+ | |||
+ | |||
+ | ==== pmtu_discovery ==== | ||
+ | If enabled, the Don't Fragment (DF) bit will be set in outbound IP packets. | ||
+ | |||
+ | pmtu_discovery = 0 | 1 (default 0) | ||
+ | |||
+ | ==== port ==== | ||
+ | |||
+ | The port the SIP server listens to. The default value for it is 5060. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | port=5080 | ||
+ | |||
+ | ==== 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_via=0 | ||
+ | ==== server_id ==== | ||
+ | |||
+ | A configurable unique server id that can be used to discriminate server instances within a cluster of servers when all other information, | ||
+ | |||
+ | <code c> | ||
+ | server_id = number | ||
+ | </ | ||
+ | |||
+ | ==== server_header ==== | ||
+ | |||
+ | Set the value of Server header for replies generated by SIP router. It must contain the header name, but not the ending CRLF. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | server_header=" | ||
+ | </ | ||
+ | |||
+ | ==== server_signature ==== | ||
+ | |||
+ | This parameter controls the " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | | ||
+ | |||
+ | If it is enabled (default=yes) a header is generated as in the following example: | ||
+ | |||
+ | | ||
+ | |||
+ | ==== shm_force_alloc ==== | ||
+ | Tries to pre-fault all the shared memory, before starting. When " | ||
+ | |||
+ | shm_force_alloc = yes | no (default no) | ||
+ | ==== sip_warning (noisy feedback) ==== | ||
+ | |||
+ | Can be 0 or 1. If set to 1 (default value) a ' | ||
+ | The header contains several details that help troubleshooting using the network traffic dumps, but might reveal details of your network infrastructure and internall SIP routing. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | sip_warning=0 | ||
+ | |||
+ | ==== statistics ==== | ||
+ | |||
+ | ==== stun_allow_fp ==== | ||
+ | Use FINGERPRINT attribute in STUN server | ||
+ | |||
+ | stun_allow_fp = 0 | 1 (off | on); default: 1 | ||
+ | |||
+ | ==== stun_allow_stun ==== | ||
+ | Activate internal STUN server. | ||
+ | stun_allow_stun = 0 | 1 (off | on); default 1 | ||
+ | |||
+ | Note: STUN support is only available if sip-router/ | ||
+ | |||
+ | |||
+ | ==== stun_refresh_interval ==== | ||
+ | Value for the REFRESH INTERVAL attribute of the internal STUN server | ||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | ==== syn_branch ==== | ||
+ | The parameter controls how the branch parameter is calculated for stateless forwarding. | ||
+ | |||
+ | If syn_branch is turned off, calculation is derived from transaction key, i.e., as an md5 of From/ | ||
+ | CSeq exactly the same way as TM does. This is good for reboot - than messages belonging to transaction lost due to reboot will still be forwarded with the same branch parameter and will be match-able downstream. | ||
+ | |||
+ | If it is turned on, just a simple value is put into the branch paramter (better for performance) | ||
+ | |||
+ | ==== tos ==== | ||
+ | |||
+ | The TOS (Type Of Service) to be used for the sent IP packages (both TCP and UDP). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tos=IPTOS_LOWDELAY | ||
+ | tos=0x10 | ||
+ | tos=IPTOS_RELIABILITY | ||
+ | |||
+ | ==== udp_mtu ==== | ||
+ | Fallback to another protocol (udp_mtu_try_proto must be set also either globally or per packet) if the constructed request size is greater then udp_mtu. | ||
+ | |||
+ | RFC 3261 specified size: 1300. Default: 0 (off). | ||
+ | |||
+ | udp_mtu = number | ||
+ | |||
+ | ==== udp_mtu_try_proto ==== | ||
+ | |||
+ | If udp_mtu !=0 and udp forwarded request size (after adding all the " | ||
+ | |||
+ | **Warning: | ||
+ | |||
+ | See also udp_mtu_try_proto(proto) function. | ||
+ | |||
+ | Default: UDP (off). Recommended: | ||
+ | |||
+ | udp_mtu_try_proto = TCP|TLS|SCTP|UDP | ||
+ | ==== user ==== | ||
+ | |||
+ | **Alias name: uid** | ||
+ | |||
+ | The user id to run sip-router (sip-router will suid to it). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | user=" | ||
+ | </ | ||
+ | |||
+ | ==== user_agent_header ==== | ||
+ | |||
+ | Set the value of User-Agent header for requests generated by SIP router. It must contain header name as well, but not the ending CRLF. | ||
+ | |||
+ | <code c> | ||
+ | user_agent_header=" | ||
+ | </ | ||
+ | |||
+ | ==== workdir ==== | ||
+ | |||
+ | **Alias name: wdir** | ||
+ | |||
+ | The working directory used by sip-router at runtime. You might find it usefull when come to generating core files :) | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | | ||
+ | or | ||
+ | | ||
+ | |||
+ | ===== DNS Parameters ===== | ||
+ | |||
+ | SIP-Router has an internal DNS resolver with caching capabilities. If this caching resolver is activated (default setting) then the system' | ||
+ | |||
+ | ^ DNS resolver comparison | ||
+ | | 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 / | ||
+ | |||
+ | If the internal resolver/ | ||
+ | dns.add_srv, | ||
+ | |||
+ | Note: During startup of SIP-Router, 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 mod_init() or normal fixups). | ||
+ | |||
+ | Note: The dns cache uses the DNS servers configured on your server (/ | ||
+ | |||
+ | SIP-Router also allows you to finetune the DNS resolver settings. | ||
+ | |||
+ | The maximum time a dns request can take (before failing) is (if dns_try_ipv6 is yes, mutliply it again by 2; if SRV and NAPTR lookups are enabled, it can take even longer!): | ||
+ | |||
+ | (dns_retr_time*(dns_retr_no+1)*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_ipv6=no | ||
+ | dns_retr_time=1 | ||
+ | dns_retr_no=1 | ||
+ | dns_use_search_list=no | ||
+ | |||
+ | ==== 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 received=< | ||
+ | DNS names (instead of IPs) should have received= added, so turning dns to yes is not recommended. | ||
+ | |||
+ | Default is no. | ||
+ | |||
+ | ==== rev_dns ==== | ||
+ | |||
+ | This parameter controls if the SIP server will try doing a reverse DNS lookup on the source IP of a sip request | ||
+ | to decide if adding a received=< | ||
+ | See also dns (the effect is cumulative, both can be turned on and in that case if the DNS lookup test fails the reverse | ||
+ | DNS test will be tried). | ||
+ | Note that Vias containing DNS names (instead of IPs) should have received= added, so turning rev_dns to yes is not recommended. | ||
+ | |||
+ | |||
+ | 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_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 ser listens also on ipv6 addresses. | ||
+ | 2 - ipv6 only: only DNS AAAA requests are performed. Ignored if dns_try_ipv6 is off or ser | ||
+ | doesn' | ||
+ | 4 - prefer ipv6: try first to resolve a host name to an ipv6 address (DNS AAAA request) and only | ||
+ | if this fails try an ipv4 address (DNS A request). By default the ipv4 addresses are preferred. | ||
+ | |||
+ | ==== 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 runtime, that 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. | ||
+ | |||
+ | ==== dns_retr_no ==== | ||
+ | |||
+ | Number of dns retransmissions before giving up. Default value is system specific, depends also on the '/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | dns_retr_no=3 | ||
+ | |||
+ | ==== dns_retr_time ==== | ||
+ | |||
+ | Time in seconds before retrying a dns request. Default value is system specific, depends also on the '/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | dns_retr_time=3 | ||
+ | |||
+ | ==== 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 '/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | dns_servers_no=2 | ||
+ | |||
+ | ==== dns_srv_lb ==== | ||
+ | |||
+ | **Alias name: dns_srv_loadbalancing** | ||
+ | |||
+ | Enable dns srv weight based load balancing (see doc/ | ||
+ | |||
+ | dns_srv_lb = yes | no (default no) | ||
+ | |||
+ | ==== dns_try_ipv6 ==== | ||
+ | |||
+ | Can be ' | ||
+ | for ipv6 (AAAA record). Default value is ' | ||
+ | |||
+ | Note: If dns_try_ipv6 is off, no hostname resolving that would result in an ipv6 address would succeed - it doesn' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | dns_try_ipv6=yes | ||
+ | |||
+ | ==== dns_try_naptr ==== | ||
+ | Enable NAPTR support according to RFC 3263 (see doc/dns.txt for more info) | ||
+ | | ||
+ | dns_try_naptr = yes | no (default no) | ||
+ | |||
+ | ==== dns_sctp_pref, | ||
+ | |||
+ | **Alias name: dns_sctp_preference, | ||
+ | |||
+ | Set preference for each protocol when doing naptr lookups. By default dns_udp_pref=30, | ||
+ | dns_tls_pref=10 and dns_sctp_pref=20. To use the remote site preferences set all dns_*_pref to the same positive value (e.g. dns_udp_pref=1, | ||
+ | dns_tcp_pref=1, | ||
+ | preference to -1 (or any other negative number). (see doc/dns.txt for more info) | ||
+ | |||
+ | dns_{udp, | ||
+ | |||
+ | ==== dns_use_search_list ==== | ||
+ | |||
+ | Can be ' | ||
+ | |||
+ | HINT: even if you don't have a search list defined, setting this option to ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | dns_use_search_list=no | ||
+ | |||
+ | ==== use_dns_cache ==== | ||
+ | |||
+ | Tells if DNS responses are cached - this means that the internal DNS resolver (instead of the system' | ||
+ | |||
+ | ==== use_dns_failover ==== | ||
+ | use_dns_failover = on | off (default off) | ||
+ | |||
+ | ===== TCP Parameters ===== | ||
+ | |||
+ | The following parameters allows to tweak the TCP behaviour. | ||
+ | |||
+ | ==== disable_tcp ==== | ||
+ | |||
+ | Global parameter to disable TCP support in the SIP server. Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_tcp=yes | ||
+ | |||
+ | ==== tcp_accept_aliases ==== | ||
+ | |||
+ | If a message received over a tcp connection has " | ||
+ | |||
+ | Based on draft-ietf-sip-connect-reuse-00.txt, | ||
+ | |||
+ | See force_tcp_alias for more details. | ||
+ | |||
+ | Note: For NAT traversal of TCP clients it is better to not use tcp_accept_aliases but just use nathelper module and fix_nated_[contact|register] functions. | ||
+ | |||
+ | | ||
+ | |||
+ | ==== 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 tcp_conn_wq_max and tcp_wq_max). | ||
+ | |||
+ | **Note:** Since version 3.1 asynch TCP is also supported for TLS! Thus, there is no reason to disable it - tcp_async should always be enabled. | ||
+ | |||
+ | tcp_async = yes | no (default yes) | ||
+ | | ||
+ | |||
+ | ==== tcp_children ==== | ||
+ | |||
+ | Number of children processes to be created for reading from TCP connections. If no value is explicitly set, the same number of TCP children as UDP children (see " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_children=4 | ||
+ | |||
+ | ==== tcp_connection_lifetime ==== | ||
+ | |||
+ | Lifetime in seconds for TCP sessions. TCP sessions which are inactive for longer than **tcp_connection_lifetime** will be closed by sip-router. Default value is defined in tcp_conn.h: #define DEFAULT_TCP_CONNECTION_LIFETIME 120. Setting this value to 0 will close the TCP connection pretty quick ;-). | ||
+ | |||
+ | Note: As many SIP clients are behind NAT/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_connection_lifetime=3605 | ||
+ | |||
+ | ==== tcp_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_timeout=5 | ||
+ | |||
+ | ==== 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_write_buf 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 tcp(7) TCP_DEFER_ACCEPT or freebsd ACCF_DATA(0). For now linux and freebsd only. | ||
+ | |||
+ | WARNING: the linux TCP_DEFER_ACCEPT is buggy (< | ||
+ | |||
+ | 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 | ||
+ | |||
+ | ==== tcp_fd_cache ==== | ||
+ | |||
+ | If enabled FDs used for sending will be cached inside the process calling tcp_send (performance increase for sending over tcp at the cost of slightly slower connection closing and extra FDs kept open) | ||
+ | |||
+ | tcp_fd_cache = yes | no (default yes) | ||
+ | |||
+ | ==== tcp_keepalive ==== | ||
+ | Enables keepalive for tcp (sets SO_KEEPALIVE socket option) | ||
+ | |||
+ | tcp_keepalive = yes | no (default yes) | ||
+ | |||
+ | ==== tcp_keepcnt ==== | ||
+ | Number of keepalives sent before dropping the connection (TCP_KEEPCNT socket option). Linux only. | ||
+ | |||
+ | tcp_keepcnt = number (not set by default) | ||
+ | |||
+ | ==== tcp_keepidle ==== | ||
+ | |||
+ | Time before starting to send keepalives, if the connection is idle (TCP_KEEPIDLE socket option). Linux only. | ||
+ | |||
+ | tcp_keepidle | ||
+ | |||
+ | ==== tcp_keepintvl ==== | ||
+ | Time interval between keepalive probes, when the previous probe failed (TCP_KEEPINTVL socket option). Linux only. | ||
+ | |||
+ | tcp_keepintvl = seconds (not set by default) | ||
+ | |||
+ | ==== tcp_linger2 ==== | ||
+ | Lifetime of orphaned sockets in FIN_WAIT2 state (overrides tcp_fin_timeout on, see linux tcp(7) TCP_LINGER2). Linux only. | ||
+ | |||
+ | tcp_linger2 = seconds (not set by default) | ||
+ | |||
+ | ==== tcp_max_connections ==== | ||
+ | |||
+ | Maximum number of tcp connections (if the number is exceeded no new tcp connections will be accepted). Default is defined in tcp_conn.h: #define DEFAULT_TCP_MAX_CONNECTIONS 2048 | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_max_connections=4096 | ||
+ | |||
+ | ==== tcp_no_connect ==== | ||
+ | |||
+ | Stop outgoing TCP connects (also stops TLS) by setting tcp_no_connect to yes. You can do this any time, even even if sip-router is already started (in this case using sercmd cfg.set_now_int tcp no_connect 1). | ||
+ | |||
+ | ==== tcp_poll_method ==== | ||
+ | |||
+ | Poll method used (by default the best one for the current OS is selected). For available types see io_wait.c and poll_types.h: | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | tcp_poll_method=select | ||
+ | |||
+ | ==== tcp_rd_buf_size ==== | ||
+ | |||
+ | Buffer size used for tcp reads. A high buffer size increases performance on server with few connections and lot of traffic on them, but also increases memory consumption (so for lots of connection is better to use a low value). Note also that this value limits the maximum datagram size that can be received over tcp. | ||
+ | |||
+ | Default: 4096, can be changed at runtime. | ||
+ | |||
+ | |||
+ | ==== tcp_send_timeout ==== | ||
+ | |||
+ | Time in seconds after a TCP connection will be closed if it is not available for writing in this interval (and sip-router 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_timeout=3 | ||
+ | |||
+ | ==== tcp_source_ipv4, | ||
+ | |||
+ | 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_wq_blk_size ==== | ||
+ | Block size used for tcp async writes. It should be big enough to hold a few datagrams. If it's smaller then a datagram (in fact a tcp write()) size, it will be rounded up. It has no influenced on the number of datagrams queued (for that see tcp_conn_wq_max or tcp_wq_max). It has mostly debugging and testing value (can be ignored). | ||
+ | |||
+ | Default: 2100 (~ 2 INVITEs), can be changed at runtime. | ||
+ | |||
+ | ==== tcp_wq_max ==== | ||
+ | |||
+ | Maximum bytes queued for write allowed globally. It has no effect if tcp_write_buf is not enabled. | ||
+ | |||
+ | tcp_wq_max = bytes (default 10 Mb) | ||
+ | |||
+ | ===== SCTP Parameters ===== | ||
+ | |||
+ | ==== disable_sctp ==== | ||
+ | |||
+ | Global parameter to disable SCTP support in the SIP server. see enable_sctp | ||
+ | |||
+ | Default value is ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | disable_sctp=yes | ||
+ | |||
+ | ==== enable_sctp ==== | ||
+ | |||
+ | enable_sctp = 0/1/2 - SCTP disabled (0)/ SCTP enabled (1)/auto (2), | ||
+ | | ||
+ | |||
+ | ==== sctp_children ==== | ||
+ | sctp children no (similar to udp children) | ||
+ | sctp_children = number | ||
+ | |||
+ | ==== sctp_socket_rcvbuf ==== | ||
+ | Size for the sctp socket receive buffer | ||
+ | |||
+ | **Alias name: sctp_socket_receive_buffer** | ||
+ | |||
+ | sctp_socket_rcvbuf = number | ||
+ | |||
+ | ==== sctp_socket_sndbuf ==== | ||
+ | Size for the sctp socket send buffer | ||
+ | |||
+ | **Alias name: sctp_socket_send_buffer** | ||
+ | |||
+ | sctp_socket_sndbuf = number | ||
+ | |||
+ | ==== sctp_autoclose ==== | ||
+ | Number of seconds before autoclosing an idle association (default: 180 s). Can be changed at runtime, but it will affect only new associations. E.g.: | ||
+ | $ sercmd cfg.set_now_int sctp autoclose 120 | ||
+ | |||
+ | sctp_autoclose = seconds | ||
+ | |||
+ | ==== sctp_send_ttl ==== | ||
+ | Number of milliseconds before an unsent message/ | ||
+ | $ sercmd cfg.set_now_int sctp send_ttl 180000 | ||
+ | |||
+ | sctp_send_ttl = milliseconds - n | ||
+ | |||
+ | ==== sctp_send_retries ==== | ||
+ | How many times to attempt re-sending a message on a re-opened association, | ||
+ | |||
+ | WARNING: use with care and low values (e.g. 1-3) to avoid " | ||
+ | |||
+ | sctp_send_retries = 1 | ||
+ | |||
+ | ==== sctp_assoc_tracking ==== | ||
+ | Controls whether or not sctp associations are tracked inside ser/ | ||
+ | |||
+ | Can be changed at runtime (sercmd 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 sctp_assoc_reuse was turned off). | ||
+ | |||
+ | Note: turning sctp_assoc_tracking on/off will delete all the tracking information for all the currently tracked associations and might introduce a small temporary delay in the sctp processing if lots of associations were tracked. | ||
+ | |||
+ | Config options depending on sctp_assoc_tracking being on: sctp_assoc_reuse. | ||
+ | |||
+ | sctp_assoc_tracking = yes/no | ||
+ | |||
+ | ==== sctp_assoc_reuse ==== | ||
+ | Controls sctp association reuse. For now only association reuse for replies is affected by it. Default: yes. | ||
+ | Depends on sctp_assoc_tracking being on. | ||
+ | |||
+ | Note that even if turned off, if the port in via corresponds to the source port of the association the request was sent on or if rport is turned on (force_rport() or via containing a rport option), the association will be automatically reused by the sctp stack. | ||
+ | Can be changed at runtime (sctp assoc_reuse), | ||
+ | |||
+ | sctp_assoc_reuse = yes/no | ||
+ | |||
+ | ==== sctp_max_assocs ==== | ||
+ | Maximum number of allowed open sctp associations. -1 means maximum allowed by the OS. Default: -1. | ||
+ | Can be changed at runtime (e.g.: | ||
+ | |||
+ | When ser/ | ||
+ | sctp_assoc_tracking is on. If on, the send triggering the active open will gracefully fail, before actually opening the new association and no packet will be sent. However if sctp_assoc_tracking is off, the association will first be opened and then immediately closed. In general this means that the initial sip packet will be sent (as part of the 4-way handshake). | ||
+ | |||
+ | ==== sctp_max_assocs ==== | ||
+ | |||
+ | sctp_max_assocs = number | ||
+ | |||
+ | ==== sctp_srto_initial ==== | ||
+ | Initial value of the retr. timeout, used in RTO calculations (default: OS specific). | ||
+ | |||
+ | Can be changed at runtime (sctp srto_initial) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_initial = milliseconds | ||
+ | |||
+ | ==== sctp_srto_max ==== | ||
+ | Maximum value of the retransmission timeout (RTO) (default: OS specific). | ||
+ | |||
+ | WARNING: values lower then the sctp sack_delay will cause lots of retransmissions and connection instability (see sctp_srto_min for more details). | ||
+ | |||
+ | Can be changed at runtime (sctp srto_max) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_max = milliseconds | ||
+ | |||
+ | ==== sctp_srto_min ==== | ||
+ | Minimum value of the retransmission timeout (RTO) (default: OS specific). | ||
+ | |||
+ | WARNING: values lower then the sctp sack_delay of any peer might cause retransmissions and possible interoperability problems. According to the standard the sack_delay should be between 200 and 500 ms, so avoid trying values lower then 500 ms unless you control all the possible sctp peers and you do make sure their sack_delay is higher or their sack_freq is 1. | ||
+ | |||
+ | Can be changed at runtime (sctp srto_min) but it will affect only new associations. | ||
+ | |||
+ | sctp_srto_min = milliseconds | ||
+ | |||
+ | ==== sctp_asocmaxrxt ==== | ||
+ | Maximum retransmissions attempts per association (default: OS specific). It should be set to sctp_pathmaxrxt * no. of expected paths. | ||
+ | |||
+ | Can be changed at runtime (sctp asocmaxrxt) but it will affect only new associations. | ||
+ | |||
+ | sctp_asocmaxrxt | ||
+ | |||
+ | ==== sctp_init_max_attempts ==== | ||
+ | Maximum INIT retransmission attempts (default: OS specific). | ||
+ | |||
+ | Can be changed at runtime (sctp init_max_attempts). | ||
+ | |||
+ | sctp_init_max_attempts = number | ||
+ | |||
+ | ==== sctp_init_max_timeo ==== | ||
+ | Maximum INIT retransmission timeout (RTO max for INIT). Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp init_max_timeo). | ||
+ | |||
+ | sctp_init_max_timeo = milliseconds | ||
+ | |||
+ | |||
+ | ==== sctp_hbinterval ==== | ||
+ | sctp heartbeat interval. Setting it to -1 will disable the heartbeats. Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp hbinterval) but it will affect only new associations. | ||
+ | |||
+ | sctp_hbinterval = milliseconds | ||
+ | |||
+ | ==== sctp_pathmaxrxt ==== | ||
+ | Maximum retransmission attempts per path (see also sctp_asocmaxrxt). Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp pathmaxrxt) but it will affect only new associations. | ||
+ | |||
+ | sctp_pathmaxrxt = number | ||
+ | |||
+ | ==== sctp_sack_delay ==== | ||
+ | Delay until an ACK is generated after receiving a packet. Default: OS specific. | ||
+ | |||
+ | WARNING: a value higher then srto_min can cause a lot of retransmissions (and strange problems). A value higher then srto_max will result in very high connections instability. According to the standard the sack_delay value should be between 200 and 500 ms. | ||
+ | |||
+ | Can be changed at runtime (sctp sack_delay) but it will affect only new associations. | ||
+ | |||
+ | sctp_sack_delay = milliseconds | ||
+ | |||
+ | ==== sctp_sack_freq ==== | ||
+ | Number of packets received before an ACK is sent (without waiting for the sack_delay to expire). | ||
+ | |||
+ | Note: on linux with lksctp up to and including 1.0.9 is not possible to set this value (having it in the config will produce a warning on startup). | ||
+ | |||
+ | Can be changed at runtime (sctp sack_freq) but it will affect only new associations. | ||
+ | |||
+ | sctp_sack_freq = number | ||
+ | |||
+ | ==== sctp_max_burst ==== | ||
+ | Maximum burst of packets that can be emitted by an association. Default: OS specific. | ||
+ | |||
+ | Can be changed at runtime (sctp max_burst) but it will affect only new associations. | ||
+ | |||
+ | sctp_max_burst = number | ||
+ | |||
+ | |||
+ | ===== Blacklist Parameters ===== | ||
+ | |||
+ | ==== dst_blacklist_expire ==== | ||
+ | |||
+ | **Alias name: dst_blacklist_ttl** | ||
+ | |||
+ | How much time a blacklisted destination will be kept in the blacklist (w/o any update). | ||
+ | |||
+ | dst_blacklist_expire = time in s (default 60 s) | ||
+ | |||
+ | ==== dst_blacklist_gc_interval ==== | ||
+ | How often the garbage collection will run (eliminating old, expired entries). | ||
+ | |||
+ | dst_blacklist_gc_interval = time in s (default 60 s) | ||
+ | |||
+ | ==== dst_blacklist_init ==== | ||
+ | If off, the blacklist is not initialized at startup and cannot be enabled runtime, that saves some memory. | ||
+ | |||
+ | dst_blacklist_init = on | off (default on) | ||
+ | |||
+ | ==== dst_blacklist_mem ==== | ||
+ | Maximum shared memory amount used for keeping the blacklisted destinations. | ||
+ | |||
+ | dst_blacklist_mem = size in Kb (default 250 Kb) | ||
+ | |||
+ | ==== use_dst_blacklist ==== | ||
+ | Enable the destination blacklist: Each failed send attempt will cause the destination to be added to the blacklist. Before any send, this blacklist will be checked and if a match is found, the send is no longer attempted (an error is returned immediately). | ||
+ | |||
+ | Note: using the blacklist incurs a small performance penalty. | ||
+ | |||
+ | See also doc/ | ||
+ | |||
+ | use_dst_blacklist = on | off (default off) | ||
+ | |||
+ | ===== Real-Time Parameters ===== | ||
+ | ==== real_time ==== | ||
+ | |||
+ | Sets real time priority for all the ser processes, or the timers (bitmaks). | ||
+ | | ||
+ | 1 - the " | ||
+ | 2 - the " | ||
+ | 4 - all processes, except the timers | ||
+ | | ||
+ | |||
+ | real_time = <int> (flags) (default off) | ||
+ | |||
+ | ==== rt_policy ==== | ||
+ | Real time scheduling policy, 0 = SCHED_OTHER, | ||
+ | |||
+ | rt_policy= < | ||
+ | |||
+ | ==== rt_prio ==== | ||
+ | Real time priority used for everything except the timers, if real_time is enabled. | ||
+ | |||
+ | rt_prio = <int> (default 0) | ||
+ | |||
+ | ==== rt_timer1_policy ==== | ||
+ | |||
+ | **Alias name: rt_ftimer_policy** | ||
+ | |||
+ | Like rt_policy but for the " | ||
+ | |||
+ | rt_timer1_policy=< | ||
+ | |||
+ | ==== rt_timer1_prio ==== | ||
+ | |||
+ | **Alias name: rt_fast_timer_prio, | ||
+ | |||
+ | Like rt_prio but for the " | ||
+ | |||
+ | rt_timer1_prio=< | ||
+ | |||
+ | ==== rt_timer2_policy ==== | ||
+ | |||
+ | **Alias name: rt_stimer_policy** | ||
+ | |||
+ | Like rt_policy but for the " | ||
+ | |||
+ | rt_timer2_policy=< | ||
+ | |||
+ | ==== rt_timer2_prio ==== | ||
+ | |||
+ | **Alias name: rt_stimer_prio** | ||
+ | |||
+ | Like rt_prio but for the " | ||
+ | |||
+ | rt_timer2_prio=< | ||
+ | ===== Core functions ===== | ||
+ | |||
+ | Functions exported by core that can be used in route blocks. | ||
+ | |||
+ | ==== add_local_rport ==== | ||
+ | |||
+ | Add **rport** parameter to local generated Via header -- see RFC3581. In effect for forwarded SIP requests. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | add_local_rport(); | ||
+ | </ | ||
+ | ==== append_branch ==== | ||
+ | |||
+ | Similarly to t_fork_to, it extends destination set by a new entry. The difference is that current URI is taken as new entry. | ||
+ | |||
+ | Without parameter, the function copies the current URI into a new branch. Thus, leaving the main branch (the URI) for further manipulation. | ||
+ | |||
+ | With a parameter, the function copies the URI in the parameter into a new branch. Thus, the current URI is not manipulated. Note: append_branch(uri) still copies the destination URI, which is usually nto what you want. Thus it is better to call append_branch without parameter and then modify the main branch. | ||
+ | |||
+ | Note that it's not possible to append a new branch in " | ||
+ | |||
+ | Example of usage: | ||
+ | < | ||
+ | # if someone calls B, the call should be forwarded to C too. | ||
+ | # | ||
+ | if (method==" | ||
+ | { | ||
+ | # copy the current branch (branches[0]) into | ||
+ | # a new branch (branches[1]) | ||
+ | append_branch(); | ||
+ | # all URI manipulation functions work on branches[0] | ||
+ | # thus, URI manipulation does not touch the | ||
+ | # appended branch (branches[1]) | ||
+ | seturi(" | ||
+ | | ||
+ | # now: branch 0 = C@domain | ||
+ | # branch 1 = B@xx.xx.xx.xx | ||
+ | | ||
+ | # and if you need a third destination ... | ||
+ | | ||
+ | # copy the current branch (branches[0]) into | ||
+ | # a new branch (branches[2]) | ||
+ | append_branch(); | ||
+ | | ||
+ | # all URI manipulation functions work on branches[0] | ||
+ | # thus, URI manipulation does not touch the | ||
+ | # appended branch (branches[1-2]) | ||
+ | seturi(" | ||
+ | | ||
+ | # now: branch 0 = D@domain | ||
+ | # branch 1 = B@xx.xx.xx.xx | ||
+ | # branch 2 = C@domain | ||
+ | | ||
+ | t_relay(); | ||
+ | exit; | ||
+ | }; | ||
+ | |||
+ | # You could also use append_branch(" | ||
+ | | ||
+ | | ||
+ | if(method==" | ||
+ | # append a new branch with the second destionation | ||
+ | append_branch(" | ||
+ | # now: branch 0 = B@xx.xx.xx.xx | ||
+ | # now: branch 1 = C@domain | ||
+ | |||
+ | t_relay(); | ||
+ | exit; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== avpflags ==== | ||
+ | ==== break ==== | ||
+ | |||
+ | ' | ||
+ | |||
+ | ==== drop ==== | ||
+ | |||
+ | Stop the execution of the configuration script and alter the implicit action which is done afterwards. | ||
+ | |||
+ | If the function is called in a ' | ||
+ | |||
+ | If the function is called in a ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | onreply_route { | ||
+ | if(status==" | ||
+ | drop(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ==== exit ==== | ||
+ | |||
+ | Stop the execution of the configuration script -- it has the same behaviour as return(0) in the top level route, but is not equivalent to return(0) from any called route. exit will terminate wherever it is called, while return(0) will not terminate the script in any called route. exit does not affect the implicit action to be taken after script execution. | ||
+ | |||
+ | route { | ||
+ | if (route(2)) { | ||
+ | xlog(" | ||
+ | } else { | ||
+ | xlog(" | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | route[2] { | ||
+ | if (is_method(" | ||
+ | return(1); | ||
+ | } else if (is_method(" | ||
+ | return(-1); | ||
+ | } else if (is_method(" | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | }; | ||
+ | } | ||
+ | |||
+ | ==== error ==== | ||
+ | |||
+ | ==== exec ==== | ||
+ | |||
+ | ==== force_rport ==== | ||
+ | |||
+ | Force_rport() adds the rport parameter to the first Via header of the received message. Thus, SIP server will add the received | ||
+ | |||
+ | This is useful for NAT traversal, to enforce symmetric response signaling. | ||
+ | |||
+ | The rport parameter is defined in RFC 3581. | ||
+ | |||
+ | Note: there is also a force_rport parameter which changes the gobal behavior of the SIP proxy. | ||
+ | |||
+ | Example 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 " | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | force_send_socket(10.10.10.10: | ||
+ | |||
+ | ==== force_tcp_alias ==== | ||
+ | |||
+ | **Alias name: add_tcp_alias** | ||
+ | |||
+ | force_tcp_alias(port) | ||
+ | |||
+ | adds a tcp port alias for the current connection (if tcp). | ||
+ | Usefull if you want to send all the trafic to port_alias through | ||
+ | the same connection this request came from [it could help | ||
+ | for firewall or nat traversal]. | ||
+ | With no parameters adds the port from the message via as the alias. | ||
+ | When the " | ||
+ | much time), all the port aliases are removed. | ||
+ | |||
+ | ==== forward ==== | ||
+ | |||
+ | Forward the SIP request to the given destination in stateless mode. This has the format of forward_proto(host, | ||
+ | If proto or port are not specified, NAPTR and SRV lookups will be used to determine them (if possible). | ||
+ | |||
+ | If destination parameter is missing, the forward will be done based on RURI. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | forward(" | ||
+ | #or | ||
+ | forward(); | ||
+ | |||
+ | ==== forward_sctp ==== | ||
+ | |||
+ | ==== forward_tcp ==== | ||
+ | |||
+ | ==== forward_tls ==== | ||
+ | |||
+ | ==== forward_udp ==== | ||
+ | |||
+ | ==== 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 http:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | if(isflagset(3)) { | ||
+ | log(" | ||
+ | }; | ||
+ | |||
+ | |||
+ | SIP-Router also supports named flags. They have to be declared at the beginning of the config file with: | ||
+ | |||
+ | | ||
+ | |||
+ | Example: | ||
+ | flags test, a:1, b:2 ; | ||
+ | | ||
+ | setflag(test); | ||
+ | if (isflagset(a)){ # equiv. to isflagset(1) | ||
+ | .... | ||
+ | } | ||
+ | resetflag(b); | ||
+ | |||
+ | |||
+ | |||
+ | ==== log ==== | ||
+ | |||
+ | Write text message to standard error terminal or syslog. You can specify the log level as first parameter. | ||
+ | |||
+ | For more see: http:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | log(" | ||
+ | |||
+ | |||
+ | ==== prefix ==== | ||
+ | |||
+ | Add the string parameter in front of username in R-URI. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | prefix(" | ||
+ | |||
+ | ==== resetavpflag ==== | ||
+ | |||
+ | ==== resetflag ==== | ||
+ | |||
+ | ==== return ==== | ||
+ | |||
+ | The return() function allows you to return any integer value from a called route() block. | ||
+ | You can test the value returned by a route using [[devel# | ||
+ | |||
+ | return(0) is same as [[devel# | ||
+ | |||
+ | In bool expressions: | ||
+ | |||
+ | * Negative and ZERO is FALSE | ||
+ | * Positive is TRUE | ||
+ | |||
+ | If no value is specified, or a route reaches its end without executing a return statement, it returns 1. If return is used in the top level route is equivalent with exit [val]. | ||
+ | |||
+ | Example usage: | ||
+ | |||
+ | < | ||
+ | route { | ||
+ | if (route(2)) { | ||
+ | xlog(" | ||
+ | } else { | ||
+ | xlog(" | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
+ | < | ||
+ | route[2] { | ||
+ | if (is_method(" | ||
+ | return(1); | ||
+ | } else if (is_method(" | ||
+ | return(-1); | ||
+ | } else { | ||
+ | return(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, | ||
+ | |||
+ | Rewrite the domain part and port of the R-URI with the value of function' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewritehostport(" | ||
+ | |||
+ | ==== rewritehostporttrans ==== | ||
+ | |||
+ | **Alias name: sethostporttrans, | ||
+ | |||
+ | Rewrite the domain part and port of the R-URI with the value of function' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewritehostporttrans(???" | ||
+ | |||
+ | ==== rewritehost ==== | ||
+ | |||
+ | **Alias name: sethost, seth** | ||
+ | |||
+ | Rewrite the domain part of the R-URI with the value of function' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewritehost(" | ||
+ | |||
+ | ==== rewriteport ==== | ||
+ | |||
+ | **Alias name: setport, setp** | ||
+ | |||
+ | Rewrites/ | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewriteport(" | ||
+ | |||
+ | ==== rewriteuri ==== | ||
+ | |||
+ | **Alias name: seturi** | ||
+ | |||
+ | Rewrite the request URI. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewriteuri(" | ||
+ | |||
+ | ==== rewriteuserpass ==== | ||
+ | |||
+ | **Alias name: setuserpass, | ||
+ | |||
+ | Rewrite the password part of the R-URI with the value of function' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewriteuserpass(" | ||
+ | ==== rewriteuser ==== | ||
+ | |||
+ | **Alias name: setuser, setu** | ||
+ | |||
+ | Rewrite the user part of the R-URI with the value of function' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | rewriteuser(" | ||
+ | |||
+ | ==== route ==== | ||
+ | |||
+ | Execute route block given in parameter. | ||
+ | |||
+ | Examples of usage: | ||
+ | |||
+ | route(REGISTER_REQUEST); | ||
+ | route(@received.proto + " | ||
+ | |||
+ | ==== send ==== | ||
+ | |||
+ | Send the original SIP message to a specific destination in stateless mode. No changes are applied to received message, no Via header is added. Host can be an IP or hostname. Used protocol: UDP | ||
+ | |||
+ | Parameter is mandatory and has string format. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | | ||
+ | |||
+ | ==== send_tcp ==== | ||
+ | |||
+ | Send the original SIP message to a specific destination in stateless mode. No changes are applied to received message, no Via header is added. Host can be an IP or hostname. Used protocol: UDP | ||
+ | |||
+ | Parameter is mandatory and has string format. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | | ||
+ | |||
+ | ==== set_advertised_address ==== | ||
+ | |||
+ | Same as ' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | set_advertised_address(" | ||
+ | |||
+ | ==== set_advertised_port ==== | ||
+ | |||
+ | Same as ' | ||
+ | |||
+ | 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 retransission for tcp/tls). | ||
+ | |||
+ | * onreply_route[0] (stateless): | ||
+ | |||
+ | * onreply_route[!=0] (tm): ignored | ||
+ | |||
+ | * branch_route: | ||
+ | |||
+ | * onsend_route: | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route { | ||
+ | ... | ||
+ | if (lookup()) { | ||
+ | //requests to local users. They are usually behind NAT so it does not make sense to try | ||
+ | //to establish a new TCP connection | ||
+ | set_forward_no_connect(); | ||
+ | t_relay(); | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ==== set_forward_close ==== | ||
+ | |||
+ | Try to close the connection (the one on which the message is sent out) after forwarding the current message. Can be used in same route blocks as set_forward_no_connect(). | ||
+ | |||
+ | Note: Use with care as you might not receive the replies anymore as the connection is closed. | ||
+ | |||
+ | |||
+ | ==== set_reply_no_connect ==== | ||
+ | |||
+ | Like set_forward_no_connect(), | ||
+ | |||
+ | * normal request route: affects all replies sent back on the transaction (either local or forwarded) and all local stateless replies (sl_reply()). | ||
+ | |||
+ | * onreply_route: | ||
+ | |||
+ | * branch_route: | ||
+ | |||
+ | * onsend_route: | ||
+ | |||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route[4] { | ||
+ | //requests from local users. There are usually behind NAT so it does not make sense to try | ||
+ | //to establish a new TCP connection for the replies | ||
+ | set_reply_no_connect(); | ||
+ | // do authentication and call routing | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ==== set_reply_close ==== | ||
+ | |||
+ | Like set_reply_no_connect, | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | route { | ||
+ | ... | ||
+ | if (...caller-is-not-registered...) { | ||
+ | // reject unregistered client | ||
+ | // if request was received via TCP/TLS close the connection, as | ||
+ | // this may trigger re-registration of the client. | ||
+ | set_reply_close(); | ||
+ | sl_send_reply(" | ||
+ | exit; | ||
+ | } | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | |||
+ | ==== setavpflag ==== | ||
+ | |||
+ | ==== setflag ==== | ||
+ | |||
+ | Set a flag for current processed message. The value of the parameter can be in range of 0..31. The flags are used to mark the message for special processing (e.g., accounting) or to keep some state (e.g., message authenticated). | ||
+ | |||
+ | For more see http:// | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | setflag(3); | ||
+ | |||
+ | ==== strip ==== | ||
+ | |||
+ | Strip the first N-th characters from username of R-URI (N is the value of the parameter). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | strip(3); | ||
+ | |||
+ | ==== strip_tail ==== | ||
+ | |||
+ | Strip the last N-th characters from username of R-URI (N is the value of the parameter). | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | strip_tail(3); | ||
+ | |||
+ | ==== udp_mtu_try_proto(proto) ==== | ||
+ | |||
+ | * proto - TCP|TLS|SCTP|UDP - like udp_mtu_try_proto global parameter but works on a per packet basis and not globally. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | < | ||
+ | if($rd==" | ||
+ | udp_mtu_try_proto(SCTP); | ||
+ | </ | ||
+ | |||
+ | ==== userphone ==== | ||
+ | |||
+ | ===== Routing blocks ===== | ||
+ | |||
+ | SIP-Router has support for named routes. Names can be used instead of numbers in all the route commads or route declarations. | ||
+ | |||
+ | Note: route(number) is equivalent to route(" | ||
+ | |||
+ | Example: | ||
+ | route{ | ||
+ | ... | ||
+ | route(" | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | route[" | ||
+ | ... | ||
+ | } | ||
+ | |||
+ | ==== route ==== | ||
+ | |||
+ | Request routing block. It contains a set of actions to be taken for SIP requests. | ||
+ | |||
+ | The main ' | ||
+ | |||
+ | 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 must be called inside the route block. | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | route { | ||
+ | | ||
+ | # send reply for each options request | ||
+ | sl_send_reply(" | ||
+ | exit(); | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | route[1] { | ||
+ | # forward according to uri | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== branch_route ==== | ||
+ | |||
+ | Request' | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | route { | ||
+ | lookup(" | ||
+ | t_on_branch(" | ||
+ | if(!t_relay()) { | ||
+ | sl_send_reply(" | ||
+ | } | ||
+ | } | ||
+ | branch_route[1] { | ||
+ | if(uri=~" | ||
+ | # discard branches that go to 10.10.10.10 | ||
+ | drop(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== failure_route ==== | ||
+ | |||
+ | Failed transaction routing block. It contains a set of actions to be taken each transaction that received only negative replies (>=300) for all branches. The ' | ||
+ | |||
+ | Note that in ' | ||
+ | |||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | <code c> | ||
+ | route { | ||
+ | lookup(" | ||
+ | t_on_failure(" | ||
+ | if(!t_relay()) { | ||
+ | sl_send_reply(" | ||
+ | } | ||
+ | } | ||
+ | failure_route[1] { | ||
+ | if(is_method(" | ||
+ | # call failed - relay to voice mail | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== onreply_route ==== | ||
+ | |||
+ | |||
+ | Reply routing block. It contains a set of actions to be taken for SIP replies. | ||
+ | |||
+ | The main ' | ||
+ | |||
+ | Certain ' | ||
+ | |||
+ | Main ' | ||
+ | |||
+ | <code c> | ||
+ | route { | ||
+ | lookup(" | ||
+ | t_on_reply(" | ||
+ | if(!t_relay()) { | ||
+ | sl_send_reply(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | onreply_route { | ||
+ | if(!t_check_trans()) { | ||
+ | drop; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | onreply_route[1] { | ||
+ | if(status=~" | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== onsend_route ==== | ||
+ | |||
+ | The route is executed in when a SIP request is sent out. Only a limited number of commands are allowed (drop, if + all the checks, msg flag manipulations, | ||
+ | |||
+ | In this route the final destination of the message is available an can be checked (with snd_ip, snd_port, to_ip, to_port, snd_proto, snd_af). | ||
+ | |||
+ | This route is executed only when forwarding requests - it is not executed for replies, retransmissions, | ||
+ | |||
+ | Example: | ||
+ | onsend_route{ | ||
+ | if(to_ip==1.2.3.4 && !isflagset(12)){ | ||
+ | log(1, " | ||
+ | drop; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | * snd_ip, snd_port - behave like src_ip/ | ||
+ | * to_ip, to_port - like above, but contain the ip/port the message will be sent to (not to be confused with dst_ip/ | ||
+ | * snd_proto, snd_af - behave like proto/af but contain the protocol/ | ||
+ | * msg:len - when used in an onsend_route, | ||
+ | |||
+ | ==== event_route ==== | ||
+ | |||
+ | Generic type of route executed when specific events happen. | ||
+ | |||
+ | Prototype: event_route[groupid: | ||
+ | * groupid - should be the name of the module that triggers the event | ||
+ | * eventid - some meaningful short text describing the event | ||
+ | |||
+ | Implementations: | ||
+ | * **event_route[htable: | ||
+ | <code c> | ||
+ | modparam(" | ||
+ | |||
+ | event_route[htable: | ||
+ | $sht(a=> | ||
+ | $sht(a=> | ||
+ | } | ||
+ | |||
+ | route { | ||
+ | if(is_method(" | ||
+ | { | ||
+ | switch($rd) { | ||
+ | case " | ||
+ | lock(" | ||
+ | $sht(a=> | ||
+ | $sht(a=> | ||
+ | unlock(" | ||
+ | if($sht(a=> | ||
+ | { | ||
+ | | ||
+ | exit; | ||
+ | } | ||
+ | break; | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | * **event_route [tm: | ||
+ | <code c> | ||
+ | event_route [tm: | ||
+ | xlog(" | ||
+ | t_set_fr(10000, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Script statements ===== | ||
+ | |||
+ | ==== if ==== | ||
+ | IF-ELSE statement | ||
+ | |||
+ | Prototype: | ||
+ | |||
+ | < | ||
+ | if(expr) { | ||
+ | | ||
+ | } else { | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The ' | ||
+ | |||
+ | The logical operators that can be used in ' | ||
+ | |||
+ | * == - equal | ||
+ | * != - not equal | ||
+ | * =~ - regular expression matching | ||
+ | * !~ - regular expression not-matching | ||
+ | * > - greater | ||
+ | * >= - greater or equal | ||
+ | * < - less | ||
+ | * <= - less or equal | ||
+ | * && - logical AND | ||
+ | * || - logical OR | ||
+ | * ! - logical NOT | ||
+ | * [ ... ] - test operator - inside can be any arithmetic expression | ||
+ | |||
+ | Example of usage: | ||
+ | |||
+ | if(is_method(" | ||
+ | { | ||
+ | log(" | ||
+ | } else { | ||
+ | log(" | ||
+ | } | ||
+ | |||
+ | |||
+ | ==== switch ==== | ||
+ | |||
+ | SWITCH statement - it can be used to test the value of a pseudo-variable. The variable can be tested against integers, strings or regular expressions. A regular expression start with a / followed by a string within quotes. | ||
+ | |||
+ | **break** can be used to jump out of the switch statement from any part of the case blocks, like in C or Java. | ||
+ | |||
+ | |||
+ | Example of usage: | ||
+ | < | ||
+ | route { | ||
+ | route(1); | ||
+ | switch($rc) | ||
+ | { | ||
+ | case -1: | ||
+ | log(" | ||
+ | break; | ||
+ | case 1: | ||
+ | log(" | ||
+ | break; | ||
+ | case 2: | ||
+ | case 3: | ||
+ | log(" | ||
+ | break; | ||
+ | default: | ||
+ | log(" | ||
+ | } | ||
+ | |||
+ | # switch of R-URI username | ||
+ | switch($rU) | ||
+ | { | ||
+ | case " | ||
+ | log(" | ||
+ | break; | ||
+ | case " | ||
+ | log(" | ||
+ | break; | ||
+ | case " | ||
+ | case /" | ||
+ | log(" | ||
+ | break; | ||
+ | default: | ||
+ | log(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | route[1]{ | ||
+ | if(is_method(" | ||
+ | { | ||
+ | return(-1); | ||
+ | }; | ||
+ | if(is_method(" | ||
+ | return(1); | ||
+ | } | ||
+ | if(is_method(" | ||
+ | return(2); | ||
+ | } | ||
+ | if(is_method(" | ||
+ | return(3); | ||
+ | } | ||
+ | return(-2); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | NOTE: take care while using ' | ||
+ | |||
+ | |||
+ | ==== while ==== | ||
+ | |||
+ | while statement | ||
+ | |||
+ | Example of usage: | ||
+ | | ||
+ | $var(i) = 0; | ||
+ | while($var(i) < 10) | ||
+ | { | ||
+ | xlog(" | ||
+ | $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 ' | ||
+ | * AVPs - to set the value of an AVP | ||
+ | * script variables ($var(...)) - to set the value of a script variable | ||
+ | * shared variables ($shv(...)) | ||
+ | * $ru - to set R-URI | ||
+ | * $rd - to set domain part of R-URI | ||
+ | * $rU - to set user part of R-URI | ||
+ | * $rp - to set the port of R-URI | ||
+ | * $du - to set dst URI | ||
+ | * $fs - to set send socket | ||
+ | * $br - to set branch | ||
+ | * $mf - to set message flags value | ||
+ | * $sf - to set script flags value | ||
+ | * $bf - to set branch flags value | ||
+ | |||
+ | < | ||
+ | $var(a) = 123; | ||
+ | </ | ||
+ | |||
+ | Note that for the avps, an assignment means adding a new value to the AVP list with the same name. If you want to remove old AVPs with same name, use index [*], like | ||
+ | < | ||
+ | $(avp(i: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== String operations ==== | ||
+ | For strings, ' | ||
+ | |||
+ | < | ||
+ | $var(a) = " | ||
+ | $var(b) = " | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Arithmetic operations ==== | ||
+ | |||
+ | For numbers, one can use: | ||
+ | |||
+ | * + : plus | ||
+ | * - : minus | ||
+ | * / : divide | ||
+ | * * : multiply | ||
+ | * mod : modulo (SER used % which might work in future versions too) | ||
+ | * | : 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(" | ||
+ | </ | ||
+ | |||
+ | ===== Operators ===== | ||
+ | |||
+ | - type casts operators: (int), (str). | ||
+ | - string comparison: eq, ne | ||
+ | - integer comparison: ieq, ine | ||
+ | |||
+ | Note: The names are not yet final (use them at your own risk). Future version might use | ||
+ | | ||
+ | |||
+ | Non equiv. examples: | ||
+ | |||
+ | |||
+ | = = "" | ||
+ | |||
+ | " | ||
+ | |||
+ | = = " | ||
+ | |||
+ | Note: internally | ||
+ | - = = and != are converted on startup to eq/ | ||
+ | |||
+ | - sip-router tries to guess what the user wanted when operators that support multiple types are used on different typed operands. In general convert the right operand to the type of the left operand and then perform the operation. Exception: the left operand is undef. This applies to the following operators: +, = = and !=. | ||
+ | | ||
+ | For +: undef + expr -> undef is converted to string => "" | ||
+ | For = = and !=: undef = = expr -> undef is converted to type_of expr. | ||
+ | If expr is undef, then undef = = undef is true (internally is converted | ||
+ | to string). | ||
+ | |||
+ | - expression evaluation changes: sip-router will auto-convert to integer or string in function of the operators: | ||
+ | | ||
+ | | ||
+ | |||
+ | - script operators for dealing with empty/ | ||
+ | defined expr - returns true if expr is defined, and false if not. | ||
+ | Note: only a standalone avp or pvar can be | ||
+ | | ||
+ | strlen(expr) - returns the lenght of expr evaluated as string. | ||
+ | strempty(expr) - returns true if expr evaluates to the empty | ||
+ | | ||
+ | Example: if (defined $v && !strempty($v)) $len=strlen($v);/ | ||
+ | | ||
+ | |||