add IF Clause logic to a dial plan

Discuss any topic about Brekeke SIP Server.

Moderator: Brekeke Support Team

Post Reply
Izzyg
Posts: 91
Joined: Tue Jun 25, 2013 1:14 pm
Location: Sip Land

add IF Clause logic to a dial plan

Post by Izzyg »

1. Brekeke Product Name and Version:
3.5.5.2 Advanced

2. Java version: 1.8.0_91

3. OS type and the version: Windows Server 2012 R2

4. UA (phone), gateway or other hardware/software involved: SIP Proxy Server

5. Your problem:

i would like to build a Dial Plan that will have a IF clause

IF the Alias Lookup returns value YES then do one thig
IF the Alias Lookup returns anything other then YES, then do something else
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

It is easy but.. what are "one thig" and "something else" ?
Are they routing to different destinations?
Or are they modifying SIP headers?
Izzyg
Posts: 91
Joined: Tue Jun 25, 2013 1:14 pm
Location: Sip Land

Post by Izzyg »

i want to take whats in the To Field, and match if i find that value in the Alias Table

the Alias Table also has 2 other fields, 1 says "Register", and the other has the Customers Registered Sip User Name


so after i do the Alias Table lookup, if it is "Register" then i will send the call to the Value from the 2nd field, since it is registered to the Brekeke

if the Value is not "Register", then the value will have the IP info where to route the call, and in this case i know how to route the call

but how do i add the IF's
Izzyg
Posts: 91
Joined: Tue Jun 25, 2013 1:14 pm
Location: Sip Land

Post by Izzyg »

i have some phone numbers which i want to route to another IP Address, but some Phone Numbers i need to route it to a SIP Peer that is registered to the Brekeke... how else can i accomplish it
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

Does your "Register" mean SIP registration made by REGISTER request? Or it is your original registration mechanism?
Izzyg
Posts: 91
Joined: Tue Jun 25, 2013 1:14 pm
Location: Sip Land

Post by Izzyg »

made by REGISTER request to brekeke server
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

Do you use Alias database to manage whether SIP client is registered or not?
Izzyg
Posts: 91
Joined: Tue Jun 25, 2013 1:14 pm
Location: Sip Land

Post by Izzyg »

this is what my Dial Plan does now:


i match for Invites
i take the 10 digits in the TO field
i check in the Alias Table what is the value of the REG column for this phone number (i get the phone number from doing: To = sip:(.*)(\d{10})@)
i check what is the IP Address of the Registered SIP Client (i get the registered SIP Client Username from doing: $alias.lookup ("%2", "REG") = (.+))



Matching Pattern:
$request = ^INVITE
To = sip:(.*)(\d{10})@
$alias.lookup ("%2", "REG") = (.+)
$regaddr ("%4") = (.+)



in the deploy pattern i send the call to the IP Address i got when i did the "$regaddr ("%5") = (.+)"

Here is what my Alias Table looks like:

AliasName: 2125551212
GroupID: REG
EntityName: Clients SIP Username


and id like to add this scenario:

IF the 10 Digit phone number GroupID is 1, then i dont need to get the Registered Address of the SIP Client, rather i just need to get the Value from the EntityName, and route the call there
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

Matching Patterns
$request = ^INVITE
To = sip:(.*)(\d{10})@
$alias.lookup("%2", "REG") = (.+)
$regaddr("%4") = (.+)

Izzyg, is it a current DialPlan rule?
I think it will not work because there is no () for %4.

If you want to execute $regaddr with a username, you need to put %3 instead of %4.

Code: Select all

$regaddr("%3") = (.+)
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

Matching Patterns
$request = ^INVITE
To = sip:(.*)(\d{10})@
$alias.lookup("%2") = ^(...):(.+)
$if($str.equals("%3","reg"),$regaddr("%4"),"%4")=(.+)

Deploy Pattern:
To = sip:%1%2@%5


Alias example for a registered user
AlaisName: 2125551212
EntityName: reg:username

Alias example for non-registered destination
AlaisName: 2125551213
EntityName: dst:99.99.99.99
janP
Posts: 336
Joined: Sun Nov 25, 2007 2:55 pm

Post by janP »

The above $if means.

Code: Select all

 
  // $if($str.equals("%3","reg"),$regaddr("%4"),"%4") 

  if (%3 == "reg" ) {
     // If the prefix is "reg:", the value is a SIP username
     return $regaddr("%4")   // return the registered IP addr
  }
  else {
     // If the prefix is "dst:", the value is an IP address
     return %4"   // return the IP address
  }
Post Reply