[SR-Users] function calling in the config script with $var() as attribute(s)
Klaus Feichtinger
klaus.feichtinger at gmx.net
Wed Feb 24 16:01:01 CET 2010
Alex,
thanks for your answer. I have already tried it with quotes before. However, the result is / was that Kamailio thinks the attribute (representing a variable) is a string / hostname (as usual for any characters within quotes).
The error message for t_relay is:
<core> [proxy.c:271]: ERROR: mk_proxy: could not resolve hostname: "$var(tc_locIpaddr)"
ERROR: tm [tm.c:613]: ERROR: fixup_hostport2proxy: bad host name in URI <$var(test)>
I've learned before, that variables MUST NOT be set in quotes for if-else-statements, because of this (it would not represent the value of the variable, but the name). The statement "if ($rU=~"$var(test)")" does not work because of the quotes; only "if ($rU=~$var(test))" is successful.
So it seems that the function "t_relay" is also an "old-school" module function ;-) I will / have to wait for a future update that will allow pseudo variables, too.
Klaus
> Klaus,
>
> 1) Variables are always evaluated in a lexical context, so
>
> func($var(x));
>
> will never work. What you want is:
>
> func("$var(x)");
>
> Just call it an idiosyncrasy of Kamailio/SR.
>
> 2) Not ALL core and module functions evaluate pseudo-variables and
> substitute their values; most do, but there are still some out there
> that don't and always evaluate their string arguments strictly literally.
>
> These are mostly old-school core functions as rewritehostport(). There
> are a few module functions that don't support PVs as well, but I imagine
> that will be changing soon. A number of functions have been upgraded
> recently to allow PV arguments.
>
> Cheers,
>
> -- Alex
>
> --
> Alex Balashov - Principal
> Evariste Systems LLC
>
> Tel : +1 678-954-0670
> Direct : +1 678-954-0671
> Web : http://www.evaristesys.com/
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
More information about the sr-users
mailing list