add IF Clause logic to a dial plan
Moderator: Brekeke Support Team
add IF Clause logic to a dial plan
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
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
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
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
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
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
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.
$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") = (.+)
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
$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
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
}