[OpenSIPS-Users] overwriting AVPs at certain index

Bogdan-Andrei Iancu bogdan at voice-system.ro
Thu Nov 4 10:34:58 CET 2010


Hi Jayesh,

Just tried the following script and it did the right job:

<snap>
    $avp(s:value1) = "abc";
    $avp(s:value2) = "ABC";

    $avp(s:variable) = $avp(s:value1);
    $avp(i:999) = 0;
    $(avp(s:variable)[$avp(i:999)]) = $avp(s:value2);

    avp_print();
</snap>

and the result (from avp_print()) :

Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e48, 
flags=0x0000
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
id=<999>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
val_int=<0>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5e70, 
flags=0x0003
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
name=<variable>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
val_str=<ABC / 3>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5dc8, 
flags=0x0003
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
name=<value2>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
val_str=<ABC / 3>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp: p=0xb5ab5d88, 
flags=0x0003
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
name=<value1>
Nov  4 11:32:49 [12046] INFO:avpops:ops_print_avp:                      
val_str=<abc / 3>


Can you post the error/log you get?

Regards,
Bogdan

Jayesh Nambiar wrote:
> Hi All,
> I am trying to overwrite certain values at specific index of AVP and 
> it doesn't work as expected. How I do it is:
>
> $avp(variable) = $avp(value1);
> $avp(i:999) = 0;
> $(avp(variable)[$avp(i:999)]) = $avp(value2);
>
> While executing this, opensips logs an error saying unable to replace 
> AVPs. Is the syntax wrong somewhere? I do this as I don't want to add 
> multiple values into single AVP and also I dont want to call 
> avp_delete function before assigning a new value to the AVP. Moreover 
> the value at $avp(i:999) can change and thus it is assigned to another 
> AVP.
>
> Any help related to AVP overwriting function would be very helpful.
>
> --- Jayesh
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>   


-- 
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
15 - 19 November 2010, Edison, New Jersey, USA
www.voice-system.ro




More information about the Users mailing list