[sr-dev] Kamailio 5-0 - Executing event routes in embedded languages

Victor Seva linuxmaniac at torreviejawireless.org
Wed May 4 10:05:50 CEST 2016


On 05/04/2016 09:34 AM, Daniel-Constantin Mierla wrote:
>
> In the native configuration, event routes are executed if they are
> defined. Their names (as in event_route[name]) are not valid function
> names for the other programming languages to be used directly
> corresponding callback function name.
>
> I was thinking of the alternative, next are the ones I came up with,
> more suggestions are welcome.
>
> 1) add parameters for event route callback names, like:
>
> modparam("htable", "evrtcb_mod_init", "ksr_htable_mod_init")
>
> would define the name of the function for the alternative to
> event_route[htable:mod-init].
>
> This has a benefit in speed, if the parameter is not defined, then there
> is no overhead in trying to execute a callback function in an embedded
> language.
>
> The drawback is that there is need to code a bit of C to add those
> parameters to the components executing event routes.
>
> 2) do a direct mapping using some translation rules, like:
>
> - prefix with ksr_
> - replace ':' and '-' with underscore '_'
>
> So event_route[htable:mod-init] will have automatically the
> correspondent function ksr_htable_mod_init().
>
> The drawback is that each time the even route should be called, a lookup
> on embedded language symbols table needs to be done to see if it exists,
> then execute it.
>
> There is still some C code to do, but less than adding parameters like
> for 1).
>
> 3) like 2), but instead of an automatic translation, keep a mapping table:
>
> struct mapping {
> str kname;
> str ename;
> } table[] = {
> str_init("htable:mod-init"),
> str_init("ksr_htable_mod_init"),
>
> }
>
> Adding a new event route will require adding a new record in the mapping
> table. The benefit is that the function name in embedded language can be
> selected to be whatever, with or without ties to the event_route name.
>
> Opinions?

I like Option 3, it is quite clear and flexible

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20160504/f16de7a5/attachment.sig>


More information about the sr-dev mailing list