[SR-Users] function calling in the config script with $var() as attribute(s)

Klaus Feichtinger klaus.feichtinger at gmx.net
Wed Feb 24 15:41:54 CET 2010


Hello SR-users and -developers,

I have the question if parameters for a function in the config script
(e.g. "t_relay(host, port)") in general can be set with a variable 
($var(xy)). Because of having a set of SIP servers / gateways distributed 
over a wide area and therefore keeping the configuration as simple as 
possible, I would like to define a custom variable, assign it to a $var 
and use this variable as attribute for a relay function. In this case the 
variable would represent a string of an IP-address (e.g. "10.1.1.55"). 
When this would work I only have to adapt the custom variables on top of 
each config script and could let the rest "as it is".


First practical tests have shown, that the functions are NOT happy with these "attributes". It can be used without any problems for if-else-
statements, but I fear not for functions....

The practical scenario looks like:

tc.ip11 = "10.16.65.101" desc "";
[...]
route {
   $var(test) = $sel(cfg_get.tc.ip11);
   [...]
   if (!t_relay($var(test), "5061"))
   [...]
}

This configuration resulted in following error messages:

<core> [cfg.y:3326]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 413, column 18-35: syntax error
<core> [cfg.y:3326]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 413, column 18-35: call params error#012
<core> [cfg.y:3326]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 413, column 18-35: call params error#012
<core> [cfg.y:3326]: parse error in config file /usr/local/etc/kamailio/kamailio.cfg, line 413, column 38-41: Function parameter with integer value not allowed#012


Please, could anybody clarify if this should work or not? If not - is any
alternative possibility available for "automating" function attributes
instead of re-writing each function using the same string attribute?

Thanks in advance,

Klaus

-- 
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser




More information about the sr-users mailing list