<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi thrillerbe,<br>
<br>
I think that if you only want to build the list of selected
destinations, you can just call use_next_gw and add the uri in RURI
to a destination string ( because use_next_gw sets the RURI to the
destination-
<a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/devel/drouting.html#id251519">http://www.opensips.org/html/docs/modules/devel/drouting.html#id251519</a>).<br>
It would be something like this:<br>
<div><font face="courier new,monospace"><br>
if (do_routing("1","2")) </font></div>
<div><font face="courier new,monospace">{ <br>
</font></div>
<div><font face="courier new,monospace"> if
($avp(s:dr_rules_attrs) == "2") </font></div>
<div><font face="courier new,monospace"> {</font></div>
<div><font face="courier new,monospace"> xlog("L_INFO","After
1, ds is $ru\n"); </font></div>
<div><font face="courier new,monospace"> $var(x) = 2;<br>
$var(ds) = $ru;<br>
<br>
</font></div>
<div><font face="courier new,monospace"> while
(use_next_gw()) </font></div>
<div><font face="courier new,monospace"> { </font></div>
<div><font face="courier new,monospace"> </font><font
face="courier new,monospace">$var(ds) = $var(ds) + "," + $ru;<br>
</font></div>
<div><font face="courier new,monospace">
xlog("L_INFO","After $var(x), ds is $var(ds)\n"); </font> <font
face="courier new,monospace"> </font></div>
<div><font face="courier new,monospace"> $var(x) =
$var(x) + 1; </font></div>
<div><font face="courier new,monospace"> }
</font></div>
<div><font face="courier new,monospace"> }
</font></div>
<div><font face="courier new,monospace">
xlog("L_INFO","Destination set is $var(ds)\n"); </font></div>
<div><font face="courier new,monospace">}</font></div>
<div><font face="courier new,monospace"><br>
</font></div>
<br>
Regards,<font face="courier new,monospace"></font><br>
<pre class="moz-signature" cols="72">--
Anca Vamanu
OpenSIPS Developer</pre>
<br>
<br>
On 03/29/2011 01:00 AM, thrillerbee wrote:
<blockquote
cite="mid:AANLkTinpqhs+W4e_VA59jZc7ECnCf3pO3XnpRqp+8p2E@mail.gmail.com"
type="cite">
<div>I'm trying to get OpenSIPS to act as a REDIRECT server and
have run into a couple issues. I'm using the drouting module to
do lookups. Essentially, a dialed number could have potentially
several routes, I want to return a 300 with these routes in the
Contact header. Please tell me if this is foolish and/or there
are better methods.</div>
<div><br>
</div>
<div>I'm running release version 1.6.4-2-notls.</div>
<div><br>
</div>
<div>With that, I've configured the following in my script:</div>
<div><font face="courier new,monospace">if (do_routing("1","2")) </font></div>
<div><font face="courier new,monospace"> {
</font></div>
<div><font face="courier new,monospace"> if
($avp(s:dr_rules_attrs) == "2") </font></div>
<div><font face="courier new,monospace"> {</font></div>
<div><font face="courier new,monospace">
xlog("L_INFO","After 1, ds is $ds\n"); </font></div>
<div><font face="courier new,monospace"> $var(x) = 2; </font></div>
<div><font face="courier new,monospace"> while
(use_next_gw()) </font></div>
<div><font face="courier new,monospace"> { </font></div>
<div><font face="courier new,monospace"> </font><font
face="courier new,monospace">append_branch();</font></div>
<div><font face="courier new,monospace">
xlog("L_INFO","After $var(x), ds is $ds\n"); </font> <font
face="courier new,monospace"> </font></div>
<div><font face="courier new,monospace"> $var(x) =
$var(x) + 1; </font></div>
<div><font face="courier new,monospace"> }
</font></div>
<div><font face="courier new,monospace"> }
</font></div>
<div><font face="courier new,monospace">
xlog("L_INFO","Destination set is $ds\n"); </font></div>
<div><font face="courier new,monospace">}</font></div>
<div><font face="courier new,monospace"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif">My relevant debug
output is:</font></div>
<div><font face="courier new,monospace">After 1, ds is Contact: <a
moz-do-not-send="true"
href="mailto:sip%3A15552345678@1.1.1.1">sip:15552345678@1.1.1.1</a> </font></div>
<div><font face="courier new,monospace">After 2, ds is Contact: <strong><a
moz-do-not-send="true"
href="mailto:sip%3A2215552345678@2.2.2.2">sip:2215552345678@2.2.2.2</a>,
<a moz-do-not-send="true"
href="mailto:sip%3A2215552345678@2.2.2.2">sip:2215552345678@2.2.2.2</a></strong> </font></div>
<div><font face="courier new,monospace">After 3, ds is Contact: <strong><a
moz-do-not-send="true"
href="mailto:sip%3A5552345678@3.3.3.3">sip:5552345678@3.3.3.3</a></strong>,
<a moz-do-not-send="true"
href="mailto:sip%3A2215552345678@2.2.2.2">sip:2215552345678@2.2.2.2</a>,
<strong><a moz-do-not-send="true"
href="mailto:sip%3A5552345678@3.3.3.3">sip:5552345678@3.3.3.3</a></strong> </font></div>
<div><font face="courier new,monospace">After 4, ds is Contact: <strong><a
moz-do-not-send="true"
href="mailto:sip%3A15552345678@5.5.5.5">sip:15552345678@5.5.5.5</a></strong>,
<a moz-do-not-send="true"
href="mailto:sip%3A2215552345678@2.2.2.2">sip:2215552345678@2.2.2.2</a>,
<a moz-do-not-send="true"
href="mailto:sip%3A5552345678@3.3.3.3">sip:5552345678@3.3.3.3</a>,
<strong><a moz-do-not-send="true"
href="mailto:sip%3A15552345678@5.5.5.5">sip:15552345678@5.5.5.5</a></strong> </font></div>
<div><font face="courier new,monospace">After 5, ds is Contact: <strong><a
moz-do-not-send="true"
href="mailto:sip%3A4415552345678@4.4.4.4">sip:4415552345678@4.4.4.4</a></strong>,
<a moz-do-not-send="true"
href="mailto:sip%3A2215552345678@2.2.2.2">sip:2215552345678@2.2.2.2</a>,
<a moz-do-not-send="true"
href="mailto:sip%3A5552345678@3.3.3.3">sip:5552345678@3.3.3.3</a>,
<a moz-do-not-send="true"
href="mailto:sip%3A15552345678@5.5.5.5">sip:15552345678@5.5.5.5</a>,
<strong><a moz-do-not-send="true"
href="mailto:sip%3A4415552345678@4.4.4.4">sip:4415552345678@4.4.4.4</a></strong> </font></div>
<div><font face="courier new,monospace"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif">It seems that
append_branch() deletes the first entry in the destination set
before adding the current RURI to the beginning and end. Is
there an easier or more predictable way to write to the
destination set?</font><font face="courier new,monospace"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif">Also, it seems the
append_branch() function will not take variables or avps as
parameters. Is there a known way of setting different q-values
as a destination set is generated? The below obviously
doesn't work but should explain what I'm looking for:</font><font
face="arial,helvetica,sans-serif"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif"><br>
</font></div>
<div><font face="courier new,monospace">var(q) = 90;</font><font
face="courier new,monospace"><br>
</font></div>
<div><font face="courier new,monospace">while (use_next_branch())</font><font
face="courier new,monospace"><br>
</font></div>
<div><font face="courier new,monospace">{</font><font
face="courier new,monospace"><br>
</font></div>
<div><font face="courier new,monospace">
append_branch("$ru","$var(q)");</font><font face="courier
new,monospace"><br>
</font></div>
<div><font face="courier new,monospace"> $var(q) = $var(q) -
10;</font><font face="courier new,monospace"><br>
</font></div>
<div><font face="courier new,monospace">}</font><font
face="arial,helvetica,sans-serif"><br>
</font></div>
<div><font face="courier new,monospace"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif">Thanks,</font><font
face="arial,helvetica,sans-serif"><br>
</font></div>
<div><font face="arial,helvetica,sans-serif">Ryan</font><font
face="courier new,monospace"><br>
</font></div>
<br>
</blockquote>
</body>
</html>