[OpenSIPS-Users] drouting module with append_branch() and q-values
Anca Vamanu
anca at opensips.org
Tue Mar 29 12:43:20 CEST 2011
Hi thrillerbe,
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-
http://www.opensips.org/html/docs/modules/devel/drouting.html#id251519).
It would be something like this:
if (do_routing("1","2"))
{
if ($avp(s:dr_rules_attrs) == "2")
{
xlog("L_INFO","After 1, ds is $ru\n");
$var(x) = 2;
$var(ds) = $ru;
while (use_next_gw())
{
$var(ds) = $var(ds) + "," + $ru;
xlog("L_INFO","After $var(x), ds is $var(ds)\n");
$var(x) = $var(x) + 1;
}
}
xlog("L_INFO","Destination set is $var(ds)\n");
}
Regards,
--
Anca Vamanu
OpenSIPS Developer
On 03/29/2011 01:00 AM, thrillerbee wrote:
> 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.
>
> I'm running release version 1.6.4-2-notls.
>
> With that, I've configured the following in my script:
> if (do_routing("1","2"))
> {
> if ($avp(s:dr_rules_attrs) == "2")
> {
> xlog("L_INFO","After 1, ds is $ds\n");
> $var(x) = 2;
> while (use_next_gw())
> {
> append_branch();
> xlog("L_INFO","After $var(x), ds is $ds\n");
> $var(x) = $var(x) + 1;
> }
> }
> xlog("L_INFO","Destination set is $ds\n");
> }
>
> My relevant debug output is:
> After 1, ds is Contact: sip:15552345678 at 1.1.1.1
> <mailto:sip%3A15552345678 at 1.1.1.1>
> After 2, ds is Contact: *sip:2215552345678 at 2.2.2.2
> <mailto:sip%3A2215552345678 at 2.2.2.2>, sip:2215552345678 at 2.2.2.2
> <mailto:sip%3A2215552345678 at 2.2.2.2>*
> After 3, ds is Contact: *sip:5552345678 at 3.3.3.3
> <mailto:sip%3A5552345678 at 3.3.3.3>*, sip:2215552345678 at 2.2.2.2
> <mailto:sip%3A2215552345678 at 2.2.2.2>, *sip:5552345678 at 3.3.3.3
> <mailto:sip%3A5552345678 at 3.3.3.3>*
> After 4, ds is Contact: *sip:15552345678 at 5.5.5.5
> <mailto:sip%3A15552345678 at 5.5.5.5>*, sip:2215552345678 at 2.2.2.2
> <mailto:sip%3A2215552345678 at 2.2.2.2>, sip:5552345678 at 3.3.3.3
> <mailto:sip%3A5552345678 at 3.3.3.3>, *sip:15552345678 at 5.5.5.5
> <mailto:sip%3A15552345678 at 5.5.5.5>*
> After 5, ds is Contact: *sip:4415552345678 at 4.4.4.4
> <mailto:sip%3A4415552345678 at 4.4.4.4>*, sip:2215552345678 at 2.2.2.2
> <mailto:sip%3A2215552345678 at 2.2.2.2>, sip:5552345678 at 3.3.3.3
> <mailto:sip%3A5552345678 at 3.3.3.3>, sip:15552345678 at 5.5.5.5
> <mailto:sip%3A15552345678 at 5.5.5.5>, *sip:4415552345678 at 4.4.4.4
> <mailto:sip%3A4415552345678 at 4.4.4.4>*
>
> 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?
>
> 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:
>
> var(q) = 90;
> while (use_next_branch())
> {
> append_branch("$ru","$var(q)");
> $var(q) = $var(q) - 10;
> }
>
> Thanks,
> Ryan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20110329/d7b6078d/attachment-0001.htm>
More information about the Users
mailing list