Implementation of interconnection between two Yate servers

Source: Internet
Author: User
Document directory
  • I. Introduction
  • II. Implementation Method
  • Iii. regexroute
  • Iv. Specific Configuration
  • 5. Regular Expressions
I. Introduction

Based on the research progress, we already know that on a Yate server, we can use the simple registration and Authentication Module: regfile to configure user information. users in the same domain can successfully register on a Yate server, and the call is successful. But what we have not done is how to connect two Yate servers so that one Yate user can call another Yate user.

The case is as follows. Assume that the IP addresses of the two Yate servers, ya, ya, 192.168.114.51, and Yb, are 192.168.114.52. The domain and IP address of the two servers are the same. 101 users are activated on the ya server, 202 users are activated on the Yb server, and mutual calls between 101 and 202 are required.

II. Implementation Method

To enable intercommunication between two Yate servers, the server must implement the SIP proxy function. View the document and find that in Yate, the proxy function is implemented through the route (route) module. The common route module is the regexroute module, and you can write the routing module by yourself. The regexroute module is used below.

Iii. regexroute

The regexroute module provides a simple method to route Telecom calls within Yate. This module uses a configuration file for configuration. Two messages are processed in regexroute:

  • Preroute
  • In preroute message processing, the module classifies callers and classifies them into a context.

  • Route
  • In a route message, the module maps the call to the target channel or module described in a string based on the called number.

A) preroute stage

In the preroute phase, the caller matches the strings in [contexts] sequentially. The matching result is "context", which is further processed in the corresponding "context" section. For example:

[Contexts]
^ $ = Empty
^ 00 = International
^ 0 = longdistance
. * = Default

The above line = the regular expression to be matched on the left, and the matching context result on the right. For more information about the regular expression rules, see the regular expression section.

In the preceding example, all callers whose names start with 00 are processed using context as international, while those whose names start with 0 are processed using longdistance. The default value is used for processing by default.

Then you can add the context section after the configuration file, for example:
[International]
[Longdistance]
[Default]

B) Route stage

In the route stage, the called number matches the Regular Expression in sequence according to the context section. After successful match, the called number matches the target.

The first character of a matched target has a special meaning:

  • Return-this context returns immediately without routing
  • Include-call another context. If the other context does not return successfully, it is returned from the next object.
  • Jump-jump to another context, but the context is no longer returned.
  • Match-Modify matched strings to replace specific targets
  • Echo-only display the replaced rows

The module also allows you to set message parameters in the form of name = value. Each parameter is separated by a semicolon (;).

C) Example

^ 00/(. */) $ = IAX // 1@internat.ion.al // 0
Match All characters starting with 00. If we call: 0099123456, the module returns: IAX/99123456@internat.ion.al/009912
3456. The/0 and/1 parameters in the following target are parameters, and the preceding characters are/0. In this example, 0099123456 AND/1 are parameters between the first/(/) in the match, /2 is the second/(/) parameter in the match. /1 is 99123456 In the example.

Route 112 and 911 to pots (common telephone service), that is, any channel of E1, and force the specified encoding:
^ 112 $ = zap/1-31; format = alaw
^ 911 $ = zap/1-31; format = mulaw

Route internal calls through sip and replace the caller Name:
^ 00/(. */) $ = Sip/SIP:/1@international.gateway; callername = International call

IAX route value-added services:
^ 09/(. */) $ = IAX/vap@gateway.for.vap // 1

All other items starting with 0 are connected to the h323 gateway.
^ 0/(. */) $ = h323 // 1@long.distance.gateway

For other illegal calls, we can give the user a recording of "you dialed an empty number:
. * = Wave/play/sounds/invalid_number.gsm

Iv. Specific Configuration

As described above, we configure the server ya192.168.114.51 as follows:

Because we do not need to classify callers, the context section only enables the default, that is, all callers are processed through the default context; of course, we should adjust it according to the actual situation. It should be noted that the matched strings are not called by the caller (caller user.

[Contexts]
. * = Default

The configuration of the default context section is as follows:
[Default]
^ 99991001 $ = tone/dial
^ 99991002 $ = tone/busy
^ 99991003 $ = tone/Ring
^ 99991004 $ = tone/specdial
^ 99991005 $ = tone/congestion
^ 99991006 $ = tone/outoforder
^ 99991007 $ = tone/milliwatt
^ 202 $ = Sip/SIP:/0@192.168.114.52

The last line is what we added, which means it is clear that if the call is 202, internal routing is performed through the SIP and the caller name is replaced with the 202@192.168.114.52, because we know that 202 is registered in the 192.168.114.52 domain, we will tell Yate to route the call to 202 (proxy) to the 202@192.168.114.52, yate will act as the role of the SIP proxy to transfer the call to 192.168.114.52 (Yb), 192.168.114.52 and then call the user to 202. In this way, we can successfully call 101 to 202. The opposite process is similar.

5. Regular Expressions

Regexroute uses regular expressions similar to those in Linux SED and grep.

^ Start of matching string
$ End of matching string
. Match any character
[LIST] Match a character in the list, such as [A-Z]. match any character between a-Z.
[^ List] Match is not a character in the list
  The list can be a separate character, such as [a, B,], or an interval of characters, such as [A-Z].
* Matches arbitrary duplicates of the preceding expression, including 0
/+ Match the previous expression with a repeat value greater than or equal to 1
/? Match the previous expression 0 or 1 repeat
/{N /} Match the exact n duplicates of the previous expression
/{N ,/} Match the previous expression with N duplicates
/{N, m /} Match the previous expression n to m times
/(/) Capture included subexpressions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.