[OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp

Podrigal, Aron aronp at guaranteedplus.com
Wed Jul 29 17:15:42 CEST 2015


All the functions in drouting module use gw_id_avp maybe not very clear
documented but here is where it is mentioned
http://www.opensips.org/html/docs/modules/2.1.x/drouting.html#id294084.

Basically that says "all dr functions store and use the values from/to that
avp".
On Jul 29, 2015 9:47 AM, "Patrick Wakano" <pwakano at gmail.com> wrote:

> Hello list,
>
> Back to this issue, I found another behavior of the gw_id_avp that is not
> documented anywhere...
> Due to the reason explained in this thread, I am setting the gw_id_avp to
> null but if I set it to null and then call use_next_gw(), the routing does
> not happen and I get this message in the logs:
> WARNING:drouting:use_next_gw: no GWs found at all -> have you done
> do_routing in script ??
>
> If I do not set it to null before calling use_next_gw() it works as
> expected. So I conclude that somehow the use_next_gw() function uses the
> gw_id_avp and we should not touch it. Is that right? Any reason for that?
>
> Regards,
> Patrick
>
>
> On Thu, Jul 2, 2015 at 1:27 PM, Podrigal, Aron <aronp at guaranteedplus.com>
> wrote:
>
>> This is more for the dev people.  But I would assume that there is some
>> pointer set to the current avp index and thats the slot which is returned
>> when accessing without an explicit index.  Each time an avp value is
>> pushed,  it updates that pointer to point to that index,  which is not done
>> by the route_to_gw function.
>>
>> Perhaps this is a bug.
>> On Jul 2, 2015 8:34 AM, "Newlin, Ben" <Ben.Newlin at inin.com> wrote:
>>
>>>   Yes, accessing the AVP without an index returns the same value as
>>> accessing with index 0.
>>>
>>>  Ben Newlin
>>>
>>>   From: <Podrigal>, Aron
>>> Reply-To: OpenSIPS users mailling list
>>> Date: Wednesday, July 1, 2015 at 8:33 PM
>>> To: OpenSIPS users mailling list
>>> Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the
>>> first index of avp
>>>
>>>
>>> On Jul 1, 2015 3:44 PM, "Newlin, Ben" <Ben.Newlin at inin.com> wrote:
>>> >
>>> > Sorry, actually the documentation confused me.
>>> >
>>> > You are correct in the way that it should work if the do_routing() and
>>> route_to_gw() are really pushing the functions on the end of the AVP.
>>> However, they must not be doing that because that is not the operation. To
>>> modify your example:
>>> >
>>> > # first time avp_gw_id is set
>>> > is_from_gw(, i);   # function adds gw1 to AVP
>>> >
>>> > If I access the AVP without an index I get gw1.
>>> >
>>> > route_to_gw("gw2,gw3,gw4");
>>> > # function adds gw2, gw3, gw4 to AVP
>>> >
>>> > If I access the AVP without an index I still get gw1. Accessing AVP[1]
>>> gives gw2.
>>> Is that that accessing the avp without a index  the same as accessing
>>> AVP[0]?
>>> >
>>> > Ben Newlin
>>> >
>>> > From: <Newlin>, "Newlin, Ben"
>>> >
>>> > Reply-To: OpenSIPS users mailling list
>>> > Date: Wednesday, July 1, 2015 at 2:40 PM
>>> >
>>> > To: OpenSIPS users mailling list
>>> > Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the
>>> first index of avp
>>> >
>>> > No, that is wrong.
>>> >
>>> > "If no index is given, the first value will be returned.” [1]
>>> >
>>> >  [1] http://www.opensips.org/Documentation/Script-CoreVar-1-11#toc2
>>> >
>>> > Ben Newlin
>>> >
>>> > From: <Podrigal>, Aron
>>> > Reply-To: OpenSIPS users mailling list
>>> > Date: Wednesday, July 1, 2015 at 1:29 PM
>>> > To: OpenSIPS users mailling list
>>> > Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the
>>> first index of avp
>>> >
>>> > When accessing an avp without explicit index isn't it returning the
>>> last index?
>>> >
>>> > # first time svp_gw_id is set
>>> > is_from_gw(, i);   #  avp now has (1)
>>> >
>>> > route_to_gw("gw2,gw3,gw4");
>>> > # avp now has (gw1, gw2);
>>> >
>>> > if we now access the avp, we can either get explicitly the specific
>>> index, or we get the last index which is `gw2`.
>>> > So if I'm not mistaken, then I don't understand what the problem is
>>> here?
>>> >
>>> >
>>> > Correct me if this is wrong.
>>> >
>>> > On Wed, Jul 1, 2015 at 11:46 AM, Newlin, Ben <Ben.Newlin at inin.com>
>>> wrote:
>>> >>
>>> >> I found similar behavior in my implementation, except that I use
>>> dr_routing() instead of route_to_gw(). When the AVP is already populated,
>>> these functions simply push on the end. This may be an implementation
>>> decision, but it is certainly not intuitive or what I expected.
>>> >>
>>> >> I am currently using the same workaround of clearing out the AVPs
>>> prior to each DROUTING module call that populates them.
>>> >>
>>> >> Ben Newlin
>>> >>
>>> >> From: Patrick Wakano
>>> >> Reply-To: OpenSIPS users mailling list
>>> >> Date: Wednesday, July 1, 2015 at 11:41 AM
>>> >> To: OpenSIPS users mailling list
>>> >> Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the
>>> first index of avp
>>> >>
>>> >> Hello Aron,
>>> >> After calling is_from_gw("-1","i") I don't need to use the index,
>>> because it is the only value hold by the avp, but later in my script, if I
>>> call route_to_gw() and use $avp(dr_gw_id), it still has the value
>>> previously pushed by is_from_gw(). Then to get the gw id pushed by
>>> route_to_gw() I have either to use the avp index (e.g. $avp(dr_gw_id)[1])
>>> or I set $avp(dr_gw_id) to null before calling route_to_gw() (which is what
>>> I am doing now).
>>> >>
>>> >>
>>> >> On Wed, Jul 1, 2015 at 9:50 AM, Podrigal, Aron <
>>> aronp at guaranteedplus.com> wrote:
>>> >>>
>>> >>> I guess  pushing to the last index of the avp is what's expected.
>>> >>>
>>> >>> But how did you retrieve the gw_id from is_from_gw, did you use an
>>> explicit index?
>>> >>>
>>> >>> On Jul 1, 2015 8:16 AM, "Patrick Wakano" <pwakano at gmail.com> wrote:
>>> >>>>
>>> >>>> Hello Opensips list,
>>> >>>>
>>> >>>> When using the route_to_gw() function, I noticed that the gw_id
>>> that is pushed back to the avp wasn't matching the address actually
>>> selected by the drouting engine.
>>> >>>> After some investigation I noticed that earlier in my script I was
>>> calling the is_from_gw() function with the 'i' flag which also pushes the
>>> gw_id to the avp and this was the value I was seeing in my avp after
>>> calling the route_to_gw().
>>> >>>> By debuging with the avp_print() function I could see that the
>>> route_to_gw() does not pushes the gw_id to first index of the avp, but to
>>> the end of it. Any reason for that or is it a bug?
>>> >>>>
>>> >>>> Regards,
>>> >>>>
>>> >>>> Patrick
>>> >>>>
>>> >>>> _______________________________________________
>>> >>>> Users mailing list
>>> >>>> Users at lists.opensips.org
>>> >>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >>>>
>>> >>>
>>> >>> _______________________________________________
>>> >>> Users mailing list
>>> >>> Users at lists.opensips.org
>>> >>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >>>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> Users mailing list
>>> >> Users at lists.opensips.org
>>> >> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Aron Podrigal
>>> > -
>>> > //Be happy :-)
>>> >
>>> > _______________________________________________
>>> > Users mailing list
>>> > Users at lists.opensips.org
>>> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>> >
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.opensips.org
>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>>
>>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20150729/2f6bccd4/attachment-0001.htm>


More information about the Users mailing list