Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
a kind if IF THEN statement inside the rule
Author Message
mbylica
Brekeke Addict


Joined: 16 May 2011
Posts: 41
Location: Poland

PostPosted: Tue Mar 20, 2012 4:14 pm    Post subject: a kind if IF THEN statement inside the rule Reply with quote

1. Brekeke Product Name and version:
2.4.8.6

2. Java version:
1.6.0_25

3. OS type and the version:
linux centos 5.5

4. UA (phone), gateway or other hardware/software involved:
doesn't matter

5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/networkpatterns.html :
Pattern 9

6. Your problem:
I have implemented following rule
Matching Patterns
$addr = ^10\.10\.10\.7$
$request = ^INVITE
To = sip:(.{9})@
Deploy Patterns
To = sip:44%1@10.10.10.5

and it works fine.

My question is whether we may create a kind of IF THEN statement inside single rule to work as follows:
1) IF To=sip:(.{9})@ then To=sip:44%1@10.10.10.5 (if 9 digits then add 44)
2) IF To=sip:(.+)@ then To=sip:%1@10.10.10.5 (if not 9 digits then pass the number as it is)

Of course we may create two rules, but to cut down number of rules this might be interesting.

Thanks in advance,
Maciej.
Back to top
View user's profile
lakeview
Brekeke Master Guru


Joined: 15 Nov 2007
Posts: 319
Location: Florida

PostPosted: Wed Mar 21, 2012 12:25 pm    Post subject: Reply with quote

Try this.
Matching Patterns
$addr = ^10\.10\.10\.7$
$request = ^INVITE
To = sip:(.+)@
$if($str.equals($str.length("%1"),"9"),"44","") = (.*)
Deploy Patterns
To = sip:%2%1@10.10.10.5


If the length of digits is 9, put "44" as the prefix.
Back to top
View user's profile
mbylica
Brekeke Addict


Joined: 16 May 2011
Posts: 41
Location: Poland

PostPosted: Wed Mar 21, 2012 3:46 pm    Post subject: Reply with quote

Thanks a lot
It works like a charm

I see the explaination of str.equals in bss admin guide, but didn't imagine of such usage Smile

Thx.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1