Tuesday, December 15, 2009

Best of New in Kamailio 3.0.0 - #1: include file

I'm starting a series of posts, to highlight the best new features in Kamailio (OpenSER) 3.0.0, of course, from my point of view, hoping to cover most of them before full 3.0.0 is out (RC3 was done yesterday).

First one to write about is the include_file support. Over the time, with addition of new features, the config file got bigger and bigger. Being in consultancy business, I have hundreds of config files and deployments to maintain. In terms of structure, there are some parts repeating in most of configs, like:
  • sanity checks
  • authentication
  • nat traversal
  • presence handling, a.s.0.
Every time I did an improvement, I had to update in all configs. Now, using the include_file, maintenance is much easier. Practically, you can break down the config in many files and have the master config just including them. For example, split of sanity checks:


if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
if ( msg:len >= 8192 ) {
sl_send_reply("513", "Message too big");
if ( is_method("NOTIFY") && uri==myself
&& $hdr(Event) =~ "keep-alive" )
sl_send_reply("200", "OK - keepalive");

Now, at the top of main route block in each config, I include the 'kamailio-sanity.cfg' file:


route {
include_file "kamailio-sanity.cfg"
Note that you can use include_file anywhere in your config file - included file must contain valid config statements for the part where is included (e.g., global parameters, modules loading, module parameters, routing actions, etc.).

Next is going to be about #!define support, which completes perfectly the include_file feature to ease the maintenance, troubleshooting and development of config files.

No comments:

Post a Comment