Asterisk Gateway Interface 1.4 and 1.6 Programming - Simionovich Nir - E-Book

Asterisk Gateway Interface 1.4 and 1.6 Programming E-Book

Simionovich Nir

0,0
20,53 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

In Detail

Asterisk is the world's leading open-source PBX, telephony engine, and telephony applications toolkit with immense flexibility.

This book will give you a firm understanding of Asterisk Gateway Interface (AGI) development and proper AGI development practices. You will learn how to formulate Atomic AGI-enabled scripts, enabling rapid development within a well-defined Asterisk execution and runtime environment.

This book builds from the simplest form of an Asterisk application, the dialplan-based application, gradually building a full understanding of AGI scripting. The book also introduces a new concept of AGI development named "Atomic AGI" or "Particle Programming". It will introduce you to various techniques of interacting with the user, where user interaction isn't limited to keypad-based input, but also includes recording messages from the user, sending output to the user, and controlling the call flow.

The book takes a pragmatic approach with clear and complete examples, and a service development project ae allowing you to understand the project cycle of developing an Asterisk-based service or application.

Get started with AGI development and use the dynamic features of Asterisk AGI to build your own VoIP-based telephony system

Approach

This friendly, clear tutorial takes a pragmatic approach to developing Asterisk applications, helping you to find the best solutions for your needs. Unlike most books, which simply show you how to do or what to do, this book tries to show you: "why to do?"-thus explaining the logic behind certain Asterisk development paradigms.

Who this book is for

This book is intended for developers wishing to utilize Asterisk, system administrators wishing to gain better control over their Asterisk installation, and telephony service providers wishing to deploy Asterisk-based solutions to their infrastructure. You are expected to have some experience with Asterisk and a basic understanding of programming. No knowledge of Asterisk programming is required.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 241

