- FreeSWITCH Cookbook
- Anthony Minessale Darren Schreiber Michael S Collins Raymond Chandler
- 472字
- 2021-08-20 15:44:34
Incoming DID calls
Phone calls coming in from the Public Switched Telephone Network (PSTN) are often called DID calls. DID stands for Direct Inward Dialing. DID numbers are delivered by your telephone service provider. They can be delivered over VoIP connections (such as a SIP trunk) or via traditional telephone circuits like PRI lines. These phone numbers are sometimes called "DID numbers" or "external phone numbers".
Getting ready
Routing a call requires two pieces of information—the phone number being routed and a destination for that phone number. In our example, we will use a DID number of 8005551212
. Our destination will be user 1000
. Replace these sample numbers with the appropriate values for your setup.
How to do it...
Follow these steps:
- Create a new file in
conf/dialplan/public/
named01_DID.xml
. Add this text:<include> <extension name="public_did"> <condition field="destination_number"expression="^(8005551212)$"> <action application="set" data="domain_name=$${domain}"/> <action application="transfer" data="1000 XML default"/> </condition> </extension> </include>
- Save the file and then execute
reloadxml
from thefs_cli
.
How it works...
All calls that come in to the FreeSWITCH server from outside (as well as internal calls that are not authenticated) are initially handled in the public
dialplan context (dialplan contexts were discussed in more detail in this chapter's introduction). Once the call hits the public
context, we try to match the destination_number
field. The destination_number
is generally the DID number (see the There's more section below for some caveats). Once we match the incoming number, we then set the domain_name
channel variable to the default domain value and then transfer the call to user 1000 (FreeSWITCH is domain-based in a way similar to e-mail.
Most systems have only a single domain, although FreeSWITCH supports multiple domains. See the FreeSWITCH wiki for explicit information on multiple domain configuration). The actual transfer happens with this dialplan entry:
<action application="transfer" data="1000 XML default"/>
In plain language, this tells FreeSWITCH to transfer the call to extension 1000 in the XML dialplan and the default context
. The default
context contains the Local_Extension
, which handles calls to users' telephones.
There's more...
Keep in mind the match in destination_number
must match what the provider sends to FreeSWITCH, not necessarily what the calling party actually dialed. In North America, there are providers that send DID information in various formats such as:
8005551212
18005551212
+18005551212
The expression must match what the provider sends. One way to accomplish this is to have a few optional characters in the pattern. This pattern matches all three formats listed above:
<condition field="destination_number" expression="^\+?1?(8005551212)$">
The value \+?
means optionally match a literal +
character and the value 1?
means "optionally match a literal digit 1". Now our pattern will match all three formats that are commonly used in North America (technically, our pattern will also match +8005551212
, but we are not concerned about that. However, the pedantic admin might be, so he or she can use the pattern ^(\+1)?1?(8005551212)$
instead).
See also
- The Configuring a SIP gateway section in Chapter 2, Connecting Telephones and Service Providers
- 零點起飛學Xilinx FPG
- 圖解西門子S7-200系列PLC入門
- Linux KVM虛擬化架構實戰指南
- 網絡服務器配置與管理(第3版)
- BeagleBone By Example
- 單片機原理及應用系統設計
- AMD FPGA設計優化寶典:面向Vivado/SystemVerilog
- 電腦軟硬件維修從入門到精通
- 計算機組裝與維修技術
- VCD、DVD原理與維修
- 分布式系統與一致性
- 基于Apache Kylin構建大數據分析平臺
- Managing Data and Media in Microsoft Silverlight 4:A mashup of chapters from Packt's bestselling Silverlight books
- “硬”核:硬件產品成功密碼
- Hands-On Motion Graphics with Adobe After Effects CC