[sr-dev] variable as avp index?

Juha Heinanen jh at tutpro.com
Wed Sep 8 20:21:20 CEST 2010


Daniel-Constantin Mierla writes:

> if that is an integer id for avp, then use:
> 
> $var(tmp) = 10;
> 
> As you wrote is taken as avp with a string name represented by "i:10".

daniel,

thanks for the info.  it seems to be missing from avp wiki page:

http://sip-router.org/wiki/cookbooks/pseudo-variables/devel

which states:

AVPs

$(avp(id)[N]) - represents the value of N-th AVP identified by 'id'.
The 'id' can be:
* "[si]:name" - name is the id of an AVP; 's' and 'i' specifies if the id is string or integer. If missing, it is considered to be string. * "name" - the name is an AVP alias
$(avp(id)[0]) can be written in shorter form as $avp(id) and
$avp(s:name) as $name.

and gives impression that avp name 10 is same as s:10.  also, the page
does not tell that avp id can be a variable or perhaps even an
expression.

a util function that takes a param list as argument and assigns avps
based on it would still be useful.  i'll try to write one unless someone
figures out a better way to achieve the same.  the application that i
have in mind is one where proxy receives from another proxy a param list
in a header and assigns avps based on it.  without such a function a
complex loop structure would be needed.

-- juha



More information about the sr-dev mailing list