Veröffentlichungsjahr: 2009

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Asterisk Gateway Interface 1.4 and 1.6 Programming
Credits
About the author
Acknowledgement
About the reviewers
Preface
What this book covers
What you need for this book
Who is this book for
Conventions
Reader feedback
Customer support
Downloading the example code for the book
Errata
Piracy
Questions
1. Installing a 'Vanilla' Asterisk
Downloading Asterisk
Zaptel—Zapata Telephony Driver
DAHDI—Digium Asterisk Hardware Device Interface
Libpri—ISDN PRI Library
Asterisk—the open source PBX
Asterisk-addons—the open source PBX
Asterisk—SVN source packages
Obtaining the source code packages from SVN
Compilation dependencies
Compiling the source code
Compiling and installing Zaptel
Step 1: Configure
Step 2: Define the options you would like to compile
Step 3: Compiling and installing
Compiling and installing DAHDI
Step 1: Compile the kernel module
Step 2: Install the dahdi kernel module
Step 3: Compile the dahdi-tools package
Step 4: Configure the dahdi-tools to be installed
Step 5: Compile and install dahdi-tools
Differences between Zaptel and DAHDI
Compiling and installing libpri
Compiling and installing Asterisk
Step 1: Configure
Step 2: Define the options you would like to compile
Section 1: Applications
Section 3: Channel drivers
Step 3: Compiling the code
Summary
2. Basic IVR Development: Using the Asterisk DialPlan
The dialplan is a set of "finite state machines"
The dialplan syntax
The extension
Inclusion of contexts
The [general] and [global] contexts
Extension pattern matching
Special extensions
Dialplan Switches
Variables, applications, and functions
Variables—built-in and custom
Mathematical manipulation
String manipulation
Substrings
String concatenation
Variables scoping
Applications and functions
Your first IVR application
A simple automatic attendant
Step 1: Flowchart
Step 2: Choice of applications
Application: Answer
Application: Dial
Application: Playback
Application: Background
Application: WaitExten
Application: Hangup
Application: SoftHangup
Application: EndWhile
Step 3: The automatic attendant code
Section 1: The main context body
Section 2: Dialed extensions management
Section 3: Error trapping
Section 4: Debugging
Step 4: Testing
Summary
3. More IVR Development: Input, Recordings, and Call Control
Grabbing and processing user input
The Read application
Branching—Goto, GotoIf, Gosub, and GosubIf
Goto and GotoIf
Writing expressions
Logical operators
Comparison operators
Arithmetic operators
Regular expressions
Operator precedence
Gosub and GosubIf
Exec, ExecIf, and TryExec
Macros—Macro and MacroExclusive
Additional Asterisk applications
Self exploration
Summary
4. A Primer to AGI: Asterisk Gateway Interface
How does AGI work?
EAGI, DeadAGI and FastAGI
EAGI—Enhanced Asterisk Gateway Interface
DeadAGI—execution on hangup
FastAGI—AGI execution via a TCP socket
Asterisk 1.2.X and 1.4.X
Asterisk 1.6.X
FastAGI frameworks
AGI scripting frameworks
The AGI application
The AGI execution flow
The AGI methods API
The ten rules of AGI development
Rule #1: An AGI script should terminate as fast as possible
Rule #2: Blocking applications have no place in AGI
Rule #3: Asterisk channels are stateful—use them
Rule #4: AGI scripts should manipulate data—no more
Rule #5: VM based languages are bad for AGI scripting
Rule #6: Binary-compiled AGI is not always the answer
Rule #7: Balance your scripts with dialplan logic
Rule #8: Balance your scripts with web services
Rule #9: Syslog is your friend—use it
Rule #10: The Internet is for Asterisk
A preface to what's coming ahead
Summary
5. AGI Scripting with PHP
PHP-CLI vs. PHP-CGI
The php.ini configuration file
AGI script permissions
The structure of a PHP based AGI script
Communication between Asterisk and AGI
The AGI Hello-World program
File: helloworld.php
AGI debugging
Summary
6. PHPAGI: An AGI Class Library in PHP
Obtaining PHPAGI
The file structure of PHPAGI
A very simple PHPAGI example
The AGI/Dialplan high-wire act
Introducing Atomic-AGI
Atomic-AGI—a dialplan example
SetSessionID.agi—meet your state maintainer
agiWrapper.agi—an all purpose AGI execution wrapper
A slightly more complex PHPAGI example
db_validate_target.inc.php
db_register_cdr.inc.php
AGI Scripts in popular Asterisk applications
FreePBX™—the most popular Asterisk management GUI
A2Billing™—a pre-paid calling card system
Summary
7. FastAGI: AGI as a TCP Server
FastAGI argument handling
Asterisk 1.2.X and 1.4.X
Asterisk 1.6.X
FastAGI error handling
Asterisk 1.2.X
Asterisk 1.4.X and 1.6.X
FastAGI with PHPAGI and xinetd
Introducing xintetd—the Internet services daemon
Configuring xinetd for FastAGI and PHPAGI
Configuring PHPAGI for FastAGI
The fastagiWrapper.php bootstrap
Performance consideration
FastAGI with PHPAGI and Google
httpd.php:
httpServer.php:
FastAGI.php:
fastagiServer.php:
FastAGI with other tool kits
Asterisk::FastAGI—a PERL module for FastAGI handling
Asterisk-JAVA—a Java package for Asterisk
Summary
8. AMI: The Asterisk Manager Interface
AMI—the history
How does AMI work?
AMI with Asterisk 1.0 and 1.2
AMI with Asterisk 1.4 and 1.6
AMI—understanding basics
Events and Actions
Logging in to the Manager Interface
Sending actions to the Manager Interface
Logging off from the Manager Interface
PHPAGI and the AMI Interface
Direct AMI interface invocation
AMI interface invocation via the PHPAGI class
Interacting with the AMI interface
Sending actions to the AMI inteface
Event callbacks from AMI interface
PHPAGI AMI originate quirk
phpagi-asmanager.php—Originate function
PHPAGI Originate for versions 1.0 and 1.2
PHPAGI Originate for versions 1.4 and 1.6
Asynchronous Originate actions
Click-2-Call and Web-Callback
Demystifying the Asterisk Originate manager action
Welcome to Jabka—the world's favourite Click-2-Call
AMI proxy servers
AJAM—AJAX Enabled Manager
Summary
9. Final Programming Project
ACRG—Asterisk Call Recording Gateway
Requirements
Network connectivity—PSTN
Project implementation guide
Step 1: Analysis of the requirements
Step 2: Understanding operational constraints
Step 3: Detailed call flow charts
Step 4: The Asterisk dialplan context
Step 5: Develop your human interfaces
Step 6: Test, test, and test again
Additional programming projects
Click-2-Call
Jajah.Com
Stateful call masking
Punk'ed call
Date rescue call
Conference bridge
Summary
10. Scaling Asterisk Applications
Scaling Asterisk platforms
Database query caching
Starting up
Using it in a script
Utilization of web services
Introduction to XML-RPC
Structure of an XML-RPC request and response
Apache versus Lighttpd
Virtualization and cloud computing
Full virtualization
Hardware-assisted virtualization
Paravirtualization
Asterisk in a virtualized environment
Summary
Index

