– Kamailio SIP Server –

Migrating Kamailio v1.5.x to Kamailio v3.0.0

Note: This is not a full list. There are much more changes than stated in this document. E.g. haven't found the change for memlog=0 yet … … http://www.kamailio.org/dokuwiki/doku.php/core-cookbook:3.1.x?s[]=memlog#memlog

Changes in core

* Kamailio 3.0.0 is first release that uses the core of http://sip-router.org project

* IMPORTANT put next line first in your config file

#!KAMAILIO
  • run in Kamailio config compatibility mode
    • auto-correct TM parameter timer values: in 3.0 they are in mili-seconds, in 1.5 they are seconds, therefore if the value is too low (< = 120), then use T * 1000
    • accept TM avp parameters in K-style: $avp(name)

Changes in modules

* Kamailio 3.0.0 is first release that uses the TM module of http://sip-router.org project * kex and tmx modules must be loaded – they provide functionalities existing in core or tm of Kamailio 1.5.x

Changes in database schema

LCR

  • table lcr has one new column (table version is 3):
    • lcr_id SMALLINT UNSIGNED NOT NULL
  • table gw has two new columns and one column removed (table version is 10):
    • lcr_id SMALLINT UNSIGNED NOT NULL
    • defunct INT UNSIGNED DEFAULT NULL
    • ping column has been removed

Dialog

  • table dialog has one new column (table version is 4):
    • req_uri VARCHAR(128) NOT NULL

Permissions

  • table trusted has one column definition updated (table version is 5):
    • tag VARCHAR(64)

Tips for migration to Kamailio 3.0.0

The section collects tips to migrate Kamailio 1.5.x to 3.0.0 in order to get as much compatibility and functionality as possible. There are Kamailio 1.5.x functions that do not exist in Kamailio 3.0.0, but alternatives are available to get more or less same behaviour.

TCP Connection Lifetime

  • registrar module in Kamailio 1.5.x has support to set automatically the lifetime of the TCP connection for current processed SIP REGISTER message.
  • in 3.0.0 similar functionality can be achieved by setting tcp_connection_lifetime config parameters just a bit higher than max registration expire. The lifetime for a TCP connection is automatically extended when a message is going through. In case of hard/soft phones, the connection is closed by client side when they shut down.

Log levels

  • the logging in kamailio 3.0.0 uses different values for each level. You can get the corresponding level by simple subtracting “1” from the value you used in kamailio 1.5.x. For example the INFO level in kamailio 1.5.x (3) is “2” in 3.0.0.

Module loading

  • The mpath statement is also available in kamailio 3.0.0, being an alias to loadpath parameter. In addition, you can omit the “.so” from each loadmodule statement, as this is automatically appended.

http://www.kamailio.org/dokuwiki/doku.php/core-cookbook:3.0.x#loadpath

Branch Flags Operations

  • functions are implemented now by kex module. The parameters must be enclosed in double quotes and they can be pseudo-variables with integer values:

http://kamailio.org/docs/modules/3.0.x/modules_k/kex.html

Script Flags Operations

  • functions are implemented now by kex module. The parameters must be enclosed in double quotes and they can be pseudo-variables with integer values:

http://kamailio.org/docs/modules/3.0.x/modules_k/kex.html

Dst URI Operations

  • functions setdsturi(uri), resetdsturi() and isdsturiset() are implemented now by kex module. The syntax is the same:

http://kamailio.org/docs/modules/3.0.x/modules_k/kex.html

TM Extensions

  • several TM extensions are now part of TMX module

http://kamailio.org/docs/modules/3.0.x/modules_k/tmx.html

Core parameters

  • avp_aliases is a parameter of PV module

http://kamailio.org/docs/modules/3.0.x/modules_k/pv.html

  • disable_dns_blacklist is replaced by dns_cache_negative_ttl

http://www.kamailio.org/dokuwiki/doku.php/core-cookbook:3.0.x#dns_cache_negative_ttl

  • disable_dns_failover is replaced by use_dns_failover

By default, use_dns_failover is currently “off”.

Core Functions

  • append_branch() - fully Kamailio 1.5.x append_branch() function is now implemented by kex module and it is named km_append_branch(). See:

Script syntax

Test operator [...]

  • test operator […] is does not exist. Same operation is supported directly in conditional expressions.

Bit tests must be written in conditions without brackets [ and ], for example,

    if ($var(a) & 4)
        log("var a has third bit set\n");

