a kind if IF THEN statement inside the rule

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
mbylica
Posts: 41
Joined: Mon May 16, 2011 1:05 pm
Location: Poland

a kind if IF THEN statement inside the rule

Post by mbylica »

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/ ... terns.html :
Pattern 9

6. Your problem:
I have implemented following rule
MATCHING PATTERN:
$addr=^10\.10\.10\.7$
$request=^INVITE
To=sip:(.{9})@

DEPLOY PATTERN:
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.
lakeview
Posts: 319
Joined: Thu Nov 15, 2007 11:54 am
Location: Florida

Post by lakeview »

Try this.
----------------------------------------
MATCHING PATTERN:
$addr = ^10\.10\.10\.7$
$request = ^INVITE
To = sip:(.+)@
$if($str.equals($str.length("%1"),"9"),"44","") = (.*)

DEPLOY PATTERN:
To = sip:%2%1@10.10.10.5
----------------------------------------

If the length of digits is 9, put "44" as the prefix.
mbylica
Posts: 41
Joined: Mon May 16, 2011 1:05 pm
Location: Poland

Post by mbylica »

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 :)

Thx.
Post Reply