Asterisk Gateway Interface 1.4 and 1.6 Programming

Nir Simionovich

Asterisk Gateway Interface 1.4 and 1.6 Programming

Copyright © 2009 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: January 2009

Production Reference: 1220109

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-847194-46-6

www.packtpub.com

Cover Image by Parag Kadam (<[email protected]>)

Credits

Author

Nir Simionovich

Reviewers

Brandon Kruse

Suresh Kumar Singampalli

Kimberly Collins

Acquisition Editor

Rashmi Phadnis

Development Editor

Dhiraj Chandiramani

Technical Editor

Gaurav Datar

Copy Editor

Sumathi Shridhar

Editorial Team Leader

Akshara Aware

Production Editorial Manager

Abhijeet Deobhakta

Project Team Leader

Lata Basantani

Project Coordinator

Lata Basantani

Indexer

Monica Ajmera

Proofreader

Dirk Manuel

Production Coordinator

Rajni R. Thorat

Cover Work

Rajni R. Thorat

About the author

Nir Simionovich has been involved with the open source community in Israel since 1997. His involvement started back in 1997, when he was a student at Technion—Israel's Technology Institute—in Haifa. Nir quickly became involved in organizing open source venues and events, promoting the use of Linux and open source technologies in Israel.

In 1998, Nir started working for an IT consulting company (artNET experts Ltd.), where he began to introduce Linux-based solutions for enterprises and banks. By the year 2000, Nir had become a SAIR/GNU certified Linux trainer and administrator, slowly educating the future generations of Linux admins.

In 2001, Nir moved to the cellular content market, working for a mobile content delivery company (m-Wise Inc.—OTC.BB: MWIS.OB). During his commission at m-Wise, Nir successfully migrated a company—built purely on Windows 2000 and ColdFusion—to open source technologies, such as Mandrake Linux (today Mandriva), Apache Tomcat, and Kannel (an open source SMS/WAP gateway).

By 2006, Nir had co-founded Atelis (Atelis PLC—AIM: ATEL). Atelis is a Digium distributor and integrator. During the course of 2006, Nir developed an Asterisk-based international operator services platform for Bezeq International, which replaced a Nortel DMS-300 switch. This platform is currently in use by Bezeq International in Israel, serving over 4000 customer a day.

In mid 2007, Nir left Atelis to become a freelance Asterisk promoter and consultant. Nir is currently providing Asterisk consulting and development services for various companies, ranging from early-stage start-up companies, through VoIP service providers and VoIP equipment vendors. Nir is the founder of the Israeli Asterisk users group. In his spare time, he acts as the website maintainer of the group, and an Asterisk developer, dealing mainly with the localization aspects of Asterisk to Israel.

Coming to 2008, Nir's company (Greenfield Technologies Ltd) won the Digium Innovation award at AstriCon 2008, in the pioneer division—for its implementation of a phone-based prayer system, allowing people from around the world to pray at the western wall in Jerusalem.

Acknowledgement

I enjoyed writing this book. I hope you will enjoy reading it, and I really look forward to hear from you about your latest Asterisk creation.

I would like to take this opportunity to thank some people:

First of all, I'd like to thank my wife for putting up with my rants and raves about open source—Asterisk, and for putting up with the amount of hardware and mess on my desk, and my complete disregard to anything in the house. Nili, I love you.

To my parents, for putting up with my craziness over the years and the endless nights of me tapping at the console when I was growing up.

To Mark Spencer, thank you for developing Asterisk™ and for creating one of the most innovative tools on the market today. And most importantly, thank you for your help back in 2003, when I needed to install the first BRI interface, and I had no idea what I was doing in there—Mark was back then sitting in the IRC channel, and was one of the biggest helps to me.

To Schuyler Deerman, who actually connected me with Packt for the publishing of my previous book, which has also led to the writing of this book. Schuyler is one of Digium's field marketing people and has become a close and personal friend over the course of our mutual work. Schuyler is currently located in Berlin, Germany.

