[OpenSIPS-Users] OpensSIPS 2.2 - avps with an index of -1
Pat Burke
pat at voxtelesys.com
Fri Oct 14 01:14:57 CEST 2016
Bogdan,
I implemented your change in my 2.2.1 code, and it works great.
Thanks for the implementation.
Pat
-----Original Message-----
From: "Bogdan-Andrei Iancu" <bogdan at opensips.org>
To: "Pat Burke" <pat at voxtelesys.com>, "OpenSIPS users mailling list" <users at lists.opensips.org>
Date: 10/13/16 05:31
Subject: Re: [Spam] Re: [OpenSIPS-Users] OpensSIPS 2.2 - avps with an index of -1
Hi Pat,
OK :).
Well, the usage of the -1 index is inconsistent with the rest of the indexes - for positive indexes are used to "overwrite" an existing value, not to add a new one. This is why the usage of -1 to add may be misleading, as you would expect to actually overwrite the last value :).
I committed a patch on trunk/2.3 that adds the "append" index for AVPs :
$(avp(name)[append]) = "last value";
https://github.com/OpenSIPS/opensips/commit/466fbf045179188c39fefe5b48ec581c37023a5b
You may consider using it (it is fully 2.2 compatible) and starting with 2.3 version you will get rid of additional patches ;).
Regards,
Bogdan-Andrei Iancu OpenSIPS Founder and Developerhttp://www.opensips-solutions.com
On 12.10.2016 18:02, Pat Burke wrote:
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
More information about the Users
mailing list