Kamailio Advanced Training
Click here for more details!

Learn how to build RTC services with Kamailio!

Wednesday, December 16, 2009

Best of New in Kamailio 3.0.0 - #2: define

The need of switching on or off features in Kamailio (OpenSER) 3.0.0 config file became more handy by addition of #!define directives support. There are five pre-processor directives:

#!define ID - define the ID
#!ifdef ID - test if ID is defined
#!ifndef ID - test if ID is not defined
#!else - create an else branch for ifdef/ifndef tests
#!endif - end an ifdef/ifndef block
Combining them, you can make parts of configuration file to be ignored at start time. For example, you can have in config a lot of xlog lines to help you troubleshooting, but you do not want them in a normal production environment. In your config you can have:

#!ifdef DEBUG_MODE
xlog("sip message from IP: $si and port $sp\r\n");
#!endif
To run in debug mode, add next line at the top of configuration file and then restart:

#!define DEBUG_MODE
For more examples, see Kamailio 3.0.0 default config file - authentication, NAT traversal, presence functionality, ... can be enabled or disabled via #!define.

Next to write about is route blocks with names.

No comments:

Post a Comment