To Optimus, my first Asterisk™ server, which suffered and suffered and suffered, untill I got it to work as I wanted it. Optimus is currently resting in pieces, somewhere down the pile of servers I have at home.

About the reviewers

Suresh Kumar Singampalli has more than four years of experience in various languages (C/C++, Java and .Net) and technologies for IVR and VOIP (Asterisk, OCS) platforms. Apart from developing products for IVR platforms, he has been doing research on various open source and Microsoft-related VOIP platforms. He works for LeadingC Pvt Ltd., and right now he is doing his research on TextToSpeech and Speech Recognition technologies for embedded and desktop applications.

I would like to thank my brother Sanjeet and my friends—Anantgiri, Mohan, Srinivas, and Pavan, who have helped me in reviewing this book.

Brandon Kruse loves and lives Asterisk. Asterisk has enabled the world to become a better place. Digium is the company that sponsors and produces this software that is revolutionizing the long-commercialized telephony industry.

I would like to say thanks to my family—particularly my dad, Eric Kruse—for molding my mind as a young boy, to find a need and fill it, to think outside the box, and for the numerous amount of advice that I could never pay him back for, and that got me where I am today. And finally, a bigger thanks for pushing me to never give up on my dreams. "Thanks to my mom, for always being there for me".

I would also like to give a token of thanks to Mark Spencer, for giving me this incredible opportunity, for being a pioneer in a dark industry, for being my mentor, friend, and an amazing entrepreneur.

Finally I would thank Lauren, my girlfriend, for always putting up with me, and my engineer type nature during this process. It takes a lot to love a geek, especially when Asterisk takes time away from us, and yet she sticks through it, and even debugs my code!

Kimberly Collins is a California transplant who found her home in Austin, TX. She has worked in the field of Information Technology and communications for over ten years. She has spent the last two years working for one of the largest hosting companies in the world, and is currently one of the lead administrators and developers of their global VOIP infrastructure.

Preface

This is my second book, and I have to admit that I really enjoyed working on this book. While I enjoyed working on my previous book, (the AsteriskNow book from Packt Publishing), I couldn't help but feel that a portion of me has really slipped into the pages of this book.

This book is a developer's book, and it is written for developers by a developer. I see myself as an Asterisk application developer. After developing dozens of platforms over the course of the past six years, all based arround Asterisk, I can honestly say that I've seen mistakes that I made six years ago, still being made today by novice developers.

My role at Greenfield Technologies Ltd. (apart from being the CEO and Founder) is that of a development consultant, where I render various Asterisk consulting services to various companies in Israel and worldwide. Wherever I go, no matter what customer I cater, the mistakes and wrongful paradigms seem to persist. They persist due to a simple reason: there is no school for Asterisk developers. We have web developers, core developers, and database developers. But Asterisk developer is usually either a web developer or a core developer who is assigned a task, or in the worst case, a database developer entrusted with a task that he totally doesn't understand. The developers automatically do what they were taught to do: they superimpose their aggregated knowledge and experience on the Asterisk world, which usually ends up in disaster.

Asterisk is one of the most innovative pieces of open source software created in the past ten years (Asterisk just hit nine years old on December 05, 2008). While Asterisk provides one of the most extensive telephony toolkits available today, its utilization in a commercial application or platform construct isn't as straightforward as it would seem. This book de-mystifies some of the mystic characteristics associated with Asterisk, while at the same exposing some of the well-guarded secrets of professional Asterisk platform developers.

Asterisk requires a new skill set to be developed—one that web developers have no idea of and core developers completely disregard. My aim with this book is to enable you to learn the lessons and values that I've learned over a period of six years from a simple, shrink wrapped, to the point guide. I hope this book will remain on your table as a useful tool.

What this book covers

Chapter 1 introduces the various hardware elements required for installing your Asterisk PBX system, and guides you through the Asterisk installation procedure.

Chapter 2 introduces us to the dialplan—extension, context, and syntax. It then covers the main part—developing a basic IVR (Interactive Voice Response) application using Asterisk dialplan.

Chapter 3 takes us a bit deeper into IVR development, wherein we learn grabbing and processing input. The introduction of the Read application, and the conditional branching and execution, enable a new flexibility that was not available initially.

Chapter 4 is all about AGI—its working, its three types, and the different frameworks. Finally it covers the do's and don'ts that need to be followed for the AGI script to work and function properly.

