[OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-28 Thread thrillerbee
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@1.1.1.1
After 2, ds is Contact: *sip:2215552345678@2.2.2.2,
sip:2215552345678@2.2.2.2*
After 3, ds is Contact: *sip:5552345678@3.3.3.3*, sip:2215552345678@2.2.2.2,
*sip:5552345678@3.3.3.3*
After 4, ds is Contact: *sip:15552345678@5.5.5.5*, sip:2215552345678@2.2.2.2,
sip:5552345678@3.3.3.3, *sip:15552345678@5.5.5.5*
After 5, ds is Contact: *sip:4415552345678@4.4.4.4*,
sip:2215552345678@2.2.2.2, sip:5552345678@3.3.3.3, sip:15552345678@5.5.5.5,
*sip:4415552345678@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
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-29 Thread Anca Vamanu

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@1.1.1.1 

After 2, ds is Contact: *sip:2215552345678@2.2.2.2 
, sip:2215552345678@2.2.2.2 
*
After 3, ds is Contact: *sip:5552345678@3.3.3.3 
*, sip:2215552345678@2.2.2.2 
, *sip:5552345678@3.3.3.3 
*
After 4, ds is Contact: *sip:15552345678@5.5.5.5 
*, sip:2215552345678@2.2.2.2 
, sip:5552345678@3.3.3.3 
, *sip:15552345678@5.5.5.5 
*
After 5, ds is Contact: *sip:4415552345678@4.4.4.4 
*, sip:2215552345678@2.2.2.2 
, sip:5552345678@3.3.3.3 
, sip:15552345678@5.5.5.5 
, *sip:4415552345678@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

___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-29 Thread Bogdan-Andrei Iancu

Hi,

Another tricks:

1) you can read the pending destinations directly from AVPs, without 
calling the "use_next_gw()" function. See:

   http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166

2) as append_branch() does not accept variables as params, use the 
"$branch" variable to write into:

   http://www.opensips.org/Resources/DocsCoreVar16#toc15
   like:
  $branch = $var(x) ; #add a new SIP URI as extra branch
  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach


Regards,
Bogdan


Anca Vamanu wrote:

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@1.1.1.1 
 
After 2, ds is Contact: *sip:2215552345678@2.2.2.2 
, sip:2215552345678@2.2.2.2 
* 
After 3, ds is Contact: *sip:5552345678@3.3.3.3 
*, sip:2215552345678@2.2.2.2 
, *sip:5552345678@3.3.3.3 
* 
After 4, ds is Contact: *sip:15552345678@5.5.5.5 
*, sip:2215552345678@2.2.2.2 
, sip:5552345678@3.3.3.3 
, *sip:15552345678@5.5.5.5 
* 
After 5, ds is Contact: *sip:4415552345678@4.4.4.4 
*, sip:2215552345678@2.2.2.2 
, sip:5552345678@3.3.3.3 
, sip:15552345678@5.5.5.5 
, *sip:4415552345678@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




___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
  



--
Bogdan-Andrei Iancu
OpenSIPS eBootcamp - 2nd of May 2011
OpenSIPS solutions and "know-how"


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-29 Thread thrillerbee
Bogdan,

When I configure:
$(branch(uri)[0]) = $ru;
$(branch(q)[0]) = 100;
xlog("L_INFO","branch 0 = $(branch(uri)[0]) with q-value
$(branch(q)[0])\n");

I get this debug:
ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
[0/0]
ERROR:core:do_assign: setting PV failed
ERROR:core:do_assign: error at line: 163
ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
[0/0]
ERROR:core:do_assign: setting PV failed
ERROR:core:do_assign: error at line: 164
branch 0 =  with q-value 

Thanks,
Ryan


On Tue, Mar 29, 2011 at 8:19 AM, Bogdan-Andrei Iancu wrote:

> Hi,
>
> Another tricks:
>
> 1) you can read the pending destinations directly from AVPs, without
> calling the "use_next_gw()" function. See:
>   http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166
>
> 2) as append_branch() does not accept variables as params, use the
> "$branch" variable to write into:
>   http://www.opensips.org/Resources/DocsCoreVar16#toc15
>   like:
>  $branch = $var(x) ; #add a new SIP URI as extra branch
>  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach
>
>
> Regards,
> Bogdan
>
>
> Anca Vamanu wrote:
>
>> 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@1.1.1.1 >> sip%3A15552345678@1.1.1.1> After 2, ds is Contact: *
>>> sip:2215552345678@2.2.2.2 ,
>>> sip:2215552345678@2.2.2.2 * After 3,
>>> ds is Contact: *sip:5552345678@3.3.3.3 *,
>>> sip:2215552345678@2.2.2.2 , *
>>> sip:5552345678@3.3.3.3 * After 4, ds is
>>> Contact: *sip:15552345678@5.5.5.5 *,
>>> sip:2215552345678@2.2.2.2 ,
>>> sip:5552345678@3.3.3.3 , *
>>> sip:15552345678@5.5.5.5 * After 5, ds
>>> is Contact: *sip:4415552345678@4.4.4.4 >> sip%3A4415552345678@4.4.4.4>*, sip:2215552345678@2.2.2.2 >> sip%3A2215552345678@2.2.2.2>, sip:5552345678@3.3.3.3 >> sip%3A5552345678@3.3.3.3>, sip:15552345678@5.5.5.5 >> sip%3A15552345678@5.5.5.5>, *sip:4415552345678@4.4.4.4 >> sip%3A4415552345678@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
>>>
>>>  
>>
>> ___
>> Users mailing list
>> Users@lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
>
> --
> Bogdan-Andrei Iancu
> OpenSIPS eBootcamp - 2n

Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-29 Thread thrillerbee
Bogdan,

