Understanding the beroNet Dialplan
English
The Dialplan is one of the most important functions to set up during the configuration of a beroNet Gateway. It defines how calls are being routed in certain circumstances. Here are two important information to know about this tool:
- It is based on regular expressions ('Howto RegEx'.)
- It 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.
In the above example, the calls coming from our SIP account will be routed to the first ISDN port only when the number "03025938919" is called. In any other case, the calls will be routed to the ISDN port number 2. If we had put the precise rule in a second position, calls would never be routed to ISDN port 1.
As this tool is a major part of the beroNet Gateway, it is important to exactly understand how it works. Let's take a closer look at the different possible options:
- Direction (From and to ID)
- Destination and New destination
- Source and New source
- Position
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. The matchtype will be coded in the configuration file "isgw.dialplan" as a prefix before the name of the SIP Account. The following prefixes exist:
- 'p:' - Match Type IP Address only
- 'd:' - Match Type IP Address and From User
- 't:' - Match Type To User only
- 'a:' - Match Type Automatic, the Matchtype configured in the SIP account will be used.
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. Therefore two 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 "(.*)" is automatically added. This means that the rule will apply whichever the called number is. 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 traditionnal 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.
4) Position
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:
Example 1:
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
Example 2:
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'
Example 3:
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
German
Der Dialplan ist das Herzstück der Konfiguration eines beroNet VoIP Gateways. Hier wird die Zu- und Verteilung der Rufe definiert. Es ist wichtig zu wissen, dass:
- er auf „Regular Expressions“ ('Howto RegEx'.) basiert
- er von oben nach unten abgearbeitet wird. Sobald eine Regel auf einen Ruf zutrifft, wird diese angewendet, so dass es sich empfiehlt, dass präzisere Regeln über allgemeineren platziert werden.
Im obigen Beispiel gehen Rufe über einen SIP Account ein und werden über den ersten ISDN Port weitergeleitet, sofern die gewählte Rufnummer "03025938919" entspricht. In jedem anderen Fall wird das Gespräch über ISDN Port 2 weitergeleitet. Wäre nun Regel 2 über Regel 1, so würde nie ein Ruf über ISDN Port 1 weitergeleitet werden, da die allgemeinere Regel alle Rufe abfängt.
Es ist von größter Wichtigkeit den Aufbau und die Funktionsweise des Dialplans zu verstehen, da dieser ein wesentlicher Bestandteil der Funktionsweise des Gateways ist. Die einzelnen Felder im Detail sind:
- Direction (From und to ID)
- Destination und New destination
- Source und New source
- Position
- Erläuterung der „Regular Expressions“
1) Direction (From ID und To ID)
Hier wählen wir die Technologie (SIP, Analog, ISDN oder GSM) über die der Ruf eingehen soll, damit die Regel auf ihn angewendet wird. Hier wird auch bereits festgelegt über welche Technologie der Ruf dann weitergeleitet werden soll.
Wählen wir ISDN, Analog oder GSM als "From direction" oder "To direction", erhalten wir die Möglichkeit aus den bereits vorher definierten Portgruppen zu wählen. Wählen wir SIP als „From direction“ aus, so definieren wir über die Option „Match type“, ob über die IP-Adresse, dem „From oder To User“, einer manuellen Adresse oder einem „Default SIP account“ gematcht werden soll.
Für gewöhnlich funktionieren die Regeln des Dialplans paarweise, da die Weiterleitung von beispielsweise SIP zu ISDN auch in die entgegengesetzte Richtung ISDN zu SIP gewünscht ist. In diesem Fall müsste die zweite Regel separat angelegt werden.
2) Destination und New destination
Das Feld "Destination" ermöglicht es die Regel anhand einer bestimmten gewählten Rufnummer greifen zu lassen. Dieses Feld ist auch als "CalledID" oder "DAD" bekannt. Sobald das Feld leer gelassen wird, wird automatisch "(.*)" gesetzt, was die Regel bei jeder Rufnummer greifen lässt. In unserem ersten Beispiel griff die Regel sobald die Nummer "03025938919" gewählt wurde. Diese Nummer wurde über das Feld „Destination“ gesetzt.
Das Feld "New destination" ermöglicht es die „DAD“ zu ändern. Die standardmäßige Option "\1" übergibt die im Feld „Destination“ innerhalb der Klammern gesetzten Parameter an die unter „To ID“ gewählte Technologie.