Table of Contents

New features in Kamailio v3.1.0

The page collects the summary of the new features in Kamailio v3.1.0.

Release date: Oct 6, 2010.

Configuration file

Kamailio 3.1.0 comes with an enhanced configuration file, among additions:

New Kamailio modules

acc_radius

Example - send a Radius accounting request:

acc_rad_request("200 Start");

app_lua

Example sending a SIP reply through Lua:

lua_dostring("sr.sl.send_reply(200, [[Lua says is ok]])");

Presentation at Amoocon 2010 about how to send Twitter notifications from your SIP server using Lua, slides at:

Next is a Lua function showing how you get access to config pseudo-variables:

function my_append_hdr_ruri()
    sr.err("message to syslog from Lua\n")
    sr.hdr.append_to_reply("P-RUri: <" .. sr.pv.get("$ru") .. ">\r\n");
end

app_python

counters

Example - count requests for offline users:

modparam("counters", "script_counter", "location.offline requests for offline users")
...
route {
...
	if (!lookup("location"))
		cnt_inc("location.offline");
...
}

debugger

Example - execution trace:

 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=501 a=17 n=if
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=470 a=25 n=has_totag
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=386 a=17 n=if
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=379 a=26 n=is_method
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=386 a=25 n=t_check_trans
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=389 a=6 n=route
 9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=643 a=3 n=return

Example - interactive debugger:

sercmd> dbg.bp show 6402
at bkp [/etc/kamailio/debugger.cfg:369] a=6 n=route
 
sercmd> dbg.bp next 6402
exec [/etc/kamailio/debugger.cfg:369] a=6 n=route
 
sercmd> dbg.bp next 6402
exec [/etc/kamailio/debugger.cfg:462] a=17 n=if
 
sercmd> dbg.bp eval 6402 $fu
$fu : t=str v=sip:test@kamailio.org
 
sercmd> dbg.bp move 6402
200 ok

geoip

Example - blocking traffic from Canada:

geoip_match("$si", "src");
if($gip(src=>cc)=="CA") {
  xlog("SIP message from Canada (ip: $si) - drop it\n");
  send_reply("403", "Forbidden");
  exit;
}

matrix

mqueue

Example - adding and fetching items from a queue:

modparam("mqueue", "mqueue", "name=myq;size=0;")
...
route {
  mq_add("myq", "ruri", "$ru");
  mq_fetch("myq");
  xlog("SCRIPT: mqueue value ($ru): $mqk(myq) >> $mqv(myq)\n");

mtree

Example - load db table 'dids' in a tree named 'prefixes' and match against request URI username:

modparam("mtree", "mtree", "name=prefixes;dbtable=dids;type=0;")
 
route {
 
  if(!mt_match("prefixes", "$rU", "0")) {
     send_reply("404", "Not found");
     exit;
  }
 
}

pipelimit

# pipes per request type - e.g., INVITE
$var(p) = "$rm;
if (!pl_check("$var(p)")) {
  pl_drop();
  exit;
}

presence_conference

rtpproxy

textopsx

Example - change 603 replies to 404:

onreply_route {
    if (status == "603") {
        change_reply_status(404, "Not Found");
        exit;
    }
}

xcap_server

See a complete tutorial of using embedded XCAP server with SIP Communicator softphone:

xhttp

Next example shows how to send back a welcome message if HTTP URL starts with “/welcome”:

event_route[xhttp:request] {
  switch($hu) {
    case /"^/welcome":
      xhttp_reply("200", "OK", "text/html",
        "<html><body>Welcome! You are connected to us from [$si:$sp]</body></html>");
    break;
    default:
      xhttp_reply("404", "Not found", "text/html",
        "<html><body>Page not found</body></html>");
  }
}

xmlops

New in Old SIP Router modules

blst

dialog

dispatcher

lcr

msilo

nathelper

rtpproxy

pv

registrar

seas

tls

tm

tmx

Example:

event_route[xhttp:request] {
  if($hu =~ "^/cancel/")
  {
    t_cancel_callid("$(hu{s.select,2,/})", "$(hu{s.select,3,/})", "0");
    xhttp_reply("200", "ok", "text/html", "<html><body>cancelled</body></html>");
  }
}

uac

xlog

xlogl("this message is prefixed by config line number\n");

Integration of ser's config framework

New in Core

Asynchronous TLS

Statistics API

Module function prototypes

 f($a, "b = " + $b);  t_set_fr($v + 2 + $x).
 t_set_fr($foo) (equivalent now with t_set_fr("$foo")).
 f("7 *" +" 6 = " + 7 * 6);

UDP Raw Sockets

Extended config pre-processor directives

#!define MYINT 123
#!define MYSTR "xyz"
$var(x) = 100 + MYINT;
$var(x) = 100 + 123;
#!define IDLOOP $var(i) = 0; \
                while($var(i)<5) { \
                    xlog("++++ $var(i)\n"); \
                    $var(i) = $var(i) + 1; \
                }
route {
    ...
    IDLOOP
    ...
}
#!subst "/regexp/subst/"
#!subst "/DBPASSWD/xyz/"
modparam("acc", "db_url", "mysql://user:DBPASSWD@localhost/db")

Command Line Parameters

New Core Parameters

    Possible values:  0 -disabled, 2 - send error; 4 - connect error,
                      8 - icmp (reserverd), 16 - transaction timeout,
                     32 - 503 received, 64 - administratively prohibited
                     (manually set).

kamctl

siremis

route_graph

The tool located in utils/route_graph/ prints a nice text based graph of your configuration file, with the routing blocks and relations between them.