O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

FreeSWITCH 1.2 - Second Edition

Book Description

Whether you’re an IT pro or an enthusiast, setting up your own fully-featured telephony system is an exciting challenge, made all the more realistic for beginners by this brilliant book on FreeSWITCH. A 100% practical tutorial.

  • Learn how to install and configure a complete telephony system of your own, even if this is your first time using FreeSWITCH
  • In-depth discussions of important concepts like the dialplan, user directory, NAT handling, and the powerful FreeSWITCH event socket
  • Best practices and expert tips from the FreeSWITCH experts, including the creator of FreeSWITCH, Anthony Minessale

In Detail

FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat-driven products, scaling from a soft-phone to a PBX and even up to an enterprise-class soft-switch. It is always exciting to design and build your own telephony system to suit your needs, but the task is time-consuming and involves a lot of technical skill.

"FreeSWITCH 1.2" comes to your rescue to help you set up a telephony system quickly and securely using FreeSWITCH. It is rich with practical examples and will give you all of the information and skills needed to implement your own PBX system.

You will start with a detailed description of the FreeSWITCH system architecture. Thereafter you will receive step-by-step instructions on how to set up basic and advanced features for your telephony platform.

The book begins by introducing the architecture and workings of FreeSWITCH before detailing how to plan a telephone system and then moves on to the installation, configuration, and management of a feature-packed PBX. You will learn about maintaining a user directory, XML dial plan, and advanced dial plan concepts, call routing, and the extremely powerful Event Socket. You will finally learn about the online community and history of FreeSWITCH.

"FreeSWITCH 1.2" is an indispensable tool for novice and expert alike.

