<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 &quot;all dr functions store and use the values from/to that avp&quot;.</p>
<div class="gmail_quote">On Jul 29, 2015 9:47 AM, &quot;Patrick Wakano&quot; &lt;<a href="mailto:pwakano@gmail.com" target="_blank">pwakano@gmail.com</a>&gt; 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 -&gt; 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">&lt;<a href="mailto:aronp@guaranteedplus.com" target="_blank">aronp@guaranteedplus.com</a>&gt;</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, &quot;Newlin, Ben&quot; &lt;<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>&gt; 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>&lt;Podrigal&gt;, 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, &quot;Newlin, Ben&quot; &lt;<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Sorry, actually the documentation confused me.<br>
&gt;<br>
&gt; 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>
&gt;<br>
&gt; # first time avp_gw_id is set<br>
&gt; is_from_gw(, i);   # function adds gw1 to AVP<br>
&gt;<br>
&gt; If I access the AVP without an index I get gw1.<br>
&gt;<br>
&gt; route_to_gw(&quot;gw2,gw3,gw4&quot;);<br>
&gt; # function adds gw2, gw3, gw4 to AVP<br>
&gt;<br>
&gt; 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>
&gt;<br>
&gt; Ben Newlin<br>
&gt;<br>
&gt; From: &lt;Newlin&gt;, &quot;Newlin, Ben&quot;<br>
&gt;<br>
&gt; Reply-To: OpenSIPS users mailling list<br>
&gt; Date: Wednesday, July 1, 2015 at 2:40 PM<br>
&gt;<br>
&gt; To: OpenSIPS users mailling list<br>
&gt; Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
&gt;<br>
&gt; No, that is wrong.<br>
&gt;<br>
&gt; &quot;If no index is given, the first value will be returned.” [1]<br>
&gt;<br>
&gt;  [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>
&gt;<br>
&gt; Ben Newlin<br>
&gt;<br>
&gt; From: &lt;Podrigal&gt;, Aron<br>
&gt; Reply-To: OpenSIPS users mailling list<br>
&gt; Date: Wednesday, July 1, 2015 at 1:29 PM<br>
&gt; To: OpenSIPS users mailling list<br>
&gt; Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
&gt;<br>
&gt; When accessing an avp without explicit index isn&#39;t it returning the last index? <br>
&gt;<br>
&gt; # first time svp_gw_id is set<br>
&gt; is_from_gw(, i);   #  avp now has (1)<br>
&gt;<br>
&gt; route_to_gw(&quot;gw2,gw3,gw4&quot;);<br>
&gt; # avp now has (gw1, gw2);<br>
&gt;<br>
&gt; if we now access the avp, we can either get explicitly the specific index, or we get the last index which is `gw2`.<br>
&gt; So if I&#39;m not mistaken, then I don&#39;t understand what the problem is here?<br>
&gt;<br>
&gt;<br>
&gt; Correct me if this is wrong.<br>
&gt;<br>
&gt; On Wed, Jul 1, 2015 at 11:46 AM, Newlin, Ben &lt;<a href="mailto:Ben.Newlin@inin.com" target="_blank">Ben.Newlin@inin.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; 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>
&gt;&gt;<br>
&gt;&gt; I am currently using the same workaround of clearing out the AVPs prior to each DROUTING module call that populates them.<br>
&gt;&gt;<br>
&gt;&gt; Ben Newlin<br>
&gt;&gt;<br>
&gt;&gt; From: Patrick Wakano<br>
&gt;&gt; Reply-To: OpenSIPS users mailling list<br>
&gt;&gt; Date: Wednesday, July 1, 2015 at 11:41 AM<br>
&gt;&gt; To: OpenSIPS users mailling list<br>
&gt;&gt; Subject: Re: [OpenSIPS-Users] Route_to_gw not pushing gw_id to the first index of avp<br>
&gt;&gt;<br>
&gt;&gt; Hello Aron,<br>
&gt;&gt; After calling is_from_gw(&quot;-1&quot;,&quot;i&quot;) I don&#39;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>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Jul 1, 2015 at 9:50 AM, Podrigal, Aron &lt;<a href="mailto:aronp@guaranteedplus.com" target="_blank">aronp@guaranteedplus.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I guess  pushing to the last index of the avp is what&#39;s expected.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But how did you retrieve the gw_id from is_from_gw, did you use an explicit index?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Jul 1, 2015 8:16 AM, &quot;Patrick Wakano&quot; &lt;<a href="mailto:pwakano@gmail.com" target="_blank">pwakano@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hello Opensips list,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; When using the route_to_gw() function, I noticed that the gw_id that is pushed back to the avp wasn&#39;t matching the address actually selected by the drouting engine.<br>
&gt;&gt;&gt;&gt; After some investigation I noticed that earlier in my script I was calling the is_from_gw() function with the &#39;i&#39; 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>
&gt;&gt;&gt;&gt; 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>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Patrick<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; Users mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
&gt;&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; Users mailing list<br>
&gt;&gt;&gt; <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Users mailing list<br>
&gt;&gt; <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; -- <br>
&gt; Aron Podrigal<br>
&gt; -<br>
&gt; //Be happy :-)<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<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>