Chapter 5 introduces you to your first AGI script, using the Hello World program. It also touches upon AGI debugging.

Chapter 6 covers a PHP based AGI class library—PHPAGI. The chapter starts with an explanation of the PHPAGI file structure, and then goes on to cover simple, and finally more complex, PHPAGI examples.

Chapter 7 introduces the basic elements of a FastAGI server, again using PHP and PHPAGI.

Chapter 8 helps understand the Asterisk Manager Interface (AMI)—an Asterisk proprietary Computer Telephony Integration (CTI) interface.

Chapter 9 takes you through the steps of developing a full click-2-call application, using all the concepts you've learned. Chapter 9 can be used as the basis for a large scale service, such as JaJah or RebTel.

Chapter 10 tries to deal with some of the more advanced topics of developing Asterisk applications—mainly scalability and performance issues. By the end of this chapter, the reader should be well-equipped with the information to build the next Verizon Killer application.

Note

Documentation for Asterisk applications are taken directly from the Asterisk source code and/or command line interface. Documentation for PHPAGI is taken from the PHPAGI website.

What you need for this book

In order to utilize this book to the fullest, you will need the following:

A personal computer (PC) running the Linux operating system. We used CentOS for this book, but you may use any distribution that you feel comfortable with. If you would like to get up and running really quickly, you can use the AsteriskNOW (version 1.5) distribution, located at http://www.asterisknow.org. This can also be a Virtual Machine (VM) based system, using VMWARE.A PC that you can use as your workstation for development purposes and web browsing purposes.An IP Phone—either a soft phone or hardware IP phone.A Digium TDM11B card (optional).The Digium TDM11B card provides two analog interfaces—one for a phone line (an FXO) and the other for an analog phone (an FXS).Experience with the Linux shell—basic system administration skills are required.Experience with a programming language. This book is for developers, it doesn't teach you a programming language. Knowledge of PHP is preferred for this book.Finally, you need patience and a pot of coffee—at least for the first three chapters.

Who is this book for

This book is intended for developers wishing to utilize Asterisk, system administrators wishing to gain better control over their Asterisk installation, and telephony service providers wishing to deploy Asterisk-based solutions to their infrastructure. You are expected to have some experience with Asterisk and a basic understanding of programming. No knowledge of Asterisk programming is required.

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: "If we are going to examine the operational flow of the just seen context, it is fairly clear that Asterisk will perform background playback on two files—demo-congrats and demo-instruct"

A block of code will be set as follows:

exten => 3,1,Set(LANGUAGE()=fr) exten => 3,n,Goto(s,restart)

Any command-line input and output is written as follows:

# ./memcached -d -m 2048 -l 192.168.2.52 -p 6636

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this:

"As the immediately preceding screenshot illustrates, issue the make config command in order to install initial configuration files and system init scripts."

Note

Warnings or important notes appear in a box like this.

Note

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 drop an email to <[email protected]>, making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form onwww.packtpub.com or email <[email protected]>.

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 onwww.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 for the book

Visit http://www.packtpub.com/files/code/4466_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata are added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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 the location address or website name immediately so we can pursue a remedy.

Please contact us at <[email protected]>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 <[email protected]>if you are having a problem with some aspect of the book, and we will do our best to address it.

Chapter 1. Installing a 'Vanilla' Asterisk

 

In order to change the world, you have to get your head together first.

  --—Jimi Hendrix

When Mark Spencer initially created Asterisk, he didn't realize the disruptive nature of his code. Just as Jimi Hendrix had a good idea of how he wanted to change the world, so does Mark on where Asterisk is destined to go. Getting our heads together with Asterisk may seem simple, but is more complex than you would imagine. You are probably saying to yourself right now: "Hey I'm a developer with years of experience; I have my head straight and on the money! Let's get coding!" Well, I have some news for you—NO YOU CAN'T!

