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

Klaus Feichtinger klaus.feichtinger at gmx.net
Wed Feb 24 16:09:04 CET 2010


Klaus, Alex,

you're right. I've seen Klaus's suggestion only after writing my email message. This is the best solution and solves my problem!

regards,

Klaus
> 
> 
> Am 24.02.2010 15:41, schrieb Klaus Feichtinger:
> > 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"))
> 
> A workaround for t_relay:
> 
>    $du = "sip:"+$var(test)+":5061";
>    t_relay();
> 
> 
> klaus
> 
> 
> >     [...]
> > }
> >
> > 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
> >

-- 
GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
http://portal.gmx.net/de/go/dsl02




More information about the sr-users mailing list