Operator :=

  • := used in Kamailio 1.5.x for AVPs - delete all then add - is not available in Kamailio 3.0.0. Same functionality is given by assignment when providing index 'all' to the right AVP. See example:
   # Kamailio 1.5.x: $avp(abc) := 'xyz';
   $(avp(abc)[*]) = 'xyz';
 
   # Kamailio 1.5.x: $avp(abc) := null;
   $(avp(abc)[*]) = $null;

Modulo %

  • % must be replaced wit mod (% conflicted with selects marker)
$var(x) = $var(y) mod 5;

Module parameters

  • tm onreply_avp_mode does not exist

In Kamailio 3.0.0, AVPs that are set in request route are always visible in branch, TM-reply and failure routes. If you set AVPS in an onreply_route, they are also visible after execution of this onreply_route.

  • tm fr_timer, fr_inv_timer, wt_timer, delete_timer, and unix_tx_timeout units

In Kamailio 3.0.0, time value of the above parameters is given in milliseconds, whereas in Kamailio 1.5.x they are given in seconds (see tm timers for more details).

  • sl_send_reply

In Kamailio 3.x, if you use an AVP for the code parameter (first one), make sure to assign it an integer value. Example: old versions would accept these statements

$avp(s:example) = "404";
sl_send_reply("$avp(s:example)", "Some Reason");

But after 3.x Kamailio will tell you “Could not convert PV to int” in this case. Some possible workarounds are:

$avp(s:example) = 404;

or:

$avp(s:example) = (int) $avp(s:example);

Module functions

t_relay

  • t_relay() parameters have different meanings in 3.0.0. For parameter compatibility with 1.5.x you can use t_relay_to() instead. If no parameter is given, then you can keep using t_relay()

Translations:

1.5.x 3.0.0
t_relay() t_relay()
t_relay(proxy) t_relay_to(proxy)
t_relay(flags) t_relay_to(flags)
t_relay(proxy, flags) t_relay_to(proxy, flags)

Examples:

1.5.x 3.0.0
t_relay() t_relay()
t_relay(“udp:1.2.3.4”) t_relay_to(“udp:1.2.3.4”)
t_relay(“0x01”) t_relay_to(“0x01”)
t_relay(“udp:1.2.3.4”, “0x01”) t_relay_to(“udp:1.2.3.4”, “0x01”)
  • t_relay() tunings in 3.0.0

Module parameter “auto_inv_100” can be used to globally turn off generation of provisional replies (default is 1 “on”). It is also possible to dynamically control generation of provisional replies using function t_set_auto_inv_100().

Core parameter “use_dns_failover” can be used to globally turn off DNS failover (default is “off”).

  • t_relay() does not generate internally a negative reply. Negative reply is can always be generated explicitly from script. If not done, it is generated implicitly at the end of the script.

t_was_cancelled

  • t_was_cancelled() is replaced by t_is_canceled(). Watch out for the single “l”!

t_check_trans

  • t_check_trans() isn't true anymore on loose-routed e2e ACK.

See http://sip-router.org/docbook/sip-router/branch/3.1/modules/tm/tm.html#t_check_trans


Note that the e2e ACK matching is more of a hint then a certainty. A delayed e2e ACK might arrive after the transaction wait time elapses, when the INVITE transaction no longer exists and thus would not match anything. There are also cases when tm would not keep all the information needed for e2e ACK matching (since this is not needed for a statefull proxy and it requires additional memory, tm will not keep this information unless needed by some other module or callbacks).


Route blocks

  • error_route is not supported

Check request sanity at the beginning of script (see sanity module).

null keyword

null keyword is not present in Kamailio 3.0.0. Use pseudo-variable $null instead.

In addition, the operator defined can be used to check if a value is null or not.

if( ! defined $avp(x) ) {
   # the avp is null
   ...
}

not operator in if()

if (!$fd=~“regexp”) must now be written as if (!($fd=~“regexp”)) for what reason ever.

Notice: the operator !~ seems not to be working for some reason as well. e.g.: ($fd !~ 'not this') must be replaced with !($fd =~ 'not this')

empty tree

Some empty { } section are not possible anymore. E.g.

if (expr) {
   setflag(1);
} else if (expr) {
   # do nothing in this case
} else if (expr) {
   setflag(2);
} else {
   setflag(3);
}

gives a syntax error in the line behind the comment for whatever reason.