Over the past five years, as the popularity of Asterisk grew and its install base multiplied at a geometric rate, it suffered an almost identical fate to that of PHP and other open source projects. Asterisk granted the integrators and developers the ability to shape and mould it to suit their needs. However, as Asterisk is an open source project, there was no clear methodology to do so. Thus many people developed a multitude of applications for Asterisk—some turned into huge projects (FreePBX, A2Billing, TrixBox) while others faded away. What made a good project unique? Was it its feature set? Was it a special function that everyone needed? If we examine the early stages of FreePBX (the early versions of FreePBX were called AMP (Asterisk Management Portal) and its current version, you wouldn't believe that they were programmed by the same people. This is because the people who invested their time into the project learned from their mistakes and created better applications. Developers and integrators dealing with Asterisk for the first time are usually fully capable of developing applications that work—at least to some extent. By superimposing their traditional development techniques to the Asterisk world, they usually end up developing an application that would work to an extent, but would fail miserably when dealing with the rapidly expanding IVR (Interactive Voice Response) services.

So how do we get our heads together? Simple! Start from the most basic thing, that is, installing Asterisk from its source code.

Note

At this point, we would assume that you already have a Linux-based desktop or server for you to use during this book. You can also use a virtual machine for this book. All of the examples and screenshots in this book are taken from a server running on a virtual machine, using VMWare.

Downloading Asterisk

The best place to obtain the Asterisk source code would be from the Asterisk community website. Point your browser to http://www.asterisk.org, and you should see the screen shown in the following screenshot, from which you can download the code.

Asterisk is available for download in two distinct versions—a stable release and an SVN release. Apart from Asterisk, there are three additional software packages that you may require for your application to work completely. We shall now explain the usage of the stable software packages, and how to download and compile them. Later on, we shall learn how to download the latest SVN package.

Zaptel—Zapata Telephony Driver

Let's turn our attention to Zaptel.

Note

If you intend to use Asterisk version 1.6.X, please skip this section and go to the next.

The Asterisk website describes Zaptel as:

Kernel interface device drivers for Analog and Digital interface cards. Digium hardware requires Zaptel drivers.

In general, Zaptel provides all of the drivers and kernel modules, required to use Asterisk with a TDM connection. The stock kernel drivers available in the Asterisk distribution are compatible with all Digium hardware and Astribank hardware available from Xorcom. In addition to the kernel support for Digium hardware, the Zaptel module also provides a virtual timer kernel module, which is used by Asterisk for allowing conference calls to be made without the physical timer that is provided by Digium hardware.

Note

Currently, there are various companies manufacturing Zaptel-compatible hardware. However, these hardware devices usually require a patch to the code, or they use an additional software package. Our book will not deal with these.

In general, it is my personal belief that when using an open source product, it is imperative to support the company funding the development—Digium in this case.

The stable Zaptel source code is available as a tar.gz file, from the Digium download site. Zaptel stable source code can be downloaded from http://downloads.digium.com/pub/zaptel/. The current stable release would usually be available with the keyword "current", indicating that this is the current stable release.

Note

At the time of writing this book, the current Zaptel stable release was 1.4.9.2. It is quite likely that by the time this book is published, the Zaptel stable release will be different.

Download the Zaptel source package to your designated Asterisk server, and continue to the next section.

DAHDI—Digium Asterisk Hardware Device Interface

In version 1.6 of Asterisk, Zaptel has been replaced by the DAHDI framework. Unlike Zaptel, which was both a self-enclosed kernel module and a set of tools, the DAHDI framework has separated these into two distinct packages—dahdi-linux and dahdi-tools.

Note

You are probably wondering: "What was wrong with the name Zaptel? Couldn't they just create zaptel-linux and zaptel-tools packages?" Well, the reason for the name change was due to a copyright infringement issue where a calling card company called Zaptel had indicated that the name Zaptel was their trademark, long before Asterisk used it—hence the name change.

The stable DAHDI source code is available as a tar.gz file, from the Digium download site. The dahdi-linux package can be downloaded from http://downloads.digium.com/pub/telephony/dahdi-linux/ and while dahdi-tools package can be downloaded from http://downloads.digium.com/pub/telephony/dahdi-tools/.

If you are using Asterisk 1.6 as the base of your installation, download the dahdi-linux and dahdi-tools packages, and continue to the next section.

Libpri—ISDN PRI Library

The Asterisk website describes Libpri as:

Primary Rate ISDN (PRI) library for T1/E1/J1 interfaces.

In general, libpri provides Asterisk a programmatic API, allowing it to interface with ISDN-type interfaces. If you are not using hardware interfaces with your Asterisk installation, or you are not using an ISDN PRI interface, you don't have to install this library.

The stable libpri source code is available as a tar.gz file, from the Digium download site. Libpri stable source code can be downloaded from http://downloads.digium.com/pub/libpri/. The current stable release would usually be available with the keyword "current", indicating that this is the current stable release.

Note