[SR-Users] Executing a C function from the Kamailio Script

Alex Balashov abalashov at evaristesys.com
Fri Dec 4 18:22:24 CET 2015


Mack,

The language modules take advantage of the fact that those other 
languages (e.g. Lua, Python) are higher-level, _interpreted_ languages, 
and that their interpreters provide an API for embedding them into C 
programs. One cannot easily embed an on-the-fly C compiler into a C program.

Writing a Kamailio module is certainly the easiest way to call a custom 
C function from route script, and it's not terribly hard to get started. 
If your needs are very simple, you don't have to make extensive study of 
the module API. Just follow/modify this example module:

https://github.com/kamailio/kamailio/tree/master/modules/print

'print' is a stub that doesn't do anything, but provides a skeleton from 
which you can build your own module.

I suppose you could also embed your C function into a library that can 
be called from an interpreted language supported by Kamailio (Lua, 
Python, Perl, etc.), but that seems like it would be vastly more 
complicated than writing a Kamailio module.

Finally, are you one hundred percent sure that the functionality you 
need cannot be achieved any other way?

-- Alex

-- 
Alex Balashov | Principal | Evariste Systems LLC
303 Perimeter Center North, Suite 300
Atlanta, GA 30346
United States

Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/



More information about the sr-users mailing list