Nevermind on that issue; I neglected to notice that I had to create the
branch with append_branch() before setting anything.

Thanks for the help.
Ryan


On Tue, Mar 29, 2011 at 9:52 AM, thrillerbee  wrote:

> Bogdan,
>
> When I configure:
> $(branch(uri)[0]) = $ru;
> $(branch(q)[0]) = 100;
> xlog("L_INFO","branch 0 = $(branch(uri)[0]) with q-value
> $(branch(q)[0])\n");
>
> I get this debug:
> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
> [0/0]
> ERROR:core:do_assign: setting PV failed
> ERROR:core:do_assign: error at line: 163
> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
> [0/0]
> ERROR:core:do_assign: setting PV failed
> ERROR:core:do_assign: error at line: 164
> branch 0 =  with q-value 
>
> Thanks,
> Ryan
>
>
> On Tue, Mar 29, 2011 at 8:19 AM, Bogdan-Andrei Iancu 
> wrote:
>
>> Hi,
>>
>> Another tricks:
>>
>> 1) you can read the pending destinations directly from AVPs, without
>> calling the "use_next_gw()" function. See:
>>   http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166
>>
>> 2) as append_branch() does not accept variables as params, use the
>> "$branch" variable to write into:
>>   http://www.opensips.org/Resources/DocsCoreVar16#toc15
>>   like:
>>  $branch = $var(x) ; #add a new SIP URI as extra branch
>>  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach
>>
>>
>> Regards,
>> Bogdan
>>
>>
>> Anca Vamanu wrote:
>>
>>> 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@1.1.1.1 >>> sip%3A15552345678@1.1.1.1> After 2, ds is Contact: *
 sip:2215552345678@2.2.2.2 ,
 sip:2215552345678@2.2.2.2 * After
 3, ds is Contact: *sip:5552345678@3.3.3.3 >>> sip%3A5552345678@3.3.3.3>*, sip:2215552345678@2.2.2.2 >>> sip%3A2215552345678@2.2.2.2>, *sip:5552345678@3.3.3.3 >>> sip%3A5552345678@3.3.3.3>* After 4, ds is Contact: *
 sip:15552345678@5.5.5.5 *,
 sip:2215552345678@2.2.2.2 ,
 sip:5552345678@3.3.3.3 , *
 sip:15552345678@5.5.5.5 * After 5, ds
 is Contact: *sip:4415552345678@4.4.4.4 >>> sip%3A4415552345678@4.4.4.4>*, sip:2215552345678@2.2.2.2 >>> sip%3A2215552345678@2.2.2.2>, sip:5552345678@3.3.3.3 >>> sip%3A5552345678@3.3.3.3>, sip:15552345678@5.5.5.5 >>> sip%3A15552345678@5.5.5.5>, *sip:4415552345678@4.4.4.4 >>> sip%3A4415552345678@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)

Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-29 Thread thrillerbee
Hopefully my last question:

Using append_branch() and $branch allows me to add all destinations as
branches with q-values. However, I am unable to remove/edit the initial
entry in $ds as set by do_routing():

Contact: *sip:15552345678@1.1.1.1, *;q=1, <
sip:2215552345678@2.2.2.2>;q=0.9, ;q=0.85, <
sip:15552345678@5.5.5.5>;q=0.8, ;q=0.75

Is there a way to prevent do_routing from adding that entry and/or remove it
after it has been added? OR is there a way to add a q-value to that
instance?

Thanks,
Ryan

On Tue, Mar 29, 2011 at 10:51 AM, thrillerbee  wrote:

