[Serusers] if routeXX fails..

Marian Dumitru marian.dumitru at voice-sistem.ro
Sat Apr 23 12:04:40 CEST 2005


Hi Matt,

If you return from the route via "break", the route will return always 
true. The trick is to avoid the break instruction for leaving the route 
and to have as last instruction something which returns false for sure.
Like this stupid example:

route[x] {
	resetflag(4);
	isflagset(4);
}

route[y] {
	if ( route(x) ) {
	.......
	} else {
	.......
	}
}

route x will be evaluated as false all the time due to isflagset which 
returns false all the time.

Best regards,
Marian


Matt Schulte wrote:
> Ok, I realized I already assumed your theory :-) This is always
> returning true, even though the last statement is returning false, the
> route ultimately is still returning true.. This was just an effort to
> consolidate code for those of our custs who send by IP (rather than
> auth). Am I going about this the right way or am I barking up the wrong
> tree? I just cant seem to get it to work :-(
> 
> 	Matt
> 
> code:
> 
> route[6]
> {
> 
>                 if lookup("location") {
>                         xlog("L_INFO", "LOG: Caught usrloc %mi %rm From
> <%fu> To <%tu> RURI <%ru>\n");
>                         route(2);
>                         break;
>                 }
>                 if enum_query("blahblah")  {
>                         xlog("L_INFO", "LOG: Caught ENUM %mi %rm From
> <%fu> To <%tu> RURI <%ru>\n");
>                         route(2);
>                         break;
>                 }
>                 if (search("(f|From): .*@x.x.x.x")) {
>                         if (exec_dset("/usr/local/bin/aliases.pl")) {
>                                 xlog("L_INFO", "LOG: Caught alias %mi
> %rm From <%fu> To <%tu> RURI <%ru>\n");
>                                 route(2);
>                                 break;
>                         }
>                 }
> }
> 
> -----Original Message-----
> From: Matt Schulte 
> Sent: Thursday, April 21, 2005 6:03 PM
> To: marian.dumitru at voice-sistem.ro
> Cc: serusers at lists.iptel.org
> Subject: RE: [Serusers] if routeXX fails..
> 
> 
> I see, that makes perfect sense :-).. So I just might need to flip
> around my "if" to get it to work. 
> 
> -----Original Message-----
> From: Marian Dumitru [mailto:marian.dumitru at voice-sistem.ro] 
> Sent: Thursday, April 21, 2005 5:10 PM
> To: Matt Schulte
> Cc: serusers at lists.iptel.org
> Subject: Re: [Serusers] if routeXX fails..
> 
> 
> Hi Matt,
> 
> Basically you can do that, but be very careful since the return code of 
> a route is the return code of the *last* command executed inside the 
> route - and break always returns true!
> 
> Best regards,
> Marian
> 
> Matt Schulte wrote:
> 
>>Is it possible to do this? or is it bad practice, I'm assuming the
>>"extra" route would have to return an error code to show a 
>>nonpositive? I coulda swore I got this to work awhile back.
>>
>>if (!route(6)) {
>>         xlog("L_INFO", "NOTICE: blah <%ru> sending 404\n");
>>         sl_send_reply("404", "Not Found");
>>         break;
>>         } else {
>>         # Else route6 ran another route and break
>>         break;
>>}
>>
> 
> 

-- 
Voice System
http://www.voice-system.ro




More information about the sr-users mailing list