User Tools

Site Tools


devel:config-engines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
devel:config-engines [2016/05/03 13:55]
miconda [Interpreters Performances]
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 scripting language (used inside kamailio.cfg).
  
 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
-  * reload the SIP routing logic without restarting Kamailio+    * good documentation about language itself and its extensions 
 +  * reload the SIP routing logic without restarting Kamailio (implemented for Lua)
  
 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 implementation relies on the ability of Lua to allow hash tables with custom indexThis is like an object that can have methods defined on the fly. Kamailio registers an empty object with custom index function implemented in Kamailio codewhenever a member of that object is accessed, the index function is executed and Kamailio will resolve it to one of its functions, corresponding by name.+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 to each embedded interpreter, which are associated at startup with a Kamailio C functionsThe lookup at runtime is by an integer index, therefore very fast. 
 + 
 +Currently the association table size is 1024 (it means that there can be maximum 1024 Kamailio C functions exported to the interpreter by configuration file). The number can be increasedbut it should be fairly enough as all kamailio.cfg functions are around 1000 and it is no real use case to load all the modules at the same time for use in production. Also, many functions may not be exported to an embedded languageas they have native alternative in the embedded language.
  
 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:
 </code> </code>
  
-===== 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/kemi** folder - online at github: Some examples of configuration files using the native, Lua or Python interpreter are available in Kamailio source tree inside the **examples/kemi** folder - online at github:
devel/config-engines.txt · Last modified: 2017/11/20 14:31 by miconda