A new feature has landed to Kamailio devel version, bringing in more flexibility for preprocessing of the kamailio.cfg file.
It is about #!ifexp, which allows to evaluate an expression created with defined IDs, string and number values. Based on evaluation result, being true or false, parts of the config file can be enabled or disabled.
An extensive number of operators can be used in expressions, such as: +, -, *, /, ==, !=, <, >, <=, >=, ||, &&, etc. The evaluation is done using snexpr, which was embedded inside Kamailio code.
Here are some simple kamailio.cfg examples:
#!ifexp KAMAILIO_VERSION >= 5006000 loadmodule "tlsa.so" #!else loadmodule "tls.so" #!endif #!ifexp MOD_xlog && (OS_NAME == "darwin") xlog("running on MacOS\n"); #!endif
Documentation and more examples can be found on the wiki portal at:
Testing would be appreciated, feedback can be addressed to sr-users mailing list!
Enjoy!
Thanks for flying Kamailio!