> Bogdan,
>
> Nevermind on that issue; I neglected to notice that I had to create the
> branch with append_branch() before setting anything.
>
> Thanks for the help.
> Ryan
>
>
> On Tue, Mar 29, 2011 at 9:52 AM, thrillerbee wrote:
>
>> Bogdan,
>>
>> When I configure:
>> $(branch(uri)[0]) = $ru;
>> $(branch(q)[0]) = 100;
>> xlog("L_INFO","branch 0 = $(branch(uri)[0]) with q-value
>> $(branch(q)[0])\n");
>>
>> I get this debug:
>> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
>> [0/0]
>> ERROR:core:do_assign: setting PV failed
>> ERROR:core:do_assign: error at line: 163
>> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
>> [0/0]
>> ERROR:core:do_assign: setting PV failed
>> ERROR:core:do_assign: error at line: 164
>> branch 0 =  with q-value 
>>
>> Thanks,
>> Ryan
>>
>>
>> On Tue, Mar 29, 2011 at 8:19 AM, Bogdan-Andrei Iancu > > wrote:
>>
>>> Hi,
>>>
>>> Another tricks:
>>>
>>> 1) you can read the pending destinations directly from AVPs, without
>>> calling the "use_next_gw()" function. See:
>>>   http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166
>>>
>>> 2) as append_branch() does not accept variables as params, use the
>>> "$branch" variable to write into:
>>>   http://www.opensips.org/Resources/DocsCoreVar16#toc15
>>>   like:
>>>  $branch = $var(x) ; #add a new SIP URI as extra branch
>>>  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach
>>>
>>>
>>> Regards,
>>> Bogdan
>>>
>>>
>>> Anca Vamanu wrote:
>>>
 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@1.1.1.1  sip%3A15552345678@1.1.1.1> After 2, ds is Contact: *
> sip:2215552345678@2.2.2.2 ,
> sip:2215552345678@2.2.2.2 * After
> 3, ds is Contact: *sip:5552345678@3.3.3.3  sip%3A5552345678@3.3.3.3>*, sip:2215552345678@2.2.2.2  sip%3A2215552345678@2.2.2.2>, *sip:5552345678@3.3.3.3  sip%3A5552345678@3.3.3.3>* After 4, ds is Contact: *
> sip:15552345678@5.5.5.5 *,
> sip:2215552345678@2.2.2.2 ,
> sip:5552345678@3.3.3.3 , *
> sip:15552345678@5.5.5.5 * After 5,
> ds is Contact: *sip:4415552345678@4.4.4.4  sip%3A4415552345678@4.4.4.4>*, sip:2215552345678@2.2.2.2  sip%3A2215552345678@2.2.2.2>, sip:5552345678@3.3.3.3  sip%3A5552345678@3.3.3.3>, sip:15552345678@5.5.5.5  sip%3A155523456

Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-31 Thread thrillerbee
bump.

On Tue, Mar 29, 2011 at 11:27 AM, thrillerbee  wrote:

> Hopefully my last question:
>
> Using append_branch() and $branch allows me to add all destinations as
> branches with q-values. However, I am unable to remove/edit the initial
> entry in $ds as set by do_routing():
>
> Contact: *sip:15552345678@1.1.1.1, *;q=1, <
> sip:2215552345678@2.2.2.2>;q=0.9, ;q=0.85, <
> sip:15552345678@5.5.5.5>;q=0.8, ;q=0.75
>
> Is there a way to prevent do_routing from adding that entry and/or remove
> it after it has been added? OR is there a way to add a q-value to that
> instance?
>
> Thanks,
> Ryan
>
> On Tue, Mar 29, 2011 at 10:51 AM, thrillerbee wrote:
>
>> Bogdan,
>>
>> Nevermind on that issue; I neglected to notice that I had to create the
>> branch with append_branch() before setting anything.
>>
>> Thanks for the help.
>> Ryan
>>
>>
>> On Tue, Mar 29, 2011 at 9:52 AM, thrillerbee wrote:
>>
>>> Bogdan,
>>>
>>> When I configure:
>>> $(branch(uri)[0]) = $ru;
>>> $(branch(q)[0]) = 100;
>>> xlog("L_INFO","branch 0 = $(branch(uri)[0]) with q-value
>>> $(branch(q)[0])\n");
>>>
>>> I get this debug:
>>> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
>>> [0/0]
>>> ERROR:core:do_assign: setting PV failed
>>> ERROR:core:do_assign: error at line: 163
>>> ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch assigment
>>> [0/0]
>>> ERROR:core:do_assign: setting PV failed
>>> ERROR:core:do_assign: error at line: 164
>>> branch 0 =  with q-value 
>>>
>>> Thanks,
>>> Ryan
>>>
>>>
>>> On Tue, Mar 29, 2011 at 8:19 AM, Bogdan-Andrei Iancu <
>>> bog...@opensips.org> wrote:
>>>
 Hi,

 Another tricks:

 1) you can read the pending destinations directly from AVPs, without
 calling the "use_next_gw()" function. See:

 http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166

 2) as append_branch() does not accept variables as params, use the
 "$branch" variable to write into:
   http://www.opensips.org/Resources/DocsCoreVar16#toc15
   like:
  $branch = $var(x) ; #add a new SIP URI as extra branch
  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach


 Regards,
 Bogdan


 Anca Vamanu wrote:

