[SR-Users] AVP assignment question

Klaus Darilion klaus.mailinglists at pernau.at
Thu May 3 13:36:26 CEST 2012


Thanks, I improved the wiki.

Klaus

On 03.05.2012 12:04, Daniel-Constantin Mierla wrote:
> Hello,
>
> On 5/3/12 11:52 AM, Klaus Darilion wrote:
>> Hi!
>>
>> For example:
>> $avp(i:test) = 1;
>> $avp(i:test) = 2;
>> # now: test[0]=2, test[1]=1
>>
>> I would think that assigning or deleting using an index would
>> overwrite the respective element in the AVP list, but assigning $null
>> always deletes [0] and assigning a value always add another AVP to the
>> top, e.g:
>>
>> $(avp(i:test)[1]) = 3;
>> # I would expect: test[0]=2, test[1]=3
>> # but it is: test[0]=3, test[1]=2, test[2]=1
>>
>> $(avp(i:test)[2]) = $null;
>> # I would expect: test[0]=3, test[1]=2
>> # but it is: test[0]=2, test[1]=1
>>
>> So, is the current behavior really the correct behavior? It is not
>> what I would expect when using indexes.
>>
>> If it is correct, I will improve the documentation accordingly.
>
> Assigning to an avp with index does not work as you expected - simple
> the index is ignored, being like there is no index. It can be
> implemented, though, nobody did it so far.
>
> There is one exception for index [*] which will overwrite all avps with
> that name (when assigning $null, will delete all, otherwise will delete
> existing ones and add a new one with the value provided in the assignment).
>
> Cheers,
> Daniel
>>
>> regards
>> Klaus
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



More information about the sr-users mailing list