Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Using $If in Dial Plan
Author Message
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Wed Feb 28, 2024 8:26 am    Post subject: Using $If in Dial Plan Reply with quote

1. Brekeke Product Name and Version:
Brekeke SIP Server - 3.14.5.17/563.2

2. Java version:
11.0.15

3. OS type and the version:
Windows Server 2012

4. UA (phone), gateway or other hardware/software involved:
3CX

5. Your problem:

I want to use $alias.lookup to determine if a number that has been dialed from a PBX connected to BSS, is in the Alias List or not. If it is, then I want to set $rtp = false and if it is not, I want to set $rtp = true, in the Deploy Patterns.

$request = ^INVITE
$registered("UserName") = true
$addr = ^PBX_IP-Address$
To = sip:(.+)@
$alias.lookup("%1") = (.+)

This part works to determine if the number dialed (the To number) is in the Alias List or not. In other programming languages, I would do something like:

IF $alias.lookup("%1") = TRUE THEN
$rtp = false
ELSE
$rtp = true
END IF

How can something like the above be set up in the Dial Plan for BSS?

John Rayfield, Jr.

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Thu Feb 29, 2024 5:42 pm    Post subject: Reply with quote

Use $not
https://docs.brekeke.com/sip/not

Matching Patterns
$request = ^INVITE
$registered("UserName") = true
$addr = ^PBX_IP-Address$
To = sip:(.+)@
$not($alias.lookup("%1")) = (.+)
Deploy Patterns
$rtp = %2



You can also use $if

Matching Patterns
$request = ^INVITE
$registered("UserName") = true
$addr = ^PBX_IP-Address$
To = sip:(.+)@
$if($alias.lookup("%1"),"false","true") = (.+)
Deploy Patterns
$rtp = %2
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Sat Mar 02, 2024 10:56 am    Post subject: Reply with quote

Thanks for these suggestions.

This also helps me to better understand how the BSS programming works overall. In other language that I'm most familiar with, I tended to use Subprograms instead of Functions. I have to remember that with BSS, these are Functions, therefore are returning a result itself, instead of returning results in 'parameters' that are being passed through the Subprogram.

So, I see in the case of using $not, $alias.lookup is returning "true" (so in effect, the Function $alias.lookup = "true", and the $not changes that to $alias.lookup = "false". And since $alias.lookup is in (), it can be retrieved by using %2.

And in the case of using $if, since alias.lookup = "true" or "false", and alias.lookup is in (), then again, the 'value' ("true" or "false") can be retrieved by using %2.

Am I getting closer to understanding how the syntax of BSS dial plan programming works?

John

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
Back to top
View user's profile
Laurie
Brekeke Master Guru


Joined: 07 Jan 2008
Posts: 241

PostPosted: Tue Mar 05, 2024 12:18 pm    Post subject: Reply with quote

John, you are right.

In DialPlan method parameter, there is no data types such as Boolean and Integer. So the true should be written as "true".

If you are familiar with Java, you can develop your own DialPlan method.
https://docs.brekeke.com/sip/bss-dial-plan-plug-in-developers-guide
Back to top
View user's profile
JRayfield
Brekeke Guru


Joined: 03 Dec 2012
Posts: 147
Location: Springfield, MO

PostPosted: Fri Mar 08, 2024 3:40 pm    Post subject: Reply with quote

Thank you very much for the help, Laurie.

John

_________________
John Rayfield, Jr. CETma
Rayfield Communications
Springfield, MO
www.rayfield.net
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