[SR-Users] Accessing #!define "variables" from within lua

Alex Balashov abalashov at evaristesys.com
Fri Mar 23 13:12:13 CET 2012


Have you considered using selectors/cfg_get variables instead?  

They are also a common way to store various types of "global" values/constants, with the difference that they can be accessed at run time using PV container functions instead of set at preprocessing.

myproject.local_ip = "1.2.3.4" descr "IP address"

$sel(cfg_get.my project.local_ip)
Or SER-style: @cfg_get.my project.local_ip

You can evaluate those in Lua, right?

--
Alex Balashov - Principal
Evariste Systems LLC
235 E Ponce de Leon Ave
Suite 106
Atlanta, GA 30030
Tel: +1-678-954-0671
Web: http://www.evaristesys.com/, http://www.alexbalashov.com

Asgaroth <00asgaroth00 at gmail.com> wrote:

>Hi All,
>
>I am looking at writing a lua function that would really benefit from 
>accessing "variables" that I would have defined by using the #!define 
>statement. Is this at all possible? I've tried looking at the 
>documentation surrounding lua and kamailio, but I cannot see how I would 
>access it. I thought I'd ask the list to see if anyone else may have 
>attempted this.
>
>for example, I may have
>
>#!define INTERNAL_ADDRESS 1.2.3.4
>
>Which I subsequently use through the the routing script to refer to the 
>internal address I am listening on. Now I would like to try and access 
>this "variable" from a lua script. Any pointers/tips/workarounds would 
>be greatly appreciated.
>
>Thanks
>
>_______________________________________________
>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>sr-users at lists.sip-router.org
>http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


More information about the sr-users mailing list