[SR-Users] SIP Routing Logic in Lua

Daniel-Constantin Mierla miconda at gmail.com
Sat Nov 20 10:30:00 CET 2010



On 11/20/10 10:24 AM, Jeremya wrote:
> Daniel-Constantin Mierla wrote:
>>
>> On 11/19/10 8:27 PM, Iñaki Baz Castillo wrote:
>>> 2010/11/17 Daniel-Constantin Mierla<miconda at gmail.com>:
>>>> I made an easy-to-do tutorial where all the SIP routing logic is
>>>> implemented
>>>> in a Lua script (including authentication, accounting, registrar, user
>>>> location). You can read it at:
>>>>
>>>> http://asipto.com/u/h
>>> sr.tm.t_check_trans()
>>> sr.sl.send_reply(404, "Not here")
>>> sr.tm.t_relay()
>>> sr.rr.loose_route()
>>> [...]
>>>
>>> I'd strongly would like that kamailio config file uses namespaced
>>> functions as well, as it's an ellegant way to realize of which module
>>> each function belongs to.
>>> There are more and more modules and new functions, and it's becoming
>>> rather difficult to understand a kamailio/SR script with so many
>>> functions sharing the same/unique "namespace".
>>>
>>>     function_name    =>      module.function_name
>>>
>>> It's cool, it's easy, it's sexy :)
>> This should not be that complex, there is no function name that has
>> '.' in order to have current conflicts to solve. My concern is related
>> to modules with very long names, but seems that most of such cases do
>> not export lot of functions (e.g., presence_*).
>>
>> Alternative is to introduce a short id for modules, eg,:
>>
>> ps =>  presence
>> rp =>  rtpproxy
>>
>> to be used only when module name is too long.
>>
>> Btw, this option can speed up a bit the startup, as now resolving a
>> function in config means going through all modules and all functions
>> in a row. Knowing the module, then the search will be only within the
>> list of functions exported by that module. Just a side note, not big
>> influence over all, this being done at startup.
>>
>> Cheers,
>> Daniel
>>
>>> BTW the article showing the LUA usage is brilliant :)
> As an aside, is there a current index of functions available? i.e. given
> a function what module is it from and what it does?
I mentioned it in the tutorial:
http://kb.asipto.com/kamailio:usage:k32-lua-routing#references

But should be added also in app_module readme, you have the available 
API at:
http://sip-router.org/wiki/api/lua/devel

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Trainings
Nov 22-25, 2010, Berlin, Germany
Jan 24-26, 2011, Irvine, CA, USA
http://www.asipto.com




More information about the sr-users mailing list