Forums Read-only archive

a kind if IF THEN statement inside the rule

3 posts · Brekeke SIP Server Forum

mbylica Original post
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
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
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.