Author |
Message |
Izzyg Brekeke Talented
Joined: 25 Jun 2013 Posts: 91
Location: Sip Land
|
Posted: Thu Aug 04, 2016 11:57 am Post subject: 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 |
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Thu Aug 04, 2016 4:25 pm Post subject: |
|
|
It is easy but.. what are "one thig" and "something else" ?
Are they routing to different destinations?
Or are they modifying SIP headers? |
|
Back to top |
|
Izzyg Brekeke Talented
Joined: 25 Jun 2013 Posts: 91
Location: Sip Land
|
Posted: Sat Aug 06, 2016 7:02 am Post subject: |
|
|
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 |
|
Back to top |
|
Izzyg Brekeke Talented
Joined: 25 Jun 2013 Posts: 91
Location: Sip Land
|
Posted: Mon Aug 08, 2016 9:47 am Post subject: |
|
|
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 |
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Mon Aug 08, 2016 4:10 pm Post subject: |
|
|
Does your "Register" mean SIP registration made by REGISTER request? Or it is your original registration mechanism? |
|
Back to top |
|
Izzyg Brekeke Talented
Joined: 25 Jun 2013 Posts: 91
Location: Sip Land
|
Posted: Mon Aug 08, 2016 6:57 pm Post subject: |
|
|
made by REGISTER request to brekeke server |
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Tue Aug 09, 2016 11:21 am Post subject: |
|
|
Do you use Alias database to manage whether SIP client is registered or not? |
|
Back to top |
|
Izzyg Brekeke Talented
Joined: 25 Jun 2013 Posts: 91
Location: Sip Land
|
Posted: Tue Aug 09, 2016 11:53 am Post subject: |
|
|
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 Patterns | $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 |
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Tue Aug 09, 2016 2:52 pm Post subject: |
|
|
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: |
$regaddr("%3") = (.+) |
|
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Tue Aug 09, 2016 4:16 pm Post subject: |
|
|
Matching Patterns | $request = ^INVITE To = sip:(.*)(\d{10})@ $alias.lookup("%2") = ^(...):(.+) $if($str.equals("%3","reg"),$regaddr("%4"),"%4") = (.+)
| Deploy Patterns | 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 |
|
Back to top |
|
janP Brekeke Master Guru
Joined: 25 Nov 2007 Posts: 336
|
Posted: Tue Aug 09, 2016 4:24 pm Post subject: |
|
|
The above $if means.
Code: |
// $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
}
|
|
|
Back to top |
|
|