Table of Contents

  1. FreeSWITCH 1.2
    1. Table of Contents
    2. FreeSWITCH 1.2
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt Publishing account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Architecture of FreeSWITCH
      1. A revolution has begun and secrets have been revealed
      2. The FreeSWITCH design – modular, scalable, and stable
      3. Important modules – Endpoint and Dialplan
      4. Complex applications made simple
        1. Voicemail
        2. Multi-party conferencing
        3. The FreeSWITCH API (FSAPI)
        4. The XML registry
        5. Language modules
        6. The demonstration configuration
      5. Summary
    9. 2. Building and Installation
      1. Setting up the FreeSWITCH environment
        1. Operating system
      2. Operating system prerequisites
        1. Linux/Unix
        2. Mac OS X
        3. Windows
      3. Text editors and XML
      4. Downloading the source
      5. Building from the latest code
      6. Compiling FreeSWITCH for Linux/Unix/Mac OS X
        1. Compiling FreeSWITCH
          1. Step 1 – edit modules.conf
          2. Step 2 – run the configure script
          3. Step 3 – run the make and make install utilities
          4. Step 4 – edit modules.conf.xml
          5. Step 5 – install sound and music files
      7. Compiling FreeSWITCH for Windows
        1. Important considerations for Windows users
        2. Building the solution with MSVC/MSVCEE
      8. Starting FreeSWITCH
      9. Running FreeSWITCH in the background
      10. Summary
    10. 3. Test Driving the Example Configuration
      1. Important concepts to understand
      2. Putting FreeSWITCH to work
        1. Controlling FreeSWITCH with the CLI
      3. Configuring a SIP phone to work with FreeSWITCH
        1. SIP settings
        2. X-Lite soft phone
        3. Hard phones
          1. Aastra phones
          2. Polycom phones
          3. Snom phones
      4. Testing the example Dialplan
        1. Test calls for a single phone
          1. The Tetris extension
          2. Echo test
          3. Music on hold
          4. Demonstration IVR
          5. The information application
        2. Test calls for two or more phones
          1. Calling another telephone
          2. Parking a call
          3. Calling a conference
        3. Example Dialplan quick reference
      5. Summary
    11. 4. SIP and the User Directory
      1. Understanding the FreeSWITCH user directory
      2. Working with the FreeSWITCH user directory
      3. User features
      4. Adding a user
      5. Testing voicemail
      6. Groups of users
      7. Connecting to the world with gateways
        1. Setting up a new gateway
        2. Making calls
        3. Receiving calls
        4. Making calls without a gateway
      8. SIP profiles and user agents
      9. Summary
    12. 5. Understanding the XML Dialplan
      1. FreeSWITCH XML Dialplan elements
      2. Contexts
        1. Default
        2. Public
        3. Features
      3. Extensions
        1. Conditions
      4. Call legs and channel variables
      5. Accessing channel variables
      6. Regular expressions
      7. Actions and anti-actions
      8. How Dialplan processing works
      9. Creating a new extension
      10. Important Dialplan applications
        1. bridge
        2. playback
        3. say
        4. play_and_get_digits
        5. ivr
        6. sleep
        7. answer
        8. pre_answer
        9. hangup
        10. set
        11. transfer
      11. Dialstring formats
      12. Summary
    13. 6. Using XML IVRs and Phrase Macros
      1. IVR engine overview
      2. IVR XML configuration file
      3. IVR engine overview
        1. IVR menu definitions
          1. greet-long
          2. greet-short
          3. invalid-sound
          4. exit-sound
          5. timeout
          6. inter-digit-timeout
          7. max-failures
          8. max-timeouts
          9. digit-len
          10. tts-voice
          11. tts-engine
          12. confirm-key
          13. confirm-macro
        2. IVR menu destinations
          1. menu-exec-app
          2. menu-play-sound
          3. menu-back
          4. menu-top
        3. Routing calls to your IVR
        4. Nesting IVRs
      4. Using phrases with IVRs
        1. Calling Phrase Macros
        2. Phrase Macro examples – voicemail
      5. Advanced routing
      6. Summary
    14. 7. Dialplan Scripting with Lua
      1. Getting started with Lua
        1. Running Lua scripts from the Dialplan
      2. Basic Lua syntax
      3. Building voice applications
        1. A simple IVR – interacting with the caller
        2. Conditions and looping
        3. Even more conditions and looping
      4. Advanced IVR concepts
        1. Connecting to a database with LuaSQL
        2. Making a web call with curl
        3. Lua patterns versus regular expressions
      5. Scripting tips
      6. Summary
    15. 8. Advanced Dialplan Concepts
      1. Dialplan overview
      2. General Diaplan concepts
        1. Contexts
        2. Conditions
        3. Actions
      3. Putting it all together
      4. XML Dialplan module review
        1. Extensions
        2. Conditions
        3. Special condition variables
        4. Inline execution
        5. Actions and anti-actions
        6. The regex operator
        7. Nested conditions
      5. Pitfalls to avoid
      6. XML Dialplan applications
        1. mod_dptools
        2. mod_sofia
        3. mod_commands
      7. Utilizing variables
        1. Testing variables with regular expressions
        2. Caller profile fields
        3. Channel variables
          1. Channel variables and call setup
      8. Global variables
      9. Dialplan functions
        1. Real-time condition evaluation
        2. String conditioning
        3. Database queries
        4. SIP contact parameters
      10. Set, export, and legs
        1. Set versus export
      11. Passing variables via call headers
      12. XML Dialplan cookbook
        1. Match by IP address and call a number
        2. Match an IP address and Caller ID
        3. Match a number and strip digits
        4. Match a number, strip digits, and add a prefix
        5. Call a registered device
        6. Try party A, then party B
        7. Route DIDs to extensions
        8. Alternate outbound gateways
        9. Multiple endpoints with enterprise originate
      13. Summary
    16. 9. Moving Beyond the Static XML Configuration
      1. The mod_xml_curl basics
      2. The mod_xml_curl Dialplan
      3. The mod_xml_curl folder
      4. The mod_xml_curl configuration
      5. The mod_xml_curl summary
      6. Generating configurations dynamically with language bindings
      7. Making calls from the command line interface
      8. Using ESL to execute commands
      9. Summary
    17. 10. Controlling FreeSWITCH Externally
      1. General overview
      2. Event system architecture
      3. Event-based modules
        1. mod_event_socket
          1. Configuring event socket settings
          2. Reading events
          3. Minimum event information
      4. Sending events
      5. Events from the Dialplan
        1. mod_event_multicast
      6. FreeSWITCH event system commands
        1. auth <password>
        2. api
        3. bgapi
        4. event
        5. noevents
        6. divert_events
        7. filter
        8. filter delete
        9. nixevents
        10. sendevent
        11. sendmsg <uuid>
        12. execute
        13. hangup
        14. nomedia
        15. log <level>
        16. nolog
        17. linger
        18. nolinger
      7. FreeSWITCH Console application
      8. Event Socket Library
        1. Supported libraries
        2. ESLObject
          1. eslSetLogLevel($loglevel)
        3. ESLevent object
          1. serialize([$format])
          2. setPriority([$number])
          3. getHeader($header_name)
          4. getBody()
          5. getType()
          6. addBody($value)
          7. addHeader($header_name, $value)
          8. delHeader($header_name)
          9. firstHeader()
          10. nextHeader()
        4. ESLconnection object
          1. new($host, $port, $password)
          2. new($fd)
          3. socketDescriptor()
          4. connected()
          5. getInfo()
          6. send($command)
          7. sendRecv($command)
          8. api($command[, $arguments])
          9. bgapi($command[, $arguments])
          10. sendEvent($send_me)
          11. recvEvent()
          12. recvEventTimed($milliseconds)
          13. filter($header, $value)
          14. events($event_type,$value)
          15. execute($app[, $arg][, $uuid])
          16. executeAsync($app[, $arg][, $uuid])
          17. setAsyncExecute($value)
          18. setEventLock($value)
          19. disconnect()
      9. Events in practice
        1. Event Socket Library example – running a command
        2. Examples of sending events to FreeSWITCH
          1. Setting phone lights
            1. Turn lights on
            2. Turn lights off
          2. Rebooting a phone
          3. Requesting phone reconfiguration
          4. Custom notify messages
      10. Summary
    18. 11. Web-based Call Control with mod_httapi
      1. HTTAPI syntax
        1. Work actions
          1. playback
          2. vmname
          3. record
          4. pause
          5. speak
          6. say
          7. execute
          8. sms
          9. dial
          10. recordCall
          11. conference
          12. hangup
          13. break
          14. log
          15. continue
          16. getVar
          17. voicemail
      2. mod_httapi configuration file
        1. Permissions
        2. Exiting
        3. Storing data across successive requests
        4. Some parameters are missing from some requests
        5. Making it easier
      3. The demo IVR – in HTTAPI
      4. Summary
    19. 12. Handling NAT
      1. A brief introduction to NAT
        1. Understanding the evolution of NAT
      2. The four pitfalls of NAT
      3. Demystifying NAT settings in FreeSWITCH
      4. Making media flow
      5. Advanced options and settings
      6. FreeSWITCH on the client side
      7. Other creative uses of FreeSWITCH in a NAT situation
      8. Conclusion
      9. Summary
    20. 13. VoIP Security
      1. Network level protection
        1. Separating interfaces and restricting traffic
          1. Sample setup – simple
          2. Sample setup – complex
        2. VLANs
        3. Intrusion detection
        4. Registration monitoring
          1. Fail2Ban
            1. Filter configurations
            2. Jail configurations
            3. Other considerations
        5. Encryption
      2. Protecting SIP signalling
        1. Choosing between encryption options
          1. Encryption with SSL
            1. Setting Up SSLv2/3
          2. Encryption with TLS
      3. Protecting audio
        1. Encryption with SRTP
          1. Enabling SRTP
        2. Encryption with ZRTP
      4. Protecting passwords
        1. Registration passwords
        2. Voicemail passwords
      5. Summary
    21. 14. Advanced Features and Further Reading
      1. Multi-user conferencing
        1. Configuration
          1. Conference profiles
          2. Caller controls
        2. Advertise
        3. Sending and receiving XMPP events
        4. Connecting callers to the conference
        5. Controlling active conferences
      2. Nibblebill
        1. Use cases
          1. Billing (pre-pay)
          2. Billing (post-pay)
          3. Pay-per-call service billing
          4. Maximum credit and/or fraud prevention
        2. Design goals
        3. Installation and configuration
        4. Database tables
        5. Creating the database table for PostgreSQL
        6. Creating the database table for MySQL
        7. Billing a call
          1. The nibble method (default)
          2. An alternative to nibble billings
        8. Examples
          1. Different rates per user
          2. Single rate for all users
          3. Different rates per area code
          4. Different rates per service delivery
          5. Hang up the call when the balance is depleted
          6. Application/CLI/API commands
            1. Check
            2. Flush
            3. Pause
            4. Resume
            5. Reset
          7. Adding and deducting funds
          8. Enabling session heartbeat
          9. Bill based on B Leg only
      3. Alternative endpoints
        1. Skype and GSM endpoints
          1. Skype with mod_skypopen
        2. GSM with mod_gsmopen
        3. TDM with FreeTDM
      4. Configuration tools and related projects
      5. Web GUIs
        1. FusionPBX
        2. FreePyBX
        3. blue.box
        4. Kazoo
      6. Supporting libraries
        1. Liverpie (Ruby)
        2. FreeSWITCHeR (Ruby)
        3. Librevox (Ruby)
        4. EventSocket (Python/Twisted)
        5. FSSocket (Perl)
      7. Vestec Automatic Speech Recognition
      8. Summary
    22. A. The FreeSWITCH Online Community
      1. The FreeSWITCH mailing lists
      2. Talking in real time via IRC
      3. The FreeSWITCH main website and wiki
        1. The main FreeSWITCH page – www.freeswitch.org
        2. The FreeSWITCH wiki page – wiki.freeswitch.org
      4. The annual ClueCon open source developer conference
    23. B. Migrating from Asterisk to FreeSWITCH
      1. Getting started
        1. Starting and stopping Asterisk or FreeSWITCH
        2. Basic debugging
          1. Asterisk
          2. FreeSWITCH
      2. Configuration files
      3. Two SIP phones
        1. Asterisk configuration
        2. FreeSWITCH configuration
        3. Analysis
      4. Voicemail
        1. Asterisk
        2. FreeSWITCH
        3. Accessing voicemail
          1. Asterisk
          2. FreeSWITCH
      5. Summary
    24. C. The History of FreeSWITCH
      1. Taking things to the next level
      2. New ideas and a new project
      3. The first ClueCon
      4. Introducing FreeSWITCH
    25. Index