Asterisk Telephony Solutions: Installing and Customizing Asterisk 1.4 9780321525666, 0321525663

Using the open source Asterisk platform, you can deploy a state-of-the-art VoIP PBX on a low-cost PC or server for a fra

1,173 293 3MB

English Pages 640 [833] Year 2009

Report DMCA / Copyright

DOWNLOAD FILE

Asterisk Telephony Solutions: Installing and Customizing Asterisk 1.4
 9780321525666, 0321525663

Table of contents :
Cover......Page 1
Contents......Page 8
Foreword......Page 28
Preface......Page 30
Acknowledgments......Page 32
About the Authors......Page 34
1.1 What Is Asterisk?......Page 36
1.2.1 The Beginner......Page 38
1.2.3 The Expert......Page 39
1.4 Reader Contributions and Feedback......Page 40
1.5 Additional Resources......Page 41
2.1 Installing Asterisk on the Server......Page 44
2.2.1 Configuring Asterisk......Page 45
2.2.2 Starting Asterisk and Calling "Hello World"......Page 46
2.3 Calling "Hello World" with a SIP Phone......Page 48
2.3.2 Starting Asterisk and the Phone......Page 49
2.4 Building a Minimal Phone System with Two SIP Phones......Page 51
2.4.1 Configuring Voicemail......Page 52
2.5.1 The Originating Context......Page 53
2.6 Calls to and from the Public Switched Telephone Network......Page 55
2.6.1 Calling the PSTN......Page 56
2.6.2 Taking Calls from the PSTN......Page 58
3.1 Contexts......Page 60
3.2 Extensions......Page 61
3.2.1 Fundamental Applications......Page 62
3.2.2 Priorities......Page 63
3.3 Pattern Matching......Page 64
3.3.1 Pattern Elements......Page 66
3.3.2 Testing a Pattern Using dialplan show......Page 67
3.3.3 Pattern-Matching Order......Page 69
3.4.1 Order of Execution When Using Include Statements......Page 72
3.5 The ${EXTEN} Variable and the ${CALLERID(num)} Function......Page 74
3.5.2 ${CALLERID(num)}......Page 75
Chapter 4 Case Study: A Typical Business Telephone System......Page 76
4.1 The Numbering Plan......Page 78
4.2.1 Network......Page 79
4.2.2 Server Hardware......Page 81
4.3 Base Configuration......Page 83
4.3.1 A sip.conf for 100 Users......Page 84
4.3.2 The Dialplan......Page 87
4.4 What Next?......Page 90
5.1 Programming "How-To"......Page 92
5.1.2 Using Set()......Page 93
5.1.3 Labels and Goto()......Page 94
5.2 Variables......Page 95
5.2.2 General Considerations......Page 96
5.2.5 Inheritance of Channel Variables......Page 98
5.2.6 System Channel Variables......Page 99
5.2.7 Manipulating Variables......Page 101
5.3.1 The h Extension......Page 102
5.3.4 The t and T Extensions......Page 103
5.3.5 The s Extension......Page 104
5.4 Macros......Page 105
5.5 Deprecated Features......Page 106
6.1 CLI Commands for AEL......Page 108
6.3 Comparing extensions.conf with extensions.ael......Page 109
6.3.2 Contexts, Extensions, and Priorities......Page 110
6.3.3 Comments......Page 111
6.3.4 Includes......Page 112
6.3.6 Expressions and Variable Assignment......Page 113
6.3.7 Labels, goto, and jump......Page 114
6.3.8 Conditionals......Page 116
6.3.9 Loops......Page 119
6.3.10 Macros......Page 121
6.3.11 Hints......Page 122
6.4 Choosing between extensions.ael and extensions.conf......Page 123
7.1 Network Protocols......Page 124
7.1.1 Transmission Control Protocol......Page 125
7.1.2 User Datagram Protocol......Page 129
7.2 Channels......Page 130
7.4 IAX Versus SIP......Page 132
8.1 Codecs......Page 136
8.1.2 Performance......Page 137
8.1.3 Configuring Codecs......Page 138
8.1.4 Commonly Used Codecs......Page 139
8.2 Integrated Services Digital Network......Page 140
8.2.1 ISDN Basics......Page 141
8.2.2 Choosing an ISDN Card......Page 143
8.2.3 Media Gateways......Page 146
8.3 Analog Telephony......Page 147
8.3.1 Connecting Analog Devices......Page 148
8.3.2 Analog Telephone Adapter......Page 149
9.1.1 An Example Home System......Page 150
9.1.2 An Example Business System......Page 152
9.3 Dialplan Applications......Page 156
9.3.1 VoiceMail......Page 157
9.3.2 VoiceMailMain......Page 158
9.4 voicemail.conf......Page 159
9.4.1 [general]......Page 160
9.4.2 [zonemessages]......Page 164
9.4.4 Mailboxes......Page 166
9.5 Dial-by-Name......Page 168
9.6 Saving Passwords in voicemail.conf......Page 170
Chapter 10 Interactive Voice Response......Page 172
10.1 A Simple IVR......Page 173
10.1.2 Invalid Input (the i Extension)......Page 174
10.2 Multilevel IVR Systems......Page 175
10.3.1 Installing Cepstral TTS......Page 177
11.1 The Asterisk Database......Page 180
11.1.2 Reading Values from the Database......Page 181
11.2 Database Access from the Command-Line Interface......Page 182
11.2.3 Deleting Values from the Database......Page 183
11.3 Database Access from the System Shell......Page 184
11.5.1 Simple Call Forwarding......Page 185
11.5.2 Complex Call Forwarding......Page 186
11.6 Application Example: Calling Card......Page 187
Chapter 12 Queues......Page 190
12.1 Extension for Testing Hold Music......Page 191
12.2 musiconhold.conf......Page 192
12.3 queues.conf......Page 195
12.3.1 Announcement Sound Files......Page 200
12.4 agents.conf......Page 201
12.5.1 Sending Callers to the Queue......Page 203
12.5.2 AgentLogin() and AgentCallbackLogin()......Page 204
12.6 Log File......Page 205
12.6.1 Importing the Queue Log into MySQL......Page 207
13.1.1 Blind Transfer......Page 210
13.2 Call Parking......Page 211
14.1 Installation and the Timing Device......Page 214
14.3 Access from the Dialplan......Page 215
14.4 Announcing the Number of Conference Participants......Page 216
15.1 asterisk -rx "command"......Page 218
15.2.1 Making a Call Automatically......Page 219
15.2.2 Parameters......Page 220
15.3 The Asterisk Manager Interface......Page 221
15.3.2 Talking to the AMI......Page 222
15.3.3 AMI Commands......Page 224
15.3.4 Getting the Number of Voicemail Messages with Expect......Page 225
15.3.5 StarAstAPI for PHP......Page 227
15.3.6 Getting the Number of Mailbox Messages with PHP......Page 228
15.4 The Asynchronous JavaScript Asterisk Manager......Page 230
15.4.1 Getting the Number of Voicemail Messages with AJAM......Page 231
15.4.2 AJAX and AJAM Considerations......Page 232
16.1.1 STDIN......Page 236
16.1.2 STDOUT......Page 237
16.2.1 Perl......Page 238
16.2.2 PHP......Page 241
16.2.3 Ruby and Adhearsion......Page 244
16.2.4 Other Programming Languages......Page 246
17.1 Installing IAXmodem......Page 248
17.1.1 Configuring IAXmodem......Page 250
17.2 Installing Hylafax......Page 252
17.3 Receiving Faxes......Page 257
17.4 Sending Faxes......Page 258
17.5 Sending Received Faxes as E-Mail......Page 259
Chapter 18 Busy Lamp Field, Hints, Pickup......Page 262
18.1.1 sip.conf......Page 263
18.1.2 Hints......Page 264
18.3 Configuring Telephones for BLF......Page 266
18.3.1 BLF on the Aastra 480i......Page 267
18.3.2 Polycom Soundpoint IP 501......Page 269
18.4 Testing the Hints......Page 271
18.5 Configuring Pickup......Page 272
18.5.2 Configuring the Phones for Pickup......Page 273
18.5.3 Configuring Group Pickup......Page 275
18.6 Advanced BLF Indicators in Asterisk 1.6......Page 277
Appendix A: Installation Instructions for Asterisk 1.4......Page 282
A.1 LibPRI......Page 284
A.2 DAHDI......Page 285
A.3 Asterisk......Page 287
Appendix B: Dialplan Applications......Page 292
B.1 AbsoluteTimeout()......Page 298
B.2 AddQueueMember()......Page 299
B.3 ADSIProg()......Page 301
B.4 AgentCallbackLogin()......Page 302
B.5 AgentLogin()......Page 303
B.6 AgentMonitorOutgoing()......Page 305
B.7 AGI()......Page 307
B.8 AlarmReceiver()......Page 311
B.9 AMD()......Page 312
B.10 Answer()......Page 316
B.11 AppendCDRUserField()......Page 317
B.12 Authenticate()......Page 318
B.13 Background()......Page 322
B.14 BackgroundDetect()......Page 325
B.15 Bridge()......Page 327
B.17 ChangeMonitor()......Page 328
B.18 ChanIsAvail()......Page 330
B.19 ChannelRedirect()......Page 332
B.20 ChanSpy()......Page 334
B.21 CheckGroup()......Page 340
B.22 ClearHash()......Page 341
B.23 Congestion()......Page 342
B.24 ContinueWhile()......Page 343
B.25 ControlPlayback()......Page 344
B.26 Curl()......Page 346
B.28 DAHDIBarge()......Page 347
B.29 DAHDIRAS()......Page 349
B.30 DAHDIScan()......Page 350
B.31 DAHDISendKeypadFacility()......Page 351
B.32 DateTime()......Page 352
B.33 DBdel()......Page 353
B.34 DBdeltree()......Page 354
B.35 DBget()......Page 355
B.36 DBput()......Page 356
B.37 DeadAGI()......Page 357
B.38 Dial()......Page 360
B.39 Dictate()......Page 376
B.40 DigitTimeout()......Page 378
B.41 Directory()......Page 379
B.42 DISA()......Page 381
B.43 DumpChan()......Page 386
B.44 DUNDiLookup()......Page 387
B.45 EAGI()......Page 388
B.46 Echo()......Page 391
B.47 EndWhile()......Page 392
B.48 EnumLookup()......Page 393
B.49 Eval()......Page 394
B.50 Exec()......Page 395
B.51 ExecIf()......Page 397
B.52 ExecIfTime()......Page 398
B.53 ExitWhile()......Page 399
B.54 ExtenSpy()......Page 400
B.55 ExternalIVR()......Page 404
B.57 Festival()......Page 407
B.58 Flash()......Page 409
B.59 FollowMe()......Page 411
B.60 ForkCDR()......Page 412
B.61 GetCPEID()......Page 416
B.62 GetGroupCount()......Page 417
B.63 GetGroupMatchCount()......Page 418
B.64 Gosub()......Page 419
B.65 GosubIf()......Page 420
B.66 Goto()......Page 421
B.67 GotoIf()......Page 423
B.68 GotoIfTime()......Page 425
B.69 Hangup()......Page 427
B.70 HasNewVoicemail()......Page 428
B.71 HasVoicemail()......Page 429
B.72 IAX2Provision()......Page 430
B.74 ImportVar()......Page 431
B.76 JabberSend()......Page 433
B.77 JabberStatus()......Page 434
B.79 Log()......Page 436
B.80 LookupBlacklist()......Page 437
B.81 LookupCIDName()......Page 439
B.82 Macro()......Page 440
B.83 MacroExclusive()......Page 443
B.84 MacroExit()......Page 444
B.85 MacroIf()......Page 445
B.86 mailboxExists()......Page 446
B.88 MD5()......Page 448
B.89 MD5Check()......Page 449
B.90 MeetMe()......Page 450
B.91 MeetMeAdmin()......Page 458
B.92 MeetMeChannelAdmin()......Page 460
B.93 MeetMeCount()......Page 461
B.94 Milliwatt()......Page 463
B.95 MinivmAccMess()......Page 464
B.96 MinivmDelete()......Page 465
B.97 MinivmGreet()......Page 466
B.98 MinivmNotify()......Page 467
B.99 MinivmRecord()......Page 468
B.100 MixMonitor()......Page 469
B.101 Monitor()......Page 471
B.102 Morsecode()......Page 475
B.103 MP3Player()......Page 476
B.104 MSet()......Page 477
B.105 MusicOnHold()......Page 478
B.106 NBScat()......Page 480
B.108 NoOp()......Page 481
B.110 Page()......Page 483
B.111 Park()......Page 485
B.112 ParkAndAnnounce()......Page 487
B.113 ParkedCall()......Page 489
B.115 PauseQueueMember()......Page 491
B.116 Pickup()......Page 493
B.117 PickupChan()......Page 495
B.118 Playback()......Page 496
B.119 Playtones()......Page 498
B.120 PrivacyManager()......Page 499
B.122 Progress()......Page 502
B.123 Queue()......Page 503
B.124 QueueLog()......Page 508
B.125 RaiseException()......Page 509
B.126 Random()......Page 510
B.127 Read()......Page 511
B.128 ReadExten()......Page 515
B.129 ReadFile()......Page 516
B.130 RealTime()......Page 517
B.131 RealTimeUpdate()......Page 518
B.132 ReceiveFAX()......Page 519
B.133 Record()......Page 521
B.134 RemoveQueueMember()......Page 524
B.135 ResetCDR()......Page 525
B.136 ResponseTimeout()......Page 526
B.137 RetryDial()......Page 527
B.138 Return()......Page 529
B.139 Ringing()......Page 530
B.141 SayDigits()......Page 531
B.142 SayNumber()......Page 532
B.143 SayPhonetic()......Page 534
B.144 SayUnixTime()......Page 535
B.145 SendDTMF()......Page 537
B.146 SendFAX()......Page 538
B.147 SendImage()......Page 539
B.148 SendText()......Page 540
B.149 SendURL()......Page 542
B.150 Set()......Page 544
B.151 SetAccount()......Page 547
B.152 SetAMAFlags()......Page 548
B.153 SetCallerID()......Page 549
B.154 SetCallerPres()......Page 550
B.155 SetCDRUserField()......Page 551
B.156 SetCIDName()......Page 552
B.157 SetCIDNum()......Page 553
B.158 SetGlobalVar()......Page 554
B.160 SetLanguage()......Page 556
B.161 SetMusicOnHold()......Page 557
B.162 SetRDNIS()......Page 558
B.163 SetTransferCapability()......Page 559
B.165 SIPAddHeader()......Page 561
B.166 SIPdtmfMode()......Page 562
B.167 SIPGetHeader()......Page 563
B.168 SMS()......Page 564
B.169 SoftHangup()......Page 567
B.171 StackPop()......Page 569
B.172 StartMusicOnHold()......Page 570
B.173 StopMixMonitor()......Page 571
B.174 StopMonitor()......Page 572
B.175 StopMusicOnHold()......Page 573
B.176 StopPlaytones()......Page 574
B.177 System()......Page 575
B.178 Transfer()......Page 576
B.179 TryExec()......Page 578
B.180 TrySystem()......Page 579
B.181 TXTCIDName()......Page 580
B.182 UnpauseMonitor()......Page 581
B.183 UnpauseQueueMember()......Page 582
B.184 UserEvent()......Page 583
B.185 Verbose()......Page 585
B.186 VMAuthenticate()......Page 586
B.187 VoiceMail()......Page 588
B.188 VoiceMailMain()......Page 590
B.189 Wait()......Page 592
B.190 WaitExten()......Page 593
B.191 WaitForNoise()......Page 594
B.192 WaitForRing()......Page 595
B.193 WaitForSilence()......Page 596
B.194 WaitMusicOnHold()......Page 598
B.195 WaitUntil()......Page 599
B.196 While()......Page 601
B.197 Zapateller()......Page 602
B.198 ZapBarge()......Page 603
B.199 ZapRAS()......Page 605
B.200 ZapScan()......Page 606
B.201 ZapSendKeypadFacility()......Page 607
Appendix C: Dialplan Functions......Page 610
C.1 AGENT()......Page 611
C.2 ARRAY()......Page 613
C.3 BASE64_DECODE()......Page 614
C.5 BLACKLIST......Page 615
C.6 CALLERID()......Page 616
C.7 CDR()......Page 619
C.8 CHANNEL()......Page 623
C.9 CHECKSIPDOMAIN()......Page 626
C.10 CURL()......Page 627
C.11 CUT()......Page 628
C.12 DB()......Page 629
C.13 DB_DELETE()......Page 630
C.14 DB_EXISTS()......Page 631
C.15 DUNDILOOKUP()......Page 632
C.16 ENUMLOOKUP()......Page 633
C.17 ENV()......Page 635
C.18 EVAL()......Page 636
C.19 EXISTS()......Page 637
C.20 FIELDQTY()......Page 638
C.21 FILTER()......Page 639
C.22 GLOBAL()......Page 640
C.23 GROUP()......Page 641
C.24 GROUP_COUNT()......Page 642
C.26 GROUP_MATCH_COUNT()......Page 643
C.27 IAXPEER()......Page 644
C.28 IF()......Page 646
C.29 IFTIME()......Page 647
C.30 ISNULL()......Page 648
C.31 KEYPADHASH()......Page 649
C.32 LANGUAGE()......Page 650
C.33 LEN()......Page 651
C.34 MATH()......Page 652
C.35 MD5()......Page 653
C.36 MUSICCLASS()......Page 654
C.38 ODBC_USER_DATABASE()......Page 655
C.39 QUEUEAGENTCOUNT()......Page 656
C.40 QUEUE_MEMBER_COUNT()......Page 657
C.41 QUEUE_MEMBER_LIST()......Page 658
C.43 RAND()......Page 659
C.44 REGEX()......Page 661
C.45 SET()......Page 662
C.46 SHA1()......Page 663
C.47 SIPCHANINFO()......Page 664
C.48 SIPPEER()......Page 665
C.49 SIP_HEADER()......Page 668
C.50 SORT()......Page 669
C.51 STAT()......Page 670
C.52 STRFTIME()......Page 672
C.53 STRPTIME()......Page 673
C.54 TIMEOUT()......Page 675
C.55 TXTCIDNAME()......Page 677
C.56 URIDECODE()......Page 678
C.57 URIENCODE()......Page 679
C.58 VMCOUNT()......Page 680
D.1 ANSWER......Page 682
D.3 CHANNEL STATUS......Page 683
D.4 CONTROL STREAM FILE......Page 684
D.6 DATABASE DELTREE......Page 685
D.8 DATABASE PUT......Page 686
D.9 EXEC......Page 687
D.11 GET FULL VARIABLE......Page 688
D.13 GET VARIABLE......Page 689
D.14 GOSUB......Page 690
D.16 NOOP......Page 691
D.18 RECEIVE TEXT......Page 692
D.19 RECORD FILE......Page 693
D.21 SAY DATE......Page 694
D.22 SAY DATETIME......Page 695
D.23 SAY DIGITS......Page 696
D.25 SAY PHONETIC......Page 697
D.26 SAY TIME......Page 698
D.28 SEND TEXT......Page 699
D.30 SET CALLERID......Page 700
D.31 SET CONTEXT......Page 701
D.33 SET MUSIC......Page 702
D.34 SET PRIORITY......Page 703
D.36 STREAM FILE......Page 704
D.38 VERBOSE......Page 705
D.39 WAIT FOR DIGIT......Page 706
E.1 AbsoluteTimeout......Page 708
E.3 AgentLogoff......Page 709
E.5 AGI......Page 710
E.7 Bridge......Page 711
E.9 ChangeMonitor......Page 712
E.11 CoreSettings......Page 713
E.13 CoreStatus......Page 714
E.15 DAHDIDialOffhook......Page 715
E.17 DAHDIDNDon......Page 716
E.19 DAHDIRestart......Page 717
E.20 DAHDIShowChannels......Page 718
E.22 DBDel......Page 719
E.24 DBGet......Page 720
E.26 Events......Page 721
E.28 GetConfig......Page 722
E.29 GetConfigJSON......Page 723
E.31 Hangup......Page 724
E.33 IAXpeerlist......Page 725
E.35 JabberSend......Page 726
E.37 ListCommands......Page 727
E.39 Logoff......Page 728
E.40 MailboxCount......Page 729
E.42 MeetmeList......Page 730
E.44 MeetmeUnmute......Page 731
E.46 ModuleLoad......Page 732
E.48 Originate......Page 733
E.49 Park......Page 734
E.51 PauseMonitor......Page 735
E.52 Ping......Page 736
E.54 QueueAdd......Page 737
E.57 QueuePenalty......Page 738
E.60 Queues......Page 739
E.62 QueueSummary......Page 740
E.64 Reload......Page 741
E.66 SetCDRUserField......Page 742
E.68 ShowDialPlan......Page 743
E.70 SIPpeers......Page 744
E.72 SIPshowpeer......Page 745
E.73 SIPshowregistry......Page 746
E.75 StopMonitor......Page 747
E.77 UpdateConfig......Page 748
E.78 UserEvent......Page 749
E.80 WaitEvent......Page 750
E.81 ZapDialOffhook......Page 751
E.83 ZapDNDon......Page 752
E.85 ZapRestart......Page 753
E.86 ZapShowChannels......Page 754
E.87 ZapTransfer......Page 755
Appendix F: Configuration Templates......Page 756
F.2 Using Templates......Page 757
G.1 AEL......Page 760
G.2 Core......Page 761
G.4 Dialplan Applications and Functions......Page 762
G.6 Audio Formats......Page 764
G.7 Channel Drivers......Page 765
G.9 Asterisk Manager Interface......Page 766
Appendix H: From Zaptel to DAHDI......Page 768
H.1 DAHDI......Page 769
H.2 Interview with Kevin P. Fleming......Page 772
Appendix I: IAX vs. SIP......Page 776
0 PREAMBLE......Page 780
1 APPLICABILITY AND DEFINITIONS......Page 781
3 COPYING IN QUANTITY......Page 783
4 MODIFICATIONS......Page 784
5 COMBINING DOCUMENTS......Page 786
8 TRANSLATION......Page 787
9 TERMINATION......Page 788
11 RELICENSING......Page 789
A......Page 792
B......Page 796
C......Page 797
D......Page 801
E......Page 807
F......Page 809
G......Page 810
H......Page 811
I......Page 812
L......Page 813
M......Page 814
N......Page 816
P......Page 817
Q......Page 819
R......Page 820
S......Page 821
T......Page 824
U......Page 825
V......Page 826
W......Page 827
Z......Page 828

Polecaj historie