<p dir="ltr"><br>
On Jul 1, 2015 3:44 PM, &quot;Newlin, Ben&quot; &lt;<a href="mailto:Ben.Newlin@inin.com">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">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">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">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">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">Users@lists.opensips.org</a><br>
&gt;&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
&gt;&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
&gt;&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
&gt; <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
&gt;<br>
</p>