> 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@1.1.1.1 > sip%3A15552345678@1.1.1.1> After 2, ds is Contact: *
>> sip:2215552345678@2.2.2.2 ,
>> sip:2215552345678@2.2.2.2 * After
>> 3, ds is Contact: *sip:5552345678@3.3.3.3 > sip%3A5552345678@3.3.3.3>*, sip:2215552345678@2.2.2.2 > sip%3A2215552345678@2.2.2.2>, *sip:5552345678@3.3.3.3 > sip%3A5552345678@3.3.3.3>* After 4, ds is Contact: *
>> sip:15552345678@5.5.5.5 *,
>> sip:2215552345678@2.2.2.2 ,
>> sip:5552345678@3.3.3.3 , *
>> sip:15552345678@5.5.5.5 

Re: [OpenSIPS-Users] drouting module with append_branch() and q-values

2011-03-31 Thread thrillerbee
I was able to manipulate $ru as set by do_routing() to get the behavior I'm
looking for. It's not very clean, but it's functional.

On Thu, Mar 31, 2011 at 9:00 AM, thrillerbee  wrote:

> bump.
>
>
> On Tue, Mar 29, 2011 at 11:27 AM, thrillerbee wrote:
>
>> Hopefully my last question:
>>
>> Using append_branch() and $branch allows me to add all destinations as
>> branches with q-values. However, I am unable to remove/edit the initial
>> entry in $ds as set by do_routing():
>>
>> Contact: *sip:15552345678@1.1.1.1, *;q=1, <
>> sip:2215552345678@2.2.2.2>;q=0.9, ;q=0.85, <
>> sip:15552345678@5.5.5.5>;q=0.8, ;q=0.75
>>
>> Is there a way to prevent do_routing from adding that entry and/or remove
>> it after it has been added? OR is there a way to add a q-value to that
>> instance?
>>
>> Thanks,
>> Ryan
>>
>> On Tue, Mar 29, 2011 at 10:51 AM, thrillerbee wrote:
>>
>>> Bogdan,
>>>
>>> Nevermind on that issue; I neglected to notice that I had to create the
>>> branch with append_branch() before setting anything.
>>>
>>> Thanks for the help.
>>> Ryan
>>>
>>>
>>> On Tue, Mar 29, 2011 at 9:52 AM, thrillerbee wrote:
>>>
 Bogdan,

 When I configure:
 $(branch(uri)[0]) = $ru;
 $(branch(q)[0]) = 100;
 xlog("L_INFO","branch 0 = $(branch(uri)[0]) with q-value
 $(branch(q)[0])\n");

 I get this debug:
 ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch
 assigment [0/0]
 ERROR:core:do_assign: setting PV failed
 ERROR:core:do_assign: error at line: 163
 ERROR:core:pv_set_branch_fields: SCRIPT BUG - inexisting branch
 assigment [0/0]
 ERROR:core:do_assign: setting PV failed
 ERROR:core:do_assign: error at line: 164
 branch 0 =  with q-value 

 Thanks,
 Ryan


 On Tue, Mar 29, 2011 at 8:19 AM, Bogdan-Andrei Iancu <
 bog...@opensips.org> wrote:

> Hi,
>
> Another tricks:
>
> 1) you can read the pending destinations directly from AVPs, without
> calling the "use_next_gw()" function. See:
>
> http://www.opensips.org/html/docs/modules/1.6.x/drouting.html#id293166
>
> 2) as append_branch() does not accept variables as params, use the
> "$branch" variable to write into:
>   http://www.opensips.org/Resources/DocsCoreVar16#toc15
>   like:
>  $branch = $var(x) ; #add a new SIP URI as extra branch
>  $(branch(q)[-1])  =  10 ;  # set Q val for the last added brach
>
>
> Regards,
> Bogdan
>
>
> Anca Vamanu wrote:
>
>> 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@1.1.1.1 >> sip%3A15552345678@1.1.1.1> After 2, ds is Contact: *
>>> sip:2215552345678@2.2.2.2 ,
>>> sip:2215552345678@2.2.2.2 *
>>> After 3, ds is Contact: *sip:5552345678@3.3.3.3 >> sip%3A5552345678@3.3.3.3>*, sip:2215552345678@2.2.2.2 >> sip%3A2215552345678@2.2.2.2>, *