Hello,
the xavps were developed in this way so far, if anyone would need to
evaluate variables in the name has to write some C code in PV module
where the xavps are exported as config variables. As I didn't have any
need, I haven't spent any time on this.
I think that there are some functions that may allow achieving what you
aim for, but probably the complexity added in the config makes it not
very attractive. In the pv module there are couple of functions that you
can combine to set the value of xavps and evaluate, respectively:
http://www.kamailio.org/docs/modules/5.1.x/modules/pv.html#pv.f.xavp_params…
http://www.kamailio.org/docs/modules/5.1.x/modules/pv.html#pv.f.pv_evalx
So you would have to build first a param like string, that you convert
to xavp and then use evalx when you need the value.
Like:
$var(root) = 'x';
$var(branch) = 'y';
$var(value)= 'abc';
$var(params) = "$var(branch)=" + $var(value);
xavp_params_explode("$var(params)", '$var(root)');
# now $xavp(x=>y) == "abc"
To get the value inside $var(result):
pv_evalx("$$xavp($var(root)=>$var(branch))", "$var(result)");
If you work with integer values, you may need to cast to int via
transformation {s.int}
Another option is to use embedded languages, such as lua, javascript,
... . There are functions that execute snippets of scripts after
evaluating the variables, should be like:
lua_dostring( 'KSR.pv.sets("$$xavp($var(root)=>$var(branch))",
"$var(value)")' );
lua_dostring( 'KSR.pv.sets("$var(result)",
KSR.pv.get("$$xavp($var(root)=>$var(branch))") )' );
Anyhow, supporting dynamic names could be added, it is not a limitation
on xavp design, but how pv module exports to config -- eventually with
some marker to show that a dynamic name should be evaluated in order to
preserve performances of existing implementation (e.g., used of $xavpx
as pv class name).
Cheers,
Daniel
On 24.07.17 08:47, Vasiliy Ganchev wrote:
Hi, Daniel!
I expected to use it per transaction. We are also actively using htables for
different cases, and I am aware of them.
My question about xavps - was "in general" - is it a limitation of the
initial design, and is it planned to be changed.
For now, instead of using xavp with variables, I am using AVPs with complex
names (name consists of 2 vars) - and it does what I needed.
Thanks for your answers!
Best regards, Vasiliy
Daniel-Constantin Mierla-6 wrote
Hello,
do you need to store per transaction or just global scope? If the later,
you can use hash table variables with dynamic name.
Cheers,
Daniel
On 19.07.17 11:09, Vasiliy Ganchev wrote:
Hi, community!
I have a question regarding xavp usage.
according to docs, xavp has format:
$xavp(root=>branch)="value";
I want to use "root" and "branch" - variables. (as it is implemented
with
AVPs - the id there, can be variable)
e.g.:
...
$var(root_key) = "root_1";
$var(branch_key1) = "key_value1";
...
$xavp($var(root_key)[0]=>$var(branch_key1)) = "some_value";
...
Playing around with the script - I found that it is currently impossible
(tested with 4.2.5 and 5.2.0 versions).
Kamailio interprets variables in "root" and "branch" as static
strings.
Walking through the mailing list history, I have an impression that xavp
are
originally designed to operate only with constant keys.
The question is: is it planned to add functionality with variables as
"root"
and "branch" components?
Thanks in advance for the answers!
Best regards
--
View this message in context:
http://sip-router.1086192.n5.nabble.com/xavp-questions-variables-in-root-br…
Sent from the Users mailing list archive at
Nabble.com.
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@.kamailio
--
Daniel-Constantin Mierla
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training -
www.asipto.com
Kamailio World Conference -
www.kamailioworld.com
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@.kamailio
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
View this message in context:
http://sip-router.1086192.n5.nabble.com/xavp-questions-variables-in-root-br…
Sent from the Users mailing list archive at
Nabble.com.
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training -
www.asipto.com
Kamailio World Conference -
www.kamailioworld.com