[OpenSIPS-Devel] Pseudovariable implementation extended
Anca Vamanu
anca at opensips.org
Wed Sep 2 11:53:18 CEST 2009
Hi,
The pseudovariable implementation has been extended with new operations to give more power to the script writer:
1. Added 2 new operations on pseudovariables values from the script:
- *delete* the pseudovariable at a certain index; syntax: *pvar[_index_]=NULL*.
- *overwrite* the value of a pseudovariable at a certain index; syntax: *pvar[_index_]=_value_*.
2. Added one new function for avp: inserts a value to an avp set at a certain position
- syntax: *avp_insert*
3. Added operations for set values of pseudovariables:
- *count* the number of values; syntax: *set_count(_pvar_name_)*.
- *select* an element from the set based on fitness. The selection algorithm is the genetic algorithm roulette-wheel selection. One usage example is selecting a route based on costs.
syntax: *set_select_weight(_pvar_name_)*; it returns the index of the selected value.
4. Added a new transformation: extract a parameter from a To like header
- syntax: *{nameaddr.param,param_name}
*- example:*'"test" <sip:test at opensips.org>;tag=dat43h' {nameaddr.param,tag} = dat43h
*
5. Added *context* meaning to pseudovariables - a new token added in front of the pv type name that specifies the context where the pv should be taken from
The implementation is made general - with a mechanism of registering pv context functions, allowing for extensions and addition of custom contexts. For now there are 2 pv contexts: reply and request, registered by the tm module.
- example: -referencing *$(<request>ru)* from a reply route will get the Request-URI from the request
-the <reply> context can be used from failure route to access information from the reply
Hope you will find this useful.
Regards,
Anca
More information about the Devel
mailing list