The beroNet dialplan defines how calls are to be routed through a beroNet Gateway. When first approaching the beroNet diaplan it helps to understand that:
- It is based on regular expressions (‘Howto RegEx’.)
- It works from top to bottom: if you have a rule that directs all calls to a specific line above a rule that directs a specific number to your fax device, the general rule will apply and the specific rule will not function. Therefore be sure that your specific rules are above your general rules in the dialplan.
As this tool is a major part of the way a beroNet gateway works, it is important to fully understand how it works. Let’s take a closer look at the different fields in the dialplan.
- Direction (From and to ID)
- Destination and New destination
- Source and New source
1) Direction (From ID and To ID)
Here we choose the technology (SIP, Analog, ISDN or GSM) the call has to come from in order for the rule to apply. Of course, we also choose to which technology the call will be routed to.
When we choose ISDN, Analog or GSM as “from” or “to”, we have the possibility to choose either a group of ports or one port within a certain group.
On the other hand, when SIP is set as “From”, it is possible to choose the “match type”. Different possibilities are then offered: we can match via the IP address, via the from or to user, via a manual address or in a default way.
Usually, dialplan rules work as pair of two rules: when the gateway routes the call from a SIP account to ISDN lines, it is often necessary to route the calls in the other way i.e. from ISDN to SIP. To do this two different rules are necessary: one from SIP to ISDN, and the other from ISDN to SIP.
2) Destination and New destination
The “Destination” field enables a user to make a rule apply when a certain number is being dialed. This field is also known as “CalledID” or “DAD”: If the field is left empty, then the gateway will automatically insert a wildcard “(.*)”. This means that the rule will apply to any number that is called. In our first example, we explained that the first rule would apply when the number “03025938919” is called. Therefore we added this number in the destination field.
The field “new destination” enables the gateway to modify the DAD.The default “\1” sends to the “To” technology the variables that are set between brackets in the “Destination” field.
In the example above, the gateway is transparent meaning that it sends the dialed number the way it received it.
In this example, the rule will apply when the number “1234” is dialed and the gateway will rewrite this number and send “6789” to the “to” technology.
As we said in the beginning, the beroNet dialplan uses regular expressions. It enables our partners to create flexible rules without having to make a long list of possible numbers that can be dialed. It is also a good way to only send a certain number of digits. When a gateway is used to connect a traditional PBX to SIP for example, it is sometimes necessary to send only 4 digits to the PBX.
Here, the rule applies when a 10 digit number starting with 014661 is being dialed. Then the gateway sends only the 4 digits that are between brackets and leaves the 6 first ones. For more example, see below.
3) Source and New Source
The “Source” field enables beroNet gateway users to make a dialplan rule apply only when the call comes from a certain number. This field is also known as “CallerID” or “OAD”. The same regular expressions are used. The default parameters are the same as for the “Destination” and “New Destination” fields. Here is a default rule:
The “New Source” field enables beroNet users to modify the CallerID with which they call. To call anonymously, we just have to write “Anonymous” in this field. Providers usually do not allow end-users to call with a complete different CallerID but calling anonymously is almost always an option.
If nothing is changed in both fields, then the gateway does a transparent job: it sends the CallerID it receives in source to ISDN / Analog or SIP depending on the direction of the rule.
The positions of dialplan rules are very important. As we already explained at the beginning of this blog post: the dialplan “works from top to bottom: if a call matches the parameters of a rule, then the rule will apply. Therefore general rules should be placed under more precised ones.”
Let’s take a look at a few example to understand this better:
In this example, according to the first rule, all calls coming from the “SIP_Account” will be routed to the ISDN ports no matter what the CallerID (OAD) or the the CalledID (DAD) is. This means that each and every call coming from this SIP account will be routed to ISDN.
The second rule says: “calls coming from “SIP_Account” with “0156638515” as a DAD, will be routed to the analog port number 1″. However, this second rule is more precise than the first one. It will not apply as long as it is placed under it. In order for it to apply, we need to put it in the first row as below:
In this example, we can send some calls to the analog port when the number 0156638515 is being dialed and the rest is sent to ISDN.
5) Understanding the regular expressions
Regular expressions enable beroNet users to create clever dialplan rules. Depending on the information set in the “Destination / New Destination” or “Source / New Source” fields, the dialplan will make a transparent job or change the CID or DAD of a call.
Let’s take a look at some examples:
Destination: “0176(.*)” matches if calledID is starting with 0176 New Destination: “0049176\1” will cut 0176 from calledID and add 0049176 to the calledID, followed by reference to parameter 1 Source: “(..)” matches callerIDs with exact 2 digits. New Source: “25938912” CallerID will be overwritten by 25938912
Destination: ”259389([0-8][0-9])” matches all numbers starting with 259389 followed by 2 digits in the range from [00-89] New Destination: “\1” will cut 259389 from calledID and add the 2 digits referenced by parameter 1 Source “(.*)” matches any callerID New Source: “\1 “ \1 is the value in the first parenthesize of 'Source'
Destination: ”0([2-9])(.*))” matches all numbers starting with 0. The second digit has to be in range[2-9] followed by the any digits. New Destination: “\1\2” will cut 0 from calledID and add the parameter 1 followed by parameter 2 Source “(.*)” will match any callerID New Source: “\1 “ \1 is the value in the first parenthesize of 'Source' field