[OpenSIPS-Users] [Spam] Re: OpensSIPS 2.2 - avps with an index of -1

Pat Burke pat at voxtelesys.com
Wed Oct 12 17:02:19 CEST 2016


Hello Bogdan,


You are exactly correct.  We have a patch in pv_set_avp in pvar.c that allows -1.  I don't know who put that in, but it works great.  I will put the patch into my 2.2 code.


The method was updated to
        if(idxf == PV_IDX_INT || idxf == PV_IDX_PVAR) /* if the avp is indexed */
        {
                if (idx == -1) { 
                        if (add_avp_last(flags, avp_name, avp_val)<0) {
                                LM_ERR("error - cannot add AVP\n");
                                goto error;
                        }
                } else if(replace_avp(flags, avp_name, avp_val, idx)< 0) {
                        LM_ERR("Failed to replace avp\n");
                        goto error;
                }
        }
  


from


        if(idxf == PV_IDX_INT || idxf == PV_IDX_PVAR) /* if the avp is indexed */
        {
                if(replace_avp(flags, avp_name, avp_val, idx)< 0)
                {
                        LM_ERR("Failed to replace avp\n");
                        goto error;
                }
        }
  
Thanks again,
Pat Burke




-----Original Message-----
From: "Bogdan-Andrei Iancu" <bogdan at opensips.org>
To: "OpenSIPS users mailling list" <users at lists.opensips.org>, "Pat Burke" <pat at voxtelesys.com>
Date: 10/12/16 03:47
Subject: [Spam] Re: [OpenSIPS-Users] OpensSIPS 2.2 - avps with an index of -1

Hi Pat,

Are you sure the -1 index works for you? I just tested with an 1.11 code and got:

Oct 12 11:35:12 [29913] ERROR:core:replace_avp: Index with negative value
Oct 12 11:35:12 [29913] ERROR:core:pv_set_avp: Failed to replace avp
Oct 12 11:35:12 [29913] ERROR:core:do_assign: setting PV failed

I don't think negative indexes were ever supported for AVPs.

Are you sure you do not have a patch for 1.11 to allow negative values ?

Regards,

Bogdan-Andrei Iancu OpenSIPS Founder and Developerhttp://www.opensips-solutions.com
On 12.10.2016 03:04, Pat Burke wrote:

In OpenSIPS 1.11 you were able to use the index of -1 on AVP's to put items into an AVP as a FIFO instead of a LIFO.

Here is what I mean.


$(avp(list)[-1]) = 1;
$(avp(list)[-1]) = 2;

$(avp(list)[-1]) = 3;
$(avp(list)[-1]) = 4;
$(avp(list)[-1]) = 5;


this would result the values coming off as a FIFO
$avp(list) is 1
$avp(list) = NULL;
$avp(list) is 2
$avp(list) = NULL;
$avp(list) is 3
$avp(list) = NULL;
$avp(list) is 4
$avp(list) = NULL;
$avp(list) is 5






Just pushing the items onto the AVP creates a LIFO
$avp(list) = 1;
$avp(list) = 2;
$avp(list) = 3;
$avp(list) = 4;
$avp(list) = 5;


this would result the values coming off as
$avp(list) is 5
$avp(list) = NULL;
$avp(list) is 4
$avp(list) = NULL;
$avp(list) is 3
$avp(list) = NULL;
$avp(list) is 2
$avp(list) = NULL;
$avp(list) is 1




So my question is how do I create a FIFO without having to keep an index to ensure that I am adding the item to the end.  When porting the code from 1.11 to 2.2 I get an error "ERROR:core:replace_avp: Index with negative value" when I use the -1.




Regards,
Pat Burke






_______________________________________________ Users mailing listUsers at lists.opensips.orghttp://lists.opensips.org/cgi-bin/mailman/listinfo/users



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20161012/f8504462/attachment-0001.htm>


More information about the Users mailing list