<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; 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 id="MAC_OUTLOOK_SIGNATURE">
<div><br>
</div>
<div>Ben Newlin</div>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<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">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">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">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">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">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">Users@lists.opensips.org</a><br>
>>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
>>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
>> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">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">Users@lists.opensips.org</a><br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
><br>
</p>
</div>
</div>
</span>
</body>
</html>