<div dir="ltr"><p dir="ltr">All the functions in drouting module use gw_id_avp maybe not very clear documented but here is where it is mentioned <a href="http://www.opensips.org/html/docs/modules/2.1.x/drouting.html#id294084" target="_blank">http://www.opensips.org/html/docs/modules/2.1.x/drouting.html#id294084</a>.</p><p>Basically that says "all dr functions store and use the values from/to that avp".</p>
<div class="gmail_quote">On Jul 29, 2015 9:47 AM, "Patrick Wakano" <<a href="mailto:pwakano@gmail.com" target="_blank">pwakano@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello list,<div><br><div>Back to this issue, I found another behavior of the gw_id_avp that is not documented anywhere...</div><div>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:</div><div>WARNING:drouting:use_next_gw: no GWs found at all -> have you done do_routing in script ??<br></div><div><br></div><div>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?</div><div><br></div><div>Regards,</div><div>Patrick</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 2, 2015 at 1:27 PM, Podrigal, Aron <span dir="ltr"><<a href="mailto:aronp@guaranteedplus.com" target="_blank">aronp@guaranteedplus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">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.</p>
<p dir="ltr">Perhaps this is a bug. </p><div><div>
<div class="gmail_quote">On Jul 2, 2015 8:34 AM, "Newlin, Ben" <<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>
<div>
<div>Yes, accessing the AVP without an index returns the same value as accessing with index 0.</div>
<div>
<div>
<div><br>
</div>
<div>Ben Newlin</div>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:12pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span><Podrigal>, Aron<br>
<span style="font-weight:bold">Reply-To: </span>OpenSIPS users mailling list<br>
<span style="font-weight:bold">Date: </span>Wednesday, July 1, 2015 at 8:33 PM<br>
<span style="font-weight:bold">To: </span>OpenSIPS users mailling list<br>
<span style="font-weight:bold">Subject: </span>Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
</div>
<div><br>
</div>
<div>
<div>
<p dir="ltr"><br>
On Jul 1, 2015 3:44 PM, "Newlin, Ben" <<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>> wrote:<br>
><br>
> Sorry, actually the documentation confused me.<br>
><br>
> 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:<br>
><br>
> # first time avp_gw_id is set<br>
> is_from_gw(, i); # function adds gw1 to AVP<br>
><br>
> If I access the AVP without an index I get gw1.<br>
><br>
> route_to_gw("gw2,gw3,gw4");<br>
> # function adds gw2, gw3, gw4 to AVP<br>
><br>
> If I access the AVP without an index I still get gw1. Accessing AVP[1] gives gw2.<br>
Is that that accessing the avp without a index the same as accessing AVP[0]?<br>
><br>
> Ben Newlin<br>
><br>
> From: <Newlin>, "Newlin, Ben"<br>
><br>
> Reply-To: OpenSIPS users mailling list<br>
> Date: Wednesday, July 1, 2015 at 2:40 PM<br>
><br>
> To: OpenSIPS users mailling list<br>
> Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
><br>
> No, that is wrong.<br>
><br>
> "If no index is given, the first value will be returned.” [1]<br>
><br>
> [1] <a href="http://www.opensips.org/Documentation/Script-CoreVar-1-11#toc2" target="_blank">http://www.opensips.org/Documentation/Script-CoreVar-1-11#toc2</a><br>
><br>
> Ben Newlin<br>
><br>
> From: <Podrigal>, Aron<br>
> Reply-To: OpenSIPS users mailling list<br>
> Date: Wednesday, July 1, 2015 at 1:29 PM<br>
> To: OpenSIPS users mailling list<br>
> Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
><br>
> When accessing an avp without explicit index isn't it returning the last index? <br>
><br>
> # first time svp_gw_id is set<br>
> is_from_gw(, i); # avp now has (1)<br>
><br>
> route_to_gw("gw2,gw3,gw4");<br>
> # avp now has (gw1, gw2);<br>
><br>
> if we now access the avp, we can either get explicitly the specific index, or we get the last index which is `gw2`.<br>
> So if I'm not mistaken, then I don't understand what the problem is here?<br>
><br>
><br>
> Correct me if this is wrong.<br>
><br>
> On Wed, Jul 1, 2015 at 11:46 AM, Newlin, Ben <<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>> wrote:<br>
>><br>
>> 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.<br>
>><br>
>> I am currently using the same workaround of clearing out the AVPs prior to each DROUTING module call that populates them.<br>
>><br>
>> Ben Newlin<br>
>><br>
>> From: Patrick Wakano<br>
>> Reply-To: OpenSIPS users mailling list<br>
>> Date: Wednesday, July 1, 2015 at 11:41 AM<br>
>> To: OpenSIPS users mailling list<br>
>> Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
>><br>
>> Hello Aron,<br>
>> 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).<br>
>><br>
>><br>
>> On Wed, Jul 1, 2015 at 9:50 AM, Podrigal, Aron <<a href="mailto:aronp@guaranteedplus.com" target="_blank">aronp@guaranteedplus.com</a>> wrote:<br>
>>><br>
>>> I guess pushing to the last index of the avp is what's expected.<br>
>>><br>
>>> But how did you retrieve the gw_id from is_from_gw, did you use an explicit index?<br>
>>><br>
>>> On Jul 1, 2015 8:16 AM, "Patrick Wakano" <<a href="mailto:pwakano@gmail.com" target="_blank">pwakano@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Hello Opensips list,<br>
>>>><br>
>>>> 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.<br>
>>>> 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().<br>
>>>> 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?<br>
>>>><br>
>>>> Regards,<br>
>>>><br>
>>>> Patrick<br>
>>>><br>
>>>> _______________________________________________<br>
>>>> Users mailing list<br>
>>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Users mailing list<br>
>>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Users mailing list<br>
>> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
>><br>
><br>
><br>
><br>
> -- <br>
> Aron Podrigal<br>
> -<br>
> //Be happy :-)<br>
><br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
><br>
</p>
</div>
</div>
</span>
</div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div>
</div>