This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
devel:config-engines [2016/05/03 13:47] miconda [To-Do] |
devel:config-engines [2016/05/03 19:04] miconda |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Configuration File Engines ====== | ====== Configuration File Engines ====== | ||
- | Kamailio implements from scratch the interpreter for its configuration file scripting language(used inside kamailio.cfg). | + | Kamailio implements from scratch the interpreter for its configuration file native |
Starting with v5.0.0, the routing blocks can be written in some other (well known) scripting languages and run via their embedded interpreters inside Kamailio. Known to work: | Starting with v5.0.0, the routing blocks can be written in some other (well known) scripting languages and run via their embedded interpreters inside Kamailio. Known to work: | ||
Line 34: | Line 34: | ||
* an extended set of data types, expressions and statements already available | * an extended set of data types, expressions and statements already available | ||
* a large set of extensions and libraries already available | * a large set of extensions and libraries already available | ||
- | | + | * good documentation about language itself and its extensions |
+ | | ||
Internally, the support for implementing routing logic in an embedded language is codenamed **KEMI** - Kamailio EMbedded Interface. | Internally, the support for implementing routing logic in an embedded language is codenamed **KEMI** - Kamailio EMbedded Interface. | ||
Line 40: | Line 41: | ||
===== Exporting Functions To KEMI ===== | ===== Exporting Functions To KEMI ===== | ||
- | The current | + | Because Kamailio needs to load modules in order to export useful functions to KEMI, statical wrappers to C functions implemented in other modules cannot be used, because they will introduce dependencies on each embedded interpreter for all modules. |
+ | |||
+ | The implementation relies on defining a set of generic functions that are exported | ||
+ | |||
+ | Currently the association table size is 1024 (it means that there can be maximum 1024 Kamailio | ||
Each existing component of Kamailio (e.g., module), can export new functions to KEMI in the following way: | Each existing component of Kamailio (e.g., module), can export new functions to KEMI in the following way: | ||
Line 382: | Line 387: | ||
</ | </ | ||
- | ===== Examples | + | ===== Basic IP Telephony Config Example |
Some examples of configuration files using the native, Lua or Python interpreter are available in Kamailio source tree inside the **examples/ | Some examples of configuration files using the native, Lua or Python interpreter are available in Kamailio source tree inside the **examples/ | ||
Line 390: | Line 395: | ||
The configuration file to start with is **kamailio-basic-kemi.cfg**: | The configuration file to start with is **kamailio-basic-kemi.cfg**: | ||
- | {{url>https:// | + | * https:// |
You can either rename it to kamailio.cfg or use **-f** command line option to point to it. | You can either rename it to kamailio.cfg or use **-f** command line option to point to it. | ||
Line 396: | Line 401: | ||
If started without any change and no define in command line, then Kamailio will continue to load the routing blocks in the native language, stored in the file **kamailio-basic-kemi-native.cfg**: | If started without any change and no define in command line, then Kamailio will continue to load the routing blocks in the native language, stored in the file **kamailio-basic-kemi-native.cfg**: | ||
- | {{url>https:// | + | * https:// |
If you define WITH_CFGLUA inside **kamailio-basic-kemi.cfg** or provide the command line parameter **-A WITH_CFGLUA**, | If you define WITH_CFGLUA inside **kamailio-basic-kemi.cfg** or provide the command line parameter **-A WITH_CFGLUA**, | ||
- | {{url>https:// | + | * https:// |
If you define WITH_CFGPYTHON inside **kamailio-basic-kemi.cfg** or provide the command line parameter **-A WITH_CFGPYTHON**, | If you define WITH_CFGPYTHON inside **kamailio-basic-kemi.cfg** or provide the command line parameter **-A WITH_CFGPYTHON**, | ||
- | {{url>https:// | + | * https:// |
Combining **kamailio-basic-kemi.cfg** with **kamailio-basic-kemi-native.cfg** results more or less in the **kamailio-basic.cfg** from the **etc/** folder in Kamailio source tree. The Lua and Python scripts are offering the same features, but written in another language. | Combining **kamailio-basic-kemi.cfg** with **kamailio-basic-kemi-native.cfg** results more or less in the **kamailio-basic.cfg** from the **etc/** folder in Kamailio source tree. The Lua and Python scripts are offering the same features, but written in another language. | ||
Line 457: | Line 462: | ||
Testing was done for registrations with user authentication, | Testing was done for registrations with user authentication, | ||
- | The values are in micro-seconds (1 / 1 000 000 of a second) and represents the average execution time, the minimum execution time and the maximum execution time. | + | The values are in micro-seconds (1 / 1 000 000 of a second) and represents the average execution time, the minimum execution time and the maximum execution time for request_route{...} block (or the equivalent of). |
The results were: | The results were: | ||
Line 474: | Line 479: | ||
Remarks: | Remarks: | ||
- | * the avverage | + | * the average |
* the test was run many times, the Native and Lua execution were close to each other, many times Lua being faster, but again, at small difference | * the test was run many times, the Native and Lua execution were close to each other, many times Lua being faster, but again, at small difference | ||
* no big surprise as Lua is calling directly the C bindings and its interpreter is written also in C. With the config used in the tests, the Lua script doesn' | * no big surprise as Lua is calling directly the C bindings and its interpreter is written also in C. With the config used in the tests, the Lua script doesn' | ||
- | * Python is slower comparing to Native and Lua, but not that much as one may expect. | + | * Python is slower comparing to Native and Lua, but not that much as one may expect. |
* in some tests, the maximum execution time was between 5000 and 10000 micro-second, | * in some tests, the maximum execution time was between 5000 and 10000 micro-second, | ||