Preface
A lot has happened in the three years since the original FreeSWITCH 1.0.6 book was released. At the time, FreeSWITCH 1.0 was only about two years old. A number of early adopters became staunch believers in this relative newcomer. Many others became introduced to FreeSWITCH with the help of a shiny new FreeSWITCH book from Packt Publishing. A few short years later the FreeSWITCH Cookbook was also released. Things were happening quickly.
In the meantime the FreeSWITCH team remained active in their development efforts. New features have been added and existing features have been optimized and enhanced. Even prior to the release of FreeSWITCH 1.2.0 we knew that we would eventually want to revise what we affectionately called the bridge book.
When writing of this edition began, FreeSWITCH 1.2.1 had just come out. In the ensuing months a number of subsequent versions were released. At the time of this writing, the FreeSWITCH project had just moved Version 1.2.8 to stable status, meaning no more features will be added, only bug fixes. The new development branch will eventually result in FreeSWITCH Version 1.4. Will we see a FreeSWITCH 1.4 book released in 2016? Only time will tell, but we wouldn't bet against it.
Like we did with the previous edition of this book, we want to answer a few important questions.
Is FreeSWITCH right for me? The correct answer is always the same, it depends. The FreeSWITCH development team and long-time users are often asked which telephony platform to use. The answer is always the same: use what works for you and your scenario. While we may favor FreeSWITCH we also recognize that every situation is different. If Asterisk or Yate is a better fit for what you want to accomplish then by all means use them. We are very bullish on open source software.
What is FreeSWITCH? FreeSWITCH is a scalable softswitch. In practical terms, this means that it can do anything a traditional PBX can do and much more. It can (and does) act as the core switching software for commercial carriers. It can scale up to handle thousands of simultaneous calls. It can also scale down to act as a simple softphone for your laptop or personal computer. It can also work in a cluster of servers. FreeSWITCH is the telephony engine that powers the CudaTel Communication Server from Barracuda Networks.
FreeSWITCH is not a proxy server. If you need proxy server functionality, then consider OpenSIPS, Kamailio, Repro, or other similar software. FreeSWITCH is a back-to-back user agent or B2BUA. In this regard, it is similar to Asterisk and other IP PBX software.
Which open source license does FreeSWITCH use? FreeSWITCH is released under the Mozilla Public License (MPL) Version 1.1. Since FreeSWITCH is a library that can be implemented in other software applications and projects, the developers felt it important to strike a balance between the extremely liberal BSD license and the so-called viral GPL. The MPL fits this paradigm well and allows businesses to create commercial products based on FreeSWITCH without licensing concerns.
However, what about using FreeSWITCH with GPL-based software? It should suffice if we said that the developers wanted to make sure that anyone, including proprietary and GPL-based software users, could use FreeSWITCH. The powerful event socket gives us this functionality, a simple TCP socket-based interface that allows an external program to control FreeSWITCH. Regardless of the license you may be using for your own software, you can still connect to a FreeSWITCH server without any licensing issues.
What this book covers
Chapter 1, Architecture of FreeSWITCH, gives a brief, but thorough introduction to the underlying architecture of FreeSWITCH.
Chapter 2, Building and Installation, shows how to download and install FreeSWITCH on Windows and Unix-like operating systems.
Chapter 3, Test Driving the Example Configuration, provides a hands-on look at the powerful and feature-rich example FreeSWITCH configuration.
Chapter 4, SIP and the User Directory, offers an introduction to the concept of users and the directory as well as a brief look at SIP user agents.
Chapter 5, Understanding the XML Dialplan, explains the basics of creating and editing Dialplan extensions to add advanced functionality to a FreeSWITCH install.
Chapter 6, Using XML IVRs and Phrase Macros, discusses how to create menus and sound phrases for interacting with callers as well as the useful Phrase Macro system.
Chapter 7, Dialplan Scripting with Lua, introduces the concept of advanced call handling using the lightweight scripting language Lua.
Chapter 8, Advanced Dialplan Concepts, builds upon the foundation laid in Chapter 5, Understanding the XML Dialplan, and shows how to handle more challenging routing scenarios.
Chapter 9, Moving Beyond the Static XML Configuration, explains concepts necessary for configuring and controlling FreeSWITCH dynamically, such as with a database system.
Chapter 10, Controlling FreeSWITCH Externally, introduces the incredibly powerful Event Socket and the Event Socket library that can be used to access and control a FreeSWITCH server.
Chapter 11, Web-based Call Control with mod_httapi, shows the reader how to use the new mod_httapi
module to create telephony applications controlled via HTTP.
Chapter 12, Handling NAT, provides much needed insight into understanding how NAT causes issues with VoIP and how to work around them.
Chapter 13, VoIP Security, offers suggestions on how to secure VoIP communications from prying eyes as well as securing a FreeSWITCH server against various attacks.
Chapter 14, Advanced Features and Further Reading, highlights some of the more powerful FreeSWITCH features such as conferencing and offers some ideas on where to learn more about FreeSWITCH.
Appendix A, The FreeSWITCH Online Community, gives a brief introduction to the worldwide online community and the tools used to stay in contact.
Appendix B, Migrating from Asterisk to FreeSWITCH, helps those familiar with Asterisk to get up and running quickly with FreeSWITCH.
Appendix C, The History of FreeSWITCH, is a description of how FreeSWITCH came to be, written by FreeSWITCH master architect and lead developer Anthony Minessale.
What you need for this book
At the very least you will need a computer on which you can run FreeSWITCH. Typically this is a server although that isn't an absolute requirement. You will also need at least one SIP device, be it a softphone, desk phone, or analog telephone adapter (ATA) device. Without such a phone you will not be able to make any phone calls into your FreeSWITCH system.
Although not a requirement, having an account with a SIP provider will enable you to make calls to the Public Switched Telephone Network or PSTN.
Who this book is for
This book is for prospective FreeSWITCH administrators as well as enthusiasts who wish to learn more about how to set up, configure, and extend a FreeSWITCH installation. If you are already using FreeSWITCH, you will find that the information in this book compliments what you have already learned from your personal experience.
A solid understanding of basic networking concepts is very important. Previous experience with VoIP is not required, but will certainly make the learning process go faster.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text are shown as follows: "We can see FreeSWITCH status information by issuing the stuts
command at the FreeSWITCH console."
A block of code is set as follows:
<extension name="get voicemail"> <condition field="destination_number" expression="^\*98$"> <action application="answer"/> <action application="voicemail"data="check auth default ${domain_name}"/> </condition> </extension>
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
<extension name="get voicemail">
<condition field="destination_number" expression="^\*98$">
<action application="answer"/>
<action application="voicemail"data="check auth default ${domain_name}"/>
</condition>
</extension>
Any command-line input or output is written as follows:
# /usr/local/freeswitch/bin/fs_cli –x version
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Numerous messages will appear in the Output window."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com>
if you are having a problem with any aspect of the book, and we will do our best to address it.